Bezier Cartography

- Curved tracks now create and manage a number of fake blocks for mapping purposes
This commit is contained in:
simibubi 2022-05-31 18:36:11 +02:00
parent b0cca3b970
commit 5a1e23fca4
26 changed files with 286 additions and 36 deletions

View file

@ -547,23 +547,23 @@ bf2b0310500213ff853c748c236eb5d01f61658e assets/create/blockstates/yellow_toolbo
6801fa1f466f172700e573e5b8ee8ee5f9ca4583 assets/create/blockstates/yellow_valve_handle.json
7f39521b211441f5c3e06d60c5978cebe16cacfb assets/create/blockstates/zinc_block.json
b7181bcd8182b2f17088e5aa881f374c9c65470c assets/create/blockstates/zinc_ore.json
bd853a35ced26255a1b1666a559f0570cbab99a0 assets/create/lang/en_ud.json
b2a8bf6cb18d2362190a277ae538f426e493cb0e assets/create/lang/en_us.json
eb1a1d939fe51ec03c2c88c639f53ca45f2dd7ac assets/create/lang/unfinished/de_de.json
41c1ad17dabcfbd151859aebfb0b3825a286ee52 assets/create/lang/unfinished/es_cl.json
fa9dd43a045b08823f5bcdb18052ba2b3c04180b assets/create/lang/unfinished/es_es.json
20840b45485aad392e6a8ec1edd14b55154aa52b assets/create/lang/unfinished/fr_fr.json
e6dc1bc75c11c24d925815f40b7e421034d06194 assets/create/lang/unfinished/it_it.json
b48f4ee1fefcca0dd6d3569f5a2a81e6e28e5d82 assets/create/lang/unfinished/ja_jp.json
eb1b2cf55a68df5b2164d430e81f580aafd95833 assets/create/lang/unfinished/ko_kr.json
f8dfc3aeee8a051e22a14a4d5c9f715750b173bf assets/create/lang/unfinished/nl_nl.json
a4588fb0aa2737ce5bd6d5b52918780c49dcca08 assets/create/lang/unfinished/pl_pl.json
58745b900154479111ef09e0565c730b4d743cee assets/create/lang/unfinished/pt_br.json
2f5d8f9fbf2df5b774b3345459818525da26f60e assets/create/lang/unfinished/pt_pt.json
55763c21bc6f34442ae41aed5090baa94730c655 assets/create/lang/unfinished/ro_ro.json
3fa42e6cfb189e0da57ad91e2077c70ad1dedc0c assets/create/lang/unfinished/ru_ru.json
dbf365dba14345250099af4424bc85b204b2c504 assets/create/lang/unfinished/zh_cn.json
6673da4c6834932e22a1e160b871baecab496038 assets/create/lang/unfinished/zh_tw.json
56b96685af1ed9a9ff80d5e7313890049612d52c assets/create/lang/en_ud.json
7a9fdb40ae622b30274a5fa4fe59185dc2540433 assets/create/lang/en_us.json
462d37dd36d00b67cfc0cd7b19656fe2d523ea3d assets/create/lang/unfinished/de_de.json
7a50456a2d324b70a0619aa3ab36e84f7bb87527 assets/create/lang/unfinished/es_cl.json
5da9750275f057245b66dd818f1aa10f43441a0d assets/create/lang/unfinished/es_es.json
a99e29d561a3be6078a41d8313abc2ce9d8a30f3 assets/create/lang/unfinished/fr_fr.json
47da035352575e42112324fc467803c668ea5ae6 assets/create/lang/unfinished/it_it.json
9795487b3310239b768258a70470b48f1538f8f6 assets/create/lang/unfinished/ja_jp.json
ca943f233d5a79ea0cd761c75f206b0061e1ab4d assets/create/lang/unfinished/ko_kr.json
b5bb93c72ca56a427f409f62a748ea036d4bd10c assets/create/lang/unfinished/nl_nl.json
9542fbea4bf253ffedaf0a1ded6585730bf90ec2 assets/create/lang/unfinished/pl_pl.json
3b45e954f1ca7450a79e801d9f3f427b2f1a8487 assets/create/lang/unfinished/pt_br.json
8a659d3c5a06a37d03f8af994379ee8d56ab2e06 assets/create/lang/unfinished/pt_pt.json
0e91d1338f1b1c4c69744d94835cf1b11a74ed5c assets/create/lang/unfinished/ro_ro.json
1fbe05e657d442a15bb63326d3cc3bdbaa94f3a0 assets/create/lang/unfinished/ru_ru.json
a5df475eaa2ebf15a5a40f48d0aa51e4550ec71d assets/create/lang/unfinished/zh_cn.json
56f8d0c160e88e9e98778130ab4a10c64675b772 assets/create/lang/unfinished/zh_tw.json
487a511a01b2a4531fb672f917922312db78f958 assets/create/models/block/acacia_window.json
b48060cba1a382f373a05bf0039054053eccf076 assets/create/models/block/acacia_window_pane_noside.json
3066db1bf03cffa1a9c7fbacf47ae586632f4eb3 assets/create/models/block/acacia_window_pane_noside_alt.json
@ -1020,6 +1020,7 @@ e63e6e0bd97cd73953a6079ff3005b33ace5a648 assets/create/models/block/exposed_copp
67e3bfb61e3237a2cf863189411fdbf4cf898638 assets/create/models/block/exposed_copper_tile_stairs_inner.json
c833caddf850cbec1f7b590b064773b8c64feeb1 assets/create/models/block/exposed_copper_tile_stairs_outer.json
d23e75ad96bb2e670f88d8c7361dfbfc9a2e3b2c assets/create/models/block/exposed_copper_tiles.json
7c36ca6b27a15a866df7b717a17d0025dc1407a3 assets/create/models/block/fake_track.json
254807760fd69eb103e89244f758525dd3dc40e3 assets/create/models/block/fluid_pipe/d_x.json
4eff30466cd0f81ea1cf7e6d99de7d24848afc20 assets/create/models/block/fluid_pipe/d_y.json
d33d12a8d8c8b7adcf0f3a3e69f4be14dfb74727 assets/create/models/block/fluid_pipe/d_z.json
@ -3548,6 +3549,7 @@ d89c4d7d212091b1aee2db2b0dedd252d4c301b9 data/create/loot_tables/blocks/exposed_
d638deb1f6b22026b4b971f85948ce20c5688e7d data/create/loot_tables/blocks/exposed_copper_tile_slab.json
bcd1139bc46d9c740e10e67246f8f7f67f909165 data/create/loot_tables/blocks/exposed_copper_tile_stairs.json
5e1d740db92d21bc89db5f62c687ce29af01ac88 data/create/loot_tables/blocks/exposed_copper_tiles.json
5c1df8443043b3fe3b665dba348e2ff188bcbe31 data/create/loot_tables/blocks/fake_track.json
b4df9a8b28f29587e75ffe11ca26d85ddbe926da data/create/loot_tables/blocks/fluid_pipe.json
5e781289562aad213b5528aa4974b811d7f04e97 data/create/loot_tables/blocks/fluid_tank.json
33e579946fc8350773eadccf000abe0b975f1483 data/create/loot_tables/blocks/fluid_valve.json

