use of net.tropicraft.core.common.item.armor.ItemAshenMask in project Tropicraft by Tropicraft.
the class AIAshenShootDart method updateTask.
@Override
public void updateTask() {
EntityLivingBase entitylivingbase = this.entity.getAttackTarget();
if (entitylivingbase != null) {
ItemStack headGear = entitylivingbase.getItemStackFromSlot(EntityEquipmentSlot.HEAD);
if (headGear != null && headGear.getItem() != null) {
if (headGear.getItem() instanceof ItemAshenMask)
return;
}
double d0 = this.entity.getDistanceSq(entitylivingbase.posX, entitylivingbase.getEntityBoundingBox().minY, entitylivingbase.posZ);
boolean canSeeEnemy = this.entity.getEntitySenses().canSee(entitylivingbase);
boolean hasSeenEnemy = this.seeTime > 0;
if (canSeeEnemy != hasSeenEnemy) {
this.seeTime = 0;
}
if (canSeeEnemy) {
++this.seeTime;
} else {
--this.seeTime;
}
if (d0 <= (double) this.maxAttackDistance && this.seeTime >= 20) {
this.entity.getNavigator().clearPath();
++this.strafingTime;
} else {
this.entity.getNavigator().tryMoveToEntityLiving(entitylivingbase, moveSpeedAmplifier);
this.strafingTime = -1;
}
if (this.strafingTime >= 20) {
if ((double) this.entity.getRNG().nextFloat() < 0.3D) {
this.strafingClockwise = !this.strafingClockwise;
}
if ((double) this.entity.getRNG().nextFloat() < 0.3D) {
this.strafingBackwards = !this.strafingBackwards;
}
this.strafingTime = 0;
}
if (this.strafingTime > -1) {
if (d0 > (double) (this.maxAttackDistance * 0.75F)) {
this.strafingBackwards = false;
} else if (d0 < (double) (this.maxAttackDistance * 0.25F)) {
this.strafingBackwards = true;
}
this.entity.getMoveHelper().strafe(this.strafingBackwards ? -0.5F : 0.5F, this.strafingClockwise ? 0.5F : -0.5F);
this.entity.faceEntity(entitylivingbase, 30.0F, 30.0F);
} else {
this.entity.getLookHelper().setLookPositionWithEntity(entitylivingbase, 30.0F, 30.0F);
}
if (this.entity.isHandActive()) {
if (!canSeeEnemy && this.seeTime < -60) {
this.entity.resetActiveHand();
} else if (canSeeEnemy) {
int i = this.entity.getItemInUseMaxCount();
if (i >= 20) {
this.entity.resetActiveHand();
this.entity.attackEntityWithRangedAttack(entitylivingbase, ItemBow.getArrowVelocity(i));
this.attackTime = this.attackCooldown;
}
}
} else if (--this.attackTime <= 0 && this.seeTime >= -60) {
this.entity.setActiveHand(EnumHand.MAIN_HAND);
}
}
}
use of net.tropicraft.core.common.item.armor.ItemAshenMask in project Tropicraft by Tropicraft.
the class EntityAIMeleeAndRangedAttack method updateTask.
/**
* Updates the task
*/
@Override
public void updateTask() {
if (this.attackTarget != null) {
ItemStack headGear = this.attackTarget.getItemStackFromSlot(EntityEquipmentSlot.HEAD);
if (headGear != null && headGear.getItem() != null) {
if (headGear.getItem() instanceof ItemAshenMask)
return;
}
}
double d0 = this.entityHost.getDistanceSq(this.attackTarget.posX, this.attackTarget.getEntityBoundingBox().minY, this.attackTarget.posZ);
boolean flag = this.entityHost.getEntitySenses().canSee(this.attackTarget);
if (flag) {
++this.field_75318_f;
} else {
this.field_75318_f = 0;
}
if (d0 <= (double) this.shootCutoffRangeSqr && this.field_75318_f >= 20) {
// this.entityHost.getNavigator().clearPathEntity();
} else {
// this.entityHost.getNavigator().tryMoveToEntityLiving(this.attackTarget, this.entityMoveSpeed);
}
if (this.field_75318_f >= 20) {
this.entityHost.getNavigator().tryMoveToEntityLiving(this.attackTarget, this.entityMoveSpeed);
}
this.entityHost.getLookHelper().setLookPositionWithEntity(this.attackTarget, 30.0F, 30.0F);
float f;
if (--this.rangedAttackTime <= 0) {
/*if (d0 > (double)this.shootCutoffRangeSqr || !flag)
{
return;
}*/
f = MathHelper.sqrt(d0) / this.shootCutoffRange;
float f1 = f;
if (f < 0.1F) {
f1 = 0.1F;
}
if (f1 > 1.0F) {
f1 = 1.0F;
}
if (d0 >= (double) this.shootCutoffRange * (double) this.shootCutoffRange) {
this.rangedAttackEntityHost.attackEntityWithRangedAttack(this.attackTarget, f1);
this.rangedAttackTime = maxRangedAttackTime;
} else if (d0 <= meleeHitRange * meleeHitRange) {
this.entityHost.attackEntityAsMob(attackTarget);
this.entityHost.swingArm(EnumHand.MAIN_HAND);
rangedAttackTime = maxMeleeAttackTime;
}
}
}
use of net.tropicraft.core.common.item.armor.ItemAshenMask in project Tropicraft by Tropicraft.
the class ItemRegistry method registerItems.
@SubscribeEvent
public static void registerItems(RegistryEvent.Register<Item> event) {
blockItemRegistry.entrySet().forEach(e -> {
Item item = e.getValue().getItem(e.getKey());
item.setRegistryName(e.getKey().getRegistryName());
event.getRegistry().register(item);
e.getValue().postRegister(e.getKey(), item);
});
IForgeRegistry<Item> registry = event.getRegistry();
diveComputer = registerItem(registry, new ItemDiveComputer(), "dive_computer");
pinkWeightBelt = registerItem(registry, new ItemTropicraft(), "pink_weight_belt");
pinkPonyBottle = registerItem(registry, new ItemPonyBottle(), "pink_pony_bottle");
pinkBCD = registerItem(registry, new ItemBCD(), "pink_bcd");
pinkRegulator = registerItem(registry, new ItemTropicraft(), "pink_regulator");
pinkScubaTank = registerItem(registry, new ItemScubaTank(), "pink_scuba_tank");
pinkFlippers = registerItem(registry, new ItemScubaFlippers(materialPinkSuit, ScubaMaterial.PINK, 0, EntityEquipmentSlot.FEET), "pink_flippers");
pinkChestplateGear = registerItem(registry, new ItemScubaChestplateGear(materialPinkSuit, ScubaMaterial.PINK, 0, EntityEquipmentSlot.CHEST), "pink_chestplate_gear");
pinkScubaGoggles = registerItem(registry, new ItemScubaHelmet(materialPinkSuit, ScubaMaterial.PINK, 0, EntityEquipmentSlot.HEAD), "pink_scuba_goggles");
yellowWeightBelt = registerItem(registry, new ItemTropicraft(), "yellow_weight_belt");
yellowPonyBottle = registerItem(registry, new ItemPonyBottle(), "yellow_pony_bottle");
yellowBCD = registerItem(registry, new ItemBCD(), "yellow_bcd");
yellowRegulator = registerItem(registry, new ItemTropicraft(), "yellow_regulator");
yellowScubaTank = registerItem(registry, new ItemScubaTank(), "yellow_scuba_tank");
yellowFlippers = registerItem(registry, new ItemScubaFlippers(materialYellowSuit, ScubaMaterial.YELLOW, 0, EntityEquipmentSlot.FEET), "yellow_flippers");
yellowChestplateGear = registerItem(registry, new ItemScubaChestplateGear(materialYellowSuit, ScubaMaterial.YELLOW, 0, EntityEquipmentSlot.CHEST), "yellow_chestplate_gear");
yellowScubaGoggles = registerItem(registry, new ItemScubaHelmet(materialYellowSuit, ScubaMaterial.YELLOW, 0, EntityEquipmentSlot.HEAD), "yellow_scuba_goggles");
recordBuriedTreasure = registerItem(registry, new ItemMusicDisc("buried_treasure", "Punchaface", TropicraftSounds.BURIED_TREASURE), "buried_treasure");
recordEasternIsles = registerItem(registry, new ItemMusicDisc("eastern_isles", "Frox", TropicraftSounds.EASTERN_ISLES), "eastern_isles");
recordSummering = registerItem(registry, new ItemMusicDisc("summering", "Billy Christiansen", TropicraftSounds.SUMMERING), "summering");
recordTheTribe = registerItem(registry, new ItemMusicDisc("the_tribe", "Emile Van Krieken", TropicraftSounds.THE_TRIBE), "the_tribe");
recordLowTide = registerItem(registry, new ItemMusicDisc("low_tide", "Punchaface", TropicraftSounds.LOW_TIDE), "low_tide");
recordTradeWinds = registerItem(registry, new ItemMusicDisc("trade_winds", "Frox", TropicraftSounds.TRADE_WINDS), "trade_winds");
azurite = registerItem(registry, new ItemTropicsOre(), "azurite");
OreDictionary.registerOre("gemAzurite", azurite);
eudialyte = registerItem(registry, new ItemTropicsOre(), "eudialyte");
OreDictionary.registerOre("gemEudialyte", eudialyte);
zircon = registerItem(registry, new ItemTropicsOre(), "zircon");
OreDictionary.registerOre("gemZircon", zircon);
grapefruit = registerItem(registry, new ItemTropicraftFood(2, 0.2F), "grapefruit");
lemon = registerItem(registry, new ItemTropicraftFood(2, 0.2F), "lemon");
lime = registerItem(registry, new ItemTropicraftFood(2, 0.2F), "lime");
orange = registerItem(registry, new ItemTropicraftFood(2, 0.2F), "orange");
hoeEudialyte = registerItem(registry, new ItemHoe(materialEudialyteTools), "hoe_eudialyte");
hoeZircon = registerItem(registry, new ItemHoe(materialZirconTools), "hoe_zircon");
pickaxeEudialyte = registerItem(registry, new ItemTropicraftPickaxe(materialEudialyteTools), "pickaxe_eudialyte");
pickaxeZircon = registerItem(registry, new ItemTropicraftPickaxe(materialZirconTools), "pickaxe_zircon");
shovelEudialyte = registerItem(registry, new ItemSpade(materialEudialyteTools), "shovel_eudialyte");
shovelZircon = registerItem(registry, new ItemSpade(materialZirconTools), "shovel_zircon");
axeEudialyte = registerItem(registry, new ItemTropicraftAxe(materialEudialyteTools, 6.0F, -3.1F), "axe_eudialyte");
axeZircon = registerItem(registry, new ItemTropicraftAxe(materialZirconTools, 6.0F, -3.2F), "axe_zircon");
swordEudialyte = registerItem(registry, new ItemSword(materialEudialyteTools), "sword_eudialyte");
swordZircon = registerItem(registry, new ItemSword(materialZirconTools), "sword_zircon");
fishingNet = registerItem(registry, new ItemTropicraft(), "fishing_net");
bambooStick = registerItem(registry, new ItemTropicraft(), "bamboo_stick");
// Note: Commented out because bamboo ladder recipe would make wooden ladders
// OreDictionary.registerOre("stickWood", bambooStick);
bambooMug = registerItem(registry, new ItemTropicraft().setMaxStackSize(16), "bamboo_mug");
freshMarlin = registerItem(registry, new ItemTropicraftFood(2, 0.3F), "fresh_marlin");
searedMarlin = registerItem(registry, new ItemTropicraftFood(8, 0.65F), "seared_marlin");
tropicsWaterBucket = registerItem(registry, (new ItemBucket(BlockRegistry.tropicsWater)).setContainerItem(Items.BUCKET), "tropics_water_bucket");
fishBucket = registerItem(registry, new ItemFishBucket(), "fish_bucket");
coconutChunk = registerItem(registry, new ItemTropicraftFood(1, 0.1F), "coconut_chunk");
pineappleCubes = registerItem(registry, new ItemTropicraftFood(1, 0.1F), "pineapple_cubes");
coffeeBeans = registerMultiItem(registry, new ItemCoffeeBean(Names.COFFEE_NAMES, BlockRegistry.coffeePlant), "coffee_beans", Names.COFFEE_NAMES);
frogLeg = registerItem(registry, new ItemTropicraft().setMaxStackSize(64), "frog_leg");
cookedFrogLeg = registerItem(registry, new ItemTropicraftFood(2, 0.15F), "cooked_frog_leg");
poisonFrogSkin = registerItem(registry, new ItemTropicraft().setMaxStackSize(64), "poison_frog_skin");
scale = registerItem(registry, new ItemTropicraft().setMaxStackSize(64), "scale");
scaleBoots = registerItem(registry, new ItemScaleArmor(materialScaleArmor, 0, EntityEquipmentSlot.FEET), "scale_boots");
scaleLeggings = registerItem(registry, new ItemScaleArmor(materialScaleArmor, 0, EntityEquipmentSlot.LEGS), "scale_leggings");
scaleChestplate = registerItem(registry, new ItemScaleArmor(materialScaleArmor, 0, EntityEquipmentSlot.CHEST), "scale_chestplate");
scaleHelmet = registerItem(registry, new ItemScaleArmor(materialScaleArmor, 0, EntityEquipmentSlot.HEAD), "scale_helmet");
fireBoots = registerItem(registry, new ItemFireArmor(materialFireArmor, 0, EntityEquipmentSlot.FEET), "fire_boots");
fireLeggings = registerItem(registry, new ItemFireArmor(materialFireArmor, 0, EntityEquipmentSlot.LEGS), "fire_leggings");
fireChestplate = registerItem(registry, new ItemFireArmor(materialFireArmor, 0, EntityEquipmentSlot.CHEST), "fire_chestplate");
fireHelmet = registerItem(registry, new ItemFireArmor(materialFireArmor, 0, EntityEquipmentSlot.HEAD), "fire_helmet");
chair = registerMultiItem(registry, new ItemChair(), "chair", ItemDye.DYE_COLORS.length);
umbrella = registerMultiItem(registry, new ItemUmbrella(), "umbrella", ItemDye.DYE_COLORS.length);
beach_float = registerMultiItem(registry, new ItemBeachFloat(), "float", ItemDye.DYE_COLORS.length);
portalEnchanter = registerItem(registry, new ItemPortalEnchanter(), "portal_enchanter");
shell = registerMultiItem(registry, new ItemShell(), "shell", TropicraftShells.values());
cocktail = registerMultiItem(registry, new ItemCocktail(), "cocktail", Drink.drinkList.length);
whitePearl = registerItem(registry, new ItemTropicraft().setMaxStackSize(64), "white_pearl");
blackPearl = registerItem(registry, new ItemTropicraft().setMaxStackSize(64), "black_pearl");
fertilizer = registerItem(registry, new ItemFertilizer(), "fertilizer");
encyclopedia = registerItem(registry, new ItemEncyclopediaTropica(), "encyclopedia_tropica");
dagger = registerItem(registry, new ItemDagger(materialZirconTools), "dagger");
bambooSpear = registerItem(registry, new ItemSword(materialBambooTools), "bamboo_spear");
coconutBomb = registerItem(registry, new ItemCoconutBomb(), "coconut_bomb");
flowerPot = registerItem(registry, new ItemTropicraftBlockSpecial(BlockRegistry.flowerPot), "flower_pot");
bambooDoor = registerItem(registry, new ItemDoor(BlockRegistry.bambooDoor), "bamboo_door");
bambooItemFrame = registerItem(registry, new ItemBambooItemFrame(EntityBambooItemFrame.class), "bamboo_item_frame");
Tropicraft.proxy.registerArbitraryBlockVariants("bamboo_item_frame", "normal", "map");
waterWand = registerItem(registry, new ItemWaterWand(), "water_wand");
seaUrchinRoe = registerItem(registry, new ItemTropicraftFood(3, 0.3F), "sea_urchin_roe");
mobEgg = registerMultiItemPrefixed(registry, new ItemMobEgg(), "spawn_egg", Names.EGG_NAMES);
iguanaLeather = registerItem(registry, new ItemTropicraft().setMaxStackSize(64), "iguana_leather");
OreDictionary.registerOre("leather", iguanaLeather);
trimix = registerItem(registry, new ItemTropicraft().setMaxStackSize(1), "trimix");
maskSquareZord = registerItem(registry, new ItemAshenMask(materialMaskArmor, 0, EntityEquipmentSlot.HEAD, AshenMasks.SQUARE_ZORD), "mask_square_zord");
maskHornMonkey = registerItem(registry, new ItemAshenMask(materialMaskArmor, 0, EntityEquipmentSlot.HEAD, AshenMasks.HORN_MONKEY), "mask_horn_monkey");
maskOblongatron = registerItem(registry, new ItemAshenMask(materialMaskArmor, 0, EntityEquipmentSlot.HEAD, AshenMasks.OBLONGATRON), "mask_oblongatron");
maskHeadinator = registerItem(registry, new ItemAshenMask(materialMaskArmor, 0, EntityEquipmentSlot.HEAD, AshenMasks.HEADINATOR), "mask_headinator");
maskSquareHorn = registerItem(registry, new ItemAshenMask(materialMaskArmor, 0, EntityEquipmentSlot.HEAD, AshenMasks.SQUARE_HORN), "mask_square_horn");
maskScrewAttack = registerItem(registry, new ItemAshenMask(materialMaskArmor, 0, EntityEquipmentSlot.HEAD, AshenMasks.SCREW_ATTACK), "mask_screw_attack");
maskTheBrain = registerItem(registry, new ItemAshenMask(materialMaskArmor, 0, EntityEquipmentSlot.HEAD, AshenMasks.THE_BRAIN), "mask_the_brain");
maskBatBoy = registerItem(registry, new ItemAshenMask(materialMaskArmor, 0, EntityEquipmentSlot.HEAD, AshenMasks.BAT_BOY), "mask_bat_boy");
mask1 = registerItem(registry, new ItemAshenMask(materialMaskArmor, 0, EntityEquipmentSlot.HEAD, AshenMasks.ASHEN_MASK1), "mask_ashen_mask1");
mask2 = registerItem(registry, new ItemAshenMask(materialMaskArmor, 0, EntityEquipmentSlot.HEAD, AshenMasks.ASHEN_MASK2), "mask_ashen_mask2");
mask3 = registerItem(registry, new ItemAshenMask(materialMaskArmor, 0, EntityEquipmentSlot.HEAD, AshenMasks.ASHEN_MASK3), "mask_ashen_mask3");
mask4 = registerItem(registry, new ItemAshenMask(materialMaskArmor, 0, EntityEquipmentSlot.HEAD, AshenMasks.ASHEN_MASK4), "mask_ashen_mask4");
mask5 = registerItem(registry, new ItemAshenMask(materialMaskArmor, 0, EntityEquipmentSlot.HEAD, AshenMasks.ASHEN_MASK5), "mask_ashen_mask5");
fishingRod = registerItem(registry, new ItemFishingRod(), "fishing_rod");
ltShell = registerMultiItem(registry, new ItemLoveTropicsShell(), "ltshell", Names.LOVE_TROPICS_NAMES.length);
}
use of net.tropicraft.core.common.item.armor.ItemAshenMask in project Tropicraft by Tropicraft.
the class EntityAshenHunter method attackEntityWithRangedAttack.
/**
* Attack the specified entity using a ranged attack.
*
* @param distanceFactor How far the target is, normalized and clamped between 0.1 and 1.0
*/
@Override
public void attackEntityWithRangedAttack(EntityLivingBase target, float distanceFactor) {
ItemStack headGear = target.getItemStackFromSlot(EntityEquipmentSlot.HEAD);
if (headGear != null && headGear.getItem() != null) {
if (headGear.getItem() instanceof ItemAshenMask)
return;
}
EntityTippedArrow entitytippedarrow = new EntityTippedArrow(this.world, this);
double d0 = target.posX - this.posX;
double d1 = target.getEntityBoundingBox().minY + (double) (target.height / 3.0F) - entitytippedarrow.posY;
double d2 = target.posZ - this.posZ;
double d3 = (double) MathHelper.sqrt(d0 * d0 + d2 * d2);
entitytippedarrow.shoot(d0, d1 + d3 * 0.20000000298023224D, d2, 1.6F, (float) (14 - this.world.getDifficulty().getDifficultyId() * 4));
entitytippedarrow.setDamage(1);
entitytippedarrow.setKnockbackStrength(0);
ItemStack itemstack = new ItemStack(Items.TIPPED_ARROW);
itemstack = PotionUtils.addPotionToItemStack(itemstack, PotionType.getPotionTypeForName("slowness"));
entitytippedarrow.setPotionEffect(itemstack);
entitytippedarrow.addEffect(new PotionEffect(MobEffects.SLOWNESS, 100, 10));
this.playSound(SoundEvents.ENTITY_SKELETON_SHOOT, 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F));
this.world.spawnEntity(entitytippedarrow);
}
Aggregations