Last active
August 29, 2015 14:01
-
-
Save AbrarSyed/515c251f06e09fd72174 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface IMultiBlockHandler | |
{ | |
public void addMember(World world, int x, int y, int z); | |
public void addSpecialHandler(Object obj); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** 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