當前位置: 首頁>>代碼示例>>Java>>正文


Java Result類代碼示例

本文整理匯總了Java中net.minecraftforge.fml.common.eventhandler.Event.Result的典型用法代碼示例。如果您正苦於以下問題:Java Result類的具體用法?Java Result怎麽用?Java Result使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Result類屬於net.minecraftforge.fml.common.eventhandler.Event包,在下文中一共展示了Result類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onItemUseFirst

import net.minecraftforge.fml.common.eventhandler.Event.Result; //導入依賴的package包/類
@Override  
public EnumActionResult onItemUseFirst(EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) {
	if (world.isRemote) {
      //If its client side we have to return pass so this method is called on server, where we need to perform the op 
      return EnumActionResult.PASS;
    }
	final IBlockState blockState = world.getBlockState(pos);
	IBlockState bs = blockState;
	Block block = bs.getBlock();
	boolean ret = false;
	if (block != null) {
		RightClickBlock e = new RightClickBlock(player, hand, pos,side, new Vec3d(hitX, hitY, hitZ));
		if (MinecraftForge.EVENT_BUS.post(e) || e.getResult() == Result.DENY || e.getUseBlock() == Result.DENY || e.getUseItem() == Result.DENY) {
			return EnumActionResult.PASS;
		}
		if (!player.isSneaking() && block.rotateBlock(world, pos, side)) {
			ret = true;
		} 
   	}
	if (ret) {
		player.swingArm(hand);
	}
	return (ret && !world.isRemote) ? EnumActionResult.SUCCESS : EnumActionResult.PASS;
}
 
開發者ID:Alec-WAM,項目名稱:CrystalMod,代碼行數:25,代碼來源:ItemCrystalWrench.java

示例2: onFillBucket

import net.minecraftforge.fml.common.eventhandler.Event.Result; //導入依賴的package包/類
@SubscribeEvent
public void onFillBucket(FillBucketEvent event) {
    RayTraceResult rtr = event.getTarget();
    if (rtr != null) {
        Block b = event.getWorld().getBlockState(rtr.getBlockPos()).getBlock();
        if (b instanceof IFluidBlock) {
            Fluid fluid = ((IFluidBlock) b).getFluid();
            ItemStack filled = FluidUtil.getFilledBucket(new FluidStack(fluid, 1000));
            if (!filled.isEmpty()) {
                event.setFilledBucket(FluidUtil.getFilledBucket(new FluidStack(fluid, 1000)));
                event.getWorld().setBlockToAir(rtr.getBlockPos());
                event.setResult(Result.ALLOW);
                if (TileEntityRefinery.isInputFluidValid(fluid, 4) && event.getEntityPlayer() instanceof EntityPlayerMP) {
                    AdvancementTriggers.OIL_BUCKET.trigger((EntityPlayerMP) event.getEntityPlayer());
                }
            }
        }
    }
}
 
開發者ID:TeamPneumatic,項目名稱:pnc-repressurized,代碼行數:20,代碼來源:EventHandlerPneumaticCraft.java

示例3: placeKiln

import net.minecraftforge.fml.common.eventhandler.Event.Result; //導入依賴的package包/類
@SubscribeEvent(priority=EventPriority.HIGH)
public void placeKiln(PlayerInteractEvent.RightClickBlock event){
	if(event.getWorld().getBlockState(event.getPos()).getBlock()==BlocksRegistry.potteryKiln){
		event.setUseBlock(Result.ALLOW);
	}else if(!event.isCanceled()&&event.getEntityPlayer().isSneaking()&&PotteryKilnRecipe.isValidInput(event.getItemStack())){
		if(event.getFace()==EnumFacing.UP&&event.getWorld().getBlockState(event.getPos()).isSideSolid(event.getWorld(), event.getPos(), EnumFacing.UP)&&
				event.getWorld().getBlockState(event.getPos().offset(EnumFacing.UP)).getBlock().isReplaceable(event.getWorld(), event.getPos().offset(EnumFacing.UP))){
			if(!event.getWorld().isRemote){
				event.getWorld().setBlockState(event.getPos().offset(EnumFacing.UP), BlocksRegistry.potteryKiln.getDefaultState());
				TilePotteryKiln tile=((TilePotteryKiln)event.getWorld().getTileEntity(event.getPos().offset(EnumFacing.UP)));
				event.getEntityPlayer().setHeldItem(event.getHand(), tile.pottery.insertItem(0, event.getItemStack(), false));
				event.getWorld().playSound(null, event.getPos(), SoundEvents.BLOCK_GRAVEL_PLACE, SoundCategory.BLOCKS, 1F, 1F);
				event.getWorld().notifyBlockUpdate(event.getPos().offset(EnumFacing.UP), BlocksRegistry.potteryKiln.getDefaultState(), BlocksRegistry.potteryKiln.getDefaultState(), 2);
			}
			event.setUseBlock(Result.DENY);
			event.setUseItem(Result.DENY);
		}
	}
}
 
