aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me/Danker/features/BlockPlacingFlowers.java
blob: 9bfc986946385981b39b62aad30fd343603ecb93 (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
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 BlockPlacingFlowers {

    @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_BLOCK) {
            Block block = Minecraft.getMinecraft().theWorld.getBlockState(event.pos).getBlock();

            ArrayList<Block> flowerPlaceable = new ArrayList<>(Arrays.asList(
                    Blocks.grass,
                    Blocks.dirt,
                    Blocks.flower_pot,
                    Blocks.tallgrass,
                    Blocks.double_plant
            ));
            if (flowerPlaceable.contains(block)) {
                if (ToggleCommand.flowerWeaponsToggled && item.getDisplayName().contains("Flower of Truth")) {
                    event.setCanceled(true);
                }
                if (ToggleCommand.flowerWeaponsToggled && item.getDisplayName().contains("Spirit Sceptre")) {
                    event.setCanceled(true);
                }
            }
        }
    }

}