118 lines
4.0 KiB
Java
118 lines
4.0 KiB
Java
|
|
package net.paladrill.paladrillmod.item;
|
|
|
|
import net.paladrill.paladrillmod.procedure.ProcedurePickaxeOfTheGodBlockDestroyedWithTool;
|
|
import net.paladrill.paladrillmod.creativetab.TabPalaDrillMod;
|
|
import net.paladrill.paladrillmod.ElementsPaladrillmodMod;
|
|
|
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
|
import net.minecraftforge.fml.relauncher.Side;
|
|
import net.minecraftforge.fml.common.registry.GameRegistry;
|
|
import net.minecraftforge.client.model.ModelLoader;
|
|
import net.minecraftforge.client.event.ModelRegistryEvent;
|
|
|
|
import net.minecraft.world.World;
|
|
import net.minecraft.util.math.BlockPos;
|
|
import net.minecraft.item.ItemStack;
|
|
import net.minecraft.item.Item;
|
|
import net.minecraft.inventory.EntityEquipmentSlot;
|
|
import net.minecraft.entity.ai.attributes.AttributeModifier;
|
|
import net.minecraft.entity.SharedMonsterAttributes;
|
|
import net.minecraft.entity.EntityLivingBase;
|
|
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
|
import net.minecraft.block.state.IBlockState;
|
|
|
|
import java.util.Map;
|
|
import java.util.HashMap;
|
|
|
|
import com.google.common.collect.Multimap;
|
|
|
|
@ElementsPaladrillmodMod.ModElement.Tag
|
|
public class ItemPickaxeOfTheGodLevel21 extends ElementsPaladrillmodMod.ModElement {
|
|
@GameRegistry.ObjectHolder("paladrillmod:pickaxeofthegodlevel21")
|
|
public static final Item block = null;
|
|
public ItemPickaxeOfTheGodLevel21(ElementsPaladrillmodMod instance) {
|
|
super(instance, 302);
|
|
}
|
|
|
|
@Override
|
|
public void initElements() {
|
|
elements.items.add(() -> new ItemToolCustom() {
|
|
@Override
|
|
public boolean onBlockDestroyed(ItemStack itemstack, World world, IBlockState bl, BlockPos pos, EntityLivingBase entity) {
|
|
boolean retval = super.onBlockDestroyed(itemstack, world, bl, pos, entity);
|
|
int x = pos.getX();
|
|
int y = pos.getY();
|
|
int z = pos.getZ();
|
|
{
|
|
Map<String, Object> $_dependencies = new HashMap<>();
|
|
$_dependencies.put("entity", entity);
|
|
$_dependencies.put("itemstack", itemstack);
|
|
$_dependencies.put("x", x);
|
|
$_dependencies.put("y", y);
|
|
$_dependencies.put("z", z);
|
|
$_dependencies.put("world", world);
|
|
ProcedurePickaxeOfTheGodBlockDestroyedWithTool.executeProcedure($_dependencies);
|
|
}
|
|
return retval;
|
|
}
|
|
}.setUnlocalizedName("pickaxeofthegodlevel21").setRegistryName("pickaxeofthegodlevel21").setCreativeTab(TabPalaDrillMod.tab));
|
|
}
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
@Override
|
|
public void registerModels(ModelRegistryEvent event) {
|
|
ModelLoader.setCustomModelResourceLocation(block, 0, new ModelResourceLocation("paladrillmod:pickaxeofthegodlevel21", "inventory"));
|
|
}
|
|
private static class ItemToolCustom extends Item {
|
|
protected ItemToolCustom() {
|
|
setMaxDamage(0);
|
|
setMaxStackSize(1);
|
|
}
|
|
|
|
@Override
|
|
public Multimap<String, AttributeModifier> getItemAttributeModifiers(EntityEquipmentSlot equipmentSlot) {
|
|
Multimap<String, AttributeModifier> multimap = super.getItemAttributeModifiers(equipmentSlot);
|
|
if (equipmentSlot == EntityEquipmentSlot.MAINHAND) {
|
|
multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(),
|
|
new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Tool modifier", -2.2999999999999998f, 0));
|
|
multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getName(),
|
|
new AttributeModifier(ATTACK_SPEED_MODIFIER, "Tool modifier", -0.1999999999999997, 0));
|
|
}
|
|
return multimap;
|
|
}
|
|
|
|
@Override
|
|
public boolean canHarvestBlock(IBlockState blockIn) {
|
|
return true;
|
|
}
|
|
|
|
@Override
|
|
public float getDestroySpeed(ItemStack par1ItemStack, IBlockState par2Block) {
|
|
return 9.8f;
|
|
}
|
|
|
|
@Override
|
|
public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker) {
|
|
stack.damageItem(1, attacker);
|
|
return true;
|
|
}
|
|
|
|
@Override
|
|
public boolean onBlockDestroyed(ItemStack stack, World worldIn, IBlockState state, BlockPos pos, EntityLivingBase entityLiving) {
|
|
stack.damageItem(1, entityLiving);
|
|
return true;
|
|
}
|
|
|
|
@Override
|
|
public boolean isFull3D() {
|
|
return true;
|
|
}
|
|
|
|
@Override
|
|
public int getItemEnchantability() {
|
|
return 32;
|
|
}
|
|
}
|
|
}
|