Compare commits

...
4 Commits
Author SHA1 Message Date
tth05 ea4f68d163 Add map to provide fast access to all config tags in sub-tree (#18) 2024-07-18 21:37:30 +07:00
Dream Master 549f769747 update 2024-07-17 16:47:04 +07:00
Caedis cba2e0f642 Fix casing 2024-07-04 00:30:22 -07:00
Jason Mitchell 3740253590 Maybe more backwards compatible (#16)
* Maybe more backwards compatible
2024-07-03 11:21:27 -07:00
17 changed files with 180 additions and 120 deletions

No files matched your search

+3
View File
@@ -55,6 +55,9 @@ generateGradleTokenClass = codechicken.core.asm.Tags
# Name of the token containing the project's current version to generate/replace. # Name of the token containing the project's current version to generate/replace.
gradleTokenVersion = VERSION gradleTokenVersion = VERSION
# [DEPRECATED] Mod Group replacement token.
gradleTokenGroupName =
# [DEPRECATED] # [DEPRECATED]
# Multiple source files can be defined here by providing a comma-separated list: Class1.java,Class2.java,Class3.java # Multiple source files can be defined here by providing a comma-separated list: Class1.java,Class2.java,Class3.java
# public static final String VERSION = "GRADLETOKEN_VERSION"; # public static final String VERSION = "GRADLETOKEN_VERSION";
Binary file not shown.
Vendored
+1 -1
View File
@@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop. # Darwin, MinGW, and NonStop.
# #
# (3) This script is generated from the Groovy template # (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project. # within the Gradle project.
# #
# You can find Gradle at https://github.com/gradle/gradle/. # You can find Gradle at https://github.com/gradle/gradle/.
@@ -119,11 +119,9 @@ public class RedirectorTransformer implements IClassTransformer {
changed = true; changed = true;
} }
} else if (node.getOpcode() == Opcodes.INVOKESTATIC && node instanceof MethodInsnNode mNode) { } else if (node instanceof MethodInsnNode mNode) {
if (redirectedMethods.contains(mNode.name) && mNode.owner.equals(RenderStateClass)) { if (node.getOpcode() == Opcodes.INVOKESTATIC && redirectedSimpleMethods.contains(mNode.name)
mNode.name = mNode.name + "Static"; && mNode.owner.equals(RenderStateClass)) {
changed = true;
} else if (redirectedSimpleMethods.contains(mNode.name) && mNode.owner.equals(RenderStateClass)) {
mn.instructions.insertBefore( mn.instructions.insertBefore(
mNode, mNode,
new MethodInsnNode( new MethodInsnNode(
@@ -132,8 +130,15 @@ public class RedirectorTransformer implements IClassTransformer {
"instance", "instance",
"()Lcodechicken/lib/render/CCRenderState;")); "()Lcodechicken/lib/render/CCRenderState;"));
mNode.setOpcode(Opcodes.INVOKEVIRTUAL); mNode.setOpcode(Opcodes.INVOKEVIRTUAL);
mNode.name = mNode.name + "Instance";
changed = true; changed = true;
} } else if (node.getOpcode() == Opcodes.INVOKEVIRTUAL && mNode.owner.equals(RenderStateClass)
&& (redirectedSimpleMethods.contains(mNode.name)
|| redirectedMethods.contains(mNode.name))) {
// Handle mods that updated to previously new API
mNode.name = mNode.name + "Instance";
changed = true;
}
} }
} }
} }
@@ -6,8 +6,10 @@ import java.io.PrintWriter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Objects;
import java.util.TreeMap; import java.util.TreeMap;
public abstract class ConfigTagParent { public abstract class ConfigTagParent {
@@ -21,25 +23,30 @@ public abstract class ConfigTagParent {
} }
public int compare(ConfigTag o1, ConfigTag o2) { public int compare(ConfigTag o1, ConfigTag o2) {
if (o1.position != o2.position) return compareInt(o1.position, o2.position); if (o1.position != o2.position) return Integer.compare(o1.position, o2.position);
if (o1.brace != o2.brace) return o1.brace ? 1 : -1; // braced one goes after if (o1.brace != o2.brace) return o1.brace ? 1 : -1; // braced one goes after
switch (sortMode) {
case 1: if (sortMode == 1) {
if (o1.value == o2.value) return 0; if (Objects.equals(o1.value, o2.value)) return 0;
if (o1.value == null) return 1; if (o1.value == null) return 1;
if (o2.value == null) return -1; if (o2.value == null) return -1;
return o1.value.compareTo(o2.value); return o1.value.compareTo(o2.value);
default: } else {
return o1.name.compareTo(o2.name); return o1.name.compareTo(o2.name);
} }
} }
private int compareInt(int a, int b) {
return a == b ? 0 : a < b ? -1 : 1;
}
} }
private TreeMap<String, ConfigTag> childtags = new TreeMap<String, ConfigTag>(); /**
* The immediate child tags of this tag
*/
private final TreeMap<String, ConfigTag> childtags = new TreeMap<>();
/**
* A map of all tags in the tree, meaning all tags in this tag and all tags in child tags (recursively). Allows for
* quick access to any tag in the tree, without the need to traverse the tree part by part.
*/
private final Map<String, ConfigTag> allTagsInTree = new HashMap<>();
public String comment; public String comment;
/** /**
* 0 = name, 1 = value * 0 = name, 1 = value
@@ -88,7 +95,7 @@ public abstract class ConfigTagParent {
} }
public boolean containsTag(String tagname) { public boolean containsTag(String tagname) {
return getTag(tagname, false) != null; return allTagsInTree.get(tagname) != null;
} }
public ConfigTag getNewTag(String tagname) { public ConfigTag getNewTag(String tagname) {
@@ -96,6 +103,12 @@ public abstract class ConfigTagParent {
} }
public ConfigTag getTag(String tagname, boolean create) { public ConfigTag getTag(String tagname, boolean create) {
ConfigTag tag = allTagsInTree.get(tagname);
if (tag == null && create) return getTagRecursive(tagname, create);
return tag;
}
public ConfigTag getTagRecursive(String tagname, boolean create) {
int dotpos = tagname.indexOf("."); int dotpos = tagname.indexOf(".");
String basetagname = dotpos == -1 ? tagname : tagname.substring(0, dotpos); String basetagname = dotpos == -1 ? tagname : tagname.substring(0, dotpos);
ConfigTag basetag = childtags.get(basetagname); ConfigTag basetag = childtags.get(basetagname);
@@ -115,6 +128,8 @@ public abstract class ConfigTagParent {
} }
public boolean removeTag(String tagname) { public boolean removeTag(String tagname) {
removeChildFromFlatMap(tagname);
ConfigTag tag = getTag(tagname, false); ConfigTag tag = getTag(tagname, false);
if (tag == null) return false; if (tag == null) return false;
@@ -131,6 +146,22 @@ public abstract class ConfigTagParent {
public void addChild(ConfigTag tag) { public void addChild(ConfigTag tag) {
childtags.put(tag.name, tag); childtags.put(tag.name, tag);
addChildToFlatMap(tag.name, tag);
}
private void addChildToFlatMap(String path, ConfigTag tag) {
allTagsInTree.put(path, tag);
// Stupid cast but these two garbage classes are interlinked anyway
if ((this instanceof ConfigTag t) && t.parent != null) t.parent.addChildToFlatMap(t.name + "." + path, tag);
}
private void removeChildFromFlatMap(String path) {
allTagsInTree.remove(path);
// Stupid cast but these two garbage classes are interlinked anyway
if ((this instanceof ConfigTag t) && t.parent != null) t.parent.removeChildFromFlatMap(t.name + "." + path);
} }
public <T extends ConfigTag> ArrayList<T> getSortedTagList() { public <T extends ConfigTag> ArrayList<T> getSortedTagList() {
@@ -64,15 +64,15 @@ public class Canvas9Seg {
public void draw(CCRenderState state, int x, int y, int w, int h) { public void draw(CCRenderState state, int x, int y, int w, int h) {
CCRenderState.changeTexture(tex); CCRenderState.changeTexture(tex);
state.reset(); state.resetInstance();
state.startDrawing(); state.startDrawingInstance();
int[] sw = new int[] { x, x + seg_w[0], x + w - seg_w[2], x + w }; int[] sw = new int[] { x, x + seg_w[0], x + w - seg_w[2], x + w };
int[] sh = new int[] { y, y + seg_h[0], y + h - seg_h[2], y + h }; int[] sh = new int[] { y, y + seg_h[0], y + h - seg_h[2], y + h };
for (int seg = 0; seg < 9; seg++) drawSeg(sw, sh, seg); for (int seg = 0; seg < 9; seg++) drawSeg(sw, sh, seg);
state.draw(); state.drawInstance();
} }
public void draw(int x, int y, int w, int h) { public void draw(int x, int y, int w, int h) {
@@ -128,8 +128,8 @@ public class LightMatrix implements CCRenderState.IVertexOperation {
float[] a = ao(lc.side); float[] a = ao(lc.side);
float f = (a[0] * lc.fa + a[1] * lc.fb + a[2] * lc.fc + a[3] * lc.fd); float f = (a[0] * lc.fa + a[1] * lc.fb + a[2] * lc.fc + a[3] * lc.fd);
int[] b = brightness(lc.side); int[] b = brightness(lc.side);
state.setColour(ColourRGBA.multiplyC(state.colour, f)); state.setColourInstance(ColourRGBA.multiplyC(state.colour, f));
state.setBrightness((int) (b[0] * lc.fa + b[1] * lc.fb + b[2] * lc.fc + b[3] * lc.fd) & 0xFF00FF); state.setBrightnessInstance((int) (b[0] * lc.fa + b[1] * lc.fb + b[2] * lc.fc + b[3] * lc.fd) & 0xFF00FF);
} }
@Override @Override
@@ -88,7 +88,7 @@ public class LightModel implements CCRenderState.IVertexOperation {
@Override @Override
public void operate(CCRenderState state) { public void operate(CCRenderState state) {
state.setColour(apply(state.colour, state.normal)); state.setColourInstance(apply(state.colour, state.normal));
} }
@Override @Override
@@ -47,7 +47,7 @@ public class PlanarLightMatrix extends PlanarLightModel {
@Override @Override
public void operate(CCRenderState state) { public void operate(CCRenderState state) {
super.operate(state); super.operate(state);
state.setBrightness(brightness(state.side)); state.setBrightnessInstance(brightness(state.side));
} }
@Override @Override
@@ -27,7 +27,7 @@ public class PlanarLightModel implements CCRenderState.IVertexOperation {
@Override @Override
public void operate(CCRenderState state) { public void operate(CCRenderState state) {
state.setColour(ColourRGBA.multiply(state.colour, colours[state.side])); state.setColourInstance(ColourRGBA.multiply(state.colour, colours[state.side]));
} }
@Override @Override
@@ -46,7 +46,7 @@ public class SimpleBrightnessModel implements CCRenderState.IVertexOperation {
@Override @Override
public void operate(CCRenderState state) { public void operate(CCRenderState state) {
state.setBrightness(sample(state.side)); state.setBrightnessInstance(sample(state.side));
} }
@Override @Override
@@ -154,7 +154,7 @@ public class BlockRenderer {
// public static void renderFullBlock(int sideMask) { // public static void renderFullBlock(int sideMask) {
public static void renderFullBlock(CCRenderState state, int sideMask) { public static void renderFullBlock(CCRenderState state, int sideMask) {
state.setModel(fullBlock); state.setModelInstance(fullBlock);
renderFaces(state, sideMask); renderFaces(state, sideMask);
} }
@@ -171,8 +171,8 @@ public class BlockRenderer {
public static void renderFaces(CCRenderState state, int sideMask) { public static void renderFaces(CCRenderState state, int sideMask) {
if (sideMask == 0x3F) return; if (sideMask == 0x3F) return;
for (int s = 0; s < 6; s++) if ((sideMask & 1 << s) == 0) { for (int s = 0; s < 6; s++) if ((sideMask & 1 << s) == 0) {
state.setVertexRange(s * 4, (s + 1) * 4); state.setVertexRangeInstance(s * 4, (s + 1) * 4);
state.render(); state.renderInstance();
} }
} }
@@ -191,10 +191,10 @@ public class BlockRenderer {
public static void renderCuboid(CCRenderState state, Cuboid6 bounds, int sideMask) { public static void renderCuboid(CCRenderState state, Cuboid6 bounds, int sideMask) {
if (sideMask == 0x3F) return; if (sideMask == 0x3F) return;
state.setModel(face); state.setModelInstance(face);
for (int s = 0; s < 6; s++) if ((sideMask & 1 << s) == 0) { for (int s = 0; s < 6; s++) if ((sideMask & 1 << s) == 0) {
face.loadCuboidFace(bounds, s); face.loadCuboidFace(bounds, s);
state.render(); state.renderInstance();
} }
} }
@@ -467,8 +467,8 @@ public class CCModel implements CCRenderState.IVertexSource, Copyable<CCModel> {
* @param ops Operations to apply * @param ops Operations to apply
*/ */
public void render(CCRenderState state, int start, int end, CCRenderState.IVertexOperation... ops) { public void render(CCRenderState state, int start, int end, CCRenderState.IVertexOperation... ops) {
state.setPipeline(this, start, end, ops); state.setPipelineInstance(this, start, end, ops);
state.render(); state.renderInstance();
} }
public void render(int start, int end, CCRenderState.IVertexOperation... ops) { public void render(int start, int end, CCRenderState.IVertexOperation... ops) {
@@ -49,7 +49,7 @@ public class CCRenderPipeline {
public void render() { public void render() {
rebuild(); rebuild();
renderState.render(); renderState.renderInstance();
} }
} }
@@ -101,7 +101,7 @@ public class CCRenderState {
/** /**
* Management class for a vertex attrute such as colour, normal etc This class should handle the loading of the * Management class for a vertex attrute such as colour, normal etc This class should handle the loading of the
* attrute from an array provided by IVertexSource.getAttributes or the computation of this attrute from others * attrute from an array provided by IVertexSource.getAttributes or the computation of this attrute from others
* *
* @param <T> The array type for this attrute eg. int[], Vector3[] * @param <T> The array type for this attrute eg. int[], Vector3[]
*/ */
public abstract static class VertexAttribute<T> implements IVertexOperation { public abstract static class VertexAttribute<T> implements IVertexOperation {
@@ -146,7 +146,7 @@ public class CCRenderState {
/** /**
* Gets an array of vertex attrutes * Gets an array of vertex attrutes
* *
* @param attr The vertex attrute to get * @param attr The vertex attrute to get
* @param <T> The attrute array type * @param <T> The attrute array type
* @return An array, or null if not computed * @return An array, or null if not computed
@@ -193,8 +193,8 @@ public class CCRenderState {
@Override @Override
public void operate(CCRenderState state) { public void operate(CCRenderState state) {
if (normalRef != null) state.setNormal(normalRef[state.vertexIndex]); if (normalRef != null) state.setNormalInstance(normalRef[state.vertexIndex]);
else state.setNormal(Rotation.axes[state.side]); else state.setNormalInstance(Rotation.axes[state.side]);
} }
}; };
public static VertexAttribute<int[]> colourAttrib = new VertexAttribute<>() { public static VertexAttribute<int[]> colourAttrib = new VertexAttribute<>() {
@@ -214,8 +214,9 @@ public class CCRenderState {
@Override @Override
public void operate(CCRenderState state) { public void operate(CCRenderState state) {
if (colourRef != null) state.setColour(ColourRGBA.multiply(state.baseColour, colourRef[state.vertexIndex])); if (colourRef != null)
else state.setColour(state.baseColour); state.setColourInstance(ColourRGBA.multiply(state.baseColour, colourRef[state.vertexIndex]));
else state.setColourInstance(state.baseColour);
} }
}; };
public static VertexAttribute<int[]> lightingAttrib = new VertexAttribute<>() { public static VertexAttribute<int[]> lightingAttrib = new VertexAttribute<>() {
@@ -241,7 +242,7 @@ public class CCRenderState {
@Override @Override
public void operate(CCRenderState state) { public void operate(CCRenderState state) {
state.setColour(ColourRGBA.multiply(state.colour, colourRef[state.vertexIndex])); state.setColourInstance(ColourRGBA.multiply(state.colour, colourRef[state.vertexIndex]));
} }
}; };
public static VertexAttribute<int[]> sideAttrib = new VertexAttribute<>() { public static VertexAttribute<int[]> sideAttrib = new VertexAttribute<>() {
@@ -326,11 +327,15 @@ public class CCRenderState {
public boolean hasBrightness; public boolean hasBrightness;
public int brightness; public int brightness;
// attrute storage // attribute storage
public int side; public int side;
public LC lc = new LC(); public LC lc = new LC();
public void reset() { public static void reset() {
instance().resetInstance();
}
public void resetInstance() {
model = null; model = null;
pipeline.reset(); pipeline.reset();
useNormals = hasNormal = hasBrightness = hasColour = false; useNormals = hasNormal = hasBrightness = hasColour = false;
@@ -338,27 +343,27 @@ public class CCRenderState {
baseColour = alphaOverride = -1; baseColour = alphaOverride = -1;
} }
public void setPipeline(IVertexOperation... ops) { public void setPipelineInstance(IVertexOperation... ops) {
pipeline.setPipeline(ops); pipeline.setPipeline(ops);
} }
@Deprecated @Deprecated
public static void setPipelineStatic(IVertexOperation... ops) { public static void setPipeline(IVertexOperation... ops) {
instance().setPipeline(ops); instance().setPipelineInstance(ops);
} }
public void setPipeline(IVertexSource model, int start, int end, IVertexOperation... ops) { public void setPipelineInstance(IVertexSource model, int start, int end, IVertexOperation... ops) {
pipeline.reset(); pipeline.reset();
setModel(model, start, end); setModelInstance(model, start, end);
pipeline.setPipeline(ops); pipeline.setPipeline(ops);
} }
@Deprecated @Deprecated
public static void setPipelineStatic(IVertexSource model, int start, int end, IVertexOperation... ops) { public static void setPipeline(IVertexSource model, int start, int end, IVertexOperation... ops) {
instance().setPipeline(model, start, end, ops); instance().setPipelineInstance(model, start, end, ops);
} }
public void bindModel(IVertexSource model) { public void bindModelInstance(IVertexSource model) {
if (this.model != model) { if (this.model != model) {
this.model = model; this.model = model;
pipeline.rebuild(); pipeline.rebuild();
@@ -366,74 +371,74 @@ public class CCRenderState {
} }
@Deprecated @Deprecated
public static void bindModelStatic(IVertexSource model) { public static void bindModel(IVertexSource model) {
instance().bindModel(model); instance().bindModelInstance(model);
} }
public void setModel(IVertexSource source) { public void setModelInstance(IVertexSource source) {
setModel(source, 0, source.getVertices().length); setModelInstance(source, 0, source.getVertices().length);
} }
@Deprecated @Deprecated
public static void setModelStatic(IVertexSource source) { public static void setModel(IVertexSource source) {
instance().setModel(source); instance().setModelInstance(source);
} }
public void setModel(IVertexSource source, int start, int end) { public void setModelInstance(IVertexSource source, int start, int end) {
bindModel(source); bindModelInstance(source);
setVertexRange(start, end); setVertexRangeInstance(start, end);
} }
@Deprecated @Deprecated
public static void setModelStatic(IVertexSource source, int start, int end) { public static void setModel(IVertexSource source, int start, int end) {
instance().setModel(source, start, end); instance().setModelInstance(source, start, end);
} }
public void setVertexRange(int start, int end) { public void setVertexRangeInstance(int start, int end) {
firstVertexIndex = start; firstVertexIndex = start;
lastVertexIndex = end; lastVertexIndex = end;
} }
@Deprecated @Deprecated
public static void setVertexRangeStatic(int start, int end) { public static void setVertexRange(int start, int end) {
instance().setVertexRange(start, end); instance().setVertexRangeInstance(start, end);
} }
public void render(IVertexOperation... ops) { public void renderInstance(IVertexOperation... ops) {
setPipeline(ops); setPipelineInstance(ops);
render(); renderInstance();
} }
@Deprecated @Deprecated
public static void renderStatic(IVertexOperation... ops) { public static void render(IVertexOperation... ops) {
instance().render(ops); instance().renderInstance(ops);
} }
public void render() { public void renderInstance() {
Vertex5[] verts = model.getVertices(); Vertex5[] verts = model.getVertices();
for (vertexIndex = firstVertexIndex; vertexIndex < lastVertexIndex; vertexIndex++) { for (vertexIndex = firstVertexIndex; vertexIndex < lastVertexIndex; vertexIndex++) {
model.prepareVertex(this); model.prepareVertex(this);
vert.set(verts[vertexIndex]); vert.set(verts[vertexIndex]);
runPipeline(); runPipelineInstance();
writeVert(); writeVertInstance();
} }
} }
@Deprecated @Deprecated
public static void renderStatic() { public static void render() {
instance().render(); instance().renderInstance();
} }
public void runPipeline() { public void runPipelineInstance() {
pipeline.operate(); pipeline.operate();
} }
@Deprecated @Deprecated
public static void runPipelineStatic() { public static void runPipeline() {
instance().runPipeline(); instance().runPipelineInstance();
} }
public void writeVert() { public void writeVertInstance() {
if (hasNormal) Tessellator.instance.setNormal((float) normal.x, (float) normal.y, (float) normal.z); if (hasNormal) Tessellator.instance.setNormal((float) normal.x, (float) normal.y, (float) normal.z);
if (hasColour) Tessellator.instance.setColorRGBA( if (hasColour) Tessellator.instance.setColorRGBA(
colour >>> 24, colour >>> 24,
@@ -445,71 +450,83 @@ public class CCRenderState {
} }
@Deprecated @Deprecated
public static void writeVertStatic() { public static void writeVert() {
instance().writeVert(); instance().writeVertInstance();
} }
public void setNormal(double x, double y, double z) { public void setNormalInstance(double x, double y, double z) {
hasNormal = true; hasNormal = true;
normal.set(x, y, z); normal.set(x, y, z);
} }
@Deprecated @Deprecated
public static void setNormalStatic(double x, double y, double z) { public static void setNormal(double x, double y, double z) {
instance().setNormal(x, y, z); instance().setNormalInstance(x, y, z);
} }
public void setNormal(Vector3 n) { public void setNormalInstance(Vector3 n) {
hasNormal = true; hasNormal = true;
normal.set(n); normal.set(n);
} }
@Deprecated @Deprecated
public static void setNormalStatic(Vector3 n) { public static void setNormal(Vector3 n) {
instance().setNormal(n); instance().setNormalInstance(n);
} }
public void setColour(int c) { public void setColourInstance(int c) {
hasColour = true; hasColour = true;
colour = c; colour = c;
} }
@Deprecated @Deprecated
public static void setColourStatic(int c) { public static void setColour(int c) {
instance().setColour(c); instance().setColourInstance(c);
} }
public void setBrightness(int b) { public void setBrightnessInstance(int b) {
hasBrightness = true; hasBrightness = true;
brightness = b; brightness = b;
} }
@Deprecated @Deprecated
public static void setBrightnessStatic(int b) { public static void setBrightness(int b) {
instance().setBrightness(b); instance().setBrightnessInstance(b);
} }
public void setBrightness(IBlockAccess world, int x, int y, int z) { public void setBrightnessInstance(IBlockAccess world, int x, int y, int z) {
setBrightness(world.getBlock(x, y, z).getMixedBrightnessForBlock(world, x, y, z)); setBrightnessInstance(world.getBlock(x, y, z).getMixedBrightnessForBlock(world, x, y, z));
} }
@Deprecated @Deprecated
public static void setBrightnessStatic(IBlockAccess world, int x, int y, int z) { public static void setBrightness(IBlockAccess world, int x, int y, int z) {
instance().setBrightness(world, x, y, z); instance().setBrightnessInstance(world, x, y, z);
} }
public void pullLightmap() { public static void pullLightmap() {
setBrightness((int) OpenGlHelper.lastBrightnessY << 16 | (int) OpenGlHelper.lastBrightnessX); instance().pullLightmapInstance();
} }
public void pushLightmap() { public void pullLightmapInstance() {
setBrightnessInstance((int) OpenGlHelper.lastBrightnessY << 16 | (int) OpenGlHelper.lastBrightnessX);
}
public static void pushLightmap() {
instance().pushLightmapInstance();
}
public void pushLightmapInstance() {
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, brightness & 0xFFFF, brightness >>> 16); OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, brightness & 0xFFFF, brightness >>> 16);
} }
/** /**
* Compact helper for setting dynamic rendering context. Uses normals and doesn't compute lighting * Compact helper for setting dynamic rendering context. Uses normals and doesn't compute lighting
*/ */
public void setDynamic() { public static void setDynamic() {
instance().setDynamicInstance();
}
public void setDynamicInstance() {
useNormals = true; useNormals = true;
computeLighting = false; computeLighting = false;
} }
@@ -522,16 +539,16 @@ public class CCRenderState {
Minecraft.getMinecraft().renderEngine.bindTexture(texture); Minecraft.getMinecraft().renderEngine.bindTexture(texture);
} }
public void startDrawing() { public void startDrawingInstance() {
startDrawing(7); startDrawingInstance(7);
} }
@Deprecated @Deprecated
public static void startDrawingStatic() { public static void startDrawing() {
instance().startDrawing(); instance().startDrawingInstance();
} }
public void startDrawing(int mode) { public void startDrawingInstance(int mode) {
Tessellator.instance.startDrawing(mode); Tessellator.instance.startDrawing(mode);
if (hasColour) Tessellator.instance.setColorRGBA( if (hasColour) Tessellator.instance.setColorRGBA(
colour >>> 24, colour >>> 24,
@@ -542,11 +559,15 @@ public class CCRenderState {
} }
@Deprecated @Deprecated
public static void startDrawingStatic(int mode) { public static void startDrawing(int mode) {
instance().startDrawing(mode); instance().startDrawingInstance(mode);
} }
public void draw() { public static void draw() {
Tessellator.instance.draw();
}
public void drawInstance() {
Tessellator.instance.draw(); Tessellator.instance.draw();
} }
} }
@@ -23,7 +23,7 @@ public class ColourMultiplier implements CCRenderState.IVertexOperation {
@Override @Override
public boolean load(CCRenderState state) { public boolean load(CCRenderState state) {
if (colour == -1) { if (colour == -1) {
state.setColour(-1); state.setColourInstance(-1);
return false; return false;
} }
@@ -33,7 +33,7 @@ public class ColourMultiplier implements CCRenderState.IVertexOperation {
@Override @Override
public void operate(CCRenderState state) { public void operate(CCRenderState state) {
state.setColour(ColourRGBA.multiply(state.colour, colour)); state.setColourInstance(ColourRGBA.multiply(state.colour, colour));
} }
@Override @Override
@@ -259,7 +259,7 @@ public class RenderUtils {
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
Fluid fluid = stack.getFluid(); Fluid fluid = stack.getFluid();
state.setColour(fluid.getColor(stack) << 8 | alpha); state.setColourInstance(fluid.getColor(stack) << 8 | alpha);
TextureUtils.bindAtlas(fluid.getSpriteNumber()); TextureUtils.bindAtlas(fluid.getSpriteNumber());
return TextureUtils.safeIcon(fluid.getIcon(stack)); return TextureUtils.safeIcon(fluid.getIcon(stack));
} }
@@ -300,9 +300,9 @@ public class RenderUtils {
else bound.max.y = bound.min.y + (bound.max.y - bound.min.y) * density; else bound.max.y = bound.min.y + (bound.max.y - bound.min.y) * density;
IIcon tex = prepareFluidRender(state, stack, alpha); IIcon tex = prepareFluidRender(state, stack, alpha);
state.startDrawing(); state.startDrawingInstance();
renderFluidCuboid(state, bound, tex, res); renderFluidCuboid(state, bound, tex, res);
state.draw(); state.drawInstance();
postFluidRender(); postFluidRender();
} }
@@ -323,14 +323,14 @@ public class RenderUtils {
} }
IIcon tex = prepareFluidRender(state, stack, alpha); IIcon tex = prepareFluidRender(state, stack, alpha);
state.startDrawing(); state.startDrawingInstance();
renderFluidQuad( renderFluidQuad(
new Vector3(rect.x, rect.y + rect.h, 0), new Vector3(rect.x, rect.y + rect.h, 0),
new Vector3(rect.w, 0, 0), new Vector3(rect.w, 0, 0),
new Vector3(0, -rect.h, 0), new Vector3(0, -rect.h, 0),
tex, tex,
res); res);
state.draw(); state.drawInstance();
postFluidRender(); postFluidRender();
} }