Jump to content

DanteZg

Members
  • Posts

    13
  • Joined

  • Last visited

Everything posted by DanteZg

  1. I have fixed that error with packets. Yeah here is my code: @Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9) { if(!world.isRemote){ TileEntityTable par1tileEntity = (TileEntityTable)world.getBlockTileEntity(x, y, z); if (player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() == net.woodworks.common.WoodworksCommonProxy.itemModCloth && par1tileEntity.getState() == 0) { int par1ItemDamage = player.getCurrentEquippedItem().getItemDamage(); par1tileEntity.setState(par1ItemDamage + 1); world.notifyBlockChange(x, y, z, this.blockID); player.inventory.decrStackSize(player.inventory.currentItem, 1); player.worldObj.playSoundAtEntity(player, "dig.cloth", 1.0F, 1.0F); return true; } else if(player.getCurrentEquippedItem().getItem() != net.woodworks.common.WoodworksCommonProxy.itemModCloth && par1tileEntity.getState() != 0){ int par1ItemDamage = par1tileEntity.getState(); dropItemStack(new ItemStack(net.woodworks.common.WoodworksCommonProxy.itemModCloth, 1, par1ItemDamage-1), world, x, y, z); par1tileEntity.setState(0); world.notifyBlockChange(x, y, z, this.blockID); player.worldObj.playSoundAtEntity(player, "dig.cloth", 1.0F, 1.0F); return true; } else if(player.getCurrentEquippedItem().getItem() == net.woodworks.common.WoodworksCommonProxy.itemModCloth && par1tileEntity.getState() != 0){ int par1ItemDamage = player.getCurrentEquippedItem().getItemDamage(); int par1State = par1tileEntity.getState(); if(par1ItemDamage != par1State-1){ player.inventory.decrStackSize(player.inventory.currentItem, 1); dropItemStack(new ItemStack(net.woodworks.common.WoodworksCommonProxy.itemModCloth, 1, par1State-1), world, x, y, z); par1tileEntity.setState(par1ItemDamage + 1); world.notifyBlockChange(x, y, z, this.blockID); player.worldObj.playSoundAtEntity(player, "dig.cloth", 1.0F, 1.0F); return true; } } else if(par1tileEntity.getState() == 1 && player.getCurrentEquippedItem().getItem() == Item.dyePowder){ int par1ItemDamage = player.getCurrentEquippedItem().getItemDamage(); player.inventory.decrStackSize(player.inventory.currentItem, 1); par1tileEntity.setState(par1ItemDamage +1); world.notifyBlockChange(x, y, z, this.blockID); player.worldObj.playSoundAtEntity(player, "dig.cloth", 1.0F, 1.0F); return true; } } return true; } However the textures only change after you rejoin the world. EDIT: I threw a bunch of this rerender methods(check to new code) and now it rerenders after clicking right click 2 times with the same item. Any ideas now? public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9) { if(!world.isRemote){ TileEntityTable par1tileEntity = (TileEntityTable)world.getBlockTileEntity(x, y, z); if (player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() == net.woodworks.common.WoodworksCommonProxy.itemModCloth && par1tileEntity.getState() == 0) { int par1ItemDamage = player.getCurrentEquippedItem().getItemDamage(); par1tileEntity.setState(par1ItemDamage + 1); world.notifyBlockChange(x, y, z, this.blockID); player.worldObj.markBlockForRenderUpdate(x, y, z); player.inventory.decrStackSize(player.inventory.currentItem, 1); player.worldObj.playSoundAtEntity(player, "dig.cloth", 1.0F, 1.0F); return true; } else if(player.getCurrentEquippedItem().getItem() != net.woodworks.common.WoodworksCommonProxy.itemModCloth && par1tileEntity.getState() != 0){ int par1ItemDamage = par1tileEntity.getState(); dropItemStack(new ItemStack(net.woodworks.common.WoodworksCommonProxy.itemModCloth, 1, par1ItemDamage-1), world, x, y, z); par1tileEntity.setState(0); world.notifyBlockChange(x, y, z, this.blockID); player.worldObj.markBlockForRenderUpdate(x, y, z); player.worldObj.playSoundAtEntity(player, "dig.cloth", 1.0F, 1.0F); return true; } else if(player.getCurrentEquippedItem().getItem() == net.woodworks.common.WoodworksCommonProxy.itemModCloth && par1tileEntity.getState() != 0){ int par1ItemDamage = player.getCurrentEquippedItem().getItemDamage(); int par1State = par1tileEntity.getState(); if(par1ItemDamage != par1State-1){ player.inventory.decrStackSize(player.inventory.currentItem, 1); dropItemStack(new ItemStack(net.woodworks.common.WoodworksCommonProxy.itemModCloth, 1, par1State-1), world, x, y, z); par1tileEntity.setState(par1ItemDamage + 1); world.notifyBlockChange(x, y, z, this.blockID); player.worldObj.markBlockForRenderUpdate(x, y, z); player.worldObj.playSoundAtEntity(player, "dig.cloth", 1.0F, 1.0F); return true; } } else if(par1tileEntity.getState() == 1 && player.getCurrentEquippedItem().getItem() == Item.dyePowder){ int par1ItemDamage = player.getCurrentEquippedItem().getItemDamage(); player.inventory.decrStackSize(player.inventory.currentItem, 1); par1tileEntity.setState(par1ItemDamage +1); world.notifyBlockChange(x, y, z, this.blockID); player.worldObj.markBlockForRenderUpdate(x, y, z); player.worldObj.playSoundAtEntity(player, "dig.cloth", 1.0F, 1.0F); return true; } } world.markBlockForUpdate(x,y,z); world.notifyBlockChange(x, y, z, this.blockID); player.worldObj.markBlockForRenderUpdate(x, y, z); Minecraft.getMinecraft().renderGlobal.markBlockForRenderUpdate(x, y, z); return true; } EDIT2: Got it to work! I will post my final code later tonight (I need to rewrite some things) so everyone with this problem can use it! Thank you for your help Draco! EDIT3: Server crashes now! EDIT4: Code works but it needs some serious rewriting, I'll be back in a few.
  2. Okay I have figured out what have I done wrong and I have fixed that NullPointException, now the same thing happens on the server, when I setState to integer, the texture doesnt change until I log out and log in again. Please help me, this is the last thing holding me from releasing my mod.
  3. OK I have noticed that when I'm in singleplayer and after I quit and then rejoin the textures get updated. When I'm testing the server I get this error: ---- Minecraft Crash Report ---- // I just don't know what went wrong Time: 1/16/14 9:30 PM Description: Ticking memory connection java.lang.NullPointerException at net.woodworks.blocks.BlockTable.onBlockActivated(BlockTable.java:166) at net.minecraft.item.ItemInWorldManager.activateBlockOrUseItem(ItemInWorldManager.java:421) at net.minecraft.network.NetServerHandler.handlePlace(NetServerHandler.java:556) at net.minecraft.network.packet.Packet15Place.processPacket(Packet15Place.java:79) at net.minecraft.network.MemoryConnection.processReadPackets(MemoryConnection.java:89) at net.minecraft.network.NetServerHandler.networkTick(NetServerHandler.java:141) at net.minecraft.network.NetworkListenThread.networkTick(NetworkListenThread.java:54) at net.minecraft.server.integrated.IntegratedServerListenThread.networkTick(IntegratedServerListenThread.java:109) at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:691) at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:587) at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:129) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:484) at net.minecraft.server.ThreadMinecraftServer.run(ThreadMinecraftServer.java:16) If you're changing from one missing texture to another... I'm not
  4. Yes, Its saved, everything else works, except that the textures stay the same. I havent finished all the textures, so when I run the game I get an error missing texture bla bla, it isnt possible that this could be causing this error? Aslo, you have my code above if you are interested in helping me out. Thank you btw.
  5. Thank you! However I never made a mod where I would have to sync packets. So I really dont know how this is done. Where should I put this? Inside your tile entity class. That's ALL you need to do in this case. Thats what I tought, however the still texture doesnt update/change. Even when I manually force a block to update.
  6. Thank you! However I never made a mod where I would have to sync packets. So I really dont know how this is done. Where should I put this?
  7. package net.woodworks.tileentity; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; public class TileEntityTable extends TileEntity { private int cloth; private int rotation; @Override public void writeToNBT(NBTTagCompound compound) { super.writeToNBT(compound); compound.setInteger("cloth", cloth); compound.setInteger("rotation", rotation); } @Override public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); cloth=compound.getInteger("cloth"); rotation=compound.getInteger("rotation"); } //Getter public int getState() { return cloth; } public int getRotation() { return rotation; } //Setter public void setState(int par1) { cloth = par1; System.out.println("Setting state integer:" + par1); } public void setRotation(int par1) { rotation = par1; System.out.println("Setting rotation integer:" + par1); } }
  8. Im trying to bind a different texture for my render based on variable stored in TileEntity, but the texture doesnt update(even when I place a block next to it, nothing changes). How can I force it to update? Here is my code(some parts are complete mess, especially renderer, used just for testing). Block Renderer(complete mess here) Every code I try doesnt seem to work.
  9. Ohhh I see. How can I make it request metadata from my block? You would need to poll the itemstack. Can you please provide me some open source codes or give me an example, never heard of this thing, I started modding forge 4 days ago.
  10. Ohhh I see. How can I make it request metadata from my block?
  11. I'm trying to render custom block which uses metadata for binding textures but my Minecraft crashes. Im trying to fix this for 4 hours straight now. Simple problem which you will probably notice in 1 min and I'm working on it for 4 hours without results. Crash Report: ItemRenderer Renderer: From what I was able to read from the crashreport I noticed that if I change this code: if(tileentity.getBlockMetadata() == 0){ this.bindTexture(texture1);} if(tileentity.getBlockMetadata() == 1){ this.bindTexture(texture2);} if(tileentity.getBlockMetadata() == 2){ this.bindTexture(texture3);} if(tileentity.getBlockMetadata() == 3){ this.bindTexture(texture4);} to this code: this.bindTexture(texture1); everything works fine and every block metadata in Inventory has texture1. But I need all of them to work. Anyone can help me with this problem?
×
×
  • Create New...

Important Information

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