Fix beacon reading

This commit is contained in:
grimmauld 2020-09-05 12:33:16 +02:00
parent 770fbd6aaa
commit 2d94838a3e

View file

@ -21,13 +21,11 @@ import net.minecraft.particles.ParticleTypes;
import net.minecraft.tileentity.BeaconTileEntity; import net.minecraft.tileentity.BeaconTileEntity;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.*;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceContext;
import net.minecraft.util.math.RayTraceContext.BlockMode; import net.minecraft.util.math.RayTraceContext.BlockMode;
import net.minecraft.util.math.RayTraceContext.FluidMode; import net.minecraft.util.math.RayTraceContext.FluidMode;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.gen.Heightmap;
public class ChromaticCompoundItem extends Item { public class ChromaticCompoundItem extends Item {
@ -117,7 +115,11 @@ public class ChromaticCompoundItem extends Item {
// Is inside beacon beam? // Is inside beacon beam?
boolean isOverBeacon = false; boolean isOverBeacon = false;
BlockPos.Mutable testPos = new BlockPos.Mutable(entity.getPosition()); int entityX = MathHelper.floor(entity.getX());
int entityZ = MathHelper.floor(entity.getZ());
int localWorldHeight = world.getHeight(Heightmap.Type.WORLD_SURFACE, entityX, entityZ);
if (entity.getY() > localWorldHeight) {
BlockPos.Mutable testPos = new BlockPos.Mutable(entityX, localWorldHeight, entityZ);
while (testPos.getY() > 0) { while (testPos.getY() > 0) {
testPos.move(Direction.DOWN); testPos.move(Direction.DOWN);
BlockState state = world.getBlockState(testPos); BlockState state = world.getBlockState(testPos);
@ -133,6 +135,7 @@ public class ChromaticCompoundItem extends Item {
break; break;
} }
} }
}
if (isOverBeacon) { if (isOverBeacon) {
ItemStack newStack = AllItems.REFINED_RADIANCE.asStack(); ItemStack newStack = AllItems.REFINED_RADIANCE.asStack();