Added an API for changing the speed of shears against blocks
This commit is contained in:
parent
eddef226e0
commit
4e4fa7b3d3
3 changed files with 116 additions and 0 deletions
|
@ -1,5 +1,9 @@
|
||||||
package biomesoplenty.api;
|
package biomesoplenty.api;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import com.google.common.base.Optional;
|
import com.google.common.base.Optional;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
|
@ -75,4 +79,9 @@ public class Blocks
|
||||||
public static Optional<? extends Block> quicksand = Optional.absent();
|
public static Optional<? extends Block> quicksand = Optional.absent();
|
||||||
|
|
||||||
public static Optional<? extends Block> promisedPortal = Optional.absent();
|
public static Optional<? extends Block> promisedPortal = Optional.absent();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Populated by Biomes O Plenty with default Biomes O Plenty leaves. Add additional leaves here (E.g. "Blocks.shearBlockIds.put(acaciaLeaves.blockID, 15.0F);")
|
||||||
|
*/
|
||||||
|
public static Map shearBlockIds = new HashMap();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
package biomesoplenty.configuration;
|
package biomesoplenty.configuration;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
import biomesoplenty.BiomesOPlenty;
|
import biomesoplenty.BiomesOPlenty;
|
||||||
import biomesoplenty.api.Blocks;
|
import biomesoplenty.api.Blocks;
|
||||||
import biomesoplenty.armor.ArmorAmethyst;
|
import biomesoplenty.armor.ArmorAmethyst;
|
||||||
|
@ -22,8 +25,10 @@ import biomesoplenty.items.ItemMediumGrass;
|
||||||
import biomesoplenty.items.ItemShortGrass;
|
import biomesoplenty.items.ItemShortGrass;
|
||||||
import biomesoplenty.items.ItemShroomPowder;
|
import biomesoplenty.items.ItemShroomPowder;
|
||||||
import biomesoplenty.items.ItemSprout;
|
import biomesoplenty.items.ItemSprout;
|
||||||
|
import biomesoplenty.items.overrides.ItemShears;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.creativetab.CreativeTabs;
|
||||||
import net.minecraft.item.EnumArmorMaterial;
|
import net.minecraft.item.EnumArmorMaterial;
|
||||||
import net.minecraft.item.EnumToolMaterial;
|
import net.minecraft.item.EnumToolMaterial;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
|
@ -33,10 +38,14 @@ import net.minecraft.util.WeightedRandomChestContent;
|
||||||
import net.minecraftforge.common.ChestGenHooks;
|
import net.minecraftforge.common.ChestGenHooks;
|
||||||
import net.minecraftforge.common.EnumHelper;
|
import net.minecraftforge.common.EnumHelper;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
|
import cpw.mods.fml.common.FMLLog;
|
||||||
|
import cpw.mods.fml.common.registry.GameData;
|
||||||
import cpw.mods.fml.common.registry.GameRegistry;
|
import cpw.mods.fml.common.registry.GameRegistry;
|
||||||
import cpw.mods.fml.common.registry.LanguageRegistry;
|
import cpw.mods.fml.common.registry.LanguageRegistry;
|
||||||
|
import cpw.mods.fml.relauncher.ReflectionHelper;
|
||||||
|
|
||||||
public class BOPItems {
|
public class BOPItems {
|
||||||
|
public static Item shears;
|
||||||
|
|
||||||
public static Item shroomPowder;
|
public static Item shroomPowder;
|
||||||
public static Item mudBall;
|
public static Item mudBall;
|
||||||
|
@ -85,6 +94,39 @@ public class BOPItems {
|
||||||
public static EnumArmorMaterial EnumArmorMaterialAmethyst;
|
public static EnumArmorMaterial EnumArmorMaterialAmethyst;
|
||||||
public static EnumToolMaterial EnumToolMaterialAmethyst;
|
public static EnumToolMaterial EnumToolMaterialAmethyst;
|
||||||
|
|
||||||
|
public static int clearItem(Item var1)
|
||||||
|
{
|
||||||
|
return clearItem(var1.itemID);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int clearItem(Item var1, boolean var2)
|
||||||
|
{
|
||||||
|
return clearItem(var1.itemID, var2);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int clearItem(int var1)
|
||||||
|
{
|
||||||
|
return clearItem(var1, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int clearItem(int var1, boolean var2)
|
||||||
|
{
|
||||||
|
if (var1 < 0 || var1 >= Item.itemsList.length)
|
||||||
|
{
|
||||||
|
FMLLog.log(Level.SEVERE, "BiomesOPlenty has an invalid item ID (%i)", new Object[] {Integer.valueOf(var1)});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (var2 && Item.itemsList[var1] == null)
|
||||||
|
{
|
||||||
|
FMLLog.log(Level.WARNING, "BiomesOPlenty tried clearing an already cleared item (%i)", new Object[] {Integer.valueOf(var1)});
|
||||||
|
}
|
||||||
|
|
||||||
|
Item.itemsList[var1] = null;
|
||||||
|
Map var3 = (Map)ReflectionHelper.getPrivateValue(GameData.class, null, new String[] {"idMap"});
|
||||||
|
var3.remove(Integer.valueOf(var1));
|
||||||
|
return var1 - 256;
|
||||||
|
}
|
||||||
|
|
||||||
public static void init()
|
public static void init()
|
||||||
{
|
{
|
||||||
// Material declaration
|
// Material declaration
|
||||||
|
@ -93,6 +135,9 @@ public class BOPItems {
|
||||||
EnumArmorMaterialAmethyst = EnumHelper.addArmorMaterial("AMETHYST", 40, new int[]{6, 12, 10, 6}, 20);
|
EnumArmorMaterialAmethyst = EnumHelper.addArmorMaterial("AMETHYST", 40, new int[]{6, 12, 10, 6}, 20);
|
||||||
EnumToolMaterialAmethyst = EnumHelper.addToolMaterial("AMETHYST", 4, 2013, 15.0F, 5, 16);
|
EnumToolMaterialAmethyst = EnumHelper.addToolMaterial("AMETHYST", 4, 2013, 15.0F, 5, 16);
|
||||||
|
|
||||||
|
//Override Items
|
||||||
|
shears = (new ItemShears(clearItem(Item.shears))).setUnlocalizedName("shears").setCreativeTab(CreativeTabs.tabTools);
|
||||||
|
|
||||||
// Item declaration
|
// Item declaration
|
||||||
shroomPowder = (new ItemShroomPowder(BOPConfiguration.shroomPowderID, 1, 0.5F, false)).setPotionEffect(Potion.confusion.id, 30, 0, 0.6F).setAlwaysEdible().setUnlocalizedName("shroomPowder").setCreativeTab(BiomesOPlenty.tabBiomesOPlenty);
|
shroomPowder = (new ItemShroomPowder(BOPConfiguration.shroomPowderID, 1, 0.5F, false)).setPotionEffect(Potion.confusion.id, 30, 0, 0.6F).setAlwaysEdible().setUnlocalizedName("shroomPowder").setCreativeTab(BiomesOPlenty.tabBiomesOPlenty);
|
||||||
mudBall = (new ItemBOP(BOPConfiguration.mudBallID, 0)).setUnlocalizedName("mudBall").setCreativeTab(BiomesOPlenty.tabBiomesOPlenty);
|
mudBall = (new ItemBOP(BOPConfiguration.mudBallID, 0)).setUnlocalizedName("mudBall").setCreativeTab(BiomesOPlenty.tabBiomesOPlenty);
|
||||||
|
|
62
src/minecraft/biomesoplenty/items/overrides/ItemShears.java
Normal file
62
src/minecraft/biomesoplenty/items/overrides/ItemShears.java
Normal file
|
@ -0,0 +1,62 @@
|
||||||
|
package biomesoplenty.items.overrides;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import cpw.mods.fml.common.registry.LanguageRegistry;
|
||||||
|
|
||||||
|
import biomesoplenty.api.Blocks;
|
||||||
|
import biomesoplenty.configuration.BOPBlocks;
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.creativetab.CreativeTabs;
|
||||||
|
import net.minecraft.entity.passive.EntityCow;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.ItemBucket;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.EnumMovingObjectType;
|
||||||
|
import net.minecraft.util.MovingObjectPosition;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
|
import net.minecraftforge.event.Event;
|
||||||
|
import net.minecraftforge.event.entity.player.FillBucketEvent;
|
||||||
|
import net.minecraftforge.oredict.OreDictionary;
|
||||||
|
|
||||||
|
public class ItemShears extends net.minecraft.item.ItemShears
|
||||||
|
{
|
||||||
|
public ItemShears(int var1)
|
||||||
|
{
|
||||||
|
super(var1);
|
||||||
|
this.maxStackSize = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the strength of the stack against a given block. 1.0F base, (Quality+1)*2 if correct blocktype, 1.5F if
|
||||||
|
* sword
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public float getStrVsBlock(ItemStack par1ItemStack, Block par2Block)
|
||||||
|
{
|
||||||
|
Float Strength = null;
|
||||||
|
|
||||||
|
if (Blocks.shearBlockIds.get(par2Block.blockID) != null)
|
||||||
|
{
|
||||||
|
Strength = Float.parseFloat(Blocks.shearBlockIds.get(par2Block.blockID).toString());
|
||||||
|
}
|
||||||
|
else if (par2Block.blockID == Block.web.blockID | par2Block.blockID == Block.leaves.blockID)
|
||||||
|
{
|
||||||
|
Strength = 15.0F;
|
||||||
|
}
|
||||||
|
else if (par2Block.blockID == Block.cloth.blockID)
|
||||||
|
{
|
||||||
|
Strength = 5.0F;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Strength = super.getStrVsBlock(par1ItemStack, par2Block);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Strength;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue