diff --git a/src/main/java/com/dreammaster/gthandler/casings/GT_Block_CasingsNH.java b/src/main/java/com/dreammaster/gthandler/casings/GT_Block_CasingsNH.java index c7b340af1..175c4a872 100644 --- a/src/main/java/com/dreammaster/gthandler/casings/GT_Block_CasingsNH.java +++ b/src/main/java/com/dreammaster/gthandler/casings/GT_Block_CasingsNH.java @@ -2,21 +2,13 @@ import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import com.dreammaster.gthandler.CustomItemList; -import com.dreammaster.gthandler.multiAirFilter.GT_MetaTileEntity_AirFilterT1; -import com.dreammaster.gthandler.multiAirFilter.GT_MetaTileEntity_AirFilterT2; -import com.dreammaster.gthandler.multiAirFilter.GT_MetaTileEntity_AirFilterT3; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.enums.Dyes; import gregtech.api.enums.Textures; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.objects.GTCopiedBlockTexture; import gregtech.api.util.GTLanguageManager; import gregtech.common.blocks.BlockCasingsAbstract; @@ -95,95 +87,6 @@ public IIcon getIcon(int aSide, int aMeta) { } } - private IIcon getTurbineCasing(int meta, int iconIndex, boolean active) { - switch (meta) { - case 3: - return active ? Textures.BlockIcons.TURBINE_ACTIVE2[iconIndex].getIcon() - : Textures.BlockIcons.TURBINE2[iconIndex].getIcon(); - case 5: - return active ? Textures.BlockIcons.TURBINE_ACTIVE3[iconIndex].getIcon() - : Textures.BlockIcons.TURBINE3[iconIndex].getIcon(); - default: // 0 or undefined turbine meta casing - return active ? Textures.BlockIcons.TURBINE_ACTIVE[iconIndex].getIcon() - : Textures.BlockIcons.TURBINE[iconIndex].getIcon(); - } - } - - public boolean isTurbineMeta(int tMeta) { - return tMeta == 0 || tMeta == 3 || tMeta == 5; - } - - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(IBlockAccess aWorld, int xCoord, int yCoord, int zCoord, int ordinalSide) { - int tMeta = aWorld.getBlockMetadata(xCoord, yCoord, zCoord); - if (!isTurbineMeta(tMeta) && tMeta < 9 || tMeta == 15) { - return getIcon(ordinalSide, tMeta); - } - if (!isTurbineMeta(tMeta) || !mConnectedMachineTextures) { - return getIcon(ordinalSide, tMeta); - } - if (ordinalSide == 1) { - TileEntity tTileEntity; - IMetaTileEntity tMetaTileEntity; - - for (int xi = -2; xi <= 2; xi++) { - for (int zi = -2; zi <= 2; zi++) { - if (null != (tTileEntity = aWorld.getTileEntity(xCoord + xi, Math.max(yCoord - 3, 0), zCoord + zi)) - && tTileEntity instanceof IGregTechTileEntity - && null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity()) - && (tMetaTileEntity instanceof GT_MetaTileEntity_AirFilterT1 - || tMetaTileEntity instanceof GT_MetaTileEntity_AirFilterT2 - || tMetaTileEntity instanceof GT_MetaTileEntity_AirFilterT3)) { - boolean active = false; - if (((IGregTechTileEntity) tTileEntity).isActive()) { - active = true; - } - // check for direction and placement and apply the texture - switch (((IGregTechTileEntity) tTileEntity).getFrontFacing()) { - case NORTH: - if (xi < 2 && xi > -2 && zi < 1) { // if invalid position ignore (aka too far away) - try { - return getTurbineCasing(tMeta, -xi + 1 - zi * 3, active); - } catch (Exception e) { - return getIcon(ordinalSide, tMeta); - } - } - break; - case SOUTH: - if (xi < 2 && xi > -2 && zi > -1) { - try { - return getTurbineCasing(tMeta, -xi + 1 + (2 - zi) * 3, active); - } catch (Exception e) { - return getIcon(ordinalSide, tMeta); - } - } - break; - case WEST: - if (zi < 2 && zi > -2 && xi < 1) { - try { - return getTurbineCasing(tMeta, -xi + (1 - zi) * 3, active); - } catch (Exception e) { - return getIcon(ordinalSide, tMeta); - } - } - break; - case EAST: - if (zi < 2 && zi > -2 && xi > -1) { - try { - return getTurbineCasing(tMeta, -xi + 2 + (1 - zi) * 3, active); - } catch (Exception e) { - return getIcon(ordinalSide, tMeta); - } - } - } - } - } - } - } - return getIcon(ordinalSide, tMeta); - } - @Override public int colorMultiplier(IBlockAccess aWorld, int aX, int aY, int aZ) { return aWorld.getBlockMetadata(aX, aY, aZ) <= 9 ? super.colorMultiplier(aWorld, aX, aY, aZ) diff --git a/src/main/java/com/dreammaster/gthandler/multiAirFilter/GT_MetaTileEntity_AirFilterBase.java b/src/main/java/com/dreammaster/gthandler/multiAirFilter/GT_MetaTileEntity_AirFilterBase.java index 0f4c99ff0..7964449c7 100644 --- a/src/main/java/com/dreammaster/gthandler/multiAirFilter/GT_MetaTileEntity_AirFilterBase.java +++ b/src/main/java/com/dreammaster/gthandler/multiAirFilter/GT_MetaTileEntity_AirFilterBase.java @@ -1,7 +1,10 @@ package com.dreammaster.gthandler.multiAirFilter; +import static com.dreammaster.gthandler.casings.GT_Container_CasingsNH.sBlockCasingsNH; import static com.gtnewhorizon.structurelib.structure.StructureUtility.*; import static gregtech.api.enums.GTValues.VN; +import static gregtech.api.enums.Textures.BlockIcons.TURBINE_NEW; +import static gregtech.api.enums.Textures.BlockIcons.TURBINE_NEW_ACTIVE; import static gregtech.api.util.GTStructureUtility.ofHatchAdder; import static gregtech.api.util.GTStructureUtility.ofHatchAdderOptional; import static gregtech.api.util.GTUtility.filterValidMTEs; @@ -11,23 +14,27 @@ import java.util.ArrayList; import java.util.Arrays; +import net.minecraft.block.Block; +import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; +import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; import com.dreammaster.gthandler.CustomItemList; -import com.dreammaster.gthandler.casings.GT_Container_CasingsNH; import com.dreammaster.item.ItemList; import com.dreammaster.main.MainRegistry; import com.gtnewhorizon.structurelib.alignment.IAlignmentLimits; +import com.gtnewhorizon.structurelib.alignment.enumerable.ExtendedFacing; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; import com.gtnewhorizon.structurelib.structure.StructureDefinition; import eu.usrv.yamcore.auxiliary.PlayerChatHelper; import gregtech.api.enums.Textures; +import gregtech.api.interfaces.IIconContainer; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.items.MetaGeneratedTool; @@ -36,6 +43,7 @@ import gregtech.api.objects.GTRenderedTexture; import gregtech.api.util.GTRecipe; import gregtech.api.util.GTUtility; +import gregtech.api.util.GTUtilityClient; import gregtech.api.util.MultiblockTooltipBuilder; import gregtech.common.items.MetaGeneratedTool01; import gregtech.common.pollution.Pollution; @@ -53,6 +61,7 @@ public abstract class GT_MetaTileEntity_AirFilterBase protected boolean isFilterLoaded = false; protected int filterUsageRemaining = 0; protected int tickCounter = 0; // because we can't trust the world tick, it may be in a dim with eternal day, etc + private boolean mFormed; protected static final String STRUCTURE_PIECE_MAIN = "main"; protected static final ClassValue> STRUCTURE_DEFINITION = new ClassValue>() { @@ -68,7 +77,7 @@ protected IStructureDefinition computeValue(Cla 'c', lazy( x -> ofChain( - ofBlock(GT_Container_CasingsNH.sBlockCasingsNH, x.getCasingMeta()), + ofBlock(sBlockCasingsNH, x.getCasingMeta()), ofHatchAdder( GT_MetaTileEntity_AirFilterBase::addMaintenanceToMachineList, x.getCasingIndex(), @@ -85,8 +94,8 @@ protected IStructureDefinition computeValue(Cla GT_MetaTileEntity_AirFilterBase::addEnergyInputToMachineList, x.getCasingIndex(), 1)))) - .addElement('x', lazy(x -> ofBlock(GT_Container_CasingsNH.sBlockCasingsNH, x.getCasingMeta()))) - .addElement('v', lazy(x -> ofBlock(GT_Container_CasingsNH.sBlockCasingsNH, x.getPipeMeta()))) + .addElement('x', lazy(x -> ofBlock(sBlockCasingsNH, x.getCasingMeta()))) + .addElement('v', lazy(x -> ofBlock(sBlockCasingsNH, x.getPipeMeta()))) .addElement( 'm', lazy( @@ -94,7 +103,7 @@ protected IStructureDefinition computeValue(Cla GT_MetaTileEntity_AirFilterBase::addMufflerToMachineList, x.getCasingIndex(), 2, - GT_Container_CasingsNH.sBlockCasingsNH, + sBlockCasingsNH, x.getCasingMeta()))) .build(); } @@ -435,6 +444,37 @@ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { super.onPostTick(aBaseMetaTileEntity, aTick); } + @Override + public void onValueUpdate(byte aValue) { + mFormed = aValue == 1; + } + + @Override + public byte getUpdateData() { + return (byte) (mMachine ? 1 : 0); + } + + @Override + public boolean renderInWorld(IBlockAccess aWorld, int aX, int aY, int aZ, Block aBlock, RenderBlocks aRenderer) { + if (!mFormed) return false; + int[] xyz = new int[3]; + ExtendedFacing ext = getExtendedFacing(); + ext.getWorldOffset(new int[] { 0, -3, 1 }, xyz); + IIconContainer[] tTextures = getBaseMetaTileEntity().isActive() ? TURBINE_NEW_ACTIVE : TURBINE_NEW; + // we know this multi can only ever face upwards, so just use +y directly + ExtendedFacing direction = ExtendedFacing.of(ForgeDirection.UP); + GTUtilityClient.renderTurbineOverlay( + aWorld, + xyz[0] + aX, + xyz[1] + aY, + xyz[2] + aZ, + aRenderer, + direction, + sBlockCasingsNH, + tTextures); + return false; + } + @Override public boolean onRunningTick(ItemStack aStack) { if (tickCounter == 19 && hasPollution) {