use of net.minecraft.block.GlazedTerracottaBlock in project minecolonies by Minecolonies.
the class WorkerUtil method getBestToolForBlock.
/**
* Get a Tooltype for a certain block. We need this because minecraft has a lot of blocks which have strange or no required tool.
*
* @param state the target BlockState.
* @param blockHardness the hardness.
* @return the toolType to use.
*/
public static IToolType getBestToolForBlock(final BlockState state, float blockHardness) {
final net.minecraftforge.common.ToolType forgeTool = state.getHarvestTool();
String toolName = "";
if (forgeTool == null) {
if (blockHardness > 0f) {
for (final Tuple<ToolType, ItemStack> tool : getOrInitTestTools()) {
if (tool.getB() != null && tool.getB().getItem() instanceof ToolItem) {
final ToolItem toolItem = (ToolItem) tool.getB().getItem();
if (tool.getB().getDestroySpeed(state) >= toolItem.getTier().getSpeed()) {
toolName = tool.getA().getName();
break;
}
}
}
}
} else {
toolName = forgeTool.getName();
}
final IToolType toolType = ToolType.getToolType(toolName);
if (toolType == ToolType.NONE && state.getMaterial() == Material.WOOD) {
return ToolType.AXE;
} else if (state.getBlock() instanceof GlazedTerracottaBlock) {
return ToolType.PICKAXE;
}
return toolType;
}
use of net.minecraft.block.GlazedTerracottaBlock in project minecolonies by ldtteam.
the class WorkerUtil method getBestToolForBlock.
/**
* Get a Tooltype for a certain block. We need this because minecraft has a lot of blocks which have strange or no required tool.
*
* @param state the target BlockState.
* @param blockHardness the hardness.
* @return the toolType to use.
*/
public static IToolType getBestToolForBlock(final BlockState state, float blockHardness) {
final net.minecraftforge.common.ToolType forgeTool = state.getHarvestTool();
String toolName = "";
if (forgeTool == null) {
if (blockHardness > 0f) {
for (final Tuple<ToolType, ItemStack> tool : getOrInitTestTools()) {
if (tool.getB() != null && tool.getB().getItem() instanceof ToolItem) {
final ToolItem toolItem = (ToolItem) tool.getB().getItem();
if (tool.getB().getDestroySpeed(state) >= toolItem.getTier().getSpeed()) {
toolName = tool.getA().getName();
break;
}
}
}
}
} else {
toolName = forgeTool.getName();
}
final IToolType toolType = ToolType.getToolType(toolName);
if (toolType == ToolType.NONE && state.getMaterial() == Material.WOOD) {
return ToolType.AXE;
} else if (state.getBlock() instanceof GlazedTerracottaBlock) {
return ToolType.PICKAXE;
}
return toolType;
}
Aggregations