Update to 1.20.1
This commit is contained in:
parent
0066b86d18
commit
f3b1ccbd3a
20 changed files with 200 additions and 166 deletions
86
build.gradle
86
build.gradle
|
@ -1,13 +1,21 @@
|
|||
plugins {
|
||||
id 'eclipse'
|
||||
id 'maven-publish'
|
||||
id 'net.minecraftforge.gradle' version '5.1.+'
|
||||
id 'java-library'
|
||||
id 'net.minecraftforge.gradle' version '[6.0,6.2)'
|
||||
id 'org.parchmentmc.librarian.forgegradle' version '1.+'
|
||||
}
|
||||
|
||||
version = "${mc_version}-${myversion}"
|
||||
group = 'dev.zontreck' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||
archivesBaseName = 'libzontreck'
|
||||
version = "${mc_version}-${mod_version}"
|
||||
group = mod_group_id
|
||||
|
||||
base {
|
||||
archivesName = mod_id
|
||||
}
|
||||
|
||||
java {
|
||||
withSourcesJar()
|
||||
}
|
||||
|
||||
// Mojang ships Java 17 to end users in 1.18+, so your mod should target Java 17.
|
||||
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
|
||||
|
@ -35,6 +43,8 @@ minecraft {
|
|||
mappings channel: 'parchment', version: "${parchment_version}-${mc_version}"
|
||||
// mappings channel: 'official', version: "${mc_version}"
|
||||
|
||||
copyIdeResources = true
|
||||
|
||||
|
||||
// accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') // Currently, this location cannot be changed from the default.
|
||||
|
||||
|
@ -152,69 +162,63 @@ dependencies {
|
|||
implementation "dev.zontreck:LibAC:${libac}"
|
||||
minecraftLibrary "dev.zontreck:LibAC:${libac}"
|
||||
|
||||
provided "dev.zontreck:EventsBus:${eventsbus}"
|
||||
implementation "dev.zontreck:EventsBus:${eventsbus}"
|
||||
minecraftLibrary "dev.zontreck:EventsBus:${eventsbus}"
|
||||
|
||||
|
||||
// For more info...
|
||||
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
|
||||
// http://www.gradle.org/docs/current/userguide/dependency_management.html
|
||||
}
|
||||
|
||||
// Example for how to get properties into the manifest for reading at runtime.
|
||||
jar {
|
||||
tasks.named('processResources', ProcessResources).configure {
|
||||
var replaceProperties = [
|
||||
minecraft_version: minecraft_version, minecraft_version_range: minecraft_version_range,
|
||||
forge_version: forge_version, forge_version_range: forge_version_range,
|
||||
loader_version_range: loader_version_range,
|
||||
mod_id: mod_id, mod_name: mod_name, mod_license: mod_license, mod_version: mod_version,
|
||||
mod_authors: mod_authors, mod_description: mod_description,
|
||||
]
|
||||
inputs.properties replaceProperties
|
||||
|
||||
filesMatching(['META-INF/mods.toml', 'pack.mcmeta']) {
|
||||
expand replaceProperties + [project: project]
|
||||
}
|
||||
}
|
||||
|
||||
tasks.named('jar', Jar).configure {
|
||||
from {
|
||||
configurations.provided.asFileTree.collect{zipTree(it)}
|
||||
}
|
||||
manifest {
|
||||
attributes([
|
||||
"Specification-Title" : project.name,
|
||||
"Specification-Vendor" : "zontreck",
|
||||
"Specification-Version": "${myversion}",
|
||||
"Specification-Title" : mod_id,
|
||||
"Specification-Vendor" : mod_authors,
|
||||
"Specification-Version": "${mod_version}",
|
||||
"Implementation-Title": project.name,
|
||||
"Implementation-Version": "${myversion}",
|
||||
"Implementation-Vendor" : "zontreck",
|
||||
"Implementation-Version": "${mod_version}",
|
||||
"Implementation-Vendor" : mod_authors,
|
||||
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
|
||||
])
|
||||
}
|
||||
|
||||
finalizedBy 'reobfJar'
|
||||
}
|
||||
|
||||
|
||||
compileJava.finalizedBy('devJar')
|
||||
// Example configuration to allow publishing using the maven-publish plugin
|
||||
// This is the preferred method to reobfuscate your jar file
|
||||
jar.finalizedBy('reobfJar')
|
||||
compileJava.finalizedBy('sourcesJar')
|
||||
|
||||
// However if you are in a multi-project build, dev time needs unobfed jar files, so you can delay the obfuscation until publishing by doing
|
||||
// publish.dependsOn('reobfJar')
|
||||
|
||||
task devJar(type: Jar) {
|
||||
|
||||
from sourceSets.main.output
|
||||
from sourceSets.main.allJava
|
||||
classifier = 'dev'
|
||||
|
||||
from {
|
||||
configurations.provided.asFileTree.collect{zipTree(it)}
|
||||
}
|
||||
manifest {
|
||||
attributes([
|
||||
"Specification-Title": project.name,
|
||||
"Specification-Vendor": "zontreck",
|
||||
"Specification-Version": "${myversion}",
|
||||
"Implementation-Title": project.name,
|
||||
"Implementation-Version": "${myversion}",
|
||||
"Implementation-Vendor": "zontreck",
|
||||
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
|
||||
])
|
||||
}
|
||||
}
|
||||
|
||||
devJar.finalizedBy('reobfJar')
|
||||
|
||||
|
||||
def MAVEN_PASSWORD_PROPERTY = "AriasCreationsMavenPassword"
|
||||
publishing {
|
||||
publications {
|
||||
mavenJava(MavenPublication) {
|
||||
artifact jar
|
||||
artifact devJar
|
||||
artifact sourcesJar
|
||||
}
|
||||
}
|
||||
repositories {
|
||||
|
@ -236,5 +240,5 @@ tasks.withType(JavaCompile).configureEach {
|
|||
}
|
||||
|
||||
artifacts {
|
||||
archives devJar
|
||||
archives sourcesJar
|
||||
}
|
|
@ -3,10 +3,44 @@
|
|||
org.gradle.jvmargs=-Xmx3G
|
||||
org.gradle.daemon=false
|
||||
|
||||
mc_version=1.19.3
|
||||
forge_version=44.1.0
|
||||
myversion=1.0.7.0515232132
|
||||
parchment_version=2023.03.12
|
||||
mc_version=1.20.1
|
||||
forge_version=47.2.0
|
||||
parchment_version=2023.09.03
|
||||
# luckperms_api_version=5.4
|
||||
|
||||
libac=1.3.61
|
||||
libac=1.4.1
|
||||
eventsbus=1.0.16
|
||||
|
||||
|
||||
|
||||
# The Forge version range can use any version of Forge as bounds or match the loader version range
|
||||
forge_version_range=[47,)
|
||||
# The loader version range can only use the major version of Forge/FML as bounds
|
||||
loader_version_range=[47,)
|
||||
minecraft_range=[1.20.1,1.21]
|
||||
|
||||
|
||||
# Parchment is an unofficial project maintained by ParchmentMC, separate from Minecraft Forge.
|
||||
# Additional setup is needed to use their mappings, see https://parchmentmc.org/docs/getting-started
|
||||
mapping_channel=official
|
||||
# The mapping version to query from the mapping channel.
|
||||
# This must match the format required by the mapping channel.
|
||||
mapping_version=1.20.1
|
||||
|
||||
# The unique mod identifier for the mod. Must be lowercase in English locale. Must fit the regex [a-z][a-z0-9_]{1,63}
|
||||
# Must match the String constant located in the main mod class annotated with @Mod.
|
||||
mod_id=libzontreck
|
||||
# The human-readable display name for the mod.
|
||||
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=All Rights Reserved
|
||||
# The mod version. See https://semver.org/
|
||||
mod_version=1.0.8.1119230115
|
||||
# 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
|
||||
mod_group_id=dev.zontreck
|
||||
# The authors of the mod. This is a simple text string that is used for display purposes in the mod list.
|
||||
mod_authors=Zontreck
|
||||
# The description of the mod. This is a simple multiline text string that is used for display purposes in the mod list.
|
||||
mod_description=This is a library mod. It contains code used commonly in all or most Zontreck Projects
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
|
@ -1,5 +1,5 @@
|
|||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
|
|
@ -7,4 +7,7 @@ pluginManagement {
|
|||
}
|
||||
}
|
||||
|
||||
rootProject.name = "libzontreck"
|
||||
|
||||
plugins {
|
||||
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.5.0'
|
||||
}
|
|
@ -8,7 +8,8 @@ import java.util.Iterator;
|
|||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import dev.zontreck.ariaslib.events.EventBus;
|
||||
import dev.zontreck.ariaslib.util.DelayedExecutorService;
|
||||
import dev.zontreck.eventsbus.Bus;
|
||||
import dev.zontreck.libzontreck.currency.Bank;
|
||||
import dev.zontreck.libzontreck.currency.CurrencyHelper;
|
||||
import dev.zontreck.libzontreck.networking.NetworkEvents;
|
||||
|
@ -16,7 +17,6 @@ import org.slf4j.Logger;
|
|||
|
||||
import com.mojang.logging.LogUtils;
|
||||
|
||||
import dev.zontreck.ariaslib.util.DelayedExecutorService;
|
||||
import dev.zontreck.libzontreck.commands.Commands;
|
||||
import dev.zontreck.libzontreck.events.ForgeEventHandlers;
|
||||
import dev.zontreck.libzontreck.memory.VolatilePlayerStorage;
|
||||
|
@ -80,8 +80,10 @@ public class LibZontreck {
|
|||
MinecraftForge.EVENT_BUS.register(new ForgeEventHandlers());
|
||||
MinecraftForge.EVENT_BUS.register(new Commands());
|
||||
MinecraftForge.EVENT_BUS.register(new NetworkEvents());
|
||||
EventBus.BUS.register(CurrencyHelper.class);
|
||||
EventBus.BUS.register(Bank.class);
|
||||
|
||||
|
||||
Bus.Register(CurrencyHelper.class, null);
|
||||
Bus.Register(Bank.class, null);
|
||||
}
|
||||
|
||||
private void setup(final FMLCommonSetupEvent event)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package dev.zontreck.libzontreck.currency;
|
||||
|
||||
import dev.zontreck.ariaslib.events.EventBus;
|
||||
|
||||
import dev.zontreck.eventsbus.Bus;
|
||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||
import dev.zontreck.libzontreck.currency.events.TransactionHistoryFlushEvent;
|
||||
import dev.zontreck.libzontreck.profiles.Profile;
|
||||
|
@ -11,6 +12,7 @@ import net.minecraft.nbt.ListTag;
|
|||
import net.minecraft.nbt.NbtUtils;
|
||||
import net.minecraft.nbt.Tag;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
@ -88,12 +90,17 @@ public class Account
|
|||
* When the TX history grows beyond 20, the history should clear and it should get transferred to the long-term tx history storage. That file is not retained in memory, and only gets loaded when clearing to merge the lists. It is immediately saved and unloaded
|
||||
* @see LongTermTransactionHistoryRecord
|
||||
*/
|
||||
public void flushTxHistory()
|
||||
{
|
||||
public void flushTxHistory() {
|
||||
LongTermTransactionHistoryRecord rec = LongTermTransactionHistoryRecord.of(player_id);
|
||||
rec.addHistory(history);
|
||||
rec.commit();
|
||||
EventBus.BUS.post(new TransactionHistoryFlushEvent(this, rec, history));
|
||||
try {
|
||||
Bus.Post(new TransactionHistoryFlushEvent(this, rec, history));
|
||||
} catch (InvocationTargetException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
rec = null;
|
||||
history = new ArrayList<>();
|
||||
}
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
package dev.zontreck.libzontreck.currency;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import dev.zontreck.ariaslib.events.Event;
|
||||
import dev.zontreck.ariaslib.events.EventBus;
|
||||
import dev.zontreck.ariaslib.events.annotations.Subscribe;
|
||||
import dev.zontreck.eventsbus.Bus;
|
||||
import dev.zontreck.eventsbus.Subscribe;
|
||||
import dev.zontreck.libzontreck.LibZontreck;
|
||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||
import dev.zontreck.libzontreck.chat.ChatColorFactory;
|
||||
|
@ -25,6 +24,7 @@ import net.minecraft.nbt.Tag;
|
|||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -81,11 +81,15 @@ public class Bank
|
|||
accounts.add(new Account((CompoundTag) t));
|
||||
}
|
||||
|
||||
EventBus.BUS.post(new BankReadyEvent());
|
||||
Bus.Post(new BankReadyEvent());
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
} catch (InvocationTargetException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Do not use manually, this saves the bank data to disk. This is fired automatically when transactions are posted to accounts.
|
||||
|
@ -128,8 +132,15 @@ public class Bank
|
|||
instance.accounts.add(new Account(ID));
|
||||
|
||||
instance.commit();
|
||||
EventBus.BUS.post(new BankAccountCreatedEvent(getAccount(ID)));
|
||||
}else return;
|
||||
try {
|
||||
Bus.Post(new BankAccountCreatedEvent(getAccount(ID)));
|
||||
} catch (InvocationTargetException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}else {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -139,10 +150,10 @@ public class Bank
|
|||
* @param tx The transaction being attempted
|
||||
* @return True if the transaction has been accepted. False if the transaction was rejected, or insufficient funds.
|
||||
*/
|
||||
protected static boolean postTx(Transaction tx) throws InvalidSideException {
|
||||
protected static boolean postTx(Transaction tx) throws InvalidSideException, InvocationTargetException, IllegalAccessException {
|
||||
if(ServerUtilities.isClient())return false;
|
||||
TransactionEvent ev = new TransactionEvent(tx);
|
||||
if(EventBus.BUS.post(ev))
|
||||
if(Bus.Post(ev))
|
||||
{
|
||||
// Send the list of reasons to the user
|
||||
String reasonStr = String.join("\n", ev.reasons);
|
||||
|
@ -207,8 +218,9 @@ public class Bank
|
|||
Profile.unload(fromProf);
|
||||
|
||||
|
||||
EventBus.BUS.post(new WalletUpdatedEvent(from.player_id, fromOld, from.balance, tx));
|
||||
EventBus.BUS.post(new WalletUpdatedEvent(to.player_id, toOld, to.balance, tx));
|
||||
Bus.Post(new WalletUpdatedEvent(from.player_id, fromOld, from.balance, tx));
|
||||
|
||||
Bus.Post(new WalletUpdatedEvent(to.player_id, toOld, to.balance, tx));
|
||||
|
||||
if(from.isValidPlayer() && !ServerUtilities.playerIsOffline(from.player_id))
|
||||
{
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package dev.zontreck.libzontreck.currency;
|
||||
|
||||
import dev.zontreck.ariaslib.events.annotations.Subscribe;
|
||||
|
||||
public class CurrencyHelper {
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ import dev.zontreck.libzontreck.exceptions.InvalidSideException;
|
|||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtUtils;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.Date;
|
||||
|
||||
public class Transaction
|
||||
|
@ -48,7 +49,7 @@ public class Transaction
|
|||
public boolean submit(){
|
||||
try {
|
||||
return Bank.postTx(this);
|
||||
} catch (InvalidSideException e) {
|
||||
} catch (InvalidSideException | InvocationTargetException | IllegalAccessException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package dev.zontreck.libzontreck.currency.events;
|
||||
|
||||
|
||||
import dev.zontreck.ariaslib.events.Event;
|
||||
import dev.zontreck.eventsbus.Event;
|
||||
import dev.zontreck.libzontreck.currency.Account;
|
||||
|
||||
public class BankAccountCreatedEvent extends Event
|
||||
|
@ -11,9 +11,4 @@ public class BankAccountCreatedEvent extends Event
|
|||
{
|
||||
account=act;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancellable() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package dev.zontreck.libzontreck.currency.events;
|
||||
|
||||
import dev.zontreck.ariaslib.events.Event;
|
||||
|
||||
import dev.zontreck.eventsbus.Event;
|
||||
|
||||
/**
|
||||
* Contains no information by itself, it only signals that the Bank is open for business
|
||||
|
@ -10,8 +11,4 @@ import dev.zontreck.ariaslib.events.Event;
|
|||
public class BankReadyEvent extends Event
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean isCancellable() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,15 @@
|
|||
package dev.zontreck.libzontreck.currency.events;
|
||||
|
||||
import dev.zontreck.ariaslib.events.Event;
|
||||
|
||||
import dev.zontreck.eventsbus.Cancellable;
|
||||
import dev.zontreck.eventsbus.Event;
|
||||
import dev.zontreck.libzontreck.currency.Transaction;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.util.List;
|
||||
|
||||
@Cancellable
|
||||
public class TransactionEvent extends Event
|
||||
{
|
||||
public Transaction tx;
|
||||
|
@ -18,9 +23,4 @@ public class TransactionEvent extends Event
|
|||
{
|
||||
tx=txNew;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancellable() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package dev.zontreck.libzontreck.currency.events;
|
||||
|
||||
import dev.zontreck.ariaslib.events.Event;
|
||||
|
||||
import dev.zontreck.eventsbus.Event;
|
||||
import dev.zontreck.libzontreck.currency.Account;
|
||||
import dev.zontreck.libzontreck.currency.LongTermTransactionHistoryRecord;
|
||||
import dev.zontreck.libzontreck.currency.Transaction;
|
||||
|
@ -19,9 +20,4 @@ public class TransactionHistoryFlushEvent extends Event
|
|||
this.txHistory=txHistory;
|
||||
this.flushed=flushed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancellable() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package dev.zontreck.libzontreck.currency.events;
|
||||
|
||||
import dev.zontreck.ariaslib.events.Event;
|
||||
import dev.zontreck.eventsbus.Event;
|
||||
import dev.zontreck.libzontreck.currency.Transaction;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
|
||||
|
@ -23,8 +23,4 @@ public class WalletUpdatedEvent extends Event
|
|||
this.newBal = newBal;
|
||||
this.tx=tx;
|
||||
}
|
||||
@Override
|
||||
public boolean isCancellable() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package dev.zontreck.libzontreck.events;
|
||||
|
||||
import dev.zontreck.ariaslib.events.EventBus;
|
||||
import dev.zontreck.ariaslib.terminal.Task;
|
||||
import dev.zontreck.ariaslib.util.DelayedExecutorService;
|
||||
import dev.zontreck.libzontreck.LibZontreck;
|
||||
|
@ -25,11 +24,10 @@ public class ForgeEventHandlers {
|
|||
@SubscribeEvent
|
||||
public void onPlayerTick(LivingEvent.LivingTickEvent ev)
|
||||
{
|
||||
if(ev.getEntity().level.isClientSide)return;
|
||||
if(ev.getEntity().level().isClientSide) return;
|
||||
|
||||
if(ev.getEntity() instanceof ServerPlayer)
|
||||
if(ev.getEntity() instanceof ServerPlayer player)
|
||||
{
|
||||
ServerPlayer player = (ServerPlayer)ev.getEntity();
|
||||
PlayerContainer cont = LibZontreck.playerStorage.get(player.getUUID());
|
||||
|
||||
if(cont.player.positionChanged())
|
||||
|
@ -45,11 +43,11 @@ public class ForgeEventHandlers {
|
|||
@SubscribeEvent
|
||||
public void onPlayerJoin(final PlayerEvent.PlayerLoggedInEvent ev)
|
||||
{
|
||||
if(ev.getEntity().level.isClientSide)return;
|
||||
if(ev.getEntity().level().isClientSide)return;
|
||||
|
||||
ServerPlayer player = (ServerPlayer)ev.getEntity();
|
||||
Profile prof = Profile.factory(player);
|
||||
ServerLevel level = player.getLevel();
|
||||
ServerLevel level = player.serverLevel();
|
||||
|
||||
MinecraftForge.EVENT_BUS.post(new ProfileLoadedEvent(prof, player, level));
|
||||
|
||||
|
@ -65,7 +63,7 @@ public class ForgeEventHandlers {
|
|||
@SubscribeEvent
|
||||
public void onLeave(final PlayerEvent.PlayerLoggedOutEvent ev)
|
||||
{
|
||||
if(ev.getEntity().level.isClientSide)return;
|
||||
if(ev.getEntity().level().isClientSide)return;
|
||||
// Get player profile, send disconnect alert, then commit profile and remove it from memory
|
||||
Profile px=null;
|
||||
try {
|
||||
|
|
|
@ -9,7 +9,6 @@ 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
|
||||
* @see PacketSerializable
|
||||
*/
|
||||
public class RegisterPacketsEvent extends Event
|
||||
{
|
||||
|
|
|
@ -2,7 +2,6 @@ package dev.zontreck.libzontreck.exceptions;
|
|||
|
||||
/**
|
||||
* Thrown when requesting a world position's level on the client when in the wrong dimension.
|
||||
* @see WorldPosition
|
||||
*/
|
||||
public class InvalidSideException extends Exception
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package dev.zontreck.libzontreck.networking.packets;
|
||||
|
||||
import dev.zontreck.ariaslib.events.EventBus;
|
||||
import dev.zontreck.eventsbus.Bus;
|
||||
import dev.zontreck.libzontreck.currency.Transaction;
|
||||
import dev.zontreck.libzontreck.currency.events.WalletUpdatedEvent;
|
||||
import dev.zontreck.libzontreck.util.ServerUtilities;
|
||||
|
@ -10,6 +10,7 @@ import net.minecraftforge.network.NetworkDirection;
|
|||
import net.minecraftforge.network.NetworkEvent;
|
||||
import net.minecraftforge.network.simple.SimpleChannel;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
|
@ -62,7 +63,13 @@ public class S2CWalletUpdatedPacket implements IPacket
|
|||
return ServerUtilities.handlePacket(supplier, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
EventBus.BUS.post(new WalletUpdatedEvent(ID, oldBal, balance, tx));
|
||||
try {
|
||||
Bus.Post(new WalletUpdatedEvent(ID, oldBal, balance, tx));
|
||||
} catch (InvocationTargetException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
|
|
@ -8,20 +8,18 @@ import net.minecraft.resources.ResourceLocation;
|
|||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
|
||||
public class WorldPosition
|
||||
{
|
||||
public class WorldPosition {
|
||||
|
||||
public Vector3 Position;
|
||||
public String Dimension;
|
||||
public String DimSafe;
|
||||
|
||||
public WorldPosition(CompoundTag tag, boolean pretty) throws InvalidDeserialization
|
||||
{
|
||||
if(pretty){
|
||||
public WorldPosition(CompoundTag tag, boolean pretty) throws InvalidDeserialization {
|
||||
if (pretty) {
|
||||
|
||||
Position = new Vector3(tag.getString("Position"));
|
||||
Dimension = tag.getString("Dimension");
|
||||
}else {
|
||||
} else {
|
||||
Position = new Vector3(tag.getCompound("pos"));
|
||||
Dimension = tag.getString("Dimension");
|
||||
}
|
||||
|
@ -30,54 +28,48 @@ public class WorldPosition
|
|||
|
||||
}
|
||||
|
||||
public WorldPosition(Vector3 pos, String dim)
|
||||
{
|
||||
Position=pos;
|
||||
Dimension=dim;
|
||||
public WorldPosition(Vector3 pos, String dim) {
|
||||
Position = pos;
|
||||
Dimension = dim;
|
||||
calcDimSafe();
|
||||
}
|
||||
|
||||
public WorldPosition(ServerPlayer player)
|
||||
{
|
||||
this(new Vector3(player.position()), player.getLevel());
|
||||
public WorldPosition(ServerPlayer player) {
|
||||
this(new Vector3(player.position()), player.serverLevel());
|
||||
}
|
||||
|
||||
public WorldPosition(Vector3 pos, ServerLevel lvl)
|
||||
{
|
||||
Position=pos;
|
||||
Dimension = lvl.dimension().location().getNamespace() + ":"+lvl.dimension().location().getPath();
|
||||
public WorldPosition(Vector3 pos, ServerLevel lvl) {
|
||||
Position = pos;
|
||||
Dimension = lvl.dimension().location().getNamespace() + ":" + lvl.dimension().location().getPath();
|
||||
calcDimSafe();
|
||||
}
|
||||
|
||||
public void calcDimSafe()
|
||||
{
|
||||
public void calcDimSafe() {
|
||||
ServerLevel lvl = getActualDimension();
|
||||
DimSafe = lvl.dimension().location().getNamespace() + "-" + lvl.dimension().location().getPath();
|
||||
}
|
||||
public static String getDimSafe(ServerLevel lvl)
|
||||
{
|
||||
|
||||
public static String getDimSafe(ServerLevel lvl) {
|
||||
return lvl.dimension().location().getNamespace() + "-" + lvl.dimension().location().getPath();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gives you the dimension string modid:dimension
|
||||
*
|
||||
* @param lvl
|
||||
* @return dimension string
|
||||
*/
|
||||
public static String getDim(ServerLevel lvl)
|
||||
{
|
||||
public static String getDim(ServerLevel lvl) {
|
||||
return lvl.dimension().location().getNamespace() + ":" + lvl.dimension().location().getPath();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
public String toString() {
|
||||
return NbtUtils.structureToSnbt(serialize());
|
||||
}
|
||||
|
||||
public CompoundTag serializePretty()
|
||||
{
|
||||
public CompoundTag serializePretty() {
|
||||
CompoundTag tag = new CompoundTag();
|
||||
|
||||
tag.putString("Position", Position.toString());
|
||||
|
@ -86,8 +78,7 @@ public class WorldPosition
|
|||
return tag;
|
||||
}
|
||||
|
||||
public CompoundTag serialize()
|
||||
{
|
||||
public CompoundTag serialize() {
|
||||
CompoundTag tag = new CompoundTag();
|
||||
tag.put("pos", Position.serialize());
|
||||
tag.putString("Dimension", Dimension);
|
||||
|
@ -96,28 +87,25 @@ public class WorldPosition
|
|||
}
|
||||
|
||||
|
||||
|
||||
public ServerLevel getActualDimension()
|
||||
{
|
||||
public ServerLevel getActualDimension() {
|
||||
|
||||
String dim = Dimension;
|
||||
String[] dims = dim.split(":");
|
||||
|
||||
ResourceLocation rl = new ResourceLocation(dims[0], dims[1]);
|
||||
ServerLevel dimL = null;
|
||||
ServerLevel dimL = null;
|
||||
for (ServerLevel lServerLevel : LibZontreck.THE_SERVER.getAllLevels()) {
|
||||
ResourceLocation XL = lServerLevel.dimension().location();
|
||||
|
||||
if(XL.getNamespace().equals(rl.getNamespace())){
|
||||
if(XL.getPath().equals(rl.getPath())){
|
||||
if (XL.getNamespace().equals(rl.getNamespace())) {
|
||||
if (XL.getPath().equals(rl.getPath())) {
|
||||
dimL = lServerLevel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(dimL == null)
|
||||
{
|
||||
LibZontreck.LOGGER.error("DIMENSION COULD NOT BE FOUND : "+Dimension);
|
||||
if (dimL == null) {
|
||||
LibZontreck.LOGGER.error("DIMENSION COULD NOT BE FOUND : " + Dimension);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -125,16 +113,13 @@ public class WorldPosition
|
|||
}
|
||||
|
||||
|
||||
public boolean same(WorldPosition other)
|
||||
{
|
||||
if(Position.same(other.Position) && Dimension == other.Dimension)return true;
|
||||
else return false;
|
||||
public boolean same(WorldPosition other) {
|
||||
return Position.same(other.Position) && Dimension == other.Dimension;
|
||||
}
|
||||
|
||||
public ChunkPos getChunkPos()
|
||||
{
|
||||
public ChunkPos getChunkPos() {
|
||||
net.minecraft.world.level.ChunkPos mcChunk = getActualDimension().getChunkAt(Position.asBlockPos()).getPos();
|
||||
ChunkPos pos = new ChunkPos(new Vector3(mcChunk.getMinBlockX(),-70,mcChunk.getMinBlockZ()), new Vector3(mcChunk.getMaxBlockX(), 400, mcChunk.getMaxBlockZ()), getActualDimension());
|
||||
ChunkPos pos = new ChunkPos(new Vector3(mcChunk.getMinBlockX(), -70, mcChunk.getMinBlockZ()), new Vector3(mcChunk.getMaxBlockX(), 400, mcChunk.getMaxBlockZ()), getActualDimension());
|
||||
pos.centerPoints = new Vector2(mcChunk.getMiddleBlockX(), mcChunk.getMiddleBlockZ());
|
||||
|
||||
return pos;
|
||||
|
|
|
@ -6,22 +6,22 @@
|
|||
# The name of the mod loader type to load - for regular FML @Mod mods it should be javafml
|
||||
modLoader="javafml" #mandatory
|
||||
# A version range to match for said mod loader - for regular FML @Mod it will be the forge version
|
||||
loaderVersion="[44,)" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions.
|
||||
loaderVersion="${loader_version_range}" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions.
|
||||
# The license for you mod. This is mandatory metadata and allows for easier comprehension of your redistributive properties.
|
||||
# Review your options at https://choosealicense.com/. All rights reserved is the default copyright stance, and is thus the default here.
|
||||
license="GPLv3"
|
||||
license="${mod_license}"
|
||||
# A URL to refer people to when problems occur with this mod
|
||||
issueTrackerURL="https://github.com/zontreck/LibZontreckMod/issues" #optional
|
||||
# A list of mods - how many allowed here is determined by the individual mod loader
|
||||
[[mods]] #mandatory
|
||||
# The modid of the mod
|
||||
modId="libzontreck" #mandatory
|
||||
modId="${mod_id}" #mandatory
|
||||
# The version number of the mod - there's a few well known ${} variables useable here or just hardcode it
|
||||
# ${file.jarVersion} will substitute the value of the Implementation-Version as read from the mod's JAR file metadata
|
||||
# see the associated build.gradle script for how to populate this completely automatically during a build
|
||||
version="${file.jarVersion}" #mandatory
|
||||
# A display name for the mod
|
||||
displayName="LibZontreck" #mandatory
|
||||
displayName="${mod_name}" #mandatory
|
||||
# A URL to query for updates for this mod. See the JSON update specification https://mcforge.readthedocs.io/en/latest/gettingstarted/autoupdate/
|
||||
#updateJSONURL="https://change.me.example.invalid/updates.json" #optional
|
||||
# A URL for the "homepage" for this mod, displayed in the mod UI
|
||||
|
@ -29,9 +29,9 @@ displayName="LibZontreck" #mandatory
|
|||
# A file name (in the root of the mod JAR) containing a logo for display
|
||||
logoFile="library.png" #optional
|
||||
# A text field displayed in the mod UI
|
||||
credits="Zontreck" #optional
|
||||
#credits="Zontreck" #optional
|
||||
# A text field displayed in the mod UI
|
||||
authors="Zontreck" #optional
|
||||
authors="#{mod_authors}" #optional
|
||||
# Display Test controls the display for your mod in the server connection screen
|
||||
# MATCH_VERSION means that your mod will cause a red X if the versions on client and server differ. This is the default behaviour and should be what you choose if you have server and client elements to your mod.
|
||||
# IGNORE_SERVER_VERSION means that your mod will not cause a red X if it's present on the server but not on the client. This is what you should use if you're a server only mod.
|
||||
|
@ -52,7 +52,7 @@ This mod provides common code to all of zontreck's mods.
|
|||
# Does this dependency have to exist - if not, ordering below must be specified
|
||||
mandatory=true #mandatory
|
||||
# The version range of the dependency
|
||||
versionRange="[44,)" #mandatory
|
||||
versionRange="${loader_version_range}" #mandatory
|
||||
# An ordering relationship for the dependency - BEFORE or AFTER required if the relationship is not mandatory
|
||||
ordering="NONE"
|
||||
# Side this dependency is applied on - BOTH, CLIENT or SERVER
|
||||
|
@ -62,6 +62,6 @@ This mod provides common code to all of zontreck's mods.
|
|||
modId="minecraft"
|
||||
mandatory=true
|
||||
# This version range declares a minimum of the current minecraft version up to but not including the next major version
|
||||
versionRange="[1.19.3,1.20)"
|
||||
versionRange="${minecraft_range}"
|
||||
ordering="NONE"
|
||||
side="BOTH"
|
||||
|
|
Reference in a new issue