mirror of
https://github.com/GTNewHorizons/Binnie.git
synced 2026-11-27 23:46:05 +00:00
port to forestry 4.2
This commit is contained in:
1 parent
dbc5c1a564
commit
f969f63b66
3697 files changed
+78372
No files matched your search
@@ -0,0 +1,115 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.extrabees.apiary.machine;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.api.apiculture.IBee;
|
||||
import forestry.api.apiculture.IBeeGenome;
|
||||
import forestry.api.apiculture.IBeeListener;
|
||||
import forestry.api.apiculture.IBeeModifier;
|
||||
import forestry.api.apiculture.IHiveFrame;
|
||||
import binnie.Binnie;
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.core.machines.inventory.ComponentInventorySlots;
|
||||
import binnie.core.machines.inventory.SlotValidator;
|
||||
import binnie.craftgui.minecraft.IMachineInformation;
|
||||
import binnie.extrabees.apiary.ComponentBeeModifier;
|
||||
import binnie.extrabees.apiary.ComponentExtraBeeGUI;
|
||||
import binnie.extrabees.apiary.TileExtraBeeAlveary;
|
||||
import binnie.extrabees.core.ExtraBeeGUID;
|
||||
import binnie.extrabees.core.ExtraBeeTexture;
|
||||
|
||||
public class AlvearyFrame
|
||||
{
|
||||
public static int slotFrame;
|
||||
|
||||
static {
|
||||
AlvearyFrame.slotFrame = 0;
|
||||
}
|
||||
|
||||
public static class PackageAlvearyFrame extends AlvearyMachine.AlvearyPackage implements IMachineInformation
|
||||
{
|
||||
public PackageAlvearyFrame() {
|
||||
super("frame", ExtraBeeTexture.AlvearyFrame.getTexture(), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createMachine(final Machine machine) {
|
||||
new ComponentExtraBeeGUI(machine, ExtraBeeGUID.AlvearyFrame);
|
||||
final ComponentInventorySlots inventory = new ComponentInventorySlots(machine);
|
||||
inventory.addSlot(AlvearyFrame.slotFrame, "frame");
|
||||
inventory.getSlot(AlvearyFrame.slotFrame).setValidator(new SlotValidatorFrame());
|
||||
new ComponentFrameModifier(machine);
|
||||
}
|
||||
}
|
||||
|
||||
public static class SlotValidatorFrame extends SlotValidator
|
||||
{
|
||||
public SlotValidatorFrame() {
|
||||
super(SlotValidator.IconFrame);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(final ItemStack itemStack) {
|
||||
return itemStack != null && itemStack.getItem() instanceof IHiveFrame;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return "Hive Frames";
|
||||
}
|
||||
}
|
||||
|
||||
public static class ComponentFrameModifier extends ComponentBeeModifier implements IBeeModifier, IBeeListener
|
||||
{
|
||||
public ComponentFrameModifier(final Machine machine) {
|
||||
super(machine);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void wearOutEquipment(final int amount) {
|
||||
if (this.getHiveFrame() == null) {
|
||||
return;
|
||||
}
|
||||
final World world = this.getMachine().getTileEntity().getWorldObj();
|
||||
final int wear = Math.round(amount * 5 * Binnie.Genetics.getBeeRoot().getBeekeepingMode(world).getWearModifier());
|
||||
this.getInventory().setInventorySlotContents(AlvearyFrame.slotFrame, this.getHiveFrame().frameUsed(((TileExtraBeeAlveary) this.getMachine().getTileEntity()).getMultiblockLogic().getController(), this.getInventory().getStackInSlot(AlvearyFrame.slotFrame), (IBee) null, wear));
|
||||
}
|
||||
|
||||
public IHiveFrame getHiveFrame() {
|
||||
if (this.getInventory().getStackInSlot(AlvearyFrame.slotFrame) != null) {
|
||||
return (IHiveFrame) this.getInventory().getStackInSlot(AlvearyFrame.slotFrame).getItem();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getTerritoryModifier(final IBeeGenome genome, final float currentModifier) {
|
||||
return (this.getHiveFrame() == null) ? 1.0f : this.getHiveFrame().getBeeModifier().getTerritoryModifier(genome, currentModifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getMutationModifier(final IBeeGenome genome, final IBeeGenome mate, final float currentModifier) {
|
||||
return (this.getHiveFrame() == null) ? 1.0f : this.getHiveFrame().getBeeModifier().getMutationModifier(genome, mate, currentModifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getLifespanModifier(final IBeeGenome genome, final IBeeGenome mate, final float currentModifier) {
|
||||
return (this.getHiveFrame() == null) ? 1.0f : this.getHiveFrame().getBeeModifier().getLifespanModifier(genome, mate, currentModifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getProductionModifier(final IBeeGenome genome, final float currentModifier) {
|
||||
return (this.getHiveFrame() == null) ? 1.0f : this.getHiveFrame().getBeeModifier().getProductionModifier(genome, currentModifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getFloweringModifier(final IBeeGenome genome, final float currentModifier) {
|
||||
return (this.getHiveFrame() == null) ? 1.0f : this.getHiveFrame().getBeeModifier().getFloweringModifier(genome, currentModifier);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.extrabees.apiary.machine;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import forestry.api.apiculture.EnumBeeType;
|
||||
import forestry.api.apiculture.IBee;
|
||||
import forestry.api.apiculture.IBeeHousing;
|
||||
import forestry.api.apiculture.IBeeListener;
|
||||
import forestry.api.apiculture.IBeeModifier;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import binnie.Binnie;
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.core.machines.inventory.ComponentInventorySlots;
|
||||
import binnie.core.machines.inventory.InventorySlot;
|
||||
import binnie.core.machines.inventory.SlotValidator;
|
||||
import binnie.core.machines.transfer.TransferRequest;
|
||||
import binnie.craftgui.minecraft.IMachineInformation;
|
||||
import binnie.extrabees.apiary.ComponentBeeModifier;
|
||||
import binnie.extrabees.apiary.ComponentExtraBeeGUI;
|
||||
import binnie.extrabees.apiary.TileExtraBeeAlveary;
|
||||
import binnie.extrabees.core.ExtraBeeGUID;
|
||||
import binnie.extrabees.core.ExtraBeeTexture;
|
||||
|
||||
public class AlvearyHatchery
|
||||
{
|
||||
public static int[] slotLarvae;
|
||||
|
||||
static {
|
||||
AlvearyHatchery.slotLarvae = new int[] { 0, 1, 2, 3, 4 };
|
||||
}
|
||||
|
||||
public static class PackageAlvearyHatchery extends AlvearyMachine.AlvearyPackage implements IMachineInformation
|
||||
{
|
||||
public PackageAlvearyHatchery() {
|
||||
super("hatchery", ExtraBeeTexture.AlvearyHatchery.getTexture(), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createMachine(final Machine machine) {
|
||||
new ComponentExtraBeeGUI(machine, ExtraBeeGUID.AlvearyHatchery);
|
||||
final ComponentInventorySlots inventory = new ComponentInventorySlots(machine);
|
||||
for (final InventorySlot slot : inventory.addSlotArray(AlvearyHatchery.slotLarvae, "hatchery")) {
|
||||
slot.setValidator(new SlotValidatorLarvae());
|
||||
}
|
||||
new ComponentFrameModifier(machine);
|
||||
}
|
||||
}
|
||||
|
||||
public static class SlotValidatorLarvae extends SlotValidator
|
||||
{
|
||||
public SlotValidatorLarvae() {
|
||||
super(SlotValidator.IconBee);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(final ItemStack itemStack) {
|
||||
return Binnie.Genetics.getBeeRoot().isMember(itemStack) && Binnie.Genetics.getBeeRoot().getType(itemStack) == EnumBeeType.LARVAE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return "Larvae";
|
||||
}
|
||||
}
|
||||
|
||||
public static class ComponentFrameModifier extends ComponentBeeModifier implements IBeeModifier, IBeeListener
|
||||
{
|
||||
public ComponentFrameModifier(final Machine machine) {
|
||||
super(machine);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
if (new Random().nextInt(2400) == 0) {
|
||||
final TileEntity tile = this.getMachine().getTileEntity();
|
||||
if (tile instanceof TileExtraBeeAlveary) {
|
||||
final IBeeHousing house = ((TileExtraBeeAlveary) tile).getMultiblockLogic().getController();
|
||||
if (house != null && !house.getErrorLogic().hasErrors()) {
|
||||
final ItemStack queenStack = house.getBeeInventory().getQueen();
|
||||
final IBee queen = (queenStack == null) ? null : Binnie.Genetics.getBeeRoot().getMember(queenStack);
|
||||
if (queen != null) {
|
||||
final ItemStack larvae = Binnie.Genetics.getBeeRoot().getMemberStack(Binnie.Genetics.getBeeRoot().getBee(this.getMachine().getWorld(), queen.getGenome()), EnumBeeType.LARVAE.ordinal());
|
||||
new TransferRequest(larvae, this.getInventory()).transfer(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.extrabees.apiary.machine;
|
||||
|
||||
import forestry.api.apiculture.IBeeListener;
|
||||
import forestry.api.apiculture.IBeeModifier;
|
||||
import binnie.extrabees.apiary.ComponentBeeModifier;
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.extrabees.core.ExtraBeeTexture;
|
||||
import binnie.craftgui.minecraft.IMachineInformation;
|
||||
|
||||
public class AlvearyLighting
|
||||
{
|
||||
public static class PackageAlvearyLighting extends AlvearyMachine.AlvearyPackage implements IMachineInformation
|
||||
{
|
||||
public PackageAlvearyLighting() {
|
||||
super("lighting", ExtraBeeTexture.AlvearyLighting.getTexture(), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createMachine(final Machine machine) {
|
||||
new ComponentLighting(machine);
|
||||
}
|
||||
}
|
||||
|
||||
public static class ComponentLighting extends ComponentBeeModifier implements IBeeModifier, IBeeListener
|
||||
{
|
||||
public ComponentLighting(final Machine machine) {
|
||||
super(machine);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSelfLighted() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.extrabees.apiary.machine;
|
||||
|
||||
import binnie.core.machines.MachineRendererBlock;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import binnie.extrabees.apiary.TileExtraBeeAlveary;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.core.resource.BinnieResource;
|
||||
import binnie.extrabees.apiary.ModuleApiary;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import binnie.core.machines.MachinePackage;
|
||||
import binnie.core.machines.IMachineType;
|
||||
|
||||
public enum AlvearyMachine implements IMachineType
|
||||
{
|
||||
Mutator(AlvearyMutator.PackageAlvearyMutator.class),
|
||||
Frame(AlvearyFrame.PackageAlvearyFrame.class),
|
||||
RainShield(AlvearyRainShield.PackageAlvearyRainShield.class),
|
||||
Lighting(AlvearyLighting.PackageAlvearyLighting.class),
|
||||
Stimulator(AlvearyStimulator.PackageAlvearyStimulator.class),
|
||||
Hatchery(AlvearyHatchery.PackageAlvearyHatchery.class),
|
||||
Transmission(AlvearyTransmission.PackageAlvearyTransmission.class);
|
||||
|
||||
Class<? extends MachinePackage> clss;
|
||||
|
||||
private AlvearyMachine(final Class<? extends MachinePackage> clss) {
|
||||
this.clss = clss;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends MachinePackage> getPackageClass() {
|
||||
return this.clss;
|
||||
}
|
||||
|
||||
public ItemStack get(final int size) {
|
||||
return new ItemStack(ModuleApiary.blockComponent, size, this.ordinal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActive() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public abstract static class AlvearyPackage extends MachinePackage
|
||||
{
|
||||
BinnieResource machineTexture;
|
||||
|
||||
public AlvearyPackage(final String id, final BinnieResource machineTexture, final boolean powered) {
|
||||
super(id, powered);
|
||||
this.machineTexture = machineTexture;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createMachine(final Machine machine) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity() {
|
||||
return new TileExtraBeeAlveary(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderMachine(final Machine machine, final double x, final double y, final double z, final float var8, final RenderBlocks renderer) {
|
||||
MachineRendererBlock.instance.renderMachine(this.machineTexture, x, y, z, var8);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.extrabees.apiary.machine;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import forestry.api.apiculture.IBee;
|
||||
import forestry.api.apiculture.IBeeGenome;
|
||||
import forestry.api.apiculture.IBeeListener;
|
||||
import forestry.api.apiculture.IBeeModifier;
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.core.machines.inventory.ComponentInventorySlots;
|
||||
import binnie.core.machines.inventory.SlotValidator;
|
||||
import binnie.core.machines.inventory.ValidatorIcon;
|
||||
import binnie.craftgui.minecraft.IMachineInformation;
|
||||
import binnie.extrabees.ExtraBees;
|
||||
import binnie.extrabees.apiary.ComponentBeeModifier;
|
||||
import binnie.extrabees.apiary.ComponentExtraBeeGUI;
|
||||
import binnie.extrabees.core.ExtraBeeGUID;
|
||||
import binnie.extrabees.core.ExtraBeeTexture;
|
||||
|
||||
public class AlvearyMutator
|
||||
{
|
||||
public static int slotMutator;
|
||||
static Map<ItemStack, Float> mutations;
|
||||
|
||||
public static boolean isMutationItem(final ItemStack item) {
|
||||
return getMutationMult(item) > 0.0f;
|
||||
}
|
||||
|
||||
public static float getMutationMult(final ItemStack item) {
|
||||
if (item == null) {
|
||||
return 1.0f;
|
||||
}
|
||||
for (final ItemStack comp : AlvearyMutator.mutations.keySet()) {
|
||||
if (ItemStack.areItemStackTagsEqual(item, comp) && item.isItemEqual(comp)) {
|
||||
return AlvearyMutator.mutations.get(comp);
|
||||
}
|
||||
}
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
public static void addMutationItem(final ItemStack item, final float chance) {
|
||||
if (item == null) {
|
||||
return;
|
||||
}
|
||||
AlvearyMutator.mutations.put(item, chance);
|
||||
}
|
||||
|
||||
public static Collection<ItemStack> getMutagens() {
|
||||
return AlvearyMutator.mutations.keySet();
|
||||
}
|
||||
|
||||
static {
|
||||
AlvearyMutator.slotMutator = 0;
|
||||
AlvearyMutator.mutations = new HashMap<ItemStack, Float>();
|
||||
}
|
||||
|
||||
public static class PackageAlvearyMutator extends AlvearyMachine.AlvearyPackage implements IMachineInformation
|
||||
{
|
||||
public PackageAlvearyMutator() {
|
||||
super("mutator", ExtraBeeTexture.AlvearyMutator.getTexture(), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createMachine(final Machine machine) {
|
||||
new ComponentExtraBeeGUI(machine, ExtraBeeGUID.AlvearyMutator);
|
||||
final ComponentInventorySlots inventory = new ComponentInventorySlots(machine);
|
||||
inventory.addSlot(AlvearyMutator.slotMutator, "mutator");
|
||||
inventory.getSlot(AlvearyMutator.slotMutator).setValidator(new SlotValidatorMutator());
|
||||
new ComponentMutatorModifier(machine);
|
||||
}
|
||||
}
|
||||
|
||||
public static class SlotValidatorMutator extends SlotValidator
|
||||
{
|
||||
public SlotValidatorMutator() {
|
||||
super(new ValidatorIcon(ExtraBees.instance, "validator/mutator.0", "validator/mutator.1"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(final ItemStack itemStack) {
|
||||
return AlvearyMutator.isMutationItem(itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return "Mutagenic Agents";
|
||||
}
|
||||
}
|
||||
|
||||
public static class ComponentMutatorModifier extends ComponentBeeModifier implements IBeeModifier, IBeeListener
|
||||
{
|
||||
public ComponentMutatorModifier(final Machine machine) {
|
||||
super(machine);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getMutationModifier(final IBeeGenome genome, final IBeeGenome mate, final float currentModifier) {
|
||||
if (this.getUtil().isSlotEmpty(AlvearyMutator.slotMutator)) {
|
||||
return 1.0f;
|
||||
}
|
||||
final float mult = AlvearyMutator.getMutationMult(this.getUtil().getStack(AlvearyMutator.slotMutator));
|
||||
return Math.min(mult, 15.0f / currentModifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPostQueenDeath(final IBee queen) {
|
||||
this.getUtil().decreaseStack(AlvearyMutator.slotMutator, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.extrabees.apiary.machine;
|
||||
|
||||
import forestry.api.apiculture.IBeeListener;
|
||||
import forestry.api.apiculture.IBeeModifier;
|
||||
import binnie.extrabees.apiary.ComponentBeeModifier;
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.extrabees.core.ExtraBeeTexture;
|
||||
import binnie.craftgui.minecraft.IMachineInformation;
|
||||
|
||||
public class AlvearyRainShield
|
||||
{
|
||||
public static class PackageAlvearyRainShield extends AlvearyMachine.AlvearyPackage implements IMachineInformation
|
||||
{
|
||||
public PackageAlvearyRainShield() {
|
||||
super("rainShield", ExtraBeeTexture.AlvearyRainShield.getTexture(), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createMachine(final Machine machine) {
|
||||
new ComponentRainShield(machine);
|
||||
}
|
||||
}
|
||||
|
||||
public static class ComponentRainShield extends ComponentBeeModifier implements IBeeModifier, IBeeListener
|
||||
{
|
||||
public ComponentRainShield(final Machine machine) {
|
||||
super(machine);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSealed() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,421 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.extrabees.apiary.machine;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import forestry.api.apiculture.IBeeGenome;
|
||||
import forestry.api.apiculture.IBeeListener;
|
||||
import forestry.api.apiculture.IBeeModifier;
|
||||
import forestry.api.circuits.ChipsetManager;
|
||||
import forestry.api.circuits.ICircuit;
|
||||
import forestry.api.circuits.ICircuitBoard;
|
||||
import forestry.api.circuits.ICircuitLayout;
|
||||
import binnie.core.Mods;
|
||||
import binnie.core.circuits.BinnieCircuit;
|
||||
import binnie.core.genetics.BeeModifierLogic;
|
||||
import binnie.core.genetics.EnumBeeBooleanModifier;
|
||||
import binnie.core.genetics.EnumBeeModifier;
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.core.machines.inventory.ComponentInventorySlots;
|
||||
import binnie.core.machines.inventory.SlotValidator;
|
||||
import binnie.core.machines.power.ComponentPowerReceptor;
|
||||
import binnie.craftgui.minecraft.IMachineInformation;
|
||||
import binnie.extrabees.apiary.ComponentBeeModifier;
|
||||
import binnie.extrabees.apiary.ComponentExtraBeeGUI;
|
||||
import binnie.extrabees.core.ExtraBeeGUID;
|
||||
import binnie.extrabees.core.ExtraBeeTexture;
|
||||
|
||||
public class AlvearyStimulator
|
||||
{
|
||||
public static int slotCircuit;
|
||||
|
||||
static {
|
||||
AlvearyStimulator.slotCircuit = 0;
|
||||
}
|
||||
|
||||
public static class PackageAlvearyStimulator extends AlvearyMachine.AlvearyPackage implements IMachineInformation
|
||||
{
|
||||
public PackageAlvearyStimulator() {
|
||||
super("stimulator", ExtraBeeTexture.AlvearyStimulator.getTexture(), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createMachine(final Machine machine) {
|
||||
new ComponentExtraBeeGUI(machine, ExtraBeeGUID.AlvearyStimulator);
|
||||
final ComponentInventorySlots inventory = new ComponentInventorySlots(machine);
|
||||
inventory.addSlot(AlvearyStimulator.slotCircuit, "circuit");
|
||||
inventory.getSlot(AlvearyStimulator.slotCircuit).setValidator(new SlotValidatorCircuit());
|
||||
final ComponentPowerReceptor power = new ComponentPowerReceptor(machine);
|
||||
new ComponentStimulatorModifier(machine);
|
||||
}
|
||||
}
|
||||
|
||||
public static class SlotValidatorCircuit extends SlotValidator
|
||||
{
|
||||
public SlotValidatorCircuit() {
|
||||
super(SlotValidator.IconCircuit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(final ItemStack itemStack) {
|
||||
return itemStack != null && ChipsetManager.circuitRegistry.isChipset(itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return "Forestry Circuits";
|
||||
}
|
||||
}
|
||||
|
||||
public static class ComponentStimulatorModifier extends ComponentBeeModifier implements IBeeModifier, IBeeListener
|
||||
{
|
||||
float powerUsage;
|
||||
boolean powered;
|
||||
StimulatorCircuit[] modifiers;
|
||||
|
||||
public ComponentStimulatorModifier(final Machine machine) {
|
||||
super(machine);
|
||||
this.powerUsage = 0.0f;
|
||||
this.powered = false;
|
||||
this.modifiers = new StimulatorCircuit[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
this.modifiers = this.getCircuits();
|
||||
this.powerUsage = 0.0f;
|
||||
for (final StimulatorCircuit beeMod : this.modifiers) {
|
||||
this.powerUsage += beeMod.getPowerUsage();
|
||||
}
|
||||
this.powered = this.getUtil().hasEnergyMJ(this.powerUsage);
|
||||
}
|
||||
|
||||
public ICircuitBoard getHiveFrame() {
|
||||
if (!this.getUtil().isSlotEmpty(AlvearyStimulator.slotCircuit)) {
|
||||
return ChipsetManager.circuitRegistry.getCircuitboard(this.getUtil().getStack(AlvearyStimulator.slotCircuit));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public StimulatorCircuit[] getCircuits() {
|
||||
final ICircuitBoard board = this.getHiveFrame();
|
||||
if (board == null) {
|
||||
return new StimulatorCircuit[0];
|
||||
}
|
||||
final ICircuit[] circuits = board.getCircuits();
|
||||
final List<IBeeModifier> mod = new ArrayList<IBeeModifier>();
|
||||
for (final ICircuit circuit : circuits) {
|
||||
if (circuit instanceof StimulatorCircuit) {
|
||||
mod.add((IBeeModifier) circuit);
|
||||
}
|
||||
}
|
||||
return mod.toArray(new StimulatorCircuit[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getTerritoryModifier(final IBeeGenome genome, final float currentModifier) {
|
||||
float mod = 1.0f;
|
||||
if (!this.powered) {
|
||||
return mod;
|
||||
}
|
||||
for (final IBeeModifier beeMod : this.modifiers) {
|
||||
mod *= beeMod.getTerritoryModifier(genome, mod);
|
||||
}
|
||||
return mod;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getMutationModifier(final IBeeGenome genome, final IBeeGenome mate, final float currentModifier) {
|
||||
float mod = 1.0f;
|
||||
if (!this.powered) {
|
||||
return mod;
|
||||
}
|
||||
for (final IBeeModifier beeMod : this.modifiers) {
|
||||
mod *= beeMod.getMutationModifier(genome, mate, mod);
|
||||
}
|
||||
return mod;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getLifespanModifier(final IBeeGenome genome, final IBeeGenome mate, final float currentModifier) {
|
||||
float mod = 1.0f;
|
||||
if (!this.powered) {
|
||||
return mod;
|
||||
}
|
||||
for (final IBeeModifier beeMod : this.modifiers) {
|
||||
mod *= beeMod.getLifespanModifier(genome, mate, mod);
|
||||
}
|
||||
return mod;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getProductionModifier(final IBeeGenome genome, final float currentModifier) {
|
||||
float mod = 1.0f;
|
||||
if (!this.powered) {
|
||||
return mod;
|
||||
}
|
||||
for (final IBeeModifier beeMod : this.modifiers) {
|
||||
mod *= beeMod.getProductionModifier(genome, mod);
|
||||
}
|
||||
return mod;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getFloweringModifier(final IBeeGenome genome, final float currentModifier) {
|
||||
float mod = 1.0f;
|
||||
if (!this.powered) {
|
||||
return mod;
|
||||
}
|
||||
for (final IBeeModifier beeMod : this.modifiers) {
|
||||
mod *= beeMod.getFloweringModifier(genome, mod);
|
||||
}
|
||||
return mod;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getGeneticDecay(final IBeeGenome genome, final float currentModifier) {
|
||||
float mod = 1.0f;
|
||||
if (!this.powered) {
|
||||
return mod;
|
||||
}
|
||||
for (final IBeeModifier beeMod : this.modifiers) {
|
||||
mod *= beeMod.getGeneticDecay(genome, mod);
|
||||
}
|
||||
return mod;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSealed() {
|
||||
if (!this.powered) {
|
||||
return false;
|
||||
}
|
||||
for (final IBeeModifier beeMod : this.modifiers) {
|
||||
if (beeMod.isSealed()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSelfLighted() {
|
||||
if (!this.powered) {
|
||||
return false;
|
||||
}
|
||||
for (final IBeeModifier beeMod : this.modifiers) {
|
||||
if (beeMod.isSelfLighted()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSunlightSimulated() {
|
||||
if (!this.powered) {
|
||||
return false;
|
||||
}
|
||||
for (final IBeeModifier beeMod : this.modifiers) {
|
||||
if (beeMod.isSunlightSimulated()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHellish() {
|
||||
if (!this.powered) {
|
||||
return false;
|
||||
}
|
||||
for (final IBeeModifier beeMod : this.modifiers) {
|
||||
if (beeMod.isHellish()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void wearOutEquipment(final int amount) {
|
||||
this.getUtil().useEnergyMJ(this.powerUsage);
|
||||
}
|
||||
}
|
||||
|
||||
public static class StimulatorCircuit extends BinnieCircuit implements IBeeModifier
|
||||
{
|
||||
CircuitType type;
|
||||
|
||||
public StimulatorCircuit(final CircuitType type, final ICircuitLayout layout) {
|
||||
super("stimulator." + type.toString().toLowerCase(), 4, layout, Mods.Forestry.item("thermionicTubes"), type.recipe);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public int getPowerUsage() {
|
||||
return this.type.power;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getTerritoryModifier(final IBeeGenome genome, final float currentModifier) {
|
||||
return this.type.getTerritoryModifier(genome, currentModifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getMutationModifier(final IBeeGenome genome, final IBeeGenome mate, final float currentModifier) {
|
||||
return this.type.getMutationModifier(genome, mate, currentModifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getLifespanModifier(final IBeeGenome genome, final IBeeGenome mate, final float currentModifier) {
|
||||
return this.type.getLifespanModifier(genome, mate, currentModifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getProductionModifier(final IBeeGenome genome, final float currentModifier) {
|
||||
return this.type.getProductionModifier(genome, currentModifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getFloweringModifier(final IBeeGenome genome, final float currentModifier) {
|
||||
return this.type.getFloweringModifier(genome, currentModifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSealed() {
|
||||
return this.type.isSealed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSelfLighted() {
|
||||
return this.type.isSelfLighted();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSunlightSimulated() {
|
||||
return this.type.isSunlightSimulated();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHellish() {
|
||||
return this.type.isHellish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getGeneticDecay(final IBeeGenome genome, final float currentModifier) {
|
||||
return this.type.getGeneticDecay(genome, currentModifier);
|
||||
}
|
||||
}
|
||||
|
||||
public enum CircuitType implements IBeeModifier
|
||||
{
|
||||
LowVoltage(3, 10),
|
||||
HighVoltage(5, 20),
|
||||
Plant(10, 10),
|
||||
Death(6, 10),
|
||||
Life(11, 10),
|
||||
Nether(7, 15),
|
||||
Mutation(4, 15),
|
||||
Inhibitor(1, 10),
|
||||
Territory(2, 10);
|
||||
|
||||
public int recipe;
|
||||
public int power;
|
||||
BeeModifierLogic logic;
|
||||
|
||||
private CircuitType(final int recipe, final int power) {
|
||||
this.logic = new BeeModifierLogic();
|
||||
this.recipe = recipe;
|
||||
this.power = power;
|
||||
}
|
||||
|
||||
public void createCircuit(final ICircuitLayout layout) {
|
||||
final StimulatorCircuit circuit = new StimulatorCircuit(this, layout);
|
||||
for (final EnumBeeModifier modifier : EnumBeeModifier.values()) {
|
||||
final float mod = this.logic.getModifier(modifier, 1.0f);
|
||||
if (mod != 1.0f) {
|
||||
if (mod > 1.0f) {
|
||||
final int increase = (int) ((mod - 1.0f) * 100.0f);
|
||||
circuit.addTooltipString("Increases " + modifier.getName() + " by " + increase + "%");
|
||||
}
|
||||
else {
|
||||
final int decrease = (int) ((1.0f - mod) * 100.0f);
|
||||
circuit.addTooltipString("Decreases " + modifier.getName() + " by " + decrease + "%");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getTerritoryModifier(final IBeeGenome genome, final float currentModifier) {
|
||||
return this.logic.getModifier(EnumBeeModifier.Territory, currentModifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getMutationModifier(final IBeeGenome genome, final IBeeGenome mate, final float currentModifier) {
|
||||
return this.logic.getModifier(EnumBeeModifier.Mutation, currentModifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getLifespanModifier(final IBeeGenome genome, final IBeeGenome mate, final float currentModifier) {
|
||||
return this.logic.getModifier(EnumBeeModifier.Lifespan, currentModifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getProductionModifier(final IBeeGenome genome, final float currentModifier) {
|
||||
return this.logic.getModifier(EnumBeeModifier.Production, currentModifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getFloweringModifier(final IBeeGenome genome, final float currentModifier) {
|
||||
return this.logic.getModifier(EnumBeeModifier.Flowering, currentModifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getGeneticDecay(final IBeeGenome genome, final float currentModifier) {
|
||||
return this.logic.getModifier(EnumBeeModifier.GeneticDecay, currentModifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSealed() {
|
||||
return this.logic.getModifier(EnumBeeBooleanModifier.Sealed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSelfLighted() {
|
||||
return this.logic.getModifier(EnumBeeBooleanModifier.SelfLighted);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSunlightSimulated() {
|
||||
return this.logic.getModifier(EnumBeeBooleanModifier.SunlightStimulated);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHellish() {
|
||||
return this.logic.getModifier(EnumBeeBooleanModifier.Hellish);
|
||||
}
|
||||
|
||||
static {
|
||||
CircuitType.LowVoltage.logic.setModifier(EnumBeeModifier.Production, 1.5f, 5.0f);
|
||||
CircuitType.HighVoltage.logic.setModifier(EnumBeeModifier.Production, 2.5f, 10.0f);
|
||||
CircuitType.Plant.logic.setModifier(EnumBeeModifier.Flowering, 1.5f, 5.0f);
|
||||
CircuitType.Death.logic.setModifier(EnumBeeModifier.Lifespan, 0.8f, 0.2f);
|
||||
CircuitType.Life.logic.setModifier(EnumBeeModifier.Lifespan, 1.5f, 5.0f);
|
||||
CircuitType.Nether.logic.setModifier(EnumBeeBooleanModifier.Hellish);
|
||||
CircuitType.Mutation.logic.setModifier(EnumBeeModifier.Mutation, 1.5f, 5.0f);
|
||||
CircuitType.Inhibitor.logic.setModifier(EnumBeeModifier.Territory, 0.4f, 0.1f);
|
||||
CircuitType.Inhibitor.logic.setModifier(EnumBeeModifier.Production, 0.9f, 0.5f);
|
||||
CircuitType.Territory.logic.setModifier(EnumBeeModifier.Territory, 1.5f, 5.0f);
|
||||
for (final CircuitType type : values()) {
|
||||
type.logic.setModifier(EnumBeeModifier.GeneticDecay, 1.5f, 10.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.extrabees.apiary.machine;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import cofh.api.energy.IEnergyHandler;
|
||||
|
||||
import forestry.api.apiculture.IBeeListener;
|
||||
import forestry.api.apiculture.IBeeModifier;
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.core.machines.power.ComponentPowerReceptor;
|
||||
import binnie.craftgui.minecraft.IMachineInformation;
|
||||
import binnie.extrabees.apiary.ComponentBeeModifier;
|
||||
import binnie.extrabees.apiary.TileExtraBeeAlveary;
|
||||
import binnie.extrabees.core.ExtraBeeTexture;
|
||||
|
||||
public class AlvearyTransmission
|
||||
{
|
||||
public static class PackageAlvearyTransmission extends AlvearyMachine.AlvearyPackage implements IMachineInformation
|
||||
{
|
||||
public PackageAlvearyTransmission() {
|
||||
super("transmission", ExtraBeeTexture.AlvearyTransmission.getTexture(), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createMachine(final Machine machine) {
|
||||
new ComponentPowerReceptor(machine, 1000);
|
||||
new ComponentTransmission(machine);
|
||||
}
|
||||
}
|
||||
|
||||
public static class ComponentTransmission extends ComponentBeeModifier implements IBeeModifier, IBeeListener
|
||||
{
|
||||
public ComponentTransmission(final Machine machine) {
|
||||
super(machine);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
int energy = this.getUtil().getPoweredMachine().getEnergyStored(ForgeDirection.NORTH);
|
||||
if (energy == 0) {
|
||||
return;
|
||||
}
|
||||
final TileExtraBeeAlveary tile = (TileExtraBeeAlveary) this.getMachine().getTileEntity();
|
||||
final List<IEnergyHandler> handlers = new ArrayList<IEnergyHandler>();
|
||||
for (final TileEntity alvearyTile : tile.getAlvearyBlocks()) {
|
||||
if (alvearyTile instanceof IEnergyHandler && alvearyTile != tile) {
|
||||
handlers.add((IEnergyHandler) alvearyTile);
|
||||
}
|
||||
}
|
||||
if (handlers.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
final int maxOutput = 500;
|
||||
int output = energy / handlers.size();
|
||||
if (output > maxOutput) {
|
||||
output = maxOutput;
|
||||
}
|
||||
if (output < 1) {
|
||||
output = 1;
|
||||
}
|
||||
for (final IEnergyHandler handler : handlers) {
|
||||
final int recieved = handler.receiveEnergy(ForgeDirection.NORTH, output, false);
|
||||
this.getUtil().getPoweredMachine().receiveEnergy(ForgeDirection.NORTH, -recieved, false);
|
||||
energy = this.getUtil().getPoweredMachine().getEnergyStored(ForgeDirection.NORTH);
|
||||
if (energy <= 0) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user