Jump to content

QuantumLeaf7895

Members
  • Posts

    33
  • Joined

  • Last visited

Everything posted by QuantumLeaf7895

  1. So I was double-checking my read/writeFromNBT methods and in the process noticed that the onDataPacket method didn't actually change the tile entity's data. . . thanks for the suggestions, though. Problem's fixed, for now. God only knows how onDataPacket could somehow not change the tile entity's data while sneakily appearing to. (Although LexManos would probably know better. . .)
  2. So. . . new problem: I've figured out how to sync server and client data, but on world load/unload the client's tile entity resets. Is there any way to automatically send a tile entity description packet when the tile entity's chunk is loaded?
  3. Thanks for that, onDataPacket did the trick. (I can't help but wonder why most vanilla TE classes don't override it. . . ah well, the packet must be handled elsewhere in the code)
  4. Aren't containers designed to be used with GUIs? I'm trying to use TE data to control what textures a block should be rendered with, similar to how signs use TE data to control what text to display. I've tried using getTileEntityDescriptionPacket(), but I can't make the game process built-in (or custom!) TE description packets. I'm working on using Forge's packet handling structure, but although I've managed to send xyz coordinates from server to client I have no idea how to send which world the coordinates originate from. (Strangely, neither Packet132TileEntityData nor Packet130UpdateSign seem to have a "world" field, yet both obviously allow minecraft to identify where the described TE is located. . . must look into that.)
  5. Isn't there a method (getBlockTexture) that takes IBlockAccess as a parameter and returns an icon to display? I was under the impression that the method could be used to grab a block's TE and use data from that to choose a texture to display on a certain side.
  6. So I want to use tile entity data to control what texture the related block uses, a bit like how IndustrialCraft fits so many types of blocks into a single ID, but the problem is that the client stubbornly refuses to store any tile entity data. How can I make the server send tile entity data? I've tried using tile entity description packets but I can't seem to make the client process them. EDIT: So I've figured out how to sync server and client data, but on world load/unload the client's tile entity resets. Is there any way to automatically send a tile entity description packet when the tile entity's chunk is loaded?
  7. Firstly: You can rename parameters in overridden methods. getCollisionBoundingBoxFromPool(World world, int x, int y, int z) is *far* easier on the eyes than (World par1, int par2. . .). Secondly, take another look at the fence's code -- you've changed the collision box so that, instead of starting at the relevant block's x, y, and z coordinates, it starts at the (2,2,2) coordinate -- four levels deep in bedrock, not too far from the initial spawn in the x and z directions, no matter where the relevant block actually *is*. And I apologize that my knowledge of the minecraft engine is somewhat limited, but you might have problems with your block if it extends across chunks. In general, if a something needs to have a collision box larger than 1 block multiple blocks are used instead -- the top and bottom of a door are technically separate blocks, as is the arm of a piston. The fence (and fence gate) is vanilla minecraft's only block that has a collision box extending beyond it's 1x1x1 m cube.
  8. I've also thought about making a block that requires a tool to harvest, but that method doesn't specify what level of tool is required, only that one is. How does vanilla minecraft prevent ore blocks from being mined with wooden picks? I haven't been able to find an example. And what exactly does that "unique block name" in the registerBlock method do? What does it mean, is it different from setBlockName or LanguageRegistry.addName?
  9. At risk of putting my foot in my mouth, there are two problems with your method. Firstly, you're using getSelectedBoundingBoxFromPool. This method, as the name *and javadoc* imply, only affects what happens when a player puts their cursor over the block (and is client-side only, to boot). Take a look at BlockFence, that block is technically 1.5 blocks tall and has an example of what you're trying to do. In addition, I'm worried by your use of 'var5's and 'par2's and other anonymous variables -- it makes code terribly difficult to read. MCP-decompiled code looks like that only because of how the vanilla minecraft code has to be deobfuscated and decombiled. Variable names *that represent what the variable does* are much, much better -- take a look at the methods near the end of Block.java, specifically the bit after the "FORGE START" comment for an example of what I'm talking about.
  10. Hi all, I've been having trouble getting block updates to work properly in two separate places. Firstly, I have a class that uses tile entity data to determine what sprites should go where: @Override @SideOnly(Side.CLIENT) public int getBlockTexture(IBlockAccess access, int x, int y, int z, int side) { if (!(access.getBlockTileEntity(x, y, z) instanceof TileEntityLavaPlate)) { return 0; } TileEntityLavaPlate te = (TileEntityLavaPlate)access.getBlockTileEntity(x, y, z); return (te.getPositionInMacro() != -2) ? 117 : 102; } Else where in the class, I have the following bit of code inside an onBlockAdded method: tileEntity = (TileEntity3x1x3Try2)world.getBlockTileEntity(x, y, z); tileEntity.setPositionInMacro(0); world.markBlockForUpdate(x, y, z); System.out.println("Made Macro Block"); The markBlockForUpdate's javadoc states that the method will re-send tile entity data from server to client, but I can never get the block's texture to change, even when I do get console output when the block is added. Possibly relatedly, I've been working on an item that, when right-clicked, places water source blocks in the world. The only problem is, while I can place a water source block, the placed block is 'still,' and won't spread. How can I make the block update itself? world.setBlockAndMetadataWithNotify(x, y, z, Block.waterStill.blockID, 0); world.scheduleBlockUpdate(x, y, z, Block.waterStill.blockID, 2);
  11. Hi all, I've been working on two unrelated things: The first is a type of item that functions a kind of bucket -- on right-clicking, it can place a liquid source block inside the world. The problem is that after placing the source block, minecraft stubbornly refuses to check if the block (lava or water) can propagate 'flowing' water blocks (IE, such as when a liquid source block is placed above an air or snow block). I'm using the following code inside an onItemRickClickMethod to place the block: world.setBlockWithNotify(x, y, z, liquidToPlaceID); //Where x, y, and z are variables derived from a getMovingObjectPositionFromPlayer's blockX,blockY, and blockZ fields world.scheduleBlockUpdate(x, y, z, liquidToPlaceID, Block.blocksList[liquidToPlaceID].tickRate()); What am I doing wrong? In addition, I'm trying to make a block that outputs redstone. The problem is, while it *will* indirectly power adjacent blocks (shutting off redstone torches, powering two-block-away redstone wires, etc), it won't ever directly power an adjacent redstone block. I'm using the following code to output redstone power (in an block that extends BlockContainer, if that's relevant): @Override public boolean canProvidePower() { return true;//Note redstone will still *render* a connection to this block, it just won't ever be powered by it } @Override public boolean isProvidingStrongPower(IBlockAccess access, int x, int y, int z, int side) { return true; } What am I doing wrong?
  12. I admit that I don't have that much experience with minecraft MP modding, but your insistence of modifying certain values the server should know about client-side only worries me. There are few occasions where doing something serverside but not clientside can go wrong (because the server can update the client about changes), but many where doing something clientside but not serverside can (because the server, IIRC, overrides the client if entity location, block ID at location, etc. differ from one to the other). Some combing of minecraft's ItemStack.java class makes me wonder if the entire removeItemFromPlayer method isn't redundant, and is actually the cause of the problem -- ItemStack's damageItem does something similar (make an itemstack null), but in a slightly different manner. I suggest you check it out.
  13. World.java has a couple methods for setting a block at an arbitrary location to an arbitrary ID -- you probably want to look into those
  14. Precisely what do you mean by that? Something two blocks tall? Something snowman style? Something else? My usual advice for rendering is to look through buildcraft's and EE3's source for something vaguely similar to what you want, and tinker with it until you get the desired result -- though an instinct of mine says that RenderBlock's updateCustomBlockBounds method could be useful for what I *think* you want (which is snowman style)
  15. IIRC, it's in-world block metadata that's limited to 16, an item's damage value should be able to store a range of values more-or-less the same size as java's int type.
  16. Hi all, When an item's damage value is 0, there is no damage bar displayed. Is there a way to override this behavior (ie, the way that an IC2 electric tool will display a damage bar even at 'full charge')? Note that the item I'm planning on using should only have a small range of possible damage values -- currently the maxItemDamage is 5.
  17. um. . . Well then, I'm sorry I said anything. I've never seen net.minecraft.block before, from my experiences forge's decompile.bash always puts minecraft.jar classes in a net.minecraft.src package; are you working with the 1.4.6 prerelease?
  18. It may also be convenient to save the experience saved directly into the item's damage value, unless you're using that for some other purpose.
  19. It's net.minecraft.src.Block. The fact that minecraft worked fine in eclipse makes me think that your mod file is in the same package as minecraft's Block.java file -- which makes me fear that you're putting your mod files directly in net.minecraft.src. That's usually a bad idea, as (iirc) it always means that the compiled version of your mod must be installed directly in minecraft.jar. I recommend looking through wuppy's tutorials on modding post-1.3.1, one of the things they recommend is putting all your mod files in a custom package.
  20. I'd also recommend looking through the source code of EE3 and buildcraft -- they might have something close enough to what you want to be a good jumping-off point. TBH, one look at EE3's calcinator render logic is a useful demonstration for why 'your first block' tutorials are so much more common than 'your first custom-rendered tile entity' tutorials. . . Practically anything that isn't a simple cube is insanely complex to render directly through openGL. And things that are simple cubes can be challenging to work with.
  21. First rule of minecraft multiplayer modding: When in doubt, add an if(!world.isRemote) [And if you don't know what that means, I suggest you find the isRemote field in World.class]. Most methods in Block.class and Item.class get called both clientside and serverside, so packets shouldn't be necessary depending on how you arrived at the posted code, but beware of Item.class's onItemUseFirst method -- when it returns true clientside, it never gets called serverside. I know how badly that tripped me up. I also suggest you read the Forge Wiki's page on SMP coding guidelines -- its helpful, if somewhat terse.
  22. Hi all, I have two mostly unrelated questions. The first: Minecraft Forge offers a number of handlers -- events, world gen, gui, etc. Can a single class implement all of them? That is, would a class like this: public class ForgeHandlers implements IWorldGenerator, IGuiHandler{ @Override public void generate(/* parameters snipped */) { //World Generation } @Override public Object getClientGuiElement(/* parameters snipped */) { //Gui stuff } @ForgeSubscribe public void entityDeath(EntityDeathEvent event) { //Event stuff } Work?(outside unimplemented methods and syntax problems) Also: Where in minecraft's code is WorldGenMinable used? I want an example of how its used (I'm adding a custom ore I want to be a little rarer than iron, and want a few examples to get started), but can't actually find any.
  23. Might the problem be in onItemUse? @Override public boolean onItemUse(ItemStack itemStack, EntityPlayer entityPlayer, World world, int x, int y, int z, int l, float f1, float f2, float f3) { itemStack.damageItem(1, entityPlayer); System.out.println(this.isDamageable()); //Testing [b]return true;[/b] } I've noticed that when that method returns true clientside, it is never called serverside. Try adding an if (world.isRemote){return false;} statement near the beginning of the method body.
  24. Hi all, I've been working on a block with a custom renderer -- the idea is a partially transparent block which has a different 'height' based on its metadata. I've been tinkering with a renderer, but for some reason when placed into the world the block is always invisible. The block looks like this: The renderer looks like this: And I register the renderer in the client proxy like this: What am I doing wrong? Edit: I noticed that in the renderer, I was dividing by 1 where I should've been dividing by 16, but fixing that changed absolutely nothing. I figured out a workaround that involves dropping the whole custom renderer and copy-pasting the render code into an overridden setBlockBoundsBasedOnState, but that a) makes it's inventory appearance change wildly depending on the metadata of the block instance the player looked at last and b) doesn't explain why the custom renderer didn't work. I'm also deeply suspicious of IBlockAccess -- the last time I tried to use it (by overriding the getBlockTexture method) didn't seem to do anything, though I had used to access the block's tile entity to determine which texture to return. Is it possible that my downloaded forge source is messed up? I remember back in August I somehow downloaded a version of forge for 1.3.2 that didn't have a working Language Registry.
  25. Yeah, I was afraid of that. So returning true clientside will always prevent calling serverside. . . Thanks. One follow-up question, minecraft plays a little animation with whatever item's in the player's hand when left-clicking on a block or right-clicking with certain items in hand -- notably when placing vines and lily-pads in the world (and, prior to 1.3.2, when onItemUse returned true). Is there any way to play that animation when using my item, instead of the 'default' item-is-rightclicked-on-a-block one?
×
×
  • Create New...

Important Information

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