mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-12 08:17:35 +00:00
Merge remote-tracking branch 'origin/pr/3110' into 1.10.x
This commit is contained in:
commit
cace1f00b2
5 files changed
+81
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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -27,6 +27,7 @@ import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.event.ForgeEventFactory;
|
||||
|
||||
/**
|
||||
* This is a fluid block implementation which emulates vanilla Minecraft fluid behavior.
|
||||
@@ -102,6 +103,17 @@ public class BlockFluidClassic extends BlockFluidBase
|
||||
@Override
|
||||
public void updateTick(World world, BlockPos pos, IBlockState state, Random rand)
|
||||
{
|
||||
if (!isSourceBlock(world, pos) && ForgeEventFactory.canCreateFluidSource(world, pos, state, false))
|
||||
{
|
||||
int adjacentSourceBlocks =
|
||||
(isSourceBlock(world, pos.north()) ? 1 : 0) +
|
||||
(isSourceBlock(world, pos.south()) ? 1 : 0) +
|
||||
(isSourceBlock(world, pos.east()) ? 1 : 0) +
|
||||
(isSourceBlock(world, pos.west()) ? 1 : 0);
|
||||
if (adjacentSourceBlocks >= 2 && (world.getBlockState(pos.up(densityDir)).getMaterial().isSolid() || isSourceBlock(world, pos.up(densityDir))))
|
||||
world.setBlockState(pos, state.withProperty(LEVEL, 0));
|
||||
}
|
||||
|
||||
int quantaRemaining = quantaPerBlock - state.getValue(LEVEL);
|
||||
int expQuanta = -101;
|
||||
|
||||
|
||||
Reference in new issue
Block a user