127 lines
4.4 KiB
Java
127 lines
4.4 KiB
Java
|
|
package net.paladrill.paladrillmod.item;
|
|
|
|
import net.paladrill.paladrillmod.procedure.ProcedurePickaxeOfTheGodLevel25ToolInHandTick;
|
|
import net.paladrill.paladrillmod.procedure.ProcedurePickaxeOfTheGodLevel25BlockDestroyedWithTool;
|
|
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.entity.Entity;
|
|
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 ItemPickaxeOfTheGodLevel25 extends ElementsPaladrillmodMod.ModElement {
|
|
@GameRegistry.ObjectHolder("paladrillmod:pickaxeofthegodlevel25")
|
|
public static final Item block = null;
|
|
public ItemPickaxeOfTheGodLevel25(ElementsPaladrillmodMod instance) {
|
|
super(instance, 306);
|
|
}
|
|
|
|
@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);
|
|
ProcedurePickaxeOfTheGodLevel25BlockDestroyedWithTool.executeProcedure($_dependencies);
|
|
}
|
|
return retval;
|
|
}
|
|
|
|
@Override
|
|
public void onUpdate(ItemStack itemstack, World world, Entity entity, int slot, boolean par5) {
|
|
super.onUpdate(itemstack, world, entity, slot, par5);
|
|
int x = (int) entity.posX;
|
|
int y = (int) entity.posY;
|
|
int z = (int) entity.posZ;
|
|
if (entity instanceof EntityLivingBase && ((EntityLivingBase) entity).getHeldItemMainhand().equals(itemstack)) {
|
|
Map<String, Object> $_dependencies = new HashMap<>();
|
|
$_dependencies.put("entity", entity);
|
|
ProcedurePickaxeOfTheGodLevel25ToolInHandTick.executeProcedure($_dependencies);
|
|
}
|
|
}
|
|
}.setUnlocalizedName("pickaxeofthegodlevel25").setRegistryName("pickaxeofthegodlevel25").setCreativeTab(TabPalaDrillMod.tab));
|
|
}
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
@Override
|
|
public void registerModels(ModelRegistryEvent event) {
|
|
ModelLoader.setCustomModelResourceLocation(block, 0, new ModelResourceLocation("paladrillmod:pickaxeofthegodlevel25", "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", 11.5f, 0));
|
|
multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Tool modifier", 11.4, 0));
|
|
}
|
|
return multimap;
|
|
}
|
|
|
|
@Override
|
|
public boolean canHarvestBlock(IBlockState blockIn) {
|
|
return true;
|
|
}
|
|
|
|
@Override
|
|
public float getDestroySpeed(ItemStack par1ItemStack, IBlockState par2Block) {
|
|
return 126.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 146;
|
|
}
|
|
}
|
|
}
|