Conflicts:
	container/AEBaseContainer.java
	core/sync/AppEngPacketHandlerBase.java
This commit is contained in:
AlgorithmX2 2014-05-13 19:25:07 -05:00
commit 25a588f303
57 changed files with 1270 additions and 152 deletions

View file

@ -116,4 +116,10 @@ public class BlockQuartzGrowthAccelerator extends AEBaseBlock implements IOrient
Minecraft.getMinecraft().effectRenderer.addEffect( (EntityFX) fx );
}
}
@Override
public boolean usesMetadata()
{
return true;
}
}

View file

@ -20,8 +20,8 @@ import appeng.block.AEBaseBlock;
import appeng.client.render.BaseBlockRender;
import appeng.client.render.blocks.RenderQuartzTorch;
import appeng.client.render.effects.LightningEffect;
import appeng.core.CommonHelper;
import appeng.core.AEConfig;
import appeng.core.CommonHelper;
import appeng.core.features.AEFeature;
import appeng.helpers.ICustomCollision;
import appeng.helpers.MetaRotation;
@ -131,4 +131,10 @@ public class BlockQuartzTorch extends AEBaseBlock implements IOrientableBlock, I
}
}
@Override
public boolean usesMetadata()
{
return true;
}
}

View file

@ -24,4 +24,10 @@ public class BlockQuartzPillar extends AEBaseBlock implements IOrientableBlock
return new MetaRotation( w, x, y, z );
}
@Override
public boolean usesMetadata()
{
return true;
}
}

View file

@ -168,4 +168,10 @@ public class BlockSkyStone extends AEBaseBlock implements IOrientableBlock
return getRenderType();
}
@Override
public boolean usesMetadata()
{
return false;
}
}

View file

