Skip to content

Commit 850dfe4

Browse files
committed
Config
1 parent 75e97bd commit 850dfe4

13 files changed

Lines changed: 155 additions & 54 deletions

File tree

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
// 1.21.1 2025-03-27T11:54:30.066302 Languages: en_us for mod: nexus
2-
40da030d5a31d9503615b5cedb905220a4212fa7 assets/nexus/lang/en_us.json
1+
// 1.21.1 2025-03-29T11:59:34.3914988 Languages: en_us for mod: nexus
2+
958333902e452acb3663e72f6ac80c6fb3413297 assets/nexus/lang/en_us.json

src/generated/resources/assets/nexus/lang/en_us.json

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,17 @@
7272
"block.nexus.yellow_nexus_portal": "Yellow Nexus Portal",
7373
"config.jade.plugin_nexus.nexus_portal": "Nexus Portal",
7474
"config.jade.plugin_nexus.nexus_portal_core": "Nexus Portal Core",
75+
"config.nexus.diamond_portal_core_coordinate_scale": "Diamond Portal Core Coordinate Scale",
76+
"config.nexus.gold_portal_core_coordinate_scale": "Gold Portal Core Coordinate Scale",
77+
"config.nexus.iron_portal_core_coordinate_scale": "Iron Portal Core Coordinate Scale",
78+
"config.nexus.max_portal_size": "Max Portal Size",
79+
"config.nexus.netherite_portal_core_coordinate_scale": "Netherite Portal Core Coordinate Scale",
80+
"config.nexus.portal_core_camo": "Portal Core Camo",
81+
"config.nexus.portal_core_coordinate_scale": "Portal Core Coordinate Scale",
82+
"config.nexus.portal_core_hud_overlay": "Portal Core HUD Overlay",
83+
"config.nexus.portal_core_world_overlay": "Portal Core World Overlay",
84+
"config.nexus.portal_transition_time": "Portal Transition Time",
85+
"config.nexus.starlight_portal_core_coordinate_scale": "Starlight Portal Core Coordinate Scale",
7586
"description.nexus.chrono_upgrade_smithing_template": "Used to craft Chrono Shards. Found in Trial Chamber Chest & Vaults.",
7687
"description.nexus.nexus_portal_core": "Allows traversal to The Nexus. Each portal core has its own coordinate scale. The blocks traveled in The Nexus are multiplied by this scale when leaving the dimension. You can use it in an Anvil to give your portal a name when placed. You can also disguise this block as another by using with a held block.",
7788
"hover_text.nexus.nexus_portal_core": "Coordinate Scale",
@@ -92,12 +103,14 @@
92103
"message.nexus.generate_link.success": "New link generated successfully!",
93104
"message.nexus.invalid_destination": "Destination is outside the world border for that dimension! Removing invalid link...",
94105
"message.nexus.invalid_dimension": "Destination dimension could not be found!",
95-
"message.nexus.light_portal.invalid_frame": "Invalid frame!",
106+
"message.nexus.light_portal.invalid_frame": "Invalid frame! Make sure no non-full blocks are inside or make up the frame!",
107+
"message.nexus.light_portal.obstructed": "The projection position is obstructed!",
108+
"message.nexus.light_portal.overflowing_frame": "The frame size is too large!",
96109
"message.nexus.light_portal.success": "Successfully created portal!",
97110
"message.nexus.no_core": "Destination Nexus Portal Core could not be found! Removing invalid link...",
98111
"message.nexus.no_link": "Destination Nexus Portal Core is not linked to this one! Removing invalid link...",
99112
"message.nexus.teleport.locked_dimension": "You can't travel to this dimension. You haven't been there before!",
100-
"message.nexus.unlink.invalid_frame": "Successfully unlinked!",
113+
"message.nexus.unlink.success": "Successfully unlinked!",
101114
"message.nexus.unlock_dimension": "You can now travel to this dimension from The Nexus.",
102115
"networking.nexus.unlocked_dimension_list_message.failed": "Failed to synchronize unlocked dimension list! %s",
103116
"screen.nexus.nexus_portal_core.button.close.title": "Close",

