aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me/Danker/features/puzzlesolvers/ArrowTerminalSolver.java
blob: 35458f3967965bcda7ddfb5db773b600b2f389bc (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
30
31
32
package me.Danker.features.puzzlesolvers;

import me.Danker.commands.ToggleCommand;
import me.Danker.utils.Utils;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.item.EntityItemFrame;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraftforge.event.entity.player.EntityInteractEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

public class ArrowTerminalSolver {

    @SubscribeEvent
    public void onEntityInteract(EntityInteractEvent event) {
        Minecraft mc = Minecraft.getMinecraft();
        if (mc.thePlayer != event.entityPlayer) return;

        if (ToggleCommand.itemFrameOnSeaLanternsToggled && Utils.inDungeons && event.target instanceof EntityItemFrame) {
            EntityItemFrame itemFrame = (EntityItemFrame) event.target;
            ItemStack item = itemFrame.getDisplayedItem();
            if (item == null || item.getItem() != Items.arrow) return;
            BlockPos blockPos = Utils.getBlockUnderItemFrame(itemFrame);
            if (mc.theWorld.getBlockState(blockPos).getBlock() == Blocks.sea_lantern) {
                event.setCanceled(true);
            }
        }
    }

}