本文整理匯總了Java中net.minecraft.inventory.EntityEquipmentSlot類的典型用法代碼示例。如果您正苦於以下問題:Java EntityEquipmentSlot類的具體用法?Java EntityEquipmentSlot怎麽用?Java EntityEquipmentSlot使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
EntityEquipmentSlot類屬於net.minecraft.inventory包,在下文中一共展示了EntityEquipmentSlot類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: damageShield
import net.minecraft.inventory.EntityEquipmentSlot; //導入依賴的package包/類
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);
}
}
}
示例2: getAttributeModifiers
import net.minecraft.inventory.EntityEquipmentSlot; //導入依賴的package包/類
@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;
}
示例3: addAttributeModifier
import net.minecraft.inventory.EntityEquipmentSlot; //導入依賴的package包/類
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);
}
示例4: distributeDamage
import net.minecraft.inventory.EntityEquipmentSlot; //導入依賴的package包/類
@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;
}
示例5: onStruckByLightning
import net.minecraft.inventory.EntityEquipmentSlot; //導入依賴的package包/類
/**
* 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();
}
}
示例6: getSearchedItemCount
import net.minecraft.inventory.EntityEquipmentSlot; //導入依賴的package包/類
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;
}
示例7: setPlayerItemStackInHand
import net.minecraft.inventory.EntityEquipmentSlot; //導入依賴的package包/類
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!");
}
}
示例8: createSkeleton
import net.minecraft.inventory.EntityEquipmentSlot; //導入依賴的package包/類
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;
}
示例9: ItemCGArmor
import net.minecraft.inventory.EntityEquipmentSlot; //導入依賴的package包/類
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);
}
}
示例10: getEntityEquipment
import net.minecraft.inventory.EntityEquipmentSlot; //導入依賴的package包/類
@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;
}
示例11: apply
import net.minecraft.inventory.EntityEquipmentSlot; //導入依賴的package包/類
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;
}
示例12: onItemRightClick
import net.minecraft.inventory.EntityEquipmentSlot; //導入依賴的package包/類
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);
}
}
示例13: getAttributeModifiers
import net.minecraft.inventory.EntityEquipmentSlot; //導入依賴的package包/類
@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;
}
示例14: getAttributeModifiers
import net.minecraft.inventory.EntityEquipmentSlot; //導入依賴的package包/類
@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;
}
示例15: renderWorldLastEvent
import net.minecraft.inventory.EntityEquipmentSlot; //導入依賴的package包/類
@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();
}