mirror of
https://github.com/GTNewHorizons/ForgeMultipart.git
synced 2026-11-20 20:22:15 +00:00
refactor: port hollow microblock client to Java
This commit is contained in:
1 parent
c22d1ac895
commit
a50ce52cd3
6 files changed
+251
-284
No files matched your search
+7
-8
@@ -24,14 +24,13 @@ No trustworthy tool will produce a maintainable Java port automatically. A decom
|
||||
## Current status
|
||||
|
||||
Work continues on `algent/java`. The low-coupling queue, core part/tile types, registries, handlers, factories,
|
||||
placement/render helpers, both generators and all built-in tile traits are Java. Two files still contain generated
|
||||
microblock implementations in Scala, alongside the compiler/signature/analyser compatibility shells. The common,
|
||||
face, corner, edge, post and hollow server traits retain inheritance/bridge declarations over Java behavior.
|
||||
Composite generation,
|
||||
Java-trait rewriting and compiler startup also delegate to Java helpers. Abstract Java mixins and Java-path side-only
|
||||
filtering are complete; multiple Scala-trait inheritance still needs its metadata. The next bounded target is
|
||||
`HollowMicroblockClient` in `microblock/HollowMicroblockTraits.scala`. Retain the
|
||||
post lifecycle/super-dispatch bridges and the ScalaSignature path-dependent model bridges.
|
||||
placement/render helpers, both generators and all built-in tile traits are Java. Common, face, corner, edge, post
|
||||
and hollow microblock traits retain Scala inheritance/bridge declarations over Java behavior. The remaining
|
||||
microblock implementations are in `TMicroOcclusion.scala`, alongside the compiler/signature/analyser compatibility
|
||||
shells elsewhere. Java-trait rewriting and compiler startup also delegate to Java helpers. Abstract Java mixins and
|
||||
Java-path side-only filtering are complete; multiple Scala-trait inheritance still needs its metadata. Next:
|
||||
`TMicroOcclusion`, followed separately by `TMicroOcclusionClient`. Retain trait lifecycle/super-dispatch bridges and
|
||||
the ScalaSignature path-dependent model bridges.
|
||||
|
||||
Start with [JAVA_MIGRATION_HANDOFF.md](JAVA_MIGRATION_HANDOFF.md) for the exact source/test baseline, workflow and
|
||||
Java-source limitations. Read both the [ABI inventory](JAVA_MIGRATION_ABI_INVENTORY.md) and
|
||||
|
||||
+17
-16
@@ -16,23 +16,23 @@ migration checkout; `codex/tile-compatibility-fixes` was deleted after its fixes
|
||||
|
||||
## Current state and next target
|
||||
|
||||
**370 plain-JVM tests and 231 Java 8 Forge tests pass, with zero failures/errors/skips.** Sources total **221 Java
|
||||
files and 9 Scala files / 1,051 nonblank Scala lines**. The packaged inventory has 444 classes.
|
||||
**378 plain-JVM tests and 232 Java 8 Forge tests pass, with zero failures/errors/skips.** Sources total **222 Java
|
||||
files and 9 Scala files / 820 nonblank Scala lines**. The packaged inventory has 442 classes.
|
||||
|
||||
Latest bounded target: `HollowMicroblock` delegates connector lookup, geometry, collections and normal occlusion to
|
||||
`HollowMicroblockTraitLogic.java`. Scala retains inheritance metadata, `$class`, singleton/constants and its
|
||||
short-circuiting super bridge. Characterization was committed first as `6e807cc`: frozen Scala forwarders pin
|
||||
repeated tile/raw-shape reads, connector/slot dispatch, list mutability/copies and occlusion super ordering. Forge
|
||||
covers all 42 shapes, live opening sizes, bounds-array replacement/errors and NBT/description bytes. Clean checks
|
||||
preserve 441 retained class/member APIs, all 17 ScalaSignature payloads, 3,704 unrelated method bodies and all 116
|
||||
generated dumps. Two internal Scala callbacks become Java callbacks under the shared classfile policy. Evidence:
|
||||
`run/migration-hollow-trait-reference/`; `clean` preserves it.
|
||||
Latest bounded target: `HollowMicroblockClient` delegates rendering and mask updates to
|
||||
`HollowMicroblockClientLogic.java`. Scala retains inheritance metadata, `$class`, initialization and the recalculation
|
||||
super bridge. Characterization was committed first as `c22d1ac`: frozen Scala forwarders pin initialization/super
|
||||
ordering, render dispatch, rim bounds/masks/callback order, snapshots, breaking pipelines and highlight commands.
|
||||
Forge covers real materials, all 42 shapes and live center connectors. Clean checks preserve 439 retained
|
||||
class/member APIs, all 17 ScalaSignature payloads, 3,706 unrelated method bodies and all 116 generated dumps.
|
||||
Five internal Scala callbacks become two Java callbacks under the shared classfile policy. Evidence:
|
||||
`run/migration-hollow-client-reference/`; `clean` preserves it.
|
||||
|
||||
**Next: port `HollowMicroblockClient` in `microblock/HollowMicroblockTraits.scala`.** Characterize render-mask
|
||||
initialization/recalculation and super ordering, pass/transparency dispatch, rim geometry/callback order, breaking
|
||||
and highlight behavior before extraction. Actual client generation, GPU output and full-pack checks remain manual.
|
||||
Retain the Scala declarations where inheritance metadata is required, the external ProjectRed Scala-trait fixture
|
||||
and the ScalaSignature model bridges; compiler changes stay separate.
|
||||
**Next: port `TMicroOcclusion` in `microblock/TMicroOcclusion.scala`.** Characterize super-call short-circuiting,
|
||||
size/material/slot constraints, repeated virtual reads and edge/corner bit tests before extraction. Leave
|
||||
`TMicroOcclusionClient` lifecycle/state handling for a separate bounded target.
|
||||
Retain the Scala inheritance declarations, external ProjectRed Scala-trait fixture and ScalaSignature model bridges;
|
||||
compiler changes stay separate. Actual client generation, GPU output and full-pack checks remain manual.
|
||||
|
||||
Remaining Scala units:
|
||||
|
||||
@@ -42,7 +42,8 @@ Remaining Scala units:
|
||||
| `multipart/asm/ScalaSignature.scala` | Named models, primitive/erased bridges and five generic inner-construction branches |
|
||||
| `multipart/asm/StackAnalyser.scala` | Class/companion/model shell over Java `StackAnalyserLogic` |
|
||||
| `microblock/MicroblockTraits.scala`, `FaceMicroblockTraits.scala`, `CornerMicroblockTraits.scala`, `EdgeMicroblockTraits.scala` | Nine retained state/inheritance/bridge shells over Java implementation, including post lifecycle/super dispatch |
|
||||
| `microblock/HollowMicroblockTraits.scala`, `TMicroOcclusion.scala` | Hollow server shell plus remaining client/occlusion implementations; preserve inheritance metadata |
|
||||
| `microblock/HollowMicroblockTraits.scala` | Hollow server/client inheritance, initializer and super shells over Java behavior |
|
||||
| `microblock/TMicroOcclusion.scala` | Remaining occlusion and client lifecycle implementations; preserve inheritance metadata |
|
||||
|
||||
Both generators, both registries, core tile/part classes, ordinary microblock helpers/factories, handlers, networking,
|
||||
placement/render helpers and built-in tile traits are Java. The low-risk queue and immediate consumer gate are
|
||||
|
||||
@@ -42,7 +42,7 @@ Lamp Cover**, **Hollow Inverted White Lamp Cover**, **Inverted White Lamp Nook**
|
||||
| [ ] | Inspect face, hollow, edge and corner microblocks in inventory and as dropped entities | Every size/material combination uses the correct localized name and centered shape/material render | `ItemMicroPart` / `ItemMicroPartRenderer` / `MicroblockRender.renderItem` |
|
||||
| [ ] | Saw **Stone**, **Glass** and a ProjectRed **Inverted White Lamp** into face covers; place them on all six faces beside other microblocks, then inspect their inventory renders | Opaque covers retain their outer face while internal faces follow the shrink mask; transparent covers use the shrunk bounds, and inventory renders show the complete shape without missing or doubled faces | `FaceMicroblockClient.render` / `FaceMicroblockTraitLogic.render` |
|
||||
| [ ] | Saw **Stone**, **Glass** and a ProjectRed **Inverted White Lamp** into strip/post shapes; place crossing posts on all three axes between face covers, then add and remove neighbours | Compare both split segments with the reference, including the second segment's use of physical bounds; removal resets the split without stale geometry or missing sections | `PostMicroblockClient.recalcBounds` / `PostMicroblockClientLogic` / `shrinkFace` / `shrinkPost` |
|
||||
| [ ] | Run connected AE2 **ME Glass Cable**, **ME Covered Cable** and **ME Dense Smart Cable**, plus ProjectRed **Framed Red Alloy Wire**, through hollow stone/glass covers on all six faces | Each opening follows the connector size; opaque and transparent rims, breaking overlay and highlight have no missing, doubled or stale sections after neighbour changes | `HollowMicroblockClient.recalcBounds` / `renderHollow` / `drawBreaking` / `drawHighlight` |
|
||||
| [ ] | Run connected AE2 **ME Glass Cable**, **ME Covered Cable** and **ME Dense Smart Cable**, plus ProjectRed **Framed Red Alloy Wire**, through hollow stone/glass covers on all six faces | Each opening follows the connector size; opaque and transparent rims, breaking overlay and highlight have no missing, doubled or stale sections after neighbour changes | `HollowMicroblockClient` / `HollowMicroblockClientLogic` |
|
||||
| [ ] | Place touching face, corner and edge microblocks of mixed sizes/transparency, then add and remove neighbours | Intersections choose the same winner, opaque covered faces stay masked, and every surviving segment refreshes without gaps or stale bounds | `MicroOcclusion` / `TMicroOcclusionClient.recalcBounds` |
|
||||
|
||||
2026-09-03: Placing a ProjectRed part with `1.7.12-algent-java.186+60d060a3ff` crashed in
|
||||
|
||||
@@ -1190,3 +1190,30 @@ differences belong in the [divergence ledger](../../JAVA_MIGRATION_DIVERGENCES.m
|
||||
pass/transparency dispatch, rim geometry/callback order, breaking and highlight behavior before extraction.
|
||||
Added a manual hollow-cover interaction/reload check with ProjectRed Framed Red Alloy Wire and Hollow Inverted
|
||||
White Lamp Cover examples; actual client generation, GPU output and full-pack validation remain manual gates.
|
||||
|
||||
### 2026-09-04 — Hollow microblock client implementation
|
||||
|
||||
- Committed eight JVM and one Forge characterization tests first as `c22d1ac`, before changing production code.
|
||||
Frozen Scala 2.11.5 forwarders and a real superclass predecessor pin default-mask initialization, super/read order,
|
||||
arbitrary opening sizes, physical/transparent/opaque render selection, repeated slot reads, callback dispatch,
|
||||
all six ordered rim bounds/masks on every axis, material/coordinate/mask snapshots and failure short-circuiting.
|
||||
A child loader records only rendering-service calls while executing the real method bodies: breaking tests assert
|
||||
translation/icon pipelines and the cuboid callback; highlight tests assert GL state order, world/part transforms,
|
||||
expanded outlines and the original lack of cleanup after failure. Forge exercises real material/bounds factories,
|
||||
all 42 supported shapes and live center-connector sizes through the client helpers.
|
||||
- Extracted five method bodies to package-private `HollowMicroblockClientLogic.java`; retained Scala inheritance,
|
||||
`$class`, initializer and the synthetic recalculation super call. The Java helper accepts an existential `Function5`
|
||||
so the retained Scala method keeps its primitive function signature. Two named Java callbacks replace five internal
|
||||
Scala callbacks under the existing shared classfile policy. No new effective divergence or compiler algorithm fix
|
||||
was introduced; opening sizes, callback order and highlight failure behavior remain unchanged.
|
||||
- Saved source/reference jar, fixture compilation, reports and 116 generated dumps under ignored
|
||||
`run/migration-hollow-client-reference/`. Normal and clean verification after stopping Gradle preserve all 439
|
||||
retained class/member APIs, all 17 ScalaSignature payloads, 3,706 unrelated method bodies and all 116 generated
|
||||
names/hashes. The helper and two callbacks replace five Scala callbacks: 444 -> 442 packaged classes. Formatting,
|
||||
checkstyle, build and Forge pass with 378 JVM / 232 Forge tests, zero failures/errors/skips. The forced Scala
|
||||
compilation guard and all five packaged `@Mod` versions remain verified. Sources total 222 Java files and
|
||||
9 Scala files / 820 nonblank Scala lines.
|
||||
- Next: `TMicroOcclusion`; characterize super short-circuiting, size/material/slot constraints, repeated reads and
|
||||
edge/corner bit tests before extraction. Leave `TMicroOcclusionClient` for a separate target. Existing manual checks
|
||||
cover AE2 cables and ProjectRed Framed Red Alloy Wire through hollow covers. Recorded rendering commands and
|
||||
headless helper tests do not validate actual client generation or GPU/full-pack output.
|
||||
@@ -0,0 +1,180 @@
|
||||
package codechicken.microblock;
|
||||
|
||||
import static org.lwjgl.opengl.GL11.*;
|
||||
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
|
||||
import codechicken.lib.render.BlockRenderer;
|
||||
import codechicken.lib.render.CCRenderState;
|
||||
import codechicken.lib.render.RenderUtils;
|
||||
import codechicken.lib.render.uv.IconTransformation;
|
||||
import codechicken.lib.vec.Cuboid6;
|
||||
import codechicken.lib.vec.Rotation;
|
||||
import codechicken.lib.vec.Translation;
|
||||
import codechicken.lib.vec.Vector3;
|
||||
import codechicken.microblock.MicroMaterialRegistry.IMicroMaterial;
|
||||
import codechicken.multipart.TMultiPart;
|
||||
import scala.Function5;
|
||||
import scala.MatchError;
|
||||
import scala.runtime.AbstractFunction5;
|
||||
import scala.runtime.BoxedUnit;
|
||||
import scala.runtime.BoxesRunTime;
|
||||
|
||||
/** Client rendering behind the retained Scala inheritance metadata, initializer and super bridge. */
|
||||
final class HollowMicroblockClientLogic {
|
||||
|
||||
private HollowMicroblockClientLogic() {}
|
||||
|
||||
static void updateRenderMask(HollowMicroblockClient part) {
|
||||
part.renderMask_$eq(part.renderMask() & 0xff | part.getHollowSize() << 8);
|
||||
}
|
||||
|
||||
static void drawBreaking(HollowMicroblockClient part, RenderBlocks renderBlocks) {
|
||||
CCRenderState state = CCRenderState.instance();
|
||||
state.resetInstance();
|
||||
TMultiPart base = (TMultiPart) part;
|
||||
state.setPipelineInstance(
|
||||
new Translation(base.x(), base.y(), base.z()),
|
||||
new IconTransformation(renderBlocks.overrideBlockTexture));
|
||||
part.renderHollow(null, 0, part.getBounds(), 0, false, new BreakingCuboid());
|
||||
}
|
||||
|
||||
static void render(HollowMicroblockClient part, Vector3 pos, int pass) {
|
||||
if (pass == -1) {
|
||||
part.renderHollow(pos, pass, part.getBounds(), 0, false, new RenderCuboid());
|
||||
} else if (((Microblock) part).isTransparent()) {
|
||||
part.renderHollow(pos, pass, part.renderBounds(), part.renderMask(), false, new RenderCuboid());
|
||||
} else {
|
||||
part.renderHollow(
|
||||
pos,
|
||||
pass,
|
||||
part.renderBounds(),
|
||||
part.renderMask() | 1 << part.getSlot(),
|
||||
false,
|
||||
new RenderCuboid());
|
||||
part.renderHollow(pos, pass, Cuboid6.full, ~(1 << part.getSlot()), true, new RenderCuboid());
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
static void renderHollow(HollowMicroblockClient part, Vector3 pos, int pass, Cuboid6 c, int sideMask, boolean face,
|
||||
Function5<?, ?, ?, ?, ?, ?> callback) {
|
||||
Function5 f = callback;
|
||||
IMicroMaterial material = ((Microblock) part).getIMaterial();
|
||||
int size = part.renderMask() >> 8;
|
||||
double d1 = 0.5 - size / 32D;
|
||||
double d2 = 0.5 + size / 32D;
|
||||
double x1 = c.min.x;
|
||||
double x2 = c.max.x;
|
||||
double y1 = c.min.y;
|
||||
double y2 = c.max.y;
|
||||
double z1 = c.min.z;
|
||||
double z2 = c.max.z;
|
||||
int slot = part.getSlot();
|
||||
int internalMask = 0;
|
||||
switch (slot) {
|
||||
case 0:
|
||||
case 1:
|
||||
if (face) internalMask = 0x3c;
|
||||
f.apply(pos, material, pass, new Cuboid6(d1, y1, d2, d2, y2, z2), 0x3b | internalMask);
|
||||
f.apply(pos, material, pass, new Cuboid6(d1, y1, z1, d2, y2, d1), 0x37 | internalMask);
|
||||
f.apply(pos, material, pass, new Cuboid6(d2, y1, d1, x2, y2, d2), sideMask & 0x23 | 0xc | internalMask);
|
||||
f.apply(pos, material, pass, new Cuboid6(x1, y1, d1, d1, y2, d2), sideMask & 0x13 | 0xc | internalMask);
|
||||
f.apply(pos, material, pass, new Cuboid6(x1, y1, d2, x2, y2, z2), sideMask & 0x3b | 4 | internalMask);
|
||||
f.apply(pos, material, pass, new Cuboid6(x1, y1, z1, x2, y2, d1), sideMask & 0x37 | 8 | internalMask);
|
||||
break;
|
||||
case 2:
|
||||
case 3:
|
||||
if (face) internalMask = 0x33;
|
||||
f.apply(pos, material, pass, new Cuboid6(d2, d1, z1, x2, d2, z2), 0x2f | internalMask);
|
||||
f.apply(pos, material, pass, new Cuboid6(x1, d1, z1, d1, d2, z2), 0x1f | internalMask);
|
||||
f.apply(pos, material, pass, new Cuboid6(d1, d2, z1, d2, y2, z2), sideMask & 0xe | 0x30 | internalMask);
|
||||
f.apply(pos, material, pass, new Cuboid6(d1, y1, z1, d2, d1, z2), sideMask & 0xd | 0x30 | internalMask);
|
||||
f.apply(
|
||||
pos,
|
||||
material,
|
||||
pass,
|
||||
new Cuboid6(d2, y1, z1, x2, y2, z2),
|
||||
sideMask & 0x2f | 0x10 | internalMask);
|
||||
f.apply(
|
||||
pos,
|
||||
material,
|
||||
pass,
|
||||
new Cuboid6(x1, y1, z1, d1, y2, z2),
|
||||
sideMask & 0x1f | 0x20 | internalMask);
|
||||
break;
|
||||
case 4:
|
||||
case 5:
|
||||
if (face) internalMask = 0xf;
|
||||
f.apply(pos, material, pass, new Cuboid6(x1, d2, d1, x2, y2, d2), 0x3e | internalMask);
|
||||
f.apply(pos, material, pass, new Cuboid6(x1, y1, d1, x2, d1, d2), 0x3d | internalMask);
|
||||
f.apply(pos, material, pass, new Cuboid6(x1, d1, d2, x2, d2, z2), sideMask & 0x38 | 3 | internalMask);
|
||||
f.apply(pos, material, pass, new Cuboid6(x1, d1, z1, x2, d2, d1), sideMask & 0x34 | 3 | internalMask);
|
||||
f.apply(pos, material, pass, new Cuboid6(x1, d2, z1, x2, y2, z2), sideMask & 0x3e | 1 | internalMask);
|
||||
f.apply(pos, material, pass, new Cuboid6(x1, y1, z1, x2, d1, z2), sideMask & 0x3d | 2 | internalMask);
|
||||
break;
|
||||
default:
|
||||
throw new MatchError(slot);
|
||||
}
|
||||
}
|
||||
|
||||
static boolean drawHighlight(HollowMicroblockClient part, MovingObjectPosition hit, EntityPlayer player,
|
||||
float frame) {
|
||||
int size = part.getHollowSize();
|
||||
double d1 = 0.5 - size / 32D;
|
||||
double d2 = 0.5 + size / 32D;
|
||||
double thickness = (((Microblock) part).shape() >> 4) / 8D;
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glColor4f(0, 0, 0, 0.4F);
|
||||
glLineWidth(2);
|
||||
glDepthMask(false);
|
||||
glPushMatrix();
|
||||
RenderUtils.translateToWorldCoords(player, frame);
|
||||
TMultiPart base = (TMultiPart) part;
|
||||
glTranslated(base.x(), base.y(), base.z());
|
||||
Rotation.sideRotations[((Microblock) part).shape() & 15].at(Vector3.center).glApply();
|
||||
RenderUtils.drawCuboidOutline(new Cuboid6(0, 0, 0, 1, thickness, 1).expand(0.001));
|
||||
RenderUtils.drawCuboidOutline(new Cuboid6(d1, 0, d1, d2, thickness, d2).expand(-0.001));
|
||||
glPopMatrix();
|
||||
glDepthMask(true);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glDisable(GL_BLEND);
|
||||
return true;
|
||||
}
|
||||
|
||||
private static final class RenderCuboid
|
||||
extends AbstractFunction5<Vector3, IMicroMaterial, Object, Cuboid6, Object, BoxedUnit>
|
||||
implements scala.Serializable {
|
||||
|
||||
private static final long serialVersionUID = 0L;
|
||||
|
||||
RenderCuboid() {}
|
||||
|
||||
@Override
|
||||
public BoxedUnit apply(Vector3 pos, IMicroMaterial material, Object pass, Cuboid6 box, Object mask) {
|
||||
MicroblockRender
|
||||
.renderCuboid(pos, material, BoxesRunTime.unboxToInt(pass), box, BoxesRunTime.unboxToInt(mask));
|
||||
return BoxedUnit.UNIT;
|
||||
}
|
||||
}
|
||||
|
||||
private static final class BreakingCuboid
|
||||
extends AbstractFunction5<Vector3, IMicroMaterial, Object, Cuboid6, Object, BoxedUnit>
|
||||
implements scala.Serializable {
|
||||
|
||||
private static final long serialVersionUID = 0L;
|
||||
|
||||
BreakingCuboid() {}
|
||||
|
||||
@Override
|
||||
public BoxedUnit apply(Vector3 pos, IMicroMaterial material, Object pass, Cuboid6 box, Object mask) {
|
||||
BoxesRunTime.unboxToInt(pass);
|
||||
BlockRenderer.renderCuboid(box, BoxesRunTime.unboxToInt(mask));
|
||||
return BoxedUnit.UNIT;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,20 +2,10 @@ package codechicken.microblock
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer
|
||||
import net.minecraft.util.MovingObjectPosition
|
||||
import codechicken.multipart.TFacePart
|
||||
import codechicken.multipart.TMultiPart
|
||||
import codechicken.lib.vec.{Translation, Cuboid6, Rotation, Vector3}
|
||||
import codechicken.multipart.TNormalOcclusion
|
||||
import codechicken.multipart.NormalOcclusionTest
|
||||
import codechicken.microblock.MicroMaterialRegistry.IMicroMaterial
|
||||
import net.minecraft.client.renderer.RenderBlocks
|
||||
import codechicken.lib.render.{BlockRenderer, RenderUtils, CCRenderState}
|
||||
import scala.collection.JavaConversions._
|
||||
import Rotation._
|
||||
import Vector3._
|
||||
import codechicken.lib.raytracer.IndexedCuboid6
|
||||
import org.lwjgl.opengl.GL11
|
||||
import codechicken.lib.render.uv.IconTransformation
|
||||
import codechicken.multipart.{TFacePart, TMultiPart, TNormalOcclusion}
|
||||
import codechicken.lib.vec.{Cuboid6, Vector3}
|
||||
import codechicken.microblock.MicroMaterialRegistry.IMicroMaterial
|
||||
|
||||
trait HollowMicroblockClient
|
||||
extends HollowMicroblock
|
||||
@@ -24,70 +14,14 @@ trait HollowMicroblockClient
|
||||
|
||||
override def recalcBounds() {
|
||||
super.recalcBounds()
|
||||
renderMask = renderMask & 0xff | getHollowSize << 8
|
||||
HollowMicroblockClientLogic.updateRenderMask(this)
|
||||
}
|
||||
|
||||
override def drawBreaking(renderBlocks: RenderBlocks) {
|
||||
val state = CCRenderState.instance
|
||||
state.resetInstance()
|
||||
state.setPipelineInstance(
|
||||
new Translation(x, y, z),
|
||||
new IconTransformation(renderBlocks.overrideBlockTexture)
|
||||
)
|
||||
renderHollow(
|
||||
null,
|
||||
0,
|
||||
getBounds,
|
||||
0,
|
||||
false,
|
||||
(
|
||||
pos: Vector3,
|
||||
mat: IMicroMaterial,
|
||||
pass: Int,
|
||||
c: Cuboid6,
|
||||
sideMask: Int
|
||||
) => BlockRenderer.renderCuboid(c, sideMask)
|
||||
)
|
||||
}
|
||||
override def drawBreaking(renderBlocks: RenderBlocks) =
|
||||
HollowMicroblockClientLogic.drawBreaking(this, renderBlocks)
|
||||
|
||||
override def render(pos: Vector3, pass: Int) {
|
||||
if (pass == -1)
|
||||
renderHollow(
|
||||
pos,
|
||||
pass,
|
||||
getBounds,
|
||||
0,
|
||||
false,
|
||||
MicroblockRender.renderCuboid
|
||||
)
|
||||
else if (isTransparent)
|
||||
renderHollow(
|
||||
pos,
|
||||
pass,
|
||||
renderBounds,
|
||||
renderMask,
|
||||
false,
|
||||
MicroblockRender.renderCuboid
|
||||
)
|
||||
else {
|
||||
renderHollow(
|
||||
pos,
|
||||
pass,
|
||||
renderBounds,
|
||||
renderMask | 1 << getSlot,
|
||||
false,
|
||||
MicroblockRender.renderCuboid
|
||||
)
|
||||
renderHollow(
|
||||
pos,
|
||||
pass,
|
||||
Cuboid6.full,
|
||||
~(1 << getSlot),
|
||||
true,
|
||||
MicroblockRender.renderCuboid
|
||||
)
|
||||
}
|
||||
}
|
||||
override def render(pos: Vector3, pass: Int) =
|
||||
HollowMicroblockClientLogic.render(this, pos, pass)
|
||||
|
||||
def renderHollow(
|
||||
pos: Vector3,
|
||||
@@ -96,196 +30,22 @@ trait HollowMicroblockClient
|
||||
sideMask: Int,
|
||||
face: Boolean,
|
||||
f: (Vector3, IMicroMaterial, Int, Cuboid6, Int) => Unit
|
||||
) {
|
||||
val mat = getIMaterial
|
||||
val size = renderMask >> 8
|
||||
val d1 = 0.5 - size / 32d
|
||||
val d2 = 0.5 + size / 32d
|
||||
val x1 = c.min.x
|
||||
val x2 = c.max.x
|
||||
val y1 = c.min.y
|
||||
val y2 = c.max.y
|
||||
val z1 = c.min.z
|
||||
val z2 = c.max.z
|
||||
|
||||
var iMask = 0
|
||||
getSlot match {
|
||||
case 0 | 1 =>
|
||||
if (face)
|
||||
iMask = 0x3c
|
||||
f(
|
||||
pos,
|
||||
mat,
|
||||
pass,
|
||||
new Cuboid6(d1, y1, d2, d2, y2, z2),
|
||||
0x3b | iMask
|
||||
) // -z internal
|
||||
f(
|
||||
pos,
|
||||
mat,
|
||||
pass,
|
||||
new Cuboid6(d1, y1, z1, d2, y2, d1),
|
||||
0x37 | iMask
|
||||
) // +z internal
|
||||
|
||||
f(
|
||||
pos,
|
||||
mat,
|
||||
pass,
|
||||
new Cuboid6(d2, y1, d1, x2, y2, d2),
|
||||
sideMask & 0x23 | 0xc | iMask
|
||||
) // -x internal -y+y+x external
|
||||
f(
|
||||
pos,
|
||||
mat,
|
||||
pass,
|
||||
new Cuboid6(x1, y1, d1, d1, y2, d2),
|
||||
sideMask & 0x13 | 0xc | iMask
|
||||
) // +x internal -y+y-x external
|
||||
|
||||
f(
|
||||
pos,
|
||||
mat,
|
||||
pass,
|
||||
new Cuboid6(x1, y1, d2, x2, y2, z2),
|
||||
sideMask & 0x3b | 4 | iMask
|
||||
) // -y+y+z-x+x external
|
||||
f(
|
||||
pos,
|
||||
mat,
|
||||
pass,
|
||||
new Cuboid6(x1, y1, z1, x2, y2, d1),
|
||||
sideMask & 0x37 | 8 | iMask
|
||||
) // -y+y-z-x+x external
|
||||
case 2 | 3 =>
|
||||
if (face)
|
||||
iMask = 0x33
|
||||
f(
|
||||
pos,
|
||||
mat,
|
||||
pass,
|
||||
new Cuboid6(d2, d1, z1, x2, d2, z2),
|
||||
0x2f | iMask
|
||||
) // -x internal
|
||||
f(
|
||||
pos,
|
||||
mat,
|
||||
pass,
|
||||
new Cuboid6(x1, d1, z1, d1, d2, z2),
|
||||
0x1f | iMask
|
||||
) // +x internal
|
||||
|
||||
f(
|
||||
pos,
|
||||
mat,
|
||||
pass,
|
||||
new Cuboid6(d1, d2, z1, d2, y2, z2),
|
||||
sideMask & 0xe | 0x30 | iMask
|
||||
) // -y internal -z+z+y external
|
||||
f(
|
||||
pos,
|
||||
mat,
|
||||
pass,
|
||||
new Cuboid6(d1, y1, z1, d2, d1, z2),
|
||||
sideMask & 0xd | 0x30 | iMask
|
||||
) // +y internal -z+z-y external
|
||||
|
||||
f(
|
||||
pos,
|
||||
mat,
|
||||
pass,
|
||||
new Cuboid6(d2, y1, z1, x2, y2, z2),
|
||||
sideMask & 0x2f | 0x10 | iMask
|
||||
) // -z+z+x-y+y external
|
||||
f(
|
||||
pos,
|
||||
mat,
|
||||
pass,
|
||||
new Cuboid6(x1, y1, z1, d1, y2, z2),
|
||||
sideMask & 0x1f | 0x20 | iMask
|
||||
) // -z+z-x-y+y external
|
||||
case 4 | 5 =>
|
||||
if (face)
|
||||
iMask = 0xf
|
||||
f(
|
||||
pos,
|
||||
mat,
|
||||
pass,
|
||||
new Cuboid6(x1, d2, d1, x2, y2, d2),
|
||||
0x3e | iMask
|
||||
) // -y internal
|
||||
f(
|
||||
pos,
|
||||
mat,
|
||||
pass,
|
||||
new Cuboid6(x1, y1, d1, x2, d1, d2),
|
||||
0x3d | iMask
|
||||
) // +y internal
|
||||
|
||||
f(
|
||||
pos,
|
||||
mat,
|
||||
pass,
|
||||
new Cuboid6(x1, d1, d2, x2, d2, z2),
|
||||
sideMask & 0x38 | 3 | iMask
|
||||
) // -z internal -x+x+z external
|
||||
f(
|
||||
pos,
|
||||
mat,
|
||||
pass,
|
||||
new Cuboid6(x1, d1, z1, x2, d2, d1),
|
||||
sideMask & 0x34 | 3 | iMask
|
||||
) // +z internal -x+x-z external
|
||||
|
||||
f(
|
||||
pos,
|
||||
mat,
|
||||
pass,
|
||||
new Cuboid6(x1, d2, z1, x2, y2, z2),
|
||||
sideMask & 0x3e | 1 | iMask
|
||||
) // -x+x+y-z+z external
|
||||
f(
|
||||
pos,
|
||||
mat,
|
||||
pass,
|
||||
new Cuboid6(x1, y1, z1, x2, d1, z2),
|
||||
sideMask & 0x3d | 2 | iMask
|
||||
) // -x+x-y-z+z external
|
||||
}
|
||||
}
|
||||
) = HollowMicroblockClientLogic.renderHollow(
|
||||
this,
|
||||
pos,
|
||||
pass,
|
||||
c,
|
||||
sideMask,
|
||||
face,
|
||||
f
|
||||
)
|
||||
|
||||
override def drawHighlight(
|
||||
hit: MovingObjectPosition,
|
||||
player: EntityPlayer,
|
||||
frame: Float
|
||||
): Boolean = {
|
||||
val size = getHollowSize
|
||||
val d1 = 0.5 - size / 32d
|
||||
val d2 = 0.5 + size / 32d
|
||||
val t = (shape >> 4) / 8d
|
||||
|
||||
import GL11._
|
||||
glEnable(GL_BLEND)
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
|
||||
glDisable(GL_TEXTURE_2D)
|
||||
glColor4f(0, 0, 0, 0.4f)
|
||||
glLineWidth(2)
|
||||
glDepthMask(false)
|
||||
glPushMatrix()
|
||||
RenderUtils.translateToWorldCoords(player, frame)
|
||||
glTranslated(x, y, z)
|
||||
sideRotations(shape & 0xf).at(center).glApply()
|
||||
|
||||
RenderUtils.drawCuboidOutline(new Cuboid6(0, 0, 0, 1, t, 1).expand(0.001))
|
||||
RenderUtils.drawCuboidOutline(
|
||||
new Cuboid6(d1, 0, d1, d2, t, d2).expand(-0.001)
|
||||
)
|
||||
glPopMatrix()
|
||||
glDepthMask(true)
|
||||
glEnable(GL_TEXTURE_2D)
|
||||
glDisable(GL_BLEND)
|
||||
return true
|
||||
}
|
||||
): Boolean =
|
||||
HollowMicroblockClientLogic.drawHighlight(this, hit, player, frame)
|
||||
}
|
||||
|
||||
trait HollowMicroblock
|
||||
|
||||
Reference in new issue
Block a user