Skip to content

Instantly share code, notes, and snippets.

@ryantheleach
Created December 8, 2015 19:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryantheleach/b51c50f03eb4058ab714 to your computer and use it in GitHub Desktop.
Save ryantheleach/b51c50f03eb4058ab714 to your computer and use it in GitHub Desktop.
//https://www.reddit.com/r/minecraftsuggestions/comments/3d5l3p/jumping_into_water_while_on_fire_plays_a/
@Listener(order = Order.POST)
public void onPlayerExtinguish(final IgniteEntityEvent event) {
logger.log(Level.WARNING, "Entity Ignited: "+event.getTargetEntity());
int ticksToGo = event.getFireTicks();
Entity entity = event.getTargetEntity();
Sponge.getScheduler().createTaskBuilder()
.intervalTicks(1)
.execute(task -> trackFireEntities(task, entity))
.submit(this);
}
final static Set<BlockType> WATER = Sets.newHashSet(BlockTypes.FLOWING_WATER, BlockTypes.WATER);
public void trackFireEntities(final Task task, final Entity entity){
boolean onFireStill = entity.get(Keys.IS_AFLAME).get();
if(!onFireStill){
logger.log(Level.WARNING, "Extinguished");
task.cancel();
Location<World> location = entity.getLocation();
//if(WATER.contains(location.getBlockType())){
location.getExtent().playSound(SoundTypes.FIZZ, location.getPosition(), 2);
location.getExtent().playSound(SoundTypes.FIZZ, location.getPosition(), 2);
location.getExtent().playSound(SoundTypes.FIZZ, location.getPosition(), 2);
location.getExtent().playSound(SoundTypes.FIZZ, location.getPosition(), 2);
//}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment