返回提交历史
Modified
gradle.properties
+1
-1
Modified
src/main/java/com/xfestudio/mydimension/MyDimension.java
+2
-0
Modified
src/main/java/com/xfestudio/mydimension/client/RiftActionScreen.java
+91
-57
Added
src/main/java/com/xfestudio/mydimension/registry/ModChunkGenerators.java
+17
-0
Added
src/main/java/com/xfestudio/mydimension/world/NoStructureNoiseChunkGenerator.java
+35
-0
Modified
src/main/resources/assets/mydimension/lang/zh_cn.json
+6
-3
Modified
src/main/resources/data/mydimension/dimension/mirror_mind.json
+1
-1
XFEstudio/MyDimension
修复部分已知UI问题 已禁止镜之心境生成建筑
2c75fc2
代码差异
7 个文件
+153
-62
@@ -11,7 +11,7 @@ loader_version_range=[47,)
11
11
mod_id=mydimension
12
12
mod_name=\u6211\u7684\u7ef4\u5ea6
13
13
mod_license=CC0-1.0
14
mod_version=1.3.5
14
mod_version=1.3.6
15
15
mod_group_id=com.xfestudio.mydimension
16
16
maven_group=com.xfestudio
17
17
archives_base_name=mydimension
@@ -2,6 +2,7 @@ package com.xfestudio.mydimension;
2
2
3
3
import com.mojang.logging.LogUtils;
4
4
import com.xfestudio.mydimension.network.ModNetwork;
5
import com.xfestudio.mydimension.registry.ModChunkGenerators;
5
6
import com.xfestudio.mydimension.registry.ModEntities;
6
7
import com.xfestudio.mydimension.registry.ModItems;
7
8
import net.minecraftforge.common.MinecraftForge;
@@ -21,6 +22,7 @@ public class MyDimension {
21
22
22
23
ModEntities.register(modEventBus);
23
24
ModItems.register(modEventBus);
25
ModChunkGenerators.CHUNK_GENERATORS.register(modEventBus);
24
26
modEventBus.addListener(ModItems::addCreative);
25
27
modEventBus.addListener(this::commonSetup);
26
28
MinecraftForge.EVENT_BUS.register(new MyDimensionEvents());
@@ -1,27 +1,34 @@
1
1
package com.xfestudio.mydimension.client;
2
2
3
import com.xfestudio.mydimension.MyDimension;
3
4
import com.xfestudio.mydimension.item.RiftAction;
4
5
import com.xfestudio.mydimension.item.RiftItem;
5
6
import com.xfestudio.mydimension.network.ModNetwork;
6
7
import com.xfestudio.mydimension.network.SetRiftActionPacket;
7
8
import com.xfestudio.mydimension.registry.ModItems;
9
import com.xfestudio.mydimension.world.ModDimensions;
8
10
import net.minecraft.client.Minecraft;
9
11
import net.minecraft.client.gui.Font;
10
12
import net.minecraft.client.gui.GuiGraphics;
11
13
import net.minecraft.client.gui.components.Button;
12
14
import net.minecraft.client.gui.screens.Screen;
13
15
import net.minecraft.network.chat.Component;
16
import net.minecraft.resources.ResourceLocation;
14
17
import net.minecraft.util.Mth;
15
18
import net.minecraft.world.item.ItemStack;
16
19
17
20
public class RiftActionScreen extends Screen {
18
private static final int BUTTON_WIDTH = 104;
19
private static final int BUTTON_HEIGHT = 22;
20
private static final int INNER_RADIUS = 76;
21
private static final int OUTER_RADIUS = 122;
21
private static final int BUTTON_HEIGHT = 26;
22
private static final int BUTTON_GAP = 22;
23
private static final int ROW_GAP = 82;
22
24
private static final int TRAVEL_COLOR = 0xFF3E8DB8;
23
25
private static final int MOB_COLOR = 0xFF8B58C8;
24
26
private static final int ANCHOR_COLOR = 0xFFD6A23E;
27
private static final ResourceLocation RIFT_ICON = new ResourceLocation(MyDimension.MOD_ID, "textures/item/rift.png");
28
private static final ResourceLocation PORTAL_ICON = new ResourceLocation("minecraft", "textures/block/nether_portal.png");
29
private static final ResourceLocation ANCHOR_ICON = new ResourceLocation(MyDimension.MOD_ID, "textures/entity/rift_anchor.png");
30
31
private boolean inMindDimension;
25
32
26
33
public RiftActionScreen() {
27
34
super(Component.translatable("screen.mydimension.rift_actions"));
@@ -29,27 +36,33 @@ public class RiftActionScreen extends Screen {
29
36
30
37
@Override
31
38
protected void init() {
32
int centerX = width / 2;
33
int centerY = height / 2;
34
35
addActionButton(RiftAction.ETHEREAL_MIND, centerX, centerY, -90.0D, INNER_RADIUS);
36
addActionButton(RiftAction.MIRROR_MIND, centerX, centerY, 0.0D, INNER_RADIUS);
37
addActionButton(RiftAction.WATER_MIND, centerX, centerY, 90.0D, INNER_RADIUS);
38
addActionButton(RiftAction.NATURE_MIND, centerX, centerY, 180.0D, INNER_RADIUS);
39
40
addActionButton(RiftAction.SEND_MOB_ETHEREAL, centerX, centerY, -135.0D, OUTER_RADIUS);
41
addActionButton(RiftAction.SEND_MOB_MIRROR, centerX, centerY, -45.0D, OUTER_RADIUS);
42
addActionButton(RiftAction.SEND_MOB_WATER, centerX, centerY, 45.0D, OUTER_RADIUS);
43
addActionButton(RiftAction.SEND_MOB_NATURE, centerX, centerY, 135.0D, OUTER_RADIUS);
44
45
addRenderableWidget(new ActionButton(centerX - BUTTON_WIDTH / 2, centerY + 33, RiftAction.SET_ANCHOR, getSelectedAction() == RiftAction.SET_ANCHOR));
39
inMindDimension = minecraft != null && minecraft.player != null && ModDimensions.isMindDimension(minecraft.player.level().dimension());
40
41
RiftAction[] travelActions = new RiftAction[] {
42
RiftAction.ETHEREAL_MIND,
43
RiftAction.MIRROR_MIND,
44
RiftAction.WATER_MIND,
45
RiftAction.NATURE_MIND
46
};
47
addActionRow(travelActions, height / 2 - ROW_GAP);
48
49
if (inMindDimension) {
50
addCenteredActionButton(RiftAction.SET_ANCHOR, height / 2 + ROW_GAP - BUTTON_HEIGHT / 2);
51
} else {
52
addActionRow(new RiftAction[] {
53
RiftAction.SEND_MOB_ETHEREAL,
54
RiftAction.SEND_MOB_MIRROR,
55
RiftAction.SEND_MOB_WATER,
56
RiftAction.SEND_MOB_NATURE
57
}, height / 2 + ROW_GAP);
58
}
46
59
}
47
60
48
61
@Override
49
62
public void render(GuiGraphics graphics, int mouseX, int mouseY, float partialTick) {
50
63
graphics.fillGradient(0, 0, width, height, 0xD0101218, 0xE0181026);
51
64
renderCenterPanel(graphics);
52
renderRingHints(graphics);
65
renderGuideLines(graphics);
53
66
super.render(graphics, mouseX, mouseY, partialTick);
54
67
}
55
68
@@ -58,29 +71,53 @@ public class RiftActionScreen extends Screen {
58
71
return false;
59
72
}
60
73
61
private void addActionButton(RiftAction action, int centerX, int centerY, double degrees, int radius) {
62
double radians = Math.toRadians(degrees);
63
int x = centerX + (int) Math.round(Math.cos(radians) * radius) - BUTTON_WIDTH / 2;
64
int y = centerY + (int) Math.round(Math.sin(radians) * radius) - BUTTON_HEIGHT / 2;
65
addRenderableWidget(new ActionButton(x, y, action, getSelectedAction() == action));
74
private void addActionRow(RiftAction[] actions, int centerY) {
75
int columns = actions.length;
76
int buttonWidth = rowButtonWidth(columns);
77
int totalWidth = columns * buttonWidth + (columns - 1) * BUTTON_GAP;
78
int x = width / 2 - totalWidth / 2;
79
int y = centerY - BUTTON_HEIGHT / 2;
80
81
for (RiftAction action : actions) {
82
addRenderableWidget(new ActionButton(x, y, buttonWidth, action, getSelectedAction() == action));
83
x += buttonWidth + BUTTON_GAP;
84
}
85
}
86
87
private void addCenteredActionButton(RiftAction action, int y) {
88
int buttonWidth = Mth.clamp(width / 4, 132, 176);
89
addRenderableWidget(new ActionButton(width / 2 - buttonWidth / 2, y, buttonWidth, action, getSelectedAction() == action));
90
}
91
92
private int rowButtonWidth(int columns) {
93
int available = Math.max(96, width - 64);
94
int maxByWidth = (available - (columns - 1) * BUTTON_GAP) / columns;
95
return Mth.clamp(maxByWidth, 92, 150);
66
96
}
67
97
68
98
private void renderCenterPanel(GuiGraphics graphics) {
69
99
int centerX = width / 2;
70
100
int centerY = height / 2;
71
fillRoundedRect(graphics, centerX - 56, centerY - 40, centerX + 56, centerY + 62, 5, 0xAA070A10);
72
drawRoundedBorder(graphics, centerX - 56, centerY - 40, centerX + 56, centerY + 62, 5, 0xFF85D6F7);
73
graphics.drawCenteredString(font, title, centerX, centerY - 23, 0xFFEAFBFF);
74
graphics.drawCenteredString(font, Component.translatable("screen.mydimension.rift_actions.travel"), centerX, centerY - 5, 0xFF9DDBFF);
75
graphics.drawCenteredString(font, Component.translatable("screen.mydimension.rift_actions.mob"), centerX, centerY + 10, 0xFFD0B6FF);
76
graphics.drawCenteredString(font, Component.translatable("screen.mydimension.rift_actions.anchor"), centerX, centerY + 25, 0xFFFFE0A3);
101
int left = centerX - 90;
102
int top = centerY - 37;
103
int right = centerX + 90;
104
int bottom = centerY + 37;
105
106
fillRoundedRect(graphics, left, top, right, bottom, 7, 0xB0060A12);
107
drawRoundedBorder(graphics, left, top, right, bottom, 7, 0xFF85D6F7);
108
graphics.drawCenteredString(font, title, centerX, centerY - 25, 0xFFEAFBFF);
109
110
Component mode = Component.translatable(inMindDimension ? "screen.mydimension.rift_actions.mode_mind" : "screen.mydimension.rift_actions.mode_outside");
111
Component selected = Component.translatable("screen.mydimension.rift_actions.selected", getSelectedAction().displayName());
112
graphics.drawCenteredString(font, mode, centerX, centerY - 4, inMindDimension ? 0xFFFFE0A3 : 0xFFD0B6FF);
113
graphics.drawCenteredString(font, selected, centerX, centerY + 14, 0xFF9DDBFF);
77
114
}
78
115
79
private void renderRingHints(GuiGraphics graphics) {
116
private void renderGuideLines(GuiGraphics graphics) {
80
117
int centerX = width / 2;
81
118
int centerY = height / 2;
82
drawDiamond(graphics, centerX, centerY, INNER_RADIUS + 30, 0x4485D6F7);
83
drawDiamond(graphics, centerX, centerY, OUTER_RADIUS + 30, 0x447F53B9);
119
graphics.fill(centerX - 1, centerY - ROW_GAP + BUTTON_HEIGHT / 2 + 8, centerX + 1, centerY - 43, 0x4485D6F7);
120
graphics.fill(centerX - 1, centerY + 43, centerX + 1, centerY + ROW_GAP - BUTTON_HEIGHT / 2 - 8, inMindDimension ? 0x55FFE0A3 : 0x447F53B9);
84
121
}
85
122
86
123
private RiftAction getSelectedAction() {
@@ -104,13 +141,6 @@ public class RiftActionScreen extends Screen {
104
141
}
105
142
}
106
143
107
private static void drawBorder(GuiGraphics graphics, int left, int top, int right, int bottom, int color) {
108
graphics.fill(left, top, right, top + 1, color);
109
graphics.fill(left, bottom - 1, right, bottom, color);
110
graphics.fill(left, top, left + 1, bottom, color);
111
graphics.fill(right - 1, top, right, bottom, color);
112
}
113
114
144
private static void fillRoundedRect(GuiGraphics graphics, int left, int top, int right, int bottom, int radius, int color) {
115
145
graphics.fill(left + radius, top, right - radius, bottom, color);
116
146
graphics.fill(left, top + radius, right, bottom - radius, color);
@@ -130,19 +160,12 @@ public class RiftActionScreen extends Screen {
130
160
graphics.fill(right - radius, bottom - 2, right - 1, bottom - 1, color);
131
161
}
132
162
133
private static void drawDiamond(GuiGraphics graphics, int centerX, int centerY, int radius, int color) {
134
graphics.fill(centerX - 1, centerY - radius, centerX + 1, centerY - radius + 2, color);
135
graphics.fill(centerX + radius - 1, centerY - 1, centerX + radius + 1, centerY + 1, color);
136
graphics.fill(centerX - 1, centerY + radius - 2, centerX + 1, centerY + radius, color);
137
graphics.fill(centerX - radius, centerY - 1, centerX - radius + 2, centerY + 1, color);
138
}
139
140
163
private class ActionButton extends Button {
141
164
private final RiftAction action;
142
165
private final boolean selected;
143
166
144
private ActionButton(int x, int y, RiftAction action, boolean selected) {
145
super(x, y, BUTTON_WIDTH, BUTTON_HEIGHT, action.displayName(), button -> select(action), DEFAULT_NARRATION);
167
private ActionButton(int x, int y, int width, RiftAction action, boolean selected) {
168
super(x, y, width, BUTTON_HEIGHT, action.displayName(), button -> select(action), DEFAULT_NARRATION);
146
169
this.action = action;
147
170
this.selected = selected;
148
171
}
@@ -157,15 +180,26 @@ public class RiftActionScreen extends Screen {
157
180
int fill = withAlpha(base, isHoveredOrFocused() ? 226 : 174);
158
181
int edge = selected ? 0xFFFFF4A8 : (action == RiftAction.SET_ANCHOR ? 0xFFFFE0A3 : (action.sendsMob() ? 0xFFD8C1FF : 0xFFB8F0FF));
159
182
160
fillRoundedRect(graphics, left, top, right, bottom, 5, darken(fill));
161
fillRoundedRect(graphics, left + 1, top + 1, right - 1, bottom - 1, 4, fill);
162
drawRoundedBorder(graphics, left, top, right, bottom, 5, edge);
183
fillRoundedRect(graphics, left, top, right, bottom, 7, darken(fill));
184
fillRoundedRect(graphics, left + 1, top + 1, right - 1, bottom - 1, 6, fill);
185
drawRoundedBorder(graphics, left, top, right, bottom, 7, edge);
163
186
if (selected) {
164
fillRoundedRect(graphics, left + 3, top + 4, left + 7, bottom - 4, 2, 0xFFFFF4A8);
187
fillRoundedRect(graphics, left + 4, top + 5, left + 8, bottom - 5, 2, 0xFFFFF4A8);
165
188
}
166
189
190
renderIcon(graphics, left + 10, top + 5);
167
191
int textColor = isHoveredOrFocused() ? 0xFFFFFFFF : 0xFFEAFBFF;
168
drawCenteredFittingText(graphics, Minecraft.getInstance().font, getMessage(), left, top, getWidth(), getHeight(), textColor);
192
drawFittingText(graphics, Minecraft.getInstance().font, getMessage(), left + 32, top, getWidth() - 38, getHeight(), textColor);
193
}
194
195
private void renderIcon(GuiGraphics graphics, int x, int y) {
196
if (action == RiftAction.SET_ANCHOR) {
197
graphics.blit(ANCHOR_ICON, x, y, 0, 0, 16, 16, 32, 32);
198
} else if (action.sendsMob()) {
199
graphics.blit(PORTAL_ICON, x, y, 0, 0, 16, 16, 16, 512);
200
} else {
201
graphics.blit(RIFT_ICON, x, y, 0, 0, 16, 16, 16, 16);
202
}
169
203
}
170
204
171
205
private int withAlpha(int color, int alpha) {
@@ -180,9 +214,9 @@ public class RiftActionScreen extends Screen {
180
214
return alpha | (red << 16) | (green << 8) | blue;
181
215
}
182
216
183
private void drawCenteredFittingText(GuiGraphics graphics, Font font, Component text, int left, int top, int width, int height, int color) {
184
String label = font.plainSubstrByWidth(text.getString(), width - 10);
185
graphics.drawCenteredString(font, label, left + width / 2, top + (height - 8) / 2, color);
217
private void drawFittingText(GuiGraphics graphics, Font font, Component text, int left, int top, int width, int height, int color) {
218
String label = font.plainSubstrByWidth(text.getString(), width);
219
graphics.drawString(font, label, left, top + (height - 8) / 2, color);
186
220
}
187
221
}
188
222
}
@@ -0,0 +1,17 @@
1
package com.xfestudio.mydimension.registry;
2
3
import com.mojang.serialization.Codec;
4
import com.xfestudio.mydimension.MyDimension;
5
import com.xfestudio.mydimension.world.NoStructureNoiseChunkGenerator;
6
import net.minecraft.core.registries.Registries;
7
import net.minecraft.world.level.chunk.ChunkGenerator;
8
import net.minecraftforge.registries.DeferredRegister;
9
import net.minecraftforge.registries.RegistryObject;
10
11
public class ModChunkGenerators {
12
public static final DeferredRegister<Codec<? extends ChunkGenerator>> CHUNK_GENERATORS =
13
DeferredRegister.create(Registries.CHUNK_GENERATOR, MyDimension.MOD_ID);
14
15
public static final RegistryObject<Codec<? extends ChunkGenerator>> NO_STRUCTURE_NOISE =
16
CHUNK_GENERATORS.register("no_structure_noise", () -> NoStructureNoiseChunkGenerator.CODEC);
17
}
@@ -0,0 +1,35 @@
1
package com.xfestudio.mydimension.world;
2
3
import com.mojang.serialization.Codec;
4
import com.mojang.serialization.codecs.RecordCodecBuilder;
5
import java.util.stream.Stream;
6
import net.minecraft.core.Holder;
7
import net.minecraft.core.HolderLookup;
8
import net.minecraft.world.level.biome.BiomeSource;
9
import net.minecraft.world.level.chunk.ChunkGenerator;
10
import net.minecraft.world.level.chunk.ChunkGeneratorStructureState;
11
import net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator;
12
import net.minecraft.world.level.levelgen.NoiseGeneratorSettings;
13
import net.minecraft.world.level.levelgen.RandomState;
14
import net.minecraft.world.level.levelgen.structure.StructureSet;
15
16
public class NoStructureNoiseChunkGenerator extends NoiseBasedChunkGenerator {
17
public static final Codec<NoStructureNoiseChunkGenerator> CODEC = RecordCodecBuilder.create(instance -> instance.group(
18
BiomeSource.CODEC.fieldOf("biome_source").forGetter(generator -> generator.biomeSource),
19
NoiseGeneratorSettings.CODEC.fieldOf("settings").forGetter(NoStructureNoiseChunkGenerator::generatorSettings)
20
).apply(instance, instance.stable(NoStructureNoiseChunkGenerator::new)));
21
22
public NoStructureNoiseChunkGenerator(BiomeSource biomeSource, Holder<NoiseGeneratorSettings> settings) {
23
super(biomeSource, settings);
24
}
25
26
@Override
27
protected Codec<? extends ChunkGenerator> codec() {
28
return CODEC;
29
}
30
31
@Override
32
public ChunkGeneratorStructureState createState(HolderLookup<StructureSet> structureSets, RandomState randomState, long seed) {
33
return ChunkGeneratorStructureState.createForFlat(randomState, seed, this.biomeSource, Stream.empty());
34
}
35
}
@@ -5,9 +5,12 @@
5
5
"dimension.mydimension.water_mind": "水之心境",
6
6
"dimension.mydimension.nature_mind": "自然心境",
7
7
"screen.mydimension.rift_actions": "裂罅",
8
"screen.mydimension.rift_actions.travel": "内环:前往心境",
9
"screen.mydimension.rift_actions.mob": "外环:传送生物",
10
"screen.mydimension.rift_actions.anchor": "中心:设置锚点",
8
"screen.mydimension.rift_actions.travel": "前往心境",
9
"screen.mydimension.rift_actions.mob": "传送生物",
10
"screen.mydimension.rift_actions.anchor": "设置锚点",
11
"screen.mydimension.rift_actions.mode_mind": "心境内:前往或设置锚点",
12
"screen.mydimension.rift_actions.mode_outside": "外界:前往或传送生物",
13
"screen.mydimension.rift_actions.selected": "当前:%s",
11
14
"action.mydimension.ethereal_mind": "前往空灵心境",
12
15
"action.mydimension.mirror_mind": "前往镜之心境",
13
16
"action.mydimension.water_mind": "前往水之心境",
@@ -1,7 +1,7 @@
1
1
{
2
2
"type": "mydimension:mirror_mind",
3
3
"generator": {
4
"type": "minecraft:noise",
4
"type": "mydimension:no_structure_noise",
5
5
"biome_source": {
6
6
"type": "minecraft:multi_noise",
7
7
"preset": "minecraft:overworld"