mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-17 11:05:12 +00:00
Moved common stuff into ItemCustomizable
This commit is contained in:
1 parent
d9e6372acb
commit
cb5b8898bb
3 files changed
+63
-70
No files matched your search
@@ -1,9 +1,69 @@
|
||||
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.client.renderer.texture.IIconRegister;
|
||||
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.api.item.IItemStack;
|
||||
import noppes.npcs.scripted.NpcAPI;
|
||||
import noppes.npcs.scripted.item.ScriptCustomizableItem;
|
||||
|
||||
public abstract class ItemCustomizable extends Item implements ItemRenderInterface {
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister par1IconRegister){
|
||||
this.itemIcon = Items.iron_pickaxe.getIconFromDamage(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColorFromItemStack(ItemStack itemStack, int par2){
|
||||
return 0x8B4513;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requiresMultipleRenderPasses(){
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item setUnlocalizedName(String name){
|
||||
GameRegistry.registerItem(this, name);
|
||||
return super.setUnlocalizedName(name);
|
||||
}
|
||||
|
||||
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
|
||||
{
|
||||
player.setItemInUse(stack, this.getMaxItemUseDuration(stack));
|
||||
return stack;
|
||||
}
|
||||
|
||||
|
||||
public EnumAction getItemUseAction(ItemStack stack)
|
||||
{
|
||||
IItemStack istack = NpcAPI.Instance().getIItemStack(stack);
|
||||
if (istack instanceof ScriptCustomizableItem) {
|
||||
switch (((ScriptCustomizableItem) istack).getItemUseAction()) {
|
||||
case 0:
|
||||
return EnumAction.none;
|
||||
case 1:
|
||||
return EnumAction.block;
|
||||
case 2:
|
||||
return EnumAction.bow;
|
||||
case 3:
|
||||
return EnumAction.eat;
|
||||
case 4:
|
||||
return EnumAction.drink;
|
||||
}
|
||||
}
|
||||
return super.getItemUseAction(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderSpecial() {}
|
||||
}
|
||||
@@ -30,33 +30,6 @@ public class ItemLinked extends ItemCustomizable {
|
||||
setHasSubtypes(true);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister par1IconRegister){
|
||||
this.itemIcon = Items.iron_pickaxe.getIconFromDamage(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColorFromItemStack(ItemStack itemStack, int par2){
|
||||
return 0x8B4513;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requiresMultipleRenderPasses(){
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item setUnlocalizedName(String name){
|
||||
GameRegistry.registerItem(this, name);
|
||||
return super.setUnlocalizedName(name);
|
||||
}
|
||||
|
||||
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
|
||||
{
|
||||
player.setItemInUse(stack, this.getMaxItemUseDuration(stack));
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onEntitySwing(EntityLivingBase entityLivingBase, ItemStack stack){
|
||||
if (entityLivingBase.worldObj.isRemote) {
|
||||
|
||||
@@ -24,9 +24,11 @@ import noppes.npcs.constants.EnumGuiType;
|
||||
import noppes.npcs.scripted.NpcAPI;
|
||||
import noppes.npcs.scripted.event.ItemEvent;
|
||||
import noppes.npcs.scripted.item.ScriptCustomItem;
|
||||
import noppes.npcs.scripted.item.ScriptCustomizableItem;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class ItemScripted extends ItemCustomizable {
|
||||
|
||||
public ItemScripted() {
|
||||
maxStackSize = 1;
|
||||
setCreativeTab(CustomItems.tab);
|
||||
@@ -34,27 +36,6 @@ public class ItemScripted extends ItemCustomizable {
|
||||
setHasSubtypes(true);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister par1IconRegister){
|
||||
this.itemIcon = Items.iron_pickaxe.getIconFromDamage(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColorFromItemStack(ItemStack itemStack, int par2){
|
||||
return 0x8B4513;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requiresMultipleRenderPasses(){
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item setUnlocalizedName(String name){
|
||||
GameRegistry.registerItem(this, name);
|
||||
return super.setUnlocalizedName(name);
|
||||
}
|
||||
|
||||
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
|
||||
{
|
||||
if(player.isSneaking() && player.capabilities.isCreativeMode) {
|
||||
@@ -64,8 +45,7 @@ public class ItemScripted extends ItemCustomizable {
|
||||
CustomNpcs.proxy.openGui(0, 0, 0, EnumGuiType.ScriptItem, player);
|
||||
}
|
||||
}
|
||||
player.setItemInUse(stack, this.getMaxItemUseDuration(stack));
|
||||
return stack;
|
||||
return super.onItemRightClick(stack, world, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -136,26 +116,6 @@ public class ItemScripted extends ItemCustomizable {
|
||||
return EventHooks.onScriptItemAttack((ScriptCustomItem) istack, eve);
|
||||
}
|
||||
|
||||
public EnumAction getItemUseAction(ItemStack stack)
|
||||
{
|
||||
IItemStack istack = NpcAPI.Instance().getIItemStack(stack);
|
||||
if (istack instanceof ScriptCustomItem) {
|
||||
switch (((ScriptCustomItem) istack).getItemUseAction()) {
|
||||
case 0:
|
||||
return EnumAction.none;
|
||||
case 1:
|
||||
return EnumAction.block;
|
||||
case 2:
|
||||
return EnumAction.bow;
|
||||
case 3:
|
||||
return EnumAction.eat;
|
||||
case 4:
|
||||
return EnumAction.drink;
|
||||
}
|
||||
}
|
||||
return super.getItemUseAction(stack);
|
||||
}
|
||||
|
||||
public void renderOffset(ScriptCustomItem scriptCustomItem) {
|
||||
GL11.glTranslatef(0.135F * scriptCustomItem.itemDisplay.scaleX, 0.2F * scriptCustomItem.itemDisplay.scaleY, 0.07F * scriptCustomItem.itemDisplay.scaleZ);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user