First pass of implementing rendering for crafting cubes (#7)
This commit is contained in:
@@ -21,23 +21,64 @@ package appeng.block.crafting;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
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.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
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.AEColor;
|
||||
import appeng.client.UnlistedProperty;
|
||||
import appeng.tile.crafting.TileCraftingMonitorTile;
|
||||
|
||||
|
||||
public class BlockCraftingMonitor extends BlockCraftingUnit
|
||||
{
|
||||
|
||||
public static final UnlistedProperty<AEColor> COLOR = new UnlistedProperty<>( "color", AEColor.class );
|
||||
|
||||
public static final UnlistedProperty<EnumFacing> FORWARD = new UnlistedProperty<>( "forward", EnumFacing.class );
|
||||
|
||||
public BlockCraftingMonitor()
|
||||
{
|
||||
super( CraftingUnitType.MONITOR );
|
||||
this.setTileEntity( TileCraftingMonitorTile.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockStateContainer createBlockState()
|
||||
{
|
||||
return new ExtendedBlockState( this, getAEStates(), new IUnlistedProperty[] {
|
||||
STATE,
|
||||
COLOR,
|
||||
FORWARD
|
||||
} );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IExtendedBlockState getExtendedState( IBlockState state, IBlockAccess world, BlockPos pos )
|
||||
{
|
||||
AEColor color = AEColor.Transparent;
|
||||
EnumFacing forward = EnumFacing.NORTH;
|
||||
|
||||
TileCraftingMonitorTile te = getTileEntity( world, pos );
|
||||
if( te != null )
|
||||
{
|
||||
color = te.getColor();
|
||||
forward = te.getForward();
|
||||
}
|
||||
|
||||
return super.getExtendedState( state, world, pos ).withProperty( COLOR, color ).withProperty( FORWARD, forward );
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void getCheckedSubBlocks( final Item item, final CreativeTabs tabs, final List<ItemStack> itemStacks )
|
||||
|
||||
@@ -19,12 +19,14 @@
|
||||
package appeng.block.crafting;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
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.BlockStateContainer;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -32,10 +34,16 @@ import net.minecraft.util.BlockRenderLayer;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
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;
|
||||
@@ -43,8 +51,9 @@ import appeng.util.Platform;
|
||||
|
||||
public class BlockCraftingUnit extends AEBaseTileBlock
|
||||
{
|
||||
public static final PropertyBool POWERED = PropertyBool.create( "powered" );
|
||||
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;
|
||||
|
||||
@@ -61,7 +70,38 @@ public class BlockCraftingUnit extends AEBaseTileBlock
|
||||
{
|
||||
return new IProperty[] { POWERED, FORMED };
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IExtendedBlockState getExtendedState( IBlockState state, IBlockAccess world, BlockPos pos )
|
||||
{
|
||||
|
||||
EnumSet<EnumFacing> connections = EnumSet.noneOf( EnumFacing.class );
|
||||
|
||||
for( EnumFacing facing : EnumFacing.values() )
|
||||
{
|
||||
if( isConnected( world, pos, facing ) )
|
||||
{
|
||||
connections.add( facing );
|
||||
}
|
||||
}
|
||||
|
||||
IExtendedBlockState extState = (IExtendedBlockState) state;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockStateContainer createBlockState()
|
||||
{
|
||||
return new ExtendedBlockState( this, getAEStates(), new IUnlistedProperty[] { STATE } );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getStateFromMeta( final int meta )
|
||||
{
|
||||
@@ -71,8 +111,8 @@ public class BlockCraftingUnit extends AEBaseTileBlock
|
||||
@Override
|
||||
public int getMetaFromState( final IBlockState state )
|
||||
{
|
||||
final boolean p = (boolean) state.getValue( POWERED );
|
||||
final boolean f = (boolean) state.getValue( FORMED );
|
||||
boolean p = state.getValue( POWERED );
|
||||
boolean f = state.getValue( FORMED );
|
||||
return ( p ? 1 : 0 ) | ( f ? 2 : 0 );
|
||||
}
|
||||
|
||||
|
||||
@@ -61,6 +61,7 @@ import appeng.api.parts.PartItemStack;
|
||||
import appeng.api.parts.SelectedPart;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.client.UnlistedProperty;
|
||||
import appeng.client.render.cablebus.CableBusBakedModel;
|
||||
import appeng.client.render.cablebus.CableBusRenderState;
|
||||
import appeng.core.AEConfig;
|
||||
@@ -81,7 +82,8 @@ import appeng.util.Platform;
|
||||
public class BlockCableBus extends AEBaseTileBlock
|
||||
{
|
||||
|
||||
public static final CableBusRenderStateProperty RENDER_STATE_PROPERTY = new CableBusRenderStateProperty();
|
||||
public static final UnlistedProperty<CableBusRenderState> RENDER_STATE_PROPERTY =
|
||||
new UnlistedProperty<>( "cable_bus_render_state", CableBusRenderState.class );
|
||||
|
||||
private static final ICableBusContainer NULL_CABLE_BUS = new NullCableBusContainer();
|
||||
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
package appeng.block.networking;
|
||||
|
||||
import net.minecraftforge.common.property.IUnlistedProperty;
|
||||
|
||||
import appeng.parts.CableBusContainer;
|
||||
|
||||
public class CableBusContainerUnlistedProperty implements IUnlistedProperty<CableBusContainer>
|
||||
{
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return "bus";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid( CableBusContainer value )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<CableBusContainer> getType()
|
||||
{
|
||||
return CableBusContainer.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String valueToString( CableBusContainer value )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
package appeng.block.networking;
|
||||
|
||||
|
||||
import net.minecraftforge.common.property.IUnlistedProperty;
|
||||
|
||||
import appeng.client.render.cablebus.CableBusRenderState;
|
||||
|
||||
|
||||
/**
|
||||
* An unlisted property for the cable bus block's render state.
|
||||
*/
|
||||
public class CableBusRenderStateProperty implements IUnlistedProperty<CableBusRenderState>
|
||||
{
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return "cable_bus_render_state";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid( CableBusRenderState value )
|
||||
{
|
||||
return value != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<CableBusRenderState> getType()
|
||||
{
|
||||
return CableBusRenderState.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String valueToString( CableBusRenderState value )
|
||||
{
|
||||
return value.toString();
|
||||
}
|
||||
}
|
||||
@@ -38,6 +38,7 @@ import net.minecraftforge.common.property.IUnlistedProperty;
|
||||
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.client.UnlistedProperty;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.tile.storage.TileDrive;
|
||||
import appeng.util.Platform;
|
||||
@@ -46,7 +47,7 @@ import appeng.util.Platform;
|
||||
public class BlockDrive extends AEBaseTileBlock
|
||||
{
|
||||
|
||||
public static final DriveSlotsStateProperty SLOTS_STATE = new DriveSlotsStateProperty();
|
||||
public static final UnlistedProperty<DriveSlotsState> SLOTS_STATE = new UnlistedProperty<>("drive_slots_state", DriveSlotsState.class);
|
||||
|
||||
public BlockDrive()
|
||||
{
|
||||
|
||||
@@ -1,50 +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.storage;
|
||||
|
||||
|
||||
import net.minecraftforge.common.property.IUnlistedProperty;
|
||||
|
||||
|
||||
public class DriveSlotsStateProperty implements IUnlistedProperty<DriveSlotsState>
|
||||
{
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return "drive_slots_state";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid( DriveSlotsState value )
|
||||
{
|
||||
return value != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<DriveSlotsState> getType()
|
||||
{
|
||||
return DriveSlotsState.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String valueToString( DriveSlotsState value )
|
||||
{
|
||||
return value.toString();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user