Skip to content
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

scan tool fixes #719

Merged
merged 2 commits into from
Feb 8, 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 @@ -6,6 +6,7 @@
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.Blocks;

/**
* Operation for removing one type of block.
Expand Down Expand Up @@ -37,6 +38,10 @@ protected void apply(final ServerLevel world, final BlockPos position)
{
storage.addPreviousDataFor(position, world);
world.removeBlock(position, false);
if (!world.getFluidState(position).isEmpty())
{
world.setBlock(position, Blocks.AIR.defaultBlockState(), 3);
}
storage.addPostDataFor(position, world);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@
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.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.level.block.state.properties.*;
import net.minecraft.world.phys.AABB;
import org.jetbrains.annotations.Nullable;

Expand Down Expand Up @@ -342,9 +339,11 @@ public List<ItemStack> getRequiredItems(
@Nullable final CompoundTag tileEntityData,
final boolean complete)
{
final List<ItemStack> itemList = new ArrayList<>();
itemList.add(new ItemStack(Blocks.DIRT));
return itemList;
if (complete)
{
return Collections.singletonList(new ItemStack(blockState.getBlock()));
}
return Collections.singletonList(new ItemStack(Blocks.DIRT));
}
}

Expand Down Expand Up @@ -648,9 +647,11 @@ public List<ItemStack> getRequiredItems(
@Nullable final CompoundTag tileEntityData,
final boolean complete)
{
final List<ItemStack> itemList = new ArrayList<>();
itemList.add(new ItemStack(Blocks.DIRT, 1));
return itemList;
if (complete)
{
return Collections.singletonList(new ItemStack(blockState.getBlock()));
}
return Collections.singletonList(new ItemStack(Blocks.DIRT));
}
}

Expand Down Expand Up @@ -687,6 +688,10 @@ public List<ItemStack> getRequiredItems(
@Nullable final CompoundTag tileEntityData,
final boolean complete)
{
if (complete)
{
return Collections.singletonList(new ItemStack(blockState.getBlock()));
}
return new ArrayList<>();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this always be the block?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this is when the world block matches

}
}
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/ldtteam/structurize/util/BlockUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,7 @@ else if (item instanceof BlockItem)
// place
world.setBlock(here, Blocks.COBBLESTONE.defaultBlockState(), Block.UPDATE_CLIENTS);
world.setBlock(here, newState, Constants.UPDATE_FLAG);
world.getBlockEntity(here).applyComponentsFromItemStack(stackToPlace);
targetBlock.setPlacedBy(world, here, newState, fakePlayer, stackToPlace);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this entire branch should honestly use just the Item#useOn(...), wonder if it is even safe these days to perform blockentity-ignore blockstate update, w/e for now

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not so easy to even use-on without messy blockstates =D

}
else if (item instanceof BucketItem)
Expand Down