use of net.mcft.copy.betterstorage.api.crafting.CraftingSourceTileEntity in project BetterStorage by copygirl.
the class InventoryCraftingStation method craft.
/** Called when an item is removed from the output slot while it doesn't
* store any real items. Returns if the recipe can be crafted again.*/
private boolean craft(EntityPlayer player, boolean simulate) {
ItemStack[] contents = (simulate ? this.contents.clone() : this.contents);
ItemStack[] crafting = (simulate ? this.crafting.clone() : this.crafting);
if (simulate)
for (int i = 0; i < crafting.length; i++) crafting[i] = ItemStack.copyItemStack(crafting[i]);
if (currentCrafting instanceof VanillaStationCrafting) {
boolean unset = false;
if (player == null) {
player = FakePlayer.get(entity);
unset = true;
}
ItemStack craftOutput = (simulate ? output[4].copy() : output[4]);
IInventory craftMatrix = new InventoryStacks(crafting);
FMLCommonHandler.instance().firePlayerCraftingEvent(player, craftOutput, craftMatrix);
new CustomSlotCrafting(player, craftOutput);
if (unset) {
FakePlayer.unset();
player = null;
}
}
ICraftingSource source = new CraftingSourceTileEntity(entity, player);
currentCrafting.craft(source);
IRecipeInput[] requiredInput = currentCrafting.getCraftRequirements();
for (int i = 0; i < crafting.length; i++) if (crafting[i] != null)
crafting[i] = craftSlot(crafting[i], requiredInput[i], player, simulate);
boolean pulled = pullRequired(contents, crafting, requiredInput);
if (!simulate) {
int requiredExperience = currentCrafting.getRequiredExperience();
if ((requiredExperience != 0) && (player != null) && !player.capabilities.isCreativeMode)
player.experienceLevel -= requiredExperience;
outputIsReal = !outputEmpty();
progress = 0;
inputChanged();
checkHasRequirements = true;
}
return pulled;
}
Aggregations