From 77ec16dab52a7cdb391a14fa4026cf597622d4fd Mon Sep 17 00:00:00 2001 From: Zalgo239 <67443118+Zalgo239@users.noreply.github.com> Date: Sat, 23 Dec 2023 14:56:34 +0100 Subject: [PATCH] Added consequences for failures --- .../api/unification/material/Materials.java | 2 ++ .../UnknownCompositionMaterials.java | 8 ++++- .../multi/MetaTileEntityFissionReactor.java | 36 +++++++++++++++++-- 3 files changed, 42 insertions(+), 4 deletions(-) diff --git a/src/main/java/gregtech/api/unification/material/Materials.java b/src/main/java/gregtech/api/unification/material/Materials.java index d2d65e81f72..1209aadd6bb 100644 --- a/src/main/java/gregtech/api/unification/material/Materials.java +++ b/src/main/java/gregtech/api/unification/material/Materials.java @@ -683,6 +683,8 @@ public static void register() { public static Material UUMatter; public static Material PCBCoolant; + public static Material Corium; + /** * Second Degree Compounds */ diff --git a/src/main/java/gregtech/api/unification/material/materials/UnknownCompositionMaterials.java b/src/main/java/gregtech/api/unification/material/materials/UnknownCompositionMaterials.java index 2b8918b2abb..cf55a739501 100644 --- a/src/main/java/gregtech/api/unification/material/materials/UnknownCompositionMaterials.java +++ b/src/main/java/gregtech/api/unification/material/materials/UnknownCompositionMaterials.java @@ -331,7 +331,13 @@ public static void register() { .flags(FLAMMABLE) .build(); - // Free IDs 1560-1575 + Corium = new Material.Builder(1560, gregtechId("corium")) + .liquid(new FluidBuilder().temperature(2500).block().density(8.0D)) + .color(0x7A6B50) + .flags(NO_UNIFICATION, STICKY, GLOWING) + .build(); + + // Free IDs 1561-1575 LPG = new Material.Builder(1576, gregtechId("lpg")) .liquid(new FluidBuilder().customStill()) diff --git a/src/main/java/gregtech/common/metatileentities/multi/MetaTileEntityFissionReactor.java b/src/main/java/gregtech/common/metatileentities/multi/MetaTileEntityFissionReactor.java index 3d11ee9ac8e..d743b66e2f1 100644 --- a/src/main/java/gregtech/common/metatileentities/multi/MetaTileEntityFissionReactor.java +++ b/src/main/java/gregtech/common/metatileentities/multi/MetaTileEntityFissionReactor.java @@ -21,6 +21,7 @@ import gregtech.api.pattern.FactoryBlockPattern; import gregtech.api.unification.OreDictUnifier; import gregtech.api.unification.material.Material; +import gregtech.api.unification.material.Materials; import gregtech.api.unification.material.properties.FissionFuelProperty; import gregtech.api.unification.material.properties.PropertyKey; import gregtech.api.unification.ore.OrePrefix; @@ -46,6 +47,10 @@ import net.minecraft.world.World; import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fml.relauncher.Side; + +import net.minecraftforge.fml.relauncher.SideOnly; + import org.jetbrains.annotations.NotNull; import java.util.ArrayList; @@ -132,17 +137,41 @@ protected void updateFormedValid() { this.updateReactorState(); if (this.fissionReactor.checkForMeltdown()) { - // TODO Meltdown consequences + this.performMeltdownEffects(); } if (this.fissionReactor.checkForExplosion()) { - // TODO Explosion consequences + this.performPrimaryExplosion(); if (this.fissionReactor.checkForSecondaryExplosion()) { - // TODO Secondary explosion consequences + this.performSecondaryExplosion(); } } + } + } + protected void performMeltdownEffects() { + BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos(this.getPos()); + pos = pos.move(this.getFrontFacing().getOpposite(), Math.floorDiv(diameter, 2)); + for (int i = 0; i <= this.heightBottom; i++) { + this.getWorld().setBlockState(pos.add(0, -i, 0), Materials.Corium.getFluid().getBlock().getDefaultState()); + this.getWorld().setBlockState(pos.add(1, -i, 0), Materials.Corium.getFluid().getBlock().getDefaultState()); + this.getWorld().setBlockState(pos.add(-1, -i, 0), Materials.Corium.getFluid().getBlock().getDefaultState()); + this.getWorld().setBlockState(pos.add(0, -i, 1), Materials.Corium.getFluid().getBlock().getDefaultState()); + this.getWorld().setBlockState(pos.add(0, -i, -1), Materials.Corium.getFluid().getBlock().getDefaultState()); } + this.getWorld().setBlockState(pos.add(0, 1, 0), Materials.Corium.getFluid().getBlock().getDefaultState()); + } + + protected void performPrimaryExplosion() { + BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos(this.getPos()); + pos = pos.move(this.getFrontFacing().getOpposite(), Math.floorDiv(diameter, 2)); + this.getWorld().createExplosion(null, pos.getX(), pos.getY() + heightTop, pos.getZ(), 4.f, true); + } + + protected void performSecondaryExplosion() { + BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos(this.getPos()); + pos = pos.move(this.getFrontFacing().getOpposite(), Math.floorDiv(diameter, 2)); + this.getWorld().newExplosion(null, pos.getX(), pos.getY() + heightTop + 3, pos.getZ(), 10.f, true, true); } public boolean updateStructureDimensions() { @@ -283,6 +312,7 @@ public ICubeRenderer getBaseTexture(IMultiblockPart sourcePart) { return Textures.FISSION_REACTOR_TEXTURE; } + @SideOnly(Side.CLIENT) @NotNull @Override protected ICubeRenderer getFrontOverlay() {