Skip to content

Commit

Permalink
2.8.2
Browse files Browse the repository at this point in the history
- Updated Artifice to fix issues with resource reloading on dedicated servers
- Piece Packs, Piece Sets, and Vanilla Pieces now all have a new optional field 'required_mod'. If this is specified, the pack, set, or piece will only be loaded if a mod with that id is present.
  • Loading branch information
Shnupbups committed Sep 21, 2019
1 parent 7d20f2a commit 6dbe9ac
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 32 deletions.
8 changes: 4 additions & 4 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.8.1
mod_version = 2.8.2
maven_group = com.shnupbups
archives_base_name = extrapieces

Expand All @@ -17,14 +17,14 @@ org.gradle.jvmargs=-Xmx1G
fabric_version=0.3.2+build.218-1.14

# check on jitpack at https://jitpack.io/#swordglowsblue/artifice
artifice_version=0.3.4
artifice_version=0.3.5

# check on cotton maven at http://server.bbkr.space:8081/artifactory/libs-release/io/github/cottonmc/Jankson/
jankson_version=1.0.0+j1.1.2

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

# check on maven at https://maven.fabricmc.net/io/github/prospector/modmenu/
modmenu_version=1.7.11+build.121
modmenu_version=1.7.13+build.123
62 changes: 40 additions & 22 deletions src/main/java/com/shnupbups/extrapieces/core/PieceSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
import com.shnupbups.extrapieces.register.ModLootTables;
import com.shnupbups.extrapieces.register.ModRecipes;
import com.swordglowsblue.artifice.api.ArtificeResourcePack;

import net.fabricmc.loader.api.FabricLoader;

import net.minecraft.block.Block;
import net.minecraft.block.Blocks;
import net.minecraft.block.Material;
Expand Down Expand Up @@ -550,6 +553,7 @@ public void addLootTables(ArtificeResourcePack.ServerResourcePackBuilder data) {
public static class Builder {
public final String name;
public final Identifier base;
public String requiredMod = "minecraft";
public boolean built = false;
public Boolean stonecuttable;
public Boolean woodmillable;
Expand Down Expand Up @@ -625,32 +629,38 @@ public Builder(String name, JsonObject ob, String packName) {
this.uncraftable.add(pt);
}
}
if (ob.containsKey("required_mod")) {
requiredMod = ob.get(String.class, "required_mod");
}
}

public PieceSet build() {
if (built) {
return PieceSets.getSet(Registry.BLOCK.get(base));
}

PieceSet ps = new PieceSet(Registry.BLOCK.get(base), name, genTypes);
if (this.stonecuttable != null) ps.setStonecuttable(this.stonecuttable);
if (this.woodmillable != null) ps.setWoodmillable(this.woodmillable);
if (this.opaque != null) ps.setOpaque(this.opaque);
if (this.mainTexture != null) ps.setTexture(this.mainTexture);
if (this.topTexture != null) ps.setTopTexture(this.topTexture);
if (this.bottomTexture != null) ps.setBottomTexture(this.bottomTexture);

for (Map.Entry<PieceType, Identifier> vanillaPiece : this.getVanillaPieces().entrySet()) {
ps.addVanillaPiece(vanillaPiece.getKey(), Registry.BLOCK.get(vanillaPiece.getValue()));
}

if (this.includeMode) ps.setInclude();
for (PieceType pt : this.uncraftable) {
ps.setUncraftable(pt);
if(shouldLoad()) {
if (built) {
return PieceSets.getSet(Registry.BLOCK.get(base));
}

PieceSet ps = new PieceSet(Registry.BLOCK.get(base), name, genTypes);
if (this.stonecuttable != null) ps.setStonecuttable(this.stonecuttable);
if (this.woodmillable != null) ps.setWoodmillable(this.woodmillable);
if (this.opaque != null) ps.setOpaque(this.opaque);
if (this.mainTexture != null) ps.setTexture(this.mainTexture);
if (this.topTexture != null) ps.setTopTexture(this.topTexture);
if (this.bottomTexture != null) ps.setBottomTexture(this.bottomTexture);

for (Map.Entry<PieceType, Identifier> vanillaPiece : this.getVanillaPieces().entrySet()) {
ps.addVanillaPiece(vanillaPiece.getKey(), Registry.BLOCK.get(vanillaPiece.getValue()));
}

if (this.includeMode) ps.setInclude();
for (PieceType pt : this.uncraftable) {
ps.setUncraftable(pt);
}

this.built = true;
return ps;
}

this.built = true;
return ps;
return null;
}

public void addVanillaPiece(Identifier type, Identifier piece) {
Expand Down Expand Up @@ -678,6 +688,14 @@ public boolean isBuilt() {
public String getPackName() {
return packName;
}

public String getRequiredMod() {
return requiredMod;
}

public boolean shouldLoad() {
return FabricLoader.getInstance().isModLoaded(getRequiredMod());
}

public boolean isReady() {
if (!Registry.BLOCK.getOrEmpty(base).isPresent() || !Registry.ITEM.getOrEmpty(base).isPresent()) {
Expand Down
24 changes: 19 additions & 5 deletions src/main/java/com/shnupbups/extrapieces/register/ModConfigs.java
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,12 @@ public static void initPiecePacks() {
JsonObject sets = null;
JsonObject vanillaPieces = null;
String ppVer;
if(pp.containsKey("required_mod")) {
String requiredMod = pp.get(String.class, "required_mod");
if(!FabricLoader.getInstance().isModLoaded(requiredMod)) {
continue;
}
}
if (!pp.containsKey("version")) {
sets = pp;
ppVer = "0.0.0";
Expand All @@ -168,9 +174,11 @@ public static void initPiecePacks() {
for (Map.Entry<String, JsonElement> entry : sets.entrySet()) {
JsonObject jsonSet = (JsonObject) entry.getValue();
PieceSet.Builder psb = new PieceSet.Builder(entry.getKey(), jsonSet, f.getName());
setsNum++;
ppSetsNum++;
ModBlocks.registerSet(psb);
if(psb.shouldLoad()) {
setsNum++;
ppSetsNum++;
ModBlocks.registerSet(psb);
}
}
ExtraPieces.debugLog("Generated " + ppSetsNum + " PieceSets from piece pack " + f.getName());
}
Expand All @@ -181,8 +189,14 @@ public static void initPiecePacks() {
Identifier base = new Identifier(jsonPiece.get(String.class, "base"));
Identifier type = new Identifier(jsonPiece.get(String.class, "type"));
Identifier piece = new Identifier(jsonPiece.get(String.class, "piece"));
ppVpNum++;
ModBlocks.registerVanillaPiece(base, type, piece);
boolean add = true;
if(jsonPiece.containsKey("required_mod")) {
add = FabricLoader.getInstance().isModLoaded(jsonPiece.get(String.class, "required_mod"));
}
if(add) {
ppVpNum++;
ModBlocks.registerVanillaPiece(base, type, piece);
}
} else {
ExtraPieces.debugLog("Invalid vanilla piece " + entry.getKey() + " in piece pack " + f.getName());
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"schemaVersion": 1,
"id": "extrapieces",
"version": "2.8.1",
"version": "2.8.2",

"name": "Extra Pieces",
"description": "Adds more block shapes to Minecraft!",
Expand Down

0 comments on commit 6dbe9ac

Please sign in to comment.