@Override public boolean isItemValidForSlot(int slotID, ItemStack itemstack) { if (slotID == 1) { return RecipeHandler.getItemToGasOutput( itemstack, false, Recipe.CHEMICAL_DISSOLUTION_CHAMBER.get()) != null; } else if (slotID == 3) { return ChargeUtils.canBeDischarged(itemstack); } return false; }
@Override public void onUpdate() { if (!worldObj.isRemote) { if (cachedRecipe == null || worldObj.provider.getDimension() != cachedDimensionId) { cachedDimensionId = worldObj.provider.getDimension(); cachedRecipe = RecipeHandler.getDimensionGas(new IntegerInput(cachedDimensionId)); } if (cachedRecipe != null && gasRand.nextDouble() < 0.05 && cachedRecipe.getOutput().applyOutputs(collectedGas, false, 1)) { cachedRecipe.getOutput().applyOutputs(collectedGas, true, 1); } } }
public boolean canOperate() { if (inventory[1] == null) { return false; } GasStack stack = RecipeHandler.getItemToGasOutput( inventory[1], false, Recipe.CHEMICAL_DISSOLUTION_CHAMBER.get()); if (stack == null || (outputTank.getGas() != null && (outputTank.getGas().getGas() != stack.getGas() || outputTank.getNeeded() < stack.amount))) { return false; } return true; }
@EventHandler public void postInit(FMLPostInitializationEvent event) { if (FuelHandler.BCPresent() && BuildcraftFuelRegistry.fuel != null) { for (IFuel s : BuildcraftFuelRegistry.fuel.getFuels()) { if (!(s.getFluid() == null || GasRegistry.containsGas(s.getFluid().getName()))) { GasRegistry.register(new Gas(s.getFluid())); } } BuildcraftFuelRegistry.fuel.addFuel( FluidRegistry.getFluid("ethene"), (int) (240 * general.TO_TE), 40 * FluidContainerRegistry.BUCKET_VOLUME); } for (ItemStack ore : OreDictionary.getOres("dustGold")) { RecipeHandler.addMetallurgicInfuserRecipe( InfuseRegistry.get("CARBON"), 10, MekanismUtils.size(ore, 4), GeneratorsItems.Hohlraum.getEmptyItem()); } }
@Override public void onUpdate() { if (worldObj.isRemote) { Mekanism.proxy.registerSound(this); if (updateDelay > 0) { updateDelay--; if (updateDelay == 0 && clientActive != isActive) { isActive = clientActive; MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); } } } if (!worldObj.isRemote) { if (updateDelay > 0) { updateDelay--; if (updateDelay == 0 && clientActive != isActive) { Mekanism.packetHandler.sendToAll( new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList()))); } } ChargeUtils.discharge(3, this); if (inventory[0] != null && (injectTank.getGas() == null || injectTank.getStored() < injectTank.getMaxGas())) { injectTank.receive( GasTransmission.removeGas( inventory[0], GasRegistry.getGas("sulfuricAcid"), injectTank.getNeeded()), true); } if (inventory[2] != null && outputTank.getGas() != null) { outputTank.draw(GasTransmission.addGas(inventory[2], outputTank.getGas()), true); } boolean changed = false; if (canOperate() && getEnergy() >= MekanismUtils.getEnergyPerTick(this, ENERGY_USAGE) && injectTank.getStored() >= INJECT_USAGE && MekanismUtils.canFunction(this)) { setActive(true); setEnergy(getEnergy() - MekanismUtils.getEnergyPerTick(this, ENERGY_USAGE)); if (operatingTicks < MekanismUtils.getTicks(this, TICKS_REQUIRED)) { operatingTicks++; injectTank.draw(INJECT_USAGE, true); } else { GasStack stack = RecipeHandler.getItemToGasOutput( inventory[1], true, Recipe.CHEMICAL_DISSOLUTION_CHAMBER.get()); outputTank.receive(stack, true); injectTank.draw(INJECT_USAGE, true); operatingTicks = 0; if (inventory[1].stackSize <= 0) { inventory[1] = null; } markDirty(); } } else { if (prevEnergy >= getEnergy()) { changed = true; setActive(false); } } if (changed && !canOperate()) { operatingTicks = 0; } prevEnergy = getEnergy(); if (outputTank.getGas() != null) { GasStack toSend = new GasStack(outputTank.getGas().getGas(), Math.min(outputTank.getStored(), gasOutput)); TileEntity tileEntity = Coord4D.get(this).getFromSide(MekanismUtils.getRight(facing)).getTileEntity(worldObj); if (tileEntity instanceof IGasHandler) { if (((IGasHandler) tileEntity) .canReceiveGas( MekanismUtils.getRight(facing).getOpposite(), outputTank.getGas().getGas())) { outputTank.draw( ((IGasHandler) tileEntity) .receiveGas(MekanismUtils.getRight(facing).getOpposite(), toSend), true); } } } } }
@Method(modid = "IC2") public void hookIC2Recipes() { for (Map.Entry<IRecipeInput, RecipeOutput> entry : Recipes.macerator.getRecipes().entrySet()) { if (!entry.getKey().getInputs().isEmpty()) { List<String> names = MekanismUtils.getOreDictName(entry.getKey().getInputs().get(0)); for (String name : names) { boolean did = false; if (name.startsWith("ingot")) { RecipeHandler.addCrusherRecipe( entry.getKey().getInputs().get(0), entry.getValue().items.get(0)); did = true; } if (did) { break; } } } } try { Recipes.macerator.addRecipe( new RecipeInputOreDict("oreOsmium"), null, new ItemStack(MekanismItems.Dust, 2, Resource.OSMIUM.ordinal())); } catch (Exception e) { } try { Recipes.macerator.addRecipe( new RecipeInputOreDict("ingotOsmium"), null, new ItemStack(MekanismItems.Dust, 1, Resource.OSMIUM.ordinal())); Recipes.macerator.addRecipe( new RecipeInputOreDict("ingotRefinedObsidian"), null, new ItemStack(MekanismItems.OtherDust, 1, 5)); Recipes.macerator.addRecipe( new RecipeInputOreDict("ingotRefinedGlowstone"), null, new ItemStack(Items.glowstone_dust)); Recipes.macerator.addRecipe( new RecipeInputOreDict("ingotSteel"), null, new ItemStack(MekanismItems.OtherDust, 1, 1)); } catch (Exception e) { } try { for (Resource resource : Resource.values()) { Recipes.macerator.addRecipe( new RecipeInputOreDict("clump" + resource.getName()), null, new ItemStack(MekanismItems.DirtyDust, 1, resource.ordinal())); } } catch (Exception e) { } NBTTagCompound tag = new NBTTagCompound(); tag.setInteger("amplification", 50000); Recipes.matterAmplifier.addRecipe( new RecipeInputItemStack(new ItemStack(MekanismItems.EnrichedAlloy), 1), tag); }
@Override public ItemStack transferStackInSlot(EntityPlayer player, int slotID) { ItemStack stack = null; Slot currentSlot = (Slot) inventorySlots.get(slotID); if (currentSlot != null && currentSlot.getHasStack()) { ItemStack slotStack = currentSlot.getStack(); stack = slotStack.copy(); if (slotID == 2 || slotID == 4) { if (!mergeItemStack(slotStack, 5, inventorySlots.size(), true)) { return null; } } else if (ChargeUtils.canBeDischarged(slotStack)) { if (slotID != 1) { if (!mergeItemStack(slotStack, 1, 2, false)) { return null; } } else if (slotID == 1) { if (!mergeItemStack(slotStack, 5, inventorySlots.size(), true)) { return null; } } } else if (RecipeHandler.getChanceOutput(slotStack, false, tileEntity.getRecipes()) != null) { if (slotID != 0 && slotID != 1 && slotID != 2 && slotID != 3 && slotID != 4) { if (!mergeItemStack(slotStack, 0, 1, false)) { return null; } } else { if (!mergeItemStack(slotStack, 5, inventorySlots.size(), true)) { return null; } } } else if (slotStack.getItem() instanceof ItemMachineUpgrade) { if (slotID != 0 && slotID != 1 && slotID != 2 && slotID != 3) { if (!mergeItemStack(slotStack, 3, 4, false)) { return null; } } else { if (!mergeItemStack(slotStack, 5, inventorySlots.size(), true)) { return null; } } } else { if (slotID >= 5 && slotID <= 31) { if (!mergeItemStack(slotStack, 32, inventorySlots.size(), false)) { return null; } } else if (slotID > 31) { if (!mergeItemStack(slotStack, 5, 31, false)) { return null; } } else { if (!mergeItemStack(slotStack, 5, inventorySlots.size(), true)) { return null; } } } if (slotStack.stackSize == 0) { currentSlot.putStack((ItemStack) null); } else { currentSlot.onSlotChanged(); } if (slotStack.stackSize == stack.stackSize) { return null; } currentSlot.onPickupFromSlot(player, slotStack); } return stack; }