reformatted all src files (#141)
This commit is contained in:
@@ -19,8 +19,13 @@
|
||||
package appeng.block.crafting;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.client.UnlistedProperty;
|
||||
import appeng.client.render.crafting.CraftingCubeState;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.tile.crafting.TileCraftingTile;
|
||||
import appeng.util.Platform;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
@@ -38,130 +43,105 @@ import net.minecraftforge.common.property.ExtendedBlockState;
|
||||
import net.minecraftforge.common.property.IExtendedBlockState;
|
||||
import net.minecraftforge.common.property.IUnlistedProperty;
|
||||
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.client.UnlistedProperty;
|
||||
import appeng.client.render.crafting.CraftingCubeState;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.tile.crafting.TileCraftingTile;
|
||||
import appeng.util.Platform;
|
||||
import java.util.EnumSet;
|
||||
|
||||
|
||||
public class BlockCraftingUnit extends AEBaseTileBlock
|
||||
{
|
||||
public static final PropertyBool FORMED = PropertyBool.create( "formed" );
|
||||
public static final PropertyBool POWERED = PropertyBool.create( "powered" );
|
||||
public static final UnlistedProperty<CraftingCubeState> STATE = new UnlistedProperty<>( "state", CraftingCubeState.class );
|
||||
public class BlockCraftingUnit extends AEBaseTileBlock {
|
||||
public static final PropertyBool FORMED = PropertyBool.create("formed");
|
||||
public static final PropertyBool POWERED = PropertyBool.create("powered");
|
||||
public static final UnlistedProperty<CraftingCubeState> STATE = new UnlistedProperty<>("state", CraftingCubeState.class);
|
||||
|
||||
public final CraftingUnitType type;
|
||||
public final CraftingUnitType type;
|
||||
|
||||
public BlockCraftingUnit( final CraftingUnitType type )
|
||||
{
|
||||
super( Material.IRON );
|
||||
public BlockCraftingUnit(final CraftingUnitType type) {
|
||||
super(Material.IRON);
|
||||
|
||||
this.type = type;
|
||||
}
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IProperty[] getAEStates()
|
||||
{
|
||||
return new IProperty[] { POWERED, FORMED };
|
||||
}
|
||||
@Override
|
||||
protected IProperty[] getAEStates() {
|
||||
return new IProperty[]{POWERED, FORMED};
|
||||
}
|
||||
|
||||
@Override
|
||||
public IExtendedBlockState getExtendedState( IBlockState state, IBlockAccess world, BlockPos pos )
|
||||
{
|
||||
@Override
|
||||
public IExtendedBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos) {
|
||||
|
||||
EnumSet<EnumFacing> connections = EnumSet.noneOf( EnumFacing.class );
|
||||
EnumSet<EnumFacing> connections = EnumSet.noneOf(EnumFacing.class);
|
||||
|
||||
for( EnumFacing facing : EnumFacing.values() )
|
||||
{
|
||||
if( this.isConnected( world, pos, facing ) )
|
||||
{
|
||||
connections.add( facing );
|
||||
}
|
||||
}
|
||||
for (EnumFacing facing : EnumFacing.values()) {
|
||||
if (this.isConnected(world, pos, facing)) {
|
||||
connections.add(facing);
|
||||
}
|
||||
}
|
||||
|
||||
IExtendedBlockState extState = (IExtendedBlockState) state;
|
||||
IExtendedBlockState extState = (IExtendedBlockState) state;
|
||||
|
||||
return extState.withProperty( STATE, new CraftingCubeState( connections ) );
|
||||
}
|
||||
return extState.withProperty(STATE, new CraftingCubeState(connections));
|
||||
}
|
||||
|
||||
private boolean isConnected( IBlockAccess world, BlockPos pos, EnumFacing side )
|
||||
{
|
||||
BlockPos adjacentPos = pos.offset( side );
|
||||
return world.getBlockState( adjacentPos ).getBlock() instanceof BlockCraftingUnit;
|
||||
}
|
||||
private boolean isConnected(IBlockAccess world, BlockPos pos, EnumFacing side) {
|
||||
BlockPos adjacentPos = pos.offset(side);
|
||||
return world.getBlockState(adjacentPos).getBlock() instanceof BlockCraftingUnit;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockStateContainer createBlockState()
|
||||
{
|
||||
return new ExtendedBlockState( this, this.getAEStates(), new IUnlistedProperty[] { STATE } );
|
||||
}
|
||||
@Override
|
||||
protected BlockStateContainer createBlockState() {
|
||||
return new ExtendedBlockState(this, this.getAEStates(), new IUnlistedProperty[]{STATE});
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getStateFromMeta( final int meta )
|
||||
{
|
||||
return this.getDefaultState().withProperty( POWERED, ( meta & 1 ) == 1 ).withProperty( FORMED, ( meta & 2 ) == 2 );
|
||||
}
|
||||
@Override
|
||||
public IBlockState getStateFromMeta(final int meta) {
|
||||
return this.getDefaultState().withProperty(POWERED, (meta & 1) == 1).withProperty(FORMED, (meta & 2) == 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetaFromState( final IBlockState state )
|
||||
{
|
||||
boolean p = state.getValue( POWERED );
|
||||
boolean f = state.getValue( FORMED );
|
||||
return ( p ? 1 : 0 ) | ( f ? 2 : 0 );
|
||||
}
|
||||
@Override
|
||||
public int getMetaFromState(final IBlockState state) {
|
||||
boolean p = state.getValue(POWERED);
|
||||
boolean f = state.getValue(FORMED);
|
||||
return (p ? 1 : 0) | (f ? 2 : 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void neighborChanged( final IBlockState state, final World worldIn, final BlockPos pos, final Block blockIn, final BlockPos fromPos )
|
||||
{
|
||||
final TileCraftingTile cp = this.getTileEntity( worldIn, pos );
|
||||
if( cp != null )
|
||||
{
|
||||
cp.updateMultiBlock();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void neighborChanged(final IBlockState state, final World worldIn, final BlockPos pos, final Block blockIn, final BlockPos fromPos) {
|
||||
final TileCraftingTile cp = this.getTileEntity(worldIn, pos);
|
||||
if (cp != null) {
|
||||
cp.updateMultiBlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockRenderLayer getBlockLayer()
|
||||
{
|
||||
return BlockRenderLayer.CUTOUT;
|
||||
}
|
||||
@Override
|
||||
public BlockRenderLayer getBlockLayer() {
|
||||
return BlockRenderLayer.CUTOUT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock( final World w, final BlockPos pos, final IBlockState state )
|
||||
{
|
||||
final TileCraftingTile cp = this.getTileEntity( w, pos );
|
||||
if( cp != null )
|
||||
{
|
||||
cp.breakCluster();
|
||||
}
|
||||
@Override
|
||||
public void breakBlock(final World w, final BlockPos pos, final IBlockState state) {
|
||||
final TileCraftingTile cp = this.getTileEntity(w, pos);
|
||||
if (cp != null) {
|
||||
cp.breakCluster();
|
||||
}
|
||||
|
||||
super.breakBlock( w, pos, state );
|
||||
}
|
||||
super.breakBlock(w, pos, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated( final World w, final BlockPos pos, final IBlockState state, final EntityPlayer p, final EnumHand hand, final EnumFacing side, final float hitX, final float hitY, final float hitZ )
|
||||
{
|
||||
final TileCraftingTile tg = this.getTileEntity( w, pos );
|
||||
@Override
|
||||
public boolean onBlockActivated(final World w, final BlockPos pos, final IBlockState state, final EntityPlayer p, final EnumHand hand, final EnumFacing side, final float hitX, final float hitY, final float hitZ) {
|
||||
final TileCraftingTile tg = this.getTileEntity(w, pos);
|
||||
|
||||
if( tg != null && !p.isSneaking() && tg.isFormed() && tg.isActive() )
|
||||
{
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (tg != null && !p.isSneaking() && tg.isFormed() && tg.isActive()) {
|
||||
if (Platform.isClient()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Platform.openGUI( p, tg, AEPartLocation.fromFacing( side ), GuiBridge.GUI_CRAFTING_CPU );
|
||||
return true;
|
||||
}
|
||||
Platform.openGUI(p, tg, AEPartLocation.fromFacing(side), GuiBridge.GUI_CRAFTING_CPU);
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.onBlockActivated( w, pos, state, p, hand, side, hitX, hitY, hitZ );
|
||||
}
|
||||
return super.onBlockActivated(w, pos, state, p, hand, side, hitX, hitY, hitZ);
|
||||
}
|
||||
|
||||
public enum CraftingUnitType
|
||||
{
|
||||
UNIT, ACCELERATOR, STORAGE_1K, STORAGE_4K, STORAGE_16K, STORAGE_64K, MONITOR
|
||||
}
|
||||
public enum CraftingUnitType {
|
||||
UNIT, ACCELERATOR, STORAGE_1K, STORAGE_4K, STORAGE_16K, STORAGE_64K, MONITOR
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user