TerminatorNL / Tiquality

Make server lag the problem of the source player.
https://www.curseforge.com/minecraft/mc-mods/tiquality
GNU General Public License v3.0
23 stars 12 forks source link

Tiquality

Tiquality is the successor of the seemingly popular mod: LagGoggles.

At this moment, Tiquality is a server side only mod, but supports clients too (Lan hosted).

The core functionality is limiting a player's tick time in the world to evenly distribute time.

Support

If you have an issue, I'd rather have you submit a new issue report on GitHub. If you think it's not worthy of an issue report on GitHub, there's a discord channel where you can contact me in a more informal way. Please note, issues discussed on GitHub are better because other people can find the same problem, and tune in without digging through hundreds of text messages (More organized)

Download

You can download the latest release here. The ONLY difference between THIN and FAT is that FAT ships Mixin, which is a library that Tiquality needs in order to function. It's possible that another mod already ships Mixin or has another version. Generally speaking, Tiquality can handle most Mixin versions well. A known mod to ship Mixin is SpongeForge. If you have SpongeForge or another mod that requires a different version of Mixin, choose the THIN release.

Modpack authors

Yes, you have my permission! Please add this to your modpack! :thumbsup: It will save server admins a lot of time if you do all the configuration work for them! (/tq setblock)

Configuration

Interested in this mod? Check out the default and documented configuration here.

What this is, and what it is intended for

An update throttler, that aims to provide a fair Minecraft experience at 20 TPS for users who do not cause a heavy load on the server, whilst players who build carelessly only get 10 TPS (Their TPS gradually decreases as their impact increases).

This encourages server friendly build behavior, and attempts to not ruin gameplay for others who care about their server.

Generally speaking, players won't notice Tiquality's presence, and don't have to interact with it. On rare occasions, /tq claim can help them out instantly.

This isn't a punishment mod, but makes the culprit face the consequences of their actions on their own. This means that everyone else benefits.

What this is not

This is not something like ClearLagg. Tiquality tries to keep the game fair for everyone, regardless of what someone else is doing.

Behavior

Blocks without an owner which are not specified in the config cannot update. This includes freshly generated areas. To keep functionality like leaf decay and grass growth, you can whitelist blocks in the config. Whitelisted blocks do not need an owner in order to tick.

If a player places a block, Tiquality will assign that block to that player's personal tracker. This tracker will perform future updates for that block, using the time constraint of the player that placed the block.

If more players log in, the time will be divided more. If a player doesn't use up all of his tick time, other's will receive the remaining time.

Logged out player's blocks have less tick time than players who are online (Config customizable)!

When entities spawn or move between chunks, their tracker is updated to match the most dominant tracker (cached) from that chunk. This means that there's full support for entity throttling as well. The most dominant tracker is generated by selecting the owner with the most blocks in a chunk. You take control of a chunk by building in it automatically.

Integration

All of the above are optional.

How it functions

All calls to Block.randomTickBlock(), Block.updateTickBlock(), Entity.onUpdate() and ITickable.tickTileEntity() are redirected to Tiquality, which in turn finds the owner of a block or entity using a customized high performance lookup.

There are trackers associated with the block positions of the world and entities, these trackers record how long an update took, and subtract that from the 'granted nanoseconds' until it reaches zero. When it reaches zero all future updates are queued for later, and the update doesn't execute right away.

When the next tick comes around, all trackers get a granted amount of tracking time, meaning blocks update again. The queue is executed first. If the queue doesn't complete, new updates will be added to the queue if it isn't already.

If a player isn't using up all his tick time, the remaining time will be consumed by players who who have used up all their time.

You can share tick time with other players using /tq share. This is useful for basemates.

Commands and permissions

Frequently asked questions

Why don't you move to Sponge already!?

It is my intention to make Tiquality as widely available to everyone. Not having to install Sponge, match the Forge version, find mods that are both compatible with Sponge and that specific Forge version makes it easier to install. Everyone should be able to use Tiquality, even if you run a Sponge-free server.

Sponge is still supported, however.

What does /tq info do?

It helps you diagnose if a block can be ticked or not, as well as finding names to use in the config

Stand on top of the block and use /tq info. The output will be as follows:

No entities are found in your chunk
Block below: minecraft:piston TickType: DEFAULT Status: Tracked by: Terminator_NL

We can break this down:

Another example of tq info:

Entities in chunk:
minecraft:item PRIORITY Not tracked
Block below: minecraft:grass TickType: NATURAL Status: Not tracked

We can break this down:

Recommended usage:

My blocks don't tick! What do I do?

A block will tick if at least one of the following statements is true:

The fastest way to solve this is simply by standing on the block and running /tq setblock below NATURAL. It will add the block to the config under NATURAL_BLOCKS.

Pro tip: Use /tq info first, to see if you are actually positioned on the block correctly.

My fluids don't flow! What do I do?

Fluid's are tracked the same way as blocks.

The fastest way to solve this is simply by standing in the liquid and running /tq setblock feet NATURAL. It will add the fluid to the config under NATURAL_BLOCKS.

Pro tip: Use /tq info first, to see if you are actually positioned in the liquid correctly.

I just installed Tiquality, and the TPS is HORRIBLE!

Keep in mind, that there are MANY other reasons the TPS can still not be 20. Chunkloading unloaded chunks is one of the big effectors: people exploring, or logging in. Another big effector is post-world-tick processing. Tiquality does NOT hook into world events, so any processing AFTER the world tick is completely outside of Tiquality's control. You can try to raise the config value TIME_BETWEEN_TICKS_IN_NS. Remember that increasing this value will cause the world to stop ticking sooner, effectively making the world tick slower.

Where is the data stored?

The data is stored in the world folder under TiqualityStorage. Inspired by minecraft's own code, Tiquality also uses bitshifting to find the right identifier for a block, without having to iterate on anything. This means blazing fast performance, and this is needed because Tiquality has to intercept and act on every ticked object.

I have an idea! What can I do to help?

Make an issue at GitHub and I'll give you some feedback. (I might already have considered your idea!) After that, fork Tiquality and just make a pull request! If you can't code, you can obviously still submit requests, and I will implement it as long as it fits the scope of the project.