Jump to content

Recommended Posts

Posted

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!

Posted
11 minutes ago, Animefan8888 said:

You can read up about events here.

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

Posted
1 minute ago, Pppineeeee3 said:

PlayerInteractEvent

There are several sub-events to this one, the one you want is called PlayerInteractEvent.RightClickBlock.

2 minutes ago, Pppineeeee3 said:

But I'm not sure where to go from it 

You have the BlockPos where the player right clicked(aka where the Block is in the World where they right clicked). That means you have access to which Block they right clicked. Check to make sure it was a Gold Block. If it was a Gold Block then use BlockPos#offset to offset in the UP direction and call World#setBlockState to put a Gold Block in the World at that offset position.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted
1 minute ago, Animefan8888 said:

There are several sub-events to this one, the one you want is called PlayerInteractEvent.RightClickBlock.

You have the BlockPos where the player right clicked(aka where the Block is in the World where they right clicked). That means you have access to which Block they right clicked. Check to make sure it was a Gold Block. If it was a Gold Block then use BlockPos#offset to offset in the UP direction and call World#setBlockState to put a Gold Block in the World at that offset position.

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 :/

Posted
3 minutes ago, Animefan8888 said:

Is your event even being called? Where do you register it?

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();

 

Posted

I was the blind one this time diesieben

2 minutes ago, Pppineeeee3 said:

So where does this exactly go? I'm confused by the wording in the docs

It goes right above your Event method.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted
3 minutes ago, Animefan8888 said:

I was the blind one this time diesieben

It goes right above your Event method.

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

Posted
7 minutes ago, Pppineeeee3 said:

This still isn't doing anything

Can you confirm if the event is being fired. Put a print line there or better yet step through that method with your debugger.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted
4 minutes ago, Animefan8888 said:

Put a print line there

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

Posted
44 minutes ago, Pppineeeee3 said:

itemstack == new ItemStack(Items.FLINT_AND_STEEL)

We were both blind diesieben...

The problem is that this will never be true. Use ItemStack#getItem and compare item instances instead.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted
Just now, diesieben07 said:

Post updated code (with the debug message).

@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
 

Posted
5 minutes ago, diesieben07 said:

Animefan is right.

Please learn basic Java (yes, the == operator is basic Java) before attempting to mod.

Yes, I see that now, however, there is still the problem with the block, as it is not being detected

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • i have just made a modpack and i accidentally added a few fabric mods and after deleting them i can no longer launch the pack if any one could help these are my latest logs [22:42:24] [main/INFO]:additionalClassesLocator: [optifine., net.optifine.] [22:42:25] [main/INFO]:Compatibility level set to JAVA_17 [22:42:25] [main/ERROR]:Mixin config epicsamurai.mixins.json does not specify "minVersion" property [22:42:25] [main/INFO]:Launching target 'forgeclient' with arguments [--version, forge-43.4.0, --gameDir, C:\Users\Mytht\curseforge\minecraft\Instances\overseer (1), --assetsDir, C:\Users\Mytht\curseforge\minecraft\Install\assets, --uuid, 4c176bf14d4041cba29572aa4333ca1d, --username, mythtitan0, --assetIndex, 1.19, --accessToken, ????????, --clientId, MGJiMTEzNGEtMjc3Mi00ODE0LThlY2QtNzFiODMyODEyYjM4, --xuid, 2535469006485684, --userType, msa, --versionType, release, --width, 854, --height, 480] [22:42:25] [main/WARN]:Reference map 'insanelib.refmap.json' for insanelib.mixins.json could not be read. If this is a development environment you can ignore this message [22:42:25] [main/WARN]:Reference map 'corpsecurioscompat.refmap.json' for gravestonecurioscompat.mixins.json could not be read. If this is a development environment you can ignore this message [22:42:25] [main/WARN]:Reference map 'nitrogen_internals.refmap.json' for nitrogen_internals.mixins.json could not be read. If this is a development environment you can ignore this message [22:42:25] [main/WARN]:Reference map 'arclight.mixins.refmap.json' for epicsamurai.mixins.json could not be read. If this is a development environment you can ignore this message [22:42:25] [main/WARN]:Reference map 'simplyswords-common-refmap.json' for simplyswords-common.mixins.json could not be read. If this is a development environment you can ignore this message [22:42:25] [main/WARN]:Reference map 'simplyswords-forge-refmap.json' for simplyswords.mixins.json could not be read. If this is a development environment you can ignore this message [22:42:25] [main/WARN]:Reference map '${refmap_target}refmap.json' for corgilib.forge.mixins.json could not be read. If this is a development environment you can ignore this message [22:42:25] [main/WARN]:Reference map 'MysticPotions-forge-refmap.json' for mysticpotions.mixins.json could not be read. If this is a development environment you can ignore this message [22:42:26] [main/WARN]:Reference map 'packetfixer-forge-forge-refmap.json' for packetfixer-forge.mixins.json could not be read. If this is a development environment you can ignore this message [22:42:26] [main/WARN]:Error loading class: atomicstryker/multimine/client/MultiMineClient (java.lang.ClassNotFoundException: atomicstryker.multimine.client.MultiMineClient) [22:42:26] [main/WARN]:@Mixin target atomicstryker.multimine.client.MultiMineClient was not found treechop.forge.compat.mixins.json:MultiMineMixin [22:42:26] [main/WARN]:Error loading class: com/simibubi/create/content/contraptions/components/fan/AirCurrent (java.lang.ClassNotFoundException: com.simibubi.create.content.contraptions.components.fan.AirCurrent) [22:42:26] [main/WARN]:Error loading class: shadows/apotheosis/ench/table/ApothEnchantContainer (java.lang.ClassNotFoundException: shadows.apotheosis.ench.table.ApothEnchantContainer) [22:42:26] [main/WARN]:@Mixin target shadows.apotheosis.ench.table.ApothEnchantContainer was not found origins_classes.mixins.json:common.apotheosis.ApotheosisEnchantmentMenuMixin [22:42:26] [main/WARN]:Error loading class: se/mickelus/tetra/blocks/workbench/WorkbenchTile (java.lang.ClassNotFoundException: se.mickelus.tetra.blocks.workbench.WorkbenchTile) [22:42:26] [main/WARN]:@Mixin target se.mickelus.tetra.blocks.workbench.WorkbenchTile was not found origins_classes.mixins.json:common.tetra.WorkbenchTileMixin [22:42:27] [main/WARN]:Error loading class: tfar/davespotioneering/blockentity/AdvancedBrewingStandBlockEntity (java.lang.ClassNotFoundException: tfar.davespotioneering.blockentity.AdvancedBrewingStandBlockEntity) [22:42:27] [main/WARN]:@Mixin target tfar.davespotioneering.blockentity.AdvancedBrewingStandBlockEntity was not found itemproductionlib.mixins.json:davespotioneering/AdvancedBrewingStandBlockEntityMixin [22:42:27] [main/WARN]:Error loading class: fuzs/visualworkbench/world/inventory/ModCraftingMenu (java.lang.ClassNotFoundException: fuzs.visualworkbench.world.inventory.ModCraftingMenu) [22:42:27] [main/WARN]:@Mixin target fuzs.visualworkbench.world.inventory.ModCraftingMenu was not found itemproductionlib.mixins.json:visualworkbench/ModCraftingMenuMixin [22:42:27] [main/WARN]:Error loading class: fuzs/easymagic/world/inventory/ModEnchantmentMenu (java.lang.ClassNotFoundException: fuzs.easymagic.world.inventory.ModEnchantmentMenu) [22:42:27] [main/WARN]:@Mixin target fuzs.easymagic.world.inventory.ModEnchantmentMenu was not found skilltree.mixins.json:easymagic/ModEnchantmentMenuMixin [22:42:27] [main/WARN]:Error loading class: shadows/apotheosis/ench/table/ApothEnchantmentMenu (java.lang.ClassNotFoundException: shadows.apotheosis.ench.table.ApothEnchantmentMenu) [22:42:27] [main/WARN]:@Mixin target shadows.apotheosis.ench.table.ApothEnchantmentMenu was not found skilltree.mixins.json:apotheosis/ApothEnchantContainerMixin [22:42:27] [main/WARN]:Error loading class: shadows/apotheosis/adventure/affix/socket/SocketingRecipe (java.lang.ClassNotFoundException: shadows.apotheosis.adventure.affix.socket.SocketingRecipe) [22:42:27] [main/WARN]:@Mixin target shadows.apotheosis.adventure.affix.socket.SocketingRecipe was not found skilltree.mixins.json:apotheosis/SocketingRecipeMixin [22:42:27] [main/WARN]:Error loading class: shadows/apotheosis/adventure/affix/socket/gem/bonus/AttributeBonus (java.lang.ClassNotFoundException: shadows.apotheosis.adventure.affix.socket.gem.bonus.AttributeBonus) [22:42:27] [main/WARN]:@Mixin target shadows.apotheosis.adventure.affix.socket.gem.bonus.AttributeBonus was not found skilltree.mixins.json:apotheosis/AttributeBonusMixin [22:42:27] [main/WARN]:Error loading class: shadows/apotheosis/adventure/affix/socket/gem/bonus/EnchantmentBonus (java.lang.ClassNotFoundException: shadows.apotheosis.adventure.affix.socket.gem.bonus.EnchantmentBonus) [22:42:27] [main/WARN]:@Mixin target shadows.apotheosis.adventure.affix.socket.gem.bonus.EnchantmentBonus was not found skilltree.mixins.json:apotheosis/EnchantmentBonusMixin [22:42:27] [main/WARN]:Error loading class: shadows/apotheosis/adventure/client/AdventureModuleClient (java.lang.ClassNotFoundException: shadows.apotheosis.adventure.client.AdventureModuleClient) [22:42:27] [main/WARN]:@Mixin target shadows.apotheosis.adventure.client.AdventureModuleClient was not found skilltree.mixins.json:apotheosis/AdventureModuleClientMixin [22:42:27] [main/WARN]:Error loading class: me/shedaniel/rei/RoughlyEnoughItemsCoreClient (java.lang.ClassNotFoundException: me.shedaniel.rei.RoughlyEnoughItemsCoreClient) [22:42:27] [main/WARN]:Error loading class: com/replaymod/replay/ReplayHandler (java.lang.ClassNotFoundException: com.replaymod.replay.ReplayHandler) [22:42:27] [main/WARN]:Error loading class: net/coderbot/iris/pipeline/newshader/ExtendedShader (java.lang.ClassNotFoundException: net.coderbot.iris.pipeline.newshader.ExtendedShader) [22:42:27] [main/WARN]:Error loading class: net/irisshaders/iris/pipeline/programs/ExtendedShader (java.lang.ClassNotFoundException: net.irisshaders.iris.pipeline.programs.ExtendedShader) [22:42:27] [main/INFO]:Initializing MixinExtras via com.llamalad7.mixinextras.service.MixinExtrasServiceImpl(version=0.3.6).
    • My Mohist server crashed as well but all it says in logs is " C:\Minecraft Mohist server>java -Xm6G -jar mohist.jar nogul  Error: Unable to access jarfile mohist.jar   C:\Minecraft Mohist server>PAUSE press any key to continue  .  .  . " Any ideas? i have the server file that its looking for where its looking for it.
    • It is an issue with Pixelmon - maybe report it to the creators
  • Topics

×
×
  • Create New...

Important Information

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