Search in sources :

Example 1 with AbstractHorse

use of net.minecraft.entity.passive.AbstractHorse in project SpongeCommon by SpongePowered.

the class InventoryArchetypeRegistryModule method registerDefaults.

@Override
public void registerDefaults() {
    InventoryArchetype SLOT = new SlotArchetype(ImmutableMap.of(CustomInventory.INVENTORY_DIMENSION, new InventoryDimension(1, 1)));
    InventoryArchetype MENU_ROW;
    InventoryArchetype MENU_COLUMN;
    InventoryArchetype MENU_GRID;
    InventoryArchetype CHEST;
    InventoryArchetype DOUBLE_CHEST;
    InventoryArchetype FURNACE;
    InventoryArchetype DISPENSER;
    InventoryArchetype WORKBENCH;
    InventoryArchetype BREWING_STAND;
    InventoryArchetype HOPPER;
    InventoryArchetype BEACON;
    InventoryArchetype ANVIL;
    InventoryArchetype ENCHANTING_TABLE;
    InventoryArchetype VILLAGER;
    InventoryArchetype HORSE;
    InventoryArchetype HORSE_WITH_CHEST;
    InventoryArchetype PLAYER;
    InventoryArchetype CRAFTING;
    InventoryArchetype UNKNOWN;
    final SpongeInventoryArchetypeBuilder builder = new SpongeInventoryArchetypeBuilder();
    for (int i = 0; i < 9; i++) {
        builder.with(new SpongeInventoryArchetypeBuilder().from(SLOT).property(SlotIndex.of(i)).build("minecraft:slot" + i, "Slot"));
    }
    MENU_ROW = builder.property(new InventoryDimension(9, 1)).build("sponge:menu_row", "Menu Row");
    MENU_COLUMN = builder.property(new InventoryDimension(9, 1)).build("sponge:menu_column", "Menu Column");
    MENU_GRID = builder.reset().with(MENU_ROW).with(MENU_ROW).with(MENU_ROW).property(new InventoryDimension(9, 3)).build("sponge:menu_grid", "Menu Grid");
    CHEST = builder.reset().with(MENU_GRID).property(InventoryTitle.of(Text.of(new SpongeTranslation("container.chest")))).property(new GuiIdProperty(GuiIds.CHEST)).container((i, p) -> new ContainerChest(p.inventory, i, p)).build("minecraft:chest", "Chest");
    DOUBLE_CHEST = builder.reset().with(CHEST).property(new InventoryDimension(9, 6)).property(InventoryTitle.of(Text.of(new SpongeTranslation("container.chestDouble")))).property(new GuiIdProperty(GuiIds.CHEST)).container((i, p) -> new ContainerChest(p.inventory, i, p)).build("minecraft:double_chest", "DoubleChest");
    FURNACE = builder.reset().with(new SpongeInventoryArchetypeBuilder().from(SLOT).property(new SlotIndex(0)).build("minecraft:furnace_input", "FurnaceInput")).with(new SpongeInventoryArchetypeBuilder().from(SLOT).property(new SlotIndex(1)).property(AcceptsItems.of()).build("minecraft:furnace_fuel", "FurnaceFuel")).with(new SpongeInventoryArchetypeBuilder().from(SLOT).property(new SlotIndex(2)).property(AcceptsItems.of()).build("minecraft:furnace_output", "FurnaceOutput")).property(new InventoryTitle(Text.of(new SpongeTranslation("container.furnace")))).property(new InventoryDimension(3, 1)).property(new GuiIdProperty(GuiIds.FURNACE)).container((i, p) -> new ContainerFurnace(p.inventory, i)).build("minecraft:furnace", "Furnace");
    DISPENSER = builder.reset().with(MENU_GRID).property(new InventoryDimension(3, 3)).property(InventoryTitle.of(Text.of(new SpongeTranslation("container.dispenser")))).property(new GuiIdProperty(GuiIds.DISPENSER)).container((i, p) -> new ContainerDispenser(p.inventory, i)).build("minecraft:dispenser", "Dispenser");
    WORKBENCH = builder.reset().with(new SpongeInventoryArchetypeBuilder().from(MENU_GRID).property(new InventoryDimension(3, 3)).build("minecraft:workbench_grid", "Workbench Grid")).with(SLOT).property(InventoryTitle.of(Text.of(new SpongeTranslation("container.crafting")))).property(new GuiIdProperty(GuiIds.CRAFTING_TABLE)).container((i, p) -> {
        ContainerWorkbench container = new ContainerWorkbench(p.inventory, p.getEntityWorld(), p.getPosition());
        // Pre-Fills the container input with the items from the inventory
        for (int index = 0; index < container.craftMatrix.getSizeInventory(); index++) {
            container.craftMatrix.setInventorySlotContents(index, i.getStackInSlot(index));
        }
        return container;
    }).build("minecraft:workbench", "Workbench");
    BREWING_STAND = builder.reset().with(MENU_ROW).property(new InventoryDimension(5, 1)).property(InventoryTitle.of(Text.of(new SpongeTranslation("container.brewing")))).property(new GuiIdProperty(GuiIds.BREWING_STAND)).container((i, p) -> new ContainerBrewingStand(p.inventory, i)).build("minecraft:brewing_stand", "BrewingStand");
    HOPPER = builder.reset().with(MENU_ROW).property(new InventoryDimension(5, 1)).property(InventoryTitle.of(Text.of(new SpongeTranslation("container.hopper")))).property(new GuiIdProperty(GuiIds.HOPPER)).container((i, p) -> new ContainerHopper(p.inventory, i, p)).build("minecraft:hopper", "Hopper");
    BEACON = builder.reset().with(SLOT).property(new InventoryDimension(1, 1)).property(InventoryTitle.of(Text.of(new SpongeTranslation("container.beacon")))).property(new GuiIdProperty(GuiIds.BEACON)).container((i, p) -> new ContainerBeacon(p.inventory, i)).build("minecraft:beacon", "Beacon");
    ENCHANTING_TABLE = builder.reset().with(SLOT).with(SLOT).property(new InventoryDimension(2, 1)).property(InventoryTitle.of(Text.of(new SpongeTranslation("container.enchant")))).property(new GuiIdProperty(GuiIds.ENCHANTING_TABLE)).container((i, p) -> {
        ContainerEnchantment container = new ContainerEnchantment(p.inventory, p.getEntityWorld(), p.getPosition());
        // Pre-Fills the container with the items from the inventory
        for (int index = 0; index < container.tableInventory.getSizeInventory(); index++) {
            container.tableInventory.setInventorySlotContents(index, i.getStackInSlot(index));
        }
        return container;
    }).build("minecraft:enchanting_table", "EnchantingTable");
    ANVIL = builder.reset().with(SLOT).with(SLOT).with(SLOT).property(new InventoryDimension(3, 1)).property(InventoryTitle.of(Text.of(new SpongeTranslation("container.repair")))).property(new GuiIdProperty(GuiIds.ANVIL)).container((i, p) -> {
        ContainerRepair container = new ContainerRepair(p.inventory, p.getEntityWorld(), p.getPosition(), p);
        // Pre-Fills the container input with the items from the inventory
        for (int index = 0; index < container.inputSlots.getSizeInventory(); index++) {
            container.inputSlots.setInventorySlotContents(index, i.getStackInSlot(index));
        }
        return container;
    }).build("minecraft:anvil", "Anvil");
    VILLAGER = builder.reset().with(SLOT).with(SLOT).with(SLOT).property(new InventoryDimension(3, 1)).property(new GuiIdProperty(GuiIds.VILLAGER)).container((i, p) -> {
        if (i instanceof CarriedInventory && ((CarriedInventory) i).getCarrier().isPresent() && ((CarriedInventory) i).getCarrier().get() instanceof IMerchant) {
            IMerchant merchant = ((IMerchant) ((CarriedInventory) i).getCarrier().get());
            ContainerMerchant container = new ContainerMerchant(p.inventory, merchant, p.getEntityWorld());
            // TODO Pre-Fill the Container?
            return container;
        }
        throw new IllegalArgumentException("Cannot open merchant inventory without a merchant as Carrier");
    }).build("minecraft:villager", "Villager");
    HORSE = builder.reset().with(SLOT).with(SLOT).property(new InventoryDimension(2, 1)).property(// hardcoded openGuiHorseInventory
    new GuiIdProperty(GuiIds.HORSE)).container((i, p) -> {
        if (i instanceof CarriedInventory && ((CarriedInventory) i).getCarrier().isPresent() && ((CarriedInventory) i).getCarrier().get() instanceof AbstractHorse) {
            AbstractHorse horse = ((AbstractHorse) ((CarriedInventory) i).getCarrier().get());
            return new ContainerHorseInventory(p.inventory, i, horse, p);
        }
        throw new IllegalArgumentException("Cannot open horse inventory without a horse as Carrier");
    }).build("minecraft:horse", "Horse");
    HORSE_WITH_CHEST = builder.reset().with(HORSE).with(new SpongeInventoryArchetypeBuilder().from(MENU_GRID).property(new InventoryDimension(5, 3)).build("horse_grid", "HorseGrid")).property(// hardcoded openGuiHorseInventory
    new GuiIdProperty(GuiIds.HORSE)).container((i, p) -> {
        if (i instanceof CarriedInventory && ((CarriedInventory) i).getCarrier().isPresent() && ((CarriedInventory) i).getCarrier().get() instanceof AbstractHorse) {
            AbstractHorse horse = ((AbstractHorse) ((CarriedInventory) i).getCarrier().get());
            // TODO size
            return new ContainerHorseInventory(p.inventory, i, horse, p);
        }
        throw new IllegalArgumentException("Cannot open horse inventory without a horse as Carrier");
    }).build("minecraft:horse_with_chest", "Horse with Chest");
    CRAFTING = builder.reset().with(SLOT).with(new SpongeInventoryArchetypeBuilder().from(MENU_GRID).property(new InventoryDimension(2, 2)).build("minecraft:crafting_grid", "Crafting Grid")).property(InventoryTitle.of(Text.of(new SpongeTranslation("container.crafting")))).build("minecraft:crafting", "Crafting");
    PLAYER = builder.reset().with(CRAFTING).with(new SpongeInventoryArchetypeBuilder().from(MENU_GRID).property(new InventoryDimension(1, 4)).build("minecraft:armor", "Armor")).with(new SpongeInventoryArchetypeBuilder().from(MENU_GRID).property(new InventoryDimension(9, 3)).build("minecraft:player_main", "Player Main")).with(new SpongeInventoryArchetypeBuilder().from(MENU_GRID).property(new InventoryDimension(9, 1)).build("minecraft:player_hotbar", "Player Hotbar")).with(new SpongeInventoryArchetypeBuilder().from(SLOT).property(new InventoryDimension(1, 1)).build("minecraft:player_offhand", "Player Offhand")).build("minecraft:player", "Player");
    UNKNOWN = builder.reset().build("minecraft:unknown", "UKNOWN");
    registerAdditionalCatalog(SLOT);
    registerAdditionalCatalog(MENU_ROW);
    registerAdditionalCatalog(MENU_COLUMN);
    registerAdditionalCatalog(MENU_GRID);
    registerAdditionalCatalog(CHEST);
    SpongeInventoryBuilder.registerInventory(TileEntityChest.class, CHEST);
    SpongeInventoryBuilder.registerContainer(ContainerChest.class, CHEST);
    registerAdditionalCatalog(DOUBLE_CHEST);
    registerAdditionalCatalog(FURNACE);
    SpongeInventoryBuilder.registerInventory(TileEntityFurnace.class, FURNACE);
    SpongeInventoryBuilder.registerContainer(ContainerFurnace.class, FURNACE);
    registerAdditionalCatalog(DISPENSER);
    SpongeInventoryBuilder.registerInventory(TileEntityDispenser.class, DISPENSER);
    SpongeInventoryBuilder.registerInventory(TileEntityDropper.class, DISPENSER);
    SpongeInventoryBuilder.registerContainer(ContainerDispenser.class, DISPENSER);
    registerAdditionalCatalog(WORKBENCH);
    SpongeInventoryBuilder.registerContainer(ContainerWorkbench.class, WORKBENCH);
    registerAdditionalCatalog(BREWING_STAND);
    SpongeInventoryBuilder.registerInventory(TileEntityBrewingStand.class, BREWING_STAND);
    SpongeInventoryBuilder.registerContainer(ContainerBrewingStand.class, BREWING_STAND);
    registerAdditionalCatalog(HOPPER);
    SpongeInventoryBuilder.registerInventory(TileEntityHopper.class, HOPPER);
    SpongeInventoryBuilder.registerContainer(ContainerHopper.class, HOPPER);
    registerAdditionalCatalog(BEACON);
    SpongeInventoryBuilder.registerInventory(TileEntityBeacon.class, BEACON);
    SpongeInventoryBuilder.registerContainer(ContainerBeacon.class, BEACON);
    registerAdditionalCatalog(ENCHANTING_TABLE);
    SpongeInventoryBuilder.registerContainer(ContainerEnchantment.class, ENCHANTING_TABLE);
    registerAdditionalCatalog(ANVIL);
    SpongeInventoryBuilder.registerContainer(ContainerRepair.class, ANVIL);
    registerAdditionalCatalog(VILLAGER);
    // TODO internal Villager Inventory? make Villager Carrier?
    SpongeInventoryBuilder.registerContainer(ContainerMerchant.class, VILLAGER);
    registerAdditionalCatalog(HORSE);
    // TODO Horse IInventory? SpongeInventoryBuilder.registerInventory(EntityHorse.class, HORSE);
    SpongeInventoryBuilder.registerContainer(ContainerHorseInventory.class, HORSE);
    registerAdditionalCatalog(HORSE_WITH_CHEST);
    registerAdditionalCatalog(CRAFTING);
    registerAdditionalCatalog(PLAYER);
    registerAdditionalCatalog(UNKNOWN);
    // Helper Archetypes for Menu
    InventoryArchetype MENU_ICON;
    InventoryArchetype MENU_BUTTON;
    InventoryArchetype MENU_CHECKBOX;
    InventoryArchetype MENU_SPINNER;
    MENU_ICON = builder.reset().with(SLOT).build("sponge:menu_icon", "Menu Icon");
    MENU_BUTTON = builder.reset().with(MENU_ICON).build("sponge:menu_button", "Menu Button");
    MENU_CHECKBOX = builder.reset().with(MENU_ICON).build("sponge:menu_checkbox", "Menu Checkbox");
    MENU_SPINNER = builder.reset().with(MENU_ICON).build("sponge:menu_spinner", "Menu Spinner");
    registerAdditionalCatalog(MENU_ICON);
    registerAdditionalCatalog(MENU_BUTTON);
    registerAdditionalCatalog(MENU_CHECKBOX);
    registerAdditionalCatalog(MENU_SPINNER);
}
Also used : SlotArchetype(org.spongepowered.common.item.inventory.archetype.SlotArchetype) AbstractHorse(net.minecraft.entity.passive.AbstractHorse) SpongeTranslation(org.spongepowered.common.text.translation.SpongeTranslation) GuiIdProperty(org.spongepowered.api.item.inventory.property.GuiIdProperty) CarriedInventory(org.spongepowered.api.item.inventory.type.CarriedInventory) ContainerDispenser(net.minecraft.inventory.ContainerDispenser) ContainerHopper(net.minecraft.inventory.ContainerHopper) ContainerBeacon(net.minecraft.inventory.ContainerBeacon) IMerchant(net.minecraft.entity.IMerchant) ContainerHorseInventory(net.minecraft.inventory.ContainerHorseInventory) ContainerBrewingStand(net.minecraft.inventory.ContainerBrewingStand) SpongeInventoryArchetypeBuilder(org.spongepowered.common.item.inventory.archetype.SpongeInventoryArchetypeBuilder) InventoryTitle(org.spongepowered.api.item.inventory.property.InventoryTitle) ContainerWorkbench(net.minecraft.inventory.ContainerWorkbench) ContainerRepair(net.minecraft.inventory.ContainerRepair) ContainerFurnace(net.minecraft.inventory.ContainerFurnace) ContainerChest(net.minecraft.inventory.ContainerChest) SlotIndex(org.spongepowered.api.item.inventory.property.SlotIndex) ContainerMerchant(net.minecraft.inventory.ContainerMerchant) InventoryDimension(org.spongepowered.api.item.inventory.property.InventoryDimension) InventoryArchetype(org.spongepowered.api.item.inventory.InventoryArchetype) ContainerEnchantment(net.minecraft.inventory.ContainerEnchantment)

