Skip to content

Commit 5057c33

Browse files
committed
fix
1 parent 7634200 commit 5057c33

20 files changed

Lines changed: 544 additions & 539 deletions

src/main/java/com/github/gtexpert/gtbm/api/gui/GTBMGuiTextures.java

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.github.gtexpert.gtbm.api.gui;
22

3+
import net.minecraft.util.ResourceLocation;
4+
35
import gregtech.api.gui.resources.TextureArea;
46

57
public class GTBMGuiTextures {
@@ -15,11 +17,15 @@ public class GTBMGuiTextures {
1517
public static final TextureArea GTBM_LOGO_BLINKING_RED = TextureArea
1618
.fullImage("textures/gui/icon/gtbm_logo_blinking_red.png");
1719

18-
// Bee slot overlays
19-
public static final TextureArea QUEEN_OVERLAY = TextureArea
20-
.fullImage("textures/gui/overlay/queen_overlay.png");
21-
public static final TextureArea DRONE_OVERLAY = TextureArea
22-
.fullImage("textures/gui/overlay/drone_overlay.png");
23-
public static final TextureArea UPGRADE_OVERLAY = TextureArea
24-
.fullImage("textures/gui/overlay/upgrade_overlay.png");
20+
// Bee status icon (from JEI)
21+
public static final TextureArea BEE_INFO_ICON = new TextureArea(
22+
new ResourceLocation("jei", "textures/gui/icons/info.png"), 0, 0, 1, 1);
23+
24+
// Bee slot overlays (directly from Gendustry's hint icons)
25+
public static final TextureArea QUEEN_OVERLAY = new TextureArea(
26+
new ResourceLocation("gendustry", "textures/items/hints/queen.png"), 0, 0, 1, 1);
27+
public static final TextureArea DRONE_OVERLAY = new TextureArea(
28+
new ResourceLocation("gendustry", "textures/items/hints/drone.png"), 0, 0, 1, 1);
29+
public static final TextureArea UPGRADE_OVERLAY = new TextureArea(
30+
new ResourceLocation("gendustry", "textures/items/hints/upgrade.png"), 0, 0, 1, 1);
2531
}

src/main/java/com/github/gtexpert/gtbm/integration/forestry/ForestryConfigHolder.java

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,16 @@ public class ForestryConfigHolder {
1616
"valid: [NORMAL, HARD]" })
1717
public static String gameMode = "NORMAL";
1818

19-
@Config.Comment({ "If true, each will be uncraftable.", "default: false" })
20-
public static boolean Still = false,
21-
Fabricator = false,
22-
Centrifuge = false,
23-
Bottler = false,
24-
Fermenter = false,
25-
Rainmaker = false,
26-
Carpenter = false,
27-
Moistener = false,
28-
Raintank = false,
29-
Squeezer = false;
19+
@Config.Comment({ "If true, each will be uncraftable.", "default: true" })
20+
public static boolean Still = true,
21+
Fabricator = true,
22+
Centrifuge = true,
23+
Bottler = true,
24+
Fermenter = true,
25+
Rainmaker = true,
26+
Carpenter = true,
27+
Moistener = true,
28+
Raintank = true,
29+
Squeezer = true,
30+
FarmBlock = true;
3031
}

src/main/java/com/github/gtexpert/gtbm/integration/forestry/ForestryModule.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import com.github.gtexpert.gtbm.integration.forestry.loaders.FFMOreDictionaryLoader;
1313
import com.github.gtexpert.gtbm.integration.forestry.recipes.*;
1414
import com.github.gtexpert.gtbm.integration.forestry.recipes.machines.*;
15+
import com.github.gtexpert.gtbm.integration.forestry.util.BeeHousingInfoProvider;
1516
import com.github.gtexpert.gtbm.module.Modules;
1617

