Java Code Examples for net.minecraft.init.Items#SHIELD
The following examples show how to use
net.minecraft.init.Items#SHIELD .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: KillAuraModule.java From seppuku with GNU General Public License v3.0 | 9 votes |
@Listener public void onWalkingUpdate(EventUpdateWalkingPlayer event) { if (event.getStage() == EventStageable.EventStage.PRE) { final Minecraft mc = Minecraft.getMinecraft(); final Entity target = findTarget(); if (target != null) { final float[] angle = MathUtil.calcAngle(mc.player.getPositionEyes(mc.getRenderPartialTicks()), target.getPositionEyes(mc.getRenderPartialTicks())); Seppuku.INSTANCE.getRotationManager().setPlayerRotations(angle[0], angle[1]); final float ticks = 20.0f - Seppuku.INSTANCE.getTickRateManager().getTickRate(); final boolean canAttack = this.coolDown.getValue() ? (mc.player.getCooledAttackStrength(this.sync.getValue() ? -ticks : 0.0f) >= 1) : true; final ItemStack stack = mc.player.getHeldItem(EnumHand.OFF_HAND); //TODO interp if (this.teleport.getValue()) { Seppuku.INSTANCE.getPositionManager().setPlayerPosition(target.posX, target.posY, target.posZ); } if (canAttack) { if (stack != null && stack.getItem() == Items.SHIELD) { mc.player.connection.sendPacket(new CPacketPlayerDigging(CPacketPlayerDigging.Action.RELEASE_USE_ITEM, BlockPos.ORIGIN, mc.player.getHorizontalFacing())); } mc.player.connection.sendPacket(new CPacketUseEntity(target)); mc.player.swingArm(EnumHand.MAIN_HAND); mc.player.resetCooldown(); } } } }
Example 2
Source File: EntityToroNpc.java From ToroQuest with GNU General Public License v3.0 | 7 votes |
protected void handleSuccessfulAttack(Entity entityIn, int knockback) { if (knockback > 0 && entityIn instanceof EntityLivingBase) { ((EntityLivingBase) entityIn).knockBack(this, (float) knockback * 0.5F, (double) MathHelper.sin(this.rotationYaw * 0.017453292F), (double) (-MathHelper.cos(this.rotationYaw * 0.017453292F))); this.motionX *= 0.6D; this.motionZ *= 0.6D; } int j = EnchantmentHelper.getFireAspectModifier(this); if (j > 0) { entityIn.setFire(j * 4); } if (entityIn instanceof EntityPlayer) { EntityPlayer entityplayer = (EntityPlayer) entityIn; ItemStack itemstack = this.getHeldItemMainhand(); ItemStack itemstack1 = entityplayer.isHandActive() ? entityplayer.getActiveItemStack() : null; if (itemstack != null && itemstack1 != null && itemstack.getItem() instanceof ItemAxe && itemstack1.getItem() == Items.SHIELD) { float f1 = 0.25F + (float) EnchantmentHelper.getEfficiencyModifier(this) * 0.05F; if (this.rand.nextFloat() < f1) { entityplayer.getCooldownTracker().setCooldown(Items.SHIELD, 100); this.world.setEntityState(entityplayer, (byte) 30); } } } this.applyEnchantments(this, entityIn); }
Example 3
Source File: EntityToro.java From ToroQuest with GNU General Public License v3.0 | 4 votes |
@Override public boolean attackEntityAsMob(Entity victim) { float attackDamage = (float) this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getAttributeValue(); int knockback = 2; if (victim instanceof EntityLivingBase) { attackDamage += EnchantmentHelper.getModifierForCreature(this.getHeldItemMainhand(), ((EntityLivingBase) victim).getCreatureAttribute()); knockback += EnchantmentHelper.getKnockbackModifier(this); } boolean wasDamaged = victim.attackEntityFrom(DamageSource.causeMobDamage(this), attackDamage); if (wasDamaged) { setRevengeTarget(getAttackTarget()); setAttackTarget(null); if (knockback > 0 && victim instanceof EntityLivingBase) { ((EntityLivingBase) victim).knockBack(this, (float) knockback * 0.5F, (double) MathHelper.sin(this.rotationYaw * 0.017453292F), (double) (-MathHelper.cos(this.rotationYaw * 0.017453292F))); this.motionX *= 0.6D; this.motionZ *= 0.6D; } if (victim instanceof EntityPlayer) { EntityPlayer entityplayer = (EntityPlayer) victim; ItemStack itemstack = this.getHeldItemMainhand(); ItemStack itemstack1 = entityplayer.isHandActive() ? entityplayer.getActiveItemStack() : null; if (itemstack != null && itemstack1 != null && itemstack.getItem() instanceof ItemAxe && itemstack1.getItem() == Items.SHIELD) { float f1 = 0.25F + (float) EnchantmentHelper.getEfficiencyModifier(this) * 0.05F; if (this.rand.nextFloat() < f1) { entityplayer.getCooldownTracker().setCooldown(Items.SHIELD, 100); this.world.setEntityState(entityplayer, (byte) 30); } } } this.applyEnchantments(this, victim); } return wasDamaged; }
Example 4
Source File: EntityFallenKnight.java From EnderZoo with Creative Commons Zero v1.0 Universal | 4 votes |
private ItemStack getShieldForLevel(int swordLevel) { //TODO: 1.9 Can I do something better here? return new ItemStack(Items.SHIELD); }
Example 5
Source File: Shield.java From minecraft-roguelike with GNU General Public License v3.0 | 4 votes |
public static ItemStack get(Random rand){ ItemStack banner = Banner.get(rand); ItemStack shield = new ItemStack(Items.SHIELD, 1, 0); applyBanner(banner, shield); return shield; }