Alloy furnace - Basic hoppers
This commit is contained in:
parent
66e39a0e29
commit
99f1736614
2 changed files with 44 additions and 5 deletions
3
TODO.txt
3
TODO.txt
|
@ -41,11 +41,12 @@ materials.ores No Tin
|
|||
materials.ores No Zinc
|
||||
-------------------------------------------------------------------------------------------------------
|
||||
tech.base No Alloy furnace
|
||||
-> support hoppers
|
||||
-> comparator output
|
||||
-> search recipe
|
||||
-> crafting recipe
|
||||
-> I18n
|
||||
-> XP
|
||||
-> let output hoppers take empty buckets / invalid input
|
||||
-> code clean-up
|
||||
tech.base No Coke oven
|
||||
-------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -11,9 +11,14 @@ import net.minecraft.network.NetworkManager;
|
|||
import net.minecraft.network.play.server.SPacketUpdateTileEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityFurnace;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.util.Constants.NBT;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.wrapper.InvWrapper;
|
||||
|
||||
|
||||
|
||||
|
@ -33,6 +38,10 @@ public class TBAlloyFurnaceTileEntity
|
|||
private int burnCurrent;
|
||||
private int burnTotal;
|
||||
|
||||
private final IItemHandler inputHopper;
|
||||
private final IItemHandler fuelHopper;
|
||||
private final IItemHandler outputHopper;
|
||||
|
||||
|
||||
public TBAlloyFurnaceTileEntity( )
|
||||
{
|
||||
|
@ -40,6 +49,10 @@ public class TBAlloyFurnaceTileEntity
|
|||
this.fuel = new UInventoryGrid( "Fuel" , 2 , 2 );
|
||||
this.output = new UInventoryGrid( "Output" , 2 , 5 );
|
||||
this.recipe = MAlloyRecipe.REGISTRY.getRecipes( ).get( 0 );
|
||||
|
||||
this.inputHopper = new InvWrapper( this.input );
|
||||
this.fuelHopper = new InvWrapper( this.fuel );
|
||||
this.outputHopper = new InvWrapper( this.output );
|
||||
}
|
||||
|
||||
|
||||
|
@ -127,7 +140,7 @@ public class TBAlloyFurnaceTileEntity
|
|||
if ( this.burnCurrent == 0 ) {
|
||||
if ( this.alloying != null ) {
|
||||
if ( !this.startBurning( this.alloyCurrent ) ) {
|
||||
cancelAlloying( );
|
||||
this.cancelAlloying( );
|
||||
this.burnCurrent = this.burnTotal = 0;
|
||||
}
|
||||
} else {
|
||||
|
@ -152,6 +165,31 @@ public class TBAlloyFurnaceTileEntity
|
|||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean hasCapability( final Capability< ? > capability , final EnumFacing facing )
|
||||
{
|
||||
return capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY && facing != null
|
||||
|| super.hasCapability( capability , facing );
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings( "unchecked" )
|
||||
@Override
|
||||
public < T > T getCapability( final Capability< T > capability , final EnumFacing facing )
|
||||
{
|
||||
if ( facing != null && capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY ) {
|
||||
if ( facing == EnumFacing.DOWN ) {
|
||||
return (T) this.outputHopper;
|
||||
} else if ( facing == EnumFacing.UP ) {
|
||||
return (T) this.inputHopper;
|
||||
} else {
|
||||
return (T) this.fuelHopper;
|
||||
}
|
||||
}
|
||||
return super.getCapability( capability , facing );
|
||||
}
|
||||
|
||||
|
||||
public void cancelAlloying( )
|
||||
{
|
||||
if ( this.alloying != null ) {
|
||||
|
@ -188,7 +226,7 @@ public class TBAlloyFurnaceTileEntity
|
|||
}
|
||||
|
||||
|
||||
public int getBurnProgress( int max )
|
||||
public int getBurnProgress( final int max )
|
||||
{
|
||||
int t = this.burnTotal;
|
||||
if ( t == 0 ) {
|
||||
|
@ -286,7 +324,7 @@ public class TBAlloyFurnaceTileEntity
|
|||
}
|
||||
|
||||
|
||||
public int getAlloyingProgress( int max )
|
||||
public int getAlloyingProgress( final int max )
|
||||
{
|
||||
if ( this.alloying == null ) {
|
||||
return max;
|
||||
|
@ -337,7 +375,7 @@ public class TBAlloyFurnaceTileEntity
|
|||
}
|
||||
|
||||
|
||||
private void addOutput( ItemStack wanted )
|
||||
private void addOutput( final ItemStack wanted )
|
||||
{
|
||||
final int maxStackSize = Math.min( this.output.getInventoryStackLimit( ) , wanted.getMaxStackSize( ) );
|
||||
int added = 0;
|
||||
|
|
Reference in a new issue