Skip to content

Commit

Permalink
Merge branch '1.21.2' into 1.21.4
Browse files Browse the repository at this point in the history
  • Loading branch information
AViewFromTheTop committed Jan 21, 2025
2 parents aff3869 + f3b75f0 commit 63f1dc7
Show file tree
Hide file tree
Showing 9 changed files with 614 additions and 3 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ Put changelog here:

-----------------
- Exposed the `structure_upgrade` command to players outside development environments.
- Removed the Camera item in favor of the `panorama` command.
- Removed the Camera item in favor of the new `panorama` client command.
- Added the new loot pool modification api, by Kluski42!
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
min_loader_version=0.16.9

# Mod Properties
mod_version = 1.9.12
mod_version = 1.9.13
maven_group = net.frozenblock
archives_base_name = FrozenLib

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ public static void register(@NotNull CommandDispatcher<FabricClientCommandSource
ClientCommandManager.literal("panorama")
.executes(
context -> {
FrozenSharedConstants.LOGGER.warn("PLAYER HAS ACCESS TO DEV CAMERA AND HAS JUST USED IT");
Minecraft client = Minecraft.getInstance();
File directory = getPanoramaFolderName(new File(client.gameDirectory, "panoramas"));
File directory1 = new File(directory, "screenshots");
Expand Down
47 changes: 47 additions & 0 deletions src/main/java/net/frozenblock/lib/loot/LootTableModifier.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright (C) 2025 FrozenBlock
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package net.frozenblock.lib.loot;

import net.fabricmc.fabric.api.loot.v3.LootTableEvents;
import net.minecraft.resources.ResourceKey;
import net.minecraft.world.level.storage.loot.LootTable;

public class LootTableModifier {

public static void editTable(ResourceKey<LootTable> targetLootTable, boolean requiresBuiltIn, Edit listener) {
LootTableEvents.Replace modification = (id, lootTable, source, registries) -> {
if ((requiresBuiltIn && !source.isBuiltin()) || !targetLootTable.equals(id)) return null;
MutableLootTable mutableLootTable = new MutableLootTable(lootTable);
listener.editLootTable(id, mutableLootTable);
return mutableLootTable.build();
};

LootTableEvents.REPLACE.register(modification);
}

@FunctionalInterface
public interface Edit {
/**
* Edits loot tables.
*
* @param id The loot table key.
* @param mutableLootTable The mutable copy of the loot table.
*/
void editLootTable(ResourceKey<LootTable> id, MutableLootTable mutableLootTable);
}
}
95 changes: 95 additions & 0 deletions src/main/java/net/frozenblock/lib/loot/MutableLootItem.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
/*
* Copyright (C) 2025 FrozenBlock
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package net.frozenblock.lib.loot;

import java.util.List;
import net.minecraft.core.Holder;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.ItemLike;
import net.minecraft.world.level.storage.loot.entries.LootItem;
import net.minecraft.world.level.storage.loot.functions.LootItemFunction;
import net.minecraft.world.level.storage.loot.predicates.LootItemCondition;
import org.jetbrains.annotations.NotNull;

public class MutableLootItem {
public final List<LootItemCondition> conditions;
public int weight;
public int quality;
public final List<LootItemFunction> functions;
public Holder<Item> item;

public MutableLootItem(LootItem original) {
this.conditions = original.conditions;
this.weight = original.weight;
this.quality = original.quality;
this.functions = original.functions;
this.item = original.item;
}

public MutableLootItem(Holder<Item> item, int weight, int quality, List<LootItemCondition> conditions, List<LootItemFunction> functions) {
this.item = item;
this.conditions = conditions;
this.weight = weight;
this.quality = quality;
this.functions = functions;
}

public MutableLootItem(@NotNull ItemLike item, int weight, int quality, List<LootItemCondition> conditions, List<LootItemFunction> functions) {
this.item = item.asItem().builtInRegistryHolder();
this.conditions = conditions;
this.weight = weight;
this.quality = quality;
this.functions = functions;
}

public LootItem build() {
return new LootItem(item, weight, quality, conditions, functions);
}

public int getWeight() {
return weight;
}

public void setWeight(int weight) {
this.weight = weight;
}

public int getQuality() {
return quality;
}

public void setQuality(int quality) {
this.quality = quality;
}

public Holder<Item> getItemHolder() {
return item;
}

public Item getItem() {
return item.value();
}

public void setItem(Holder<Item> item) {
this.item = item;
}

public void setItem(@NotNull ItemLike item) {
this.item = item.asItem().builtInRegistryHolder();
}
}
Loading

0 comments on commit 63f1dc7

Please sign in to comment.