xTekBlue Posted April 26, 2018 Author Share Posted April 26, 2018 (edited) NEW CODE FOR METHOD private boolean DoDropsOB(World worldIn, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand) { if (player.getHeldItem(hand) != null) { Item item = player.getHeldItem(hand).getItem(); if (item != ItemInit.INGOT_SAW && item != ItemInit.ENCHANTED_SAW) { return false; }else if(item == ItemInit.INGOT_SAW && item.getDamage(player.getHeldItem(hand)) == player.getHeldItem(hand).getMaxDamage()) { player.inventory.deleteStack(player.getHeldItem(hand)); worldIn.destroyBlock(pos, false); player.addItemStackToInventory(new ItemStack(ItemInit.OBSIDIAN_INGOT, 9)); return true; }else if (item == ItemInit.INGOT_SAW && item.getDamage(player.getHeldItem(hand)) != player.getHeldItem(hand).getMaxDamage()) { player.getHeldItem(hand).setItemDamage(player.getHeldItem(hand).getItemDamage() + 1); worldIn.destroyBlock(pos, false); player.addItemStackToInventory(new ItemStack(ItemInit.OBSIDIAN_INGOT, 9)); return true; }else if (item == ItemInit.ENCHANTED_SAW) { worldIn.destroyBlock(pos, false); player.addItemStackToInventory(new ItemStack(ItemInit.OBSIDIAN_INGOT, 9)); return true; } } return true; } The code below still does not seem to work, like it reverts back to normal. worldIn.destroyBlock(pos, false); player.addItemStackToInventory(new ItemStack(ItemInit.OBSIDIAN_INGOT, 9)); Edited April 26, 2018 by xTekBlue Quote Link to comment Share on other sites More sharing options...
xTekBlue Posted April 26, 2018 Author Share Posted April 26, 2018 Problem solved, i wasn't calling the method on client's. package xtekblue.mod.objects.blocks; import java.util.Random; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.oredict.OreDictionary; import xtekblue.mod.Main; import xtekblue.mod.init.ItemInit; public class SmoothObsidian extends BlockBase { public SmoothObsidian(String name, Material material) { super(name, material); setCreativeTab(Main.xtrablocks); setHardness(50.0F); setHarvestLevel("pickaxe", 3); setResistance(2000.0F); } public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { if(worldIn.isRemote) { return this.DoDropsOB(worldIn, pos, state, playerIn, hand); }else { return this.DoDropsOB(worldIn, pos, state, playerIn, hand); } } private boolean DoDropsOB(World worldIn, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand) { if (player.getHeldItem(hand) != null) { Item item = player.getHeldItem(hand).getItem(); if (item != ItemInit.INGOT_SAW && item != ItemInit.ENCHANTED_SAW) { return false; }else if(item == ItemInit.INGOT_SAW && item.getDamage(player.getHeldItem(hand)) == player.getHeldItem(hand).getMaxDamage()) { player.inventory.deleteStack(player.getHeldItem(hand)); worldIn.destroyBlock(pos, false); player.addItemStackToInventory(new ItemStack(ItemInit.OBSIDIAN_INGOT, 9)); return true; }else if (item == ItemInit.INGOT_SAW && item.getDamage(player.getHeldItem(hand)) != player.getHeldItem(hand).getMaxDamage()) { player.getHeldItem(hand).setItemDamage(player.getHeldItem(hand).getItemDamage() + 1); worldIn.destroyBlock(pos, false); player.addItemStackToInventory(new ItemStack(ItemInit.OBSIDIAN_INGOT, 9)); return true; }else if (item == ItemInit.ENCHANTED_SAW) { worldIn.destroyBlock(pos, false); player.addItemStackToInventory(new ItemStack(ItemInit.OBSIDIAN_INGOT, 9)); return true; } } return true; } } Working code ^^^ Last thing, is there a method i'm missing to allow a item to harvest a block regardless of level or even whether its a tool period? I can not find it. Quote Link to comment Share on other sites More sharing options...
jabelar Posted April 26, 2018 Share Posted April 26, 2018 27 minutes ago, xTekBlue said: Last thing, is there a method i'm missing to allow a item to harvest a block regardless of level or even whether its a tool period? I can not find it. I think you can handle the harvest block event. Quote Check out my tutorials here: http://jabelarminecraft.blogspot.com/ Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.