mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-19 19:59:42 +00:00
Fix cancelling ProjectileImpactEvent still firing onBlockHit (#10481)
This commit is contained in:
1 parent
783c8b7d2b
commit
68a8d3b830
4 files changed
+69
-2
No files matched your search
+33
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.debug.entity;
|
||||
|
||||
import net.minecraft.world.entity.projectile.AbstractArrow;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.ProjectileImpactEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
@Mod(ProjectileImpactEventLegacyCancelTest.MOD_ID)
|
||||
public class ProjectileImpactEventLegacyCancelTest {
|
||||
static final String MOD_ID = "projectile_impact_event_legacy_cancel";
|
||||
|
||||
private static final boolean ENABLED = false;
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
public ProjectileImpactEventLegacyCancelTest() {
|
||||
if (ENABLED) {
|
||||
LOGGER.warn("ProjectileImpactEvent Legacy Cancel test mod active! This will cancel all AbstractArrow impacts!");
|
||||
MinecraftForge.EVENT_BUS.addListener(this::onProjectileImpact);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
private void onProjectileImpact(ProjectileImpactEvent event) {
|
||||
event.setCanceled(event.getProjectile() instanceof AbstractArrow);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user