@@ -209,6 +209,7 @@ public interface IPart extends IBoxProvider, ICustomCableConnection
|
||||
* Called when you right click the part, very similar to Block.onActivateBlock
|
||||
*
|
||||
* @param player right clicking player
|
||||
* @param hand hand used
|
||||
* @param pos position of block
|
||||
*
|
||||
* @return if your activate method performed something.
|
||||
@@ -219,12 +220,41 @@ public interface IPart extends IBoxProvider, ICustomCableConnection
|
||||
* Called when you right click the part, very similar to Block.onActivateBlock
|
||||
*
|
||||
* @param player shift right clicking player
|
||||
* @param hand hand used
|
||||
* @param pos position of block
|
||||
*
|
||||
* @return if your activate method performed something, you should use false unless you really need it.
|
||||
*/
|
||||
boolean onShiftActivate( EntityPlayer player, EnumHand hand, Vec3d pos );
|
||||
|
||||
/**
|
||||
* Called when you left click the part, very similar to Block.onBlockClicked
|
||||
*
|
||||
* @param player left clicking player
|
||||
* @param hand hand used
|
||||
* @param pos position of block
|
||||
*
|
||||
* @return if your activate method performed something, you should use false unless you really need it.
|
||||
*/
|
||||
default boolean onClicked( EntityPlayer player, EnumHand hand, Vec3d pos )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when you shift-left click the part, very similar to Block.onBlockClicked
|
||||
*
|
||||
* @param player shift-left clicking player
|
||||
* @param hand hand used
|
||||
* @param pos position of block
|
||||
*
|
||||
* @return if your activate method performed something, you should use false unless you really need it.
|
||||
*/
|
||||
default boolean onShiftClicked( EntityPlayer player, EnumHand hand, Vec3d pos )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add drops to the items being dropped into the world, if your item stores its contents when wrenched use the
|
||||
* wrenched boolean to control what data is saved vs dropped when it is broken.
|
||||
|
||||
@@ -49,6 +49,7 @@ import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.math.RayTraceResult.Type;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
@@ -70,6 +71,8 @@ import appeng.client.render.cablebus.CableBusBakedModel;
|
||||
import appeng.client.render.cablebus.CableBusRenderState;
|
||||
import appeng.core.Api;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketClick;
|
||||
import appeng.helpers.AEGlassMaterial;
|
||||
import appeng.parts.ICableBusContainer;
|
||||
import appeng.parts.NullCableBusContainer;
|
||||
@@ -353,6 +356,31 @@ public class BlockCableBus extends AEBaseTileBlock
|
||||
return out == null ? NULL_CABLE_BUS : out;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockClicked( World worldIn, BlockPos pos, EntityPlayer playerIn )
|
||||
{
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
final RayTraceResult rtr = Minecraft.getMinecraft().objectMouseOver;
|
||||
if( rtr != null && rtr.typeOfHit == Type.BLOCK && pos.equals( rtr.getBlockPos() ) )
|
||||
{
|
||||
final Vec3d hitVec = rtr.hitVec.subtract( new Vec3d( pos ) );
|
||||
|
||||
if( this.cb( worldIn, pos ).clicked( playerIn, EnumHand.MAIN_HAND, hitVec ) )
|
||||
{
|
||||
NetworkHandler.instance()
|
||||
.sendToServer(
|
||||
new PacketClick( pos, rtr.sideHit, (float) hitVec.x, (float) hitVec.y, (float) hitVec.z, EnumHand.MAIN_HAND, true ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onBlockClickPacket( World worldIn, BlockPos pos, EntityPlayer playerIn, EnumHand hand, Vec3d hitVec )
|
||||
{
|
||||
this.cb( worldIn, pos ).clicked( playerIn, hand, hitVec );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActivated( final World w, final BlockPos pos, final EntityPlayer player, final EnumHand hand, final @Nullable ItemStack heldItem, final EnumFacing side, final float hitX, final float hitY, final float hitZ )
|
||||
{
|
||||
|
||||
@@ -22,17 +22,20 @@ package appeng.core.sync.packets;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.definitions.IComparableDefinition;
|
||||
import appeng.api.definitions.IItems;
|
||||
import appeng.api.implementations.items.IMemoryCard;
|
||||
import appeng.api.implementations.items.MemoryCardMessages;
|
||||
import appeng.block.networking.BlockCableBus;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.items.tools.ToolNetworkTool;
|
||||
@@ -50,6 +53,7 @@ public class PacketClick extends AppEngPacket
|
||||
private final float hitY;
|
||||
private final float hitZ;
|
||||
private EnumHand hand;
|
||||
private final boolean leftClick;
|
||||
|
||||
// automatic.
|
||||
public PacketClick( final ByteBuf stream )
|
||||
@@ -70,10 +74,16 @@ public class PacketClick extends AppEngPacket
|
||||
this.hitY = stream.readFloat();
|
||||
this.hitZ = stream.readFloat();
|
||||
this.hand = EnumHand.values()[stream.readByte()];
|
||||
this.leftClick = stream.readBoolean();
|
||||
}
|
||||
|
||||
// api
|
||||
public PacketClick( final BlockPos pos, final EnumFacing side, final float hitX, final float hitY, final float hitZ, final EnumHand hand )
|
||||
{
|
||||
this( pos, side, hitX, hitY, hitZ, hand, false );
|
||||
}
|
||||
|
||||
public PacketClick( final BlockPos pos, final EnumFacing side, final float hitX, final float hitY, final float hitZ, final EnumHand hand, boolean leftClick )
|
||||
{
|
||||
|
||||
final ByteBuf data = Unpooled.buffer();
|
||||
@@ -94,6 +104,7 @@ public class PacketClick extends AppEngPacket
|
||||
data.writeFloat( this.hitY = hitY );
|
||||
data.writeFloat( this.hitZ = hitZ );
|
||||
data.writeByte( hand.ordinal() );
|
||||
data.writeBoolean( this.leftClick = leftClick );
|
||||
|
||||
this.configureWrite( data );
|
||||
}
|
||||
@@ -105,27 +116,38 @@ public class PacketClick extends AppEngPacket
|
||||
final IItems items = AEApi.instance().definitions().items();
|
||||
final IComparableDefinition maybeMemoryCard = items.memoryCard();
|
||||
final IComparableDefinition maybeColorApplicator = items.colorApplicator();
|
||||
|
||||
if( !is.isEmpty() )
|
||||
final BlockPos pos = new BlockPos( this.x, this.y, this.z );
|
||||
if( this.leftClick )
|
||||
{
|
||||
if( is.getItem() instanceof ToolNetworkTool )
|
||||
final Block block = player.world.getBlockState( pos ).getBlock();
|
||||
if( block instanceof BlockCableBus )
|
||||
{
|
||||
final ToolNetworkTool tnt = (ToolNetworkTool) is.getItem();
|
||||
tnt.serverSideToolLogic( is, player, this.hand, player.world, new BlockPos( this.x, this.y, this.z ), this.side, this.hitX, this.hitY,
|
||||
this.hitZ );
|
||||
( (BlockCableBus) block ).onBlockClickPacket( player.world, pos, player, this.hand, new Vec3d( this.hitX, this.hitY, this.hitZ ) );
|
||||
}
|
||||
|
||||
else if( maybeMemoryCard.isSameAs( is ) )
|
||||
}
|
||||
else
|
||||
{
|
||||
if( !is.isEmpty() )
|
||||
{
|
||||
final IMemoryCard mem = (IMemoryCard) is.getItem();
|
||||
mem.notifyUser( player, MemoryCardMessages.SETTINGS_CLEARED );
|
||||
is.setTagCompound( null );
|
||||
}
|
||||
if( is.getItem() instanceof ToolNetworkTool )
|
||||
{
|
||||
final ToolNetworkTool tnt = (ToolNetworkTool) is.getItem();
|
||||
tnt.serverSideToolLogic( is, player, this.hand, player.world, pos, this.side, this.hitX, this.hitY,
|
||||
this.hitZ );
|
||||
}
|
||||
|
||||
else if( maybeColorApplicator.isSameAs( is ) )
|
||||
{
|
||||
final ToolColorApplicator mem = (ToolColorApplicator) is.getItem();
|
||||
mem.cycleColors( is, mem.getColor( is ), 1 );
|
||||
else if( maybeMemoryCard.isSameAs( is ) )
|
||||
{
|
||||
final IMemoryCard mem = (IMemoryCard) is.getItem();
|
||||
mem.notifyUser( player, MemoryCardMessages.SETTINGS_CLEARED );
|
||||
is.setTagCompound( null );
|
||||
}
|
||||
|
||||
else if( maybeColorApplicator.isSameAs( is ) )
|
||||
{
|
||||
final ToolColorApplicator mem = (ToolColorApplicator) is.getItem();
|
||||
mem.cycleColors( is, mem.getColor( is ), 1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -185,18 +185,12 @@ public class PartFluidFormationPlane extends PartAbstractFormationPlane<IAEFluid
|
||||
@Override
|
||||
public boolean onPartActivate( final EntityPlayer player, final EnumHand hand, final Vec3d pos )
|
||||
{
|
||||
if( !player.isSneaking() )
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
Platform.openGUI( player, this.getHost().getTile(), this.getSide(), GuiBridge.GUI_FLUID_FORMATION_PLANE );
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -136,11 +136,6 @@ public class PartFluidInterface extends PartBasicState implements IGridTickable,
|
||||
@Override
|
||||
public boolean onPartActivate( final EntityPlayer p, final EnumHand hand, final Vec3d pos )
|
||||
{
|
||||
if( p.isSneaking() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
Platform.openGUI( p, this.getTileEntity(), this.getSide(), GuiBridge.GUI_FLUID_INTERFACE );
|
||||
@@ -237,7 +232,7 @@ public class PartFluidInterface extends PartBasicState implements IGridTickable,
|
||||
{
|
||||
return this.duality.getInventoryByName( name );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStackRepresentation()
|
||||
{
|
||||
|
||||
@@ -266,18 +266,11 @@ public class PartFluidLevelEmitter extends PartUpgradeable implements IStackWatc
|
||||
@Override
|
||||
public boolean onPartActivate( final EntityPlayer player, final EnumHand hand, final Vec3d pos )
|
||||
{
|
||||
if( !player.isSneaking() )
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
Platform.openGUI( player, this.getHost().getTile(), this.getSide(), GuiBridge.GUI_FLUID_LEVEL_EMITTER );
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -222,17 +222,11 @@ public class PartFluidStorageBus extends PartSharedStorageBus implements IMEMoni
|
||||
@Override
|
||||
public boolean onPartActivate( final EntityPlayer player, final EnumHand hand, final Vec3d pos )
|
||||
{
|
||||
if( !player.isSneaking() )
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
Platform.openGUI( player, this.getHost().getTile(), this.getSide(), GuiBridge.GUI_STORAGEBUS_FLUID );
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -491,7 +485,7 @@ public class PartFluidStorageBus extends PartSharedStorageBus implements IMEMoni
|
||||
return MODELS_OFF;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStackRepresentation()
|
||||
{
|
||||
|
||||
@@ -104,18 +104,12 @@ public abstract class PartSharedFluidBus extends PartUpgradeable implements IGri
|
||||
@Override
|
||||
public boolean onPartActivate( final EntityPlayer player, final EnumHand hand, final Vec3d pos )
|
||||
{
|
||||
if( !player.isSneaking() )
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
Platform.openGUI( player, this.getHost().getTile(), this.getSide(), GuiBridge.GUI_BUS_FLUID );
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -818,11 +818,35 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I
|
||||
final SelectedPart p = this.selectPart( pos );
|
||||
if( p != null && p.part != null )
|
||||
{
|
||||
// forge sends activate even when sneaking in some cases (eg emtpy hand)
|
||||
// if sneaking try shift activate first.
|
||||
if( player.isSneaking() && p.part.onShiftActivate( player, hand, pos ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return p.part.onActivate( player, hand, pos );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean clicked( EntityPlayer player, EnumHand hand, Vec3d hitVec )
|
||||
{
|
||||
final SelectedPart p = this.selectPart( hitVec );
|
||||
if( p != null && p.part != null )
|
||||
{
|
||||
if( player.isSneaking() )
|
||||
{
|
||||
return p.part.onShiftClicked( player, hand, hitVec );
|
||||
}
|
||||
else
|
||||
{
|
||||
return p.part.onClicked( player, hand, hitVec );
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborChanged( IBlockAccess w, BlockPos pos, BlockPos neighbor )
|
||||
{
|
||||
|
||||
@@ -52,6 +52,8 @@ public interface ICableBusContainer
|
||||
|
||||
boolean activate( EntityPlayer player, EnumHand hand, Vec3d vecFromPool );
|
||||
|
||||
boolean clicked( EntityPlayer player, EnumHand hand, Vec3d hitVec );
|
||||
|
||||
void onNeighborChanged( IBlockAccess w, BlockPos pos, BlockPos neighbor );
|
||||
|
||||
boolean isSolidOnSide( EnumFacing side );
|
||||
|
||||
@@ -124,4 +124,10 @@ public class NullCableBusContainer implements ICableBusContainer
|
||||
return new CableBusRenderState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean clicked( EntityPlayer player, EnumHand hand, Vec3d hitVec )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -196,7 +196,7 @@ public class PartPlacement
|
||||
}
|
||||
}
|
||||
|
||||
// if ( held == null )
|
||||
if( held.isEmpty() )
|
||||
{
|
||||
final Block block = world.getBlockState( pos ).getBlock();
|
||||
if( host != null && player.isSneaking() && block != null )
|
||||
@@ -261,8 +261,9 @@ public class PartPlacement
|
||||
final boolean multiPartPresent = maybeMultiPartBlock.isPresent() && maybeMultiPartStack.isPresent() && maybeMultiPartItemBlock.isPresent();
|
||||
final boolean canMultiPartBePlaced = maybeMultiPartBlock.get().canPlaceBlockAt( world, te_pos );
|
||||
|
||||
if( hostIsNotPresent && multiPartPresent && canMultiPartBePlaced && maybeMultiPartItemBlock.get().placeBlockAt( maybeMultiPartStack.get(), player,
|
||||
world, te_pos, side, 0.5f, 0.5f, 0.5f, maybeMultiPartBlock.get().getDefaultState() ) )
|
||||
if( hostIsNotPresent && multiPartPresent && canMultiPartBePlaced && maybeMultiPartItemBlock.get()
|
||||
.placeBlockAt( maybeMultiPartStack.get(), player,
|
||||
world, te_pos, side, 0.5f, 0.5f, 0.5f, maybeMultiPartBlock.get().getDefaultState() ) )
|
||||
{
|
||||
if( !world.isRemote )
|
||||
{
|
||||
|
||||
@@ -130,8 +130,10 @@ public class PartExportBus extends PartSharedItemBus implements ICraftingRequest
|
||||
try
|
||||
{
|
||||
final InventoryAdaptor destination = this.getHandler();
|
||||
final IMEMonitor<IAEItemStack> inv = this.getProxy().getStorage().getInventory(
|
||||
AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
|
||||
final IMEMonitor<IAEItemStack> inv = this.getProxy()
|
||||
.getStorage()
|
||||
.getInventory(
|
||||
AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
|
||||
final IEnergyGrid energy = this.getProxy().getEnergy();
|
||||
final ICraftingGrid cg = this.getProxy().getCrafting();
|
||||
final FuzzyMode fzMode = (FuzzyMode) this.getConfigManager().getSetting( Settings.FUZZY_MODE );
|
||||
@@ -215,18 +217,11 @@ public class PartExportBus extends PartSharedItemBus implements ICraftingRequest
|
||||
@Override
|
||||
public boolean onPartActivate( final EntityPlayer player, final EnumHand hand, final Vec3d pos )
|
||||
{
|
||||
if( !player.isSneaking() )
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
Platform.openGUI( player, this.getHost().getTile(), this.getSide(), GuiBridge.GUI_BUS );
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -196,18 +196,11 @@ public class PartFormationPlane extends PartAbstractFormationPlane<IAEItemStack>
|
||||
@Override
|
||||
public boolean onPartActivate( final EntityPlayer player, final EnumHand hand, final Vec3d pos )
|
||||
{
|
||||
if( !player.isSneaking() )
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
Platform.openGUI( player, this.getHost().getTile(), this.getSide(), GuiBridge.GUI_FORMATION_PLANE );
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -93,8 +93,10 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin
|
||||
|
||||
try
|
||||
{
|
||||
final IMEMonitor<IAEItemStack> inv = this.getProxy().getStorage().getInventory(
|
||||
AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
|
||||
final IMEMonitor<IAEItemStack> inv = this.getProxy()
|
||||
.getStorage()
|
||||
.getInventory(
|
||||
AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
|
||||
|
||||
final IAEItemStack out = inv.injectItems( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createStack( stack ),
|
||||
Actionable.SIMULATE,
|
||||
@@ -128,18 +130,11 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin
|
||||
@Override
|
||||
public boolean onPartActivate( final EntityPlayer player, final EnumHand hand, final Vec3d pos )
|
||||
{
|
||||
if( !player.isSneaking() )
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
Platform.openGUI( player, this.getHost().getTile(), this.getSide(), GuiBridge.GUI_BUS );
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -173,8 +168,10 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin
|
||||
{
|
||||
this.itemsToSend = this.calculateItemsToSend();
|
||||
|
||||
final IMEMonitor<IAEItemStack> inv = this.getProxy().getStorage().getInventory(
|
||||
AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
|
||||
final IMEMonitor<IAEItemStack> inv = this.getProxy()
|
||||
.getStorage()
|
||||
.getInventory(
|
||||
AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
|
||||
final IEnergyGrid energy = this.getProxy().getEnergy();
|
||||
|
||||
boolean Configured = false;
|
||||
|
||||
@@ -465,18 +465,11 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH
|
||||
@Override
|
||||
public boolean onPartActivate( final EntityPlayer player, final EnumHand hand, final Vec3d pos )
|
||||
{
|
||||
if( !player.isSneaking() )
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
Platform.openGUI( player, this.getHost().getTile(), this.getSide(), GuiBridge.GUI_LEVEL_EMITTER );
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -174,16 +174,10 @@ public class PartInterface extends PartBasicState implements IGridTickable, ISto
|
||||
@Override
|
||||
public boolean onPartActivate( final EntityPlayer p, final EnumHand hand, final Vec3d pos )
|
||||
{
|
||||
if( p.isSneaking() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
Platform.openGUI( p, this.getTileEntity(), this.getSide(), GuiBridge.GUI_INTERFACE );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -311,7 +305,7 @@ public class PartInterface extends PartBasicState implements IGridTickable, ISto
|
||||
{
|
||||
return this.duality.getCapability( capabilityClass, this.getSide().getFacing() );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStackRepresentation()
|
||||
{
|
||||
|
||||
@@ -256,8 +256,10 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
|
||||
{
|
||||
if( this.getProxy().isActive() )
|
||||
{
|
||||
this.getProxy().getStorage().postAlterationOfStoredItems( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ), change,
|
||||
this.mySrc );
|
||||
this.getProxy()
|
||||
.getStorage()
|
||||
.postAlterationOfStoredItems( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ), change,
|
||||
this.mySrc );
|
||||
}
|
||||
}
|
||||
catch( final GridAccessException e )
|
||||
@@ -298,18 +300,11 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
|
||||
@Override
|
||||
public boolean onPartActivate( final EntityPlayer player, final EnumHand hand, final Vec3d pos )
|
||||
{
|
||||
if( !player.isSneaking() )
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
Platform.openGUI( player, this.getHost().getTile(), this.getSide(), GuiBridge.GUI_STORAGEBUS );
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -625,7 +620,7 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
|
||||
return MODELS_OFF;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStackRepresentation()
|
||||
{
|
||||
|
||||
@@ -160,6 +160,11 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
|
||||
@Override
|
||||
public boolean onPartActivate( final EntityPlayer player, final EnumHand hand, final Vec3d pos )
|
||||
{
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if( hand == EnumHand.OFF_HAND )
|
||||
{
|
||||
return false;
|
||||
@@ -305,6 +310,11 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
|
||||
final ItemStack is = player.inventory.getCurrentItem();
|
||||
if( !is.isEmpty() && is.getItem() instanceof IMemoryCard )
|
||||
{
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
final IMemoryCard mc = (IMemoryCard) is.getItem();
|
||||
final NBTTagCompound data = new NBTTagCompound();
|
||||
|
||||
|
||||
@@ -27,7 +27,6 @@ import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
@@ -163,24 +162,46 @@ public abstract class AbstractPartMonitor extends AbstractPartDisplay implements
|
||||
return false;
|
||||
}
|
||||
|
||||
final TileEntity te = this.getTile();
|
||||
final ItemStack eq = player.getHeldItem( hand );
|
||||
|
||||
if( Platform.isWrench( player, eq, te.getPos() ) )
|
||||
{
|
||||
this.isLocked = !this.isLocked;
|
||||
player.sendMessage( ( this.isLocked ? PlayerMessages.isNowLocked : PlayerMessages.isNowUnlocked ).get() );
|
||||
this.getHost().markForUpdate();
|
||||
}
|
||||
else if( !this.isLocked )
|
||||
if( !this.isLocked )
|
||||
{
|
||||
final ItemStack eq = player.getHeldItem( hand );
|
||||
this.configuredItem = AEItemStack.fromItemStack( eq );
|
||||
this.configureWatchers();
|
||||
this.getHost().markForSave();
|
||||
this.getHost().markForUpdate();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.extractItem( player );
|
||||
return super.onPartActivate( player, hand, pos );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPartShiftActivate( EntityPlayer player, EnumHand hand, Vec3d pos )
|
||||
{
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if( !this.getProxy().isActive() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if( !Platform.hasPermissions( this.getLocation(), player ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if( player.getHeldItem( hand ).isEmpty() )
|
||||
{
|
||||
this.isLocked = !this.isLocked;
|
||||
player.sendMessage( ( this.isLocked ? PlayerMessages.isNowLocked : PlayerMessages.isNowUnlocked ).get() );
|
||||
this.getHost().markForSave();
|
||||
this.getHost().markForUpdate();
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -213,11 +234,6 @@ public abstract class AbstractPartMonitor extends AbstractPartDisplay implements
|
||||
}
|
||||
}
|
||||
|
||||
protected void extractItem( final EntityPlayer player )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void updateReportingValue( final IMEMonitor<IAEItemStack> itemInventory )
|
||||
{
|
||||
if( this.configuredItem != null )
|
||||
@@ -271,7 +287,7 @@ public abstract class AbstractPartMonitor extends AbstractPartDisplay implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEStack<?> getDisplayed()
|
||||
public IAEItemStack getDisplayed()
|
||||
{
|
||||
return this.configuredItem;
|
||||
}
|
||||
|
||||
@@ -199,7 +199,7 @@ public abstract class AbstractPartReporting extends AEBasePart implements IPartM
|
||||
{
|
||||
final TileEntity te = this.getTile();
|
||||
|
||||
if( !player.isSneaking() && Platform.isWrench( player, player.inventory.getCurrentItem(), te.getPos() ) )
|
||||
if( Platform.isWrench( player, player.inventory.getCurrentItem(), te.getPos() ) )
|
||||
{
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
|
||||
@@ -115,19 +115,12 @@ public abstract class AbstractPartTerminal extends AbstractPartDisplay implement
|
||||
{
|
||||
if( !super.onPartActivate( player, hand, pos ) )
|
||||
{
|
||||
if( !player.isSneaking() )
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
Platform.openGUI( player, this.getHost().getTile(), this.getSide(), this.getGui( player ) );
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public GuiBridge getGui( final EntityPlayer player )
|
||||
|
||||
@@ -28,6 +28,8 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.wrapper.PlayerMainInvWrapper;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.networking.energy.IEnergySource;
|
||||
@@ -72,7 +74,7 @@ public class PartConversionMonitor extends AbstractPartMonitor
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPartShiftActivate( final EntityPlayer player, final EnumHand hand, final Vec3d pos )
|
||||
public boolean onPartActivate( EntityPlayer player, EnumHand hand, Vec3d pos )
|
||||
{
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
@@ -89,62 +91,133 @@ public class PartConversionMonitor extends AbstractPartMonitor
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean ModeB = false;
|
||||
|
||||
ItemStack item = player.getHeldItem( hand );
|
||||
if( item.isEmpty() && this.getDisplayed() != null )
|
||||
final ItemStack eq = player.getHeldItem( hand );
|
||||
if( this.isLocked() )
|
||||
{
|
||||
ModeB = true;
|
||||
item = ( (IAEItemStack) this.getDisplayed() ).createItemStack();
|
||||
}
|
||||
|
||||
if( !item.isEmpty() )
|
||||
{
|
||||
try
|
||||
if( eq.isEmpty() )
|
||||
{
|
||||
if( !this.getProxy().isActive() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final IEnergySource energy = this.getProxy().getEnergy();
|
||||
final IMEMonitor<IAEItemStack> cell = this.getProxy().getStorage().getInventory(
|
||||
AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
|
||||
final IAEItemStack input = AEItemStack.fromItemStack( item );
|
||||
|
||||
if( ModeB )
|
||||
{
|
||||
for( int x = 0; x < player.inventory.getSizeInventory(); x++ )
|
||||
{
|
||||
final ItemStack targetStack = player.inventory.getStackInSlot( x );
|
||||
if( input.equals( targetStack ) )
|
||||
{
|
||||
final IAEItemStack insertItem = input.copy();
|
||||
insertItem.setStackSize( targetStack.getCount() );
|
||||
final IAEItemStack failedToInsert = Platform.poweredInsert( energy, cell, insertItem, new PlayerSource( player, this ) );
|
||||
player.inventory.setInventorySlotContents( x, failedToInsert == null ? ItemStack.EMPTY : failedToInsert.createItemStack() );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
final IAEItemStack failedToInsert = Platform.poweredInsert( energy, cell, input, new PlayerSource( player, this ) );
|
||||
player.inventory.setInventorySlotContents( player.inventory.currentItem,
|
||||
failedToInsert == null ? ItemStack.EMPTY : failedToInsert.createItemStack() );
|
||||
}
|
||||
this.insertItem( player, hand, true );
|
||||
}
|
||||
catch( final GridAccessException e )
|
||||
else if( Platform.isWrench( player, eq, this.getLocation().getPos() ) && ( this.getDisplayed() == null || !this.getDisplayed().equals( eq ) ) )
|
||||
{
|
||||
// :P
|
||||
// wrench it
|
||||
return super.onPartActivate( player, hand, pos );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.insertItem( player, hand, false );
|
||||
}
|
||||
}
|
||||
else if( this.getDisplayed() != null && this.getDisplayed().equals( eq ) )
|
||||
{
|
||||
this.insertItem( player, hand, false );
|
||||
}
|
||||
else
|
||||
{
|
||||
return super.onPartActivate( player, hand, pos );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void extractItem( final EntityPlayer player )
|
||||
public boolean onClicked( EntityPlayer player, EnumHand hand, Vec3d pos )
|
||||
{
|
||||
final IAEItemStack input = (IAEItemStack) this.getDisplayed();
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if( !this.getProxy().isActive() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if( !Platform.hasPermissions( this.getLocation(), player ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if( this.getDisplayed() != null )
|
||||
{
|
||||
this.extractItem( player, this.getDisplayed().getDefinition().getMaxStackSize() );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onShiftClicked( EntityPlayer player, EnumHand hand, Vec3d pos )
|
||||
{
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if( !this.getProxy().isActive() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if( !Platform.hasPermissions( this.getLocation(), player ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if( this.getDisplayed() != null )
|
||||
{
|
||||
this.extractItem( player, 1 );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void insertItem( final EntityPlayer player, final EnumHand hand, final boolean allItems )
|
||||
{
|
||||
try
|
||||
{
|
||||
final IEnergySource energy = this.getProxy().getEnergy();
|
||||
final IMEMonitor<IAEItemStack> cell = this.getProxy()
|
||||
.getStorage()
|
||||
.getInventory(
|
||||
AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
|
||||
if( allItems )
|
||||
{
|
||||
final IAEItemStack input = this.getDisplayed().copy();
|
||||
IItemHandler inv = new PlayerMainInvWrapper( player.inventory );
|
||||
|
||||
for( int x = 0; x < inv.getSlots(); x++ )
|
||||
{
|
||||
final ItemStack targetStack = inv.getStackInSlot( x );
|
||||
if( input.equals( targetStack ) )
|
||||
{
|
||||
final ItemStack canExtract = inv.extractItem( x, targetStack.getCount(), true );
|
||||
if( !canExtract.isEmpty() )
|
||||
{
|
||||
input.setStackSize( canExtract.getCount() );
|
||||
final IAEItemStack failedToInsert = Platform.poweredInsert( energy, cell, input, new PlayerSource( player, this ) );
|
||||
inv.extractItem( x, failedToInsert == null ? canExtract.getCount() : canExtract.getCount() - (int) failedToInsert.getStackSize(),
|
||||
false );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
final IAEItemStack input = AEItemStack.fromItemStack( player.getHeldItem( hand ) );
|
||||
final IAEItemStack failedToInsert = Platform.poweredInsert( energy, cell, input, new PlayerSource( player, this ) );
|
||||
player.setHeldItem( hand, failedToInsert == null ? ItemStack.EMPTY : failedToInsert.createItemStack() );
|
||||
}
|
||||
}
|
||||
catch( final GridAccessException e )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
}
|
||||
|
||||
private void extractItem( final EntityPlayer player, int count )
|
||||
{
|
||||
final IAEItemStack input = this.getDisplayed();
|
||||
if( input != null )
|
||||
{
|
||||
try
|
||||
@@ -155,11 +228,12 @@ public class PartConversionMonitor extends AbstractPartMonitor
|
||||
}
|
||||
|
||||
final IEnergySource energy = this.getProxy().getEnergy();
|
||||
final IMEMonitor<IAEItemStack> cell = this.getProxy().getStorage().getInventory(
|
||||
AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
|
||||
final IMEMonitor<IAEItemStack> cell = this.getProxy()
|
||||
.getStorage()
|
||||
.getInventory(
|
||||
AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
|
||||
|
||||
final ItemStack is = input.createItemStack();
|
||||
input.setStackSize( is.getMaxStackSize() );
|
||||
input.setStackSize( count );
|
||||
|
||||
final IAEItemStack retrieved = Platform.poweredExtraction( energy, cell, input, new PlayerSource( player, this ) );
|
||||
if( retrieved != null )
|
||||
|
||||
@@ -55,20 +55,12 @@ public class PartInterfaceTerminal extends AbstractPartDisplay
|
||||
{
|
||||
if( !super.onPartActivate( player, hand, pos ) )
|
||||
{
|
||||
if( !player.isSneaking() )
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
Platform.openGUI( player, this.getHost().getTile(), this.getSide(), GuiBridge.GUI_INTERFACE_TERMINAL );
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user