Bump version. Add event for restore queue registration

This commit is contained in:
zontreck 2024-04-12 08:28:40 -07:00
parent 25aa4b2f9d
commit 20a756277d
6 changed files with 25 additions and 15 deletions

View file

@ -53,7 +53,7 @@ mod_name=Zontreck's Library Mod
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
mod_license=GPLv3
# The mod version. See https://semver.org/
mod_version=1201.13.041224.0752
mod_version=1201.13.041224.0827
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
# This should match the base package used for the mod sources.
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html

View file

@ -11,6 +11,7 @@ import java.util.UUID;
import dev.zontreck.libzontreck.chestgui.ChestGUIRegistry;
import dev.zontreck.libzontreck.currency.Bank;
import dev.zontreck.libzontreck.currency.CurrencyHelper;
import dev.zontreck.libzontreck.events.BlockRestoreQueueRegistrationEvent;
import dev.zontreck.libzontreck.items.ModItems;
import dev.zontreck.libzontreck.menus.ChestGUIScreen;
import dev.zontreck.libzontreck.types.ModMenuTypes;
@ -106,6 +107,8 @@ public class LibZontreck {
{
ALIVE=true;
CURRENT_SIDE = LogicalSide.SERVER;
MinecraftForge.EVENT_BUS.post(new BlockRestoreQueueRegistrationEvent());
}
@SubscribeEvent

View file

@ -6,11 +6,7 @@ import java.util.List;
import dev.zontreck.libzontreck.networking.packets.IPacket;
import net.minecraftforge.eventbus.api.Event;
/**
* Used to register your packets with LibZontreck. Packets must extend IPacket and implement PacketSerializable. This is dispatched on both logical sides, and is considered a final event. It is not cancelable
* @see IPacket
*/
@Deprecated
public class RegisterPacketsEvent extends Event
{
public final List<IPacket> packets = new ArrayList<>();
}

View file

@ -2,6 +2,8 @@ package dev.zontreck.libzontreck.memory.world;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.block.Block;
import net.minecraftforge.event.TickEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import java.util.ArrayList;
import java.util.List;
@ -112,4 +114,13 @@ public abstract class BlockRestoreQueue
Thread tx = new Thread(RUNNER);
tx.start();
}
@SubscribeEvent
public void onTick(TickEvent.LevelTickEvent event)
{
if(event.phase == TickEvent.Phase.END)
{
tick();
}
}
}

View file

@ -18,4 +18,13 @@ public class BlockRestoreQueueRegistry
public static void addQueue(BlockRestoreQueue queue) {
QUEUES.put(queue.getRestoreQueueName(), queue);
}
/**
* Retrieves a registered restore queue by its name
* @param restoreQueueName Queue Name
* @return
*/
public static BlockRestoreQueue getQueue(String restoreQueueName) {
return QUEUES.get(restoreQueueName);
}
}

View file

@ -36,16 +36,7 @@ public class ModMessages {
.clientAcceptedVersions(s->true)
.serverAcceptedVersions(s->true)
.simpleChannel();
RegisterPacketsEvent event = new RegisterPacketsEvent();
MinecraftForge.EVENT_BUS.post(event);
INSTANCE=net;
for(IPacket packet : event.packets)
{
packet.register(net);
}
net.messageBuilder(S2CPlaySoundPacket.class, PACKET_ID.getAndIncrement(), NetworkDirection.PLAY_TO_CLIENT)
.decoder(S2CPlaySoundPacket::new)