本文整理汇总了Java中cpw.mods.fml.common.eventhandler.Event.Result.ALLOW属性的典型用法代码示例。如果您正苦于以下问题:Java Result.ALLOW属性的具体用法?Java Result.ALLOW怎么用?Java Result.ALLOW使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类cpw.mods.fml.common.eventhandler.Event.Result
的用法示例。
在下文中一共展示了Result.ALLOW属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onWorldDecoration
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onWorldDecoration(DecorateBiomeEvent.Decorate event)
{
if ((event.getResult() == Result.ALLOW || event.getResult() == Result.DEFAULT) && event.type == EventType.FLOWERS)
{
for(int i = 0; i < 2; i++)
{
int x = event.chunkX + event.rand.nextInt(16) + 8;
int z = event.chunkZ + event.rand.nextInt(16) + 8;
int y = event.world.getTopSolidOrLiquidBlock(x, z);
if(event.world.isAirBlock(x, y, z) && Blocks.flower_pot.canBlockStay(event.world, x, y, z) && ConfigPrimitiveCraft.genrocks)
{
event.world.setBlock(x, y, z, ModBlocks.rock);
}
else if(event.world.getBlock(x, y, z) == Blocks.water && ConfigPrimitiveCraft.genshale)
{
event.world.setBlock(x, y-1, z, ModBlocks.shale);
}
}
}
}
示例2: onItemUse
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;
}
}
}
示例3: onItemUse
@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;
}
}
}
示例4: applyBonemeal
public static boolean applyBonemeal(ItemStack itemstack, World world, int x, int y, int z, EntityPlayer player) {
Block block = world.getBlock(x, y, z);
BonemealEvent event = new BonemealEvent(player, world, block, x, y, z);
if (MinecraftForge.EVENT_BUS.post(event)) {
return false;
}
if (event.getResult() == Result.ALLOW) {
if (!world.isRemote) {
itemstack.stackSize--;
}
return true;
}
if (block instanceof IGrowable) {
IGrowable igrowable = (IGrowable) block;
if (igrowable.func_149851_a(world, x, y, z, world.isRemote)) {
if (!world.isRemote) {
if (igrowable.func_149852_a(world, world.rand, x, y, z)) {
igrowable.func_149853_b(world, world.rand, x, y, z);
}
}
return true;
}
}
return false;
}
示例5: onItemUse
/**
* 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 doesn't. This is for ITEMS, not BLOCKS
*/
public boolean onItemUse(ItemStack itemStack, EntityPlayer entityPlayer, World world, int blockX, int blockY,
int blockZ, int blockSide, float pointX, float pointY, float pointZ) {
if (!entityPlayer.canPlayerEdit(blockX, blockY, blockZ, blockSide, itemStack)) {
return false;
} else {
UseSandRakeEvent event = new UseSandRakeEvent(entityPlayer, itemStack, world, blockX, blockY, blockZ);
if (MinecraftForge.EVENT_BUS.post(event)) {
return false;
}
if (event.getResult() == Result.ALLOW) {
itemStack.damageItem(1, entityPlayer);
return true;
}
Block block = world.getBlock(blockX, blockY, blockZ);
if (blockSide != 0 && world.getBlock(blockX, blockY + 1, blockZ).isAir(world, blockX, blockY + 1, blockZ)
&& (block == ModBlocks.blockBlackSand)) {
Block sand = Blocks.sand;
Block farmSand = ModBlocks.blockFarmsand;
world.playSoundEffect((double) ((float) blockX + 0.5F), (double) ((float) blockY + 0.5F),
(double) ((float) blockZ + 0.5F), sand.stepSound.getStepResourcePath(),
(sand.stepSound.getVolume() + 1.0F) / 2.0F, sand.stepSound.getPitch() * 0.8F);
if (world.isRemote) {
return true;
} else {
world.setBlock(blockX, blockY, blockZ, farmSand);
itemStack.damageItem(1, entityPlayer);
return true;
}
} else {
return false;
}
}
}
示例6: applyBonemeal
public static boolean applyBonemeal(World world, int x, int y, int z, EntityPlayer player)
{
Block block = world.getBlock(x, y, z);
BonemealEvent event = new BonemealEvent(player, world, block, x, y, z);
if (MinecraftForge.EVENT_BUS.post(event))
{
return false;
}
if (event.getResult() == Result.ALLOW)
{
return true;
}
if (block instanceof IGrowable)
{
IGrowable igrowable = (IGrowable) block;
if (igrowable.func_149851_a(world, x, y, z, world.isRemote))
{
if (!world.isRemote)
{
if (igrowable.func_149852_a(world, world.rand, x, y, z))
{
igrowable.func_149853_b(world, world.rand, x, y, z);
}
}
return true;
}
}
return false;
}
示例7: getMaxSpawnPackSize
public static int getMaxSpawnPackSize(EntityLiving entity)
{
LivingPackSizeEvent maxCanSpawnEvent = new LivingPackSizeEvent(entity);
MinecraftForge.EVENT_BUS.post(maxCanSpawnEvent);
return maxCanSpawnEvent.getResult() == Result.ALLOW ? maxCanSpawnEvent.maxPackSize : entity.func_70641_bl();
}
示例8: getMaxSpawnPackSize
public static int getMaxSpawnPackSize(EntityLiving entity)
{
LivingPackSizeEvent maxCanSpawnEvent = new LivingPackSizeEvent(entity);
MinecraftForge.EVENT_BUS.post(maxCanSpawnEvent);
return maxCanSpawnEvent.getResult() == Result.ALLOW ? maxCanSpawnEvent.maxPackSize : entity.getMaxSpawnedInChunk();
}
示例9: isGenerationAllowed
private static boolean isGenerationAllowed(final DecorateBiomeEvent.Decorate event) {
return (event.getResult() == Result.ALLOW || event.getResult() == Result.DEFAULT)
&& event.type == EventType.FLOWERS && isGenAllowedInDimension(event.world.provider.dimensionId);
}
示例10: onItemUse
/**
* 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);
}
示例11: onItemUse
@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;
}
}
}
}
示例12: useHoe
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;
}
}
}
示例13: onItemUse
@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;
}
}
}
示例14: onItemUse
@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;
}
}
}
示例15: onItemUse
/**
* 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
*/
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 = Blocks.farmland;
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;
}
}
}