View file

@ -209,6 +209,7 @@
"block.create.exposed_copper_tile_slab": "q\u0250\u05DFS \u01DD\u05DF\u0131\u27D8 \u0279\u01DDddo\u0186 p\u01DDsodx\u018E",
"block.create.exposed_copper_tile_stairs": "s\u0279\u0131\u0250\u0287S \u01DD\u05DF\u0131\u27D8 \u0279\u01DDddo\u0186 p\u01DDsodx\u018E",
"block.create.exposed_copper_tiles": "s\u01DD\u05DF\u0131\u27D8 \u0279\u01DDddo\u0186 p\u01DDsodx\u018E",
"block.create.fake_track": "sd\u0250W \u0279o\u025F \u0279\u01DD\u029E\u0279\u0250W \u029E\u0254\u0250\u0279\u27D8",
"block.create.fluid_pipe": "\u01DDd\u0131\u0500 p\u0131n\u05DF\u2132",
"block.create.fluid_tank": "\u029Eu\u0250\u27D8 p\u0131n\u05DF\u2132",
"block.create.fluid_valve": "\u01DD\u028C\u05DF\u0250\u039B p\u0131n\u05DF\u2132",

View file

@ -212,6 +212,7 @@
"block.create.exposed_copper_tile_slab": "Exposed Copper Tile Slab",
"block.create.exposed_copper_tile_stairs": "Exposed Copper Tile Stairs",
"block.create.exposed_copper_tiles": "Exposed Copper Tiles",
"block.create.fake_track": "Track Marker for Maps",
"block.create.fluid_pipe": "Fluid Pipe",
"block.create.fluid_tank": "Fluid Tank",
"block.create.fluid_valve": "Fluid Valve",