@ -11,15 +11,12 @@ import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.oredict.OreDictionary;
import appeng.api.AEApi;
import appeng.api.util.IOrientable;
import appeng.api.util.IOrientableBlock;
import appeng.block.AEBaseBlock;
import appeng.client.render.BaseBlockRender;
import appeng.client.render.blocks.RenderQuartzOre;
import appeng.core.features.AEFeature;
import appeng.helpers.LocationRotation;
public class OreQuartz extends AEBaseBlock implements IOrientableBlock
public class OreQuartz extends AEBaseBlock
{
public int boostBrightnessLow;
@ -77,12 +74,6 @@ public class OreQuartz extends AEBaseBlock implements IOrientableBlock
return AEApi.instance().materials().materialCertusQuartzCrystal.stack( 1 );
}
@Override
public IOrientable getOrientable(final IBlockAccess w, final int x, final int y, final int z)
{
return new LocationRotation( w, x, y, z );
}
@Override
public Item getItemDropped(int id, Random rand, int meta)
{

View file

@ -116,11 +116,41 @@ public abstract class AEBaseGui extends GuiContainer
{
super.handleMouseInput();
if ( myScrollBar != null )
int i = Mouse.getEventDWheel();
if ( i != 0 && isShiftKeyDown() )
{
int i = Mouse.getEventDWheel();
if ( i != 0 )
myScrollBar.wheel( i );
int x = Mouse.getEventX() * this.width / this.mc.displayWidth;
int y = this.height - Mouse.getEventY() * this.height / this.mc.displayHeight - 1;
mouseWheelEvent( x, y, i / Math.abs( i ) );
}
else if ( i != 0 && myScrollBar != null )
myScrollBar.wheel( i );
}
protected void mouseWheelEvent(int x, int y, int wheel)
{
Slot slot = getSlot( x, y );
if ( slot instanceof SlotME )
{
IAEItemStack item = ((SlotME) slot).getAEStack();
if ( item != null )
{
try
{
((AEBaseContainer) inventorySlots).setTargetStack( item );
InventoryAction direction = wheel > 0 ? InventoryAction.ROLLDOWN : InventoryAction.ROLLUP;
int times = Math.abs( wheel );
for (int h = 0; h < times; h++)
{
PacketInventoryAction p = new PacketInventoryAction( direction, inventorySlots.inventorySlots.size(), null );
NetworkHandler.instance.sendToServer( p );
}
}
catch (IOException e)
{
AELog.error( e );
}
}
}
}
@ -150,15 +180,13 @@ public abstract class AEBaseGui extends GuiContainer
if ( slot instanceof SlotFake )
{
InventoryAction action = null;
IAEItemStack stack = null;
action = ctrlDown == 1 ? InventoryAction.SPLIT_OR_PLACESINGLE : InventoryAction.PICKUP_OR_SETDOWN;
if ( action != null )
{
PacketInventoryAction p;
try
{
p = new PacketInventoryAction( action, slotIdx, stack );
PacketInventoryAction p = new PacketInventoryAction( action, slotIdx, null );
NetworkHandler.instance.sendToServer( p );
}
catch (IOException e)
@ -190,7 +218,6 @@ public abstract class AEBaseGui extends GuiContainer
return; // prevent weird double clicks..
InventoryAction action = null;
IAEItemStack stack = null;
if ( key == 1 )
action = InventoryAction.CRAFT_SHIFT;
else
@ -198,10 +225,9 @@ public abstract class AEBaseGui extends GuiContainer
if ( action != null )
{
PacketInventoryAction p;
try
{
p = new PacketInventoryAction( action, slotIdx, stack );
PacketInventoryAction p = new PacketInventoryAction( action, slotIdx, null );
NetworkHandler.instance.sendToServer( p );
}
catch (IOException e)
@ -219,7 +245,6 @@ public abstract class AEBaseGui extends GuiContainer
if ( slot instanceof SlotME )
stack = ((SlotME) slot).getAEStack();
PacketInventoryAction p;
try
{
int slotNum = inventorySlots.inventorySlots.size();
@ -227,7 +252,8 @@ public abstract class AEBaseGui extends GuiContainer
if ( !(slot instanceof SlotME) && slot != null )
slotNum = slot.slotNumber;
p = new PacketInventoryAction( InventoryAction.MOVE_REGION, slotNum, stack );
((AEBaseContainer) inventorySlots).setTargetStack( stack );
PacketInventoryAction p = new PacketInventoryAction( InventoryAction.MOVE_REGION, slotNum, null );
NetworkHandler.instance.sendToServer( p );
}
catch (IOException e)
@ -272,10 +298,10 @@ public abstract class AEBaseGui extends GuiContainer
if ( action != null )
{
PacketInventoryAction p;
try
{
p = new PacketInventoryAction( action, inventorySlots.inventorySlots.size(), stack );
((AEBaseContainer) inventorySlots).setTargetStack( stack );
PacketInventoryAction p = new PacketInventoryAction( action, inventorySlots.inventorySlots.size(), null );
NetworkHandler.instance.sendToServer( p );
}
catch (IOException e)

View file

@ -1,5 +1,7 @@
package appeng.container;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.lang.reflect.Field;
import java.util.ArrayList;
@ -16,6 +18,8 @@ import net.minecraft.inventory.ICrafting;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompressedStreamTools;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.AEApi;
@ -47,6 +51,7 @@ import appeng.container.slot.SlotPlayerInv;
import appeng.core.AELog;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketInventoryAction;
import appeng.core.sync.packets.PacketPartialItem;
import appeng.core.sync.packets.PacketValueConfig;
import appeng.helpers.ICustomNameObject;
import appeng.helpers.InventoryAction;
@ -70,6 +75,101 @@ public abstract class AEBaseContainer extends Container
int ticksSinceCheck = 900;
IAEItemStack clientRequestedTargetItem = null;
List<PacketPartialItem> dataChunks = new LinkedList();
public void postPartial(PacketPartialItem packetPartialItem)
{
dataChunks.add( packetPartialItem );
if ( packetPartialItem.getPageCount() == dataChunks.size() )
parsePartials();
}
private void parsePartials()
{
int total = 0;
for (PacketPartialItem ppi : dataChunks)
total += ppi.getSize();
byte[] buffer = new byte[total];
int cursor = 0;
for (PacketPartialItem ppi : dataChunks)
cursor = ppi.write( buffer, cursor );
try
{
NBTTagCompound data = CompressedStreamTools.readCompressed( new ByteArrayInputStream( buffer ) );
if ( data != null )
setTargetStack( AEApi.instance().storage().createItemStack( ItemStack.loadItemStackFromNBT( data ) ) );
}
catch (IOException e)
{
AELog.error( e );
}
dataChunks.clear();
}
public void setTargetStack(IAEItemStack stack)
{
// client dosn't need to re-send, makes for lower overhead rapid packets.
if ( Platform.isClient() )
{
ItemStack a = stack == null ? null : stack.getItemStack();
ItemStack b = clientRequestedTargetItem == null ? null : clientRequestedTargetItem.getItemStack();
if ( Platform.isSameItemPrecise( a, b ) )
return;
ByteArrayOutputStream stream = new ByteArrayOutputStream();
NBTTagCompound item = new NBTTagCompound();
if ( stack != null )
stack.writeToNBT( item );
try
{
CompressedStreamTools.writeCompressed( item, stream );
int maxChunkSize = 30000;
List<byte[]> miniPackets = new LinkedList();
byte[] data = stream.toByteArray();
ByteArrayInputStream bis = new ByteArrayInputStream( data, 0, stream.size() );
while (bis.available() > 0)
{
int nextBLock = bis.available() > maxChunkSize ? maxChunkSize : bis.available();
byte[] nextSegment = new byte[nextBLock];
bis.read( nextSegment );
miniPackets.add( nextSegment );
}
bis.close();
stream.close();
int page = 0;
for (byte[] packet : miniPackets)
{
PacketPartialItem ppi = new PacketPartialItem( page++, miniPackets.size(), packet );
NetworkHandler.instance.sendToServer( ppi );
}
}
catch (IOException e)
{
AELog.error( e );
return;
}
}
clientRequestedTargetItem = stack == null ? null : stack.copy();
}
public IAEItemStack getTargetStack()
{
return clientRequestedTargetItem;
}
public BaseActionSource getSource()
{
return mySrc;
@ -548,7 +648,7 @@ public abstract class AEBaseContainer extends Container
return ais.getItemStack();
}
public void doAction(EntityPlayerMP player, InventoryAction action, int slot, IAEItemStack slotItem)
public void doAction(EntityPlayerMP player, InventoryAction action, int slot)
{
if ( slot >= 0 && slot < inventorySlots.size() )
{
@ -632,6 +732,9 @@ public abstract class AEBaseContainer extends Container
return;
}
// get target item.
IAEItemStack slotItem = getTargetStack();
switch (action)
{
case SHIFT_CLICK:
@ -657,6 +760,34 @@ public abstract class AEBaseContainer extends Container
adp.addItems( ais.getItemStack() );
}
break;
case ROLLDOWN:
if ( powerSrc == null || cellInv == null )
return;
int releaseQty = 1;
ItemStack isg = player.inventory.getItemStack();
if ( isg != null && releaseQty > 0 )
{
IAEItemStack ais = AEApi.instance().storage().createItemStack( isg );
ais.setStackSize( 1 );
IAEItemStack extracted = ais.copy();
ais = Platform.poweredInsert( powerSrc, cellInv, ais, mySrc );
if ( ais == null )
{
InventoryAdaptor ia = new AdaptorPlayerHand( player );
ItemStack fail = ia.removeItems( 1, extracted.getItemStack(), null );
if ( fail == null )
cellInv.extractItems( extracted, Actionable.MODULATE, mySrc );
updateHeld( player );
}
}
break;
case ROLLUP:
case PICKUP_SINGLE:
if ( powerSrc == null || cellInv == null )
return;
@ -664,13 +795,13 @@ public abstract class AEBaseContainer extends Container
if ( slotItem != null )
{
int liftQty = 1;
ItemStack isg = player.inventory.getItemStack();
ItemStack isgg = player.inventory.getItemStack();
if ( isg != null )
if ( isgg != null )
{
if ( isg.stackSize >= isg.getMaxStackSize() )
if ( isgg.stackSize >= isgg.getMaxStackSize() )
liftQty = 0;
if ( !Platform.isSameItemPrecise( slotItem.getItemStack(), isg ) )
if ( !Platform.isSameItemPrecise( slotItem.getItemStack(), isgg ) )
liftQty = 0;
}
@ -679,14 +810,16 @@ public abstract class AEBaseContainer extends Container
IAEItemStack ais = slotItem.copy();
ais.setStackSize( 1 );
ais = Platform.poweredExtraction( powerSrc, cellInv, ais, mySrc );
if ( ais != null )
{
InventoryAdaptor ia = new AdaptorPlayerHand( player );
InventoryAdaptor ia = new AdaptorPlayerHand( player );
ItemStack fail = ia.addItems( ais.getItemStack() );
if ( fail != null )
cellInv.injectItems( ais, Actionable.MODULATE, mySrc );
ItemStack fail = ia.addItems( ais.getItemStack() );
if ( fail != null )
cellInv.injectItems( ais, Actionable.MODULATE, mySrc );
updateHeld( player );
updateHeld( player );
}
}
}
break;
@ -802,13 +935,17 @@ public abstract class AEBaseContainer extends Container
protected void updateHeld(EntityPlayerMP p)
{
try
if ( Platform.isServer() )
{
NetworkHandler.instance.sendTo( new PacketInventoryAction( InventoryAction.UPDATE_HAND, 0, AEItemStack.create( p.inventory.getItemStack() ) ), p );
}
catch (IOException e)
{
AELog.error( e );
try
{
NetworkHandler.instance.sendTo( new PacketInventoryAction( InventoryAction.UPDATE_HAND, 0, AEItemStack.create( p.inventory.getItemStack() ) ),
p );
}
catch (IOException e)
{
AELog.error( e );
}
}
}

View file

@ -6,6 +6,7 @@ import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import appeng.api.config.Actionable;
@ -82,7 +83,27 @@ public class SlotCraftingTerm extends AppEngCraftingSlot
IRecipe r = Platform.findMatchingRecipe( ic, p.worldObj );
if ( r == null )
{
Item target = request.getItem();
if ( target.isDamageable() && target.isRepairable() )
{
boolean isBad = false;
for (int x = 0; x < ic.getSizeInventory(); x++)
{
ItemStack pis = ic.getStackInSlot( x );
if ( pis == null )
continue;
if ( pis.getItem() != target )
isBad = true;
}
if ( !isBad )
{
super.onPickupFromSlot( p, is );
return request;
}
}
return null;
}
is = r.getCraftingResult( ic );

View file

@ -80,8 +80,7 @@ public class AppEng
IMCHandlers.put( "add-p2p-attunement-" + type.name().replace( '_', '-' ).toLowerCase(), new IMCP2PAttunement() );
}
for (CrashInfo ci : CrashInfo.values())
FMLCommonHandler.instance().registerCrashCallable( new CrashEnhancement( ci ) );
FMLCommonHandler.instance().registerCrashCallable( new CrashEnhancement( CrashInfo.MOD_VERSION ) );
}
public boolean isIntegrationEnabled(String Name)
@ -157,6 +156,7 @@ public class AppEng
Registration.instance.PostInit( event );
IntegrationRegistry.instance.postinit();
FMLCommonHandler.instance().registerCrashCallable( new CrashEnhancement( CrashInfo.INTEGRATION ) );
CommonHelper.proxy.postinit();
AEConfig.instance.save();

View file

@ -486,16 +486,22 @@ public class Registration
ph.registerNewLayer( "appeng.api.parts.layers.LayerIEnergySource", "ic2.api.energy.tile.IEnergySource" );
}
if ( AppEng.instance.isIntegrationEnabled( "MJ" ) )
if ( AppEng.instance.isIntegrationEnabled( "MJ5" ) )
{
ph.registerNewLayer( "appeng.api.parts.layers.LayerIPowerEmitter", "buildcraft.api.power.IPowerEmitter" );
ph.registerNewLayer( "appeng.api.parts.layers.LayerIPowerReceptor", "buildcraft.api.power.IPowerReceptor" );
}
if ( AppEng.instance.isIntegrationEnabled( "MJ6" ) )
{
ph.registerNewLayer( "appeng.api.parts.layers.LayerIBatteryProvider", "buildcraft.api.mj.IBatteryProvider" );
}
if ( AppEng.instance.isIntegrationEnabled( "RF" ) )
ph.registerNewLayer( "appeng.api.parts.layers.LayerIEnergyHandler", "cofh.api.energy.IEnergyHandler" );
FMLCommonHandler.instance().bus().register( TickHandler.instance );
MinecraftForge.EVENT_BUS.register( TickHandler.instance );
MinecraftForge.EVENT_BUS.register( new PartPlacement() );
IGridCacheRegistry gcr = AEApi.instance().registries().gridCache();

View file

@ -9,8 +9,21 @@ public class CrashEnhancement implements ICrashCallable
final CrashInfo Output;
final String ModVersion = AEConfig.CHANNEL + " " + AEConfig.VERSION + " for Forge " + // WHAT?
net.minecraftforge.common.ForgeVersion.majorVersion + "." // majorVersion
+ net.minecraftforge.common.ForgeVersion.minorVersion + "." // minorVersion
+ net.minecraftforge.common.ForgeVersion.revisionVersion + "." // revisionVersion
+ net.minecraftforge.common.ForgeVersion.buildVersion;
final String IntegrationInfo;
public CrashEnhancement(CrashInfo ci) {
Output = ci;
if ( IntegrationRegistry.instance != null )
IntegrationInfo = IntegrationRegistry.instance.getStatus();
else
IntegrationInfo = "N/A";
}
@Override
@ -19,15 +32,9 @@ public class CrashEnhancement implements ICrashCallable
switch (Output)
{
case MOD_VERSION:
return AEConfig.CHANNEL + " " + AEConfig.VERSION + " for Forge "
+ net.minecraftforge.common.ForgeVersion.majorVersion + "." // majorVersion
+ net.minecraftforge.common.ForgeVersion.minorVersion + "." // minorVersion
+ net.minecraftforge.common.ForgeVersion.revisionVersion + "." // revisionVersion
+ net.minecraftforge.common.ForgeVersion.buildVersion;
return ModVersion;
case INTEGRATION:
if ( IntegrationRegistry.instance == null )
return "N/A";
return IntegrationRegistry.instance.getStatus();
return IntegrationInfo;
}
return "UNKNOWN_VALUE";

View file

@ -36,8 +36,8 @@ public abstract class AppEngPacket
public FMLProxyPacket getProxy()
{
if ( p.array().length > 30000 ) // 2k walking room :)
throw new IllegalArgumentException( "Sorry AE2 made a huge packet by accident!" );
if ( p.array().length > 2 * 1024 * 1024 ) // 2k walking room :)
throw new IllegalArgumentException( "Sorry AE2 made a " + p.array().length + " byte packet by accident!" );
return new FMLProxyPacket( p, NetworkHandler.instance.getChannel() );
}

View file

@ -20,6 +20,7 @@ import appeng.core.sync.packets.PacketMultiPart;
import appeng.core.sync.packets.PacketNEIRecipe;
import appeng.core.sync.packets.PacketNewStorageDimension;
import appeng.core.sync.packets.PacketPartPlacement;
import appeng.core.sync.packets.PacketPartialItem;
import appeng.core.sync.packets.PacketPatternSlot;
import appeng.core.sync.packets.PacketProgressBar;
import appeng.core.sync.packets.PacketSwapSlots;
@ -70,7 +71,9 @@ public class AppEngPacketHandlerBase
PACKET_PATTERN_SLOT(PacketPatternSlot.class),
PACKET_RECIPE_NEI(PacketNEIRecipe.class);
PACKET_RECIPE_NEI(PacketNEIRecipe.class),
PACKET_PARTIAL_ITEM(PacketPartialItem.class);
final public Class pc;
final public Constructor con;

View file

@ -13,6 +13,7 @@ import appeng.container.AEBaseContainer;
import appeng.core.sync.AppEngPacket;
import appeng.core.sync.network.INetworkInfo;
import appeng.helpers.InventoryAction;
import appeng.util.Platform;
import appeng.util.item.AEItemStack;
public class PacketInventoryAction extends AppEngPacket
@ -40,7 +41,7 @@ public class PacketInventoryAction extends AppEngPacket
if ( sender.openContainer instanceof AEBaseContainer )
{
AEBaseContainer aebc = (AEBaseContainer) sender.openContainer;
aebc.doAction( sender, action, slot, slotItem );
aebc.doAction( sender, action, slot );
}
}
@ -58,6 +59,10 @@ public class PacketInventoryAction extends AppEngPacket
// api
public PacketInventoryAction(InventoryAction action, int slot, IAEItemStack slotItem) throws IOException {
if ( Platform.isClient() && slotItem != null )
throw new RuntimeException( "invalid packet, client cannot post inv actions with stacks." );
this.action = action;
this.slot = slot;
this.slotItem = slotItem;

View file

@ -136,7 +136,7 @@ public class PacketMEInventoryUpdate extends AppEngPacket
is.writeToPacket( tmp );
compressFrame.flush();
if ( writtenBytes + tmp.readableBytes() > 30000 )
if ( writtenBytes + tmp.readableBytes() > 2 * 1024 * 1024 ) // 2mb!
throw new BufferOverflowException();
else
{

View file

@ -0,0 +1,63 @@
package appeng.core.sync.packets;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import java.io.IOException;
import net.minecraft.entity.player.EntityPlayer;
import appeng.container.AEBaseContainer;
import appeng.core.sync.AppEngPacket;
import appeng.core.sync.network.INetworkInfo;
public class PacketPartialItem extends AppEngPacket
{
short pageNum;
byte[] data;
// automatic.
public PacketPartialItem(ByteBuf stream) throws IOException {
pageNum = stream.readShort();
stream.readBytes( data = new byte[stream.readableBytes()] );
}
@Override
public void serverPacketData(INetworkInfo manager, AppEngPacket packet, EntityPlayer player)
{
if ( player.openContainer instanceof AEBaseContainer )
{
((AEBaseContainer) player.openContainer).postPartial( this );
}
}
// api
public PacketPartialItem(int page, int maxPages, byte[] buf) throws IOException {
ByteBuf data = Unpooled.buffer();
pageNum = (short) (page | (maxPages << 8));
this.data = buf;
data.writeInt( getPacketID() );
data.writeShort( pageNum );
data.writeBytes( buf );
configureWrite( data );
}
public int getPageCount()
{
return pageNum >> 8;
}
public int getSize()
{
return data.length;
}
public int write(byte[] buffer, int cursor)
{
System.arraycopy( data, 0, buffer, cursor, data.length );
return cursor + data.length;
}
}

View file

@ -49,6 +49,8 @@ public class FacadeContainer implements IFacadeContainer
{
int facadeSides = out.readByte();
boolean changed = false;
int ids[] = new int[2];
for (int x = 0; x < facades.length; x++)
{
@ -64,6 +66,7 @@ public class FacadeContainer implements IFacadeContainer
if ( isBC && AppEng.instance.isIntegrationEnabled( "BC" ) )
{
IBC bc = (IBC) AppEng.instance.getIntegration( "BC" );
changed = changed || facades[x] == null;
facades[x] = bc.createFacadePart( (Block) Block.blockRegistry.getObjectById( ids[0] ), ids[1], side );
}
else if ( !isBC )
@ -71,13 +74,20 @@ public class FacadeContainer implements IFacadeContainer
ItemFacade ifa = (ItemFacade) AEApi.instance().items().itemFacade.item();
ItemStack facade = ifa.createFromInts( ids );
if ( facade != null )
{
changed = changed || facades[x] == null;
facades[x] = ifa.createPartFromItemStack( facade, side );
}
}
}
else
{
changed = changed || facades[x] != null;
facades[x] = null;
}
}
return false;
return changed;
}
public void readFromNBT(NBTTagCompound c)
@ -160,4 +170,20 @@ public class FacadeContainer implements IFacadeContainer
return false;
return true;
}
public void rotateLeft()
{
IFacadePart newfacades[] = new FacadePart[6];
newfacades[ForgeDirection.UP.ordinal()] = facades[ForgeDirection.UP.ordinal()];
newfacades[ForgeDirection.DOWN.ordinal()] = facades[ForgeDirection.DOWN.ordinal()];
newfacades[ForgeDirection.EAST.ordinal()] = facades[ForgeDirection.NORTH.ordinal()];
newfacades[ForgeDirection.SOUTH.ordinal()] = facades[ForgeDirection.EAST.ordinal()];
newfacades[ForgeDirection.WEST.ordinal()] = facades[ForgeDirection.SOUTH.ordinal()];
newfacades[ForgeDirection.NORTH.ordinal()] = facades[ForgeDirection.WEST.ordinal()];
for (int x = 0; x < facades.length; x++)
facades[x] = newfacades[x];
}
}

