10000 Port741 by someaddons · Pull Request #742 · ldtteam/Structurize · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Port741 #742

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
import com.ldtteam.structurize.api.IRotatableBlockEntity;
import com.ldtteam.structurize.api.ItemStackUtils;
import com.ldtteam.structurize.api.Log;
import com.ldtteam.structurize.api.RotationMirror;
import com.ldtteam.structurize.blocks.ModBlocks;
import com.ldtteam.structurize.blocks.schematic.BlockFluidSubstitution;
import com.ldtteam.structurize.blueprints.v1.Blueprint;
import com.ldtteam.structurize.placement.structure.IStructureHandler;
import com.ldtteam.structurize.tag.ModTags;
import com.ldtteam.structurize.util.BlockUtils;
import com.ldtteam.structurize.api.RotationMirror;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag;
Expand All @@ -23,7 +23,10 @@
import net.minecraft.world.level.block.*;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.*;
import net.minecraft.world.level.block.state.properties.BedPart;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.block.state.properties.DoubleBlockHalf;
import net.minecraft.world.level.block.state.properties.DripstoneThickness;
import net.minecraft.world.phys.AABB;
import org.jetbrains.annotations.Nullable;

Expand Down Expand Up @@ -244,19 +247,29 @@ public List<ItemStack> getRequiredItems(
if (!BlockUtils.isAnySolid(world.getBlockState(pos.below())))
{
BlockPos posBelow = pos;
BlockState supportBlockState = Blocks.DIRT.defaultBlockState();
BlockState supportBlockState = Blocks.DIRT instanceof Fallable ? Blocks.STONE.defaultBlockState() : Blocks.DIRT.defaultBlockState();
for (int i = 0; i < 10; i++) // try up to ten blocks below for solid worldgen
{
posBelow = posBelow.below();
final boolean isFirstTest = i == 0;
final BlockState possibleSupport = BlockUtils.getWorldgenBlock(world, posBelow, bp -> isFirstTest ? blockState : null);
if (possibleSupport != null && BlockUtils.canBlockFloatInAir(possibleSupport) && !canHandle(world, posBelow, possibleSupport))
if (possibleSupport != null && BlockUtils.canBlockFloatInAir(possibleSupport) && !canHandle(world,
posBelow,
possibleSupport))
{
supportBlockState = possibleSupport;
break;
}
}
itemList.addAll(getRequiredItemsForState(world, pos, supportBlockState, tileEntityData, complete));

if (canHandle(world, pos, supportBlockState))
{
Log.getLogger().warn("Unable to use: " + supportBlockState + " as support for a falling block, it is either a falling black itself or made fallable");
}
else
{
itemList.addAll(getRequiredItemsForState(world, pos, supportBlockState, tileEntityData, complete));
}
}
return itemList;
}
Expand Down
23 changes: 7 additions & 16 deletions src/main/java/com/ldtteam/structurize/util/BlockUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,7 @@
import net.minecraft.util.StaticCache2D;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.item.AirItem;
import net.minecraft.world.item.BedItem;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.BucketItem;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.*;
import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.item.context.UseOnContext;
import net.minecraft.world.level.ChunkPos;
Expand All @@ -49,12 +43,7 @@
import net.minecraft.world.level.chunk.status.ChunkStatus;
import net.minecraft.world.level.chunk.status.ChunkStep;
import net.minecraft.world.level.dimension.DimensionType;
import net.minecraft.world.level.levelgen.FlatLevelSource;
import net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator;
import net.minecraft.world.level.levelgen.NoiseChunk;
import net.minecraft.world.level.levelgen.NoiseGeneratorSettings;
import net.minecraft.world.level.levelgen.SurfaceRules;
import net.minecraft.world.level.levelgen.WorldGenerationContext;
import net.minecraft.world.level.levelgen.*;
import net.minecraft.world.level.levelgen.blending.Blender;
import net.minecraft.world.level.material.Fluid;
import net.minecraft.world.level.storage.loot.LootParams;
Expand All @@ -64,6 +53,7 @@
import net.neoforged.neoforge.common.util.FakePlayer;
import net.neoforged.neoforge.registries.GameData;
import org.jetbrains.annotations.Nullable;

import java.text.MessageFormat;
import java.util.*;
import java.util.function.BiPredicate;
Expand Down Expand Up @@ -111,7 +101,8 @@ public static void checkOrInit()
{
BuiltInRegistries.BLOCK.stream()
.filter(BlockUtils::canBlockSurviveWithoutSupport)
.filter(block -> !block.defaultBlockState().canBeReplaced() && block.hasCollision && !block.defaultBlockState().isAir() && !(block instanceof LiquidBlock) && !block.builtInRegistryHolder().is(ModTags.WEAK_SOLID_BLOCKS))
.filter(block -> !block.defaultBlockState().canBeReplaced() && block.hasCollision && !(block instanceof Fallable) && !block.defaultBlockState().isAir()
&& !(block instanceof LiquidBlock) && !block.builtInRegistryHolder().is(ModTags.WEAK_SOLID_BLOCKS))
.forEach(trueSolidBlocks::add);
}
}
Expand Down Expand Up @@ -697,7 +688,7 @@ private static <T extends Comparable<T>> BlockState copyProperty(final BlockStat
{
return to.setValue(property, from.getValue(property));
}

private static class OurWorldGenRegion extends WorldGenRegion
{
private final StaticCache2D<ChunkAccess> chunks;
Expand All @@ -709,7 +700,7 @@ private OurWorldGenRegion(final ServerLevel level, final ChunkStep step, final C
final int chunkX = chunk.getPos().x;
final int chunkZ = chunk.getPos().z;
final int chunkRange = step.accumulatedDependencies().getRadius();

this.level = level;
chunks = StaticCache2D.create(chunkX, chunkZ, chunkRange, (x, z) -> {
ChunkAccess surroundingChunk = level.getChunk(x, z, ChunkStatus.SURFACE);
Expand Down
0