Entity exit fixes

This commit is contained in:
paulevsGitch 2021-01-05 02:17:09 +03:00
parent 2fc9418e96
commit 3fde68a14d

View file

@ -16,6 +16,7 @@ import net.minecraft.sound.SoundEvents;
import net.minecraft.util.BlockRotation; import net.minecraft.util.BlockRotation;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction; import net.minecraft.util.math.Direction;
import net.minecraft.util.math.Direction.Axis;
import net.minecraft.util.math.Direction.AxisDirection; import net.minecraft.util.math.Direction.AxisDirection;
import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.Registry;
import net.minecraft.world.Heightmap; import net.minecraft.world.Heightmap;
@ -99,7 +100,7 @@ public class EndPortalBlock extends NetherPortalBlock implements IRenderTypeable
} }
Direction direction = Direction.EAST; Direction direction = Direction.EAST;
BlockPos.Mutable checkPos = basePos.mutableCopy(); BlockPos.Mutable checkPos = basePos.mutableCopy();
for (int step = 1; step < 64; step++) { for (int step = 1; step < 128; step++) {
for (int i = 0; i < (step >> 1); i++) { for (int i = 0; i < (step >> 1); i++) {
checkPos.setY(5); checkPos.setY(5);
int ceil = world.getChunk(basePos).sampleHeightmap(Heightmap.Type.WORLD_SURFACE, checkPos.getX(), checkPos.getZ()) + 1; int ceil = world.getChunk(basePos).sampleHeightmap(Heightmap.Type.WORLD_SURFACE, checkPos.getX(), checkPos.getZ()) + 1;
@ -107,26 +108,22 @@ public class EndPortalBlock extends NetherPortalBlock implements IRenderTypeable
while(checkPos.getY() < ceil) { while(checkPos.getY() < ceil) {
BlockState state = world.getBlockState(checkPos); BlockState state = world.getBlockState(checkPos);
if(state.isOf(this)) { if(state.isOf(this)) {
int offStep; Axis axis = state.get(AXIS);
checkPos = this.findCenter(world, checkPos, state.get(AXIS)); checkPos = this.findCenter(world, checkPos, axis);
if (state.get(AXIS).equals(Direction.Axis.X)) {
if (entity.getMovementDirection().getAxis() == Direction.Axis.X) { Direction frontDir = Direction.from(axis, AxisDirection.POSITIVE).rotateYClockwise();
offStep = entity.getMovementDirection() == Direction.EAST ? 1 : -1; Direction entityDir = entity.getMovementDirection();
float rotation = entity.applyRotation(BlockRotation.CLOCKWISE_90); if (entityDir.getAxis().isVertical()) {
entity.yaw = rotation; entityDir = frontDir;
} else {
offStep = entity.getMovementDirection() == Direction.NORTH ? -1 : 1;
} }
return checkPos.add(0, 0, offStep);
} else { if (frontDir == entityDir || frontDir.getOpposite() == entityDir) {
if (entity.getMovementDirection().getAxis() == Direction.Axis.Z) { return checkPos.offset(entityDir);
offStep = entity.getMovementDirection() == Direction.SOUTH ? -1 : 1;
float rotation = entity.applyRotation(BlockRotation.CLOCKWISE_90);
entity.yaw = rotation;
} else {
offStep = entity.getMovementDirection() == Direction.EAST ? 1 : -1;
} }
return checkPos.add(offStep, 0, 0); else {
entity.applyRotation(BlockRotation.CLOCKWISE_90);
entityDir = entityDir.rotateYClockwise();
return checkPos.offset(entityDir);
} }
} }
checkPos.move(Direction.UP); checkPos.move(Direction.UP);