本文整理汇总了Java中net.minecraftforge.common.ForgeHooks.blockStrength方法的典型用法代码示例。如果您正苦于以下问题:Java ForgeHooks.blockStrength方法的具体用法?Java ForgeHooks.blockStrength怎么用?Java ForgeHooks.blockStrength使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraftforge.common.ForgeHooks
的用法示例。
在下文中一共展示了ForgeHooks.blockStrength方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkBlockBreak
import net.minecraftforge.common.ForgeHooks; //导入方法依赖的package包/类
public void checkBlockBreak(World world, EntityPlayer player, int x, int y, int z, ItemStack stack, float strength,
Block originalBlock, int side)
{
Block breakBlock = world.getBlock(x, y, z);
if (this.canHarvestBlock(breakBlock, stack))
{
float newStrength = ForgeHooks.blockStrength(breakBlock, player, world, x, y, z);
Material material = originalBlock.getMaterial();
if (newStrength > 0f && strength / newStrength <= 10f && breakBlock.getMaterial() == material)
{
RandomUtils.breakBlock(world, breakBlock, x, y, z, side, player);
if ((double) breakBlock.getBlockHardness(world, x, y, z) != 0.0D)
{
stack.damageItem(1, player);
}
}
}
}
示例2: checkBlockBreak
import net.minecraftforge.common.ForgeHooks; //导入方法依赖的package包/类
public void checkBlockBreak(World world, EntityPlayer player, int x, int y, int z, ItemStack stack, float strength,
Block originalBlock, int side)
{
Block breakBlock = world.getBlock(x, y, z);
int metadata = world.getBlockMetadata(x, y, z);
if (ForgeHooks.canToolHarvestBlock(breakBlock, metadata, stack))
{
float newStrength = ForgeHooks.blockStrength(breakBlock, player, world, x, y, z);
if (newStrength > 0f && strength / newStrength <= 10f)
{
RandomUtils.breakBlock(world, breakBlock, x, y, z, side, player);
if ((double) breakBlock.getBlockHardness(world, x, y, z) != 0.0D)
{
stack.damageItem(1, player);
}
}
}
}
示例3: checkBlockBreak
import net.minecraftforge.common.ForgeHooks; //导入方法依赖的package包/类
public void checkBlockBreak(World world, EntityPlayer player, BlockPos pos, ItemStack stack, float strength, Block originalBlock,
EnumFacing side)
{
IBlockState state = world.getBlockState(pos);
Block breakBlock = state.getBlock();
Material material = originalBlock.getMaterial(state);
if (breakBlock.getMaterial(state) == material && ForgeHooks.canHarvestBlock(breakBlock, player, world, pos)
&& stack.canHarvestBlock(state))
{
float newStrength = ForgeHooks.blockStrength(state, player, world, pos);
if (newStrength > 0f && strength / newStrength <= 10f)
{
if ((double) breakBlock.getBlockHardness(state, world, pos) != 0.0D)
{
if (DamageHandler.handleDamage(false, state, stack, player))
{
BlockUtils.tryHarvestBlock(world, state, pos, side, player);
}
}
else
{
BlockUtils.tryHarvestBlock(world, state, pos, side, player);
}
}
}
}
示例4: getPlayerRelativeBlockHardness
import net.minecraftforge.common.ForgeHooks; //导入方法依赖的package包/类
public float getPlayerRelativeBlockHardness(EntityPlayer player, World world, int x, int y, int z)
{
TileEntity te = world.getTileEntity(x, y, z);
if(te instanceof TileEntityPrivate)
{
TileEntityPrivate tePrivate = (TileEntityPrivate)te;
if(!player.getGameProfile().equals(tePrivate.getOwner()))
{
return -1;
}
}
else if(te instanceof TileEntityPassword)
{
TileEntityPassword tePass = (TileEntityPassword)te;
if(!PrivatizerHelper.checkPassword(player, tePass.getPassword()))
{
return -1;
}
}
return ForgeHooks.blockStrength(this, player, world, x, y, z);
}
示例5: getPlayerRelativeBlockHardness
import net.minecraftforge.common.ForgeHooks; //导入方法依赖的package包/类
public float getPlayerRelativeBlockHardness(EntityPlayer player, World world, int x, int y, int z)
{
TileEntity te = world.getTileEntity(x, y, z);
if(te instanceof TileEntityPrivateChest)
{
TileEntityPrivateChest tePrivate = (TileEntityPrivateChest)te;
if(!player.getGameProfile().equals(tePrivate.getOwner()))
{
return -1;
}
}
else if(te instanceof TileEntityPassword)
{
TileEntityPassword tePass = (TileEntityPassword)te;
if(!PrivatizerHelper.checkPassword(player, tePass.getPassword()))
{
return -1;
}
}
return ForgeHooks.blockStrength(this, player, world, x, y, z);
}
示例6: getPlayerRelativeBlockHardness
import net.minecraftforge.common.ForgeHooks; //导入方法依赖的package包/类
@Override
public float getPlayerRelativeBlockHardness(IBlockState state, EntityPlayer player, World world, BlockPos pos) {
if (pos.getY() >= 10)
return ForgeHooks.blockStrength(state, player, world, pos);
return -1.0F;
}
示例7: getPlayerRelativeBlockHardness
import net.minecraftforge.common.ForgeHooks; //导入方法依赖的package包/类
public float getPlayerRelativeBlockHardness(EntityPlayer player, World p_149737_2_, int p_149737_3_, int p_149737_4_, int p_149737_5_)
{
ItemStack stack = player.inventory.getCurrentItem();
if (stack != null && stack.getItem() == MarsItems.deshPickSlime)
{
return 0.2F;
}
return ForgeHooks.blockStrength(this, player, p_149737_2_, p_149737_3_, p_149737_4_, p_149737_5_);
}
示例8: getPlayerRelativeBlockHardness
import net.minecraftforge.common.ForgeHooks; //导入方法依赖的package包/类
@Override
public float getPlayerRelativeBlockHardness(EntityPlayer player, World p_149737_2_, int p_149737_3_, int p_149737_4_, int p_149737_5_) {
ItemStack stack = player.inventory.getCurrentItem();
if (stack != null && stack.getItem() == MarsItems.deshPickSlime) {
return 0.2F;
}
return ForgeHooks.blockStrength(this, player, p_149737_2_, p_149737_3_, p_149737_4_, p_149737_5_);
}
示例9: getPlayerRelativeBlockHardness
import net.minecraftforge.common.ForgeHooks; //导入方法依赖的package包/类
@Override
/**
* Gets the hardness of block at the given coordinates in the given world, relative to the ability of the given
* EntityPlayer.
*/
public float getPlayerRelativeBlockHardness(EntityPlayer entityPlayer, World world, int x, int y, int z)
{
/* Don't damage block if holding Carpenter's tool. */
ItemStack itemStack = entityPlayer.getHeldItem();
if (itemStack != null) {
Item item = itemStack.getItem();
if (item instanceof ItemHammer || item instanceof ItemChisel) {
return -1;
}
}
/* Return block hardness of cover. */
TEBase TE = getTileEntity(world, x, y, z);
if (TE != null) {
return ForgeHooks.blockStrength(BlockProperties.toBlock(BlockProperties.getCover(TE, 6)), entityPlayer, world, x, y, z);
} else {
return super.getPlayerRelativeBlockHardness(entityPlayer, world, x, y, z);
}
}
示例10: ScriptExecutor
import net.minecraftforge.common.ForgeHooks; //导入方法依赖的package包/类
public ScriptExecutor(CompiledSymbol[] newSymbols, EntityPlayer newPlayer, ItemStack enchantedItem, StartPoint newStartPoint)
{
compiledSymbols = newSymbols.clone();
player = newPlayer;
currentSymbol = 0;
RunicItem = enchantedItem;
variablesChanged = false;
startPoint = newStartPoint;
MAX_ALLOWED_PROCESSES = processesPerTick+MAX_ALLOWED_INPUT;
inputsInRow = 0;
initPos = player.rayTrace(6,1.0F).getBlockPos();
initBlock = player.worldObj.getBlockState(initPos);
initBlockStrength = ForgeHooks.blockStrength(initBlock, player, player.worldObj, initPos);
switch(startPoint)
{
case SNEAK_RIGHT:
actionQueue.add(new Short((short)0));
actionQueue.add(new Short((short)1));
actionQueue.add(true);
break;
case RIGHT_CLICK:
actionQueue.add(new Short((short)0));
actionQueue.add(new Short((short)0));
actionQueue.add(true);
break;
case BLOCK_BREAK:
actionQueue.add(new Short((short)0));
actionQueue.add(new Short((short)3));
actionQueue.add(true);
break;
default:
break;
}
if(!ModDust.runningScripts.contains(this)&&!player.worldObj.isRemote)
{
ModDust.runningScripts.add(this);
MinecraftForge.EVENT_BUS.register(this);
}
}
示例11: getPlayerRelativeBlockHardness
import net.minecraftforge.common.ForgeHooks; //导入方法依赖的package包/类
public float getPlayerRelativeBlockHardness(final EntityPlayer par1EntityPlayer, final World par2World, final int par3, final int par4, final int par5) {
return ForgeHooks.blockStrength(getBlock(par2World.getBlockMetadata(par3, par4, par5)), par1EntityPlayer, par2World, par3, par4, par5);
}
示例12: breakExtraBlock
import net.minecraftforge.common.ForgeHooks; //导入方法依赖的package包/类
public static void breakExtraBlock(ItemStack stack, World world, EntityPlayer player, BlockPos pos, BlockPos refPos) {
if(world.isAirBlock(pos)) {
return;
}
IBlockState state = world.getBlockState(pos);
Block block = state.getBlock();
if(!ToolUtil.isToolEffective(stack, state)) {
return;
}
IBlockState refState = world.getBlockState(refPos);
float refStrength = ForgeHooks.blockStrength(refState, player, world, refPos);
float strength = ForgeHooks.blockStrength(state, player, world, pos);
if(!ForgeHooks.canHarvestBlock(block, player, world, pos) || refStrength / strength > 10f) {
return;
}
if(player.capabilities.isCreativeMode) {
block.onBlockHarvested(world, pos, state, player);
if(block.removedByPlayer(state, world, pos, player, false)) {
block.onBlockDestroyedByPlayer(world, pos, state);
}
if(!world.isRemote) {
CrystalModNetwork.sendMCPacket(player, new SPacketBlockChange(world, pos));
}
return;
}
stack.onBlockDestroyed(world, state, pos, player);
if(!world.isRemote) {
int xp = ForgeHooks.onBlockBreakEvent(world, ((EntityPlayerMP) player).interactionManager.getGameType(), (EntityPlayerMP) player, pos);
if(xp == -1) {
return;
}
TileEntity tileEntity = world.getTileEntity(pos);
if(block.removedByPlayer(state, world, pos, player, true))
{
block.onBlockDestroyedByPlayer(world, pos, state);
block.harvestBlock(world, player, pos, state, tileEntity, stack);
block.dropXpOnBlockBreak(world, pos, xp);
}
CrystalModNetwork.sendMCPacket(player, new SPacketBlockChange(world, pos));
}
else {
Minecraft.getMinecraft();
world.playBroadcastSound(2001, pos, Block.getStateId(state));
if(block.removedByPlayer(state, world, pos, player, true)) {
block.onBlockDestroyedByPlayer(world, pos, state);
}
stack.onBlockDestroyed(world, state, pos, player);
if(ItemStackTools.getStackSize(stack) == 0 && stack == player.getHeldItemMainhand()) {
ForgeEventFactory.onPlayerDestroyItem(player, stack, EnumHand.MAIN_HAND);
player.setHeldItem(EnumHand.MAIN_HAND, ItemStackTools.getEmptyStack());
}
Minecraft.getMinecraft().getConnection().sendPacket(new CPacketPlayerDigging(CPacketPlayerDigging.Action.STOP_DESTROY_BLOCK, pos, Minecraft
.getMinecraft().objectMouseOver.sideHit));
}
}
示例13: onBlockStartBreak
import net.minecraftforge.common.ForgeHooks; //导入方法依赖的package包/类
@Override
public boolean onBlockStartBreak(ItemStack stack, int x, int y, int z, EntityPlayer player)
{
World world = player.worldObj;
Block block = world.getBlock(x, y, z);
MovingObjectPosition object = RandomUtils.raytraceFromEntity(world, player, false, 4.5D);
if (object == null)
{
return super.onBlockDestroyed(stack, world, block, x, y, z, player);
}
int side = object.sideHit;
int xmove = 0;
int ymove = 0;
int zmove = 0;
if (side == 0 || side == 1)
{
xmove = 1;
zmove = 1;
}
else
{
ymove = 1;
if (side == 4 || side == 5)
{
zmove = 1;
}
else
{
xmove = 1;
}
}
float strength = ForgeHooks.blockStrength(block, player, world, x, y, z);
if (player.isSneaking() && ConfigInfo.EnableHammerShiftOneBlock
&& (player.experienceLevel >= 20 || player.capabilities.isCreativeMode))
{
checkBlockBreak(world, player, x, y, z, stack, strength, block, side);
}
else
{
for (int i = -xmove; i <= xmove; i++)
{
for (int j = -ymove; j <= ymove; j++)
{
for (int k = -zmove; k <= zmove; k++)
{
if (i != x && j != y && k != z)
{
checkBlockBreak(world, player, x + i, y + j, z + k, stack, strength, block, side);
}
}
}
}
}
return false;
}
示例14: onBlockStartBreak
import net.minecraftforge.common.ForgeHooks; //导入方法依赖的package包/类
@Override
public boolean onBlockStartBreak(ItemStack stack, int x, int y, int z, EntityPlayer player)
{
World world = player.worldObj;
Block block = world.getBlock(x, y, z);
MovingObjectPosition object = RandomUtils.raytraceFromEntity(world, player, false, 4.5D);
if (object == null)
{
return super.onBlockDestroyed(stack, world, block, x, y, z, player);
}
int side = object.sideHit;
int xmove = 0;
int ymove = 0;
int zmove = 0;
if (side == 0 || side == 1)
{
xmove = 1;
zmove = 1;
}
else
{
ymove = 1;
if (side == 4 || side == 5)
{
zmove = 1;
}
else
{
xmove = 1;
}
}
float strength = ForgeHooks.blockStrength(block, player, world, x, y, z);
if (player.isSneaking() && ConfigInfo.EnableEarthMoverShiftOneBlock
&& (player.experienceLevel >= 20 || player.capabilities.isCreativeMode))
{
checkBlockBreak(world, player, x, y, z, stack, strength, block, side);
}
else
{
for (int i = -xmove; i <= xmove; i++)
{
for (int j = -ymove; j <= ymove; j++)
{
for (int k = -zmove; k <= zmove; k++)
{
if (i != x && j != y && k != z)
{
checkBlockBreak(world, player, x + i, y + j, z + k, stack, strength, block, side);
}
}
}
}
}
return false;
}
示例15: onBlockStartBreak
import net.minecraftforge.common.ForgeHooks; //导入方法依赖的package包/类
@Override
public boolean onBlockStartBreak(ItemStack stack, BlockPos pos, EntityPlayer player)
{
World world = player.worldObj;
IBlockState state = world.getBlockState(pos);
Block block = state.getBlock();
if ((player.isSneaking() && ConfigOptions.CanShiftMine) || block.getBlockHardness(state, world, pos) == 0)
{
return false;
}
RayTraceResult object = RandomUtils.raytraceFromEntity(world, player, false, 4.5D);
if (object == null)
{
return super.onBlockDestroyed(stack, world, state, pos, player);
}
EnumFacing side = object.sideHit;
int xmove = 0;
int ymove = 0;
int zmove = 0;
if (side == EnumFacing.UP || side == EnumFacing.DOWN)
{
xmove = 1;
zmove = 1;
}
else
{
ymove = 1;
if (side == EnumFacing.WEST || side == EnumFacing.EAST)
{
zmove = 1;
}
else
{
xmove = 1;
}
}
float strength = ForgeHooks.blockStrength(state, player, world, pos);
int x = pos.getX();
int y = pos.getY();
int z = pos.getZ();
for (int i = -xmove; i <= xmove; i++)
{
for (int j = -ymove; j <= ymove; j++)
{
for (int k = -zmove; k <= zmove; k++)
{
if ((x + i) != x || (y + j) != y || (z + k) != z)
{
checkBlockBreak(world, player, new BlockPos(x + i, y + j, z + k), stack, strength, block, side);
}
}
}
}
return false;
}