use of net.minecraft.item.ItemEndCrystal in project Spark-Client by Spark-Client-Development.
the class ShulkerAura method onUpdate.
@SubscribeEvent
void onUpdate(PlayerUpdateEvent event) {
if (targetPos == null) {
disable();
return;
}
boolean disable = true;
for (EntityPlayer e : mc.world.playerEntities) {
if (!e.isDead)
if (new BlockPos(e.posX, e.posY + 2, e.posZ).equals(targetPos)) {
disable = false;
break;
}
}
if (disable) {
Spark.sendInfo("No more target in the trap");
this.disable();
}
// trap player on sides...
for (EnumFacing facing : EnumFacing.HORIZONTALS) {
BlockPos pos = targetPos.down().add(facing.getDirectionVec());
Block block = mc.world.getBlockState(pos).getBlock();
if (block != Blocks.AIR)
continue;
BlockInteractUtil.BlockPlaceResult r = BlockInteractUtil.tryPlaceBlock(pos, new SpecBlockSwitchItem(Blocks.OBSIDIAN), false, true, 2);
if (r != BlockInteractUtil.BlockPlaceResult.FAILED)
return;
}
// trap the upperblock...
if (mc.world.getBlockState(targetPos).getBlock() == Blocks.AIR) {
BlockInteractUtil.BlockPlaceResult r = BlockInteractUtil.tryPlaceBlock(targetPos, new SpecBlockSwitchItem(Blocks.OBSIDIAN), false, true, 2);
if (r == BlockInteractUtil.BlockPlaceResult.FAILED) {
// failed lets add support
for (EnumFacing facing : EnumFacing.HORIZONTALS) {
if (targetFacing == facing || targetFacing == facing.getOpposite())
continue;
BlockPos pos = targetPos.add(facing.getDirectionVec());
Block block = mc.world.getBlockState(pos).getBlock();
if (block != Blocks.AIR)
continue;
BlockInteractUtil.BlockPlaceResult r2 = BlockInteractUtil.tryPlaceBlock(pos, new SpecBlockSwitchItem(Blocks.OBSIDIAN), false, true, 2);
if (r2 != BlockInteractUtil.BlockPlaceResult.FAILED)
return;
}
} else
return;
}
// check if the shulk is there
if (mc.world.getBlockState(targetPos.offset(targetFacing).offset(targetFacing)).getBlock() instanceof BlockShulkerBox) {
doShulkerAura();
} else {
flag = false;
int slot = ItemSwitcher.FindStackInInventory(new ShulkerSwitchItem(), false);
if ((slot != -1 && slot < 9) || !craft.getValue()) {
BlockPos support = targetPos.add(targetFacing.getDirectionVec()).add(targetFacing.getDirectionVec()).add(targetFacing.getDirectionVec());
if (mc.world.getBlockState(support).getBlock().isReplaceable(mc.world, support)) {
if (BlockInteractUtil.tryPlaceBlock(support, new SpecBlockSwitchItem(Blocks.OBSIDIAN), false, true, 2) == BlockInteractUtil.BlockPlaceResult.FAILED) {
if (BlockInteractUtil.tryPlaceBlock(support.down(), new SpecBlockSwitchItem(Blocks.OBSIDIAN), false, true, 2) == BlockInteractUtil.BlockPlaceResult.FAILED) {
if (BlockInteractUtil.tryPlaceBlock(support.down().offset(targetFacing.getOpposite()), new SpecBlockSwitchItem(Blocks.OBSIDIAN), false, true, 2) == BlockInteractUtil.BlockPlaceResult.FAILED) {
// wtf i hope we never get here but nothing left to do but return ig
} else
return;
} else
return;
} else
return;
} else {
BlockInteractUtil.tryPlaceBlockOnBlock(support.offset(targetFacing.getOpposite()), targetFacing.getOpposite(), new ShulkerSwitchItem(), false, true, 2, false);
}
} else if (craft.getValue() && mc.currentScreen == null && !flag) {
boolean flag = false;
BlockPos craftPos = null;
int best = 0;
for (BlockPos pos : WorldUtils.getSphere(PlayerUtil.getPlayerPosFloored(mc.player), 6, 6, 1)) {
if (mc.world.getBlockState(pos).getBlock() == Blocks.CRAFTING_TABLE) {
Pair<Vec3d, EnumFacing> pair = BlockInteractUtil.getInteractPoint(pos);
if (pair != null) {
craftPos = pos;
flag = true;
break;
}
}
if (!BlockInteractUtil.canPlaceBlockAtPos(pos, true))
continue;
if (BlockInteractUtil.getDirForPlacingBlockAtPos(pos) == null)
continue;
int save = 0;
for (EnumFacing enumFacing : EnumFacing.VALUES) {
if (HoleUtil.getBlockResistance(pos.offset(enumFacing)) == HoleUtil.BlockResistance.Resistant || HoleUtil.getBlockResistance(pos.offset(enumFacing)) == HoleUtil.BlockResistance.Unbreakable)
save++;
}
if (craftPos == null || save > best || (save == best && mc.player.getDistanceSq(pos) < mc.player.getDistanceSq(craftPos))) {
best = save;
craftPos = pos;
}
}
if (flag || BlockInteractUtil.tryPlaceBlock(craftPos, new SpecBlockSwitchItem(Blocks.CRAFTING_TABLE), false, true, 2) == BlockInteractUtil.BlockPlaceResult.PLACED) {
Vec3d pos = new Vec3d(craftPos).add(0.5, 0.5, 0.5);
List<Vec3d> vecs = RaytraceUtil.getVisiblePointsForBox(new AxisAlignedBB(craftPos));
if (!vecs.isEmpty())
pos = PlayerUtil.getClosestPoint(vecs);
final RayTraceResult result = mc.world.rayTraceBlocks(PlayerUtil.getEyePos(), pos, false, true, false);
EnumFacing facing = (result == null || !craftPos.equals(result.getBlockPos()) || result.sideHit == null) ? EnumFacing.UP : result.sideHit;
if (flag && !Spark.rotationManager.rotate(Spark.rotationManager.getLegitRotations(pos), AntiCheatConfig.INSTANCE.getBlockRotStep(), 2, true, false))
return;
EnumHand hand = EnumHand.OFF_HAND;
if (mc.player.getHeldItemOffhand().getItem() instanceof ItemEndCrystal && !(mc.player.getHeldItemMainhand().getItem() instanceof ItemEndCrystal))
hand = EnumHand.MAIN_HAND;
mc.player.connection.sendPacket(new CPacketPlayerTryUseItemOnBlock(craftPos, facing, hand, (float) pos.x, (float) pos.y, (float) pos.z));
state = 0;
}
} else if (craft.getValue() && mc.currentScreen instanceof GuiCrafting) {
int id = mc.player.openContainer.windowId;
if (mc.player.openContainer.getSlot(0).getStack().getItem() instanceof ItemShulkerBox) {
if (state == 4) {
mc.playerController.windowClick(id, 0, 0, ClickType.PICKUP, mc.player);
mc.playerController.windowClick(id, 36 + shulkerSlot.getValue(), 0, ClickType.PICKUP, mc.player);
mc.player.closeScreen();
state++;
} else
state++;
} else {
if (state == 0) {
shell = -1;
chest = -1;
for (int i = 10; i < 46; i++) {
ItemStack stack = mc.player.openContainer.getSlot(i).getStack();
if (stack.getItem() == Items.SHULKER_SHELL)
shell = i;
if (stack.getItem() == Item.getItemFromBlock(Blocks.CHEST))
chest = i;
if (chest > 0 && shell > 0)
break;
}
if (shell == -1 || chest == -1) {
disable();
} else
state++;
} else if (state == 1) {
if (shell == -1 || chest == -1) {
disable();
}
mc.playerController.windowClick(id, shell, 0, ClickType.PICKUP, mc.player);
mc.playerController.windowClick(id, 1, 1, ClickType.PICKUP, mc.player);
mc.playerController.windowClick(id, 7, 1, ClickType.PICKUP, mc.player);
mc.playerController.windowClick(id, shell, 0, ClickType.PICKUP, mc.player);
state++;
} else if (state == 2) {
if (shell == -1 || chest == -1) {
disable();
}
mc.playerController.windowClick(id, chest, 0, ClickType.PICKUP, mc.player);
mc.playerController.windowClick(id, 4, 1, ClickType.PICKUP, mc.player);
mc.playerController.windowClick(id, chest, 0, ClickType.PICKUP, mc.player);
state++;
}
}
}
}
}
use of net.minecraft.item.ItemEndCrystal in project cosmos by momentumdevelopment.
the class AutoCrystalModule method onPacketSend.
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onPacketSend(PacketEvent.PacketSendEvent event) {
if (event.getPacket() instanceof CPacketHeldItemChange) {
// reset our switch time, we just switched
switchTimer.resetTime();
// pause switch
Item switchItem = mc.player.inventory.getStackInSlot(((CPacketHeldItemChange) event.getPacket()).getSlotId()).getItem();
if (!(switchItem instanceof ItemEndCrystal)) {
switchTicks = 0;
}
}
}
use of net.minecraft.item.ItemEndCrystal in project 3arthh4ck by 3arthqu4ke.
the class ListenerPlace method invoke.
@Override
public void invoke(PacketEvent.Post<CPacketPlayerTryUseItemOnBlock> event) {
if (module.place.getValue()) {
CPacketPlayerTryUseItemOnBlock packet = event.getPacket();
ItemStack stack = mc.player.getHeldItem(packet.getHand());
if (stack.getItem() instanceof ItemBlock || stack.getItem() instanceof ItemEndCrystal) {
module.addWordAndIncrement(AnnouncementType.Place, stack.getDisplayName());
}
}
}
use of net.minecraft.item.ItemEndCrystal in project Spark-Client by Spark-Client-Development.
the class ShulkerAura method openShulk.
private void openShulk(BlockPos shulkPos) {
Vec3d pos = new Vec3d(shulkPos).add(0.5, 0.5, 0.5);
List<Vec3d> vecs = RaytraceUtil.getVisiblePointsForBox(mc.world.getBlockState(shulkPos).getBoundingBox(mc.world, shulkPos));
if (!vecs.isEmpty())
pos = PlayerUtil.getClosestPoint(vecs);
final RayTraceResult result = mc.world.rayTraceBlocks(PlayerUtil.getEyePos(), pos, false, true, false);
EnumFacing facing = (result == null || !shulkPos.equals(result.getBlockPos()) || result.sideHit == null) ? EnumFacing.UP : result.sideHit;
// rotate if needed
if (!Spark.rotationManager.rotate(RotationUtil.getViewRotations(pos, mc.player), AntiCheatConfig.INSTANCE.getCrystalRotStep(), 2, false)) {
return;
}
// send packet
EnumHand hand = EnumHand.OFF_HAND;
if (mc.player.getHeldItemOffhand().getItem() instanceof ItemEndCrystal && !(mc.player.getHeldItemMainhand().getItem() instanceof ItemEndCrystal))
hand = EnumHand.MAIN_HAND;
mc.player.connection.sendPacket(new CPacketPlayerTryUseItemOnBlock(shulkPos, facing, hand, (float) pos.x, (float) pos.y, (float) pos.z));
flag = true;
}
Aggregations