Add support for 1.9 blocks and textures

This commit is contained in:
Mike Primm 2011-09-22 22:55:48 -05:00
parent ad6f6f4316
commit 085e06eb43
5 changed files with 120 additions and 27 deletions

View file

@ -83,6 +83,8 @@ public class IsoHDPerspective implements HDPerspective {
private static final int IRONFENCE_BLKTYPEID = 101;
private static final int GLASSPANE_BLKTYPEID = 102;
private static final int FENCEGATE_BLKTYPEID = 107;
private static final int NETHERFENCE_BLKTYPEID = 113;
private enum ChestData {
SINGLE_WEST, SINGLE_SOUTH, SINGLE_EAST, SINGLE_NORTH, LEFT_WEST, LEFT_SOUTH, LEFT_EAST, LEFT_NORTH, RIGHT_WEST, RIGHT_SOUTH, RIGHT_EAST, RIGHT_NORTH
};
@ -338,27 +340,27 @@ public class IsoHDPerspective implements HDPerspective {
nonairhit = false;
skiptoair = isnether;
}
private int generateFenceBlockData(MapIterator mapiter) {
private int generateFenceBlockData(MapIterator mapiter, int blkid) {
int blockdata = 0;
int id;
/* Check north */
id = mapiter.getBlockTypeIDAt(BlockStep.X_MINUS);
if((id == FENCE_BLKTYPEID) || (id == FENCEGATE_BLKTYPEID)) { /* Fence? */
if((id == blkid) || (id == FENCEGATE_BLKTYPEID)) { /* Fence? */
blockdata |= 1;
}
/* Look east */
id = mapiter.getBlockTypeIDAt(BlockStep.Z_MINUS);
if((id == FENCE_BLKTYPEID) || (id == FENCEGATE_BLKTYPEID)) { /* Fence? */
if((id == blkid) || (id == FENCEGATE_BLKTYPEID)) { /* Fence? */
blockdata |= 2;
}
/* Look south */
id = mapiter.getBlockTypeIDAt(BlockStep.X_PLUS);
if((id == FENCE_BLKTYPEID) || (id == FENCEGATE_BLKTYPEID)) { /* Fence? */
if((id == blkid) || (id == FENCEGATE_BLKTYPEID)) { /* Fence? */
blockdata |= 4;
}
/* Look west */
id = mapiter.getBlockTypeIDAt(BlockStep.Z_PLUS);
if((id == FENCE_BLKTYPEID) || (id == FENCEGATE_BLKTYPEID)) { /* Fence? */
if((id == blkid) || (id == FENCEGATE_BLKTYPEID)) { /* Fence? */
blockdata |= 8;
}
return blockdata;
@ -537,7 +539,8 @@ public class IsoHDPerspective implements HDPerspective {
blockdata = mapiter.getBlockData();
switch(blocktypeid) {
case FENCE_BLKTYPEID: /* Special case for fence - need to fake data so we can render properly */
blockrenderdata = generateFenceBlockData(mapiter);
case NETHERFENCE_BLKTYPEID:
blockrenderdata = generateFenceBlockData(mapiter, blocktypeid);
break;
case CHEST_BLKTYPEID: /* Special case for chest - need to fake data so we can render */
blockrenderdata = generateChestBlockData(mapiter);

View file

@ -1,6 +1,9 @@
package org.dynmap.utils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* scalable flags primitive - used for keeping track of potentially huge number of tiles
*
@ -17,6 +20,37 @@ public class TileFlags {
public TileFlags() {
}
public List<String> save() {
ArrayList<String> v = new ArrayList<String>();
StringBuilder sb = new StringBuilder();
for(Map.Entry<Long, long[]> ent : chunkmap.entrySet()) {
sb.append(String.format("%lx", ent.getKey().longValue()));
long[] val = ent.getValue();
for(long vv : val) {
sb.append(String.format(":%lx", vv));
}
v.add(sb.toString());
sb.setLength(0);
}
return v;
}
public void load(List<String> vals) {
clear();
for(String v : vals) {
String[] tok = v.split(":");
long[] row = new long[64];
try {
long rowaddr = Long.parseLong(tok[0], 16);
for(int i = 0; (i < 64) && (i < (tok.length-1)); i++) {
row[i] = Long.parseLong(tok[i+1], 16);
}
chunkmap.put(rowaddr, row);
} catch (NumberFormatException nfx) {
}
}
}
public boolean getFlag(int x, int y) {
long k = (((long)(x >> 6)) << 32) | (0xFFFFFFFFL & (long)(y >> 6));
long[] row;