Skip to content

Instantly share code, notes, and snippets.

@robotgryphon
Created June 5, 2021 16:26
Show Gist options
  • Save robotgryphon/344e5815e27f28fef7a837c4f98ade40 to your computer and use it in GitHub Desktop.
Save robotgryphon/344e5815e27f28fef7a837c4f98ade40 to your computer and use it in GitHub Desktop.
Fake Recipe Inventory
package com.robotgryphon.compactcrafting.recipes.setup;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
public class FakeInventory implements IInventory {
/**
* Returns the number of slots in the inventory.
*/
@Override
public int getContainerSize() {
return 0;
}
@Override
public boolean isEmpty() {
return true;
}
/**
* Returns the stack in the given slot.
*
* @param index
*/
@Override
public ItemStack getItem(int index) {
return ItemStack.EMPTY;
}
/**
* Removes up to a specified number of items from an inventory slot and returns them in a new stack.
*
* @param index
* @param count
*/
@Override
public ItemStack removeItem(int index, int count) {
return ItemStack.EMPTY;
}
/**
* Removes a stack from the given slot and returns it.
*
* @param index
*/
@Override
public ItemStack removeItemNoUpdate(int index) {
return ItemStack.EMPTY;
}
/**
* Sets the given item stack to the specified slot in the inventory (can be crafting or armor sections).
*
* @param index
* @param stack
*/
@Override
public void setItem(int index, ItemStack stack) { }
/**
* For tile entities, ensures the chunk containing the tile entity is saved to disk later - the game won't think it
* hasn't changed and skip it.
*/
@Override
public void setChanged() { }
/**
* Don't rename this method to canInteractWith due to conflicts with Container
*
* @param player
*/
@Override
public boolean stillValid(PlayerEntity player) {
return false;
}
@Override
public void clearContent() { }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment