Skip to content

Commit eb772b1

Browse files
committed
Fix texture mapping and rotation on modelblockmodels
1 parent ef0d882 commit eb772b1

File tree

6 files changed

+17
-20
lines changed

6 files changed

+17
-20
lines changed

core/src/main/java/org/dynmapblockscan/core/AbstractBlockScanBase.java

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -492,9 +492,9 @@ public void registerModelListModel(String blkname, StateRec state, List<BlockEle
492492
}
493493
// Get model list model
494494
ModelBlockModel mod = td.getModelBlockModelRec(blknm, state.keyValuePairs);
495-
// Loop over elements
496-
int imgidx = 0;
497-
int[] cuboididx = new int[6];
495+
// Start patch list
496+
ArrayList<String> textures = new ArrayList<String>();
497+
// Loop over elements
498498
for (BlockElement be : elems) {
499499
double xrot = 0, yrot = 0, zrot = 0;
500500
double[] origin = null;
@@ -516,8 +516,6 @@ else if (be.rotation.axis.equals("z")) {
516516
}
517517
ModelBlock modelem = mod.addModelBlock(be.from, be.to, xrot, yrot, zrot, be.shade, origin,
518518
be.modelrot.rotX, be.modelrot.rotY, be.modelrot.rotZ);
519-
// Initialize to no texture for each side
520-
for (int v = 0; v < cuboididx.length; v++) cuboididx[v] = -1;
521519
// Loop over the images for the element
522520
for (Entry<ElementFace, BlockFace> face : be.faces.entrySet()) {
523521
ElementFace facing = face.getKey();
@@ -534,18 +532,17 @@ else if (be.rotation.axis.equals("z")) {
534532
rot = SideRotation.DEG270;
535533
break;
536534
}
535+
int txtidx = -1;
537536
if (f.texture != null) {
538-
TextureFile gtf = td.registerTexture(f.texture);
539-
int faceidx = (360-f.rotation);
540-
if (!be.uvlock) {
541-
faceidx = faceidx + f.facerotation;
542-
}
543-
TextureModifier tm = TextureModifier.NONE;
544-
cuboididx[facing.ordinal()] = imgidx;
545-
btr.setPatchTexture(gtf, tm, imgidx);
546-
imgidx++;
537+
txtidx = textures.indexOf(f.texture); // See if already registered
538+
if (txtidx < 0) {
539+
txtidx = textures.size();
540+
textures.add(f.texture); // Add to list
541+
TextureFile gtf = td.registerTexture(f.texture); // Register if needed
542+
btr.setPatchTexture(gtf, TextureModifier.NONE, txtidx); // And set texture to assigned index
543+
}
547544
}
548-
modelem.addBlockSide(facing.side, f.uv, rot, cuboididx[facing.ordinal()], f.tintindex);
545+
modelem.addBlockSide(facing.side, f.uv, rot, txtidx, f.tintindex);
549546
}
550547
}
551548
}

forge-1.14.4/src/main/java/org/dynmapblockscan/forge_1_14_4/DynmapBlockScanPlugin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ public Map<String, String> fromBlockState(net.minecraft.block.BlockState bs) {
235235

236236
public static class OurLog implements BlockScanLog {
237237
Logger log;
238-
public static final String DM = "";
238+
public static final String DM = "[DynmapBlockScan] ";
239239
OurLog() {
240240
log = LogManager.getLogger("DynmapBlockScan");
241241
}

forge-1.15.2/src/main/java/org/dynmapblockscan/forge_1_15_2/DynmapBlockScanPlugin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ public Map<String, String> fromBlockState(net.minecraft.block.BlockState bs) {
235235

236236
public static class OurLog implements BlockScanLog {
237237
Logger log;
238-
public static final String DM = "";
238+
public static final String DM = "[DynmapBlockScan] ";
239239
OurLog() {
240240
log = LogManager.getLogger("DynmapBlockScan");
241241
}

forge-1.16.5/src/main/java/org/dynmapblockscan/forge_1_16_5/DynmapBlockScanPlugin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ public Map<String, String> fromBlockState(net.minecraft.block.BlockState bs) {
239239

240240
public static class OurLog implements BlockScanLog {
241241
Logger log;
242-
public static final String DM = "";
242+
public static final String DM = "[DynmapBlockScan] ";
243243
OurLog() {
244244
log = LogManager.getLogger("DynmapBlockScan");
245245
}

forge-1.17.1/src/main/java/org/dynmapblockscan/forge_1_17_1/DynmapBlockScanPlugin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ public ImmutableMap<String, String> fromBlockState(BlockState bs) {
241241

242242
public static class OurLog implements BlockScanLog {
243243
Logger log;
244-
public static final String DM = "";
244+
public static final String DM = "[DynmapBlockScan] ";
245245
OurLog() {
246246
log = LogManager.getLogger("DynmapBlockScan");
247247
}

forge-1.18/src/main/java/org/dynmapblockscan/forge_1_18/DynmapBlockScanPlugin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ public Map<String, String> fromBlockState(BlockState bs) {
237237

238238
public static class OurLog implements BlockScanLog {
239239
Logger log;
240-
public static final String DM = "";
240+
public static final String DM = "[DynmapBlockScan] ";
241241
OurLog() {
242242
log = LogManager.getLogger("DynmapBlockScan");
243243
}

0 commit comments

Comments
 (0)