mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-18 23:09:05 +00:00
More linked item changes
This commit is contained in:
1 parent
d394174108
commit
4a1a092757
15 files changed
+338
-436
No files matched your search
@@ -3,16 +3,22 @@ package noppes.npcs.items;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.EnumAction;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import noppes.npcs.EventHooks;
|
||||
import noppes.npcs.api.item.IItemCustomizable;
|
||||
import noppes.npcs.api.item.IItemStack;
|
||||
import noppes.npcs.scripted.NpcAPI;
|
||||
import noppes.npcs.scripted.item.ScriptCustomizableItem;
|
||||
import noppes.npcs.scripted.event.ItemEvent;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public abstract class ItemCustomizable extends Item implements ItemRenderInterface {
|
||||
|
||||
@@ -26,6 +32,73 @@ public abstract class ItemCustomizable extends Item implements ItemRenderInterfa
|
||||
return 0x8B4513;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onEntitySwing(EntityLivingBase entityLivingBase, ItemStack stack){
|
||||
if (entityLivingBase.worldObj.isRemote) {
|
||||
return false;
|
||||
}
|
||||
|
||||
IItemStack istack = NpcAPI.Instance().getIItemStack(stack);
|
||||
ItemEvent.AttackEvent eve = new ItemEvent.AttackEvent((IItemCustomizable) istack, NpcAPI.Instance().getIEntity(entityLivingBase), 2, null);
|
||||
return EventHooks.onScriptItemAttack((IItemCustomizable) istack, eve);
|
||||
}
|
||||
|
||||
public int getMaxItemUseDuration(ItemStack stack){
|
||||
IItemCustomizable customizable = (IItemCustomizable) NpcAPI.Instance().getIItemStack(stack);
|
||||
return customizable.getMaxItemUseDuration();
|
||||
}
|
||||
|
||||
public boolean showDurabilityBar(ItemStack stack) {
|
||||
IItemStack istack = NpcAPI.Instance().getIItemStack(stack);
|
||||
return istack instanceof IItemCustomizable && ((IItemCustomizable) istack).getDurabilityShow();
|
||||
}
|
||||
|
||||
public double getDurabilityForDisplay(ItemStack stack) {
|
||||
|
||||
IItemStack istack = NpcAPI.Instance().getIItemStack(stack);
|
||||
return istack instanceof IItemCustomizable ? 1.0D - ((IItemCustomizable) istack).getDurabilityValue() : 1.0D;
|
||||
}
|
||||
|
||||
public int getItemStackLimit(ItemStack stack) {
|
||||
IItemStack istack = NpcAPI.Instance().getIItemStack(stack);
|
||||
return istack instanceof IItemCustomizable ? istack.getMaxStackSize() : super.getItemStackLimit(stack);
|
||||
}
|
||||
|
||||
public boolean isItemTool(ItemStack stack)
|
||||
{
|
||||
IItemStack istack = NpcAPI.Instance().getIItemStack(stack);
|
||||
return istack instanceof IItemCustomizable ? ((IItemCustomizable) istack).isTool() : super.isItemTool(stack);
|
||||
}
|
||||
|
||||
public float getDigSpeed(ItemStack stack, Block block, int metadata)
|
||||
{
|
||||
IItemStack istack = NpcAPI.Instance().getIItemStack(stack);
|
||||
return istack instanceof IItemCustomizable ? ((IItemCustomizable) istack).getDigSpeed() : super.getDigSpeed(stack, block, metadata);
|
||||
}
|
||||
|
||||
public boolean isValidArmor(ItemStack stack, int armorType, Entity entity)
|
||||
{
|
||||
IItemStack istack = NpcAPI.Instance().getIItemStack(stack);
|
||||
if (istack instanceof IItemCustomizable) {
|
||||
if(((IItemCustomizable) istack).getArmorType() == -1)
|
||||
return true;
|
||||
return armorType == ((IItemCustomizable) istack).getArmorType();
|
||||
}
|
||||
return super.isValidArmor(stack, armorType, entity);
|
||||
}
|
||||
|
||||
public int getItemEnchantability(ItemStack stack)
|
||||
{
|
||||
IItemStack istack = NpcAPI.Instance().getIItemStack(stack);
|
||||
return istack instanceof IItemCustomizable ? ((IItemCustomizable) istack).getEnchantability() : super.getItemEnchantability(stack);
|
||||
}
|
||||
|
||||
public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker) {
|
||||
IItemStack istack = NpcAPI.Instance().getIItemStack(stack);
|
||||
ItemEvent.AttackEvent eve = new ItemEvent.AttackEvent((IItemCustomizable) istack, NpcAPI.Instance().getIEntity(attacker), 1, NpcAPI.Instance().getIEntity(target));
|
||||
return EventHooks.onScriptItemAttack((IItemCustomizable) istack, eve);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requiresMultipleRenderPasses(){
|
||||
return true;
|
||||
@@ -47,8 +120,8 @@ public abstract class ItemCustomizable extends Item implements ItemRenderInterfa
|
||||
public EnumAction getItemUseAction(ItemStack stack)
|
||||
{
|
||||
IItemStack istack = NpcAPI.Instance().getIItemStack(stack);
|
||||
if (istack instanceof ScriptCustomizableItem) {
|
||||
switch (((ScriptCustomizableItem) istack).getItemUseAction()) {
|
||||
if (istack instanceof IItemCustomizable) {
|
||||
switch (((IItemCustomizable) istack).getItemUseAction()) {
|
||||
case 0:
|
||||
return EnumAction.none;
|
||||
case 1:
|
||||
@@ -66,4 +139,8 @@ public abstract class ItemCustomizable extends Item implements ItemRenderInterfa
|
||||
|
||||
@Override
|
||||
public void renderSpecial() {}
|
||||
|
||||
public void renderOffset(IItemCustomizable scriptCustomItem) {
|
||||
GL11.glTranslatef(0.135F * scriptCustomItem.getScaleX(), 0.2F * scriptCustomItem.getScaleY(), 0.07F * scriptCustomItem.getScaleZ());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user