From c6728c6a2b4d78d3290dcff683a7a03a6fcfdcd1 Mon Sep 17 00:00:00 2001 From: ImplicitSaber Date: Mon, 21 Oct 2024 17:47:42 -0500 Subject: [PATCH] v1.21-1.1.0 --- gradle.properties | 2 +- .../forkcart/ForkcartClient.java | 1 + .../entity/TrackTiesBlockEntityRenderer.java | 4 +- .../forkcart/blockstates/shuttle_ties.json | 212 ++++++++++++++++++ .../block/shuttle_off_ties_pointing_0.json | 18 ++ .../block/shuttle_off_ties_pointing_1.json | 18 ++ .../block/shuttle_off_ties_pointing_2.json | 18 ++ .../block/shuttle_off_ties_pointing_3.json | 18 ++ .../models/block/shuttle_ties_pointing_0.json | 18 ++ .../models/block/shuttle_ties_pointing_1.json | 18 ++ .../models/block/shuttle_ties_pointing_2.json | 18 ++ .../models/block/shuttle_ties_pointing_3.json | 18 ++ .../forkcart/models/item/brake_track.json | 6 + .../forkcart/models/item/shuttle_ties.json | 6 + .../textures/block/shuttle_ties_off.png | Bin 0 -> 859 bytes .../textures/block/shuttle_ties_on.png | Bin 0 -> 875 bytes .../assets/forkcart/textures/brake_track.png | Bin 0 -> 595 bytes .../forkcart/textures/item/brake_track.png | Bin 0 -> 626 bytes .../implicitsaber/forkcart/Forkcart.java | 31 ++- .../forkcart/block/ShuttleTiesBlock.java | 43 ++++ .../forkcart/block/TrackTiesBlockEntity.java | 1 + .../forkcart/entity/TrackFollowerEntity.java | 86 +++++-- .../forkcart/item/TrackItem.java | 3 +- .../forkcart/mixin/EntityMixin.java | 6 + .../implicitsaber/forkcart/util/Pose.java | 10 + .../forkcart/util/TrackSnapUtil.java | 101 +++++++++ .../resources/assets/forkcart/lang/en_us.json | 10 +- .../loot_table/blocks/shuttle_ties.json | 21 ++ .../data/forkcart/recipe/brake_track.json | 24 ++ .../data/forkcart/recipe/shuttle_ties.json | 27 +++ .../data/forkcart/tags/item/track.json | 3 +- .../tags/block/mineable/pickaxe.json | 5 +- 32 files changed, 709 insertions(+), 37 deletions(-) create mode 100644 src/client/resources/assets/forkcart/blockstates/shuttle_ties.json create mode 100644 src/client/resources/assets/forkcart/models/block/shuttle_off_ties_pointing_0.json create mode 100644 src/client/resources/assets/forkcart/models/block/shuttle_off_ties_pointing_1.json create mode 100644 src/client/resources/assets/forkcart/models/block/shuttle_off_ties_pointing_2.json create mode 100644 src/client/resources/assets/forkcart/models/block/shuttle_off_ties_pointing_3.json create mode 100644 src/client/resources/assets/forkcart/models/block/shuttle_ties_pointing_0.json create mode 100644 src/client/resources/assets/forkcart/models/block/shuttle_ties_pointing_1.json create mode 100644 src/client/resources/assets/forkcart/models/block/shuttle_ties_pointing_2.json create mode 100644 src/client/resources/assets/forkcart/models/block/shuttle_ties_pointing_3.json create mode 100644 src/client/resources/assets/forkcart/models/item/brake_track.json create mode 100644 src/client/resources/assets/forkcart/models/item/shuttle_ties.json create mode 100644 src/client/resources/assets/forkcart/textures/block/shuttle_ties_off.png create mode 100644 src/client/resources/assets/forkcart/textures/block/shuttle_ties_on.png create mode 100644 src/client/resources/assets/forkcart/textures/brake_track.png create mode 100644 src/client/resources/assets/forkcart/textures/item/brake_track.png create mode 100644 src/main/java/io/github/implicitsaber/forkcart/block/ShuttleTiesBlock.java create mode 100644 src/main/java/io/github/implicitsaber/forkcart/util/TrackSnapUtil.java create mode 100644 src/main/resources/data/forkcart/loot_table/blocks/shuttle_ties.json create mode 100644 src/main/resources/data/forkcart/recipe/brake_track.json create mode 100644 src/main/resources/data/forkcart/recipe/shuttle_ties.json diff --git a/gradle.properties b/gradle.properties index ebd2a8e..a2015af 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,7 +9,7 @@ yarn_mappings=1.21+build.2 loader_version=0.15.11 # Mod Properties -mod_version=1.21-1.0.0 +mod_version=1.21-1.1.0 maven_group=io.github.implicitsaber archives_base_name=forkcart diff --git a/src/client/java/io/github/implicitsaber/forkcart/ForkcartClient.java b/src/client/java/io/github/implicitsaber/forkcart/ForkcartClient.java index ee8651e..d1c642d 100644 --- a/src/client/java/io/github/implicitsaber/forkcart/ForkcartClient.java +++ b/src/client/java/io/github/implicitsaber/forkcart/ForkcartClient.java @@ -36,6 +36,7 @@ public void onInitializeClient() { BlockRenderLayerMap.INSTANCE.putBlock(Forkcart.TRACK_TIES, RenderLayer.getCutout()); BlockRenderLayerMap.INSTANCE.putBlock(Forkcart.SWITCH_TIES, RenderLayer.getCutout()); BlockRenderLayerMap.INSTANCE.putBlock(Forkcart.INVISIBLE_TIES, RenderLayer.getCutout()); + BlockRenderLayerMap.INSTANCE.putBlock(Forkcart.SHUTTLE_TIES, RenderLayer.getCutout()); BlockEntityRendererFactories.register(Forkcart.TRACK_TIES_BE, TrackTiesBlockEntityRenderer::new); EntityRendererRegistry.register(Forkcart.TRACK_FOLLOWER, EmptyEntityRenderer::new); diff --git a/src/client/java/io/github/implicitsaber/forkcart/block/entity/TrackTiesBlockEntityRenderer.java b/src/client/java/io/github/implicitsaber/forkcart/block/entity/TrackTiesBlockEntityRenderer.java index 5d92508..99af186 100644 --- a/src/client/java/io/github/implicitsaber/forkcart/block/entity/TrackTiesBlockEntityRenderer.java +++ b/src/client/java/io/github/implicitsaber/forkcart/block/entity/TrackTiesBlockEntityRenderer.java @@ -24,9 +24,8 @@ public class TrackTiesBlockEntityRenderer implements BlockEntityRenderer { public static final int WHITE = 0xFFFFFFFF; public static final Identifier CHAIN_TRACK_TEXTURE = Forkcart.id("textures/chain_track.png"); - public static final Identifier ANTIGRAVITY_TRACK_TEXTURE = Forkcart.id("textures/antigravity_track.png"); - public static final Identifier FRICTIONLESS_TRACK_TEXTURE = Forkcart.id("textures/frictionless_track.png"); public static final Identifier STATION_TRACK_TEXTURE = Forkcart.id("textures/station_track.png"); + private static final Identifier BRAKE_TRACK_TEXTURE = Forkcart.id("textures/brake_track.png"); public static final Identifier TRACK_TEXTURE = Forkcart.id("textures/track.png"); public static final Identifier POSE_TEXTURE_DEBUG = Forkcart.id("textures/debug.png"); @@ -141,6 +140,7 @@ protected Identifier getTexture(TrackTiesBlockEntity be) { case STANDARD -> TRACK_TEXTURE; case CHAIN -> CHAIN_TRACK_TEXTURE; case STATION -> STATION_TRACK_TEXTURE; + case BRAKE -> BRAKE_TRACK_TEXTURE; }; } diff --git a/src/client/resources/assets/forkcart/blockstates/shuttle_ties.json b/src/client/resources/assets/forkcart/blockstates/shuttle_ties.json new file mode 100644 index 0000000..1eefa36 --- /dev/null +++ b/src/client/resources/assets/forkcart/blockstates/shuttle_ties.json @@ -0,0 +1,212 @@ +{ + "variants": { + "running=false,pointing=0,facing=down": { + "model": "forkcart:block/shuttle_off_ties_pointing_0", + "x": 180 + }, + "running=false,pointing=0,facing=east": { + "model": "forkcart:block/shuttle_off_ties_pointing_0", + "x": 90, + "y": 90 + }, + "running=false,pointing=0,facing=north": { + "model": "forkcart:block/shuttle_off_ties_pointing_0", + "x": 90 + }, + "running=false,pointing=0,facing=south": { + "model": "forkcart:block/shuttle_off_ties_pointing_0", + "x": 90, + "y": 180 + }, + "running=false,pointing=0,facing=up": { + "model": "forkcart:block/shuttle_off_ties_pointing_0" + }, + "running=false,pointing=0,facing=west": { + "model": "forkcart:block/shuttle_off_ties_pointing_0", + "x": 90, + "y": 270 + }, + "running=false,pointing=1,facing=down": { + "model": "forkcart:block/shuttle_off_ties_pointing_1", + "x": 180 + }, + "running=false,pointing=1,facing=east": { + "model": "forkcart:block/shuttle_off_ties_pointing_1", + "x": 90, + "y": 90 + }, + "running=false,pointing=1,facing=north": { + "model": "forkcart:block/shuttle_off_ties_pointing_1", + "x": 90 + }, + "running=false,pointing=1,facing=south": { + "model": "forkcart:block/shuttle_off_ties_pointing_1", + "x": 90, + "y": 180 + }, + "running=false,pointing=1,facing=up": { + "model": "forkcart:block/shuttle_off_ties_pointing_1" + }, + "running=false,pointing=1,facing=west": { + "model": "forkcart:block/shuttle_off_ties_pointing_1", + "x": 90, + "y": 270 + }, + "running=false,pointing=2,facing=down": { + "model": "forkcart:block/shuttle_off_ties_pointing_2", + "x": 180 + }, + "running=false,pointing=2,facing=east": { + "model": "forkcart:block/shuttle_off_ties_pointing_2", + "x": 90, + "y": 90 + }, + "running=false,pointing=2,facing=north": { + "model": "forkcart:block/shuttle_off_ties_pointing_2", + "x": 90 + }, + "running=false,pointing=2,facing=south": { + "model": "forkcart:block/shuttle_off_ties_pointing_2", + "x": 90, + "y": 180 + }, + "running=false,pointing=2,facing=up": { + "model": "forkcart:block/shuttle_off_ties_pointing_2" + }, + "running=false,pointing=2,facing=west": { + "model": "forkcart:block/shuttle_off_ties_pointing_2", + "x": 90, + "y": 270 + }, + "running=false,pointing=3,facing=down": { + "model": "forkcart:block/shuttle_off_ties_pointing_3", + "x": 180 + }, + "running=false,pointing=3,facing=east": { + "model": "forkcart:block/shuttle_off_ties_pointing_3", + "x": 90, + "y": 90 + }, + "running=false,pointing=3,facing=north": { + "model": "forkcart:block/shuttle_off_ties_pointing_3", + "x": 90 + }, + "running=false,pointing=3,facing=south": { + "model": "forkcart:block/shuttle_off_ties_pointing_3", + "x": 90, + "y": 180 + }, + "running=false,pointing=3,facing=up": { + "model": "forkcart:block/shuttle_off_ties_pointing_3" + }, + "running=false,pointing=3,facing=west": { + "model": "forkcart:block/shuttle_off_ties_pointing_3", + "x": 90, + "y": 270 + }, + "running=true,pointing=0,facing=down": { + "model": "forkcart:block/shuttle_ties_pointing_0", + "x": 180 + }, + "running=true,pointing=0,facing=east": { + "model": "forkcart:block/shuttle_ties_pointing_0", + "x": 90, + "y": 90 + }, + "running=true,pointing=0,facing=north": { + "model": "forkcart:block/shuttle_ties_pointing_0", + "x": 90 + }, + "running=true,pointing=0,facing=south": { + "model": "forkcart:block/shuttle_ties_pointing_0", + "x": 90, + "y": 180 + }, + "running=true,pointing=0,facing=up": { + "model": "forkcart:block/shuttle_ties_pointing_0" + }, + "running=true,pointing=0,facing=west": { + "model": "forkcart:block/shuttle_ties_pointing_0", + "x": 90, + "y": 270 + }, + "running=true,pointing=1,facing=down": { + "model": "forkcart:block/shuttle_ties_pointing_1", + "x": 180 + }, + "running=true,pointing=1,facing=east": { + "model": "forkcart:block/shuttle_ties_pointing_1", + "x": 90, + "y": 90 + }, + "running=true,pointing=1,facing=north": { + "model": "forkcart:block/shuttle_ties_pointing_1", + "x": 90 + }, + "running=true,pointing=1,facing=south": { + "model": "forkcart:block/shuttle_ties_pointing_1", + "x": 90, + "y": 180 + }, + "running=true,pointing=1,facing=up": { + "model": "forkcart:block/shuttle_ties_pointing_1" + }, + "running=true,pointing=1,facing=west": { + "model": "forkcart:block/shuttle_ties_pointing_1", + "x": 90, + "y": 270 + }, + "running=true,pointing=2,facing=down": { + "model": "forkcart:block/shuttle_ties_pointing_2", + "x": 180 + }, + "running=true,pointing=2,facing=east": { + "model": "forkcart:block/shuttle_ties_pointing_2", + "x": 90, + "y": 90 + }, + "running=true,pointing=2,facing=north": { + "model": "forkcart:block/shuttle_ties_pointing_2", + "x": 90 + }, + "running=true,pointing=2,facing=south": { + "model": "forkcart:block/shuttle_ties_pointing_2", + "x": 90, + "y": 180 + }, + "running=true,pointing=2,facing=up": { + "model": "forkcart:block/shuttle_ties_pointing_2" + }, + "running=true,pointing=2,facing=west": { + "model": "forkcart:block/shuttle_ties_pointing_2", + "x": 90, + "y": 270 + }, + "running=true,pointing=3,facing=down": { + "model": "forkcart:block/shuttle_ties_pointing_3", + "x": 180 + }, + "running=true,pointing=3,facing=east": { + "model": "forkcart:block/shuttle_ties_pointing_3", + "x": 90, + "y": 90 + }, + "running=true,pointing=3,facing=north": { + "model": "forkcart:block/shuttle_ties_pointing_3", + "x": 90 + }, + "running=true,pointing=3,facing=south": { + "model": "forkcart:block/shuttle_ties_pointing_3", + "x": 90, + "y": 180 + }, + "running=true,pointing=3,facing=up": { + "model": "forkcart:block/shuttle_ties_pointing_3" + }, + "running=true,pointing=3,facing=west": { + "model": "forkcart:block/shuttle_ties_pointing_3", + "x": 90, + "y": 270 + } + } +} \ No newline at end of file diff --git a/src/client/resources/assets/forkcart/models/block/shuttle_off_ties_pointing_0.json b/src/client/resources/assets/forkcart/models/block/shuttle_off_ties_pointing_0.json new file mode 100644 index 0000000..b258274 --- /dev/null +++ b/src/client/resources/assets/forkcart/models/block/shuttle_off_ties_pointing_0.json @@ -0,0 +1,18 @@ +{ + "ambientocclusion": false, + "textures": { + "particle": "forkcart:block/shuttle_ties_off", + "rail": "forkcart:block/shuttle_ties_off" + }, + "elements": [ + { + "from": [0, 0.5, 0], + "to": [16, 0.5, 16], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 0, 8]}, + "faces": { + "up": {"uv": [0, 0, 16, 16], "texture": "#rail"}, + "down": {"uv": [0, 16, 16, 0], "texture": "#rail"} + } + } + ] +} \ No newline at end of file diff --git a/src/client/resources/assets/forkcart/models/block/shuttle_off_ties_pointing_1.json b/src/client/resources/assets/forkcart/models/block/shuttle_off_ties_pointing_1.json new file mode 100644 index 0000000..6b27460 --- /dev/null +++ b/src/client/resources/assets/forkcart/models/block/shuttle_off_ties_pointing_1.json @@ -0,0 +1,18 @@ +{ + "ambientocclusion": false, + "textures": { + "particle": "forkcart:block/shuttle_ties_off", + "rail": "forkcart:block/shuttle_ties_off" + }, + "elements": [ + { + "from": [0, 0.5, 0], + "to": [16, 0.5, 16], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 0, 8]}, + "faces": { + "up": {"uv": [0, 0, 16, 16], "rotation": 270, "texture": "#rail"}, + "down": {"uv": [0, 16, 16, 0], "rotation": 90, "texture": "#rail"} + } + } + ] +} \ No newline at end of file diff --git a/src/client/resources/assets/forkcart/models/block/shuttle_off_ties_pointing_2.json b/src/client/resources/assets/forkcart/models/block/shuttle_off_ties_pointing_2.json new file mode 100644 index 0000000..6c311cd --- /dev/null +++ b/src/client/resources/assets/forkcart/models/block/shuttle_off_ties_pointing_2.json @@ -0,0 +1,18 @@ +{ + "ambientocclusion": false, + "textures": { + "particle": "forkcart:block/shuttle_ties_off", + "rail": "forkcart:block/shuttle_ties_off" + }, + "elements": [ + { + "from": [0, 0.5, 0], + "to": [16, 0.5, 16], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 0, 8]}, + "faces": { + "up": {"uv": [0, 0, 16, 16], "rotation": 180, "texture": "#rail"}, + "down": {"uv": [0, 16, 16, 0], "rotation": 180, "texture": "#rail"} + } + } + ] +} \ No newline at end of file diff --git a/src/client/resources/assets/forkcart/models/block/shuttle_off_ties_pointing_3.json b/src/client/resources/assets/forkcart/models/block/shuttle_off_ties_pointing_3.json new file mode 100644 index 0000000..5f0fcaf --- /dev/null +++ b/src/client/resources/assets/forkcart/models/block/shuttle_off_ties_pointing_3.json @@ -0,0 +1,18 @@ +{ + "ambientocclusion": false, + "textures": { + "particle": "forkcart:block/shuttle_ties_off", + "rail": "forkcart:block/shuttle_ties_off" + }, + "elements": [ + { + "from": [0, 0.5, 0], + "to": [16, 0.5, 16], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 0, 8]}, + "faces": { + "up": {"uv": [0, 0, 16, 16], "rotation": 90, "texture": "#rail"}, + "down": {"uv": [0, 16, 16, 0], "rotation": 270, "texture": "#rail"} + } + } + ] +} \ No newline at end of file diff --git a/src/client/resources/assets/forkcart/models/block/shuttle_ties_pointing_0.json b/src/client/resources/assets/forkcart/models/block/shuttle_ties_pointing_0.json new file mode 100644 index 0000000..f6ba3bc --- /dev/null +++ b/src/client/resources/assets/forkcart/models/block/shuttle_ties_pointing_0.json @@ -0,0 +1,18 @@ +{ + "ambientocclusion": false, + "textures": { + "particle": "forkcart:block/shuttle_ties_on", + "rail": "forkcart:block/shuttle_ties_on" + }, + "elements": [ + { + "from": [0, 0.5, 0], + "to": [16, 0.5, 16], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 0, 8]}, + "faces": { + "up": {"uv": [0, 0, 16, 16], "texture": "#rail"}, + "down": {"uv": [0, 16, 16, 0], "texture": "#rail"} + } + } + ] +} \ No newline at end of file diff --git a/src/client/resources/assets/forkcart/models/block/shuttle_ties_pointing_1.json b/src/client/resources/assets/forkcart/models/block/shuttle_ties_pointing_1.json new file mode 100644 index 0000000..6da5bf3 --- /dev/null +++ b/src/client/resources/assets/forkcart/models/block/shuttle_ties_pointing_1.json @@ -0,0 +1,18 @@ +{ + "ambientocclusion": false, + "textures": { + "particle": "forkcart:block/shuttle_ties_on", + "rail": "forkcart:block/shuttle_ties_on" + }, + "elements": [ + { + "from": [0, 0.5, 0], + "to": [16, 0.5, 16], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 0, 8]}, + "faces": { + "up": {"uv": [0, 0, 16, 16], "rotation": 270, "texture": "#rail"}, + "down": {"uv": [0, 16, 16, 0], "rotation": 90, "texture": "#rail"} + } + } + ] +} \ No newline at end of file diff --git a/src/client/resources/assets/forkcart/models/block/shuttle_ties_pointing_2.json b/src/client/resources/assets/forkcart/models/block/shuttle_ties_pointing_2.json new file mode 100644 index 0000000..4d84681 --- /dev/null +++ b/src/client/resources/assets/forkcart/models/block/shuttle_ties_pointing_2.json @@ -0,0 +1,18 @@ +{ + "ambientocclusion": false, + "textures": { + "particle": "forkcart:block/shuttle_ties_on", + "rail": "forkcart:block/shuttle_ties_on" + }, + "elements": [ + { + "from": [0, 0.5, 0], + "to": [16, 0.5, 16], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 0, 8]}, + "faces": { + "up": {"uv": [0, 0, 16, 16], "rotation": 180, "texture": "#rail"}, + "down": {"uv": [0, 16, 16, 0], "rotation": 180, "texture": "#rail"} + } + } + ] +} \ No newline at end of file diff --git a/src/client/resources/assets/forkcart/models/block/shuttle_ties_pointing_3.json b/src/client/resources/assets/forkcart/models/block/shuttle_ties_pointing_3.json new file mode 100644 index 0000000..8ccfe65 --- /dev/null +++ b/src/client/resources/assets/forkcart/models/block/shuttle_ties_pointing_3.json @@ -0,0 +1,18 @@ +{ + "ambientocclusion": false, + "textures": { + "particle": "forkcart:block/shuttle_ties_on", + "rail": "forkcart:block/shuttle_ties_on" + }, + "elements": [ + { + "from": [0, 0.5, 0], + "to": [16, 0.5, 16], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 0, 8]}, + "faces": { + "up": {"uv": [0, 0, 16, 16], "rotation": 90, "texture": "#rail"}, + "down": {"uv": [0, 16, 16, 0], "rotation": 270, "texture": "#rail"} + } + } + ] +} \ No newline at end of file diff --git a/src/client/resources/assets/forkcart/models/item/brake_track.json b/src/client/resources/assets/forkcart/models/item/brake_track.json new file mode 100644 index 0000000..0578d93 --- /dev/null +++ b/src/client/resources/assets/forkcart/models/item/brake_track.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/generated", + "textures": { + "layer0": "forkcart:item/brake_track" + } +} \ No newline at end of file diff --git a/src/client/resources/assets/forkcart/models/item/shuttle_ties.json b/src/client/resources/assets/forkcart/models/item/shuttle_ties.json new file mode 100644 index 0000000..13d72a2 --- /dev/null +++ b/src/client/resources/assets/forkcart/models/item/shuttle_ties.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/generated", + "textures": { + "layer0": "forkcart:block/shuttle_ties_on" + } +} \ No newline at end of file diff --git a/src/client/resources/assets/forkcart/textures/block/shuttle_ties_off.png b/src/client/resources/assets/forkcart/textures/block/shuttle_ties_off.png new file mode 100644 index 0000000000000000000000000000000000000000..b64c5ce084fe2bb3d0140924883d4226480c3989 GIT binary patch literal 859 zcmV-h1ElEX>4Tx04R}tkv&MmKpe$iQ?)7;2dk(!WT;MdQ4z;d#UfZJZG~1HOfLO`CJjl7 zi=*ILaPVWX>fqw6tAnc`2!4P#J2)x2NQwVT3N2ziIPS;0dyl(!fKV$j)$9lZs%9C9 zXhckBRz=?{x-f)6^k76{rXEW!rqFhL-NVDzyAaQ6f9}uGr({hActqkb(+!JwgLrn+ z(mC%F2UtN;h|h^94Z0xlBiCh@-#F(T7I+$4Vl=zOv5k8!}a3)HK&{e5iP^%KDR3|whVf4K(CeUe^n zYQZC*e;c^CZff!#aJd5vKk1SoIg*#Akjnw@XY@@OVBi+$U2}VD?BnzSNKseIH^9Lm zFp;P1^)~PBZtd;gGmZX!0F7O8v6fhwUH||Akx4{BR5*>LlRrd?Uib#T$>>Y@wbOSt$g9Q+`D0!>Ve6AOtZ#(_l!Y&68d!7I=R2oY+;0eZBdiG$Dd z+z&giwm5(%5aaXfzrC z6bc2>*(^8L*GjMsAQo))eL_vjW&qo^NvO%WI)FI9NztO(H0X6Y9IOx7utpqNTk?Pj zj}hA$i^_|NX6S5Z-Z(oKNCxB#JkOgjaQm{^X@6lXEl7{Df;Sxf&7jxmVB5B2pcy(> z7njitqU1OG-W!f0>tqfdyKA^klY{l4%)!&E!-i!5vpkgRF|_67`5Z9KfpGhBKDjs5 zghe{Et_0`zwY#@R6odQQyU_E65K1fvB#%%Vm^iU4|tzQi5=q#3}#z6o8002ovPDHLkV1ic7k68c! literal 0 HcmV?d00001 diff --git a/src/client/resources/assets/forkcart/textures/block/shuttle_ties_on.png b/src/client/resources/assets/forkcart/textures/block/shuttle_ties_on.png new file mode 100644 index 0000000000000000000000000000000000000000..71fa1e50e8d683b0b3ba92e30b3e742c538c0e6e GIT binary patch literal 875 zcmV-x1C;!UP)EX>4Tx04R}tkv&MmKpe$iQ?)7;2dk(!WT;MdQ4z;d#UfZJZG~1HOfLO`CJjl7 zi=*ILaPVWX>fqw6tAnc`2!4P#J2)x2NQwVT3N2ziIPS;0dyl(!fKV$j)$9lZs%9C9 zXhckBRz=?{x-f)6^k76{rXEW!rqFhL-NVDzyAaQ6f9}uGr({hActqkb(+!JwgLrn+ z(mC%F2UtN;h|h^94Z0xlBiCh@-#F(T7I+$4Vl=zOv5k8!}a3)HK&{e5iP^%KDR3|whVf4K(CeUe^n zYQZC*e;c^CZff!#aJd5vKk1SoIg*#Akjnw@XY@@OVBi+$U2}VD?BnzSNKseIH^9Lm zFp;P1^)~PBZtd;gGmZX!0F7O8v6fhwUH||Ap-DtRR5*>Llf6m;zlU&WEt@348(V1qDH@QWy{m3ma4D5($D9W|LhKHDa=2EaFbG zX2Bw-I?UWVGxy^R^eF{kcWa?_Qx@2j3QM!!B((^M*dPGa*LPm*50YAh7yEh9Lu47uCIA1y;HB7!>bzT6laq!dvINDArt7~g5 zyHcT8ECP^Dr-{bnoS&U3-E{zg?q=7A)Ua#@Fbso`8t$nB2m++9*10JQ-fA@#ryI;< z1j|!%@_;svCihqC$2IjJ`qC$(xZ&wG@Ac2c&pVg z3_~)|gwE;li9Z8Bxy`P38cp9inS;&emi;QrBMW=a5^JY??zXv4$3Ip8-3 zCA%)?lY75vvxs`ug8<>p3jjueD$qRL!H+?8WuM9J_g|*k3|t`H-j9J_o#!vOIRHp% z5rCdQk-ZBrGCoEo_WXxILU?A&)0y2X-IIg9^#fl`=WY^;b+P~e002ovPDHLkV1k=Y Bih%$C literal 0 HcmV?d00001 diff --git a/src/client/resources/assets/forkcart/textures/brake_track.png b/src/client/resources/assets/forkcart/textures/brake_track.png new file mode 100644 index 0000000000000000000000000000000000000000..0a20bdf57dc9a76820e642b0c09685f53d325229 GIT binary patch literal 595 zcmV-Z0<8UsP)EX>4Tx04R}tkv&MmKpe$iTeTt;hZYeP$xxl_q9Tr^ibb$c+6t{Ym|Xe=O&XFE z7e~Rh;NZt%)xpJCR|i)?5c~jfc5qU3krMxx6k5c1aNLh~_a1le0B@th6r(E&D5|Na z;xQqcTNV7T=)nkr7{r*!3@wpf%)oVg-NVDzy9m#6KlkV8m-7Y#JOXi)X}U?gK|H%@ zYMl3pL#!mq#OK75I$emr&ZfnvWaJd5vJ!zsY+LDi^w@?7y&*+}0001rNklUzN%Tz(`TS7$01rgOh{*5)A~F$m-Rfvrd++BaMBN}A$!Zq0nw!vy31;^Q z-Jo10)L?#LVhPryLCwu-5Y6MX))K>bXH=P{{P7A3YLHxmVLUTP<{6_o0Dx~vbeA~b h21(6<;%)|MEX>4Tx04R}tkv&MmKpe$iQ?)7;2dk(!WT;MdQ4z;d#UfZJZG~1HOfLO`CJjl7 zi=*ILaPVWX>fqw6tAnc`2!4P#J2)x2NQwVT3N2ziIPS;0dyl(!fKV$j)$9lZs%9C9 zXhckBRz=?{x-f)6^k76{rXEW!rqFhL-NVDzyAaQ6f9}uGr({hActqkb(+!JwgLrn+ z(mC%F2UtN;h|h^94Z0xlBiCh@-#F(T7I+$4Vl=zOv5k8!}a3)HK&{e5iP^%KDR3|whVf4K(CeUe^n zYQZC*e;c^CZff!#aJd5vKk1SoIg*#Akjnw@XY@@OVBi+$U2}VD?BnzSNKseIH^9Lm zFp;P1^)~PBZtd;gGmZX!0F7O8v6fhwUH||9s7XXYR5*>LlhFypAP__+-2GUB1#Ayn zOspfn*HB0sYYn!L>p+@-Tn!wrw;s&htzW;WgF3 zW=4`N?0aAULsfaKOWS80*9LkQthYjwljx;1S8eze#MiJ< TRACK_TIES_BE = Registry.register(Registries.BLOCK_ENTITY_TYPE, id("track_ties"), - BlockEntityType.Builder.create(TrackTiesBlockEntity::new, TRACK_TIES, SWITCH_TIES, INVISIBLE_TIES).build()); + BlockEntityType.Builder.create(TrackTiesBlockEntity::new, TRACK_TIES, SWITCH_TIES, INVISIBLE_TIES, SHUTTLE_TIES).build()); public static final TrackItem TRACK = Registry.register(Registries.ITEM, id("track"), new TrackItem(new Item.Settings(), TrackItem.Type.STANDARD)); @@ -58,6 +61,8 @@ protected BlockRenderType getRenderType(BlockState state) { new TrackItem(new Item.Settings(), TrackItem.Type.CHAIN)); public static final TrackItem STATION_TRACK = Registry.register(Registries.ITEM, id("station_track"), new TrackItem(new Item.Settings(), TrackItem.Type.STATION)); + public static final TrackItem BRAKE_TRACK = Registry.register(Registries.ITEM, id("brake_track"), + new TrackItem(new Item.Settings(), TrackItem.Type.BRAKE)); public static final Identifier CHAIN_LIFT_SOUND_ID = id("entity.track_follower.lift"); public static final SoundEvent CHAIN_LIFT_SOUND = Registry.register(Registries.SOUND_EVENT, CHAIN_LIFT_SOUND_ID, @@ -69,6 +74,12 @@ protected BlockRenderType getRenderType(BlockState state) { public static final EntityType TRACK_FOLLOWER = Registry.register(Registries.ENTITY_TYPE, id("track_follower"), EntityType.Builder.create(TrackFollowerEntity::new, SpawnGroup.MISC).trackingTickInterval(2).dimensions(0.25f, 0.25f).build()); + public static final RegistryKey MOD_GROUP = Registry.registerReference(Registries.ITEM_GROUP, id("forkcart"), + FabricItemGroup.builder() + .displayName(Text.translatable("itemGroup.forkcart")) + .icon(() -> new ItemStack(TRACK)) + .build()).getKey().orElseThrow(); + public static final TagKey> CARTS = TagKey.of(RegistryKeys.ENTITY_TYPE, id("carts")); public static final TagKey TRACK_TAG = TagKey.of(RegistryKeys.ITEM, id("track")); @@ -91,14 +102,22 @@ public void onInitialize() { Text.translatable("item.forkcart.track_ties.desc").formatted(Formatting.GRAY), Text.translatable("item.forkcart.invisible_ties.desc").formatted(Formatting.GRAY) )))); + BlockItem shuttleTieItem = Registry.register(Registries.ITEM, id("shuttle_ties"), + new BlockItem(SHUTTLE_TIES, new Item.Settings() + .component(DataComponentTypes.LORE, lore( + Text.translatable("item.forkcart.track_ties.desc").formatted(Formatting.GRAY), + Text.translatable("item.forkcart.shuttle_ties.desc").formatted(Formatting.GRAY) + )))); - ItemGroupEvents.modifyEntriesEvent(ItemGroups.REDSTONE).register(entries -> { + ItemGroupEvents.modifyEntriesEvent(MOD_GROUP).register(entries -> { entries.add(tieItem.getDefaultStack()); entries.add(switchTieItem.getDefaultStack()); entries.add(invisibleTieItem.getDefaultStack()); + entries.add(shuttleTieItem.getDefaultStack()); entries.add(TRACK.getDefaultStack()); entries.add(CHAIN_TRACK.getDefaultStack()); entries.add(STATION_TRACK.getDefaultStack()); + entries.add(BRAKE_TRACK.getDefaultStack()); }); } diff --git a/src/main/java/io/github/implicitsaber/forkcart/block/ShuttleTiesBlock.java b/src/main/java/io/github/implicitsaber/forkcart/block/ShuttleTiesBlock.java new file mode 100644 index 0000000..d2b0f56 --- /dev/null +++ b/src/main/java/io/github/implicitsaber/forkcart/block/ShuttleTiesBlock.java @@ -0,0 +1,43 @@ +package io.github.implicitsaber.forkcart.block; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.entity.LivingEntity; +import net.minecraft.item.ItemStack; +import net.minecraft.state.StateManager; +import net.minecraft.state.property.BooleanProperty; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Direction; +import net.minecraft.world.World; +import org.jetbrains.annotations.Nullable; + +public class ShuttleTiesBlock extends TrackTiesBlock { + + public static final BooleanProperty RUNNING = BooleanProperty.of("running"); + + public ShuttleTiesBlock(Settings settings) { + super(settings); + setDefaultState(getDefaultState().with(FACING, Direction.UP).with(POINTING, 0).with(RUNNING, true)); + } + + @Override + protected void neighborUpdate(BlockState state, World world, BlockPos pos, Block sourceBlock, BlockPos sourcePos, boolean notify) { + boolean running = state.get(RUNNING); + boolean powered = world.isReceivingRedstonePower(pos); + if(running == powered) world.setBlockState(pos, state.with(RUNNING, !powered), Block.NOTIFY_ALL); + } + + @Override + protected void appendProperties(StateManager.Builder builder) { + super.appendProperties(builder); + builder.add(RUNNING); + } + + @Override + public void onPlaced(World world, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack itemStack) { + boolean running = state.get(RUNNING); + boolean powered = world.isReceivingRedstonePower(pos); + if(running == powered) world.setBlockState(pos, state.with(RUNNING, !powered), Block.NOTIFY_ALL); + } + +} diff --git a/src/main/java/io/github/implicitsaber/forkcart/block/TrackTiesBlockEntity.java b/src/main/java/io/github/implicitsaber/forkcart/block/TrackTiesBlockEntity.java index 018a67c..1049340 100644 --- a/src/main/java/io/github/implicitsaber/forkcart/block/TrackTiesBlockEntity.java +++ b/src/main/java/io/github/implicitsaber/forkcart/block/TrackTiesBlockEntity.java @@ -70,6 +70,7 @@ private void dropTrack(TrackItem.Type trackType) { case STANDARD -> Forkcart.TRACK; case CHAIN -> Forkcart.CHAIN_TRACK; case STATION -> Forkcart.STATION_TRACK; + case BRAKE -> Forkcart.BRAKE_TRACK; })); world.spawnEntity(item); diff --git a/src/main/java/io/github/implicitsaber/forkcart/entity/TrackFollowerEntity.java b/src/main/java/io/github/implicitsaber/forkcart/entity/TrackFollowerEntity.java index 5e7efdb..ae9710c 100644 --- a/src/main/java/io/github/implicitsaber/forkcart/entity/TrackFollowerEntity.java +++ b/src/main/java/io/github/implicitsaber/forkcart/entity/TrackFollowerEntity.java @@ -1,11 +1,13 @@ package io.github.implicitsaber.forkcart.entity; import io.github.implicitsaber.forkcart.Forkcart; +import io.github.implicitsaber.forkcart.block.ShuttleTiesBlock; import io.github.implicitsaber.forkcart.block.SwitchTiesBlock; import io.github.implicitsaber.forkcart.block.TrackTiesBlockEntity; import io.github.implicitsaber.forkcart.item.TrackItem; import io.github.implicitsaber.forkcart.util.Pose; import io.github.implicitsaber.forkcart.util.SUtil; +import io.github.implicitsaber.forkcart.util.TrackSnapUtil; import net.minecraft.block.BlockState; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityType; @@ -19,7 +21,6 @@ import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3i; import net.minecraft.world.World; -import org.jetbrains.annotations.Nullable; import org.joml.Matrix3d; import org.joml.Matrix3dc; import org.joml.Quaternionf; @@ -36,6 +37,7 @@ public class TrackFollowerEntity extends Entity { private double splinePieceProgress = 0; // t private double motionScale; // t-distance per block private double trackVelocity; + private boolean reversed = false; private final Vector3d serverPosition = new Vector3d(); private final Vector3d serverVelocity = new Vector3d(); @@ -184,25 +186,45 @@ protected void updateServer() { startE.markHasCart(); double velocity = Math.min(this.trackVelocity, MAX_SPEED); - this.splinePieceProgress += velocity * this.motionScale; + this.splinePieceProgress += velocity * this.motionScale * (this.reversed ? -1 : 1); if (this.splinePieceProgress > 1) { - this.splinePieceProgress -= 1; - - var nextE = endE.next(); - if (nextE == null) { - fullDismount(passenger, null); + if(endE.getCachedState().isOf(Forkcart.SHUTTLE_TIES) && endE.getCachedState().get(ShuttleTiesBlock.RUNNING)) { + this.reversed = !reversed; return; } else { - if(endE.getCachedState().isOf(Forkcart.SWITCH_TIES)) { - boolean switched = endE.getCachedState().get(SwitchTiesBlock.SWITCHED); - if(switched) { - fullDismount(passenger, endE.getCachedState()); - return; + this.splinePieceProgress -= 1; + var nextE = endE.next(); + if (nextE == null) { + fullDismount(passenger, endE.getCachedState(), this.endTie, false); + return; + } else { + if (endE.getCachedState().isOf(Forkcart.SWITCH_TIES)) { + boolean switched = endE.getCachedState().get(SwitchTiesBlock.SWITCHED); + if (switched) { + fullDismount(passenger, endE.getCachedState(), this.endTie, true); + return; + } } + this.setStretch(this.endTie, nextE.getPos()); + startE = endE; + endE = nextE; + } + } + } else if(this.reversed && this.splinePieceProgress < 0) { + if(startE.getCachedState().isOf(Forkcart.SHUTTLE_TIES) && startE.getCachedState().get(ShuttleTiesBlock.RUNNING)) { + this.reversed = !reversed; + return; + } else { + this.splinePieceProgress += 1; + var nextE = startE.prev(); + if (nextE == null) { + fullDismount(passenger, startE.getCachedState(), this.startTie, false); + return; + } else { + this.setStretch(nextE.getPos(), this.startTie); + endE = startE; + startE = nextE; } - this.setStretch(this.endTie, nextE.getPos()); - startE = endE; - endE = nextE; } } @@ -218,7 +240,7 @@ protected void updateServer() { this.getDataTracker().set(ORIENTATION, this.basis.getNormalizedRotation(new Quaternionf())); this.motionScale = 1 / grad.length(); - double dt = this.trackVelocity * this.motionScale; // Change in spline progress per tick + double dt = this.trackVelocity * this.motionScale * (this.reversed ? -1 : 1); // Change in spline progress per tick grad.mul(dt); // Change in position per tick (velocity) this.setVelocity(grad.x(), grad.y(), grad.z()); @@ -227,10 +249,24 @@ protected void updateServer() { Math.min(this.trackVelocity, COMFORTABLE_SPEED), Math.max(this.trackVelocity, MAX_ENERGY)); - this.dataTracker.set(CHAIN_LIFTING, trackType == TrackItem.Type.CHAIN); + this.dataTracker.set(CHAIN_LIFTING, trackType == TrackItem.Type.CHAIN && !world.isReceivingRedstonePower(startTie)); switch(trackType) { - case CHAIN -> this.trackVelocity = 0.05; - case STATION -> this.trackVelocity = world.isReceivingRedstonePower(startTie) ? 0.05 : 0; + case CHAIN -> { + boolean powered = world.isReceivingRedstonePower(startTie); + if(!powered) { + this.trackVelocity = 0.05; + this.reversed = false; + } + } + case STATION -> { + boolean powered = world.isReceivingRedstonePower(startTie); + this.trackVelocity = powered ? 0.05 : 0; + this.reversed = false; + } + case BRAKE -> { + boolean powered = world.isReceivingRedstonePower(startTie); + if(!powered) this.trackVelocity *= 0.9; + } default -> { if (this.trackVelocity > COMFORTABLE_SPEED) { double diff = this.trackVelocity - COMFORTABLE_SPEED; @@ -247,16 +283,18 @@ protected void updateServer() { } } - private void fullDismount(Entity passenger, @Nullable BlockState switchTies) { + private void fullDismount(Entity passenger, BlockState ties, BlockPos tiesPos, boolean trackSwitch) { passenger.stopRiding(); - if(switchTies != null) { - Vec3i newVel = SwitchTiesBlock.VELOCITY_MAP.getOrDefault(switchTies.get(SwitchTiesBlock.POINTING), Vec3i.ZERO); + if(trackSwitch) { + Vec3i newVel = SwitchTiesBlock.VELOCITY_MAP.getOrDefault(ties.get(SwitchTiesBlock.POINTING), Vec3i.ZERO); passenger.setVelocity(newVel.getX(), newVel.getY(), newVel.getZ()); Vec3d startPos = passenger.getPos().add(Vec3d.of(newVel)); passenger.setPos(startPos.x, startPos.y, startPos.z); } else { - Vector3d newVel = new Vector3d(0, 0, this.trackVelocity).mul(this.basis); + Vector3d newVel = new Vector3d(0, 0, this.trackVelocity).mul(this.basis).mul(this.reversed ? -1 : 1); passenger.setVelocity(newVel.x(), newVel.y(), newVel.z()); + BlockPos snapTo = TrackSnapUtil.snapToTrackOnExit(getWorld(), tiesPos, ties, reversed); + if(snapTo != null) passenger.setPos(snapTo.getX() + 0.5, snapTo.getY(), snapTo.getZ() + 0.5); } this.destroy(); } @@ -315,6 +353,7 @@ protected void readCustomDataFromNbt(NbtCompound nbt) { this.trackVelocity = nbt.getDouble("track_velocity"); this.motionScale = nbt.getDouble("motion_scale"); this.splinePieceProgress = nbt.getDouble("spline_piece_progress"); + this.reversed = nbt.getBoolean("reversed"); } @Override @@ -328,6 +367,7 @@ protected void writeCustomDataToNbt(NbtCompound nbt) { nbt.putDouble("track_velocity", this.trackVelocity); nbt.putDouble("motion_scale", this.motionScale); nbt.putDouble("spline_piece_progress", this.splinePieceProgress); + nbt.putBoolean("reversed", this.reversed); } public boolean isChainLifting() { diff --git a/src/main/java/io/github/implicitsaber/forkcart/item/TrackItem.java b/src/main/java/io/github/implicitsaber/forkcart/item/TrackItem.java index 35155e4..7803dc4 100644 --- a/src/main/java/io/github/implicitsaber/forkcart/item/TrackItem.java +++ b/src/main/java/io/github/implicitsaber/forkcart/item/TrackItem.java @@ -91,7 +91,8 @@ public enum Type { STANDARD, CHAIN, - STATION + STATION, + BRAKE } diff --git a/src/main/java/io/github/implicitsaber/forkcart/mixin/EntityMixin.java b/src/main/java/io/github/implicitsaber/forkcart/mixin/EntityMixin.java index 7e919d1..02ef599 100644 --- a/src/main/java/io/github/implicitsaber/forkcart/mixin/EntityMixin.java +++ b/src/main/java/io/github/implicitsaber/forkcart/mixin/EntityMixin.java @@ -5,9 +5,11 @@ import io.github.implicitsaber.forkcart.entity.TrackFollowerEntity; import net.minecraft.entity.Entity; import net.minecraft.util.math.Vec3d; +import net.minecraft.world.World; import org.joml.Quaternionf; import org.joml.Vector3d; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @@ -15,6 +17,9 @@ @Mixin(Entity.class) public class EntityMixin { + + @Shadow private World world; + @Inject(method = "setPosition(DDD)V", at = @At("TAIL")) private void forkcart$getOnTrackIfNecessary(double x, double y, double z, CallbackInfo info) { @@ -82,4 +87,5 @@ public class EntityMixin { vehicle = vehicle.getVehicle(); } } + } diff --git a/src/main/java/io/github/implicitsaber/forkcart/util/Pose.java b/src/main/java/io/github/implicitsaber/forkcart/util/Pose.java index a131f6e..1e58244 100644 --- a/src/main/java/io/github/implicitsaber/forkcart/util/Pose.java +++ b/src/main/java/io/github/implicitsaber/forkcart/util/Pose.java @@ -42,6 +42,16 @@ public void interpolate(Pose other, double t, double factor, Vector3d translatio } } + public Pose invertIf(boolean invert) { + if(invert) return this.invert(); + return this; + } + + public Pose invert() { + Matrix3d basis = this.basis.invert(new Matrix3d()); + return new Pose(translation, basis); + } + public static Vector3d cubicHermiteSpline(double t, double factor, Vector3dc p0, Vector3dc m0, Vector3dc p1, Vector3dc m1, Vector3d pOut, @Nullable Vector3d mOut) { var temp = new Vector3d(); diff --git a/src/main/java/io/github/implicitsaber/forkcart/util/TrackSnapUtil.java b/src/main/java/io/github/implicitsaber/forkcart/util/TrackSnapUtil.java new file mode 100644 index 0000000..ffb9978 --- /dev/null +++ b/src/main/java/io/github/implicitsaber/forkcart/util/TrackSnapUtil.java @@ -0,0 +1,101 @@ +package io.github.implicitsaber.forkcart.util; + +import io.github.implicitsaber.forkcart.block.TrackTiesBlock; +import net.minecraft.block.AbstractRailBlock; +import net.minecraft.block.BlockState; +import net.minecraft.block.enums.RailShape; +import net.minecraft.registry.tag.BlockTags; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Direction; +import net.minecraft.world.World; + +import java.util.HashMap; +import java.util.Map; + +public class TrackSnapUtil { + + public static final Map> POINTING_MAP = new HashMap<>(); + + static { + Map upMap = new HashMap<>(); + upMap.put(0, Direction.NORTH); + upMap.put(1, Direction.WEST); + upMap.put(2, Direction.SOUTH); + upMap.put(3, Direction.EAST); + Map downMap = new HashMap<>(); + downMap.put(2, Direction.NORTH); + downMap.put(1, Direction.WEST); + downMap.put(0, Direction.SOUTH); + downMap.put(3, Direction.EAST); + Map northMap = new HashMap<>(); + northMap.put(0, Direction.DOWN); + northMap.put(1, Direction.WEST); + northMap.put(2, Direction.UP); + northMap.put(3, Direction.EAST); + Map eastMap = new HashMap<>(); + eastMap.put(1, Direction.NORTH); + eastMap.put(2, Direction.UP); + eastMap.put(3, Direction.SOUTH); + eastMap.put(0, Direction.DOWN); + Map southMap = new HashMap<>(); + southMap.put(2, Direction.UP); + southMap.put(3, Direction.WEST); + southMap.put(0, Direction.DOWN); + southMap.put(1, Direction.EAST); + Map westMap = new HashMap<>(); + westMap.put(3, Direction.NORTH); + westMap.put(0, Direction.DOWN); + westMap.put(1, Direction.SOUTH); + westMap.put(2, Direction.UP); + POINTING_MAP.put(Direction.UP, upMap); + POINTING_MAP.put(Direction.DOWN, downMap); + POINTING_MAP.put(Direction.NORTH, northMap); + POINTING_MAP.put(Direction.EAST, eastMap); + POINTING_MAP.put(Direction.SOUTH, southMap); + POINTING_MAP.put(Direction.WEST, westMap); + } + + public static BlockPos snapToTrackOnExit(World w, BlockPos from, BlockState state, boolean reverse) { + Direction facing = state.get(TrackTiesBlock.FACING); + int pointing = state.get(TrackTiesBlock.POINTING); + Direction towards = POINTING_MAP.getOrDefault(facing, Map.of()).get(pointing); + if(towards == null) return null; + if(reverse) towards = towards.getOpposite(); + BlockPos fwPos = from.offset(towards); + BlockState fwState = w.getBlockState(fwPos); + if(!fwState.isIn(BlockTags.RAILS)) return null; + if(!(fwState.getBlock() instanceof AbstractRailBlock b)) return null; + if(!railShapeContainsDir(fwState.get(b.getShapeProperty()), towards)) return null; + return fwPos; + } + + public static boolean railShapeContainsDir(RailShape shape, Direction dir) { + return switch(shape) { + case NORTH_SOUTH, ASCENDING_NORTH, ASCENDING_SOUTH -> switch(dir) { + case NORTH, SOUTH -> true; + default -> false; + }; + case EAST_WEST, ASCENDING_EAST, ASCENDING_WEST -> switch(dir) { + case EAST, WEST -> true; + default -> false; + }; + case SOUTH_EAST -> switch(dir) { + case SOUTH, EAST -> true; + default -> false; + }; + case SOUTH_WEST -> switch(dir) { + case SOUTH, WEST -> true; + default -> false; + }; + case NORTH_WEST -> switch(dir) { + case NORTH, WEST -> true; + default -> false; + }; + case NORTH_EAST -> switch(dir) { + case NORTH, EAST -> true; + default -> false; + }; + }; + } + +} diff --git a/src/main/resources/assets/forkcart/lang/en_us.json b/src/main/resources/assets/forkcart/lang/en_us.json index a48bb5e..3f251d8 100644 --- a/src/main/resources/assets/forkcart/lang/en_us.json +++ b/src/main/resources/assets/forkcart/lang/en_us.json @@ -2,18 +2,22 @@ "block.forkcart.track_ties": "Track Ties", "block.forkcart.switch_ties": "Switch Ties", "block.forkcart.invisible_ties": "Invisible Ties", + "block.forkcart.shuttle_ties": "Shuttle Ties", "item.forkcart.track": "Track", "item.forkcart.chain_track": "Chain Track", "item.forkcart.station_track": "Station Track", + "item.forkcart.brake_track": "Brake Track", "item.forkcart.track_ties.desc": "Interact to rotate when placed", "item.forkcart.switch_ties.desc": "Pushes carts off to the right when powered", "item.forkcart.invisible_ties.desc": "Invisible unless holding item", + "item.forkcart.shuttle_ties.desc": "Reverses carts when not powered", "item.forkcart.track.desc": "Links two Track Ties blocks together", "item.forkcart.track.standard.desc": "Regular track, no modifiers", - "item.forkcart.track.chain.desc": "Pulls carts along the segment", + "item.forkcart.track.chain.desc": "Pulls carts along the segment if not powered", "item.forkcart.track.station.desc": "Holds carts or pushes them depending on if the first tie is powered", + "item.forkcart.track.brake.desc": "Slows carts down if not powered", "item.forkcart.track.origin": "First track selected", "item.forkcart.track.clear_hint": "Cancel first selection by using on a non-track block", @@ -27,5 +31,7 @@ "forkcart.config.forkcart_client.track_resolution.desc": "Higher values decrease performance and increase visual quality. Determines how many segments tracks will be cut into when rendering, with fewer segments making tracks appear jagged. Does not affect minecart movement along tracks.", "forkcart.config.forkcart_client.track_render_distance.desc": "When the origin track tie block is this many chunks away from you, its track will stop rendering.", - "tag.item.forkcart.track": "Trackx" + "tag.item.forkcart.track": "Track", + + "itemGroup.forkcart": "Forkcart" } \ No newline at end of file diff --git a/src/main/resources/data/forkcart/loot_table/blocks/shuttle_ties.json b/src/main/resources/data/forkcart/loot_table/blocks/shuttle_ties.json new file mode 100644 index 0000000..86fb031 --- /dev/null +++ b/src/main/resources/data/forkcart/loot_table/blocks/shuttle_ties.json @@ -0,0 +1,21 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "bonus_rolls": 0.0, + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ], + "entries": [ + { + "type": "minecraft:item", + "name": "forkcart:shuttle_ties" + } + ], + "rolls": 1.0 + } + ], + "random_sequence": "minecraft:blocks/rail" +} \ No newline at end of file diff --git a/src/main/resources/data/forkcart/recipe/brake_track.json b/src/main/resources/data/forkcart/recipe/brake_track.json new file mode 100644 index 0000000..a547497 --- /dev/null +++ b/src/main/resources/data/forkcart/recipe/brake_track.json @@ -0,0 +1,24 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "misc", + "key": { + "A": { + "item": "minecraft:rail" + }, + "B": { + "item": "minecraft:iron_ingot" + }, + "C": { + "tag": "minecraft:wool" + } + }, + "pattern": [ + " B ", + "CAC", + " B " + ], + "result": { + "count": 4, + "id": "forkcart:brake_track" + } +} \ No newline at end of file diff --git a/src/main/resources/data/forkcart/recipe/shuttle_ties.json b/src/main/resources/data/forkcart/recipe/shuttle_ties.json new file mode 100644 index 0000000..3144dde --- /dev/null +++ b/src/main/resources/data/forkcart/recipe/shuttle_ties.json @@ -0,0 +1,27 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "misc", + "key": { + "A": { + "item": "minecraft:stick" + }, + "B": { + "tag": "minecraft:wooden_slabs" + }, + "C": { + "item": "minecraft:diamond" + }, + "D": { + "item": "minecraft:redstone" + } + }, + "pattern": [ + "BDB", + "BAB", + "BCB" + ], + "result": { + "count": 8, + "id": "forkcart:shuttle_ties" + } +} \ No newline at end of file diff --git a/src/main/resources/data/forkcart/tags/item/track.json b/src/main/resources/data/forkcart/tags/item/track.json index 3312aae..d6ce9dd 100644 --- a/src/main/resources/data/forkcart/tags/item/track.json +++ b/src/main/resources/data/forkcart/tags/item/track.json @@ -2,6 +2,7 @@ "values": [ "forkcart:track", "forkcart:chain_track", - "forkcart:station_track" + "forkcart:station_track", + "forkcart:brake_track" ] } \ No newline at end of file diff --git a/src/main/resources/data/minecraft/tags/block/mineable/pickaxe.json b/src/main/resources/data/minecraft/tags/block/mineable/pickaxe.json index c933be4..0261b12 100644 --- a/src/main/resources/data/minecraft/tags/block/mineable/pickaxe.json +++ b/src/main/resources/data/minecraft/tags/block/mineable/pickaxe.json @@ -1,5 +1,8 @@ { "values": [ - "forkcart:track_ties" + "forkcart:track_ties", + "forkcart:switch_ties", + "forkcart:invisible_ties", + "forkcart:shuttle_ties" ] } \ No newline at end of file