Skip to content

Commit

Permalink
2.8.0
Browse files Browse the repository at this point in the history
- Piece types can now be individually disabled via the config (only the regular EP piece types are in there, addon devs will have to implement type disabling themselves. it's not hard.)
- Transparent stairs and corners no longer look bad
- Added glass and stained glass pieces to the default set
- Fixed the default pack not actually updating
  • Loading branch information
Shnupbups committed Sep 8, 2019
1 parent 7981d29 commit 0d842f8
Show file tree
Hide file tree
Showing 14 changed files with 319 additions and 107 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '0.2.4-SNAPSHOT'
id 'fabric-loom' version '0.2.5-SNAPSHOT'
id 'maven-publish'
}

Expand Down
13 changes: 13 additions & 0 deletions gource-captions.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
1553493480|For clarification, Alexander is the same person as Shnupbups. Version 1.0.0 only had Sidings.
1553734800|Version 1.1.0 is released, adding Slabs, Stairs, Fences and Walls.
1554861600|Version 1.2.0 is released, adding lots more piece sets, and making every piece set have every piece type.
1558058400|Version 1.3.0 is released, adding Corners and Posts.
1558144800|Work on 2.0.0 begins. This would be a major rewrite resulting in removal of thousands of JSON files.
1562292000|Version 2.0.0 is released, now everything is added based on a config using JMX and Artifice. Columns are also added.
1562637600|Version 2.1.0 is released, JMX is no longer used, with Artifice now handling everything JMX did.
1563760800|Version 2.2.0 is released, adding Layers and changing the config system into Piece Packs.
1564106400|Version 2.3.0 is released, mods can now ship a Piece Pack in their jars.
1564192800|Version 2.4.0 is released, mods can now register their own custom piece types.
1564480800|Version 2.5.0 is released, Piece Pack schema is changed to allow for better mod support.
1566943200|Version 2.6.0 is released, recipe internals are overhauled, and new recipes are added.
1567288800|Version 2.7.0 is released, recipe internals are further altered, Layers can now face any direction.
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ org.gradle.jvmargs=-Xmx1G
loader_version=0.6.1+build.165

# Mod Properties
mod_version = 2.7.2
mod_version = 2.8.0
maven_group = com.shnupbups
archives_base_name = extrapieces

Expand All @@ -24,7 +24,7 @@ org.gradle.jvmargs=-Xmx1G

# Other Stuff
# check on maven at https://maven.fabricmc.net/me/shedaniel/RoughlyEnoughItems/
rei_version=3.1.1+build.8
rei_version=3.1.3+build.15