View file

@ -9,5 +9,5 @@ public enum InventoryAction
CRAFT_STACK, CRAFT_ITEM, CRAFT_SHIFT,
// extra...
MOVE_REGION, PICKUP_SINGLE, UPDATE_HAND
MOVE_REGION, PICKUP_SINGLE, UPDATE_HAND, ROLLUP, ROLLDOWN
}

View file

@ -0,0 +1,23 @@
package appeng.helpers;
import java.util.EnumSet;
import java.util.HashMap;
import appeng.api.config.SecurityPermissions;
import appeng.api.networking.security.ISecurityRegister;
public class PlayerSecuirtyWrapper implements ISecurityRegister
{
final HashMap<Integer, EnumSet<SecurityPermissions>> target;
public PlayerSecuirtyWrapper(HashMap<Integer, EnumSet<SecurityPermissions>> playerPerms) {
target = playerPerms;
}
@Override
public void addPlayer(int PlayerID, EnumSet<SecurityPermissions> permissions)
{
target.put( PlayerID, permissions );
}
}

View file

@ -5,6 +5,7 @@ import java.util.LinkedList;
import java.util.Queue;
import java.util.concurrent.Callable;
import net.minecraftforge.event.world.ChunkEvent;
import net.minecraftforge.event.world.WorldEvent;
import appeng.api.networking.IGridNode;
import appeng.core.AELog;
@ -103,10 +104,23 @@ public class TickHandler
}
}
@SubscribeEvent
public void onChunkLoad(ChunkEvent.Load load)
{
for (Object te : load.getChunk().chunkTileEntityMap.values())
{
if ( te instanceof AEBaseTile )
{
((AEBaseTile) te).onChunkLoad();
}
}
}
@SubscribeEvent
public void onTick(TickEvent ev)
{
if ( ev.type == Type.SERVER && ev.phase == Phase.END ) // for no there is no reason to care about this on the client...
if ( ev.type == Type.SERVER && ev.phase == Phase.END ) // for no there is no reason to care about this on the
// client...
{
HandlerRep repo = getRepo();
while (!repo.tiles.isEmpty())

View file

@ -1,10 +0,0 @@
package appeng.integration.abstraction;
import appeng.tile.powersink.MinecraftJoules;
public interface IMJ
{
Object createPerdition(MinecraftJoules buildCraft);
}

View file

@ -0,0 +1,9 @@
package appeng.integration.abstraction;
public interface IMJ5
{
Object createPerdition(Object buildCraft);
}

View file

@ -0,0 +1,7 @@
package appeng.integration.abstraction;
public interface IMJ6
{
}

View file

@ -12,10 +12,10 @@ public abstract class BaseMJperdition extends AETileEventHandler
super( TileEventType.TICK, TileEventType.WORLD_NBT );
}
@Method(iname = "MJ")
@Method(iname = "MJ5")
public abstract PowerReceiver getPowerReceiver();
public abstract double useEnergy(float f, float requred, boolean b);
public abstract double useEnergy(double f, double requred, boolean b);
public abstract void addEnergy(float failed);

View file

@ -1,5 +1,7 @@
package appeng.integration.modules;
import java.lang.reflect.Field;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
@ -12,12 +14,19 @@ import appeng.api.config.TunnelType;
import appeng.api.definitions.Blocks;
import appeng.api.features.IP2PTunnelRegistry;
import appeng.api.parts.IFacadePart;
import appeng.api.util.AEItemDefinition;
import appeng.api.util.IOrientableBlock;
import appeng.core.AppEng;
import appeng.facade.FacadePart;
import appeng.integration.BaseModule;
import appeng.integration.abstraction.IBC;
import appeng.integration.modules.helpers.BCPipeHandler;
import appeng.integration.modules.BCHelpers.AECableSchematicTile;
import appeng.integration.modules.BCHelpers.AEGenericSchematicTile;
import appeng.integration.modules.BCHelpers.AERotateableBlockSchematic;
import appeng.integration.modules.BCHelpers.BCPipeHandler;
import buildcraft.BuildCraftEnergy;
import buildcraft.BuildCraftTransport;
import buildcraft.api.blueprints.SchematicRegistry;
import buildcraft.api.tools.IToolWrench;
import buildcraft.api.transport.IPipeConnection;
import buildcraft.api.transport.IPipeTile;
@ -109,7 +118,15 @@ public class BC extends BaseModule implements IBC
{
if ( is == null )
return false;
return is.getItem() instanceof ItemFacade;
try
{
return is.getItem() instanceof ItemFacade && ItemFacade.getType( is ) == ItemFacade.TYPE_BASIC;
}
catch (Throwable t)
{
return is.getItem() instanceof ItemFacade;
}
}
@Override
@ -189,7 +206,16 @@ public class BC extends BaseModule implements IBC
addFacade( b.blockQuartz.stack( 1 ) );
addFacade( b.blockQuartzChiseled.stack( 1 ) );
addFacade( b.blockQuartzPiller.stack( 1 ) );
try
{
initBuilderSupport();
}
catch (Throwable builderSupport)
{
// not supported?
}
Block skyStone = b.blockSkyStone.block();
if ( skyStone != null )
{
@ -200,6 +226,42 @@ public class BC extends BaseModule implements IBC
}
}
private void initBuilderSupport()
{
SchematicRegistry.declareBlueprintSupport( AppEng.modid );
Blocks blks = AEApi.instance().blocks();
Block cable = blks.blockMultiPart.block();
for (Field f : blks.getClass().getFields())
{
AEItemDefinition def;
try
{
def = (AEItemDefinition) f.get( blks );
if ( def != null )
{
Block myBlock = def.block();
if ( myBlock instanceof IOrientableBlock && ((IOrientableBlock) myBlock).usesMetadata() && def.entity() == null )
{
SchematicRegistry.registerSchematicBlock( myBlock, AERotateableBlockSchematic.class );
}
else if ( myBlock == cable )
{
SchematicRegistry.registerSchematicBlock( myBlock, AECableSchematicTile.class );
}
else if ( def.entity() != null )
{
SchematicRegistry.registerSchematicBlock( myBlock, AEGenericSchematicTile.class );
}
}
}
catch (Throwable t)
{
// :P
}
}
}
@Override
public void PostInit()
{
@ -211,8 +273,27 @@ public class BC extends BaseModule implements IBC
@Override
public IFacadePart createFacadePart(Block blk, int meta, ForgeDirection side)
{
ItemStack fs = ItemFacade.getStack( blk, meta );
return new FacadePart( fs, side );
try
{
ItemStack fs = ItemFacade.getFacade( blk, meta );
return new FacadePart( fs, side );
}
catch (Throwable t)
{
}
try
{
ItemStack fs = ItemFacade.getStack( blk, meta );
return new FacadePart( fs, side );
}
catch (Throwable t)
{
}
return null;
}
@Override
@ -224,8 +305,31 @@ public class BC extends BaseModule implements IBC
@Override
public ItemStack getTextureForFacade(ItemStack facade)
{
Block blk = ItemFacade.getBlock( facade );
return new ItemStack( blk, 1, ItemFacade.getMetaData( facade ) );
try
{
Block blk[] = ItemFacade.getBlocks( facade );
int meta[] = ItemFacade.getMetaValues( facade );
if ( blk == null || blk.length < 1 )
return null;
return new ItemStack( blk[0], 1, meta[0] );
}
catch (Throwable t)
{
}
try
{
Block blk = ItemFacade.getBlock( facade );
return new ItemStack( blk, 1, ItemFacade.getMetaData( facade ) );
}
catch (Throwable t)
{
}
return null;
}
@Override

View file

@ -0,0 +1,143 @@
package appeng.integration.modules.BCHelpers;
import java.util.Set;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Vec3;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.parts.IFacadeContainer;
import appeng.api.parts.IPart;
import appeng.api.parts.IPartHost;
import appeng.api.parts.LayerFlags;
import appeng.api.parts.SelectedPart;
import appeng.api.util.AEColor;
import appeng.api.util.DimensionalCoord;
import appeng.parts.CableBusContainer;
import buildcraft.api.blueprints.IBuilderContext;
public class AECableSchematicTile extends AEGenericSchematicTile implements IPartHost
{
@Override
public void rotateLeft(IBuilderContext context)
{
CableBusContainer cbc = new CableBusContainer( this );
cbc.readFromNBT( tileNBT );
cbc.rotateLeft();
tileNBT = new NBTTagCompound();
cbc.writeToNBT( tileNBT );
}
@Override
public IFacadeContainer getFacadeContainer()
{
return null;
}
@Override
public boolean canAddPart(ItemStack part, ForgeDirection side)
{
return false;
}
@Override
public ForgeDirection addPart(ItemStack is, ForgeDirection side, EntityPlayer owner)
{
return null;
}
@Override
public IPart getPart(ForgeDirection side)
{
return null;
}
@Override
public void removePart(ForgeDirection side, boolean suppressUpdate)
{
}
@Override
public void markForUpdate()
{
}
@Override
public DimensionalCoord getLocation()
{
return null;
}
@Override
public TileEntity getTile()
{
return null;
}
@Override
public AEColor getColor()
{
return null;
}
@Override
public void clearContainer()
{
}
@Override
public boolean isBlocked(ForgeDirection side)
{
return false;
}
@Override
public SelectedPart selectPart(Vec3 pos)
{
return null;
}
@Override
public void markForSave()
{
}
@Override
public void partChanged()
{
}
@Override
public boolean hasRedstone(ForgeDirection side)
{
return false;
}
@Override
public boolean isEmpty()
{
return false;
}
@Override
public Set<LayerFlags> getLayerFlags()
{
return null;
}
@Override
public void cleanup()
{
}
}

View file

@ -0,0 +1,59 @@
package appeng.integration.modules.BCHelpers;
import java.util.ArrayList;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.tile.AEBaseTile;
import appeng.util.Platform;
import buildcraft.api.blueprints.IBuilderContext;
import buildcraft.api.blueprints.SchematicTile;
public class AEGenericSchematicTile extends SchematicTile
{
@Override
public void writeRequirementsToBlueprint(IBuilderContext context, int x, int y, int z)
{
TileEntity tile = context.world().getTileEntity( x, y, z );
ArrayList<ItemStack> list = new ArrayList();
if ( tile instanceof AEBaseTile )
{
AEBaseTile tcb = (AEBaseTile) tile;
tcb.getDrops( tile.getWorldObj(), tile.xCoord, tile.yCoord, tile.zCoord, list );
}
storedRequirements = list.toArray( new ItemStack[list.size()] );
}
@Override
public void rotateLeft(IBuilderContext context)
{
if ( tileNBT.hasKey( "orientation_forward" ) && tileNBT.hasKey( "orientation_up" ) )
{
String forward = tileNBT.getString( "orientation_forward" );
String up = tileNBT.getString( "orientation_up" );
if ( forward != null && up != null )
{
try
{
ForgeDirection fdForward = ForgeDirection.valueOf( forward );
ForgeDirection fdUp = ForgeDirection.valueOf( up );
fdForward = Platform.rotateAround( fdForward, ForgeDirection.DOWN );
fdUp = Platform.rotateAround( fdUp, ForgeDirection.DOWN );
tileNBT.setString( "orientation_forward", fdForward.name() );
tileNBT.setString( "orientation_up", fdUp.name() );
}
catch (Throwable t)
{
}
}
}
}
}

View file

@ -0,0 +1,21 @@
package appeng.integration.modules.BCHelpers;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.util.Platform;
import buildcraft.api.blueprints.IBuilderContext;
import buildcraft.api.blueprints.SchematicBlock;
public class AERotateableBlockSchematic extends SchematicBlock
{
@Override
public void rotateLeft(IBuilderContext context)
{
if ( meta < 6 )
{
ForgeDirection d = Platform.rotateAround( ForgeDirection.values()[meta], ForgeDirection.DOWN );
meta = d.ordinal();
}
}
}

View file

@ -1,4 +1,4 @@
package appeng.integration.modules.helpers;
package appeng.integration.modules.BCHelpers;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;

View file

@ -1,4 +1,4 @@
package appeng.integration.modules.helpers;
package appeng.integration.modules.BCHelpers;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;

View file

@ -1,36 +1,37 @@
package appeng.integration.modules;
import appeng.integration.BaseModule;
import appeng.integration.abstraction.IMJ;
import appeng.integration.abstraction.IMJ5;
import appeng.integration.modules.helpers.MJPerdition;
import appeng.tile.powersink.MinecraftJoules;
import buildcraft.api.power.IPowerReceptor;
public class MJ extends BaseModule implements IMJ
public class MJ5 extends BaseModule implements IMJ5
{
public static MJ instance;
public static MJ5 instance;
public MJ() {
public MJ5() {
TestClass( IPowerReceptor.class );
}
@Override
public Object createPerdition(MinecraftJoules buildCraft)
public Object createPerdition(Object buildCraft)
{
if ( buildCraft instanceof IPowerReceptor )
return new MJPerdition( buildCraft );
return new MJPerdition( (IPowerReceptor) buildCraft );
return null;
}
@Override
public void Init() throws Throwable
{
}
@Override
public void PostInit() throws Throwable
{
}
}

View file

@ -0,0 +1,31 @@
package appeng.integration.modules;
import appeng.integration.BaseModule;
import appeng.integration.abstraction.IMJ6;
import buildcraft.api.mj.IBatteryObject;
import buildcraft.api.mj.IBatteryProvider;
import buildcraft.api.mj.ISidedBatteryProvider;
public class MJ6 extends BaseModule implements IMJ6
{
public static MJ6 instance;
public MJ6() {
TestClass( IBatteryObject.class );
TestClass( IBatteryProvider.class );
TestClass( ISidedBatteryProvider.class );
throw new RuntimeException( "Disabled For Now!" );
}
@Override
public void Init() throws Throwable
{
}
@Override
public void PostInit() throws Throwable
{
}
}

View file

@ -12,12 +12,12 @@ import net.minecraft.item.ItemStack;
import appeng.client.gui.implementations.GuiCraftingTerm;
import appeng.integration.IIntegrationModule;
import appeng.integration.abstraction.INEI;
import appeng.integration.modules.helpers.NEIAEShapedRecipeHandler;
import appeng.integration.modules.helpers.NEIAEShapelessRecipeHandler;
import appeng.integration.modules.helpers.NEICraftingHandler;
import appeng.integration.modules.helpers.NEIGrinderRecipeHandler;
import appeng.integration.modules.helpers.NEIInscriberRecipeHandler;
import appeng.integration.modules.helpers.NEIWorldCraftingHandler;
import appeng.integration.modules.NEIHelpers.NEIAEShapedRecipeHandler;
import appeng.integration.modules.NEIHelpers.NEIAEShapelessRecipeHandler;
import appeng.integration.modules.NEIHelpers.NEICraftingHandler;
import appeng.integration.modules.NEIHelpers.NEIGrinderRecipeHandler;
import appeng.integration.modules.NEIHelpers.NEIInscriberRecipeHandler;
import appeng.integration.modules.NEIHelpers.NEIWorldCraftingHandler;
import codechicken.nei.guihook.GuiContainerManager;
public class NEI implements IIntegrationModule, INEI

View file

@ -1,4 +1,4 @@
package appeng.integration.modules.helpers;
package appeng.integration.modules.NEIHelpers;
import java.awt.Rectangle;
import java.util.ArrayList;

View file

@ -1,4 +1,4 @@
package appeng.integration.modules.helpers;
package appeng.integration.modules.NEIHelpers;
import java.awt.Rectangle;
import java.util.ArrayList;

View file

@ -1,4 +1,4 @@
package appeng.integration.modules.helpers;
package appeng.integration.modules.NEIHelpers;
import java.util.List;

View file

@ -1,4 +1,4 @@
package appeng.integration.modules.helpers;
package appeng.integration.modules.NEIHelpers;
import static codechicken.lib.gui.GuiDraw.changeTexture;
import static codechicken.lib.gui.GuiDraw.drawTexturedModalRect;

View file

@ -1,4 +1,4 @@
package appeng.integration.modules.helpers;
package appeng.integration.modules.NEIHelpers;
import static codechicken.lib.gui.GuiDraw.changeTexture;
import static codechicken.lib.gui.GuiDraw.drawTexturedModalRect;

View file

@ -1,4 +1,4 @@
package appeng.integration.modules.helpers;
package appeng.integration.modules.NEIHelpers;
import java.util.ArrayList;
import java.util.HashMap;

View file

@ -0,0 +1,7 @@
package appeng.integration.modules.helpers;
public class MJBattery
{
}

View file

@ -41,7 +41,7 @@ public class MJPerdition extends BaseMJperdition
}
@Override
public double useEnergy(float min, float max, boolean doUse)
public double useEnergy(double min, double max, boolean doUse)
{
return bcPowerHandler.useEnergy( min, max, doUse );
}

View file

@ -27,6 +27,8 @@ import appeng.facade.FacadePart;
import appeng.facade.IFacadeItem;
import appeng.items.AEBaseItem;
import appeng.util.Platform;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.GameRegistry.UniqueIdentifier;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@ -158,6 +160,9 @@ public class ItemFacade extends AEBaseItem implements IFacadeItem, IAlphaPassIte
ds[0] = Item.getIdFromItem( l.getItem() );
ds[1] = metadata;
data.setIntArray( "x", ds );
UniqueIdentifier ui = GameRegistry.findUniqueIdentifierFor( l.getItem() );
data.setString( "modid", ui.modId );
data.setString( "itemname", ui.name );
is.setTagCompound( data );
return is;
}
@ -170,9 +175,16 @@ public class ItemFacade extends AEBaseItem implements IFacadeItem, IAlphaPassIte
NBTTagCompound data = is.getTagCompound();
if ( data != null )
{
int[] blk = data.getIntArray( "x" );
if ( blk != null && blk.length == 2 )
return Block.getBlockById( blk[0] );
if ( data.hasKey( "modid" ) && data.hasKey( "itemname" ) )
{
return GameRegistry.findBlock( data.getString( "modid" ), data.getString( "itemname" ) );
}
else
{
int[] blk = data.getIntArray( "x" );
if ( blk != null && blk.length == 2 )
return Block.getBlockById( blk[0] );
}
}
return Blocks.glass;
}
@ -213,9 +225,14 @@ public class ItemFacade extends AEBaseItem implements IFacadeItem, IAlphaPassIte
public boolean useAlphaPass(ItemStack is)
{
ItemStack out = getTextureItem( is );
if ( out == null || out.getItem() == null )
return false;
Block blk = Block.getBlockFromItem( out.getItem() );
if ( blk != null && blk.canRenderInPass( 1 ) )
return true;
return false;
}

