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


Java Result.DEFAULT属性代码示例

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


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

示例1: fogRenderEvent

@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,代码行数:16,代码来源:FogEffectHandler.java

示例2: wasBombEaten

/**
 * Returns true if any nearby {@link IEntityBombEater} consumes this bomb
 */
private boolean wasBombEaten() {
	List<EntityLivingBase> entities = worldObj.getEntitiesWithinAABB(EntityLivingBase.class, getEntityBoundingBox().expand(0.5D, 0.5D, 0.5D));
	for (EntityLivingBase entity : entities) {
		if (!entity.isEntityAlive()) {
			continue;
		}
		Result result = (entity instanceof IEntityBombEater ? ((IEntityBombEater) entity).ingestBomb(this) : Result.DENY);
		if (result == Result.ALLOW) {
			return true;
		} else if (result == Result.DEFAULT && ZSSEntityInfo.get(entity).onBombIngested(this)) {
			return true;
		}
	}
	return false;
}
 
开发者ID:coolAlias,项目名称:ZeldaSwordSkills,代码行数:18,代码来源:EntityBomb.java

示例3: onBowUse

@SubscribeEvent
public void onBowUse(ArrowNockEvent event){
	// change to use Result: DENY (cannot fire), DEFAULT (attempt standard nocking algorithm), ALLOW (nock without further checks)
	Result canDrawBow = Result.DEFAULT;
	// insert special bow check here:
	if (event.getBow().getItem() instanceof ISpecialBow) {
		canDrawBow = ((ISpecialBow) event.getBow().getItem()).canDrawBow(event.getBow(), event.getEntityPlayer());
	}
	// Special bow did not determine a result, so use standard algorithms instead:
	if (canDrawBow == Result.DEFAULT && (event.hasAmmo() || event.getEntityPlayer().capabilities.isCreativeMode)) {
		canDrawBow = Result.ALLOW;
	}
	if (canDrawBow == Result.DEFAULT) {
		ItemStack quiver = QuiverArrowRegistry.getArrowContainer(event.getBow(), event.getEntityPlayer());
		if (!quiver.isEmpty() && ((IArrowContainer2)quiver.getItem()).
			hasArrowFor(quiver, event.getBow(), event.getEntityPlayer(), ((IArrowContainer2) quiver.getItem()).getSelectedSlot(quiver))) {
			canDrawBow = Result.ALLOW;
		}
	}
	// only nock if allowed
	if (canDrawBow == Result.ALLOW) {
		event.getEntityPlayer().setActiveHand(event.getHand());
		event.setAction(ActionResult.newResult(EnumActionResult.SUCCESS, event.getBow()));
	}
}
 
开发者ID:Mine-and-blade-admin,项目名称:Battlegear2,代码行数:25,代码来源:BowHookContainerClass2.java

示例4: onBucketFill

@SubscribeEvent(priority = EventPriority.HIGH)
public void onBucketFill(FillBucketEvent evt) {
	if (evt.getResult() != Result.DEFAULT) return;

	if (evt.getEmptyBucket().getItem() != EMPTY_BUCKET) return;

	final RayTraceResult target = evt.getTarget();
	if (target == null || target.typeOfHit != RayTraceResult.Type.BLOCK) return;

	final TileEntity te = evt.getWorld().getTileEntity(target.getBlockPos());
	if (te == null) return;

	if (te.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, target.sideHit)) {
		final IFluidHandler source = te.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, target.sideHit);

		final FluidStack drained = source.drain(containedFluid, false);
		if (containedFluid.isFluidStackIdentical(drained)) {
			source.drain(containedFluid, true);
			evt.setFilledBucket(filledBucket.copy());
			evt.setResult(Result.ALLOW);
		}
	}
}
 
开发者ID:OpenMods,项目名称:OpenModsLib,代码行数:23,代码来源:SingleFluidBucketFillHandler.java

示例5: canEntitySpawn

