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 5d2d9b8f..9b5ed21c 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 @@ -5,10 +5,10 @@ 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; -import argent_matter.gcys.common.machine.multiblock.electric.SpaceShuttleMachine; import argent_matter.gcys.data.recipe.GCySTags; import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.GTValues; +import com.gregtechceu.gtceu.api.capability.recipe.FluidRecipeCapability; import com.gregtechceu.gtceu.api.data.RotationState; import com.gregtechceu.gtceu.api.data.chemical.ChemicalHelper; import com.gregtechceu.gtceu.api.data.tag.TagPrefix; @@ -20,15 +20,19 @@ import com.gregtechceu.gtceu.api.pattern.FactoryBlockPattern; import com.gregtechceu.gtceu.api.pattern.MultiblockShapeInfo; import com.gregtechceu.gtceu.api.pattern.Predicates; +import com.gregtechceu.gtceu.api.recipe.GTRecipeType; import com.gregtechceu.gtceu.api.registry.registrate.MachineBuilder; import com.gregtechceu.gtceu.client.renderer.machine.TieredHullMachineRenderer; import com.gregtechceu.gtceu.common.data.GTBlocks; import com.gregtechceu.gtceu.common.data.GTMaterials; import com.gregtechceu.gtceu.common.data.GTRecipeTypes; +import com.gregtechceu.gtceu.config.ConfigHolder; import net.minecraft.core.Direction; +import net.minecraft.network.chat.Component; import net.minecraft.world.level.block.Blocks; import java.util.ArrayList; +import java.util.List; import java.util.function.BiFunction; import static argent_matter.gcys.api.registries.GcysRegistries.REGISTRATE; @@ -36,10 +40,13 @@ import static com.gregtechceu.gtceu.api.pattern.Predicates.*; import static com.gregtechceu.gtceu.common.data.GCyMBlocks.CASING_ATOMIC; import static com.gregtechceu.gtceu.common.data.GTBlocks.*; -import static com.gregtechceu.gtceu.common.data.GTMachines.*; +import static com.gregtechceu.gtceu.common.data.GTMachines.POWER_TRANSFORMER; +@SuppressWarnings({"Convert2MethodRef", "FunctionalExpressionCanBeFolded", "unused"}) public class GCySMachines { + public final static int[] HIGH_TIERS = new int[] {GTValues.IV, GTValues.LuV, GTValues.ZPM, GTValues.UV, GTValues.UHV}; + public final static MachineDefinition[] OXYGEN_SPREADER = registerTieredMachines("oxygen_spreader", OxygenSpreaderMachine::new, (tier, builder) -> builder .rotationState(RotationState.NON_Y_AXIS) @@ -95,7 +102,7 @@ public class GCySMachines { public static final MultiblockMachineDefinition DYSON_SYSTEM_CONTROLLER = REGISTRATE.multiblock("dyson_system_controller", DysonSystemControllerMachine::new) .rotationState(RotationState.NON_Y_AXIS) - .appearanceBlock(CASING_ATOMIC) + .appearanceBlock(() -> CASING_ATOMIC.get()) // You MUST do it like this, so that the GTBlocks/GCyMBlocks class isn't loaded too early. Because that causes a crash. .recipeType(GCySRecipeTypes.DYSON_ENERGY_RECIPES) .pattern(definition -> FactoryBlockPattern.start() .aisle("CCCCCCC", "CCCCCCC", " F ", " ", " ", " ", " ", " ", " ", " ", " ", " ") @@ -120,7 +127,7 @@ public class GCySMachines { public static final MultiblockMachineDefinition SPACE_ELEVATOR = REGISTRATE.multiblock("space_elevator", WorkableElectricMultiblockMachine::new) .rotationState(RotationState.NON_Y_AXIS) - .appearanceBlock(CASING_TUNGSTENSTEEL_ROBUST) + .appearanceBlock(() -> CASING_TUNGSTENSTEEL_ROBUST.get()) .recipeType(GCySRecipeTypes.SPACE_ELEVATOR_RECIPES) .pattern(definition -> FactoryBlockPattern.start() .aisle(" KKKKKKK ", " BXXXB ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ") @@ -162,37 +169,10 @@ public class GCySMachines { GTCEu.id("block/multiblock/assembly_line"), false) .register(); - public static final MultiblockMachineDefinition SPACE_SHUTTLE = REGISTRATE.multiblock("space_shuttle", SpaceShuttleMachine::new) - .rotationState(RotationState.NON_Y_AXIS) - .appearanceBlock(CASING_TUNGSTENSTEEL_ROBUST) - .recipeType(GCySRecipeTypes.SPACE_SHUTTLE_RECIPES) - .pattern(definition -> FactoryBlockPattern.start() - .aisle("CCCCCCCCC", "CCCCCCCCC", " X X ", " XXX ", " X X ", " XXX ", " X X ", " XXX ", " X X ", " XXX ", " X X ", " ") - .aisle("CCCCCCCCC", "CCCCCCCCC", " X X ", " ", " X X ", " ", " X X ", " ", " X X ", " ", " X X ", " ") - .aisle("CCCCCCCCC", "CCCCCCCCC", " X X ", " XXX ", " X X ", " XXX ", " X X ", " XXX ", " X X ", " XXX ", " X X ", " ") - .aisle("CCCCCCCCC", "CCCCCCCCC", " ", " T ", " ", " ", " ", " ", " XXX ", " ", " ", " ") - .aisle("CCCCCCCCC", "CCCCCCCCC", " ", " T ", " T ", " T ", " ", " ", " XXX ", " ", " ", " ") - .aisle("CCCCCCCCC", "CCCCCCCCC", " A ", " TTT ", " TTT ", " TTT ", " TTT ", " TTT ", " TTT ", " TTT ", " B ", " ") - .aisle("CCCCCCCCC", " ", " A A ", " TTTTTTT ", " TTT TTT ", " TT TT ", " TT TT ", " T T ", " T T ", " T T ", " B B ", " B ") - .aisle("CCCCCCCCC", "CCCCCCCCC", " A ", " TTT ", " TTT ", " TTT ", " TTT ", " TTT ", " TTT ", " TTT ", " B ", " ") - .aisle("CCCCCCCCC", "CCCCSCCCC", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ") - .where('S', controller(blocks(definition.getBlock()))) - .where(' ', air()) - .where('C', blocks(CASING_TUNGSTENSTEEL_ROBUST.get()).setMinGlobalLimited(110) - .or(Predicates.autoAbilities(definition.getRecipeTypes()))) - .where('X', blocks(MATERIAL_BLOCKS.get(TagPrefix.frameGt, GTMaterials.StainlessSteel).get())) - .where('T', blocks(CASING_ALUMINIUM_AEROSPACE.get())) - .where('A', blocks(ROCKET_MOTOR.get())) - .where('B', blocks(MATERIAL_BLOCKS.get(TagPrefix.block, GCySMaterials.KaptonK).get())) - .build()) - .workableCasingRenderer(GTCEu.id("block/casings/solid/machine_casing_robust_tungstensteel"), - GTCEu.id("block/multiblock/assembly_line"), false) - .register(); - public static final MultiblockMachineDefinition DRONE_HANGAR = REGISTRATE.multiblock("drone_hangar", WorkableElectricMultiblockMachine::new) .rotationState(RotationState.NON_Y_AXIS) .recipeType(GTRecipeTypes.VACUUM_RECIPES) - .appearanceBlock(CASING_ALUMINIUM_FROSTPROOF) + .appearanceBlock(() -> CASING_ALUMINIUM_FROSTPROOF.get()) .pattern(definition -> FactoryBlockPattern.start() .aisle("XXX", "XXX", "XXX") .aisle("XXX", "X#X", "XXX") @@ -220,6 +200,22 @@ public static MachineDefinition[] registerTieredMachines(String name, return definitions; } + public static Component explosion() { + if (ConfigHolder.INSTANCE.machines.doTerrainExplosion) + return Component.translatable("gtceu.universal.tooltip.terrain_resist"); + return null; + } + + public static Component[] workableTiered(int tier, long voltage, long energyCapacity, GTRecipeType recipeType, long tankCapacity, boolean input) { + List tooltipComponents = new ArrayList<>(); + tooltipComponents.add(input ? Component.translatable("gtceu.universal.tooltip.voltage_in", voltage, GTValues.VNF[tier]) : + Component.translatable("gtceu.universal.tooltip.voltage_out", voltage, GTValues.VNF[tier])); + tooltipComponents.add(Component.translatable("gtceu.universal.tooltip.energy_storage_capacity", energyCapacity)); + if (recipeType.getMaxInputs(FluidRecipeCapability.CAP) > 0 || recipeType.getMaxOutputs(FluidRecipeCapability.CAP) > 0) + tooltipComponents.add(Component.translatable("gtceu.universal.tooltip.fluid_storage_capacity", tankCapacity)); + return tooltipComponents.toArray(Component[]::new); + } + public static void init() { } diff --git a/common/src/main/java/argent_matter/gcys/common/data/GCySRecipeTypes.java b/common/src/main/java/argent_matter/gcys/common/data/GCySRecipeTypes.java index 491dbfcb..5bf577a5 100644 --- a/common/src/main/java/argent_matter/gcys/common/data/GCySRecipeTypes.java +++ b/common/src/main/java/argent_matter/gcys/common/data/GCySRecipeTypes.java @@ -31,10 +31,6 @@ public class GCySRecipeTypes { .setProgressBar(GcysGuiTextures.PROGRESS_BAR_ROCKET, LEFT_TO_RIGHT) .setSound(GTSoundEntries.TRICORDER_TOOL); - public static final GTRecipeType SPACE_SHUTTLE_RECIPES = register("space_shuttle", MULTIBLOCK).setMaxIOSize(4, 0, 2, 0).setEUIO(IO.IN) - .setProgressBar(GcysGuiTextures.PROGRESS_BAR_ROCKET, LEFT_TO_RIGHT) - .setSound(GCySSoundEntries.ROCKET); - public static GTRecipeType register(String name, String group, RecipeType... proxyRecipes) { var recipeType = new GTRecipeType(GCyS.id(name), group, proxyRecipes); GTRegistries.register(BuiltInRegistries.RECIPE_TYPE, recipeType.registryName, recipeType); diff --git a/common/src/main/java/argent_matter/gcys/common/machine/multiblock/electric/SpaceShuttleMachine.java b/common/src/main/java/argent_matter/gcys/common/machine/multiblock/electric/SpaceShuttleMachine.java deleted file mode 100644 index 364820e2..00000000 --- a/common/src/main/java/argent_matter/gcys/common/machine/multiblock/electric/SpaceShuttleMachine.java +++ /dev/null @@ -1,151 +0,0 @@ -package argent_matter.gcys.common.machine.multiblock.electric; - -import argent_matter.gcys.GCyS; -import argent_matter.gcys.api.capability.GcysCapabilityHelper; -import argent_matter.gcys.api.capability.ISpaceStationHolder; -import argent_matter.gcys.api.gui.widget.GcysGuiTextures; -import argent_matter.gcys.api.registries.GcysRegistries; -import argent_matter.gcys.api.space.satellite.SatelliteType; -import argent_matter.gcys.api.space.satellite.data.SatelliteData; -import argent_matter.gcys.api.space.station.SpaceStation; -import argent_matter.gcys.common.data.GCySDimensionTypes; -import argent_matter.gcys.common.data.GCySItems; -import argent_matter.gcys.common.data.GCySRecipeTypes; -import argent_matter.gcys.common.item.KeyCardBehaviour; -import argent_matter.gcys.common.item.PlanetIdChipBehaviour; -import argent_matter.gcys.common.worldgen.SpaceLevelSource; -import argent_matter.gcys.data.lang.LangHandler; -import argent_matter.gcys.data.loader.PlanetData; -import argent_matter.gcys.util.Vec2i; -import com.gregtechceu.gtceu.api.capability.recipe.IO; -import com.gregtechceu.gtceu.api.gui.GuiTextures; -import com.gregtechceu.gtceu.api.gui.UITemplate; -import com.gregtechceu.gtceu.api.machine.IMachineBlockEntity; -import com.gregtechceu.gtceu.api.machine.multiblock.WorkableElectricMultiblockMachine; -import com.gregtechceu.gtceu.api.machine.trait.NotifiableItemStackHandler; -import com.gregtechceu.gtceu.api.recipe.GTRecipe; -import com.lowdragmc.lowdraglib.gui.modular.ModularUI; -import com.lowdragmc.lowdraglib.gui.texture.GuiTextureGroup; -import com.lowdragmc.lowdraglib.gui.util.ClickData; -import com.lowdragmc.lowdraglib.gui.widget.*; -import com.lowdragmc.lowdraglib.syncdata.ISubscription; -import com.lowdragmc.lowdraglib.syncdata.annotation.Persisted; -import com.lowdragmc.lowdraglib.syncdata.field.ManagedFieldHolder; -import net.minecraft.core.BlockPos; -import net.minecraft.nbt.Tag; -import net.minecraft.network.chat.MutableComponent; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.server.level.ServerLevel; -import net.minecraft.server.level.ServerPlayer; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.level.Level; - -import javax.annotation.Nullable; -import java.util.UUID; - -public class SpaceShuttleMachine extends WorkableElectricMultiblockMachine { - protected static final ManagedFieldHolder MANAGED_FIELD_HOLDER = new ManagedFieldHolder(SpaceShuttleMachine.class, WorkableElectricMultiblockMachine.MANAGED_FIELD_HOLDER); - public static final int SATELLITE_RANGE_MULTIPLIER = 32; - - @Persisted - public final NotifiableItemStackHandler inventory; - @Nullable - protected ISubscription inventorySubs; - @Nullable - private UUID currentSatelliteOwnerUUID; - - public SpaceShuttleMachine(IMachineBlockEntity holder) { - super(holder); - this.inventory = createInventory(); - } - - @Override - public boolean isWorkingEnabled() { - return super.isWorkingEnabled(); - } - - @Override - public ManagedFieldHolder getFieldHolder() { - return MANAGED_FIELD_HOLDER; - } - - protected NotifiableItemStackHandler createInventory() { - return new NotifiableItemStackHandler(this, 1, IO.BOTH); - } - - @Override - public void onLoad() { - super.onLoad(); - inventorySubs = inventory.addChangedListener(this::updatedInventory); - } - - protected void updatedInventory() { - var stack = inventory.getStackInSlot(0); - if (GCySItems.KEYCARD.isIn(stack)) { - this.currentSatelliteOwnerUUID = KeyCardBehaviour.getOwner(stack); - this.recipeLogic.setWorkingEnabled(true); - } else if (GCySItems.ID_CHIP.isIn(stack)) { - this.currentSatelliteOwnerUUID = null; - this.recipeLogic.setWorkingEnabled(true); - } else { - this.recipeLogic.setWorkingEnabled(false); - } - } - - @Override - protected @Nullable GTRecipe getRealRecipe(GTRecipe recipe) { - if (recipe.data.contains("satellite_type", Tag.TAG_STRING) && recipe.data.getString("satellite_type").equals("gcys.manned_rocket")) return null; - if (this.getLevel().dimensionType().hasCeiling()) return null; - return super.modifyRecipe(recipe); - } - - @Override - public void afterWorking() { - super.afterWorking(); - if (recipeLogic.getLastRecipe() != null) { - var data = this.recipeLogic.getLastRecipe().data; - SatelliteType type = data.contains("satellite_type") ? GcysRegistries.SATELLITES.get(new ResourceLocation(data.getString("satellite_type"))) : null; - BlockPos pos = this.getPos(); - if (!this.getLevel().isClientSide && type != null) { - GcysCapabilityHelper.getSatellites((ServerLevel) this.getLevel()).addSatellite(type.getFactory().create(type, new SatelliteData(new Vec2i(pos.getX(), pos.getZ()), this.getTier() * SATELLITE_RANGE_MULTIPLIER, currentSatelliteOwnerUUID), this.getLevel().dimension())); - } - } - } - - private static final ResourceLocation mannedLaunchRecipeId = GCyS.id("space_shuttle/manned_launch_station"); - - private void launchPlayerToStation(ClickData data, Player player) { - Level level = player.level(); - var recipe = GCySRecipeTypes.SPACE_SHUTTLE_RECIPES.getRecipe(level.getRecipeManager(), mannedLaunchRecipeId); - if (!level.isClientSide && recipe.matchRecipe(this).isSuccess() && GCySItems.ID_CHIP.isIn(inventory.getStackInSlot(0))) { - this.recipeLogic.setupRecipe(recipe); - int stationId = PlanetIdChipBehaviour.getSpaceStationId(inventory.getStackInSlot(0)); - if (stationId != SpaceStation.ID_EMPTY) { - ServerPlayer serverPlayer = (ServerPlayer) player; - ServerLevel space = level.getServer().getLevel(GCySDimensionTypes.SPACE_LEVEL); - ISpaceStationHolder stations = GcysCapabilityHelper.getSpaceStations(space); - Vec2i pos = stations.getStationPos(stationId); - if (pos == Vec2i.MAX_NEGATIVE) { - pos = stations.getFreeStationPos(stationId); - stations.addStation(stationId, new SpaceStation(PlanetData.getPlanetFromLevel(Level.OVERWORLD).orElse(null), pos)); - } - serverPlayer.teleportTo(space, pos.x(), SpaceLevelSource.PLATFORM_HEIGHT + 1, pos.y(), serverPlayer.getYRot(), serverPlayer.getXRot()); - } - } - } - - @Override - public ModularUI createUI(Player player) { - var screen = new DraggableScrollableWidgetGroup(4, 4, 162, 121).setBackground(getScreenTexture()); - screen.addWidget(new LabelWidget(4, 5, self().getBlockState().getBlock().getDescriptionId())); - screen.addWidget(new ComponentPanelWidget(4, 17, this::addDisplayText) - .setMaxWidthLimit(156) - .clickHandler(this::handleDisplayClick)); - return new ModularUI(190, 216, this, player) - .background(GuiTextures.BACKGROUND) - .widget(new SlotWidget(inventory, 0, 168, 107).setBackgroundTexture(new GuiTextureGroup(GuiTextures.SLOT))) - .widget(new ButtonWidget(168, 87, 18, 18, GcysGuiTextures.BUTTON_LAUNCH_ROCKET, data -> launchPlayerToStation(data, player)).setHoverTooltips(LangHandler.getMultiLang("gcys.multiblock.space_shuttle.launch").toArray(MutableComponent[]::new))) - .widget(screen) - .widget(UITemplate.bindPlayerInventory(player.getInventory(), GuiTextures.SLOT, 7, 134, true)); - } -}