# check on maven at https://maven.fabricmc.net/io/github/prospector/modmenu/
modmenu_version=1.7.10+build.119
modmenu_version=1.7.11+build.121
4 changes: 3 additions & 1 deletion src/main/java/com/shnupbups/extrapieces/ExtraPieces.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.shnupbups.extrapieces.api.EPInitializer;
import com.shnupbups.extrapieces.core.PieceSet;
import com.shnupbups.extrapieces.core.PieceSets;
import com.shnupbups.extrapieces.core.PieceTypes;
import com.shnupbups.extrapieces.debug.DebugItem;
import com.shnupbups.extrapieces.register.ModBlocks;
import com.shnupbups.extrapieces.register.ModConfigs;
Expand All @@ -22,7 +23,7 @@
public class ExtraPieces implements ModInitializer {
public static final String mod_id = "extrapieces";
public static final String mod_name = "Extra Pieces";
public static final String piece_pack_version = "2.5.3";
public static final String piece_pack_version = "2.8.0";
public static final Logger logger = LogManager.getFormatterLogger(mod_name);

public static ArtificeResourcePack datapack;
Expand Down Expand Up @@ -87,6 +88,7 @@ public static void dump() {
@Override
public void onInitialize() {
ModConfigs.init();
PieceTypes.init();
FabricLoader.getInstance().getEntrypoints("extrapieces", EPInitializer.class).forEach(api -> {
debugLog("EPInitializer " + api.toString());
api.onInitialize();
Expand Down
24 changes: 13 additions & 11 deletions src/main/java/com/shnupbups/extrapieces/core/PieceTypes.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import com.shnupbups.extrapieces.blocks.PieceBlock;
import com.shnupbups.extrapieces.pieces.*;
import com.shnupbups.extrapieces.register.ModConfigs;

import net.minecraft.block.Block;
import net.minecraft.item.BlockItem;
import net.minecraft.item.ItemStack;
Expand All @@ -26,18 +28,18 @@ public class PieceTypes {

private static HashSet<PieceType> types = new HashSet<PieceType>();

static {
public static void init() {
register(PieceTypes.BASE);
register(PieceTypes.STAIRS);
register(PieceTypes.SLAB);
register(PieceTypes.SIDING);
register(PieceTypes.WALL);
register(PieceTypes.FENCE);
register(PieceTypes.FENCE_GATE);
register(PieceTypes.POST);
register(PieceTypes.COLUMN);
register(PieceTypes.CORNER);
register(PieceTypes.LAYER);
if(ModConfigs.stairs) register(PieceTypes.STAIRS);
if(ModConfigs.slabs) register(PieceTypes.SLAB);
if(ModConfigs.sidings) register(PieceTypes.SIDING);
if(ModConfigs.walls) register(PieceTypes.WALL);
if(ModConfigs.fences) register(PieceTypes.FENCE);
if(ModConfigs.fenceGates) register(PieceTypes.FENCE_GATE);
if(ModConfigs.posts) register(PieceTypes.POST);
if(ModConfigs.columns) register(PieceTypes.COLUMN);
if(ModConfigs.corners) register(PieceTypes.CORNER);
if(ModConfigs.layers) register(PieceTypes.LAYER);
}

public static PieceType register(PieceType type) {
Expand Down
34 changes: 34 additions & 0 deletions src/main/java/com/shnupbups/extrapieces/register/ModBlocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,23 @@ public class ModBlocks {
public static PieceSet STRIPPED_JUNGLE_WOOD_PIECES;
public static PieceSet STRIPPED_ACACIA_WOOD_PIECES;
public static PieceSet STRIPPED_DARK_OAK_WOOD_PIECES;
public static PieceSet GLASS_PIECES;
public static PieceSet WHITE_STAINED_GLASS_PIECES;
public static PieceSet ORANGE_STAINED_GLASS_PIECES;
public static PieceSet MAGENTA_STAINED_GLASS_PIECES;
public static PieceSet LIGHT_BLUE_STAINED_GLASS_PIECES;
public static PieceSet YELLOW_STAINED_GLASS_PIECES;
public static PieceSet LIME_STAINED_GLASS_PIECES;
public static PieceSet PINK_STAINED_GLASS_PIECES;
public static PieceSet GRAY_STAINED_GLASS_PIECES;
public static PieceSet LIGHT_GRAY_STAINED_GLASS_PIECES;
public static PieceSet CYAN_STAINED_GLASS_PIECES;
public static PieceSet PURPLE_STAINED_GLASS_PIECES;
public static PieceSet BLUE_STAINED_GLASS_PIECES;
public static PieceSet BROWN_STAINED_GLASS_PIECES;
public static PieceSet GREEN_STAINED_GLASS_PIECES;
public static PieceSet RED_STAINED_GLASS_PIECES;
public static PieceSet BLACK_STAINED_GLASS_PIECES;
static int built = 0;

public static void generateDefaultSets() {
Expand Down Expand Up @@ -303,6 +320,23 @@ public static void generateDefaultSets() {
STRIPPED_JUNGLE_WOOD_PIECES = PieceSets.createDefaultSet(Blocks.STRIPPED_JUNGLE_WOOD, "stripped_jungle_wood").setTexture("stripped_jungle_log");
STRIPPED_ACACIA_WOOD_PIECES = PieceSets.createDefaultSet(Blocks.STRIPPED_ACACIA_WOOD, "stripped_acacia_wood").setTexture("stripped_acacia_log");
STRIPPED_DARK_OAK_WOOD_PIECES = PieceSets.createDefaultSet(Blocks.STRIPPED_DARK_OAK_WOOD, "stripped_dark_oak_wood").setTexture("stripped_dark_oak_log");
GLASS_PIECES = PieceSets.createDefaultSet(Blocks.GLASS, "glass");
WHITE_STAINED_GLASS_PIECES = PieceSets.createDefaultSet(Blocks.WHITE_STAINED_GLASS, "white_stained_glass");
ORANGE_STAINED_GLASS_PIECES = PieceSets.createDefaultSet(Blocks.ORANGE_STAINED_GLASS, "orange_stained_glass");
MAGENTA_STAINED_GLASS_PIECES = PieceSets.createDefaultSet(Blocks.MAGENTA_STAINED_GLASS, "magenta_stained_glass");
LIGHT_BLUE_STAINED_GLASS_PIECES = PieceSets.createDefaultSet(Blocks.LIGHT_BLUE_STAINED_GLASS, "light_blue_stained_glass");
YELLOW_STAINED_GLASS_PIECES = PieceSets.createDefaultSet(Blocks.YELLOW_STAINED_GLASS, "yellow_stained_glass");
LIME_STAINED_GLASS_PIECES = PieceSets.createDefaultSet(Blocks.LIME_STAINED_GLASS, "lime_stained_glass");
PINK_STAINED_GLASS_PIECES = PieceSets.createDefaultSet(Blocks.PINK_STAINED_GLASS, "pink_stained_glass");
GRAY_STAINED_GLASS_PIECES = PieceSets.createDefaultSet(Blocks.GRAY_STAINED_GLASS, "gray_stained_glass");
LIGHT_GRAY_STAINED_GLASS_PIECES = PieceSets.createDefaultSet(Blocks.LIGHT_GRAY_STAINED_GLASS, "light_gray_stained_glass");
CYAN_STAINED_GLASS_PIECES = PieceSets.createDefaultSet(Blocks.CYAN_STAINED_GLASS, "cyan_stained_glass");
PURPLE_STAINED_GLASS_PIECES = PieceSets.createDefaultSet(Blocks.PURPLE_STAINED_GLASS, "purple_stained_glass");
BLUE_STAINED_GLASS_PIECES = PieceSets.createDefaultSet(Blocks.BLUE_STAINED_GLASS, "blue_stained_glass");
BROWN_STAINED_GLASS_PIECES = PieceSets.createDefaultSet(Blocks.BROWN_STAINED_GLASS, "brown_stained_glass");
GREEN_STAINED_GLASS_PIECES = PieceSets.createDefaultSet(Blocks.GREEN_STAINED_GLASS, "green_stained_glass");
RED_STAINED_GLASS_PIECES = PieceSets.createDefaultSet(Blocks.RED_STAINED_GLASS, "red_stained_glass");
BLACK_STAINED_GLASS_PIECES = PieceSets.createDefaultSet(Blocks.BLACK_STAINED_GLASS, "black_stained_glass");
ExtraPieces.debugLog("Generated Default Sets");
}

Expand Down
111 changes: 100 additions & 11 deletions src/main/java/com/shnupbups/extrapieces/register/ModConfigs.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.util.Map;
import java.util.Objects;

public class ModConfigs {

Expand All @@ -29,6 +30,18 @@ public class ModConfigs {
public static boolean debugOutput = false;
public static boolean moreDebugOutput = false;
public static boolean dumpData = false;

public static boolean slabs = true;
public static boolean stairs = true;
public static boolean sidings = true;
public static boolean corners = true;
public static boolean walls = true;
public static boolean fences = true;
public static boolean fenceGates = true;
public static boolean columns = true;
public static boolean posts = true;
public static boolean layers = true;

private static int setsNum = 0;
private static int ppSetsNum = 0;
private static int ppVpNum = 0;
Expand All @@ -41,12 +54,25 @@ public static void init() {
if (isConfigOutdated(cfg)) {
updateConfig(cfg, config);
}

generateDefaultPack = cfg.get("generateDefaultPack").equals(JsonPrimitive.TRUE);
forceUpdateDefaultPack = cfg.get("forceUpdateDefaultPack").equals(JsonPrimitive.TRUE);
everythingStonecuttable = cfg.get("everythingStonecuttable").equals(JsonPrimitive.TRUE);
debugOutput = cfg.get("debugOutput").equals(JsonPrimitive.TRUE);
moreDebugOutput = cfg.get("moreDebugOutput").equals(JsonPrimitive.TRUE);
dumpData = cfg.get("dumpData").equals(JsonPrimitive.TRUE);

JsonObject types = cfg.getObject("pieceTypes");
slabs = types.get("slabs").equals(JsonPrimitive.TRUE);
stairs = types.get("stairs").equals(JsonPrimitive.TRUE);
sidings = types.get("sidings").equals(JsonPrimitive.TRUE);
corners = types.get("corners").equals(JsonPrimitive.TRUE);
walls = types.get("walls").equals(JsonPrimitive.TRUE);
fences = types.get("fences").equals(JsonPrimitive.TRUE);
fenceGates = types.get("fenceGates").equals(JsonPrimitive.TRUE);
columns = types.get("columns").equals(JsonPrimitive.TRUE);
posts = types.get("posts").equals(JsonPrimitive.TRUE);
layers = types.get("layers").equals(JsonPrimitive.TRUE);
} catch (IOException e) {
generateConfig(config);
} catch (SyntaxError e) {
Expand Down Expand Up @@ -109,17 +135,20 @@ public static void findAndCopyPiecePacks() {
public static void initPiecePacks() {
File ppDir = ExtraPieces.getPiecePackDirectory();
File defaultPack = new File(ppDir, "default.json");
if (ppDir.listFiles().length == 0) {
File[] packs = ppDir.listFiles();
assert packs != null;
if (packs.length == 0) {
if (generateDefaultPack) {
ExtraPieces.log("No piece packs found, generating default!");
generateDefaultPack(new File(ppDir, "default.json"));
} else ExtraPieces.log("No piece packs found! Why bother having Extra Pieces installed then?");
} else {
if (generateDefaultPack && (!defaultPack.exists() || forceUpdateDefaultPack)) {
if (generateDefaultPack && (!defaultPack.exists() || forceUpdateDefaultPack || isDefaultPackOutdated(defaultPack))) {
ExtraPieces.log("Generating default piece pack as it either did not exist or needed updating...");
generateDefaultPack(defaultPack);
}
}
for (File f : ppDir.listFiles()) {
for (File f : packs) {
try (FileReader reader = new FileReader(f)) {
JsonObject pp = Jankson.builder().build().load(f);
JsonObject sets = null;
Expand Down Expand Up @@ -197,13 +226,26 @@ public static void generateDefaultPack(File pack) {
}

public static boolean isConfigOutdated(JsonObject cfg) {
if (!cfg.containsKey("generateDefaultPack")) return true;
if (!cfg.containsKey("forceUpdateDefaultPack")) return true;
if (!cfg.containsKey("everythingStonecuttable")) return true;
if (!cfg.containsKey("debugOutput")) return true;
if (!cfg.containsKey("moreDebugOutput")) return true;
if (!cfg.containsKey("dumpData")) return true;
return false;
if (!cfg.containsKey("generateDefaultPack") ||
!cfg.containsKey("forceUpdateDefaultPack") ||
!cfg.containsKey("everythingStonecuttable") ||
!cfg.containsKey("debugOutput") ||
!cfg.containsKey("moreDebugOutput") ||
!cfg.containsKey("dumpData") ||
!cfg.containsKey("pieceTypes")) return true;
else {
JsonObject types = cfg.getObject("pieceTypes");
return !types.containsKey("slabs") ||
!types.containsKey("stairs") ||
!types.containsKey("sidings") ||
!types.containsKey("corners") ||
!types.containsKey("walls") ||
!types.containsKey("fences") ||
!types.containsKey("fenceGates") ||
!types.containsKey("columns") ||
!types.containsKey("posts") ||
!types.containsKey("layers");
}
}

public static void updateConfig(JsonObject cfg, File config) {
Expand All @@ -219,6 +261,30 @@ public static void updateConfig(JsonObject cfg, File config) {
cfg.put("moreDebugOutput", new JsonPrimitive(moreDebugOutput));
if (!cfg.containsKey("dumpData"))
cfg.put("dumpData", new JsonPrimitive(dumpData));
if(!cfg.containsKey("pieceTypes"))
cfg.put("pieceTypes", new JsonObject());
JsonObject types = cfg.getObject("pieceTypes");
if(!types.containsKey("slabs"))
types.put("slabs", new JsonPrimitive(slabs));
if(!types.containsKey("stairs"))
types.put("stairs", new JsonPrimitive(stairs));
if(!types.containsKey("sidings"))
types.put("sidings", new JsonPrimitive(sidings));
if(!types.containsKey("corners"))
types.put("corners", new JsonPrimitive(corners));
if(!types.containsKey("walls"))
types.put("walls", new JsonPrimitive(walls));
if(!types.containsKey("fences"))
types.put("fences", new JsonPrimitive(fences));
if(!types.containsKey("fenceGates"))
types.put("fenceGates", new JsonPrimitive(fenceGates));
if(!types.containsKey("columns"))
types.put("columns", new JsonPrimitive(columns));
if(!types.containsKey("posts"))
types.put("posts", new JsonPrimitive(posts));
if(!types.containsKey("layers"))
types.put("layers", new JsonPrimitive(layers));
cfg.put("pieceTypes", types);
if (config.exists()) config.delete();
try (FileWriter writer = new FileWriter(config)) {
writer.write(cfg.toJson(false, true));
Expand All @@ -243,14 +309,29 @@ public static boolean isNewer(Path toCheck, Path toReplace) {
if (ppR.containsKey("version")) {
rVer = new Version(ppR.get(String.class, "version"));
} else rVer = new Version();
return cVer.compareTo(rVer) == 1;
return cVer.isNewerThan(rVer);
} catch (Exception e) {
ExtraPieces.log("Failed to check if Piece Pack " + toCheck.getFileName() + " needed updating:");
e.printStackTrace();

return false;
}
}

public static boolean isDefaultPackOutdated(File defaultPack) {
try {
JsonObject dpp = Jankson.builder().build().load(defaultPack);
Version ver;
if (dpp.containsKey("version")) {
ver = new Version(dpp.get(String.class, "version"));
} else ver = new Version();
return new Version(ExtraPieces.piece_pack_version).isNewerThan(ver);
} catch (Exception e) {
ExtraPieces.log("Failed to check if default Piece Pack needed updating:");
e.printStackTrace();
return false;
}
}

public static class Version implements Comparable<Version> {

Expand Down Expand Up @@ -291,6 +372,14 @@ public int compareTo(Version that) {
}
return 0;
}

public boolean isOlderThan(Version that) {
return compareTo(that) == -1;
}

public boolean isNewerThan(Version that) {
return compareTo(that) == 1;
}

@Override
public boolean equals(Object that) {
Expand Down
4 changes: 3 additions & 1 deletion src/main/resources/assets/extrapieces/lang/en_gb.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@
"pieceSet.chiseled_stone_brick": "Chiselled Stone Brick",
"pieceSet.chiseled_quartz": "Chiselled Quartz",

"pieceSet.gray_stone_brick": "Grey Stone Brick"
"pieceSet.gray_stone_brick": "Grey Stone Brick",

"pieceSet.chiseled_basalt_brick": "Chiselled Basalt Brick"
}
2 changes: 2 additions & 0 deletions src/main/resources/assets/extrapieces/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,8 @@
"pieceSet.sakura_leaf": "Sakura Leaf",
"pieceSet.basalt_grass": "Basalt Grass",
"pieceSet.basalt_brick": "Basalt Brick",
"pieceSet.mossy_basalt_brick": "Mossy Basalt Brick",
"pieceSet.chiseled_basalt_brick": "Chiseled Basalt Brick",
"pieceSet.japanese_maple_shrub_leaf": "Japanese Maple Shrub Leaf",

"pieceSet.red_autumnal_leaf": "Red Autumnal Leaf",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@
"elements": [
{
"from": [0, 0, 8],
"to": [16, 16, 16],
"to": [8, 16, 16],
"faces": {
"north": {"uv": [0, 0, 16, 16], "texture": "#main"},
"east": {"uv": [0, 0, 8, 16], "texture": "#main", "cullface": "east"},
"south": {"uv": [0, 0, 16, 16], "texture": "#main", "cullface": "south"},
"north": {"uv": [8, 0, 16, 16], "texture": "#main"},
"south": {"uv": [0, 0, 8, 16], "texture": "#main", "cullface": "south"},
"west": {"uv": [8, 0, 16, 16], "texture": "#main", "cullface": "west"},
"up": {"uv": [0, 8, 16, 16], "texture": "#top", "cullface": "up"},
"down": {"uv": [0, 0, 16, 8], "texture": "#bottom", "cullface": "down"}
"up": {"uv": [0, 8, 8, 16], "texture": "#top", "cullface": "up"},
"down": {"uv": [0, 0, 8, 8], "texture": "#bottom", "cullface": "down"}
}
},
{
Expand All @@ -23,6 +22,16 @@
"up": {"uv": [8, 0, 16, 8], "texture": "#top", "cullface": "up"},
"down": {"uv": [8, 8, 16, 16], "texture": "#bottom", "cullface": "down"}
}
},
{
"from": [8, 0, 8],
"to": [16, 16, 16],
"faces": {
"east": {"uv": [0, 0, 8, 16], "texture": "#main", "cullface": "east"},
"south": {"uv": [8, 0, 16, 16], "texture": "#main", "cullface": "south"},
"up": {"uv": [8, 8, 16, 16], "texture": "#top", "cullface": "up"},
"down": {"uv": [8, 0, 16, 8], "texture": "#bottom", "cullface": "down"}
}
}
],
"display": {
Expand Down
Loading

0 comments on commit 0d842f8

Please sign in to comment.