Skip to content

Commit

Permalink
Merge pull request #330 from P3pp3rF1y/1.20.x-dev
Browse files Browse the repository at this point in the history
feat: ✨ Add logic to fill backpack that was dropped by mobs with loot…
  • Loading branch information
P3pp3rF1y authored Nov 22, 2024
2 parents 63f9dfb + ac260ba commit f414c36
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ org.gradle.daemon=false

mod_id=sophisticatedcore
mod_group_id=sophisticatedcore
mod_version=0.7.7
mod_version=0.7.8
sonar_project_key=sophisticatedcore:SophisticatedCore
github_package_url=https://maven.pkg.github.com/P3pp3rF1y/SophisticatedCore

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package net.p3pp3rf1y.sophisticatedcore.util;

import net.minecraft.core.BlockPos;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.RandomSource;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.world.level.storage.loot.LootParams;
Expand All @@ -21,9 +21,9 @@
public class LootHelper {
private LootHelper() {}

public static List<ItemStack> getLoot(ResourceLocation lootTableName, MinecraftServer server, ServerLevel level, Entity entity) {
public static List<ItemStack> getLoot(ResourceLocation lootTableName, MinecraftServer server, ServerLevel level, BlockPos pos) {
LootTable lootTable = server.getLootData().getLootTable(lootTableName);
LootContext.Builder lootBuilder = new LootContext.Builder((new LootParams.Builder(level)).withParameter(LootContextParams.ORIGIN, Vec3.atCenterOf(entity.blockPosition())).create(LootContextParamSets.CHEST)).withOptionalRandomSeed(level.random.nextLong());
LootContext.Builder lootBuilder = new LootContext.Builder((new LootParams.Builder(level)).withParameter(LootContextParams.ORIGIN, Vec3.atCenterOf(pos)).create(LootContextParamSets.CHEST)).withOptionalRandomSeed(level.random.nextLong());
List<ItemStack> lootStacks = new ArrayList<>();
lootTable.getRandomItemsRaw(lootBuilder.create(null), lootStacks::add);
return lootStacks;
Expand Down

0 comments on commit f414c36

Please sign in to comment.