Skip to content

Commit a448a36

Browse files
committed
Switch over to new modsupport APIs
1 parent 48b5104 commit a448a36

16 files changed

+44
-1386
lines changed

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

Lines changed: 3 additions & 142 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import java.util.Map;
1717
import java.util.Set;
1818
import java.util.Map.Entry;
19-
import java.util.logging.Logger;
2019
import java.util.zip.ZipEntry;
2120
import java.util.zip.ZipFile;
2221

@@ -43,18 +42,9 @@
4342
import org.dynmapblockscan.core.model.BlockElement;
4443
import org.dynmapblockscan.core.model.BlockFace;
4544
import org.dynmapblockscan.core.model.BlockModel;
46-
import org.dynmapblockscan.core.statehandlers.BedMetadataStateHandler;
47-
import org.dynmapblockscan.core.statehandlers.DoorStateHandler;
48-
import org.dynmapblockscan.core.statehandlers.GateMetadataStateHandler;
4945
import org.dynmapblockscan.core.statehandlers.IStateHandler;
5046
import org.dynmapblockscan.core.statehandlers.IStateHandlerFactory;
51-
import org.dynmapblockscan.core.statehandlers.NSEWConnectedMetadataStateHandler;
52-
import org.dynmapblockscan.core.statehandlers.NSEWUConnectedMetadataStateHandler;
53-
import org.dynmapblockscan.core.statehandlers.PistonMetadataStateHandler;
54-
import org.dynmapblockscan.core.statehandlers.RedstoneWireStateHandler;
5547
import org.dynmapblockscan.core.statehandlers.SimpleMetadataStateHandler;
56-
import org.dynmapblockscan.core.statehandlers.SnowyMetadataStateHandler;
57-
import org.dynmapblockscan.core.statehandlers.StairMetadataStateHandler;
5848
import org.dynmapblockscan.core.statehandlers.StateContainer;
5949
import org.dynmapblockscan.core.statehandlers.StateContainer.StateRec;
6050
import org.dynmapblockscan.core.statehandlers.StateContainer.WellKnownBlockClasses;
@@ -73,19 +63,9 @@ public abstract class AbstractBlockScanBase {
7363
public static boolean verboselogging = false;
7464
protected BlockStateOverrides overrides;
7565

76-
private Gson gson = new GsonBuilder().setPrettyPrinting().create();
66+
//private Gson gson = new GsonBuilder().setPrettyPrinting().create();
7767

7868
protected IStateHandlerFactory[] state_handler = {
79-
new NSEWConnectedMetadataStateHandler(),
80-
new NSEWUConnectedMetadataStateHandler(),
81-
new RedstoneWireStateHandler(),
82-
new GateMetadataStateHandler(),
83-
new StairMetadataStateHandler(),
84-
new DoorStateHandler(),
85-
new PistonMetadataStateHandler(),
86-
new SnowyMetadataStateHandler(),
87-
new BedMetadataStateHandler(),
88-
new SimpleMetadataStateHandler(true),
8969
new SimpleMetadataStateHandler(false)
9070
};
9171

@@ -460,113 +440,6 @@ public void registerSimpleDynmapCubes(String blkname, StateRec state, BlockEleme
460440
}
461441
}
462442

