Portaln't

- Feedback message when a portal track fails to bind
This commit is contained in:
simibubi 2022-05-18 03:32:27 +02:00
parent 41facb7543
commit e344551057
19 changed files with 130 additions and 35 deletions

View file

@ -545,22 +545,22 @@ bf2b0310500213ff853c748c236eb5d01f61658e assets/create/blockstates/yellow_toolbo
7f39521b211441f5c3e06d60c5978cebe16cacfb assets/create/blockstates/zinc_block.json
b7181bcd8182b2f17088e5aa881f374c9c65470c assets/create/blockstates/zinc_ore.json
ad4db674caf6a1abe0bea573fd38ecfb198d3a9f assets/create/lang/en_ud.json
45ad7384355cc39fb9e5e6b91f4bb2dc281b5c4a assets/create/lang/en_us.json
ebe46e52d7001f42e8c1fcab420839cf1d18bfca assets/create/lang/unfinished/de_de.json
c5af61fb0a83c63d5f758c4fdb9529f74a68cb12 assets/create/lang/unfinished/es_cl.json
42b1bc512547b363dd80fd1c706768a0d871fdb8 assets/create/lang/unfinished/es_es.json
fe981e80118d19e1c1c3d792bb312ee84ebf8504 assets/create/lang/unfinished/fr_fr.json
adcd4142a024ccb40d3459224174495fc99f6379 assets/create/lang/unfinished/it_it.json
ff6ee4585d4895e16e54e65e0aa4ef2f0808a7e0 assets/create/lang/unfinished/ja_jp.json
4703035e480ad272f0d4247428e98963f03e7e2b assets/create/lang/unfinished/ko_kr.json
f0888188c11ded8d07885629279099595ec3596c assets/create/lang/unfinished/nl_nl.json
1b9ce55ffaa78c74c90dd17b419791ed0e5ef168 assets/create/lang/unfinished/pl_pl.json
d32edfcd1a5643db71c6a8f749e5c55e16eba284 assets/create/lang/unfinished/pt_br.json
fabd680b944443de442cf3efaf1d968020d44a19 assets/create/lang/unfinished/pt_pt.json
849c7decbbe7c4a5afefba4bf47b9c7a99534dbb assets/create/lang/unfinished/ro_ro.json
9c9f038828b3000d63f1ec76728276d1558b6cb2 assets/create/lang/unfinished/ru_ru.json
fc935326da55a21ebae23d15f87dfdfea426bafc assets/create/lang/unfinished/zh_cn.json
3606f74bf9906cf839425231f6f369ad2fc8e242 assets/create/lang/unfinished/zh_tw.json
f7b3b5d1701800018eb6f337f289bcb09a2d2b32 assets/create/lang/en_us.json
78d55ed7e2c935ca1fceeaeadd19d6d4798e18f6 assets/create/lang/unfinished/de_de.json
abe03a5c6c992e45f5c1248a2a9f69fb8ee777fb assets/create/lang/unfinished/es_cl.json
8629b686bfb443c5ab5e7b364a197af0b34d07da assets/create/lang/unfinished/es_es.json
f716fa6e0ed4cd2d521c5e45b436b2abf2651325 assets/create/lang/unfinished/fr_fr.json
5e3d9743807181eafc7f34f08a83bb0906c69cec assets/create/lang/unfinished/it_it.json
a41170acf0976a295eb8e6c4ae2b0f496027460b assets/create/lang/unfinished/ja_jp.json
041aeb71ac42b3256338f6a8a0c7c1af9ac52bf3 assets/create/lang/unfinished/ko_kr.json
6112f9780067a315d25f21e37177060c043f8a53 assets/create/lang/unfinished/nl_nl.json
78cc27aac1829635b4dd18ec3cd4d720594ee714 assets/create/lang/unfinished/pl_pl.json
f827b360177819a70a3da17946d44f24ccd5fcb8 assets/create/lang/unfinished/pt_br.json
b7b3c9434b1a6a2139669aff6157f678d51062f5 assets/create/lang/unfinished/pt_pt.json
a4296b4ef145871d6838fd1756a82ec505e62cda assets/create/lang/unfinished/ro_ro.json
fa0d21f2bba491c1e30889d4838680006d5d27a7 assets/create/lang/unfinished/ru_ru.json
97bc1cd81e4e4dd151a1b3565b8b24421e69f075 assets/create/lang/unfinished/zh_cn.json
7be762379b0b2439fe4d0ffd9a8514ef01080d1f 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

View file

