@SubscribeEvent public void playerTick(TickEvent.PlayerTickEvent event) { EntityPlayer player = event.player; TPlayerStats stats = TPlayerStats.get(player); // Wall climb if (stats.climbWalls) { double motionX = player.posX - player.lastTickPosX; double motionZ = player.posZ - player.lastTickPosZ; double motionY = player.posY - player.lastTickPosY - 0.762; if (motionY > 0.0D && (motionX == 0D || motionZ == 0D)) { player.fallDistance = 0.0F; } } // Feet changes ItemStack feet = player.getCurrentArmor(0); if (feet != null) { if (feet.getItem() instanceof IModifyable && !player.isSneaking()) { NBTTagCompound tag = feet.getTagCompound().getCompoundTag(((IModifyable) feet.getItem()).getBaseTagName()); int sole = tag.getInteger("Slimy Soles"); if (sole > 0) { if (!player.isSneaking() && player.onGround && prevMotionY < -0.4) player.motionY = -prevMotionY * (Math.min(0.99, sole * 0.2)); } } prevMotionY = player.motionY; } if (feet != prevFeet) { if (prevFeet != null && prevFeet.getItem() instanceof TravelGear) player.stepHeight -= 0.6f; if (feet != null && feet.getItem() instanceof TravelGear) player.stepHeight += 0.6f; prevFeet = feet; } // TODO: Proper minimap support /*ItemStack stack = player.inventory.getStackInSlot(8); if (stack != null && stack.getItem() instanceof ItemMap) { stack.getItem().onUpdate(stack, player.worldObj, player, 8, true); }*/ if (!player.isPlayerSleeping()) { ItemStack chest = player.getCurrentArmor(2); if (chest == null || !(chest.getItem() instanceof IModifyable)) { if (!morphLoaded || !morphed) PlayerAbilityHelper.setEntitySize(player, 0.6F, 1.8F); } else { NBTTagCompound tag = chest.getTagCompound().getCompoundTag(((IModifyable) chest.getItem()).getBaseTagName()); int dodge = tag.getInteger("Perfect Dodge"); if (dodge > 0) { if (!morphLoaded || !morphed) PlayerAbilityHelper.setEntitySize( player, Math.max(0.15F, 0.6F - (dodge * 0.09f)), 1.8F - (dodge * 0.04f)); } } } }
void tickPlayer(EntityPlayer player) { if (player.worldObj.isRemote) player.stepHeight = player.isSneaking() ? 0.5F : 1F; Utils.setWalkSpeed(player.capabilities, Utils.getWalkSpeed(player.capabilities) + 0.05F); player.jumpMovementFactor = player.isSprinting() ? 0.05F : 0.04F; player.fallDistance = 0F; int x = (int) player.posX; int y = (int) player.posY - 1; int z = (int) player.posZ; if (player.worldObj.getBlockId(x, y, z) == Block.dirt.blockID) player.worldObj.setBlock(x, y, z, Block.grass.blockID, 0, 2); }
@SubscribeEvent public void livingUpdate(LivingUpdateEvent event) { if (event.entityLiving instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) event.entityLiving; ItemStack is = player.inventory.armorItemInSlot(3); if ((is != null) && (is.getItem() == InitItems.itemBrassGoggles)) player.addPotionEffect(new PotionEffect(Potion.nightVision.id, 2, 0, true)); if ((is != null) && (is.getItem() == InitItems.itemDivingHelmet) && player.isInWater()) player.addPotionEffect(new PotionEffect(Potion.nightVision.id, 2, 0, true)); // TODO Change tis!! ItemStack stack = player.inventory.armorItemInSlot(0); if (stack == null) player.stepHeight = 0.5F; } }
@ForgeSubscribe(priority = EventPriority.HIGH) public void onLivingUpdate(LivingUpdateEvent event) { if (event.entityLiving instanceof EntityPlayer && event.entityLiving.worldObj.isRemote) { EntityPlayer player = (EntityPlayer) event.entityLiving; boolean highStepListed = playersWith1Step.contains(player.username); boolean hasHighStep = player.getCurrentArmor(0) != null && player.getCurrentArmor(0).itemID == itemID; if (hasHighStep && !highStepListed) playersWith1Step.add(player.username); if (!hasHighStep && highStepListed) { playersWith1Step.remove(player.username); player.stepHeight = 0.5F; } } }