use of net.minecraft.item.ItemArmor in project MorePlanets by SteveKunG.
the class BlockInfectedVines method onEntityCollidedWithBlock.
@Override
public void onEntityCollidedWithBlock(World world, BlockPos pos, IBlockState state, Entity entity) {
if (entity instanceof EntityLivingBase) {
EntityLivingBase living = (EntityLivingBase) entity;
if (living instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) entity;
InventoryPlayer inventory = player.inventory;
for (int i = 0; i < 4; i++) {
if (!(inventory.armorInventory.get(i) != null && inventory.armorInventory.get(i).getItem() instanceof ItemArmor)) {
if (!player.capabilities.isCreativeMode) {
player.attackEntityFrom(DamageSourceMP.INFECTED_GAS, (int) (4.0D * 0.1D + 1.0D));
player.addPotionEffect(new PotionEffect(MobEffects.POISON, 50, 1));
}
}
}
}
if (!(living instanceof EntityPlayer) && !(entity instanceof ISpaceMob && ((ISpaceMob) entity).getMobType() == EnumMobType.NIBIRU)) {
living.attackEntityFrom(DamageSourceMP.INFECTED_GAS, (int) (4.0D * 0.1D + 1.0D));
living.addPotionEffect(new PotionEffect(MobEffects.POISON, 50, 1));
}
}
}
use of net.minecraft.item.ItemArmor in project Wurst-MC-1.12 by Wurst-Imperium.
the class AutoArmorMod method onUpdate.
@Override
public void onUpdate() {
// wait for timer
if (timer > 0) {
timer--;
return;
}
// check screen
if (mc.currentScreen instanceof GuiContainer && !(mc.currentScreen instanceof InventoryEffectRenderer))
return;
// store slots and values of best armor pieces
int[] bestArmorSlots = new int[4];
int[] bestArmorValues = new int[4];
// initialize with currently equipped armor
for (int armorType = 0; armorType < 4; armorType++) {
ItemStack oldArmor = WMinecraft.getPlayer().inventory.armorItemInSlot(armorType);
if (!WItem.isNullOrEmpty(oldArmor) && oldArmor.getItem() instanceof ItemArmor)
bestArmorValues[armorType] = ((ItemArmor) oldArmor.getItem()).damageReduceAmount;
bestArmorSlots[armorType] = -1;
}
// search inventory for better armor
for (int slot = 0; slot < 36; slot++) {
ItemStack stack = WMinecraft.getPlayer().inventory.getStackInSlot(slot);
if (WItem.isNullOrEmpty(stack) || !(stack.getItem() instanceof ItemArmor))
continue;
ItemArmor armor = (ItemArmor) stack.getItem();
int armorType = WItem.getArmorType(armor);
int armorValue = armor.damageReduceAmount;
if (armorValue > bestArmorValues[armorType]) {
bestArmorSlots[armorType] = slot;
bestArmorValues[armorType] = armorValue;
}
}
// equip better armor
for (int armorType = 0; armorType < 4; armorType++) {
// check if better armor was found
int slot = bestArmorSlots[armorType];
if (slot == -1)
continue;
// check if armor can be swapped
// needs 1 free slot where it can put the old armor
ItemStack oldArmor = WMinecraft.getPlayer().inventory.armorItemInSlot(armorType);
if (WItem.isNullOrEmpty(oldArmor) || WMinecraft.getPlayer().inventory.getFirstEmptyStack() != -1) {
// hotbar fix
if (slot < 9)
slot += 36;
// swap armor
if (!WItem.isNullOrEmpty(oldArmor))
WPlayerController.windowClick_QUICK_MOVE(8 - armorType);
WPlayerController.windowClick_QUICK_MOVE(slot);
break;
}
}
// set timer
timer = 2;
}
use of net.minecraft.item.ItemArmor in project CompositeGear by TwilightWingsStudio.
the class CommonEventHandler method onPlayerAttackTarget.
@SubscribeEvent
public boolean onPlayerAttackTarget(AttackEntityEvent event) {
if (event.getEntityPlayer().getEntityWorld().isRemote) {
return true;
}
// If we don't hate gem armor then don't execute following code.
if (!ConfigurationCG.hateGemArmor) {
return true;
}
Item itemHeld = event.getEntityPlayer().getHeldItemMainhand().getItem();
int constantGemDmg = 0;
if (itemHeld == ItemsCG.compositeMace) {
constantGemDmg = 100;
} else if (itemHeld == ItemsCG.compositeClub) {
constantGemDmg = 50;
} else {
return true;
}
if (event.getTarget() instanceof EntityPlayer) {
EntityPlayer targetPlayer = (EntityPlayer) event.getTarget();
for (ItemStack itemstack : targetPlayer.getArmorInventoryList()) {
if (itemstack != null && itemstack.getItem() instanceof ItemArmor) {
ItemArmor armorPiece = (ItemArmor) itemstack.getItem();
ItemArmor.ArmorMaterial material = armorPiece.getArmorMaterial();
if (material == ArmorMaterial.DIAMOND) {
itemstack.damageItem(constantGemDmg, targetPlayer);
} else {
String name = material.toString().toLowerCase();
for (String gem : GEMS) {
if (name.contains(gem)) {
itemstack.damageItem(constantGemDmg, targetPlayer);
break;
}
}
}
}
}
}
return true;
}
use of net.minecraft.item.ItemArmor in project CompositeGear by TwilightWingsStudio.
the class CompositeGear method registerItemColorHandler.
@SideOnly(Side.CLIENT)
public void registerItemColorHandler() {
modLog.info("Registering IItemColor handler for mod items.");
Minecraft.getMinecraft().getItemColors().registerItemColorHandler(new IItemColor() {
public int colorMultiplier(ItemStack stack, int tintIndex) {
return tintIndex > 0 ? -1 : ((ItemArmor) stack.getItem()).getColor(stack);
}
}, ItemsCG.compositeHelmet, ItemsCG.compositeChestplate, ItemsCG.compositeLeggings, ItemsCG.compositeBoots, ItemsCG.compositeFaceplate, ItemsCG.ushankaHat, ItemsCG.balaclavaMask, ItemsCG.shemaghMask, ItemsCG.rubberGasmask, ItemsCG.respiratorMask, ItemsCG.respiratorMaskComposite, ItemsCG.compositeLightHelmet, ItemsCG.compositeLightVest, ItemsCG.compositeLightLeggings, ItemsCG.compositeLightBoots);
}
use of net.minecraft.item.ItemArmor in project Tropicraft by Tropicraft.
the class ModelScubaGear method renderTank.
private void renderTank(EntityLivingBase entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
ItemStack gearStack = entityIn.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
IScubaGear gear = gearStack.getCapability(ScubaCapabilities.getGearCapability(), null);
TextureManager tm = Minecraft.getMinecraft().getTextureManager();
if (gear.getTanks().getRight() != null) {
ScubaMaterial material = gear.getStackInSlot(1).getItem() == ItemRegistry.pinkScubaTank ? ScubaMaterial.PINK : ScubaMaterial.YELLOW;
tm.bindTexture(ItemScubaGear.getArmorTexture(material));
Tank2.rotateAngleX = 0F;
Tank2.rotateAngleY = 0F;
Tank2.rotateAngleZ = 0F;
Tank2.renderWithRotation(scale);
Tank2m1.rotateAngleX = 0F;
Tank2m1.rotateAngleY = 0F;
Tank2m1.rotateAngleZ = 0F;
Tank2m1.renderWithRotation(scale);
Tank2m2.rotateAngleX = 0F;
Tank2m2.rotateAngleY = -1.570796F;
Tank2m2.rotateAngleZ = 0F;
Tank2m2.renderWithRotation(scale);
Tank2m3.rotateAngleX = 0F;
Tank2m3.rotateAngleY = -1.570796F;
Tank2m3.rotateAngleZ = 0F;
Tank2m3.renderWithRotation(scale);
Tank2m4.rotateAngleX = 0F;
Tank2m4.rotateAngleY = 0F;
Tank2m4.rotateAngleZ = 0F;
Tank2m4.renderWithRotation(scale);
Tank2m5.rotateAngleX = 0F;
Tank2m5.rotateAngleY = 0F;
Tank2m5.rotateAngleZ = 0F;
Tank2m5.renderWithRotation(scale);
Tank2m6.rotateAngleX = 0F;
Tank2m6.rotateAngleY = 0F;
Tank2m6.rotateAngleZ = 0F;
Tank2m6.renderWithRotation(scale);
Tank2m7.rotateAngleX = 0F;
Tank2m7.rotateAngleY = 0F;
Tank2m7.rotateAngleZ = 0F;
Tank2m7.renderWithRotation(scale);
}
if (gear.getTanks().getLeft() != null) {
ScubaMaterial material = gear.getStackInSlot(0).getItem() == ItemRegistry.pinkScubaTank ? ScubaMaterial.PINK : ScubaMaterial.YELLOW;
tm.bindTexture(ItemScubaGear.getArmorTexture(material));
Tank1.rotateAngleX = 0F;
Tank1.rotateAngleY = 0F;
Tank1.rotateAngleZ = 0F;
Tank1.renderWithRotation(scale);
Tank1m1.rotateAngleX = 0F;
Tank1m1.rotateAngleY = 0F;
Tank1m1.rotateAngleZ = 0F;
Tank1m1.renderWithRotation(scale);
Tank1m2.rotateAngleX = 0F;
Tank1m2.rotateAngleY = -1.570796F;
Tank1m2.rotateAngleZ = 0F;
Tank1m2.renderWithRotation(scale);
Tank1m3.rotateAngleX = 0F;
Tank1m3.rotateAngleY = -1.570796F;
Tank1m3.rotateAngleZ = 0F;
Tank1m3.renderWithRotation(scale);
Tank1m4.rotateAngleX = 0F;
Tank1m4.rotateAngleY = 0F;
Tank1m4.rotateAngleZ = 0F;
Tank1m4.renderWithRotation(scale);
Tank1m5.rotateAngleX = 0F;
Tank1m5.rotateAngleY = 0F;
Tank1m5.rotateAngleZ = 0F;
Tank1m5.renderWithRotation(scale);
Tank1m6.rotateAngleX = 0F;
Tank1m6.rotateAngleY = 0F;
Tank1m6.rotateAngleZ = 0F;
Tank1m6.renderWithRotation(scale);
Tank1m7.rotateAngleX = 0F;
Tank1m7.rotateAngleY = 0F;
Tank1m7.rotateAngleZ = 0F;
Tank1m7.renderWithRotation(scale);
}
Minecraft.getMinecraft().renderEngine.bindTexture(new ResourceLocation(((ItemArmor) gearStack.getItem()).getArmorTexture(gearStack, entityIn, EntityEquipmentSlot.CHEST, null)));
}
Aggregations