本文整理汇总了Java中net.minecraft.world.World.getCapability方法的典型用法代码示例。如果您正苦于以下问题:Java World.getCapability方法的具体用法?Java World.getCapability怎么用?Java World.getCapability使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.world.World
的用法示例。
在下文中一共展示了World.getCapability方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onEntityJoinWorld
import net.minecraft.world.World; //导入方法依赖的package包/类
@SubscribeEvent
public void onEntityJoinWorld(EntityJoinWorldEvent event)
{
if (event.getEntity() instanceof EntityLivingBase && !(event.getEntity() instanceof EntityPlayer))
{
EntityLivingBase entity = (EntityLivingBase) event.getEntity();
World world = entity.getEntityWorld();
IEnemyLevel enemyLevelCap = entity.getCapability(CapabilityEnemyLevel.ENEMY_LEVEL, null);
IChunkLevelHolder chunkLevelHolder = world.getCapability(CapabilityChunkLevel.CHUNK_LEVEL, null);
if (enemyLevelCap != null && chunkLevelHolder != null)
{
if (enemyLevelCap.getEnemyLevel() == 0)
{
IChunkLevel chunkLevel = chunkLevelHolder.getChunkLevel(new ChunkPos(entity.getPosition()));
int level = chunkLevel.getChunkLevel();
enemyLevelCap.setEnemyLevel(level);
entity.setCustomNameTag("Level: " + enemyLevelCap.getEnemyLevel());
if (level > 1) setAttributeModifiers(entity, level);
}
}
}
}
示例2: createSpecial
import net.minecraft.world.World; //导入方法依赖的package包/类
@Override
public void createSpecial(ItemStack stack, NBTTagCompound nbt, World world, ChunkPos pos)
{
IChunkLevelHolder chunkLevelHolder = world.getCapability(CapabilityChunkLevel.CHUNK_LEVEL, null);
IChunkLevel chunkLevel = chunkLevelHolder.getChunkLevel(pos);
int level = chunkLevel.getChunkLevel();
Rarity.setRarity(nbt, Rarity.LEGENDARY);
nbt.setInteger("Level", level);
// Attributes
WeaponAttribute.AGILITY.addAttribute(nbt, 5);
WeaponAttribute.DEXTERITY.addAttribute(nbt, 5);
WeaponAttribute.LIFE_STEAL.addAttribute(nbt, 0.05);
WeaponAttribute.MANA_STEAL.addAttribute(nbt, 0.05);
ItemGeneratorHelper.setAttributeModifiers(nbt, stack);
}
示例3: createSpecial
import net.minecraft.world.World; //导入方法依赖的package包/类
@Override
public void createSpecial(ItemStack stack, NBTTagCompound nbt, World world, ChunkPos pos)
{
IChunkLevelHolder chunkLevelHolder = world.getCapability(CapabilityChunkLevel.CHUNK_LEVEL, null);
IChunkLevel chunkLevel = chunkLevelHolder.getChunkLevel(pos);
int level = chunkLevel.getChunkLevel();
Rarity.setRarity(nbt, Rarity.LEGENDARY);
nbt.setInteger("Level", level);
// Attributes
WeaponAttribute.DEXTERITY.addAttribute(nbt, 10);
WeaponAttribute.MAX_DAMAGE.addAttribute(nbt, 3);
WeaponAttribute.LIFE_STEAL.addAttribute(nbt, 0.15);
ItemGeneratorHelper.setAttributeModifiers(nbt, stack);
}
示例4: createSpecial
import net.minecraft.world.World; //导入方法依赖的package包/类
@Override
public void createSpecial(ItemStack stack, NBTTagCompound nbt, World world, ChunkPos pos)
{
IChunkLevelHolder chunkLevelHolder = world.getCapability(CapabilityChunkLevel.CHUNK_LEVEL, null);
IChunkLevel chunkLevel = chunkLevelHolder.getChunkLevel(pos);
int level = chunkLevel.getChunkLevel();
Rarity.setRarity(nbt, Rarity.LEGENDARY);
nbt.setInteger("Level", level);
// Attributes
WeaponAttribute.FIRE.addAttribute(nbt, 5);
WeaponAttribute.STRENGTH.addAttribute(nbt, 3);
WeaponAttribute.DURABLE.addAttribute(nbt, 0.3);
ItemGeneratorHelper.setAttributeModifiers(nbt, stack);
}
示例5: createSpecial
import net.minecraft.world.World; //导入方法依赖的package包/类
@Override
public void createSpecial(ItemStack stack, NBTTagCompound nbt, World world, ChunkPos pos)
{
IChunkLevelHolder chunkLevelHolder = world.getCapability(CapabilityChunkLevel.CHUNK_LEVEL, null);
IChunkLevel chunkLevel = chunkLevelHolder.getChunkLevel(pos);
int level = chunkLevel.getChunkLevel();
Rarity.setRarity(nbt, Rarity.EXOTIC);
nbt.setInteger("Level", level);
// Attributes
WeaponAttribute.STRENGTH.addAttribute(nbt, 10);
WeaponAttribute.FORTITUDE.addAttribute(nbt, 10);
WeaponAttribute.FROST.addAttribute(nbt, 7);
ItemGeneratorHelper.setAttributeModifiers(nbt, stack);
}
示例6: createSpecial
import net.minecraft.world.World; //导入方法依赖的package包/类
@Override
public void createSpecial(ItemStack stack, NBTTagCompound nbt, World world, ChunkPos pos)
{
IChunkLevelHolder chunkLevelHolder = world.getCapability(CapabilityChunkLevel.CHUNK_LEVEL, null);
IChunkLevel chunkLevel = chunkLevelHolder.getChunkLevel(pos);
int level = chunkLevel.getChunkLevel();
Rarity.setRarity(nbt, Rarity.LEGENDARY);
nbt.setInteger("Level", level);
// Attributes
WeaponAttribute.FORTITUDE.addAttribute(nbt, 10);
WeaponAttribute.LIGHTNING.addAttribute(nbt, 7);
WeaponAttribute.MANA_STEAL.addAttribute(nbt, 0.2);
ItemGeneratorHelper.setAttributeModifiers(nbt, stack);
}
示例7: createSpecial
import net.minecraft.world.World; //导入方法依赖的package包/类
@Override
public void createSpecial(ItemStack stack, NBTTagCompound nbt, World world, ChunkPos pos)
{
IChunkLevelHolder chunkLevelHolder = world.getCapability(CapabilityChunkLevel.CHUNK_LEVEL, null);
IChunkLevel chunkLevel = chunkLevelHolder.getChunkLevel(pos);
int level = chunkLevel.getChunkLevel();
Rarity.setRarity(nbt, Rarity.EXOTIC);
nbt.setInteger("Level", level);
// Attributes
WeaponAttribute.AGILITY.addAttribute(nbt, 10);
WeaponAttribute.DEXTERITY.addAttribute(nbt, 10);
WeaponAttribute.GOLD.addAttribute(nbt, 10);
WeaponAttribute.LIFE_STEAL.addAttribute(nbt, 0.1);
WeaponAttribute.MANA_STEAL.addAttribute(nbt, 0.1);
ItemGeneratorHelper.setAttributeModifiers(nbt, stack);
}
示例8: createSpecial
import net.minecraft.world.World; //导入方法依赖的package包/类
@Override
public void createSpecial(ItemStack stack, NBTTagCompound nbt, World world, ChunkPos pos)
{
IChunkLevelHolder chunkLevelHolder = world.getCapability(CapabilityChunkLevel.CHUNK_LEVEL, null);
IChunkLevel chunkLevel = chunkLevelHolder.getChunkLevel(pos);
int level = chunkLevel.getChunkLevel();
Rarity.setRarity(nbt, Rarity.LEGENDARY);
nbt.setInteger("Level", level);
// Attributes
WeaponAttribute.STRENGTH.addAttribute(nbt, 6);
WeaponAttribute.FORTITUDE.addAttribute(nbt, 4);
WeaponAttribute.CHAINED.addAttribute(nbt, 10);
ItemGeneratorHelper.setAttributeModifiers(nbt, stack);
}
示例9: createSpecial
import net.minecraft.world.World; //导入方法依赖的package包/类
@Override
public void createSpecial(ItemStack stack, NBTTagCompound nbt, World world, ChunkPos pos)
{
IChunkLevelHolder chunkLevelHolder = world.getCapability(CapabilityChunkLevel.CHUNK_LEVEL, null);
IChunkLevel chunkLevel = chunkLevelHolder.getChunkLevel(pos);
int level = chunkLevel.getChunkLevel();
Rarity.setRarity(nbt, Rarity.EXOTIC);
nbt.setInteger("Level", level);
// Attributes
WeaponAttribute.FIRE.addAttribute(nbt, 3);
WeaponAttribute.FROST.addAttribute(nbt, 3);
WeaponAttribute.LIGHTNING.addAttribute(nbt, 3);
WeaponAttribute.STRENGTH.addAttribute(nbt, 8);
ItemGeneratorHelper.setAttributeModifiers(nbt, stack);
}
示例10: createSpecial
import net.minecraft.world.World; //导入方法依赖的package包/类
@Override
public void createSpecial(ItemStack stack, NBTTagCompound nbt, World world, ChunkPos pos)
{
IChunkLevelHolder chunkLevelHolder = world.getCapability(CapabilityChunkLevel.CHUNK_LEVEL, null);
IChunkLevel chunkLevel = chunkLevelHolder.getChunkLevel(pos);
int level = chunkLevel.getChunkLevel();
Rarity.setRarity(nbt, Rarity.LEGENDARY);
nbt.setInteger("Level", level);
ItemGeneratorHelper.setRune(nbt);
// Attributes
WeaponAttribute.ALL_STATS.addAttribute(nbt, 2);
WeaponAttribute.MANA_STEAL.addAttribute(nbt, 0.25);
// Damage and Attack Speed
double baseDamage = this.getBaseDamage();
double baseAttackSpeed = this.getBaseAttackSpeed();
double weightedDamage = ItemGeneratorHelper.getWeightedDamage(nbt, Rarity.getRarity(nbt), baseDamage);
double weightedAttackSpeed = ItemGeneratorHelper.getWeightedAttackSpeed(Rarity.getRarity(nbt), baseAttackSpeed);
ItemGeneratorHelper.setMinMaxDamage(nbt, weightedDamage);
nbt.setDouble("AttackSpeed", weightedAttackSpeed);
}
示例11: createSpecial
import net.minecraft.world.World; //导入方法依赖的package包/类
@Override
public void createSpecial(ItemStack stack, NBTTagCompound nbt, World world, ChunkPos pos)
{
IChunkLevelHolder chunkLevelHolder = world.getCapability(CapabilityChunkLevel.CHUNK_LEVEL, null);
IChunkLevel chunkLevel = chunkLevelHolder.getChunkLevel(pos);
int level = chunkLevel.getChunkLevel();
Rarity.setRarity(nbt, Rarity.LEGENDARY);
nbt.setInteger("Level", level);
ItemGeneratorHelper.setRune(nbt);
// Attributes
WeaponAttribute.INTELLIGENCE.addAttribute(nbt, 10);
WeaponAttribute.WISDOM.addAttribute(nbt, 10);
WeaponAttribute.MANA_STEAL.addAttribute(nbt, 0.2);
// Damage and Attack Speed
double baseDamage = this.getBaseDamage();
double baseAttackSpeed = this.getBaseAttackSpeed();
double weightedDamage = ItemGeneratorHelper.getWeightedDamage(nbt, Rarity.getRarity(nbt), baseDamage);
double weightedAttackSpeed = ItemGeneratorHelper.getWeightedAttackSpeed(Rarity.getRarity(nbt), baseAttackSpeed);
ItemGeneratorHelper.setMinMaxDamage(nbt, weightedDamage);
nbt.setDouble("AttackSpeed", weightedAttackSpeed);
}
示例12: createSpecial
import net.minecraft.world.World; //导入方法依赖的package包/类
@Override
public void createSpecial(ItemStack stack, NBTTagCompound nbt, World world, ChunkPos pos)
{
IChunkLevelHolder chunkLevelHolder = world.getCapability(CapabilityChunkLevel.CHUNK_LEVEL, null);
IChunkLevel chunkLevel = chunkLevelHolder.getChunkLevel(pos);
int level = chunkLevel.getChunkLevel();
Rarity.setRarity(nbt, Rarity.LEGENDARY);
nbt.setInteger("Level", level);
ItemGeneratorHelper.setRune(nbt);
// Attributes
WeaponAttribute.FIRE.addAttribute(nbt, 3);
WeaponAttribute.FROST.addAttribute(nbt, 3);
WeaponAttribute.LIGHTNING.addAttribute(nbt, 3);
// Damage and Attack Speed
double baseDamage = this.getBaseDamage();
double baseAttackSpeed = this.getBaseAttackSpeed();
double weightedDamage = ItemGeneratorHelper.getWeightedDamage(nbt, Rarity.getRarity(nbt), baseDamage);
double weightedAttackSpeed = ItemGeneratorHelper.getWeightedAttackSpeed(Rarity.getRarity(nbt), baseAttackSpeed);
ItemGeneratorHelper.setMinMaxDamage(nbt, weightedDamage);
nbt.setDouble("AttackSpeed", weightedAttackSpeed);
}
示例13: createSpecial
import net.minecraft.world.World; //导入方法依赖的package包/类
@Override
public void createSpecial(ItemStack stack, NBTTagCompound nbt, World world, ChunkPos pos)
{
IChunkLevelHolder chunkLevelHolder = world.getCapability(CapabilityChunkLevel.CHUNK_LEVEL, null);
IChunkLevel chunkLevel = chunkLevelHolder.getChunkLevel(pos);
int level = chunkLevel.getChunkLevel();
Rarity.setRarity(nbt, Rarity.EXOTIC);
nbt.setInteger("Level", level);
ItemGeneratorHelper.setRune(nbt);
// Attributes
WeaponAttribute.FIRE.addAttribute(nbt, 5);
WeaponAttribute.MIN_DAMAGE.addAttribute(nbt, 3);
WeaponAttribute.FORTITUDE.addAttribute(nbt, 5);
WeaponAttribute.CHAINED.addAttribute(nbt, 15);
// Damage and Attack Speed
double baseDamage = this.getBaseDamage();
double baseAttackSpeed = this.getBaseAttackSpeed();
double weightedDamage = ItemGeneratorHelper.getWeightedDamage(nbt, Rarity.getRarity(nbt), baseDamage);
double weightedAttackSpeed = ItemGeneratorHelper.getWeightedAttackSpeed(Rarity.getRarity(nbt), baseAttackSpeed);
ItemGeneratorHelper.setMinMaxDamage(nbt, weightedDamage);
nbt.setDouble("AttackSpeed", weightedAttackSpeed);
}
示例14: createSpecial
import net.minecraft.world.World; //导入方法依赖的package包/类
@Override
public void createSpecial(ItemStack stack, NBTTagCompound nbt, World world, ChunkPos pos)
{
IChunkLevelHolder chunkLevelHolder = world.getCapability(CapabilityChunkLevel.CHUNK_LEVEL, null);
IChunkLevel chunkLevel = chunkLevelHolder.getChunkLevel(pos);
int level = chunkLevel.getChunkLevel();
Rarity.setRarity(nbt, Rarity.LEGENDARY);
nbt.setInteger("Level", level);
ItemGeneratorHelper.setRune(nbt);
// Attributes
WeaponAttribute.INTELLIGENCE.addAttribute(nbt, 3);
WeaponAttribute.WISDOM.addAttribute(nbt, 3);
WeaponAttribute.LIGHTNING.addAttribute(nbt, 5);
// Damage and Attack Speed
double baseDamage = this.getBaseDamage();
double baseAttackSpeed = this.getBaseAttackSpeed();
double weightedDamage = ItemGeneratorHelper.getWeightedDamage(nbt, Rarity.getRarity(nbt), baseDamage);
double weightedAttackSpeed = ItemGeneratorHelper.getWeightedAttackSpeed(Rarity.getRarity(nbt), baseAttackSpeed);
ItemGeneratorHelper.setMinMaxDamage(nbt, weightedDamage);
nbt.setDouble("AttackSpeed", weightedAttackSpeed);
}
示例15: create
import net.minecraft.world.World; //导入方法依赖的package包/类
/** Creates a melee weapon/armor with randomized stats. */
public static void create(ItemStack stack, NBTTagCompound nbt, World world, ChunkPos pos)
{
/*
* Set rarity
* Set level
* Generate attributes based on Rarity
* - Common: 0-1 attributes
* - Uncommon: 1-2 attributes
* - Rare: 2-3 attributes
* - Legendary: 3-4 attributes
* - Mythic: 4-5 attributes
* Generate base damage and base attack speed
* Generate name based on attributes + material/type
*/
if (Rarity.getRarity(nbt) != Rarity.DEFAULT)
{
IChunkLevelHolder chunkLevelHolder = world.getCapability(CapabilityChunkLevel.CHUNK_LEVEL, null);
IChunkLevel chunkLevel = chunkLevelHolder.getChunkLevel(pos);
int level = chunkLevel.getChunkLevel();
//Rarity.setRarity(nbt, Rarity.getRandomRarity(nbt, ItemGeneratorHelper.rand)); // sets a random rarity
ItemGeneratorHelper.setTypes(stack, nbt);
nbt.setInteger("Level", level); // set level to current player level
ItemGeneratorHelper.setRandomAttributes(stack, nbt, Rarity.getRarity(nbt));
ItemGeneratorHelper.setAttributeModifiers(nbt, stack);
nbt.setInteger("HideFlags", 6); // hides Attribute Modifier and Unbreakable tags
}
}