Skip to content

Commit

Permalink
Quartz Block Fix and REI Integration
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewperiut committed Dec 20, 2021
1 parent 444d280 commit a2c99ee
Show file tree
Hide file tree
Showing 7 changed files with 192 additions and 36 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17

archivesBaseName = project.archives_base_name
version = project.mod_version
version = project.mod_version + "+" + project.minecraft_version
group = project.maven_group

repositories {
Expand Down
2 changes: 1 addition & 1 deletion 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.12.12

# Mod Properties
mod_version = 1.4.1
mod_version = 1.4.2
maven_group = com.matthewperiut
archives_base_name = chisel

Expand Down
151 changes: 151 additions & 0 deletions src/main/java/com/matthewperiut/chisel/ChiselREI.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
package com.matthewperiut.chisel;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import com.matthewperiut.chisel.block.ChiselGroupLookup;

import me.shedaniel.math.Point;
import me.shedaniel.math.Rectangle;
import me.shedaniel.rei.api.client.gui.Renderer;
import me.shedaniel.rei.api.client.gui.widgets.Slot;
import me.shedaniel.rei.api.client.gui.widgets.Widget;
import me.shedaniel.rei.api.client.gui.widgets.Widgets;
import me.shedaniel.rei.api.client.registry.category.CategoryRegistry;
import me.shedaniel.rei.api.client.registry.display.DisplayCategory;
import me.shedaniel.rei.api.client.registry.display.DisplayRegistry;
import me.shedaniel.rei.api.common.category.CategoryIdentifier;
import me.shedaniel.rei.api.common.display.Display;
import me.shedaniel.rei.api.common.entry.EntryIngredient;
import me.shedaniel.rei.api.common.util.EntryIngredients;
import me.shedaniel.rei.api.common.util.EntryStacks;
import net.minecraft.client.resource.language.I18n;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;

import me.shedaniel.rei.api.client.plugins.REIClientPlugin;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.item.Item;
import net.minecraft.tag.ServerTagManagerHolder;


@Environment(EnvType.CLIENT)
public class ChiselREI implements REIClientPlugin {
@Override
public void registerCategories(CategoryRegistry registry) {
registry.add(new ChiselCategory());

registry.addWorkstations(CategoryIdentifier.of(Chisel.MOD_ID, "chisel_recipes_category"), EntryStacks.of(Chisel.ITEM_CHISEL));
}

@Override
public void registerDisplays(DisplayRegistry registry) {
Iterator<String> chiselGroupNames = ChiselGroupLookup.getGroupNameIterator();
while (chiselGroupNames.hasNext()) {
registry.add(new ChiselDisplay(chiselGroupNames.next()));
}
}

public static class ChiselDisplay implements Display {
private final List<Item> chiselGroupItems;

public ChiselDisplay(String chiselGroup) {
chiselGroupItems = ChiselGroupLookup.getBlocksInGroup(chiselGroup, ServerTagManagerHolder.getTagManager().getOrCreateTagGroup(Registry.ITEM_KEY));
}

@Override
public List<EntryIngredient> getInputEntries() {
List<EntryIngredient> entryIngredientList = new ArrayList<>();
for (Item item : chiselGroupItems) {
entryIngredientList.add(EntryIngredients.of(item));
}
return entryIngredientList;
}

@Override
public List<EntryIngredient> getOutputEntries() {
List<EntryIngredient> entryIngredientList = new ArrayList<>();
for (Item item : chiselGroupItems) {
entryIngredientList.add(EntryIngredients.of(item));
}
return entryIngredientList;
}

@Override
public CategoryIdentifier<?> getCategoryIdentifier() {
return CategoryIdentifier.of(Chisel.MOD_ID, "chisel_recipes_category");
}
}

public static class ChiselCategory implements DisplayCategory<ChiselDisplay> {
private final Identifier TEXTURE = new Identifier(Chisel.MOD_ID, "textures/rei_recipes.png");

@Override
public Renderer getIcon() {
return EntryStacks.of(Chisel.ITEM_CHISEL, 1);
}

@Override
public Text getTitle() {
return Text.of(I18n.translate("rei.chisel.category"));
}

@Override
public CategoryIdentifier<? extends ChiselDisplay> getCategoryIdentifier() {
return CategoryIdentifier.of(Chisel.MOD_ID, "chisel_recipes_category");
}

@Override
public int getDisplayHeight() {
return 200;

}

@Override
public int getDisplayWidth(ChiselDisplay display) {
return 150;
}

@Override
public List<Widget> setupDisplay(ChiselDisplay display, Rectangle bounds) {
List<Widget> widgets = new ArrayList<>();
Point startPoint = new Point(bounds.getMinX() + 21, bounds.getMinY() + 15);
//widgets.add(Widgets.createRecipeBase(bounds));

// draw background texture
List<EntryIngredient> outputEntries = display.getOutputEntries();
int j = outputEntries.size();
int rows = (int)Math.ceil((double) j / 6.0d);
widgets.add(Widgets.createTexturedWidget(TEXTURE, startPoint.x, startPoint.y, 108, 236 - (18 * (10 - rows) + 1)));

//Chisel.LOGGER.info("printing " + rows + " rows (" + (236 - (16 * (10 - rows))) + "px)" );

// draw slots
List<Slot> slots = new ArrayList<>();
slots.add(
Widgets.createSlot(new Point(startPoint.x + 1 + 45, startPoint.y + 1 + 16))
.backgroundEnabled(false)
.markInput()
.entries(display.getInputEntries().get(0))
);
for (int x = 0; x < 6; x++) {
for (int y = 0; y < rows; y++) {
if (6 * y + x >= j) {
break;
}
slots.add(
Widgets.createSlot(new Point(startPoint.x + 1 + 18 * x, startPoint.y + 1 + 55 + 18 * y))
.markOutput()
.entries(outputEntries.get(6 * y + x))
);
}
}
widgets.addAll(slots);

return widgets;
}
}
}
64 changes: 32 additions & 32 deletions src/main/java/com/matthewperiut/chisel/block/GeneratedRegister.java
Original file line number Diff line number Diff line change
Expand Up @@ -2268,38 +2268,38 @@ public static void Register()
Reg("purpur", "twist/purpur", TWIST_PURPUR);
Reg("purpur", "weaver/purpur", WEAVER_PURPUR);
Reg("purpur", "zag/purpur", ZAG_PURPUR);
Reg("quartz", "array/quartz", ARRAY_QUARTZ);
Reg("quartz", "braid/quartz", BRAID_QUARTZ);
Reg("quartz", "chaotic_bricks/quartz", CHAOTIC_BRICKS_QUARTZ);
Reg("quartz", "chaotic_medium/quartz", CHAOTIC_MEDIUM_QUARTZ);
Reg("quartz", "chaotic_small/quartz", CHAOTIC_SMALL_QUARTZ);
Reg("quartz", "circular/quartz", CIRCULAR_QUARTZ);
Reg("quartz", "cracked/quartz", CRACKED_QUARTZ);
Reg("quartz", "cracked_bricks/quartz", CRACKED_BRICKS_QUARTZ);
Reg("quartz", "cut/quartz", CUT_QUARTZ);
Reg("quartz", "dent/quartz", DENT_QUARTZ);
Reg("quartz", "encased_bricks/quartz", ENCASED_BRICKS_QUARTZ);
Reg("quartz", "french/quartz", FRENCH_QUARTZ);
Reg("quartz", "jellybean/quartz", JELLYBEAN_QUARTZ);
Reg("quartz", "large_tile/quartz", LARGE_TILE_QUARTZ);
Reg("quartz", "layer/quartz", LAYER_QUARTZ);
Reg("quartz", "mosaic/quartz", MOSAIC_QUARTZ);
Reg("quartz", "ornate/quartz", ORNATE_QUARTZ);
Reg("quartz", "panel/quartz", PANEL_QUARTZ);
Reg("quartz", "pillar/quartz", PILLAR_QUARTZ);
Reg("quartz", "prism/quartz", PRISM_QUARTZ);
Reg("quartz", "raw/quartz", RAW_QUARTZ);
Reg("quartz", "road/quartz", ROAD_QUARTZ);
Reg("quartz", "slant/quartz", SLANT_QUARTZ);
Reg("quartz", "small_bricks/quartz", SMALL_BRICKS_QUARTZ);
Reg("quartz", "soft_bricks/quartz", SOFT_BRICKS_QUARTZ);
Reg("quartz", "solid_bricks/quartz", SOLID_BRICKS_QUARTZ);
Reg("quartz", "tiles_medium/quartz", TILES_MEDIUM_QUARTZ);
Reg("quartz", "tiles_small/quartz", TILES_SMALL_QUARTZ);
Reg("quartz", "triple_bricks/quartz", TRIPLE_BRICKS_QUARTZ);
Reg("quartz", "twist/quartz", TWIST_QUARTZ);
Reg("quartz", "weaver/quartz", WEAVER_QUARTZ);
Reg("quartz", "zag/quartz", ZAG_QUARTZ);
Reg("quartz_block", "array/quartz", ARRAY_QUARTZ);
Reg("quartz_block", "braid/quartz", BRAID_QUARTZ);
Reg("quartz_block", "chaotic_bricks/quartz", CHAOTIC_BRICKS_QUARTZ);
Reg("quartz_block", "chaotic_medium/quartz", CHAOTIC_MEDIUM_QUARTZ);
Reg("quartz_block", "chaotic_small/quartz", CHAOTIC_SMALL_QUARTZ);
Reg("quartz_block", "circular/quartz", CIRCULAR_QUARTZ);
Reg("quartz_block", "cracked/quartz", CRACKED_QUARTZ);
Reg("quartz_block", "cracked_bricks/quartz", CRACKED_BRICKS_QUARTZ);
Reg("quartz_block", "cut/quartz", CUT_QUARTZ);
Reg("quartz_block", "dent/quartz", DENT_QUARTZ);
Reg("quartz_block", "encased_bricks/quartz", ENCASED_BRICKS_QUARTZ);
Reg("quartz_block", "french/quartz", FRENCH_QUARTZ);
Reg("quartz_block", "jellybean/quartz", JELLYBEAN_QUARTZ);
Reg("quartz_block", "large_tile/quartz", LARGE_TILE_QUARTZ);
Reg("quartz_block", "layer/quartz", LAYER_QUARTZ);
Reg("quartz_block", "mosaic/quartz", MOSAIC_QUARTZ);
Reg("quartz_block", "ornate/quartz", ORNATE_QUARTZ);
Reg("quartz_block", "panel/quartz", PANEL_QUARTZ);
Reg("quartz_block", "pillar/quartz", PILLAR_QUARTZ);
Reg("quartz_block", "prism/quartz", PRISM_QUARTZ);
Reg("quartz_block", "raw/quartz", RAW_QUARTZ);
Reg("quartz_block", "road/quartz", ROAD_QUARTZ);
Reg("quartz_block", "slant/quartz", SLANT_QUARTZ);
Reg("quartz_block", "small_bricks/quartz", SMALL_BRICKS_QUARTZ);
Reg("quartz_block", "soft_bricks/quartz", SOFT_BRICKS_QUARTZ);
Reg("quartz_block", "solid_bricks/quartz", SOLID_BRICKS_QUARTZ);
Reg("quartz_block", "tiles_medium/quartz", TILES_MEDIUM_QUARTZ);
Reg("quartz_block", "tiles_small/quartz", TILES_SMALL_QUARTZ);
Reg("quartz_block", "triple_bricks/quartz", TRIPLE_BRICKS_QUARTZ);
Reg("quartz_block", "twist/quartz", TWIST_QUARTZ);
Reg("quartz_block", "weaver/quartz", WEAVER_QUARTZ);
Reg("quartz_block", "zag/quartz", ZAG_QUARTZ);
Reg("red_concrete", "array/red_concrete", ARRAY_RED_CONCRETE);
Reg("red_concrete", "braid/red_concrete", BRAID_RED_CONCRETE);
Reg("red_concrete", "chaotic_bricks/red_concrete", CHAOTIC_BRICKS_RED_CONCRETE);
Expand Down
Binary file modified src/main/resources/assets/chisel/textures/rei_recipes.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 5 additions & 2 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"schemaVersion": 1,
"id": "chisel",
"version": "1.4.1",
"version": "1.4.2",

"name": "Chisel Refabricated",
"description": "Adds New Blocks!",
Expand All @@ -25,14 +25,17 @@
],
"client": [
"com.matthewperiut.chisel.ChiselClient"
],
"rei_plugins": [
"com.matthewperiut.chisel.ChiselREI"
]
},
"mixins": [],

"depends": {
"fabricloader": ">=0.7.4",
"fabric": "*",
"minecraft": [ "1.17.x", "1.18.x", "1.19.x" ],
"minecraft": [ "1.18.x" ],
"java": "17"
},
"suggests": {
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/writeCode.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ def write_generated_register(register_dir,client_register_dir):

for name in full_names:
semi = name.split('/')
if semi[1] == "quartz":
semi[1] = "quartz_block"
lines.insert(i, ' Reg("' + semi[1] + '", "' + name + '", ' + name.replace('/','_').upper() + ');\n')
i += 1

Expand Down

0 comments on commit a2c99ee

Please sign in to comment.