Jump to content

Reika

Members
  • Posts

    228
  • Joined

  • Last visited

Everything posted by Reika

  1. I am. The problem is that all blocks change to the last one active. So if I set metadata 4 to full block and 5 to half block, then look at metadata 5, then both blocks become half-block hitboxes. If I then look at metadata 4, both become full blocks. This can be done at will, back and forth. I do not care about rendering - these have TE renderers for them. I need the block bounds set for collision detection and some mathematical calculations. I should have provided this code in advance. Each value of m (determined based on metadata and ID) has different values for the bounds. @Override public final void setBlockBoundsBasedOnState(IBlockAccess iba, int x, int y, int z) { MachineRegistry m = MachineRegistry.getMachine(iba, x, y, z); this.setBlockBounds(m.getMinX(), m.getMinY(), m.getMinZ(), m.getMaxX(), m.getMaxY(), m.getMaxZ()); }
  2. Free in the sense that they are permitted to do so. Not in the sense that the game would get away with it without suffering from it.
  3. OK, and do they all have the same number of input ItemStacks?
  4. What is it intended for? Also, they would have to (eventually) worry about running out of IDs - the limit is a technical one (the limit of a byte), so it is not like they could change it (without severe consequences for world file size and performance) if they ever ran to 255 blocks.
  5. I second this. Just because MC uses multiple IDs for something does not mean that is the only way to do it; frankly, Mojang is rather lazy when it comes to metadata use.
  6. As a lot of my machines share blocks, and with the way Minecraft instantiates blocks, every instance of a block takes on the hitbox of the last one interacted with (this is the cause behind the "wireless redstone" bug exploit involving iron bars, glass panes, or upside-down stairs). This means that things with wildly different sizes, like the Spawner Controller (meant to be 0.25 blocks tall), the Heater (0.5), Aerosolizer (0.875) and Item Vacuum (1) all have the same hitbox size. While I can make it account for which machine it is (using IBlockAccess), they all change to the last one placed/looked at. So, for example, if I place an Item Vacuum, it is a full block. But I then place a Heater, and now both are 0.5 blocks. Also, since the block sizes are what control my block's power input sides (they only take in power on a side they extend to, so a block <1 tall cannot take power in the top), this actually affects more than just in-world collision detection (though that is in itself a problem, seeing as how it make make you able to "phase through" machines). BuildCraft does not have this issue (I remember engines having a T-shaped hitbox like the model itself) - how did it do it? Before you say "just look at their GitHub", I have done so and they do not even have ANY hitbox code in the BlockEngine class.
  7. I really hate doing this, but I am desperate for a solution to this...
  8. Noone? At all?
  9. Um...not to be rude, but did you even read my post? I am having a problem with a mod I am writing in single-player. This has nothing to do with servers or admins or AntiCheat.
  10. "id" is a Hashmap of type <String,Int>, with keys being the names of the machines (the labels in the config file).
  11. In my config-reading class, I use the following code: for (int i = 0; i < MachineRegistry.machineList.length; i++) { String name = MachineRegistry.machineList[i].getName(); if (id.containsKey(name)) throw new RuntimeException("Machine name "+name+"is attempting to re-register, from slot "+id.get(name)+" to "+String.valueOf(i)); //ReikaJavaLibrary.pConsole(name); id.put(name, config.getBlock("Machine IDs", name, (490+i)).getInt()); ReikaJavaLibrary.pConsole("ROTARYCRAFT: Loading machine "+name+" with ID "+id.get(name)); } I intend for the default IDs to start at 490 and proceed until the max value of i (61, so the max ID should be 561). However, it seems to parse them as strings instead, and I get default IDs like 4095 for i = 61. This happens even if I try crap like Integer.parseInt(String.valueOf(490+i)) and functions returning integers. Reading existing IDs is OK, but when it has to pick a new default, well, this is the console output: 2013-05-17 00:05:20 [iNFO] [sTDOUT] i: 59 2013-05-17 00:05:20 [iNFO] [sTDOUT] ROTARYCRAFT: Loading machine Firestarter with ID 561 2013-05-17 00:05:20 [iNFO] [sTDOUT] i: 60 2013-05-17 00:05:20 [iNFO] [sTDOUT] ROTARYCRAFT: Loading machine Magnetizing Unit with ID 562 2013-05-17 00:05:20 [iNFO] [sTDOUT] i: 61 2013-05-17 00:05:20 [iNFO] [sTDOUT] ROTARYCRAFT: Loading machine Containment Field with ID 4095 Why?
  12. I have been experiencing a severe glitch with the inventory under seemingly random circumstances. It appears to be causing a desynchronization between the server and the client. Here is what I am experiencing: With one TileEntity (machine) in the world, the changes made in the inventory by a player (like moving things between slots) do not seem to be reflected in the server-side inventory. This manifests as situations like the following: Player A has a hotbar full of the following, left to right: Dirt, dirt, cobble, wood, glass, empty, piston, redstone, torch. They go around and do stuff, and in the process they have rearranged their hotbar to look like the following (they have not interacted with a chest): cobble, cobble, stone, redstone, empty, empty, empty, torch, dirt. They try to place the dirt block. Instead, a dirt block appears for a split second, and then a torch appears in that place instead. If they were to try to place the piston, what they would have seen is the piston appear for a second and then disappear, with the piston seemingly disappearing from their inventory. When the world is reloaded, the GUI is totally rearranged to reflect what the server had in mind all along, the original hotbar. That is, it seems like the client and server are disagreeing on player-GUI-made changes to the location of items in the player inventory, and since the server controls the placing of blocks, it always "wins out", causing it to look like the inventory is scrambling itself or placing different things than are intended. Similarly, trying to toss items from an inventory can cause them to just disappear without spawning the item entities. When reloading the world, they reappear in the inventory, as if the "drop event" was never processed server-side. Also worth noting is that block breaking exhibits a related glitch - blocks can be broken and their items picked up (making the popping noise), but they do not appear in the inventory, as the client is not getting the update that says "item is in slot x now". Again, reloading resyncs them. I must emphasize that this bug is NOT consistent - its behavior is, but it exhibits itself at random times and it was only with great effort that I was able to link it to being (probably) dependent on one TileEntity existing in the world. The TE Code. Note that is has NO functions for editing inventories or player data. @Override public void updateEntity(World world, int x, int y, int z, int meta) { super.updateTileEntity(); tickcount++; this.getIOSides(world, x, y, z, meta); this.getPower(false, false); power = omega*torque; boolean nodig = true; for (int i = 0; i < 7; i++) { for (int j = 0; j < 5; j++) { if (cutShape[i][j]) { nodig = false; i = j = 7; } } } if (nodig) return; //ModLoader.getMinecraftInstance().thePlayer.addChatMessage(String.valueOf(cutShape[0][0])); if (omega <= 0) return; if (this.operationComplete(tickcount, 0)) { this.calcReqPower(world, x, y, z, meta); //ModLoader.getMinecraftInstance().ingameGUI.addChatMessage(String.format("%d", this.reqpow)); if (power > reqpow && reqpow != -1) this.dig(world, x, y, z, meta); tickcount = 0; if (reqpow == -1) step = ReikaMathLibrary.extrema(step-1, 1, "max"); } } public void reqPowAdd(World world, int xread, int yread, int zread, int metadata) { if (world.getBlockId(xread, yread, zread) != 0) { reqpow += (int)(DIGPOWER*10*Block.blocksList[world.getBlockId(xread, yread, zread)].getBlockHardness(world, xread, yread, zread)); if (ReikaMathLibrary.ceil2exp((int)(16*10*Block.blocksList[world.getBlockId(xread, yread, zread)].getBlockHardness(world, xread, yread, zread))) > mintorque) mintorque = ReikaMathLibrary.ceil2exp((int)(16*10*Block.blocksList[world.getBlockId(xread, yread, zread)].getBlockHardness(world, xread, yread, zread))); if (world.getBlockId(xread, yread, zread) == 7) reqpow = -1; } } public void calcReqPower(World world, int x, int y, int z, int metadata) { reqpow = 0; int mintorque = -1; int a = 0; if (metadata > 1) a = 1; int b = 1-a; int xread; int yread; int zread; for (int i = 0; i < 7; i++) { for (int j = 0; j < 5; j++) { if (cutShape[i][j] || step == 1) { xread = x+step*xstep+a*(i-3); yread = y+step*ystep+(4-j); zread = z+step*zstep+b*(i-3); this.reqPowAdd(world, xread, yread, zread, metadata); } } } if (torque < mintorque) reqpow = -1; //ModLoader.getMinecraftInstance().ingameGUI.addChatMessage(String.format("%d", mintorque)); } public void support(World world, int x, int y, int z, int metadata) { int a = 0; if (metadata > 1) a = 1; int b = 1-a; int xread; int yread; int zread; for (int i = 0; i < 7; i++) { for (int j = 0; j < 5; j++) { if (cutShape[i][j] || step == 1) { xread = x+step*xstep+a*(i-3); yread = y+step*ystep+(4-j); zread = z+step*zstep+b*(i-3); int id = world.getBlockId(xread, yread+1, zread); if (id == Block.sand.blockID || id == Block.gravel.blockID) if (this.checkTop(i, j)) if (id == Block.sand.blockID) ReikaWorldHelper.legacySetBlockWithNotify(world, xread, yread, zread, Block.sandStone.blockID); else ReikaWorldHelper.legacySetBlockWithNotify(world, xread, yread, zread, Block.stone.blockID); } } } } private boolean checkTop(int i, int j) { while (j > 0) { j--; if (cutShape[i][j]) return false; } return true; } public void dropBlocks(int xread, int yread, int zread, World world, int x, int y, int z, int id, int meta) { if (drops && id != 0) { if (id == Block.mobSpawner.blockID) { TileEntityMobSpawner spw = (TileEntityMobSpawner)world.getBlockTileEntity(xread, yread, zread); if (spw != null) { if (world.isRemote) return; MobSpawnerBaseLogic lgc = spw.func_98049_a(); String mob = lgc.getEntityNameToSpawn(); //ModLoader.getMinecraftInstance().thePlayer.addChatMessage(String.format("%s", mob)); int dmg = -1; if (mob == "Zombie") dmg = 0; if (mob == "Spider") dmg = 1; if (mob == "CaveSpider") dmg = 2; if (mob == "Skeleton") dmg = 3; if (mob == "Silverfish") dmg = 4; if (mob == "Blaze") dmg = 5; if (dmg == -1) return; ItemStack is = new ItemStack(mod_RotaryCraft.spawner.itemID, 1, dmg); EntityItem ent = new EntityItem(world, x, y, z, is); ent.delayBeforeCanPickup = 10; world.spawnEntityInWorld(ent); return; } } Block.blocksList[id].dropBlockAsItem(world, x, y+1, z, world.getBlockMetadata(xread, yread, zread), 0); } } public void dig(World world, int x, int y, int z, int metadata) { this.support(world, x, y, z, metadata); int a = 0; if (metadata > 1) a = 1; int b = 1-a; int xread; int yread; int zread; if (step == 1) { pipemeta2 = pipemeta; pipemeta = 3; } else if (pipemeta > 2 && pipemeta2 != 3) pipemeta = pipemeta2; for (int i = 0; i < 7; i++) { for (int j = 0; j < 5; j++) { if (cutShape[i][j] || step == 1) { xread = x+step*xstep+a*(i-3); yread = y+step*ystep+(4-j); zread = z+step*zstep+b*(i-3); this.dropBlocks(xread, yread, zread, world, x, y, z, world.getBlockId(xread, yread, zread), world.getBlockMetadata(xread, yread, zread)); ReikaWorldHelper.legacySetBlockAndMetadataWithNotify(world, xread, yread, zread, mod_RotaryCraft.miningpipe.blockID, pipemeta); } } } step++; } @Override public void writeToNBT(NBTTagCompound NBT) { super.writeToNBT(NBT); NBT.setInteger("mode", mode); NBT.setBoolean("drops", drops); NBT.setInteger("step", step); for (int i = 0; i < 7; i++) { for (int j = 0; j < 5; j++) NBT.setBoolean("cut"+String.valueOf(i*7+j), cutShape[i][j]); } } /** * Reads a tile entity from NBT. */ @Override public void readFromNBT(NBTTagCompound NBT) { super.readFromNBT(NBT); mode = NBT.getInteger("mode"); drops = NBT.getBoolean("drops"); step = NBT.getInteger("step"); for (int i = 0; i < 7; i++) { for (int j = 0; j < 5; j++) cutShape[i][j] = NBT.getBoolean("cut"+String.valueOf(i*7+j)); } }
  13. If you know the slot in advance (like it was the active item), iteration is not necessary.
  14. Maybe a different approach is a better idea. How many recipes were you imagining?
  15. No, what I want is to make it so that the classes, fields, and method names get scrambled like in vanilla code.
  16. I use it, and it works...
  17. Um...bump?
  18. Um...bump?
  19. You connect the ingredients with array indices. Look again at the canSmelt() function. See the references to inventory[a], where a is an integer? Those are checking the specific slots in the inventory (which, as per your container file, relate to specific item "positions" in the GUI).
  20. I am using the recommended build (or, at least as of a few days ago). As for name changing, I agree - I HATE that. @Override helps, but it still means we have to go in and change names manually all the time...
  21. They are unrelated. Let me explain. Making the variable in Block static means other methods can access it without instantiating Block.class. The reason blocks only have one instance, however, is because all other block-creation code (world-gen, placing, etc) refers back to that one instance declared in Block. So that one instance is getting used everywhere.
  22. OK, there is one thing to note here: Blocks being defined as static in Block.class is completely unrelated to the issue here. static Block = new Block(stuff) Makes the Block variable static to the Block class. That is not (well, at least not directly) what makes Blocks themselves static and behave accordingly.
×
×
  • Create New...

Important Information

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