diff --git a/CHANGELOG.md b/CHANGELOG.md index ca8250b1..2f13411d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,16 +1,3 @@ - -0.0.2.b: -- fix Dyson Sphere Casing recipe -- fix lang issues -- add Atomic Casing recipe -- fix dyson crash on fabric - -0.0.2.a: -- fix fabric -- make dyson sphere able to collapse if left without maintenance -- add dyson sphere maintenance logic -- remove rocket launch keybind - - -0.0.2: -- initial release \ No newline at end of file +- make space stations use different dimensions per planet orbit +- remove "orbit" button from planet selection screen, it did nothing +- \ No newline at end of file diff --git a/common/src/main/java/argent_matter/gcys/GCyS.java b/common/src/main/java/argent_matter/gcys/GCyS.java index 35feef1f..6b184c35 100644 --- a/common/src/main/java/argent_matter/gcys/GCyS.java +++ b/common/src/main/java/argent_matter/gcys/GCyS.java @@ -72,7 +72,7 @@ public static void onLevelTick(Level ticked, boolean isStart) { if (sat != null) sat.tickSatellites(); } - IDysonSystem system = DysonSystemSavedData.getOrCreate(level); + IDysonSystem system = GcysCapabilityHelper.getDysonSystem(level); if (system == null || TICKED_SYSTEMS.get().contains(system)) return; system.tick(); } else { diff --git a/common/src/main/java/argent_matter/gcys/api/capability/GcysCapabilityHelper.java b/common/src/main/java/argent_matter/gcys/api/capability/GcysCapabilityHelper.java index 974bfb4a..66189bca 100644 --- a/common/src/main/java/argent_matter/gcys/api/capability/GcysCapabilityHelper.java +++ b/common/src/main/java/argent_matter/gcys/api/capability/GcysCapabilityHelper.java @@ -3,14 +3,13 @@ import argent_matter.gcys.api.space.dyson.DysonSystemSavedData; import argent_matter.gcys.api.space.satellite.capability.SatelliteWorldSavedData; import argent_matter.gcys.api.space.station.StationWorldSavedData; -import net.minecraft.core.BlockPos; import net.minecraft.server.level.ServerLevel; import javax.annotation.Nullable; public class GcysCapabilityHelper { @Nullable - public static ISpaceStationHolder getSpaceStations(ServerLevel level) { + public static ISpaceStationHolder getSpaceStations(@Nullable ServerLevel level) { return StationWorldSavedData.getOrCreate(level); } @@ -20,7 +19,7 @@ public static ISatelliteHolder getSatellites(ServerLevel level) { } @Nullable - public static IDysonSystem getDysonSystem(ServerLevel level, @Nullable BlockPos pos) { - return DysonSystemSavedData.getOrCreateMaybeSpace(level, pos); + public static IDysonSystem getDysonSystem(ServerLevel level) { + return DysonSystemSavedData.getOrCreate(level); } } diff --git a/common/src/main/java/argent_matter/gcys/api/capability/ISpaceStationHolder.java b/common/src/main/java/argent_matter/gcys/api/capability/ISpaceStationHolder.java index 620c3bb3..59b8149f 100644 --- a/common/src/main/java/argent_matter/gcys/api/capability/ISpaceStationHolder.java +++ b/common/src/main/java/argent_matter/gcys/api/capability/ISpaceStationHolder.java @@ -23,11 +23,6 @@ public interface ISpaceStationHolder { */ Int2ObjectMap getStations(); - /** - * @return all space stations orbiting this planet. - */ - Set getStationsForPlanet(Planet planet); - /** * @param position the position from which distance is measured from * @return the closest satellite to this position, or null if none 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 7135310a..3af20a57 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 @@ -1,11 +1,8 @@ package argent_matter.gcys.api.space.dyson; import argent_matter.gcys.GCyS; -import argent_matter.gcys.api.capability.GcysCapabilityHelper; import argent_matter.gcys.api.capability.IDysonSystem; -import argent_matter.gcys.api.capability.ISpaceStationHolder; import argent_matter.gcys.api.space.planet.Planet; -import argent_matter.gcys.common.data.GCySDimensionTypes; import argent_matter.gcys.common.data.GCySNetworking; import argent_matter.gcys.common.data.GCySSatellites; import argent_matter.gcys.common.networking.s2c.PacketSyncDysonSphereStatus; @@ -15,9 +12,11 @@ import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; import net.minecraft.MethodsReturnNonnullByDefault; import net.minecraft.core.BlockPos; -import net.minecraft.nbt.*; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.ListTag; +import net.minecraft.nbt.NbtOps; +import net.minecraft.nbt.Tag; import net.minecraft.resources.ResourceLocation; -import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.level.saveddata.SavedData; @@ -33,10 +32,9 @@ public class DysonSystemSavedData extends SavedData implements IDysonSystem { public static DysonSystemSavedData getOrCreate(ServerLevel originLevel) { if (originLevel.dimensionType().hasCeiling()) return null; - Planet planet = PlanetData.getPlanetFromLevel(originLevel.dimension()).orElse(null); - if (planet == null) return null; // A planet definition is required. + ResourceLocation solarSystem = PlanetData.getPlanetFromLevelOrOrbit(originLevel.dimension()).map(Planet::solarSystem).orElse(null); + if (solarSystem == null) return null; // A planet definition is required. - ResourceLocation solarSystem = planet.solarSystem(); List planets = PlanetData.getSolarSystemPlanets(solarSystem); if (planets.isEmpty()) { internalGetOrCreate(originLevel); @@ -45,28 +43,6 @@ public static DysonSystemSavedData getOrCreate(ServerLevel originLevel) { return internalGetOrCreate(Objects.requireNonNullElse(firstWorldLevel, originLevel)); } - @Nullable - public static DysonSystemSavedData getOrCreateMaybeSpace(ServerLevel level, @Nullable BlockPos pos) { - if (pos != null && level.dimension().location().equals(GCySDimensionTypes.SPACE_LEVEL.location())) { - ISpaceStationHolder spaceStations = GcysCapabilityHelper.getSpaceStations(level); - if (spaceStations == null) return null; - List nearbyStationIds = spaceStations.getStationsNearWorldPos(pos, 8 * 8 /*half of max station size*/); - if (nearbyStationIds.isEmpty()) return null; - return getOrCreateForSpace(level.getServer(), nearbyStationIds.get(0)); - } - return getOrCreate(level); - } - - @Nullable - public static DysonSystemSavedData getOrCreateForSpace(MinecraftServer server, int stationId) { - ISpaceStationHolder spaceStations = GcysCapabilityHelper.getSpaceStations(server.getLevel(GCySDimensionTypes.SPACE_LEVEL)); - if (spaceStations == null) return null; - - ServerLevel serverLevel = server.getLevel(spaceStations.getStation(stationId).orbitPlanet().level()); - if (serverLevel == null) return null; - return getOrCreate(serverLevel); - } - private static DysonSystemSavedData internalGetOrCreate(ServerLevel serverLevel) { return serverLevel.getDataStorage().computeIfAbsent(tag -> new DysonSystemSavedData(serverLevel, tag), () -> new DysonSystemSavedData(serverLevel), GCyS.MOD_ID + "_dyson_systems"); } @@ -99,7 +75,7 @@ public boolean isDysonSphereActive() { @Override public int activeDysonSwarmSatelliteCount() { - return (int) swarmSatellites.values().stream().flatMap(Collection::stream).count(); + return swarmSatellites.values().stream().mapToInt(Collection::size).sum(); } @Override diff --git a/common/src/main/java/argent_matter/gcys/api/space/station/StationWorldSavedData.java b/common/src/main/java/argent_matter/gcys/api/space/station/StationWorldSavedData.java index 6f853d4f..00892518 100644 --- a/common/src/main/java/argent_matter/gcys/api/space/station/StationWorldSavedData.java +++ b/common/src/main/java/argent_matter/gcys/api/space/station/StationWorldSavedData.java @@ -2,9 +2,8 @@ import argent_matter.gcys.GCyS; import argent_matter.gcys.api.capability.ISpaceStationHolder; -import argent_matter.gcys.api.space.planet.Planet; -import argent_matter.gcys.common.data.GCySDimensionTypes; import argent_matter.gcys.common.worldgen.SpaceLevelSource; +import argent_matter.gcys.data.loader.PlanetData; import argent_matter.gcys.util.Vec2i; import it.unimi.dsi.fastutil.ints.Int2ObjectLinkedOpenHashMap; import it.unimi.dsi.fastutil.ints.Int2ObjectMap; @@ -20,15 +19,14 @@ import javax.annotation.ParametersAreNonnullByDefault; import java.util.Comparator; import java.util.List; -import java.util.Set; import java.util.stream.Collectors; @MethodsReturnNonnullByDefault @ParametersAreNonnullByDefault public class StationWorldSavedData extends SavedData implements ISpaceStationHolder { @Nullable - public static StationWorldSavedData getOrCreate(ServerLevel serverLevel) { - if (serverLevel.dimension() != GCySDimensionTypes.SPACE_LEVEL) return null; + public static StationWorldSavedData getOrCreate(@Nullable ServerLevel serverLevel) { + if (serverLevel == null || !PlanetData.isOrbitLevel(serverLevel.dimension())) return null; return serverLevel.getDataStorage().computeIfAbsent(tag -> new StationWorldSavedData(serverLevel, tag), () -> new StationWorldSavedData(serverLevel), GCyS.MOD_ID + "_space_stations"); } @@ -55,11 +53,6 @@ public Int2ObjectMap getStations() { return stations; } - @Override - public Set getStationsForPlanet(Planet planet) { - return stations.values().stream().filter(spaceStation -> spaceStation.orbitPlanet().equals(planet)).collect(Collectors.toSet()); - } - @Override public int getClosestStationId(Vec2i position) { var result = stations.int2ObjectEntrySet().stream().min(Comparator.comparingDouble(obj -> obj.getValue().position().distanceToSqr(position))).orElse(null); diff --git a/common/src/main/java/argent_matter/gcys/client/gui/screen/PlanetSelectionScreen.java b/common/src/main/java/argent_matter/gcys/client/gui/screen/PlanetSelectionScreen.java index 4a8420d9..f70eccef 100644 --- a/common/src/main/java/argent_matter/gcys/client/gui/screen/PlanetSelectionScreen.java +++ b/common/src/main/java/argent_matter/gcys/client/gui/screen/PlanetSelectionScreen.java @@ -36,11 +36,13 @@ import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.level.Level; +import javax.annotation.ParametersAreNonnullByDefault; import java.util.*; import java.util.function.Consumer; @Environment(EnvType.CLIENT) @MethodsReturnNonnullByDefault +@ParametersAreNonnullByDefault public class PlanetSelectionScreen extends Screen implements MenuAccess { public static final ResourceLocation SMALL_MENU_LIST = GCyS.id("textures/gui/selection_menu.png"); @@ -87,7 +89,6 @@ public PlanetSelectionScreen(PlanetSelectionMenu handler, Inventory inventory, C } // Set the initial gui time to the level time. This creates a random start position for each rotating object. - //noinspection resource guiTime = handler.getPlayer().level().getRandom().nextFloat() * 100000.0f; } @@ -219,8 +220,7 @@ protected void init() { } createTeleportButton(1, label, planetCategory, planet.buttonColor(), 71, 20, TooltipType.PLANET, planet, planet.level()); - createTeleportButton(2, ORBIT_TEXT, planetCategory, planet.buttonColor(), 37, 20, TooltipType.ORBIT, null, planet.orbitWorld()); - createSpaceStationTeleportButton(3, SPACE_STATION_TEXT, planetCategory, planet.buttonColor(), 71, 20, planet.level()); + createSpaceStationTeleportButton(2, SPACE_STATION_TEXT, planetCategory, planet.buttonColor(), 71, 20, planet.orbitWorld()); }); this.galaxyCategories.forEach((this::createGalaxyButton)); @@ -285,7 +285,7 @@ public void createTeleportButton(int row, Component label, Category category, in LinkedList buttons = this.categoryButtons.getOrDefault(category, new LinkedList<>()); int column = getColumn(category) - (row - 1) * 22; - column -= 44 * (buttons.size() / 3); + column -= 22 * (buttons.size() / 2); createButton(newRow + 10, column, label, category, colour, sizeX, sizeY, tooltip, planetInfo, onClick); } diff --git a/common/src/main/java/argent_matter/gcys/common/data/GCySDimensionTypes.java b/common/src/main/java/argent_matter/gcys/common/data/GCySDimensionTypes.java index b1ef45d2..92929e66 100644 --- a/common/src/main/java/argent_matter/gcys/common/data/GCySDimensionTypes.java +++ b/common/src/main/java/argent_matter/gcys/common/data/GCySDimensionTypes.java @@ -4,12 +4,10 @@ import dev.architectury.injectables.annotations.ExpectPlatform; import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceKey; -import net.minecraft.world.level.Level; import net.minecraft.world.level.dimension.DimensionType; public class GCySDimensionTypes { - public static final ResourceKey SPACE_DIMENSION = ResourceKey.create(Registries.DIMENSION_TYPE, GCyS.id("space")); - public static final ResourceKey SPACE_LEVEL = ResourceKey.create(Registries.DIMENSION, GCyS.id("space")); + public static final ResourceKey SPACE_TYPE = ResourceKey.create(Registries.DIMENSION_TYPE, GCyS.id("space")); public static void init() { initGenerator(); diff --git a/common/src/main/java/argent_matter/gcys/common/data/GCySRecipeConditions.java b/common/src/main/java/argent_matter/gcys/common/data/GCySRecipeConditions.java index 00262b29..ff4881c7 100644 --- a/common/src/main/java/argent_matter/gcys/common/data/GCySRecipeConditions.java +++ b/common/src/main/java/argent_matter/gcys/common/data/GCySRecipeConditions.java @@ -1,11 +1,13 @@ package argent_matter.gcys.common.data; import argent_matter.gcys.common.recipe.DysonSphereCondition; +import argent_matter.gcys.common.recipe.OrbitCondition; import com.gregtechceu.gtceu.api.registry.GTRegistries; public class GCySRecipeConditions { public static void init() { GTRegistries.RECIPE_CONDITIONS.register(DysonSphereCondition.INSTANCE.getType(), DysonSphereCondition.class); + GTRegistries.RECIPE_CONDITIONS.register(OrbitCondition.INSTANCE.getType(), OrbitCondition.class); } } diff --git a/common/src/main/java/argent_matter/gcys/common/entity/RocketEntity.java b/common/src/main/java/argent_matter/gcys/common/entity/RocketEntity.java index bf0fc04f..88ee1d14 100644 --- a/common/src/main/java/argent_matter/gcys/common/entity/RocketEntity.java +++ b/common/src/main/java/argent_matter/gcys/common/entity/RocketEntity.java @@ -70,6 +70,7 @@ import java.util.List; import java.util.Set; +@SuppressWarnings("resource") @MethodsReturnNonnullByDefault @ParametersAreNonnullByDefault public class RocketEntity extends Entity implements HasCustomInventoryScreen, IUIHolder { @@ -414,12 +415,8 @@ private void goToDestination() { } else if (GCySItems.KEYCARD.isIn(configStack) && KeyCardBehaviour.getSavedStation(configStack) != SpaceStation.ID_EMPTY) { this.destinationIsSpaceStation = true; } - final ServerLevel destinationLevel; - if (this.destinationIsSpaceStation) { - destinationLevel = this.getServer().getLevel(GCySDimensionTypes.SPACE_LEVEL); - } else { - destinationLevel = this.getServer().getLevel(destination.level()); - } + final ServerLevel destinationLevel = this.getServer().getLevel(this.destinationIsSpaceStation ? destination.orbitWorld() : destination.level()); + Vec3 pos = this.position(); @@ -652,13 +649,6 @@ protected void readAdditionalSaveData(CompoundTag compound) { for (int i = 0; i < blocks.size(); ++i) { this.addBlock(PosWithState.readFromTag(blocks.getCompound(i))); } - /* - this.getSeatPositions().clear(); - ListTag seats = compound.getList("seats", Tag.TAG_COMPOUND); - for (int i = 0; i < seats.size(); ++i) { - this.addSeatPos(NbtUtils.readBlockPos(seats.getCompound(i))); - } - */ this.setFuelCapacity(compound.getLong("fuelCapacity")); this.fuelTank.setFluid(FluidStack.loadFromTag(compound.getCompound("fuel"))); @@ -677,14 +667,6 @@ protected void addAdditionalSaveData(CompoundTag compound) { for (PosWithState state : blocks) { blockTag.add(state.writeToTag()); } - /* - var seats = this.getSeatPositions(); - ListTag seatsTag = new ListTag(); - compound.put("seat", seatsTag); - for (BlockPos seatPos : seats) { - seatsTag.add(NbtUtils.writeBlockPos(seatPos)); - } - */ compound.putLong("fuelCapacity", this.getFuelCapacity()); CompoundTag fuel = new CompoundTag(); diff --git a/common/src/main/java/argent_matter/gcys/common/item/PlanetIdChipBehaviour.java b/common/src/main/java/argent_matter/gcys/common/item/PlanetIdChipBehaviour.java index bc145135..fc5bef33 100644 --- a/common/src/main/java/argent_matter/gcys/common/item/PlanetIdChipBehaviour.java +++ b/common/src/main/java/argent_matter/gcys/common/item/PlanetIdChipBehaviour.java @@ -5,11 +5,8 @@ import argent_matter.gcys.common.data.GCySItems; import argent_matter.gcys.common.data.GCySMenus; import argent_matter.gcys.data.loader.PlanetData; -import com.google.common.collect.BiMap; -import com.google.common.collect.HashBiMap; import com.gregtechceu.gtceu.api.item.component.IAddInformation; import com.gregtechceu.gtceu.api.item.component.IInteractionItem; -import net.minecraft.core.Registry; import net.minecraft.core.registries.Registries; import net.minecraft.nbt.Tag; import net.minecraft.network.chat.Component; @@ -28,8 +25,6 @@ import java.util.List; public class PlanetIdChipBehaviour implements IInteractionItem, IAddInformation { - private static final BiMap PLANET_NAME_CACHE = HashBiMap.create(); - public static final String CURRENT_STATION_TAG_ID = "gcys:current_station"; public static final String CURRENT_PLANET_TAG_ID = "gcys:current_planet"; @@ -54,18 +49,12 @@ public static int getSpaceStationId(ItemStack held) { } public String getPlanetName(Planet currentTarget) { - return PLANET_NAME_CACHE.inverse().computeIfAbsent(currentTarget, planet -> PlanetData.getLevelFromPlanet(planet).map(level -> "level." + level.location().toLanguageKey()).orElse("UNKNOWN LEVEL")); - } - - public static void setPlanetFromName(String planetName, ItemStack held) { - if (!GCySItems.ID_CHIP.isIn(held)) return; - Planet currentTarget = PLANET_NAME_CACHE.computeIfAbsent(planetName, (name) -> PlanetData.getPlanetFromLevel(ResourceKey.create(Registries.DIMENSION, ResourceLocation.of(name.substring(6), '.'))).orElse(null)); - held.getOrCreateTag().putString(CURRENT_PLANET_TAG_ID, currentTarget.level().location().toString()); + return currentTarget.translation(); } @Nullable public static Planet getPlanetFromStack(ItemStack stack) { - return PlanetData.getPlanetFromLevel(ResourceKey.create(Registries.DIMENSION, new ResourceLocation(stack.getOrCreateTag().getString(CURRENT_PLANET_TAG_ID)))).orElse(null); + return PlanetData.getPlanetFromLevelOrOrbit(ResourceKey.create(Registries.DIMENSION, new ResourceLocation(stack.getOrCreateTag().getString(CURRENT_PLANET_TAG_ID)))).orElse(null); } @Override diff --git a/common/src/main/java/argent_matter/gcys/common/machine/multiblock/RocketScannerMachine.java b/common/src/main/java/argent_matter/gcys/common/machine/multiblock/RocketScannerMachine.java index 5e5dffcd..b8c521db 100644 --- a/common/src/main/java/argent_matter/gcys/common/machine/multiblock/RocketScannerMachine.java +++ b/common/src/main/java/argent_matter/gcys/common/machine/multiblock/RocketScannerMachine.java @@ -8,6 +8,7 @@ import argent_matter.gcys.common.item.KeyCardBehaviour; import argent_matter.gcys.common.item.PlanetIdChipBehaviour; import com.gregtechceu.gtceu.api.data.tag.TagPrefix; +import com.gregtechceu.gtceu.api.gui.GuiTextures; import com.gregtechceu.gtceu.api.machine.IMachineBlockEntity; import com.gregtechceu.gtceu.api.machine.feature.multiblock.IDisplayUIMachine; import com.gregtechceu.gtceu.api.machine.multiblock.MultiblockControllerMachine; @@ -73,11 +74,9 @@ public RocketScannerMachine(IMachineBlockEntity holder) { super(holder); this.configSaveSlot = new ItemStackTransfer(1); this.configSaveSlot.setFilter(GCySItems.ID_CHIP::isIn); - this.configSaveSlot.setOnContentsChanged(this::onSaveSlotChanged); this.configLoadSlot = new ItemStackTransfer(1); this.configLoadSlot.setFilter(GCySItems.KEYCARD::isIn); - this.configLoadSlot.setOnContentsChanged(this::onLoadSlotChanged); } @Override @@ -85,7 +84,7 @@ public ModularUI createUI(Player entityPlayer) { ModularUI modularUI = IDisplayUIMachine.super.createUI(entityPlayer); modularUI.widget(new SlotWidget(configSaveSlot, 0, 149, 83)); modularUI.widget(new SlotWidget(configLoadSlot, 0, 149, 105)); - modularUI.widget(new ButtonWidget(129, 105, 18, 18, this::onSaveButtonClick).setHoverTooltips(Component.translatable("menu.gcys.save_destination_station"))); + modularUI.widget(new ButtonWidget(129, 83, 18, 18, this::onSaveButtonClick).setButtonTexture(GuiTextures.BUTTON).setHoverTooltips(Component.translatable("menu.gcys.save_destination_station"))); return modularUI; } 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 1226a719..e658951b 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 @@ -10,7 +10,6 @@ import com.gregtechceu.gtceu.api.recipe.GTRecipe; import com.gregtechceu.gtceu.common.data.GTDamageTypes; import com.lowdragmc.lowdraglib.gui.util.ClickData; -import com.lowdragmc.lowdraglib.gui.widget.ComponentPanelWidget; import net.minecraft.ChatFormatting; import net.minecraft.MethodsReturnNonnullByDefault; import net.minecraft.core.BlockPos; @@ -39,7 +38,7 @@ public DysonSystemControllerMachine(IMachineBlockEntity holder, Object... args) public void onStructureInvalid() { super.onStructureInvalid(); if (!isRemote()) { - IDysonSystem system = GcysCapabilityHelper.getDysonSystem((ServerLevel) this.getLevel(), this.getPos()); + IDysonSystem system = GcysCapabilityHelper.getDysonSystem((ServerLevel) this.getLevel()); if (system == null || !system.isDysonSphereActive()) return; system.activeDysonSphere().setControllerPos(null); } @@ -49,7 +48,7 @@ public void onStructureInvalid() { public void onStructureFormed() { super.onStructureFormed(); if (!isRemote()) { - IDysonSystem system = GcysCapabilityHelper.getDysonSystem((ServerLevel) this.getLevel(), this.getPos()); + IDysonSystem system = GcysCapabilityHelper.getDysonSystem((ServerLevel) this.getLevel()); if (system == null) return; if (system.isDysonSphereActive() && system.activeDysonSphere().getControllerPos() == null) { system.activeDysonSphere().setControllerPos(this.getPos()); @@ -63,7 +62,7 @@ public void onStructureFormed() { protected @Nullable GTRecipe getRealRecipe(GTRecipe recipe) { if (this.getLevel().dimensionType().hasCeiling()) return null; if (recipe.data.contains("gcys:repair_dyson_sphere")) { - IDysonSystem system = GcysCapabilityHelper.getDysonSystem((ServerLevel) this.getLevel(), this.getPos()); + IDysonSystem system = GcysCapabilityHelper.getDysonSystem((ServerLevel) this.getLevel()); if (system != null && system.isDysonSphereActive() && (!system.activeDysonSphere().isNeedsMaintenance() || !this.getPos().equals(system.activeDysonSphere().getControllerPos()))) return null; } return super.getRealRecipe(recipe); @@ -90,7 +89,7 @@ public void afterWorking() { if (recipe == null || this.isRemote()) return; 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()); + IDysonSystem system = GcysCapabilityHelper.getDysonSystem((ServerLevel) this.getLevel()); if (system == null) return; if (!system.isDysonSphereActive() && recipe.data.contains("gcys:launch_dyson_sphere")) { system.addDysonSphere(this.getPos()); @@ -111,7 +110,7 @@ public void animateTick(RandomSource random) { double x = pos.getX() + 0.5; double z = pos.getZ() + 0.5; - for (int y = pos.getY(); y < 512; y += 4) { + for (int y = pos.getY(); y < 512; y += 2) { level.addAlwaysVisibleParticle(GCySParticles.DYSON_BEAM, true, x, y, z, 0, 0, 0); } } @@ -123,7 +122,7 @@ public void addDisplayText(List textList) { if (!isFormed) return; if (!isRemote()) { - IDysonSystem system = GcysCapabilityHelper.getDysonSystem((ServerLevel) this.getLevel(), this.getPos()); + IDysonSystem system = GcysCapabilityHelper.getDysonSystem((ServerLevel) this.getLevel()); if (system == null) return; if (system.isDysonSphereActive()) { @@ -143,9 +142,9 @@ public void addDisplayText(List textList) { public void handleDisplayClick(String componentData, ClickData clickData) { if (!clickData.isRemote) { if (componentData.equals("dbg_start_sphere")) { - GcysCapabilityHelper.getDysonSystem((ServerLevel) this.getLevel(), this.getPos()).addDysonSphere(this.getPos()); + GcysCapabilityHelper.getDysonSystem((ServerLevel) this.getLevel()).addDysonSphere(this.getPos()); } else if (componentData.equals("dbg_delete_sphere")) { - GcysCapabilityHelper.getDysonSystem((ServerLevel) this.getLevel(), this.getPos()).disableDysonSphere(this.getPos()); + GcysCapabilityHelper.getDysonSystem((ServerLevel) this.getLevel()).disableDysonSphere(this.getPos()); } } } diff --git a/common/src/main/java/argent_matter/gcys/common/networking/c2s/PacketCreateSpaceStation.java b/common/src/main/java/argent_matter/gcys/common/networking/c2s/PacketCreateSpaceStation.java index 94afca8c..9f6e01c3 100644 --- a/common/src/main/java/argent_matter/gcys/common/networking/c2s/PacketCreateSpaceStation.java +++ b/common/src/main/java/argent_matter/gcys/common/networking/c2s/PacketCreateSpaceStation.java @@ -2,9 +2,10 @@ import argent_matter.gcys.api.capability.GcysCapabilityHelper; import argent_matter.gcys.api.capability.ISpaceStationHolder; -import argent_matter.gcys.common.data.GCySDimensionTypes; +import argent_matter.gcys.api.space.planet.Planet; import argent_matter.gcys.common.data.GCySItems; import argent_matter.gcys.common.item.PlanetIdChipBehaviour; +import argent_matter.gcys.data.loader.PlanetData; import com.lowdragmc.lowdraglib.networking.IHandlerContext; import com.lowdragmc.lowdraglib.networking.IPacket; import lombok.NoArgsConstructor; @@ -25,7 +26,7 @@ public void decode(FriendlyByteBuf buf) { @Override public void execute(IHandlerContext handler) { if (handler.getLevel() instanceof ServerLevel serverLevel) { - ISpaceStationHolder holder = GcysCapabilityHelper.getSpaceStations(serverLevel.getServer().getLevel(GCySDimensionTypes.SPACE_LEVEL)); + ISpaceStationHolder holder = GcysCapabilityHelper.getSpaceStations(serverLevel.getServer().getLevel(PlanetData.getPlanetFromLevelOrOrbit(serverLevel.dimension()).map(Planet::orbitWorld).orElse(null))); if (holder == null) return; ItemStack held = handler.getPlayer().getItemInHand(handler.getPlayer().getUsedItemHand()); diff --git a/common/src/main/java/argent_matter/gcys/common/networking/c2s/PacketRequestPlanetData.java b/common/src/main/java/argent_matter/gcys/common/networking/c2s/PacketRequestPlanetData.java index f3555bec..64632a50 100644 --- a/common/src/main/java/argent_matter/gcys/common/networking/c2s/PacketRequestPlanetData.java +++ b/common/src/main/java/argent_matter/gcys/common/networking/c2s/PacketRequestPlanetData.java @@ -1,5 +1,7 @@ package argent_matter.gcys.common.networking.c2s; +import argent_matter.gcys.common.data.GCySNetworking; +import argent_matter.gcys.common.networking.s2c.PacketReturnPlanetData; import com.lowdragmc.lowdraglib.networking.IHandlerContext; import com.lowdragmc.lowdraglib.networking.IPacket; import lombok.NoArgsConstructor; @@ -17,4 +19,11 @@ public void decode(FriendlyByteBuf buf) { } + @Override + public void execute(IHandlerContext handler) { + if (!handler.isClient()) { + GCySNetworking.NETWORK.sendToPlayer(new PacketReturnPlanetData(), handler.getPlayer()); + } + } + } 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 969a18af..cdc86a85 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 @@ -1,29 +1,21 @@ package argent_matter.gcys.common.recipe; +import argent_matter.gcys.GCySClient; import argent_matter.gcys.api.capability.GcysCapabilityHelper; import argent_matter.gcys.api.capability.IDysonSystem; -import com.google.gson.JsonObject; import com.gregtechceu.gtceu.api.machine.trait.RecipeLogic; import com.gregtechceu.gtceu.api.recipe.GTRecipe; import com.gregtechceu.gtceu.api.recipe.RecipeCondition; -import lombok.AllArgsConstructor; -import lombok.Getter; import lombok.NoArgsConstructor; -import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.chat.Component; import net.minecraft.server.level.ServerLevel; -import net.minecraft.util.GsonHelper; import net.minecraft.world.level.Level; import org.jetbrains.annotations.NotNull; -@AllArgsConstructor @NoArgsConstructor public class DysonSphereCondition extends RecipeCondition { public final static DysonSphereCondition INSTANCE = new DysonSphereCondition(); - @Getter - private boolean isActive = true; - @Override public String getType() { return "dyson_sphere"; @@ -31,48 +23,20 @@ public String getType() { @Override public Component getTooltips() { - return Component.translatable(isActive ? "gcys.condition.requires_dyson_sphere.true" : "gcys.condition.requires_dyson_sphere.false"); + return Component.translatable(isReverse ? "gcys.condition.requires_dyson_sphere.false" : "gcys.condition.requires_dyson_sphere.true"); } @Override 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() || !system.activeDysonSphere().isCollapsed() && !isActive) return true; - else return system.isDysonSphereActive() && !system.activeDysonSphere().isCollapsed() && isActive; + IDysonSystem system = GcysCapabilityHelper.getDysonSystem((ServerLevel) level); + if (system == null) return false; + return system.isDysonSphereActive() && !system.activeDysonSphere().isCollapsed(); } return false; } - @NotNull - @Override - public JsonObject serialize() { - JsonObject value = super.serialize(); - value.addProperty("isActive", isActive); - return value; - } - - @Override - public RecipeCondition deserialize(@NotNull JsonObject config) { - super.deserialize(config); - this.isActive = GsonHelper.getAsBoolean(config, "isActive", true); - return this; - } - - @Override - public void toNetwork(FriendlyByteBuf buf) { - super.toNetwork(buf); - buf.writeBoolean(this.isActive); - } - - @Override - public RecipeCondition fromNetwork(FriendlyByteBuf buf) { - super.fromNetwork(buf); - this.isActive = buf.readBoolean(); - return this; - } - @Override public RecipeCondition createTemplate() { return new DysonSphereCondition(); diff --git a/common/src/main/java/argent_matter/gcys/common/recipe/OrbitCondition.java b/common/src/main/java/argent_matter/gcys/common/recipe/OrbitCondition.java new file mode 100644 index 00000000..0e7550ba --- /dev/null +++ b/common/src/main/java/argent_matter/gcys/common/recipe/OrbitCondition.java @@ -0,0 +1,43 @@ +package argent_matter.gcys.common.recipe; + +import argent_matter.gcys.GCySClient; +import argent_matter.gcys.common.data.GCySNetworking; +import argent_matter.gcys.common.networking.c2s.PacketRequestPlanetData; +import argent_matter.gcys.data.loader.PlanetData; +import com.gregtechceu.gtceu.api.machine.trait.RecipeLogic; +import com.gregtechceu.gtceu.api.recipe.GTRecipe; +import com.gregtechceu.gtceu.api.recipe.RecipeCondition; +import lombok.NoArgsConstructor; +import net.minecraft.network.chat.Component; +import net.minecraft.world.level.Level; +import org.jetbrains.annotations.NotNull; + +@NoArgsConstructor +public class OrbitCondition extends RecipeCondition { + public final static OrbitCondition INSTANCE = new OrbitCondition(); + + @Override + public String getType() { + return "orbit"; + } + + @Override + public Component getTooltips() { + return Component.translatable("gcys.condition.space"); + } + + @Override + public boolean test(@NotNull GTRecipe recipe, @NotNull RecipeLogic recipeLogic) { + Level level = recipeLogic.getMachine().getLevel(); + if (level.isClientSide && !GCySClient.hasUpdatedPlanets) { + GCySNetworking.NETWORK.sendToServer(new PacketRequestPlanetData()); + GCySClient.hasUpdatedPlanets = true; + } + return PlanetData.isOrbitLevel(level.dimension()); + } + + @Override + public RecipeCondition createTemplate() { + return new OrbitCondition(); + } +} 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 b4a4fc8c..3d6c81fa 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 @@ -58,13 +58,14 @@ public static void init(RegistrateLangProvider provider) { provider.add("gcys.machine.satellite_jammer.position", "At %s"); provider.add("gcys.condition.requires_dyson_sphere.true", "Requires active Dyson Sphere"); provider.add("gcys.condition.requires_dyson_sphere.false", "Requires no Dyson Sphere to be active"); + provider.add("gcys.condition.space", "Requires machine to be in space"); // satellites provider.add("gcys.satellite.gps", "GPS Satellite"); provider.add("gcys.satellite.laser", "LASER Satellite"); provider.add("gcys.satellite.empty", "Empty Satellite"); provider.add("gcys.satellite.dyson_swarm", "Dyson Swarm Satellite"); - provider.add("behaviour.satellite.type", "Satellite Type: "); + provider.add("behaviour.satellite.type", "Satellite Type: %s"); provider.add("key.startRocket", "Start RocketEntity"); provider.add("key.categories.gcys", "Gregicality Space"); diff --git a/common/src/main/java/argent_matter/gcys/data/loader/PlanetData.java b/common/src/main/java/argent_matter/gcys/data/loader/PlanetData.java index 6d0020c9..2c78008e 100644 --- a/common/src/main/java/argent_matter/gcys/data/loader/PlanetData.java +++ b/common/src/main/java/argent_matter/gcys/data/loader/PlanetData.java @@ -3,9 +3,8 @@ import argent_matter.gcys.GCyS; import argent_matter.gcys.GCySClient; import argent_matter.gcys.api.space.planet.Planet; -import argent_matter.gcys.common.data.GCySDimensionTypes; import argent_matter.gcys.common.data.GCySNetworking; -import argent_matter.gcys.common.networking.s2c.PacketReturnPlanetData; +import argent_matter.gcys.common.networking.c2s.PacketRequestPlanetData; import argent_matter.gcys.util.GCySValues; import com.google.common.collect.BiMap; import com.google.common.collect.HashBiMap; @@ -145,6 +144,10 @@ public static Optional getPlanetFromOrbit(ResourceKey level) { return Optional.ofNullable(ORBIT_TO_PLANET.get(level)); } + public static Optional getPlanetFromLevelOrOrbit(ResourceKey level) { + return Optional.ofNullable(getPlanetFromLevel(level).orElseGet(() -> getPlanetFromOrbit(level).orElse(null))); + } + public static Optional> getLevelFromPlanet(Planet planet) { return Optional.ofNullable(LEVEL_TO_PLANET.inverse().get(planet)); } @@ -155,7 +158,7 @@ public static boolean isOrbitLevel(ResourceKey level) { public static boolean isPlanetLevel(Level level) { if (level.isClientSide && !GCySClient.hasUpdatedPlanets) { - GCySNetworking.NETWORK.sendToServer(new PacketReturnPlanetData()); + GCySNetworking.NETWORK.sendToServer(new PacketRequestPlanetData()); GCySClient.hasUpdatedPlanets = true; } return PLANET_LEVELS.contains(level.dimension()); 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 959db023..89f7b99d 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 @@ -2,10 +2,10 @@ import argent_matter.gcys.GCyS; import argent_matter.gcys.common.data.GCySBlocks; -import argent_matter.gcys.common.data.GCySDimensionTypes; import argent_matter.gcys.common.data.GCySItems; import argent_matter.gcys.common.data.GCySMaterials; import argent_matter.gcys.common.recipe.DysonSphereCondition; +import argent_matter.gcys.common.recipe.OrbitCondition; import com.gregtechceu.gtceu.api.data.tag.TagPrefix; import com.gregtechceu.gtceu.common.data.GTMachines; import com.gregtechceu.gtceu.common.data.GTMaterials; @@ -62,8 +62,8 @@ public static void init(Consumer provider) { .inputItems(GCySBlocks.CASING_DYSON_CELL.asStack(48)) .inputItems(GCySBlocks.CASING_DYSON_PORT.asStack(32)) .inputItems(GCySItems.DYSON_CONSTRUCTION_DRONE.asStack(32)) - .dimension(GCySDimensionTypes.SPACE_LEVEL.location()) - .addCondition(new DysonSphereCondition(false)) + .addCondition(new OrbitCondition()) + .addCondition(new DysonSphereCondition().setReverse(true)) .addData("gcys:launch_dyson_sphere", true) .EUt(VA[UV]).duration(32000) .save(provider); @@ -72,21 +72,21 @@ public static void init(Consumer provider) { .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)) + .addCondition(new OrbitCondition()) + .addCondition(new DysonSphereCondition()) .addData("gcys:repair_dyson_sphere", true) .EUt(VA[UV]).duration(32000) .save(provider); DYSON_ENERGY_RECIPES.recipeBuilder(GCyS.id("run_dyson_sphere_space")) - .addCondition(new DysonSphereCondition(true)) - .dimension(GCySDimensionTypes.SPACE_LEVEL.location()) + .addCondition(new DysonSphereCondition()) + .addCondition(new OrbitCondition()) .duration(200).EUt(-V[UHV]) .save(provider); DYSON_ENERGY_RECIPES.recipeBuilder(GCyS.id("run_dyson_sphere_not_space")) - .addCondition(new DysonSphereCondition(true)) - .dimension(GCySDimensionTypes.SPACE_LEVEL.location(), true) + .addCondition(new DysonSphereCondition()) + .addCondition(new OrbitCondition().setReverse(true)) .duration(200).EUt(-V[UV]) .save(provider); } diff --git a/common/src/main/java/argent_matter/gcys/mixin/EntityMixin.java b/common/src/main/java/argent_matter/gcys/mixin/EntityMixin.java new file mode 100644 index 00000000..1505db3c --- /dev/null +++ b/common/src/main/java/argent_matter/gcys/mixin/EntityMixin.java @@ -0,0 +1,28 @@ +package argent_matter.gcys.mixin; + +import argent_matter.gcys.api.space.planet.Planet; +import argent_matter.gcys.data.loader.PlanetData; +import argent_matter.gcys.util.PlatformUtils; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.level.Level; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(Entity.class) +public class EntityMixin { + + @Inject(method = "tick", at = @At("TAIL")) + private void gcys$tick(CallbackInfo ci) { + Entity entity = ((Entity) (Object) this); + if (!(entity.level() instanceof ServerLevel level)) return; + + // Teleport the entity to the planet when they fall in the void while in an orbit dimension + if (entity.getY() < level.getMinBuildHeight() && PlanetData.isOrbitLevel(level.dimension())) { + ServerLevel newLevel = level.getServer().getLevel(PlanetData.getPlanetFromOrbit(level.dimension()).map(Planet::level).orElse(Level.OVERWORLD)); + PlatformUtils.changeDimension(entity, newLevel); + } + } +} 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 a8c9a515..479f785e 100644 --- a/common/src/main/java/argent_matter/gcys/mixin/ServerLevelMixin.java +++ b/common/src/main/java/argent_matter/gcys/mixin/ServerLevelMixin.java @@ -18,7 +18,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); + IDysonSystem dysonSystem = GcysCapabilityHelper.getDysonSystem((ServerLevel) (Object) this); if (dysonSystem != null && dysonSystem.isDysonSphereActive() && !dysonSystem.activeDysonSphere().isCollapsed()) { long dayTime = this.serverLevelData.getDayTime(); this.serverLevelData.setDayTime(dayTime + (24000L - (dayTime % 24000L) + 18000L) % 24000L); diff --git a/common/src/main/resources/data/gcys/dimension/space.json b/common/src/main/resources/data/gcys/dimension/overworld_orbit.json similarity index 100% rename from common/src/main/resources/data/gcys/dimension/space.json rename to common/src/main/resources/data/gcys/dimension/overworld_orbit.json diff --git a/common/src/main/resources/data/gcys/gcys/planets/earth.json b/common/src/main/resources/data/gcys/gcys/planets/earth.json index a6d0a21a..94ae080e 100644 --- a/common/src/main/resources/data/gcys/gcys/planets/earth.json +++ b/common/src/main/resources/data/gcys/gcys/planets/earth.json @@ -3,6 +3,7 @@ "galaxy": "gcys:milky_way", "solar_system": "gcys:solar_system", "world": "minecraft:overworld", + "orbit_world": "gcys:overworld_orbit", "rocket_tier": 1, "gravity": 9.806, "has_atmosphere": true, diff --git a/common/src/main/resources/data/gcys/gcys/planets/luna.json b/common/src/main/resources/data/gcys/gcys/planets/luna.json index da247da5..55eb00b7 100644 --- a/common/src/main/resources/data/gcys/gcys/planets/luna.json +++ b/common/src/main/resources/data/gcys/gcys/planets/luna.json @@ -3,6 +3,7 @@ "galaxy": "gcys:milky_way", "solar_system": "gcys:solar_system", "world": "gcys:luna", + "orbit_world": "gcys:luna_orbit", "parent_world": "minecraft:overworld", "rocket_tier": 1, "gravity": 1.625, diff --git a/common/src/main/resources/gcys-common.mixins.json b/common/src/main/resources/gcys-common.mixins.json index 1923d195..49ace943 100644 --- a/common/src/main/resources/gcys-common.mixins.json +++ b/common/src/main/resources/gcys-common.mixins.json @@ -4,6 +4,7 @@ "package": "argent_matter.gcys.mixin", "compatibilityLevel": "JAVA_17", "mixins": [ + "EntityMixin", "LivingEntityMixin", "ServerLevelMixin" ], 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 ab3f03f2..fee2d202 100644 --- a/fabric/src/generated/resources/assets/gcys/lang/en_ud.json +++ b/fabric/src/generated/resources/assets/gcys/lang/en_ud.json @@ -25,6 +25,7 @@ "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ǝᴚ", + "gcys.condition.space": "ǝɔɐds uı ǝq oʇ ǝuıɥɔɐɯ sǝɹınbǝᴚ", "gcys.machine.satellite_jammer.jammed": "%s pǝɯɯɐſ", "gcys.machine.satellite_jammer.position": "%s ʇⱯ", "gcys.multiblock.rocket.build": "ʇǝʞɔoᴚ uɐɔS", @@ -91,6 +92,7 @@ "menu.gcys.oxygen.true": "uǝbʎxo sɐH", "menu.gcys.planet": "ʇǝuɐןԀ", "menu.gcys.provided": "pǝpıʌoɹԀ", + "menu.gcys.save_destination_station": "pɹɐɔʎǝʞ oʇ ᗡI uoıʇɐʇS ǝɔɐdS ǝʌɐS", "menu.gcys.solar_system": "ɯǝʇsʎS ɹɐןoS", "menu.gcys.space_station": "uoıʇɐʇS ǝɔɐdS", "menu.gcys.temperature": "ǝɹnʇɐɹǝdɯǝ⟘", 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 3e43eb7f..cd4cb599 100644 --- a/fabric/src/generated/resources/assets/gcys/lang/en_us.json +++ b/fabric/src/generated/resources/assets/gcys/lang/en_us.json @@ -25,6 +25,7 @@ "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", + "gcys.condition.space": "Requires machine to be in space", "gcys.machine.satellite_jammer.jammed": "Jammed %s", "gcys.machine.satellite_jammer.position": "At %s", "gcys.multiblock.rocket.build": "Scan Rocket", @@ -91,6 +92,7 @@ "menu.gcys.oxygen.true": "Has oxygen", "menu.gcys.planet": "Planet", "menu.gcys.provided": "Provided", + "menu.gcys.save_destination_station": "Save Space Station ID to keycard", "menu.gcys.solar_system": "Solar System", "menu.gcys.space_station": "Space Station", "menu.gcys.temperature": "Temperature", 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 3c59abe0..95ce74ee 100644 --- a/fabric/src/main/java/argent_matter/gcys/fabric/GCySFabric.java +++ b/fabric/src/main/java/argent_matter/gcys/fabric/GCySFabric.java @@ -57,7 +57,7 @@ public CompletableFuture reload(PreparationBarrier preparationBarrier, Res }); ServerEntityWorldChangeEvents.AFTER_PLAYER_CHANGE_WORLD.register((player, origin, destination) -> { - IDysonSystem system = GcysCapabilityHelper.getDysonSystem(player.serverLevel(), player.getOnPos()); + IDysonSystem system = GcysCapabilityHelper.getDysonSystem(player.serverLevel()); if (system != null && system.isDysonSphereActive() && !system.activeDysonSphere().isCollapsed()) { GCySNetworking.NETWORK.sendToPlayer(new PacketSyncDysonSphereStatus(true), player); } else { @@ -67,7 +67,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()); + IDysonSystem system = GcysCapabilityHelper.getDysonSystem(player.serverLevel()); if (system != null && system.isDysonSphereActive() && !system.activeDysonSphere().isCollapsed()) { GCySNetworking.NETWORK.sendToPlayer(new PacketSyncDysonSphereStatus(true), player); } else { diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index 41a35e55..b866ef58 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -10,7 +10,7 @@ "license": "GNU GPL 3.0", "icon": "icon.png", - "accessWidener" : "gcys.accesswidener", + "environment": "*", "entrypoints": { "main": [ 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 ab3f03f2..fee2d202 100644 --- a/forge/src/generated/resources/assets/gcys/lang/en_ud.json +++ b/forge/src/generated/resources/assets/gcys/lang/en_ud.json @@ -25,6 +25,7 @@ "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ǝᴚ", + "gcys.condition.space": "ǝɔɐds uı ǝq oʇ ǝuıɥɔɐɯ sǝɹınbǝᴚ", "gcys.machine.satellite_jammer.jammed": "%s pǝɯɯɐſ", "gcys.machine.satellite_jammer.position": "%s ʇⱯ", "gcys.multiblock.rocket.build": "ʇǝʞɔoᴚ uɐɔS", @@ -91,6 +92,7 @@ "menu.gcys.oxygen.true": "uǝbʎxo sɐH", "menu.gcys.planet": "ʇǝuɐןԀ", "menu.gcys.provided": "pǝpıʌoɹԀ", + "menu.gcys.save_destination_station": "pɹɐɔʎǝʞ oʇ ᗡI uoıʇɐʇS ǝɔɐdS ǝʌɐS", "menu.gcys.solar_system": "ɯǝʇsʎS ɹɐןoS", "menu.gcys.space_station": "uoıʇɐʇS ǝɔɐdS", "menu.gcys.temperature": "ǝɹnʇɐɹǝdɯǝ⟘", 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 3e43eb7f..cd4cb599 100644 --- a/forge/src/generated/resources/assets/gcys/lang/en_us.json +++ b/forge/src/generated/resources/assets/gcys/lang/en_us.json @@ -25,6 +25,7 @@ "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", + "gcys.condition.space": "Requires machine to be in space", "gcys.machine.satellite_jammer.jammed": "Jammed %s", "gcys.machine.satellite_jammer.position": "At %s", "gcys.multiblock.rocket.build": "Scan Rocket", @@ -91,6 +92,7 @@ "menu.gcys.oxygen.true": "Has oxygen", "menu.gcys.planet": "Planet", "menu.gcys.provided": "Provided", + "menu.gcys.save_destination_station": "Save Space Station ID to keycard", "menu.gcys.solar_system": "Solar System", "menu.gcys.space_station": "Space Station", "menu.gcys.temperature": "Temperature", 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 f1c7a0ed..b85bdcbf 100644 --- a/forge/src/main/java/argent_matter/gcys/forge/ForgeCommonEventListener.java +++ b/forge/src/main/java/argent_matter/gcys/forge/ForgeCommonEventListener.java @@ -53,7 +53,7 @@ public static void registerServerReloadListeners(AddReloadListenerEvent event) { @SubscribeEvent public static void playerChangedDimension(PlayerEvent.PlayerChangedDimensionEvent event) { if (event.getEntity() instanceof ServerPlayer player) { - IDysonSystem system = GcysCapabilityHelper.getDysonSystem(player.serverLevel(), player.getOnPos()); + IDysonSystem system = GcysCapabilityHelper.getDysonSystem(player.serverLevel()); if (system != null && system.isDysonSphereActive() && !system.activeDysonSphere().isCollapsed()) { GCySNetworking.NETWORK.sendToPlayer(new PacketSyncDysonSphereStatus(true), player); } else { @@ -65,7 +65,7 @@ public static void playerChangedDimension(PlayerEvent.PlayerChangedDimensionEven @SubscribeEvent public static void entityJoined(EntityJoinLevelEvent event) { if (event.getEntity() instanceof ServerPlayer player) { - IDysonSystem system = GcysCapabilityHelper.getDysonSystem(player.serverLevel(), player.getOnPos()); + IDysonSystem system = GcysCapabilityHelper.getDysonSystem(player.serverLevel()); if (system != null && system.isDysonSphereActive() && !system.activeDysonSphere().isCollapsed()) { GCySNetworking.NETWORK.sendToPlayer(new PacketSyncDysonSphereStatus(true), player); } else {