Java 类net.minecraftforge.event.entity.player.PlayerEvent.BreakSpeed 实例源码

项目:ToolUtilities    文件:AOEHandler.java   
@SubscribeEvent
public void breakSpeed(BreakSpeed event)
{
    ItemStack stack = event.entityPlayer.getCurrentEquippedItem();
    if (stack != null && !event.entityPlayer.isSneaking() && canHarvestBlock(event.entityPlayer, event.block, event.block, event.metadata, event.x, event.y, event.z))
    {
        if (ToolUpgrade.THREExONE.isOn(stack))
        {
            event.newSpeed *= Config.speedMult3x1;
        }
        if (ToolUpgrade.THREExTHREE.isOn(stack))
        {
            event.newSpeed *= Config.speedMult3x3;
        }
    }
}
项目:ForbiddenMagic    文件:FMEventHandler.java   
@SubscribeEvent
public void onPlayerBreaking(BreakSpeed event) {
    if (event.entityPlayer.getCurrentEquippedItem() != null) {
        ItemStack stack = event.entityPlayer.getCurrentEquippedItem();
        if (stack.getItem() instanceof ItemTaintPickaxe) {
            World world = event.entityPlayer.worldObj;
            int x = event.x;
            int y = event.y;
            int z = event.z;
            float hardness = world.getBlock(x, y, z).getBlockHardness(world, x, y, z);
            if (hardness == 0.0F)
                event.newSpeed = 0.0F;
            else if (hardness < 5.0F)
                event.newSpeed = 0.1F;
            else if (hardness < 20.0F)
                event.newSpeed = hardness / 2.0F;
            else
                event.newSpeed = 5.0F + hardness;
        }
    }
}
项目:CustomThings    文件:BreakSpeedFixer.java   
@SubscribeEvent
public void onBreakSpeed(BreakSpeed event)
{
    if (event.block instanceof IBlockCustom)
    {
        BlockType type = ((IBlockCustom) event.block).getType(event.metadata);
        if (type.toolType.isEmpty())
        {
            return;
        }
        ItemStack held = event.entityPlayer.getHeldItem();
        if (held != null && !held.getItem().getToolClasses(held).contains(type.toolType))
        {
            event.newSpeed = ForgeHooks.canHarvestBlock(event.block, event.entityPlayer, event.metadata) ? 0.3f : 1;
        }
    }
}
项目:Mini-Bosses    文件:MBEventHandler.java   
@SubscribeEvent
public void changeBreakSpeed(BreakSpeed speed) {
    if(speed.entityPlayer.getExtendedProperties(ExtendedPlayerProperties.PROP_NAME) != null && ConfigHelper.powersEnabled) {
        ExtendedPlayerProperties props = (ExtendedPlayerProperties) speed.entityPlayer.getExtendedProperties(ExtendedPlayerProperties.PROP_NAME);

        if(props.getAbilityUsageAmount() > 0 && props.getPowersEnabled()) {
            speed.newSpeed = speed.originalSpeed * 2;

            if(random.nextInt(149) == 1) {
                props.decreaseAbilityUsage();
            }
        } else {
            speed.newSpeed = speed.originalSpeed;
        }
    }
}
项目:Darklight    文件:AbilityEventHandler.java   
@SubscribeEvent
public void breakSpeed(BreakSpeed event)
{
    if (event.entityPlayer != null)
    {
        DarklightPlayer abilities = DarklightPlayer.get(event.entityPlayer);

        if (abilities != null)
        {
            LogHelper.info("Found player with ability trying to break block");
            if (abilities.isDark || abilities.isLight)
            {
                event.newSpeed = abilities.breakRate;
            }
        }
        else
        {
            LogHelper.info("Player tried break, but has no abilities");
        }
    }
}
项目:CountryGamer_Oceanic    文件:OceanicEventHandler.java   
@ForgeSubscribe
public void onBreaking(BreakSpeed event) {
    if( event.entity instanceof EntityPlayer ) {
        EntityPlayer player = (EntityPlayer)event.entity;
        if( player.isInWater() ) {
            ItemStack chest = player.getCurrentItemOrArmor(3);
            if( chest != null ) {
                float speed1 = event.originalSpeed;
                if( chest.itemID == OceanicMain.wetsuitBody.itemID ) {
                    event.newSpeed = speed1+(speed1*2F);//0.5F);
                }
                if( chest.itemID == OceanicMain.divingSuitBody.itemID ) {
                    event.newSpeed = speed1*4F;//2F;
                }
            }
        }
    }


}
项目:EnderIO    文件:BlockConduitBundle.java   
@SubscribeEvent
public void onBreakSpeed(BreakSpeed event) {
  if (event.getState().getBlock() == this) {
    ItemStack held = event.getEntityPlayer().getHeldItemMainhand();
    if (held.isEmpty() || held.getItem().getHarvestLevel(held, "pickaxe", event.getEntityPlayer(), event.getState()) == -1) {
      event.setNewSpeed(event.getNewSpeed() + 2);
    }
    IConduitBundle te = (IConduitBundle) event.getEntity().world.getTileEntity(NullHelper.notnullF(event.getPos(), "BreakSpeed#getPos"));
    if (te != null && te.getFacadeType().isHardened()) {
      if (!YetaUtil.isSolidFacadeRendered(te, event.getEntityPlayer())) {
        event.setNewSpeed(event.getNewSpeed() * 6);
      } else {
        event.setNewSpeed(event.getNewSpeed() * 2);
      }
    }
  }
}
项目:uniquecrops    文件:EmblemPowerfist.java   
@SubscribeEvent
public void fistingSpeed(BreakSpeed event) {

    ItemStack powerfist = BaublesApi.getBaublesHandler(event.getEntityPlayer()).getStackInSlot(6);
    if (powerfist == null || (powerfist != null && powerfist.getItem() != this)) return;

    ItemStack mininghand = event.getEntityPlayer().getHeldItemMainhand();
    if (mininghand != null) return;

    if (event.getNewSpeed() < 8.0F)
        event.setNewSpeed(8.0F);
}
项目:Aether-Legacy    文件:PlayerAetherEvents.java   
@SubscribeEvent
public void onPlayerStrVsBlock(BreakSpeed event)
{
    PlayerAether playerAether = PlayerAether.get(event.getEntityPlayer());

    if (playerAether != null)
    {
        event.setNewSpeed(playerAether.getCurrentPlayerStrVsBlock(event.getOriginalSpeed()));
    }
}
项目:Toms-Mod    文件:WorldHandler.java   
public static boolean breakSpeed(BreakSpeed event) {
    try {
        float f = getWorldHandlerForDim(event.getEntityPlayer().world.provider.getDimension()).breakSpeed(event.getPos(), event.getEntityPlayer(), event.getOriginalSpeed());
        if (f < 0)
            return true;
        event.setNewSpeed(f);
    } catch (Exception e) {
    }
    return false;
}
项目:morecommands    文件:CommandBreakspeed.java   
@Override
public void onEvent(BreakSpeed event) {
    if (!(event.getEntityPlayer() instanceof EntityPlayerMP)) return;

    ServerPlayerSettings settings = getPlayerSettings((EntityPlayerMP) event.getEntityPlayer());
    event.setNewSpeed(settings.breakspeed > 0 ? settings.breakspeed : event.getOriginalSpeed());
}
项目:Progression    文件:ActionBreakBlock.java   
@SubscribeEvent
public void onBreakSpeed(BreakSpeed event) {
    EntityPlayer player = event.getEntityPlayer();
    if (player != null) {
        Block block = event.getState().getBlock();
        int meta = block.getMetaFromState(event.getState());
        if (ProgressionEvents.isEventCancelled(event.getEntityPlayer(), ActionType.BREAKBLOCKWITH, event.getEntityPlayer().getHeldItemMainhand(), ActionType.BREAKBLOCK, BlockActionHelper.getStackFromBlockData(block, meta))) {
            event.setNewSpeed(0F);
        }
    }
}
项目:Imperium    文件:EventHandlerRestrictions.java   
@SubscribeEvent
public void onBreakSpeed(BreakSpeed event) { // player is trying to break a block
    final ImperiumPlayer playerImperium = ImperiumPlayer.get(event.entityPlayer); 
    if (event.block == Blocks.log)
        checkAbortTree(event, playerImperium);
    else if (event.block == Blocks.log2)
        checkAbortTree(event, playerImperium);
}
项目:Imperium    文件:EventHandlerRestrictions.java   
public void checkAbortTree(final BreakSpeed event, final ImperiumPlayer playerImperium) {
    if (!PlayerData.hasAbility(playerImperium, PlayerAbilities.CANPUNCHWOOD)) {
        if (!playerImperium.eventListDone.toString().contains("WOODPUNCH")) {
            playerImperium.addInstantEvent(TutorialEvents.WOODPUNCH);
            playerImperium.syncToServer("events");
        }
        if(event.isCancelable()) { // not sure if needed but doesn't hurt
            event.entityPlayer.swingProgressInt = 0;
            event.setCanceled(true);
        }
    }
}
项目:mcplus_mods    文件:EventHandlerSickle.java   
@SubscribeEvent
public void onBreakSpeed(BreakSpeed parEvent)
{
    if (parEvent.state.getBlock() instanceof BlockCrops)
    {
        ItemStack playerItem = parEvent.entityPlayer.getCurrentEquippedItem();
        if (playerItem != null && playerItem.getItem() == _Sickle.sickle)
        {
            if (!isFullGrownCrop(parEvent.entity.worldObj, parEvent.pos, parEvent.state))
            {
                parEvent.newSpeed = 0F;
            }
        }
    }
}
项目:Apocalyptic    文件:EventPlayerDestroyBlock.java   
@ForgeSubscribe
public void breakSpeed(BreakSpeed e) {
    World world = e.entityPlayer.worldObj;
    if (world.provider.dimensionId == 4 && (e.block.blockID == 116 || e.block.blockID == 117)) {
        e.setCanceled(true);
    }
}
项目:RandomAdditions    文件:EventHandlerRandom.java   
@SubscribeEvent
public void getSpeed(BreakSpeed event)
{
    ItemStack stack = event.entityPlayer.getHeldItem();
    float newSpeed = 1;
    if(stack != null && stack.getItem() instanceof ItemTool)
    {
        newSpeed = ItemTool.getDigSpeed(event.entityPlayer, stack, event.block, event.metadata);
        if (event.entityPlayer.isPotionActive(Potion.digSpeed))
        {
            newSpeed *= 1.0F + (float)(event.entityPlayer.getActivePotionEffect(Potion.digSpeed).getAmplifier() + 1) * 0.2F;
        }

        if (event.entityPlayer.isPotionActive(Potion.digSlowdown))
        {
            newSpeed *= 1.0F - (float)(event.entityPlayer.getActivePotionEffect(Potion.digSlowdown).getAmplifier() + 1) * 0.2F;
        }

        if (event.entityPlayer.isInsideOfMaterial(Material.water) && !EnchantmentHelper.getAquaAffinityModifier(event.entityPlayer))
        {
            newSpeed /= 5.0F;
        }

        if (!event.entityPlayer.onGround)
        {
            newSpeed /= 5.0F;
        }
        if(ItemTool.getItemDamage(stack) >= ItemTool.getTool(stack).durabilityFactor*ItemTool.getMaterial(stack).durability)
        {
            newSpeed = 1;
        }else{
            ArrayList<EnchantmentModifier> modifiers = CraftMaterial.getModifiers(stack);
            for (int i = 0; i < modifiers.size(); i++) {
                newSpeed = modifiers.get(i).getMiningSpeedLate(event.entityPlayer, stack, ItemTool.getTool(stack).isToolEffective(stack, event.block), event.block, newSpeed);
            }
        }
        event.newSpeed = newSpeed;
    }
}
项目:Toms-Mod    文件:EventHandler.java   
@SubscribeEvent
public void breakSpeed(BreakSpeed event) {
    boolean cancel = WorldHandler.breakSpeed(event);
    if (cancel)
        event.setCanceled(true);
}