public void setCombatTask() { if (this.world != null && !this.world.isRemote) { this.tasks.removeTask(this.aiAttackOnCollide); this.tasks.removeTask(this.aiSpellAttack); ItemStack itemstack = this.getHeldItemMainhand(); if (itemstack.getItem() == InfernumItems.SPELL_PAGE && ItemSpellPage.getSpell(itemstack).equals(InfernumSpells.WITHERING_BOLT)) { int i = 30; if (this.world.getDifficulty() != EnumDifficulty.HARD) { i = 50; } this.aiSpellAttack.setAttackCooldown(i); this.tasks.addTask(4, this.aiSpellAttack); } else { this.tasks.addTask(4, this.aiAttackOnCollide); } } }
public GameSettings(Minecraft mcIn, File p_i46326_2_) { this.keyBindings = (KeyBinding[])((KeyBinding[])ArrayUtils.addAll(new KeyBinding[] {this.keyBindAttack, this.keyBindUseItem, this.keyBindForward, this.keyBindLeft, this.keyBindBack, this.keyBindRight, this.keyBindJump, this.keyBindSneak, this.keyBindSprint, this.keyBindDrop, this.keyBindInventory, this.keyBindChat, this.keyBindPlayerList, this.keyBindPickBlock, this.keyBindCommand, this.keyBindScreenshot, this.keyBindTogglePerspective, this.keyBindSmoothCamera, this.keyBindStreamStartStop, this.keyBindStreamPauseUnpause, this.keyBindStreamCommercials, this.keyBindStreamToggleMic, this.keyBindFullscreen, this.keyBindSpectatorOutlines}, this.keyBindsHotbar)); this.difficulty = EnumDifficulty.NORMAL; this.lastServer = ""; this.fovSetting = 70.0F; this.language = "en_US"; this.forceUnicodeFont = false; this.mc = mcIn; this.optionsFile = new File(p_i46326_2_, "options.txt"); this.optionsFileOF = new File(p_i46326_2_, "optionsof.txt"); this.limitFramerate = (int)GameSettings.Options.FRAMERATE_LIMIT.getValueMax(); this.ofKeyBindZoom = new KeyBinding("Zoom", 46, "key.categories.misc"); this.keyBindings = (KeyBinding[])((KeyBinding[])ArrayUtils.add(this.keyBindings, this.ofKeyBindZoom)); GameSettings.Options.RENDER_DISTANCE.setValueMax(32.0F); this.renderDistanceChunks = 8; this.loadOptions(); Config.initGameSettings(this); }
/** * Updates the task */ public void updateTask() { super.updateTask(); if (this.theEntity.getRNG().nextInt(20) == 0) { this.theEntity.worldObj.playAuxSFX(1010, this.doorPosition, 0); } ++this.breakingTime; int i = (int)((float)this.breakingTime / 240.0F * 10.0F); if (i != this.previousBreakProgress) { this.theEntity.worldObj.sendBlockBreakProgress(this.theEntity.getEntityId(), this.doorPosition, i); this.previousBreakProgress = i; } if (this.breakingTime == 240 && this.theEntity.worldObj.getDifficulty() == EnumDifficulty.HARD) { this.theEntity.worldObj.setBlockToAir(this.doorPosition); this.theEntity.worldObj.playAuxSFX(1012, this.doorPosition, 0); this.theEntity.worldObj.playAuxSFX(2001, this.doorPosition, Block.getIdFromBlock(this.doorBlock)); } }
public void setDifficultyForAllWorlds(EnumDifficulty difficulty) { for (WorldServer worldserver : this.worldServers) { if (worldserver != null) { if (worldserver.getWorldInfo().isHardcoreModeEnabled()) { worldserver.getWorldInfo().setDifficulty(EnumDifficulty.HARD); worldserver.setAllowedSpawnTypes(true, true); } else if (this.isSinglePlayer()) { worldserver.getWorldInfo().setDifficulty(difficulty); worldserver.setAllowedSpawnTypes(worldserver.getDifficulty() != EnumDifficulty.PEACEFUL, true); } else { worldserver.getWorldInfo().setDifficulty(difficulty); worldserver.setAllowedSpawnTypes(this.allowSpawnMonsters(), this.canSpawnAnimals); } } } }
@Override @SuppressWarnings("ConstantConditions") public void updateTask() { EntityLivingBase target = eye.getAttackTarget(); if(!eye.canEntityBeSeen(target)) { eye.setAttackTarget(null); } else if(tickCounter++ >= 10) { float f = 1.0F; if(eye.world.getDifficulty() == EnumDifficulty.HARD) { f += 2.0F; } target.attackEntityFrom(DamageSource.causeIndirectMagicDamage(eye, eye), f); target.attackEntityFrom(DamageSource.causeMobDamage(eye), (float) eye.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getAttributeValue()); eye.setAttackTarget(null); } eye.getLookHelper().setLookPosition(target.posX, target.posY + (double) target.getEyeHeight(), target.posZ, (float) eye.getHorizontalFaceSpeed(), (float) eye.getVerticalFaceSpeed()); }
/** * Gives armor or weapon for entity based on given DifficultyInstance */ protected void setEquipmentBasedOnDifficulty(DifficultyInstance difficulty) { super.setEquipmentBasedOnDifficulty(difficulty); if (this.rand.nextFloat() < (this.worldObj.getDifficulty() == EnumDifficulty.HARD ? 0.05F : 0.01F)) { int i = this.rand.nextInt(3); if (i == 0) { this.setCurrentItemOrArmor(0, new ItemStack(Items.iron_sword)); } else { this.setCurrentItemOrArmor(0, new ItemStack(Items.iron_shovel)); } } }
/** * Reads the raw packet data from the data stream. */ public void readPacketData(PacketBuffer buf) throws IOException { this.entityId = buf.readInt(); int i = buf.readUnsignedByte(); this.hardcoreMode = (i & 8) == 8; i = i & -9; this.gameType = WorldSettings.GameType.getByID(i); this.dimension = buf.readByte(); this.difficulty = EnumDifficulty.getDifficultyEnum(buf.readUnsignedByte()); this.maxPlayers = buf.readUnsignedByte(); this.worldType = WorldType.parseWorldType(buf.readStringFromBuffer(16)); if (this.worldType == null) { this.worldType = WorldType.DEFAULT; } this.reducedDebugInfo = buf.readBoolean(); }
/** * Gives armor or weapon for entity based on given DifficultyInstance */ protected void setEquipmentBasedOnDifficulty(DifficultyInstance difficulty) { super.setEquipmentBasedOnDifficulty(difficulty); if (this.rand.nextFloat() < (this.world.getDifficulty() == EnumDifficulty.HARD ? 0.05F : 0.01F)) { int i = this.rand.nextInt(3); if (i == 0) { this.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, new ItemStack(Items.IRON_SWORD)); } else { this.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, new ItemStack(Items.IRON_SHOVEL)); } } }
public GameSettings(Minecraft mcIn, File p_i46326_2_) { this.keyBindings = (KeyBinding[])((KeyBinding[])ArrayUtils.addAll(new KeyBinding[] {this.keyBindAttack, this.keyBindUseItem, this.keyBindForward, this.keyBindLeft, this.keyBindBack, this.keyBindRight, this.keyBindJump, this.keyBindSneak, this.keyBindSprint, this.keyBindDrop, this.keyBindInventory, this.keyBindChat, this.keyBindPlayerList, this.keyBindPickBlock, this.keyBindCommand, this.keyBindScreenshot, this.keyBindTogglePerspective, this.keyBindSmoothCamera, this.keyBindStreamStartStop, this.keyBindStreamPauseUnpause, this.keyBindStreamCommercials, this.keyBindStreamToggleMic, this.keyBindFullscreen, this.keyBindSpectatorOutlines}, this.keyBindsHotbar)); this.difficulty = EnumDifficulty.NORMAL; this.lastServer = ""; this.fovSetting = 70.0F; this.language = "en_US"; this.forceUnicodeFont = false; this.mc = mcIn; this.optionsFile = new File(p_i46326_2_, "options.txt"); this.optionsFileOF = new File(p_i46326_2_, "optionsof.txt"); this.limitFramerate = (int)GameSettings.Options.FRAMERATE_LIMIT.getValueMax(); this.ofKeyBindZoom = new KeyBinding("of.key.zoom", 46, "key.categories.misc"); this.keyBindings = (KeyBinding[])((KeyBinding[])ArrayUtils.add(this.keyBindings, this.ofKeyBindZoom)); GameSettings.Options.RENDER_DISTANCE.setValueMax(32.0F); this.renderDistanceChunks = 8; this.loadOptions(); Config.initGameSettings(this); }
public GameSettings(Minecraft mcIn, File p_i46326_2_) { this.keyBindings = (KeyBinding[])ArrayUtils.addAll(new KeyBinding[] {this.keyBindAttack, this.keyBindUseItem, this.keyBindForward, this.keyBindLeft, this.keyBindBack, this.keyBindRight, this.keyBindJump, this.keyBindSneak, this.keyBindSprint, this.keyBindDrop, this.keyBindInventory, this.keyBindChat, this.keyBindPlayerList, this.keyBindPickBlock, this.keyBindCommand, this.keyBindScreenshot, this.keyBindTogglePerspective, this.keyBindSmoothCamera, this.keyBindStreamStartStop, this.keyBindStreamPauseUnpause, this.keyBindStreamCommercials, this.keyBindStreamToggleMic, this.keyBindFullscreen, this.keyBindSpectatorOutlines}, this.keyBindsHotbar); this.difficulty = EnumDifficulty.NORMAL; this.lastServer = ""; this.fovSetting = 70.0F; this.language = "en_US"; this.forceUnicodeFont = false; this.mc = mcIn; this.optionsFile = new File(p_i46326_2_, "options.txt"); if (mcIn.isJava64bit() && Runtime.getRuntime().maxMemory() >= 1000000000L) { GameSettings.Options.RENDER_DISTANCE.setValueMax(32.0F); } else { GameSettings.Options.RENDER_DISTANCE.setValueMax(16.0F); } this.renderDistanceChunks = mcIn.isJava64bit() ? 12 : 8; this.loadOptions(); }
/** * Reads the raw packet data from the data stream. */ public void readPacketData(PacketBuffer buf) throws IOException { this.playerId = buf.readInt(); int i = buf.readUnsignedByte(); this.hardcoreMode = (i & 8) == 8; i = i & -9; this.gameType = GameType.getByID(i); this.dimension = buf.readInt(); this.difficulty = EnumDifficulty.getDifficultyEnum(buf.readUnsignedByte()); this.maxPlayers = buf.readUnsignedByte(); this.worldType = WorldType.parseWorldType(buf.readStringFromBuffer(16)); if (this.worldType == null) { this.worldType = WorldType.DEFAULT; } this.reducedDebugInfo = buf.readBoolean(); }
public void setDifficultyForAllWorlds(EnumDifficulty difficulty) { for (int i = 0; i < this.worldServers.length; ++i) { World world = this.worldServers[i]; if (world != null) { if (world.getWorldInfo().isHardcoreModeEnabled()) { world.getWorldInfo().setDifficulty(EnumDifficulty.HARD); world.setAllowedSpawnTypes(true, true); } else if (this.isSinglePlayer()) { world.getWorldInfo().setDifficulty(difficulty); world.setAllowedSpawnTypes(world.getDifficulty() != EnumDifficulty.PEACEFUL, true); } else { world.getWorldInfo().setDifficulty(difficulty); world.setAllowedSpawnTypes(this.allowSpawnMonsters(), this.canSpawnAnimals); } } } }
/** * Called to update the entity's position/logic. */ public void onUpdate() { super.onUpdate(); if (!this.worldObj.isRemote && this.worldObj.getDifficulty() == EnumDifficulty.PEACEFUL) { this.setDead(); } }
/** * Called only once on an entity when first time spawned, via egg, mob spawner, natural spawning etc, but not called * when entity is reloaded from nbt. Mainly used for initializing attributes and inventory */ public IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, IEntityLivingData livingdata) { livingdata = super.onInitialSpawn(difficulty, livingdata); if (this.worldObj.rand.nextInt(100) == 0) { EntitySkeleton entityskeleton = new EntitySkeleton(this.worldObj); entityskeleton.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, 0.0F); entityskeleton.onInitialSpawn(difficulty, (IEntityLivingData)null); this.worldObj.spawnEntityInWorld(entityskeleton); entityskeleton.mountEntity(this); } if (livingdata == null) { livingdata = new EntitySpider.GroupData(); if (this.worldObj.getDifficulty() == EnumDifficulty.HARD && this.worldObj.rand.nextFloat() < 0.1F * difficulty.getClampedAdditionalDifficulty()) { ((EntitySpider.GroupData)livingdata).func_111104_a(this.worldObj.rand); } } if (livingdata instanceof EntitySpider.GroupData) { int i = ((EntitySpider.GroupData)livingdata).potionEffectId; if (i > 0 && Potion.potionTypes[i] != null) { this.addPotionEffect(new PotionEffect(i, Integer.MAX_VALUE)); } } return livingdata; }
public EntityLightningBolt(World worldIn, double x, double y, double z, boolean effectOnlyIn) { super(worldIn); this.setLocationAndAngles(x, y, z, 0.0F, 0.0F); this.lightningState = 2; this.boltVertex = this.rand.nextLong(); this.boltLivingTime = this.rand.nextInt(3) + 1; this.effectOnly = effectOnlyIn; BlockPos blockpos = new BlockPos(this); if (!effectOnlyIn && !worldIn.isRemote && worldIn.getGameRules().getBoolean("doFireTick") && (worldIn.getDifficulty() == EnumDifficulty.NORMAL || worldIn.getDifficulty() == EnumDifficulty.HARD) && worldIn.isAreaLoaded(blockpos, 10)) { if (worldIn.getBlockState(blockpos).getMaterial() == Material.AIR && Blocks.FIRE.canPlaceBlockAt(worldIn, blockpos)) { worldIn.setBlockState(blockpos, Blocks.FIRE.getDefaultState()); } for (int i = 0; i < 4; ++i) { BlockPos blockpos1 = blockpos.add(this.rand.nextInt(3) - 1, this.rand.nextInt(3) - 1, this.rand.nextInt(3) - 1); if (worldIn.getBlockState(blockpos1).getMaterial() == Material.AIR && Blocks.FIRE.canPlaceBlockAt(worldIn, blockpos1)) { worldIn.setBlockState(blockpos1, Blocks.FIRE.getDefaultState()); } } } }
public static void attractMobs(EntityLivingBase living, World world) { if (!world.isRemote && TF2ConfigVars.shootAttract && world.getDifficulty().getDifficultyId()>1) { int range=world.getDifficulty()==EnumDifficulty.HARD?60:38; for (EntityCreature mob : world.getEntitiesWithinAABB(EntityCreature.class, living.getEntityBoundingBox().grow(range, range, range), new Predicate<EntityCreature>() { @Override public boolean apply(EntityCreature input) { // TODO Auto-generated method stub return input.getAttackTarget() == null && (input instanceof IMob) && input.isNonBoss(); } })) { mob.getLookHelper().setLookPositionWithEntity(mob, 60, 30); if (!TF2Util.isOnSameTeam(living, mob)) { if (mob.getEntitySenses().canSee(living) || mob.getDistanceSqToEntity(living)<150){ mob.setAttackTarget(living); if(mob.getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE).getModifier(FOLLOW_MODIFIER)==null) mob.getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE) .applyModifier(new AttributeModifier(FOLLOW_MODIFIER, "Follow Check", 65-mob.getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE).getAttributeValue(), 0)); //mob.getNavigator().tryMoveToEntityLiving(living, 1.1f); mob.getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE).removeModifier(FOLLOW_MODIFIER); } // CoroUtilPath.tryMoveToEntityLivingLongDist((EntityCreature)mob, // living, 1.1D); ; } } } }
public S07PacketRespawn(int dimensionIDIn, EnumDifficulty difficultyIn, WorldType worldTypeIn, WorldSettings.GameType gameTypeIn) { this.dimensionID = dimensionIDIn; this.difficulty = difficultyIn; this.gameType = gameTypeIn; this.worldType = worldTypeIn; }
/** * Called to update the entity's position/logic. */ public void onUpdate() { super.onUpdate(); if (!this.world.isRemote && this.world.getDifficulty() == EnumDifficulty.PEACEFUL) { this.setDead(); } }
public void setDifficultyForAllWorlds(EnumDifficulty difficulty) { super.setDifficultyForAllWorlds(difficulty); if (this.mc.world != null) { this.mc.world.getWorldInfo().setDifficulty(difficulty); } }
public GameSettings(Minecraft mcIn, File optionsFileIn) { this.setForgeKeybindProperties(); this.keyBindings = (KeyBinding[])((KeyBinding[])ArrayUtils.addAll(new KeyBinding[] {this.keyBindAttack, this.keyBindUseItem, this.keyBindForward, this.keyBindLeft, this.keyBindBack, this.keyBindRight, this.keyBindJump, this.keyBindSneak, this.keyBindSprint, this.keyBindDrop, this.keyBindInventory, this.keyBindChat, this.keyBindPlayerList, this.keyBindPickBlock, this.keyBindCommand, this.keyBindScreenshot, this.keyBindTogglePerspective, this.keyBindSmoothCamera, this.keyBindFullscreen, this.keyBindSpectatorOutlines, this.keyBindSwapHands}, this.keyBindsHotbar)); this.difficulty = EnumDifficulty.NORMAL; this.lastServer = ""; this.fovSetting = 70.0F; this.language = "en_us"; this.mc = mcIn; this.optionsFile = new File(optionsFileIn, "options.txt"); if (mcIn.isJava64bit() && Runtime.getRuntime().maxMemory() >= 1000000000L) { GameSettings.Options.RENDER_DISTANCE.setValueMax(32.0F); } else { GameSettings.Options.RENDER_DISTANCE.setValueMax(16.0F); } this.renderDistanceChunks = mcIn.isJava64bit() ? 12 : 8; this.optionsFileOF = new File(optionsFileIn, "optionsof.txt"); this.limitFramerate = (int)GameSettings.Options.FRAMERATE_LIMIT.getValueMax(); this.ofKeyBindZoom = new KeyBinding("of.key.zoom", 46, "key.categories.misc"); this.keyBindings = (KeyBinding[])((KeyBinding[])ArrayUtils.add(this.keyBindings, this.ofKeyBindZoom)); GameSettings.Options.RENDER_DISTANCE.setValueMax(32.0F); this.renderDistanceChunks = 8; this.loadOptions(); Config.initGameSettings(this); }
/** * Callback when the command is invoked */ public void processCommand(ICommandSender sender, String[] args) throws CommandException { if (args.length <= 0) { throw new WrongUsageException("commands.difficulty.usage", new Object[0]); } else { EnumDifficulty enumdifficulty = this.getDifficultyFromCommand(args[0]); MinecraftServer.getServer().setDifficultyForAllWorlds(enumdifficulty); notifyOperators(sender, this, "commands.difficulty.success", new Object[] {new ChatComponentTranslation(enumdifficulty.getDifficultyResourceKey(), new Object[0])}); } }
public SPacketRespawn(int dimensionIdIn, EnumDifficulty difficultyIn, WorldType worldTypeIn, GameType gameModeIn) { this.dimensionID = dimensionIdIn; this.difficulty = difficultyIn; this.gameType = gameModeIn; this.worldType = worldTypeIn; }
public void setDifficultyForAllWorlds(EnumDifficulty difficulty) { super.setDifficultyForAllWorlds(difficulty); if (this.mc.theWorld != null) { this.mc.theWorld.getWorldInfo().setDifficulty(difficulty); } }
/** * Checks if the entity's current position is a valid location to spawn this entity. */ public boolean getCanSpawnHere() { BlockPos blockpos = new BlockPos(MathHelper.floor_double(this.posX), 0, MathHelper.floor_double(this.posZ)); Chunk chunk = this.worldObj.getChunkFromBlockCoords(blockpos); if (this.worldObj.getWorldInfo().getTerrainType() == WorldType.FLAT && this.rand.nextInt(4) != 1) { return false; } else { if (this.worldObj.getDifficulty() != EnumDifficulty.PEACEFUL) { BiomeGenBase biomegenbase = this.worldObj.getBiomeGenForCoords(blockpos); if (biomegenbase == BiomeGenBase.swampland && this.posY > 50.0D && this.posY < 70.0D && this.rand.nextFloat() < 0.5F && this.rand.nextFloat() < this.worldObj.getCurrentMoonPhaseFactor() && this.worldObj.getLightFromNeighbors(new BlockPos(this)) <= this.rand.nextInt(8)) { return super.getCanSpawnHere(); } if (this.rand.nextInt(10) == 0 && chunk.getRandomWithSeed(987234911L).nextInt(10) == 0 && this.posY < 40.0D) { return super.getCanSpawnHere(); } } return false; } }
/** * Reads the raw packet data from the data stream. */ public void readPacketData(PacketBuffer buf) throws IOException { this.dimensionID = buf.readInt(); this.difficulty = EnumDifficulty.getDifficultyEnum(buf.readUnsignedByte()); this.gameType = WorldSettings.GameType.getByID(buf.readUnsignedByte()); this.worldType = WorldType.parseWorldType(buf.readStringFromBuffer(16)); if (this.worldType == null) { this.worldType = WorldType.DEFAULT; } }
public boolean attackEntityAsMob(Entity entityIn) { if (super.attackEntityAsMob(entityIn)) { if (entityIn instanceof EntityLivingBase) { int i = 0; if (this.worldObj.getDifficulty() == EnumDifficulty.NORMAL) { i = 7; } else if (this.worldObj.getDifficulty() == EnumDifficulty.HARD) { i = 15; } if (i > 0) { ((EntityLivingBase)entityIn).addPotionEffect(new PotionEffect(Potion.poison.id, i * 20, 0)); } } return true; } else { return false; } }
public GameSettings() { this.keyBindings = (KeyBinding[])((KeyBinding[])ArrayUtils.addAll(new KeyBinding[] {this.keyBindAttack, this.keyBindUseItem, this.keyBindForward, this.keyBindLeft, this.keyBindBack, this.keyBindRight, this.keyBindJump, this.keyBindSneak, this.keyBindSprint, this.keyBindDrop, this.keyBindInventory, this.keyBindChat, this.keyBindPlayerList, this.keyBindPickBlock, this.keyBindCommand, this.keyBindScreenshot, this.keyBindTogglePerspective, this.keyBindSmoothCamera, this.keyBindStreamStartStop, this.keyBindStreamPauseUnpause, this.keyBindStreamCommercials, this.keyBindStreamToggleMic, this.keyBindFullscreen, this.keyBindSpectatorOutlines}, this.keyBindsHotbar)); this.difficulty = EnumDifficulty.NORMAL; this.lastServer = ""; this.fovSetting = 70.0F; this.language = "en_US"; this.forceUnicodeFont = false; }