Skip to content

Instantly share code, notes, and snippets.

package gigaherz.enderRift.common.container;
import net.minecraft.item.ItemStack;
public interface IItemHandlerContainer
{
boolean isItemValidForSlot(int slot, ItemStack stack);
int getInventoryStackLimit(int slot);
}
package gigaherz.packingtape.cap;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraftforge.items.ItemStackHandler;
/**
* Created by gigaherz on 06/08/2016.
*
* This class is the feature we want to attach to the player.

I want to show you why the capabilities work the way they work, and not just how they work.

The following explanation is not meant to be accurate with reality, only a way to form the necessary connections and be able to understand one possible reasoning for the design.

I will try my best.

Backstory

Once upon a time, every API would define a bunch of interfaces that people would implement

{
"__comment": "It may be best to have a difference between localization keys, and actual display strings",
"name": "entity.creeper.name",
"__comment": "User-defined 'team', useful for distinguishing enemies",
"faction": "creeper",
"initial_state": "wander",
"states": {
@gigaherz
gigaherz / IDEA.md
Last active October 13, 2020 17:46

Terminal-free IntelliJ IDEA configuration

These instructions assume that you have created the project folder as described in the Getting Started page, and are meant to be used in place of steps 4+ of that page.

  1. Launch IDEA and choose to open/import the build.gradle file, using the default gradle wrapper choice. While you wait for this process to finish, you can open the gradle panel, which will get filled with the gradle tasks once importing is completed.
  2. Run the setupDecompWorkspace task (inside the forgegradle task group). It will take a few minutes, and use quite a bit of RAM. If it fails, you can add -Xmx3G to the Gradle VM options in IDEA's gradle settings window, or edit your global gradle properties.
  3. Once the setup task is done, you will want to run the genIntellijRuns task, which will configure the project's run/debug targets.
  4. After it's done, you should click the blue refre
@gigaherz
gigaherz / code.json
Last active July 8, 2017 15:52
A concept for a JSON-encoded Java AST
{
"PROGRAM": "Name here",
"VERSION": "1.0",
"Program": {
"TYPE": "class",
"SUPER": "Application",
"ATTRIBUTES": [ "public", "static"],
"FORMAT": 1,
"MEMBERS": {
// ==UserScript==
// @name Foldable diffs
// @namespace http://tampermonkey.net/
// @version 0.4
// @description Adds a fold button to file diffs, and folds deleted files by default
// @author gigaherz
// @match https://bitbucket.org/*
// @grant none
// ==/UserScript==
// ==UserScript==
// @name Down with the Circles!
// @namespace https://gist.github.com/gigaherz/cee1af98c298dbeea14f12986307fdf0
// @version 0.4
// @description Changes the circleness of twitter avatars.
// @author gigaherz
// @match https://twitter.com/*
// @grant GM_addStyle
// ==/UserScript==

An attempt at explaining the purpose and design of capabilities

Capabilitites are a concrete solution to an abstract problem.

The problem

In order to implement an api like RF, you have to implement interfaces in your tileentities or items or such. If you are implementing 20 different APIs for a tech mod they pile up into the same TE-

class MyTileEntity extends TileEntity implements EnergyInterface1, EnergyInterface2, EnergyInterface3, FluidsInterface1, FluidsInterface2, FluidsInterface3, ItemsApi1, ItemsApi2, ItemsApi3, ComputerApi1, ComputerApi2, ...
{"sidebarBg":"#23252c","sidebarText":"#ffffff","sidebarUnreadText":"#ffffff","sidebarTextHoverBg":"#2a2d34","sidebarTextActiveBorder":"#196caf","sidebarTextActiveColor":"#ffffff","sidebarHeaderBg":"#363a42","sidebarHeaderTextColor":"#ffffff","onlineIndicator":"#399fff","awayIndicator":"#c1b966","dndIndicator":"#e81023","mentionBj":"#0177e7","mentionColor":"#ffffff","centerChannelBg":"#2a2d34","centerChannelColor":"#dddddd","newMessageSeparator":"#cc992d","linkColor":"#0d93ff","buttonBg":"#0177e7","buttonColor":"#ffffff","errorTextColor":"#ff6461","mentionHighlightBg":"#784098","mentionHighlightLink":"#a4ffeb","codeTheme":"monokai","mentionBg":"#0177e7"}