Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,18 @@ import com.simibubi.create.foundation.block.IBE
import com.simibubi.create.foundation.utility.Iterate
import net.minecraft.core.BlockPos
import net.minecraft.core.Direction
import net.minecraft.world.InteractionHand
import net.minecraft.world.InteractionResult
import net.minecraft.world.entity.player.Player
import net.minecraft.world.item.ItemStack
import net.minecraft.world.item.context.BlockPlaceContext
import net.minecraft.world.level.Level
import net.minecraft.world.level.block.Block
import net.minecraft.world.level.block.DirectionalBlock
import net.minecraft.world.level.block.entity.BlockEntityType
import net.minecraft.world.level.block.state.BlockState
import net.minecraft.world.level.block.state.StateDefinition
import net.minecraft.world.phys.BlockHitResult
import org.valkyrienskies.clockwork.ClockworkBlockEntities
import org.valkyrienskies.clockwork.content.logistics.gas.INodeBlock

Expand Down Expand Up @@ -85,4 +90,19 @@ class ExtendonBlock(properties: Properties) : DirectionalBlock(properties), IBE<
override fun getBlockEntityType(): BlockEntityType<out ExtendonBlockEntity> {
return ClockworkBlockEntities.EXTENDON.get()
}

override fun use(
state: BlockState,
level: Level,
pos: BlockPos,
player: Player,
hand: InteractionHand,
hit: BlockHitResult
): InteractionResult {

val be = level.getBlockEntity(pos) as? ExtendonBlockEntity? ?: return super.use(state, level, pos, player, hand, hit)
if (player.getItemInHand(hand) == ItemStack.EMPTY) be.disconnect()

return super.use(state, level, pos, player, hand, hit)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class ExtendonBlockEntity(type: BlockEntityType<*>?, pos: BlockPos, state: Block
override fun tick() {
super.tick()


if (level!!.isClientSide) return

if (connectedBe == null || connectedJoint == null || distanceJoint == null || distanceJointId == null || !main) return
Expand Down Expand Up @@ -98,14 +99,14 @@ class ExtendonBlockEntity(type: BlockEntityType<*>?, pos: BlockPos, state: Block
if (connectedJoint == null) return

if (connectedBe!!.edge == null) edge = null
else removeEdge()
else if (edge != null) removeEdge()

if (connectedBe!!.distanceJoint == null) {
distanceJoint = null
distanceJointId = null
sphericalJoint = null
sphericalJointId = null
} else removeJoint()
} else if (distanceJointId != null) removeJoint()

connectedBe = null
main = false
Expand Down Expand Up @@ -201,7 +202,7 @@ class ExtendonBlockEntity(type: BlockEntityType<*>?, pos: BlockPos, state: Block
connectedBe = level?.getBlockEntity(BlockPos(compound.getInt("ConnectedPosX"),compound.getInt("ConnectedPosY"),compound.getInt("ConnectedPosZ"))) as? ExtendonBlockEntity
connectedJoint = connectedBe
main = compound.getBoolean("IsMain")
}
} else disconnect()

super.read(compound, clientPacket)
}
Expand Down