src/main/java/com/calemi/ccore/api/scanner2/BlockScanner2.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public void setHalted(boolean halted) {
6565
}
6666

6767
/**
68-
* @param scannedLocation The currently scanned BlockPos.
68+
* @param scannedBlockPos The currently scanned BlockPos.
6969
* @return whether the scanner should collect this BlockPos or not.
7070
*/
7171
public abstract boolean shouldCollect(BlockPos scannedBlockPos);

src/main/java/com/calemi/nexus/block/NexusBlocks.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.calemi.nexus.block.wood.NexusWoodTypes;
44
import com.calemi.nexus.client.partclie.NexusParticles;
5+
import com.calemi.nexus.config.NexusConfig;
56
import com.calemi.nexus.item.NexusItems;
67
import com.calemi.nexus.block.family.NexusBlockSetTypes;
78
import com.calemi.nexus.main.Nexus;
@@ -29,22 +30,22 @@ public class NexusBlocks {
2930

3031

3132
public static final DeferredBlock<Block> NEXUS_PORTAL_CORE = regBlock("nexus_portal_core", () ->
32-
new NexusPortalCoreBlock(1));
33+
new NexusPortalCoreBlock(NexusConfig.server.portalCoreCoordinateScale));
3334

3435
public static final DeferredBlock<Block> IRON_NEXUS_PORTAL_CORE = regBlock("iron_nexus_portal_core", () ->
35-
new NexusPortalCoreBlock(8));
36+
new NexusPortalCoreBlock(NexusConfig.server.ironPortalCoreCoordinateScale));
3637

3738
public static final DeferredBlock<Block> GOLD_NEXUS_PORTAL_CORE = regBlock("gold_nexus_portal_core", () ->
38-
new NexusPortalCoreBlock(16));
39+
new NexusPortalCoreBlock(NexusConfig.server.goldPortalCoreCoordinateScale));
3940

4041
public static final DeferredBlock<Block> DIAMOND_NEXUS_PORTAL_CORE = regBlock("diamond_nexus_portal_core", () ->
41-
new NexusPortalCoreBlock(32));
42+
new NexusPortalCoreBlock(NexusConfig.server.diamondPortalCoreCoordinateScale));
4243

4344
public static final DeferredBlock<Block> NETHERITE_NEXUS_PORTAL_CORE = regBlock("netherite_nexus_portal_core", () ->
44-
new NexusPortalCoreBlock(64));
45+
new NexusPortalCoreBlock(NexusConfig.server.netheritePortalCoreCoordinateScale));
4546

4647
public static final DeferredBlock<Block> STARLIGHT_NEXUS_PORTAL_CORE = regBlock("starlight_nexus_portal_core", () ->
47-
new NexusPortalCoreBlock(128));
48+
new NexusPortalCoreBlock(NexusConfig.server.starlightPortalCoreCoordinateScale));
4849

4950

5051

