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


  • Posts

  • Joined

  • Last visited

Everything 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. Okay now I understand how features and placements work. I created a feature which will place farmland with wheat on top of it. I am not sure yet how I tell a placement that it needs to place it near water.
  3. Do I need to register features as well, or just placements?
  4. 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?
  5. 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.
  6. I want to know if there is event for register a fluid just like there is the event for registering blocks and items. RegistryEvent.Register<Fluid> isn't a thing so I am curious if there is one for registering fluids.
  7. You were right, there was another error with the BlockPos of the tileEntity being null. I didn't realise that because the log was spamming errors so I got that fixed now. Everything seems to work now and the packet works! Thanks a lot, you really helped me.
  8. 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?
  9. @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: 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: 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: Thank you, I fixed that now.
  10. 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: SimpleNetworkWrapper object: PacketBuffer class (for storing FluidStack & BlockPos): (the relevant) part of the container class for my TileEntity When I open my TileEntity ingame, I get the following error: 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.
  11. 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: PacketHandler class: PacketBuffer class: 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).
  12. If somebody could explain me how this works that would be appreciated. I'm a little confused by the forge documentation because it only explains how this works with integers.
  13. 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 } }
  14. 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?
  15. You need to inject your items or loottable in the vanilla fishing loot table. In the LootTableLoadEvent, check if the table that is being loaded is the fishing table and then inject your items into that table.
  16. Removing the spaces from the first file worked. Thank you.
  17. 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" } } } }
  18. 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.
  19. 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.
  20. Thanks! I accidentally imported the jdk.nashorn class instead of the minecaft one.
  21. Okay I will use if(block == Blocks.SAND) but I still have the error that the types are incompatible
  22. What do you mean by which Block I imported?
  23. 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.