本文整理汇总了Java中net.minecraftforge.event.entity.player.UseHoeEvent.getResult方法的典型用法代码示例。如果您正苦于以下问题:Java UseHoeEvent.getResult方法的具体用法?Java UseHoeEvent.getResult怎么用?Java UseHoeEvent.getResult使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraftforge.event.entity.player.UseHoeEvent
的用法示例。
在下文中一共展示了UseHoeEvent.getResult方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: 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;
}
示例4: 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;
}
}
}
示例5: 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;
}
}
}
示例6: 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;
}
}
}
示例7: onItemUse
import net.minecraftforge.event.entity.player.UseHoeEvent; //导入方法依赖的package包/类
/**
* Callback for item usage. If the item does something special on right clicking, he will have one of those. Return
* True if something happen and false if it don't. This is for ITEMS, not BLOCKS
*/
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ)
{
if(this.hasEnoughEnergyAndMode(stack, energyCostUseSmall, Mode.HOE)) {
//if(this.getMode(stack) == Mode.HOE) {
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)
{
this.consumePower(stack, player, energyCostUseSmall);
//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);
this.consumePower(stack, player, energyCostUseSmall);
return true;
}
}
else
{
return false;
}
}
}
return super.onItemUse(stack, player, world, x, y, z, side, hitX, hitY, hitZ);
}
示例8: onItemUse
import net.minecraftforge.event.entity.player.UseHoeEvent; //导入方法依赖的package包/类
@Override
public boolean onItemUse(ItemStack itemstack, EntityPlayer entityplayer, World world, int x, int y, int z, int side, float entityX, float entityY, float entityZ)
{
if(!entityplayer.canPlayerEdit(x, y, z, side, itemstack))
{
return false;
}
else {
UseHoeEvent event = new UseHoeEvent(entityplayer, itemstack, world, x, y, z);
if(MinecraftForge.EVENT_BUS.post(event))
{
return false;
}
if(event.getResult() == Result.ALLOW)
{
itemstack.damageItem(1, entityplayer);
return true;
}
Block blockID = world.getBlock(x, y, z);
Block aboveBlock = world.getBlock(x, y + 1, z);
if((side == 0 || !aboveBlock.isAir(world, x, y, z+1) || blockID != Blocks.grass) && blockID != Blocks.dirt)
{
return false;
}
else {
Block block = Blocks.farmland;
world.playSoundEffect(x + 0.5F, y + 0.5F, z + 0.5F, block.stepSound.getStepResourcePath(), (block.stepSound.getVolume() + 1.0F) / 2.0F, block.stepSound.getPitch() * 0.8F);
if(world.isRemote)
{
return true;
}
else {
world.setBlock(x, y, z, block);
itemstack.damageItem(1, entityplayer);
return true;
}
}
}
}
示例9: useHoe
import net.minecraftforge.event.entity.player.UseHoeEvent; //导入方法依赖的package包/类
private boolean useHoe(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side)
{
if(!player.canPlayerEdit(x, y, z, side, stack) || (!player.capabilities.isCreativeMode && getEnergy(stack) < HOE_USAGE))
{
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)
{
setEnergy(stack, getEnergy(stack)-HOE_USAGE);
return true;
}
Block block1 = world.getBlock(x, y, z);
boolean air = world.isAirBlock(x, y + 1, z);
if(side != 0 && air && (block1 == Blocks.grass || block1 == Blocks.dirt))
{
Block farm = Blocks.farmland;
world.playSoundEffect(x + 0.5F, y + 0.5F, z + 0.5F, farm.stepSound.getStepResourcePath(), (farm.stepSound.getVolume() + 1.0F) / 2.0F, farm.stepSound.getPitch() * 0.8F);
if(world.isRemote)
{
return true;
}
else {
world.setBlock(x, y, z, farm);
if(!player.capabilities.isCreativeMode)
{
setEnergy(stack, getEnergy(stack)-HOE_USAGE);
}
return true;
}
}
else {
return false;
}
}
}
示例10: onItemUse
import net.minecraftforge.event.entity.player.UseHoeEvent; //导入方法依赖的package包/类
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int par7, float par8, float par9, float par10)
{
// TODO: Make sure this works right.. They can break from this.
if ( !player.canPlayerEdit( x, y, z, par7, stack ) )
{
return false;
}
UseHoeEvent event = new UseHoeEvent( player, stack, world, x, y, z );
if ( MinecraftForge.EVENT_BUS.post( event ) )
{
return false;
}
if ( event.getResult() == Result.ALLOW )
{
damageItemStack( player, stack, 1 );
return true;
}
Block i1 = world.getBlock(x, y, z);
Block j1 = world.getBlock(x, y + 1, z);
if ((par7 == 0 || j1 != air || i1 != grass) && i1 != dirt)
{
return false;
}
else
{
Block block = farmland;
world.playSoundEffect((double)((float)x + 0.5F), (double)((float)y + 0.5F), (double)((float)z + 0.5F), block.stepSound.soundName, (block.stepSound.getVolume() + 1.0F) / 2.0F, block.stepSound.getPitch() * 0.8F);
if (world.isRemote)
{
return true;
}
else
{
world.setBlock(x, y, z, block);
damageItemStack( player, stack, 1 );
return true;
}
}
}
示例11: hoeGround
import net.minecraftforge.event.entity.player.UseHoeEvent; //导入方法依赖的package包/类
public static boolean hoeGround (ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, Random random)
{
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() == Event.Result.ALLOW)
{
//damageTool(stack, 1, player, false);
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);
//damageTool(stack, 1, player, false);
return true;
}
}
else
{
return false;
}
}
}
示例12: onItemUse
import net.minecraftforge.event.entity.player.UseHoeEvent; //导入方法依赖的package包/类
@Override
public boolean onItemUse(ItemStack p_77648_1_, EntityPlayer p_77648_2_, World p_77648_3_, int p_77648_4_, int p_77648_5_, int p_77648_6_, int p_77648_7_, float p_77648_8_, float p_77648_9_, 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;
}
else
{
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))
{
return false;
}
if (event.getResult() == Result.ALLOW)
{
p_77648_1_.damageItem(1, p_77648_2_);
return true;
}
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(p_77648_3_, p_77648_4_, p_77648_5_ + 1, p_77648_6_) && (block == Blocks.grass || block == Blocks.dirt))
{
Block block1 = IlluminatedBlocks.illuminatedFarmland;
p_77648_3_.playSoundEffect((double)((float)p_77648_4_ + 0.5F), (double)((float)p_77648_5_ + 0.5F), (double)((float)p_77648_6_ + 0.5F), block1.stepSound.getStepResourcePath(), (block1.stepSound.getVolume() + 1.0F) / 2.0F, block1.stepSound.getPitch() * 0.8F);
if (p_77648_3_.isRemote)
{
return true;
}
else
{
p_77648_3_.setBlock(p_77648_4_, p_77648_5_, p_77648_6_, block1);
p_77648_1_.damageItem(1, p_77648_2_);
return true;
}
}
else
{
return false;
}
}
}
示例13: onItemUse
import net.minecraftforge.event.entity.player.UseHoeEvent; //导入方法依赖的package包/类
public boolean onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int i, float a, float b, float c)
{
if (!player.canPlayerEdit(x, y, z, i, 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 (i != 0 && world.getBlock(x, y + 1, z).isAir(world, x, y + 1, z) && (block == Blocks.dirt || block == Blocks.grass))
{
Block block1 = ModBlocks.nuggetDirt;
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 + 1, z, block1);
itemStack.damageItem(1, player);
return true;
}
}
else
{
return false;
}
}
}
示例14: onItemUse
import net.minecraftforge.event.entity.player.UseHoeEvent; //导入方法依赖的package包/类
public boolean onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int i, float a, float b, float c)
{
if (!player.canPlayerEdit(x, y, z, i, 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 (i != 0 && world.getBlock(x, y + 1, z).isAir(world, x, y + 1, z) && (block == Blocks.dirt || block == Blocks.grass))
{
Block block1 = ModBlocks.chunkyDirt;
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;
}
}
}
示例15: hoeGround
import net.minecraftforge.event.entity.player.UseHoeEvent; //导入方法依赖的package包/类
public static boolean hoeGround (ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, Random random)
{
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)
{
onBlockChanged(stack, world, 0, x, y, z, player, random);
return true;
}
int bID = world.getBlockId(x, y, z);
int bIDabove = world.getBlockId(x, y + 1, z);
if ((side == 0 || bIDabove != 0 || bID != Block.grass.blockID) && bID != Block.dirt.blockID)
{
return false;
}
else
{
Block block = Block.tilledField;
world.playSoundEffect((double) ((float) x + 0.5F), (double) ((float) y + 0.5F), (double) ((float) z + 0.5F), block.stepSound.getStepSound(),
(block.stepSound.getVolume() + 1.0F) / 2.0F, block.stepSound.getPitch() * 0.8F);
if (world.isRemote)
{
return true;
}
else
{
world.setBlock(x, y, z, block.blockID);
onBlockChanged(stack, world, 0, x, y, z, player, random);
return true;
}
}
}
}