本文整理匯總了Java中net.minecraftforge.fml.common.eventhandler.Event.Result.ALLOW屬性的典型用法代碼示例。如果您正苦於以下問題:Java Result.ALLOW屬性的具體用法?Java Result.ALLOW怎麽用?Java Result.ALLOW使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類net.minecraftforge.fml.common.eventhandler.Event.Result
的用法示例。
在下文中一共展示了Result.ALLOW屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onBucketUse
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;
}
示例2: onItemRightClick
@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);
}
示例3: 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;
}
示例4: canDestroyBlock
/**
* Returns true if the hookshot can destroy the material type
*/
protected boolean canDestroyBlock(Block block, BlockPos pos, EnumFacing face) {
Result result = Result.DEFAULT;
if (block instanceof IHookable) {
result = ((IHookable) block).canDestroyBlock(getType(), worldObj, pos, face);
} else if (Config.allowHookableOnly()) {
return false;
}
switch (result) {
case DEFAULT:
boolean isBreakable = block.getBlockHardness(worldObj, pos) >= 0.0F;
boolean canPlayerEdit = false;
if (getThrower() instanceof EntityPlayer) {
canPlayerEdit = ((EntityPlayer) getThrower()).capabilities.allowEdit && Config.canHookshotBreakBlocks();
}
Material m = block.getMaterial();
return (isBreakable && canPlayerEdit && (m == Material.glass || (m == Material.wood && getType().ordinal() / 2 == (HookshotType.CLAW_SHOT.ordinal() / 2))));
default: return result == Result.ALLOW;
}
}
示例5: 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()));
}
}
示例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;
}
}
示例7: onHoeUse
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: onApplyBonemeal
public static int onApplyBonemeal(EntityPlayer player, World world, BlockPos pos, IBlockState state, ItemStack stack)
{
BonemealEvent event = new BonemealEvent(player, world, pos, state);
if (MinecraftForge.EVENT_BUS.post(event)) return -1;
if (event.getResult() == Result.ALLOW)
{
if (!world.isRemote)
stack.stackSize--;
return 1;
}
return 0;
}
示例9: 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;
}
示例10: 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;
}
示例11: 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;
}
示例12: onItemUse
@Override
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
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 EnumActionResult.SUCCESS;
}
if (world.isRemote || player == null || stack == null) return EnumActionResult.PASS;
if (stack.getItemDamage() == ItemMeta.claim.ordinal()) {
TileEntity tile = world.getTileEntity(pos);
if (tile != null) {
Crafter crafter = CraftingRegistry.get(world.isRemote).getCrafterFromTile(tile);
if (crafter == CraftingUnclaimed.INSTANCE) {
PlayerTracker.setTileOwner(tile, PlayerHelper.getUUIDForPlayer(player));
PacketHandler.sendToClient(new PacketClaimed(pos.getX(), pos.getY(), pos.getZ()), (EntityPlayerMP) player);
return EnumActionResult.SUCCESS;
}
}
} else {
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 EnumActionResult.SUCCESS;
}
}
}
return EnumActionResult.PASS;
}
示例13: 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);
}
}
示例14: 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;
}
示例15: canLeftClickConvert
@Override
public Result canLeftClickConvert(EntityPlayer player, EntityVillager villager) {
if (!villager.worldObj.isRemote && villager.getClass() == EntityVillager.class && !villager.isChild()) {
if (getMaskQuest(player).complete(player)) {
return Result.ALLOW;
}
}
return Result.DEFAULT;
}