Skip to content

Instantly share code, notes, and snippets.

View tterrag1098's full-sized avatar

tterrag tterrag1098

View GitHub Profile
// Helpful buffer methods I'm using
public long sizeOf(FloatBuffer buf) {
return buf.capacity() * 4L;
}
NBTTagCompound testtag = new NBTTagCompound();
testtag.setString("group", "marble");
testtag.setTag("stack", new ItemStack(Items.DIAMOND_PICKAXE, 1, 100).serializeNBT());
FMLInterModComms.sendMessage(MOD_ID, IMC.ADD_VARIATION_2.toString(), testtag);
testtag = new NBTTagCompound();
testtag.setString("group", "marble");
testtag.setString("block", Blocks.WOOL.getRegistryName().toString());
FMLInterModComms.sendMessage(MOD_ID, IMC.ADD_VARIATION_2.toString(), testtag);
testtag = new NBTTagCompound();
testtag.setString("group", "marble");
@tterrag1098
tterrag1098 / ExceptionInDependencyTest.java
Last active June 28, 2017 03:28
"waldo" is never reported, instead "wilma" is shown in the crash log, even though "waldo" is raised first.
public class ExceptionInDependencyTest {
@Mod(modid = "dependency", name = "Dependency", version = "1.0.0")
public static class Dependency {
@Mod.EventHandler
public void init(FMLPreInitializationEvent event) {
throw new RuntimeException("waldo");
}
}
@Mod(modid = "dependent", name = "Dependent", version = "1.0.0", dependencies = "required-after:dependency")
private static void parseStates(Block block, List<Map<String, String>> states, Collection<IBlockState> data) {
if (states.isEmpty()) {
data.addAll(block.getBlockState().getValidStates());
} else {
for (Map<String, String> state : states) {
data.add(parseState(block, state));
}
}
}
var colors = [
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 3,
3, 12, 12, 3, 3, 12, 12, 12, 3, 12, 13, 13, 12, 10, 12, 12, 5, 12, 12, 12, 12, 3,
3, 12, 12, 3, 12, 3, 12, 12, 3, 12, 13, 12, 12, 10, 10, 12, 5, 5, 5, 12, 12, 3,
3, 12, 12, 3, 3, 12, 12, 3, 12, 12, 13, 13, 12, 10, 12, 12, 5, 12, 5, 12, 12, 3,
3, 12, 12, 3, 12, 3, 12, 3, 12, 12, 13, 12, 12, 10, 10, 12, 5, 5, 5, 12, 12, 3,
3, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 3,
3, 12, 12, 12, 12, 12, 12, 12, 12, 12, 3, 3, 12, 12, 12, 12, 12, 12, 12, 12, 12, 3,
3, 12, 12, 12, 12, 12, 12, 12, 3, 3, 1, 2, 3, 3, 12, 12, 12, 12, 12, 12, 12, 3,
{
"ores" : {
"coal_ore": {
"models" : [
"coal_ore#normal"
],
"texture" : "coal_ore",
"preserveShading": false
},
"iron_ore" : {
package tterrag.placelapse;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.ArrayDeque;
import java.util.Queue;
import java.util.Scanner;
package com.creatubbles.ctbmod.client;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.nio.IntBuffer;
import java.util.List;

The Capability System

A capability can be thought of much like a trait. It allows exposing features in a dynamic and flexible way, without having to resort to directly implementing many interfaces.

In general terms, a capability is a marker object (generally a singleton) which provides an implementation of the capability, specific to the parent object. For instance, in the case of a chest with an inventory, we have:

  • The parent object - this is the Tile Entity, ItemStack, Entity, or whatever it may be that "owns" the capability. In this case, it is the chest Tile Entity.

  • The capability - the "idea" of an inventory can be considered the capability. A capability is not any one implementation of an inventory, but more of a contract stating whether the parent object has the ability (or capability) to be treated as an inventory.