|
| 1 | +/* |
| 2 | + * This file is part of Sponge, licensed under the MIT License (MIT). |
| 3 | + * |
| 4 | + * Copyright (c) SpongePowered <https://www.spongepowered.org> |
| 5 | + * Copyright (c) contributors |
| 6 | + * |
| 7 | + * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 8 | + * of this software and associated documentation files (the "Software"), to deal |
| 9 | + * in the Software without restriction, including without limitation the rights |
| 10 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 11 | + * copies of the Software, and to permit persons to whom the Software is |
| 12 | + * furnished to do so, subject to the following conditions: |
| 13 | + * |
| 14 | + * The above copyright notice and this permission notice shall be included in |
| 15 | + * all copies or substantial portions of the Software. |
| 16 | + * |
| 17 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 18 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 19 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 20 | + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 21 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 22 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 23 | + * THE SOFTWARE. |
| 24 | + */ |
| 25 | +package org.spongepowered.common.mixin.inventory.impl.world; |
| 26 | + |
| 27 | +import net.minecraft.world.CompoundContainer; |
| 28 | +import net.minecraft.world.SimpleContainer; |
| 29 | +import net.minecraft.world.entity.player.Inventory; |
| 30 | +import net.minecraft.world.entity.vehicle.AbstractMinecartContainer; |
| 31 | +import net.minecraft.world.entity.vehicle.ChestBoat; |
| 32 | +import net.minecraft.world.inventory.MerchantContainer; |
| 33 | +import net.minecraft.world.inventory.ResultContainer; |
| 34 | +import net.minecraft.world.inventory.TransientCraftingContainer; |
| 35 | +import net.minecraft.world.level.block.entity.BaseContainerBlockEntity; |
| 36 | +import org.checkerframework.checker.nullness.qual.MonotonicNonNull; |
| 37 | +import org.spongepowered.asm.mixin.Mixin; |
| 38 | +import org.spongepowered.common.entity.player.SpongeUserInventory; |
| 39 | +import org.spongepowered.common.inventory.custom.CustomInventory; |
| 40 | +import org.spongepowered.common.inventory.fabric.InventoryTranslator; |
| 41 | +import org.spongepowered.common.inventory.fabric.InventoryTranslators; |
| 42 | +import org.spongepowered.common.inventory.fabric.UniversalFabric; |
| 43 | + |
| 44 | +@Mixin(value = { |
| 45 | + AbstractMinecartContainer.class, |
| 46 | + ChestBoat.class, |
| 47 | + BaseContainerBlockEntity.class, |
| 48 | + CompoundContainer.class, |
| 49 | + TransientCraftingContainer.class, |
| 50 | + CustomInventory.class, |
| 51 | + Inventory.class, |
| 52 | + MerchantContainer.class, |
| 53 | + ResultContainer.class, |
| 54 | + SimpleContainer.class, |
| 55 | + SpongeUserInventory.class |
| 56 | +}) |
| 57 | +public abstract class TraitMixin_UniversalFabric_Inventory implements UniversalFabric { |
| 58 | + |
| 59 | + private @MonotonicNonNull InventoryTranslator<?> fabric$inventoryTranslator; |
| 60 | + |
| 61 | + @Override |
| 62 | + public InventoryTranslator<?> fabric$translator() { |
| 63 | + if (this.fabric$inventoryTranslator == null) { |
| 64 | + this.fabric$inventoryTranslator = InventoryTranslators.getTranslator(this.getClass()); |
| 65 | + } |
| 66 | + return this.fabric$inventoryTranslator; |
| 67 | + } |
| 68 | +} |
0 commit comments