-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
34 changed files
with
857 additions
and
236 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
src/client/kotlin/me/znepb/roadworks/render/PedestrianButtonRenderer.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package me.znepb.roadworks.render | ||
|
||
import me.znepb.roadworks.RoadworksMain.ModId | ||
import me.znepb.roadworks.block.PedestrianButton | ||
import me.znepb.roadworks.block.PedestrianButtonBlockEntity | ||
import me.znepb.roadworks.block.post.AbstractPostMountableBlockEntity.Companion.getThickest | ||
import me.znepb.roadworks.util.PostThickness | ||
import me.znepb.roadworks.util.RenderUtils | ||
import net.minecraft.client.render.VertexConsumerProvider | ||
import net.minecraft.client.render.block.entity.BlockEntityRendererFactory | ||
import net.minecraft.client.util.math.MatrixStack | ||
import net.minecraft.state.property.Properties | ||
import net.minecraft.util.math.Direction | ||
|
||
class PedestrianButtonRenderer( | ||
private val ctx: BlockEntityRendererFactory.Context, | ||
) : | ||
AbstractPostMountableRenderer<PedestrianButtonBlockEntity>() { | ||
|
||
companion object { | ||
val PEDESTRIAN_BUTTON_OFF = ModId("block/pedestrian_button_off") | ||
val PEDESTRIAN_BUTTON_ON = ModId("block/pedestrian_button_on") | ||
} | ||
|
||
override fun renderAttachment( | ||
entity: PedestrianButtonBlockEntity, | ||
tickDelta: Float, | ||
matrices: MatrixStack, | ||
vertexConsumers: VertexConsumerProvider, | ||
light: Int, | ||
overlay: Int | ||
) { | ||
|
||
val direction = Direction.byId(entity.facing) | ||
val thickest = getThickest(entity) | ||
val translateBy = if(entity.wall) { | ||
7.0/16 | ||
} else { | ||
-(when (thickest) { | ||
PostThickness.NONE -> 0 | ||
PostThickness.THIN -> 2 | ||
PostThickness.MEDIUM -> 3 | ||
PostThickness.THICK -> 3 | ||
}).toDouble() / 16 | ||
}.toDouble() | ||
|
||
val isButtonPressed = entity.world?.getBlockState(entity.pos)?.block is PedestrianButton && entity.world?.getBlockState(entity.pos)?.get(Properties.POWERED) == true | ||
|
||
val renderer = PostMountRenderer(entity, matrices, vertexConsumers, light, overlay, direction, translateBy) | ||
matrices.push() | ||
renderer.rotateForRender() | ||
matrices.translate(0.0, 0.0, translateBy) | ||
RenderUtils.renderModel(matrices, renderer.buffer, light, overlay, if(isButtonPressed) PEDESTRIAN_BUTTON_ON else PEDESTRIAN_BUTTON_OFF, null) | ||
matrices.pop() | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
src/main/generated/.cache/6fe4d677fbb7b44f14903d96301f1a75bf6b5ac7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
// 1.20.1 2024-06-06T22:35:14.8128604 Roadworks/Language (en_us) | ||
83a497a018a044969947c4127779a0db8ba81f4b assets\roadworks\lang\en_us.json | ||
// 1.20.1 2024-06-07T19:30:39.5048389 Roadworks/Language (en_us) | ||
00e965a320863a2118473dc37172f148de20b8c5 assets\roadworks\lang\en_us.json |
4 changes: 2 additions & 2 deletions
4
src/main/generated/.cache/b04aec471b8c80daca32233710909329a8febd71
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
// 1.20.1 2024-06-06T22:35:14.8123596 Roadworks/Tags for minecraft:block | ||
// 1.20.1 2024-06-07T19:30:39.5038327 Roadworks/Tags for minecraft:block | ||
6458da5395adad7476561352b614d45e9d8169a1 data\roadworks\tags\blocks\standalone_markings.json | ||
b007ad12c3c45db36f651fa35b4b78b2ae28ad59 data\roadworks\tags\blocks\marking.json | ||
fdceaba6990989dbc2afd6e18fb38f0eedbf0231 data\roadworks\tags\blocks\post_mountables.json | ||
6430e3cc2899d59c8e5521eb5dc96beedebfac0b data\roadworks\tags\blocks\post_mountables.json | ||
d02e791778da7a79b0b515823cffbb2fc5c4f6d3 data\roadworks\tags\blocks\posts.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
src/main/generated/assets/roadworks/blockstates/pedestrian_button.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"variants": { | ||
"": { | ||
"model": "roadworks:block/pedestrian_button" | ||
} | ||
} | ||
} |
Oops, something went wrong.