2022-05-03 23:09:21 -05:00
|
|
|
package noppes.npcs.scripted;
|
|
|
|
|
|
|
|
|
|
import net.minecraft.nbt.NBTTagCompound;
|
|
|
|
|
import net.minecraft.tileentity.TileEntity;
|
|
|
|
|
import net.minecraft.util.math.BlockPos;
|
|
|
|
|
import net.minecraft.world.WorldServer;
|
2022-11-06 00:10:04 -04:00
|
|
|
import noppes.npcs.scripted.interfaces.IBlock;
|
|
|
|
|
import noppes.npcs.scripted.interfaces.INbt;
|
|
|
|
|
import noppes.npcs.scripted.interfaces.ITileEntity;
|
2022-05-03 23:09:21 -05:00
|
|
|
|
|
|
|
|
public class ScriptTileEntity<T extends TileEntity> implements ITileEntity {
|
|
|
|
|
protected T tileEntity;
|
|
|
|
|
|
2022-11-06 00:10:04 -04:00
|
|
|
public ScriptTileEntity(T tileEntity) { this.tileEntity = tileEntity; }
|
2022-05-03 23:09:21 -05:00
|
|
|
|
|
|
|
|
public int getBlockMetadata(){
|
|
|
|
|
return tileEntity.getBlockMetadata();
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-06 00:10:04 -04:00
|
|
|
public ScriptWorld getWorld(){
|
|
|
|
|
return (ScriptWorld) NpcAPI.Instance().getIWorld((WorldServer) tileEntity.getWorldObj());
|
2022-05-03 23:09:21 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public TileEntity getMCTileEntity() {
|
|
|
|
|
return this.tileEntity;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void readFromNBT(INbt nbt){
|
|
|
|
|
this.tileEntity.readFromNBT(nbt.getMCNBT());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public double getDistanceFrom(double x, double y, double z){
|
|
|
|
|
return this.tileEntity.getDistanceFrom(x,y,z);
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-17 18:02:09 -05:00
|
|
|
public IBlock getBlockType(){
|
2022-11-06 00:10:04 -04:00
|
|
|
return NpcAPI.Instance().getIBlock(tileEntity.getWorldObj(), tileEntity.getBlockType(), new BlockPos(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord));
|
2022-05-03 23:09:21 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean isInvalid(){
|
|
|
|
|
return tileEntity.isInvalid();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void invalidate(){
|
|
|
|
|
tileEntity.invalidate();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void validate() {
|
|
|
|
|
tileEntity.validate();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void updateContainingBlockInfo(){
|
|
|
|
|
tileEntity.updateContainingBlockInfo();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public INbt getNBT() {
|
|
|
|
|
NBTTagCompound compound = new NBTTagCompound();
|
|
|
|
|
this.tileEntity.writeToNBT(compound);
|
|
|
|
|
return NpcAPI.Instance().getINbt(compound);
|
|
|
|
|
}
|
|
|
|
|
}
|