Compare commits

..
12 Commits
Author SHA1 Message Date
Dream Master 43fc136fe3 update 2025-07-18 10:15:39 +07:00
boubou19 ea52fa0d55 Speed up forge event registration (#98) 2025-07-17 18:49:32 +00:00
Martin Robertz 725d556718 update 2025-07-10 11:11:16 +02:00
Yoshy d88c007fbb Add missing = in Localisation (#97) 2025-07-09 22:28:25 +00:00
Martin Robertz 485333c6aa update 2025-06-20 23:40:15 +02:00
slprime 240802082e Change NEIHandler Tooltip Position (#96) 2025-06-16 07:46:05 +02:00
Martin Robertz 6f182e932d update 2025-06-03 20:22:19 +02:00
d08b42f18c Protect some calls that lead to loadChunk with blockExists (#91)
Co-authored-by: Martin Robertz <[email protected]>
Co-authored-by: boubou19 <[email protected]>
Co-authored-by: Maya <[email protected]>
2025-06-01 21:05:22 +00:00
Martin Robertz 57cc915a1e update 2025-05-25 15:29:38 +02:00
DrParadox7 d7c5940596 Disable flowers that cannot be planted (#94) 2025-05-25 15:28:01 +02:00
Martin Robertz 79a6af701b update 2025-05-17 12:17:12 +02:00
dibbydoda 4c0b503b8b Add thunder substrate for rainmaker (#95) 2025-05-17 11:39:34 +02:00
21 changed files with 134 additions and 93 deletions

No files matched your search

+3 -3
View File
@@ -2,10 +2,10 @@
dependencies {
api('curse.maven:cofh-lib-220333:2388748')
compileOnlyApi('com.github.GTNewHorizons:Angelica:1.0.0-beta40:api')
devOnlyNonPublishable('com.github.GTNewHorizons:NotEnoughItems:2.7.38-GTNH:dev')
compileOnlyApi('com.github.GTNewHorizons:Angelica:1.0.0-beta51:api')
devOnlyNonPublishable('com.github.GTNewHorizons:NotEnoughItems:2.7.66-GTNH:dev')
compileOnly('com.github.GTNewHorizons:inventory-tweaks:1.7.1:api')
compileOnly('com.github.GTNewHorizons:BuildCraft:7.1.42:api')
compileOnly('com.github.GTNewHorizons:BuildCraft:7.1.44:api')
compileOnly('net.industrial-craft:industrialcraft-2:2.2.828-experimental:dev')
compileOnly('curse.maven:craftguide-75557:2459320')
}
+2 -2
View File
@@ -80,7 +80,7 @@ apiPackage = api
# Specify the configuration file for Forge's access transformers here. It must be placed into /src/main/resources/META-INF/
# There can be multiple files in a space-separated list.
# Example value: mymodid_at.cfg nei_at.cfg
accessTransformersFile =
accessTransformersFile = forestry_at.cfg
# Provides setup for Mixins if enabled. If you don't know what mixins are: Keep it disabled!
usesMixins = false
@@ -151,7 +151,7 @@ modrinthProjectId =
# type can be one of [project, version],
# and the name is the Modrinth project or version slug/id of the other mod.
# Example: required-project:fplib;optional-project:gasstation;incompatible-project:gregtech
# Note: GTNH Mixins is automatically set as a required dependency if usesMixins = true
# Note: UniMixins is automatically set as a required dependency if usesMixins = true.
modrinthRelations =
# Publishing to CurseForge requires you to set the CURSEFORGE_TOKEN environment variable to one of your CurseForge API tokens.
+1 -1
View File
@@ -17,7 +17,7 @@ pluginManagement {
}
plugins {
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.38'
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.41'
}
@@ -9,33 +9,37 @@ import net.minecraft.item.ItemStack;
public class RainSubstrate {
public enum WeatherState {
CLEAR,
RAIN,
STORM
}
/**
* Rain substrate capable of activating the rainmaker.
*/
public ItemStack item;
/**
* Duration of the rain shower triggered by this substrate in Minecraft ticks.
* Duration of the weather event triggered by this substrate in Minecraft ticks.
*/
public int duration;
/**
* Speed of activation sequence triggered.
*/
public float speed;
/**
* The type of weather triggered.
*/
public WeatherState weather;
public boolean reverse;
public RainSubstrate(ItemStack item, int duration, float speed) {
this(item, duration, speed, false);
public RainSubstrate(ItemStack item, float speed, WeatherState weather) {
this(item, 0, speed, weather);
}
public RainSubstrate(ItemStack item, float speed) {
this(item, 0, speed, true);
}
public RainSubstrate(ItemStack item, int duration, float speed, boolean reverse) {
public RainSubstrate(ItemStack item, int duration, float speed, WeatherState weather) {
this.item = item;
this.duration = duration;
this.speed = speed;
this.reverse = reverse;
this.weather = weather;
}
}
@@ -213,6 +213,7 @@ public final class FlowerRegistry implements IFlowerRegistry, IFlowerGrowthHelpe
private static boolean isAcceptedFlower(String flowerType, Set<Block> acceptedBlocks, Set<Flower> acceptedFlowers,
World world, int x, int y, int z) {
if (!world.blockExists(x, y, z)) return false;
Block block = world.getBlock(x, y, z);
final int meta;
@@ -24,7 +24,7 @@ public class GrowthRuleDirtGrass implements IFlowerGrowthRule {
@Override
public boolean growFlower(IFlowerRegistry flowerRegistry, String flowerType, World world, IIndividual individual,
int x, int y, int z) {
if (!world.isAirBlock(x, y, z)) {
if (!world.blockExists(x, y, z) || !world.isAirBlock(x, y, z)) {
return false;
}
@@ -39,7 +39,7 @@ public class GrowthRuleDirtGrass implements IFlowerGrowthRule {
@Override
public boolean growFlower(IFlowerGrowthHelper helper, String flowerType, World world, int x, int y, int z) {
if (!world.isAirBlock(x, y, z)) {
if (!world.blockExists(x, y, z) || !world.isAirBlock(x, y, z)) {
return false;
}
@@ -34,6 +34,10 @@ public class GrowthRuleFlowerPot implements IFlowerGrowthRule {
}
private static boolean growFlower(String flowerType, World world, int x, int y, int z) {
if (!world.blockExists(x, y, z)) {
return false;
}
TileEntity tile = world.getTileEntity(x, y, z);
if (!(tile instanceof TileEntityFlowerPot)) {
return false;
@@ -773,6 +773,9 @@ public class Bee extends IndividualLiving implements IBee {
for (int i = 0; i < 20; i++) {
Vect randomPos = Vect.getRandomPositionInArea(random, area);
Vect blockPos = Vect.add(housingPos, randomPos, offset);
if (!world.blockExists(blockPos.x, blockPos.y, blockPos.z)) {
continue;
}
TileEntity tile = world.getTileEntity(blockPos.x, blockPos.y, blockPos.z);
if (tile instanceof IPollinatable) {
@@ -109,6 +109,7 @@ public class Constants implements IForestryConstants {
public static final int MACHINE_MAX_ENERGY = 5000;
public static final int RAINMAKER_RAIN_DURATION_IODINE = 10000;
public static final int RAINMAKER_RAIN_DURATION_PHOSPHORICIODINE = 10000;
public static final int STILL_DESTILLATION_DURATION = 100;
public static final int STILL_DESTILLATION_INPUT = 10;
@@ -31,7 +31,7 @@ public class ItemForestryTool extends ItemForestry {
setMaxDamage(200);
this.remnants = remnants;
if (remnants != null) {
MinecraftForge.EVENT_BUS.register(this);
MinecraftForge.EVENT_BUS.register(new EventHandler());
}
}
@@ -53,20 +53,6 @@ public class ItemForestryTool extends ItemForestry {
return ForgeHooks.canToolHarvestBlock(block, 0, stack);
}
@SubscribeEvent
public void onDestroyCurrentItem(PlayerDestroyItemEvent event) {
if (event.original == null || event.original.getItem() != this) {
return;
}
EntityPlayer player = event.entityPlayer;
World world = player.worldObj;
if (!world.isRemote && remnants != null) {
ItemStackUtil.dropItemStackAsEntity(remnants.copy(), world, player.posX, player.posY, player.posZ);
}
}
@Override
public boolean onBlockDestroyed(ItemStack itemstack, World world, Block block, int x, int y, int z,
EntityLivingBase entityliving) {
@@ -80,4 +66,21 @@ public class ItemForestryTool extends ItemForestry {
public boolean isFull3D() {
return true;
}
public class EventHandler {
@SubscribeEvent
public void onDestroyCurrentItem(PlayerDestroyItemEvent event) {
if (event.original == null || event.original.getItem() != ItemForestryTool.this) {
return;
}
EntityPlayer player = event.entityPlayer;
World world = player.worldObj;
if (!world.isRemote && remnants != null) {
ItemStackUtil.dropItemStackAsEntity(remnants.copy(), world, player.posX, player.posY, player.posZ);
}
}
}
}
@@ -78,6 +78,7 @@ public class ItemRegistryCore extends ItemRegistry {
/* Rainmaker */
public final ItemForestry iodineCharge;
public final ItemForestry phosphor;
public final ItemForestry phosphorCharge;
/* Misc */
public final ItemCraftingMaterial craftingMaterial;
@@ -181,8 +182,8 @@ public class ItemRegistryCore extends ItemRegistry {
// / RAINMAKER SUBSTRATES
iodineCharge = registerItem(new ItemForestry(), "iodineCapsule");
phosphor = registerItem(new ItemForestry(), "phosphor");
phosphorCharge = registerItem(new ItemForestry(), "phosphoricIodineCapsule");
// / BEE RESOURCES
beeswax = registerItem(new ItemForestry(), "beeswax");
@@ -112,18 +112,12 @@ public abstract class RecipeHandlerBase extends TemplateRecipeHandler implements
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)) {
Point mouse = GuiDraw.getMousePosition();
int recipeIndex = guiRecipe.getRecipeIndices().indexOf(recipe);
if (recipeIndex >= 0) {
Point offset = guiRecipe.getRecipePosition(recipeIndex);
Point relMouse = new Point(
mouse.x - (guiRecipe.width - 176) / 2 - offset.x,
mouse.y - (guiRecipe.height - 166) / 2 - offset.y);
currenttip = this.provideTooltip(guiRecipe, currenttip, crecipe, relMouse);
}
Point offset = guiRecipe.getRecipePosition(recipe);
Point relMouse = new Point(mouse.x - guiRecipe.guiLeft - offset.x, mouse.y - guiRecipe.guiTop - offset.y);
currenttip = this.provideTooltip(guiRecipe, currenttip, crecipe, relMouse);
}
return currenttip;
@@ -135,18 +129,10 @@ public abstract class RecipeHandlerBase extends TemplateRecipeHandler implements
super.handleItemTooltip(guiRecipe, itemStack, currenttip, recipe);
CachedBaseRecipe crecipe = (CachedBaseRecipe) this.arecipes.get(recipe);
Point mouse = GuiDraw.getMousePosition();
int recipeIndex = guiRecipe.getRecipeIndices().indexOf(recipe);
Point offset = guiRecipe.getRecipePosition(recipe);
Point relMouse = new Point(mouse.x - guiRecipe.guiLeft - offset.x, mouse.y - guiRecipe.guiTop - offset.y);
if (recipeIndex >= 0) {
Point offset = guiRecipe.getRecipePosition(recipeIndex);
Point relMouse = new Point(
mouse.x - (guiRecipe.width - 176) / 2 - offset.x,
mouse.y - (guiRecipe.height - 166) / 2 - offset.y);
currenttip = this.provideItemTooltip(guiRecipe, itemStack, currenttip, crecipe, relMouse);
}
return currenttip;
return this.provideItemTooltip(guiRecipe, itemStack, currenttip, crecipe, relMouse);
}
public List<String> provideTooltip(GuiRecipe<?> guiRecipe, List<String> currenttip, CachedBaseRecipe crecipe,
@@ -210,11 +196,9 @@ public abstract class RecipeHandlerBase extends TemplateRecipeHandler implements
protected boolean transferFluidTank(GuiRecipe<?> guiRecipe, int recipe, boolean usage) {
CachedBaseRecipe crecipe = (CachedBaseRecipe) this.arecipes.get(recipe);
Point mousepos = GuiDraw.getMousePosition();
Point mouse = GuiDraw.getMousePosition();
Point offset = guiRecipe.getRecipePosition(recipe);
Point relMouse = new Point(
mousepos.x - (guiRecipe.width - 176) / 2 - offset.x,
mousepos.y - (guiRecipe.height - 166) / 2 - offset.y);
Point relMouse = new Point(mouse.x - guiRecipe.guiLeft - offset.x, mouse.y - guiRecipe.guiTop - offset.y);
if (crecipe.getFluidTanks() != null) {
for (PositionedFluidTank tank : crecipe.getFluidTanks()) {
@@ -96,6 +96,8 @@ public class GeneticsUtil {
* altering the world by changing vanilla leaves to forestry ones.
*/
public static ICheckPollinatable getCheckPollinatable(World world, final int x, final int y, final int z) {
if (!world.blockExists(x, y, z)) return null;
TileEntity tile = world.getTileEntity(x, y, z);
if (tile instanceof IPollinatable) {
@@ -26,16 +26,14 @@ public class InventoryRainmaker extends InventoryAdapterTile<TileMillRainmaker>
@Override
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
if (slotIndex == SLOT_SUBSTRATE) {
if (getStackInSlot(SLOT_SUBSTRATE) != null) {
return false;
}
if (FuelManager.rainSubstrate.containsKey(itemStack) && tile.charge == 0 && tile.progress == 0) {
RainSubstrate substrate = FuelManager.rainSubstrate.get(itemStack);
if (tile.getWorld().isRaining() && substrate.reverse) {
return true;
} else if (!tile.getWorld().isRaining() && !substrate.reverse) {
return true;
}
return tile.isValidSubstrate(substrate);
}
}
return false;
}
@@ -10,6 +10,7 @@ package forestry.factory.tiles;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.storage.WorldInfo;
import forestry.api.fuels.FuelManager;
import forestry.api.fuels.RainSubstrate;
@@ -20,7 +21,7 @@ import forestry.factory.inventory.InventoryRainmaker;
public class TileMillRainmaker extends TileMill {
private int duration;
private boolean reverse;
private RainSubstrate.WeatherState weather;
public TileMillRainmaker() {
super(null);
@@ -39,9 +40,9 @@ public class TileMillRainmaker extends TileMill {
}
// We don't have a gui, but we can be activated
if (FuelManager.rainSubstrate.containsKey(player.inventory.getCurrentItem()) && charge == 0) {
if (FuelManager.rainSubstrate.containsKey(player.inventory.getCurrentItem()) && charge == 0 && progress == 0) {
RainSubstrate substrate = FuelManager.rainSubstrate.get(player.inventory.getCurrentItem());
if (substrate.item.isItemEqual(player.inventory.getCurrentItem())) {
if (isValidSubstrate(substrate)) {
addCharge(substrate);
player.inventory.getCurrentItem().stackSize--;
}
@@ -49,6 +50,17 @@ public class TileMillRainmaker extends TileMill {
sendNetworkUpdate();
}
public boolean isValidSubstrate(RainSubstrate substrate) {
boolean thundering = getWorld().isThundering();
boolean raining = getWorld().isRaining();
return switch (substrate.weather) {
case CLEAR -> (thundering || raining);
case RAIN -> (thundering || !raining);
case STORM -> (!thundering);
};
}
@Override
public void readFromNBT(NBTTagCompound nbttagcompound) {
super.readFromNBT(nbttagcompound);
@@ -57,7 +69,7 @@ public class TileMillRainmaker extends TileMill {
progress = nbttagcompound.getFloat("Progress");
stage = nbttagcompound.getInteger("Stage");
duration = nbttagcompound.getInteger("Duration");
reverse = nbttagcompound.getBoolean("Reverse");
weather = RainSubstrate.WeatherState.valueOf(nbttagcompound.getString("Weather"));
}
@Override
@@ -68,14 +80,14 @@ public class TileMillRainmaker extends TileMill {
nbttagcompound.setFloat("Progress", progress);
nbttagcompound.setInteger("Stage", stage);
nbttagcompound.setInteger("Duration", duration);
nbttagcompound.setBoolean("Reverse", reverse);
nbttagcompound.setString("Weather", weather.name());
}
public void addCharge(RainSubstrate substrate) {
charge = 1;
speed = substrate.speed;
duration = substrate.duration;
reverse = substrate.reverse;
weather = substrate.weather;
sendNetworkUpdate();
}
@@ -103,15 +115,26 @@ public class TileMillRainmaker extends TileMill {
}
if (!worldObj.isRemote) {
if (reverse) {
worldObj.getWorldInfo().setRaining(false);
} else {
worldObj.getWorldInfo().setRaining(true);
worldObj.getWorldInfo().setRainTime(duration);
WorldInfo world = worldObj.getWorldInfo();
switch (weather) {
case CLEAR:
world.setRaining(false);
world.setThundering(false);
break;
case STORM:
world.setRaining(true);
world.setRainTime(duration);
world.setThundering(true);
world.setThunderTime(duration);
break;
case RAIN:
world.setRaining(true);
world.setRainTime(duration);
world.setThundering(false);
break;
}
charge = 0;
duration = 0;
reverse = false;
sendNetworkUpdate();
}
}
@@ -222,9 +222,23 @@ public class PluginFactory extends ForestryPlugin {
// Set rain substrates
ItemStack iodineCharge = coreItems.iodineCharge.getItemStack();
ItemStack dissipationCharge = coreItems.craftingMaterial.getDissipationCharge();
ItemStack phosphorCharge = coreItems.phosphorCharge.getItemStack();
FuelManager.rainSubstrate.put(
iodineCharge,
new RainSubstrate(
iodineCharge,
Constants.RAINMAKER_RAIN_DURATION_IODINE,
0.01f,
RainSubstrate.WeatherState.RAIN));
FuelManager.rainSubstrate
.put(iodineCharge, new RainSubstrate(iodineCharge, Constants.RAINMAKER_RAIN_DURATION_IODINE, 0.01f));
FuelManager.rainSubstrate.put(dissipationCharge, new RainSubstrate(dissipationCharge, 0.075f));
.put(dissipationCharge, new RainSubstrate(dissipationCharge, 0.075f, RainSubstrate.WeatherState.CLEAR));
FuelManager.rainSubstrate.put(
phosphorCharge,
new RainSubstrate(
phosphorCharge,
Constants.RAINMAKER_RAIN_DURATION_PHOSPHORICIODINE,
0.008f,
RainSubstrate.WeatherState.STORM));
for (BlockFactoryTesrType type : BlockFactoryTesrType.VALUES) {
MachineDefinition machineDefinition = new MachineDefinition(type);
@@ -594,6 +608,15 @@ public class PluginFactory extends ForestryPlugin {
PluginFluids.items.canEmpty,
'Z',
beeItems.honeydew);
RecipeManagers.carpenterManager.addRecipe(
5,
PluginCore.items.iodineCharge.getItemStack(),
PluginCore.items.phosphorCharge.getItemStack(),
"# #",
" # ",
"# #",
'#',
PluginCore.items.phosphor.getItemStack());
}
// Ender pearl
@@ -197,8 +197,6 @@ public class PluginBiomesOPlenty extends ForestryPlugin {
FlowerManager.FlowerTypeVanilla,
FlowerManager.FlowerTypeSnow,
FlowerManager.FlowerTypeMushrooms); // Swampflower
// FlowerManager.flowerRegistry.registerPlantableFlower(flowers, 2, 1.0, FlowerManager.FlowerTypeNether);
// //Deathbloom
FlowerManager.flowerRegistry.registerPlantableFlower(
flowers,
3,
@@ -248,16 +246,8 @@ public class PluginBiomesOPlenty extends ForestryPlugin {
1.0,
FlowerManager.FlowerTypeVanilla,
FlowerManager.FlowerTypeSnow); // Waterlily
FlowerManager.flowerRegistry.registerPlantableFlower(
flowers,
11,
1.0,
FlowerManager.FlowerTypeVanilla,
FlowerManager.FlowerTypeSnow); // EnderLotus (does not actually spawn in the end)
FlowerManager.flowerRegistry.registerPlantableFlower(flowers, 12, 1.0, FlowerManager.FlowerTypeCacti); // Bromeliad
FlowerManager.flowerRegistry.registerPlantableFlower(flowers, 13, 1.0, FlowerManager.FlowerTypeNether); // EyeBulb
// FlowerManager.flowerRegistry.registerPlantableFlower(flowers, 14, 1.0, FlowerManager.FlowerTypeNether);
// // Unlisted top of the eyebulb
FlowerManager.flowerRegistry.registerPlantableFlower(
flowers,
15,
@@ -283,8 +273,6 @@ public class PluginBiomesOPlenty extends ForestryPlugin {
FlowerManager.flowerRegistry.registerPlantableFlower(flowers2, 3, 1.0, FlowerManager.FlowerTypeVanilla); // Lavender
FlowerManager.flowerRegistry.registerPlantableFlower(flowers2, 4, 1.0, FlowerManager.FlowerTypeVanilla); // Goldenrod
FlowerManager.flowerRegistry.registerPlantableFlower(flowers2, 5, 1.0, FlowerManager.FlowerTypeVanilla); // Bluebells
FlowerManager.flowerRegistry.registerPlantableFlower(flowers2, 6, 1.0, FlowerManager.FlowerTypeVanilla); // Miner's
// delight
FlowerManager.flowerRegistry.registerPlantableFlower(
flowers2,
7,
@@ -0,0 +1,5 @@
# Forestry Access Transformer configuration file
public net.minecraft.client.gui.inventory.GuiContainer field_146999_f #xSize
public net.minecraft.client.gui.inventory.GuiContainer field_147000_g #ySize
public net.minecraft.client.gui.inventory.GuiContainer field_147003_i #guiLeft
public net.minecraft.client.gui.inventory.GuiContainer field_147009_r #guiTop
@@ -755,6 +755,7 @@ item.for.naturalistHelmet.name=Spectacles
item.for.oakStick.name=Impregnated Stick
item.for.peat.name=Peat
item.for.phosphor.name=Phosphor
item.for.phosphoricIodineCapsule.name=Phosphoric Iodine Capsule
item.for.pipette.name=Pipette
item.for.pollenFertile.name=Fertile Pollen
@@ -150,7 +150,7 @@ gui.maxspeed=Mбximo
gui.fastest=Rбpida++
gui.faster=Rбpida+
gui.fast=Rбpida
gui.slowLenta
gui.slow=Lenta
gui.slower=Lenta+
gui.slowest=Lenta++
gui.longestlife=Longa++
Binary file not shown.

After

Width:  |  Height:  |  Size: 789 B