View file

@ -1,5 +1,5 @@
{
"_": "Missing Localizations: 930",
"_": "Missing Localizations: 931",
"_": "->------------------------] Game Elements [------------------------<-",
@ -213,6 +213,7 @@
"block.create.exposed_copper_tile_slab": "Angelaufene Kupferfliesenstufe",
"block.create.exposed_copper_tile_stairs": "Angelaufene Kupferfliesentreppe",
"block.create.exposed_copper_tiles": "Angelaufene Kupferfliesen",
"block.create.fake_track": "UNLOCALIZED: Track Marker for Maps",
"block.create.fluid_pipe": "Flüssigkeitsrohr",
"block.create.fluid_tank": "Flüssigkeitstank",
"block.create.fluid_valve": "Flüssigkeitsventil",

View file

@ -1,5 +1,5 @@
{
"_": "Missing Localizations: 580",
"_": "Missing Localizations: 581",
"_": "->------------------------] Game Elements [------------------------<-",
@ -213,6 +213,7 @@
"block.create.exposed_copper_tile_slab": "UNLOCALIZED: Exposed Copper Tile Slab",
"block.create.exposed_copper_tile_stairs": "UNLOCALIZED: Exposed Copper Tile Stairs",
"block.create.exposed_copper_tiles": "UNLOCALIZED: Exposed Copper Tiles",
"block.create.fake_track": "UNLOCALIZED: Track Marker for Maps",
"block.create.fluid_pipe": "Tubería de Fluidos",
"block.create.fluid_tank": "Tanque de Fluidos",
"block.create.fluid_valve": "Válvula de Fluidos",

View file

@ -1,5 +1,5 @@
{
"_": "Missing Localizations: 244",
"_": "Missing Localizations: 245",
"_": "->------------------------] Game Elements [------------------------<-",
@ -213,6 +213,7 @@
"block.create.exposed_copper_tile_slab": "Losa de baldosas de cobre expuesto",
"block.create.exposed_copper_tile_stairs": "Escaleras de baldosas de cobre expuesto",
"block.create.exposed_copper_tiles": "Blooque de baldosas de cobre expuesto",
"block.create.fake_track": "UNLOCALIZED: Track Marker for Maps",
"block.create.fluid_pipe": "Tubería de fluidos de cobre",
"block.create.fluid_tank": "Depósito de fluidos",
"block.create.fluid_valve": "Válvula de fluidos",

View file

@ -1,5 +1,5 @@
{
"_": "Missing Localizations: 1818",
"_": "Missing Localizations: 1819",
"_": "->------------------------] Game Elements [------------------------<-",
@ -213,6 +213,7 @@
"block.create.exposed_copper_tile_slab": "UNLOCALIZED: Exposed Copper Tile Slab",
"block.create.exposed_copper_tile_stairs": "UNLOCALIZED: Exposed Copper Tile Stairs",
"block.create.exposed_copper_tiles": "UNLOCALIZED: Exposed Copper Tiles",
"block.create.fake_track": "UNLOCALIZED: Track Marker for Maps",
"block.create.fluid_pipe": "UNLOCALIZED: Fluid Pipe",
"block.create.fluid_tank": "UNLOCALIZED: Fluid Tank",
"block.create.fluid_valve": "UNLOCALIZED: Fluid Valve",

View file

@ -1,5 +1,5 @@
{
"_": "Missing Localizations: 1507",
"_": "Missing Localizations: 1508",
"_": "->------------------------] Game Elements [------------------------<-",
@ -213,6 +213,7 @@
"block.create.exposed_copper_tile_slab": "UNLOCALIZED: Exposed Copper Tile Slab",
"block.create.exposed_copper_tile_stairs": "UNLOCALIZED: Exposed Copper Tile Stairs",
"block.create.exposed_copper_tiles": "UNLOCALIZED: Exposed Copper Tiles",
"block.create.fake_track": "UNLOCALIZED: Track Marker for Maps",
"block.create.fluid_pipe": "Tubo per fluidi",
"block.create.fluid_tank": "Serbatoio per fluidi",
"block.create.fluid_valve": "Valvola per fluidi",

View file

@ -1,5 +1,5 @@
{
"_": "Missing Localizations: 246",
"_": "Missing Localizations: 247",
"_": "->------------------------] Game Elements [------------------------<-",
@ -213,6 +213,7 @@
"block.create.exposed_copper_tile_slab": "風化した銅タイルのハーフブロック",
"block.create.exposed_copper_tile_stairs": "風化した銅タイルの階段",
"block.create.exposed_copper_tiles": "風化した銅タイル",
"block.create.fake_track": "UNLOCALIZED: Track Marker for Maps",
"block.create.fluid_pipe": "液体パイプ",
"block.create.fluid_tank": "液体タンク",
"block.create.fluid_valve": "液体バルブ",

View file

@ -1,5 +1,5 @@
{
"_": "Missing Localizations: 246",
"_": "Missing Localizations: 247",
"_": "->------------------------] Game Elements [------------------------<-",
@ -213,6 +213,7 @@
"block.create.exposed_copper_tile_slab": "약간 녹슨 구리 타일 반 블록",
"block.create.exposed_copper_tile_stairs": "약간 녹슨 구리 타일 계단",
"block.create.exposed_copper_tiles": "약간 녹슨 구리 타일",
"block.create.fake_track": "UNLOCALIZED: Track Marker for Maps",
"block.create.fluid_pipe": "액체 파이프",
"block.create.fluid_tank": "액체 탱크",
"block.create.fluid_valve": "액체 밸브",

View file

@ -1,5 +1,5 @@
{
"_": "Missing Localizations: 2170",
"_": "Missing Localizations: 2171",
"_": "->------------------------] Game Elements [------------------------<-",
@ -213,6 +213,7 @@
"block.create.exposed_copper_tile_slab": "UNLOCALIZED: Exposed Copper Tile Slab",
"block.create.exposed_copper_tile_stairs": "UNLOCALIZED: Exposed Copper Tile Stairs",
"block.create.exposed_copper_tiles": "UNLOCALIZED: Exposed Copper Tiles",
"block.create.fake_track": "UNLOCALIZED: Track Marker for Maps",
"block.create.fluid_pipe": "UNLOCALIZED: Fluid Pipe",
"block.create.fluid_tank": "UNLOCALIZED: Fluid Tank",
"block.create.fluid_valve": "UNLOCALIZED: Fluid Valve",

View file

@ -1,5 +1,5 @@
{
"_": "Missing Localizations: 619",
"_": "Missing Localizations: 620",
"_": "->------------------------] Game Elements [------------------------<-",
@ -213,6 +213,7 @@
"block.create.exposed_copper_tile_slab": "UNLOCALIZED: Exposed Copper Tile Slab",
"block.create.exposed_copper_tile_stairs": "UNLOCALIZED: Exposed Copper Tile Stairs",
"block.create.exposed_copper_tiles": "UNLOCALIZED: Exposed Copper Tiles",
"block.create.fake_track": "UNLOCALIZED: Track Marker for Maps",
"block.create.fluid_pipe": "Rura",
"block.create.fluid_tank": "Zbiornik",
"block.create.fluid_valve": "Zawór",

View file

@ -1,5 +1,5 @@
{
"_": "Missing Localizations: 1114",
"_": "Missing Localizations: 1115",
"_": "->------------------------] Game Elements [------------------------<-",
@ -213,6 +213,7 @@
"block.create.exposed_copper_tile_slab": "Laje de ladrilho de cobre exposta",
"block.create.exposed_copper_tile_stairs": "Escada de ladrilho de cobre exposta",
"block.create.exposed_copper_tiles": "Ladrilho de cobre exposto",
"block.create.fake_track": "UNLOCALIZED: Track Marker for Maps",
"block.create.fluid_pipe": "Cano de Fluido",
"block.create.fluid_tank": "Tanque de fluido",
"block.create.fluid_valve": "Válvula",

View file

@ -1,5 +1,5 @@
{
"_": "Missing Localizations: 1792",
"_": "Missing Localizations: 1793",
"_": "->------------------------] Game Elements [------------------------<-",
@ -213,6 +213,7 @@
"block.create.exposed_copper_tile_slab": "UNLOCALIZED: Exposed Copper Tile Slab",
"block.create.exposed_copper_tile_stairs": "UNLOCALIZED: Exposed Copper Tile Stairs",
"block.create.exposed_copper_tiles": "UNLOCALIZED: Exposed Copper Tiles",
"block.create.fake_track": "UNLOCALIZED: Track Marker for Maps",
"block.create.fluid_pipe": "Cano de Fluido",
"block.create.fluid_tank": "Tanque de fluido",
"block.create.fluid_valve": "Válvula de fluido",

View file

@ -1,5 +1,5 @@
{
"_": "Missing Localizations: 247",
"_": "Missing Localizations: 248",
"_": "->------------------------] Game Elements [------------------------<-",
@ -213,6 +213,7 @@
"block.create.exposed_copper_tile_slab": "Lespede De Țiglă De Cupru Expusă",
"block.create.exposed_copper_tile_stairs": "Scări De Țiglă De Cupru Expuse",
"block.create.exposed_copper_tiles": "Țigle De Cupru Expuse",
"block.create.fake_track": "UNLOCALIZED: Track Marker for Maps",
"block.create.fluid_pipe": "Conductă De Fluide",
"block.create.fluid_tank": "Rezervor De Fluid",
"block.create.fluid_valve": "Supapă De Fluid",

View file

@ -1,5 +1,5 @@
{
"_": "Missing Localizations: 624",
"_": "Missing Localizations: 625",
"_": "->------------------------] Game Elements [------------------------<-",
@ -213,6 +213,7 @@
"block.create.exposed_copper_tile_slab": "UNLOCALIZED: Exposed Copper Tile Slab",
"block.create.exposed_copper_tile_stairs": "UNLOCALIZED: Exposed Copper Tile Stairs",
"block.create.exposed_copper_tiles": "UNLOCALIZED: Exposed Copper Tiles",
"block.create.fake_track": "UNLOCALIZED: Track Marker for Maps",
"block.create.fluid_pipe": "Жидкостная труба",
"block.create.fluid_tank": "Жидкостный бак",
"block.create.fluid_valve": "Жидкостный клапан",

View file

@ -1,5 +1,5 @@
{
"_": "Missing Localizations: 244",
"_": "Missing Localizations: 245",
"_": "->------------------------] Game Elements [------------------------<-",
@ -213,6 +213,7 @@
"block.create.exposed_copper_tile_slab": "斑驳的铜瓦台阶",
"block.create.exposed_copper_tile_stairs": "斑驳的铜瓦楼梯",
"block.create.exposed_copper_tiles": "斑驳的铜瓦",
"block.create.fake_track": "UNLOCALIZED: Track Marker for Maps",
"block.create.fluid_pipe": "流体管道",
"block.create.fluid_tank": "流体储罐",
"block.create.fluid_valve": "流体阀门",

View file

@ -1,5 +1,5 @@
{
"_": "Missing Localizations: 638",
"_": "Missing Localizations: 639",
"_": "->------------------------] Game Elements [------------------------<-",
@ -213,6 +213,7 @@
"block.create.exposed_copper_tile_slab": "UNLOCALIZED: Exposed Copper Tile Slab",
"block.create.exposed_copper_tile_stairs": "UNLOCALIZED: Exposed Copper Tile Stairs",
"block.create.exposed_copper_tiles": "UNLOCALIZED: Exposed Copper Tiles",
"block.create.fake_track": "UNLOCALIZED: Track Marker for Maps",
"block.create.fluid_pipe": "液體管道",
"block.create.fluid_tank": "液體儲存罐",
"block.create.fluid_valve": "液體閥門",

View file

@ -0,0 +1,3 @@
{
"parent": "minecraft:block/air"
}

View file

@ -0,0 +1,20 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1.0,
"bonus_rolls": 0.0,
"entries": [
{
"type": "minecraft:item",
"name": "minecraft:air"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View file

@ -195,6 +195,7 @@ import com.simibubi.create.content.logistics.trains.management.display.FlapDispl
import com.simibubi.create.content.logistics.trains.management.edgePoint.TrackTargetingBlockItem;
import com.simibubi.create.content.logistics.trains.management.edgePoint.signal.SignalBlock;
import com.simibubi.create.content.logistics.trains.management.edgePoint.station.StationBlock;
import com.simibubi.create.content.logistics.trains.track.FakeTrackBlock;
import com.simibubi.create.content.logistics.trains.track.StandardBogeyBlock;
import com.simibubi.create.content.logistics.trains.track.TrackBlock;
import com.simibubi.create.content.logistics.trains.track.TrackBlockItem;
@ -1476,6 +1477,16 @@ public class AllBlocks {
.build()
.register();
public static final BlockEntry<FakeTrackBlock> FAKE_TRACK = REGISTRATE.block("fake_track", FakeTrackBlock::new)
.initialProperties((new Material.Builder(MaterialColor.METAL)).noCollider()
.nonSolid()
.replaceable()
.build())
.blockstate((c, p) -> p.models()
.withExistingParent(c.getName(), p.mcLoc("block/air")))
.lang("Track Marker for Maps")
.register();
public static final BlockEntry<CasingBlock> RAILWAY_CASING = REGISTRATE.block("railway_casing", CasingBlock::new)
.transform(BuilderTransformers.layeredCasing(() -> AllSpriteShifts.RAILWAY_CASING_SIDE,
() -> AllSpriteShifts.RAILWAY_CASING))

View file

@ -182,6 +182,7 @@ import com.simibubi.create.content.logistics.trains.management.edgePoint.signal.
import com.simibubi.create.content.logistics.trains.management.edgePoint.signal.SignalTileEntity;
import com.simibubi.create.content.logistics.trains.management.edgePoint.station.StationRenderer;
import com.simibubi.create.content.logistics.trains.management.edgePoint.station.StationTileEntity;
import com.simibubi.create.content.logistics.trains.track.FakeTrackTileEntity;
import com.simibubi.create.content.logistics.trains.track.StandardBogeyTileEntity;
import com.simibubi.create.content.logistics.trains.track.TrackInstance;
import com.simibubi.create.content.logistics.trains.track.TrackRenderer;
@ -767,6 +768,11 @@ public class AllTileEntities {
.renderer(() -> TrackRenderer::new)
.validBlocks(AllBlocks.TRACK)
.register();
public static final BlockEntityEntry<FakeTrackTileEntity> FAKE_TRACK = Create.registrate()
.tileEntity("fake_track", FakeTrackTileEntity::new)
.validBlocks(AllBlocks.FAKE_TRACK)
.register();
public static final BlockEntityEntry<StandardBogeyTileEntity> BOGEY = Create.registrate()
.tileEntity("bogey", StandardBogeyTileEntity::new)

View file

@ -0,0 +1,54 @@
package com.simibubi.create.content.logistics.trains.track;
import java.util.Random;
import com.simibubi.create.AllTileEntities;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.EntityBlock;
import net.minecraft.world.level.block.RenderShape;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
public class FakeTrackBlock extends Block implements EntityBlock {
public FakeTrackBlock(Properties p_49795_) {
super(p_49795_.randomTicks()
.noCollission()
.noOcclusion());
}
@Override
public VoxelShape getShape(BlockState pState, BlockGetter pLevel, BlockPos pPos, CollisionContext pContext) {
return Shapes.empty();
}
@Override
public RenderShape getRenderShape(BlockState pState) {
return RenderShape.ENTITYBLOCK_ANIMATED;
}
@Override
public void randomTick(BlockState pState, ServerLevel pLevel, BlockPos pPos, Random pRandom) {
if (pLevel.getBlockEntity(pPos) instanceof FakeTrackTileEntity te)
te.randomTick();
}
public static void keepAlive(LevelAccessor level, BlockPos pos) {
if (level.getBlockEntity(pos) instanceof FakeTrackTileEntity te)
te.keepAlive();
}
@Override
public BlockEntity newBlockEntity(BlockPos pPos, BlockState pState) {
return AllTileEntities.FAKE_TRACK.create(pPos, pState);
}
}

View file

@ -0,0 +1,30 @@
package com.simibubi.create.content.logistics.trains.track;
import com.simibubi.create.foundation.tileEntity.SyncedTileEntity;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
public class FakeTrackTileEntity extends SyncedTileEntity {
int keepAlive;
public FakeTrackTileEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
super(type, pos, state);
keepAlive();
}
public void randomTick() {
keepAlive--;
if (keepAlive > 0)
return;
level.removeBlock(worldPosition, false);
}
public void keepAlive() {
keepAlive = 3;
}
}

View file

@ -39,6 +39,7 @@ import com.simibubi.create.content.logistics.trains.management.edgePoint.station
import com.simibubi.create.content.schematics.ISpecialBlockItemRequirement;
import com.simibubi.create.content.schematics.ItemRequirement;
import com.simibubi.create.content.schematics.ItemRequirement.ItemUseType;
import com.simibubi.create.foundation.block.ITE;
import com.simibubi.create.foundation.block.ProperWaterloggedBlock;
import com.simibubi.create.foundation.block.render.DestroyProgressRenderingHandler;
import com.simibubi.create.foundation.block.render.ReducedDestroyEffects;
@ -74,11 +75,11 @@ import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.EntityBlock;
import net.minecraft.world.level.block.Mirror;
import net.minecraft.world.level.block.NetherPortalBlock;
import net.minecraft.world.level.block.Rotation;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition.Builder;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
@ -101,7 +102,7 @@ import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.client.IBlockRenderProperties;
public class TrackBlock extends Block
implements EntityBlock, IWrenchable, ITrackBlock, ISpecialBlockItemRequirement, ProperWaterloggedBlock {
implements ITE<TrackTileEntity>, IWrenchable, ITrackBlock, ISpecialBlockItemRequirement, ProperWaterloggedBlock {
public static final EnumProperty<TrackShape> SHAPE = EnumProperty.create("shape", TrackShape.class);
public static final BooleanProperty HAS_TE = BooleanProperty.create("turn");
@ -535,6 +536,16 @@ public class TrackBlock extends Block
return null;
return AllTileEntities.TRACK.create(p_153215_, state);
}
@Override
public Class<TrackTileEntity> getTileEntityClass() {
return TrackTileEntity.class;
}
@Override
public BlockEntityType<? extends TrackTileEntity> getTileEntityType() {
return AllTileEntities.TRACK.get();
}
@Override
public Vec3 getUpNormal(BlockGetter world, BlockPos pos, BlockState state) {

View file

@ -20,6 +20,7 @@ import com.simibubi.create.foundation.tileEntity.RemoveTileEntityPacket;
import com.simibubi.create.foundation.tileEntity.SmartTileEntity;
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
import com.simibubi.create.foundation.utility.Pair;
import com.simibubi.create.foundation.utility.VecHelper;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction.Axis;
@ -31,6 +32,7 @@ import net.minecraft.nbt.Tag;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.Mth;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType;
@ -53,6 +55,7 @@ public class TrackTileEntity extends SmartTileEntity implements ITransformableTE
super(type, pos, state);
connections = new HashMap<>();
connectionsValidated = false;
setLazyTickRate(100);
}
public Map<BlockPos, BezierConnection> getConnections() {
@ -68,6 +71,13 @@ public class TrackTileEntity extends SmartTileEntity implements ITransformableTE
registerToCurveInteraction();
}
@Override
public void lazyTick() {
for (BezierConnection connection : connections.values())
if (connection.isPrimary())
manageFakeTracksAlong(connection, false);
}
private void validateConnections() {
Set<BlockPos> invalid = new HashSet<>();
@ -81,7 +91,7 @@ public class TrackTileEntity extends SmartTileEntity implements ITransformableTE
}
BlockState blockState = level.getBlockState(key);
if (blockState.getBlock()instanceof ITrackBlock trackBlock && !blockState.getValue(TrackBlock.HAS_TE))
if (blockState.getBlock() instanceof ITrackBlock trackBlock && !blockState.getValue(TrackBlock.HAS_TE))
for (Vec3 v : trackBlock.getTrackAxes(level, key, blockState)) {
Vec3 bcEndAxis = bc.axes.getSecond();
if (v.distanceTo(bcEndAxis) < 1 / 1024f || v.distanceTo(bcEndAxis.scale(-1)) < 1 / 1024f)
@ -107,11 +117,18 @@ public class TrackTileEntity extends SmartTileEntity implements ITransformableTE
connections.put(connection.getKey(), connection);
level.scheduleTick(worldPosition, getBlockState().getBlock(), 1);
notifyUpdate();
if (connection.isPrimary())
manageFakeTracksAlong(connection, false);
}
public void removeConnection(BlockPos target) {
connections.remove(target);
BezierConnection removed = connections.remove(target);
notifyUpdate();
if (removed != null)
manageFakeTracksAlong(removed, true);
if (!connections.isEmpty() || getBlockState().getOptionalValue(TrackBlock.SHAPE)
.orElse(TrackShape.NONE)
.isPortal())
@ -263,6 +280,9 @@ public class TrackTileEntity extends SmartTileEntity implements ITransformableTE
@Override
protected void setRemovedNotDueToChunkUnload() {
super.setRemovedNotDueToChunkUnload();
for (BezierConnection connection : connections.values())
manageFakeTracksAlong(connection, true);
if (boundLocation != null && level instanceof ServerLevel) {
ServerLevel otherLevel = level.getServer()
@ -294,4 +314,80 @@ public class TrackTileEntity extends SmartTileEntity implements ITransformableTE
.remove(worldPosition);
}
public void manageFakeTracksAlong(BezierConnection bc, boolean remove) {
Map<Pair<Integer, Integer>, Double> yLevels = new HashMap<>();
BlockPos tePosition = bc.tePositions.getFirst();
Vec3 end1 = bc.starts.getFirst()
.subtract(Vec3.atLowerCornerOf(tePosition))
.add(0, 3 / 16f, 0);
Vec3 end2 = bc.starts.getSecond()
.subtract(Vec3.atLowerCornerOf(tePosition))
.add(0, 3 / 16f, 0);
Vec3 axis1 = bc.axes.getFirst();
Vec3 axis2 = bc.axes.getSecond();
double handleLength = bc.getHandleLength();
Vec3 finish1 = axis1.scale(handleLength)
.add(end1);
Vec3 finish2 = axis2.scale(handleLength)
.add(end2);
Vec3 faceNormal1 = bc.normals.getFirst();
Vec3 faceNormal2 = bc.normals.getSecond();
int segCount = bc.getSegmentCount();
float[] lut = bc.getStepLUT();
for (int i = 0; i < segCount; i++) {
float t = i == segCount ? 1 : i * lut[i] / segCount;
t += 0.5f / segCount;
Vec3 result = VecHelper.bezier(end1, end2, finish1, finish2, t);
Vec3 derivative = VecHelper.bezierDerivative(end1, end2, finish1, finish2, t)
.normalize();
Vec3 faceNormal =
faceNormal1.equals(faceNormal2) ? faceNormal1 : VecHelper.slerp(t, faceNormal1, faceNormal2);
Vec3 normal = faceNormal.cross(derivative)
.normalize();
Vec3 below = result.add(faceNormal.scale(-.25f));
Vec3 rail1 = below.add(normal.scale(.05f));
Vec3 rail2 = below.subtract(normal.scale(.05f));
Vec3 railMiddle = rail1.add(rail2)
.scale(.5);
for (Vec3 vec : new Vec3[] { railMiddle }) {
BlockPos pos = new BlockPos(vec);
Pair<Integer, Integer> key = Pair.of(pos.getX(), pos.getZ());
if (!yLevels.containsKey(key) || yLevels.get(key) > vec.y)
yLevels.put(key, vec.y);
}
}
for (Entry<Pair<Integer, Integer>, Double> entry : yLevels.entrySet()) {
double yValue = entry.getValue();
int floor = Mth.floor(yValue);
BlockPos targetPos = new BlockPos(entry.getKey()
.getFirst(), floor,
entry.getKey()
.getSecond());
targetPos = targetPos.offset(tePosition)
.above(1);
BlockState stateAtPos = level.getBlockState(targetPos);
boolean present = AllBlocks.FAKE_TRACK.has(stateAtPos);
if (remove) {
if (present)
level.removeBlock(targetPos, false);
continue;
}
if (!present && stateAtPos.getMaterial()
.isReplaceable())
level.setBlock(targetPos, AllBlocks.FAKE_TRACK.getDefaultState(), 3);
FakeTrackBlock.keepAlive(level, targetPos);
}
}
}