2022-05-03 23:09:21 -05:00
|
|
|
package noppes.npcs.scripted;
|
|
|
|
|
|
|
|
|
|
import net.minecraft.nbt.NBTTagCompound;
|
|
|
|
|
import net.minecraft.tileentity.TileEntity;
|
2022-11-15 15:25:53 -05:00
|
|
|
import noppes.npcs.api.*;
|
2022-05-03 23:09:21 -05:00
|
|
|
|
|
|
|
|
public class ScriptTileEntity<T extends TileEntity> implements ITileEntity {
|
|
|
|
|
protected T tileEntity;
|
2022-11-06 01:25:28 -06:00
|
|
|
protected IWorld world;
|
2022-05-03 23:09:21 -05:00
|
|
|
|
2022-11-06 01:25:28 -06:00
|
|
|
public ScriptTileEntity(T tileEntity) {
|
|
|
|
|
this.tileEntity = tileEntity;
|
|
|
|
|
this.world = NpcAPI.Instance().getIWorld(tileEntity.getWorldObj());
|
|
|
|
|
}
|
2022-05-03 23:09:21 -05:00
|
|
|
|
|
|
|
|
public int getBlockMetadata(){
|
|
|
|
|
return tileEntity.getBlockMetadata();
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-06 01:25:28 -06:00
|
|
|
public IWorld getWorld(){
|
|
|
|
|
return world;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setWorld(IWorld world) {
|
|
|
|
|
this.tileEntity.setWorldObj(world.getMCWorld());
|
|
|
|
|
this.world = world;
|
2022-05-03 23:09:21 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public TileEntity getMCTileEntity() {
|
|
|
|
|
return this.tileEntity;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-06 01:25:28 -06:00
|
|
|
public void markDirty()
|
|
|
|
|
{
|
|
|
|
|
this.tileEntity.markDirty();
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-03 23:09:21 -05:00
|
|
|
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-11-06 01:25:28 -06:00
|
|
|
public double getDistanceFrom(IPos pos){
|
2023-07-07 17:51:51 -05:00
|
|
|
return this.getDistanceFrom(pos.getXD(),pos.getYD(),pos.getZD());
|
2022-11-06 01:25:28 -06:00
|
|
|
}
|
|
|
|
|
|
2022-05-17 18:02:09 -05:00
|
|
|
public IBlock getBlockType(){
|
2022-11-06 01:25:28 -06:00
|
|
|
return NpcAPI.Instance().getIBlock(world, 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);
|
|
|
|
|
}
|
|
|
|
|
}
|