forked from DistrictOfJoban/Joban-Client-Mod
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Render station name for Standing Station Name Sign
- Loading branch information
Showing
7 changed files
with
80 additions
and
17 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
## Manifold Preprocessor | ||
This is a preprocessor that is integrated to the Joban Client Mod projects for multi-target builds. | ||
|
||
### Usage | ||
To conditionally run a code, you can use the `#if` and `#endif` block: | ||
``` | ||
#if MC_VERSION == "11904" | ||
System.out.println("Now running on 1.19.4"); | ||
#elif MC_VERSION == "11802" | ||
System.out.println("Now running on 1.18.2"); | ||
#else | ||
System.out.println("Not running on 1.19.4 nor 1.18.2"); | ||
#endif | ||
``` | ||
|
||
You can also compare the minecraft version: | ||
``` | ||
#if MC_VERSION > "11904" | ||
System.out.println("Running on 1.19.4 or above (e.g. 1.20)"); | ||
#else | ||
System.out.println("Running below 1.19.4"); | ||
#endif | ||
``` | ||
|
||
If you have the [Manifold Plugin](https://plugins.jetbrains.com/plugin/10057-manifold) installed for IntelliJ, the code inside the `#if` and `#elif` block would have a distinct gray background, and there will not be any syntax highlighting. | ||
|
||
Available variable as follows: | ||
|
||
| Variable Name | Description | Example | | ||
|---------------|------------------------------------------------------------------------------------|---------| | ||
| MC_VERSION | The Minecraft version this build is for, in the format MAJOR(1)MINOR(2)PATCH(2) | 11902 | | ||
| LOADER | The modloader this build is for, possible values are `fabric`, `forge`, `neoforge` | fabric | | ||
|
||
The preprocessing should target the main development configuration (Fabric, Latest MC Version). | ||
|
||
To avoid misleading IDE syntax error caused by code from other versions, the code for the main development configuration should be placed in the `#else` block. |
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
33 changes: 25 additions & 8 deletions
33
fabric/src/main/java/com/lx862/jcm/mod/render/block/StationNameStandingRenderer.java
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,19 +1,36 @@ | ||
package com.lx862.jcm.mod.render.block; | ||
|
||
import com.lx862.jcm.mod.block.entity.StationNameStandingBlockEntity; | ||
import org.mtr.mapping.mapper.GraphicsHolder; | ||
import com.lx862.jcm.mod.data.BlockProperties; | ||
import com.lx862.jcm.mod.util.BlockUtil; | ||
import org.mtr.mapping.holder.BlockPos; | ||
import org.mtr.mapping.holder.BlockState; | ||
import org.mtr.mapping.holder.Direction; | ||
import org.mtr.mapping.holder.World; | ||
import org.mtr.mod.client.DynamicTextureCache; | ||
import org.mtr.mod.client.IDrawing; | ||
import org.mtr.mod.render.RenderStationNameBase; | ||
import org.mtr.mod.render.RenderTrains; | ||
import org.mtr.mod.render.StoredMatrixTransformations; | ||
|
||
public class StationNameStandingRenderer extends RenderStationNameBase<StationNameStandingBlockEntity> { | ||
|
||
private static final float WIDTH = 0.6875F; | ||
private static final float HEIGHT = 1; | ||
private static final float OFFSET_Y = 0.125F; | ||
|
||
public class StationNameStandingRenderer extends JCMBlockEntityRenderer<StationNameStandingBlockEntity> { | ||
public StationNameStandingRenderer(Argument dispatcher) { | ||
super(dispatcher); | ||
} | ||
|
||
@Override | ||
public void renderCurated(StationNameStandingBlockEntity blockEntity, float tickDelta, GraphicsHolder graphicsHolder, int light, int i1) { | ||
graphicsHolder.push(); | ||
scaleCentered(graphicsHolder, 0.018F, 0.018F, 0.018F); | ||
rotateToBlockDirection(graphicsHolder, blockEntity); | ||
// TODO: Render with IDrawing | ||
graphicsHolder.pop(); | ||
protected void drawStationName(World world, BlockPos pos, BlockState state, Direction facing, StoredMatrixTransformations storedMatrixTransformations, String stationName, int stationColor, int color, int light) { | ||
if (BlockUtil.getProperty(state, BlockProperties.VERTICAL_PART_3) == 1) { | ||
RenderTrains.scheduleRender(DynamicTextureCache.instance.getTallStationName(color, stationName, stationColor, WIDTH / HEIGHT).identifier, false, RenderTrains.QueuedRenderLayer.EXTERIOR, (graphicsHolder, offset) -> { | ||
storedMatrixTransformations.transform(graphicsHolder, offset); | ||
IDrawing.drawTexture(graphicsHolder, -WIDTH / 2, -HEIGHT / 2 - OFFSET_Y, WIDTH, HEIGHT, 0, 0, 1, 1, facing, ARGB_WHITE, light); | ||
graphicsHolder.pop(); | ||
}); | ||
} | ||
} | ||
} |