public static Result canEntitySpawn(EntityLiving entity, World world, float x, float y, float z)
{
    if (entity == null)
        return Result.DEFAULT;
    LivingSpawnEvent.CheckSpawn event = new LivingSpawnEvent.CheckSpawn(entity, world, x, y, z);
    MinecraftForge.EVENT_BUS.post(event);
    return event.getResult();
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:8,代码来源:ForgeEventFactory.java

示例6: canEntitySpawnSpawner

public static boolean canEntitySpawnSpawner(EntityLiving entity, World world, float x, float y, float z)
{
    Result result = canEntitySpawn(entity, world, x, y, z);
    if (result == Result.DEFAULT)
    {
        return entity.getCanSpawnHere() && entity.isNotColliding(); // vanilla logic
    }
    else
    {
        return result == Result.ALLOW;
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:12,代码来源:ForgeEventFactory.java

示例7: fireSleepingLocationCheck

public static boolean fireSleepingLocationCheck(EntityPlayer player, BlockPos sleepingLocation)
{
    SleepingLocationCheckEvent evt = new SleepingLocationCheckEvent(player, sleepingLocation);
    MinecraftForge.EVENT_BUS.post(evt);

    Result canContinueSleep = evt.getResult();
    if (canContinueSleep == Result.DEFAULT)
    {
        IBlockState state = player.worldObj.getBlockState(player.bedLocation);
        return state.getBlock().isBed(state, player.worldObj, player.bedLocation, player);
    }
    else
        return canContinueSleep == Result.ALLOW;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:14,代码来源:ForgeEventFactory.java

示例8: canCreateFluidSource

public static boolean canCreateFluidSource(World world, BlockPos pos, IBlockState state, boolean def)
{
    CreateFluidSourceEvent evt = new CreateFluidSourceEvent(world, pos, state);
    MinecraftForge.EVENT_BUS.post(evt);

    Result result = evt.getResult();
    return result == Result.DEFAULT ? def : result == Result.ALLOW;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:8,代码来源:ForgeEventFactory.java

示例9: forceRemoval

public Result forceRemoval(ICriteria criteria) {
    if (criteria == null || !completedCritera.keySet().contains(criteria)) return Result.DEFAULT;
    else removeCriteria(criteria);
    remap(); //Remap everything
    data.markDirty();
    return Result.ALLOW;
}
 
开发者ID:joshiejack,项目名称:Progression,代码行数:7,代码来源:CriteriaMappings.java

示例10: fireTrigger

@Override
//Fired Server Side only
public Result fireTrigger(EntityPlayer player, String string, Object... data) {
    if (!player.worldObj.isRemote) {
        return fireTrigger(PlayerHelper.getUUIDForPlayer(player), string, data);
    } else return Result.DEFAULT;
}
 
开发者ID:joshiejack,项目名称:Progression,代码行数:7,代码来源:APIHandler.java

示例11: canGrabBlock

/**
 * Returns true if the block at the given position can be grappled by this type of hookshot
 */
protected boolean canGrabBlock(Block block, BlockPos pos, EnumFacing face) {
	Material material = block.getMaterial();
	Result result = Result.DEFAULT;
	if (block instanceof IHookable) {
		result = ((IHookable) block).canGrabBlock(getType(), worldObj, pos, face);
		material = ((IHookable) block).getHookableMaterial(getType(), worldObj, pos, face);
	} else if (Config.allowHookableOnly()) {
		return false;
	}
	switch (result) {
	case DEFAULT:
		switch (getType()) {
		case WOOD_SHOT:
		case WOOD_SHOT_EXT:
			return material == Material.wood;
		case CLAW_SHOT:
		case CLAW_SHOT_EXT:
			return material == Material.rock || (block instanceof BlockPane && material == Material.iron);
		case MULTI_SHOT:
		case MULTI_SHOT_EXT:
			return material == Material.wood || material == Material.rock || material == Material.ground ||
			material == Material.grass || material == Material.clay;
		}
	default: return (result == Result.ALLOW);
	}
}
 
开发者ID:coolAlias,项目名称:ZeldaSwordSkills,代码行数:29,代码来源:EntityHookShot.java

示例12: canInteractConvert

@Override
public Result canInteractConvert(EntityPlayer player, EntityVillager villager) {
	if (player.worldObj.isRemote || villager.getClass() != EntityVillager.class || villager.isChild()) {
		return Result.DEFAULT;
	} else if (PlayerUtils.consumeHeldItem(player, Items.gunpowder, 1)) {
		return Result.ALLOW;
	}
	PlayerUtils.sendTranslatedChat(player, "chat.zss.npc.barnes.hmph");
	return Result.DENY;
}
 
开发者ID:coolAlias,项目名称:ZeldaSwordSkills,代码行数:10,代码来源:EntityNpcBarnes.java

示例13: onInteract

/**
 * This event fires on BOTH sides
 */
@SubscribeEvent
public void onInteract(EntityInteractEvent event) {
	ItemStack stack = event.entityPlayer.getHeldItem();
	if (event.target instanceof EntityVillager && Result.DEFAULT != NpcHelper.convertVillager(event.entityPlayer, (EntityVillager) event.target, true)) {
		event.setCanceled(true);
	}
	// Check if the held item has any special interaction upon right-clicking an entity
	if (!event.isCanceled() && stack != null && stack.getItem() instanceof IRightClickEntity) {
		event.setCanceled(((IRightClickEntity) stack.getItem()).onRightClickEntity(stack, event.entityPlayer, event.target));
	}
	// If the event is not yet canceled, check for Mask interactions
	if (!event.isCanceled() && event.target instanceof INpc) {
		ItemStack helm = event.entityPlayer.getCurrentArmor(ArmorIndex.WORN_HELM);
		if (helm != null && helm.getItem() instanceof ItemMask) {
			event.setCanceled(((ItemMask) helm.getItem()).onInteract(helm, event.entityPlayer, event.target));
		}
	}
	// Check for Lon Lon Milk cow interaction
	if (!event.isCanceled() && stack != null && stack.getItem() == Items.glass_bottle && event.target.getClass() == EntityCow.class) {
		event.setCanceled(ZSSPlayerSongs.get(event.entityPlayer).milkLonLonCow(event.entityPlayer, (EntityCow) event.target));
	}
	// Finally, check for interactions with the Cursed Man
	if (!event.isCanceled() && event.target.getClass() == EntityVillager.class && ("Cursed Man").equals(event.target.getCustomNameTag())) {
		EntityVillager villager = (EntityVillager) event.target;
		if (stack == null || (stack.getItem() != ZSSItems.skulltulaToken && stack.getItem() != Items.name_tag)) {
			int tokens = ZSSPlayerInfo.get(event.entityPlayer).getSkulltulaTokens();
			if (villager.worldObj.isRemote) {
				// don't send chat - will be sent from server
			} else if (villager.isChild()) {
				PlayerUtils.sendTranslatedChat(event.entityPlayer, "chat.zss.npc.cursed_man.child");
			} else if (tokens > 0) {
				PlayerUtils.sendTranslatedChat(event.entityPlayer, "chat.zss.npc.cursed_man.amount", tokens);
			} else {
				PlayerUtils.sendTranslatedChat(event.entityPlayer, "chat.zss.npc.cursed_man." + event.entity.worldObj.rand.nextInt(4));
			}
			event.setCanceled(true);
		}
	}
}
 
开发者ID:coolAlias,项目名称:ZeldaSwordSkills,代码行数:42,代码来源:ZSSEntityEvents.java

示例14: blockWasSmashed

/**
 * Returns true if the ISmashBlock itemstack was able to smash up the block clicked
 * and the useBlock result should be denied
 */
private boolean blockWasSmashed(World world, EntityPlayer player, ItemStack stack, BlockPos pos, EnumFacing face) {
	IBlockState state = world.getBlockState(pos);
	Block block = state.getBlock();
	boolean isSmashable = block instanceof ISmashable;
	Result smashResult = Result.DEFAULT;
	boolean wasDestroyed = false;
	if (player.canPlayerEdit(pos, face, stack) || isSmashable) {
		BlockWeight weight = (isSmashable ? ((ISmashable) block).getSmashWeight(player, stack, state, face)
				: (Config.canSmashVanilla() || isVanillaBlockSmashable(block) ? null : BlockWeight.IMPOSSIBLE));
		float strength = ((ISmashBlock) stack.getItem()).getSmashStrength(player, stack, state, face).weight;
		float resistance = (weight != null ? weight.weight : (block.getExplosionResistance(world, pos, null, null) * 5.0F/3.0F));
		smashResult = (isSmashable ? ((ISmashable) block).onSmashed(world, player, stack, pos, state, face) : smashResult);
		if (smashResult == Result.DEFAULT) {
			boolean isValidBlock = block.isOpaqueCube() || block instanceof BlockBreakable;
			if (isValidBlock && weight != BlockWeight.IMPOSSIBLE && strength >= resistance && (!block.hasTileEntity(state) || isSmashable)) {
				if (!(block instanceof BlockBreakable)) {
					world.playSoundAtEntity(player, Sounds.ROCK_FALL, 1.0F, 1.0F);
				}
				if (!world.isRemote) { 
					world.destroyBlock(pos, false);
				}
				wasDestroyed = true;
			}
		}
		((ISmashBlock) stack.getItem()).onBlockSmashed(player, stack, state, face, (smashResult == Result.ALLOW || wasDestroyed));
	}
	return (smashResult == Result.ALLOW || wasDestroyed);
}
 
开发者ID:coolAlias,项目名称:ZeldaSwordSkills,代码行数:32,代码来源:ZSSItemEvents.java

示例15: onLeftClickEntity

@Override
public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) {
	if (player.worldObj.isRemote) {
		return true;
	} else if (entity instanceof EntityNpcMaskTrader && ((EntityNpcMaskTrader) entity).checkShopStatus(player, false, true)) {
		return true; // allows quest to complete without having to convert a villager if Salesman already in town
	} else if (entity instanceof EntityVillager && Result.DEFAULT == NpcHelper.convertVillager(player, (EntityVillager) entity, false)) {
		// villager not converted, try other treasure interactions (note that conversion handles beginnings of several quests)
		handleTrade(stack, player, entity, true);
	} else if (entity instanceof INpc) {
		handleTrade(stack, player, entity, true);
	}
	return true;
}
 
开发者ID:coolAlias,项目名称:ZeldaSwordSkills,代码行数:14,代码来源:ItemTreasure.java


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