Lots of compile fixes

This commit is contained in:
Sebastian Hartte
2020-06-04 03:02:48 +02:00
parent 6eb2a9504a
commit 237463dd94
241 changed files with 3438 additions and 3474 deletions
@@ -0,0 +1,99 @@
/*
* 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.crafting;
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.StateContainer;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.world.World;
import appeng.block.AEBaseTileBlock;
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 final CraftingUnitType type;
public AbstractCraftingUnitBlock(Block.Properties props, final CraftingUnitType type )
{
super( props );
this.type = type;
}
@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 onReplaced(BlockState state, World w, BlockPos pos, BlockState newState, boolean isMoving)
{
final TileCraftingTile cp = this.getTileEntity( w, pos );
if( cp != null )
{
cp.breakCluster();
}
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 );
if( tg != null && !p.isCrouching() && tg.isFormed() && tg.isActive() )
{
if ( !w.isRemote() )
{
// FIXME Platform.openGUI( p, tg, AEPartLocation.fromFacing( side ), GuiBridge.GUI_CRAFTING_CPU );
}
return ActionResultType.SUCCESS;
}
return super.onBlockActivated(state, w, pos, p, hand, hit);
}
public enum CraftingUnitType
{
UNIT, ACCELERATOR, STORAGE_1K, STORAGE_4K, STORAGE_16K, STORAGE_64K, MONITOR
}
}
@@ -19,72 +19,12 @@
package appeng.block.crafting;
import net.minecraft.block.BlockStateContainer;
import net.minecraft.block.BlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Direction;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockReader;
import net.minecraftforge.common.property.ExtendedBlockState;
import net.minecraftforge.common.property.IExtendedBlockState;
import net.minecraftforge.common.property.IUnlistedProperty;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import appeng.api.util.AEColor;
import appeng.client.UnlistedProperty;
import appeng.tile.crafting.TileCraftingMonitorTile;
public class BlockCraftingMonitor extends BlockCraftingUnit
public class BlockCraftingMonitor extends AbstractCraftingUnitBlock<TileCraftingMonitorTile>
{
public static final UnlistedProperty<AEColor> COLOR = new UnlistedProperty<>( "color", AEColor.class );
public BlockCraftingMonitor()
public BlockCraftingMonitor(Properties props)
{
super( CraftingUnitType.MONITOR );
}
@Override
protected BlockStateContainer createBlockState()
{
return new ExtendedBlockState( this, this.getAEStates(), new IUnlistedProperty[] {
STATE,
COLOR,
FORWARD,
UP
} );
}
@Override
public IExtendedBlockState getExtendedState( BlockState state, IBlockReader world, BlockPos pos )
{
AEColor color = AEColor.TRANSPARENT;
Direction forward = Direction.NORTH;
Direction up = Direction.UP;
TileCraftingMonitorTile te = this.getTileEntity( world, pos );
if( te != null )
{
color = te.getColor();
forward = te.getForward();
up = te.getUp();
}
return super.getExtendedState( state, world, pos )
.with( COLOR, color )
.with( FORWARD, forward )
.with( UP, up );
}
@Override
@OnlyIn( Dist.CLIENT )
public void fillItemGroup(ItemGroup group, NonNullList<ItemStack> itemStacks)
{
itemStacks.add( new ItemStack( this, 1, 0 ) );
super( props, CraftingUnitType.MONITOR );
}
}
@@ -19,12 +19,13 @@
package appeng.block.crafting;
public class BlockCraftingStorage extends BlockCraftingUnit
import appeng.tile.crafting.TileCraftingStorageTile;
public class BlockCraftingStorage extends AbstractCraftingUnitBlock<TileCraftingStorageTile>
{
public BlockCraftingStorage( final CraftingUnitType type )
{
super( type );
public BlockCraftingStorage(Properties props, CraftingUnitType type) {
super(props, type);
}
}
@@ -1,167 +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.crafting;
import java.util.EnumSet;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.BlockStateContainer;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.BooleanProperty;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.state.IProperty;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.Direction;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
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;
public class BlockCraftingUnit extends AEBaseTileBlock
{
public static final BooleanProperty FORMED = BooleanProperty.create( "formed" );
public static final BooleanProperty POWERED = BooleanProperty.create( "powered" );
public static final UnlistedProperty<CraftingCubeState> STATE = new UnlistedProperty<>( "state", CraftingCubeState.class );
public final CraftingUnitType type;
public BlockCraftingUnit( final CraftingUnitType type )
{
super( Material.IRON );
this.type = type;
}
@Override
protected IProperty[] getAEStates()
{
return new IProperty[] { POWERED, FORMED };
}
@Override
public IExtendedBlockState getExtendedState( BlockState state, IBlockReader world, BlockPos pos )
{
EnumSet<Direction> connections = EnumSet.noneOf( Direction.class );
for( Direction facing : Direction.values() )
{
if( this.isConnected( world, pos, facing ) )
{
connections.add( facing );
}
}
IExtendedBlockState extState = (IExtendedBlockState) state;
return extState.with( STATE, new CraftingCubeState( connections ) );
}
private boolean isConnected( IBlockReader world, BlockPos pos, Direction 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
public BlockState getStateFromMeta( final int meta )
{
return this.getDefaultState().with( POWERED, ( meta & 1 ) == 1 ).with( FORMED, ( meta & 2 ) == 2 );
}
@Override
public int getMetaFromState( final BlockState state )
{
boolean p = state.getValue( POWERED );
boolean f = state.getValue( FORMED );
return ( p ? 1 : 0 ) | ( f ? 2 : 0 );
}
@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 BlockRenderLayer getBlockLayer()
{
return BlockRenderLayer.CUTOUT;
}
@Override
public void onReplaced(BlockState state, World w, BlockPos pos, BlockState newState, boolean isMoving)
{
final TileCraftingTile cp = this.getTileEntity( w, pos );
if( cp != null )
{
cp.breakCluster();
}
super.onReplaced( state, w, pos, newState, isMoving );
}
@Override
public boolean onBlockActivated( final World w, final BlockPos pos, final BlockState state, final PlayerEntity p, final Hand hand, final Direction side, final float hitX, final float hitY, final float hitZ )
{
final TileCraftingTile tg = this.getTileEntity( w, pos );
if( tg != null && !p.isCrouching() && tg.isFormed() && tg.isActive() )
{
if( Platform.isClient() )
{
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 );
}
public enum CraftingUnitType
{
UNIT, ACCELERATOR, STORAGE_1K, STORAGE_4K, STORAGE_16K, STORAGE_64K, MONITOR
}
}
@@ -19,93 +19,62 @@
package appeng.block.crafting;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.BooleanProperty;
import appeng.block.AEBaseTileBlock;
import appeng.tile.crafting.TileMolecularAssembler;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.Direction;
import net.minecraft.state.BooleanProperty;
import net.minecraft.state.StateContainer;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockReader;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import appeng.api.util.AEPartLocation;
import appeng.block.AEBaseTileBlock;
import appeng.core.sync.GuiBridge;
import appeng.tile.crafting.TileMolecularAssembler;
import appeng.util.Platform;
public class BlockMolecularAssembler extends AEBaseTileBlock
public class BlockMolecularAssembler extends AEBaseTileBlock<TileMolecularAssembler>
{
public static final BooleanProperty POWERED = BooleanProperty.create( "powered" );
public BlockMolecularAssembler()
public BlockMolecularAssembler(Block.Properties props)
{
super( Material.IRON );
this.setOpaque( false );
this.lightOpacity = 1;
super( props );
}
@Override
protected IProperty[] getAEStates()
{
return new IProperty[] { POWERED };
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
super.fillStateContainer(builder);
builder.add(POWERED);
}
@Override
public BlockState getActualState( BlockState state, IBlockReader worldIn, BlockPos pos )
{
boolean powered = false;
TileMolecularAssembler te = this.getTileEntity( worldIn, pos );
if( te != null )
{
powered = te.isPowered();
}
return super.getActualState( state, worldIn, pos ).with( POWERED, powered );
}
/**
* NOTE: This is only used to determine how to render an item being held in hand.
* For determining block rendering, the method below is used (canRenderInLayer).
*/
@OnlyIn( Dist.CLIENT )
@Override
public BlockRenderLayer getBlockLayer()
{
return BlockRenderLayer.CUTOUT;
}
@OnlyIn( Dist.CLIENT )
@Override
public boolean canRenderInLayer( BlockState state, BlockRenderLayer layer )
{
return layer == BlockRenderLayer.CUTOUT || layer == BlockRenderLayer.TRANSLUCENT;
}
// FIXME: This apparently was used to update block states purely client-side... this wont work anymore :|
// FIXME @Override
// FIXME public BlockState getActualState( BlockState state, IBlockReader worldIn, BlockPos pos )
// FIXME {
// FIXME boolean powered = false;
// FIXME TileMolecularAssembler te = this.getTileEntity( worldIn, pos );
// FIXME if( te != null )
// FIXME {
// FIXME powered = te.isPowered();
// FIXME }
// FIXME
// FIXME return super.getActualState( state, worldIn, pos ).with( POWERED, powered );
// FIXME }
@Override
public boolean isFullCube( BlockState state )
{
return false;
}
@Override
public boolean onBlockActivated( final World w, final BlockPos pos, final BlockState state, final PlayerEntity p, final Hand hand, final Direction side, final float hitX, final float hitY, final float hitZ )
{
public ActionResultType onBlockActivated(BlockState state, World w, BlockPos pos, PlayerEntity p, Hand hand, BlockRayTraceResult hit) {
final TileMolecularAssembler tg = this.getTileEntity( w, pos );
if( tg != null && !p.isCrouching() )
{
Platform.openGUI( p, tg, AEPartLocation.fromFacing( side ), GuiBridge.GUI_MAC );
return true;
if (!tg.isRemote()) {
// FIXME Platform.openGUI(p, tg, AEPartLocation.fromFacing(side), GuiBridge.GUI_MAC);
}
return ActionResultType.SUCCESS;
}
return super.onBlockActivated( w, pos, state, p, hand, side, hitX, hitY, hitZ );
return super.onBlockActivated(state, w, pos, p, hand, hit);
}
}
@@ -0,0 +1,32 @@
/*
* 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.crafting;
import appeng.tile.crafting.TileCraftingTile;
public class CraftingUnitBlock extends AbstractCraftingUnitBlock<TileCraftingTile>
{
public CraftingUnitBlock(Properties props, CraftingUnitType type) {
super(props, type);
}
}
@@ -19,6 +19,7 @@
package appeng.block.crafting;
import appeng.core.Api;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
@@ -30,9 +31,8 @@ import appeng.api.features.AEFeature;
public class ItemCraftingStorage extends AEBaseBlockItem
{
public ItemCraftingStorage( final Block id )
{
super( id );
public ItemCraftingStorage(Block id, Properties props) {
super(id, props);
}
@Override