Java Code Examples for net.minecraft.inventory.EntityEquipmentSlot#values()
The following examples show how to use
net.minecraft.inventory.EntityEquipmentSlot#values() .
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: MetaEntity.java From minecraft-roguelike with GNU General Public License v3.0 | 6 votes |
@Override public void setMobClass(MobType type, boolean clear) { EntityLiving oldMob = (EntityLiving)this.mob; EntityLiving newMob = (EntityLiving)MobType.getEntity(this.mob.world, type); newMob.copyLocationAndAnglesFrom(oldMob); this.mob = (Entity)newMob; if(newMob instanceof EntityZombie){ ((EntityZombie)newMob).setChild(((EntityZombie)oldMob).isChild()); } for(EntityEquipmentSlot slot : EntityEquipmentSlot.values()){ ItemStack toTrade = oldMob.getItemStackFromSlot(slot); newMob.setItemStackToSlot(slot, toTrade); } oldMob.world.removeEntity(oldMob); newMob.world.spawnEntity(newMob); }
Example 2
Source File: EntityFallenKnight.java From EnderZoo with Creative Commons Zero v1.0 Universal | 5 votes |
private void addRandomArmor() { float occupiedDiffcultyMultiplier = EntityUtil.getDifficultyMultiplierForLocation(world, posX, posY, posZ); int equipmentLevel = getRandomEquipmentLevel(occupiedDiffcultyMultiplier); int armorLevel = equipmentLevel; if(armorLevel == 1) { //Skip gold armor, I don't like it armorLevel++; } float chancePerPiece = isHardDifficulty() ? Config.fallenKnightChancePerArmorPieceHard : Config.fallenKnightChancePerArmorPiece; chancePerPiece *= (1 + occupiedDiffcultyMultiplier); //If we have the max occupied factor, double the chance of improved armor for(EntityEquipmentSlot slot : EntityEquipmentSlot.values()) { ItemStack itemStack = getItemStackFromSlot(slot); if(itemStack.isEmpty() && rand.nextFloat() <= chancePerPiece) { Item item = EntityLiving.getArmorByChance(slot, armorLevel); if(item != null) { ItemStack stack = new ItemStack(item); if(armorLevel == 0) { ((ItemArmor) item).setColor(stack, 0); } setItemStackToSlot(slot, stack); } } } if(rand.nextFloat() > Config.fallenKnightRangedRatio) { setItemStackToSlot(EntityEquipmentSlot.MAINHAND, getSwordForLevel(equipmentLevel)); if(Math.random() <= Config.fallenKnightChanceShield) { setItemStackToSlot(EntityEquipmentSlot.OFFHAND, getShieldForLevel(getRandomEquipmentLevel())); } } else { setItemStackToSlot(EntityEquipmentSlot.MAINHAND, new ItemStack(Items.BOW)); } }
Example 3
Source File: CraftEntityEquipment.java From Kettle with GNU General Public License v3.0 | 4 votes |
public void clear() { for (EntityEquipmentSlot slot : EntityEquipmentSlot.values()) { setEquipment(slot, null); } }