src/main/java/com/calemi/nexus/block/NexusPortalBlock.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.calemi.nexus.blockentity.NexusPortalBlockEntity;
44
import com.calemi.nexus.blockentity.NexusPortalCoreBlockEntity;
5+
import com.calemi.nexus.config.NexusConfig;
56
import com.calemi.nexus.util.NexusLists;
67
import com.calemi.nexus.client.partclie.NexusParticles;
78
import com.mojang.serialization.MapCodec;
@@ -111,7 +112,7 @@ public Transition getLocalTransition() {
111112

112113
@Override
113114
public int getPortalTransitionTime(ServerLevel level, Entity entity) {
114-
return entity instanceof Player player ? player.getAbilities().invulnerable ? 1 : 80 : 0;
115+
return entity instanceof Player player ? player.getAbilities().invulnerable ? 1 : NexusConfig.server.portalTransitionTime.get() : 0;
115116
}
116117

117118
@Override

src/main/java/com/calemi/nexus/block/NexusPortalCoreBlock.java

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
package com.calemi.nexus.block;
22

33
import com.calemi.ccore.api.location.Location;
4+
import com.calemi.ccore.api.string.StringHelper;
5+
import com.calemi.nexus.blockentity.NexusBlockEntities;
46
import com.calemi.nexus.blockentity.NexusPortalCoreBlockEntity;
57
import com.calemi.nexus.main.Nexus;
6-
import com.calemi.nexus.blockentity.NexusBlockEntities;
7-
import com.calemi.nexus.world.dimension.NexusDimensions;
88
import com.calemi.nexus.screen.NexusPortalCoreScreen;
9-
import com.calemi.nexus.world.dimension.NexusDimensionHelper;
109
import com.calemi.nexus.util.NexusSoundHelper;
10+
import com.calemi.nexus.world.dimension.NexusDimensionHelper;
11+
import com.calemi.nexus.world.dimension.NexusDimensions;
1112
import com.mojang.serialization.MapCodec;
1213
import net.minecraft.ChatFormatting;
1314
import net.minecraft.client.Minecraft;
@@ -40,6 +41,7 @@
4041
import net.minecraft.world.level.storage.loot.LootParams;
4142
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
4243
import net.minecraft.world.phys.BlockHitResult;
44+
import net.neoforged.neoforge.common.ModConfigSpec;
4345
import org.jetbrains.annotations.Nullable;
4446

4547
import java.util.List;
@@ -51,15 +53,15 @@ public class NexusPortalCoreBlock extends AbstractCamoBlock {
5153

5254
public static final BooleanProperty POWERED = BlockStateProperties.POWERED;
5355

54-
private int coordinateScale;
56+
private ModConfigSpec.ConfigValue<Integer> configOption;
5557

56-
public NexusPortalCoreBlock(int coordinateScale) {
58+
public NexusPortalCoreBlock(ModConfigSpec.ConfigValue<Integer> configOption) {
5759
this(BlockBehaviour.Properties.of()
5860
.mapColor(MapColor.QUARTZ)
5961
.requiresCorrectToolForDrops()
6062
.noOcclusion()
6163
.strength(1.5F, 6.0F));
62-
this.coordinateScale = coordinateScale;
64+
this.configOption = configOption;
6365
registerDefaultState(stateDefinition.any().setValue(FACING, Direction.UP).setValue(AXIS, Direction.Axis.X).setValue(POWERED, false));
6466
}
6567

@@ -68,12 +70,12 @@ public NexusPortalCoreBlock(Properties properties) {
6870
}
6971

7072
public int getCoordinateScale() {
71-
return coordinateScale;
73+
return configOption.get();
7274
}
7375

7476
@Override
7577
public void appendHoverText(ItemStack stack, Item.TooltipContext context, List<Component> tooltipComponents, TooltipFlag tooltipFlag) {
76-
tooltipComponents.add(Component.translatable("hover_text.nexus.nexus_portal_core").append(": x" + getCoordinateScale()).withStyle(ChatFormatting.GRAY));
78+
tooltipComponents.add(Component.translatable("hover_text.nexus.nexus_portal_core").append(": x" + StringHelper.insertCommas(getCoordinateScale())).withStyle(ChatFormatting.GRAY));
7779
}
7880

7981
@Override
@@ -135,7 +137,7 @@ protected InteractionResult useWithoutItem(BlockState originState, Level level,
135137

136138
if (level.getBlockEntity(originPos) instanceof NexusPortalCoreBlockEntity originBlockEntity) {
137139

138-
if (player.isCrouching()) {
140+
if (player.isCrouching() && originBlockEntity.getCamoState() != null) {
139141

140142
originBlockEntity.setCamoState(null);
141143
originBlockEntity.setChanged();
@@ -179,6 +181,8 @@ protected ItemInteractionResult useItemOn(ItemStack stack, BlockState state, Lev
179181
@Override
180182
protected void neighborChanged(BlockState state, Level level, BlockPos pos, Block neighborBlock, BlockPos neighborPos, boolean movedByPiston) {
181183

184+
if (!level.isClientSide()) return;
185+
182186
if (level.getBlockEntity(pos) instanceof NexusPortalCoreBlockEntity blockEntity) {
183187

184188
if (level.getBlockState(blockEntity.getProjectionPosition()).getBlock() instanceof NexusPortalBlock portal) {

src/main/java/com/calemi/nexus/blockentity/NexusPortalCoreBlockEntity.java

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@
55
import com.calemi.nexus.block.NexusPortalBlock;
66
import com.calemi.nexus.block.NexusPortalCoreBlock;
77
import com.calemi.nexus.capability.NexusCapabilityHandler;
8-
import com.calemi.nexus.util.NexusMessengers;
98
import com.calemi.nexus.client.model.NexusPortalCoreBakedModel;
9+
import com.calemi.nexus.config.NexusConfig;
10+
import com.calemi.nexus.util.NexusMessengers;
11+
import com.calemi.nexus.util.NexusSoundHelper;
12+
import com.calemi.nexus.util.TeleportHelper;
1013
import com.calemi.nexus.util.scanner.PortalScanner;
1114
import com.calemi.nexus.util.scanner.PortalSpaceScanner;
1215
import com.calemi.nexus.world.dimension.NexusDimensionHelper;
13-
import com.calemi.nexus.util.NexusSoundHelper;
14-
import com.calemi.nexus.util.TeleportHelper;
1516
import net.minecraft.ChatFormatting;
1617
import net.minecraft.core.BlockPos;
1718
import net.minecraft.core.Direction;
@@ -39,6 +40,7 @@
3940
import net.minecraft.world.level.block.state.BlockState;
4041
import net.neoforged.neoforge.client.model.data.ModelData;
4142
import org.jetbrains.annotations.Nullable;
43+
4244
import java.util.HashMap;
4345
import java.util.List;
4446
import java.util.Map;
@@ -96,10 +98,12 @@ public void setCamoState(BlockState camoState) {
9698
}
9799

98100
public boolean isValidCamoState(BlockState state) {
101+
if (!NexusConfig.server.portalCoreCamo.get()) return false;
99102
if (state == null) return true;
100103
if (state.getBlock() == Blocks.AIR) return false;
101104
if (state.getBlock() instanceof NexusPortalCoreBlock) return false;
102105
if (state.getRenderShape() != RenderShape.MODEL) return false;
106+
if (getCamoState() != null && getCamoState().is(state.getBlock())) return false;
103107
return state.isCollisionShapeFullBlock(getLevel(), getBlockPos());
104108
}
105109

@@ -228,7 +232,7 @@ public boolean isPortalActive() {
228232
}
229233

230234
public List<BlockPos> getPortalPositions() {
231-
PortalScanner scanner = new PortalScanner(new Location(level, getProjectionPosition()), getProjectionAxis(), true, 1000);
235+
PortalScanner scanner = new PortalScanner(new Location(level, getProjectionPosition()), getProjectionAxis(), true, NexusConfig.server.maxPortalSize.get());
232236
scanner.start();
233237
return scanner.getCollectedPositions();
234238
}
@@ -257,6 +261,14 @@ public void togglePortal(@Nullable Entity feedbackEntity) {
257261

258262
BlockPos projectionPosition = getProjectionPosition();
259263

264+
BlockState projectionState = level.getBlockState(projectionPosition);
265+
266+
if (!(projectionState.getBlock() instanceof NexusPortalBlock) && !level.getBlockState(projectionPosition).isAir()) {
267+
NexusMessengers.NEXUS_PORTAL_CORE.send(Component.translatable("message.nexus.light_portal.obstructed").withStyle(ChatFormatting.RED), feedbackEntity);
268+
NexusSoundHelper.playErrorSound(getLocation());
269+
return;
270+
}
271+
260272
if (isPortalActive()) {
261273
unlightPortal();
262274
}
@@ -288,11 +300,22 @@ public void lightPortal(@Nullable Entity feedbackEntity) {
288300
BlockPos projectionPosition = getProjectionPosition();
289301
Direction.Axis projectionAxis = getProjectionAxis();
290302

291-
PortalSpaceScanner scanner = new PortalSpaceScanner(new Location(level, projectionPosition), projectionAxis, 1000);
303+
PortalSpaceScanner scanner = new PortalSpaceScanner(new Location(level, projectionPosition), projectionAxis, NexusConfig.server.maxPortalSize.get() + 1);
292304
scanner.start();
293305

294-
if (!scanner.isHalted()) {
306+
List<BlockPos> collectedPositions = scanner.getCollectedPositions();
295307

308+
if (scanner.isHalted()) {
309+
NexusMessengers.NEXUS_PORTAL_CORE.send(Component.translatable("message.nexus.light_portal.invalid_frame").withStyle(ChatFormatting.RED), feedbackEntity);
310+
NexusSoundHelper.playErrorSound(getLocation());
311+
}
312+
313+
else if (collectedPositions.size() > scanner.getMaxCollectionSize() - 1) {
314+
NexusMessengers.NEXUS_PORTAL_CORE.send(Component.translatable("message.nexus.light_portal.overflowing_frame").withStyle(ChatFormatting.RED), feedbackEntity);
315+
NexusSoundHelper.playErrorSound(getLocation());
316+
}
317+
318+
else {
296319
scanner.getCollectedPositions().forEach(blockPos -> {
297320

298321
Block portalBlock = NexusPortalBlock.fromDye(portalColorPattern.getOrDefault(blockPos, getPortalColorBase()));
@@ -306,11 +329,6 @@ public void lightPortal(@Nullable Entity feedbackEntity) {
306329
NexusMessengers.NEXUS_PORTAL_CORE.send(Component.translatable("message.nexus.light_portal.success").withStyle(ChatFormatting.GREEN), feedbackEntity);
307330
NexusSoundHelper.playSuccessSound(getLocation());
308331
}
309-
310-
else {
311-
NexusMessengers.NEXUS_PORTAL_CORE.send(Component.translatable("message.nexus.light_portal.invalid_frame").withStyle(ChatFormatting.RED), feedbackEntity);
312-
NexusSoundHelper.playErrorSound(getLocation());
313-
}
314332
}
315333

316334
public void teleportEntity(Entity feedbackEntity) {

src/main/java/com/calemi/nexus/client/render/RenderNexusPortalCoreWorldOverlay.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.calemi.nexus.client.render;
22

33
import com.calemi.nexus.block.NexusPortalCoreBlock;
4+
import com.calemi.nexus.config.NexusConfig;
45
import com.calemi.nexus.world.dimension.NexusDimensionHelper;
56
import com.mojang.blaze3d.vertex.PoseStack;
67
import com.mojang.blaze3d.vertex.VertexConsumer;
@@ -20,6 +21,8 @@ public class RenderNexusPortalCoreWorldOverlay {
2021
@SubscribeEvent
2122
public void onRenderLevelStageEvent(RenderLevelStageEvent event) {
2223

24+
if (!NexusConfig.client.portalCoreWorldOverlay.get()) return;
25+
2326
if (event.getStage() == RenderLevelStageEvent.Stage.AFTER_TRANSLUCENT_BLOCKS) {
2427

2528
Minecraft mc = Minecraft.getInstance();

0 commit comments

Comments
 (0)