mirror of
https://github.com/dragonruler1000/hdm-mod.git
synced 2025-06-29 00:19:32 -05:00
trying to get a chat message to show in the chat if the portal cant find an aplicable loccation.
Signed-off-by: dragonruler1000 <github@me.minecraftchest2.us>
This commit is contained in:
parent
cc98e7cd6b
commit
8f94831df0
4 changed files with 35 additions and 12 deletions
|
@ -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
|
||||
|
|
|
@ -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)) {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -5,5 +5,5 @@
|
|||
},
|
||||
"result": "minecraft:red_wool",
|
||||
"experience": 10000000,
|
||||
"cookingtime": 200
|
||||
"cookingtime": 100
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue