Add fallback item constant to ToolSet
This commit is contained in:
parent
24cbb5e149
commit
1beff941d2
@ -4,6 +4,7 @@ import net.minecraft.block.Block;
|
|||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.entity.EntityPlayerSP;
|
import net.minecraft.client.entity.EntityPlayerSP;
|
||||||
|
import net.minecraft.init.Items;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemAir;
|
import net.minecraft.item.ItemAir;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
@ -23,6 +24,8 @@ import java.util.Map;
|
|||||||
*/
|
*/
|
||||||
public class ToolSet {
|
public class ToolSet {
|
||||||
|
|
||||||
|
private static final Item FALLBACK_ITEM = Items.APPLE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A list of tools on the hotbar that should be considered.
|
* A list of tools on the hotbar that should be considered.
|
||||||
* Note that if there are no tools on the hotbar this list will still have one (null) entry.
|
* Note that if there are no tools on the hotbar this list will still have one (null) entry.
|
||||||
@ -83,7 +86,7 @@ public class ToolSet {
|
|||||||
for (byte i = 0; i < tools.size(); i++) {
|
for (byte i = 0; i < tools.size(); i++) {
|
||||||
Item item = tools.get(i);
|
Item item = tools.get(i);
|
||||||
if (item == null) {
|
if (item == null) {
|
||||||
item = Item.getByNameOrId("minecraft:apple");
|
item = FALLBACK_ITEM;
|
||||||
}
|
}
|
||||||
float v = item.getDestroySpeed(new ItemStack(item), b);
|
float v = item.getDestroySpeed(new ItemStack(item), b);
|
||||||
if (v < value || value == -1) {
|
if (v < value || value == -1) {
|
||||||
@ -118,7 +121,7 @@ public class ToolSet {
|
|||||||
public double getStrVsBlock(IBlockState b, BlockPos pos) {
|
public double getStrVsBlock(IBlockState b, BlockPos pos) {
|
||||||
Item item = this.getBestTool(b);
|
Item item = this.getBestTool(b);
|
||||||
if (item == null) {
|
if (item == null) {
|
||||||
item = Item.getByNameOrId("minecraft:apple");
|
item = FALLBACK_ITEM;
|
||||||
}
|
}
|
||||||
float f = b.getBlockHardness(Minecraft.getMinecraft().world, pos);
|
float f = b.getBlockHardness(Minecraft.getMinecraft().world, pos);
|
||||||
return f < 0.0F ? 0.0F : (!canHarvest(b, item) ? item.getDestroySpeed(new ItemStack(item), b) / f / 100.0F : item.getDestroySpeed(new ItemStack(item), b) / f / 30.0F);
|
return f < 0.0F ? 0.0F : (!canHarvest(b, item) ? item.getDestroySpeed(new ItemStack(item), b) / f / 100.0F : item.getDestroySpeed(new ItemStack(item), b) / f / 30.0F);
|
||||||
|
Loading…
Reference in New Issue
Block a user