Fix ITeleporter being ignored when teleporting from the end to the overworld (#6505)
* Fix custom teleporters triggering end credits when returning from the end * Fix setdimension command ignoring position
This commit is contained in:
parent
1a4955f9fd
commit
a740044e21
2 changed files with 12 additions and 11 deletions
|
@ -19,7 +19,8 @@
|
||||||
+ if (!net.minecraftforge.common.ForgeHooks.onTravelToDimension(this, p_212321_1_)) return null;
|
+ if (!net.minecraftforge.common.ForgeHooks.onTravelToDimension(this, p_212321_1_)) return null;
|
||||||
this.field_184851_cj = true;
|
this.field_184851_cj = true;
|
||||||
DimensionType dimensiontype = this.field_71093_bK;
|
DimensionType dimensiontype = this.field_71093_bK;
|
||||||
if (dimensiontype == DimensionType.field_223229_c_ && p_212321_1_ == DimensionType.field_223227_a_) {
|
- if (dimensiontype == DimensionType.field_223229_c_ && p_212321_1_ == DimensionType.field_223227_a_) {
|
||||||
|
+ if (dimensiontype == DimensionType.field_223229_c_ && p_212321_1_ == DimensionType.field_223227_a_ && teleporter instanceof net.minecraft.world.Teleporter) { //Forge: Fix non-vanilla teleporters triggering end credits
|
||||||
this.func_213319_R();
|
this.func_213319_R();
|
||||||
- this.func_71121_q().func_217434_e(this);
|
- this.func_71121_q().func_217434_e(this);
|
||||||
+ this.func_71121_q().removePlayer(this, true); //Forge: The player entity is cloned so keep the data until after cloning calls copyFrom
|
+ this.func_71121_q().removePlayer(this, true); //Forge: The player entity is cloned so keep the data until after cloning calls copyFrom
|
||||||
|
|
|
@ -57,15 +57,6 @@ public class CommandSetDimension
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final ITeleporter PORTALLESS = new ITeleporter()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public Entity placeEntity(Entity entity, ServerWorld currentWorld, ServerWorld destWorld, float yaw, Function<Boolean, Entity> repositionEntity)
|
|
||||||
{
|
|
||||||
return repositionEntity.apply(false);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
private static int execute(CommandSource sender, Collection<? extends Entity> entities, DimensionType dim, BlockPos pos) throws CommandSyntaxException
|
private static int execute(CommandSource sender, Collection<? extends Entity> entities, DimensionType dim, BlockPos pos) throws CommandSyntaxException
|
||||||
{
|
{
|
||||||
entities.removeIf(e -> !canEntityTeleport(e));
|
entities.removeIf(e -> !canEntityTeleport(e));
|
||||||
|
@ -76,7 +67,16 @@ public class CommandSetDimension
|
||||||
// throw INVALID_DIMENSION.create(dim);
|
// throw INVALID_DIMENSION.create(dim);
|
||||||
|
|
||||||
entities.stream().filter(e -> e.dimension == dim).forEach(e -> sender.sendFeedback(new TranslationTextComponent("commands.forge.setdim.invalid.nochange", e.getDisplayName().getFormattedText(), dim), true));
|
entities.stream().filter(e -> e.dimension == dim).forEach(e -> sender.sendFeedback(new TranslationTextComponent("commands.forge.setdim.invalid.nochange", e.getDisplayName().getFormattedText(), dim), true));
|
||||||
entities.stream().filter(e -> e.dimension != dim).forEach(e -> e.changeDimension(dim, PORTALLESS));
|
entities.stream().filter(e -> e.dimension != dim).forEach(e -> e.changeDimension(dim, new ITeleporter()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public Entity placeEntity(Entity entity, ServerWorld currentWorld, ServerWorld destWorld, float yaw, Function<Boolean, Entity> repositionEntity)
|
||||||
|
{
|
||||||
|
Entity repositionedEntity = repositionEntity.apply(false);
|
||||||
|
repositionedEntity.setPositionAndUpdate(pos.getX(), pos.getY(), pos.getZ());
|
||||||
|
return repositionedEntity;
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue