Search in sources :

Example 1 with IMixinItem

use of org.spongepowered.common.interfaces.item.IMixinItem in project SpongeCommon by SpongePowered.

the class MixinItemStack method getContainers.

@Override
public Collection<DataManipulator<?, ?>> getContainers() {
    final List<DataManipulator<?, ?>> manipulators = Lists.newArrayList();
    final Item item = this.shadow$getItem();
    // Null items should be impossible to create
    if (item == null) {
        final PrettyPrinter printer = new PrettyPrinter(60);
        printer.add("Null Item found!").centre().hr();
        printer.add("An ItemStack has a null ItemType! This is usually not supported as it will likely have issues elsewhere.");
        printer.add("Please ask help for seeing if this is an issue with a mod and report it!");
        printer.add("Printing a Stacktrace:");
        printer.add(new Exception());
        printer.log(SpongeImpl.getLogger(), Level.WARN);
        return manipulators;
    }
    ((IMixinItem) item).getManipulatorsFor((net.minecraft.item.ItemStack) (Object) this, manipulators);
    if (hasManipulators()) {
        final List<DataManipulator<?, ?>> customManipulators = this.getCustomManipulators();
        manipulators.addAll(customManipulators);
    }
    return manipulators;
}
Also used : IMixinItem(org.spongepowered.common.interfaces.item.IMixinItem) Item(net.minecraft.item.Item) IMixinItem(org.spongepowered.common.interfaces.item.IMixinItem) PrettyPrinter(org.spongepowered.asm.util.PrettyPrinter) DataManipulator(org.spongepowered.api.data.manipulator.DataManipulator) InvalidDataException(org.spongepowered.api.data.persistence.InvalidDataException)

Aggregations

Item (net.minecraft.item.Item)1 DataManipulator (org.spongepowered.api.data.manipulator.DataManipulator)1 InvalidDataException (org.spongepowered.api.data.persistence.InvalidDataException)1 PrettyPrinter (org.spongepowered.asm.util.PrettyPrinter)1 IMixinItem (org.spongepowered.common.interfaces.item.IMixinItem)1