Skip to content

Commit

Permalink
Merge pull request #15 from Zundrel/master
Browse files Browse the repository at this point in the history
Allow defining a table as non-opaque.
  • Loading branch information
Meredith Espinosa authored Jan 30, 2020
2 parents 47e1c73 + de0056d commit f83ada4
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
6 changes: 5 additions & 1 deletion src/main/java/io/github/alloffabric/artis/Artis.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ public void onInitialize() {
public static Block registerTable(ArtisTableType type, Optional<Block.Settings> settings) {
Identifier id = type.getId();
ContainerProviderRegistry.INSTANCE.registerFactory(id, (syncId, containerId, player, buf) -> new ArtisCraftingController(type, syncId, player, BlockContext.create(player.world, buf.readBlockPos())));
ArtisTableBlock block = Registry.register(Registry.BLOCK, id, new ArtisTableBlock(type, settings.orElse(FabricBlockSettings.copy(Blocks.CRAFTING_TABLE).build())));
Block.Settings blockSettings = settings.orElse(FabricBlockSettings.copy(Blocks.CRAFTING_TABLE).build());
if (!type.isOpaque()) {
blockSettings = blockSettings.nonOpaque();
}
ArtisTableBlock block = Registry.register(Registry.BLOCK, id, new ArtisTableBlock(type, blockSettings));
ARTIS_TABLE_BLOCKS.add(block);
Registry.register(Registry.ITEM, id, new ArtisTableItem(block, new Item.Settings().group(ARTIS_GROUP)));
Registry.register(ARTIS_TABLE_TYPES, id, type);
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/io/github/alloffabric/artis/ArtisData.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,11 @@ static ArtisTableType getType(String key, JsonObject json) {
height = 9;
}
boolean genAssets = json.containsKey("generate_assets")? json.get(Boolean.class, ("generate_assets")) : false;
boolean opaque = json.containsKey("opaque")? json.get(Boolean.class, ("opaque")) : true;
if (json.containsKey("color")) {
return new ArtisTableType(id, width, height, genAssets, Integer.decode(json.get(String.class, "color").replace("#", "0x")));
return new ArtisTableType(id, width, height, genAssets, opaque, Integer.decode(json.get(String.class, "color").replace("#", "0x")));
}
return new ArtisTableType(id, width, height, genAssets);
return new ArtisTableType(id, width, height, genAssets, opaque);
}

}
14 changes: 10 additions & 4 deletions src/main/java/io/github/alloffabric/artis/api/ArtisTableType.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,24 @@ public class ArtisTableType implements RecipeType {
private int height;
private int color = 0;
private boolean generateAssets;
private boolean opaque;
private boolean hasColor = false;
private RecipeSerializer shaped;
private RecipeSerializer shapeless;

public ArtisTableType(Identifier id, int width, int height, boolean makeModel, int color) {
this(id, width, height, makeModel);
public ArtisTableType(Identifier id, int width, int height, boolean makeModel, boolean opaque, int color) {
this(id, width, height, makeModel, opaque);
this.color = 0xFF000000 | color;
this.hasColor = true;
}

//TODO: block settings?
public ArtisTableType(Identifier id, int width, int height, boolean makeModel) {
public ArtisTableType(Identifier id, int width, int height, boolean makeModel, boolean opaque) {
this.id = id;
this.width = width;
this.height = height;
this.generateAssets = makeModel;
this.opaque = opaque;
Identifier shapedId = new Identifier(id.getNamespace(), id.getPath() + "_shaped");
Identifier shapelessId = new Identifier(id.getNamespace(), id.getPath() + "_shapeless");
this.shaped = Registry.register(Registry.RECIPE_SERIALIZER, shapedId, new ShapedArtisSerializer(this));
Expand Down Expand Up @@ -59,7 +61,11 @@ public boolean shouldGenerateAssets() {
return generateAssets;
}

public boolean hasColor() {
public boolean isOpaque() {
return opaque;
}

public boolean hasColor() {
return hasColor;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package io.github.alloffabric.artis.compat.rei;

import com.mojang.blaze3d.platform.GlStateManager;
Expand Down

0 comments on commit f83ada4

Please sign in to comment.