mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-21 04:32:39 +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,19 +12,23 @@ 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.AxisAlignedBB;
|
||||
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;
|
||||
import noppes.npcs.blocks.tiles.TileBanner;
|
||||
import noppes.npcs.blocks.tiles.TileColorable;
|
||||
import noppes.npcs.blocks.tiles.TileTallLamp;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static kamkeel.npcs.util.ColorUtil.colorTableInts;
|
||||
import static noppes.npcs.items.ItemNpcTool.BRUSH_COLOR_TAG;
|
||||
|
||||
public class BlockTallLamp extends BlockContainer {
|
||||
|
||||
@@ -90,8 +94,11 @@ public class BlockTallLamp extends BlockContainer {
|
||||
TileColorable tile = (TileColorable) 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);
|
||||
}
|
||||
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, par6ItemStack.getItemDamage() , 2);
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, par6ItemStack.getItemDamage() , 2);
|
||||
par1World.setBlock(par2, par3 + 1, par4, this, par6ItemStack.getItemDamage() + 7, 2);
|
||||
}
|
||||
}
|
||||
@@ -157,4 +164,23 @@ public class BlockTallLamp 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 TileTallLamp) {
|
||||
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