Jump to content

kenoba10

Members
  • Posts

    127
  • Joined

  • Last visited

Converted

  • Gender
    Undisclosed
  • Personal Text
    I am new!

kenoba10's Achievements

Creeper Killer

Creeper Killer (4/8)

6

Reputation

  1. It doesn't look like you commented out all of your code and you have a GameRegistry.ObjectHolder annotation somewhere it shouldn't be. Remove that and it should work
  2. yes in the direction it faces, I got it figured out by doing what you said and if the meta = 0, render it the way I want it to
  3. I have a block that has a few different textures and I hae gotten it so, the front texture faces you when it is placed. But how would I make the icon when it is in my inventory display similar to how the furnace does? Here is my code: @SideOnly(Side.CLIENT) private IIcon blockTop; @SideOnly(Side.CLIENT) private IIcon blockSide; public BlockFactoryTerminal() { super(); this.setBlockName("factoryFactoryTerminal"); } public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack) { int l = MathHelper.floor_double((double) (player.rotationYaw * 4f / 360f) + .5d) & 3; if(l == 0) world.setBlockMetadataWithNotify(x, y, z, 2, 2); if(l == 1) world.setBlockMetadataWithNotify(x, y, z, 5, 2); if(l == 2) world.setBlockMetadataWithNotify(x, y, z, 3, 2); if(l == 3) world.setBlockMetadataWithNotify(x, y, z, 4, 2); } @SideOnly(Side.CLIENT) public void registerBlockIcons(IIconRegister iconRegister) { blockIcon = iconRegister.registerIcon(String.format("%s", getUnWrappedUnlocalizedName(this.getUnlocalizedName()))); blockTop = iconRegister.registerIcon(String.format("%s", getUnWrappedUnlocalizedName(ElectricFactoryBlocks.factoryFactoryStructureBlock.getUnlocalizedName() + "Top"))); blockSide = iconRegister.registerIcon(String.format("%s", getUnWrappedUnlocalizedName(ElectricFactoryBlocks.factoryFactoryStructureBlock.getUnlocalizedName()))); } @SideOnly(Side.CLIENT) public IIcon getIcon(int side, int meta) { if(side == 0 || side == 1) return blockTop; else if(side != meta) return blockSide; else return blockIcon; }
  4. I may have figured it out but the fix is a bit weird. I have another block that on every update edits the internal power and if I wait to manipulate the variables until the end of the method, it works more often. I think I should be able to get it working now though.
  5. This is strange. I tried what you said and it actually loaded up correctly. Then I loaded up the world again and it crashed saying that the tile entity was null. Also, I have done this on separate worlds and they all do this.
  6. That is most likely not the issue because it only happens when buildcraft energy pipes are connected to it. Here is my tile entity code though: public class PowerFactoryTileEntity extends TileEntity implements IInventory, IFluidHandler { private ItemStack[] itemInventory; private FluidTank tankWater; private FluidTank tankLava; private int energy = 0; public PowerFactoryTileEntity() { itemInventory = new ItemStack[8]; tankWater = new FluidTank(FluidRegistry.WATER, 0, FluidContainerRegistry.BUCKET_VOLUME * 4); tankLava = new FluidTank(FluidRegistry.LAVA, 0, FluidContainerRegistry.BUCKET_VOLUME * 4); } public String getInventoryName() { return "container.electricfactory:factoryPower"; } public boolean hasCustomInventoryName() { return false; } public int getSizeInventory() { return itemInventory.length; } public int getInventoryStackLimit() { return 64; } public boolean isUseableByPlayer(EntityPlayer player) { return true; } public void openInventory() { } public void closeInventory() { } public boolean isItemValidForSlot(int index, ItemStack stack) { return true; } public ItemStack getStackInSlot(int index) { return itemInventory[index]; } public ItemStack getStackInSlotOnClosing(int index) { if(itemInventory[index] != null) { itemInventory[index] = null; return itemInventory[index]; } return null; } public ItemStack decrStackSize(int index, int amount) { ItemStack stack = getStackInSlot(index); if(stack != null) { if(stack.stackSize <= amount) { setInventorySlotContents(index, null); } else { stack = stack.splitStack(amount); if(stack.stackSize == 0) setInventorySlotContents(index, null); } } return stack; } public void setInventorySlotContents(int index, ItemStack stack) { itemInventory[index] = stack; if(stack != null && stack.stackSize > getInventoryStackLimit()) stack.stackSize = getInventoryStackLimit(); markDirty(); } public int fill(ForgeDirection side, FluidStack stack, boolean fill) { int filled; if(stack.getFluid() == FluidRegistry.WATER) filled = tankWater.fill(stack, fill); else if(stack.getFluid() == FluidRegistry.LAVA) filled = tankLava.fill(stack, fill); else filled = 0; if(!worldObj.isRemote) Packets.INSTANCE.sendToAll(new PowerFactoryPacket(this)); return filled; } public FluidStack drain(ForgeDirection side, FluidStack stack, boolean drain) { return null; } public FluidStack drain(ForgeDirection side, int max, boolean drain) { return null; } public boolean canFill(ForgeDirection side, Fluid fluid) { return fluid == FluidRegistry.WATER || fluid == FluidRegistry.LAVA; } public boolean canDrain(ForgeDirection side, Fluid fluid) { return false; } public FluidTankInfo[] getTankInfo(ForgeDirection side) { return new FluidTankInfo[] {tankWater.getInfo(), tankLava.getInfo()}; } public Packet getDescriptionPacket() { return Packets.INSTANCE.getPacketFrom(new PowerFactoryPacket(this)); } public void updateEntity() { super.updateEntity(); } public void readFromNBT(NBTTagCompound tagCompound) { super.readFromNBT(tagCompound); NBTTagList tags = tagCompound.getTagList("items", 10); for(int i = 0; i < tags.tagCount(); i++) { NBTTagCompound tag = tags.getCompoundTagAt(i); byte index = tag.getByte("slot"); if(index >= 0 && index < itemInventory.length) itemInventory[index] = ItemStack.loadItemStackFromNBT(tag); } NBTTagCompound tagWater = tagCompound.getCompoundTag("water"); NBTTagCompound tagLava = tagCompound.getCompoundTag("lava"); tankWater.readFromNBT(tagWater); tankLava.readFromNBT(tagLava); energy = tagCompound.getInteger("energy"); } public void writeToNBT(NBTTagCompound tagCompound) { super.writeToNBT(tagCompound); NBTTagList tags = new NBTTagList(); for(int i = 0; i < itemInventory.length; i++) { if(itemInventory[i] != null) { NBTTagCompound tag = new NBTTagCompound(); tag.setByte("slot", (byte)i); itemInventory[i].writeToNBT(tag); tags.appendTag(tag); } } tagCompound.setTag("items", tags); NBTTagCompound tagWater = new NBTTagCompound(); NBTTagCompound tagLava = new NBTTagCompound(); tankWater.writeToNBT(tagWater); tankLava.writeToNBT(tagLava); tagCompound.setTag("water", tagWater); tagCompound.setTag("lava", tagLava); tagCompound.setInteger("energy", energy); } public int getEnergy() { return energy; } public void setEnergy(int energy) { if(energy > PowerFactoryMultiBlock.getPowerCells(worldObj, xCoord, yCoord, zCoord) * 200000) return; this.energy = energy; if(!worldObj.isRemote) Packets.INSTANCE.sendToAll(new PowerFactoryPacket(this)); } public void addEnergy(int energy) { if(this.energy + energy > PowerFactoryMultiBlock.getPowerCells(worldObj, xCoord, yCoord, zCoord) * 200000) return; this.energy += energy; if(!worldObj.isRemote) Packets.INSTANCE.sendToAll(new PowerFactoryPacket(this)); } public void removeEnergy(int energy) { if(this.energy - energy > PowerFactoryMultiBlock.getPowerCells(worldObj, xCoord, yCoord, zCoord) * 200000) return; this.energy -= energy; if(!worldObj.isRemote) Packets.INSTANCE.sendToAll(new PowerFactoryPacket(this)); } }
  7. maybe try extending BlockStairs?
  8. In my mod, I setup a packet to handle fluids before and it worked just fine. However, now that I added energy along with BuildCraft support, the world crashes when it loads if pipes from BuildCraft are next to the block. Here is my crash log. [18:40:16] [Client thread/ERROR] [FML]: SimpleChannelHandlerWrapper exception java.lang.NullPointerException at com.kenoba10.electricfactory.network.packet.PowerFactoryPacket.onMessage(PowerFactoryPacket.java:69) ~[PowerFactoryPacket.class:?] at com.kenoba10.electricfactory.network.packet.PowerFactoryPacket.onMessage(PowerFactoryPacket.java:11) ~[PowerFactoryPacket.class:?] at cpw.mods.fml.common.network.simpleimpl.SimpleChannelHandlerWrapper.channelRead0(SimpleChannelHandlerWrapper.java:34) ~[simpleChannelHandlerWrapper.class:?] at cpw.mods.fml.common.network.simpleimpl.SimpleChannelHandlerWrapper.channelRead0(SimpleChannelHandlerWrapper.java:14) ~[simpleChannelHandlerWrapper.class:?] at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:98) ~[simpleChannelInboundHandler.class:?] at io.netty.channel.DefaultChannelHandlerContext.invokeChannelRead(DefaultChannelHandlerContext.java:337) [DefaultChannelHandlerContext.class:?] at io.netty.channel.DefaultChannelHandlerContext.fireChannelRead(DefaultChannelHandlerContext.java:323) [DefaultChannelHandlerContext.class:?] at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103) [MessageToMessageDecoder.class:?] at io.netty.handler.codec.MessageToMessageCodec.channelRead(MessageToMessageCodec.java:111) [MessageToMessageCodec.class:?] at io.netty.channel.DefaultChannelHandlerContext.invokeChannelRead(DefaultChannelHandlerContext.java:337) [DefaultChannelHandlerContext.class:?] at io.netty.channel.DefaultChannelHandlerContext.fireChannelRead(DefaultChannelHandlerContext.java:323) [DefaultChannelHandlerContext.class:?] at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:785) [DefaultChannelPipeline.class:?] at io.netty.channel.embedded.EmbeddedChannel.writeInbound(EmbeddedChannel.java:169) [EmbeddedChannel.class:?] at cpw.mods.fml.common.network.internal.FMLProxyPacket.processPacket(FMLProxyPacket.java:86) [FMLProxyPacket.class:?] at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:247) [NetworkManager.class:?] at net.minecraft.client.multiplayer.PlayerControllerMP.updateController(PlayerControllerMP.java:321) [PlayerControllerMP.class:?] at net.minecraft.client.Minecraft.runTick(Minecraft.java:1693) [Minecraft.class:?] at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1039) [Minecraft.class:?] at net.minecraft.client.Minecraft.run(Minecraft.java:961) [Minecraft.class:?] at net.minecraft.client.main.Main.main(Main.java:164) [Main.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_60] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[?:1.7.0_60] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.7.0_60] at java.lang.reflect.Method.invoke(Method.java:606) ~[?:1.7.0_60] at net.minecraft.launchwrapper.Launch.launch(Launch.java:134) [launchwrapper-1.9.jar:?] at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.9.jar:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_60] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[?:1.7.0_60] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.7.0_60] at java.lang.reflect.Method.invoke(Method.java:606) ~[?:1.7.0_60] at GradleStart.bounce(GradleStart.java:108) [start/:?] at GradleStart.startClient(GradleStart.java:101) [start/:?] at GradleStart.main(GradleStart.java:66) [start/:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_60] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[?:1.7.0_60] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.7.0_60] at java.lang.reflect.Method.invoke(Method.java:606) ~[?:1.7.0_60] at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134) [idea_rt.jar:?] My packet code is: public class PowerFactoryPacket implements IMessage, IMessageHandler<PowerFactoryPacket, IMessage> { public int x; public int y; public int z; public int amountWater; public int amountLava; public int energy; public PowerFactoryPacket() { } public PowerFactoryPacket(PowerFactoryTileEntity tileentity) { x = tileentity.xCoord; y = tileentity.yCoord; z = tileentity.zCoord; amountWater = tileentity.getTankInfo(ForgeDirection.UNKNOWN)[0].fluid.amount; amountLava = tileentity.getTankInfo(ForgeDirection.UNKNOWN)[1].fluid.amount; energy = tileentity.getEnergy(); } public void fromBytes(ByteBuf buf) { x = buf.readInt(); y = buf.readInt(); z = buf.readInt(); amountWater = buf.readInt(); amountLava = buf.readInt(); energy = buf.readInt(); } public void toBytes(ByteBuf buf) { buf.writeInt(x); buf.writeInt(y); buf.writeInt(z); buf.writeInt(amountWater); buf.writeInt(amountLava); buf.writeInt(energy); } public IMessage onMessage(PowerFactoryPacket message, MessageContext context) { PowerFactoryTileEntity tileentity = (PowerFactoryTileEntity)FMLClientHandler.instance().getClient().theWorld.getTileEntity(message.x, message.y, message.z); tileentity.getTankInfo(ForgeDirection.UNKNOWN)[0].fluid.amount = message.amountWater; tileentity.getTankInfo(ForgeDirection.UNKNOWN)[1].fluid.amount = message.amountLava; tileentity.setEnergy(message.energy); return null; } }
  9. I decided to just setup a packet and I set it as the description packet and it works. Thank You!
  10. public FluidTank steamTank = new FluidTank({fluid}, 0, this.tankCapacity); the {fluid} is your steam fluid similar to how if it were water it would be FluidRegistry.WATER
  11. when your checking if it is not null and then using it, you also have an else which still used the variable if it is null. if it is null the fluid itself does not exist including the amount, so you would need to either do nothing with the variable or set the fluid to be the fluid you want it to be.
  12. if it is null your still using the variable, if it is null you can't use it at all
  13. Thank You! I ran a test and it is correctly reading the data, just not displaying it in the gui. Do I want to setup a packet to send the information to the clients then in readFromNBT after I have read in the values?
  14. your tank does not have a default fluid in it so when you get the amount of fluid in it there sometimes is no fluid so it returns null. since it is null when you call it, it crashes your game
  15. I have my gui show me a bar with how much of the liquid is stored. The gui works just fine and shows me how much lava and water is stored when I put water and lava into it. However, when I close the world and reopen it, all fluid in it disappears from what I had last time.
×
×
  • Create New...

Important Information

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