Alloy furnace - Can be disabled with a redstone signal
This commit is contained in:
parent
8001cb13a2
commit
d322be6c07
3 changed files with 31 additions and 14 deletions
1
TODO.txt
1
TODO.txt
|
@ -44,7 +44,6 @@ materials.ores No Tin
|
||||||
materials.ores No Zinc
|
materials.ores No Zinc
|
||||||
-------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------
|
||||||
tech.base No Alloy furnace
|
tech.base No Alloy furnace
|
||||||
-> redstone activation
|
|
||||||
-> make redstone activation configurable
|
-> make redstone activation configurable
|
||||||
-> make output hopper configurable
|
-> make output hopper configurable
|
||||||
-> comparator signal configuration
|
-> comparator signal configuration
|
||||||
|
|
|
@ -118,17 +118,17 @@ public class TBAlloyFurnaceBlock
|
||||||
final TileEntity tileentity = world.getTileEntity( pos );
|
final TileEntity tileentity = world.getTileEntity( pos );
|
||||||
|
|
||||||
TBAlloyFurnaceBlock.keepInventory = true;
|
TBAlloyFurnaceBlock.keepInventory = true;
|
||||||
|
IBlockState nState;
|
||||||
|
Block nBlock;
|
||||||
if ( burning ) {
|
if ( burning ) {
|
||||||
world.setBlockState( pos , TechBase.ALLOY_FURNACE_BLOCK_ACTIVE.getDefaultState( ).withProperty(
|
nBlock = TechBase.ALLOY_FURNACE_BLOCK_ACTIVE;
|
||||||
TBAlloyFurnaceBlock.FACING , iblockstate.getValue( TBAlloyFurnaceBlock.FACING ) ) , 3 );
|
|
||||||
world.setBlockState( pos , TechBase.ALLOY_FURNACE_BLOCK_ACTIVE.getDefaultState( ).withProperty(
|
|
||||||
TBAlloyFurnaceBlock.FACING , iblockstate.getValue( TBAlloyFurnaceBlock.FACING ) ) , 3 );
|
|
||||||
} else {
|
} else {
|
||||||
world.setBlockState( pos , TechBase.ALLOY_FURNACE_BLOCK_INACTIVE.getDefaultState( ).withProperty(
|
nBlock = TechBase.ALLOY_FURNACE_BLOCK_INACTIVE;
|
||||||
TBAlloyFurnaceBlock.FACING , iblockstate.getValue( TBAlloyFurnaceBlock.FACING ) ) , 3 );
|
|
||||||
world.setBlockState( pos , TechBase.ALLOY_FURNACE_BLOCK_INACTIVE.getDefaultState( ).withProperty(
|
|
||||||
TBAlloyFurnaceBlock.FACING , iblockstate.getValue( TBAlloyFurnaceBlock.FACING ) ) , 3 );
|
|
||||||
}
|
}
|
||||||
|
nState = nBlock.getDefaultState( ) //
|
||||||
|
.withProperty( TBAlloyFurnaceBlock.FACING , iblockstate.getValue( TBAlloyFurnaceBlock.FACING ) ) //
|
||||||
|
.withProperty( TBAlloyFurnaceBlock.POWERED , iblockstate.getValue( TBAlloyFurnaceBlock.POWERED ) );
|
||||||
|
world.setBlockState( pos , nState , 3 );
|
||||||
TBAlloyFurnaceBlock.keepInventory = false;
|
TBAlloyFurnaceBlock.keepInventory = false;
|
||||||
|
|
||||||
if ( tileentity != null ) {
|
if ( tileentity != null ) {
|
||||||
|
@ -419,10 +419,13 @@ public class TBAlloyFurnaceBlock
|
||||||
{
|
{
|
||||||
final boolean powered = worldIn.isBlockPowered( pos );
|
final boolean powered = worldIn.isBlockPowered( pos );
|
||||||
if ( powered != state.getValue( TBAlloyFurnaceBlock.POWERED ).booleanValue( ) ) {
|
if ( powered != state.getValue( TBAlloyFurnaceBlock.POWERED ).booleanValue( ) ) {
|
||||||
worldIn.setBlockState( pos ,
|
worldIn.setBlockState( pos , state.withProperty( TBAlloyFurnaceBlock.POWERED , powered ) , 4 );
|
||||||
state.withProperty( TBAlloyFurnaceBlock.POWERED , Boolean.valueOf( powered ) ) , 4 );
|
|
||||||
System.err.println( pos + " POWERED? " + ( powered ? "yes" : "no" ) );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static boolean isPowered( int meta )
|
||||||
|
{
|
||||||
|
return ( meta & 8 ) == 8;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,8 @@ import net.minecraft.tileentity.TileEntityFurnace;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraft.util.ITickable;
|
import net.minecraft.util.ITickable;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.capabilities.Capability;
|
import net.minecraftforge.common.capabilities.Capability;
|
||||||
import net.minecraftforge.common.util.Constants.NBT;
|
import net.minecraftforge.common.util.Constants.NBT;
|
||||||
import net.minecraftforge.items.CapabilityItemHandler;
|
import net.minecraftforge.items.CapabilityItemHandler;
|
||||||
|
@ -56,6 +58,13 @@ public class TBAlloyFurnaceTileEntity
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean shouldRefresh( World world , BlockPos pos , IBlockState oldState , IBlockState newSate )
|
||||||
|
{
|
||||||
|
return ! ( newSate.getBlock( ) instanceof TBAlloyFurnaceBlock );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readFromNBT( final NBTTagCompound compound )
|
public void readFromNBT( final NBTTagCompound compound )
|
||||||
{
|
{
|
||||||
|
@ -135,7 +144,7 @@ public class TBAlloyFurnaceTileEntity
|
||||||
|
|
||||||
if ( this.burnCurrent == 0 ) {
|
if ( this.burnCurrent == 0 ) {
|
||||||
if ( this.alloying != null ) {
|
if ( this.alloying != null ) {
|
||||||
if ( !this.startBurning( this.alloyCurrent ) ) {
|
if ( ! ( this.isEnabled( ) && this.startBurning( this.alloyCurrent ) ) ) {
|
||||||
this.cancelAlloying( );
|
this.cancelAlloying( );
|
||||||
this.burnCurrent = this.burnTotal = 0;
|
this.burnCurrent = this.burnTotal = 0;
|
||||||
}
|
}
|
||||||
|
@ -146,7 +155,7 @@ public class TBAlloyFurnaceTileEntity
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !this.isAlloying( ) && this.canAlloy( )
|
if ( this.isEnabled( ) && !this.isAlloying( ) && this.canAlloy( )
|
||||||
&& ( this.isBurning( ) || this.startBurning( this.recipe.burnTime ) ) ) {
|
&& ( this.isBurning( ) || this.startBurning( this.recipe.burnTime ) ) ) {
|
||||||
this.startAlloying( );
|
this.startAlloying( );
|
||||||
dirty = true;
|
dirty = true;
|
||||||
|
@ -164,6 +173,12 @@ public class TBAlloyFurnaceTileEntity
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public boolean isEnabled( )
|
||||||
|
{
|
||||||
|
return !TBAlloyFurnaceBlock.isPowered( this.getBlockMetadata( ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasCapability( final Capability< ? > capability , final EnumFacing facing )
|
public boolean hasCapability( final Capability< ? > capability , final EnumFacing facing )
|
||||||
{
|
{
|
||||||
|
|
Reference in a new issue