Example 2 with AbstractHorse

use of net.minecraft.entity.passive.AbstractHorse in project HorsePower by GoryMoon.

the class TileEntityHPHorseBase method update.

@Override
public void update() {
    validationTimer--;
    if (validationTimer <= 0) {
        valid = validateArea();
        if (valid)
            validationTimer = 220;
        else
            validationTimer = 60;
    }
    boolean flag = false;
    if (!hasWorker())
        locateHorseTimer--;
    if (!hasWorker() && nbtWorker != null && locateHorseTimer <= 0) {
        UUID uuid = nbtWorker.getUniqueId("UUID");
        int x = pos.getX();
        int y = pos.getY();
        int z = pos.getZ();
        ArrayList<Class<? extends EntityCreature>> clazzes = Utils.getCreatureClasses();
        search: for (Class<? extends Entity> clazz : clazzes) {
            for (Object entity : world.getEntitiesWithinAABB(clazz, new AxisAlignedBB((double) x - 7.0D, (double) y - 7.0D, (double) z - 7.0D, (double) x + 7.0D, (double) y + 7.0D, (double) z + 7.0D))) {
                if (entity instanceof EntityCreature) {
                    EntityCreature creature = (EntityCreature) entity;
                    if (creature.getUniqueID().equals(uuid)) {
                        setWorker(creature);
                        flag = true;
                        break search;
                    }
                }
            }
        }
    }
    if (locateHorseTimer <= 0)
        locateHorseTimer = 220;
    if (!world.isRemote && valid) {
        if (!running && canWork()) {
            running = true;
        } else if (running && !canWork()) {
            running = false;
        }
        if (running != wasRunning) {
            target = getClosestTarget();
            wasRunning = running;
        }
        if (hasWorker()) {
            if (running) {
                Vec3d pos = getPathPosition(target);
                double x = pos.x;
                double y = pos.y;
                double z = pos.z;
                if (searchAreas[target] == null)
                    searchAreas[target] = new AxisAlignedBB(x - 0.5D, y - 0.5D, z - 0.5D, x + 0.5D, y + 0.5D, z + 0.5D);
                if (worker.getEntityBoundingBox().intersects(searchAreas[target])) {
                    int next = target + 1;
                    int previous = target - 1;
                    if (next >= path.length)
                        next = 0;
                    if (previous < 0)
                        previous = path.length - 1;
                    if (origin != target && target != previous) {
                        origin = target;
                        flag = targetReached();
                    }
                    target = next;
                }
                if (worker instanceof AbstractHorse && ((AbstractHorse) worker).isEatingHaystack()) {
                    ((AbstractHorse) worker).setEatingHaystack(false);
                }
                if (target != -1 && worker.getNavigator().noPath()) {
                    pos = getPathPosition(target);
                    x = pos.x;
                    y = pos.y;
                    z = pos.z;
                    worker.getNavigator().tryMoveToXYZ(x, y, z, 1D);
                }
            }
        }
    }
    if (flag) {
        markDirty();
    }
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) Entity(net.minecraft.entity.Entity) AbstractHorse(net.minecraft.entity.passive.AbstractHorse) UUID(java.util.UUID) EntityCreature(net.minecraft.entity.EntityCreature) Vec3d(net.minecraft.util.math.Vec3d)

