summaryrefslogtreecommitdiff
path: root/src/main/java/com/keuin/ohmyvanillamc/mixins/rule/reintroduceLlamaItemDuping/PlayerManagerMixin.java
blob: d3c87d80785a44052adac2abf0a6cf186d090256 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package com.keuin.ohmyvanillamc.mixins.rule.reintroduceLlamaItemDuping;

import com.keuin.ohmyvanillamc.OmvmSettings;
import net.minecraft.entity.Entity;
import net.minecraft.server.PlayerManager;
import org.objectweb.asm.Opcodes;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;

/**
 * Reintroduce MC-161754 glitch
 */
@Mixin(PlayerManager.class)
public abstract class PlayerManagerMixin {
    @Redirect(
            method = "remove",
            at = @At(
                    value = "FIELD",
                    opcode = Opcodes.PUTFIELD,
                    target = "Lnet/minecraft/entity/Entity;removed:Z"
            ),
            require = 2
    )
    private void Entity_setRemoved(Entity entity, boolean value) {
//        OmvmExtension.LOGGER.info("set entity remove!");
        entity.removed = !OmvmSettings.reintroduceLlamaItemDuplicating || entity.removed;
    }
}