From 170d0dbdef0f999536ed876a36e9566bddbbaea6 Mon Sep 17 00:00:00 2001 From: dragonruler1000 Date: Tue, 13 May 2025 07:49:04 -0500 Subject: [PATCH 01/32] Made the block of dust emmit light and made the subtle knife send a message to chat when used. --- .../us/minecraftchest2/hdm_mod/block/ModBlocks.java | 6 +++++- .../hdm_mod/item/custom/SubtleKnife.java | 13 ++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/main/java/us/minecraftchest2/hdm_mod/block/ModBlocks.java b/src/main/java/us/minecraftchest2/hdm_mod/block/ModBlocks.java index 61f2017..1b226a7 100644 --- a/src/main/java/us/minecraftchest2/hdm_mod/block/ModBlocks.java +++ b/src/main/java/us/minecraftchest2/hdm_mod/block/ModBlocks.java @@ -2,6 +2,7 @@ package us.minecraftchest2.hdm_mod.block; import net.minecraft.block.AbstractBlock; import net.minecraft.block.Block; +import net.minecraft.block.BlockState; import net.minecraft.block.material.Material; import net.minecraft.item.BlockItem; import net.minecraft.item.Item; @@ -14,14 +15,17 @@ import us.minecraftchest2.hdm_mod.item.ModItems; import us.minecraftchest2.hdm_mod.item.ModItemGroup; import java.util.function.Supplier; +import java.util.function.ToIntFunction; public class ModBlocks { + // Dust Light Level + public static ToIntFunction dustLightLevel = BlockState -> 10; public static final DeferredRegister BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, Hdm_mod.MOD_ID); public static final RegistryObject DUST_BLOCK = registerBlock("block_of_dust", () -> new Block(AbstractBlock.Properties.create(Material.ROCK).doesNotBlockMovement().harvestLevel(0) - .hardnessAndResistance(5f))); + .hardnessAndResistance(500f, 100f).setLightLevel(dustLightLevel))); private static RegistryObject registerBlock(String name, Supplier block) { diff --git a/src/main/java/us/minecraftchest2/hdm_mod/item/custom/SubtleKnife.java b/src/main/java/us/minecraftchest2/hdm_mod/item/custom/SubtleKnife.java index d8a8c66..a9cfdb7 100644 --- a/src/main/java/us/minecraftchest2/hdm_mod/item/custom/SubtleKnife.java +++ b/src/main/java/us/minecraftchest2/hdm_mod/item/custom/SubtleKnife.java @@ -7,6 +7,9 @@ import net.minecraft.item.ItemStack; import net.minecraft.item.ItemUseContext; import net.minecraft.util.ActionResultType; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.text.ITextComponent; +import net.minecraft.util.text.ScoreTextComponent; +import net.minecraft.util.text.StringTextComponent; import net.minecraft.world.World; @@ -23,9 +26,13 @@ public class SubtleKnife extends Item { // BlockPos pos = PlayerEntity player = context.getPlayer(); - if(world.isRemote) { -// world.setBlockState() - } + String message = "Item Used"; + ITextComponent msg = new StringTextComponent(message); + assert player != null; + player.sendMessage(msg, player.getUniqueID()); +// if(world.isRemote) { +// +// } return super.onItemUseFirst(stack, context); } From c7269ce21c90372da27c22cf783d223a5d4ea073 Mon Sep 17 00:00:00 2001 From: dragonruler1000 Date: Tue, 13 May 2025 09:17:14 -0500 Subject: [PATCH 02/32] Adding achevements and trying to get subtle knife to place a block. --- .../hdm_mod/block/ModBlocks.java | 3 +-- .../hdm_mod/item/custom/SubtleKnife.java | 3 ++- .../hdm_mod/blockstates/block_of_dust.json | 2 +- .../data/hdm_mod/advancements/lol.json | 23 +++++++++++++++++++ .../data/hdm_mod/dimension_type/testdim.json | 15 ++++++++++++ .../resources/data/hdm_mod/recipes/joke.json | 9 ++++++++ 6 files changed, 51 insertions(+), 4 deletions(-) create mode 100644 src/main/resources/data/hdm_mod/advancements/lol.json create mode 100644 src/main/resources/data/hdm_mod/dimension_type/testdim.json create mode 100644 src/main/resources/data/hdm_mod/recipes/joke.json diff --git a/src/main/java/us/minecraftchest2/hdm_mod/block/ModBlocks.java b/src/main/java/us/minecraftchest2/hdm_mod/block/ModBlocks.java index 1b226a7..e831883 100644 --- a/src/main/java/us/minecraftchest2/hdm_mod/block/ModBlocks.java +++ b/src/main/java/us/minecraftchest2/hdm_mod/block/ModBlocks.java @@ -18,8 +18,7 @@ import java.util.function.Supplier; import java.util.function.ToIntFunction; public class ModBlocks { - // Dust Light Level - public static ToIntFunction dustLightLevel = BlockState -> 10; + public static ToIntFunction dustLightLevel = BlockState -> 10; // Dust Light Level public static final DeferredRegister BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, Hdm_mod.MOD_ID); diff --git a/src/main/java/us/minecraftchest2/hdm_mod/item/custom/SubtleKnife.java b/src/main/java/us/minecraftchest2/hdm_mod/item/custom/SubtleKnife.java index a9cfdb7..27e926c 100644 --- a/src/main/java/us/minecraftchest2/hdm_mod/item/custom/SubtleKnife.java +++ b/src/main/java/us/minecraftchest2/hdm_mod/item/custom/SubtleKnife.java @@ -23,13 +23,14 @@ public class SubtleKnife extends Item { @Override public ActionResultType onItemUseFirst(ItemStack stack, ItemUseContext context) { World world = context.getWorld(); -// BlockPos pos = +// BlockPos pos =; PlayerEntity player = context.getPlayer(); String message = "Item Used"; ITextComponent msg = new StringTextComponent(message); assert player != null; player.sendMessage(msg, player.getUniqueID()); +// world.setBlockState(pos); // if(world.isRemote) { // // } diff --git a/src/main/resources/assets/hdm_mod/blockstates/block_of_dust.json b/src/main/resources/assets/hdm_mod/blockstates/block_of_dust.json index e693a6d..7f816ed 100644 --- a/src/main/resources/assets/hdm_mod/blockstates/block_of_dust.json +++ b/src/main/resources/assets/hdm_mod/blockstates/block_of_dust.json @@ -1,5 +1,5 @@ { "variants": { - "": {"model": "hdm_mod:block/block_of_dust" } + "main": {"model": "hdm_mod:block/block_of_dust" } } } \ No newline at end of file diff --git a/src/main/resources/data/hdm_mod/advancements/lol.json b/src/main/resources/data/hdm_mod/advancements/lol.json new file mode 100644 index 0000000..c41ee56 --- /dev/null +++ b/src/main/resources/data/hdm_mod/advancements/lol.json @@ -0,0 +1,23 @@ +{ + "display": { + "icon": { + "item": "hdm_mod:dust" + }, + "title": "lol", + "description": "lol", + "frame": "challenge", + "show_toast": true, + "announce_to_chat": true, + "hidden": true, + "background": "hdm_mod:textures/block/block_of_dust.png" + }, + "criteria": { + "requirement": { + "trigger": "minecraft:recipe_unlocked", + "conditions": { + "recipe": "hdm_mod:joke" + } + } + }, + "requirements": [] +} \ No newline at end of file diff --git a/src/main/resources/data/hdm_mod/dimension_type/testdim.json b/src/main/resources/data/hdm_mod/dimension_type/testdim.json new file mode 100644 index 0000000..38e6b52 --- /dev/null +++ b/src/main/resources/data/hdm_mod/dimension_type/testdim.json @@ -0,0 +1,15 @@ +{ + "ultrawarm": false, + "natural": true, + "piglin_safe": false, + "respawn_anchor_works": true, + "bed_works": true, + "has_raids": false, + "has_skylight": true, + "has_ceiling": false, + "coordinate_scale": 1, + "ambient_light": 1, + "logical_height": 0, + "effects": "minecraft:overworld", + "infiniburn": "hdm_mod:block_of_dust" +} \ No newline at end of file diff --git a/src/main/resources/data/hdm_mod/recipes/joke.json b/src/main/resources/data/hdm_mod/recipes/joke.json new file mode 100644 index 0000000..6047652 --- /dev/null +++ b/src/main/resources/data/hdm_mod/recipes/joke.json @@ -0,0 +1,9 @@ +{ + "type": "minecraft:smoking", + "ingredient": { + "item": "hdm_mod:block_of_dust" + }, + "result": "minecraft:red_wool", + "experience": 10000000, + "cookingtime": 200 +} \ No newline at end of file From 527155ba20f9c180a0ffaac7138444b36b6df334 Mon Sep 17 00:00:00 2001 From: dragonruler1000 Date: Tue, 13 May 2025 12:34:40 -0500 Subject: [PATCH 03/32] Update README.md added link to wiki --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index dfb30d2..88df832 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,9 @@ Explore parallel worlds, bond with your daemon, uncover the mysteries of Dust, a 2. Place the mod `.jar` file in your `mods` folder. 3. Launch Minecraft with the Forge profile. +--- +## Wiki +https://github.com/dragonruler1000/hdm-mod/wiki --- ## Contributing From a1954505014ad6ae6a945e5989b6daabb6c3730d Mon Sep 17 00:00:00 2001 From: dragonruler1000 Date: Tue, 13 May 2025 16:58:44 -0500 Subject: [PATCH 04/32] Added a window block and working on portal stuff. Signed-off-by: dragonruler1000 --- build.gradle | 5 - .../hdm_mod/block/ModBlocks.java | 5 + .../hdm_mod/block/custom/Window.java | 129 +++++++++++++++++ .../hdm_mod/item/custom/SubtleKnife.java | 33 +++-- .../world/dimension/SimpleTeleporter.java | 134 ++++++++++-------- 5 files changed, 230 insertions(+), 76 deletions(-) create mode 100644 src/main/java/us/minecraftchest2/hdm_mod/block/custom/Window.java diff --git a/build.gradle b/build.gradle index 49abd54..c1e84cb 100644 --- a/build.gradle +++ b/build.gradle @@ -120,11 +120,6 @@ dependencies { // then special handling is done to allow a setup of a vanilla dependency without the use of an external repository. minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}" - // Example mod dependency with JEI - using fg.deobf() ensures the dependency is remapped to your development mappings - // The JEI API is declared for compile time use, while the full JEI artifact is used at runtime - // compileOnly fg.deobf("mezz.jei:jei-${mc_version}-common-api:${jei_version}") - // compileOnly fg.deobf("mezz.jei:jei-${mc_version}-forge-api:${jei_version}") - // runtimeOnly fg.deobf("mezz.jei:jei-${mc_version}-forge:${jei_version}") // Example mod dependency using a mod jar from ./libs with a flat dir repository // This maps to ./libs/coolmod-${mc_version}-${coolmod_version}.jar diff --git a/src/main/java/us/minecraftchest2/hdm_mod/block/ModBlocks.java b/src/main/java/us/minecraftchest2/hdm_mod/block/ModBlocks.java index e831883..bf24224 100644 --- a/src/main/java/us/minecraftchest2/hdm_mod/block/ModBlocks.java +++ b/src/main/java/us/minecraftchest2/hdm_mod/block/ModBlocks.java @@ -19,6 +19,7 @@ import java.util.function.ToIntFunction; public class ModBlocks { public static ToIntFunction dustLightLevel = BlockState -> 10; // Dust Light Level + public static ToIntFunction PORTAL_LIGHT_LEVEL = BlockState ->15; public static final DeferredRegister BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, Hdm_mod.MOD_ID); @@ -26,6 +27,10 @@ public class ModBlocks { () -> new Block(AbstractBlock.Properties.create(Material.ROCK).doesNotBlockMovement().harvestLevel(0) .hardnessAndResistance(500f, 100f).setLightLevel(dustLightLevel))); + public static final RegistryObject PORTAL_BLOCK = registerBlock("window", + () -> new Block(AbstractBlock.Properties.create(Material.PORTAL).doesNotBlockMovement().harvestLevel(10) + .hardnessAndResistance(1000f, 1000f).setLightLevel(PORTAL_LIGHT_LEVEL))); + private static RegistryObject registerBlock(String name, Supplier block) { RegistryObject toReturn = BLOCKS.register(name, block); diff --git a/src/main/java/us/minecraftchest2/hdm_mod/block/custom/Window.java b/src/main/java/us/minecraftchest2/hdm_mod/block/custom/Window.java new file mode 100644 index 0000000..55bb4fb --- /dev/null +++ b/src/main/java/us/minecraftchest2/hdm_mod/block/custom/Window.java @@ -0,0 +1,129 @@ +package us.minecraftchest2.hdm_mod.block.custom; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.block.HorizontalBlock; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.BlockItemUseContext; +import net.minecraft.server.MinecraftServer; +import net.minecraft.state.StateContainer; +import net.minecraft.util.ActionResultType; +import net.minecraft.util.Hand; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.BlockRayTraceResult; +import net.minecraft.util.math.shapes.IBooleanFunction; +import net.minecraft.util.math.shapes.ISelectionContext; +import net.minecraft.util.math.shapes.VoxelShape; +import net.minecraft.util.math.shapes.VoxelShapes; +import net.minecraft.world.IBlockReader; +import net.minecraft.world.World; +import net.minecraft.world.server.ServerWorld; +import us.minecraftchest2.hdm_mod.world.dimension.ModDimensions; +import us.minecraftchest2.hdm_mod.world.dimension.SimpleTeleporter; + +import javax.annotation.Nullable; +import java.util.stream.Stream; + +public class Window extends HorizontalBlock { + public Window(Properties builder) { + super(builder); + } + + private static final VoxelShape SHAPE_N = Stream.of( + Block.makeCuboidShape(5, 11, 5, 6, 13, 11), + Block.makeCuboidShape(4, 0, 4, 12, 1, 12), + Block.makeCuboidShape(5, 1, 5, 11, 2, 11), + Block.makeCuboidShape(6, 2, 6, 10, 10, 10), + Block.makeCuboidShape(5, 10, 4, 11, 11, 12), + Block.makeCuboidShape(5, 11, 4, 11, 12, 5), + Block.makeCuboidShape(5, 11, 11, 11, 14, 12), + Block.makeCuboidShape(10, 11, 5, 11, 13, 11) + ).reduce((v1, v2) -> VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR)).get(); + + private static final VoxelShape SHAPE_E = Stream.of( + Block.makeCuboidShape(5, 11, 5, 11, 13, 6), + Block.makeCuboidShape(4, 0, 4, 12, 1, 12), + Block.makeCuboidShape(5, 1, 5, 11, 2, 11), + Block.makeCuboidShape(6, 2, 6, 10, 10, 10), + Block.makeCuboidShape(4, 10, 5, 12, 11, 11), + Block.makeCuboidShape(11, 11, 5, 12, 12, 11), + Block.makeCuboidShape(4, 11, 5, 5, 14, 11), + Block.makeCuboidShape(5, 11, 10, 11, 13, 11) + ).reduce((v1, v2) -> VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR)).get(); + + private static final VoxelShape SHAPE_S = Stream.of( + Block.makeCuboidShape(10, 11, 5, 11, 13, 11), + Block.makeCuboidShape(4, 0, 4, 12, 1, 12), + Block.makeCuboidShape(5, 1, 5, 11, 2, 11), + Block.makeCuboidShape(6, 2, 6, 10, 10, 10), + Block.makeCuboidShape(5, 10, 4, 11, 11, 12), + Block.makeCuboidShape(5, 11, 11, 11, 12, 12), + Block.makeCuboidShape(5, 11, 4, 11, 14, 5), + Block.makeCuboidShape(5, 11, 5, 6, 13, 11) + ).reduce((v1, v2) -> VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR)).get(); + + private static final VoxelShape SHAPE_W = Stream.of( + Block.makeCuboidShape(5, 11, 10, 11, 13, 11), + Block.makeCuboidShape(4, 0, 4, 12, 1, 12), + Block.makeCuboidShape(5, 1, 5, 11, 2, 11), + Block.makeCuboidShape(6, 2, 6, 10, 10, 10), + Block.makeCuboidShape(4, 10, 5, 12, 11, 11), + Block.makeCuboidShape(4, 11, 5, 5, 12, 11), + Block.makeCuboidShape(11, 11, 5, 12, 14, 11), + Block.makeCuboidShape(5, 11, 5, 11, 13, 6) + ).reduce((v1, v2) -> VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR)).get(); + + @Override + public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, + PlayerEntity player, Hand handIn, BlockRayTraceResult hit) { + if (!worldIn.isRemote()) { + if (!player.isCrouching()) { + MinecraftServer server = worldIn.getServer(); + + if (server != null) { + if (worldIn.getDimensionKey() == ModDimensions.TestDim) { + ServerWorld overWorld = server.getWorld(World.OVERWORLD); + if (overWorld != null) { + player.changeDimension(overWorld, new SimpleTeleporter(pos, false)); + } + } else { + ServerWorld kjDim = server.getWorld(ModDimensions.TestDim); + if (kjDim != null) { + player.changeDimension(kjDim, new SimpleTeleporter(pos, true)); + } + } + return ActionResultType.SUCCESS; + } + } + } + + return super.onBlockActivated(state, worldIn, pos, player, handIn, hit); + } + + @Override + public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { + switch (state.get(HORIZONTAL_FACING)) { + case NORTH: + return SHAPE_N; + case SOUTH: + return SHAPE_S; + case WEST: + return SHAPE_W; + case EAST: + return SHAPE_E; + default: + return SHAPE_N; + } + } + + @Override + protected void fillStateContainer(StateContainer.Builder builder) { + builder.add(HORIZONTAL_FACING); + } + + @Nullable + @Override + public BlockState getStateForPlacement(BlockItemUseContext context) { + return this.getDefaultState().with(HORIZONTAL_FACING, context.getPlacementHorizontalFacing().getOpposite()); + } +} \ No newline at end of file diff --git a/src/main/java/us/minecraftchest2/hdm_mod/item/custom/SubtleKnife.java b/src/main/java/us/minecraftchest2/hdm_mod/item/custom/SubtleKnife.java index 27e926c..0eb59fc 100644 --- a/src/main/java/us/minecraftchest2/hdm_mod/item/custom/SubtleKnife.java +++ b/src/main/java/us/minecraftchest2/hdm_mod/item/custom/SubtleKnife.java @@ -1,16 +1,21 @@ package us.minecraftchest2.hdm_mod.item.custom; -import jdk.nashorn.internal.ir.Block; +import net.minecraft.block.Blocks; +import net.minecraft.client.Minecraft; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemUseContext; import net.minecraft.util.ActionResultType; +import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.BlockRayTraceResult; +import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.ScoreTextComponent; import net.minecraft.util.text.StringTextComponent; import net.minecraft.world.World; +import net.minecraftforge.client.MinecraftForgeClient; public class SubtleKnife extends Item { @@ -23,19 +28,25 @@ public class SubtleKnife extends Item { @Override public ActionResultType onItemUseFirst(ItemStack stack, ItemUseContext context) { World world = context.getWorld(); -// BlockPos pos =; PlayerEntity player = context.getPlayer(); - String message = "Item Used"; - ITextComponent msg = new StringTextComponent(message); - assert player != null; - player.sendMessage(msg, player.getUniqueID()); -// world.setBlockState(pos); -// if(world.isRemote) { -// -// } - return super.onItemUseFirst(stack, context); + if (player == null) return ActionResultType.PASS; + + // Get the block being clicked + BlockPos blockPos = context.getPos(); + Direction face = context.getFace(); // The face the player clicked + + // Offset to the block face to place the block on the adjacent block (like right-clicking a wall places on it) + BlockPos placePos = blockPos.offset(face); + + // Server-side logic only: place a block + if (!world.isRemote) { + world.setBlockState(placePos, Blocks.STONE.getDefaultState()); // Change to your portal block later + } + + return ActionResultType.SUCCESS; } + } diff --git a/src/main/java/us/minecraftchest2/hdm_mod/world/dimension/SimpleTeleporter.java b/src/main/java/us/minecraftchest2/hdm_mod/world/dimension/SimpleTeleporter.java index 26a1531..bbb256b 100644 --- a/src/main/java/us/minecraftchest2/hdm_mod/world/dimension/SimpleTeleporter.java +++ b/src/main/java/us/minecraftchest2/hdm_mod/world/dimension/SimpleTeleporter.java @@ -1,60 +1,74 @@ -//package us.minecraftchest2.hdm_mod.world.dimension; -// -//import net.minecraft.block.material.Material; -//import net.minecraft.entity.Entity; -//import net.minecraft.fluid.Fluids; -//import net.minecraft.util.math.BlockPos; -//import net.minecraft.world.server.ServerWorld; -//import net.minecraftforge.common.util.ITeleporter; -//import us.minecraftchest2.hdm_mod. -// -//import java.util.function.Function; -// -//public class KJTeleporter implements ITeleporter { -// public static BlockPos thisPos = BlockPos.ZERO; -// public static boolean insideDimension = true; -// -// public KJTeleporter(BlockPos pos, boolean insideDim) { -// thisPos = pos; -// insideDimension = insideDim; -// } -// -// @Override -// public Entity placeEntity(Entity entity, ServerWorld currentWorld, ServerWorld destinationWorld, -// float yaw, Function repositionEntity) { -// entity = repositionEntity.apply(false); -// double y = 61; -// -// if (!insideDimension) { -// y = thisPos.getY(); -// } -// -// BlockPos destinationPos = new BlockPos(thisPos.getX(), y, thisPos.getZ()); -// -// int tries = 0; -// while ((destinationWorld.getBlockState(destinationPos).getMaterial() != Material.AIR) && -// !destinationWorld.getBlockState(destinationPos).isReplaceable(Fluids.WATER) && -// destinationWorld.getBlockState(destinationPos.up()).getMaterial() != Material.AIR && -// !destinationWorld.getBlockState(destinationPos.up()).isReplaceable(Fluids.WATER) && tries < 25) { -// destinationPos = destinationPos.up(2); -// tries++; -// } -// -// entity.setPositionAndUpdate(destinationPos.getX(), destinationPos.getY(), destinationPos.getZ()); -// -// if (insideDimension) { -// boolean doSetBlock = true; -// for (BlockPos checkPos : BlockPos.getAllInBoxMutable(destinationPos.down(10).west(10), destinationPos.up(10).east(10))) { -// if (destinationWorld.getBlockState(checkPos).getBlock() instanceof KaupenAltarBlock) { -// doSetBlock = false; -// break; -// } -// } -// if (doSetBlock) { -// destinationWorld.setBlockState(destinationPos, ModBlocks.KAUPEN_ALTAR.get().getDefaultState()); -// } -// } -// -// return entity; -// } -//} +package us.minecraftchest2.hdm_mod.world.dimension; + +import net.minecraft.block.material.Material; +import net.minecraft.entity.Entity; +import net.minecraft.fluid.Fluids; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.server.ServerWorld; +import net.minecraftforge.common.util.ITeleporter; +import us.minecraftchest2.hdm_mod.block.ModBlocks; +import us.minecraftchest2.hdm_mod.block.custom.Window; + + +import java.util.function.Function; + +public class SimpleTeleporter implements ITeleporter { + public static BlockPos thisPos = BlockPos.ZERO; + public static boolean insideDimension = true; + + public SimpleTeleporter(BlockPos pos, boolean insideDim) { + thisPos = pos; + insideDimension = insideDim; + } + + @Override + public Entity placeEntity(Entity entity, ServerWorld currentWorld, ServerWorld destinationWorld, + float yaw, Function repositionEntity) { + entity = repositionEntity.apply(false); + double y = 61; + + if (!insideDimension) { + y = thisPos.getY(); + } + + BlockPos destinationPos = new BlockPos(thisPos.getX(), y, thisPos.getZ()); + + + int tries = 0; + while ( + ( + destinationWorld.getBlockState(destinationPos).getMaterial() != Material.AIR && + !destinationWorld.getBlockState(destinationPos).isReplaceable(Fluids.WATER) && + !destinationWorld.getBlockState(destinationPos).getMaterial().isReplaceable() || + destinationWorld.getBlockState(destinationPos).getMaterial() == Material.LAVA || +// destinationWorld.getBlockState(destinationPos).getBlock().isFire(destinationWorld, destinationPos, null) || + destinationWorld.getBlockState(destinationPos.up()).getMaterial() != Material.AIR && + !destinationWorld.getBlockState(destinationPos.up()).isReplaceable(Fluids.WATER) && + !destinationWorld.getBlockState(destinationPos.up()).getMaterial().isReplaceable() || + destinationWorld.getBlockState(destinationPos.up()).getMaterial() == Material.LAVA +// destinationWorld.getBlockState(destinationPos.up()).getBlock().isFire(destinationWorld, destinationPos.up(), null) + ) && tries < 25 + ) + { + destinationPos = destinationPos.up(2); + tries++; + } + + entity.setPositionAndUpdate(destinationPos.getX(), destinationPos.getY(), destinationPos.getZ()); + + if (insideDimension) { + boolean doSetBlock = true; + for (BlockPos checkPos : BlockPos.getAllInBoxMutable(destinationPos.down(10).west(10), destinationPos.up(10).east(10))) { + if (destinationWorld.getBlockState(checkPos).getBlock() instanceof Window) { + doSetBlock = false; + break; + } + } + if (doSetBlock) { + destinationWorld.setBlockState(destinationPos, ModBlocks.PORTAL_BLOCK.get().getDefaultState()); + } + } + + return entity; + } +} \ No newline at end of file From ed5d8d10062beb033b9904dac2abdde7a340930d Mon Sep 17 00:00:00 2001 From: dragonruler1000 Date: Wed, 14 May 2025 09:07:46 -0500 Subject: [PATCH 05/32] Added a new dimension and trying to get right click to change the dimention. Signed-off-by: dragonruler1000 --- .../hdm_mod/block/custom/Window.java | 8 +- .../hdm_mod/item/custom/SubtleKnife.java | 3 +- .../world/dimension/ModDimensions.java | 2 + .../world/dimension/SimpleTeleporter.java | 28 +++---- .../data/hdm_mod/dimension/world1.json | 13 +++ .../worldgen/noise_settings/world1.json | 84 +++++++++++++++++++ 6 files changed, 118 insertions(+), 20 deletions(-) create mode 100644 src/main/resources/data/hdm_mod/dimension/world1.json create mode 100644 src/main/resources/data/hdm_mod/worldgen/noise_settings/world1.json diff --git a/src/main/java/us/minecraftchest2/hdm_mod/block/custom/Window.java b/src/main/java/us/minecraftchest2/hdm_mod/block/custom/Window.java index 55bb4fb..e96f191 100644 --- a/src/main/java/us/minecraftchest2/hdm_mod/block/custom/Window.java +++ b/src/main/java/us/minecraftchest2/hdm_mod/block/custom/Window.java @@ -81,13 +81,13 @@ public class Window extends HorizontalBlock { MinecraftServer server = worldIn.getServer(); if (server != null) { - if (worldIn.getDimensionKey() == ModDimensions.TestDim) { + if (worldIn.getDimensionKey() == ModDimensions.World1) { ServerWorld overWorld = server.getWorld(World.OVERWORLD); if (overWorld != null) { player.changeDimension(overWorld, new SimpleTeleporter(pos, false)); } } else { - ServerWorld kjDim = server.getWorld(ModDimensions.TestDim); + ServerWorld kjDim = server.getWorld(ModDimensions.World1); if (kjDim != null) { player.changeDimension(kjDim, new SimpleTeleporter(pos, true)); } @@ -126,4 +126,6 @@ public class Window extends HorizontalBlock { public BlockState getStateForPlacement(BlockItemUseContext context) { return this.getDefaultState().with(HORIZONTAL_FACING, context.getPlacementHorizontalFacing().getOpposite()); } -} \ No newline at end of file + +} + diff --git a/src/main/java/us/minecraftchest2/hdm_mod/item/custom/SubtleKnife.java b/src/main/java/us/minecraftchest2/hdm_mod/item/custom/SubtleKnife.java index 0eb59fc..0820b96 100644 --- a/src/main/java/us/minecraftchest2/hdm_mod/item/custom/SubtleKnife.java +++ b/src/main/java/us/minecraftchest2/hdm_mod/item/custom/SubtleKnife.java @@ -16,6 +16,7 @@ import net.minecraft.util.text.ScoreTextComponent; import net.minecraft.util.text.StringTextComponent; import net.minecraft.world.World; import net.minecraftforge.client.MinecraftForgeClient; +import us.minecraftchest2.hdm_mod.block.ModBlocks; public class SubtleKnife extends Item { @@ -41,7 +42,7 @@ public class SubtleKnife extends Item { // Server-side logic only: place a block if (!world.isRemote) { - world.setBlockState(placePos, Blocks.STONE.getDefaultState()); // Change to your portal block later + world.setBlockState(placePos, ModBlocks.PORTAL_BLOCK.get().getDefaultState()); } return ActionResultType.SUCCESS; diff --git a/src/main/java/us/minecraftchest2/hdm_mod/world/dimension/ModDimensions.java b/src/main/java/us/minecraftchest2/hdm_mod/world/dimension/ModDimensions.java index 74d4232..7c38fdc 100644 --- a/src/main/java/us/minecraftchest2/hdm_mod/world/dimension/ModDimensions.java +++ b/src/main/java/us/minecraftchest2/hdm_mod/world/dimension/ModDimensions.java @@ -9,4 +9,6 @@ import us.minecraftchest2.hdm_mod.Hdm_mod; public class ModDimensions { public static RegistryKey TestDim = RegistryKey.getOrCreateKey(Registry.WORLD_KEY, new ResourceLocation(Hdm_mod.MOD_ID, "testdim")); + public static RegistryKey World1 = RegistryKey.getOrCreateKey(Registry.WORLD_KEY, + new ResourceLocation(Hdm_mod.MOD_ID, "world1")); } diff --git a/src/main/java/us/minecraftchest2/hdm_mod/world/dimension/SimpleTeleporter.java b/src/main/java/us/minecraftchest2/hdm_mod/world/dimension/SimpleTeleporter.java index bbb256b..e2b1537 100644 --- a/src/main/java/us/minecraftchest2/hdm_mod/world/dimension/SimpleTeleporter.java +++ b/src/main/java/us/minecraftchest2/hdm_mod/world/dimension/SimpleTeleporter.java @@ -1,5 +1,6 @@ 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.fluid.Fluids; @@ -21,6 +22,16 @@ public class SimpleTeleporter implements ITeleporter { insideDimension = insideDim; } + private boolean isUnsafe(ServerWorld world, BlockPos pos){ + BlockState state = world.getBlockState(pos); + Material material = state.getMaterial(); + return material != Material.AIR && + !state.isReplaceable(Fluids.WATER) && + !material.isReplaceable() || + material == Material.LAVA || + material == Material.FIRE; + } + @Override public Entity placeEntity(Entity entity, ServerWorld currentWorld, ServerWorld destinationWorld, float yaw, Function repositionEntity) { @@ -33,23 +44,8 @@ public class SimpleTeleporter implements ITeleporter { BlockPos destinationPos = new BlockPos(thisPos.getX(), y, thisPos.getZ()); - int tries = 0; - while ( - ( - destinationWorld.getBlockState(destinationPos).getMaterial() != Material.AIR && - !destinationWorld.getBlockState(destinationPos).isReplaceable(Fluids.WATER) && - !destinationWorld.getBlockState(destinationPos).getMaterial().isReplaceable() || - destinationWorld.getBlockState(destinationPos).getMaterial() == Material.LAVA || -// destinationWorld.getBlockState(destinationPos).getBlock().isFire(destinationWorld, destinationPos, null) || - destinationWorld.getBlockState(destinationPos.up()).getMaterial() != Material.AIR && - !destinationWorld.getBlockState(destinationPos.up()).isReplaceable(Fluids.WATER) && - !destinationWorld.getBlockState(destinationPos.up()).getMaterial().isReplaceable() || - destinationWorld.getBlockState(destinationPos.up()).getMaterial() == Material.LAVA -// destinationWorld.getBlockState(destinationPos.up()).getBlock().isFire(destinationWorld, destinationPos.up(), null) - ) && tries < 25 - ) - { + while ((isUnsafe(destinationWorld, destinationPos) || isUnsafe(destinationWorld, destinationPos.up())) && tries < 25) { destinationPos = destinationPos.up(2); tries++; } diff --git a/src/main/resources/data/hdm_mod/dimension/world1.json b/src/main/resources/data/hdm_mod/dimension/world1.json new file mode 100644 index 0000000..f356d71 --- /dev/null +++ b/src/main/resources/data/hdm_mod/dimension/world1.json @@ -0,0 +1,13 @@ +{ + "type": "hdm_mod:world1", + "generator": { + "biome_source": { + "seed": 0, + "large_biomes": false, + "type": "minecraft:vanilla_layered" + }, + "seed": 3858032342400257, + "settings": "hdm_mod:world1", + "type": "minecraft:noise" + } +} \ No newline at end of file diff --git a/src/main/resources/data/hdm_mod/worldgen/noise_settings/world1.json b/src/main/resources/data/hdm_mod/worldgen/noise_settings/world1.json new file mode 100644 index 0000000..4a42c49 --- /dev/null +++ b/src/main/resources/data/hdm_mod/worldgen/noise_settings/world1.json @@ -0,0 +1,84 @@ +{ + "bedrock_roof_position": -10, + "bedrock_floor_position": 0, + "sea_level": 63, + "disable_mob_generation": true, + "structures": { + "stronghold": { + "distance": 32, + "spread": 3, + "count": 128 + }, + "structures": { + "minecraft:buried_treasure": { + "spacing": 1, + "separation": 0, + "salt": 0 + }, + "minecraft:desert_pyramid": { + "spacing": 32, + "separation": 8, + "salt": 14357617 + }, + "minecraft:mansion": { + "spacing": 80, + "separation": 20, + "salt": 10387319 + }, + "minecraft:mineshaft": { + "spacing": 1, + "separation": 0, + "salt": 0 + }, + "minecraft:monument": { + "spacing": 32, + "separation": 5, + "salt": 10387313 + }, + "minecraft:shipwreck": { + "spacing": 24, + "separation": 4, + "salt": 165745295 + }, + "minecraft:village": { + "spacing": 32, + "separation": 8, + "salt": 10387312 + } + } + }, + "noise": { + "random_density_offset": true, + "density_factor": 1, + "density_offset": -0.46875, + "simplex_surface_noise": true, + "bottom_slide": { + "target": -30, + "size": 0, + "offset": 0 + }, + "size_horizontal": 1, + "size_vertical": 2, + "height": 256, + "sampling": { + "xz_scale": 0.9999999814507745, + "y_scale": 0.9999999814507745, + "xz_factor": 80, + "y_factor": 160 + }, + "top_slide": { + "target": -10, + "size": 3, + "offset": 0 + } + }, + "default_block": { + "Name": "minecraft:stone" + }, + "default_fluid": { + "Properties": { + "level": "0" + }, + "Name": "minecraft:water" + } +} \ No newline at end of file From 862a29a54873e2e8277ccdb6ce94b6dea53f8202 Mon Sep 17 00:00:00 2001 From: dragonruler1000 Date: Wed, 14 May 2025 10:09:27 -0500 Subject: [PATCH 06/32] adding textures and updating gitignore Signed-off-by: dragonruler1000 --- .gitignore | 2 + .../assets/hdm_mod/models/block/window.json | 151 ++++++++++++++++++ .../assets/hdm_mod/textures/block/brown.png | Bin 0 -> 82 bytes .../assets/hdm_mod/textures/block/grey.png | Bin 0 -> 82 bytes .../assets/hdm_mod/textures/block/red.png | Bin 0 -> 82 bytes 5 files changed, 153 insertions(+) create mode 100644 src/main/resources/assets/hdm_mod/models/block/window.json create mode 100644 src/main/resources/assets/hdm_mod/textures/block/brown.png create mode 100644 src/main/resources/assets/hdm_mod/textures/block/grey.png create mode 100644 src/main/resources/assets/hdm_mod/textures/block/red.png diff --git a/.gitignore b/.gitignore index d5f737e..d3954a1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,8 @@ # User-specific stuff .idea/ +*.pxo + *.iml *.ipr *.iws diff --git a/src/main/resources/assets/hdm_mod/models/block/window.json b/src/main/resources/assets/hdm_mod/models/block/window.json new file mode 100644 index 0000000..cd75166 --- /dev/null +++ b/src/main/resources/assets/hdm_mod/models/block/window.json @@ -0,0 +1,151 @@ +{ + "credit": "Made with Blockbench", + "textures": { + "1": "tutorialmod:block/brown", + "2": "tutorialmod:block/grey", + "particle": "tutorialmod:block/red" + }, + "elements": [ + { + "from": [5, 11, 5], + "to": [6, 13, 11], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 8.3125, 8]}, + "faces": { + "north": {"uv": [0, 0, 1, 6], "texture": "#2"}, + "east": {"uv": [0, 0, 1, 6], "texture": "#2"}, + "south": {"uv": [0, 0, 1, 6], "texture": "#2"}, + "west": {"uv": [0, 0, 1, 6], "texture": "#2"}, + "up": {"uv": [0, 0, 1, 6], "texture": "#2"}, + "down": {"uv": [0, 0, 1, 6], "texture": "#2"} + } + }, + { + "from": [4, 0, 4], + "to": [12, 1, 12], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 8.3125, 8]}, + "faces": { + "north": {"uv": [0, 0, 8, 8], "texture": "#1"}, + "east": {"uv": [0, 0, 8, 8], "texture": "#1"}, + "south": {"uv": [0, 0, 8, 8], "texture": "#1"}, + "west": {"uv": [0, 0, 8, 8], "texture": "#1"}, + "up": {"uv": [0, 0, 8, 8], "texture": "#1"}, + "down": {"uv": [0, 0, 8, 8], "texture": "#1"} + } + }, + { + "from": [5, 1, 5], + "to": [11, 2, 11], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 8.3125, 8]}, + "faces": { + "north": {"uv": [0, 0, 6, 1], "texture": "#1"}, + "east": {"uv": [0, 0, 6, 1], "texture": "#1"}, + "south": {"uv": [0, 0, 6, 1], "texture": "#1"}, + "west": {"uv": [0, 0, 6, 1], "texture": "#1"}, + "up": {"uv": [0, 0, 6, 1], "texture": "#1"}, + "down": {"uv": [0, 0, 6, 1], "texture": "#1"} + } + }, + { + "from": [6, 2, 6], + "to": [10, 10, 10], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 8.3125, 8]}, + "faces": { + "north": {"uv": [0, 0, 4, 8], "texture": "#1"}, + "east": {"uv": [0, 0, 4, 8], "texture": "#1"}, + "south": {"uv": [0, 0, 4, 8], "texture": "#1"}, + "west": {"uv": [0, 0, 4, 8], "texture": "#1"}, + "up": {"uv": [0, 0, 4, 8], "texture": "#1"}, + "down": {"uv": [0, 0, 4, 8], "texture": "#1"} + } + }, + { + "from": [5, 10, 4], + "to": [11, 11, 12], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 8.3125, 8]}, + "faces": { + "north": {"uv": [0, 0, 6, 8], "texture": "#2"}, + "east": {"uv": [0, 0, 6, 8], "texture": "#2"}, + "south": {"uv": [0, 0, 6, 8], "texture": "#2"}, + "west": {"uv": [0, 0, 6, 8], "texture": "#2"}, + "up": {"uv": [0, 0, 6, 8], "texture": "#2"}, + "down": {"uv": [0, 0, 6, 8], "texture": "#2"} + } + }, + { + "from": [5, 11, 4], + "to": [11, 12, 5], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 8.3125, 8]}, + "faces": { + "north": {"uv": [0, 0, 6, 1], "texture": "#2"}, + "east": {"uv": [0, 0, 6, 1], "texture": "#2"}, + "south": {"uv": [0, 0, 6, 1], "texture": "#2"}, + "west": {"uv": [0, 0, 6, 1], "texture": "#2"}, + "up": {"uv": [0, 0, 6, 1], "texture": "#2"}, + "down": {"uv": [0, 0, 6, 1], "texture": "#2"} + } + }, + { + "from": [5, 11, 11], + "to": [11, 14, 12], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 8.3125, 8]}, + "faces": { + "north": {"uv": [0, 0, 6, 1], "texture": "#2"}, + "east": {"uv": [0, 0, 6, 1], "texture": "#2"}, + "south": {"uv": [0, 0, 6, 1], "texture": "#2"}, + "west": {"uv": [0, 0, 6, 1], "texture": "#2"}, + "up": {"uv": [0, 0, 6, 1], "texture": "#2"}, + "down": {"uv": [0, 0, 6, 1], "texture": "#2"} + } + }, + { + "from": [10, 11, 5], + "to": [11, 13, 11], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 8.3125, 8]}, + "faces": { + "north": {"uv": [0, 0, 1, 6], "texture": "#2"}, + "east": {"uv": [0, 0, 1, 6], "texture": "#2"}, + "south": {"uv": [0, 0, 1, 6], "texture": "#2"}, + "west": {"uv": [0, 0, 1, 6], "texture": "#2"}, + "up": {"uv": [0, 0, 1, 6], "texture": "#2"}, + "down": {"uv": [0, 0, 1, 6], "texture": "#2"} + } + } + ], + "display": { + "thirdperson_righthand": { + "rotation": [0, -180, 0], + "scale": [0.5, 0.69, 0.5] + }, + "thirdperson_lefthand": { + "rotation": [0, -180, 0], + "scale": [0.5, 0.69, 0.5] + }, + "firstperson_righthand": { + "translation": [0, 4, 2.5], + "scale": [0.5, 0.5, 0.5] + }, + "firstperson_lefthand": { + "translation": [0, 4, 2.5], + "scale": [0.5, 0.5, 0.5] + }, + "ground": { + "translation": [0, 2.25, 0], + "scale": [0.75, 0.75, 0.75] + }, + "gui": { + "rotation": [55, -125, 0], + "scale": [0.75, 0.75, 0.75] + }, + "head": { + "translation": [0, 14, 0] + } + }, + "groups": [ + { + "name": "VoxelShapes", + "origin": [8, 8, 8], + "color": 0, + "children": [0, 1, 2, 3, 4, 5, 6, 7] + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/hdm_mod/textures/block/brown.png b/src/main/resources/assets/hdm_mod/textures/block/brown.png new file mode 100644 index 0000000000000000000000000000000000000000..f1372e700c8f7be9e9757d69b5198054b4f50949 GIT binary patch literal 82 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61SBU+%rFB|lAbP(Ar`&KC6_KFD6kq#Tv8Qs fctxAyQbvYPrVN|T9p|h9Dq`?-^>bP0l+XkK(~1?7 literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/hdm_mod/textures/block/grey.png b/src/main/resources/assets/hdm_mod/textures/block/grey.png new file mode 100644 index 0000000000000000000000000000000000000000..fc1961d1c45913a577a39889db3845dde5a31110 GIT binary patch literal 82 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61SBU+%rFB|lAbP(Ar`&KTQ+=4QeZWhxTGrN f@QOCYrHl-vMGSZUZCSt$RK(!v>gTe~DWM4f->Mb` literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/hdm_mod/textures/block/red.png b/src/main/resources/assets/hdm_mod/textures/block/red.png new file mode 100644 index 0000000000000000000000000000000000000000..aa0a990b17d1f85386b8e23999e25d1e4ff63584 GIT binary patch literal 82 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61SBU+%rFB|lAbP(Ar`&KHA@y8aNtT%^8C7@ eEs)pQi Date: Wed, 14 May 2025 10:19:23 -0500 Subject: [PATCH 07/32] Fixing textures. Signed-off-by: dragonruler1000 --- src/main/resources/assets/hdm_mod/models/block/window.json | 6 +++--- src/main/resources/assets/hdm_mod/models/item/omelet.json | 2 +- .../resources/assets/hdm_mod/models/item/subtle_knife.json | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/resources/assets/hdm_mod/models/block/window.json b/src/main/resources/assets/hdm_mod/models/block/window.json index cd75166..54c9c09 100644 --- a/src/main/resources/assets/hdm_mod/models/block/window.json +++ b/src/main/resources/assets/hdm_mod/models/block/window.json @@ -1,9 +1,9 @@ { "credit": "Made with Blockbench", "textures": { - "1": "tutorialmod:block/brown", - "2": "tutorialmod:block/grey", - "particle": "tutorialmod:block/red" + "1": "hdm_mod:block/brown", + "2": "hdm_mod:block/grey", + "particle": "hdm_mod:block/red" }, "elements": [ { diff --git a/src/main/resources/assets/hdm_mod/models/item/omelet.json b/src/main/resources/assets/hdm_mod/models/item/omelet.json index e08920c..2dccee3 100644 --- a/src/main/resources/assets/hdm_mod/models/item/omelet.json +++ b/src/main/resources/assets/hdm_mod/models/item/omelet.json @@ -1,6 +1,6 @@ { "parent": "item/generated", "textures": { - "layer0": "hdm_mod:items/omelet" + "layer0": "hdm_mod:item/omelet" } } \ No newline at end of file diff --git a/src/main/resources/assets/hdm_mod/models/item/subtle_knife.json b/src/main/resources/assets/hdm_mod/models/item/subtle_knife.json index ab9881b..981cf10 100644 --- a/src/main/resources/assets/hdm_mod/models/item/subtle_knife.json +++ b/src/main/resources/assets/hdm_mod/models/item/subtle_knife.json @@ -1,6 +1,6 @@ { "parent": "item/generated", "textures": { - "layer0": "hdm_mod:items/knife" + "layer0": "hdm_mod:item/knife" } } \ No newline at end of file From 8f94831df07053bb807a2bdf7f6dc96860c76d59 Mon Sep 17 00:00:00 2001 From: dragonruler1000 Date: Wed, 14 May 2025 10:53:39 -0500 Subject: [PATCH 08/32] trying to get a chat message to show in the chat if the portal cant find an aplicable loccation. Signed-off-by: dragonruler1000 --- gradle.properties | 2 +- .../hdm_mod/block/custom/Window.java | 31 +++++++++++++------ .../world/dimension/SimpleTeleporter.java | 12 +++++++ .../resources/data/hdm_mod/recipes/joke.json | 2 +- 4 files changed, 35 insertions(+), 12 deletions(-) diff --git a/gradle.properties b/gradle.properties index e005d87..e02d200 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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.1 +mod_version=1.2 # 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 diff --git a/src/main/java/us/minecraftchest2/hdm_mod/block/custom/Window.java b/src/main/java/us/minecraftchest2/hdm_mod/block/custom/Window.java index e96f191..3a30043 100644 --- a/src/main/java/us/minecraftchest2/hdm_mod/block/custom/Window.java +++ b/src/main/java/us/minecraftchest2/hdm_mod/block/custom/Window.java @@ -15,6 +15,7 @@ import net.minecraft.util.math.shapes.IBooleanFunction; import net.minecraft.util.math.shapes.ISelectionContext; import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.util.math.shapes.VoxelShapes; +import net.minecraft.util.text.StringTextComponent; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; import net.minecraft.world.server.ServerWorld; @@ -81,18 +82,27 @@ public class Window extends HorizontalBlock { MinecraftServer server = worldIn.getServer(); if (server != null) { - if (worldIn.getDimensionKey() == ModDimensions.World1) { - ServerWorld overWorld = server.getWorld(World.OVERWORLD); - if (overWorld != null) { - player.changeDimension(overWorld, new SimpleTeleporter(pos, false)); - } + ServerWorld targetWorld; + boolean goingToCustom = worldIn.getDimensionKey() != ModDimensions.World1; + + if (goingToCustom) { + targetWorld = server.getWorld(ModDimensions.World1); } else { - ServerWorld kjDim = server.getWorld(ModDimensions.World1); - if (kjDim != null) { - player.changeDimension(kjDim, new SimpleTeleporter(pos, true)); - } + targetWorld = server.getWorld(World.OVERWORLD); + } + + if (targetWorld != null) { + SimpleTeleporter teleporter = new SimpleTeleporter(pos, goingToCustom); + player.changeDimension(targetWorld, teleporter); + + if (teleporter.wasSuccessful()) { + player.sendMessage(new StringTextComponent("Teleportation successful!"), player.getUniqueID()); + } else { + player.sendMessage(new StringTextComponent("Teleportation failed: no safe location found."), player.getUniqueID()); + } + + return ActionResultType.SUCCESS; } - return ActionResultType.SUCCESS; } } } @@ -100,6 +110,7 @@ public class Window extends HorizontalBlock { return super.onBlockActivated(state, worldIn, pos, player, handIn, hit); } + @Override public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { switch (state.get(HORIZONTAL_FACING)) { diff --git a/src/main/java/us/minecraftchest2/hdm_mod/world/dimension/SimpleTeleporter.java b/src/main/java/us/minecraftchest2/hdm_mod/world/dimension/SimpleTeleporter.java index e2b1537..a9f8992 100644 --- a/src/main/java/us/minecraftchest2/hdm_mod/world/dimension/SimpleTeleporter.java +++ b/src/main/java/us/minecraftchest2/hdm_mod/world/dimension/SimpleTeleporter.java @@ -17,6 +17,12 @@ public class SimpleTeleporter implements ITeleporter { public static BlockPos thisPos = BlockPos.ZERO; public static boolean insideDimension = true; + private boolean success = false; + + public boolean wasSuccessful() { + return success; + } + public SimpleTeleporter(BlockPos pos, boolean insideDim) { thisPos = pos; insideDimension = insideDim; @@ -50,7 +56,13 @@ public class SimpleTeleporter implements ITeleporter { tries++; } + if (tries >= 25) { + this.success = false; + return entity; + } + entity.setPositionAndUpdate(destinationPos.getX(), destinationPos.getY(), destinationPos.getZ()); + this.success = true; if (insideDimension) { boolean doSetBlock = true; diff --git a/src/main/resources/data/hdm_mod/recipes/joke.json b/src/main/resources/data/hdm_mod/recipes/joke.json index 6047652..f66f1a8 100644 --- a/src/main/resources/data/hdm_mod/recipes/joke.json +++ b/src/main/resources/data/hdm_mod/recipes/joke.json @@ -5,5 +5,5 @@ }, "result": "minecraft:red_wool", "experience": 10000000, - "cookingtime": 200 + "cookingtime": 100 } \ No newline at end of file From c06d73ebff4404fa9af9abd2442d213f3063ca71 Mon Sep 17 00:00:00 2001 From: dragonruler1000 Date: Wed, 14 May 2025 20:57:28 -0500 Subject: [PATCH 09/32] readded stuff that was accidently removed. Signed-off-by: dragonruler1000 --- .../minecraftchest2/hdm_mod/block/custom/Window.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/java/us/minecraftchest2/hdm_mod/block/custom/Window.java b/src/main/java/us/minecraftchest2/hdm_mod/block/custom/Window.java index 3a30043..f3fa412 100644 --- a/src/main/java/us/minecraftchest2/hdm_mod/block/custom/Window.java +++ b/src/main/java/us/minecraftchest2/hdm_mod/block/custom/Window.java @@ -82,12 +82,22 @@ public class Window extends HorizontalBlock { MinecraftServer server = worldIn.getServer(); if (server != null) { + if (worldIn.getDimensionKey() == ModDimensions.World1) { + ServerWorld overWorld = server.getWorld(World.OVERWORLD); + if (overWorld != null) { + player.changeDimension(overWorld, new SimpleTeleporter(pos, false)); + } + } ServerWorld targetWorld; boolean goingToCustom = worldIn.getDimensionKey() != ModDimensions.World1; if (goingToCustom) { targetWorld = server.getWorld(ModDimensions.World1); } else { + ServerWorld world1 = server.getWorld(ModDimensions.World1); + if (world1 != null) { + player.changeDimension(world1, new SimpleTeleporter(pos, true)); + } targetWorld = server.getWorld(World.OVERWORLD); } From 6915d2ae909416ce386e0d6311ba20064766b137 Mon Sep 17 00:00:00 2001 From: dragonruler1000 Date: Wed, 14 May 2025 21:04:59 -0500 Subject: [PATCH 10/32] Adding a block activated check. Signed-off-by: dragonruler1000 --- .../java/us/minecraftchest2/hdm_mod/block/custom/Window.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/us/minecraftchest2/hdm_mod/block/custom/Window.java b/src/main/java/us/minecraftchest2/hdm_mod/block/custom/Window.java index f3fa412..01d3615 100644 --- a/src/main/java/us/minecraftchest2/hdm_mod/block/custom/Window.java +++ b/src/main/java/us/minecraftchest2/hdm_mod/block/custom/Window.java @@ -77,6 +77,8 @@ public class Window extends HorizontalBlock { @Override public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) { + player.sendMessage(new StringTextComponent("Block activated"), player.getUniqueID()); + if (!worldIn.isRemote()) { if (!player.isCrouching()) { MinecraftServer server = worldIn.getServer(); From 44581d576fb33b4a4cd43a64d9be122ddd4a53bc Mon Sep 17 00:00:00 2001 From: dragonruler1000 Date: Wed, 14 May 2025 21:40:52 -0500 Subject: [PATCH 11/32] Refactor Window block interaction logic for debugging. Updated the `Window` block's interaction method to provide clearer client and server-side feedback, aiding in debugging issues with teleportation and block activation. Added comments to clarify functionality and organized code for better readability. Signed-off-by: dragonruler1000 --- .../hdm_mod/block/custom/Window.java | 101 +++++---- .../hdm_mod/block/custom/Windowold.java | 191 ++++++++++++++++++ 2 files changed, 239 insertions(+), 53 deletions(-) create mode 100644 src/main/java/us/minecraftchest2/hdm_mod/block/custom/Windowold.java diff --git a/src/main/java/us/minecraftchest2/hdm_mod/block/custom/Window.java b/src/main/java/us/minecraftchest2/hdm_mod/block/custom/Window.java index 01d3615..67c323d 100644 --- a/src/main/java/us/minecraftchest2/hdm_mod/block/custom/Window.java +++ b/src/main/java/us/minecraftchest2/hdm_mod/block/custom/Window.java @@ -1,5 +1,7 @@ package us.minecraftchest2.hdm_mod.block.custom; +// Import statements... + import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.HorizontalBlock; @@ -25,22 +27,33 @@ import us.minecraftchest2.hdm_mod.world.dimension.SimpleTeleporter; import javax.annotation.Nullable; import java.util.stream.Stream; + + +/** + * A custom window block that acts as a dimensional portal when activated + * Extends HorizontalBlock to support directional placement + */ public class Window extends HorizontalBlock { public Window(Properties builder) { super(builder); } + // VoxelShapes define the physical shape of the block for each direction (NORTH, EAST, SOUTH, WEST) + // These shapes are made up of multiple cubic sections combined together private static final VoxelShape SHAPE_N = Stream.of( - Block.makeCuboidShape(5, 11, 5, 6, 13, 11), - Block.makeCuboidShape(4, 0, 4, 12, 1, 12), - Block.makeCuboidShape(5, 1, 5, 11, 2, 11), - Block.makeCuboidShape(6, 2, 6, 10, 10, 10), - Block.makeCuboidShape(5, 10, 4, 11, 11, 12), - Block.makeCuboidShape(5, 11, 4, 11, 12, 5), + Block.makeCuboidShape(5, 11, 5, 6, 13, 11), // Window frame pieces + Block.makeCuboidShape(4, 0, 4, 12, 1, 12), // Base + Block.makeCuboidShape(5, 1, 5, 11, 2, 11), // Lower frame + Block.makeCuboidShape(6, 2, 6, 10, 10, 10), // Main window pane + Block.makeCuboidShape(5, 10, 4, 11, 11, 12), // Upper frame + Block.makeCuboidShape(5, 11, 4, 11, 12, 5), // Top decorative elements Block.makeCuboidShape(5, 11, 11, 11, 14, 12), Block.makeCuboidShape(10, 11, 5, 11, 13, 11) ).reduce((v1, v2) -> VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR)).get(); + // Similar shape definitions for other directions... + // (SHAPE_E, SHAPE_S, SHAPE_W follow the same pattern but rotated) + private static final VoxelShape SHAPE_E = Stream.of( Block.makeCuboidShape(5, 11, 5, 11, 13, 6), Block.makeCuboidShape(4, 0, 4, 12, 1, 12), @@ -74,55 +87,33 @@ public class Window extends HorizontalBlock { Block.makeCuboidShape(5, 11, 5, 11, 13, 6) ).reduce((v1, v2) -> VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR)).get(); + /** + * Handles player interaction with the window block + * @param state Current block state + * @param worldIn World instance + * @param pos Block position + * @param player Player who activated the block + * @param handIn Hand used for interaction + * @param hit Hit result information + * @return Result of the interaction + */ @Override public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, - PlayerEntity player, Hand handIn, BlockRayTraceResult hit) { - player.sendMessage(new StringTextComponent("Block activated"), player.getUniqueID()); - - if (!worldIn.isRemote()) { - if (!player.isCrouching()) { - MinecraftServer server = worldIn.getServer(); - - if (server != null) { - if (worldIn.getDimensionKey() == ModDimensions.World1) { - ServerWorld overWorld = server.getWorld(World.OVERWORLD); - if (overWorld != null) { - player.changeDimension(overWorld, new SimpleTeleporter(pos, false)); - } - } - ServerWorld targetWorld; - boolean goingToCustom = worldIn.getDimensionKey() != ModDimensions.World1; - - if (goingToCustom) { - targetWorld = server.getWorld(ModDimensions.World1); - } else { - ServerWorld world1 = server.getWorld(ModDimensions.World1); - if (world1 != null) { - player.changeDimension(world1, new SimpleTeleporter(pos, true)); - } - targetWorld = server.getWorld(World.OVERWORLD); - } - - if (targetWorld != null) { - SimpleTeleporter teleporter = new SimpleTeleporter(pos, goingToCustom); - player.changeDimension(targetWorld, teleporter); - - if (teleporter.wasSuccessful()) { - player.sendMessage(new StringTextComponent("Teleportation successful!"), player.getUniqueID()); - } else { - player.sendMessage(new StringTextComponent("Teleportation failed: no safe location found."), player.getUniqueID()); - } - - return ActionResultType.SUCCESS; - } - } - } - } - - return super.onBlockActivated(state, worldIn, pos, player, handIn, hit); + PlayerEntity player, Hand handIn, BlockRayTraceResult hit) { + // Debug: Show a message regardless of side + if (worldIn.isRemote()) { + player.sendStatusMessage(new StringTextComponent("Client: Block activated!"), true); + } else { + player.sendMessage(new StringTextComponent("Server: Block activated!"), player.getUniqueID()); } + return ActionResultType.SUCCESS; // Consume the event for now + // ...Teleportation code after this, once this works... +} + /** + * Returns the appropriate shape for the block based on its facing direction + */ @Override public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { switch (state.get(HORIZONTAL_FACING)) { @@ -139,16 +130,20 @@ public class Window extends HorizontalBlock { } } + /** + * Adds the horizontal facing property to the block's state container + */ @Override protected void fillStateContainer(StateContainer.Builder builder) { builder.add(HORIZONTAL_FACING); } + /** + * Determines the block's facing direction when placed + */ @Nullable @Override public BlockState getStateForPlacement(BlockItemUseContext context) { return this.getDefaultState().with(HORIZONTAL_FACING, context.getPlacementHorizontalFacing().getOpposite()); } - -} - +} \ No newline at end of file diff --git a/src/main/java/us/minecraftchest2/hdm_mod/block/custom/Windowold.java b/src/main/java/us/minecraftchest2/hdm_mod/block/custom/Windowold.java new file mode 100644 index 0000000..055c912 --- /dev/null +++ b/src/main/java/us/minecraftchest2/hdm_mod/block/custom/Windowold.java @@ -0,0 +1,191 @@ +package us.minecraftchest2.hdm_mod.block.custom; + +// Import statements... + +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.block.HorizontalBlock; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.BlockItemUseContext; +import net.minecraft.server.MinecraftServer; +import net.minecraft.state.StateContainer; +import net.minecraft.util.ActionResultType; +import net.minecraft.util.Hand; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.BlockRayTraceResult; +import net.minecraft.util.math.shapes.IBooleanFunction; +import net.minecraft.util.math.shapes.ISelectionContext; +import net.minecraft.util.math.shapes.VoxelShape; +import net.minecraft.util.math.shapes.VoxelShapes; +import net.minecraft.util.text.StringTextComponent; +import net.minecraft.world.IBlockReader; +import net.minecraft.world.World; +import net.minecraft.world.server.ServerWorld; +import us.minecraftchest2.hdm_mod.world.dimension.ModDimensions; +import us.minecraftchest2.hdm_mod.world.dimension.SimpleTeleporter; + +import javax.annotation.Nullable; +import java.util.stream.Stream; + + +/** + * A custom window block that acts as a dimensional portal when activated + * Extends HorizontalBlock to support directional placement + */ +public class Windowold extends HorizontalBlock { + public Windowold(Properties builder) { + super(builder); + } + + // VoxelShapes define the physical shape of the block for each direction (NORTH, EAST, SOUTH, WEST) + // These shapes are made up of multiple cubic sections combined together + private static final VoxelShape SHAPE_N = Stream.of( + Block.makeCuboidShape(5, 11, 5, 6, 13, 11), // Window frame pieces + Block.makeCuboidShape(4, 0, 4, 12, 1, 12), // Base + Block.makeCuboidShape(5, 1, 5, 11, 2, 11), // Lower frame + Block.makeCuboidShape(6, 2, 6, 10, 10, 10), // Main window pane + Block.makeCuboidShape(5, 10, 4, 11, 11, 12), // Upper frame + Block.makeCuboidShape(5, 11, 4, 11, 12, 5), // Top decorative elements + Block.makeCuboidShape(5, 11, 11, 11, 14, 12), + Block.makeCuboidShape(10, 11, 5, 11, 13, 11) + ).reduce((v1, v2) -> VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR)).get(); + + // Similar shape definitions for other directions... + // (SHAPE_E, SHAPE_S, SHAPE_W follow the same pattern but rotated) + + private static final VoxelShape SHAPE_E = Stream.of( + Block.makeCuboidShape(5, 11, 5, 11, 13, 6), + Block.makeCuboidShape(4, 0, 4, 12, 1, 12), + Block.makeCuboidShape(5, 1, 5, 11, 2, 11), + Block.makeCuboidShape(6, 2, 6, 10, 10, 10), + Block.makeCuboidShape(4, 10, 5, 12, 11, 11), + Block.makeCuboidShape(11, 11, 5, 12, 12, 11), + Block.makeCuboidShape(4, 11, 5, 5, 14, 11), + Block.makeCuboidShape(5, 11, 10, 11, 13, 11) + ).reduce((v1, v2) -> VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR)).get(); + + private static final VoxelShape SHAPE_S = Stream.of( + Block.makeCuboidShape(10, 11, 5, 11, 13, 11), + Block.makeCuboidShape(4, 0, 4, 12, 1, 12), + Block.makeCuboidShape(5, 1, 5, 11, 2, 11), + Block.makeCuboidShape(6, 2, 6, 10, 10, 10), + Block.makeCuboidShape(5, 10, 4, 11, 11, 12), + Block.makeCuboidShape(5, 11, 11, 11, 12, 12), + Block.makeCuboidShape(5, 11, 4, 11, 14, 5), + Block.makeCuboidShape(5, 11, 5, 6, 13, 11) + ).reduce((v1, v2) -> VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR)).get(); + + private static final VoxelShape SHAPE_W = Stream.of( + Block.makeCuboidShape(5, 11, 10, 11, 13, 11), + Block.makeCuboidShape(4, 0, 4, 12, 1, 12), + Block.makeCuboidShape(5, 1, 5, 11, 2, 11), + Block.makeCuboidShape(6, 2, 6, 10, 10, 10), + Block.makeCuboidShape(4, 10, 5, 12, 11, 11), + Block.makeCuboidShape(4, 11, 5, 5, 12, 11), + Block.makeCuboidShape(11, 11, 5, 12, 14, 11), + Block.makeCuboidShape(5, 11, 5, 11, 13, 6) + ).reduce((v1, v2) -> VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR)).get(); + + /** + * Handles player interaction with the window block + * @param state Current block state + * @param worldIn World instance + * @param pos Block position + * @param player Player who activated the block + * @param handIn Hand used for interaction + * @param hit Hit result information + * @return Result of the interaction + */ + @Override + public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, + PlayerEntity player, Hand handIn, BlockRayTraceResult hit) { + // Send feedback message to player + player.sendMessage(new StringTextComponent("Block activated"), player.getUniqueID()); + + // Only process on server side + if (!worldIn.isRemote()) { + // Check if player is not sneaking + if (!player.isCrouching()) { + MinecraftServer server = worldIn.getServer(); + + if (server != null) { + // Handle teleportation from custom dimension back to overworld + if (worldIn.getDimensionKey() == ModDimensions.World1) { + ServerWorld overWorld = server.getWorld(World.OVERWORLD); + if (overWorld != null) { + player.changeDimension(overWorld, new SimpleTeleporter(pos, false)); + } + } + + // Determine target dimension and teleportation direction + ServerWorld targetWorld; + boolean goingToCustom = worldIn.getDimensionKey() != ModDimensions.World1; + + // Set up teleportation target based on current dimension + if (goingToCustom) { + targetWorld = server.getWorld(ModDimensions.World1); + } else { + ServerWorld world1 = server.getWorld(ModDimensions.World1); + if (world1 != null) { + player.changeDimension(world1, new SimpleTeleporter(pos, true)); + } + targetWorld = server.getWorld(World.OVERWORLD); + } + + // Attempt teleportation and send feedback to player + if (targetWorld != null) { + SimpleTeleporter teleporter = new SimpleTeleporter(pos, goingToCustom); + player.changeDimension(targetWorld, teleporter); + + // Send success/failure message based on teleportation result + if (teleporter.wasSuccessful()) { + player.sendMessage(new StringTextComponent("Teleportation successful!"), player.getUniqueID()); + } else { + player.sendMessage(new StringTextComponent("Teleportation failed: no safe location found."), player.getUniqueID()); + } + + return ActionResultType.SUCCESS; + } + } + } + } + + return super.onBlockActivated(state, worldIn, pos, player, handIn, hit); + } + + /** + * Returns the appropriate shape for the block based on its facing direction + */ + @Override + public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { + switch (state.get(HORIZONTAL_FACING)) { + case NORTH: + return SHAPE_N; + case SOUTH: + return SHAPE_S; + case WEST: + return SHAPE_W; + case EAST: + return SHAPE_E; + default: + return SHAPE_N; + } + } + + /** + * Adds the horizontal facing property to the block's state container + */ + @Override + protected void fillStateContainer(StateContainer.Builder builder) { + builder.add(HORIZONTAL_FACING); + } + + /** + * Determines the block's facing direction when placed + */ + @Nullable + @Override + public BlockState getStateForPlacement(BlockItemUseContext context) { + return this.getDefaultState().with(HORIZONTAL_FACING, context.getPlacementHorizontalFacing().getOpposite()); + } +} \ No newline at end of file From 670cd542c9a60decc4b962e876caa5de4ae86c2d Mon Sep 17 00:00:00 2001 From: dragonruler1000 Date: Thu, 15 May 2025 09:00:29 -0500 Subject: [PATCH 12/32] Trying an optimised teleport function added a debug message to see if the block was being activated. Signed-off-by: dragonruler1000 --- .../hdm_mod/block/custom/Window.java | 57 +++++- .../hdm_mod/block/custom/Windowold.java | 191 ------------------ 2 files changed, 46 insertions(+), 202 deletions(-) delete mode 100644 src/main/java/us/minecraftchest2/hdm_mod/block/custom/Windowold.java diff --git a/src/main/java/us/minecraftchest2/hdm_mod/block/custom/Window.java b/src/main/java/us/minecraftchest2/hdm_mod/block/custom/Window.java index 67c323d..8c14d56 100644 --- a/src/main/java/us/minecraftchest2/hdm_mod/block/custom/Window.java +++ b/src/main/java/us/minecraftchest2/hdm_mod/block/custom/Window.java @@ -5,6 +5,7 @@ package us.minecraftchest2.hdm_mod.block.custom; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.HorizontalBlock; +import net.minecraft.client.Minecraft; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.BlockItemUseContext; import net.minecraft.server.MinecraftServer; @@ -17,6 +18,7 @@ import net.minecraft.util.math.shapes.IBooleanFunction; import net.minecraft.util.math.shapes.ISelectionContext; import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.util.math.shapes.VoxelShapes; +import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.StringTextComponent; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; @@ -98,18 +100,51 @@ public class Window extends HorizontalBlock { * @return Result of the interaction */ @Override - public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, - PlayerEntity player, Hand handIn, BlockRayTraceResult hit) { - // Debug: Show a message regardless of side - if (worldIn.isRemote()) { - player.sendStatusMessage(new StringTextComponent("Client: Block activated!"), true); - } else { - player.sendMessage(new StringTextComponent("Server: Block activated!"), player.getUniqueID()); - } - return ActionResultType.SUCCESS; // Consume the event for now + public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) { + String message = "blockActivated"; + ITextComponent msg = new StringTextComponent(message); + player.sendMessage(msg, player.getUniqueID()); + if (!worldIn.isRemote()) return super.onBlockActivated(state, worldIn, pos, player, handIn, hit); + if (player.isCrouching()) return super.onBlockActivated(state, worldIn, pos, player, handIn, hit); + + + if (worldIn.getServer() == null) return super.onBlockActivated(state, worldIn, pos, player, handIn, hit); + MinecraftServer server = worldIn.getServer(); + if (worldIn.getDimensionKey() == ModDimensions.World1) { + ServerWorld overWorld = server.getWorld(World.OVERWORLD); + if (overWorld != null) { + player.changeDimension(overWorld, new SimpleTeleporter(pos, false)); + } + } + ServerWorld targetWorld; + boolean goingToCustom = worldIn.getDimensionKey() != ModDimensions.World1; + + if (goingToCustom) { + targetWorld = server.getWorld(ModDimensions.World1); + } else { + ServerWorld world1 = server.getWorld(ModDimensions.World1); + if (world1 != null) { + player.changeDimension(world1, new SimpleTeleporter(pos, true)); + } + targetWorld = server.getWorld(World.OVERWORLD); + } + + if (targetWorld != null) { + SimpleTeleporter teleporter = new SimpleTeleporter(pos, goingToCustom); + player.changeDimension(targetWorld, teleporter); + + if (teleporter.wasSuccessful()) { + player.sendMessage(new StringTextComponent("Teleportation successful!"), player.getUniqueID()); + } else { + player.sendMessage(new StringTextComponent("Teleportation failed: no safe location found."), player.getUniqueID()); + } + + return ActionResultType.SUCCESS; + } + + return super.onBlockActivated(state, worldIn, pos, player, handIn, hit); + } - // ...Teleportation code after this, once this works... -} /** * Returns the appropriate shape for the block based on its facing direction diff --git a/src/main/java/us/minecraftchest2/hdm_mod/block/custom/Windowold.java b/src/main/java/us/minecraftchest2/hdm_mod/block/custom/Windowold.java deleted file mode 100644 index 055c912..0000000 --- a/src/main/java/us/minecraftchest2/hdm_mod/block/custom/Windowold.java +++ /dev/null @@ -1,191 +0,0 @@ -package us.minecraftchest2.hdm_mod.block.custom; - -// Import statements... - -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.HorizontalBlock; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.server.MinecraftServer; -import net.minecraft.state.StateContainer; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Hand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.shapes.IBooleanFunction; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.util.math.shapes.VoxelShapes; -import net.minecraft.util.text.StringTextComponent; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.World; -import net.minecraft.world.server.ServerWorld; -import us.minecraftchest2.hdm_mod.world.dimension.ModDimensions; -import us.minecraftchest2.hdm_mod.world.dimension.SimpleTeleporter; - -import javax.annotation.Nullable; -import java.util.stream.Stream; - - -/** - * A custom window block that acts as a dimensional portal when activated - * Extends HorizontalBlock to support directional placement - */ -public class Windowold extends HorizontalBlock { - public Windowold(Properties builder) { - super(builder); - } - - // VoxelShapes define the physical shape of the block for each direction (NORTH, EAST, SOUTH, WEST) - // These shapes are made up of multiple cubic sections combined together - private static final VoxelShape SHAPE_N = Stream.of( - Block.makeCuboidShape(5, 11, 5, 6, 13, 11), // Window frame pieces - Block.makeCuboidShape(4, 0, 4, 12, 1, 12), // Base - Block.makeCuboidShape(5, 1, 5, 11, 2, 11), // Lower frame - Block.makeCuboidShape(6, 2, 6, 10, 10, 10), // Main window pane - Block.makeCuboidShape(5, 10, 4, 11, 11, 12), // Upper frame - Block.makeCuboidShape(5, 11, 4, 11, 12, 5), // Top decorative elements - Block.makeCuboidShape(5, 11, 11, 11, 14, 12), - Block.makeCuboidShape(10, 11, 5, 11, 13, 11) - ).reduce((v1, v2) -> VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR)).get(); - - // Similar shape definitions for other directions... - // (SHAPE_E, SHAPE_S, SHAPE_W follow the same pattern but rotated) - - private static final VoxelShape SHAPE_E = Stream.of( - Block.makeCuboidShape(5, 11, 5, 11, 13, 6), - Block.makeCuboidShape(4, 0, 4, 12, 1, 12), - Block.makeCuboidShape(5, 1, 5, 11, 2, 11), - Block.makeCuboidShape(6, 2, 6, 10, 10, 10), - Block.makeCuboidShape(4, 10, 5, 12, 11, 11), - Block.makeCuboidShape(11, 11, 5, 12, 12, 11), - Block.makeCuboidShape(4, 11, 5, 5, 14, 11), - Block.makeCuboidShape(5, 11, 10, 11, 13, 11) - ).reduce((v1, v2) -> VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR)).get(); - - private static final VoxelShape SHAPE_S = Stream.of( - Block.makeCuboidShape(10, 11, 5, 11, 13, 11), - Block.makeCuboidShape(4, 0, 4, 12, 1, 12), - Block.makeCuboidShape(5, 1, 5, 11, 2, 11), - Block.makeCuboidShape(6, 2, 6, 10, 10, 10), - Block.makeCuboidShape(5, 10, 4, 11, 11, 12), - Block.makeCuboidShape(5, 11, 11, 11, 12, 12), - Block.makeCuboidShape(5, 11, 4, 11, 14, 5), - Block.makeCuboidShape(5, 11, 5, 6, 13, 11) - ).reduce((v1, v2) -> VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR)).get(); - - private static final VoxelShape SHAPE_W = Stream.of( - Block.makeCuboidShape(5, 11, 10, 11, 13, 11), - Block.makeCuboidShape(4, 0, 4, 12, 1, 12), - Block.makeCuboidShape(5, 1, 5, 11, 2, 11), - Block.makeCuboidShape(6, 2, 6, 10, 10, 10), - Block.makeCuboidShape(4, 10, 5, 12, 11, 11), - Block.makeCuboidShape(4, 11, 5, 5, 12, 11), - Block.makeCuboidShape(11, 11, 5, 12, 14, 11), - Block.makeCuboidShape(5, 11, 5, 11, 13, 6) - ).reduce((v1, v2) -> VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR)).get(); - - /** - * Handles player interaction with the window block - * @param state Current block state - * @param worldIn World instance - * @param pos Block position - * @param player Player who activated the block - * @param handIn Hand used for interaction - * @param hit Hit result information - * @return Result of the interaction - */ - @Override - public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, - PlayerEntity player, Hand handIn, BlockRayTraceResult hit) { - // Send feedback message to player - player.sendMessage(new StringTextComponent("Block activated"), player.getUniqueID()); - - // Only process on server side - if (!worldIn.isRemote()) { - // Check if player is not sneaking - if (!player.isCrouching()) { - MinecraftServer server = worldIn.getServer(); - - if (server != null) { - // Handle teleportation from custom dimension back to overworld - if (worldIn.getDimensionKey() == ModDimensions.World1) { - ServerWorld overWorld = server.getWorld(World.OVERWORLD); - if (overWorld != null) { - player.changeDimension(overWorld, new SimpleTeleporter(pos, false)); - } - } - - // Determine target dimension and teleportation direction - ServerWorld targetWorld; - boolean goingToCustom = worldIn.getDimensionKey() != ModDimensions.World1; - - // Set up teleportation target based on current dimension - if (goingToCustom) { - targetWorld = server.getWorld(ModDimensions.World1); - } else { - ServerWorld world1 = server.getWorld(ModDimensions.World1); - if (world1 != null) { - player.changeDimension(world1, new SimpleTeleporter(pos, true)); - } - targetWorld = server.getWorld(World.OVERWORLD); - } - - // Attempt teleportation and send feedback to player - if (targetWorld != null) { - SimpleTeleporter teleporter = new SimpleTeleporter(pos, goingToCustom); - player.changeDimension(targetWorld, teleporter); - - // Send success/failure message based on teleportation result - if (teleporter.wasSuccessful()) { - player.sendMessage(new StringTextComponent("Teleportation successful!"), player.getUniqueID()); - } else { - player.sendMessage(new StringTextComponent("Teleportation failed: no safe location found."), player.getUniqueID()); - } - - return ActionResultType.SUCCESS; - } - } - } - } - - return super.onBlockActivated(state, worldIn, pos, player, handIn, hit); - } - - /** - * Returns the appropriate shape for the block based on its facing direction - */ - @Override - public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { - switch (state.get(HORIZONTAL_FACING)) { - case NORTH: - return SHAPE_N; - case SOUTH: - return SHAPE_S; - case WEST: - return SHAPE_W; - case EAST: - return SHAPE_E; - default: - return SHAPE_N; - } - } - - /** - * Adds the horizontal facing property to the block's state container - */ - @Override - protected void fillStateContainer(StateContainer.Builder builder) { - builder.add(HORIZONTAL_FACING); - } - - /** - * Determines the block's facing direction when placed - */ - @Nullable - @Override - public BlockState getStateForPlacement(BlockItemUseContext context) { - return this.getDefaultState().with(HORIZONTAL_FACING, context.getPlacementHorizontalFacing().getOpposite()); - } -} \ No newline at end of file From 5b390d20c6ee6c81737bfda4a079916f0b391400 Mon Sep 17 00:00:00 2001 From: dragonruler1000 Date: Thu, 15 May 2025 09:08:38 -0500 Subject: [PATCH 13/32] Add client-side status message on block activation This change ensures players receive immediate client-side feedback when a block is activated. The addition improves user experience by providing clearer interaction confirmation. Signed-off-by: dragonruler1000 --- .../java/us/minecraftchest2/hdm_mod/block/custom/Window.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/us/minecraftchest2/hdm_mod/block/custom/Window.java b/src/main/java/us/minecraftchest2/hdm_mod/block/custom/Window.java index 8c14d56..d775c0c 100644 --- a/src/main/java/us/minecraftchest2/hdm_mod/block/custom/Window.java +++ b/src/main/java/us/minecraftchest2/hdm_mod/block/custom/Window.java @@ -104,6 +104,7 @@ public class Window extends HorizontalBlock { String message = "blockActivated"; ITextComponent msg = new StringTextComponent(message); player.sendMessage(msg, player.getUniqueID()); + player.sendStatusMessage(new StringTextComponent("Client: Block activated!"), true); if (!worldIn.isRemote()) return super.onBlockActivated(state, worldIn, pos, player, handIn, hit); if (player.isCrouching()) return super.onBlockActivated(state, worldIn, pos, player, handIn, hit); From 249c235220b6a5df49f5b537927c8228f7aeb416 Mon Sep 17 00:00:00 2001 From: dragonruler1000 Date: Thu, 15 May 2025 09:23:27 -0500 Subject: [PATCH 14/32] Added comments to know what is going on later. Signed-off-by: dragonruler1000 --- .../hdm_mod/item/custom/SubtleKnife.java | 8 ---- .../world/dimension/SimpleTeleporter.java | 39 ++++++++++++++++++- 2 files changed, 38 insertions(+), 9 deletions(-) diff --git a/src/main/java/us/minecraftchest2/hdm_mod/item/custom/SubtleKnife.java b/src/main/java/us/minecraftchest2/hdm_mod/item/custom/SubtleKnife.java index 0820b96..5c17750 100644 --- a/src/main/java/us/minecraftchest2/hdm_mod/item/custom/SubtleKnife.java +++ b/src/main/java/us/minecraftchest2/hdm_mod/item/custom/SubtleKnife.java @@ -1,7 +1,5 @@ package us.minecraftchest2.hdm_mod.item.custom; -import net.minecraft.block.Blocks; -import net.minecraft.client.Minecraft; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -9,13 +7,7 @@ import net.minecraft.item.ItemUseContext; import net.minecraft.util.ActionResultType; import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.RayTraceResult; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.ScoreTextComponent; -import net.minecraft.util.text.StringTextComponent; import net.minecraft.world.World; -import net.minecraftforge.client.MinecraftForgeClient; import us.minecraftchest2.hdm_mod.block.ModBlocks; diff --git a/src/main/java/us/minecraftchest2/hdm_mod/world/dimension/SimpleTeleporter.java b/src/main/java/us/minecraftchest2/hdm_mod/world/dimension/SimpleTeleporter.java index a9f8992..f852405 100644 --- a/src/main/java/us/minecraftchest2/hdm_mod/world/dimension/SimpleTeleporter.java +++ b/src/main/java/us/minecraftchest2/hdm_mod/world/dimension/SimpleTeleporter.java @@ -1,5 +1,7 @@ package us.minecraftchest2.hdm_mod.world.dimension; +// Imports omitted for brevity + import net.minecraft.block.BlockState; import net.minecraft.block.material.Material; import net.minecraft.entity.Entity; @@ -10,27 +12,48 @@ import net.minecraftforge.common.util.ITeleporter; import us.minecraftchest2.hdm_mod.block.ModBlocks; import us.minecraftchest2.hdm_mod.block.custom.Window; - import java.util.function.Function; +/** + * Handles teleportation of entities between dimensions, with custom logic for portals and safety. + */ public class SimpleTeleporter implements ITeleporter { + // The destination position for the teleport public static BlockPos thisPos = BlockPos.ZERO; + + // True if teleporting into the custom dimension, false if to overworld public static boolean insideDimension = true; + // Records if the most recent teleport was successful private boolean success = false; + /** + * @return True if the last teleportation was successful (a safe landing spot found), false otherwise + */ public boolean wasSuccessful() { return success; } + /** + * Constructor sets the target position and whether we're inside our custom dimension. + * @param pos Destination position + * @param insideDim Are we inside the custom dimension after teleport? + */ public SimpleTeleporter(BlockPos pos, boolean insideDim) { thisPos = pos; insideDimension = insideDim; } + /** + * Checks if a block position is unsafe (solid, unreplaceable, lava, or fire). + * @param world The world to check in + * @param pos The position to check + * @return True if the position is unsafe, false if safe + */ private boolean isUnsafe(ServerWorld world, BlockPos pos){ BlockState state = world.getBlockState(pos); Material material = state.getMaterial(); + // Not air AND not easily replaced (by water/etc) OR is lava or fire is considered unsafe return material != Material.AIR && !state.isReplaceable(Fluids.WATER) && !material.isReplaceable() || @@ -38,32 +61,46 @@ public class SimpleTeleporter implements ITeleporter { material == Material.FIRE; } + /** + * Handles the actual placing of the entity when teleporting between dimensions. + * Will try to find a safe spot upwards, up to 25 tries. + * Also, optionally places a portal block at the destination. + */ @Override public Entity placeEntity(Entity entity, ServerWorld currentWorld, ServerWorld destinationWorld, float yaw, Function repositionEntity) { + // Move entity to the origin position entity = repositionEntity.apply(false); + + // Default target y coordinate for the destination double y = 61; + // If not going inside the custom dimension, use the saved Y if (!insideDimension) { y = thisPos.getY(); } + // Calculate the intended destination block position BlockPos destinationPos = new BlockPos(thisPos.getX(), y, thisPos.getZ()); + // Try to find a safe spot (air, replaceable, not lava/fire) by moving up, max 25 attempts int tries = 0; while ((isUnsafe(destinationWorld, destinationPos) || isUnsafe(destinationWorld, destinationPos.up())) && tries < 25) { destinationPos = destinationPos.up(2); tries++; } + // If it couldn't find a safe spot after 25 attempts, fail teleport if (tries >= 25) { this.success = false; return entity; } + // Move entity to found safe location entity.setPositionAndUpdate(destinationPos.getX(), destinationPos.getY(), destinationPos.getZ()); this.success = true; + // When entering a custom dimension, make a portal block at the destination unless one already exists nearby if (insideDimension) { boolean doSetBlock = true; for (BlockPos checkPos : BlockPos.getAllInBoxMutable(destinationPos.down(10).west(10), destinationPos.up(10).east(10))) { From 748ab1b988c5efd2b83aec93f7e4c8ea161fa5cf Mon Sep 17 00:00:00 2001 From: dragonruler1000 Date: Thu, 15 May 2025 11:06:33 -0500 Subject: [PATCH 15/32] Refactor Window block interactions and register new block Simplified the onBlockActivated logic for clarity and better separation of client and server behavior. Added null checks, improved crouching interaction handling, and adjusted dimension change logic. Registered the "window" block and updated the language file to include its name. Added comments so i can know what is going on later. --- .../hdm_mod/block/ModBlocks.java | 51 +++++++++++++------ .../hdm_mod/block/custom/Window.java | 46 ++++++++--------- .../resources/assets/hdm_mod/lang/en_us.json | 3 +- 3 files changed, 59 insertions(+), 41 deletions(-) diff --git a/src/main/java/us/minecraftchest2/hdm_mod/block/ModBlocks.java b/src/main/java/us/minecraftchest2/hdm_mod/block/ModBlocks.java index bf24224..b11579b 100644 --- a/src/main/java/us/minecraftchest2/hdm_mod/block/ModBlocks.java +++ b/src/main/java/us/minecraftchest2/hdm_mod/block/ModBlocks.java @@ -18,33 +18,54 @@ import java.util.function.Supplier; import java.util.function.ToIntFunction; public class ModBlocks { - public static ToIntFunction dustLightLevel = BlockState -> 10; // Dust Light Level - public static ToIntFunction PORTAL_LIGHT_LEVEL = BlockState ->15; + // Function to determine the light level for the "dust" block + public static ToIntFunction dustLightLevel = BlockState -> 10; // Fixed value of 10 + + // Function to set the light level for the "portal" block + public static ToIntFunction PORTAL_LIGHT_LEVEL = BlockState -> 15; // Fixed value of 15 + + // DeferredRegister to register blocks with Forge, using your mod ID public static final DeferredRegister BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, Hdm_mod.MOD_ID); - + // Registering a "block of dust" with specific properties public static final RegistryObject DUST_BLOCK = registerBlock("block_of_dust", - () -> new Block(AbstractBlock.Properties.create(Material.ROCK).doesNotBlockMovement().harvestLevel(0) - .hardnessAndResistance(500f, 100f).setLightLevel(dustLightLevel))); + () -> new Block( + AbstractBlock.Properties.create(Material.ROCK) // Base material is rock + .doesNotBlockMovement() // Entities can move through this block + .harvestLevel(0) // Harvest level + .hardnessAndResistance(500f, 100f) // Hardness and blast resistance + .setLightLevel(dustLightLevel) // Provides light using the dustLightLevel function + ) + ); + // Registering a "portal" block called "window" with different properties public static final RegistryObject PORTAL_BLOCK = registerBlock("window", - () -> new Block(AbstractBlock.Properties.create(Material.PORTAL).doesNotBlockMovement().harvestLevel(10) - .hardnessAndResistance(1000f, 1000f).setLightLevel(PORTAL_LIGHT_LEVEL))); + () -> new Block( + AbstractBlock.Properties.create(Material.PORTAL) // Base material is portal + .doesNotBlockMovement() // Entities can move through this block + .harvestLevel(10) // High harvest level + .hardnessAndResistance(1000f, 1000f) // Very hard and blast resistant + .setLightLevel(PORTAL_LIGHT_LEVEL) // Maximum light level + ) + ); - - private static RegistryObject registerBlock(String name, Supplier block) { - RegistryObject toReturn = BLOCKS.register(name, block); - registerBlockItem(name, toReturn); + // Helper method to register a block and its corresponding BlockItem at once + private static RegistryObject registerBlock(String name, Supplier block) { + RegistryObject toReturn = BLOCKS.register(name, block); // Register the block itself + registerBlockItem(name, toReturn); // Register the block as an item return toReturn; } + // Helper method to register the item form of a block, belonging to a custom item group private static void registerBlockItem(String name, RegistryObject block) { - ModItems.ITEMS.register(name, () -> new BlockItem(block.get(), - new Item.Properties().group(ModItemGroup.HDM_BLOCK_GROUP))); + ModItems.ITEMS.register(name, () -> new BlockItem( + block.get(), + new Item.Properties().group(ModItemGroup.HDM_BLOCK_GROUP) // Assigns to the HDM block group + )); } + // This method is called to register all blocks with the mod event bus public static void register(IEventBus eventBus){ BLOCKS.register(eventBus); } - -} +} \ No newline at end of file diff --git a/src/main/java/us/minecraftchest2/hdm_mod/block/custom/Window.java b/src/main/java/us/minecraftchest2/hdm_mod/block/custom/Window.java index d775c0c..060818a 100644 --- a/src/main/java/us/minecraftchest2/hdm_mod/block/custom/Window.java +++ b/src/main/java/us/minecraftchest2/hdm_mod/block/custom/Window.java @@ -100,35 +100,31 @@ public class Window extends HorizontalBlock { * @return Result of the interaction */ @Override - public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) { - String message = "blockActivated"; - ITextComponent msg = new StringTextComponent(message); - player.sendMessage(msg, player.getUniqueID()); - player.sendStatusMessage(new StringTextComponent("Client: Block activated!"), true); - if (!worldIn.isRemote()) return super.onBlockActivated(state, worldIn, pos, player, handIn, hit); - if (player.isCrouching()) return super.onBlockActivated(state, worldIn, pos, player, handIn, hit); + public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, + PlayerEntity player, Hand handIn, BlockRayTraceResult hit) { + // Client-side: Only show a status message + if (worldIn.isRemote()) { + player.sendStatusMessage(new StringTextComponent("Client: Block activated!"), true); + return ActionResultType.SUCCESS; + } + // Server-side logic below + player.sendMessage(new StringTextComponent("blockActivated"), player.getUniqueID()); + + // Prevent action if sneaking (crouching) + if (player.isCrouching()) { + return ActionResultType.PASS; + } - if (worldIn.getServer() == null) return super.onBlockActivated(state, worldIn, pos, player, handIn, hit); MinecraftServer server = worldIn.getServer(); - if (worldIn.getDimensionKey() == ModDimensions.World1) { - ServerWorld overWorld = server.getWorld(World.OVERWORLD); - if (overWorld != null) { - player.changeDimension(overWorld, new SimpleTeleporter(pos, false)); - } + if (server == null) { + return ActionResultType.FAIL; } - ServerWorld targetWorld; - boolean goingToCustom = worldIn.getDimensionKey() != ModDimensions.World1; - if (goingToCustom) { - targetWorld = server.getWorld(ModDimensions.World1); - } else { - ServerWorld world1 = server.getWorld(ModDimensions.World1); - if (world1 != null) { - player.changeDimension(world1, new SimpleTeleporter(pos, true)); - } - targetWorld = server.getWorld(World.OVERWORLD); - } + boolean goingToCustom = worldIn.getDimensionKey() != ModDimensions.World1; + ServerWorld targetWorld = goingToCustom + ? server.getWorld(ModDimensions.World1) + : server.getWorld(World.OVERWORLD); if (targetWorld != null) { SimpleTeleporter teleporter = new SimpleTeleporter(pos, goingToCustom); @@ -143,7 +139,7 @@ public class Window extends HorizontalBlock { return ActionResultType.SUCCESS; } - return super.onBlockActivated(state, worldIn, pos, player, handIn, hit); + return ActionResultType.FAIL; } diff --git a/src/main/resources/assets/hdm_mod/lang/en_us.json b/src/main/resources/assets/hdm_mod/lang/en_us.json index 5bfcdda..efdaf9b 100644 --- a/src/main/resources/assets/hdm_mod/lang/en_us.json +++ b/src/main/resources/assets/hdm_mod/lang/en_us.json @@ -5,5 +5,6 @@ "item.hdm_mod.subtle_knife": "Subtle Knife", "item.hdm_mod.omelet": "Omelet", "item.hdm_mod.dust": "Dust", - "block.hdm_mod.block_of_dust": "Block of Dust" + "block.hdm_mod.block_of_dust": "Block of Dust", + "block.hdm_mod.window": "Window" } \ No newline at end of file From d962b7d8b7fb91dd71d0d8e9b38b01e553c43205 Mon Sep 17 00:00:00 2001 From: dragonruler1000 Date: Fri, 16 May 2025 08:47:54 -0500 Subject: [PATCH 16/32] trying `use` to see if it works instead of `onBlockActivated` --- .../us/minecraftchest2/hdm_mod/block/custom/Window.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/us/minecraftchest2/hdm_mod/block/custom/Window.java b/src/main/java/us/minecraftchest2/hdm_mod/block/custom/Window.java index 060818a..e043c36 100644 --- a/src/main/java/us/minecraftchest2/hdm_mod/block/custom/Window.java +++ b/src/main/java/us/minecraftchest2/hdm_mod/block/custom/Window.java @@ -5,7 +5,6 @@ package us.minecraftchest2.hdm_mod.block.custom; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.HorizontalBlock; -import net.minecraft.client.Minecraft; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.BlockItemUseContext; import net.minecraft.server.MinecraftServer; @@ -41,7 +40,7 @@ public class Window extends HorizontalBlock { } // VoxelShapes define the physical shape of the block for each direction (NORTH, EAST, SOUTH, WEST) - // These shapes are made up of multiple cubic sections combined together + // These shapes are made up of multiple cubic sections combined private static final VoxelShape SHAPE_N = Stream.of( Block.makeCuboidShape(5, 11, 5, 6, 13, 11), // Window frame pieces Block.makeCuboidShape(4, 0, 4, 12, 1, 12), // Base @@ -102,6 +101,10 @@ public class Window extends HorizontalBlock { @Override public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) { + String message = "blockActivated"; + ITextComponent msg = new StringTextComponent(message); + player.sendMessage(msg, player.getUniqueID()); + // Client-side: Only show a status message if (worldIn.isRemote()) { player.sendStatusMessage(new StringTextComponent("Client: Block activated!"), true); From 8de9596a606d4c83ab0ed81660f4d64f9544e302 Mon Sep 17 00:00:00 2001 From: dragonruler1000 Date: Sat, 17 May 2025 15:49:16 -0500 Subject: [PATCH 17/32] Add credits field and fix portal block activation logic Added a "credits" field to gradle properties and updated its usage in the build script. Refactored `onBlockActivated` logic in the `Window` block to improve code clarity and handle dimension-specific teleportation more robustly. Updated `ModBlocks` to properly register the custom `Window` block. Signed-off-by: dragonruler1000 --- build.gradle | 2 +- gradle.properties | 1 + .../hdm_mod/block/ModBlocks.java | 3 +- .../hdm_mod/block/custom/Window.java | 43 ++++++++++--------- 4 files changed, 27 insertions(+), 22 deletions(-) diff --git a/build.gradle b/build.gradle index c1e84cb..c1bd60a 100644 --- a/build.gradle +++ b/build.gradle @@ -141,7 +141,7 @@ tasks.named('processResources', ProcessResources).configure { forge_version : forge_version, forge_version_range: forge_version_range, loader_version_range: loader_version_range, mod_id : mod_id, mod_name: mod_name, mod_license: mod_license, mod_version: mod_version, - mod_authors : mod_authors, mod_description: mod_description,] + mod_authors : mod_authors, credits: credits, mod_description: mod_description,] inputs.properties replaceProperties diff --git a/gradle.properties b/gradle.properties index e02d200..fc1c5f8 100644 --- a/gradle.properties +++ b/gradle.properties @@ -45,5 +45,6 @@ mod_version=1.2 mod_group_id=us.minecraftchest2 # The authors of the mod. This is a simple text string that is used for display purposes in the mod list. mod_authors=Minecraftchest2 +credits=Everyone on the Tardis Mod Discord and on the hackclub slack that helped me debug my mod. # The description of the mod. This is a simple multiline text string that is used for display purposes in the mod list. mod_description=A Mod Inspired by "His Dark Materials" By Philip Pullman diff --git a/src/main/java/us/minecraftchest2/hdm_mod/block/ModBlocks.java b/src/main/java/us/minecraftchest2/hdm_mod/block/ModBlocks.java index b11579b..5c7d76f 100644 --- a/src/main/java/us/minecraftchest2/hdm_mod/block/ModBlocks.java +++ b/src/main/java/us/minecraftchest2/hdm_mod/block/ModBlocks.java @@ -11,6 +11,7 @@ import net.minecraftforge.fml.RegistryObject; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; import us.minecraftchest2.hdm_mod.Hdm_mod; +import us.minecraftchest2.hdm_mod.block.custom.Window; import us.minecraftchest2.hdm_mod.item.ModItems; import us.minecraftchest2.hdm_mod.item.ModItemGroup; @@ -40,7 +41,7 @@ public class ModBlocks { // Registering a "portal" block called "window" with different properties public static final RegistryObject PORTAL_BLOCK = registerBlock("window", - () -> new Block( + () -> new Window( AbstractBlock.Properties.create(Material.PORTAL) // Base material is portal .doesNotBlockMovement() // Entities can move through this block .harvestLevel(10) // High harvest level diff --git a/src/main/java/us/minecraftchest2/hdm_mod/block/custom/Window.java b/src/main/java/us/minecraftchest2/hdm_mod/block/custom/Window.java index e043c36..c811185 100644 --- a/src/main/java/us/minecraftchest2/hdm_mod/block/custom/Window.java +++ b/src/main/java/us/minecraftchest2/hdm_mod/block/custom/Window.java @@ -98,36 +98,39 @@ public class Window extends HorizontalBlock { * @param hit Hit result information * @return Result of the interaction */ + @SuppressWarnings("deprecation") @Override - public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, - PlayerEntity player, Hand handIn, BlockRayTraceResult hit) { - String message = "blockActivated"; - ITextComponent msg = new StringTextComponent(message); - player.sendMessage(msg, player.getUniqueID()); + public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) { - // Client-side: Only show a status message if (worldIn.isRemote()) { player.sendStatusMessage(new StringTextComponent("Client: Block activated!"), true); return ActionResultType.SUCCESS; } - // Server-side logic below - player.sendMessage(new StringTextComponent("blockActivated"), player.getUniqueID()); + if (!worldIn.isRemote()) return super.onBlockActivated(state, worldIn, pos, player, handIn, hit); + if (player.isCrouching()) return super.onBlockActivated(state, worldIn, pos, player, handIn, hit); - // Prevent action if sneaking (crouching) - if (player.isCrouching()) { - return ActionResultType.PASS; - } + if (worldIn.getServer() == null) return super.onBlockActivated(state, worldIn, pos, player, handIn, hit); MinecraftServer server = worldIn.getServer(); - if (server == null) { - return ActionResultType.FAIL; + if (worldIn.getDimensionKey() == ModDimensions.World1) { + ServerWorld overWorld = server.getWorld(World.OVERWORLD); + if (overWorld != null) { + player.changeDimension(overWorld, new SimpleTeleporter(pos, false)); + } } - + ServerWorld targetWorld; boolean goingToCustom = worldIn.getDimensionKey() != ModDimensions.World1; - ServerWorld targetWorld = goingToCustom - ? server.getWorld(ModDimensions.World1) - : server.getWorld(World.OVERWORLD); + + if (goingToCustom) { + targetWorld = server.getWorld(ModDimensions.World1); + } else { + ServerWorld world1 = server.getWorld(ModDimensions.World1); + if (world1 != null) { + player.changeDimension(world1, new SimpleTeleporter(pos, true)); + } + targetWorld = server.getWorld(World.OVERWORLD); + } if (targetWorld != null) { SimpleTeleporter teleporter = new SimpleTeleporter(pos, goingToCustom); @@ -142,7 +145,7 @@ public class Window extends HorizontalBlock { return ActionResultType.SUCCESS; } - return ActionResultType.FAIL; + return super.onBlockActivated(state, worldIn, pos, player, handIn, hit); } @@ -166,7 +169,7 @@ public class Window extends HorizontalBlock { } /** - * Adds the horizontal facing property to the block's state container + * Adds the horizontal-facing property to the block's state container */ @Override protected void fillStateContainer(StateContainer.Builder builder) { From ef61988f6121546034a8a324241fc4155d8f4fa5 Mon Sep 17 00:00:00 2001 From: dragonruler1000 Date: Sat, 17 May 2025 16:42:03 -0500 Subject: [PATCH 18/32] Fix block activation logic and add server-side message Reversed client/server check to ensure correct logic during block activation. Added a server-side message to notify players when the block is activated. This improves clarity and ensures consistent behavior across client and server. Signed-off-by: dragonruler1000 --- .../java/us/minecraftchest2/hdm_mod/block/custom/Window.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/us/minecraftchest2/hdm_mod/block/custom/Window.java b/src/main/java/us/minecraftchest2/hdm_mod/block/custom/Window.java index c811185..e3ad55e 100644 --- a/src/main/java/us/minecraftchest2/hdm_mod/block/custom/Window.java +++ b/src/main/java/us/minecraftchest2/hdm_mod/block/custom/Window.java @@ -102,10 +102,11 @@ public class Window extends HorizontalBlock { @Override public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) { - if (worldIn.isRemote()) { + if (!worldIn.isRemote()) { player.sendStatusMessage(new StringTextComponent("Client: Block activated!"), true); return ActionResultType.SUCCESS; } + player.sendMessage(new StringTextComponent("blockActivated"), player.getUniqueID()); if (!worldIn.isRemote()) return super.onBlockActivated(state, worldIn, pos, player, handIn, hit); if (player.isCrouching()) return super.onBlockActivated(state, worldIn, pos, player, handIn, hit); From a540f3bf60ee3c88e781e275efda5d3283bff213 Mon Sep 17 00:00:00 2001 From: dragonruler1000 Date: Mon, 19 May 2025 08:56:16 -0500 Subject: [PATCH 19/32] Refactor gradle properties and clean up Window block logic Improve clarity in `credits` and `mod_authors` formatting within `gradle.properties`. Removed redundant player message handling logic in `Window.java` to streamline block activation behavior. --- build.gradle | 2 +- gradle.properties | 3 ++- .../us/minecraftchest2/hdm_mod/block/custom/Window.java | 7 ------- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/build.gradle b/build.gradle index c1bd60a..a0ab1e4 100644 --- a/build.gradle +++ b/build.gradle @@ -141,7 +141,7 @@ tasks.named('processResources', ProcessResources).configure { forge_version : forge_version, forge_version_range: forge_version_range, loader_version_range: loader_version_range, mod_id : mod_id, mod_name: mod_name, mod_license: mod_license, mod_version: mod_version, - mod_authors : mod_authors, credits: credits, mod_description: mod_description,] + mod_authors : mod_authors, credits:credits, mod_description: mod_description,] inputs.properties replaceProperties diff --git a/gradle.properties b/gradle.properties index fc1c5f8..e61404c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -45,6 +45,7 @@ mod_version=1.2 mod_group_id=us.minecraftchest2 # The authors of the mod. This is a simple text string that is used for display purposes in the mod list. mod_authors=Minecraftchest2 -credits=Everyone on the Tardis Mod Discord and on the hackclub slack that helped me debug my mod. +# The mod credits. +credits=Everyone on the Tardis Mod Discord and on the hackclub slack that helped me debug my mod # The description of the mod. This is a simple multiline text string that is used for display purposes in the mod list. mod_description=A Mod Inspired by "His Dark Materials" By Philip Pullman diff --git a/src/main/java/us/minecraftchest2/hdm_mod/block/custom/Window.java b/src/main/java/us/minecraftchest2/hdm_mod/block/custom/Window.java index e3ad55e..1b83e9a 100644 --- a/src/main/java/us/minecraftchest2/hdm_mod/block/custom/Window.java +++ b/src/main/java/us/minecraftchest2/hdm_mod/block/custom/Window.java @@ -101,13 +101,6 @@ public class Window extends HorizontalBlock { @SuppressWarnings("deprecation") @Override public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) { - - if (!worldIn.isRemote()) { - player.sendStatusMessage(new StringTextComponent("Client: Block activated!"), true); - return ActionResultType.SUCCESS; - } - player.sendMessage(new StringTextComponent("blockActivated"), player.getUniqueID()); - if (!worldIn.isRemote()) return super.onBlockActivated(state, worldIn, pos, player, handIn, hit); if (player.isCrouching()) return super.onBlockActivated(state, worldIn, pos, player, handIn, hit); From 9cad3a926e397474a6721b6a570431ba757eb404 Mon Sep 17 00:00:00 2001 From: dragonruler1000 Date: Mon, 19 May 2025 22:22:13 -0500 Subject: [PATCH 20/32] Fix incorrect remote check in Window block activation Previously, the remote check in the `onBlockActivated` method was reversed, causing improper behavior. This update corrects the logic to handle block activation appropriately on the client side. Additionally, an unused import line was cleaned up for clarity. Signed-off-by: dragonruler1000 --- .../java/us/minecraftchest2/hdm_mod/block/custom/Window.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/us/minecraftchest2/hdm_mod/block/custom/Window.java b/src/main/java/us/minecraftchest2/hdm_mod/block/custom/Window.java index 1b83e9a..374e5ca 100644 --- a/src/main/java/us/minecraftchest2/hdm_mod/block/custom/Window.java +++ b/src/main/java/us/minecraftchest2/hdm_mod/block/custom/Window.java @@ -22,6 +22,7 @@ import net.minecraft.util.text.StringTextComponent; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; import net.minecraft.world.server.ServerWorld; +//import us.minecraftchest2.hdm_mod.world.dimension.ModDimensions; import us.minecraftchest2.hdm_mod.world.dimension.ModDimensions; import us.minecraftchest2.hdm_mod.world.dimension.SimpleTeleporter; @@ -101,7 +102,7 @@ public class Window extends HorizontalBlock { @SuppressWarnings("deprecation") @Override public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) { - if (!worldIn.isRemote()) return super.onBlockActivated(state, worldIn, pos, player, handIn, hit); + if (worldIn.isRemote()) return super.onBlockActivated(state, worldIn, pos, player, handIn, hit); if (player.isCrouching()) return super.onBlockActivated(state, worldIn, pos, player, handIn, hit); From 1289e20bc0377974861e4d4a85cb839f27545db9 Mon Sep 17 00:00:00 2001 From: dragonruler1000 Date: Tue, 20 May 2025 20:55:44 -0500 Subject: [PATCH 21/32] Add credits field to mods.toml and clean up imports in Window.java The mods.toml file now includes a credits field so it shows up in the mod list. Additionally, unused imports in Window.java were removed to improve code readability and maintainability. --- .../java/us/minecraftchest2/hdm_mod/block/custom/Window.java | 2 -- src/main/resources/META-INF/mods.toml | 1 + 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/us/minecraftchest2/hdm_mod/block/custom/Window.java b/src/main/java/us/minecraftchest2/hdm_mod/block/custom/Window.java index 374e5ca..37f8fe9 100644 --- a/src/main/java/us/minecraftchest2/hdm_mod/block/custom/Window.java +++ b/src/main/java/us/minecraftchest2/hdm_mod/block/custom/Window.java @@ -17,12 +17,10 @@ import net.minecraft.util.math.shapes.IBooleanFunction; import net.minecraft.util.math.shapes.ISelectionContext; import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.util.math.shapes.VoxelShapes; -import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.StringTextComponent; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; import net.minecraft.world.server.ServerWorld; -//import us.minecraftchest2.hdm_mod.world.dimension.ModDimensions; import us.minecraftchest2.hdm_mod.world.dimension.ModDimensions; import us.minecraftchest2.hdm_mod.world.dimension.SimpleTeleporter; diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index e0d6b70..e557235 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -30,6 +30,7 @@ displayName = "${mod_name}" #mandatory #credits="Thanks for this example mod goes to Java" #optional # A text field displayed in the mod UI authors = "${mod_authors}" #optional +credits="${credits}" # The description text for the mod (multi line!) (#mandatory) description = '''${mod_description}''' # A dependency - use the . to indicate dependency for a specific modid. Dependencies are optional. From 79949bc13b8e90246afa91ab1514356bcb6e2962 Mon Sep 17 00:00:00 2001 From: dragonruler1000 Date: Wed, 21 May 2025 22:16:36 -0500 Subject: [PATCH 22/32] Refactor and enhance documentation for Window block class Improved clarity and consistency in code comments for the Window block, providing better explanations of its functionality and behaviors. Refactored shape and teleportation logic comments for better readability. No functional changes were introduced. --- .../hdm_mod/block/custom/Window.java | 79 +++++++++++-------- 1 file changed, 48 insertions(+), 31 deletions(-) diff --git a/src/main/java/us/minecraftchest2/hdm_mod/block/custom/Window.java b/src/main/java/us/minecraftchest2/hdm_mod/block/custom/Window.java index 37f8fe9..3274282 100644 --- a/src/main/java/us/minecraftchest2/hdm_mod/block/custom/Window.java +++ b/src/main/java/us/minecraftchest2/hdm_mod/block/custom/Window.java @@ -27,33 +27,34 @@ import us.minecraftchest2.hdm_mod.world.dimension.SimpleTeleporter; import javax.annotation.Nullable; import java.util.stream.Stream; - - /** - * A custom window block that acts as a dimensional portal when activated - * Extends HorizontalBlock to support directional placement + * Custom window block class, serving as a dimensional portal between worlds. + * Inherits directional placement capabilities from HorizontalBlock. */ public class Window extends HorizontalBlock { + /** + * Constructor for Window block; forwards the properties to the parent constructor. + */ public Window(Properties builder) { super(builder); } - // VoxelShapes define the physical shape of the block for each direction (NORTH, EAST, SOUTH, WEST) - // These shapes are made up of multiple cubic sections combined + // VoxelShapes for visually and physically shaping the block based on orientation. + // Each direction (N/E/S/W) has a custom composition of rectangular regions. + + /** Shape for the block facing NORTH. */ private static final VoxelShape SHAPE_N = Stream.of( - Block.makeCuboidShape(5, 11, 5, 6, 13, 11), // Window frame pieces - Block.makeCuboidShape(4, 0, 4, 12, 1, 12), // Base - Block.makeCuboidShape(5, 1, 5, 11, 2, 11), // Lower frame - Block.makeCuboidShape(6, 2, 6, 10, 10, 10), // Main window pane - Block.makeCuboidShape(5, 10, 4, 11, 11, 12), // Upper frame - Block.makeCuboidShape(5, 11, 4, 11, 12, 5), // Top decorative elements - Block.makeCuboidShape(5, 11, 11, 11, 14, 12), - Block.makeCuboidShape(10, 11, 5, 11, 13, 11) + Block.makeCuboidShape(5, 11, 5, 6, 13, 11), // Window frame elements (left, etc.) + Block.makeCuboidShape(4, 0, 4, 12, 1, 12), // Base of window + Block.makeCuboidShape(5, 1, 5, 11, 2, 11), // Lower window frame + Block.makeCuboidShape(6, 2, 6, 10, 10, 10), // Glass pane + Block.makeCuboidShape(5, 10, 4, 11, 11, 12), // Top frame + Block.makeCuboidShape(5, 11, 4, 11, 12, 5), // Decorative details + Block.makeCuboidShape(5, 11, 11, 11, 14, 12),// Upper right details + Block.makeCuboidShape(10, 11, 5, 11, 13, 11) // Right vertical side ).reduce((v1, v2) -> VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR)).get(); - // Similar shape definitions for other directions... - // (SHAPE_E, SHAPE_S, SHAPE_W follow the same pattern but rotated) - + /** Shape for the block facing EAST (rotated). */ private static final VoxelShape SHAPE_E = Stream.of( Block.makeCuboidShape(5, 11, 5, 11, 13, 6), Block.makeCuboidShape(4, 0, 4, 12, 1, 12), @@ -65,6 +66,7 @@ public class Window extends HorizontalBlock { Block.makeCuboidShape(5, 11, 10, 11, 13, 11) ).reduce((v1, v2) -> VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR)).get(); + /** Shape for the block facing SOUTH. */ private static final VoxelShape SHAPE_S = Stream.of( Block.makeCuboidShape(10, 11, 5, 11, 13, 11), Block.makeCuboidShape(4, 0, 4, 12, 1, 12), @@ -76,6 +78,7 @@ public class Window extends HorizontalBlock { Block.makeCuboidShape(5, 11, 5, 6, 13, 11) ).reduce((v1, v2) -> VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR)).get(); + /** Shape for the block facing WEST. */ private static final VoxelShape SHAPE_W = Stream.of( Block.makeCuboidShape(5, 11, 10, 11, 13, 11), Block.makeCuboidShape(4, 0, 4, 12, 1, 12), @@ -88,36 +91,45 @@ public class Window extends HorizontalBlock { ).reduce((v1, v2) -> VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR)).get(); /** - * Handles player interaction with the window block - * @param state Current block state - * @param worldIn World instance - * @param pos Block position - * @param player Player who activated the block - * @param handIn Hand used for interaction - * @param hit Hit result information - * @return Result of the interaction + * Handles when a player right-clicks/interacts with this block. + * Triggers portal teleportation if conditions are met. */ @SuppressWarnings("deprecation") @Override - public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) { + public ActionResultType onBlockActivated( + BlockState state, + World worldIn, + BlockPos pos, + PlayerEntity player, + Hand handIn, + BlockRayTraceResult hit + ) { + // Only process on the server side, avoid duplicating logic on client if (worldIn.isRemote()) return super.onBlockActivated(state, worldIn, pos, player, handIn, hit); + // Do nothing if the player is crouching (commonly used for alternative interactions) if (player.isCrouching()) return super.onBlockActivated(state, worldIn, pos, player, handIn, hit); - + // Get the server instance safely if (worldIn.getServer() == null) return super.onBlockActivated(state, worldIn, pos, player, handIn, hit); MinecraftServer server = worldIn.getServer(); + + // Check if in custom dimension; if so, teleport to Overworld if (worldIn.getDimensionKey() == ModDimensions.World1) { ServerWorld overWorld = server.getWorld(World.OVERWORLD); if (overWorld != null) { player.changeDimension(overWorld, new SimpleTeleporter(pos, false)); } } + + // Set up for teleportation based on current dimension ServerWorld targetWorld; boolean goingToCustom = worldIn.getDimensionKey() != ModDimensions.World1; if (goingToCustom) { + // Teleporting from Overworld to custom dimension targetWorld = server.getWorld(ModDimensions.World1); } else { + // From custom dimension, teleport to Overworld ServerWorld world1 = server.getWorld(ModDimensions.World1); if (world1 != null) { player.changeDimension(world1, new SimpleTeleporter(pos, true)); @@ -125,10 +137,12 @@ public class Window extends HorizontalBlock { targetWorld = server.getWorld(World.OVERWORLD); } + // Attempt teleport if a valid world was found if (targetWorld != null) { SimpleTeleporter teleporter = new SimpleTeleporter(pos, goingToCustom); player.changeDimension(targetWorld, teleporter); + // Notify the player about the result if (teleporter.wasSuccessful()) { player.sendMessage(new StringTextComponent("Teleportation successful!"), player.getUniqueID()); } else { @@ -138,12 +152,13 @@ public class Window extends HorizontalBlock { return ActionResultType.SUCCESS; } + // Fall back to default processing if teleportation did not occur return super.onBlockActivated(state, worldIn, pos, player, handIn, hit); } - /** - * Returns the appropriate shape for the block based on its facing direction + * Returns the block's physical outline for rendering and collision. + * The shape depends on the current facing direction of the block. */ @Override public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { @@ -162,7 +177,8 @@ public class Window extends HorizontalBlock { } /** - * Adds the horizontal-facing property to the block's state container + * Registers the horizontal facing property with the block state container, + * enabling the block to store which direction it is facing. */ @Override protected void fillStateContainer(StateContainer.Builder builder) { @@ -170,7 +186,8 @@ public class Window extends HorizontalBlock { } /** - * Determines the block's facing direction when placed + * Determines the block's initial facing based on the placement context. + * The block will face opposite to the player's direction when placed. */ @Nullable @Override From 02d4df7c55d537a1afdaec61d9809fa448e4b564 Mon Sep 17 00:00:00 2001 From: dragonruler1000 Date: Thu, 22 May 2025 20:14:18 -0500 Subject: [PATCH 23/32] Refactor teleportation logic and add custom dimension config Simplified portal activation logic to improve readability and efficiency, removing redundant checks and consolidating teleport code paths. Added configuration file for the "world1" custom dimension, defining its properties and behavior and fixing the bug I was having. --- .../hdm_mod/block/custom/Window.java | 67 +++++++------------ .../data/hdm_mod/dimension_type/world1.json | 15 +++++ 2 files changed, 38 insertions(+), 44 deletions(-) create mode 100644 src/main/resources/data/hdm_mod/dimension_type/world1.json diff --git a/src/main/java/us/minecraftchest2/hdm_mod/block/custom/Window.java b/src/main/java/us/minecraftchest2/hdm_mod/block/custom/Window.java index 3274282..13b77b3 100644 --- a/src/main/java/us/minecraftchest2/hdm_mod/block/custom/Window.java +++ b/src/main/java/us/minecraftchest2/hdm_mod/block/custom/Window.java @@ -104,56 +104,35 @@ public class Window extends HorizontalBlock { Hand handIn, BlockRayTraceResult hit ) { - // Only process on the server side, avoid duplicating logic on client - if (worldIn.isRemote()) return super.onBlockActivated(state, worldIn, pos, player, handIn, hit); - // Do nothing if the player is crouching (commonly used for alternative interactions) - if (player.isCrouching()) return super.onBlockActivated(state, worldIn, pos, player, handIn, hit); + if (!worldIn.isRemote() && !player.isCrouching()) { + MinecraftServer server = worldIn.getServer(); + if (server == null) return ActionResultType.PASS; - // Get the server instance safely - if (worldIn.getServer() == null) return super.onBlockActivated(state, worldIn, pos, player, handIn, hit); - MinecraftServer server = worldIn.getServer(); + boolean goingToCustom = worldIn.getDimensionKey() != ModDimensions.World1; - // Check if in custom dimension; if so, teleport to Overworld - if (worldIn.getDimensionKey() == ModDimensions.World1) { - ServerWorld overWorld = server.getWorld(World.OVERWORLD); - if (overWorld != null) { - player.changeDimension(overWorld, new SimpleTeleporter(pos, false)); - } - } + ServerWorld targetWorld = (worldIn.getDimensionKey() == ModDimensions.World1) + ? server.getWorld(World.OVERWORLD) + : server.getWorld(ModDimensions.World1); - // Set up for teleportation based on current dimension - ServerWorld targetWorld; - boolean goingToCustom = worldIn.getDimensionKey() != ModDimensions.World1; + if (worldIn.getDimensionKey() == ModDimensions.World1) { + ServerWorld overWorld = server.getWorld(World.OVERWORLD); + if (overWorld != null) { + player.changeDimension(overWorld, new SimpleTeleporter(pos, false)); + } + } - if (goingToCustom) { - // Teleporting from Overworld to custom dimension - targetWorld = server.getWorld(ModDimensions.World1); - } else { - // From custom dimension, teleport to Overworld - ServerWorld world1 = server.getWorld(ModDimensions.World1); - if (world1 != null) { - player.changeDimension(world1, new SimpleTeleporter(pos, true)); - } - targetWorld = server.getWorld(World.OVERWORLD); - } + if (targetWorld != null) { + SimpleTeleporter teleporter = new SimpleTeleporter(pos, goingToCustom); + player.changeDimension(targetWorld, teleporter); + } - // Attempt teleport if a valid world was found - if (targetWorld != null) { - 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; - // Notify the player about the result - if (teleporter.wasSuccessful()) { - player.sendMessage(new StringTextComponent("Teleportation successful!"), player.getUniqueID()); - } else { - player.sendMessage(new StringTextComponent("Teleportation failed: no safe location found."), player.getUniqueID()); - } - - return ActionResultType.SUCCESS; - } - - // Fall back to default processing if teleportation did not occur - return super.onBlockActivated(state, worldIn, pos, player, handIn, hit); + } + return super.onBlockActivated(state, worldIn, pos, player, handIn, hit); } /** diff --git a/src/main/resources/data/hdm_mod/dimension_type/world1.json b/src/main/resources/data/hdm_mod/dimension_type/world1.json new file mode 100644 index 0000000..460751b --- /dev/null +++ b/src/main/resources/data/hdm_mod/dimension_type/world1.json @@ -0,0 +1,15 @@ +{ + "logical_height": 256, + "infiniburn": "minecraft:infiniburn_overworld", + "effects": "minecraft:overworld", + "ambient_light": 0, + "bed_works": true, + "respawn_anchor_works": false, + "has_raids": true, + "ultrawarm": false, + "natural": true, + "coordinate_scale": 1, + "piglin_safe": false, + "has_skylight": true, + "has_ceiling": false +} \ No newline at end of file From a8d47d18453f4e6a6dd51fe10d5f5236343473e4 Mon Sep 17 00:00:00 2001 From: dragonruler1000 Date: Thu, 22 May 2025 20:54:02 -0500 Subject: [PATCH 24/32] Trying to fix broken textures Signed-off-by: dragonruler1000 --- .../assets/hdm_mod/blockstates/window.json | 5 + .../assets/hdm_mod/models/block/window.json | 153 +----------------- .../assets/hdm_mod/models/block/window1.json | 151 +++++++++++++++++ .../assets/hdm_mod/models/item/window.json | 3 + 4 files changed, 163 insertions(+), 149 deletions(-) create mode 100644 src/main/resources/assets/hdm_mod/blockstates/window.json create mode 100644 src/main/resources/assets/hdm_mod/models/block/window1.json create mode 100644 src/main/resources/assets/hdm_mod/models/item/window.json diff --git a/src/main/resources/assets/hdm_mod/blockstates/window.json b/src/main/resources/assets/hdm_mod/blockstates/window.json new file mode 100644 index 0000000..5bd80c6 --- /dev/null +++ b/src/main/resources/assets/hdm_mod/blockstates/window.json @@ -0,0 +1,5 @@ +{ + "variants": { + "main": {"model": "hdm_mod:block/window" } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/hdm_mod/models/block/window.json b/src/main/resources/assets/hdm_mod/models/block/window.json index 54c9c09..43306a9 100644 --- a/src/main/resources/assets/hdm_mod/models/block/window.json +++ b/src/main/resources/assets/hdm_mod/models/block/window.json @@ -1,151 +1,6 @@ { - "credit": "Made with Blockbench", - "textures": { - "1": "hdm_mod:block/brown", - "2": "hdm_mod:block/grey", - "particle": "hdm_mod:block/red" - }, - "elements": [ - { - "from": [5, 11, 5], - "to": [6, 13, 11], - "rotation": {"angle": 0, "axis": "y", "origin": [8, 8.3125, 8]}, - "faces": { - "north": {"uv": [0, 0, 1, 6], "texture": "#2"}, - "east": {"uv": [0, 0, 1, 6], "texture": "#2"}, - "south": {"uv": [0, 0, 1, 6], "texture": "#2"}, - "west": {"uv": [0, 0, 1, 6], "texture": "#2"}, - "up": {"uv": [0, 0, 1, 6], "texture": "#2"}, - "down": {"uv": [0, 0, 1, 6], "texture": "#2"} - } - }, - { - "from": [4, 0, 4], - "to": [12, 1, 12], - "rotation": {"angle": 0, "axis": "y", "origin": [8, 8.3125, 8]}, - "faces": { - "north": {"uv": [0, 0, 8, 8], "texture": "#1"}, - "east": {"uv": [0, 0, 8, 8], "texture": "#1"}, - "south": {"uv": [0, 0, 8, 8], "texture": "#1"}, - "west": {"uv": [0, 0, 8, 8], "texture": "#1"}, - "up": {"uv": [0, 0, 8, 8], "texture": "#1"}, - "down": {"uv": [0, 0, 8, 8], "texture": "#1"} - } - }, - { - "from": [5, 1, 5], - "to": [11, 2, 11], - "rotation": {"angle": 0, "axis": "y", "origin": [8, 8.3125, 8]}, - "faces": { - "north": {"uv": [0, 0, 6, 1], "texture": "#1"}, - "east": {"uv": [0, 0, 6, 1], "texture": "#1"}, - "south": {"uv": [0, 0, 6, 1], "texture": "#1"}, - "west": {"uv": [0, 0, 6, 1], "texture": "#1"}, - "up": {"uv": [0, 0, 6, 1], "texture": "#1"}, - "down": {"uv": [0, 0, 6, 1], "texture": "#1"} - } - }, - { - "from": [6, 2, 6], - "to": [10, 10, 10], - "rotation": {"angle": 0, "axis": "y", "origin": [8, 8.3125, 8]}, - "faces": { - "north": {"uv": [0, 0, 4, 8], "texture": "#1"}, - "east": {"uv": [0, 0, 4, 8], "texture": "#1"}, - "south": {"uv": [0, 0, 4, 8], "texture": "#1"}, - "west": {"uv": [0, 0, 4, 8], "texture": "#1"}, - "up": {"uv": [0, 0, 4, 8], "texture": "#1"}, - "down": {"uv": [0, 0, 4, 8], "texture": "#1"} - } - }, - { - "from": [5, 10, 4], - "to": [11, 11, 12], - "rotation": {"angle": 0, "axis": "y", "origin": [8, 8.3125, 8]}, - "faces": { - "north": {"uv": [0, 0, 6, 8], "texture": "#2"}, - "east": {"uv": [0, 0, 6, 8], "texture": "#2"}, - "south": {"uv": [0, 0, 6, 8], "texture": "#2"}, - "west": {"uv": [0, 0, 6, 8], "texture": "#2"}, - "up": {"uv": [0, 0, 6, 8], "texture": "#2"}, - "down": {"uv": [0, 0, 6, 8], "texture": "#2"} - } - }, - { - "from": [5, 11, 4], - "to": [11, 12, 5], - "rotation": {"angle": 0, "axis": "y", "origin": [8, 8.3125, 8]}, - "faces": { - "north": {"uv": [0, 0, 6, 1], "texture": "#2"}, - "east": {"uv": [0, 0, 6, 1], "texture": "#2"}, - "south": {"uv": [0, 0, 6, 1], "texture": "#2"}, - "west": {"uv": [0, 0, 6, 1], "texture": "#2"}, - "up": {"uv": [0, 0, 6, 1], "texture": "#2"}, - "down": {"uv": [0, 0, 6, 1], "texture": "#2"} - } - }, - { - "from": [5, 11, 11], - "to": [11, 14, 12], - "rotation": {"angle": 0, "axis": "y", "origin": [8, 8.3125, 8]}, - "faces": { - "north": {"uv": [0, 0, 6, 1], "texture": "#2"}, - "east": {"uv": [0, 0, 6, 1], "texture": "#2"}, - "south": {"uv": [0, 0, 6, 1], "texture": "#2"}, - "west": {"uv": [0, 0, 6, 1], "texture": "#2"}, - "up": {"uv": [0, 0, 6, 1], "texture": "#2"}, - "down": {"uv": [0, 0, 6, 1], "texture": "#2"} - } - }, - { - "from": [10, 11, 5], - "to": [11, 13, 11], - "rotation": {"angle": 0, "axis": "y", "origin": [8, 8.3125, 8]}, - "faces": { - "north": {"uv": [0, 0, 1, 6], "texture": "#2"}, - "east": {"uv": [0, 0, 1, 6], "texture": "#2"}, - "south": {"uv": [0, 0, 1, 6], "texture": "#2"}, - "west": {"uv": [0, 0, 1, 6], "texture": "#2"}, - "up": {"uv": [0, 0, 1, 6], "texture": "#2"}, - "down": {"uv": [0, 0, 1, 6], "texture": "#2"} - } - } - ], - "display": { - "thirdperson_righthand": { - "rotation": [0, -180, 0], - "scale": [0.5, 0.69, 0.5] - }, - "thirdperson_lefthand": { - "rotation": [0, -180, 0], - "scale": [0.5, 0.69, 0.5] - }, - "firstperson_righthand": { - "translation": [0, 4, 2.5], - "scale": [0.5, 0.5, 0.5] - }, - "firstperson_lefthand": { - "translation": [0, 4, 2.5], - "scale": [0.5, 0.5, 0.5] - }, - "ground": { - "translation": [0, 2.25, 0], - "scale": [0.75, 0.75, 0.75] - }, - "gui": { - "rotation": [55, -125, 0], - "scale": [0.75, 0.75, 0.75] - }, - "head": { - "translation": [0, 14, 0] - } - }, - "groups": [ - { - "name": "VoxelShapes", - "origin": [8, 8, 8], - "color": 0, - "children": [0, 1, 2, 3, 4, 5, 6, 7] - } - ] + "parent": "block/cube_all", + "textures" : { + "all": "hdm_mod:block/grey" + } } \ No newline at end of file diff --git a/src/main/resources/assets/hdm_mod/models/block/window1.json b/src/main/resources/assets/hdm_mod/models/block/window1.json new file mode 100644 index 0000000..54c9c09 --- /dev/null +++ b/src/main/resources/assets/hdm_mod/models/block/window1.json @@ -0,0 +1,151 @@ +{ + "credit": "Made with Blockbench", + "textures": { + "1": "hdm_mod:block/brown", + "2": "hdm_mod:block/grey", + "particle": "hdm_mod:block/red" + }, + "elements": [ + { + "from": [5, 11, 5], + "to": [6, 13, 11], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 8.3125, 8]}, + "faces": { + "north": {"uv": [0, 0, 1, 6], "texture": "#2"}, + "east": {"uv": [0, 0, 1, 6], "texture": "#2"}, + "south": {"uv": [0, 0, 1, 6], "texture": "#2"}, + "west": {"uv": [0, 0, 1, 6], "texture": "#2"}, + "up": {"uv": [0, 0, 1, 6], "texture": "#2"}, + "down": {"uv": [0, 0, 1, 6], "texture": "#2"} + } + }, + { + "from": [4, 0, 4], + "to": [12, 1, 12], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 8.3125, 8]}, + "faces": { + "north": {"uv": [0, 0, 8, 8], "texture": "#1"}, + "east": {"uv": [0, 0, 8, 8], "texture": "#1"}, + "south": {"uv": [0, 0, 8, 8], "texture": "#1"}, + "west": {"uv": [0, 0, 8, 8], "texture": "#1"}, + "up": {"uv": [0, 0, 8, 8], "texture": "#1"}, + "down": {"uv": [0, 0, 8, 8], "texture": "#1"} + } + }, + { + "from": [5, 1, 5], + "to": [11, 2, 11], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 8.3125, 8]}, + "faces": { + "north": {"uv": [0, 0, 6, 1], "texture": "#1"}, + "east": {"uv": [0, 0, 6, 1], "texture": "#1"}, + "south": {"uv": [0, 0, 6, 1], "texture": "#1"}, + "west": {"uv": [0, 0, 6, 1], "texture": "#1"}, + "up": {"uv": [0, 0, 6, 1], "texture": "#1"}, + "down": {"uv": [0, 0, 6, 1], "texture": "#1"} + } + }, + { + "from": [6, 2, 6], + "to": [10, 10, 10], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 8.3125, 8]}, + "faces": { + "north": {"uv": [0, 0, 4, 8], "texture": "#1"}, + "east": {"uv": [0, 0, 4, 8], "texture": "#1"}, + "south": {"uv": [0, 0, 4, 8], "texture": "#1"}, + "west": {"uv": [0, 0, 4, 8], "texture": "#1"}, + "up": {"uv": [0, 0, 4, 8], "texture": "#1"}, + "down": {"uv": [0, 0, 4, 8], "texture": "#1"} + } + }, + { + "from": [5, 10, 4], + "to": [11, 11, 12], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 8.3125, 8]}, + "faces": { + "north": {"uv": [0, 0, 6, 8], "texture": "#2"}, + "east": {"uv": [0, 0, 6, 8], "texture": "#2"}, + "south": {"uv": [0, 0, 6, 8], "texture": "#2"}, + "west": {"uv": [0, 0, 6, 8], "texture": "#2"}, + "up": {"uv": [0, 0, 6, 8], "texture": "#2"}, + "down": {"uv": [0, 0, 6, 8], "texture": "#2"} + } + }, + { + "from": [5, 11, 4], + "to": [11, 12, 5], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 8.3125, 8]}, + "faces": { + "north": {"uv": [0, 0, 6, 1], "texture": "#2"}, + "east": {"uv": [0, 0, 6, 1], "texture": "#2"}, + "south": {"uv": [0, 0, 6, 1], "texture": "#2"}, + "west": {"uv": [0, 0, 6, 1], "texture": "#2"}, + "up": {"uv": [0, 0, 6, 1], "texture": "#2"}, + "down": {"uv": [0, 0, 6, 1], "texture": "#2"} + } + }, + { + "from": [5, 11, 11], + "to": [11, 14, 12], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 8.3125, 8]}, + "faces": { + "north": {"uv": [0, 0, 6, 1], "texture": "#2"}, + "east": {"uv": [0, 0, 6, 1], "texture": "#2"}, + "south": {"uv": [0, 0, 6, 1], "texture": "#2"}, + "west": {"uv": [0, 0, 6, 1], "texture": "#2"}, + "up": {"uv": [0, 0, 6, 1], "texture": "#2"}, + "down": {"uv": [0, 0, 6, 1], "texture": "#2"} + } + }, + { + "from": [10, 11, 5], + "to": [11, 13, 11], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 8.3125, 8]}, + "faces": { + "north": {"uv": [0, 0, 1, 6], "texture": "#2"}, + "east": {"uv": [0, 0, 1, 6], "texture": "#2"}, + "south": {"uv": [0, 0, 1, 6], "texture": "#2"}, + "west": {"uv": [0, 0, 1, 6], "texture": "#2"}, + "up": {"uv": [0, 0, 1, 6], "texture": "#2"}, + "down": {"uv": [0, 0, 1, 6], "texture": "#2"} + } + } + ], + "display": { + "thirdperson_righthand": { + "rotation": [0, -180, 0], + "scale": [0.5, 0.69, 0.5] + }, + "thirdperson_lefthand": { + "rotation": [0, -180, 0], + "scale": [0.5, 0.69, 0.5] + }, + "firstperson_righthand": { + "translation": [0, 4, 2.5], + "scale": [0.5, 0.5, 0.5] + }, + "firstperson_lefthand": { + "translation": [0, 4, 2.5], + "scale": [0.5, 0.5, 0.5] + }, + "ground": { + "translation": [0, 2.25, 0], + "scale": [0.75, 0.75, 0.75] + }, + "gui": { + "rotation": [55, -125, 0], + "scale": [0.75, 0.75, 0.75] + }, + "head": { + "translation": [0, 14, 0] + } + }, + "groups": [ + { + "name": "VoxelShapes", + "origin": [8, 8, 8], + "color": 0, + "children": [0, 1, 2, 3, 4, 5, 6, 7] + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/hdm_mod/models/item/window.json b/src/main/resources/assets/hdm_mod/models/item/window.json new file mode 100644 index 0000000..97f1558 --- /dev/null +++ b/src/main/resources/assets/hdm_mod/models/item/window.json @@ -0,0 +1,3 @@ +{ + "parent": "hdm_mod:block/window" +} \ No newline at end of file From a9303a44cbf3282abaa5831cb2f53b8aafc3892a Mon Sep 17 00:00:00 2001 From: dragonruler1000 Date: Sat, 24 May 2025 10:18:18 -0500 Subject: [PATCH 25/32] Add welcome message to dimensions and introduce config support Players entering non-overworld dimensions now receive a tailored welcome message. Additionally, basic configuration support has been introduced, laying the foundation for future customization. Updated mod version to 1.2.1 to reflect these changes. --- gradle.properties | 2 +- .../us/minecraftchest2/hdm_mod/Hdm_mod.java | 3 +++ .../hdm_mod/block/custom/Window.java | 5 +--- .../hdm_mod/config/ModConfig.java | 18 +++++++++++++ .../hdm_mod/config/modconfig.toml | 18 +++++++++++++ .../world/dimension/SimpleTeleporter.java | 27 +++++++++++++++++++ 6 files changed, 68 insertions(+), 5 deletions(-) create mode 100644 src/main/java/us/minecraftchest2/hdm_mod/config/ModConfig.java create mode 100644 src/main/java/us/minecraftchest2/hdm_mod/config/modconfig.toml diff --git a/gradle.properties b/gradle.properties index e61404c..635380c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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 diff --git a/src/main/java/us/minecraftchest2/hdm_mod/Hdm_mod.java b/src/main/java/us/minecraftchest2/hdm_mod/Hdm_mod.java index 69b2566..1a2092e 100644 --- a/src/main/java/us/minecraftchest2/hdm_mod/Hdm_mod.java +++ b/src/main/java/us/minecraftchest2/hdm_mod/Hdm_mod.java @@ -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); diff --git a/src/main/java/us/minecraftchest2/hdm_mod/block/custom/Window.java b/src/main/java/us/minecraftchest2/hdm_mod/block/custom/Window.java index 13b77b3..09ef11d 100644 --- a/src/main/java/us/minecraftchest2/hdm_mod/block/custom/Window.java +++ b/src/main/java/us/minecraftchest2/hdm_mod/block/custom/Window.java @@ -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; } diff --git a/src/main/java/us/minecraftchest2/hdm_mod/config/ModConfig.java b/src/main/java/us/minecraftchest2/hdm_mod/config/ModConfig.java new file mode 100644 index 0000000..07aa724 --- /dev/null +++ b/src/main/java/us/minecraftchest2/hdm_mod/config/ModConfig.java @@ -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); +//} +//} diff --git a/src/main/java/us/minecraftchest2/hdm_mod/config/modconfig.toml b/src/main/java/us/minecraftchest2/hdm_mod/config/modconfig.toml new file mode 100644 index 0000000..7c482ca --- /dev/null +++ b/src/main/java/us/minecraftchest2/hdm_mod/config/modconfig.toml @@ -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); +} +} diff --git a/src/main/java/us/minecraftchest2/hdm_mod/world/dimension/SimpleTeleporter.java b/src/main/java/us/minecraftchest2/hdm_mod/world/dimension/SimpleTeleporter.java index f852405..2579e20 100644 --- a/src/main/java/us/minecraftchest2/hdm_mod/world/dimension/SimpleTeleporter.java +++ b/src/main/java/us/minecraftchest2/hdm_mod/world/dimension/SimpleTeleporter.java @@ -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; } } \ No newline at end of file From 89cff4ca48314a7b48d0a40801a19c034e5d082c Mon Sep 17 00:00:00 2001 From: dragonruler1000 Date: Tue, 27 May 2025 10:13:53 -0500 Subject: [PATCH 26/32] fixed tetures for the block of dust and window blocks --- gradle.properties | 2 +- .../resources/assets/hdm_mod/blockstates/block_of_dust.json | 4 +++- src/main/resources/assets/hdm_mod/blockstates/window.json | 4 +++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/gradle.properties b/gradle.properties index 635380c..99d1277 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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.1 +mod_version=1.2.2 # 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 diff --git a/src/main/resources/assets/hdm_mod/blockstates/block_of_dust.json b/src/main/resources/assets/hdm_mod/blockstates/block_of_dust.json index 7f816ed..2e143c2 100644 --- a/src/main/resources/assets/hdm_mod/blockstates/block_of_dust.json +++ b/src/main/resources/assets/hdm_mod/blockstates/block_of_dust.json @@ -1,5 +1,7 @@ { "variants": { - "main": {"model": "hdm_mod:block/block_of_dust" } + "":[ + {"model": "hdm_mod:block/block_of_dust" } + ] } } \ No newline at end of file diff --git a/src/main/resources/assets/hdm_mod/blockstates/window.json b/src/main/resources/assets/hdm_mod/blockstates/window.json index 5bd80c6..5741ab8 100644 --- a/src/main/resources/assets/hdm_mod/blockstates/window.json +++ b/src/main/resources/assets/hdm_mod/blockstates/window.json @@ -1,5 +1,7 @@ { "variants": { - "main": {"model": "hdm_mod:block/window" } + "": [ + {"model": "hdm_mod:block/window" } + ] } } \ No newline at end of file From 059f2d881bddc1091edf8f98540a74636e209ec7 Mon Sep 17 00:00:00 2001 From: dragonruler1000 Date: Wed, 28 May 2025 11:14:13 -0500 Subject: [PATCH 27/32] Add cooked omelet item, recipe, and HDM dimension support Introduced the cooked omelet item with functionality and crafting recipe. Added recognition for the "HDM Dimension" in teleportation logic. Updated gradle settings to enable daemon for faster builds. Signed-off-by: dragonruler1000 --- gradle.properties | 2 +- .../us/minecraftchest2/hdm_mod/Hdm_mod.java | 4 ++++ .../hdm_mod/block/ModBlocks.java | 1 + .../hdm_mod/item/ModItems.java | 13 ++++++++--- .../world/dimension/SimpleTeleporter.java | 3 +++ .../resources/assets/hdm_mod/lang/en_us.json | 1 + .../hdm_mod/models/item/omelet-cooked.json | 6 +++++ .../data/hdm_mod/recipes/omelet.json | 23 +++++++++++++++++++ 8 files changed, 49 insertions(+), 4 deletions(-) create mode 100644 src/main/resources/assets/hdm_mod/models/item/omelet-cooked.json create mode 100644 src/main/resources/data/hdm_mod/recipes/omelet.json diff --git a/gradle.properties b/gradle.properties index 99d1277..6d71518 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ org.gradle.jvmargs=-Xmx3G -org.gradle.daemon=false +org.gradle.daemon=true # The Minecraft version must agree with the Forge version to get a valid artifact minecraft_version=1.16.5 # The Minecraft version range can use any release version of Minecraft as bounds. diff --git a/src/main/java/us/minecraftchest2/hdm_mod/Hdm_mod.java b/src/main/java/us/minecraftchest2/hdm_mod/Hdm_mod.java index 1a2092e..9a829ce 100644 --- a/src/main/java/us/minecraftchest2/hdm_mod/Hdm_mod.java +++ b/src/main/java/us/minecraftchest2/hdm_mod/Hdm_mod.java @@ -2,6 +2,8 @@ package us.minecraftchest2.hdm_mod; import net.minecraft.block.Block; import net.minecraft.block.Blocks; +import net.minecraft.client.renderer.RenderType; +import net.minecraft.client.renderer.RenderTypeLookup; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.eventbus.api.IEventBus; @@ -66,6 +68,8 @@ public class Hdm_mod { private void doClientStuff(final FMLClientSetupEvent event) { // do something that can only be done on the client + event.enqueueWork(() -> { + }); } private void enqueueIMC(final InterModEnqueueEvent event) { diff --git a/src/main/java/us/minecraftchest2/hdm_mod/block/ModBlocks.java b/src/main/java/us/minecraftchest2/hdm_mod/block/ModBlocks.java index 5c7d76f..6849074 100644 --- a/src/main/java/us/minecraftchest2/hdm_mod/block/ModBlocks.java +++ b/src/main/java/us/minecraftchest2/hdm_mod/block/ModBlocks.java @@ -3,6 +3,7 @@ package us.minecraftchest2.hdm_mod.block; import net.minecraft.block.AbstractBlock; import net.minecraft.block.Block; import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; import net.minecraft.block.material.Material; import net.minecraft.item.BlockItem; import net.minecraft.item.Item; diff --git a/src/main/java/us/minecraftchest2/hdm_mod/item/ModItems.java b/src/main/java/us/minecraftchest2/hdm_mod/item/ModItems.java index f7b0f54..21d7357 100644 --- a/src/main/java/us/minecraftchest2/hdm_mod/item/ModItems.java +++ b/src/main/java/us/minecraftchest2/hdm_mod/item/ModItems.java @@ -1,11 +1,17 @@ package us.minecraftchest2.hdm_mod.item; +import net.minecraft.item.BlockItem; +import net.minecraft.item.Food; import net.minecraft.item.Item; +import net.minecraft.potion.Effect; +import net.minecraft.potion.EffectInstance; +import net.minecraft.potion.Effects; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.fml.RegistryObject; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; import us.minecraftchest2.hdm_mod.Hdm_mod; +import us.minecraftchest2.hdm_mod.block.ModBlocks; import us.minecraftchest2.hdm_mod.item.custom.SubtleKnife; public class ModItems { @@ -18,12 +24,13 @@ public class ModItems { public static final RegistryObject OMELET = ITEMS.register("omelet", - () -> new Item(new Item.Properties().group(ModItemGroup.HDM_ITEM_GROUP))); + () -> new Item(new Item.Properties().food(new Food.Builder().hunger(5).fastToEat().saturation(20) + .effect(() -> new EffectInstance(Effects.HUNGER, 40, 4), 0.75f).build()).group(ModItemGroup.HDM_ITEM_GROUP))); public static final RegistryObject KNIFE = ITEMS.register("subtle_knife", () -> new SubtleKnife(new Item.Properties().maxStackSize(1).group(ModItemGroup.HDM_ITEM_GROUP).maxDamage(2000))); - - + public static final RegistryObject OMELET_COOKED = ITEMS.register("omelet-cooked", + () -> new Item(new Item.Properties().food(new Food.Builder().hunger(5).fastToEat().saturation(20).build()).group(ModItemGroup.HDM_ITEM_GROUP))); public static void register(IEventBus eventBus) { ITEMS.register(eventBus); diff --git a/src/main/java/us/minecraftchest2/hdm_mod/world/dimension/SimpleTeleporter.java b/src/main/java/us/minecraftchest2/hdm_mod/world/dimension/SimpleTeleporter.java index 2579e20..9337c1f 100644 --- a/src/main/java/us/minecraftchest2/hdm_mod/world/dimension/SimpleTeleporter.java +++ b/src/main/java/us/minecraftchest2/hdm_mod/world/dimension/SimpleTeleporter.java @@ -132,6 +132,9 @@ public class SimpleTeleporter implements ITeleporter { case "the_end": dimensionName = "the End"; break; + case "hdm_dimension": + dimensionName = "HDM Dimension"; + break; default: dimensionName = path.replace('_', ' '); dimensionName = dimensionName.substring(0, 1).toUpperCase() + dimensionName.substring(1); diff --git a/src/main/resources/assets/hdm_mod/lang/en_us.json b/src/main/resources/assets/hdm_mod/lang/en_us.json index efdaf9b..30eb76e 100644 --- a/src/main/resources/assets/hdm_mod/lang/en_us.json +++ b/src/main/resources/assets/hdm_mod/lang/en_us.json @@ -4,6 +4,7 @@ "item.hdm_mod.subtle_knife": "Subtle Knife", "item.hdm_mod.omelet": "Omelet", + "item.hdm_mod.omelet-cooked": "Omelet", "item.hdm_mod.dust": "Dust", "block.hdm_mod.block_of_dust": "Block of Dust", "block.hdm_mod.window": "Window" diff --git a/src/main/resources/assets/hdm_mod/models/item/omelet-cooked.json b/src/main/resources/assets/hdm_mod/models/item/omelet-cooked.json new file mode 100644 index 0000000..2dccee3 --- /dev/null +++ b/src/main/resources/assets/hdm_mod/models/item/omelet-cooked.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "hdm_mod:item/omelet" + } +} \ No newline at end of file diff --git a/src/main/resources/data/hdm_mod/recipes/omelet.json b/src/main/resources/data/hdm_mod/recipes/omelet.json new file mode 100644 index 0000000..491aaec --- /dev/null +++ b/src/main/resources/data/hdm_mod/recipes/omelet.json @@ -0,0 +1,23 @@ +{ + "type": "minecraft:crafting_shaped", + "pattern": [ + "#B", + "E " + ], + "key": { + "#": { + "item": "minecraft:porkchop" + }, + "B": { + "item": "minecraft:brown_mushroom" + }, + "E": { + "item": "minecraft:egg" + } + }, + "result": { + "item": "hdm_mod:omelet", + "count": 1 + }, + "group": "omelets" +} \ No newline at end of file From 15b1027f9bccf8021501a6b9534ecd5f23d184ac Mon Sep 17 00:00:00 2001 From: dragonruler1000 Date: Wed, 28 May 2025 11:15:15 -0500 Subject: [PATCH 28/32] Add smelting recipe for cooked omelet to the mod Signed-off-by: dragonruler1000 --- .../resources/data/hdm_mod/recipes/omelet_cooked.json | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 src/main/resources/data/hdm_mod/recipes/omelet_cooked.json diff --git a/src/main/resources/data/hdm_mod/recipes/omelet_cooked.json b/src/main/resources/data/hdm_mod/recipes/omelet_cooked.json new file mode 100644 index 0000000..1a11c97 --- /dev/null +++ b/src/main/resources/data/hdm_mod/recipes/omelet_cooked.json @@ -0,0 +1,11 @@ +{ + "type": "minecraft:smelting", + "category": "food", + "ingredient": { + "item": "hdm_mod:omelet" + }, + "result": "hdm_mod:omelet-cooked", + "experience": 1, + "cookingtime": 200, + "group": "omelets" +} \ No newline at end of file From bcd5a4081351e2f43ee52119e7ed0c2c1c8ad335 Mon Sep 17 00:00:00 2001 From: dragonruler1000 Date: Wed, 28 May 2025 12:29:12 -0500 Subject: [PATCH 29/32] Introduce custom DustHouse structure and update mod configuration Added a new DustHouse structure with associated registration logic and configuration settings. Updated `gradle.properties`, introduced `accesstransformer.cfg`, and added JSON and NBT files for structure generation. Fixed typo in gradle daemon setting. Signed-off-by: dragonruler1000 --- gradle.properties | 2 +- .../us/minecraftchest2/hdm_mod/Hdm_mod.java | 3 + .../world/structure/ModStructures.java | 113 ++++++++++++++++++ .../structures/DustHouseStructure.java | 90 ++++++++++++++ .../resources/META-INF/accesstransformer.cfg | 4 + .../data/hdm_mod/structures/dust_house.nbt | Bin 0 -> 1465 bytes .../template_pool/house/start_pool.json | 15 +++ 7 files changed, 226 insertions(+), 1 deletion(-) create mode 100644 src/main/java/us/minecraftchest2/hdm_mod/world/structure/ModStructures.java create mode 100644 src/main/java/us/minecraftchest2/hdm_mod/world/structure/structures/DustHouseStructure.java create mode 100644 src/main/resources/META-INF/accesstransformer.cfg create mode 100644 src/main/resources/data/hdm_mod/structures/dust_house.nbt create mode 100644 src/main/resources/data/hdm_mod/worldgen/template_pool/house/start_pool.json diff --git a/gradle.properties b/gradle.properties index 6d71518..dd48fb0 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ org.gradle.jvmargs=-Xmx3G -org.gradle.daemon=true +org.gradle.daemon=flase # The Minecraft version must agree with the Forge version to get a valid artifact minecraft_version=1.16.5 # The Minecraft version range can use any release version of Minecraft as bounds. diff --git a/src/main/java/us/minecraftchest2/hdm_mod/Hdm_mod.java b/src/main/java/us/minecraftchest2/hdm_mod/Hdm_mod.java index 9a829ce..4032970 100644 --- a/src/main/java/us/minecraftchest2/hdm_mod/Hdm_mod.java +++ b/src/main/java/us/minecraftchest2/hdm_mod/Hdm_mod.java @@ -22,6 +22,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import us.minecraftchest2.hdm_mod.block.ModBlocks; import us.minecraftchest2.hdm_mod.item.ModItems; +import us.minecraftchest2.hdm_mod.world.structure.ModStructures; //import us.minecraftchest2.hdm_mod.init.ItemInit; import java.util.stream.Collectors; @@ -41,6 +42,8 @@ public class Hdm_mod { ModItems.register(modEventBus1); ModBlocks.register(modEventBus1); + ModStructures.register(modEventBus1); + modEventBus1.addListener(this::setup); // Register the enqueueIMC method for modloading modEventBus1.addListener(this::enqueueIMC); diff --git a/src/main/java/us/minecraftchest2/hdm_mod/world/structure/ModStructures.java b/src/main/java/us/minecraftchest2/hdm_mod/world/structure/ModStructures.java new file mode 100644 index 0000000..415c9bd --- /dev/null +++ b/src/main/java/us/minecraftchest2/hdm_mod/world/structure/ModStructures.java @@ -0,0 +1,113 @@ +package us.minecraftchest2.hdm_mod.world.structure; + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import net.minecraft.util.registry.WorldGenRegistries; +import net.minecraft.world.gen.feature.NoFeatureConfig; +import net.minecraft.world.gen.feature.structure.Structure; +import net.minecraft.world.gen.settings.DimensionStructuresSettings; +import net.minecraft.world.gen.settings.StructureSeparationSettings; +import net.minecraftforge.eventbus.api.IEventBus; +import net.minecraftforge.fml.RegistryObject; +import net.minecraftforge.registries.DeferredRegister; +import net.minecraftforge.registries.ForgeRegistries; +import us.minecraftchest2.hdm_mod.Hdm_mod; +import us.minecraftchest2.hdm_mod.world.structure.structures.DustHouseStructure; + +import java.util.HashMap; +import java.util.Map; + +public class ModStructures { + public static final DeferredRegister> STRUCTURES = + DeferredRegister.create(ForgeRegistries.STRUCTURE_FEATURES, Hdm_mod.MOD_ID); + + public static final RegistryObject> HOUSE = + STRUCTURES.register("house", DustHouseStructure::new); + + /* average distance apart in chunks between spawn attempts */ + /* minimum distance apart in chunks between spawn attempts. MUST BE LESS THAN ABOVE VALUE*/ + /* this modifies the seed of the structure so no two structures always spawn over each-other. + Make this large and unique. */ + public static void setupStructures() { + setupMapSpacingAndLand(HOUSE.get(), + new StructureSeparationSettings(100,50, 1234567890), + true); + } + + /** + * Adds the provided structure to the registry, and adds the separation settings. + * The rarity of the structure is determined based on the values passed into + * this method in the structureSeparationSettings argument. + * This method is called by setupStructures above. + **/ + public static > void setupMapSpacingAndLand(F structure, StructureSeparationSettings structureSeparationSettings, + boolean transformSurroundingLand) { + //add our structures into the map in Structure class + Structure.NAME_STRUCTURE_BIMAP.put(structure.getRegistryName().toString(), structure); + + /* + * Whether surrounding land will be modified automatically to conform to the bottom of the structure. + * Basically, it adds land at the base of the structure like it does for Villages and Outposts. + * Doesn't work well on structure that have pieces stacked vertically or change in heights. + * + */ + if (transformSurroundingLand) { + Structure.field_236384_t_ = ImmutableList.>builder() + .addAll(Structure.field_236384_t_) + .add(structure) + .build(); + } + + /* + * This is the map that holds the default spacing of all structures. + * Always add your structure to here so that other mods can utilize it if needed. + * + * However, while it does propagate the spacing to some correct dimensions from this map, + * it seems it doesn't always work for code made dimensions as they read from this list beforehand. + * + * Instead, we will use the WorldEvent.Load event in ModWorldEvents to add the structure + * spacing from this list into that dimension or to do dimension blacklisting properly. + * We also use our entry in DimensionStructuresSettings.DEFAULTS in WorldEvent.Load as well. + * + * DEFAULTS requires AccessTransformer (See resources/META-INF/accesstransformer.cfg) + */ + DimensionStructuresSettings.field_236191_b_ = + ImmutableMap., StructureSeparationSettings>builder() + .putAll(DimensionStructuresSettings.field_236191_b_) + .put(structure, structureSeparationSettings) + .build(); + + /* + * There are very few mods that relies on seeing your structure in the + * noise settings registry before the world is made. + * + * You may see some mods add their spacings to DimensionSettings.BUILTIN_OVERWORLD instead of the + * NOISE_GENERATOR_SETTINGS loop below but that field only applies for the default overworld and + * won't add to other worldtypes or dimensions (like amplified or Nether). + * So yeah, don't do DimensionSettings.BUILTIN_OVERWORLD. Use the NOISE_GENERATOR_SETTINGS loop + * below instead if you must. + */ + WorldGenRegistries.NOISE_SETTINGS.getEntries().forEach(settings -> { + Map, StructureSeparationSettings> structureMap = + settings.getValue().getStructures().func_236195_a_(); + /* + * Pre-caution in case a mod makes the structure map immutable like datapacks do. + * I take no chances myself. You never know what another mods does... + * + * structureConfig requires AccessTransformer (See resources/META-INF/accesstransformer.cfg) + */ + if (structureMap instanceof ImmutableMap) { + Map, StructureSeparationSettings> tempMap = new HashMap<>(structureMap); + tempMap.put(structure, structureSeparationSettings); + settings.getValue().getStructures().func_236195_a_(); + + } else { + structureMap.put(structure, structureSeparationSettings); + } + }); + } + + public static void register(IEventBus eventBus) { + STRUCTURES.register(eventBus); + } +} \ No newline at end of file diff --git a/src/main/java/us/minecraftchest2/hdm_mod/world/structure/structures/DustHouseStructure.java b/src/main/java/us/minecraftchest2/hdm_mod/world/structure/structures/DustHouseStructure.java new file mode 100644 index 0000000..64a5cb0 --- /dev/null +++ b/src/main/java/us/minecraftchest2/hdm_mod/world/structure/structures/DustHouseStructure.java @@ -0,0 +1,90 @@ +package us.minecraftchest2.hdm_mod.world.structure.structures; + +import net.minecraft.block.BlockState; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.SharedSeedRandom; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.ChunkPos; +import net.minecraft.util.math.MutableBoundingBox; +import net.minecraft.util.registry.DynamicRegistries; +import net.minecraft.util.registry.Registry; +import net.minecraft.world.IBlockReader; +import net.minecraft.world.biome.Biome; +import net.minecraft.world.biome.provider.BiomeProvider; +import net.minecraft.world.gen.ChunkGenerator; +import net.minecraft.world.gen.GenerationStage; +import net.minecraft.world.gen.Heightmap; +import net.minecraft.world.gen.feature.NoFeatureConfig; +import net.minecraft.world.gen.feature.jigsaw.JigsawManager; +import net.minecraft.world.gen.feature.structure.AbstractVillagePiece; +import net.minecraft.world.gen.feature.structure.Structure; +import net.minecraft.world.gen.feature.structure.StructureStart; +import net.minecraft.world.gen.feature.structure.VillageConfig; +import net.minecraft.world.gen.feature.template.TemplateManager; +import org.apache.logging.log4j.Level; +import org.apache.logging.log4j.LogManager; +import us.minecraftchest2.hdm_mod.Hdm_mod; + +public class DustHouseStructure extends Structure { + public DustHouseStructure() { + super(NoFeatureConfig.CODEC); + } + + @Override + public GenerationStage.Decoration getDecorationStage() { + return GenerationStage.Decoration.SURFACE_STRUCTURES; + } + + @Override + protected boolean func_230363_a_(ChunkGenerator chunkGenerator, BiomeProvider biomeSource, + long seed, SharedSeedRandom chunkRandom, int chunkX, int chunkZ, + Biome biome, ChunkPos chunkPos, NoFeatureConfig featureConfig) { + BlockPos centerOfChunk = new BlockPos((chunkX << 4) + 7, 0, (chunkZ << 4) + 7); + int landHeight = chunkGenerator.getHeight(centerOfChunk.getX(), centerOfChunk.getZ(), + Heightmap.Type.WORLD_SURFACE_WG); + + IBlockReader columnOfBlocks = chunkGenerator.func_230348_a_(centerOfChunk.getX(), centerOfChunk.getZ()); + BlockState topBlock = columnOfBlocks.getBlockState(centerOfChunk.up(landHeight)); + + return topBlock.getFluidState().isEmpty(); + } + + @Override + public IStartFactory getStartFactory() { + return DustHouseStructure.Start::new; + } + + public static class Start extends StructureStart { + public Start(Structure structureIn, int chunkX, int chunkZ, + MutableBoundingBox mutableBoundingBox, int referenceIn, long seedIn) { + super(structureIn, chunkX, chunkZ, mutableBoundingBox, referenceIn, seedIn); + } + + @Override // generatePieces + public void func_230364_a_(DynamicRegistries dynamicRegistryManager, ChunkGenerator chunkGenerator, + TemplateManager templateManagerIn, int chunkX, int chunkZ, Biome biomeIn, + NoFeatureConfig config) { + // Turns the chunk coordinates into actual coordinates we can use. (Gets center of that chunk) + int x = (chunkX << 4) + 7; + int z = (chunkZ << 4) + 7; + BlockPos blockpos = new BlockPos(x, 0, z); + + //addpieces() + JigsawManager.func_242837_a(dynamicRegistryManager, + new VillageConfig(() -> dynamicRegistryManager.getRegistry(Registry.JIGSAW_POOL_KEY) + .getOrDefault(new ResourceLocation(Hdm_mod.MOD_ID, "house/start_pool")), + 10), AbstractVillagePiece::new, chunkGenerator, templateManagerIn, + blockpos, this.components, this.rand,false,true); + + this.components.forEach(piece -> piece.offset(0, 1, 0)); + this.components.forEach(piece -> piece.getBoundingBox().minY -= 1); + + this.recalculateStructureSize(); + + LogManager.getLogger().log(Level.DEBUG, "House at " + + this.components.get(0).getBoundingBox().minX + " " + + this.components.get(0).getBoundingBox().minY + " " + + this.components.get(0).getBoundingBox().minZ); + } + } +} \ No newline at end of file diff --git a/src/main/resources/META-INF/accesstransformer.cfg b/src/main/resources/META-INF/accesstransformer.cfg new file mode 100644 index 0000000..b134280 --- /dev/null +++ b/src/main/resources/META-INF/accesstransformer.cfg @@ -0,0 +1,4 @@ +public-f net.minecraft.world.gen.feature.structure.Structure field_236384_t_ #LAND_TRANSFORMING_STRUCTURES +public-f net.minecraft.world.gen.settings.DimensionStructuresSettings field_236191_b_ #DEFAULT_STRUCTURE_CONFIGS +public-f net.minecraft.world.gen.FlatGenerationSettings field_202247_j #STRUCTURES +public-f net.minecraft.world.gen.settings.DimensionStructuresSettings field_236193_d_ #structures \ No newline at end of file diff --git a/src/main/resources/data/hdm_mod/structures/dust_house.nbt b/src/main/resources/data/hdm_mod/structures/dust_house.nbt new file mode 100644 index 0000000000000000000000000000000000000000..049ae74de81a1370a9a09e9a4fcab36d97f71854 GIT binary patch literal 1465 zcmb2|=3sz;qqBYUZ@WpfO#kh9)3;f!OYE|?qh!jy_bNl_;d#7Av z>WNBr-6ku6o{0YT-#yc3KV{ojocHii<@a>yImOejCsizc7^)w0SMFEr{_OMT_U@Y~ z|LyLpmo?90w#M!#cysQ@ve)hfFYlPw{{AK#?4xQBmvD$T_^d%-!lZ(=ItHx&@Pwz6pHR`J36oprC_NETTrO60 zV8c(IwzKI5jtPsv=75Z=ld+S|b}Fc`Wl8?~Th8t88N(bP^Q~~x=I@*bZ~kUkJ>ToZ zN2fmVqNWMLEps%UxG1V~T6&&1>EtI?)HNZvWlq!yMxgRFznOZr`fqs0ZE(%*;4b|G z5x-k3UZrQ{cAmSZ?sEKks6kFF>)~sm2G{D8t*ZA6&fR-|12Fi`sUFx+Y!7tLjh(y_ zWqMp~w&l$mzXgWb149vkZtP?Mg?M&-##dk{GPljW9do@(u^q@d3y#Zc`>wwNr-9i> znt%qZ`Mc*TJi7QL%HFYqbbn<&R^_)5WV!1>U$d!2 zOtuY=0>vBREfgywN^uus!*laCPU$$e5Xldk(NPb}~(7Q4>DK9T)fEQ`2UNSPgs8K>PN{pGRbQ{ zKmK^e@S2sqUGv;1V_kjyipqnhA+`gpYI-2b0<%5vLswI{2+Ve%Rh)62aNAke>r|w| zZ5Q0r^&pf5YJ1#|{ga~C@0L6k^}P8ZD}+>=Z1|gV{mRm-pJ1L;-?QwR&uN4wfi@#~ z5@<8BCpl3(sZ%kPbN$C#L2wIG553O&AUsu-7TbEy3zxaZ!%^UXacNgNc{=B^+ zd;9WJ@$#(c+jbvLe*I|Q-7kmB^Jf1&wzT&9rFpLoKKryYcK4RdZ_l@tRbF1hcIW6e z%lH?H&pv#6_H~o}of~G$m#1F0(Y+p9K5J)z)mypk@jp*7*zI9Ho0sSCKj+csk3Z~9 zKZdTWnJaz!>*r59qwA~w_O4Cc9=Xn*e{zkD>`}pydukp98zy4k?WB4um rk9hg{{d{$QGtWF{EB{}7*?j-@<)7DC^SnOn|4#o|)b`9xW(*7f{Mgav literal 0 HcmV?d00001 diff --git a/src/main/resources/data/hdm_mod/worldgen/template_pool/house/start_pool.json b/src/main/resources/data/hdm_mod/worldgen/template_pool/house/start_pool.json new file mode 100644 index 0000000..1fd8cd4 --- /dev/null +++ b/src/main/resources/data/hdm_mod/worldgen/template_pool/house/start_pool.json @@ -0,0 +1,15 @@ +{ + "name": "tutorialmod:house/start_pool", + "fallback": "minecraft:empty", + "elements": [ + { + "weight": 1, + "element": { + "location": "tutorialmod:house", + "processors": "minecraft:empty", + "projection": "rigid", + "element_type": "minecraft:single_pool_element" + } + } + ] +} \ No newline at end of file From 5a27c4ab2e1666822dc5bace1b0ce24549cd035f Mon Sep 17 00:00:00 2001 From: dragonruler1000 Date: Wed, 28 May 2025 17:43:08 -0500 Subject: [PATCH 30/32] Introduce dimensional event handling and improve loot table configuration Added `ModWorldEvents` class to manage custom dimensional events and ensure proper spacing in server world generation. Enhanced block_of_dust loot table with weighted drop chances and refined access transformer configuration in `build.gradle`. Integrated structure setup initialization in pre-loading event. Signed-off-by: dragonruler1000 --- build.gradle | 1 + .../us/minecraftchest2/hdm_mod/Hdm_mod.java | 4 +++ .../hdm_mod/world/ModWorldEvents.java | 31 +++++++++++++++++++ .../loot_tables/blocks/block_of_dust.json | 6 ++-- 4 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 src/main/java/us/minecraftchest2/hdm_mod/world/ModWorldEvents.java diff --git a/build.gradle b/build.gradle index a0ab1e4..816dfc4 100644 --- a/build.gradle +++ b/build.gradle @@ -31,6 +31,7 @@ minecraft { // Use non-default mappings at your own risk. They may not always work. // Simply re-run your setup task after changing the mappings to update your workspace. mappings channel: mapping_channel, version: mapping_version + accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') // When true, this property will have all Eclipse/IntelliJ IDEA run configurations run the "prepareX" task for the given run configuration before launching the game. // In most cases, it is not necessary to enable. diff --git a/src/main/java/us/minecraftchest2/hdm_mod/Hdm_mod.java b/src/main/java/us/minecraftchest2/hdm_mod/Hdm_mod.java index 4032970..d9e4bea 100644 --- a/src/main/java/us/minecraftchest2/hdm_mod/Hdm_mod.java +++ b/src/main/java/us/minecraftchest2/hdm_mod/Hdm_mod.java @@ -67,6 +67,10 @@ public class Hdm_mod { // some preinit code LOGGER.info("HELLO FROM PREINIT"); LOGGER.info("DIRT BLOCK >> {}", Blocks.DIRT.getRegistryName()); + + event.enqueueWork(() ->{ + ModStructures.setupStructures(); + }); } private void doClientStuff(final FMLClientSetupEvent event) { diff --git a/src/main/java/us/minecraftchest2/hdm_mod/world/ModWorldEvents.java b/src/main/java/us/minecraftchest2/hdm_mod/world/ModWorldEvents.java new file mode 100644 index 0000000..5497ffe --- /dev/null +++ b/src/main/java/us/minecraftchest2/hdm_mod/world/ModWorldEvents.java @@ -0,0 +1,31 @@ +package us.minecraftchest2.hdm_mod.world; + +import com.mojang.serialization.Codec; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.registry.Registry; +import net.minecraft.world.gen.ChunkGenerator; +import net.minecraft.world.server.ServerWorld; +import net.minecraftforge.event.world.WorldEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; +import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.common.ObfuscationReflectionHelper; +import us.minecraftchest2.hdm_mod.Hdm_mod; + +import java.lang.reflect.Method; + +@Mod.EventBusSubscriber(modid = Hdm_mod.MOD_ID) +public class ModWorldEvents { + @SubscribeEvent + public static void addDimensinalSpacing(final WorldEvent.Load event) { + if(event.getWorld() instanceof ServerWorld) { + ServerWorld serverWorld = (ServerWorld) event.getWorld(); + + try { + Method GETCODEC_METHOD = + ObfuscationReflectionHelper.findMethod(ChunkGenerator.class, "func_230347_a_"); + ResourceLocation cgRL = Registry.CHUNK_GENERATOR_CODEC.getKey( + (Codec)GETCODEC_METHOD.invoke(serverWorld.getChunkProvider().generator)); + } + } + } +} diff --git a/src/main/resources/data/hdm_mod/loot_tables/blocks/block_of_dust.json b/src/main/resources/data/hdm_mod/loot_tables/blocks/block_of_dust.json index 3424ef6..a333168 100644 --- a/src/main/resources/data/hdm_mod/loot_tables/blocks/block_of_dust.json +++ b/src/main/resources/data/hdm_mod/loot_tables/blocks/block_of_dust.json @@ -3,10 +3,12 @@ "pools": [ { "rolls": 1, - "entries":[ + "entries": [ { "type": "minecraft:item", - "name": "hdm_mod:dust" + "name": "hdm_mod:dust", + "weight": 4, + "quality": 9 } ] } From 3085bd5d920416724c0b891d5089f34e1f748cf7 Mon Sep 17 00:00:00 2001 From: dragonruler1000 Date: Thu, 26 Jun 2025 20:19:03 -0500 Subject: [PATCH 31/32] Update mod version to 1.2.3, rename DustHouseStructure to HouseStructure, and implement structure generation for plains biomes. Updated textures for the subtle knife and omelet items and the house structure should now generate. Signed-off-by: dragonruler1000 --- gradle.properties | 2 +- .../hdm_mod/item/custom/StructureLocator.java | 51 ++++++++++++++++++ .../hdm_mod/world/ModWorldEvents.java | 2 + .../world/gen/ModStructureGeneration.java | 27 ++++++++++ .../world/structure/ModStructures.java | 4 +- ...ouseStructure.java => HouseStructure.java} | 8 +-- .../assets/hdm_mod/textures/item/knife.png | Bin 108 -> 308 bytes .../assets/hdm_mod/textures/item/omelet.png | Bin 136 -> 230 bytes .../template_pool/house/start_pool.json | 4 +- 9 files changed, 89 insertions(+), 9 deletions(-) create mode 100644 src/main/java/us/minecraftchest2/hdm_mod/item/custom/StructureLocator.java create mode 100644 src/main/java/us/minecraftchest2/hdm_mod/world/gen/ModStructureGeneration.java rename src/main/java/us/minecraftchest2/hdm_mod/world/structure/structures/{DustHouseStructure.java => HouseStructure.java} (96%) diff --git a/gradle.properties b/gradle.properties index dd48fb0..0213130 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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.2 +mod_version=1.2.3 # 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 diff --git a/src/main/java/us/minecraftchest2/hdm_mod/item/custom/StructureLocator.java b/src/main/java/us/minecraftchest2/hdm_mod/item/custom/StructureLocator.java new file mode 100644 index 0000000..bab98f8 --- /dev/null +++ b/src/main/java/us/minecraftchest2/hdm_mod/item/custom/StructureLocator.java @@ -0,0 +1,51 @@ +//package us.minecraftchest2.hdm_mod.item.custom; +// +//import net.minecraft.entity.player.PlayerEntity; +//import net.minecraft.item.Item; +//import net.minecraft.item.ItemStack; +//import net.minecraft.util.*; +//import net.minecraft.util.text.StringTextComponent; +//import net.minecraft.world.World; +//import net.minecraft.world.gen.feature.structure.Structure; +////import net.minecraft.world.gen.feature.structure.StructureFeature; +//import net.minecraft.util.math.BlockPos; +//import net.minecraft.world.server.ServerWorld; +// +//public class StructureLocatorItem extends Item { +// +// public StructureLocatorItem(Properties properties) { +// super(properties); +// } +// +// @Override +// public ActionResult use(World world, PlayerEntity player, Hand hand) { +// if (!world.isClientSide && world instanceof ServerWorld) { +// ServerWorld serverWorld = (ServerWorld) world; +// BlockPos playerPos = player.blockPosition(); +// +// // Replace this with your own structure, or any StructureFeature +// Structure structureToFind = Structure.STRONGHOLD; +// +// BlockPos structurePos = serverWorld.getStructureLocation( +// structureToFind, +// playerPos, +// 100, // search radius in chunks +// false +// ); +// +// if (structurePos != null) { +// player.sendMessage( +// new StringTextComponent("Nearest structure at: " + structurePos.getX() + ", " + structurePos.getY() + ", " + structurePos.getZ()), +// player.getUUID() +// ); +// } else { +// player.sendMessage( +// new StringTextComponent("No structure found nearby."), +// player.getUUID() +// ); +// } +// } +// +// return ActionResult.resultSuccess(player.getItemInHand(hand)); +// } +//} diff --git a/src/main/java/us/minecraftchest2/hdm_mod/world/ModWorldEvents.java b/src/main/java/us/minecraftchest2/hdm_mod/world/ModWorldEvents.java index 5497ffe..2c7dd3f 100644 --- a/src/main/java/us/minecraftchest2/hdm_mod/world/ModWorldEvents.java +++ b/src/main/java/us/minecraftchest2/hdm_mod/world/ModWorldEvents.java @@ -25,6 +25,8 @@ public class ModWorldEvents { ObfuscationReflectionHelper.findMethod(ChunkGenerator.class, "func_230347_a_"); ResourceLocation cgRL = Registry.CHUNK_GENERATOR_CODEC.getKey( (Codec)GETCODEC_METHOD.invoke(serverWorld.getChunkProvider().generator)); + } catch (Exception e) { + e.printStackTrace(); } } } diff --git a/src/main/java/us/minecraftchest2/hdm_mod/world/gen/ModStructureGeneration.java b/src/main/java/us/minecraftchest2/hdm_mod/world/gen/ModStructureGeneration.java new file mode 100644 index 0000000..e083aa1 --- /dev/null +++ b/src/main/java/us/minecraftchest2/hdm_mod/world/gen/ModStructureGeneration.java @@ -0,0 +1,27 @@ +package us.minecraftchest2.hdm_mod.world.gen; + +import net.minecraft.util.RegistryKey; +import net.minecraft.util.registry.Registry; +import net.minecraft.world.biome.Biome; +import net.minecraft.world.gen.feature.IFeatureConfig; +import net.minecraft.world.gen.feature.StructureFeature; +import net.minecraftforge.common.BiomeDictionary; +import net.minecraftforge.event.world.BiomeLoadingEvent; +import us.minecraftchest2.hdm_mod.world.structure.ModStructures; + +import java.util.List; +import java.util.Set; +import java.util.function.Supplier; + +public class ModStructureGeneration { + public static void generateStructures(final BiomeLoadingEvent event) { + RegistryKey key = RegistryKey.getOrCreateKey(Registry.BIOME_KEY, event.getName()); + Set types = BiomeDictionary.getTypes(key); + + if(types.contains(BiomeDictionary.Type.PLAINS)) { + List>> structures = event.getGeneration().getStructures(); + + structures.add(() -> ModStructures.HOUSE.get().withConfiguration(IFeatureConfig.NO_FEATURE_CONFIG)); + } + } +} \ No newline at end of file diff --git a/src/main/java/us/minecraftchest2/hdm_mod/world/structure/ModStructures.java b/src/main/java/us/minecraftchest2/hdm_mod/world/structure/ModStructures.java index 415c9bd..a7927f5 100644 --- a/src/main/java/us/minecraftchest2/hdm_mod/world/structure/ModStructures.java +++ b/src/main/java/us/minecraftchest2/hdm_mod/world/structure/ModStructures.java @@ -12,7 +12,7 @@ import net.minecraftforge.fml.RegistryObject; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; import us.minecraftchest2.hdm_mod.Hdm_mod; -import us.minecraftchest2.hdm_mod.world.structure.structures.DustHouseStructure; +import us.minecraftchest2.hdm_mod.world.structure.structures.HouseStructure; import java.util.HashMap; import java.util.Map; @@ -22,7 +22,7 @@ public class ModStructures { DeferredRegister.create(ForgeRegistries.STRUCTURE_FEATURES, Hdm_mod.MOD_ID); public static final RegistryObject> HOUSE = - STRUCTURES.register("house", DustHouseStructure::new); + STRUCTURES.register("house", HouseStructure::new); /* average distance apart in chunks between spawn attempts */ /* minimum distance apart in chunks between spawn attempts. MUST BE LESS THAN ABOVE VALUE*/ diff --git a/src/main/java/us/minecraftchest2/hdm_mod/world/structure/structures/DustHouseStructure.java b/src/main/java/us/minecraftchest2/hdm_mod/world/structure/structures/HouseStructure.java similarity index 96% rename from src/main/java/us/minecraftchest2/hdm_mod/world/structure/structures/DustHouseStructure.java rename to src/main/java/us/minecraftchest2/hdm_mod/world/structure/structures/HouseStructure.java index 64a5cb0..9a65477 100644 --- a/src/main/java/us/minecraftchest2/hdm_mod/world/structure/structures/DustHouseStructure.java +++ b/src/main/java/us/minecraftchest2/hdm_mod/world/structure/structures/HouseStructure.java @@ -21,12 +21,12 @@ import net.minecraft.world.gen.feature.structure.Structure; import net.minecraft.world.gen.feature.structure.StructureStart; import net.minecraft.world.gen.feature.structure.VillageConfig; import net.minecraft.world.gen.feature.template.TemplateManager; +import us.minecraftchest2.hdm_mod.Hdm_mod; import org.apache.logging.log4j.Level; import org.apache.logging.log4j.LogManager; -import us.minecraftchest2.hdm_mod.Hdm_mod; -public class DustHouseStructure extends Structure { - public DustHouseStructure() { +public class HouseStructure extends Structure { + public HouseStructure() { super(NoFeatureConfig.CODEC); } @@ -51,7 +51,7 @@ public class DustHouseStructure extends Structure { @Override public IStartFactory getStartFactory() { - return DustHouseStructure.Start::new; + return HouseStructure.Start::new; } public static class Start extends StructureStart { diff --git a/src/main/resources/assets/hdm_mod/textures/item/knife.png b/src/main/resources/assets/hdm_mod/textures/item/knife.png index 859a66dd3a8d102cda4661fac0818bd00290be23..01538f80d4c36d7fb88e16901e2ab23e6f801a1b 100644 GIT binary patch delta 267 zcmV+m0rdWCv;vSZf9^>{K~y-6V_+BsjKnD7vp4$>V}Ck$iYPrOnwR|j@L&7*n*YcK z5v|$y_38iG$JhKfetr5shpGa81NiLC;IYAwxujj8};82lg zxM~&3@ZS;vpnf!a%n%Pk&wW^aEpzZ Ur8{ETJ_aE0boFyt=akR{0Kx$k8~^|S diff --git a/src/main/resources/assets/hdm_mod/textures/item/omelet.png b/src/main/resources/assets/hdm_mod/textures/item/omelet.png index edf0513db1c0fb036a94f0e6f95ebd023de1534e..ca90c3f7b483059212c1eae3a79e281b4d3afac5 100644 GIT binary patch delta 189 zcmV;u07CzW0pW92)ARV{`fHqH19VIoE| zE8i)c@^AytB?HQTA{&g;5)>C8Yu?bwj$+8XPg2;FLc#!>(*nwWGHjiG5yJ)ZK1ng8 z%WQy$1&Rw`eq~@_VA#;f&hYz_8HQ$bz=Ui&vSM^F?~@cm5;os6OfTSzHe_32n$e>Y rs{yQhr?9$)U^;*SVl^``FfafBC=pE;=qi`%00000NkvXXu0mjfI516} delta 94 zcmaFH*ugl#Fx<)0#WBR9H#tFq^|0ihe<|PQOO*QTFtK0x+hK~L1RF@i{{0t!wwY>- xZF?@;cb0LsDSqd^@^A7|$(sV3O#2NO7%Ih;-d@@_eKP|Pc)I$ztaD0e0sw*#C&>T+ diff --git a/src/main/resources/data/hdm_mod/worldgen/template_pool/house/start_pool.json b/src/main/resources/data/hdm_mod/worldgen/template_pool/house/start_pool.json index 1fd8cd4..b805d55 100644 --- a/src/main/resources/data/hdm_mod/worldgen/template_pool/house/start_pool.json +++ b/src/main/resources/data/hdm_mod/worldgen/template_pool/house/start_pool.json @@ -1,11 +1,11 @@ { - "name": "tutorialmod:house/start_pool", + "name": "hdm_mod:house/start_pool", "fallback": "minecraft:empty", "elements": [ { "weight": 1, "element": { - "location": "tutorialmod:house", + "location": "hdm_mod:house", "processors": "minecraft:empty", "projection": "rigid", "element_type": "minecraft:single_pool_element" From 092a473abd328196fae5f82217e5fd7f748b99c9 Mon Sep 17 00:00:00 2001 From: dragonruler1000 Date: Fri, 27 Jun 2025 20:34:31 -0500 Subject: [PATCH 32/32] Updated the portal block texture Signed-off-by: dragonruler1000 --- .../assets/hdm_mod/models/block/window.json | 2 +- .../assets/hdm_mod/textures/block/portalblock.png | Bin 0 -> 228 bytes 2 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 src/main/resources/assets/hdm_mod/textures/block/portalblock.png diff --git a/src/main/resources/assets/hdm_mod/models/block/window.json b/src/main/resources/assets/hdm_mod/models/block/window.json index 43306a9..f302f99 100644 --- a/src/main/resources/assets/hdm_mod/models/block/window.json +++ b/src/main/resources/assets/hdm_mod/models/block/window.json @@ -1,6 +1,6 @@ { "parent": "block/cube_all", "textures" : { - "all": "hdm_mod:block/grey" + "all": "hdm_mod:block/portalblock" } } \ No newline at end of file diff --git a/src/main/resources/assets/hdm_mod/textures/block/portalblock.png b/src/main/resources/assets/hdm_mod/textures/block/portalblock.png new file mode 100644 index 0000000000000000000000000000000000000000..29a83400e80eaf2e85aff707a3c1670f026d1ae2 GIT binary patch literal 228 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|=6Sj}hFJ6_ zhfFd5dEPMrDwulxP* zYR`3sBt}Q(4?pKOGP+9~U|2Un{S-q^q2Ct97ALv&j4gja3jXw5W=Q(m!zXd_$W-So+_$0QrN#)78&qol`;+06>aXeE