your current location:首页 > news>How to configure and use [qωq library].QΩq library minecraft game

How to configure and use [qωq library].QΩq library minecraft game

2024-12-10 17:46:53|Myriagame |source:minecraft skins

This tutorial is set by the author's setting without permission.

Since [qωq library] is not passed on a website like CurseForge or Modrinth, a better way to use this library is to quote from local.

Find DependenCies in your Build.gradle and add the following code:

 Modimplementation Filetree (DIR: 'SRC/Main/Libs', Includes: ['*.jar'] 

And put the jar file you downloaded (both using the development version and the release) are placed under the SRC/main/Libs folder.

After re -construction, you should have found that QΩQ has been successfully introduced.

QΩQ provides a method of simple registration of objects such as items, as shown below:

 Public Class iteminit {

Public Static Final Registration items = new registry <> (registry.item, mod_id);

Public Static Final item exmple_item = items.register ("example_item", ()-> new item (new ittem.settings ()));

}

Objects such as blocks are similar to this.

Of course don't forget to add the following sentence to your main class:

@outerride

public void oninitialize () {

Itminit.items.register ();

}

Of course, QΩQ also added a set of event subscription systems similar to Forge. If you want to subscribe to an event, you do this as follows:

@Modevent

public class Oneventhandle {

@SubscripeEvent

Public Static Void Onevent (IEVENT EVENT) {

// Todo

}

// If the parameters are not equal to one, QΩQ will throw a warning and does not subscribe to this method

@SubscripeEvent

Public Static Void Onevent (IEVENT EVENT1, IEVENT EVENT2) {) {

// Todo

}

// The method of annotation of @SubscripeEvent is not added.

Public static void Onevent () {

// Todo

}

}

Please don't forget to check the client in the event. Of course, you should not use the @Envalonment () annotation, which may cause the program to go wrong!

Due to the problem of some mechanisms of QΩq, it cannot completely automatically subscribe to the event. You must tell the program, which folder you put in your event, like this:

@outerride

public void oninitialize () {

Itminit.items.register ();

Eventloader.initevent ("org.abstruck.qwq.init.event");

}

Of course, if you put your events under the Std.init.event folder, you can need not tell the program where you store the event, because the QΩQ in the folder will automatically read.

Note, don't put the class with @mixin notes and put it under the subscribed folder, it will report an error!IntersectionIntersection

If you want to use an event, but you find that when QΩQ is not implemented, you can choose to add it yourself. The following example implements the afterbread event in Block:

 // Remember to inherit the IEVENT interface!

Public Class afterBreakevent Implements IEvent {

Private World World;

Private Playrence Player;

Private blockpos pos;

Private blockstate state;

Private blockity blockitity;

Private itemstack stack;

Public AfterBreakevent (World World, PlayEnceRENTITY PLAYER, Blockpos POS, BlockState State, @nullable Blockentity, ITEMSTACK Stack) { This.World = world;

This.Player = Player;

This.pos = pOS;

This.State = state;

This.blockntity = blockentity;

This.stack = stack;

}

Public PlayErenetity Getplayer () {

Return Player;

}

Public blockpos getpos () {

Return pos;

}

Public blockstate getState () {

Reutrn State;

}

Public world getwork () {Return world;

}

Public blockity getBlockntity () {

Return blockity;

}

Public itemstack getstack () {

Return Stack;

}

}

Of course, only adding this code cannot achieve new events. We have to use Mixin to complete this operation, as shown below:

@mixin (block.class)

public Abstract class blockmixin {

@Inject (Method = "Afterbreak", at = @AT ("Return")

Public Void AfterBreak (World World, PlayErenTity Player, Blockpos POS, BlockState State, Blockentity Blockentity, Itemstack Stack, CallBackinfo Ci) {{{{{{{{{{{{{{{{{

Block self = (block) (object) this;

EventManager.OnEventAction (()-> New AfterBreakevent (World, Player, POS, State, Blockntity, Stack)););););;);

}

}

We like Mixin, but the less it, the better, right?

Like this, you can simply create a new event.

Of course, there is a simpler way to send this issue, and I will add all event requests in Issue as much as possible.

Q & A

Q: Why must QΩQ be telling the folder where the program event is located?

A: The principle of the QΩq subscription event is to scan all class files under a folder, but if scanned to a special class like @mixin, it will report strange errors. At present, there is no solution.

Q: There are too few events that QΩq comes with it. Can I put backsts?

A: Of course, very welcome.

Q: Can QΩq add xxx?

A: You can tell me in the comment area or issue