Skip to content

Commit

Permalink
Bug fix - NPE because local player is null
Browse files Browse the repository at this point in the history
  • Loading branch information
fr1kin committed Oct 30, 2018
1 parent acad674 commit 4e279ab
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/main/java/com/matt/forgehax/mods/AntiKnockbackMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ public AntiKnockbackMod() {
/** Stops TNT and knockback velocity */
@SubscribeEvent
public void onPacketRecieved(PacketEvent.Incoming.Pre event) {
if (event.getPacket() instanceof SPacketExplosion) {
if(getLocalPlayer() == null)
return;
else if (event.getPacket() instanceof SPacketExplosion) {
// for tnt knockback
SPacketExplosion packet = (SPacketExplosion) event.getPacket();
FastReflection.Fields.SPacketExplosion_motionX.set(
Expand All @@ -70,7 +72,7 @@ public void onPacketRecieved(PacketEvent.Incoming.Pre event) {
FastReflection.Fields.SPacketExplosion_motionZ.get(packet) * multiplier_z.getAsFloat());
} else if (event.getPacket() instanceof SPacketEntityVelocity) {
// for player knockback
if (((SPacketEntityVelocity) event.getPacket()).getEntityID() == MC.player.getEntityId()) {
if (((SPacketEntityVelocity) event.getPacket()).getEntityID() == getLocalPlayer().getEntityId()) {
double multiX = multiplier_x.getAsInteger();
double multiY = multiplier_y.getAsInteger();
double multiZ = multiplier_z.getAsInteger();
Expand Down

0 comments on commit 4e279ab

Please sign in to comment.