use of net.minecraft.network.packet.c2s.play.CloseHandledScreenC2SPacket in project FabricWaystones by LordDeatHunter.
the class UniversalWaystoneScreenHandler method closeOnClient.
protected void closeOnClient() {
((ClientPlayerEntityAccessor) player).getNetworkHandler().sendPacket(new CloseHandledScreenC2SPacket(this.syncId));
setCursorStack(ItemStack.EMPTY);
player.currentScreenHandler = player.playerScreenHandler;
MinecraftClient.getInstance().setScreen(null);
}
use of net.minecraft.network.packet.c2s.play.CloseHandledScreenC2SPacket in project BleachHack by BleachDrinker420.
the class AutoSteal method onTick.
@BleachSubscribe
public void onTick(EventTick event) {
currentTime++;
for (Entry<BlockPos, Integer> e : new HashMap<>(opened).entrySet()) {
if (e.getValue() <= 0)
opened.remove(e.getKey());
else
opened.replace(e.getKey(), e.getValue() - 1);
}
if (currentItems != null && currentSyncId != -1) {
if (currentTime - lastSteal >= getSetting(1).asSlider().getValue()) {
for (int i = 0; i < currentItems.size(); i++) {
if (!currentItems.get(i).isEmpty()) {
if (isBlacklisted(currentItems.get(i).getItem())) {
continue;
}
int fi = i;
boolean openSlot = InventoryUtils.getSlot(false, j -> mc.player.getInventory().getStack(j).isEmpty() || (mc.player.getInventory().getStack(j).isStackable() && mc.player.getInventory().getStack(j).getCount() < mc.player.getInventory().getStack(j).getMaxCount() && currentItems.get(fi).isItemEqual(mc.player.getInventory().getStack(j)))) != 1;
if (openSlot) {
mc.interactionManager.clickSlot(currentSyncId, i, 0, SlotActionType.QUICK_MOVE, mc.player);
currentItems.set(i, ItemStack.EMPTY);
lastSteal = currentTime + RandomUtils.nextInt(0, getSetting(2).asSlider().getValueInt() + 1);
}
return;
}
}
if (getSetting(0).asMode().getMode() >= 1 || getSetting(3).asToggle().getState()) {
mc.setScreen(null);
mc.player.networkHandler.sendPacket(new CloseHandledScreenC2SPacket(currentSyncId));
}
}
} else if (currentItems == null && currentSyncId == -1 && getSetting(3).asToggle().getState()) {
for (BlockEntity be : WorldUtils.getBlockEntities()) {
if (!opened.containsKey(be.getPos()) && be instanceof ChestBlockEntity && mc.player.getEyePos().distanceTo(Vec3d.ofCenter(be.getPos())) <= getSetting(3).asToggle().getChild(0).asSlider().getValue() + 0.25) {
Vec3d lookVec = Vec3d.ofCenter(be.getPos()).add(0, 0.5, 0);
if (getSetting(3).asToggle().getChild(2).asRotate().getState()) {
WorldUtils.facePosAuto(lookVec.x, lookVec.y, lookVec.z, getSetting(3).asToggle().getChild(2).asRotate());
}
mc.interactionManager.interactBlock(mc.player, mc.world, Hand.MAIN_HAND, new BlockHitResult(lookVec, Direction.UP, be.getPos(), false));
opened.put(be.getPos(), getSetting(3).asToggle().getChild(1).asSlider().getValueInt() * 20);
return;
}
}
}
}
use of net.minecraft.network.packet.c2s.play.CloseHandledScreenC2SPacket in project BleachHack by BleachDrinker420.
the class AutoSteal method onSendPacket.
@BleachSubscribe
public void onSendPacket(EventPacket.Send event) {
if (event.getPacket() instanceof CloseHandledScreenC2SPacket) {
currentItems = null;
currentSyncId = -1;
}
if (event.getPacket() instanceof PlayerInteractBlockC2SPacket) {
BlockPos pos = ((PlayerInteractBlockC2SPacket) event.getPacket()).getBlockHitResult().getBlockPos();
if (mc.world.getBlockState(pos).getBlock() instanceof ChestBlock) {
currentPos = pos;
}
}
}
use of net.minecraft.network.packet.c2s.play.CloseHandledScreenC2SPacket in project BleachHack by BleachDrinker420.
the class AutoSteal method onOpenScreen.
@BleachSubscribe
public void onOpenScreen(EventOpenScreen event) {
currentSyncId = -1;
if (mc.player != null) {
if (event.getScreen() instanceof HandledScreen) {
ScreenHandler handler = ((HandledScreen<?>) event.getScreen()).getScreenHandler();
if (handler instanceof GenericContainerScreenHandler) {
currentSyncId = handler.syncId;
lastOpen = currentTime;
if (getSetting(0).asMode().getMode() >= 1) {
event.setCancelled(true);
}
} else {
currentItems = null;
mc.player.networkHandler.sendPacket(new CloseHandledScreenC2SPacket(currentSyncId));
}
} else {
currentItems = null;
mc.player.networkHandler.sendPacket(new CloseHandledScreenC2SPacket(currentSyncId));
}
}
}
Aggregations