diff --git a/src/main/java/makeo/gadomancy/client/renderers/item/ItemRenderRemoteJar.java b/src/main/java/makeo/gadomancy/client/renderers/item/ItemRenderRemoteJar.java index 2d2f4c5..004297f 100644 --- a/src/main/java/makeo/gadomancy/client/renderers/item/ItemRenderRemoteJar.java +++ b/src/main/java/makeo/gadomancy/client/renderers/item/ItemRenderRemoteJar.java @@ -3,6 +3,7 @@ package makeo.gadomancy.client.renderers.item; import makeo.gadomancy.client.renderers.tile.RenderTileRemoteJar; import makeo.gadomancy.common.blocks.tiles.TileRemoteJar; import makeo.gadomancy.common.registration.RegisteredBlocks; +import makeo.gadomancy.common.utils.NBTHelper; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.item.ItemStack; import net.minecraft.src.FMLRenderAccessLibrary; @@ -38,6 +39,10 @@ public class ItemRenderRemoteJar extends ItemRenderTileEntity { tile.amount = 0; } + if(stack.hasTagCompound()) { + tile.networkId = NBTHelper.getUUID(stack.getTagCompound(), "networkId"); + } + super.renderItem(type, stack, data); GL11.glPushMatrix(); diff --git a/src/main/java/makeo/gadomancy/client/renderers/tile/RenderTileRemoteJar.java b/src/main/java/makeo/gadomancy/client/renderers/tile/RenderTileRemoteJar.java index 71e47af..06784aa 100644 --- a/src/main/java/makeo/gadomancy/client/renderers/tile/RenderTileRemoteJar.java +++ b/src/main/java/makeo/gadomancy/client/renderers/tile/RenderTileRemoteJar.java @@ -2,6 +2,7 @@ package makeo.gadomancy.client.renderers.tile; import makeo.gadomancy.client.models.ModelJarPot; import makeo.gadomancy.client.util.FakeWorld; +import makeo.gadomancy.common.blocks.BlockRemoteJar; import makeo.gadomancy.common.utils.SimpleResourceLocation; import net.minecraft.client.Minecraft; import net.minecraft.entity.player.EntityPlayer; @@ -41,7 +42,7 @@ public class RenderTileRemoteJar extends TileJarRenderer { renderer.func_147497_a(this.field_147501_a); if(field_147501_a.field_147553_e != null) { - renderer.renderTileEntityAt(createFakeTile(tile, true), 0, 0, 0, partialTicks); + renderer.renderTileEntityAt(createFakeTile(tile, BlockRemoteJar.getJarTile(tile).networkId != null), 0, 0, 0, partialTicks); } GL11.glPopMatrix(); diff --git a/src/main/java/makeo/gadomancy/common/items/ItemBlockRemoteJar.java b/src/main/java/makeo/gadomancy/common/items/ItemBlockRemoteJar.java index a14817b..cf32cfa 100644 --- a/src/main/java/makeo/gadomancy/common/items/ItemBlockRemoteJar.java +++ b/src/main/java/makeo/gadomancy/common/items/ItemBlockRemoteJar.java @@ -7,6 +7,7 @@ import makeo.gadomancy.common.blocks.BlockRemoteJar; import makeo.gadomancy.common.blocks.tiles.TileRemoteJar; import makeo.gadomancy.common.blocks.tiles.TileStickyJar; import makeo.gadomancy.common.registration.RegisteredBlocks; +import makeo.gadomancy.common.registration.RegisteredItems; import makeo.gadomancy.common.utils.NBTHelper; import makeo.gadomancy.common.utils.StringHelper; import net.minecraft.block.Block; @@ -16,9 +17,11 @@ import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ChatComponentTranslation; import net.minecraft.util.StatCollector; import net.minecraft.world.World; import thaumcraft.api.aspects.AspectList; +import thaumcraft.api.wands.IWandTriggerManager; import thaumcraft.common.blocks.ItemJarFilled; import thaumcraft.common.config.ConfigItems; @@ -45,8 +48,23 @@ public class ItemBlockRemoteJar extends ItemBlock { } @Override - public ItemStack onItemRightClick(ItemStack p_77659_1_, World p_77659_2_, EntityPlayer p_77659_3_) { - return super.onItemRightClick(p_77659_1_, p_77659_2_, p_77659_3_); + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { + if(!world.isRemote) { + if(player.isSneaking()) { + NBTTagCompound compound = NBTHelper.getData(stack); + if(compound.hasKey("networkId")) { + compound.removeTag("networkId"); + + if(compound.hasNoTags()) { + stack.setTagCompound(null); + } + + player.addChatComponentMessage(new ChatComponentTranslation("gadomancy.info.RemoteJar.clear")); + } + } + } + + return super.onItemRightClick(stack, world, player); } @Override @@ -60,21 +78,31 @@ public class ItemBlockRemoteJar extends ItemBlock { if (tile != null) { if(!world.isRemote) { NBTTagCompound compound = NBTHelper.getData(stack); + if(!player.isSneaking()) { + UUID networkId = null; + if(tile.networkId == null) { + player.addChatComponentMessage(new ChatComponentTranslation("gadomancy.info.RemoteJar.new")); + networkId = UUID.randomUUID(); + tile.networkId = networkId; + tile.markForUpdate(); + } else { + UUID current = NBTHelper.getUUID(compound, "networkId"); + if(current == null || !current.equals(tile.networkId)) { + player.addChatComponentMessage(new ChatComponentTranslation("gadomancy.info.RemoteJar.connected")); + networkId = tile.networkId; + } + } - UUID networkId = tile.networkId; - if(networkId == null) { - networkId = UUID.randomUUID(); - tile.networkId = networkId; - tile.markForUpdate(); + if(networkId != null) { + NBTHelper.setUUID(compound, "networkId", networkId); + } } - - NBTHelper.setUUID(compound, "networkId", networkId); return true; } else { - //TODO: message - return super.onItemUseFirst(stack, player, world, x, y, z, side, hitX, hitY, hitZ); + if(player.isSneaking()) { + return true; + } } - } return false; } diff --git a/src/main/resources/assets/gadomancy/lang/en_US.lang b/src/main/resources/assets/gadomancy/lang/en_US.lang index ee7a025..44e9900 100644 --- a/src/main/resources/assets/gadomancy/lang/en_US.lang +++ b/src/main/resources/assets/gadomancy/lang/en_US.lang @@ -47,4 +47,8 @@ gadomancy.nodes.growing=Growing gadomancy.info.InfusionClaw.owner=You are now the owner. gadomancy.info.InfusionClaw.waila=ยง7Owner: -gadomancy.info.InfusionClaw.lock=Keep useable wand \ No newline at end of file +gadomancy.info.InfusionClaw.lock=Keep useable wand + +gadomancy.info.RemoteJar.new=Created new jar network +gadomancy.info.RemoteJar.clear=Disconnected from current jar network +gadomancy.info.RemoteJar.connected=Connected to existing jar network \ No newline at end of file