Add the aligner

-> still needs some better color combination logic
This commit is contained in:
grimmauld 2021-04-22 22:21:05 +02:00
parent 352ad95a84
commit 273fe8ebf1
34 changed files with 365 additions and 43 deletions

View file

@ -4,6 +4,7 @@ f0d6baaabda94151134f569246d61a6e710c35a9 assets/create/blockstates/acacia_window
55d57354040f4b5cefa2a9bfaf1cb777350fd699 assets/create/blockstates/adjustable_crate.json
79c50afcea3a360783a5b3c73de9823511e9aed9 assets/create/blockstates/adjustable_pulse_repeater.json
1d730df54c9eae94063e37396d224fb3c87517e0 assets/create/blockstates/adjustable_repeater.json
beeb4a297a932efa0526496d237b0f885ad7868c assets/create/blockstates/aligner.json
9dd79bf5430f674e7d3e3fc7d59edee3d66e241e assets/create/blockstates/analog_lever.json
dd468657a73fc2ad6e1ac08ace2996b6997d33e0 assets/create/blockstates/andesite_belt_funnel.json
585481e97c5066af63ea12fa5dd658798844d64c assets/create/blockstates/andesite_bricks.json
@ -407,20 +408,20 @@ a3a11524cd3515fc01d905767b4b7ea782adaf03 assets/create/blockstates/yellow_seat.j
6801fa1f466f172700e573e5b8ee8ee5f9ca4583 assets/create/blockstates/yellow_valve_handle.json
7f39521b211441f5c3e06d60c5978cebe16cacfb assets/create/blockstates/zinc_block.json
b7181bcd8182b2f17088e5aa881f374c9c65470c assets/create/blockstates/zinc_ore.json
4ab580b05eecdd48750cb873b7c7ef98a048915b assets/create/lang/en_ud.json
304611e751ede140c40f1bd6aabe5deedb1a972d assets/create/lang/en_us.json
8a5eabaddf94e00aba82aefb2589dfbbeca256aa assets/create/lang/unfinished/de_de.json
8f517f0bf301df8bbd4e593c8d01988a84b5f347 assets/create/lang/unfinished/es_es.json
72228d3f96a2b64e7659fe3e074818565fc7c5ab assets/create/lang/unfinished/es_mx.json
a4dfe786b3a3b8fbc7b2b8f5f7e0ae651aba8b68 assets/create/lang/unfinished/fr_fr.json
1043d68f4cdf0e3bae33a0fdc1c674abe31957f2 assets/create/lang/unfinished/it_it.json
2ffbf79be01436647b5baacb80bce6fc83c5f972 assets/create/lang/unfinished/ja_jp.json
9ab33a11eaa36e4abb4be64421067160ee276ff0 assets/create/lang/unfinished/ko_kr.json
9c73e2832455a07bc65e5a8c52894085ffa5a59e assets/create/lang/unfinished/nl_nl.json
ad1f915a8caeebc2f1c2e3224b1ff3a244922da9 assets/create/lang/unfinished/pt_br.json
d1421f69f733e2fedf16817a02d222775ef450a1 assets/create/lang/unfinished/ru_ru.json
c1b8459be62f7656d8f8d63066f4a5c3ea68f187 assets/create/lang/unfinished/zh_cn.json
ed026aacde00bfb9da6ae50b0778d166a6b84152 assets/create/lang/unfinished/zh_tw.json
b3733c1c460f4d2b4fddff0212681be767de1921 assets/create/lang/en_ud.json
f8405603b4fa68aaeab35f6ef49a9c176c5eef84 assets/create/lang/en_us.json
ce8d5dd6e8d6b75e2e843c601ecebb71d9453b7a assets/create/lang/unfinished/de_de.json
e9b570d56c072066839af8f1e506fe49339efccf assets/create/lang/unfinished/es_es.json
a0d535713a3706eb423981b5fa1cd045ad8ccc25 assets/create/lang/unfinished/es_mx.json
737755d8092eb2080834740523275fcfeeb95641 assets/create/lang/unfinished/fr_fr.json
94b87d5209f7cf41ce351974ee3b7dfcc350c2ee assets/create/lang/unfinished/it_it.json
08c52b18c705b90df4a60003e22d9e06234d98a3 assets/create/lang/unfinished/ja_jp.json
ec8840b32956f5b24417a12b301b911aab840093 assets/create/lang/unfinished/ko_kr.json
6b479c419f686af54d1d26bc12b3d001440e470e assets/create/lang/unfinished/nl_nl.json
f575ce2953234532321b8eabfd56f479bd96ce54 assets/create/lang/unfinished/pt_br.json
5ae527b03c101aca3f09f4ff5121cc17ccb2c789 assets/create/lang/unfinished/ru_ru.json
597454ac322e5298b845cf96c2b58954eebfe5ae assets/create/lang/unfinished/zh_cn.json
645e15ab013c7fc7d92052f9e79ea721d8d5b90d 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
@ -1205,6 +1206,7 @@ c695dab3964186a857767b2b4975aebffa86dcf9 assets/create/models/item/acacia_window
06d8b6e8f050b8ec0bef88b7633f3741baad4571 assets/create/models/item/adjustable_crate.json
96fcec285c0c26a8cb55e126f8c7053c70ad188b assets/create/models/item/adjustable_pulse_repeater.json
30292e874dd36e45eaeebb8d0bb8c4867866a38b assets/create/models/item/adjustable_repeater.json
9b392ed4704e42a7c6fdc98426c60c0b5c37e799 assets/create/models/item/aligner.json
e7759d9b3cd64d2719a58dc35fc75ca65b9e14fa assets/create/models/item/analog_lever.json
2e90c7abfcad12ca656ae253d834fbb799e15277 assets/create/models/item/andesite_alloy.json
a513af38f164a48fd44693b70a93012f3546caff assets/create/models/item/andesite_bricks.json
@ -1651,7 +1653,7 @@ d080b1b25e5bc8baf5aee68691b08c7f12ece3b0 assets/create/models/item/windmill_bear
a80fb25a0b655e76be986b5b49fcb0f03461a1ab assets/create/models/item/zinc_nugget.json
b1689617190c05ef34bd18456b0c7ae09bb3210f assets/create/models/item/zinc_ore.json
71739e613693c476e481dfcf38628a4f52f0f570 assets/create/sounds.json
0f1b4b980afba9bf2caf583b88e261bba8b10313 data/create/advancements/aesthetics.json
5d0cc4c0255dc241e61c173b31ddca70c88d08e4 data/create/advancements/aesthetics.json
187921fa131b06721bfaf63f2623a28c141aae9a data/create/advancements/andesite_alloy.json
0ea2db7173b5be28b289ea7c9a6a0cf5805c60c7 data/create/advancements/andesite_casing.json
83c046bd200623933545c9e4326f782fb02c87fa data/create/advancements/arm_blaze_burner.json
@ -2380,6 +2382,7 @@ d6b94fd499cb4fb0ae587b0e9e7088832f67fe01 data/create/advancements/windmill.json
191b117d0a25940248ed54d419ea0bb0afb482d0 data/create/loot_tables/blocks/adjustable_crate.json
417da41ebd0520ae22ddc3541eb490daf2af95dd data/create/loot_tables/blocks/adjustable_pulse_repeater.json
d0ba402852cea164f6d279a9b37cc38ac3958574 data/create/loot_tables/blocks/adjustable_repeater.json
01b6060e1426c53bd3101d8f5e99ed27dfa01a45 data/create/loot_tables/blocks/aligner.json
0d139e302f4a11438b0acd664c0df15b41040f69 data/create/loot_tables/blocks/analog_lever.json
d3202a337c15c8b8ec41fa5879bb94327bb75057 data/create/loot_tables/blocks/andesite_belt_funnel.json
1d04146c468ce4bf898b596c171b3ba3146d7d66 data/create/loot_tables/blocks/andesite_bricks.json
@ -3650,7 +3653,7 @@ eedf31af7134d03656c5fa57229982f9c5bed07c data/create/tags/blocks/brittle.json
330bfb3850ba3964b10b1bccbc3cbb9b012cae54 data/create/tags/blocks/fan_heaters.json
3bc64e3a1e7980237435b1770a9ba2102d57fcd4 data/create/tags/blocks/fan_transparent.json
74700d556ca80c7a1db5fd4efb09c3ddb26cad66 data/create/tags/blocks/non_movable.json
834b0ba683dac15d2decb80c34214b98cb2be67f data/create/tags/blocks/safe_nbt.json
0476240204d2a82ab9cba82649b7261a89c3acbe data/create/tags/blocks/safe_nbt.json
c9ac7e3e5ec18554e7184168d65e9b8e44ef5610 data/create/tags/blocks/sails.json
6cdeeac1689f7b5bfd9bc40b462143d8eaf3ad0b data/create/tags/blocks/seats.json
50936b211d94167a35ec78c89954082a336b6269 data/create/tags/blocks/valve_handles.json

