2013-12-27 23:59:59 +01:00
|
|
|
package appeng.parts;
|
|
|
|
|
|
|
|
import java.io.DataInputStream;
|
|
|
|
import java.io.DataOutputStream;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.util.EnumSet;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Random;
|
|
|
|
|
|
|
|
import net.minecraft.client.renderer.RenderBlocks;
|
|
|
|
import net.minecraft.entity.Entity;
|
2013-12-28 21:54:05 +01:00
|
|
|
import net.minecraft.entity.EntityLivingBase;
|
2013-12-27 23:59:59 +01:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
2013-12-30 06:57:08 +01:00
|
|
|
import net.minecraft.inventory.IInventory;
|
2013-12-27 23:59:59 +01:00
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.nbt.NBTTagCompound;
|
|
|
|
import net.minecraft.tileentity.TileEntity;
|
|
|
|
import net.minecraft.util.Vec3;
|
|
|
|
import net.minecraft.world.World;
|
|
|
|
import net.minecraftforge.common.ForgeDirection;
|
2013-12-30 06:57:08 +01:00
|
|
|
import appeng.api.config.Upgrades;
|
|
|
|
import appeng.api.implementations.IBusCommon;
|
2013-12-27 23:59:59 +01:00
|
|
|
import appeng.api.networking.IGridHost;
|
|
|
|
import appeng.api.networking.IGridNode;
|
|
|
|
import appeng.api.parts.IPart;
|
|
|
|
import appeng.api.parts.IPartCollsionHelper;
|
|
|
|
import appeng.api.parts.IPartHost;
|
|
|
|
import appeng.api.parts.IPartRenderHelper;
|
2014-01-20 17:41:37 +01:00
|
|
|
import appeng.api.parts.PartItemStack;
|
2013-12-27 23:59:59 +01:00
|
|
|
import appeng.api.util.AECableType;
|
|
|
|
import appeng.api.util.AEColor;
|
|
|
|
import appeng.api.util.DimensionalCoord;
|
2013-12-30 06:57:08 +01:00
|
|
|
import appeng.api.util.IConfigManager;
|
2013-12-27 23:59:59 +01:00
|
|
|
import appeng.me.helpers.AENetworkProxy;
|
|
|
|
import appeng.me.helpers.IGridProxyable;
|
|
|
|
import appeng.parts.networking.PartCable;
|
|
|
|
|
2013-12-30 06:57:08 +01:00
|
|
|
public class AEBasePart implements IPart, IGridProxyable, IGridHost, IBusCommon
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
|
|
|
|
|
|
|
protected AENetworkProxy proxy = new AENetworkProxy( this, "part", this instanceof PartCable );
|
|
|
|
protected TileEntity tile = null;
|
|
|
|
protected IPartHost host = null;
|
|
|
|
protected ForgeDirection side = null;
|
|
|
|
|
|
|
|
protected final ItemStack is;
|
|
|
|
|
|
|
|
public AEBasePart(Class c, ItemStack is) {
|
|
|
|
this.is = is;
|
|
|
|
proxy.setValidSides( EnumSet.noneOf( ForgeDirection.class ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void renderInventory(IPartRenderHelper rh, RenderBlocks renderer)
|
|
|
|
{
|
|
|
|
rh.setBounds( 1, 1, 1, 15, 15, 15 );
|
|
|
|
rh.renderInventoryBox( renderer );
|
|
|
|
|
|
|
|
rh.setBounds( 1, 1, 1, 15, 15, 15 );
|
|
|
|
rh.renderInventoryBox( renderer );
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void renderStatic(int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer)
|
|
|
|
{
|
|
|
|
rh.setBounds( 1, 1, 1, 15, 15, 15 );
|
|
|
|
rh.renderBlock( x, y, z, renderer );
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void renderDynamic(double x, double y, double z, IPartRenderHelper rh, RenderBlocks renderer)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-01-20 17:41:37 +01:00
|
|
|
public ItemStack getItemStack(PartItemStack type)
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
|
|
|
return is;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isSolid()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onNeighborChanged()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean canConnectRedstone()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-01-05 09:46:54 +01:00
|
|
|
public void readFromNBT(NBTTagCompound data)
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2014-01-05 09:46:54 +01:00
|
|
|
proxy.readFromNBT( data );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-01-05 09:46:54 +01:00
|
|
|
public void writeToNBT(NBTTagCompound data)
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2014-01-05 09:46:54 +01:00
|
|
|
proxy.writeToNBT( data );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int isProvidingStrongPower()
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int isProvidingWeakPower()
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void writeToStream(DataOutputStream data) throws IOException
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean readFromStream(DataInputStream data) throws IOException
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public IGridNode getGridNode()
|
|
|
|
{
|
|
|
|
return proxy.getNode();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onEntityCollision(Entity entity)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void removeFromWorld()
|
|
|
|
{
|
|
|
|
proxy.invalidate();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void addToWorld()
|
|
|
|
{
|
|
|
|
proxy.onReady();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void setPartHostInfo(ForgeDirection side, IPartHost host, TileEntity tile)
|
|
|
|
{
|
|
|
|
this.side = side;
|
|
|
|
this.tile = tile;
|
|
|
|
this.host = host;
|
|
|
|
}
|
|
|
|
|
|
|
|
public IPartHost getHost()
|
|
|
|
{
|
|
|
|
return host;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public IGridNode getExternalFacingNode()
|
|
|
|
{
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public IGridNode getGridNode(ForgeDirection dir)
|
|
|
|
{
|
|
|
|
return proxy.getNode();
|
|
|
|
}
|
|
|
|
|
|
|
|
protected AEColor getColor()
|
|
|
|
{
|
|
|
|
if ( getHost() == null )
|
|
|
|
return AEColor.Transparent;
|
|
|
|
return getHost().getColor();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public DimensionalCoord getLocation()
|
|
|
|
{
|
|
|
|
return new DimensionalCoord( tile );
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void getBoxes(IPartCollsionHelper bch)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void randomDisplayTick(World world, int x, int y, int z, Random r)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getLightLevel()
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean onActivate(EntityPlayer player, Vec3 pos)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public AECableType getCableConnectionType(ForgeDirection dir)
|
|
|
|
{
|
|
|
|
return AECableType.GLASS;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void getDrops(List<ItemStack> drops, boolean wrenched)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int cableConnectionRenderTo()
|
|
|
|
{
|
|
|
|
return 3;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void gridChanged()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-12-28 21:54:05 +01:00
|
|
|
@Override
|
|
|
|
public boolean isLadder(EntityLivingBase entity)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-12-30 06:57:08 +01:00
|
|
|
@Override
|
|
|
|
public IConfigManager getConfigManager()
|
|
|
|
{
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public IInventory getInventoryByName(String name)
|
|
|
|
{
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getInstalledUpgrades(Upgrades u)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-01-20 17:41:37 +01:00
|
|
|
@Override
|
|
|
|
public boolean onShiftActivate(EntityPlayer player, Vec3 pos)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onPlacement(EntityPlayer player, ItemStack held, ForgeDirection side)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|