View file

@ -10,7 +10,9 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import net.minecraftforge.client.MinecraftForgeClient;
import appeng.api.config.SecurityPermissions;
import appeng.api.features.IPlayerRegistry;
import appeng.api.implementations.items.IBiometricCard;
import appeng.api.networking.security.ISecurityRegister;
import appeng.client.render.items.ToolBiometricCardRender;
import appeng.core.features.AEFeature;
import appeng.core.localization.GuiText;
@ -148,4 +150,9 @@ public class ToolBiometricCard extends AEBaseItem implements IBiometricCard
tag.setBoolean( permission.name(), true );
}
@Override
public void registerPermissions(ISecurityRegister register, IPlayerRegistry pr, ItemStack is)
{
register.addPlayer( pr.getID( getUsername( is ) ), getPermissions( is ) );
}
}

View file

@ -15,14 +15,14 @@ import appeng.api.networking.IGridStorage;
import appeng.api.networking.events.MENetworkEventSubscribe;
import appeng.api.networking.events.MENetworkSecurityChange;
import appeng.api.networking.security.ISecurityGrid;
import appeng.api.networking.security.ISecurityProvider;
import appeng.core.WorldSettings;
import appeng.me.GridNode;
import appeng.tile.misc.TileSecurity;
public class SecurityCache implements IGridCache, ISecurityGrid
{
private List<TileSecurity> securityProvider = new ArrayList();
private List<ISecurityProvider> securityProvider = new ArrayList();
private HashMap<Integer, EnumSet<SecurityPermissions>> playerPerms = new HashMap<Integer, EnumSet<SecurityPermissions>>();
public SecurityCache(IGrid g) {
@ -84,7 +84,7 @@ public class SecurityCache implements IGridCache, ISecurityGrid
long lastCode = securityKey;
if ( securityProvider.size() == 1 )
securityKey = securityProvider.get( 0 ).securityKey;
securityKey = securityProvider.get( 0 ).getSecurityKey();
else
securityKey = -1;
@ -99,9 +99,9 @@ public class SecurityCache implements IGridCache, ISecurityGrid
@Override
public void removeNode(IGridNode gridNode, IGridHost machine)
{
if ( machine instanceof TileSecurity )
if ( machine instanceof ISecurityProvider )
{
securityProvider.remove( (TileSecurity) machine );
securityProvider.remove( (ISecurityProvider) machine );
updateSecurityKey();
}
}
@ -109,9 +109,9 @@ public class SecurityCache implements IGridCache, ISecurityGrid
@Override
public void addNode(IGridNode gridNode, IGridHost machine)
{
if ( machine instanceof TileSecurity )
if ( machine instanceof ISecurityProvider )
{
securityProvider.add( (TileSecurity) machine );
securityProvider.add( (ISecurityProvider) machine );
updateSecurityKey();
}
else

View file

@ -3,7 +3,6 @@ package appeng.me.cache;
import java.util.HashMap;
import java.util.PriorityQueue;
import net.minecraft.tileentity.TileEntity;
import appeng.api.networking.IGrid;
import appeng.api.networking.IGridHost;
import appeng.api.networking.IGridNode;
@ -12,7 +11,6 @@ import appeng.api.networking.ticking.IGridTickable;
import appeng.api.networking.ticking.ITickManager;
import appeng.api.networking.ticking.TickRateModulation;
import appeng.api.networking.ticking.TickingRequest;
import appeng.core.AELog;
import appeng.me.cache.helpers.TickTracker;
public class TickManagerCache implements ITickManager
@ -170,9 +168,6 @@ public class TickManagerCache implements ITickManager
TickingRequest tr = ((IGridTickable) machine).getTickingRequest( gridNode );
if ( tr != null )
{
if ( machine instanceof TileEntity && ((TileEntity) machine).canUpdate() )
AELog.warning( "Tile: " + machine.getClass().getName() + " - reports to use MC ticking, but also requests Network Based Ticking." );
TickTracker tt = new TickTracker( tr, gridNode, (IGridTickable) machine, currentTick, this );
if ( tr.canBeAlerted )

View file

@ -79,6 +79,23 @@ public class CableBusContainer implements AEMultiTile, ICableBusContainer
return sides[side.ordinal()];
}
public void rotateLeft()
{
IPart newSides[] = new IPart[6];
newSides[ForgeDirection.UP.ordinal()] = sides[ForgeDirection.UP.ordinal()];
newSides[ForgeDirection.DOWN.ordinal()] = sides[ForgeDirection.DOWN.ordinal()];
newSides[ForgeDirection.EAST.ordinal()] = sides[ForgeDirection.NORTH.ordinal()];
newSides[ForgeDirection.SOUTH.ordinal()] = sides[ForgeDirection.EAST.ordinal()];
newSides[ForgeDirection.WEST.ordinal()] = sides[ForgeDirection.SOUTH.ordinal()];
newSides[ForgeDirection.NORTH.ordinal()] = sides[ForgeDirection.WEST.ordinal()];
sides = newSides;
fc.rotateLeft();
}
public void updateDynamicRender()
{
requiresDynamicRender = false;

View file

@ -15,9 +15,16 @@ import appeng.api.networking.ticking.TickRateModulation;
import appeng.api.networking.ticking.TickingRequest;
import appeng.core.AppEng;
import appeng.core.settings.TickRates;
import appeng.integration.abstraction.IMJ5;
import appeng.integration.abstraction.helpers.BaseMJperdition;
import appeng.me.GridAccessException;
import appeng.me.cache.helpers.TunnelCollection;
import appeng.transformer.annotations.integration.Interface;
import appeng.transformer.annotations.integration.InterfaceList;
import appeng.transformer.annotations.integration.Method;
import buildcraft.api.mj.IBatteryObject;
import buildcraft.api.mj.ISidedBatteryProvider;
import buildcraft.api.mj.MjAPI;
import buildcraft.api.power.IPowerReceptor;
import buildcraft.api.power.PowerHandler;
import buildcraft.api.power.PowerHandler.PowerReceiver;
@ -25,11 +32,13 @@ import buildcraft.api.power.PowerHandler.Type;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@Interface(iface = "buildcraft.api.power.IPowerReceptor", iname = "BC")
public class PartP2PBCPower extends PartP2PTunnel<PartP2PBCPower> implements IPowerReceptor, IGridTickable
@InterfaceList(value = { @Interface(iface = "buildcraft.api.mj.ISidedBatteryProvider", iname = "MJ6"),
@Interface(iface = "buildcraft.api.mj.IBatteryObject", iname = "MJ6"), @Interface(iface = "buildcraft.api.power.IPowerReceptor", iname = "MJ5"),
@Interface(iface = "appeng.api.networking.ticking.IGridTickable", iname = "MJ5") })
public class PartP2PBCPower extends PartP2PTunnel<PartP2PBCPower> implements IPowerReceptor, ISidedBatteryProvider, IBatteryObject, IGridTickable
{
PowerHandler pp;
BaseMJperdition pp;
public TunnelType getTunnelType()
{
@ -39,20 +48,26 @@ public class PartP2PBCPower extends PartP2PTunnel<PartP2PBCPower> implements IPo
public PartP2PBCPower(ItemStack is) {
super( is );
if ( !AppEng.instance.isIntegrationEnabled( "MJ" ) )
if ( !AppEng.instance.isIntegrationEnabled( "MJ5" ) && !AppEng.instance.isIntegrationEnabled( "MJ6" ) )
throw new RuntimeException( "MJ Not installed!" );
pp = new PowerHandler( this, Type.MACHINE );
pp.configure( 1f, 320f, 800f, 640f );
if ( AppEng.instance.isIntegrationEnabled( "MJ5" ) )
{
pp = (BaseMJperdition) ((IMJ5) AppEng.instance.getIntegration( "MJ5" )).createPerdition( this );
if ( pp != null )
pp.configure( 1, 380, 1.0f / 5.0f, 1000 );
}
}
@Override
@Method(iname = "MJ5")
public TickingRequest getTickingRequest(IGridNode node)
{
return new TickingRequest( TickRates.MJTunnel.min, TickRates.MJTunnel.max, false, false );
}
@Override
@Method(iname = "MJ5")
public TickRateModulation tickingRequest(IGridNode node, int TicksSinceLastCall)
{
if ( !output && proxy.isActive() )
@ -93,7 +108,7 @@ public class PartP2PBCPower extends PartP2PTunnel<PartP2PBCPower> implements IPo
if ( totalRequiredPower < 0.1 )
return TickRateModulation.SLOWER;
double currentTotal = pp.getEnergyStored();
double currentTotal = pp.getPowerReceiver().getEnergyStored();
if ( currentTotal < 0.01 )
return TickRateModulation.SLOWER;
@ -105,8 +120,8 @@ public class PartP2PBCPower extends PartP2PTunnel<PartP2PBCPower> implements IPo
PowerReceiver tp = target.getPowerReceiver( side.getOpposite() );
if ( tp != null )
{
double howmuch = tp.powerRequest(); // orientation.getOpposite()
// );
double howmuch = tp.powerRequest();
if ( howmuch > tp.getMaxEnergyReceived() )
howmuch = tp.getMaxEnergyReceived();
@ -133,6 +148,16 @@ public class PartP2PBCPower extends PartP2PTunnel<PartP2PBCPower> implements IPo
return 0.5f;
};
@Method(iname = "MJ6")
private IBatteryObject getTargetBattery()
{
TileEntity te = getWorld().getTileEntity( tile.xCoord + side.offsetX, tile.yCoord + side.offsetY, tile.zCoord + side.offsetZ );
if ( te != null )
return MjAPI.getMjBattery( te );
return null;
}
@Method(iname = "MJ5")
private IPowerReceptor getPowerTarget()
{
TileEntity te = getWorld().getTileEntity( tile.xCoord + side.offsetX, tile.yCoord + side.offsetY, tile.zCoord + side.offsetZ );
@ -148,14 +173,16 @@ public class PartP2PBCPower extends PartP2PTunnel<PartP2PBCPower> implements IPo
public void writeToNBT(NBTTagCompound tag)
{
super.writeToNBT( tag );
pp.writeToNBT( tag );
if ( pp != null )
pp.writeToNBT( tag );
}
@Override
public void readFromNBT(NBTTagCompound tag)
{
super.readFromNBT( tag );
pp.readFromNBT( tag );
if ( pp != null )
pp.readFromNBT( tag );
}
@SideOnly(Side.CLIENT)
@ -165,14 +192,16 @@ public class PartP2PBCPower extends PartP2PTunnel<PartP2PBCPower> implements IPo
}
@Override
@Method(iname = "MJ5")
public PowerReceiver getPowerReceiver(ForgeDirection side)
{
if ( side.equals( side ) )
return pp.getPowerReceiver();
return ((BaseMJperdition) pp).getPowerReceiver();
return null;
}
@Override
@Method(iname = "MJ5")
public void doWork(PowerHandler workProvider)
{
@ -184,4 +213,229 @@ public class PartP2PBCPower extends PartP2PTunnel<PartP2PBCPower> implements IPo
return tile.getWorldObj();
}
@Override
@Method(iname = "MJ6")
public IBatteryObject getMjBattery(String kind)
{
return this;
}
@Override
@Method(iname = "MJ6")
public IBatteryObject getMjBattery(String kind, ForgeDirection direction)
{
return this;
}
@Override
@Method(iname = "MJ6")
public double getEnergyRequested()
{
try
{
double totalRequiredPower = 0.0f;
for (PartP2PBCPower g : getOutputs())
{
IBatteryObject o = g.getTargetBattery();
if ( o != null )
totalRequiredPower += o.getEnergyRequested();
}
return totalRequiredPower;
}
catch (GridAccessException e)
{
return 0;
}
}
@Override
@Method(iname = "MJ6")
public double addEnergy(double mj)
{
return addEnergyInternal( mj, false, false );
}
@Override
@Method(iname = "MJ6")
public double addEnergy(double mj, boolean ignoreCycleLimit)
{
return addEnergyInternal( mj, true, ignoreCycleLimit );
}
@Method(iname = "MJ6")
private double addEnergyInternal(double mj, boolean cycleLimitMode, boolean ignoreCycleLimit)
{
if ( !output && proxy.isActive() )
return 0;
double originaInput = mj;
try
{
TunnelCollection<PartP2PBCPower> outs = getOutputs();
double outputs = 0;
for (PartP2PBCPower g : outs)
{
IBatteryObject o = g.getTargetBattery();
if ( o != null )
{
outputs = outputs + 1.0;
}
}
if ( outputs < 0.0000001 )
return 0;
for (PartP2PBCPower g : outs)
{
IBatteryObject o = g.getTargetBattery();
if ( o != null )
{
double fraction = originaInput / outputs;
if ( cycleLimitMode )
fraction = o.addEnergy( fraction );
else
fraction = o.addEnergy( fraction, ignoreCycleLimit );
mj -= fraction;
}
}
if ( mj > 0 )
{
for (PartP2PBCPower g : outs)
{
IBatteryObject o = g.getTargetBattery();
if ( o != null )
{
if ( cycleLimitMode )
mj = mj - o.addEnergy( mj );
else
mj = mj - o.addEnergy( mj, ignoreCycleLimit );
}
}
}
return originaInput - mj;
}
catch (GridAccessException e)
{
return 0;
}
}
@Override
@Method(iname = "MJ6")
public double getEnergyStored()
{
try
{
double totalRequiredPower = 0.0f;
for (PartP2PBCPower g : getOutputs())
{
IBatteryObject o = g.getTargetBattery();
if ( o != null )
totalRequiredPower += o.getEnergyStored();
}
return totalRequiredPower;
}
catch (GridAccessException e)
{
return 0;
}
}
@Override
@Method(iname = "MJ6")
public void setEnergyStored(double mj)
{
// EHh?!
}
@Override
public double maxCapacity()
{
try
{
double totalRequiredPower = 0.0f;
for (PartP2PBCPower g : getOutputs())
{
IBatteryObject o = g.getTargetBattery();
if ( o != null )
totalRequiredPower += o.maxCapacity();
}
return totalRequiredPower;
}
catch (GridAccessException e)
{
return 0;
}
}
@Override
@Method(iname = "MJ6")
public double minimumConsumption()
{
try
{
double totalRequiredPower = 1000000000000.0;
for (PartP2PBCPower g : getOutputs())
{
IBatteryObject o = g.getTargetBattery();
if ( o != null )
totalRequiredPower = Math.min( totalRequiredPower, o.minimumConsumption() );
}
return totalRequiredPower;
}
catch (GridAccessException e)
{
return 0;
}
}
@Override
@Method(iname = "MJ6")
public double maxReceivedPerCycle()
{
try
{
double totalRequiredPower = 1000000.0;
for (PartP2PBCPower g : getOutputs())
{
IBatteryObject o = g.getTargetBattery();
if ( o != null )
totalRequiredPower = Math.min( totalRequiredPower, o.maxReceivedPerCycle() );
}
return totalRequiredPower;
}
catch (GridAccessException e)
{
return 0;
}
}
@Override
@Method(iname = "MJ6")
public IBatteryObject reconfigure(double maxCapacity, double maxReceivedPerCycle, double minimumConsumption)
{
return this;
}
@Override
@Method(iname = "MJ6")
public String kind()
{
return "tunnel";
}
}

View file

@ -8,8 +8,8 @@ import java.util.Date;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import appeng.core.AELog;
import appeng.core.AEConfig;
import appeng.core.AELog;
public class VersionChecker implements Runnable
{

View file

@ -111,6 +111,22 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
h.Tick();
}
@Override
public void onChunkUnload()
{
if ( !isInvalid() )
invalidate();
}
/**
* for dormant chunk cache.
*/
public void onChunkLoad()
{
if ( isInvalid() )
validate();
}
@Override
// NOTE: WAS FINAL, changed for Immibis
public void writeToNBT(NBTTagCompound data)
@ -322,12 +338,8 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
for (int l = 0; l < inv.getSizeInventory(); l++)
{
ItemStack is = inv.getStackInSlot( l );
if ( is != null )
{
drops.add( is );
inv.setInventorySlotContents( l, (ItemStack) null );
}
}
}

View file

@ -191,10 +191,7 @@ public class TileCellWorkbench extends AEBaseTile implements IUpgradeableHost, I
super.getDrops( w, x, y, z, drops );
if ( cell.getStackInSlot( 0 ) != null )
{
drops.add( cell.getStackInSlot( 0 ) );
cell.setInventorySlotContents( 0, null );
}
}
public ICellWorkbenchItem getCell()

View file

@ -31,6 +31,7 @@ import appeng.api.networking.events.MENetworkChannelsChanged;
import appeng.api.networking.events.MENetworkEventSubscribe;
import appeng.api.networking.events.MENetworkPowerStatusChange;
import appeng.api.networking.events.MENetworkSecurityChange;
import appeng.api.networking.security.ISecurityProvider;
import appeng.api.storage.IMEInventoryHandler;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.ITerminalHost;
@ -40,6 +41,7 @@ import appeng.api.storage.data.IAEItemStack;
import appeng.api.util.AECableType;
import appeng.api.util.DimensionalCoord;
import appeng.api.util.IConfigManager;
import appeng.helpers.PlayerSecuirtyWrapper;
import appeng.me.GridAccessException;
import appeng.me.storage.SecurityInventory;
import appeng.tile.events.AETileEventHandler;
@ -53,7 +55,7 @@ import appeng.util.IConfigManagerHost;
import appeng.util.Platform;
import appeng.util.item.AEItemStack;
public class TileSecurity extends AENetworkTile implements ITerminalHost, IAEAppEngInventory, ILocatable, IConfigManagerHost
public class TileSecurity extends AENetworkTile implements ITerminalHost, IAEAppEngInventory, ILocatable, IConfigManagerHost, ISecurityProvider
{
private static int diffrence = 0;
@ -205,7 +207,7 @@ public class TileSecurity extends AENetworkTile implements ITerminalHost, IAEApp
if ( i instanceof IBiometricCard )
{
IBiometricCard bc = (IBiometricCard) i;
playerPerms.put( pr.getID( bc.getUsername( is ) ), bc.getPermissions( is ) );
bc.registerPermissions( new PlayerSecuirtyWrapper( playerPerms ), pr, is );
}
}
@ -306,4 +308,10 @@ public class TileSecurity extends AENetworkTile implements ITerminalHost, IAEApp
}
@Override
public long getSecurityKey()
{
return securityKey;
}
}

View file

@ -13,7 +13,7 @@ import appeng.transformer.annotations.integration.Interface;
import appeng.util.Platform;
@Interface(iname = "IC2", iface = "ic2.api.energy.tile.IEnergySink")
public abstract class IC2 extends MinecraftJoules implements IEnergySink
public abstract class IC2 extends MinecraftJoules6 implements IEnergySink
{
boolean isInIC2 = false;

View file

@ -4,7 +4,7 @@ import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.config.PowerUnits;
import appeng.core.AppEng;
import appeng.integration.abstraction.IMJ;
import appeng.integration.abstraction.IMJ5;
import appeng.integration.abstraction.helpers.BaseMJperdition;
import appeng.transformer.annotations.integration.Interface;
import appeng.transformer.annotations.integration.Method;
@ -13,20 +13,20 @@ import buildcraft.api.power.IPowerReceptor;
import buildcraft.api.power.PowerHandler;
import buildcraft.api.power.PowerHandler.PowerReceiver;
@Interface(iname = "BC", iface = "buildcraft.api.power.IPowerReceptor")
public abstract class MinecraftJoules extends AERootPoweredTile implements IPowerReceptor
@Interface(iname = "MJ5", iface = "buildcraft.api.power.IPowerReceptor")
public abstract class MinecraftJoules5 extends AERootPoweredTile implements IPowerReceptor
{
BaseMJperdition bcPowerWrapper;
public MinecraftJoules() {
public MinecraftJoules5() {
if ( Platform.isServer() )
{
try
{
if ( AppEng.instance.isIntegrationEnabled( "MJ" ) )
if ( AppEng.instance.isIntegrationEnabled( "MJ5" ) )
{
IMJ mjIntegration = (IMJ) AppEng.instance.getIntegration( "MJ" );
IMJ5 mjIntegration = (IMJ5) AppEng.instance.getIntegration( "MJ5" );
if ( mjIntegration != null )
{
addNewHandler( bcPowerWrapper = (BaseMJperdition) mjIntegration.createPerdition( this ) );
@ -43,7 +43,7 @@ public abstract class MinecraftJoules extends AERootPoweredTile implements IPowe
}
@Override
@Method(iname = "BC")
@Method(iname = "MJ5")
final public PowerReceiver getPowerReceiver(ForgeDirection side)
{
if ( internalCanAcceptPower && getPowerSides().contains( side ) && bcPowerWrapper != null )
@ -52,7 +52,7 @@ public abstract class MinecraftJoules extends AERootPoweredTile implements IPowe
}
@Override
@Method(iname = "BC")
@Method(iname = "MJ5")
final public void doWork(PowerHandler workProvider)
{
float requred = (float) getExternalPowerDemand( PowerUnits.MJ );
@ -62,7 +62,7 @@ public abstract class MinecraftJoules extends AERootPoweredTile implements IPowe
}
@Override
@Method(iname = "BC")
@Method(iname = "MJ5")
final public World getWorld()
{
return worldObj;

View file

@ -0,0 +1,94 @@
package appeng.tile.powersink;
import appeng.api.config.PowerUnits;
import appeng.transformer.annotations.integration.Interface;
import appeng.transformer.annotations.integration.InterfaceList;
import appeng.transformer.annotations.integration.Method;
import buildcraft.api.mj.IBatteryObject;
import buildcraft.api.mj.IBatteryProvider;
@InterfaceList(value = { @Interface(iname = "MJ6", iface = "buildcraft.api.mj.IBatteryProvider"),
@Interface(iname = "MJ6", iface = "buildcraft.api.mj.IBatteryObject") })
public abstract class MinecraftJoules6 extends MinecraftJoules5 implements IBatteryProvider, IBatteryObject
{
@Override
@Method(iname = "MJ6")
public String kind()
{
return null;
}
@Override
@Method(iname = "MJ6")
public double getEnergyRequested()
{
return getExternalPowerDemand( PowerUnits.MJ );
}
@Override
@Method(iname = "MJ6")
public double addEnergy(double amount)
{
double overflow = injectExternalPower( PowerUnits.MJ, amount );
return amount - overflow;
}
@Override
@Method(iname = "MJ6")
public double addEnergy(double amount, boolean ignoreCycleLimit)
{
double overflow = injectExternalPower( PowerUnits.MJ, amount );
return amount - overflow;
}
@Override
@Method(iname = "MJ6")
public double getEnergyStored()
{
return PowerUnits.AE.convertTo( PowerUnits.MJ, internalCurrentPower );
}
@Override
@Method(iname = "MJ6")
public void setEnergyStored(double mj)
{
internalCurrentPower = PowerUnits.MJ.convertTo( PowerUnits.AE, mj );
}
@Override
@Method(iname = "MJ6")
public double maxCapacity()
{
return PowerUnits.AE.convertTo( PowerUnits.MJ, internalMaxPower );
}
@Override
@Method(iname = "MJ6")
public double minimumConsumption()
{
return 0.1;
}
@Override
@Method(iname = "MJ6")
public double maxReceivedPerCycle()
{
return 999999.0;
}
@Override
@Method(iname = "MJ6")
public IBatteryObject reconfigure(double maxCapacity, double maxReceivedPerCycle, double minimumConsumption)
{
return getMjBattery( "" );
}
@Override
@Method(iname = "MJ6")
public IBatteryObject getMjBattery(String kind)
{
return this;
}
}

View file

@ -35,7 +35,8 @@ public class ASMIntegration implements IClassTransformer
// integrationModules.add( IntegrationSide.BOTH, "Thermal Expansion", "ThermalExpansion", "TE" );
// integrationModules.add( IntegrationSide.BOTH, "Mystcraft", "Mystcraft", "Mystcraft" );
integrationModules.add( IntegrationSide.BOTH, "BuildCraft", "BuildCraft|Silicon", "BC" );
integrationModules.add( IntegrationSide.BOTH, "BuildCraft Power", null, "MJ" );
integrationModules.add( IntegrationSide.BOTH, "BuildCraft5 Power", null, "MJ5" );
integrationModules.add( IntegrationSide.BOTH, "BuildCraft6 Power", null, "MJ6" );
integrationModules.add( IntegrationSide.BOTH, "RedstoneFlux Power", null, "RF" );
// integrationModules.add( IntegrationSide.BOTH, "Greg Tech", "gregtech_addon", "GT" );
// integrationModules.add( IntegrationSide.BOTH, "Universal Electricity", null, "UE" );

View file

@ -18,7 +18,6 @@ import appeng.util.inv.ItemSlot;
import appeng.util.inv.WrapperMCISidedInventory;
import buildcraft.api.inventory.ISpecialInventory;
@SuppressWarnings("deprecation")
public abstract class InventoryAdaptor implements Iterable<ItemSlot>
{

View file

@ -9,7 +9,6 @@ import appeng.api.config.FuzzyMode;
import appeng.util.InventoryAdaptor;
import buildcraft.api.inventory.ISpecialInventory;
@SuppressWarnings("deprecation")
public class AdaptorISpecialInventory extends InventoryAdaptor
{