Skip to content

Commit

Permalink
small prop
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-s168 committed Jan 16, 2024
1 parent 3c762e2 commit 63fbf73
Show file tree
Hide file tree
Showing 16 changed files with 471 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,10 @@ import org.valkyrienskies.tournament.registry.RegistrySupplier
object TournamentBlockEntities {
private val BLOCKENTITIES = DeferredRegister.create(TournamentMod.MOD_ID, Registry.BLOCK_ENTITY_TYPE_REGISTRY)

val SENSOR = TournamentBlocks.SENSOR withBE ::SensorBlockEntity byName "sensor"
val ROPE_HOOK = TournamentBlocks.ROPE_HOOK withBE ::RopeHookBlockEntity byName "rope_hook"
val PROPELLER = TournamentBlocks.PROP_BIG withBE {pos, state ->
PropellerBlockEntity(
pos,
state,
TournamentConfig.SERVER.propellerBigSpeed,
TournamentConfig.SERVER.propellerBigAccel
)
} byName "propeller"
val SENSOR = TournamentBlocks.SENSOR withBE ::SensorBlockEntity byName "sensor"
val ROPE_HOOK = TournamentBlocks.ROPE_HOOK withBE ::RopeHookBlockEntity byName "rope_hook"
val PROP_BIG = TournamentBlocks.PROP_BIG withBE ::BigPropellerBlockEntity byName "prop_big"
val PROP_SMALL = TournamentBlocks.PROP_SMALL withBE ::SmallPropellerBlockEntity byName "prop_small"

// explosives:
val EXPLOSIVE = TournamentBlocks.EXPLOSIVE_INSTANT_SMALL withBE ::ExplosiveBlockEntity byName "explosive_instant_small"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import net.minecraft.world.level.block.*
import net.minecraft.world.level.block.state.BlockBehaviour
import net.minecraft.world.level.material.Material
import org.valkyrienskies.mod.common.hooks.VSGameEvents
import org.valkyrienskies.tournament.blockentity.BigPropellerBlockEntity
import org.valkyrienskies.tournament.blockentity.SmallPropellerBlockEntity
import org.valkyrienskies.tournament.util.extension.explodeShip
import org.valkyrienskies.tournament.blocks.*
import org.valkyrienskies.tournament.blocks.explosive.AbstractExplosiveBlock
Expand All @@ -38,6 +40,7 @@ object TournamentBlocks {
lateinit var ROPE_HOOK : RegistrySupplier<RopeHookBlock>
lateinit var SENSOR : RegistrySupplier<SensorBlock>
lateinit var PROP_BIG : RegistrySupplier<PropellerBlock>
lateinit var PROP_SMALL : RegistrySupplier<PropellerBlock>

lateinit var EXPLOSIVE_INSTANT_SMALL : RegistrySupplier<AbstractExplosiveBlock>
lateinit var EXPLOSIVE_INSTANT_MEDIUM : RegistrySupplier<AbstractExplosiveBlock>
Expand Down Expand Up @@ -87,8 +90,13 @@ object TournamentBlocks {
PROP_BIG = register("prop_big") {
PropellerBlock(
TournamentConfig.SERVER.propellerBigForce,
TournamentConfig.SERVER.propellerBigSpeed,
TournamentConfig.SERVER.propellerBigAccel,
::BigPropellerBlockEntity
)
}
PROP_SMALL = register("prop_small") {
PropellerBlock(
TournamentConfig.SERVER.propellerSmallForce,
::SmallPropellerBlockEntity
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,15 @@ object TournamentConfig {
@JsonSchema(description = "The acceleration of a big propeller. (deaccel = accel * 2)")
var propellerBigAccel = 0.1f

@JsonSchema(description = "The force of a big propeller at max speed")
var propellerSmallForce = 1000.0

@JsonSchema(description = "The max speed of a big propeller at max redstone input")
var propellerSmallSpeed = 50.0f

@JsonSchema(description = "The acceleration of a big propeller. (deaccel = accel * 2)")
var propellerSmallAccel = 1.0f

@JsonSchema(description = "The list of blocks that don't get assembled by the ship assembler")
var blockBlacklist = setOf(
"minecraft:dirt",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ object TournamentMod {
clientRenderers.registerBlockEntityRenderer(be, renderer)
}

renderer(TournamentBlockEntities.PROPELLER.get()) { PropellerBlockEntityRender() }
renderer(TournamentBlockEntities.PROP_BIG.get()) {
PropellerBlockEntityRender(TournamentModels.PROP_BIG)
}
renderer(TournamentBlockEntities.PROP_SMALL.get()) {
PropellerBlockEntityRender(TournamentModels.PROP_SMALL)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,6 @@ object TournamentModels {
}

val PROP_BIG = model("block/prop_big_prop")
val PROP_SMALL = model("block/prop_small_prop")

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,19 @@ import net.minecraft.world.level.Level
import net.minecraft.world.level.block.Block
import net.minecraft.world.level.block.entity.BlockEntity
import net.minecraft.world.level.block.entity.BlockEntityTicker
import net.minecraft.world.level.block.entity.BlockEntityType
import net.minecraft.world.level.block.state.BlockState
import org.valkyrienskies.tournament.TournamentBlockEntities
import org.valkyrienskies.tournament.TournamentConfig
import org.valkyrienskies.tournament.blocks.PropellerBlock

class PropellerBlockEntity(
abstract class PropellerBlockEntity<T: BlockEntity>(
be: BlockEntityType<T>,
pos: BlockPos,
state: BlockState,
val maxSpeed: Float,
val accel: Float
): BlockEntity(TournamentBlockEntities.PROPELLER.get(), pos, state) {
): BlockEntity(be, pos, state) {

var signal: Int = -1
var rotation: Double = 0.0
Expand All @@ -40,7 +43,7 @@ class PropellerBlockEntity(
}

companion object {
val ticker = BlockEntityTicker<PropellerBlockEntity> { level, _, _, be ->
val ticker = BlockEntityTicker<PropellerBlockEntity<*>> { level, _, _, be ->
be.tick(level)
}
}
Expand Down Expand Up @@ -73,4 +76,26 @@ class PropellerBlockEntity(
level?.sendBlockUpdated(blockPos, blockState, blockState, Block.UPDATE_ALL_IMMEDIATE)
}

}
}

class BigPropellerBlockEntity(
pos: BlockPos,
state: BlockState,
): PropellerBlockEntity<BigPropellerBlockEntity>(
TournamentBlockEntities.PROP_BIG.get(),
pos,
state,
TournamentConfig.SERVER.propellerBigSpeed,
TournamentConfig.SERVER.propellerBigAccel
)

class SmallPropellerBlockEntity(
pos: BlockPos,
state: BlockState,
): PropellerBlockEntity<SmallPropellerBlockEntity>(
TournamentBlockEntities.PROP_SMALL.get(),
pos,
state,
TournamentConfig.SERVER.propellerSmallSpeed,
TournamentConfig.SERVER.propellerSmallAccel
)
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import org.valkyrienskies.tournament.TournamentModels
import org.valkyrienskies.tournament.blockentity.PropellerBlockEntity
import org.valkyrienskies.tournament.util.extension.pose

class PropellerBlockEntityRender:
BlockEntityRenderer<PropellerBlockEntity>
{
class PropellerBlockEntityRender<T: PropellerBlockEntity<T>>(
val model: TournamentModels.Model
): BlockEntityRenderer<T> {

override fun render(
be: PropellerBlockEntity,
be: T,
partial: Float,
pose: PoseStack,
bufferSource: MultiBufferSource,
Expand All @@ -26,7 +26,7 @@ class PropellerBlockEntityRender:
mulPose(be.blockState.getValue(DirectionalBlock.FACING).opposite.rotation)
pose.mulPose(Vector3f.YP.rotationDegrees(be.rotation.toFloat()))
translate(-0.5, -0.5, -0.5)
TournamentModels.PROP_BIG.renderer.render(
model.renderer.render(
pose,
be,
bufferSource,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ import org.valkyrienskies.tournament.util.block.DirectionalBaseEntityBlock

class PropellerBlock(
val mult: Double,
val maxSpeed: Float,
val accel: Float
val beConstr: (BlockPos, BlockState) -> PropellerBlockEntity<*>,
): DirectionalBaseEntityBlock(
Properties.of(Material.STONE)
.sound(SoundType.STONE)
Expand Down Expand Up @@ -81,7 +80,7 @@ class PropellerBlock(

val signal = getPropSignal(state, level, pos)

val be = level.getBlockEntity(pos) as? PropellerBlockEntity
val be = level.getBlockEntity(pos) as? PropellerBlockEntity<*>
?: return

be.signal = signal
Expand Down Expand Up @@ -119,7 +118,7 @@ class PropellerBlock(

val signal = getPropSignal(state, level, pos)

val be = level.getBlockEntity(pos) as? PropellerBlockEntity
val be = level.getBlockEntity(pos) as? PropellerBlockEntity<*>
?: return

be.signal = signal
Expand All @@ -138,7 +137,7 @@ class PropellerBlock(
}

override fun newBlockEntity(pos: BlockPos, state: BlockState): BlockEntity =
PropellerBlockEntity(pos, state, maxSpeed, accel)
beConstr(pos, state)

@Suppress("UNCHECKED_CAST")
override fun <T: BlockEntity> getTicker(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class TournamentShips: ShipForcesInducer {

val be = lvl.getBlockEntity(
p.pos.toBlockPos()
) as PropellerBlockEntity?
) as PropellerBlockEntity<*>?

if (be != null) {
p.speed.set(be.speed)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"variants": {
"facing=north": {
"model": "vs_tournament:block/prop_small",
"y": 0,
"x": 90
},
"facing=east": {
"model": "vs_tournament:block/prop_small",
"y": 90,
"x": 90
},
"facing=south": {
"model": "vs_tournament:block/prop_small",
"y": 180,
"x": 90
},
"facing=west": {
"model": "vs_tournament:block/prop_small",
"y": 270,
"x": 90
},
"facing=up": {
"model": "vs_tournament:block/prop_small",
"x": 0
},
"facing=down": {
"model": "vs_tournament:block/prop_small",
"x": 180
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"block.vs_tournament.fuel_gauge": "Fuel Gauge",
"block.vs_tournament.floater": "Floater",
"block.vs_tournament.prop_big": "Propeller (big)",
"block.vs_tournament.prop_small": "Propeller (small)",

"block.vs_tournament.explosive_instant_small": "Instant Explosive (small)",
"block.vs_tournament.explosive_instant_medium": "Instant Explosive (medium)",
Expand All @@ -37,9 +38,6 @@
"chat.vs_tournament.rope.connected": "Rope connected!",
"chat.vs_tournament.rope.first": "First position set!",
"chat.vs_tournament.delete_wand.deleted": "Deleted ship!",
"chat.vs_tournament.fuel_container.amount": "Fuel: %s / %s kg",
"chat.vs_tournament.fuel_gauge.not_on_ship": "Not on a ship!",
"chat.vs_tournament.fuel_gauge.amount": "Total fuel: %s kg",

"advancements.vs_tournament.ship_assemble.title": "Assemble a ship",
"advancements.vs_tournament.ship_assemble.description": "Create a VS2 ship with the ship assembler",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"credit": "Made with Blockbench",
"texture_size": [64, 64],
"textures": {
"2": "vs_tournament:block/prop_small",
"particle": "vs_tournament:block/prop_small"
},
"elements": [
{
"name": "Base",
"from": [0, 8, 0],
"to": [16,16, 16],
"faces": {
"north": {"uv": [4, 0, 8, 1.75], "texture": "#2"},
"east": {"uv": [4, 1.75, 8, 3.5], "texture": "#2"},
"south": {"uv": [4, 3.5, 8, 5.25], "texture": "#2"},
"west": {"uv": [4, 5.25, 8, 7], "texture": "#2"},
"up": {"uv": [4, 4, 0, 0], "texture": "#2"},
"down": {"uv": [4, 4, 0, 8], "texture": "#2"}
}
}
],
"groups": [

]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
{
"credit": "Made with Blockbench",
"texture_size": [64, 64],
"textures": {
"2": "vs_tournament:block/prop_small",
"particle": "vs_tournament:block/prop_small"
},
"elements": [
{
"from": [-1.5, 8, -1],
"to": [4.5, 8, 6],
"rotation": {"angle": -45, "axis": "z", "origin": [9.5, 2, 0]},
"faces": {
"north": {"uv": [0, 0, 1.5, 0], "texture": "#2"},
"east": {"uv": [0, 0, 1.75, 0], "texture": "#2"},
"south": {"uv": [0, 0, 1.5, 0], "texture": "#2"},
"west": {"uv": [0, 0, 1.75, 0], "texture": "#2"},
"up": {"uv": [9.5, 1.75, 8, 0], "texture": "#2"},
"down": {"uv": [3.25, 8, 1.75, 9.75], "texture": "#2"}
}
},
{
"from": [6, 7, 6],
"to": [10, 13, 10],
"rotation": {"angle": 0, "axis": "y", "origin": [0, 5, 0]},
"faces": {
"north": {"uv": [8, 5.25, 9, 6.75], "texture": "#2"},
"east": {"uv": [3.25, 8.5, 4.25, 10], "texture": "#2"},
"south": {"uv": [4.25, 8.5, 5.25, 10], "texture": "#2"},
"west": {"uv": [5.25, 8.5, 6.25, 10], "texture": "#2"},
"up": {"uv": [7.25, 9.5, 6.25, 8.5], "texture": "#2"},
"down": {"uv": [8.25, 8.5, 7.25, 9.5], "texture": "#2"}
}
},
{
"from": [-1, 8, 11.5],
"to": [6, 8, 17.5],
"rotation": {"angle": -45, "axis": "x", "origin": [0, 2, 6.5]},
"faces": {
"north": {"uv": [0, 0, 1.75, 0], "texture": "#2"},
"east": {"uv": [0, 0, 1.5, 0], "texture": "#2"},
"south": {"uv": [0, 0, 1.75, 0], "texture": "#2"},
"west": {"uv": [0, 0, 1.5, 0], "texture": "#2"},
"up": {"uv": [5.75, 8.5, 4, 7], "texture": "#2"},
"down": {"uv": [5.75, 8.5, 7.5, 7], "texture": "#2"}
}
},
{
"from": [10, 8, -1.5],
"to": [17, 8, 4.5],
"rotation": {"angle": 45, "axis": "x", "origin": [16, 2, 9.5]},
"faces": {
"north": {"uv": [0, 0, 1.75, 0], "texture": "#2"},
"east": {"uv": [0, 0, 1.5, 0], "texture": "#2"},
"south": {"uv": [0, 0, 1.75, 0], "texture": "#2"},
"west": {"uv": [0, 0, 1.5, 0], "texture": "#2"},
"up": {"uv": [9.25, 8.5, 7.5, 7], "texture": "#2"},
"down": {"uv": [1.75, 8, 0, 9.5], "texture": "#2"}
}
},
{
"from": [11.5, 8, 10],
"to": [17.5, 8, 17],
"rotation": {"angle": 45, "axis": "z", "origin": [6.5, 2, 16]},
"faces": {
"north": {"uv": [0, 0, 1.5, 0], "texture": "#2"},
"east": {"uv": [0, 0, 1.75, 0], "texture": "#2"},
"south": {"uv": [0, 0, 1.5, 0], "texture": "#2"},
"west": {"uv": [0, 0, 1.75, 0], "texture": "#2"},
"up": {"uv": [9.5, 3.5, 8, 1.75], "texture": "#2"},
"down": {"uv": [9.5, 3.5, 8, 5.25], "texture": "#2"}
}
}
],
"groups": [
{
"name": "prop",
"origin": [6.5, -3, 16],
"color": 0,
"children": [0, 1, 2, 3, 4]
},
5
]
}
Loading

0 comments on commit 63fbf73

Please sign in to comment.