ActuallyAdditions/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemPickaxeAA.java

92 lines
4.1 KiB
Java
Raw Normal View History

2016-03-19 11:36:17 +01:00
/*
2016-05-16 22:52:27 +02:00
* This file ("ItemPickaxeAA.java") is part of the Actually Additions mod for Minecraft.
2016-03-19 11:36:17 +01:00
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
2016-05-16 22:52:27 +02:00
* http://ellpeck.de/actaddlicense
2016-03-19 11:36:17 +01:00
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
2017-01-01 16:23:26 +01:00
* © 2015-2017 Ellpeck
2016-03-19 11:36:17 +01:00
*/
package de.ellpeck.actuallyadditions.mod.items;
import com.google.common.collect.Sets;
import de.ellpeck.actuallyadditions.mod.items.base.ItemToolAA;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import java.util.Collections;
2016-03-19 11:36:17 +01:00
import java.util.Set;
public class ItemPickaxeAA extends ItemToolAA{
2016-04-20 21:39:03 +02:00
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, Blocks.STONE_BUTTON, Blocks.STONE_PRESSURE_PLATE);
2016-03-19 11:36:17 +01:00
public ItemPickaxeAA(Item.ToolMaterial material, String repairItem, String unlocalizedName, EnumRarity rarity){
super(1.0F, -2.8F, material, repairItem, unlocalizedName, rarity, EFFECTIVE_ON);
this.setHarvestLevel("pickaxe", material.getHarvestLevel());
2016-03-19 11:36:17 +01:00
}
public ItemPickaxeAA(Item.ToolMaterial material, ItemStack repairItem, String unlocalizedName, EnumRarity rarity){
super(1.0F, -2.8F, material, repairItem, unlocalizedName, rarity, EFFECTIVE_ON);
this.setHarvestLevel("pickaxe", material.getHarvestLevel());
2016-03-19 11:36:17 +01:00
}
2016-05-02 17:09:23 +02:00
@Override
2016-04-20 21:39:03 +02:00
public boolean canHarvestBlock(IBlockState blockIn){
Block block = blockIn.getBlock();
if(block == Blocks.OBSIDIAN){
return this.toolMaterial.getHarvestLevel() == 3;
}
else if(block != Blocks.DIAMOND_BLOCK && block != Blocks.DIAMOND_ORE){
if(block != Blocks.EMERALD_ORE && block != Blocks.EMERALD_BLOCK){
if(block != Blocks.GOLD_BLOCK && block != Blocks.GOLD_ORE){
if(block != Blocks.IRON_BLOCK && block != Blocks.IRON_ORE){
if(block != Blocks.LAPIS_BLOCK && block != Blocks.LAPIS_ORE){
if(block != Blocks.REDSTONE_ORE && block != Blocks.LIT_REDSTONE_ORE){
Material material = blockIn.getMaterial();
return material == Material.ROCK || (material == Material.IRON || material == Material.ANVIL);
}
else{
return this.toolMaterial.getHarvestLevel() >= 2;
}
}
else{
return this.toolMaterial.getHarvestLevel() >= 1;
}
}
else{
return this.toolMaterial.getHarvestLevel() >= 1;
}
}
else{
return this.toolMaterial.getHarvestLevel() >= 2;
}
}
else{
return this.toolMaterial.getHarvestLevel() >= 2;
}
}
else{
return this.toolMaterial.getHarvestLevel() >= 2;
}
2016-03-19 11:36:17 +01:00
}
2016-05-02 17:09:23 +02:00
@Override
2017-11-16 00:11:17 +01:00
public float getDestroySpeed(ItemStack stack, IBlockState state){
2016-03-19 11:36:17 +01:00
Material material = state.getMaterial();
2017-11-16 00:11:17 +01:00
return material != Material.IRON && material != Material.ANVIL && material != Material.ROCK ? super.getDestroySpeed(stack, state) : this.efficiency;
2016-03-19 11:36:17 +01:00
}
@Override
public Set<String> getToolClasses(ItemStack stack){
return Collections.singleton("pickaxe");
}
2016-03-19 11:36:17 +01:00
}