-
[1.12.2] RightClickEvent
Yes, I see that now, however, there is still the problem with the block, as it is not being detected
-
[1.12.2] RightClickEvent
@SubscribeEvent public void exampleEvent(RightClickBlock event) { World world = event.getWorld(); EntityPlayer player = event.getEntityPlayer(); ItemStack itemstack = player.getItemStackFromSlot(EntityEquipmentSlot.MAINHAND); BlockPos pos = event.getPos(); IBlockState state = world.getBlockState(pos); Block block = state.getBlock(); if(itemstack == new ItemStack(Items.FLINT_AND_STEEL)) { System.out.println("Tested and Found Flint And Steel"); if(block == Blocks.SOUL_SAND.getDefaultState()) { BlockPos fire = pos.offset(EnumFacing.UP); world.setBlockState(fire, Blocks.GOLD_BLOCK.getDefaultState()); System.out.println("Event Success"); } } else { System.out.println("Event Completely Failed"); } } And in the console: [19:17:54] [main/INFO] [STDOUT]: [club.mcmodding.netherupdate.events.TestEvent:exampleEvent:43]: Event Completely Failed [19:17:54] [Server thread/INFO] [STDOUT]: [club.mcmodding.netherupdate.events.TestEvent:exampleEvent:43]: Event Completely Failed
-
[1.12.2] RightClickEvent
However, just right clicking is bringing up the message as well
-
[1.12.2] RightClickEvent
I have added 2 print lines (Event Failed, and Event Success), every time I right click with a flint and steel, the Event Failed comes through, even if I am aimed at soul sand
-
[1.12.2] RightClickEvent
So: @SubscribeEvent public void exampleEvent(RightClickBlock event) { World world = event.getWorld(); EntityPlayer player = event.getEntityPlayer(); ItemStack itemstack = player.getHeldItemMainhand(); BlockPos pos = event.getPos(); IBlockState state = world.getBlockState(pos); Block block = state.getBlock(); if(itemstack == new ItemStack(Items.FLINT_AND_STEEL) && block.equals(Blocks.SOUL_SAND)) { BlockPos fire = pos.offset(EnumFacing.UP); world.setBlockState(fire, Blocks.GOLD_BLOCK.getDefaultState()); } } This still isn't doing anything
-
[1.12.2] RightClickEvent
So where does this exactly go? I'm confused by the wording in the docs
-
[1.12.2] RightClickEvent
I'm guessing it has something to do with the fire being placed first?
-
[1.12.2] RightClickEvent
I made a new class - EventHandler and added this to it: public static void registerEvents() { TestEvent testEvent = new TestEvent(); MinecraftForge.EVENT_BUS.register(testEvent); } Then in my RegistryHandler (where the FMLInitialization events are) I have this in the preInit: EventHandler.registerEvents();
-
[1.12.2] RightClickEvent
Okay so I have this now... public class TestEvent { public void exampleEvent(RightClickBlock event) { World world = event.getWorld(); EntityPlayer player = event.getEntityPlayer(); ItemStack itemstack = player.getHeldItemMainhand(); BlockPos pos = event.getPos(); IBlockState state = world.getBlockState(pos); Block block = state.getBlock(); if(itemstack == new ItemStack(Items.FLINT_AND_STEEL) && block.equals(Blocks.SOUL_SAND)) { BlockPos fire = pos.offset(EnumFacing.UP); world.setBlockState(fire, Blocks.GOLD_BLOCK.getDefaultState()); } } } But nothing seems to happen in game, it still places the fire
-
[1.12.2] RightClickEvent
Okay, so I've managed to get this... public class TestEvent { public void exampleEvent(PlayerInteractEvent event) { World world = event.getWorld(); EntityPlayer player = event.getEntityPlayer(); ItemStack itemstack = player.getHeldItemMainhand(); BlockPos pos = event.getPos(); if(itemstack == new ItemStack(Items.FLINT_AND_STEEL)) { } } } But I'm not sure where to go from it
-
[1.12.2] RightClickEvent
That's the thing, I haven't got anything apart from a class, I'm not entirety sure how to check/cancel the event.
-
[1.12.2] RightClickEvent
I am wanting to create an event to do something rather strange... What I want is: when a player right clicks a gold block with a flint and steel I want it to spawn another gold block on top of it instead of fire I tried using events but I just can't wrap my head around it. Any help would be useful!
-
Custom Crafting Table
The block was IG but no GUI opened.
-
Custom Crafting Table
Hi, I wanted to make a custom crafting table. The idea I had was to basically to copy the vanilla crafting table - so have the 3 by 3 grid and the 1 output (I wanted to do this so my recipes wouldn't clash, in the vanilla table). Context aside for a minute. I tried to copy the classes, but nothing worked! I was just wondering if anyone would be able to help, either with reference code or just some help! Please and Thanks! This is for 1.12.2!
IPS spam blocked by CleanTalk.