mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-22 00:22:19 +00:00
Custom Item NBT Renderers for TileColorable for Block Picking its NBT Colors
This commit is contained in:
1 parent
768f494631
commit
a2d4c4fd5a
17 files changed
+513
-158
No files matched your search
@@ -12,10 +12,12 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ChatComponentTranslation;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import noppes.npcs.NoppesUtilServer;
|
||||
@@ -25,6 +27,7 @@ import noppes.npcs.blocks.tiles.TileColorable;
|
||||
import java.util.List;
|
||||
|
||||
import static kamkeel.npcs.util.ColorUtil.colorTableInts;
|
||||
import static noppes.npcs.items.ItemNpcTool.BRUSH_COLOR_TAG;
|
||||
|
||||
public class BlockBanner extends BlockContainer{
|
||||
|
||||
@@ -94,6 +97,10 @@ public class BlockBanner extends BlockContainer{
|
||||
TileBanner tile = (TileBanner) par1World.getTileEntity(par2, par3, par4);
|
||||
tile.rotation = l;
|
||||
tile.color = colorTableInts[15 - par6ItemStack.getItemDamage()];
|
||||
if(par6ItemStack.hasTagCompound() && par6ItemStack.getTagCompound().hasKey(BRUSH_COLOR_TAG)){
|
||||
tile.color = par6ItemStack.getTagCompound().getInteger(BRUSH_COLOR_TAG);
|
||||
}
|
||||
|
||||
tile.time = System.currentTimeMillis();
|
||||
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, par6ItemStack.getItemDamage() , 2);
|
||||
@@ -156,4 +163,23 @@ public class BlockBanner extends BlockContainer{
|
||||
else if (p_149681_5_ < 7 && p_149681_1_.getBlock(p_149681_2_, p_149681_3_ + 1, p_149681_4_) == this)
|
||||
p_149681_1_.setBlockToAir(p_149681_2_, p_149681_3_ + 1, p_149681_4_);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) {
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if(meta >= 7)
|
||||
y--;
|
||||
|
||||
TileEntity tileentity = world.getTileEntity(x, y, z);
|
||||
ItemStack stack = new ItemStack(this, 1, world.getBlockMetadata(x, y, z));
|
||||
if (tileentity instanceof TileBanner) {
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
tileentity.writeToNBT(compound);
|
||||
|
||||
NBTTagCompound brushCompound = new NBTTagCompound();
|
||||
brushCompound.setInteger(BRUSH_COLOR_TAG, compound.getInteger(BRUSH_COLOR_TAG));
|
||||
stack.setTagCompound(brushCompound);
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user