Files
AE2FluidCraft-Rework/src/main/java/com/glodblock/github/util/BlockPos.java
T
asdflj 78e9291fc6 Certus Quartz Tank add waila support
fluid packet decode add support to use conduit to export fluid
2023-02-27 16:50:29 +08:00

79 lines
1.7 KiB
Java

package com.glodblock.github.util;
import java.util.Objects;
import javax.annotation.Nonnull;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
public class BlockPos {
private final int x;
private final int y;
private final int z;
private final World w;
public BlockPos(int x, int y, int z) {
this.x = x;
this.y = y;
this.z = z;
this.w = null;
}
public BlockPos(int x, int y, int z, World w) {
this.x = x;
this.y = y;
this.z = z;
this.w = w;
}
public BlockPos(@Nonnull TileEntity te) {
this.x = te.xCoord;
this.y = te.yCoord;
this.z = te.zCoord;
this.w = te.getWorldObj();
}
public BlockPos getOffSet(ForgeDirection face) {
return new BlockPos(this.x + face.offsetX, this.y + face.offsetY, this.z + face.offsetZ, this.w);
}
public BlockPos getOffSet(int x, int y, int z) {
return new BlockPos(this.x + x, this.y + y, this.z + z, this.w);
}
public TileEntity getTileEntity() {
if (w != null) {
return w.getTileEntity(x, y, z);
}
return null;
}
public int getX() {
return x;
}
public int getY() {
return y;
}
public int getZ() {
return z;
}
public World getWorld() {
return w;
}
@Override
public boolean equals(Object obj) {
if (obj instanceof BlockPos) {
BlockPos pos = (BlockPos) obj;
return pos.x == x && pos.y == y && pos.z == z && Objects.equals(pos.w, w);
}
return false;
}
}