Jump to content

TheGreyGhost

Members
  • Posts

    3280
  • Joined

  • Last visited

  • Days Won

    8

Everything posted by TheGreyGhost

  1. Hi You could try if (Minecraft.getMinecraft().thePlayer().getHeldItem().getItem().itemID == myLightStaffID) { // staff is held so render } This must be in the renderer only, i.e. it can only work on the client side. If it works at all, which I'm not sure :-P -TGG
  2. Hi Unfortunately I really don't understand your question. Could you explain it a bit further? -TGG
  3. Hi OK, that's much clearer now. I have some suggestions on how you could go about it - some of this I've never tried before so it might take a bit of work to get it right. (1) Create a BlockLight that is (a) renderAsNormalBlock false (b) isOpaqueCube false © public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4) { return null; } (d) collisionRayTrace - return super.collisionRayTrace if player is holding the staff, NULL otherwise (2) Have a single TileEntity associated with the block. In the custom renderer for the TileEntity, check if the player has the staff equipped and if so, render the TileEntity using the player's coordinates to determine which way the object should face. Do you want the Light block to act like a torch when the staff is held (i.e. light up nearby blocks)? That is a bit trickier because it means you would need to force an update of the blocklight map when you equip/unequip the item. This is a bit different to some of your earlier posts, where the blocks would be interactable by any player, if there is another player holding the staff nearby. What I've written above only allows the player holding the staff to interact, which is what I think you wanted? -TGG
  4. Hi ha ha, I've got a looong way to go before I'm worthy of that title. Plenty of folks on this list are far more awesome than me! Glad I could help. -TGG
  5. Hi That's a bit odd. Try putting the breakpoint in FolderResourcePack.makeFullPath and FileResourcePack.makeFullPath instead. That also worked for me. If all else fails and you know a bit about linux, you could perhaps try running a file access system call logging program to see if you can determine what folder/filename it is looking for. Might be faster than digging through the code, I found it pretty confusing myself. -TGG
  6. Hi I think you need to force the server to update the player inventory on the client. It's worth a try. See vanilla code in BlockCauldron if (!par1World.isRemote) { ((EntityPlayerMP)par5EntityPlayer).sendContainerToPlayer(par5EntityPlayer.inventoryContainer); } -TGG
  7. Hi I might be missing something obvious, but is this what you want? if(player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().itemID == Base.tankEmpty.itemID) { if(event.action == Action.RIGHT_CLICK_AIR) { boolean itemWasAdded = player.inventory.addItemStackToInventory(new ItemStack(Base.tankAir)); if (!player.capabilities.isCreativeMode && itemWasAdded) { --player.getCurrentEquippedItem().stackSize; } } } -TGG
  8. Hi I suspect it might be important to tell the server to send the updated inventory to the client ((EntityPlayerMP)par5EntityPlayer).sendContainerToPlayer(par5EntityPlayer.inventoryContainer); - see BlockCauldron.onBlockActivated -TGG
  9. Hi Interesting. Your code looks roughly right, I don't see anything obviously with the method calls. Why do you have a return in your for loop? The way it's written, you will only ever check the first living entity in range. You should probably add 0.5 to xCoord, yCoord, and zCoord in your getVecFromPool to put the camera position in the middle of your block, to make sure that the raytrace does actually collide with your camera block. You do have a Block of some sort at the camera position, yes? What happens if you insert blocks between the camera and your test entity, does the canSee method return non-NULL then? If no luck with those, I would suggest you put a breakpoint in your canSee and step through the clip method to make sure that the [x,y,z] coordinates are what you think they should be. Otherwise I'm stumped! -TGG
  10. Hi The reason this is happening is because of the way the code tells whether you've clicked on a block or not. In Minecraft.clickMouse(1) is where it's all happening: if (this.objectMouseOver == null) { if (button == 0 && this.playerController.isNotCreative()) { this.leftClickCounter = 10; } } else if (this.objectMouseOver.typeOfHit == EnumMovingObjectType.ENTITY) { //snip } else if (this.objectMouseOver.typeOfHit == EnumMovingObjectType.TILE) { int j = this.objectMouseOver.blockX; int k = this.objectMouseOver.blockY; int l = this.objectMouseOver.blockZ; int i1 = this.objectMouseOver.sideHit; if (button == 0) { this.playerController.clickBlock(j, k, l, this.objectMouseOver.sideHit); } else { int j1 = itemstack != null ? itemstack.stackSize : 0; boolean result = !ForgeEventFactory.onPlayerInteract(thePlayer, Action.RIGHT_CLICK_BLOCK, j, k, l, i1).isCanceled(); if (result && this.playerController.onPlayerRightClick(this.thePlayer, this.theWorld, itemstack, j, k, l, i1, this.objectMouseOver.hitVec)) { rightClickNoEffect = false; this.thePlayer.swingItem(); } //snip } } if (rightClickNoEffect && button == 1) { ItemStack itemstack1 = this.thePlayer.inventory.getCurrentItem(); boolean result = !ForgeEventFactory.onPlayerInteract(thePlayer, Action.RIGHT_CLICK_AIR, 0, 0, 0, -1).isCanceled(); if (result && itemstack1 != null && this.playerController.sendUseItem(this.thePlayer, this.theWorld, itemstack1)) { this.entityRenderer.itemRenderer.resetEquippedProgress2(); } } .objectMouseOver contains the first object that your line of sight intersects within a certain distance (6 blocks from memory). It contains the location and the type: NULL = hit nothing (or fluids) TILE = hit a block ENTITY = hit an entity I think the problem is that this .objectMouseOver ignores liquids. So if you right-click when pointing at a liquid, it falls through to the RIGHT_CLICK_AIR, then keeps going to .sendUseItem which makes its way to your onItemRightClick method as well. You could fix this by putting your onItemRightClick code into the RIGHT_CLICK_AIR handler. The first statement in this code performs the line-of-sight ray tracing again, but with the "collide with liquids" flag set to true, so it will stop when it hits a liquid rather than keeping on going. MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(par2World, par3EntityPlayer, true); if (movingobjectposition == null) // didn't hit any blocks or liquid { } You also need to handle the case where your line of sight passes through a liquid then hits a block, because in .clickMouse it will get EnumMovingObjectType.TILE. Perhaps the easiest way is to use the RIGHT_CLICK_BLOCK handler the same as your RIGHT_CLICK_AIR, i.e. perform the ray-trace again and verify that the block you hit is a fluid. Disclaimer: I've never tried this myself. However it looks like it should work. -TGG
  11. Hi I'm not sure I really understand your question - do you mean that you don't know how to throw your item, or that you don't know how to make it render using your techne model? The answer to the first one is in ItemSnowball.onItemRightClick - i.e. you need to spawn an EntityItem. The vanilla code has lots of examples on how to do it, it's quite straightforward. The answer to the second one is that you can use the same rendering code for EntityItems as for when it is held. For more information see here: http://greyminecraftcoder.blogspot.com/2013/08/rendering-items.html and http://greyminecraftcoder.blogspot.com.au/2013/08/rendering-dropped-items.html -TGG
  12. Hi Just to expand on GotoLink's answer- That statement performs a raytrace between the two coordinates you specify and looks for any non-transparent block faces in between the two. If it doesn't find anything, it returns null. If your CCTV block is collideable (Block.canCollideCheck), then the ray trace will always intersect your block and never return null. But if you make your block non-collideable, the player won't be able to left or right click it. You don't need to spawn an entity. I'd suggest your algorithm should look something like (1) find all entities within a given distance of the camera. RenderGlobal.renderEntities "entities" section is an example of how the vanilla code does it - looks for all entities within a given radius and in the frustrum (where the player "camera" is looking) (2) for each entity, ray trace from the entity to the camera using the World.clip method you found. If the returned MovingObjectPosition.[x,y,z] is equal to your block's [x,y,z], then you know that the entity is visible to the camera because the ray made it all the way to your camera block. It's only a rough approximation since your camera treats the entity as a point - if eg the entity[x,y,z] corresponds to its head the camera will ignore it unless it can see the head, even if it can see the feet. But this is probably good enough. -TGG BTW I think this method treats glass as collideable, i.e. your camera wouldn't be able to see through glass. Likewise blocks with torches, redstone wires, etc.
  13. Hi So when you right-click in mid air with an empty bucket, you want the bucket to stay empty, and in addition a second custom item ("compressed air" or "captured butterfly" or similar) to appear in the player's inventory? -TGG
  14. Hi What do you want to happen exactly when you right-click in mid air? -TGG
  15. Hi I would suggest that you add a breakpoint where the error occurs, and look to see what your variables contain. One of them is not the size you expect. If you're not using a debugger, add some diagnostic code that checks if the array index is in bounds before using it, if not writes an error message containing information about the contents of the array. This should show you pretty quickly where the problem lies. -TGG
  16. Hi Alix If you are not sure what the parameters for a particular function are, the fastest way to find out is to look through vanilla code which uses the parameters and trace through until you either reach something you know or which has comments. For example: onBlockDestroyed(ItemStack par1ItemStack, World par2World, int par3, int par4, int par5, int par6, EntityLivingBase par7EntityLivingBase) If you look in ItemShears.onBlockDestroyed, you see this... par3 != Block.leaves.blockID This tells you that par3 is the blockID. In ItemSword.onBlockDestroyed, you see Block.blocksList[par3].getBlockHardness(par2World, par4, par5, par6) If you then go into Block.getBlockHardness, you see in the comments /** * Returns the block hardness at a location. Args: world, x, y, z */ so par4, par5, par6 are x,y,z -TGG
  17. Hi So how does your custom bucket differ from a normal bucket? So far it sounds exactly like a normal bucket. If so, why aren't the two existing ItemBucket methods suitable? -TGG
  18. Hi I think the best way forward is if you could describe more exactly what you're trying to do, i.e. a paragraph describing what this item is, what effects it has, on which blocks. For example "The staff of opening causes all wooden and iron doors within a 10m radius of the player to spontaneously open while the player is nearby." At the moment I can't really give you any advice because it's not clear to me the behaviour you need, and hence whether you need TileEntities or not, whether the renderer is the best place, whether you can use metadata or you need something else, etc. -TGG
  19. Hi If you search the code for calls to .isSneaking() you will find what you're looking for. For example reduced visibility to mobs, look in World.getClosestVulnerablePlayer reduced name visibility, look in RendererLivingEntity.passSpecialRender -TGG
  20. Hi What they mean is... you should perform this action on the server side only, not the client side. if(!par1World.isRemote) { // give item code } The other bit I suspect might be important is to tell the server to send the updated inventory to the client ((EntityPlayerMP)par5EntityPlayer).sendContainerToPlayer(par5EntityPlayer.inventoryContainer); - see BlockCauldron.onBlockActivated -TGG
  21. Hi To be honest there's quite a bit to learn about debugging and I doubt I'm the best person to teach it to you. I'd suggest looking for a decent textbook or online tutorial or youtube series to show you what's possible with an Integrated Development Environment. It'll be well worth your investment of time- being able to stop the code, see what's doing, where it has come, watch it go step by step through each instruction, read the values of your variables and see whether they match what you expected. Stops a lot of fumbling in the dark. -TGG
  22. Hi You can fix the second problem by overriding getIcon. I would also suggest renaming your field_94392_b and field_94393_a to something meaningful, eg @SideOnly(Side.CLIENT) private Icon chainTnt_top; @SideOnly(Side.CLIENT) private Icon chainTnt_bottom; @Override public Icon getIcon(int side, int metaData) { return side == 0 ? this.chainTnt_bottom : (side == 1 ? this.chainTnt_top : this.blockIcon); } @Override public void registerIcons(IconRegister par1IconRegister) { this.blockIcon = par1IconRegister.registerIcon(Tutorial.modid + ":" + "chainTnt" + "_side"); this.chainTnt_top = par1IconRegister.registerIcon(Tutorial.modid + ":" + "chainTnt" + "_top"); this.chainTnt_bottom = par1IconRegister.registerIcon(Tutorial.modid + ":" + "chainTnt" + "_bottom"); } -TGG
  23. Hi Yes it is possible. You need to render on pass 1. See here for more information. http://greyminecraftcoder.blogspot.com.au/2013/07/rendering-transparent-blocks.html -TGG
  24. Hi It looks to me like your object is rendering using the default block texture sheet instead of your new texture. Are you sure that your renderAll isn't rebinding the texture back to block perhaps? Perhaps you could test this by drawing a rectangle using the tessellator immediately after your bindTexture. If it works, at least you know your resource has been properly located. -TGG
  25. hi do you mean EntityPlayerSP.isSneaking() (client side) EntityPlayerMP.isSneaking() (server side) -TGG
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.