AE2 First Commit, the dawn of 1.7 hast arrived.
This commit is contained in:
@@ -0,0 +1,234 @@
|
||||
package appeng.block.networking;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import appeng.api.parts.SelectedPart;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
import appeng.client.render.blocks.RendererCableBus;
|
||||
import appeng.client.texture.CableBusTextures;
|
||||
import appeng.core.Api;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.integration.abstraction.IFMP;
|
||||
import appeng.parts.CableBusContainer;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.tile.networking.TileCableBus;
|
||||
|
||||
public class BlockCableBus extends AEBaseBlock
|
||||
{
|
||||
|
||||
public BlockCableBus() {
|
||||
super( BlockCableBus.class, Material.glass );
|
||||
setfeature( EnumSet.of( AEFeature.Core ) );
|
||||
setLightOpacity( 0 );
|
||||
isFullSize = isOpaque = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean recolourBlock(World world, int x, int y, int z, ForgeDirection side, int colour)
|
||||
{
|
||||
try
|
||||
{
|
||||
return cb( world, x, y, z ).recolourBlock( side, colour );
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void randomDisplayTick(World world, int x, int y, int z, Random r)
|
||||
{
|
||||
CableBusContainer cb = cb( world, x, y, z );
|
||||
if ( cb != null )
|
||||
cb.randomDisplayTick( world, x, y, z, r );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLightValue(IBlockAccess world, int x, int y, int z)
|
||||
{
|
||||
CableBusContainer cb = cb( world, x, y, z );
|
||||
if ( cb != null )
|
||||
return cb.getLightValue();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z)
|
||||
{
|
||||
Vec3 v3 = target.hitVec.addVector( -x, -y, -z );
|
||||
SelectedPart sp = cb( world, x, y, z ).selectPart( v3 );
|
||||
if ( sp != null )
|
||||
{
|
||||
if ( sp.part != null )
|
||||
return sp.part.getItemStack( false );
|
||||
if ( sp.facade != null )
|
||||
return sp.facade.getItemStack();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBlockReplaceable(World world, int x, int y, int z)
|
||||
{
|
||||
return cb( world, x, y, z ).isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeBlockByPlayer(World world, EntityPlayer player, int x, int y, int z)
|
||||
{
|
||||
if ( player.capabilities.isCreativeMode )
|
||||
{
|
||||
AEBaseTile tile = getTileEntity( world, x, y, z );
|
||||
if ( tile != null )
|
||||
tile.dropItems = false;
|
||||
// maybe ray trace?
|
||||
}
|
||||
return super.removeBlockByPlayer( world, player, x, y, z );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getBlockTexture(IBlockAccess w, int x, int y, int z, int s)
|
||||
{
|
||||
return getIcon( s, 0 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getIcon(int direction, int metadata)
|
||||
{
|
||||
Icon i = super.getIcon( direction, metadata );
|
||||
if ( i != null )
|
||||
return i;
|
||||
return CableBusTextures.getMissing();
|
||||
}
|
||||
|
||||
private CableBusContainer cb(IBlockAccess w, int x, int y, int z)
|
||||
{
|
||||
TileEntity te = w.getBlockTileEntity( x, y, z );
|
||||
if ( te instanceof TileCableBus )
|
||||
return ((TileCableBus) te).cb;
|
||||
|
||||
if ( AppEng.instance.isIntegrationEnabled( "FMP" ) )
|
||||
return ((IFMP) AppEng.instance.getIntegration( "FMP" )).getCableContainer( te );
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<? extends BaseBlockRender> getRenderer()
|
||||
{
|
||||
return RendererCableBus.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons(IconRegister iconRegistry)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private int rs(int side)
|
||||
{
|
||||
int s = 0;
|
||||
switch (side)
|
||||
{
|
||||
case -1:
|
||||
s = 1;
|
||||
break;
|
||||
case 1:
|
||||
s = 2;
|
||||
break;
|
||||
case 2:
|
||||
s = 5;
|
||||
break;
|
||||
case 3:
|
||||
s = 3;
|
||||
break;
|
||||
case 4:
|
||||
s = 4;
|
||||
break;
|
||||
default:
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProvidePower()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBlockSolidOnSide(World w, int x, int y, int z, ForgeDirection side)
|
||||
{
|
||||
return cb( w, x, y, z ).isSolidOnSide( side );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange(World w, int x, int y, int z, int meh)
|
||||
{
|
||||
cb( w, x, y, z ).onNeighborChanged();
|
||||
// kinda works
|
||||
/*
|
||||
* if ( cb( w, x, y, z ).isEmpty() ) { w.setBlockToAir( x, y, z ); }
|
||||
*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActivated(World w, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
return cb( w, x, y, z ).activate( player, w.getWorldVec3Pool().getVecFromPool( hitX, hitY, hitZ ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCollidedWithBlock(World w, int x, int y, int z, Entity e)
|
||||
{
|
||||
cb( w, x, y, z ).onEntityCollision( e );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectRedstone(IBlockAccess w, int x, int y, int z, int side)
|
||||
{
|
||||
return cb( w, x, y, z ).canConnectRedstone( ForgeDirection.getOrientation( rs( side ) ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int isProvidingWeakPower(IBlockAccess w, int x, int y, int z, int side)
|
||||
{
|
||||
return cb( w, x, y, z ).isProvidingWeakPower( ForgeDirection.getOrientation( side ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int isProvidingStrongPower(IBlockAccess w, int x, int y, int z, int side)
|
||||
{
|
||||
return cb( w, x, y, z ).isProvidingStrongPower( ForgeDirection.getOrientation( side ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void setupTile()
|
||||
{
|
||||
setTileEntiy( Api.instance.partHelper.getCombinedInstance( TileCableBus.class.getName() ) );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package appeng.block.networking;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.world.World;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
import appeng.client.render.blocks.RenderBlockController;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.tile.networking.TileController;
|
||||
|
||||
public class BlockController extends AEBaseBlock
|
||||
{
|
||||
|
||||
public BlockController() {
|
||||
super( BlockController.class, Material.iron );
|
||||
setfeature( EnumSet.of( AEFeature.Core ) );
|
||||
setTileEntiy( TileController.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange(World w, int x, int y, int z, int id_junk)
|
||||
{
|
||||
TileController tc = getTileEntity( w, x, y, z );
|
||||
if ( tc != null )
|
||||
tc.onNeighborChange( false );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<? extends BaseBlockRender> getRenderer()
|
||||
{
|
||||
return RenderBlockController.class;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package appeng.block.networking;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.tile.networking.TileCreativeEnergyCell;
|
||||
|
||||
public class BlockCreativeEnergyCell extends AEBaseBlock
|
||||
{
|
||||
|
||||
public BlockCreativeEnergyCell() {
|
||||
super( BlockCreativeEnergyCell.class, Material.glass );
|
||||
setfeature( EnumSet.of( AEFeature.Creative ) );
|
||||
setTileEntiy( TileCreativeEnergyCell.class );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package appeng.block.networking;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.util.Icon;
|
||||
import appeng.client.texture.ExtraTextures;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.tile.networking.TileDenseEnergyCell;
|
||||
|
||||
public class BlockDenseEnergyCell extends BlockEnergyCell
|
||||
{
|
||||
|
||||
@Override
|
||||
public double getMaxPower()
|
||||
{
|
||||
return 200000.0 * 8.0;
|
||||
}
|
||||
|
||||
public BlockDenseEnergyCell() {
|
||||
super( BlockDenseEnergyCell.class );
|
||||
setfeature( EnumSet.of( AEFeature.DenseEnergyCells ) );
|
||||
setTileEntiy( TileDenseEnergyCell.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getIcon(int direction, int metadata)
|
||||
{
|
||||
switch (metadata)
|
||||
{
|
||||
case 0:
|
||||
return ExtraTextures.MEDenseEnergyCell0.getIcon();
|
||||
case 1:
|
||||
return ExtraTextures.MEDenseEnergyCell1.getIcon();
|
||||
case 2:
|
||||
return ExtraTextures.MEDenseEnergyCell2.getIcon();
|
||||
case 3:
|
||||
return ExtraTextures.MEDenseEnergyCell3.getIcon();
|
||||
case 4:
|
||||
return ExtraTextures.MEDenseEnergyCell4.getIcon();
|
||||
case 5:
|
||||
return ExtraTextures.MEDenseEnergyCell5.getIcon();
|
||||
case 6:
|
||||
return ExtraTextures.MEDenseEnergyCell6.getIcon();
|
||||
case 7:
|
||||
return ExtraTextures.MEDenseEnergyCell7.getIcon();
|
||||
|
||||
}
|
||||
return super.getIcon( direction, metadata );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package appeng.block.networking;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.tile.networking.TileEnergyAcceptor;
|
||||
|
||||
public class BlockEnergyAcceptor extends AEBaseBlock
|
||||
{
|
||||
|
||||
public BlockEnergyAcceptor() {
|
||||
super( BlockEnergyAcceptor.class, Material.iron );
|
||||
setfeature( EnumSet.of( AEFeature.Core ) );
|
||||
setTileEntiy( TileEnergyAcceptor.class );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
package appeng.block.networking;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.Icon;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.block.AEBaseItemBlockChargeable;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
import appeng.client.render.blocks.RenderBlockEnergyCube;
|
||||
import appeng.client.texture.ExtraTextures;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.tile.networking.TileEnergyCell;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class BlockEnergyCell extends AEBaseBlock
|
||||
{
|
||||
|
||||
public double getMaxPower()
|
||||
{
|
||||
return 200000.0;
|
||||
}
|
||||
|
||||
public BlockEnergyCell(Class c) {
|
||||
super( c, Material.glass );
|
||||
}
|
||||
|
||||
public BlockEnergyCell() {
|
||||
this( BlockEnergyCell.class );
|
||||
setfeature( EnumSet.of( AEFeature.Core ) );
|
||||
setTileEntiy( TileEnergyCell.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks(int id, CreativeTabs tab, List list)
|
||||
{
|
||||
super.getSubBlocks( id, tab, list );
|
||||
|
||||
ItemStack charged = new ItemStack( this, 1 );
|
||||
NBTTagCompound tag = Platform.openNbtData( charged );
|
||||
tag.setDouble( "internalCurrentPower", getMaxPower() );
|
||||
tag.setDouble( "internalMaxPower", getMaxPower() );
|
||||
list.add( charged );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<? extends BaseBlockRender> getRenderer()
|
||||
{
|
||||
return RenderBlockEnergyCube.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getIcon(int direction, int metadata)
|
||||
{
|
||||
switch (metadata)
|
||||
{
|
||||
case 0:
|
||||
return ExtraTextures.MEEnergyCell0.getIcon();
|
||||
case 1:
|
||||
return ExtraTextures.MEEnergyCell1.getIcon();
|
||||
case 2:
|
||||
return ExtraTextures.MEEnergyCell2.getIcon();
|
||||
case 3:
|
||||
return ExtraTextures.MEEnergyCell3.getIcon();
|
||||
case 4:
|
||||
return ExtraTextures.MEEnergyCell4.getIcon();
|
||||
case 5:
|
||||
return ExtraTextures.MEEnergyCell5.getIcon();
|
||||
case 6:
|
||||
return ExtraTextures.MEEnergyCell6.getIcon();
|
||||
case 7:
|
||||
return ExtraTextures.MEEnergyCell7.getIcon();
|
||||
|
||||
}
|
||||
return super.getIcon( direction, metadata );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getItemBlockClass()
|
||||
{
|
||||
return AEBaseItemBlockChargeable.class;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,169 @@
|
||||
package appeng.block.networking;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
import appeng.client.render.blocks.RenderBlockWireless;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.helpers.ICustomCollision;
|
||||
import appeng.tile.networking.TileWireless;
|
||||
|
||||
public class BlockWireless extends AEBaseBlock implements ICustomCollision
|
||||
{
|
||||
|
||||
public BlockWireless() {
|
||||
super( BlockWireless.class, Material.glass );
|
||||
setfeature( EnumSet.of( AEFeature.Core, AEFeature.WirelessAccessTerminal ) );
|
||||
setTileEntiy( TileWireless.class );
|
||||
setLightOpacity( 0 );
|
||||
isFullSize = false;
|
||||
isOpaque = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<? extends BaseBlockRender> getRenderer()
|
||||
{
|
||||
return RenderBlockWireless.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getIcon(int direction, int metadata)
|
||||
{
|
||||
return super.getIcon( direction, metadata );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<AxisAlignedBB> getSelectedBoundingBoxsFromPool(World w, int x, int y, int z)
|
||||
{
|
||||
TileWireless tile = getTileEntity( w, x, y, z );
|
||||
if ( tile != null )
|
||||
{
|
||||
ForgeDirection forward = tile.getForward();
|
||||
|
||||
double minX = 0;
|
||||
double minY = 0;
|
||||
double minZ = 0;
|
||||
double maxX = 1;
|
||||
double maxY = 1;
|
||||
double maxZ = 1;
|
||||
|
||||
switch (forward)
|
||||
{
|
||||
case DOWN:
|
||||
minZ = minX = 3.0 / 16.0;
|
||||
maxZ = maxX = 13.0 / 16.0;
|
||||
maxY = 1.0;
|
||||
minY = 5.0 / 16.0;
|
||||
break;
|
||||
case EAST:
|
||||
minZ = minY = 3.0 / 16.0;
|
||||
maxZ = maxY = 13.0 / 16.0;
|
||||
maxX = 11.0 / 16.0;
|
||||
minX = 0.0;
|
||||
break;
|
||||
case NORTH:
|
||||
minY = minX = 3.0 / 16.0;
|
||||
maxY = maxX = 13.0 / 16.0;
|
||||
maxZ = 1.0;
|
||||
minZ = 5.0 / 16.0;
|
||||
break;
|
||||
case SOUTH:
|
||||
minY = minX = 3.0 / 16.0;
|
||||
maxY = maxX = 13.0 / 16.0;
|
||||
maxZ = 11.0 / 16.0;
|
||||
minZ = 0.0;
|
||||
break;
|
||||
case UP:
|
||||
minZ = minX = 3.0 / 16.0;
|
||||
maxZ = maxX = 13.0 / 16.0;
|
||||
maxY = 11.0 / 16.0;
|
||||
minY = 0.0;
|
||||
break;
|
||||
case WEST:
|
||||
minZ = minY = 3.0 / 16.0;
|
||||
maxZ = maxY = 13.0 / 16.0;
|
||||
maxX = 1.0;
|
||||
minX = 5.0 / 16.0;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return Arrays.asList( new AxisAlignedBB[] { AxisAlignedBB.getBoundingBox( minX, minY, minZ, maxX, maxY, maxZ ) } );
|
||||
}
|
||||
return Arrays.asList( new AxisAlignedBB[] { AxisAlignedBB.getBoundingBox( 0.0, 0, 0.0, 1.0, 1.0, 1.0 ) } );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCollidingBlockToList(World w, int x, int y, int z, AxisAlignedBB bb, List out, Entity e)
|
||||
{
|
||||
TileWireless tile = getTileEntity( w, x, y, z );
|
||||
if ( tile != null )
|
||||
{
|
||||
ForgeDirection forward = tile.getForward();
|
||||
|
||||
double minX = 0;
|
||||
double minY = 0;
|
||||
double minZ = 0;
|
||||
double maxX = 1;
|
||||
double maxY = 1;
|
||||
double maxZ = 1;
|
||||
|
||||
switch (forward)
|
||||
{
|
||||
case DOWN:
|
||||
minZ = minX = 3.0 / 16.0;
|
||||
maxZ = maxX = 13.0 / 16.0;
|
||||
maxY = 1.0;
|
||||
minY = 5.0 / 16.0;
|
||||
break;
|
||||
case EAST:
|
||||
minZ = minY = 3.0 / 16.0;
|
||||
maxZ = maxY = 13.0 / 16.0;
|
||||
maxX = 11.0 / 16.0;
|
||||
minX = 0.0;
|
||||
break;
|
||||
case NORTH:
|
||||
minY = minX = 3.0 / 16.0;
|
||||
maxY = maxX = 13.0 / 16.0;
|
||||
maxZ = 1.0;
|
||||
minZ = 5.0 / 16.0;
|
||||
break;
|
||||
case SOUTH:
|
||||
minY = minX = 3.0 / 16.0;
|
||||
maxY = maxX = 13.0 / 16.0;
|
||||
maxZ = 11.0 / 16.0;
|
||||
minZ = 0.0;
|
||||
break;
|
||||
case UP:
|
||||
minZ = minX = 3.0 / 16.0;
|
||||
maxZ = maxX = 13.0 / 16.0;
|
||||
maxY = 11.0 / 16.0;
|
||||
minY = 0.0;
|
||||
break;
|
||||
case WEST:
|
||||
minZ = minY = 3.0 / 16.0;
|
||||
maxZ = maxY = 13.0 / 16.0;
|
||||
maxX = 1.0;
|
||||
minX = 5.0 / 16.0;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
out.add( AxisAlignedBB.getAABBPool().getAABB( minX, minY, minZ, maxX, maxY, maxZ ) );
|
||||
}
|
||||
else
|
||||
out.add( AxisAlignedBB.getAABBPool().getAABB( 0.0, 0.0, 0.0, 1.0, 1.0, 1.0 ) );
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user