Merge pull request #3301 from wagyourtail/toolmaterial-fix
fix modded toolmaterials (1.12.2)
This commit is contained in:
commit
8fe5b2369a
35
src/launch/java/baritone/launch/mixins/MixinItemTool.java
Normal file
35
src/launch/java/baritone/launch/mixins/MixinItemTool.java
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of Baritone.
|
||||||
|
*
|
||||||
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package baritone.launch.mixins;
|
||||||
|
|
||||||
|
import baritone.utils.accessor.IItemTool;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.ItemTool;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
|
|
||||||
|
@Mixin(ItemTool.class)
|
||||||
|
public class MixinItemTool implements IItemTool {
|
||||||
|
@Shadow protected Item.ToolMaterial toolMaterial;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getHarvestLevel() {
|
||||||
|
return toolMaterial.getHarvestLevel();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -21,6 +21,7 @@
|
|||||||
"MixinEntityRenderer",
|
"MixinEntityRenderer",
|
||||||
"MixinGuiScreen",
|
"MixinGuiScreen",
|
||||||
"MixinItemStack",
|
"MixinItemStack",
|
||||||
|
"MixinItemTool",
|
||||||
"MixinMinecraft",
|
"MixinMinecraft",
|
||||||
"MixinNetHandlerPlayClient",
|
"MixinNetHandlerPlayClient",
|
||||||
"MixinNetworkManager",
|
"MixinNetworkManager",
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
package baritone.utils;
|
package baritone.utils;
|
||||||
|
|
||||||
import baritone.Baritone;
|
import baritone.Baritone;
|
||||||
|
import baritone.utils.accessor.IItemTool;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.client.entity.EntityPlayerSP;
|
import net.minecraft.client.entity.EntityPlayerSP;
|
||||||
@ -78,15 +79,16 @@ public class ToolSet {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Evaluate the material cost of a possible tool. The priority matches the
|
* Evaluate the material cost of a possible tool. The priority matches the
|
||||||
* listed order in the Item.ToolMaterial enum.
|
* harvest level order; there is a chance for multiple at the same with modded tools
|
||||||
|
* but in that case we don't really care.
|
||||||
*
|
*
|
||||||
* @param itemStack a possibly empty ItemStack
|
* @param itemStack a possibly empty ItemStack
|
||||||
* @return values range from -1 to 4
|
* @return values from 0 up
|
||||||
*/
|
*/
|
||||||
private int getMaterialCost(ItemStack itemStack) {
|
private int getMaterialCost(ItemStack itemStack) {
|
||||||
if (itemStack.getItem() instanceof ItemTool) {
|
if (itemStack.getItem() instanceof ItemTool) {
|
||||||
ItemTool tool = (ItemTool) itemStack.getItem();
|
ItemTool tool = (ItemTool) itemStack.getItem();
|
||||||
return ToolMaterial.valueOf(tool.getToolMaterialName()).ordinal();
|
return ((IItemTool) tool).getHarvestLevel();
|
||||||
} else {
|
} else {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
24
src/main/java/baritone/utils/accessor/IItemTool.java
Normal file
24
src/main/java/baritone/utils/accessor/IItemTool.java
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of Baritone.
|
||||||
|
*
|
||||||
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package baritone.utils.accessor;
|
||||||
|
|
||||||
|
public interface IItemTool {
|
||||||
|
|
||||||
|
int getHarvestLevel();
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user