Jump to content

Recommended Posts

Posted

Hello, I am trying to make event, that triggers when I attack any mob and it will summon primed tnt and it will instantly blow up.

What was always working was that I placed block under that entity.

My code for placing blocks under entity:

@Mod.EventBusSubscriber(modid = Geornamezi.MOD_ID, bus = Mod.EventBusSubscriber.Bus.FORGE, value = Dist.CLIENT)
public class ModClientEvents {

    @SubscribeEvent
    public static void attackEntity(AttackEntityEvent event) {
        if (event.getEntityLiving().getHeldItemMainhand().getItem() == RegistryHandler.GEORNAMEZI.get()) {
        	if (event.getTarget().isAlive()) {
            	LivingEntity target = (LivingEntity) event.getTarget();
            	if (target instanceof Entity) {
            
           	 	World world = target.getEntityWorld();
            		world.setBlockState(target.getPosition().add(0, -1, 0), RegistryHandler.GEORNAMEZI_BLOCK.get().getDefaultState());
         }
     }
}}  

I seen that there is world.createExplosion(), but i dont know, how to get things working inside that brackets.

Important thing is that, I am using using Forge 1.16.1 32.0.63 with mappings from July 7, 2020 (because i dont know, how to code with newer and mapped mappings).

Thank you for any post on this theme.

George

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



×
×
  • Create New...

Important Information

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