View file

@ -0,0 +1,30 @@
{
"variants": {
"facing=down": {
"model": "create:block/aligner",
"x": 180
},
"facing=up": {
"model": "create:block/aligner"
},
"facing=north": {
"model": "create:block/aligner",
"x": 90
},
"facing=south": {
"model": "create:block/aligner",
"x": 90,
"y": 180
},
"facing=west": {
"model": "create:block/aligner",
"x": 90,
"y": 270
},
"facing=east": {
"model": "create:block/aligner",
"x": 90,
"y": 90
}
}
}

View file

@ -5,6 +5,7 @@
"block.create.adjustable_crate": "\u01DD\u0287\u0250\u0279\u0186 \u01DD\u05DFq\u0250\u0287sn\u0638p\u2C6F",
"block.create.adjustable_pulse_repeater": "\u0279\u01DD\u0287\u0250\u01DDd\u01DD\u1D1A \u01DDs\u05DFn\u0500 \u01DD\u05DFq\u0250\u0287sn\u0638p\u2C6F",
"block.create.adjustable_repeater": "\u0279\u01DD\u0287\u0250\u01DDd\u01DD\u1D1A \u01DD\u05DFq\u0250\u0287sn\u0638p\u2C6F",
"block.create.aligner": "\u0279\u01DDub\u0131\u05DF\u2C6F",
"block.create.analog_lever": "\u0279\u01DD\u028C\u01DD\uA780 bo\u05DF\u0250u\u2C6F",
"block.create.andesite_belt_funnel": "\u05DF\u01DDuun\u2132 \u0287\u05DF\u01DD\u15FA \u01DD\u0287\u0131s\u01DDpu\u2C6F",
"block.create.andesite_bricks": "s\u029E\u0254\u0131\u0279\u15FA \u01DD\u0287\u0131s\u01DDpu\u2C6F",

View file

@ -8,6 +8,7 @@
"block.create.adjustable_crate": "Adjustable Crate",
"block.create.adjustable_pulse_repeater": "Adjustable Pulse Repeater",
"block.create.adjustable_repeater": "Adjustable Repeater",
"block.create.aligner": "Aligner",
"block.create.analog_lever": "Analog Lever",
"block.create.andesite_belt_funnel": "Andesite Belt Funnel",
"block.create.andesite_bricks": "Andesite Bricks",

View file

@ -1,5 +1,5 @@
{
"_": "Missing Localizations: 922",
"_": "Missing Localizations: 923",
"_": "->------------------------] Game Elements [------------------------<-",
@ -9,6 +9,7 @@
"block.create.adjustable_crate": "Verstellbare Kiste",
"block.create.adjustable_pulse_repeater": "Verstellbarer Pulsverstärker",
"block.create.adjustable_repeater": "Verstellbarer Verstärker",
"block.create.aligner": "UNLOCALIZED: Aligner",
"block.create.analog_lever": "Analoger Schalter",
"block.create.andesite_belt_funnel": "Riementrichter aus Andesit",
"block.create.andesite_bricks": "Andesitziegel",

View file

@ -1,5 +1,5 @@
{
"_": "Missing Localizations: 615",
"_": "Missing Localizations: 616",
"_": "->------------------------] Game Elements [------------------------<-",
@ -9,6 +9,7 @@
"block.create.adjustable_crate": "Caja ajustable",
"block.create.adjustable_pulse_repeater": "Repetidor de pulso ajustable",
"block.create.adjustable_repeater": "Repetidor ajustable",
"block.create.aligner": "UNLOCALIZED: Aligner",
"block.create.analog_lever": "Palanca analógica",
"block.create.andesite_belt_funnel": "Embudo de cinta de andesita",
"block.create.andesite_bricks": "Ladrillos de andesita",

View file

@ -1,5 +1,5 @@
{
"_": "Missing Localizations: 1273",
"_": "Missing Localizations: 1274",
"_": "->------------------------] Game Elements [------------------------<-",
@ -9,6 +9,7 @@
"block.create.adjustable_crate": "Caja Ajustable",
"block.create.adjustable_pulse_repeater": "Repetidor de Pulso Ajustable",
"block.create.adjustable_repeater": "Repetidor Ajustable",
"block.create.aligner": "UNLOCALIZED: Aligner",
"block.create.analog_lever": "Palanca Analogica",
"block.create.andesite_belt_funnel": "UNLOCALIZED: Andesite Belt Funnel",
"block.create.andesite_bricks": "Ladrillos de Andesita",

View file

@ -1,5 +1,5 @@
{
"_": "Missing Localizations: 1172",
"_": "Missing Localizations: 1173",
"_": "->------------------------] Game Elements [------------------------<-",
@ -9,6 +9,7 @@
"block.create.adjustable_crate": "Caisse ajustable",
"block.create.adjustable_pulse_repeater": "Répéteur d'impulsions réglable",
"block.create.adjustable_repeater": "Répéteur réglable",
"block.create.aligner": "UNLOCALIZED: Aligner",
"block.create.analog_lever": "Levier analogique",
"block.create.andesite_belt_funnel": "Entonnoir en andésite pour tapis roulant",
"block.create.andesite_bricks": "Briques d'andésite",

View file

@ -1,5 +1,5 @@
{
"_": "Missing Localizations: 632",
"_": "Missing Localizations: 633",
"_": "->------------------------] Game Elements [------------------------<-",
@ -9,6 +9,7 @@
"block.create.adjustable_crate": "Baule regolabile",
"block.create.adjustable_pulse_repeater": "Ripetitore di impulsi regolabile",
"block.create.adjustable_repeater": "Ripetitore regolabile",
"block.create.aligner": "UNLOCALIZED: Aligner",
"block.create.analog_lever": "Leva analogica",
"block.create.andesite_belt_funnel": "Imbuto per nastro di andesite",
"block.create.andesite_bricks": "Mattoni di andesite",

View file

@ -1,5 +1,5 @@
{
"_": "Missing Localizations: 614",
"_": "Missing Localizations: 615",
"_": "->------------------------] Game Elements [------------------------<-",
@ -9,6 +9,7 @@
"block.create.adjustable_crate": "可変クレート",
"block.create.adjustable_pulse_repeater": "可変パルスリピーター",
"block.create.adjustable_repeater": "可変リピーター",
"block.create.aligner": "UNLOCALIZED: Aligner",
"block.create.analog_lever": "アナログレバー",
"block.create.andesite_belt_funnel": "安山岩のベルトファンネル",
"block.create.andesite_bricks": "安山岩レンガ",

View file

@ -1,5 +1,5 @@
{
"_": "Missing Localizations: 685",
"_": "Missing Localizations: 686",
"_": "->------------------------] Game Elements [------------------------<-",
@ -9,6 +9,7 @@
"block.create.adjustable_crate": "가변 창고",
"block.create.adjustable_pulse_repeater": "가변 펄스 리피터",
"block.create.adjustable_repeater": "가변 리피터",
"block.create.aligner": "UNLOCALIZED: Aligner",
"block.create.analog_lever": "아날로그 레버",
"block.create.andesite_belt_funnel": "안산암 깔때기",
"block.create.andesite_bricks": "안산암 벽돌",

View file

@ -1,5 +1,5 @@
{
"_": "Missing Localizations: 1562",
"_": "Missing Localizations: 1563",
"_": "->------------------------] Game Elements [------------------------<-",
@ -9,6 +9,7 @@
"block.create.adjustable_crate": "FlexKrat",
"block.create.adjustable_pulse_repeater": "UNLOCALIZED: Adjustable Pulse Repeater",
"block.create.adjustable_repeater": "FlexSterker",
"block.create.aligner": "UNLOCALIZED: Aligner",
"block.create.analog_lever": "UNLOCALIZED: Analog Lever",
"block.create.andesite_belt_funnel": "UNLOCALIZED: Andesite Belt Funnel",
"block.create.andesite_bricks": "Andesietstenen",

View file

@ -1,5 +1,5 @@
{
"_": "Missing Localizations: 1616",
"_": "Missing Localizations: 1617",
"_": "->------------------------] Game Elements [------------------------<-",
@ -9,6 +9,7 @@
"block.create.adjustable_crate": "adjustable_crate",
"block.create.adjustable_pulse_repeater": "UNLOCALIZED: Adjustable Pulse Repeater",
"block.create.adjustable_repeater": "Repetidor Flex",
"block.create.aligner": "UNLOCALIZED: Aligner",
"block.create.analog_lever": "UNLOCALIZED: Analog Lever",
"block.create.andesite_belt_funnel": "UNLOCALIZED: Andesite Belt Funnel",
"block.create.andesite_bricks": "Tijolos de Andesite",

View file

@ -1,5 +1,5 @@
{
"_": "Missing Localizations: 529",
"_": "Missing Localizations: 530",
"_": "->------------------------] Game Elements [------------------------<-",
@ -9,6 +9,7 @@
"block.create.adjustable_crate": "Регулируемый ящик",
"block.create.adjustable_pulse_repeater": "Регулируемый импульсный повторитель",
"block.create.adjustable_repeater": "Регулируемый повторитель",
"block.create.aligner": "UNLOCALIZED: Aligner",
"block.create.analog_lever": "Аналоговый рычаг",
"block.create.andesite_belt_funnel": "Андезитовая конвейерная воронка",
"block.create.andesite_bricks": "Андезитовый кирпич",

View file

@ -1,5 +1,5 @@
{
"_": "Missing Localizations: 629",
"_": "Missing Localizations: 630",
"_": "->------------------------] Game Elements [------------------------<-",
@ -9,6 +9,7 @@
"block.create.adjustable_crate": "可调节板条箱",
"block.create.adjustable_pulse_repeater": "可调节脉冲中继器",
"block.create.adjustable_repeater": "可调节中继器",
"block.create.aligner": "UNLOCALIZED: Aligner",
"block.create.analog_lever": "可调节拉杆",
"block.create.andesite_belt_funnel": "安山岩传送带漏斗",
"block.create.andesite_bricks": "安山岩砖",

View file

@ -1,5 +1,5 @@
{
"_": "Missing Localizations: 634",
"_": "Missing Localizations: 635",
"_": "->------------------------] Game Elements [------------------------<-",
@ -9,6 +9,7 @@
"block.create.adjustable_crate": "可調式板條箱",
"block.create.adjustable_pulse_repeater": "可調式脈衝中繼器",
"block.create.adjustable_repeater": "可調式中繼器",
"block.create.aligner": "UNLOCALIZED: Aligner",
"block.create.analog_lever": "可調式拉桿",
"block.create.andesite_belt_funnel": "安山岩輸送帶漏斗",
"block.create.andesite_bricks": "安山岩磚",

View file

@ -0,0 +1,3 @@
{
"parent": "create:block/aligner"
}

View file

@ -28,8 +28,8 @@
"trigger": "create:bracket_apply",
"conditions": {
"accepted_entries": [
"create:cogwheel",
"create:large_cogwheel"
"create:large_cogwheel",
"create:cogwheel"
]
}
},

View file

@ -0,0 +1,19 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "create:aligner"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View file

@ -16,6 +16,7 @@
"create:sequenced_gearshift",
"create:rotation_speed_controller",
"create:mirror",
"create:aligner",
"create:andesite_funnel",
"create:andesite_belt_funnel",
"create:brass_funnel",

View file

@ -154,6 +154,7 @@ import com.simibubi.create.content.logistics.block.redstone.RedstoneContactBlock
import com.simibubi.create.content.logistics.block.redstone.RedstoneLinkBlock;
import com.simibubi.create.content.logistics.block.redstone.RedstoneLinkGenerator;
import com.simibubi.create.content.logistics.block.redstone.StockpileSwitchBlock;
import com.simibubi.create.content.optics.aligner.AlignerBlock;
import com.simibubi.create.content.optics.mirror.MirrorBlock;
import com.simibubi.create.content.schematics.block.SchematicTableBlock;
import com.simibubi.create.content.schematics.block.SchematicannonBlock;
@ -1118,6 +1119,17 @@ public class AllBlocks {
.transform(customItemModel())
.register();
public static final BlockEntry<AlignerBlock> ALIGNER =
REGISTRATE.block("aligner", AlignerBlock::new)
.initialProperties(SharedProperties::softMetal)
.properties(AbstractBlock.Properties::nonOpaque)
.addLayer(() -> RenderType::getTranslucent)
.tag(AllBlockTags.SAFE_NBT.tag)
.blockstate(BlockStateGen.directionalBlockProvider(false))
.simpleItem()
.register();
// Logistics
static {

View file

@ -149,6 +149,8 @@ import com.simibubi.create.content.logistics.block.redstone.NixieTubeRenderer;
import com.simibubi.create.content.logistics.block.redstone.NixieTubeTileEntity;
import com.simibubi.create.content.logistics.block.redstone.RedstoneLinkTileEntity;
import com.simibubi.create.content.logistics.block.redstone.StockpileSwitchTileEntity;
import com.simibubi.create.content.optics.aligner.AlignerRenderer;
import com.simibubi.create.content.optics.aligner.AlignerTileEntity;
import com.simibubi.create.content.optics.mirror.MirrorInstance;
import com.simibubi.create.content.optics.mirror.MirrorRenderer;
import com.simibubi.create.content.optics.mirror.MirrorTileEntity;
@ -593,6 +595,12 @@ public class AllTileEntities {
.renderer(() -> MirrorRenderer::new)
.register();
public static final TileEntityEntry<AlignerTileEntity> ALIGNER = Create.registrate()
.tileEntity("aligner", AlignerTileEntity::new)
.validBlocks(AllBlocks.ALIGNER)
.renderer(() -> AlignerRenderer::new)
.register();
// Logistics
public static final TileEntityEntry<RedstoneLinkTileEntity> REDSTONE_LINK = Create.registrate()
.tileEntity("redstone_link", RedstoneLinkTileEntity::new)

View file

@ -88,9 +88,7 @@ public class Beam extends ArrayList<BeamSegment> {
}
public boolean isRemoved() {
ILightHandler handler = getHandler();
removed = removed || isEmpty() || handler == null || handler.getTile()
.isRemoved() || (parent != null && parent.isRemovedSimple());
removed = isRemovedSimple() || (parent != null && parent.isRemovedSimple());
return removed;
}

View file

@ -25,16 +25,16 @@ public interface ILightHandler {
}
default Beam constructOutBeam(@Nullable Beam parent, Vector3d beamDirection) {
return constructOutBeam(parent, beamDirection, getBlockPos());
return constructOutBeam(parent, beamDirection, getBlockPos(), DyeColor.WHITE.getColorComponentValues());
}
default Beam constructOutBeam(@Nullable Beam parent, Vector3d beamDirection, BlockPos testBlockPos) {
default Beam constructOutBeam(@Nullable Beam parent, Vector3d beamDirection, BlockPos testBlockPos, float[] colorComponentValues) {
Beam beam = new Beam(parent, getHandlerWorld());
World world = getHandlerWorld();
if (world == null)
return beam;
float[] segmentColor = parent == null ? DyeColor.WHITE.getColorComponentValues() : parent.getColorAt(testBlockPos);
float[] segmentColor = parent == null ? colorComponentValues : parent.getColorAt(testBlockPos);
Vector3d direction = VecHelper.step(beamDirection);
Vector3d testPos = VecHelper.getCenterOf(testBlockPos);

View file

@ -0,0 +1,111 @@
package com.simibubi.create.content.optics.aligner;
import java.util.Collections;
import java.util.Iterator;
import java.util.Objects;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import com.google.common.collect.Iterators;
import com.google.common.util.concurrent.AtomicDouble;
import com.simibubi.create.content.optics.Beam;
import com.simibubi.create.content.optics.behaviour.AbstractLightHandlingBehaviour;
import com.simibubi.create.content.optics.behaviour.LightHandlingbehaviourProperties;
import com.simibubi.create.foundation.tileEntity.behaviour.BehaviourType;
import com.simibubi.create.foundation.utility.AngleHelper;
import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.util.Direction;
import net.minecraft.util.math.vector.Vector3d;
public class AlignerBehaviour extends AbstractLightHandlingBehaviour<AlignerTileEntity> {
public static final BehaviourType<AlignerBehaviour> TYPE = new BehaviourType<>();
@Nullable
protected Beam collectedBeam = null;
boolean updating = false;
protected AlignerBehaviour(AlignerTileEntity te) {
super(te, LightHandlingbehaviourProperties.create()
.withScansBeacons(true)
.withAbsorbsLight(true));
}
@Override
public void updateBeams() {
super.updateBeams();
if (updating)
return;
updating = true;
AtomicDouble r = new AtomicDouble();
AtomicDouble g = new AtomicDouble();
AtomicDouble b = new AtomicDouble();
beams = beams.stream()
.filter(Objects::nonNull)
.filter(((Predicate<Beam>) Beam::isRemoved).negate())
.peek(beam -> {
float[] localColor = beam.getColorAt(getBlockPos());
r.addAndGet(localColor[0] * localColor[0]);
g.addAndGet(localColor[1] * localColor[1]);
b.addAndGet(localColor[2] * localColor[2]);
})
.collect(Collectors.toSet());
if (collectedBeam != null) {
collectedBeam.onRemoved();
collectedBeam = null;
}
if (!beams.isEmpty()) {
collectedBeam = constructOutBeam(null, getFacingVec(), getBlockPos(), new float[]{(float) Math.sqrt(r.get() / beams.size()), (float) Math.sqrt(g.get() / beams.size()), (float) Math.sqrt(b.get() / beams.size())});
if (collectedBeam != null && !collectedBeam.isEmpty()) {
collectedBeam.addListener(this);
collectedBeam.onCreated();
}
}
updating = false;
}
@Nonnull
@Override
public Direction getBeamRotationAround() {
return Direction.getFacingFromAxisDirection(getFacing().getAxis(), Direction.AxisDirection.POSITIVE);
}
private Direction getFacing() {
return tileEntity.getBlockState()
.get(BlockStateProperties.FACING);
}
private Vector3d getFacingVec() {
return Vector3d.of(getFacing().getDirectionVec());
}
@Override
public Stream<Beam> constructSubBeams(Beam beam) {
Vector3d beamDir = beam.getDirection();
if (!beam.isRemoved() && beamDir != null && AngleHelper.deg(Math.cos(beamDir.dotProduct(getFacingVec()))) < 60) {
beams.add(beam);
requestBeamUpdate();
}
return Stream.empty();
}
@Override
public BehaviourType<?> getType() {
return TYPE;
}
@Override
public Iterator<Beam> getRenderBeams() {
return Iterators.concat(super.getRenderBeams(), collectedBeam == null ? Collections.emptyIterator() : Collections.singleton(collectedBeam)
.iterator());
}
}

View file

@ -0,0 +1,36 @@
package com.simibubi.create.content.optics.aligner;
import javax.annotation.Nullable;
import com.simibubi.create.AllTileEntities;
import com.simibubi.create.content.contraptions.wrench.IWrenchable;
import com.simibubi.create.foundation.block.ITE;
import com.simibubi.create.foundation.block.ProperDirectionalBlock;
import net.minecraft.block.BlockState;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Direction;
import net.minecraft.world.IBlockReader;
public class AlignerBlock extends ProperDirectionalBlock implements IWrenchable, ITE<AlignerTileEntity> {
public AlignerBlock(Properties properties) {
super(properties);
setDefaultState(getDefaultState().with(FACING, Direction.DOWN));
}
@Override
public Class<AlignerTileEntity> getTileEntityClass() {
return AlignerTileEntity.class;
}
@Override
public boolean hasTileEntity(BlockState state) {
return true;
}
@Nullable
@Override
public TileEntity createTileEntity(BlockState state, IBlockReader world) {
return AllTileEntities.ALIGNER.create();
}
}

View file

@ -0,0 +1,20 @@
package com.simibubi.create.content.optics.aligner;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer;
import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
public class AlignerRenderer extends SafeTileEntityRenderer<AlignerTileEntity> {
public AlignerRenderer(TileEntityRendererDispatcher dispatcher) {
super(dispatcher);
}
@Override
protected void renderSafe(AlignerTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) {
te.getHandler()
.getRenderBeams()
.forEachRemaining(beam -> beam.render(ms, buffer, partialTicks));
}
}

View file

@ -0,0 +1,29 @@
package com.simibubi.create.content.optics.aligner;
import java.util.List;
import com.simibubi.create.content.optics.ILightHandler;
import com.simibubi.create.foundation.tileEntity.SmartTileEntity;
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
import net.minecraft.tileentity.TileEntityType;
public class AlignerTileEntity extends SmartTileEntity implements ILightHandler.ILightHandlerProvider {
protected AlignerBehaviour aligner;
public AlignerTileEntity(TileEntityType<?> tileEntityTypeIn) {
super(tileEntityTypeIn);
setLazyTickRate(20);
}
@Override
public void addBehaviours(List<TileEntityBehaviour> behaviours) {
aligner = new AlignerBehaviour(this);
behaviours.add(aligner);
}
@Override
public ILightHandler getHandler() {
return aligner;
}
}

View file

@ -14,6 +14,7 @@ import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
import com.simibubi.create.foundation.utility.BeaconHelper;
import com.simibubi.create.foundation.utility.VecHelper;
import net.minecraft.item.DyeColor;
import net.minecraft.tileentity.BeaconTileEntity;
import net.minecraft.tileentity.TileEntity;
@ -21,9 +22,11 @@ public abstract class AbstractLightHandlingBehaviour<T extends SmartTileEntity &
protected final T handler;
private final LightHandlingbehaviourProperties properties;
protected Set<Beam> beams;
@Nullable
protected Beam beaconBeam = null;
@Nullable
protected BeaconTileEntity beacon;
boolean needsBeamUpdate = false;
protected AbstractLightHandlingBehaviour(T te, LightHandlingbehaviourProperties properties) {
super(te);
@ -37,6 +40,8 @@ public abstract class AbstractLightHandlingBehaviour<T extends SmartTileEntity &
super.tick();
if (properties.scansBeacon && beacon != null && beacon.isRemoved())
updateBeaconState();
if (needsBeamUpdate)
updateBeams();
}
@ -48,11 +53,11 @@ public abstract class AbstractLightHandlingBehaviour<T extends SmartTileEntity &
if (beaconBefore != null) {
beaconBeam.clear();
beaconBeam = null;
updateBeams();
requestBeamUpdate();
}
if (beacon != null) {
beaconBeam = constructOutBeam(null, VecHelper.UP, beacon.getPos());
beaconBeam = constructOutBeam(null, VecHelper.UP, beacon.getPos(), DyeColor.WHITE.getColorComponentValues());
if (beaconBeam != null && !beaconBeam.isEmpty()) {
beaconBeam.addListener(this);
beaconBeam.onCreated();
@ -70,9 +75,17 @@ public abstract class AbstractLightHandlingBehaviour<T extends SmartTileEntity &
super.lazyTick();
if (properties.scansBeacon)
updateBeaconState();
updateBeams();
requestBeamUpdate();
}
public void requestBeamUpdate() {
needsBeamUpdate = true;
}
@Override
public void updateBeams() {
needsBeamUpdate = false;
}
@Override
public Iterator<Beam> getRenderBeams() {
@ -87,6 +100,8 @@ public abstract class AbstractLightHandlingBehaviour<T extends SmartTileEntity &
@Override
public void remove() {
beams.forEach(Beam::onRemoved);
if (beaconBeam != null)
beaconBeam.onRemoved();
}
@Override

View file

@ -22,6 +22,7 @@ public abstract class AbstractLightRelayBehaviour<T extends SmartTileEntity & IL
@Override
public void updateBeams() {
super.updateBeams();
if (isUpdating)
return;
isUpdating = true;

View file

@ -7,12 +7,11 @@ import java.util.stream.Stream;
import com.simibubi.create.content.optics.Beam;
import com.simibubi.create.content.optics.ILightHandler;
import com.simibubi.create.content.optics.mirror.MirrorBehaviour;
import com.simibubi.create.foundation.tileEntity.SmartTileEntity;
import com.simibubi.create.foundation.tileEntity.behaviour.BehaviourType;
public class LightAcceptingBehaviour<T extends SmartTileEntity & ILightHandler.ILightHandlerProvider> extends AbstractLightHandlingBehaviour<T> {
public static final BehaviourType<MirrorBehaviour> TYPE = new BehaviourType<>();
public static final BehaviourType<LightAcceptingBehaviour<? extends SmartTileEntity>> TYPE = new BehaviourType<>();
boolean isUpdating = false;
public LightAcceptingBehaviour(T te, LightHandlingbehaviourProperties properties) {
@ -27,6 +26,7 @@ public class LightAcceptingBehaviour<T extends SmartTileEntity & ILightHandler.I
@Override
public void updateBeams() {
super.updateBeams();
if (isUpdating)
return;
isUpdating = true;

View file

@ -8,7 +8,6 @@ import java.util.stream.Stream;
import com.google.common.collect.Iterators;
import com.simibubi.create.content.optics.Beam;
import com.simibubi.create.content.optics.ILightHandler;
import com.simibubi.create.content.optics.mirror.MirrorBehaviour;
import com.simibubi.create.foundation.tileEntity.SmartTileEntity;
import com.simibubi.create.foundation.tileEntity.behaviour.BehaviourType;
@ -17,7 +16,7 @@ import net.minecraft.util.Direction;
import net.minecraft.util.math.vector.Vector3d;
public class LightEmittingBehaviour<T extends SmartTileEntity & ILightHandler.ILightHandlerProvider> extends AbstractLightHandlingBehaviour<T> {
public static final BehaviourType<MirrorBehaviour> TYPE = new BehaviourType<>();
public static final BehaviourType<LightEmittingBehaviour<? extends SmartTileEntity>> TYPE = new BehaviourType<>();
boolean updating = false;
@ -34,6 +33,7 @@ public class LightEmittingBehaviour<T extends SmartTileEntity & ILightHandler.IL
@Override
public void updateBeams() {
super.updateBeams();
if (updating)
return;
updating = true;

View file

@ -0,0 +1,22 @@
{
"credit": "Made with Blockbench",
"parent": "block/block",
"textures": {
"0": "create:block/aligner",
"particle": "create:block/aligner"
},
"elements": [
{
"from": [0, 0, 0],
"to": [16, 16, 16],
"faces": {
"north": {"uv": [8, 0, 16, 8], "rotation": 180, "texture": "#0"},
"east": {"uv": [8, 0, 16, 8], "rotation": 180, "texture": "#0"},
"south": {"uv": [8, 0, 16, 8], "rotation": 180, "texture": "#0"},
"west": {"uv": [8, 0, 16, 8], "rotation": 180, "texture": "#0"},
"up": {"uv": [0, 0, 8, 8], "texture": "#0"},
"down": {"uv": [0, 8, 8, 16], "texture": "#0"}
}
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.1 KiB