Skip to content

Commit

Permalink
[1.19.2] code cleanup and lang tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
Christofmeg committed Aug 5, 2023
1 parent 2ff8baa commit 80d4a8f
Show file tree
Hide file tree
Showing 9 changed files with 139 additions and 69 deletions.
32 changes: 19 additions & 13 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
id 'org.parchmentmc.librarian.forgegradle' version '1.+'
}

version = '1.19.2-1.2.1'
version = "${project.minecraft_version}-${project.version}"
group = 'com.christofmeg.${mod_name}'
archivesBaseName = 'ic2cuumatter'

Expand Down Expand Up @@ -66,28 +66,34 @@ repositories {
}

dependencies {
minecraft 'net.minecraftforge:forge:1.19.2-43.2.0'

// CURSEMAVEN
// IC2 CLASSIC
if (project.hasProperty('ic2_version')) {
implementation fg.deobf("curse.maven:ic2_classic-242942:${ic2_version}")
}

minecraft "net.minecraftforge:forge:${project.minecraft_version}-${project.forge_version}"

// IC2 CLASSIC
if (project.hasProperty('ic2_version')) {
implementation fg.deobf("curse.maven:ic2_classic-242942:${ic2_version}")
}
// JEI
if (project.hasProperty('jei_version')) {
compileOnly(fg.deobf("mezz.jei:jei-${minecraft_version}-common-api:${jei_version}"))
compileOnly(fg.deobf("mezz.jei:jei-${minecraft_version}-forge-api:${jei_version}"))
runtimeOnly(fg.deobf("mezz.jei:jei-${minecraft_version}-forge:${jei_version}"))
}
// CONFIGURED
if (project.hasProperty('configured_version')) {
implementation fg.deobf("curse.maven:configured-457570:${configured_version}")
}
// CATALOGUE
if (project.hasProperty('catalogue_version')) {
implementation fg.deobf("curse.maven:catalogue-459701:${catalogue_version}")
}
// REI
if (project.hasProperty('rei_version')) {
compileOnly(fg.deobf("mezz.jei:jei-${minecraft_version}-common-api:11.+"))
compileOnly(fg.deobf("mezz.jei:jei-${minecraft_version}-forge-api:11.+"))

implementation fg.deobf("curse.maven:roughly-enough-items-310111:${rei_version}")

runtimeOnly fg.deobf("curse.maven:roughly-enough-items-hacks-521393:${rei_hacks_version}")
runtimeOnly fg.deobf("curse.maven:cloth-config-348521:${cloth_config_version}")
runtimeOnly fg.deobf("curse.maven:architectury-api-419699:${architectury_version}")
}


}

Expand Down
17 changes: 14 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,24 @@ org.gradle.daemon=false

minecraft_version = 1.19.2
parchment_version = 2022.11.27
forge_version = 43.2.0

#IC2-Classic-1.19.2-2.0.5
ic2_version = 4441313
version = 1.2.2

#IC2-Classic-1.19.2-2.0.6.2
ic2_version = 4563059

# JEI
jei_version = 11.+

# Configured-1.19.2-2.1.1 https://www.curseforge.com/minecraft/mc-mods/configured
configured_version = 4462837

# Catalogue-1.19-1.7.0 https://www.curseforge.com/minecraft/mc-mods/catalogue
catalogue_version = 4171024
catalogue_version = 4171024

# REI
#rei_version = 4647683
rei_hacks_version = 4647810
cloth_config_version = 4633416
architectury_version = 4555749
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.christofmeg.ic2cuumatter.integration.jei;

import ic2.api.recipes.registries.IMachineRecipeList;
import ic2.core.block.machines.components.hv.MassFabricatorComponent;
import ic2.core.block.machines.containers.ev.PlasmafierContainer;
import ic2.core.block.machines.containers.hv.MassFabricatorContainer;
Expand All @@ -10,24 +9,23 @@
import ic2.core.utils.collection.CollectionUtils;
import mezz.jei.api.gui.handlers.IGuiClickableArea;
import mezz.jei.api.gui.handlers.IGuiContainerHandler;
import mezz.jei.api.recipe.RecipeType;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import org.jetbrains.annotations.NotNull;

import java.util.Collection;
import java.util.List;
import java.util.Map;

