diff options
16 files changed, 166 insertions, 25 deletions
diff --git a/src/main/java/gregtech/api/enums/GT_Values.java b/src/main/java/gregtech/api/enums/GT_Values.java index cda42cbcbf..59cb64bce8 100644 --- a/src/main/java/gregtech/api/enums/GT_Values.java +++ b/src/main/java/gregtech/api/enums/GT_Values.java @@ -259,6 +259,7 @@ public class GT_Values { OWNER_UUID = "gt.ownerUuid", // UUID (String) // Machines + ACTIVE = "gt.active", // Boolean FLUID_OUT = "gt.fluidout", // Output Fluid INV_OUT = "gt.invout", // ItemStack PARALLEL = "gt.parallel", // Number @@ -334,6 +335,20 @@ public class GT_Values { OPOS = { 1, 0, 3, 2, 5, 4, 6}; /** + * [Facing,Side]->Side Mappings for Blocks, which don't face up- and downwards. + * 0 = bottom, 1 = top, 2 = left, 3 = front, 4 = right, 5 = back, 6 = undefined. + */ + public static final byte[][] FACING_ROTATIONS = { + {0,1,2,3,4,5,6}, + {0,1,2,3,4,5,6}, + {0,1,3,5,4,2,6}, + {0,1,5,3,2,4,6}, + {0,1,2,4,3,5,6}, + {0,1,4,2,5,3,6}, + {0,1,2,3,4,5,6} + }; + + /** * The Mod Object itself. That is the GT_Mod-Object. It's needed to open GUI's and similar. */ public static IGT_Mod GT; diff --git a/src/main/java/gregtech/api/multitileentity/MultiTileEntityClassContainer.java b/src/main/java/gregtech/api/multitileentity/MultiTileEntityClassContainer.java index e6740a0663..563d2fc462 100644 --- a/src/main/java/gregtech/api/multitileentity/MultiTileEntityClassContainer.java +++ b/src/main/java/gregtech/api/multitileentity/MultiTileEntityClassContainer.java @@ -81,8 +81,23 @@ public class MultiTileEntityClassContainer { /* These methods are builder methods for commonly used NBT tags */ - public MultiTileEntityClassContainer material(Material aMaterial) { + // Need a base texture for the MTE machine, and then a separate texture set for the machine/active overlays + + public MultiTileEntityClassContainer material(Materials aMaterial) { + // Sets the material, and the color from the material, if not already set mParameters.setString(NBT.MATERIAL, aMaterial.toString()); + if (!mParameters.hasKey(NBT.COLOR)) + mParameters.setInteger(NBT.COLOR, GT_Util.getRGBInt(aMaterial.getRGBA())); + return this; + } + + public MultiTileEntityClassContainer color(int aRPG) { + mParameters.setInteger(NBT.COLOR, aRPG); + return this; + } + + public MultiTileEntityClassContainer color(short[] aRPGA) { + mParameters.setInteger(NBT.COLOR, GT_Util.getRGBInt(aRPGA)); return this; } diff --git a/src/main/java/gregtech/api/multitileentity/base/BaseMultiTileEntity.java b/src/main/java/gregtech/api/multitileentity/base/BaseMultiTileEntity.java index 96a04b6147..50c43c9764 100644 --- a/src/main/java/gregtech/api/multitileentity/base/BaseMultiTileEntity.java +++ b/src/main/java/gregtech/api/multitileentity/base/BaseMultiTileEntity.java @@ -70,7 +70,8 @@ import static gregtech.api.enums.GT_Values.VALID_SIDES; public abstract class BaseMultiTileEntity extends CoverableTileEntity implements IMultiTileEntity, IHasWorldObjectAndCoords, IRenderedBlock, IGregtechWailaProvider { - public IIconContainer[] mTextures = emptyIconContainerArray, mTexturesFront = emptyIconContainerArray; + public IIconContainer[] mTextures = emptyIconContainerArray; +// public IIconContainer[] mTexturesFront = emptyIconContainerArray; // Makes a Bounding Box without having to constantly specify the Offset Coordinates. protected static final float[] PX_BOX = {0, 0, 0, 1, 1, 1}; @@ -86,6 +87,7 @@ public abstract class BaseMultiTileEntity extends CoverableTileEntity implements protected boolean mIsPainted = false; protected byte mFacing = SIDE_WEST; // Default to WEST, so it renders facing Left in the inventory protected byte mColor; + protected int mRGBa = GT_Values.UNCOLORED; private short mMTEID = GT_Values.W, mMTERegistry = GT_Values.W; private String mCustomName = null; private String mOwnerName = ""; @@ -121,6 +123,25 @@ public abstract class BaseMultiTileEntity extends CoverableTileEntity implements } @Override + public void loadTextureNBT(NBTTagCompound aNBT) { + // Loading the registry + final String textureName = aNBT.getString(NBT.TEXTURE); + mTextures = new IIconContainer[] { + new Textures.BlockIcons.CustomIcon("multitileentity/base/"+textureName+"/bottom"), + new Textures.BlockIcons.CustomIcon("multitileentity/base/"+textureName+"/top"), + new Textures.BlockIcons.CustomIcon("multitileentity/base/"+textureName+"/side"), + }; + } + + @Override + public void copyTextures() { + // Loading an instance + final TileEntity tCanonicalTileEntity = MultiTileEntityRegistry.getCanonicalTileEntity(getMultiTileEntityRegistryID(), getMultiTileEntityID()); + if(tCanonicalTileEntity instanceof BaseMultiTileEntity) + mTextures = ((BaseMultiTileEntity)tCanonicalTileEntity).mTextures; + } + + @Override public void readFromNBT(NBTTagCompound aNBT) { // Check if this is a World/Chunk Loading Process calling readFromNBT. if (mMTEID == GT_Values.W || mMTERegistry == GT_Values.W) { @@ -147,6 +168,8 @@ public abstract class BaseMultiTileEntity extends CoverableTileEntity implements // And now everything else. try { if (aNBT.hasKey(NBT.MATERIAL)) mMaterial = Materials.get(aNBT.getString(NBT.MATERIAL)); + if (aNBT.hasKey(NBT.COLOR)) mRGBa = aNBT.getInteger(NBT.COLOR); + mOwnerName = aNBT.getString(NBT.OWNER); try { mOwnerUuid = UUID.fromString(aNBT.getString(NBT.OWNER_UUID)); @@ -160,18 +183,9 @@ public abstract class BaseMultiTileEntity extends CoverableTileEntity implements readMultiTileNBT(aNBT); if(GregTech_API.sBlockIcons == null && aNBT.hasKey(NBT.TEXTURE)) { - // Loading the registry - final String textureName = aNBT.getString(NBT.TEXTURE); - mTextures = new IIconContainer[] { - new Textures.BlockIcons.CustomIcon("machines/multiblockparts/"+textureName+"/bottom"), - new Textures.BlockIcons.CustomIcon("machines/multiblockparts/"+textureName+"/top"), - new Textures.BlockIcons.CustomIcon("machines/multiblockparts/"+textureName+"/side"), - }; + loadTextureNBT(aNBT); } else { - // Loading an instance - final TileEntity tCanonicalTileEntity = MultiTileEntityRegistry.getCanonicalTileEntity(getMultiTileEntityRegistryID(), getMultiTileEntityID()); - if(tCanonicalTileEntity instanceof BaseMultiTileEntity) - mTextures = ((BaseMultiTileEntity)tCanonicalTileEntity).mTextures; + copyTextures(); } if (mCoverData == null || mCoverData.length != 6) mCoverData = new ISerializableObject[6]; @@ -333,7 +347,7 @@ public abstract class BaseMultiTileEntity extends CoverableTileEntity implements @Override public ITexture[] getTexture(Block aBlock, byte aSide, boolean isActive, int aRenderPass) { // Top, bottom or side aSide = (byte)Math.min(aSide, 2); - return new ITexture[]{TextureFactory.of(mTextures[aSide])}; + return new ITexture[]{TextureFactory.of(mTextures[aSide], GT_Util.getRGBaArray(mRGBa))}; } @Override @@ -410,7 +424,7 @@ public abstract class BaseMultiTileEntity extends CoverableTileEntity implements @Override public int getPaint() { - return GT_Values.UNCOLORED; + return this.mRGBa; } @Override diff --git a/src/main/java/gregtech/api/multitileentity/interfaces/IMultiTileEntity.java b/src/main/java/gregtech/api/multitileentity/interfaces/IMultiTileEntity.java index 87d7892fba..d601d8abd2 100644 --- a/src/main/java/gregtech/api/multitileentity/interfaces/IMultiTileEntity.java +++ b/src/main/java/gregtech/api/multitileentity/interfaces/IMultiTileEntity.java @@ -60,6 +60,9 @@ public interface IMultiTileEntity extends IHasWorldObjectAndCoords, ICoverable, @Override boolean isDead(); + void loadTextureNBT(NBTTagCompound aNBT); + void copyTextures(); + void issueClientUpdate(); void sendClientData( EntityPlayerMP aPlayer); boolean receiveClientEvent(int aEventID, int aValue); diff --git a/src/main/java/gregtech/api/multitileentity/machine/MultiTileBasicMachine.java b/src/main/java/gregtech/api/multitileentity/machine/MultiTileBasicMachine.java index 3997b5af71..9fcbaa235f 100644 --- a/src/main/java/gregtech/api/multitileentity/machine/MultiTileBasicMachine.java +++ b/src/main/java/gregtech/api/multitileentity/machine/MultiTileBasicMachine.java @@ -2,23 +2,35 @@ package gregtech.api.multitileentity.machine; import gregtech.api.enums.GT_Values; import gregtech.api.enums.GT_Values.NBT; +import gregtech.api.enums.Textures; import gregtech.api.fluid.FluidTankGT; +import gregtech.api.interfaces.IIconContainer; import gregtech.api.interfaces.ITexture; import gregtech.api.multitileentity.MultiTileEntityRegistry; import gregtech.api.multitileentity.base.BaseTickableMultiTileEntity; +import gregtech.api.multitileentity.multiblock.base.MultiBlockPart; +import gregtech.api.render.TextureFactory; +import gregtech.api.util.GT_Util; import gregtech.api.util.GT_Utility; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; +import net.minecraft.tileentity.TileEntity; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.IFluidTank; import static com.google.common.primitives.Ints.saturatedCast; +import static gregtech.api.enums.GT_Values.emptyIconContainerArray; public class MultiTileBasicMachine extends BaseTickableMultiTileEntity { + private static final String TEXTURE_LOCATION = "multitileentity/machines/"; + public IIconContainer[] mTexturesInactive = emptyIconContainerArray; + public IIconContainer[] mTexturesActive = emptyIconContainerArray; + protected int mParallel = 1; + protected boolean mActive = false; protected long mStoredEnergy = 0; protected FluidTankGT[] mTanksInput = GT_Values.emptyFluidTankGT, mTanksOutput = GT_Values.emptyFluidTankGT; protected ItemStack[] mOutputItems = GT_Values.emptyItemStackArray; @@ -35,13 +47,15 @@ public class MultiTileBasicMachine extends BaseTickableMultiTileEntity { @Override public void writeMultiTileNBT(NBTTagCompound aNBT) { super.writeMultiTileNBT(aNBT); + if (mParallel > 0) aNBT.setInteger(NBT.PARALLEL, mParallel); + if (mActive) aNBT.setBoolean(NBT.ACTIVE, mActive); } - @Override public void readMultiTileNBT(NBTTagCompound aNBT) { super.readMultiTileNBT(aNBT); if (aNBT.hasKey(NBT.PARALLEL)) mParallel = Math.max(1, aNBT.getInteger(NBT.PARALLEL)); + if (aNBT.hasKey(NBT.ACTIVE)) mActive = aNBT.getBoolean(NBT.ACTIVE); mInventory = getDefaultInventory(aNBT); if(mInventory != null) { @@ -69,6 +83,61 @@ public class MultiTileBasicMachine extends BaseTickableMultiTileEntity { } + @Override + public void loadTextureNBT(NBTTagCompound aNBT) { + // Loading the registry + final String textureName = aNBT.getString(NBT.TEXTURE); + mTextures = new IIconContainer[]{ + new Textures.BlockIcons.CustomIcon(TEXTURE_LOCATION + textureName + "/bottom"), + new Textures.BlockIcons.CustomIcon(TEXTURE_LOCATION + textureName + "/top"), + new Textures.BlockIcons.CustomIcon(TEXTURE_LOCATION + textureName + "/left"), + new Textures.BlockIcons.CustomIcon(TEXTURE_LOCATION + textureName + "/front"), + new Textures.BlockIcons.CustomIcon(TEXTURE_LOCATION + textureName + "/right"), + new Textures.BlockIcons.CustomIcon(TEXTURE_LOCATION + textureName + "/side") + }; + mTexturesInactive = new IIconContainer[]{ + new Textures.BlockIcons.CustomIcon(TEXTURE_LOCATION + textureName + "/overlay/inactive/bottom"), + new Textures.BlockIcons.CustomIcon(TEXTURE_LOCATION + textureName + "/overlay/inactive/top"), + new Textures.BlockIcons.CustomIcon(TEXTURE_LOCATION + textureName + "/overlay/inactive/left"), + new Textures.BlockIcons.CustomIcon(TEXTURE_LOCATION + textureName + "/overlay/inactive/front"), + new Textures.BlockIcons.CustomIcon(TEXTURE_LOCATION + textureName + "/overlay/inactive/right"), + new Textures.BlockIcons.CustomIcon(TEXTURE_LOCATION + textureName + "/overlay/inactive/back") + }; + mTexturesActive = new IIconContainer[]{ + new Textures.BlockIcons.CustomIcon(TEXTURE_LOCATION + textureName + "/overlay/active/bottom"), + new Textures.BlockIcons.CustomIcon(TEXTURE_LOCATION + textureName + "/overlay/active/top"), + new Textures.BlockIcons.CustomIcon(TEXTURE_LOCATION + textureName + "/overlay/active/left"), + new Textures.BlockIcons.CustomIcon(TEXTURE_LOCATION + textureName + "/overlay/active/front"), + new Textures.BlockIcons.CustomIcon(TEXTURE_LOCATION + textureName + "/overlay/active/right"), + new Textures.BlockIcons.CustomIcon(TEXTURE_LOCATION + textureName + "/overlay/active/back") + }; + + } + + @Override + public void copyTextures() { + // Loading an instance + final TileEntity tCanonicalTileEntity = MultiTileEntityRegistry.getCanonicalTileEntity(getMultiTileEntityRegistryID(), getMultiTileEntityID()); + if(tCanonicalTileEntity instanceof MultiTileBasicMachine){ + mTextures = ((MultiTileBasicMachine)tCanonicalTileEntity).mTextures; + mTexturesInactive = ((MultiTileBasicMachine)tCanonicalTileEntity).mTexturesInactive; + mTexturesActive = ((MultiTileBasicMachine)tCanonicalTileEntity).mTexturesActive; + } else { + mTextures = mTexturesInactive = mTexturesActive = emptyIconContainerArray; + } + } + + + + @Override + public ITexture[] getTexture(Block aBlock, byte aSide, boolean isActive, int aRenderPass) { + return new ITexture[]{ + TextureFactory.of(mTextures[GT_Values.FACING_ROTATIONS[mFacing][aSide]], GT_Util.getRGBaArray(mRGBa)), + TextureFactory.of((mActive ? mTexturesActive : mTexturesInactive)[GT_Values.FACING_ROTATIONS[mFacing][aSide]]) + }; + } + + /* * Fluids */ @@ -93,11 +162,6 @@ public class MultiTileBasicMachine extends BaseTickableMultiTileEntity { return tSize > 0 ? new ItemStack[tSize] : GT_Values.emptyItemStackArray; } - @Override - public ITexture[] getTexture(Block aBlock, byte aSide, boolean isActive, int aRenderPass) { - // TODO: MTE(Texture) - return new ITexture[0]; - } @Override public void setLightValue(byte aLightValue) { diff --git a/src/main/java/gregtech/api/multitileentity/multiblock/base/MultiBlockPart.java b/src/main/java/gregtech/api/multitileentity/multiblock/base/MultiBlockPart.java index e64ace1452..6c36798197 100644 --- a/src/main/java/gregtech/api/multitileentity/multiblock/base/MultiBlockPart.java +++ b/src/main/java/gregtech/api/multitileentity/multiblock/base/MultiBlockPart.java @@ -1,12 +1,17 @@ package gregtech.api.multitileentity.multiblock.base; import gregtech.api.enums.GT_Values; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.IIconContainer; import gregtech.api.interfaces.ITexture; +import gregtech.api.multitileentity.MultiTileEntityRegistry; +import gregtech.api.multitileentity.base.BaseMultiTileEntity; import gregtech.api.multitileentity.base.BaseNontickableMultiTileEntity; import gregtech.api.multitileentity.interfaces.IMultiBlockController; import gregtech.api.multitileentity.interfaces.IMultiTileEntity.IMTE_BreakBlock; import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_CoverBehaviorBase; +import gregtech.api.util.GT_Util; import gregtech.api.util.GT_Utility; import gregtech.api.util.ISerializableObject; import gregtech.common.render.GT_MultiTexture; @@ -187,10 +192,34 @@ public class MultiBlockPart extends BaseNontickableMultiTileEntity implements IM mMode = aData; } + + @Override + public void loadTextureNBT(NBTTagCompound aNBT) { + // Loading the registry + final String textureName = aNBT.getString(NBT.TEXTURE); + mTextures = new IIconContainer[] { + new Textures.BlockIcons.CustomIcon("multitileentity/multiblockparts/"+textureName+"/bottom"), + new Textures.BlockIcons.CustomIcon("multitileentity/multiblockparts/"+textureName+"/top"), + new Textures.BlockIcons.CustomIcon("multitileentity/multiblockparts/"+textureName+"/side"), + new Textures.BlockIcons.CustomIcon("multitileentity/multiblockparts/"+textureName+"/overlay/bottom"), + new Textures.BlockIcons.CustomIcon("multitileentity/multiblockparts/"+textureName+"/overlay/top"), + new Textures.BlockIcons.CustomIcon("multitileentity/multiblockparts/"+textureName+"/overlay/side") + }; + } + + @Override + public void copyTextures() { + // Loading an instance + final TileEntity tCanonicalTileEntity = MultiTileEntityRegistry.getCanonicalTileEntity(getMultiTileEntityRegistryID(), getMultiTileEntityID()); + if(tCanonicalTileEntity instanceof MultiBlockPart) + mTextures = ((MultiBlockPart)tCanonicalTileEntity).mTextures; + } + + @Override public ITexture[] getTexture(Block aBlock, byte aSide, boolean isActive, int aRenderPass) { - // TODO: MTE(Texture) -// final ITexture baseTexture = MACHINE_CASINGS[1][2]; + // For normal parts - texture comes from BaseMTE; overlay based on current mode + // TODO(MTE) - For Advanced parts they might come from somewhere else final ITexture baseTexture = TextureFactory.of(super.getTexture(aBlock, aSide, isActive, aRenderPass)); if(mMode != 0 && aSide == mFacing) { if(mMode == getModeOrdinal(ITEM_IN)) diff --git a/src/main/java/gregtech/loaders/preload/GT_Loader_MultiTileEntities.java b/src/main/java/gregtech/loaders/preload/GT_Loader_MultiTileEntities.java index 1df5f1cca4..78816374ef 100644 --- a/src/main/java/gregtech/loaders/preload/GT_Loader_MultiTileEntities.java +++ b/src/main/java/gregtech/loaders/preload/GT_Loader_MultiTileEntities.java @@ -1,5 +1,6 @@ package gregtech.loaders.preload; +import gregtech.api.enums.Materials; import gregtech.api.multitileentity.MultiTileEntityBlock; import gregtech.api.multitileentity.MultiTileEntityRegistry; import gregtech.api.multitileentity.multiblock.base.MultiBlockPart; @@ -26,7 +27,7 @@ public class GT_Loader_MultiTileEntities implements Runnable { .name("Large Macerator") .category("Multiblock Controller") .setBlock(aMachine) - .material(Material.iron) + .material(Materials.Iron) .texture("metalwall") .tankCapacity(128000L) .register(); @@ -35,7 +36,7 @@ public class GT_Loader_MultiTileEntities implements Runnable { .name("Test Casing") .category("Multiblock Casing") .setBlock(aMachine) - .material(Material.iron) + .material(Materials.Cobalt) .texture("metalwall") .register(); diff --git a/src/main/resources/assets/gregtech/textures/blocks/machines/multiblockparts/metalwall/bottom.png b/src/main/resources/assets/gregtech/textures/blocks/multitileentity/base/metalwall/bottom.png Binary files differindex e05f5d89c7..e05f5d89c7 100644 --- a/src/main/resources/assets/gregtech/textures/blocks/machines/multiblockparts/metalwall/bottom.png +++ b/src/main/resources/assets/gregtech/textures/blocks/multitileentity/base/metalwall/bottom.png diff --git a/src/main/resources/assets/gregtech/textures/blocks/machines/multiblockparts/metalwall/side.png b/src/main/resources/assets/gregtech/textures/blocks/multitileentity/base/metalwall/side.png Binary files differindex e05f5d89c7..e05f5d89c7 100644 --- a/src/main/resources/assets/gregtech/textures/blocks/machines/multiblockparts/metalwall/side.png +++ b/src/main/resources/assets/gregtech/textures/blocks/multitileentity/base/metalwall/side.png diff --git a/src/main/resources/assets/gregtech/textures/blocks/machines/multiblockparts/metalwall/top.png b/src/main/resources/assets/gregtech/textures/blocks/multitileentity/base/metalwall/top.png Binary files differindex e05f5d89c7..e05f5d89c7 100644 --- a/src/main/resources/assets/gregtech/textures/blocks/machines/multiblockparts/metalwall/top.png +++ b/src/main/resources/assets/gregtech/textures/blocks/multitileentity/base/metalwall/top.png diff --git a/src/main/resources/assets/gregtech/textures/blocks/multitileentity/machines/metalwall/bottom.png b/src/main/resources/assets/gregtech/textures/blocks/multitileentity/machines/metalwall/bottom.png Binary files differnew file mode 100644 index 0000000000..e05f5d89c7 --- /dev/null +++ b/src/main/resources/assets/gregtech/textures/blocks/multitileentity/machines/metalwall/bottom.png diff --git a/src/main/resources/assets/gregtech/textures/blocks/multitileentity/machines/metalwall/side.png b/src/main/resources/assets/gregtech/textures/blocks/multitileentity/machines/metalwall/side.png Binary files differnew file mode 100644 index 0000000000..e05f5d89c7 --- /dev/null +++ b/src/main/resources/assets/gregtech/textures/blocks/multitileentity/machines/metalwall/side.png diff --git a/src/main/resources/assets/gregtech/textures/blocks/multitileentity/machines/metalwall/top.png b/src/main/resources/assets/gregtech/textures/blocks/multitileentity/machines/metalwall/top.png Binary files differnew file mode 100644 index 0000000000..e05f5d89c7 --- /dev/null +++ b/src/main/resources/assets/gregtech/textures/blocks/multitileentity/machines/metalwall/top.png diff --git a/src/main/resources/assets/gregtech/textures/blocks/multitileentity/multiblockparts/metalwall/bottom.png b/src/main/resources/assets/gregtech/textures/blocks/multitileentity/multiblockparts/metalwall/bottom.png Binary files differnew file mode 100644 index 0000000000..e05f5d89c7 --- /dev/null +++ b/src/main/resources/assets/gregtech/textures/blocks/multitileentity/multiblockparts/metalwall/bottom.png diff --git a/src/main/resources/assets/gregtech/textures/blocks/multitileentity/multiblockparts/metalwall/side.png b/src/main/resources/assets/gregtech/textures/blocks/multitileentity/multiblockparts/metalwall/side.png Binary files differnew file mode 100644 index 0000000000..e05f5d89c7 --- /dev/null +++ b/src/main/resources/assets/gregtech/textures/blocks/multitileentity/multiblockparts/metalwall/side.png diff --git a/src/main/resources/assets/gregtech/textures/blocks/multitileentity/multiblockparts/metalwall/top.png b/src/main/resources/assets/gregtech/textures/blocks/multitileentity/multiblockparts/metalwall/top.png Binary files differnew file mode 100644 index 0000000000..e05f5d89c7 --- /dev/null +++ b/src/main/resources/assets/gregtech/textures/blocks/multitileentity/multiblockparts/metalwall/top.png |