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

溜槽更改 #126

Merged
merged 2 commits into from
Apr 1, 2024
Merged
Changes from 1 commit
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 @@ -22,6 +22,7 @@
import net.minecraft.world.level.block.entity.HopperBlockEntity;
import net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.Vec3;
import org.jetbrains.annotations.NotNull;

Expand Down Expand Up @@ -112,12 +113,18 @@ protected boolean insertOrDropItem(Direction direction, Level level, @NotNull Bl
if (HopperBlockEntity.getContainerAt(level, curPos) != null) return false;
if (ItemStorage.SIDED.find(level, curPos, direction.getOpposite()) != null) return false;
}
if (!needEmpty || level.isEmptyBlock(curPos)) {
if (!needEmpty || this.canDropItem(level, curPos)) {
flag = this.dropItem(direction, level, pos, container, slot, momentum);
}
return flag;
}

private boolean canDropItem(@NotNull Level level, @NotNull BlockPos pos) {
Vec3 vec3 = pos.getCenter();
ItemEntity entity = new ItemEntity(level, vec3.x, vec3.y, vec3.z, ItemStack.EMPTY);
return level.noCollision(entity);
}

@SuppressWarnings("UnstableApiUsage")
private boolean insertItem(Direction direction, Level level, @NotNull BlockPos pos, @NotNull Container container, int slot) {
ItemStack item = container.getItem(slot);
Expand Down
Loading