Jump to content

_bau5

Members
  • Posts

    30
  • Joined

  • Last visited

Converted

  • Gender
    Undisclosed
  • Personal Text
    I am new!

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

_bau5's Achievements

Tree Puncher

Tree Puncher (2/8)

2

Reputation

  1. public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase living, ItemStack stack) { super.onBlockPlacedBy(world, x, y, z, living, stack); byte dir = 0; int plyrFacing = MathHelper.floor_double(((living.rotationYaw * 4F) / 360F) + 0.5D) & 3; if (plyrFacing == 0) dir = 2; if (plyrFacing == 1) dir = 5; if (plyrFacing == 2) dir = 3; if (plyrFacing == 3) dir = 4; TileEntity tpb = world.getBlockTileEntity(x, y, z); if (tpb != null && tpb instanceof TEProjectBenchII) { ((TEProjectBenchII)tpb).setDirection(dir); world.markBlockForUpdate(x, y, z); } } This works fine for me. Throw this in your Block class.
  2. I'm not sure about #3, but here are my thoughts on the other two. 1. I'm fairly certain that is a server-client issue, as in the client says you have a different amount of items than the server says you have. It's some sort of de-sync issue that could be attributed to a lot of different things. Just go into the debugging tool and work your way through it as it's running on the client, then the server, and see where they start to disagree. 2. Override the transferStackInSlot method and make sure it will only try to transfer 15, or however many makes 15, at a time to a single slot and leave the rest. I'm not really sure why it would be deleting it, because the default minecraft code will only transfer up to the slot limit and leave the rest.
  3. Think about it- during the preInitialization phase of Minecraft, do you think a player exists? Nope. Not until a world is loading. You'll need to use an event handler and run this code when a new world is loading and the player has been created.
  4. So the way recipes work, as I understand it, is that when you place the components in the grid, it's checked against the CraftingManager looking for matches in item types and layouts. I'm implementing a method of crafting that doesn't hinge on the 3x3, or any layout, crafting grid at all, just the raw components themselves. For vanilla recipes it works just fine, all IRecipes in the game (Shaped/Shapeless/Ore etc) have an array of all the item types and respective alternatives (such as for the ore dictionary recipes) so I can just go through and translate them all based on the case. However, this doesn't come as part of the interface, there is no way to be plainly given what's in the recipe. The only thing the interface offers is a way to check if it matches what is provided. So this leaves me with the problem I've run into: What way is there to universally access all the components of a crafting recipe across all the custom handlers? I'm starting to get the feeling there isn't. Which is inconvenient. SOLVED This was the solution I came up with. Used cpw's reflection helper to go through all the fields until it throws an ArrayOutOfBounds exception and then break. Easy peasy. try{ int i = 0; do{ try { Field f = rec.getClass().getDeclaredFields()[i++]; f.setAccessible(true); Object obj = f.get(rec); if(obj != null){ if(obj instanceof Object[]){ Object[] objArr = (Object[])obj; newRecItem.input = new Object[objArr.length]; for(int j = 0; j < objArr.length; j++){ Object obj2 = objArr[j]; newRecItem.input[j] = obj2; if(obj2 == null){ if(newRecItem.items == null) newRecItem.items = new ItemStack[objArr.length]; }else if(obj2 instanceof ItemStack){ if(newRecItem.items == null) newRecItem.items = new ItemStack[objArr.length]; newRecItem.items[j] = ((ItemStack)obj2).copy(); }else if(obj2 instanceof String){ ItemStack oreStack = OreDictionary.getOres((String)obj2).get(0); ItemStack newStack = new ItemStack(oreStack.itemID, oreStack.stackSize, OreDictionary.WILDCARD_VALUE); if(newRecItem.items == null) newRecItem.items = new ItemStack[objArr.length]; newRecItem.items[j] = newStack; }else{ System.out.println("ProjectBench: Unaccounted for object type, disabling recipe. " +obj2); newRecItem.forceDisable(); } } } } } catch(ArrayIndexOutOfBoundsException ex) { break; } catch(Exception ex){ newRecItem.forceDisable(); } } while(true);
  5. I'm trying to develop with NEI installed into the eclipse environment, but am not successfully getting it working. I've followed his instructions on the MCForum topic, added the _at.cfg's to the right places and all. But I am still getting this error: I googled it, others have had this problem, but no solution was ever posted. Any help would be great.
  6. My problem is: I'm trying to render some ItemStacks on the in game gui when looking at one of my entities. Now it works, but it seems that it isn't rendering the texture, as the pale-blue backdrop can be seen through where the render is supposed to be. Above you can see, circled in red, the problem. The stone on the left is rendered using the exact same call, but from the GuiIngame class, while the block on the right, that isn't being rendered correctly, is being called from outside the GuiIngame class. I am terrible, terrible at the OpenGL stuff, and am verging on scrapping this idea. Any ideas as to why this would be happening? My guess is it's due to differing states of the OpenGL render, but I've fiddled with it and can't get the textures to show. Here is the pertinent code. [embed=425,349][/embed]
  7. Thanks but I figured it out. Was having problems with the Forum so it took me awhile to edit the post.
  8. Multiple derps fixed. ------------------- I've got a Block that has a rendered block/item above it if there is a valid recipe in the crafting grid. But other players can't see the render until they open the bench themselves. Also, when the world loads, you can't see the render until you open the bench, regardless if there's a valid recipe in it. I figure this has something to do with packets, and have been working on trying to do this myself, but to no avail; I just can't seem to get any of it to work. The render class for the tile entity cannot see what's in the TileEntity's class. For instance; I have the packets set up to send the the items in the crafting grid, and receive it which works (mostly) right, aside from a few randomly returning null occasionally. But from within the TileEntity the correct output stack is fine and works, but the renderer only sees null. This really perplexes me. So anyways, any help would be fantastic. Thanks
  9. This can be sort of confusing...It's basically spread between three different classes. First, the Block: This part is fairly straight forward except that you want to be a subclass of BlockContainer. Example: https://github.com/bau5/ProjectBench/blob/master/bau5/mods/projectbench/common/ProjectBenchBlock.java Secondly, the TileEntity: The TileEntity holds all the information about the ItemStacks, what index they are within the inventory, all the logic about decreasing, increasing, and moving stacks, and the NBTTags that save what is held in the inventory. Example: https://github.com/bau5/ProjectBench/blob/master/bau5/mods/projectbench/common/TileEntityProjectBench.java Thirdly, the Container: Imagine this; if the GUI is what you, the client, sees and interacts with, the Container is what the server sees and interacts with. The container is where you lay out all the slots that the GUI will let the player interact with. Example: https://github.com/bau5/ProjectBench/blob/master/bau5/mods/projectbench/common/ContainerProjectBench.java Mine is a little different than the Minecraft workbench because I wanted the items to stay in the crafting matrix even when you close the GUI (the regular one tosses them on the ground). Hope this helps!
  10. I have a block that has a custom render for something above it. Single player it all works fine, but in smp i'm having some issues. In smp, only one player can see the render and for the anyone else they won't see the render until they open the GUI that is attached to the block's tile entity. The render is based off of a value in the tile entity. I'm assuming that this has something to do with client-server-client communication, but I'm not sure to deal with it. I read up on making a packet handler, but didn't quite understand how to implement it in my case.
  11. I got it....I finally got it. For some reason var6 and var7 were both zero, there must have been something weird going on with the get block light value method. I debugged the code for the enderman, figured out what were the appropriate values and hardcoded it in. Success.
  12. use this: int var5 = (int) (tpb.worldObj.getBlockLightValue(tpb.xCoord, tpb.yCoord, tpb.zCoord) / 15F * 240F); instead of this: int var5 = (int) (tpb.worldObj.getBlockLightValue(tpb.xCoord, tpb.yCoord, tpb.zCoord) / 15F); Still no change...So frustrating. Code now looks like this: glColor4f(1.0F, 1.0F, 1.0F, 1.0F); glPushMatrix(); glEnable(32826 /*rescale*/); glTranslatef((float)x,(float)y,(float)z); glTranslatef(0.5F, 1.2F, 0.5F); glScalef(0.3F, 0.3F, 0.3F); bindTextureByName("/terrain.png"); int var5 = (int) (tpb.worldObj.getBlockLightValue(tpb.xCoord, tpb.yCoord, tpb.zCoord) / 15F * 240F); int var6 = var5 % 65536; int var7 = var5 / 65536; OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, var6 / 1.0F, var7 / 1.0F); renderBlocks.renderBlockAsItem(Block.blocksList[stack.itemID], stack.getItemDamage(), 1.0F); glDisable(32826 /* GL_RESCALE_NORMAL_EXT */); glPopMatrix(); glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
  13. int var5 = (int) (tpb.worldObj.getBlockLightValue(tpb.xCoord, tpb.yCoord, tpb.zCoord) / 15F); int var6 = var5 % 65536; int var7 = var5 / 65536; OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, var6 / 1.0F, var7 / 1.0F); This is the closest I could come. Didn't change a thing. Here's the code on https://github.com/bau5/ProjectBench/blob/master/bau5/mods/projectbench/client/TEProjectBenchRenderer.java
  14. Thanks for the suggestion, but it didn't do anything. It's weird, it's like OpenGL isn't responding to any of the functions I throw in for lighting. I don't get it.
  15. Awesome, I'll try that when I can. Thanks for the suggestion
×
×
  • Create New...

Important Information

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