mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-28 02:05:39 +00:00
Hex Color Update
This commit is contained in:
1 parent
3c610e7105
commit
3a00d08304
50 files changed
+456
-360
No files matched your search
@@ -0,0 +1,102 @@
|
||||
package noppes.npcs.blocks.tiles;
|
||||
|
||||
import kamkeel.npcs.util.ColorUtil;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
|
||||
public class TileVariant extends TileEntity {
|
||||
|
||||
public static int variantVersion = 1;
|
||||
|
||||
int version = variantVersion;
|
||||
public int variant = 14;
|
||||
public int rotation;
|
||||
|
||||
public void readFromNBT(NBTTagCompound compound){
|
||||
super.readFromNBT(compound);
|
||||
version = compound.getInteger("CNPCVersion");
|
||||
FixTileData(version, compound, this);
|
||||
variant = compound.getInteger("CNPCVersion");
|
||||
rotation = compound.getInteger("CNPCRotation");
|
||||
}
|
||||
|
||||
public void writeToNBT(NBTTagCompound compound){
|
||||
super.writeToNBT(compound);
|
||||
compound.setInteger("CNPCVersion", version);
|
||||
compound.setInteger("CNPCVariant", variant);
|
||||
compound.setInteger("CNPCRotation", rotation);
|
||||
}
|
||||
|
||||
public boolean canUpdate(){
|
||||
return false;
|
||||
}
|
||||
|
||||
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt){
|
||||
NBTTagCompound compound = pkt.func_148857_g();
|
||||
readFromNBT(compound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket(){
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
writeToNBT(compound);
|
||||
compound.removeTag("Items");
|
||||
S35PacketUpdateTileEntity packet = new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 0, compound);
|
||||
return packet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getRenderBoundingBox(){
|
||||
return AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 1, zCoord + 1);
|
||||
}
|
||||
|
||||
public int powerProvided(){
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
public static void FixTileData(int version, NBTTagCompound compound, TileEntity tileEntity){
|
||||
if(version == variantVersion)
|
||||
return;
|
||||
boolean fixMade = false;
|
||||
if(version < 1){
|
||||
if(compound.hasKey("BannerColor")){
|
||||
int bannerColor = compound.getInteger("BannerColor");
|
||||
if(isColorTile(tileEntity)){
|
||||
compound.setInteger("BrushColor", ColorUtil.colorTableInts[bannerColor]);
|
||||
}
|
||||
compound.setInteger("CNPCVariant", bannerColor);
|
||||
compound.removeTag("BannerColor");
|
||||
fixMade = true;
|
||||
}
|
||||
if(compound.hasKey("BannerRotation")){
|
||||
compound.setInteger("CNPCRotation", compound.getInteger("BannerRotation"));
|
||||
compound.removeTag("BannerRotation");
|
||||
fixMade = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(fixMade)
|
||||
tileEntity.markDirty();
|
||||
}
|
||||
|
||||
public static boolean isColorTile(TileEntity tileEntity){
|
||||
if(tileEntity instanceof TileShortLamp)
|
||||
return true;
|
||||
|
||||
if(tileEntity instanceof TileBanner)
|
||||
return true;
|
||||
|
||||
if(tileEntity instanceof TileWallBanner)
|
||||
return true;
|
||||
|
||||
if(tileEntity instanceof TileCouchWool)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user