mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-15 01:24:59 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7b5febd394 | ||
|
|
71481d5ace | ||
|
|
1d0efd537e | ||
|
|
5052df8844 | ||
|
|
b1d496f24f | ||
|
|
2bfe576f7e | ||
|
|
cc5c8af338 | ||
|
|
19a9c2681c | ||
|
|
f020dcf2e2 |
No files matched your search
+1
-1
Submodule api/forestry updated: cb7a1a6181...5c3dc357e8.
@@ -2,4 +2,4 @@ mcversion=1.7.10
|
||||
forgeversion=10.13.3.1370-1.7.10
|
||||
version_major=4
|
||||
version_minor=0
|
||||
version_patch=1
|
||||
version_patch=4
|
||||
@@ -73,8 +73,8 @@ public class BeekeepingLogic implements IBeekeepingLogic, IStreamable {
|
||||
|
||||
public BeekeepingLogic(IBeeHousing housing) {
|
||||
this.housing = housing;
|
||||
this.beeModifier = new BeeHousingModifier(housing);
|
||||
this.beeListener = new BeeHousingListener(housing);
|
||||
this.beeModifier = BeeManager.beeRoot.createBeeHousingModifier(housing);
|
||||
this.beeListener = BeeManager.beeRoot.createBeeHousingListener(housing);
|
||||
}
|
||||
|
||||
// / SAVING & LOADING
|
||||
|
||||
@@ -38,6 +38,7 @@ import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
import forestry.api.apiculture.BeeManager;
|
||||
import forestry.api.apiculture.FlowerManager;
|
||||
import forestry.api.apiculture.IBee;
|
||||
import forestry.api.apiculture.IBeeGenome;
|
||||
@@ -47,7 +48,6 @@ import forestry.api.genetics.IFlower;
|
||||
import forestry.api.genetics.IFlowerGrowthRule;
|
||||
import forestry.api.genetics.IFlowerRegistry;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.apiculture.BeeHousingModifier;
|
||||
import forestry.core.utils.vect.MutableVect;
|
||||
import forestry.core.utils.vect.Vect;
|
||||
import forestry.plugins.PluginManager;
|
||||
@@ -142,7 +142,7 @@ public final class FlowerRegistry implements IFlowerRegistry {
|
||||
Set<IFlower> acceptedFlowers = this.registeredFlowers.get(flowerType);
|
||||
World world = beeHousing.getWorld();
|
||||
|
||||
IBeeModifier beeModifier = new BeeHousingModifier(beeHousing);
|
||||
IBeeModifier beeModifier = BeeManager.beeRoot.createBeeHousingModifier(beeHousing);
|
||||
|
||||
Vect area = getArea(bee.getGenome(), beeModifier);
|
||||
Vect housingPos = new Vect(beeHousing.getCoordinates()).add(-area.x / 2, -area.y / 2, -area.z / 2);
|
||||
|
||||
@@ -52,7 +52,6 @@ import forestry.api.genetics.IFlowerProvider;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.genetics.IMutation;
|
||||
import forestry.api.genetics.IPollinatable;
|
||||
import forestry.apiculture.BeeHousingModifier;
|
||||
import forestry.arboriculture.genetics.pollination.FakePollinatable;
|
||||
import forestry.arboriculture.genetics.pollination.ICheckPollinatable;
|
||||
import forestry.core.config.Config;
|
||||
@@ -253,7 +252,7 @@ public class Bee extends IndividualLiving implements IBee {
|
||||
|
||||
Set<IErrorState> errorStates = new HashSet<IErrorState>();
|
||||
|
||||
IBeeModifier beeModifier = new BeeHousingModifier(housing);
|
||||
IBeeModifier beeModifier = BeeManager.beeRoot.createBeeHousingModifier(housing);
|
||||
|
||||
// / Rain needs tolerant flyers
|
||||
if (world.isRaining() && !genome.getTolerantFlyer() && BiomeHelper.canRainOrSnow(biome) && !beeModifier.isSealed()) {
|
||||
@@ -458,7 +457,7 @@ public class Bee extends IndividualLiving implements IBee {
|
||||
setIsNatural(false);
|
||||
}
|
||||
|
||||
IBeeModifier beeHousingModifier = new BeeHousingModifier(housing);
|
||||
IBeeModifier beeHousingModifier = BeeManager.beeRoot.createBeeHousingModifier(housing);
|
||||
IBeeModifier beeModeModifier = mode.getBeeModifier();
|
||||
|
||||
// Bee genetic speed * beehousing * beekeeping mode
|
||||
@@ -630,7 +629,7 @@ public class Bee extends IndividualLiving implements IBee {
|
||||
@Override
|
||||
public IIndividual retrievePollen(IBeeHousing housing) {
|
||||
|
||||
IBeeModifier beeModifier = new BeeHousingModifier(housing);
|
||||
IBeeModifier beeModifier = BeeManager.beeRoot.createBeeHousingModifier(housing);
|
||||
|
||||
int chance = Math.round(genome.getFlowering() * beeModifier.getFloweringModifier(getGenome(), 1f));
|
||||
|
||||
@@ -673,7 +672,7 @@ public class Bee extends IndividualLiving implements IBee {
|
||||
@Override
|
||||
public boolean pollinateRandom(IBeeHousing housing, IIndividual pollen) {
|
||||
|
||||
IBeeModifier beeModifier = new BeeHousingModifier(housing);
|
||||
IBeeModifier beeModifier = BeeManager.beeRoot.createBeeHousingModifier(housing);
|
||||
|
||||
int chance = (int) (genome.getFlowering() * beeModifier.getFloweringModifier(getGenome(), 1f));
|
||||
|
||||
@@ -720,7 +719,7 @@ public class Bee extends IndividualLiving implements IBee {
|
||||
@Override
|
||||
public void plantFlowerRandom(IBeeHousing housing) {
|
||||
|
||||
IBeeModifier beeModifier = new BeeHousingModifier(housing);
|
||||
IBeeModifier beeModifier = BeeManager.beeRoot.createBeeHousingModifier(housing);
|
||||
|
||||
int chance = Math.round(genome.getFlowering() * beeModifier.getFloweringModifier(getGenome(), 1f));
|
||||
|
||||
|
||||
@@ -33,6 +33,8 @@ import forestry.api.apiculture.IApiaristTracker;
|
||||
import forestry.api.apiculture.IBee;
|
||||
import forestry.api.apiculture.IBeeGenome;
|
||||
import forestry.api.apiculture.IBeeHousing;
|
||||
import forestry.api.apiculture.IBeeListener;
|
||||
import forestry.api.apiculture.IBeeModifier;
|
||||
import forestry.api.apiculture.IBeeMutation;
|
||||
import forestry.api.apiculture.IBeeRoot;
|
||||
import forestry.api.apiculture.IBeekeepingLogic;
|
||||
@@ -42,6 +44,8 @@ import forestry.api.genetics.IAllele;
|
||||
import forestry.api.genetics.IChromosomeType;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.genetics.IMutation;
|
||||
import forestry.apiculture.BeeHousingListener;
|
||||
import forestry.apiculture.BeeHousingModifier;
|
||||
import forestry.apiculture.BeekeepingLogic;
|
||||
import forestry.core.config.ForestryItem;
|
||||
import forestry.core.genetics.SpeciesRoot;
|
||||
@@ -326,6 +330,16 @@ public class BeeHelper extends SpeciesRoot implements IBeeRoot {
|
||||
return new BeekeepingLogic(housing);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBeeModifier createBeeHousingModifier(IBeeHousing housing) {
|
||||
return new BeeHousingModifier(housing);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBeeListener createBeeHousingListener(IBeeHousing housing) {
|
||||
return new BeeHousingListener(housing);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IChromosomeType[] getKaryotype() {
|
||||
return EnumBeeChromosome.values();
|
||||
|
||||
@@ -21,7 +21,6 @@ import forestry.api.apiculture.IBeeModifier;
|
||||
import forestry.api.apiculture.IBeeMutationCustom;
|
||||
import forestry.api.apiculture.IBeeRoot;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.apiculture.BeeHousingModifier;
|
||||
import forestry.core.genetics.mutations.Mutation;
|
||||
|
||||
public class BeeMutation extends Mutation implements IBeeMutationCustom {
|
||||
@@ -48,7 +47,7 @@ public class BeeMutation extends Mutation implements IBeeMutationCustom {
|
||||
return 0;
|
||||
}
|
||||
|
||||
IBeeModifier beeHousingModifier = new BeeHousingModifier(housing);
|
||||
IBeeModifier beeHousingModifier = BeeManager.beeRoot.createBeeHousingModifier(housing);
|
||||
IBeeModifier beeModeModifier = BeeManager.beeRoot.getBeekeepingMode(world).getBeeModifier();
|
||||
|
||||
processedChance *= beeHousingModifier.getMutationModifier(genome0, genome1, processedChance);
|
||||
|
||||
@@ -16,13 +16,13 @@ import java.util.Random;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.api.apiculture.BeeManager;
|
||||
import forestry.api.apiculture.DefaultBeeModifier;
|
||||
import forestry.api.apiculture.IBee;
|
||||
import forestry.api.apiculture.IBeeGenome;
|
||||
import forestry.api.apiculture.IBeeHousing;
|
||||
import forestry.api.apiculture.IBeeModifier;
|
||||
import forestry.api.apiculture.IBeekeepingMode;
|
||||
import forestry.apiculture.BeeHousingModifier;
|
||||
|
||||
public class BeekeepingMode implements IBeekeepingMode {
|
||||
|
||||
@@ -84,7 +84,7 @@ public class BeekeepingMode implements IBeekeepingMode {
|
||||
return false;
|
||||
}
|
||||
|
||||
IBeeModifier beeModifier = new BeeHousingModifier(housing);
|
||||
IBeeModifier beeModifier = BeeManager.beeRoot.createBeeHousingModifier(housing);
|
||||
|
||||
return queen.getGeneration() > 96 + rand.nextInt(6) + rand.nextInt(6) &&
|
||||
rand.nextFloat() < 0.02f * beeModifier.getGeneticDecay(queen.getGenome(), 1f);
|
||||
@@ -92,7 +92,7 @@ public class BeekeepingMode implements IBeekeepingMode {
|
||||
|
||||
@Override
|
||||
public boolean isOverworked(IBee queen, IBeeHousing housing) {
|
||||
IBeeModifier beeModifier = new BeeHousingModifier(housing);
|
||||
IBeeModifier beeModifier = BeeManager.beeRoot.createBeeHousingModifier(housing);
|
||||
|
||||
float productionModifier = beeModifier.getProductionModifier(queen.getGenome(), 1f);
|
||||
if (productionModifier > 16) {
|
||||
@@ -106,7 +106,7 @@ public class BeekeepingMode implements IBeekeepingMode {
|
||||
|
||||
@Override
|
||||
public boolean isDegenerating(IBee queen, IBee offspring, IBeeHousing housing) {
|
||||
IBeeModifier beeModifier = new BeeHousingModifier(housing);
|
||||
IBeeModifier beeModifier = BeeManager.beeRoot.createBeeHousingModifier(housing);
|
||||
|
||||
float mutationModifier = beeModifier.getMutationModifier(queen.getGenome(), queen.getMate(), 1.0f);
|
||||
if (mutationModifier > 10) {
|
||||
|
||||
@@ -12,12 +12,12 @@ package forestry.apiculture.genetics.alleles;
|
||||
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
|
||||
import forestry.api.apiculture.BeeManager;
|
||||
import forestry.api.apiculture.IAlleleBeeEffect;
|
||||
import forestry.api.apiculture.IBeeGenome;
|
||||
import forestry.api.apiculture.IBeeHousing;
|
||||
import forestry.api.apiculture.IBeeModifier;
|
||||
import forestry.api.genetics.IEffectData;
|
||||
import forestry.apiculture.BeeHousingModifier;
|
||||
import forestry.core.genetics.alleles.AlleleCategorized;
|
||||
import forestry.core.utils.vect.MutableVect;
|
||||
import forestry.core.utils.vect.Vect;
|
||||
@@ -51,7 +51,7 @@ public class AlleleEffectNone extends AlleleCategorized implements IAlleleBeeEff
|
||||
}
|
||||
|
||||
protected Vect getModifiedArea(IBeeGenome genome, IBeeHousing housing) {
|
||||
IBeeModifier beeModifier = new BeeHousingModifier(housing);
|
||||
IBeeModifier beeModifier = BeeManager.beeRoot.createBeeHousingModifier(housing);
|
||||
float territoryModifier = beeModifier.getTerritoryModifier(genome, 1f);
|
||||
|
||||
MutableVect area = new MutableVect(genome.getTerritory());
|
||||
@@ -71,7 +71,7 @@ public class AlleleEffectNone extends AlleleCategorized implements IAlleleBeeEff
|
||||
}
|
||||
|
||||
protected AxisAlignedBB getBounding(IBeeGenome genome, IBeeHousing housing) {
|
||||
IBeeModifier beeModifier = new BeeHousingModifier(housing);
|
||||
IBeeModifier beeModifier = BeeManager.beeRoot.createBeeHousingModifier(housing);
|
||||
float territoryModifier = beeModifier.getTerritoryModifier(genome, 1.0f);
|
||||
|
||||
MutableVect area = new MutableVect(genome.getTerritory());
|
||||
|
||||
@@ -12,13 +12,12 @@ package forestry.apiculture.items;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.api.apiculture.BeeManager;
|
||||
import forestry.api.apiculture.IBee;
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.core.Tabs;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import forestry.core.config.Config;
|
||||
import forestry.core.gui.IHintSource;
|
||||
import forestry.core.items.ItemAlyzer;
|
||||
@@ -48,48 +47,11 @@ public class ItemBeealyzer extends ItemAlyzer {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isSpecimen(ItemStack itemStack) {
|
||||
return BeeManager.beeRoot.isMember(itemStack);
|
||||
protected ISpeciesRoot getSpeciesRoot() {
|
||||
return BeeManager.beeRoot;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSlotClick(EntityPlayer player) {
|
||||
// Source slot to analyze empty
|
||||
if (getStackInSlot(SLOT_SPECIMEN) == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
IBee bee = BeeManager.beeRoot.getMember(getStackInSlot(SLOT_SPECIMEN));
|
||||
// No bee, abort
|
||||
if (bee == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Analyze if necessary
|
||||
if (!bee.isAnalyzed()) {
|
||||
|
||||
// Requires energy
|
||||
if (!isEnergy(getStackInSlot(SLOT_ENERGY))) {
|
||||
return;
|
||||
}
|
||||
|
||||
bee.analyze();
|
||||
if (player != null) {
|
||||
BeeManager.beeRoot.getBreedingTracker(player.worldObj, player.getGameProfile()).registerSpecies(bee.getGenome().getPrimary());
|
||||
BeeManager.beeRoot.getBreedingTracker(player.worldObj, player.getGameProfile()).registerSpecies(bee.getGenome().getSecondary());
|
||||
}
|
||||
|
||||
NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
bee.writeToNBT(nbttagcompound);
|
||||
getStackInSlot(SLOT_SPECIMEN).setTagCompound(nbttagcompound);
|
||||
|
||||
// Decrease energy
|
||||
decrStackSize(SLOT_ENERGY, 1);
|
||||
}
|
||||
|
||||
setInventorySlotContents(SLOT_ANALYZE_1, getStackInSlot(SLOT_SPECIMEN));
|
||||
setInventorySlotContents(SLOT_SPECIMEN, null);
|
||||
}
|
||||
|
||||
// / IHINTSOURCE
|
||||
@Override
|
||||
|
||||
@@ -35,7 +35,6 @@ import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import forestry.api.core.IClimateControlled;
|
||||
import forestry.apiculture.BeeHousingInventory;
|
||||
import forestry.apiculture.BeeHousingModifier;
|
||||
import forestry.core.access.EnumAccess;
|
||||
import forestry.core.inventory.IInventoryAdapter;
|
||||
import forestry.core.multiblock.CoordTriplet;
|
||||
@@ -384,7 +383,7 @@ public class AlvearyController extends RectangularMultiblockControllerBase imple
|
||||
|
||||
@Override
|
||||
public EnumTemperature getTemperature() {
|
||||
IBeeModifier beeModifier = new BeeHousingModifier(this);
|
||||
IBeeModifier beeModifier = BeeManager.beeRoot.createBeeHousingModifier(this);
|
||||
if (beeModifier.isHellish() && tempChange >= 0) {
|
||||
return EnumTemperature.HELLISH;
|
||||
}
|
||||
|
||||
@@ -12,13 +12,12 @@ package forestry.arboriculture.items;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.api.arboriculture.ITree;
|
||||
import forestry.api.arboriculture.TreeManager;
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.core.Tabs;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import forestry.core.config.Config;
|
||||
import forestry.core.gui.IHintSource;
|
||||
import forestry.core.items.ItemAlyzer;
|
||||
@@ -50,52 +49,32 @@ public class ItemTreealyzer extends ItemAlyzer {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isSpecimen(ItemStack itemStack) {
|
||||
return GeneticsUtil.getGeneticEquivalent(itemStack) instanceof ITree;
|
||||
protected ISpeciesRoot getSpeciesRoot() {
|
||||
return TreeManager.treeRoot;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
|
||||
if (!TreeManager.treeRoot.isMember(itemStack)) {
|
||||
ItemStack ersatz = GeneticsUtil.convertSaplingToGeneticEquivalent(itemStack);
|
||||
if (ersatz != null) {
|
||||
return super.canSlotAccept(slotIndex, ersatz);
|
||||
}
|
||||
}
|
||||
return super.canSlotAccept(slotIndex, itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSlotClick(EntityPlayer player) {
|
||||
// Source slot to analyze empty
|
||||
if (getStackInSlot(SLOT_SPECIMEN) == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!TreeManager.treeRoot.isMember(getStackInSlot(SLOT_SPECIMEN))) {
|
||||
ItemStack ersatz = GeneticsUtil.convertSaplingToGeneticEquivalent(getStackInSlot(SLOT_SPECIMEN));
|
||||
ItemStack specimen = getStackInSlot(SLOT_SPECIMEN);
|
||||
if (!TreeManager.treeRoot.isMember(specimen)) {
|
||||
ItemStack ersatz = GeneticsUtil.convertSaplingToGeneticEquivalent(specimen);
|
||||
if (ersatz != null) {
|
||||
setInventorySlotContents(SLOT_SPECIMEN, ersatz);
|
||||
}
|
||||
}
|
||||
ITree tree = TreeManager.treeRoot.getMember(getStackInSlot(SLOT_SPECIMEN));
|
||||
// No tree, abort
|
||||
if (tree == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Analyze if necessary
|
||||
if (!tree.isAnalyzed()) {
|
||||
|
||||
// Requires energy
|
||||
if (!isEnergy(getStackInSlot(SLOT_ENERGY))) {
|
||||
return;
|
||||
}
|
||||
|
||||
tree.analyze();
|
||||
if (player != null) {
|
||||
TreeManager.treeRoot.getBreedingTracker(player.worldObj, player.getGameProfile()).registerSpecies(tree.getGenome().getPrimary());
|
||||
TreeManager.treeRoot.getBreedingTracker(player.worldObj, player.getGameProfile()).registerSpecies(tree.getGenome().getSecondary());
|
||||
}
|
||||
NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
tree.writeToNBT(nbttagcompound);
|
||||
getStackInSlot(SLOT_SPECIMEN).setTagCompound(nbttagcompound);
|
||||
|
||||
// Decrease energy
|
||||
decrStackSize(SLOT_ENERGY, 1);
|
||||
}
|
||||
|
||||
setInventorySlotContents(SLOT_ANALYZE_1, getStackInSlot(SLOT_SPECIMEN));
|
||||
setInventorySlotContents(SLOT_SPECIMEN, null);
|
||||
super.onSlotClick(player);
|
||||
}
|
||||
|
||||
// / IHINTSOURCE
|
||||
|
||||
@@ -21,7 +21,6 @@ import net.minecraft.item.ItemStack;
|
||||
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.IFluidContainerItem;
|
||||
@@ -196,23 +195,6 @@ public final class FluidHelper {
|
||||
return output.stackSize + drainedItem.stackSize <= output.getMaxStackSize();
|
||||
}
|
||||
|
||||
public static boolean isFillableContainer(ItemStack stack, FluidStack liquid) {
|
||||
ItemStack empty = ItemStackUtil.createSplitStack(stack, 1);
|
||||
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)) {
|
||||
@@ -299,8 +281,7 @@ public final class FluidHelper {
|
||||
|
||||
Item item = empty.getItem();
|
||||
if (item instanceof IFluidContainerItem) {
|
||||
ItemStack full = empty.copy();
|
||||
full.stackSize = 1;
|
||||
ItemStack full = ItemStackUtil.createSplitStack(empty, 1);
|
||||
IFluidContainerItem containerItem = (IFluidContainerItem) item;
|
||||
containerItem.fill(full, liquid, true);
|
||||
return full;
|
||||
|
||||
@@ -14,9 +14,13 @@ import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import forestry.api.core.IErrorSource;
|
||||
import forestry.api.core.IErrorState;
|
||||
import forestry.api.genetics.IBreedingTracker;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import forestry.core.config.ForestryItem;
|
||||
import forestry.core.errors.EnumErrorCode;
|
||||
import forestry.core.inventory.ItemInventory;
|
||||
@@ -58,15 +62,71 @@ public abstract class ItemAlyzer extends ItemInventoried {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected abstract boolean isSpecimen(ItemStack itemStack);
|
||||
protected abstract ISpeciesRoot getSpeciesRoot();
|
||||
|
||||
@Override
|
||||
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
|
||||
if (slotIndex == SLOT_ENERGY) {
|
||||
return isEnergy(itemStack);
|
||||
} else {
|
||||
return !hasSpecimen() && isSpecimen(itemStack);
|
||||
}
|
||||
|
||||
ISpeciesRoot speciesRoot = getSpeciesRoot();
|
||||
if (!speciesRoot.isMember(itemStack)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// only allow one slot to be used at a time
|
||||
if (hasSpecimen() && getStackInSlot(slotIndex) == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (slotIndex == SLOT_SPECIMEN) {
|
||||
return true;
|
||||
}
|
||||
|
||||
IIndividual individual = speciesRoot.getMember(itemStack);
|
||||
return individual.isAnalyzed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSlotClick(EntityPlayer player) {
|
||||
// Source slot to analyze empty
|
||||
ItemStack specimen = getStackInSlot(SLOT_SPECIMEN);
|
||||
if (specimen == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
IIndividual individual = getSpeciesRoot().getMember(specimen);
|
||||
// No individual, abort
|
||||
if (individual == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Analyze if necessary
|
||||
if (!individual.isAnalyzed()) {
|
||||
|
||||
// Requires energy
|
||||
if (!isEnergy(getStackInSlot(SLOT_ENERGY))) {
|
||||
return;
|
||||
}
|
||||
|
||||
individual.analyze();
|
||||
if (player != null) {
|
||||
IBreedingTracker breedingTracker = getSpeciesRoot().getBreedingTracker(player.worldObj, player.getGameProfile());
|
||||
breedingTracker.registerSpecies(individual.getGenome().getPrimary());
|
||||
breedingTracker.registerSpecies(individual.getGenome().getSecondary());
|
||||
}
|
||||
|
||||
NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
individual.writeToNBT(nbttagcompound);
|
||||
specimen.setTagCompound(nbttagcompound);
|
||||
|
||||
// Decrease energy
|
||||
decrStackSize(SLOT_ENERGY, 1);
|
||||
}
|
||||
|
||||
setInventorySlotContents(SLOT_ANALYZE_1, specimen);
|
||||
setInventorySlotContents(SLOT_SPECIMEN, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -159,6 +159,9 @@ public class GeneticsUtil {
|
||||
}
|
||||
|
||||
public static IIndividual getGeneticEquivalent(ItemStack itemStack) {
|
||||
if (itemStack == null) {
|
||||
return null;
|
||||
}
|
||||
Item item = itemStack.getItem();
|
||||
if (item instanceof ItemGE) {
|
||||
return ((ItemGE) item).getIndividual(itemStack);
|
||||
|
||||
@@ -202,7 +202,7 @@ public abstract class ItemStackUtil {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (craftingTools && isCraftingTool(base) && base.getItem() == comparison.getItem()) {
|
||||
if (craftingTools && isCraftingToolEquivalent(base, comparison)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -235,19 +235,30 @@ public abstract class ItemStackUtil {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isCraftingTool(ItemStack itemstack) {
|
||||
Item item = itemstack.getItem();
|
||||
if (item == null) {
|
||||
public static boolean isCraftingToolEquivalent(ItemStack base, ItemStack comparison) {
|
||||
if (base == null || comparison == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (item.hasContainerItem(itemstack)) {
|
||||
if (item.isDamageable() || itemstack.hasTagCompound()) {
|
||||
return !item.doesContainerItemLeaveCraftingGrid(itemstack);
|
||||
}
|
||||
Item baseItem = base.getItem();
|
||||
if (baseItem.doesContainerItemLeaveCraftingGrid(base)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
if (baseItem != comparison.getItem()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (base.stackTagCompound == null || base.stackTagCompound.hasNoTags()) {
|
||||
// tool uses meta for damage
|
||||
return true;
|
||||
} else {
|
||||
// tool uses NBT for damage
|
||||
if (base.getItemDamage() == OreDictionary.WILDCARD_VALUE) {
|
||||
return true;
|
||||
}
|
||||
return base.getItemDamage() == comparison.getItemDamage();
|
||||
}
|
||||
}
|
||||
|
||||
public static void dropItemStackAsEntity(ItemStack items, World world, double x, double y, double z) {
|
||||
|
||||
@@ -15,6 +15,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import forestry.core.fluids.FluidHelper;
|
||||
import forestry.core.utils.ItemStackUtil;
|
||||
|
||||
public class SqueezerContainerRecipe implements ISqueezerContainerRecipe {
|
||||
|
||||
@@ -52,9 +53,14 @@ public class SqueezerContainerRecipe implements ISqueezerContainerRecipe {
|
||||
|
||||
@Override
|
||||
public ISqueezerRecipe getSqueezerRecipe(ItemStack filledContainer) {
|
||||
if (filledContainer == null) {
|
||||
return null;
|
||||
}
|
||||
FluidStack fluidOutput = FluidHelper.getFluidStackInContainer(filledContainer);
|
||||
ItemStack filledContainerCopy = filledContainer.copy();
|
||||
filledContainerCopy.stackSize = 1;
|
||||
if (fluidOutput == null) {
|
||||
return null;
|
||||
}
|
||||
ItemStack filledContainerCopy = ItemStackUtil.createSplitStack(filledContainer, 1);
|
||||
return new SqueezerRecipe(processingTime, new ItemStack[]{filledContainerCopy}, fluidOutput, remnants, remnantsChance);
|
||||
}
|
||||
|
||||
|
||||
@@ -221,10 +221,12 @@ public class NEIHandlerSqueezer extends RecipeHandlerBase {
|
||||
}
|
||||
for (ISqueezerContainerRecipe containerRecipe : TileSqueezer.RecipeManager.containerRecipes.values()) {
|
||||
ItemStack emptyContainer = containerRecipe.getEmptyContainer();
|
||||
if (FluidHelper.isFillableContainer(emptyContainer, result)) {
|
||||
ItemStack filledContainer = FluidHelper.getFilledContainer(result, emptyContainer);
|
||||
ItemStack filledContainer = FluidHelper.getFilledContainer(result, emptyContainer);
|
||||
if (filledContainer != null) {
|
||||
ISqueezerRecipe recipe = containerRecipe.getSqueezerRecipe(filledContainer);
|
||||
this.arecipes.add(new CachedSqueezerRecipe(recipe, true));
|
||||
if (recipe != null) {
|
||||
this.arecipes.add(new CachedSqueezerRecipe(recipe, true));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -230,7 +230,7 @@ public class TileRaintank extends TileBase implements ISidedInventory, ILiquidTa
|
||||
@Override
|
||||
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
|
||||
if (slotIndex == SLOT_RESOURCE) {
|
||||
return FluidHelper.isFillableContainer(itemStack, Fluids.WATER.getFluid(1000));
|
||||
return FluidHelper.getFilledContainer(Fluids.WATER.getFluid(1000), itemStack) != null;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -415,9 +415,12 @@ public class TileSqueezer extends TilePowered implements ISocketable, ISidedInve
|
||||
public static ISqueezerRecipe findMatchingRecipe(ItemStack[] items) {
|
||||
// Find container recipes
|
||||
for (ItemStack itemStack : items) {
|
||||
ISqueezerContainerRecipe recipe = findMatchingContainerRecipe(itemStack);
|
||||
if (recipe != null) {
|
||||
return recipe.getSqueezerRecipe(itemStack);
|
||||
ISqueezerContainerRecipe containerRecipe = findMatchingContainerRecipe(itemStack);
|
||||
if (containerRecipe != null) {
|
||||
ISqueezerRecipe recipe = containerRecipe.getSqueezerRecipe(itemStack);
|
||||
if (recipe != null) {
|
||||
return recipe;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,12 +12,11 @@ package forestry.lepidopterology.items;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.core.Tabs;
|
||||
import forestry.api.lepidopterology.IButterfly;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import forestry.core.config.Config;
|
||||
import forestry.core.gui.IHintSource;
|
||||
import forestry.core.items.ItemAlyzer;
|
||||
@@ -33,46 +32,8 @@ public class ItemFlutterlyzer extends ItemAlyzer {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isSpecimen(ItemStack itemStack) {
|
||||
return PluginLepidopterology.butterflyInterface.isMember(itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSlotClick(EntityPlayer player) {
|
||||
// Source slot to analyze empty
|
||||
if (getStackInSlot(SLOT_SPECIMEN) == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
IButterfly butterfly = PluginLepidopterology.butterflyInterface.getMember(getStackInSlot(SLOT_SPECIMEN));
|
||||
// No tree, abort
|
||||
if (butterfly == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Analyze if necessary
|
||||
if (!butterfly.isAnalyzed()) {
|
||||
|
||||
// Requires energy
|
||||
if (!isEnergy(getStackInSlot(SLOT_ENERGY))) {
|
||||
return;
|
||||
}
|
||||
|
||||
butterfly.analyze();
|
||||
if (player != null) {
|
||||
PluginLepidopterology.butterflyInterface.getBreedingTracker(player.worldObj, player.getGameProfile()).registerSpecies(butterfly.getGenome().getPrimary());
|
||||
PluginLepidopterology.butterflyInterface.getBreedingTracker(player.worldObj, player.getGameProfile()).registerSpecies(butterfly.getGenome().getSecondary());
|
||||
}
|
||||
NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
butterfly.writeToNBT(nbttagcompound);
|
||||
getStackInSlot(SLOT_SPECIMEN).setTagCompound(nbttagcompound);
|
||||
|
||||
// Decrease energy
|
||||
decrStackSize(SLOT_ENERGY, 1);
|
||||
}
|
||||
|
||||
setInventorySlotContents(SLOT_ANALYZE_1, getStackInSlot(SLOT_SPECIMEN));
|
||||
setInventorySlotContents(SLOT_SPECIMEN, null);
|
||||
protected ISpeciesRoot getSpeciesRoot() {
|
||||
return PluginLepidopterology.butterflyInterface;
|
||||
}
|
||||
|
||||
/* IHINTSOURCE */
|
||||
|
||||
Reference in new issue
Block a user