1718
@TModule(
@@ -36,6 +37,11 @@ public void postInit(FMLPostInitializationEvent event) {
3637
CarpenterLoader.initMode();
3738
CentrifugeLoader.init();
3839
FabricatorLoader.init();
40+
41+
// Register TOP provider for bee housing health display
42+
if (Mods.TheOneProbe.isModLoaded()) {
43+
mcjty.theoneprobe.TheOneProbe.theOneProbeImp.registerProvider(new BeeHousingInfoProvider());
44+
}
3945
}
4046

4147
@Override

src/main/java/com/github/gtexpert/gtbm/integration/forestry/ForestryUtility.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,24 @@ public class ForestryUtility {
1313
public static float energyModifier = ForestryAPI.activeMode.getFloatSetting("energy.demand.modifier");
1414
public static int feToEu = ConfigHolder.compat.energy.euToFeRatio;
1515

16+
/** Get ticks per bee work cycle from Forestry config. Default 550. */
17+
public static int getTicksPerWorkCycle() {
18+
return forestry.apiculture.ModuleApiculture.ticksPerBeeWorkCycle;
19+
}
20+
21+
/** Effective ticks per health point, accounting for lifespan modifier. */
22+
public static int getEffectiveTicksPerHealth(float lifespanModifier) {
23+
return Math.round(getTicksPerWorkCycle() * lifespanModifier);
24+
}
25+
26+
/** Format seconds as "Xm Ys" or "Xs". */
27+
public static String formatTime(int totalSeconds) {
28+
if (totalSeconds >= 60) {
29+
return String.format("%dm %ds", totalSeconds / 60, totalSeconds % 60);
30+
}
31+
return totalSeconds + "s";
32+
}
33+
1634
public static int timeCarpenter(int EUt) {
1735
return Math.round(EUt * 204 * energyModifier / (100 * feToEu));
1836
}

src/main/java/com/github/gtexpert/gtbm/integration/forestry/recipes/FFMBlockRecipe.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import gregtech.common.items.MetaItems;
2020

2121
import com.github.gtexpert.gtbm.api.util.Mods;
22+
import com.github.gtexpert.gtbm.integration.forestry.ForestryConfigHolder;
2223

2324
import forestry.core.ModuleCore;
2425
import forestry.core.items.EnumElectronTube;
@@ -69,6 +70,8 @@ public static void blockCharcoal() {
6970
}
7071

7172
public static void farm() {
73+
if (!ForestryConfigHolder.FarmBlock) return;
74+
7275
BlockRegistryFarming blocks = getBlocks();
7376

7477
ItemStack basic = blocks.farm.get(EnumFarmBlockType.PLAIN, 1);
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
package com.github.gtexpert.gtbm.integration.forestry.util;
2+
3+
import javax.annotation.Nullable;
4+
5+
import net.bdew.gendustry.api.ApiaryModifiers;
6+
7+
import forestry.api.apiculture.DefaultBeeModifier;
8+
import forestry.api.apiculture.IBeeGenome;
9+
10+
/**
11+
* IBeeModifier implementation that delegates to ApiaryModifiers.
12+
* Reusable bridge between Gendustry's upgrade system and Forestry's modifier interface.
13+
* Override {@link #isHellish()} in subclass since it requires world/pos context.
14+
*/
15+
public class ApiaryModifierBridge extends DefaultBeeModifier {
16+
17+
protected final ApiaryModifiers modifiers;
18+
19+
public ApiaryModifierBridge(ApiaryModifiers modifiers) {
20+
this.modifiers = modifiers;
21+
}
22+
23+
@Override
24+
public float getTerritoryModifier(IBeeGenome genome, float currentModifier) {
25+
return Math.min(modifiers.territory, 5);
26+
}
27+
28+
@Override
29+
public float getMutationModifier(IBeeGenome genome, IBeeGenome mate, float currentModifier) {
30+
return modifiers.mutation;
31+
}
32+
33+
@Override
34+
public float getLifespanModifier(IBeeGenome genome, @Nullable IBeeGenome mate, float currentModifier) {
35+
return modifiers.lifespan;
36+
}
37+
38+
@Override
39+
public float getProductionModifier(IBeeGenome genome, float currentModifier) {
40+
return modifiers.production;
41+
}
42+
43+
@Override
44+
public float getFloweringModifier(IBeeGenome genome, float currentModifier) {
45+
return modifiers.flowering;
46+
}
47+
48+
@Override
49+
public float getGeneticDecay(IBeeGenome genome, float currentModifier) {
50+
return modifiers.geneticDecay;
51+
}
52+
53+
@Override
54+
public boolean isSealed() {
55+
return modifiers.isSealed;
56+
}
57+
58+
@Override
59+
public boolean isSelfLighted() {
60+
return modifiers.isSelfLighted;
61+
}
62+
63+
@Override
64+
public boolean isSunlightSimulated() {
65+
return modifiers.isSunlightSimulated;
66+
}
67+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package com.github.gtexpert.gtbm.integration.forestry.util;
2+
3+
import javax.annotation.Nullable;
4+
5+
import net.bdew.gendustry.api.ApiaryModifiers;
6+
import net.minecraft.util.math.BlockPos;
7+
import net.minecraft.world.World;
8+
import net.minecraft.world.biome.Biome;
9+
10+
import forestry.api.core.BiomeHelper;
11+
import forestry.api.core.EnumHumidity;
12+
import forestry.api.core.EnumTemperature;
13+
14+
/**
15+
* Reusable climate calculation helper for bee housings.
16+
* Combines biome data with ApiaryModifiers for temperature/humidity.
17+
*/
18+
public class BeeClimateHelper {
19+
20+
private final ApiaryModifiers modifiers;
21+
22+
public BeeClimateHelper(ApiaryModifiers modifiers) {
23+
this.modifiers = modifiers;
24+
}
25+
26+
@Nullable
27+
public Biome getEffectiveBiome(@Nullable World world, BlockPos pos) {
28+
if (modifiers.biomeOverride != null) return modifiers.biomeOverride;
29+
return world != null ? world.getBiome(pos) : null;
30+
}
31+
32+
public Biome getBiome(World world, BlockPos pos) {
33+
Biome biome = getEffectiveBiome(world, pos);
34+
return biome != null ? biome : world.getBiome(pos);
35+
}
36+
37+
public EnumTemperature getTemperature(@Nullable World world, BlockPos pos) {
38+
Biome biome = getEffectiveBiome(world, pos);
39+
if (biome == null) return EnumTemperature.NORMAL;
40+
if (BiomeHelper.isBiomeHellish(biome)) return EnumTemperature.HELLISH;
41+
return EnumTemperature.getFromValue(biome.getTemperature(pos) + modifiers.temperature);
42+
}
43+
44+
public EnumHumidity getHumidity(@Nullable World world, BlockPos pos) {
45+
Biome biome = getEffectiveBiome(world, pos);
46+
if (biome == null) return EnumHumidity.NORMAL;
47+
return EnumHumidity.getFromValue(biome.getRainfall() + modifiers.humidity);
48+
}
49+
50+
public boolean isHellish(@Nullable World world, BlockPos pos) {
51+
Biome biome = getEffectiveBiome(world, pos);
52+
return biome != null && BiomeHelper.isBiomeHellish(biome);
53+
}
54+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
package com.github.gtexpert.gtbm.integration.forestry.util;
2+
3+
import net.minecraft.block.state.IBlockState;
4+
import net.minecraft.entity.player.EntityPlayer;
5+
import net.minecraft.tileentity.TileEntity;
6+
import net.minecraft.world.World;
7+
8+
import org.jetbrains.annotations.NotNull;
9+
10+
import gregtech.api.metatileentity.interfaces.IGregTechTileEntity;
11+
12+
import com.github.gtexpert.gtbm.api.ModValues;
13+
14+
import forestry.api.apiculture.*;
15+
import mcjty.theoneprobe.api.IProbeHitData;
16+
import mcjty.theoneprobe.api.IProbeInfo;
17+
import mcjty.theoneprobe.api.IProbeInfoProvider;
18+
import mcjty.theoneprobe.api.ProbeMode;
19+
20+
/**
21+
* TOP provider that shows queen health for any GT MTE implementing IBeeHousing.
22+
*/
23+
public class BeeHousingInfoProvider implements IProbeInfoProvider {
24+
25+
@Override
26+
public String getID() {
27+
return ModValues.MODID + ":bee_housing_provider";
28+
}
29+
30+
@Override
31+
public void addProbeInfo(@NotNull ProbeMode mode, @NotNull IProbeInfo probeInfo, @NotNull EntityPlayer player,
32+
@NotNull World world, @NotNull IBlockState blockState, @NotNull IProbeHitData data) {
33+
TileEntity te = world.getTileEntity(data.getPos());
34+
if (!(te instanceof IGregTechTileEntity)) return;
35+
36+
var mte = ((IGregTechTileEntity) te).getMetaTileEntity();
37+
if (!(mte instanceof IBeeHousing)) return;
38+
39+
IBeeHousing housing = (IBeeHousing) mte;
40+
IBeeHousingInventory inv = housing.getBeeInventory();
41+
if (inv.getQueen().isEmpty()) return;
42+
43+
IBeeRoot beeRoot = BeeManager.beeRoot;
44+
if (beeRoot == null) return;
45+
46+
EnumBeeType type = beeRoot.getType(inv.getQueen());
47+
if (type == EnumBeeType.QUEEN) {
48+
IBee bee = beeRoot.getMember(inv.getQueen());
49+
if (bee != null && bee.getMaxHealth() > 0) {
50+
int health = bee.getHealth();
51+
int maxHealth = bee.getMaxHealth();
52+
int color = health > maxHealth / 4 ? 0xFF00D4CE : 0xFFBB1C28;
53+
probeInfo.progress(health, maxHealth, probeInfo.defaultProgressStyle()
54+
.suffix(" / " + maxHealth + " HP")
55+
.filledColor(color)
56+
.alternateFilledColor(color)
57+
.borderColor(0xFF555555));
58+
}
59+
}
60+
}
61+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
package com.github.gtexpert.gtbm.integration.forestry.util;
2+
3+
import net.bdew.gendustry.api.ApiaryModifiers;
4+
import net.minecraft.item.ItemStack;
5+
import net.minecraftforge.items.IItemHandlerModifiable;
6+
7+
import forestry.api.apiculture.EnumBeeType;
8+
import forestry.api.apiculture.IBeeHousingInventory;
9+
import forestry.api.apiculture.IBeeRoot;
10+
11+
/**
12+
* Reusable product distribution logic for bee housings.
13+
* Handles automated bee re-insertion and output slot management.
14+
*/
15+
public class BeeProductHelper {
16+
17+
/**
18+
* Add a bee product to the housing's inventory.
19+
* If automated, attempts to re-insert bees into queen/drone slots first.
20+
*
21+
* @param product the product to add
22+
* @param beeRoot the bee root (nullable, skips automation if null)
23+
* @param modifiers the apiary modifiers (checks isAutomated)
24+
* @param autoBreeding whether auto-breeding is enabled (GT toggle button)
25+
* @param beeInv the bee housing inventory (queen/drone access)
26+
* @param importItems the import item handler (for drone merging)
27+
* @param exportItems the export item handler (output slots)
28+
* @return true if the product was fully inserted
29+
*/
30+
public static boolean addProduct(ItemStack product, IBeeRoot beeRoot, ApiaryModifiers modifiers,
31+
boolean autoBreeding, IBeeHousingInventory beeInv,
32+
IItemHandlerModifiable importItems, IItemHandlerModifiable exportItems) {
33+
if (product.isEmpty()) return true;
34+
35+
ItemStack remaining = product.copy();
36+
37+
if (beeRoot != null && beeRoot.isMember(remaining)) {
38+
// Princess/Queen auto-insertion: controlled by autoBreeding button (master switch)
39+
if (autoBreeding && (beeRoot.isMember(remaining, EnumBeeType.PRINCESS) ||
40+
beeRoot.isMember(remaining, EnumBeeType.QUEEN))) {
41+
if (beeInv.getQueen().isEmpty()) {
42+
beeInv.setQueen(remaining);
43+
return true;
44+
}
45+
}
46+
// Drone auto-insertion: controlled by automation upgrade OR autoBreeding
47+
if ((autoBreeding || modifiers.isAutomated) && beeRoot.isMember(remaining, EnumBeeType.DRONE)) {
48+
if (beeInv.getDrone().isEmpty()) {
49+
beeInv.setDrone(remaining);
50+
return true;
51+
}
52+
ItemStack mergeResult = importItems.insertItem(1, remaining, false);
53+
if (mergeResult.isEmpty()) return true;
54+
remaining = mergeResult;
55+
}
56+
}
57+
58+
// Try to add to output slots
59+
for (int i = 0; i < exportItems.getSlots(); i++) {
60+
remaining = exportItems.insertItem(i, remaining, false);
61+
if (remaining.isEmpty()) return true;
62+
}
63+
return remaining.isEmpty();
64+
}
65+
}

0 commit comments

Comments
 (0)