Skip to content

Commit d07ad76

Browse files
authored
Merge branch '1.18.x/main' into 1.18.x/universal-joint
2 parents 1a7adc2 + 6292156 commit d07ad76

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+2846
-9
lines changed

common/src/main/kotlin/org/valkyrienskies/clockwork/ClockworkBlockEntities.kt

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,11 @@ import org.valkyrienskies.clockwork.content.contraptions.phys.slicker.SlickerBlo
3030
import org.valkyrienskies.clockwork.content.contraptions.propeller.PropellerBearingBlockEntity
3131
import org.valkyrienskies.clockwork.content.contraptions.propeller.blades.BladeControllerBlockEntity
3232
import org.valkyrienskies.clockwork.content.contraptions.propeller.blades.BladeControllerRenderer
33+
import org.valkyrienskies.clockwork.content.curiosities.altmeter.AltMeterRenderer
3334
import org.valkyrienskies.clockwork.content.curiosities.clock.ClockBlockEntity
3435
import org.valkyrienskies.clockwork.content.curiosities.clock.ClockRenderer
36+
import org.valkyrienskies.clockwork.content.curiosities.sensor.rotation.LodefocusBlockEntity
37+
import org.valkyrienskies.clockwork.content.curiosities.sensor.rotation.LodefocusRenderer
3538
import org.valkyrienskies.clockwork.content.generic.ColorBlockEntity
3639
import org.valkyrienskies.clockwork.content.kinetics.resistor.RedstoneResistorBlockEntity
3740
import org.valkyrienskies.clockwork.content.kinetics.resistor.RedstoneResistorRenderer
@@ -65,9 +68,32 @@ import org.valkyrienskies.clockwork.content.physicalities.extendon.ExtendonRende
6568
import org.valkyrienskies.clockwork.content.physicalities.reactionwheel.ReactionWheelBlockEntity
6669
import org.valkyrienskies.clockwork.content.physicalities.reactionwheel.ReactionWheelInstance
6770
import org.valkyrienskies.clockwork.content.physicalities.reactionwheel.ReactionWheelRenderer
71+
import org.valkyrienskies.clockwork.content.propulsion.sugar_rocket.SugarRocketBlockEntity
72+
import org.valkyrienskies.clockwork.content.propulsion.sugar_rocket.SugarRocketRenderer
6873

