Network tool can now lock Storage/Conversion Monitors.

Buckets no longer place when trying to insert them into a network via Conversion Monitor.
This commit is contained in:
AlgorithmX2 2014-05-03 02:51:56 -05:00
parent bba2f3ba25
commit b9ef599e13
3 changed files with 51 additions and 1 deletions

View file

@ -8,12 +8,16 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.implementations.guiobjects.IGuiItem;
import appeng.api.implementations.guiobjects.IGuiItemObject;
import appeng.api.implementations.items.IAEWrench;
import appeng.api.networking.IGridHost;
import appeng.api.parts.IPartHost;
import appeng.api.parts.SelectedPart;
import appeng.api.util.INetworkToolAgent;
import appeng.client.ClientHelper;
import appeng.container.AEBaseContainer;
import appeng.core.AELog;
@ -72,6 +76,22 @@ public class ToolNetworkTool extends AEBaseItem implements IGuiItem, IAEWrench,
@Override
public boolean onItemUseFirst(ItemStack is, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ)
{
MovingObjectPosition mop = new MovingObjectPosition( x, y, z, side, Vec3.createVectorHelper( hitX, hitY, hitZ ) );
TileEntity te = world.getTileEntity( x, y, z );
if ( te instanceof IPartHost )
{
SelectedPart part = ((IPartHost) te).selectPart( mop.hitVec );
if ( part.part != null )
{
if ( part.part instanceof INetworkToolAgent && !((INetworkToolAgent) part.part).showNetworkInfo( mop ) )
return false;
}
}
else if ( te instanceof INetworkToolAgent && !((INetworkToolAgent) te).showNetworkInfo( mop ) )
{
return false;
}
if ( Platform.isClient() )
{
try
@ -110,10 +130,12 @@ public class ToolNetworkTool extends AEBaseItem implements IGuiItem, IAEWrench,
return true;
TileEntity te = w.getTileEntity( x, y, z );
if ( te instanceof IGridHost )
Platform.openGUI( p, te, ForgeDirection.getOrientation( side ), GuiBridge.GUI_NETWORK_STATUS );
else
Platform.openGUI( p, null, ForgeDirection.UNKNOWN, GuiBridge.GUI_NETWORK_TOOL );
return true;
}
else

View file

@ -6,11 +6,13 @@ import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.block.Block.SoundType;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.ForgeDirection;
@ -42,7 +44,26 @@ public class PartPlacement
@SubscribeEvent
public void playerInteract(PlayerInteractEvent event)
{
if ( event.action == Action.RIGHT_CLICK_BLOCK && event.entityPlayer.worldObj.isRemote )
if ( event.action == Action.RIGHT_CLICK_AIR && event.entityPlayer.worldObj.isRemote )
{
// re-check to see if this event was already channeled, cause these two events are really stupid...
MovingObjectPosition mop = Platform.rayTrace( event.entityPlayer, true, false );
Minecraft mc = Minecraft.getMinecraft();
float f = 1.0F;
double d0 = (double) mc.playerController.getBlockReachDistance();
double d1 = d0;
Vec3 vec3 = mc.renderViewEntity.getPosition( f );
if ( mop != null && mop.hitVec.distanceTo( vec3 ) < d0 )
{
World w = event.entity.worldObj;
TileEntity te = w.getTileEntity( mop.blockX, mop.blockY, mop.blockZ );
if ( te instanceof IPartHost )
event.setCanceled( true );
}
}
else if ( event.action == Action.RIGHT_CLICK_BLOCK && event.entityPlayer.worldObj.isRemote )
{
if ( placing.get() != null )
return;

View file

@ -15,6 +15,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraftforge.common.util.ForgeDirection;
@ -382,4 +383,10 @@ public class PartStorageMonitor extends PartMonitor implements IPartStorageMonit
}
}
@Override
public boolean showNetworkInfo(MovingObjectPosition where)
{
return false;
}
}