Skip to content

Commit f374049

Browse files
committed
Allow toolbelt to fix maintenance in-world and prevent merge crafting
1 parent 03c55bc commit f374049

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

src/main/java/gregtech/api/items/toolitem/ItemGTToolbelt.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import gregtech.api.items.IDyeableItem;
55
import gregtech.api.items.gui.ItemUIFactory;
66
import gregtech.api.items.toolitem.behavior.IToolBehavior;
7+
import gregtech.api.metatileentity.MetaTileEntityHolder;
78
import gregtech.api.mui.GTGuiTextures;
89
import gregtech.api.mui.GTGuis;
910
import gregtech.api.unification.material.Material;
@@ -12,6 +13,7 @@
1213
import gregtech.api.unification.material.properties.ToolProperty;
1314
import gregtech.api.util.LocalizationUtils;
1415
import gregtech.common.items.behaviors.ColorSprayBehaviour;
16+
import gregtech.common.metatileentities.multi.multiblockpart.MetaTileEntityMaintenanceHatch;
1517
import gregtech.core.network.packets.PacketToolbeltSelectionChange;
1618

1719
import net.minecraft.block.state.IBlockState;
@@ -393,9 +395,15 @@ public void setSelectedTool(@Nullable Integer slot, ItemStack stack) {
393395
@NotNull BlockPos pos, @NotNull EnumFacing side, float hitX,
394396
float hitY, float hitZ, @NotNull EnumHand hand) {
395397
EnumActionResult result = IDyeableItem.super.onItemUseFirst(player, world, pos, side, hitX, hitY, hitZ, hand);
396-
if (result == EnumActionResult.PASS)
398+
if (result == EnumActionResult.PASS) {
399+
ToolStackHandler handler = getHandler(player.getHeldItem(hand));
400+
if (handler.getSelectedSlot() == null && world.getTileEntity(pos) instanceof MetaTileEntityHolder holder &&
401+
holder.getMetaTileEntity() instanceof MetaTileEntityMaintenanceHatch maintenance) {
402+
maintenance.fixMaintenanceProblems(player);
403+
return EnumActionResult.SUCCESS;
404+
}
397405
return super.onItemUseFirst(player, world, pos, side, hitX, hitY, hitZ, hand);
398-
else return result;
406+
} else return result;
399407
}
400408

401409
@Override

src/main/java/gregtech/common/metatileentities/multi/multiblockpart/MetaTileEntityMaintenanceHatch.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ public void update() {
197197
*
198198
* @param entityPlayer the player performing the fixing
199199
*/
200-
private void fixMaintenanceProblems(@Nullable EntityPlayer entityPlayer) {
200+
public void fixMaintenanceProblems(@Nullable EntityPlayer entityPlayer) {
201201
if (!(this.getController() instanceof IMaintenance))
202202
return;
203203

src/main/java/gregtech/mixins/minecraft/RecipeRepairItemMixin.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package gregtech.mixins.minecraft;
22

33
import gregtech.api.items.toolitem.IGTTool;
4+
import gregtech.api.items.toolitem.ItemGTToolbelt;
45
import gregtech.api.items.toolitem.ToolHelper;
56

67
import net.minecraft.inventory.InventoryCrafting;
@@ -36,7 +37,8 @@ public class RecipeRepairItemMixin {
3637
ItemStack itemstack1 = list.get(0);
3738
if (itemstack.getItem() instanceof IGTTool first &&
3839
itemstack1.getItem() instanceof IGTTool second) {
39-
if (first.isElectric() || second.isElectric()) {
40+
if (first.isElectric() || second.isElectric() ||
41+
first instanceof ItemGTToolbelt || second instanceof ItemGTToolbelt) {
4042
cir.setReturnValue(false);
4143
} else {
4244
cir.setReturnValue(first.getToolMaterial(itemstack) == second.getToolMaterial(itemstack1));

0 commit comments

Comments
 (0)