use of net.minecraft.util.EnumHand in project MatterOverdrive-Community-Edition-1.12.2 by Matter-Overdrive-Community-Edition.
the class RenderMatterScannerInfoHandler method onRenderWorldLast.
public void onRenderWorldLast(RenderHandler renderHandler, RenderWorldLastEvent event) {
EntityPlayer player = Minecraft.getMinecraft().player;
boolean holdingPad = false;
EnumHand hand = EnumHand.MAIN_HAND;
ItemStack heldItem = ItemStack.EMPTY;
if (!player.getHeldItem(EnumHand.MAIN_HAND).isEmpty()) {
hand = EnumHand.MAIN_HAND;
heldItem = player.getHeldItem(EnumHand.MAIN_HAND);
if (heldItem.getItem() instanceof IBlockScanner) {
holdingPad = true;
} else {
heldItem = ItemStack.EMPTY;
}
} else if (!player.getHeldItem(EnumHand.OFF_HAND).isEmpty()) {
hand = EnumHand.OFF_HAND;
heldItem = player.getHeldItem(EnumHand.OFF_HAND);
if (heldItem.getItem() instanceof IBlockScanner) {
holdingPad = true;
} else {
heldItem = ItemStack.EMPTY;
}
}
if (holdingPad && !heldItem.isEmpty() && player.getActiveHand() == hand) {
GlStateManager.pushMatrix();
renderInfo(Minecraft.getMinecraft().player, heldItem, event.getPartialTicks());
GlStateManager.popMatrix();
} else if (MOPlayerCapabilityProvider.GetAndroidCapability(Minecraft.getMinecraft().player).isAndroid()) {
renderInfo(Minecraft.getMinecraft().player, Minecraft.getMinecraft().objectMouseOver, ItemStack.EMPTY, event.getPartialTicks());
}
}
use of net.minecraft.util.EnumHand in project Advent-Of-Ascension by Tslat.
the class SoulSpark method doEntityImpact.
@Override
public boolean doEntityImpact(BaseEnergyShot shot, Entity target, EntityLivingBase shooter) {
if (!EntityUtil.isSpecExempt(target, shooter) && !EntityUtil.isTypeImmune(target, Enums.MobProperties.BLASTER_IMMUNE)) {
if (shooter instanceof EntityPlayerMP && !((EntityPlayerMP) shooter).capabilities.isCreativeMode) {
EntityPlayer player = (EntityPlayer) shooter;
PlayerDataManager.PlayerStats stats = PlayerUtil.getAdventPlayer(player).stats();
if (stats.getResourceValue(Enums.Resources.ENERGY) < 200) {
PlayerUtil.notifyPlayerOfInsufficientResources((EntityPlayerMP) player, Enums.Resources.ENERGY, 200);
return false;
}
if (stats.getResourceValue(Enums.Resources.SOUL) < 50) {
PlayerUtil.notifyPlayerOfInsufficientResources((EntityPlayerMP) player, Enums.Resources.SOUL, 50);
return false;
}
stats.consumeResource(Enums.Resources.ENERGY, 200, false);
stats.consumeResource(Enums.Resources.SOUL, 50, false);
EnumHand hand = player.getActiveHand();
ItemStack stack = player.getHeldItem(hand);
if (stack.getItem() != this)
stack = player.getHeldItem(hand == EnumHand.MAIN_HAND ? EnumHand.OFF_HAND : EnumHand.MAIN_HAND);
if (stack.getItem() != this)
return false;
stack.damageItem(1, shooter);
}
target.setDead();
return true;
}
return false;
}
use of net.minecraft.util.EnumHand in project 3arthh4ck by 3arthqu4ke.
the class ServerTimeHelper method place.
private void place(BlockPos pos, int sleep) {
SwingTime time = placeSwing.getValue();
THREAD.schedule(() -> {
if (InventoryUtil.isHolding(Items.END_CRYSTAL)) {
EnumHand hand = InventoryUtil.getHand(Items.END_CRYSTAL);
RayTraceResult ray = RotationUtil.rayTraceTo(pos, mc.world);
float[] f = RayTraceUtil.hitVecToPlaceVec(pos, ray.hitVec);
if (time == SwingTime.Pre) {
Swing.Packet.swing(hand);
Swing.Client.swing(hand);
}
mc.player.connection.sendPacket(new CPacketPlayerTryUseItemOnBlock(pos, ray.sideHit, hand, f[0], f[1], f[2]));
if (time == SwingTime.Post) {
Swing.Packet.swing(hand);
Swing.Client.swing(hand);
}
}
}, sleep, TimeUnit.MILLISECONDS);
}
use of net.minecraft.util.EnumHand in project 3arthh4ck by 3arthqu4ke.
the class ListenerSpawnObject method invoke.
@Override
public void invoke(PacketEvent.Receive<SPacketSpawnObject> event) {
EntityPlayerSP player = mc.player;
if (module.instant.getValue() && player != null && Managers.SWITCH.getLastSwitch() >= module.coolDown.getValue() && !DamageUtil.isWeaknessed() && module.timer.passed(module.delay.getValue()) && event.getPacket().getType() == 51) {
SPacketSpawnObject packet = event.getPacket();
LegConstellation constellation = module.constellation;
if (constellation != null && // TODO: make it place asnyc?
!constellation.firstNeedsObby && !constellation.secondNeedsObby && (InventoryUtil.isHolding(Items.END_CRYSTAL) || module.autoSwitch.getValue() != LegAutoSwitch.None)) {
double x = packet.getX();
double y = packet.getY();
double z = packet.getZ();
BlockPos pos = new BlockPos(x, y - 1, z);
BlockPos previous = module.targetPos;
if (!pos.equals(previous)) {
return;
}
BlockPos targetPos = constellation.firstPos.equals(previous) ? constellation.secondPos : constellation.firstPos;
EntityEnderCrystal entity = new EntityEnderCrystal(mc.world, x, y, z);
if (!module.rotate.getValue().noRotate(ACRotate.Break) && !RotationUtil.isLegit(entity) || !module.rotate.getValue().noRotate(ACRotate.Place) && !RotationUtil.isLegit(targetPos)) {
return;
}
RayTraceResult result = RotationUtil.rayTraceTo(targetPos, mc.world);
if (result == null) {
result = new RayTraceResult(new Vec3d(0.5, 1.0, 0.5), EnumFacing.UP);
}
entity.setUniqueId(packet.getUniqueId());
entity.setEntityId(packet.getEntityID());
entity.setShowBottom(false);
int slot = InventoryUtil.findHotbarItem(Items.END_CRYSTAL);
RayTraceResult finalResult = result;
Locks.acquire(Locks.PLACE_SWITCH_LOCK, () -> {
int last = player.inventory.currentItem;
EnumHand hand = player.getHeldItemMainhand().getItem() == Items.END_CRYSTAL || slot != -2 ? EnumHand.MAIN_HAND : EnumHand.OFF_HAND;
player.connection.sendPacket(new CPacketUseEntity(entity));
player.connection.sendPacket(new CPacketAnimation(EnumHand.MAIN_HAND));
InventoryUtil.switchTo(slot);
player.connection.sendPacket(new CPacketPlayerTryUseItemOnBlock(targetPos, finalResult.sideHit, hand, (float) finalResult.hitVec.x, (float) finalResult.hitVec.y, (float) finalResult.hitVec.z));
player.connection.sendPacket(new CPacketAnimation(hand));
if (last != slot && module.autoSwitch.getValue() != LegAutoSwitch.Keep) {
InventoryUtil.switchTo(last);
}
});
module.targetPos = targetPos;
if (module.setDead.getValue()) {
event.addPostEvent(() -> {
if (mc.world != null) {
Entity e = mc.world.getEntityByID(packet.getEntityID());
if (e != null) {
Managers.SET_DEAD.setDead(e);
}
}
});
}
module.timer.reset(module.delay.getValue());
}
}
}
use of net.minecraft.util.EnumHand in project 3arthh4ck by 3arthqu4ke.
the class ListenerObby method rotateCheck.
@Override
protected boolean rotateCheck() {
if (crystalPos != null && (!module.isAnvil || module.ticks > 3 && module.hasMined)) {
IBlockStateHelper helper = new BlockStateHelper();
helper.addBlockState(crystalPos, Blocks.OBSIDIAN.getDefaultState());
RayTraceResult ray = null;
if (module.rotations != null) {
ray = RotationUtil.rayTraceWithYP(crystalPos, helper, module.rotations[0], module.rotations[1], (b, p) -> p.equals(crystalPos));
}
if (ray == null) {
double x = RotationUtil.getRotationPlayer().posX;
double y = RotationUtil.getRotationPlayer().posY;
double z = RotationUtil.getRotationPlayer().posZ;
module.rotations = RotationUtil.getRotations(crystalPos.getX() + 0.5f, crystalPos.getY() + 1, crystalPos.getZ() + 0.5f, x, y, z, mc.player.getEyeHeight());
ray = RotationUtil.rayTraceWithYP(crystalPos, helper, module.rotations[0], module.rotations[1], (b, p) -> p.equals(crystalPos));
if (ray == null) {
ray = new RayTraceResult(new Vec3d(0.5, 1.0, 0.5), EnumFacing.UP, crystalPos);
}
}
int crystalSlot = module.crystalSlot;
RayTraceResult finalResult = ray;
float[] f = RayTraceUtil.hitVecToPlaceVec(crystalPos, ray.hitVec);
EnumHand h = InventoryUtil.getHand(crystalSlot);
BlockPos finalPos = crystalPos;
module.post.add(() -> {
InventoryUtil.switchTo(crystalSlot);
mc.player.connection.sendPacket(new CPacketPlayerTryUseItemOnBlock(finalPos, finalResult.sideHit, h, f[0], f[1], f[2]));
});
}
return super.rotateCheck();
}
Aggregations