-
Posts
796 -
Joined
-
Last visited
-
Days Won
1
Everything posted by Kokkie
-
I think it is impossible as minecraft always generates an infinite map
-
[1.11.2][solved] Removal from Creative tabs + Recipe
Kokkie replied to nexusrightsi's topic in Modder Support
This is the furthest I'll go private void removeCraftRecipe(ItemStack stack) { Iterator<IRecipe> recipes = CraftingManager.getInstance().getRecipeList().iterator(); while (recipes.hasNext()) { ItemStack output = recipes.next().getRecipeOutput(); if (output.isItemEqual(stack)) { recipes.remove(); } } } -
[1.11.2][solved] Removal from Creative tabs + Recipe
Kokkie replied to nexusrightsi's topic in Modder Support
So basically fuck all the code that I've got already and just do that instead of what I've got... No thanks... -
[1.11.2][solved] Removal from Creative tabs + Recipe
Kokkie replied to nexusrightsi's topic in Modder Support
OK SENSEI private void removeCraftRecipe(ItemStack stack) { Iterator<IRecipe> recipes = CraftingManager.getInstance().getRecipeList().iterator(); while (recipes.hasNext()) { ItemStack output = recipes.next().getRecipeOutput(); if(output != null && output.getItem() != null) { if(output.isItemEqual(stack)) { recipes.remove(); } } } } -
[1.11.2][solved] Removal from Creative tabs + Recipe
Kokkie replied to nexusrightsi's topic in Modder Support
private void removeCraftRecipe(ItemStack stack) { Iterator<IRecipe> recipes = CraftingManager.getInstance().getRecipeList().iterator(); while (recipes.hasNext()) { ItemStack output = ((IRecipe) recipes.next()).getRecipeOutput(); if(output != null && output.getItem() != null) { if(output.isItemEqual(stack)) { recipes.remove(); } } } } Here you go... -
[1.11.2][solved] Removal from Creative tabs + Recipe
Kokkie replied to nexusrightsi's topic in Modder Support
Here is my code using an Iterator private void removeCraftRecipe(ItemStack stack) { Iterator recipes = CraftingManager.getInstance().getRecipeList().iterator(); while (recipes.hasNext()) { ItemStack output = ((IRecipe) recipes.next()).getRecipeOutput(); if(output != null && output.getItem() != null) { if(output.isItemEqual(stack)) { recipes.remove(); } } } } -
I've now got this @SubscribeEvent public void onBonemeal(BonemealEvent event) { event.setCanceled(true); World world = event.getWorld(); BlockPos pos = event.getPos(); IBlockState state = world.getBlockState(pos); EntityPlayer player = event.getEntityPlayer(); ItemStack stack; if (player.getHeldItemMainhand().getItem() == Items.DYE && player.getHeldItemMainhand().getMetadata() == 15) { stack = player.getHeldItemMainhand(); } else if (player.getHeldItemOffhand().getItem() == Items.DYE && player.getHeldItemOffhand().getMetadata() == 15) { stack = player.getHeldItemOffhand(); } else { stack = ItemStack.EMPTY; } boolean grown = false; IGrowable igrowable; if (!world.isRemote) { while (state.getBlock() instanceof IGrowable && (igrowable = (IGrowable) state.getBlock()).canGrow(world, pos, state, world.isRemote)) { igrowable.grow(world, world.rand, pos, state); state = world.getBlockState(pos); grown = true; } if (grown) { stack.shrink(1); } } } Only thing is I still get the weird invisible tree bug... The grown boolean is to check if it should take away an item..
-
How can I do it now? Probably just check both hands like I did before, shouldn't I? Also, how can I make sure it is bonemeal and not any other dye?
-
I can't do player.getActiveHand() because it isn't active anymore I think.. [11:41:19] [Client thread/FATAL]: Unreported exception thrown! java.lang.IllegalArgumentException: Invalid hand null at net.minecraft.entity.EntityLivingBase.getHeldItem(EntityLivingBase.java:1721) ~[EntityLivingBase.class:?] at com.Egietje.degeweldigemod.handler.CheeseCommonHandler.onBonemeal(CheeseCommonHandler.java:76) ~[CheeseCommonHandler.class:?] at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_17_CheeseCommonHandler_onBonemeal_BonemealEvent.invoke(.dynamic) ~[?:?] at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90) ~[ASMEventHandler.class:?] at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:185) ~[EventBus.class:?] at net.minecraftforge.event.ForgeEventFactory.onApplyBonemeal(ForgeEventFactory.java:355) ~[ForgeEventFactory.class:?] at net.minecraft.item.ItemDye.applyBonemeal(ItemDye.java:118) ~[ItemDye.class:?] at net.minecraft.item.ItemDye.onItemUse(ItemDye.java:62) ~[ItemDye.class:?] at net.minecraft.item.ItemStack.onItemUse(ItemStack.java:180) ~[ItemStack.class:?] at net.minecraft.client.multiplayer.PlayerControllerMP.processRightClickBlock(PlayerControllerMP.java:496) ~[PlayerControllerMP.class:?] at net.minecraft.client.Minecraft.rightClickMouse(Minecraft.java:1606) ~[Minecraft.class:?] at net.minecraft.client.Minecraft.processKeyBinds(Minecraft.java:2276) ~[Minecraft.class:?] at net.minecraft.client.Minecraft.runTickKeyboard(Minecraft.java:2053) ~[Minecraft.class:?] at net.minecraft.client.Minecraft.runTick(Minecraft.java:1841) ~[Minecraft.class:?] at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1119) ~[Minecraft.class:?] at net.minecraft.client.Minecraft.run(Minecraft.java:407) [Minecraft.class:?] at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_77] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_77] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_77] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_77] at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?] at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_77] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_77] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_77] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_77] at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?] at GradleStart.main(GradleStart.java:26) [start/:?] @SubscribeEvent public void onBonemeal(BonemealEvent event) { event.setCanceled(true); World world = event.getWorld(); BlockPos pos = event.getPos(); IBlockState state = world.getBlockState(pos); EntityPlayer player = event.getEntityPlayer(); ItemStack stack = player.getHeldItem(player.getActiveHand()); IGrowable igrowable; if (!world.isRemote) { while (state.getBlock() instanceof IGrowable && (igrowable = (IGrowable) state.getBlock()).canGrow(world, pos, state, world.isRemote)) { igrowable.grow(world, world.rand, pos, state); state = world.getBlockState(pos); } stack.shrink(1); } }
-
So.. this? @SubscribeEvent public void onBonemeal(BonemealEvent event) { event.setCanceled(true); World world = event.getWorld(); BlockPos pos = event.getPos(); IBlockState state = world.getBlockState(pos); ItemStack stack = event.getEntityPlayer().getHeldItemMainhand(); if (stack.getItem() != Items.DYE) { stack = event.getEntityPlayer().getHeldItemOffhand(); if (stack.getItem() != Items.DYE) { return; } } if (state.getBlock() instanceof IGrowable) { IGrowable igrowable = (IGrowable) state.getBlock(); if (!world.isRemote) { while (igrowable.canGrow(world, pos, state, world.isRemote)) { igrowable.grow(world, world.rand, pos, state); state = world.getBlockState(pos); if (state.getBlock() instanceof IGrowable) { igrowable = (IGrowable) state.getBlock(); } else { stack.shrink(1); } } } } }
-
Bump
-
This isn't that hard... You just test for the position of the player and tp him back if he goes further than the border you set
-
Why do you want a MapGenStructure instead of a WorldGenerator?
-
Look at the vanilla Fossils for an example
-
So... What should the method do?
-
Also, I get this error in the console [14:16:20] [Server thread/ERROR] [FML]: Exception caught during firing event net.minecraftforge.event.entity.player.BonemealEvent@75452f75: java.lang.IllegalArgumentException: Cannot get property PropertyInteger{name=stage, clazz=class java.lang.Integer, values=[0, 1]} as it does not exist in BlockStateContainer{block=minecraft:log, properties=[axis, variant]} at net.minecraft.block.state.BlockStateContainer$StateImplementation.getValue(BlockStateContainer.java:201) ~[BlockStateContainer$StateImplementation.class:?] at net.minecraft.block.BlockSapling.grow(BlockSapling.java:71) ~[BlockSapling.class:?] at net.minecraft.block.BlockSapling.grow(BlockSapling.java:251) ~[BlockSapling.class:?] at com.Egietje.degeweldigemod.handler.CheeseCommonHandler.onCropGrow(CheeseCommonHandler.java:80) ~[CheeseCommonHandler.class:?] at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_18_CheeseCommonHandler_onCropGrow_BonemealEvent.invoke(.dynamic) ~[?:?] at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90) ~[ASMEventHandler.class:?] at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:185) [EventBus.class:?] at net.minecraftforge.event.ForgeEventFactory.onApplyBonemeal(ForgeEventFactory.java:355) [ForgeEventFactory.class:?] at net.minecraft.item.ItemDye.applyBonemeal(ItemDye.java:118) [ItemDye.class:?] at net.minecraft.item.ItemDye.onItemUse(ItemDye.java:62) [ItemDye.class:?] at net.minecraftforge.common.ForgeHooks.onPlaceItemIntoWorld(ForgeHooks.java:812) [ForgeHooks.class:?] at net.minecraft.item.ItemStack.onItemUse(ItemStack.java:179) [ItemStack.class:?] at net.minecraft.server.management.PlayerInteractionManager.processRightClickBlock(PlayerInteractionManager.java:516) [PlayerInteractionManager.class:?] at net.minecraft.network.NetHandlerPlayServer.processTryUseItemOnBlock(NetHandlerPlayServer.java:712) [NetHandlerPlayServer.class:?] at net.minecraft.network.play.client.CPacketPlayerTryUseItemOnBlock.processPacket(CPacketPlayerTryUseItemOnBlock.java:68) [CPacketPlayerTryUseItemOnBlock.class:?] at net.minecraft.network.play.client.CPacketPlayerTryUseItemOnBlock.processPacket(CPacketPlayerTryUseItemOnBlock.java:13) [CPacketPlayerTryUseItemOnBlock.class:?] at net.minecraft.network.PacketThreadUtil$1.run(PacketThreadUtil.java:15) [PacketThreadUtil$1.class:?] at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_77] at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_77] at net.minecraft.util.Util.runTask(Util.java:26) [Util.class:?] at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:753) [MinecraftServer.class:?] at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:698) [MinecraftServer.class:?] at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:156) [IntegratedServer.class:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:547) [MinecraftServer.class:?] at java.lang.Thread.run(Unknown Source) [?:1.8.0_77] [14:16:20] [Server thread/ERROR] [FML]: Index: 1 Listeners: [14:16:20] [Server thread/ERROR] [FML]: 0: NORMAL [14:16:20] [Server thread/ERROR] [FML]: 1: ASM: com.Egietje.degeweldigemod.handler.CheeseCommonHandler@63a5a05a onCropGrow(Lnet/minecraftforge/event/entity/player/BonemealEvent;)V [14:16:20] [Server thread/FATAL]: Error executing task java.util.concurrent.ExecutionException: java.lang.IllegalArgumentException: Cannot get property PropertyInteger{name=stage, clazz=class java.lang.Integer, values=[0, 1]} as it does not exist in BlockStateContainer{block=minecraft:log, properties=[axis, variant]} at java.util.concurrent.FutureTask.report(Unknown Source) ~[?:1.8.0_77] at java.util.concurrent.FutureTask.get(Unknown Source) ~[?:1.8.0_77] at net.minecraft.util.Util.runTask(Util.java:27) [Util.class:?] at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:753) [MinecraftServer.class:?] at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:698) [MinecraftServer.class:?] at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:156) [IntegratedServer.class:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:547) [MinecraftServer.class:?] at java.lang.Thread.run(Unknown Source) [?:1.8.0_77] Caused by: java.lang.IllegalArgumentException: Cannot get property PropertyInteger{name=stage, clazz=class java.lang.Integer, values=[0, 1]} as it does not exist in BlockStateContainer{block=minecraft:log, properties=[axis, variant]} at net.minecraft.block.state.BlockStateContainer$StateImplementation.getValue(BlockStateContainer.java:201) ~[BlockStateContainer$StateImplementation.class:?] at net.minecraft.block.BlockSapling.grow(BlockSapling.java:71) ~[BlockSapling.class:?] at net.minecraft.block.BlockSapling.grow(BlockSapling.java:251) ~[BlockSapling.class:?] at com.Egietje.degeweldigemod.handler.CheeseCommonHandler.onCropGrow(CheeseCommonHandler.java:80) ~[CheeseCommonHandler.class:?] at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_18_CheeseCommonHandler_onCropGrow_BonemealEvent.invoke(.dynamic) ~[?:?] at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90) ~[ASMEventHandler.class:?] at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:185) ~[EventBus.class:?] at net.minecraftforge.event.ForgeEventFactory.onApplyBonemeal(ForgeEventFactory.java:355) ~[ForgeEventFactory.class:?] at net.minecraft.item.ItemDye.applyBonemeal(ItemDye.java:118) ~[ItemDye.class:?] at net.minecraft.item.ItemDye.onItemUse(ItemDye.java:62) ~[ItemDye.class:?] at net.minecraftforge.common.ForgeHooks.onPlaceItemIntoWorld(ForgeHooks.java:812) ~[ForgeHooks.class:?] at net.minecraft.item.ItemStack.onItemUse(ItemStack.java:179) ~[ItemStack.class:?] at net.minecraft.server.management.PlayerInteractionManager.processRightClickBlock(PlayerInteractionManager.java:516) ~[PlayerInteractionManager.class:?] at net.minecraft.network.NetHandlerPlayServer.processTryUseItemOnBlock(NetHandlerPlayServer.java:712) ~[NetHandlerPlayServer.class:?] at net.minecraft.network.play.client.CPacketPlayerTryUseItemOnBlock.processPacket(CPacketPlayerTryUseItemOnBlock.java:68) ~[CPacketPlayerTryUseItemOnBlock.class:?] at net.minecraft.network.play.client.CPacketPlayerTryUseItemOnBlock.processPacket(CPacketPlayerTryUseItemOnBlock.java:13) ~[CPacketPlayerTryUseItemOnBlock.class:?] at net.minecraft.network.PacketThreadUtil$1.run(PacketThreadUtil.java:15) ~[PacketThreadUtil$1.class:?] at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) ~[?:1.8.0_77] at java.util.concurrent.FutureTask.run(Unknown Source) ~[?:1.8.0_77] at net.minecraft.util.Util.runTask(Util.java:26) ~[Util.class:?] ... 5 more
-
Oh that... Ok.
-
Where can I find the javadoc? And what should I look for?
-
@SubscribeEvent public void onCropGrow(BonemealEvent event) { event.setCanceled(true); World world = event.getWorld(); IBlockState state = event.getBlock(); BlockPos pos = event.getPos(); ItemStack stack = event.getEntityPlayer().getActiveItemStack(); if (state.getBlock() instanceof IGrowable) { IGrowable igrowable = (IGrowable) state.getBlock(); if (igrowable.canGrow(world, pos, state, world.isRemote)) { if (!world.isRemote) { while (igrowable.canGrow(world, pos, state, world.isRemote)) { igrowable.grow(world, world.rand, pos, state); state = world.getBlockState(pos); } world.markAndNotifyBlock(pos, world.getChunkFromBlockCoords(pos), state, world.getBlockState(pos), 2); stack.shrink(1); } } } } Nope...
-
world.markAndNotifyBlock(pos, world.getChunkFromBlockCoords(pos), state, state, 2); This doesn't work
-
Which one?
-
Ah thanks it works, only thing is, it doesn't take away an item... And the tree gets well.. buggy... It isn't rendered until you update the blocks (right-click)...
-
@SubscribeEvent public void onCropGrow(BonemealEvent event) { event.setCanceled(true); World world = event.getWorld(); IBlockState state = event.getBlock(); BlockPos pos = event.getPos(); ItemStack stack = event.getEntityPlayer().getActiveItemStack(); if (state.getBlock() instanceof IGrowable) { IGrowable igrowable = (IGrowable) state.getBlock(); if (igrowable.canGrow(world, pos, state, world.isRemote)) { if (!world.isRemote) { igrowable.grow(world, world.rand, pos, state); while (igrowable.canGrow(world, pos, state, world.isRemote)) { igrowable.grow(world, world.rand, pos, state); igrowable = (IGrowable) world.getBlockState(pos).getBlock(); } stack.shrink(1); } } } } Doesn't work either
-
Now it 'crashes' the game when I use bonemeal, so when I use it I can't use anything in the game (use hoes on land, open guis from blocks) and then it crashes when I try to go back to the main menu... No crashes in the console
-
Thanks, it works!