Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Tieso2001

Members
  • Posts

    73
  • Joined

  • Last visited

Posts posted by Tieso2001

  1. I could create an if statement in the feature class so that it only places when next to water, but I don't think that is the proper way to do it. I think the proper way is to create a custom placement.

     

    Edit: Nevermind vanilla does the checks in the feature class itself, I checked in the feature from sugarcane and it does the check there.

  2. 17 minutes ago, Animefan8888 said:

    It looks like you are gonna need a Placement object which is an ForgeRegistryEntry so don't forget to register it.

    I don't really know how this works, I'm trying to understand by looking at vanilla classes. For example, I'm looking at the Placement class.

    public static final Placement<> CROP = 

    Are there any tutorials, examples or documentations for this? How do I register a placement object and is there an example of this?

  3. I would like to generate farmland with wheat crops near water, but I don't know how I can do that.

     

    I only know how to do this, but that can only generate wheat like grass is generated:

    public static void setupWorldGen() {
    
            for (Biome biome : ForgeRegistries.BIOMES) {
                biome.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, Biome.createDecoratedFeature(Feature.BUSH, new BushConfig(Blocks.WHEAT.getDefaultState()), Placement.CHANCE_HEIGHTMAP, new ChanceConfig(4)));
            }
        }

     

    Could someone please explain to me how I can generate the wheat with farmland below, thanks in advance.

  4. Thanks I got that part working now, but now I got this error when I open the TileEntity:

    Caused by: java.lang.IndexOutOfBoundsException: readerIndex(0) + length(1) exceeds writerIndex(0): UnpooledSlicedByteBuf(ridx: 0, widx: 0, cap: 0/0, unwrapped: UnpooledByteBufAllocator$InstrumentedUnpooledUnsafeHeapByteBuf(ridx: 0, widx: 1, cap: 256))
    	at io.netty.buffer.AbstractByteBuf.checkReadableBytes0(AbstractByteBuf.java:1396) ~[AbstractByteBuf.class:4.1.9.Final]
    	at io.netty.buffer.AbstractByteBuf.readByte(AbstractByteBuf.java:687) ~[AbstractByteBuf.class:4.1.9.Final]
    	at net.minecraft.network.PacketBuffer.readByte(PacketBuffer.java:903) ~[PacketBuffer.class:?]
    	at net.minecraft.network.PacketBuffer.readCompoundTag(PacketBuffer.java:332) ~[PacketBuffer.class:?]
    	at net.minecraftforge.fml.common.network.ByteBufUtils.readTag(ByteBufUtils.java:227) ~[ByteBufUtils.class:?]
    	at com.tieso2001.boneappletea.network.PacketFluidTankUpdate.fromBytes(PacketFluidTankUpdate.java:47) ~[PacketFluidTankUpdate.class:?]
    	at net.minecraftforge.fml.common.network.simpleimpl.SimpleIndexedCodec.decodeInto(SimpleIndexedCodec.java:36) ~[SimpleIndexedCodec.class:?]
    	at net.minecraftforge.fml.common.network.simpleimpl.SimpleIndexedCodec.decodeInto(SimpleIndexedCodec.java:26) ~[SimpleIndexedCodec.class:?]
    	at net.minecraftforge.fml.common.network.FMLIndexedMessageToMessageCodec.decode(FMLIndexedMessageToMessageCodec.java:111) ~[FMLIndexedMessageToMessageCodec.class:?]
    	at net.minecraftforge.fml.common.network.FMLIndexedMessageToMessageCodec.decode(FMLIndexedMessageToMessageCodec.java:41) ~[FMLIndexedMessageToMessageCodec.class:?]
    	at io.netty.handler.codec.MessageToMessageCodec$2.decode(MessageToMessageCodec.java:81) ~[MessageToMessageCodec$2.class:4.1.9.Final]
    	at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:88) ~[MessageToMessageDecoder.class:4.1.9.Final]
    	... 33 more
    [00:59:09] [Netty Local Client IO #0/ERROR] [FML]: Network Disconnect: A fatal error has occurred, this connection is terminated

     

    It says that it caused by the following, but I have no idea how to fix this:

    Caused by: java.lang.IndexOutOfBoundsException: readerIndex(0) + length(1) exceeds writerIndex(0): UnpooledSlicedByteBuf(ridx: 0, widx: 0, cap: 0/0, unwrapped: UnpooledByteBufAllocator$InstrumentedUnpooledUnsafeHeapByteBuf(ridx: 0, widx: 1, cap: 256))
    

     

    This happens in fromBytes():

    @Override
        public void toBytes(ByteBuf buf)
        {
            NBTTagCompound compound = new NBTTagCompound();
            fluidStack.writeToNBT(compound);
            ByteBufUtils.writeTag(buf, compound);
        }
    
    @Override
        public void fromBytes(ByteBuf buf)
        {
            NBTTagCompound compound = ByteBufUtils.readTag(buf);
            fluidStack = FluidStack.loadFluidStackFromNBT(compound);
        }

    I think the error says that I try to read more bytes than that are written, but this is not the case right?

     

  5. @Override
        public void toBytes(ByteBuf buf)
        {
            NBTTagCompound compound = new NBTTagCompound();
            fluidStack.writeToNBT(compound);
        }
    
        @Override
        public void fromBytes(ByteBuf buf)
        {
    
        }

     

    Okay so I wrote the FluidStack to NBTTagCompound, but now I don't know what to do. I have to write it to buf, but I don't know how exactly. It has to be a byte or an int.

    I can convert the compound to byte with compound.getId(), but I don't know how that can be converted back into a fluidstack in fromBytes().

    I can also convert it to an int with compound.hashcode(), but I don't that is of any use here.

     

    I want to thank you for helping me, this networking stuff is all new to me so I appreciate that you take the effort to help me with this. Let me explain the things I have done and why I did.

     

    Custom PacketBuffer implementation:

    3 hours ago, V0idWa1k3r said:

    What is this? Why are you doing this?

    I got confused how write the NBTTagCompound to ByteBuf, so I started searching for other people that use FluidTank's in GUI's. I found the Forestry code on github and there it was done with a custom PacketBuffer implementation, so I thought that I also had to use that.

     

    serverPlayer:

    3 hours ago, V0idWa1k3r said:

    Your statement conflicts your implementation. Your implementation works as if the client is sending the fluid stack to the server(don't ever do that either by the way).

    In the forge documentation they get the player by using ctx.getServerHandler().player; I tried to do ctx.getClientHandler() but I can't retrieve the player from that.

     

    And also:

    3 hours ago, V0idWa1k3r said:

    An IMessage implementation must have a parameterless constructor. Which the error report is telling you. Learn to read the error report, in 90% of cases the issue is stated right in it. 

    Thank you, I fixed that now.

  6. Brief summary: I'm trying to create a packet for sending a FluidStack from the server to the client, so that the GUI of my TileEntity can be updated on the client.

     

    I have tried some things and this is what I currently have:

     

    The packet & the handler for the packet:

    Spoiler
    
    public class PacketFluidTankUpdate implements IMessage
    {
        private BlockPos pos;
        private FluidStack fluidStack;
    
        public PacketFluidTankUpdate(TileStockPot tileStockPot, FluidStack fluidStack)
        {
            this.pos = tileStockPot.getPos();
            this.fluidStack = fluidStack;
        }
    
        @Override
        public void toBytes(ByteBuf buf)
        {
            PacketBufferMod data = new PacketBufferMod(Unpooled.buffer());
            data.writeBlockPos(pos);
            data.writeFluidStack(fluidStack);
            buf.writeBytes(data);
        }
    
        @Override
        public void fromBytes(ByteBuf buf)
        {
            PacketBufferMod data = (PacketBufferMod) buf.readBytes(buf);
            pos = data.readBlockPos();
            fluidStack = data.readFluidStack();
        }
    
        @SideOnly(Side.CLIENT)
        public static class PacketHandler implements IMessageHandler<PacketFluidTankUpdate, IMessage>
        {
            @Override
            public IMessage onMessage(PacketFluidTankUpdate message, MessageContext ctx)
            {
                EntityPlayerMP serverPlayer = ctx.getServerHandler().player;
                BlockPos pos = message.pos;
                FluidStack fluidStack = message.fluidStack;
                TileEntity tileEntity = serverPlayer.world.getTileEntity(pos);
    
                if (tileEntity != null)
                {
                    if (tileEntity instanceof TileStockPot)
                    {
                        if (serverPlayer.world.isBlockLoaded(pos))
                        {
                            serverPlayer.getServerWorld().addScheduledTask(() -> ((TileStockPot) tileEntity).getFluidTank().setFluid(fluidStack));
                        }
                    }
                }
                return null;
            }
        }
    }

     

     

    SimpleNetworkWrapper object:

    Spoiler
    
    public class ModPacketHandler
    {
        public static final SimpleNetworkWrapper INSTANCE = NetworkRegistry.INSTANCE.newSimpleChannel(BoneAppleTea.MODID);
    }

     

     

    PacketBuffer class (for storing FluidStack & BlockPos):

    Spoiler
    
    public class PacketBufferMod extends PacketBuffer
    {
        public PacketBufferMod(ByteBuf wrapped)
        {
            super(wrapped);
        }
    
        public void writeFluidStack(@Nullable FluidStack fluidStack)
        {
            if (fluidStack == null) writeVarInt(-1);
            else {
                writeVarInt(fluidStack.amount);
                writeString(fluidStack.getFluid().getName());
            }
        }
    
        @Nullable
        public FluidStack readFluidStack()
        {
            int amount = readVarInt();
            if (amount > 0)
            {
                String fluidName = readString(1024);
                Fluid fluid = FluidRegistry.getFluid(fluidName);
                if (fluid == null) return null;
                return new FluidStack(fluid, amount);
            }
            return null;
        }
    }

     

     

    (the relevant) part of the container class for my TileEntity

    Spoiler
    
    @Override
        public void detectAndSendChanges()
        {
            super.detectAndSendChanges();
    
            for (IContainerListener listener : listeners)
            {
                if (listener instanceof EntityPlayerMP)
                {
                    ModPacketHandler.INSTANCE.sendToAll(new PacketFluidTankUpdate(tileEntity, tileEntity.getFluidTank().getFluid()));
                }
            }
        }

     

     

    When I open my TileEntity ingame, I get the following error:

    Network Disconnect: A fatal error has occurred, this connection is terminated

    Spoiler
    
    [18:43:26] [Netty Local Client IO #0/ERROR] [FML]: FMLIndexedMessageCodec exception caught
    io.netty.handler.codec.DecoderException: java.lang.InstantiationException: com.tieso2001.boneappletea.network.PacketFluidTankUpdate
    	at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:98) ~[MessageToMessageDecoder.class:4.1.9.Final]
    	at io.netty.handler.codec.MessageToMessageCodec.channelRead(MessageToMessageCodec.java:111) ~[MessageToMessageCodec.class:4.1.9.Final]
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [AbstractChannelHandlerContext.class:4.1.9.Final]
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [AbstractChannelHandlerContext.class:4.1.9.Final]
    	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) [AbstractChannelHandlerContext.class:4.1.9.Final]
    	at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1334) [DefaultChannelPipeline$HeadContext.class:4.1.9.Final]
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [AbstractChannelHandlerContext.class:4.1.9.Final]
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [AbstractChannelHandlerContext.class:4.1.9.Final]
    	at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:926) [DefaultChannelPipeline.class:4.1.9.Final]
    	at io.netty.channel.embedded.EmbeddedChannel.writeInbound(EmbeddedChannel.java:274) [EmbeddedChannel.class:4.1.9.Final]
    	at net.minecraftforge.fml.common.network.internal.FMLProxyPacket.processPacket(FMLProxyPacket.java:108) [FMLProxyPacket.class:?]
    	at net.minecraft.network.NetworkManager.channelRead0(NetworkManager.java:155) [NetworkManager.class:?]
    	at net.minecraft.network.NetworkManager.channelRead0(NetworkManager.java:49) [NetworkManager.class:?]
    	at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105) [SimpleChannelInboundHandler.class:4.1.9.Final]
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [AbstractChannelHandlerContext.class:4.1.9.Final]
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [AbstractChannelHandlerContext.class:4.1.9.Final]
    	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) [AbstractChannelHandlerContext.class:4.1.9.Final]
    	at net.minecraftforge.fml.common.network.handshake.NetworkDispatcher.handleClientSideCustomPacket(NetworkDispatcher.java:385) [NetworkDispatcher.class:?]
    	at net.minecraftforge.fml.common.network.handshake.NetworkDispatcher.channelRead0(NetworkDispatcher.java:271) [NetworkDispatcher.class:?]
    	at net.minecraftforge.fml.common.network.handshake.NetworkDispatcher.channelRead0(NetworkDispatcher.java:72) [NetworkDispatcher.class:?]
    	at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105) [SimpleChannelInboundHandler.class:4.1.9.Final]
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [AbstractChannelHandlerContext.class:4.1.9.Final]
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [AbstractChannelHandlerContext.class:4.1.9.Final]
    	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) [AbstractChannelHandlerContext.class:4.1.9.Final]
    	at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1334) [DefaultChannelPipeline$HeadContext.class:4.1.9.Final]
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [AbstractChannelHandlerContext.class:4.1.9.Final]
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [AbstractChannelHandlerContext.class:4.1.9.Final]
    	at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:926) [DefaultChannelPipeline.class:4.1.9.Final]
    	at io.netty.channel.local.LocalChannel.finishPeerRead0(LocalChannel.java:443) [LocalChannel.class:4.1.9.Final]
    	at io.netty.channel.local.LocalChannel.access$500(LocalChannel.java:49) [LocalChannel.class:4.1.9.Final]
    	at io.netty.channel.local.LocalChannel$5.run(LocalChannel.java:397) [LocalChannel$5.class:4.1.9.Final]
    	at io.netty.channel.DefaultEventLoop.run(DefaultEventLoop.java:54) [DefaultEventLoop.class:4.1.9.Final]
    	at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:858) [SingleThreadEventExecutor$5.class:4.1.9.Final]
    	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_192]
    Caused by: java.lang.InstantiationException: com.tieso2001.boneappletea.network.PacketFluidTankUpdate
    	at java.lang.Class.newInstance(Class.java:427) ~[?:1.8.0_192]
    	at net.minecraftforge.fml.common.network.FMLIndexedMessageToMessageCodec.decode(FMLIndexedMessageToMessageCodec.java:109) ~[FMLIndexedMessageToMessageCodec.class:?]
    	at net.minecraftforge.fml.common.network.FMLIndexedMessageToMessageCodec.decode(FMLIndexedMessageToMessageCodec.java:41) ~[FMLIndexedMessageToMessageCodec.class:?]
    	at io.netty.handler.codec.MessageToMessageCodec$2.decode(MessageToMessageCodec.java:81) ~[MessageToMessageCodec$2.class:4.1.9.Final]
    	at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:88) ~[MessageToMessageDecoder.class:4.1.9.Final]
    	... 33 more
    Caused by: java.lang.NoSuchMethodException: com.tieso2001.boneappletea.network.PacketFluidTankUpdate.<init>()
    	at java.lang.Class.getConstructor0(Class.java:3082) ~[?:1.8.0_192]
    	at java.lang.Class.newInstance(Class.java:412) ~[?:1.8.0_192]
    	at net.minecraftforge.fml.common.network.FMLIndexedMessageToMessageCodec.decode(FMLIndexedMessageToMessageCodec.java:109) ~[FMLIndexedMessageToMessageCodec.class:?]
    	at net.minecraftforge.fml.common.network.FMLIndexedMessageToMessageCodec.decode(FMLIndexedMessageToMessageCodec.java:41) ~[FMLIndexedMessageToMessageCodec.class:?]
    	at io.netty.handler.codec.MessageToMessageCodec$2.decode(MessageToMessageCodec.java:81) ~[MessageToMessageCodec$2.class:4.1.9.Final]
    	at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:88) ~[MessageToMessageDecoder.class:4.1.9.Final]
    	... 33 more
    [18:43:26] [Netty Local Client IO #0/ERROR] [FML]: SimpleChannelHandlerWrapper exception
    io.netty.handler.codec.DecoderException: java.lang.InstantiationException: com.tieso2001.boneappletea.network.PacketFluidTankUpdate
    	at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:98) ~[MessageToMessageDecoder.class:4.1.9.Final]
    	at io.netty.handler.codec.MessageToMessageCodec.channelRead(MessageToMessageCodec.java:111) ~[MessageToMessageCodec.class:4.1.9.Final]
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [AbstractChannelHandlerContext.class:4.1.9.Final]
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [AbstractChannelHandlerContext.class:4.1.9.Final]
    	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) [AbstractChannelHandlerContext.class:4.1.9.Final]
    	at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1334) [DefaultChannelPipeline$HeadContext.class:4.1.9.Final]
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [AbstractChannelHandlerContext.class:4.1.9.Final]
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [AbstractChannelHandlerContext.class:4.1.9.Final]
    	at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:926) [DefaultChannelPipeline.class:4.1.9.Final]
    	at io.netty.channel.embedded.EmbeddedChannel.writeInbound(EmbeddedChannel.java:274) [EmbeddedChannel.class:4.1.9.Final]
    	at net.minecraftforge.fml.common.network.internal.FMLProxyPacket.processPacket(FMLProxyPacket.java:108) [FMLProxyPacket.class:?]
    	at net.minecraft.network.NetworkManager.channelRead0(NetworkManager.java:155) [NetworkManager.class:?]
    	at net.minecraft.network.NetworkManager.channelRead0(NetworkManager.java:49) [NetworkManager.class:?]
    	at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105) [SimpleChannelInboundHandler.class:4.1.9.Final]
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [AbstractChannelHandlerContext.class:4.1.9.Final]
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [AbstractChannelHandlerContext.class:4.1.9.Final]
    	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) [AbstractChannelHandlerContext.class:4.1.9.Final]
    	at net.minecraftforge.fml.common.network.handshake.NetworkDispatcher.handleClientSideCustomPacket(NetworkDispatcher.java:385) [NetworkDispatcher.class:?]
    	at net.minecraftforge.fml.common.network.handshake.NetworkDispatcher.channelRead0(NetworkDispatcher.java:271) [NetworkDispatcher.class:?]
    	at net.minecraftforge.fml.common.network.handshake.NetworkDispatcher.channelRead0(NetworkDispatcher.java:72) [NetworkDispatcher.class:?]
    	at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105) [SimpleChannelInboundHandler.class:4.1.9.Final]
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [AbstractChannelHandlerContext.class:4.1.9.Final]
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [AbstractChannelHandlerContext.class:4.1.9.Final]
    	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) [AbstractChannelHandlerContext.class:4.1.9.Final]
    	at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1334) [DefaultChannelPipeline$HeadContext.class:4.1.9.Final]
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [AbstractChannelHandlerContext.class:4.1.9.Final]
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [AbstractChannelHandlerContext.class:4.1.9.Final]
    	at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:926) [DefaultChannelPipeline.class:4.1.9.Final]
    	at io.netty.channel.local.LocalChannel.finishPeerRead0(LocalChannel.java:443) [LocalChannel.class:4.1.9.Final]
    	at io.netty.channel.local.LocalChannel.access$500(LocalChannel.java:49) [LocalChannel.class:4.1.9.Final]
    	at io.netty.channel.local.LocalChannel$5.run(LocalChannel.java:397) [LocalChannel$5.class:4.1.9.Final]
    	at io.netty.channel.DefaultEventLoop.run(DefaultEventLoop.java:54) [DefaultEventLoop.class:4.1.9.Final]
    	at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:858) [SingleThreadEventExecutor$5.class:4.1.9.Final]
    	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_192]
    Caused by: java.lang.InstantiationException: com.tieso2001.boneappletea.network.PacketFluidTankUpdate
    	at java.lang.Class.newInstance(Class.java:427) ~[?:1.8.0_192]
    	at net.minecraftforge.fml.common.network.FMLIndexedMessageToMessageCodec.decode(FMLIndexedMessageToMessageCodec.java:109) ~[FMLIndexedMessageToMessageCodec.class:?]
    	at net.minecraftforge.fml.common.network.FMLIndexedMessageToMessageCodec.decode(FMLIndexedMessageToMessageCodec.java:41) ~[FMLIndexedMessageToMessageCodec.class:?]
    	at io.netty.handler.codec.MessageToMessageCodec$2.decode(MessageToMessageCodec.java:81) ~[MessageToMessageCodec$2.class:4.1.9.Final]
    	at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:88) ~[MessageToMessageDecoder.class:4.1.9.Final]
    	... 33 more
    Caused by: java.lang.NoSuchMethodException: com.tieso2001.boneappletea.network.PacketFluidTankUpdate.<init>()
    	at java.lang.Class.getConstructor0(Class.java:3082) ~[?:1.8.0_192]
    	at java.lang.Class.newInstance(Class.java:412) ~[?:1.8.0_192]
    	at net.minecraftforge.fml.common.network.FMLIndexedMessageToMessageCodec.decode(FMLIndexedMessageToMessageCodec.java:109) ~[FMLIndexedMessageToMessageCodec.class:?]
    	at net.minecraftforge.fml.common.network.FMLIndexedMessageToMessageCodec.decode(FMLIndexedMessageToMessageCodec.java:41) ~[FMLIndexedMessageToMessageCodec.class:?]
    	at io.netty.handler.codec.MessageToMessageCodec$2.decode(MessageToMessageCodec.java:81) ~[MessageToMessageCodec$2.class:4.1.9.Final]
    	at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:88) ~[MessageToMessageDecoder.class:4.1.9.Final]
    	... 33 more
    [18:43:26] [Netty Local Client IO #0/ERROR] [FML]: There was a critical exception handling a packet on channel boneappletea
    io.netty.handler.codec.DecoderException: java.lang.InstantiationException: com.tieso2001.boneappletea.network.PacketFluidTankUpdate
    	at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:98) ~[MessageToMessageDecoder.class:4.1.9.Final]
    	at io.netty.handler.codec.MessageToMessageCodec.channelRead(MessageToMessageCodec.java:111) ~[MessageToMessageCodec.class:4.1.9.Final]
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) ~[AbstractChannelHandlerContext.class:4.1.9.Final]
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) ~[AbstractChannelHandlerContext.class:4.1.9.Final]
    	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) ~[AbstractChannelHandlerContext.class:4.1.9.Final]
    	at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1334) ~[DefaultChannelPipeline$HeadContext.class:4.1.9.Final]
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) ~[AbstractChannelHandlerContext.class:4.1.9.Final]
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) ~[AbstractChannelHandlerContext.class:4.1.9.Final]
    	at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:926) ~[DefaultChannelPipeline.class:4.1.9.Final]
    	at io.netty.channel.embedded.EmbeddedChannel.writeInbound(EmbeddedChannel.java:274) ~[EmbeddedChannel.class:4.1.9.Final]
    	at net.minecraftforge.fml.common.network.internal.FMLProxyPacket.processPacket(FMLProxyPacket.java:108) [FMLProxyPacket.class:?]
    	at net.minecraft.network.NetworkManager.channelRead0(NetworkManager.java:155) [NetworkManager.class:?]
    	at net.minecraft.network.NetworkManager.channelRead0(NetworkManager.java:49) [NetworkManager.class:?]
    	at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105) [SimpleChannelInboundHandler.class:4.1.9.Final]
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [AbstractChannelHandlerContext.class:4.1.9.Final]
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [AbstractChannelHandlerContext.class:4.1.9.Final]
    	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) [AbstractChannelHandlerContext.class:4.1.9.Final]
    	at net.minecraftforge.fml.common.network.handshake.NetworkDispatcher.handleClientSideCustomPacket(NetworkDispatcher.java:385) [NetworkDispatcher.class:?]
    	at net.minecraftforge.fml.common.network.handshake.NetworkDispatcher.channelRead0(NetworkDispatcher.java:271) [NetworkDispatcher.class:?]
    	at net.minecraftforge.fml.common.network.handshake.NetworkDispatcher.channelRead0(NetworkDispatcher.java:72) [NetworkDispatcher.class:?]
    	at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105) [SimpleChannelInboundHandler.class:4.1.9.Final]
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [AbstractChannelHandlerContext.class:4.1.9.Final]
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [AbstractChannelHandlerContext.class:4.1.9.Final]
    	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) [AbstractChannelHandlerContext.class:4.1.9.Final]
    	at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1334) [DefaultChannelPipeline$HeadContext.class:4.1.9.Final]
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [AbstractChannelHandlerContext.class:4.1.9.Final]
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [AbstractChannelHandlerContext.class:4.1.9.Final]
    	at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:926) [DefaultChannelPipeline.class:4.1.9.Final]
    	at io.netty.channel.local.LocalChannel.finishPeerRead0(LocalChannel.java:443) [LocalChannel.class:4.1.9.Final]
    	at io.netty.channel.local.LocalChannel.access$500(LocalChannel.java:49) [LocalChannel.class:4.1.9.Final]
    	at io.netty.channel.local.LocalChannel$5.run(LocalChannel.java:397) [LocalChannel$5.class:4.1.9.Final]
    	at io.netty.channel.DefaultEventLoop.run(DefaultEventLoop.java:54) [DefaultEventLoop.class:4.1.9.Final]
    	at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:858) [SingleThreadEventExecutor$5.class:4.1.9.Final]
    	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_192]
    Caused by: java.lang.InstantiationException: com.tieso2001.boneappletea.network.PacketFluidTankUpdate
    	at java.lang.Class.newInstance(Class.java:427) ~[?:1.8.0_192]
    	at net.minecraftforge.fml.common.network.FMLIndexedMessageToMessageCodec.decode(FMLIndexedMessageToMessageCodec.java:109) ~[FMLIndexedMessageToMessageCodec.class:?]
    	at net.minecraftforge.fml.common.network.FMLIndexedMessageToMessageCodec.decode(FMLIndexedMessageToMessageCodec.java:41) ~[FMLIndexedMessageToMessageCodec.class:?]
    	at io.netty.handler.codec.MessageToMessageCodec$2.decode(MessageToMessageCodec.java:81) ~[MessageToMessageCodec$2.class:4.1.9.Final]
    	at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:88) ~[MessageToMessageDecoder.class:4.1.9.Final]
    	... 33 more
    Caused by: java.lang.NoSuchMethodException: com.tieso2001.boneappletea.network.PacketFluidTankUpdate.<init>()
    	at java.lang.Class.getConstructor0(Class.java:3082) ~[?:1.8.0_192]
    	at java.lang.Class.newInstance(Class.java:412) ~[?:1.8.0_192]
    	at net.minecraftforge.fml.common.network.FMLIndexedMessageToMessageCodec.decode(FMLIndexedMessageToMessageCodec.java:109) ~[FMLIndexedMessageToMessageCodec.class:?]
    	at net.minecraftforge.fml.common.network.FMLIndexedMessageToMessageCodec.decode(FMLIndexedMessageToMessageCodec.java:41) ~[FMLIndexedMessageToMessageCodec.class:?]
    	at io.netty.handler.codec.MessageToMessageCodec$2.decode(MessageToMessageCodec.java:81) ~[MessageToMessageCodec$2.class:4.1.9.Final]
    	at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:88) ~[MessageToMessageDecoder.class:4.1.9.Final]
    	... 33 more
    [18:43:26] [Netty Local Client IO #0/ERROR] [FML]: Network Disconnect: A fatal error has occurred, this connection is terminated

     

     

    If somebody could me help out with what is wrong / what isn't working. I would really appreciate that. Thanks in advance.

  7. Okay so I think I have figured out how to write and read a FluidStack from ByteBuf, Here is the code I have:

     

    Packet class:

    Spoiler
    
    import io.netty.buffer.ByteBuf;
    import io.netty.buffer.Unpooled;
    import net.minecraftforge.fluids.FluidStack;
    import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
    
    public class PacketFluidTankUpdate implements IMessage
    {
        private FluidStack fluidStack;
    
        public PacketFluidTankUpdate(FluidStack fluidStack)
        {
            this.fluidStack = fluidStack;
        }
    
        @Override
        public void toBytes(ByteBuf buf)
        {
            PacketBufferMod data = new PacketBufferMod(Unpooled.buffer());
            data.writeFluidStack(fluidStack);
            buf.writeBytes(data);
        }
    
        @Override
        public void fromBytes(ByteBuf buf)
        {
            PacketBufferMod data = (PacketBufferMod) buf.readBytes(buf);
            fluidStack = data.readFluidStack();
        }
    }

     

     

    PacketHandler class:

    Spoiler
    
    import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
    import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
    import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
    
    public class PacketHandlerFluidTankUpdate implements IMessageHandler<PacketFluidTankUpdate, IMessage>
    {
        @Override
        public IMessage onMessage(PacketFluidTankUpdate message, MessageContext ctx)
        {
    
        }
    }

     

     

    PacketBuffer class:

    Spoiler
    
    import io.netty.buffer.ByteBuf;
    import net.minecraft.network.PacketBuffer;
    import net.minecraftforge.fluids.Fluid;
    import net.minecraftforge.fluids.FluidRegistry;
    import net.minecraftforge.fluids.FluidStack;
    
    import javax.annotation.Nullable;
    
    public class PacketBufferMod extends PacketBuffer
    {
        public PacketBufferMod(ByteBuf wrapped)
        {
            super(wrapped);
        }
    
        public void writeFluidStack(@Nullable FluidStack fluidStack)
        {
            if (fluidStack == null) writeVarInt(-1);
            else {
                writeVarInt(fluidStack.amount);
                writeString(fluidStack.getFluid().getName());
            }
        }
    
        @Nullable
        public FluidStack readFluidStack()
        {
            int amount = readVarInt();
            if (amount > 0)
            {
                String fluidName = readString(1024);
                Fluid fluid = FluidRegistry.getFluid(fluidName);
                if (fluid == null) return null;
                return new FluidStack(fluid, amount);
            }
            return null;
        }
    }

     

     

    According to the forge documentation I have to create PacketHandler class which implements IMessageHandler, so I created PacketHandlerFluidTankUpdate. I have no idea what I have to do so that the GUI in my TileEntity updates with the right fluid (amount).

  8. So I created a packet for sending the FluidTank, but I have no idea how I should write and read it to ByteBuf, If it was an integer I could use buf.writeInt(), but how do I do that with a FluidTank.

    public class MessageFluidTank implements IMessage
    {
        private FluidTank fluidTank;
    
        public MessageFluidTank(FluidTank fluidTank)
        {
            this.fluidTank = fluidTank;
        }
    
        @Override
        public void toBytes(ByteBuf buf)
        {
            buf.writeBytes(fluidTank); // How do I write fluidTank to buf
        }
    
        @Override
        public void fromBytes(ByteBuf buf)
        {
            fluidTank = buf.readBytes(); // How do I read fluidTank from buf
        }
    }

     

  9. I have created a TileEntity that has a fluidtank. Now I am trying to draw the fluid that is in the tank in the TileEntity's gui. The problem is that I have no idea on how to communicate the fluidstack or fluidtank with the client. I know that I can send integers with detectAndSendChanges() in the container class using listeners, but I don't think I can send any other data like a fluidstack or a fluidtank with this method. How do I communicate a fluidtank or a fluidstack from my TileEntity on the server to the gui on the client?

  10. I am making a corn plant/crop that is two blocks high. I want the plant to use different textures depending on if it the the lower or upper half of the plant and depending on the age that half is. That is why I have made two different type of states: "age" & "half. "age" can be a value from 0-7 and "half" can be "upper" or "lower". The problem is that I can't get my blockstate file to work. Can someone explain me how I should do this, because the forge documentation only explains how to select a model with one state/variable. Here are some of the things I've tried.

     

    {
      "forge_marker": 1,
      "variants": {
        "age=0, half=lower": { "model" : "boneappletea:corn_lower_stage0" },
        "age=1, half=lower": { "model" : "boneappletea:corn_lower_stage0" },
        "age=2, half=lower": { "model" : "boneappletea:corn_lower_stage1" },
        "age=3, half=lower": { "model" : "boneappletea:corn_lower_stage1" },
        "age=4, half=lower": { "model" : "boneappletea:corn_lower_stage2" },
        "age=5, half=lower": { "model" : "boneappletea:corn_lower_stage2" },
        "age=6, half=lower": { "model" : "boneappletea:corn_lower_stage3" },
        "age=7, half=lower": { "model" : "boneappletea:corn_lower_stage3" },
        "age=0, half=upper": { "model" : "boneappletea:corn_upper_stage0" },
        "age=1, half=upper": { "model" : "boneappletea:corn_upper_stage0" },
        "age=2, half=upper": { "model" : "boneappletea:corn_upper_stage1" },
        "age=3, half=upper": { "model" : "boneappletea:corn_upper_stage1" },
        "age=4, half=upper": { "model" : "boneappletea:corn_upper_stage2" },
        "age=5, half=upper": { "model" : "boneappletea:corn_upper_stage2" },
        "age=6, half=upper": { "model" : "boneappletea:corn_upper_stage3" },
        "age=7, half=upper": { "model" : "boneappletea:corn_upper_stage3" }
      }
    }
    {
      "forge_marker": 1,
      "variants": {
        "half=lower": {
            "age=0": { "model" : "boneappletea:corn_lower_stage0" },
            "age=1": { "model" : "boneappletea:corn_lower_stage0" },
            "age=2": { "model" : "boneappletea:corn_lower_stage1" },
            "age=3": { "model" : "boneappletea:corn_lower_stage1" },
            "age=4": { "model" : "boneappletea:corn_lower_stage2" },
            "age=5": { "model" : "boneappletea:corn_lower_stage2" },
            "age=6": { "model" : "boneappletea:corn_lower_stage3" },
            "age=7": { "model" : "boneappletea:corn_lower_stage3" }
        },
        "half=upper": {
          "age=0": { "model" : "boneappletea:corn_upper_stage0" },
          "age=1": { "model" : "boneappletea:corn_upper_stage0" },
          "age=2": { "model" : "boneappletea:corn_upper_stage1" },
          "age=3": { "model" : "boneappletea:corn_upper_stage1" },
          "age=4": { "model" : "boneappletea:corn_upper_stage2" },
          "age=5": { "model" : "boneappletea:corn_upper_stage2" },
          "age=6": { "model" : "boneappletea:corn_upper_stage3" },
          "age=7": { "model" : "boneappletea:corn_upper_stage3" }
        },
        "age=0": {
          "half=lower": { "model" : "boneappletea:corn_lower_stage0" },
          "half=upper": { "model" : "boneappletea:corn_upper_stage0" }
        },
        "age=1": {
          "half=lower": { "model" : "boneappletea:corn_lower_stage0" },
          "half=upper": { "model" : "boneappletea:corn_upper_stage0" }
        },
        "age=2": {
          "half=lower": { "model" : "boneappletea:corn_lower_stage1" },
          "half=upper": { "model" : "boneappletea:corn_upper_stage1" }
        },
        "age=3": {
          "half=lower": { "model" : "boneappletea:corn_lower_stage1" },
          "half=upper": { "model" : "boneappletea:corn_upper_stage1" }
        },
        "age=4": {
          "half=lower": { "model" : "boneappletea:corn_lower_stage2" },
          "half=upper": { "model" : "boneappletea:corn_upper_stage2" }
        },
        "age=5": {
          "half=lower": { "model" : "boneappletea:corn_lower_stage2" },
          "half=upper": { "model" : "boneappletea:corn_upper_stage2" }
        },
        "age=6": {
          "half=lower": { "model" : "boneappletea:corn_lower_stage3" },
          "half=upper": { "model" : "boneappletea:corn_upper_stage3" }
        },
        "age=7": {
          "half=lower": { "model" : "boneappletea:corn_lower_stage3" },
          "half=upper": { "model" : "boneappletea:corn_upper_stage3" }
        }
      }
    }

     

  11. I have created a tool that decreases it's durability by 1 everytime you use it to craft something. This works fine, except when you try to repair the tool by combining two damaged ones. This creates a new tool and leaves the other two tools in the crafting window.

     

        @Override
        public boolean hasContainerItem(ItemStack stack)
        {
            return true;
        }
    
        @Override
        public ItemStack getContainerItem(ItemStack stack) 
        {
            ItemStack item = stack.copy();
            item.setItemDamage(stack.getItemDamage() + 1);
            return item;
        }

     

    Is there anyway to fix this issue or exclude this repairing recipe from the code above? I have not added this repairing recipe myself but it is automatically added by minecraft or forge.

  12. Thanks for the advice, I know basic java and I have made mods before, but this was something that I just didn't realise and thought that it was some other mistakes than importing the wrong class. Also I tried googling but that didn't really got me anywhere so I decided to see if someone could help me here. Anyways thanks for your help.

  13. I'm making a mod where if I right click with an empty hand on sand, it gives me a item. I use the onPlayerInteract(PlayerInteractEvent.RightClickBlock event) to do this, but when I try to get the block which is right clicked it returns the wrong type.

     

    Block block = event.getWorld().getBlockState(event.getPos()).getBlock();

     

    It says incompatible types:

    required: jdk.nashorn.internal.ir.Block

    found: net.minecraft.block.Block

     

    The whole class:

    @SubscribeEvent
        public static void onPlayerInteract(PlayerInteractEvent.RightClickBlock event) {
            ItemStack hand = event.getItemStack();
            Block block = event.getWorld().getBlockState(event.getPos()).getBlock();
            if (hand.isEmpty() && event.getEntityPlayer().isSneaking()) {
                if (ImmutableSet.of(Blocks.SAND).contains(block)) {
                    if (event.getWorld().isRemote) {
                        event.getEntityPlayer().swingArm(event.getHand());
                    } else {
                        if (Math.random() < 0.8)
                            event.getEntityPlayer().dropItem(new ItemStack(Items.STICK), false);
                    }
                    event.setCanceled(true);
                    event.setCancellationResult(EnumActionResult.SUCCESS);
                }
            }
        }

     

    How do I solve this problem?

     

    This is in 1.12.2 btw.

×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.