Portal search function fix. Portals now work as intended
This commit is contained in:
parent
c240576185
commit
c394f5a5f0
1 changed files with 30 additions and 23 deletions
|
@ -22,6 +22,7 @@ import net.minecraft.util.registry.Registry;
|
||||||
import net.minecraft.world.Heightmap;
|
import net.minecraft.world.Heightmap;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraft.world.WorldAccess;
|
import net.minecraft.world.WorldAccess;
|
||||||
|
import net.minecraft.world.chunk.Chunk;
|
||||||
import net.minecraft.world.dimension.DimensionType;
|
import net.minecraft.world.dimension.DimensionType;
|
||||||
import ru.betterend.client.render.ERenderLayer;
|
import ru.betterend.client.render.ERenderLayer;
|
||||||
import ru.betterend.interfaces.IRenderTypeable;
|
import ru.betterend.interfaces.IRenderTypeable;
|
||||||
|
@ -102,31 +103,37 @@ public class EndPortalBlock extends NetherPortalBlock implements IRenderTypeable
|
||||||
BlockPos.Mutable checkPos = basePos.mutableCopy();
|
BlockPos.Mutable checkPos = basePos.mutableCopy();
|
||||||
for (int step = 1; step < 128; 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);
|
Chunk chunk = world.getChunk(checkPos);
|
||||||
int ceil = world.getChunk(basePos).sampleHeightmap(Heightmap.Type.WORLD_SURFACE, checkPos.getX(), checkPos.getZ()) + 1;
|
if (chunk != null) {
|
||||||
if (ceil < 5) continue;
|
int ceil = chunk.sampleHeightmap(Heightmap.Type.WORLD_SURFACE, checkPos.getX() & 15, checkPos.getZ() & 15);
|
||||||
while(checkPos.getY() < ceil) {
|
if (ceil > 5) {
|
||||||
BlockState state = world.getBlockState(checkPos);
|
checkPos.setY(ceil);
|
||||||
if(state.isOf(this)) {
|
while (checkPos.getY() > 5) {
|
||||||
Axis axis = state.get(AXIS);
|
BlockState state = world.getBlockState(checkPos);
|
||||||
checkPos = this.findCenter(world, checkPos, axis);
|
if (state.isOf(this)) {
|
||||||
|
System.out.println("Out: " + checkPos);
|
||||||
Direction frontDir = Direction.from(axis, AxisDirection.POSITIVE).rotateYClockwise();
|
|
||||||
Direction entityDir = entity.getMovementDirection();
|
Axis axis = state.get(AXIS);
|
||||||
if (entityDir.getAxis().isVertical()) {
|
checkPos = this.findCenter(world, checkPos, axis);
|
||||||
entityDir = frontDir;
|
|
||||||
}
|
Direction frontDir = Direction.from(axis, AxisDirection.POSITIVE).rotateYClockwise();
|
||||||
|
Direction entityDir = entity.getMovementDirection();
|
||||||
if (frontDir == entityDir || frontDir.getOpposite() == entityDir) {
|
if (entityDir.getAxis().isVertical()) {
|
||||||
return checkPos.offset(entityDir);
|
entityDir = frontDir;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
entity.applyRotation(BlockRotation.CLOCKWISE_90);
|
if (frontDir == entityDir || frontDir.getOpposite() == entityDir) {
|
||||||
entityDir = entityDir.rotateYClockwise();
|
return checkPos.offset(entityDir);
|
||||||
return checkPos.offset(entityDir);
|
}
|
||||||
|
else {
|
||||||
|
entity.applyRotation(BlockRotation.CLOCKWISE_90);
|
||||||
|
entityDir = entityDir.rotateYClockwise();
|
||||||
|
return checkPos.offset(entityDir);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
checkPos.move(Direction.DOWN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
checkPos.move(Direction.UP);
|
|
||||||
}
|
}
|
||||||
checkPos.move(direction);
|
checkPos.move(direction);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue