Skip to content

Instantly share code, notes, and snippets.

@psxlover
Created May 14, 2012 16:58
Show Gist options
  • Save psxlover/2695062 to your computer and use it in GitHub Desktop.
Save psxlover/2695062 to your computer and use it in GitHub Desktop.
ISetBlockHandler hook example
package net.minecraft.src;
import net.minecraft.src.forge.ISetBlockHandler;
import net.minecraft.src.forge.MinecraftForge;
public class mod_ProtectSpawnFromTNT extends BaseMod implements ISetBlockHandler {
@Override
public boolean onBlockBeingPlaced(World w, int x, int y, int z, int blockID, int metadata) {
WorldInfo wI = w.worldInfo;
if (blockID == 46 && Math.abs(wI.getSpawnX() - x) < 100 && Math.abs(wI.getSpawnZ() - z) < 100) {
return true;
}
return false;
}
@Override
public String getVersion() {
return "0";
}
@Override
public void load() {
MinecraftForge.registerSetBlockHandler(this);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment