Skip to content

Commit

Permalink
starmetal replacement blockstate (#252)
Browse files Browse the repository at this point in the history
  • Loading branch information
WaitingIdly authored Oct 4, 2024
1 parent be47fbd commit 9ce7d02
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 0 deletions.
2 changes: 2 additions & 0 deletions examples/postInit/astralsorcery.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ mods.astralsorcery.light_transmutation.recipeBuilder()
.register()


mods.astralsorcery.light_transmutation.setStarmetalReplacementState(blockstate('minecraft:clay'))

// Lightwell:
// Converts an input item into fluid, with a chance at breaking every time fluid is produced. The amount of fluid produced
// per interval can be increased via starlight.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.cleanroommc.groovyscript.compat.mods.astralsorcery;

import com.cleanroommc.groovyscript.api.GroovyBlacklist;
import com.cleanroommc.groovyscript.api.GroovyLog;
import com.cleanroommc.groovyscript.api.documentation.annotations.*;
import com.cleanroommc.groovyscript.compat.mods.ModSupport;
Expand All @@ -11,13 +12,21 @@
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.ItemStack;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;

import java.util.Collection;

@RegistryDescription
public class LightTransmutation extends StandardListRegistry<LightOreTransmutations.Transmutation> {

private IBlockState replacementState;

@GroovyBlacklist
public IBlockState getReplacementState() {
return replacementState;
}

@Override
public Collection<LightOreTransmutations.Transmutation> getRecipes() {
if (LightOreTransmutationsAccessor.getRegisteredTransmutations() == null) {
Expand All @@ -26,6 +35,14 @@ public Collection<LightOreTransmutations.Transmutation> getRecipes() {
return LightOreTransmutationsAccessor.getRegisteredTransmutations();
}

@Override
@GroovyBlacklist
@ApiStatus.Internal
public void onReload() {
super.onReload();
replacementState = null;
}

@RecipeBuilderDescription(example = {
@Example(".input(block('minecraft:stone')).output(block('astralsorcery:blockmarble')).cost(100.0).constellation(constellation('armara')).inputDisplayStack(item('minecraft:stone')).outputDisplayStack(item('minecraft:dye:15').withNbt([display:[Name:'Marble']])) "),
@Example(".input(blockstate('minecraft:pumpkin')).output(blockstate('minecraft:diamond_block')).cost(0)")})
Expand Down Expand Up @@ -81,6 +98,11 @@ public void removeByOutput(Block block) {
removeByOutput(block.getDefaultState());
}

@MethodDescription(type = MethodDescription.Type.VALUE, example = @Example("blockstate('minecraft:clay')"))
public void setStarmetalReplacementState(IBlockState state) {
replacementState = state;
}

public static class RecipeBuilder extends AbstractRecipeBuilder<LightOreTransmutations.Transmutation> {

@Property(comp = @Comp(not = "null or input"))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.cleanroommc.groovyscript.core.mixin.astralsorcery;

import com.cleanroommc.groovyscript.compat.mods.ModSupport;
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import hellfirepvp.astralsorcery.common.tile.TileCelestialCrystals;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;

@Mixin(value = TileCelestialCrystals.class, remap = false)
public abstract class TileCelestialCrystalsMixin {

@WrapOperation(method = "update", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/Block;getDefaultState()Lnet/minecraft/block/state/IBlockState;"))
public IBlockState replaceIronOreDowngrade(Block instance, Operation<IBlockState> original) {
var replacementState = ModSupport.ASTRAL_SORCERY.get().lightTransmutation.getReplacementState();
if (replacementState == null) return original.call(instance);
return replacementState;
}

}
1 change: 1 addition & 0 deletions src/main/resources/assets/groovyscript/lang/en_us.lang
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,7 @@ groovyscript.wiki.astralsorcery.light_transmutation.cost.value=Sets the amount o
groovyscript.wiki.astralsorcery.light_transmutation.constellation.value=Sets the required Constellation the starlight must be collected from. Must be either a Major or Weak Constellation
groovyscript.wiki.astralsorcery.light_transmutation.inStack.value=Sets the item representing the input Block or IBlockState in JEI
groovyscript.wiki.astralsorcery.light_transmutation.outStack.value=Sets the item representing the output IBlockState in JEI
groovyscript.wiki.astralsorcery.light_transmutation.setStarmetalReplacementState=Sets the IBlockState that Starmetal Ore is converted into when placed beneath a Celestial Crystal Cluster. Useful when the Light Transmutation recipe converting Iron Ore into Starmetal Ore has changed.

groovyscript.wiki.astralsorcery.lightwell.title=Lightwell
groovyscript.wiki.astralsorcery.lightwell.description=Converts an input item into fluid, with a chance at breaking every time fluid is produced. The amount of fluid produced per interval can be increased via starlight.
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/mixin.groovyscript.astralsorcery.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"PerkLevelManagerMixin",
"PerkTreeAccessor",
"ResearchNodeAccessor",
"TileCelestialCrystalsMixin",
"TraitRecipeAccessor",
"WellLiquefactionAccessor"
]
Expand Down

0 comments on commit 9ce7d02

Please sign in to comment.