Files
ForestryMC/src/main/java/forestry/apiculture/items/ItemHiveFrame.java
T
hacatuandJakub afc859c6e9 Fix Additive Production (#55)
* Fixed Secondary Species Primary Production
Calling Math.round on probabilities is a logical error

* gradle spotlessApply

* Fixed computation of BeeModifiers to be consistent with additive modifiers

Needs work in other mods (Binnie and MagicBees)

* Fixed doubled base production modifier, fixed tooltips for frames with negative modifiers

* Fixed floating point bug if productionModifier is negative

* Fixed floating point bug if productionModifier + tier is negative

* Float constant suffix

* Actually fix base production modifier

* Improve tooltip coloring, correct production modifier self capping, add float suffixes

* More tooltip improvments

* Nerf base production (apiaries in shambles)

* Halve forestry frame production boost

Co-authored-by: Jakub <[email protected]>

* Added flowering modifier to tooltips

I believe one of the blood magic frames has a non-default flowering modifier

* Fixed flowering modifier in tooltip and made default values visible

---------

Co-authored-by: Jakub <[email protected]>
2023-07-18 20:28:03 +02:00

68 lines
2.3 KiB
Java
Executable File

/*******************************************************************************
* 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.items;
import net.minecraft.item.ItemStack;
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.IHiveFrame;
import forestry.api.core.Tabs;
import forestry.core.items.ItemForestry;
public class ItemHiveFrame extends ItemForestry implements IHiveFrame {
private final IBeeModifier beeModifier;
public ItemHiveFrame(int maxDamage, float geneticDecay) {
setMaxStackSize(1);
setMaxDamage(maxDamage);
setCreativeTab(Tabs.tabApiculture);
this.beeModifier = new HiveFrameBeeModifier(geneticDecay);
}
@Override
public ItemStack frameUsed(IBeeHousing housing, ItemStack frame, IBee queen, int wear) {
frame.setItemDamage(frame.getItemDamage() + wear);
if (frame.getItemDamage() >= frame.getMaxDamage()) {
return null;
} else {
return frame;
}
}
@Override
public IBeeModifier getBeeModifier() {
return beeModifier;
}
private static class HiveFrameBeeModifier extends DefaultBeeModifier {
private final float geneticDecay;
public HiveFrameBeeModifier(float geneticDecay) {
this.geneticDecay = geneticDecay;
}
@Override
public float getProductionModifier(IBeeGenome genome, float currentModifier) {
return (currentModifier < 10.0f) ? 1.0f : 0.0f;
}
@Override
public float getGeneticDecay(IBeeGenome genome, float currentModifier) {
return this.geneticDecay;
}
}
}