Jump to content

lethinh

Members
  • Posts

    191
  • Joined

  • Last visited

Everything posted by lethinh

  1. I use @Mod.EventBusSubscriber on the beginning of the class file
  2. When I toggle line breakpoint. It doesn't break. But it doesn't break unbreable block
  3. Thanks for your idea but it doesn't work. The world.isRemote has already called in the code.
  4. So do you know how to convert List<ItemStack> to ItemStack ?
  5. How to wheater the code is reaching the break unbreakable block statements?
  6. Do you know how to use debugger? I'm using Intellij IDEA
  7. It breaks ordinary breakable blocks. The game doesn't crash. And I have called the event by using MinecraftForge.EventBus::register
  8. It doesn't break unbreakable block. That's the point of the code.
  9. I have just learned java for few months. And the code didn't work: @SubscribeEvent public void onPlayerDig(PlayerInteractEvent.LeftClickBlock event) { World world = event.getWorld(); EntityPlayer player = event.getEntityPlayer(); if (event.getFace() == null || world.isRemote || StackUtils.isEmpty(player.getHeldItem(EnumHand.MAIN_HAND)) || player.isCreative()) return; BlockPos pos = event.getPos(); IBlockState state = world.getBlockState(pos); Block block = state.getBlock(); List<ItemStack> drop = new ArrayList<>(); if (drop == null) drop = new ArrayList<>(block.getDrops(world, pos, state, EnchantmentHelper.getEnchantmentLevel(Enchantments.FORTUNE, new ItemStack(this)))); block.harvestBlock(world, player, pos, state, world.getTileEntity(pos), new ItemStack(block)); InventoryHelper.spawnItemStack(world, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(block)); world.setBlockToAir(pos); world.playEvent(2001, pos, Block.getStateId(state)); }
  10. My fml-client-latest.log: https://gist.github.com/letruongthinh/39a43b171466c9a97cec851b27871e23 My latest.log: https://gist.github.com/letruongthinh/0030e677c0918872b176a3ddb6d4eec7
  11. It shows these error lines: [21:04:27] [File IO Thread/ERROR]: Failed to save chunk java.lang.NullPointerException at java.io.DataOutputStream.writeUTF(DataOutputStream.java:347) ~[?:1.8.0_51] at java.io.DataOutputStream.writeUTF(DataOutputStream.java:323) ~[?:1.8.0_51] at net.minecraft.nbt.NBTTagCompound.writeEntry(NBTTagCompound.java:555) ~[NBTTagCompound.class:?] at net.minecraft.nbt.NBTTagCompound.write(NBTTagCompound.java:29) ~[NBTTagCompound.class:?] at net.minecraft.nbt.NBTTagList.write(NBTTagList.java:37) ~[NBTTagList.class:?] at net.minecraft.nbt.NBTTagCompound.writeEntry(NBTTagCompound.java:556) ~[NBTTagCompound.class:?] at net.minecraft.nbt.NBTTagCompound.write(NBTTagCompound.java:29) ~[NBTTagCompound.class:?] at net.minecraft.nbt.NBTTagCompound.writeEntry(NBTTagCompound.java:556) ~[NBTTagCompound.class:?] at net.minecraft.nbt.NBTTagCompound.write(NBTTagCompound.java:29) ~[NBTTagCompound.class:?] at net.minecraft.nbt.CompressedStreamTools.writeTag(CompressedStreamTools.java:126) ~[CompressedStreamTools.class:?] at net.minecraft.nbt.CompressedStreamTools.write(CompressedStreamTools.java:116) ~[CompressedStreamTools.class:?] at net.minecraft.world.chunk.storage.AnvilChunkLoader.writeChunkData(AnvilChunkLoader.java:252) ~[AnvilChunkLoader.class:?] at net.minecraft.world.chunk.storage.AnvilChunkLoader.writeNextIO(AnvilChunkLoader.java:230) [AnvilChunkLoader.class:?] at net.minecraft.world.storage.ThreadedFileIOBase.processQueue(ThreadedFileIOBase.java:48) [ThreadedFileIOBase.class:?] at net.minecraft.world.storage.ThreadedFileIOBase.run(ThreadedFileIOBase.java:36) [ThreadedFileIOBase.class:?] at java.lang.Thread.run(Thread.java:745) [?:1.8.0_51]
  12. Well, I changed the SLOT_PLAN to 0, SLOLT_CRAFT_RESULT to 1, and SLOT_CRAFT_MATRIX to 2 in the InventoryConstructor.
  13. Now it doesn't open the gui. Here is my ContainerBase code: https://gist.github.com/letruongthinh/21f58eb3c04fac917d72ed35190397d0 My ContainerConstructor code: https://gist.github.com/letruongthinh/649c2ace3a7dd7fed501b421df50478e
  14. It is: @SubscribeEvent public void onPlayerDig(PlayerInteractEvent.LeftClickBlock event) { World world = event.getWorld(); EntityPlayer player = event.getEntityPlayer(); if (event.getFace() == null || world.isRemote || StackUtils.isEmpty(player.getHeldItem(EnumHand.MAIN_HAND)) || player.isCreative()) return; BlockPos pos = event.getPos(); IBlockState state = world.getBlockState(pos); Block block = state.getBlock(); List<ItemStack> drop = new ArrayList<>(); if (block.getDrops(world, pos, state, EnchantmentHelper.getEnchantmentLevel(Enchantments.FORTUNE, new ItemStack(this))) == drop) { if (drop == null) drop = new ArrayList<>(block.getDrops(world, pos, state, EnchantmentHelper.getEnchantmentLevel(Enchantments.FORTUNE, new ItemStack(this)))); InventoryHelper.spawnItemStack(world, (double) pos.getX(), (double) pos.getY(), (double) pos.getZ(), drop); } else block.harvestBlock(world, player, pos, state, world.getTileEntity(pos), drop); world.setBlockToAir(pos); world.playEvent(2001, pos, Block.getStateId(state)); }
  15. Can't be. If I do that, the method InventoryHelper::spawnItemStack and Block::harvestBlock WILL NOT WORK
  16. Hello everyone. I'm getting trouble with my TileEntity. Here is my crash report: https://gist.github.com/letruongthinh/cfe53052b3b289502973deb28c65f71a My Inventory Base code: https://gist.github.com/letruongthinh/7f2dd5df5ae401aca54f7deb3085f9f9 My InventoryTile code: https://gist.github.com/letruongthinh/594b82c891f6796f3994bb012993b63d My Tile Base code: https://gist.github.com/letruongthinh/9cf3622a35e9069332e0c74c85aee15b
  17. I can't. Block::getDrops is List<ItemStack> but the drop is a item stack.
  18. All the code that I have shown to you. And could you show me how to not call Block::getMetaFromState?
  19. Do you know how to fix those errors? I have tried all!
  20. Here is my final newest code: https://gist.github.com/anonymous/28b892b90e2f73d2242a3f2b077e77ca
  21. Here is my written code: https://gist.github.com/anonymous/07469e8949863a712c21d1c512accb13 And I'm stuck on that I have created a block that have meta but facing hasn't. Please help me...
  22. You can use getCount() to get stack size or setCount() to set stackSize. The stackSize is private because ItemStack in forge 1.11.2 is never null. You should use ItemStack.EMPTY instead of null!
×
×
  • Create New...

Important Information

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