Compare commits

...
8 Commits
Author SHA1 Message Date
初夏同学 00a507f6e1 Fix a bug when NBTString does not exist. 2023-06-30 23:50:16 +08:00
Runakai1GitHub GTNH Actionsgithub-actions[bot]
99ebd8efe0 Fix Alveary Simulation of Temperatures (#52)
* Fix Alveary Simulation of Temperatures

* Spottless

* spotlessApply (#53)

Co-authored-by: GitHub GTNH Actions <>

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2023-06-18 14:56:09 +02:00
Dane Strandboge 29df6ceb1b Auto-apply stats tooltips to all IHiveFrame items (#51)
* Auto-apply stats tooltips to all IHiveFrame items

* allow generated tooltip to be overridden

* link event in api, update production tooltip
2023-04-28 18:54:35 +02:00
AlastorsandJason Mitchell 39c822df8a Fixes the incompatability with the newest NEI
Thanks Mitchbama

Co-Authored-By: Jason Mitchell <[email protected]>
2023-04-26 17:49:04 -07:00
Jakub 9e9ae6bcad Support GT_Block_Machines in mutation requirements (#48) 2023-04-07 17:50:43 +02:00
Jakub 661a5598ea New bees formula (#45)
* New formula

* Make production modifier globally additive
2023-03-29 17:26:15 +02:00
Jakub d96669f5f7 Add a way to simulate night (#46)
* Add a way to simulate night

* Add default value to avoid crashes

* Delighted -> Unlighted
2023-03-27 21:01:10 +02:00
Quetz4l ca9ebbc0ed add setting to config-> disable butterflies spawn (#44)
* bs

* add setting to config-> disable butterflies spawn
+ default disable is false

* changed name DISABLE_BUTTERFLY to disableButterfly

* changed Boolean to boolean
(for disableButterfly)
2023-03-20 21:48:43 +01:00
21 changed files with 504 additions and 49 deletions

No files matched your search

+291 -19
View File
@@ -1,4 +1,4 @@
//version: 1675110695
//version: 1678003329
/*
DO NOT CHANGE THIS FILE!
Also, you may replace this file at any time if there is an update available.
@@ -9,13 +9,18 @@
import com.diffplug.blowdryer.Blowdryer
import com.github.jengelman.gradle.plugins.shadow.tasks.ConfigureShadowRelocation
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import com.gtnewhorizons.retrofuturagradle.ObfuscationAttribute
import com.gtnewhorizons.retrofuturagradle.mcp.ReobfuscatedJar
import com.gtnewhorizons.retrofuturagradle.minecraft.RunMinecraftTask
import com.matthewprenger.cursegradle.CurseArtifact
import com.matthewprenger.cursegradle.CurseRelation
import com.modrinth.minotaur.dependencies.ModDependency
import com.modrinth.minotaur.dependencies.VersionDependency
import cpw.mods.fml.relauncher.Side
import org.gradle.api.tasks.options.Option;
import org.gradle.internal.logging.text.StyledTextOutput.Style
import org.gradle.internal.logging.text.StyledTextOutputFactory
import org.gradle.internal.xml.XmlTransformer
import org.jetbrains.gradle.ext.*
import java.nio.file.Files
@@ -23,10 +28,10 @@ import java.nio.file.Paths
import java.util.concurrent.TimeUnit
import java.util.zip.ZipEntry
import java.util.zip.ZipOutputStream
import javax.inject.Inject
buildscript {
repositories {
mavenLocal()
mavenCentral()
maven {
@@ -47,6 +52,8 @@ buildscript {
name 'Scala CI dependencies'
url 'https://repo1.maven.org/maven2/'
}
mavenLocal()
}
}
plugins {
@@ -66,7 +73,7 @@ plugins {
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
id 'com.gtnewhorizons.retrofuturagradle' version '1.1.2'
id 'com.gtnewhorizons.retrofuturagradle' version '1.2.3'
}
boolean settingsupdated = verifySettingsGradle()
settingsupdated = verifyGitAttributes() || settingsupdated
@@ -122,6 +129,9 @@ propertyDefaultIfUnset("gradleTokenGroupName", "")
propertyDefaultIfUnset("enableModernJavaSyntax", false) // On by default for new projects only
propertyDefaultIfUnset("enableGenericInjection", false) // On by default for new projects only
// this is meant to be set using the user wide property file. by default we do nothing.
propertyDefaultIfUnset("ideaOverrideBuildType", "") // Can be nothing, "gradle" or "idea"
project.extensions.add(Blowdryer, "Blowdryer", Blowdryer) // Make blowdryer available in "apply from:" scripts
if (!disableSpotless) {
apply plugin: 'com.diffplug.spotless'
@@ -143,7 +153,7 @@ java {
} else {
languageVersion.set(projectJavaVersion)
}
vendor.set(JvmVendorSpec.ADOPTIUM)
vendor.set(JvmVendorSpec.AZUL)
}
if (!noPublishedSources) {
withSourcesJar()
@@ -186,11 +196,21 @@ configurations {
}
if (enableModernJavaSyntax.toBoolean()) {
repositories {
mavenCentral {
mavenContent {
includeGroup("me.eigenraven.java8unsupported")
}
}
}
dependencies {
annotationProcessor 'com.github.bsideup.jabel:jabel-javac-plugin:1.0.0'
compileOnly('com.github.bsideup.jabel:jabel-javac-plugin:1.0.0') {
transitive = false // We only care about the 1 annotation class
}
// Allow using jdk.unsupported classes like sun.misc.Unsafe in the compiled code, working around JDK-8206937.
patchedMinecraft('me.eigenraven.java8unsupported:java-8-unsupported-shim:1.0.0')
}
tasks.withType(JavaCompile).configureEach {
@@ -202,7 +222,7 @@ if (enableModernJavaSyntax.toBoolean()) {
javaCompiler.set(javaToolchains.compilerFor {
languageVersion.set(JavaLanguageVersion.of(17))
vendor.set(JvmVendorSpec.ADOPTIUM)
vendor.set(JvmVendorSpec.AZUL)
})
}
}
@@ -234,12 +254,14 @@ if (apiPackage) {
}
if (accessTransformersFile) {
String targetFile = "src/main/resources/META-INF/" + accessTransformersFile
if (!getFile(targetFile).exists()) {
throw new GradleException("Could not resolve \"accessTransformersFile\"! Could not find " + targetFile)
for (atFile in accessTransformersFile.split(",")) {
String targetFile = "src/main/resources/META-INF/" + atFile.trim()
if (!getFile(targetFile).exists()) {
throw new GradleException("Could not resolve \"accessTransformersFile\"! Could not find " + targetFile)
}
tasks.deobfuscateMergedJarToSrg.accessTransformerFiles.from(targetFile)
tasks.srgifyBinpatchedJar.accessTransformerFiles.from(targetFile)
}
tasks.deobfuscateMergedJarToSrg.accessTransformerFiles.from(targetFile)
tasks.srgifyBinpatchedJar.accessTransformerFiles.from(targetFile)
} else {
boolean atsFound = false
for (File at : sourceSets.getByName("main").resources.files) {
@@ -367,6 +389,10 @@ minecraft {
injectMissingGenerics.set(true)
}
username = developmentEnvironmentUserName.toString()
lwjgl3Version = "3.3.2-SNAPSHOT"
// Enable assertions in the current mod
extraRunJvmArguments.add("-ea:${modGroup}")
@@ -401,6 +427,16 @@ configurations.configureEach {
}
}
}
def obfuscationAttr = it.attributes.getAttribute(ObfuscationAttribute.OBFUSCATION_ATTRIBUTE)
if (obfuscationAttr != null && obfuscationAttr.name == ObfuscationAttribute.SRG) {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
// Remap CoFH core cursemaven dev jar to the obfuscated version for runObfClient/Server
if (details.requested.group == 'curse.maven' && details.requested.name.endsWith('-69162') && details.requested.version == '2388751') {
details.useVersion '2388750'
details.because 'Pick obfuscated jar'
}
}
}
}
// Ensure tests have access to minecraft classes
@@ -430,8 +466,9 @@ repositories.configureEach { repo ->
apply from: 'repositories.gradle'
configurations {
runtimeClasspath.extendsFrom(runtimeOnlyNonPublishable)
testRuntimeClasspath.extendsFrom(runtimeOnlyNonPublishable)
for (config in [compileClasspath, runtimeClasspath, testCompileClasspath, testRuntimeClasspath]) {
config.extendsFrom(runtimeOnlyNonPublishable)
if (usesShadowedDependencies.toBoolean()) {
config.extendsFrom(shadowImplementation)
// TODO: remove Compile after all uses are refactored to Implementation
@@ -484,6 +521,13 @@ repositories {
}
}
}
maven {
name 'sonatype'
url 'https://oss.sonatype.org/content/repositories/snapshots/'
content {
includeGroup "org.lwjgl"
}
}
if (includeWellKnownRepositories.toBoolean()) {
maven {
name "CurseMaven"
@@ -520,20 +564,20 @@ dependencies {
annotationProcessor('org.ow2.asm:asm-debug-all:5.0.3')
annotationProcessor('com.google.guava:guava:24.1.1-jre')
annotationProcessor('com.google.code.gson:gson:2.8.6')
annotationProcessor('com.gtnewhorizon:gtnhmixins:2.1.10:processor')
annotationProcessor('com.gtnewhorizon:gtnhmixins:2.1.13:processor')
if (usesMixinDebug.toBoolean()) {
runtimeOnlyNonPublishable('org.jetbrains:intellij-fernflower:1.2.1.16')
}
}
if (usesMixins.toBoolean() || forceEnableMixins.toBoolean()) {
implementation('com.gtnewhorizon:gtnhmixins:2.1.10')
implementation('com.gtnewhorizon:gtnhmixins:2.1.13')
}
}
pluginManager.withPlugin('org.jetbrains.kotlin.kapt') {
if (usesMixins.toBoolean()) {
dependencies {
kapt('com.gtnewhorizon:gtnhmixins:2.1.10:processor')
kapt('com.gtnewhorizon:gtnhmixins:2.1.13:processor')
}
}
}
@@ -633,9 +677,150 @@ tasks.named("processResources", ProcessResources).configure {
if (usesMixins.toBoolean()) {
from refMap
dependsOn("compileJava", "compileScala")
}
}
ext.java17Toolchain = (JavaToolchainSpec spec) -> {
spec.languageVersion.set(JavaLanguageVersion.of(17))
spec.vendor.set(JvmVendorSpec.matching("jetbrains"))
}
ext.java17DependenciesCfg = configurations.create("java17Dependencies") {
extendsFrom(configurations.getByName("runtimeClasspath")) // Ensure consistent transitive dependency resolution
canBeConsumed = false
}
ext.java17PatchDependenciesCfg = configurations.create("java17PatchDependencies") {
canBeConsumed = false
}
dependencies {
def lwjgl3ifyVersion = '1.1.35'
def asmVersion = '9.4'
if (modId != 'lwjgl3ify') {
java17Dependencies("com.github.GTNewHorizons:lwjgl3ify:${lwjgl3ifyVersion}")
}
if (modId != 'hodgepodge') {
java17Dependencies('com.github.GTNewHorizons:Hodgepodge:2.0.40')
}
java17PatchDependencies('net.minecraft:launchwrapper:1.15') {transitive = false}
java17PatchDependencies("org.ow2.asm:asm:${asmVersion}")
java17PatchDependencies("org.ow2.asm:asm-commons:${asmVersion}")
java17PatchDependencies("org.ow2.asm:asm-tree:${asmVersion}")
java17PatchDependencies("org.ow2.asm:asm-analysis:${asmVersion}")
java17PatchDependencies("org.ow2.asm:asm-util:${asmVersion}")
java17PatchDependencies('org.ow2.asm:asm-deprecated:7.1')
java17PatchDependencies("org.apache.commons:commons-lang3:3.12.0")
java17PatchDependencies("com.github.GTNewHorizons:lwjgl3ify:${lwjgl3ifyVersion}:forgePatches") {transitive = false}
}
ext.java17JvmArgs = [
// Java 9+ support
"--illegal-access=warn",
"-Djava.security.manager=allow",
"-Dfile.encoding=UTF-8",
"--add-opens", "java.base/jdk.internal.loader=ALL-UNNAMED",
"--add-opens", "java.base/java.net=ALL-UNNAMED",
"--add-opens", "java.base/java.nio=ALL-UNNAMED",
"--add-opens", "java.base/java.io=ALL-UNNAMED",
"--add-opens", "java.base/java.lang=ALL-UNNAMED",
"--add-opens", "java.base/java.lang.reflect=ALL-UNNAMED",
"--add-opens", "java.base/java.text=ALL-UNNAMED",
"--add-opens", "java.base/java.util=ALL-UNNAMED",
"--add-opens", "java.base/jdk.internal.reflect=ALL-UNNAMED",
"--add-opens", "java.base/sun.nio.ch=ALL-UNNAMED",
"--add-opens", "jdk.naming.dns/com.sun.jndi.dns=ALL-UNNAMED,java.naming",
"--add-opens", "java.desktop/sun.awt.image=ALL-UNNAMED",
"--add-modules", "jdk.dynalink",
"--add-opens", "jdk.dynalink/jdk.dynalink.beans=ALL-UNNAMED",
"--add-modules", "java.sql.rowset",
"--add-opens", "java.sql.rowset/javax.sql.rowset.serial=ALL-UNNAMED"
]
ext.hotswapJvmArgs = [
// DCEVM advanced hot reload
"-XX:+AllowEnhancedClassRedefinition",
"-XX:HotswapAgent=fatjar"
]
ext.setupHotswapAgentTask = tasks.register("setupHotswapAgent") {
group = "GTNH Buildscript"
description = "Installs a recent version of HotSwapAgent into the Java 17 JetBrains runtime directory"
def hsaUrl = 'https://github.com/HotswapProjects/HotswapAgent/releases/download/1.4.2-SNAPSHOT/hotswap-agent-1.4.2-SNAPSHOT.jar'
def targetFolderProvider = javaToolchains.launcherFor(java17Toolchain).map {it.metadata.installationPath.dir("lib/hotswap")}
def targetFilename = "hotswap-agent.jar"
onlyIf {
!targetFolderProvider.get().file(targetFilename).asFile.exists()
}
doLast {
def targetFolder = targetFolderProvider.get()
targetFolder.asFile.mkdirs()
download.run {
src hsaUrl
dest targetFolder.file(targetFilename).asFile
overwrite false
tempAndMove true
}
}
}
public abstract class RunHotswappableMinecraftTask extends RunMinecraftTask {
// IntelliJ doesn't seem to allow commandline arguments so we also support an env variable
private boolean enableHotswap = Boolean.valueOf(System.getenv("HOTSWAP"));
@Input
public boolean getEnableHotswap() { return enableHotswap }
@Option(option = "hotswap", description = "Enables HotSwapAgent for enhanced class reloading under a debugger")
public boolean setEnableHotswap(boolean enable) { enableHotswap = enable }
@Inject
public RunHotswappableMinecraftTask(Side side, String superTask, org.gradle.api.invocation.Gradle gradle) {
super(side, gradle)
this.lwjglVersion = 3
this.javaLauncher = project.javaToolchains.launcherFor(project.java17Toolchain)
this.extraJvmArgs.addAll(project.java17JvmArgs)
this.extraJvmArgs.addAll(project.provider(() -> enableHotswap ? project.hotswapJvmArgs : []))
this.classpath(project.java17PatchDependenciesCfg)
if (side == Side.CLIENT) {
this.classpath(project.minecraftTasks.lwjgl3Configuration)
}
// Use a raw provider instead of map to not create a dependency on the task
this.classpath(project.provider(() -> project.tasks.named(superTask, RunMinecraftTask).get().classpath))
this.classpath.filter { file ->
!file.path.contains("2.9.4-nightly-20150209") // Remove lwjgl2
}
this.classpath(project.java17DependenciesCfg)
if (!(project.usesMixins.toBoolean() || project.forceEnableMixins.toBoolean())) {
this.extraArgs.addAll("--tweakClass", "org.spongepowered.asm.launch.MixinTweaker")
}
}
}
def runClient17Task = tasks.register("runClient17", RunHotswappableMinecraftTask, Side.CLIENT, "runClient")
runClient17Task.configure {
setup(project)
group = "Modded Minecraft"
description = "Runs the modded client using Java 17, lwjgl3ify and Hodgepodge"
dependsOn(setupHotswapAgentTask, mcpTasks.launcherSources.classesTaskName, minecraftTasks.taskDownloadVanillaAssets, mcpTasks.taskPackagePatchedMc, 'jar')
mainClass = "GradleStart"
username = minecraft.username
userUUID = minecraft.userUUID
}
def runServer17Task = tasks.register("runServer17", RunHotswappableMinecraftTask, Side.SERVER, "runServer")
runServer17Task.configure {
setup(project)
group = "Modded Minecraft"
description = "Runs the modded server using Java 17, lwjgl3ify and Hodgepodge"
dependsOn(setupHotswapAgentTask, mcpTasks.launcherSources.classesTaskName, minecraftTasks.taskDownloadVanillaAssets, mcpTasks.taskPackagePatchedMc, 'jar')
mainClass = "GradleStartServer"
extraArgs.add("nogui")
}
def getManifestAttributes() {
def manifestAttributes = [:]
if (!containsMixinsAndOrCoreModOnly.toBoolean() && (usesMixins.toBoolean() || coreModClass)) {
@@ -670,7 +855,7 @@ if (usesShadowedDependencies.toBoolean()) {
tasks.register('relocateShadowJar', ConfigureShadowRelocation) {
target = tasks.shadowJar
prefix = modGroup + ".shadow"
enabled = minimizeShadowedDependencies.toBoolean()
enabled = relocateShadowedDependencies.toBoolean()
}
tasks.named("shadowJar", ShadowJar).configure {
manifest {
@@ -686,7 +871,7 @@ if (usesShadowedDependencies.toBoolean()) {
project.configurations.shadeCompile
]
archiveClassifier.set('dev')
if (minimizeShadowedDependencies.toBoolean()) {
if (relocateShadowedDependencies.toBoolean()) {
dependsOn(relocateShadowJar)
}
}
@@ -705,7 +890,7 @@ if (usesShadowedDependencies.toBoolean()) {
javaComponent.withVariantsFromConfiguration(configurations.shadowRuntimeElements) {
skip()
}
for (runTask in ["runClient", "runServer"]) {
for (runTask in ["runClient", "runServer", "runClient17", "runServer17"]) {
tasks.named(runTask).configure {
dependsOn("shadowJar")
}
@@ -743,9 +928,23 @@ idea {
module {
downloadJavadoc = true
downloadSources = true
inheritOutputDirs = true
}
project {
settings {
if (ideaOverrideBuildType != "") {
delegateActions {
if ("gradle".equalsIgnoreCase(ideaOverrideBuildType)) {
delegateBuildRunToGradle = true
testRunner = org.jetbrains.gradle.ext.ActionDelegationConfig.TestRunner.GRADLE
} else if ("idea".equalsIgnoreCase(ideaOverrideBuildType)) {
delegateBuildRunToGradle = false
testRunner = org.jetbrains.gradle.ext.ActionDelegationConfig.TestRunner.PLATFORM
} else {
throw GradleScriptException('Accepted value for ideaOverrideBuildType is one of gradle or idea.')
}
}
}
runConfigurations {
"1. Run Client"(Gradle) {
taskNames = ["runClient"]
@@ -753,6 +952,20 @@ idea {
"2. Run Server"(Gradle) {
taskNames = ["runServer"]
}
"1a. Run Client (Java 17)"(Gradle) {
taskNames = ["runClient17"]
}
"2a. Run Server (Java 17)"(Gradle) {
taskNames = ["runServer17"]
}
"1b. Run Client (Java 17, Hotswap)"(Gradle) {
taskNames = ["runClient17"]
envs = ["HOTSWAP": "true"]
}
"2b. Run Server (Java 17, Hotswap)"(Gradle) {
taskNames = ["runServer17"]
envs = ["HOTSWAP": "true"]
}
"3. Run Obfuscated Client"(Gradle) {
taskNames = ["runObfClient"]
}
@@ -770,7 +983,7 @@ idea {
}
"Run Client (IJ Native)"(Application) {
mainClass = "GradleStart"
moduleName = project.name + ".main"
moduleName = project.name + ".ideVirtualMain"
afterEvaluate {
workingDirectory = tasks.runClient.workingDir.absolutePath
programParameters = tasks.runClient.calculateArgs(project).collect { '"' + it + '"' }.join(' ')
@@ -781,7 +994,7 @@ idea {
}
"Run Server (IJ Native)"(Application) {
mainClass = "GradleStartServer"
moduleName = project.name + ".main"
moduleName = project.name + ".ideVirtualMain"
afterEvaluate {
workingDirectory = tasks.runServer.workingDir.absolutePath
programParameters = tasks.runServer.calculateArgs(project).collect { '"' + it + '"' }.join(' ')
@@ -798,6 +1011,51 @@ idea {
]
}
}
withIDEADir { File ideaDir ->
if (!ideaDir.path.contains(".idea")) {
// If an .ipr file exists, the project root directory is passed here instead of the .idea subdirectory
ideaDir = new File(ideaDir, ".idea")
}
if (ideaDir.isDirectory()) {
def miscFile = new File(ideaDir, "misc.xml")
if (miscFile.isFile()) {
boolean dirty = false
def miscTransformer = new XmlTransformer()
miscTransformer.addAction { root ->
Node rootNode = root.asNode()
def rootManager = rootNode
.component.find { it.@name == 'ProjectRootManager' }
if (!rootManager) {
rootManager = rootNode.appendNode('component', ['name': 'ProjectRootManager', 'version': '2'])
dirty = true
}
def output = rootManager.output
if (!output) {
output = rootManager.appendNode('output')
dirty = true
}
if (!output.@url) {
// Only modify the output url if it doesn't yet have one, or if the existing one is blank somehow.
// This is a sensible default for most setups
output.@url = 'file://$PROJECT_DIR$/build/ideaBuild'
dirty = true
}
}
def result = miscTransformer.transform(miscFile.text)
if (dirty) {
miscFile.write(result)
}
} else {
miscFile.text = """<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2">
<output url="file://\$PROJECT_DIR\$/out" />
</component>
</project>
"""
}
}
}
}
}
}
@@ -945,10 +1203,21 @@ def addCurseForgeRelation(String type, String name) {
}
// Updating
def buildscriptGradleVersion = "8.0.1"
tasks.named('wrapper', Wrapper).configure {
gradleVersion = buildscriptGradleVersion
}
tasks.register('updateBuildScript') {
group = 'GTNH Buildscript'
description = 'Updates the build script to the latest version'
if (gradle.gradleVersion != buildscriptGradleVersion && !Boolean.getBoolean('DISABLE_BUILDSCRIPT_GRADLE_UPDATE')) {
dependsOn('wrapper')
}
doLast {
if (performBuildScriptUpdate()) return
@@ -961,6 +1230,9 @@ if (!project.getGradle().startParameter.isOffline() && !Boolean.getBoolean('DISA
performBuildScriptUpdate()
} else {
out.style(Style.SuccessHeader).println("Build script update available! Run 'gradle updateBuildScript'")
if (gradle.gradleVersion != buildscriptGradleVersion) {
out.style(Style.SuccessHeader).println("updateBuildScript can update gradle from ${gradle.gradleVersion} to ${buildscriptGradleVersion}\n")
}
}
}
+1 -1
View File
@@ -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')
@@ -43,6 +43,10 @@ public class DefaultBeeModifier implements IBeeModifier {
return false;
}
public boolean isSelfUnlighted() {
return false;
}
public boolean isSunlightSimulated() {
return false;
}
@@ -54,10 +54,17 @@ public interface IBeeModifier {
boolean isSealed();
/**
* @return Boolean indicating if housing can ignore darkness/night
* @return Boolean indicating if housing can ignore darkness/night. Cannot be used together with SelfUnlighted
*/
boolean isSelfLighted();
/**
* @return Boolean indicating if housing can ignore lightness/day. Cannot be used together with SelfLighted
*/
default boolean isSelfUnlighted() {
return false;
}
/**
* @return Boolean indicating if housing can ignore not seeing the sky
*/
@@ -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;
}
@@ -94,6 +94,16 @@ public class BeeHousingModifier implements IBeeModifier {
return false;
}
@Override
public boolean isSelfUnlighted() {
for (IBeeModifier modifier : beeHousing.getBeeModifiers()) {
if (modifier.isSelfUnlighted()) {
return true;
}
}
return false;
}
@Override
public boolean isSunlightSimulated() {
for (IBeeModifier modifier : beeHousing.getBeeModifiers()) {
@@ -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);
}
}
@@ -248,7 +248,7 @@ public class Bee extends IndividualLiving implements IBee {
// / Night or darkness requires nocturnal species
if (world.isDaytime()) {
if (!canWorkDuringDay()) {
if (!canWorkDuringDay(beeModifier)) {
errorStates.add(EnumErrorCode.NOT_NIGHT);
}
} else {
@@ -258,7 +258,7 @@ public class Bee extends IndividualLiving implements IBee {
}
if (housing.getBlockLightValue() > Constants.APIARY_MIN_LEVEL_LIGHT) {
if (!canWorkDuringDay()) {
if (!canWorkDuringDay(beeModifier)) {
errorStates.add(EnumErrorCode.NOT_GLOOMY);
}
} else {
@@ -308,12 +308,16 @@ public class Bee extends IndividualLiving implements IBee {
return errorStates;
}
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
private boolean canWorkAtNight(IBeeModifier beeModifier) {
return genome.getPrimary().isNocturnal() || genome.getNocturnal() || beeModifier.isSelfLighted();
return (genome.getPrimary().isNocturnal() || genome.getNocturnal() || beeModifier.isSelfLighted())
&& !(beeModifier.isSelfUnlighted() && beeModifier.isSelfLighted());
}
private boolean canWorkDuringDay() {
return !genome.getPrimary().isNocturnal() || genome.getNocturnal();
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
private boolean canWorkDuringDay(IBeeModifier beeModifier) {
return (!genome.getPrimary().isNocturnal() || genome.getNocturnal() || beeModifier.isSelfUnlighted())
&& !(beeModifier.isSelfUnlighted() && beeModifier.isSelfLighted());
}
private boolean canWorkUnderground(IBeeModifier beeModifier) {
@@ -451,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
@@ -475,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
@@ -513,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()) {
@@ -537,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(),
@@ -550,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
@@ -31,6 +31,7 @@ import forestry.mail.gui.GuiMailboxInfo;
public class Config {
public static boolean disableButterfly;
public static final String CATEGORY_COMMON = "common";
public static final String CATEGORY_FLUIDS = "fluids";
@@ -146,6 +147,8 @@ public class Config {
configCommon = new LocalizedConfiguration(configFileCommon, "1.2.0");
disableButterfly = configCommon.getBooleanLocalized("mobs", "disable.butterfly", false);
gameMode = configCommon
.getStringLocalized("difficulty", "game.mode", "EASY", new String[] { "OP, EASY, NORMAL, HARD" });
@@ -106,7 +106,7 @@ public abstract class ItemInventory implements IInventory, IFilterSlotDelegate {
String baseUID = base.getTagCompound().getString(KEY_UID);
String comparisonUID = comparison.getTagCompound().getString(KEY_UID);
return baseUID != null && comparisonUID != null && baseUID.equals(comparisonUID);
return baseUID != null && !baseUID.isEmpty() && baseUID.equals(comparisonUID);
}
public void readFromNBT(NBTTagCompound nbt) {
@@ -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));
}
}
@@ -14,6 +14,7 @@ import forestry.api.arboriculture.ILeafTickHandler;
import forestry.api.arboriculture.ITree;
import forestry.api.lepidopterology.ButterflyManager;
import forestry.api.lepidopterology.IButterfly;
import forestry.core.config.Config;
import forestry.core.utils.Log;
import forestry.lepidopterology.entities.EntityButterfly;
import forestry.plugins.PluginLepidopterology;
@@ -22,6 +23,9 @@ public class ButterflySpawner implements ILeafTickHandler {
@Override
public boolean onRandomLeafTick(ITree tree, World world, int x, int y, int z, boolean isDestroyed) {
if (Config.disableButterfly) {
return false;
}
if (world.rand.nextFloat() >= tree.getGenome().getSappiness() * tree.getGenome().getYield()) {
return false;
@@ -48,6 +48,7 @@ import forestry.api.lepidopterology.IButterflyGenome;
import forestry.api.lepidopterology.IButterflyRoot;
import forestry.api.lepidopterology.IEntityButterfly;
import forestry.api.lepidopterology.ILepidopteristTracker;
import forestry.core.config.Config;
import forestry.core.utils.ItemStackUtil;
import forestry.lepidopterology.genetics.Butterfly;
@@ -369,6 +370,9 @@ public class EntityButterfly extends EntityCreature implements IEntityButterfly
@Override
protected boolean canDespawn() {
if (Config.disableButterfly) {
this.setDead();
}
return ticksExisted > MAX_LIFESPAN;
}
@@ -21,6 +21,8 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import com.mojang.realmsclient.gui.ChatFormatting;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import forestry.api.core.Tabs;
@@ -87,6 +89,12 @@ public class ItemButterflyGE extends ItemGE {
return butterfly.getDisplayName();
}
@Override
public void addInformation(ItemStack itemstack, EntityPlayer player, List list, boolean flag) {
super.addInformation(itemstack, player, list, flag);
if (Config.disableButterfly && type == EnumFlutterType.BUTTERFLY) list.add(ChatFormatting.RED + "Disabled");
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList) {
@@ -107,7 +115,7 @@ public class ItemButterflyGE extends ItemGE {
@Override
public boolean onEntityItemUpdate(EntityItem entityItem) {
if (type != EnumFlutterType.BUTTERFLY) {
if (type != EnumFlutterType.BUTTERFLY || Config.disableButterfly) {
return false;
}
if (entityItem.worldObj.isRemote || entityItem.ticksExisted < 80) {
@@ -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