-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(api/entity): add EntityEvent.Push when an entity is pushed
- Loading branch information
1 parent
93a615e
commit f183afc
Showing
6 changed files
with
109 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
src/test/java/net/minecraftforge/debug/entity/PushEventTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright (c) Forge Development LLC and contributors | ||
* SPDX-License-Identifier: LGPL-2.1-only | ||
*/ | ||
|
||
package net.minecraftforge.debug.entity; | ||
|
||
import net.minecraft.world.entity.animal.Cow; | ||
import net.minecraft.world.entity.player.Player; | ||
import net.minecraft.world.phys.Vec3; | ||
import net.minecraftforge.common.MinecraftForge; | ||
import net.minecraftforge.event.entity.EntityEvent; | ||
import net.minecraftforge.eventbus.api.SubscribeEvent; | ||
import net.minecraftforge.fml.common.Mod; | ||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
|
||
@Mod(PushEventTest.MODID) | ||
public class PushEventTest | ||
{ | ||
public static final boolean ENABLE = true; | ||
public static final String MODID = "push_event_test"; | ||
private static Logger logger = LogManager.getLogger(MODID); | ||
|
||
public PushEventTest() | ||
{ | ||
if (ENABLE) | ||
{ | ||
MinecraftForge.EVENT_BUS.register(this); | ||
} | ||
} | ||
|
||
@SubscribeEvent | ||
public void pushEntity(EntityEvent.Push event) | ||
{ | ||
if (event.getEntity() instanceof Player) | ||
{ | ||
event.setMotion(event.getMotion().scale(100)); | ||
} | ||
|
||
if (event.getEntity() instanceof Cow) | ||
{ | ||
event.setMotion(Vec3.ZERO); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters