|
| 1 | +/* |
| 2 | + * Minecraft Forge, Patchwork Project |
| 3 | + * Copyright (c) 2016-2020, 2019-2020 |
| 4 | + * |
| 5 | + * This library is free software; you can redistribute it and/or |
| 6 | + * modify it under the terms of the GNU Lesser General Public |
| 7 | + * License as published by the Free Software Foundation version 2.1 |
| 8 | + * of the License. |
| 9 | + * |
| 10 | + * This library is distributed in the hope that it will be useful, |
| 11 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | + * Lesser General Public License for more details. |
| 14 | + * |
| 15 | + * You should have received a copy of the GNU Lesser General Public |
| 16 | + * License along with this library; if not, write to the Free Software |
| 17 | + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 18 | + */ |
| 19 | + |
| 20 | +package com.patchworkmc.mixin.loot; |
| 21 | + |
| 22 | +import org.spongepowered.asm.mixin.Mixin; |
| 23 | +import org.spongepowered.asm.mixin.Shadow; |
| 24 | +import org.spongepowered.asm.mixin.injection.At; |
| 25 | +import org.spongepowered.asm.mixin.injection.Inject; |
| 26 | +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; |
| 27 | +import org.spongepowered.asm.mixin.injection.callback.LocalCapture; |
| 28 | + |
| 29 | +import net.minecraft.entity.Entity; |
| 30 | +import net.minecraft.entity.player.PlayerEntity; |
| 31 | +import net.minecraft.entity.projectile.FishingBobberEntity; |
| 32 | +import net.minecraft.item.ItemStack; |
| 33 | +import net.minecraft.world.loot.LootSupplier; |
| 34 | +import net.minecraft.world.loot.context.LootContext; |
| 35 | +import net.minecraft.world.loot.context.LootContextParameters; |
| 36 | + |
| 37 | +@Mixin(FishingBobberEntity.class) |
| 38 | +public class MixinFishingBobberEntity { |
| 39 | + private static final String LOOT_CONTEXT_BUILD_TARGET = |
| 40 | + "net/minecraft/world/loot/context/LootContext$Builder.build(Lnet/minecraft/world/loot/context/LootContextType;)Lnet/minecraft/world/loot/context/LootContext;"; |
| 41 | + |
| 42 | + @Shadow |
| 43 | + private final PlayerEntity owner = null; |
| 44 | + |
| 45 | + @Inject(method = "method_6957(Lnet/minecraft/item/ItemStack;)I", at = @At(value = "INVOKE", target = LOOT_CONTEXT_BUILD_TARGET), locals = LocalCapture.CAPTURE_FAILHARD) |
| 46 | + private void patchwork_addFishingParameters(ItemStack stack, CallbackInfoReturnable<Integer> callback, int rodDamage, LootContext.Builder builder, LootSupplier supplier) { |
| 47 | + builder.put(LootContextParameters.KILLER_ENTITY, this.owner); |
| 48 | + builder.put(LootContextParameters.THIS_ENTITY, (Entity) (Object) this); |
| 49 | + } |
| 50 | +} |
0 commit comments