aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/loaders
diff options
context:
space:
mode:
authorhacatu <hacatu5000@gmail.com>2023-09-08 20:38:41 +0000
committerGitHub <noreply@github.com>2023-09-08 22:38:41 +0200
commite4f17b7b40503fd34d9dae447802453480b9577c (patch)
treee5d8d6eb5c0caaa87ba40f8fb2e62740f3e1ad3f /src/main/java/gregtech/loaders
parent7e18bbad926a8b142113ecd59e428db08209b4de (diff)
downloadGT5-Unofficial-e4f17b7b40503fd34d9dae447802453480b9577c.tar.gz
GT5-Unofficial-e4f17b7b40503fd34d9dae447802453480b9577c.tar.bz2
GT5-Unofficial-e4f17b7b40503fd34d9dae447802453480b9577c.zip
Add BarnardaC bee effect, enhance tooltip and waila for iapiary (#2255)
* Added BarnardaC bee effect, added harder alternative mutation for indium bee * Improved tooltip and waila hud for iapiary * Shorten effect name for beealyzer * Moved Effects to own files, cached constants * Refactor constant names
Diffstat (limited to 'src/main/java/gregtech/loaders')
-rw-r--r--src/main/java/gregtech/loaders/misc/GT_BeeDefinition.java10
-rw-r--r--src/main/java/gregtech/loaders/misc/GT_Bees.java16
-rw-r--r--src/main/java/gregtech/loaders/misc/bees/GT_AlleleEffect.java44
-rw-r--r--src/main/java/gregtech/loaders/misc/bees/GT_EffectTreeTwister.java86
4 files changed, 155 insertions, 1 deletions
diff --git a/src/main/java/gregtech/loaders/misc/GT_BeeDefinition.java b/src/main/java/gregtech/loaders/misc/GT_BeeDefinition.java
index 197c012825..25665eaf7c 100644
--- a/src/main/java/gregtech/loaders/misc/GT_BeeDefinition.java
+++ b/src/main/java/gregtech/loaders/misc/GT_BeeDefinition.java
@@ -713,6 +713,11 @@ public enum GT_BeeDefinition implements IBeeDefinition {
IBeeMutationCustom tMutation = dis.registerMutation(LEAD, OSMIUM, 1);
tMutation.requireResource("blockIndium");
tMutation.addMutationCondition(new GT_Bees.DimensionMutationCondition(39, "Venus")); // Venus Dim
+ // Harder mutation that isn't dim locked
+ tMutation = dis.registerMutation(SILVER, OSMIUM, 1);
+ tMutation.requireResource("blockCinobiteA243");
+ tMutation.addMutationCondition(new GT_Bees.DimensionMutationCondition(60, "Bedrock")); // Thaumic Tinkerer
+ // Bedrock Dim
}),
// IC2
@@ -2224,7 +2229,10 @@ public enum GT_BeeDefinition implements IBeeDefinition {
beeSpecies.addProduct(GT_Bees.combs.getStackForType(CombType.BARNARDA), 0.25f);
beeSpecies.setHumidity(ARID);
beeSpecies.setTemperature(HOT);
- }, template -> AlleleHelper.instance.set(template, LIFESPAN, Lifespan.SHORTEST), dis -> {
+ }, template -> {
+ AlleleHelper.instance.set(template, LIFESPAN, Lifespan.SHORTEST);
+ AlleleHelper.instance.set(template, EFFECT, getEffect(GREGTECH, "Treetwister"));
+ }, dis -> {
IBeeMutationCustom tMutation = dis.registerMutation(BARNARDA, AMERICIUM, 3, 2);
if (GalaxySpace.isModLoaded()) {
tMutation.requireResource(GameRegistry.findBlock(GalaxySpace.ID, "barnardaEgrunt"), 0);
diff --git a/src/main/java/gregtech/loaders/misc/GT_Bees.java b/src/main/java/gregtech/loaders/misc/GT_Bees.java
index cca35521a2..497105d75c 100644
--- a/src/main/java/gregtech/loaders/misc/GT_Bees.java
+++ b/src/main/java/gregtech/loaders/misc/GT_Bees.java
@@ -1,11 +1,14 @@
package gregtech.loaders.misc;
import static gregtech.api.enums.Mods.Forestry;
+import static gregtech.api.enums.Mods.GalaxySpace;
+import static gregtech.api.enums.Mods.TwilightForest;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import forestry.api.apiculture.EnumBeeChromosome;
+import forestry.api.apiculture.IAlleleBeeEffect;
import forestry.api.core.IClimateProvider;
import forestry.api.genetics.AlleleManager;
import forestry.api.genetics.IAllele;
@@ -22,6 +25,8 @@ import gregtech.common.items.ItemComb;
import gregtech.common.items.ItemDrop;
import gregtech.common.items.ItemPollen;
import gregtech.common.items.ItemPropolis;
+import gregtech.loaders.misc.bees.GT_AlleleEffect;
+import gregtech.loaders.misc.bees.GT_EffectTreeTwister;
public class GT_Bees {
@@ -41,6 +46,8 @@ public class GT_Bees {
public static IAlleleInteger blinkLife;
public static IAlleleInteger superLife;
+ public static IAlleleBeeEffect treetwisterEffect;
+
public static ItemPropolis propolis;
public static ItemPollen pollen;
public static ItemDrop drop;
@@ -84,6 +91,15 @@ public class GT_Bees {
blinkLife = new AlleleInteger("lifeBlink", 2, false, EnumBeeChromosome.LIFESPAN);
superLife = new AlleleInteger("lifeEon", 600, false, EnumBeeChromosome.LIFESPAN);
+
+ if (GalaxySpace.isModLoaded() && TwilightForest.isModLoaded()) {
+ GT_Mod.GT_FML_LOGGER.info("treetwisterEffect: GalaxySpace and TwilightForest loaded, using default impl");
+ treetwisterEffect = new GT_EffectTreeTwister();
+ } else {
+ GT_Mod.GT_FML_LOGGER
+ .info("treetwisterEffect: GalaxySpace or TwilightForest was not loaded, using fallback impl");
+ treetwisterEffect = GT_AlleleEffect.FORESTRY_BASE_EFFECT;
+ }
}
private static class AlleleFloat extends Allele implements IAlleleFloat {
diff --git a/src/main/java/gregtech/loaders/misc/bees/GT_AlleleEffect.java b/src/main/java/gregtech/loaders/misc/bees/GT_AlleleEffect.java
new file mode 100644
index 0000000000..bb0d9eef8b
--- /dev/null
+++ b/src/main/java/gregtech/loaders/misc/bees/GT_AlleleEffect.java
@@ -0,0 +1,44 @@
+package gregtech.loaders.misc.bees;
+
+import forestry.api.apiculture.EnumBeeChromosome;
+import forestry.api.apiculture.IAlleleBeeEffect;
+import forestry.api.apiculture.IBeeGenome;
+import forestry.api.apiculture.IBeeHousing;
+import forestry.api.genetics.AlleleManager;
+import forestry.api.genetics.IEffectData;
+import forestry.core.genetics.alleles.Allele;
+
+// helper class for implementing custom bee effects, based on MagicBees' implementation
+public abstract class GT_AlleleEffect extends Allele implements IAlleleBeeEffect {
+
+ public static final IAlleleBeeEffect FORESTRY_BASE_EFFECT = (IAlleleBeeEffect) AlleleManager.alleleRegistry
+ .getAllele("forestry.effectNone");
+ protected boolean combinable;
+
+ public GT_AlleleEffect(String id, boolean isDominant) {
+ super("gregtech." + id, "gregtech." + id, isDominant);
+ AlleleManager.alleleRegistry.registerAllele(this, EnumBeeChromosome.EFFECT);
+ combinable = false;
+ }
+
+ @Override
+ public boolean isCombinable() {
+ return combinable;
+ }
+
+ public GT_AlleleEffect setIsCombinable(boolean canCombine) {
+ combinable = canCombine;
+ return this;
+ }
+
+ @Override
+ public abstract IEffectData validateStorage(IEffectData storedData);
+
+ @Override
+ public abstract IEffectData doEffect(IBeeGenome genome, IEffectData storedData, IBeeHousing housing);
+
+ @Override
+ public IEffectData doFX(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) {
+ return FORESTRY_BASE_EFFECT.doFX(genome, storedData, housing);
+ }
+}
diff --git a/src/main/java/gregtech/loaders/misc/bees/GT_EffectTreeTwister.java b/src/main/java/gregtech/loaders/misc/bees/GT_EffectTreeTwister.java
new file mode 100644
index 0000000000..61c78e7443
--- /dev/null
+++ b/src/main/java/gregtech/loaders/misc/bees/GT_EffectTreeTwister.java
@@ -0,0 +1,86 @@
+package gregtech.loaders.misc.bees;
+
+import static gregtech.api.enums.Mods.GalaxySpace;
+import static gregtech.api.enums.Mods.TwilightForest;
+
+import java.util.Arrays;
+
+import net.minecraft.block.Block;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.ChunkCoordinates;
+import net.minecraft.world.World;
+
+import forestry.api.apiculture.BeeManager;
+import forestry.api.apiculture.IBeeGenome;
+import forestry.api.apiculture.IBeeHousing;
+import forestry.api.apiculture.IBeeModifier;
+import forestry.api.genetics.IEffectData;
+import gregtech.GT_Mod;
+import gregtech.api.util.GT_ModHandler;
+
+public class GT_EffectTreeTwister extends GT_AlleleEffect {
+
+ private static final Integer[] ALLOWED_DIMS = { 2, // spectre
+ 112, // last millenium
+ 60, // bedrock
+ 69, // pocket plane
+ };
+
+ private static final ItemStack TF_TRANS_SAPLING = GT_ModHandler
+ .getModItem(TwilightForest.ID, "tile.TFSapling", 1, 6);
+ private static final ItemStack BARN_SAPLING = GT_ModHandler.getModItem(GalaxySpace.ID, "barnardaCsapling", 1, 0);
+
+ static {
+ if (TF_TRANS_SAPLING == null) {
+ GT_Mod.GT_FML_LOGGER.info("GT_EffectTreeTwister(): Could not get ItemStack for BarnardaC sapling");
+ }
+ if (BARN_SAPLING == null) {
+ GT_Mod.GT_FML_LOGGER.info("GT_EffectTreeTwister(): Could not get ItemStack for BarnardaC sapling");
+ }
+ }
+
+ public GT_EffectTreeTwister() {
+ super("effectTreetwister", false);
+ }
+
+ public IEffectData validateStorage(IEffectData storedData) {
+ return storedData; // unused for this effect
+ }
+
+ public IEffectData doEffect(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) {
+ if (TF_TRANS_SAPLING == null || BARN_SAPLING == null) {
+ return storedData;
+ }
+ World world = housing.getWorld();
+ if (!Arrays.asList(ALLOWED_DIMS)
+ .contains(world.provider.dimensionId)) {
+ return storedData;
+ }
+ ChunkCoordinates coords = housing.getCoordinates();
+ IBeeModifier beeModifier = BeeManager.beeRoot.createBeeHousingModifier(housing);
+
+ // Get random coords within territory
+ int xRange = (int) (beeModifier.getTerritoryModifier(genome, 1f) * genome.getTerritory()[0]);
+ int yRange = (int) (beeModifier.getTerritoryModifier(genome, 1f) * genome.getTerritory()[1]);
+ int zRange = (int) (beeModifier.getTerritoryModifier(genome, 1f) * genome.getTerritory()[2]);
+
+ int xCoord = coords.posX + world.rand.nextInt(xRange) - xRange / 2;
+ int yCoord = coords.posY + world.rand.nextInt(yRange) - yRange / 2;
+ int zCoord = coords.posZ + world.rand.nextInt(zRange) - zRange / 2;
+
+ ItemStack sourceBlock = new ItemStack(
+ world.getBlock(xCoord, yCoord, zCoord),
+ 1,
+ world.getBlockMetadata(xCoord, yCoord, zCoord));
+ if (TF_TRANS_SAPLING != null && BARN_SAPLING != null && TF_TRANS_SAPLING.isItemEqual(sourceBlock)) {
+ world.setBlock(
+ xCoord,
+ yCoord,
+ zCoord,
+ Block.getBlockFromItem(BARN_SAPLING.getItem()),
+ BARN_SAPLING.getItemDamage(),
+ 2);
+ }
+ return storedData;
+ }
+}