Change storage/conversion monitor interaction. (#3613)

Fixes #1480
This commit is contained in:
fscan
2018-07-14 16:40:20 +02:00
committed by GitHub
parent 3363acb7db
commit 71a9bb2532
24 changed files with 343 additions and 208 deletions
@@ -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 );
}
}
}
}