98 lines
3.6 KiB
Java
98 lines
3.6 KiB
Java
package com.thebrokenrail.energonrelics.client.rei.reactor;
|
|
|
|
import com.thebrokenrail.energonrelics.EnergonRelics;
|
|
import com.thebrokenrail.energonrelics.registry.reactor.ReactorFuelRegistry;
|
|
import com.thebrokenrail.energonrelics.client.rei.EnergonRelicsPlugin;
|
|
import me.shedaniel.math.Point;
|
|
import me.shedaniel.math.Rectangle;
|
|
import me.shedaniel.rei.api.EntryStack;
|
|
import me.shedaniel.rei.api.RecipeCategory;
|
|
import me.shedaniel.rei.api.RecipeHelper;
|
|
import me.shedaniel.rei.api.widgets.Slot;
|
|
import me.shedaniel.rei.api.widgets.Tooltip;
|
|
import me.shedaniel.rei.api.widgets.Widgets;
|
|
import me.shedaniel.rei.gui.entries.RecipeEntry;
|
|
import me.shedaniel.rei.gui.widget.Widget;
|
|
import net.fabricmc.api.EnvType;
|
|
import net.fabricmc.api.Environment;
|
|
import net.minecraft.client.resource.language.I18n;
|
|
import net.minecraft.client.util.math.MatrixStack;
|
|
import net.minecraft.item.Item;
|
|
import net.minecraft.item.ItemStack;
|
|
import net.minecraft.text.Text;
|
|
import net.minecraft.text.TranslatableText;
|
|
import net.minecraft.util.Identifier;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
@Environment(EnvType.CLIENT)
|
|
public class ReactorFuelCategory implements RecipeCategory<ReactorFuelDisplay> {
|
|
@Override
|
|
public List<Widget> setupDisplay(ReactorFuelDisplay display, Rectangle bounds) {
|
|
Point startPoint = new Point(bounds.getCenterX() - 41, bounds.getCenterY() - 13);
|
|
List<Widget> widgets = new ArrayList<>();
|
|
widgets.add(Widgets.createRecipeBase(bounds));
|
|
widgets.add(Widgets.createSlot(new Point(bounds.x + 9, startPoint.y + 5)).entries(display.getInputEntries().get(0)).markInput());
|
|
|
|
Text text = new TranslatableText("category.rei." + EnergonRelics.NAMESPACE + ".reactor_fuel.multiplier", String.valueOf(display.multiplier));
|
|
widgets.add(Widgets.createLabel(new Point(bounds.x + 31, startPoint.y + 8), text).noShadow().leftAligned().color(0xFF404040, 0xFFBBBBBB));
|
|
|
|
return widgets;
|
|
}
|
|
|
|
@Override
|
|
public int getDisplayHeight() {
|
|
return 36;
|
|
}
|
|
|
|
@Override
|
|
public Identifier getIdentifier() {
|
|
return EnergonRelicsPlugin.REACTOR_FUEL;
|
|
}
|
|
|
|
@Override
|
|
public EntryStack getLogo() {
|
|
return EntryStack.create(EnergonRelics.REACTOR_INPUT_BLOCK);
|
|
}
|
|
|
|
@Override
|
|
public String getCategoryName() {
|
|
return I18n.translate("category.rei." + EnergonRelics.NAMESPACE + ".reactor_fuel.name");
|
|
}
|
|
|
|
@Override
|
|
public RecipeEntry getSimpleRenderer(ReactorFuelDisplay recipe) {
|
|
Slot slot = Widgets.createSlot(new Point(0, 0)).entries(recipe.getInputEntries().get(0)).disableBackground().disableHighlight();
|
|
return new RecipeEntry() {
|
|
@Override
|
|
public int getHeight() {
|
|
return 22;
|
|
}
|
|
|
|
@Override
|
|
public Tooltip getTooltip(Point point) {
|
|
if (slot.containsMouse(point)) {
|
|
return slot.getCurrentTooltip(point);
|
|
} else {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void render(MatrixStack matrices, Rectangle bounds, int mouseX, int mouseY, float delta) {
|
|
slot.setZ(getZ() + 50);
|
|
slot.getBounds().setLocation(bounds.x + bounds.width / 2 - 10, bounds.y + 2);
|
|
slot.render(matrices, mouseX, mouseY, delta);
|
|
}
|
|
};
|
|
}
|
|
|
|
public static void register(RecipeHelper recipeHelper) {
|
|
for (Map.Entry<Item, Float> entry : ReactorFuelRegistry.entrySet()) {
|
|
recipeHelper.registerDisplay(new ReactorFuelDisplay(new ItemStack(entry.getKey()), entry.getValue()));
|
|
}
|
|
}
|
|
}
|