本文整理匯總了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
}
}