mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2024-11-10 20:45:59 +01:00
Disassemble contraption when bearing block being rotated by wrench
This commit is contained in:
parent
3b36526443
commit
7954aed0fd
@ -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 New Issue
Block a user