generated from FabricMC/fabric-example-mod
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
159 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../incubus_core/mixin/BlockEntityMixin.java → ...s_core/mixin/entity/BlockEntityMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../incubus_core/mixin/NameDisplayMixin.java → ...s_core/mixin/entity/NameDisplayMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...d/incubus_core/mixin/ServerTickMixin.java → ...bus_core/mixin/world/ServerTickMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
src/main/java/net/id/incubus_core/mixin/world/biome/source/MultiNoiseBiomeSourceMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package net.id.incubus_core.mixin.world.biome.source; | ||
|
||
import com.mojang.serialization.MapCodec; | ||
import com.mojang.serialization.codecs.PrimitiveCodec; | ||
import net.id.incubus_core.util.SeedSupplier; | ||
import net.minecraft.world.biome.source.MultiNoiseBiomeSource; | ||
import org.objectweb.asm.Opcodes; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Unique; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.ModifyVariable; | ||
import org.spongepowered.asm.mixin.injection.Redirect; | ||
|
||
@Mixin(MultiNoiseBiomeSource.class) | ||
public abstract class MultiNoiseBiomeSourceMixin { | ||
/*This doesn't seem to exist in 1.18... | ||
@Unique private static long LAST_SEED = SeedSupplier.MARKER; | ||
@Redirect( | ||
method = "method_38172(Lcom/mojang/serialization/codecs/RecordCodecBuilder$Instance;)Lcom/mojang/datafixers/kinds/App;", | ||
at = @At( | ||
value = "INVOKE", | ||
target = "Lcom/mojang/serialization/codecs/PrimitiveCodec;fieldOf(Ljava/lang/String;)Lcom/mojang/serialization/MapCodec;", | ||
ordinal = 0 | ||
) | ||
) | ||
private static MapCodec<Long> giveUsRandomSeeds(PrimitiveCodec<Long> codec, final String name) { | ||
return codec.fieldOf(name).orElseGet(SeedSupplier::getSeed); | ||
} | ||
@ModifyVariable( | ||
method = "<init>(JLnet/minecraft/class_6452$class_6455;Lnet/minecraft/world/biome/source/MultiNoiseBiomeSource$NoiseParameters;Lnet/minecraft/world/biome/source/MultiNoiseBiomeSource$NoiseParameters;Lnet/minecraft/world/biome/source/MultiNoiseBiomeSource$NoiseParameters;Lnet/minecraft/world/biome/source/MultiNoiseBiomeSource$NoiseParameters;Lnet/minecraft/world/biome/source/MultiNoiseBiomeSource$NoiseParameters;IIZLjava/util/Optional;)V", | ||
at = @At( | ||
value = "FIELD", | ||
target = "Lnet/minecraft/world/biome/source/MultiNoiseBiomeSource;field_34194:Lnet/minecraft/class_6466;", | ||
opcode = Opcodes.PUTFIELD, | ||
shift = At.Shift.AFTER | ||
), | ||
ordinal = 0 | ||
) | ||
private long replaceSeed(long seed) { | ||
if (seed == SeedSupplier.MARKER) { | ||
return LAST_SEED; | ||
} else { | ||
LAST_SEED = seed; | ||
} | ||
return seed; | ||
} | ||
*/ | ||
} |
31 changes: 31 additions & 0 deletions
31
src/main/java/net/id/incubus_core/mixin/world/gen/GeneratorOptionsMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package net.id.incubus_core.mixin.world.gen; | ||
|
||
import com.mojang.serialization.MapCodec; | ||
import com.mojang.serialization.codecs.PrimitiveCodec; | ||
import dev.hephaestus.seedy.SeedSupplier; | ||
import net.minecraft.util.registry.SimpleRegistry; | ||
import net.minecraft.world.dimension.DimensionOptions; | ||
import net.minecraft.world.gen.GeneratorOptions; | ||
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.Redirect; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
import java.util.Optional; | ||
|
||
@Mixin(GeneratorOptions.class) | ||
public abstract class GeneratorOptionsMixin { | ||
// private static synthetic method_28606(Lcom/mojang/serialization/codecs/RecordCodecBuilder$Instance;)Lcom/mojang/datafixers/kinds/App; | ||
@Redirect( | ||
method = "method_28606(Lcom/mojang/serialization/codecs/RecordCodecBuilder$Instance;)Lcom/mojang/datafixers/kinds/App;", | ||
at = @At( | ||
value = "INVOKE", | ||
target = "Lcom/mojang/serialization/codecs/PrimitiveCodec;fieldOf(Ljava/lang/String;)Lcom/mojang/serialization/MapCodec;", | ||
ordinal = 0 | ||
) | ||
) | ||
private static MapCodec<Long> giveUsRandomSeeds(PrimitiveCodec<Long> codec, final String name) { | ||
return codec.fieldOf(name).orElseGet(SeedSupplier::getSeed); | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
src/main/java/net/id/incubus_core/mixin/world/gen/chunk/NoiseChunkGeneratorMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package net.id.incubus_core.mixin.world.gen.chunk; | ||
|
||
import com.mojang.serialization.MapCodec; | ||
import com.mojang.serialization.codecs.PrimitiveCodec; | ||
import dev.hephaestus.seedy.SeedSupplier; | ||
import net.minecraft.world.biome.source.BiomeSource; | ||
import net.minecraft.world.gen.chunk.ChunkGenerator; | ||
import net.minecraft.world.gen.chunk.NoiseChunkGenerator; | ||
import net.minecraft.world.gen.chunk.StructuresConfig; | ||
import org.objectweb.asm.Opcodes; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Unique; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.ModifyVariable; | ||
import org.spongepowered.asm.mixin.injection.Redirect; | ||
|
||
@Mixin(NoiseChunkGenerator.class) | ||
public abstract class NoiseChunkGeneratorMixin extends ChunkGenerator { | ||
@Unique private static long LAST_SEED = SeedSupplier.MARKER; | ||
|
||
public NoiseChunkGeneratorMixin(BiomeSource biomeSource, StructuresConfig structuresConfig) { | ||
super(biomeSource, structuresConfig); | ||
} | ||
|
||
@Redirect( | ||
method = "method_28550(Lcom/mojang/serialization/codecs/RecordCodecBuilder$Instance;)Lcom/mojang/datafixers/kinds/App;", | ||
at = @At( | ||
value = "INVOKE", | ||
target = "Lcom/mojang/serialization/codecs/PrimitiveCodec;fieldOf(Ljava/lang/String;)Lcom/mojang/serialization/MapCodec;", | ||
ordinal = 0 | ||
) | ||
) | ||
private static MapCodec<Long> giveUsRandomSeeds(PrimitiveCodec<Long> codec, final String name) { | ||
return codec.fieldOf(name).orElseGet(SeedSupplier::getSeed); | ||
} | ||
|
||
@ModifyVariable( | ||
method = "<init>(Lnet/minecraft/util/registry/Registry;Lnet/minecraft/world/biome/source/BiomeSource;Lnet/minecraft/world/biome/source/BiomeSource;JLjava/util/function/Supplier;)V", | ||
at = @At( | ||
value = "FIELD", | ||
target = "Lnet/minecraft/world/gen/chunk/NoiseChunkGenerator;seed:J", | ||
opcode = Opcodes.PUTFIELD, | ||
shift = At.Shift.AFTER | ||
), | ||
ordinal = 0, | ||
argsOnly = true | ||
) | ||
private long replaceSeed(long seed) { | ||
if (seed == SeedSupplier.MARKER) { | ||
return LAST_SEED; | ||
} else { | ||
LAST_SEED = seed; | ||
} | ||
|
||
return seed; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package net.id.incubus_core.util; | ||
|
||
public class SeedSupplier { | ||
public static final long MARKER = -1; | ||
|
||
public static long getSeed() { | ||
return MARKER; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters