From 207e96e95ad49fa530ef33dcc75c6613780720d4 Mon Sep 17 00:00:00 2001 From: screret <68943070+screret@users.noreply.github.com> Date: Sun, 22 Oct 2023 19:07:53 +0300 Subject: [PATCH] update. --- CHANGELOG.md | 3 + .../main/java/argent_matter/gcys/GCyS.java | 27 ++++ .../java/argent_matter/gcys/GCySClient.java | 4 +- .../java/argent_matter/gcys/GCySGTAddon.java | 12 +- .../gcys/api/capability/IDysonSystem.java | 11 +- .../registrate/GcysSoundEntryProvider.java | 45 ------- .../gcys/api/space/dyson/DysonSphere.java | 127 ++++++++++++++---- .../api/space/dyson/DysonSystemSavedData.java | 55 +++++--- .../client/particle/DysonBeamParticle.java | 5 +- .../DysonSystemControllerRenderer.java | 46 ------- .../gcys/common/data/GCySMachines.java | 4 +- .../gcys/common/data/GCySMaterials.java | 7 - .../DysonSystemControllerMachine.java | 89 +++++++++--- .../common/recipe/DysonSphereCondition.java | 10 +- .../gcys/data/lang/LangHandler.java | 5 + .../data/recipe/DysonSphereRecipeLoader.java | 12 ++ .../gcys/mixin/ServerLevelMixin.java | 2 +- .../resources/assets/gcys/lang/en_ud.json | 14 +- .../resources/assets/gcys/lang/en_us.json | 14 +- .../FixedGTRegistriesDatapackGenerator.java | 88 ------------ .../gcys/data/fabric/GCySDatagen.java | 10 +- .../argent_matter/gcys/fabric/GCySFabric.java | 13 +- fabric/src/main/resources/fabric.mod.json | 4 +- .../resources/assets/gcys/lang/en_ud.json | 5 +- .../resources/assets/gcys/lang/en_us.json | 5 +- .../data/forge/GCySKeyMappingsImpl.java | 2 +- .../gcys/data/forge/DataGenerators.java | 4 +- .../gcys/forge/ForgeCommonEventListener.java | 11 +- ...Client.java => GCySForgeClientEvents.java} | 2 +- forge/src/main/resources/META-INF/mods.toml | 2 +- settings.gradle | 2 +- 31 files changed, 339 insertions(+), 301 deletions(-) delete mode 100644 common/src/main/java/argent_matter/gcys/api/registries/registrate/GcysSoundEntryProvider.java delete mode 100644 common/src/main/java/argent_matter/gcys/client/renderer/machine/DysonSystemControllerRenderer.java delete mode 100644 fabric/src/main/java/argent_matter/gcys/data/fabric/FixedGTRegistriesDatapackGenerator.java rename forge/src/main/java/argent_matter/gcys/forge/{GCySForgeEventClient.java => GCySForgeClientEvents.java} (94%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2aaee4f7..2b236114 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ 0.0.2.a: - fix fabric +- make dyson sphere able to collapse if left without maintenance +- add dyson sphe +- remove rocket launch keybind 0.0.2: diff --git a/common/src/main/java/argent_matter/gcys/GCyS.java b/common/src/main/java/argent_matter/gcys/GCyS.java index 26790b90..35feef1f 100644 --- a/common/src/main/java/argent_matter/gcys/GCyS.java +++ b/common/src/main/java/argent_matter/gcys/GCyS.java @@ -1,16 +1,24 @@ package argent_matter.gcys; +import argent_matter.gcys.api.capability.GcysCapabilityHelper; +import argent_matter.gcys.api.capability.IDysonSystem; import argent_matter.gcys.api.gui.factory.EntityUIFactory; import argent_matter.gcys.api.registries.GcysRegistries; +import argent_matter.gcys.api.space.dyson.DysonSystemSavedData; import argent_matter.gcys.common.data.*; import argent_matter.gcys.config.GcysConfig; import argent_matter.gcys.data.GCySDatagen; import com.gregtechceu.gtceu.config.ConfigHolder; import com.lowdragmc.lowdraglib.gui.factory.UIFactory; import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.level.Level; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.HashSet; +import java.util.Set; + public class GCyS { public static final String MOD_ID = "gcys", @@ -52,4 +60,23 @@ public static void onKeyPressed(int key, int action, int modifiers) { } */ } + + private static final ThreadLocal> TICKED_SYSTEMS = ThreadLocal.withInitial(HashSet::new); + + public static void onLevelTick(Level ticked, boolean isStart) { + if (!(ticked instanceof ServerLevel level)) return; + + if (isStart) { + if (!level.dimensionType().hasCeiling()) { + var sat = GcysCapabilityHelper.getSatellites(level); + if (sat != null) sat.tickSatellites(); + } + + IDysonSystem system = DysonSystemSavedData.getOrCreate(level); + if (system == null || TICKED_SYSTEMS.get().contains(system)) return; + system.tick(); + } else { + TICKED_SYSTEMS.get().clear(); + } + } } \ No newline at end of file diff --git a/common/src/main/java/argent_matter/gcys/GCySClient.java b/common/src/main/java/argent_matter/gcys/GCySClient.java index f764740a..0e09c754 100644 --- a/common/src/main/java/argent_matter/gcys/GCySClient.java +++ b/common/src/main/java/argent_matter/gcys/GCySClient.java @@ -11,7 +11,7 @@ public class GCySClient { - public static boolean isDysonSphereActive; + public static boolean isDysonSphereActive = false; public static boolean hasUpdatedPlanets = false; public static List skyRenderers = new ArrayList<>(); @@ -20,6 +20,6 @@ public class GCySClient { public static List galaxies = new ArrayList<>(); public static void init() { - GCySKeyMappings.init(); + //GCySKeyMappings.init(); } } diff --git a/common/src/main/java/argent_matter/gcys/GCySGTAddon.java b/common/src/main/java/argent_matter/gcys/GCySGTAddon.java index a6df8817..2ec7fd00 100644 --- a/common/src/main/java/argent_matter/gcys/GCySGTAddon.java +++ b/common/src/main/java/argent_matter/gcys/GCySGTAddon.java @@ -45,16 +45,6 @@ public void registerCovers() { IGTAddon.super.registerCovers(); } - @Override - public void registerRecipeTypes() { - - } - - @Override - public void registerMachines() { - - } - @Override public void registerWorldgenLayers() { IGTAddon.super.registerWorldgenLayers(); @@ -71,7 +61,7 @@ public void collectMaterialCasings(MaterialCasingCollectionEvent event) { } @Override - public void initializeRecipes(Consumer provider) { + public void addRecipes(Consumer provider) { GCySRecipes.init(provider); } } diff --git a/common/src/main/java/argent_matter/gcys/api/capability/IDysonSystem.java b/common/src/main/java/argent_matter/gcys/api/capability/IDysonSystem.java index e98a1c19..cffb95c6 100644 --- a/common/src/main/java/argent_matter/gcys/api/capability/IDysonSystem.java +++ b/common/src/main/java/argent_matter/gcys/api/capability/IDysonSystem.java @@ -1,18 +1,23 @@ package argent_matter.gcys.api.capability; +import argent_matter.gcys.api.space.dyson.DysonSphere; import argent_matter.gcys.common.satellite.DysonSwarmSatellite; import net.minecraft.MethodsReturnNonnullByDefault; import net.minecraft.core.BlockPos; +import javax.annotation.Nullable; import javax.annotation.ParametersAreNonnullByDefault; @MethodsReturnNonnullByDefault @ParametersAreNonnullByDefault public interface IDysonSystem { /** - * @return if a dyson sphere active in this dimension. + * @return this solar system's active dyson sphere, or null if none */ + @Nullable + DysonSphere activeDysonSphere(); + boolean isDysonSphereActive(); /** @@ -27,4 +32,8 @@ public interface IDysonSystem { void addDysonSatellite(BlockPos controllerPos, DysonSwarmSatellite satellite); void disableAllDysonSatellites(BlockPos controllerPos); + + void tick(); + + void setDirty(); } diff --git a/common/src/main/java/argent_matter/gcys/api/registries/registrate/GcysSoundEntryProvider.java b/common/src/main/java/argent_matter/gcys/api/registries/registrate/GcysSoundEntryProvider.java deleted file mode 100644 index a928cb32..00000000 --- a/common/src/main/java/argent_matter/gcys/api/registries/registrate/GcysSoundEntryProvider.java +++ /dev/null @@ -1,45 +0,0 @@ -package argent_matter.gcys.api.registries.registrate; - -import argent_matter.gcys.GCyS; -import com.google.gson.JsonObject; -import com.gregtechceu.gtceu.GTCEu; -import com.gregtechceu.gtceu.api.registry.GTRegistries; -import com.gregtechceu.gtceu.api.sound.SoundEntry; -import net.minecraft.data.CachedOutput; -import net.minecraft.data.DataGenerator; -import net.minecraft.data.DataProvider; -import net.minecraft.data.PackOutput; - -import java.io.IOException; -import java.nio.file.Path; -import java.util.concurrent.CompletableFuture; - -public class GcysSoundEntryProvider implements DataProvider { - private final PackOutput output; - - public GcysSoundEntryProvider(PackOutput output) { - this.output = output; - } - - @Override - public CompletableFuture run(CachedOutput cache) { - return generate(output.getOutputFolder(PackOutput.Target.RESOURCE_PACK).resolve(GCyS.MOD_ID), cache); - } - - @Override - public String getName() { - return "GCyS's Custom Sounds"; - } - - public CompletableFuture generate(Path path, CachedOutput cache) { - JsonObject json = new JsonObject(); - try { - for (SoundEntry sound : GTRegistries.SOUNDS) { - if (sound.getId().getNamespace().equals(GCyS.MOD_ID)) sound.write(json); - } - } catch (Exception ignored) { - } - return DataProvider.saveStable(cache, json, path.resolve("sounds.json")); - } - -} \ No newline at end of file diff --git a/common/src/main/java/argent_matter/gcys/api/space/dyson/DysonSphere.java b/common/src/main/java/argent_matter/gcys/api/space/dyson/DysonSphere.java index ce25478d..a040fe95 100644 --- a/common/src/main/java/argent_matter/gcys/api/space/dyson/DysonSphere.java +++ b/common/src/main/java/argent_matter/gcys/api/space/dyson/DysonSphere.java @@ -1,40 +1,117 @@ package argent_matter.gcys.api.space.dyson; -import com.gregtechceu.gtceu.api.gui.widget.EnumSelectorWidget; -import com.lowdragmc.lowdraglib.gui.texture.IGuiTexture; +import argent_matter.gcys.api.capability.IDysonSystem; +import com.gregtechceu.gtceu.api.GTValues; +import lombok.Getter; +import lombok.Setter; import net.minecraft.core.BlockPos; -import net.minecraft.util.StringRepresentable; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtUtils; +import net.minecraft.nbt.Tag; +import net.minecraft.server.level.ServerLevel; -public record DysonSphere( - BlockPos controllerPos) { +public class DysonSphere { - public enum Component implements StringRepresentable, EnumSelectorWidget.SelectableEnum { - FRAME("frame", "gcys.dyson_component.frame"), - CELL("cell", "gcys.dyson_component.cell"), - PANEL("panel", "gcys.dyson_component.panel"), - PORT("port", "gcys.dyson_component.port") - ; + private final int MINIMUM_MAINTENANCE_TIME = 3456000; // 48 real-life hours = 3456000 ticks + private final float BASE_COLLAPSE_CHANCE = 0.00005f; - private final String id, tooltipKey; + private final IDysonSystem system; - Component(String id, String tooltipKey) { - this.id = id; - this.tooltipKey = tooltipKey; - } + @Getter + private BlockPos controllerPos; + @Getter @Setter + private int timeActive = 0, timeNeededMaintenance = 0; + @Getter + private boolean needsMaintenance; + @Getter @Setter + private boolean collapsed; + + public DysonSphere(BlockPos controllerPos, IDysonSystem system) { + this.controllerPos = controllerPos; + this.system = system; + } - @Override - public String getSerializedName() { - return id; + public void tick(ServerLevel level) { + if (level.getGameTime() % 20 == 0) { + if (this.isCollapsed()) return; + if (this.isNeedsMaintenance()) { + if (GTValues.RNG.nextFloat() <= BASE_COLLAPSE_CHANCE * timeNeededMaintenance) { + this.setCollapsed(); + } + + timeNeededMaintenance++; + this.system.setDirty(); + return; + } + + if (calculateTime(20)) { + if (GTValues.RNG.nextFloat() - 0.75f >= 0) { + this.needsMaintenance(); + } + } } + } - @Override - public String getTooltip() { - return tooltipKey; + public float getCollapseChance() { + return BASE_COLLAPSE_CHANCE * timeNeededMaintenance; + } + + public void needsMaintenance() { + this.needsMaintenance = true; + this.timeNeededMaintenance++; + this.system.setDirty(); + } + + public void fixMaintenance() { + this.needsMaintenance = false; + this.timeNeededMaintenance = 0; + this.system.setDirty(); + } + + public void setCollapsed() { + this.setCollapsed(true); + this.system.disableDysonSphere(this.controllerPos); + } + + private boolean calculateTime(int timeSinceLastTick) { + setTimeActive(timeSinceLastTick + getTimeActive()); + this.system.setDirty(); + var value = getTimeActive() - MINIMUM_MAINTENANCE_TIME; + if (value > 0) { + setTimeActive(value); + return true; } + return false; + } + + public void setControllerPos(BlockPos controllerPos) { + this.controllerPos = controllerPos; + this.system.setDirty(); + } - @Override - public IGuiTexture getIcon() { - return null; + public void save(CompoundTag tag) { + if (controllerPos != null) { + tag.put("controllerPos", NbtUtils.writeBlockPos(controllerPos)); } + tag.putBoolean("needsMaintenance", this.isNeedsMaintenance()); + tag.putBoolean("collapsed", this.isCollapsed()); + tag.putInt("timeActive", this.timeActive); + tag.putInt("timeNeededMaintenance", this.timeNeededMaintenance); + } + + public static DysonSphere load(CompoundTag tag, IDysonSystem system) { + BlockPos controllerPos = tag.contains("controllerPos", Tag.TAG_COMPOUND) ? NbtUtils.readBlockPos(tag.getCompound("controllerPos")) : null; + boolean needsMaintenance = tag.getBoolean("needsMaintenance"); + boolean collapsed = tag.getBoolean("collapsed"); + int timeActive = tag.getInt("timeActive"); + int timeNeededMaintenance = tag.getInt("timeNeededMaintenance"); + + DysonSphere sphere = new DysonSphere(controllerPos, system); + sphere.needsMaintenance = needsMaintenance; + sphere.setCollapsed(collapsed); + sphere.setTimeActive(timeActive); + sphere.setTimeNeededMaintenance(timeNeededMaintenance); + + return sphere; } } diff --git a/common/src/main/java/argent_matter/gcys/api/space/dyson/DysonSystemSavedData.java b/common/src/main/java/argent_matter/gcys/api/space/dyson/DysonSystemSavedData.java index ef029bc6..b3124aa6 100644 --- a/common/src/main/java/argent_matter/gcys/api/space/dyson/DysonSystemSavedData.java +++ b/common/src/main/java/argent_matter/gcys/api/space/dyson/DysonSystemSavedData.java @@ -24,10 +24,7 @@ import javax.annotation.Nullable; import javax.annotation.ParametersAreNonnullByDefault; -import java.util.HashSet; -import java.util.List; -import java.util.Objects; -import java.util.Set; +import java.util.*; @ParametersAreNonnullByDefault @MethodsReturnNonnullByDefault @@ -89,6 +86,12 @@ public DysonSystemSavedData(ServerLevel level, CompoundTag tag) { this.load(tag); } + @Override + @Nullable + public DysonSphere activeDysonSphere() { + return currentActiveSunBlock; + } + @Override public boolean isDysonSphereActive() { return currentActiveSunBlock != null; @@ -96,26 +99,38 @@ public boolean isDysonSphereActive() { @Override public int activeDysonSwarmSatelliteCount() { - return swarmSatellites.size(); + return (int) swarmSatellites.values().stream().flatMap(Collection::stream).count(); } @Override public void addDysonSphere(BlockPos controllerPos) { if (this.currentActiveSunBlock != null) return; - currentActiveSunBlock = new DysonSphere(controllerPos); + this.currentActiveSunBlock = new DysonSphere(controllerPos, this); + this.swarmSatellites.keySet().forEach(pos -> this.disableAllDysonSatellites(BlockPos.of(pos))); this.setDirty(); - for (ServerPlayer player : this.level.players()) { - GCySNetworking.NETWORK.sendToPlayer(new PacketSyncDysonSphereStatus(true), player); + for (ServerPlayer player : this.level.getServer().getPlayerList().getPlayers()) { + Planet playerPlanet = PlanetData.getPlanetFromLevel(player.serverLevel().dimension()).orElse(null); + Planet thisPlanet = PlanetData.getPlanetFromLevel(this.level.dimension()).orElse(null); + if (playerPlanet == null || thisPlanet == null) continue; + if (playerPlanet.solarSystem().equals(thisPlanet.solarSystem())) { + GCySNetworking.NETWORK.sendToPlayer(new PacketSyncDysonSphereStatus(false), player); + } } } @Override public void disableDysonSphere(BlockPos controllerPos) { - if (currentActiveSunBlock != null && controllerPos.equals(currentActiveSunBlock.controllerPos())) { - currentActiveSunBlock = null; + if (currentActiveSunBlock != null && controllerPos.equals(currentActiveSunBlock.getControllerPos())) { + currentActiveSunBlock.setControllerPos(null); + this.setDirty(); - for (ServerPlayer player : this.level.players()) { - GCySNetworking.NETWORK.sendToPlayer(new PacketSyncDysonSphereStatus(false), player); + for (ServerPlayer player : this.level.getServer().getPlayerList().getPlayers()) { + Planet playerPlanet = PlanetData.getPlanetFromLevel(player.serverLevel().dimension()).orElse(null); + Planet thisPlanet = PlanetData.getPlanetFromLevel(this.level.dimension()).orElse(null); + if (playerPlanet == null || thisPlanet == null) continue; + if (playerPlanet.solarSystem().equals(thisPlanet.solarSystem())) { + GCySNetworking.NETWORK.sendToPlayer(new PacketSyncDysonSphereStatus(false), player); + } } } } @@ -132,10 +147,16 @@ public void disableAllDysonSatellites(BlockPos controllerPos) { this.setDirty(); } + @Override + public void tick() { + if (this.currentActiveSunBlock != null) { + this.currentActiveSunBlock.tick(this.level); + } + } + public void load(CompoundTag arg) { - if (arg.contains("dysonSphereControllerPos", Tag.TAG_COMPOUND)) { - BlockPos sphereControllerPos = NbtUtils.readBlockPos(arg.getCompound("dysonSphereControllerPos")); - this.currentActiveSunBlock = new DysonSphere(sphereControllerPos); + if (arg.contains("dysonSphere", Tag.TAG_COMPOUND)) { + this.currentActiveSunBlock = DysonSphere.load(arg.getCompound("dysonSphere"), this); for (ServerPlayer player : this.level.players()) { GCySNetworking.NETWORK.sendToPlayer(new PacketSyncDysonSphereStatus(true), player); } @@ -154,7 +175,9 @@ public void load(CompoundTag arg) { @Override public CompoundTag save(CompoundTag compoundTag) { if (currentActiveSunBlock != null) { - compoundTag.put("dysonSphereControllerPos", NbtUtils.writeBlockPos(this.currentActiveSunBlock.controllerPos())); + CompoundTag tag = new CompoundTag(); + this.currentActiveSunBlock.save(tag); + compoundTag.put("dysonSphere", tag); } CompoundTag tag = new CompoundTag(); for (Long2ObjectMap.Entry> entry : swarmSatellites.long2ObjectEntrySet()) { diff --git a/common/src/main/java/argent_matter/gcys/client/particle/DysonBeamParticle.java b/common/src/main/java/argent_matter/gcys/client/particle/DysonBeamParticle.java index fd3acaef..419dd822 100644 --- a/common/src/main/java/argent_matter/gcys/client/particle/DysonBeamParticle.java +++ b/common/src/main/java/argent_matter/gcys/client/particle/DysonBeamParticle.java @@ -7,8 +7,9 @@ public class DysonBeamParticle extends SimpleAnimatedParticle { protected DysonBeamParticle(ClientLevel level, double x, double y, double z, SpriteSet sprites) { super(level, x, y, z, sprites, 0.0f); - this.quadSize *= 4.0f; - this.lifetime = 100; + this.quadSize = 1.0f; + this.lifetime = 20; + this.setSize(4.0f, 4.0f); this.setSpriteFromAge(sprites); } diff --git a/common/src/main/java/argent_matter/gcys/client/renderer/machine/DysonSystemControllerRenderer.java b/common/src/main/java/argent_matter/gcys/client/renderer/machine/DysonSystemControllerRenderer.java deleted file mode 100644 index 1c2d27de..00000000 --- a/common/src/main/java/argent_matter/gcys/client/renderer/machine/DysonSystemControllerRenderer.java +++ /dev/null @@ -1,46 +0,0 @@ -package argent_matter.gcys.client.renderer.machine; - -import argent_matter.gcys.common.data.GCySParticles; -import argent_matter.gcys.common.machine.multiblock.electric.DysonSystemControllerMachine; -import com.gregtechceu.gtceu.GTCEu; -import com.gregtechceu.gtceu.api.machine.IMachineBlockEntity; -import com.gregtechceu.gtceu.client.renderer.machine.WorkableCasingMachineRenderer; -import com.mojang.blaze3d.vertex.PoseStack; -import net.minecraft.client.renderer.MultiBufferSource; -import net.minecraft.core.BlockPos; -import net.minecraft.core.Direction; -import net.minecraft.world.level.block.entity.BlockEntity; - -public class DysonSystemControllerRenderer extends WorkableCasingMachineRenderer { - public DysonSystemControllerRenderer() { - super(GTCEu.id("block/casings/gcym/atomic_casing"), GTCEu.id("block/multiblock/assembly_line"), false); - } - - @Override - public int getViewDistance() { - return 128; - } - - @Override - public boolean isGlobalRenderer(BlockEntity blockEntity) { - return true; - } - - @Override - public void render(BlockEntity blockEntity, float partialTicks, PoseStack poseStack, MultiBufferSource buffer, int combinedLight, int combinedOverlay) { - if (blockEntity instanceof IMachineBlockEntity machineBlockEntity && machineBlockEntity.getMetaMachine() instanceof DysonSystemControllerMachine machine && machine.isActive()) { - var level = machine.getLevel(); - - Direction frontFacing = machine.getFrontFacing(); - Direction backFacing = frontFacing.getOpposite(); - Direction leftFacing = frontFacing.getCounterClockWise(); - BlockPos pos = blockEntity.getBlockPos().mutable().move(backFacing, 4).move(leftFacing, 1).immutable(); - - double x = pos.getX() + 0.5; - double z = pos.getZ() + 0.5; - for (int y = pos.getY(); y < 512; y += 4) { - level.addAlwaysVisibleParticle(GCySParticles.DYSON_BEAM, x, y, z, 0, 0, 0); - } - } - } -} diff --git a/common/src/main/java/argent_matter/gcys/common/data/GCySMachines.java b/common/src/main/java/argent_matter/gcys/common/data/GCySMachines.java index 9b5ed21c..cca80cfc 100644 --- a/common/src/main/java/argent_matter/gcys/common/data/GCySMachines.java +++ b/common/src/main/java/argent_matter/gcys/common/data/GCySMachines.java @@ -1,7 +1,6 @@ package argent_matter.gcys.common.data; import argent_matter.gcys.GCyS; -import argent_matter.gcys.client.renderer.machine.DysonSystemControllerRenderer; import argent_matter.gcys.common.machine.electric.OxygenSpreaderMachine; import argent_matter.gcys.common.machine.multiblock.electric.DysonSystemControllerMachine; import argent_matter.gcys.common.machine.multiblock.RocketScannerMachine; @@ -122,7 +121,8 @@ public class GCySMachines { .where('T', blocks(POWER_TRANSFORMER[GTValues.UV].getBlock())) .where(' ', any()) .build()) - .renderer(DysonSystemControllerRenderer::new) + .workableCasingRenderer(GTCEu.id("block/casings/gcym/atomic_casing"), + GTCEu.id("block/multiblock/assembly_line"), false) .register(); public static final MultiblockMachineDefinition SPACE_ELEVATOR = REGISTRATE.multiblock("space_elevator", WorkableElectricMultiblockMachine::new) diff --git a/common/src/main/java/argent_matter/gcys/common/data/GCySMaterials.java b/common/src/main/java/argent_matter/gcys/common/data/GCySMaterials.java index c2989b11..357e1482 100644 --- a/common/src/main/java/argent_matter/gcys/common/data/GCySMaterials.java +++ b/common/src/main/java/argent_matter/gcys/common/data/GCySMaterials.java @@ -95,13 +95,6 @@ public static void init() { .buildAndRegister() .setFormula("C6H2(CH3)4", true); - public static final Material FormicAcid = new Material.Builder("formic_acid") - .fluid(FluidStorageKeys.LIQUID, new FluidBuilder().attribute(FluidAttributes.ACID)) - .color(0xA6A6A6) - .flags(DISABLE_DECOMPOSITION) - .components(Carbon, 1, Hydrogen, 2, Oxygen, 2) - .buildAndRegister(); - public static final Material Dimethylformamide = new Material.Builder("dimethylformamide") .fluid() .color(0x554469) diff --git a/common/src/main/java/argent_matter/gcys/common/machine/multiblock/electric/DysonSystemControllerMachine.java b/common/src/main/java/argent_matter/gcys/common/machine/multiblock/electric/DysonSystemControllerMachine.java index ea319ba7..5e527d65 100644 --- a/common/src/main/java/argent_matter/gcys/common/machine/multiblock/electric/DysonSystemControllerMachine.java +++ b/common/src/main/java/argent_matter/gcys/common/machine/multiblock/electric/DysonSystemControllerMachine.java @@ -1,8 +1,8 @@ package argent_matter.gcys.common.machine.multiblock.electric; -import argent_matter.gcys.GCySClient; import argent_matter.gcys.api.capability.GcysCapabilityHelper; import argent_matter.gcys.api.capability.IDysonSystem; +import argent_matter.gcys.common.data.GCySParticles; import argent_matter.gcys.config.GcysConfig; import com.gregtechceu.gtceu.api.capability.recipe.ItemRecipeCapability; import com.gregtechceu.gtceu.api.machine.IMachineBlockEntity; @@ -17,6 +17,7 @@ import net.minecraft.core.Direction; import net.minecraft.network.chat.Component; import net.minecraft.server.level.ServerLevel; +import net.minecraft.util.RandomSource; import net.minecraft.world.entity.EntitySelector; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.level.Level; @@ -34,12 +35,36 @@ public DysonSystemControllerMachine(IMachineBlockEntity holder, Object... args) super(holder, args); } + @Override + public void onStructureInvalid() { + super.onStructureInvalid(); + if (!isRemote()) { + IDysonSystem system = GcysCapabilityHelper.getDysonSystem((ServerLevel) this.getLevel(), this.getPos()); + if (system == null || !system.isDysonSphereActive()) return; + system.activeDysonSphere().setControllerPos(null); + } + } + + @Override + public void onStructureFormed() { + super.onStructureFormed(); + if (!isRemote()) { + IDysonSystem system = GcysCapabilityHelper.getDysonSystem((ServerLevel) this.getLevel(), this.getPos()); + if (system == null) return; + if (system.isDysonSphereActive() && system.activeDysonSphere().getControllerPos() == null) { + system.activeDysonSphere().setControllerPos(this.getPos()); + } else if (!system.isDysonSphereActive()) { + system.addDysonSphere(this.getPos()); + } + } + } + @Override protected @Nullable GTRecipe getRealRecipe(GTRecipe recipe) { if (this.getLevel().dimensionType().hasCeiling()) return null; - if (recipe.getInputContents(ItemRecipeCapability.CAP).isEmpty()) { + if (recipe.data.contains("gcys:repair_dyson_sphere")) { IDysonSystem system = GcysCapabilityHelper.getDysonSystem((ServerLevel) this.getLevel(), this.getPos()); - if (system == null) return null; + if (system != null && system.isDysonSphereActive() && (!system.activeDysonSphere().isNeedsMaintenance() || !this.getPos().equals(system.activeDysonSphere().getControllerPos()))) return null; } return super.getRealRecipe(recipe); } @@ -66,8 +91,30 @@ public void afterWorking() { if (recipe.getInputContents(ItemRecipeCapability.CAP).isEmpty()) return; // assume the recipe is a dyson launch or repair if it has item inputs. IDysonSystem system = GcysCapabilityHelper.getDysonSystem((ServerLevel) this.getLevel(), this.getPos()); - if (system == null || system.isDysonSphereActive()) return; - system.addDysonSphere(this.getPos()); + if (system == null) return; + if (!system.isDysonSphereActive() && recipe.data.contains("gcys:launch_dyson_sphere")) { + system.addDysonSphere(this.getPos()); + } else if (system.isDysonSphereActive() && recipe.data.contains("gcys:repair_dyson_sphere") && system.activeDysonSphere().getControllerPos().equals(this.getPos())) { + system.activeDysonSphere().fixMaintenance(); + } + } + + @Override + public void animateTick(RandomSource random) { + if (this.isActive() && this.getOffsetTimer() % 20 == 0) { + var level = this.getLevel(); + + Direction frontFacing = this.getFrontFacing(); + Direction backFacing = frontFacing.getOpposite(); + Direction rightFacing = frontFacing.getClockWise(); + BlockPos pos = this.getPos().mutable().move(backFacing, 4).move(rightFacing, 1).move(0, 9, 0).immutable(); + + double x = pos.getX() + 0.5; + double z = pos.getZ() + 0.5; + for (int y = pos.getY(); y < 512; y += 4) { + level.addAlwaysVisibleParticle(GCySParticles.DYSON_BEAM, true, x, y, z, 0, 0, 0); + } + } } @Override @@ -75,24 +122,30 @@ public void addDisplayText(List textList) { super.addDisplayText(textList); if (!isFormed) return; - // TODO disable/remove this once release comes - Component button; - if (isRemote()) { - if (GCySClient.isDysonSphereActive) { - button = ComponentPanelWidget.withButton(Component.translatable("gui.gcys.dyson_sphere.stop").withStyle(ChatFormatting.RED), "dbg_delete_sphere"); - } else { - button = ComponentPanelWidget.withButton(Component.translatable("gui.gcys.dyson_sphere.start").withStyle(ChatFormatting.GREEN), "dbg_start_sphere"); - } - } else { + if (!isRemote()) { IDysonSystem system = GcysCapabilityHelper.getDysonSystem((ServerLevel) this.getLevel(), this.getPos()); - if (system != null && system.isDysonSphereActive()) { - button = ComponentPanelWidget.withButton(Component.translatable("gui.gcys.dyson_sphere.stop").withStyle(ChatFormatting.RED), "dbg_delete_sphere"); + if (system == null) return; + + if (system.isDysonSphereActive()) { + if (system.activeDysonSphere().isNeedsMaintenance() && !system.activeDysonSphere().isCollapsed()) { + textList.add(Component.translatable("menu.gcys.dyson_sphere.needs_maintenance").withStyle(this.getOffsetTimer() % 10 >= 5 ? ChatFormatting.RED : ChatFormatting.DARK_RED)); + textList.add(Component.translatable("menu.gcys.dyson_sphere.time_since_needed_maintenance", system.activeDysonSphere().getTimeNeededMaintenance())); + textList.add(Component.translatable("menu.gcys.dyson_sphere.implosion_chance", system.activeDysonSphere().getCollapseChance() * 100.0f)); + } else if (system.activeDysonSphere().isCollapsed()) { + textList.add(Component.translatable("menu.gcys.dyson_sphere.collapsed")); + } + } + + // TODO disable/remove this once release comes + Component button; + if (system.isDysonSphereActive()) { + button = ComponentPanelWidget.withButton(Component.translatable("menu.gcys.dyson_sphere.stop"), "dbg_delete_sphere").copy().withStyle(ChatFormatting.RED); } else { - button = ComponentPanelWidget.withButton(Component.translatable("gui.gcys.dyson_sphere.start").withStyle(ChatFormatting.GREEN), "dbg_start_sphere"); + button = ComponentPanelWidget.withButton(Component.translatable("menu.gcys.dyson_sphere.start"), "dbg_start_sphere").copy().withStyle(ChatFormatting.GREEN); } + textList.add(button); } - textList.add(button); } @Override diff --git a/common/src/main/java/argent_matter/gcys/common/recipe/DysonSphereCondition.java b/common/src/main/java/argent_matter/gcys/common/recipe/DysonSphereCondition.java index 45ad1026..969a18af 100644 --- a/common/src/main/java/argent_matter/gcys/common/recipe/DysonSphereCondition.java +++ b/common/src/main/java/argent_matter/gcys/common/recipe/DysonSphereCondition.java @@ -3,15 +3,9 @@ import argent_matter.gcys.api.capability.GcysCapabilityHelper; import argent_matter.gcys.api.capability.IDysonSystem; import com.google.gson.JsonObject; -import com.gregtechceu.gtceu.api.capability.ICleanroomReceiver; -import com.gregtechceu.gtceu.api.machine.MetaMachine; -import com.gregtechceu.gtceu.api.machine.feature.ICleanroomProvider; -import com.gregtechceu.gtceu.api.machine.feature.multiblock.IMultiController; -import com.gregtechceu.gtceu.api.machine.multiblock.CleanroomType; import com.gregtechceu.gtceu.api.machine.trait.RecipeLogic; import com.gregtechceu.gtceu.api.recipe.GTRecipe; import com.gregtechceu.gtceu.api.recipe.RecipeCondition; -import com.gregtechceu.gtceu.config.ConfigHolder; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; @@ -45,8 +39,8 @@ public boolean test(@NotNull GTRecipe recipe, @NotNull RecipeLogic recipeLogic) Level level = recipeLogic.getMachine().getLevel(); if (!level.isClientSide) { IDysonSystem system = GcysCapabilityHelper.getDysonSystem((ServerLevel) level, recipeLogic.getMachine().getPos()); - if ((system == null || !system.isDysonSphereActive()) && !isActive) return true; - else return system != null && system.isDysonSphereActive() && isActive; + if (system == null || !system.isDysonSphereActive() || !system.activeDysonSphere().isCollapsed() && !isActive) return true; + else return system.isDysonSphereActive() && !system.activeDysonSphere().isCollapsed() && isActive; } return false; } diff --git a/common/src/main/java/argent_matter/gcys/data/lang/LangHandler.java b/common/src/main/java/argent_matter/gcys/data/lang/LangHandler.java index c142bd42..f38a2123 100644 --- a/common/src/main/java/argent_matter/gcys/data/lang/LangHandler.java +++ b/common/src/main/java/argent_matter/gcys/data/lang/LangHandler.java @@ -37,6 +37,11 @@ public static void init(RegistrateLangProvider provider) { provider.add("key.startRocket", "Start RocketEntity"); provider.add("key.categories.gcys", "Gregicality Space"); + provider.add("menu.gcys.dyson_sphere.needs_maintenance", "DYSON SPHERE REQUIRES MAINTENANCE"); + provider.add("menu.gcys.dyson_sphere.time_since_needed_maintenance", "Time since last maintenance: %s seconds"); + provider.add("menu.gcys.dyson_sphere.implosion_chance", "Chance of implosion: %.2f%%"); + provider.add("menu.gcys.dyson_sphere.collapsed", "DYSON SPHERE COLLAPSED"); + provider.add("menu.gcys.launch", "LAUNCH"); provider.add("menu.gcys.catalog", "Catalog"); diff --git a/common/src/main/java/argent_matter/gcys/data/recipe/DysonSphereRecipeLoader.java b/common/src/main/java/argent_matter/gcys/data/recipe/DysonSphereRecipeLoader.java index 9965b512..959db023 100644 --- a/common/src/main/java/argent_matter/gcys/data/recipe/DysonSphereRecipeLoader.java +++ b/common/src/main/java/argent_matter/gcys/data/recipe/DysonSphereRecipeLoader.java @@ -63,6 +63,18 @@ public static void init(Consumer provider) { .inputItems(GCySBlocks.CASING_DYSON_PORT.asStack(32)) .inputItems(GCySItems.DYSON_CONSTRUCTION_DRONE.asStack(32)) .dimension(GCySDimensionTypes.SPACE_LEVEL.location()) + .addCondition(new DysonSphereCondition(false)) + .addData("gcys:launch_dyson_sphere", true) + .EUt(VA[UV]).duration(32000) + .save(provider); + + DYSON_ENERGY_RECIPES.recipeBuilder(GCyS.id("repair_dyson_sphere")) + .inputItems(GCySBlocks.CASING_DYSON_SPHERE.asStack(16)) + .inputItems(GCySBlocks.CASING_DYSON_CELL.asStack(8)) + .inputItems(GCySItems.DYSON_CONSTRUCTION_DRONE.asStack(16)) + .dimension(GCySDimensionTypes.SPACE_LEVEL.location()) + .addCondition(new DysonSphereCondition(true)) + .addData("gcys:repair_dyson_sphere", true) .EUt(VA[UV]).duration(32000) .save(provider); diff --git a/common/src/main/java/argent_matter/gcys/mixin/ServerLevelMixin.java b/common/src/main/java/argent_matter/gcys/mixin/ServerLevelMixin.java index 2d5603be..a8c9a515 100644 --- a/common/src/main/java/argent_matter/gcys/mixin/ServerLevelMixin.java +++ b/common/src/main/java/argent_matter/gcys/mixin/ServerLevelMixin.java @@ -19,7 +19,7 @@ public class ServerLevelMixin { @Inject(method = "setDayTime", at = @At("HEAD"), cancellable = true) public void gcys$overrideDayTime(long time, CallbackInfo ci) { IDysonSystem dysonSystem = GcysCapabilityHelper.getDysonSystem((ServerLevel) (Object) this, null); - if (dysonSystem != null && dysonSystem.isDysonSphereActive()) { + if (dysonSystem != null && dysonSystem.isDysonSphereActive() && !dysonSystem.activeDysonSphere().isCollapsed()) { long dayTime = this.serverLevelData.getDayTime(); this.serverLevelData.setDayTime(dayTime + (24000L - (dayTime % 24000L) + 18000L) % 24000L); ci.cancel(); diff --git a/fabric/src/generated/resources/assets/gcys/lang/en_ud.json b/fabric/src/generated/resources/assets/gcys/lang/en_ud.json index 78ba82ff..f76fb95f 100644 --- a/fabric/src/generated/resources/assets/gcys/lang/en_ud.json +++ b/fabric/src/generated/resources/assets/gcys/lang/en_ud.json @@ -3,17 +3,25 @@ "block.gcys.aerospace_aluminium_casing": "buısɐƆ ǝuıɥɔɐW ɯnıuıɯnןⱯ ǝpɐɹb-ǝɔɐdsoɹǝⱯ", "block.gcys.airlock_door": "ɹooᗡ ʞɔoןɹıⱯ", "block.gcys.beam_receiver": "ɹǝʌıǝɔǝᴚ ɯɐǝᗺ", + "block.gcys.drone_hangar": "ɹɐbuɐH ǝuoɹᗡ", "block.gcys.dyson_solar_cell": "ןןǝƆ ɹɐןoS uosʎᗡ", "block.gcys.dyson_sphere_casing": "buısɐƆ ǝɹǝɥdS uosʎᗡ", "block.gcys.dyson_sphere_maintenance_port": "ʇɹoԀ ǝɔuɐuǝʇuıɐW ǝɹǝɥdS uosʎᗡ", + "block.gcys.dyson_system_controller": "ɹǝןןoɹʇuoƆ ɯǝʇsʎS uosʎᗡ", "block.gcys.fuel_tank": "ʞuɐ⟘ ןǝnℲ", + "block.gcys.iv_oxygen_spreader": "ɹǝpɐǝɹdS uǝbʎxO ʌI", "block.gcys.launch_pad": "pɐԀ ɥɔunɐꞀ", + "block.gcys.luv_oxygen_spreader": "ɹǝpɐǝɹdS uǝbʎxO ʌnꞀ", "block.gcys.moon_sand": "puɐS uooW", "block.gcys.moon_stone": "ǝuoʇS uooW", "block.gcys.rocket_motor": "ɹoʇoW ʇǝʞɔoᴚ", + "block.gcys.rocket_scanner": "ɹǝuuɐɔS ʇǝʞɔoᴚ", "block.gcys.seat": "ʇɐǝS", + "block.gcys.space_elevator": "ɹoʇɐʌǝןƎ ǝɔɐdS", "block.gcys.space_elevator_support": "ʇɹoddnS ɹoʇɐʌǝןƎ ǝɔɐdS", - "block.minecraft.air": "ɹıⱯ", + "block.gcys.uhv_oxygen_spreader": "ɹǝpɐǝɹdS uǝbʎxO ʌɥ∩", + "block.gcys.uv_oxygen_spreader": "ɹǝpɐǝɹdS uǝbʎxO ʌ∩", + "block.gcys.zpm_oxygen_spreader": "ɹǝpɐǝɹdS uǝbʎxO ɯdZ", "entity.gcys.rocket": "ʇǝʞɔoᴚ", "gcys.condition.requires_dyson_sphere.false": "ǝʌıʇɔɐ ǝq oʇ ǝɹǝɥdS uosʎᗡ ou sǝɹınbǝᴚ", "gcys.condition.requires_dyson_sphere.true": "ǝɹǝɥdS uosʎᗡ ǝʌıʇɔɐ sǝɹınbǝᴚ", @@ -47,6 +55,10 @@ "menu.gcys.back": "ʞɔɐᗺ", "menu.gcys.catalog": "boןɐʇɐƆ", "menu.gcys.category": "ʎɹobǝʇɐƆ", + "menu.gcys.dyson_sphere.collapsed": "ᗡƎSԀⱯꞀꞀOƆ ƎᴚƎHԀS NOSʎᗡ", + "menu.gcys.dyson_sphere.implosion_chance": "%%ɟᄅ˙% :uoısoןdɯı ɟo ǝɔuɐɥƆ", + "menu.gcys.dyson_sphere.needs_maintenance": "ƎƆNⱯNƎ⟘NIⱯW SƎᴚI∩ὉƎᴚ ƎᴚƎHԀS NOSʎᗡ", + "menu.gcys.dyson_sphere.time_since_needed_maintenance": "spuoɔǝs %s :ǝɔuɐuǝʇuıɐɯ ʇsɐן ǝɔuıs ǝɯı⟘", "menu.gcys.galaxy": "ʎxɐןɐ⅁", "menu.gcys.gravity": "ʎʇıʌɐɹ⅁", "menu.gcys.launch": "HƆN∩ⱯꞀ", diff --git a/fabric/src/generated/resources/assets/gcys/lang/en_us.json b/fabric/src/generated/resources/assets/gcys/lang/en_us.json index 9f22106b..71812528 100644 --- a/fabric/src/generated/resources/assets/gcys/lang/en_us.json +++ b/fabric/src/generated/resources/assets/gcys/lang/en_us.json @@ -3,17 +3,25 @@ "block.gcys.aerospace_aluminium_casing": "Aerospace-grade Aluminium Machine Casing", "block.gcys.airlock_door": "Airlock Door", "block.gcys.beam_receiver": "Beam Receiver", + "block.gcys.drone_hangar": "Drone Hangar", "block.gcys.dyson_solar_cell": "Dyson Solar Cell", "block.gcys.dyson_sphere_casing": "Dyson Sphere Casing", "block.gcys.dyson_sphere_maintenance_port": "Dyson Sphere Maintenance Port", + "block.gcys.dyson_system_controller": "Dyson System Controller", "block.gcys.fuel_tank": "Fuel Tank", + "block.gcys.iv_oxygen_spreader": "Iv Oxygen Spreader", "block.gcys.launch_pad": "Launch Pad", + "block.gcys.luv_oxygen_spreader": "Luv Oxygen Spreader", "block.gcys.moon_sand": "Moon Sand", "block.gcys.moon_stone": "Moon Stone", "block.gcys.rocket_motor": "Rocket Motor", + "block.gcys.rocket_scanner": "Rocket Scanner", "block.gcys.seat": "Seat", + "block.gcys.space_elevator": "Space Elevator", "block.gcys.space_elevator_support": "Space Elevator Support", - "block.minecraft.air": "Air", + "block.gcys.uhv_oxygen_spreader": "Uhv Oxygen Spreader", + "block.gcys.uv_oxygen_spreader": "Uv Oxygen Spreader", + "block.gcys.zpm_oxygen_spreader": "Zpm Oxygen Spreader", "entity.gcys.rocket": "Rocket", "gcys.condition.requires_dyson_sphere.false": "Requires no Dyson Sphere to be active", "gcys.condition.requires_dyson_sphere.true": "Requires active Dyson Sphere", @@ -47,6 +55,10 @@ "menu.gcys.back": "Back", "menu.gcys.catalog": "Catalog", "menu.gcys.category": "Category", + "menu.gcys.dyson_sphere.collapsed": "DYSON SPHERE COLLAPSED", + "menu.gcys.dyson_sphere.implosion_chance": "Chance of implosion: %.2f%%", + "menu.gcys.dyson_sphere.needs_maintenance": "DYSON SPHERE REQUIRES MAINTENANCE", + "menu.gcys.dyson_sphere.time_since_needed_maintenance": "Time since last maintenance: %s seconds", "menu.gcys.galaxy": "Galaxy", "menu.gcys.gravity": "Gravity", "menu.gcys.launch": "LAUNCH", diff --git a/fabric/src/main/java/argent_matter/gcys/data/fabric/FixedGTRegistriesDatapackGenerator.java b/fabric/src/main/java/argent_matter/gcys/data/fabric/FixedGTRegistriesDatapackGenerator.java deleted file mode 100644 index f14d4db4..00000000 --- a/fabric/src/main/java/argent_matter/gcys/data/fabric/FixedGTRegistriesDatapackGenerator.java +++ /dev/null @@ -1,88 +0,0 @@ -package argent_matter.gcys.data.fabric; - -import com.google.gson.JsonElement; -import com.mojang.serialization.DynamicOps; -import com.mojang.serialization.JsonOps; -import net.minecraft.core.HolderLookup; -import net.minecraft.core.Registry; -import net.minecraft.core.RegistryAccess; -import net.minecraft.core.RegistrySetBuilder; -import net.minecraft.core.registries.BuiltInRegistries; -import net.minecraft.data.CachedOutput; -import net.minecraft.data.PackOutput; -import net.minecraft.data.registries.RegistriesDatapackGenerator; -import net.minecraft.core.HolderLookup.Provider; -import net.minecraft.resources.RegistryDataLoader; -import net.minecraft.resources.RegistryOps; -import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; -import org.jetbrains.annotations.NotNull; - -import java.util.HashSet; -import java.util.Optional; -import java.util.Set; -import java.util.concurrent.CompletableFuture; -import java.util.stream.Stream; - -public class FixedGTRegistriesDatapackGenerator extends RegistriesDatapackGenerator { - private final String name; - private final PackOutput output; - private final CompletableFuture registries; - private final java.util.function.Predicate namespacePredicate; - - private FixedGTRegistriesDatapackGenerator(String name, PackOutput output, CompletableFuture registries, Set modIds) { - super(output, registries); - this.name = name; - this.namespacePredicate = modIds::contains; - this.registries = registries; - this.output = output; - } - - public FixedGTRegistriesDatapackGenerator(PackOutput output, CompletableFuture registries, RegistrySetBuilder builder, Set modIds, String name) { - this(name, output, registries.thenApply(r -> constructRegistries(r, builder)), modIds); - } - - /** - * A method used to construct empty bootstraps for all registries this provider - * did not touch such that existing dynamic registry objects do not get inlined. - * - * @param original a future of a lookup for registries and their objects - * @param datapackEntriesBuilder a builder containing the dynamic registry objects added by this provider - * @return a new lookup containing the existing and to be generated registries and their objects - */ - private static HolderLookup.Provider constructRegistries(HolderLookup.Provider original, RegistrySetBuilder datapackEntriesBuilder) { - var builderKeys = new HashSet<>(datapackEntriesBuilder.entries.stream().map(RegistrySetBuilder.RegistryStub::key).toList()); - getDataPackRegistriesWithDimensions().filter(data -> !builderKeys.contains(data.key())).forEach(data -> datapackEntriesBuilder.add(data.key(), context -> {})); - return datapackEntriesBuilder.buildPatch(RegistryAccess.fromRegistryOfRegistries(BuiltInRegistries.REGISTRY), original); - } - - @Override - public CompletableFuture run(CachedOutput output) { - return this.registries.thenCompose((provider) -> { - DynamicOps dynamicops = RegistryOps.create(JsonOps.INSTANCE, provider); - return CompletableFuture.allOf(getDataPackRegistriesWithDimensions().flatMap((registryData) -> this.dumpRegistryCap(output, provider, dynamicops, registryData).stream()).toArray(CompletableFuture[]::new)); - }); - } - - private Optional> dumpRegistryCap(CachedOutput p_256502_, HolderLookup.Provider p_256492_, DynamicOps p_256000_, RegistryDataLoader.RegistryData p_256449_) { - ResourceKey> resourcekey = p_256449_.key(); - return p_256492_.lookup(resourcekey).map((registryLookup) -> { - PackOutput.PathProvider packoutput$pathprovider = this.output.createPathProvider(PackOutput.Target.DATA_PACK, prefixNamespace(resourcekey.location())); - return CompletableFuture.allOf(registryLookup.listElements().filter(holder -> this.namespacePredicate.test(holder.key().location().getNamespace())).map((p_256105_) -> dumpValue(packoutput$pathprovider.json(p_256105_.key().location()), p_256502_, p_256000_, p_256449_.elementCodec(), p_256105_.value())).toArray(CompletableFuture[]::new)); - }); - } - - public static Stream> getDataPackRegistriesWithDimensions() { - return Stream.concat(RegistryDataLoader.WORLDGEN_REGISTRIES.stream(), RegistryDataLoader.DIMENSION_REGISTRIES.stream()); - } - - public static String prefixNamespace(ResourceLocation registryKey) { - return registryKey.getNamespace().equals("minecraft") ? registryKey.getPath() : registryKey.getNamespace() + "/" + registryKey.getPath(); - } - - @Override - @NotNull - public String getName() { - return name; - } -} \ No newline at end of file diff --git a/fabric/src/main/java/argent_matter/gcys/data/fabric/GCySDatagen.java b/fabric/src/main/java/argent_matter/gcys/data/fabric/GCySDatagen.java index f91401fa..f5d284b8 100644 --- a/fabric/src/main/java/argent_matter/gcys/data/fabric/GCySDatagen.java +++ b/fabric/src/main/java/argent_matter/gcys/data/fabric/GCySDatagen.java @@ -2,15 +2,13 @@ import argent_matter.gcys.GCyS; import argent_matter.gcys.api.registries.GcysRegistries; -import argent_matter.gcys.api.registries.registrate.GcysSoundEntryProvider; import argent_matter.gcys.common.data.GCySBiomes; -import argent_matter.gcys.common.data.GCySRecipeTypes; -import argent_matter.gcys.common.data.GCySSoundEntries; -import com.gregtechceu.gtceu.common.data.GTMachines; +import com.gregtechceu.gtceu.api.registry.registrate.SoundEntryBuilder; import com.gregtechceu.gtceu.data.fabric.GTRegistriesDatapackGenerator; import io.github.fabricators_of_create.porting_lib.data.ExistingFileHelper; import net.fabricmc.fabric.api.datagen.v1.DataGeneratorEntrypoint; import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator; +import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; import net.fabricmc.loader.api.FabricLoader; import net.minecraft.Util; import net.minecraft.core.HolderLookup; @@ -39,12 +37,12 @@ public void onInitializeDataGenerator(FabricDataGenerator generator) { var pack = generator.createPack(); GcysRegistries.REGISTRATE.setupDatagen(pack, helper); // sound - pack.addProvider((FabricDataGenerator.Pack.Factory) GcysSoundEntryProvider::new); + pack.addProvider((FabricDataOutput output) -> new SoundEntryBuilder.SoundEntryProvider(output, GCyS.MOD_ID)); // worldgen var set = Set.of(GCyS.MOD_ID); var registryAccess = RegistryAccess.fromRegistryOfRegistries(BuiltInRegistries.REGISTRY); var registries = createProvider(registryAccess); - pack.addProvider(bindRegistries((output, provider) -> new FixedGTRegistriesDatapackGenerator( + pack.addProvider(bindRegistries((output, provider) -> new GTRegistriesDatapackGenerator( output, registries, new RegistrySetBuilder() .add(Registries.BIOME, GCySBiomes::bootstrap), set, "Worldgen Data"), registries)); diff --git a/fabric/src/main/java/argent_matter/gcys/fabric/GCySFabric.java b/fabric/src/main/java/argent_matter/gcys/fabric/GCySFabric.java index 9e3bf4fd..3c59abe0 100644 --- a/fabric/src/main/java/argent_matter/gcys/fabric/GCySFabric.java +++ b/fabric/src/main/java/argent_matter/gcys/fabric/GCySFabric.java @@ -39,12 +39,9 @@ public void onInitialize() { // register satellite ticking - ServerTickEvents.START_WORLD_TICK.register((serverLevel) -> { - if (!serverLevel.dimensionType().hasCeiling()) { - var sat = GcysCapabilityHelper.getSatellites(serverLevel); - if (sat != null) sat.tickSatellites(); - } - }); + ServerTickEvents.START_WORLD_TICK.register((serverLevel) -> GCyS.onLevelTick(serverLevel, true)); + + ServerTickEvents.END_WORLD_TICK.register((serverLevel) -> GCyS.onLevelTick(serverLevel, false)); ResourceManagerHelper.get(PackType.SERVER_DATA).registerReloadListener(new IdentifiableResourceReloadListener() { private final PlanetData data = new PlanetData(); @@ -61,7 +58,7 @@ public CompletableFuture reload(PreparationBarrier preparationBarrier, Res ServerEntityWorldChangeEvents.AFTER_PLAYER_CHANGE_WORLD.register((player, origin, destination) -> { IDysonSystem system = GcysCapabilityHelper.getDysonSystem(player.serverLevel(), player.getOnPos()); - if (system != null && system.isDysonSphereActive()) { + if (system != null && system.isDysonSphereActive() && !system.activeDysonSphere().isCollapsed()) { GCySNetworking.NETWORK.sendToPlayer(new PacketSyncDysonSphereStatus(true), player); } else { GCySNetworking.NETWORK.sendToPlayer(new PacketSyncDysonSphereStatus(false), player); @@ -71,7 +68,7 @@ public CompletableFuture reload(PreparationBarrier preparationBarrier, Res ServerEntityEvents.ENTITY_LOAD.register((entity, world) -> { if (entity instanceof ServerPlayer player) { IDysonSystem system = GcysCapabilityHelper.getDysonSystem(player.serverLevel(), player.getOnPos()); - if (system != null && system.isDysonSphereActive()) { + if (system != null && system.isDysonSphereActive() && !system.activeDysonSphere().isCollapsed()) { GCySNetworking.NETWORK.sendToPlayer(new PacketSyncDysonSphereStatus(true), player); } else { GCySNetworking.NETWORK.sendToPlayer(new PacketSyncDysonSphereStatus(false), player); diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index 8d3001f7..b866ef58 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -32,7 +32,7 @@ ], "depends": { "fabricloader": ">=0.14.21", - "minecraft": ">=1.20", - "gtceu": ">=1.0.13.b" + "minecraft": ">=1.20.1", + "gtceu": "*" } } diff --git a/forge/src/generated/resources/assets/gcys/lang/en_ud.json b/forge/src/generated/resources/assets/gcys/lang/en_ud.json index ca41cdca..f76fb95f 100644 --- a/forge/src/generated/resources/assets/gcys/lang/en_ud.json +++ b/forge/src/generated/resources/assets/gcys/lang/en_ud.json @@ -19,7 +19,6 @@ "block.gcys.seat": "ʇɐǝS", "block.gcys.space_elevator": "ɹoʇɐʌǝןƎ ǝɔɐdS", "block.gcys.space_elevator_support": "ʇɹoddnS ɹoʇɐʌǝןƎ ǝɔɐdS", - "block.gcys.space_shuttle": "ǝןʇʇnɥS ǝɔɐdS", "block.gcys.uhv_oxygen_spreader": "ɹǝpɐǝɹdS uǝbʎxO ʌɥ∩", "block.gcys.uv_oxygen_spreader": "ɹǝpɐǝɹdS uǝbʎxO ʌ∩", "block.gcys.zpm_oxygen_spreader": "ɹǝpɐǝɹdS uǝbʎxO ɯdZ", @@ -56,6 +55,10 @@ "menu.gcys.back": "ʞɔɐᗺ", "menu.gcys.catalog": "boןɐʇɐƆ", "menu.gcys.category": "ʎɹobǝʇɐƆ", + "menu.gcys.dyson_sphere.collapsed": "ᗡƎSԀⱯꞀꞀOƆ ƎᴚƎHԀS NOSʎᗡ", + "menu.gcys.dyson_sphere.implosion_chance": "%%ɟᄅ˙% :uoısoןdɯı ɟo ǝɔuɐɥƆ", + "menu.gcys.dyson_sphere.needs_maintenance": "ƎƆNⱯNƎ⟘NIⱯW SƎᴚI∩ὉƎᴚ ƎᴚƎHԀS NOSʎᗡ", + "menu.gcys.dyson_sphere.time_since_needed_maintenance": "spuoɔǝs %s :ǝɔuɐuǝʇuıɐɯ ʇsɐן ǝɔuıs ǝɯı⟘", "menu.gcys.galaxy": "ʎxɐןɐ⅁", "menu.gcys.gravity": "ʎʇıʌɐɹ⅁", "menu.gcys.launch": "HƆN∩ⱯꞀ", diff --git a/forge/src/generated/resources/assets/gcys/lang/en_us.json b/forge/src/generated/resources/assets/gcys/lang/en_us.json index 1821cc61..71812528 100644 --- a/forge/src/generated/resources/assets/gcys/lang/en_us.json +++ b/forge/src/generated/resources/assets/gcys/lang/en_us.json @@ -19,7 +19,6 @@ "block.gcys.seat": "Seat", "block.gcys.space_elevator": "Space Elevator", "block.gcys.space_elevator_support": "Space Elevator Support", - "block.gcys.space_shuttle": "Space Shuttle", "block.gcys.uhv_oxygen_spreader": "Uhv Oxygen Spreader", "block.gcys.uv_oxygen_spreader": "Uv Oxygen Spreader", "block.gcys.zpm_oxygen_spreader": "Zpm Oxygen Spreader", @@ -56,6 +55,10 @@ "menu.gcys.back": "Back", "menu.gcys.catalog": "Catalog", "menu.gcys.category": "Category", + "menu.gcys.dyson_sphere.collapsed": "DYSON SPHERE COLLAPSED", + "menu.gcys.dyson_sphere.implosion_chance": "Chance of implosion: %.2f%%", + "menu.gcys.dyson_sphere.needs_maintenance": "DYSON SPHERE REQUIRES MAINTENANCE", + "menu.gcys.dyson_sphere.time_since_needed_maintenance": "Time since last maintenance: %s seconds", "menu.gcys.galaxy": "Galaxy", "menu.gcys.gravity": "Gravity", "menu.gcys.launch": "LAUNCH", diff --git a/forge/src/main/java/argent_matter/gcys/common/data/forge/GCySKeyMappingsImpl.java b/forge/src/main/java/argent_matter/gcys/common/data/forge/GCySKeyMappingsImpl.java index 4999b89f..ccc56368 100644 --- a/forge/src/main/java/argent_matter/gcys/common/data/forge/GCySKeyMappingsImpl.java +++ b/forge/src/main/java/argent_matter/gcys/common/data/forge/GCySKeyMappingsImpl.java @@ -13,7 +13,7 @@ public static void initPlatform() { } - @SubscribeEvent + //@SubscribeEvent public static void event(RegisterKeyMappingsEvent event) { event.register(GCySKeyMappings.START_ROCKET); } diff --git a/forge/src/main/java/argent_matter/gcys/data/forge/DataGenerators.java b/forge/src/main/java/argent_matter/gcys/data/forge/DataGenerators.java index 6627d99f..3b8c1f5a 100644 --- a/forge/src/main/java/argent_matter/gcys/data/forge/DataGenerators.java +++ b/forge/src/main/java/argent_matter/gcys/data/forge/DataGenerators.java @@ -1,8 +1,8 @@ package argent_matter.gcys.data.forge; import argent_matter.gcys.GCyS; -import argent_matter.gcys.api.registries.registrate.GcysSoundEntryProvider; import argent_matter.gcys.common.data.GCySBiomes; +import com.gregtechceu.gtceu.api.registry.registrate.SoundEntryBuilder; import com.gregtechceu.gtceu.data.forge.GTRegistriesDatapackGenerator; import net.minecraft.Util; import net.minecraft.core.HolderLookup; @@ -34,7 +34,7 @@ public static void gatherData(GatherDataEvent event) { var registries = createProvider(registryAccess); if (event.includeServer()) { var set = Set.of(GCyS.MOD_ID); - generator.addProvider(true, new GcysSoundEntryProvider(generator.getPackOutput())); + generator.addProvider(true, new SoundEntryBuilder.SoundEntryProvider(generator.getPackOutput(), GCyS.MOD_ID)); generator.addProvider(true, bindRegistries((output, provider) -> new GTRegistriesDatapackGenerator( output, registries, new RegistrySetBuilder() .add(Registries.BIOME, GCySBiomes::bootstrap), diff --git a/forge/src/main/java/argent_matter/gcys/forge/ForgeCommonEventListener.java b/forge/src/main/java/argent_matter/gcys/forge/ForgeCommonEventListener.java index 8cb6560b..f1c7a0ed 100644 --- a/forge/src/main/java/argent_matter/gcys/forge/ForgeCommonEventListener.java +++ b/forge/src/main/java/argent_matter/gcys/forge/ForgeCommonEventListener.java @@ -16,6 +16,7 @@ import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.event.AddReloadListenerEvent; import net.minecraftforge.event.AttachCapabilitiesEvent; +import net.minecraftforge.event.TickEvent; import net.minecraftforge.event.entity.EntityJoinLevelEvent; import net.minecraftforge.event.entity.player.PlayerEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; @@ -28,7 +29,6 @@ public class ForgeCommonEventListener { @SubscribeEvent public static void registerItemStackCapabilities(AttachCapabilitiesEvent event) { - if (event.getObject().getItem() instanceof SpaceSuitArmorItemImpl spaceSuitItem) { final ItemStack itemStack = event.getObject(); event.addCapability(GCyS.id("fluid"), new ICapabilityProvider() { @@ -54,7 +54,7 @@ public static void registerServerReloadListeners(AddReloadListenerEvent event) { public static void playerChangedDimension(PlayerEvent.PlayerChangedDimensionEvent event) { if (event.getEntity() instanceof ServerPlayer player) { IDysonSystem system = GcysCapabilityHelper.getDysonSystem(player.serverLevel(), player.getOnPos()); - if (system != null && system.isDysonSphereActive()) { + if (system != null && system.isDysonSphereActive() && !system.activeDysonSphere().isCollapsed()) { GCySNetworking.NETWORK.sendToPlayer(new PacketSyncDysonSphereStatus(true), player); } else { GCySNetworking.NETWORK.sendToPlayer(new PacketSyncDysonSphereStatus(false), player); @@ -66,11 +66,16 @@ public static void playerChangedDimension(PlayerEvent.PlayerChangedDimensionEven public static void entityJoined(EntityJoinLevelEvent event) { if (event.getEntity() instanceof ServerPlayer player) { IDysonSystem system = GcysCapabilityHelper.getDysonSystem(player.serverLevel(), player.getOnPos()); - if (system != null && system.isDysonSphereActive()) { + if (system != null && system.isDysonSphereActive() && !system.activeDysonSphere().isCollapsed()) { GCySNetworking.NETWORK.sendToPlayer(new PacketSyncDysonSphereStatus(true), player); } else { GCySNetworking.NETWORK.sendToPlayer(new PacketSyncDysonSphereStatus(false), player); } } } + + @SubscribeEvent + public static void levelTick(TickEvent.LevelTickEvent event) { + GCyS.onLevelTick(event.level, event.phase == TickEvent.Phase.START); + } } diff --git a/forge/src/main/java/argent_matter/gcys/forge/GCySForgeEventClient.java b/forge/src/main/java/argent_matter/gcys/forge/GCySForgeClientEvents.java similarity index 94% rename from forge/src/main/java/argent_matter/gcys/forge/GCySForgeEventClient.java rename to forge/src/main/java/argent_matter/gcys/forge/GCySForgeClientEvents.java index 6c479594..35413dd8 100644 --- a/forge/src/main/java/argent_matter/gcys/forge/GCySForgeEventClient.java +++ b/forge/src/main/java/argent_matter/gcys/forge/GCySForgeClientEvents.java @@ -9,7 +9,7 @@ @SuppressWarnings("unused") @Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD, modid = GCyS.MOD_ID, value = Dist.CLIENT) -public class GCySForgeEventClient { +public class GCySForgeClientEvents { @SubscribeEvent public static void registerParticles(RegisterParticleProvidersEvent event) { diff --git a/forge/src/main/resources/META-INF/mods.toml b/forge/src/main/resources/META-INF/mods.toml index 9238e1fd..0d475952 100644 --- a/forge/src/main/resources/META-INF/mods.toml +++ b/forge/src/main/resources/META-INF/mods.toml @@ -67,6 +67,6 @@ issueTrackerURL="https://github.com/argent-matter/gcys/issues" [[dependencies.gcys]] modId="gtceu" mandatory=true - versionRange="[1.0.13.b,)" + versionRange="[1.0.13.c,)" ordering="AFTER" side="BOTH" \ No newline at end of file diff --git a/settings.gradle b/settings.gradle index 1562ad4b..2f221508 100644 --- a/settings.gradle +++ b/settings.gradle @@ -41,7 +41,7 @@ dependencyResolutionManagement { def vineFlowerVersion = "1.+" def macheteVersion = "1.+" def configurationVersion = "2.2.0" - def gtCeuVersion = "1.0.13.b" + def gtCeuVersion = "1.0.13.c" def ldLibVersion = "1.0.19.d" def mixinExtrasVersion = "0.2.0-rc.5"