@ -1422,6 +1422,10 @@
"create.track.not_enough_tracks": "Not holding enough tracks",
"create.track.not_enough_pavement": "Not holding enough pavement blocks",
"create.portal_track.failed": "Cannot place portal track:",
"create.portal_track.missing": "Target portal not generated yet",
"create.portal_track.blocked": "Target location blocked (%1$s,%2$s,%3$s)",
"create.station.create_train": "Create new Train",
"create.station.disassemble_train": "Disassemble Train",
"create.station.remove_schedule": "Retrieve Schedule",

View file

@ -1,5 +1,5 @@
{
"_": "Missing Localizations: 1540",
"_": "Missing Localizations: 1543",
"_": "->------------------------] Game Elements [------------------------<-",
@ -1423,6 +1423,10 @@
"create.track.not_enough_tracks": "UNLOCALIZED: Not holding enough tracks",
"create.track.not_enough_pavement": "UNLOCALIZED: Not holding enough pavement blocks",
"create.portal_track.failed": "UNLOCALIZED: Cannot place portal track:",
"create.portal_track.missing": "UNLOCALIZED: Target portal not generated yet",
"create.portal_track.blocked": "UNLOCALIZED: Target location blocked (%1$s,%2$s,%3$s)",
"create.station.create_train": "UNLOCALIZED: Create new Train",
"create.station.disassemble_train": "UNLOCALIZED: Disassemble Train",
"create.station.remove_schedule": "UNLOCALIZED: Retrieve Schedule",

View file

@ -1,5 +1,5 @@
{
"_": "Missing Localizations: 562",
"_": "Missing Localizations: 565",
"_": "->------------------------] Game Elements [------------------------<-",
@ -1423,6 +1423,10 @@
"create.track.not_enough_tracks": "UNLOCALIZED: Not holding enough tracks",
"create.track.not_enough_pavement": "UNLOCALIZED: Not holding enough pavement blocks",
"create.portal_track.failed": "UNLOCALIZED: Cannot place portal track:",
"create.portal_track.missing": "UNLOCALIZED: Target portal not generated yet",
"create.portal_track.blocked": "UNLOCALIZED: Target location blocked (%1$s,%2$s,%3$s)",
"create.station.create_train": "UNLOCALIZED: Create new Train",
"create.station.disassemble_train": "UNLOCALIZED: Disassemble Train",
"create.station.remove_schedule": "UNLOCALIZED: Retrieve Schedule",

View file

@ -1,5 +1,5 @@
{
"_": "Missing Localizations: 233",
"_": "Missing Localizations: 236",
"_": "->------------------------] Game Elements [------------------------<-",
@ -1423,6 +1423,10 @@
"create.track.not_enough_tracks": "UNLOCALIZED: Not holding enough tracks",
"create.track.not_enough_pavement": "UNLOCALIZED: Not holding enough pavement blocks",
"create.portal_track.failed": "UNLOCALIZED: Cannot place portal track:",
"create.portal_track.missing": "UNLOCALIZED: Target portal not generated yet",
"create.portal_track.blocked": "UNLOCALIZED: Target location blocked (%1$s,%2$s,%3$s)",
"create.station.create_train": "UNLOCALIZED: Create new Train",
"create.station.disassemble_train": "UNLOCALIZED: Disassemble Train",
"create.station.remove_schedule": "UNLOCALIZED: Retrieve Schedule",

View file

@ -1,5 +1,5 @@
{
"_": "Missing Localizations: 1802",
"_": "Missing Localizations: 1805",
"_": "->------------------------] Game Elements [------------------------<-",
@ -1423,6 +1423,10 @@
"create.track.not_enough_tracks": "UNLOCALIZED: Not holding enough tracks",
"create.track.not_enough_pavement": "UNLOCALIZED: Not holding enough pavement blocks",
"create.portal_track.failed": "UNLOCALIZED: Cannot place portal track:",
"create.portal_track.missing": "UNLOCALIZED: Target portal not generated yet",
"create.portal_track.blocked": "UNLOCALIZED: Target location blocked (%1$s,%2$s,%3$s)",
"create.station.create_train": "UNLOCALIZED: Create new Train",
"create.station.disassemble_train": "UNLOCALIZED: Disassemble Train",
"create.station.remove_schedule": "UNLOCALIZED: Retrieve Schedule",

View file

@ -1,5 +1,5 @@
{
"_": "Missing Localizations: 1491",
"_": "Missing Localizations: 1494",
"_": "->------------------------] Game Elements [------------------------<-",
@ -1423,6 +1423,10 @@
"create.track.not_enough_tracks": "UNLOCALIZED: Not holding enough tracks",
"create.track.not_enough_pavement": "UNLOCALIZED: Not holding enough pavement blocks",
"create.portal_track.failed": "UNLOCALIZED: Cannot place portal track:",
"create.portal_track.missing": "UNLOCALIZED: Target portal not generated yet",
"create.portal_track.blocked": "UNLOCALIZED: Target location blocked (%1$s,%2$s,%3$s)",
"create.station.create_train": "UNLOCALIZED: Create new Train",
"create.station.disassemble_train": "UNLOCALIZED: Disassemble Train",
"create.station.remove_schedule": "UNLOCALIZED: Retrieve Schedule",

View file

@ -1,5 +1,5 @@
{
"_": "Missing Localizations: 228",
"_": "Missing Localizations: 231",
"_": "->------------------------] Game Elements [------------------------<-",
@ -1423,6 +1423,10 @@
"create.track.not_enough_tracks": "UNLOCALIZED: Not holding enough tracks",
"create.track.not_enough_pavement": "UNLOCALIZED: Not holding enough pavement blocks",
"create.portal_track.failed": "UNLOCALIZED: Cannot place portal track:",
"create.portal_track.missing": "UNLOCALIZED: Target portal not generated yet",
"create.portal_track.blocked": "UNLOCALIZED: Target location blocked (%1$s,%2$s,%3$s)",
"create.station.create_train": "UNLOCALIZED: Create new Train",
"create.station.disassemble_train": "UNLOCALIZED: Disassemble Train",
"create.station.remove_schedule": "UNLOCALIZED: Retrieve Schedule",

View file

@ -1,5 +1,5 @@
{
"_": "Missing Localizations: 228",
"_": "Missing Localizations: 231",
"_": "->------------------------] Game Elements [------------------------<-",
@ -1423,6 +1423,10 @@
"create.track.not_enough_tracks": "UNLOCALIZED: Not holding enough tracks",
"create.track.not_enough_pavement": "UNLOCALIZED: Not holding enough pavement blocks",
"create.portal_track.failed": "UNLOCALIZED: Cannot place portal track:",
"create.portal_track.missing": "UNLOCALIZED: Target portal not generated yet",
"create.portal_track.blocked": "UNLOCALIZED: Target location blocked (%1$s,%2$s,%3$s)",
"create.station.create_train": "UNLOCALIZED: Create new Train",
"create.station.disassemble_train": "UNLOCALIZED: Disassemble Train",
"create.station.remove_schedule": "UNLOCALIZED: Retrieve Schedule",

View file

@ -1,5 +1,5 @@
{
"_": "Missing Localizations: 2154",
"_": "Missing Localizations: 2157",
"_": "->------------------------] Game Elements [------------------------<-",
@ -1423,6 +1423,10 @@
"create.track.not_enough_tracks": "UNLOCALIZED: Not holding enough tracks",
"create.track.not_enough_pavement": "UNLOCALIZED: Not holding enough pavement blocks",
"create.portal_track.failed": "UNLOCALIZED: Cannot place portal track:",
"create.portal_track.missing": "UNLOCALIZED: Target portal not generated yet",
"create.portal_track.blocked": "UNLOCALIZED: Target location blocked (%1$s,%2$s,%3$s)",
"create.station.create_train": "UNLOCALIZED: Create new Train",
"create.station.disassemble_train": "UNLOCALIZED: Disassemble Train",
"create.station.remove_schedule": "UNLOCALIZED: Retrieve Schedule",

View file

@ -1,5 +1,5 @@
{
"_": "Missing Localizations: 601",
"_": "Missing Localizations: 604",
"_": "->------------------------] Game Elements [------------------------<-",
@ -1423,6 +1423,10 @@
"create.track.not_enough_tracks": "UNLOCALIZED: Not holding enough tracks",
"create.track.not_enough_pavement": "UNLOCALIZED: Not holding enough pavement blocks",
"create.portal_track.failed": "UNLOCALIZED: Cannot place portal track:",
"create.portal_track.missing": "UNLOCALIZED: Target portal not generated yet",
"create.portal_track.blocked": "UNLOCALIZED: Target location blocked (%1$s,%2$s,%3$s)",
"create.station.create_train": "UNLOCALIZED: Create new Train",
"create.station.disassemble_train": "UNLOCALIZED: Disassemble Train",
"create.station.remove_schedule": "UNLOCALIZED: Retrieve Schedule",

View file

@ -1,5 +1,5 @@
{
"_": "Missing Localizations: 1402",
"_": "Missing Localizations: 1405",
"_": "->------------------------] Game Elements [------------------------<-",
@ -1423,6 +1423,10 @@
"create.track.not_enough_tracks": "UNLOCALIZED: Not holding enough tracks",
"create.track.not_enough_pavement": "UNLOCALIZED: Not holding enough pavement blocks",
"create.portal_track.failed": "UNLOCALIZED: Cannot place portal track:",
"create.portal_track.missing": "UNLOCALIZED: Target portal not generated yet",
"create.portal_track.blocked": "UNLOCALIZED: Target location blocked (%1$s,%2$s,%3$s)",
"create.station.create_train": "UNLOCALIZED: Create new Train",
"create.station.disassemble_train": "UNLOCALIZED: Disassemble Train",
"create.station.remove_schedule": "UNLOCALIZED: Retrieve Schedule",

View file

@ -1,5 +1,5 @@
{
"_": "Missing Localizations: 1774",
"_": "Missing Localizations: 1777",
"_": "->------------------------] Game Elements [------------------------<-",
@ -1423,6 +1423,10 @@
"create.track.not_enough_tracks": "UNLOCALIZED: Not holding enough tracks",
"create.track.not_enough_pavement": "UNLOCALIZED: Not holding enough pavement blocks",
"create.portal_track.failed": "UNLOCALIZED: Cannot place portal track:",
"create.portal_track.missing": "UNLOCALIZED: Target portal not generated yet",
"create.portal_track.blocked": "UNLOCALIZED: Target location blocked (%1$s,%2$s,%3$s)",
"create.station.create_train": "UNLOCALIZED: Create new Train",
"create.station.disassemble_train": "UNLOCALIZED: Disassemble Train",
"create.station.remove_schedule": "UNLOCALIZED: Retrieve Schedule",

View file

@ -1,5 +1,5 @@
{
"_": "Missing Localizations: 229",
"_": "Missing Localizations: 232",
"_": "->------------------------] Game Elements [------------------------<-",
@ -1423,6 +1423,10 @@
"create.track.not_enough_tracks": "UNLOCALIZED: Not holding enough tracks",
"create.track.not_enough_pavement": "UNLOCALIZED: Not holding enough pavement blocks",
"create.portal_track.failed": "UNLOCALIZED: Cannot place portal track:",
"create.portal_track.missing": "UNLOCALIZED: Target portal not generated yet",
"create.portal_track.blocked": "UNLOCALIZED: Target location blocked (%1$s,%2$s,%3$s)",
"create.station.create_train": "UNLOCALIZED: Create new Train",
"create.station.disassemble_train": "UNLOCALIZED: Disassemble Train",
"create.station.remove_schedule": "UNLOCALIZED: Retrieve Schedule",

View file

@ -1,5 +1,5 @@
{
"_": "Missing Localizations: 606",
"_": "Missing Localizations: 609",
"_": "->------------------------] Game Elements [------------------------<-",
@ -1423,6 +1423,10 @@
"create.track.not_enough_tracks": "UNLOCALIZED: Not holding enough tracks",
"create.track.not_enough_pavement": "UNLOCALIZED: Not holding enough pavement blocks",
"create.portal_track.failed": "UNLOCALIZED: Cannot place portal track:",
"create.portal_track.missing": "UNLOCALIZED: Target portal not generated yet",
"create.portal_track.blocked": "UNLOCALIZED: Target location blocked (%1$s,%2$s,%3$s)",
"create.station.create_train": "UNLOCALIZED: Create new Train",
"create.station.disassemble_train": "UNLOCALIZED: Disassemble Train",
"create.station.remove_schedule": "UNLOCALIZED: Retrieve Schedule",

View file

@ -1,5 +1,5 @@
{
"_": "Missing Localizations: 228",
"_": "Missing Localizations: 231",
"_": "->------------------------] Game Elements [------------------------<-",
@ -1423,6 +1423,10 @@
"create.track.not_enough_tracks": "UNLOCALIZED: Not holding enough tracks",
"create.track.not_enough_pavement": "UNLOCALIZED: Not holding enough pavement blocks",
"create.portal_track.failed": "UNLOCALIZED: Cannot place portal track:",
"create.portal_track.missing": "UNLOCALIZED: Target portal not generated yet",
"create.portal_track.blocked": "UNLOCALIZED: Target location blocked (%1$s,%2$s,%3$s)",
"create.station.create_train": "UNLOCALIZED: Create new Train",
"create.station.disassemble_train": "UNLOCALIZED: Disassemble Train",
"create.station.remove_schedule": "UNLOCALIZED: Retrieve Schedule",

View file

@ -1,5 +1,5 @@
{
"_": "Missing Localizations: 620",
"_": "Missing Localizations: 623",
"_": "->------------------------] Game Elements [------------------------<-",
@ -1423,6 +1423,10 @@
"create.track.not_enough_tracks": "UNLOCALIZED: Not holding enough tracks",
"create.track.not_enough_pavement": "UNLOCALIZED: Not holding enough pavement blocks",
"create.portal_track.failed": "UNLOCALIZED: Cannot place portal track:",
"create.portal_track.missing": "UNLOCALIZED: Target portal not generated yet",
"create.portal_track.blocked": "UNLOCALIZED: Target location blocked (%1$s,%2$s,%3$s)",
"create.station.create_train": "UNLOCALIZED: Create new Train",
"create.station.disassemble_train": "UNLOCALIZED: Disassemble Train",
"create.station.remove_schedule": "UNLOCALIZED: Retrieve Schedule",

View file

@ -17,6 +17,7 @@ import java.util.Map.Entry;
import java.util.Random;
import java.util.function.Consumer;
import com.google.common.base.Predicates;
import com.jozufozu.flywheel.core.PartialModel;
import com.jozufozu.flywheel.util.transform.TransformStack;
import com.mojang.blaze3d.vertex.PoseStack;
@ -40,15 +41,19 @@ import com.simibubi.create.foundation.block.render.ReducedDestroyEffects;
import com.simibubi.create.foundation.utility.AngleHelper;
import com.simibubi.create.foundation.utility.BlockFace;
import com.simibubi.create.foundation.utility.Iterate;
import com.simibubi.create.foundation.utility.Lang;
import com.simibubi.create.foundation.utility.Pair;
import com.simibubi.create.foundation.utility.VecHelper;
import net.minecraft.ChatFormatting;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.renderer.LevelRenderer;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.Direction.Axis;
import net.minecraft.core.Direction.AxisDirection;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.resources.ResourceKey;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerLevel;
@ -193,6 +198,8 @@ public class TrackBlock extends Block implements EntityBlock, IWrenchable, ITrac
return;
boolean pop = false;
String fail = null;
BlockPos failPos = null;
for (Direction d : Iterate.directionsInAxis(portalTest)) {
BlockPos portalPos = pos.relative(d);
@ -202,16 +209,21 @@ public class TrackBlock extends Block implements EntityBlock, IWrenchable, ITrac
pop = true;
Pair<ServerLevel, BlockFace> otherSide = getOtherSide(level, new BlockFace(pos, d));
if (otherSide == null)
if (otherSide == null) {
fail = "missing";
continue;
}
ServerLevel otherLevel = otherSide.getFirst();
BlockFace otherTrack = otherSide.getSecond();
BlockPos otherTrackPos = otherTrack.getPos();
BlockState existing = otherLevel.getBlockState(otherTrackPos);
if (!existing.getMaterial()
.isReplaceable())
.isReplaceable()) {
fail = "blocked";
failPos = otherTrackPos;
continue;
}
level.setBlock(pos, state.setValue(SHAPE, TrackShape.asPortal(d))
.setValue(HAS_TE, true), 3);
@ -228,8 +240,23 @@ public class TrackBlock extends Block implements EntityBlock, IWrenchable, ITrac
pop = false;
}
if (pop)
level.destroyBlock(pos, true);
if (!pop)
return;
level.destroyBlock(pos, true);
if (fail == null)
return;
Player player = level.getNearestPlayer(pos.getX(), pos.getY(), pos.getZ(), 10, Predicates.alwaysTrue());
if (player == null)
return;
player.displayClientMessage(new TextComponent("<!> ").append(Lang.translate("portal_track.failed"))
.withStyle(ChatFormatting.GOLD), false);
MutableComponent component =
failPos != null ? Lang.translate("portal_track." + fail, failPos.getX(), failPos.getY(), failPos.getZ())
: Lang.translate("portal_track." + fail);
player.displayClientMessage(new TextComponent(" - ").withStyle(ChatFormatting.GRAY)
.append(component.withStyle(st -> st.withColor(0xFFD3B4))), false);
}
protected Pair<ServerLevel, BlockFace> getOtherSide(ServerLevel level, BlockFace inboundTrack) {

View file

@ -645,6 +645,10 @@
"create.track.not_enough_tracks": "Not holding enough tracks",
"create.track.not_enough_pavement": "Not holding enough pavement blocks",
"create.portal_track.failed": "Cannot place portal track:",
"create.portal_track.missing": "Target portal not generated yet",
"create.portal_track.blocked": "Target location blocked (%1$s,%2$s,%3$s)",
"create.station.create_train": "Create new Train",
"create.station.disassemble_train": "Disassemble Train",
"create.station.remove_schedule": "Retrieve Schedule",