
Bugzoo
Members-
Posts
268 -
Joined
-
Last visited
Everything posted by Bugzoo
-
I know how to get the held item. I just want to know how I can decrease 1 item from that stack
-
Or in other words, HOW do I decrement the stack size
-
Ok, I've now got this code player.inventory.setInventorySlotContents(player.inventory.currentItem, null); But that takes the whole stack away, how do I only take 1 away?
-
I want to consume one log (ex. spruce) everytime I right click on a block. Here is where I've got so far player.inventory.consumeInventoryItem(Item.getItemFromBlock(Blocks.log)); But that code consume only oak log, but I want it to consume spruce
-
Yea, so sorry about so much fuss over me being blind https://www.youtube.com/watch?v=YhSXAyybEIM
-
OMFG! I just realized I was running another if statement somewhere in the method which checked if the block was a log, and if it was it ran some code. That was the problem. But, on a sidenote, i'm not new to this. I have been programming in java for 4 years, programming minecraft mods for 2 years. Published 3 mods. So, i'm not really new to this.
-
When I right click with oak it prints this [com.bugzoo.GranterMod.BlockGranter:onBlockActivated:50]: Right clicked with: net.minecraft.item.ItemMultiTexture@1c29de2:0 true true true When I right click with any other type of log it prints out this [com.bugzoo.GranterMod.BlockGranter:onBlockActivated:50]: Right clicked with: net.minecraft.item.ItemMultiTexture@1c29de2:3 true false false
-
I just noticed something. That line of code does work. So if I did if(hand.getItemDamage() == 0) The if statement would run, only if the block is Spruce or Dark Oak. Though if I do this if(hand.getItem() == Item.getItemFromBlock(Blocks.log) && hand.getItemDamage() == 0) It runs no-matter what log it is.
-
? That doesn't work.
-
I know that, but how do I check the metadata?
-
Yea, so this if statement if(hand.getItem() == Item.getItemFromBlock(Blocks.log)) Runs the code no-matter what log it is. I only want it to run if it is birch
-
Yea, thats what i'm trying to do, but that code doesn't work. It runs the method no-matter what log it is
-
Ok, the way my code works, is if you right click with a birch log it runs the code within the if statement, so why shouldn't it go in the if statement?
-
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9){ if(player.getCurrentEquippedItem() != null) { ItemStack hand = player.getCurrentEquippedItem(); if(hand.getItem() == Item.getItemFromBlock(Blocks.log) && hand.getItemDamage() == 1) { player.inventory.addItemStackToInventory(new ItemStack(Blocks.log, 1, 1)); player.inventory.consumeInventoryItem(Item.getItemFromBlock(Blocks.log)); RenderGranter.isAnimated = true; RenderGranter.renderOak = true; System.out.println(hand.getItem().getMetadata(1)); world.spawnEntityInWorld((new EntityLightningBolt(world, x, y+1, z))); world.createExplosion((Entity)player, (double)x, (double)y, (double)z, 2F, false); } } }
-
if(player.getCurrentEquippedItem() != null) { ItemStack hand = player.getCurrentEquippedItem(); if(hand.getItem() == Item.getItemFromBlock(Blocks.log) && hand.getItemDamage() == 1) { player.inventory.addItemStackToInventory(new ItemStack(Blocks.log, 1, 1)); player.inventory.consumeInventoryItem(Item.getItemFromBlock(Blocks.log)); RenderGranter.isAnimated = true; RenderGranter.renderOak = true; System.out.println(hand.getItem().getMetadata(1)); world.spawnEntityInWorld((new EntityLightningBolt(world, x, y+1, z))); world.createExplosion((Entity)player, (double)x, (double)y, (double)z, 2F, false); } } }
-
How do I check for birch specifically?
-
It runs the method if you right click with any type of wood
-
Thanks, that works, but now going back in time to this. I've got this code if(hand.getItem() == Item.getItemFromBlock(Blocks.log) && hand.getItemDamage() == 1) But this doesn't work
-
I've got this code player.inventory.setInventorySlotContents(int, itemstack); So what arguments do I have to put in?
-
Lol, well how do I get the slot?
-
Tried this and it crashed my game player.inventory.currentItem = (Integer) null;
-
I've got that, but now I need to consume the birch wood player.inventory.consumeInventoryItem(Item.getItemFromBlock(Blocks.log));
-
Ok, that works for oak wood, but how do I do it for birch using hand.getItemDamage?
-
I want to check if Birch wood is in the players hand if(hand.getItem() == Blocks.log) I have this code, but I get an error and thats oak and not birch
-
The diamond block that I render on my item