package im.expensive.functions.impl.player;
import com.google.common.eventbus.Subscribe;
import im.expensive.events.EventPacket;
import im.expensive.events.WorldEvent;
import im.expensive.functions.api.Category;
import im.expensive.functions.api.Function;
import im.expensive.functions.api.FunctionRegister;
import im.expensive.utils.render.ColorUtils;
import java.util.ArrayList;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.network.IPacket;
import net.minecraft.network.play.server.SMultiBlockChangePacket;
import net.minecraft.util.math.BlockPos;
import net.optifine.render.RenderUtils;
@FunctionRegister(name="AncientXRay", type=Category.Player)
public class AncientFinder
extends Function {
private final ArrayList<BlockPos> ores = new ArrayList();
@Subscribe
public void onPacket(EventPacket eventPacket) {
IPacket<?> iPacket = eventPacket.getPacket();
if (iPacket instanceof SMultiBlockChangePacket) {
SMultiBlockChangePacket sMultiBlockChangePacket = (SMultiBlockChangePacket)iPacket;
sMultiBlockChangePacket.func_244310_a(this::lambda$onPacket$0);
}
}
@Subscribe
public void onRender3D(WorldEvent worldEvent) {
for (BlockPos blockPos : this.ores) {
if (AncientFinder.mc.world.getBlockState(blockPos).getBlock().equals(Blocks.ANCIENT_DEBRIS)) {
this.print("Рендерю на: " + blockPos);
RenderUtils.drawBlockBox(blockPos, ColorUtils.rgba(255, 255, 255, 255));
continue;
}
this.ores.remove(blockPos);
break;
}
}
private void lambda$onPacket$0(BlockPos blockPos, BlockState blockState) {
if (blockState.getBlock().equals(Blocks.ANCIENT_DEBRIS)) {
this.ores.add(blockPos);
}
}
}