Compare commits

..
8 Commits
Author SHA1 Message Date
miozune 10df035419 Fix BOP Turnip Seeds extracted into 0mB of Seed Oil (#39)
* Fix BOP Turnip Seeds extracted into 0mB of Seed Oil

* Use `GameRegistry#findItemStack`
2022-10-25 19:54:42 +02:00
Jakub 5f622686f3 Fix typo (#38) 2022-10-21 22:57:06 +02:00
Glease fce7efd59a fix potential memory leak (#36) 2022-10-19 08:50:23 +01:00
Jakub 6158afeb86 Add Jubiliance description (#35)
* Add Jubilance description

* Update GuiBeealyzer.java

* Translatable strings
2022-10-16 13:45:10 +02:00
Jakub e94f967c38 Move IAlleleBeeAcceleratableEffect from GT (#34) 2022-10-13 16:05:44 +02:00
Jason Mitchell 3ee9facc9b Let the people have their giant sequoia with slightly less tedium. (#32)
* Let the people have their giant sequoia with slightly less tedium.
2022-10-09 16:52:11 -07:00
Jakub 67026cf3cc Apply new bee production chance formula (#31)
* Apply new formula

* Update build.gradle

* Update

* Use function
2022-10-08 17:28:06 +02:00
Glease 47f33cb8ec forget invalid recipe entries (#30) 2022-10-05 17:57:58 +02:00
15 changed files with 251 additions and 60 deletions

No files matched your search

+133 -6
View File
@@ -1,4 +1,4 @@
//version: 1661114848
//version: 1664372158
/*
DO NOT CHANGE THIS FILE!
Also, you may replace this file at any time if there is an update available.
@@ -8,6 +8,10 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ConfigureShadowRelocation
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import com.matthewprenger.cursegradle.CurseArtifact
import com.matthewprenger.cursegradle.CurseRelation
import com.modrinth.minotaur.dependencies.ModDependency
import com.modrinth.minotaur.dependencies.VersionDependency
import org.gradle.internal.logging.text.StyledTextOutput.Style
import org.gradle.internal.logging.text.StyledTextOutputFactory
@@ -59,6 +63,8 @@ plugins {
id 'de.undercouch.download' version '5.0.1'
id 'com.github.gmazzo.buildconfig' version '3.0.3' apply false
id 'com.diffplug.spotless' version '6.7.2' apply false
id 'com.modrinth.minotaur' version '2.+' apply false
id 'com.matthewprenger.cursegradle' version '1.4.0' apply false
}
boolean settingsupdated = verifySettingsGradle()
settingsupdated = verifyGitAttributes() || settingsupdated
@@ -127,11 +133,16 @@ checkPropertyExists("containsMixinsAndOrCoreModOnly")
checkPropertyExists("usesShadowedDependencies")
checkPropertyExists("developmentEnvironmentUserName")
boolean noPublishedSources = project.hasProperty("noPublishedSources") ? project.noPublishedSources.toBoolean() : false
boolean usesMixinDebug = project.hasProperty('usesMixinDebug') ?: project.usesMixins.toBoolean()
boolean forceEnableMixins = project.hasProperty('forceEnableMixins') ? project.forceEnableMixins.toBoolean() : false
String channel = project.hasProperty('channel') ? project.channel : 'stable'
String mappingsVersion = project.hasProperty('mappingsVersion') ? project.mappingsVersion : '12'
propertyDefaultIfUnset("noPublishedSources", false)
propertyDefaultIfUnset("usesMixinDebug", project.usesMixins)
propertyDefaultIfUnset("forceEnableMixins", false)
propertyDefaultIfUnset("channel", "stable")
propertyDefaultIfUnset("mappingsVersion", "12")
propertyDefaultIfUnset("modrinthProjectId", "")
propertyDefaultIfUnset("modrinthRelations", "")
propertyDefaultIfUnset("curseForgeProjectId", "")
propertyDefaultIfUnset("curseForgeRelations", "")
String javaSourceDir = "src/main/java/"
String scalaSourceDir = "src/main/scala/"
String kotlinSourceDir = "src/main/kotlin/"
@@ -651,6 +662,107 @@ publishing {
}
}
if (modrinthProjectId.size() != 0) {
apply plugin: 'com.modrinth.minotaur'
File changelogFile = new File("CHANGELOG.md")
modrinth {
token = System.getenv("MODRINTH_TOKEN")
projectId = modrinthProjectId
versionNumber = identifiedVersion
versionType = identifiedVersion.endsWith("-pre") ? "beta" : "release"
changelog = changelogFile.exists() ? changelogFile.getText("UTF-8") : ""
uploadFile = jar
additionalFiles = getSecondaryArtifacts()
gameVersions = [minecraftVersion]
loaders = ["forge"]
debugMode = false
}
if (modrinthRelations.size() != 0) {
String[] deps = modrinthRelations.split(";")
deps.each { dep ->
if (dep.size() == 0) {
return
}
String[] parts = dep.split(":")
String[] qual = parts[0].split("-")
addModrinthDep(qual[0], qual[1], parts[1])
}
}
tasks.modrinth.dependsOn(build)
tasks.publish.dependsOn(tasks.modrinth)
}
if (curseForgeProjectId.size() != 0) {
apply plugin: 'com.matthewprenger.cursegradle'
File changelogFile = new File("CHANGELOG.md")
curseforge {
apiKey = System.getenv("CURSEFORGE_TOKEN")
project {
id = curseForgeProjectId
if (changelogFile.exists()) {
changelogType = "markdown"
changelog = changelogFile
}
releaseType = identifiedVersion.endsWith("-pre") ? "beta" : "release"
addGameVersion minecraftVersion
addGameVersion "Forge"
mainArtifact jar
for (artifact in getSecondaryArtifacts()) addArtifact artifact
}
options {
javaIntegration = false
forgeGradleIntegration = false
debug = false
}
}
if (curseForgeRelations.size() != 0) {
String[] deps = curseForgeRelations.split(";")
deps.each { dep ->
if (dep.size() == 0) {
return
}
String[] parts = dep.split(":")
addCurseForgeRelation(parts[0], parts[1])
}
}
tasks.curseforge.dependsOn(build)
tasks.publish.dependsOn(tasks.curseforge)
}
def addModrinthDep(scope, type, name) {
com.modrinth.minotaur.dependencies.Dependency dep;
if (!(scope in ["required", "optional", "incompatible", "embedded"])) {
throw new Exception("Invalid modrinth dependency scope: " + scope)
}
switch (type) {
case "project":
dep = new ModDependency(name, scope)
break
case "version":
dep = new VersionDependency(name, scope)
break
default:
throw new Exception("Invalid modrinth dependency type: " + type)
}
project.modrinth.dependencies.add(dep)
}
def addCurseForgeRelation(type, name) {
if (!(type in ["requiredDependency", "embeddedLibrary", "optionalDependency", "tool", "incompatible"])) {
throw new Exception("Invalid CurseForge relation type: " + type)
}
CurseArtifact artifact = project.curseforge.curseProjects[0].mainArtifact
CurseRelation rel = (artifact.curseRelations ?: (artifact.curseRelations = new CurseRelation()))
rel."$type"(name)
}
// Updating
task updateBuildScript {
doLast {
@@ -963,6 +1075,21 @@ def checkPropertyExists(String propertyName) {
}
}
def propertyDefaultIfUnset(String propertyName, defaultValue) {
if (!project.hasProperty(propertyName) || project.property(propertyName) == "") {
project.ext.setProperty(propertyName, defaultValue)
}
}
def getFile(String relativePath) {
return new File(projectDir, relativePath)
}
def getSecondaryArtifacts() {
// Because noPublishedSources from the beginning of the script is somehow not visible here...
boolean noPublishedSources = project.hasProperty("noPublishedSources") ? project.noPublishedSources.toBoolean() : false
def secondaryArtifacts = [devJar]
if (!noPublishedSources) secondaryArtifacts += [sourcesJar]
if (apiPackage) secondaryArtifacts += [apiJar]
return secondaryArtifacts
}
@@ -0,0 +1,8 @@
package forestry.api.apiculture;
import forestry.api.genetics.IEffectData;
@SuppressWarnings("unused")
public interface IAlleleBeeAcceleratableEffect {
IEffectData doEffectAccelerated(IBeeGenome genome, IEffectData storedData, IBeeHousing housing, float did);
}
@@ -29,6 +29,13 @@ public interface IAlleleBeeSpeciesCustom extends IAlleleBeeSpecies, IAlleleSpeci
*/
IAlleleBeeSpeciesCustom setJubilanceProvider(IJubilanceProvider provider);
/**
* Get the Jubilance Provider for this bee species.
*/
default IJubilanceProvider getJubilanceProvider() {
return null;
}
/**
* Make this species only active at night.
*/
@@ -12,4 +12,8 @@ public interface IJubilanceProvider {
* Jubilant bees can produce their Specialty products.
*/
boolean isJubilant(IAlleleBeeSpecies species, IBeeGenome genome, IBeeHousing housing);
default String getDescription() {
return null;
}
}
@@ -11,18 +11,7 @@
package forestry.apiculture.genetics;
import com.mojang.authlib.GameProfile;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.EnumBeeChromosome;
import forestry.api.apiculture.FlowerManager;
import forestry.api.apiculture.IAlleleBeeEffect;
import forestry.api.apiculture.IAlleleBeeSpecies;
import forestry.api.apiculture.IApiaristTracker;
import forestry.api.apiculture.IBee;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.apiculture.IBeeModifier;
import forestry.api.apiculture.IBeeMutation;
import forestry.api.apiculture.IBeekeepingMode;
import forestry.api.apiculture.*;
import forestry.api.core.BiomeHelper;
import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
@@ -426,12 +415,18 @@ public class Bee extends IndividualLiving implements IBee {
+ AlleleManager.climateHelper.toDisplay(genome.getPrimary().getHumidity()) + " / "
+ humidToleranceAllele.getName();
String flowers = genome.getFlowerProvider().getDescription();
String jubilance = null;
if (primary instanceof IAlleleBeeSpeciesCustom) {
IJubilanceProvider provider = ((IAlleleBeeSpeciesCustom) primary).getJubilanceProvider();
if (provider != null) jubilance = provider.getDescription();
}
list.add(lifespan);
list.add(speed);
list.add(tempTolerance);
list.add(humidTolerance);
list.add(flowers);
if (jubilance != null) list.add(StringUtil.localizeAndFormat("gui.jubilance", jubilance));
if (genome.getNocturnal()) {
list.add(EnumChatFormatting.RED + GenericRatings.rateActivityTime(genome.getNocturnal(), false));
@@ -514,19 +509,21 @@ public class Bee extends IndividualLiving implements IBee {
IBeeModifier beeModeModifier = mode.getBeeModifier();
// Bee genetic speed * beehousing * beekeeping mode
float speed = genome.getSpeed()
* beeHousingModifier.getProductionModifier(genome, 1f)
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()) {
if (housing.getWorld().rand.nextFloat() < entry.getValue() * speed) {
if (housing.getWorld().rand.nextFloat() < getFinalChance(entry.getValue(), speed, prodModifier, 1f)) {
products.add(entry.getKey().copy());
}
}
// / Secondary Products
for (Map.Entry<ItemStack, Float> entry : secondary.getProductChances().entrySet()) {
if (housing.getWorld().rand.nextFloat() < Math.round(entry.getValue() / 2) * speed) {
if (housing.getWorld().rand.nextFloat()
< getFinalChance(Math.round(entry.getValue() / 2), speed, prodModifier, 1f)) {
products.add(entry.getKey().copy());
}
}
@@ -535,7 +532,7 @@ public class Bee extends IndividualLiving implements IBee {
if (primary.isJubilant(genome, housing) && secondary.isJubilant(genome, housing)) {
for (Map.Entry<ItemStack, Float> entry :
primary.getSpecialtyChances().entrySet()) {
if (housing.getWorld().rand.nextFloat() < entry.getValue() * speed) {
if (housing.getWorld().rand.nextFloat() < getFinalChance(entry.getValue(), speed, prodModifier, 1f)) {
products.add(entry.getKey().copy());
}
}
@@ -553,6 +550,14 @@ public class Bee extends IndividualLiving implements IBee {
productsArray);
}
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);
}
/* REPRODUCTION */
@Override
public IBee spawnPrincess(IBeeHousing housing) {
@@ -16,6 +16,7 @@ import forestry.api.apiculture.IBeeHousing;
import forestry.api.apiculture.IJubilanceProvider;
import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
import forestry.core.utils.StringUtil;
public class JubilanceDefault implements IJubilanceProvider {
@@ -30,4 +31,9 @@ public class JubilanceDefault implements IJubilanceProvider {
return temperature == species.getTemperature() && humidity == species.getHumidity();
}
@Override
public String getDescription() {
return StringUtil.localize("jubilance.climate");
}
}
@@ -14,6 +14,7 @@ import forestry.api.apiculture.IAlleleBeeSpecies;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.apiculture.genetics.alleles.AlleleEffect;
import forestry.core.utils.StringUtil;
import java.util.List;
import net.minecraft.entity.EntityLiving;
@@ -26,4 +27,9 @@ public class JubilanceProviderHermit extends JubilanceDefault {
List<EntityLiving> list = AlleleEffect.getEntitiesInRange(genome, housing, EntityLiving.class);
return list.size() <= 0;
}
@Override
public String getDescription() {
return StringUtil.localize("jubilance.hermit");
}
}
@@ -16,12 +16,12 @@ import forestry.api.apiculture.IBeeHousing;
import forestry.api.apiculture.IJubilanceProvider;
import forestry.core.utils.BlockUtil;
import forestry.core.utils.InventoryUtil;
import forestry.core.utils.StringUtil;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.world.World;
// import forestry.core.utils.ItemStackUtil;
public class JubilanceRequiresResource implements IJubilanceProvider {
@@ -35,20 +35,6 @@ public class JubilanceRequiresResource implements IJubilanceProvider {
public boolean isJubilant(IAlleleBeeSpecies species, IBeeGenome genome, IBeeHousing housing) {
World world = housing.getWorld();
ChunkCoordinates housingCoords = housing.getCoordinates();
/*
Block block;
TileEntity tile;
int meta;
int i = 1;
do {
block = world.getBlock(housingCoords.posX, housingCoords.posY - i, housingCoords.posZ);
meta = world.getBlockMetadata(housingCoords.posX, housingCoords.posY - i, housingCoords.posZ);
tile = world.getTileEntity(housingCoords.posX, housingCoords.posY - i, housingCoords.posZ);
i++;
} while (tile instanceof IBeeHousing);
return ItemStackUtil.equals(block, meta, blockRequired);
*/
ItemStack stk = BlockUtil.getItemStackFromBlockBelow(
world,
housingCoords.posX,
@@ -56,11 +42,11 @@ public class JubilanceRequiresResource implements IJubilanceProvider {
housingCoords.posZ,
(TileEntity tile) -> (tile instanceof IBeeHousing));
return InventoryUtil.isItemEqual(
blockRequired,
stk,
true,
true); // ffs dont compare itemsstacks with equal >_> and why tf didnt i got this until i debugged it?
// im getting old..
return InventoryUtil.isItemEqual(blockRequired, stk, true, true);
}
@Override
public String getDescription() {
return StringUtil.localizeAndFormat("jubilance.resource", blockRequired.getDisplayName());
}
}
@@ -100,6 +100,11 @@ public class AlleleBeeSpecies extends AlleleSpecies implements IAlleleBeeSpecies
return this;
}
@Override
public IJubilanceProvider getJubilanceProvider() {
return this.jubilanceProvider;
}
@Override
public IAlleleBeeSpeciesCustom setNocturnal() {
nocturnal = true;
@@ -10,11 +10,7 @@
******************************************************************************/
package forestry.apiculture.gui;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.EnumBeeChromosome;
import forestry.api.apiculture.EnumBeeType;
import forestry.api.apiculture.IAlleleBeeSpecies;
import forestry.api.apiculture.IBee;
import forestry.api.apiculture.*;
import forestry.api.genetics.AlleleManager;
import forestry.api.genetics.IAlleleInteger;
import forestry.api.genetics.IAlleleTolerance;
@@ -298,6 +294,17 @@ public class GuiBeealyzer extends GuiAlyzer {
}
}
String jubilance = null;
IAlleleBeeSpecies primary = bee.getGenome().getPrimary();
if (primary instanceof IAlleleBeeSpeciesCustom) {
IJubilanceProvider provider = ((IAlleleBeeSpeciesCustom) primary).getJubilanceProvider();
if (provider != null) jubilance = provider.getDescription();
}
textLayout.newLine();
textLayout.newLine();
if (jubilance != null) textLayout.drawLine(StringUtil.localizeAndFormat("gui.jubilance", jubilance), COLUMN_0);
textLayout.endPage();
}
}
@@ -83,7 +83,6 @@ import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraft.world.gen.feature.WorldGenerator;
import net.minecraftforge.common.BiomeDictionary;
import net.minecraftforge.common.util.ForgeDirection;
public enum TreeDefinition implements ITreeDefinition, ITreeGenerator {
@@ -566,7 +565,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator {
@Override
protected void registerMutations() {
registerMutation(Sequioa, Baobab, 1).requireNight().restrictBiomeType(BiomeDictionary.Type.FOREST);
registerMutation(Sequioa, Baobab, 1);
}
},
Jungle(
@@ -20,6 +20,7 @@ import forestry.api.genetics.IMutation;
import forestry.api.genetics.ISpeciesRoot;
import forestry.core.network.packets.PacketGenomeTrackerSync;
import forestry.core.proxy.Proxies;
import java.lang.ref.WeakReference;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
@@ -57,7 +58,7 @@ public abstract class BreedingTracker extends WorldSavedData implements IBreedin
private GameProfile username;
@Nullable
private World world;
private WeakReference<World> world;
protected BreedingTracker(String s) {
super(s);
@@ -68,7 +69,7 @@ public abstract class BreedingTracker extends WorldSavedData implements IBreedin
}
public void setWorld(@Nullable World world) {
this.world = world;
this.world = new WeakReference<>(world);
}
@Override
@@ -113,6 +114,7 @@ public abstract class BreedingTracker extends WorldSavedData implements IBreedin
Collection<String> discoveredSpecies,
Collection<String> discoveredMutations,
Collection<String> researchedMutations) {
World world = this.world != null ? this.world.get() : null;
if (world != null && username != null && username.getName() != null) {
EntityPlayer player = world.getPlayerEntityByName(username.getName());
if (player instanceof EntityPlayerMP && !(player instanceof FakePlayer)) {
@@ -14,6 +14,7 @@ import forestry.api.core.INBTTagable;
import forestry.core.network.DataInputStreamForestry;
import forestry.core.network.DataOutputStreamForestry;
import forestry.core.network.IStreamable;
import forestry.core.utils.Log;
import java.io.IOException;
import java.util.ArrayList;
import java.util.LinkedList;
@@ -24,6 +25,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.world.World;
import org.apache.logging.log4j.Level;
public class RecipeMemory implements INBTTagable, IStreamable {
@@ -54,8 +56,22 @@ public class RecipeMemory implements INBTTagable, IStreamable {
LinkedList<MemorizedRecipe> validRecipes = new LinkedList<>();
for (MemorizedRecipe recipe : memorizedRecipes) {
if (recipe != null) {
recipe.calculateRecipeOutput(world);
if (isValid(recipe)) {
boolean doAdd = false;
try {
recipe.calculateRecipeOutput(world);
if (isValid(recipe)) {
doAdd = true;
}
} catch (Exception ex) {
Log.logThrowable(
Level.ERROR,
"Error validating memorized recipe. This recipe will now be forgotten!",
Integer.MAX_VALUE,
ex);
}
if (doAdd) {
validRecipes.add(recipe);
}
}
@@ -126,10 +126,6 @@ public class PluginBiomesOPlenty extends ForestryPlugin {
Farmables.farmables
.get(FarmableReference.Vegetables.get())
.add(new FarmableGenericCrop(boPTurnipSeedStack, boPTurnip, 7));
if (PluginManager.Module.FACTORY.isEnabled()) {
RecipeManagers.squeezerManager.addRecipe(
10, new ItemStack[] {boPTurnipSeedStack}, Fluids.SEEDOIL.getFluid(amount));
}
}
Farmables.farmables.get(FarmableReference.Orchard.get()).add(new FarmableBasicFruit(boPTurnip, 7));
@@ -171,6 +167,14 @@ public class PluginBiomesOPlenty extends ForestryPlugin {
RecipeManagers.squeezerManager.addRecipe(
10, new ItemStack[] {persimmon}, Fluids.JUICE.getFluid(200), mulch, 20);
}
ItemStack boPTurnipSeedStack = GameRegistry.findItemStack(BoP, "turnipSeeds", 1);
if (boPTurnipSeedStack != null) {
if (PluginManager.Module.FACTORY.isEnabled()) {
RecipeManagers.squeezerManager.addRecipe(
10, new ItemStack[] {boPTurnipSeedStack}, Fluids.SEEDOIL.getFluid(amount));
}
}
}
private static void addFlowers() {
@@ -172,6 +172,7 @@ for.gui.inactive=Inactive
for.gui.life=Life
for.gui.lifespan=Lifespan
for.gui.normal=Normal
for.gui.jubilance=Jubilance: %s
for.gui.escritoire.probe=Examine Specimens
for.gui.escritoire.instructions=Place a genetic sample in the center to begin. Place more in the left slots and examine them for help.
@@ -355,7 +356,7 @@ for.hints.beebreeding.desc=Crossbreeding drones and princesses of different spec
for.hints.beebreeding.tag=Breed your bees!
for.hints.beeflowers.desc=Any bee will need some type of flower in the vicinity. Some rather mundane flowers, others very exotic ones.
for.hints.beeflowers.tag=Bees need flowers
for.hints.beejubilance.desc=Only jubilant bees will produce their specialty. Make sure to have them in their preferred climate.
for.hints.beejubilance.desc=Only jubilant bees will produce their specialty. Make sure to check jubilance requirements in the bee scan.
for.hints.beejubilance.tag=Make your bee happy!
for.hints.cooldownloss.desc=Engines going into forced cooldown will also lose a significant chunk of their stored energy.
for.hints.cooldownloss.tag=Cooldown means energy loss!
@@ -759,6 +760,14 @@ neiintegration.handler.forestry.shaped=Forestry Shaped
neiintegration.handler.forestry.shapeless=Forestry Shapeless
neiintegration.handler.forestry.fabricator.worth=Worth:
################
# JUBILANCE
################
for.jubilance.climate=Needs preferred climate
for.jubilance.hermit=Will not produce if there are any other living creatures nearby
for.jubilance.resource=Requires %s as foundation
################
# ERRORS
################