From 88c80be206bbb22f9cb8a664618a6fb8bbae31a1 Mon Sep 17 00:00:00 2001 From: AViewFromTheTop <87103914+AViewFromTheTop@users.noreply.github.com> Date: Wed, 18 Oct 2023 17:15:42 -0400 Subject: [PATCH] WOOOOOOOOO we don't need that either --- .../frozenblock/wilderwild/entity/Crab.java | 12 ++- .../entity/crab/NaturalSpawnerMixin.java | 88 ------------------- src/main/resources/wilderwild.mixins.json | 1 - 3 files changed, 9 insertions(+), 92 deletions(-) delete mode 100644 src/main/java/net/frozenblock/wilderwild/mixin/entity/crab/NaturalSpawnerMixin.java diff --git a/src/main/java/net/frozenblock/wilderwild/entity/Crab.java b/src/main/java/net/frozenblock/wilderwild/entity/Crab.java index 4105a9d63c..aaae13c59f 100644 --- a/src/main/java/net/frozenblock/wilderwild/entity/Crab.java +++ b/src/main/java/net/frozenblock/wilderwild/entity/Crab.java @@ -68,6 +68,7 @@ import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; +import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.level.LevelReader; import net.minecraft.world.level.ServerLevelAccessor; import net.minecraft.world.level.biome.Biome; @@ -210,7 +211,7 @@ public SpawnGroupData finalizeSpawn(ServerLevelAccessor level, DifficultyInstanc return spawnData; } if (spawnData instanceof CrabGroupData crabGroupData) { - if (crabGroupData.getGroupSize() >= 2 && random.nextFloat() <= 0.4F) { + if (crabGroupData.getGroupSize() >= 2) { this.setAge(-24000); } } else { @@ -234,6 +235,11 @@ public static int getCrabs(@NotNull ServerLevel level) { return count.get(); } + @Override + public float getWalkTargetValue(BlockPos pos, LevelReader level) { + return 0.0f; + } + public static void clearLevelToCrabCount() { CRABS_PER_LEVEL.clear(); } @@ -243,9 +249,9 @@ public static boolean canSpawn(@NotNull EntityType type, @NotNull ServerLe return true; } Holder biome = level.getBiome(pos); - int randomBound = 20; + int randomBound = 1; if (!biome.is(WilderBiomeTags.HAS_COMMON_CRAB)) { - randomBound = 50; + randomBound = 1; if (getCrabs(level.getLevel()) >= type.getCategory().getMaxInstancesPerChunk() / 3) { return false; } diff --git a/src/main/java/net/frozenblock/wilderwild/mixin/entity/crab/NaturalSpawnerMixin.java b/src/main/java/net/frozenblock/wilderwild/mixin/entity/crab/NaturalSpawnerMixin.java deleted file mode 100644 index 23554e21aa..0000000000 --- a/src/main/java/net/frozenblock/wilderwild/mixin/entity/crab/NaturalSpawnerMixin.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright 2023 FrozenBlock - * This file is part of Wilder Wild. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see . - */ - -package net.frozenblock.wilderwild.mixin.entity.crab; - -import com.llamalad7.mixinextras.injector.wrapoperation.Operation; -import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; -import net.minecraft.core.BlockPos; -import net.minecraft.core.Direction; -import net.minecraft.server.level.ServerLevel; -import net.minecraft.world.entity.Mob; -import net.minecraft.world.entity.MobCategory; -import net.minecraft.world.level.NaturalSpawner; -import net.minecraft.world.level.block.Blocks; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.chunk.ChunkAccess; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.At; - -@Mixin(NaturalSpawner.class) -public class NaturalSpawnerMixin { - - @Unique @Nullable - private static BlockPos wilderWild$mutableCrabPos; - - @WrapOperation( - method = "spawnCategoryForPosition(Lnet/minecraft/world/entity/MobCategory;Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/level/chunk/ChunkAccess;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/NaturalSpawner$SpawnPredicate;Lnet/minecraft/world/level/NaturalSpawner$AfterSpawnCallback;)V", - at = @At(value = "INVOKE", target = "Lnet/minecraft/core/BlockPos$MutableBlockPos;set(III)Lnet/minecraft/core/BlockPos$MutableBlockPos;", ordinal = 0) - ) - private static BlockPos.MutableBlockPos wilderWild$spawnCategoryForPosition(BlockPos.MutableBlockPos mutableBlockPos, int x, int y, int z, Operation operation, MobCategory category, ServerLevel level, ChunkAccess chunk, BlockPos pos, NaturalSpawner.SpawnPredicate filter, NaturalSpawner.AfterSpawnCallback callback) { - if (category.getName().equals("wilderwildcrab")) { - wilderWild$mutableCrabPos = wilderWild$findFloorPos(level, x, y, z, 11); - return mutableBlockPos.set(wilderWild$mutableCrabPos.getX(), wilderWild$mutableCrabPos.getY(), wilderWild$mutableCrabPos.getZ()); - } - wilderWild$mutableCrabPos = null; - return operation.call(mutableBlockPos, x, y, z); - } - - @WrapOperation( - method = "spawnCategoryForPosition(Lnet/minecraft/world/entity/MobCategory;Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/level/chunk/ChunkAccess;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/NaturalSpawner$SpawnPredicate;Lnet/minecraft/world/level/NaturalSpawner$AfterSpawnCallback;)V", - at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Mob;moveTo(DDDFF)V", ordinal = 0) - ) - private static void wilderWild$spawnCategoryForPosition(Mob mob, double x, double y, double z, float yRot, float xRot, Operation operation, MobCategory category, ServerLevel level, ChunkAccess chunk, BlockPos pos, NaturalSpawner.SpawnPredicate filter, NaturalSpawner.AfterSpawnCallback callback) { - if (category.getName().equals("wilderwildcrab") && wilderWild$mutableCrabPos != null) { - operation.call(mob, (double) wilderWild$mutableCrabPos.getX(), (double) wilderWild$mutableCrabPos.getY(), (double) wilderWild$mutableCrabPos.getZ(), yRot, xRot); - } else { - operation.call(mob, x, y, z, yRot, xRot); - } - } - - @Unique - @NotNull - private static BlockPos wilderWild$findFloorPos(ServerLevel level, int x, int startY, int z, int maxSearch) { - BlockPos original = new BlockPos(x, startY, z); - BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos(x, startY, z); - BlockPos.MutableBlockPos mutableBlockPosBelow = new BlockPos.MutableBlockPos(x, startY, z).move(Direction.DOWN); - BlockState inBlockState = level.getBlockState(mutableBlockPos); - Direction moveDirection = !(inBlockState.isAir() || inBlockState.is(Blocks.WATER)) ? Direction.UP : Direction.DOWN; - for (int i = 0; i < maxSearch; i++) { - inBlockState = level.getBlockState(mutableBlockPos); - if (level.getBlockState(mutableBlockPosBelow).isSolid() && (inBlockState.isAir() || inBlockState.is(Blocks.WATER))) { - return mutableBlockPos; - } - mutableBlockPos.move(moveDirection); - mutableBlockPosBelow.set(mutableBlockPos).move(Direction.DOWN); - } - return original; - } - -} diff --git a/src/main/resources/wilderwild.mixins.json b/src/main/resources/wilderwild.mixins.json index c649545b11..ed9fc3bb3f 100644 --- a/src/main/resources/wilderwild.mixins.json +++ b/src/main/resources/wilderwild.mixins.json @@ -36,7 +36,6 @@ "entity.boat.BoatDropsMixin", "entity.boat.BoatTypeMixin", "entity.boat.ChestBoatDropsMixin", - "entity.crab.NaturalSpawnerMixin", "entity.crab.VibrationSystemTickerMixin", "entity.crab.WallClimberNavigationMixin", "entity.easter.EntityMixin",