use of net.minecraft.util.EnumHand in project 3arthh4ck by 3arthqu4ke.
the class ListenerUpdate method invoke.
@Override
public void invoke(MotionUpdateEvent event) {
if (event.getStage() == Stage.PRE && module.mode.getValue() == FastEatMode.Update && module.isValid(mc.player.getActiveItemStack())) {
EnumHand hand = mc.player.getActiveHand();
// noinspection ConstantConditions
if (// this can happen!
hand == null) {
hand = mc.player.getHeldItemOffhand().equals(mc.player.getActiveItemStack()) ? EnumHand.OFF_HAND : EnumHand.MAIN_HAND;
}
mc.player.connection.sendPacket(new CPacketPlayerTryUseItem(hand));
} else if (event.getStage() == Stage.POST && module.mode.getValue() == FastEatMode.Packet && module.isValid(mc.player.getActiveItemStack()) && mc.player.getItemInUseMaxCount() > module.speed.getValue() - 1 && module.speed.getValue() < 25) {
for (int i = 0; i < 32; i++) {
mc.player.connection.sendPacket(new CPacketPlayer(mc.player.onGround));
}
mc.player.connection.sendPacket(new CPacketPlayerDigging(CPacketPlayerDigging.Action.RELEASE_USE_ITEM, BlockPos.ORIGIN, EnumFacing.DOWN));
mc.player.stopActiveHand();
}
}
use of net.minecraft.util.EnumHand in project defrag by Edouard127.
the class MixinMinecraft method rightClickMouseAtInvokeGetHeldItem.
// Fix random crystal placing when eating gapple in offhand
@Inject(method = "rightClickMouse", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/entity/EntityPlayerSP;getHeldItem(Lnet/minecraft/util/EnumHand;)Lnet/minecraft/item/ItemStack;"), cancellable = true)
public void rightClickMouseAtInvokeGetHeldItem(CallbackInfo ci) {
EntityPlayerSP player = Wrapper.getPlayer();
WorldClient world = Wrapper.getWorld();
PlayerControllerMP playerController = Wrapper.getMinecraft().playerController;
RayTraceResult objectMouseOver = Wrapper.getMinecraft().objectMouseOver;
if (player == null || world == null || playerController == null)
return;
if (CrystalAura.INSTANCE.isDisabled() || CrystalAura.INSTANCE.getInactiveTicks() > 2)
return;
if (player.getHeldItemOffhand().getItem() == Items.END_CRYSTAL)
return;
if (HotbarManager.INSTANCE.getServerSideItem(player).getItem() != Items.END_CRYSTAL)
return;
ci.cancel();
for (EnumHand enumhand : EnumHand.values()) {
ItemStack itemstack = player.getHeldItem(enumhand);
if (itemstack.isEmpty() && (objectMouseOver == null || objectMouseOver.typeOfHit == RayTraceResult.Type.MISS)) {
ForgeHooks.onEmptyClick(player, enumhand);
}
if (!itemstack.isEmpty() && playerController.processRightClick(player, world, enumhand) == EnumActionResult.SUCCESS) {
Wrapper.getMinecraft().entityRenderer.itemRenderer.resetEquippedProgress(enumhand);
}
}
}
use of net.minecraft.util.EnumHand in project GregTech by GregTechCE.
the class PlayerInventoryUIFactory method readHolderFromSyncData.
@Override
@SideOnly(Side.CLIENT)
protected PlayerInventoryHolder readHolderFromSyncData(PacketBuffer syncData) {
EntityPlayer entityPlayer = Minecraft.getMinecraft().player;
EnumHand enumHand = EnumHand.values()[syncData.readByte()];
ItemStack itemStack;
try {
itemStack = syncData.readItemStack();
} catch (IOException exception) {
throw new RuntimeException(exception);
}
return new PlayerInventoryHolder(entityPlayer, enumHand, itemStack);
}
use of net.minecraft.util.EnumHand in project ImmersiveEngineering by BluSunrize.
the class ApiUtils method consumePlayerIngredient.
public static void consumePlayerIngredient(EntityPlayer player, IngredientStack ingredient) {
int amount = ingredient.inputSize;
ItemStack itemstack;
for (EnumHand hand : EnumHand.values()) {
itemstack = player.getHeldItem(hand);
if (ingredient.matchesItemStackIgnoringSize(itemstack)) {
int taken = Math.min(amount, itemstack.stackSize);
amount -= taken;
itemstack.stackSize -= taken;
if (itemstack.stackSize <= 0)
player.setHeldItem(hand, null);
if (amount <= 0)
return;
}
}
for (int i = 0; i < player.inventory.getSizeInventory(); i++) {
itemstack = player.inventory.getStackInSlot(i);
if (ingredient.matchesItemStackIgnoringSize(itemstack)) {
int taken = Math.min(amount, itemstack.stackSize);
amount -= taken;
itemstack.stackSize -= taken;
if (itemstack.stackSize <= 0)
player.inventory.setInventorySlotContents(i, null);
if (amount <= 0)
return;
}
}
}
use of net.minecraft.util.EnumHand in project NetherEx by LogicTechCorp.
the class EventHandler method onPlayerRightClickBlock.
@SubscribeEvent
public static void onPlayerRightClickBlock(PlayerInteractEvent.RightClickBlock event) {
World world = event.getWorld();
BlockPos pos = event.getPos();
EntityPlayer player = event.getEntityPlayer();
ItemStack stack = event.getItemStack();
if (stack.getItem() == NetherExItems.TOOL_SHOVEL_BONE || ConfigHandler.block.netherrack.allowAllShovelsToFlatten && stack.getItem() instanceof ItemHoe) {
IBlockState state = world.getBlockState(pos);
Block block = state.getBlock();
if (block == Blocks.NETHERRACK || block == NetherExBlocks.BLOCK_NETHERRACK || block == NetherExBlocks.BLOCK_HYPHAE) {
for (EnumHand hand : EnumHand.values()) {
if (player.getHeldItem(hand).getItem() instanceof ItemSpade) {
player.swingArm(hand);
}
}
int meta = block == Blocks.NETHERRACK ? 0 : block == NetherExBlocks.BLOCK_HYPHAE ? 3 : NetherExBlocks.BLOCK_NETHERRACK.getMetaFromState(state) + 1;
world.playSound(player, pos, SoundEvents.ITEM_SHOVEL_FLATTEN, SoundCategory.BLOCKS, 1.0F, 1.0F);
world.setBlockState(pos, NetherExBlocks.BLOCK_NETHERRACK_PATH.getDefaultState().withProperty(BlockNetherrackPath.TYPE, BlockNetherrackPath.EnumType.fromMeta(meta)), 11);
stack.damageItem(1, player);
}
}
if (stack.getItem() == NetherExItems.TOOL_HOE_BONE || ConfigHandler.block.soulSand.allowAllHoesToTill && stack.getItem() instanceof ItemHoe) {
if (world.getBlockState(pos).getBlock() == Blocks.SOUL_SAND) {
for (EnumHand hand : EnumHand.values()) {
if (player.getHeldItem(hand).getItem() instanceof ItemHoe) {
player.swingArm(hand);
}
}
world.playSound(player, pos, SoundEvents.ITEM_HOE_TILL, SoundCategory.BLOCKS, 1.0F, 1.0F);
world.setBlockState(pos, NetherExBlocks.BLOCK_SAND_SOUL_TILLED.getDefaultState(), 11);
stack.damageItem(1, player);
}
}
}
Aggregations