開發者ID:EnderiumSmith,項目名稱:CharcoalPit,代碼行數:20,代碼來源:PileIgnitr.java

示例4: onSpawn

import net.minecraftforge.fml.common.eventhandler.Event.Result; //導入依賴的package包/類
/**
 * Checks spawning
 */
@SubscribeEvent
public void onSpawn(CheckSpawn event) {
	//If the entity is not a mob or above the forced-spawn-y-level, stop
	if (!(event.getEntity() instanceof EntityMob && event.getY() < underground))
		return;

	EntityMob mob = (EntityMob) event.getEntity();
	String name = EntityList.getEntityString(mob);

	//If whitelist and list contains mob, or blacklist and list does not contain mob
	if ((spawnWhitelist && mobsToSpawn.contains(name)) || (!(spawnWhitelist && mobsToSpawn.contains(name)))){
		//If the chance is within allowed mob-spawn-under-y-level range, and the game is not on Peaceful
		if (rand.nextFloat() < undergroundChance && event.getWorld().getDifficulty() != EnumDifficulty.PEACEFUL){
			//If there are no other entities in this area, and there are no collisions, and there is not a liquid
			if (event.getWorld().checkNoEntityCollision(mob.getEntityBoundingBox())
					&& event.getWorld().getCollisionBoxes(mob, mob.getEntityBoundingBox()).isEmpty()
					&& !event.getWorld().containsAnyLiquid(mob.getEntityBoundingBox())){
				//Allow the spawn
				event.setResult(Result.ALLOW);
			}
		}
	}

}
 
開發者ID:bookerthegeek,項目名稱:Mob-Option-Redux,代碼行數:28,代碼來源:MobOptionsEventHandler.java

示例5: onBucketUse

import net.minecraftforge.fml.common.eventhandler.Event.Result; //導入依賴的package包/類
public static ActionResult<ItemStack> onBucketUse(EntityPlayer player, World world, ItemStack stack, RayTraceResult target)
{
    FillBucketEvent event = new FillBucketEvent(player, stack, world, target);
    if (MinecraftForge.EVENT_BUS.post(event)) return new ActionResult<ItemStack>(EnumActionResult.FAIL, stack);

    if (event.getResult() == Result.ALLOW)
    {
        if (player.capabilities.isCreativeMode)
            return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack);

        if (--stack.stackSize <= 0)
            return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, event.getFilledBucket());

        if (!player.inventory.addItemStackToInventory(event.getFilledBucket()))
            player.dropItem(event.getFilledBucket(), false);

        return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack);
    }
    return null;
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:21,代碼來源:ForgeEventFactory.java

示例6: fogRenderEvent

import net.minecraftforge.fml.common.eventhandler.Event.Result; //導入依賴的package包/類
@SubscribeEvent(priority = EventPriority.LOWEST)
public void fogRenderEvent(final EntityViewRenderEvent.RenderFogEvent event) {
	if (!doFog() || event.getResult() != Result.DEFAULT)
		return;

	final float planeDistance = this.scanner.getPlaneDistance(event.getFarPlaneDistance());
	if (event.getFogMode() < 0) {
		GlStateManager.setFogStart(0F);
		GlStateManager.setFogEnd(planeDistance);
	} else {
		GlStateManager.setFogStart(planeDistance * this.scanner.getPlaneDistanceScale());
		GlStateManager.setFogEnd(planeDistance);
	}

	event.setResult(Result.ALLOW);
}
 
開發者ID:OreCruncher,項目名稱:DynamicSurroundings,代碼行數:17,代碼來源:FogEffectHandler.java

示例7: populate

import net.minecraftforge.fml.common.eventhandler.Event.Result; //導入依賴的package包/類
/** Alters vanilla chunk populating. */
@SubscribeEvent
public void populate(PopulateChunkEvent.Populate event) {
    
    Random rand = event.getRand();        
    
    // Chance of generating rice lake
    if (event.getType() == PopulateChunkEvent.Populate.EventType.LAKE &&
            rand.nextFloat() <= 0.1) {
        
        event.setResult(Result.DENY);
        new PopulateChunkRicelake(event.getWorld(), rand)
                .generateChunk(event.getChunkX(), event.getChunkZ());
        return;
    }
}
 
開發者ID:JayAvery,項目名稱:geomastery,代碼行數:17,代碼來源:WorldGenerator.java

示例8: oreGenMinable

import net.minecraftforge.fml.common.eventhandler.Event.Result; //導入依賴的package包/類
/** Alters vanilla ore generation. */
@SubscribeEvent
public void oreGenMinable(OreGenEvent.GenerateMinable event) {

    OreGenEvent.GenerateMinable.EventType type = event.getType();

    // Cancel vanilla ores to be overriden
    if (type == OreGenEvent.GenerateMinable.EventType.COAL ||
            type == OreGenEvent.GenerateMinable.EventType.DIAMOND ||
            type == OreGenEvent.GenerateMinable.EventType.EMERALD ||
            type == OreGenEvent.GenerateMinable.EventType.GOLD ||
            type == OreGenEvent.GenerateMinable.EventType.IRON ||
            type == OreGenEvent.GenerateMinable.EventType.LAPIS ||
            type == OreGenEvent.GenerateMinable.EventType.REDSTONE) {

        event.setResult(Event.Result.DENY);
    }
}
 
開發者ID:JayAvery,項目名稱:geomastery,代碼行數:19,代碼來源:WorldGenerator.java

示例9: checkSpawn

import net.minecraftforge.fml.common.eventhandler.Event.Result; //導入依賴的package包/類
/** Reduces animal spawns by half. */
@SubscribeEvent
public void checkSpawn(CheckSpawn event) {

    EntityLivingBase entity  = event.getEntityLiving();
    boolean canSpawn = true;
    
    if (entity instanceof EntityAnimal) {
        
        if (entity.world.rand.nextInt(2) == 0) {
            
            canSpawn = false;
        }
    }

    event.setResult(canSpawn ? Result.DEFAULT : Result.DENY);
}
 
開發者ID:JayAvery,項目名稱:geomastery,代碼行數:18,代碼來源:EntityEvents.java

示例10: genDisabler

import net.minecraftforge.fml.common.eventhandler.Event.Result; //導入依賴的package包/類
@SubscribeEvent
public void genDisabler(OreGenEvent.GenerateMinable event)
{
	EventType type = event.type;
	if (type == EventType.COAL || type == EventType.DIAMOND || type == EventType.GOLD || type == EventType.IRON
			|| type == EventType.LAPIS || type == EventType.QUARTZ || type == EventType.REDSTONE || type == EventType.EMERALD)
	{
		if(ConfigOptions.disableVanillaOres)
		{
			event.setResult(Result.DENY);
		}
	}
	
	else if (type == EventType.ANDESITE || type == EventType.DIORITE || type == EventType.GRANITE || type == EventType.GRAVEL || type == EventType.DIRT)
	{
		if(ConfigOptions.disableVanillaOthers)
		{
			event.setResult(Result.DENY);
		}
	}
}
 
開發者ID:VapourDrive,項目名稱:GenLoader,代碼行數:22,代碼來源:VanillaGenDisabler.java

示例11: spawnHandler

import net.minecraftforge.fml.common.eventhandler.Event.Result; //導入依賴的package包/類
@SubscribeEvent
public void spawnHandler(LivingSpawnEvent.CheckSpawn event)
{
	if((!(event.getEntity() instanceof EntityPlayer))&&(!(event.getWorld().isRemote)))
	{
		if(ScarecrowTracking.get(event.getWorld()).inRange(event.getEntity()))
		{
			if(event.getWorld().getBlockState(event.getEntity().getPosition()).getBlock()==Blocks.FARMLAND)
			{
				event.setResult(Result.DENY);
			}
			if(event.getEntity() instanceof EntityBat)
			{
				event.setResult(Result.DENY);
				// I hate bats
			}
		}
	}
}
 
開發者ID:theishiopian,項目名稱:ForageCraft,代碼行數:20,代碼來源:SpawnHandler.java

示例12: func_180517_a

import net.minecraftforge.fml.common.eventhandler.Event.Result; //導入依賴的package包/類
public void func_180517_a(int p_180517_1_, int p_180517_2_, ChunkPrimer p_180517_3_, BiomeGenBase[] p_180517_4_)
{
	ChunkProviderEvent.ReplaceBiomeBlocks event = new ChunkProviderEvent.ReplaceBiomeBlocks(this, p_180517_1_,
			p_180517_2_, p_180517_3_, this.worldObj);
	MinecraftForge.EVENT_BUS.post(event);
	if (event.getResult() == Result.DENY)
		return;

	double d0 = 0.03125D;
	this.stoneNoise = this.field_147430_m.func_151599_a(this.stoneNoise, (double) (p_180517_1_ * 16),
			(double) (p_180517_2_ * 16), 16, 16, d0 * 2.0D, d0 * 2.0D, 1.0D);

	for (int k = 0; k < 16; ++k)
	{
		for (int l = 0; l < 16; ++l)
		{
			BiomeGenBase biomegenbase = p_180517_4_[l + k * 16];
			biomegenbase.genTerrainBlocks(this.worldObj, this.rand, p_180517_3_, p_180517_1_ * 16 + k,
					p_180517_2_ * 16 + l, this.stoneNoise[l + k * 16]);
		}
	}
}
 
開發者ID:sokratis12GR,項目名稱:MoreDimensions,代碼行數:23,代碼來源:CoalDimension.java

示例13: onBonemealClick

import net.minecraftforge.fml.common.eventhandler.Event.Result; //導入依賴的package包/類
@SubscribeEvent
public void onBonemealClick(BonemealEvent event) 
{
	World world = event.world;
	if (event.block.equals(mod_Rediscovered.CherrySapling)) 
	{
		if (!world.isRemote)
		{
			double chance = 0.45D;
			if (world.rand.nextFloat() < chance)
			{
				//grow tree
				event.setResult(Result.ALLOW);
				((BlockCherrySapling)mod_Rediscovered.CherrySapling).generateTree(event.world, event.pos, event.world.getBlockState(event.pos), event.world.rand);
				
			}
		}
	}
}
 
開發者ID:Stormister,項目名稱:Rediscovered-Mod-1.8,代碼行數:20,代碼來源:RediscoveredEventHandler.java

示例14: onItemRightClick

import net.minecraftforge.fml.common.eventhandler.Event.Result; //導入依賴的package包/類
@Override
public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand) {
    if (stack.getItemDamage() == ItemMeta.book.ordinal() || stack.getItemDamage() == ItemMeta.edit.ordinal()) {
        int guiid = player.isSneaking() ? GuiIDs.GROUP : GuiIDs.EDITOR;
        if (world.isRemote) {
            if (stack.getItemDamage() == ItemMeta.edit.ordinal()) MCClientHelper.FORCE_EDIT = true;
            else MCClientHelper.FORCE_EDIT = false;
        }

        player.openGui(Progression.instance, guiid, null, 0, 0, 0);
        return new ActionResult(EnumActionResult.SUCCESS, stack);
    } else if (!world.isRemote) {
        ICriteria criteria = getCriteriaFromStack(stack, world.isRemote);
        if (criteria != null) {
            Result completed = PlayerTracker.getServerPlayer(PlayerHelper.getUUIDForPlayer(player)).getMappings().forceComplete(criteria);
            if (!player.capabilities.isCreativeMode && completed == Result.ALLOW) {
                stack.stackSize--;
                return new ActionResult(EnumActionResult.SUCCESS, stack);
            }
        }
    }

    return new ActionResult(EnumActionResult.PASS, stack);
}
 
開發者ID:joshiejack,項目名稱:Progression,代碼行數:25,代碼來源:ItemProgression.java

示例15: hoeUsed

import net.minecraftforge.fml.common.eventhandler.Event.Result; //導入依賴的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);
}
 
開發者ID:tyronx,項目名稱:vintagecraft,代碼行數:24,代碼來源:BlockTopSoil.java


注:本文中的net.minecraftforge.fml.common.eventhandler.Event.Result類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。