Merge branch 'dev' of github.com:ForestryMC/ForestryMC into inventory-cleanup

Conflicts:
	src/main/java/forestry/apiculture/gadgets/TileAlvearyHygroregulator.java
	src/main/java/forestry/apiculture/gadgets/TileAlvearySwarmer.java
	src/main/java/forestry/core/gui/ContainerForestry.java
	src/main/java/forestry/energy/gadgets/EngineBronze.java
	src/main/java/forestry/energy/gadgets/MachineGenerator.java
	src/main/java/forestry/factory/gadgets/MachineBottler.java
	src/main/java/forestry/factory/gadgets/MachineCarpenter.java
	src/main/java/forestry/factory/gadgets/MachineFabricator.java
	src/main/java/forestry/factory/gadgets/MachineFermenter.java
	src/main/java/forestry/factory/gadgets/MachineMoistener.java
	src/main/java/forestry/factory/gadgets/MachineRaintank.java
	src/main/java/forestry/factory/gadgets/MachineStill.java
	src/main/java/forestry/factory/gadgets/TileWorktable.java
	src/main/java/forestry/farming/gadgets/TileFarmPlain.java
	src/main/java/forestry/farming/gui/ContainerFarm.java
This commit is contained in:
CovertJaguar committed 2014-12-13 16:39:40 -08:00
commit 3326f4db03
71 files changed
+1449 -1557

No files matched your search

@@ -61,26 +61,46 @@ public class CommandBeekeepingGiveBee extends SubCommand {
@Override
public void processSubCommand(ICommandSender sender, String[] arguments) {
if (arguments.length < 3) {
if (arguments.length < 2) {
printHelp(sender);
return;
}
EnumBeeType beeType = getBeeType(arguments[0]);
IBeeGenome beeGenome = getBeeGenome(arguments[0]);
EnumBeeType beeType = getBeeType(arguments[1]);
if (beeType == EnumBeeType.NONE) {
printHelp(sender);
return;
}
EntityPlayer player = CommandHelpers.getPlayer(sender, arguments[1]);
EntityPlayer player;
if (arguments.length == 3) {
player = CommandHelpers.getPlayer(sender, arguments[2]);
} else {
player = CommandHelpers.getPlayer(sender, sender.getCommandSenderName());
}
if (player == null) {
printHelp(sender);
return;
}
String parameter = arguments[2];
IBee bee = PluginApiculture.beeInterface.getBee(player.worldObj, beeGenome);
if(beeType == EnumBeeType.QUEEN)
bee.mate(bee);
ItemStack beeStack = PluginApiculture.beeInterface.getMemberStack(bee, beeType.ordinal());
player.dropPlayerItemWithRandomChoice(beeStack, true);
CommandHelpers.sendLocalizedChatMessage(sender, "for.chat.command.forestry.beekeeping.give.given", player.getCommandSenderName(), bee.getGenome().getPrimary().getName(), beeType.getName());
}
private static IBeeGenome getBeeGenome(String speciesName) {
IAlleleBeeSpecies species = null;
for (String uid : AlleleManager.alleleRegistry.getRegisteredAlleles().keySet()) {
if (!uid.equals(parameter))
if (!uid.equals(speciesName))
continue;
if (AlleleManager.alleleRegistry.getAllele(uid) instanceof IAlleleBeeSpecies) {
@@ -91,7 +111,7 @@ public class CommandBeekeepingGiveBee extends SubCommand {
if (species == null) {
for (IAllele allele : AlleleManager.alleleRegistry.getRegisteredAlleles().values()) {
if (allele instanceof IAlleleBeeSpecies && allele.getName().equals(parameter)) {
if (allele instanceof IAlleleBeeSpecies && allele.getName().equals(speciesName)) {
species = (IAlleleBeeSpecies) allele;
break;
}
@@ -99,36 +119,26 @@ public class CommandBeekeepingGiveBee extends SubCommand {
}
if (species == null)
throw new SpeciesNotFoundException(parameter);
throw new SpeciesNotFoundException(speciesName);
IAllele[] template = PluginApiculture.beeInterface.getTemplate(species.getUID());
if (template == null)
throw new TemplateNotFoundException(species);
IBeeGenome genome = PluginApiculture.beeInterface.templateAsGenome(template);
IBee bee = PluginApiculture.beeInterface.getBee(player.worldObj, genome);
if(beeType == EnumBeeType.QUEEN)
bee.mate(bee);
ItemStack beeStack = PluginApiculture.beeInterface.getMemberStack(bee, beeType.ordinal());
player.dropPlayerItemWithRandomChoice(beeStack, true);
CommandHelpers.sendLocalizedChatMessage(sender, "for.chat.command.forestry.beekeeping.give.given", player.getCommandSenderName(), template[0].getName(), beeType.getName());
return PluginApiculture.beeInterface.templateAsGenome(template);
}
@Override
public List<String> addTabCompletionOptions(ICommandSender sender, String[] parameters) {
if (parameters.length == 1) {
List<String> tabCompletion = CommandHelpers.getListOfStringsMatchingLastWord(parameters, beeTypeArr);
List<String> tabCompletion = CommandHelpers.getListOfStringsMatchingLastWord(parameters, getSpecies());
tabCompletion.add("help");
return tabCompletion;
} else if (parameters.length == 2) {
return CommandHelpers.getListOfStringsMatchingLastWord(parameters, CommandHelpers.getPlayers());
return CommandHelpers.getListOfStringsMatchingLastWord(parameters, beeTypeArr);
} else if (parameters.length == 3) {
return CommandHelpers.getListOfStringsMatchingLastWord(parameters, getSpecies());
return CommandHelpers.getListOfStringsMatchingLastWord(parameters, CommandHelpers.getPlayers());
}
return null;
}
@@ -12,7 +12,6 @@ package forestry.apiculture.gadgets;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.IHiveDrop;
import forestry.api.apiculture.hives.HiveManager;
import forestry.api.core.Tabs;
@@ -123,9 +122,6 @@ public class BlockBeehives extends BlockContainer {
}
private List<IHiveDrop> getDropsForHive(int meta) {
if (meta == 8) //TODO: make a real hive for swarm
return BeeManager.hiveDrops[meta];
String hiveName = getHiveNameForMeta(meta);
if (hiveName == null)
return Collections.emptyList();
@@ -177,7 +173,7 @@ public class BlockBeehives extends BlockContainer {
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int i, int j) {
if (j == 0 || j >= 8)
if (j == 0 || j > 8)
return null;
if (i == 0 || i == 1) {
@@ -27,6 +27,8 @@ import net.minecraftforge.fluids.FluidTankInfo;
import forestry.api.apiculture.IAlvearyComponent;
import forestry.api.core.ForestryAPI;
import forestry.core.config.Defaults;
import forestry.core.fluids.FluidHelper;
import forestry.core.fluids.Fluids;
import forestry.core.fluids.TankManager;
import forestry.core.fluids.tanks.FilteredTank;
import forestry.core.interfaces.ILiquidTankContainer;
@@ -72,9 +74,9 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory
setInternalInventory(new TileInventoryAdapter(this, 1, "CanInv"));
Fluid water = LiquidHelper.getFluid(Defaults.LIQUID_WATER);
Fluid lava = LiquidHelper.getFluid(Defaults.LIQUID_LAVA);
Fluid liquidIce = LiquidHelper.getFluid(Defaults.LIQUID_ICE);
Fluid water = Fluids.WATER.get();
Fluid lava = Fluids.LAVA.get();
Fluid liquidIce = Fluids.ICE.get();
liquidTank = new FilteredTank(Defaults.PROCESSOR_TANK_CAPACITY, water, lava, liquidIce);
tankManager = new TankManager(liquidTank);
@@ -139,14 +141,7 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory
// Check if we have suitable items waiting in the item slot
if (canInventory.getStackInSlot(0) != null) {
FluidContainerData container = LiquidHelper.getLiquidContainer(canInventory.getStackInSlot(0));
if (container != null
&& (container.fluid.getFluid() == FluidRegistry.WATER || container.fluid.getFluid() == FluidRegistry.LAVA)) {
canInventory.setInventorySlotContents(0, StackUtils.replenishByContainer(this, canInventory.getStackInSlot(0), container, liquidTank));
if (canInventory.getStackInSlot(0).stackSize <= 0)
canInventory.setInventorySlotContents(0, null);
}
FluidHelper.drainContainers(tankManager, canInventory, 0);
}
}
@@ -270,7 +265,7 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory
return false;
if (slotIndex == 0) {
FluidStack fluid = LiquidHelper.getFluidStackInContainer(itemstack);
FluidStack fluid = FluidHelper.getFluidStackInContainer(itemstack);
if (fluid == null || fluid.amount <= 0)
return false;
return liquidTank.accepts(fluid.getFluid());
@@ -10,35 +10,33 @@
******************************************************************************/
package forestry.apiculture.gadgets;
import java.util.Map.Entry;
import java.util.Stack;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.EnumBeeType;
import forestry.api.apiculture.IAlvearyComponent;
import forestry.api.apiculture.IBee;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.core.ForestryAPI;
import forestry.apiculture.worldgen.WorldGenHive;
import forestry.apiculture.worldgen.WorldGenHiveSwamer;
import forestry.apiculture.worldgen.HiveDecorator;
import forestry.apiculture.worldgen.HiveSwarmer;
import forestry.core.config.Defaults;
import forestry.core.config.ForestryItem;
import forestry.core.inventory.TileInventoryAdapter;
import forestry.core.inventory.wrappers.IInvSlot;
import forestry.core.inventory.wrappers.InventoryIterator;
import forestry.core.network.GuiId;
import forestry.core.network.PacketPayload;
import forestry.core.proxy.Proxies;
import forestry.core.utils.StackUtils;
import forestry.core.inventory.TileInventoryAdapter;
import forestry.core.utils.Utils;
import forestry.plugins.PluginApiculture;
import java.util.Map.Entry;
import java.util.Stack;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
public class TileAlvearySwarmer extends TileAlveary implements ISidedInventory {
@@ -46,6 +44,7 @@ public class TileAlvearySwarmer extends TileAlveary implements ISidedInventory {
public static final int BLOCK_META = 2;
private final Stack<ItemStack> pendingSpawns = new Stack<ItemStack>();
private boolean isActive;
public TileAlvearySwarmer() {
super(BLOCK_META);
@@ -68,87 +67,101 @@ public class TileAlvearySwarmer extends TileAlveary implements ISidedInventory {
protected void updateServerSide() {
super.updateServerSide();
if (worldObj.getTotalWorldTime() % 100 != 0)
if (pendingSpawns.size() > 0)
if (pendingSpawns.size() > 0) {
setIsActive(true);
if (worldObj.getTotalWorldTime() % 1000 == 0)
trySpawnSwarm();
} else
setIsActive(false);
if (worldObj.getTotalWorldTime() % 500 != 0)
return;
if (!this.hasMaster())
ItemStack princessStack = getPrincessStack();
if (princessStack == null)
return;
IAlvearyComponent master = (IAlvearyComponent) this.getCentralTE();
if (!(master instanceof IBeeHousing))
int chance = consumeInducerAndGetChance();
if (chance == 0)
return;
IBeeHousing housing = (IBeeHousing) master;
ItemStack queenstack = housing.getQueen();
if (queenstack == null)
return;
if (!PluginApiculture.beeInterface.isMated(queenstack))
return;
// Calculate chance
int slot = getInducerSlot();
if (slot < 0)
return;
int chance = getChanceFor(getInternalInventory().getStackInSlot(slot));
// Remove resource
getInternalInventory().decrStackSize(slot, 1);
// Try to spawn princess
if (worldObj.rand.nextInt(1000) >= chance)
return;
// Queue swarm spawn
IBee spawn = PluginApiculture.beeInterface.getMember(queenstack);
spawn.setIsNatural(false);
pendingSpawns.push(PluginApiculture.beeInterface.getMemberStack(spawn, EnumBeeType.PRINCESS.ordinal()));
IBee princess = PluginApiculture.beeInterface.getMember(princessStack);
princess.setIsNatural(false);
pendingSpawns.push(PluginApiculture.beeInterface.getMemberStack(princess, EnumBeeType.PRINCESS.ordinal()));
}
private int getChanceFor(ItemStack stack) {
for (Entry<ItemStack, Integer> entry : BeeManager.inducers.entrySet()) {
if (entry.getKey().isItemEqual(stack))
return entry.getValue();
private ItemStack getPrincessStack() {
if (!this.hasMaster())
return null;
IAlvearyComponent master = (IAlvearyComponent) this.getCentralTE();
if (!(master instanceof IBeeHousing))
return null;
IBeeHousing housing = (IBeeHousing) master;
ItemStack princessStack = housing.getQueen();
if (princessStack == null || !PluginApiculture.beeInterface.isMated(princessStack))
return null;
return princessStack;
}
private int consumeInducerAndGetChance() {
if (getInternalInventory() == null)
return 0;
for (IInvSlot slot : InventoryIterator.getIterable(getInternalInventory())) {
ItemStack stack = slot.getStackInSlot();
for (Entry<ItemStack, Integer> entry : BeeManager.inducers.entrySet()) {
if (StackUtils.isIdenticalItem(entry.getKey(), stack)) {
slot.decreaseStackInSlot();
return entry.getValue();
}
}
}
return 0;
}
private int getInducerSlot() {
for (IInvSlot slot : InventoryIterator.getIterable(getInternalInventory())) {
ItemStack stack = slot.getStackInSlot();
if (stack == null)
continue;
for (Entry<ItemStack, Integer> entry : BeeManager.inducers.entrySet()) {
if (entry.getKey().isItemEqual(stack))
return slot.getIndex();
}
}
return -1;
}
private void trySpawnSwarm() {
ItemStack toSpawn = pendingSpawns.peek();
WorldGenHive generator = new WorldGenHiveSwamer(new ItemStack[]{toSpawn});
HiveSwarmer hive = new HiveSwarmer(128, toSpawn);
int i = 0;
while (i < 10) {
i++;
int spawnX = xCoord + worldObj.rand.nextInt(40 * 2) - 40;
int spawnY = yCoord + worldObj.rand.nextInt(40);
int spawnZ = zCoord + worldObj.rand.nextInt(40 * 2) - 40;
if (generator.generate(worldObj, worldObj.rand, spawnX, spawnY, spawnZ)) {
pendingSpawns.pop();
break;
}
int chunkX = (xCoord + worldObj.rand.nextInt(40 * 2) - 40) / 16;
int chunkZ = (zCoord + worldObj.rand.nextInt(40 * 2) - 40) / 16;
if (HiveDecorator.instance().genHive(worldObj, worldObj.rand, chunkX, chunkZ, hive))
pendingSpawns.pop();
}
private void setIsActive(boolean isActive) {
if (this.isActive != isActive) {
this.isActive = isActive;
sendNetworkUpdate();
}
}
/* NETWORK */
@Override
public void fromPacketPayload(PacketPayload payload) {
boolean act = payload.shortPayload[0] > 0;
if (this.isActive != act) {
this.isActive = act;
worldObj.func_147479_m(xCoord, yCoord, zCoord);
}
}
@Override
public PacketPayload getPacketPayload() {
PacketPayload payload = new PacketPayload(0, 1);
payload.shortPayload[0] = (short) (isActive ? 1 : 0);
return payload;
}
@Override
@@ -162,7 +175,7 @@ public class TileAlvearySwarmer extends TileAlveary implements ISidedInventory {
if (side == 0 || side == 1)
return BlockAlveary.BOTTOM;
if (pendingSpawns.size() > 0)
if (isActive)
return BlockAlveary.ALVEARY_SWARMER_ON;
else
return BlockAlveary.ALVEARY_SWARMER_OFF;
@@ -23,7 +23,7 @@ public class AlleleEffectFertile extends AlleleEffectThrottled {
}
World world = housing.getWorld();
int territorySize[] = genome.getTerritory();
int territorySize[] = getModifiedArea(genome, housing);
int blockX = getRandomOffset(world.rand, housing.getXCoord(), territorySize[0]);
int blockZ = getRandomOffset(world.rand, housing.getZCoord(), territorySize[2]);
@@ -0,0 +1,129 @@
package forestry.apiculture.genetics;
import java.util.List;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.passive.EntityCow;
import net.minecraft.entity.passive.EntityMooshroom;
import net.minecraft.init.Blocks;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
import net.minecraft.world.gen.feature.WorldGenBigMushroom;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.genetics.IEffectData;
import forestry.core.genetics.EffectData;
public class AlleleEffectFungification extends AlleleEffectThrottled {
public static final int MAX_BLOCK_FIND_TRIES = 10;
public static final int ENTITY_THROTTLE = 6;
public AlleleEffectFungification(String uid) {
super(uid, "mycophilic", true, 10, false, false);
}
@Override
public IEffectData validateStorage(IEffectData storedData) {
if (storedData instanceof EffectData && ((EffectData) storedData).getIntSize() == 2) {
return storedData;
}
return new EffectData(2, 0);
}
@Override
public IEffectData doEffect(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) {
if (isHalted(storedData, housing)) {
return storedData;
}
doBlockEffect(genome, housing);
int entityThrottle = storedData.getInteger(1);
if (entityThrottle >= ENTITY_THROTTLE) {
doEntityEffect(genome, housing);
entityThrottle = 0;
} else {
++entityThrottle;
}
storedData.setInteger(1, entityThrottle);
return storedData;
}
private void doBlockEffect(IBeeGenome genome, IBeeHousing housing) {
World world = housing.getWorld();
int territorySize[] = getModifiedArea(genome, housing);
int blockX = getRandomOffset(world.rand, housing.getXCoord(), territorySize[0]);
int blockY = getRandomOffset(world.rand, housing.getYCoord(), territorySize[1]);
int blockZ = getRandomOffset(world.rand, housing.getZCoord(), territorySize[2]);
for (int attempt = 0; attempt < MAX_BLOCK_FIND_TRIES; ++attempt) {
Block block = world.getBlock(blockX, blockY, blockZ);
if (isSuitableForMycelium(world, block, blockX, blockY, blockZ)) {
world.setBlock(blockX, blockY, blockZ, Blocks.mycelium);
break;
} else if (isSuitableForGrowth(block)) {
doMushroomGrowth(block, world, blockX, blockY, blockZ);
break;
}
blockX = getRandomOffset(world.rand, housing.getXCoord(), territorySize[0]);
blockY = getRandomOffset(world.rand, housing.getYCoord(), territorySize[1]);
blockZ = getRandomOffset(world.rand, housing.getZCoord(), territorySize[2]);
}
}
private void doEntityEffect(IBeeGenome genome, IBeeHousing housing) {
AxisAlignedBB aabb = this.getBounding(genome, housing, 1f);
World world = housing.getWorld();
@SuppressWarnings("unchecked") // Quiets warnings. Eventually returns a list of entities.
List<Entity> entities = (List<Entity>)world.getEntitiesWithinAABB(EntityCow.class, aabb);
for (Entity entity : entities) {
if (entity instanceof EntityCow && !(entity instanceof EntityMooshroom)) {
convertCowToMooshroom((EntityCow)entity);
break;
}
}
}
private int getRandomOffset(Random random, int centrePos, int offset) {
return centrePos + random.nextInt(offset) - (offset / 2);
}
private boolean isSuitableForMycelium(World world, Block block, int blockX, int blockY, int blockZ) {
return block == Blocks.grass || (block == Blocks.dirt && world.canBlockSeeTheSky(blockX, blockY, blockZ));
}
private boolean isSuitableForGrowth(Block block) {
return block == Blocks.red_mushroom || block == Blocks.brown_mushroom;
}
private static void convertCowToMooshroom(EntityCow cow) {
World worldObj = cow.worldObj;
cow.setDead();
EntityMooshroom mooshroom = new EntityMooshroom(worldObj);
mooshroom.setLocationAndAngles(cow.posX, cow.posY, cow.posZ, cow.rotationYaw, cow.rotationPitch);
mooshroom.setHealth(cow.getHealth());
mooshroom.renderYawOffset = cow.renderYawOffset;
worldObj.spawnEntityInWorld(mooshroom);
worldObj.spawnParticle("largeexplode", cow.posX, cow.posY + (double)(cow.height / 2.0F), cow.posZ, 0.0D, 0.0D, 0.0D);
}
private void doMushroomGrowth(Block block, World world, int blockX, int blockY, int blockZ) {
WorldGenBigMushroom giantMushroomGenerator = null;
if (block == Blocks.brown_mushroom) {
giantMushroomGenerator = new WorldGenBigMushroom(0);
} else {
giantMushroomGenerator = new WorldGenBigMushroom(1);
}
world.setBlockToAir(blockX, blockY, blockZ);
giantMushroomGenerator.generate(world, world.rand, blockX, blockY, blockZ);
}
}
@@ -10,10 +10,12 @@
******************************************************************************/
package forestry.apiculture.genetics;
import cpw.mods.fml.relauncher.ReflectionHelper;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.genetics.IEffectData;
import forestry.apiculture.items.ItemArmorApiarist;
import forestry.core.proxy.Proxies;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
@@ -24,11 +26,13 @@ import java.util.List;
public class AlleleEffectPotion extends AlleleEffectThrottled {
private final Potion potion;
private final boolean isBadEffect;
private final int duration;
public AlleleEffectPotion(String uid, String name, boolean isDominant, Potion potion, int duration, boolean requiresWorking) {
super(uid, name, isDominant, 200, requiresWorking, false);
this.potion = potion;
this.isBadEffect = isBadEffect(potion);
this.duration = duration;
}
@@ -48,7 +52,7 @@ public class AlleleEffectPotion extends AlleleEffectThrottled {
EntityPlayer player = (EntityPlayer) entity;
int duration = this.duration;
if (potion.isBadEffect()) {
if (isBadEffect) {
// Players are not attacked if they wear a full set of apiarist's armor.
int count = ItemArmorApiarist.wearsItems((EntityPlayer) entity, getUID(), true);
if (count >= 4)
@@ -67,4 +71,14 @@ public class AlleleEffectPotion extends AlleleEffectThrottled {
return storedData;
}
//FIXME: remove when Potion.isBadEffect() is available server-side
private static boolean isBadEffect(Potion potion) {
try {
return ReflectionHelper.getPrivateValue(Potion.class, potion, "field_76418_K", "isBadEffect");
} catch (ReflectionHelper.UnableToFindFieldException e) {
Proxies.log.severe("Could not access potion field isBadEffect.");
return false;
}
}
}
@@ -582,6 +582,25 @@ public class BeeTemplates {
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesMarshy;
return alleles;
}
public static IAllele[] getMiryTemplate() {
IAllele[] alleles = getBoggyBranchTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesMiry;
alleles[EnumBeeChromosome.FERTILITY.ordinal()] = Allele.fertilityMaximum;
alleles[EnumBeeChromosome.TOLERANT_FLYER.ordinal()] = Allele.boolTrue;
alleles[EnumBeeChromosome.NOCTURNAL.ordinal()] = Allele.boolTrue;
return alleles;
}
public static IAllele[] getBoggyTemplate() {
IAllele[] alleles = getBoggyBranchTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesBoggy;
alleles[EnumBeeChromosome.TOLERANT_FLYER.ordinal()] = Allele.boolTrue;
alleles[EnumBeeChromosome.NOCTURNAL.ordinal()] = Allele.boolTrue;
alleles[EnumBeeChromosome.EFFECT.ordinal()] = Allele.effectMycophilic;
alleles[EnumBeeChromosome.TERRITORY.ordinal()] = Allele.territoryLarger;
return alleles;
}
/* MONASTIC BRANCH */
public static IAllele[] getMonasticBranchTemplate() {
@@ -52,34 +52,39 @@ public class HiveDecorator {
if (!TerrainGen.populate(event.chunkProvider, event.world, event.rand, event.chunkX, event.chunkZ, event.hasVillageGenerated, EVENT_TYPE)) {
return;
}
decorateHives(event.world, event.rand, event.chunkX * 16, event.chunkZ * 16);
decorateHives(event.world, event.rand, event.chunkX, event.chunkZ);
}
private void decorateHives(World world, Random rand, int worldX, int worldZ) {
private void decorateHives(World world, Random rand, int chunkX, int chunkZ) {
for (IHive hive : HiveManager.getHives())
if (Config.generateBeehivesDebug)
genHiveDebug(world, worldX, worldZ, hive);
genHiveDebug(world, chunkX, chunkZ, hive);
else
genHive(world, rand, worldX, worldZ, hive);
genHive(world, rand, chunkX, chunkZ, hive);
}
private void genHive(World world, Random rand, int worldX, int worldZ, IHive hive) {
public boolean genHive(World world, Random rand, int chunkX, int chunkZ, IHive hive) {
if (hive.genChance() < rand.nextFloat() * 128.0f)
return;
return false;
int worldX = chunkX * 16;
int worldZ = chunkZ * 16;
BiomeGenBase biome = world.getBiomeGenForCoords(worldX, worldZ);
EnumHumidity humidity = EnumHumidity.getFromValue(biome.rainfall);
if (!hive.isGoodBiome(biome) || !hive.isGoodHumidity(humidity))
return;
return false;
for (int tries = 0; tries < 4; tries ++) {
int x = worldX + rand.nextInt(16);
int z = worldZ + rand.nextInt(16);
if (tryGenHive(world, x, z, hive))
return;
return true;
}
return false;
}
private void genHiveDebug(World world, int worldX, int worldZ, IHive hive) {
@@ -11,8 +11,6 @@
package forestry.apiculture.worldgen;
import forestry.api.apiculture.hives.HiveGround;
import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
import forestry.core.config.ForestryBlock;
import net.minecraft.init.Blocks;
import net.minecraft.world.biome.BiomeGenBase;
@@ -14,7 +14,6 @@ import forestry.api.apiculture.hives.HiveTree;
import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
import forestry.core.config.ForestryBlock;
import net.minecraft.world.biome.BiomeGenBase;
public class HiveForest extends HiveTree {
@@ -14,7 +14,6 @@ import forestry.api.apiculture.hives.HiveTree;
import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
import forestry.core.config.ForestryBlock;
import net.minecraft.world.biome.BiomeGenBase;
public class HiveJungle extends HiveTree {
@@ -15,7 +15,6 @@ import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
import forestry.core.config.ForestryBlock;
import net.minecraft.init.Blocks;
import net.minecraft.world.biome.BiomeGenBase;
public class HiveMeadows extends HiveGround {
@@ -11,12 +11,10 @@
package forestry.apiculture.worldgen;
import forestry.api.apiculture.hives.HiveGround;
import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
import forestry.core.config.ForestryBlock;
import net.minecraft.init.Blocks;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
public class HiveSnow extends HiveGround {
@@ -15,7 +15,6 @@ import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
import forestry.core.config.ForestryBlock;
import net.minecraft.init.Blocks;
import net.minecraft.world.biome.BiomeGenBase;
public class HiveSwamp extends HiveGround {
@@ -4,46 +4,34 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.worldgen;
import java.util.Random;
import forestry.api.apiculture.hives.HiveGround;
import forestry.apiculture.gadgets.TileSwarm;
import forestry.core.config.ForestryBlock;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import forestry.apiculture.gadgets.TileSwarm;
public class HiveSwarmer extends HiveGround {
/**
*
* @author CovertJaguar <http://www.railcraft.info/>
*/
public class WorldGenHiveSwamer extends WorldGenHive {
private final ItemStack[] bees;
private ItemStack[] bees;
public WorldGenHiveSwamer(ItemStack[] bees) {
public HiveSwarmer(float genChance, ItemStack... bees) {
super(ForestryBlock.beehives.block(), 8, genChance, Blocks.dirt, Blocks.grass);
this.bees = bees;
}
@Override
public boolean generate(World world, Random random, int x, int y, int z) {
if (world.blockExists(x, y, z) && world.isAirBlock(x, y, z) && (!world.isAirBlock(x, y - 1, z) || !world.isAirBlock(x, y + 1, z))) {
setHive(world, x, y, z, 8);
return true;
}
return false;
}
@Override
protected void postGen(World world, int x, int y, int z, int meta) {
public void postGen(World world, int x, int y, int z) {
TileEntity tile = world.getTileEntity(x, y, z);
if (tile instanceof TileSwarm)
((TileSwarm) tile).setContained(bees);
}
}
@@ -1,43 +0,0 @@
/*******************************************************************************
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.worldgen;
import java.util.Random;
import net.minecraft.world.World;
import net.minecraft.world.gen.feature.WorldGenerator;
import forestry.core.config.Defaults;
import forestry.core.config.ForestryBlock;
public abstract class WorldGenHive extends WorldGenerator {
@Override
public abstract boolean generate(World world, Random random, int x, int y, int z);
protected void setHive(World world, int x, int y, int z, int meta) {
boolean placed = world.setBlock(x, y, z, ForestryBlock.beehives.block(), meta, Defaults.FLAG_BLOCK_SYNCH);
if (!placed)
return;
if (!ForestryBlock.beehives.isBlockEqual(world, x, y, z))
return;
ForestryBlock.beehives.block().onBlockAdded(world, x, y, z);
world.markBlockForUpdate(x, y, z);
postGen(world, x, y, z, meta);
}
protected void postGen(World world, int x, int y, int z, int meta) {
ForestryBlock.beehives.block().onBlockPlaced(world, x, y, z, 0, 0.0f, 0.0f, 0.0f, meta);
}
}
+11 -10
View File
@@ -10,6 +10,8 @@
******************************************************************************/
package forestry.core;
import com.google.common.collect.ImmutableList;
import java.io.File;
import net.minecraft.init.Blocks;
@@ -17,15 +19,14 @@ import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.server.MinecraftServer;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fluids.FluidRegistry;
import cpw.mods.fml.common.event.FMLInterModComms;
import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraftforge.common.MinecraftForge;
import com.google.common.collect.ImmutableList;
import forestry.api.apiculture.FlowerManager;
import forestry.api.core.ForestryAPI;
import forestry.api.fuels.EngineBronzeFuel;
@@ -89,17 +90,17 @@ public class ForestryCore {
Defaults.ENGINE_COPPER_FUEL_VALUE_PEAT, Defaults.ENGINE_COPPER_CYCLE_DURATION_PEAT));
FuelManager.copperEngineFuel.put(ForestryItem.bituminousPeat.getItemStack(), new EngineCopperFuel(ForestryItem.bituminousPeat.getItemStack(),
Defaults.ENGINE_COPPER_FUEL_VALUE_BITUMINOUS_PEAT, Defaults.ENGINE_COPPER_CYCLE_DURATION_BITUMINOUS_PEAT));
FuelManager.bronzeEngineFuel.put(LiquidHelper.getFluid(Defaults.LIQUID_BIOMASS), new EngineBronzeFuel(LiquidHelper.getFluid(Defaults.LIQUID_BIOMASS),
FuelManager.bronzeEngineFuel.put(FluidRegistry.getFluid(Defaults.LIQUID_BIOMASS), new EngineBronzeFuel(FluidRegistry.getFluid(Defaults.LIQUID_BIOMASS),
Defaults.ENGINE_FUEL_VALUE_BIOMASS, (int) (Defaults.ENGINE_CYCLE_DURATION_BIOMASS * GameMode.getGameMode().getFloatSetting("fuel.biomass.biogas")), 1));
FuelManager.bronzeEngineFuel.put(LiquidHelper.getFluid(Defaults.LIQUID_WATER), new EngineBronzeFuel(LiquidHelper.getFluid(Defaults.LIQUID_WATER),
FuelManager.bronzeEngineFuel.put(FluidRegistry.getFluid(Defaults.LIQUID_WATER), new EngineBronzeFuel(FluidRegistry.getFluid(Defaults.LIQUID_WATER),
Defaults.ENGINE_FUEL_VALUE_WATER, Defaults.ENGINE_CYCLE_DURATION_WATER, 3));
FuelManager.bronzeEngineFuel.put(LiquidHelper.getFluid(Defaults.LIQUID_MILK), new EngineBronzeFuel(LiquidHelper.getFluid(Defaults.LIQUID_MILK),
FuelManager.bronzeEngineFuel.put(FluidRegistry.getFluid(Defaults.LIQUID_MILK), new EngineBronzeFuel(FluidRegistry.getFluid(Defaults.LIQUID_MILK),
Defaults.ENGINE_FUEL_VALUE_MILK, Defaults.ENGINE_CYCLE_DURATION_MILK, 3));
FuelManager.bronzeEngineFuel.put(LiquidHelper.getFluid(Defaults.LIQUID_SEEDOIL), new EngineBronzeFuel(LiquidHelper.getFluid(Defaults.LIQUID_SEEDOIL),
FuelManager.bronzeEngineFuel.put(FluidRegistry.getFluid(Defaults.LIQUID_SEEDOIL), new EngineBronzeFuel(FluidRegistry.getFluid(Defaults.LIQUID_SEEDOIL),
Defaults.ENGINE_FUEL_VALUE_SEED_OIL, Defaults.ENGINE_CYCLE_DURATION_SEED_OIL, 1));
FuelManager.bronzeEngineFuel.put(LiquidHelper.getFluid(Defaults.LIQUID_HONEY), new EngineBronzeFuel(LiquidHelper.getFluid(Defaults.LIQUID_HONEY),
FuelManager.bronzeEngineFuel.put(FluidRegistry.getFluid(Defaults.LIQUID_HONEY), new EngineBronzeFuel(FluidRegistry.getFluid(Defaults.LIQUID_HONEY),
Defaults.ENGINE_FUEL_VALUE_HONEY, Defaults.ENGINE_CYCLE_DURATION_HONEY, 1));
FuelManager.bronzeEngineFuel.put(LiquidHelper.getFluid(Defaults.LIQUID_JUICE), new EngineBronzeFuel(LiquidHelper.getFluid(Defaults.LIQUID_JUICE),
FuelManager.bronzeEngineFuel.put(FluidRegistry.getFluid(Defaults.LIQUID_JUICE), new EngineBronzeFuel(FluidRegistry.getFluid(Defaults.LIQUID_JUICE),
Defaults.ENGINE_FUEL_VALUE_JUICE, Defaults.ENGINE_CYCLE_DURATION_JUICE, 1));
// Set rain substrates
@@ -10,22 +10,28 @@
******************************************************************************/
package forestry.core.fluids;
import forestry.core.fluids.tanks.StandardTank;
import forestry.core.inventory.InvTools;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraft.block.Block;
import net.minecraft.block.BlockLiquid;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.fluids.*;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidBlock;
import net.minecraftforge.fluids.IFluidContainerItem;
import net.minecraftforge.fluids.IFluidHandler;
import forestry.core.fluids.tanks.StandardTank;
import forestry.core.inventory.InvTools;
import forestry.core.utils.StackUtils;
/**
*
@@ -63,7 +69,7 @@ public final class FluidHelper {
FluidStack available = tank.drain(side, Integer.MAX_VALUE, false);
if (available != null) {
ItemStack filled = fillContainer(available, current);
ItemStack filled = getFilledContainer(available, current);
liquid = getFluidStackInContainer(filled);
if (liquid != null) {
@@ -116,6 +122,10 @@ public final class FluidHelper {
}
public static boolean fillContainers(IFluidHandler fluidHandler, IInventory inv, int inputSlot, int outputSlot, Fluid fluidToFill) {
return fillContainers(fluidHandler, inv, inputSlot, outputSlot, fluidToFill, true);
}
public static boolean fillContainers(IFluidHandler fluidHandler, IInventory inv, int inputSlot, int outputSlot, Fluid fluidToFill, boolean doFill) {
ItemStack input = inv.getStackInSlot(inputSlot);
ItemStack output = inv.getStackInSlot(outputSlot);
ItemStack filled = getFilledContainer(fluidToFill, input);
@@ -123,12 +133,14 @@ public final class FluidHelper {
FluidStack fluidInContainer = getFluidStackInContainer(filled);
FluidStack drain = fluidHandler.drain(ForgeDirection.UNKNOWN, fluidInContainer, false);
if (drain != null && drain.amount == fluidInContainer.amount) {
fluidHandler.drain(ForgeDirection.UNKNOWN, fluidInContainer, true);
if (output == null)
inv.setInventorySlotContents(outputSlot, filled);
else
output.stackSize++;
inv.decrStackSize(inputSlot, 1);
if (doFill) {
fluidHandler.drain(ForgeDirection.UNKNOWN, fluidInContainer, true);
if (output == null)
inv.setInventorySlotContents(outputSlot, filled);
else
output.stackSize++;
inv.decrStackSize(inputSlot, 1);
}
return true;
}
}
@@ -143,30 +155,37 @@ public final class FluidHelper {
ItemStack input = inv.getStackInSlot(inputSlot);
ItemStack output = inv.getStackInSlot(outputSlot);
if (input != null) {
FluidStack fluidInContainer = getFluidStackInContainer(input);
ItemStack emptyItem = input.getItem().getContainerItem(input);
if (fluidInContainer != null && (emptyItem == null || output == null
|| (inputSlot == outputSlot && input.stackSize == 1)
|| (output.stackSize < output.getMaxStackSize() && InvTools.isItemEqual(output, emptyItem)))) {
int used = fluidHandler.fill(ForgeDirection.UNKNOWN, fluidInContainer, false);
if (used >= fluidInContainer.amount) {
fluidHandler.fill(ForgeDirection.UNKNOWN, fluidInContainer, true);
if (emptyItem != null)
if (output == null)
inv.setInventorySlotContents(outputSlot, emptyItem);
else
output.stackSize++;
inv.decrStackSize(inputSlot, 1);
return true;
}
}
}
return false;
}
if (input == null)
return false;
public static boolean isBucket(ItemStack stack) {
return FluidContainerRegistry.isBucket(stack);
FluidStack fluidInContainer = getFluidStackInContainer(input);
if (fluidInContainer == null)
return false;
int used = fluidHandler.fill(ForgeDirection.UNKNOWN, fluidInContainer, false);
if (used < fluidInContainer.amount)
return false;
fluidHandler.fill(ForgeDirection.UNKNOWN, fluidInContainer, true);
ItemStack emptyItem = getEmptyContainer(input);
// unstackable containers like buckets are not consumed
if (outputSlot == inputSlot && input.getMaxStackSize() == 1) {
inv.setInventorySlotContents(outputSlot, emptyItem);
return true;
}
if (emptyItem != null) {
if (output == null) {
inv.setInventorySlotContents(outputSlot, emptyItem);
} else if (StackUtils.isIdenticalItem(output, emptyItem) && (output.stackSize < output.getMaxStackSize())) {
output.stackSize++;
}
// else output item is consumed
}
inv.decrStackSize(inputSlot, 1);
return true;
}
public static boolean isContainer(ItemStack stack) {
@@ -176,48 +195,116 @@ public final class FluidHelper {
}
public static boolean isFilledContainer(ItemStack stack) {
return FluidContainerRegistry.isFilledContainer(stack);
if (FluidContainerRegistry.isFilledContainer(stack))
return true;
Item item = stack.getItem();
if (item instanceof IFluidContainerItem) {
IFluidContainerItem containerItem = (IFluidContainerItem)item;
FluidStack fluidStack = containerItem.getFluid(stack);
return fluidStack != null && fluidStack.amount > 0;
}
return false;
}
public static boolean isEmptyContainer(ItemStack stack) {
return FluidContainerRegistry.isEmptyContainer(stack);
public static boolean isFillableContainer(ItemStack empty, FluidStack liquid) {
Item item = empty.getItem();
if (item instanceof IFluidContainerItem) {
IFluidContainerItem containerItem = (IFluidContainerItem)item;
return containerItem.fill(empty, liquid, false) > 0;
}
for (FluidContainerData cont : FluidContainerRegistry.getRegisteredFluidContainerData()) {
if (cont.fluid.isFluidEqual(liquid) && (cont.emptyContainer != null && cont.emptyContainer.isItemEqual(empty)))
return true;
}
return false;
}
public static boolean isEmptyContainer(ItemStack empty) {
if (FluidContainerRegistry.isEmptyContainer(empty))
return true;
Item item = empty.getItem();
if (item instanceof IFluidContainerItem) {
IFluidContainerItem containerItem = (IFluidContainerItem)item;
FluidStack fluid = containerItem.getFluid(empty);
return fluid == null || fluid.amount == 0;
}
return false;
}
public static ItemStack getEmptyContainer(ItemStack container) {
Item item = container.getItem();
if (item instanceof IFluidContainerItem) {
ItemStack empty = container.copy();
empty.stackSize = 1;
IFluidContainerItem containerItem = (IFluidContainerItem) item;
containerItem.drain(empty, Integer.MAX_VALUE, true);
return empty;
}
return FluidContainerRegistry.drainFluidContainer(container);
}
public static ItemStack getFilledContainer(Fluid fluid, ItemStack empty) {
if (fluid == null || empty == null)
if (fluid == null)
return null;
return FluidContainerRegistry.fillFluidContainer(new FluidStack(fluid, Integer.MAX_VALUE), empty);
FluidStack fluidToFill = new FluidStack(fluid, Integer.MAX_VALUE);
return getFilledContainer(fluidToFill, empty);
}
public static ItemStack getFilledContainer(FluidStack fluid, ItemStack empty) {
if (fluid == null || empty == null)
return null;
fluid = fluid.copy();
fluid.amount = Integer.MAX_VALUE;
return FluidContainerRegistry.fillFluidContainer(fluid, empty);
}
public static ItemStack fillContainer(FluidStack liquid, ItemStack empty) {
public static ItemStack getFilledContainer(FluidStack liquid, ItemStack empty) {
if (liquid == null || empty == null)
return null;
Item item = empty.getItem();
if (item instanceof IFluidContainerItem) {
ItemStack full = empty.copy();
full.stackSize = 1;
IFluidContainerItem containerItem = (IFluidContainerItem) item;
containerItem.fill(full, liquid, true);
return full;
}
return FluidContainerRegistry.fillFluidContainer(liquid, empty);
}
public static FluidStack getFluidStackInContainer(ItemStack stack) {
Item item = stack.getItem();
if (item instanceof IFluidContainerItem) {
IFluidContainerItem containerItem = (IFluidContainerItem) item;
return containerItem.getFluid(stack);
}
return FluidContainerRegistry.getFluidForFilledItem(stack);
}
public static Fluid getFluidInContianer(ItemStack stack) {
FluidStack fluidStack = FluidContainerRegistry.getFluidForFilledItem(stack);
public static Fluid getFluidInContainer(ItemStack stack) {
FluidStack fluidStack = getFluidStackInContainer(stack);
return fluidStack != null ? fluidStack.getFluid() : null;
}
public static boolean containsFluidStack(ItemStack stack, FluidStack fluidStack) {
Item item = stack.getItem();
if (item instanceof IFluidContainerItem) {
IFluidContainerItem containerItem = (IFluidContainerItem) item;
FluidStack contained = containerItem.getFluid(stack);
return contained != null && contained.containsFluid(fluidStack);
}
return FluidContainerRegistry.containsFluid(stack, fluidStack);
}
public static boolean containsFluid(ItemStack stack, Fluid fluid) {
return FluidContainerRegistry.containsFluid(stack, new FluidStack(fluid, 1));
return containsFluidStack(stack, new FluidStack(fluid, 1));
}
public static boolean isFluidEqual(FluidStack L1, FluidStack L2) {
@@ -226,24 +313,6 @@ public final class FluidHelper {
return L1.isFluidEqual(L2);
}
public static Collection<ItemStack> getContainersFilledWith(FluidStack fluidStack) {
List<ItemStack> containers = new ArrayList<ItemStack>();
for (FluidContainerData data : FluidContainerRegistry.getRegisteredFluidContainerData()) {
FluidStack inContainer = getFluidStackInContainer(data.filledContainer);
if (inContainer != null && inContainer.containsFluid(fluidStack))
containers.add(data.filledContainer.copy());
}
return containers;
}
public static void nerfWaterBottle() {
for (FluidContainerData data : FluidContainerRegistry.getRegisteredFluidContainerData())
if (data.filledContainer.getItem() == Items.potionitem && data.emptyContainer.getItem() == Items.glass_bottle && Fluids.WATER.is(data.fluid)) {
data.fluid.amount = 333;
return;
}
}
public static FluidStack drainBlock(World world, int x, int y, int z, boolean doDrain) {
return drainBlock(world.getBlock(x, y, z), world, x, y, z, doDrain);
}
@@ -11,13 +11,7 @@
package forestry.core.fluids;
import com.google.common.collect.ForwardingList;
import forestry.core.fluids.tanks.FakeTank;
import forestry.core.fluids.tanks.StandardTank;
import forestry.core.inventory.ITileFilter;
import forestry.core.network.PacketGuiInteger;
import forestry.core.proxy.Proxies;
import forestry.core.utils.NBTUtil;
import forestry.core.utils.NBTUtil.NBTList;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
@@ -26,19 +20,26 @@ import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.ICrafting;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidHandler;
import net.minecraftforge.fluids.IFluidTank;
import forestry.core.fluids.tanks.FakeTank;
import forestry.core.fluids.tanks.StandardTank;
import forestry.core.inventory.ITileFilter;
import forestry.core.network.PacketGuiInteger;
import forestry.core.proxy.Proxies;
import forestry.core.utils.NBTUtil;
import forestry.core.utils.NBTUtil.NBTList;
/**
*
@@ -287,14 +288,18 @@ public class TankManager extends ForwardingList<StandardTank> implements IFluidH
return tank.drain(maxDrain, doDrain);
}
@Override
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) {
public FluidStack drain(FluidStack resource, boolean doDrain) {
for (StandardTank tank : tanks)
if (tankCanDrainFluid(tank, resource))
return tank.drain(resource.amount, doDrain);
return null;
}
@Override
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) {
return drain(resource, doDrain);
}
@Override
public boolean canFill(ForgeDirection from, Fluid fluid) {
return true;
@@ -345,6 +350,14 @@ public class TankManager extends ForwardingList<StandardTank> implements IFluidH
return tank;
}
public boolean accepts(Fluid fluid) {
for (StandardTank tank : tanks)
if (tank.accepts(fluid))
return true;
return false;
}
private boolean tankAcceptsFluid(StandardTank tank, FluidStack fluidStack) {
if (fluidStack == null)
return false;
@@ -22,20 +22,22 @@ import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.IFluidHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import forestry.core.fluids.FluidHelper;
import forestry.core.interfaces.IOwnable;
import forestry.core.items.ItemNBTTile;
import forestry.core.proxy.Proxies;
import forestry.core.utils.LiquidHelper;
import forestry.core.utils.StringUtil;
import forestry.core.utils.Utils;
@@ -168,7 +170,7 @@ public class BlockBase extends BlockForestry {
ItemStack current = player.getCurrentEquippedItem();
if (current != null && current.getItem() != Items.bucket && tile instanceof IFluidHandler) {
if (Proxies.common.isSimulating(world)) {
if (LiquidHelper.handleRightClick((IFluidHandler) tile, ForgeDirection.getOrientation(side), player, true, tile.canDrainWithBucket())) {
if (FluidHelper.handleRightClick((IFluidHandler) tile, ForgeDirection.getOrientation(side), player, true, tile.canDrainWithBucket())) {
return true;
}
} else {
@@ -70,7 +70,7 @@ public abstract class StructureLogic implements IStructureLogic {
EnumStructureState state = EnumStructureState.INDETERMINATE;
boolean rotate = false;
boolean rotate;
for (int i = 0; i < schematas.length; i++) {
if (!schematas[i].isEnabled())
continue;
@@ -87,7 +87,6 @@ public abstract class StructureLogic implements IStructureLogic {
isRotated = rotate;
break;
}
}
// Structure state is indeterminate, possibly caused by chunkloading. Remain calm, do nothing.
@@ -118,32 +118,6 @@ public abstract class TilePowered extends TileBase implements IRenderableMachine
energyManager.readFromNBT(nbt);
}
/* LIQUID CONTAINER HANDLING */
/**
@deprecated Use FluidHelper
*/
@Deprecated
protected ItemStack bottleIntoContainer(ItemStack canStack, ItemStack outputStack, FluidContainerData container, StandardTank tank) {
if (tank.getFluidAmount() < container.fluid.amount)
return outputStack;
if (canStack.stackSize <= 0)
return outputStack;
if (outputStack != null && !outputStack.isItemEqual(container.filledContainer))
return outputStack;
if (outputStack != null && outputStack.stackSize >= outputStack.getMaxStackSize())
return outputStack;
tank.drain(container.fluid.amount, true);
canStack.stackSize--;
if (outputStack == null)
outputStack = container.filledContainer.copy();
else
outputStack.stackSize++;
return outputStack;
}
// / ADDITIONAL LIQUID HANDLING
@Override
public EnumTankLevel getPrimaryLevel() {
@@ -123,8 +123,8 @@ public class Allele implements IAllele {
// Boggy branch
public static AlleleSpecies speciesMarshy;
// 44 speciesMiry
// 45 speciesBoggy
public static AlleleSpecies speciesMiry;
public static AlleleSpecies speciesBoggy;
// Monastic branch
public static AlleleSpecies speciesMonastic;
@@ -392,6 +392,7 @@ public class Allele implements IAllele {
public static Allele effectResurrection;
public static Allele effectRepulsion;
public static Allele effectFertile;
public static Allele effectMycophilic;
// / TREES // EFFECTS
public static Allele leavesNone;
@@ -13,7 +13,6 @@ package forestry.core.gui;
import forestry.core.gadgets.TileForestry;
import forestry.core.gui.slots.SlotForestry;
import forestry.core.utils.EnumAccess;
import forestry.core.utils.PlayerUtil;
import forestry.core.utils.StackUtils;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
@@ -39,6 +38,7 @@ public class ContainerForestry extends Container {
* Adds a slot to the container, shortcut for addSlotToContainer(slot).
*
* @param slot
* @return
*/
protected Slot addSlot(Slot slot) {
return addSlotToContainer(slot);
@@ -54,41 +54,41 @@ public class ContainerForestry extends Container {
return null;
Slot slot = slotIndex < 0 ? null : (Slot) this.inventorySlots.get(slotIndex);
if (slot instanceof SlotForestry) {
((SlotForestry) slot).onSlotClick(slotIndex, button, modifier, player);
if (slot instanceof SlotForestry)
if (((SlotForestry) slot).isPhantom())
return slotClickPhantom(slot, button, modifier, player);
}
return super.slotClick(slotIndex, button, modifier, player);
}
private ItemStack slotClickPhantom(Slot slot, int mouseButton, int modifier, EntityPlayer player) {
ItemStack stack = null;
if (mouseButton == 2) {
if (((SlotForestry) slot).canAdjustPhantom())
slot.putStack(null);
} else if (mouseButton == 0 || mouseButton == 1) {
InventoryPlayer playerInv = player.inventory;
slot.onSlotChanged();
ItemStack stackSlot = slot.getStack();
ItemStack stackHeld = playerInv.getItemStack();
ItemStack stackSlot = slot.getStack();
if (stackSlot != null)
stack = stackSlot.copy();
if (stackSlot != null)
stack = stackSlot.copy();
if (mouseButton == 2)
fillPhantomSlot(slot, null, mouseButton, modifier);
else if (mouseButton == 0 || mouseButton == 1) {
InventoryPlayer playerInv = player.inventory;
ItemStack stackHeld = playerInv.getItemStack();
if (stackSlot == null) {
if (stackHeld != null && slot.isItemValid(stackHeld))
fillPhantomSlot(slot, stackHeld, mouseButton, modifier);
} else if (stackHeld == null) {
} else if (stackHeld == null)
adjustPhantomSlot(slot, mouseButton, modifier);
slot.onPickupFromSlot(player, playerInv.getItemStack());
} else if (slot.isItemValid(stackHeld))
else if (slot.isItemValid(stackHeld))
if (StackUtils.isIdenticalItem(stackSlot, stackHeld))
adjustPhantomSlot(slot, mouseButton, modifier);
else
fillPhantomSlot(slot, stackHeld, mouseButton, modifier);
} else if (mouseButton == 5) {
InventoryPlayer playerInv = player.inventory;
ItemStack stackHeld = playerInv.getItemStack();
if (!slot.getHasStack())
fillPhantomSlot(slot, stackHeld, mouseButton, modifier);
}
return stack;
}
@@ -109,12 +109,20 @@ public class ContainerForestry extends Container {
stackSlot.stackSize = stackSize;
if (stackSlot.stackSize <= 0)
slot.putStack(null);
stackSlot = null;
slot.putStack(stackSlot);
}
protected void fillPhantomSlot(Slot slot, ItemStack stackHeld, int mouseButton, int modifier) {
if (!((SlotForestry) slot).canAdjustPhantom())
return;
if (stackHeld == null) {
slot.putStack(null);
return;
}
int stackSize = mouseButton == 0 ? stackHeld.stackSize : 1;
if (stackSize > slot.getSlotStackLimit())
stackSize = slot.getSlotStackLimit();
@@ -214,9 +214,6 @@ public abstract class GuiForestry<T extends TileForestry> extends GuiContainer i
widgetManager.handleMouseMove(mouseX, mouseY, mouseButton, time);
Slot slot = getSlotAtPosition(mouseX, mouseY);
if (mouseButton == 1 && slot instanceof SlotForestry && ((SlotForestry) slot).isPhantom())
return;
super.mouseClickMove(mouseX, mouseY, mouseButton, time);
}
@@ -10,20 +10,22 @@
******************************************************************************/
package forestry.core.gui.slots;
import cpw.mods.fml.common.FMLCommonHandler;
import forestry.core.interfaces.ICrafter;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.inventory.SlotCrafting;
import net.minecraft.item.ItemStack;
import forestry.core.interfaces.ICrafter;
public class SlotCrafter extends Slot {
public class SlotCrafter extends SlotCrafting {
private final ICrafter crafter;
private final IInventory craftMatrix;
public SlotCrafter(IInventory inventory, ICrafter crafter, int slot, int xPos, int yPos) {
super(inventory, slot, xPos, yPos);
public SlotCrafter(EntityPlayer player, IInventory craftMatrix, ICrafter crafter, int slot, int xPos, int yPos) {
super(player, craftMatrix, craftMatrix, slot, xPos, yPos);
this.crafter = crafter;
this.craftMatrix = craftMatrix;
}
@Override
@@ -56,6 +58,8 @@ public class SlotCrafter extends Slot {
@Override
public void onPickupFromSlot(EntityPlayer player, ItemStack itemStack) {
FMLCommonHandler.instance().firePlayerCraftingEvent(player, itemStack, craftMatrix);
this.onCrafting(itemStack, itemStack.stackSize); // handles crafting achievements, maps, and statistics
crafter.takenFromSlot(getSlotIndex(), true, player);
}
}
@@ -51,6 +51,12 @@ public class SlotForestry extends Slot implements IToolTipProvider{
return this;
}
@Override
public void putStack(ItemStack itemStack) {
if (!isPhantom() || canAdjustPhantom())
super.putStack(itemStack);
}
public SlotForestry setCanAdjustPhantom(boolean canAdjust) {
this.canAdjustPhantom = canAdjust;
return this;
@@ -105,9 +111,6 @@ public class SlotForestry extends Slot implements IToolTipProvider{
return result;
}
public void onSlotClick(int slotIndex, int button, int modifier, EntityPlayer player) {
}
/**
* @param toolTips the tooltips to set
*/
@@ -61,10 +61,11 @@ public class TankWidget extends Widget {
@Override
public void draw(int startX, int startY) {
if (getTank() == null)
StandardTank tank = getTank();
if (tank == null)
return;
FluidStack contents = getTank().getFluid();
FluidStack contents = tank.getFluid();
if (contents == null || contents.amount <= 0 || contents.getFluid() == null)
return;
IIcon liquidIcon = contents.getFluid().getIcon(contents);
@@ -32,7 +32,7 @@ public class InventoryIterator implements Iterable<IInvSlot> {
private InventoryIterator(IInventory inv) {
this.inv = inv;
this.invSize = inv.getSizeInventory();
this.invSize = inv != null ? inv.getSizeInventory() : 0;
}
@Override
@@ -33,6 +33,7 @@ import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidBlock;
import forestry.core.CreativeTabForestry;
import forestry.core.fluids.FluidHelper;
import forestry.core.proxy.Proxies;
import forestry.core.render.TextureManager;
import forestry.core.utils.LiquidHelper;
@@ -149,19 +150,18 @@ public class ItemLiquidContainer extends Item {
if (fluid == null || fluid.amount <= 0)
return itemstack;
// Check whether there is valid container for the liquid.
FluidContainerData container = LiquidHelper.getEmptyContainer(itemstack, fluid);
if (container == null)
ItemStack filledContainer = FluidHelper.getFilledContainer(fluid.getFluid(), itemstack);
if (filledContainer == null)
return itemstack;
// Search for a slot to stow a filled container in player's
// inventory
int slot = getMatchingSlot(entityplayer, container.filledContainer);
int slot = getMatchingSlot(entityplayer, filledContainer);
if (slot < 0)
return itemstack;
if (entityplayer.inventory.getStackInSlot(slot) == null)
entityplayer.inventory.setInventorySlotContents(slot, container.filledContainer.copy());
entityplayer.inventory.setInventorySlotContents(slot, filledContainer.copy());
else
entityplayer.inventory.getStackInSlot(slot).stackSize++;
@@ -11,6 +11,7 @@
package forestry.core.utils;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
public class FluidStackMap<T> extends StackMap<FluidStack, T> {
@@ -38,9 +39,9 @@ public class FluidStackMap<T> extends StackMap<FluidStack, T> {
if (key instanceof FluidStack)
return (FluidStack) key;
if (key instanceof Fluid)
return LiquidHelper.getLiquid(((Fluid) key).getName(), 1);
return FluidRegistry.getFluidStack(((Fluid) key).getName(), 1);
if (key instanceof String)
return LiquidHelper.getLiquid((String) key, 1);
return FluidRegistry.getFluidStack((String) key, 1);
return null;
}
@@ -18,6 +18,8 @@ import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import forestry.core.fluids.FluidHelper;
/**
* @author CovertJaguar <http://www.railcraft.info>
*/
@@ -46,7 +48,7 @@ public enum Fluids {
}
public boolean isContained(ItemStack containerStack) {
return containerStack != null && LiquidHelper.containsFluid(containerStack, Fluids.WATER.get());
return containerStack != null && FluidHelper.containsFluid(containerStack, Fluids.WATER.get());
}
public static boolean areEqual(Fluid fluid, FluidStack fluidStack) {
@@ -10,83 +10,36 @@
******************************************************************************/
package forestry.core.utils;
import java.util.HashMap;
import java.util.LinkedList;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import cpw.mods.fml.common.registry.LanguageRegistry;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidHandler;
import forestry.api.recipes.RecipeManagers;
import forestry.core.config.Defaults;
import forestry.core.config.ForestryItem;
import forestry.core.render.TextureManager;
public class LiquidHelper {
private static final LinkedList<String> myLiquids = new LinkedList<String>();
private static final HashMap<String, Fluid> liquidMap = new HashMap<String, Fluid>();
public static boolean isEmptyLiquidData() {
return FluidContainerRegistry.getRegisteredFluidContainerData().length <= 0;
}
public static boolean isEmptyContainer(ItemStack empty) {
return FluidContainerRegistry.isEmptyContainer(empty);
}
public static FluidContainerData getEmptyContainer(ItemStack empty, FluidStack liquid) {
for (FluidContainerData cont : FluidContainerRegistry.getRegisteredFluidContainerData()) {
if (cont.fluid.isFluidEqual(liquid) && (cont.emptyContainer != null && cont.emptyContainer.isItemEqual(empty)))
return cont;
}
return null;
}
public static FluidContainerData getLiquidContainer(ItemStack container) {
for (FluidContainerData cont : FluidContainerRegistry.getRegisteredFluidContainerData()) {
if (cont.filledContainer.isItemEqual(container))
return cont;
}
return null;
}
public static FluidContainerData createLiquidData(String ident, FluidStack stillLiquid, ItemStack filled, ItemStack container) {
return new FluidContainerData(new FluidStack(getOrCreateLiquid(ident), Defaults.BUCKET_VOLUME), filled, container);
}
public static boolean isLiquid(String ident, FluidStack stack) {
return FluidRegistry.getFluidID(ident) == stack.fluidID;
}
public static boolean exists(String ident) {
return FluidRegistry.isFluidRegistered(ident);
}
public static Fluid getFluid(String ident) {
return FluidRegistry.getFluid(ident);
}
public static Fluid getOrCreateLiquid(String ident) {
if (!FluidRegistry.isFluidRegistered(ident)) {
Fluid fluid = new Fluid(ident);
FluidRegistry.registerFluid(fluid);
myLiquids.add(ident);
}
liquidMap.put(ident, FluidRegistry.getFluid(ident));
return FluidRegistry.getFluid(ident);
}
@@ -111,7 +64,7 @@ public class LiquidHelper {
}
public static void injectLiquidContainer(String name, int volume, ItemStack filled, ItemStack empty, ItemStack remnant, int chance) {
FluidStack contained = getLiquid(name, volume);
FluidStack contained = FluidRegistry.getFluidStack(name, volume);
if (contained == null)
throw new IllegalArgumentException(String.format("Attempted to inject a liquid container for the non-existent liquid '%s'.", name));
@@ -128,140 +81,9 @@ public class LiquidHelper {
public static void resetLiquidIcons(IIconRegister register) {
for (String fluidString : myLiquids) {
Fluid fluid = getFluid(fluidString);
Fluid fluid = FluidRegistry.getFluid(fluidString);
IIcon icon = TextureManager.getInstance().registerTex(register, "liquid/" + fluid.getName());
fluid.setIcons(icon);
}
}
public static boolean handleRightClick(IFluidHandler tank, ForgeDirection side, EntityPlayer player, boolean fill, boolean drain) {
if (player == null) {
return false;
}
ItemStack current = player.inventory.getCurrentItem();
if (current != null) {
FluidStack liquid = FluidContainerRegistry.getFluidForFilledItem(current);
if (fill && liquid != null) {
int used = tank.fill(side, liquid, true);
if (used > 0) {
if (!player.capabilities.isCreativeMode) {
player.inventory.setInventorySlotContents(player.inventory.currentItem, StackUtils.consumeItem(current));
player.inventory.markDirty();
}
return true;
}
} else if (drain) {
FluidStack available = tank.drain(side, Integer.MAX_VALUE, false);
if (available != null) {
ItemStack filled = FluidContainerRegistry.fillFluidContainer(available, current);
liquid = FluidContainerRegistry.getFluidForFilledItem(filled);
if (liquid != null) {
if (current.stackSize > 1) {
if (!player.inventory.addItemStackToInventory(filled))
return false;
player.inventory.setInventorySlotContents(player.inventory.currentItem, StackUtils.consumeItem(current));
player.inventory.markDirty();
} else {
player.inventory.setInventorySlotContents(player.inventory.currentItem, StackUtils.consumeItem(current));
player.inventory.setInventorySlotContents(player.inventory.currentItem, filled);
player.inventory.markDirty();
}
tank.drain(side, liquid.amount, true);
return true;
}
}
}
}
return false;
}
public static void processContainers(IFluidHandler fluidHandler, IInventory inv, int inputSlot, int outputSlot, Fluid fluidToFill, boolean processFilled, boolean processEmpty) {
ItemStack input = inv.getStackInSlot(inputSlot);
if (input == null)
return;
if (processFilled && drainContainers(fluidHandler, inv, inputSlot, outputSlot))
return;
if (processEmpty && fluidToFill != null)
fillContainers(fluidHandler, inv, inputSlot, outputSlot, fluidToFill);
}
public static boolean fillContainers(IFluidHandler fluidHandler, IInventory inv, int inputSlot, int outputSlot, Fluid fluidToFill) {
return fillContainers(fluidHandler, inv, inputSlot, outputSlot, fluidToFill, true);
}
public static boolean fillContainers(IFluidHandler fluidHandler, IInventory inv, int inputSlot, int outputSlot, Fluid fluidToFill, boolean doFill) {
ItemStack input = inv.getStackInSlot(inputSlot);
ItemStack output = inv.getStackInSlot(outputSlot);
ItemStack filled = getFilledContainer(fluidToFill, input);
if (filled != null && (output == null || (output.stackSize < output.getMaxStackSize() && StackUtils.isIdenticalItem(filled, output)))) {
FluidStack fluidInContainer = getFluidStackInContainer(filled);
FluidStack drain = fluidHandler.drain(ForgeDirection.UNKNOWN, fluidInContainer, false);
if (drain != null && drain.amount == fluidInContainer.amount) {
if (doFill) {
fluidHandler.drain(ForgeDirection.UNKNOWN, fluidInContainer, true);
if (output == null)
inv.setInventorySlotContents(outputSlot, filled);
else
output.stackSize++;
inv.decrStackSize(inputSlot, 1);
}
return true;
}
}
return false;
}
public static boolean drainContainers(IFluidHandler fluidHandler, IInventory inv, int inputSlot, int outputSlot) {
ItemStack input = inv.getStackInSlot(inputSlot);
ItemStack output = inv.getStackInSlot(outputSlot);
if (input != null) {
FluidStack fluidInContainer = getFluidStackInContainer(input);
ItemStack emptyItem = input.getItem().getContainerItem(input);
if (fluidInContainer != null && (emptyItem == null || output == null || (output.stackSize < output.getMaxStackSize() && StackUtils.isIdenticalItem(output, emptyItem)))) {
int used = fluidHandler.fill(ForgeDirection.UNKNOWN, fluidInContainer, false);
if (used >= fluidInContainer.amount) {
fluidHandler.fill(ForgeDirection.UNKNOWN, fluidInContainer, true);
if (emptyItem != null)
if (output == null)
inv.setInventorySlotContents(outputSlot, emptyItem);
else
output.stackSize++;
inv.decrStackSize(inputSlot, 1);
return true;
}
}
}
return false;
}
public static ItemStack getFilledContainer(Fluid fluid, ItemStack empty) {
if (fluid == null || empty == null)
return null;
return FluidContainerRegistry.fillFluidContainer(new FluidStack(fluid, Integer.MAX_VALUE), empty);
}
public static FluidStack getFluidStackInContainer(ItemStack stack) {
return FluidContainerRegistry.getFluidForFilledItem(stack);
}
public static boolean containsFluidStack(ItemStack stack, FluidStack fluidStack) {
return FluidContainerRegistry.containsFluid(stack, fluidStack);
}
public static boolean containsFluid(ItemStack stack, Fluid fluid) {
return FluidContainerRegistry.containsFluid(stack, new FluidStack(fluid, 1));
}
}
@@ -10,25 +10,57 @@
******************************************************************************/
package forestry.core.utils;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.world.World;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.oredict.OreDictionary;
import forestry.api.recipes.RecipeManagers;
import forestry.core.config.Defaults;
import forestry.core.gui.ContainerDummy;
import forestry.core.interfaces.IDescriptiveRecipe;
import forestry.core.proxy.Proxies;
import net.minecraft.item.ItemStack;
public class RecipeUtil {
private static final Container DUMMY_CONTAINER = new ContainerDummy();
public static void injectLeveledRecipe(ItemStack resource, int fermentationValue, String output) {
if (RecipeManagers.fermenterManager == null)
return;
RecipeManagers.fermenterManager.addRecipe(resource, fermentationValue, 1.0f, LiquidHelper.getLiquid(output, 1), LiquidHelper.getLiquid(Defaults.LIQUID_WATER, 1));
RecipeManagers.fermenterManager.addRecipe(resource, fermentationValue, 1.0f, FluidRegistry.getFluidStack(output, 1), FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 1));
if (LiquidHelper.exists(Defaults.LIQUID_JUICE))
RecipeManagers.fermenterManager.addRecipe(resource, fermentationValue, 1.5f, LiquidHelper.getLiquid(output, 1), LiquidHelper.getLiquid(Defaults.LIQUID_JUICE, 1));
if (FluidRegistry.isFluidRegistered(Defaults.LIQUID_JUICE))
RecipeManagers.fermenterManager.addRecipe(resource, fermentationValue, 1.5f, FluidRegistry.getFluidStack(output, 1), FluidRegistry.getFluidStack(Defaults.LIQUID_JUICE, 1));
if (LiquidHelper.exists(Defaults.LIQUID_HONEY))
RecipeManagers.fermenterManager.addRecipe(resource, fermentationValue, 1.5f, LiquidHelper.getLiquid(output, 1), LiquidHelper.getLiquid(Defaults.LIQUID_HONEY, 1));
if (FluidRegistry.isFluidRegistered(Defaults.LIQUID_HONEY))
RecipeManagers.fermenterManager.addRecipe(resource, fermentationValue, 1.5f, FluidRegistry.getFluidStack(output, 1), FluidRegistry.getFluidStack(Defaults.LIQUID_HONEY, 1));
}
/**
* Returns a list of the ore dictionary names if they exist.
* Returns a list containing itemStack if there are no ore dictionary names.
* Used for creating recipes that should accept equivalent itemStacks, based on the ore dictionary.
*/
public static List getOreDictRecipeEquivalents(ItemStack itemStack) {
int[] oreDictIds = OreDictionary.getOreIDs(itemStack);
List<String> oreDictNames = new ArrayList<String>(oreDictIds.length);
for (int oreId : oreDictIds) {
String oreDictName = OreDictionary.getOreName(oreId);
oreDictNames.add(oreDictName);
}
if (oreDictNames.isEmpty())
return Collections.singletonList(itemStack);
return oreDictNames;
}
public static Object[] getCraftingRecipeAsArray(Object rec) {
@@ -67,4 +99,53 @@ public class RecipeUtil {
result[9] = output;
return result;
}
public static boolean canCraftRecipe(World world, ItemStack[] recipeItems, ItemStack recipeOutput, ItemStack[] availableItems) {
// Need at least one matched set
if (StackUtils.containsSets(recipeItems, availableItems, true, true) == 0)
return false;
// Check that it doesn't make a different recipe.
// For example:
// Wood Logs are all ore dictionary equivalent with each other,
// but an Oak Log shouldn't be able to make Ebony Wood Planks
// because it makes Oak Wood Planks using the same recipe.
// Strategy:
// Create a fake crafting inventory using items we have in availableItems
// in place of the ones in the saved crafting inventory.
// Check that the recipe it makes is the same as the currentRecipe.
InventoryCrafting crafting = new InventoryCrafting(DUMMY_CONTAINER, 3, 3);
ItemStack[] stockCopy = StackUtils.condenseStacks(availableItems);
for (int slot = 0; slot < recipeItems.length; slot++) {
ItemStack recipeStack = recipeItems[slot];
if (recipeStack == null)
continue;
// Use crafting equivalent (not oredict) items first
for (ItemStack stockStack : stockCopy) {
if (stockStack.stackSize > 0 && StackUtils.isCraftingEquivalent(recipeStack, stockStack, false, false)) {
ItemStack stack = new ItemStack(stockStack.getItem(), 1, stockStack.getItemDamage());
stockStack.stackSize--;
crafting.setInventorySlotContents(slot, stack);
break;
}
}
// Use oredict items if crafting equivalent items aren't available
if (crafting.getStackInSlot(slot) == null) {
for (ItemStack stockStack : stockCopy) {
if (stockStack.stackSize > 0 && StackUtils.isCraftingEquivalent(recipeStack, stockStack, true, true)) {
ItemStack stack = new ItemStack(stockStack.getItem(), 1, stockStack.getItemDamage());
stockStack.stackSize--;
crafting.setInventorySlotContents(slot, stack);
break;
}
}
}
}
ItemStack output = CraftingManager.getInstance().findMatchingRecipe(crafting, world);
return ItemStack.areItemStacksEqual(output, recipeOutput);
}
}
@@ -33,12 +33,12 @@ public class ShapedRecipeCustom implements IDescriptiveRecipe {
private final int width;
private final int height;
private final Object ingredients[];
private final Object[] ingredients;
private final ItemStack product;
private boolean preserveNBT = false;
public ShapedRecipeCustom(int width, int height, Object ingredients[], ItemStack product) {
public ShapedRecipeCustom(int width, int height, Object[] ingredients, ItemStack product) {
this.width = width;
this.height = height;
this.ingredients = ingredients;
@@ -397,27 +397,6 @@ public class StackUtils {
}
public static void replenishByContainer(TileForestry tile, ItemStack inventoryStack, StandardTank tank) {
FluidContainerData container = LiquidHelper.getLiquidContainer(inventoryStack);
replenishByContainer(tile, inventoryStack, container, tank);
}
public static ItemStack replenishByContainer(TileForestry tile, ItemStack inventoryStack, FluidContainerData container, StandardTank tank) {
if (container == null)
return inventoryStack;
if (tank.fill(container.fluid, false) >= container.fluid.amount) {
tank.fill(container.fluid, true);
if (container.filledContainer != null && container.filledContainer.getItem().hasContainerItem(container.filledContainer))
inventoryStack = container.emptyContainer.copy();
else
inventoryStack.stackSize--;
tile.sendNetworkUpdate();
}
return inventoryStack;
}
public static ItemStack copyWithRandomSize(ItemStack template, int max, Random rand) {
int size = rand.nextInt(max);
ItemStack created = template.copy();
@@ -16,16 +16,17 @@ import forestry.api.fuels.EngineBronzeFuel;
import forestry.api.fuels.FuelManager;
import forestry.core.config.Config;
import forestry.core.config.Defaults;
import forestry.core.fluids.FluidHelper;
import forestry.core.fluids.TankManager;
import forestry.core.fluids.tanks.FilteredTank;
import forestry.core.fluids.tanks.StandardTank;
import forestry.core.gadgets.Engine;
import forestry.core.gadgets.TileBase;
import forestry.core.interfaces.ILiquidTankContainer;
import forestry.core.inventory.TileInventoryAdapter;
import forestry.core.network.GuiId;
import forestry.core.network.PacketPayload;
import forestry.core.utils.LiquidHelper;
import forestry.core.inventory.TileInventoryAdapter;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.ICrafting;
@@ -102,35 +103,15 @@ public class EngineBronze extends Engine implements ISidedInventory, ILiquidTank
@Override
public void updateServerSide() {
super.updateServerSide();
TileInventoryAdapter inventory = getInternalInventory();
// Check if we have suitable items waiting in the item slot
if (inventory.getStackInSlot(SLOT_CAN) != null) {
FluidContainerData container = LiquidHelper.getLiquidContainer(inventory.getStackInSlot(SLOT_CAN));
if (container != null) {
StandardTank tank = null;
if (heatingTank.accepts(container.fluid.getFluid()))
tank = heatingTank;
else if (fuelTank.accepts(container.fluid.getFluid()))
tank = fuelTank;
if (tank != null) {
inventory.setInventorySlotContents(SLOT_CAN, replenishByContainer(inventory.getStackInSlot(SLOT_CAN), container, tank));
if (inventory.getStackInSlot(SLOT_CAN).stackSize <= 0)
inventory.setInventorySlotContents(0, null);
}
}
}
if (worldObj.getTotalWorldTime() % 20 * 10 != 0)
return;
TileInventoryAdapter inventory = getInternalInventory();
// Check if we have suitable items waiting in the item slot
if (inventory.getStackInSlot(SLOT_CAN) != null)
FluidHelper.drainContainers(tankManager, inventory, SLOT_CAN);
if (getHeatLevel() <= 0.2 && heatingTank.getFluidAmount() <= 0)
setErrorState(EnumErrorCode.NOHEAT);
else if (burnTime <= 0 && fuelTank.getFluidAmount() <= 0)
@@ -432,7 +413,7 @@ public class EngineBronze extends Engine implements ISidedInventory, ILiquidTank
@Override
public boolean isItemValidForSlot(int slotIndex, ItemStack itemstack) {
if (slotIndex == SLOT_CAN) {
FluidStack fluid = LiquidHelper.getFluidStackInContainer(itemstack);
FluidStack fluid = FluidHelper.getFluidStackInContainer(itemstack);
if (fluid == null || fluid.amount <= 0)
return false;
return fuelTank.accepts(fluid.getFluid()) || heatingTank.accepts(fluid.getFluid());
@@ -18,7 +18,6 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData;
import net.minecraftforge.fluids.FluidStack;
import ic2.api.energy.prefab.BasicSource;
@@ -29,22 +28,23 @@ import forestry.api.fuels.GeneratorFuel;
import forestry.api.core.EnumErrorCode;
import forestry.core.config.Config;
import forestry.core.config.Defaults;
import forestry.core.fluids.FluidHelper;
import forestry.core.fluids.tanks.FilteredTank;
import forestry.core.fluids.TankManager;
import forestry.core.gadgets.TileBase;
import forestry.core.interfaces.ILiquidTankContainer;
import forestry.core.interfaces.IRenderableMachine;
import forestry.core.inventory.TileInventoryAdapter;
import forestry.core.network.EntityNetData;
import forestry.core.network.GuiId;
import forestry.core.utils.EnumTankLevel;
import forestry.core.inventory.TileInventoryAdapter;
import forestry.core.utils.LiquidHelper;
import forestry.core.utils.StackUtils;
import forestry.core.utils.Utils;
import forestry.plugins.PluginIC2;
import net.minecraft.inventory.ISidedInventory;
import net.minecraftforge.fluids.FluidTankInfo;
public class MachineGenerator extends TileBase implements ISidedInventory, ILiquidTankContainer, IRenderableMachine {
// / CONSTANTS
@@ -122,16 +122,8 @@ public class MachineGenerator extends TileBase implements ISidedInventory, ILiqu
// Check inventory slots for fuel
// Check if we have suitable items waiting in the item slot
TileInventoryAdapter inventory = getInternalInventory();
if (inventory.getStackInSlot(SLOT_CAN) != null) {
FluidContainerData container = LiquidHelper.getLiquidContainer(inventory.getStackInSlot(SLOT_CAN));
if (container != null)
if (resourceTank.accepts(container.fluid.getFluid())) {
inventory.setInventorySlotContents(SLOT_CAN, StackUtils.replenishByContainer(this, inventory.getStackInSlot(SLOT_CAN), container, resourceTank));
if (inventory.getStackInSlot(SLOT_CAN).stackSize <= 0)
inventory.setInventorySlotContents(SLOT_CAN, null);
}
}
if (inventory.getStackInSlot(SLOT_CAN) != null)
FluidHelper.drainContainers(tankManager, inventory, SLOT_CAN);
// No work to be done if IC2 is unavailable.
if (ic2EnergySource == null) {
@@ -257,11 +249,8 @@ public class MachineGenerator extends TileBase implements ISidedInventory, ILiqu
return false;
if (slotIndex == SLOT_CAN) {
FluidContainerData container = LiquidHelper.getLiquidContainer(stack);
if (container == null)
return false;
return container.fluid != null && FuelManager.generatorFuel.containsKey(container.fluid.getFluid());
Fluid fluid = FluidHelper.getFluidInContainer(stack);
return fluid != null && FuelManager.generatorFuel.containsKey(fluid);
}
return false;
}
@@ -17,6 +17,7 @@ import forestry.api.core.ForestryAPI;
import forestry.api.recipes.ICraftingProvider;
import forestry.core.config.Config;
import forestry.core.config.Defaults;
import forestry.core.fluids.FluidHelper;
import forestry.core.fluids.TankManager;
import forestry.core.fluids.tanks.StandardTank;
import forestry.core.gadgets.TileBase;
@@ -226,13 +227,7 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq
// Check if we have suitable items waiting in the item slot
if (inventory.getStackInSlot(SLOT_CAN) != null) {
FluidContainerData container = LiquidHelper.getLiquidContainer(inventory.getStackInSlot(SLOT_CAN));
if (container != null && RecipeManager.isInput(container.fluid)) {
inventory.setInventorySlotContents(SLOT_CAN, StackUtils.replenishByContainer(this, inventory.getStackInSlot(SLOT_CAN), container, resourceTank));
if (inventory.getStackInSlot(SLOT_CAN).stackSize <= 0)
inventory.setInventorySlotContents(SLOT_CAN, null);
}
FluidHelper.drainContainers(tankManager, inventory, SLOT_CAN);
}
checkRecipe();
@@ -444,9 +439,15 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq
if (slotIndex == SLOT_RESOURCE)
return FluidContainerRegistry.isEmptyContainer(itemstack);
<<<<<<< HEAD
if (slotIndex == SLOT_CAN) {
FluidContainerData container = LiquidHelper.getLiquidContainer(itemstack);
return container != null && RecipeManager.isInput(container.fluid);
=======
if(slotIndex == SLOT_CAN) {
FluidStack fluidStack = FluidHelper.getFluidStackInContainer(itemstack);
return RecipeManager.isInput(fluidStack);
>>>>>>> 5ea4770a2d5fef57cf52fb7c81f33671f8086740
}
return false;
@@ -10,28 +10,11 @@
******************************************************************************/
package forestry.factory.gadgets;
import forestry.api.core.ForestryAPI;
import forestry.api.recipes.ICarpenterManager;
import forestry.api.core.EnumErrorCode;
import forestry.core.config.Config;
import forestry.core.config.Defaults;
import forestry.core.config.ForestryItem;
import forestry.core.fluids.TankManager;
import forestry.core.fluids.tanks.FilteredTank;
import forestry.core.gadgets.TileBase;
import forestry.core.gadgets.TilePowered;
import forestry.core.interfaces.ILiquidTankContainer;
import forestry.core.network.EntityNetData;
import forestry.core.network.GuiId;
import forestry.core.proxy.Proxies;
import forestry.core.utils.EnumTankLevel;
import forestry.core.inventory.InventoryAdapter;
import forestry.core.utils.LiquidHelper;
import forestry.core.utils.ShapedRecipeCustom;
import forestry.core.utils.StackUtils;
import forestry.core.inventory.TileInventoryAdapter;
import forestry.core.utils.Utils;
import forestry.factory.gui.ContainerCarpenter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.ICrafting;
@@ -42,17 +25,41 @@ import net.minecraft.item.crafting.IRecipe;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import forestry.api.core.EnumErrorCode;
import forestry.api.core.ForestryAPI;
import forestry.api.recipes.ICarpenterManager;
import forestry.core.config.Config;
import forestry.core.config.Defaults;
import forestry.core.config.ForestryItem;
import forestry.core.fluids.FluidHelper;
import forestry.core.fluids.TankManager;
import forestry.core.fluids.tanks.FilteredTank;
import forestry.core.gadgets.TileBase;
import forestry.core.gadgets.TilePowered;
import forestry.core.interfaces.ILiquidTankContainer;
import forestry.core.network.EntityNetData;
import forestry.core.network.GuiId;
import forestry.core.proxy.Proxies;
import forestry.core.utils.EnumTankLevel;
<<<<<<< HEAD
import forestry.core.inventory.InventoryAdapter;
import forestry.core.utils.LiquidHelper;
=======
import forestry.core.utils.InventoryAdapter;
>>>>>>> 5ea4770a2d5fef57cf52fb7c81f33671f8086740
import forestry.core.utils.ShapedRecipeCustom;
import forestry.core.utils.StackUtils;
import forestry.core.inventory.TileInventoryAdapter;
import forestry.core.utils.Utils;
import forestry.factory.gui.ContainerCarpenter;
public class MachineCarpenter extends TilePowered implements ISidedInventory, ILiquidTankContainer {
@@ -144,16 +151,28 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL
@Override
public void addCrating(ItemStack itemStack) {
ItemStack uncrated = ((forestry.core.items.ItemCrated) itemStack.getItem()).getContained(itemStack);
<<<<<<< HEAD
addRecipe(Defaults.CARPENTER_CRATING_CYCLES, LiquidHelper.getLiquid(Defaults.LIQUID_WATER, Defaults.CARPENTER_CRATING_LIQUID_QUANTITY),
ForestryItem.crate.getItemStack(), itemStack, new Object[]{"###", "###", "###", '#', uncrated});
addRecipe(null, new ItemStack(uncrated.getItem(), 9, uncrated.getItemDamage()), new Object[]{"#", Character.valueOf('#'), itemStack});
=======
addRecipe(Defaults.CARPENTER_CRATING_CYCLES, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, Defaults.CARPENTER_CRATING_LIQUID_QUANTITY),
ForestryItem.crate.getItemStack(), itemStack, new Object[] { "###", "###", "###", '#', uncrated });
addRecipe(null, new ItemStack(uncrated.getItem(), 9, uncrated.getItemDamage()), new Object[] { "#", '#', itemStack });
>>>>>>> 5ea4770a2d5fef57cf52fb7c81f33671f8086740
}
@Override
public void addCrating(String toCrate, ItemStack unpack, ItemStack crated) {
<<<<<<< HEAD
addRecipe(Defaults.CARPENTER_CRATING_CYCLES, LiquidHelper.getLiquid(Defaults.LIQUID_WATER, Defaults.CARPENTER_CRATING_LIQUID_QUANTITY),
ForestryItem.crate.getItemStack(), crated, new Object[]{"###", "###", "###", '#', toCrate});
addRecipe(null, new ItemStack(unpack.getItem(), 9, unpack.getItemDamage()), new Object[]{"#", '#', crated});
=======
addRecipe(Defaults.CARPENTER_CRATING_CYCLES, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, Defaults.CARPENTER_CRATING_LIQUID_QUANTITY),
ForestryItem.crate.getItemStack(), crated, new Object[] { "###", "###", "###", '#', toCrate });
addRecipe(null, new ItemStack(unpack.getItem(), 9, unpack.getItemDamage()), new Object[] { "#", '#', crated });
>>>>>>> 5ea4770a2d5fef57cf52fb7c81f33671f8086740
}
@Override
@@ -320,22 +339,15 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL
@Override
public void updateServerSide() {
if (worldObj.getTotalWorldTime() % 20 * 10 != 0)
if (worldObj.getTotalWorldTime() % 20 != 0)
return;
TileInventoryAdapter accessibleInventory = getInternalInventory();
// Check if we have suitable items waiting in the item slot
if (accessibleInventory.getStackInSlot(SLOT_CAN_INPUT) != null) {
FluidContainerData container = LiquidHelper.getLiquidContainer(accessibleInventory.getStackInSlot(SLOT_CAN_INPUT));
if (container != null && RecipeManager.isResourceLiquid(container.fluid)) {
accessibleInventory.setInventorySlotContents(SLOT_CAN_INPUT,
StackUtils.replenishByContainer(this, accessibleInventory.getStackInSlot(SLOT_CAN_INPUT), container, resourceTank));
if (accessibleInventory.getStackInSlot(SLOT_CAN_INPUT).stackSize <= 0)
accessibleInventory.setInventorySlotContents(SLOT_CAN_INPUT, null);
}
FluidHelper.drainContainers(tankManager, accessibleInventory, SLOT_CAN_INPUT);
}
if (worldObj.getTotalWorldTime() % 40 * 10 != 0)
if (worldObj.getTotalWorldTime() % 40 != 0)
return;
if (currentRecipe == null) {
@@ -10,28 +10,14 @@
******************************************************************************/
package forestry.factory.gadgets;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import forestry.api.core.EnumErrorCode;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.ICrafting;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import forestry.api.core.ForestryAPI;
import forestry.api.core.ISpecialInventory;
import forestry.api.recipes.IFabricatorManager;
import forestry.core.config.Defaults;
import forestry.core.fluids.TankManager;
import forestry.core.fluids.tanks.FilteredTank;
import forestry.core.fluids.tanks.StandardTank;
import forestry.core.gadgets.TileBase;
import forestry.core.gadgets.TilePowered;
import forestry.core.interfaces.ICrafter;
@@ -39,20 +25,38 @@ import forestry.core.interfaces.ICraftingPlan;
import forestry.core.interfaces.ILiquidTankContainer;
import forestry.core.network.GuiId;
import forestry.core.proxy.Proxies;
<<<<<<< HEAD
import forestry.core.fluids.tanks.StandardTank;
import forestry.core.fluids.TankManager;
import forestry.core.fluids.tanks.FilteredTank;
import forestry.core.inventory.InventoryAdapter;
=======
import forestry.core.utils.InventoryAdapter;
>>>>>>> 5ea4770a2d5fef57cf52fb7c81f33671f8086740
import forestry.core.utils.ShapedRecipeCustom;
import forestry.core.utils.StackUtils;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.ICrafting;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
public class MachineFabricator extends TilePowered implements ICrafter, ISpecialInventory, ILiquidTankContainer {
/* RECIPE MANAGMENT */
public static class Recipe {
private final ItemStack plan;
private final FluidStack molten;
private final ShapedRecipeCustom internal;
@@ -62,20 +66,8 @@ public class MachineFabricator extends TilePowered implements ICrafter, ISpecial
this.internal = internal;
}
public boolean matches(ItemStack plan) {
if (this.plan == null)
return true;
else if (plan == null)
return false;
if (this.plan.getItemDamage() == Defaults.WILDCARD)
return plan.getItem() == this.plan.getItem();
else
return plan.isItemEqual(this.plan);
}
public boolean matches(ItemStack plan, ItemStack[][] resources) {
if (!this.matches(plan))
if (this.plan != null && !StackUtils.isCraftingEquivalent(this.plan, plan))
return false;
return internal.matches(resources);
@@ -106,9 +98,9 @@ public class MachineFabricator extends TilePowered implements ICrafter, ISpecial
}
public static class Smelting {
ItemStack resource;
FluidStack product;
int meltingPoint;
private final ItemStack resource;
private final FluidStack product;
private final int meltingPoint;
public Smelting(ItemStack resource, FluidStack molten, int meltingPoint) {
if(resource == null)
@@ -121,10 +113,6 @@ public class MachineFabricator extends TilePowered implements ICrafter, ISpecial
this.meltingPoint = meltingPoint;
}
public boolean matches(ItemStack resource) {
return this.resource.isItemEqual(resource);
}
public boolean matches(FluidStack product) {
return this.product.isFluidEqual(product);
}
@@ -156,30 +144,6 @@ public class MachineFabricator extends TilePowered implements ICrafter, ISpecial
smeltings.add(new Smelting(resource, molten, meltingPoint));
}
public static Recipe findMatchingRecipe(ItemStack plan) {
for (Recipe recipe : recipes)
if (recipe.matches(plan))
return recipe;
return null;
}
public static Recipe findMatchingRecipeIfSmelted(ItemStack plan, FluidStack liquid, ItemStack itemToMelt, ItemStack[] resources) {
Smelting smelting = findMatchingSmelting(itemToMelt);
if (smelting == null || (liquid != null && !smelting.matches(liquid)))
return findMatchingRecipe(plan, liquid, resources);
FluidStack liquidIfSmelted;
if (liquid != null) {
liquidIfSmelted = liquid.copy();
liquidIfSmelted.amount += smelting.getProduct().amount * itemToMelt.stackSize;
} else {
liquidIfSmelted = smelting.getProduct().copy();
liquidIfSmelted.amount *= itemToMelt.stackSize;
}
return findMatchingRecipe(plan, liquidIfSmelted, resources);
}
public static Recipe findMatchingRecipe(ItemStack plan, FluidStack liquid, ItemStack[] resources) {
ItemStack[][] gridResources = new ItemStack[3][3];
for (int i = 0; i < 3; i++)
@@ -207,7 +171,7 @@ public class MachineFabricator extends TilePowered implements ICrafter, ISpecial
return null;
for (Smelting smelting : smeltings)
if (smelting.matches(resource))
if (StackUtils.isCraftingEquivalent(smelting.resource, resource))
return smelting;
return null;
@@ -233,7 +197,6 @@ public class MachineFabricator extends TilePowered implements ICrafter, ISpecial
return recipeList;
}
}
/* CONSTANTS */
@@ -243,6 +206,7 @@ public class MachineFabricator extends TilePowered implements ICrafter, ISpecial
public static final short SLOT_PLAN = 1;
public static final short SLOT_RESULT = 2;
public static final short SLOT_CRAFTING_1 = 3;
public static final short SLOT_CRAFTING_COUNT = 9;
public static final short SLOT_INVENTORY_1 = 12;
public static final short SLOT_INVENTORY_COUNT = 18;
@@ -372,20 +336,10 @@ public class MachineFabricator extends TilePowered implements ICrafter, ISpecial
this.heat--;
}
public Object[] getPlan() {
if (inventory.getStackInSlot(SLOT_PLAN) == null)
return null;
Recipe myRecipe = RecipeManager.findMatchingRecipe(inventory.getStackInSlot(SLOT_PLAN));
if (myRecipe == null)
return null;
return myRecipe.internal.getIngredients();
}
private Recipe getRecipe() {
return RecipeManager.findMatchingRecipe(inventory.getStackInSlot(SLOT_PLAN), moltenTank.getFluid(),
inventory.getStacks(SLOT_CRAFTING_1, 9));
ItemStack plan = inventory.getStackInSlot(SLOT_PLAN);
ItemStack[] crafting = inventory.getStacks(SLOT_CRAFTING_1, SLOT_CRAFTING_COUNT);
return RecipeManager.findMatchingRecipe(plan, moltenTank.getFluid(), crafting);
}
/* ICRAFTER */
@@ -416,8 +370,8 @@ public class MachineFabricator extends TilePowered implements ICrafter, ISpecial
FluidStack liquid = myRecipe.molten;
// Remove resources
if (removeFromInventory(1, inventory.getStacks(SLOT_CRAFTING_1, 9), player, false)) {
removeFromInventory(1, inventory.getStacks(SLOT_CRAFTING_1, 9), player, true);
if (removeFromInventory(1, inventory.getStacks(SLOT_CRAFTING_1, SLOT_CRAFTING_COUNT), player, false)) {
removeFromInventory(1, inventory.getStacks(SLOT_CRAFTING_1, SLOT_CRAFTING_COUNT), player, true);
moltenTank.drain(liquid.amount, true);
} else if (consumeRecipe) {
removeFromCraftMatrix(myRecipe);
@@ -463,9 +417,16 @@ public class MachineFabricator extends TilePowered implements ICrafter, ISpecial
@Override
public boolean hasWork() {
Recipe recipe = RecipeManager.findMatchingRecipeIfSmelted(inventory.getStackInSlot(SLOT_PLAN), moltenTank.getFluid(), inventory.getStackInSlot(SLOT_METAL),
inventory.getStacks(SLOT_CRAFTING_1, 9));
return recipe != null;
ItemStack itemToMelt = inventory.getStackInSlot(SLOT_METAL);
Smelting smelting = RecipeManager.findMatchingSmelting(itemToMelt);
FluidStack liquid = smelting.getProduct();
if (moltenTank.fill(liquid, false) > 0)
return true;
ItemStack plan = inventory.getStackInSlot(SLOT_PLAN);
ItemStack[] resources = inventory.getStacks(SLOT_CRAFTING_1, SLOT_CRAFTING_COUNT);
return RecipeManager.findMatchingRecipe(plan, liquid, resources) != null;
}
public int getHeatScaled(int i) {
@@ -10,8 +10,29 @@
******************************************************************************/
package forestry.factory.gadgets;
import buildcraft.api.statements.ITriggerExternal;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.ICrafting;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
import cpw.mods.fml.common.Optional;
import forestry.api.core.EnumErrorCode;
import forestry.api.core.ForestryAPI;
import forestry.api.fuels.FuelManager;
@@ -19,6 +40,7 @@ import forestry.api.recipes.IFermenterManager;
import forestry.api.recipes.IVariableFermentable;
import forestry.core.config.Config;
import forestry.core.config.Defaults;
import forestry.core.fluids.FluidHelper;
import forestry.core.fluids.TankManager;
import forestry.core.fluids.tanks.FilteredTank;
import forestry.core.fluids.tanks.StandardTank;
@@ -28,30 +50,17 @@ import forestry.core.interfaces.ILiquidTankContainer;
import forestry.core.network.EntityNetData;
import forestry.core.network.GuiId;
import forestry.core.utils.EnumTankLevel;
<<<<<<< HEAD
import forestry.core.inventory.InventoryAdapter;
import forestry.core.utils.LiquidHelper;
import forestry.core.utils.StackUtils;
=======
import forestry.core.utils.InventoryAdapter;
>>>>>>> 5ea4770a2d5fef57cf52fb7c81f33671f8086740
import forestry.core.utils.Utils;
import forestry.factory.triggers.FactoryTriggers;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.ICrafting;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map;
import buildcraft.api.statements.ITriggerExternal;
public class MachineFermenter extends TilePowered implements ISidedInventory, ILiquidTankContainer {
@@ -135,7 +144,7 @@ public class MachineFermenter extends TilePowered implements ISidedInventory, IL
@Override
public void addRecipe(ItemStack resource, int fermentationValue, float modifier, FluidStack output) {
addRecipe(resource, fermentationValue, modifier, output, LiquidHelper.getLiquid(Defaults.LIQUID_WATER, 1000));
addRecipe(resource, fermentationValue, modifier, output, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 1000));
}
public static Recipe findMatchingRecipe(ItemStack res, FluidStack liqu) {
@@ -161,6 +170,8 @@ public class MachineFermenter extends TilePowered implements ISidedInventory, IL
}
public static boolean isLiquidResource(FluidStack liquid) {
if (liquid == null)
return false;
return recipeFluidInputs.contains(liquid.getFluid());
}
@@ -247,33 +258,20 @@ public class MachineFermenter extends TilePowered implements ISidedInventory, IL
@Override
public void updateServerSide() {
// Check if we have suitable items waiting in the item slot
if (inventory.getStackInSlot(SLOT_INPUT) != null) {
FluidContainerData container = LiquidHelper.getLiquidContainer(inventory.getStackInSlot(SLOT_INPUT));
if (container != null && RecipeManager.isLiquidResource(container.fluid)) {
inventory.setInventorySlotContents(SLOT_INPUT, StackUtils.replenishByContainer(this, inventory.getStackInSlot(SLOT_INPUT), container, resourceTank));
if (inventory.getStackInSlot(SLOT_INPUT).stackSize <= 0)
inventory.setInventorySlotContents(SLOT_INPUT, null);
}
}
// Can/capsule input/output needs to be handled here.
if (inventory.getStackInSlot(SLOT_CAN_INPUT) != null) {
FluidContainerData container = LiquidHelper.getEmptyContainer(inventory.getStackInSlot(SLOT_CAN_INPUT), productTank.getFluid());
if (container != null) {
inventory.setInventorySlotContents(SLOT_CAN_OUTPUT, bottleIntoContainer(inventory.getStackInSlot(SLOT_CAN_INPUT), inventory.getStackInSlot(SLOT_CAN_OUTPUT), container,
productTank));
if (inventory.getStackInSlot(SLOT_CAN_INPUT).stackSize <= 0)
inventory.setInventorySlotContents(SLOT_CAN_INPUT, null);
}
}
if (worldObj.getTotalWorldTime() % 20 * 10 != 0)
if (worldObj.getTotalWorldTime() % 20 != 0)
return;
// Check if we have suitable items waiting in the item slot
if (inventory.getStackInSlot(SLOT_INPUT) != null) {
FluidHelper.drainContainers(tankManager, inventory, SLOT_INPUT);
}
// Can/capsule input/output needs to be handled here.
if (inventory.getStackInSlot(SLOT_CAN_INPUT) != null) {
FluidStack fluidStack = productTank.getFluid();
if (fluidStack != null)
FluidHelper.fillContainers(tankManager, inventory, SLOT_CAN_INPUT, SLOT_CAN_OUTPUT, fluidStack.getFluid());
}
if (RecipeManager.findMatchingRecipe(inventory.getStackInSlot(SLOT_RESOURCE), resourceTank.getFluid()) != null) {
if (resourceTank.getFluidAmount() < fuelCurrentFerment)
@@ -550,11 +548,11 @@ public class MachineFermenter extends TilePowered implements ISidedInventory, IL
if (slotIndex == SLOT_INPUT) {
FluidContainerData container = LiquidHelper.getLiquidContainer(itemstack);
return container != null && RecipeManager.isLiquidResource(container.fluid);
FluidStack fluidStack = FluidHelper.getFluidStackInContainer(itemstack);
return RecipeManager.isLiquidResource(fluidStack);
}
if (slotIndex == SLOT_CAN_INPUT && LiquidHelper.isEmptyContainer(itemstack)) {
if (slotIndex == SLOT_CAN_INPUT && FluidHelper.isEmptyContainer(itemstack)) {
return true;
}
if (slotIndex == SLOT_FUEL && FuelManager.fermenterFuel.containsKey(itemstack))
@@ -18,6 +18,7 @@ import forestry.api.fuels.MoistenerFuel;
import forestry.api.recipes.IMoistenerManager;
import forestry.core.config.Config;
import forestry.core.config.Defaults;
import forestry.core.fluids.FluidHelper;
import forestry.core.fluids.TankManager;
import forestry.core.fluids.tanks.FilteredTank;
import forestry.core.gadgets.TileBase;
@@ -26,8 +27,12 @@ import forestry.core.interfaces.IRenderableMachine;
import forestry.core.network.EntityNetData;
import forestry.core.network.GuiId;
import forestry.core.utils.EnumTankLevel;
<<<<<<< HEAD
import forestry.core.inventory.InventoryAdapter;
import forestry.core.utils.LiquidHelper;
=======
import forestry.core.utils.InventoryAdapter;
>>>>>>> 5ea4770a2d5fef57cf52fb7c81f33671f8086740
import forestry.core.utils.StackUtils;
import forestry.core.utils.Utils;
import net.minecraft.entity.player.EntityPlayer;
@@ -38,7 +43,6 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
@@ -204,13 +208,7 @@ public class MachineMoistener extends TileBase implements ISpecialInventory, ISi
// Check if we have suitable water container waiting in the item slot
if (inventory.getStackInSlot(SLOT_PRODUCT) != null) {
FluidContainerData container = LiquidHelper.getLiquidContainer(inventory.getStackInSlot(SLOT_PRODUCT));
if (container != null && resourceTank.accepts(container.fluid.getFluid())) {
inventory.setInventorySlotContents(SLOT_PRODUCT, StackUtils.replenishByContainer(this, inventory.getStackInSlot(SLOT_PRODUCT), container, resourceTank));
if (inventory.getStackInSlot(SLOT_PRODUCT).stackSize <= 0)
inventory.setInventorySlotContents(SLOT_PRODUCT, null);
}
FluidHelper.drainContainers(tankManager, inventory, SLOT_PRODUCT);
}
// Let's get to work
@@ -620,8 +618,8 @@ public class MachineMoistener extends TileBase implements ISpecialInventory, ISi
@Override
public int addItem(ItemStack stack, boolean doAdd, ForgeDirection from) {
FluidContainerData container = LiquidHelper.getLiquidContainer(stack);
if (container != null && resourceTank.accepts(container.fluid.getFluid())) {
Fluid fluid = FluidHelper.getFluidInContainer(stack);
if (fluid != null && resourceTank.accepts(fluid)) {
return inventory.addStack(stack, SLOT_PRODUCT, 1, false, doAdd);
}
@@ -10,21 +10,6 @@
******************************************************************************/
package forestry.factory.gadgets;
import forestry.api.core.BiomeHelper;
import forestry.api.core.EnumErrorCode;
import forestry.api.core.ForestryAPI;
import forestry.core.config.Config;
import forestry.core.config.Defaults;
import forestry.core.fluids.TankManager;
import forestry.core.fluids.tanks.FilteredTank;
import forestry.core.gadgets.TileBase;
import forestry.core.interfaces.ILiquidTankContainer;
import forestry.core.network.GuiId;
import forestry.core.utils.Fluids;
import forestry.core.inventory.InventoryAdapter;
import forestry.core.utils.LiquidHelper;
import forestry.core.utils.StackUtils;
import forestry.core.utils.Utils;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.ICrafting;
@@ -32,18 +17,40 @@ import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
import forestry.api.core.BiomeHelper;
import forestry.api.core.EnumErrorCode;
import forestry.api.core.ForestryAPI;
import forestry.core.config.Config;
import forestry.core.config.Defaults;
import forestry.core.fluids.FluidHelper;
import forestry.core.fluids.TankManager;
import forestry.core.fluids.tanks.FilteredTank;
import forestry.core.gadgets.TileBase;
import forestry.core.interfaces.ILiquidTankContainer;
import forestry.core.network.GuiId;
import forestry.core.utils.Fluids;
<<<<<<< HEAD
import forestry.core.inventory.InventoryAdapter;
import forestry.core.utils.LiquidHelper;
=======
import forestry.core.utils.InventoryAdapter;
>>>>>>> 5ea4770a2d5fef57cf52fb7c81f33671f8086740
import forestry.core.utils.StackUtils;
import forestry.core.utils.Utils;
public class MachineRaintank extends TileBase implements ISidedInventory, ILiquidTankContainer {
/* CONSTANTS */
public static final short SLOT_RESOURCE = 0;
public static final short SLOT_PRODUCT = 1;
private static final FluidStack STACK_WATER = LiquidHelper.getLiquid(Defaults.LIQUID_WATER, Defaults.RAINTANK_AMOUNT_PER_UPDATE);
private static final FluidStack STACK_WATER = FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, Defaults.RAINTANK_AMOUNT_PER_UPDATE);
/* MEMBER */
public FilteredTank resourceTank;
@@ -132,7 +139,7 @@ public class MachineRaintank extends TileBase implements ISidedInventory, ILiqui
tryToStartFillling();
else {
fillingTime--;
if (fillingTime <= 0 && LiquidHelper.fillContainers(this, inventory, SLOT_RESOURCE, SLOT_PRODUCT, Fluids.WATER.get()))
if (fillingTime <= 0 && FluidHelper.fillContainers(tankManager, inventory, SLOT_RESOURCE, SLOT_PRODUCT, Fluids.WATER.get()))
fillingTime = 0;
}
}
@@ -143,7 +150,7 @@ public class MachineRaintank extends TileBase implements ISidedInventory, ILiqui
private void tryToStartFillling() {
// Nothing to do if no empty cans are available
if (!LiquidHelper.fillContainers(this, inventory, SLOT_RESOURCE, SLOT_PRODUCT, Fluids.WATER.get(), false))
if (!FluidHelper.fillContainers(tankManager, inventory, SLOT_RESOURCE, SLOT_PRODUCT, Fluids.WATER.get(), false))
return;
fillingTime = Defaults.RAINTANK_FILLING_TIME;
@@ -262,7 +269,7 @@ public class MachineRaintank extends TileBase implements ISidedInventory, ILiqui
if (slotIndex != SLOT_RESOURCE)
return false;
return LiquidHelper.getEmptyContainer(itemstack, STACK_WATER) != null;
return FluidHelper.isFillableContainer(itemstack, STACK_WATER);
}
/* SMP GUI */
@@ -16,6 +16,7 @@ import forestry.api.recipes.ISqueezerManager;
import forestry.api.core.EnumErrorCode;
import forestry.core.config.Config;
import forestry.core.config.Defaults;
import forestry.core.fluids.FluidHelper;
import forestry.core.fluids.TankManager;
import forestry.core.fluids.tanks.FilteredTank;
import forestry.core.fluids.tanks.StandardTank;
@@ -230,21 +231,16 @@ public class MachineSqueezer extends TilePowered implements ISpecialInventory, I
@Override
public void updateServerSide() {
if (worldObj.getTotalWorldTime() % 20 != 0)
return;
// Can/capsule input/output needs to be handled here.
if (inventory.getStackInSlot(SLOT_CAN_INPUT) != null) {
FluidContainerData container = LiquidHelper.getEmptyContainer(inventory.getStackInSlot(SLOT_CAN_INPUT), productTank.getFluid());
if (container != null) {
inventory.setInventorySlotContents(SLOT_CAN_OUTPUT, bottleIntoContainer(inventory.getStackInSlot(SLOT_CAN_INPUT), inventory.getStackInSlot(SLOT_CAN_OUTPUT), container, productTank));
if (inventory.getStackInSlot(SLOT_CAN_INPUT).stackSize <= 0)
inventory.setInventorySlotContents(SLOT_CAN_INPUT, null);
}
FluidStack fluidStack = productTank.getFluid();
if (fluidStack != null)
FluidHelper.fillContainers(tankManager, inventory, SLOT_CAN_INPUT, SLOT_CAN_OUTPUT, fluidStack.getFluid());
}
if (worldObj.getTotalWorldTime() % 20 * 10 != 0)
return;
checkRecipe();
if (getErrorState() == EnumErrorCode.NORECIPE && currentRecipe != null)
setErrorState(EnumErrorCode.OK);
@@ -436,11 +432,11 @@ public class MachineSqueezer extends TilePowered implements ISpecialInventory, I
public boolean isItemValidForSlot(int slotIndex, ItemStack itemstack) {
if(slotIndex == SLOT_CAN_INPUT) {
return LiquidHelper.isEmptyContainer(itemstack);
return FluidHelper.isEmptyContainer(itemstack);
}
if(slotIndex >= SLOT_RESOURCE_1 && slotIndex < SLOT_RESOURCE_1 + SLOTS_RESOURCE_COUNT) {
if (LiquidHelper.isEmptyContainer(itemstack))
if (FluidHelper.isEmptyContainer(itemstack))
return false;
if (RecipeManager.canUse(itemstack))
@@ -504,7 +500,7 @@ public class MachineSqueezer extends TilePowered implements ISpecialInventory, I
public int addItem(ItemStack stack, boolean doAdd, ForgeDirection from) {
// Try to add to can slot if input is from top or bottom.
if (LiquidHelper.isEmptyContainer(stack)) {
if (FluidHelper.isEmptyContainer(stack)) {
return inventory.addStack(stack, SLOT_CAN_INPUT, 1, false, doAdd);
} else {
return inventory.addStack(stack, SLOT_RESOURCE_1, SLOTS_RESOURCE_COUNT, false, doAdd);
@@ -10,12 +10,30 @@
******************************************************************************/
package forestry.factory.gadgets;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.ICrafting;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
import forestry.api.core.EnumErrorCode;
import forestry.api.core.ForestryAPI;
import forestry.api.core.ISpecialInventory;
import forestry.api.recipes.IStillManager;
import forestry.api.core.EnumErrorCode;
import forestry.core.config.Config;
import forestry.core.config.Defaults;
import forestry.core.fluids.FluidHelper;
import forestry.core.fluids.TankManager;
import forestry.core.fluids.tanks.FilteredTank;
import forestry.core.fluids.tanks.StandardTank;
@@ -25,26 +43,14 @@ import forestry.core.interfaces.ILiquidTankContainer;
import forestry.core.network.EntityNetData;
import forestry.core.network.GuiId;
import forestry.core.utils.EnumTankLevel;
<<<<<<< HEAD
import forestry.core.inventory.InventoryAdapter;
import forestry.core.utils.LiquidHelper;
=======
import forestry.core.utils.InventoryAdapter;
>>>>>>> 5ea4770a2d5fef57cf52fb7c81f33671f8086740
import forestry.core.utils.StackUtils;
import forestry.core.utils.Utils;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.ICrafting;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
public class MachineStill extends TilePowered implements ISpecialInventory, ISidedInventory, ILiquidTankContainer {
@@ -177,32 +183,22 @@ public class MachineStill extends TilePowered implements ISpecialInventory, ISid
@Override
public void updateServerSide() {
if (worldObj.getTotalWorldTime() % 20 * 10 != 0)
return;
// Check if we have suitable items waiting in the item slot
if (inventory.getStackInSlot(SLOT_CAN) != null) {
FluidContainerData container = LiquidHelper.getLiquidContainer(inventory.getStackInSlot(SLOT_CAN));
if (container != null && resourceTank.accepts(container.fluid.getFluid())) {
inventory.setInventorySlotContents(SLOT_CAN, StackUtils.replenishByContainer(this, inventory.getStackInSlot(SLOT_CAN), container, resourceTank));
if (inventory.getStackInSlot(SLOT_CAN).stackSize <= 0)
inventory.setInventorySlotContents(SLOT_CAN, null);
}
FluidHelper.drainContainers(tankManager, inventory, SLOT_CAN);
}
// Can product liquid if possible
if (inventory.getStackInSlot(SLOT_RESOURCE) != null) {
FluidContainerData container = LiquidHelper.getEmptyContainer(inventory.getStackInSlot(SLOT_RESOURCE), productTank.getFluid());
if (container != null) {
inventory.setInventorySlotContents(SLOT_PRODUCT, bottleIntoContainer(inventory.getStackInSlot(SLOT_RESOURCE), inventory.getStackInSlot(SLOT_PRODUCT), container, productTank));
if (inventory.getStackInSlot(SLOT_RESOURCE).stackSize <= 0)
inventory.setInventorySlotContents(SLOT_RESOURCE, null);
FluidStack fluidStack = productTank.getFluid();
if (fluidStack != null) {
FluidHelper.fillContainers(tankManager, inventory, SLOT_RESOURCE, SLOT_PRODUCT, fluidStack.getFluid());
}
}
if (worldObj.getTotalWorldTime() % 20 * 10 != 0)
return;
checkRecipe();
if (getErrorState() == EnumErrorCode.NORECIPE && currentRecipe != null)
setErrorState(EnumErrorCode.OK);
@@ -335,10 +331,10 @@ public class MachineStill extends TilePowered implements ISpecialInventory, ISid
public int addItem(ItemStack stack, boolean doAdd, ForgeDirection from) {
int inventorySlot;
FluidContainerData container = LiquidHelper.getLiquidContainer(stack);
if (container != null && resourceTank.accepts(container.fluid.getFluid()))
Fluid fluid = FluidHelper.getFluidInContainer(stack);
if (fluid != null && resourceTank.accepts(fluid))
inventorySlot = SLOT_CAN;
else if (LiquidHelper.isEmptyContainer(stack))
else if (FluidHelper.isEmptyContainer(stack))
inventorySlot = SLOT_RESOURCE;
else
return 0;
@@ -447,11 +443,11 @@ public class MachineStill extends TilePowered implements ISpecialInventory, ISid
return false;
if(slotIndex == SLOT_RESOURCE)
return LiquidHelper.isEmptyContainer(itemstack);
return FluidHelper.isEmptyContainer(itemstack);
if(slotIndex == SLOT_CAN) {
FluidContainerData container = LiquidHelper.getLiquidContainer(itemstack);
return container != null && resourceTank.accepts(container.fluid.getFluid());
Fluid fluid = FluidHelper.getFluidInContainer(itemstack);
return fluid != null && resourceTank.accepts(fluid);
}
return false;
@@ -10,23 +10,8 @@
******************************************************************************/
package forestry.factory.gadgets;
import java.util.LinkedList;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.world.World;
import forestry.api.core.ForestryAPI;
import forestry.api.core.INBTTagable;
import forestry.core.gadgets.TileBase;
import forestry.core.gui.ContainerDummy;
import forestry.core.interfaces.ICrafter;
import forestry.core.network.ForestryPacket;
import forestry.core.network.GuiId;
@@ -34,10 +19,23 @@ import forestry.core.network.PacketIds;
import forestry.core.network.PacketTileNBT;
import forestry.core.network.PacketTileUpdate;
import forestry.core.proxy.Proxies;
<<<<<<< HEAD
import forestry.core.inventory.InventoryAdapter;
import forestry.core.utils.PlainInventory;
import forestry.core.utils.StackUtils;
import forestry.core.inventory.TileInventoryAdapter;
=======
import forestry.core.utils.InventoryAdapter;
import forestry.core.utils.RecipeUtil;
import forestry.core.utils.TileInventoryAdapter;
import forestry.factory.recipes.RecipeMemory;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.nbt.NBTTagCompound;
>>>>>>> 5ea4770a2d5fef57cf52fb7c81f33671f8086740
public class TileWorktable extends TileBase implements ICrafter {
@@ -47,298 +45,9 @@ public class TileWorktable extends TileBase implements ICrafter {
public final static int SLOT_CRAFTING_RESULT = 9;
public final static short SLOT_INVENTORY_1 = 0;
public final static short SLOT_INVENTORY_COUNT = 18;
private final static Container DUMMY_CONTAINER = new ContainerDummy();
private final static RecipeBridge RECIPE_BRIDGE = new RecipeBridge();
private static class RecipeBridge {
public ItemStack findMatchingRecipe(InventoryCrafting crafting, World world) {
return CraftingManager.getInstance().findMatchingRecipe(crafting, world);
}
}
/* RECIPE MEMORY */
public static final class Recipe implements INBTTagable {
private InventoryAdapter matrix;
private long lastUsed;
private boolean locked;
private World cachedWorld;
private ItemStack cachedRecipeOutput;
public Recipe(InventoryCrafting crafting) {
this.matrix = new InventoryAdapter(new PlainInventory(crafting));
}
public Recipe(NBTTagCompound nbttagcompound) {
readFromNBT(nbttagcompound);
}
public void setCacheWorld(World world) {
this.cachedWorld = world;
}
private boolean updateCachedRecipeOutput() {
if (cachedRecipeOutput != null)
return true;
InventoryCrafting crafting = new InventoryCrafting(DUMMY_CONTAINER, 3, 3);
for (int i = 0; i < crafting.getSizeInventory(); i++) {
crafting.setInventorySlotContents(i, matrix.getStackInSlot(i));
}
cachedRecipeOutput = RECIPE_BRIDGE.findMatchingRecipe(crafting, cachedWorld);
return cachedRecipeOutput != null;
}
public void updateLastUse(World world) {
lastUsed = world.getTotalWorldTime();
setCacheWorld(world);
}
public void toogleLock() {
locked = !locked;
}
public InventoryAdapter getMatrix() {
return matrix;
}
public ItemStack getCraftingResult(InventoryCrafting inventorycrafting) {
if (updateCachedRecipeOutput())
return cachedRecipeOutput;
return null;
}
public ItemStack getRecipeOutput() {
if (updateCachedRecipeOutput())
return cachedRecipeOutput;
return null;
}
public long getLastUsed() {
return this.lastUsed;
}
public boolean isLocked() {
return this.locked;
}
public int getRecipeSize() {
return matrix.getSizeInventory();
}
public boolean hasSameOutput(InventoryCrafting crafting, World world) {
if (!updateCachedRecipeOutput())
return false;
ItemStack recipeOutput = RECIPE_BRIDGE.findMatchingRecipe(crafting, world);
return ItemStack.areItemStacksEqual(cachedRecipeOutput, recipeOutput);
}
@Override
public final void readFromNBT(NBTTagCompound nbttagcompound) {
matrix = new InventoryAdapter(new InventoryCrafting(DUMMY_CONTAINER, 3, 3));
matrix.readFromNBT(nbttagcompound);
sanitizeMatrix();
lastUsed = nbttagcompound.getLong("LastUsed");
locked = nbttagcompound.getBoolean("Locked");
}
@Override
public void writeToNBT(NBTTagCompound nbttagcompound) {
sanitizeMatrix();
matrix.writeToNBT(nbttagcompound);
nbttagcompound.setLong("LastUsed", lastUsed);
nbttagcompound.setBoolean("Locked", locked);
}
/**
* This is a nasty hack to hide a bug where the recipe stacks somehow
* get the stackSize set to -1. Which makes the recipe no longer work,
* ever. I've seen the bug, even inspected the NBT data of an afflicted
* worktable, but can't duplicate it, and can't trace it. -CovertJaguar
*/
private void sanitizeMatrix() {
for (int slot = 0; slot < matrix.getSizeInventory(); slot++) {
ItemStack stack = matrix.getStackInSlot(slot);
if (stack != null)
stack.stackSize = 1;
}
}
}
public static class RecipeMemory implements INBTTagable, IInventory {
private LinkedList<Recipe> recipes = new LinkedList<Recipe>();
private long lastUpdate;
public final int capacity = 9;
public long getLastUpdate() {
return lastUpdate;
}
public void memorizeRecipe(World world, Recipe recipe, InventoryCrafting crafting) {
lastUpdate = world.getTotalWorldTime();
recipe.updateLastUse(world);
Recipe memory = getMemorized(crafting, world);
if (memory != null) {
int index = recipes.indexOf(memory);
recipes.set(index, recipe);
return;
}
if (recipes.size() < capacity) {
recipes.add(recipe);
return;
}
Recipe oldest = null;
for (Recipe existing : recipes) {
if (oldest != null && oldest.getLastUsed() < existing.getLastUsed())
continue;
if (existing.isLocked())
continue;
oldest = existing;
}
if (oldest != null) {
recipes.remove(oldest);
recipes.add(recipe);
}
}
public Recipe getRecipe(int recipeIndex) {
if (recipes.size() > recipeIndex)
return recipes.get(recipeIndex);
return null;
}
public ItemStack getRecipeOutput(int recipeIndex) {
if (recipes.size() > recipeIndex)
return recipes.get(recipeIndex).getRecipeOutput();
else
return null;
}
public boolean isLocked(int recipeIndex) {
if (recipes.size() > recipeIndex)
return recipes.get(recipeIndex).isLocked();
return false;
}
public void toggleLock(World world, int recipeIndex) {
lastUpdate = world.getTotalWorldTime();
if (recipes.size() > recipeIndex)
recipes.get(recipeIndex).toogleLock();
}
private Recipe getMemorized(InventoryCrafting crafting, World world) {
for (Recipe recipe : recipes) {
if (recipe.hasSameOutput(crafting, world))
return recipe;
}
return null;
}
@Override
public void readFromNBT(NBTTagCompound nbttagcompound) {
recipes = new LinkedList<Recipe>();
if (!nbttagcompound.hasKey("RecipeMemory"))
return;
NBTTagList nbttaglist = nbttagcompound.getTagList("RecipeMemory", 10);
for (int j = 0; j < nbttaglist.tagCount(); ++j) {
NBTTagCompound nbttagcompound2 = nbttaglist.getCompoundTagAt(j);
recipes.add(new Recipe(nbttagcompound2));
}
}
@Override
public void writeToNBT(NBTTagCompound nbttagcompound) {
NBTTagList nbttaglist = new NBTTagList();
for (Recipe recipe : recipes) {
if (recipe != null) {
NBTTagCompound nbttagcompound2 = new NBTTagCompound();
recipe.writeToNBT(nbttagcompound2);
nbttaglist.appendTag(nbttagcompound2);
}
}
nbttagcompound.setTag("RecipeMemory", nbttaglist);
}
@Override
public int getSizeInventory() {
return recipes.size();
}
@Override
public ItemStack getStackInSlot(int i) {
return getRecipeOutput(i);
}
@Override
public ItemStack decrStackSize(int i, int j) {
return null;
}
@Override
public ItemStack getStackInSlotOnClosing(int i) {
return null;
}
@Override
public void setInventorySlotContents(int i, ItemStack itemstack) {
}
@Override
public String getInventoryName() {
return "";
}
@Override
public boolean hasCustomInventoryName() {
return false;
}
@Override
public int getInventoryStackLimit() {
return 64;
}
@Override
public void markDirty() {
}
@Override
public boolean isUseableByPlayer(EntityPlayer entityplayer) {
return true;
}
@Override
public void openInventory() {
}
@Override
public void closeInventory() {
}
@Override
public boolean isItemValidForSlot(int i, ItemStack itemstack) {
return false;
}
}
/* MEMBERS */
private Recipe currentRecipe;
private RecipeMemory.Recipe currentRecipe;
private InventoryCrafting currentCrafting;
private final RecipeMemory memorized;
private final TileInventoryAdapter craftingInventory;
@@ -393,6 +102,12 @@ public class TileWorktable extends TileBase implements ICrafter {
Proxies.net.sendToPlayer(new PacketTileNBT(PacketIds.TILE_NBT, this), player);
}
@Override
public void validate() {
super.validate();
memorized.validate(worldObj);
}
/* RECIPE SELECTION */
public RecipeMemory getMemory() {
return memorized;
@@ -406,9 +121,7 @@ public class TileWorktable extends TileBase implements ICrafter {
return;
}
Recipe recipe = memorized.getRecipe(recipeIndex);
recipe.sanitizeMatrix();
IInventory matrix = recipe.getMatrix();
IInventory matrix = memorized.getRecipeMatrix(recipeIndex);
if (matrix == null)
return;
@@ -420,20 +133,20 @@ public class TileWorktable extends TileBase implements ICrafter {
/* CRAFTING */
public void setRecipe(InventoryCrafting crafting) {
ItemStack recipeOutput = RECIPE_BRIDGE.findMatchingRecipe(crafting, worldObj);
ItemStack recipeOutput = CraftingManager.getInstance().findMatchingRecipe(crafting, worldObj);
if (recipeOutput == null) {
currentRecipe = null;
currentCrafting = null;
} else {
currentRecipe = new Recipe(crafting);
currentRecipe = new RecipeMemory.Recipe(crafting);
currentCrafting = crafting;
}
updateCraftResult(currentCrafting);
updateCraftResult();
}
private void updateCraftResult(InventoryCrafting inventorycrafting) {
private void updateCraftResult() {
if (currentRecipe != null) {
ItemStack result = currentRecipe.getCraftingResult(inventorycrafting);
ItemStack result = currentRecipe.getRecipeOutput(worldObj);
if (result != null) {
craftingInventory.setInventorySlotContents(SLOT_CRAFTING_RESULT, result.copy());
return;
@@ -447,56 +160,11 @@ public class TileWorktable extends TileBase implements ICrafter {
if (currentRecipe == null)
return false;
// Need at least one matched set
ItemStack[] set = craftingInventory.getStacks(SLOT_CRAFTING_1, SLOT_CRAFTING_COUNT);
ItemStack[] stock = accessibleInventory.getStacks(SLOT_INVENTORY_1, SLOT_INVENTORY_COUNT);
if (StackUtils.containsSets(set, stock, true, true) == 0)
return false;
ItemStack[] recipeItems = craftingInventory.getStacks(SLOT_CRAFTING_1, SLOT_CRAFTING_COUNT);
ItemStack[] inventory = accessibleInventory.getStacks(SLOT_INVENTORY_1, SLOT_INVENTORY_COUNT);
ItemStack recipeOutput = currentRecipe.getRecipeOutput(worldObj);
// Check that it doesn't make a different recipe.
// For example:
// Wood Logs are all ore dictionary equivalent with each other,
// but an Oak Log shouldn't be able to make Ebony Wood Planks
// because it makes Oak Wood Planks using the same recipe.
// Strategy:
// Create a fake crafting inventory using items we have in stock
// in place of the ones in the saved crafting inventory.
// Check that the recipe it makes is the same as the currentRecipe.
InventoryCrafting crafting = new InventoryCrafting(DUMMY_CONTAINER, 3, 3);
ItemStack[] stockCopy = StackUtils.condenseStacks(stock);
for (int slot = 0; slot < currentCrafting.getSizeInventory(); slot++) {
ItemStack recipeStack = currentCrafting.getStackInSlot(slot);
if (recipeStack == null)
continue;
// Use crafting equivalent (not oredict) items first
for (ItemStack stockStack : stockCopy) {
if (stockStack.stackSize > 0 && StackUtils.isCraftingEquivalent(recipeStack, stockStack, false, false)) {
ItemStack stack = new ItemStack(stockStack.getItem(), 1, stockStack.getItemDamage());
stockStack.stackSize--;
crafting.setInventorySlotContents(slot, stack);
break;
}
}
// Use oredict items if crafting equivalent items aren't available
if (crafting.getStackInSlot(slot) == null) {
for (ItemStack stockStack : stockCopy) {
if (stockStack.stackSize > 0 && StackUtils.isCraftingEquivalent(recipeStack, stockStack, true, true)) {
ItemStack stack = new ItemStack(stockStack.getItem(), 1, stockStack.getItemDamage());
stockStack.stackSize--;
crafting.setInventorySlotContents(slot, stack);
break;
}
}
}
}
ItemStack recipeOutput = RECIPE_BRIDGE.findMatchingRecipe(crafting, worldObj);
if (recipeOutput == null)
return false;
return ItemStack.areItemStacksEqual(recipeOutput, currentRecipe.getRecipeOutput());
return RecipeUtil.canCraftRecipe(worldObj, recipeItems, recipeOutput, inventory);
}
private boolean removeResources(EntityPlayer player) {
@@ -519,8 +187,8 @@ public class TileWorktable extends TileBase implements ICrafter {
if (Proxies.common.isSimulating(worldObj))
memorized.memorizeRecipe(worldObj, currentRecipe, currentCrafting);
updateCraftResult(currentCrafting);
return currentRecipe.getRecipeOutput().copy();
updateCraftResult();
return currentRecipe.getRecipeOutput(worldObj).copy();
}
@Override
@@ -528,8 +196,8 @@ public class TileWorktable extends TileBase implements ICrafter {
if (currentRecipe == null)
return null;
if (currentRecipe.getRecipeOutput() != null)
return currentRecipe.getRecipeOutput().copy();
if (currentRecipe.getRecipeOutput(worldObj) != null)
return currentRecipe.getRecipeOutput(worldObj).copy();
return null;
}
@@ -20,7 +20,7 @@ public class ContainerFabricator extends ContainerLiquidTanks {
private final MachineFabricator tile;
public ContainerFabricator(InventoryPlayer player, MachineFabricator tile) {
public ContainerFabricator(InventoryPlayer playerInventory, MachineFabricator tile) {
super(tile, tile);
this.tile = tile;
@@ -36,7 +36,7 @@ public class ContainerFabricator extends ContainerLiquidTanks {
this.addSlot(new Slot(tile, MachineFabricator.SLOT_PLAN, 139, 17));
// Result
this.addSlot(new SlotCrafter(tile, tile, MachineFabricator.SLOT_RESULT, 139, 53));
this.addSlot(new SlotCrafter(playerInventory.player, tile, tile, MachineFabricator.SLOT_RESULT, 139, 53));
// Crafting matrix
for (int l = 0; l < 3; l++)
@@ -46,10 +46,10 @@ public class ContainerFabricator extends ContainerLiquidTanks {
// Player inventory
for (int i = 0; i < 3; i++)
for (int k = 0; k < 9; k++)
addSlot(new Slot(player, k + i * 9 + 9, 8 + k * 18, 129 + i * 18));
addSlot(new Slot(playerInventory, k + i * 9 + 9, 8 + k * 18, 129 + i * 18));
// Player hotbar
for (int j = 0; j < 9; j++)
addSlot(new Slot(player, j, 8 + j * 18, 187));
addSlot(new Slot(playerInventory, j, 8 + j * 18, 187));
}
@@ -60,7 +60,7 @@ public class ContainerWorktable extends ContainerForestry implements IContainerC
}
// CraftResult display
addSlot(new SlotCrafter(craftingInventory, tile, TileWorktable.SLOT_CRAFTING_RESULT, 77, 38));
addSlot(new SlotCrafter(player, craftingInventory, tile, TileWorktable.SLOT_CRAFTING_RESULT, 77, 38));
// Player inventory
for (int i1 = 0; i1 < 3; i1++) {
@@ -22,6 +22,7 @@ import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import org.lwjgl.opengl.GL11;
public class GuiWorktable extends GuiForestryTitled<TileWorktable> {
@@ -29,14 +30,16 @@ public class GuiWorktable extends GuiForestryTitled<TileWorktable> {
private class MemorizedSlot extends Widget {
private final int slotNumber;
private final World world;
public MemorizedSlot(WidgetManager manager, int xPos, int yPos, int slot) {
public MemorizedSlot(World world, WidgetManager manager, int xPos, int yPos, int slot) {
super(manager, xPos, yPos);
this.slotNumber = slot;
this.world = world;
}
private ItemStack getOutputStack() {
return worktable.getMemory().getRecipeOutput(slotNumber);
return worktable.getMemory().getRecipeOutput(world, slotNumber);
}
@Override
@@ -111,7 +114,7 @@ public class GuiWorktable extends GuiForestryTitled<TileWorktable> {
int yPos = 20 + (y * spacing);
for (int x = 0; x < 3; x++) {
int xPos = 110 + (x * spacing);
widgetManager.add(new MemorizedSlot(widgetManager, xPos, yPos, slot));
widgetManager.add(new MemorizedSlot(player.getEntityWorld(), widgetManager, xPos, yPos, slot));
slot += 1;
}
}
@@ -0,0 +1,259 @@
/*******************************************************************************
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.factory.recipes;
import forestry.api.core.INBTTagable;
import forestry.core.gui.ContainerDummy;
import forestry.core.utils.InventoryAdapter;
import forestry.core.utils.PlainInventory;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.Item;
import net.minecraft.item.ItemMap;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.world.World;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
public class RecipeMemory implements INBTTagable {
public static final class Recipe implements INBTTagable {
private InventoryAdapter matrix;
private long lastUsed;
private boolean locked;
private ItemStack cachedRecipeOutput;
public Recipe(InventoryCrafting crafting) {
this.matrix = new InventoryAdapter(new PlainInventory(crafting));
}
public Recipe(NBTTagCompound nbttagcompound) {
readFromNBT(nbttagcompound);
}
public void updateLastUse(long lastUsed) {
this.lastUsed = lastUsed;
}
public void toggleLock() {
locked = !locked;
}
public InventoryAdapter getMatrix() {
return matrix;
}
public ItemStack getRecipeOutput(World world) {
if (cachedRecipeOutput == null) {
InventoryCrafting crafting = new InventoryCrafting(DUMMY_CONTAINER, 3, 3);
for (int i = 0; i < crafting.getSizeInventory(); i++) {
crafting.setInventorySlotContents(i, matrix.getStackInSlot(i));
}
cachedRecipeOutput = CraftingManager.getInstance().findMatchingRecipe(crafting, world);
}
return cachedRecipeOutput;
}
public long getLastUsed() {
return this.lastUsed;
}
public boolean isLocked() {
return this.locked;
}
public boolean hasSameOutput(InventoryCrafting crafting, World world) {
ItemStack recipeOutput = getRecipeOutput(world);
if (recipeOutput == null)
return false;
ItemStack matchingRecipeOutput = CraftingManager.getInstance().findMatchingRecipe(crafting, world);
return ItemStack.areItemStacksEqual(recipeOutput, matchingRecipeOutput);
}
@Override
public final void readFromNBT(NBTTagCompound nbttagcompound) {
matrix = new InventoryAdapter(new InventoryCrafting(DUMMY_CONTAINER, 3, 3));
matrix.readFromNBT(nbttagcompound);
sanitizeMatrix();
lastUsed = nbttagcompound.getLong("LastUsed");
locked = nbttagcompound.getBoolean("Locked");
}
@Override
public void writeToNBT(NBTTagCompound nbttagcompound) {
sanitizeMatrix();
matrix.writeToNBT(nbttagcompound);
nbttagcompound.setLong("LastUsed", lastUsed);
nbttagcompound.setBoolean("Locked", locked);
}
/**
* This is a nasty hack to hide a bug where the recipe stacks somehow
* get the stackSize set to -1. Which makes the recipe no longer work,
* ever. I've seen the bug, even inspected the NBT data of an afflicted
* worktable, but can't duplicate it, and can't trace it. -CovertJaguar
*/
private void sanitizeMatrix() {
for (int slot = 0; slot < matrix.getSizeInventory(); slot++) {
ItemStack stack = matrix.getStackInSlot(slot);
if (stack != null)
stack.stackSize = 1;
}
}
}
private static final Container DUMMY_CONTAINER = new ContainerDummy();
private static final List<Class<? extends Item>> memoryBlacklist = new ArrayList<Class<? extends Item>>();
static {
memoryBlacklist.add(ItemMap.class); // almost every ItemMap is unique
}
private LinkedList<Recipe> recipes = new LinkedList<Recipe>();
private long lastUpdate;
public final int capacity = 9;
private static boolean isValid(World world, Recipe recipe) {
if (recipe == null)
return false;
ItemStack recipeOutput = recipe.getRecipeOutput(world);
if (recipeOutput == null)
return false;
Item item = recipeOutput.getItem();
return item != null && !memoryBlacklist.contains(item.getClass());
}
public void validate(World world) {
LinkedList<Recipe> validRecipes = new LinkedList<Recipe>();
for (Recipe recipe : recipes) {
if (isValid(world, recipe))
validRecipes.add(recipe);
}
this.recipes = validRecipes;
}
public long getLastUpdate() {
return lastUpdate;
}
public void memorizeRecipe(World world, Recipe recipe, InventoryCrafting crafting) {
if (!isValid(world, recipe))
return;
lastUpdate = world.getTotalWorldTime();
recipe.updateLastUse(lastUpdate);
Recipe memory = getMemorized(crafting, world);
if (memory != null) {
int index = recipes.indexOf(memory);
recipes.set(index, recipe);
return;
}
if (recipes.size() < capacity) {
recipes.add(recipe);
return;
}
Recipe oldest = null;
for (Recipe existing : recipes) {
if (oldest != null && oldest.getLastUsed() < existing.getLastUsed())
continue;
if (existing.isLocked())
continue;
oldest = existing;
}
if (oldest != null) {
recipes.remove(oldest);
recipes.add(recipe);
}
}
public Recipe getRecipe(int recipeIndex) {
if (recipes.size() > recipeIndex)
return recipes.get(recipeIndex);
return null;
}
public IInventory getRecipeMatrix(int recipeIndex) {
RecipeMemory.Recipe recipe = getRecipe(recipeIndex);
recipe.sanitizeMatrix();
return recipe.getMatrix();
}
public ItemStack getRecipeOutput(World world, int recipeIndex) {
if (recipes.size() > recipeIndex)
return recipes.get(recipeIndex).getRecipeOutput(world);
else
return null;
}
public boolean isLocked(int recipeIndex) {
if (recipes.size() > recipeIndex)
return recipes.get(recipeIndex).isLocked();
return false;
}
public void toggleLock(World world, int recipeIndex) {
lastUpdate = world.getTotalWorldTime();
if (recipes.size() > recipeIndex)
recipes.get(recipeIndex).toggleLock();
}
private Recipe getMemorized(InventoryCrafting crafting, World world) {
for (Recipe recipe : recipes) {
if (recipe.hasSameOutput(crafting, world))
return recipe;
}
return null;
}
@Override
public void readFromNBT(NBTTagCompound nbttagcompound) {
recipes = new LinkedList<Recipe>();
if (!nbttagcompound.hasKey("RecipeMemory"))
return;
NBTTagList nbttaglist = nbttagcompound.getTagList("RecipeMemory", 10);
for (int j = 0; j < nbttaglist.tagCount(); ++j) {
NBTTagCompound nbttagcompound2 = nbttaglist.getCompoundTagAt(j);
recipes.add(new Recipe(nbttagcompound2));
}
}
@Override
public void writeToNBT(NBTTagCompound nbttagcompound) {
NBTTagList nbttaglist = new NBTTagList();
for (Recipe recipe : recipes) {
if (recipe != null) {
NBTTagCompound nbttagcompound2 = new NBTTagCompound();
recipe.writeToNBT(nbttagcompound2);
nbttaglist.appendTag(nbttagcompound2);
}
}
nbttagcompound.setTag("RecipeMemory", nbttaglist);
}
}
@@ -62,10 +62,6 @@ public class TileControl extends TileFarm implements IFarmListener {
return true;
}
@Override
protected void createInventory() {
}
/* IFARMLISTENER */
@Override
public boolean cancelTask(IFarmLogic logic, ForgeDirection direction) {
@@ -228,19 +228,21 @@ public abstract class TileFarm extends TileForestry implements IFarmComponent {
/* INVENTORY MANAGMENT */
protected TileInventoryAdapter inventory;
protected abstract void createInventory();
/* TILEFORESTRY */
@Override
public PacketPayload getPacketPayload() {
PacketPayload payload = new PacketPayload(0, 1);
PacketPayload payload = new PacketPayload(0, 2);
payload.shortPayload[0] = (short) farmBlock.ordinal();
payload.shortPayload[1] = (short) (isMaster() ? 1 : 0);
return payload;
}
@Override
public void fromPacketPayload(PacketPayload payload) {
EnumFarmBlock farmType = EnumFarmBlock.values()[payload.shortPayload[0]];
if (payload.shortPayload[1] > 0)
makeMaster();
if (this.farmBlock != farmType) {
this.farmBlock = farmType;
worldObj.func_147479_m(xCoord, yCoord, zCoord);
@@ -267,9 +269,6 @@ public abstract class TileFarm extends TileForestry implements IFarmComponent {
public void makeMaster() {
setCentralTE(null);
this.isMaster = true;
if (inventory == null)
createInventory();
}
@Override
@@ -284,22 +283,19 @@ public abstract class TileFarm extends TileForestry implements IFarmComponent {
@Override
public ITileStructure getCentralTE() {
if (!isIntegratedIntoStructure() || !hasMaster())
if (!isIntegratedIntoStructure())
return null;
if (!isMaster) {
TileEntity tile = worldObj.getTileEntity(masterX, masterY, masterZ);
if (tile instanceof ITileStructure) {
ITileStructure master = (ITileStructure) worldObj.getTileEntity(masterX, masterY, masterZ);
if (master.isMaster())
return master;
else
return null;
} else
return null;
} else
if (isMaster)
return this;
TileEntity tile = worldObj.getTileEntity(masterX, masterY, masterZ);
if (tile instanceof ITileStructure) {
ITileStructure master = (ITileStructure)tile;
if (master.isMaster())
return master;
}
return null;
}
private boolean isSameTile(TileEntity tile) {
@@ -348,10 +344,4 @@ public abstract class TileFarm extends TileForestry implements IFarmComponent {
@Override
public void removeListener(IFarmListener listener) {
}
/* INTERACTION */
@Override
public boolean isUseableByPlayer(EntityPlayer player) {
return Utils.isUseableByPlayer(player, this, worldObj, xCoord, yCoord, zCoord);
}
}
@@ -19,8 +19,6 @@ import java.util.Set;
import java.util.Stack;
import java.util.TreeMap;
import forestry.api.core.BiomeHelper;
import forestry.core.utils.Utils;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.ICrafting;
@@ -31,14 +29,13 @@ import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
import forestry.api.circuits.ChipsetManager;
import forestry.api.circuits.ICircuitBoard;
import forestry.api.core.BiomeHelper;
import forestry.api.core.EnumErrorCode;
import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
import forestry.api.farming.ICrop;
@@ -47,29 +44,27 @@ import forestry.api.farming.IFarmHousing;
import forestry.api.farming.IFarmListener;
import forestry.api.farming.IFarmLogic;
import forestry.api.farming.IFarmable;
import forestry.api.core.EnumErrorCode;
import forestry.core.GameMode;
import forestry.core.config.Config;
import forestry.core.config.Defaults;
import forestry.core.fluids.FluidHelper;
import forestry.core.fluids.TankManager;
import forestry.core.fluids.tanks.FilteredTank;
import forestry.core.interfaces.IClimatised;
import forestry.core.interfaces.IHintSource;
import forestry.core.interfaces.ISocketable;
import forestry.core.interfaces.ILiquidTankContainer;
import forestry.core.inventory.InventoryAdapter;
import forestry.core.inventory.TileInventoryAdapter;
import forestry.core.proxy.Proxies;
import forestry.core.utils.DelayTimer;
import forestry.core.fluids.tanks.StandardTank;
import forestry.core.fluids.tanks.FilteredTank;
import forestry.core.fluids.TankManager;
import forestry.core.inventory.InventoryAdapter;
import forestry.core.utils.LiquidHelper;
import forestry.core.utils.StackUtils;
import forestry.core.inventory.TileInventoryAdapter;
import forestry.core.utils.Utils;
import forestry.core.utils.Vect;
import forestry.farming.FarmTarget;
import forestry.farming.logic.FarmLogicArboreal;
import forestry.plugins.PluginFarming;
public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable, IClimatised, IHintSource, ILiquidTankContainer {
public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable, IClimatised, IHintSource {
public static final int SLOT_RESOURCES_1 = 0;
public static final int SLOT_GERMLINGS_1 = 6;
@@ -82,9 +77,9 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable
public static final int SLOT_COUNT = 22;
public static final int DELAY_HYDRATION = 100;
public static final float RAINFALL_MODIFIER_CAP = 15f;
public static final int BUFFER_FERTILIZER = 200;
private static final int DELAY_HYDRATION = 100;
private static final float RAINFALL_MODIFIER_CAP = 15f;
private static final int BUFFER_FERTILIZER = 200;
private IFarmLogic[] farmLogics = new IFarmLogic[4];
@@ -94,8 +89,7 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable
private final InventoryAdapter sockets = new InventoryAdapter(1, "sockets");
private final FilteredTank liquidTank;
private final TankManager tankManager;
private TankManager tankManager;
private IFarmLogic harvestProvider; // The farm logic which supplied the pending crops.
private final Stack<ICrop> pendingCrops = new Stack<ICrop>();
@@ -112,8 +106,6 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable
public TileFarmPlain() {
fertilizerValue = GameMode.getGameMode().getIntegerSetting("farms.fertilizer.value");
liquidTank = new FilteredTank(Defaults.PROCESSOR_TANK_CAPACITY, FluidRegistry.WATER);
tankManager = new TankManager(liquidTank);
}
@Override
@@ -134,7 +126,8 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable
refreshFarmLogics();
tankManager.readTanksFromNBT(nbttagcompound);
if (tankManager != null)
tankManager.readTanksFromNBT(nbttagcompound);
}
@Override
@@ -146,15 +139,11 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable
nbttagcompound.setInteger("HydrationDelay", hydrationDelay);
nbttagcompound.setInteger("TicksSinceRainfall", ticksSinceRainfall);
tankManager.writeTanksToNBT(nbttagcompound);
if (tankManager != null)
tankManager.writeTanksToNBT(nbttagcompound);
}
/* UPDATING */
@Override
public void initialize() {
setBiomeInformation();
}
@Override
protected void updateServerSide() {
super.updateServerSide();
@@ -178,13 +167,7 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable
// Check if we have suitable items waiting in the item slot
if (inventory.getStackInSlot(SLOT_CAN) != null) {
FluidContainerData container = LiquidHelper.getLiquidContainer(inventory.getStackInSlot(SLOT_CAN));
if (container != null && liquidTank.accepts(container.fluid.getFluid())) {
inventory.setInventorySlotContents(SLOT_CAN, StackUtils.replenishByContainer(this, inventory.getStackInSlot(SLOT_CAN), container, liquidTank));
if (inventory.getStackInSlot(SLOT_CAN).stackSize <= 0)
inventory.setInventorySlotContents(SLOT_CAN, null);
}
FluidHelper.drainContainers(tankManager, inventory, SLOT_CAN);
}
}
@@ -366,16 +349,14 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable
}
}
@Override
protected void createInventory() {
inventory = new TileInventoryAdapter(this, SLOT_COUNT, "Items");
FilteredTank liquidTank = new FilteredTank(Defaults.PROCESSOR_TANK_CAPACITY, FluidRegistry.WATER);
tankManager = new TankManager(liquidTank);
}
@Override
public boolean doWork() {
setBiomeInformation();
// System.out.println("Starting doWork()");
if (targets == null) {
createTargets();
@@ -453,7 +434,7 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable
else
hasFertilizer = true;
FluidStack liquid = LiquidHelper.getLiquid(Defaults.LIQUID_WATER, logic.getWaterConsumption(getHydrationModifier()));
FluidStack liquid = FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, logic.getWaterConsumption(getHydrationModifier()));
if (liquid.amount > 0 && !hasLiquid(liquid))
continue;
else
@@ -576,7 +557,7 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable
}
// Check water
FluidStack liquid = LiquidHelper.getLiquid(Defaults.LIQUID_WATER, provider.getWaterConsumption(getHydrationModifier()));
FluidStack liquid = FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, provider.getWaterConsumption(getHydrationModifier()));
if (liquid.amount > 0 && !hasLiquid(liquid)) {
setErrorState(EnumErrorCode.NOLIQUID);
return false;
@@ -681,18 +662,9 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable
public void makeMaster() {
super.makeMaster();
refreshFarmLogics();
createInventory();
}
@Override
public void onStructureReset() {
super.onStructureReset();
}
public StandardTank[] getTanks() {
return new StandardTank[] {liquidTank};
}
@Override
public TankManager getTankManager() {
return tankManager;
}
@@ -786,18 +758,18 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable
@Override
public void removeResources(ItemStack[] resources) {
EntityPlayer player = Proxies.common.getPlayer(worldObj, owner);
EntityPlayer player = Proxies.common.getPlayer(worldObj, getOwnerProfile());
inventory.removeSets(1, resources, SLOT_RESOURCES_1, SLOT_COUNT_RESERVOIRS, player, false, true, true);
}
@Override
public boolean hasLiquid(FluidStack liquid) {
return liquidTank.getFluidAmount() >= liquid.amount;
return tankManager.get(0).getFluidAmount() >= liquid.amount;
}
@Override
public void removeLiquid(FluidStack liquid) {
liquidTank.drain(liquid.amount, true);
tankManager.drain(liquid, true);
}
public boolean hasGermlings(ItemStack[] germlings) {
@@ -813,7 +785,7 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable
if (!germling.isGermling(inventory.getStackInSlot(i)))
continue;
EntityPlayer player = Proxies.common.getPlayer(world, owner);
EntityPlayer player = Proxies.common.getPlayer(world, getOwnerProfile());
if (!germling.plantSaplingAt(player, inventory.getStackInSlot(i), world, x, y, z))
continue;
@@ -877,9 +849,9 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable
return StackUtils.isIdenticalItem(PluginFarming.farmFertilizer, itemstack);
}
int[] coords;
int[] offset;
int[] area;
private int[] coords;
private int[] offset;
private int[] area;
@Override
public int[] getCoords() {
@@ -989,35 +961,4 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable
public boolean isOwnable() {
return true;
}
/* ILiquidTankContainer */
@Override
public int fill(ForgeDirection direction, FluidStack resource, boolean doFill) {
return tankManager.fill(direction, resource, doFill);
}
@Override
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) {
return tankManager.drain(from, resource, doDrain);
}
@Override
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) {
return tankManager.drain(from, maxDrain, doDrain);
}
@Override
public boolean canFill(ForgeDirection from, Fluid fluid) {
return tankManager.canFill(from, fluid);
}
@Override
public boolean canDrain(ForgeDirection from, Fluid fluid) {
return tankManager.canDrain(from, fluid);
}
@Override
public FluidTankInfo[] getTankInfo(ForgeDirection from) {
return tankManager.getTankInfo(from);
}
}
@@ -33,10 +33,6 @@ public class TileGearbox extends TileFarm implements IPowerHandler {
fixedType = TYPE_GEARS;
}
@Override
protected void createInventory() {
}
@Override
public boolean hasFunction() {
return true;
@@ -42,10 +42,6 @@ public class TileHatch extends TileFarm implements ISidedInventory {
return true;
}
@Override
protected void createInventory() {
}
@Override
protected void updateServerSide() {
if (worldObj.getTotalWorldTime() % 40 == 0)
@@ -33,10 +33,6 @@ public class TileValve extends TileFarm implements ILiquidTankContainer {
return true;
}
@Override
protected void createInventory() {
}
/* ILIQUIDTANKCONTAINER */
@Override
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) {
@@ -24,7 +24,6 @@ import forestry.core.gui.slots.SlotCustom;
import forestry.core.gui.slots.SlotForestry;
import forestry.core.gui.slots.SlotLiquidContainer;
import forestry.core.gui.slots.SlotOutput;
import forestry.core.inventory.TileInventoryAdapter;
import forestry.farming.gadgets.TileFarmPlain;
import forestry.plugins.PluginFarming;
@@ -37,43 +36,40 @@ public class ContainerFarm extends ContainerSocketed {
this.tile = tile;
IInventory inventory = tile.getInventory();
// Tile will not have an inventory client side.
if (inventory == null)
inventory = new TileInventoryAdapter(tile, TileFarmPlain.SLOT_COUNT, "Items");
IInventory inv = tile.getInventory();
// Resources
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 2; j++) {
addSlot(new SlotResources(inventory, tile.getFarmLogics(), TileFarmPlain.SLOT_RESOURCES_1 + j + i * 2, 123 + j * 18, 22 + i * 18));
addSlot(new SlotResources(inv, tile.getFarmLogics(), TileFarmPlain.SLOT_RESOURCES_1 + j + i * 2, 123 + j * 18, 22 + i * 18));
}
}
// Germlings
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 2; j++) {
addSlot(new SlotGermlings(inventory, tile.getFarmLogics(), TileFarmPlain.SLOT_GERMLINGS_1 + j + i * 2, 164 + j * 18, 22 + i * 18));
addSlot(new SlotGermlings(inv, tile.getFarmLogics(), TileFarmPlain.SLOT_GERMLINGS_1 + j + i * 2, 164 + j * 18, 22 + i * 18));
}
}
// Production 1
for (int i = 0; i < 2; i++) {
for (int j = 0; j < 2; j++) {
addSlot(new SlotOutput(inventory, TileFarmPlain.SLOT_PRODUCTION_1 + j + i * 2, 123 + j * 18, 86 + i * 18));
addSlot(new SlotOutput(inv, TileFarmPlain.SLOT_PRODUCTION_1 + j + i * 2, 123 + j * 18, 86 + i * 18));
}
}
// Production 2
for (int i = 0; i < 2; i++) {
for (int j = 0; j < 2; j++) {
addSlot(new SlotOutput(inventory, TileFarmPlain.SLOT_PRODUCTION_1 + 4 + j + i * 2, 164 + j * 18, 86 + i * 18));
addSlot(new SlotOutput(inv, TileFarmPlain.SLOT_PRODUCTION_1 + 4 + j + i * 2, 164 + j * 18, 86 + i * 18));
}
}
// Fertilizer
addSlot(new SlotCustom(inventory, TileFarmPlain.SLOT_FERTILIZER, 63, 95, PluginFarming.farmFertilizer));
addSlot(new SlotCustom(inv, TileFarmPlain.SLOT_FERTILIZER, 63, 95, PluginFarming.farmFertilizer));
// Can Slot
addSlot(new SlotLiquidContainer(inventory, TileFarmPlain.SLOT_CAN, 15, 95));
addSlot(new SlotLiquidContainer(inv, TileFarmPlain.SLOT_CAN, 15, 95));
// Player inventory
for (int i = 0; i < 3; i++) {
@@ -23,6 +23,7 @@ import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import java.util.ArrayList;
@@ -33,7 +34,7 @@ public abstract class FarmLogicWatered extends FarmLogic {
protected ItemStack ground;
private final ItemStack[] resource;
private static final FluidStack STACK_WATER = new FluidStack(LiquidHelper.getFluid(Defaults.LIQUID_WATER), 1000);
private static final FluidStack STACK_WATER = new FluidStack(FluidRegistry.getFluid(Defaults.LIQUID_WATER), 1000);
ArrayList<ItemStack> produce = new ArrayList<ItemStack>();
@@ -10,6 +10,29 @@
******************************************************************************/
package forestry.plugins;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.Potion;
import net.minecraft.util.IIcon;
import net.minecraft.util.WeightedRandomChestContent;
import net.minecraftforge.client.event.TextureStitchEvent;
import net.minecraftforge.common.BiomeDictionary;
import net.minecraftforge.common.ChestGenHooks;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.oredict.OreDictionary;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage;
@@ -20,6 +43,7 @@ import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.VillagerRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.EnumBeeType;
import forestry.api.apiculture.FlowerManager;
@@ -37,7 +61,6 @@ import forestry.api.genetics.IAllele;
import forestry.api.genetics.IClassification;
import forestry.api.genetics.IClassification.EnumClassLevel;
import forestry.api.recipes.RecipeManagers;
import forestry.apiculture.commands.CommandBeekeeping;
import forestry.apiculture.FlowerProviderCacti;
import forestry.apiculture.FlowerProviderEnd;
import forestry.apiculture.FlowerProviderGourd;
@@ -50,6 +73,7 @@ import forestry.apiculture.GuiHandlerApiculture;
import forestry.apiculture.PacketHandlerApiculture;
import forestry.apiculture.SaveEventHandlerApiculture;
import forestry.apiculture.VillageHandlerApiculture;
import forestry.apiculture.commands.CommandBeekeeping;
import forestry.apiculture.gadgets.BlockAlveary;
import forestry.apiculture.gadgets.BlockBeehives;
import forestry.apiculture.gadgets.BlockCandle;
@@ -71,6 +95,8 @@ import forestry.apiculture.genetics.AlleleBeeSpecies;
import forestry.apiculture.genetics.AlleleEffectAggressive;
import forestry.apiculture.genetics.AlleleEffectCreeper;
import forestry.apiculture.genetics.AlleleEffectExploration;
import forestry.apiculture.genetics.AlleleEffectFertile;
import forestry.apiculture.genetics.AlleleEffectFungification;
import forestry.apiculture.genetics.AlleleEffectGlacial;
import forestry.apiculture.genetics.AlleleEffectHeroic;
import forestry.apiculture.genetics.AlleleEffectIgnition;
@@ -82,7 +108,6 @@ import forestry.apiculture.genetics.AlleleEffectRadioactive;
import forestry.apiculture.genetics.AlleleEffectRepulsion;
import forestry.apiculture.genetics.AlleleEffectResurrection;
import forestry.apiculture.genetics.AlleleEffectSnowing;
import forestry.apiculture.genetics.AlleleEffectFertile;
import forestry.apiculture.genetics.AlleleFlowers;
import forestry.apiculture.genetics.Bee;
import forestry.apiculture.genetics.BeeHelper;
@@ -105,7 +130,6 @@ import forestry.apiculture.items.ItemImprinter;
import forestry.apiculture.items.ItemWaxCast;
import forestry.apiculture.proxy.ProxyApiculture;
import forestry.apiculture.trigger.ApicultureTriggers;
import forestry.apiculture.trigger.TriggerNoFrames;
import forestry.apiculture.worldgen.HiveDecorator;
import forestry.apiculture.worldgen.HiveEnd;
import forestry.apiculture.worldgen.HiveForest;
@@ -136,30 +160,7 @@ import forestry.core.items.ItemOverlay.OverlayInfo;
import forestry.core.items.ItemScoop;
import forestry.core.proxy.Proxies;
import forestry.core.render.EntitySnowFX;
import forestry.core.triggers.Trigger;
import forestry.core.utils.LiquidHelper;
import forestry.core.utils.ShapedRecipeCustom;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.command.ICommand;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.Potion;
import net.minecraft.util.IIcon;
import net.minecraft.util.WeightedRandomChestContent;
import net.minecraftforge.client.event.TextureStitchEvent;
import net.minecraftforge.common.BiomeDictionary;
import net.minecraftforge.common.ChestGenHooks;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.oredict.OreDictionary;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
@Plugin(pluginID = "Apiculture", name = "Apiculture", author = "SirSengir", url = Defaults.URL, unlocalizedDescription = "for.plugin.apiculture.description")
public class PluginApiculture extends ForestryPlugin {
@@ -315,11 +316,6 @@ public class PluginApiculture extends ForestryPlugin {
registerTemplates();
definitionAnalyzer.register();
definitionApiary.register();
definitionBeehouse.register();
definitionChest.register();
GameRegistry.registerTileEntity(TileAlvearyPlain.class, "forestry.Alveary");
GameRegistry.registerTileEntity(TileSwarm.class, "forestry.Swarm");
GameRegistry.registerTileEntity(TileAlvearySwarmer.class, "forestry.AlvearySwarmer");
@@ -567,13 +563,13 @@ public class PluginApiculture extends ForestryPlugin {
'#', ForestryItem.propolis.getItemStack(1, 2));
// / CANDLES
RecipeManagers.carpenterManager.addRecipe(30, LiquidHelper.getLiquid(Defaults.LIQUID_WATER, 600), null, ForestryBlock.candle.getItemStack(24),
RecipeManagers.carpenterManager.addRecipe(30, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 600), null, ForestryBlock.candle.getItemStack(24),
" X ",
"###",
"###",
'#', ForestryItem.beeswax,
'X', Items.string);
RecipeManagers.carpenterManager.addRecipe(10, LiquidHelper.getLiquid(Defaults.LIQUID_WATER, 200), null, ForestryBlock.candle.getItemStack(6),
RecipeManagers.carpenterManager.addRecipe(10, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 200), null, ForestryBlock.candle.getItemStack(6),
"#X#",
'#', ForestryItem.beeswax,
'X', ForestryItem.craftingMaterial.getItemStack(1, 2));
@@ -643,20 +639,20 @@ public class PluginApiculture extends ForestryPlugin {
'W', ForestryItem.craftingMaterial.getItemStack(1, 3));
// / SQUEEZER
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{ForestryItem.honeyDrop.getItemStack()}, LiquidHelper.getLiquid(Defaults.LIQUID_HONEY, Defaults.FLUID_PER_HONEY_DROP),
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{ForestryItem.honeyDrop.getItemStack()}, FluidRegistry.getFluidStack(Defaults.LIQUID_HONEY, Defaults.FLUID_PER_HONEY_DROP),
ForestryItem.propolis.getItemStack(), 5);
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{ForestryItem.honeydew.getItemStack()}, LiquidHelper.getLiquid(Defaults.LIQUID_HONEY, Defaults.FLUID_PER_HONEY_DROP));
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{ForestryItem.phosphor.getItemStack(2), new ItemStack(Blocks.sand)}, LiquidHelper.getLiquid(Defaults.LIQUID_LAVA, 2000));
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{ForestryItem.phosphor.getItemStack(2), new ItemStack(Blocks.dirt)}, LiquidHelper.getLiquid(Defaults.LIQUID_LAVA, 1600));
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{ForestryItem.honeydew.getItemStack()}, FluidRegistry.getFluidStack(Defaults.LIQUID_HONEY, Defaults.FLUID_PER_HONEY_DROP));
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{ForestryItem.phosphor.getItemStack(2), new ItemStack(Blocks.sand)}, FluidRegistry.getFluidStack(Defaults.LIQUID_LAVA, 2000));
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{ForestryItem.phosphor.getItemStack(2), new ItemStack(Blocks.dirt)}, FluidRegistry.getFluidStack(Defaults.LIQUID_LAVA, 1600));
// / CARPENTER
RecipeManagers.carpenterManager.addRecipe(100, LiquidHelper.getLiquid(Defaults.LIQUID_WATER, 2000), null, ForestryItem.beealyzer.getItemStack(),
RecipeManagers.carpenterManager.addRecipe(100, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 2000), null, ForestryItem.beealyzer.getItemStack(),
"X#X", "X#X", "RDR",
'#', Blocks.glass_pane,
'X', "ingotTin",
'R', Items.redstone,
'D', Items.diamond);
RecipeManagers.carpenterManager.addRecipe(50, LiquidHelper.getLiquid(Defaults.LIQUID_HONEY, 500), null, ForestryItem.craftingMaterial.getItemStack(1, 6),
RecipeManagers.carpenterManager.addRecipe(50, FluidRegistry.getFluidStack(Defaults.LIQUID_HONEY, 500), null, ForestryItem.craftingMaterial.getItemStack(1, 6),
" J ", "###", "WPW",
'#', "plankWood",
'J', ForestryItem.royalJelly,
@@ -711,11 +707,16 @@ public class PluginApiculture extends ForestryPlugin {
ForestryItem.craftingMaterial.getItemStack(1, 2), ForestryItem.propolis.getItemStack()}, new int[]{60, 10});
// / FERMENTER
RecipeManagers.fermenterManager.addRecipe(ForestryItem.honeydew.getItemStack(), 500, 1.0f, LiquidHelper.getLiquid(Defaults.LIQUID_MEAD, 1),
LiquidHelper.getLiquid(Defaults.LIQUID_HONEY, 1));
RecipeManagers.fermenterManager.addRecipe(ForestryItem.honeydew.getItemStack(), 500, 1.0f, FluidRegistry.getFluidStack(Defaults.LIQUID_MEAD, 1),
FluidRegistry.getFluidStack(Defaults.LIQUID_HONEY, 1));
// ANALYZER
definitionAnalyzer.recipes = createAlyzerRecipes(ForestryBlock.core.block(), Defaults.DEFINITION_ANALYZER_META);
definitionAnalyzer.register();
definitionApiary.register();
definitionBeehouse.register();
definitionChest.register();
}
public IRecipe[] createAlyzerRecipes(Block block, int meta) {
@@ -1037,8 +1038,10 @@ public class PluginApiculture extends ForestryPlugin {
// Boggy branch
Allele.speciesMarshy = new AlleleBeeSpecies("speciesMarshy", true, "bees.species.marshy", boggy, "adorasti", 0x546626, 0xffdc16).addProduct(
ForestryItem.beeComb.getItemStack(1, 15), 30).setHumidity(EnumHumidity.DAMP);
// 44 speciesMiry
// 45 speciesBoggy
Allele.speciesMiry = new AlleleBeeSpecies("speciesMiry", true, "bees.species.miry", boggy, "humidium", 0x92AF42, 0xffdc16).addProduct(
ForestryItem.beeComb.getItemStack(1, 15), 36).setHumidity(EnumHumidity.DAMP).setIsSecret();
Allele.speciesBoggy = new AlleleBeeSpecies("speciesBoggy", true, "bees.species.boggy", boggy, "paluster", 0x698948, 0xffdc16).addProduct(
ForestryItem.beeComb.getItemStack(1, 15), 39).addSpecialty(ForestryItem.peat.getItemStack(1), 8).setHumidity(EnumHumidity.DAMP).setIsSecret();
// Monastic branch
Allele.speciesMonastic = new AlleleBeeSpecies("speciesMonastic", false, "bees.species.monastic", monastic, "monachus", 0x42371c, 0xfff7b6)
@@ -1079,6 +1082,7 @@ public class PluginApiculture extends ForestryPlugin {
Allele.effectResurrection = new AlleleEffectResurrection("effectResurrection", "resurrection", AlleleEffectResurrection.getResurrectionList());
Allele.effectRepulsion = new AlleleEffectRepulsion("effectRepulsion");
Allele.effectFertile = new AlleleEffectFertile("effectFertile");
Allele.effectMycophilic = new AlleleEffectFungification("effectMycophilic");
}
@@ -1168,6 +1172,12 @@ public class PluginApiculture extends ForestryPlugin {
.restrictBiomeType(BiomeDictionary.Type.PLAINS).enableStrictBiomeCheck();
new BeeMutation(Allele.speciesFarmerly, Allele.speciesIndustrious, BeeTemplates.getAgrarianTemplate(), 6)
.restrictBiomeType(BiomeDictionary.Type.PLAINS).enableStrictBiomeCheck();
// Boggy branch
new BeeMutation(Allele.speciesMarshy, Allele.speciesNoble, BeeTemplates.getMiryTemplate(), 15)
.setTemperatureRainfall(0.75f, 0.94f, 0.75f, 2.0f);
new BeeMutation(Allele.speciesMarshy, Allele.speciesMiry, BeeTemplates.getBoggyTemplate(), 9)
.setTemperatureRainfall(0.75f, 0.94f, 0.75f, 2.0f);
// Monastic branch
BeeTemplates.secludedA = new BeeMutation(Allele.speciesMonastic, Allele.speciesAustere, BeeTemplates.getSecludedTemplate(), 12);
@@ -1225,6 +1235,8 @@ public class PluginApiculture extends ForestryPlugin {
beeInterface.registerTemplate(BeeTemplates.getTipsyTemplate());
beeInterface.registerTemplate(BeeTemplates.getTrickyTemplate());
beeInterface.registerTemplate(BeeTemplates.getMarshyTemplate());
beeInterface.registerTemplate(BeeTemplates.getMiryTemplate());
beeInterface.registerTemplate(BeeTemplates.getBoggyTemplate());
beeInterface.registerTemplate(BeeTemplates.getMonasticTemplate());
beeInterface.registerTemplate(BeeTemplates.getSecludedTemplate());
beeInterface.registerTemplate(BeeTemplates.getHermiticTemplate());
@@ -10,6 +10,24 @@
******************************************************************************/
package forestry.plugins;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.command.ICommand;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.WeightedRandomChestContent;
import net.minecraftforge.common.ChestGenHooks;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.oredict.OreDictionary;
import cpw.mods.fml.common.IFuelHandler;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage;
@@ -17,6 +35,7 @@ import cpw.mods.fml.common.network.IGuiHandler;
import cpw.mods.fml.common.registry.GameData;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.VillagerRegistry;
import forestry.api.arboriculture.EnumGermlingType;
import forestry.api.arboriculture.ITree;
import forestry.api.arboriculture.ITreeRoot;
@@ -122,24 +141,8 @@ import forestry.core.interfaces.IPacketHandler;
import forestry.core.items.ItemForestryBlock;
import forestry.core.items.ItemFruit.EnumFruit;
import forestry.core.proxy.Proxies;
import forestry.core.utils.LiquidHelper;
import forestry.core.utils.RecipeUtil;
import forestry.core.utils.ShapedRecipeCustom;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.command.ICommand;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.WeightedRandomChestContent;
import net.minecraftforge.common.ChestGenHooks;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.oredict.OreDictionary;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
@Plugin(pluginID = "Arboriculture", name = "Arboriculture", author = "Binnie & SirSengir", url = Defaults.URL, unlocalizedDescription = "for.plugin.arboriculture.description")
public class PluginArboriculture extends ForestryPlugin {
@@ -409,7 +412,7 @@ public class PluginArboriculture extends ForestryPlugin {
ItemStack logStack = forestryBlock.getItemStack(1, i);
ItemStack fireproofLogStack = fireproofLog.getItemStack(1, i);
RecipeManagers.fabricatorManager.addRecipe(null, LiquidHelper.getLiquid(Defaults.LIQUID_GLASS, 500), fireproofLogStack, new Object[]{
RecipeManagers.fabricatorManager.addRecipe(null, FluidRegistry.getFluidStack(Defaults.LIQUID_GLASS, 500), fireproofLogStack, new Object[]{
" # ",
"#X#",
" # ",
@@ -424,7 +427,7 @@ public class PluginArboriculture extends ForestryPlugin {
ForestryBlock fireproofPlank = BlockFireproofPlanks.getFireproofPlanks((BlockPlanks)plank.block());
ItemStack plankStack = plank.getItemStack(1, i);
ItemStack fireproofPlankStack = fireproofPlank.getItemStack(5, i);
RecipeManagers.fabricatorManager.addRecipe(null, LiquidHelper.getLiquid(Defaults.LIQUID_GLASS, 500), fireproofPlankStack, new Object[]{
RecipeManagers.fabricatorManager.addRecipe(null, FluidRegistry.getFluidStack(Defaults.LIQUID_GLASS, 500), fireproofPlankStack, new Object[]{
"X#X",
"#X#",
"X#X",
@@ -436,7 +439,7 @@ public class PluginArboriculture extends ForestryPlugin {
ForestryBlock fireproofPlank = BlockFireproofPlanks.getFireproofPlanks((BlockPlanks)plank.block());
ItemStack plankStack = plank.getItemStack(1, i);
ItemStack fireproofPlankStack = fireproofPlank.getItemStack(5, i);
RecipeManagers.fabricatorManager.addRecipe(null, LiquidHelper.getLiquid(Defaults.LIQUID_GLASS, 500), fireproofPlankStack, new Object[]{
RecipeManagers.fabricatorManager.addRecipe(null, FluidRegistry.getFluidStack(Defaults.LIQUID_GLASS, 500), fireproofPlankStack, new Object[]{
"X#X",
"#X#",
"X#X",
@@ -474,20 +477,20 @@ public class PluginArboriculture extends ForestryPlugin {
Proxies.common.addRecipe(ForestryBlock.fences2.getItemStack(4, i), "###", "# #", '#', ForestryBlock.planks2.getItemStack(1, i));
// Treealyzer
RecipeManagers.carpenterManager.addRecipe(100, LiquidHelper.getLiquid(Defaults.LIQUID_WATER, 2000), null, ForestryItem.treealyzer.getItemStack(), "X#X", "X#X", "RDR",
RecipeManagers.carpenterManager.addRecipe(100, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 2000), null, ForestryItem.treealyzer.getItemStack(), "X#X", "X#X", "RDR",
'#', Blocks.glass_pane,
'X', "ingotCopper",
'R', Items.redstone,
'D', Items.diamond);
// SQUEEZER RECIPES
RecipeManagers.squeezerManager.addRecipe(20, new ItemStack[]{ForestryItem.fruits.getItemStack(1, EnumFruit.CHERRY.ordinal())}, LiquidHelper.getLiquid(Defaults.LIQUID_SEEDOIL, 5 * GameMode.getGameMode().getIntegerSetting("squeezer.liquid.seed")), ForestryItem.mulch.getItemStack(), 5);
RecipeManagers.squeezerManager.addRecipe(60, new ItemStack[]{ForestryItem.fruits.getItemStack(1, EnumFruit.WALNUT.ordinal())}, LiquidHelper.getLiquid(Defaults.LIQUID_SEEDOIL, 18 * GameMode.getGameMode().getIntegerSetting("squeezer.liquid.seed")), ForestryItem.mulch.getItemStack(), 5);
RecipeManagers.squeezerManager.addRecipe(70, new ItemStack[]{ForestryItem.fruits.getItemStack(1, EnumFruit.CHESTNUT.ordinal())}, LiquidHelper.getLiquid(Defaults.LIQUID_SEEDOIL, 22 * GameMode.getGameMode().getIntegerSetting("squeezer.liquid.seed")), ForestryItem.mulch.getItemStack(), 2);
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{ForestryItem.fruits.getItemStack(1, EnumFruit.LEMON.ordinal())}, LiquidHelper.getLiquid(Defaults.LIQUID_JUICE, GameMode.getGameMode().getIntegerSetting("squeezer.liquid.apple") * 2), ForestryItem.mulch.getItemStack(), (int) Math.floor(GameMode.getGameMode().getIntegerSetting("squeezer.mulch.apple") * 0.5f));
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{ForestryItem.fruits.getItemStack(1, EnumFruit.PLUM.ordinal())}, LiquidHelper.getLiquid(Defaults.LIQUID_JUICE, (int) Math.floor(GameMode.getGameMode().getIntegerSetting("squeezer.liquid.apple") * 0.5f)), ForestryItem.mulch.getItemStack(), GameMode.getGameMode().getIntegerSetting("squeezer.mulch.apple") * 3);
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{ForestryItem.fruits.getItemStack(1, EnumFruit.PAPAYA.ordinal())}, LiquidHelper.getLiquid(Defaults.LIQUID_JUICE, GameMode.getGameMode().getIntegerSetting("squeezer.liquid.apple") * 3), ForestryItem.mulch.getItemStack(), (int) Math.floor(GameMode.getGameMode().getIntegerSetting("squeezer.mulch.apple") * 0.5f));
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{ForestryItem.fruits.getItemStack(1, EnumFruit.DATES.ordinal())}, LiquidHelper.getLiquid(Defaults.LIQUID_JUICE, (int) Math.floor(GameMode.getGameMode().getIntegerSetting("squeezer.liquid.apple") * 0.25)), ForestryItem.mulch.getItemStack(), (int) Math.floor(GameMode.getGameMode().getIntegerSetting("squeezer.mulch.apple")));
RecipeManagers.squeezerManager.addRecipe(20, new ItemStack[]{ForestryItem.fruits.getItemStack(1, EnumFruit.CHERRY.ordinal())}, FluidRegistry.getFluidStack(Defaults.LIQUID_SEEDOIL, 5 * GameMode.getGameMode().getIntegerSetting("squeezer.liquid.seed")), ForestryItem.mulch.getItemStack(), 5);
RecipeManagers.squeezerManager.addRecipe(60, new ItemStack[]{ForestryItem.fruits.getItemStack(1, EnumFruit.WALNUT.ordinal())}, FluidRegistry.getFluidStack(Defaults.LIQUID_SEEDOIL, 18 * GameMode.getGameMode().getIntegerSetting("squeezer.liquid.seed")), ForestryItem.mulch.getItemStack(), 5);
RecipeManagers.squeezerManager.addRecipe(70, new ItemStack[]{ForestryItem.fruits.getItemStack(1, EnumFruit.CHESTNUT.ordinal())}, FluidRegistry.getFluidStack(Defaults.LIQUID_SEEDOIL, 22 * GameMode.getGameMode().getIntegerSetting("squeezer.liquid.seed")), ForestryItem.mulch.getItemStack(), 2);
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{ForestryItem.fruits.getItemStack(1, EnumFruit.LEMON.ordinal())}, FluidRegistry.getFluidStack(Defaults.LIQUID_JUICE, GameMode.getGameMode().getIntegerSetting("squeezer.liquid.apple") * 2), ForestryItem.mulch.getItemStack(), (int) Math.floor(GameMode.getGameMode().getIntegerSetting("squeezer.mulch.apple") * 0.5f));
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{ForestryItem.fruits.getItemStack(1, EnumFruit.PLUM.ordinal())}, FluidRegistry.getFluidStack(Defaults.LIQUID_JUICE, (int) Math.floor(GameMode.getGameMode().getIntegerSetting("squeezer.liquid.apple") * 0.5f)), ForestryItem.mulch.getItemStack(), GameMode.getGameMode().getIntegerSetting("squeezer.mulch.apple") * 3);
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{ForestryItem.fruits.getItemStack(1, EnumFruit.PAPAYA.ordinal())}, FluidRegistry.getFluidStack(Defaults.LIQUID_JUICE, GameMode.getGameMode().getIntegerSetting("squeezer.liquid.apple") * 3), ForestryItem.mulch.getItemStack(), (int) Math.floor(GameMode.getGameMode().getIntegerSetting("squeezer.mulch.apple") * 0.5f));
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{ForestryItem.fruits.getItemStack(1, EnumFruit.DATES.ordinal())}, FluidRegistry.getFluidStack(Defaults.LIQUID_JUICE, (int) Math.floor(GameMode.getGameMode().getIntegerSetting("squeezer.liquid.apple") * 0.25)), ForestryItem.mulch.getItemStack(), (int) Math.floor(GameMode.getGameMode().getIntegerSetting("squeezer.mulch.apple")));
RecipeUtil.injectLeveledRecipe(ForestryItem.sapling.getItemStack(), GameMode.getGameMode().getIntegerSetting("fermenter.yield.sapling"), Defaults.LIQUID_BIOMASS);
@@ -10,14 +10,18 @@
******************************************************************************/
package forestry.plugins;
import buildcraft.api.fuels.BuildcraftFuelRegistry;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import cpw.mods.fml.common.Optional;
import forestry.core.GameMode;
import forestry.core.config.Defaults;
import forestry.core.config.ForestryItem;
import forestry.core.proxy.Proxies;
import forestry.core.utils.LiquidHelper;
import net.minecraftforge.fluids.Fluid;
import buildcraft.api.fuels.BuildcraftFuelRegistry;
@Plugin(pluginID = "BC6|Fuels", name = "BuildCraft 6 Fuels", author = "mezz", url = Defaults.URL, unlocalizedDescription = "for.plugin.buildcraft6.description")
public class PluginBuildCraftFuels extends ForestryPlugin {
@@ -35,9 +39,9 @@ public class PluginBuildCraftFuels extends ForestryPlugin {
@Optional.Method(modid = "BuildCraftAPI|fuels")
@Override
public void doInit() {
BuildcraftFuelRegistry.coolant.addCoolant(LiquidHelper.getFluid(Defaults.LIQUID_ICE), 10.0f);
BuildcraftFuelRegistry.coolant.addCoolant(FluidRegistry.getFluid(Defaults.LIQUID_ICE), 10.0f);
Fluid ethanol = LiquidHelper.getLiquid(Defaults.LIQUID_ETHANOL, 1).getFluid();
Fluid ethanol = FluidRegistry.getFluidStack(Defaults.LIQUID_ETHANOL, 1).getFluid();
int ethanolPower = 40;
int ethanolBurnTime = Math.round(Defaults.ENGINE_CYCLE_DURATION_ETHANOL * GameMode.getGameMode().getFloatSetting("fuel.ethanol.combustion"));
BuildcraftFuelRegistry.fuel.addFuel(ethanol, ethanolPower, ethanolBurnTime);
@@ -10,12 +10,15 @@
******************************************************************************/
package forestry.plugins;
import buildcraft.api.recipes.BuildcraftRecipeRegistry;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import cpw.mods.fml.common.Optional;
import forestry.core.config.Defaults;
import forestry.core.proxy.Proxies;
import forestry.core.utils.LiquidHelper;
import net.minecraftforge.fluids.FluidStack;
import buildcraft.api.recipes.BuildcraftRecipeRegistry;
@Plugin(pluginID = "BC6|Recipes", name = "BuildCraft 6 Recipes", author = "SirSengir", url = Defaults.URL, unlocalizedDescription = "for.plugin.buildcraft6.description")
public class PluginBuildCraftRecipes extends ForestryPlugin {
@@ -34,8 +37,8 @@ public class PluginBuildCraftRecipes extends ForestryPlugin {
@Override
protected void registerRecipes() {
// Add recipe for ethanol
FluidStack input = LiquidHelper.getLiquid(Defaults.LIQUID_BIOMASS, 4);
FluidStack output = LiquidHelper.getLiquid(Defaults.LIQUID_ETHANOL, 1);
FluidStack input = FluidRegistry.getFluidStack(Defaults.LIQUID_BIOMASS, 4);
FluidStack output = FluidRegistry.getFluidStack(Defaults.LIQUID_ETHANOL, 1);
BuildcraftRecipeRegistry.refinery.addRecipe("forestry:BiomassToEthanol", input, output, 100, 1);
}
}
@@ -10,7 +10,17 @@
******************************************************************************/
package forestry.plugins;
import java.util.ArrayList;
import net.minecraft.block.material.Material;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidRegistry;
import cpw.mods.fml.common.network.IGuiHandler;
import forestry.api.recipes.ICraftingProvider;
import forestry.api.recipes.RecipeManagers;
import forestry.core.GameMode;
@@ -25,7 +35,6 @@ import forestry.core.interfaces.ISaveEventHandler;
import forestry.core.items.ItemForestryBlock;
import forestry.core.items.ItemNBTTile;
import forestry.core.proxy.Proxies;
import forestry.core.utils.LiquidHelper;
import forestry.core.utils.RecipeUtil;
import forestry.core.utils.ShapedRecipeCustom;
import forestry.factory.GuiHandlerFactory;
@@ -42,12 +51,6 @@ import forestry.factory.gadgets.MillRainmaker;
import forestry.factory.gadgets.TileWorktable;
import forestry.factory.recipes.CraftGuideIntegration;
import forestry.factory.triggers.FactoryTriggers;
import net.minecraft.block.material.Material;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import java.util.ArrayList;
@Plugin(pluginID = "Factory", name = "Factory", author = "SirSengir", url = Defaults.URL, unlocalizedDescription = "for.plugin.factory.description")
public class PluginFactory extends ForestryPlugin {
@@ -250,27 +253,27 @@ public class PluginFactory extends ForestryPlugin {
protected void registerRecipes() {
// / FABRICATOR
RecipeManagers.fabricatorManager.addRecipe(null, LiquidHelper.getLiquid(Defaults.LIQUID_GLASS, 500), ForestryItem.tubes.getItemStack(4, 0), new Object[]{
RecipeManagers.fabricatorManager.addRecipe(null, FluidRegistry.getFluidStack(Defaults.LIQUID_GLASS, 500), ForestryItem.tubes.getItemStack(4, 0), new Object[]{
" X ", "#X#", "XXX", '#', Items.redstone, 'X', "ingotCopper"});
RecipeManagers.fabricatorManager.addRecipe(null, LiquidHelper.getLiquid(Defaults.LIQUID_GLASS, 500), ForestryItem.tubes.getItemStack(4, 1), new Object[]{
RecipeManagers.fabricatorManager.addRecipe(null, FluidRegistry.getFluidStack(Defaults.LIQUID_GLASS, 500), ForestryItem.tubes.getItemStack(4, 1), new Object[]{
" X ", "#X#", "XXX", '#', Items.redstone, 'X', "ingotTin"});
RecipeManagers.fabricatorManager.addRecipe(null, LiquidHelper.getLiquid(Defaults.LIQUID_GLASS, 500), ForestryItem.tubes.getItemStack(4, 2), new Object[]{
RecipeManagers.fabricatorManager.addRecipe(null, FluidRegistry.getFluidStack(Defaults.LIQUID_GLASS, 500), ForestryItem.tubes.getItemStack(4, 2), new Object[]{
" X ", "#X#", "XXX", '#', Items.redstone, 'X', "ingotBronze"});
RecipeManagers.fabricatorManager.addRecipe(null, LiquidHelper.getLiquid(Defaults.LIQUID_GLASS, 500), ForestryItem.tubes.getItemStack(4, 3), new Object[]{
RecipeManagers.fabricatorManager.addRecipe(null, FluidRegistry.getFluidStack(Defaults.LIQUID_GLASS, 500), ForestryItem.tubes.getItemStack(4, 3), new Object[]{
" X ", "#X#", "XXX", '#', Items.redstone, 'X', Items.iron_ingot});
RecipeManagers.fabricatorManager.addRecipe(null, LiquidHelper.getLiquid(Defaults.LIQUID_GLASS, 500), ForestryItem.tubes.getItemStack(4, 4), new Object[]{
RecipeManagers.fabricatorManager.addRecipe(null, FluidRegistry.getFluidStack(Defaults.LIQUID_GLASS, 500), ForestryItem.tubes.getItemStack(4, 4), new Object[]{
" X ", "#X#", "XXX", '#', Items.redstone, 'X', Items.gold_ingot});
RecipeManagers.fabricatorManager.addRecipe(null, LiquidHelper.getLiquid(Defaults.LIQUID_GLASS, 500), ForestryItem.tubes.getItemStack(4, 5), new Object[]{
RecipeManagers.fabricatorManager.addRecipe(null, FluidRegistry.getFluidStack(Defaults.LIQUID_GLASS, 500), ForestryItem.tubes.getItemStack(4, 5), new Object[]{
" X ", "#X#", "XXX", '#', Items.redstone, 'X', Items.diamond});
RecipeManagers.fabricatorManager.addRecipe(null, LiquidHelper.getLiquid(Defaults.LIQUID_GLASS, 500), ForestryItem.tubes.getItemStack(4, 6), new Object[]{
RecipeManagers.fabricatorManager.addRecipe(null, FluidRegistry.getFluidStack(Defaults.LIQUID_GLASS, 500), ForestryItem.tubes.getItemStack(4, 6), new Object[]{
" X ", "#X#", "XXX", '#', Items.redstone, 'X', Blocks.obsidian});
RecipeManagers.fabricatorManager.addRecipe(null, LiquidHelper.getLiquid(Defaults.LIQUID_GLASS, 500), ForestryItem.tubes.getItemStack(4, 7), new Object[]{
RecipeManagers.fabricatorManager.addRecipe(null, FluidRegistry.getFluidStack(Defaults.LIQUID_GLASS, 500), ForestryItem.tubes.getItemStack(4, 7), new Object[]{
" X ", "#X#", "XXX", '#', Items.redstone, 'X', Items.blaze_powder});
RecipeManagers.fabricatorManager.addRecipe(null, LiquidHelper.getLiquid(Defaults.LIQUID_GLASS, 500), ForestryItem.tubes.getItemStack(4, 9), new Object[]{
RecipeManagers.fabricatorManager.addRecipe(null, FluidRegistry.getFluidStack(Defaults.LIQUID_GLASS, 500), ForestryItem.tubes.getItemStack(4, 9), new Object[]{
" X ", "#X#", "XXX", '#', Items.redstone, 'X', Items.emerald});
RecipeManagers.fabricatorManager.addRecipe(null, LiquidHelper.getLiquid(Defaults.LIQUID_GLASS, 500), ForestryItem.tubes.getItemStack(4, 10),
RecipeManagers.fabricatorManager.addRecipe(null, FluidRegistry.getFluidStack(Defaults.LIQUID_GLASS, 500), ForestryItem.tubes.getItemStack(4, 10),
new Object[]{" X ", "#X#", "XXX", '#', Items.redstone, 'X', "gemApatite"});
RecipeManagers.fabricatorManager.addRecipe(null, LiquidHelper.getLiquid(Defaults.LIQUID_GLASS, 500), ForestryItem.tubes.getItemStack(4, 11),
RecipeManagers.fabricatorManager.addRecipe(null, FluidRegistry.getFluidStack(Defaults.LIQUID_GLASS, 500), ForestryItem.tubes.getItemStack(4, 11),
new Object[]{" X ", "#X#", "XXX", '#', Items.redstone, 'X', new ItemStack(Items.dye, 1, 4)});
String[] dyes = {"dyeBlack", "dyeRed", "dyeGreen", "dyeBrown", "dyeBlue", "dyePurple", "dyeCyan", "dyeLightGray", "dyeGray", "dyePink", "dyeLime",
@@ -278,28 +281,28 @@ public class PluginFactory extends ForestryPlugin {
if (PluginManager.Module.APICULTURE.isEnabled())
for (int i = 0; i < 16; i++)
RecipeManagers.fabricatorManager.addRecipe(ForestryItem.waxCast.getItemStack(1, Defaults.WILDCARD), LiquidHelper.getLiquid(Defaults.LIQUID_GLASS,
RecipeManagers.fabricatorManager.addRecipe(ForestryItem.waxCast.getItemStack(1, Defaults.WILDCARD), FluidRegistry.getFluidStack(Defaults.LIQUID_GLASS,
Defaults.BUCKET_VOLUME), ForestryBlock.glass.getItemStack(1, 15 - i), new Object[]{"#", "X", '#', dyes[i],
'X', ForestryItem.propolis.getItemStack(1, Defaults.WILDCARD)});
// / SQUEEZER
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{new ItemStack(Items.apple)}, LiquidHelper.getLiquid(Defaults.LIQUID_JUICE, GameMode.getGameMode().getIntegerSetting("squeezer.liquid.apple")),
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{new ItemStack(Items.apple)}, FluidRegistry.getFluidStack(Defaults.LIQUID_JUICE, GameMode.getGameMode().getIntegerSetting("squeezer.liquid.apple")),
ForestryItem.mulch.getItemStack(), GameMode.getGameMode().getIntegerSetting("squeezer.mulch.apple"));
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{new ItemStack(Items.wheat_seeds)}, LiquidHelper.getLiquid(Defaults.LIQUID_SEEDOIL, GameMode
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{new ItemStack(Items.wheat_seeds)}, FluidRegistry.getFluidStack(Defaults.LIQUID_SEEDOIL, GameMode
.getGameMode().getIntegerSetting("squeezer.liquid.seed")));
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{new ItemStack(Items.pumpkin_seeds)}, LiquidHelper.getLiquid(Defaults.LIQUID_SEEDOIL, GameMode
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{new ItemStack(Items.pumpkin_seeds)}, FluidRegistry.getFluidStack(Defaults.LIQUID_SEEDOIL, GameMode
.getGameMode().getIntegerSetting("squeezer.liquid.seed")));
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{new ItemStack(Items.melon_seeds)}, LiquidHelper.getLiquid(Defaults.LIQUID_SEEDOIL, GameMode
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{new ItemStack(Items.melon_seeds)}, FluidRegistry.getFluidStack(Defaults.LIQUID_SEEDOIL, GameMode
.getGameMode().getIntegerSetting("squeezer.liquid.seed")));
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{ForestryItem.phosphor.getItemStack(2), new ItemStack(Blocks.cobblestone)},
LiquidHelper.getLiquid(Defaults.LIQUID_LAVA, 1600));
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{new ItemStack(Blocks.cactus)}, LiquidHelper.getLiquid(Defaults.LIQUID_WATER, 500));
FluidRegistry.getFluidStack(Defaults.LIQUID_LAVA, 1600));
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{new ItemStack(Blocks.cactus)}, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 500));
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{new ItemStack(Items.snowball), ForestryItem.craftingMaterial.getItemStack(4, 5)},
LiquidHelper.getLiquid(Defaults.LIQUID_ICE, 4000));
FluidRegistry.getFluidStack(Defaults.LIQUID_ICE, 4000));
// STILL
RecipeManagers.stillManager.addRecipe(Defaults.STILL_DESTILLATION_DURATION, LiquidHelper.getLiquid(Defaults.LIQUID_BIOMASS,
Defaults.STILL_DESTILLATION_INPUT), LiquidHelper.getLiquid(Defaults.LIQUID_ETHANOL, Defaults.STILL_DESTILLATION_OUTPUT));
RecipeManagers.stillManager.addRecipe(Defaults.STILL_DESTILLATION_DURATION, FluidRegistry.getFluidStack(Defaults.LIQUID_BIOMASS,
Defaults.STILL_DESTILLATION_INPUT), FluidRegistry.getFluidStack(Defaults.LIQUID_ETHANOL, Defaults.STILL_DESTILLATION_OUTPUT));
// MOISTENER
RecipeManagers.moistenerManager.addRecipe(new ItemStack(Items.wheat_seeds), new ItemStack(Blocks.mycelium), 5000);
@@ -319,17 +322,17 @@ public class PluginFactory extends ForestryPlugin {
RecipeUtil.injectLeveledRecipe(new ItemStack(Blocks.red_mushroom), GameMode.getGameMode().getIntegerSetting("fermenter.yield.mushroom"), Defaults.LIQUID_BIOMASS);
// FABRICATOR
RecipeManagers.fabricatorManager.addSmelting(new ItemStack(Blocks.glass), LiquidHelper.getLiquid(Defaults.LIQUID_GLASS, 1000), 1000);
RecipeManagers.fabricatorManager.addSmelting(new ItemStack(Blocks.glass_pane), LiquidHelper.getLiquid(Defaults.LIQUID_GLASS, 375), 1000);
RecipeManagers.fabricatorManager.addSmelting(new ItemStack(Blocks.sand), LiquidHelper.getLiquid(Defaults.LIQUID_GLASS, 1000), 3000);
RecipeManagers.fabricatorManager.addSmelting(new ItemStack(Blocks.glass), FluidRegistry.getFluidStack(Defaults.LIQUID_GLASS, 1000), 1000);
RecipeManagers.fabricatorManager.addSmelting(new ItemStack(Blocks.glass_pane), FluidRegistry.getFluidStack(Defaults.LIQUID_GLASS, 375), 1000);
RecipeManagers.fabricatorManager.addSmelting(new ItemStack(Blocks.sand), FluidRegistry.getFluidStack(Defaults.LIQUID_GLASS, 1000), 3000);
// / CARPENTER
RecipeManagers.carpenterManager.addRecipe(50, LiquidHelper.getLiquid(Defaults.LIQUID_SEEDOIL, 250), null, ForestryItem.impregnatedCasing.getItemStack(),
RecipeManagers.carpenterManager.addRecipe(50, FluidRegistry.getFluidStack(Defaults.LIQUID_SEEDOIL, 250), null, ForestryItem.impregnatedCasing.getItemStack(),
"###",
"# #",
"###",
'#', "logWood");
RecipeManagers.carpenterManager.addRecipe(50, LiquidHelper.getLiquid(Defaults.LIQUID_SEEDOIL, 500), null,
RecipeManagers.carpenterManager.addRecipe(50, FluidRegistry.getFluidStack(Defaults.LIQUID_SEEDOIL, 500), null,
ForestryBlock.core.getItemStack(1, Defaults.DEFINITION_ESCRITOIRE_META),
"# ",
"###",
@@ -337,35 +340,35 @@ public class PluginFactory extends ForestryPlugin {
'#', "plankWood");
// RESOURCES
RecipeManagers.carpenterManager.addRecipe(10, LiquidHelper.getLiquid(Defaults.LIQUID_SEEDOIL, 100), null,
RecipeManagers.carpenterManager.addRecipe(10, FluidRegistry.getFluidStack(Defaults.LIQUID_SEEDOIL, 100), null,
ForestryItem.stickImpregnated.getItemStack(2),
"#",
"#",
'#', "logWood");
RecipeManagers.carpenterManager.addRecipe(5, LiquidHelper.getLiquid(Defaults.LIQUID_WATER, 250), null,
RecipeManagers.carpenterManager.addRecipe(5, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 250), null,
ForestryItem.woodPulp.getItemStack(4),
"#",
'#', "logWood");
RecipeManagers.carpenterManager.addRecipe(5, LiquidHelper.getLiquid(Defaults.LIQUID_WATER, 250), null,
RecipeManagers.carpenterManager.addRecipe(5, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 250), null,
new ItemStack(Items.paper, 1),
"#",
"#",
'#', "pulpWood");
RecipeManagers.carpenterManager.addRecipe(5, LiquidHelper.getLiquid(Defaults.LIQUID_WATER, 1000), null,
RecipeManagers.carpenterManager.addRecipe(5, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 1000), null,
ForestryBlock.soil.getItemStack(9),
"###",
"#X#",
"###",
'#', Blocks.dirt,
'X', ForestryItem.mulch);
RecipeManagers.carpenterManager.addRecipe(5, LiquidHelper.getLiquid(Defaults.LIQUID_WATER, 1000), null,
RecipeManagers.carpenterManager.addRecipe(5, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 1000), null,
ForestryBlock.soil.getItemStack(8, 1),
"#X#",
"XYX", "#X#",
'#', Blocks.dirt,
'X', Blocks.sand,
'Y', ForestryItem.mulch);
RecipeManagers.carpenterManager.addRecipe(75, LiquidHelper.getLiquid(Defaults.LIQUID_WATER, 5000), null, ForestryItem.hardenedCasing.getItemStack(),
RecipeManagers.carpenterManager.addRecipe(75, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 5000), null, ForestryItem.hardenedCasing.getItemStack(),
"# #",
" Y ",
"# #",
@@ -373,21 +376,21 @@ public class PluginFactory extends ForestryPlugin {
'Y', ForestryItem.sturdyCasing);
// / CHIPSETS
RecipeManagers.carpenterManager.addRecipe(20, LiquidHelper.getLiquid(Defaults.LIQUID_WATER, 1000), null, ForestryItem.circuitboards.getItemStack(1, 0),
RecipeManagers.carpenterManager.addRecipe(20, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 1000), null, ForestryItem.circuitboards.getItemStack(1, 0),
"R R", "R#R", "R R", '#', "ingotTin", 'R', Items.redstone);
RecipeManagers.carpenterManager.addRecipe(40, LiquidHelper.getLiquid(Defaults.LIQUID_WATER, 1000), null, ForestryItem.circuitboards.getItemStack(1, 1),
RecipeManagers.carpenterManager.addRecipe(40, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 1000), null, ForestryItem.circuitboards.getItemStack(1, 1),
"R#R", "R#R", "R#R", '#', "ingotBronze", 'R', Items.redstone);
RecipeManagers.carpenterManager.addRecipe(80, LiquidHelper.getLiquid(Defaults.LIQUID_WATER, 1000), null, ForestryItem.circuitboards.getItemStack(1, 2),
RecipeManagers.carpenterManager.addRecipe(80, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 1000), null, ForestryItem.circuitboards.getItemStack(1, 2),
"R#R", "R#R", "R#R", '#', Items.iron_ingot, 'R', Items.redstone);
RecipeManagers.carpenterManager.addRecipe(80, LiquidHelper.getLiquid(Defaults.LIQUID_WATER, 1000), null, ForestryItem.circuitboards.getItemStack(1, 3),
RecipeManagers.carpenterManager.addRecipe(80, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 1000), null, ForestryItem.circuitboards.getItemStack(1, 3),
"R#R", "R#R", "R#R", '#', Items.gold_ingot, 'R', Items.redstone);
RecipeManagers.carpenterManager.addRecipe(40, LiquidHelper.getLiquid(Defaults.LIQUID_WATER, 1000), null, ForestryItem.solderingIron.getItemStack(),
RecipeManagers.carpenterManager.addRecipe(40, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 1000), null, ForestryItem.solderingIron.getItemStack(),
" # ", "# #", " B", '#', Items.iron_ingot, 'B', "ingotBronze");
// ForestryCore.oreHandler.registerCarpenterRecipe(solderingIron);
// RAIN SUBSTRATES
if (PluginManager.Module.APICULTURE.isEnabled()) {
RecipeManagers.carpenterManager.addRecipe(5, LiquidHelper.getLiquid(Defaults.LIQUID_WATER, 1000), null, ForestryItem.iodineCharge.getItemStack(),
RecipeManagers.carpenterManager.addRecipe(5, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 1000), null, ForestryItem.iodineCharge.getItemStack(),
"Z#Z",
"#Y#",
"X#X",
@@ -396,7 +399,7 @@ public class PluginFactory extends ForestryPlugin {
'Y', ForestryItem.canEmpty,
'Z', ForestryItem.honeyDrop);
// ForestryCore.oreHandler.registerCarpenterRecipe(iodineCapsule);
RecipeManagers.carpenterManager.addRecipe(5, LiquidHelper.getLiquid(Defaults.LIQUID_WATER, 1000), null, ForestryItem.craftingMaterial.getItemStack(1, 4),
RecipeManagers.carpenterManager.addRecipe(5, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 1000), null, ForestryItem.craftingMaterial.getItemStack(1, 4),
"Z#Z",
"#Y#",
"X#X",
@@ -411,13 +414,13 @@ public class PluginFactory extends ForestryPlugin {
RecipeManagers.carpenterManager.addRecipe(100, null, new ItemStack(Items.ender_pearl, 1), " # ", "###", " # ", '#',
ForestryItem.craftingMaterial.getItemStack(1, 1));
// Woven Silk
RecipeManagers.carpenterManager.addRecipe(10, LiquidHelper.getLiquid(Defaults.LIQUID_WATER, 500), null, ForestryItem.craftingMaterial.getItemStack(1, 3),
RecipeManagers.carpenterManager.addRecipe(10, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 500), null, ForestryItem.craftingMaterial.getItemStack(1, 3),
"###", "###", "###", '#', ForestryItem.craftingMaterial.getItemStack(1, 2));
// Boxes
RecipeManagers.carpenterManager.addRecipe(5, LiquidHelper.getLiquid(Defaults.LIQUID_WATER, 1000), null, ForestryItem.carton.getItemStack(2),
RecipeManagers.carpenterManager.addRecipe(5, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 1000), null, ForestryItem.carton.getItemStack(2),
" # ", "# #", " # ", '#', "pulpWood");
RecipeManagers.carpenterManager.addRecipe(20, LiquidHelper.getLiquid(Defaults.LIQUID_WATER, 1000), null, ForestryItem.crate.getItemStack(24),
RecipeManagers.carpenterManager.addRecipe(20, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 1000), null, ForestryItem.crate.getItemStack(24),
" # ", "# #", " # ", '#', "logWood");
// Assembly Kits
+19 -11
View File
@@ -10,9 +10,19 @@
******************************************************************************/
package forestry.plugins;
import java.util.EnumSet;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import cpw.mods.fml.common.Optional;
import cpw.mods.fml.common.event.FMLInterModComms;
import cpw.mods.fml.common.registry.GameData;
import forestry.api.circuits.ChipsetManager;
import forestry.api.circuits.ICircuitLayout;
import forestry.api.fuels.FuelManager;
@@ -45,15 +55,10 @@ import forestry.energy.gadgets.EngineTin;
import forestry.energy.gadgets.MachineGenerator;
import forestry.farming.circuits.CircuitFarmLogic;
import forestry.farming.logic.FarmLogicRubber;
import ic2.api.item.IC2Items;
import ic2.api.recipe.RecipeInputItemStack;
import ic2.api.recipe.Recipes;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import java.util.EnumSet;
@Plugin(pluginID = "IC2", name = "IndustrialCraft2", author = "SirSengir", url = Defaults.URL, unlocalizedDescription = "for.plugin.ic2.description")
public class PluginIC2 extends ForestryPlugin {
@@ -195,11 +200,11 @@ public class PluginIC2 extends ForestryPlugin {
definitionEngineTin.register();
definitionGenerator.register();
FluidStack ethanol = LiquidHelper.getLiquid(Defaults.LIQUID_ETHANOL, 1);
FluidStack ethanol = FluidRegistry.getFluidStack(Defaults.LIQUID_ETHANOL, 1);
GeneratorFuel ethanolFuel = new GeneratorFuel(ethanol, (int) (32 * GameMode.getGameMode().getFloatSetting("fuel.ethanol.generator")), 4);
FuelManager.generatorFuel.put(ethanol.getFluid(), ethanolFuel);
FluidStack biomass = LiquidHelper.getLiquid(Defaults.LIQUID_BIOMASS, 1);
FluidStack biomass = FluidRegistry.getFluidStack(Defaults.LIQUID_BIOMASS, 1);
GeneratorFuel biomassFuel = new GeneratorFuel(biomass, (int) (8 * GameMode.getGameMode().getFloatSetting("fuel.biomass.generator")), 1);
FuelManager.generatorFuel.put(biomass.getFluid(), biomassFuel);
@@ -263,9 +268,12 @@ public class PluginIC2 extends ForestryPlugin {
@Optional.Method(modid = "IC2")
protected void registerRecipes() {
if (rubber != null)
RecipeManagers.fabricatorManager.addRecipe(null, LiquidHelper.getLiquid(Defaults.LIQUID_GLASS, 500), ForestryItem.tubes.getItemStack(4, 8),
new Object[]{" X ", "#X#", "XXX", '#', Items.redstone, 'X', PluginIC2.rubber});
if (rubber != null) {
for (Object rubberOreDict : RecipeUtil.getOreDictRecipeEquivalents(rubber)) {
RecipeManagers.fabricatorManager.addRecipe(null, FluidRegistry.getFluidStack(Defaults.LIQUID_GLASS, 500), ForestryItem.tubes.getItemStack(4, 8),
new Object[]{" X ", "#X#", "XXX", '#', Items.redstone, 'X', rubberOreDict});
}
}
if (plantBall != null && compressedPlantBall != null) {
RecipeUtil.injectLeveledRecipe(plantBall, GameMode.getGameMode().getIntegerSetting("fermenter.yield.wheat") * 4, Defaults.LIQUID_BIOMASS);
@@ -17,6 +17,8 @@ import net.minecraft.block.material.Material;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.oredict.RecipeSorter;
import cpw.mods.fml.common.SidedProxy;
@@ -42,7 +44,6 @@ import forestry.core.gadgets.MachineDefinition;
import forestry.core.genetics.Allele;
import forestry.core.genetics.Branch;
import forestry.core.items.ItemForestryBlock;
import forestry.core.utils.LiquidHelper;
import forestry.core.utils.ShapedRecipeCustom;
import forestry.core.utils.Utils;
import forestry.lepidopterology.ButterflySpawner;
@@ -148,9 +149,9 @@ public class PluginLepidopterology extends ForestryPlugin {
protected void registerRecipes() {
CraftingManager.getInstance().getRecipeList().add(new MatingRecipe());
RecipeManagers.carpenterManager.addRecipe(100, LiquidHelper.getLiquid(Defaults.LIQUID_WATER, 2000), null, ForestryItem.flutterlyzer.getItemStack(),
"X#X", "X#X", "RDR", Character.valueOf('#'), Blocks.glass_pane, Character.valueOf('X'), "ingotBronze", Character.valueOf('R'),
Items.redstone, Character.valueOf('D'), Items.diamond);
RecipeManagers.carpenterManager.addRecipe(100, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 2000), null, ForestryItem.flutterlyzer.getItemStack(),
"X#X", "X#X", "RDR", '#', Blocks.glass_pane, 'X', "ingotBronze", 'R',
Items.redstone, 'D', Items.diamond);
}
private void createAlleles() {
@@ -16,9 +16,12 @@ import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidRegistry;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.network.IGuiHandler;
import forestry.api.mail.EnumAddressee;
import forestry.api.mail.EnumPostage;
import forestry.api.mail.PostManager;
import forestry.api.recipes.RecipeManagers;
@@ -34,9 +37,7 @@ import forestry.core.interfaces.ISaveEventHandler;
import forestry.core.items.ItemForestryBlock;
import forestry.core.proxy.Proxies;
import forestry.core.triggers.Trigger;
import forestry.core.utils.LiquidHelper;
import forestry.core.utils.ShapedRecipeCustom;
import forestry.api.mail.EnumAddressee;
import forestry.mail.GuiHandlerMail;
import forestry.mail.PacketHandlerMail;
import forestry.mail.PostRegistry;
@@ -201,7 +202,7 @@ public class PluginMail extends ForestryPlugin {
'X', stampDefinitions[i].getCraftingIngredient(),
'#', Items.paper,
'Z', stampGlue);
RecipeManagers.carpenterManager.addRecipe(10, LiquidHelper.getLiquid(Defaults.LIQUID_SEEDOIL, 300), null, ForestryItem.stamps.getItemStack(9, i),
RecipeManagers.carpenterManager.addRecipe(10, FluidRegistry.getFluidStack(Defaults.LIQUID_SEEDOIL, 300), null, ForestryItem.stamps.getItemStack(9, i),
"XXX", "###",
'X', stampDefinitions[i].getCraftingIngredient(),
'#', Items.paper);
@@ -211,7 +212,7 @@ public class PluginMail extends ForestryPlugin {
Proxies.common.addRecipe(new ItemStack(Items.paper), "###", '#', ForestryItem.letters.getItemStack(1, Defaults.WILDCARD));
// Carpenter
RecipeManagers.carpenterManager.addRecipe(10, LiquidHelper.getLiquid(Defaults.LIQUID_WATER, 250), null, ForestryItem.letters.getItemStack(), "###", "###", '#', ForestryItem.woodPulp);
RecipeManagers.carpenterManager.addRecipe(10, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 250), null, ForestryItem.letters.getItemStack(), "###", "###", '#', ForestryItem.woodPulp);
Proxies.common.addShapelessRecipe(ForestryItem.catalogue.getItemStack(), ForestryItem.stamps.getItemStack(1, Defaults.WILDCARD), new ItemStack(Items.book));
}
@@ -12,19 +12,20 @@ package forestry.plugins;
import java.util.ArrayList;
import cpw.mods.fml.common.registry.GameData;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidRegistry;
import cpw.mods.fml.common.event.FMLInterModComms;
import cpw.mods.fml.common.registry.GameData;
import cpw.mods.fml.common.registry.GameRegistry;
import forestry.api.recipes.RecipeManagers;
import forestry.core.GameMode;
import forestry.core.config.Defaults;
import forestry.core.proxy.Proxies;
import forestry.core.utils.LiquidHelper;
@Plugin(pluginID = "Natura", name = "Natura", author = "SirSengir", url = Defaults.URL, unlocalizedDescription = "for.plugin.natura.description")
public class PluginNatura extends ForestryPlugin {
@@ -86,7 +87,7 @@ public class PluginNatura extends ForestryPlugin {
int amount = GameMode.getGameMode().getIntegerSetting("squeezer.liquid.seed");
for (ItemStack aSeedList : seedList)
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{aSeedList},
LiquidHelper.getLiquid(Defaults.LIQUID_SEEDOIL, amount));
FluidRegistry.getFluidStack(Defaults.LIQUID_SEEDOIL, amount));
ItemStack berryBlight = GameRegistry.findItemStack(NATURA, "berryBlight", 1);
ItemStack berryDusk = GameRegistry.findItemStack(NATURA, "berryDusk", 1);
@@ -119,7 +120,7 @@ public class PluginNatura extends ForestryPlugin {
amount = (amount > 1) ? amount : 1; // Produce at least 1 mb of juice.
for (ItemStack berry : berries)
RecipeManagers.squeezerManager.addRecipe(3, new ItemStack[]{berry},
LiquidHelper.getLiquid(Defaults.LIQUID_JUICE, amount));
FluidRegistry.getFluidStack(Defaults.LIQUID_JUICE, amount));
}
}
@@ -41,14 +41,15 @@ import net.minecraft.item.ItemDoor;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.IPlantable;
import net.minecraftforge.common.IShearable;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.oredict.OreDictionary;
import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage;
import cpw.mods.fml.common.network.IGuiHandler;
import cpw.mods.fml.common.registry.GameData;
import net.minecraftforge.common.IPlantable;
import net.minecraftforge.common.IShearable;
import net.minecraftforge.oredict.OreDictionary;
import forestry.api.core.Tabs;
import forestry.api.recipes.RecipeManagers;
import forestry.api.storage.BackpackManager;
@@ -66,7 +67,6 @@ import forestry.core.interfaces.ISaveEventHandler;
import forestry.core.items.ItemForestry;
import forestry.core.network.GuiId;
import forestry.core.proxy.Proxies;
import forestry.core.utils.LiquidHelper;
import forestry.storage.BackpackDefinition;
import forestry.storage.BackpackHelper;
import forestry.storage.GuiHandlerStorage;
@@ -504,22 +504,22 @@ public class PluginStorage extends ForestryPlugin implements IOreDictionaryHandl
// / CARPENTER
// / BACKPACKS T2
RecipeManagers.carpenterManager.addRecipe(200, LiquidHelper.getLiquid(Defaults.LIQUID_WATER, 1000), null, ForestryItem.minerBackpackT2.getItemStack(),
RecipeManagers.carpenterManager.addRecipe(200, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 1000), null, ForestryItem.minerBackpackT2.getItemStack(),
"WXW", "WTW", "WWW", 'X', Items.diamond, 'W',
ForestryItem.craftingMaterial.getItemStack(1, 3), 'T', ForestryItem.minerBackpack);
RecipeManagers.carpenterManager.addRecipe(200, LiquidHelper.getLiquid(Defaults.LIQUID_WATER, 1000), null, ForestryItem.diggerBackpackT2.getItemStack(),
RecipeManagers.carpenterManager.addRecipe(200, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 1000), null, ForestryItem.diggerBackpackT2.getItemStack(),
"WXW", "WTW", "WWW", 'X', Items.diamond, 'W',
ForestryItem.craftingMaterial.getItemStack(1, 3), 'T', ForestryItem.diggerBackpack);
RecipeManagers.carpenterManager.addRecipe(200, LiquidHelper.getLiquid(Defaults.LIQUID_WATER, 1000), null, ForestryItem.foresterBackpackT2.getItemStack(),
RecipeManagers.carpenterManager.addRecipe(200, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 1000), null, ForestryItem.foresterBackpackT2.getItemStack(),
"WXW", "WTW", "WWW", 'X', Items.diamond, 'W',
ForestryItem.craftingMaterial.getItemStack(1, 3), 'T', ForestryItem.foresterBackpack);
RecipeManagers.carpenterManager.addRecipe(200, LiquidHelper.getLiquid(Defaults.LIQUID_WATER, 1000), null, ForestryItem.hunterBackpackT2.getItemStack(),
RecipeManagers.carpenterManager.addRecipe(200, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 1000), null, ForestryItem.hunterBackpackT2.getItemStack(),
"WXW", "WTW", "WWW", 'X', Items.diamond, 'W',
ForestryItem.craftingMaterial.getItemStack(1, 3), 'T', ForestryItem.hunterBackpack);
RecipeManagers.carpenterManager.addRecipe(200, LiquidHelper.getLiquid(Defaults.LIQUID_WATER, 1000), null, ForestryItem.adventurerBackpackT2.getItemStack(),
RecipeManagers.carpenterManager.addRecipe(200, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 1000), null, ForestryItem.adventurerBackpackT2.getItemStack(),
"WXW", "WTW", "WWW", 'X', Items.diamond, 'W',
ForestryItem.craftingMaterial.getItemStack(1, 3), 'T', ForestryItem.adventurerBackpack);
RecipeManagers.carpenterManager.addRecipe(200, LiquidHelper.getLiquid(Defaults.LIQUID_WATER, 1000), null, ForestryItem.builderBackpackT2.getItemStack(),
RecipeManagers.carpenterManager.addRecipe(200, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 1000), null, ForestryItem.builderBackpackT2.getItemStack(),
"WXW", "WTW", "WWW", 'X', Items.diamond, 'W',
ForestryItem.craftingMaterial.getItemStack(1, 3), 'T', ForestryItem.builderBackpack);