463-
public boolean isSimpleCuboid(List<BlockElement> elements) {
464-
for (BlockElement be : elements) {
465-
if (be.isSimpleCuboid() == false) {
466-
return false;
467-
}
468-
}
469-
return true;
470-
}
471-
472-
public void registerSimpleDynmapCuboids(String blkname, StateRec state, List<BlockElement> elems, WellKnownBlockClasses type) {
473-
String[] tok = blkname.split(":");
474-
String modid = tok[0];
475-
String blknm = tok[1];
476-
if (tok[0].equals("minecraft")) { // Skip vanilla
477-
return;
478-
}
479-
// Get record for mod
480-
ModDynmapRec td = getModRec(modid);
481-
// Create block texture record
482-
BlockTextureRecord btr = td.getBlockTxtRec(blknm,state.keyValuePairs);
483-
if (btr == null) {
484-
return;
485-
}
486-
// Check for tinting and/or culling
487-
boolean tinting = false; // Watch out for tinting
488-
boolean culling = false;
489-
for (BlockElement be : elems) {
490-
for (BlockFace f : be.faces.values()) {
491-
if (f.tintindex >= 0) {
492-
tinting = true;
493-
break;
494-
}
495-
if (f.cullface != null) {
496-
culling = true;
497-
}
498-
}
499-
}
500-
// Set to transparent (or semitransparent if culling)
501-
if (culling) {
502-
btr.setTransparencyMode(TransparencyMode.SEMITRANSPARENT);
503-
}
504-
else {
505-
btr.setTransparencyMode(TransparencyMode.TRANSPARENT);
506-
}
507-
// If block has tinting, try to figure out what to use
508-
if (tinting) {
509-
String txtfile = null;
510-
BlockTintOverride ovr = overrides.getTinting(modid, blknm, state.getProperties());
511-
if (ovr == null) { // No match, need to guess
512-
switch (type) {
513-
case LEAVES:
514-
case VINES:
515-
txtfile = "minecraft:colormap/foliage";
516-
break;
517-
default:
518-
txtfile = "minecraft:colormap/grass";
519-
break;
520-
}
521-
}
522-
else {
523-
txtfile = ovr.colormap[0];
524-
}
525-
if (txtfile != null) {
526-
TextureFile gtf = td.registerBiomeTexture(txtfile);
527-
btr.setBlockColorMapTexture(gtf);
528-
}
529-
}
530-
// Get cuboid model
531-
CuboidBlockModel mod = td.getCuboidModelRec(blknm, state.keyValuePairs);
532-
// Loop over elements
533-
int imgidx = 0;
534-
int[] cuboididx = new int[6];
535-
for (BlockElement be : elems) {
536-
// Initialize to no texture for each side
537-
for (int v = 0; v < cuboididx.length; v++) cuboididx[v] = -1;
538-
// Loop over the images for the element
539-
for (Entry<ElementFace, BlockFace> face : be.faces.entrySet()) {
540-
ElementFace facing = face.getKey();
541-
BlockFace f = face.getValue();
542-
if (f.texture != null) {
543-
TextureFile gtf = td.registerTexture(f.texture);
544-
int faceidx = (360-f.rotation);
545-
if (!be.uvlock) {
546-
faceidx = faceidx + f.facerotation;
547-
}
548-
TextureModifier tm = TextureModifier.NONE;
549-
switch (faceidx % 360) {
550-
case 90:
551-
tm = TextureModifier.ROT90;
552-
break;
553-
case 180:
554-
tm = TextureModifier.ROT180;
555-
break;
556-
case 270:
557-
tm = TextureModifier.ROT270;
558-
break;
559-
}
560-
cuboididx[facing.ordinal()] = imgidx;
561-
btr.setPatchTexture(gtf, tm, imgidx);
562-
imgidx++;
563-
}
564-
}
565-
// Add cuboid element to model
566-
mod.addCuboid(be.from[0]/16.0, be.from[1]/16.0, be.from[2]/16.0, be.to[0]/16.0, be.to[1]/16.0, be.to[2]/16.0, cuboididx);
567-
}
568-
}
569-
570443
public void registerModelListModel(String blkname, StateRec state, List<BlockElement> elems, WellKnownBlockClasses type) {
571444
String[] tok = blkname.split(":");
572445
String modid = tok[0];
@@ -649,7 +522,8 @@ else if (be.rotation.axis.equals("z")) {
649522
}
650523
}
651524
}
652-
ModelBlock modelem = mod.addModelBlock(be.from, be.to, xrot, yrot, zrot, be.shade, origin);
525+
ModelBlock modelem = mod.addModelBlock(be.from, be.to, xrot, yrot, zrot, be.shade, origin,
526+
be.modelrot.rotX, be.modelrot.rotY, be.modelrot.rotZ);
653527
// Initialize to no texture for each side
654528
for (int v = 0; v < cuboididx.length; v++) cuboididx[v] = -1;
655529
// Loop over the images for the element
@@ -968,19 +842,6 @@ protected void resolveAllElements(Map<String, BlockRecord> blockRecords, Map<Str
968842
registerModelListModel(blkname, var.getKey(), elems, br.sc.getBlockType());
969843
}
970844
}
971-
// // Else if simple cuboid
972-
// else if (isSimpleCuboid(elems)) {
973-
// if (br.handler != null) {
974-
// //logger.info(String.format("%s: %s is simple block with %s map", blkname, var.getKey(), br.handler.getName()));
975-
// registerSimpleDynmapCuboids(blkname, var.getKey(), elems, br.sc.getBlockType());
976-
// }
977-
// }
978-
// else {
979-
// if (br.handler != null) {
980-
// //logger.info(String.format("%s: %s is simple block with %s map", blkname, var.getKey(), br.handler.getName()));
981-
// registerDynmapPatches(blkname, var.getKey(), elems, br.sc.getBlockType());
982-
// }
983-
// }
984845
}
985846
}
986847
}

