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:
Richard Freimer 2020-02-17 11:16:46 -05:00 committed by GitHub
parent 1a4955f9fd
commit a740044e21
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 11 deletions

View file

@ -19,7 +19,8 @@
+ if (!net.minecraftforge.common.ForgeHooks.onTravelToDimension(this, p_212321_1_)) return null;
this.field_184851_cj = true;
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_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

View file

@ -56,15 +56,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
{
@ -76,7 +67,16 @@ public class CommandSetDimension
// 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 -> 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;
}