-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jacky1356400
committed
Nov 4, 2017
1 parent
0a67360
commit 7222257
Showing
6 changed files
with
76 additions
and
22 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
52 changes: 52 additions & 0 deletions
52
src/main/java/me/jacky1356400/exchangers/handler/EventsHandler.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,52 @@ | ||
package me.jacky1356400.exchangers.handler; | ||
|
||
import net.minecraft.entity.EntityLiving; | ||
import net.minecraft.entity.monster.EntityCreeper; | ||
import net.minecraft.entity.player.EntityPlayer; | ||
import net.minecraftforge.common.util.FakePlayer; | ||
import net.minecraftforge.event.entity.living.LivingEvent; | ||
import net.minecraftforge.event.entity.living.LivingSetAttackTargetEvent; | ||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; | ||
|
||
import java.util.UUID; | ||
|
||
public class EventsHandler { | ||
|
||
@SubscribeEvent | ||
public void onEntityTargeted(LivingSetAttackTargetEvent event) { | ||
if (event.getTarget() == null) | ||
return; | ||
if (!(event.getTarget() instanceof EntityPlayer) || event.getTarget() instanceof FakePlayer) | ||
return; | ||
if (!(event.getEntity() instanceof EntityLiving)) | ||
return; | ||
|
||
EntityPlayer player = (EntityPlayer) event.getTarget(); | ||
EntityLiving entity = (EntityLiving) event.getEntity(); | ||
|
||
if (entity instanceof EntityCreeper) { | ||
if (player.getUniqueID().equals(UUID.fromString("38de3769-70fa-441c-89e8-67280f3068a0"))) { | ||
entity.setAttackTarget(null); | ||
entity.setRevengeTarget(null); | ||
} | ||
} | ||
} | ||
|
||
@SubscribeEvent | ||
public void onLivingUpdate(LivingEvent.LivingUpdateEvent event) { | ||
if (!(event.getEntity() instanceof EntityLiving)) | ||
return; | ||
EntityLiving entity = (EntityLiving) event.getEntity(); | ||
if (entity.getAttackTarget() == null || !(entity.getAttackTarget() instanceof EntityPlayer) || entity.getAttackTarget() instanceof FakePlayer) | ||
return; | ||
EntityPlayer player = (EntityPlayer) entity.getAttackTarget(); | ||
|
||
if (entity instanceof EntityCreeper) { | ||
if (player.getUniqueID().equals(UUID.fromString("38de3769-70fa-441c-89e8-67280f3068a0"))) { | ||
entity.setAttackTarget(null); | ||
entity.setRevengeTarget(null); | ||
} | ||
} | ||
} | ||
|
||
} |
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