Add dart and dart blower items

This commit is contained in:
Cheeserolls 2015-04-18 10:36:44 +01:00
parent ae906f10f4
commit 04d54ad29e
10 changed files with 214 additions and 0 deletions

View File

@ -74,5 +74,8 @@ public class BOPItems
public static Item diamond_scythe;
public static Item amethyst_scythe;
public static Item dart;
public static Item dart_blower;
}

View File

@ -37,6 +37,8 @@ import net.minecraftforge.fml.relauncher.Side;
import biomesoplenty.api.block.BOPBlocks;
import biomesoplenty.common.command.BOPCommand;
import biomesoplenty.common.item.ItemBOPScythe;
import biomesoplenty.common.item.ItemDart;
import biomesoplenty.common.item.ItemDartBlower;
import biomesoplenty.common.item.ItemGem;
import biomesoplenty.common.item.ItemMudball;
import biomesoplenty.common.item.ItemWadingBoots;
@ -61,6 +63,9 @@ public class ModItems
ash = registerItem(new Item(), "ash");
berries = registerItem(new ItemFood(1, 0.1F, false), "berries");
wildcarrots = registerItem(new ItemFood(3, 0.5F, false), "wildcarrots");
dart = registerItem(new ItemDart(), "dart");
dart_blower = registerItem(new ItemDartBlower(), "dart_blower");
// armor

View File

@ -0,0 +1,76 @@
/*******************************************************************************
* Copyright 2014, the Biomes O' Plenty Team
*
* This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International Public License.
*
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
******************************************************************************/
package biomesoplenty.common.item;
import java.util.List;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IStringSerializable;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class ItemDart extends Item
{
public static enum DartType implements IStringSerializable
{
// in order of preference when selecting from inventory to use in the dart blower, items on the right are preferred to items on the left
DART, POISONDART;
@Override
public String getName()
{
return this.name().toLowerCase();
}
@Override
public String toString()
{
return this.getName();
}
public static DartType fromMeta(int meta)
{
return DartType.values()[meta % DartType.values().length];
}
};
public ItemDart()
{
this.setHasSubtypes(true);
this.setMaxDamage(0);
}
// add all the gem types as separate items in the creative tab
@Override
@SideOnly(Side.CLIENT)
public void getSubItems(Item itemIn, CreativeTabs tab, List subItems)
{
for (DartType dartType : DartType.values())
{
subItems.add(new ItemStack(itemIn, 1, dartType.ordinal()));
}
}
// default behavior in Item is to return 0, but the meta value is important here because it determines which dart type to use
@Override
public int getMetadata(int metadata)
{
return metadata;
}
// get the correct name for this item by looking up the meta value in the DartType enum
@Override
public String getUnlocalizedName(ItemStack stack)
{
return "item." + DartType.fromMeta(stack.getMetadata()).toString();
}
}

View File

@ -0,0 +1,76 @@
/*******************************************************************************
* Copyright 2014, the Biomes O' Plenty Team
*
* This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International Public License.
*
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
******************************************************************************/
package biomesoplenty.common.item;
import biomesoplenty.api.item.BOPItems;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntitySnowball;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
public class ItemDartBlower extends Item
{
public ItemDartBlower()
{
this.maxStackSize = 1;
this.setMaxDamage(63);
}
@Override
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn)
{
if (worldIn.isRemote) {return itemStackIn;}
boolean isCreative = playerIn.capabilities.isCreativeMode;
if (isCreative || playerIn.inventory.hasItem(BOPItems.dart))
{
// TODO: implement EntityDart EntityDart entityDart = new EntityDart(worldIn, playerIn, 1.0F);
EntitySnowball entityDart = new EntitySnowball(worldIn, playerIn);
itemStackIn.damageItem(1, playerIn);
worldIn.playSoundAtEntity(playerIn, "random.bow", 1.0F, 1.75F);
// look for the best dart in inventory - find out which slot it's in
int bestDartSlot = -1;
ItemDart.DartType bestDart = ItemDart.DartType.DART;
for (int k = 0; k < playerIn.inventory.mainInventory.length; ++k)
{
ItemStack current = playerIn.inventory.mainInventory[k];
if (current != null && current.getItem()==BOPItems.dart)
{
ItemDart.DartType currentDart = ItemDart.DartType.fromMeta(current.getMetadata());
if (currentDart.ordinal() >= bestDart.ordinal())
{
bestDart = currentDart;
bestDartSlot = k;
}
}
}
// TODO: entityDart.setDartType(bestDart);
if (isCreative)
{
worldIn.spawnEntityInWorld(entityDart);
}
else if (bestDartSlot >= 0)
{
worldIn.spawnEntityInWorld(entityDart);
playerIn.inventory.decrStackSize(bestDartSlot, 1);
}
}
return itemStackIn;
}
}

View File

@ -0,0 +1,18 @@
{
"parent": "builtin/generated",
"textures": {
"layer0": "biomesoplenty:items/dart"
},
"display": {
"thirdperson": {
"rotation": [ -90, 0, 0 ],
"translation": [ 0, 1, -3 ],
"scale": [ 0.55, 0.55, 0.55 ]
},
"firstperson": {
"rotation": [ 0, -135, 25 ],
"translation": [ 0, 4, 2 ],
"scale": [ 1.7, 1.7, 1.7 ]
}
}
}

View File

@ -0,0 +1,18 @@
{
"parent": "builtin/generated",
"textures": {
"layer0": "biomesoplenty:items/dart_blower"
},
"display": {
"thirdperson": {
"rotation": [ -90, 0, 0 ],
"translation": [ 0, 1, -3 ],
"scale": [ 0.55, 0.55, 0.55 ]
},
"firstperson": {
"rotation": [ 0, -135, 25 ],
"translation": [ 0, 4, 2 ],
"scale": [ 1.7, 1.7, 1.7 ]
}
}
}

View File

@ -0,0 +1,18 @@
{
"parent": "builtin/generated",
"textures": {
"layer0": "biomesoplenty:items/poisondart"
},
"display": {
"thirdperson": {
"rotation": [ -90, 0, 0 ],
"translation": [ 0, 1, -3 ],
"scale": [ 0.55, 0.55, 0.55 ]
},
"firstperson": {
"rotation": [ 0, -135, 25 ],
"translation": [ 0, 4, 2 ],
"scale": [ 1.7, 1.7, 1.7 ]
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 266 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 306 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 301 B