本文整理匯總了Java中net.minecraftforge.event.entity.player.PlayerEvent.BreakSpeed方法的典型用法代碼示例。如果您正苦於以下問題:Java PlayerEvent.BreakSpeed方法的具體用法?Java PlayerEvent.BreakSpeed怎麽用?Java PlayerEvent.BreakSpeed使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net.minecraftforge.event.entity.player.PlayerEvent
的用法示例。
在下文中一共展示了PlayerEvent.BreakSpeed方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: playerBreakSpeed
import net.minecraftforge.event.entity.player.PlayerEvent; //導入方法依賴的package包/類
/** Adjusts block breaking speed. */
@SubscribeEvent
public void playerBreakSpeed(PlayerEvent.BreakSpeed event) {
Block block = event.getState().getBlock();
ItemStack stack = event.getEntityPlayer().getHeldItemMainhand();
String toolRequired = block.getHarvestTool(event.getState());
// Make axe and pickaxe blocks unbreakable without tool
if (("axe".equals(toolRequired) &&
!(stack.getItem() instanceof ItemAxe)) ||
("pickaxe".equals(toolRequired) &&
!(stack.getItem() instanceof ItemPickaxe))) {
event.setCanceled(true);
}
}
示例2: BreakSpeed
import net.minecraftforge.event.entity.player.PlayerEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void BreakSpeed(PlayerEvent.BreakSpeed evt) {
/* Increases Block-breaking speed while wearing emerald ring (right slot) */
if (evt.entityPlayer != null) {
PlayerRpgInventory inv = PlayerRpgInventory.get(evt.entityPlayer);
if(inv.getShield() != null && evt.entityPlayer.isSneaking())
evt.newSpeed = -1f;
ItemStack ringa = inv.getRing1();
if ((ringa != null)&& ringa.getItem().equals(RpgInventoryMod.ringem))
evt.newSpeed = evt.originalSpeed * 4;
}
}
示例3: onBreakProgress
import net.minecraftforge.event.entity.player.PlayerEvent; //導入方法依賴的package包/類
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onBreakProgress(PlayerEvent.BreakSpeed event) {
EntityPlayer player = event.getEntityPlayer();
if (player != null && player.getHealth() <= 0f) {
event.setNewSpeed(0f);
}
}
示例4: onBreakSpeed
import net.minecraftforge.event.entity.player.PlayerEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onBreakSpeed(PlayerEvent.BreakSpeed event)
{
if (event.getEntityPlayer() != null)
{
if (event.getEntityPlayer().isPotionActive(ExPPotions.stunned))
{
event.setCanceled(true);
}
}
}
示例5: onBreakSpeed
import net.minecraftforge.event.entity.player.PlayerEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onBreakSpeed(PlayerEvent.BreakSpeed event) {
IBlockState block = event.getEntityPlayer().worldObj.getBlockState(event.getPos());
if (block.getMaterial() == Material.GROUND || block.getMaterial() == Material.GRASS) {
event.setNewSpeed(event.getOriginalSpeed() * 2.0F);
}
}
示例6: breakBlock
import net.minecraftforge.event.entity.player.PlayerEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void breakBlock(PlayerEvent.BreakSpeed breakEvent)
{
World world = breakEvent.getEntity().getEntityWorld();
BlockPos breakpos = breakEvent.getPos();
IBlockState state = world.getBlockState(breakpos);
Block block = state.getBlock();
float speed = breakEvent.getNewSpeed();
float multiplier = 1f;
if(InteractionBTWTweak.HARD_STUMPS) {
if(block instanceof BlockLog && state.getValue(BlockLog.LOG_AXIS) == BlockLog.EnumAxis.Y) {
IBlockState bottomstate = world.getBlockState(breakpos.down());
Material material = bottomstate.getMaterial();
if (material == Material.GROUND || material == Material.GRASS)
multiplier = (float)InteractionBTWTweak.HARD_STUMPS_MODIFIER;
}
}
if(InteractionBTWTweak.SOFT_WOODS) {
WoodHardness wood = getSoftWood(block,block.damageDropped(state));
if(wood != null)
multiplier = wood.hardness / state.getBlockHardness(world,breakpos);
}
breakEvent.setNewSpeed(speed * multiplier);
}
示例7: breakBlock
import net.minecraftforge.event.entity.player.PlayerEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void breakBlock(PlayerEvent.BreakSpeed breakEvent) {
World world = breakEvent.getEntity().getEntityWorld();
Entity entity = breakEvent.getEntity();
WorldScaleData scaledata = WorldScaleData.getInstance(world);
BlockPos worldscale = scaledata.getNearbyScale(breakEvent.getPos());
ItemStack banner;
BlockPos breakpos = breakEvent.getPos();
IBlockState blockstate = world.getBlockState(breakpos);
/*if(entity instanceof EntityPlayer) {
ItemStack stack = breakEvent.getEntityPlayer().getHeldItemMainhand();
if (toolShouldntBreak(stack) && breakEvent.getState().getBlockHardness(world,breakEvent.getPos()) > 0.0f) {
breakEvent.setNewSpeed(0f);
return;
}
}*/
float hardnessmod = 1.0f;
if (!(blockstate.getBlock() instanceof BlockLattice) && isNextToHardener(world, breakpos)) {
hardnessmod = 2.0f;
}
float hardness = blockstate.getBlockHardness(world, breakEvent.getPos()) * hardnessmod;
float newspeed = breakEvent.getNewSpeed() * (1.0f / hardnessmod);
if (worldscale != null && !(banner = BannerUtil.getBannerItemFromBlock(world, worldscale.up())).isEmpty()) {
if (!BannerUtil.isSameBanner(banner, entity)) {
newspeed = breakEvent.getOriginalSpeed() * (Math.max(0f, HardnessThreshold - hardness) / HardnessThreshold) * 0.3333f * (1.0f / hardnessmod);
}
}
breakEvent.setNewSpeed(newspeed);
}
示例8: miningSpeed
import net.minecraftforge.event.entity.player.PlayerEvent; //導入方法依賴的package包/類
@Override
public void miningSpeed(ItemStack tool, PlayerEvent.BreakSpeed event) {
World w = event.getEntity().getEntityWorld();
IBlockState state = w.getBlockState(event.getPos());
float speed = event.getOriginalSpeed();
if (!w.isRemote) {
if (state.getBlockHardness(w, event.getPos()) <= 1.0f) {
event.setNewSpeed(speed * speedmulti);
}
}
}
示例9: onStartHarvestLog
import net.minecraftforge.event.entity.player.PlayerEvent; //導入方法依賴的package包/類
/** Try to harvest a log, and give the player Mining Fatigue in treecapitate mode */
@SubscribeEvent
public void onStartHarvestLog(PlayerEvent.BreakSpeed event) {
World world = event.getEntity().worldObj;
if(world.isRemote || !HarvestConfig.doTreeChop) return; // nothing clientside
EntityPlayerMP player = (EntityPlayerMP)event.getEntityPlayer();
if(player != null && canTreecapitate(player, event.getPos(), event.getState())) {
player.addPotionEffect(new PotionEffect(MobEffects.MINING_FATIGUE, 5, HarvestConfig.harvestSpeed, true, false));
}
}
示例10: breakSpeed
import net.minecraftforge.event.entity.player.PlayerEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void breakSpeed(PlayerEvent.BreakSpeed event) {
if (event.getEntityPlayer().getHeldItemMainhand() != null) {
if (event.getEntityPlayer().getHeldItemMainhand().getItem() == Items.malgraPickaxe){
if (event.getEntityPlayer().getHeldItemMainhand().hasTagCompound()) {
if (event.getEntityPlayer().getHeldItemMainhand().getTagCompound().getInteger("malgra") <= 0) {
event.setCanceled(true);
} else {
event.setCanceled(false);
}
}
}
}
}
示例11: boostBreakSpeed
import net.minecraftforge.event.entity.player.PlayerEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void boostBreakSpeed(PlayerEvent.BreakSpeed event) {
if (working.get() != null) {
return;
}
working.set(true);
try {
determineBreakSpeed(event);
} finally {
working.remove();
}
}
示例12: determineBreakSpeed
import net.minecraftforge.event.entity.player.PlayerEvent; //導入方法依賴的package包/類
private void determineBreakSpeed(PlayerEvent.BreakSpeed event) {
final int y = event.pos.getY();
if (y == -1) return; // Event specifies that 'y' might be -1 for unknown usage?
final IBlockState bs = event.state;
final Block block = bs.getBlock();
final int x = event.pos.getX();
final int z = event.pos.getZ();
final EntityPlayer player = event.entityPlayer;
if (stillBusy(player)) return;
if (!canUndo(event, event.pos, block, bs)) return;
// Duplicate logic to figure out what the *actual* break speed will be, so that we don't make this actual break speed too fast
float hardness = block.getBlockHardness(player.worldObj, event.pos);
if (hardness < 0.0F) {
// Block is invulnerable
return;
}
String heldName = DataUtil.getName(player.getHeldItem());
if (heldName == null) heldName = "";
if (heldName.toLowerCase(Locale.ROOT).startsWith("tconstruct:")) {
return; // avoid warp-speed issues
}
final float harvestingSpeed = ForgeHooks.canHarvestBlock(block, player, player.worldObj, event.pos) ? 30F : 100F;
final float max_true_speed = block.hasTileEntity(bs) ? MAX_TRUE_SPEED_TILEENTITY : MAX_TRUE_SPEED_STANDARD;
float true_speed = event.newSpeed / hardness / harvestingSpeed;
if (true_speed > max_true_speed) return;
float boost = max_true_speed * hardness * harvestingSpeed;
event.newSpeed = Math.max(event.newSpeed * boost, event.newSpeed);
event.newSpeed = Math.min(ANTI_WARP_SPEED, event.newSpeed);
// ... this code is wrong. It's suuuper fast for enderchests. Everything too complicated?
// Maybe just a single blind speed, and be done with it?
}
示例13: magPickBonus
import net.minecraftforge.event.entity.player.PlayerEvent; //導入方法依賴的package包/類
/**
* Speeds up the player's ability to harvest Blocks based on their
* experience while using the magPick
*
* @param event
*/
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void magPickBonus(PlayerEvent.BreakSpeed event)
{
EntityPlayer player = event.entityPlayer;
ItemStack itemstack = player.getCurrentEquippedItem();
List<Item> SpeedItems = new ArrayList();
SpeedItems.add(MagItems.MagAxe);
SpeedItems.add(MagItems.MagEarthMover);
SpeedItems.add(MagItems.MagHammer);
SpeedItems.add(MagItems.MagPick);
if (itemstack != null)
{
float bonus = (float) player.experienceLevel;
if (SpeedItems.contains(itemstack.getItem()) && ConfigInfo.EnableXPSpeed)
{
if (ConfigInfo.EnableXPSpeed)
{
event.newSpeed = event.originalSpeed + (bonus / 25);
}
}
else if (itemstack.getItem() == MagItems.MagHatchet)
{
Block block = event.block;
Material material = block.getMaterial();
if (material == Material.plants || material == Material.vine || material == Material.coral || material == Material.leaves
|| material == Material.gourd)
{
event.newSpeed = event.originalSpeed + (bonus / 5);
}
}
}
return;
}
示例14: playerPunchPain
import net.minecraftforge.event.entity.player.PlayerEvent; //導入方法依賴的package包/類
/**
* Damages the player if they try to punch certain blocks Slow then down
* while punching other TODO consider moving from block materials to block
* hardnesses
*
* @param event
*/
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void playerPunchPain(PlayerEvent.BreakSpeed event)
{
EntityPlayer player = event.entityPlayer;
Block block = event.block;
Material material = block.getMaterial();
ItemStack itemstack = player.getCurrentEquippedItem();
if (material == Material.wood || material == Material.anvil || material == Material.rock || material == Material.iron)
{
if (itemstack == null)
{
player.attackEntityFrom(DamageSource.generic, 1.5F);
event.newSpeed = 0.0F;
}
if (itemstack != null && itemstack.getItem().getToolClasses(itemstack).isEmpty())
{
event.newSpeed = 0.0F;
}
}
else
{
if (itemstack == null || itemstack.getItem().getToolClasses(itemstack).isEmpty())
{
event.newSpeed = 0.25F;
}
/**
* A stick is your first tool, like real life survival
*/
if (OreDictionary.itemMatches(new ItemStack(Items.stick), itemstack, true))
{
event.newSpeed = 0.5F;
}
}
return;
}
示例15: onGetBreakSpeed
import net.minecraftforge.event.entity.player.PlayerEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onGetBreakSpeed(PlayerEvent.BreakSpeed event) {
ItemStack item = BaublesApi.getBaubles(event.getEntityPlayer()).getStackInSlot(1);
if (item != null && item.getItem() instanceof ItemFairyRing && !event.getEntityPlayer().worldObj.isRemote) {
List<EntityDigFairy> fairyList = event.getEntityPlayer().worldObj.getEntitiesWithinAABB(EntityDigFairy.class, event.getEntityPlayer().getEntityBoundingBox().expand(20, 20, 20));
int count = -1;
for (EntityDigFairy digFairy : fairyList) {
if (digFairy.player == event.getEntityPlayer()) {
count++;
}
}
count = Math.min(count, 15);
event.setNewSpeed((float) (event.getNewSpeed() * Math.pow(1.08, count)));
}
if (event.getEntityPlayer().inventory.getCurrentItem() != null && AngelsteelToolHelper.isAngelsteelTool(event.getEntityPlayer().inventory.getCurrentItem().getItem())) {
if (event.getEntityPlayer().inventory.getCurrentItem().getTagCompound() == null) {
event.getEntityPlayer().inventory.getCurrentItem().setTagCompound(AngelsteelToolHelper.getRandomBuffCompound(((IAngelsteelTool) event.getEntityPlayer().inventory.getCurrentItem().getItem()).getDegree()));
}
ItemStack tool = event.getEntityPlayer().inventory.getCurrentItem();
if (ForgeHooks.canToolHarvestBlock(event.getEntityPlayer().worldObj, event.getPos(), tool)) {
int[] buffs = AngelsteelToolHelper.readFromNBT(event.getEntityPlayer().inventory.getCurrentItem().getTagCompound());
if (buffs.length > 0) {
int efficiency = buffs[0];
event.setNewSpeed((float) (event.getNewSpeed() * Math.pow(1.3, efficiency)));
int shatter = buffs[2];
int disintegrate = buffs[3];
//1.5F, the hardness of stone, is used as a dividing point
//Stone is not affected by either enchant
if (event.getState().getBlock().getBlockHardness(event.getState(), event.getEntity().worldObj, event.getPos()) <= 1F) {
event.setNewSpeed((float) (event.getNewSpeed() * Math.pow(3, disintegrate)));
}
if (event.getState().getBlock().getBlockHardness(event.getState(), event.getEntity().worldObj, event.getPos()) >= 2F) {
event.setNewSpeed((float) (event.getNewSpeed() * Math.pow(3, shatter)));
}
}
}
}
}