core/src/main/java/org/dynmapblockscan/core/blockstate/BSBlockState.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import java.util.Set;
1010
import java.util.Map.Entry;
1111

12-
import org.dynmapblockscan.core.AbstractBlockScanBase;
1312
import org.dynmapblockscan.core.blockstate.BSBlockState;
1413
import org.dynmapblockscan.core.model.BlockModel;
1514

core/src/main/java/org/dynmapblockscan/core/blockstate/BaseCondition.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package org.dynmapblockscan.core.blockstate;
22

3-
import java.util.Arrays;
43
import java.util.HashMap;
54
import java.util.Map;
65
import java.util.Set;

core/src/main/java/org/dynmapblockscan/core/blockstate/ForgeVariantV1.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public class ForgeVariantV1 {
2424
public Map<String, String> textures = new HashMap<String, String>();
2525
public Integer x;
2626
public Integer y;
27+
public Integer z;
2728
public Boolean uvlock;
2829
public Integer weight;
2930
public Boolean smooth_lighting;
@@ -58,6 +59,9 @@ public String toString() {
5859
if ((y != null) && (y != 0)) {
5960
sb.append(",y=").append(y);
6061
}
62+
if ((z != null) && (z != 0)) {
63+
sb.append(",z=").append(y);
64+
}
6165
if ((uvlock != null) && uvlock.booleanValue()) {
6266
sb.append(",uvlock=true");
6367
}
@@ -92,6 +96,9 @@ public ForgeVariantV1 deserialize(JsonElement element, Type type, JsonDeserializ
9296
if (jobj.has("y")) {
9397
v.y = context.deserialize(jobj.get("y"), Integer.class);
9498
}
99+
if (jobj.has("z")) {
100+
v.z = context.deserialize(jobj.get("z"), Integer.class);
101+
}
95102
if (jobj.has("uvlock")) {
96103
v.uvlock = context.deserialize(jobj.get("uvlock"), Boolean.class);
97104
}
@@ -144,6 +151,9 @@ public void applyValues(ForgeVariantV1 src, boolean no_submodels) {
144151
if (this.y == null) {
145152
this.y = src.y;
146153
}
154+
if (this.z == null) {
155+
this.z = src.z;
156+
}
147157
if (this.uvlock == null) {
148158
this.uvlock = src.uvlock;
149159
}
@@ -217,7 +227,7 @@ public Variant generateVanilla(Map<String, BlockModel> models) {
217227
mod = "dynmapblockscan:forgemodel" + idx;
218228
}
219229
// Now build vanilla variant
220-
Variant var = new Variant(mod, this.x, this.y, this.uvlock, this.weight);
230+
Variant var = new Variant(mod, this.x, this.y, this.z, this.uvlock, this.weight);
221231
// Now, do same for submodels : add them to list for variant
222232
if (this.submodel != null) {
223233
List<Variant> vlist = new ArrayList<Variant>();

0 commit comments

Comments
 (0)