Old Optimizations

From EscapeToMars
Jump to navigation Jump to search
  • Detect chickens on hoppers and disable constant falling
  • Entity: this.onGround = this.C && d8 < 0.0D; // kade edit this is shit
  • Skip BoundingBox checks with lastInLavaResult && !blockPositionChanged
  • Skip BoundingBox checks with lastInBlockResult blockPositionChanged
  • EntityCreature - lastFindPath AI stuff
  • EntityEnderman - antiBunker code + PathfinderGoalHurtByTarget - buker code public void e() {
  • EntityExperienceOrb - disable Mending enchantment
  • lastClimableBlockResult
  • lastFrictionFactor, blockPositionChanged
  • lastList, lastCollided
  • Entityplayer - tick container Update Delay / this.activeContainer.b();
  • EntityTrackerEntry - track - velocityChanged ( rocketboots mass spam fix)
            if (!cancelled) { // todo1.13
	            if (this.tracker instanceof EntityPlayer) { // kade edit rocketboots mass-spam fix
	                Player player = (Player) this.tracker.getBukkitEntity();
	                org.bukkit.inventory.ItemStack boots = player.getInventory().getBoots();
	                if(boots != null && boots.getType() == org.bukkit.Material.GOLDEN_BOOTS){
	                    if (this.tracker instanceof EntityPlayer) {
	                        ((EntityPlayer) this.tracker).playerConnection.sendPacket(new PacketPlayOutEntityVelocity(this.tracker));
	                    }
	                    cancelled = true; // fake cancelled to not broadcast two lines below
	                }
	            }
            }
            
            if (!cancelled) { 
                this.broadcastIncludingSelf(new PacketPlayOutEntityVelocity(this.tracker));
            }
  • ItemSkullPlayer fixMobHeadTag
    // Mob-Head-Tag-Fixer kade, allow stacking and remove unneeded signature
    if(fixMobHeadTag(nbttagcompound)) return true; //kade
  • Packet Spamming
    NetworkManager -  protected void a(ChannelHandlerContext channelhandlercontext, Packet<?> packet) throws Exception {
    
    
    	// kade edit: This prevents packet-spamming to lag the server todo1.13	
        public int lastPacketPlayInBlockPlace = 0; //kade 
        private long packetCount = 0;
        private long lastPacketTick = MinecraftServer.currentTick;
        protected void a(ChannelHandlerContext channelhandlercontext, Packet<?> packet) throws Exception {
    		ServerConnection.packetCount++; // kade
    		packetCount++; //kade
    
        	if(MinecraftServer.currentTick > lastPacketTick  + 40){ //kade
        		lastPacketTick = MinecraftServer.currentTick;
        		packetCount = 0;
        	}
        	
    
    //    	if(packet instanceof PacketPlayInCustomPayload) {
    //    		PacketPlayInCustomPayload pp = (PacketPlayInCustomPayload) packet;
    //    		System.out.println(pp);
    //    		System.out.println(pp.a());
    //    	}
        	
    		if (packetCount > 1000){ //kade
    			close(new ChatMessage("disconnect.spam", new Object[0]));
    			OutputHelper.error("Kicking player for packetSpam");
    			return;
    		}
    		
    		if (packet instanceof PacketPlayInBlockPlace) { // kade
    			lastPacketPlayInBlockPlace = 40;
    		}
    		if (lastPacketPlayInBlockPlace > 0) lastPacketPlayInBlockPlace--; // kade
    
            if (this.channel.isOpen()) {
                try {
                    a(packet, this.m);
                } catch (CancelledPacketHandleException cancelledpackethandleexception) {
                    ;
                }
    
                ++this.q;
            }
    
        }
  • PlayerConnection - horse running
                    double movedWronglyThreshold = org.spigotmc.SpigotConfig.movedWronglyThreshold; //kade
                    if(!(entity instanceof EntityPlayer)){ //kade edit fixes buggy stairs-running with horses
                    	movedWronglyThreshold *= 1.5f;
                    }
                    
                    if (d10 > movedWronglyThreshold) { // Spigot
                        flag1 = true;
                        PlayerConnection.LOGGER.warn("{} moved wrongly!", entity.getDisplayName().getString());
                    }
  • Limit Elytra speed to prevent mass chunk loading
    // if(distance > 1.30d){
    // this.player.motX *= 0.75d;
  • Possibly limit enchantment levels again if bugged as in 1.9
    int level = getEnchantmentLevel(Enchantments.LURE, itemstack);
    if(level > 3) level = 3; // kade fix max fortune, luck, loot bonus 3 // 1.9
  • Limit PathfinderGoalMeleeAttack lookups lastLocalPathEntityLookup (zombie hordes lag / villager targeting farm lag)