mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-27 23:47:38 +01:00
Disassemble contraption when bearing block being rotated by wrench
This commit is contained in:
parent
3b36526443
commit
7954aed0fd
2 changed files with 23 additions and 0 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<Clockwork
|
|||
return ClockworkBearingTileEntity.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResultType onWrenched(BlockState state, ItemUseContext context) {
|
||||
ActionResultType resultType = super.onWrenched(state, context);
|
||||
if (!context.getWorld().isRemote && resultType.isAccepted())
|
||||
withTileEntityDo(context.getWorld(), context.getPos(), ClockworkBearingTileEntity::disassemble);
|
||||
return resultType;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue