Java 类net.minecraft.inventory.EntityEquipmentSlot 实例源码
项目:Zombe-Modpack
文件:EntityPlayer.java
protected void damageShield(float damage)
{
if (damage >= 3.0F && this.activeItemStack.getItem() == Items.SHIELD)
{
int i = 1 + MathHelper.floor(damage);
this.activeItemStack.damageItem(i, this);
if (this.activeItemStack.func_190926_b())
{
EnumHand enumhand = this.getActiveHand();
if (enumhand == EnumHand.MAIN_HAND)
{
this.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, ItemStack.field_190927_a);
}
else
{
this.setItemStackToSlot(EntityEquipmentSlot.OFFHAND, ItemStack.field_190927_a);
}
this.activeItemStack = ItemStack.field_190927_a;
this.playSound(SoundEvents.ITEM_SHIELD_BREAK, 0.8F, 0.8F + this.world.rand.nextFloat() * 0.4F);
}
}
}
项目:Mods
文件:ItemWeapon.java
@Override
public Multimap<String, AttributeModifier> getAttributeModifiers(EntityEquipmentSlot slot, ItemStack stack) {
Multimap<String, AttributeModifier> multimap = super.getAttributeModifiers(slot, stack);
if (slot == EntityEquipmentSlot.MAINHAND && getData(stack) != ItemFromData.BLANK_DATA && stack.hasTagCompound()) {
int heads=Math.min((int)TF2Attribute.getModifier("Kill Count", stack, 0, null), stack.getTagCompound().getInteger("Heads"));
multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(),
new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier",
this.getWeaponDamage(stack, null, null) * this.getWeaponPelletCount(stack, null) - 1, 0));
multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getName(), new AttributeModifier(
ATTACK_SPEED_MODIFIER, "Weapon modifier", -4 + (1000D / this.getFiringSpeed(stack, null)), 0));
float addHealth = TF2Attribute.getModifier("Health", stack, 0, null)+heads * TF2Attribute.getModifier("Max Health Kill", stack, 0, null);
if (addHealth != 0)
multimap.put(SharedMonsterAttributes.MAX_HEALTH.getName(),
new AttributeModifier(HEALTH_MODIFIER, "Weapon modifier", addHealth, 0));
float addSpeed = TF2Attribute.getModifier("Speed", stack, 1 + heads * TF2Attribute.getModifier("Speed Kill", stack, 0, null), null);
if (addSpeed != 1)
multimap.put(SharedMonsterAttributes.MOVEMENT_SPEED.getName(),
new AttributeModifier(SPEED_MODIFIER, "Weapon modifier", addSpeed - 1, 2));
}
return multimap;
}
项目:CustomWorldGen
文件:ItemStack.java
public void addAttributeModifier(String attributeName, AttributeModifier modifier, EntityEquipmentSlot equipmentSlot)
{
if (this.stackTagCompound == null)
{
this.stackTagCompound = new NBTTagCompound();
}
if (!this.stackTagCompound.hasKey("AttributeModifiers", 9))
{
this.stackTagCompound.setTag("AttributeModifiers", new NBTTagList());
}
NBTTagList nbttaglist = this.stackTagCompound.getTagList("AttributeModifiers", 10);
NBTTagCompound nbttagcompound = SharedMonsterAttributes.writeAttributeModifierToNBT(modifier);
nbttagcompound.setString("AttributeName", attributeName);
if (equipmentSlot != null)
{
nbttagcompound.setString("Slot", equipmentSlot.getName());
}
nbttaglist.appendTag(nbttagcompound);
}
项目:FirstAid
文件:DamageDistribution.java
@Override
public float distributeDamage(float damage, @Nonnull EntityPlayer player, @Nonnull DamageSource source, boolean addStat) {
AbstractPlayerDamageModel damageModel = PlayerDataManager.getDamageModel(player);
for (Pair<EntityEquipmentSlot, EnumPlayerPart[]> pair : getPartList()) {
EntityEquipmentSlot slot = pair.getLeft();
damage = ArmorUtils.applyArmor(player, player.getItemStackFromSlot(slot), source, damage, slot);
if (damage <= 0F)
return 0F;
damage = ArmorUtils.applyEnchantmentModifiers(player.getItemStackFromSlot(slot), source, damage);
if (damage <= 0F)
return 0F;
damage = distributeDamageOnParts(damage, damageModel, pair.getRight(), player, addStat);
if (damage == 0F)
break;
}
return damage;
}
项目:Backmemed
文件:EntityPig.java
/**
* Called when a lightning bolt hits the entity.
*/
public void onStruckByLightning(EntityLightningBolt lightningBolt)
{
if (!this.world.isRemote && !this.isDead)
{
EntityPigZombie entitypigzombie = new EntityPigZombie(this.world);
entitypigzombie.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, new ItemStack(Items.GOLDEN_SWORD));
entitypigzombie.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, this.rotationPitch);
entitypigzombie.setNoAI(this.isAIDisabled());
if (this.hasCustomName())
{
entitypigzombie.setCustomNameTag(this.getCustomNameTag());
entitypigzombie.setAlwaysRenderNameTag(this.getAlwaysRenderNameTag());
}
this.world.spawnEntityInWorld(entitypigzombie);
this.setDead();
}
}
项目:pnc-repressurized
文件:RenderSearchItemBlock.java
private int getSearchedItemCount() {
TileEntity te = world.getTileEntity(pos);
if (te != null && te.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null)) {
// if (world.getTileEntity(pos) instanceof IInventory) {
IItemHandler handler = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
int itemCount = 0;
// IInventory inventory = (IInventory) world.getTileEntity(pos);
ItemStack searchStack = ItemPneumaticArmor.getSearchedStack(FMLClientHandler.instance().getClient().player.getItemStackFromSlot(EntityEquipmentSlot.HEAD));
if (searchStack.isEmpty()) return 0;
for (int l = 0; l < handler.getSlots(); l++) {
if (!handler.getStackInSlot(l).isEmpty()) {
itemCount += getSearchedItemCount(handler.getStackInSlot(l), searchStack);
}
}
return itemCount;
}
return 0;
}
项目:UniversalRemote
文件:Util.java
public static void setPlayerItemStackInHand(ItemStack stack, EntityPlayer player, EnumHand hand)
{
// okay, find the itemstack
if (hand == EnumHand.MAIN_HAND)
{
player.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, stack);
}
else if (hand == EnumHand.OFF_HAND)
{
player.setItemStackToSlot(EntityEquipmentSlot.OFFHAND, stack);
}
else
{
// uhh... what?
Util.logger.error("Found invalid EnumHand value!");
}
}
项目:CustomWorldGen
文件:EntityAISkeletonRiders.java
private EntitySkeleton createSkeleton(DifficultyInstance p_188514_1_, EntityHorse p_188514_2_)
{
EntitySkeleton entityskeleton = new EntitySkeleton(p_188514_2_.worldObj);
entityskeleton.onInitialSpawn(p_188514_1_, (IEntityLivingData)null);
entityskeleton.setPosition(p_188514_2_.posX, p_188514_2_.posY, p_188514_2_.posZ);
entityskeleton.hurtResistantTime = 60;
entityskeleton.enablePersistence();
if (entityskeleton.getItemStackFromSlot(EntityEquipmentSlot.HEAD) == null)
{
entityskeleton.setItemStackToSlot(EntityEquipmentSlot.HEAD, new ItemStack(Items.IRON_HELMET));
}
EnchantmentHelper.addRandomEnchantment(entityskeleton.getRNG(), entityskeleton.getHeldItemMainhand(), (int)(5.0F + p_188514_1_.getClampedAdditionalDifficulty() * (float)entityskeleton.getRNG().nextInt(18)), false);
EnchantmentHelper.addRandomEnchantment(entityskeleton.getRNG(), entityskeleton.getItemStackFromSlot(EntityEquipmentSlot.HEAD), (int)(5.0F + p_188514_1_.getClampedAdditionalDifficulty() * (float)entityskeleton.getRNG().nextInt(18)), false);
entityskeleton.worldObj.spawnEntityInWorld(entityskeleton);
return entityskeleton;
}
项目:CompositeGear
文件:ItemCGArmor.java
public ItemCGArmor(String id, ArmorMaterial armorMaterial, String armorName, int renderIndex, EntityEquipmentSlot armorType)
{
super(armorMaterial, renderIndex, armorType);
this.armorName = armorName;
this.itemClass = EnumItemClass.MEDIUM_ARMOR;
this.isAirMask = false;
this.minAirToStartRefil = 0;
this.rarity = EnumRarity.COMMON;
setUnlocalizedName(id);
ItemsCG.registerItem(this, new ResourceLocation(ModInfo.MODID, id)); // Put into registry.
if (CompositeGear.ic2Tab != null) {
setCreativeTab(CompositeGear.ic2Tab);
}
}
项目:CustomWorldGen
文件:Enchantment.java
@Nullable
public Iterable<ItemStack> getEntityEquipment(EntityLivingBase entityIn)
{
List<ItemStack> list = Lists.<ItemStack>newArrayList();
for (EntityEquipmentSlot entityequipmentslot : this.applicableEquipmentTypes)
{
ItemStack itemstack = entityIn.getItemStackFromSlot(entityequipmentslot);
if (itemstack != null)
{
list.add(itemstack);
}
}
return list.size() > 0 ? list : null;
}
项目:CustomWorldGen
文件:SetAttributes.java
public ItemStack apply(ItemStack stack, Random rand, LootContext context)
{
for (SetAttributes.Modifier setattributes$modifier : this.modifiers)
{
UUID uuid = setattributes$modifier.uuid;
if (uuid == null)
{
uuid = UUID.randomUUID();
}
EntityEquipmentSlot entityequipmentslot = setattributes$modifier.slots[rand.nextInt(setattributes$modifier.slots.length)];
stack.addAttributeModifier(setattributes$modifier.attributeName, new AttributeModifier(uuid, setattributes$modifier.modifierName, (double)setattributes$modifier.amount.generateFloat(rand), setattributes$modifier.operation), entityequipmentslot);
}
return stack;
}
项目:Backmemed
文件:ItemArmor.java
public ActionResult<ItemStack> onItemRightClick(World itemStackIn, EntityPlayer worldIn, EnumHand playerIn)
{
ItemStack itemstack = worldIn.getHeldItem(playerIn);
EntityEquipmentSlot entityequipmentslot = EntityLiving.getSlotForItemStack(itemstack);
ItemStack itemstack1 = worldIn.getItemStackFromSlot(entityequipmentslot);
if (itemstack1.func_190926_b())
{
worldIn.setItemStackToSlot(entityequipmentslot, itemstack.copy());
itemstack.func_190920_e(0);
return new ActionResult(EnumActionResult.SUCCESS, itemstack);
}
else
{
return new ActionResult(EnumActionResult.FAIL, itemstack);
}
}
项目:Adventurers-Toolbox
文件:ItemRock.java
@Override
public Multimap<String, AttributeModifier> getAttributeModifiers(EntityEquipmentSlot equipmentSlot,
ItemStack stack) {
Multimap<String, AttributeModifier> multimap = super.getItemAttributeModifiers(equipmentSlot);
if (equipmentSlot == EntityEquipmentSlot.MAINHAND) {
multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(),
new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", (double) 3.0F, 0));
multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getName(),
new AttributeModifier(ATTACK_SPEED_MODIFIER, "Weapon modifier", (double) -3F, 0));
}
return multimap;
}
项目:Loot-Slash-Conquer
文件:ItemLEAdvancedMelee.java
@Override
public Multimap<String, AttributeModifier> getAttributeModifiers(EntityEquipmentSlot slot, ItemStack stack)
{
final Multimap<String, AttributeModifier> modifiers = super.getAttributeModifiers(slot, stack);
if (slot == EntityEquipmentSlot.MAINHAND)
{
replaceModifier(modifiers, SharedMonsterAttributes.ATTACK_DAMAGE, ATTACK_DAMAGE_MODIFIER, damageMultiplier);
replaceModifier(modifiers, SharedMonsterAttributes.ATTACK_SPEED, ATTACK_SPEED_MODIFIER, speedMultiplier);
}
return modifiers;
}
项目:pnc-repressurized
文件:HUDHandler.java
@SubscribeEvent
public void renderWorldLastEvent(RenderWorldLastEvent event) {
if (!GuiKeybindCheckBox.trackedCheckboxes.get("pneumaticHelmet.upgrade.coreComponents").checked) return;
Minecraft mc = FMLClientHandler.instance().getClient();
EntityPlayer player = mc.player;
double playerX = player.prevPosX + (player.posX - player.prevPosX) * event.getPartialTicks();
double playerY = player.prevPosY + (player.posY - player.prevPosY) * event.getPartialTicks();
double playerZ = player.prevPosZ + (player.posZ - player.prevPosZ) * event.getPartialTicks();
GL11.glPushMatrix();
GL11.glTranslated(-playerX, -playerY, -playerZ);
ItemStack helmetStack = player.getItemStackFromSlot(EntityEquipmentSlot.HEAD);
if (helmetStack.getItem() == Itemss.PNEUMATIC_HELMET) {
if (((IPressurizable) helmetStack.getItem()).getPressure(helmetStack) > 0F) {
CommonHUDHandler comHudHandler = CommonHUDHandler.getHandlerForPlayer(player);
if (comHudHandler.ticksExisted > comHudHandler.getStartupTime()) {
GL11.glDisable(GL11.GL_TEXTURE_2D);
for (int i = 0; i < UpgradeRenderHandlerList.instance().upgradeRenderers.size(); i++) {
if (comHudHandler.upgradeRenderersInserted[i] && GuiKeybindCheckBox.trackedCheckboxes.get("pneumaticHelmet.upgrade." + UpgradeRenderHandlerList.instance().upgradeRenderers.get(i).getUpgradeName()).checked)
UpgradeRenderHandlerList.instance().upgradeRenderers.get(i).render3D(event.getPartialTicks());
}
GL11.glEnable(GL11.GL_TEXTURE_2D);
}
}
}
GL11.glPopMatrix();
}
项目:uniquecrops
文件:TileShyPlant.java
@Override
public void update() {
if (worldObj.isRemote)
return;
if (this.worldObj.getTotalWorldTime() % 10L != 0)
return;
boolean wasLooking = this.isLooking();
int range = 10;
List<EntityPlayer> players = worldObj.getEntitiesWithinAABB(EntityPlayer.class, new AxisAlignedBB(pos.add(-range, -range, -range), pos.add(range, range, range)));
boolean looker = false;
for (EntityPlayer player : players) {
ItemStack helm = player.getItemStackFromSlot(EntityEquipmentSlot.HEAD);
if (helm != null && helm.getItem() == Item.getItemFromBlock(Blocks.PUMPKIN))
continue;
RayTraceResult rtr = this.rayTraceFromEntity(worldObj, player, true, range);
if (rtr != null && rtr.getBlockPos() != null && rtr.getBlockPos().equals(getPos())) {
looker = true;
break;
}
if (!wasLooking && ((WeepingBells)worldObj.getBlockState(getPos()).getBlock()).isWeepingCropGrown(worldObj.getBlockState(getPos())) && !player.capabilities.isCreativeMode) {
if (getTarget(worldObj, getPos()).canEntityBeSeen(player)) {
player.attackEntityFrom(DamageSource.outOfWorld, 1.0F);
}
}
}
if (looker != wasLooking && !worldObj.isRemote)
setLooking(looker);
}
项目:Backmemed
文件:EntityArmorStand.java
private void swapItem(EntityPlayer player, EntityEquipmentSlot p_184795_2_, ItemStack p_184795_3_, EnumHand hand)
{
ItemStack itemstack = this.getItemStackFromSlot(p_184795_2_);
if (itemstack.func_190926_b() || (this.disabledSlots & 1 << p_184795_2_.getSlotIndex() + 8) == 0)
{
if (!itemstack.func_190926_b() || (this.disabledSlots & 1 << p_184795_2_.getSlotIndex() + 16) == 0)
{
if (player.capabilities.isCreativeMode && itemstack.func_190926_b() && !p_184795_3_.func_190926_b())
{
ItemStack itemstack2 = p_184795_3_.copy();
itemstack2.func_190920_e(1);
this.setItemStackToSlot(p_184795_2_, itemstack2);
}
else if (!p_184795_3_.func_190926_b() && p_184795_3_.func_190916_E() > 1)
{
if (itemstack.func_190926_b())
{
ItemStack itemstack1 = p_184795_3_.copy();
itemstack1.func_190920_e(1);
this.setItemStackToSlot(p_184795_2_, itemstack1);
p_184795_3_.func_190918_g(1);
}
}
else
{
this.setItemStackToSlot(p_184795_2_, p_184795_3_);
player.setHeldItem(hand, itemstack);
}
}
}
}
项目:Adventurers-Toolbox
文件:ItemATSword.java
@Override
public Multimap<String, AttributeModifier> getAttributeModifiers(EntityEquipmentSlot equipmentSlot,
ItemStack stack) {
Multimap<String, AttributeModifier> multimap = HashMultimap.<String, AttributeModifier>create();
if (equipmentSlot == EntityEquipmentSlot.MAINHAND) {
multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER,
"Weapon modifier", (double) 3.0F + this.getAttackDamage(stack), 0));
multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getName(), new AttributeModifier(ATTACK_SPEED_MODIFIER,
"Weapon modifier", (double) (-2.4000000953674316D + getEfficiencyMod(stack)), 0));
}
return multimap;
}
项目:Backmemed
文件:ItemTool.java
public Multimap<String, AttributeModifier> getItemAttributeModifiers(EntityEquipmentSlot equipmentSlot)
{
Multimap<String, AttributeModifier> multimap = super.getItemAttributeModifiers(equipmentSlot);
if (equipmentSlot == EntityEquipmentSlot.MAINHAND)
{
multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getAttributeUnlocalizedName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Tool modifier", (double)this.damageVsEntity, 0));
multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getAttributeUnlocalizedName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Tool modifier", (double)this.attackSpeed, 0));
}
return multimap;
}
项目:Mods
文件:ItemArmorTF2.java
public Multimap<String, AttributeModifier> getItemAttributeModifiers(EntityEquipmentSlot equipmentSlot)
{
Multimap<String, AttributeModifier> multimap = super.getItemAttributeModifiers(equipmentSlot);
if (equipmentSlot == this.armorType && this.knockbackReduction != 0)
{
multimap.put(SharedMonsterAttributes.KNOCKBACK_RESISTANCE.getName(), new AttributeModifier(knockbackUUID, "Knockback modifier", (double)this.knockbackReduction, 0));
}
return multimap;
}
项目:Backmemed
文件:ItemSword.java
public Multimap<String, AttributeModifier> getItemAttributeModifiers(EntityEquipmentSlot equipmentSlot)
{
Multimap<String, AttributeModifier> multimap = super.getItemAttributeModifiers(equipmentSlot);
if (equipmentSlot == EntityEquipmentSlot.MAINHAND)
{
multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getAttributeUnlocalizedName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", (double)this.attackDamage, 0));
multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getAttributeUnlocalizedName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Weapon modifier", -2.4000000953674316D, 0));
}
return multimap;
}
项目:Backmemed
文件:EntityLiving.java
public void setDropChance(EntityEquipmentSlot slotIn, float chance)
{
switch (slotIn.getSlotType())
{
case HAND:
this.inventoryHandsDropChances[slotIn.getIndex()] = chance;
break;
case ARMOR:
this.inventoryArmorDropChances[slotIn.getIndex()] = chance;
}
}
项目:pnc-repressurized
文件:PacketUpdateSearchStack.java
@Override
public void handleServerSide(PacketUpdateSearchStack message, EntityPlayer player) {
ItemStack helmetStack = player.getItemStackFromSlot(EntityEquipmentSlot.HEAD);
if (!helmetStack.isEmpty()) {
NBTTagCompound tag = NBTUtil.getCompoundTag(helmetStack, "SearchStack");
tag.setInteger("itemID", message.itemId);
tag.setInteger("itemDamage", message.itemDamage);
}
}
项目:pnc-repressurized
文件:EventHandlerPneumaticCraft.java
@SideOnly(Side.CLIENT)
private void warnPlayerIfNecessary(LivingSetAttackTargetEvent event) {
EntityPlayer player = FMLClientHandler.instance().getClient().player;
if (event.getTarget() == player && (event.getEntityLiving() instanceof EntityGolem || event.getEntityLiving() instanceof EntityMob)) {
ItemStack helmetStack = player.getItemStackFromSlot(EntityEquipmentSlot.HEAD);
if (helmetStack.getItem() == Itemss.PNEUMATIC_HELMET && ((IPressurizable) helmetStack.getItem()).getPressure(helmetStack) > 0 && ItemPneumaticArmor.getUpgrades(EnumUpgrade.ENTITY_TRACKER, helmetStack) > 0 && GuiKeybindCheckBox.trackedCheckboxes.get("pneumaticHelmet.upgrade.coreComponents").checked && GuiKeybindCheckBox.trackedCheckboxes.get("pneumaticHelmet.upgrade." + EntityTrackUpgradeHandler.UPGRADE_NAME).checked) {
HUDHandler.instance().getSpecificRenderer(EntityTrackUpgradeHandler.class).warnIfNecessary(event.getEntity());
}
} else {
HUDHandler.instance().getSpecificRenderer(EntityTrackUpgradeHandler.class).removeTargetingEntity(event.getEntityLiving());
}
}
项目:CustomWorldGen
文件:ItemArmor.java
public Multimap<String, AttributeModifier> getItemAttributeModifiers(EntityEquipmentSlot equipmentSlot)
{
Multimap<String, AttributeModifier> multimap = super.getItemAttributeModifiers(equipmentSlot);
if (equipmentSlot == this.armorType)
{
multimap.put(SharedMonsterAttributes.ARMOR.getAttributeUnlocalizedName(), new AttributeModifier(ARMOR_MODIFIERS[equipmentSlot.getIndex()], "Armor modifier", (double)this.damageReduceAmount, 0));
multimap.put(SharedMonsterAttributes.ARMOR_TOUGHNESS.getAttributeUnlocalizedName(), new AttributeModifier(ARMOR_MODIFIERS[equipmentSlot.getIndex()], "Armor toughness", (double)this.toughness, 0));
}
return multimap;
}
项目:CustomWorldGen
文件:EntityZombie.java
/**
* Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons
* use this to react to sunlight and start to burn.
*/
public void onLivingUpdate()
{
if (this.worldObj.isDaytime() && !this.worldObj.isRemote && !this.isChild() && (this.getZombieType() == null || this.getZombieType().isSunSensitive()))
{
float f = this.getBrightness(1.0F);
BlockPos blockpos = this.getRidingEntity() instanceof EntityBoat ? (new BlockPos(this.posX, (double)Math.round(this.posY), this.posZ)).up() : new BlockPos(this.posX, (double)Math.round(this.posY), this.posZ);
if (f > 0.5F && this.rand.nextFloat() * 30.0F < (f - 0.4F) * 2.0F && this.worldObj.canSeeSky(blockpos))
{
boolean flag = true;
ItemStack itemstack = this.getItemStackFromSlot(EntityEquipmentSlot.HEAD);
if (itemstack != null)
{
if (itemstack.isItemStackDamageable())
{
itemstack.setItemDamage(itemstack.getItemDamage() + this.rand.nextInt(2));
if (itemstack.getItemDamage() >= itemstack.getMaxDamage())
{
this.renderBrokenItemStack(itemstack);
this.setItemStackToSlot(EntityEquipmentSlot.HEAD, (ItemStack)null);
}
}
flag = false;
}
if (flag)
{
this.setFire(8);
}
}
}
super.onLivingUpdate();
}
项目:pnc-repressurized
文件:SlotPneumaticArmor.java
/**
* Check if the stack is a valid item for this slot. Always true beside for
* the armor slots.
*/
@Override
public boolean isItemValid(ItemStack par1ItemStack) {
Item item = par1ItemStack.getItem();
EntityEquipmentSlot eq = EntityEquipmentSlot.values()[armorType + 2]; // 0 & 1 are main & off hands
return item.isValidArmor(par1ItemStack, eq, player);
}
项目:pnc-repressurized
文件:TileEntityProgrammableController.java
private void initializeFakePlayer() {
String playerName = "Drone";
fakePlayer = new DroneFakePlayer((WorldServer) getWorld(), new GameProfile(null, playerName), this);
fakePlayer.connection = new NetHandlerPlayServer(FMLCommonHandler.instance().getMinecraftServerInstance(), new NetworkManager(EnumPacketDirection.SERVERBOUND), fakePlayer);
fakePlayer.inventory = new InventoryPlayer(fakePlayer) {
private ItemStack oldStack;
@Override
public int getSizeInventory() {
return getDroneSlots();
}
@Override
public void setInventorySlotContents(int slot, ItemStack stack) {
super.setInventorySlotContents(slot, stack);
if (slot == 0) {
for (EntityEquipmentSlot ee : EntityEquipmentSlot.values()) {
if (!oldStack.isEmpty()) {
getFakePlayer().getAttributeMap().removeAttributeModifiers(oldStack.getAttributeModifiers(ee));
}
if (!stack.isEmpty()) {
getFakePlayer().getAttributeMap().applyAttributeModifiers(stack.getAttributeModifiers(ee));
}
}
oldStack = stack;
}
}
};
}
项目:Backmemed
文件:AbstractSkeleton.java
public void setItemStackToSlot(EntityEquipmentSlot slotIn, ItemStack stack)
{
super.setItemStackToSlot(slotIn, stack);
if (!this.world.isRemote && slotIn == EntityEquipmentSlot.MAINHAND)
{
this.setCombatTask();
}
}
项目:UniversalRemote
文件:EntityPlayerProxy.java
@Override
public ItemStack getItemStackFromSlot(EntityEquipmentSlot slotIn) {
if (m_realPlayer == null) {
return super.getItemStackFromSlot(slotIn);
} else {
return m_realPlayer.getItemStackFromSlot(slotIn);
}
}
项目:FirstAid
文件:ArmorUtils.java
private static float getModifier(EntityEquipmentSlot slot) {
switch (slot) {
case CHEST:
return 2.5F;
case LEGS:
return 3F;
case FEET:
case HEAD:
return 6.5F;
default:
throw new IllegalArgumentException("Invalid slot " + slot);
}
}
项目:Randores2
文件:EmpoweredEnchantment.java
public static void doArmor(EntityLivingBase hurt, EntityLivingBase cause) {
for (EntityEquipmentSlot slot : armorSlots) {
if (!hurt.getItemStackFromSlot(slot).isEmpty() && EmpoweredEnchantment.appliedTo(hurt.getItemStackFromSlot(slot))) {
ItemStack stack = hurt.getItemStackFromSlot(slot);
if(RandoresItemData.hasData(stack)) {
RandoresWorldData.delegateVoid(new RandoresItemData(stack), definition -> definition.getAbilitySeries().onArmorHit(hurt, cause), () -> {});
}
}
}
}
项目:Backmemed
文件:EntityLivingBase.java
/**
* Called each tick. Updates state for the elytra.
*/
private void updateElytra()
{
boolean flag = this.getFlag(7);
if (flag && !this.onGround && !this.isRiding())
{
ItemStack itemstack = this.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
if (itemstack.getItem() == Items.ELYTRA && ItemElytra.isBroken(itemstack))
{
flag = true;
if (!this.world.isRemote && (this.ticksElytraFlying + 1) % 20 == 0)
{
itemstack.damageItem(1, this);
}
}
else
{
flag = false;
}
}
else
{
flag = false;
}
if (!this.world.isRemote)
{
this.setFlag(7, flag);
}
}
项目:CustomWorldGen
文件:EntityArmorStand.java
private void swapItem(EntityPlayer player, EntityEquipmentSlot p_184795_2_, @Nullable ItemStack p_184795_3_, EnumHand hand)
{
ItemStack itemstack = this.getItemStackFromSlot(p_184795_2_);
if (itemstack == null || (this.disabledSlots & 1 << p_184795_2_.getSlotIndex() + 8) == 0)
{
if (itemstack != null || (this.disabledSlots & 1 << p_184795_2_.getSlotIndex() + 16) == 0)
{
if (player.capabilities.isCreativeMode && (itemstack == null || itemstack.getItem() == Item.getItemFromBlock(Blocks.AIR)) && p_184795_3_ != null)
{
ItemStack itemstack2 = p_184795_3_.copy();
itemstack2.stackSize = 1;
this.setItemStackToSlot(p_184795_2_, itemstack2);
}
else if (p_184795_3_ != null && p_184795_3_.stackSize > 1)
{
if (itemstack == null)
{
ItemStack itemstack1 = p_184795_3_.copy();
itemstack1.stackSize = 1;
this.setItemStackToSlot(p_184795_2_, itemstack1);
--p_184795_3_.stackSize;
}
}
else
{
this.setItemStackToSlot(p_184795_2_, p_184795_3_);
player.setHeldItem(hand, itemstack);
}
}
}
}
项目:Backmemed
文件:LayerBipedArmor.java
@SuppressWarnings("incomplete-switch")
protected void setModelSlotVisible(ModelBiped p_188359_1_, EntityEquipmentSlot slotIn)
{
this.setModelVisible(p_188359_1_);
switch (slotIn)
{
case HEAD:
p_188359_1_.bipedHead.showModel = true;
p_188359_1_.bipedHeadwear.showModel = true;
break;
case CHEST:
p_188359_1_.bipedBody.showModel = true;
p_188359_1_.bipedRightArm.showModel = true;
p_188359_1_.bipedLeftArm.showModel = true;
break;
case LEGS:
p_188359_1_.bipedBody.showModel = true;
p_188359_1_.bipedRightLeg.showModel = true;
p_188359_1_.bipedLeftLeg.showModel = true;
break;
case FEET:
p_188359_1_.bipedRightLeg.showModel = true;
p_188359_1_.bipedLeftLeg.showModel = true;
}
}
项目:UniversalRemote
文件:EntityPlayerProxy.java
@Override
public boolean hasItemInSlot(EntityEquipmentSlot p_190630_1_) {
if (m_realPlayer == null) {
return super.hasItemInSlot(p_190630_1_);
} else {
return m_realPlayer.hasItemInSlot(p_190630_1_);
}
}
项目:customstuff4
文件:ItemSword.java
@Override
public Multimap<String, AttributeModifier> getAttributeModifiers(EntityEquipmentSlot slot, ItemStack stack)
{
Multimap<String, AttributeModifier> multimap = HashMultimap.create();
if (slot == EntityEquipmentSlot.MAINHAND)
{
double damage = attackDamage != null ? attackDamage : defaultAttackDamage;
double speed = attackSpeed != null ? attackSpeed : defaultAttackSpeed;
multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", damage, 0));
multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Weapon modifier", speed, 0));
}
return multimap;
}
项目:harshencastle
文件:EntitySoullessKnight.java
@Override
public IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, IEntityLivingData livingdata) {
setItemStackToSlot(this.isLeftHanded() ? EntityEquipmentSlot.OFFHAND : EntityEquipmentSlot.MAINHAND, new ItemStack(HarshenItems.PROPS, 1, 0));
try {
setItemStackToSlot(this.isLeftHanded() ? EntityEquipmentSlot.MAINHAND : EntityEquipmentSlot.OFFHAND, new ItemStack(JsonToNBT.getTagFromJson("{id:\"minecraft:shield\",Count:1b,tag:{BlockEntityTag:{Patterns:[{Pattern:\"ss\",Color:6},{Pattern:\"flo\",Color:1}],Base:8}},Damage:0s}")));
} catch (NBTException e) {
e.printStackTrace();
}
this.getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE).applyModifier(new AttributeModifier("Random spawn bonus", this.rand.nextGaussian() * 0.05D, 1));
this.setLeftHanded(false);
return livingdata;
}
项目:Backmemed
文件:AbstractSkeleton.java
@Nullable
/**
* Called only once on an entity when first time spawned, via egg, mob spawner, natural spawning etc, but not called
* when entity is reloaded from nbt. Mainly used for initializing attributes and inventory
*/
public IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, @Nullable IEntityLivingData livingdata)
{
livingdata = super.onInitialSpawn(difficulty, livingdata);
this.setEquipmentBasedOnDifficulty(difficulty);
this.setEnchantmentBasedOnDifficulty(difficulty);
this.setCombatTask();
this.setCanPickUpLoot(this.rand.nextFloat() < 0.55F * difficulty.getClampedAdditionalDifficulty());
if (this.getItemStackFromSlot(EntityEquipmentSlot.HEAD).func_190926_b())
{
Calendar calendar = this.world.getCurrentDate();
if (calendar.get(2) + 1 == 10 && calendar.get(5) == 31 && this.rand.nextFloat() < 0.25F)
{
this.setItemStackToSlot(EntityEquipmentSlot.HEAD, new ItemStack(this.rand.nextFloat() < 0.1F ? Blocks.LIT_PUMPKIN : Blocks.PUMPKIN));
this.inventoryArmorDropChances[EntityEquipmentSlot.HEAD.getIndex()] = 0.0F;
}
}
return livingdata;
}
项目:harshencastle
文件:HandlerBurnInDaylight.java
@SubscribeEvent
public void onEntityUpdate(LivingUpdateEvent event)
{
EntityLivingBase living = event.getEntityLiving();
if(living instanceof IBurnInDay && living.world.isDaytime() && !living.world.isRemote && !living.isChild() && ((IBurnInDay)living).shouldBurn() && living.getBrightness() > 0.5F &&
living.getRNG().nextFloat() * 30.0F < (living.getBrightness() - 0.4F) * 2.0F && living.world.canSeeSky(new BlockPos(living.posX, living.posY + (double)living.getEyeHeight(), living.posZ)))
{
boolean flag = true;
ItemStack itemstack = living.getItemStackFromSlot(EntityEquipmentSlot.HEAD);
if (!itemstack.isEmpty())
{
if (itemstack.isItemStackDamageable())
{
itemstack.setItemDamage(itemstack.getItemDamage() + living.getRNG().nextInt(2));
if (itemstack.getItemDamage() >= itemstack.getMaxDamage())
{
living.renderBrokenItemStack(itemstack);
living.setItemStackToSlot(EntityEquipmentSlot.HEAD, ItemStack.EMPTY);
}
}
flag = false;
}
if (flag)
{
living.setFire(8);
}
}
}