Most of the 1.8 Port.
This commit is contained in:
@@ -23,12 +23,14 @@ import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.properties.PropertyEnum;
|
||||
import net.minecraft.block.state.BlockState;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.client.resources.IResource;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.Entity;
|
||||
@@ -36,24 +38,27 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import net.minecraftforge.common.property.ExtendedBlockState;
|
||||
import net.minecraftforge.common.property.IExtendedBlockState;
|
||||
import net.minecraftforge.common.property.IUnlistedProperty;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.api.util.IOrientable;
|
||||
import appeng.api.util.IOrientableBlock;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
import appeng.client.render.BlockRenderInfo;
|
||||
import appeng.client.render.WorldRender;
|
||||
import appeng.client.texture.BaseIcon;
|
||||
import appeng.client.texture.FlippableIcon;
|
||||
import appeng.client.texture.MissingIcon;
|
||||
import appeng.client.texture.IAESprite;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.features.AEBlockFeatureHandler;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.features.FeatureNameExtractor;
|
||||
@@ -64,9 +69,13 @@ import appeng.helpers.ICustomCollision;
|
||||
import appeng.util.LookDirection;
|
||||
import appeng.util.Platform;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
|
||||
public abstract class AEBaseBlock extends Block implements IAEFeature
|
||||
{
|
||||
public static final PropertyEnum AXIS_ORIENTATION = PropertyEnum.create("axis", EnumFacing.Axis.class);
|
||||
|
||||
private final String featureFullName;
|
||||
protected final Optional<String> featureSubName;
|
||||
protected boolean isOpaque = true;
|
||||
@@ -76,7 +85,13 @@ public abstract class AEBaseBlock extends Block implements IAEFeature
|
||||
private IFeatureHandler handler;
|
||||
@SideOnly( Side.CLIENT )
|
||||
BlockRenderInfo renderInfo;
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isVisuallyOpaque()
|
||||
{
|
||||
return isOpaque && isFullSize;
|
||||
}
|
||||
|
||||
protected AEBaseBlock( Material mat )
|
||||
{
|
||||
this( mat, Optional.<String>absent() );
|
||||
@@ -117,13 +132,29 @@ public abstract class AEBaseBlock extends Block implements IAEFeature
|
||||
return this.featureFullName;
|
||||
}
|
||||
|
||||
public void registerNoIcons()
|
||||
public static final UnlistedBlockPos AE_BLOCK_POS = new UnlistedBlockPos();
|
||||
public static final UnlistedBlockAccess AE_BLOCK_ACCESS = new UnlistedBlockAccess();
|
||||
|
||||
@Override
|
||||
final protected BlockState createBlockState()
|
||||
{
|
||||
final BlockRenderInfo info = this.getRendererInstance();
|
||||
final FlippableIcon i = new FlippableIcon( new MissingIcon( this ) );
|
||||
info.updateIcons( i, i, i, i, i, i );
|
||||
return new ExtendedBlockState( this, getAEStates(), new IUnlistedProperty[] { AE_BLOCK_POS, AE_BLOCK_ACCESS} );
|
||||
}
|
||||
|
||||
@Override
|
||||
final public IBlockState getExtendedState(
|
||||
IBlockState state,
|
||||
IBlockAccess world,
|
||||
BlockPos pos )
|
||||
{
|
||||
return ((IExtendedBlockState)super.getExtendedState( state, world, pos ) ).withProperty( AE_BLOCK_POS, pos ).withProperty( AE_BLOCK_ACCESS, world );
|
||||
}
|
||||
|
||||
protected IProperty[] getAEStates()
|
||||
{
|
||||
return new IProperty[0];
|
||||
}
|
||||
|
||||
@SideOnly( Side.CLIENT )
|
||||
public BlockRenderInfo getRendererInstance()
|
||||
{
|
||||
@@ -134,7 +165,9 @@ public abstract class AEBaseBlock extends Block implements IAEFeature
|
||||
|
||||
try
|
||||
{
|
||||
final BaseBlockRender renderer = this.getRenderer().newInstance();
|
||||
Class<? extends BaseBlockRender> re = this.getRenderer();
|
||||
if ( re == null ) return null; // use 1.8 models.
|
||||
final BaseBlockRender renderer = re.newInstance();
|
||||
this.renderInfo = new BlockRenderInfo( renderer );
|
||||
|
||||
return this.renderInfo;
|
||||
@@ -148,6 +181,15 @@ public abstract class AEBaseBlock extends Block implements IAEFeature
|
||||
throw new IllegalStateException( "Failed to create a new instance of " + this.getRenderer() + " because of permissions.", e );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int colorMultiplier(
|
||||
IBlockAccess worldIn,
|
||||
BlockPos pos,
|
||||
int colorTint )
|
||||
{
|
||||
return colorTint;
|
||||
}
|
||||
|
||||
@SideOnly( Side.CLIENT )
|
||||
protected Class<? extends BaseBlockRender> getRenderer()
|
||||
@@ -155,11 +197,6 @@ public abstract class AEBaseBlock extends Block implements IAEFeature
|
||||
return BaseBlockRender.class;
|
||||
}
|
||||
|
||||
public IIcon unmappedGetIcon( IBlockAccess w, int x, int y, int z, int s )
|
||||
{
|
||||
return super.getIcon( w, x, y, z, s );
|
||||
}
|
||||
|
||||
protected void setFeature( EnumSet<AEFeature> f )
|
||||
{
|
||||
final AEBlockFeatureHandler featureHandler = new AEBlockFeatureHandler( f, this, this.featureSubName );
|
||||
@@ -187,34 +224,14 @@ public abstract class AEBaseBlock extends Block implements IAEFeature
|
||||
{
|
||||
return this.isOpaque;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock()
|
||||
public boolean isNormalCube()
|
||||
{
|
||||
return this.isFullSize && this.isOpaque;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public int getRenderType()
|
||||
{
|
||||
return WorldRender.INSTANCE.getRenderId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon( IBlockAccess w, int x, int y, int z, int s )
|
||||
{
|
||||
return this.getIcon( this.mapRotation( w, x, y, z, s ), w.getBlockMetadata( x, y, z ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public IIcon getIcon( int direction, int metadata )
|
||||
{
|
||||
return this.getRendererInstance().getTexture( ForgeDirection.getOrientation( direction ) );
|
||||
}
|
||||
|
||||
protected ICustomCollision getCustomCollision( World w, int x, int y, int z )
|
||||
|
||||
protected ICustomCollision getCustomCollision( World w, BlockPos pos )
|
||||
{
|
||||
if( this instanceof ICustomCollision )
|
||||
{
|
||||
@@ -223,42 +240,61 @@ public abstract class AEBaseBlock extends Block implements IAEFeature
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings( "unchecked" )
|
||||
// NOTE: WAS FINAL, changed for Immibis
|
||||
public void addCollisionBoxesToList( World w, int x, int y, int z, AxisAlignedBB bb, List out, Entity e )
|
||||
@SideOnly( Side.CLIENT )
|
||||
public IAESprite getIcon( IBlockAccess w, BlockPos pos, EnumFacing side )
|
||||
{
|
||||
final ICustomCollision collisionHandler = this.getCustomCollision( w, x, y, z );
|
||||
IBlockState state =w.getBlockState( pos );
|
||||
IOrientable ori = getOrientable( w, pos );
|
||||
|
||||
if ( ori == null )
|
||||
return getIcon( side,state );
|
||||
|
||||
return this.getIcon( this.mapRotation( ori, side ), state );
|
||||
}
|
||||
|
||||
@SideOnly( Side.CLIENT )
|
||||
public IAESprite getIcon( EnumFacing side, IBlockState state )
|
||||
{
|
||||
return this.getRendererInstance().getTexture( AEPartLocation.fromFacing( side ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCollisionBoxesToList(
|
||||
World w,
|
||||
BlockPos pos,
|
||||
IBlockState state,
|
||||
AxisAlignedBB bb,
|
||||
List out,
|
||||
Entity e )
|
||||
{
|
||||
final ICustomCollision collisionHandler = this.getCustomCollision( w, pos );
|
||||
|
||||
if( collisionHandler != null && bb != null )
|
||||
{
|
||||
List<AxisAlignedBB> tmp = new ArrayList<AxisAlignedBB>();
|
||||
collisionHandler.addCollidingBlockToList( w, x, y, z, bb, tmp, e );
|
||||
collisionHandler.addCollidingBlockToList( w, pos, bb, tmp, e );
|
||||
for( AxisAlignedBB b : tmp )
|
||||
{
|
||||
b.minX += x;
|
||||
b.minY += y;
|
||||
b.minZ += z;
|
||||
b.maxX += x;
|
||||
b.maxY += y;
|
||||
b.maxZ += z;
|
||||
if( bb.intersectsWith( b ) )
|
||||
AxisAlignedBB offset = b.offset( pos.getX(), pos.getY(), pos.getZ() );
|
||||
if( bb.intersectsWith( offset ) )
|
||||
{
|
||||
out.add( b );
|
||||
out.add( offset );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
super.addCollisionBoxesToList( w, x, y, z, bb, out, e );
|
||||
super.addCollisionBoxesToList( w, pos, state, bb, out, e );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public final AxisAlignedBB getSelectedBoundingBoxFromPool( World w, int x, int y, int z )
|
||||
public AxisAlignedBB getSelectedBoundingBox(
|
||||
World w,
|
||||
BlockPos pos )
|
||||
{
|
||||
final ICustomCollision collisionHandler = this.getCustomCollision( w, x, y, z );
|
||||
final ICustomCollision collisionHandler = this.getCustomCollision( w, pos );
|
||||
|
||||
if( collisionHandler != null )
|
||||
{
|
||||
@@ -267,7 +303,7 @@ public abstract class AEBaseBlock extends Block implements IAEFeature
|
||||
final EntityPlayer player = Minecraft.getMinecraft().thePlayer;
|
||||
final LookDirection ld = Platform.getPlayerRay( player, Platform.getEyeOffset( player ) );
|
||||
|
||||
final Iterable<AxisAlignedBB> bbs = collisionHandler.getSelectedBoundingBoxesFromPool( w, x, y, z, Minecraft.getMinecraft().thePlayer, true );
|
||||
final Iterable<AxisAlignedBB> bbs = collisionHandler.getSelectedBoundingBoxesFromPool( w, pos, Minecraft.getMinecraft().thePlayer, true );
|
||||
AxisAlignedBB br = null;
|
||||
|
||||
double lastDist = 0;
|
||||
@@ -276,7 +312,7 @@ public abstract class AEBaseBlock extends Block implements IAEFeature
|
||||
{
|
||||
this.setBlockBounds( (float) bb.minX, (float) bb.minY, (float) bb.minZ, (float) bb.maxX, (float) bb.maxY, (float) bb.maxZ );
|
||||
|
||||
MovingObjectPosition r = super.collisionRayTrace( w, x, y, z, ld.a, ld.b );
|
||||
MovingObjectPosition r = super.collisionRayTrace( w, pos, ld.a, ld.b );
|
||||
|
||||
this.setBlockBounds( 0, 0, 0, 1, 1, 1 );
|
||||
|
||||
@@ -298,15 +334,21 @@ public abstract class AEBaseBlock extends Block implements IAEFeature
|
||||
|
||||
if( br != null )
|
||||
{
|
||||
br.setBounds( br.minX + x, br.minY + y, br.minZ + z, br.maxX + x, br.maxY + y, br.maxZ + z );
|
||||
br = AxisAlignedBB.fromBounds( br.minX + pos.getX(), br.minY + pos.getY(), br.minZ + pos.getZ(), br.maxX + pos.getX(), br.maxY + pos.getY(), br.maxZ + pos.getZ() );
|
||||
return br;
|
||||
}
|
||||
}
|
||||
|
||||
final AxisAlignedBB b = AxisAlignedBB.getBoundingBox( 16d, 16d, 16d, 0d, 0d, 0d );
|
||||
AxisAlignedBB b = null; // new AxisAlignedBB( 16d, 16d, 16d, 0d, 0d, 0d );
|
||||
|
||||
for( AxisAlignedBB bx : collisionHandler.getSelectedBoundingBoxesFromPool( w, x, y, z, null, false ) )
|
||||
for( AxisAlignedBB bx : collisionHandler.getSelectedBoundingBoxesFromPool( w, pos, null, false ) )
|
||||
{
|
||||
if ( b == null )
|
||||
{
|
||||
b = bx;
|
||||
continue;
|
||||
}
|
||||
|
||||
final double minX = Math.min( b.minX, bx.minX );
|
||||
final double minY = Math.min( b.minY, bx.minY );
|
||||
final double minZ = Math.min( b.minZ, bx.minZ );
|
||||
@@ -314,15 +356,18 @@ public abstract class AEBaseBlock extends Block implements IAEFeature
|
||||
final double maxY = Math.max( b.maxY, bx.maxY );
|
||||
final double maxZ = Math.max( b.maxZ, bx.maxZ );
|
||||
|
||||
b.setBounds( minX, minY, minZ, maxX, maxY, maxZ );
|
||||
b = AxisAlignedBB.fromBounds( minX, minY, minZ, maxX, maxY, maxZ );
|
||||
}
|
||||
|
||||
b.setBounds( b.minX + x, b.minY + y, b.minZ + z, b.maxX + x, b.maxY + y, b.maxZ + z );
|
||||
if ( b == null )
|
||||
b = new AxisAlignedBB( 16d, 16d, 16d, 0d, 0d, 0d );
|
||||
else
|
||||
b = AxisAlignedBB.fromBounds( b.minX + pos.getX(), b.minY + pos.getY(), b.minZ + pos.getZ(), b.maxX+ pos.getX(), b.maxY + pos.getY(), b.maxZ + pos.getZ() );
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
return super.getSelectedBoundingBoxFromPool( w, x, y, z );
|
||||
return super.getSelectedBoundingBox( w, pos );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -332,13 +377,17 @@ public abstract class AEBaseBlock extends Block implements IAEFeature
|
||||
}
|
||||
|
||||
@Override
|
||||
public MovingObjectPosition collisionRayTrace( World w, int x, int y, int z, Vec3 a, Vec3 b )
|
||||
public MovingObjectPosition collisionRayTrace(
|
||||
World w,
|
||||
BlockPos pos,
|
||||
Vec3 a,
|
||||
Vec3 b )
|
||||
{
|
||||
final ICustomCollision collisionHandler = this.getCustomCollision( w, x, y, z );
|
||||
final ICustomCollision collisionHandler = this.getCustomCollision( w, pos );
|
||||
|
||||
if( collisionHandler != null )
|
||||
{
|
||||
final Iterable<AxisAlignedBB> bbs = collisionHandler.getSelectedBoundingBoxesFromPool( w, x, y, z, null, true );
|
||||
final Iterable<AxisAlignedBB> bbs = collisionHandler.getSelectedBoundingBoxesFromPool( w, pos, null, true );
|
||||
MovingObjectPosition br = null;
|
||||
|
||||
double lastDist = 0;
|
||||
@@ -347,7 +396,7 @@ public abstract class AEBaseBlock extends Block implements IAEFeature
|
||||
{
|
||||
this.setBlockBounds( (float) bb.minX, (float) bb.minY, (float) bb.minZ, (float) bb.maxX, (float) bb.maxY, (float) bb.maxZ );
|
||||
|
||||
MovingObjectPosition r = super.collisionRayTrace( w, x, y, z, a, b );
|
||||
MovingObjectPosition r = super.collisionRayTrace( w, pos, a, b );
|
||||
|
||||
this.setBlockBounds( 0, 0, 0, 1, 1, 1 );
|
||||
|
||||
@@ -375,14 +424,14 @@ public abstract class AEBaseBlock extends Block implements IAEFeature
|
||||
}
|
||||
|
||||
this.setBlockBounds( 0, 0, 0, 1, 1, 1 );
|
||||
return super.collisionRayTrace( w, x, y, z, a, b );
|
||||
return super.collisionRayTrace( w, pos, a, b );
|
||||
}
|
||||
|
||||
public boolean onActivated( World w, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ )
|
||||
public boolean onActivated( World w, BlockPos pos, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
@SuppressWarnings( "unchecked" )
|
||||
@@ -396,56 +445,39 @@ public abstract class AEBaseBlock extends Block implements IAEFeature
|
||||
{
|
||||
return this.isInventory;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getComparatorInputOverride( World w, int x, int y, int z, int s )
|
||||
public int getComparatorInputOverride(
|
||||
World worldIn,
|
||||
BlockPos pos )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void registerBlockIcons( IIconRegister iconRegistry )
|
||||
{
|
||||
final BlockRenderInfo info = this.getRendererInstance();
|
||||
final FlippableIcon topIcon;
|
||||
final FlippableIcon bottomIcon;
|
||||
final FlippableIcon sideIcon;
|
||||
final FlippableIcon eastIcon;
|
||||
final FlippableIcon westIcon;
|
||||
final FlippableIcon southIcon;
|
||||
final FlippableIcon northIcon;
|
||||
|
||||
this.blockIcon = topIcon = this.optionalIcon( iconRegistry, this.getTextureName(), null );
|
||||
bottomIcon = this.optionalIcon( iconRegistry, this.getTextureName() + "Bottom", topIcon );
|
||||
sideIcon = this.optionalIcon( iconRegistry, this.getTextureName() + "Side", topIcon );
|
||||
eastIcon = this.optionalIcon( iconRegistry, this.getTextureName() + "East", sideIcon );
|
||||
westIcon = this.optionalIcon( iconRegistry, this.getTextureName() + "West", sideIcon );
|
||||
southIcon = this.optionalIcon( iconRegistry, this.getTextureName() + "Front", sideIcon );
|
||||
northIcon = this.optionalIcon( iconRegistry, this.getTextureName() + "Back", sideIcon );
|
||||
|
||||
info.updateIcons( bottomIcon, topIcon, northIcon, southIcon, eastIcon, westIcon );
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean isNormalCube( IBlockAccess world, int x, int y, int z )
|
||||
public boolean isNormalCube(
|
||||
IBlockAccess world,
|
||||
BlockPos pos )
|
||||
{
|
||||
return this.isFullSize;
|
||||
}
|
||||
|
||||
public IOrientable getOrientable( IBlockAccess w, int x, int y, int z )
|
||||
public IOrientable getOrientable( IBlockAccess w, BlockPos pos )
|
||||
{
|
||||
if( this instanceof IOrientableBlock )
|
||||
{
|
||||
return ( (IOrientableBlock) this ).getOrientable( w, x, y, z );
|
||||
return ( (IOrientableBlock) this ).getOrientable( w, pos );
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean rotateBlock( World w, int x, int y, int z, ForgeDirection axis )
|
||||
public boolean rotateBlock(
|
||||
World w,
|
||||
BlockPos pos,
|
||||
EnumFacing axis )
|
||||
{
|
||||
final IOrientable rotatable = this.getOrientable( w, x, y, z );
|
||||
final IOrientable rotatable = this.getOrientable( w, pos );
|
||||
|
||||
if( rotatable != null && rotatable.canBeRotated() )
|
||||
{
|
||||
@@ -456,15 +488,15 @@ public abstract class AEBaseBlock extends Block implements IAEFeature
|
||||
}
|
||||
else
|
||||
{
|
||||
ForgeDirection forward = rotatable.getForward();
|
||||
ForgeDirection up = rotatable.getUp();
|
||||
EnumFacing forward = rotatable.getForward();
|
||||
EnumFacing up = rotatable.getUp();
|
||||
|
||||
for( int rs = 0; rs < 4; rs++ )
|
||||
{
|
||||
forward = Platform.rotateAround( forward, axis );
|
||||
up = Platform.rotateAround( up, axis );
|
||||
|
||||
if( this.isValidOrientation( w, x, y, z, forward, up ) )
|
||||
if( this.isValidOrientation( w, pos, forward, up ) )
|
||||
{
|
||||
rotatable.setOrientation( forward, up );
|
||||
return true;
|
||||
@@ -473,7 +505,7 @@ public abstract class AEBaseBlock extends Block implements IAEFeature
|
||||
}
|
||||
}
|
||||
|
||||
return super.rotateBlock( w, x, y, z, axis );
|
||||
return super.rotateBlock( w, pos, axis );
|
||||
}
|
||||
|
||||
protected boolean hasCustomRotation()
|
||||
@@ -481,51 +513,20 @@ public abstract class AEBaseBlock extends Block implements IAEFeature
|
||||
return false;
|
||||
}
|
||||
|
||||
protected void customRotateBlock( IOrientable rotatable, ForgeDirection axis )
|
||||
protected void customRotateBlock( IOrientable rotatable, EnumFacing axis )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public boolean isValidOrientation( World w, int x, int y, int z, ForgeDirection forward, ForgeDirection up )
|
||||
public boolean isValidOrientation( World w, BlockPos pos, EnumFacing forward, EnumFacing up )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ForgeDirection[] getValidRotations( World w, int x, int y, int z )
|
||||
public EnumFacing[] getValidRotations( World w, BlockPos pos )
|
||||
{
|
||||
return new ForgeDirection[0];
|
||||
}
|
||||
|
||||
@SideOnly( Side.CLIENT )
|
||||
private FlippableIcon optionalIcon( IIconRegister ir, String name, IIcon substitute )
|
||||
{
|
||||
// if the input is an flippable IIcon find the original.
|
||||
while( substitute instanceof FlippableIcon )
|
||||
{
|
||||
substitute = ( (FlippableIcon) substitute ).getOriginal();
|
||||
}
|
||||
|
||||
if( substitute != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
ResourceLocation resLoc = new ResourceLocation( name );
|
||||
resLoc = new ResourceLocation( resLoc.getResourceDomain(), String.format( "%s/%s%s", "textures/blocks", resLoc.getResourcePath(), ".png" ) );
|
||||
|
||||
IResource res = Minecraft.getMinecraft().getResourceManager().getResource( resLoc );
|
||||
if( res != null )
|
||||
{
|
||||
return new FlippableIcon( ir.registerIcon( name ) );
|
||||
}
|
||||
}
|
||||
catch( Throwable e )
|
||||
{
|
||||
return new FlippableIcon( substitute );
|
||||
}
|
||||
}
|
||||
|
||||
return new FlippableIcon( ir.registerIcon( name ) );
|
||||
return new EnumFacing[0];
|
||||
}
|
||||
|
||||
@SideOnly( Side.CLIENT )
|
||||
@@ -534,78 +535,6 @@ public abstract class AEBaseBlock extends Block implements IAEFeature
|
||||
super.getSubBlocks( item, tabs, itemStacks );
|
||||
}
|
||||
|
||||
int mapRotation( IBlockAccess w, int x, int y, int z, int s )
|
||||
{
|
||||
final IOrientable ori = this.getOrientable( w, x, y, z );
|
||||
|
||||
if( ori != null && ori.canBeRotated() )
|
||||
{
|
||||
return this.mapRotation( ori, ForgeDirection.getOrientation( s ) ).ordinal();
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
public ForgeDirection mapRotation( IOrientable ori, ForgeDirection dir )
|
||||
{
|
||||
// case DOWN: return bottomIcon;
|
||||
// case UP: return blockIcon;
|
||||
// case NORTH: return northIcon;
|
||||
// case SOUTH: return southIcon;
|
||||
// case WEST: return sideIcon;
|
||||
// case EAST: return sideIcon;
|
||||
|
||||
final ForgeDirection forward = ori.getForward();
|
||||
final ForgeDirection up = ori.getUp();
|
||||
ForgeDirection west = ForgeDirection.UNKNOWN;
|
||||
|
||||
if( forward == null || up == null )
|
||||
{
|
||||
return dir;
|
||||
}
|
||||
|
||||
int west_x = forward.offsetY * up.offsetZ - forward.offsetZ * up.offsetY;
|
||||
int west_y = forward.offsetZ * up.offsetX - forward.offsetX * up.offsetZ;
|
||||
int west_z = forward.offsetX * up.offsetY - forward.offsetY * up.offsetX;
|
||||
|
||||
for( ForgeDirection dx : ForgeDirection.VALID_DIRECTIONS )
|
||||
{
|
||||
if( dx.offsetX == west_x && dx.offsetY == west_y && dx.offsetZ == west_z )
|
||||
{
|
||||
west = dx;
|
||||
}
|
||||
}
|
||||
|
||||
if( dir == forward )
|
||||
{
|
||||
return ForgeDirection.SOUTH;
|
||||
}
|
||||
if( dir == forward.getOpposite() )
|
||||
{
|
||||
return ForgeDirection.NORTH;
|
||||
}
|
||||
|
||||
if( dir == up )
|
||||
{
|
||||
return ForgeDirection.UP;
|
||||
}
|
||||
if( dir == up.getOpposite() )
|
||||
{
|
||||
return ForgeDirection.DOWN;
|
||||
}
|
||||
|
||||
if( dir == west )
|
||||
{
|
||||
return ForgeDirection.WEST;
|
||||
}
|
||||
if( dir == west.getOpposite() )
|
||||
{
|
||||
return ForgeDirection.EAST;
|
||||
}
|
||||
|
||||
return ForgeDirection.UNKNOWN;
|
||||
}
|
||||
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void setRenderStateByMeta( int itemDamage )
|
||||
{
|
||||
@@ -632,4 +561,137 @@ public abstract class AEBaseBlock extends Block implements IAEFeature
|
||||
return this.hasSubtypes;
|
||||
}
|
||||
|
||||
public EnumFacing mapRotation(
|
||||
IOrientable ori,
|
||||
EnumFacing dir )
|
||||
{
|
||||
// case DOWN: return bottomIcon;
|
||||
// case UP: return blockIcon;
|
||||
// case NORTH: return northIcon;
|
||||
// case SOUTH: return southIcon;
|
||||
// case WEST: return sideIcon;
|
||||
// case EAST: return sideIcon;
|
||||
|
||||
final EnumFacing forward = ori.getForward();
|
||||
final EnumFacing up = ori.getUp();
|
||||
EnumFacing west = null;
|
||||
|
||||
if( forward == null || up == null )
|
||||
{
|
||||
return dir;
|
||||
}
|
||||
|
||||
int west_x = forward.getFrontOffsetY() * up.getFrontOffsetZ() - forward.getFrontOffsetZ() * up.getFrontOffsetY();
|
||||
int west_y = forward.getFrontOffsetZ() * up.getFrontOffsetX() - forward.getFrontOffsetX() * up.getFrontOffsetZ();
|
||||
int west_z = forward.getFrontOffsetX() * up.getFrontOffsetY() - forward.getFrontOffsetY() * up.getFrontOffsetX();
|
||||
|
||||
for( EnumFacing dx : EnumFacing.VALUES )
|
||||
{
|
||||
if( dx.getFrontOffsetX() == west_x && dx.getFrontOffsetY() == west_y && dx.getFrontOffsetZ() == west_z )
|
||||
{
|
||||
west = dx;
|
||||
}
|
||||
}
|
||||
|
||||
if ( west == null )
|
||||
return dir;
|
||||
|
||||
if( dir == forward )
|
||||
{
|
||||
return EnumFacing.SOUTH;
|
||||
}
|
||||
if( dir == forward.getOpposite() )
|
||||
{
|
||||
return EnumFacing.NORTH;
|
||||
}
|
||||
|
||||
if( dir == up )
|
||||
{
|
||||
return EnumFacing.UP;
|
||||
}
|
||||
if( dir == up.getOpposite() )
|
||||
{
|
||||
return EnumFacing.DOWN;
|
||||
}
|
||||
|
||||
if( dir == west )
|
||||
{
|
||||
return EnumFacing.WEST;
|
||||
}
|
||||
if( dir == west.getOpposite() )
|
||||
{
|
||||
return EnumFacing.EAST;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void registerBlockIcons(
|
||||
TextureMap clientHelper,
|
||||
String name )
|
||||
{
|
||||
final BlockRenderInfo info = this.getRendererInstance();
|
||||
final FlippableIcon blockIcon;
|
||||
final FlippableIcon topIcon;
|
||||
final FlippableIcon bottomIcon;
|
||||
final FlippableIcon sideIcon;
|
||||
final FlippableIcon eastIcon;
|
||||
final FlippableIcon westIcon;
|
||||
final FlippableIcon southIcon;
|
||||
final FlippableIcon northIcon;
|
||||
|
||||
blockIcon = topIcon = this.optionalIcon( clientHelper, this.getTextureName(), null );
|
||||
bottomIcon = this.optionalIcon( clientHelper, this.getTextureName() + "Bottom", topIcon );
|
||||
sideIcon = this.optionalIcon( clientHelper, this.getTextureName() + "Side", topIcon );
|
||||
eastIcon = this.optionalIcon( clientHelper, this.getTextureName() + "East", sideIcon );
|
||||
westIcon = this.optionalIcon( clientHelper, this.getTextureName() + "West", sideIcon );
|
||||
southIcon = this.optionalIcon( clientHelper, this.getTextureName() + "Front", sideIcon );
|
||||
northIcon = this.optionalIcon( clientHelper, this.getTextureName() + "Back", sideIcon );
|
||||
|
||||
info.updateIcons( bottomIcon, topIcon, northIcon, southIcon, eastIcon, westIcon );
|
||||
}
|
||||
|
||||
@SideOnly( Side.CLIENT )
|
||||
private FlippableIcon optionalIcon( TextureMap ir, String name, IAESprite substitute )
|
||||
{
|
||||
// if the input is an flippable IAESprite find the original.
|
||||
while( substitute instanceof FlippableIcon )
|
||||
{
|
||||
substitute = ( (FlippableIcon) substitute ).getOriginal();
|
||||
}
|
||||
|
||||
if( substitute != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
ResourceLocation resLoc = new ResourceLocation( AppEng.MOD_ID, String.format( "%s/%s%s", "textures/blocks", name, ".png" ) );
|
||||
|
||||
IResource res = Minecraft.getMinecraft().getResourceManager().getResource( resLoc );
|
||||
if( res != null )
|
||||
{
|
||||
return new FlippableIcon( new BaseIcon( ir.registerSprite( new ResourceLocation(AppEng.MOD_ID, "blocks/" + name ) ) ) );
|
||||
}
|
||||
}
|
||||
catch( Throwable e )
|
||||
{
|
||||
return new FlippableIcon( substitute );
|
||||
}
|
||||
}
|
||||
|
||||
ResourceLocation resLoc = new ResourceLocation(AppEng.MOD_ID, "blocks/" + name );
|
||||
return new FlippableIcon(new BaseIcon( ir.registerSprite( resLoc ) ) );
|
||||
}
|
||||
|
||||
String textureName;
|
||||
public void setBlockTextureName( String texture )
|
||||
{
|
||||
textureName = texture;
|
||||
}
|
||||
|
||||
private String getTextureName()
|
||||
{
|
||||
return textureName;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -22,26 +22,23 @@ package appeng.block;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.MinecraftForgeClient;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import appeng.api.util.IOrientable;
|
||||
import appeng.api.util.IOrientableBlock;
|
||||
import appeng.block.misc.BlockLightDetector;
|
||||
import appeng.block.misc.BlockSkyCompass;
|
||||
import appeng.block.networking.BlockWireless;
|
||||
import appeng.client.render.ItemRenderer;
|
||||
import appeng.me.helpers.IGridProxyable;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class AEBaseItemBlock extends ItemBlock
|
||||
@@ -54,11 +51,6 @@ public class AEBaseItemBlock extends ItemBlock
|
||||
super( id );
|
||||
this.blockType = (AEBaseBlock) id;
|
||||
this.hasSubtypes = this.blockType.hasSubtypes;
|
||||
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
MinecraftForgeClient.registerItemRenderer( this, ItemRenderer.INSTANCE );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -96,12 +88,21 @@ public class AEBaseItemBlock extends ItemBlock
|
||||
{
|
||||
return this.blockType.getUnlocalizedName( is );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean placeBlockAt( ItemStack stack, EntityPlayer player, World w, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata )
|
||||
public boolean placeBlockAt(
|
||||
ItemStack stack,
|
||||
EntityPlayer player,
|
||||
World w,
|
||||
BlockPos pos,
|
||||
EnumFacing side,
|
||||
float hitX,
|
||||
float hitY,
|
||||
float hitZ,
|
||||
IBlockState newState )
|
||||
{
|
||||
ForgeDirection up = ForgeDirection.UNKNOWN;
|
||||
ForgeDirection forward = ForgeDirection.UNKNOWN;
|
||||
EnumFacing up = null;
|
||||
EnumFacing forward = null;
|
||||
|
||||
IOrientable ori = null;
|
||||
|
||||
@@ -109,31 +110,31 @@ public class AEBaseItemBlock extends ItemBlock
|
||||
{
|
||||
if( this.blockType instanceof BlockLightDetector )
|
||||
{
|
||||
up = ForgeDirection.getOrientation( side );
|
||||
if( up == ForgeDirection.UP || up == ForgeDirection.DOWN )
|
||||
up = side;
|
||||
if( up == EnumFacing.UP || up == EnumFacing.DOWN )
|
||||
{
|
||||
forward = ForgeDirection.SOUTH;
|
||||
forward = EnumFacing.SOUTH;
|
||||
}
|
||||
else
|
||||
{
|
||||
forward = ForgeDirection.UP;
|
||||
forward = EnumFacing.UP;
|
||||
}
|
||||
}
|
||||
else if( this.blockType instanceof BlockWireless || this.blockType instanceof BlockSkyCompass )
|
||||
{
|
||||
forward = ForgeDirection.getOrientation( side );
|
||||
if( forward == ForgeDirection.UP || forward == ForgeDirection.DOWN )
|
||||
forward = side;
|
||||
if( forward == EnumFacing.UP || forward == EnumFacing.DOWN )
|
||||
{
|
||||
up = ForgeDirection.SOUTH;
|
||||
up = EnumFacing.SOUTH;
|
||||
}
|
||||
else
|
||||
{
|
||||
up = ForgeDirection.UP;
|
||||
up = EnumFacing.UP;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
up = ForgeDirection.UP;
|
||||
up = EnumFacing.UP;
|
||||
|
||||
byte rotation = (byte) ( MathHelper.floor_double( ( player.rotationYaw * 4F ) / 360F + 2.5D ) & 3 );
|
||||
|
||||
@@ -141,53 +142,53 @@ public class AEBaseItemBlock extends ItemBlock
|
||||
{
|
||||
default:
|
||||
case 0:
|
||||
forward = ForgeDirection.SOUTH;
|
||||
forward = EnumFacing.SOUTH;
|
||||
break;
|
||||
case 1:
|
||||
forward = ForgeDirection.WEST;
|
||||
forward = EnumFacing.WEST;
|
||||
break;
|
||||
case 2:
|
||||
forward = ForgeDirection.NORTH;
|
||||
forward = EnumFacing.NORTH;
|
||||
break;
|
||||
case 3:
|
||||
forward = ForgeDirection.EAST;
|
||||
forward = EnumFacing.EAST;
|
||||
break;
|
||||
}
|
||||
|
||||
if( player.rotationPitch > 65 )
|
||||
{
|
||||
up = forward.getOpposite();
|
||||
forward = ForgeDirection.UP;
|
||||
forward = EnumFacing.UP;
|
||||
}
|
||||
else if( player.rotationPitch < -65 )
|
||||
{
|
||||
up = forward.getOpposite();
|
||||
forward = ForgeDirection.DOWN;
|
||||
forward = EnumFacing.DOWN;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( this.blockType instanceof IOrientableBlock )
|
||||
{
|
||||
ori = ( (IOrientableBlock) this.blockType ).getOrientable( w, x, y, z );
|
||||
up = ForgeDirection.getOrientation( side );
|
||||
forward = ForgeDirection.SOUTH;
|
||||
if( up.offsetY == 0 )
|
||||
ori = ( (IOrientableBlock) this.blockType ).getOrientable( w, pos );
|
||||
up = side;
|
||||
forward = EnumFacing.SOUTH;
|
||||
if( up.getFrontOffsetY() == 0 )
|
||||
{
|
||||
forward = ForgeDirection.UP;
|
||||
forward = EnumFacing.UP;
|
||||
}
|
||||
}
|
||||
|
||||
if( !this.blockType.isValidOrientation( w, x, y, z, forward, up ) )
|
||||
if( !this.blockType.isValidOrientation( w, pos, forward, up ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if( super.placeBlockAt( stack, player, w, x, y, z, side, hitX, hitY, hitZ, metadata ) )
|
||||
if( super.placeBlockAt( stack, player, w, pos, side, hitX, hitY, hitZ, newState ) )
|
||||
{
|
||||
if( this.blockType instanceof AEBaseTileBlock && !( this.blockType instanceof BlockLightDetector ) )
|
||||
{
|
||||
AEBaseTile tile = ( (AEBaseTileBlock) this.blockType ).getTileEntity( w, x, y, z );
|
||||
AEBaseTile tile = ( (AEBaseTileBlock) this.blockType ).getTileEntity( w, pos );
|
||||
ori = tile;
|
||||
|
||||
if( tile == null )
|
||||
@@ -197,8 +198,7 @@ public class AEBaseItemBlock extends ItemBlock
|
||||
|
||||
if( ori.canBeRotated() && !this.blockType.hasCustomRotation() )
|
||||
{
|
||||
if( ori.getForward() == null || ori.getUp() == null || // null
|
||||
tile.getForward() == ForgeDirection.UNKNOWN || ori.getUp() == ForgeDirection.UNKNOWN )
|
||||
if( ori.getForward() == null || ori.getUp() == null )
|
||||
{
|
||||
ori.setOrientation( forward, up );
|
||||
}
|
||||
|
||||
@@ -26,10 +26,8 @@ import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import appeng.api.config.AccessRestriction;
|
||||
import appeng.api.config.PowerUnits;
|
||||
import appeng.api.definitions.IBlockDefinition;
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
package appeng.block;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemSlab;
|
||||
|
||||
public class AEBaseItemBlockSlab extends ItemSlab {
|
||||
|
||||
public AEBaseItemBlockSlab(Block block, AEBaseSlabBlock singleSlab, AEBaseSlabBlock doubleSlab, Boolean isDoubleSlab)
|
||||
{
|
||||
super( block, singleSlab, doubleSlab, isDoubleSlab );
|
||||
}
|
||||
}
|
||||
@@ -1,129 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.block;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockSlab;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.features.IAEFeature;
|
||||
import appeng.core.features.IFeatureHandler;
|
||||
import appeng.core.features.SlabBlockFeatureHandler;
|
||||
|
||||
|
||||
public class AEBaseSlabBlock extends BlockSlab implements IAEFeature
|
||||
{
|
||||
private final IFeatureHandler features;
|
||||
private final AEBaseBlock block;
|
||||
private final int meta;
|
||||
private AEBaseSlabBlock slabs;
|
||||
private AEBaseSlabBlock doubleSlabs;
|
||||
private final String name;
|
||||
|
||||
public AEBaseSlabBlock( AEBaseBlock block, int meta, EnumSet<AEFeature> features, boolean isDoubleSlab, String name )
|
||||
{
|
||||
super( isDoubleSlab, block.getMaterial() );
|
||||
this.block = block;
|
||||
this.meta = meta;
|
||||
this.name = name;
|
||||
this.setBlockName( "appliedenergistics2." + name );
|
||||
this.setHardness( block.getBlockHardness( null, 0, 0, 0 ) );
|
||||
this.setResistance( block.getExplosionResistance( null ) * 5.0F / 3.0F );
|
||||
this.setStepSound( block.stepSound );
|
||||
this.useNeighborBrightness = true;
|
||||
if (!field_150004_a) this.doubleSlabs = new AEBaseSlabBlock( block, meta, features, true, name + ".double" ).setSlabs(this);
|
||||
this.features = !field_150004_a ? new SlabBlockFeatureHandler( features, this ) : null;
|
||||
}
|
||||
|
||||
public AEBaseSlabBlock setSlabs(AEBaseSlabBlock slabs)
|
||||
{
|
||||
this.slabs = slabs;
|
||||
return this;
|
||||
}
|
||||
|
||||
public AEBaseSlabBlock slabs()
|
||||
{
|
||||
return slabs;
|
||||
}
|
||||
|
||||
public AEBaseSlabBlock doubleSlabs()
|
||||
{
|
||||
return doubleSlabs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFeatureHandler handler()
|
||||
{
|
||||
return this.features;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postInit()
|
||||
{
|
||||
// Override to do stuff
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(int dir, int meta)
|
||||
{
|
||||
return block.getIcon( dir, this.meta );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String func_150002_b(int p_150002_1_)
|
||||
{
|
||||
return this.getUnlocalizedName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister reg) { }
|
||||
|
||||
@Override
|
||||
public Item getItemDropped(int meta, Random rand, int fortune)
|
||||
{
|
||||
return this.field_150004_a ? Item.getItemFromBlock(this.slabs) : Item.getItemFromBlock(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z)
|
||||
{
|
||||
AEBaseSlabBlock block = (AEBaseSlabBlock) world.getBlock(x, y, z);
|
||||
|
||||
if (block == null) return null;
|
||||
if (block.field_150004_a) block = this.slabs;
|
||||
|
||||
int meta = world.getBlockMetadata(x, y, z) & 7;
|
||||
return new ItemStack(block, 1, meta);
|
||||
}
|
||||
|
||||
public String name()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
}
|
||||
@@ -21,27 +21,26 @@ package appeng.block;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockStairs;
|
||||
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.features.IAEFeature;
|
||||
import appeng.core.features.IFeatureHandler;
|
||||
import appeng.core.features.StairBlockFeatureHandler;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
|
||||
public abstract class AEBaseStairBlock extends BlockStairs implements IAEFeature
|
||||
{
|
||||
private final IFeatureHandler features;
|
||||
|
||||
protected AEBaseStairBlock( Block block, int meta, EnumSet<AEFeature> features )
|
||||
protected AEBaseStairBlock( Block block, EnumSet<AEFeature> features, String type )
|
||||
{
|
||||
super( block, meta );
|
||||
super( block.getDefaultState() );
|
||||
|
||||
this.features = new StairBlockFeatureHandler( features, this, Optional.<String>absent() );
|
||||
this.setBlockName( block.getUnlocalizedName() );
|
||||
this.features = new StairBlockFeatureHandler( features, this, Optional.<String>of(type) );
|
||||
setUnlocalizedName( block.getUnlocalizedName() );
|
||||
|
||||
this.setLightOpacity( 0 );
|
||||
}
|
||||
|
||||
@@ -26,25 +26,23 @@ import java.util.List;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.ITileEntityProvider;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.EnumDyeColor;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import cpw.mods.fml.relauncher.ReflectionHelper;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.ReflectionHelper;
|
||||
import appeng.api.implementations.items.IMemoryCard;
|
||||
import appeng.api.implementations.items.MemoryCardMessages;
|
||||
import appeng.api.implementations.tiles.IColorableTile;
|
||||
@@ -61,6 +59,9 @@ import appeng.tile.storage.TileSkyChest;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.SettingsFrom;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
|
||||
public abstract class AEBaseTileBlock extends AEBaseBlock implements IAEFeature, ITileEntityProvider
|
||||
{
|
||||
@@ -94,6 +95,7 @@ public abstract class AEBaseTileBlock extends AEBaseBlock implements IAEFeature,
|
||||
this.setTileProvider( this.hasBlockTileEntity() );
|
||||
}
|
||||
|
||||
|
||||
// update Block value.
|
||||
private void setTileProvider( boolean b )
|
||||
{
|
||||
@@ -112,13 +114,19 @@ public abstract class AEBaseTileBlock extends AEBaseBlock implements IAEFeature,
|
||||
|
||||
@Nullable
|
||||
public <T extends AEBaseTile> T getTileEntity( IBlockAccess w, int x, int y, int z )
|
||||
{
|
||||
return getTileEntity( w, new BlockPos(x,y,z) );
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public <T extends AEBaseTile> T getTileEntity( IBlockAccess w, BlockPos pos )
|
||||
{
|
||||
if( !this.hasBlockTileEntity() )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
final TileEntity te = w.getTileEntity( x, y, z );
|
||||
final TileEntity te = w.getTileEntity( pos );
|
||||
if( this.tileEntityType.isInstance( te ) )
|
||||
{
|
||||
return (T) te;
|
||||
@@ -150,51 +158,58 @@ public abstract class AEBaseTileBlock extends AEBaseBlock implements IAEFeature,
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock( World w, int x, int y, int z, Block a, int b )
|
||||
public void breakBlock(
|
||||
World w,
|
||||
BlockPos pos,
|
||||
IBlockState state )
|
||||
{
|
||||
final AEBaseTile te = this.getTileEntity( w, x, y, z );
|
||||
final AEBaseTile te = this.getTileEntity( w,pos );
|
||||
if( te != null )
|
||||
{
|
||||
final ArrayList<ItemStack> drops = new ArrayList<ItemStack>();
|
||||
if( te.dropItems() )
|
||||
{
|
||||
te.getDrops( w, x, y, z, drops );
|
||||
te.getDrops( w, pos, drops );
|
||||
}
|
||||
else
|
||||
{
|
||||
te.getNoDrops( w, x, y, z, drops );
|
||||
te.getNoDrops( w, pos, drops );
|
||||
}
|
||||
|
||||
// Cry ;_; ...
|
||||
Platform.spawnDrops( w, x, y, z, drops );
|
||||
Platform.spawnDrops( w, pos, drops );
|
||||
}
|
||||
|
||||
// super will remove the TE, as it is not an instance of BlockContainer
|
||||
super.breakBlock( w, x, y, z, a, b );
|
||||
super.breakBlock( w, pos, state );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public final ForgeDirection[] getValidRotations( World w, int x, int y, int z )
|
||||
public final EnumFacing[] getValidRotations( World w, BlockPos pos )
|
||||
{
|
||||
final AEBaseTile obj = this.getTileEntity( w, x, y, z );
|
||||
final AEBaseTile obj = this.getTileEntity( w, pos );
|
||||
if( obj != null && obj.canBeRotated() )
|
||||
{
|
||||
return ForgeDirection.VALID_DIRECTIONS;
|
||||
return EnumFacing.VALUES;
|
||||
}
|
||||
|
||||
return super.getValidRotations( w, x, y, z );
|
||||
return super.getValidRotations( w, pos );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean recolourBlock( World world, int x, int y, int z, ForgeDirection side, int colour )
|
||||
public boolean recolorBlock(
|
||||
World world,
|
||||
BlockPos pos,
|
||||
EnumFacing side,
|
||||
EnumDyeColor color )
|
||||
{
|
||||
final TileEntity te = this.getTileEntity( world, x, y, z );
|
||||
final TileEntity te = this.getTileEntity( world, pos );
|
||||
|
||||
if( te instanceof IColorableTile )
|
||||
{
|
||||
final IColorableTile ct = (IColorableTile) te;
|
||||
final AEColor c = ct.getColor();
|
||||
final AEColor newColor = AEColor.values()[colour];
|
||||
final AEColor newColor = AEColor.values()[color.getMetadata()];
|
||||
|
||||
if( c != newColor )
|
||||
{
|
||||
@@ -204,13 +219,15 @@ public abstract class AEBaseTileBlock extends AEBaseBlock implements IAEFeature,
|
||||
return false;
|
||||
}
|
||||
|
||||
return super.recolourBlock( world, x, y, z, side, colour );
|
||||
return super.recolorBlock( world, pos, side, color);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getComparatorInputOverride( World w, int x, int y, int z, int s )
|
||||
public int getComparatorInputOverride(
|
||||
World w,
|
||||
BlockPos pos )
|
||||
{
|
||||
final TileEntity te = this.getTileEntity( w, x, y, z );
|
||||
final TileEntity te = this.getTileEntity( w, pos );
|
||||
if( te instanceof IInventory )
|
||||
{
|
||||
return Container.calcRedstoneFromInventory( (IInventory) te );
|
||||
@@ -219,41 +236,59 @@ public abstract class AEBaseTileBlock extends AEBaseBlock implements IAEFeature,
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockEventReceived( World p_149696_1_, int p_149696_2_, int p_149696_3_, int p_149696_4_, int p_149696_5_, int p_149696_6_ )
|
||||
public boolean onBlockEventReceived(
|
||||
World worldIn,
|
||||
BlockPos pos,
|
||||
IBlockState state,
|
||||
int eventID,
|
||||
int eventParam )
|
||||
{
|
||||
super.onBlockEventReceived( p_149696_1_, p_149696_2_, p_149696_3_, p_149696_4_, p_149696_5_, p_149696_6_ );
|
||||
final TileEntity tileentity = p_149696_1_.getTileEntity( p_149696_2_, p_149696_3_, p_149696_4_ );
|
||||
return tileentity != null ? tileentity.receiveClientEvent( p_149696_5_, p_149696_6_ ) : false;
|
||||
super.onBlockEventReceived( worldIn, pos, state ,eventID, eventParam);
|
||||
final TileEntity tileentity = worldIn.getTileEntity( pos );
|
||||
return tileentity != null ? tileentity.receiveClientEvent( eventID, eventParam ) : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy( World w, int x, int y, int z, EntityLivingBase player, ItemStack is )
|
||||
public void onBlockPlacedBy(
|
||||
World w,
|
||||
BlockPos pos,
|
||||
IBlockState state,
|
||||
EntityLivingBase placer,
|
||||
ItemStack is )
|
||||
{
|
||||
if( is.hasDisplayName() )
|
||||
{
|
||||
final TileEntity te = this.getTileEntity( w, x, y, z );
|
||||
final TileEntity te = this.getTileEntity( w, pos );
|
||||
if( te instanceof AEBaseTile )
|
||||
{
|
||||
( (AEBaseTile) w.getTileEntity( x, y, z ) ).setName( is.getDisplayName() );
|
||||
( (AEBaseTile) w.getTileEntity( pos ) ).setName( is.getDisplayName() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean onBlockActivated( World w, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ )
|
||||
public boolean onBlockActivated(
|
||||
World w,
|
||||
BlockPos pos,
|
||||
IBlockState state,
|
||||
EntityPlayer player,
|
||||
EnumFacing side,
|
||||
float hitX,
|
||||
float hitY,
|
||||
float hitZ )
|
||||
{
|
||||
if( player != null )
|
||||
{
|
||||
final ItemStack is = player.inventory.getCurrentItem();
|
||||
if( is != null )
|
||||
{
|
||||
if( Platform.isWrench( player, is, x, y, z ) && player.isSneaking() )
|
||||
if( Platform.isWrench( player, is, pos ) && player.isSneaking() )
|
||||
{
|
||||
final Block id = w.getBlock( x, y, z );
|
||||
final Block id = w.getBlockState( pos ).getBlock();
|
||||
if( id != null )
|
||||
{
|
||||
final AEBaseTile tile = this.getTileEntity( w, x, y, z );
|
||||
final ItemStack[] drops = Platform.getBlockDrops( w, x, y, z );
|
||||
final AEBaseTile tile = this.getTileEntity( w, pos );
|
||||
final ItemStack[] drops = Platform.getBlockDrops( w, pos );
|
||||
|
||||
if( tile == null )
|
||||
{
|
||||
@@ -278,11 +313,11 @@ public abstract class AEBaseTileBlock extends AEBaseBlock implements IAEFeature,
|
||||
}
|
||||
}
|
||||
|
||||
if( id.removedByPlayer( w, player, x, y, z, false ) )
|
||||
if( id.removedByPlayer( w, pos, player, false ) )
|
||||
{
|
||||
final List<ItemStack> l = Lists.newArrayList( drops );
|
||||
Platform.spawnDrops( w, x, y, z, l );
|
||||
w.setBlockToAir( x, y, z );
|
||||
Platform.spawnDrops( w, pos, l );
|
||||
w.setBlockToAir( pos );
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@@ -293,7 +328,7 @@ public abstract class AEBaseTileBlock extends AEBaseBlock implements IAEFeature,
|
||||
final IMemoryCard memoryCard = (IMemoryCard) is.getItem();
|
||||
if( player.isSneaking() )
|
||||
{
|
||||
final AEBaseTile t = this.getTileEntity( w, x, y, z );
|
||||
final AEBaseTile t = this.getTileEntity( w, pos );
|
||||
if( t != null )
|
||||
{
|
||||
final String name = this.getUnlocalizedName();
|
||||
@@ -312,7 +347,7 @@ public abstract class AEBaseTileBlock extends AEBaseBlock implements IAEFeature,
|
||||
final NBTTagCompound data = memoryCard.getData( is );
|
||||
if( this.getUnlocalizedName().equals( name ) )
|
||||
{
|
||||
final AEBaseTile t = this.getTileEntity( w, x, y, z );
|
||||
final AEBaseTile t = this.getTileEntity( w, pos );
|
||||
t.uploadSettings( SettingsFrom.MEMORY_CARD, data );
|
||||
memoryCard.notifyUser( player, MemoryCardMessages.SETTINGS_LOADED );
|
||||
}
|
||||
@@ -326,25 +361,25 @@ public abstract class AEBaseTileBlock extends AEBaseBlock implements IAEFeature,
|
||||
}
|
||||
}
|
||||
|
||||
return this.onActivated( w, x, y, z, player, side, hitX, hitY, hitZ );
|
||||
return this.onActivated( w, pos, player, side, hitX, hitY, hitZ );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IOrientable getOrientable( IBlockAccess w, int x, int y, int z )
|
||||
public IOrientable getOrientable( IBlockAccess w, BlockPos pos )
|
||||
{
|
||||
return this.getTileEntity( w, x, y, z );
|
||||
return this.getTileEntity( w, pos );
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICustomCollision getCustomCollision( World w, int x, int y, int z )
|
||||
public ICustomCollision getCustomCollision( World w, BlockPos pos )
|
||||
{
|
||||
final AEBaseTile te = this.getTileEntity( w, x, y, z );
|
||||
final AEBaseTile te = this.getTileEntity( w, pos );
|
||||
if( te instanceof ICustomCollision )
|
||||
{
|
||||
return (ICustomCollision) te;
|
||||
}
|
||||
|
||||
return super.getCustomCollision( w, x, y, z );
|
||||
return super.getCustomCollision( w, pos );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,8 +20,6 @@ package appeng.block;
|
||||
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
|
||||
public class AEDecorativeBlock extends AEBaseBlock
|
||||
@@ -31,15 +29,4 @@ public class AEDecorativeBlock extends AEBaseBlock
|
||||
super( mat );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon( IBlockAccess w, int x, int y, int z, int s )
|
||||
{
|
||||
return super.unmappedGetIcon( w, x, y, z, s );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package appeng.block;
|
||||
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.common.property.IUnlistedProperty;
|
||||
|
||||
public final class UnlistedBlockAccess implements IUnlistedProperty<IBlockAccess>
|
||||
{
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return "ba";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(
|
||||
final IBlockAccess value )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<IBlockAccess> getType()
|
||||
{
|
||||
return IBlockAccess.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String valueToString(
|
||||
final IBlockAccess value )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package appeng.block;
|
||||
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraftforge.common.property.IUnlistedProperty;
|
||||
|
||||
public final class UnlistedBlockPos implements IUnlistedProperty<BlockPos>
|
||||
{
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return "pos";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(
|
||||
final BlockPos value )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<BlockPos> getType()
|
||||
{
|
||||
return BlockPos.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String valueToString(
|
||||
final BlockPos value )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -22,19 +22,18 @@ package appeng.block.crafting;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
import appeng.client.render.blocks.RenderBlockCraftingCPUMonitor;
|
||||
import appeng.client.texture.ExtraBlockTextures;
|
||||
import appeng.client.texture.IAESprite;
|
||||
import appeng.tile.crafting.TileCraftingMonitorTile;
|
||||
|
||||
|
||||
@@ -42,6 +41,7 @@ public class BlockCraftingMonitor extends BlockCraftingUnit
|
||||
{
|
||||
public BlockCraftingMonitor()
|
||||
{
|
||||
super( CraftingUnitType.MONITOR );
|
||||
this.setTileEntity( TileCraftingMonitorTile.class );
|
||||
}
|
||||
|
||||
@@ -52,24 +52,19 @@ public class BlockCraftingMonitor extends BlockCraftingUnit
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon( int direction, int metadata )
|
||||
public IAESprite getIcon(
|
||||
EnumFacing side,
|
||||
IBlockState state )
|
||||
{
|
||||
if( direction != ForgeDirection.SOUTH.ordinal() )
|
||||
if( side != EnumFacing.SOUTH )
|
||||
{
|
||||
for( Block craftingUnitBlock : AEApi.instance().definitions().blocks().craftingUnit().maybeBlock().asSet() )
|
||||
{
|
||||
return craftingUnitBlock.getIcon( direction, metadata );
|
||||
return ( (BlockCraftingUnit)craftingUnitBlock ).getIcon( side, state );
|
||||
}
|
||||
}
|
||||
|
||||
switch( metadata )
|
||||
{
|
||||
default:
|
||||
case 0:
|
||||
return super.getIcon( 0, 0 );
|
||||
case FLAG_FORMED:
|
||||
return ExtraBlockTextures.BlockCraftingMonitorFit_Light.getIcon();
|
||||
}
|
||||
|
||||
return ExtraBlockTextures.BlockCraftingMonitorFit_Light.getIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -24,19 +24,18 @@ import java.util.List;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import appeng.client.texture.ExtraBlockTextures;
|
||||
import appeng.tile.crafting.TileCraftingStorageTile;
|
||||
|
||||
|
||||
public class BlockCraftingStorage extends BlockCraftingUnit
|
||||
{
|
||||
public BlockCraftingStorage()
|
||||
|
||||
public BlockCraftingStorage( CraftingUnitType type )
|
||||
{
|
||||
super(type );
|
||||
this.setTileEntity( TileCraftingStorageTile.class );
|
||||
}
|
||||
|
||||
@@ -47,29 +46,29 @@ public class BlockCraftingStorage extends BlockCraftingUnit
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon( int direction, int metadata )
|
||||
public appeng.client.texture.IAESprite getIcon(net.minecraft.util.EnumFacing side, net.minecraft.block.state.IBlockState state)
|
||||
{
|
||||
switch( metadata & ( ~4 ) )
|
||||
boolean formed = (boolean)state.getValue( FORMED );
|
||||
switch( this.type )
|
||||
{
|
||||
default:
|
||||
|
||||
case 0:
|
||||
return super.getIcon( 0, 0 );
|
||||
case 1:
|
||||
return ExtraBlockTextures.BlockCraftingStorage4k.getIcon();
|
||||
case 2:
|
||||
return ExtraBlockTextures.BlockCraftingStorage16k.getIcon();
|
||||
case 3:
|
||||
return ExtraBlockTextures.BlockCraftingStorage64k.getIcon();
|
||||
|
||||
case FLAG_FORMED:
|
||||
return ExtraBlockTextures.BlockCraftingStorage1kFit.getIcon();
|
||||
case 1 | FLAG_FORMED:
|
||||
return ExtraBlockTextures.BlockCraftingStorage4kFit.getIcon();
|
||||
case 2 | FLAG_FORMED:
|
||||
return ExtraBlockTextures.BlockCraftingStorage16kFit.getIcon();
|
||||
case 3 | FLAG_FORMED:
|
||||
return ExtraBlockTextures.BlockCraftingStorage64kFit.getIcon();
|
||||
case STORAGE_1K:
|
||||
return formed ?
|
||||
super.getIcon( side,state ) :
|
||||
ExtraBlockTextures.BlockCraftingStorage1kFit.getIcon();
|
||||
case STORAGE_4K:
|
||||
return formed ?
|
||||
ExtraBlockTextures.BlockCraftingStorage4k.getIcon() :
|
||||
ExtraBlockTextures.BlockCraftingStorage1kFit.getIcon();
|
||||
case STORAGE_16K:
|
||||
return formed ?
|
||||
ExtraBlockTextures.BlockCraftingStorage16k.getIcon() :
|
||||
ExtraBlockTextures.BlockCraftingStorage16kFit.getIcon();
|
||||
case STORAGE_64K:
|
||||
return formed ?
|
||||
ExtraBlockTextures.BlockCraftingStorage64k.getIcon() :
|
||||
ExtraBlockTextures.BlockCraftingStorage64kFit.getIcon();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,17 +24,20 @@ import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.properties.PropertyBool;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumWorldBlockLayer;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
import appeng.client.render.blocks.RenderBlockCraftingCPU;
|
||||
@@ -44,16 +47,49 @@ import appeng.core.sync.GuiBridge;
|
||||
import appeng.tile.crafting.TileCraftingTile;
|
||||
import appeng.util.Platform;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
|
||||
public class BlockCraftingUnit extends AEBaseTileBlock
|
||||
{
|
||||
public static final PropertyBool POWERED = PropertyBool.create("powered");
|
||||
public static final PropertyBool FORMED = PropertyBool.create("formed");
|
||||
|
||||
public static final int FLAG_FORMED = 8;
|
||||
|
||||
public BlockCraftingUnit()
|
||||
final public CraftingUnitType type;
|
||||
|
||||
public static enum CraftingUnitType
|
||||
{
|
||||
super( Material.iron );
|
||||
UNIT, ACCELERATOR, STORAGE_1K,STORAGE_4K, STORAGE_16K, STORAGE_64K, MONITOR
|
||||
};
|
||||
|
||||
this.hasSubtypes = true;
|
||||
@Override
|
||||
public EnumWorldBlockLayer getBlockLayer()
|
||||
{
|
||||
return EnumWorldBlockLayer.CUTOUT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetaFromState(
|
||||
IBlockState state )
|
||||
{
|
||||
boolean p = (boolean)state.getValue( POWERED );
|
||||
boolean f = (boolean)state.getValue( FORMED );
|
||||
return (p ? 1 : 0) | (f?2 : 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getStateFromMeta( int meta )
|
||||
{
|
||||
return getDefaultState().withProperty( POWERED, ( meta & 1 ) == 1 ? true : false ).withProperty( FORMED, ( meta & 2 ) == 2 ? true : false );
|
||||
}
|
||||
|
||||
public BlockCraftingUnit( CraftingUnitType type )
|
||||
{
|
||||
super( Material.iron, Optional.of(type.name()) );
|
||||
|
||||
this.type = type;
|
||||
this.setTileEntity( TileCraftingTile.class );
|
||||
this.setFeature( EnumSet.of( AEFeature.CraftingCPU ) );
|
||||
}
|
||||
@@ -65,26 +101,34 @@ public class BlockCraftingUnit extends AEBaseTileBlock
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon( int direction, int metadata )
|
||||
public appeng.client.texture.IAESprite getIcon(EnumFacing side, IBlockState state)
|
||||
{
|
||||
switch( metadata )
|
||||
if ( type == CraftingUnitType.ACCELERATOR )
|
||||
{
|
||||
default:
|
||||
case 0:
|
||||
return super.getIcon( 0, 0 );
|
||||
case 1:
|
||||
return ExtraBlockTextures.BlockCraftingAccelerator.getIcon();
|
||||
case FLAG_FORMED:
|
||||
return ExtraBlockTextures.BlockCraftingUnitFit.getIcon();
|
||||
case 1 | FLAG_FORMED:
|
||||
if ( (boolean)state.getValue( FORMED ) )
|
||||
return ExtraBlockTextures.BlockCraftingAcceleratorFit.getIcon();
|
||||
|
||||
return ExtraBlockTextures.BlockCraftingAccelerator.getIcon();
|
||||
}
|
||||
|
||||
if ( (boolean)state.getValue( FORMED ) )
|
||||
return ExtraBlockTextures.BlockCraftingUnitFit.getIcon();
|
||||
|
||||
return super.getIcon( side,state );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActivated( World w, int x, int y, int z, EntityPlayer p, int side, float hitX, float hitY, float hitZ )
|
||||
{
|
||||
TileCraftingTile tg = this.getTileEntity( w, x, y, z );
|
||||
@Override
|
||||
public boolean onBlockActivated(
|
||||
World w,
|
||||
BlockPos pos,
|
||||
IBlockState state,
|
||||
EntityPlayer p,
|
||||
EnumFacing side,
|
||||
float hitX,
|
||||
float hitY,
|
||||
float hitZ )
|
||||
{
|
||||
TileCraftingTile tg = this.getTileEntity( w, pos );
|
||||
if( tg != null && !p.isSneaking() && tg.isFormed() && tg.isActive() )
|
||||
{
|
||||
if( Platform.isClient() )
|
||||
@@ -92,7 +136,7 @@ public class BlockCraftingUnit extends AEBaseTileBlock
|
||||
return true;
|
||||
}
|
||||
|
||||
Platform.openGUI( p, tg, ForgeDirection.getOrientation( side ), GuiBridge.GUI_CRAFTING_CPU );
|
||||
Platform.openGUI( p, tg, AEPartLocation.fromFacing( side ), GuiBridge.GUI_CRAFTING_CPU );
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -108,23 +152,18 @@ public class BlockCraftingUnit extends AEBaseTileBlock
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRenderStateByMeta( int itemDamage )
|
||||
public void breakBlock(
|
||||
World w,
|
||||
BlockPos pos,
|
||||
IBlockState state )
|
||||
{
|
||||
IIcon front = this.getIcon( ForgeDirection.SOUTH.ordinal(), itemDamage );
|
||||
IIcon other = this.getIcon( ForgeDirection.NORTH.ordinal(), itemDamage );
|
||||
this.getRendererInstance().setTemporaryRenderIcons( other, other, front, other, other, other );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock( World w, int x, int y, int z, Block a, int b )
|
||||
{
|
||||
TileCraftingTile cp = this.getTileEntity( w, x, y, z );
|
||||
TileCraftingTile cp = this.getTileEntity( w, pos );
|
||||
if( cp != null )
|
||||
{
|
||||
cp.breakCluster();
|
||||
}
|
||||
|
||||
super.breakBlock( w, x, y, z, a, b );
|
||||
super.breakBlock( w, pos, state );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -144,25 +183,23 @@ public class BlockCraftingUnit extends AEBaseTileBlock
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange( World w, int x, int y, int z, Block junk )
|
||||
protected IProperty[] getAEStates()
|
||||
{
|
||||
TileCraftingTile cp = this.getTileEntity( w, x, y, z );
|
||||
return new IProperty[]{POWERED, FORMED };
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange(
|
||||
World worldIn,
|
||||
BlockPos pos,
|
||||
IBlockState state,
|
||||
Block neighborBlock )
|
||||
{
|
||||
TileCraftingTile cp = this.getTileEntity( worldIn, pos );
|
||||
if( cp != null )
|
||||
{
|
||||
cp.updateMultiBlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped( int meta )
|
||||
{
|
||||
return meta & 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDamageValue( World w, int x, int y, int z )
|
||||
{
|
||||
int meta = w.getBlockMetadata( x, y, z );
|
||||
return this.damageDropped( meta );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,13 +22,15 @@ package appeng.block.crafting;
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumWorldBlockLayer;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
import appeng.client.render.blocks.RenderBlockAssembler;
|
||||
@@ -41,8 +43,6 @@ import appeng.util.Platform;
|
||||
public class BlockMolecularAssembler extends AEBaseTileBlock
|
||||
{
|
||||
|
||||
public static boolean booleanAlphaPass = false;
|
||||
|
||||
public BlockMolecularAssembler()
|
||||
{
|
||||
super( Material.iron );
|
||||
@@ -54,18 +54,10 @@ public class BlockMolecularAssembler extends AEBaseTileBlock
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderBlockPass()
|
||||
{
|
||||
return 1;
|
||||
public boolean canRenderInLayer(net.minecraft.util.EnumWorldBlockLayer layer) {
|
||||
return layer == EnumWorldBlockLayer.CUTOUT_MIPPED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canRenderInPass( int pass )
|
||||
{
|
||||
booleanAlphaPass = pass == 1;
|
||||
return pass == 0 || pass == 1;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public Class<? extends BaseBlockRender> getRenderer()
|
||||
@@ -74,12 +66,20 @@ public class BlockMolecularAssembler extends AEBaseTileBlock
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActivated( World w, int x, int y, int z, EntityPlayer p, int side, float hitX, float hitY, float hitZ )
|
||||
public boolean onBlockActivated(
|
||||
World w,
|
||||
BlockPos pos,
|
||||
IBlockState state,
|
||||
EntityPlayer p,
|
||||
EnumFacing side,
|
||||
float hitX,
|
||||
float hitY,
|
||||
float hitZ )
|
||||
{
|
||||
TileMolecularAssembler tg = this.getTileEntity( w, x, y, z );
|
||||
TileMolecularAssembler tg = this.getTileEntity( w, pos );
|
||||
if( tg != null && !p.isSneaking() )
|
||||
{
|
||||
Platform.openGUI( p, tg, ForgeDirection.getOrientation( side ), GuiBridge.GUI_MAC );
|
||||
Platform.openGUI( p, tg, AEPartLocation.fromFacing( side ), GuiBridge.GUI_MAC );
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -21,7 +21,6 @@ package appeng.block.crafting;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.block.AEBaseItemBlock;
|
||||
import appeng.core.AEConfig;
|
||||
|
||||
@@ -23,14 +23,15 @@ import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.FakePlayer;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import appeng.api.implementations.tiles.ICrankable;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
@@ -60,17 +61,24 @@ public class BlockCrank extends AEBaseTileBlock
|
||||
{
|
||||
return RenderBlockCrank.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onActivated( World w, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ )
|
||||
public boolean onActivated(
|
||||
World w,
|
||||
BlockPos pos,
|
||||
EntityPlayer player,
|
||||
EnumFacing side,
|
||||
float hitX,
|
||||
float hitY,
|
||||
float hitZ )
|
||||
{
|
||||
if( player instanceof FakePlayer || player == null )
|
||||
{
|
||||
this.dropCrank( w, x, y, z );
|
||||
this.dropCrank( w, pos );
|
||||
return true;
|
||||
}
|
||||
|
||||
AEBaseTile tile = this.getTileEntity( w, x, y, z );
|
||||
AEBaseTile tile = this.getTileEntity( w, pos );
|
||||
if( tile instanceof TileCrank )
|
||||
{
|
||||
if( ( (TileCrank) tile ).power() )
|
||||
@@ -82,78 +90,93 @@ public class BlockCrank extends AEBaseTileBlock
|
||||
return true;
|
||||
}
|
||||
|
||||
private void dropCrank( World world, int x, int y, int z )
|
||||
private void dropCrank( World world, BlockPos pos )
|
||||
{
|
||||
world.func_147480_a( x, y, z, true ); // w.destroyBlock( x, y, z, true );
|
||||
world.markBlockForUpdate( x, y, z );
|
||||
world.destroyBlock( pos, true ); // w.destroyBlock( x, y, z, true );
|
||||
world.markBlockForUpdate( pos );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy( World world, int x, int y, int z, EntityLivingBase placer, ItemStack itemStack )
|
||||
public void onBlockPlacedBy(
|
||||
World world,
|
||||
BlockPos pos,
|
||||
IBlockState state,
|
||||
EntityLivingBase placer,
|
||||
ItemStack stack )
|
||||
{
|
||||
AEBaseTile tile = this.getTileEntity( world, x, y, z );
|
||||
AEBaseTile tile = this.getTileEntity( world, pos );
|
||||
if( tile != null )
|
||||
{
|
||||
ForgeDirection mnt = this.findCrankable( world, x, y, z );
|
||||
ForgeDirection forward = ForgeDirection.UP;
|
||||
if( mnt == ForgeDirection.UP || mnt == ForgeDirection.DOWN )
|
||||
EnumFacing mnt = this.findCrankable( world, pos );
|
||||
EnumFacing forward = EnumFacing.UP;
|
||||
if( mnt == EnumFacing.UP || mnt == EnumFacing.DOWN )
|
||||
{
|
||||
forward = ForgeDirection.SOUTH;
|
||||
forward = EnumFacing.SOUTH;
|
||||
}
|
||||
tile.setOrientation( forward, mnt.getOpposite() );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.dropCrank( world, x, y, z );
|
||||
this.dropCrank( world, pos );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isValidOrientation( World world, int x, int y, int z, ForgeDirection forward, ForgeDirection up )
|
||||
public boolean isValidOrientation(
|
||||
World w,
|
||||
BlockPos pos,
|
||||
EnumFacing forward,
|
||||
EnumFacing up )
|
||||
{
|
||||
TileEntity te = world.getTileEntity( x, y, z );
|
||||
return !( te instanceof TileCrank ) || this.isCrankable( world, x, y, z, up.getOpposite() );
|
||||
TileEntity te = w.getTileEntity( pos );
|
||||
return !( te instanceof TileCrank ) || this.isCrankable( w, pos, up.getOpposite() );
|
||||
}
|
||||
|
||||
private ForgeDirection findCrankable( World world, int x, int y, int z )
|
||||
private EnumFacing findCrankable( World world, BlockPos pos )
|
||||
{
|
||||
for( ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS )
|
||||
for( EnumFacing dir : EnumFacing.VALUES )
|
||||
{
|
||||
if( this.isCrankable( world, x, y, z, dir ) )
|
||||
if( this.isCrankable( world, pos, dir ) )
|
||||
{
|
||||
return dir;
|
||||
}
|
||||
}
|
||||
return ForgeDirection.UNKNOWN;
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean isCrankable( World world, int x, int y, int z, ForgeDirection offset )
|
||||
private boolean isCrankable( World world, BlockPos pos, EnumFacing offset )
|
||||
{
|
||||
TileEntity te = world.getTileEntity( x + offset.offsetX, y + offset.offsetY, z + offset.offsetZ );
|
||||
BlockPos o = pos.offset( offset);
|
||||
TileEntity te = world.getTileEntity( o );
|
||||
|
||||
return te instanceof ICrankable && ( (ICrankable) te ).canCrankAttach( offset.getOpposite() );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange( World world, int x, int y, int z, Block block )
|
||||
public void onNeighborBlockChange(
|
||||
World world,
|
||||
BlockPos pos,
|
||||
IBlockState state,
|
||||
Block neighborBlock )
|
||||
{
|
||||
AEBaseTile tile = this.getTileEntity( world, x, y, z );
|
||||
|
||||
AEBaseTile tile = this.getTileEntity( world, pos );
|
||||
if( tile != null )
|
||||
{
|
||||
if( !this.isCrankable( world, x, y, z, tile.getUp().getOpposite() ) )
|
||||
if( !this.isCrankable( world, pos, tile.getUp().getOpposite() ) )
|
||||
{
|
||||
this.dropCrank( world, x, y, z );
|
||||
this.dropCrank( world, pos );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.dropCrank( world, x, y, z );
|
||||
this.dropCrank( world, pos );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlaceBlockAt( World world, int x, int y, int z )
|
||||
public boolean canPlaceBlockAt( World world, BlockPos pos )
|
||||
{
|
||||
return this.findCrankable( world, x, y, z ) != ForgeDirection.UNKNOWN;
|
||||
return this.findCrankable( world, pos ) != null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,10 +22,12 @@ package appeng.block.grindstone;
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
@@ -46,12 +48,34 @@ public class BlockGrinder extends AEBaseTileBlock
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActivated( World w, int x, int y, int z, EntityPlayer p, int side, float hitX, float hitY, float hitZ )
|
||||
public boolean onBlockActivated(
|
||||
World worldIn,
|
||||
BlockPos pos,
|
||||
IBlockState state,
|
||||
EntityPlayer playerIn,
|
||||
EnumFacing side,
|
||||
float hitX,
|
||||
float hitY,
|
||||
float hitZ )
|
||||
{
|
||||
TileGrinder tg = this.getTileEntity( w, x, y, z );
|
||||
// TODO Auto-generated method stub
|
||||
return super.onBlockActivated( worldIn, pos, state, playerIn, side, hitX, hitY, hitZ );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActivated(
|
||||
World w,
|
||||
BlockPos pos,
|
||||
EntityPlayer p,
|
||||
EnumFacing side,
|
||||
float hitX,
|
||||
float hitY,
|
||||
float hitZ )
|
||||
{
|
||||
TileGrinder tg = this.getTileEntity( w, pos );
|
||||
if( tg != null && !p.isSneaking() )
|
||||
{
|
||||
Platform.openGUI( p, tg, ForgeDirection.getOrientation( side ), GuiBridge.GUI_GRINDER );
|
||||
Platform.openGUI( p, tg, AEPartLocation.fromFacing( side ), GuiBridge.GUI_GRINDER );
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -23,9 +23,10 @@ import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
@@ -45,19 +46,26 @@ public class BlockCellWorkbench extends AEBaseTileBlock
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActivated( World w, int x, int y, int z, EntityPlayer p, int side, float hitX, float hitY, float hitZ )
|
||||
public boolean onActivated(
|
||||
World w,
|
||||
BlockPos pos,
|
||||
EntityPlayer p,
|
||||
EnumFacing side,
|
||||
float hitX,
|
||||
float hitY,
|
||||
float hitZ )
|
||||
{
|
||||
if( p.isSneaking() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
TileCellWorkbench tg = this.getTileEntity( w, x, y, z );
|
||||
TileCellWorkbench tg = this.getTileEntity( w, pos );
|
||||
if( tg != null )
|
||||
{
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
Platform.openGUI( p, tg, ForgeDirection.getOrientation( side ), GuiBridge.GUI_CELL_WORKBENCH );
|
||||
Platform.openGUI( p, tg, AEPartLocation.fromFacing( side ), GuiBridge.GUI_CELL_WORKBENCH );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -25,17 +25,18 @@ import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.util.AEAxisAlignedBB;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
import appeng.client.render.blocks.RenderBlockCharger;
|
||||
@@ -69,7 +70,14 @@ public class BlockCharger extends AEBaseTileBlock implements ICustomCollision
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActivated( World w, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ )
|
||||
public boolean onActivated(
|
||||
World w,
|
||||
BlockPos pos,
|
||||
EntityPlayer player,
|
||||
EnumFacing side,
|
||||
float hitX,
|
||||
float hitY,
|
||||
float hitZ )
|
||||
{
|
||||
if( player.isSneaking() )
|
||||
{
|
||||
@@ -78,7 +86,7 @@ public class BlockCharger extends AEBaseTileBlock implements ICustomCollision
|
||||
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
TileCharger tc = this.getTileEntity( w, x, y, z );
|
||||
TileCharger tc = this.getTileEntity( w, pos );
|
||||
if( tc != null )
|
||||
{
|
||||
tc.activate( player );
|
||||
@@ -87,10 +95,14 @@ public class BlockCharger extends AEBaseTileBlock implements ICustomCollision
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void randomDisplayTick( World w, int x, int y, int z, Random r )
|
||||
public void randomDisplayTick(
|
||||
World w,
|
||||
BlockPos pos,
|
||||
IBlockState state,
|
||||
Random r )
|
||||
{
|
||||
if( !AEConfig.instance.enableEffects )
|
||||
{
|
||||
@@ -102,7 +114,7 @@ public class BlockCharger extends AEBaseTileBlock implements ICustomCollision
|
||||
return;
|
||||
}
|
||||
|
||||
AEBaseTile tile = this.getTileEntity( w, x, y, z );
|
||||
AEBaseTile tile = this.getTileEntity( w, pos );
|
||||
if( tile instanceof TileCharger )
|
||||
{
|
||||
TileCharger tc = (TileCharger) tile;
|
||||
@@ -117,7 +129,7 @@ public class BlockCharger extends AEBaseTileBlock implements ICustomCollision
|
||||
{
|
||||
if( CommonHelper.proxy.shouldAddParticles( r ) )
|
||||
{
|
||||
LightningFX fx = new LightningFX( w, xOff + 0.5 + x, yOff + 0.5 + y, zOff + 0.5 + z, 0.0D, 0.0D, 0.0D );
|
||||
LightningFX fx = new LightningFX( w, xOff + 0.5 + pos.getX(), yOff + 0.5 + pos.getY(), zOff + 0.5 + pos.getZ(), 0.0D, 0.0D, 0.0D );
|
||||
Minecraft.getMinecraft().effectRenderer.addEffect( fx );
|
||||
}
|
||||
}
|
||||
@@ -126,27 +138,31 @@ public class BlockCharger extends AEBaseTileBlock implements ICustomCollision
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool( World w, int x, int y, int z, Entity e, boolean isVisual )
|
||||
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool(
|
||||
World w,
|
||||
BlockPos pos,
|
||||
Entity thePlayer,
|
||||
boolean b )
|
||||
{
|
||||
TileCharger tile = this.getTileEntity( w, x, y, z );
|
||||
TileCharger tile = this.getTileEntity( w, pos );
|
||||
if( tile != null )
|
||||
{
|
||||
double twoPixels = 2.0 / 16.0;
|
||||
ForgeDirection up = tile.getUp();
|
||||
ForgeDirection forward = tile.getForward();
|
||||
AxisAlignedBB bb = AxisAlignedBB.getBoundingBox( twoPixels, twoPixels, twoPixels, 1.0 - twoPixels, 1.0 - twoPixels, 1.0 - twoPixels );
|
||||
EnumFacing up = tile.getUp();
|
||||
EnumFacing forward = tile.getForward();
|
||||
AEAxisAlignedBB bb = AEAxisAlignedBB.fromBounds( twoPixels, twoPixels, twoPixels, 1.0 - twoPixels, 1.0 - twoPixels, 1.0 - twoPixels );
|
||||
|
||||
if( up.offsetX != 0 )
|
||||
if( up.getFrontOffsetX() != 0 )
|
||||
{
|
||||
bb.minX = 0;
|
||||
bb.maxX = 1;
|
||||
}
|
||||
if( up.offsetY != 0 )
|
||||
if( up.getFrontOffsetY() != 0 )
|
||||
{
|
||||
bb.minY = 0;
|
||||
bb.maxY = 1;
|
||||
}
|
||||
if( up.offsetZ != 0 )
|
||||
if( up.getFrontOffsetZ() != 0 )
|
||||
{
|
||||
bb.minZ = 0;
|
||||
bb.maxZ = 1;
|
||||
@@ -176,14 +192,19 @@ public class BlockCharger extends AEBaseTileBlock implements ICustomCollision
|
||||
break;
|
||||
}
|
||||
|
||||
return Collections.singletonList( bb );
|
||||
return Collections.singletonList( bb.getBoundingBox() );
|
||||
}
|
||||
return Collections.singletonList( AxisAlignedBB.getBoundingBox( 0.0, 0, 0.0, 1.0, 1.0, 1.0 ) );
|
||||
return Collections.singletonList( AxisAlignedBB.fromBounds( 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<AxisAlignedBB> out, Entity e )
|
||||
public void addCollidingBlockToList(
|
||||
World w,
|
||||
BlockPos pos,
|
||||
AxisAlignedBB bb,
|
||||
List<AxisAlignedBB> out,
|
||||
Entity e )
|
||||
{
|
||||
out.add( AxisAlignedBB.getBoundingBox( 0.0, 0.0, 0.0, 1.0, 1.0, 1.0 ) );
|
||||
out.add( AxisAlignedBB.fromBounds( 0.0, 0.0, 0.0, 1.0, 1.0, 1.0 ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,9 +23,10 @@ import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
@@ -45,7 +46,14 @@ public class BlockCondenser extends AEBaseTileBlock
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActivated( World w, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ )
|
||||
public boolean onActivated(
|
||||
World w,
|
||||
BlockPos pos,
|
||||
EntityPlayer player,
|
||||
EnumFacing side,
|
||||
float hitX,
|
||||
float hitY,
|
||||
float hitZ )
|
||||
{
|
||||
if( player.isSneaking() )
|
||||
{
|
||||
@@ -54,10 +62,10 @@ public class BlockCondenser extends AEBaseTileBlock
|
||||
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
TileCondenser tc = this.getTileEntity( w, x, y, z );
|
||||
TileCondenser tc = this.getTileEntity( w, pos );
|
||||
if( tc != null && !player.isSneaking() )
|
||||
{
|
||||
Platform.openGUI( player, tc, ForgeDirection.getOrientation( side ), GuiBridge.GUI_CONDENSER );
|
||||
Platform.openGUI( player, tc, AEPartLocation.fromFacing( side ), GuiBridge.GUI_CONDENSER );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,9 +23,10 @@ import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
import appeng.client.render.blocks.RenderBlockInscriber;
|
||||
@@ -53,21 +54,28 @@ public class BlockInscriber extends AEBaseTileBlock
|
||||
{
|
||||
return RenderBlockInscriber.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onActivated( World w, int x, int y, int z, EntityPlayer p, int side, float hitX, float hitY, float hitZ )
|
||||
public boolean onActivated(
|
||||
World w,
|
||||
BlockPos pos,
|
||||
EntityPlayer p,
|
||||
EnumFacing side,
|
||||
float hitX,
|
||||
float hitY,
|
||||
float hitZ )
|
||||
{
|
||||
if( p.isSneaking() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
TileInscriber tg = this.getTileEntity( w, x, y, z );
|
||||
TileInscriber tg = this.getTileEntity( w, pos );
|
||||
if( tg != null )
|
||||
{
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
Platform.openGUI( p, tg, ForgeDirection.getOrientation( side ), GuiBridge.GUI_INSCRIBER );
|
||||
Platform.openGUI( p, tg, AEPartLocation.fromFacing( side ), GuiBridge.GUI_INSCRIBER );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -23,9 +23,10 @@ import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.api.util.IOrientable;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
@@ -54,19 +55,26 @@ public class BlockInterface extends AEBaseTileBlock
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActivated( World w, int x, int y, int z, EntityPlayer p, int side, float hitX, float hitY, float hitZ )
|
||||
public boolean onActivated(
|
||||
World w,
|
||||
BlockPos pos,
|
||||
EntityPlayer p,
|
||||
EnumFacing side,
|
||||
float hitX,
|
||||
float hitY,
|
||||
float hitZ )
|
||||
{
|
||||
if( p.isSneaking() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
TileInterface tg = this.getTileEntity( w, x, y, z );
|
||||
TileInterface tg = this.getTileEntity( w, pos );
|
||||
if( tg != null )
|
||||
{
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
Platform.openGUI( p, tg, ForgeDirection.getOrientation( side ), GuiBridge.GUI_INTERFACE );
|
||||
Platform.openGUI( p, tg, AEPartLocation.fromFacing( side ), GuiBridge.GUI_INTERFACE );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -80,11 +88,11 @@ public class BlockInterface extends AEBaseTileBlock
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void customRotateBlock( IOrientable rotatable, ForgeDirection axis )
|
||||
protected void customRotateBlock( IOrientable rotatable, EnumFacing axis )
|
||||
{
|
||||
if( rotatable instanceof TileInterface )
|
||||
{
|
||||
( (TileInterface) rotatable ).setSide( axis );
|
||||
( (TileInterface) rotatable ).setSide( AEPartLocation.fromFacing( axis ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,20 +25,19 @@ import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockTorch;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import appeng.api.util.IOrientable;
|
||||
import appeng.api.util.IOrientableBlock;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
import appeng.client.render.blocks.RenderQuartzTorch;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.helpers.ICustomCollision;
|
||||
@@ -46,14 +45,13 @@ import appeng.helpers.MetaRotation;
|
||||
import appeng.tile.misc.TileLightDetector;
|
||||
|
||||
|
||||
public class BlockLightDetector extends AEBaseTileBlock implements IOrientableBlock, ICustomCollision
|
||||
public class BlockLightDetector extends AEBaseTileBlock implements IOrientableBlock,ICustomCollision
|
||||
{
|
||||
|
||||
public BlockLightDetector()
|
||||
{
|
||||
super( Material.circuits );
|
||||
|
||||
this.setLightLevel( 0.9375F );
|
||||
this.setLightOpacity( 0 );
|
||||
this.isFullSize = false;
|
||||
this.isOpaque = false;
|
||||
@@ -63,22 +61,49 @@ public class BlockLightDetector extends AEBaseTileBlock implements IOrientableBl
|
||||
}
|
||||
|
||||
@Override
|
||||
public int isProvidingWeakPower( IBlockAccess w, int x, int y, int z, int side )
|
||||
public int getMetaFromState(
|
||||
IBlockState state )
|
||||
{
|
||||
if( w instanceof World && ( (TileLightDetector) this.getTileEntity( w, x, y, z ) ).isReady() )
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getStateFromMeta(
|
||||
int meta )
|
||||
{
|
||||
return getDefaultState();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IProperty[] getAEStates()
|
||||
{
|
||||
return new IProperty[]{ BlockTorch.FACING };
|
||||
}
|
||||
|
||||
@Override
|
||||
public int isProvidingWeakPower(
|
||||
IBlockAccess w,
|
||||
BlockPos pos,
|
||||
IBlockState state,
|
||||
EnumFacing side )
|
||||
{
|
||||
if( w instanceof World && ( (TileLightDetector) this.getTileEntity( w, pos ) ).isReady() )
|
||||
{
|
||||
return ( (World) w ).getBlockLightValue( x, y, z ) - 6;
|
||||
return ( (World) w ).getLightFromNeighbors( pos ) - 6;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborChange( IBlockAccess world, int x, int y, int z, int tileX, int tileY, int tileZ )
|
||||
public void onNeighborChange(
|
||||
IBlockAccess world,
|
||||
BlockPos pos,
|
||||
BlockPos neighbor )
|
||||
{
|
||||
super.onNeighborChange( world, x, y, z, tileX, tileY, tileZ );
|
||||
super.onNeighborChange( world, pos, neighbor );
|
||||
|
||||
TileLightDetector tld = this.getTileEntity( world, x, y, z );
|
||||
TileLightDetector tld = this.getTileEntity( world, pos );
|
||||
if( tld != null )
|
||||
{
|
||||
tld.updateLight();
|
||||
@@ -86,8 +111,11 @@ public class BlockLightDetector extends AEBaseTileBlock implements IOrientableBl
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void randomDisplayTick( World w, int x, int y, int z, Random r )
|
||||
public void randomDisplayTick(
|
||||
World worldIn,
|
||||
BlockPos pos,
|
||||
IBlockState state,
|
||||
Random rand )
|
||||
{
|
||||
// cancel out lightning
|
||||
}
|
||||
@@ -99,58 +127,76 @@ public class BlockLightDetector extends AEBaseTileBlock implements IOrientableBl
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidOrientation( World w, int x, int y, int z, ForgeDirection forward, ForgeDirection up )
|
||||
public boolean isValidOrientation(
|
||||
World w,
|
||||
BlockPos pos,
|
||||
EnumFacing forward,
|
||||
EnumFacing up )
|
||||
{
|
||||
return this.canPlaceAt( w, x, y, z, up.getOpposite() );
|
||||
return this.canPlaceAt( w, pos, up.getOpposite() );
|
||||
}
|
||||
|
||||
private boolean canPlaceAt( World w, int x, int y, int z, ForgeDirection dir )
|
||||
private boolean canPlaceAt( World w, BlockPos pos, EnumFacing dir )
|
||||
{
|
||||
return w.isSideSolid( x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ, dir.getOpposite(), false );
|
||||
return w.isSideSolid( pos.offset( dir ), dir.getOpposite(), false );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool(
|
||||
World w,
|
||||
BlockPos pos,
|
||||
Entity thePlayer,
|
||||
boolean b )
|
||||
{
|
||||
EnumFacing up = this.getOrientable( w, pos ).getUp();
|
||||
double xOff = -0.3 * up.getFrontOffsetX();
|
||||
double yOff = -0.3 * up.getFrontOffsetY();
|
||||
double zOff = -0.3 * up.getFrontOffsetZ();
|
||||
return Collections.singletonList( AxisAlignedBB.fromBounds( xOff + 0.3, yOff + 0.3, zOff + 0.3, xOff + 0.7, yOff + 0.7, zOff + 0.7 ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool( World w, int x, int y, int z, Entity e, boolean isVisual )
|
||||
{
|
||||
ForgeDirection up = this.getOrientable( w, x, y, z ).getUp();
|
||||
double xOff = -0.3 * up.offsetX;
|
||||
double yOff = -0.3 * up.offsetY;
|
||||
double zOff = -0.3 * up.offsetZ;
|
||||
return Collections.singletonList( AxisAlignedBB.getBoundingBox( xOff + 0.3, yOff + 0.3, zOff + 0.3, xOff + 0.7, yOff + 0.7, zOff + 0.7 ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCollidingBlockToList( World w, int x, int y, int z, AxisAlignedBB bb, List out, Entity e )
|
||||
public void addCollidingBlockToList(
|
||||
World w,
|
||||
BlockPos pos,
|
||||
AxisAlignedBB bb,
|
||||
List<AxisAlignedBB> out,
|
||||
Entity e )
|
||||
{/*
|
||||
* double xOff = -0.15 * getUp().offsetX; double yOff = -0.15 * getUp().offsetY; double zOff = -0.15 *
|
||||
* getUp().offsetZ; out.add( AxisAlignedBB.getBoundingBox( xOff + (double) x + 0.15, yOff + (double) y + 0.15, zOff
|
||||
* + (double) z + 0.15,// ahh xOff + (double) x + 0.85, yOff + (double) y + 0.85, zOff + (double) z + 0.85 ) );
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange( World w, int x, int y, int z, Block id )
|
||||
public void onNeighborBlockChange(
|
||||
World w,
|
||||
BlockPos pos,
|
||||
IBlockState state,
|
||||
Block neighborBlock )
|
||||
{
|
||||
ForgeDirection up = this.getOrientable( w, x, y, z ).getUp();
|
||||
if( !this.canPlaceAt( w, x, y, z, up.getOpposite() ) )
|
||||
EnumFacing up = this.getOrientable( w, pos ).getUp();
|
||||
if( !this.canPlaceAt( w, pos, up.getOpposite() ) )
|
||||
{
|
||||
this.dropTorch( w, x, y, z );
|
||||
this.dropTorch( w, pos );
|
||||
}
|
||||
}
|
||||
|
||||
private void dropTorch( World w, int x, int y, int z )
|
||||
private void dropTorch( World w, BlockPos pos )
|
||||
{
|
||||
w.func_147480_a( x, y, z, true );
|
||||
// w.destroyBlock( x, y, z, true );
|
||||
w.markBlockForUpdate( x, y, z );
|
||||
w.destroyBlock( pos, true );
|
||||
w.markBlockForUpdate( pos );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean canPlaceBlockAt( World w, int x, int y, int z )
|
||||
public boolean canPlaceBlockAt(
|
||||
World w,
|
||||
BlockPos pos )
|
||||
{
|
||||
for( ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS )
|
||||
for( EnumFacing dir : EnumFacing.VALUES )
|
||||
{
|
||||
if( this.canPlaceAt( w, x, y, z, dir ) )
|
||||
if( this.canPlaceAt( w, pos, dir ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -165,8 +211,8 @@ public class BlockLightDetector extends AEBaseTileBlock implements IOrientableBl
|
||||
}
|
||||
|
||||
@Override
|
||||
public IOrientable getOrientable( final IBlockAccess w, final int x, final int y, final int z )
|
||||
public IOrientable getOrientable( final IBlockAccess w, BlockPos pos )
|
||||
{
|
||||
return new MetaRotation( w, x, y, z );
|
||||
return new MetaRotation( w, pos,true );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,16 +26,17 @@ import java.util.Random;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.MapColor;
|
||||
import net.minecraft.block.material.MaterialLiquid;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumWorldBlockLayer;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
import appeng.client.render.blocks.RenderBlockPaint;
|
||||
@@ -58,6 +59,12 @@ public class BlockPaint extends AEBaseTileBlock
|
||||
this.setFeature( EnumSet.of( AEFeature.PaintBalls ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumWorldBlockLayer getBlockLayer()
|
||||
{
|
||||
return EnumWorldBlockLayer.CUTOUT;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<? extends BaseBlockRender> getRenderer()
|
||||
{
|
||||
@@ -70,23 +77,32 @@ public class BlockPaint extends AEBaseTileBlock
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool( World world, int x, int y, int z )
|
||||
public AxisAlignedBB getCollisionBoundingBox(
|
||||
World worldIn,
|
||||
BlockPos pos,
|
||||
IBlockState state )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCollideCheck( int metadata, boolean isHoldingRightClick )
|
||||
public boolean canCollideCheck(
|
||||
IBlockState state,
|
||||
boolean hitIfLiquid )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange( World w, int x, int y, int z, Block junk )
|
||||
public void onNeighborBlockChange(
|
||||
World w,
|
||||
BlockPos pos,
|
||||
IBlockState state,
|
||||
Block neighborBlock )
|
||||
{
|
||||
TilePaint tp = this.getTileEntity( w, x, y, z );
|
||||
TilePaint tp = this.getTileEntity( w, pos );
|
||||
|
||||
if( tp != null )
|
||||
{
|
||||
@@ -95,30 +111,42 @@ public class BlockPaint extends AEBaseTileBlock
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getItemDropped( int meta, Random random, int fortune )
|
||||
public Item getItemDropped(
|
||||
IBlockState state,
|
||||
Random rand,
|
||||
int fortune )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dropBlockAsItemWithChance( World world, int x, int y, int z, int meta, float chance, int fortune )
|
||||
public void dropBlockAsItemWithChance(
|
||||
World worldIn,
|
||||
BlockPos pos,
|
||||
IBlockState state,
|
||||
float chance,
|
||||
int fortune )
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void fillWithRain( World w, int x, int y, int z )
|
||||
public void fillWithRain(
|
||||
World w,
|
||||
BlockPos pos )
|
||||
{
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
w.setBlock( x, y, z, Platform.AIR_BLOCK, 0, 3 );
|
||||
w.setBlockToAir( pos );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getLightValue( IBlockAccess w, int x, int y, int z )
|
||||
public int getLightValue(
|
||||
IBlockAccess w,
|
||||
BlockPos pos )
|
||||
{
|
||||
TilePaint tp = this.getTileEntity( w, x, y, z );
|
||||
TilePaint tp = this.getTileEntity( w, pos );
|
||||
|
||||
if( tp != null )
|
||||
{
|
||||
@@ -129,14 +157,19 @@ public class BlockPaint extends AEBaseTileBlock
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReplaceable( IBlockAccess world, int x, int y, int z )
|
||||
public boolean isAir(
|
||||
IBlockAccess world,
|
||||
BlockPos pos )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isAir( IBlockAccess world, int x, int y, int z )
|
||||
public boolean isReplaceable(
|
||||
World worldIn,
|
||||
BlockPos pos )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,16 +24,11 @@ import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import appeng.api.util.IOrientable;
|
||||
import appeng.api.util.IOrientableBlock;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
import appeng.client.render.blocks.RenderBlockQuartzAccelerator;
|
||||
@@ -41,12 +36,11 @@ import appeng.client.render.effects.LightningFX;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.CommonHelper;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.helpers.MetaRotation;
|
||||
import appeng.tile.misc.TileQuartzGrowthAccelerator;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class BlockQuartzGrowthAccelerator extends AEBaseTileBlock implements IOrientableBlock
|
||||
public class BlockQuartzGrowthAccelerator extends AEBaseTileBlock
|
||||
{
|
||||
|
||||
public BlockQuartzGrowthAccelerator()
|
||||
@@ -64,42 +58,50 @@ public class BlockQuartzGrowthAccelerator extends AEBaseTileBlock implements IOr
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void randomDisplayTick( World w, int x, int y, int z, Random r )
|
||||
public void randomDisplayTick(
|
||||
World w,
|
||||
BlockPos pos,
|
||||
IBlockState state,
|
||||
Random r )
|
||||
{
|
||||
if( !AEConfig.instance.enableEffects )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
TileQuartzGrowthAccelerator cga = this.getTileEntity( w, x, y, z );
|
||||
TileQuartzGrowthAccelerator cga = this.getTileEntity( w, pos );
|
||||
|
||||
if( cga != null && cga.hasPower && CommonHelper.proxy.shouldAddParticles( r ) )
|
||||
{
|
||||
double d0 = r.nextFloat() - 0.5F;
|
||||
double d1 = r.nextFloat() - 0.5F;
|
||||
|
||||
ForgeDirection up = cga.getUp();
|
||||
ForgeDirection forward = cga.getForward();
|
||||
ForgeDirection west = Platform.crossProduct( forward, up );
|
||||
EnumFacing up = cga.getUp();
|
||||
EnumFacing forward = cga.getForward();
|
||||
EnumFacing west = Platform.crossProduct( forward, up );
|
||||
|
||||
double rx = 0.5 + x;
|
||||
double ry = 0.5 + y;
|
||||
double rz = 0.5 + z;
|
||||
double rx = 0.5 + pos.getX();
|
||||
double ry = 0.5 + pos.getY();
|
||||
double rz = 0.5 + pos.getZ();
|
||||
|
||||
double dx = 0;
|
||||
double dz = 0;
|
||||
|
||||
rx += up.offsetX * d0;
|
||||
ry += up.offsetY * d0;
|
||||
rz += up.offsetZ * d0;
|
||||
rx += up.getFrontOffsetX() * d0;
|
||||
ry += up.getFrontOffsetY() * d0;
|
||||
rz += up.getFrontOffsetZ() * d0;
|
||||
|
||||
int x = pos.getX();
|
||||
int y = pos.getY();
|
||||
int z = pos.getZ();
|
||||
|
||||
switch( r.nextInt( 4 ) )
|
||||
{
|
||||
case 0:
|
||||
dx = 0.6;
|
||||
dz = d1;
|
||||
if( !w.getBlock( x + west.offsetX, y + west.offsetY, z + west.offsetZ ).isAir( w, x + west.offsetX, y + west.offsetY, z + west.offsetZ ) )
|
||||
BlockPos pt = new BlockPos( x + west.getFrontOffsetX(), y + west.getFrontOffsetY(), z + west.getFrontOffsetZ() );
|
||||
if( !w.getBlockState(pt).getBlock().isAir( w, pt) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -107,7 +109,8 @@ public class BlockQuartzGrowthAccelerator extends AEBaseTileBlock implements IOr
|
||||
case 1:
|
||||
dx = d1;
|
||||
dz += 0.6;
|
||||
if( !w.getBlock( x + forward.offsetX, y + forward.offsetY, z + forward.offsetZ ).isAir( w, x + forward.offsetX, y + forward.offsetY, z + forward.offsetZ ) )
|
||||
pt = new BlockPos( x + forward.getFrontOffsetX(), y + forward.getFrontOffsetY(), z + forward.getFrontOffsetZ() );
|
||||
if( !w.getBlockState(pt).getBlock().isAir( w, pt) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -115,7 +118,8 @@ public class BlockQuartzGrowthAccelerator extends AEBaseTileBlock implements IOr
|
||||
case 2:
|
||||
dx = d1;
|
||||
dz = -0.6;
|
||||
if( !w.getBlock( x - forward.offsetX, y - forward.offsetY, z - forward.offsetZ ).isAir( w, x - forward.offsetX, y - forward.offsetY, z - forward.offsetZ ) )
|
||||
pt = new BlockPos( x - forward.getFrontOffsetX(), y - forward.getFrontOffsetY(), z - forward.getFrontOffsetZ() );
|
||||
if( !w.getBlockState(pt).getBlock().isAir( w, pt) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -123,35 +127,25 @@ public class BlockQuartzGrowthAccelerator extends AEBaseTileBlock implements IOr
|
||||
case 3:
|
||||
dx = -0.6;
|
||||
dz = d1;
|
||||
if( !w.getBlock( x - west.offsetX, y - west.offsetY, z - west.offsetZ ).isAir( w, x - west.offsetX, y - west.offsetY, z - west.offsetZ ) )
|
||||
pt = new BlockPos( x - west.getFrontOffsetX(), y - west.getFrontOffsetY(), z - west.getFrontOffsetZ() );
|
||||
if( !w.getBlockState(pt).getBlock().isAir( w, pt) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
rx += dx * west.offsetX;
|
||||
ry += dx * west.offsetY;
|
||||
rz += dx * west.offsetZ;
|
||||
rx += dx * west.getFrontOffsetX();
|
||||
ry += dx * west.getFrontOffsetY();
|
||||
rz += dx * west.getFrontOffsetZ();
|
||||
|
||||
rx += dz * forward.offsetX;
|
||||
ry += dz * forward.offsetY;
|
||||
rz += dz * forward.offsetZ;
|
||||
rx += dz * forward.getFrontOffsetX();
|
||||
ry += dz * forward.getFrontOffsetY();
|
||||
rz += dz * forward.getFrontOffsetZ();
|
||||
|
||||
LightningFX fx = new LightningFX( w, rx, ry, rz, 0.0D, 0.0D, 0.0D );
|
||||
Minecraft.getMinecraft().effectRenderer.addEffect( fx );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean usesMetadata()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IOrientable getOrientable( final IBlockAccess w, final int x, final int y, final int z )
|
||||
{
|
||||
return new MetaRotation( w, x, y, z );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,17 +25,19 @@ import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockTorch;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import appeng.api.util.IOrientable;
|
||||
import appeng.api.util.IOrientableBlock;
|
||||
import appeng.block.AEBaseBlock;
|
||||
@@ -61,6 +63,26 @@ public class BlockQuartzTorch extends AEBaseBlock implements IOrientableBlock, I
|
||||
this.isFullSize = false;
|
||||
this.isOpaque = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetaFromState(
|
||||
IBlockState state )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getStateFromMeta(
|
||||
int meta )
|
||||
{
|
||||
return getDefaultState();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IProperty[] getAEStates()
|
||||
{
|
||||
return new IProperty[]{ BlockTorch.FACING };
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<? extends BaseBlockRender> getRenderer()
|
||||
@@ -69,38 +91,43 @@ public class BlockQuartzTorch extends AEBaseBlock implements IOrientableBlock, I
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidOrientation( World w, int x, int y, int z, ForgeDirection forward, ForgeDirection up )
|
||||
public boolean isValidOrientation( World w, BlockPos pos, EnumFacing forward, EnumFacing up )
|
||||
{
|
||||
return this.canPlaceAt( w, x, y, z, up.getOpposite() );
|
||||
return this.canPlaceAt( w, pos, up.getOpposite() );
|
||||
}
|
||||
|
||||
private boolean canPlaceAt( World w, int x, int y, int z, ForgeDirection dir )
|
||||
private boolean canPlaceAt( World w, BlockPos pos, EnumFacing dir )
|
||||
{
|
||||
return w.isSideSolid( x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ, dir.getOpposite(), false );
|
||||
BlockPos test = pos.offset( dir );
|
||||
return w.isSideSolid( test, dir.getOpposite(), false );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool( World w, int x, int y, int z, Entity e, boolean isVisual )
|
||||
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool( World w, BlockPos pos, Entity e, boolean isVisual )
|
||||
{
|
||||
ForgeDirection up = this.getOrientable( w, x, y, z ).getUp();
|
||||
double xOff = -0.3 * up.offsetX;
|
||||
double yOff = -0.3 * up.offsetY;
|
||||
double zOff = -0.3 * up.offsetZ;
|
||||
return Collections.singletonList( AxisAlignedBB.getBoundingBox( xOff + 0.3, yOff + 0.3, zOff + 0.3, xOff + 0.7, yOff + 0.7, zOff + 0.7 ) );
|
||||
EnumFacing up = this.getOrientable( w, pos ).getUp();
|
||||
double xOff = -0.3 * up.getFrontOffsetX();
|
||||
double yOff = -0.3 * up.getFrontOffsetY();
|
||||
double zOff = -0.3 * up.getFrontOffsetZ();
|
||||
return Collections.singletonList( AxisAlignedBB.fromBounds( xOff + 0.3, yOff + 0.3, zOff + 0.3, xOff + 0.7, yOff + 0.7, zOff + 0.7 ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCollidingBlockToList( World w, int x, int y, int z, AxisAlignedBB bb, List out, Entity e )
|
||||
public void addCollidingBlockToList( World w, BlockPos pos, AxisAlignedBB bb, List out, Entity e )
|
||||
{/*
|
||||
* double xOff = -0.15 * getUp().offsetX; double yOff = -0.15 * getUp().offsetY; double zOff = -0.15 *
|
||||
* getUp().offsetZ; out.add( AxisAlignedBB.getBoundingBox( xOff + (double) x + 0.15, yOff + (double) y + 0.15, zOff
|
||||
* + (double) z + 0.15,// ahh xOff + (double) x + 0.85, yOff + (double) y + 0.85, zOff + (double) z + 0.85 ) );
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void randomDisplayTick( World w, int x, int y, int z, Random r )
|
||||
public void randomDisplayTick(
|
||||
World w,
|
||||
BlockPos pos,
|
||||
IBlockState state,
|
||||
Random r )
|
||||
{
|
||||
if( !AEConfig.instance.enableEffects )
|
||||
{
|
||||
@@ -112,15 +139,15 @@ public class BlockQuartzTorch extends AEBaseBlock implements IOrientableBlock, I
|
||||
return;
|
||||
}
|
||||
|
||||
ForgeDirection up = this.getOrientable( w, x, y, z ).getUp();
|
||||
double xOff = -0.3 * up.offsetX;
|
||||
double yOff = -0.3 * up.offsetY;
|
||||
double zOff = -0.3 * up.offsetZ;
|
||||
EnumFacing up = this.getOrientable( w, pos ).getUp();
|
||||
double xOff = -0.3 * up.getFrontOffsetX();
|
||||
double yOff = -0.3 * up.getFrontOffsetY();
|
||||
double zOff = -0.3 * up.getFrontOffsetZ();
|
||||
for( int bolts = 0; bolts < 3; bolts++ )
|
||||
{
|
||||
if( CommonHelper.proxy.shouldAddParticles( r ) )
|
||||
{
|
||||
LightningFX fx = new LightningFX( w, xOff + 0.5 + x, yOff + 0.5 + y, zOff + 0.5 + z, 0.0D, 0.0D, 0.0D );
|
||||
LightningFX fx = new LightningFX( w, xOff + 0.5 + pos.getX(), yOff + 0.5 + pos.getY(), zOff + 0.5 + pos.getZ(), 0.0D, 0.0D, 0.0D );
|
||||
|
||||
Minecraft.getMinecraft().effectRenderer.addEffect( fx );
|
||||
}
|
||||
@@ -128,28 +155,31 @@ public class BlockQuartzTorch extends AEBaseBlock implements IOrientableBlock, I
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange( World w, int x, int y, int z, Block id )
|
||||
public void onNeighborBlockChange(
|
||||
World w,
|
||||
BlockPos pos,
|
||||
IBlockState state,
|
||||
Block neighborBlock )
|
||||
{
|
||||
ForgeDirection up = this.getOrientable( w, x, y, z ).getUp();
|
||||
if( !this.canPlaceAt( w, x, y, z, up.getOpposite() ) )
|
||||
EnumFacing up = this.getOrientable( w, pos ).getUp();
|
||||
if( !this.canPlaceAt( w, pos, up.getOpposite() ) )
|
||||
{
|
||||
this.dropTorch( w, x, y, z );
|
||||
this.dropTorch( w, pos );
|
||||
}
|
||||
}
|
||||
|
||||
private void dropTorch( World w, int x, int y, int z )
|
||||
private void dropTorch( World w, BlockPos pos )
|
||||
{
|
||||
w.func_147480_a( x, y, z, true );
|
||||
// w.destroyBlock( x, y, z, true );
|
||||
w.markBlockForUpdate( x, y, z );
|
||||
w.destroyBlock( pos, true );
|
||||
w.markBlockForUpdate( pos );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlaceBlockAt( World w, int x, int y, int z )
|
||||
public boolean canPlaceBlockAt( World w, BlockPos pos )
|
||||
{
|
||||
for( ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS )
|
||||
for( EnumFacing dir : EnumFacing.VALUES )
|
||||
{
|
||||
if( this.canPlaceAt( w, x, y, z, dir ) )
|
||||
if( this.canPlaceAt( w, pos, dir ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -164,8 +194,8 @@ public class BlockQuartzTorch extends AEBaseBlock implements IOrientableBlock, I
|
||||
}
|
||||
|
||||
@Override
|
||||
public IOrientable getOrientable( final IBlockAccess w, final int x, final int y, final int z )
|
||||
public IOrientable getOrientable( final IBlockAccess w, BlockPos pos )
|
||||
{
|
||||
return new MetaRotation( w, x, y, z );
|
||||
return new MetaRotation( w, pos,true );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,9 +23,11 @@ import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumWorldBlockLayer;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
import appeng.client.render.blocks.RendererSecurity;
|
||||
@@ -46,21 +48,34 @@ public class BlockSecurity extends AEBaseTileBlock
|
||||
this.setFeature( EnumSet.of( AEFeature.Security ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumWorldBlockLayer getBlockLayer()
|
||||
{
|
||||
return EnumWorldBlockLayer.CUTOUT;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<? extends BaseBlockRender> getRenderer()
|
||||
{
|
||||
return RendererSecurity.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onActivated( World w, int x, int y, int z, EntityPlayer p, int side, float hitX, float hitY, float hitZ )
|
||||
public boolean onActivated(
|
||||
World w,
|
||||
BlockPos pos,
|
||||
EntityPlayer p,
|
||||
EnumFacing side,
|
||||
float hitX,
|
||||
float hitY,
|
||||
float hitZ )
|
||||
{
|
||||
if( p.isSneaking() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
TileSecurity tg = this.getTileEntity( w, x, y, z );
|
||||
TileSecurity tg = this.getTileEntity( w, pos );
|
||||
if( tg != null )
|
||||
{
|
||||
if( Platform.isClient() )
|
||||
@@ -68,7 +83,7 @@ public class BlockSecurity extends AEBaseTileBlock
|
||||
return true;
|
||||
}
|
||||
|
||||
Platform.openGUI( p, tg, ForgeDirection.getOrientation( side ), GuiBridge.GUI_SECURITY );
|
||||
Platform.openGUI( p, tg, AEPartLocation.fromFacing( side ), GuiBridge.GUI_SECURITY );
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -25,17 +25,12 @@ import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
import appeng.client.render.blocks.RenderBlockSkyCompass;
|
||||
@@ -63,58 +58,50 @@ public class BlockSkyCompass extends AEBaseTileBlock implements ICustomCollision
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public IIcon getIcon( int direction, int metadata )
|
||||
public boolean isValidOrientation( World w, BlockPos pos, EnumFacing forward, EnumFacing up )
|
||||
{
|
||||
return Blocks.iron_block.getIcon( direction, metadata );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons( IIconRegister iconRegistry )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidOrientation( World w, int x, int y, int z, ForgeDirection forward, ForgeDirection up )
|
||||
{
|
||||
TileSkyCompass sc = this.getTileEntity( w, x, y, z );
|
||||
TileSkyCompass sc = this.getTileEntity( w, pos );
|
||||
if( sc != null )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return this.canPlaceAt( w, x, y, z, forward.getOpposite() );
|
||||
return this.canPlaceAt( w, pos, forward.getOpposite() );
|
||||
}
|
||||
|
||||
private boolean canPlaceAt( World w, int x, int y, int z, ForgeDirection dir )
|
||||
private boolean canPlaceAt( World w, BlockPos pos, EnumFacing dir )
|
||||
{
|
||||
return w.isSideSolid( x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ, dir.getOpposite(), false );
|
||||
return w.isSideSolid( pos.offset( dir ), dir.getOpposite(), false );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange( World w, int x, int y, int z, Block id )
|
||||
public void onNeighborBlockChange(
|
||||
World w,
|
||||
BlockPos pos,
|
||||
IBlockState state,
|
||||
Block neighborBlock )
|
||||
{
|
||||
TileSkyCompass sc = this.getTileEntity( w, x, y, z );
|
||||
ForgeDirection up = sc.getForward();
|
||||
if( !this.canPlaceAt( w, x, y, z, up.getOpposite() ) )
|
||||
TileSkyCompass sc = this.getTileEntity( w, pos );
|
||||
EnumFacing up = sc.getForward();
|
||||
if( !this.canPlaceAt( w, pos, up.getOpposite() ) )
|
||||
{
|
||||
this.dropTorch( w, x, y, z );
|
||||
this.dropTorch( w, pos );
|
||||
}
|
||||
}
|
||||
|
||||
private void dropTorch( World w, int x, int y, int z )
|
||||
private void dropTorch( World w, BlockPos pos )
|
||||
{
|
||||
w.func_147480_a( x, y, z, true );
|
||||
// w.destroyBlock( x, y, z, true );
|
||||
w.markBlockForUpdate( x, y, z );
|
||||
w.destroyBlock( pos, true );
|
||||
w.markBlockForUpdate( pos );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlaceBlockAt( World w, int x, int y, int z )
|
||||
public boolean canPlaceBlockAt(
|
||||
World w,
|
||||
BlockPos pos )
|
||||
{
|
||||
for( ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS )
|
||||
for( EnumFacing dir : EnumFacing.VALUES )
|
||||
{
|
||||
if( this.canPlaceAt( w, x, y, z, dir ) )
|
||||
if( this.canPlaceAt( w, pos, dir ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -123,12 +110,16 @@ public class BlockSkyCompass extends AEBaseTileBlock implements ICustomCollision
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool( World w, int x, int y, int z, Entity e, boolean isVisual )
|
||||
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool(
|
||||
World w,
|
||||
BlockPos pos,
|
||||
Entity thePlayer,
|
||||
boolean b )
|
||||
{
|
||||
TileSkyCompass tile = this.getTileEntity( w, x, y, z );
|
||||
TileSkyCompass tile = this.getTileEntity( w, pos );
|
||||
if( tile != null )
|
||||
{
|
||||
ForgeDirection forward = tile.getForward();
|
||||
EnumFacing forward = tile.getForward();
|
||||
|
||||
double minX = 0;
|
||||
double minY = 0;
|
||||
@@ -179,14 +170,19 @@ public class BlockSkyCompass extends AEBaseTileBlock implements ICustomCollision
|
||||
break;
|
||||
}
|
||||
|
||||
return Collections.singletonList( AxisAlignedBB.getBoundingBox( minX, minY, minZ, maxX, maxY, maxZ ) );
|
||||
return Collections.singletonList( AxisAlignedBB.fromBounds( minX, minY, minZ, maxX, maxY, maxZ ) );
|
||||
}
|
||||
return Collections.singletonList( AxisAlignedBB.getBoundingBox( 0.0, 0, 0.0, 1.0, 1.0, 1.0 ) );
|
||||
return Collections.singletonList( AxisAlignedBB.fromBounds( 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 )
|
||||
public void addCollidingBlockToList(
|
||||
World w,
|
||||
BlockPos pos,
|
||||
AxisAlignedBB bb,
|
||||
List<AxisAlignedBB> out,
|
||||
Entity e )
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,25 +26,22 @@ import java.util.List;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockDispenser;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.projectile.EntityArrow;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.Explosion;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import cpw.mods.fml.common.registry.EntityRegistry;
|
||||
|
||||
import net.minecraftforge.fml.common.registry.EntityRegistry;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
import appeng.client.render.blocks.RenderTinyTNT;
|
||||
import appeng.client.texture.FullIcon;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.entity.EntityIds;
|
||||
@@ -72,7 +69,7 @@ public class BlockTinyTNT extends AEBaseBlock implements ICustomCollision
|
||||
@Override
|
||||
protected Class<? extends BaseBlockRender> getRenderer()
|
||||
{
|
||||
return RenderTinyTNT.class;
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -83,78 +80,86 @@ public class BlockTinyTNT extends AEBaseBlock implements ICustomCollision
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon( int direction, int metadata )
|
||||
{
|
||||
return new FullIcon( Blocks.tnt.getIcon( direction, metadata ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActivated( World w, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ )
|
||||
public boolean onActivated(
|
||||
World w,
|
||||
BlockPos pos,
|
||||
EntityPlayer player,
|
||||
EnumFacing side,
|
||||
float hitX,
|
||||
float hitY,
|
||||
float hitZ )
|
||||
{
|
||||
if( player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() == Items.flint_and_steel )
|
||||
{
|
||||
this.startFuse( w, x, y, z, player );
|
||||
w.setBlockToAir( x, y, z );
|
||||
this.startFuse( w, pos, player );
|
||||
w.setBlockToAir( pos );
|
||||
player.getCurrentEquippedItem().damageItem( 1, player );
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return super.onActivated( w, x, y, z, player, side, hitX, hitY, hitZ );
|
||||
return super.onActivated( w, pos, player, side, hitX, hitY, hitZ );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons( IIconRegister iconRegistry )
|
||||
{
|
||||
// no images required.
|
||||
}
|
||||
|
||||
public void startFuse( World w, int x, int y, int z, EntityLivingBase igniter )
|
||||
public void startFuse( World w, BlockPos pos, EntityLivingBase igniter )
|
||||
{
|
||||
if( !w.isRemote )
|
||||
{
|
||||
EntityTinyTNTPrimed primedTinyTNTEntity = new EntityTinyTNTPrimed( w, x + 0.5F, y + 0.5F, z + 0.5F, igniter );
|
||||
EntityTinyTNTPrimed primedTinyTNTEntity = new EntityTinyTNTPrimed( w, pos.getX() + 0.5F, pos.getY() + 0.5F, pos.getZ() + 0.5F, igniter );
|
||||
w.spawnEntityInWorld( primedTinyTNTEntity );
|
||||
w.playSoundAtEntity( primedTinyTNTEntity, "game.tnt.primed", 1.0F, 1.0F );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onBlockAdded( World w, int x, int y, int z )
|
||||
public void onBlockAdded(
|
||||
World w,
|
||||
BlockPos pos,
|
||||
IBlockState state )
|
||||
{
|
||||
super.onBlockAdded( w, x, y, z );
|
||||
super.onBlockAdded( w, pos, state );
|
||||
|
||||
if( w.isBlockIndirectlyGettingPowered( x, y, z ) )
|
||||
if( w.isBlockIndirectlyGettingPowered( pos ) > 0 )
|
||||
{
|
||||
this.startFuse( w, x, y, z, null );
|
||||
w.setBlockToAir( x, y, z );
|
||||
this.startFuse( w, pos, null );
|
||||
w.setBlockToAir( pos );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange( World w, int x, int y, int z, Block id )
|
||||
public void onNeighborBlockChange(
|
||||
World w,
|
||||
BlockPos pos,
|
||||
IBlockState state,
|
||||
Block neighborBlock )
|
||||
{
|
||||
if( w.isBlockIndirectlyGettingPowered( x, y, z ) )
|
||||
if( w.isBlockIndirectlyGettingPowered( pos ) > 0 )
|
||||
{
|
||||
this.startFuse( w, x, y, z, null );
|
||||
w.setBlockToAir( x, y, z );
|
||||
this.startFuse( w, pos, null );
|
||||
w.setBlockToAir( pos );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockDestroyedByExplosion( World w, int x, int y, int z, Explosion exp )
|
||||
public void onBlockExploded(
|
||||
World w,
|
||||
BlockPos pos,
|
||||
Explosion exp )
|
||||
{
|
||||
if( !w.isRemote )
|
||||
{
|
||||
EntityTinyTNTPrimed primedTinyTNTEntity = new EntityTinyTNTPrimed( w, x + 0.5F, y + 0.5F, z + 0.5F, exp.getExplosivePlacedBy() );
|
||||
EntityTinyTNTPrimed primedTinyTNTEntity = new EntityTinyTNTPrimed( w, pos.getX() + 0.5F, pos.getY() + 0.5F, pos.getZ() + 0.5F, exp.getExplosivePlacedBy() );
|
||||
primedTinyTNTEntity.fuse = w.rand.nextInt( primedTinyTNTEntity.fuse / 4 ) + primedTinyTNTEntity.fuse / 8;
|
||||
w.spawnEntityInWorld( primedTinyTNTEntity );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCollidedWithBlock( World w, int x, int y, int z, Entity entity )
|
||||
public void onEntityCollidedWithBlock(
|
||||
World w,
|
||||
BlockPos pos,
|
||||
Entity entity )
|
||||
{
|
||||
if( entity instanceof EntityArrow && !w.isRemote )
|
||||
{
|
||||
@@ -162,8 +167,8 @@ public class BlockTinyTNT extends AEBaseBlock implements ICustomCollision
|
||||
|
||||
if( entityarrow.isBurning() )
|
||||
{
|
||||
this.startFuse( w, x, y, z, entityarrow.shootingEntity instanceof EntityLivingBase ? (EntityLivingBase) entityarrow.shootingEntity : null );
|
||||
w.setBlockToAir( x, y, z );
|
||||
this.startFuse( w, pos, entityarrow.shootingEntity instanceof EntityLivingBase ? (EntityLivingBase) entityarrow.shootingEntity : null );
|
||||
w.setBlockToAir( pos );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -175,14 +180,23 @@ public class BlockTinyTNT extends AEBaseBlock implements ICustomCollision
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool( World w, int x, int y, int z, Entity e, boolean isVisual )
|
||||
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool(
|
||||
World w,
|
||||
BlockPos pos,
|
||||
Entity thePlayer,
|
||||
boolean b )
|
||||
{
|
||||
return Collections.singletonList( AxisAlignedBB.getBoundingBox( 0.25, 0, 0.25, 0.75, 0.5, 0.75 ) );
|
||||
return Collections.singletonList( AxisAlignedBB.fromBounds( 0.25, 0, 0.25, 0.75, 0.5, 0.75 ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCollidingBlockToList( World w, int x, int y, int z, AxisAlignedBB bb, List<AxisAlignedBB> out, Entity e )
|
||||
public void addCollidingBlockToList(
|
||||
World w,
|
||||
BlockPos pos,
|
||||
AxisAlignedBB bb,
|
||||
List<AxisAlignedBB> out,
|
||||
Entity e )
|
||||
{
|
||||
out.add( AxisAlignedBB.getBoundingBox( 0.25, 0, 0.25, 0.75, 0.5, 0.75 ) );
|
||||
out.add( AxisAlignedBB.fromBounds( 0.25, 0, 0.25, 0.75, 0.5, 0.75 ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,14 +23,17 @@ import java.util.EnumSet;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumParticleTypes;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.client.texture.ExtraBlockTextures;
|
||||
import appeng.client.texture.IAESprite;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
@@ -49,14 +52,14 @@ public final class BlockVibrationChamber extends AEBaseTileBlock
|
||||
this.setHardness( 4.2F );
|
||||
this.setFeature( EnumSet.of( AEFeature.PowerGen ) );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IIcon getIcon( IBlockAccess w, int x, int y, int z, int s )
|
||||
public appeng.client.texture.IAESprite getIcon(IBlockAccess w, BlockPos pos, EnumFacing side)
|
||||
{
|
||||
IIcon ico = super.getIcon( w, x, y, z, s );
|
||||
TileVibrationChamber tvc = this.getTileEntity( w, x, y, z );
|
||||
IAESprite ico = super.getIcon( w, pos, side );
|
||||
TileVibrationChamber tvc = this.getTileEntity( w, pos );
|
||||
|
||||
if( tvc != null && tvc.isOn && ico == this.getRendererInstance().getTexture( ForgeDirection.SOUTH ) )
|
||||
if( tvc != null && tvc.isOn && ico == this.getRendererInstance().getTexture( AEPartLocation.SOUTH ) )
|
||||
{
|
||||
return ExtraBlockTextures.BlockVibrationChamberFrontOn.getIcon();
|
||||
}
|
||||
@@ -65,7 +68,14 @@ public final class BlockVibrationChamber extends AEBaseTileBlock
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActivated( World w, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ )
|
||||
public boolean onActivated(
|
||||
World w,
|
||||
BlockPos pos,
|
||||
EntityPlayer player,
|
||||
EnumFacing side,
|
||||
float hitX,
|
||||
float hitY,
|
||||
float hitZ )
|
||||
{
|
||||
if( player.isSneaking() )
|
||||
{
|
||||
@@ -74,10 +84,10 @@ public final class BlockVibrationChamber extends AEBaseTileBlock
|
||||
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
TileVibrationChamber tc = this.getTileEntity( w, x, y, z );
|
||||
TileVibrationChamber tc = this.getTileEntity( w, pos );
|
||||
if( tc != null && !player.isSneaking() )
|
||||
{
|
||||
Platform.openGUI( player, tc, ForgeDirection.getOrientation( side ), GuiBridge.GUI_VIBRATION_CHAMBER );
|
||||
Platform.openGUI( player, tc, AEPartLocation.fromFacing( side ), GuiBridge.GUI_VIBRATION_CHAMBER );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -86,47 +96,51 @@ public final class BlockVibrationChamber extends AEBaseTileBlock
|
||||
}
|
||||
|
||||
@Override
|
||||
public void randomDisplayTick( World w, int x, int y, int z, Random r )
|
||||
public void randomDisplayTick(
|
||||
World w,
|
||||
BlockPos pos,
|
||||
IBlockState state,
|
||||
Random r )
|
||||
{
|
||||
if( !AEConfig.instance.enableEffects )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
AEBaseTile tile = this.getTileEntity( w, x, y, z );
|
||||
AEBaseTile tile = this.getTileEntity( w, pos );
|
||||
if( tile instanceof TileVibrationChamber )
|
||||
{
|
||||
TileVibrationChamber tc = (TileVibrationChamber) tile;
|
||||
if( tc.isOn )
|
||||
{
|
||||
float f1 = x + 0.5F;
|
||||
float f2 = y + 0.5F;
|
||||
float f3 = z + 0.5F;
|
||||
float f1 = pos.getX() + 0.5F;
|
||||
float f2 = pos.getY() + 0.5F;
|
||||
float f3 = pos.getZ() + 0.5F;
|
||||
|
||||
ForgeDirection forward = tc.getForward();
|
||||
ForgeDirection up = tc.getUp();
|
||||
EnumFacing forward = tc.getForward();
|
||||
EnumFacing up = tc.getUp();
|
||||
|
||||
int west_x = forward.offsetY * up.offsetZ - forward.offsetZ * up.offsetY;
|
||||
int west_y = forward.offsetZ * up.offsetX - forward.offsetX * up.offsetZ;
|
||||
int west_z = forward.offsetX * up.offsetY - forward.offsetY * up.offsetX;
|
||||
int west_x = forward.getFrontOffsetY() * up.getFrontOffsetZ() - forward.getFrontOffsetZ() * up.getFrontOffsetY();
|
||||
int west_y = forward.getFrontOffsetZ() * up.getFrontOffsetX() - forward.getFrontOffsetX() * up.getFrontOffsetZ();
|
||||
int west_z = forward.getFrontOffsetX() * up.getFrontOffsetY() - forward.getFrontOffsetY() * up.getFrontOffsetX();
|
||||
|
||||
f1 += forward.offsetX * 0.6;
|
||||
f2 += forward.offsetY * 0.6;
|
||||
f3 += forward.offsetZ * 0.6;
|
||||
f1 += forward.getFrontOffsetX() * 0.6;
|
||||
f2 += forward.getFrontOffsetY() * 0.6;
|
||||
f3 += forward.getFrontOffsetZ() * 0.6;
|
||||
|
||||
float ox = r.nextFloat();
|
||||
float oy = r.nextFloat() * 0.2f;
|
||||
|
||||
f1 += up.offsetX * ( -0.3 + oy );
|
||||
f2 += up.offsetY * ( -0.3 + oy );
|
||||
f3 += up.offsetZ * ( -0.3 + oy );
|
||||
f1 += up.getFrontOffsetX() * ( -0.3 + oy );
|
||||
f2 += up.getFrontOffsetY() * ( -0.3 + oy );
|
||||
f3 += up.getFrontOffsetZ() * ( -0.3 + oy );
|
||||
|
||||
f1 += west_x * ( 0.3 * ox - 0.15 );
|
||||
f2 += west_y * ( 0.3 * ox - 0.15 );
|
||||
f3 += west_z * ( 0.3 * ox - 0.15 );
|
||||
|
||||
w.spawnParticle( "smoke", f1, f2, f3, 0.0D, 0.0D, 0.0D );
|
||||
w.spawnParticle( "flame", f1, f2, f3, 0.0D, 0.0D, 0.0D );
|
||||
w.spawnParticle( EnumParticleTypes.SMOKE_NORMAL, f1, f2, f3, 0.0D, 0.0D, 0.0D, new int[0] );
|
||||
w.spawnParticle( EnumParticleTypes.FLAME, f1, f2, f3, 0.0D, 0.0D, 0.0D, new int[0] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,40 +24,33 @@ import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.particle.EffectRenderer;
|
||||
import net.minecraft.client.particle.EntityDiggingFX;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.EnumDyeColor;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumWorldBlockLayer;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import powercrystals.minefactoryreloaded.api.rednet.connectivity.IRedNetConnection;
|
||||
import powercrystals.minefactoryreloaded.api.rednet.connectivity.RedNetConnectionType;
|
||||
|
||||
import appeng.api.parts.IPart;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import appeng.api.parts.IPartHost;
|
||||
import appeng.api.parts.PartItemStack;
|
||||
import appeng.api.parts.SelectedPart;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
import appeng.client.render.BusRenderHelper;
|
||||
import appeng.client.render.blocks.RendererCableBus;
|
||||
import appeng.client.texture.ExtraBlockTextures;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.Api;
|
||||
import appeng.core.CommonHelper;
|
||||
@@ -72,13 +65,11 @@ import appeng.parts.NullCableBusContainer;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.tile.networking.TileCableBus;
|
||||
import appeng.tile.networking.TileCableBusTESR;
|
||||
import appeng.transformer.annotations.Integration.Interface;
|
||||
import appeng.transformer.annotations.Integration.Method;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
@Interface( iface = "powercrystals.minefactoryreloaded.api.rednet.connectivity.IRedNetConnection", iname = "MFR" )
|
||||
public class BlockCableBus extends AEBaseTileBlock implements IRedNetConnection
|
||||
// TODO: MFR INTEGRATION
|
||||
//@Interface( iface = "powercrystals.minefactoryreloaded.api.rednet.connectivity.IRedNetConnection", iname = "MFR" )
|
||||
public class BlockCableBus extends AEBaseTileBlock // implements IRedNetConnection
|
||||
{
|
||||
|
||||
private static final ICableBusContainer NULL_CABLE_BUS = new NullCableBusContainer();
|
||||
@@ -88,7 +79,6 @@ public class BlockCableBus extends AEBaseTileBlock implements IRedNetConnection
|
||||
* Immibis MB Support.
|
||||
*/
|
||||
boolean ImmibisMicroblocks_TransformableBlockMarker = true;
|
||||
int myColorMultiplier = 0xffffff;
|
||||
|
||||
public BlockCableBus()
|
||||
{
|
||||
@@ -102,43 +92,41 @@ public class BlockCableBus extends AEBaseTileBlock implements IRedNetConnection
|
||||
}
|
||||
|
||||
@Override
|
||||
public void randomDisplayTick( World world, int x, int y, int z, Random r )
|
||||
public void randomDisplayTick(
|
||||
World worldIn,
|
||||
BlockPos pos,
|
||||
IBlockState state,
|
||||
Random rand )
|
||||
{
|
||||
this.cb( world, x, y, z ).randomDisplayTick( world, x, y, z, r );
|
||||
this.cb( worldIn, pos ).randomDisplayTick( worldIn, pos, rand );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange( World w, int x, int y, int z, Block meh )
|
||||
public void onNeighborChange(
|
||||
IBlockAccess w,
|
||||
BlockPos pos,
|
||||
BlockPos neighbor )
|
||||
{
|
||||
this.cb( w, x, y, z ).onNeighborChanged();
|
||||
this.cb( w, pos ).onNeighborChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getItemDropped( int i, Random r, int k )
|
||||
public Item getItemDropped(
|
||||
IBlockState state,
|
||||
Random rand,
|
||||
int fortune )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderBlockPass()
|
||||
public int isProvidingWeakPower(
|
||||
IBlockAccess w,
|
||||
BlockPos pos,
|
||||
IBlockState state,
|
||||
EnumFacing side )
|
||||
{
|
||||
if( AEConfig.instance.isFeatureEnabled( AEFeature.AlphaPass ) )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int colorMultiplier( IBlockAccess world, int x, int y, int z )
|
||||
{
|
||||
return this.myColorMultiplier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int isProvidingWeakPower( IBlockAccess w, int x, int y, int z, int side )
|
||||
{
|
||||
return this.cb( w, x, y, z ).isProvidingWeakPower( ForgeDirection.getOrientation( side ).getOpposite() );
|
||||
return this.cb( w, pos ).isProvidingWeakPower( side.getOpposite() ); // TODO: IS OPPOSITE!?
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -148,104 +136,113 @@ public class BlockCableBus extends AEBaseTileBlock implements IRedNetConnection
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCollidedWithBlock( World w, int x, int y, int z, Entity e )
|
||||
public void onEntityCollidedWithBlock(
|
||||
World w,
|
||||
BlockPos pos,
|
||||
IBlockState state,
|
||||
Entity entityIn )
|
||||
{
|
||||
this.cb( w, x, y, z ).onEntityCollision( e );
|
||||
this.cb( w, pos ).onEntityCollision( entityIn );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int isProvidingStrongPower( IBlockAccess w, int x, int y, int z, int side )
|
||||
public int isProvidingStrongPower(
|
||||
IBlockAccess w,
|
||||
BlockPos pos,
|
||||
IBlockState state,
|
||||
EnumFacing side )
|
||||
{
|
||||
return this.cb( w, x, y, z ).isProvidingStrongPower( ForgeDirection.getOrientation( side ).getOpposite() );
|
||||
return this.cb( w, pos ).isProvidingStrongPower( side.getOpposite() ); // TODO: IS OPPOSITE!?
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLightValue( IBlockAccess world, int x, int y, int z )
|
||||
public int getLightValue(
|
||||
IBlockAccess world,
|
||||
BlockPos pos )
|
||||
{
|
||||
Block block = world.getBlock( x, y, z );
|
||||
if( block != null && block != this )
|
||||
IBlockState block = world.getBlockState( pos );
|
||||
if( block != null && block.getBlock() != this )
|
||||
{
|
||||
return block.getLightValue( world, x, y, z );
|
||||
return block.getBlock().getLightValue( world, pos );
|
||||
}
|
||||
if( block == null )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return this.cb( world, x, y, z ).getLightValue();
|
||||
return this.cb( world, pos ).getLightValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLadder( IBlockAccess world, int x, int y, int z, EntityLivingBase entity )
|
||||
public boolean isLadder( IBlockAccess world, BlockPos pos, EntityLivingBase entity )
|
||||
{
|
||||
return this.cb( world, x, y, z ).isLadder( entity );
|
||||
return this.cb( world, pos ).isLadder( entity );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSideSolid( IBlockAccess w, int x, int y, int z, ForgeDirection side )
|
||||
public boolean isSideSolid( IBlockAccess w, BlockPos pos, EnumFacing side )
|
||||
{
|
||||
return this.cb( w, x, y, z ).isSolidOnSide( side );
|
||||
return this.cb( w, pos ).isSolidOnSide( side );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReplaceable( IBlockAccess world, int x, int y, int z )
|
||||
public boolean isReplaceable(
|
||||
World w,
|
||||
BlockPos pos )
|
||||
{
|
||||
return this.cb( world, x, y, z ).isEmpty();
|
||||
return this.cb( w, pos ).isEmpty();
|
||||
}
|
||||
|
||||
@SuppressWarnings( "deprecation" )
|
||||
@Override
|
||||
public boolean removedByPlayer( World world, EntityPlayer player, int x, int y, int z )
|
||||
public boolean removedByPlayer(
|
||||
World world,
|
||||
BlockPos pos,
|
||||
EntityPlayer player,
|
||||
boolean willHarvest )
|
||||
{
|
||||
if( player.capabilities.isCreativeMode )
|
||||
{
|
||||
AEBaseTile tile = this.getTileEntity( world, x, y, z );
|
||||
AEBaseTile tile = this.getTileEntity( world, pos );
|
||||
if( tile != null )
|
||||
{
|
||||
tile.disableDrops();
|
||||
}
|
||||
// maybe ray trace?
|
||||
}
|
||||
return super.removedByPlayer( world, player, x, y, z );
|
||||
return super.removedByPlayer( world, pos, player, willHarvest );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectRedstone( IBlockAccess w, int x, int y, int z, int side )
|
||||
public boolean canConnectRedstone(
|
||||
IBlockAccess w,
|
||||
BlockPos pos,
|
||||
EnumFacing side )
|
||||
{
|
||||
switch( side )
|
||||
{
|
||||
case -1:
|
||||
case 4:
|
||||
return this.cb( w, x, y, z ).canConnectRedstone( EnumSet.of( ForgeDirection.UP, ForgeDirection.DOWN ) );
|
||||
case 0:
|
||||
return this.cb( w, x, y, z ).canConnectRedstone( EnumSet.of( ForgeDirection.NORTH ) );
|
||||
case 1:
|
||||
return this.cb( w, x, y, z ).canConnectRedstone( EnumSet.of( ForgeDirection.EAST ) );
|
||||
case 2:
|
||||
return this.cb( w, x, y, z ).canConnectRedstone( EnumSet.of( ForgeDirection.SOUTH ) );
|
||||
case 3:
|
||||
return this.cb( w, x, y, z ).canConnectRedstone( EnumSet.of( ForgeDirection.WEST ) );
|
||||
}
|
||||
return false;
|
||||
if ( side == null )
|
||||
side = EnumFacing.UP;
|
||||
|
||||
return this.cb( w, pos ).canConnectRedstone( EnumSet.of( side ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canRenderInPass( int pass )
|
||||
public boolean canRenderInLayer(
|
||||
EnumWorldBlockLayer layer )
|
||||
{
|
||||
BusRenderHelper.INSTANCE.setPass( pass );
|
||||
|
||||
if( AEConfig.instance.isFeatureEnabled( AEFeature.AlphaPass ) )
|
||||
{
|
||||
return true;
|
||||
return layer == EnumWorldBlockLayer.CUTOUT || layer == EnumWorldBlockLayer.TRANSLUCENT;
|
||||
}
|
||||
|
||||
return pass == 0;
|
||||
return layer == EnumWorldBlockLayer.CUTOUT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getPickBlock( MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player )
|
||||
public ItemStack getPickBlock(
|
||||
MovingObjectPosition target,
|
||||
World world,
|
||||
BlockPos pos )
|
||||
{
|
||||
Vec3 v3 = target.hitVec.addVector( -x, -y, -z );
|
||||
SelectedPart sp = this.cb( world, x, y, z ).selectPart( v3 );
|
||||
Vec3 v3 = target.hitVec.subtract( pos.getX(), pos.getY(), pos.getZ() );
|
||||
SelectedPart sp = this.cb( world, pos ).selectPart( v3 );
|
||||
|
||||
if( sp.part != null )
|
||||
{
|
||||
@@ -263,15 +260,17 @@ public class BlockCableBus extends AEBaseTileBlock implements IRedNetConnection
|
||||
@SideOnly( Side.CLIENT )
|
||||
public boolean addHitEffects( World world, MovingObjectPosition target, EffectRenderer effectRenderer )
|
||||
{
|
||||
Object object = this.cb( world, target.blockX, target.blockY, target.blockZ );
|
||||
Object object = this.cb( world, target.getBlockPos() );
|
||||
if( object instanceof IPartHost )
|
||||
{
|
||||
IPartHost host = (IPartHost) object;
|
||||
|
||||
for( ForgeDirection side : ForgeDirection.values() )
|
||||
// TODO HIT EFFECTS
|
||||
/*
|
||||
for( AEPartLocation side : AEPartLocation.values() )
|
||||
{
|
||||
IPart p = host.getPart( side );
|
||||
IIcon ico = this.getIcon( p );
|
||||
TextureAtlasSprite ico = this.getIcon( p );
|
||||
|
||||
if( ico == null )
|
||||
{
|
||||
@@ -302,24 +301,29 @@ public class BlockCableBus extends AEBaseTileBlock implements IRedNetConnection
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public boolean addDestroyEffects( World world, int x, int y, int z, int meta, EffectRenderer effectRenderer )
|
||||
public boolean addDestroyEffects(
|
||||
World world,
|
||||
BlockPos pos,
|
||||
EffectRenderer effectRenderer )
|
||||
{
|
||||
Object object = this.cb( world, x, y, z );
|
||||
Object object = this.cb( world, pos );
|
||||
if( object instanceof IPartHost )
|
||||
{
|
||||
IPartHost host = (IPartHost) object;
|
||||
|
||||
for( ForgeDirection side : ForgeDirection.values() )
|
||||
// TODO DESTROY EFFECTS
|
||||
/*
|
||||
for( AEPartLocation side : AEPartLocation.values() )
|
||||
{
|
||||
IPart p = host.getPart( side );
|
||||
IIcon ico = this.getIcon( p );
|
||||
TextureAtlasSprite ico = this.getIcon( p );
|
||||
|
||||
if( ico == null )
|
||||
{
|
||||
@@ -346,52 +350,28 @@ public class BlockCableBus extends AEBaseTileBlock implements IRedNetConnection
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborChange( IBlockAccess w, int x, int y, int z, int tileX, int tileY, int tileZ )
|
||||
public void onNeighborBlockChange(
|
||||
World w,
|
||||
BlockPos pos,
|
||||
IBlockState state,
|
||||
Block neighborBlock )
|
||||
{
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
this.cb( w, x, y, z ).onNeighborChanged();
|
||||
this.cb( w, pos ).onNeighborChanged();
|
||||
}
|
||||
}
|
||||
|
||||
private IIcon getIcon( IPart p )
|
||||
private ICableBusContainer cb( IBlockAccess w, BlockPos pos )
|
||||
{
|
||||
if( p == null )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
IIcon ico = p.getBreakingTexture();
|
||||
if( ico != null )
|
||||
{
|
||||
return ico;
|
||||
}
|
||||
}
|
||||
catch( Throwable t )
|
||||
{
|
||||
// nothing.
|
||||
}
|
||||
|
||||
ItemStack is = p.getItemStack( PartItemStack.Network );
|
||||
if( is == null || is.getItem() == null )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return is.getItem().getIcon( is, 0 );
|
||||
}
|
||||
|
||||
private ICableBusContainer cb( IBlockAccess w, int x, int y, int z )
|
||||
{
|
||||
TileEntity te = w.getTileEntity( x, y, z );
|
||||
TileEntity te = w.getTileEntity( pos );
|
||||
ICableBusContainer out = null;
|
||||
|
||||
if( te instanceof TileCableBus )
|
||||
@@ -413,46 +393,38 @@ public class BlockCableBus extends AEBaseTileBlock implements IRedNetConnection
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon( IBlockAccess w, int x, int y, int z, int s )
|
||||
public boolean onActivated(
|
||||
World w,
|
||||
BlockPos pos,
|
||||
EntityPlayer player,
|
||||
EnumFacing side,
|
||||
float hitX,
|
||||
float hitY,
|
||||
float hitZ )
|
||||
{
|
||||
return this.getIcon( s, 0 );
|
||||
return this.cb( w, pos ).activate( player, new Vec3( hitX, hitY, hitZ ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon( int direction, int metadata )
|
||||
public boolean recolorBlock(
|
||||
World world,
|
||||
BlockPos pos,
|
||||
EnumFacing side,
|
||||
EnumDyeColor color )
|
||||
{
|
||||
IIcon i = super.getIcon( direction, metadata );
|
||||
if( i != null )
|
||||
{
|
||||
return i;
|
||||
}
|
||||
|
||||
return ExtraBlockTextures.BlockQuartzGlassB.getIcon();
|
||||
return this.recolorBlock( world, pos, side, color, null );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActivated( World w, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ )
|
||||
{
|
||||
return this.cb( w, x, y, z ).activate( player, Vec3.createVectorHelper( hitX, hitY, hitZ ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons( IIconRegister iconRegistry )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean recolourBlock( World world, int x, int y, int z, ForgeDirection side, int colour )
|
||||
{
|
||||
return this.recolourBlock( world, x, y, z, side, colour, null );
|
||||
}
|
||||
|
||||
public boolean recolourBlock( World world, int x, int y, int z, ForgeDirection side, int colour, EntityPlayer who )
|
||||
public boolean recolorBlock(
|
||||
World world,
|
||||
BlockPos pos,
|
||||
EnumFacing side,
|
||||
EnumDyeColor color,
|
||||
EntityPlayer who )
|
||||
{
|
||||
try
|
||||
{
|
||||
return this.cb( world, x, y, z ).recolourBlock( side, AEColor.values()[colour], who );
|
||||
return this.cb( world, pos ).recolourBlock( side, AEColor.values()[ color.ordinal() ], who );
|
||||
}
|
||||
catch( Throwable ignored )
|
||||
{}
|
||||
@@ -467,9 +439,9 @@ public class BlockCableBus extends AEBaseTileBlock implements IRedNetConnection
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends AEBaseTile> T getTileEntity( IBlockAccess w, int x, int y, int z )
|
||||
public <T extends AEBaseTile> T getTileEntity( IBlockAccess w, BlockPos pos )
|
||||
{
|
||||
TileEntity te = w.getTileEntity( x, y, z );
|
||||
TileEntity te = w.getTileEntity( pos );
|
||||
|
||||
if( noTesrTile.isInstance( te ) )
|
||||
{
|
||||
@@ -504,15 +476,13 @@ public class BlockCableBus extends AEBaseTileBlock implements IRedNetConnection
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Method( iname = "MFR" )
|
||||
public RedNetConnectionType getConnectionType( World world, int x, int y, int z, ForgeDirection side )
|
||||
{
|
||||
return this.cb( world, x, y, z ).canConnectRedstone( EnumSet.allOf( ForgeDirection.class ) ) ? RedNetConnectionType.CableSingle : RedNetConnectionType.None;
|
||||
}
|
||||
|
||||
public void setRenderColor( int color )
|
||||
{
|
||||
this.myColorMultiplier = color;
|
||||
}
|
||||
/*
|
||||
* // TODO MFR INTEGRATION
|
||||
@Override
|
||||
@Method( iname = "MFR" )
|
||||
public RedNetConnectionType getConnectionType( World world, int x, int y, int z, AEPartLocation side )
|
||||
{
|
||||
return this.cb( world, x, y, z ).canConnectRedstone( EnumSet.allOf( AEPartLocation.class ) ) ? RedNetConnectionType.CableSingle : RedNetConnectionType.None;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
@@ -23,8 +23,13 @@ import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.properties.PropertyEnum;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumWorldBlockLayer;
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
import appeng.client.render.blocks.RenderBlockController;
|
||||
@@ -35,6 +40,45 @@ import appeng.tile.networking.TileController;
|
||||
public class BlockController extends AEBaseTileBlock
|
||||
{
|
||||
|
||||
public static enum ControllerBlockState implements IStringSerializable
|
||||
{
|
||||
OFFLINE, ONLINE, CONFLICTED;
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return name();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
public static final PropertyEnum CONTROLLER_STATE = PropertyEnum.create("state",ControllerBlockState.class);
|
||||
|
||||
@Override
|
||||
protected IProperty[] getAEStates()
|
||||
{
|
||||
return new IProperty[]{ CONTROLLER_STATE };
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetaFromState(
|
||||
IBlockState state )
|
||||
{
|
||||
return ((ControllerBlockState)state.getValue( CONTROLLER_STATE )).ordinal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getStateFromMeta( int meta )
|
||||
{
|
||||
return getDefaultState().withProperty( CONTROLLER_STATE, ControllerBlockState.OFFLINE );
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumWorldBlockLayer getBlockLayer()
|
||||
{
|
||||
return EnumWorldBlockLayer.CUTOUT;
|
||||
}
|
||||
|
||||
public BlockController()
|
||||
{
|
||||
super( Material.iron );
|
||||
@@ -44,9 +88,13 @@ public class BlockController extends AEBaseTileBlock
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange( World w, int x, int y, int z, Block neighborBlock )
|
||||
public void onNeighborBlockChange(
|
||||
World w,
|
||||
BlockPos pos,
|
||||
IBlockState state,
|
||||
Block neighborBlock )
|
||||
{
|
||||
TileController tc = this.getTileEntity( w, x, y, z );
|
||||
TileController tc = this.getTileEntity( w, pos );
|
||||
if( tc != null )
|
||||
{
|
||||
tc.onNeighborChange( false );
|
||||
|
||||
@@ -21,8 +21,6 @@ package appeng.block.networking;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
import appeng.client.texture.ExtraBlockTextures;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.tile.networking.TileDenseEnergyCell;
|
||||
@@ -38,10 +36,11 @@ public class BlockDenseEnergyCell extends BlockEnergyCell
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon( int direction, int metadata )
|
||||
public appeng.client.texture.IAESprite getIcon(net.minecraft.util.EnumFacing side, net.minecraft.block.state.IBlockState state)
|
||||
{
|
||||
switch( metadata )
|
||||
switch( (int)state.getValue( ENERGY_STORAGE ) )
|
||||
{
|
||||
default:
|
||||
case 0:
|
||||
return ExtraBlockTextures.MEDenseEnergyCell0.getIcon();
|
||||
case 1:
|
||||
@@ -59,9 +58,8 @@ public class BlockDenseEnergyCell extends BlockEnergyCell
|
||||
case 7:
|
||||
return ExtraBlockTextures.MEDenseEnergyCell7.getIcon();
|
||||
}
|
||||
return super.getIcon( direction, metadata );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public double getMaxPower()
|
||||
{
|
||||
|
||||
@@ -22,7 +22,6 @@ package appeng.block.networking;
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.tile.networking.TileEnergyAcceptor;
|
||||
|
||||
@@ -22,15 +22,15 @@ package appeng.block.networking;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.properties.PropertyInteger;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import appeng.block.AEBaseItemBlock;
|
||||
import appeng.block.AEBaseItemBlockChargeable;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
@@ -46,6 +46,21 @@ import appeng.util.Platform;
|
||||
public class BlockEnergyCell extends AEBaseTileBlock
|
||||
{
|
||||
|
||||
public static final PropertyInteger ENERGY_STORAGE = PropertyInteger.create( "fullness", 0, 8 );
|
||||
|
||||
@Override
|
||||
public int getMetaFromState(
|
||||
IBlockState state )
|
||||
{
|
||||
return (int)state.getValue( ENERGY_STORAGE );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getStateFromMeta( int meta )
|
||||
{
|
||||
return getDefaultState().withProperty( ENERGY_STORAGE, Math.min( 7, Math.max( 0, meta ) ) );
|
||||
}
|
||||
|
||||
public BlockEnergyCell()
|
||||
{
|
||||
super( AEGlassMaterial.INSTANCE );
|
||||
@@ -61,10 +76,11 @@ public class BlockEnergyCell extends AEBaseTileBlock
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon( int direction, int metadata )
|
||||
public appeng.client.texture.IAESprite getIcon(net.minecraft.util.EnumFacing side, IBlockState state)
|
||||
{
|
||||
switch( metadata )
|
||||
switch( (int)state.getValue( ENERGY_STORAGE ) )
|
||||
{
|
||||
default:
|
||||
case 0:
|
||||
return ExtraBlockTextures.MEEnergyCell0.getIcon();
|
||||
case 1:
|
||||
@@ -82,7 +98,6 @@ public class BlockEnergyCell extends AEBaseTileBlock
|
||||
case 7:
|
||||
return ExtraBlockTextures.MEEnergyCell7.getIcon();
|
||||
}
|
||||
return super.getIcon( direction, metadata );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -104,6 +119,12 @@ public class BlockEnergyCell extends AEBaseTileBlock
|
||||
return 200000.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IProperty[] getAEStates()
|
||||
{
|
||||
return new IProperty[]{ENERGY_STORAGE};
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends AEBaseItemBlock> getItemBlockClass()
|
||||
{
|
||||
|
||||
@@ -23,12 +23,15 @@ import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumWorldBlockLayer;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
import appeng.client.render.blocks.RenderBlockWireless;
|
||||
@@ -60,19 +63,33 @@ public class BlockWireless extends AEBaseTileBlock implements ICustomCollision
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActivated( World w, int x, int y, int z, EntityPlayer p, int side, float hitX, float hitY, float hitZ )
|
||||
public EnumWorldBlockLayer getBlockLayer()
|
||||
{
|
||||
if( p.isSneaking() )
|
||||
return EnumWorldBlockLayer.CUTOUT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(
|
||||
World w,
|
||||
BlockPos pos,
|
||||
IBlockState state,
|
||||
EntityPlayer player,
|
||||
EnumFacing side,
|
||||
float hitX,
|
||||
float hitY,
|
||||
float hitZ )
|
||||
{
|
||||
if( player.isSneaking() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
TileWireless tg = this.getTileEntity( w, x, y, z );
|
||||
TileWireless tg = this.getTileEntity( w, pos );
|
||||
if( tg != null )
|
||||
{
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
Platform.openGUI( p, tg, ForgeDirection.getOrientation( side ), GuiBridge.GUI_WIRELESS );
|
||||
Platform.openGUI( player, tg, AEPartLocation.fromFacing( side ), GuiBridge.GUI_WIRELESS );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -80,12 +97,16 @@ public class BlockWireless extends AEBaseTileBlock implements ICustomCollision
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool( World w, int x, int y, int z, Entity e, boolean isVisual )
|
||||
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool(
|
||||
World w,
|
||||
BlockPos pos,
|
||||
Entity thePlayer,
|
||||
boolean b )
|
||||
{
|
||||
TileWireless tile = this.getTileEntity( w, x, y, z );
|
||||
TileWireless tile = this.getTileEntity( w, pos );
|
||||
if( tile != null )
|
||||
{
|
||||
ForgeDirection forward = tile.getForward();
|
||||
EnumFacing forward = tile.getForward();
|
||||
|
||||
double minX = 0;
|
||||
double minY = 0;
|
||||
@@ -136,18 +157,23 @@ public class BlockWireless extends AEBaseTileBlock implements ICustomCollision
|
||||
break;
|
||||
}
|
||||
|
||||
return Collections.singletonList( AxisAlignedBB.getBoundingBox( minX, minY, minZ, maxX, maxY, maxZ ) );
|
||||
return Collections.singletonList( AxisAlignedBB.fromBounds( minX, minY, minZ, maxX, maxY, maxZ ) );
|
||||
}
|
||||
return Collections.singletonList( AxisAlignedBB.getBoundingBox( 0.0, 0, 0.0, 1.0, 1.0, 1.0 ) );
|
||||
return Collections.singletonList( AxisAlignedBB.fromBounds( 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<AxisAlignedBB> out, Entity e )
|
||||
public void addCollidingBlockToList(
|
||||
World w,
|
||||
BlockPos pos,
|
||||
AxisAlignedBB bb,
|
||||
List<AxisAlignedBB> out,
|
||||
Entity e )
|
||||
{
|
||||
TileWireless tile = this.getTileEntity( w, x, y, z );
|
||||
TileWireless tile = this.getTileEntity( w, pos );
|
||||
if( tile != null )
|
||||
{
|
||||
ForgeDirection forward = tile.getForward();
|
||||
EnumFacing forward = tile.getForward();
|
||||
|
||||
double minX = 0;
|
||||
double minY = 0;
|
||||
@@ -198,11 +224,11 @@ public class BlockWireless extends AEBaseTileBlock implements ICustomCollision
|
||||
break;
|
||||
}
|
||||
|
||||
out.add( AxisAlignedBB.getBoundingBox( minX, minY, minZ, maxX, maxY, maxZ ) );
|
||||
out.add( AxisAlignedBB.fromBounds( minX, minY, minZ, maxX, maxY, maxZ ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
out.add( AxisAlignedBB.getBoundingBox( 0.0, 0.0, 0.0, 1.0, 1.0, 1.0 ) );
|
||||
out.add( AxisAlignedBB.fromBounds( 0.0, 0.0, 0.0, 1.0, 1.0, 1.0 ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,10 +23,11 @@ import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumWorldBlockLayer;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
import appeng.client.render.blocks.RenderQNB;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.helpers.ICustomCollision;
|
||||
@@ -48,9 +49,19 @@ public abstract class BlockQuantumBase extends AEBaseTileBlock implements ICusto
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange( World w, int x, int y, int z, Block pointlessNumber )
|
||||
public EnumWorldBlockLayer getBlockLayer()
|
||||
{
|
||||
TileQuantumBridge bridge = this.getTileEntity( w, x, y, z );
|
||||
return EnumWorldBlockLayer.CUTOUT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange(
|
||||
World w,
|
||||
BlockPos pos,
|
||||
IBlockState state,
|
||||
Block neighborBlock )
|
||||
{
|
||||
TileQuantumBridge bridge = this.getTileEntity( w, pos );
|
||||
if( bridge != null )
|
||||
{
|
||||
bridge.neighborUpdate();
|
||||
@@ -58,15 +69,18 @@ public abstract class BlockQuantumBase extends AEBaseTileBlock implements ICusto
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock( World w, int x, int y, int z, Block a, int b )
|
||||
public void breakBlock(
|
||||
World w,
|
||||
BlockPos pos,
|
||||
IBlockState state )
|
||||
{
|
||||
TileQuantumBridge bridge = this.getTileEntity( w, x, y, z );
|
||||
TileQuantumBridge bridge = this.getTileEntity( w, pos );
|
||||
if( bridge != null )
|
||||
{
|
||||
bridge.breakCluster();
|
||||
}
|
||||
|
||||
super.breakBlock( w, x, y, z, a, b );
|
||||
super.breakBlock( w, pos, state );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -23,15 +23,15 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumWorldBlockLayer;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.client.EffectType;
|
||||
import appeng.core.CommonHelper;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
@@ -47,38 +47,48 @@ public class BlockQuantumLinkChamber extends BlockQuantumBase
|
||||
{
|
||||
super( AEGlassMaterial.INSTANCE );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void randomDisplayTick( World w, int bx, int by, int bz, Random r )
|
||||
public void randomDisplayTick(
|
||||
World w,
|
||||
BlockPos pos,
|
||||
IBlockState state,
|
||||
Random rand )
|
||||
{
|
||||
TileQuantumBridge bridge = this.getTileEntity( w, bx, by, bz );
|
||||
TileQuantumBridge bridge = this.getTileEntity( w, pos );
|
||||
if( bridge != null )
|
||||
{
|
||||
if( bridge.hasQES() )
|
||||
{
|
||||
if( CommonHelper.proxy.shouldAddParticles( r ) )
|
||||
if( CommonHelper.proxy.shouldAddParticles( rand ) )
|
||||
{
|
||||
CommonHelper.proxy.spawnEffect( EffectType.Energy, w, bx + 0.5, by + 0.5, bz + 0.5, null );
|
||||
CommonHelper.proxy.spawnEffect( EffectType.Energy, w, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, null );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActivated( World w, int x, int y, int z, EntityPlayer p, int side, float hitX, float hitY, float hitZ )
|
||||
public boolean onActivated(
|
||||
World w,
|
||||
BlockPos pos,
|
||||
EntityPlayer p,
|
||||
EnumFacing side,
|
||||
float hitX,
|
||||
float hitY,
|
||||
float hitZ )
|
||||
{
|
||||
if( p.isSneaking() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
TileQuantumBridge tg = this.getTileEntity( w, x, y, z );
|
||||
TileQuantumBridge tg = this.getTileEntity( w, pos );
|
||||
if( tg != null )
|
||||
{
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
Platform.openGUI( p, tg, ForgeDirection.getOrientation( side ), GuiBridge.GUI_QNB );
|
||||
Platform.openGUI( p, tg, AEPartLocation.fromFacing( side ), GuiBridge.GUI_QNB );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -86,16 +96,25 @@ public class BlockQuantumLinkChamber extends BlockQuantumBase
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool( World w, int x, int y, int z, Entity e, boolean isVisual )
|
||||
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool(
|
||||
World w,
|
||||
BlockPos pos,
|
||||
Entity thePlayer,
|
||||
boolean b )
|
||||
{
|
||||
double onePixel = 2.0 / 16.0;
|
||||
return Collections.singletonList( AxisAlignedBB.getBoundingBox( onePixel, onePixel, onePixel, 1.0 - onePixel, 1.0 - onePixel, 1.0 - onePixel ) );
|
||||
return Collections.singletonList( AxisAlignedBB.fromBounds( onePixel, onePixel, onePixel, 1.0 - onePixel, 1.0 - onePixel, 1.0 - onePixel ) );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void addCollidingBlockToList( World w, int x, int y, int z, AxisAlignedBB bb, List<AxisAlignedBB> out, Entity e )
|
||||
public void addCollidingBlockToList(
|
||||
World w,
|
||||
BlockPos pos,
|
||||
AxisAlignedBB bb,
|
||||
List<AxisAlignedBB> out,
|
||||
Entity e )
|
||||
{
|
||||
double onePixel = 2.0 / 16.0;
|
||||
out.add( AxisAlignedBB.getBoundingBox( onePixel, onePixel, onePixel, 1.0 - onePixel, 1.0 - onePixel, 1.0 - onePixel ) );
|
||||
out.add( AxisAlignedBB.fromBounds( onePixel, onePixel, onePixel, 1.0 - onePixel, 1.0 - onePixel, 1.0 - onePixel ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,15 +20,13 @@ package appeng.block.qnb;
|
||||
|
||||
|
||||
import java.util.Collections;
|
||||
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.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.tile.qnb.TileQuantumBridge;
|
||||
|
||||
|
||||
@@ -41,10 +39,14 @@ public class BlockQuantumRing extends BlockQuantumBase
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool( World w, int x, int y, int z, Entity e, boolean isVisual )
|
||||
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool(
|
||||
World w,
|
||||
BlockPos pos,
|
||||
Entity thePlayer,
|
||||
boolean b )
|
||||
{
|
||||
double onePixel = 2.0 / 16.0;
|
||||
TileQuantumBridge bridge = this.getTileEntity( w, x, y, z );
|
||||
TileQuantumBridge bridge = this.getTileEntity( w, pos );
|
||||
if( bridge != null && bridge.isCorner() )
|
||||
{
|
||||
onePixel = 4.0 / 16.0;
|
||||
@@ -53,14 +55,19 @@ public class BlockQuantumRing extends BlockQuantumBase
|
||||
{
|
||||
onePixel = 1.0 / 16.0;
|
||||
}
|
||||
return Collections.singletonList( AxisAlignedBB.getBoundingBox( onePixel, onePixel, onePixel, 1.0 - onePixel, 1.0 - onePixel, 1.0 - onePixel ) );
|
||||
return Collections.singletonList( AxisAlignedBB.fromBounds( onePixel, onePixel, onePixel, 1.0 - onePixel, 1.0 - onePixel, 1.0 - onePixel ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCollidingBlockToList( World w, int x, int y, int z, AxisAlignedBB bb, List<AxisAlignedBB> out, Entity e )
|
||||
public void addCollidingBlockToList(
|
||||
World w,
|
||||
BlockPos pos,
|
||||
AxisAlignedBB bb,
|
||||
List<AxisAlignedBB> out,
|
||||
Entity e )
|
||||
{
|
||||
double onePixel = 2.0 / 16.0;
|
||||
TileQuantumBridge bridge = this.getTileEntity( w, x, y, z );
|
||||
TileQuantumBridge bridge = this.getTileEntity( w, pos );
|
||||
if( bridge != null && bridge.isCorner() )
|
||||
{
|
||||
onePixel = 4.0 / 16.0;
|
||||
@@ -69,6 +76,6 @@ public class BlockQuantumRing extends BlockQuantumBase
|
||||
{
|
||||
onePixel = 1.0 / 16.0;
|
||||
}
|
||||
out.add( AxisAlignedBB.getBoundingBox( onePixel, onePixel, onePixel, 1.0 - onePixel, 1.0 - onePixel, 1.0 - onePixel ) );
|
||||
out.add( AxisAlignedBB.fromBounds( onePixel, onePixel, onePixel, 1.0 - onePixel, 1.0 - onePixel, 1.0 - onePixel ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ package appeng.block.solids;
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
|
||||
import appeng.block.AEDecorativeBlock;
|
||||
import appeng.core.features.AEFeature;
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@ package appeng.block.solids;
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
|
||||
import appeng.block.AEDecorativeBlock;
|
||||
import appeng.core.features.AEFeature;
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@ package appeng.block.solids;
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
|
||||
import appeng.block.AEDecorativeBlock;
|
||||
import appeng.core.features.AEFeature;
|
||||
|
||||
|
||||
@@ -22,11 +22,12 @@ package appeng.block.solids;
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumWorldBlockLayer;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
import appeng.client.render.blocks.RenderQuartzGlass;
|
||||
@@ -43,6 +44,12 @@ public class BlockQuartzGlass extends AEBaseBlock
|
||||
this.isOpaque = false;
|
||||
this.setFeature( EnumSet.of( AEFeature.DecorativeQuartzBlocks ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumWorldBlockLayer getBlockLayer()
|
||||
{
|
||||
return EnumWorldBlockLayer.CUTOUT;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
@@ -52,16 +59,19 @@ public class BlockQuartzGlass extends AEBaseBlock
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldSideBeRendered( IBlockAccess w, int x, int y, int z, int side )
|
||||
public boolean shouldSideBeRendered(
|
||||
IBlockAccess w,
|
||||
BlockPos pos,
|
||||
EnumFacing side )
|
||||
{
|
||||
Material mat = w.getBlock( x, y, z ).getMaterial();
|
||||
Material mat = w.getBlockState( pos ).getBlock().getMaterial();
|
||||
if( mat == Material.glass || mat == AEGlassMaterial.INSTANCE )
|
||||
{
|
||||
if( w.getBlock( x, y, z ).getRenderType() == this.getRenderType() )
|
||||
if( w.getBlockState( pos ).getBlock().getRenderType() == this.getRenderType() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return super.shouldSideBeRendered( w, x, y, z, side );
|
||||
return super.shouldSideBeRendered( w, pos, side );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,12 +22,10 @@ package appeng.block.solids;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import appeng.client.render.effects.VibrantFX;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.CommonHelper;
|
||||
@@ -45,8 +43,11 @@ public class BlockQuartzLamp extends BlockQuartzGlass
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void randomDisplayTick( World w, int x, int y, int z, Random r )
|
||||
public void randomDisplayTick(
|
||||
World w,
|
||||
BlockPos pos,
|
||||
IBlockState state,
|
||||
Random r )
|
||||
{
|
||||
if( !AEConfig.instance.enableEffects )
|
||||
{
|
||||
@@ -59,7 +60,7 @@ public class BlockQuartzLamp extends BlockQuartzGlass
|
||||
double d1 = ( r.nextFloat() - 0.5F ) * 0.96D;
|
||||
double d2 = ( r.nextFloat() - 0.5F ) * 0.96D;
|
||||
|
||||
VibrantFX fx = new VibrantFX( w, 0.5 + x + d0, 0.5 + y + d1, 0.5 + z + d2, 0.0D, 0.0D, 0.0D );
|
||||
VibrantFX fx = new VibrantFX( w, 0.5 + pos.getX() + d0, 0.5 + pos.getY() + d1, 0.5 + pos.getZ() + d2, 0.0D, 0.0D, 0.0D );
|
||||
|
||||
Minecraft.getMinecraft().effectRenderer.addEffect( fx );
|
||||
}
|
||||
|
||||
@@ -22,8 +22,10 @@ package appeng.block.solids;
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
import appeng.api.util.IOrientable;
|
||||
import appeng.api.util.IOrientableBlock;
|
||||
import appeng.block.AEBaseBlock;
|
||||
@@ -31,6 +33,7 @@ import appeng.core.features.AEFeature;
|
||||
import appeng.helpers.MetaRotation;
|
||||
|
||||
|
||||
// TODO Quartz Rotation.
|
||||
public class BlockQuartzPillar extends AEBaseBlock implements IOrientableBlock
|
||||
{
|
||||
|
||||
@@ -40,6 +43,26 @@ public class BlockQuartzPillar extends AEBaseBlock implements IOrientableBlock
|
||||
this.setFeature( EnumSet.of( AEFeature.DecorativeQuartzBlocks ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetaFromState(
|
||||
IBlockState state )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getStateFromMeta(
|
||||
int meta )
|
||||
{
|
||||
return getDefaultState();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IProperty[] getAEStates()
|
||||
{
|
||||
return new IProperty[]{ AXIS_ORIENTATION };
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean usesMetadata()
|
||||
{
|
||||
@@ -47,8 +70,9 @@ public class BlockQuartzPillar extends AEBaseBlock implements IOrientableBlock
|
||||
}
|
||||
|
||||
@Override
|
||||
public IOrientable getOrientable( final IBlockAccess w, final int x, final int y, final int z )
|
||||
public IOrientable getOrientable( final IBlockAccess w,BlockPos pos )
|
||||
{
|
||||
return new MetaRotation( w, x, y, z );
|
||||
return new MetaRotation( w, pos,false );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,67 +20,54 @@ package appeng.block.solids;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.player.PlayerEvent;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import appeng.api.util.IOrientable;
|
||||
import appeng.api.util.IOrientableBlock;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.core.WorldSettings;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.helpers.LocationRotation;
|
||||
import appeng.helpers.NullRotation;
|
||||
import appeng.util.Platform;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
public class BlockSkyStone extends AEBaseBlock implements IOrientableBlock
|
||||
|
||||
public class BlockSkyStone extends AEBaseBlock
|
||||
{
|
||||
private static final float BLOCK_RESISTANCE = 150.0f;
|
||||
private static final double BREAK_SPEAK_SCALAR = 0.1;
|
||||
private static final double BREAK_SPEAK_THRESHOLD = 7.0;
|
||||
|
||||
@SideOnly( Side.CLIENT )
|
||||
private IIcon block;
|
||||
|
||||
@SideOnly( Side.CLIENT )
|
||||
private IIcon brick;
|
||||
|
||||
@SideOnly( Side.CLIENT )
|
||||
private IIcon smallBrick;
|
||||
|
||||
public BlockSkyStone()
|
||||
public static enum SkystoneType {
|
||||
stone,block,brick,smallbrick
|
||||
};
|
||||
|
||||
SkystoneType type;
|
||||
|
||||
public BlockSkyStone( SkystoneType type )
|
||||
{
|
||||
super( Material.rock );
|
||||
super( Material.rock, Optional.of( type.name()) );
|
||||
this.setHardness( 50 );
|
||||
this.hasSubtypes = true;
|
||||
this.blockResistance = BLOCK_RESISTANCE;
|
||||
this.setHarvestLevel( "pickaxe", 3, 0 );
|
||||
if ( type == SkystoneType.stone )
|
||||
this.setHarvestLevel( "pickaxe", 3 );
|
||||
this.setFeature( EnumSet.of( AEFeature.Core ) );
|
||||
|
||||
this.type = type;
|
||||
|
||||
MinecraftForge.EVENT_BUS.register( this );
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void breakFaster( PlayerEvent.BreakSpeed event )
|
||||
{
|
||||
if( event.block == this && event.entityPlayer != null )
|
||||
if( event.state.getBlock() == this && event.entityPlayer != null )
|
||||
{
|
||||
ItemStack is = event.entityPlayer.inventory.getCurrentItem();
|
||||
int level = -1;
|
||||
@@ -90,7 +77,7 @@ public class BlockSkyStone extends AEBaseBlock implements IOrientableBlock
|
||||
level = is.getItem().getHarvestLevel( is, "pickaxe" );
|
||||
}
|
||||
|
||||
if( event.metadata > 0 || level >= 3 || event.originalSpeed > BREAK_SPEAK_THRESHOLD )
|
||||
if( type != SkystoneType.stone || level >= 3 || event.originalSpeed > BREAK_SPEAK_THRESHOLD )
|
||||
{
|
||||
event.newSpeed /= BREAK_SPEAK_SCALAR;
|
||||
}
|
||||
@@ -98,121 +85,40 @@ public class BlockSkyStone extends AEBaseBlock implements IOrientableBlock
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped( int meta )
|
||||
public void onBlockAdded(
|
||||
World w,
|
||||
BlockPos pos,
|
||||
IBlockState state )
|
||||
{
|
||||
return meta;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getPickBlock( MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player )
|
||||
{
|
||||
final ItemStack is = super.getPickBlock( target, world, x, y, z, player );
|
||||
is.setItemDamage( world.getBlockMetadata( x, y, z ) );
|
||||
|
||||
return is;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockAdded( World w, int x, int y, int z )
|
||||
{
|
||||
super.onBlockAdded( w, x, y, z );
|
||||
super.onBlockAdded( w, pos, state );
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
WorldSettings.getInstance().getCompass().updateArea( w, x, y, z );
|
||||
WorldSettings.getInstance().getCompass().updateArea( w, pos.getX(), pos.getY(), pos.getZ() );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean usesMetadata()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IOrientable getOrientable( final IBlockAccess w, final int x, final int y, final int z )
|
||||
{
|
||||
if( w.getBlockMetadata( x, y, z ) == 0 )
|
||||
{
|
||||
return new LocationRotation( w, x, y, z );
|
||||
}
|
||||
|
||||
return new NullRotation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName( ItemStack is )
|
||||
{
|
||||
if( is.getItemDamage() == 1 )
|
||||
switch(type)
|
||||
{
|
||||
return this.getUnlocalizedName() + ".Block";
|
||||
case block: return this.getUnlocalizedName() + ".Block";
|
||||
case brick: return this.getUnlocalizedName() + ".Brick";
|
||||
case smallbrick: return this.getUnlocalizedName() + ".SmallBrick";
|
||||
default: return this.getUnlocalizedName();
|
||||
}
|
||||
|
||||
if( is.getItemDamage() == 2 )
|
||||
{
|
||||
return this.getUnlocalizedName() + ".Brick";
|
||||
}
|
||||
|
||||
if( is.getItemDamage() == 3 )
|
||||
{
|
||||
return this.getUnlocalizedName() + ".SmallBrick";
|
||||
}
|
||||
|
||||
return this.getUnlocalizedName();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void registerBlockIcons( IIconRegister ir )
|
||||
public void breakBlock(
|
||||
World w,
|
||||
BlockPos pos,
|
||||
IBlockState state )
|
||||
{
|
||||
super.registerBlockIcons( ir );
|
||||
this.block = ir.registerIcon( this.getTextureName() + ".Block" );
|
||||
this.brick = ir.registerIcon( this.getTextureName() + ".Brick" );
|
||||
this.smallBrick = ir.registerIcon( this.getTextureName() + ".SmallBrick" );
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public IIcon getIcon( int direction, int metadata )
|
||||
{
|
||||
if( metadata == 1 )
|
||||
{
|
||||
return this.block;
|
||||
}
|
||||
if( metadata == 2 )
|
||||
{
|
||||
return this.brick;
|
||||
}
|
||||
if( metadata == 3 )
|
||||
{
|
||||
return this.smallBrick;
|
||||
}
|
||||
return super.getIcon( direction, metadata );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRenderStateByMeta( int metadata )
|
||||
{
|
||||
this.getRendererInstance().setTemporaryRenderIcon( this.getIcon( 0, metadata ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void getCheckedSubBlocks( Item item, CreativeTabs tabs, List<ItemStack> itemStacks )
|
||||
{
|
||||
super.getCheckedSubBlocks( item, tabs, itemStacks );
|
||||
|
||||
itemStacks.add( new ItemStack( item, 1, 1 ) );
|
||||
itemStacks.add( new ItemStack( item, 1, 2 ) );
|
||||
itemStacks.add( new ItemStack( item, 1, 3 ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock( World w, int x, int y, int z, Block b, int metadata )
|
||||
{
|
||||
super.breakBlock( w, x, y, z, b, metadata );
|
||||
super.breakBlock( w, pos, state );
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
WorldSettings.getInstance().getCompass().updateArea( w, x, y, z );
|
||||
WorldSettings.getInstance().getCompass().updateArea( w, pos.getX(), pos.getY(), pos.getZ() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,16 +22,16 @@ package appeng.block.solids;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Random;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumWorldBlockLayer;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.exceptions.MissingDefinition;
|
||||
import appeng.block.AEBaseBlock;
|
||||
@@ -56,6 +56,12 @@ public class OreQuartz extends AEBaseBlock
|
||||
this.enhanceBrightness = false;
|
||||
this.setFeature( EnumSet.of( AEFeature.Core ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumWorldBlockLayer getBlockLayer()
|
||||
{
|
||||
return EnumWorldBlockLayer.CUTOUT;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<? extends BaseBlockRender> getRenderer()
|
||||
@@ -70,9 +76,11 @@ public class OreQuartz extends AEBaseBlock
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMixedBrightnessForBlock( IBlockAccess par1iBlockAccess, int par2, int par3, int par4 )
|
||||
public int getMixedBrightnessForBlock(
|
||||
IBlockAccess worldIn,
|
||||
BlockPos pos )
|
||||
{
|
||||
int j1 = super.getMixedBrightnessForBlock( par1iBlockAccess, par2, par3, par4 );
|
||||
int j1 = super.getMixedBrightnessForBlock( worldIn, pos );
|
||||
if( this.enhanceBrightness )
|
||||
{
|
||||
j1 = Math.max( j1 >> 20, j1 >> 4 );
|
||||
@@ -100,10 +108,12 @@ public class OreQuartz extends AEBaseBlock
|
||||
{
|
||||
return 1 + rand.nextInt( 2 );
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@Override
|
||||
public Item getItemDropped( int id, Random rand, int meta )
|
||||
public Item getItemDropped(
|
||||
IBlockState state, /* is null */
|
||||
Random rand,
|
||||
int fortune )
|
||||
{
|
||||
for( Item crystalItem : AEApi.instance().definitions().materials().certusQuartzCrystal().maybeItem().asSet() )
|
||||
{
|
||||
@@ -114,20 +124,26 @@ public class OreQuartz extends AEBaseBlock
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dropBlockAsItemWithChance( World w, int x, int y, int z, int blockID, float something, int meta )
|
||||
public void dropBlockAsItemWithChance(
|
||||
World w,
|
||||
BlockPos pos,
|
||||
IBlockState state,
|
||||
float chance,
|
||||
int fortune )
|
||||
{
|
||||
super.dropBlockAsItemWithChance( w, x, y, z, blockID, something, meta );
|
||||
super.dropBlockAsItemWithChance( w, pos, state, chance, fortune );
|
||||
|
||||
if( this.getItemDropped( blockID, w.rand, meta ) != Item.getItemFromBlock( this ) )
|
||||
if( this.getItemDropped( state, w.rand, fortune ) != Item.getItemFromBlock( this ) )
|
||||
{
|
||||
int xp = MathHelper.getRandomIntegerInRange( w.rand, 2, 5 );
|
||||
|
||||
this.dropXpOnBlockBreak( w, x, y, z, xp );
|
||||
this.dropXpOnBlockBreak( w, pos, xp );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped( int id )
|
||||
public int damageDropped(
|
||||
IBlockState state )
|
||||
{
|
||||
for( ItemStack crystalStack : AEApi.instance().definitions().materials().certusQuartzCrystal().maybeStack( 1 ).asSet() )
|
||||
{
|
||||
@@ -140,7 +156,7 @@ public class OreQuartz extends AEBaseBlock
|
||||
@Override
|
||||
public int quantityDroppedWithBonus( int fortune, Random rand )
|
||||
{
|
||||
if( fortune > 0 && Item.getItemFromBlock( this ) != this.getItemDropped( 0, rand, fortune ) )
|
||||
if( fortune > 0 && Item.getItemFromBlock( this ) != this.getItemDropped( null, rand, fortune ) )
|
||||
{
|
||||
int j = rand.nextInt( fortune + 2 ) - 1;
|
||||
|
||||
|
||||
@@ -21,16 +21,12 @@ package appeng.block.solids;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.exceptions.MissingDefinition;
|
||||
import appeng.client.render.effects.ChargedOreFX;
|
||||
@@ -46,10 +42,12 @@ public class OreQuartzCharged extends OreQuartz
|
||||
this.setBoostBrightnessLow( 2 );
|
||||
this.setBoostBrightnessHigh( 5 );
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@Override
|
||||
public Item getItemDropped( int id, Random rand, int meta )
|
||||
public Item getItemDropped(
|
||||
IBlockState state,
|
||||
Random rand,
|
||||
int fortune )
|
||||
{
|
||||
for( Item charged : AEApi.instance().definitions().materials().certusQuartzCrystalCharged().maybeItem().asSet() )
|
||||
{
|
||||
@@ -60,7 +58,8 @@ public class OreQuartzCharged extends OreQuartz
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped( int id )
|
||||
public int damageDropped(
|
||||
IBlockState state )
|
||||
{
|
||||
for ( ItemStack crystalStack : AEApi.instance().definitions().materials().certusQuartzCrystalCharged().maybeStack( 1 ).asSet() )
|
||||
{
|
||||
@@ -71,8 +70,11 @@ public class OreQuartzCharged extends OreQuartz
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void randomDisplayTick( World w, int x, int y, int z, Random r )
|
||||
public void randomDisplayTick(
|
||||
World w,
|
||||
BlockPos pos,
|
||||
IBlockState state,
|
||||
Random r )
|
||||
{
|
||||
if ( !AEConfig.instance.enableEffects )
|
||||
{
|
||||
@@ -110,7 +112,7 @@ public class OreQuartzCharged extends OreQuartz
|
||||
|
||||
if( CommonHelper.proxy.shouldAddParticles( r ) )
|
||||
{
|
||||
ChargedOreFX fx = new ChargedOreFX( w, x + xOff, y + yOff, z + zOff, 0.0f, 0.0f, 0.0f );
|
||||
ChargedOreFX fx = new ChargedOreFX( w, pos.getX() + xOff, pos.getY() + yOff, pos.getZ() + zOff, 0.0f, 0.0f, 0.0f );
|
||||
Minecraft.getMinecraft().effectRenderer.addEffect( fx );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,19 +24,17 @@ import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.world.Explosion;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
import appeng.client.render.blocks.RenderNull;
|
||||
@@ -63,12 +61,6 @@ public class BlockMatrixFrame extends AEBaseBlock implements ICustomCollision
|
||||
return RenderNull.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons( IIconRegister iconRegistry )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void getCheckedSubBlocks( Item item, CreativeTabs tabs, List<ItemStack> itemStacks )
|
||||
@@ -77,32 +69,49 @@ public class BlockMatrixFrame extends AEBaseBlock implements ICustomCollision
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool( World w, int x, int y, int z, Entity e, boolean isVisual )
|
||||
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool(
|
||||
World w,
|
||||
BlockPos pos,
|
||||
Entity thePlayer,
|
||||
boolean b )
|
||||
{
|
||||
return Arrays.asList( new AxisAlignedBB[] {} );// AxisAlignedBB.getBoundingBox( 0.25, 0, 0.25, 0.75, 0.5, 0.75 )
|
||||
// } );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void addCollidingBlockToList( World w, int x, int y, int z, AxisAlignedBB bb, List<AxisAlignedBB> out, Entity e )
|
||||
public void addCollidingBlockToList(
|
||||
World w,
|
||||
BlockPos pos,
|
||||
AxisAlignedBB bb,
|
||||
List<AxisAlignedBB> out,
|
||||
Entity e )
|
||||
{
|
||||
out.add( AxisAlignedBB.getBoundingBox( 0.0, 0.0, 0.0, 1.0, 1.0, 1.0 ) );
|
||||
out.add( AxisAlignedBB.fromBounds( 0.0, 0.0, 0.0, 1.0, 1.0, 1.0 ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlaceBlockAt( World world, int x, int y, int z )
|
||||
public boolean canPlaceBlockAt(
|
||||
World worldIn,
|
||||
BlockPos pos )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockExploded( World world, int x, int y, int z, Explosion explosion )
|
||||
public void onBlockExploded(
|
||||
World world,
|
||||
BlockPos pos,
|
||||
Explosion explosion )
|
||||
{
|
||||
// Don't explode.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canEntityDestroy( IBlockAccess world, int x, int y, int z, Entity entity )
|
||||
public boolean canEntityDestroy(
|
||||
IBlockAccess world,
|
||||
BlockPos pos,
|
||||
Entity entity )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -23,10 +23,12 @@ import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
@@ -45,9 +47,13 @@ public class BlockSpatialIOPort extends AEBaseTileBlock
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void onNeighborBlockChange( World w, int x, int y, int z, Block junk )
|
||||
public void onNeighborBlockChange(
|
||||
World w,
|
||||
BlockPos pos,
|
||||
IBlockState state,
|
||||
Block neighborBlock )
|
||||
{
|
||||
TileSpatialIOPort te = this.getTileEntity( w, x, y, z );
|
||||
TileSpatialIOPort te = this.getTileEntity( w, pos );
|
||||
if( te != null )
|
||||
{
|
||||
te.updateRedstoneState();
|
||||
@@ -55,19 +61,26 @@ public class BlockSpatialIOPort extends AEBaseTileBlock
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActivated( World w, int x, int y, int z, EntityPlayer p, int side, float hitX, float hitY, float hitZ )
|
||||
public boolean onActivated(
|
||||
World w,
|
||||
BlockPos pos,
|
||||
EntityPlayer p,
|
||||
EnumFacing side,
|
||||
float hitX,
|
||||
float hitY,
|
||||
float hitZ )
|
||||
{
|
||||
if( p.isSneaking() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
TileSpatialIOPort tg = this.getTileEntity( w, x, y, z );
|
||||
TileSpatialIOPort tg = this.getTileEntity( w, pos );
|
||||
if( tg != null )
|
||||
{
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
Platform.openGUI( p, tg, ForgeDirection.getOrientation( side ), GuiBridge.GUI_SPATIAL_IO_PORT );
|
||||
Platform.openGUI( p, tg, AEPartLocation.fromFacing( side ), GuiBridge.GUI_SPATIAL_IO_PORT );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -22,9 +22,10 @@ package appeng.block.spatial;
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
import appeng.client.render.blocks.RenderSpatialPylon;
|
||||
@@ -44,24 +45,30 @@ public class BlockSpatialPylon extends AEBaseTileBlock
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange( World w, int x, int y, int z, Block junk )
|
||||
public void onNeighborBlockChange(
|
||||
World w,
|
||||
BlockPos pos,
|
||||
IBlockState state,
|
||||
Block neighborBlock )
|
||||
{
|
||||
TileSpatialPylon tsp = this.getTileEntity( w, x, y, z );
|
||||
TileSpatialPylon tsp = this.getTileEntity( w, pos );
|
||||
if( tsp != null )
|
||||
{
|
||||
tsp.onNeighborBlockChange();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getLightValue( IBlockAccess w, int x, int y, int z )
|
||||
public int getLightValue(
|
||||
IBlockAccess w,
|
||||
BlockPos pos )
|
||||
{
|
||||
TileSpatialPylon tsp = this.getTileEntity( w, x, y, z );
|
||||
TileSpatialPylon tsp = this.getTileEntity( w, pos );
|
||||
if( tsp != null )
|
||||
{
|
||||
return tsp.getLightValue();
|
||||
}
|
||||
return super.getLightValue( w, x, y, z );
|
||||
return super.getLightValue( w, pos );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+3
-4
@@ -22,15 +22,14 @@ package appeng.block.stair;
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import appeng.block.AEBaseStairBlock;
|
||||
import appeng.core.features.AEFeature;
|
||||
|
||||
|
||||
public class QuartzPillarStairBlock extends AEBaseStairBlock
|
||||
public class BlockStairCommon extends AEBaseStairBlock
|
||||
{
|
||||
public QuartzPillarStairBlock( Block block )
|
||||
public BlockStairCommon( Block material, String type )
|
||||
{
|
||||
super( block, 0, EnumSet.of( AEFeature.DecorativeQuartzBlocks ) );
|
||||
super( material,EnumSet.of( AEFeature.DecorativeQuartzBlocks ), type );
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.block.stair;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import appeng.block.AEBaseStairBlock;
|
||||
import appeng.core.features.AEFeature;
|
||||
|
||||
|
||||
public class ChiseledQuartzStairBlock extends AEBaseStairBlock
|
||||
{
|
||||
public ChiseledQuartzStairBlock( Block block )
|
||||
{
|
||||
super( block, 0, EnumSet.of( AEFeature.DecorativeQuartzBlocks ) );
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.block.stair;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import appeng.block.AEBaseStairBlock;
|
||||
import appeng.core.features.AEFeature;
|
||||
|
||||
|
||||
public class FluixStairBlock extends AEBaseStairBlock
|
||||
{
|
||||
public FluixStairBlock( Block block )
|
||||
{
|
||||
super( block, 0, EnumSet.of( AEFeature.DecorativeQuartzBlocks ) );
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.block.stair;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import appeng.block.AEBaseStairBlock;
|
||||
import appeng.core.features.AEFeature;
|
||||
|
||||
|
||||
public class QuartzStairBlock extends AEBaseStairBlock
|
||||
{
|
||||
public QuartzStairBlock( Block block )
|
||||
{
|
||||
super( block, 0, EnumSet.of( AEFeature.DecorativeQuartzBlocks ) );
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.block.stair;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import appeng.block.AEBaseStairBlock;
|
||||
import appeng.core.features.AEFeature;
|
||||
|
||||
|
||||
public class SkyStoneBlockStairBlock extends AEBaseStairBlock
|
||||
{
|
||||
public SkyStoneBlockStairBlock( Block block, Integer meta )
|
||||
{
|
||||
super( block, meta, EnumSet.of( AEFeature.DecorativeQuartzBlocks ) );
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.block.stair;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import appeng.block.AEBaseStairBlock;
|
||||
import appeng.core.features.AEFeature;
|
||||
|
||||
|
||||
public class SkyStoneBrickStairBlock extends AEBaseStairBlock
|
||||
{
|
||||
public SkyStoneBrickStairBlock( Block block, Integer meta )
|
||||
{
|
||||
super( block, meta, EnumSet.of( AEFeature.DecorativeQuartzBlocks ) );
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.block.stair;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import appeng.block.AEBaseStairBlock;
|
||||
import appeng.core.features.AEFeature;
|
||||
|
||||
|
||||
public class SkyStoneSmallBrickStairBlock extends AEBaseStairBlock
|
||||
{
|
||||
public SkyStoneSmallBrickStairBlock( Block block, int meta )
|
||||
{
|
||||
super( block, meta, EnumSet.of( AEFeature.DecorativeQuartzBlocks ) );
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.block.stair;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import appeng.block.AEBaseStairBlock;
|
||||
import appeng.core.features.AEFeature;
|
||||
|
||||
|
||||
public class SkyStoneStairBlock extends AEBaseStairBlock
|
||||
{
|
||||
public SkyStoneStairBlock( Block block, Integer meta )
|
||||
{
|
||||
super( block, meta, EnumSet.of( AEFeature.DecorativeQuartzBlocks ) );
|
||||
}
|
||||
}
|
||||
@@ -24,11 +24,13 @@ import java.util.EnumSet;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumWorldBlockLayer;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.storage.ICellHandler;
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
import appeng.client.render.blocks.RenderMEChest;
|
||||
@@ -41,7 +43,7 @@ import appeng.util.Platform;
|
||||
|
||||
public class BlockChest extends AEBaseTileBlock
|
||||
{
|
||||
|
||||
|
||||
public BlockChest()
|
||||
{
|
||||
super( Material.iron );
|
||||
@@ -49,6 +51,12 @@ public class BlockChest extends AEBaseTileBlock
|
||||
this.setFeature( EnumSet.of( AEFeature.StorageCells, AEFeature.MEChest ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumWorldBlockLayer getBlockLayer()
|
||||
{
|
||||
return EnumWorldBlockLayer.CUTOUT;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<? extends BaseBlockRender> getRenderer()
|
||||
{
|
||||
@@ -56,9 +64,16 @@ public class BlockChest extends AEBaseTileBlock
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActivated( World w, int x, int y, int z, EntityPlayer p, int side, float hitX, float hitY, float hitZ )
|
||||
public boolean onActivated(
|
||||
World w,
|
||||
BlockPos pos,
|
||||
EntityPlayer p,
|
||||
EnumFacing side,
|
||||
float hitX,
|
||||
float hitY,
|
||||
float hitZ )
|
||||
{
|
||||
TileChest tg = this.getTileEntity( w, x, y, z );
|
||||
TileChest tg = this.getTileEntity( w, pos );
|
||||
if( tg != null && !p.isSneaking() )
|
||||
{
|
||||
if( Platform.isClient() )
|
||||
@@ -66,9 +81,9 @@ public class BlockChest extends AEBaseTileBlock
|
||||
return true;
|
||||
}
|
||||
|
||||
if( side != tg.getUp().ordinal() )
|
||||
if( side != tg.getUp() )
|
||||
{
|
||||
Platform.openGUI( p, tg, ForgeDirection.getOrientation( side ), GuiBridge.GUI_CHEST );
|
||||
Platform.openGUI( p, tg, AEPartLocation.fromFacing( side ), GuiBridge.GUI_CHEST );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -23,9 +23,11 @@ import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumWorldBlockLayer;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
import appeng.client.render.blocks.RenderDrive;
|
||||
@@ -45,26 +47,39 @@ public class BlockDrive extends AEBaseTileBlock
|
||||
this.setFeature( EnumSet.of( AEFeature.StorageCells, AEFeature.MEDrive ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumWorldBlockLayer getBlockLayer()
|
||||
{
|
||||
return EnumWorldBlockLayer.CUTOUT;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<? extends BaseBlockRender> getRenderer()
|
||||
{
|
||||
return RenderDrive.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onActivated( World w, int x, int y, int z, EntityPlayer p, int side, float hitX, float hitY, float hitZ )
|
||||
public boolean onActivated(
|
||||
World w,
|
||||
BlockPos pos,
|
||||
EntityPlayer p,
|
||||
EnumFacing side,
|
||||
float hitX,
|
||||
float hitY,
|
||||
float hitZ )
|
||||
{
|
||||
if( p.isSneaking() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
TileDrive tg = this.getTileEntity( w, x, y, z );
|
||||
TileDrive tg = this.getTileEntity( w, pos );
|
||||
if( tg != null )
|
||||
{
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
Platform.openGUI( p, tg, ForgeDirection.getOrientation( side ), GuiBridge.GUI_DRIVE );
|
||||
Platform.openGUI( p, tg, AEPartLocation.fromFacing( side ), GuiBridge.GUI_DRIVE );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -23,10 +23,12 @@ import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
@@ -43,31 +45,42 @@ public class BlockIOPort extends AEBaseTileBlock
|
||||
this.setTileEntity( TileIOPort.class );
|
||||
this.setFeature( EnumSet.of( AEFeature.StorageCells, AEFeature.IOPort ) );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public final void onNeighborBlockChange( World w, int x, int y, int z, Block junk )
|
||||
public void onNeighborBlockChange(
|
||||
World w,
|
||||
BlockPos pos,
|
||||
IBlockState state,
|
||||
Block neighborBlock )
|
||||
{
|
||||
TileIOPort te = this.getTileEntity( w, x, y, z );
|
||||
TileIOPort te = this.getTileEntity( w, pos );
|
||||
if( te != null )
|
||||
{
|
||||
te.updateRedstoneState();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onActivated( World w, int x, int y, int z, EntityPlayer p, int side, float hitX, float hitY, float hitZ )
|
||||
public boolean onActivated(
|
||||
World w,
|
||||
BlockPos pos,
|
||||
EntityPlayer p,
|
||||
EnumFacing side,
|
||||
float hitX,
|
||||
float hitY,
|
||||
float hitZ )
|
||||
{
|
||||
if( p.isSneaking() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
TileIOPort tg = this.getTileEntity( w, x, y, z );
|
||||
TileIOPort tg = this.getTileEntity( w, pos );
|
||||
if( tg != null )
|
||||
{
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
Platform.openGUI( p, tg, ForgeDirection.getOrientation( side ), GuiBridge.GUI_IOPORT );
|
||||
Platform.openGUI( p, tg, AEPartLocation.fromFacing( side ), GuiBridge.GUI_IOPORT );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -23,25 +23,14 @@ import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
import appeng.client.render.blocks.RenderBlockSkyChest;
|
||||
@@ -51,37 +40,32 @@ import appeng.helpers.ICustomCollision;
|
||||
import appeng.tile.storage.TileSkyChest;
|
||||
import appeng.util.Platform;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
|
||||
public class BlockSkyChest extends AEBaseTileBlock implements ICustomCollision
|
||||
{
|
||||
|
||||
public BlockSkyChest()
|
||||
|
||||
public static enum SkyChestType
|
||||
{
|
||||
super( Material.rock );
|
||||
STONE, BLOCK
|
||||
};
|
||||
|
||||
public final SkyChestType type;
|
||||
|
||||
public BlockSkyChest( SkyChestType type )
|
||||
{
|
||||
super( Material.rock, Optional.of( type.name() ) );
|
||||
this.setTileEntity( TileSkyChest.class );
|
||||
this.isOpaque = this.isFullSize = false;
|
||||
this.lightOpacity = 0;
|
||||
this.hasSubtypes = true;
|
||||
this.setHardness( 50 );
|
||||
this.blockResistance = 150.0f;
|
||||
this.type = type;
|
||||
this.setFeature( EnumSet.of( AEFeature.Core, AEFeature.SkyStoneChests ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped( int metadata )
|
||||
{
|
||||
return metadata;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getPickBlock( MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player )
|
||||
{
|
||||
final ItemStack is = super.getPickBlock( target, world, x, y, z, player );
|
||||
is.setItemDamage( world.getBlockMetadata( x, y, z ) );
|
||||
|
||||
return is;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<? extends BaseBlockRender> getRenderer()
|
||||
{
|
||||
@@ -89,75 +73,54 @@ public class BlockSkyChest extends AEBaseTileBlock implements ICustomCollision
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public IIcon getIcon( int direction, int metadata )
|
||||
{
|
||||
for( Block skyStoneBlock : AEApi.instance().definitions().blocks().skyStone().maybeBlock().asSet() )
|
||||
{
|
||||
return skyStoneBlock.getIcon( direction, metadata );
|
||||
}
|
||||
|
||||
return Blocks.stone.getIcon( direction, metadata );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActivated( World w, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ )
|
||||
public boolean onActivated(
|
||||
World w,
|
||||
BlockPos pos,
|
||||
EntityPlayer player,
|
||||
EnumFacing side,
|
||||
float hitX,
|
||||
float hitY,
|
||||
float hitZ )
|
||||
{
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
Platform.openGUI( player, this.getTileEntity( w, x, y, z ), ForgeDirection.getOrientation( side ), GuiBridge.GUI_SKYCHEST );
|
||||
Platform.openGUI( player, this.getTileEntity( w, pos ), AEPartLocation.fromFacing( side ), GuiBridge.GUI_SKYCHEST );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons( IIconRegister iconRegistry )
|
||||
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool(
|
||||
World w,
|
||||
BlockPos pos,
|
||||
Entity thePlayer,
|
||||
boolean b )
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void getCheckedSubBlocks( Item item, CreativeTabs tabs, List<ItemStack> itemStacks )
|
||||
{
|
||||
super.getCheckedSubBlocks( item, tabs, itemStacks );
|
||||
|
||||
itemStacks.add( new ItemStack( item, 1, 1 ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName( ItemStack is )
|
||||
{
|
||||
if( is.getItemDamage() == 1 )
|
||||
{
|
||||
return this.getUnlocalizedName() + ".Block";
|
||||
}
|
||||
|
||||
return this.getUnlocalizedName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool( World w, int x, int y, int z, Entity e, boolean isVisual )
|
||||
{
|
||||
TileSkyChest sk = this.getTileEntity( w, x, y, z );
|
||||
TileSkyChest sk = this.getTileEntity( w, pos );
|
||||
double sc = 0.06;
|
||||
ForgeDirection o = ForgeDirection.UNKNOWN;
|
||||
EnumFacing o = EnumFacing.UP;
|
||||
|
||||
if( sk != null )
|
||||
{
|
||||
o = sk.getUp();
|
||||
}
|
||||
|
||||
double offsetX = o.offsetX == 0 ? 0.06 : 0.0;
|
||||
double offsetY = o.offsetY == 0 ? 0.06 : 0.0;
|
||||
double offsetZ = o.offsetZ == 0 ? 0.06 : 0.0;
|
||||
double offsetX = o.getFrontOffsetX() == 0 ? 0.06 : 0.0;
|
||||
double offsetY = o.getFrontOffsetY() == 0 ? 0.06 : 0.0;
|
||||
double offsetZ = o.getFrontOffsetZ() == 0 ? 0.06 : 0.0;
|
||||
|
||||
return Collections.singletonList( AxisAlignedBB.getBoundingBox( Math.max( 0.0, offsetX - o.offsetX * sc ), Math.max( 0.0, offsetY - o.offsetY * sc ), Math.max( 0.0, offsetZ - o.offsetZ * sc ), Math.min( 1.0, ( 1.0 - offsetX ) - o.offsetX * sc ), Math.min( 1.0, ( 1.0 - offsetY ) - o.offsetY * sc ), Math.min( 1.0, ( 1.0 - offsetZ ) - o.offsetZ * sc ) ) );
|
||||
return Collections.singletonList( AxisAlignedBB.fromBounds( Math.max( 0.0, offsetX - o.getFrontOffsetX() * sc ), Math.max( 0.0, offsetY - o.getFrontOffsetY() * sc ), Math.max( 0.0, offsetZ - o.getFrontOffsetZ() * sc ), Math.min( 1.0, ( 1.0 - offsetX ) - o.getFrontOffsetX() * sc ), Math.min( 1.0, ( 1.0 - offsetY ) - o.getFrontOffsetY() * sc ), Math.min( 1.0, ( 1.0 - offsetZ ) - o.getFrontOffsetZ() * sc ) ) );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void addCollidingBlockToList( World w, int x, int y, int z, AxisAlignedBB bb, List<AxisAlignedBB> out, Entity e )
|
||||
public void addCollidingBlockToList(
|
||||
World w,
|
||||
BlockPos pos,
|
||||
AxisAlignedBB bb,
|
||||
List<AxisAlignedBB> out,
|
||||
Entity e )
|
||||
{
|
||||
out.add( AxisAlignedBB.getBoundingBox( 0.05, 0.05, 0.05, 0.95, 0.95, 0.95 ) );
|
||||
out.add( AxisAlignedBB.fromBounds( 0.05, 0.05, 0.05, 0.95, 0.95, 0.95 ) );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user