mirror of
https://github.com/dragonruler1000/hdm-mod.git
synced 2025-06-29 08:29:33 -05:00
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:
commit
d7c9678147
4 changed files with 41 additions and 8 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.
|
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
|
||||||
mod_license=MIT
|
mod_license=MIT
|
||||||
# The mod version. See https://semver.org/
|
# 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.
|
# 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.
|
# This should match the base package used for the mod sources.
|
||||||
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
|
# 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.ISelectionContext;
|
||||||
import net.minecraft.util.math.shapes.VoxelShape;
|
import net.minecraft.util.math.shapes.VoxelShape;
|
||||||
import net.minecraft.util.math.shapes.VoxelShapes;
|
import net.minecraft.util.math.shapes.VoxelShapes;
|
||||||
|
import net.minecraft.util.text.StringTextComponent;
|
||||||
import net.minecraft.world.IBlockReader;
|
import net.minecraft.world.IBlockReader;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraft.world.server.ServerWorld;
|
import net.minecraft.world.server.ServerWorld;
|
||||||
|
@ -86,20 +87,40 @@ public class Window extends HorizontalBlock {
|
||||||
if (overWorld != null) {
|
if (overWorld != null) {
|
||||||
player.changeDimension(overWorld, new SimpleTeleporter(pos, false));
|
player.changeDimension(overWorld, new SimpleTeleporter(pos, false));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
ServerWorld targetWorld;
|
||||||
|
boolean goingToCustom = worldIn.getDimensionKey() != ModDimensions.World1;
|
||||||
|
|
||||||
|
if (goingToCustom) {
|
||||||
|
targetWorld = server.getWorld(ModDimensions.World1);
|
||||||
} else {
|
} else {
|
||||||
ServerWorld kjDim = server.getWorld(ModDimensions.World1);
|
ServerWorld world1 = server.getWorld(ModDimensions.World1);
|
||||||
if (kjDim != null) {
|
if (world1 != null) {
|
||||||
player.changeDimension(kjDim, new SimpleTeleporter(pos, true));
|
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 ActionResultType.SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return super.onBlockActivated(state, worldIn, pos, player, handIn, hit);
|
return super.onBlockActivated(state, worldIn, pos, player, handIn, hit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
|
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
|
||||||
switch (state.get(HORIZONTAL_FACING)) {
|
switch (state.get(HORIZONTAL_FACING)) {
|
||||||
|
|
|
@ -17,6 +17,12 @@ public class SimpleTeleporter implements ITeleporter {
|
||||||
public static BlockPos thisPos = BlockPos.ZERO;
|
public static BlockPos thisPos = BlockPos.ZERO;
|
||||||
public static boolean insideDimension = true;
|
public static boolean insideDimension = true;
|
||||||
|
|
||||||
|
private boolean success = false;
|
||||||
|
|
||||||
|
public boolean wasSuccessful() {
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
public SimpleTeleporter(BlockPos pos, boolean insideDim) {
|
public SimpleTeleporter(BlockPos pos, boolean insideDim) {
|
||||||
thisPos = pos;
|
thisPos = pos;
|
||||||
insideDimension = insideDim;
|
insideDimension = insideDim;
|
||||||
|
@ -50,7 +56,13 @@ public class SimpleTeleporter implements ITeleporter {
|
||||||
tries++;
|
tries++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (tries >= 25) {
|
||||||
|
this.success = false;
|
||||||
|
return entity;
|
||||||
|
}
|
||||||
|
|
||||||
entity.setPositionAndUpdate(destinationPos.getX(), destinationPos.getY(), destinationPos.getZ());
|
entity.setPositionAndUpdate(destinationPos.getX(), destinationPos.getY(), destinationPos.getZ());
|
||||||
|
this.success = true;
|
||||||
|
|
||||||
if (insideDimension) {
|
if (insideDimension) {
|
||||||
boolean doSetBlock = true;
|
boolean doSetBlock = true;
|
||||||
|
|
|
@ -5,5 +5,5 @@
|
||||||
},
|
},
|
||||||
"result": "minecraft:red_wool",
|
"result": "minecraft:red_wool",
|
||||||
"experience": 10000000,
|
"experience": 10000000,
|
||||||
"cookingtime": 200
|
"cookingtime": 100
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue