Skip to content

Commit

Permalink
Fix Recycling Groovy Helpers, Localize Colours, JEI Helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
IntegerLimit committed Jan 21, 2024
1 parent c2d444f commit 5853388
Show file tree
Hide file tree
Showing 45 changed files with 597 additions and 442 deletions.
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,11 @@ org.gradle.jvmargs = -Xmx3G

# Whether to enable Storage Drawers and its deps in runtime. Enables Hand Framing Tool.
# If this is set to false, the hand framing tool is disabled.
enable_storage_drawers = false
enable_storage_drawers = true

# Whether to enable Framed Compacting Drawers and its deps in runtime. Enables more of the Hand Framing Tool.
# Requires `enable_storage_drawers` to be set to true.
enable_framed_compact = false
enable_framed_compact = true

# Whether to enable Ender IO and its deps in runtime. Enables Custom Capacitors.
# If this is set to false, custom capacitors are disabled.
Expand All @@ -219,7 +219,7 @@ enable_ae2 = false

# Whether to enable Extended Crafting in runtime. Enables Extended Crafting Blocks in DME Sim Chamber and Naq Reactors.
# If this is set to false, those blocks will be set to air.
enable_extended_crafting = false
enable_extended_crafting = true

# Whether to enable Draconic Evolution in runtime. Enables the energy core and reactor mixin improvements, and Draconic Evolution blocks in Universal Crystallizer.
# If this is set to false, the mixin will not apply, and those blocks will be set to air.
Expand Down
24 changes: 11 additions & 13 deletions src/main/groovy-tests/forMaterialTests.groovy
Original file line number Diff line number Diff line change
@@ -1,34 +1,33 @@
import net.minecraft.item.ItemStack

import static com.nomiceu.nomilabs.groovy.GroovyHelpers.*
import net.minecraftforge.fluids.Fluid

import static com.nomiceu.nomilabs.groovy.GroovyHelpers.MaterialHelpers.*

// Actions on Items include all material items and blocks, and buckets containing any material fluid.
// Actions on Fluids include liquids, gasses, solids, and addon fluids (such as molten fluids, added by GCYM)

println("ITEMS:")

// Do an Action for each Material's Item (GregTech's)
MaterialHelpers.forMaterialItem(material('tungsten_steel'), (stack) -> println(getFormattingForStack(stack, "Tungsten Steel")))
forMaterialItem(material('tungsten_steel'), (stack) -> println(getFormattingForStack(stack, "Tungsten Steel")))

// Do an Action for each Material's Item (Nomi Labs')
MaterialHelpers.forMaterialItem(material('nomilabs:dulysite'), (stack) -> println(getFormattingForStack(stack, "Dulysite")))
forMaterialItem(material('nomilabs:dulysite'), (stack) -> println(getFormattingForStack(stack, "Dulysite")))

println("FLUIDS:")

// Do an Action for each Material's Fluid (GregTech's)
MaterialHelpers.forMaterialFluid(material('tungsten_steel'), (fluid) -> println(getFormattingForFluid(fluid, "Tungsten Steel")))
forMaterialFluid(material('tungsten_steel'), (fluid) -> println(getFormattingForFluid(fluid, "Tungsten Steel")))

// Do an Action for each Material's Fluid (Nomi Labs')
MaterialHelpers.forMaterialFluid(material('nomilabs:dulysite'), (fluid) -> println(getFormattingForFluid(fluid, "Dulysite")))
forMaterialFluid(material('nomilabs:dulysite'), (fluid) -> println(getFormattingForFluid(fluid, "Dulysite")))

println("COMBINED:")

// Do an Action for each Material's Items and Fluids (GregTech's)
MaterialHelpers.forMaterial(material('tungsten_steel'), (stack) -> println(getFormattingForStack(stack, "Tungsten Steel")), (fluid) -> println(getFormattingForFluid(fluid, "Tungsten Steel")))
forMaterial(material('tungsten_steel'), (stack) -> println(getFormattingForStack(stack, "Tungsten Steel")), (fluid) -> println(getFormattingForFluid(fluid, "Tungsten Steel")))

// Do an Action for each Material's Items and Fluids (Nomi Labs')
MaterialHelpers.forMaterial(material('nomilabs:dulysite'), (stack) -> println(getFormattingForStack(stack, "Dulysite")), (fluid) -> println(getFormattingForFluid(fluid, "Dulysite")))
forMaterial(material('nomilabs:dulysite'), (stack) -> println(getFormattingForStack(stack, "Dulysite")), (fluid) -> println(getFormattingForFluid(fluid, "Dulysite")))

