mirror of
https://github.com/dragonruler1000/hdm-mod.git
synced 2025-06-29 08:29:33 -05:00
Merge pull request #10 from dragonruler1000/DEV
Added a new dimension and trying to get right click to change the dimention
This commit is contained in:
commit
6e40197dd9
6 changed files with 118 additions and 20 deletions
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -9,4 +9,6 @@ import us.minecraftchest2.hdm_mod.Hdm_mod;
|
|||
public class ModDimensions {
|
||||
public static RegistryKey<World> TestDim = RegistryKey.getOrCreateKey(Registry.WORLD_KEY,
|
||||
new ResourceLocation(Hdm_mod.MOD_ID, "testdim"));
|
||||
public static RegistryKey<World> World1 = RegistryKey.getOrCreateKey(Registry.WORLD_KEY,
|
||||
new ResourceLocation(Hdm_mod.MOD_ID, "world1"));
|
||||
}
|
||||
|
|
|
@ -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<Boolean, Entity> 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++;
|
||||
}
|
||||
|
|
13
src/main/resources/data/hdm_mod/dimension/world1.json
Normal file
13
src/main/resources/data/hdm_mod/dimension/world1.json
Normal file
|
@ -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"
|
||||
}
|
||||
}
|
|
@ -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"
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue