Skip to content

Commit

Permalink
fix: Fix client API usage in serverside code
Browse files Browse the repository at this point in the history
  • Loading branch information
Steveplays28 committed May 31, 2024
1 parent 158bafa commit b4790d4
Showing 1 changed file with 18 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package io.github.steveplays28.simpleseasons.mixin;

import io.github.steveplays28.simpleseasons.api.SimpleSeasonsApi;
import io.github.steveplays28.simpleseasons.state.SeasonTracker;
import io.github.steveplays28.simpleseasons.client.SimpleSeasonsClient;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.StructureWorldAccess;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
import net.minecraft.world.gen.feature.FreezeTopLayerFeature;
import net.minecraft.world.gen.feature.util.FeatureContext;
import org.jetbrains.annotations.NotNull;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
Expand All @@ -17,12 +18,24 @@
@Mixin(FreezeTopLayerFeature.class)
public class FreezeTopLayerFeatureMixin {
@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/world/StructureWorldAccess;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z", ordinal = 0), method = "generate", locals = LocalCapture.CAPTURE_FAILSOFT, cancellable = true)
public void setMeltableIce(FeatureContext<DefaultFeatureConfig> context, CallbackInfoReturnable<Boolean> cir, StructureWorldAccess structureWorldAccess, BlockPos blockPos, BlockPos.Mutable mutable, BlockPos.Mutable mutable2, int i, int j, int k, int l, int m, Biome biome) {
cir.setReturnValue(SimpleSeasonsClient.seasonTracker.getSeason().getId() != SeasonTracker.Seasons.WINTER.ordinal());
public void setMeltableIce(
@NotNull FeatureContext<DefaultFeatureConfig> context, @NotNull CallbackInfoReturnable<Boolean> cir,
@NotNull StructureWorldAccess structureWorldAccess, @NotNull BlockPos blockPos,
@NotNull BlockPos.Mutable mutable, @NotNull BlockPos.Mutable mutable2,
int i, int j, int k, int l, int m, @NotNull Biome biome
) {
cir.setReturnValue(
SimpleSeasonsApi.getSeason(structureWorldAccess.toServerWorld()).getId() != SeasonTracker.Seasons.WINTER.ordinal());
}

@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/world/StructureWorldAccess;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z", ordinal = 1), method = "generate", locals = LocalCapture.CAPTURE_FAILSOFT, cancellable = true)
public void setMeltableSnow(FeatureContext<DefaultFeatureConfig> context, CallbackInfoReturnable<Boolean> cir, StructureWorldAccess structureWorldAccess, BlockPos blockPos, BlockPos.Mutable mutable, BlockPos.Mutable mutable2, int i, int j, int k, int l, int m, Biome biome) {
cir.setReturnValue(SimpleSeasonsClient.seasonTracker.getSeason().getId() != SeasonTracker.Seasons.WINTER.ordinal());
public void setMeltableSnow(
@NotNull FeatureContext<DefaultFeatureConfig> context, @NotNull CallbackInfoReturnable<Boolean> cir,
@NotNull StructureWorldAccess structureWorldAccess, @NotNull BlockPos blockPos,
@NotNull BlockPos.Mutable mutable, @NotNull BlockPos.Mutable mutable2,
int i, int j, int k, int l, int m, @NotNull Biome biome
) {
cir.setReturnValue(
SimpleSeasonsApi.getSeason(structureWorldAccess.toServerWorld()).getId() != SeasonTracker.Seasons.WINTER.ordinal());
}
}

0 comments on commit b4790d4

Please sign in to comment.