Skip to content

Commit

Permalink
Merge branch 'master' into update-internals-to-upstream-latest
Browse files Browse the repository at this point in the history
  • Loading branch information
David Lindström committed Feb 23, 2024
2 parents c7f0d32 + 0afd170 commit c619414
Show file tree
Hide file tree
Showing 103 changed files with 21,384 additions and 11 deletions.
30 changes: 26 additions & 4 deletions src/main/java/org/dynmap/hdmap/TexturePack.java
Original file line number Diff line number Diff line change
Expand Up @@ -2687,6 +2687,15 @@ public static void handleBlockAlias() {

private static final int BLOCKID_GRASS = 2;
private static final int BLOCKID_SNOW = 78;
private void blendColors(Color color1AndOut, Color color2){
int alpha = color1AndOut.getAlpha();
int alpha2 = color2.getAlpha() * (255-alpha) / 255;
int talpha = alpha + alpha2;

color1AndOut.setRGBA((color2.getRed()*alpha2 + color1AndOut.getRed()*alpha) / talpha,
(color2.getGreen()*alpha2 + color1AndOut.getGreen()*alpha) / talpha,
(color2.getBlue()*alpha2 + color1AndOut.getBlue()*alpha) / talpha, talpha);
}
/**
* Read color for given subblock coordinate, with given block id and data and face
* @param ps - perspective state
Expand Down Expand Up @@ -2733,8 +2742,15 @@ public final void readColor(final HDPerspectiveState ps, final MapIterator mapit
customTextureId = mod + ctm.mapTexture(mapiter, blkid, blkdata, laststep, customTextureId, ss);
}

if(layer == layers.length -1 || rslt.getAlpha() < 0xFE)
readColor(ps, mapiter, rslt, blkid, lastblocktype, ss, blkdata, map, laststep, patchid, customTextureId, map.stdrotate, ccm);
if(layer == layers.length -1 || rslt.getAlpha() < 0xFE) {
if(rslt.isTransparent()) {
readColor(ps, mapiter, rslt, blkid, lastblocktype, ss, blkdata, map, laststep, patchid, customTextureId, map.stdrotate, ccm);
} else {
Color tmpColor = new Color();
readColor(ps, mapiter, tmpColor, blkid, lastblocktype, ss, blkdata, map, laststep, patchid, customTextureId, map.stdrotate, ccm);
blendColors(rslt, tmpColor);
}
}
}
handledByCustomRendering = true;
}
Expand All @@ -2757,10 +2773,16 @@ public final void readColor(final HDPerspectiveState ps, final MapIterator mapit
readColor(ps, mapiter, rslt, blkid, lastblocktype, ss, blkdata, map, laststep, patchid, textid, map.stdrotate, ccm);
if (map.layers != null) { /* If layered */
/* While transparent and more layers */
while (rslt.isTransparent() && (map.layers[faceindex] >= 0)) {
while (rslt.getAlpha() < 0xFE && (map.layers[faceindex] >= 0)) {
faceindex = map.layers[faceindex];
textid = map.faces[faceindex];
readColor(ps, mapiter, rslt, blkid, lastblocktype, ss, blkdata, map, laststep, patchid, textid, map.stdrotate, ccm);
if(rslt.isTransparent()) {
readColor(ps, mapiter, rslt, blkid, lastblocktype, ss, blkdata, map, laststep, patchid, textid, map.stdrotate, ccm);
} else {
Color tmpColor = new Color();
readColor(ps, mapiter, tmpColor, blkid, lastblocktype, ss, blkdata, map, laststep, patchid, textid, map.stdrotate, ccm);
blendColors(rslt, tmpColor);
}
}
}
}
Expand Down
103 changes: 102 additions & 1 deletion src/main/java/org/dynmap/hdmap/renderer/CarpentersBlocksRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ public boolean initializeRenderer(RenderPatchFactory rpf, int blkid, int blockda
initStairsShapes(rpf);
} else if(type.equals("block")){
initBlockShapes(rpf);
} else if(type.equals("plate")){
initPlateShapes(rpf);
} else if(type.equals("hatch")){
initHatchShapes(rpf);
} else if(type.equals("garage")){
initGarageShapes(rpf);
} else if(type.equals("door")){
initDoorShapes(rpf);
} else if(type.equals("gate")){
initGateShapes(rpf);
link_ids.set(blkid);
Expand Down Expand Up @@ -93,10 +101,100 @@ private void initBlockShapes(RenderPatchFactory rpf) {
shapes[5] = CustomRenderer.getBoxSingleTexture(rpf, 0.0, 1.0, 0.0, 1.0, 0.0, 0.5,0, false);
shapes[6] = CustomRenderer.getBoxSingleTexture(rpf, 0.0, 1.0, 0.0, 1.0, 0.5, 1.0,0, false);
}
private void initPlateShapes(RenderPatchFactory rpf) {
shapes[0] = fullBlock;
shapes[1] = CustomRenderer.getBoxSingleTextureInt(rpf, 1, 15, 0, 1, 1, 15,0, false);
shapes[33] = CustomRenderer.getBoxSingleTextureInt(rpf, 1, 15, 0, 1, 1, 15,0, false);
shapes[65] = CustomRenderer.getBoxSingleTextureInt(rpf, 1, 15, 0, 1, 1, 15,0, false);
shapes[97] = CustomRenderer.getBoxSingleTextureInt(rpf, 1, 15, 0, 1, 1, 15,0, false);
}
private void initHatchShapes(RenderPatchFactory rpf) {
shapes[0] = getBoxSingleTextureInt(rpf, 0,16,0,2,0,16,0,false);
shapes[32] = getRotatedSet(rpf, shapes[0], 0, 180, 0);
shapes[64] = getRotatedSet(rpf, shapes[0], 0, 270, 0);
shapes[96] = getRotatedSet(rpf, shapes[0], 0, 90, 0);

shapes[16] = getBoxSingleTextureInt(rpf, 0,16,0,16,14,16,0,false);
shapes[48] = getRotatedSet(rpf, shapes[16], 0, 180, 0);
shapes[80] = getRotatedSet(rpf, shapes[16], 0, 270, 0);
shapes[112] = getRotatedSet(rpf, shapes[16], 0, 90, 0);

shapes[8] = getBoxSingleTextureInt(rpf, 0,16,14,16,0,16,0,false);
shapes[40] = getRotatedSet(rpf, shapes[8], 0, 180, 0);
shapes[72] = getRotatedSet(rpf, shapes[8], 0, 270, 0);
shapes[104] = getRotatedSet(rpf, shapes[8], 0, 90, 0);

shapes[24] = getBoxSingleTextureInt(rpf, 0,16,0,16,14,16,0,false);
shapes[56] = getRotatedSet(rpf, shapes[24], 0, 180, 0);
shapes[88] = getRotatedSet(rpf, shapes[24], 0, 270, 0);
shapes[120] = getRotatedSet(rpf, shapes[24], 0, 90, 0);

for(int i = 1; i < 128; i++){
if(shapes[i] == null && shapes[i-1] != null){
shapes[i] = shapes[i-1];
}
}
}
private void initGarageShapes(RenderPatchFactory rpf) {
shapes[0] = fullBlock;
shapes[32] = getBoxSingleTextureInt(rpf, 0,16,0,16,12,14,0,false);
shapes[48] = getRotatedSet(rpf, shapes[32], 0, 180, 0);
shapes[64] = getRotatedSet(rpf, shapes[32], 0, 270, 0);
shapes[80] = getRotatedSet(rpf, shapes[32], 0, 90, 0);

shapes[160] = getBoxSingleTextureInt(rpf, 0,16,8,16,14,16,0,false);
shapes[176] = getRotatedSet(rpf, shapes[160], 0, 180, 0);
shapes[192] = getRotatedSet(rpf, shapes[160], 0, 270, 0);
shapes[208] = getRotatedSet(rpf, shapes[160], 0, 90, 0);

for(int i = 1; i < 128; i++){
if(shapes[i] == null && shapes[i-1] != null){
shapes[i] = shapes[i-1];
}
}
}

private void initDoorShapes(RenderPatchFactory rpf) {
shapes[0] = getBoxSingleTextureInt(rpf, 0,3,0,16,0,16,0,false);
shapes[16] = getRotatedSet(rpf, shapes[0], 0, 90, 0);
shapes[32] = getRotatedSet(rpf, shapes[0], 0, 180, 0);
shapes[48] = getRotatedSet(rpf, shapes[0], 0, 270, 0);

shapes[128] = getBoxSingleTextureInt(rpf, 0,3,0,16,0,16,0,false);
shapes[144] = getRotatedSet(rpf, shapes[128], 0, 90, 0);
shapes[160] = getRotatedSet(rpf, shapes[128], 0, 180, 0);
shapes[176] = getRotatedSet(rpf, shapes[128], 0, 270, 0);

shapes[8] = getBoxSingleTextureInt(rpf, 0,3,0,16,0,16,0,false);
shapes[24] = getRotatedSet(rpf, shapes[8], 0, 90, 0);
shapes[40] = getRotatedSet(rpf, shapes[8], 0, 180, 0);
shapes[56] = getRotatedSet(rpf, shapes[8], 0, 270, 0);

shapes[136] = getBoxSingleTextureInt(rpf, 0,3,0,16,0,16,0,false);
shapes[152] = getRotatedSet(rpf, shapes[136], 0, 90, 0);
shapes[168] = getRotatedSet(rpf, shapes[136], 0, 180, 0);
shapes[184] = getRotatedSet(rpf, shapes[136], 0, 270, 0);

for(int i = 255 - 64; i>=0; i--){
if(shapes[i] != null && shapes[i + 64] == null){
if((i & 8) != 0){
shapes[i + 64] = getRotatedSet(rpf, shapes[i], 0, 270, 0);
} else {
shapes[i + 64] = getRotatedSet(rpf, shapes[i], 0, 90, 0);
}
}
}

for(int i = 1; i < 256; i++){
if(shapes[i] == null && shapes[i-1] != null){
shapes[i] = shapes[i-1];
}
}
}

private void initStairsShapes(RenderPatchFactory rpf) {
shapes[8] = ArchitectureCraftShapeRenderer.makeStairs(rpf);
shapes[9] = getRotatedSet(rpf, shapes[8], 0, 180, 0);
shapes[9] = getRotatedSet(rpf, shapes[8], 0, 180, 0);
shapes[10] = getRotatedSet(rpf, shapes[8], 0, 270, 0);
shapes[11] = getRotatedSet(rpf, shapes[8], 0, 90, 0);

Expand Down Expand Up @@ -180,6 +278,9 @@ else if(objMetaData instanceof Short)
else
return fullBlock;

if(metaData >= 256)
metaData %= 256;

if(metaData >= 0 && metaData < shapes.length && shapes[metaData] != null)
return shapes[metaData];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

import java.util.HashMap;

public class ArchitectureCraftModSupportLoader extends CustomModSupportLoader {
public class ArchitectureCraftModSupportLoader extends DummyModSupportLoader {
@Override
public void initializeModSupport(DynmapCore core, HashMap<String, Integer> filetoidx) {
GWM_Util.initialize(core);
super.initializeModSupport(core, filetoidx);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.dynmap.modsupport.loaders;

import org.dynmap.DynmapCore;
import org.dynmap.modsupport.GWM_Util;
import org.dynmap.renderer.CustomModSupportLoader;

import java.util.HashMap;

public class DummyModSupportLoader extends CustomModSupportLoader {
@Override
public void initializeModSupport(DynmapCore core, HashMap<String, Integer> filetoidx) {
GWM_Util.initialize(core);
}
}
Loading

0 comments on commit c619414

Please sign in to comment.