Skip to content

Commit f2cb5af

Browse files
authored
Add convenience methods to Material and OrePrefix for making ItemStacks (#2761)
1 parent 63236dd commit f2cb5af

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

src/main/java/gregtech/api/unification/material/Material.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import gregtech.api.fluids.store.FluidStorageKeys;
99
import gregtech.api.unification.Element;
1010
import gregtech.api.unification.Elements;
11+
import gregtech.api.unification.OreDictUnifier;
1112
import gregtech.api.unification.material.info.MaterialFlag;
1213
import gregtech.api.unification.material.info.MaterialFlags;
1314
import gregtech.api.unification.material.info.MaterialIconSet;
@@ -29,13 +30,15 @@
2930
import gregtech.api.unification.material.properties.WireProperties;
3031
import gregtech.api.unification.material.properties.WoodProperty;
3132
import gregtech.api.unification.material.registry.MaterialRegistry;
33+
import gregtech.api.unification.ore.OrePrefix;
3234
import gregtech.api.unification.stack.MaterialStack;
3335
import gregtech.api.util.FluidTooltipUtil;
3436
import gregtech.api.util.GTUtility;
3537
import gregtech.api.util.LocalizationUtils;
3638
import gregtech.api.util.SmallDigits;
3739

3840
import net.minecraft.enchantment.Enchantment;
41+
import net.minecraft.item.ItemStack;
3942
import net.minecraft.util.ResourceLocation;
4043
import net.minecraftforge.fluids.Fluid;
4144
import net.minecraftforge.fluids.FluidStack;
@@ -278,6 +281,27 @@ public FluidStack getFluid(@NotNull FluidStorageKey key, int amount) {
278281
return new FluidStack(getFluid(key), amount);
279282
}
280283

284+
/**
285+
* Gets the item form of this material in the form of an {@link OrePrefix}
286+
*
287+
* @param prefix the ore prefix to use
288+
* @return an item stack of the ore prefix using this material
289+
*/
290+
public @NotNull ItemStack getItemForm(@NotNull OrePrefix prefix) {
291+
return OreDictUnifier.get(prefix, this);
292+
}
293+
294+
/**
295+
* Gets the item form of this material in the form of an {@link OrePrefix}
296+
*
297+
* @param prefix the ore prefix to use
298+
* @param count the amount the ItemStack will have
299+
* @return an item stack of the ore prefix using this material
300+
*/
301+
public @NotNull ItemStack getItemForm(@NotNull OrePrefix prefix, int count) {
302+
return OreDictUnifier.get(prefix, this, count);
303+
}
304+
281305
public int getBlockHarvestLevel() {
282306
if (!hasProperty(PropertyKey.DUST)) {
283307
throw new IllegalArgumentException(

src/main/java/gregtech/api/unification/ore/OrePrefix.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package gregtech.api.unification.ore;
22

3+
import gregtech.api.unification.OreDictUnifier;
34
import gregtech.api.unification.material.MarkerMaterials;
45
import gregtech.api.unification.material.Material;
56
import gregtech.api.unification.material.Materials;
@@ -12,6 +13,7 @@
1213
import gregtech.common.ConfigHolder;
1314

1415
import net.minecraft.client.resources.I18n;
16+
import net.minecraft.item.ItemStack;
1517

1618
import com.google.common.base.Preconditions;
1719
import crafttweaker.annotations.ZenRegister;
@@ -703,6 +705,27 @@ public boolean isMarkerPrefix() {
703705
return isMarkerPrefix;
704706
}
705707

708+
/**
709+
* Gets the item form of this ore prefix using a {@link Material}
710+
*
711+
* @param material the Material to use
712+
* @return an ItemStack of the Material using this ore prefix
713+
*/
714+
public @NotNull ItemStack getItemForm(@NotNull Material material) {
715+
return OreDictUnifier.get(this, material);
716+
}
717+
718+
/**
719+
* Gets the item form of this ore prefix using a {@link Material}
720+
*
721+
* @param material the Material to use
722+
* @param count the amount the ItemStack will have
723+
* @return an ItemStack of the Material using this ore prefix
724+
*/
725+
public @NotNull ItemStack getItemForm(@NotNull Material material, int count) {
726+
return OreDictUnifier.get(this, material, count);
727+
}
728+
706729
@Override
707730
public boolean equals(Object o) {
708731
if (this == o) return true;

0 commit comments

Comments
 (0)