-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathItemFrameMixin.java
More file actions
31 lines (27 loc) · 1.27 KB
/
ItemFrameMixin.java
File metadata and controls
31 lines (27 loc) · 1.27 KB
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
30
31
package westeroscraft.mixin;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.decoration.ItemFrame;
import net.minecraft.world.entity.player.Player;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import westeroscraft.config.WesterosCraftConfig;
@Mixin(ItemFrame.class)
public abstract class ItemFrameMixin {
protected ItemFrameMixin() {}
@Inject(method = "interact", at = @At("HEAD"), cancellable=true)
private void doInteract(Player player, InteractionHand hand, CallbackInfoReturnable<InteractionResult> ci) {
if ((!player.isCreative()) && WesterosCraftConfig.blockHangingItemChanges) {
ci.setReturnValue(InteractionResult.CONSUME);
}
}
@Inject(method = "hurt", at = @At("HEAD"), cancellable=true)
private void doHurt(DamageSource src, float damage, CallbackInfoReturnable<Boolean> ci) {
if ((!src.isCreativePlayer()) && WesterosCraftConfig.blockHangingItemChanges) {
ci.setReturnValue(Boolean.FALSE);
}
}
}