本文整理汇总了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;
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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_);
}
}
}
示例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;
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}