aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/net
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/net')
-rw-r--r--src/main/java/net/glease/ggfab/BlockIcons.java30
-rw-r--r--src/main/java/net/glease/ggfab/GGConstants.java11
-rw-r--r--src/main/java/net/glease/ggfab/GGItemList.java171
-rw-r--r--src/main/java/net/glease/ggfab/GGUtils.java39
-rw-r--r--src/main/java/net/glease/ggfab/GigaGramFab.java3
5 files changed, 252 insertions, 2 deletions
diff --git a/src/main/java/net/glease/ggfab/BlockIcons.java b/src/main/java/net/glease/ggfab/BlockIcons.java
new file mode 100644
index 0000000000..6db4b72a60
--- /dev/null
+++ b/src/main/java/net/glease/ggfab/BlockIcons.java
@@ -0,0 +1,30 @@
+package net.glease.ggfab;
+
+import gregtech.api.enums.Textures.BlockIcons.CustomIcon;
+import gregtech.api.interfaces.IIconContainer;
+import net.minecraft.util.IIcon;
+import net.minecraft.util.ResourceLocation;
+
+public enum BlockIcons implements IIconContainer {
+ ;
+ private final CustomIcon backing;
+
+ BlockIcons() {
+ backing = new CustomIcon("iconsets/" + name());
+ }
+
+ @Override
+ public IIcon getIcon() {
+ return backing.getIcon();
+ }
+
+ @Override
+ public IIcon getOverlayIcon() {
+ return backing.getOverlayIcon();
+ }
+
+ @Override
+ public ResourceLocation getTextureFile() {
+ return backing.getTextureFile();
+ }
+}
diff --git a/src/main/java/net/glease/ggfab/GGConstants.java b/src/main/java/net/glease/ggfab/GGConstants.java
new file mode 100644
index 0000000000..888ca67913
--- /dev/null
+++ b/src/main/java/net/glease/ggfab/GGConstants.java
@@ -0,0 +1,11 @@
+package net.glease.ggfab;
+
+import net.minecraft.util.EnumChatFormatting;
+
+public class GGConstants {
+ public static final String MODID = "ggfab";
+ public static final String MODNAME = "GRADLETOKEN_MODNAME";
+ public static final String VERSION = "GRADLETOKEN_VERSION";
+
+ public static final String GGMARK = EnumChatFormatting.GOLD + "GigaGram" + EnumChatFormatting.RESET + "Fab";
+}
diff --git a/src/main/java/net/glease/ggfab/GGItemList.java b/src/main/java/net/glease/ggfab/GGItemList.java
new file mode 100644
index 0000000000..d126419ec1
--- /dev/null
+++ b/src/main/java/net/glease/ggfab/GGItemList.java
@@ -0,0 +1,171 @@
+package net.glease.ggfab;
+
+import gregtech.api.interfaces.IItemContainer;
+import gregtech.api.util.GT_ModHandler;
+import gregtech.api.util.GT_OreDictUnificator;
+import gregtech.api.util.GT_Utility;
+import net.minecraft.block.Block;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+
+import static gregtech.api.enums.GT_Values.W;
+
+public enum GGItemList implements IItemContainer{
+ ;
+
+ private ItemStack mStack;
+ private boolean 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() {
+ if (mHasNotBeenSet) {
+ throw new IllegalAccessError("The Enum '" + name() + "' has not been set to an Item at this time!");
+ }
+ if (GT_Utility.isStackInvalid(mStack)) {
+ return null;
+ }
+ return mStack.getItem();
+ }
+
+ @Override
+ public Block getBlock() {
+ if (mHasNotBeenSet) {
+ throw new IllegalAccessError("The Enum '" + name() + "' has not been set to an Item at this time!");
+ }
+ return GT_Utility.getBlockFromStack(new ItemStack(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 (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) {
+ if (mHasNotBeenSet) {
+ throw new IllegalAccessError("The Enum '" + name() + "' has not been set to an Item at this time!");
+ }
+ if (GT_Utility.isStackInvalid(mStack)) {
+ return GT_Utility.copyAmount(aAmount, aReplacements);
+ }
+ return GT_Utility.copyAmount(aAmount, GT_OreDictUnificator.get(mStack));
+ }
+
+ @Override
+ public ItemStack getWildcard(long aAmount, Object... aReplacements) {
+ if (mHasNotBeenSet) {
+ throw new IllegalAccessError("The Enum '" + name() + "' has not been set to an Item at this time!");
+ }
+ 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) {
+ if (mHasNotBeenSet) {
+ throw new IllegalAccessError("The Enum '" + name() + "' has not been set to an Item at this time!");
+ }
+ 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) {
+ if (mHasNotBeenSet) {
+ throw new IllegalAccessError("The Enum '" + name() + "' has not been set to an Item at this time!");
+ }
+ 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 null;
+ }
+ rStack.setStackDisplayName(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) {
+ if (mHasNotBeenSet) {
+ throw new IllegalAccessError("The Enum '" + name() + "' has not been set to an Item at this time!");
+ }
+ 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) {
+ if (mHasNotBeenSet) {
+ throw new IllegalAccessError("The Enum '" + name() + "' has not been set to an Item at this time!");
+ }
+ for (Object tOreName : aOreNames) {
+ GT_OreDictUnificator.registerOre(tOreName, get(1));
+ }
+ return this;
+ }
+
+ @Override
+ public IItemContainer registerWildcardAsOre(Object... aOreNames) {
+ if (mHasNotBeenSet) {
+ throw new IllegalAccessError("The Enum '" + name() + "' has not been set to an Item at this time!");
+ }
+ for (Object tOreName : aOreNames) {
+ GT_OreDictUnificator.registerOre(tOreName, getWildcard(1));
+ }
+ return this;
+ }
+
+}
diff --git a/src/main/java/net/glease/ggfab/GGUtils.java b/src/main/java/net/glease/ggfab/GGUtils.java
new file mode 100644
index 0000000000..ea34952971
--- /dev/null
+++ b/src/main/java/net/glease/ggfab/GGUtils.java
@@ -0,0 +1,39 @@
+package net.glease.ggfab;
+
+import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
+import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
+import net.minecraft.util.ChunkCoordinates;
+import net.minecraftforge.common.util.ForgeDirection;
+
+import java.util.StringJoiner;
+
+public class GGUtils {
+ public static boolean isValidTile(IGregTechTileEntity tile) {
+ return tile != null && !tile.isDead() && tile.getMetaTileEntity() != null && tile.getMetaTileEntity().getBaseMetaTileEntity() == tile;
+ }
+ public static boolean isValidTile(IMetaTileEntity mte) {
+ return mte != null && mte.getBaseMetaTileEntity() != null && mte.getBaseMetaTileEntity().getMetaTileEntity() == mte && !mte.getBaseMetaTileEntity().isDead();
+ }
+ public static ChunkCoordinates translate(ChunkCoordinates origin, ForgeDirection direction) {
+ return new ChunkCoordinates(origin.posX + direction.offsetX, origin.posY + direction.offsetY, origin.posZ + direction.offsetZ);
+ }
+
+ public static String formatTileInfo(String prefix, IMetaTileEntity mte, String delimiter, String suffix) {
+ if (!isValidTile(mte)) return prefix + "N/A" + suffix;
+ StringJoiner sj = new StringJoiner(delimiter, prefix, suffix);
+ IGregTechTileEntity til = mte.getBaseMetaTileEntity();
+ sj.add(String.valueOf(til.getXCoord()));
+ sj.add(String.valueOf(til.getYCoord()));
+ sj.add(String.valueOf(til.getZCoord()));
+ return sj.toString();
+ }
+
+ public static String formatTileInfo(String prefix, IGregTechTileEntity tile, String delimiter, String suffix) {
+ if (!isValidTile(tile)) return prefix + "N/A" + suffix;
+ StringJoiner sj = new StringJoiner(delimiter, prefix, suffix);
+ sj.add(String.valueOf(tile.getXCoord()));
+ sj.add(String.valueOf(tile.getYCoord()));
+ sj.add(String.valueOf(tile.getZCoord()));
+ return sj.toString();
+ }
+}
diff --git a/src/main/java/net/glease/ggfab/GigaGramFab.java b/src/main/java/net/glease/ggfab/GigaGramFab.java
index f5100fa177..580a967504 100644
--- a/src/main/java/net/glease/ggfab/GigaGramFab.java
+++ b/src/main/java/net/glease/ggfab/GigaGramFab.java
@@ -3,9 +3,8 @@ package net.glease.ggfab;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.event.*;
-@Mod(modid = GigaGramFab.MODID, version = "${version}", name = "GigaGramFab", acceptedMinecraftVersions = "[1.7.10]", dependencies = "required-after:IC2;")
+@Mod(modid = GGConstants.MODID, version = GGConstants.VERSION, name = GGConstants.MODNAME, acceptedMinecraftVersions = "[1.7.10]", dependencies = "required-after:IC2;required-after:gregtech")
public class GigaGramFab {
- public static final String MODID = "ggfab";
@Mod.EventHandler
public void preInit(FMLPreInitializationEvent event) {