mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-15 01:24:59 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
99ebd8efe0 | ||
|
|
29df6ceb1b | ||
|
|
39c822df8a | ||
|
|
9e9ae6bcad | ||
|
|
661a5598ea |
No files matched your search
+1
-1
@@ -1,7 +1,7 @@
|
||||
// Add your dependencies here
|
||||
|
||||
dependencies {
|
||||
compile('com.github.GTNewHorizons:NotEnoughItems:2.2.7-GTNH:dev')
|
||||
compile('com.github.GTNewHorizons:NotEnoughItems:2.3.45-GTNH:dev')
|
||||
compile('com.github.GTNewHorizons:inventory-tweaks:1.5.14:api')
|
||||
compile('com.github.GTNewHorizons:BuildCraft:7.1.27:api')
|
||||
compile('net.industrial-craft:industrialcraft-2:2.2.828-experimental:dev')
|
||||
|
||||
@@ -5,7 +5,12 @@
|
||||
******************************************************************************/
|
||||
package forestry.api.apiculture;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
|
||||
|
||||
public interface IHiveFrame {
|
||||
|
||||
@@ -22,4 +27,15 @@ public interface IHiveFrame {
|
||||
ItemStack frameUsed(IBeeHousing housing, ItemStack frame, IBee queen, int wear);
|
||||
|
||||
IBeeModifier getBeeModifier();
|
||||
|
||||
/**
|
||||
* Provides an override for the "Hold Shift" tooltip info for a frame.<br>
|
||||
* Called by {@link forestry.apiculture.EventHandlerApiculture#addFrameTooltip(ItemTooltipEvent)}.
|
||||
*
|
||||
* @return The info to display for this frame, or null if default generated info.
|
||||
*/
|
||||
@Nullable
|
||||
default List<String> getFrameTooltip() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -51,7 +51,7 @@ public class BeeHousingModifier implements IBeeModifier {
|
||||
public float getProductionModifier(IBeeGenome genome, final float currentModifier) {
|
||||
float modifierValue = 1.0f;
|
||||
for (IBeeModifier modifier : beeHousing.getBeeModifiers()) {
|
||||
modifierValue *= modifier.getProductionModifier(genome, modifierValue * currentModifier);
|
||||
modifierValue += modifier.getProductionModifier(genome, modifierValue + currentModifier);
|
||||
}
|
||||
return modifierValue;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
package forestry.apiculture;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import forestry.api.apiculture.IBeeModifier;
|
||||
import forestry.api.apiculture.IHiveFrame;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.StringUtil;
|
||||
|
||||
public class EventHandlerApiculture {
|
||||
|
||||
@SubscribeEvent
|
||||
public void addFrameTooltip(ItemTooltipEvent event) {
|
||||
ItemStack itemStack = event.itemStack;
|
||||
if (itemStack != null && itemStack.getItem() instanceof IHiveFrame) {
|
||||
IHiveFrame frame = (IHiveFrame) itemStack.getItem();
|
||||
IBeeModifier modifier = frame.getBeeModifier();
|
||||
List<String> tooltip = event.toolTip;
|
||||
|
||||
if (!Proxies.common.isShiftDown()) {
|
||||
tooltip.add(EnumChatFormatting.ITALIC + "<" + StringUtil.localize("gui.tooltip.tmi") + ">");
|
||||
} else {
|
||||
if (frame.getFrameTooltip() != null) {
|
||||
// use the override if it exists
|
||||
tooltip.addAll(frame.getFrameTooltip());
|
||||
} else {
|
||||
// otherwise use the auto-generated info
|
||||
int durability = itemStack.getMaxDamage();
|
||||
tooltip.add(StringUtil.localize("frame.tooltip.durability") + getDurabilityFormatted(durability));
|
||||
|
||||
float territory = modifier.getTerritoryModifier(null, 1.0F);
|
||||
tooltip.add(StringUtil.localize("frame.tooltip.territory") + getColorFormatted(territory));
|
||||
|
||||
float mutation = modifier.getMutationModifier(null, null, 1.0F);
|
||||
tooltip.add(StringUtil.localize("frame.tooltip.mutationRate") + getColorFormatted(mutation));
|
||||
|
||||
float lifespan = modifier.getLifespanModifier(null, null, 1.0F);
|
||||
tooltip.add(StringUtil.localize("frame.tooltip.lifespan") + getColorFormatted(lifespan));
|
||||
|
||||
float production = modifier.getProductionModifier(null, 1.0F);
|
||||
tooltip.add(StringUtil.localize("frame.tooltip.production") + getColorFormatted(production, true));
|
||||
|
||||
float decay = modifier.getGeneticDecay(null, 1.0F);
|
||||
tooltip.add(StringUtil.localize("frame.tooltip.geneticDecay") + getColorFormatted(decay));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static String getDurabilityFormatted(int durability) {
|
||||
EnumChatFormatting color;
|
||||
if (durability < 100) {
|
||||
color = EnumChatFormatting.DARK_RED;
|
||||
} else if (durability < 200) {
|
||||
color = EnumChatFormatting.RED;
|
||||
} else if (durability < 250) {
|
||||
color = EnumChatFormatting.GOLD;
|
||||
} else if (durability < 750) {
|
||||
color = EnumChatFormatting.GREEN;
|
||||
} else {
|
||||
color = EnumChatFormatting.AQUA;
|
||||
}
|
||||
return color + " " + durability;
|
||||
}
|
||||
|
||||
private static String getColorFormatted(float value, boolean additive) {
|
||||
EnumChatFormatting color;
|
||||
if (value <= 0.5F) {
|
||||
color = EnumChatFormatting.DARK_RED; // "bad" stat
|
||||
} else if (value < 1.0F) {
|
||||
color = EnumChatFormatting.RED; // "below average" stat
|
||||
} else if (value == 1.0F) {
|
||||
color = EnumChatFormatting.GOLD; // "average" stat
|
||||
} else if (value <= 2.0F) {
|
||||
color = EnumChatFormatting.GREEN; // "above average" stat
|
||||
} else {
|
||||
color = EnumChatFormatting.AQUA; // "great" stat
|
||||
}
|
||||
String formatted = color.toString();
|
||||
|
||||
// Set symbol for if this value is additive or multiplicative
|
||||
if (additive) {
|
||||
formatted += " +";
|
||||
} else {
|
||||
formatted += " x";
|
||||
}
|
||||
|
||||
// trim trailing zeroes if no decimal-precision is needed
|
||||
if (value == (long) value) {
|
||||
return formatted + (long) value;
|
||||
}
|
||||
return formatted + value;
|
||||
}
|
||||
|
||||
private static String getColorFormatted(float value) {
|
||||
return getColorFormatted(value, false);
|
||||
}
|
||||
}
|
||||
@@ -455,12 +455,11 @@ public class Bee extends IndividualLiving implements IBee {
|
||||
// / PRODUCTION
|
||||
@Override
|
||||
public ItemStack[] getProduceList() {
|
||||
ArrayList<ItemStack> products = new ArrayList<>();
|
||||
|
||||
IAlleleBeeSpecies primary = genome.getPrimary();
|
||||
IAlleleBeeSpecies secondary = genome.getSecondary();
|
||||
|
||||
products.addAll(primary.getProductChances().keySet());
|
||||
ArrayList<ItemStack> products = new ArrayList<>(primary.getProductChances().keySet());
|
||||
|
||||
Set<ItemStack> secondaryProducts = secondary.getProductChances().keySet();
|
||||
// Remove duplicates
|
||||
@@ -479,13 +478,13 @@ public class Bee extends IndividualLiving implements IBee {
|
||||
}
|
||||
}
|
||||
|
||||
return products.toArray(new ItemStack[products.size()]);
|
||||
return products.toArray(new ItemStack[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] getSpecialtyList() {
|
||||
Set<ItemStack> specialties = genome.getPrimary().getSpecialtyChances().keySet();
|
||||
return specialties.toArray(new ItemStack[specialties.size()]);
|
||||
return specialties.toArray(new ItemStack[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -517,7 +516,6 @@ public class Bee extends IndividualLiving implements IBee {
|
||||
float speed = genome.getSpeed();
|
||||
float prodModifier = beeHousingModifier.getProductionModifier(genome, 1f)
|
||||
* beeModeModifier.getProductionModifier(genome, 1f);
|
||||
prodModifier /= 4f;
|
||||
|
||||
// / Primary Products
|
||||
for (Map.Entry<ItemStack, Float> entry : primary.getProductChances().entrySet()) {
|
||||
@@ -541,7 +539,7 @@ public class Bee extends IndividualLiving implements IBee {
|
||||
}
|
||||
}
|
||||
|
||||
ItemStack[] productsArray = products.toArray(new ItemStack[products.size()]);
|
||||
ItemStack[] productsArray = products.toArray(new ItemStack[0]);
|
||||
ChunkCoordinates housingCoordinates = housing.getCoordinates();
|
||||
return genome.getFlowerProvider().affectProducts(
|
||||
housing.getWorld(),
|
||||
@@ -554,9 +552,9 @@ public class Bee extends IndividualLiving implements IBee {
|
||||
|
||||
public static float getFinalChance(float chance, float beeSpeed, float productionModifier, float t) {
|
||||
chance *= 100f;
|
||||
return (float) (((1f + t / 6f) * Math.sqrt(chance) * 2f * (1f + beeSpeed)
|
||||
+ Math.pow(productionModifier, Math.cbrt(chance))
|
||||
- 3f) / 100f);
|
||||
return (float) (2.8 * Math.pow(chance, 0.52)
|
||||
* Math.pow((productionModifier + t), 0.52)
|
||||
* Math.pow(beeSpeed, 0.37)) / 100.f;
|
||||
}
|
||||
|
||||
/* REPRODUCTION */
|
||||
|
||||
@@ -414,7 +414,6 @@ public class AlvearyController extends RectangularMultiblockControllerBase
|
||||
tempChange += change;
|
||||
tempChange = Math.max(boundaryDown - temperature, tempChange);
|
||||
tempChange = Math.min(boundaryUp - temperature, tempChange);
|
||||
tempChange = (change > 0 && tempChange < 0) || (change < 0 && tempChange > 0) ? 0 : tempChange;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -424,7 +423,6 @@ public class AlvearyController extends RectangularMultiblockControllerBase
|
||||
humidChange += change;
|
||||
humidChange = Math.max(boundaryDown - humidity, humidChange);
|
||||
humidChange = Math.min(boundaryUp - humidity, humidChange);
|
||||
humidChange = (change > 0 && humidChange < 0) || (change < 0 && humidChange > 0) ? 0 : humidChange;
|
||||
}
|
||||
|
||||
/* GUI */
|
||||
|
||||
@@ -32,7 +32,7 @@ public class TileAlvearyFan extends TileAlvearyClimatiser {
|
||||
|
||||
@Override
|
||||
public float getBoundaryDown() {
|
||||
return 0.05f;
|
||||
return -1f;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -22,12 +22,12 @@ public class TileAlvearyHeater extends TileAlvearyClimatiser {
|
||||
|
||||
@Override
|
||||
public float getChangePerTransfer() {
|
||||
return 0.01f;
|
||||
return 0.015f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getBoundaryUp() {
|
||||
return 2.5f;
|
||||
return 3.5f;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -56,9 +56,9 @@ public class TileAlvearyHygroregulator extends TileAlveary
|
||||
this.tankManager = new TankManager(this, liquidTank);
|
||||
|
||||
this.recipes = new HygroregulatorRecipe[] {
|
||||
new HygroregulatorRecipe(new FluidStack(water, 1), 1, 0.01f, -0.005f),
|
||||
new HygroregulatorRecipe(new FluidStack(lava, 1), 10, -0.01f, +0.005f),
|
||||
new HygroregulatorRecipe(new FluidStack(liquidIce, 1), 10, 0.02f, -0.01f) };
|
||||
new HygroregulatorRecipe(new FluidStack(water, 1), 1, +0.01f, -0.0005f),
|
||||
new HygroregulatorRecipe(new FluidStack(lava, 1), 10, -0.01f, +0.0005f),
|
||||
new HygroregulatorRecipe(new FluidStack(liquidIce, 1), 10, +0.02f, -0.001f) };
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -109,7 +109,7 @@ public abstract class RecipeHandlerBase extends TemplateRecipeHandler implements
|
||||
public void loadUsageRecipes(FluidStack ingredient) {}
|
||||
|
||||
@Override
|
||||
public List<String> handleTooltip(GuiRecipe guiRecipe, List<String> currenttip, int recipe) {
|
||||
public List<String> handleTooltip(GuiRecipe<?> guiRecipe, List<String> currenttip, int recipe) {
|
||||
super.handleTooltip(guiRecipe, currenttip, recipe);
|
||||
CachedBaseRecipe crecipe = (CachedBaseRecipe) this.arecipes.get(recipe);
|
||||
if (GuiContainerManager.shouldShowTooltip(guiRecipe)) {
|
||||
@@ -125,7 +125,7 @@ public abstract class RecipeHandlerBase extends TemplateRecipeHandler implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> handleItemTooltip(GuiRecipe guiRecipe, ItemStack itemStack, List<String> currenttip,
|
||||
public List<String> handleItemTooltip(GuiRecipe<?> guiRecipe, ItemStack itemStack, List<String> currenttip,
|
||||
int recipe) {
|
||||
super.handleItemTooltip(guiRecipe, itemStack, currenttip, recipe);
|
||||
CachedBaseRecipe crecipe = (CachedBaseRecipe) this.arecipes.get(recipe);
|
||||
|
||||
@@ -231,10 +231,14 @@ public abstract class BlockUtil {
|
||||
|
||||
private static Class<? extends Block> BW_MetaGenerated_WerkstoffBlocksClass;
|
||||
private static Block BWBlocks;
|
||||
private static boolean bw = Loader.isModLoaded("bartworks");
|
||||
private static Class<? extends Block> GTBlockMachines_Class;
|
||||
private static Block GTBlockMachines;
|
||||
private static final boolean bw = Loader.isModLoaded("bartworks");
|
||||
private static final boolean gt = Loader.isModLoaded("gregtech");
|
||||
|
||||
static {
|
||||
if (bw) try {
|
||||
// noinspection unchecked
|
||||
BW_MetaGenerated_WerkstoffBlocksClass = (Class<? extends Block>) Class
|
||||
.forName("com.github.bartimaeusnek.bartworks.system.material.BW_MetaGenerated_WerkstoffBlocks");
|
||||
BWBlocks = (Block) Class.forName("com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader")
|
||||
@@ -242,6 +246,13 @@ public abstract class BlockUtil {
|
||||
} catch (ClassNotFoundException | NoSuchFieldException | IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (gt) try {
|
||||
// noinspection unchecked
|
||||
GTBlockMachines_Class = (Class<? extends Block>) Class.forName("gregtech.common.blocks.GT_Block_Machines");
|
||||
GTBlockMachines = (Block) Class.forName("gregtech.api.GregTech_API").getField("sBlockMachines").get(null);
|
||||
} catch (ClassNotFoundException | NoSuchFieldException | IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static ItemStack getItemStackFromBlockBelow(World world, int x, int y, int z,
|
||||
@@ -260,6 +271,10 @@ public abstract class BlockUtil {
|
||||
return new ItemStack(BWBlocks, 1, block.getDamageValue(world, x, y - depth, z));
|
||||
}
|
||||
|
||||
if (gt && GTBlockMachines_Class.isInstance(block)) {
|
||||
return new ItemStack(GTBlockMachines, 1, block.getDamageValue(world, x, y - depth, z));
|
||||
}
|
||||
|
||||
return new ItemStack(block, 1, world.getBlockMetadata(x, y - depth, z));
|
||||
}
|
||||
}
|
||||
@@ -60,6 +60,7 @@ import forestry.api.recipes.RecipeManagers;
|
||||
import forestry.api.storage.ICrateRegistry;
|
||||
import forestry.api.storage.StorageManager;
|
||||
import forestry.apiculture.ArmorApiaristHelper;
|
||||
import forestry.apiculture.EventHandlerApiculture;
|
||||
import forestry.apiculture.SaveEventHandlerApiculture;
|
||||
import forestry.apiculture.VillageHandlerApiculture;
|
||||
import forestry.apiculture.blocks.BlockAlveary;
|
||||
@@ -185,6 +186,7 @@ public class PluginApiculture extends ForestryPlugin {
|
||||
super.preInit();
|
||||
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
MinecraftForge.EVENT_BUS.register(new EventHandlerApiculture());
|
||||
|
||||
blocks.apiculture.addDefinitions(
|
||||
new MachineDefinition(BlockApicultureType.APIARY).setFaces(0, 1, 2, 2, 4, 4, 0, 7),
|
||||
|
||||
@@ -568,6 +568,13 @@ item.for.frameImpregnated.name=Impregnated Frame
|
||||
item.for.frameProven.name=Proven Frame
|
||||
item.for.frameUntreated.name=Untreated Frame
|
||||
|
||||
for.frame.tooltip.durability=Durability:
|
||||
for.frame.tooltip.territory=Territory:
|
||||
for.frame.tooltip.mutationRate=Mutation Rate:
|
||||
for.frame.tooltip.lifespan=Lifespan:
|
||||
for.frame.tooltip.production=Production:
|
||||
for.frame.tooltip.geneticDecay=Genetic Decay:
|
||||
|
||||
item.for.fruits.cherry.name=Cherry
|
||||
item.for.fruits.chestnut.name=Chestnut
|
||||
item.for.fruits.dates.name=Date
|
||||
|
||||
Reference in new issue
Block a user