diff options
author | Alexdoru <57050655+Alexdoru@users.noreply.github.com> | 2024-09-17 01:38:03 +0200 |
---|---|---|
committer | boubou19 <miisterunknown@gmail.com> | 2024-09-17 22:55:46 +0200 |
commit | 4659a3d88d15ea5c9faa054161d5996ba6f598fd (patch) | |
tree | 0ae31bdbd1fec2cd9e2f2174c7272fe0a6e9df36 /src/main | |
parent | 5e5bd082654643f0c2d3a889363c3868549c89ac (diff) | |
download | GT5-Unofficial-4659a3d88d15ea5c9faa054161d5996ba6f598fd.tar.gz GT5-Unofficial-4659a3d88d15ea5c9faa054161d5996ba6f598fd.tar.bz2 GT5-Unofficial-4659a3d88d15ea5c9faa054161d5996ba6f598fd.zip |
remove reflection from MTEHatchNaquadah
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/gregtech/api/metatileentity/implementations/MTEHatch.java | 8 | ||||
-rw-r--r-- | src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/MTEHatchNaquadah.java | 56 |
2 files changed, 16 insertions, 48 deletions
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/MTEHatch.java b/src/main/java/gregtech/api/metatileentity/implementations/MTEHatch.java index bd0b3b6f61..8eb11ab37f 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/MTEHatch.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/MTEHatch.java @@ -198,6 +198,14 @@ public abstract class MTEHatch extends MTEBasicTank implements ICraftingIconProv return (byte) (mTexturePage & 0x7F); } + public final byte getmTexturePage() { + return mTexturePage; + } + + public final byte getActualTexture() { + return actualTexture; + } + @Override public boolean doesFillContainers() { return false; diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/MTEHatchNaquadah.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/MTEHatchNaquadah.java index 90db739be7..adcf85c775 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/MTEHatchNaquadah.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/MTEHatchNaquadah.java @@ -1,16 +1,12 @@ package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations; -import java.lang.reflect.Field; - import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; import gregtech.api.enums.Materials; -import gregtech.api.enums.Textures; import gregtech.api.enums.Textures.BlockIcons; -import gregtech.api.interfaces.IIconContainer; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; @@ -18,7 +14,6 @@ import gregtech.api.metatileentity.implementations.MTEHatchInput; import gregtech.api.objects.GTRenderedTexture; import gregtech.api.util.GTUtility; import gtPlusPlus.core.lib.GTPPCore; -import gtPlusPlus.core.util.reflect.ReflectionUtils; public class MTEHatchNaquadah extends MTEHatchInput { @@ -51,14 +46,12 @@ public class MTEHatchNaquadah extends MTEHatchInput { @Override public ITexture[] getTexturesActive(final ITexture aBaseTexture) { - return new ITexture[] { aBaseTexture, - new GTRenderedTexture((IIconContainer) Textures.BlockIcons.NAQUADAH_REACTOR_FLUID_SIDE_ACTIVE) }; + return new ITexture[] { aBaseTexture, new GTRenderedTexture(BlockIcons.NAQUADAH_REACTOR_FLUID_SIDE_ACTIVE) }; } @Override public ITexture[] getTexturesInactive(final ITexture aBaseTexture) { - return new ITexture[] { aBaseTexture, - new GTRenderedTexture((IIconContainer) Textures.BlockIcons.NAQUADAH_REACTOR_FLUID_SIDE) }; + return new ITexture[] { aBaseTexture, new GTRenderedTexture(BlockIcons.NAQUADAH_REACTOR_FLUID_SIDE) }; } public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, @@ -98,6 +91,8 @@ public class MTEHatchNaquadah extends MTEHatchInput { return new MTEHatchNaquadah(this.mName, this.mDescriptionArray, this.mTextures); } + private static final String[] aDescCache = new String[3]; + @Override public String[] getDescription() { if (aDescCache[0] == null || aDescCache[0].contains(".name") || aDescCache[0].contains("fluid.")) { @@ -112,14 +107,11 @@ public class MTEHatchNaquadah extends MTEHatchInput { String aNaq = aDescCache[0]; String aEnrNaq = aDescCache[1]; String aNaquad = aDescCache[2]; - String[] s2 = new String[] { "Fluid Input for Multiblocks", "Capacity: " + getCapacity() + "L", + return new String[] { "Fluid Input for Multiblocks", "Capacity: " + getCapacity() + "L", "Accepted Fluid: " + aNaq, "Accepted Fluid: " + aEnrNaq, "Accepted Fluid: " + aNaquad, GTPPCore.GT_Tooltip.get() }; - return s2; } - private static String[] aDescCache = new String[3]; - private String formatFluidString(FluidStack fluidStack) { String mTempMod = EnumChatFormatting.RESET.toString(); int mLockedTemp = fluidStack.getFluid() @@ -143,49 +135,17 @@ public class MTEHatchNaquadah extends MTEHatchInput { } @Override - public boolean doesFillContainers() { - return false; - } - - @Override - public ITexture[][][] getTextureSet(ITexture[] aTextures) { - // TODO Auto-generated method stub - return super.getTextureSet(aTextures); - } - - private Field F1, F2; - - @Override public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection facing, int aColorIndex, boolean aActive, boolean aRedstone) { - byte a1 = 0, a2 = 0; - try { - if (F1 == null) { - F1 = ReflectionUtils.getField(getClass(), "actualTexture"); - } - if (F2 == null) { - F2 = ReflectionUtils.getField(getClass(), "mTexturePage"); - } - - if (F1 != null) { - a1 = F1.getByte(this); - } - if (F2 != null) { - a2 = F2.getByte(this); - } - } catch (IllegalArgumentException | IllegalAccessException n) {} - + byte a1 = this.getActualTexture(); + byte a2 = this.getmTexturePage(); int textureIndex = a1 | a2 << 7; byte texturePointer = (byte) (a1 & 127); - if (side == ForgeDirection.UP || side == ForgeDirection.DOWN) { ITexture g = textureIndex > 0 ? BlockIcons.casingTexturePages[a2][texturePointer] : BlockIcons.MACHINE_CASINGS[this.mTier][aColorIndex + 1]; - - return new ITexture[] { g, - new GTRenderedTexture((IIconContainer) Textures.BlockIcons.NAQUADAH_REACTOR_FLUID_TOP_ACTIVE) }; + return new ITexture[] { g, new GTRenderedTexture(BlockIcons.NAQUADAH_REACTOR_FLUID_TOP_ACTIVE) }; } - return side != facing ? (textureIndex > 0 ? new ITexture[] { BlockIcons.casingTexturePages[a2][texturePointer] } : new ITexture[] { BlockIcons.MACHINE_CASINGS[this.mTier][aColorIndex + 1] }) |