Code cleanup

This commit is contained in:
2025-04-11 17:21:51 +02:00
parent 0941d3929e
commit 23aefb2f8d
4 changed files with 6 additions and 8 deletions

View File

@ -8,6 +8,7 @@ import net.minecraft.client.render.FogShape;
import net.minecraft.world.World; import net.minecraft.world.World;
import org.joml.Vector4f; import org.joml.Vector4f;
import org.spongepowered.asm.mixin.Mixin; 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.At;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@ -17,6 +18,7 @@ import static wtf.hak.survivalfabric.config.client.ClientConfigManager.getConfig
@Mixin(value = BackgroundRenderer.class, priority = 910) @Mixin(value = BackgroundRenderer.class, priority = 910)
public abstract class BackgroundRendererMixin { public abstract class BackgroundRendererMixin {
@Unique
private static final Fog EMPTY_FOG = new Fog(-8.0f, 1_000_000.0F, FogShape.CYLINDER, 0,0,0,0); private static final Fog EMPTY_FOG = new Fog(-8.0f, 1_000_000.0F, FogShape.CYLINDER, 0,0,0,0);
@Inject(method = "applyFog", at = @At("RETURN"), cancellable = true) @Inject(method = "applyFog", at = @At("RETURN"), cancellable = true)

View File

@ -57,8 +57,7 @@ public class SharedInventory implements Inventory {
@Override @Override
public ItemStack removeStack(int int_1, int int_2) { public ItemStack removeStack(int int_1, int int_2) {
ItemStack itemStack_1 = Inventories.splitStack(this.stacks, int_1, int_2); return Inventories.splitStack(this.stacks, int_1, int_2);
return itemStack_1;
} }
@Override @Override

View File

@ -9,7 +9,7 @@ import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
public class VeinMinerSession { public class VeinMinerSession {
private static ArrayList<VeinMinerSession> sessions = new ArrayList<>(); private static final ArrayList<VeinMinerSession> sessions = new ArrayList<>();
public ServerPlayerEntity player; public ServerPlayerEntity player;
public ServerWorld world; public ServerWorld world;

View File

@ -33,8 +33,8 @@ public class WoodDrill extends DrillBase {
public boolean drill(BlockPos startPos) { public boolean drill(BlockPos startPos) {
ServerWorld world = session.world; ServerWorld world = session.world;
int broken = 0; int broken = 0;
ArrayDeque<BlockPos> pendingLogs = new ArrayDeque<BlockPos>(); ArrayDeque<BlockPos> pendingLogs = new ArrayDeque<>();
ArrayDeque<BlockPos> logBlocks = new ArrayDeque<BlockPos>(); ArrayDeque<BlockPos> logBlocks = new ArrayDeque<>();
pendingLogs.add(startPos); pendingLogs.add(startPos);
String leavesBlockId = Registries.BLOCK.getId(world.getBlockState(startPos).getBlock()).toString().replace("_log", "_leaves"); String leavesBlockId = Registries.BLOCK.getId(world.getBlockState(startPos).getBlock()).toString().replace("_log", "_leaves");
@ -57,11 +57,8 @@ public class WoodDrill extends DrillBase {
} }
} }
// second round, leaves
// The pending blocks are all air now,
ArrayDeque<BlockPos> pendingLeaves = logBlocks; ArrayDeque<BlockPos> pendingLeaves = logBlocks;
while (!pendingLeaves.isEmpty() && broken < getConfig().maxVeinSize) { while (!pendingLeaves.isEmpty() && broken < getConfig().maxVeinSize) {
// remove the immediately surrounding leaves around the log blocks
broken += forXYZ(pendingLeaves.remove(), 1, newPos -> { broken += forXYZ(pendingLeaves.remove(), 1, newPos -> {
int brokenLeaves = 0; int brokenLeaves = 0;
Block newBlock = world.getBlockState(newPos).getBlock(); Block newBlock = world.getBlockState(newPos).getBlock();