Fix Hanging Pale Moss not dropping with modded shears (#10414)

This commit is contained in:
cech12 authored and GitHub committed 2025-02-17 18:06:56 -08:00
1 parent 6ae39c8597
commit c97eabc0c4
4 files changed
+204 -3

No files matched your search

@@ -130,11 +130,11 @@ public final class ForgeLootTableProvider extends LootTableProvider {
} else if (invLootCondition instanceof CompositeLootItemCondition compositeLootItemCondition && findAndReplaceInComposite(compositeLootItemCondition, from, toolAction)) {
found = true;
}
} else if (lootCondition instanceof CompositeLootItemCondition compositeLootItemCondition && findAndReplaceInComposite(compositeLootItemCondition, from, toolAction)) {
found = true;
}
}
return found;
}
@@ -16,6 +16,11 @@ import net.minecraft.resources.ResourceKey;
import net.minecraft.ChatFormatting;
import net.minecraft.Util;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.AABB;
import org.jetbrains.annotations.Nullable;
import com.mojang.authlib.GameProfile;
@@ -119,6 +124,10 @@ public interface IForgeGameTestHelper {
}
default ServerPlayer makeMockServerPlayer() {
return makeMockServerPlayer(true);
}
default ServerPlayer makeMockServerPlayer(boolean creative) {
var level = self().getLevel();
var cookie = CommonListenerCookie.createInitial(new GameProfile(UUID.randomUUID(), "test-mock-player"), false);
var player = new ServerPlayer(level.getServer(), level, cookie.gameProfile(), cookie.clientInformation()) {
@@ -127,7 +136,7 @@ public interface IForgeGameTestHelper {
}
public boolean isCreative() {
return true;
return creative;
}
};
var connection = new Connection(PacketFlow.SERVERBOUND);
@@ -186,6 +195,32 @@ public interface IForgeGameTestHelper {
}
}
default void setAndAssertBlock(int x, int y, int z, Block block) {
this.setAndAssertBlock(x, y, z, block.defaultBlockState());
}
default void setAndAssertBlock(int x, int y, int z, BlockState state) {
this.setAndAssertBlock(new BlockPos(x, y, z), state);
}
default void setAndAssertBlock(BlockPos pos, Block block) {
this.setAndAssertBlock(pos, block.defaultBlockState());
}
default void setAndAssertBlock(BlockPos pos, BlockState state) {
this.assertTrue(
this.self().getLevel().setBlock(this.self().absolutePos(pos), state, Block.UPDATE_ALL),
() -> "Failed to set block at pos %s : %s".formatted(pos, state.getBlock())
);
}
default void removeAllItemEntitiesInRange(BlockPos pos, double range) {
BlockPos blockpos = this.self().absolutePos(pos);
for (ItemEntity itemEntity : this.self().getLevel().getEntities(EntityType.ITEM, new AABB(blockpos).inflate(range), Entity::isAlive)) {
itemEntity.remove(Entity.RemovalReason.DISCARDED);
}
}
default <T> Flag<T> flag(String name) {
return new Flag<>(name);
}