diff options
| author | Jason Mitchell <mitchej@gmail.com> | 2022-04-18 11:16:31 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-04-18 20:16:31 +0200 |
| commit | 44a1027dfa51af1864364c391e67686590ce347f (patch) | |
| tree | 5f2fa25724841885d9e0cb721a7806812aca8016 /src/main | |
| parent | bb4cec9a73ec6c50199de6c48119ddd85e23b013 (diff) | |
| download | GT5-Unofficial-44a1027dfa51af1864364c391e67686590ce347f.tar.gz GT5-Unofficial-44a1027dfa51af1864364c391e67686590ce347f.tar.bz2 GT5-Unofficial-44a1027dfa51af1864364c391e67686590ce347f.zip | |
Multitileentity precursor (#963)
* Refactors
* Refactor CoverableTileEntity a bit more, pull out a CommonMetaTileEntity
* Add an IDebugableTileEntity interface instead of checking various subclasses
* Move more redstone related things to CoverableTileEntity
* Add IGTENet
* Final and dead code removal
* Address a few comments, fix a few comments, remove some more dead code, and add some more finals.
* fix bad rebase
Diffstat (limited to 'src/main')
47 files changed, 1108 insertions, 1017 deletions
diff --git a/src/main/java/gregtech/api/enums/GT_Values.java b/src/main/java/gregtech/api/enums/GT_Values.java index e41eafab78..6dca327429 100644 --- a/src/main/java/gregtech/api/enums/GT_Values.java +++ b/src/main/java/gregtech/api/enums/GT_Values.java @@ -55,7 +55,7 @@ public class GT_Values { * This is worth exactly one normal Item. * This Constant can be divided by many commonly used Numbers such as * 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 24, ... 64 or 81 - * without loosing precision and is for that reason used as Unit of Amount. + * without losing precision and is for that reason used as Unit of Amount. * But it is also small enough to be multiplied with larger Numbers. * <p/> * This is used to determine the amount of Material contained inside a prefixed Ore. @@ -195,6 +195,98 @@ public class GT_Values { RES_PATH_ASPECTS = MOD_ID + ":" + TEX_DIR_ASPECTS, RES_PATH_IC2 = MOD_ID_IC2.toLowerCase(Locale.ENGLISH) + ":", RES_PATH_MODEL = MOD_ID + ":" + TEX_DIR + "models/"; + + /** + * NBT String Keys + */ + public static class NBT { + public static final String + COLOR = "gt.color", // Integer + CUSTOM_NAME = "name", // String + DISPAY = "gt.display", // String + FACING = "gt.facing", // Byte + HIDDEN = "gt.hidden", // Boolean + LOCK_UPGRADE = "gt.locked", // Boolean + MATERIAL = "gt.material", // String containing the Material Name. + MODE = "gt.mode", // Number + ALLOWED_MODES = "gt.amode", // Number + MTE_ID = "gt.mte.id", // Containing the MTE ID + MTE_REG = "gt.mte.reg", // Containing the MTE Registry ID + OWNER = "gt.owner", // String + OWNER_UUID = "gt.ownerUuid", // UUID (String) + + // Machines + FLUID_OUT = "gt.fluidout", // Output Fluid + INV_OUT = "gt.invout", // ItemStack + PARALLEL = "gt.parallel", // Number + TANK_CAPACITY = "gt.tankcap", // Number + TANK_IN = "gt.tank.in.", // FluidStack + TANK_OUT = "gt.tank.out.", // FluidStack + TEXTURE = "gt.texture", // String + INV_SIZE = "gt.invsize", // Number + INV_LIST = "gt.invlist", // NBT List + + // MultiBlock + STRUCTURE_OK = "gt.structure.ok", + ROTATION = "gt.eRotation", + FLIP = "gt.eFlip", + TARGET = "gt.target", // Boolean + TARGET_X = "gt.target.x", // Number + TARGET_Y = "gt.target.y", // Number + TARGET_Z = "gt.target.z", // Number + + empty_ = ""; + } + + + public static final int UNCOLORED = 0x00ffffff; + + /** + * Sides + */ + public static final byte + SIDE_BOTTOM = 0, SIDE_DOWN = 0, + SIDE_TOP = 1, SIDE_UP = 1, + SIDE_NORTH = 2, // Also a Side with a stupidly mirrored Texture + SIDE_SOUTH = 3, + SIDE_WEST = 4, + SIDE_EAST = 5, // Also a Side with a stupidly mirrored Texture + SIDE_ANY = 6, SIDE_UNKNOWN = 6, SIDE_INVALID = 6, SIDE_INSIDE = 6, SIDE_UNDEFINED = 6; + + /** Compass alike Array for the proper ordering of North, East, South and West. */ + public static final byte[] COMPASS_DIRECTIONS = {SIDE_NORTH, SIDE_EAST, SIDE_SOUTH, SIDE_WEST}; + + + /** + * An Array containing all Sides which follow the Condition, in order to iterate over them for example. + */ + public static final byte[] + ALL_SIDES = {0,1,2,3,4,5,6}, + ALL_VALID_SIDES = {0,1,2,3,4,5 }; + + /** + * For Facing Checks. + */ + + public static final boolean[] + INVALID_SIDES = { false, false, false, false, false, false, true }, + VALID_SIDES = { true, true, true, true, true, true, false }; + + + /** + * Side->Offset Mappings. + */ + public static final byte[] + OFFX = { 0, 0, 0, 0,-1,+1, 0}, + OFFY = {-1,+1, 0, 0, 0, 0, 0}, + OFFZ = { 0, 0,-1,+1, 0, 0, 0}; + + /** + * Side->Opposite Mappings. + **/ + public static final byte[] + OPOS = { 1, 0, 3, 2, 5, 4, 6}; + /** * The Mod Object itself. That is the GT_Mod-Object. It's needed to open GUI's and similar. */ @@ -316,4 +408,6 @@ public class GT_Values { public static boolean disableDigitalChestsExternalAccess = false; public static boolean lateConfigSave = true; public static boolean worldTickHappened = false; + + public static final int[] emptyIntArray = new int[0]; } diff --git a/src/main/java/gregtech/api/enums/ItemList.java b/src/main/java/gregtech/api/enums/ItemList.java index b874f1df2e..a14691f4b3 100644 --- a/src/main/java/gregtech/api/enums/ItemList.java +++ b/src/main/java/gregtech/api/enums/ItemList.java @@ -63,6 +63,7 @@ public enum ItemList implements IItemContainer { RC_Bed_Wood, RC_Bed_Stone, RC_Rebar, + TC_Thaumometer, IC2_Item_Casing_Tin, IC2_Item_Casing_Copper, IC2_Item_Casing_Iron, diff --git a/src/main/java/gregtech/api/enums/Textures.java b/src/main/java/gregtech/api/enums/Textures.java index e7fb1e9af8..5730be05e9 100644 --- a/src/main/java/gregtech/api/enums/Textures.java +++ b/src/main/java/gregtech/api/enums/Textures.java @@ -1681,14 +1681,13 @@ public class Textures { BLOCK_BLAZE, BLOCK_CRYOLITE }; - public static ITexture[] HIDDEN_TEXTURE = { + public static final ITexture[] HIDDEN_TEXTURE = { TextureFactory.builder().addIcon(HIDDEN_FACE).stdOrient().build() }; - public static ITexture[] - ERROR_RENDERING = { + public static final ITexture[] ERROR_RENDERING = { TextureFactory.of(RENDERING_ERROR) }; - public static ITexture[] OVERLAYS_ENERGY_IN = { + public static final ITexture[] OVERLAYS_ENERGY_IN = { TextureFactory.of(OVERLAY_ENERGY_IN, new short[]{180, 180, 180, 0}), TextureFactory.of(OVERLAY_ENERGY_IN, new short[]{220, 220, 220, 0}), TextureFactory.of(OVERLAY_ENERGY_IN, new short[]{255, 100, 0, 0}), @@ -1724,7 +1723,7 @@ public class Textures { TextureFactory.of(OVERLAY_ENERGY_OUT, new short[]{60, 60, 245, 0}), TextureFactory.of(OVERLAY_ENERGY_OUT, new short[]{40, 40, 245, 0}), }; - public static ITexture[] OVERLAYS_ENERGY_IN_MULTI = { + public static final ITexture[] OVERLAYS_ENERGY_IN_MULTI = { TextureFactory.of(OVERLAY_ENERGY_IN_MULTI, new short[]{180, 180, 180, 0}), TextureFactory.of(OVERLAY_ENERGY_IN_MULTI, new short[]{220, 220, 220, 0}), TextureFactory.of(OVERLAY_ENERGY_IN_MULTI, new short[]{255, 100, 0, 0}), @@ -1742,7 +1741,7 @@ public class Textures { TextureFactory.of(OVERLAY_ENERGY_IN_MULTI, new short[]{60, 60, 245, 0}), TextureFactory.of(OVERLAY_ENERGY_IN_MULTI, new short[]{40, 40, 245, 0}), }; - public static ITexture[] OVERLAYS_ENERGY_OUT_MULTI = { + public static final ITexture[] OVERLAYS_ENERGY_OUT_MULTI = { TextureFactory.of(OVERLAY_ENERGY_OUT_MULTI, new short[]{180, 180, 180, 0}), TextureFactory.of(OVERLAY_ENERGY_OUT_MULTI, new short[]{220, 220, 220, 0}), TextureFactory.of(OVERLAY_ENERGY_OUT_MULTI, new short[]{255, 100, 0, 0}), @@ -1760,7 +1759,7 @@ public class Textures { TextureFactory.of(OVERLAY_ENERGY_OUT_MULTI, new short[]{60, 60, 245, 0}), TextureFactory.of(OVERLAY_ENERGY_OUT_MULTI, new short[]{40, 40, 245, 0}), }; - public static ITexture[] OVERLAYS_ENERGY_IN_POWER = { + public static final ITexture[] OVERLAYS_ENERGY_IN_POWER = { TextureFactory.of(OVERLAY_ENERGY_IN_POWER, new short[]{180, 180, 180, 0}), TextureFactory.of(OVERLAY_ENERGY_IN_POWER, new short[]{220, 220, 220, 0}), TextureFactory.of(OVERLAY_ENERGY_IN_POWER, new short[]{255, 100, 0, 0}), @@ -1778,7 +1777,7 @@ public class Textures { TextureFactory.of(OVERLAY_ENERGY_IN_POWER, new short[]{60, 60, 245, 0}), TextureFactory.of(OVERLAY_ENERGY_IN_POWER, new short[]{40, 40, 245, 0}), }; - public static ITexture[] OVERLAYS_ENERGY_OUT_POWER = { + public static final ITexture[] OVERLAYS_ENERGY_OUT_POWER = { TextureFactory.of(OVERLAY_ENERGY_OUT_POWER, new short[]{180, 180, 180, 0}), TextureFactory.of(OVERLAY_ENERGY_OUT_POWER, new short[]{220, 220, 220, 0}), TextureFactory.of(OVERLAY_ENERGY_OUT_POWER, new short[]{255, 100, 0, 0}), @@ -1796,7 +1795,7 @@ public class Textures { TextureFactory.of(OVERLAY_ENERGY_OUT_POWER, new short[]{60, 60, 245, 0}), TextureFactory.of(OVERLAY_ENERGY_OUT_POWER, new short[]{40, 40, 245, 0}), }; - public static ITexture[] LOCKERS = { + public static final ITexture[] LOCKERS = { TextureFactory.of(OVERLAY_LOCKER_000), TextureFactory.of(OVERLAY_LOCKER_001), TextureFactory.of(OVERLAY_LOCKER_002), diff --git a/src/main/java/gregtech/api/interfaces/IIconContainer.java b/src/main/java/gregtech/api/interfaces/IIconContainer.java index 0b185b387a..780edf18d6 100644 --- a/src/main/java/gregtech/api/interfaces/IIconContainer.java +++ b/src/main/java/gregtech/api/interfaces/IIconContainer.java @@ -1,5 +1,7 @@ package gregtech.api.interfaces; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.util.IIcon; import net.minecraft.util.ResourceLocation; @@ -7,15 +9,28 @@ public interface IIconContainer { /** * @return A regular Icon. */ + @SideOnly(Side.CLIENT) IIcon getIcon(); /** * @return Icon of the Overlay (or null if there is no Icon) */ + @SideOnly(Side.CLIENT) IIcon getOverlayIcon(); /** + * @return the Amount of Render Passes for this Icon. + */ + @SideOnly(Side.CLIENT) + default int getIconPasses() { + return 1; + }; + + /** * @return the Default Texture File for this Icon. */ + @SideOnly(Side.CLIENT) ResourceLocation getTextureFile(); + + } diff --git a/src/main/java/gregtech/api/interfaces/tileentity/IBasicEnergyContainer.java b/src/main/java/gregtech/api/interfaces/tileentity/IBasicEnergyContainer.java index 6998556fd0..ca3db3354e 100644 --- a/src/main/java/gregtech/api/interfaces/tileentity/IBasicEnergyContainer.java +++ b/src/main/java/gregtech/api/interfaces/tileentity/IBasicEnergyContainer.java @@ -80,12 +80,12 @@ public interface IBasicEnergyContainer extends IEnergyConnected { /** * returns the amount of Steam contained in this Block, in EU units! */ - long getStoredSteam(); + default long getStoredSteam() { return 0; } /** * returns the amount of Steam containable in this Block, in EU units! */ - long getSteamCapacity(); + default long getSteamCapacity() { return 0; } /** * Increases stored Energy. Energy Base Value is in EU, even though it's Steam! @@ -96,5 +96,5 @@ public interface IBasicEnergyContainer extends IEnergyConnected { * <p/> * And yes, you can't directly decrease the Steam of a Machine. That is done by decreaseStoredEnergyUnits */ - boolean increaseStoredSteam(long aEnergy, boolean aIgnoreTooMuchEnergy); + default boolean increaseStoredSteam(long aEnergy, boolean aIgnoreTooMuchEnergy) { return false; } } diff --git a/src/main/java/gregtech/api/interfaces/tileentity/ICoverable.java b/src/main/java/gregtech/api/interfaces/tileentity/ICoverable.java index ebfae9d90e..e496479bed 100644 --- a/src/main/java/gregtech/api/interfaces/tileentity/ICoverable.java +++ b/src/main/java/gregtech/api/interfaces/tileentity/ICoverable.java @@ -21,8 +21,9 @@ public interface ICoverable extends IRedstoneTileEntity, IHasInventory, IBasicEn setCoverDataAtSide(aSide, ((ISerializableObject.LegacyCoverData) aData).get()); } + void setCoverIdAndDataAtSide(byte aSide, int aId, ISerializableObject aData); void setCoverIDAtSide(byte aSide, int aID); - + boolean setCoverIDAtSideNoUpdate(byte aSide, int aID); void setCoverItemAtSide(byte aSide, ItemStack aCover); @Deprecated diff --git a/src/main/java/gregtech/api/interfaces/tileentity/IDebugableTileEntity.java b/src/main/java/gregtech/api/interfaces/tileentity/IDebugableTileEntity.java new file mode 100644 index 0000000000..0063eb57c6 --- /dev/null +++ b/src/main/java/gregtech/api/interfaces/tileentity/IDebugableTileEntity.java @@ -0,0 +1,20 @@ +package gregtech.api.interfaces.tileentity; + +import net.minecraft.entity.player.EntityPlayer; + +import java.util.ArrayList; + +public interface IDebugableTileEntity { + /** + * Returns a Debug Message, for a generic DebugItem + * + * @param aPlayer the Player, who rightclicked with his Debug Item + * @param aLogLevel the Log Level of the Debug Item. + * 0 = Obvious + * 1 = Visible for the regular Scanner + * 2 = Only visible to more advanced Scanners + * 3 = Debug ONLY + * @return a String-Array containing the DebugInfo, every Index is a separate line (0 = first Line) + */ + ArrayList<String> getDebugInfo(EntityPlayer aPlayer, int aLogLevel); +} diff --git a/src/main/java/gregtech/api/interfaces/tileentity/IEnergyConnected.java b/src/main/java/gregtech/api/interfaces/tileentity/IEnergyConnected.java index 2b67e680a4..702f19a89d 100644 --- a/src/main/java/gregtech/api/interfaces/tileentity/IEnergyConnected.java +++ b/src/main/java/gregtech/api/interfaces/tileentity/IEnergyConnected.java @@ -46,21 +46,21 @@ public interface IEnergyConnected extends IColoredTileEntity, IHasWorldObjectAnd /** * Utility for the Network */ - class Util { + final class Util { /** * Emits Energy to the E-net. Also compatible with adjacent IC2 TileEntities. * * @return the used Amperage. */ - public static final long emitEnergyToNetwork(long aVoltage, long aAmperage, IEnergyConnected aEmitter) { + public static long emitEnergyToNetwork(long aVoltage, long aAmperage, IEnergyConnected aEmitter) { long rUsedAmperes = 0; for (byte i = 0, j = 0; i < 6 && aAmperage > rUsedAmperes; i++) { if (aEmitter.outputsEnergyTo(i)) { j = GT_Utility.getOppositeSide(i); - TileEntity tTileEntity = aEmitter.getTileEntityAtSide(i); + final TileEntity tTileEntity = aEmitter.getTileEntityAtSide(i); if (tTileEntity instanceof IEnergyConnected) { if (aEmitter.getColorization() >= 0) { - byte tColor = ((IEnergyConnected) tTileEntity).getColorization(); + final byte tColor = ((IEnergyConnected) tTileEntity).getColorization(); if (tColor >= 0 && tColor != aEmitter.getColorization()) continue; } rUsedAmperes += ((IEnergyConnected) tTileEntity).injectEnergyUnits(j, aVoltage, aAmperage - rUsedAmperes); @@ -71,8 +71,8 @@ public interface IEnergyConnected extends IColoredTileEntity, IHasWorldObjectAnd rUsedAmperes++; } } else if (GregTech_API.mOutputRF && tTileEntity instanceof IEnergyReceiver) { - ForgeDirection tDirection = ForgeDirection.getOrientation(i).getOpposite(); - int rfOut = GT_Utility.safeInt(aVoltage * GregTech_API.mEUtoRF / 100); + final ForgeDirection tDirection = ForgeDirection.getOrientation(i).getOpposite(); + final int rfOut = GT_Utility.safeInt(aVoltage * GregTech_API.mEUtoRF / 100); if (((IEnergyReceiver) tTileEntity).receiveEnergy(tDirection, rfOut, true) == rfOut) { ((IEnergyReceiver) tTileEntity).receiveEnergy(tDirection, rfOut, false); rUsedAmperes++; diff --git a/src/main/java/gregtech/api/interfaces/tileentity/IGTEnet.java b/src/main/java/gregtech/api/interfaces/tileentity/IGTEnet.java new file mode 100644 index 0000000000..cd4810eba6 --- /dev/null +++ b/src/main/java/gregtech/api/interfaces/tileentity/IGTEnet.java @@ -0,0 +1,20 @@ +package gregtech.api.interfaces.tileentity; + +public interface IGTEnet { + + /** + * @return true if this Device consumes Energy at all + */ + default boolean isEnetInput() { + return false; + } + + /** + * + * @return true if this Device emits Energy at all + */ + default boolean isEnetOutput() { + return false; + } + +} diff --git a/src/main/java/gregtech/api/interfaces/tileentity/IGregTechTileEntity.java b/src/main/java/gregtech/api/interfaces/tileentity/IGregTechTileEntity.java index 7b3e3fee6c..8c6da608fd 100644 --- a/src/main/java/gregtech/api/interfaces/tileentity/IGregTechTileEntity.java +++ b/src/main/java/gregtech/api/interfaces/tileentity/IGregTechTileEntity.java @@ -17,7 +17,7 @@ import java.util.UUID; /** * A simple compound Interface for all my TileEntities. * <p/> - * Also delivers most of the Informations about my TileEntities. + * Also delivers most of the Information about my TileEntities. * <p/> * It can cause Problems to include this Interface! */ diff --git a/src/main/java/gregtech/api/interfaces/tileentity/IHasWorldObjectAndCoords.java b/src/main/java/gregtech/api/interfaces/tileentity/IHasWorldObjectAndCoords.java index f367b7c073..2464816045 100644 --- a/src/main/java/gregtech/api/interfaces/tileentity/IHasWorldObjectAndCoords.java +++ b/src/main/java/gregtech/api/interfaces/tileentity/IHasWorldObjectAndCoords.java @@ -5,6 +5,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ChunkCoordinates; import net.minecraft.world.World; import net.minecraft.world.biome.BiomeGenBase; import net.minecraftforge.fluids.IFluidHandler; @@ -25,6 +26,10 @@ public interface IHasWorldObjectAndCoords { int getZCoord(); + default ChunkCoordinates getCoords() { + return new ChunkCoordinates(getXCoord(), getYCoord(), getZCoord()); + } + boolean isServerSide(); boolean isClientSide(); diff --git a/src/main/java/gregtech/api/interfaces/tileentity/IIC2Enet.java b/src/main/java/gregtech/api/interfaces/tileentity/IIC2Enet.java new file mode 100644 index 0000000000..ee3516dfac --- /dev/null +++ b/src/main/java/gregtech/api/interfaces/tileentity/IIC2Enet.java @@ -0,0 +1,17 @@ +package gregtech.api.interfaces.tileentity; + +/** + * IC2 Energy Compat + */ +public interface IIC2Enet { + /** + * Should this tile/block join the ic2 enet + */ + boolean shouldJoinIc2Enet(); + + /** + * Update the ic2 enet + */ + void doEnetUpdate(); + +} diff --git a/src/main/java/gregtech/api/interfaces/tileentity/IMachineProgress.java b/src/main/java/gregtech/api/interfaces/tileentity/IMachineProgress.java index f5eeaf9318..0c342b8cfc 100644 --- a/src/main/java/gregtech/api/interfaces/tileentity/IMachineProgress.java +++ b/src/main/java/gregtech/api/interfaces/tileentity/IMachineProgress.java @@ -49,13 +49,13 @@ public interface IMachineProgress extends IHasWorldObjectAndCoords { * used to control Machines via Redstone Signal Strength by special Covers * In case of 0 the Machine is very likely doing nothing, or is just not being controlled at all. */ - byte getWorkDataValue(); + default byte getWorkDataValue() { return 0; } /** * used to control Machines via Redstone Signal Strength by special Covers * only Values between 0 and 15! */ - void setWorkDataValue(byte aValue); + default void setWorkDataValue(byte aValue) {} /** * gives you the Active Status of the Machine |
