Mercerenies / a-turtles-troll

Random Minecraft shenanigans
GNU General Public License v3.0
4 stars 2 forks source link

mimic chests should be random between chest types #145

Closed EvanSkiStudios closed 11 months ago

EvanSkiStudios commented 11 months ago

I changed the textures, it would be cool if the fake chests where randomized so like

a chance to be a double chest

a 50/50 to be a trapped or normal chest

then my resourcepack will texture them appropriately

good luck figuring out the correct double chest spawning generation code

EvanSkiStudios commented 11 months ago

I've actually gone ahead and made some pysudo code you can use

Inventory mimicInventory = Bukkit.createInventory(new mimicOwner(), InventoryType.CHEST, "Mimic");
// Inventories have 4 special things, a title, a type, a owner, and the inventory contents
// a owner is special as it can be used to define what inventory this is, so you could make a static owner of mimic and then check if // the inventory the player is viewing is owned by "mimic"

// Here is how I check this for the show craft command
//prevents player from taking items as well as custom actions
    @EventHandler
    public void onMenu(InventoryClickEvent event) {
        if (event.isCancelled()) return;

        Inventory Active_Inventory = event.getClickedInventory();

        if ((Active_Inventory == null) || (Active_Inventory.getHolder() == null) || !(Active_Inventory.getHolder() instanceof GUIHolder)) {
            return;
        }

        event.setCancelled(true);
    }

and this is my "GUI Holders" utility

enum Holders{
    GUIHOLDER
}

@SuppressWarnings("All") //STFU
public class GUIHolder implements InventoryHolder {

    Holders holder;

    public GUIHolder() {
        this.holder = Holders.GUIHOLDER;
    }

    @Override
    public Inventory getInventory() {
        return null;
    }

    public Holders getPlayer() {
        return holder;
    }
}

Currently how you check if a chest is a mimic is by the inventory, but by using a owner, the inventory can be anything, even "fake" items, or a mirror of a real chest someone has

Of course you can see how this can lead to mimics being more hidden and more of an annoyance >:)