Clean packet registration, misc compile things
This commit is contained in:
@@ -130,7 +130,7 @@ public class BlockCraftingUnit extends AEBaseTileBlock
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReplaced(BlockState state, World w, BlockPos pos, BlockState newState, boolean isMoving) {
|
||||
public void onReplaced(BlockState state, World w, BlockPos pos, BlockState newState, boolean isMoving)
|
||||
{
|
||||
final TileCraftingTile cp = this.getTileEntity( w, pos );
|
||||
if( cp != null )
|
||||
|
||||
@@ -35,6 +35,7 @@ import com.google.common.base.Joiner;
|
||||
import com.google.common.base.Stopwatch;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import net.minecraft.client.gui.screen.inventory.ContainerScreen;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.client.renderer.texture.AtlasTexture;
|
||||
import net.minecraft.inventory.container.ClickType;
|
||||
@@ -93,7 +94,7 @@ import appeng.fluids.container.slots.IMEFluidSlot;
|
||||
import appeng.helpers.InventoryAction;
|
||||
|
||||
|
||||
public abstract class AEBaseGui extends GuiContainer
|
||||
public abstract class AEBaseGui extends ContainerScreen<AEBaseContainer>
|
||||
{
|
||||
private final List<InternalSlotME> meSlots = new ArrayList<>();
|
||||
// drag y
|
||||
|
||||
@@ -19,12 +19,13 @@
|
||||
package appeng.core.sync;
|
||||
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.jodah.typetools.TypeResolver;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
|
||||
import appeng.core.sync.packets.PacketAssemblerAnimation;
|
||||
import appeng.core.sync.packets.PacketClick;
|
||||
@@ -57,84 +58,73 @@ public class AppEngPacketHandlerBase
|
||||
{
|
||||
private static final Map<Class<? extends AppEngPacket>, PacketTypes> REVERSE_LOOKUP = new HashMap<>();
|
||||
|
||||
|
||||
public enum PacketTypes
|
||||
{
|
||||
PACKET_COMPASS_REQUEST( PacketCompassRequest.class ),
|
||||
PACKET_COMPASS_REQUEST( PacketCompassRequest::new ),
|
||||
|
||||
PACKET_COMPASS_RESPONSE( PacketCompassResponse.class ),
|
||||
PACKET_COMPASS_RESPONSE( PacketCompassResponse::new ),
|
||||
|
||||
PACKET_INVENTORY_ACTION( PacketInventoryAction.class ),
|
||||
PACKET_INVENTORY_ACTION( PacketInventoryAction::new ),
|
||||
|
||||
PACKET_ME_INVENTORY_UPDATE( PacketMEInventoryUpdate.class ),
|
||||
PACKET_ME_INVENTORY_UPDATE( PacketMEInventoryUpdate::new ),
|
||||
|
||||
PACKET_ME_FLUID_INVENTORY_UPDATE( PacketMEFluidInventoryUpdate.class ),
|
||||
PACKET_ME_FLUID_INVENTORY_UPDATE( PacketMEFluidInventoryUpdate::new ),
|
||||
|
||||
PACKET_CONFIG_BUTTON( PacketConfigButton.class ),
|
||||
PACKET_CONFIG_BUTTON( PacketConfigButton::new ),
|
||||
|
||||
PACKET_PART_PLACEMENT( PacketPartPlacement.class ),
|
||||
PACKET_PART_PLACEMENT( PacketPartPlacement::new ),
|
||||
|
||||
PACKET_LIGHTNING( PacketLightning.class ),
|
||||
PACKET_LIGHTNING( PacketLightning::new ),
|
||||
|
||||
PACKET_MATTER_CANNON( PacketMatterCannon.class ),
|
||||
PACKET_MATTER_CANNON( PacketMatterCannon::new ),
|
||||
|
||||
PACKET_MOCK_EXPLOSION( PacketMockExplosion.class ),
|
||||
PACKET_MOCK_EXPLOSION( PacketMockExplosion::new ),
|
||||
|
||||
PACKET_VALUE_CONFIG( PacketValueConfig.class ),
|
||||
PACKET_VALUE_CONFIG( PacketValueConfig::new ),
|
||||
|
||||
PACKET_TRANSITION_EFFECT( PacketTransitionEffect.class ),
|
||||
PACKET_TRANSITION_EFFECT( PacketTransitionEffect::new ),
|
||||
|
||||
PACKET_PROGRESS_VALUE( PacketProgressBar.class ),
|
||||
PACKET_PROGRESS_VALUE( PacketProgressBar::new ),
|
||||
|
||||
PACKET_CLICK( PacketClick.class ),
|
||||
PACKET_CLICK( PacketClick::new ),
|
||||
|
||||
PACKET_SWITCH_GUIS( PacketSwitchGuis.class ),
|
||||
PACKET_SWITCH_GUIS( PacketSwitchGuis::new ),
|
||||
|
||||
PACKET_SWAP_SLOTS( PacketSwapSlots.class ),
|
||||
PACKET_SWAP_SLOTS( PacketSwapSlots::new ),
|
||||
|
||||
PACKET_PATTERN_SLOT( PacketPatternSlot.class ),
|
||||
PACKET_PATTERN_SLOT( PacketPatternSlot::new ),
|
||||
|
||||
PACKET_RECIPE_JEI( PacketJEIRecipe.class ),
|
||||
PACKET_RECIPE_JEI( PacketJEIRecipe::new ),
|
||||
|
||||
PACKET_TARGET_ITEM( PacketTargetItemStack.class ),
|
||||
PACKET_TARGET_ITEM( PacketTargetItemStack::new ),
|
||||
|
||||
PACKET_TARGET_FLUID( PacketTargetFluidStack.class ),
|
||||
PACKET_TARGET_FLUID( PacketTargetFluidStack::new ),
|
||||
|
||||
PACKET_CRAFTING_REQUEST( PacketCraftRequest.class ),
|
||||
PACKET_CRAFTING_REQUEST( PacketCraftRequest::new ),
|
||||
|
||||
PACKET_ASSEMBLER_ANIMATION( PacketAssemblerAnimation.class ),
|
||||
PACKET_ASSEMBLER_ANIMATION( PacketAssemblerAnimation::new ),
|
||||
|
||||
PACKET_COMPRESSED_NBT( PacketCompressedNBT.class ),
|
||||
PACKET_COMPRESSED_NBT( PacketCompressedNBT::new ),
|
||||
|
||||
PACKET_PAINTED_ENTITY( PacketPaintedEntity.class ),
|
||||
PACKET_PAINTED_ENTITY( PacketPaintedEntity::new ),
|
||||
|
||||
PACKET_FLUID_TANK( PacketFluidSlot.class );
|
||||
PACKET_FLUID_TANK( PacketFluidSlot::new );
|
||||
|
||||
private final Class<? extends AppEngPacket> packetClass;
|
||||
private final Constructor<? extends AppEngPacket> packetConstructor;
|
||||
private final Function<PacketBuffer, AppEngPacket> factory;
|
||||
|
||||
PacketTypes( final Class<? extends AppEngPacket> c )
|
||||
PacketTypes( Function<PacketBuffer, AppEngPacket> factory )
|
||||
{
|
||||
this.packetClass = c;
|
||||
Type c = TypeResolver.resolveGenericType( Function.class, factory.getClass() );
|
||||
if( c == TypeResolver.Unknown.class )
|
||||
{
|
||||
throw new IllegalStateException("Failed to resolve type for AE packet type: " + factory.toString());
|
||||
}
|
||||
this.packetClass = (Class<? extends AppEngPacket>) c;
|
||||
this.factory = factory;
|
||||
|
||||
Constructor<? extends AppEngPacket> x = null;
|
||||
try
|
||||
{
|
||||
x = this.packetClass.getConstructor( ByteBuf.class );
|
||||
}
|
||||
catch( final NoSuchMethodException ignored )
|
||||
{
|
||||
}
|
||||
catch( final SecurityException ignored )
|
||||
{
|
||||
}
|
||||
|
||||
this.packetConstructor = x;
|
||||
REVERSE_LOOKUP.put( this.packetClass, this );
|
||||
|
||||
if( this.packetConstructor == null )
|
||||
{
|
||||
throw new IllegalStateException( "Invalid Packet Class " + c + ", must be constructable on DataInputStream" );
|
||||
}
|
||||
}
|
||||
|
||||
public static PacketTypes getPacket( final int id )
|
||||
@@ -147,9 +137,9 @@ public class AppEngPacketHandlerBase
|
||||
return REVERSE_LOOKUP.get( c );
|
||||
}
|
||||
|
||||
public AppEngPacket parsePacket( final ByteBuf in ) throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException
|
||||
public AppEngPacket parsePacket( final PacketBuffer in ) throws IllegalArgumentException
|
||||
{
|
||||
return this.packetConstructor.newInstance( in );
|
||||
return this.factory.apply( in );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
@@ -46,8 +47,7 @@ public class PacketAssemblerAnimation extends AppEngPacket
|
||||
public final byte rate;
|
||||
public final IAEItemStack is;
|
||||
|
||||
// automatic.
|
||||
public PacketAssemblerAnimation( final ByteBuf stream ) throws IOException
|
||||
public PacketAssemblerAnimation( final ByteBuf stream )
|
||||
{
|
||||
this.x = stream.readInt();
|
||||
this.y = stream.readInt();
|
||||
@@ -60,7 +60,7 @@ public class PacketAssemblerAnimation extends AppEngPacket
|
||||
public PacketAssemblerAnimation( final BlockPos pos, final byte rate, final IAEItemStack is ) throws IOException
|
||||
{
|
||||
|
||||
final ByteBuf data = Unpooled.buffer();
|
||||
final PacketBuffer data = new PacketBuffer( Unpooled.buffer() );
|
||||
|
||||
data.writeInt( this.getPacketID() );
|
||||
data.writeInt( this.x = pos.getX() );
|
||||
|
||||
@@ -25,6 +25,7 @@ import io.netty.buffer.Unpooled;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@@ -55,8 +56,7 @@ public class PacketClick extends AppEngPacket
|
||||
private Hand hand;
|
||||
private final boolean leftClick;
|
||||
|
||||
// automatic.
|
||||
public PacketClick( final ByteBuf stream )
|
||||
public PacketClick( final PacketBuffer stream )
|
||||
{
|
||||
this.x = stream.readInt();
|
||||
this.y = stream.readInt();
|
||||
|
||||
@@ -23,7 +23,8 @@ import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerEntityMP;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
@@ -43,8 +44,7 @@ public class PacketCompassRequest extends AppEngPacket implements ICompassCallba
|
||||
|
||||
private PlayerEntity talkBackTo;
|
||||
|
||||
// automatic.
|
||||
public PacketCompassRequest( final ByteBuf stream )
|
||||
public PacketCompassRequest( final PacketBuffer stream )
|
||||
{
|
||||
this.attunement = stream.readLong();
|
||||
this.cx = stream.readInt();
|
||||
@@ -70,7 +70,7 @@ public class PacketCompassRequest extends AppEngPacket implements ICompassCallba
|
||||
@Override
|
||||
public void calculatedDirection( final boolean hasResult, final boolean spin, final double radians, final double dist )
|
||||
{
|
||||
NetworkHandler.instance().sendTo( new PacketCompassResponse( this, hasResult, spin, radians ), (PlayerEntityMP) this.talkBackTo );
|
||||
NetworkHandler.instance().sendTo( new PacketCompassResponse( this, hasResult, spin, radians ), (ServerPlayerEntity) this.talkBackTo );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -23,6 +23,7 @@ import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
@@ -40,8 +41,7 @@ public class PacketCompassResponse extends AppEngPacket
|
||||
|
||||
private CompassResult cr;
|
||||
|
||||
// automatic.
|
||||
public PacketCompassResponse( final ByteBuf stream )
|
||||
public PacketCompassResponse( final PacketBuffer stream )
|
||||
{
|
||||
this.attunement = stream.readLong();
|
||||
this.cx = stream.readInt();
|
||||
|
||||
@@ -31,10 +31,11 @@ import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.nbt.CompressedStreamTools;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.CompressedStreamTools;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@@ -43,6 +44,7 @@ import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
|
||||
|
||||
//TODO, this is pointless, NBT is already compressed when written to a PacketBuffer.
|
||||
public class PacketCompressedNBT extends AppEngPacket
|
||||
{
|
||||
|
||||
@@ -52,13 +54,12 @@ public class PacketCompressedNBT extends AppEngPacket
|
||||
private final ByteBuf data;
|
||||
private final GZIPOutputStream compressFrame;
|
||||
|
||||
// automatic.
|
||||
public PacketCompressedNBT( final ByteBuf stream ) throws IOException
|
||||
public PacketCompressedNBT( final PacketBuffer stream )
|
||||
{
|
||||
this.data = null;
|
||||
this.compressFrame = null;
|
||||
|
||||
final GZIPInputStream gzReader = new GZIPInputStream( new InputStream()
|
||||
try( DataInputStream inStream = new DataInputStream( new GZIPInputStream( new InputStream()
|
||||
{
|
||||
|
||||
@Override
|
||||
@@ -71,11 +72,14 @@ public class PacketCompressedNBT extends AppEngPacket
|
||||
|
||||
return stream.readByte() & 0xff;
|
||||
}
|
||||
} );
|
||||
|
||||
final DataInputStream inStream = new DataInputStream( gzReader );
|
||||
this.in = CompressedStreamTools.read( inStream );
|
||||
inStream.close();
|
||||
} ) ) )
|
||||
{
|
||||
this.in = CompressedStreamTools.read( inStream );
|
||||
}
|
||||
catch( IOException e )
|
||||
{
|
||||
throw new RuntimeException( "Failed to decompress packet.", e );
|
||||
}
|
||||
}
|
||||
|
||||
// api
|
||||
@@ -107,7 +111,7 @@ public class PacketCompressedNBT extends AppEngPacket
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
public void clientPacketData( final INetworkInfo network, final PlayerEntity player )
|
||||
{
|
||||
final GuiScreen gs = Minecraft.getInstance().currentScreen;
|
||||
final Screen gs = Minecraft.getInstance().currentScreen;
|
||||
|
||||
if( gs instanceof GuiInterfaceTerminal )
|
||||
{
|
||||
|
||||
@@ -23,7 +23,8 @@ import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerEntityMP;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.util.IConfigManager;
|
||||
@@ -31,7 +32,6 @@ import appeng.api.util.IConfigurableObject;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.helpers.Reflected;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
@@ -40,9 +40,7 @@ public final class PacketConfigButton extends AppEngPacket
|
||||
private final Settings option;
|
||||
private final boolean rotationDirection;
|
||||
|
||||
// automatic.
|
||||
@Reflected
|
||||
public PacketConfigButton( final ByteBuf stream )
|
||||
public PacketConfigButton( final PacketBuffer stream )
|
||||
{
|
||||
this.option = Settings.values()[stream.readInt()];
|
||||
this.rotationDirection = stream.readBoolean();
|
||||
@@ -66,7 +64,7 @@ public final class PacketConfigButton extends AppEngPacket
|
||||
@Override
|
||||
public void serverPacketData( final INetworkInfo manager, final PlayerEntity player )
|
||||
{
|
||||
final PlayerEntityMP sender = (PlayerEntityMP) player;
|
||||
final ServerPlayerEntity sender = (ServerPlayerEntity) player;
|
||||
if( sender.openContainer instanceof AEBaseContainer )
|
||||
{
|
||||
final AEBaseContainer baseContainer = (AEBaseContainer) sender.openContainer;
|
||||
|
||||
@@ -25,6 +25,7 @@ import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import appeng.api.networking.IGrid;
|
||||
@@ -48,8 +49,7 @@ public class PacketCraftRequest extends AppEngPacket
|
||||
private final long amount;
|
||||
private final boolean heldShift;
|
||||
|
||||
// automatic.
|
||||
public PacketCraftRequest( final ByteBuf stream )
|
||||
public PacketCraftRequest( final PacketBuffer stream )
|
||||
{
|
||||
this.heldShift = stream.readBoolean();
|
||||
this.amount = stream.readLong();
|
||||
|
||||
@@ -28,6 +28,7 @@ import io.netty.buffer.Unpooled;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraftforge.fml.common.network.ByteBufUtils;
|
||||
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
@@ -41,7 +42,7 @@ public class PacketFluidSlot extends AppEngPacket
|
||||
{
|
||||
private final Map<Integer, IAEFluidStack> list;
|
||||
|
||||
public PacketFluidSlot( final ByteBuf stream )
|
||||
public PacketFluidSlot( final PacketBuffer stream )
|
||||
{
|
||||
this.list = new HashMap<>();
|
||||
CompoundNBT tag = ByteBufUtils.readTag( stream );
|
||||
|
||||
@@ -27,6 +27,7 @@ import io.netty.buffer.Unpooled;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerEntityMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
@@ -50,8 +51,7 @@ public class PacketInventoryAction extends AppEngPacket
|
||||
private final long id;
|
||||
private final IAEItemStack slotItem;
|
||||
|
||||
// automatic.
|
||||
public PacketInventoryAction( final ByteBuf stream ) throws IOException
|
||||
public PacketInventoryAction( final PacketBuffer stream )
|
||||
{
|
||||
this.action = InventoryAction.values()[stream.readInt()];
|
||||
this.slot = stream.readInt();
|
||||
|
||||
@@ -34,6 +34,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompressedStreamTools;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import appeng.api.config.Actionable;
|
||||
@@ -64,12 +65,9 @@ public class PacketJEIRecipe extends AppEngPacket
|
||||
|
||||
private ItemStack[][] recipe;
|
||||
|
||||
// automatic.
|
||||
public PacketJEIRecipe( final ByteBuf stream ) throws IOException
|
||||
public PacketJEIRecipe( final PacketBuffer stream )
|
||||
{
|
||||
final ByteArrayInputStream bytes = this.getPacketByteArray( stream );
|
||||
bytes.skip( stream.readerIndex() );
|
||||
final CompoundNBT comp = CompressedStreamTools.readCompressed( bytes );
|
||||
final CompoundNBT comp = stream.readCompoundTag();
|
||||
if( comp != null )
|
||||
{
|
||||
this.recipe = new ItemStack[9][];
|
||||
@@ -91,15 +89,11 @@ public class PacketJEIRecipe extends AppEngPacket
|
||||
// api
|
||||
public PacketJEIRecipe( final CompoundNBT recipe ) throws IOException
|
||||
{
|
||||
final ByteBuf data = Unpooled.buffer();
|
||||
|
||||
final ByteArrayOutputStream bytes = new ByteArrayOutputStream();
|
||||
final DataOutputStream outputStream = new DataOutputStream( bytes );
|
||||
final PacketBuffer data = new PacketBuffer(Unpooled.buffer());
|
||||
|
||||
data.writeInt( this.getPacketID() );
|
||||
|
||||
CompressedStreamTools.writeCompressed( recipe, outputStream );
|
||||
data.writeBytes( bytes.toByteArray() );
|
||||
data.writeCompoundTag( recipe );
|
||||
|
||||
this.configureWrite( data );
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@@ -42,8 +43,7 @@ public class PacketLightning extends AppEngPacket
|
||||
private final double y;
|
||||
private final double z;
|
||||
|
||||
// automatic.
|
||||
public PacketLightning( final ByteBuf stream )
|
||||
public PacketLightning( final PacketBuffer stream )
|
||||
{
|
||||
this.x = stream.readFloat();
|
||||
this.y = stream.readFloat();
|
||||
|
||||
@@ -27,18 +27,16 @@ import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.network.IPacket;
|
||||
import net.minecraftforge.fml.common.network.internal.FMLProxyPacket;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.fml.network.NetworkDirection;
|
||||
@@ -77,8 +75,7 @@ public class PacketMEFluidInventoryUpdate extends AppEngPacket
|
||||
private int writtenBytes = 0;
|
||||
private boolean empty = true;
|
||||
|
||||
// automatic.
|
||||
public PacketMEFluidInventoryUpdate( final ByteBuf stream ) throws IOException
|
||||
public PacketMEFluidInventoryUpdate( final PacketBuffer stream )
|
||||
{
|
||||
this.data = null;
|
||||
this.compressFrame = null;
|
||||
@@ -120,6 +117,10 @@ public class PacketMEFluidInventoryUpdate extends AppEngPacket
|
||||
this.list.add( AEFluidStack.fromPacket( uncompressed ) );
|
||||
}
|
||||
}
|
||||
catch( IOException e )
|
||||
{
|
||||
throw new RuntimeException( "Failed to decompress packet.", e );
|
||||
}
|
||||
|
||||
this.empty = this.list.isEmpty();
|
||||
}
|
||||
@@ -183,7 +184,7 @@ public class PacketMEFluidInventoryUpdate extends AppEngPacket
|
||||
|
||||
public void appendFluid( final IAEFluidStack fs ) throws IOException, BufferOverflowException
|
||||
{
|
||||
final ByteBuf tmp = Unpooled.buffer( OPERATION_BYTE_LIMIT );
|
||||
final PacketBuffer tmp = new PacketBuffer( Unpooled.buffer( OPERATION_BYTE_LIMIT ) );
|
||||
fs.writeToPacket( tmp );
|
||||
|
||||
this.compressFrame.flush();
|
||||
|
||||
@@ -27,7 +27,6 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
@@ -37,7 +36,7 @@ import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.network.IPacket;
|
||||
import net.minecraftforge.fml.common.network.internal.FMLProxyPacket;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.fml.network.NetworkDirection;
|
||||
@@ -74,8 +73,7 @@ public class PacketMEInventoryUpdate extends AppEngPacket
|
||||
private int writtenBytes = 0;
|
||||
private boolean empty = true;
|
||||
|
||||
// automatic.
|
||||
public PacketMEInventoryUpdate( final ByteBuf stream ) throws IOException
|
||||
public PacketMEInventoryUpdate( final PacketBuffer stream )
|
||||
{
|
||||
this.data = null;
|
||||
this.compressFrame = null;
|
||||
@@ -116,9 +114,12 @@ public class PacketMEInventoryUpdate extends AppEngPacket
|
||||
this.list.add( AEItemStack.fromPacket( uncompressed ) );
|
||||
}
|
||||
}
|
||||
catch( IOException e )
|
||||
{
|
||||
throw new RuntimeException( "Failed to decompress packet.", e );
|
||||
}
|
||||
|
||||
this.empty = this.list.isEmpty();
|
||||
|
||||
}
|
||||
|
||||
// api
|
||||
|
||||
@@ -25,6 +25,7 @@ import io.netty.buffer.Unpooled;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.client.FMLClientHandler;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
@@ -46,8 +47,7 @@ public class PacketMatterCannon extends AppEngPacket
|
||||
private final double dz;
|
||||
private final byte len;
|
||||
|
||||
// automatic.
|
||||
public PacketMatterCannon( final ByteBuf stream )
|
||||
public PacketMatterCannon( final PacketBuffer stream )
|
||||
{
|
||||
this.x = stream.readFloat();
|
||||
this.y = stream.readFloat();
|
||||
|
||||
@@ -23,6 +23,7 @@ import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.EnumParticleTypes;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
@@ -40,8 +41,7 @@ public class PacketMockExplosion extends AppEngPacket
|
||||
private final double y;
|
||||
private final double z;
|
||||
|
||||
// automatic.
|
||||
public PacketMockExplosion( final ByteBuf stream )
|
||||
public PacketMockExplosion( final PacketBuffer stream )
|
||||
{
|
||||
this.x = stream.readDouble();
|
||||
this.y = stream.readDouble();
|
||||
|
||||
@@ -23,6 +23,7 @@ import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
@@ -38,8 +39,7 @@ public class PacketPaintedEntity extends AppEngPacket
|
||||
private final int entityId;
|
||||
private int ticks;
|
||||
|
||||
// automatic.
|
||||
public PacketPaintedEntity( final ByteBuf stream )
|
||||
public PacketPaintedEntity( final PacketBuffer stream )
|
||||
{
|
||||
this.entityId = stream.readInt();
|
||||
this.myColor = AEColor.values()[stream.readByte()];
|
||||
|
||||
@@ -24,6 +24,7 @@ import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerEntityMP;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@@ -44,8 +45,7 @@ public class PacketPartPlacement extends AppEngPacket
|
||||
private float eyeHeight;
|
||||
private Hand hand;
|
||||
|
||||
// automatic.
|
||||
public PacketPartPlacement( final ByteBuf stream )
|
||||
public PacketPartPlacement( final PacketBuffer stream )
|
||||
{
|
||||
this.x = stream.readInt();
|
||||
this.y = stream.readInt();
|
||||
|
||||
@@ -26,6 +26,7 @@ import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerEntityMP;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import appeng.api.storage.channels.IItemStorageChannel;
|
||||
@@ -45,8 +46,7 @@ public class PacketPatternSlot extends AppEngPacket
|
||||
|
||||
public final boolean shift;
|
||||
|
||||
// automatic.
|
||||
public PacketPatternSlot( final ByteBuf stream ) throws IOException
|
||||
public PacketPatternSlot( final PacketBuffer stream )
|
||||
{
|
||||
|
||||
this.shift = stream.readBoolean();
|
||||
@@ -59,7 +59,7 @@ public class PacketPatternSlot extends AppEngPacket
|
||||
}
|
||||
}
|
||||
|
||||
private IAEItemStack readItem( final ByteBuf stream ) throws IOException
|
||||
private IAEItemStack readItem( final ByteBuf stream )
|
||||
{
|
||||
final boolean hasItem = stream.readBoolean();
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
@@ -36,8 +37,7 @@ public class PacketProgressBar extends AppEngPacket
|
||||
private final short id;
|
||||
private final long value;
|
||||
|
||||
// automatic.
|
||||
public PacketProgressBar( final ByteBuf stream )
|
||||
public PacketProgressBar( final PacketBuffer stream )
|
||||
{
|
||||
this.id = stream.readShort();
|
||||
this.value = stream.readLong();
|
||||
|
||||
@@ -23,6 +23,7 @@ import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
@@ -35,8 +36,7 @@ public class PacketSwapSlots extends AppEngPacket
|
||||
private final int slotA;
|
||||
private final int slotB;
|
||||
|
||||
// automatic.
|
||||
public PacketSwapSlots( final ByteBuf stream )
|
||||
public PacketSwapSlots( final PacketBuffer stream )
|
||||
{
|
||||
this.slotA = stream.readInt();
|
||||
this.slotB = stream.readInt();
|
||||
|
||||
@@ -24,6 +24,7 @@ import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import appeng.container.AEBaseContainer;
|
||||
@@ -39,8 +40,7 @@ public class PacketSwitchGuis extends AppEngPacket
|
||||
|
||||
private final GuiBridge newGui;
|
||||
|
||||
// automatic.
|
||||
public PacketSwitchGuis( final ByteBuf stream )
|
||||
public PacketSwitchGuis( final PacketBuffer stream )
|
||||
{
|
||||
this.newGui = GuiBridge.values()[stream.readInt()];
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
@@ -40,8 +41,7 @@ public class PacketTargetFluidStack extends AppEngPacket
|
||||
{
|
||||
private AEFluidStack stack;
|
||||
|
||||
// automatic.
|
||||
public PacketTargetFluidStack( final ByteBuf stream )
|
||||
public PacketTargetFluidStack( final PacketBuffer stream )
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
@@ -23,6 +23,7 @@ import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.core.AELog;
|
||||
@@ -35,8 +36,7 @@ public class PacketTargetItemStack extends AppEngPacket
|
||||
{
|
||||
private AEItemStack stack;
|
||||
|
||||
// automatic.
|
||||
public PacketTargetItemStack( final ByteBuf stream )
|
||||
public PacketTargetItemStack( final PacketBuffer stream )
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
@@ -27,6 +27,7 @@ import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.audio.PositionedSoundRecord;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
@@ -50,8 +51,7 @@ public class PacketTransitionEffect extends AppEngPacket
|
||||
private final double z;
|
||||
private final AEPartLocation d;
|
||||
|
||||
// automatic.
|
||||
public PacketTransitionEffect( final ByteBuf stream )
|
||||
public PacketTransitionEffect( final PacketBuffer stream )
|
||||
{
|
||||
this.x = stream.readFloat();
|
||||
this.y = stream.readFloat();
|
||||
|
||||
@@ -19,12 +19,8 @@
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -32,6 +28,7 @@ import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.Hand;
|
||||
|
||||
import appeng.api.config.FuzzyMode;
|
||||
@@ -64,12 +61,10 @@ public class PacketValueConfig extends AppEngPacket
|
||||
private final String Name;
|
||||
private final String Value;
|
||||
|
||||
// automatic.
|
||||
public PacketValueConfig( final ByteBuf stream ) throws IOException
|
||||
public PacketValueConfig( final PacketBuffer stream )
|
||||
{
|
||||
final DataInputStream dis = new DataInputStream( this.getPacketByteArray( stream, stream.readerIndex(), stream.readableBytes() ) );
|
||||
this.Name = dis.readUTF();
|
||||
this.Value = dis.readUTF();
|
||||
this.Name = stream.readString();
|
||||
this.Value = stream.readString();
|
||||
// dis.close();
|
||||
}
|
||||
|
||||
@@ -79,17 +74,12 @@ public class PacketValueConfig extends AppEngPacket
|
||||
this.Name = name;
|
||||
this.Value = value;
|
||||
|
||||
final ByteBuf data = Unpooled.buffer();
|
||||
final PacketBuffer data = new PacketBuffer( Unpooled.buffer() );
|
||||
|
||||
data.writeInt( this.getPacketID() );
|
||||
|
||||
final ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
final DataOutputStream dos = new DataOutputStream( bos );
|
||||
dos.writeUTF( name );
|
||||
dos.writeUTF( value );
|
||||
// dos.close();
|
||||
|
||||
data.writeBytes( bos.toByteArray() );
|
||||
data.writeString( name );
|
||||
data.writeString( value );
|
||||
|
||||
this.configureWrite( data );
|
||||
}
|
||||
@@ -99,9 +89,7 @@ public class PacketValueConfig extends AppEngPacket
|
||||
{
|
||||
final Container c = player.openContainer;
|
||||
|
||||
if( this.Name.equals( "Item" ) && ( ( !player.getHeldItem( Hand.MAIN_HAND ).isEmpty() && player.getHeldItem( Hand.MAIN_HAND )
|
||||
.getItem() instanceof IMouseWheelItem ) || ( !player.getHeldItem( Hand.OFF_HAND )
|
||||
.isEmpty() && player.getHeldItem( Hand.OFF_HAND ).getItem() instanceof IMouseWheelItem ) ) )
|
||||
if( this.Name.equals( "Item" ) && ( ( !player.getHeldItem( Hand.MAIN_HAND ).isEmpty() && player.getHeldItem( Hand.MAIN_HAND ).getItem() instanceof IMouseWheelItem ) || ( !player.getHeldItem( Hand.OFF_HAND ).isEmpty() && player.getHeldItem( Hand.OFF_HAND ).getItem() instanceof IMouseWheelItem ) ) )
|
||||
{
|
||||
final Hand hand;
|
||||
if( !player.getHeldItem( Hand.MAIN_HAND ).isEmpty() && player.getHeldItem( Hand.MAIN_HAND ).getItem() instanceof IMouseWheelItem )
|
||||
|
||||
@@ -22,6 +22,7 @@ package appeng.entity;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.item.ItemEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
@@ -31,6 +32,11 @@ import net.minecraft.world.World;
|
||||
public abstract class AEBaseEntityItem extends ItemEntity
|
||||
{
|
||||
|
||||
public AEBaseEntityItem( final World world )
|
||||
{
|
||||
super( EntityType.ITEM, world );
|
||||
}
|
||||
|
||||
public AEBaseEntityItem( final World world, final double x, final double y, final double z, final ItemStack stack )
|
||||
{
|
||||
super( world, x, y, z, stack );
|
||||
|
||||
@@ -36,6 +36,7 @@ import appeng.api.AEApi;
|
||||
import appeng.api.definitions.IMaterials;
|
||||
import appeng.client.EffectType;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.Api;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.util.Platform;
|
||||
|
||||
@@ -33,6 +33,7 @@ import net.minecraft.world.World;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.definitions.IMaterials;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.Api;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.helpers.Reflected;
|
||||
import appeng.util.Platform;
|
||||
@@ -110,7 +111,7 @@ public final class EntitySingularity extends AEBaseEntityItem
|
||||
|
||||
materials.qESingularity().maybeStack( 2 ).ifPresent( singularityStack ->
|
||||
{
|
||||
final CompoundNBT cmp = Platform.openNbtData( singularityStack );
|
||||
final CompoundNBT cmp = singularityStack.getOrCreateTag();
|
||||
cmp.putLong( "freq", ( new Date() ).getTime() * 100 + ( randTickSeed ) % 100 );
|
||||
randTickSeed++;
|
||||
item.grow( -1 );
|
||||
|
||||
@@ -44,6 +44,7 @@ import net.minecraftforge.fml.common.registry.IEntityAdditionalSpawnData;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.Api;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.sync.packets.PacketMockExplosion;
|
||||
|
||||
@@ -33,6 +33,7 @@ import appeng.api.parts.IFacadeContainer;
|
||||
import appeng.api.parts.IFacadePart;
|
||||
import appeng.api.parts.IPartHost;
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.core.Api;
|
||||
import appeng.items.parts.ItemFacade;
|
||||
import appeng.parts.CableBusStorage;
|
||||
|
||||
@@ -130,7 +131,7 @@ public class FacadeContainer implements IFacadeContainer
|
||||
if( ( facadeSides & ix ) == ix )
|
||||
{
|
||||
ids[0] = out.readInt();
|
||||
ids[1] = out.readInt();
|
||||
//ids[1] = out.readInt();
|
||||
ids[0] = Math.abs( ids[0] );
|
||||
|
||||
Optional<Item> maybeFacadeItem = Api.INSTANCE.definitions().items().facade().maybeItem();
|
||||
@@ -197,9 +198,9 @@ public class FacadeContainer implements IFacadeContainer
|
||||
if( part != null )
|
||||
{
|
||||
final int itemID = Item.getIdFromItem( part.getItem() );
|
||||
final int dmgValue = part.getItemDamage();
|
||||
//final int dmgValue = part.getItemDamage();
|
||||
out.writeInt( itemID * ( part.notAEFacade() ? -1 : 1 ) );
|
||||
out.writeInt( dmgValue );
|
||||
//out.writeInt( dmgValue );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ import appeng.api.parts.IBoxProvider;
|
||||
import appeng.api.parts.IFacadePart;
|
||||
import appeng.api.parts.IPartCollisionHelper;
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.core.Api;
|
||||
|
||||
|
||||
public class FacadePart implements IFacadePart, IBoxProvider
|
||||
|
||||
@@ -29,6 +29,7 @@ import java.util.Optional;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import appeng.core.Api;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
@@ -42,6 +43,7 @@ import net.minecraft.nbt.ListNBT;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
@@ -1189,12 +1191,12 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
||||
Vec3d from = new Vec3d( hostTile.getPos().getX() + 0.5, hostTile.getPos().getY() + 0.5, hostTile.getPos().getZ() + 0.5 );
|
||||
from = from.add( direction.getXOffset() * 0.501, direction.getYOffset() * 0.501, direction.getZOffset() * 0.501 );
|
||||
final Vec3d to = from.add( direction.getXOffset(), direction.getYOffset(), direction.getZOffset() );
|
||||
final RayTraceResult mop = hostWorld.rayTraceBlocks( from, to );
|
||||
if( mop != null && !BAD_BLOCKS.contains( directedBlock ) )
|
||||
final BlockRayTraceResult hit = null;//hostWorld.rayTraceBlocks( from, to ); //FIXME: https://github.com/MinecraftForge/MinecraftForge/pull/6708
|
||||
if( hit != null && !BAD_BLOCKS.contains( directedBlock ) )
|
||||
{
|
||||
if( mop.getBlockPos().equals( directedTile.getPos() ) )
|
||||
if( hit.getPos().equals( directedTile.getPos() ) )
|
||||
{
|
||||
final ItemStack g = directedBlock.getPickBlock( directedBlockState, mop, hostWorld, directedTile.getPos(), null );
|
||||
final ItemStack g = directedBlock.getPickBlock( directedBlockState, hit, hostWorld, directedTile.getPos(), null );
|
||||
if( !g.isEmpty() )
|
||||
{
|
||||
what = g;
|
||||
|
||||
@@ -22,6 +22,7 @@ package appeng.helpers;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import appeng.core.Api;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
|
||||
@@ -27,6 +27,7 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.StringJoiner;
|
||||
|
||||
import appeng.core.Api;
|
||||
import net.minecraft.inventory.CraftingInventory;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -36,7 +37,6 @@ import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.ListNBT;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.networking.crafting.ICraftingPatternDetails;
|
||||
import appeng.api.storage.channels.IItemStorageChannel;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
|
||||
@@ -74,7 +74,7 @@ public class Splotch
|
||||
this.pos = data.readByte();
|
||||
final int val = data.readByte();
|
||||
|
||||
this.side = Direction.VALUES[val & 0x07];
|
||||
this.side = Direction.values()[val & 0x07];
|
||||
this.color = AEColor.values()[( val >> 3 ) & 0x0F];
|
||||
this.lumen = ( ( val >> 7 ) & 0x01 ) > 0;
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
package appeng.helpers;
|
||||
|
||||
|
||||
import appeng.core.Api;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@@ -39,6 +39,7 @@ import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.property.IExtendedBlockState;
|
||||
|
||||
@@ -47,6 +48,7 @@ import appeng.api.exceptions.MissingDefinitionException;
|
||||
import appeng.api.parts.IAlphaPassItem;
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.Api;
|
||||
import appeng.core.FacadeConfig;
|
||||
import appeng.facade.FacadePart;
|
||||
import appeng.facade.IFacadeItem;
|
||||
@@ -316,7 +318,7 @@ public class ItemFacade extends AEBaseItem implements IFacadeItem, IAlphaPassIte
|
||||
.orElseThrow( () -> new MissingDefinitionException( "Tried to create a facade, while facades are being deactivated." ) );
|
||||
|
||||
// Convert back to a registry name...
|
||||
Item item = Item.REGISTRY.getObjectById( ids[0] );
|
||||
Item item = Registry.ITEM.getByValue( ids[0] );
|
||||
if( item == null )
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
@@ -324,8 +326,8 @@ public class ItemFacade extends AEBaseItem implements IFacadeItem, IAlphaPassIte
|
||||
|
||||
final CompoundNBT facadeTag = new CompoundNBT();
|
||||
facadeTag.putString(TAG_ITEM_ID, item.getRegistryName().toString());
|
||||
facadeTag.setInteger( TAG_DAMAGE, ids[1] );
|
||||
facadeStack.setTagCompound( facadeTag );
|
||||
//facadeTag.setInteger( TAG_DAMAGE, ids[1] );
|
||||
facadeStack.setTag( facadeTag );
|
||||
|
||||
return facadeStack;
|
||||
}
|
||||
|
||||
@@ -19,12 +19,28 @@
|
||||
package appeng.util;
|
||||
|
||||
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.PowerMultiplier;
|
||||
import appeng.api.config.SearchBoxMode;
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.config.SortOrder;
|
||||
import appeng.api.definitions.IItemDefinition;
|
||||
import appeng.api.implementations.items.IAEWrench;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.energy.IEnergySource;
|
||||
import appeng.api.networking.security.IActionHost;
|
||||
import appeng.api.networking.security.IActionSource;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.core.Api;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.stats.Stats;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.me.helpers.AENetworkProxy;
|
||||
import appeng.util.helpers.ItemComparisonHelper;
|
||||
import appeng.util.item.AEItemStack;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
@@ -41,10 +57,13 @@ import net.minecraftforge.fml.common.thread.SidedThreadGroups;
|
||||
import net.minecraftforge.fml.loading.FMLEnvironment;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
|
||||
/**
|
||||
* @author AlgorithmX2
|
||||
@@ -179,101 +198,102 @@ public class Platform
|
||||
// return Direction.NORTH;
|
||||
// }
|
||||
//
|
||||
// public static <T extends Enum> T rotateEnum( T ce, final boolean backwards, final EnumSet validOptions )
|
||||
// {
|
||||
// do
|
||||
// {
|
||||
// if( backwards )
|
||||
// {
|
||||
// ce = prevEnum( ce );
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// ce = nextEnum( ce );
|
||||
// }
|
||||
// }
|
||||
// while( !validOptions.contains( ce ) || isNotValidSetting( ce ) );
|
||||
//
|
||||
// return ce;
|
||||
// }
|
||||
//
|
||||
// /*
|
||||
// * Simple way to cycle an enum...
|
||||
// */
|
||||
// private static <T extends Enum> T prevEnum( final T ce )
|
||||
// {
|
||||
// final EnumSet valList = EnumSet.allOf( ce.getClass() );
|
||||
//
|
||||
// int pLoc = ce.ordinal() - 1;
|
||||
// if( pLoc < 0 )
|
||||
// {
|
||||
// pLoc = valList.size() - 1;
|
||||
// }
|
||||
//
|
||||
// if( pLoc < 0 || pLoc >= valList.size() )
|
||||
// {
|
||||
// pLoc = 0;
|
||||
// }
|
||||
//
|
||||
// int pos = 0;
|
||||
// for( final Object g : valList )
|
||||
// {
|
||||
// if( pos == pLoc )
|
||||
// {
|
||||
// return (T) g;
|
||||
// }
|
||||
// pos++;
|
||||
// }
|
||||
//
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// /*
|
||||
// * Simple way to cycle an enum...
|
||||
// */
|
||||
// public static <T extends Enum> T nextEnum( final T ce )
|
||||
// {
|
||||
// final EnumSet valList = EnumSet.allOf( ce.getClass() );
|
||||
//
|
||||
// int pLoc = ce.ordinal() + 1;
|
||||
// if( pLoc >= valList.size() )
|
||||
// {
|
||||
// pLoc = 0;
|
||||
// }
|
||||
//
|
||||
// if( pLoc < 0 || pLoc >= valList.size() )
|
||||
// {
|
||||
// pLoc = 0;
|
||||
// }
|
||||
//
|
||||
// int pos = 0;
|
||||
// for( final Object g : valList )
|
||||
// {
|
||||
// if( pos == pLoc )
|
||||
// {
|
||||
// return (T) g;
|
||||
// }
|
||||
// pos++;
|
||||
// }
|
||||
//
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// private static boolean isNotValidSetting( final Enum e )
|
||||
// {
|
||||
public static <T extends Enum> T rotateEnum( T ce, final boolean backwards, final EnumSet validOptions )
|
||||
{
|
||||
do
|
||||
{
|
||||
if( backwards )
|
||||
{
|
||||
ce = prevEnum( ce );
|
||||
}
|
||||
else
|
||||
{
|
||||
ce = nextEnum( ce );
|
||||
}
|
||||
}
|
||||
while( !validOptions.contains( ce ) || isNotValidSetting( ce ) );
|
||||
|
||||
return ce;
|
||||
}
|
||||
|
||||
/*
|
||||
* Simple way to cycle an enum...
|
||||
*/
|
||||
private static <T extends Enum> T prevEnum( final T ce )
|
||||
{
|
||||
final EnumSet valList = EnumSet.allOf( ce.getClass() );
|
||||
|
||||
int pLoc = ce.ordinal() - 1;
|
||||
if( pLoc < 0 )
|
||||
{
|
||||
pLoc = valList.size() - 1;
|
||||
}
|
||||
|
||||
if( pLoc < 0 || pLoc >= valList.size() )
|
||||
{
|
||||
pLoc = 0;
|
||||
}
|
||||
|
||||
int pos = 0;
|
||||
for( final Object g : valList )
|
||||
{
|
||||
if( pos == pLoc )
|
||||
{
|
||||
return (T) g;
|
||||
}
|
||||
pos++;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* Simple way to cycle an enum...
|
||||
*/
|
||||
public static <T extends Enum<?>> T nextEnum( final T ce )
|
||||
{
|
||||
final EnumSet valList = EnumSet.allOf( ce.getClass() );
|
||||
|
||||
int pLoc = ce.ordinal() + 1;
|
||||
if( pLoc >= valList.size() )
|
||||
{
|
||||
pLoc = 0;
|
||||
}
|
||||
|
||||
if( pLoc < 0 || pLoc >= valList.size() )
|
||||
{
|
||||
pLoc = 0;
|
||||
}
|
||||
|
||||
int pos = 0;
|
||||
for( final Object g : valList )
|
||||
{
|
||||
if( pos == pLoc )
|
||||
{
|
||||
return (T) g;
|
||||
}
|
||||
pos++;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static boolean isNotValidSetting( final Enum<?> e )
|
||||
{
|
||||
//FIXME, INVENTORY TWEAKS
|
||||
// if( e == SortOrder.INVTWEAKS && !Integrations.invTweaks().isEnabled() )
|
||||
// {
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
//FIXME, JEI
|
||||
// final boolean isJEI = e == SearchBoxMode.JEI_AUTOSEARCH || e == SearchBoxMode.JEI_AUTOSEARCH_KEEP || e == SearchBoxMode.JEI_MANUAL_SEARCH || e == SearchBoxMode.JEI_MANUAL_SEARCH_KEEP;
|
||||
// if( isJEI && !Integrations.jei().isEnabled() )
|
||||
// {
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// return false;
|
||||
// }
|
||||
|
||||
return false;
|
||||
}
|
||||
//
|
||||
// public static void openGUI(@Nonnull final PlayerEntity p, @Nullable final TileEntity tile, @Nullable final AEPartLocation side, @Nonnull final GuiBridge type )
|
||||
// {
|
||||
@@ -518,45 +538,45 @@ public class Platform
|
||||
// return n == null ? "** Null" : n.getNamespace(); // FIXME: Check if namespace == mod
|
||||
// }
|
||||
//
|
||||
// public static String getItemDisplayName( final Object o )
|
||||
// {
|
||||
// if( o == null )
|
||||
// {
|
||||
// return "** Null";
|
||||
// }
|
||||
//
|
||||
// ItemStack itemStack = ItemStack.EMPTY;
|
||||
// if( o instanceof AEItemStack )
|
||||
// {
|
||||
// final String n = ( (AEItemStack) o ).getDisplayName();
|
||||
// return n == null ? "** Null" : n;
|
||||
// }
|
||||
// else if( o instanceof ItemStack )
|
||||
// {
|
||||
// itemStack = (ItemStack) o;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return "**Invalid Object";
|
||||
// }
|
||||
//
|
||||
// try
|
||||
// {
|
||||
// // FIXME: Double-check that this is TRULY translated
|
||||
// return itemStack.getDisplayName().getString();
|
||||
// }
|
||||
// catch( final Exception errA )
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// return itemStack.getTranslationKey();
|
||||
// }
|
||||
// catch( final Exception errB )
|
||||
// {
|
||||
// return "** Exception";
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
public static String getItemDisplayName( final Object o )
|
||||
{
|
||||
if( o == null )
|
||||
{
|
||||
return "** Null";
|
||||
}
|
||||
|
||||
ItemStack itemStack = ItemStack.EMPTY;
|
||||
if( o instanceof AEItemStack )
|
||||
{
|
||||
final String n = ( (AEItemStack) o ).getDisplayName();
|
||||
return n == null ? "** Null" : n;
|
||||
}
|
||||
else if( o instanceof ItemStack )
|
||||
{
|
||||
itemStack = (ItemStack) o;
|
||||
}
|
||||
else
|
||||
{
|
||||
return "**Invalid Object";
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
// FIXME: Double-check that this is TRULY translated
|
||||
return itemStack.getDisplayName().getString();
|
||||
}
|
||||
catch( final Exception errA )
|
||||
{
|
||||
try
|
||||
{
|
||||
return itemStack.getTranslationKey();
|
||||
}
|
||||
catch( final Exception errB )
|
||||
{
|
||||
return "** Exception";
|
||||
}
|
||||
}
|
||||
}
|
||||
//
|
||||
// public static String getFluidDisplayName( Object o )
|
||||
// {
|
||||
@@ -1025,120 +1045,120 @@ public class Platform
|
||||
// return pos;
|
||||
// }
|
||||
//
|
||||
// public static <T extends IAEStack<T>> T poweredExtraction( final IEnergySource energy, final IMEInventory<T> cell, final T request, final IActionSource src )
|
||||
// {
|
||||
// return poweredExtraction( energy, cell, request, src, Actionable.MODULATE );
|
||||
// }
|
||||
//
|
||||
// public static <T extends IAEStack<T>> T poweredExtraction( final IEnergySource energy, final IMEInventory<T> cell, final T request, final IActionSource src, final Actionable mode )
|
||||
// {
|
||||
// Preconditions.checkNotNull( energy );
|
||||
// Preconditions.checkNotNull( cell );
|
||||
// Preconditions.checkNotNull( request );
|
||||
// Preconditions.checkNotNull( src );
|
||||
// Preconditions.checkNotNull( mode );
|
||||
//
|
||||
// final T possible = cell.extractItems( request.copy(), Actionable.SIMULATE, src );
|
||||
//
|
||||
// long retrieved = 0;
|
||||
// if( possible != null )
|
||||
// {
|
||||
// retrieved = possible.getStackSize();
|
||||
// }
|
||||
//
|
||||
// final double energyFactor = Math.max( 1.0, cell.getChannel().transferFactor() );
|
||||
// final double availablePower = energy.extractAEPower( retrieved / energyFactor, Actionable.SIMULATE, PowerMultiplier.CONFIG );
|
||||
// final long itemToExtract = Math.min( (long) ( ( availablePower * energyFactor ) + 0.9 ), retrieved );
|
||||
//
|
||||
// if( itemToExtract > 0 )
|
||||
// {
|
||||
// if( mode == Actionable.MODULATE )
|
||||
// {
|
||||
// energy.extractAEPower( retrieved / energyFactor, Actionable.MODULATE, PowerMultiplier.CONFIG );
|
||||
// possible.setStackSize( itemToExtract );
|
||||
// final T ret = cell.extractItems( possible, Actionable.MODULATE, src );
|
||||
//
|
||||
// if( ret != null )
|
||||
// {
|
||||
// src.player().ifPresent( player -> Stats.ItemsExtracted.addToPlayer( player, (int) ret.getStackSize() ) );
|
||||
// }
|
||||
// return ret;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return possible.setStackSize( itemToExtract );
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// public static <T extends IAEStack<T>> T poweredInsert( final IEnergySource energy, final IMEInventory<T> cell, final T input, final IActionSource src )
|
||||
// {
|
||||
// return poweredInsert( energy, cell, input, src, Actionable.MODULATE );
|
||||
// }
|
||||
//
|
||||
// public static <T extends IAEStack<T>> T poweredInsert( final IEnergySource energy, final IMEInventory<T> cell, final T input, final IActionSource src, final Actionable mode )
|
||||
// {
|
||||
// Preconditions.checkNotNull( energy );
|
||||
// Preconditions.checkNotNull( cell );
|
||||
// Preconditions.checkNotNull( input );
|
||||
// Preconditions.checkNotNull( src );
|
||||
// Preconditions.checkNotNull( mode );
|
||||
//
|
||||
// final T possible = cell.injectItems( input.copy(), Actionable.SIMULATE, src );
|
||||
//
|
||||
// long stored = input.getStackSize();
|
||||
// if( possible != null )
|
||||
// {
|
||||
// stored -= possible.getStackSize();
|
||||
// }
|
||||
//
|
||||
// final double energyFactor = Math.max( 1.0, cell.getChannel().transferFactor() );
|
||||
// final double availablePower = energy.extractAEPower( stored / energyFactor, Actionable.SIMULATE, PowerMultiplier.CONFIG );
|
||||
// final long itemToAdd = Math.min( (long) ( ( availablePower * energyFactor ) + 0.9 ), stored );
|
||||
//
|
||||
// if( itemToAdd > 0 )
|
||||
// {
|
||||
// if( mode == Actionable.MODULATE )
|
||||
// {
|
||||
// energy.extractAEPower( stored / energyFactor, Actionable.MODULATE, PowerMultiplier.CONFIG );
|
||||
// if( itemToAdd < input.getStackSize() )
|
||||
// {
|
||||
// final long original = input.getStackSize();
|
||||
// final T split = input.copy();
|
||||
// split.decStackSize( itemToAdd );
|
||||
// input.setStackSize( itemToAdd );
|
||||
// split.add( cell.injectItems( input, Actionable.MODULATE, src ) );
|
||||
//
|
||||
// src.player().ifPresent( player ->
|
||||
// {
|
||||
// final long diff = original - split.getStackSize();
|
||||
// Stats.ItemsInserted.addToPlayer( player, (int) diff );
|
||||
// } );
|
||||
//
|
||||
// return split;
|
||||
// }
|
||||
//
|
||||
// final T ret = cell.injectItems( input, Actionable.MODULATE, src );
|
||||
//
|
||||
// src.player().ifPresent( player ->
|
||||
// {
|
||||
// final long diff = ret == null ? input.getStackSize() : input.getStackSize() - ret.getStackSize();
|
||||
// Stats.ItemsInserted.addToPlayer( player, (int) diff );
|
||||
// } );
|
||||
//
|
||||
// return ret;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// final T ret = input.copy().setStackSize( input.getStackSize() - itemToAdd );
|
||||
// return ( ret != null && ret.getStackSize() > 0 ) ? ret : null;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return input;
|
||||
// }
|
||||
public static <T extends IAEStack<T>> T poweredExtraction( final IEnergySource energy, final IMEInventory<T> cell, final T request, final IActionSource src )
|
||||
{
|
||||
return poweredExtraction( energy, cell, request, src, Actionable.MODULATE );
|
||||
}
|
||||
|
||||
public static <T extends IAEStack<T>> T poweredExtraction( final IEnergySource energy, final IMEInventory<T> cell, final T request, final IActionSource src, final Actionable mode )
|
||||
{
|
||||
Preconditions.checkNotNull( energy );
|
||||
Preconditions.checkNotNull( cell );
|
||||
Preconditions.checkNotNull( request );
|
||||
Preconditions.checkNotNull( src );
|
||||
Preconditions.checkNotNull( mode );
|
||||
|
||||
final T possible = cell.extractItems( request.copy(), Actionable.SIMULATE, src );
|
||||
|
||||
long retrieved = 0;
|
||||
if( possible != null )
|
||||
{
|
||||
retrieved = possible.getStackSize();
|
||||
}
|
||||
|
||||
final double energyFactor = Math.max( 1.0, cell.getChannel().transferFactor() );
|
||||
final double availablePower = energy.extractAEPower( retrieved / energyFactor, Actionable.SIMULATE, PowerMultiplier.CONFIG );
|
||||
final long itemToExtract = Math.min( (long) ( ( availablePower * energyFactor ) + 0.9 ), retrieved );
|
||||
|
||||
if( itemToExtract > 0 )
|
||||
{
|
||||
if( mode == Actionable.MODULATE )
|
||||
{
|
||||
energy.extractAEPower( retrieved / energyFactor, Actionable.MODULATE, PowerMultiplier.CONFIG );
|
||||
possible.setStackSize( itemToExtract );
|
||||
final T ret = cell.extractItems( possible, Actionable.MODULATE, src );
|
||||
|
||||
if( ret != null )
|
||||
{
|
||||
src.player().ifPresent( player -> Stats.ItemsExtracted.addToPlayer( player, (int) ret.getStackSize() ) );
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
else
|
||||
{
|
||||
return possible.setStackSize( itemToExtract );
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static <T extends IAEStack<T>> T poweredInsert( final IEnergySource energy, final IMEInventory<T> cell, final T input, final IActionSource src )
|
||||
{
|
||||
return poweredInsert( energy, cell, input, src, Actionable.MODULATE );
|
||||
}
|
||||
|
||||
public static <T extends IAEStack<T>> T poweredInsert( final IEnergySource energy, final IMEInventory<T> cell, final T input, final IActionSource src, final Actionable mode )
|
||||
{
|
||||
Preconditions.checkNotNull( energy );
|
||||
Preconditions.checkNotNull( cell );
|
||||
Preconditions.checkNotNull( input );
|
||||
Preconditions.checkNotNull( src );
|
||||
Preconditions.checkNotNull( mode );
|
||||
|
||||
final T possible = cell.injectItems( input.copy(), Actionable.SIMULATE, src );
|
||||
|
||||
long stored = input.getStackSize();
|
||||
if( possible != null )
|
||||
{
|
||||
stored -= possible.getStackSize();
|
||||
}
|
||||
|
||||
final double energyFactor = Math.max( 1.0, cell.getChannel().transferFactor() );
|
||||
final double availablePower = energy.extractAEPower( stored / energyFactor, Actionable.SIMULATE, PowerMultiplier.CONFIG );
|
||||
final long itemToAdd = Math.min( (long) ( ( availablePower * energyFactor ) + 0.9 ), stored );
|
||||
|
||||
if( itemToAdd > 0 )
|
||||
{
|
||||
if( mode == Actionable.MODULATE )
|
||||
{
|
||||
energy.extractAEPower( stored / energyFactor, Actionable.MODULATE, PowerMultiplier.CONFIG );
|
||||
if( itemToAdd < input.getStackSize() )
|
||||
{
|
||||
final long original = input.getStackSize();
|
||||
final T split = input.copy();
|
||||
split.decStackSize( itemToAdd );
|
||||
input.setStackSize( itemToAdd );
|
||||
split.add( cell.injectItems( input, Actionable.MODULATE, src ) );
|
||||
|
||||
src.player().ifPresent( player ->
|
||||
{
|
||||
final long diff = original - split.getStackSize();
|
||||
Stats.ItemsInserted.addToPlayer( player, (int) diff );
|
||||
} );
|
||||
|
||||
return split;
|
||||
}
|
||||
|
||||
final T ret = cell.injectItems( input, Actionable.MODULATE, src );
|
||||
|
||||
src.player().ifPresent( player ->
|
||||
{
|
||||
final long diff = ret == null ? input.getStackSize() : input.getStackSize() - ret.getStackSize();
|
||||
Stats.ItemsInserted.addToPlayer( player, (int) diff );
|
||||
} );
|
||||
|
||||
return ret;
|
||||
}
|
||||
else
|
||||
{
|
||||
final T ret = input.copy().setStackSize( input.getStackSize() - itemToAdd );
|
||||
return ( ret != null && ret.getStackSize() > 0 ) ? ret : null;
|
||||
}
|
||||
}
|
||||
|
||||
return input;
|
||||
}
|
||||
//
|
||||
// @SuppressWarnings( { "rawtypes", "unchecked" } )
|
||||
// public static void postChanges( final IStorageGrid gs, final ItemStack removed, final ItemStack added, final IActionSource src )
|
||||
@@ -1315,36 +1335,36 @@ public class Platform
|
||||
// );
|
||||
// }
|
||||
//
|
||||
// public static boolean canAccess( final AENetworkProxy gridProxy, final IActionSource src )
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// if( src.player().isPresent() )
|
||||
// {
|
||||
// return gridProxy.getSecurity().hasPermission( src.player().get(), SecurityPermissions.BUILD );
|
||||
// }
|
||||
// else if( src.machine().isPresent() )
|
||||
// {
|
||||
// final IActionHost te = src.machine().get();
|
||||
// final IGridNode n = te.getActionableNode();
|
||||
// if( n == null )
|
||||
// {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// final int playerID = n.getPlayerID();
|
||||
// return gridProxy.getSecurity().hasPermission( playerID, SecurityPermissions.BUILD );
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
// catch( final GridAccessException gae )
|
||||
// {
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
public static boolean canAccess( final AENetworkProxy gridProxy, final IActionSource src )
|
||||
{
|
||||
try
|
||||
{
|
||||
if( src.player().isPresent() )
|
||||
{
|
||||
return gridProxy.getSecurity().hasPermission( src.player().get(), SecurityPermissions.BUILD );
|
||||
}
|
||||
else if( src.machine().isPresent() )
|
||||
{
|
||||
final IActionHost te = src.machine().get();
|
||||
final IGridNode n = te.getActionableNode();
|
||||
if( n == null )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final int playerID = n.getPlayerID();
|
||||
return gridProxy.getSecurity().hasPermission( playerID, SecurityPermissions.BUILD );
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch( final GridAccessException gae )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
//
|
||||
// public static ItemStack extractItemsByRecipe(final IEnergySource energySrc, final IActionSource mySrc, final IMEMonitor<IAEItemStack> src, final World w, final IRecipe r, final ItemStack output, final CraftingInventory ci, final ItemStack providedTemplate, final int slot, final IItemList<IAEItemStack> items, final Actionable realForFake, final IPartitionList<IAEItemStack> filter )
|
||||
// {
|
||||
|
||||
Reference in New Issue
Block a user