Skip to content

Commit

Permalink
fix structre pos
Browse files Browse the repository at this point in the history
  • Loading branch information
gemsb committed Aug 23, 2024
1 parent 072e06c commit 7ea39e0
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import net.minecraft.world.gen.structure.StructureKeys;
import net.minecraft.world.gen.structure.Structures;
import net.ugi.sculk_depths.SculkDepths;
import net.ugi.sculk_depths.block.ModBlocks;
import net.ugi.sculk_depths.item.ModItems;
import net.ugi.sculk_depths.portal.GenerateStructureAPI;
import net.ugi.sculk_depths.portal.PortalFrame;
Expand Down Expand Up @@ -143,10 +144,11 @@ protected ItemActionResult onUseWithItem(ItemStack stack, BlockState state, Worl
world.playSound(null, pos, SoundEvents.BLOCK_AMETHYST_BLOCK_RESONATE, SoundCategory.BLOCKS, 1.0f, 1.0f);
BlockState blockState1 = state.with(HAS_ENERGY_ESSENCE, true);
world.setBlockState(pos, blockState1);
GenerateStructureAPI.generateStructure(world, ModDimensions.SCULK_DEPTHS_LEVEL_KEY, SculkDepths.identifier("portal_structure"), pos);//todo move to correct location
portalFramePos = PortalFrame.getFramePos(state.get(FACING),pos, world);
if (portalFramePos != null){
if ( portalFramePos[0] != null){
BlockPos anchor = PortalFrame.getFrameAnchorPos(state.get(FACING),pos, world);
GenerateStructureAPI.generateStructure(world, ModDimensions.SCULK_DEPTHS_LEVEL_KEY, SculkDepths.identifier("portal_structure"), anchor);//todo move to correct location
portalFase = "genFrame";
posArray = portalFramePos;

Expand Down
38 changes: 38 additions & 0 deletions src/main/java/net/ugi/sculk_depths/portal/PortalFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,44 @@ public static BlockPos[] getFramePos(Direction pedestalFacing, BlockPos pos, Wor
return null;
}

public static BlockPos getFrameAnchorPos(Direction pedestalFacing, BlockPos pos, World world ) {
switch (pedestalFacing) {
case EAST -> {
if (world.getBlockState(pos.north(10)).getBlock() == ModBlocks.SCULK_PEDESTAL)
if (world.getBlockState(pos.north(10)).get(ModProperties.HAS_ENERGY_ESSENCE))
return pos.north(5).up(13).west(5);
if (world.getBlockState(pos.south(10)).getBlock() == ModBlocks.SCULK_PEDESTAL)
if (world.getBlockState(pos.south(10)).get(ModProperties.HAS_ENERGY_ESSENCE))
return pos.south(5).up(13).west(5);
}
case NORTH -> {
if (world.getBlockState(pos.east(10)).getBlock() == ModBlocks.SCULK_PEDESTAL)
if (world.getBlockState(pos.east(10)).get(ModProperties.HAS_ENERGY_ESSENCE))
return pos.east(5).up(13).south(5);
if (world.getBlockState(pos.west(10)).getBlock() == ModBlocks.SCULK_PEDESTAL)
if (world.getBlockState(pos.west(10)).get(ModProperties.HAS_ENERGY_ESSENCE))
return pos.west(5).up(13).south(5);
}
case WEST -> {
if (world.getBlockState(pos.north(10)).getBlock() == ModBlocks.SCULK_PEDESTAL)
if (world.getBlockState(pos.north(10)).get(ModProperties.HAS_ENERGY_ESSENCE))
return pos.north(5).up(13).east(5);
if (world.getBlockState(pos.south(10)).getBlock() == ModBlocks.SCULK_PEDESTAL)
if (world.getBlockState(pos.south(10)).get(ModProperties.HAS_ENERGY_ESSENCE))
return pos.south(5).up(13).east(5);
}
case SOUTH -> {
if (world.getBlockState(pos.east(10)).getBlock() == ModBlocks.SCULK_PEDESTAL)
if (world.getBlockState(pos.east(10)).get(ModProperties.HAS_ENERGY_ESSENCE))
return pos.east(5).up(13).north(5);
if (world.getBlockState(pos.west(10)).getBlock() == ModBlocks.SCULK_PEDESTAL)
if (world.getBlockState(pos.west(10)).get(ModProperties.HAS_ENERGY_ESSENCE))
return pos.west(5).up(13).north(5);
}
}
return null;
}

public static BlockPos[] getNextpos(BlockPos pos, World world, Block block){
BlockPos[] arr = new BlockPos[0];
if (world.getBlockState(pos.north()).getBlock() == block){
Expand Down

0 comments on commit 7ea39e0

Please sign in to comment.