mirror of
https://github.com/GTNewHorizons/Binnie.git
synced 2026-11-17 19:15:24 +00:00
Fix #98 Analyzer doesn't add researched data to the tracker.
This commit is contained in:
1 parent
0d35e58106
commit
f1df70aeec
5 files changed
+66
-52
No files matched your search
@@ -1,5 +1,28 @@
|
||||
package binnie.core.craftgui;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.api.genetics.IChromosomeType;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
|
||||
import binnie.Binnie;
|
||||
import binnie.core.AbstractMod;
|
||||
import binnie.core.BinnieCore;
|
||||
@@ -21,26 +44,6 @@ import binnie.core.craftgui.resource.minecraft.StandardTexture;
|
||||
import binnie.core.machines.inventory.SlotValidator;
|
||||
import binnie.genetics.gui.ControlChromosome;
|
||||
import binnie.genetics.machine.analyser.Analyser;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.api.genetics.IChromosomeType;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
public class WindowFieldKit extends Window {
|
||||
private int glassOffsetX;
|
||||
@@ -268,7 +271,7 @@ public class WindowFieldKit extends Window {
|
||||
public void receiveGuiNBTOnServer(final EntityPlayer player, final String name, final NBTTagCompound nbt) {
|
||||
super.receiveGuiNBTOnServer(player, name, nbt);
|
||||
if (name.equals("analyse")) {
|
||||
this.getWindowInventory().setInventorySlotContents(0, Analyser.analyse(this.getWindowInventory().getStackInSlot(0)));
|
||||
this.getWindowInventory().setInventorySlotContents(0, Analyser.analyse(this.getWindowInventory().getStackInSlot(0), this.getWorld(), this.getUsername()));
|
||||
this.getWindowInventory().decrStackSize(1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -171,13 +171,13 @@ public class ComponentPowerReceptor extends MachineComponent implements IPowered
|
||||
}
|
||||
}
|
||||
|
||||
@Optional.Method(modid = "IC2")
|
||||
@Optional.Method(modid = "ic2")
|
||||
private void do_addToEnergyNet() {
|
||||
MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent((IEnergyTile) this.getMachine().getTileEntity()));
|
||||
this.registeredToIC2EnergyNet = true;
|
||||
}
|
||||
|
||||
@Optional.Method(modid = "IC2")
|
||||
@Optional.Method(modid = "ic2")
|
||||
private void do_removeFromEnergyNet() {
|
||||
MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent((IEnergyTile) this.getMachine().getTileEntity()));
|
||||
this.registeredToIC2EnergyNet = false;
|
||||
|
||||
@@ -1,5 +1,24 @@
|
||||
package binnie.genetics.gui;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.apiculture.IBee;
|
||||
import forestry.api.arboriculture.ITree;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.IBreedingTracker;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import forestry.api.lepidopterology.IButterfly;
|
||||
|
||||
import binnie.Binnie;
|
||||
import binnie.botany.api.IFlower;
|
||||
import binnie.core.AbstractMod;
|
||||
@@ -42,22 +61,6 @@ import binnie.genetics.gui.tree.AnalystPageWood;
|
||||
import binnie.genetics.item.GeneticsItems;
|
||||
import binnie.genetics.machine.ModuleMachine;
|
||||
import binnie.genetics.machine.analyser.Analyser;
|
||||
import forestry.api.apiculture.IBee;
|
||||
import forestry.api.arboriculture.ITree;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.IBreedingTracker;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import forestry.api.lepidopterology.IButterfly;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class WindowAnalyst extends Window {
|
||||
@Nullable
|
||||
@@ -453,13 +456,9 @@ public class WindowAnalyst extends Window {
|
||||
WindowInventory inv = getWindowInventory();
|
||||
ItemStack stack = inv.getStackInSlot(0);
|
||||
if (!stack.isEmpty() && !Analyser.isAnalysed(stack)) {
|
||||
inv.setInventorySlotContents(0, Analyser.analyse(stack));
|
||||
inv.setInventorySlotContents(0, Analyser.analyse(stack, this.getWorld(), this.getUsername()));
|
||||
inv.decrStackSize(1, 1);
|
||||
}
|
||||
final IIndividual ind = AlleleManager.alleleRegistry.getIndividual(stack);
|
||||
if (ind != null) {
|
||||
ind.getGenome().getSpeciesRoot().getBreedingTracker(this.getWorld(), this.getUsername()).registerBirth(ind);
|
||||
}
|
||||
|
||||
if (this.isClient()) {
|
||||
//noinspection MethodCallSideOnly
|
||||
|
||||
@@ -1,12 +1,18 @@
|
||||
package binnie.genetics.machine.analyser;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.IBreedingTracker;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
|
||||
import binnie.Binnie;
|
||||
import binnie.genetics.api.IItemAnalysable;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class Analyser {
|
||||
public static final int[] SLOT_RESERVE = new int[]{0, 1, 2, 3, 4, 5};
|
||||
@@ -30,7 +36,7 @@ public class Analyser {
|
||||
return stack.getItem() instanceof IItemAnalysable && ((IItemAnalysable) stack.getItem()).isAnalysed(stack);
|
||||
}
|
||||
|
||||
public static ItemStack analyse(ItemStack stack) {
|
||||
public static ItemStack analyse(ItemStack stack, World world, GameProfile username) {
|
||||
if (!stack.isEmpty()) {
|
||||
final ItemStack conv = Binnie.GENETICS.getConversionStack(stack);
|
||||
if (!conv.isEmpty()) {
|
||||
@@ -40,6 +46,8 @@ public class Analyser {
|
||||
if (root != null) {
|
||||
final IIndividual ind = root.getMember(stack);
|
||||
ind.analyze();
|
||||
IBreedingTracker breedingTracker = ind.getGenome().getSpeciesRoot().getBreedingTracker(world, username);
|
||||
breedingTracker.registerBirth(ind);
|
||||
final NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
ind.writeToNBT(nbttagcompound);
|
||||
stack.setTagCompound(nbttagcompound);
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
package binnie.genetics.machine.analyser;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.core.machines.power.ComponentProcessSetCost;
|
||||
import binnie.core.machines.power.ErrorState;
|
||||
import binnie.core.machines.power.IProcess;
|
||||
import binnie.genetics.Genetics;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class AnalyserLogic extends ComponentProcessSetCost implements IProcess {
|
||||
private static final float DYE_PER_TICK = 0.002f;
|
||||
@@ -28,6 +29,9 @@ public class AnalyserLogic extends ComponentProcessSetCost implements IProcess {
|
||||
|
||||
@Override
|
||||
public ErrorState canProgress() {
|
||||
if(getMachine().getOwner() == null){
|
||||
return new ErrorState.InvalidItem(Genetics.proxy.localise("genetics.machine.errors.no.owner.desc"), Genetics.proxy.localise("genetics.machine.errors.no.owner.info"), Analyser.SLOT_TARGET);
|
||||
}
|
||||
if (this.getUtil().getSlotCharge(Analyser.SLOT_DYE) == 0.0f) {
|
||||
return new ErrorState.Item(Genetics.proxy.localise("machine.labMachine.analyser.errors.insufficient.dye.desc"), Genetics.proxy.localise("machine.labMachine.analyser.errors.insufficient.dye.info"), new int[]{13});
|
||||
}
|
||||
@@ -38,7 +42,7 @@ public class AnalyserLogic extends ComponentProcessSetCost implements IProcess {
|
||||
protected void onFinishTask() {
|
||||
super.onFinishTask();
|
||||
ItemStack itemStack = this.getUtil().getStack(Analyser.SLOT_TARGET);
|
||||
itemStack = Analyser.analyse(itemStack);
|
||||
itemStack = Analyser.analyse(itemStack, getMachine().getWorld(), getMachine().getOwner());
|
||||
this.getInventory().setInventorySlotContents(Analyser.SLOT_TARGET, itemStack);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user