Skip to content

Commit

Permalink
Feature/soul hatch (#12)
Browse files Browse the repository at this point in the history
* Add Blood Magic as a mod Dependency

* Add Soul Hatch base

* Add missing texture

* Add Soul Hatch

* Add Soul Hatch

* Add Soul Hatch

* Fix UI

* Tests recipe fix

* make the soul input hatch work

* Add Soul Input/Output hatch throttling

* Add Soul Input/Output hatch throttling

* Update gitignore

* Add recipe

* Fix workflow typo

* Fix workflow typo
  • Loading branch information
mrquentin authored May 11, 2024
1 parent 2bcb616 commit 252414e
Show file tree
Hide file tree
Showing 14 changed files with 170 additions and 38 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ jobs:

files: ./build/libs/!(*-@(dev|sources|dev-shadow)).jar
name: "Cosmic Core ${{ steps.properties.outputs.mod_version }}"
version: ${{ steps.properties.outputs.version }}
version: ${{ steps.properties.outputs.mod_version }}
version-type: ${{ inputs.version_type }}
changelog-file: changelog.md
loaders: forge
game-versions: ${{ steps.properties.outputs.minecraftVersion }}
game-versions: ${{ steps.properties.outputs.minecraft_version }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,6 @@ bin/
# fabric

run/

# forge generated resources cache
src/generated/resources/.cache
2 changes: 0 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ curios_version=5.4.3
configuration_version=2.2.0
jei_version=15.3.0.4
mixinextras_version=0.2.0
# Unused for now until I can find the official Bloodmagic Maven repo
blood_magic_version=3.3.2-44
# Ad Astra
ad_astra_version=1.15.18
botarium_version=2.3.3
Expand Down
14 changes: 13 additions & 1 deletion src/generated/resources/assets/cosmiccore/lang/en_ud.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"block.cosmiccore.aerospace_aluminium_casing": "buısɐƆ ɯnıuıɯnןⱯ ǝɔɐdsoɹǝⱯ",
"block.cosmiccore.alternator_flux_coiling": "buıןıoƆ xnןℲ ɹoʇɐuɹǝʇןⱯ",
"block.cosmiccore.drygmy_grove": "ǝʌoɹ⅁ ʎɯbʎɹᗡ",
"block.cosmiccore.dyson_solar_cell": "ןןǝƆ ɹɐןoS uosʎᗡ",
Expand All @@ -8,6 +9,16 @@
"block.cosmiccore.luv_soul_output_hatch": "ɥɔʇɐH ʇndʇnO ןnoS ΛnꞀp§",
"block.cosmiccore.opv_soul_input_hatch": "ɥɔʇɐH ʇnduI ןnoS ΛdOן§6§",
"block.cosmiccore.opv_soul_output_hatch": "ɥɔʇɐH ʇndʇnO ןnoS ΛdOן§6§",
"block.cosmiccore.dyson_sphere_casing": "buısɐƆ ǝɹǝɥdS uosʎᗡ",
"block.cosmiccore.dyson_sphere_maintenance_port": "ʇɹoԀ ǝɔuɐuǝʇuıɐW ǝɹǝɥdS uosʎᗡ",
"block.cosmiccore.iv_soul_input_hatch": "ɥɔʇɐH ʇnduI ןnoS ΛI6§",
"block.cosmiccore.iv_soul_output_hatch": "ɥɔʇɐH ʇndʇnO ןnoS ΛI6§",
"block.cosmiccore.luv_soul_input_hatch": "ɥɔʇɐH ʇnduI ןnoS ΛnꞀp§",
"block.cosmiccore.luv_soul_output_hatch": "ɥɔʇɐH ʇndʇnO ןnoS ΛnꞀp§",
"block.cosmiccore.opv_soul_input_hatch": "ɥɔʇɐH ʇnduI ןnoS ΛdOן§6§",
"block.cosmiccore.opv_soul_output_hatch": "ɥɔʇɐH ʇndʇnO ןnoS ΛdOן§6§",
"block.cosmiccore.max_soul_input_hatch": "ɥɔʇɐH ʇnduI ןnoS XⱯWן§ɔ§",
"block.cosmiccore.max_soul_output_hatch": "ɥɔʇɐH ʇndʇnO ןnoS XⱯWן§ɔ§",
"block.cosmiccore.plated_aerocloud": "pnoןɔoɹǝⱯ pǝʇɐןԀ",
"block.cosmiccore.prismatic_tungstensteel_coil_block": "ʞɔoןᗺ ןıoƆ ןǝǝʇsuǝʇsbun⟘ ɔıʇɐɯsıɹԀ",
"block.cosmiccore.shimmering_neutronium_coil_block": "ʞɔoןᗺ ןıoƆ ɯnıuoɹʇnǝN buıɹǝɯɯıɥS",
Expand Down Expand Up @@ -49,5 +60,6 @@
"item.cosmiccore.psionic_processor_supercomputer": "ɹǝʇndɯoɔɹǝdnS ɹossǝɔoɹԀ ɔıuoısԀ",
"item.cosmiccore.waxed_leather": "ɹǝɥʇɐǝꞀ pǝxɐM",
"material.cosmiccore.prisma": "ɐɯsıɹԀ",
"material.cosmiccore.prismatic_tungstensteel": "ןǝǝʇsuǝʇsbun⟘ ɔıʇɐɯsıɹԀ"
"material.cosmiccore.prismatic_tungstensteel": "ןǝǝʇsuǝʇsbun⟘ ɔıʇɐɯsıɹԀ",
"itemGroup.cosmiccore.creative_tab": "ǝɹoƆ ɔıɯsoƆ"
}
15 changes: 14 additions & 1 deletion src/generated/resources/assets/cosmiccore/lang/en_us.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
{
"block.cosmiccore.aerospace_aluminium_casing": "Aerospace Aluminium Casing",
"block.cosmiccore.alternator_flux_coiling": "Alternator Flux Coiling",
"block.cosmiccore.drygmy_grove": "Drygmy Grove",
"block.cosmiccore.dyson_solar_cell": "Dyson Solar Cell",
"block.cosmiccore.dyson_sphere_casing": "Dyson Sphere Casing",
"block.cosmiccore.dyson_sphere_maintenance_port": "Dyson Sphere Maintenance Port",
"block.cosmiccore.iv_soul_input_hatch": "§9IV Soul Input Hatch",
"block.cosmiccore.iv_soul_output_hatch": "§9IV Soul Output Hatch",
"block.cosmiccore.luv_soul_input_hatch": "§dLuV Soul Input Hatch",
"block.cosmiccore.luv_soul_output_hatch": "§dLuV Soul Output Hatch",
"block.cosmiccore.opv_soul_input_hatch": "§9§lOpV Soul Input Hatch",
"block.cosmiccore.opv_soul_output_hatch": "§9§lOpV Soul Output Hatch",
"block.cosmiccore.max_soul_input_hatch": "§c§lMAX Soul Input Hatch",
"block.cosmiccore.max_soul_output_hatch": "§c§lMAX Soul Output Hatch",
"block.cosmiccore.plated_aerocloud": "Plated Aerocloud",
"block.cosmiccore.prismatic_tungstensteel_coil_block": "Prismatic Tungstensteel Coil Block",
"block.cosmiccore.shimmering_neutronium_coil_block": "Shimmering Neutronium Coil Block",
Expand Down Expand Up @@ -50,5 +55,13 @@
"item.cosmiccore.waxed_leather": "Waxed Leather",
"material.cosmiccore.prisma": "Prisma",
"material.cosmiccore.prismatic_tungstensteel": "Prismatic Tungstensteel",
"cosmiccore.recipe.soul": "Soul"
"cosmiccore.recipe.soul": "Soul",
"gui.cosmiccore.soul_hatch.label.import": "Soul Input Hatch",
"gui.cosmiccore.soul_hatch.label.export": "Soul Output Hatch",
"gui.cosmiccore.soul_hatch.owner": "Owner: %s",
"gui.cosmiccore.soul_hatch.lp": "LP: %s",
"gui.cosmiccore.soul_hatch.no_network": "No Network Connected",
"tooltip.cosmiccore.soul_hatch.input": "Max recipe consumption: %s LP",
"tooltip.cosmiccore.soul_hatch.output": "Max network Capacity: %s LP",
"itemGroup.cosmiccore.creative_tab": "Cosmic Core"
}
4 changes: 2 additions & 2 deletions src/main/java/com/ghostipedia/cosmiccore/CosmicCore.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
import com.ghostipedia.cosmiccore.common.data.CosmicCreativeModeTabs;
import com.ghostipedia.cosmiccore.common.data.CosmicItems;
import com.ghostipedia.cosmiccore.common.data.CosmicMachines;
import com.ghostipedia.cosmiccore.common.data.CosmicMachines;
import com.ghostipedia.cosmiccore.common.data.materials.CosmicElements;
import com.ghostipedia.cosmiccore.common.data.materials.CosmicMaterials;
import com.ghostipedia.cosmiccore.gtbridge.CosmicCoreRecipeTypes;
import com.gregtechceu.gtceu.api.GTCEuAPI;
import com.gregtechceu.gtceu.api.capability.recipe.RecipeCapability;
import com.gregtechceu.gtceu.api.capability.recipe.RecipeCapability;
import com.gregtechceu.gtceu.api.data.chemical.Element;
import com.gregtechceu.gtceu.api.data.chemical.material.event.MaterialEvent;
import com.gregtechceu.gtceu.api.data.chemical.material.event.MaterialRegistryEvent;
Expand All @@ -37,9 +39,7 @@
public class CosmicCore {
public static final String MOD_ID = "cosmiccore", NAME = "CosmicCore";
public static final Logger LOGGER = LoggerFactory.getLogger(NAME);

public static MaterialRegistry MATERIAL_REGISTRY;

//Init Everything
public CosmicCore() {
CosmicCore.init();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
package com.ghostipedia.cosmiccore.api.capability.recipe;

import com.ghostipedia.cosmiccore.api.recipe.lookup.MapSoulIngredient;
import com.gregtechceu.gtceu.api.capability.recipe.RecipeCapability;
import com.gregtechceu.gtceu.api.recipe.content.ContentModifier;
import com.gregtechceu.gtceu.api.recipe.content.SerializerInteger;
import com.gregtechceu.gtceu.api.recipe.lookup.AbstractMapIngredient;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;

import java.util.Collection;
import java.util.List;

public class SoulRecipeCapability extends RecipeCapability<Integer> {
public final static SoulRecipeCapability CAP = new SoulRecipeCapability();
Expand All @@ -20,4 +26,22 @@ public Integer copyInner(Integer content) {
public Integer copyWithModifier(Integer content, ContentModifier modifier) {
return modifier.apply(content).intValue();
}

@Override
public List<AbstractMapIngredient> convertToMapIngredient(Object ingredient) {
List<AbstractMapIngredient> ingredients = new ObjectArrayList<>(1);
if (ingredient instanceof Integer essence) ingredients.add(new MapSoulIngredient(essence));
return ingredients;
}

@Override
public List<Object> compressIngredients(Collection<Object> ingredients) {
//TODO: Figure out what it needs to do
return super.compressIngredients(ingredients);
}

@Override
public boolean isRecipeSearchFilter() {
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import wayoftime.bloodmagic.core.data.SoulNetwork;
import wayoftime.bloodmagic.core.data.SoulTicket;
import wayoftime.bloodmagic.util.helper.NetworkHelper;
import com.gregtechceu.gtceu.api.GTValues;

import java.util.Collections;
import java.util.List;
Expand All @@ -36,10 +37,18 @@ public class NotifiableSoulContainer extends NotifiableRecipeHandlerTrait<Intege
@DescSynced
private int currentEssence;

public NotifiableSoulContainer(MetaMachine machine,IO io) {
@Persisted
private int maxCapacity;

@Persisted
private int maxConsumption;

public NotifiableSoulContainer(MetaMachine machine, IO io, int maxCapacity, int maxConsumption) {
super(machine);
this.handlerIO = io;
this.currentEssence = -1;
this.maxCapacity = maxCapacity;
this.maxConsumption = maxConsumption;
conditionalSubscriptionHandler = new ConditionalSubscriptionHandler(machine, this::querySoulNetwork, () -> owner != null);
}

Expand All @@ -63,9 +72,13 @@ public List<Integer> handleRecipeInner(IO io, GTRecipe recipe, List<Integer> lef

int lifeEssence = left.stream().reduce(0, Integer::sum);
if (io == IO.IN) {
if (!simulate) lifeEssence = container.getSoulNetwork().syphon(SoulTicket.block(this.machine.getLevel(), this.machine.getPos(), lifeEssence), false);
var canOutput = Math.min(this.maxConsumption, container.getSoulNetwork().getCurrentEssence());
if (!simulate) lifeEssence = container.getSoulNetwork().syphon(SoulTicket.block(this.machine.getLevel(), this.machine.getPos(), Math.min(canOutput, lifeEssence)), false);
lifeEssence = lifeEssence - canOutput;
} else if (io == IO.OUT) {
if (!simulate) lifeEssence = container.getSoulNetwork().add(SoulTicket.block(this.machine.getLevel(), this.machine.getPos(), lifeEssence), Integer.MAX_VALUE);
var canInput = this.maxCapacity - container.getSoulNetwork().getCurrentEssence();
if (!simulate) lifeEssence = container.getSoulNetwork().add(SoulTicket.block(this.machine.getLevel(), this.machine.getPos(), Math.min(canInput, lifeEssence)), this.maxCapacity);
lifeEssence = lifeEssence - canInput;
}

return lifeEssence <= 0 ? null : Collections.singletonList(lifeEssence);
Expand Down Expand Up @@ -98,6 +111,11 @@ public SoulNetwork getSoulNetwork() {
return NetworkHelper.getSoulNetwork(this.owner);
}

@Override
public int getSize() {
return 1;
}

@Override
public void setOwner(UUID owner) {
this.owner = owner;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.ghostipedia.cosmiccore.api.recipe.lookup;

import com.gregtechceu.gtceu.api.recipe.lookup.AbstractMapIngredient;

public class MapSoulIngredient extends AbstractMapIngredient {

public final Integer souls;

public MapSoulIngredient(Integer souls) {
this.souls = souls;
}

@Override
protected int hash() {
return MapSoulIngredient.class.hashCode();
}

@Override
public boolean equals(Object obj) {
return obj instanceof MapSoulIngredient;
}

@Override
public String toString() {
return "MapSoulIngredient{" + "souls=" + souls + '}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import com.ghostipedia.cosmiccore.CosmicCore;
import com.gregtechceu.gtceu.common.data.GTCreativeModeTabs;
import com.tterrag.registrate.util.entry.RegistryEntry;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.*;

import static com.ghostipedia.cosmiccore.api.registries.CosmicRegistries.REGISTRATE;
Expand All @@ -10,6 +11,7 @@
public class CosmicCreativeModeTabs {
public static RegistryEntry<CreativeModeTab> COSMIC_CORE = REGISTRATE.defaultCreativeTab(CosmicCore.MOD_ID,
builder -> builder.displayItems(new GTCreativeModeTabs.RegistrateDisplayItemsGenerator(CosmicCore.MOD_ID, REGISTRATE))
.title(REGISTRATE.addLang("itemGroup", CosmicCore.id("creative_tab"), "Cosmic Core"))
.icon(CosmicItems.DONK::asStack)
.build())
.register();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.ghostipedia.cosmiccore.common.data;

import com.ghostipedia.cosmiccore.api.machine.part.CosmicPartAbility;
import com.ghostipedia.cosmiccore.api.registries.CosmicRegistries;
import com.ghostipedia.cosmiccore.common.machine.multiblock.part.SoulHatchPartMachine;
import com.ghostipedia.cosmiccore.gtbridge.CosmicCoreRecipeTypes;
import com.gregtechceu.gtceu.GTCEu;
Expand All @@ -19,8 +20,6 @@
import com.gregtechceu.gtceu.api.machine.MultiblockMachineDefinition;
import com.gregtechceu.gtceu.api.machine.multiblock.PartAbility;
import com.gregtechceu.gtceu.api.machine.multiblock.WorkableElectricMultiblockMachine;
import com.gregtechceu.gtceu.api.machine.multiblock.WorkableMultiblockMachine;
import com.gregtechceu.gtceu.api.machine.trait.RecipeLogic;
import com.gregtechceu.gtceu.api.pattern.FactoryBlockPattern;
import com.gregtechceu.gtceu.api.recipe.GTRecipe;
import com.gregtechceu.gtceu.api.recipe.OverclockingLogic;
Expand All @@ -30,9 +29,9 @@
import com.gregtechceu.gtceu.common.data.GTMaterials;
import com.gregtechceu.gtceu.common.data.GTRecipeModifiers;
import com.gregtechceu.gtceu.common.machine.multiblock.primitive.PrimitiveWorkableMachine;
import net.minecraft.network.chat.Component;
import com.gregtechceu.gtceu.utils.GTHashMaps;
import com.gregtechceu.gtceu.utils.ItemStackHashStrategy;
import com.ibm.icu.impl.ICUService;
import it.unimi.dsi.fastutil.objects.Object2IntMap;
import it.unimi.dsi.fastutil.objects.Object2IntOpenCustomHashMap;
import net.minecraft.core.registries.BuiltInRegistries;
Expand All @@ -47,7 +46,9 @@
import static com.gregtechceu.gtceu.api.pattern.Predicates.*;

public class CosmicMachines {

static {
CosmicRegistries.REGISTRATE.creativeModeTab(() -> CosmicCreativeModeTabs.COSMIC_CORE);
}

public static final int[] HIGH_TIERS = GTValues.tiersBetween(GTValues.IV, GTCEuAPI.isHighTier() ? GTValues.OpV : GTValues.UHV);

Expand All @@ -59,11 +60,11 @@ public static GTRecipe copyOutputs(GTRecipe recipe, ContentModifier modifier) {
"soul_input_hatch", "Soul Input Hatch", "soul_hatch.import",
IO.IN, HIGH_TIERS, CosmicPartAbility.IMPORT_SOUL);

public final static MachineDefinition[] SOUL_EXPORT_HATCH = registerSoulTieredHatch(
public static final MachineDefinition[] SOUL_EXPORT_HATCH = registerSoulTieredHatch(
"soul_output_hatch", "Soul Output Hatch", "soul_hatch.export",
IO.OUT, HIGH_TIERS, CosmicPartAbility.EXPORT_SOUL);

public final static MultiblockMachineDefinition SOUL_TESTER = REGISTRATE.multiblock("soul_tester", PrimitiveWorkableMachine::new)
public static final MultiblockMachineDefinition SOUL_TESTER = REGISTRATE.multiblock("soul_tester", PrimitiveWorkableMachine::new)
.rotationState(RotationState.NON_Y_AXIS)
.recipeType(CosmicCoreRecipeTypes.SOUL_TESTER_RECIPES)
.appearanceBlock(GTBlocks.CASING_PRIMITIVE_BRICKS)
Expand All @@ -75,6 +76,7 @@ public static GTRecipe copyOutputs(GTRecipe recipe, ContentModifier modifier) {
.build())
.workableCasingRenderer(GTCEu.id("block/casings/solid/machine_casing_inert_ptfe"), GTCEu.id("block/multiblock/coke_oven"))
.register();

//Terrifying Recipe Modifiers half of this is moonruns to me :lets:
public final static MultiblockMachineDefinition DRYGMY_GROVE = REGISTRATE.multiblock("drygmy_grove", WorkableElectricMultiblockMachine::new)
.rotationState(RotationState.NON_Y_AXIS)
Expand Down Expand Up @@ -118,14 +120,11 @@ public static GTRecipe copyOutputs(GTRecipe recipe, ContentModifier modifier) {
.or(abilities(PartAbility.EXPORT_ITEMS))
.or(abilities(PartAbility.INPUT_ENERGY))
.or(abilities(PartAbility.MAINTENANCE))
)

.build())
).build())
.workableCasingRenderer(GTCEu.id("block/casings/solid/machine_casing_stable_titanium"), GTCEu.id("block/multiblock/coke_oven"))
.register();

private static MachineDefinition[] registerSoulTieredHatch(String name, String displayName, String model, IO io,
int[] tiers, PartAbility... abilities) {
private static MachineDefinition[] registerSoulTieredHatch(String name, String displayName, String model, IO io, int[] tiers, PartAbility... abilities) {
return registerTieredMachines(name,
(holder, tier) -> new SoulHatchPartMachine(holder, tier, io),
(tier, builder) -> builder
Expand All @@ -134,7 +133,10 @@ private static MachineDefinition[] registerSoulTieredHatch(String name, String d
.rotationState(RotationState.ALL)
.overlayTieredHullRenderer(model)
.compassNode("soul_hatch")
.register(), tiers);
.tooltipBuilder((item, tooltip) -> {
if (io == IO.IN) tooltip.add(Component.translatable("tooltip.cosmiccore.soul_hatch.input", SoulHatchPartMachine.getMaxConsumption(tier)));
else tooltip.add(Component.translatable("tooltip.cosmiccore.soul_hatch.output", SoulHatchPartMachine.getMaxCapacity(tier)));
}).register(), tiers);
}

private static MachineDefinition[] registerTieredMachines(String name, BiFunction<IMachineBlockEntity, Integer, MetaMachine> factory, BiFunction<Integer, MachineBuilder<MachineDefinition>, MachineDefinition> builder, int... tiers) {
Expand All @@ -146,6 +148,5 @@ private static MachineDefinition[] registerTieredMachines(String name, BiFunctio
return definitions;
}

public static void init() {
}
public static void init() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class SoulHatchPartMachine extends TieredIOPartMachine {

public SoulHatchPartMachine(IMachineBlockEntity holder, int tier, IO io) {
super(holder, tier, io);
this.soulContainer = new NotifiableSoulContainer(this, io);
this.soulContainer = new NotifiableSoulContainer(this, io, getMaxCapacity(tier), getMaxConsumption(tier));
}

@Override
Expand All @@ -51,6 +51,34 @@ public Widget createUIWidget() {
return group;
}

public static int getMaxCapacity(int tier) {
return switch (tier) {
case GTValues.ZPM -> 10000000;
case GTValues.UV -> 20000000;
case GTValues.UHV -> 50000000;
case GTValues.UEV -> 100000000;
case GTValues.UIV -> 250000000;
case GTValues.UXV -> 500000000;
case GTValues.OpV -> 1000000000;
case GTValues.MAX -> Integer.MAX_VALUE;
default -> 0;
};
}

public static int getMaxConsumption(int tier) {
return switch (tier) {
case GTValues.ZPM -> 5000000;
case GTValues.UV -> 10000000;
case GTValues.UHV -> 25000000;
case GTValues.UEV -> 50000000;
case GTValues.UIV -> 125000000;
case GTValues.UXV -> 250000000;
case GTValues.OpV -> 500000000;
case GTValues.MAX -> Integer.MAX_VALUE;
default -> 0;
};
}

public void attachSoulNetwork(Player player) {
this.soulContainer.setOwner(player.getUUID());
}
Expand Down
Loading

0 comments on commit 252414e

Please sign in to comment.