BlockUtils.register is weird

This commit is contained in:
StormyBytes
2021-06-06 09:08:29 +07:00
parent 138fec7944
commit e8f43fecbe

View File

@@ -26,10 +26,8 @@ public class SpawnProofer extends Module {
private final Setting<Integer> range = sgGeneral.add(new IntSetting.Builder() private final Setting<Integer> range = sgGeneral.add(new IntSetting.Builder()
.name("range") .name("range")
.description("Range for block placement and rendering") .description("Range for block placement and rendering")
.min(1) .min(0)
.max(4) .sliderMax(10)
.sliderMin(1)
.sliderMax(1)
.defaultValue(3) .defaultValue(3)
.build() .build()
); );
@@ -42,10 +40,11 @@ public class SpawnProofer extends Module {
.build() .build()
); );
private final Setting<Boolean> multiPlace = sgGeneral.add(new BoolSetting.Builder() private final Setting<Integer> delay = sgGeneral.add(new IntSetting.Builder()
.name("multi-place") .name("delay")
.description("Places multiple blocks per tick") .description("Delay in ticks between placing blocks")
.defaultValue(false) .defaultValue(0)
.min(0).sliderMax(10)
.build() .build()
); );
@@ -56,14 +55,6 @@ public class SpawnProofer extends Module {
.build() .build()
); );
private final Setting<Integer> delay = sgGeneral.add(new IntSetting.Builder()
.name("delay")
.description("Delay in ticks between placing blocks")
.defaultValue(0)
.min(0).max(10)
.build()
);
private final Setting<Boolean> spawnProofPotentialSpawns = sgGeneral.add(new BoolSetting.Builder() private final Setting<Boolean> spawnProofPotentialSpawns = sgGeneral.add(new BoolSetting.Builder()
.name("potential-spawns") .name("potential-spawns")
.description("Spawn Proofs Potential Spawns (Spots that have access to sunlight and only spawns mobs during night time)") .description("Spawn Proofs Potential Spawns (Spots that have access to sunlight and only spawns mobs during night time)")
@@ -86,25 +77,8 @@ public class SpawnProofer extends Module {
super(MeteorRejectsAddon.CATEGORY, "spawn-proofer", "Automatically spawnproofs using blocks."); super(MeteorRejectsAddon.CATEGORY, "spawn-proofer", "Automatically spawnproofs using blocks.");
} }
@Override
public void onActivate() {
ticksWaited = 0;
}
@Override
public void onDeactivate() {
ticksWaited = 0;
}
@EventHandler @EventHandler
private void onTick(TickEvent.Post event) { private void onTick(TickEvent.Post event) {
// Clear and set positions
positions.clear();
for (BlockPos blockPos : WorldUtils.getSphere(mc.player.getBlockPos(), range.get(), range.get())) {
if (validSpawn(blockPos)) positions.add(blockPos);
}
if (positions.size() == 0) return;
// Tick delay // Tick delay
if (ticksWaited < delay.get()) { if (ticksWaited < delay.get()) {
@@ -120,36 +94,42 @@ public class SpawnProofer extends Module {
return; return;
} }
// If is light source // Clear and set positions
if (isLightSource(Block.getBlockFromItem( positions.clear();
mc.player.inventory.getStack(slot).getItem() for (BlockPos blockPos : WorldUtils.getSphere(mc.player.getBlockPos(), range.get(), range.get())) {
))) { if (validSpawn(blockPos)) positions.add(blockPos);
}
if (positions.size() == 0) return;
// Find lowest light level block
int lowestLightLevel = 16;
BlockPos selectedBlockPos = positions.get(0); // Just for initialization
for (BlockPos blockPos : positions) {
int lightLevel = mc.world.getLightLevel(blockPos); // Place the blocks
if (lightLevel < lowestLightLevel) { if (delay.get() == 0) {
lowestLightLevel = lightLevel;
selectedBlockPos = blockPos;
}
}
BlockUtils.place(selectedBlockPos, Hand.MAIN_HAND, slot, rotate.get(), -50, false); for (BlockPos blockPos : positions) BlockUtils.place(blockPos, Hand.MAIN_HAND, slot, rotate.get(), -50, false);
} else { } else {
// Place first in positions // If is light source
BlockUtils.place(positions.get(0), Hand.MAIN_HAND, slot, rotate.get(), -50, false); if (isLightSource(Block.getBlockFromItem(mc.player.inventory.getStack(slot).getItem()))) {
// Multiplace // Find lowest light level block
if (multiPlace.get()) { int lowestLightLevel = 16;
slot = findSlot(); BlockPos selectedBlockPos = positions.get(0); // Just for initialization
for (BlockPos blockPos : positions) {
int lightLevel = mc.world.getLightLevel(blockPos);
if (lightLevel < lowestLightLevel) {
lowestLightLevel = lightLevel;
selectedBlockPos = blockPos;
}
}
BlockUtils.place(selectedBlockPos, Hand.MAIN_HAND, slot, rotate.get(), -50, false);
} else {
// Place first in positions
BlockUtils.place(positions.get(0), Hand.MAIN_HAND, slot, rotate.get(), -50, false);
positions.remove(0);
for (BlockPos blockPos : positions) BlockUtils.place(blockPos, Hand.MAIN_HAND, slot, rotate.get(), -50, false);
} }
} }
@@ -200,11 +180,11 @@ public class SpawnProofer extends Module {
return block instanceof AbstractButtonBlock || return block instanceof AbstractButtonBlock ||
block instanceof SlabBlock || block instanceof SlabBlock ||
block instanceof AbstractPressurePlateBlock || block instanceof AbstractPressurePlateBlock ||
block instanceof GlassBlock || block instanceof TransparentBlock ||
block instanceof TripwireBlock; block instanceof TripwireBlock;
} }
private boolean isLightSource(Block block) { private boolean isLightSource(Block block) {
return block instanceof TorchBlock; return block.getDefaultState().getLuminance() > 0;
} }
} }