6974
object ClockworkBlockEntities {
7075

76+
@JvmField
77+
val SUGAR_ROCKET: BlockEntityEntry<SugarRocketBlockEntity> = ClockworkMod.REGISTRATE
78+
.blockEntity<SugarRocketBlockEntity>(
79+
"sugar_rocket"
80+
) { type: BlockEntityType<SugarRocketBlockEntity?>?, pos: BlockPos?, state: BlockState? ->
81+
SugarRocketBlockEntity(
82+
type!!,
83+
pos!!,
84+
state!!
85+
)
86+
}
87+
.validBlocks(ClockworkBlocks.SUGAR_ROCKET)
88+
.renderer {
89+
NonNullFunction<BlockEntityRendererProvider.Context?, BlockEntityRenderer<in SugarRocketBlockEntity?>> { context: BlockEntityRendererProvider.Context? ->
90+
SugarRocketRenderer(
91+
context!!
92+
)
93+
}
94+
}
95+
.register()
96+
7197
@JvmField
7298
val PROPELLER_BEARING: BlockEntityEntry<PropellerBearingBlockEntity> = ClockworkMod.REGISTRATE
7399
.blockEntity<PropellerBearingBlockEntity>(
@@ -190,6 +216,31 @@ object ClockworkBlockEntities {
190216
)
191217
}
192218
.validBlocks(ClockworkBlocks.ALT_METER)
219+
.renderer {
220+
NonNullFunction<BlockEntityRendererProvider.Context?, BlockEntityRenderer<in AltMeterBlockEntity?>> { context: BlockEntityRendererProvider.Context? ->
221+
AltMeterRenderer(
222+
context
223+
)
224+
}
225+
}
226+
.register()
227+
228+
@JvmField
229+
val LODEFOCUS = ClockworkMod.REGISTRATE.blockEntity<LodefocusBlockEntity>("lodefocus") { type: BlockEntityType<*>, pos: BlockPos, state: BlockState ->
230+
LodefocusBlockEntity(
231+
type,
232+
pos,
233+
state
234+
)
235+
}
236+
.validBlocks(ClockworkBlocks.LODEFOCUS)
237+
.renderer {
238+
NonNullFunction<BlockEntityRendererProvider.Context?, BlockEntityRenderer<in LodefocusBlockEntity?>> { context: BlockEntityRendererProvider.Context? ->
239+
LodefocusRenderer(
240+
context
241+
)
242+
}
243+
}
193244
.register()
194245

195246
@JvmField

common/src/main/kotlin/org/valkyrienskies/clockwork/ClockworkBlocks.kt

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import net.minecraft.world.item.Item
2121
import net.minecraft.world.level.block.Block
2222
import net.minecraft.world.level.block.Blocks
2323
import net.minecraft.world.level.block.state.BlockBehaviour
24+
import net.minecraft.world.level.block.state.BlockBehaviour.Properties
2425
import net.minecraft.world.level.block.state.BlockState
2526
import org.valkyrienskies.clockwork.ClockworkMod.REGISTRATE
2627
import org.valkyrienskies.clockwork.client.render.WingBlockItemRenderer
@@ -41,6 +42,10 @@ import org.valkyrienskies.clockwork.content.curiosities.GenericWanderliteSlab
4142
import org.valkyrienskies.clockwork.content.curiosities.GenericWanderliteStairs
4243
import org.valkyrienskies.clockwork.content.curiosities.asteroid.AsteroidBlock
4344
import org.valkyrienskies.clockwork.content.curiosities.clock.ClockBlock
45+
import org.valkyrienskies.clockwork.content.curiosities.sensor.distance.DistanceSensorBlock
46+
import org.valkyrienskies.clockwork.content.curiosities.sensor.impact.ImpactSensorBlock
47+
import org.valkyrienskies.clockwork.content.curiosities.sensor.rotation.GyroscopicSensorBlock
48+
import org.valkyrienskies.clockwork.content.curiosities.sensor.rotation.LodefocusBlock
4449
import org.valkyrienskies.clockwork.content.kinetics.resistor.RedstoneResistorBlock
4550
import org.valkyrienskies.clockwork.content.kinetics.sequenced_seat.SequencedSeatBlock
4651
import org.valkyrienskies.clockwork.content.kinetics.universal_shaft.UniversalShaftBlock
@@ -62,13 +67,29 @@ import org.valkyrienskies.clockwork.content.physicalities.reactionwheel.Reaction
6267
import org.valkyrienskies.clockwork.content.physicalities.wing.DyedWingBlockItem
6368
import org.valkyrienskies.clockwork.content.physicalities.wing.FlapBlock
6469
import org.valkyrienskies.clockwork.content.physicalities.wing.WingBlock
70+
import org.valkyrienskies.clockwork.content.propulsion.sugar_rocket.SugarRocketBlock
6571
import org.valkyrienskies.clockwork.util.builder.BuilderTransformersClockwork.flapbearing
6672
import org.valkyrienskies.clockwork.util.builder.ClockworkRegistrate
6773
import java.util.function.Supplier
6874

6975

7076
object ClockworkBlocks {
7177

78+
@JvmField
79+
val SUGAR_ROCKET: BlockEntry<SugarRocketBlock> =
80+
REGISTRATE.block<SugarRocketBlock>("sugar_rocket") { properties: BlockBehaviour.Properties? ->
81+
SugarRocketBlock(properties!!)
82+
}
83+
.initialProperties(SharedProperties.BELT_MATERIAL)
84+
.transform(TagGen.axeOrPickaxe())
85+
.properties { it.instabreak().explosionResistance(0f) }
86+
.addLayer { Supplier { RenderType.cutout() } }
87+
.tag(AllTags.AllBlockTags.SAFE_NBT.tag)
88+
.item()
89+
.tab { ClockworkMod.BASE_CREATIVE_TAB }
90+
.build()
91+
.register()
92+
7293
@JvmField
7394
val BRASS_PROPELLER_BEARING: BlockEntry<PropellerBearingBlock> =
7495
REGISTRATE.block<PropellerBearingBlock>("brass_propeller_bearing") { properties: BlockBehaviour.Properties? ->
@@ -177,6 +198,65 @@ object ClockworkBlocks {
177198
.build()
178199
.register()
179200

201+
@JvmField
202+
val DISTANCE_SENSOR: BlockEntry<DistanceSensorBlock> =
203+
REGISTRATE.block<DistanceSensorBlock>("distance_sensor") { properties: BlockBehaviour.Properties? ->
204+
DistanceSensorBlock(properties!!)
205+
}
206+
.initialProperties { SharedProperties.stone() }
207+
.transform(TagGen.axeOrPickaxe())
208+
.properties { it.noOcclusion() }
209+
.addLayer { Supplier { RenderType.cutout() } }
210+
.tag(AllTags.AllBlockTags.SAFE_NBT.tag)
211+
.item()
212+
.tab { ClockworkMod.BASE_CREATIVE_TAB }
213+
.build()
214+
.register()
215+
216+
@JvmField
217+
val GYROSCOPIC_SENSOR: BlockEntry<GyroscopicSensorBlock> = REGISTRATE.block<GyroscopicSensorBlock>("gyroscopic_sensor") { properties: BlockBehaviour.Properties? ->
218+
GyroscopicSensorBlock(properties!!)
219+
}
220+
.initialProperties { SharedProperties.stone() }
221+
.transform(TagGen.axeOrPickaxe())
222+
.properties { it.noOcclusion() }
223+
.addLayer { Supplier { RenderType.cutout() } }
224+
.tag(AllTags.AllBlockTags.SAFE_NBT.tag)
225+
.item()
226+
.tab { ClockworkMod.BASE_CREATIVE_TAB }
227+
.build()
228+
.register()
229+
230+
@JvmField
231+
val LODEFOCUS: BlockEntry<LodefocusBlock> = REGISTRATE.block<LodefocusBlock>("lodefocus") { properties: BlockBehaviour.Properties? ->
232+
LodefocusBlock(properties!!)
233+
}
234+
.initialProperties { Blocks.GLASS }
235+
.transform(TagGen.axeOrPickaxe())
236+
.properties { it.noOcclusion() ; it.lightLevel{ _ -> 1 } ; it.isViewBlocking{ _, _, _ -> false } }
237+
.addLayer { Supplier { RenderType.cutout() } }
238+
.tag(AllTags.AllBlockTags.SAFE_NBT.tag)
239+
.tag(ClockworkTags.AllBlockTags.SENSOR_LENS.tag)
240+
.item()
241+
.tab { ClockworkMod.BASE_CREATIVE_TAB }
242+
.build()
243+
.register()
244+
245+
@JvmField
246+
val IMPACT_SENSOR: BlockEntry<ImpactSensorBlock> =
247+
REGISTRATE.block<ImpactSensorBlock>("impact_sensor") { properties: BlockBehaviour.Properties? ->
248+
ImpactSensorBlock(properties!!)
249+
}
250+
.initialProperties { SharedProperties.stone() }
251+
.transform(TagGen.axeOrPickaxe())
252+
.properties { it.noOcclusion() }
253+
.addLayer { Supplier { RenderType.cutout() } }
254+
.tag(AllTags.AllBlockTags.SAFE_NBT.tag)
255+
.item()
256+
.tab { ClockworkMod.BASE_CREATIVE_TAB }
257+
.build()
258+
.register()
259+
180260
@JvmField
181261
val GYRO: BlockEntry<GyroBlock> = REGISTRATE.block<GyroBlock>("gyro") { properties: BlockBehaviour.Properties? ->
182262
GyroBlock(properties!!)

common/src/main/kotlin/org/valkyrienskies/clockwork/ClockworkMod.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ import com.simibubi.create.foundation.data.CreateRegistrate
55
import dev.architectury.event.events.common.InteractionEvent
66
import dev.architectury.event.events.common.LifecycleEvent
77
import dev.architectury.event.events.common.TickEvent
8+
import dev.architectury.registry.client.rendering.ColorHandlerRegistry
9+
import net.minecraft.client.color.block.BlockColor
10+
import net.minecraft.client.color.block.BlockTintCache
811
import net.minecraft.resources.ResourceLocation
912
import net.minecraft.world.item.CreativeModeTab
1013
import org.slf4j.LoggerFactory
@@ -56,6 +59,7 @@ object ClockworkMod {
5659
vsApi.registerAttachment(EncasedFanController::class.java)
5760
vsApi.registerAttachment(GyroShipControl::class.java)
5861
vsApi.registerAttachment(GravitronController::class.java)
62+
vsApi.registerAttachment(SugarRocketController::class.java)
5963

6064

6165
VSEvents.ShipLoadEvent.on { event ->
@@ -91,7 +95,6 @@ object ClockworkMod {
9195
DualLinkHandler.handler(player, hand, pos, face)
9296
})
9397

94-
9598
}
9699

97100
fun getKelvin(): DuctNetworkServer {

common/src/main/kotlin/org/valkyrienskies/clockwork/ClockworkTags.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ object ClockworkTags {
3737
optional: Boolean = namespace.optionalDefault,
3838
alwaysDatagen: Boolean = namespace.alwaysDatagenDefault
3939
) {
40-
BALLOON_BLOCK;
40+
BALLOON_BLOCK,
41+
SENSOR_LENS;
4142

4243
val tag: TagKey<Block>
4344
val alwaysDatagen: Boolean

common/src/main/kotlin/org/valkyrienskies/clockwork/content/curiosities/altmeter/AltMeterBlock.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ class AltMeterBlock(properties: Properties) : Block(properties), IBE<AltMeterBlo
8181

8282
override fun getSignal(state: BlockState, level: BlockGetter, pos: BlockPos, direction: Direction): Int {
8383
return if (state.getValue(POWERED)) {
84-
15
84+
(level.getBlockEntity(pos) as? AltMeterBlockEntity)?.getSignalPower()
85+
?: return 15
8586
} else 0
8687
}
8788

common/src/main/kotlin/org/valkyrienskies/clockwork/content/curiosities/altmeter/AltMeterBlockEntity.kt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,19 @@ import net.minecraft.world.level.block.state.BlockState
99
import org.joml.Vector3d
1010
import org.valkyrienskies.clockwork.util.ClockworkConstants
1111
import org.valkyrienskies.mod.common.getShipManagingPos
12+
import kotlin.math.absoluteValue
13+
import kotlin.math.min
1214

1315
class AltMeterBlockEntity(typeIn: BlockEntityType<*>?, pos: BlockPos, state: BlockState) :
1416
SmartBlockEntity(typeIn, pos, state) {
1517
internal var triggerHeight: Double = 0.0
18+
internal var signalStrength = 0
1619
override fun addBehaviours(behaviours: MutableList<BlockEntityBehaviour>) {}
1720

21+
fun getSignalPower(): Int {
22+
return signalStrength
23+
}
24+
1825
override fun tick() {
1926
super.tick()
2027
if (level!!.isClientSide) return
@@ -25,7 +32,9 @@ class AltMeterBlockEntity(typeIn: BlockEntityType<*>?, pos: BlockPos, state: Blo
2532
val posInWorld = Vector3d(blockPos.x + 0.5, blockPos.y + 0.5, blockPos.z + 0.5)
2633
val shipOn = level.getShipManagingPos(blockPos)
2734
shipOn?.transform?.shipToWorld?.transformPosition(posInWorld)
28-
val shouldBePowered = posInWorld.y() >= triggerHeightCopy
35+
val distance = posInWorld.y - triggerHeightCopy
36+
val shouldBePowered = distance.absoluteValue > 0.9
37+
signalStrength = if (shouldBePowered) min(distance.absoluteValue.toInt(), 15) else 0
2938

3039
val isCurrentlyPowered = blockState.getValue(AltMeterBlock.POWERED)
3140

@@ -43,10 +52,12 @@ class AltMeterBlockEntity(typeIn: BlockEntityType<*>?, pos: BlockPos, state: Blo
4352
super.write(compound, clientPacket)
4453
val triggerHeightCopy = triggerHeight
4554
compound.putDouble(ClockworkConstants.Nbt.TRIGGER_HEIGHT, triggerHeightCopy)
55+
compound.putInt("Signal Strength", signalStrength)
4656
}
4757

4858
public override fun read(compound: CompoundTag, clientPacket: Boolean) {
4959
super.read(compound, clientPacket)
5060
triggerHeight = compound.getDouble(ClockworkConstants.Nbt.TRIGGER_HEIGHT)
61+
signalStrength = compound.getInt("Signal Strength")
5162
}
5263
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package org.valkyrienskies.clockwork.content.curiosities.altmeter
2+
3+
import com.mojang.blaze3d.vertex.PoseStack
4+
import com.simibubi.create.foundation.blockEntity.renderer.SmartBlockEntityRenderer
5+
import com.simibubi.create.foundation.render.CachedBufferer
6+
import com.simibubi.create.foundation.utility.Color
7+
import net.minecraft.client.renderer.MultiBufferSource
8+
import net.minecraft.client.renderer.RenderType
9+
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider
10+
import org.valkyrienskies.clockwork.ClockworkPartials
11+
12+
class AltMeterRenderer(context: BlockEntityRendererProvider.Context?) : SmartBlockEntityRenderer<AltMeterBlockEntity>(
13+
context
14+
) {
15+
override fun renderSafe(
16+
blockEntity: AltMeterBlockEntity,
17+
partialTicks: Float,
18+
ms: PoseStack,
19+
buffer: MultiBufferSource,
20+
light: Int,
21+
overlay: Int
22+
) {
23+
super.renderSafe(blockEntity, partialTicks, ms, buffer, light, overlay)
24+
val indicator = CachedBufferer.partial(ClockworkPartials.ALTIMETER_REDSTONE, blockEntity.blockState)
25+
val color = Color.mixColors(0x2C0300, 0xCD0000, blockEntity.signalStrength / 15f)
26+
27+
indicator.light(light).overlay(overlay)
28+
.color(color)
29+
.renderInto(ms, buffer.getBuffer(RenderType.solid()))
30+
}
31+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package org.valkyrienskies.clockwork.content.curiosities.sensor
2+
3+
import com.simibubi.create.content.equipment.wrench.IWrenchable
4+
import net.minecraft.core.BlockPos
5+
import net.minecraft.server.level.ServerLevel
6+
import net.minecraft.world.level.block.state.BlockState
7+
import net.minecraft.world.level.block.state.properties.BlockStateProperties
8+
import net.minecraft.world.level.block.state.properties.IntegerProperty
9+
import java.util.*
10+
11+
interface ISensorBlock : IWrenchable {
12+
companion object {
13+
val POWER: IntegerProperty = BlockStateProperties.POWER
14+
}
15+
16+
fun updatePower(state: BlockState, level: ServerLevel, pos: BlockPos, random: Random): Int
17+
}

0 commit comments

Comments
 (0)