Merge pull request #25 from dragonruler1000/DEV

Add welcome message to dimensions and introduce config support
This commit is contained in:
dragonruler1000 2025-05-24 10:18:50 -05:00 committed by GitHub
commit f7777980c3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 68 additions and 5 deletions

View file

@ -38,7 +38,7 @@ mod_name=Hdm Mod
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
mod_license=MIT
# The mod version. See https://semver.org/
mod_version=1.2
mod_version=1.2.1
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
# This should match the base package used for the mod sources.
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html

View file

@ -7,7 +7,9 @@ import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.InterModComms;
import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.config.ModConfig;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.event.lifecycle.InterModEnqueueEvent;
@ -44,6 +46,7 @@ public class Hdm_mod {
modEventBus1.addListener(this::processIMC);
// Register the doClientStuff method for modloading
modEventBus1.addListener(this::doClientStuff);
// ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, ModConfig.GENERAL_SPEC, "modconfig.toml");
// Register ourselves for server and other game events we are interested in
MinecraftForge.EVENT_BUS.register(this);

View file

@ -11,6 +11,7 @@ import net.minecraft.server.MinecraftServer;
import net.minecraft.state.StateContainer;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Hand;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.shapes.IBooleanFunction;
@ -125,10 +126,6 @@ public class Window extends HorizontalBlock {
SimpleTeleporter teleporter = new SimpleTeleporter(pos, goingToCustom);
player.changeDimension(targetWorld, teleporter);
}
System.out.println("[DEBUG] Portal activated on server!");
player.sendMessage(new StringTextComponent("Teleport logic running!"), player.getUniqueID());
player.sendMessage(new StringTextComponent("Teleport attempted!"), player.getUniqueID());
return ActionResultType.SUCCESS;
}

View file

@ -0,0 +1,18 @@
//package us.minecraftchest2.hdm_mod.config;
//
//import net.minecraftforge.common.ForgeConfigSpec;
//
//public class ModConfig {
//public static final ForgeConfigSpec GENERAL_SPEC;
//
//static {
// ForgeConfigSpec.Builder configBuilder = new ForgeConfigSpec.Builder();
// setupConfig(configBuilder);
// GENERAL_SPEC = configBuilder.build();
//}
//public static ForgeConfigSpec.IntValue exampleIntConfigEntry;
//
//private static void setupConfig(ForgeConfigSpec.Builder builder) {
// exampleIntConfigEntry = builder.defineInRange("exampleIntConfigEntry", 5, 2, 50);
//}
//}

View file

@ -0,0 +1,18 @@
package us.minecraftchest2.hdm_mod.config;
import net.minecraftforge.common.ForgeConfigSpec;
public class ModConfig {
public static final ForgeConfigSpec GENERAL_SPEC;
static {
ForgeConfigSpec.Builder configBuilder = new ForgeConfigSpec.Builder();
setupConfig(configBuilder);
GENERAL_SPEC = configBuilder.build();
}
public static ForgeConfigSpec.IntValue exampleIntConfigEntry;
private static void setupConfig(ForgeConfigSpec.Builder builder) {
exampleIntConfigEntry = builder.defineInRange("exampleIntConfigEntry", 5, 2, 50);
}
}

View file

@ -5,8 +5,11 @@ package us.minecraftchest2.hdm_mod.world.dimension;
import net.minecraft.block.BlockState;
import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.fluid.Fluids;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.world.server.ServerWorld;
import net.minecraftforge.common.util.ITeleporter;
import us.minecraftchest2.hdm_mod.block.ModBlocks;
@ -114,6 +117,30 @@ public class SimpleTeleporter implements ITeleporter {
}
}
if (entity instanceof PlayerEntity) {
PlayerEntity player = (PlayerEntity) entity;
ResourceLocation dimensionKey = destinationWorld.getDimensionKey().getLocation();
// Only send the welcome message if NOT the overworld
if (!dimensionKey.getPath().equals("overworld")) {
// (Same nice formatting as before)
String path = dimensionKey.getPath();
String dimensionName;
switch (path) {
case "the_nether":
dimensionName = "the Nether";
break;
case "the_end":
dimensionName = "the End";
break;
default:
dimensionName = path.replace('_', ' ');
dimensionName = dimensionName.substring(0, 1).toUpperCase() + dimensionName.substring(1);
break;
}
player.sendMessage(new StringTextComponent("Welcome to " + dimensionName + "!"), player.getUniqueID());
}
}
return entity;
}
}