static String getFormattingForStack(ItemStack stack, String name) {
if (!stack.hasTagCompound()) return "${name}: Item: ${stack.getItem().getRegistryName()} at ${stack.getMetadata()} with no tag."
Expand All @@ -42,11 +41,10 @@ static String getFormattingForFluid(Fluid fluid, String name) {

// JEI Shortforms
// Hide All Material Items and Fluids
MaterialHelpers.hideMaterial(material('nomilabs:taranium'))
hideMaterial(material('nomilabs:taranium'))

// Remove and Hide All Material Items and Fluids (Removes crafting recipes outputting material items)
MaterialHelpers.removeAndHideMaterial(material('titanium'))
removeAndHideMaterial(material('titanium'))

// Same as above, but... yeet. Same as Groovy's
MaterialHelpers.yeetMaterial(material('gcym:watertight_steel'))

yeetMaterial(material('gcym:watertight_steel'))
20 changes: 20 additions & 0 deletions src/main/groovy-tests/jeiTests.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import net.minecraft.util.text.TextFormatting

import static com.nomiceu.nomilabs.groovy.GroovyHelpers.JEIHelpers.*
import static com.nomiceu.nomilabs.groovy.GroovyHelpers.TranslationHelpers.*

/* Description Pages. Each entry is seperated by double new lines. */

// Add a description page for a stack
addDescription(item('minecraft:apple'), format("An Ordinary Apple... Not Poisoned.", TextFormatting.DARK_GREEN), "Eat it!")

// Add a translated description page for a stack
addDescription(item('minecraft:iron_ingot'), translate("tooltip.nomilabs.greenhouse.description"), translate("tooltip.nomilabs.dme_sim_chamber.description"))

/* Recipe Output Tooltips. These are tooltips that appear on recipes that output that stack. */

// Add a recipe output tooltip for a stack
addRecipeOutputTooltip(item('minecraft:golden_apple'), format("An Ordinary Apple... Not Poisoned.", TextFormatting.GREEN), "Eat it!")

// Add a translated recipe output tooltip for a stack
addRecipeOutputTooltip(item('minecraft:iron_ingot'), translate("tooltip.nomilabs.greenhouse.description"), translate("tooltip.nomilabs.dme_sim_chamber.description"))
5 changes: 1 addition & 4 deletions src/main/groovy-tests/replaceRecyclingTests.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,4 @@ replaceRecipeInput("electric_motor_hv", [
[metaitem('plateWroughtIron'), metaitem('plateWroughtIron'), metaitem('plateWroughtIron')],
[metaitem('plateWroughtIron'), ore('toolWrench'), metaitem('plateWroughtIron')],
[metaitem('plateWroughtIron'), metaitem('plateWroughtIron'), metaitem('plateWroughtIron')]
])

// Reload recycling recipes (so it works in GS Reload, and in the postInit phase)
reloadRecyclingRecipes()
])
1 change: 1 addition & 0 deletions src/main/java/com/nomiceu/nomilabs/LabsValues.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ public class LabsValues {
public static final String STORAGE_DRAWERS_MODID = "storagedrawers";
public static final String FRAMED_COMPACT_MODID = "framedcompactdrawers";
public static final String ENDER_IO_MODID = "enderio";
public static final String JEI_MODID = "jei";
}
4 changes: 2 additions & 2 deletions src/main/java/com/nomiceu/nomilabs/NomiLabs.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import com.nomiceu.nomilabs.event.ClientProxy;
import com.nomiceu.nomilabs.event.CommonProxy;
import com.nomiceu.nomilabs.remap.datafixer.DataFixerHandler;
import com.nomiceu.nomilabs.util.LabsSide;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.event.*;
Expand All @@ -32,7 +32,7 @@ public class NomiLabs {
@EventHandler
public void preInit(FMLPreInitializationEvent event) {
MinecraftForge.EVENT_BUS.register(this);
if (FMLCommonHandler.instance().getEffectiveSide().isClient())
if (LabsSide.isClient())
ClientProxy.preInit();
CommonProxy.preInit();
}
Expand Down
24 changes: 7 additions & 17 deletions src/main/java/com/nomiceu/nomilabs/block/BlockBase.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package com.nomiceu.nomilabs.block;

import com.google.common.collect.ImmutableList;
import com.nomiceu.nomilabs.integration.top.TOPInfoProvider;
import com.nomiceu.nomilabs.tooltip.LabsTooltipHelper;
import net.minecraft.block.Block;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
Expand All @@ -18,13 +16,14 @@
import org.jetbrains.annotations.Nullable;

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

public class BlockBase extends Block implements TOPInfoProvider {
private List<LabsTooltipHelper.Tooltip> description;
private String[] description;
public BlockBase(ResourceLocation rl, CreativeTabs tab, Material material, SoundType sound) {
super(material);
initialize(rl, tab, sound, ImmutableList.of());
initialize(rl, tab, sound);
}

/**
Expand All @@ -35,12 +34,12 @@ public BlockBase(ResourceLocation rl, CreativeTabs tab, Material material, Sound
* @param sound Sound
* @param description Description. Map of translation keys to formatting keys. Is of string to string so we can use GTFormatCodes
*/
public BlockBase(ResourceLocation rl, CreativeTabs tab, Material material, SoundType sound, List<LabsTooltipHelper.Tooltip> description) {
public BlockBase(ResourceLocation rl, CreativeTabs tab, Material material, SoundType sound, String... description) {
super(material);
initialize(rl, tab, sound, description);
}

private void initialize(ResourceLocation rl, CreativeTabs tab, SoundType sound, List<LabsTooltipHelper.Tooltip> description) {
private void initialize(ResourceLocation rl, CreativeTabs tab, SoundType sound, String... description) {
this.setRegistryName(rl);
this.setHardness(2.0F);
this.setResistance(10.0F);
Expand All @@ -49,24 +48,15 @@ private void initialize(ResourceLocation rl, CreativeTabs tab, SoundType sound,
this.description = description;
}

/**
* I18n formatting is done here instead of in constructor as I18n is client only
*/
@Override
@SideOnly(Side.CLIENT)
public void addInformation(@NotNull ItemStack stack, @Nullable World world, @NotNull List<String> tooltip, @NotNull ITooltipFlag flagIn) {
for (var text : description)
tooltip.add(text.getFormattedString());
tooltip.addAll(Arrays.asList(description));
}

@Override
@SideOnly(Side.CLIENT)
public List<String> getTOPMessage(IBlockState state) {
List<String> tooltip = new ArrayList<>();
for (var text : description) {
var string = text.getTOPFormattedString();
if (string != null) tooltip.add(string);
}
return tooltip;
return new ArrayList<>(Arrays.asList(description));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import net.minecraft.block.*;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.util.Mirror;
import net.minecraft.util.ResourceLocation;
Expand All @@ -14,7 +13,6 @@
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.util.math.BlockPos;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.IBlockAccess;
import net.minecraft.util.EnumFacing;
import net.minecraft.block.state.BlockFaceShape;
Expand All @@ -25,6 +23,8 @@

import java.util.List;

import static com.nomiceu.nomilabs.util.LabsTranslate.*;

@SuppressWarnings({"PointlessArithmeticExpression", "deprecation"})
public class BlockExcitationCoil extends BlockDirectional implements TOPInfoProvider {

Expand Down Expand Up @@ -150,6 +150,6 @@ public int getMetaFromState(IBlockState state)
@Override
@SideOnly(Side.CLIENT)
public List<String> getTOPMessage(IBlockState state) {
return ImmutableList.of(TextFormatting.GRAY + I18n.format("tooltip.nomilabs.excitationcoil.description_block"));
return ImmutableList.of(translate("tooltip.nomilabs.general.crafting_component"));
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.nomiceu.nomilabs.block.registry;

import com.google.common.collect.ImmutableList;
import com.nomiceu.nomilabs.block.*;
import com.nomiceu.nomilabs.item.ItemBlockBase;
import com.nomiceu.nomilabs.creativetab.registry.LabsCreativeTabs;
Expand All @@ -13,7 +12,6 @@
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.common.IRarity;
import net.minecraftforge.registries.IForgeRegistry;
import org.jetbrains.annotations.NotNull;
Expand All @@ -25,7 +23,7 @@
import java.util.function.Function;

import static com.nomiceu.nomilabs.util.LabsNames.makeLabsName;
import static com.nomiceu.nomilabs.tooltip.LabsTooltipHelper.Tooltip;
import static com.nomiceu.nomilabs.util.LabsTranslate.*;

@SuppressWarnings("unused")
public class LabsBlocks {
Expand Down Expand Up @@ -60,10 +58,10 @@ public static void preInit() {

/* Ultimate Blocks */
ULTIMATE_POWER_STORAGE = createBlock(new BlockBase(makeLabsName("ultimate_power_storage"), LabsCreativeTabs.TAB_NOMI_LABS, Material.IRON, SoundType.METAL,
ImmutableList.of(Tooltip.of("tooltip.nomilabs.ultimate_items.description").withFormat(TextFormatting.GRAY))),
translate("tooltip.nomilabs.general.crafting_component")),
EnumRarity.EPIC, 1);
ULTIMATE_GENERATOR = createBlock(new BlockBase(makeLabsName("ultimate_generator"), LabsCreativeTabs.TAB_NOMI_LABS, Material.IRON, SoundType.METAL,
ImmutableList.of(Tooltip.of("tooltip.nomilabs.ultimate_items.description").withFormat(TextFormatting.GRAY))),
translate("tooltip.nomilabs.general.crafting_component")),
EnumRarity.EPIC, 1);

/* Misc Blocks */
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/nomiceu/nomilabs/core/LabsLateMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ public class LabsLateMixin implements ILateMixinLoader {
LabsValues.DRACONIC_MODID, LabsConfig.modIntegration.draconicEvolutionIntegration.enableDraconicEvolutionIntegration,
LabsValues.NUCLEARCRAFT_MODID, LabsConfig.modIntegration.enableNuclearCraftIntegration,
LabsValues.XU2_MODID, LabsConfig.modIntegration.enableExtraUtils2Integration,
LabsValues.GREGTECH_MODID, true
LabsValues.GREGTECH_MODID, true,
LabsValues.JEI_MODID, true
);

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/nomiceu/nomilabs/event/CommonProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public static void registerRecipes(RegistryEvent.Register<IRecipe> event) {
if (LabsConfig.content.customContent.enableComplexRecipes && LabsItems.HAND_FRAMING_TOOL != null)
event.getRegistry().register(new HandFramingRecipe(LabsNames.makeLabsName("hand_framing_recipe")));

//com.nomiceu.nomilabs.recipe.LabsTestRecipes.initRecipes();
com.nomiceu.nomilabs.recipe.LabsTestRecipes.initRecipes();
}

@SubscribeEvent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@
import gregtech.common.blocks.MetaBlocks;
import gregtech.core.sound.GTSoundEvents;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.resources.I18n;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundEvent;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
Expand All @@ -27,6 +25,8 @@

import java.util.List;

import static com.nomiceu.nomilabs.util.LabsTranslate.translate;

public class MetaTileEntityActualizationChamber extends RecipeMapMultiblockController {
public MetaTileEntityActualizationChamber(ResourceLocation metaTileEntityId) {
super(metaTileEntityId, LabsRecipeMaps.ACTUALIZATION_CHAMBER_RECIPES);
Expand Down Expand Up @@ -89,7 +89,7 @@ public boolean canBeDistinct() {
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, @Nullable World world, @NotNull List<String> tooltip, boolean advanced) {
tooltip.add(TextFormatting.DARK_GRAY + I18n.format("tooltip.nomilabs.actualization_chamber.description") + TextFormatting.RESET);
tooltip.add(translate("tooltip.nomilabs.actualization_chamber.description"));
super.addInformation(stack, world, tooltip, advanced);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@
import gregtech.common.blocks.*;
import gregtech.core.sound.GTSoundEvents;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.resources.I18n;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundEvent;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
Expand All @@ -29,6 +27,8 @@

import java.util.List;

import static com.nomiceu.nomilabs.util.LabsTranslate.*;

public class MetaTileEntityCreativeTankProvider extends RecipeMapMultiblockController {

public MetaTileEntityCreativeTankProvider(ResourceLocation metaTileEntityId) {
Expand Down Expand Up @@ -88,7 +88,7 @@ public boolean canBeDistinct() {
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, @Nullable World world, @NotNull List<String> tooltip, boolean advanced) {
tooltip.add(TextFormatting.DARK_GRAY + I18n.format("tooltip.nomilabs.creative_tank_provider.description") + TextFormatting.RESET);
tooltip.add(translate("tooltip.nomilabs.creative_tank_provider.description"));
super.addInformation(stack, world, tooltip, advanced);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,10 @@
import gregtech.common.blocks.MetaBlocks;
import gregtech.core.sound.GTSoundEvents;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.resources.I18n;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundEvent;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.relauncher.Side;
Expand All @@ -35,6 +33,8 @@

import java.util.List;

import static com.nomiceu.nomilabs.util.LabsTranslate.*;

public class MetaTileEntityDMESimChamber extends RecipeMapMultiblockController {
public MetaTileEntityDMESimChamber(ResourceLocation metaTileEntityId) {
super(metaTileEntityId, LabsRecipeMaps.DME_SIM_CHAMBER_RECIPES);
Expand Down Expand Up @@ -122,7 +122,7 @@ public boolean canBeDistinct() {
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, @Nullable World world, @NotNull List<String> tooltip, boolean advanced) {
tooltip.add(TextFormatting.DARK_GRAY + I18n.format("tooltip.nomilabs.dme_sim_chamber.description") + TextFormatting.RESET);
tooltip.add(translate("tooltip.nomilabs.dme_sim_chamber.description"));
super.addInformation(stack, world, tooltip, advanced);
}
}
Loading

0 comments on commit 5853388

Please sign in to comment.