SpongeForge icon indicating copy to clipboard operation
SpongeForge copied to clipboard

ConstructEntityEvent.Post not being called

Open DosMike opened this issue 5 years ago • 1 comments

I am currently running

  • SpongeForge version: 1.12.2-2838-7.1.9

  • Forge version: 1.12.2-14.23.5.2847

  • Java version: 1.8.0_241-b07

  • Operating System: Windows 10

  • Plugins/Mods:

│   Mantle-1.12-1.3.3.55.jar
│   TConstruct-1.12.2-2.13.0.171.jar
│   _aa_spongeforge-1.12.2-2838-7.1.9.jar
│
└───plugins
        LangSwitch-1.6.1.jar
        MegaMenus-0.7.jar
        MikesToolBox-1.2.2.jar
        TotalEconomy-1.7.1-API_7.jar
        VillagerShops-2.4.jar
        WarCraft-0.5.5.jar

Issue Description So I'm trying to attach some data to a projectile when it's being fired by the player using

@Listener
public void onShootArrow(ConstructEntityEvent.Post event) {
	if (!(event.getTargetEntity() instanceof Projectile)) return;
	Projectile projectile = (Projectile)event.getTargetEntity();
	Optional<ItemStackSnapshot> item = event.getContext().get(EventContextKeys.USED_ITEM);
	WarCraft.l("Trying to attaching projectile data via ConstructEntityEvent.Post");
	event.getContext().keySet().forEach(k->WarCraft.l("%s: %s", k.getId(), event.getContext().get(k).get().toString()));
//	item.ifPresent(itemStackSnapshot -> new ProjectileWeapon(itemStackSnapshot).attachTo(projectile));
	item.filter(weapon->!weapon.getType().equals(ItemTypes.AIR))
		.map(weapon->projectile.offer(new ProjectileWeaponDataImpl(weapon)))
		.filter(result->!result.getRejectedData().isEmpty()).ifPresent(result->{
			WarCraft.w("Could not attach weapon data to projectile");
	});
}

I'm also @Listening to LaunchProjectileEvent, but that does not seem to being triggered in SpongeVanilla as well. Nevertheless In vanilla this code logs the following when shooting an arrow using a bow:

[10:01:32 INFO] [dosmike_warcraft]: Trying to attaching projectile data via ConstructEntityEvent.Post
[10:01:32 INFO] [dosmike_warcraft]: sponge:owner: EntityPlayerMP['DosMike'/59, l='world', x=117,29, y=5,00, z=-1285,21]
[10:01:32 INFO] [dosmike_warcraft]: sponge:used_hand: MAIN_HAND
[10:01:32 INFO] [dosmike_warcraft]: sponge:notifier: EntityPlayerMP['DosMike'/59, l='world', x=117,29, y=5,00, z=-1285,21]
[10:01:32 INFO] [dosmike_warcraft]: sponge:used_item: SpongeItemStackSnapshot{itemType=minecraft:bow, quantity=1}

Here's the problem: Running the same plugin in SpongeForge does not seem to trigger the event at all. I also removed TConstruct and Mantle, but the error persists.

DosMike avatar Feb 21 '20 09:02 DosMike

Experiencing this as well, the event works fine on SpongeVanilla but does not trigger at all on SpongeForge. No mods or plugins other than LuckPerms and a plugin used to test this.

Tested with every combination of:

  • SF 1.12.2-2838-7.1.10-RC3998
  • SF 1.12.2-2838-7.1.9
  • Forge 14.23.5.2847
  • Forge 14.23.5.2838

ConstructEntityEvent and ConstructEntityEvent.Pre are triggered on SF, however.

@DosMike AFAIK LaunchProjectileEvent is not triggered by players at all, as it's not fully implemented or if at all really.

Draycia avatar Feb 23 '20 11:02 Draycia