Example 3 with AbstractHorse

use of net.minecraft.entity.passive.AbstractHorse in project Wizardry by TeamWizardry.

the class ModelUnicorn method render.

@Override
@SuppressWarnings("unused")
public void render(Entity entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
    AbstractHorse abstracthorse = (AbstractHorse) entityIn;
    float f = abstracthorse.getGrassEatingAmount(0.0F);
    boolean flag = abstracthorse.isChild();
    boolean flag1 = !flag && abstracthorse.isHorseSaddled();
    boolean flag2 = abstracthorse instanceof AbstractChestHorse;
    float f1 = abstracthorse.getHorseSize();
    boolean flag4 = abstracthorse.isBeingRidden();
    if (flag1) {
        this.horseFaceRopes.render(scale);
        this.horseSaddleBottom.render(scale);
        this.horseSaddleFront.render(scale);
        this.horseSaddleBack.render(scale);
        this.horseLeftSaddleRope.render(scale);
        this.horseLeftSaddleMetal.render(scale);
        this.horseRightSaddleRope.render(scale);
        this.horseRightSaddleMetal.render(scale);
        this.horseLeftFaceMetal.render(scale);
        this.horseRightFaceMetal.render(scale);
        if (flag4) {
            this.horseLeftRein.render(scale);
            this.horseRightRein.render(scale);
        }
    }
    if (!flag) {
        GlStateManager.pushMatrix();
        GlStateManager.scale(f1, 0.5F + f1 * 0.5F, f1);
        GlStateManager.translate(0.0F, 0.95F * (1.0F - f1), 0.0F);
    }
    this.backLeftLeg.render(scale);
    this.backLeftShin.render(scale);
    this.backLeftHoof.render(scale);
    this.backRightLeg.render(scale);
    this.backRightShin.render(scale);
    this.backRightHoof.render(scale);
    this.frontLeftLeg.render(scale);
    this.frontLeftShin.render(scale);
    this.frontLeftHoof.render(scale);
    this.frontRightLeg.render(scale);
    this.frontRightShin.render(scale);
    this.frontRightHoof.render(scale);
    if (!flag) {
        GlStateManager.popMatrix();
        GlStateManager.pushMatrix();
        GlStateManager.scale(f1, f1, f1);
        GlStateManager.translate(0.0F, 1.35F * (1.0F - f1), 0.0F);
    }
    this.body.render(scale);
    this.tailBase.render(scale);
    this.tailMiddle.render(scale);
    this.tailTip.render(scale);
    this.neck.render(scale);
    this.mane.render(scale);
    if (!flag) {
        GlStateManager.popMatrix();
        GlStateManager.pushMatrix();
        float f2 = 0.5F + f1 * f1 * 0.5F;
        GlStateManager.scale(f2, f2, f2);
        if (f <= 0.0F) {
            GlStateManager.translate(0.0F, 1.35F * (1.0F - f1), 0.0F);
        } else {
            GlStateManager.translate(0.0F, 0.9F * (1.0F - f1) * f + 1.35F * (1.0F - f1) * (1.0F - f), 0.15F * (1.0F - f1) * f);
        }
    }
    this.horseLeftEar.render(scale);
    this.horseRightEar.render(scale);
    this.head.render(scale);
    this.horn.render(scale);
    if (!flag) {
        GlStateManager.popMatrix();
    }
}
Also used : AbstractHorse(net.minecraft.entity.passive.AbstractHorse) AbstractChestHorse(net.minecraft.entity.passive.AbstractChestHorse)

