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:
dragonruler1000 2025-05-14 10:01:22 -05:00 committed by GitHub
commit 6e40197dd9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 118 additions and 20 deletions

View file

@ -81,13 +81,13 @@ public class Window extends HorizontalBlock {
MinecraftServer server = worldIn.getServer(); MinecraftServer server = worldIn.getServer();
if (server != null) { if (server != null) {
if (worldIn.getDimensionKey() == ModDimensions.TestDim) { if (worldIn.getDimensionKey() == ModDimensions.World1) {
ServerWorld overWorld = server.getWorld(World.OVERWORLD); ServerWorld overWorld = server.getWorld(World.OVERWORLD);
if (overWorld != null) { if (overWorld != null) {
player.changeDimension(overWorld, new SimpleTeleporter(pos, false)); player.changeDimension(overWorld, new SimpleTeleporter(pos, false));
} }
} else { } else {
ServerWorld kjDim = server.getWorld(ModDimensions.TestDim); ServerWorld kjDim = server.getWorld(ModDimensions.World1);
if (kjDim != null) { if (kjDim != null) {
player.changeDimension(kjDim, new SimpleTeleporter(pos, true)); player.changeDimension(kjDim, new SimpleTeleporter(pos, true));
} }
@ -126,4 +126,6 @@ public class Window extends HorizontalBlock {
public BlockState getStateForPlacement(BlockItemUseContext context) { public BlockState getStateForPlacement(BlockItemUseContext context) {
return this.getDefaultState().with(HORIZONTAL_FACING, context.getPlacementHorizontalFacing().getOpposite()); return this.getDefaultState().with(HORIZONTAL_FACING, context.getPlacementHorizontalFacing().getOpposite());
} }
}
}

View file

@ -16,6 +16,7 @@ import net.minecraft.util.text.ScoreTextComponent;
import net.minecraft.util.text.StringTextComponent; import net.minecraft.util.text.StringTextComponent;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.client.MinecraftForgeClient; import net.minecraftforge.client.MinecraftForgeClient;
import us.minecraftchest2.hdm_mod.block.ModBlocks;
public class SubtleKnife extends Item { public class SubtleKnife extends Item {
@ -41,7 +42,7 @@ public class SubtleKnife extends Item {
// Server-side logic only: place a block // Server-side logic only: place a block
if (!world.isRemote) { 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; return ActionResultType.SUCCESS;

View file

@ -9,4 +9,6 @@ import us.minecraftchest2.hdm_mod.Hdm_mod;
public class ModDimensions { public class ModDimensions {
public static RegistryKey<World> TestDim = RegistryKey.getOrCreateKey(Registry.WORLD_KEY, public static RegistryKey<World> TestDim = RegistryKey.getOrCreateKey(Registry.WORLD_KEY,
new ResourceLocation(Hdm_mod.MOD_ID, "testdim")); new ResourceLocation(Hdm_mod.MOD_ID, "testdim"));
public static RegistryKey<World> World1 = RegistryKey.getOrCreateKey(Registry.WORLD_KEY,
new ResourceLocation(Hdm_mod.MOD_ID, "world1"));
} }

View file

@ -1,5 +1,6 @@
package us.minecraftchest2.hdm_mod.world.dimension; package us.minecraftchest2.hdm_mod.world.dimension;
import net.minecraft.block.BlockState;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.fluid.Fluids; import net.minecraft.fluid.Fluids;
@ -21,6 +22,16 @@ public class SimpleTeleporter implements ITeleporter {
insideDimension = insideDim; 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 @Override
public Entity placeEntity(Entity entity, ServerWorld currentWorld, ServerWorld destinationWorld, public Entity placeEntity(Entity entity, ServerWorld currentWorld, ServerWorld destinationWorld,
float yaw, Function<Boolean, Entity> repositionEntity) { float yaw, Function<Boolean, Entity> repositionEntity) {
@ -33,23 +44,8 @@ public class SimpleTeleporter implements ITeleporter {
BlockPos destinationPos = new BlockPos(thisPos.getX(), y, thisPos.getZ()); BlockPos destinationPos = new BlockPos(thisPos.getX(), y, thisPos.getZ());
int tries = 0; int tries = 0;
while ( while ((isUnsafe(destinationWorld, destinationPos) || isUnsafe(destinationWorld, destinationPos.up())) && tries < 25) {
(
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); destinationPos = destinationPos.up(2);
tries++; tries++;
} }

View 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"
}
}

View file

@ -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"
}
}