Skip to content
This repository was archived by the owner on Jun 3, 2024. It is now read-only.

Commit 8c4015d

Browse files
committed
Begin patchwork-loot
1 parent f583ac8 commit 8c4015d

8 files changed

Lines changed: 122 additions & 0 deletions

File tree

patchwork-loot/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
archivesBaseName = "patchwork-loot"
2+
version = getSubprojectVersion(project, "0.1.0")
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package net.patchworkmc.mixin.loot;
2+
3+
import org.spongepowered.asm.mixin.Mixin;
4+
import org.spongepowered.asm.mixin.injection.At;
5+
import org.spongepowered.asm.mixin.injection.Inject;
6+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
7+
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
8+
9+
import net.minecraft.advancement.AdvancementRewards;
10+
import net.minecraft.server.network.ServerPlayerEntity;
11+
12+
@Mixin(AdvancementRewards.class)
13+
public class MixinAdvancementRewards {
14+
private static final String LOOT_CONTEXT_BUILD_TARGET =
15+
"net/minecraft/world/loot/context/LootContext$Builder.build(Lnet/minecraft/world/loot/context/LootContextType;)Lnet/minecraft/world/loot/context/LootContext;";
16+
17+
@Inject(method = "apply(Lnet/minecraft/server/network/ServerPlayerEntity;)V", at = @At(value = "INVOKE", target = LOOT_CONTEXT_BUILD_TARGET), locals = LocalCapture.CAPTURE_FAILHARD)
18+
private void patchwork_addLuckToLootContext(ServerPlayerEntity player, CallbackInfo callback) {
19+
20+
}
21+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package net.patchworkmc.mixin.loot;
2+
3+
import org.spongepowered.asm.mixin.Mixin;
4+
import org.spongepowered.asm.mixin.Shadow;
5+
import org.spongepowered.asm.mixin.injection.At;
6+
import org.spongepowered.asm.mixin.injection.Inject;
7+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
8+
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
9+
10+
import net.minecraft.entity.Entity;
11+
import net.minecraft.entity.player.PlayerEntity;
12+
import net.minecraft.entity.projectile.FishingBobberEntity;
13+
import net.minecraft.item.ItemStack;
14+
import net.minecraft.world.loot.LootSupplier;
15+
import net.minecraft.world.loot.context.LootContext;
16+
import net.minecraft.world.loot.context.LootContextParameters;
17+
18+
@Mixin(FishingBobberEntity.class)
19+
public class MixinFishingBobberEntity {
20+
private static final String LOOT_CONTEXT_BUILD_TARGET =
21+
"net/minecraft/world/loot/context/LootContext$Builder.build(Lnet/minecraft/world/loot/context/LootContextType;)Lnet/minecraft/world/loot/context/LootContext;";
22+
23+
@Shadow
24+
private final PlayerEntity owner = null;
25+
26+
@Inject(method = "method_6957(Lnet/minecraft/item/ItemStack;)I", at = @At(value = "INVOKE", target = LOOT_CONTEXT_BUILD_TARGET), locals = LocalCapture.CAPTURE_FAILHARD)
27+
private void patchwork_addFishingParameters(ItemStack stack, CallbackInfoReturnable<Integer> callback, int rodDamage, LootContext.Builder builder, LootSupplier supplier) {
28+
builder.put(LootContextParameters.KILLER_ENTITY, this.owner);
29+
builder.put(LootContextParameters.THIS_ENTITY, (Entity) (Object) this);
30+
}
31+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package net.patchworkmc.mixin.loot;
2+
3+
import org.spongepowered.asm.mixin.Mixin;
4+
import org.spongepowered.asm.mixin.injection.At;
5+
import org.spongepowered.asm.mixin.injection.Inject;
6+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
7+
8+
import net.minecraft.world.loot.context.LootContextParameters;
9+
import net.minecraft.world.loot.context.LootContextType;
10+
import net.minecraft.world.loot.context.LootContextTypes;
11+
12+
@Mixin(LootContextTypes.class)
13+
public class MixinLootContextTypes {
14+
@Inject(method = "method_15970(Lnet/minecraft/world/loot/context/LootContextType$Builder;)V", at = @At("RETURN"))
15+
private static void patchwork_addChestParameters(LootContextType.Builder builder, CallbackInfo callback) {
16+
// Chest minecarts can have killers.
17+
builder.allow(LootContextParameters.KILLER_ENTITY);
18+
}
19+
20+
@Inject(method = "method_764(Lnet/minecraft/world/loot/context/LootContextType$Builder;)V", at = @At("RETURN"))
21+
private static void patchwork_addFishingParameters(LootContextType.Builder builder, CallbackInfo callback) {
22+
// Entity that is using the fishing rod
23+
builder.allow(LootContextParameters.KILLER_ENTITY);
24+
25+
// Fishing bobber entity
26+
builder.allow(LootContextParameters.THIS_ENTITY);
27+
}
28+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"schemaVersion": 1,
3+
"id": "patchwork-loot",
4+
"name": "Patchwork Loot",
5+
"version": "${version}",
6+
"license": "LGPL-2.1-only",
7+
"icon": "assets/patchwork-loot/icon.png",
8+
"contact": {
9+
"issues": "https://github.com/PatchworkMC/patchwork-api/issues",
10+
"sources": "https://github.com/PatchworkMC/patchwork-api"
11+
},
12+
"authors": [
13+
"PatchworkMC"
14+
],
15+
"depends": {
16+
"fabricloader": ">=0.6.2"
17+
},
18+
"mixins": [
19+
"patchwork-loot.mixins.json"
20+
],
21+
"description": "Implementation of the Forge's additions to loot tables.",
22+
"custom": {
23+
"modmenu:api": true,
24+
"modmenu:parent": "patchwork"
25+
}
26+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"required": true,
3+
"package": "net.patchworkmc.mixin.loot",
4+
"compatibilityLevel": "JAVA_8",
5+
"mixins": [
6+
"MixinAdvancementRewards",
7+
"MixinFishingBobberEntity",
8+
"MixinLootContextTypes"
9+
],
10+
"injectors": {
11+
"defaultRequire": 1
12+
}
13+
}
22.2 KB
Loading

settings.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ include 'patchwork-extensions-shearing'
2323
include 'patchwork-extensions'
2424
include 'patchwork-extensions-item'
2525
include 'patchwork-fml'
26+
include 'patchwork-loot'
2627
include 'patchwork-registries'
2728
include 'patchwork-gui'
2829
include 'patchwork-networking'

0 commit comments

Comments
 (0)