Skip to content

Instantly share code, notes, and snippets.

@Unh0lyTigg
Created January 5, 2015 19:41
Show Gist options
  • Save Unh0lyTigg/7d3e56115137fe1d94e6 to your computer and use it in GitHub Desktop.
Save Unh0lyTigg/7d3e56115137fe1d94e6 to your computer and use it in GitHub Desktop.
public class DeVoid {
@AutoSubscribe
public static DeVoid INSTANCE = new DeVoid();
@SubscribeEvent
public void worldLoad(WorldEvent.Load event) {
if (!event.world.getGameRules().hasRule("doesVoidKillPlayer")) {
event.world.getGameRules().addGameRule("doesVoidKillPlayer", "true", ValueType.BOOLEAN_VALUE);
TiggCore.LOGGER.info("Added doesVoidKillPlayer gamerule to " + event.world.getSaveHandler().getWorldDirectoryName() + "\\" + event.world.provider.getDimensionName());
}
}
@SubscribeEvent
public void undoDamage(LivingAttackEvent event) {
if (event.entity.worldObj.getGameRules().getGameRuleBooleanValue("doesVoidKillPlayer"))
return;
if (event.source == DamageSource.outOfWorld) {
if (event.entityLiving instanceof EntityPlayer)
event.setCanceled(true);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment