use of net.minecraft.entity.EntityLeashKnot in project Charset by CharsetMC.
the class CharsetTweakZorro method doTheZorroThing.
@SubscribeEvent
public void doTheZorroThing(PlayerInteractEvent.EntityInteract event) {
EntityPlayer player = event.getEntityPlayer();
if (player.world.isRemote)
return;
if (player.isRiding())
return;
if (!(event.getTarget() instanceof EntityHorse))
return;
EntityHorse horse = (EntityHorse) event.getTarget();
if (player.fallDistance <= 2)
return;
if (!horse.isHorseSaddled())
return;
if (horse.getLeashed()) {
if (!(horse.getLeashHolder() instanceof EntityLeashKnot))
return;
horse.getLeashHolder().processInitialInteract(player, EnumHand.MAIN_HAND);
}
boolean awesome = false;
ItemStack heldStack = player.getHeldItem(EnumHand.MAIN_HAND);
if (player.fallDistance > 5 && !heldStack.isEmpty()) {
Item held = heldStack.getItem();
boolean has_baby = false;
if (player.getRidingEntity() instanceof EntityAgeable) {
EntityAgeable ea = (EntityAgeable) player.getRidingEntity();
has_baby = ea.isChild();
}
awesome = held instanceof ItemSword || held instanceof ItemBow || player.getRidingEntity() instanceof EntityPlayer || has_baby;
if (!awesome) {
Set<String> classes = held.getToolClasses(heldStack);
awesome |= classes.contains("axe");
}
}
if (awesome) {
horse.addPotionEffect(new PotionEffect(Potion.getPotionFromResourceLocation("speed"), 20 * 40, 2, false, false));
horse.addPotionEffect(new PotionEffect(Potion.getPotionFromResourceLocation("resistance"), 20 * 40, 1, true, true));
horse.addPotionEffect(new PotionEffect(Potion.getPotionFromResourceLocation("jump_boost"), 20 * 40, 1, true, true));
} else {
horse.addPotionEffect(new PotionEffect(Potion.getPotionFromResourceLocation("speed"), 20 * 8, 1, false, false));
}
horse.playLivingSound();
}
Aggregations