use of net.minecraft.item.SwordItem in project Hypnotic-Client by Hypnotic-Development.
the class Killaura method onMotionUpdate.
@EventTarget
public void onMotionUpdate(EventMotionUpdate event) {
if (maxAps.getValue() <= minAps.getValue())
maxAps.setValue(minAps.getValue() + 1);
if (event.isPre()) {
try {
if (mc.world != null) {
List<LivingEntity> targets = Lists.<LivingEntity>newArrayList();
for (Entity e : mc.world.getEntities()) {
if (e instanceof LivingEntity && e != mc.player && !FriendManager.INSTANCE.isFriend((LivingEntity) e) && mc.player.distanceTo(e) <= range.getValue() && canAttack((LivingEntity) e))
targets.add((LivingEntity) e);
else {
if (targets.contains(e))
targets.remove(e);
}
}
if (target != null && mc.player.distanceTo(target) > range.getValue()) {
targets.remove(target);
target = null;
if (!ModuleManager.INSTANCE.getModule(Scaffold.class).isEnabled()) {
RotationUtils.resetPitch();
RotationUtils.resetYaw();
}
}
switch(mode.getSelected()) {
case "Sort":
switch(sortMode.getSelected()) {
case "Distance":
targets.sort(Comparator.comparingDouble(entity -> mc.player.distanceTo(entity)));
break;
case "Health":
targets.sort(Comparator.comparingDouble(entity -> ((LivingEntity) entity).getHealth()));
break;
}
if (!targets.isEmpty()) {
if (!FriendManager.INSTANCE.isFriend((LivingEntity) targets.get(0)))
target = (LivingEntity) targets.get(0);
if (mc.player.distanceTo(target) > range.getValue())
target = null;
if (target != null) {
this.setDisplayName("Killaura " + ColorUtils.gray + (target instanceof PlayerEntity ? target.getName().asString().replaceAll(ColorUtils.colorChar, "&") : target.getDisplayName().asString()));
if (canAttack(target)) {
RotationUtils.setSilentPitch(RotationUtils.getRotations(target)[1]);
RotationUtils.setSilentYaw(RotationUtils.getRotations(target)[0]);
if (rotation.is("Lock View")) {
mc.player.setYaw(RotationUtils.getRotations(target)[0]);
mc.player.setPitch(RotationUtils.getRotations(target)[1]);
}
long aps = minAps.getValue() < 20 ? new Random().nextInt((int) (maxAps.getValue() - minAps.getValue())) + (int) minAps.getValue() : 20;
if (delay.isEnabled() && random.isEnabled() && mc.player.getAttackCooldownProgress(0.5F) != 1)
attackTimer.reset();
if (delay.isEnabled() ? mc.player.getAttackCooldownProgress(0.5F) == 1 && (random.isEnabled() ? attackTimer.hasTimeElapsed(new Random().nextInt(300 - 100) + 100, true) : true) : attackTimer.hasTimeElapsed((long) (1000L / aps), true)) {
if (autoBlock.isEnabled() && mc.player.getOffHandStack().getItem() instanceof ShieldItem && (mc.player.getMainHandStack().getItem() instanceof ToolItem || mc.player.getMainHandStack().getItem() == Items.AIR || mc.player.getMainHandStack().getItem() instanceof AxeItem || mc.player.getMainHandStack().getItem() instanceof SwordItem) && autoBlockMode.is("Normal")) {
mc.player.networkHandler.sendPacket(new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.RELEASE_USE_ITEM, BlockPos.ORIGIN, Direction.DOWN));
}
blocking = false;
mc.interactionManager.attackEntity(mc.player, target);
if (swing.isEnabled() && (autoBlock.isEnabled() ? !ModuleManager.INSTANCE.getModule(OldBlock.class).isEnabled() : true) || (ModuleManager.INSTANCE.getModule(OldBlock.class).isEnabled() ? mc.options.getPerspective() != Perspective.FIRST_PERSON : false) && !(mc.player.getMainHandStack().getItem() instanceof SwordItem))
mc.player.swingHand(Hand.MAIN_HAND);
else
mc.player.networkHandler.sendPacket(new HandSwingC2SPacket(Hand.MAIN_HAND));
if (swing.isEnabled() && !(mc.player.getMainHandStack().getItem() instanceof SwordItem) || ModuleManager.INSTANCE.getModule(OldBlock.class).animation.is("Swing"))
mc.player.swingHand(Hand.MAIN_HAND);
}
}
if (target.isDead()) {
RotationUtils.resetYaw();
RotationUtils.resetPitch();
}
} else {
if (blocking)
mc.options.useKey.setPressed(false);
blocking = false;
if (!ModuleManager.INSTANCE.getModule(Scaffold.class).isEnabled()) {
RotationUtils.resetPitch();
RotationUtils.resetYaw();
}
this.setDisplayName("Killaura " + ColorUtils.gray + "None");
}
} else {
if (blocking)
mc.options.useKey.setPressed(false);
blocking = false;
if (!ModuleManager.INSTANCE.getModule(Scaffold.class).isEnabled()) {
RotationUtils.resetPitch();
RotationUtils.resetYaw();
}
}
break;
case "Multi":
if (!targets.isEmpty()) {
for (LivingEntity entity : targets) {
if (entity != null && !FriendManager.INSTANCE.isFriend(entity)) {
this.setDisplayName("Killaura " + ColorUtils.gray + (entity instanceof PlayerEntity ? entity.getName().asString().replaceAll(ColorUtils.colorChar, "&") : entity.getDisplayName().asString()));
if (canAttack(entity)) {
if (target != null)
RotationUtils.setSilentPitch(RotationUtils.getRotations(target)[1]);
if (target != null)
RotationUtils.setSilentYaw(RotationUtils.getRotations(target)[0]);
if (rotation.is("Lock View")) {
if (target != null)
mc.player.setYaw(RotationUtils.getRotations(target)[0]);
if (target != null)
mc.player.setPitch(RotationUtils.getRotations(target)[1]);
}
long aps = minAps.getValue() < 20 ? new Random().nextInt((int) (maxAps.getValue() - minAps.getValue())) + (int) minAps.getValue() : 20;
if (delay.isEnabled() && random.isEnabled() && mc.player.getAttackCooldownProgress(0.5F) != 1)
attackTimer.reset();
if ((delay.isEnabled() ? mc.player.getAttackCooldownProgress(0.5F) == 1 && (random.isEnabled() ? attackTimer.hasTimeElapsed(new Random().nextInt(300 - 100) + 100, true) : true) : attackTimer.hasTimeElapsed((long) (1000L / aps), true)) && targets.indexOf(entity) == new Random().nextInt(targets.size())) {
if (autoBlock.isEnabled() && mc.player.getOffHandStack().getItem() instanceof ShieldItem && (mc.player.getMainHandStack().getItem() instanceof ToolItem || mc.player.getMainHandStack().getItem() == Items.AIR || mc.player.getMainHandStack().getItem() instanceof AxeItem || mc.player.getMainHandStack().getItem() instanceof SwordItem) && autoBlockMode.is("NCP")) {
mc.player.networkHandler.sendPacket(new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.RELEASE_USE_ITEM, BlockPos.ORIGIN, Direction.DOWN));
}
blocking = false;
target = entity;
mc.interactionManager.attackEntity(mc.player, entity);
if (swing.isEnabled() && (autoBlock.isEnabled() ? !ModuleManager.INSTANCE.getModule(OldBlock.class).isEnabled() : true) || (ModuleManager.INSTANCE.getModule(OldBlock.class).isEnabled() ? mc.options.getPerspective() != Perspective.FIRST_PERSON : false) && !(mc.player.getMainHandStack().getItem() instanceof SwordItem))
mc.player.swingHand(Hand.MAIN_HAND);
else
mc.player.networkHandler.sendPacket(new HandSwingC2SPacket(Hand.MAIN_HAND));
if (swing.isEnabled() && !(mc.player.getMainHandStack().getItem() instanceof SwordItem) || ModuleManager.INSTANCE.getModule(OldBlock.class).animation.is("Swing"))
mc.player.swingHand(Hand.MAIN_HAND);
}
}
if (entity.isDead()) {
RotationUtils.resetYaw();
RotationUtils.resetPitch();
}
} else {
}
}
} else {
if (!ModuleManager.INSTANCE.getModule(Scaffold.class).isEnabled()) {
RotationUtils.resetPitch();
RotationUtils.resetYaw();
}
}
break;
}
if (targets.isEmpty())
target = null;
this.setDisplayName("Killaura " + ColorUtils.gray + mode.getSelected());
}
} catch (Exception e) {
e.printStackTrace();
}
} else {
if (target == null)
return;
if (autoBlock.isEnabled() && (mc.player.getMainHandStack().getItem() instanceof ToolItem || mc.player.getMainHandStack().getItem() == Items.AIR || mc.player.getMainHandStack().getItem() instanceof AxeItem || mc.player.getMainHandStack().getItem() instanceof SwordItem) && !autoBlockMode.is("Visual")) {
mc.interactionManager.interactItem(mc.player, mc.world, Hand.OFF_HAND);
mc.interactionManager.interactItem(mc.player, mc.world, Hand.MAIN_HAND);
if (!blocking && autoBlockMode.is("NCP")) {
mc.player.networkHandler.sendPacket(new PlayerInteractBlockC2SPacket(Hand.MAIN_HAND, new BlockHitResult(new Vec3d(0.0f, 0.0f, 0.0f), Direction.DOWN, new BlockPos(-1, -1, -1), false)));
blocking = true;
}
}
}
}
use of net.minecraft.item.SwordItem in project Terracraft by SimplyCmd.
the class ItemRegistry method register.
public static void register() {
magic_mirror = new SimpleItem(ID("magic_mirror"), new MirrorItem(new FabricItemSettings().group(ItemGroup.MISC).maxCount(1))).defaultItemModel();
grenade = new SimpleItem(ID("grenade"), new GrenadeThrowableItem(new FabricItemSettings().group(ItemGroup.COMBAT))).defaultItemModel();
flaming_arrow = new SimpleItem(ID("flaming_arrow"), new FlamingArrowItem()).defaultItemModel();
soul_fire_arrow = new SimpleItem(ID("soul_fire_arrow"), new FlamingArrowItem()).defaultItemModel();
slap_hand = new SimpleItem(ID("slap_hand"), new SlapHandItem()).defaultItemModel();
wand_of_sparking = new SimpleItem(ID("wand_of_sparking"), new WandOfSparkingItem(new FabricItemSettings().group(ItemGroup.COMBAT).maxCount(1).maxDamage(250))).defaultItemModel();
heart = new SimpleItem(ID("heart"), new HeartItem()).defaultItemModel();
umbrella = new SimpleItem(ID("umbrella"), new UmbrellaItem());
sickle = new SimpleItem(ID("sickle"), new SickleItem()).defaultItemModel();
daybloom = new SimpleItem(ID("daybloom"), new Item(new FabricItemSettings().group(ItemGroup.MATERIALS)));
daybloom_seeds = new SimpleItem(ID("daybloom_seeds"), new AliasedBlockItem(BlockRegistry.daybloom.getBlock(), new FabricItemSettings().group(ItemGroup.MISC)));
blue_berries = new SimpleItem(ID("blue_berries"), new AliasedBlockItem(BlockRegistry.blue_berry_bush.getBlock(), new FabricItemSettings().group(ItemGroup.MISC)));
platinum_coin = new SimpleItem(ID("platinum_coin"), new CoinItem(new Value(1, 0, 0, 0), null)).defaultItemModel();
gold_coin = new SimpleItem(ID("gold_coin"), new CoinItem(new Value(0, 1, 0, 0), ItemRegistry.platinum_coin.getItem())).defaultItemModel();
silver_coin = new SimpleItem(ID("silver_coin"), new CoinItem(new Value(0, 0, 1, 0), ItemRegistry.gold_coin.getItem())).defaultItemModel();
copper_coin = new SimpleItem(ID("copper_coin"), new CoinItem(new Value(0, 0, 0, 1), ItemRegistry.silver_coin.getItem())).defaultItemModel();
cactus_helmet = new SimpleItem(ID("cactus_helmet"), new ArmorItem(ArmorMaterials.CACTUS, EquipmentSlot.HEAD, new FabricItemSettings().group(ItemGroup.COMBAT))).defaultItemModel();
cactus_chestplate = new SimpleItem(ID("cactus_chestplate"), new ArmorItem(ArmorMaterials.CACTUS, EquipmentSlot.CHEST, new FabricItemSettings().group(ItemGroup.COMBAT))).defaultItemModel();
cactus_leggings = new SimpleItem(ID("cactus_leggings"), new ArmorItem(ArmorMaterials.CACTUS, EquipmentSlot.LEGS, new FabricItemSettings().group(ItemGroup.COMBAT))).defaultItemModel();
cactus_boots = new SimpleItem(ID("cactus_boots"), new ArmorItem(ArmorMaterials.CACTUS, EquipmentSlot.FEET, new FabricItemSettings().group(ItemGroup.COMBAT))).defaultItemModel();
cactus_sword = new SimpleItem(ID("cactus_sword"), new SwordItem(ToolMaterials.CACTUS, 3, -2.4F, new FabricItemSettings().group(ItemGroup.COMBAT))).defaultItemModel();
cactus_shovel = new SimpleItem(ID("cactus_shovel"), new ShovelItem(ToolMaterials.CACTUS, 1.5F, -3.0F, new FabricItemSettings().group(ItemGroup.TOOLS))).defaultItemModel();
cactus_pickaxe = new SimpleItem(ID("cactus_pickaxe"), new PickaxeItem(ToolMaterials.CACTUS, 1, -2.8F, new FabricItemSettings().group(ItemGroup.TOOLS))).defaultItemModel();
cactus_axe = new SimpleItem(ID("cactus_axe"), new AxeItem(ToolMaterials.CACTUS, 6.0F, -3.2F, new FabricItemSettings().group(ItemGroup.TOOLS))).defaultItemModel();
cactus_hoe = new SimpleItem(ID("cactus_hoe"), new HoeItem(ToolMaterials.CACTUS, 0, -3.0F, new FabricItemSettings().group(ItemGroup.TOOLS))).defaultItemModel();
}
Aggregations