mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-18 11:29:15 +00:00
Added Fluid Place Block Event for when fluid changes blocks in world. (#4627)
This commit is contained in:
1 parent
0e4d73230b
commit
1007d3e9c5
7 files changed
+148
-7
No files matched your search
@@ -0,0 +1,45 @@
|
||||
package net.minecraftforge.debug;
|
||||
|
||||
import net.minecraft.block.BlockStone;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.biome.BiomeHills;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.world.BlockEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
|
||||
/**
|
||||
* This test will:
|
||||
* - Cause lava to turn into gold when touched by water.
|
||||
* - Replace the result of a cobblestone generator with granite.
|
||||
* - Replace the result of a stone generator with either diamond, or emerald when in a biome where emerald spawns naturally.
|
||||
* - Prevent lava from setting surrounding blocks on fire.
|
||||
*/
|
||||
@Mod(modid = "fluidplaceblocktest", name = "FluidPlaceBlockTest", version = "0.0.0", acceptableRemoteVersions = "*")
|
||||
public class FluidPlaceBlockTest
|
||||
{
|
||||
private static final boolean ENABLED = false;
|
||||
|
||||
@Mod.EventHandler
|
||||
public void preinit(FMLPreInitializationEvent event)
|
||||
{
|
||||
if (!ENABLED) return;
|
||||
MinecraftForge.EVENT_BUS.register(FluidPlaceBlockTest.class);
|
||||
}
|
||||
|
||||
@SubscribeEvent @SuppressWarnings("unused")
|
||||
public static void onFluidPlaceBlockEvent(BlockEvent.FluidPlaceBlockEvent event)
|
||||
{
|
||||
if (event.getState().getBlock() == Blocks.OBSIDIAN) event.setNewState(Blocks.GOLD_BLOCK.getDefaultState());
|
||||
if (event.getState().getBlock() == Blocks.COBBLESTONE) event.setNewState(Blocks.STONE.getDefaultState().withProperty(BlockStone.VARIANT, BlockStone.EnumType.GRANITE));
|
||||
if (event.getState() == Blocks.STONE.getDefaultState())
|
||||
{
|
||||
Biome biome = event.getWorld().getBiome(event.getPos());
|
||||
if (biome instanceof BiomeHills) event.setNewState(Blocks.EMERALD_BLOCK.getDefaultState());
|
||||
else event.setNewState(Blocks.DIAMOND_BLOCK.getDefaultState());
|
||||
}
|
||||
if (event.getState().getBlock() == Blocks.FIRE) event.setNewState(event.getOriginalState());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user