diff options
| author | RecursivePineapple <recursive_pineapple@proton.me> | 2024-08-08 09:16:57 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-08-08 20:16:57 +0700 |
| commit | 89156d0d8485753e0cea91637fced1b66897a6df (patch) | |
| tree | c5f8fb72aa0e30822cad8f015fd8a25021915466 /src/main | |
| parent | 3c228c3bab6b2fd731063e59b029f98882fc25e6 (diff) | |
| download | GT5-Unofficial-89156d0d8485753e0cea91637fced1b66897a6df.tar.gz GT5-Unofficial-89156d0d8485753e0cea91637fced1b66897a6df.tar.bz2 GT5-Unofficial-89156d0d8485753e0cea91637fced1b66897a6df.zip | |
Added the miniature wormhole generator (#2800)
* Added the miniature wormhole generator
* Updated structure & tooltip and added hatch hask
* Fixed controller promotion not working
* Initial work wormhole render + spotless + git strangeness
* Fix wildcard imports
* Removed redundant code + added more reasonable defaults
* fix
* sa
* Remove debug print statements
---------
Co-authored-by: Martin Robertz <dream-master@gmx.net>
Co-authored-by: CookieBrigade <138534411+cookiebrigade@users.noreply.github.com>
Diffstat (limited to 'src/main')
14 files changed, 1468 insertions, 2 deletions
diff --git a/src/main/java/gregtech/api/GregTech_API.java b/src/main/java/gregtech/api/GregTech_API.java index a65f9eedb5..cdcc3b4a0f 100644 --- a/src/main/java/gregtech/api/GregTech_API.java +++ b/src/main/java/gregtech/api/GregTech_API.java @@ -301,6 +301,7 @@ public class GregTech_API { public static Block sBlockGlass1; public static Block sBlockTintedGlass; public static Block sLaserRender; + public static Block sWormholeRender; /** * Getting assigned by the Config */ diff --git a/src/main/java/gregtech/api/enums/ItemList.java b/src/main/java/gregtech/api/enums/ItemList.java index 1f5d223a6b..57a44373b6 100644 --- a/src/main/java/gregtech/api/enums/ItemList.java +++ b/src/main/java/gregtech/api/enums/ItemList.java @@ -2040,6 +2040,8 @@ public enum ItemList implements IItemContainer { TierdDrone1, TierdDrone2, Hatch_DroneDownLink, + Casing_Shielded_Accelerator, + WormholeGenerator, Hatch_pHSensor, Hatch_LensHousing, Hatch_LensIndicator, @@ -2069,7 +2071,6 @@ public enum ItemList implements IItemContainer { Quark_Creation_Catalyst_Bottom, Quark_Creation_Catalyst_Top, Quark_Creation_Catalyst_Unaligned, - Casing_Shielded_Accelerator, GlassOmniPurposeInfinityFused, GlassQuarkContainment, BlockQuarkPipe, diff --git a/src/main/java/gregtech/api/enums/MetaTileEntityIDs.java b/src/main/java/gregtech/api/enums/MetaTileEntityIDs.java index 78bc31ec57..de74b51806 100644 --- a/src/main/java/gregtech/api/enums/MetaTileEntityIDs.java +++ b/src/main/java/gregtech/api/enums/MetaTileEntityIDs.java @@ -701,7 +701,8 @@ public enum MetaTileEntityIDs { sofc2(13102), tfft(13104), lsc(13106), - tfftHatch(13109); + tfftHatch(13109), + WORMHOLE_GENERATOR_CONTROLLER(13115); public final int ID; diff --git a/src/main/java/gregtech/api/recipe/check/CheckRecipeResultRegistry.java b/src/main/java/gregtech/api/recipe/check/CheckRecipeResultRegistry.java index 41ea858fec..5844a49180 100644 --- a/src/main/java/gregtech/api/recipe/check/CheckRecipeResultRegistry.java +++ b/src/main/java/gregtech/api/recipe/check/CheckRecipeResultRegistry.java @@ -155,5 +155,6 @@ public final class CheckRecipeResultRegistry { register(new ResultInsufficientMachineTier(0)); register(new ResultInsufficientStartupPower(0)); register(new ResultInsufficientStartupPowerBigInt(BigInteger.ZERO)); + register(new ResultMissingItem()); } } diff --git a/src/main/java/gregtech/api/recipe/check/ResultMissingItem.java b/src/main/java/gregtech/api/recipe/check/ResultMissingItem.java new file mode 100644 index 0000000000..868d664109 --- /dev/null +++ b/src/main/java/gregtech/api/recipe/check/ResultMissingItem.java @@ -0,0 +1,60 @@ +package gregtech.api.recipe.check; + +import java.util.Objects; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +import net.minecraft.client.resources.I18n; +import net.minecraft.item.ItemStack; +import net.minecraft.network.PacketBuffer; + +import cpw.mods.fml.common.network.ByteBufUtils; + +public class ResultMissingItem implements CheckRecipeResult { + + @Nullable + public ItemStack itemStack; + + public ResultMissingItem() { + + } + + public ResultMissingItem(@Nullable ItemStack itemStack) { + this.itemStack = itemStack; + } + + @Override + @Nonnull + public String getID() { + return "missing_item"; + } + + @Override + public boolean wasSuccessful() { + return false; + } + + @Override + @Nonnull + public String getDisplayString() { + return Objects.requireNonNull( + I18n.format("GT5U.gui.text.missing_item", itemStack != null ? itemStack.getDisplayName() : "null")); + } + + @Override + @Nonnull + public CheckRecipeResult newInstance() { + return new ResultMissingItem(itemStack != null ? itemStack.copy() : null); + } + + @Override + public void encode(@Nonnull PacketBuffer buffer) { + ByteBufUtils.writeItemStack(buffer, itemStack); + } + + @Override + public void decode(PacketBuffer buffer) { + this.itemStack = ByteBufUtils.readItemStack(buffer); + } +} diff --git a/src/main/java/gregtech/api/util/GT_Utility.java b/src/main/java/gregtech/api/util/GT_Utility.java index c0f7413995..581c22852e 100644 --- a/src/main/java/gregtech/api/util/GT_Utility.java +++ b/src/main/java/gregtech/api/util/GT_Utility.java @@ -3489,6 +3489,7 @@ public class GT_Utility { EnumChatFormatting.GOLD + GT_Utility.trans("166", "Is valid Beacon Pyramid Material") + EnumChatFormatting.RESET); } catch (Throwable e) { + tList.add(String.format("§cAn exception was thrown while fetching this block's info.§r")); if (D1) e.printStackTrace(GT_Log.err); } } @@ -3517,6 +3518,7 @@ public class GT_Utility { } } } catch (Throwable e) { + tList.add(String.format("§cAn exception was thrown while fetching this tile's fluid tank info.§r")); if (D1) e.printStackTrace(GT_Log.err); } return rEUAmount; @@ -3532,6 +3534,7 @@ public class GT_Utility { if (temp != null) tList.addAll(temp); } } catch (Throwable e) { + tList.add(String.format("§cAn exception was thrown while fetching this block's debug info.§r")); if (D1) e.printStackTrace(GT_Log.err); } return rEUAmount; @@ -3585,6 +3588,7 @@ public class GT_Utility { } } } catch (Throwable e) { + tList.add(String.format("§cAn exception was thrown while fetching this leaves' info.§r")); if (D1) e.printStackTrace(GT_Log.err); } return rEUAmount; @@ -3636,6 +3640,7 @@ public class GT_Utility { } } } catch (Throwable e) { + tList.add(String.format("§cAn exception was thrown while fetching this crop's info.§r")); if (D1) e.printStackTrace(GT_Log.err); } return rEUAmount; @@ -3647,6 +3652,7 @@ public class GT_Utility { tList.addAll(Arrays.asList(info.getInfoData())); } } catch (Throwable e) { + tList.add(String.format("§cAn exception was thrown while fetching this device's info.§r")); if (D1) e.printStackTrace(GT_Log.err); } } @@ -3660,6 +3666,7 @@ public class GT_Utility { + EnumChatFormatting.RESET); } } catch (Throwable e) { + tList.add(String.format("§cAn exception was thrown while fetching this device's owner.§r")); if (D1) e.printStackTrace(GT_Log.err); } } @@ -3702,6 +3709,7 @@ public class GT_Utility { + " EU"); } } catch (Throwable e) { + tList.add(String.format("§cAn exception was thrown while fetching this device's energy info.§r")); if (D1) e.printStackTrace(GT_Log.err); } } @@ -3716,6 +3724,7 @@ public class GT_Utility { if (tString != null && !tString.equals(E)) tList.add(tString); } } catch (Throwable e) { + tList.add(String.format("§cAn exception was thrown while fetching this device's covers.§r")); if (D1) e.printStackTrace(GT_Log.err); } return rEUAmount; @@ -3747,6 +3756,7 @@ public class GT_Utility { + EnumChatFormatting.RESET); } } catch (Throwable e) { + tList.add(String.format("§cAn exception was thrown while fetching this device's progress.§r")); if (D1) e.printStackTrace(GT_Log.err); } return rEUAmount; @@ -3762,6 +3772,7 @@ public class GT_Utility { + EnumChatFormatting.RESET); } } catch (Throwable e) { + tList.add(String.format("§cAn exception was thrown while fetching this device's upgrades.§r")); if (D1) e.printStackTrace(GT_Log.err); } return rEUAmount; @@ -3783,6 +3794,7 @@ public class GT_Utility { + " EU"); } } catch (Throwable e) { + tList.add(String.format("§cAn exception was thrown while fetching this device's IC2 energy info.§r")); if (D1) e.printStackTrace(GT_Log.err); } return rEUAmount; @@ -3799,6 +3811,7 @@ public class GT_Utility { + EnumChatFormatting.RESET); } } catch (Throwable e) { + tList.add(String.format("§cAn exception was thrown while fetching this device's EU conduction info.§r")); if (D1) e.printStackTrace(GT_Log.err); } return rEUAmount; @@ -3826,6 +3839,7 @@ public class GT_Utility { + EnumChatFormatting.RESET); } } catch (Throwable e) { + tList.add(String.format("§cAn exception was thrown while fetching this device's IC@ wrenchability.§r")); if (D1) e.printStackTrace(GT_Log.err); } return rEUAmount; @@ -3845,6 +3859,7 @@ public class GT_Utility { } } } catch (Throwable e) { + tList.add(String.format("§cAn exception was thrown while fetching this device's alignment info.§r")); if (D1) e.printStackTrace(GT_Log.err); } return rEUAmount; @@ -3869,6 +3884,7 @@ public class GT_Utility { + EnumChatFormatting.RESET); } } catch (Throwable e) { + tList.add(String.format("§cAn exception was thrown while fetching this reactor's info.§r")); if (D1) e.printStackTrace(GT_Log.err); } return rEUAmount; diff --git a/src/main/java/gregtech/common/GT_Client.java b/src/main/java/gregtech/common/GT_Client.java index 69fc98212f..9de59e8661 100644 --- a/src/main/java/gregtech/common/GT_Client.java +++ b/src/main/java/gregtech/common/GT_Client.java @@ -97,6 +97,7 @@ import gregtech.common.render.GT_MultiTile_Renderer; import gregtech.common.render.GT_PollutionRenderer; import gregtech.common.render.GT_RenderDrone; import gregtech.common.render.GT_Renderer_Block; +import gregtech.common.render.GT_WormholeRenderer; import gregtech.common.render.items.GT_MetaGenerated_Item_Renderer; import gregtech.common.tileentities.debug.GT_MetaTileEntity_AdvDebugStructureWriter; import gregtech.loaders.ExtraIcons; @@ -624,6 +625,7 @@ public class GT_Client extends GT_Proxy implements Runnable { new GT_MultiTile_Renderer(); new GT_RenderDrone(); new GT_LaserRenderer(); + new GT_WormholeRenderer(); metaGeneratedItemRenderer = new GT_MetaGenerated_Item_Renderer(); for (GT_MetaGenerated_Item item : GT_MetaGenerated_Item.sInstances.values()) { metaGeneratedItemRenderer.registerItem(item); diff --git a/src/main/java/gregtech/common/blocks/GT_WormholeRenderBlock.java b/src/main/java/gregtech/common/blocks/GT_WormholeRenderBlock.java new file mode 100644 index 0000000000..1c6e434477 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/GT_WormholeRenderBlock.java @@ -0,0 +1,75 @@ +package gregtech.common.blocks; + +import java.util.ArrayList; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.common.tileentities.render.TileWormhole; + +public class GT_WormholeRenderBlock extends Block { + + public GT_WormholeRenderBlock() { + super(Material.iron); + this.setResistance(20f); + this.setHardness(-1.0f); + // this.setCreativeTab(TecTech.creativeTabTecTech); + this.setBlockName("WormholeRenderer"); + this.setLightLevel(100.0f); + GameRegistry.registerBlock(this, getUnlocalizedName()); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister iconRegister) { + blockIcon = iconRegister.registerIcon("gregtech:iconsets/TRANSPARENT"); + } + + @Override + public String getUnlocalizedName() { + return "gt.wormholerenderer"; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public boolean canRenderInPass(int a) { + return true; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + public boolean hasTileEntity(int metadata) { + return true; + } + + @Override + public TileEntity createTileEntity(World world, int metadata) { + return new TileWormhole(); + } + + @Override + public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int meta, int fortune) { + return new ArrayList<>(); + } + + @Override + public boolean isCollidable() { + return true; + } + +} diff --git a/src/main/java/gregtech/common/render/GT_WormholeRenderer.java b/src/main/java/gregtech/common/render/GT_WormholeRenderer.java new file mode 100644 index 0000000000..43385eb861 --- /dev/null +++ b/src/main/java/gregtech/common/render/GT_WormholeRenderer.java @@ -0,0 +1,79 @@ +package gregtech.common.render; + +import static com.github.technus.tectech.rendering.EOH.EOH_RenderingUtils.addRenderedBlockInWorld; + +import net.minecraft.block.Block; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.init.Blocks; +import net.minecraft.tileentity.TileEntity; + +import org.lwjgl.opengl.GL11; + +import cpw.mods.fml.client.registry.ClientRegistry; +import gregtech.common.tileentities.render.TileWormhole; + +public class GT_WormholeRenderer extends TileEntitySpecialRenderer { + + public GT_WormholeRenderer() { + ClientRegistry.bindTileEntitySpecialRenderer(TileWormhole.class, this); + } + + private static final double trimPercentage = .95; + private static final double corePercentage = trimPercentage / Math.sqrt(3); + + private static void render(Block coreBlock, double rotation) { + + GL11.glPushMatrix(); + GL11.glRotated(rotation, 2, 1, 0); + GL11.glScaled(-1, -1, -1); + + Tessellator.instance.startDrawingQuads(); + Tessellator.instance.setColorOpaque_F(1f, 1f, 1f); + addRenderedBlockInWorld(Blocks.quartz_block, 0, 0, 0, 0); + Tessellator.instance.draw(); + + GL11.glScaled(trimPercentage, trimPercentage, trimPercentage); + + Tessellator.instance.startDrawingQuads(); + Tessellator.instance.setColorOpaque_F(0.1f, 0.1f, 0.1f); + addRenderedBlockInWorld(Blocks.coal_block, 0, 0, 0, 0); + Tessellator.instance.draw(); + GL11.glPopMatrix(); + + if (coreBlock != null) { + GL11.glPushMatrix(); + GL11.glScaled(corePercentage, corePercentage, corePercentage); + GL11.glRotated(rotation, 0, -2, .1); + Tessellator.instance.startDrawingQuads(); + Tessellator.instance.setColorOpaque_F(1f, 1f, 1f); + addRenderedBlockInWorld(coreBlock, 0, 0, 0, 0); + Tessellator.instance.draw(); + GL11.glPopMatrix(); + } + + } + + @Override + public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float timeSinceLastTick) { + + if (tile instanceof TileWormhole wTile) { + GL11.glPushMatrix(); + GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5); + GL11.glScaled(wTile.targetRadius, wTile.targetRadius, wTile.targetRadius); + GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); + GL11.glDisable(GL11.GL_LIGHTING); + + double rotationTimer = wTile.getWorldObj() + .getWorldInfo() + .getWorldTotalTime() + timeSinceLastTick; + + this.bindTexture(TextureMap.locationBlocksTexture); + render(wTile.getBlock(), rotationTimer); + + GL11.glPopAttrib(); + GL11.glPopMatrix(); + } + } +} diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_WormholeGenerator.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_WormholeGenerator.java new file mode 100644 index 0000000000..d0c356e4fe --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_WormholeGenerator.java @@ -0,0 +1,1119 @@ +package gregtech.common.tileentities.machines.multi; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.lazy; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.withChannel; +import static goodgenerator.util.DescTextLocalization.BLUE_PRINT_INFO; +import static gregtech.api.enums.GT_HatchElement.InputBus; +import static gregtech.api.enums.GT_HatchElement.Maintenance; +import static gregtech.api.enums.GT_Values.V; +import static gregtech.api.enums.GT_Values.VN; +import static gregtech.api.enums.Textures.BlockIcons.getCasingTextureForId; +import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.lang.ref.Reference; +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +import com.github.bartimaeusnek.bartworks.API.BorosilicateGlass; +import com.github.technus.tectech.thing.casing.GT_Block_CasingsTT; +import com.github.technus.tectech.thing.casing.TT_Container_Casings; +import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_DynamoMulti; +import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_EnergyMulti; +import com.google.common.collect.MapMaker; +import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.ISurvivalBuildEnvironment; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; +import com.gtnewhorizons.modularui.common.widget.DynamicPositionedColumn; +import com.gtnewhorizons.modularui.common.widget.FakeSyncWidget; +import com.gtnewhorizons.modularui.common.widget.SlotWidget; +import com.gtnewhorizons.modularui.common.widget.TextWidget; + +import appeng.api.AEApi; +import gregtech.GT_Mod; +import gregtech.api.GregTech_API; +import gregtech.api.enums.SoundResource; +import gregtech.api.enums.TierEU; +import gregtech.api.interfaces.IHatchElement; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.interfaces.tileentity.IHasWorldObjectAndCoords; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_EnhancedMultiBlockBase; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.ResultMissingItem; +import gregtech.api.recipe.check.SimpleCheckRecipeResult; +import gregtech.api.render.TextureFactory; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; +import gregtech.api.util.IGT_HatchAdder; +import gregtech.common.tileentities.render.TileWormhole; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; + +public class GT_MetaTileEntity_WormholeGenerator extends + GT_MetaTileEntity_EnhancedMultiBlockBase<GT_MetaTileEntity_WormholeGenerator> implements ISurvivalConstructable { + + /** + * Number of seconds to average the wormhole energy over. + */ + public static int WH_ENERGY_AVG_WINDOW = 90; + + /** + * The amount of EU received per EU sent. + */ + public static double TRANSFER_EFFICIENCY = (1.0 - 0.00_0004 * 64); + + /** + * The amount of EU to lose every second the wormhole decays. + */ + public static double DECAY_RATE = 0.25; + + /** + * The amount of EU that the wormhole collapses at. + */ + public static double COLLAPSE_THRESHOLD = 32; + + /** + * The wormhole render radius percent of the max size when specified wormhole power is reached (purely aesthetical) + */ + public static double RENDER_PERCENT_TARGET = .1; + + /** + * Wormhole energy to specify reach the specified size percentage (purely aesthetical) + */ + public static double RENDER_TARGET_ENERGY = TierEU.IV * 256; + + /** + * Maximum wormhole radius (purely aesthetical) + */ + public static double RENDER_MAX_RADIUS = 2.999 / Math.sqrt(3); + + private static final String STRUCTURE_PIECE_MAIN = "main"; + private static final byte GLASS_TIER_UNSET = -2; + + private static final int TT_CASING_INDEX = GT_Block_CasingsTT.textureOffset; + + private static final int TOP_HATCH = 0, BOTTOM_HATCH = 1, LEFT_HATCH = 2, RIGHT_HATCH = 3, BACK_HATCH = 4, + FRONT_HATCH = 5, MAX_HATCHES = 6; + + private static final int[] OPPOSITES = { BOTTOM_HATCH, TOP_HATCH, RIGHT_HATCH, LEFT_HATCH, FRONT_HATCH, + BACK_HATCH, }; + + private static final String[] HATCH_NAMES = { "Top", "Bottom", "Left", "Right", "Back", "Front" }; + private static final boolean[] HATCH_MASK = { true, true, true, true, false, false }; + + private byte mGlassTier = -2; + private boolean mStructureBadGlassTier = false; + + private final GT_MetaTileEntity_Hatch_EnergyMulti[] mSendHatches = new GT_MetaTileEntity_Hatch_EnergyMulti[MAX_HATCHES]; + private final GT_MetaTileEntity_Hatch_DynamoMulti[] mReceiveHatches = new GT_MetaTileEntity_Hatch_DynamoMulti[MAX_HATCHES]; + + private final ItemStack singularity = AEApi.instance() + .definitions() + .materials() + .singularity() + .maybeStack(1) + .get(); + private final ItemStack qeSingularity = AEApi.instance() + .definitions() + .materials() + .qESingularity() + .maybeStack(1) + .get(); + + private WormholeLink mLink; + private final WeakReference<GT_MetaTileEntity_WormholeGenerator> mSelfReference = new WeakReference<>(this); + + private double mWormholeEnergy_UI = 0; + + private boolean mIsUnloading = false; + + public GT_MetaTileEntity_WormholeGenerator(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GT_MetaTileEntity_WormholeGenerator(String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_WormholeGenerator(mName); + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity baseMetaTileEntity, ForgeDirection side, ForgeDirection facing, + int colorIndex, boolean active, boolean redstoneLevel) { + if (side == facing) { + if (active) { + return new ITexture[] { getCasingTextureForId(TT_CASING_INDEX), TextureFactory.builder() + .addIcon(TexturesGtBlock.Overlay_Machine_Controller_Advanced_Active) + .extFacing() + .build() }; + } else { + return new ITexture[] { getCasingTextureForId(TT_CASING_INDEX), TextureFactory.builder() + .addIcon(TexturesGtBlock.Overlay_Machine_Controller_Advanced) + .extFacing() + .build() }; + } + } + return new ITexture[] { getCasingTextureForId(TT_CASING_INDEX) }; + } + + // #region Structure + + // spotless:off + private static final IStructureDefinition<GT_MetaTileEntity_WormholeGenerator> STRUCTURE_DEFINITION = StructureDefinition + .<GT_MetaTileEntity_WormholeGenerator>builder() + .addShape( + STRUCTURE_PIECE_MAIN, + transpose( + new String[][]{ + {" "," F "," EEE "," FEtEF "," EEE "," F "," "}, + {" F "," AADAA "," A B A ","FDBBBDF"," A B A "," AADAA "," F "}, + {" EEE "," A B A ","E E","EB BE","E E"," A B A "," EEE "}, + {" FE~EF ","FA B AF","E E","lB Br","E E","FA B AF"," FEEEF "}, + {" EEE "," A B A ","E E","EB BE","E E"," A B A "," EEE "}, + {" F "," AADAA "," A B A ","FDBBBDF"," A B A "," AADAA "," F "}, + {" "," F "," EEE "," FEbEF "," EEE "," F "," "} + })) + .addElement('E', + buildHatchAdder(GT_MetaTileEntity_WormholeGenerator.class) + .atLeast(Maintenance, InputBus) + .casingIndex(TT_CASING_INDEX) // High Power Casing + .dot(1) + .buildAndChain(lazy(() -> ofBlock(TT_Container_Casings.sBlockCasingsTT, 0))) // High Power Casing + ) + .addElement( + 'A', + withChannel( + "glass", + BorosilicateGlass.ofBoroGlass(GLASS_TIER_UNSET, (te, t) -> te.mGlassTier = t, te -> te.mGlassTier)) + ) + .addElement('D', ofBlock(GregTech_API.sBlockCasings8, 5)) // Europium Reinforced Radiation Proof Machine Casing + .addElement('B', ofBlock(GregTech_API.sBlockCasings4, 7)) // Fusion Coil Block + .addElement('F', lazy(() -> ofBlock(TT_Container_Casings.sBlockCasingsTT, 4))) // Molecular Casing + .addElement('t', + buildHatchAdder(GT_MetaTileEntity_WormholeGenerator.class) + .anyOf(new TransferHatch(TOP_HATCH)) + .casingIndex(TT_CASING_INDEX) // High Power Casing + .dot(2) + .buildAndChain(lazy(() -> ofBlock(TT_Container_Casings.sBlockCasingsTT, 0))) // High Power Casing + ) + .addElement('b', + buildHatchAdder(GT_MetaTileEntity_WormholeGenerator.class) + .anyOf(new TransferHatch(BOTTOM_HATCH)) + .casingIndex(TT_CASING_INDEX) // High Power Casing + .dot(2) + .buildAndChain(lazy(() -> ofBlock(TT_Container_Casings.sBlockCasingsTT, 0))) // High Power Casing + ) + .addElement('l', + buildHatchAdder(GT_MetaTileEntity_WormholeGenerator.class) + .anyOf(new TransferHatch(LEFT_HATCH)) + .casingIndex(TT_CASING_INDEX) // High Power Casing + .dot(2) + .buildAndChain(lazy(() -> ofBlock(TT_Container_Casings.sBlockCasingsTT, 0))) // High Power Casing + ) + .addElement('r', + buildHatchAdder(GT_MetaTileEntity_WormholeGenerator.class) + .anyOf(new TransferHatch(RIGHT_HATCH)) + .casingIndex(TT_CASING_INDEX) // High Power Casing + .dot(2) + .buildAndChain(lazy(() -> ofBlock(TT_Container_Casings.sBlockCasingsTT, 0))) // High Power Casing + ) + .build(); + // spotless:on + + private static class TransferHatch implements IHatchElement<GT_MetaTileEntity_WormholeGenerator> { + + public final int mIndex; + + public TransferHatch(int index) { + this.mIndex = index; + } + + @Override + public List<? extends Class<? extends IMetaTileEntity>> mteClasses() { + return Arrays.asList(GT_MetaTileEntity_Hatch_EnergyMulti.class, GT_MetaTileEntity_Hatch_DynamoMulti.class); + } + + @Override + public IGT_HatchAdder<? super GT_MetaTileEntity_WormholeGenerator> adder() { + return (tile, aTileEntity, aBaseCasingIndex) -> { + if (aTileEntity == null) return false; + + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + + if (aMetaTileEntity == null) return false; + + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_EnergyMulti input) { + input.updateTexture(aBaseCasingIndex); + input.updateCraftingIcon(tile.getMachineCraftingIcon()); + tile.mSendHatches[mIndex] = input; + return true; + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_DynamoMulti output) { + output.updateTexture(aBaseCasingIndex); + output.updateCraftingIcon(tile.getMachineCraftingIcon()); + tile.mReceiveHatches[mIndex] = output; + return true; + } + + return false; + }; + } + + @Override + public String name() { + return "TransferHatch"; + } + + @Override + public long count(GT_MetaTileEntity_WormholeGenerator t) { + return t.mExoticEnergyHatches.size(); + } + } + + @Override + public boolean isCorrectMachinePart(ItemStack aStack) { + return true; + } + + @Override + protected SoundResource getProcessStartSound() { + return SoundResource.GT_MACHINES_FUSION_LOOP; + } + + @Override + public IStructureDefinition<GT_MetaTileEntity_WormholeGenerator> getStructureDefinition() { + return STRUCTURE_DEFINITION; + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + if (!checkPiece(STRUCTURE_PIECE_MAIN, 3, 3, 0)) return false; + + mStructureBadGlassTier = false; + + for (var energyHatch : mExoticEnergyHatches) { + if (energyHatch.getBaseMetaTileEntity() == null) { + continue; + } + + if (energyHatch.getTierForStructure() > mGlassTier) { + mStructureBadGlassTier = true; + } + } + + return !mStructureBadGlassTier; + } + + @Override + public void clearHatches() { + super.clearHatches(); + + Arrays.fill(mSendHatches, null); + Arrays.fill(mReceiveHatches, null); + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(STRUCTURE_PIECE_MAIN, stackSize, hintsOnly, 3, 3, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { + if (mMachine) return -1; + return survivialBuildPiece(STRUCTURE_PIECE_MAIN, stackSize, 3, 3, 0, elementBudget, env, false, true); + } + + @Override + public int getDamageToComponent(ItemStack aStack) { + return 0; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack aStack) { + |
