fix the event firing of AE2's items
This commit is contained in:
parent
3334933701
commit
11bc4b60a2
|
@ -50,7 +50,6 @@ import net.minecraft.tileentity.TileEntity;
|
|||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.event.ForgeEventFactory;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
@ -244,8 +243,6 @@ public abstract class AEBaseTileBlock extends AEBaseBlock implements IAEFeature,
|
|||
{
|
||||
if( Platform.isWrench( player, is, x, y, z ) && player.isSneaking() )
|
||||
{
|
||||
if( ForgeEventFactory.onItemUseStart( player, is, 1 ) <= 0 )
|
||||
return false;
|
||||
final Block id = w.getBlock( x, y, z );
|
||||
if( id != null )
|
||||
{
|
||||
|
@ -287,8 +284,6 @@ public abstract class AEBaseTileBlock extends AEBaseBlock implements IAEFeature,
|
|||
|
||||
if( is.getItem() instanceof IMemoryCard && !( this instanceof BlockCableBus ) )
|
||||
{
|
||||
if( ForgeEventFactory.onItemUseStart( player, is, 1 ) <= 0 )
|
||||
return false;
|
||||
final IMemoryCard memoryCard = (IMemoryCard) is.getItem();
|
||||
if( player.isSneaking() )
|
||||
{
|
||||
|
|
|
@ -45,6 +45,7 @@ import net.minecraft.tileentity.TileEntity;
|
|||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.event.ForgeEventFactory;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashSet;
|
||||
|
@ -61,6 +62,9 @@ public class ToolDebugCard extends AEBaseItem
|
|||
@Override
|
||||
public boolean onItemUseFirst( final ItemStack stack, final EntityPlayer player, final World world, final int x, final int y, final int z, final int side, final float hitX, final float hitY, final float hitZ )
|
||||
{
|
||||
if( ForgeEventFactory.onItemUseStart( player, stack, 1 ) <= 0 )
|
||||
return true;
|
||||
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
return false;
|
||||
|
|
|
@ -30,6 +30,8 @@ import net.minecraft.client.renderer.texture.IIconRegister;
|
|||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.event.ForgeEventFactory;
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.EnumSet;
|
||||
|
@ -56,6 +58,9 @@ public class ToolEraser extends AEBaseItem
|
|||
@Override
|
||||
public boolean onItemUseFirst( final ItemStack stack, final EntityPlayer player, final World world, final int x, final int y, final int z, final int side, final float hitX, final float hitY, final float hitZ )
|
||||
{
|
||||
if( ForgeEventFactory.onItemUseStart( player, stack, 1 ) <= 0 )
|
||||
return true;
|
||||
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
return false;
|
||||
|
@ -64,6 +69,9 @@ public class ToolEraser extends AEBaseItem
|
|||
final Block blk = world.getBlock( x, y, z );
|
||||
final int meta = world.getBlockMetadata( x, y, z );
|
||||
|
||||
if( blk != null && ForgeEventFactory.onPlayerInteract( player, PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK, x, y, z, side, world ).isCanceled() )
|
||||
return true;
|
||||
|
||||
List<WorldCoord> next = new LinkedList<WorldCoord>();
|
||||
next.add( new WorldCoord( x, y, z ) );
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ import net.minecraft.entity.player.EntityPlayer;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.event.ForgeEventFactory;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
|
@ -50,6 +51,9 @@ public class ToolMeteoritePlacer extends AEBaseItem
|
|||
@Override
|
||||
public boolean onItemUseFirst( final ItemStack stack, final EntityPlayer player, final World world, final int x, final int y, final int z, final int side, final float hitX, final float hitY, final float hitZ )
|
||||
{
|
||||
if( ForgeEventFactory.onItemUseStart( player, stack, 1 ) <= 0 )
|
||||
return true;
|
||||
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
return false;
|
||||
|
|
|
@ -37,6 +37,7 @@ import net.minecraft.util.ChatComponentText;
|
|||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.event.ForgeEventFactory;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
|
@ -51,6 +52,9 @@ public class ToolReplicatorCard extends AEBaseItem
|
|||
@Override
|
||||
public boolean onItemUseFirst( final ItemStack stack, final EntityPlayer player, final World world, int x, int y, int z, final int side, final float hitX, final float hitY, final float hitZ )
|
||||
{
|
||||
if( ForgeEventFactory.onItemUseStart( player, stack, 1 ) <= 0 )
|
||||
return true;
|
||||
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
return false;
|
||||
|
|
|
@ -52,6 +52,7 @@ import net.minecraft.util.IIcon;
|
|||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.event.ForgeEventFactory;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import java.util.*;
|
||||
|
@ -324,6 +325,9 @@ public final class ItemMultiMaterial extends AEBaseItem implements IStorageCompo
|
|||
@Override
|
||||
public boolean onItemUseFirst( final ItemStack is, final EntityPlayer player, final World world, final int x, final int y, final int z, final int side, final float hitX, final float hitY, final float hitZ )
|
||||
{
|
||||
if( ForgeEventFactory.onItemUseStart( player, is, 1 ) <= 0 )
|
||||
return true;
|
||||
|
||||
if( player.isSneaking() )
|
||||
{
|
||||
final TileEntity te = world.getTileEntity( x, y, z );
|
||||
|
|
|
@ -36,6 +36,7 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.MinecraftForgeClient;
|
||||
import net.minecraftforge.event.ForgeEventFactory;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
@ -69,6 +70,9 @@ public class ItemEncodedPattern extends AEBaseItem implements ICraftingPatternIt
|
|||
@Override
|
||||
public boolean onItemUseFirst( final ItemStack stack, final EntityPlayer player, final World world, final int x, final int y, final int z, final int side, final float hitX, final float hitY, final float hitZ )
|
||||
{
|
||||
if( ForgeEventFactory.onItemUseStart( player, stack, 1 ) <= 0 )
|
||||
return true;
|
||||
|
||||
return this.clearPattern( stack, player );
|
||||
}
|
||||
|
||||
|
|
|
@ -48,6 +48,7 @@ import net.minecraft.inventory.IInventory;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.event.ForgeEventFactory;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
@ -289,6 +290,9 @@ public final class ItemBasicStorageCell extends AEBaseItem implements IStorageCe
|
|||
@Override
|
||||
public boolean onItemUseFirst( final ItemStack stack, final EntityPlayer player, final World world, final int x, final int y, final int z, final int side, final float hitX, final float hitY, final float hitZ )
|
||||
{
|
||||
if( ForgeEventFactory.onItemUseStart( player, stack, 1 ) <= 0 )
|
||||
return true;
|
||||
|
||||
return this.disassembleDrive( stack, world, player );
|
||||
}
|
||||
|
||||
|
|
|
@ -49,6 +49,7 @@ 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.util.EnumSet;
|
||||
|
||||
|
@ -104,7 +105,10 @@ public class ToolNetworkTool extends AEBaseItem implements IGuiItem, IAEWrench,
|
|||
public boolean onItemUseFirst( final ItemStack is, final EntityPlayer player, final World world, final int x, final int y, final int z, final int side, final float hitX, final float hitY, final float hitZ )
|
||||
{
|
||||
if( ForgeEventFactory.onItemUseStart( player, is, 1 ) <= 0 )
|
||||
return false;
|
||||
return true;
|
||||
|
||||
if( ForgeEventFactory.onPlayerInteract( player, PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK, x, y, z, side, world ).isCanceled() )
|
||||
return true;
|
||||
|
||||
final MovingObjectPosition mop = new MovingObjectPosition( x, y, z, side, Vec3.createVectorHelper( hitX, hitY, hitZ ) );
|
||||
final TileEntity te = world.getTileEntity( x, y, z );
|
||||
|
|
|
@ -34,6 +34,7 @@ import net.minecraft.item.ItemStack;
|
|||
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.util.EnumSet;
|
||||
|
||||
|
@ -55,9 +56,13 @@ public class ToolQuartzWrench extends AEBaseItem implements IAEWrench, IToolWren
|
|||
public boolean onItemUseFirst( final ItemStack is, final EntityPlayer player, final World world, final int x, final int y, final int z, final int side, final float hitX, final float hitY, final float hitZ )
|
||||
{
|
||||
if( ForgeEventFactory.onItemUseStart( player, is, 1 ) <= 0 )
|
||||
return false;
|
||||
return true;
|
||||
|
||||
final Block b = world.getBlock( x, y, z );
|
||||
|
||||
if( b != null && ForgeEventFactory.onPlayerInteract( player, PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK, x, y, z, side, world ).isCanceled() )
|
||||
return true;
|
||||
|
||||
if( b != null && !player.isSneaking() && Platform.hasPermissions( new DimensionalCoord( world, x, y, z ), player ) )
|
||||
{
|
||||
if( Platform.isClient() )
|
||||
|
|
|
@ -489,27 +489,33 @@ public abstract class AEBasePart implements IPart, IGridProxyable, IActionHost,
|
|||
@Override
|
||||
public final boolean onActivate( final EntityPlayer player, final Vec3 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() );
|
||||
if( event.isCanceled() )
|
||||
return false;
|
||||
|
||||
if( this.useMemoryCard( player ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
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 );
|
||||
return onPartActivate( player, pos );
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean onShiftActivate( final EntityPlayer player, final Vec3 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() );
|
||||
if( event.isCanceled() )
|
||||
return false;
|
||||
|
||||
if( this.useMemoryCard( player ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
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 );
|
||||
return this.onPartShiftActivate( player, pos );
|
||||
}
|
||||
|
||||
public boolean onPartActivate( final EntityPlayer player, final Vec3 pos )
|
||||
|
|
Loading…
Reference in New Issue