Move armor items to IMeshProvider
Minor change to IMeshProvider allow for this
This commit is contained in:
parent
6cd993a619
commit
aa48c540f5
12 changed files with 178 additions and 26 deletions
|
@ -17,6 +17,7 @@ import net.minecraft.init.Blocks;
|
|||
import net.minecraft.init.Enchantments;
|
||||
import net.minecraft.inventory.EntityEquipmentSlot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
@ -35,6 +36,8 @@ import com.google.common.collect.HashMultiset;
|
|||
import com.google.common.collect.Multimap;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class ItemBoundAxe extends ItemBoundTool implements IMeshProvider
|
||||
{
|
||||
private static final Set<Block> EFFECTIVE_ON = Sets.newHashSet(Blocks.planks, Blocks.bookshelf, Blocks.log, Blocks.log2, Blocks.chest, Blocks.pumpkin, Blocks.lit_pumpkin, Blocks.melon_block, Blocks.ladder);
|
||||
|
@ -135,6 +138,13 @@ public class ItemBoundAxe extends ItemBoundTool implements IMeshProvider
|
|||
return new CustomMeshDefinitionActivatable("ItemBoundAxe");
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ResourceLocation getCustomLocation()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getVariants()
|
||||
{
|
||||
|
|
|
@ -17,6 +17,7 @@ import net.minecraft.init.Blocks;
|
|||
import net.minecraft.init.Enchantments;
|
||||
import net.minecraft.inventory.EntityEquipmentSlot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
@ -35,6 +36,8 @@ import com.google.common.collect.HashMultiset;
|
|||
import com.google.common.collect.Multimap;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class ItemBoundPickaxe extends ItemBoundTool implements IMeshProvider
|
||||
{
|
||||
private static final Set<Block> EFFECTIVE_ON = Sets.newHashSet(Blocks.activator_rail, Blocks.coal_ore, Blocks.cobblestone, Blocks.detector_rail, Blocks.diamond_block, Blocks.diamond_ore, Blocks.double_stone_slab, Blocks.golden_rail, Blocks.gold_block, Blocks.gold_ore, Blocks.ice, Blocks.iron_block, Blocks.iron_ore, Blocks.lapis_block, Blocks.lapis_ore, Blocks.lit_redstone_ore, Blocks.mossy_cobblestone, Blocks.netherrack, Blocks.packed_ice, Blocks.rail, Blocks.redstone_ore, Blocks.sandstone, Blocks.red_sandstone, Blocks.stone, Blocks.stone_slab);
|
||||
|
@ -152,6 +155,13 @@ public class ItemBoundPickaxe extends ItemBoundTool implements IMeshProvider
|
|||
return new CustomMeshDefinitionActivatable("ItemBoundPickaxe");
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ResourceLocation getCustomLocation()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getVariants()
|
||||
{
|
||||
|
|
|
@ -16,6 +16,7 @@ import net.minecraft.init.Blocks;
|
|||
import net.minecraft.init.Enchantments;
|
||||
import net.minecraft.inventory.EntityEquipmentSlot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
@ -34,6 +35,8 @@ import com.google.common.collect.HashMultiset;
|
|||
import com.google.common.collect.Multimap;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class ItemBoundShovel extends ItemBoundTool implements IMeshProvider
|
||||
{
|
||||
private static final Set<Block> EFFECTIVE_ON = Sets.newHashSet(Blocks.clay, Blocks.dirt, Blocks.farmland, Blocks.grass, Blocks.gravel, Blocks.mycelium, Blocks.sand, Blocks.snow, Blocks.snow_layer, Blocks.soul_sand);
|
||||
|
@ -134,6 +137,13 @@ public class ItemBoundShovel extends ItemBoundTool implements IMeshProvider
|
|||
return new CustomMeshDefinitionActivatable("ItemBoundShovel");
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ResourceLocation getCustomLocation()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getVariants()
|
||||
{
|
||||
|
|
|
@ -15,6 +15,7 @@ import net.minecraft.item.ItemSword;
|
|||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
@ -36,6 +37,8 @@ import com.google.common.base.Strings;
|
|||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class ItemBoundSword extends ItemSword implements IBindable, IActivatable, IMeshProvider
|
||||
{
|
||||
private float attackDamage;
|
||||
|
@ -136,6 +139,13 @@ public class ItemBoundSword extends ItemSword implements IBindable, IActivatable
|
|||
return new CustomMeshDefinitionActivatable("ItemBoundSword");
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ResourceLocation getCustomLocation()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getVariants()
|
||||
{
|
||||
|
|
|
@ -4,12 +4,15 @@ import WayofTime.bloodmagic.BloodMagic;
|
|||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade;
|
||||
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
|
||||
import WayofTime.bloodmagic.client.IMeshProvider;
|
||||
import WayofTime.bloodmagic.livingArmour.LivingArmour;
|
||||
import WayofTime.bloodmagic.registry.ModItems;
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
|
||||
import com.google.common.collect.Multimap;
|
||||
|
||||
import net.minecraft.client.renderer.ItemMeshDefinition;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.ai.attributes.AttributeModifier;
|
||||
|
@ -19,17 +22,19 @@ import net.minecraft.item.ItemArmor;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ISpecialArmor;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
public class ItemLivingArmour extends ItemArmor implements ISpecialArmor
|
||||
public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshProvider
|
||||
{
|
||||
public static String[] names = { "helmet", "chest", "legs", "boots" };
|
||||
|
||||
|
@ -258,6 +263,45 @@ public class ItemLivingArmour extends ItemArmor implements ISpecialArmor
|
|||
return super.getUnlocalizedName(stack) + names[armorType.getIndex()];
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public ItemMeshDefinition getMeshDefinition()
|
||||
{
|
||||
return new ItemMeshDefinition()
|
||||
{
|
||||
@Override
|
||||
public ModelResourceLocation getModelLocation(ItemStack stack)
|
||||
{
|
||||
assert getCustomLocation() != null;
|
||||
if (stack.getItem() == ModItems.livingArmourHelmet)
|
||||
return new ModelResourceLocation(getCustomLocation(), "armour=head");
|
||||
else if (stack.getItem() == ModItems.livingArmourChest)
|
||||
return new ModelResourceLocation(getCustomLocation(), "armour=body");
|
||||
else if (stack.getItem() == ModItems.livingArmourLegs)
|
||||
return new ModelResourceLocation(getCustomLocation(), "armour=leg");
|
||||
else
|
||||
return new ModelResourceLocation(getCustomLocation(), "armour=feet");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getCustomLocation()
|
||||
{
|
||||
return new ResourceLocation(Constants.Mod.MODID, "item/ItemLivingArmour");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getVariants()
|
||||
{
|
||||
List<String> ret = new ArrayList<String>();
|
||||
ret.add("armour=head");
|
||||
ret.add("armour=body");
|
||||
ret.add("armour=leg");
|
||||
ret.add("armour=feet");
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static LivingArmour getLivingArmour(ItemStack stack)
|
||||
{
|
||||
NBTTagCompound livingTag = getArmourTag(stack);
|
||||
|
|
|
@ -1,7 +1,12 @@
|
|||
package WayofTime.bloodmagic.item.armour;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import WayofTime.bloodmagic.client.IMeshProvider;
|
||||
import net.minecraft.client.renderer.ItemMeshDefinition;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.entity.Entity;
|
||||
|
@ -12,6 +17,7 @@ import net.minecraft.item.ItemArmor;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.common.ISpecialArmor;
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
|
@ -19,8 +25,10 @@ import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
|
|||
import WayofTime.bloodmagic.api.soul.PlayerDemonWillHandler;
|
||||
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
|
||||
import WayofTime.bloodmagic.registry.ModItems;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class ItemSentientArmour extends ItemArmor implements ISpecialArmor
|
||||
public class ItemSentientArmour extends ItemArmor implements ISpecialArmor, IMeshProvider
|
||||
{
|
||||
public static String[] names = { "helmet", "chest", "legs", "boots" };
|
||||
|
||||
|
@ -220,6 +228,45 @@ public class ItemSentientArmour extends ItemArmor implements ISpecialArmor
|
|||
// player.inventory.armorInventory[3 - armorType.getIndex()] = stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public ItemMeshDefinition getMeshDefinition()
|
||||
{
|
||||
return new ItemMeshDefinition()
|
||||
{
|
||||
@Override
|
||||
public ModelResourceLocation getModelLocation(ItemStack stack)
|
||||
{
|
||||
assert getCustomLocation() != null;
|
||||
if (stack.getItem() == ModItems.sentientArmourHelmet)
|
||||
return new ModelResourceLocation(getCustomLocation(), "armour=head");
|
||||
else if (stack.getItem() == ModItems.sentientArmourChest)
|
||||
return new ModelResourceLocation(getCustomLocation(), "armour=body");
|
||||
else if (stack.getItem() == ModItems.sentientArmourLegs)
|
||||
return new ModelResourceLocation(getCustomLocation(), "armour=leg");
|
||||
else
|
||||
return new ModelResourceLocation(getCustomLocation(), "armour=feet");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getCustomLocation()
|
||||
{
|
||||
return new ResourceLocation(Constants.Mod.MODID, "item/ItemSentientArmour");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getVariants()
|
||||
{
|
||||
List<String> ret = new ArrayList<String>();
|
||||
ret.add("armour=head");
|
||||
ret.add("armour=body");
|
||||
ret.add("armour=leg");
|
||||
ret.add("armour=feet");
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static void revertAllArmour(EntityPlayer player)
|
||||
{
|
||||
ItemStack[] armourInventory = player.inventory.armorInventory;
|
||||
|
|
|
@ -30,10 +30,12 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
@ -157,6 +159,13 @@ public class ItemSentientSword extends ItemSword implements IDemonWillWeapon, IA
|
|||
return new CustomMeshDefinitionActivatable("ItemSentientSword");
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ResourceLocation getCustomLocation()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getVariants()
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue