Example usage for net.minecraftforge.event.world BlockEvent BlockEvent

List of usage examples for net.minecraftforge.event.world BlockEvent BlockEvent

Introduction

In this page you can find the example usage for net.minecraftforge.event.world BlockEvent BlockEvent.

Prototype

public BlockEvent(IWorld world, BlockPos pos, BlockState state) 

Source Link

Usage

From source file:org.spongepowered.mod.event.SpongeForgeEventFactory.java

License:MIT License

public static BlockEvent createBlockEvent(Event event) {
    if (!(event instanceof ChangeBlockEvent)) {
        throw new IllegalArgumentException("Event is not a valid ChangeBlockEvent.");
    }//w w  w .  ja  v a 2s . c o  m

    ChangeBlockEvent spongeEvent = (ChangeBlockEvent) event;
    Location<World> location = spongeEvent.getTransactions().get(0).getOriginal().getLocation().get();
    net.minecraft.world.World world = (net.minecraft.world.World) location.getExtent();
    BlockPos pos = new BlockPos(location.getBlockX(), location.getBlockY(), location.getBlockZ());
    BlockEvent forgeEvent = new BlockEvent(world, pos, world.getBlockState(pos));
    return forgeEvent;
}