Skip to content

Commit

Permalink
fire PlayerInteractEvent when player right click on the most ME netwo…
Browse files Browse the repository at this point in the history
…rk part. #6
  • Loading branch information
xsun committed Apr 13, 2017
1 parent 5be7ace commit 439ae2e
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/main/java/appeng/parts/AEBasePart.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.event.ForgeEventFactory;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;

import java.io.IOException;
import java.util.ArrayList;
Expand Down Expand Up @@ -435,6 +437,8 @@ public boolean useStandardMemoryCard()
private boolean useMemoryCard( final EntityPlayer player )
{
final ItemStack memCardIS = player.inventory.getCurrentItem();
if( ForgeEventFactory.onItemUseStart( player, memCardIS, 1 ) <= 0 )
return false;

if( memCardIS != null && this.useStandardMemoryCard() && memCardIS.getItem() instanceof IMemoryCard )
{
Expand Down Expand Up @@ -490,7 +494,9 @@ public final boolean onActivate( final EntityPlayer player, final Vec3 pos )
return true;
}

return this.onPartActivate( player, pos );
int x = (int) pos.xCoord, y = (int) pos.yCoord, z = (int) pos.zCoord;
PlayerInteractEvent event = ForgeEventFactory.onPlayerInteract( player, PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK, x, y, z, this.side.flag, player.getEntityWorld() );
return !event.isCanceled() && this.onPartActivate( player, pos );
}

@Override
Expand All @@ -501,7 +507,9 @@ public final boolean onShiftActivate( final EntityPlayer player, final Vec3 pos
return true;
}

return this.onPartShiftActivate( player, pos );
int x = (int) pos.xCoord, y = (int) pos.yCoord, z = (int) pos.zCoord;
PlayerInteractEvent event = ForgeEventFactory.onPlayerInteract( player, PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK, x, y, z, this.side.flag, player.getEntityWorld() );
return !event.isCanceled() && this.onPartShiftActivate( player, pos );
}

public boolean onPartActivate( final EntityPlayer player, final Vec3 pos )
Expand Down

0 comments on commit 439ae2e

Please sign in to comment.