Clean packet registration, misc compile things

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