Skip to content

Commit

Permalink
Avoid breaking addons by adding a deprecated copy of the original tha…
Browse files Browse the repository at this point in the history
…t has @HideFromJS. Also fix KubeJS block builders to use the new name.
  • Loading branch information
ChiefArug committed Jul 21, 2023
1 parent a6adf19 commit 9f17a9f
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ protected void generateBlockModelJsons(AssetJsonGenerator generator) {
}

protected void generateBlockStateJson(VariantBlockStateGenerator bs) {
bs.variant("", model.isEmpty() ? (id.getNamespace() + ":block/" + id.getPath()) : model);
bs.simpleVariant("", model.isEmpty() ? (id.getNamespace() + ":block/" + id.getPath()) : model);
}

public Map<ResourceLocation, JsonObject> generateBlockModels(BlockBuilder builder) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ public Block createObject() {
@Override
public void generateAssetJsons(AssetJsonGenerator generator) {
generator.blockState(id, bs -> {
bs.variant("powered=false", "kubejs:block/detector");
bs.variant("powered=true", "kubejs:block/detector_on");
bs.simpleVariant("powered=false", "kubejs:block/detector");
bs.simpleVariant("powered=true", "kubejs:block/detector_on");
});

generator.itemModel(id, m -> m.parent(KubeJS.MOD_ID + ":block/detector"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public BlockBuilder randomTick(@Nullable Consumer<RandomTickCallbackJS> randomTi
@Override
protected void generateBlockStateJson(VariantBlockStateGenerator bs) {
for (int i = 0; i <= age; i++) {
bs.variant("age=%s".formatted(i), model.isEmpty() ? (id.getNamespace() + ":block/" + id.getPath() + i) : model);
bs.simpleVariant("age=%s".formatted(i), model.isEmpty() ? (id.getNamespace() + ":block/" + id.getPath() + i) : model);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import dev.latvian.mods.rhino.util.HideFromJS;

import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -90,6 +91,12 @@ public void variant(String key, Consumer<Variant> consumer) {
variants.add(v.key, v.toJson());
}

@HideFromJS
@Deprecated
public void variant(String key, String model) {
simpleVariant(key, model);
}

public void simpleVariant(String key, String model) {
variant(key, v -> v.model(model));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public Block createObject() {

@Override
public void generateAssetJsons(AssetJsonGenerator generator) {
generator.blockState(id, m -> m.variant("", id.getNamespace() + ":block/" + id.getPath()));
generator.blockState(id, m -> m.simpleVariant("", id.getNamespace() + ":block/" + id.getPath()));
generator.blockModel(id, m -> {
m.parent("");
m.texture("particle", fluidBuilder.stillTexture.toString());
Expand Down

0 comments on commit 9f17a9f

Please sign in to comment.