Example 4 with AbstractHorse

use of net.minecraft.entity.passive.AbstractHorse in project SpongeCommon by SpongePowered.

the class SpongeCommonEventFactory method displayContainer.

@Nullable
public static Container displayContainer(EntityPlayerMP player, Inventory inventory) {
    net.minecraft.inventory.Container previousContainer = player.openContainer;
    net.minecraft.inventory.Container container;
    if (inventory instanceof CustomInventory) {
        if (!checkValidVanillaCustomInventory(((CustomInventory) inventory))) {
            // Invalid size for vanilla inventory ; This is to
            return null;
        // prevent crashing the client with invalid data
        }
    }
    if (inventory instanceof IInteractionObject) {
        final String guiId = ((IInteractionObject) inventory).getGuiID();
        switch(guiId) {
            case "EntityHorse":
                if (inventory instanceof CarriedInventory) {
                    CarriedInventory<?> cinventory = (CarriedInventory<?>) inventory;
                    if (cinventory.getCarrier().isPresent() && cinventory.getCarrier().get() instanceof AbstractHorse) {
                        player.openGuiHorseInventory(((AbstractHorse) cinventory.getCarrier().get()), (IInventory) inventory);
                    }
                }
                break;
            case "minecraft:chest":
                player.displayGUIChest((IInventory) inventory);
                break;
            case "minecraft:crafting_table":
            case "minecraft:anvil":
            case "minecraft:enchanting_table":
                player.displayGui((IInteractionObject) inventory);
                break;
            default:
                player.displayGUIChest((IInventory) inventory);
                break;
        }
    } else if (inventory instanceof IInventory) {
        player.displayGUIChest(((IInventory) inventory));
    } else {
        return null;
    }
    container = player.openContainer;
    if (previousContainer == container) {
        return null;
    }
    if (!callInteractInventoryOpenEvent(player)) {
        return null;
    }
    if (container instanceof IMixinContainer) {
        // This overwrites the normal container behaviour and allows viewing
        // inventories that are more than 8 blocks away
        // This currently actually only works for the Containers mixed into
        // by MixinContainerCanInteract ; but throws no errors for other
        // containers
        // Allow viewing inventory; except when dead
        ((IMixinContainer) container).setCanInteractWith(p -> !p.isDead);
    }
    return container;
}
Also used : IInventory(net.minecraft.inventory.IInventory) IMixinContainer(org.spongepowered.common.interfaces.IMixinContainer) AbstractHorse(net.minecraft.entity.passive.AbstractHorse) IInteractionObject(net.minecraft.world.IInteractionObject) CarriedInventory(org.spongepowered.api.item.inventory.type.CarriedInventory) CustomInventory(org.spongepowered.common.item.inventory.custom.CustomInventory) Container(net.minecraft.inventory.Container) Nullable(javax.annotation.Nullable)

