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,10 +94,23 @@ public class SpawnProofer extends Module {
return; return;
} }
// 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;
// Place the blocks
if (delay.get() == 0) {
for (BlockPos blockPos : positions) BlockUtils.place(blockPos, Hand.MAIN_HAND, slot, rotate.get(), -50, false);
} else {
// If is light source // If is light source
if (isLightSource(Block.getBlockFromItem( if (isLightSource(Block.getBlockFromItem(mc.player.inventory.getStack(slot).getItem()))) {
mc.player.inventory.getStack(slot).getItem()
))) {
// Find lowest light level block // Find lowest light level block
int lowestLightLevel = 16; int lowestLightLevel = 16;
@@ -136,7 +123,6 @@ public class SpawnProofer extends Module {
selectedBlockPos = blockPos; selectedBlockPos = blockPos;
} }
} }
BlockUtils.place(selectedBlockPos, Hand.MAIN_HAND, slot, rotate.get(), -50, false); BlockUtils.place(selectedBlockPos, Hand.MAIN_HAND, slot, rotate.get(), -50, false);
} else { } else {
@@ -144,12 +130,6 @@ public class SpawnProofer extends Module {
// Place first in positions // Place first in positions
BlockUtils.place(positions.get(0), Hand.MAIN_HAND, slot, rotate.get(), -50, false); BlockUtils.place(positions.get(0), Hand.MAIN_HAND, slot, rotate.get(), -50, false);
// Multiplace
if (multiPlace.get()) {
slot = findSlot();
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;
} }
} }