From 7954aed0fd67f5d42f7274af504d2f632c615294 Mon Sep 17 00:00:00 2001 From: Snownee Date: Thu, 18 Mar 2021 23:26:15 +0800 Subject: [PATCH] Disassemble contraption when bearing block being rotated by wrench --- .../structureMovement/bearing/BearingBlock.java | 14 ++++++++++++++ .../bearing/ClockworkBearingBlock.java | 9 +++++++++ 2 files changed, 23 insertions(+) diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/BearingBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/BearingBlock.java index e35a06e2d..66e55acbe 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/BearingBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/BearingBlock.java @@ -3,6 +3,9 @@ package com.simibubi.create.content.contraptions.components.structureMovement.be import com.simibubi.create.content.contraptions.base.DirectionalKineticBlock; import net.minecraft.block.BlockState; +import net.minecraft.item.ItemUseContext; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ActionResultType; import net.minecraft.util.Direction; import net.minecraft.util.Direction.Axis; import net.minecraft.util.math.BlockPos; @@ -29,4 +32,15 @@ public abstract class BearingBlock extends DirectionalKineticBlock { return true; } + @Override + public ActionResultType onWrenched(BlockState state, ItemUseContext context) { + ActionResultType resultType = super.onWrenched(state, context); + if (!context.getWorld().isRemote && resultType.isAccepted()) { + TileEntity te = context.getWorld().getTileEntity(context.getPos()); + if (te instanceof MechanicalBearingTileEntity) { + ((MechanicalBearingTileEntity) te).disassemble(); + } + } + return resultType; + } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/ClockworkBearingBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/ClockworkBearingBlock.java index 18112fbfa..125950656 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/ClockworkBearingBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/ClockworkBearingBlock.java @@ -5,6 +5,7 @@ import com.simibubi.create.foundation.block.ITE; import net.minecraft.block.BlockState; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.ItemUseContext; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ActionResultType; import net.minecraft.util.Hand; @@ -51,4 +52,12 @@ public class ClockworkBearingBlock extends BearingBlock implements ITE