mirror of
https://github.com/webbukkit/dynmap.git
synced 2024-11-24 03:05:28 +01:00
More fixes and enhancements for modsupport API
This commit is contained in:
parent
a2f8f9defa
commit
611832fa22
@ -150,6 +150,8 @@ public abstract class BlockModelImpl implements BlockModel {
|
|||||||
// If we have state data, favor this
|
// If we have state data, favor this
|
||||||
if (this.blockstates != null) {
|
if (this.blockstates != null) {
|
||||||
for (Map<String, String> rec : this.blockstates) {
|
for (Map<String, String> rec : this.blockstates) {
|
||||||
|
// If no state, skip
|
||||||
|
if (rec.size() == 0) { continue; }
|
||||||
s += ",state=";
|
s += ",state=";
|
||||||
boolean first = true;
|
boolean first = true;
|
||||||
for (Entry<String, String> r : rec.entrySet()) {
|
for (Entry<String, String> r : rec.entrySet()) {
|
||||||
|
@ -533,6 +533,7 @@ public class BlockTextureRecordImpl implements BlockTextureRecord {
|
|||||||
// If we have state data, favor this
|
// If we have state data, favor this
|
||||||
if (this.blockstates != null) {
|
if (this.blockstates != null) {
|
||||||
for (Map<String, String> rec : this.blockstates) {
|
for (Map<String, String> rec : this.blockstates) {
|
||||||
|
if (rec.size() == 0) { continue; } // Skip if none
|
||||||
s += ",state=";
|
s += ",state=";
|
||||||
boolean first = true;
|
boolean first = true;
|
||||||
for (Entry<String, String> r : rec.entrySet()) {
|
for (Entry<String, String> r : rec.entrySet()) {
|
||||||
|
@ -191,6 +191,7 @@ public class CopyBlockTextureRecordImpl implements CopyBlockTextureRecord {
|
|||||||
// If we have state data, favor this
|
// If we have state data, favor this
|
||||||
if (this.blockstates != null) {
|
if (this.blockstates != null) {
|
||||||
for (Map<String, String> rec : this.blockstates) {
|
for (Map<String, String> rec : this.blockstates) {
|
||||||
|
if (rec.size() == 0) { continue; } // Skip if none
|
||||||
s += ",state=";
|
s += ",state=";
|
||||||
boolean first = true;
|
boolean first = true;
|
||||||
for (Entry<String, String> r : rec.entrySet()) {
|
for (Entry<String, String> r : rec.entrySet()) {
|
||||||
|
@ -22,6 +22,7 @@ public class ModelBlockModelImpl extends BlockModelImpl implements ModelBlockMod
|
|||||||
private double[] to = { 16, 16, 16 };
|
private double[] to = { 16, 16, 16 };
|
||||||
private double xrot = 0, yrot = 0, zrot = 0;
|
private double xrot = 0, yrot = 0, zrot = 0;
|
||||||
private boolean shade;
|
private boolean shade;
|
||||||
|
private double[] rotorigin;
|
||||||
@Override
|
@Override
|
||||||
public void addBlockSide(BlockSide side, double[] uv, SideRotation rot, int textureid, int tintidx) {
|
public void addBlockSide(BlockSide side, double[] uv, SideRotation rot, int textureid, int tintidx) {
|
||||||
ModelSide ms = new ModelSide();
|
ModelSide ms = new ModelSide();
|
||||||
@ -77,9 +78,10 @@ public class ModelBlockModelImpl extends BlockModelImpl implements ModelBlockMod
|
|||||||
public String getLine() {
|
public String getLine() {
|
||||||
String ids = this.getIDsAndMeta();
|
String ids = this.getIDsAndMeta();
|
||||||
if (ids == null) return null;
|
if (ids == null) return null;
|
||||||
String line = String.format("patchblock:%s", ids);
|
String line;
|
||||||
// If rotating another model
|
// If rotating another model
|
||||||
if (rotsourceblockname != null) {
|
if (rotsourceblockname != null) {
|
||||||
|
line = String.format("patchblock:%s", ids);
|
||||||
line += "\npatchrotate:id=" + rotsourceblockname;
|
line += "\npatchrotate:id=" + rotsourceblockname;
|
||||||
if (rotsourcestatemap != null) {
|
if (rotsourcestatemap != null) {
|
||||||
line += ",state=";
|
line += ",state=";
|
||||||
@ -105,6 +107,7 @@ public class ModelBlockModelImpl extends BlockModelImpl implements ModelBlockMod
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
line = String.format("modellist:%s", ids);
|
||||||
for (ModelBlockImpl mb: boxes) {
|
for (ModelBlockImpl mb: boxes) {
|
||||||
line += String.format(",box=%f/%f/%f", mb.from[0], mb.from[1], mb.from[2]);
|
line += String.format(",box=%f/%f/%f", mb.from[0], mb.from[1], mb.from[2]);
|
||||||
if (!mb.shade) { // if shade=false
|
if (!mb.shade) { // if shade=false
|
||||||
@ -113,6 +116,10 @@ public class ModelBlockModelImpl extends BlockModelImpl implements ModelBlockMod
|
|||||||
line += String.format(":%f/%f/%f", mb.to[0], mb.to[1], mb.to[2]);
|
line += String.format(":%f/%f/%f", mb.to[0], mb.to[1], mb.to[2]);
|
||||||
if ((mb.xrot != 0) || (mb.yrot != 0) || (mb.zrot != 0)) { // If needed, add rotation
|
if ((mb.xrot != 0) || (mb.yrot != 0) || (mb.zrot != 0)) { // If needed, add rotation
|
||||||
line += String.format("/%f/%f/%f", mb.xrot, mb.yrot, mb.zrot);
|
line += String.format("/%f/%f/%f", mb.xrot, mb.yrot, mb.zrot);
|
||||||
|
// If origin also defined, add it
|
||||||
|
if (mb.rotorigin != null) {
|
||||||
|
line += String.format("/%f/%f/%f", mb.rotorigin[0], mb.rotorigin[1], mb.rotorigin[2]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for (BlockSide bs : fromBlockSide.keySet()) {
|
for (BlockSide bs : fromBlockSide.keySet()) {
|
||||||
String side = fromBlockSide.get(bs);
|
String side = fromBlockSide.get(bs);
|
||||||
@ -160,16 +167,20 @@ public class ModelBlockModelImpl extends BlockModelImpl implements ModelBlockMod
|
|||||||
* @param yrot - degrees of rotation of block around Y
|
* @param yrot - degrees of rotation of block around Y
|
||||||
* @param zrot - degrees of rotation of block around Z
|
* @param zrot - degrees of rotation of block around Z
|
||||||
* @param shade - shade setting for model
|
* @param shade - shade setting for model
|
||||||
|
* @param rotorigin - rotation origin, if any (default [ 8, 8, 8 ](
|
||||||
* @return model block to add faces to
|
* @return model block to add faces to
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ModelBlock addModelBlock(double[] from, double[] to, double xrot, double yrot, double zrot,
|
public ModelBlock addModelBlock(double[] from, double[] to, double xrot, double yrot, double zrot,
|
||||||
boolean shade) {
|
boolean shade, double[] rotorigin) {
|
||||||
ModelBlockImpl mbi = new ModelBlockImpl();
|
ModelBlockImpl mbi = new ModelBlockImpl();
|
||||||
if (from != null) { mbi.from[0] = from[0]; mbi.from[1] = from[1]; mbi.from[2] = from[2]; }
|
if (from != null) { mbi.from[0] = from[0]; mbi.from[1] = from[1]; mbi.from[2] = from[2]; }
|
||||||
if (to != null) { mbi.to[0] = to[0]; mbi.to[1] = to[1]; mbi.to[2] = to[2]; }
|
if (to != null) { mbi.to[0] = to[0]; mbi.to[1] = to[1]; mbi.to[2] = to[2]; }
|
||||||
mbi.xrot = xrot; mbi.yrot = yrot; mbi.zrot = zrot;
|
mbi.xrot = xrot; mbi.yrot = yrot; mbi.zrot = zrot;
|
||||||
mbi.shade = shade;
|
mbi.shade = shade;
|
||||||
|
if (rotorigin != null) {
|
||||||
|
mbi.rotorigin = Arrays.copyOf(rotorigin, 3);
|
||||||
|
}
|
||||||
boxes.add(mbi);
|
boxes.add(mbi);
|
||||||
return mbi;
|
return mbi;
|
||||||
}
|
}
|
||||||
|
@ -38,10 +38,14 @@ public interface ModelBlockModel extends BlockModel {
|
|||||||
* @param yrot - degrees of rotation of block around Y
|
* @param yrot - degrees of rotation of block around Y
|
||||||
* @param zrot - degrees of rotation of block around Z
|
* @param zrot - degrees of rotation of block around Z
|
||||||
* @param shade - shade setting for model
|
* @param shade - shade setting for model
|
||||||
|
* @param rotorigin = rotation origin [x, y, z] (if null, [ 8,8,8 ] is assumed
|
||||||
* @return model block to add faces to
|
* @return model block to add faces to
|
||||||
*/
|
*/
|
||||||
public ModelBlock addModelBlock(double[] from, double[] to, double xrot, double yrot, double zrot, boolean shade);
|
public ModelBlock addModelBlock(double[] from, double[] to, double xrot, double yrot, double zrot, boolean shade, double[] rotorigin);
|
||||||
|
default public ModelBlock addModelBlock(double[] from, double[] to, double xrot, double yrot, double zrot, boolean shade) {
|
||||||
|
return addModelBlock(from, to, xrot, yrot, zrot, shade, null);
|
||||||
|
}
|
||||||
default public ModelBlock addModelBlock(double[] from, double[] to, double xrot, double yrot, double zrot) {
|
default public ModelBlock addModelBlock(double[] from, double[] to, double xrot, double yrot, double zrot) {
|
||||||
return addModelBlock(from, to, xrot, yrot, zrot, true);
|
return addModelBlock(from, to, xrot, yrot, zrot, true, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user