Java Code Examples for net.minecraft.world.World.getCapability()

The following are Jave code examples for showing how to use getCapability() of the net.minecraft.world.World class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: Loot-Slash-Conquer   File: EventEntityJoinWorld.java   Source Code and License Vote up 6 votes
@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);
			}
		}
	}
}
 
Example 2
Project: Loot-Slash-Conquer   File: ItemRequiem.java   Source Code and License Vote up 6 votes
@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);
}
 
Example 3
Project: Loot-Slash-Conquer   File: ItemShadowfall.java   Source Code and License Vote up 6 votes
@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);
}
 
Example 4
Project: Loot-Slash-Conquer   File: ItemDivineRapier.java   Source Code and License Vote up 6 votes
@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);
}
 
Example 5
Project: Loot-Slash-Conquer   File: ItemAlakaslam.java   Source Code and License Vote up 6 votes
@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);
}
 
Example 6
Project: Loot-Slash-Conquer   File: ItemGoldenPummel.java   Source Code and License Vote up 6 votes
@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);
}
 
Example 7
Project: Loot-Slash-Conquer   File: ItemAnnihilation.java   Source Code and License Vote up 6 votes
@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);
}
 
Example 8
Project: Loot-Slash-Conquer   File: ItemDoomshadow.java   Source Code and License Vote up 6 votes
@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);
}
 
Example 9
Project: Loot-Slash-Conquer   File: ItemExcaliburRapier.java   Source Code and License Vote up 6 votes
@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);
}
 
Example 10
Project: Loot-Slash-Conquer   File: ItemEpilogue.java   Source Code and License Vote up 6 votes
@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);
}
 
Example 11
Project: Loot-Slash-Conquer   File: ItemVisageOfWizardry.java   Source Code and License Vote up 6 votes
@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);
}
 
Example 12
Project: Loot-Slash-Conquer   File: ItemBlazefury.java   Source Code and License Vote up 6 votes
@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);
}
 
Example 13
Project: Loot-Slash-Conquer   File: ItemGazeOfTruth.java   Source Code and License Vote up 6 votes
@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);
}
 
Example 14
Project: Loot-Slash-Conquer   File: ItemMoonlitRod.java   Source Code and License Vote up 6 votes
@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);
}
 
Example 15
Project: Loot-Slash-Conquer   File: ItemGenerator.java   Source Code and License Vote up 5 votes
/** 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
	}
}
 
Example 16
Project: Loot-Slash-Conquer   File: ItemGenerator.java   Source Code and License Vote up 5 votes
/** Creates a magical weapon with randomized stats. */
public static void createMagical(ItemStack stack, NBTTagCompound nbt, World world, ChunkPos pos)
{
	if (Rarity.getRarity(nbt) != Rarity.DEFAULT && stack.getItem() instanceof ItemLEMagical)
	{
		IChunkLevelHolder chunkLevelHolder = world.getCapability(CapabilityChunkLevel.CHUNK_LEVEL, null);
		IChunkLevel chunkLevel = chunkLevelHolder.getChunkLevel(pos);
		int level = chunkLevel.getChunkLevel();
		ItemLEMagical wand = (ItemLEMagical) stack.getItem();
		
		ItemGeneratorHelper.setTypes(stack, nbt);
		Rarity.setRarity(nbt, Rarity.getRandomRarity(nbt, ItemGeneratorHelper.rand));
		nbt.setInteger("Level", level);
		ItemGeneratorHelper.setRandomAttributes(stack, nbt, Rarity.getRarity(nbt));
		
		// handles setting weighted damage/attack speed and min/max damage
		double baseDamage = wand.getBaseDamage();
		double baseAttackSpeed = wand.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);
		ItemGeneratorHelper.setRune(nbt);
		nbt.setInteger("HideFlags", 6); // hides Attribute Modifier and Unbreakable tags
	}
}
 
Example 17
Project: Loot-Slash-Conquer   File: ItemGenerator.java   Source Code and License Vote up 5 votes
public static void createJewelry(ItemStack stack, NBTTagCompound nbt, World world, ChunkPos pos)
{
	if (Rarity.getRarity(nbt) != Rarity.DEFAULT && stack.getItem() instanceof ItemLEBauble)
	{
		IChunkLevelHolder chunkLevelHolder = world.getCapability(CapabilityChunkLevel.CHUNK_LEVEL, null);
		IChunkLevel chunkLevel = chunkLevelHolder.getChunkLevel(pos);
		int level = chunkLevel.getChunkLevel();
		
		ItemGeneratorHelper.setTypes(stack, nbt);
		Rarity.setRarity(nbt, Rarity.getRandomRarity(nbt, ItemGeneratorHelper.rand));
		nbt.setInteger("Level", level);
		ItemGeneratorHelper.setRandomAttributes(stack, nbt, Rarity.getRarity(nbt));
	}
}
 
Example 18
Project: Loot-Slash-Conquer   File: EventRenderOverlayText.java   Source Code and License Vote up 5 votes
@SubscribeEvent
public void onRenderOverlayText(RenderGameOverlayEvent.Text event)
{
	EntityPlayer player = Minecraft.getMinecraft().player;
	World world = Minecraft.getMinecraft().world;
	IChunkLevelHolder chunkLevelHolder = world.getCapability(CapabilityChunkLevel.CHUNK_LEVEL, null);
	IChunkLevel chunkLevel = chunkLevelHolder.getChunkLevel(new ChunkPos(player.getPosition()));
	
	if (chunkLevelHolder != null && chunkLevel != null)
	{
		Minecraft.getMinecraft().fontRenderer.drawStringWithShadow("Area Level: " + chunkLevel.getChunkLevel(), 10, 10, 0xFFFFFF);
	}
}
 
Example 19
Project: Mods   File: TF2EventsCommon.java   Source Code and License Vote up 4 votes
public static boolean isSpawnEvent(World world) {
	return world.hasCapability(TF2weapons.WORLD_CAP, null) && world.getCapability(TF2weapons.WORLD_CAP, null).eventFlag == 1;
}