本文整理汇总了Java中net.minecraftforge.event.entity.player.UseHoeEvent类的典型用法代码示例。如果您正苦于以下问题:Java UseHoeEvent类的具体用法?Java UseHoeEvent怎么用?Java UseHoeEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
UseHoeEvent类属于net.minecraftforge.event.entity.player包,在下文中一共展示了UseHoeEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
}
示例2: onItemUse
import net.minecraftforge.event.entity.player.UseHoeEvent; //导入依赖的package包/类
public boolean onItemUse(final ItemStack p_77648_1_, final EntityPlayer p_77648_2_, final World p_77648_3_, final int p_77648_4_, final int p_77648_5_, final int p_77648_6_, final int p_77648_7_, final float p_77648_8_, final float p_77648_9_, final float p_77648_10_) {
if (!p_77648_2_.canPlayerEdit(p_77648_4_, p_77648_5_, p_77648_6_, p_77648_7_, p_77648_1_)) {
return false;
}
final UseHoeEvent event = new UseHoeEvent(p_77648_2_, p_77648_1_, p_77648_3_, p_77648_4_, p_77648_5_, p_77648_6_);
if (MinecraftForge.EVENT_BUS.post((Event)event)) {
return false;
}
if (event.getResult() == Event.Result.ALLOW) {
return true;
}
final Block block = p_77648_3_.getBlock(p_77648_4_, p_77648_5_, p_77648_6_);
if (p_77648_7_ == 0 || !p_77648_3_.getBlock(p_77648_4_, p_77648_5_ + 1, p_77648_6_).isAir((IBlockAccess)p_77648_3_, p_77648_4_, p_77648_5_ + 1, p_77648_6_) || (block != Blocks.grass && block != Blocks.dirt)) {
return false;
}
final Block block2 = Blocks.farmland;
p_77648_3_.playSoundEffect((double)(p_77648_4_ + 0.5f), (double)(p_77648_5_ + 0.5f), (double)(p_77648_6_ + 0.5f), block2.stepSound.getStepResourcePath(), (block2.stepSound.getVolume() + 1.0f) / 2.0f, block2.stepSound.getPitch() * 0.8f);
if (p_77648_3_.isRemote) {
return true;
}
p_77648_3_.setBlock(p_77648_4_, p_77648_5_, p_77648_6_, block2);
return true;
}
示例3: hoeBlock
import net.minecraftforge.event.entity.player.UseHoeEvent; //导入依赖的package包/类
public static boolean hoeBlock(ItemStack stack, World world, int x, int y, int z, int sideHit, EntityPlayer player){
Block block = world.getBlock(x, y, z);
UseHoeEvent event = new UseHoeEvent(player, stack, world, x, y, z);
if(MinecraftForge.EVENT_BUS.post(event)) //if the event got canceled
return false;
if (event.getResult() == Event.Result.ALLOW) //if another mod handled this block using the event
return true;
//vanilla hoe behaviour
if (sideHit != 0 && world.isAirBlock(x, y + 1, z) && (block == Blocks.grass || block == Blocks.dirt) && player.canPlayerEdit(x, y, z, sideHit, stack)) {
if (!world.isRemote)
world.setBlock(x, y, z, Blocks.farmland);
return true;
}
return false;
}
示例4: hoeUsed
import net.minecraftforge.event.entity.player.UseHoeEvent; //导入依赖的package包/类
@Override
public void hoeUsed(UseHoeEvent event) {
EnumFertility fertility = getFertility(event.world, event.pos);
IBlockState newState = BlocksVC.farmland.getDefaultState().withProperty(BlockFarmlandVC.fertility, fertility);
event.world.playSoundEffect((double)((float)event.entityPlayer.posX + 0.5F), (double)((float)event.entityPlayer.posY + 0.5F), (double)((float)event.entityPlayer.posZ + 0.5F), newState.getBlock().stepSound.getStepSound(), (newState.getBlock().stepSound.getVolume() + 1.0F) / 2.0F, newState.getBlock().stepSound.getFrequency() * 0.8F);
event.world.setBlockState(event.pos, newState);
TEFarmland tileentity = (TEFarmland)event.world.getTileEntity(event.pos);
if (tileentity != null) {
tileentity.setFertility(fertility.getAsNumber());
} else {
System.out.println("tileentity was not created?");
}
event.setResult(Result.ALLOW);
event.entityPlayer.addExhaustion(0.1f);
super.hoeUsed(event);
}
示例5: onUseHoe
import net.minecraftforge.event.entity.player.UseHoeEvent; //导入依赖的package包/类
@SubscribeEvent
public void onUseHoe(UseHoeEvent event) {
Block oblock = event.world.getBlock(event.x, event.y, event.z);
if (LongHoe.AOEEnabled && event.current.getItem() instanceof LongHoe && (oblock instanceof BlockDirt || oblock instanceof BlockGrass)) {
LongHoe.AOEEnabled = false;
for (int x = event.x - 3; x < event.x + 3; x++) {
for (int z = event.z - 3; z < event.z + 3; z++) {
Block block = event.world.getBlock(x, event.y, z);
if ((!(x == event.x && z == event.z)) && (block instanceof BlockDirt || block instanceof BlockGrass) && (!MinecraftForge.EVENT_BUS.post(new UseHoeEvent(event.entityPlayer, event.current, event.world, x, event.y, z)))) {
event.world.setBlock(x, event.y, z, Blocks.farmland);
if (event.world.getBlock(x, event.y + 1, z).isReplaceable(event.world, x, event.y + 1, z)) {
event.world.setBlockToAir(x, event.y + 1, z);
}
DerpyItems.damageItem(event.current, 1, event.entityPlayer);
}
}
}
LongHoe.AOEEnabled = true;
}
}
示例6: onHoeEvent
import net.minecraftforge.event.entity.player.UseHoeEvent; //导入依赖的package包/类
public static void onHoeEvent(UseHoeEvent event) {
if (EtFuturum.enableCoarseDirt) {
World world = event.world;
if (world.getBlock(event.x, event.y, event.z) == ModBlocks.coarse_dirt) {
world.setBlock(event.x, event.y, event.z, Blocks.dirt);
world.playSoundEffect(event.x + 0.5F, event.y + 0.5F, event.z + 0.5F, Block.soundTypeGravel.getStepResourcePath(), 1.0F, 0.8F);
event.setResult(Result.ALLOW);
}
}
}
示例7: onHoeUse
import net.minecraftforge.event.entity.player.UseHoeEvent; //导入依赖的package包/类
public static int onHoeUse(ItemStack stack, EntityPlayer player, World worldIn, BlockPos pos)
{
UseHoeEvent event = new UseHoeEvent(player, stack, worldIn, pos);
if (MinecraftForge.EVENT_BUS.post(event)) return -1;
if (event.getResult() == Result.ALLOW)
{
stack.damageItem(1, player);
return 1;
}
return 0;
}
示例8: onHoe
import net.minecraftforge.event.entity.player.UseHoeEvent; //导入依赖的package包/类
@SubscribeEvent
public void onHoe(UseHoeEvent event) {
if (!event.getCurrent().isEmpty()) {
if (disabledItems.contains(event.getCurrent().getItem()))
event.setCanceled(true);
}
}
示例9: onItemUse
import net.minecraftforge.event.entity.player.UseHoeEvent; //导入依赖的package包/类
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
if (!player.canPlayerEdit(x, y, z, side, stack)) {
return false;
} else {
UseHoeEvent event = new UseHoeEvent(player, stack, world, x, y, z);
if (MinecraftForge.EVENT_BUS.post(event)) {
return false;
}
if (event.getResult() == Result.ALLOW) {
stack.damageItem(1, player);
return true;
}
Block block = world.getBlock(x, y, z);
if (side != 0 && world.getBlock(x, y + 1, z).isAir(world, x, y + 1, z) && (block == Blocks.grass || block == Blocks.dirt)) {
Block block1 = Blocks.farmland;
world.playSoundEffect((double)((float)x + 0.5F), (double)((float)y + 0.5F), (double)((float)z + 0.5F), block1.stepSound.getStepResourcePath(), (block1.stepSound.getVolume() + 1.0F) / 2.0F, block1.stepSound.getPitch() * 0.8F);
if (world.isRemote) {
return true;
} else {
world.setBlock(x, y, z, block1);
stack.damageItem(1, player);
return true;
}
} else {
return false;
}
}
}
示例10: 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;
}
}
}
}
示例11: onItemUse
import net.minecraftforge.event.entity.player.UseHoeEvent; //导入依赖的package包/类
@Override
public boolean onItemUse(ItemStack itemstack, EntityPlayer player, World world, int x, int y, int z, int blockMeta, float blockX, float blockY, float blockZ) { //Taken from vanilla code
if (!player.canPlayerEdit(x, y, z, blockMeta, itemstack)) {
return false;
}
else {
UseHoeEvent event = new UseHoeEvent(player, itemstack, world, x, y, z);
if (MinecraftForge.EVENT_BUS.post(event)) {
return false;
}
if (event.getResult() == Event.Result.ALLOW) {
itemstack.damageItem(1, player);
return true;
}
Block block = world.getBlock(x, y, z);
if (blockMeta != 0 && world.getBlock(x, y + 1, z).isAir(world, x, y + 1, z) && (block == Blocks.grass || block == Blocks.dirt)) {
Block block1 = Blocks.farmland;
world.playSoundEffect((double)((float)x + 0.5F), (double)((float)y + 0.5F), (double)((float)z + 0.5F), block1.stepSound.getStepResourcePath(), (block1.stepSound.getVolume() + 1.0F) / 2.0F, block1.stepSound.getPitch() * 0.8F);
if (world.isRemote) {
return true;
}
else {
world.setBlock(x, y, z, block1);
itemstack.damageItem(1, player);
return true;
}
}
else {
return false;
}
}
}
示例12: onItemUse
import net.minecraftforge.event.entity.player.UseHoeEvent; //导入依赖的package包/类
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int posX, int posY, int posZ, int p_77648_7_, float p_77648_8_, float p_77648_9_, float p_77648_10_) {
if (!player.canPlayerEdit(posX, posY, posZ, p_77648_7_, stack)) {
return false;
} else {
UseHoeEvent event = new UseHoeEvent(player, stack, world, posX, posY, posZ);
if (MinecraftForge.EVENT_BUS.post(event)) {
return false;
}
if (event.getResult() == Result.ALLOW) {
if (stack.getItemDamage() >= this.getMaxDamage()) {
player.setCurrentItemOrArmor(0, new ItemStack(Items.iron_hoe, 1, 0));
return true;
}
stack.damageItem(1, player);
return true;
}
Block block = world.getBlock(posX, posY, posZ);
if (p_77648_7_ != 0 && world.getBlock(posX, posY + 1, posZ).isAir(world, posX, posY + 1, posZ) && (block == Blocks.grass || block == Blocks.dirt)) {
Block block1 = Blocks.farmland;
world.playSoundEffect((double)((float)posX + 0.5F), (double)((float)posZ + 0.5F), (double)((float)posZ + 0.5F), block1.stepSound.getStepResourcePath(), (block1.stepSound.getVolume() + 1.0F) / 2.0F, block1.stepSound.getPitch() * 0.8F);
if (world.isRemote) {
return true;
} else {
world.setBlock(posX, posY, posZ, block1);
if (stack.getItemDamage() >= this.getMaxDamage()) {
player.setCurrentItemOrArmor(0, new ItemStack(Items.iron_hoe, 1, 0));
return true;
}
stack.damageItem(1, player);
return true;
}
} else {
return false;
}
}
}
示例13: onEvent
import net.minecraftforge.event.entity.player.UseHoeEvent; //导入依赖的package包/类
@SubscribeEvent
public void onEvent(UseHoeEvent event) {
Block block = event.world.getBlockState(event.pos).getBlock();
if (block instanceof BlockVC) {
((BlockVC)block).hoeUsed(event);
}
}
示例14: onUseHoe
import net.minecraftforge.event.entity.player.UseHoeEvent; //导入依赖的package包/类
@SubscribeEvent
public void onUseHoe(UseHoeEvent event){
Block b = event.getWorld().getBlockState(event.getPos()).getBlock();
if(b == ACBlocks.dreadlands_grass || b == ACBlocks.dreadlands_dirt){
event.getWorld().playSound(event.getEntityPlayer(), event.getPos(), SoundEvents.ITEM_HOE_TILL, SoundCategory.BLOCKS, 1.0F, 1.0F);
if(!event.getWorld().isRemote)
event.getWorld().setBlockState(event.getPos(), Blocks.FARMLAND.getDefaultState());
event.setResult(Result.ALLOW);
}
}
示例15: onHoeEvent
import net.minecraftforge.event.entity.player.UseHoeEvent; //导入依赖的package包/类
@SubscribeEvent
public void onHoeEvent(UseHoeEvent parEvent)
{
if (parEvent.world.isRemote || parEvent.entityPlayer.capabilities.isCreativeMode) return;
IBlockState block = parEvent.world.getBlockState(parEvent.pos);
if (block.equals(Blocks.grass.getDefaultState()) || block.equals(Blocks.dirt.getDefaultState()))
{
if (parEvent.world.rand.nextInt(18) == 0)
{
parEvent.world.spawnEntityInWorld(new EntityItem(parEvent.world, parEvent.pos.getX(), parEvent.pos.getY(), parEvent.pos.getZ(), new ItemStack(_Beetroot.beetrootSeeds)));
}
}
}