Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Hello,

 

I'm trying to learn Minecraft modding and was busy with an exploding arrow. But I was getting an error in my event where it said I had to add a constructor method. I don't know why this happened. Could someone help me please?

Here is the Code:

package com.evilgood.github.events;

import net.minecraft.entity.Entity;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraftforge.event.entity.EntityEvent;
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

public class ExplodingArrowEvent extends EntityEvent {

	@SubscribeEvent
	public void onImpact(EntityJoinWorldEvent e) {
		if(e.getEntity() instanceof EntityArrow) {
			EntityArrow arrow = (EntityArrow) e.getEntity();
			arrow.getEntityWorld().createExplosion(arrow, arrow.getPosition().getX(), arrow.getPosition().getY(), arrow.getPosition().getZ(), 10, true);
		}
	}
}

Thanks in advance, EvilGood.

  • Author

I was looking through a document that said that I should extend it. I removed it now and it works, so thank you for that, but not the way I intended. I want it to explode on impact. Its now exploding when the arrow spawns in the world. Do I have to use another event or another command? And when do I extend public class?

Thanks for helping, Evilgood.

first of all. If you want to listen to events you should be doing that inside an event listener class (if you dont know what im talking about google minecraft event handling you will find enough information there)

You are using the EntityJoinWorld event. Which is the wrong event for listening for the impact of an arrow..

I dont even think there is such an event in forge. 

I was coding sth similar once, and I remember that I had to use the event for updating entities (LivingUpdateEvent), check if the arrow is inside an block (I see the EntityArrow class now has  the property inTile, you will need reflection to access the private field) if that is != null you can create an explosion at the position of the arrow.

Although I am not sure if using reflection is the right thing for something that isnt that experienced in java ;)

 

Greetz Failender

47 minutes ago, EvilGood said:

I was looking through a document that said that I should extend it.

What documentation where?

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

  • Author

Do you know a link or guide that would help me with reflection, because I'm kinda stuck at the moment. ^

 

Thanks for helping, Evilgood

5 hours ago, EvilGood said:

This document. forgeevents.html

That is not what that document says.  It is saying that EntityJoinWorldEvent extends EntityEvent already, not that YOU need to extend EntityEvent in order to use it.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.