[Suggestion]: radial decay
LizzieSpace opened this issue ยท 1 comments
This suggestion is unique
- I have searched the issue tracker and did not find an issue describing my suggestion
Use the editor below to elaborate.
The applySpreadDecay method from the DetachedRiftBlockEntity class uses the raw output of the BlockPos.randomInCube method, which causes a cubic decay pattern far too regular.
A simple check comparing the radius with the distance between the rift block and the randomly selected block would suffice to fix the problem and make the decay pattern grow far better and less regular.
The code addition below would add such check
public void applySpreadDecay(ServerLevel world, BlockPos pos) {
float chance = this.size / 100.0F;
if (random.nextFloat() <= chance) {
BlockPos selected = (BlockPos)BlockPos.randomInCube(world.getRandom(), 1, pos, (int)chance).iterator().next();
++ if (pos.getCenter().distanceTo(selected.getCenter()) >= (int) chance) {return}
Decay.decayBlock(world, selected, world.getBlockState(selected), DecaySource.RIFT);
}
}
Resulting in the following effect
Wrote a mixin that fixes the issue as well. I am using it for a personal mod pack.
Uses official Mojang mappings
import com.llamalad7.mixinextras.sugar.Local;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.phys.Vec3;
import org.dimdev.dimdoors.block.entity.DetachedRiftBlockEntity;
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.callback.CallbackInfo;
@Mixin(DetachedRiftBlockEntity.class)
public class DetachedRiftBlockEntityMixin {
@Inject(method = "applySpreadDecay",cancellable = true , at = @At(value = "INVOKE", target = "Lorg/dimdev/dimdoors/world/decay/Decay;decayBlock(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;Lorg/dimdev/dimdoors/world/decay/DecaySource;)V"))
private void injectBreak(ServerLevel world, BlockPos pos, CallbackInfo ci, @Local(ordinal = 1) BlockPos selected, @Local float radius) {
Vec3 targetCenter = selected.getCenter();
Vec3 posCenter = pos.getCenter();
if ( posCenter.distanceTo(targetCenter) >= (int) radius) {ci.cancel();}
}
}