Added Blocks that can have metaData
parent
084c02a1bf
commit
112b8abe19
Binary file not shown.
@ -0,0 +1,22 @@
|
|||||||
|
package com.zivilon.cinder_loe;
|
||||||
|
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.item.ItemBlock;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
|
public class CinderBlockMetaData extends ItemBlock {
|
||||||
|
public CinderBlockMetaData(Block block) {
|
||||||
|
super(block);
|
||||||
|
this.setHasSubtypes(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMetadata(int damage) {
|
||||||
|
return damage;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getUnlocalizedName(ItemStack stack) {
|
||||||
|
return super.getUnlocalizedName() + "." + stack.getItemDamage();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,13 +1,56 @@
|
|||||||
package com.zivilon.cinder_loe.items;
|
package com.zivilon.cinder_loe.items;
|
||||||
|
|
||||||
|
import com.zivilon.cinder_loe.entity.corrupt.CorruptMan;
|
||||||
|
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||||
import lotr.common.item.LOTRItemArmor;
|
import lotr.common.item.LOTRItemArmor;
|
||||||
import lotr.common.item.LOTRMaterial;
|
import lotr.common.item.LOTRMaterial;
|
||||||
|
import net.minecraft.entity.IEntityLivingData;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.potion.Potion;
|
||||||
|
import net.minecraft.potion.PotionEffect;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraftforge.event.entity.living.LivingEvent;
|
||||||
|
|
||||||
public class BrokenHalo extends LOTRItemArmor {
|
public class BrokenHalo extends LOTRItemArmor {
|
||||||
|
|
||||||
public BrokenHalo(LOTRMaterial material, int slotType, String s) {
|
public BrokenHalo(LOTRMaterial material, int slotType, String s) {
|
||||||
super(material, slotType, s);
|
super(material, slotType, s);
|
||||||
};
|
|
||||||
|
}
|
||||||
|
@SubscribeEvent
|
||||||
|
public void onLivingUpdate(LivingEvent.LivingUpdateEvent event) {
|
||||||
|
if (event.entityLiving instanceof EntityPlayer) {
|
||||||
|
EntityPlayer player = (EntityPlayer) event.entityLiving;
|
||||||
|
ItemStack helmet = player.getCurrentArmor(0); // Helmet slot
|
||||||
|
|
||||||
|
if (helmet != null && helmet.getItem() instanceof BrokenHalo) {
|
||||||
|
World world = player.worldObj;
|
||||||
|
if (!world.isRemote) {
|
||||||
|
// Summon NPC
|
||||||
|
CorruptMan corruptman = new CorruptMan(world);
|
||||||
|
corruptman.copyLocationAndAnglesFrom(player);
|
||||||
|
|
||||||
|
// Copy armor and weapon from player to CorruptOrc
|
||||||
|
for (int i = 0; i < 4; i++) {
|
||||||
|
ItemStack armor = player.getCurrentArmor(i);
|
||||||
|
corruptman.setCurrentItemOrArmor(i + 1, armor);
|
||||||
|
}
|
||||||
|
|
||||||
|
ItemStack mainWeapon = player.getHeldItem();
|
||||||
|
corruptman.npcItemsInv.setIdleItem(mainWeapon);
|
||||||
|
corruptman.npcItemsInv.setMeleeWeapon(mainWeapon);
|
||||||
|
corruptman.setHealth(20);
|
||||||
|
corruptman.addPotionEffect(new PotionEffect(Potion.regeneration.id, 9999, 0));
|
||||||
|
|
||||||
|
// Remove player and spawn CorruptOrc
|
||||||
|
world.removeEntity(player);
|
||||||
|
corruptman.onSpawnWithEgg((IEntityLivingData) null);
|
||||||
|
world.spawnEntityInWorld(corruptman);
|
||||||
|
world.playAuxSFXAtEntity(null, 1016, (int) corruptman.posX, (int) corruptman.posY, (int) corruptman.posZ, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 5.5 KiB After Width: | Height: | Size: 5.5 KiB |
Loading…
Reference in New Issue