aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me/Danker/features/BlockAbilities.java
blob: 814fd6523564fb162209b07ea6bc21ef527464e4 (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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
package me.Danker.features;

import me.Danker.commands.ToggleCommand;
import me.Danker.utils.Utils;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

import java.util.ArrayList;
import java.util.Arrays;

public class BlockAbilities {

    @SubscribeEvent
    public void onInteract(PlayerInteractEvent event) {
        if (!Utils.inSkyblock || Minecraft.getMinecraft().thePlayer != event.entityPlayer) return;
        ItemStack item = event.entityPlayer.getHeldItem();
        if (item == null) return;

        if (event.action == PlayerInteractEvent.Action.RIGHT_CLICK_AIR) {
            if (ToggleCommand.aotdToggled && item.getDisplayName().contains("Aspect of the Dragons")) {
                event.setCanceled(true);
            }
            if (ToggleCommand.lividDaggerToggled && item.getDisplayName().contains("Livid Dagger")) {
                event.setCanceled(true);
            }
            if (ToggleCommand.shadowFuryToggled && item.getDisplayName().contains("Shadow Fury")) {
                event.setCanceled(true);
            }
            if (ToggleCommand.specialHoeRightClick && (item.getDisplayName().contains("Mathematical Hoe") || item.getDisplayName().contains("Potato Hoe") || item.getDisplayName().contains("Wheat Hoe") || item.getDisplayName().contains("Carrot Hoe") || item.getDisplayName().contains("Sugar Cane Hoe") || item.getDisplayName().contains("Nether Warts Hoe"))) {
                event.setCanceled(true);
            }
        } else if (event.action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) {
            Block block = Minecraft.getMinecraft().theWorld.getBlockState(event.pos).getBlock();

            ArrayList<Block> interactables = new ArrayList<>(Arrays.asList(
                    Blocks.acacia_door,
                    Blocks.anvil,
                    Blocks.beacon,
                    Blocks.bed,
                    Blocks.birch_door,
                    Blocks.brewing_stand,
                    Blocks.command_block,
                    Blocks.crafting_table,
                    Blocks.chest,
                    Blocks.dark_oak_door,
                    Blocks.daylight_detector,
                    Blocks.daylight_detector_inverted,
                    Blocks.dispenser,
                    Blocks.dropper,
                    Blocks.enchanting_table,
                    Blocks.ender_chest,
                    Blocks.furnace,
                    Blocks.hopper,
                    Blocks.jungle_door,
                    Blocks.lever,
                    Blocks.noteblock,
                    Blocks.powered_comparator,
                    Blocks.unpowered_comparator,
                    Blocks.powered_repeater,
                    Blocks.unpowered_repeater,
                    Blocks.standing_sign,
                    Blocks.wall_sign,
                    Blocks.trapdoor,
                    Blocks.trapped_chest,
                    Blocks.wooden_button,
                    Blocks.stone_button,
                    Blocks.oak_door,
                    Blocks.skull
            ));
            if (Utils.inDungeons) {
                interactables.add(Blocks.coal_block);
                interactables.add(Blocks.stained_hardened_clay);
            }

            if (!interactables.contains(block)) {
                if (ToggleCommand.aotdToggled && item.getDisplayName().contains("Aspect of the Dragons")) {
                    event.setCanceled(true);
                }
                if (ToggleCommand.lividDaggerToggled && item.getDisplayName().contains("Livid Dagger")) {
                    event.setCanceled(true);
                }
                if (ToggleCommand.shadowFuryToggled && item.getDisplayName().contains("Shadow Fury")) {
                    event.setCanceled(true);
                }
            }
            if (ToggleCommand.specialHoeRightClick && (item.getDisplayName().contains("Mathematical Hoe") || item.getDisplayName().contains("Potato Hoe") || item.getDisplayName().contains("Wheat Hoe") || item.getDisplayName().contains("Carrot Hoe") || item.getDisplayName().contains("Sugar Cane Hoe") || item.getDisplayName().contains("Nether Warts Hoe"))) {
                event.setCanceled(true);
            }
        }
    }

}