Skip to content

Instantly share code, notes, and snippets.

@AbrarSyed
Last active August 29, 2015 14:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AbrarSyed/515c251f06e09fd72174 to your computer and use it in GitHub Desktop.
Save AbrarSyed/515c251f06e09fd72174 to your computer and use it in GitHub Desktop.
public interface IMultiBlockHandler
{
public void addMember(World world, int x, int y, int z);
public void addSpecialHandler(Object obj);
}
public class BlockMyMultiblock extends Block
{
public MyBlockMultiblock()
{
super(Material.rock);
}
public boolean isMultiBlock(World world, int x, int y, int z)
{
return true;
}
/* this data could be subject to change. Dont store it indefinitely. */
public void populateMultiblock(World world, int x, int y, int z, IMultiBlockHandler handler)
{
handler.addMember(world, x, y, z); // adds this block
handler.addSpecialHandler(world.getBlockTileEntity(x, y, z)); // adds in my TE for liquid handling.
}
}
/** This is a dummy implementation. You would generally want to write your own. */
public class MultiBlockHandlerImpl implements IMultiBlockHandler
{
/** DONT STORE THIS DATA PERMANENTLY */
private final TIntHashMultimap<ChunkCoordinate> members = new TIntHashMultimap<ChunkCoordinate>();
private final LinkedList<WeakReference<Object>> specials = new LinkedList<WeakReference<Object>>();
public void addMember(World world, int x, int y, int z)
{
members.put(world.provider.dimensionId, new ChunkCoordinate(x, y, z));
}
public void addSpecialHandler(Object obj)
{
specials.add(new WeakReference(obj));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment