Jump to content

daafganggdg

Members
  • Posts

    141
  • Joined

  • Last visited

Everything posted by daafganggdg

  1. TE: public class TileEntityCauldron extends TileEntity implements ISidedInventory{ private ItemStack[] slots = new ItemStack[9]; private Item content = null; @Override public int getSizeInventory() { return 0; } @Override public ItemStack getStackInSlot(int var1) { if(!this.isInvalid()) return this.slots[var1]; return null; } @Override public void updateEntity(){ } @Override public ItemStack decrStackSize(int var1, int var2) { if(this.slots[var1] != null) { ItemStack itemstack; if(this.slots[var1].stackSize <= var2) { itemstack = this.slots[var1]; this.slots[var1] = null; return itemstack; } else { itemstack = this.slots[var1].splitStack(var2); if(this.slots[var1].stackSize == 0) { this.slots[var1] = null; } return itemstack; } } else return null; } @Override public ItemStack getStackInSlotOnClosing(int var1) { if(this.slots[var1] != null) { ItemStack itemstack = this.slots[var1]; this.slots[var1] = null; return itemstack; } return null; } @Override public void setInventorySlotContents(int var1, ItemStack var2) { this.slots[var1] = var2; if(var2 != null && var2.stackSize > this.getInventoryStackLimit()) { var2.stackSize = this.getInventoryStackLimit(); } } @Override public String getInventoryName() { return null; } @Override public boolean hasCustomInventoryName() { // return this.localizedName != null && this.localizedName.length() > 0; return false; } @Override public int getInventoryStackLimit() { return 64; } @Override public boolean isUseableByPlayer(EntityPlayer player) { return this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : player.getDistanceSq((double)this.xCoord + 0.5D, (double)this.yCoord + 0.5D, (double)this.zCoord + 0.5D) <= 64; } @Override public void openInventory() { } @Override public void closeInventory() { } @Override public boolean isItemValidForSlot(int var1, ItemStack stack) { return true; } @Override public int[] getAccessibleSlotsFromSide(int var1) { return null; } @Override public boolean canInsertItem(int var1, ItemStack var2, int var3) { return this.isItemValidForSlot(var1, var2); } @Override public boolean canExtractItem(int var1, ItemStack var2, int var3) { return false; } public void serverSideClick() { Item item = CauldronRecipes.getResult(this.content, this.slots); if(item != null) { this.content = item; this.slots = new ItemStack[9]; } } public void onButtonClick() { Civilized.network.sendToServer(new CallServerMessage(xCoord, yCoord, zCoord)); } public Item getContent() { return this.content; } @Override public Packet getDescriptionPacket() { super.getDescriptionPacket(); NBTTagCompound nbt = new NBTTagCompound(); nbt.setInteger("content", Item.getIdFromItem(this.content)); System.out.println("PACKET SEND"); return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 2, nbt); } @Override public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { super.onDataPacket(net, pkt); this.content = Item.getItemById(pkt.func_148857_g().getInteger("content")); System.out.println(Item.getItemById(pkt.func_148857_g().getInteger("content")) != null ? Item.getItemById(pkt.func_148857_g().getInteger("content")).getUnlocalizedName() : "empty"); } public void setContent(Item item) { this.content = item; this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); } public void readFromNBT(NBTTagCompound nbt) { this.content = Item.getItemById(nbt.getInteger("content")); super.readFromNBT(nbt); NBTTagList nbttaglist = nbt.getTagList("Items", 10); this.slots = new ItemStack[this.getSizeInventory()]; for (int i = 0; i < nbttaglist.tagCount(); ++i) { NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); byte b0 = nbttagcompound1.getByte("Slot"); if (b0 >= 0 && b0 < this.slots.length) { this.slots[b0] = ItemStack.loadItemStackFromNBT(nbttagcompound1); } } } public void writeToNBT(NBTTagCompound nbt) { super.writeToNBT(nbt); nbt.setInteger("content", Item.getIdFromItem(this.content)); NBTTagList nbttaglist = new NBTTagList(); for (int i = 0; i < this.slots.length; ++i) { if (this.slots[i] != null) { NBTTagCompound nbttagcompound1 = new NBTTagCompound(); nbttagcompound1.setByte("Slot", (byte)i); this.slots[i].writeToNBT(nbttagcompound1); nbttaglist.appendTag(nbttagcompound1); } } nbt.setTag("Items", nbttaglist); } } ISBRH: (Yes its the vanilla cauldron code, completly unobviouscated public class CauldronRenderer implements ISimpleBlockRenderingHandler { @Override public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) { } @Override public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { block = Blocks.cauldron; renderer.renderStandardBlock(block, x, y, z); Tessellator tessellator = Tessellator.instance; tessellator.setBrightness(block.getMixedBrightnessForBlock(renderer.blockAccess, x, y, z)); int l = block.colorMultiplier(renderer.blockAccess, x, y, z); float f = (float)(l >> 16 & 255) / 255.0F; float f1 = (float)(l >> 8 & 255) / 255.0F; float f2 = (float)(l & 255) / 255.0F; float f4; if (EntityRenderer.anaglyphEnable) { float f3 = (f * 30.0F + f1 * 59.0F + f2 * 11.0F) / 100.0F; f4 = (f * 30.0F + f1 * 70.0F) / 100.0F; float f5 = (f * 30.0F + f2 * 70.0F) / 100.0F; f = f3; f1 = f4; f2 = f5; } tessellator.setColorOpaque_F(f, f1, f2); IIcon iicon1 = block.getBlockTextureFromSide(2); f4 = 0.125F; renderer.renderFaceXPos(block, (double)((float)x - 1.0F + f4), (double)y, (double)z, iicon1); renderer.renderFaceXNeg(block, (double)((float)x + 1.0F - f4), (double)y, (double)z, iicon1); renderer.renderFaceZPos(block, (double)x, (double)y, (double)((float)z - 1.0F + f4), iicon1); renderer.renderFaceZNeg(block, (double)x, (double)y, (double)((float)z + 1.0F - f4), iicon1); IIcon iicon2 = BlockCauldron.getCauldronIcon("inner"); renderer.renderFaceYPos(block, (double)x, (double)((float)y - 1.0F + 0.25F), (double)z, iicon2); renderer.renderFaceYNeg(block, (double)x, (double)((float)y + 1.0F - 0.75F), (double)z, iicon2); System.out.println("RENDERING"); TileEntityCauldron tileEntity = (TileEntityCauldron) world.getTileEntity(x, y, z); if (tileEntity != null) { IIcon iicon = null; if(tileEntity.getContent() == Items.water_bucket) iicon = BlockLiquid.getLiquidIcon("water_still"); // else iicon = MyBlocks.CauldronBlock.getIcon(0, 0); //TODO if(iicon != null) renderer.renderFaceYPos(block, x, y - 0.0625F * 2, z, iicon); } return true; } @Override public boolean shouldRender3DInInventory(int modelId) { return false; } @Override public int getRenderId() { return MyBlocks.CauldronBlock.getRenderType(); } } I'm not done yet, sorry if its a little mess
  2. Uhm i dont have a TESR but a ISBRH, is that a problem?
  3. @Override public Packet getDescriptionPacket() { NBTTagCompound nbt = new NBTTagCompound(); nbt.setInteger("content", Item.getIdFromItem(this.content)); System.out.println("PACKET SENT"); return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 2, nbt); } @Override public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { super.onDataPacket(net, pkt); this.content = Item.getItemById(pkt.func_148857_g().getInteger("content")); net.processReceivedPackets(); System.out.println(Item.getItemById(pkt.func_148857_g().getInteger("content")) != null ? Item.getItemById(pkt.func_148857_g().getInteger("content")).getUnlocalizedName() : "empty"); } console: (right clicking with water bucket) PACKET SENT item.bucketWater (right clicking with empty bucket) PACKET SENT empty (right clicking with water bucket) PACKET SENT item.bucketWater soo, just how its supposed to work..
  4. When i use world.markBlockForUpdate(x, y, z); client and server side its working Is that normal? Edit: Actually no, now its now rendering the last state, like it should render stateB its rendering stateA, it should render stateC its rendering stateB, it should render stateD its rendering stateC...
  5. @Override public Packet getDescriptionPacket() { NBTTagCompound nbt = new NBTTagCompound(); nbt.setInteger("content", Item.getIdFromItem(this.content)); return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, nbt); } @Override public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { super.onDataPacket(net, pkt); this.content = Item.getItemById(pkt.func_148857_g().getInteger("content")); net.processReceivedPackets(); } I already do
  6. I'm using an ISimpleBlockRenderingHandler to render a block, depending on a variable in the TileEntity of that block. I change that variable in the onBlockActivated() method of the block. However, it only renders correctly when i remove the world.isRemote check and i think that because the client tileEntity is synchronized after the rendering. But I heard you should do all the tileEntity stuff on server only. I guess when running that mod on a server only the player that clicked the block is actually going to see the changes in the rendering.. So well What can i do to get this to work?
  7. 47? i came up with 16 1 for no side connected 1 for all sides 2 for 2 opposite sides 4 for 2 sides in a corner 4 for 1 side 4 for 3 sides well probably confusing maybe a ISBRH is better, dunno what that is ^^
  8. Alright look, its like saying "2" == 2, for our human eye its 2 and 2 and thats ofc the same but for a computer its a string and an integer and you can never ever compare these types like that. Same as an itemStack is not an item. you can use item.getItem tho.. Then you have the item of the itemStack and you can compare it with a item
  9. Hi, youre going to need a texture for every possible state and register them in registerBlockIcons, then use the method onBlockAdded to detect if blocks of the same type are around and change the blocks metadata. use the method onNeighborBlockChange to detect if blocks of the same type are placed or removed later on and again, change the metadata. in getIcon you then return one of the different textures you registered depending on the metadata.. Hope that's not confusing
  10. you mean inside minecraft? Maybe make an item similar to the name tag..
  11. nbt.setInteger("meta", worldObj.getBlockMetadata(xCoord, yCoord, zCoord)); alright now its working, thanks
  12. Alright thats what I came up with: @Override public Packet getDescriptionPacket() { NBTTagCompound nbt = new NBTTagCompound(); nbt.setInteger("meta", this.blockMetadata); return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, nbt); } @Override public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { super.onDataPacket(net, pkt); this.blockMetadata = pkt.func_148857_g().getInteger("meta"); } in my TileEntity and in the renderer: @Override public void renderTileEntityAt(TileEntity entity, double x, double y, double z, float f) { //.... int m = entity.blockMetadata; //.... But still not working
  13. data in the tileEntity instance, how do I sync it? Why is the TileEntity metadata getting synced automatically when i place the block and set the metadate of the block?
  14. Hi, I have a TESR that renders a block different based on the metadata and its all working fine until i load the world again, The metadata from the block is right but in the TESR its 0.. Why is it not loading the metadata correctly?
  15. Havent tried anything so far, just asking if there's a method like "setRenderDistance" or something like that.. Still can poste code if you want to, the Renderer or the Entity?
  16. Hi, my custom mob stops rendering like 3 blocks or something.. How can I increase the render distance?
  17. Jup, but still wondering about that weird y coord behavior with the wanderer
  18. Everything is possible - Java Its just about how much time you want to invest in creating a mod
  19. Hi me again So, I thought it may be a good idea to use the EntityAIWander and the just handle the motionY in the update method of my entity manually, however EntityAIWander only sets the path of my entity to a "viable" location so, on superflat only height 4, and I dont really understand why? EntityAIWander uses RandomPositionGenerator.findRandomTarget(this.entity, 10, 7); to get a random Vec3 and then sets the path of the entity to it, cant find anything changing the y coord..
  20. Uhm, you mean some kind of like that: int x = 0; public void updateEntity(){ if(x == 40) { x = 0 /... } x++ } It would be probably smarter to send packets only if the data actually changed, just set a boolean whenever you are changing the data and check for the boolean when you are sending the packet, wich, I assume you do in updateEntity()
  21. You can basically also use the metadata like: isNight & previousState metadata = 1 isNight & !previousState metadata = 2 !isNight & previousState metadata = 3 !isNight & !previousState metadata = 4
  22. A bee And thanks for the links @jabelar
×
×
  • Create New...

Important Information

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