Alloy furnace - Shift-clicking

This commit is contained in:
Emmanuel BENOîT 2016-06-24 09:15:36 +02:00
parent 5b0232ff7f
commit 66e39a0e29
3 changed files with 64 additions and 1 deletions

View file

@ -41,11 +41,11 @@ materials.ores No Tin
materials.ores No Zinc materials.ores No Zinc
------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------
tech.base No Alloy furnace tech.base No Alloy furnace
-> fix shift+click crash
-> support hoppers -> support hoppers
-> comparator output -> comparator output
-> search recipe -> search recipe
-> I18n -> I18n
-> XP
-> code clean-up -> code clean-up
tech.base No Coke oven tech.base No Coke oven
------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------

View file

@ -293,4 +293,15 @@ public class MAlloyRecipe
return sum; return sum;
} }
public boolean hasInput( ItemStack stack )
{
for ( int i = 0 ; i < this.inputs.length ; i++ ) {
if ( this.inputs[ i ].isItemEqual( stack ) ) {
return true;
}
}
return false;
}
} }

View file

@ -13,6 +13,8 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container; import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot; import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntityFurnace;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -81,6 +83,56 @@ public class TBAlloyFurnaceContainer
} }
@Override
public ItemStack transferStackInSlot( final EntityPlayer playerIn , final int index )
{
final Slot slot = this.inventorySlots.get( index );
if ( slot == null || !slot.getHasStack( ) ) {
return null;
}
final ItemStack slotStack = slot.getStack( );
final ItemStack slotStackCopy = slotStack.copy( );
if ( slot.inventory == playerIn.inventory ) {
boolean checkInput;
if ( TileEntityFurnace.isItemFuel( slotStack ) ) {
checkInput = !this.mergeItemStack( slotStackCopy , 51 , 55 , false );
} else {
checkInput = true;
}
if ( checkInput ) {
if ( this.tileEntity.recipe.hasInput( slotStack ) ) {
if ( !this.mergeItemStack( slotStackCopy , 36 , 51 , false ) ) {
return null;
}
} else {
return null;
}
}
} else {
if ( !this.mergeItemStack( slotStackCopy , 0 , 36 , false ) ) {
return null;
}
if ( slot.inventory == this.output ) {
slot.onSlotChange( slotStackCopy , slotStack );
}
}
if ( slotStackCopy.stackSize == 0 ) {
slot.putStack( null );
} else {
slot.onSlotChanged( );
}
if ( slotStackCopy.stackSize == slotStack.stackSize ) {
return null;
}
slot.onPickupFromSlot( playerIn , slotStackCopy );
return slotStack;
}
public void setCurrentRecipe( final ResourceLocation name , final boolean confirm ) public void setCurrentRecipe( final ResourceLocation name , final boolean confirm )
{ {
final MAlloyRecipe recipe = MAlloyRecipe.REGISTRY.getRecipe( name ); final MAlloyRecipe recipe = MAlloyRecipe.REGISTRY.getRecipe( name );