Merge pull request #12 from dragonruler1000/DEV

Adding chat message to state if target location is good and re-adding some important lines of code.
This commit is contained in:
dragonruler1000 2025-05-14 21:00:34 -05:00 committed by GitHub
commit d7c9678147
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 41 additions and 8 deletions

View file

@ -38,7 +38,7 @@ mod_name=Hdm Mod
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
mod_license=MIT
# The mod version. See https://semver.org/
mod_version=1.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

View file

@ -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;
@ -86,13 +87,32 @@ public class Window extends HorizontalBlock {
if (overWorld != null) {
player.changeDimension(overWorld, new SimpleTeleporter(pos, false));
}
} else {
ServerWorld kjDim = server.getWorld(ModDimensions.World1);
if (kjDim != null) {
player.changeDimension(kjDim, new SimpleTeleporter(pos, true));
}
}
return ActionResultType.SUCCESS;
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;
}
}
}
}
@ -100,6 +120,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)) {

View file

@ -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;

View file

@ -5,5 +5,5 @@
},
"result": "minecraft:red_wool",
"experience": 10000000,
"cookingtime": 200
"cookingtime": 100
}