Posts posted by Draco18s
-
-
-
Also, oh god, that if-stack checking whether the item given was equal to an array of stuff.
Jesus christ.
Cleaned it up
public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int q, float a, float b, float c) { if (!player.isSneaking()) { boolean hasSpace = false; int giftedVolume = 0; String giftedItem = ""; Random ran = new Random(); int randomNum = ran.nextInt(10); int maxStack = 64; giftedVolume = 1; if (player.inventory.getFirstEmptyStack() != -1) { hasSpace = true; } else { for (int slot = 0; slot < player.inventory.getSizeInventory(); ++slot) { ItemStack itemstack = player.inventory.getStackInSlot(slot); if (itemstack != null && itemstack.isItemEqual(checkStack[randomNum])) { int volume = itemstack.stackSize; if (volume < maxStack) { hasSpace = true; break; } } } } if (hasSpace == true) { ItemStack stack; switch(randomNum) { case 0: stack = new ItemStack(Items.coal,1); giftedItem = "Some coal"; break; case 1: stack = new ItemStack(Items.rotten_flesh,1); giftedItem = "Some rotten meat"; break; case 2: stack = new ItemStack(Items.wheat_seeds,1); giftedItem = "Some seeds"; break; case 3: stack = new ItemStack(Items.bone,1); giftedItem = "A bone"; break; case 4: stack = new ItemStack(Items.flint,1); giftedItem = "A piece of flint"; break; case 5: stack = new ItemStack(Items.fish,1); giftedItem = "Fresh fish"; break; case 6: stack = new ItemStack(Items.bread,1); giftedItem = "A loaf of bread"; break; case 7: stack = new ItemStack(Items.string,1); giftedItem = "A piece of string"; break; case 8: stack = new ItemStack(Items.bowl,1); giftedItem = "A wooden bowl"; break; } player.inventory.addItemStackToInventory(stack); String successMessage = EnumChatFormatting.YELLOW + ">You searched the crate and discovered... " + giftedItem; if(!world.isRemote) { player.addChatComponentMessage(new ChatComponentText(successMessage)); } this.func_150185_e(world, x, y, z); } if (hasSpace == false) { if(!world.isRemote) { player.addChatComponentMessage(new ChatComponentText("Searching this crate would be a waste as your inventory is full!")); } } return true; } else { return false; } } -
-
-
-
What you want is a coremod that operates via ASM.
ASM is a very deep, dark abyss and you will get minimal help figuring out how to make a coremod. Primarily because:
1) You should not be modifying base classes at all ever, doing so can very easily introduce mod conflicts.
2) ASM requires understanding Java bytecode, you will need to know this before you can start, at all.
3) Providing resources on how to coremod will cause more people to go "yay, I can modify base classes!" when they didn't need to.
Given that you are interested in doing this on 1.9, I suggest actually supplying a patch back to Forge as a Pull Request that inserts an event hook where you want it, that way you don't have to modify vanilla classes.
-
-
I don't think my for loop is pointless, because it cycles trough all the metadata.
And then doesn't give a shit what the actual value of the metadata was, because it performed the same check on all of them:
meta == i
It doesn't matter what value
meta
was from the world (because it can only be 0 to 15), at some point during that loop that check will be true.
Following that, because you are doing
return true
in the block-check, as soon as it determines that yes, one of these blocks is what we're looking for it never even fucking checks your loop.
-
-
-
-
but if you want it to print once you have to add @sideOnly before the method I think...
-
-
-
-
-
-
-
-
-
-
And some are weirdly related, like seeds. Seeds are absolutely not the item form of a block, yet when used they create a block, when that block is middle-clicked, you get a seed, and when the block is broken, you get the seed (usually!)
But you can also get seeds from breaking tall grass (which has its own itemblock!)
-
-
[1.7.10] Custom Gui for custom crafting table.
in Modder Support
You've gone all bonkers with the file. The first problem is that BlockPos does not exist in 1.7.10, but you're trying to use it.
This is what the class should look like.