net.minecraft.inventory.SimpleInventory Java Examples

The following examples show how to use net.minecraft.inventory.SimpleInventory. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CmdPeek.java    From bleachhack-1.14 with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onCommand(String command, String[] args) throws Exception {
	ItemStack item = mc.player.inventory.getMainHandStack();
	
	if (!(item.getItem() instanceof BlockItem)) {
		BleachLogger.errorMessage("Must be holding a containter to peek.");
		return;
	}
	
	if (!(((BlockItem) item.getItem()).getBlock() instanceof ShulkerBoxBlock)
			 && !(((BlockItem) item.getItem()).getBlock() instanceof ChestBlock)
			 && !(((BlockItem) item.getItem()).getBlock() instanceof DispenserBlock)
			 && !(((BlockItem) item.getItem()).getBlock() instanceof HopperBlock)) {
		BleachLogger.errorMessage("Must be holding a containter to peek.");
		return;
	}
	
	List<ItemStack> items = ItemContentUtils.getItemsInContainer(item);
	
	SimpleInventory inv = new SimpleInventory(items.toArray(new ItemStack[27]));
	
	BleachQueue.queue.add(() -> {
		mc.openScreen(new ShulkerBoxScreen(
				new ShulkerBoxScreenHandler(420, mc.player.inventory, inv),
				mc.player.inventory,
				item.getName()));
	});
}
 
Example #2
Source File: CircuitFabricatorBlockEntity.java    From Galacticraft-Rewoven with MIT License 4 votes vote down vote up
private ItemStack getResultFromRecipeStack() {
    SimpleInventory inv = new SimpleInventory(getInventory().getStack(5));
    // This should under no circumstances not be present. If it is, this method has been called before isValidRecipe and you should feel bad.
    FabricationRecipe recipe = getRecipe(inv).orElseThrow(() -> new IllegalStateException("Not a valid recipe."));
    return recipe.craft(inv);
}
 
Example #3
Source File: CircuitFabricatorBlockEntity.java    From Galacticraft-Rewoven with MIT License 4 votes vote down vote up
private Optional<FabricationRecipe> getRecipe(SimpleInventory input) {
    return this.world.getRecipeManager().getFirstMatch(GalacticraftRecipes.FABRICATION_TYPE, input, this.world);
}
 
Example #4
Source File: CircuitFabricatorBlockEntity.java    From Galacticraft-Rewoven with MIT License 4 votes vote down vote up
private boolean isValidRecipe(ItemStack input) {
        // TODO check up on this
        return getRecipe(new SimpleInventory(input)).isPresent() && hasMandatoryMaterials();
//        return !input.isEmpty() && hasMandatoryMaterials();
    }
 
Example #5
Source File: SyncedGuiDescription.java    From LibGui with MIT License 2 votes vote down vote up
/**
 * Gets the block inventory at the context.
 *
 * <p>If no inventory is found, returns a simple mutable inventory
 * with the specified number of slots.
 *
 * <p>Searches for these implementations in the following order:
 * <ol>
 *     <li>Blocks implementing {@code InventoryProvider}</li>
 *     <li>Block entities implementing {@code InventoryProvider}</li>
 *     <li>Block entities implementing {@code Inventory}</li>
 * </ol>
 *
 * @param ctx  the context
 * @param size the fallback inventory size
 * @return the found inventory
 * @since 2.0.0
 */
public static Inventory getBlockInventory(ScreenHandlerContext ctx, int size) {
	return getBlockInventory(ctx, () -> new SimpleInventory(size));
}