equivalent-exchange-3/src/main/java/com/pahimar/ee3/util/TileEntityDataHelper.java
2023-01-03 17:47:36 +01:00

80 lines
2.5 KiB
Java

package com.pahimar.ee3.util;
import java.util.UUID;
import com.pahimar.ee3.tileentity.TileEntityEE;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
public class TileEntityDataHelper {
private static TileEntityDataHelper tileEntityDataHelper = null;
private TileEntityDataHelper() {}
public static TileEntityDataHelper getInstance() {
if (tileEntityDataHelper == null) {
tileEntityDataHelper = new TileEntityDataHelper();
}
return tileEntityDataHelper;
}
public Class getTileEntityClass(World world, int xCoord, int yCoord, int zCoord) {
if (!world.isRemote) {
return world.getTileEntity(xCoord, yCoord, zCoord).getClass();
}
return null;
}
public ForgeDirection
getOrientation(World world, int xCoord, int yCoord, int zCoord) {
if (!world.isRemote
&& world.getTileEntity(xCoord, yCoord, zCoord) instanceof TileEntityEE) {
return ((TileEntityEE) world.getTileEntity(xCoord, yCoord, zCoord))
.getOrientation();
}
return null;
}
public short getState(World world, int xCoord, int yCoord, int zCoord) {
if (!world.isRemote
&& world.getTileEntity(xCoord, yCoord, zCoord) instanceof TileEntityEE) {
return ((TileEntityEE) world.getTileEntity(xCoord, yCoord, zCoord))
.getState();
}
return Short.MIN_VALUE;
}
public String getCustomName(World world, int xCoord, int yCoord, int zCoord) {
if (!world.isRemote
&& world.getTileEntity(xCoord, yCoord, zCoord) instanceof TileEntityEE) {
return ((TileEntityEE) world.getTileEntity(xCoord, yCoord, zCoord))
.getCustomName();
}
return null;
}
public UUID getOwnerUUID(World world, int xCoord, int yCoord, int zCoord) {
if (!world.isRemote
&& world.getTileEntity(xCoord, yCoord, zCoord) instanceof TileEntityEE) {
return ((TileEntityEE) world.getTileEntity(xCoord, yCoord, zCoord))
.getOwnerUUID();
}
return null;
}
public String getOwnerName(World world, int xCoord, int yCoord, int zCoord) {
if (!world.isRemote
&& world.getTileEntity(xCoord, yCoord, zCoord) instanceof TileEntityEE) {
return ((TileEntityEE) world.getTileEntity(xCoord, yCoord, zCoord))
.getOwnerName();
}
return null;
}
}