-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4a507c4
commit fd45fcd
Showing
4 changed files
with
99 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
src/main/java/io/github/nickid2018/genwiki/autovalue/wikidata/JsonWikiData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package io.github.nickid2018.genwiki.autovalue.wikidata; | ||
|
||
import com.google.gson.JsonElement; | ||
|
||
public abstract class JsonWikiData implements WikiData { | ||
|
||
public abstract JsonElement asJsonData(); | ||
|
||
@Override | ||
public String output(int indent) { | ||
return asJsonData().toString(); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/main/java/io/github/nickid2018/genwiki/autovalue/wikidata/LiquidComputationWikiData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package io.github.nickid2018.genwiki.autovalue.wikidata; | ||
|
||
import com.google.gson.JsonArray; | ||
import com.google.gson.JsonElement; | ||
import com.google.gson.JsonObject; | ||
|
||
import java.util.Set; | ||
|
||
public class LiquidComputationWikiData extends JsonWikiData { | ||
|
||
private final JsonObject data = new JsonObject(); | ||
|
||
public void put(String key, boolean blocksMotion, Set<String> sturdyFaces) { | ||
JsonObject obj = new JsonObject(); | ||
obj.addProperty("blocks_motion", blocksMotion); | ||
JsonArray array = new JsonArray(); | ||
sturdyFaces.forEach(array::add); | ||
obj.add("face_sturdy", array); | ||
data.add(key, obj); | ||
} | ||
|
||
@Override | ||
public JsonElement asJsonData() { | ||
return data; | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
src/main/java/io/github/nickid2018/genwiki/autovalue/wikidata/OcclusionWikiData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package io.github.nickid2018.genwiki.autovalue.wikidata; | ||
|
||
import com.google.gson.JsonArray; | ||
import com.google.gson.JsonElement; | ||
import com.google.gson.JsonObject; | ||
import net.minecraft.world.phys.AABB; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
public class OcclusionWikiData extends JsonWikiData { | ||
|
||
private final JsonObject data = new JsonObject(); | ||
|
||
public void put(String key, boolean canOcclude, Map<String, List<double[]>> faces) { | ||
JsonObject obj = new JsonObject(); | ||
obj.addProperty("can_occlude", canOcclude); | ||
for (Map.Entry<String, List<double[]>> entry : faces.entrySet()) { | ||
JsonArray array = new JsonArray(); | ||
for (double[] doubles : entry.getValue()) { | ||
JsonArray face = new JsonArray(); | ||
for (double d : doubles) | ||
face.add(d); | ||
array.add(face); | ||
} | ||
obj.add(entry.getKey(), array); | ||
} | ||
data.add(key, obj); | ||
} | ||
|
||
@Override | ||
public JsonElement asJsonData() { | ||
return data; | ||
} | ||
} |