diff --git a/gradle.properties b/gradle.properties index 6e63481534..498152c09f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,7 +4,7 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check these on https://fabricmc.net/use # or better: https://modmuss50.me/fabric.html - minecraft_version=22w13a + minecraft_version=22w14a loader_version=0.13.3 fabric_version=0.49.4+1.19 @@ -17,12 +17,12 @@ org.gradle.jvmargs=-Xmx1G # The Curseforge versions "names" or ids for the main branch (comma separated: 1.16.4,1.16.5) # This is needed because CF uses too vague names for prereleases and release candidates # Can also be the version ID directly coming from https://minecraft.curseforge.com/api/game/versions?token=[API_TOKEN] - release-curse-versions = 1.18:1.18.2 + release-curse-versions = Minecraft 1.19:1.19-Snapshot # Whether or not to build another branch on release - release-extra-branch = true + release-extra-branch = false # The name of the second branch to release release-extra-branch-name = future # The "name" or id of the Curseforge version for the secondary branch # This is needed because CF uses too vague names for snapshots # Can also be the version ID directly coming from https://minecraft.curseforge.com/api/game/versions?token=[API_TOKEN] - release-extra-curse-version = 1.19-Snapshot \ No newline at end of file + release-extra-curse-version = Minecraft 1.19:1.19-Snapshot \ No newline at end of file diff --git a/src/main/java/carpet/fakes/CoralFeatureInterface.java b/src/main/java/carpet/fakes/CoralFeatureInterface.java index 9d332f6d40..915d09b322 100644 --- a/src/main/java/carpet/fakes/CoralFeatureInterface.java +++ b/src/main/java/carpet/fakes/CoralFeatureInterface.java @@ -2,10 +2,11 @@ import java.util.Random; import net.minecraft.core.BlockPos; +import net.minecraft.util.RandomSource; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; public interface CoralFeatureInterface { - boolean growSpecific(Level worldIn, Random random, BlockPos pos, BlockState blockUnder); + boolean growSpecific(Level worldIn, RandomSource random, BlockPos pos, BlockState blockUnder); } diff --git a/src/main/java/carpet/helpers/FeatureGenerator.java b/src/main/java/carpet/helpers/FeatureGenerator.java index 4547711dff..5d3056d70c 100644 --- a/src/main/java/carpet/helpers/FeatureGenerator.java +++ b/src/main/java/carpet/helpers/FeatureGenerator.java @@ -24,6 +24,7 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ServerLevel; import net.minecraft.tags.BiomeTags; +import net.minecraft.util.RandomSource; import net.minecraft.util.valueproviders.ConstantInt; import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.biome.Biome; @@ -354,7 +355,7 @@ public static boolean plopAnywhere(Structure structure, ServerLevel world, Block { return false; } - Random rand = new Random(world.getRandom().nextInt()); + RandomSource rand = RandomSource.create(world.getRandom().nextInt()); int j = pos.getX() >> 4; int k = pos.getZ() >> 4; long chId = ChunkPos.asLong(j, k); diff --git a/src/main/java/carpet/helpers/OptimizedExplosion.java b/src/main/java/carpet/helpers/OptimizedExplosion.java index 9f9740d32e..43f17d8aa5 100644 --- a/src/main/java/carpet/helpers/OptimizedExplosion.java +++ b/src/main/java/carpet/helpers/OptimizedExplosion.java @@ -6,6 +6,8 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; + +import net.minecraft.Util; import net.minecraft.core.BlockPos; import net.minecraft.core.particles.ParticleTypes; import net.minecraft.server.level.ServerLevel; @@ -230,7 +232,7 @@ public static void doExplosionB(Explosion e, boolean spawnParticles) if (damagesTerrain) { ObjectArrayList> objectArrayList = new ObjectArrayList<>(); - Collections.shuffle(e.getToBlow(), world.random); + Util.shuffle(e.getToBlow(), world.random); for (BlockPos blockpos : e.getToBlow()) { diff --git a/src/main/java/carpet/mixins/AbstractArrow_extremeMixin.java b/src/main/java/carpet/mixins/AbstractArrow_extremeMixin.java index 85dc7ed8ee..0b7d29b0d4 100644 --- a/src/main/java/carpet/mixins/AbstractArrow_extremeMixin.java +++ b/src/main/java/carpet/mixins/AbstractArrow_extremeMixin.java @@ -1,6 +1,7 @@ package carpet.mixins; import carpet.utils.RandomTools; +import net.minecraft.util.RandomSource; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; @@ -14,9 +15,9 @@ public class AbstractArrow_extremeMixin // calculates damage @Redirect(method = "setEnchantmentEffectsFromEntity", expect = 1, at = @At( value = "INVOKE", - target = "Ljava/util/Random;nextGaussian()D" + target = "Lnet/minecraft/util/RandomSource;nextGaussian()D" )) - private double nextGauBian2(Random random) + private double nextGauBian2(RandomSource random) { return RandomTools.nextGauBian(random); } diff --git a/src/main/java/carpet/mixins/BarrierBlock_updateSuppressionBlockMixin.java b/src/main/java/carpet/mixins/BarrierBlock_updateSuppressionBlockMixin.java index ea9cff3227..c2e44843ba 100644 --- a/src/main/java/carpet/mixins/BarrierBlock_updateSuppressionBlockMixin.java +++ b/src/main/java/carpet/mixins/BarrierBlock_updateSuppressionBlockMixin.java @@ -1,6 +1,7 @@ package carpet.mixins; import carpet.CarpetSettings; +import net.minecraft.util.RandomSource; import org.spongepowered.asm.mixin.Mixin; import java.util.Random; @@ -43,7 +44,7 @@ public void neighborChanged(BlockState state, Level world, BlockPos pos, Block b } @Override - public void tick(BlockState state, ServerLevel world, BlockPos pos, Random random) { + public void tick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) { BlockPos posAbove = pos.above(); BlockState stateAbove = world.getBlockState(posAbove); if (stateAbove.is(Blocks.ACTIVATOR_RAIL) && !stateAbove.getValue(PoweredRailBlock.POWERED)) { diff --git a/src/main/java/carpet/mixins/BlazeAttackGoal_extremeMixin.java b/src/main/java/carpet/mixins/BlazeAttackGoal_extremeMixin.java index 00e2d7726f..946166c9f7 100644 --- a/src/main/java/carpet/mixins/BlazeAttackGoal_extremeMixin.java +++ b/src/main/java/carpet/mixins/BlazeAttackGoal_extremeMixin.java @@ -1,6 +1,7 @@ package carpet.mixins; import carpet.utils.RandomTools; +import net.minecraft.util.RandomSource; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; @@ -12,9 +13,9 @@ public class BlazeAttackGoal_extremeMixin { @Redirect(method = "tick()V", expect = 2, at = @At( value = "INVOKE", - target = "Ljava/util/Random;nextGaussian()D" + target = "Lnet/minecraft/util/RandomSource;nextGaussian()D" )) - private double nextGauBian(Random random) + private double nextGauBian(RandomSource random) { return RandomTools.nextGauBian(random); } diff --git a/src/main/java/carpet/mixins/Blaze_extremeMixin.java b/src/main/java/carpet/mixins/Blaze_extremeMixin.java index 24bc9c7216..d963ce913a 100644 --- a/src/main/java/carpet/mixins/Blaze_extremeMixin.java +++ b/src/main/java/carpet/mixins/Blaze_extremeMixin.java @@ -1,6 +1,7 @@ package carpet.mixins; import carpet.utils.RandomTools; +import net.minecraft.util.RandomSource; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; @@ -14,9 +15,9 @@ public class Blaze_extremeMixin // unused actually @Redirect(method = "customServerAiStep", expect = 1, at = @At( value = "INVOKE", - target = "Ljava/util/Random;nextGaussian()D" + target = "Lnet/minecraft/util/RandomSource;nextGaussian()D" )) - private double nextGauBian(Random random) + private double nextGauBian(RandomSource random) { return RandomTools.nextGauBian(random); } diff --git a/src/main/java/carpet/mixins/Containers_extremeMixin.java b/src/main/java/carpet/mixins/Containers_extremeMixin.java index b7b833a0e7..7486c5e3f1 100644 --- a/src/main/java/carpet/mixins/Containers_extremeMixin.java +++ b/src/main/java/carpet/mixins/Containers_extremeMixin.java @@ -1,6 +1,7 @@ package carpet.mixins; import carpet.utils.RandomTools; +import net.minecraft.util.RandomSource; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; @@ -13,9 +14,9 @@ public class Containers_extremeMixin { @Redirect(method = "dropItemStack(Lnet/minecraft/world/level/Level;DDDLnet/minecraft/world/item/ItemStack;)V", expect = 3, at = @At( value = "INVOKE", - target = "Ljava/util/Random;nextGaussian()D" + target = "Lnet/minecraft/util/RandomSource;nextGaussian()D" )) - private static double nextGauBian(Random random) + private static double nextGauBian(RandomSource random) { return RandomTools.nextGauBian(random); } diff --git a/src/main/java/carpet/mixins/CoralFanBlock_renewableCoralMixin.java b/src/main/java/carpet/mixins/CoralFanBlock_renewableCoralMixin.java index c775e0badf..b19e43c154 100644 --- a/src/main/java/carpet/mixins/CoralFanBlock_renewableCoralMixin.java +++ b/src/main/java/carpet/mixins/CoralFanBlock_renewableCoralMixin.java @@ -8,6 +8,7 @@ import net.minecraft.server.level.ServerLevel; import net.minecraft.tags.BlockTags; import net.minecraft.tags.FluidTags; +import net.minecraft.util.RandomSource; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.BaseCoralPlantTypeBlock; @@ -38,12 +39,12 @@ public boolean isValidBonemealTarget(BlockGetter var1, BlockPos var2, BlockState && var1.getFluidState(var2.above()).is(FluidTags.WATER); } - public boolean isBonemealSuccess(Level var1, Random var2, BlockPos var3, BlockState var4) + public boolean isBonemealSuccess(Level var1, RandomSource var2, BlockPos var3, BlockState var4) { return (double)var1.random.nextFloat() < 0.15D; } - public void performBonemeal(ServerLevel worldIn, Random random, BlockPos pos, BlockState blockUnder) + public void performBonemeal(ServerLevel worldIn, RandomSource random, BlockPos pos, BlockState blockUnder) { CoralFeature coral; diff --git a/src/main/java/carpet/mixins/CoralFeature_renewableCoralMixin.java b/src/main/java/carpet/mixins/CoralFeature_renewableCoralMixin.java index 86a2957beb..f2d3800f82 100644 --- a/src/main/java/carpet/mixins/CoralFeature_renewableCoralMixin.java +++ b/src/main/java/carpet/mixins/CoralFeature_renewableCoralMixin.java @@ -1,6 +1,7 @@ package carpet.mixins; import carpet.fakes.CoralFeatureInterface; +import net.minecraft.util.RandomSource; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -15,10 +16,10 @@ public abstract class CoralFeature_renewableCoralMixin implements CoralFeatureInterface { - @Shadow protected abstract boolean placeFeature(LevelAccessor var1, Random var2, BlockPos var3, BlockState var4); + @Shadow protected abstract boolean placeFeature(LevelAccessor var1, RandomSource var2, BlockPos var3, BlockState var4); @Override - public boolean growSpecific(Level worldIn, Random random, BlockPos pos, BlockState blockUnder) + public boolean growSpecific(Level worldIn, RandomSource random, BlockPos pos, BlockState blockUnder) { return placeFeature(worldIn, random, pos, blockUnder); } diff --git a/src/main/java/carpet/mixins/CoralPlantBlock_renewableCoralMixin.java b/src/main/java/carpet/mixins/CoralPlantBlock_renewableCoralMixin.java index 83e9182fe0..a1051fbcf4 100644 --- a/src/main/java/carpet/mixins/CoralPlantBlock_renewableCoralMixin.java +++ b/src/main/java/carpet/mixins/CoralPlantBlock_renewableCoralMixin.java @@ -4,6 +4,7 @@ import carpet.fakes.CoralFeatureInterface; import net.minecraft.core.Holder; import net.minecraft.core.Registry; +import net.minecraft.util.RandomSource; import org.spongepowered.asm.mixin.Mixin; import java.util.Random; @@ -40,12 +41,12 @@ public boolean isValidBonemealTarget(BlockGetter var1, BlockPos var2, BlockState && var1.getFluidState(var2.above()).is(FluidTags.WATER); } - public boolean isBonemealSuccess(Level var1, Random var2, BlockPos var3, BlockState var4) + public boolean isBonemealSuccess(Level var1, RandomSource var2, BlockPos var3, BlockState var4) { return (double)var1.random.nextFloat() < 0.15D; } - public void performBonemeal(ServerLevel worldIn, Random random, BlockPos pos, BlockState blockUnder) + public void performBonemeal(ServerLevel worldIn, RandomSource random, BlockPos pos, BlockState blockUnder) { CoralFeature coral; diff --git a/src/main/java/carpet/mixins/DefaultDispenseItemBehavior_extremeBehavioursMixin.java b/src/main/java/carpet/mixins/DefaultDispenseItemBehavior_extremeBehavioursMixin.java index 973ac5c436..7d100c9a9f 100644 --- a/src/main/java/carpet/mixins/DefaultDispenseItemBehavior_extremeBehavioursMixin.java +++ b/src/main/java/carpet/mixins/DefaultDispenseItemBehavior_extremeBehavioursMixin.java @@ -1,6 +1,7 @@ package carpet.mixins; import carpet.utils.RandomTools; +import net.minecraft.util.RandomSource; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; @@ -13,9 +14,9 @@ public class DefaultDispenseItemBehavior_extremeBehavioursMixin { @Redirect(method = "spawnItem", expect = 3, at = @At( value = "INVOKE", - target = "Ljava/util/Random;nextGaussian()D" + target = "Lnet/minecraft/util/RandomSource;nextGaussian()D" )) - private static double nextGauBian(Random random) + private static double nextGauBian(RandomSource random) { return RandomTools.nextGauBian(random); } diff --git a/src/main/java/carpet/mixins/ExplosionAccessor.java b/src/main/java/carpet/mixins/ExplosionAccessor.java index 6371192f32..d4ef66ecb8 100644 --- a/src/main/java/carpet/mixins/ExplosionAccessor.java +++ b/src/main/java/carpet/mixins/ExplosionAccessor.java @@ -1,5 +1,6 @@ package carpet.mixins; +import net.minecraft.util.RandomSource; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; @@ -21,7 +22,7 @@ public interface ExplosionAccessor { Level getLevel(); @Accessor - Random getRandom(); + RandomSource getRandom(); @Accessor double getX(); diff --git a/src/main/java/carpet/mixins/FireworkRocketEntity_extremeMixin.java b/src/main/java/carpet/mixins/FireworkRocketEntity_extremeMixin.java index f8b9e9b21f..ea97c3306f 100644 --- a/src/main/java/carpet/mixins/FireworkRocketEntity_extremeMixin.java +++ b/src/main/java/carpet/mixins/FireworkRocketEntity_extremeMixin.java @@ -1,6 +1,7 @@ package carpet.mixins; import carpet.utils.RandomTools; +import net.minecraft.util.RandomSource; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; @@ -13,9 +14,9 @@ public class FireworkRocketEntity_extremeMixin { @Redirect(method = "(Lnet/minecraft/world/level/Level;DDDLnet/minecraft/world/item/ItemStack;)V", expect = 2, at = @At( value = "INVOKE", - target = "Ljava/util/Random;nextGaussian()D" + target = "Lnet/minecraft/util/RandomSource;nextGaussian()D" )) - private double nextGauBian(Random random) + private double nextGauBian(RandomSource random) { return RandomTools.nextGauBian(random); } diff --git a/src/main/java/carpet/mixins/FishingHook_extremeMixin.java b/src/main/java/carpet/mixins/FishingHook_extremeMixin.java index bae9a6922c..93eee61e52 100644 --- a/src/main/java/carpet/mixins/FishingHook_extremeMixin.java +++ b/src/main/java/carpet/mixins/FishingHook_extremeMixin.java @@ -1,6 +1,7 @@ package carpet.mixins; import carpet.utils.RandomTools; +import net.minecraft.util.RandomSource; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; @@ -13,9 +14,9 @@ public class FishingHook_extremeMixin { @Redirect(method = "(Lnet/minecraft/world/entity/player/Player;Lnet/minecraft/world/level/Level;II)V", expect =3, at = @At( value = "INVOKE", - target = "Ljava/util/Random;nextGaussian()D" + target = "Lnet/minecraft/util/RandomSource;nextGaussian()D" )) - private double nextGauBian(Random random) + private double nextGauBian(RandomSource random) { return RandomTools.nextGauBian(random); } diff --git a/src/main/java/carpet/mixins/Mob_extremeMixin.java b/src/main/java/carpet/mixins/Mob_extremeMixin.java index b23d882a85..681e489ad2 100644 --- a/src/main/java/carpet/mixins/Mob_extremeMixin.java +++ b/src/main/java/carpet/mixins/Mob_extremeMixin.java @@ -1,6 +1,7 @@ package carpet.mixins; import carpet.utils.RandomTools; +import net.minecraft.util.RandomSource; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; @@ -13,9 +14,9 @@ public class Mob_extremeMixin { @Redirect(method = "finalizeSpawn", expect = 1, at = @At( value = "INVOKE", - target = "Ljava/util/Random;nextGaussian()D" + target = "Lnet/minecraft/util/RandomSource;nextGaussian()D" )) - private double nextGauBian(Random random) + private double nextGauBian(RandomSource random) { return RandomTools.nextGauBian(random); } diff --git a/src/main/java/carpet/mixins/Projectile_extremeMixin.java b/src/main/java/carpet/mixins/Projectile_extremeMixin.java index 1b0b606fac..724fbe95f3 100644 --- a/src/main/java/carpet/mixins/Projectile_extremeMixin.java +++ b/src/main/java/carpet/mixins/Projectile_extremeMixin.java @@ -1,6 +1,7 @@ package carpet.mixins; import carpet.utils.RandomTools; +import net.minecraft.util.RandomSource; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; @@ -13,9 +14,9 @@ public class Projectile_extremeMixin { @Redirect(method = "shoot", expect = 3, at = @At( //TODO make sure it's correct after mojmap value = "INVOKE", - target = "Ljava/util/Random;nextGaussian()D" + target = "Lnet/minecraft/util/RandomSource;nextGaussian()D" )) - private double nextGauBian(Random random) + private double nextGauBian(RandomSource random) { return RandomTools.nextGauBian(random); } diff --git a/src/main/java/carpet/mixins/SaplingBlock_desertShrubsMixin.java b/src/main/java/carpet/mixins/SaplingBlock_desertShrubsMixin.java index d725871616..b6ba5cc65c 100644 --- a/src/main/java/carpet/mixins/SaplingBlock_desertShrubsMixin.java +++ b/src/main/java/carpet/mixins/SaplingBlock_desertShrubsMixin.java @@ -1,6 +1,7 @@ package carpet.mixins; import carpet.CarpetSettings; +import net.minecraft.util.RandomSource; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; @@ -22,9 +23,9 @@ public abstract class SaplingBlock_desertShrubsMixin { @Inject(method = "advanceTree", at = @At(value = "INVOKE", shift = At.Shift.BEFORE, - target = "Lnet/minecraft/world/level/block/grower/AbstractTreeGrower;growTree(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/level/chunk/ChunkGenerator;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;Ljava/util/Random;)Z"), + target = "Lnet/minecraft/world/level/block/grower/AbstractTreeGrower;growTree(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/level/chunk/ChunkGenerator;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/util/RandomSource;)Z"), cancellable = true) - private void onGenerate(ServerLevel level, BlockPos pos, BlockState blockState, Random random, CallbackInfo ci) + private void onGenerate(ServerLevel level, BlockPos pos, BlockState blockState, RandomSource random, CallbackInfo ci) { if (CarpetSettings.desertShrubs && level.getBiome(pos).is(BiomeTags.HAS_DESERT_PYRAMID) && !nearWater(level, pos)) { diff --git a/src/main/java/carpet/mixins/SkeletonTrapGoal_extremeMixin.java b/src/main/java/carpet/mixins/SkeletonTrapGoal_extremeMixin.java index a1cf912685..ca52240144 100644 --- a/src/main/java/carpet/mixins/SkeletonTrapGoal_extremeMixin.java +++ b/src/main/java/carpet/mixins/SkeletonTrapGoal_extremeMixin.java @@ -1,6 +1,7 @@ package carpet.mixins; import carpet.utils.RandomTools; +import net.minecraft.util.RandomSource; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; @@ -13,9 +14,9 @@ public class SkeletonTrapGoal_extremeMixin { @Redirect(method = "tick", expect = 2, at = @At( value = "INVOKE", - target = "Ljava/util/Random;nextGaussian()D" + target = "Lnet/minecraft/util/RandomSource;nextGaussian()D" )) - private double nextGauBian(Random random) + private double nextGauBian(RandomSource random) { return RandomTools.nextGauBian(random); } diff --git a/src/main/java/carpet/mixins/StructureBlockEntity_fillUpdatesMixin.java b/src/main/java/carpet/mixins/StructureBlockEntity_fillUpdatesMixin.java index 568609d92c..ce251de400 100644 --- a/src/main/java/carpet/mixins/StructureBlockEntity_fillUpdatesMixin.java +++ b/src/main/java/carpet/mixins/StructureBlockEntity_fillUpdatesMixin.java @@ -1,6 +1,7 @@ package carpet.mixins; import carpet.CarpetSettings; +import net.minecraft.util.RandomSource; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; @@ -17,15 +18,15 @@ public abstract class StructureBlockEntity_fillUpdatesMixin { @Redirect(method = "Lnet/minecraft/world/level/block/entity/StructureBlockEntity;loadStructure(Lnet/minecraft/server/level/ServerLevel;ZLnet/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate;)Z", at = @At( value = "INVOKE", - target = "Lnet/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate;placeInWorld(Lnet/minecraft/world/level/ServerLevelAccessor;Lnet/minecraft/core/BlockPos;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/levelgen/structure/templatesystem/StructurePlaceSettings;Ljava/util/Random;I)Z" + target = "Lnet/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate;placeInWorld(Lnet/minecraft/world/level/ServerLevelAccessor;Lnet/minecraft/core/BlockPos;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/levelgen/structure/templatesystem/StructurePlaceSettings;Lnet/minecraft/util/RandomSource;I)Z" )) - private boolean onStructurePlacen(StructureTemplate structure, ServerLevelAccessor serverWorldAccess, BlockPos pos, BlockPos blockPos, StructurePlaceSettings placementData, Random random, int i) + private boolean onStructurePlacen(StructureTemplate structure, ServerLevelAccessor serverWorldAccess, BlockPos pos, BlockPos blockPos, StructurePlaceSettings placementData, RandomSource random, int i) { if(!CarpetSettings.fillUpdates) CarpetSettings.impendingFillSkipUpdates.set(true); try { - return structure.placeInWorld(serverWorldAccess, pos, blockPos, placementData, random, i); // serverWorldAccess, pos, placementData, random); + return structure.placeInWorld(serverWorldAccess, pos, blockPos, placementData, random, i); } finally { diff --git a/src/main/java/carpet/mixins/StructureTemplate_fillUpdatesMixin.java b/src/main/java/carpet/mixins/StructureTemplate_fillUpdatesMixin.java index 572f6d3e6b..bd9cbb44d6 100644 --- a/src/main/java/carpet/mixins/StructureTemplate_fillUpdatesMixin.java +++ b/src/main/java/carpet/mixins/StructureTemplate_fillUpdatesMixin.java @@ -13,7 +13,7 @@ @Mixin(StructureTemplate.class) public class StructureTemplate_fillUpdatesMixin { - @Redirect( method = "placeInWorld(Lnet/minecraft/world/level/ServerLevelAccessor;Lnet/minecraft/core/BlockPos;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/levelgen/structure/templatesystem/StructurePlaceSettings;Ljava/util/Random;I)Z", at = @At( + @Redirect( method = "placeInWorld", at = @At( value = "INVOKE", target = "Lnet/minecraft/world/level/ServerLevelAccessor;blockUpdated(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/Block;)V" )) @@ -23,7 +23,7 @@ private void skipUpdateNeighbours(ServerLevelAccessor serverWorldAccess, BlockPo serverWorldAccess.blockUpdated(pos, block); } - @Redirect(method = "placeInWorld(Lnet/minecraft/world/level/ServerLevelAccessor;Lnet/minecraft/core/BlockPos;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/levelgen/structure/templatesystem/StructurePlaceSettings;Ljava/util/Random;I)Z", at = @At( + @Redirect(method = "placeInWorld", at = @At( value = "INVOKE", target = "Lnet/minecraft/world/level/levelgen/structure/templatesystem/StructurePlaceSettings;getKnownShape()Z" )) diff --git a/src/main/java/carpet/mixins/WitherBoss_extremeMixin.java b/src/main/java/carpet/mixins/WitherBoss_extremeMixin.java index 2d07fbd112..4a4de497ec 100644 --- a/src/main/java/carpet/mixins/WitherBoss_extremeMixin.java +++ b/src/main/java/carpet/mixins/WitherBoss_extremeMixin.java @@ -2,6 +2,7 @@ import carpet.CarpetSettings; +import net.minecraft.util.RandomSource; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; @@ -14,9 +15,9 @@ public class WitherBoss_extremeMixin { @Redirect(method = "performRangedAttack(ILnet/minecraft/world/entity/LivingEntity;)V", at = @At( value = "INVOKE", - target = "Ljava/util/Random;nextFloat()F") + target = "Lnet/minecraft/util/RandomSource;nextFloat()F") ) - private float nextFloatAmplfied(Random random) + private float nextFloatAmplfied(RandomSource random) { if (CarpetSettings.extremeBehaviours) return random.nextFloat()/100; return random.nextFloat(); diff --git a/src/main/java/carpet/script/api/Auxiliary.java b/src/main/java/carpet/script/api/Auxiliary.java index 2703f8ebb6..19185ff978 100644 --- a/src/main/java/carpet/script/api/Auxiliary.java +++ b/src/main/java/carpet/script/api/Auxiliary.java @@ -164,10 +164,11 @@ public static void apply(Expression expression) Vec3 vec = locator.vec; double d0 = Math.pow(volume > 1.0F ? (double)(volume * 16.0F) : 16.0D, 2.0D); int count = 0; + long seed = cc.s.getLevel().getRandom().nextLong(); for (ServerPlayer player : cc.s.getLevel().getPlayers( (p) -> p.distanceToSqr(vec) < d0)) { count++; - player.connection.send(new ClientboundCustomSoundPacket(soundName, mixer, vec, volume, pitch)); + player.connection.send(new ClientboundCustomSoundPacket(soundName, mixer, vec, volume, pitch, seed)); } return new NumericValue(count); }); diff --git a/src/main/java/carpet/script/utils/ShapeDispatcher.java b/src/main/java/carpet/script/utils/ShapeDispatcher.java index fea54e7632..a67d976a51 100644 --- a/src/main/java/carpet/script/utils/ShapeDispatcher.java +++ b/src/main/java/carpet/script/utils/ShapeDispatcher.java @@ -39,6 +39,7 @@ import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.util.Mth; +import net.minecraft.util.RandomSource; import net.minecraft.world.entity.Entity; import net.minecraft.world.level.Level; import net.minecraft.world.phys.Vec3; @@ -716,7 +717,7 @@ public Consumer alternative() { return p -> { ParticleOptions particle = replacementParticle(); int partno = Math.min(1000,20*subdivisions); - Random rand = p.level.getRandom(); + RandomSource rand = p.level.getRandom(); ServerLevel world = p.getLevel(); Vec3 ccenter = relativiseRender(world, center, 0 ); @@ -794,7 +795,7 @@ public Consumer alternative() { return p -> { ParticleOptions particle = replacementParticle(); int partno = (int)Math.min(1000,Math.sqrt(20*subdivisions*(1+height))); - Random rand = p.level.getRandom(); + RandomSource rand = p.level.getRandom(); ServerLevel world = p.getLevel(); Vec3 ccenter = relativiseRender(world, center, 0 ); @@ -1312,7 +1313,7 @@ public static int drawParticleLine(List players, ParticleOptions p int pcount = 0; if (distance < 100) { - Random rand = players.get(0).level.random; + RandomSource rand = players.get(0).level.random; int particles = (int)(distance/density)+1; Vec3 towards = to.subtract(from); for (int i = 0; i < particles; i++) diff --git a/src/main/java/carpet/utils/RandomTools.java b/src/main/java/carpet/utils/RandomTools.java index 0cfb442ccd..4d0a9348a1 100644 --- a/src/main/java/carpet/utils/RandomTools.java +++ b/src/main/java/carpet/utils/RandomTools.java @@ -1,12 +1,11 @@ package carpet.utils; import carpet.CarpetSettings; - -import java.util.Random; +import net.minecraft.util.RandomSource; public class RandomTools { - public static double nextGauBian(Random random) + public static double nextGauBian(RandomSource random) { if (CarpetSettings.extremeBehaviours) {