eio conduct compact and fix transfer item and fluid in differentdirections

This commit is contained in:
GlodBlock committed 2022-10-01 14:44:34 +08:00
1 parent 292a70ab6e
commit c6f7c17854
3 files changed
+81 -9

No files matched your search

@@ -1,30 +1,49 @@
package com.glodblock.github.util;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import javax.annotation.Nonnull;
import java.util.Objects;
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);
return new BlockPos(this.x + face.offsetX, this.y + face.offsetY, this.z + face.offsetZ, this.w);
}
public TileEntity getTileEntity() {
if (w != null) {
return w.getTileEntity(x, y, z);
}
return null;
}
public int getX() {
@@ -39,11 +58,15 @@ public class BlockPos {
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;
return pos.x == x && pos.y == y && pos.z == z && Objects.equals(pos.w, w);
}
return false;
}