Aggregations

AbstractHorse (net.minecraft.entity.passive.AbstractHorse)4 CarriedInventory (org.spongepowered.api.item.inventory.type.CarriedInventory)2 UUID (java.util.UUID)1 Nullable (javax.annotation.Nullable)1 Entity (net.minecraft.entity.Entity)1 EntityCreature (net.minecraft.entity.EntityCreature)1 IMerchant (net.minecraft.entity.IMerchant)1 AbstractChestHorse (net.minecraft.entity.passive.AbstractChestHorse)1 Container (net.minecraft.inventory.Container)1 ContainerBeacon (net.minecraft.inventory.ContainerBeacon)1 ContainerBrewingStand (net.minecraft.inventory.ContainerBrewingStand)1 ContainerChest (net.minecraft.inventory.ContainerChest)1 ContainerDispenser (net.minecraft.inventory.ContainerDispenser)1 ContainerEnchantment (net.minecraft.inventory.ContainerEnchantment)1 ContainerFurnace (net.minecraft.inventory.ContainerFurnace)1 ContainerHopper (net.minecraft.inventory.ContainerHopper)1 ContainerHorseInventory (net.minecraft.inventory.ContainerHorseInventory)1 ContainerMerchant (net.minecraft.inventory.ContainerMerchant)1 ContainerRepair (net.minecraft.inventory.ContainerRepair)1 ContainerWorkbench (net.minecraft.inventory.ContainerWorkbench)1