Advertisement
Guest User

Capability: Impl

a guest
Jul 1st, 2017
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.66 KB | None | 0 0
  1. package iitest.capability;
  2.  
  3. import net.minecraft.entity.player.EntityPlayer;
  4. import net.minecraft.item.ItemStack;
  5. import net.minecraft.util.text.ITextComponent;
  6.  
  7. import java.util.List;
  8.  
  9. public class ITestImpl implements ITest {
  10.     private int       value = 0;
  11.  
  12.     private ItemStack[] slot = new ItemStack[1];
  13.  
  14.  
  15.     public int getValue() {
  16.         return value;
  17.     }
  18.  
  19.     public void setValue(int v) {
  20.         value = v;
  21.     }
  22.  
  23.  
  24.     @Override
  25.     public int getSizeInventory() {
  26.         return 1;
  27.     }
  28.  
  29.     @Override
  30.     public boolean isEmpty() {
  31.         return slot[0] == null;
  32.     }
  33.  
  34.     @Override
  35.     public ItemStack getStackInSlot(int index) {
  36.         if (index == 0 && slot[0] != null)
  37.             return slot[0];
  38.         return ItemStack.EMPTY;
  39.     }
  40.  
  41.     @Override
  42.     public ItemStack decrStackSize(int index, int count) {
  43.         if (index == 0 && count > 0 && slot[0] != null) {
  44.             ItemStack tmp = this.slot[0].splitStack(count);
  45.  
  46.             if (this.slot[0].getCount() == 0)
  47.                 this.slot[0] = null;
  48.  
  49.             return tmp;
  50.         }
  51.         return ItemStack.EMPTY;
  52.     }
  53.  
  54.     @Override
  55.     public ItemStack removeStackFromSlot(int index) {
  56.         if (index == 0 && slot[0] != null) {
  57.             ItemStack tmp = slot[0];
  58.             slot[0] = null;
  59.             return (tmp);
  60.         }
  61.         return ItemStack.EMPTY;
  62.     }
  63.  
  64.     @Override
  65.     public void setInventorySlotContents(int index, ItemStack stack) {
  66.         if (index == 0)
  67.             this.slot[0] = stack;
  68.     }
  69.  
  70.     @Override
  71.     public int getInventoryStackLimit() {
  72.         return 64;
  73.     }
  74.  
  75.     @Override
  76.     public void markDirty() {
  77.         // ???
  78.     }
  79.  
  80.     @Override
  81.     public boolean isUsableByPlayer(EntityPlayer player) {
  82.         return true;
  83.     }
  84.  
  85.     @Override
  86.     public void openInventory(EntityPlayer player) {
  87.         // ???
  88.     }
  89.  
  90.     @Override
  91.     public void closeInventory(EntityPlayer player) {
  92.         // ???
  93.     }
  94.  
  95.     @Override
  96.     public boolean isItemValidForSlot(int index, ItemStack stack) {
  97.         return true;
  98.     }
  99.  
  100.     @Override
  101.     public int getField(int id) {
  102.         return 0;
  103.     }
  104.  
  105.     @Override
  106.     public void setField(int id, int value) {
  107.         // ???
  108.     }
  109.  
  110.     @Override
  111.     public int getFieldCount() {
  112.         return 0;
  113.     }
  114.  
  115.     @Override
  116.     public void clear() {
  117.         slot[0] = null;
  118.     }
  119.  
  120.  
  121.     @Override
  122.     public String getName() {
  123.         return null;
  124.     }
  125.  
  126.     @Override
  127.     public boolean hasCustomName() {
  128.         return false;
  129.     }
  130.  
  131.     @Override
  132.     public ITextComponent getDisplayName() {
  133.         return null;
  134.     }
  135. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement