pick 97420a31d The big reformat of 2020
This commit is contained in:
@@ -18,13 +18,10 @@
|
||||
|
||||
package appeng.block.crafting;
|
||||
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.ContainerCraftingCPU;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.state.BooleanProperty;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.state.BooleanProperty;
|
||||
import net.minecraft.state.StateContainer;
|
||||
import net.minecraft.util.ActionResultType;
|
||||
import net.minecraft.util.Hand;
|
||||
@@ -33,75 +30,71 @@ import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.ContainerCraftingCPU;
|
||||
import appeng.tile.crafting.TileCraftingTile;
|
||||
|
||||
public abstract class AbstractCraftingUnitBlock<T extends TileCraftingTile> extends AEBaseTileBlock<T> {
|
||||
public static final BooleanProperty FORMED = BooleanProperty.create("formed");
|
||||
public static final BooleanProperty POWERED = BooleanProperty.create("powered");
|
||||
|
||||
public abstract class AbstractCraftingUnitBlock<T extends TileCraftingTile> extends AEBaseTileBlock<T>
|
||||
{
|
||||
public static final BooleanProperty FORMED = BooleanProperty.create( "formed" );
|
||||
public static final BooleanProperty POWERED = BooleanProperty.create( "powered" );
|
||||
public final CraftingUnitType type;
|
||||
|
||||
public final CraftingUnitType type;
|
||||
public AbstractCraftingUnitBlock(Block.Properties props, final CraftingUnitType type) {
|
||||
super(props);
|
||||
this.type = type;
|
||||
this.setDefaultState(getDefaultState().with(FORMED, false).with(POWERED, false));
|
||||
}
|
||||
|
||||
public AbstractCraftingUnitBlock(Block.Properties props, final CraftingUnitType type )
|
||||
{
|
||||
super( props );
|
||||
this.type = type;
|
||||
this.setDefaultState(getDefaultState().with(FORMED, false).with(POWERED, false));
|
||||
}
|
||||
@Override
|
||||
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
|
||||
super.fillStateContainer(builder);
|
||||
builder.add(POWERED);
|
||||
builder.add(FORMED);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
|
||||
super.fillStateContainer(builder);
|
||||
builder.add(POWERED);
|
||||
builder.add(FORMED);
|
||||
}
|
||||
@Override
|
||||
public void neighborChanged(final BlockState state, final World worldIn, final BlockPos pos, final Block blockIn,
|
||||
final BlockPos fromPos, boolean isMoving) {
|
||||
final TileCraftingTile cp = this.getTileEntity(worldIn, pos);
|
||||
if (cp != null) {
|
||||
cp.updateMultiBlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void neighborChanged( final BlockState state, final World worldIn, final BlockPos pos, final Block blockIn, final BlockPos fromPos, boolean isMoving )
|
||||
{
|
||||
final TileCraftingTile cp = this.getTileEntity( worldIn, pos );
|
||||
if( cp != null )
|
||||
{
|
||||
cp.updateMultiBlock();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onReplaced(BlockState state, World w, BlockPos pos, BlockState newState, boolean isMoving) {
|
||||
if (newState.getBlock() == state.getBlock()) {
|
||||
return; // Just a block state change
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReplaced(BlockState state, World w, BlockPos pos, BlockState newState, boolean isMoving)
|
||||
{
|
||||
if (newState.getBlock() == state.getBlock()) {
|
||||
return; // Just a block state change
|
||||
}
|
||||
final TileCraftingTile cp = this.getTileEntity(w, pos);
|
||||
if (cp != null) {
|
||||
cp.breakCluster();
|
||||
}
|
||||
|
||||
final TileCraftingTile cp = this.getTileEntity( w, pos );
|
||||
if( cp != null )
|
||||
{
|
||||
cp.breakCluster();
|
||||
}
|
||||
super.onReplaced(state, w, pos, newState, isMoving);
|
||||
}
|
||||
|
||||
super.onReplaced( state, w, pos, newState, isMoving );
|
||||
}
|
||||
@Override
|
||||
public ActionResultType onBlockActivated(BlockState state, World w, BlockPos pos, PlayerEntity p, Hand hand,
|
||||
BlockRayTraceResult hit) {
|
||||
final TileCraftingTile tg = this.getTileEntity(w, pos);
|
||||
|
||||
@Override
|
||||
public ActionResultType onBlockActivated(BlockState state, World w, BlockPos pos, PlayerEntity p, Hand hand, BlockRayTraceResult hit) {
|
||||
final TileCraftingTile tg = this.getTileEntity( w, pos );
|
||||
if (tg != null && !p.isCrouching() && tg.isFormed() && tg.isActive()) {
|
||||
if (!w.isRemote()) {
|
||||
ContainerOpener.openContainer(ContainerCraftingCPU.TYPE, p,
|
||||
ContainerLocator.forTileEntitySide(tg, hit.getFace()));
|
||||
}
|
||||
|
||||
if( tg != null && !p.isCrouching() && tg.isFormed() && tg.isActive() )
|
||||
{
|
||||
if ( !w.isRemote() )
|
||||
{
|
||||
ContainerOpener.openContainer(ContainerCraftingCPU.TYPE, p, ContainerLocator.forTileEntitySide(tg, hit.getFace()));
|
||||
}
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
return super.onBlockActivated(state, w, pos, p, hand, hit);
|
||||
}
|
||||
|
||||
return super.onBlockActivated(state, w, pos, p, hand, hit);
|
||||
}
|
||||
|
||||
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