Thread safe (#64)

* update readme and bs

* Thread safe
This commit is contained in:
Jason Mitchell authored and GitHub committed 2024-03-02 21:43:31 +01:00
1 parent 2e20b14e06
commit 7db0dc7767
10 files changed
+45 -100

No files matched your search

+2 -12
View File
@@ -3,17 +3,9 @@ Forestry
### What is it?
This is the GTNH fork of Forestry for 1.7.10. Do not report any issues to the original Forestry team. This fork is maintained by the GTNH team and is not supported by the original Forestry team.
Forestry is a modification for the game Minecraft and known primarily for its farms and bees.
### Homepage
[Wiki](http://forestry.sengir.net/)
[Latest Builds for 1.7.10](http://jenkins.ic2.player.to/job/Forestry_Dev/)
[IRC #forestry on esper.net](http://webchat.esper.net/?nick=ForestryGithub...&channels=forestry&prompt=1)
For those interested in developement, you can also visit #forestry-dev.
### Building
@@ -31,8 +23,6 @@ Beware of ugly code.
Bugfixes are generally welcome. If you want to contribute something which changes game mechanics, please talk to someone with commit privileges first. Nothing is more frustrating than putting a lot of work and effort into a new game mechanic and then having the PR rejected because it doesn’t fit gameplay-wise.
**If you submit a PR you must accept the [Contributor License Agreement](https://cla-assistant.io/ForestryMC/ForestryMC). There is no way around that, since otherwise changing the license later - even to something more permissive! - , becomes close to impossible.**
### License & Copyright
Forestry is (c) 2011 - 2014 SirSengir and licensed under LGPL v3. See the LICENSE.txt for all the gory details or go to http://www.gnu.org/licenses/lgpl-3.0.txt for more information. Forestry also contains code contributed by CovertJaguar, Player, MysteriousAges, Binnie, RichardG, cpw and others.
Forestry is (c) 2011 - 2014 SirSengir and licensed under LGPL v3. See the LICENSE.txt for all the gory details or go to http://www.gnu.org/licenses/lgpl-3.0.txt for more information. Forestry also contains code contributed by CovertJaguar, Player, MysteriousAges, Binnie, RichardG, cpw, the GTNH Team, and others.
+1
View File
@@ -2,6 +2,7 @@
dependencies {
api('curse.maven:cofh-lib-220333:2388748')
compileOnlyApi('com.github.GTNewHorizons:Angelica:1.0.0-alpha31:api')
devOnlyNonPublishable('com.github.GTNewHorizons:NotEnoughItems:2.5.18-GTNH:dev')
compileOnly('com.github.GTNewHorizons:inventory-tweaks:1.6.2:api')
compileOnly('com.github.GTNewHorizons:BuildCraft:7.1.39:api')
+1 -1
View File
@@ -17,7 +17,7 @@ pluginManagement {
}
plugins {
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.14'
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.15'
}
@@ -15,11 +15,14 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import com.gtnewhorizons.angelica.api.ThreadSafeISBRH;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
import forestry.apiculture.blocks.BlockCandle;
import forestry.apiculture.tiles.TileCandle;
import forestry.core.proxy.Proxies;
@ThreadSafeISBRH(perThread = false)
public class RenderCandleBlock implements ISimpleBlockRenderingHandler {
@Override
@@ -58,7 +61,7 @@ public class RenderCandleBlock implements ISimpleBlockRenderingHandler {
IIcon iconB = block.getTextureFromPassAndLit(1, isLit);
int colour = tileCandle.getColour();
Tessellator tessellator = Tessellator.instance;
final Tessellator tessellator = Tessellator.instance;
tessellator.setBrightness(world.getLightBrightnessForSkyBlocks(x, y, z, block.getLightValue(world, x, y, z)));
tessellator.setColorOpaque_F(1.0F, 1.0F, 1.0F);
double d0 = 0.4000000059604645D;
@@ -87,7 +90,7 @@ public class RenderCandleBlock implements ISimpleBlockRenderingHandler {
private static void renderCandleAtAngle(IIcon icon, double x, double y, double z, double par8, double par10,
int colour) {
Tessellator tessellator = Tessellator.instance;
final Tessellator tessellator = Tessellator.instance;
double minU = icon.getMinU();
double minV = icon.getMinV();
double maxU = icon.getMaxU();
@@ -15,11 +15,14 @@ import net.minecraft.client.renderer.Tessellator;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import com.gtnewhorizons.angelica.api.ThreadSafeISBRH;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
import forestry.arboriculture.blocks.BlockFruitPod;
import forestry.arboriculture.tiles.TileFruitPod;
import forestry.plugins.PluginArboriculture;
@ThreadSafeISBRH(perThread = false)
public class RenderFruitPodBlock implements ISimpleBlockRenderingHandler {
@Override
@@ -37,7 +40,7 @@ public class RenderFruitPodBlock implements ISimpleBlockRenderingHandler {
maturity = pod.getMaturity();
}
Tessellator tessellator = Tessellator.instance;
final Tessellator tessellator = Tessellator.instance;
tessellator.setBrightness(blockPod.getMixedBrightnessForBlock(world, x, y, z));
tessellator.setColorOpaque_F(1.0f, 1.0f, 1.0f);
int metadata = world.getBlockMetadata(x, y, z);
@@ -14,6 +14,8 @@ import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import com.gtnewhorizons.angelica.api.ThreadSafeISBRH;
import forestry.arboriculture.blocks.BlockForestryLeaves;
import forestry.arboriculture.tiles.TileLeaves;
import forestry.core.render.RenderOverlayBlock;
@@ -22,6 +24,7 @@ import forestry.plugins.PluginArboriculture;
/**
* Ugly but serviceable renderer for leaves, taking fruits into account.
*/
@ThreadSafeISBRH(perThread = false)
public class RenderLeavesBlock extends RenderOverlayBlock {
@Override
@@ -15,6 +15,8 @@ import net.minecraft.client.renderer.Tessellator;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import com.gtnewhorizons.angelica.api.ThreadSafeISBRH;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
import forestry.api.arboriculture.EnumGermlingType;
import forestry.api.arboriculture.IAlleleTreeSpecies;
@@ -22,10 +24,9 @@ import forestry.arboriculture.blocks.BlockSapling;
import forestry.arboriculture.tiles.TileSapling;
import forestry.plugins.PluginArboriculture;
@ThreadSafeISBRH(perThread = false)
public class RenderSaplingBlock implements ISimpleBlockRenderingHandler {
private static int renderLayer = 0;
@Override
public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) {}
@@ -45,10 +46,8 @@ public class RenderSaplingBlock implements ISimpleBlockRenderingHandler {
IAlleleTreeSpecies species = tile.getTree().getGenome().getPrimary();
renderCrossedSquares(species, world, block, x, y, z);
renderLayer = 1;
renderCrossedSquares(species, world, block, x, y, z);
renderLayer = 0;
renderCrossedSquares(species, world, block, x, y, z, 0);
renderCrossedSquares(species, world, block, x, y, z, 1);
return true;
}
@@ -63,9 +62,9 @@ public class RenderSaplingBlock implements ISimpleBlockRenderingHandler {
}
private static boolean renderCrossedSquares(IAlleleTreeSpecies species, IBlockAccess world, Block block, int x,
int y, int z) {
int y, int z, int renderLayer) {
Tessellator tess = Tessellator.instance;
final Tessellator tess = Tessellator.instance;
tess.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z));
int colourMultiplier = species.getGermlingColour(EnumGermlingType.SAPLING, renderLayer);
@@ -81,14 +80,14 @@ public class RenderSaplingBlock implements ISimpleBlockRenderingHandler {
}
tess.setColorOpaque_F(r, g, b);
drawCrossedSquares(species, x, y, z, 1.0f);
drawCrossedSquares(species, x, y, z, 1.0f, renderLayer);
return true;
}
private static void drawCrossedSquares(IAlleleTreeSpecies species, double par3, double par5, double par7,
float mod) {
private static void drawCrossedSquares(IAlleleTreeSpecies species, double par3, double par5, double par7, float mod,
int renderLayer) {
Tessellator tess = Tessellator.instance;
final Tessellator tess = Tessellator.instance;
IIcon icon = species.getGermlingIcon(EnumGermlingType.SAPLING, renderLayer);
double d3 = (double) icon.getMinU();
@@ -14,11 +14,15 @@ import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.world.IBlockAccess;
import com.gtnewhorizons.angelica.api.ThreadSafeISBRH;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
import forestry.core.proxy.Proxies;
@ThreadSafeISBRH(perThread = false)
public class RenderBlock implements ISimpleBlockRenderingHandler {
// Seems to be set during registration - should be fine to not use a concurrent hashmap
public static final HashMap<TileRendererIndex, IBlockRenderer> byBlockRenderer = new HashMap<>();
@Override
@@ -14,8 +14,11 @@ import net.minecraft.client.renderer.Tessellator;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import com.gtnewhorizons.angelica.api.ThreadSafeISBRH;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
@ThreadSafeISBRH(perThread = false)
public abstract class RenderOverlayBlock implements ISimpleBlockRenderingHandler {
protected static final double OVERLAY_SHIFT = 0.001;
@@ -12,10 +12,13 @@ import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.world.IBlockAccess;
import com.gtnewhorizons.angelica.api.ThreadSafeISBRH;
import forestry.core.render.RenderOverlayBlock;
import forestry.farming.blocks.BlockFarm;
import forestry.plugins.PluginFarming;
@ThreadSafeISBRH(perThread = false)
public class RenderFarmBlock extends RenderOverlayBlock {
@Override
@@ -41,78 +44,14 @@ public class RenderFarmBlock extends RenderOverlayBlock {
float adjG = 0.5f;
float adjB = 0.5f;
renderBottomFace(
world,
block,
x,
y,
z,
renderer,
BlockFarm.getOverlayTextureForBlock(0, metadata),
mixedBrightness,
adjR,
adjG,
adjB);
renderTopFace(
world,
block,
x,
y,
z,
renderer,
BlockFarm.getOverlayTextureForBlock(1, metadata),
mixedBrightness,
adjR,
adjG,
adjB);
renderEastFace(
world,
block,
x,
y,
z,
renderer,
BlockFarm.getOverlayTextureForBlock(2, metadata),
mixedBrightness,
adjR,
adjG,
adjB);
renderWestFace(
world,
block,
x,
y,
z,
renderer,
BlockFarm.getOverlayTextureForBlock(3, metadata),
mixedBrightness,
adjR,
adjG,
adjB);
renderNorthFace(
world,
block,
x,
y,
z,
renderer,
BlockFarm.getOverlayTextureForBlock(4, metadata),
mixedBrightness,
adjR,
adjG,
adjB);
renderSouthFace(
world,
block,
x,
y,
z,
renderer,
BlockFarm.getOverlayTextureForBlock(5, metadata),
mixedBrightness,
adjR,
adjG,
adjB);
// spotless:off
renderBottomFace(world, block, x, y, z, renderer, BlockFarm.getOverlayTextureForBlock(0, metadata), mixedBrightness, adjR, adjG, adjB);
renderTopFace(world, block, x, y, z, renderer, BlockFarm.getOverlayTextureForBlock(1, metadata), mixedBrightness, adjR, adjG, adjB);
renderEastFace(world, block, x, y, z, renderer, BlockFarm.getOverlayTextureForBlock(2, metadata), mixedBrightness, adjR, adjG, adjB);
renderWestFace(world, block, x, y, z, renderer, BlockFarm.getOverlayTextureForBlock(3, metadata), mixedBrightness, adjR, adjG, adjB);
renderNorthFace(world, block, x, y, z, renderer, BlockFarm.getOverlayTextureForBlock(4, metadata), mixedBrightness, adjR, adjG, adjB);
renderSouthFace(world, block, x, y, z, renderer, BlockFarm.getOverlayTextureForBlock(5, metadata), mixedBrightness, adjR, adjG, adjB);
// spotless:on
}
@Override