Jump to content

cookie545445

Members
  • Posts

    31
  • Joined

  • Last visited

Everything posted by cookie545445

  1. I managed to change the entity viewpoint relatively easily in 1.7.10, just change a field in Minecraft.getMinecraft(). I'll add the name of the field when I'm at home. EDIT: Minecraft.getMinecraft().renderViewEntity = (EntityLivingBase) event.target; is what I did. No reflection needed; renderViewEntity is public (this was in EntityInteractEvent handler).
  2. The block renders differently dependant on whether there's something in the slot or not.
  3. How else should I sync the inventory, IMessage?
  4. Any expansion on that statement?
  5. Line 2 removed, for some reason original "vanilla" crash doesn't come back. And no, markBlockForUpdate ISN'T resending the packet.
  6. I've installed the Baubles API what seems to me like correctly, with the API file linked to in Eclipse project setup and the deobf in the mods folder. Eclipse says there's no files in baubles.api unless I open it in the "navigator". I can't use the API because Eclipse just complains that IBauble doesn't exist and it won't tell me which unimplemented methods I need to add. Any help would be appreciated, also this probably isn't the right board to put this topic on . Edit: I solved this by referencing the deobf jar in eclipse instead of the api.
  7. Be more specific. Do you want everyone reading to spawn an entity in front of the player on item right click? If you mean a projectile, say so. If you mean a <? extends EntityLivingBase> then say so.
  8. That's not sending the packet, it's setting the null delegate that caused the first crash.
  9. Didn't do anything=no difference between before using markBlockForUpdate() and after. @Override public void setInventorySlotContents(int p_70299_1_, ItemStack p_70299_2_) { contents[p_70299_1_] = p_70299_2_; contents[p_70299_1_].func_150996_a(contents[p_70299_1_].getItem()); markDirty(); worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); } @Override public String getInventoryName() { return "Research Desk"; } @Override public boolean hasCustomInventoryName() { return false; } @Override public int getInventoryStackLimit() { return 64; } @Override public boolean isUseableByPlayer(EntityPlayer p_70300_1_) { return true; } @Override public void openInventory() {} @Override public void closeInventory() {} @Override public boolean isItemValidForSlot(int p_94041_1_, ItemStack p_94041_2_) { if (p_94041_2_ != null && p_94041_2_.getItem() == Item.itemRegistry.getObject("paper")) { return true; } else return false; } @Override public void readFromNBT(NBTTagCompound nbtTag) { super.readFromNBT(nbtTag); contents[0] = ItemStack.loadItemStackFromNBT(nbtTag.getCompoundTag("Item")); } @Override public void writeToNBT(NBTTagCompound nbtTag) { super.writeToNBT(nbtTag); NBTTagCompound item = new NBTTagCompound(); if (contents[0] != null) contents[0].writeToNBT(item); nbtTag.setTag("Item", item); } public ResourceLocation getBlockTexture() { if (contents[0] == null && contents[0] != new ItemStack((Item)null)) { return new ResourceLocation("soulwizardry:textures/blocks/ModelResearchDesk.png"); } else { return new ResourceLocation("soulwizardry:textures/blocks/ModelResearchDeskPaper.png"); } } @Override public Packet getDescriptionPacket() { NBTTagCompound tag = new NBTTagCompound(); writeToNBT(tag); return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 0, tag); } @Override public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { System.out.println("Packet!"); readFromNBT(pkt.func_148857_g()); } public ItemStack tryAddItemToSlot(int slot, ItemStack item) { // TODO: Cut down on the 'if's if (isItemValidForSlot(slot, item)) { if (contents[slot] != null) { if (contents[slot].getItem() == item.getItem() && contents[slot].getTagCompound() == item.getTagCompound()) { contents[slot].stackSize += item.stackSize; item.stackSize = 0; if (contents[slot].stackSize > contents[slot].getMaxStackSize()) { item.stackSize = contents[slot].stackSize - contents[slot].getMaxStackSize(); contents[slot].stackSize = contents[slot].getMaxStackSize(); } this.worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); } else return null; } else { contents[slot] = item; return null; } } return item; } }
  10. I found that on another post as well, still didn't do anything.
  11. @Override public void updateTick(World world, int x, int y, int z, Random rand) { EntityPlayer player = world.getClosestPlayer(x+0.5, y+0.5, z+0.5, -1); if (player.getDistanceSq(x, y, z)>1 && player.inventory.hasItemStack(new ItemStack(MOD.ACTIVATED_ITEM, 1, 1))) { world.setBlock(x, y, z, Blocks.air, 0, 3); } } @Override public boolean getTickRandomly() { return true; // Seems to be the only way to make it actually tick at all, tried removing, nothing happened } @Override public int onBlockPlaced(World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int meta) { world.scheduleBlockUpdate(x, y, z, this, 5); return meta; }
  12. I tried this and my block still didn't tick, so I looked at the declaration of scheduleBlockUpdate() and it did the most useful thing ever: {}. Any different methods that actually do something?
  13. That statement makes no sense. You are assigning something to contents[0] in readFromNBT, so the value of contents[0] does not matter, whether it's null or not. Sorry, I got confused between the staticness of readFromNBT() (non-static) and loadItemStackFromNBT() (static). That isn't the problem though. I fixed the crash with func_150996_a() but now the S35PacketUpdateTileEntity only gets sent once when you load the world.
  14. I can't do that because if I do it crashes with an NPE because contents[0] is null when I try to call loadItemStackFromNBT(). I ran func_150996_a() to set the null delegate every time setInventorySlotContents() gets called and that fixed the bug. Now S35PacketUpdateTileEntity only gets sent on world load for some reason, but I'm not sure if it did that anyway. Also markDirty() doesn't do anything.
  15. That's what stopped the crash. It actually sets the delegate so there isn't an NPE when you use getItem().
  16. It seems to be the only way to be able to call loadItemStackFromNBT() with nothing in the slot. I fixed the crash by calling func_150996_a() every time the item gets changed but now the changing texture doesn't work again. The S35PacketUpdateTileEntity only gets sent on world load, so I tried using markDirty() but that makes no difference.
  17. public class TileEntityResearchDesk extends TileEntity implements IInventory { private ItemStack[] contents = new ItemStack[2]; public TileEntityResearchDesk() { contents[0] = new ItemStack((Item)null); } @Override public int getSizeInventory() { return 2; } @Override public ItemStack getStackInSlot(int p_70301_1_) { return contents[p_70301_1_]; } @Override public ItemStack decrStackSize(int p_70298_1_, int p_70298_2_) { if (this.contents[p_70298_1_] != null) { ItemStack itemstack; if (this.contents[p_70298_1_].stackSize <= p_70298_2_) { itemstack = this.contents[p_70298_1_]; this.contents[p_70298_1_] = null; this.markDirty(); return itemstack; } else { itemstack = this.contents[p_70298_1_].splitStack(p_70298_2_); if (this.contents[p_70298_1_].stackSize == 0) { this.contents[p_70298_1_] = null; } this.markDirty(); return itemstack; } } else { return null; } } @Override public ItemStack getStackInSlotOnClosing(int p_70304_1_) { if (this.contents[p_70304_1_] != null) { ItemStack itemstack = this.contents[p_70304_1_]; this.contents[p_70304_1_] = null; return itemstack; } else return null; } @Override public void setInventorySlotContents(int p_70299_1_, ItemStack p_70299_2_) { contents[p_70299_1_] = p_70299_2_; contents[p_70299_1_].func_150996_a(contents[p_70299_1_].getItem()); } @Override public String getInventoryName() { return "Research Desk"; } @Override public boolean hasCustomInventoryName() { return false; } @Override public int getInventoryStackLimit() { return 64; } @Override public boolean isUseableByPlayer(EntityPlayer p_70300_1_) { return true; } @Override public void openInventory() {} @Override public void closeInventory() {} @Override public boolean isItemValidForSlot(int p_94041_1_, ItemStack p_94041_2_) { if (p_94041_2_.getItem() == Item.itemRegistry.getObject("paper")) { return true; } else return false; } @Override public void readFromNBT(NBTTagCompound nbtTag) { super.readFromNBT(nbtTag); contents[0] = ItemStack.loadItemStackFromNBT(nbtTag.getCompoundTag("Item")); } @Override public void writeToNBT(NBTTagCompound nbtTag) { super.writeToNBT(nbtTag); NBTTagCompound item = new NBTTagCompound(); if (contents[0] != null) contents[0].writeToNBT(item); nbtTag.setTag("Item", item); } public ResourceLocation getBlockTexture() { if (contents[0] == null) return new ResourceLocation("soulwizardry:textures/blocks/ModelResearchDesk.png"); else return new ResourceLocation("soulwizardry:textures/blocks/ModelResearchDeskPaper.png"); } @Override public Packet getDescriptionPacket() { NBTTagCompound tag = new NBTTagCompound(); writeToNBT(tag); return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 3, tag); } @Override public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { readFromNBT(pkt.func_148857_g()); } public ItemStack tryAddItemToSlot(int slot, ItemStack item) { // TODO: Cut down on the 'if's if (isItemValidForSlot(slot, item)) { if (contents[slot] != null) { if (contents[slot].getItem() == item.getItem()) { contents[slot].stackSize += item.stackSize; item.stackSize = 0; if (contents[slot].stackSize > contents[slot].getMaxStackSize()) { item.stackSize = contents[slot].stackSize - contents[slot].getMaxStackSize(); contents[slot].stackSize = contents[slot].getMaxStackSize(); } } else return null; } else { contents[slot] = item; return null; } } return item; } } I'm using 1 piece of paper.
  18. I made a tile entity that works ok, but whenever I try to add an item into it with a hopper (or take one out) it crashes with: I checked and ItemStack.getMaxStackSize() is at ItemStack.java:214 which is what the report blames and it calls ItemStack.getItem() which uses an uninitialised delegate. The report doesn't reference any of my code whatsoever. After the crash the item's in the tile entity and everything, just doesn't like it when it goes in/out.
  19. Fixed! I read http://www.minecraftforge.net/forum/index.php/topic,24181.0.html, and realised that "oh, why not call readFromNBT()? It loads the item and everything..." so I did and now it works! Only it flashes paper on the desk for about a tick then goes back to normal, but I'm sure I'll figure it out.
  20. I can't think of a way to do this. For some reason using contents[0] = ItemStack.loadItemStackFromNBT(pkt.func_148857_g().getCompoundTag("Item")); makes the render method only get called once, but I can't use contents[0].readFromNBT(pkt.funt_148857_g().getCompoundTag("Item")); because contents[0] is null.
  21. Yeah, as expected, I crashed with an NPE at the line: contents[0].readFromNBT(pkt.func_148857_g().getCompoundTag("Item"));
  22. I swear I tried that and crashed with an NPE, but I'll try again and see what happens.
  23. Don't be on java 8.
  24. public class TileEntityResearchDesk extends TileEntity implements IInventory { private ItemStack[] contents = new ItemStack[1]; @Override public int getSizeInventory() { return 1; } @Override public ItemStack getStackInSlot(int p_70301_1_) { return contents[p_70301_1_]; } @Override public ItemStack decrStackSize(int p_70298_1_, int p_70298_2_) { if (this.contents[p_70298_1_] != null) { ItemStack itemstack; if (this.contents[p_70298_1_].stackSize <= p_70298_2_) { itemstack = this.contents[p_70298_1_]; this.contents[p_70298_1_] = null; this.markDirty(); return itemstack; } else { itemstack = this.contents[p_70298_1_].splitStack(p_70298_2_); if (this.contents[p_70298_1_].stackSize == 0) { this.contents[p_70298_1_] = null; } this.markDirty(); return itemstack; } } else { return null; } } @Override public ItemStack getStackInSlotOnClosing(int p_70304_1_) { if (this.contents[p_70304_1_] != null) { ItemStack itemstack = this.contents[p_70304_1_]; this.contents[p_70304_1_] = null; return itemstack; } else return null; } @Override public void setInventorySlotContents(int p_70299_1_, ItemStack p_70299_2_) { contents[p_70299_1_] = p_70299_2_; } @Override public String getInventoryName() { return "Research Desk"; } @Override public boolean hasCustomInventoryName() { return false; } @Override public int getInventoryStackLimit() { return 1; } @Override public boolean isUseableByPlayer(EntityPlayer p_70300_1_) { return true; } @Override public void openInventory() {} @Override public void closeInventory() {} @Override public boolean isItemValidForSlot(int p_94041_1_, ItemStack p_94041_2_) { if (p_94041_2_.getItem() == Item.itemRegistry.getObject("paper")) { return true; } else return false; } @Override public void readFromNBT(NBTTagCompound nbtTag) { super.readFromNBT(nbtTag); contents[0] = ItemStack.loadItemStackFromNBT(nbtTag.getCompoundTag("Item")); } @Override public void writeToNBT(NBTTagCompound nbtTag) { super.writeToNBT(nbtTag); NBTTagCompound item = new NBTTagCompound(); if (contents[0] != null) contents[0].writeToNBT(item); nbtTag.setTag("Item", item); } public ResourceLocation getBlockTexture() { if (getStackInSlot(0) == null) { System.out.println("Loaded No Paper Texture"); return new ResourceLocation("soulwizardry:textures/blocks/ModelResearchDesk.png"); } else { System.out.println("Loaded Paper Texture"); return new ResourceLocation("soulwizardry:textures/blocks/ModelResearchDeskPaper.png"); } } @Override public Packet getDescriptionPacket() { NBTTagCompound tag = new NBTTagCompound(); writeToNBT(tag); return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 3, tag); } @Override public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { xCoord = pkt.func_148853_f(); yCoord = pkt.func_148854_e(); zCoord = pkt.func_148855_d(); contents[0].loadItemStackFromNBT(pkt.func_148857_g()); } } public class RenderResearchDesk extends TileEntitySpecialRenderer { private final ModelResearchDesk model; @Override public void renderTileEntityAt(TileEntity p_147500_1_, double x, double y, double z, float scale) { System.out.println("rendering"); TileEntityResearchDesk tentity = (TileEntityResearchDesk) p_147500_1_; GL11.glPushMatrix(); GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F); ResourceLocation textures = tentity.getBlockTexture(); Minecraft.getMinecraft().renderEngine.bindTexture(textures); System.out.println("Got the texture, bound it"); GL11.glPushMatrix(); GL11.glRotatef(180F, 0F, 0F, 1F); this.model.render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); GL11.glPopMatrix(); GL11.glPopMatrix(); } public RenderResearchDesk() { model = new ModelResearchDesk(); } private void adjustRotatePivotViaMeta(World world, int x, int y, int z) { int meta = world.getBlockMetadata(x, y, z); GL11.glPushMatrix(); GL11.glRotatef(meta * (-90), 0.0F, 0.0F, 1.0F); GL11.glPopMatrix(); } private void adjustLightFixture(World world, int i, int j, int k, Block block) { Tessellator tess = Tessellator.instance; float brightness = block.getLightValue(world, i, j, k); int skyLight = world.getLightBrightnessForSkyBlocks(i, j, k, 0); int modulousModifier = skyLight % 65536; int divModifier = skyLight / 65536; tess.setColorOpaque_F(brightness, brightness, brightness); OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float) modulousModifier, divModifier); } }
  25. I tried that, but now the block doesn't render at all. It renders for a few ticks, then it seems after a bit of debugging System.out.println()s that renderTileEntityAt() isn't even getting called. I commented out the packet methods you told me about and it worked fine, without the syncing.
×
×
  • Create New...

Important Information

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