Merge in Builder support.

This commit is contained in:
AlgorithmX2 2014-05-11 13:48:14 -05:00
commit ce561ffbe3
31 changed files with 393 additions and 50 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

@ -334,7 +334,7 @@ public class BusRenderHelper implements IPartRenderHelper
if ( !renderThis() )
return;
renderer.renderStandardBlock( renderer.blockAccess.getBlock( x, y, z ), x, y, z );
renderer.renderStandardBlock( blk, x, y, z );
}
@Override

View file

@ -419,8 +419,7 @@ public class Registration
}
catch (Throwable e)
{
AELog.severe( "Error with Feature: " + c.getName() );
throw new RuntimeException( e );
throw new RuntimeException( "Error with Feature: " + c.getName(), e );
}
}

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

@ -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

@ -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;
@ -191,6 +200,15 @@ public class BC extends BaseModule implements IBC
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 )
{
@ -201,6 +219,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()
{

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

@ -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

@ -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;
}

View file

@ -19,7 +19,6 @@ import appeng.api.parts.IPart;
import appeng.api.parts.IPartItem;
import appeng.core.AEConfig;
import appeng.core.features.AEFeature;
import appeng.core.features.AEFeatureHandler;
import appeng.core.features.ItemStackSrc;
import appeng.core.localization.GuiText;
import appeng.items.AEBaseItem;
@ -152,7 +151,8 @@ public class OldItemPart extends AEBaseItem implements IPartItem, IItemGroup, II
}
@Override
public String getItemStackDisplayName(ItemStack par1ItemStack) {
public String getItemStackDisplayName(ItemStack par1ItemStack)
{
return "AE2-OLD-PART";
}

View file

@ -5,7 +5,6 @@ import java.util.EnumSet;
import net.minecraft.entity.Entity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraftforge.oredict.OreDictionary;
import appeng.core.AppEng;
import appeng.core.features.AEFeature;
import appeng.entity.EntityChargedQuartz;

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;
@ -575,6 +592,8 @@ public class CableBusContainer implements AEMultiTile, ICableBusContainer
{
byte sides = data.readByte();
boolean updateBlock = false;
for (int x = 0; x < 7; x++)
{
ForgeDirection side = ForgeDirection.getOrientation( x );
@ -589,7 +608,10 @@ public class CableBusContainer implements AEMultiTile, ICableBusContainer
ItemStack current = p != null ? p.getItemStack( PartItemStack.Network ) : null;
if ( current != null && current.getItem() == myItem && current.getItemDamage() == dmgValue )
p.readFromStream( data );
{
if ( p.readFromStream( data ) )
updateBlock = true;
}
else
{
removePart( side, false );
@ -607,7 +629,9 @@ public class CableBusContainer implements AEMultiTile, ICableBusContainer
removePart( side, false );
}
return fc.readFromStream( data );
if ( fc.readFromStream( data ) )
return true;
return updateBlock;
}
ForgeDirection getSide(IPart part)

View file

@ -284,7 +284,7 @@ public class PartCable extends AEBasePart implements IPartCable
int cs = data.readByte();
int sideOut = data.readInt();
EnumSet<ForgeDirection> myC = connections;
EnumSet<ForgeDirection> myC = connections.clone();
boolean wasPowered = powered;
powered = false;
boolean chchanged = false;

View file

@ -322,12 +322,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

@ -174,10 +174,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

@ -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
{