mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-19 03:49:14 +00:00
Add CreateFluidSourceEvent to control infinite fluid sources
This commit is contained in:
1 parent
d7245c5ffe
commit
b95d443f22
3 files changed
+37
No files matched your search
@@ -98,6 +98,7 @@ import net.minecraftforge.event.entity.player.UseHoeEvent;
|
||||
import net.minecraftforge.event.terraingen.ChunkGeneratorEvent;
|
||||
import net.minecraftforge.event.terraingen.PopulateChunkEvent;
|
||||
import net.minecraftforge.event.world.BlockEvent;
|
||||
import net.minecraftforge.event.world.BlockEvent.CreateFluidSourceEvent;
|
||||
import net.minecraftforge.event.world.BlockEvent.MultiPlaceEvent;
|
||||
import net.minecraftforge.event.world.BlockEvent.NeighborNotifyEvent;
|
||||
import net.minecraftforge.event.world.BlockEvent.PlaceEvent;
|
||||
@@ -585,4 +586,13 @@ public class ForgeEventFactory
|
||||
return event.getTable();
|
||||
}
|
||||
|
||||
public static boolean canCreateFluidSource(World world, BlockPos pos, IBlockState state, boolean def)
|
||||
{
|
||||
CreateFluidSourceEvent evt = new CreateFluidSourceEvent(world, pos, state);
|
||||
MinecraftForge.EVENT_BUS.post(evt);
|
||||
|
||||
Result result = evt.getResult();
|
||||
return result == Result.DEFAULT ? def : result == Result.ALLOW;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -252,4 +252,20 @@ public class BlockEvent extends Event
|
||||
return notifiedSides;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fired to check whether a non-source block can turn into a source block.
|
||||
* A result of ALLOW causes a source block to be created even if the liquid
|
||||
* usually doesn't do that (like lava), and a result of DENY prevents creation
|
||||
* even if the liquid usually does do that (like water).
|
||||
*/
|
||||
@HasResult
|
||||
public static class CreateFluidSourceEvent extends BlockEvent
|
||||
{
|
||||
public CreateFluidSourceEvent(World world, BlockPos pos, IBlockState state)
|
||||
{
|
||||
super(world, pos, state);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user