use of net.minecraft.util.EnumHand in project takumicraft by TNTModders.
the class BlockTakumiInstantWall method getItem.
@Override
public ItemBlock getItem() {
return new ItemBlock(TakumiBlockCore.CREEPER_INSTANT_WALL) {
@Override
public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
EnumActionResult result = super.onItemUse(player, worldIn, pos, hand, facing, hitX, hitY, hitZ);
player.getCooldownTracker().setCooldown(this, 100);
return result;
}
};
}
use of net.minecraft.util.EnumHand in project Spark-Client by Spark-Client-Development.
the class BlockPlaceHelper method tick.
public void tick(boolean rightClickRequested) {
if (rightClickTimer > 0) {
rightClickTimer--;
return;
}
RayTraceResult mouseOver = ctx.objectMouseOver();
if (!rightClickRequested || ctx.player().isRowingBoat() || mouseOver == null || mouseOver.getBlockPos() == null || mouseOver.typeOfHit != RayTraceResult.Type.BLOCK) {
return;
}
rightClickTimer = Baritone.settings().rightClickDelay.getValue();
for (EnumHand hand : EnumHand.values()) {
if (ctx.playerController().processRightClickBlock(ctx.player(), ctx.world(), mouseOver.getBlockPos(), mouseOver.sideHit, mouseOver.hitVec, hand) == EnumActionResult.SUCCESS) {
ctx.player().swingArm(hand);
return;
}
if (!ctx.player().getHeldItem(hand).isEmpty() && ctx.playerController().processRightClick(ctx.player(), ctx.world(), hand) == EnumActionResult.SUCCESS) {
return;
}
}
}
use of net.minecraft.util.EnumHand in project Spark-Client by Spark-Client-Development.
the class CrystalAura method doPlace.
boolean doPlace() {
if (currentCrystalBlockPos == null || !CanPlaceOnBlock(currentCrystalBlockPos, true))
return false;
if (placePauseTimer <= 0) {
// get point for rotations
if (delayTimer < 10 && slowFacePlace.getValue() && facePlace) {
return false;
}
Vec3d pos = CrystalUtil.getRotationPos(true, currentCrystalBlockPos, currentCrystalEntity);
if (pos == null)
pos = new Vec3d(currentCrystalBlockPos).add(0.5, 1, 0.5);
final RayTraceResult result = mc.world.rayTraceBlocks(PlayerUtil.getEyePos(), pos, false, true, false);
EnumFacing facing = (result == null || !currentCrystalBlockPos.equals(result.getBlockPos()) || result.sideHit == null) ? EnumFacing.UP : result.sideHit;
Vec3d v = new Vec3d(currentCrystalBlockPos).add(0.5, 0.5, 0.5).add(new Vec3d(facing.getDirectionVec()).scale(0.5));
if (result != null && currentCrystalBlockPos.equals(result.getBlockPos()) && result.hitVec != null)
v = result.hitVec;
if (currentCrystalBlockPos.getY() >= 254)
facing = EnumFacing.EAST;
renderVec = facing;
// update offhand
Offhand.instance.update();
// hand
EnumHand hand = Spark.switchManager.Switch(new SpecItemSwitchItem(Items.END_CRYSTAL), ItemSwitcher.usedHand.Both, Spark.switchManager.getModeFromString(switchingMode.getValue()), 10);
if (hand == null)
return false;
// rotate if needed
if (!rotate(false))
return true;
// send packet
mc.player.connection.sendPacket(new CPacketPlayerTryUseItemOnBlock(currentCrystalBlockPos, facing, hand, (float) v.x, (float) v.y, (float) v.z));
// swing
switch(AntiCheatConfig.getInstance().crystalPlaceSwing.getValue()) {
case "Normal":
mc.player.swingArm(hand);
break;
case "Packet":
mc.player.connection.sendPacket(new CPacketAnimation(hand));
break;
}
if (!isUpdate) {
Spark.switchManager.OnLateUpdate();
}
// apply cooldown/timeout if failed xamount(2by default) places
PlaceTries++;
if (PlaceTries >= placeTries.getValue())
placePauseTimer = placeCooldown.getValue();
// reset delay to wait time before next action
delayTimer = 0;
if (Debug.isOn())
Spark.sendInfo("Place packet sent!");
}
return true;
}
use of net.minecraft.util.EnumHand in project Spark-Client by Spark-Client-Development.
the class Burrow method OnUpdate.
@SubscribeEvent
void OnUpdate(PlayerUpdateEvent event) {
BlockPos floored = PlayerUtil.getPlayerPosFloored(mc.player, 0.2);
BlockPos pos = floored.add(0, -1, 0);
if (mc.world.getBlockState(floored).getBlock().material.isSolid() && !mc.world.getBlockState(floored.add(0, 1, 0)).getBlock().material.isSolid()) {
if (bypass.isOn()) {
mc.player.motionY = 0;
} else if (KeepPlayer.isOn()) {
Vec3d Center = new Vec3d(pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5);
double l_XDiff = Math.abs(Center.x - mc.player.posX);
double l_ZDiff = Math.abs(Center.z - mc.player.posZ);
if (l_XDiff <= 0.1 && l_ZDiff <= 0.1) {
Center = Vec3d.ZERO;
} else {
double l_MotionX = Center.x - mc.player.posX;
double l_MotionZ = Center.z - mc.player.posZ;
mc.player.motionX = l_MotionX * 0.6f;
mc.player.motionZ = l_MotionZ * 0.6f;
}
}
} else if (status > 20)
this.setEnabled(false);
if (status == 0) {
if (!mc.player.onGround) {
this.setEnabled(false);
return;
} else {
List<Entity> l = mc.world.getEntitiesWithinAABBExcludingEntity(mc.player, new AxisAlignedBB(floored));
for (Entity e : l) {
if (!(e instanceof EntityItem) && !e.isDead) {
this.setEnabled(false);
return;
}
}
}
if (Surround.instance.isPlacing())
return;
if (center.isOn()) {
Vec3d Center = new Vec3d(pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5);
double l_XDiff = Math.abs(Center.x - mc.player.posX);
double l_ZDiff = Math.abs(Center.z - mc.player.posZ);
if (l_XDiff <= 0.1 && l_ZDiff <= 0.1) {
} else {
double l_MotionX = Center.x - mc.player.posX;
double l_MotionZ = Center.z - mc.player.posZ;
mc.player.motionX = l_MotionX / 2;
mc.player.motionZ = l_MotionZ / 2;
return;
}
}
EnumHand hand = Spark.switchManager.Switch(new SpecBlockSwitchItem(getUse()), ItemSwitcher.usedHand.Both);
if (UseOtherBlocks.isOn() && hand == null)
hand = Spark.switchManager.Switch(new HardSolidBlockSwitchItem(), ItemSwitcher.usedHand.Both);
if (hand == null) {
this.setEnabled(false);
return;
}
if (Rotate.isOn()) {
sendPlayerRot(90, 90, true);
}
if (OneTick.isOn())
status = 1;
}
if (status == 1) {
Spark.rotationManager.setCancelNextWalkingUpdate();
sendPlayerPos(mc.player.posX, mc.player.posY + 0.41999998688698, mc.player.posZ, false);
sendPlayerPos(mc.player.posX, mc.player.posY + 0.7531999805212, mc.player.posZ, false);
sendPlayerPos(mc.player.posX, mc.player.posY + 1.001335979, mc.player.posZ, false);
sendPlayerPos(mc.player.posX, mc.player.posY + 1.16610926, mc.player.posZ, false);
EnumHand hand = Spark.switchManager.Switch(new SpecBlockSwitchItem(getUse()), ItemSwitcher.usedHand.Both);
if (UseOtherBlocks.isOn() && hand == null)
hand = Spark.switchManager.Switch(new HardSolidBlockSwitchItem(), ItemSwitcher.usedHand.Both);
if (hand == null) {
this.setEnabled(false);
return;
}
if (!BlockInteractUtil.processRightClickBlock(pos, EnumFacing.UP, false, hand, new Vec3d(mc.player.posX, pos.getY() + 0.5, mc.player.posZ)))
return;
Spark.sendInfo("placing burrow block");
if (OneTick.isOn())
status = 2;
}
if (status == 2) {
Vec3i clip = getClip();
sendPlayerPos(mc.player.posX + clip.getX(), mc.player.posY + clip.getY(), mc.player.posZ + clip.getZ(), true);
}
status++;
}
use of net.minecraft.util.EnumHand in project Spark-Client by Spark-Client-Development.
the class ShulkerAura method placeCrystal.
private boolean placeCrystal(BlockPos placePos) {
Vec3d pos = CrystalUtil.getRotationPos(true, placePos, null);
if (pos == null)
pos = new Vec3d(placePos).add(0.5, 1, 0.5);
final RayTraceResult result = mc.world.rayTraceBlocks(PlayerUtil.getEyePos(), pos, false, true, false);
EnumFacing facing = (result == null || !placePos.equals(result.getBlockPos()) || result.sideHit == null) ? EnumFacing.UP : result.sideHit;
Vec3d v = new Vec3d(placePos).add(0.5, 0.5, 0.5).add(new Vec3d(facing.getDirectionVec()).scale(0.5));
if (result != null && placePos.equals(result.getBlockPos()) && result.hitVec != null)
v = result.hitVec;
// offhand
EnumHand hand = Spark.switchManager.Switch(new SpecItemSwitchItem(Items.END_CRYSTAL), ItemSwitcher.usedHand.Both, ItemSwitcher.switchType.Normal);
if (hand == null) {
disable();
return false;
}
// rotate if needed
if (!Spark.rotationManager.rotate(RotationUtil.getViewRotations(pos, mc.player), AntiCheatConfig.INSTANCE.getCrystalRotStep(), 2, false)) {
return true;
}
// send packet
mc.player.connection.sendPacket(new CPacketPlayerTryUseItemOnBlock(placePos, facing, hand, (float) v.x, (float) v.y, (float) v.z));
// swing da arms
switch(AntiCheatConfig.getInstance().crystalPlaceSwing.getValue()) {
case "Normal":
mc.player.swingArm(hand);
break;
case "Packet":
mc.player.connection.sendPacket(new CPacketAnimation(hand));
break;
}
return true;
}
Aggregations