forked from ChomeNS/chipmunkmod
CORE UH UH AUTO REFILL YEAH AND SOME SONG PLAYER SHIT
This commit is contained in:
parent
fedd15b946
commit
8fce7f0ee6
2 changed files with 49 additions and 2 deletions
|
@ -5,6 +5,8 @@ import land.chipmunk.chipmunkmod.data.BlockArea;
|
|||
import land.chipmunk.chipmunkmod.listeners.Listener;
|
||||
import land.chipmunk.chipmunkmod.listeners.ListenerManager;
|
||||
import land.chipmunk.chipmunkmod.util.MathUtilities;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.CommandBlock;
|
||||
import net.minecraft.block.entity.CommandBlockBlockEntity;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
||||
|
@ -30,6 +32,8 @@ public class CommandCore {
|
|||
|
||||
private Timer timer;
|
||||
|
||||
private boolean shouldRefill = false;
|
||||
|
||||
public boolean runFillCommand = true;
|
||||
|
||||
public static CommandCore INSTANCE = new CommandCore(MinecraftClient.getInstance());
|
||||
|
@ -51,9 +55,22 @@ public class CommandCore {
|
|||
}
|
||||
};
|
||||
|
||||
final TimerTask refillTask = new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!shouldRefill) return;
|
||||
|
||||
refill();
|
||||
|
||||
shouldRefill = false;
|
||||
}
|
||||
};
|
||||
|
||||
timer = new Timer();
|
||||
|
||||
timer.schedule(task, 50, 50);
|
||||
|
||||
timer.schedule(refillTask, 50, 550);
|
||||
}
|
||||
|
||||
private void tick () {
|
||||
|
@ -62,12 +79,44 @@ public class CommandCore {
|
|||
if (networkHandler == null) cleanup();
|
||||
|
||||
reloadRelativeArea();
|
||||
|
||||
check();
|
||||
}
|
||||
|
||||
public void reloadRelativeArea () {
|
||||
noPos = ChipmunkMod.CONFIG.core.relativeArea;
|
||||
}
|
||||
|
||||
public void check () {
|
||||
final ClientPlayNetworkHandler networkHandler = client.getNetworkHandler();
|
||||
|
||||
if (networkHandler == null || withPos == null) return;
|
||||
|
||||
for (int x = withPos.start.getX(); x <= withPos.end.getX(); x++) {
|
||||
for (int y = withPos.start.getY(); y <= withPos.end.getY(); y++) {
|
||||
for (int z = withPos.start.getZ(); z <= withPos.end.getZ(); z++) {
|
||||
try {
|
||||
final BlockPos pos = new BlockPos(x, y, z);
|
||||
|
||||
final ClientWorld world = client.world;
|
||||
|
||||
if (world == null) return;
|
||||
|
||||
final Block block = world.getBlockState(pos).getBlock();
|
||||
|
||||
if (block instanceof CommandBlock) continue;
|
||||
|
||||
shouldRefill = true;
|
||||
|
||||
return;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void move (Vec3d position) {
|
||||
final ClientWorld world = client.world;
|
||||
|
||||
|
|
|
@ -8,8 +8,6 @@ import land.chipmunk.chipmunkmod.song.Song;
|
|||
import land.chipmunk.chipmunkmod.song.SongLoaderException;
|
||||
import land.chipmunk.chipmunkmod.song.SongLoaderThread;
|
||||
import land.chipmunk.chipmunkmod.util.MathUtilities;
|
||||
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
|
|
Loading…
Reference in a new issue