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


Java ForgeHooks類代碼示例

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


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

示例1: work

import net.minecraftforge.common.ForgeHooks; //導入依賴的package包/類
@Override
public float work() {
    if (WorkUtils.isDisabled(this.getBlockType())) return 0;
    List<BlockPos> blockPosList = BlockUtils.getBlockPosInAABB(getWorkingArea());
    for (BlockPos pos : blockPosList) {
        if (this.world.isAirBlock(pos)) {
            ItemStack stack = getFirstStackHasBlock();
            if (stack.isEmpty()) return 0;
            if (this.world.isAirBlock(pos)) {
                FakePlayer player = IndustrialForegoing.getFakePlayer(this.world);
                player.setHeldItem(EnumHand.MAIN_HAND, stack);
                EnumActionResult result = ForgeHooks.onPlaceItemIntoWorld(stack, player, world, pos, EnumFacing.UP, 0, 0, 0, EnumHand.MAIN_HAND);
                return result == EnumActionResult.SUCCESS ? 1 : 0;
            }
        }
    }

    return 0;
}
 
開發者ID:Buuz135,項目名稱:Industrial-Foregoing,代碼行數:20,代碼來源:BlockPlacerTile.java

示例2: resizeContent

import net.minecraftforge.common.ForgeHooks; //導入依賴的package包/類
private List<ITextComponent> resizeContent(List<String> lines)
{
    List<ITextComponent> ret = new ArrayList<ITextComponent>();
    for (String line : lines)
    {
        if (line == null)
        {
            ret.add(null);
            continue;
        }

        ITextComponent chat = ForgeHooks.newChatWithLinks(line, false);
        ret.addAll(GuiUtilRenderComponents.splitText(chat, this.listWidth-8, GuiModList.this.fontRendererObj, false, true));
    }
    return ret;
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:17,代碼來源:GuiModList.java

示例3: BreakEvent

import net.minecraftforge.common.ForgeHooks; //導入依賴的package包/類
public BreakEvent(World world, BlockPos pos, IBlockState state, EntityPlayer player)
{
    super(world, pos, state);
    this.player = player;

    if (state == null || !ForgeHooks.canHarvestBlock(state.getBlock(), player, world, pos) || // Handle empty block or player unable to break block scenario
        (state.getBlock().canSilkHarvest(world, pos, world.getBlockState(pos), player) && EnchantmentHelper.getEnchantmentLevel(Enchantments.SILK_TOUCH, player.getHeldItemMainhand()) > 0)) // If the block is being silk harvested, the exp dropped is 0
    {
        this.exp = 0;
    }
    else
    {
        int bonusLevel = EnchantmentHelper.getEnchantmentLevel(Enchantments.FORTUNE, player.getHeldItemMainhand());
        this.exp = state.getBlock().getExpDrop(state, world, pos, bonusLevel);
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:17,代碼來源:BlockEvent.java

示例4: onClickAir

import net.minecraftforge.common.ForgeHooks; //導入依賴的package包/類
@Override
public void onClickAir(PossessivePlayer possessivePlayer, EntityPlayer player) {
    RayTraceResult result = ForgeHooks.rayTraceEyes(player, 64);
    if (result != null && result.typeOfHit != RayTraceResult.Type.MISS) {
        if (result.typeOfHit == RayTraceResult.Type.BLOCK) {
            BlockPos pos = result.getBlockPos().offset(result.sideHit);
            player.setPosition(pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5);
        } else {
            Entity entityHit = result.entityHit;
            player.setPosition(entityHit.posX, entityHit.posY, entityHit.posZ);
        }
        if (!player.capabilities.isCreativeMode) {
            player.attackEntityFrom(DamageSource.fall, 4.0F);
        }
        player.worldObj.playSound(null, player.prevPosX, player.prevPosY, player.prevPosZ, SoundEvents.ENTITY_ENDERMEN_TELEPORT, player.getSoundCategory(), 1.0F, 1.0F);
        player.worldObj.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_ENDERMEN_TELEPORT, player.getSoundCategory(), 1.0F, 1.0F);
    }
}
 
開發者ID:Fararise,項目名稱:Possessed,代碼行數:19,代碼來源:EndermanHandler.java

示例5: jump

import net.minecraftforge.common.ForgeHooks; //導入依賴的package包/類
@Override
protected void jump()
{
    this.motionY = 0.48D / WorldUtil.getGravityFactor(this);
    if (this.motionY < 0.28D) this.motionY = 0.28D;

    if (this.isPotionActive(Potion.jump))
    {
        this.motionY += (this.getActivePotionEffect(Potion.jump).getAmplifier() + 1) * 0.1F;
    }

    if (this.isSprinting())
    {
        float f = this.rotationYaw * 0.017453292F;
        this.motionX -= MathHelper.sin(f) * 0.2F;
        this.motionZ += MathHelper.cos(f) * 0.2F;
    }

    this.isAirBorne = true;
    ForgeHooks.onLivingJump(this);
}
 
開發者ID:4Space,項目名稱:4Space-5,代碼行數:22,代碼來源:EntitySlimeling.java

示例6: jump

import net.minecraftforge.common.ForgeHooks; //導入依賴的package包/類
@Override
protected void jump()
{
    this.motionY = 0.52D / WorldUtil.getGravityFactor(this);
    if (this.motionY < 0.26D) this.motionY = 0.26D;

    if (this.isPotionActive(Potion.jump))
    {
        this.motionY += (this.getActivePotionEffect(Potion.jump).getAmplifier() + 1) * 0.1F;
    }

    if (this.isSprinting())
    {
        float f = this.rotationYaw * 0.017453292F;
        this.motionX -= MathHelper.sin(f) * 0.2F;
        this.motionZ += MathHelper.cos(f) * 0.2F;
    }

    this.isAirBorne = true;
    ForgeHooks.onLivingJump(this);
}
 
開發者ID:4Space,項目名稱:4Space-5,代碼行數:22,代碼來源:EntityEvolvedSpider.java

示例7: jump

import net.minecraftforge.common.ForgeHooks; //導入依賴的package包/類
@Override
protected void jump()
{
    this.motionY = 0.45D / WorldUtil.getGravityFactor(this);
    if (this.motionY < 0.22D) this.motionY = 0.22D;

    if (this.isPotionActive(Potion.jump))
    {
        this.motionY += (this.getActivePotionEffect(Potion.jump).getAmplifier() + 1) * 0.1F;
    }

    if (this.isSprinting())
    {
        float f = this.rotationYaw * 0.017453292F;
        this.motionX -= MathHelper.sin(f) * 0.2F;
        this.motionZ += MathHelper.cos(f) * 0.2F;
    }

    this.isAirBorne = true;
    ForgeHooks.onLivingJump(this);
}
 
開發者ID:4Space,項目名稱:4Space-5,代碼行數:22,代碼來源:EntityEvolvedCreeper.java

示例8: jump

import net.minecraftforge.common.ForgeHooks; //導入依賴的package包/類
@Override
protected void jump()
{
    this.motionY = 0.48D / WorldUtil.getGravityFactor(this);
    if (this.motionY < 0.24D) this.motionY = 0.24D;

    if (this.isPotionActive(Potion.jump))
    {
        this.motionY += (this.getActivePotionEffect(Potion.jump).getAmplifier() + 1) * 0.1F;
    }

    if (this.isSprinting())
    {
        float f = this.rotationYaw * 0.017453292F;
        this.motionX -= MathHelper.sin(f) * 0.2F;
        this.motionZ += MathHelper.cos(f) * 0.2F;
    }

    this.isAirBorne = true;
    ForgeHooks.onLivingJump(this);
}
 
開發者ID:4Space,項目名稱:4Space-5,代碼行數:22,代碼來源:EntityEvolvedZombie.java

示例9: jump

import net.minecraftforge.common.ForgeHooks; //導入依賴的package包/類
@Override
protected void jump()
{
    this.motionY = 0.45D / WorldUtil.getGravityFactor(this);
    if (this.motionY < 0.24D) this.motionY = 0.24D;

    if (this.isPotionActive(Potion.jump))
    {
        this.motionY += (this.getActivePotionEffect(Potion.jump).getAmplifier() + 1) * 0.1F;
    }

    if (this.isSprinting())
    {
        float f = this.rotationYaw * 0.017453292F;
        this.motionX -= MathHelper.sin(f) * 0.2F;
        this.motionZ += MathHelper.cos(f) * 0.2F;
    }

    this.isAirBorne = true;
    ForgeHooks.onLivingJump(this);
}
 
開發者ID:4Space,項目名稱:4Space-5,代碼行數:22,代碼來源:EntityEvolvedSkeleton.java

示例10: damageEntity

import net.minecraftforge.common.ForgeHooks; //導入依賴的package包/類
protected void damageEntity(DamageSource p_70665_1_, float p_70665_2_) {
	;
	;
	;
	if (!isEntityInvulnerable()) {
		p_70665_2_ = ForgeHooks.onLivingHurt(this, p_70665_1_, p_70665_2_);
		if (p_70665_2_ <= 0.0F) {
			return;
		}
		p_70665_2_ = applyArmorCalculations(p_70665_1_, p_70665_2_);
		p_70665_2_ = applyPotionDamageCalculations(p_70665_1_, p_70665_2_);
		float f1 = p_70665_2_;
		p_70665_2_ = Math.max(p_70665_2_ - getAbsorptionAmount(), 0.0F);
		setAbsorptionAmount(getAbsorptionAmount() - (f1 - p_70665_2_));
		if (p_70665_2_ != 0.0F) {
			float f2 = getHealth();
			setHealth(f2 - p_70665_2_);
			func_110142_aN().func_94547_a(p_70665_1_, f2, p_70665_2_);
			setAbsorptionAmount(getAbsorptionAmount() - p_70665_2_);
		}
	}
}
 
開發者ID:4Space,項目名稱:4Space-5,代碼行數:23,代碼來源:EntityLivingBase.java

示例11: getRemainingItems

import net.minecraftforge.common.ForgeHooks; //導入依賴的package包/類
@Override
public NonNullList<ItemStack> getRemainingItems(InventoryCrafting inv) {
	NonNullList<ItemStack> ret = NonNullList.withSize(inv.getSizeInventory(), ItemStack.EMPTY);
       for (int i = 0; i < ret.size(); i++)
       {
       	if(i == pickSlot){
       		ItemStack pick = inv.getStackInSlot(i);
       		int current = pick.getItemDamage();
       		int count = ItemStackTools.getStackSize(output);
       		if(count > 0)pick.setItemDamage(current+count);
       		
       		if(pick.getItemDamage() < pick.getMaxDamage()){
   				inv.setInventorySlotContents(i, ItemStackTools.getEmptyStack());
       			ret.set(i, pick);
       		}
       	}
       	else ret.set(i, ForgeHooks.getContainerItem(inv.getStackInSlot(i)));
       }
	return ret;
}
 
開發者ID:Alec-WAM,項目名稱:CrystalMod,代碼行數:21,代碼來源:ChisledBlockRecipe.java

示例12: BreakEvent

import net.minecraftforge.common.ForgeHooks; //導入依賴的package包/類
public BreakEvent(int x, int y, int z, World world, Block block, int blockMetadata, EntityPlayer player)
{
    super(x, y, z, world, block, blockMetadata);
    this.player = player;

    if (block == null || !ForgeHooks.canHarvestBlock(block, player, blockMetadata) || // Handle empty block or player unable to break block scenario
        block.canSilkHarvest(world, player, x, y, z, blockMetadata) && EnchantmentHelper.func_77502_d(player)) // If the block is being silk harvested, the exp dropped is 0
    {
        this.exp = 0;
    }
    else
    {
        int meta = block.func_149643_k(world, x, y, z);
        int bonusLevel = EnchantmentHelper.func_77517_e(player);
        this.exp = block.getExpDrop(world, meta, bonusLevel);
    }
}
 
開發者ID:SchrodingersSpy,項目名稱:TRHS_Club_Mod_2016,代碼行數:18,代碼來源:BlockEvent.java

示例13: getRemainingItems

import net.minecraftforge.common.ForgeHooks; //導入依賴的package包/類
@Nonnull
@Override
public NonNullList<ItemStack> getRemainingItems(@Nonnull InventoryCrafting inv) {
	NonNullList<ItemStack> remainingItems = ForgeHooks.defaultRecipeGetRemainingItems(inv);

	ItemStack sword;
	for (int i = 0; i < inv.getSizeInventory(); i++) {
		ItemStack stack = inv.getStackInSlot(i);
		if (stack.getItem() == Items.GOLDEN_SWORD) {
			sword = stack.copy();
			sword.setItemDamage(sword.getItemDamage() + 1);
			if (sword.getItemDamage() > sword.getMaxDamage()) sword = null;
			if (sword != null) {
				remainingItems.set(i, sword);
			}
			break;
		}
	}

	return remainingItems;
}
 
開發者ID:TeamWizardry,項目名稱:Wizardry,代碼行數:22,代碼來源:RecipeJam.java

示例14: onItemUse

import net.minecraftforge.common.ForgeHooks; //導入依賴的package包/類
@Override
@SuppressWarnings("deprecation")
   public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
   {
   	if ((this.getStrVsBlock(stack, world.getBlockState(pos)) == this.efficiencyOnProperMaterial || ForgeHooks.isToolEffective(world, pos, stack)) && world.isAirBlock(pos.up()))
   	{
       	if (world.getTileEntity(pos) != null || world.getBlockState(pos).getBlock().getBlockHardness(world.getBlockState(pos), world, pos) == -1.0F)
       	{
       		return EnumActionResult.FAIL;
       	}

       	if (!world.isRemote)
       	{
           	EntityFloatingBlock entity = new EntityFloatingBlock(world, pos, world.getBlockState(pos));
       		world.spawnEntityInWorld(entity);
       		world.setBlockToAir(pos);
       	}

       	stack.damageItem(4, player);
   	}

       return EnumActionResult.SUCCESS;
   }
 
開發者ID:Modding-Legacy,項目名稱:Aether-Legacy,代碼行數:24,代碼來源:ItemGravititeTool.java

示例15: getRemainingItems

import net.minecraftforge.common.ForgeHooks; //導入依賴的package包/類
@Override
public ItemStack[] getRemainingItems(InventoryCrafting inventoryCrafting) {
    final ItemStack[] remainingItems = new ItemStack[inventoryCrafting.getSizeInventory()];

    for (int i = 0; i < remainingItems.length; ++i) {
        final ItemStack itemstack = inventoryCrafting.getStackInSlot(i);

        if (itemstack != null && itemstack.getItem() instanceof ItemAxe) {
            remainingItems[i] = damageAxe(itemstack.copy());
        } else {
            remainingItems[i] = ForgeHooks.getContainerItem(itemstack);
        }
    }

    return remainingItems;
}
 
開發者ID:droidicus,項目名稱:AquaRegia,代碼行數:17,代碼來源:ShapelessCuttingRecipe.java


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