TheGreyGhost
Members-
Posts
3280 -
Joined
-
Last visited
-
Days Won
8
Everything posted by TheGreyGhost
-
[Solved] Getting block's textures - Sided and Metadata textures
TheGreyGhost replied to joaopms's topic in Modder Support
Hi Is this what you're looking for? Block. /** * From the specified side and block metadata retrieves the blocks texture. Args: side, metadata */ public Icon getIcon(int par1, int par2) -TGG -
Hi Do you know how to use breakpoints? If so I suggest you add a breakpoint in your renderAll, then trace into your getCableConnectings to see why it's not working. Otherwise, you could add logging code to your methods to see what's happening. public static boolean getCableConnectings(World world1, int x1, int y1, int z1, String direction) { world = world1; x = x1; y = y1; z = z1; System.out.println("getCableConnectings (" + x1 + "," + y1 + "," + z1 + "):" + direction); return isConnecting(direction); } public static int getNorthBlock() { System.out.println("getNorthBlock (" + (x-1) + "," + y + "," + z +"):" +world.getBlockId(x-1, y, z)); return world.getBlockId(x-1, y, z); } public static int getSouthBlock() { System.out.println("getSouthBlock (" + (x+1) + "," + y + "," + z +"):" +world.getBlockId(x+1, y, z)); return world.getBlockId(x+1, y, z); } {etc} It looks to me like your blockIDs probably aren't right for some reason. -TGG
-
Hi OK I think I understand better. A couple of further questions.. if you modify your code to this, what do you see? Are the Extensions rendering in all six directions properly? Or just the middle? public void renderAll(World world, int x, int y, int z) { Middle.render(0.0625F); ExtensionNorth.render(0.0625F); ExtensionEast.render(0.0625F); ExtensionSouth.render(0.0625F); ExtensionWest.render(0.0625F); ExtensionDown.render(0.0625F); ExtensionUp.render(0.0625F); } -TGG
-
Hi I've spent a few minutes looking at your posts and code and to be honest I really don't understand what it is supposed to do, or how it is supposed to work. Could you describe to us in some more detail what you're trying to do? What are "cables", "middle parts", and "extensions"? Perhaps you could mock up a screenshot of what the possible arrangements should be, using (say) stone for middle parts and something else for cables (redstone? wood?) -TGG
-
Problems with Tile Entity Rendering and Bounding Boxes
TheGreyGhost replied to Bedrock_Miner's topic in Modder Support
Hi I'd suggest: Is the ClientProxy.registerRenderers() called? If so, consider a breakpoint in TileEntityRenderer.renderTileEntityAt() at this line- TileEntitySpecialRenderer tileentityspecialrenderer = this.getSpecialRendererForEntity(par1TileEntity); then trace into getSpecialRendererForEntity and see why your par1TileEntity doesn't match any of the entries in specialRendererMap -TGG -
Hi Using bindTexture directly will work fine too, like you've already discovered... Some help with item rendering: http://greyminecraftcoder.blogspot.com.au/2013/08/rendering-items.html or the broader list of topics http://greyminecraftcoder.blogspot.com.au/p/list-of-topics.html with some sample code which might be useful... http://greyminecraftcoder.blogspot.com.au/2013/09/sample-code-for-rendering-items.html -TGG
-
Hi Your code is stuck in a recursive loop because your transferStackInSlot method doesn't properly reduce the number of items left in the slot. The purpose of the vanilla code in this section if (slot2 != null && slot2.canTakeStack(par4EntityPlayer)) { itemstack1 = this.transferStackInSlot(par4EntityPlayer, slotNumber); if (itemstack1 != null) { l = itemstack1.itemID; itemstack = itemstack1.copy(); if (slot2 != null && slot2.getStack() != null && slot2.getStack().itemID == l) { this.retrySlotClick(slotNumber, whichButton, true, par4EntityPlayer); } } } is to properly handle stacks of items. For example, if your hotbar has a spot with 34 stone in it, and your inventory contains 58 stone, then the first call to transferStackInSlot will take 30 stone from your 58 inventory stone and add it to the 34 hotbar stone, so that you get 64 hotbar stone and 28 inventory stone. The slot2.getStack().itemID == l then detects that there is still 28 inventory stone left in the slot that you shift-clicked, so it calls slotClick again on the same slot in order to try and get rid of the remaining 28. So if your transferStackInSlot always returns an ItemStack (meaning "I found somewhere to put at least some of these inventory stone") but doesn't ever decrease the inventory stone to zero / replace that slot with null, then the code will loop infinitely like is happening to you. -TGG
-
Hi Could you paste the crash log in, please? -TGG
-
Hi It looks like the render is using textures from the icon sheet (1) instead of from the terrain sheet (0). See getSpriteNumber. i.e. you must override getSpriteNumber to return 0 when your custom item is rendered. -TGG
-
Hi Yeah that's pretty close, couple of further tweaks using some code out of Block.dropBlockAsItem_do ... @ForgeSubscribe public void HarvestCheck(EntityPlayer player, Block block, boolean success){ if(block != null && block == Block.oreIron) { ItemStack heldItem = player.getHeldItem(); if (heldItem != null && heldItem.itemID == hammerID) { success = false; // insert code from Block.dropBlockAsItem_do here // useful things to have: player.worldObj, player.posX, .posY, .posZ } } } I reckon that should get you where you want to go. -TGG
-
Hi The basic problem seems to be that you are trying to store 108 ItemStacks into a chest with only 45 slots. So I would suggest putting a breakpoint into Packet104WindowItems.processPacket and then have a look at the container to see why it only has 45 slots instead of the expected 108. I'm guessing either it's the wrong container, or you haven't set it up right. -TGG
-
Getting front of block to face player when placed
TheGreyGhost replied to gellegbs's topic in Modder Support
Hi Glad it helped :-) To be honest most of this I figure out as I go. I found the onBlockPlacedBy method by looking through BlockPumpkin, realising that onBlockAdded was all about spawning Golems and not about placing the Pumpkin block, which really just left onBlockPlacedBy and the setBlockMetadataWithNotify (which I guessed from the name what it does). It helped that I spent a while mucking around with Pistons while I was trying to figure out how the icon thing worked, so I knew pretty much what I was looking for. There are lots of informative articles around but it's often hard to find the ones you need, and they're often very specific so it can be hard to get the overview. Mazetar's tutorial guide is a good start. http://mazetar.com/mctuts/displayTutorials.php I've also written a few other overview pages on things that I had to figure out myself. http://greyminecraftcoder.blogspot.com.au/p/list-of-topics.html But most of the time I tend to think of a vanilla item or block that does what I'm looking for, then follow the trail of crumbs through the code until I can narrow down the bit I'm interested in. -TGG -
Hi What I suggest: Register your HarvestCheck event as per Mazetar's tutorial Put code in the HarvestCheck that checks if the block and player's held item match the conditions for dropping your special item. If yes, drop the item (see ItemInWorldManager.tryHarvestBlock) and return false from your HarvestCheck handler (set success to false). Otherwise, set success to true and let the vanilla code handle it. -TGG
-
Hi I don't think this is so easy. I can think of a few possibilities, none of them easy- modify the Block class modify the Explosion class intercept World.createExplosion, World.newExplosion, to substitute a customised MyExplosion class; modify the TNT and creeper entities I reckon that probably means a core mod. -TGG
-
Getting front of block to face player when placed
TheGreyGhost replied to gellegbs's topic in Modder Support
Hi Some background reading that might help http://greyminecraftcoder.blogspot.com.au/2013/07/blocks.html http://greyminecraftcoder.blogspot.com.au/2013/07/rendering-standard-blocks-cubes.html It might make it a bit easier to understand if you neaten up the BlockPumpkin.getIcon and onBlockPlacedBy code: /** * From the specified side and block metadata retrieves the blocks texture. Args: side, metadata */ public Icon getIcon(int side, int metadata) { if (side == 1) return this.topAndBottomIcon; else if (side == 0) return this.topAndBottomIcon; else if (metadata == 2 && side == 2) return this.faceIcon; else if (metadata == 3 && side == 5) return this.faceIcon; else if (metadata == 0 && side == 3) return this.faceIcon; else if (metadata == 1 && side == 4) return this.faceIcon; else return this.blockIcon; } /** * Called when the block is placed in the world. */ public void onBlockPlacedBy(World par1World, int x, int y, int z, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack) { int whichDirectionFacing = MathHelper.floor_double((double)(par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 2.5D) & 3; par1World.setBlockMetadataWithNotify(x, y, z, whichDirectionFacing, 2); } -TGG -
Custom furnace won't change texture when burning (or active)
TheGreyGhost replied to Jeerdus's topic in Modder Support
Hi The vanilla furnace changes its blockID when it becomes active, in updateFurnaceBlockState. Have you used breakpoints or logging to check whether the ID is changing properly? And that your TileEntity.updateEntity() being called properly? -TGG -
no worries :-)
-
Hi Hmm that varies quite a bit depending on what you want to render. Fonts I don't know about, but the vanilla code has lots of examples eg TileEntitySignRenderer.renderTileEntitySignAt or GuiTextField.drawTextBox. General textures I know a bit about- http://greyminecraftcoder.blogspot.com.au/2013/08/the-tessellator.html http://greyminecraftcoder.blogspot.com.au/2013/09/sample-code-for-rendering-items.html If you tell us what exactly you want to do, then wiser folks than I might be able to chip in with something helpful. -TGG
-
Hi er, my first guess would be that goldore_item, emould_pickaxe_head, {etc} are all the same item? or at least, you've given them all the same unLocalizedName? http://www.minecraftforge.net/forum/index.php?topic=7798.0 and http://wuppy29.blogspot.com.au/2013/08/modding-16-basic-item-part-1.html or -TGG
-
Awesome :-) Glad we could help -TGG
-
Problems with Tile Entity Rendering and Bounding Boxes
TheGreyGhost replied to Bedrock_Miner's topic in Modder Support
Hi I don't know the answer but I'd suggest it should be pretty easy to figure out with a few well-placed breakpoints- eg is the renderer called at all? if not why not? is it rendering at the correct x,y,z location? what happens if you replace your render with a test object that you know renders properly? -TGG -
Hi This looks promising: EntityLivingBase.onDeath() // snip if (!ForgeHooks.onLivingDrops(this, par1DamageSource, capturedDrops, i, recentlyHit > 0, j)) { for (EntityItem item : capturedDrops) { worldObj.spawnEntityInWorld(item); } } } i.e. if you register the LivingDropsEvent, you can check which Entity did the dropping, and either change the drops or add to them as your heart desires -TGG
-
Hi This link might help http://greyminecraftcoder.blogspot.com.au/2013/10/user-input.html An approach I've used successfully is to "intercept" the keyBindAttack. https://gist.github.com/TheGreyGhost/7033821 -TGG
-
Hi I suspect one or more of your items eg emould_pickaxe_head are null (not initialised yet). -TGG