Compare commits

..
3 Commits
Author SHA1 Message Date
Martin Robertz 8ecec5b096 update 2024-02-28 20:07:25 +01:00
boubou19GitHub GTNH Actionsgithub-actions[bot]
4e3fbc7667 Reduce allocation spam in capacitor banks (#155)
* reduce memory allocation

* update dep

* use public

* wrong dep

* spotlessApply (#156)

Co-authored-by: GitHub GTNH Actions <>

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2024-02-25 23:26:17 +01:00
Jason Mitchell 845f277497 Actually optional (#154)
* Actually optional

* Tags
2024-02-22 21:21:37 +01:00
8 changed files with 61 additions and 37 deletions

No files matched your search

+7 -7
View File
@@ -1,18 +1,18 @@
// Add your dependencies here
dependencies {
api('com.github.GTNewHorizons:EnderCore:0.4.1:dev') {transitive = false}
api('com.github.GTNewHorizons:EnderCore:0.4.5:dev') {transitive = false}
compileOnly('com.github.GTNewHorizons:ForestryMC:4.8.4:dev')
compileOnly('com.github.GTNewHorizons:NotEnoughItems:2.5.19-GTNH:dev')
compileOnly("com.github.GTNewHorizons:GTNHLib:0.2.7:dev")
compileOnly('com.github.GTNewHorizons:NotEnoughItems:2.5.21-GTNH:dev')
compileOnly("com.github.GTNewHorizons:GTNHLib:0.2.9:dev")
compileOnly('com.github.GTNewHorizons:BuildCraft:7.1.39:dev')
api('curse.maven:cofh-lib-220333:2388748') // https://www.curseforge.com/minecraft/mc-mods/cofh-lib/files/2388748
shadowImplementation('cglib:cglib-nodep:3.3.0')
compileOnly('com.github.GTNewHorizons:waila:1.7.0:api') {transitive = false}
compileOnly('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-325-GTNH:api') {transitive = false}
compileOnly('com.github.GTNewHorizons:waila:1.7.1:api') {transitive = false}
compileOnly('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-328-GTNH:api') {transitive = false}
compileOnly('com.github.GTNewHorizons:Baubles:1.0.4:dev') {transitive = false}
compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.45.71:dev') {transitive = false}
compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.45.79:dev') {transitive = false}
compileOnly('com.github.GTNewHorizons:Railcraft:9.15.5:api') {transitive = false}
compileOnly('com.github.GTNewHorizons:StorageDrawers:1.13.3-GTNH:api') {transitive = false}
compileOnly('com.github.GTNewHorizons:Chisel:2.14.1-GTNH:dev') {transitive = false}
@@ -24,5 +24,5 @@ dependencies {
compileOnly(rfg.deobf('curse.maven:mekanism-268560:2475797')) // https://www.curseforge.com/minecraft/mc-mods/mekanism/files/2475797
compileOnly(rfg.deobf('maven.modrinth:immibis-microblocks:59.1.2')) // https://modrinth.com/mod/immibis-microblocks/version/59.1.2
api('com.github.GTNewHorizons:Angelica:1.0.0-alpha29:api') {transitive = false}
compileOnlyApi('com.github.GTNewHorizons:Angelica:1.0.0-alpha30:api') {transitive = false}
}
+3 -3
View File
@@ -50,10 +50,10 @@ enableGenericInjection = false
# Generate a class with a String field for the mod version named as defined below.
# If generateGradleTokenClass is empty or not missing, no such class will be generated.
# If gradleTokenVersion is empty or missing, the field will not be present in the class.
generateGradleTokenClass =
generateGradleTokenClass = crazypants.enderio.Tags
# Name of the token containing the project's current version to generate/replace.
gradleTokenVersion = GRADLETOKEN_VERSION
gradleTokenVersion = VERSION
# [DEPRECATED] Mod ID replacement token.
gradleTokenModId =
@@ -70,7 +70,7 @@ gradleTokenGroupName =
# The string's content will be replaced with your mod's version when compiled. You should use this to specify your mod's
# version in @Mod([...], version = VERSION, [...]).
# Leave these properties empty to skip individual token replacements.
replaceGradleTokenInFile = EnderIO.java
replaceGradleTokenInFile =
# In case your mod provides an API for other mods to implement you may declare its package here. Otherwise, you can
# leave this property empty.
@@ -193,7 +193,7 @@ public class EnderIO {
public static final String MODID = "EnderIO";
public static final String DOMAIN = MODID.toLowerCase(Locale.US);
public static final String MOD_NAME = "Ender IO";
public static final String VERSION = "GRADLETOKEN_VERSION";
public static final String VERSION = Tags.VERSION;
@Instance(MODID)
public static EnderIO instance;
@@ -42,7 +42,7 @@ public class AbstractMachineRenderer implements ISimpleBlockRenderingHandler, II
private CustomCubeRenderer ccr = new CustomCubeRenderer();
private PaintedBlockRenderer paintedRenderer = new PaintedBlockRenderer(this.getRenderId(), null); // passthrough
private final PaintedBlockRenderer paintedRenderer = new PaintedBlockRenderer(this.getRenderId(), null);
// renderer for
// paintable
// machines
@@ -129,7 +129,7 @@ public class CapBankRenderer extends TileEntitySpecialRenderer implements ISimpl
nw.setMaxEnergyStoredL(CapBankType.getTypeFromMeta(item.getItemDamage()).getMaxEnergyStored());
nw.setEnergyStored(PowerHandlerUtil.getStoredEnergyForItem(item));
GaugeInfo gi = new GaugeInfo(1, 0);
GaugeInfo gi = GaugeInfo.DEFAULT;
GaugeKey key = new GaugeKey(ForgeDirection.SOUTH, FillGauge.Type.SINGLE);
fillGaugeRenderer.doRender(nw, RenderUtil.BRIGHTNESS_MAX, gi, key);
// key = new GaugeKey(ForgeDirection.EAST, FillGauge.Type.SINGLE);
@@ -1,6 +1,5 @@
package crazypants.enderio.machine.capbank.render;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -32,6 +31,7 @@ public class FillGauge implements IInfoRenderer, IResourceManagerReloadListener
private static final double HEIGHT = 0.75;
private static final double VERT_BORDER = (1 - HEIGHT) / 2;
private static final double WIDTH = 0.25;
private final Vertex[] newVerts = new Vertex[] { new Vertex(), new Vertex(), new Vertex(), new Vertex() };
enum Type {
SINGLE,
@@ -95,8 +95,8 @@ public class FillGauge implements IInfoRenderer, IResourceManagerReloadListener
if (ratio <= 0) {
return;
}
double maxY = ratio * info.height;
if (maxY <= info.yPosition) {
double maxY = ratio * info.getHeight();
if (maxY <= info.getyPosition()) {
// empty
return;
}
@@ -105,26 +105,24 @@ public class FillGauge implements IInfoRenderer, IResourceManagerReloadListener
Tessellator.instance.addTranslation((float) offset.x, (float) offset.y, (float) offset.z);
List<Vertex> verts = levelVertexCache.get(key);
if (maxY >= info.yPosition + 1) {
if (maxY >= info.getyPosition() + 1) {
// full bar
RenderUtil.addVerticesToTessellator(verts, Tessellator.instance);
} else {
// need to render partial bar
double myMaxY = maxY - info.yPosition;
double myMaxY = maxY - info.getyPosition();
if (info.type == Type.BOTTOM || info.type == Type.SINGLE) {
// If we have some power and we are the bottom bit of the display,
// always show at least a little bit in the bar
myMaxY = Math.max(0.2, myMaxY);
}
List<Vertex> newVerts = new ArrayList<Vertex>();
for (Vertex v : verts) {
v = new Vertex(v);
newVerts.add(v);
if (v.y() > myMaxY) {
v.setXYZ(v.x(), myMaxY, v.z());
v.setUV(v.u(), barMinV + (float) (myMaxY * barHeightV));
for (int i = 0; i < verts.size(); i++) {
newVerts[i].set(verts.get(i));
if (newVerts[i].y() > myMaxY) {
newVerts[i].setXYZ(newVerts[i].x(), myMaxY, newVerts[i].z());
newVerts[i].setUV(newVerts[i].u(), barMinV + (float) (myMaxY * barHeightV));
}
}
RenderUtil.addVerticesToTessellator(newVerts, Tessellator.instance);
@@ -136,7 +134,7 @@ public class FillGauge implements IInfoRenderer, IResourceManagerReloadListener
private GaugeInfo getGaugeInfo(TileCapBank cb, ForgeDirection dir) {
if (!cb.getType().isMultiblock()) {
return new GaugeInfo(1, 0);
return GaugeInfo.DEFAULT;
}
int height = 1;
@@ -240,8 +238,10 @@ public class FillGauge implements IInfoRenderer, IResourceManagerReloadListener
static class GaugeInfo {
int height;
int yPosition;
public static final GaugeInfo DEFAULT = new GaugeInfo(1, 0);
private int height;
private int yPosition;
Type type;
GaugeInfo(int height, int position) {
@@ -262,6 +262,14 @@ public class FillGauge implements IInfoRenderer, IResourceManagerReloadListener
}
return Type.MIDDLE;
}
public int getHeight() {
return height;
}
public int getyPosition() {
return yPosition;
}
}
static class GaugeKey {
@@ -21,6 +21,14 @@ import crazypants.enderio.machine.power.PowerDisplayUtil;
public class IoDisplay implements IInfoRenderer {
private float previousAverageInput;
private float previousAverageOutput;
String averageInputText = "0";
String averageOutputText = "0";
HeadingText heading1;
HeadingText heading2;
@Override
public void render(TileCapBank cb, ForgeDirection dir, double x, double y, double z, float partialTick) {
if (dir.offsetY != 0) {
@@ -137,10 +145,8 @@ public class IoDisplay implements IInfoRenderer {
nw.requestPowerUpdate(cb, 20);
HeadingText heading1 = HeadingText.STABLE;
HeadingText heading2 = null;
String text1;
String text2 = "";
heading1 = HeadingText.STABLE;
heading2 = null;
FontRenderer fr = Minecraft.getMinecraft().fontRenderer;
float size = 0.15f * Math.min(info.width, info.height);
@@ -150,8 +156,14 @@ public class IoDisplay implements IInfoRenderer {
if (info.height * 3 >= info.width * 4) {
heading1 = HeadingText.INPUT;
heading2 = HeadingText.OUTPUT;
text1 = getChangeText(nw.getAverageInputPerTick(), fr);
text2 = getChangeText(nw.getAverageOutputPerTick(), fr);
if (previousAverageInput != nw.getAverageInputPerTick()) {
averageInputText = getChangeText(nw.getAverageInputPerTick(), fr);
previousAverageInput = nw.getAverageInputPerTick();
}
if (previousAverageOutput != nw.getAverageOutputPerTick()) {
averageOutputText = getChangeText(nw.getAverageOutputPerTick(), fr);
previousAverageOutput = nw.getAverageOutputPerTick();
}
offset = -size * 2.5f;
} else {
int change = Math.round(nw.getAverageChangePerTick());
@@ -160,7 +172,10 @@ public class IoDisplay implements IInfoRenderer {
} else if (change < 0) {
heading1 = HeadingText.LOSS;
}
text1 = getChangeText(change, fr);
if (change != previousAverageInput) {
averageInputText = getChangeText(change, fr);
previousAverageInput = change;
}
offset = -size;
}
@@ -184,9 +199,9 @@ public class IoDisplay implements IInfoRenderer {
GL11.glDisable(GL11.GL_LIGHTING);
OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO);
offset = drawText(heading1, text1, offset, scale, size, fr);
offset = drawText(heading1, averageInputText, offset, scale, size, fr);
if (heading2 != null) {
drawText(heading2, text2, offset, scale, size, fr);
drawText(heading2, averageOutputText, offset, scale, size, fr);
}
GL11.glEnable(GL11.GL_LIGHTING);
@@ -29,6 +29,7 @@ public class PaintedBlockRenderer implements ISimpleBlockRenderingHandler, Threa
}
@Override
@Optional.Method(modid = "angelica")
public ThreadSafeISBRHFactory newInstance() {
return new PaintedBlockRenderer(renderId, defaultBlock);
}