Skip to content

Commit

Permalink
Merge pull request #17 from Tctraveler/main
Browse files Browse the repository at this point in the history
Tc_traveler's PR -> Add some Thaumic things.
  • Loading branch information
Keriils authored Sep 7, 2024
2 parents db62805 + 351ac36 commit aadd07b
Show file tree
Hide file tree
Showing 18 changed files with 753 additions and 3 deletions.
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,7 @@ indent_size = 2

[*.lang]
trim_trailing_whitespace = false

[*.java]
ij_java_class_count_to_use_import_on_demand = 66666
ij_java_names_count_to_use_import_on_demand = 66666
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ addon.local.gradle.kts
addon.late.local.gradle
addon.late.local.gradle.kts
layout.json
/ToDo
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
package com.xir.NHUtilities.common.enumPackages;

import static gregtech.api.enums.GT_Values.NI;
import static gregtech.api.enums.GT_Values.W;

import java.util.Locale;

import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;

import gregtech.api.interfaces.IItemContainer;
import gregtech.api.util.GT_LanguageManager;
import gregtech.api.util.GT_Log;
import gregtech.api.util.GT_ModHandler;
import gregtech.api.util.GT_OreDictUnificator;
import gregtech.api.util.GT_Utility;

public enum CustomItemList implements IItemContainer {

Machine_Multi_TCBlastFurnace;

private ItemStack mStack;
private boolean mHasNotBeenSet;
private boolean mDeprecated;
private boolean mWarned;

CustomItemList() {
mHasNotBeenSet = true;
}

CustomItemList(boolean aDeprecated) {
if (aDeprecated) {
mDeprecated = true;
mHasNotBeenSet = true;
}
}

@Override
public IItemContainer set(Item aItem) {
mHasNotBeenSet = false;
if (aItem == null) return this;
ItemStack aStack = new ItemStack(aItem, 1, 0);
mStack = GT_Utility.copyAmount(1, aStack);
return this;
}

@Override
public IItemContainer set(ItemStack aStack) {
mHasNotBeenSet = false;
mStack = GT_Utility.copyAmount(1, aStack);
return this;
}

@Override
public Item getItem() {
sanityCheck();
if (GT_Utility.isStackInvalid(mStack)) return null;
return mStack.getItem();
}

@Override
public Block getBlock() {
sanityCheck();
return GT_Utility.getBlockFromItem(getItem());
}

@Override
public final boolean hasBeenSet() {
return !mHasNotBeenSet;
}

@Override
public boolean isStackEqual(Object aStack) {
return isStackEqual(aStack, false, false);
}

@Override
public boolean isStackEqual(Object aStack, boolean aWildcard, boolean aIgnoreNBT) {
if (mDeprecated && !mWarned) {
new Exception(this + " is now deprecated").printStackTrace(GT_Log.err);
// warn only once
mWarned = true;
}
if (GT_Utility.isStackInvalid(aStack)) return false;
return GT_Utility.areUnificationsEqual((ItemStack) aStack, aWildcard ? getWildcard(1) : get(1), aIgnoreNBT);
}

@Override
public ItemStack get(long aAmount, Object... aReplacements) {
sanityCheck();
if (GT_Utility.isStackInvalid(mStack)) {
GT_Log.out.println("Object in the ItemList is null at:");
new NullPointerException().printStackTrace(GT_Log.out);
return GT_Utility.copyAmount(aAmount, aReplacements);
}
return GT_Utility.copyAmount(aAmount, GT_OreDictUnificator.get(mStack));
}

@Override
public ItemStack getWildcard(long aAmount, Object... aReplacements) {
sanityCheck();
if (GT_Utility.isStackInvalid(mStack)) return GT_Utility.copyAmount(aAmount, aReplacements);
return GT_Utility.copyAmountAndMetaData(aAmount, W, GT_OreDictUnificator.get(mStack));
}

@Override
public ItemStack getUndamaged(long aAmount, Object... aReplacements) {
sanityCheck();
if (GT_Utility.isStackInvalid(mStack)) return GT_Utility.copyAmount(aAmount, aReplacements);
return GT_Utility.copyAmountAndMetaData(aAmount, 0, GT_OreDictUnificator.get(mStack));
}

@Override
public ItemStack getAlmostBroken(long aAmount, Object... aReplacements) {
sanityCheck();
if (GT_Utility.isStackInvalid(mStack)) return GT_Utility.copyAmount(aAmount, aReplacements);
return GT_Utility.copyAmountAndMetaData(aAmount, mStack.getMaxDamage() - 1, GT_OreDictUnificator.get(mStack));
}

@Override
public ItemStack getWithName(long aAmount, String aDisplayName, Object... aReplacements) {
ItemStack rStack = get(1, aReplacements);
if (GT_Utility.isStackInvalid(rStack)) return NI;

// CamelCase alphanumeric words from aDisplayName
StringBuilder tCamelCasedDisplayNameBuilder = new StringBuilder();
final String[] tDisplayNameWords = aDisplayName.split("\\W");
for (String tWord : tDisplayNameWords) {
if (tWord.length() > 0) tCamelCasedDisplayNameBuilder.append(
tWord.substring(0, 1)
.toUpperCase(Locale.US));
if (tWord.length() > 1) tCamelCasedDisplayNameBuilder.append(
tWord.substring(1)
.toLowerCase(Locale.US));
}
if (tCamelCasedDisplayNameBuilder.length() == 0) {
// CamelCased DisplayName is empty, so use hash of aDisplayName
tCamelCasedDisplayNameBuilder.append(((Long) (long) aDisplayName.hashCode()));
}

// Construct a translation key from UnlocalizedName and CamelCased DisplayName
final String tKey = rStack.getUnlocalizedName() + ".with." + tCamelCasedDisplayNameBuilder + ".name";

rStack.setStackDisplayName(GT_LanguageManager.addStringLocalization(tKey, aDisplayName));
return GT_Utility.copyAmount(aAmount, rStack);
}

@Override
public ItemStack getWithCharge(long aAmount, int aEnergy, Object... aReplacements) {
ItemStack rStack = get(1, aReplacements);
if (GT_Utility.isStackInvalid(rStack)) return null;
GT_ModHandler.chargeElectricItem(rStack, aEnergy, Integer.MAX_VALUE, true, false);
return GT_Utility.copyAmount(aAmount, rStack);
}

@Override
public ItemStack getWithDamage(long aAmount, long aMetaValue, Object... aReplacements) {
sanityCheck();
if (GT_Utility.isStackInvalid(mStack)) return GT_Utility.copyAmount(aAmount, aReplacements);
return GT_Utility.copyAmountAndMetaData(aAmount, aMetaValue, GT_OreDictUnificator.get(mStack));
}

@Override
public IItemContainer registerOre(Object... aOreNames) {
sanityCheck();
for (Object tOreName : aOreNames) GT_OreDictUnificator.registerOre(tOreName, get(1));
return this;
}

@Override
public IItemContainer registerWildcardAsOre(Object... aOreNames) {
sanityCheck();
for (Object tOreName : aOreNames) GT_OreDictUnificator.registerOre(tOreName, getWildcard(1));
return this;
}

public ItemStack getInternalStack_unsafe() {
return mStack;
}

private void sanityCheck() {
if (mHasNotBeenSet)
throw new IllegalAccessError("The Enum '" + name() + "' has not been set to an Item at this time!");
if (mDeprecated && !mWarned) {
new Exception(this + " is now deprecated").printStackTrace(GT_Log.err);
// warn only once
mWarned = true;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.xir.NHUtilities.common.enumPackages;

public enum MetaTileEntityID {

TCEBF_CONTROLLER(14350);

public final int ID;

private MetaTileEntityID(int ID) {
this.ID = ID;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.xir.NHUtilities.common.recipes.TCRecipes;

import java.util.HashMap;

import thaumcraft.common.config.ConfigResearch;

public class AllTCRecipes {

public static HashMap<String, Object> AllTCRecipes = new HashMap<>();

public static void addAllNHUTCRecipes() {
// part
ArcaneCraftingRecipes.run();
// part->all
AllTCRecipes.putAll(ArcaneCraftingRecipes.ArcaneCraftingRecipes);
// all->tcAll
ConfigResearch.recipes.putAll(AllTCRecipes);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.xir.NHUtilities.common.recipes.TCRecipes;

import java.util.HashMap;

import net.minecraft.item.ItemStack;

import com.xir.NHUtilities.common.enumPackages.CustomItemList;
import com.xir.NHUtilities.loader.ResearchLoader;

import gregtech.api.enums.ItemList;
import gregtech.api.enums.Materials;
import gregtech.api.enums.OrePrefixes;
import gregtech.api.util.GT_OreDictUnificator;
import thaumcraft.api.ThaumcraftApi;
import thaumcraft.api.aspects.Aspect;
import thaumcraft.api.aspects.AspectList;
import thaumcraft.common.config.ConfigBlocks;

public class ArcaneCraftingRecipes {

public static HashMap<String, Object> ArcaneCraftingRecipes = new HashMap<>();
private static final AspectList gtcthaumicebf = new AspectList().add(Aspect.FIRE, 25)
.add(Aspect.ORDER, 25)
.add(Aspect.ENTROPY, 25);

public static void run() {
ArcaneCraftingRecipes.put(
"gtcthaumicebf",
ThaumcraftApi.addArcaneCraftingRecipe(
ResearchLoader.ThaumicEBF.toUpperCase(),
CustomItemList.Machine_Multi_TCBlastFurnace.get(1L),
gtcthaumicebf,
new Object[] { " a ", "aba", " c ", 'a', ItemList.Machine_Multi_BlastFurnace.get(1L), 'b',
new ItemStack(ConfigBlocks.blockCrystal, 1, 1), 'c',
GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Advanced, 1L) }));
}
}
Loading

0 comments on commit aadd07b

Please sign in to comment.