当前位置: 首页>>代码示例>>Java>>正文


Java UseHoeEvent.getEntityPlayer方法代码示例

本文整理汇总了Java中net.minecraftforge.event.entity.player.UseHoeEvent.getEntityPlayer方法的典型用法代码示例。如果您正苦于以下问题:Java UseHoeEvent.getEntityPlayer方法的具体用法?Java UseHoeEvent.getEntityPlayer怎么用?Java UseHoeEvent.getEntityPlayer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraftforge.event.entity.player.UseHoeEvent的用法示例。


在下文中一共展示了UseHoeEvent.getEntityPlayer方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onUseHoe

import net.minecraftforge.event.entity.player.UseHoeEvent; //导入方法依赖的package包/类
@SubscribeEvent
public static void onUseHoe(UseHoeEvent event) {
    EntityPlayer player = event.getEntityPlayer();
    World world = event.getWorld();
    BlockPos pos = event.getPos();
    IBlockState state = world.getBlockState(pos);
    Block block = state.getBlock();

    if (block == GenesisBlocks.HUMUS || block == GenesisBlocks.HUMUS_PATH) {
        world.playSound(player, pos, SoundEvents.ITEM_HOE_TILL, SoundCategory.BLOCKS, 1.0F, 1.0F);

        if (!world.isRemote) {
            IBlockState farmland = GenesisBlocks.HUMUS_FARMLAND.getDefaultState();
            world.setBlockState(pos, farmland, WorldFlags.UPDATE_BLOCK_AND_CLIENT_AND_RERENDER_ON_MAIN);
        }

        event.setResult(Event.Result.ALLOW);
    }
}
 
开发者ID:Boethie,项目名称:Genesis,代码行数:20,代码来源:GenesisEventHandler.java

示例2: onUseHoeEvent

import net.minecraftforge.event.entity.player.UseHoeEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onUseHoeEvent(UseHoeEvent event) {
    if (ModBlocks.customFarmLand == null) {
        return;
    }

    World world = event.getWorld();
    BlockPos pos = event.getPos();
    EntityPlayer player = event.getEntityPlayer();
    ItemStack stack = event.getCurrent();

    IBlockState iblockstate = world.getBlockState(pos);
    Block block = iblockstate.getBlock();

    if (world.isAirBlock(pos.up())) {
        if (block == Blocks.GRASS) {
            event.setCanceled(true);
            useHoe(stack, player, world, pos, ModBlocks.customFarmLand.getDefaultState());
        } else if (block == Blocks.DIRT) {
            switch (iblockstate.getValue(BlockDirt.VARIANT)) {
                case DIRT:
                    event.setCanceled(true);
                    useHoe(stack, player, world, pos, ModBlocks.customFarmLand.getDefaultState());
                    break;
                case COARSE_DIRT:
                    event.setCanceled(true);
                    useHoe(stack, player, world, pos, Blocks.DIRT.getDefaultState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.DIRT));
                    break;
            }
        }
    }
}
 
开发者ID:McJty,项目名称:AquaMunda,代码行数:33,代码来源:ForgeEventHandlers.java


注:本文中的net.minecraftforge.event.entity.player.UseHoeEvent.getEntityPlayer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。