@OnlyIn(Dist.CLIENT)
public class GuiClickableArea implements IGuiContainerHandler<IC2Screen> {

public GuiClickableArea() {
}

public Collection<IGuiClickableArea> getGuiClickableAreas(IC2Screen containerScreen, double mouseX, double mouseY) {
public @NotNull Collection<IGuiClickableArea> getGuiClickableAreas(@NotNull IC2Screen containerScreen, double mouseX, double mouseY) {
List<IGuiClickableArea> areas = CollectionUtils.createList();
if (containerScreen instanceof ComponentContainerScreen) {
ContainerComponent<?> comp = (ContainerComponent)containerScreen.getCastedContainer(ContainerComponent.class);
ContainerComponent<?> comp = containerScreen.getCastedContainer(ContainerComponent.class);
if (comp != null) {
if (comp.getHolder() != null) {
if (comp instanceof MassFabricatorContainer && comp.getComponent(MassFabricatorComponent.class) != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,26 @@
import mezz.jei.api.JeiPlugin;
import mezz.jei.api.registration.*;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.inventory.MenuType;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.crafting.Ingredient;
import org.jetbrains.annotations.NotNull;

import java.util.Arrays;
import java.util.List;

@JeiPlugin
public class JEIPlugin implements IModPlugin {

@Override
public ResourceLocation getPluginUid() {
public @NotNull ResourceLocation getPluginUid() {
return new ResourceLocation("ic2cuumatter", "jei_plugin");
}

@Override
public void registerCategories(IRecipeCategoryRegistration registration) {
registration.addRecipeCategories(
new MassFabricatorCategory(registration.getJeiHelpers().getGuiHelper(), MassFabricatorContainer.TEXTURE,
IC2Blocks.MASS_FABRICATOR),
new MassFabricatorCategory(registration.getJeiHelpers().getGuiHelper(), IC2Blocks.MASS_FABRICATOR),
new PlasmafierCategory(registration.getJeiHelpers().getGuiHelper(), PlasmafierContainer.TEXTURE,
IC2Blocks.PLASMAFIER));
}
Expand All @@ -50,7 +50,7 @@ public void registerRecipes(IRecipeRegistration registration) {
new ItemStack(IC2Items.UUMATTER), "100,000")));

registration.addRecipes(PlasmafierCategory.TYPE,
Arrays.asList(
List.of(
new PlasmafierCategory.PlasmafierRecipe(Ingredient.of(new ItemStack(IC2Items.UUMATTER, 10)),
Ingredient.of(IC2Items.CELL_EMPTY), new ItemStack(IC2Items.CELL_PLASMA))));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,68 +18,86 @@
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.Ingredient;
import net.minecraft.world.level.ItemLike;
import org.jetbrains.annotations.NotNull;

import java.util.Objects;

public class MassFabricatorCategory implements IRecipeCategory<MassFabricatorCategory.MassFabricatorRecipe> {

public static final RecipeType<MassFabricatorRecipe> TYPE = new RecipeType<>(
new ResourceLocation("ic2cuumatter", "mass_fabricator"), MassFabricatorRecipe.class);

public static final ResourceLocation slotVanilla = new ResourceLocation("jei",
"textures/gui/slot.png");
public static final ResourceLocation guiVanilla = new ResourceLocation("jei",
"textures/gui/gui_vanilla.png");

IDrawable background;
IDrawable icon;
IDrawable slot;
IDrawable bigSlot;

public MassFabricatorCategory(IGuiHelper helper, ResourceLocation texture, ItemLike itemStack) {
background = helper.createDrawable(texture, 13, 14, 133, 69);
public MassFabricatorCategory(IGuiHelper helper, ItemLike itemStack) {
background = helper.createBlankDrawable(133, 69);
icon = helper.createDrawableIngredient(VanillaTypes.ITEM_STACK, new ItemStack(itemStack));
slot = helper.drawableBuilder(slotVanilla, 0, 0, 18, 18).setTextureSize(18, 18).build();
bigSlot = helper.drawableBuilder(guiVanilla, 90, 74, 26, 26).build();
}

@Override
public RecipeType<MassFabricatorRecipe> getRecipeType() {
public @NotNull RecipeType<MassFabricatorRecipe> getRecipeType() {
return TYPE;
}

@Override
public Component getTitle() {
public @NotNull Component getTitle() {
return Component.translatable("block.ic2.mass_fabricator");
}

@Override
public IDrawable getBackground() {
public @NotNull IDrawable getBackground() {
return background;
}

@Override
public IDrawable getIcon() {
public @NotNull IDrawable getIcon() {
return icon;
}

@Override
public void setRecipe(IRecipeLayoutBuilder iRecipeLayoutBuilder, MassFabricatorRecipe recipe,
IFocusGroup iFocusGroup) {
@NotNull IFocusGroup iFocusGroup) {
iRecipeLayoutBuilder.addSlot(RecipeIngredientRole.INPUT, 67, 42).addIngredients(recipe.item());
iRecipeLayoutBuilder.addSlot(RecipeIngredientRole.OUTPUT, 67, 5).addItemStack(recipe.output());
}

@SuppressWarnings("resource")
@Override
public void draw(MassFabricatorRecipe recipe, IRecipeSlotsView recipeSlotsView, PoseStack stack, double mouseX,
double mouseY) {
public void draw(MassFabricatorRecipe recipe, @NotNull IRecipeSlotsView recipeSlotsView, @NotNull PoseStack stack, double mouseX,
double mouseY) {

slot.draw(stack, 66, 41);
bigSlot.draw(stack, 62, 0);

Font font = Minecraft.getInstance().font;
Component tierHV = Component.translatable("translation.ic2cuumatter.tier.hv");
Component tier = Component.translatable("translation.ic2cuumatter.tier");
Component HV = Component.translatable("translation.ic2cuumatter.tier.hv");
Component tierHV = Component.translatable("translation.ic2cuumatter.format2", tier, HV);
font.draw(stack, tierHV, 0.0F, 0.0F, 4210752);

Component energy = Component.translatable("translation.ic2cuumatter.energy");
font.draw(stack, energy, 0.0F, 52.0F, 4210752);
Component energyFormat = Component.translatable("translation.ic2cuumatter.format1", energy);
font.draw(stack, energyFormat, 0.0F, 52.0F, 4210752);

font.draw(stack, Component.nullToEmpty("7,000,000 EU"), 0.0F, 62.0F, 4210752);
font.draw(stack, Component.nullToEmpty("512 EU/p"), 88.0F, 62.0F, 4210752);

if (recipe.getEnergy() != "0") {
if (!Objects.equals(recipe.getEnergy(), "0")) {
Component amplifier = Component.translatable("translation.ic2cuumatter.amplifier");
font.draw(stack, amplifier, 90.0F, 20.0F, 4210752);
if (recipe.getEnergy() == "100,000") {
Component amplifierFormat = Component.translatable("translation.ic2cuumatter.format1", amplifier);
font.draw(stack, amplifierFormat, 90.0F, 20.0F, 4210752);
if (Objects.equals(recipe.getEnergy(), "100,000")) {
font.draw(stack, Component.nullToEmpty("+ " + recipe.getEnergy()), 86.0F, 30.0F, 4210752);
} else if (recipe.getEnergy() == "45,000") {
} else if (Objects.equals(recipe.getEnergy(), "45,000")) {
font.draw(stack, Component.nullToEmpty("+ " + recipe.getEnergy()), 92.0F, 30.0F, 4210752);
} else {
font.draw(stack, Component.nullToEmpty("+ " + recipe.getEnergy()), 98.0F, 30.0F, 4210752);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.Ingredient;
import net.minecraft.world.level.ItemLike;
import org.jetbrains.annotations.NotNull;

public class PlasmafierCategory implements IRecipeCategory<PlasmafierCategory.PlasmafierRecipe> {

Expand All @@ -27,6 +28,9 @@ public class PlasmafierCategory implements IRecipeCategory<PlasmafierCategory.Pl
public static final ResourceLocation plasmafierTexture = new ResourceLocation("ic2cuumatter",
"textures/gui/plasmafier.png");

public static final ResourceLocation slotVanilla = new ResourceLocation("jei",
"textures/gui/slot.png");

IDrawable background;
IDrawable icon;
IDrawable press1;
Expand All @@ -37,10 +41,27 @@ public class PlasmafierCategory implements IRecipeCategory<PlasmafierCategory.Pl
IDrawable tank3;
IDrawable plasma;
IDrawable glass;
IDrawable slot;
IDrawable frame;
IDrawable frameBottom;
IDrawable frameTop;

int input1X = 31;
int input1Y = 21;
int input2X = 103;
int input2Y = 9;
int outputX = 103;
int outputY = 31;

public PlasmafierCategory(IGuiHelper helper, ResourceLocation texture, ItemLike itemStack) {
background = helper.createDrawable(texture, 13, 14, 132, 64);
background = helper.createBlankDrawable(132, 64);
icon = helper.createDrawableIngredient(VanillaTypes.ITEM_STACK, new ItemStack(itemStack));
slot = helper.drawableBuilder(slotVanilla, 0, 0, 18, 18).setTextureSize(18, 18).build();

frame = helper.drawableBuilder(texture, 78, 15, 20, 52).build();
frameBottom = helper.drawableBuilder(texture, 79, 67, 18, 1).build();
frameTop = helper.drawableBuilder(texture, 79, 14, 18, 1).build();

press1 = helper.createDrawable(texture, 176, 41, 12, 1);
press2 = helper.createDrawable(texture, 176, 42, 12, 1);
press3 = helper.createDrawable(texture, 176, 45, 12, 1);
Expand All @@ -52,36 +73,43 @@ public PlasmafierCategory(IGuiHelper helper, ResourceLocation texture, ItemLike
}

@Override
public RecipeType<PlasmafierRecipe> getRecipeType() {
public @NotNull RecipeType<PlasmafierRecipe> getRecipeType() {
return TYPE;
}

@Override
public Component getTitle() {
public @NotNull Component getTitle() {
return Component.translatable("block.ic2.plasmafier");
}

@Override
public IDrawable getBackground() {
public @NotNull IDrawable getBackground() {
return background;
}

@Override
public IDrawable getIcon() {
public @NotNull IDrawable getIcon() {
return icon;
}

@Override
public void setRecipe(IRecipeLayoutBuilder iRecipeLayoutBuilder, PlasmafierRecipe recipe, IFocusGroup iFocusGroup) {
iRecipeLayoutBuilder.addSlot(RecipeIngredientRole.INPUT, 31, 21).addIngredients(recipe.tool());
iRecipeLayoutBuilder.addSlot(RecipeIngredientRole.INPUT, 103, 9).addIngredients(recipe.block());
iRecipeLayoutBuilder.addSlot(RecipeIngredientRole.OUTPUT, 103, 31).addItemStack(recipe.output());
public void setRecipe(IRecipeLayoutBuilder iRecipeLayoutBuilder, PlasmafierRecipe recipe, @NotNull IFocusGroup iFocusGroup) {
iRecipeLayoutBuilder.addSlot(RecipeIngredientRole.INPUT, input1X, input1Y).addIngredients(recipe.tool());
iRecipeLayoutBuilder.addSlot(RecipeIngredientRole.INPUT, input2X, input2Y).addIngredients(recipe.block());
iRecipeLayoutBuilder.addSlot(RecipeIngredientRole.OUTPUT, outputX, outputY).addItemStack(recipe.output());
}

@SuppressWarnings("resource")
@Override
public void draw(PlasmafierRecipe recipe, IRecipeSlotsView recipeSlotsView, PoseStack stack, double mouseX,
double mouseY) {
public void draw(@NotNull PlasmafierRecipe recipe, @NotNull IRecipeSlotsView recipeSlotsView, @NotNull PoseStack stack, double mouseX,
double mouseY) {
slot.draw(stack, input1X - 1, input1Y - 1);
slot.draw(stack, input2X - 1, input2Y - 1);
slot.draw(stack, outputX - 1, outputY - 1);

frame.draw(stack, 65, 1);
frameBottom.draw(stack, 66, 53);
frameTop.draw(stack, 66, 0);

press1.draw(stack, 69, 45);
press2.draw(stack, 69, 46);
press2.draw(stack, 69, 47);
Expand All @@ -94,11 +122,14 @@ public void draw(PlasmafierRecipe recipe, IRecipeSlotsView recipeSlotsView, Pose
glass.draw(stack, 68, 4);

Font font = Minecraft.getInstance().font;
Component tierEV = Component.translatable("translation.ic2cuumatter.tier.ev");
Component tier = Component.translatable("translation.ic2cuumatter.tier");
Component EV = Component.translatable("translation.ic2cuumatter.tier.ev");
Component tierEV = Component.translatable("translation.ic2cuumatter.format2", tier, EV);
font.draw(stack, tierEV, 0.0F, 0.0F, 4210752);

Component ticks = Component.translatable("translation.ic2cuumatter.ticks");
font.draw(stack, ticks, 0.0F, 57.0F, 4210752);
Component ticksFormat = Component.translatable("translation.ic2cuumatter.format2", ticks, "2,500");
font.draw(stack, ticksFormat, 0.0F, 57.0F, 4210752);
font.draw(stack, Component.nullToEmpty("2,048 EU/p"), 79.0F, 57.0F, 4210752);
}

Expand Down
Loading

0 comments on commit 80d4a8f

Please sign in to comment.