diff --git a/src/main/java/net/frozenblock/wilderwild/block/CoconutBlock.java b/src/main/java/net/frozenblock/wilderwild/block/CoconutBlock.java index eec1e39922..856633fa05 100644 --- a/src/main/java/net/frozenblock/wilderwild/block/CoconutBlock.java +++ b/src/main/java/net/frozenblock/wilderwild/block/CoconutBlock.java @@ -255,7 +255,7 @@ public void tick(@NotNull BlockState state, @NotNull ServerLevel level, @NotNull @Override public void onLand(@NotNull Level level, @NotNull BlockPos pos, @NotNull BlockState state, @NotNull BlockState replaceableState, @NotNull FallingBlockEntity fallingBlock) { if (!level.isClientSide) { - level.setBlock(pos, replaceableState, UPDATE_ALL); + level.setBlockAndUpdate(pos, replaceableState); } } diff --git a/src/main/java/net/frozenblock/wilderwild/block/GeyserBlock.java b/src/main/java/net/frozenblock/wilderwild/block/GeyserBlock.java index 0622d4f691..631fd1183c 100644 --- a/src/main/java/net/frozenblock/wilderwild/block/GeyserBlock.java +++ b/src/main/java/net/frozenblock/wilderwild/block/GeyserBlock.java @@ -141,7 +141,7 @@ protected void neighborChanged(BlockState blockState, @NotNull Level level, Bloc newState = newState.setValue(GEYSER_STAGE, GeyserStage.ERUPTING); } } - level.setBlock(blockPos, newState, UPDATE_ALL); + level.setBlockAndUpdate(blockPos, newState); } } } @@ -187,7 +187,7 @@ public static GeyserType getGeyserTypeForPos(@NotNull LevelAccessor level, @NotN public void tick(@NotNull BlockState state, @NotNull ServerLevel level, @NotNull BlockPos pos, @NotNull RandomSource random) { GeyserType geyserType = getGeyserTypeForPos(level, state, pos); if (geyserType != state.getValue(GEYSER_TYPE)) { - level.setBlock(pos, state.setValue(GEYSER_TYPE, geyserType), UPDATE_ALL); + level.setBlockAndUpdate(pos, state.setValue(GEYSER_TYPE, geyserType)); } } diff --git a/src/main/java/net/frozenblock/wilderwild/block/HangingTendrilBlock.java b/src/main/java/net/frozenblock/wilderwild/block/HangingTendrilBlock.java index 518dc3079c..915112d535 100644 --- a/src/main/java/net/frozenblock/wilderwild/block/HangingTendrilBlock.java +++ b/src/main/java/net/frozenblock/wilderwild/block/HangingTendrilBlock.java @@ -92,7 +92,7 @@ public HangingTendrilBlock(@NotNull Properties settings) { } public static void deactivate(@NotNull Level level, @NotNull BlockPos pos, @NotNull BlockState state, RandomSource random) { - level.setBlock(pos, state.setValue(PHASE, SculkSensorPhase.INACTIVE).setValue(POWER, 0), UPDATE_ALL); + level.setBlockAndUpdate(pos, state.setValue(PHASE, SculkSensorPhase.INACTIVE).setValue(POWER, 0)); if (!state.getValue(WATERLOGGED)) { level.playSound(null, pos, WWSounds.BLOCK_HANGING_TENDRIL_CLICKING_STOP, SoundSource.BLOCKS, 1F, random.nextFloat() * 0.2F + 0.8F); } @@ -233,7 +233,7 @@ public void activate( int power, int frequency ) { - level.setBlock(pos, state.setValue(PHASE, SculkSensorPhase.ACTIVE).setValue(POWER, power), UPDATE_ALL); + level.setBlockAndUpdate(pos, state.setValue(PHASE, SculkSensorPhase.ACTIVE).setValue(POWER, power)); boolean tendrilsCarryEvents = WWBlockConfig.get().sculk.tendrilsCarryEvents; SculkSensorBlock.updateNeighbours(level, pos, state); SculkSensorBlock.tryResonateVibration(tendrilsCarryEvents ? entity : null, level, pos, frequency); diff --git a/src/main/java/net/frozenblock/wilderwild/block/IcicleBlock.java b/src/main/java/net/frozenblock/wilderwild/block/IcicleBlock.java index fa59a62919..9d21b36b17 100644 --- a/src/main/java/net/frozenblock/wilderwild/block/IcicleBlock.java +++ b/src/main/java/net/frozenblock/wilderwild/block/IcicleBlock.java @@ -20,6 +20,10 @@ import com.google.common.annotations.VisibleForTesting; import com.mojang.serialization.MapCodec; +import java.util.Iterator; +import java.util.Optional; +import java.util.function.BiPredicate; +import java.util.function.Predicate; import net.frozenblock.wilderwild.block.entity.IcicleBlockEntity; import net.frozenblock.wilderwild.block.impl.SnowloggingUtils; import net.frozenblock.wilderwild.registry.WWBlockEntityTypes; @@ -69,10 +73,6 @@ import net.minecraft.world.phys.shapes.VoxelShape; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.Iterator; -import java.util.Optional; -import java.util.function.BiPredicate; -import java.util.function.Predicate; public class IcicleBlock extends BaseEntityBlock implements Fallable, SimpleWaterloggedBlock { public static final MapCodec CODEC = simpleCodec(IcicleBlock::new); diff --git a/src/main/java/net/frozenblock/wilderwild/block/ScorchedBlock.java b/src/main/java/net/frozenblock/wilderwild/block/ScorchedBlock.java index 4a97265e15..2a68691e1c 100644 --- a/src/main/java/net/frozenblock/wilderwild/block/ScorchedBlock.java +++ b/src/main/java/net/frozenblock/wilderwild/block/ScorchedBlock.java @@ -87,7 +87,7 @@ public static boolean canScorch(@NotNull BlockState state) { public static void scorch(@NotNull BlockState state, @NotNull Level level, @NotNull BlockPos pos) { state = stateWithoutDusting(state); if (canScorch(state)) { - level.setBlock(pos, SCORCH_MAP.get(state), UPDATE_ALL); + level.setBlockAndUpdate(pos, SCORCH_MAP.get(state)); level.gameEvent(null, GameEvent.BLOCK_CHANGE, pos); } } diff --git a/src/main/java/net/frozenblock/wilderwild/block/WilderBushBlock.java b/src/main/java/net/frozenblock/wilderwild/block/WilderBushBlock.java index 7ec172d812..598f85e842 100644 --- a/src/main/java/net/frozenblock/wilderwild/block/WilderBushBlock.java +++ b/src/main/java/net/frozenblock/wilderwild/block/WilderBushBlock.java @@ -269,7 +269,14 @@ public BlockState playerWillDestroy(@NotNull Level level, @NotNull BlockPos pos, } @Override - public void playerDestroy(@NotNull Level level, @NotNull Player player, @NotNull BlockPos pos, @NotNull BlockState state, @Nullable BlockEntity blockEntity, @NotNull ItemStack stack) { + public void playerDestroy( + @NotNull Level level, + @NotNull Player player, + @NotNull BlockPos pos, + @NotNull BlockState state, + @Nullable BlockEntity blockEntity, + @NotNull ItemStack stack + ) { if (SnowloggingUtils.isSnowlogged(state)) { BlockState snowEquivalent = SnowloggingUtils.getSnowEquivalent(state); if (player.hasCorrectToolForDrops(snowEquivalent)) { @@ -300,13 +307,13 @@ public BlockState setAgeOnBothHalves(@NotNull BlockState state, @NotNull Level l public void removeTopHalfIfYoung(@NotNull BlockState state, @NotNull Level level, @NotNull BlockPos pos) { if (state.is(this) && !isLower(state) && !isFullyGrown(state)) { - level.setBlock(pos, level.getFluidState(pos).createLegacyBlock(), UPDATE_ALL); + level.setBlockAndUpdate(pos, level.getFluidState(pos).createLegacyBlock()); return; } BlockPos movedPos = pos.above(); BlockState secondState = level.getBlockState(movedPos); if (secondState.is(this) && !isLower(secondState) && !isFullyGrown(secondState)) { - level.setBlock(movedPos, level.getFluidState(movedPos).createLegacyBlock(), UPDATE_ALL); + level.setBlockAndUpdate(movedPos, level.getFluidState(movedPos).createLegacyBlock()); } } } diff --git a/src/main/java/net/frozenblock/wilderwild/block/entity/GeyserBlockEntity.java b/src/main/java/net/frozenblock/wilderwild/block/entity/GeyserBlockEntity.java index 6a936f9e8e..db19ebf7f0 100644 --- a/src/main/java/net/frozenblock/wilderwild/block/entity/GeyserBlockEntity.java +++ b/src/main/java/net/frozenblock/wilderwild/block/entity/GeyserBlockEntity.java @@ -55,7 +55,6 @@ import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.Level; import net.minecraft.world.level.LevelAccessor; -import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.LevelEvent; import net.minecraft.world.level.block.SupportType; import net.minecraft.world.level.block.entity.BlockEntity; @@ -336,7 +335,7 @@ public void setDormant(Level level, BlockPos pos, BlockState state, RandomSource } public void setStageAndCooldown(@NotNull Level level, BlockPos pos, @NotNull BlockState state, GeyserStage geyserStage, RandomSource random) { - level.setBlock(pos, state.setValue(GeyserBlock.GEYSER_STAGE, geyserStage), Block.UPDATE_ALL); + level.setBlockAndUpdate(pos, state.setValue(GeyserBlock.GEYSER_STAGE, geyserStage)); if (geyserStage == GeyserStage.ACTIVE) { this.ticksUntilNextEvent = random.nextInt(MIN_ACTIVE_TICKS, MAX_ACTIVE_TICKS); } else if (geyserStage != GeyserStage.ERUPTING) { // Eruption duration is set in serverTick to work with Redstone properly diff --git a/src/main/java/net/frozenblock/wilderwild/block/entity/ScorchedBlockEntity.java b/src/main/java/net/frozenblock/wilderwild/block/entity/ScorchedBlockEntity.java index 840638b171..4fea95b6e2 100644 --- a/src/main/java/net/frozenblock/wilderwild/block/entity/ScorchedBlockEntity.java +++ b/src/main/java/net/frozenblock/wilderwild/block/entity/ScorchedBlockEntity.java @@ -30,6 +30,7 @@ import org.jetbrains.annotations.NotNull; public class ScorchedBlockEntity extends BlockEntity { + private static final int RESET_DELAY = 40; private int brushCount; private long brushCountResetsAtTick; private long coolDownEndsAtTick; @@ -39,7 +40,7 @@ public ScorchedBlockEntity(@NotNull BlockPos blockPos, @NotNull BlockState block } public boolean brush(long l) { - this.brushCountResetsAtTick = l + 40L; + this.brushCountResetsAtTick = l + RESET_DELAY; if (l < this.coolDownEndsAtTick || !(this.level instanceof ServerLevel)) { return false; } @@ -49,20 +50,18 @@ public boolean brush(long l) { this.brushingCompleted(); return true; } - this.level.scheduleTick(this.getBlockPos(), this.getBlockState().getBlock(), 40); - int j = this.getCompletionState(); - if (i != j) { + this.level.scheduleTick(this.getBlockPos(), this.getBlockState().getBlock(), RESET_DELAY); + int completionState = this.getCompletionState(); + if (i != completionState) { BlockState blockState = this.getBlockState(); - BlockState blockState2 = blockState.setValue(BlockStateProperties.DUSTED, j); - this.level.setBlock(this.getBlockPos(), blockState2, 3); + BlockState blockState2 = blockState.setValue(BlockStateProperties.DUSTED, completionState); + this.level.setBlockAndUpdate(this.getBlockPos(), blockState2); } return false; } private void brushingCompleted() { - if (this.level == null || this.level.getServer() == null) { - return; - } + if (this.level == null || this.level.getServer() == null) return; this.level.levelEvent(LevelEvent.PARTICLES_AND_SOUND_BRUSH_BLOCK_COMPLETE, this.worldPosition, Block.getId(this.getBlockState())); ScorchedBlock.hydrate(this.getBlockState(), this.level, this.worldPosition); this.brushCount = 0; @@ -79,7 +78,7 @@ public void checkReset() { this.brushCount = Math.max(0, this.brushCount - 2); int j = this.getCompletionState(); if (i != j) { - this.level.setBlock(this.getBlockPos(), this.getBlockState().setValue(BlockStateProperties.DUSTED, j), Block.UPDATE_ALL); + this.level.setBlockAndUpdate(this.getBlockPos(), this.getBlockState().setValue(BlockStateProperties.DUSTED, j)); } this.brushCountResetsAtTick = this.level.getGameTime() + 4L; } @@ -92,17 +91,10 @@ public void checkReset() { } private int getCompletionState() { - if (this.brushCount == 0) { - return 0; - } - if (this.brushCount < 3) { - return 1; - } - if (this.brushCount < 6) { - return 2; - } + if (this.brushCount == 0) return 0; + if (this.brushCount < 3) return 1; + if (this.brushCount < 6) return 2; return 3; } } - diff --git a/src/main/java/net/frozenblock/wilderwild/block/impl/SnowloggingUtils.java b/src/main/java/net/frozenblock/wilderwild/block/impl/SnowloggingUtils.java index 47c65500f2..26e3c08914 100644 --- a/src/main/java/net/frozenblock/wilderwild/block/impl/SnowloggingUtils.java +++ b/src/main/java/net/frozenblock/wilderwild/block/impl/SnowloggingUtils.java @@ -129,7 +129,7 @@ public static void onRandomTick(BlockState state, ServerLevel level, BlockPos po if (isSnowlogged(state)) { if (level.getBrightness(LightLayer.BLOCK, pos) > 11) { Block.dropResources(getSnowEquivalent(state), level, pos); - level.setBlock(pos, state.setValue(SNOW_LAYERS, 0), Block.UPDATE_ALL); + level.setBlockAndUpdate(pos, state.setValue(SNOW_LAYERS, 0)); } } } diff --git a/src/main/java/net/frozenblock/wilderwild/block/impl/SnowyBlockUtils.java b/src/main/java/net/frozenblock/wilderwild/block/impl/SnowyBlockUtils.java index fda42069f9..9d2100357f 100644 --- a/src/main/java/net/frozenblock/wilderwild/block/impl/SnowyBlockUtils.java +++ b/src/main/java/net/frozenblock/wilderwild/block/impl/SnowyBlockUtils.java @@ -19,6 +19,7 @@ package net.frozenblock.wilderwild.block.impl; import com.google.common.collect.ImmutableMap; +import java.util.Map; import net.frozenblock.wilderwild.registry.WWBlocks; import net.minecraft.core.BlockPos; import net.minecraft.world.level.WorldGenLevel; @@ -27,7 +28,6 @@ import net.minecraft.world.level.block.state.BlockState; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; -import java.util.Map; public class SnowyBlockUtils { public static final Map SNOWY_BLOCK_MAP = ImmutableMap.builder() diff --git a/src/main/java/net/frozenblock/wilderwild/datagen/loot/WWBlockLootProvider.java b/src/main/java/net/frozenblock/wilderwild/datagen/loot/WWBlockLootProvider.java index cc23194a76..c432288abc 100644 --- a/src/main/java/net/frozenblock/wilderwild/datagen/loot/WWBlockLootProvider.java +++ b/src/main/java/net/frozenblock/wilderwild/datagen/loot/WWBlockLootProvider.java @@ -30,20 +30,16 @@ import net.minecraft.world.item.Items; import net.minecraft.world.item.enchantment.Enchantment; import net.minecraft.world.item.enchantment.Enchantments; -import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.DoublePlantBlock; import net.minecraft.world.level.block.SlabBlock; import net.minecraft.world.level.block.state.properties.BlockStateProperties; import net.minecraft.world.level.block.state.properties.DoubleBlockHalf; import net.minecraft.world.level.block.state.properties.SlabType; -import net.minecraft.world.level.storage.loot.IntRange; import net.minecraft.world.level.storage.loot.LootPool; import net.minecraft.world.level.storage.loot.LootTable; import net.minecraft.world.level.storage.loot.entries.LootItem; -import net.minecraft.world.level.storage.loot.functions.ApplyBonusCount; import net.minecraft.world.level.storage.loot.functions.CopyBlockState; import net.minecraft.world.level.storage.loot.functions.CopyComponentsFunction; -import net.minecraft.world.level.storage.loot.functions.LimitCount; import net.minecraft.world.level.storage.loot.functions.SetItemCountFunction; import net.minecraft.world.level.storage.loot.predicates.BonusLevelTableCondition; import net.minecraft.world.level.storage.loot.predicates.ExplosionCondition; diff --git a/src/main/java/net/frozenblock/wilderwild/datagen/model/WWModelHelper.java b/src/main/java/net/frozenblock/wilderwild/datagen/model/WWModelHelper.java index ed81145682..097d925faa 100644 --- a/src/main/java/net/frozenblock/wilderwild/datagen/model/WWModelHelper.java +++ b/src/main/java/net/frozenblock/wilderwild/datagen/model/WWModelHelper.java @@ -43,7 +43,6 @@ import net.minecraft.data.models.model.TexturedModel; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.properties.AttachFace; import net.minecraft.world.level.block.state.properties.BlockStateProperties; import net.minecraft.world.level.block.state.properties.BooleanProperty; diff --git a/src/main/java/net/frozenblock/wilderwild/entity/ai/ostrich/OstrichLayEgg.java b/src/main/java/net/frozenblock/wilderwild/entity/ai/ostrich/OstrichLayEgg.java index e7ec901fc7..a16a582454 100644 --- a/src/main/java/net/frozenblock/wilderwild/entity/ai/ostrich/OstrichLayEgg.java +++ b/src/main/java/net/frozenblock/wilderwild/entity/ai/ostrich/OstrichLayEgg.java @@ -48,7 +48,7 @@ private static boolean attemptPlace(Ostrich entity, @NotNull Level level, Block BlockState belowState = level.getBlockState(belowPos); if (blockState.isAir() && belowState.isFaceSturdy(level, belowPos, Direction.UP)) { BlockState placementState = block.defaultBlockState(); - level.setBlock(placePos, placementState, Block.UPDATE_ALL); + level.setBlockAndUpdate(placePos, placementState); level.gameEvent(GameEvent.BLOCK_PLACE, placePos, GameEvent.Context.of(entity, placementState)); level.playSound(null, entity, WWSounds.ENTITY_OSTRICH_LAY_EGG, SoundSource.BLOCKS, 1F, 1F); return true; diff --git a/src/main/java/net/frozenblock/wilderwild/entity/ai/penguin/PenguinLayEgg.java b/src/main/java/net/frozenblock/wilderwild/entity/ai/penguin/PenguinLayEgg.java index 8fe25e2f43..cab344cada 100644 --- a/src/main/java/net/frozenblock/wilderwild/entity/ai/penguin/PenguinLayEgg.java +++ b/src/main/java/net/frozenblock/wilderwild/entity/ai/penguin/PenguinLayEgg.java @@ -48,7 +48,7 @@ private static boolean attemptPlace(Penguin entity, @NotNull Level level, Block BlockState belowState = level.getBlockState(belowPos); if (blockState.isAir() && belowState.isFaceSturdy(level, belowPos, Direction.UP)) { BlockState placementState = block.defaultBlockState(); - level.setBlock(placePos, placementState, Block.UPDATE_ALL); + level.setBlockAndUpdate(placePos, placementState); level.gameEvent(GameEvent.BLOCK_PLACE, placePos, GameEvent.Context.of(entity, placementState)); level.playSound(null, entity, entity.isLinux() ? WWSounds.ENTITY_LINUX_LAY_EGG : WWSounds.ENTITY_PENGUIN_LAY_EGG, SoundSource.BLOCKS, 1F, 1F); return true; diff --git a/src/main/java/net/frozenblock/wilderwild/entity/ai/penguin/PenguinPreSearch.java b/src/main/java/net/frozenblock/wilderwild/entity/ai/penguin/PenguinPreSearch.java index caf31b1f94..f3ae788976 100644 --- a/src/main/java/net/frozenblock/wilderwild/entity/ai/penguin/PenguinPreSearch.java +++ b/src/main/java/net/frozenblock/wilderwild/entity/ai/penguin/PenguinPreSearch.java @@ -23,9 +23,7 @@ import net.frozenblock.wilderwild.registry.WWMemoryModuleTypes; import net.minecraft.server.level.ServerLevel; import net.minecraft.util.Unit; -import net.minecraft.world.entity.ai.Brain; import net.minecraft.world.entity.ai.behavior.Behavior; -import net.minecraft.world.entity.ai.memory.MemoryModuleType; import net.minecraft.world.entity.ai.memory.MemoryStatus; import org.jetbrains.annotations.NotNull; diff --git a/src/main/java/net/frozenblock/wilderwild/entity/effect/ScorchingMobEffect.java b/src/main/java/net/frozenblock/wilderwild/entity/effect/ScorchingMobEffect.java index 9f44572780..3308bf1218 100644 --- a/src/main/java/net/frozenblock/wilderwild/entity/effect/ScorchingMobEffect.java +++ b/src/main/java/net/frozenblock/wilderwild/entity/effect/ScorchingMobEffect.java @@ -37,7 +37,6 @@ import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.GameRules; import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.BlockState; import org.jetbrains.annotations.NotNull; @@ -87,16 +86,17 @@ private void spawnFireRandomlyAround(Level level, RandomSource random, BlockPos blockPos = poses.next(); BlockPos blockPos2 = blockPos.below(); BlockState blockState = level.getBlockState(blockPos); - if (!set.contains(blockPos) && blockState.canBeReplaced() && blockState.getFluidState().isEmpty() && level.getBlockState(blockPos2).isFaceSturdy(level, blockPos2, Direction.UP)) { + if (!set.contains(blockPos) + && blockState.canBeReplaced() + && blockState.getFluidState().isEmpty() + && level.getBlockState(blockPos2).isFaceSturdy(level, blockPos2, Direction.UP) + ) { set.add(blockPos.immutable()); - if (set.size() >= i) { - break; - } + if (set.size() >= i) break; } } poses = set.iterator(); - while (poses.hasNext()) { blockPos = poses.next(); BlockState fireState; @@ -106,7 +106,7 @@ private void spawnFireRandomlyAround(Level level, RandomSource random, BlockPos fireState = Blocks.FIRE.defaultBlockState(); } if (fireState.canSurvive(level, blockPos)) { - level.setBlock(blockPos, fireState, Block.UPDATE_ALL); + level.setBlockAndUpdate(blockPos, fireState); WWScorchingFirePlacePacket.sendToAll(serverLevel, blockPos); } } diff --git a/src/main/java/net/frozenblock/wilderwild/mixin/block/block_break/ServerPlayerGameModeMixin.java b/src/main/java/net/frozenblock/wilderwild/mixin/block/block_break/ServerPlayerGameModeMixin.java index e928a83f55..e5f53c7ad3 100644 --- a/src/main/java/net/frozenblock/wilderwild/mixin/block/block_break/ServerPlayerGameModeMixin.java +++ b/src/main/java/net/frozenblock/wilderwild/mixin/block/block_break/ServerPlayerGameModeMixin.java @@ -26,7 +26,6 @@ import net.minecraft.core.BlockPos; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayerGameMode; -import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.BlockState; import org.spongepowered.asm.mixin.Mixin; @@ -47,10 +46,10 @@ public class ServerPlayerGameModeMixin { @Local(ordinal = 1) BlockState destroyedState ) { if (SnowloggingUtils.isSnowlogged(destroyedState)) { - instance.setBlock(pos, destroyedState.setValue(SnowloggingUtils.SNOW_LAYERS, 0), Block.UPDATE_ALL); + instance.setBlockAndUpdate(pos, destroyedState.setValue(SnowloggingUtils.SNOW_LAYERS, 0)); return true; } else if (destroyedState.getBlock() instanceof MesogleaBlock) { - instance.setBlock(pos, Blocks.AIR.defaultBlockState(), Block.UPDATE_ALL); + instance.setBlockAndUpdate(pos, Blocks.AIR.defaultBlockState()); return true; } return original.call(instance, pos, b); diff --git a/src/main/java/net/frozenblock/wilderwild/mixin/block/ice/WalkNodeEvaluatorMixin.java b/src/main/java/net/frozenblock/wilderwild/mixin/block/ice/WalkNodeEvaluatorMixin.java index 6a42010c17..a80fd9eb53 100644 --- a/src/main/java/net/frozenblock/wilderwild/mixin/block/ice/WalkNodeEvaluatorMixin.java +++ b/src/main/java/net/frozenblock/wilderwild/mixin/block/ice/WalkNodeEvaluatorMixin.java @@ -21,18 +21,11 @@ import com.llamalad7.mixinextras.injector.wrapoperation.Operation; import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; import net.frozenblock.wilderwild.registry.WWBlocks; -import net.frozenblock.wilderwild.registry.WWGameEvents; -import net.minecraft.core.Holder; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.gameevent.GameEvent; import net.minecraft.world.level.pathfinder.WalkNodeEvaluator; -import net.minecraft.world.phys.Vec3; import org.objectweb.asm.Opcodes; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Slice; diff --git a/src/main/java/net/frozenblock/wilderwild/mixin/sculk/SculkSensorBlockEntityMixin.java b/src/main/java/net/frozenblock/wilderwild/mixin/sculk/SculkSensorBlockEntityMixin.java index d717e5040d..b4b33189f4 100644 --- a/src/main/java/net/frozenblock/wilderwild/mixin/sculk/SculkSensorBlockEntityMixin.java +++ b/src/main/java/net/frozenblock/wilderwild/mixin/sculk/SculkSensorBlockEntityMixin.java @@ -199,7 +199,7 @@ private SculkSensorBlockEntityMixin(BlockEntityType type, BlockPos pos, Block this.wilderWild$setPrevActive(nbt.getBoolean("prevActive")); Direction facing = Direction.byName(nbt.getString("facing")); - this.wilderWild$setFacing(Objects.requireNonNullElse(facing, Direction.SOUTH)); + this.wilderWild$setFacing(Objects.requireNonNullElse(facing, Direction.NORTH)); } @Inject(method = "saveAdditional", at = @At("TAIL")) diff --git a/src/main/java/net/frozenblock/wilderwild/mod_compat/FrozenLibIntegration.java b/src/main/java/net/frozenblock/wilderwild/mod_compat/FrozenLibIntegration.java index 74bd65d9a4..081f885d8b 100644 --- a/src/main/java/net/frozenblock/wilderwild/mod_compat/FrozenLibIntegration.java +++ b/src/main/java/net/frozenblock/wilderwild/mod_compat/FrozenLibIntegration.java @@ -263,7 +263,7 @@ public void init() { Blocks.DIRT, (blockState, serverLevel, blockPos, randomSource) -> { if (DripstoneDripApi.getDripstoneFluid(serverLevel, blockPos) == Fluids.WATER) { - serverLevel.setBlock(blockPos, Blocks.MUD.defaultBlockState(), Block.UPDATE_ALL); + serverLevel.setBlockAndUpdate(blockPos, Blocks.MUD.defaultBlockState()); } } ); diff --git a/src/main/java/net/frozenblock/wilderwild/registry/WWBiomes.java b/src/main/java/net/frozenblock/wilderwild/registry/WWBiomes.java index 7633192127..a741a12fff 100644 --- a/src/main/java/net/frozenblock/wilderwild/registry/WWBiomes.java +++ b/src/main/java/net/frozenblock/wilderwild/registry/WWBiomes.java @@ -21,6 +21,7 @@ import net.frozenblock.wilderwild.WWConstants; import net.frozenblock.wilderwild.worldgen.biome.AridForest; import net.frozenblock.wilderwild.worldgen.biome.AridSavanna; +import net.frozenblock.wilderwild.worldgen.biome.AutumnalPlains; import net.frozenblock.wilderwild.worldgen.biome.BirchJungle; import net.frozenblock.wilderwild.worldgen.biome.BirchTaiga; import net.frozenblock.wilderwild.worldgen.biome.CypressWetlands; @@ -46,7 +47,6 @@ import net.frozenblock.wilderwild.worldgen.biome.SparseBirchJungle; import net.frozenblock.wilderwild.worldgen.biome.SparseForest; import net.frozenblock.wilderwild.worldgen.biome.TemperateRainforest; -import net.frozenblock.wilderwild.worldgen.biome.AutumnalPlains; import net.frozenblock.wilderwild.worldgen.biome.WarmBeach; import net.frozenblock.wilderwild.worldgen.biome.WarmRiver; import net.minecraft.data.worldgen.BootstrapContext; diff --git a/src/main/java/net/frozenblock/wilderwild/worldgen/features/placed/WWMiscPlaced.java b/src/main/java/net/frozenblock/wilderwild/worldgen/features/placed/WWMiscPlaced.java index 8615205b1c..dc7225aab6 100644 --- a/src/main/java/net/frozenblock/wilderwild/worldgen/features/placed/WWMiscPlaced.java +++ b/src/main/java/net/frozenblock/wilderwild/worldgen/features/placed/WWMiscPlaced.java @@ -40,7 +40,6 @@ import net.minecraft.world.level.levelgen.placement.CountPlacement; import net.minecraft.world.level.levelgen.placement.EnvironmentScanPlacement; import net.minecraft.world.level.levelgen.placement.HeightRangePlacement; -import net.minecraft.world.level.levelgen.placement.HeightmapPlacement; import net.minecraft.world.level.levelgen.placement.InSquarePlacement; import net.minecraft.world.level.levelgen.placement.PlacedFeature; import net.minecraft.world.level.levelgen.placement.PlacementModifier; diff --git a/src/main/java/net/frozenblock/wilderwild/worldgen/impl/feature/AlgaeFeature.java b/src/main/java/net/frozenblock/wilderwild/worldgen/impl/feature/AlgaeFeature.java index ab6647e408..0b0619705b 100644 --- a/src/main/java/net/frozenblock/wilderwild/worldgen/impl/feature/AlgaeFeature.java +++ b/src/main/java/net/frozenblock/wilderwild/worldgen/impl/feature/AlgaeFeature.java @@ -94,7 +94,13 @@ public boolean place(@NotNull FeaturePlaceContext context) { return bl; } - private boolean genAlgae(boolean bl, WorldGenLevel level, @NotNull RandomSource random, @NotNull BlockPos.MutableBlockPos mutableDisk, boolean fade) { + private boolean genAlgae( + boolean bl, + WorldGenLevel level, + @NotNull RandomSource random, + @NotNull BlockPos.MutableBlockPos mutableDisk, + boolean fade + ) { if (random.nextFloat() > 0.2F) { if (fade) { if (random.nextFloat() > 0.5F) { diff --git a/src/main/java/net/frozenblock/wilderwild/worldgen/impl/feature/NematocystFeature.java b/src/main/java/net/frozenblock/wilderwild/worldgen/impl/feature/NematocystFeature.java index 1282044f53..fa0d22ef78 100644 --- a/src/main/java/net/frozenblock/wilderwild/worldgen/impl/feature/NematocystFeature.java +++ b/src/main/java/net/frozenblock/wilderwild/worldgen/impl/feature/NematocystFeature.java @@ -37,16 +37,21 @@ public NematocystFeature(@NotNull Codec codec) { super(codec); } - public static boolean placeGrowthIfPossible(@NotNull WorldGenLevel level, @NotNull BlockPos pos, @NotNull BlockState state, @NotNull MultifaceGrowthConfiguration config, @NotNull RandomSource random, @NotNull List directions) { + public static boolean placeGrowthIfPossible( + @NotNull WorldGenLevel level, + @NotNull BlockPos pos, + @NotNull BlockState state, + @NotNull MultifaceGrowthConfiguration config, + @NotNull RandomSource random, + @NotNull List directions + ) { BlockPos.MutableBlockPos mutableBlockPos = pos.mutable(); for (Direction direction : directions) { BlockState blockState = level.getBlockState(mutableBlockPos.setWithOffset(pos, direction)); if (blockState.is(config.canBePlacedOn)) { BlockState blockState2 = config.placeBlock.getStateForPlacement(state, level, pos, direction); - if (blockState2 == null) { - return false; - } + if (blockState2 == null) return false; level.setBlock(pos, blockState2, Block.UPDATE_ALL); level.getChunk(pos).markPosForPostprocessing(pos); @@ -71,34 +76,23 @@ public boolean place(@NotNull FeaturePlaceContext BlockPos blockPos = context.origin(); RandomSource randomSource = context.random(); MultifaceGrowthConfiguration multifaceGrowthConfiguration = context.config(); - if (!isAirOrWater(worldGenLevel.getBlockState(blockPos))) { - return false; - } else { - List list = multifaceGrowthConfiguration.getShuffledDirections(randomSource); - if (placeGrowthIfPossible(worldGenLevel, blockPos, worldGenLevel.getBlockState(blockPos), multifaceGrowthConfiguration, randomSource, list)) { - return true; - } else { - BlockPos.MutableBlockPos mutableBlockPos = blockPos.mutable(); - for (Direction direction : list) { - mutableBlockPos.set(blockPos); - List list2 = multifaceGrowthConfiguration.getShuffledDirectionsExcept(randomSource, direction.getOpposite()); + if (!isAirOrWater(worldGenLevel.getBlockState(blockPos))) return false; + List list = multifaceGrowthConfiguration.getShuffledDirections(randomSource); + if (placeGrowthIfPossible(worldGenLevel, blockPos, worldGenLevel.getBlockState(blockPos), multifaceGrowthConfiguration, randomSource, list)) return true; - for (int i = 0; i < multifaceGrowthConfiguration.searchRange; ++i) { - mutableBlockPos.setWithOffset(blockPos, direction); - BlockState blockState = worldGenLevel.getBlockState(mutableBlockPos); - if (!isAirOrWater(blockState) && !blockState.is(multifaceGrowthConfiguration.placeBlock)) { - break; - } - - if (placeGrowthIfPossible(worldGenLevel, mutableBlockPos, blockState, multifaceGrowthConfiguration, randomSource, list2)) { - return true; - } - } - } - return false; + BlockPos.MutableBlockPos mutableBlockPos = blockPos.mutable(); + for (Direction direction : list) { + mutableBlockPos.set(blockPos); + List list2 = multifaceGrowthConfiguration.getShuffledDirectionsExcept(randomSource, direction.getOpposite()); + for (int i = 0; i < multifaceGrowthConfiguration.searchRange; ++i) { + mutableBlockPos.setWithOffset(blockPos, direction); + BlockState blockState = worldGenLevel.getBlockState(mutableBlockPos); + if (!isAirOrWater(blockState) && !blockState.is(multifaceGrowthConfiguration.placeBlock)) break; + if (placeGrowthIfPossible(worldGenLevel, mutableBlockPos, blockState, multifaceGrowthConfiguration, randomSource, list2)) return true; } } + return false; } -} +} diff --git a/src/main/java/net/frozenblock/wilderwild/worldgen/impl/feature/ShelfFungiFeature.java b/src/main/java/net/frozenblock/wilderwild/worldgen/impl/feature/ShelfFungiFeature.java index 5638be0cb1..990b1012f5 100644 --- a/src/main/java/net/frozenblock/wilderwild/worldgen/impl/feature/ShelfFungiFeature.java +++ b/src/main/java/net/frozenblock/wilderwild/worldgen/impl/feature/ShelfFungiFeature.java @@ -40,7 +40,12 @@ public ShelfFungiFeature(@NotNull Codec codec) { super(codec); } - public static boolean generate(@NotNull WorldGenLevel level, @NotNull BlockPos pos, @NotNull ShelfFungiFeatureConfig config, @NotNull RandomSource random, @NotNull List directions) { + public static boolean generate( + @NotNull WorldGenLevel level, + @NotNull BlockPos pos, + @NotNull ShelfFungiFeatureConfig config, + @NotNull RandomSource random + ) { MutableBlockPos mutable = pos.mutable(); Direction placementDirection = null; @@ -78,33 +83,22 @@ public boolean place(@NotNull FeaturePlaceContext conte RandomSource abstractRandom = context.random(); BlockPos blockPos = context.origin().above(abstractRandom.nextInt(0, 4)); ShelfFungiFeatureConfig shelfFungusFeatureConfig = context.config(); - if (!isAirOrWater(structureWorldAccess.getBlockState(blockPos))) { - return false; - } else { - List list = shelfFungusFeatureConfig.shuffleDirections(abstractRandom); - if (generate(structureWorldAccess, blockPos, shelfFungusFeatureConfig, abstractRandom, list)) { - return true; - } else { - MutableBlockPos mutable = blockPos.mutable(); - for (Direction direction : list) { - mutable.set(blockPos); - List list2 = shelfFungusFeatureConfig.shuffleDirections(abstractRandom, direction.getOpposite()); + if (!isAirOrWater(structureWorldAccess.getBlockState(blockPos))) return false; + List list = shelfFungusFeatureConfig.shuffleDirections(abstractRandom); + if (generate(structureWorldAccess, blockPos, shelfFungusFeatureConfig, abstractRandom)) return true; - for (int i = 0; i < shelfFungusFeatureConfig.searchRange; ++i) { - mutable.setWithOffset(blockPos, direction); - BlockState blockState = structureWorldAccess.getBlockState(mutable); - if (!isAirOrWater(blockState) && !blockState.is(shelfFungusFeatureConfig.fungus)) { - break; - } - - if (generate(structureWorldAccess, mutable, shelfFungusFeatureConfig, abstractRandom, list2)) { - return true; - } - } - } - return false; + MutableBlockPos mutable = blockPos.mutable(); + for (Direction direction : list) { + mutable.set(blockPos); + for (int i = 0; i < shelfFungusFeatureConfig.searchRange; ++i) { + mutable.setWithOffset(blockPos, direction); + BlockState blockState = structureWorldAccess.getBlockState(mutable); + if (!isAirOrWater(blockState) && !blockState.is(shelfFungusFeatureConfig.fungus)) break; + if (generate(structureWorldAccess, mutable, shelfFungusFeatureConfig, abstractRandom)) return true; } } + return false; } + } diff --git a/src/main/java/net/frozenblock/wilderwild/worldgen/impl/feature/SnowBlanketFeature.java b/src/main/java/net/frozenblock/wilderwild/worldgen/impl/feature/SnowBlanketFeature.java index fbc35438e6..bf099cea2a 100644 --- a/src/main/java/net/frozenblock/wilderwild/worldgen/impl/feature/SnowBlanketFeature.java +++ b/src/main/java/net/frozenblock/wilderwild/worldgen/impl/feature/SnowBlanketFeature.java @@ -88,9 +88,8 @@ private static boolean placeSnowAtPos( if (belowState.hasProperty(BlockStateProperties.SNOWY)) { level.setBlock(mutablePos2, belowState.setValue(BlockStateProperties.SNOWY, true), Block.UPDATE_CLIENTS); } - return SnowGenerationState.SUCCESS; } - return SnowGenerationState.FAIL; + return SnowGenerationState.CONTINUE; } private static int findLowestHeightForSnow(@NotNull WorldGenLevel level, int x, int z) { @@ -143,7 +142,6 @@ public boolean place(@NotNull FeaturePlaceContext cont private enum SnowGenerationState { CANCEL, - SUCCESS, - FAIL; + CONTINUE; } } diff --git a/src/main/java/net/frozenblock/wilderwild/worldgen/impl/feature/SpongeBudFeature.java b/src/main/java/net/frozenblock/wilderwild/worldgen/impl/feature/SpongeBudFeature.java index 1eafba3cb4..f2c5762b78 100644 --- a/src/main/java/net/frozenblock/wilderwild/worldgen/impl/feature/SpongeBudFeature.java +++ b/src/main/java/net/frozenblock/wilderwild/worldgen/impl/feature/SpongeBudFeature.java @@ -45,16 +45,20 @@ public SpongeBudFeature(@NotNull Codec codec) { super(codec); } - public static boolean generate(@NotNull WorldGenLevel level, @NotNull BlockPos pos, @NotNull BlockState state, @NotNull SpongeBudFeatureConfig config, @NotNull List directions) { + public static boolean generate( + @NotNull WorldGenLevel level, + @NotNull BlockPos pos, + @NotNull BlockState state, + @NotNull SpongeBudFeatureConfig config, + @NotNull List directions + ) { BlockPos.MutableBlockPos mutableBlockPos = pos.mutable(); for (Direction direction : directions) { BlockState blockState = level.getBlockState(mutableBlockPos.setWithOffset(pos, direction)); if (blockState.is(config.canPlaceOn)) { BlockState blockState2 = getStateForPlacement(level.getRandom(), state, level, pos, direction); - if (blockState2 == null) { - return false; - } + if (blockState2 == null) return false; if (blockState2.getValue(SpongeBudBlock.WATERLOGGED)) { level.setBlock(pos, blockState2, Block.UPDATE_ALL); @@ -67,7 +71,13 @@ public static boolean generate(@NotNull WorldGenLevel level, @NotNull BlockPos p } @Nullable - private static BlockState getStateForPlacement(RandomSource random, @NotNull BlockState currentState, @NotNull BlockGetter level, @NotNull BlockPos pos, @NotNull Direction lookingDirection) { + private static BlockState getStateForPlacement( + RandomSource random, + @NotNull BlockState currentState, + @NotNull BlockGetter level, + @NotNull BlockPos pos, + @NotNull Direction lookingDirection + ) { Block sponge = WWBlocks.SPONGE_BUD; if (!isValidStateForPlacement(level, pos, lookingDirection)) { return null; @@ -82,9 +92,12 @@ private static BlockState getStateForPlacement(RandomSource random, @NotNull Blo } if (lookingDirection.getAxis() == Direction.Axis.Y) { - blockState = blockState.setValue(SpongeBudBlock.FACE, lookingDirection == Direction.UP ? AttachFace.CEILING : AttachFace.FLOOR).setValue(SpongeBudBlock.FACING, Direction.Plane.HORIZONTAL.getRandomDirection(random)); + blockState = blockState + .setValue(SpongeBudBlock.FACE, lookingDirection == Direction.UP ? AttachFace.CEILING : AttachFace.FLOOR) + .setValue(SpongeBudBlock.FACING, Direction.Plane.HORIZONTAL.getRandomDirection(random)); } else { - blockState = blockState.setValue(SpongeBudBlock.FACE, AttachFace.WALL).setValue(SpongeBudBlock.FACING, lookingDirection.getOpposite()); + blockState = blockState.setValue(SpongeBudBlock.FACE, AttachFace.WALL) + .setValue(SpongeBudBlock.FACING, lookingDirection.getOpposite()); } return blockState.setValue(SpongeBudBlock.AGE, random.nextInt(SpongeBudBlock.MAX_AGE)); @@ -110,34 +123,23 @@ public boolean place(@NotNull FeaturePlaceContext contex BlockPos blockPos = context.origin(); RandomSource randomSource = context.random(); SpongeBudFeatureConfig config = context.config(); - if (!isAirOrWater(worldGenLevel.getBlockState(blockPos))) { - return false; - } else { - List list = config.shuffleDirections(randomSource); - if (generate(worldGenLevel, blockPos, worldGenLevel.getBlockState(blockPos), config, list)) { - return true; - } else { - BlockPos.MutableBlockPos mutableBlockPos = blockPos.mutable(); - - for (Direction direction : list) { - mutableBlockPos.set(blockPos); - List list2 = config.shuffleDirections(randomSource, direction.getOpposite()); - - for (int i = 0; i < config.searchRange; ++i) { - mutableBlockPos.setWithOffset(blockPos, direction); - BlockState blockState = worldGenLevel.getBlockState(mutableBlockPos); - if (!isAirOrWater(blockState) && !blockState.is(WWBlocks.SPONGE_BUD)) { - break; - } - - if (generate(worldGenLevel, mutableBlockPos, blockState, config, list2)) { - return true; - } - } - } - return false; + + if (!isAirOrWater(worldGenLevel.getBlockState(blockPos))) return false; + List list = config.shuffleDirections(randomSource); + if (generate(worldGenLevel, blockPos, worldGenLevel.getBlockState(blockPos), config, list)) return true; + + BlockPos.MutableBlockPos mutableBlockPos = blockPos.mutable(); + for (Direction direction : list) { + mutableBlockPos.set(blockPos); + List list2 = config.shuffleDirections(randomSource, direction.getOpposite()); + for (int i = 0; i < config.searchRange; ++i) { + mutableBlockPos.setWithOffset(blockPos, direction); + BlockState blockState = worldGenLevel.getBlockState(mutableBlockPos); + if (!isAirOrWater(blockState) && !blockState.is(WWBlocks.SPONGE_BUD)) break; + if (generate(worldGenLevel, mutableBlockPos, blockState, config, list2)) return true; } } + return false; } -} +}