Quetzal

Quetzal
Quetzal is a Better Than Adventure plugin that I made myself! It uses babric (fabric fork for beta Minecraft) and HalpLibe for common stuff. I've chosen the name Quetzal because they're such pretty birds. Just look at them.
Setting up the project was pretty difficult and required some research. What you want to do is make a fork of HalpLibe example mod. For the documentation the best place I could find was the community documentation although I must admit that it has some outdated examples. Good enough to get started tho!
Quetzal is open source!! If you want to see how I made some stuff you can check it out anytime.

What does Quetzal even do?

Quetzal offers basic utilities for setting and accessing homes and basic teleport request. In short:
  • Teleporting
    • Making teleport requests
    • Teleport sender to receiver or reverse
    • Accepting or denying teleport requests
    • Teleport delay to avoid griefing
  • Homes
    • Setting home location
    • Teleporting to home location
    • Teleport delay to avoid griefing

Tricks

public interface IWorldUtils {
	void addTickCallback(int delayTicks, Consumer<World> callback);

	void addRequestToTeleportTo(Player sender, Player receiver);
	void addRequestToTeleportFrom(Player sender, Player receiver);

	List<TeleportRequest> getPendingRequests(Player receiver);
	TeleportRequest getNewestRequest(Player receiver);

	TickTimer getTickTimer();
}

So how do mixins work? They are basically code snippets injected to some part of the already existing codebase. The most important thing I used it for was to make a tick timer. The class World has an already existing method that runs every tick so I "hijacked" it to register every tick myself. But first you need an interface.

@Mixin(value = World.class, remap = false)
public class WorldOverwriteMixin implements IWorldUtils {
	@Unique
	private final TickTimer tickTimer = new TickTimer();
	
    	... 

	@Override
	public void addTickCallback(int delayTicks, Consumer<World> callback) {
		tickTimer.addTickTask(delayTicks, callback);
	}

	@Inject(method = "tick", at = @At(value = "TAIL"))
	public void tick(CallbackInfo ci) {
		tickTimer.tick((World) (Object) this);
	}

	...

}

The method `tick` will run after each World's class `tick`

Now I can use Mixins however I want.

If you need to do stuff every x amount of ticks, feel free to steal my code!

If you're interested in Better Than Adventure itself please click here!!