mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-06-17 22:31:52 +00:00
implement LockableContainerBlockEntityMixin
This commit is contained in:
@@ -1,37 +0,0 @@
|
|||||||
package com.dfsek.terra.fabric.inventory;
|
|
||||||
|
|
||||||
import com.dfsek.terra.api.platform.inventory.Inventory;
|
|
||||||
import com.dfsek.terra.api.platform.inventory.ItemStack;
|
|
||||||
import com.dfsek.terra.fabric.world.FabricAdapter;
|
|
||||||
import net.minecraft.item.Items;
|
|
||||||
|
|
||||||
public class FabricInventory implements Inventory {
|
|
||||||
private final net.minecraft.inventory.Inventory delegate;
|
|
||||||
|
|
||||||
public FabricInventory(net.minecraft.inventory.Inventory delegate) {
|
|
||||||
this.delegate = delegate;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public net.minecraft.inventory.Inventory getHandle() {
|
|
||||||
return delegate;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getSize() {
|
|
||||||
return delegate.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("ConstantConditions")
|
|
||||||
@Override
|
|
||||||
public ItemStack getItem(int slot) {
|
|
||||||
net.minecraft.item.ItemStack itemStack = delegate.getStack(slot);
|
|
||||||
return itemStack.getItem() == Items.AIR ? null : (ItemStack) (Object) itemStack;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("ConstantConditions")
|
|
||||||
@Override
|
|
||||||
public void setItem(int slot, ItemStack newStack) {
|
|
||||||
delegate.setStack(slot, (net.minecraft.item.ItemStack) (Object) newStack);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+1
-2
@@ -2,7 +2,6 @@ package com.dfsek.terra.fabric.mixin.implementations.block.state;
|
|||||||
|
|
||||||
import com.dfsek.terra.api.platform.block.state.Container;
|
import com.dfsek.terra.api.platform.block.state.Container;
|
||||||
import com.dfsek.terra.api.platform.inventory.Inventory;
|
import com.dfsek.terra.api.platform.inventory.Inventory;
|
||||||
import com.dfsek.terra.fabric.inventory.FabricInventory;
|
|
||||||
import com.dfsek.terra.fabric.mixin.implementations.block.BlockEntityMixin;
|
import com.dfsek.terra.fabric.mixin.implementations.block.BlockEntityMixin;
|
||||||
import net.minecraft.block.entity.LootableContainerBlockEntity;
|
import net.minecraft.block.entity.LootableContainerBlockEntity;
|
||||||
import org.spongepowered.asm.mixin.Implements;
|
import org.spongepowered.asm.mixin.Implements;
|
||||||
@@ -13,7 +12,7 @@ import org.spongepowered.asm.mixin.Mixin;
|
|||||||
@Implements(@Interface(iface = Container.class, prefix = "terra$"))
|
@Implements(@Interface(iface = Container.class, prefix = "terra$"))
|
||||||
public abstract class LootableContainerBlockEntityMixin extends BlockEntityMixin {
|
public abstract class LootableContainerBlockEntityMixin extends BlockEntityMixin {
|
||||||
public Inventory terra$getInventory() {
|
public Inventory terra$getInventory() {
|
||||||
return new FabricInventory(((LootableContainerBlockEntity) (Object) this));
|
return (Inventory) this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object terra$getHandle() {
|
public Object terra$getHandle() {
|
||||||
|
|||||||
+32
@@ -0,0 +1,32 @@
|
|||||||
|
package com.dfsek.terra.fabric.mixin.implementations.inventory;
|
||||||
|
|
||||||
|
import com.dfsek.terra.api.platform.inventory.Inventory;
|
||||||
|
import com.dfsek.terra.api.platform.inventory.ItemStack;
|
||||||
|
import net.minecraft.block.entity.LockableContainerBlockEntity;
|
||||||
|
import net.minecraft.item.Items;
|
||||||
|
import org.spongepowered.asm.mixin.Implements;
|
||||||
|
import org.spongepowered.asm.mixin.Interface;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
|
||||||
|
@Mixin(LockableContainerBlockEntity.class)
|
||||||
|
@Implements(@Interface(iface = Inventory.class, prefix = "terra$"))
|
||||||
|
public class LockableContainerBlockEntityMixin {
|
||||||
|
public Object terra$getHandle() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int terra$getSize() {
|
||||||
|
return ((LockableContainerBlockEntity) (Object) this).size();
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("ConstantConditions")
|
||||||
|
public ItemStack terra$getItem(int slot) {
|
||||||
|
net.minecraft.item.ItemStack itemStack = ((LockableContainerBlockEntity) (Object) this).getStack(slot);
|
||||||
|
return itemStack.getItem() == Items.AIR ? null : (ItemStack) (Object) itemStack;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("ConstantConditions")
|
||||||
|
public void terra$setItem(int slot, ItemStack newStack) {
|
||||||
|
((LockableContainerBlockEntity) (Object) this).setStack(slot, (net.minecraft.item.ItemStack) (Object) newStack);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -20,6 +20,7 @@
|
|||||||
"implementations.entity.EntityTypeMixin",
|
"implementations.entity.EntityTypeMixin",
|
||||||
"implementations.entity.PlayerEntityMixin",
|
"implementations.entity.PlayerEntityMixin",
|
||||||
"implementations.entity.ServerCommandSourceMixin",
|
"implementations.entity.ServerCommandSourceMixin",
|
||||||
|
"implementations.inventory.LockableContainerBlockEntityMixin",
|
||||||
"implementations.inventory.item.ItemMixin",
|
"implementations.inventory.item.ItemMixin",
|
||||||
"implementations.inventory.item.ItemStackMixin",
|
"implementations.inventory.item.ItemStackMixin",
|
||||||
"implementations.inventory.meta.EnchantmentMixin",
|
"implementations.inventory.meta.EnchantmentMixin",
|
||||||
|
|||||||
Reference in New Issue
Block a user