Compare commits

...
Sign in to create a new pull request.

4 commits
main ... 1.18.2

Author SHA1 Message Date
ce4667b6b4 Adjust the warps command 2024-01-28 16:36:34 -07:00
e713101f59 Reduce max tries in RTP Search to fix it 2024-01-22 00:15:36 -07:00
11864385e4 Attempt to fix rtp 2024-01-21 23:57:03 -07:00
8eb93ff176 Backport to 1.18.2 2024-01-16 19:35:17 -07:00
36 changed files with 369 additions and 434 deletions

View file

@ -2,7 +2,7 @@ plugins {
id 'eclipse'
id 'idea'
id 'maven-publish'
id 'net.minecraftforge.gradle' version '[6.0,6.2)'
id 'net.minecraftforge.gradle' version '5.1+'
id 'org.parchmentmc.librarian.forgegradle' version '1.+'
}
@ -41,7 +41,6 @@ minecraft {
// This property allows configuring Gradle's ProcessResources task(s) to run on IDE output locations before launching the game.
// It is REQUIRED to be set to true for this template to function.
// See https://docs.gradle.org/current/dsl/org.gradle.language.jvm.tasks.ProcessResources.html
copyIdeResources = true
// When true, this property will add the folder name of all declared run configurations to generated IDE run configurations.
// The folder name can be set on a run configuration using the "folderName" property.
@ -169,24 +168,6 @@ dependencies {
// http://www.gradle.org/docs/current/userguide/dependency_management.html
}
// This block of code expands all declared replace properties in the specified resource targets.
// A missing property will result in an error. Properties are expanded using ${} Groovy notation.
// When "copyIdeResources" is enabled, this will also run before the game launches in IDE environments.
// See https://docs.gradle.org/current/dsl/org.gradle.language.jvm.tasks.ProcessResources.html
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]
}
}
// Example for how to get properties into the manifest for reading at runtime.
tasks.named('jar', Jar).configure {

View file

@ -3,22 +3,22 @@
org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false
libzontreck=1.10.011524.0045
libzontreck=1.10.012124.1709
## Environment Properties
# The Minecraft version must agree with the Forge version to get a valid artifact
minecraft_version=1.20.1
minecraft_version=1.18.2
# The Minecraft version range can use any release version of Minecraft as bounds.
# Snapshots, pre-releases, and release candidates are not guaranteed to sort properly
# as they do not follow standard versioning conventions.
minecraft_version_range=[1.20.1,1.21)
minecraft_version_range=[1.18.2,1.19)
# The Forge version must agree with the Minecraft version to get a valid artifact
forge_version=47.2.0
forge_version=40.2.1
# The Forge version range can use any version of Forge as bounds or match the loader version range
forge_version_range=[47,)
forge_version_range=[40,)
# The loader version range can only use the major version of Forge/FML as bounds
loader_version_range=[47,)
loader_version_range=[40,)
# The mapping channel to use for mappings.
# The default set of supported mapping channels are ["official", "snapshot", "snapshot_nodoc", "stable", "stable_nodoc"].
# Additional mapping channels can be registered through the "channelProviders" extension in a Gradle plugin.
@ -36,7 +36,7 @@ loader_version_range=[47,)
mapping_channel=parchment
# The mapping version to query from the mapping channel.
# This must match the format required by the mapping channel.
mapping_version=2023.09.03-1.20.1
mapping_version=2022.11.06-1.18.2
## Mod Properties
@ -49,7 +49,7 @@ mod_name=Aria's Essentials
# 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=1.2.011524.2039
mod_version=1.2.012124.2356
# 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

@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

View file

@ -3,8 +3,4 @@ pluginManagement {
gradlePluginPortal()
maven { url = "https://maven.zontreck.com/repository/internal" }
}
}
plugins {
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.5.0'
}

View file

@ -25,7 +25,6 @@ import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.player.Player;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.client.event.RegisterKeyMappingsEvent;
import net.minecraftforge.event.entity.living.LivingDeathEvent;
import net.minecraftforge.eventbus.api.EventPriority;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
@ -145,13 +144,6 @@ public class AriasEssentials {
MinecraftForge.EVENT_BUS.register(new HeartsRenderer());
}
@OnlyIn(Dist.CLIENT)
@SubscribeEvent
public static void onRegisterKeyBinds(RegisterKeyMappingsEvent ev)
{
ev.register(Keybindings.AUTOWALK);
}
}
}

View file

@ -11,6 +11,7 @@ import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import java.time.Instant;
import java.util.UUID;
@OnlyIn(Dist.CLIENT)
@Mod.EventBusSubscriber(modid = AriasEssentials.MODID, value = Dist.CLIENT)
@ -21,7 +22,7 @@ public class AutoWalk {
static long lastPress;
@SubscribeEvent
public static void onKeyPress(InputEvent.Key event) {
public static void onKeyPress(InputEvent.KeyInputEvent event) {
if(Keybindings.AUTOWALK.matches(event.getKey(), event.getScanCode()) && Minecraft.getInstance().screen == null && Keybindings.AUTOWALK.isDown())
{
lastPress = Instant.now().getEpochSecond();
@ -35,10 +36,10 @@ public class AutoWalk {
private static void startWalking() {
isWalking=true;
autoJump = Minecraft.getInstance().options.autoJump().get();
Minecraft.getInstance().options.autoJump().set(true);
autoJump = Minecraft.getInstance().options.autoJump;
Minecraft.getInstance().options.autoJump = true;
Minecraft.getInstance().player.sendSystemMessage(ChatHelpers.macro(Messages.ESSENTIALS_PREFIX + "!Dark_Green!AutoWalking started"));
Minecraft.getInstance().player.sendMessage(ChatHelpers.macro(Messages.ESSENTIALS_PREFIX + "!Dark_Green!AutoWalking started"), new UUID(0,0));
runner = new Thread(()->{
while(AutoWalk.isWalking)
@ -54,10 +55,10 @@ public class AutoWalk {
isWalking=false;
runner.interrupt();
runner=null;
Minecraft.getInstance().options.autoJump().set(autoJump);
Minecraft.getInstance().options.autoJump = autoJump;
Minecraft.getInstance().options.keyUp.setDown(false);
Minecraft.getInstance().player.sendSystemMessage(ChatHelpers.macro(Messages.ESSENTIALS_PREFIX + "!Dark_Green!AutoWalking stopped"));
Minecraft.getInstance().player.sendMessage(ChatHelpers.macro(Messages.ESSENTIALS_PREFIX + "!Dark_Green!AutoWalking stopped"), new UUID(0,0));
}
}

View file

@ -5,8 +5,9 @@ import com.mojang.blaze3d.platform.InputConstants;
import net.minecraft.client.KeyMapping;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.client.event.RegisterKeyMappingsEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
@OnlyIn(Dist.CLIENT)
public class Keybindings {
@ -19,11 +20,5 @@ public class Keybindings {
final KeyMapping key = new KeyMapping(name, keycode, category);
return key;
}
@SubscribeEvent
public static void registerKeyMappings(RegisterKeyMappingsEvent event)
{
event.register(AUTOWALK);
}
}

View file

@ -2,6 +2,7 @@ package dev.zontreck.essentials.commands.gui;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.BoolArgumentType;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import dev.zontreck.essentials.Messages;
import dev.zontreck.essentials.events.CommandExecutionEvent;
import dev.zontreck.essentials.networking.ModMessages;
@ -9,6 +10,7 @@ import dev.zontreck.essentials.networking.packets.s2c.S2CUpdateHearts;
import dev.zontreck.libzontreck.util.ChatHelpers;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.server.level.ServerPlayer;
import net.minecraftforge.common.MinecraftForge;
public class HeartsCommand
@ -20,24 +22,31 @@ public class HeartsCommand
private static int hearts(CommandSourceStack stack, boolean compressHearts)
{
var exec = new CommandExecutionEvent(stack.getPlayer(), "hearts");
ServerPlayer player = null;
try {
player = stack.getPlayerOrException();
} catch (CommandSyntaxException e) {
throw new RuntimeException(e);
}
var exec = new CommandExecutionEvent(player, "hearts");
if(MinecraftForge.EVENT_BUS.post(exec))
{
return 0;
}
// Send the state to the client, then update the config
// Send feedback to the user
ChatHelpers.broadcastTo(stack.getPlayer().getUUID(), ChatHelpers.macro(Messages.HEARTS_UPDATED), stack.getServer());
ChatHelpers.broadcastTo(player.getUUID(), ChatHelpers.macro(Messages.HEARTS_UPDATED), stack.getServer());
S2CUpdateHearts update = new S2CUpdateHearts(compressHearts);
ModMessages.sendToPlayer(update, stack.getPlayer());
ModMessages.sendToPlayer(update, player);
return 0;
}
private static int usage(CommandSourceStack stack)
{
ChatHelpers.broadcastTo(stack.getPlayer().getUUID(), ChatHelpers.macro(Messages.HEARTS_USAGE), stack.getServer());
ChatHelpers.broadcastTo(stack.getEntity().getUUID(), ChatHelpers.macro(Messages.HEARTS_USAGE), stack.getServer());
return 0;

View file

@ -3,6 +3,7 @@ package dev.zontreck.essentials.commands.homes;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import dev.zontreck.essentials.AriasEssentials;
import dev.zontreck.essentials.Messages;
import dev.zontreck.essentials.events.CommandExecutionEvent;
@ -36,7 +37,12 @@ public class DelHomeCommand {
private static int rmHome(CommandSourceStack ctx, String homeName)
{
var exec = new CommandExecutionEvent(ctx.getPlayer(), "delhome");
CommandExecutionEvent exec = null;
try {
exec = new CommandExecutionEvent(ctx.getPlayerOrException(), "delhome");
} catch (CommandSyntaxException e) {
throw new RuntimeException(e);
}
if(MinecraftForge.EVENT_BUS.post(exec))
{
return 0;

View file

@ -33,7 +33,12 @@ public class HomeCommand {
private static int home(CommandSourceStack ctx, String homeName)
{
var exec = new CommandExecutionEvent(ctx.getPlayer(), "home");
CommandExecutionEvent exec = null;
try {
exec = new CommandExecutionEvent(ctx.getPlayerOrException(), "home");
} catch (CommandSyntaxException e) {
throw new RuntimeException(e);
}
if(MinecraftForge.EVENT_BUS.post(exec))
{
return 0;

View file

@ -60,7 +60,7 @@ public class HomesCommand {
{
stack = new ItemStack(Items.GRASS_BLOCK, 1);
}
stack.setHoverName(Component.literal(string.homeName));
stack.setHoverName(ChatHelpers.macro(string.homeName));
ChestGUIButton button = new ChestGUIButton(stack, (stackx, container, lore)-> {

View file

@ -24,6 +24,7 @@ import net.minecraft.commands.Commands;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.Vec2;
import net.minecraft.world.phys.Vec3;
import net.minecraftforge.common.MinecraftForge;
@ -42,7 +43,12 @@ public class SetHomeCommand {
private static int setHome(CommandSourceStack ctx, String homeName)
{
var exec = new CommandExecutionEvent(ctx.getPlayer(), "sethome");
CommandExecutionEvent exec = null;
try {
exec = new CommandExecutionEvent(ctx.getPlayerOrException(), "sethome");
} catch (CommandSyntaxException e) {
throw new RuntimeException(e);
}
if(MinecraftForge.EVENT_BUS.post(exec))
{
return 0;
@ -58,7 +64,7 @@ public class SetHomeCommand {
p = ctx.getPlayerOrException();
if(TeleportActioner.isBlacklistedDimension(p.serverLevel()))
if(TeleportActioner.isBlacklistedDimension(p.getLevel()))
{
ChatHelpers.broadcastTo(p, ChatHelpers.macro(Messages.ESSENTIALS_PREFIX + AEServerConfig.getInstance().messages.BlacklistedDimensionError), p.server);
@ -68,9 +74,11 @@ public class SetHomeCommand {
Vec3 position = p.position();
Vec2 rot = p.getRotationVector();
TeleportDestination dest = new TeleportDestination(new Vector3(position), new Vector2(rot), p.serverLevel());
TeleportDestination dest = new TeleportDestination(new Vector3(position), new Vector2(rot), p.getLevel());
BlockState bs = p.getLevel().getBlockState(dest.Position.moveDown().asBlockPos());
Home newhome = new Home(p, homeName, dest, new ItemStack(p.getBlockStateOn().getBlock().asItem()));
Home newhome = new Home(p, homeName, dest, new ItemStack(bs.getBlock().asItem()));
AriasEssentials.player_homes.get(p.getUUID()).add(newhome);

View file

@ -1,6 +1,7 @@
package dev.zontreck.essentials.commands.teleport;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import dev.zontreck.essentials.Messages;
import dev.zontreck.essentials.configs.server.AEServerConfig;
import dev.zontreck.essentials.events.CommandExecutionEvent;
@ -20,7 +21,12 @@ public class BackCommand
public static int back(CommandSourceStack ctx)
{
var exec = new CommandExecutionEvent(ctx.getPlayer(), "back");
CommandExecutionEvent exec = null;
try {
exec = new CommandExecutionEvent(ctx.getPlayerOrException(), "back");
} catch (CommandSyntaxException e) {
throw new RuntimeException(e);
}
if(MinecraftForge.EVENT_BUS.post(exec))
{
return 0;
@ -28,20 +34,20 @@ public class BackCommand
try {
if(!AEServerConfig.getInstance().back.Enabled && !ctx.hasPermission(ctx.getServer().getOperatorUserPermissionLevel()))
{
ChatHelpers.broadcastTo(ctx.getPlayer(), ChatHelpers.macro(Messages.TELEPORT_BACK_DISABLED), ctx.getServer());
ChatHelpers.broadcastTo(ctx.getPlayerOrException(), ChatHelpers.macro(Messages.TELEPORT_BACK_DISABLED), ctx.getServer());
return 0;
}
WorldPosition wp = BackPositionCaches.Pop(ctx.getPlayer().getUUID());
WorldPosition wp = BackPositionCaches.Pop(ctx.getPlayerOrException().getUUID());
ChatHelpers.broadcastTo(ctx.getPlayer(), ChatHelpers.macro(Messages.TELEPORT_BACK), ctx.getServer());
ChatHelpers.broadcastTo(ctx.getPlayerOrException(), ChatHelpers.macro(Messages.TELEPORT_BACK), ctx.getServer());
TeleportContainer cont = new TeleportContainer(ctx.getPlayer(), wp.Position.asMinecraftVector(), ctx.getRotation(), wp.getActualDimension());
TeleportContainer cont = new TeleportContainer(ctx.getPlayerOrException(), wp.Position.asMinecraftVector(), ctx.getRotation(), wp.getActualDimension());
TeleportActioner.ApplyTeleportEffect(ctx.getPlayer());
TeleportActioner.ApplyTeleportEffect(ctx.getPlayerOrException());
TeleportActioner.PerformTeleport(cont, true);
} catch (Exception e) {
ChatHelpers.broadcastTo(ctx.getPlayer(), ChatHelpers.macro(Messages.NO_BACK), ctx.getServer());
ChatHelpers.broadcastTo(ctx.getEntity().getUUID(), ChatHelpers.macro(Messages.NO_BACK), ctx.getServer());
}
return 0;
}

View file

@ -2,6 +2,7 @@ package dev.zontreck.essentials.commands.teleport;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import dev.zontreck.essentials.events.CommandExecutionEvent;
import dev.zontreck.essentials.rtp.RandomPositionFactory;
import net.minecraft.commands.CommandSourceStack;
@ -27,7 +28,12 @@ public class RTPCommand {
private static int rtp(CommandSourceStack source) {
var exec = new CommandExecutionEvent(source.getPlayer(), "rtp");
CommandExecutionEvent exec = null;
try {
exec = new CommandExecutionEvent(source.getPlayerOrException(), "rtp");
} catch (CommandSyntaxException e) {
throw new RuntimeException(e);
}
if(MinecraftForge.EVENT_BUS.post(exec))
{
return 0;
@ -58,7 +64,7 @@ public class RTPCommand {
Vec3 pos = pla.position();
//boolean found_place= false;
RandomPositionFactory.beginRTP(pla, pla.serverLevel());
RandomPositionFactory.beginRTP(pla, pla.getLevel());
}

View file

@ -2,6 +2,7 @@ package dev.zontreck.essentials.commands.teleport;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import dev.zontreck.essentials.Messages;
import dev.zontreck.essentials.events.CommandExecutionEvent;
import dev.zontreck.libzontreck.util.ChatHelpers;
@ -27,7 +28,12 @@ public class SpawnCommand {
private static int respawn(CommandSourceStack source) {
var exec = new CommandExecutionEvent(source.getPlayer(), "spawn");
CommandExecutionEvent exec = null;
try {
exec = new CommandExecutionEvent(source.getPlayerOrException(), "spawn");
} catch (CommandSyntaxException e) {
throw new RuntimeException(e);
}
if(MinecraftForge.EVENT_BUS.post(exec))
{
return 0;
@ -36,10 +42,10 @@ public class SpawnCommand {
ChatHelpers.broadcastTo(p.getUUID(), ChatHelpers.macro(Messages.RESPAWNING), p.server);
BlockPos spawn = p.serverLevel().getSharedSpawnPos();
BlockPos spawn = p.getLevel().getSharedSpawnPos();
TeleportActioner.ApplyTeleportEffect(p);
TeleportContainer cont = new TeleportContainer(p, new Vec3(spawn.getX(), spawn.getY(), spawn.getZ()), Vec2.ZERO, p.serverLevel());
TeleportContainer cont = new TeleportContainer(p, new Vec3(spawn.getX(), spawn.getY(), spawn.getZ()), Vec2.ZERO, p.getLevel());
TeleportActioner.PerformTeleport(cont, false);

View file

@ -2,6 +2,7 @@ package dev.zontreck.essentials.commands.teleport;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import dev.zontreck.ariaslib.terminal.Task;
import dev.zontreck.ariaslib.util.DelayedExecutorService;
import dev.zontreck.essentials.Messages;
@ -37,7 +38,12 @@ public class TPACommand {
private static int tpa(CommandSourceStack source, ServerPlayer serverPlayer) {
var exec = new CommandExecutionEvent(source.getPlayer(), "tpa");
CommandExecutionEvent exec = null;
try {
exec = new CommandExecutionEvent(source.getPlayerOrException(), "tpa");
} catch (CommandSyntaxException e) {
throw new RuntimeException(e);
}
if(MinecraftForge.EVENT_BUS.post(exec))
{
return 0;
@ -118,7 +124,7 @@ public class TPACommand {
private static int usage(CommandSourceStack source) {
source.sendSystemMessage(ChatHelpers.macro("/tpa USAGE\n\n "+ChatColor.BOLD + ChatColor.DARK_GRAY+"/tpa "+ChatColor.DARK_RED+"target_player\n"));
ChatHelpers.broadcastTo(source.getEntity().getUUID(), ChatHelpers.macro("/tpa USAGE\n\n "+ChatColor.BOLD + ChatColor.DARK_GRAY+"/tpa "+ChatColor.DARK_RED+"target_player\n"), source.getServer());
return 0;
}
}

View file

@ -2,6 +2,7 @@ package dev.zontreck.essentials.commands.teleport;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import dev.zontreck.ariaslib.terminal.Task;
import dev.zontreck.ariaslib.util.DelayedExecutorService;
import dev.zontreck.essentials.Messages;
@ -33,7 +34,12 @@ public class TPAHereCommand {
private static int tpa(CommandSourceStack source, ServerPlayer serverPlayer) {
var exec = new CommandExecutionEvent(source.getPlayer(), "tpahere");
CommandExecutionEvent exec = null;
try {
exec = new CommandExecutionEvent(source.getPlayerOrException(), "tpahere");
} catch (CommandSyntaxException e) {
throw new RuntimeException(e);
}
if(MinecraftForge.EVENT_BUS.post(exec))
{
return 0;
@ -114,7 +120,7 @@ public class TPAHereCommand {
}
private static int usage(CommandSourceStack source) {
source.sendSystemMessage(ChatHelpers.macro("/tpahere USAGE\n\n !Bold!!Dark_Gray!/tpahere !Dark_Red!target_player\n"));
ChatHelpers.broadcastTo(source.getEntity().getUUID(), ChatHelpers.macro("/tpahere USAGE\n\n !Bold!!Dark_Gray!/tpahere !Dark_Red!target_player\n"), source.getServer());
return 0;
}
}

View file

@ -6,6 +6,7 @@ import java.util.UUID;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import dev.zontreck.essentials.Messages;
import dev.zontreck.essentials.events.CommandExecutionEvent;
import dev.zontreck.libzontreck.chat.ChatColor;
@ -25,7 +26,12 @@ public class TPAcceptCommand {
private static int doAccept(CommandSourceStack source, String TPID) {
var exec = new CommandExecutionEvent(source.getPlayer(), "tpaccept");
CommandExecutionEvent exec = null;
try {
exec = new CommandExecutionEvent(source.getPlayerOrException(), "tpaccept");
} catch (CommandSyntaxException e) {
throw new RuntimeException(e);
}
if(MinecraftForge.EVENT_BUS.post(exec))
{
return 0;
@ -54,7 +60,7 @@ public class TPAcceptCommand {
cont.PlayerInst = from;
cont.Position = to.position();
cont.Rotation = to.getRotationVector();
cont.Dimension = to.serverLevel();
cont.Dimension = to.getLevel();
TeleportActioner.ApplyTeleportEffect(from);
TeleportActioner.PerformTeleport(cont, false);

View file

@ -2,11 +2,14 @@ package dev.zontreck.essentials.commands.teleport;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.BoolArgumentType;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import dev.zontreck.essentials.Messages;
import dev.zontreck.libzontreck.chestgui.ChestGUI;
import dev.zontreck.libzontreck.chestgui.ChestGUIButton;
import dev.zontreck.libzontreck.chestgui.ChestGUIIdentifier;
import dev.zontreck.libzontreck.profiles.Profile;
import dev.zontreck.libzontreck.profiles.UserProfileNotYetExistsException;
import dev.zontreck.libzontreck.util.ChatHelpers;
import dev.zontreck.libzontreck.util.ServerUtilities;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
@ -20,16 +23,23 @@ public class TPEffectsCommand
{
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
{
dispatcher.register(Commands.literal("tpeffects").then(Commands.argument("enable", BoolArgumentType.bool()).executes(x->tpeffects(x.getSource(), BoolArgumentType.getBool(x, "enable")))));
dispatcher.register(Commands.literal("tpeffects_disable").then(Commands.argument("disabled", BoolArgumentType.bool()).executes(x->tpeffects(x.getSource(), BoolArgumentType.getBool(x, "disabled")))));
}
public static int tpeffects(CommandSourceStack source, boolean enabled)
public static int tpeffects(CommandSourceStack source, boolean disabled)
{
ServerPlayer player = source.getPlayer();
ServerPlayer player = null;
try {
player = source.getPlayerOrException();
} catch (CommandSyntaxException e) {
throw new RuntimeException(e);
}
try {
Profile prof = Profile.get_profile_of(player.getStringUUID());
prof.NBT.putBoolean("tpeffects", enabled);
prof.NBT.putBoolean("tpeffects", disabled);
ChatHelpers.broadcastTo(player.getUUID(), ChatHelpers.macro(Messages.TP_EFFECTS_TOGGLED, disabled ? "disabled" : "enabled"), player.server);
return 0;
} catch (UserProfileNotYetExistsException e) {

View file

@ -3,9 +3,10 @@ package dev.zontreck.essentials.commands.teleport;
import dev.zontreck.ariaslib.util.DelayedExecutorService;
import dev.zontreck.essentials.AriasEssentials;
import dev.zontreck.essentials.configs.server.AEServerConfig;
import dev.zontreck.libzontreck.profiles.Profile;
import dev.zontreck.libzontreck.profiles.UserProfileNotYetExistsException;
import dev.zontreck.libzontreck.vectors.Vector3;
import dev.zontreck.libzontreck.vectors.WorldPosition;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.commands.EffectCommands;
import net.minecraft.server.level.ServerLevel;
@ -30,7 +31,16 @@ public class TeleportActioner
}
public static void ApplyTeleportEffect(ServerPlayer player){
if(isBlacklistedDimension(player.serverLevel())){
try {
Profile prof = Profile.get_profile_of(player.getStringUUID());
if(prof.NBT.getBoolean("tpeffects"))
{
return;
}
} catch (UserProfileNotYetExistsException e) {
throw new RuntimeException(e);
}
if(isBlacklistedDimension(player.getLevel())){
return;
}
// 10/05/2022 - Thinking ahead here to future proof it so i can do things in threads safely
@ -43,7 +53,7 @@ public class TeleportActioner
for(int i = 0; i < effects.size(); i++) {
RegistryObject<MobEffect> effect = RegistryObject.create(new ResourceLocation(effects.get(i)), ForgeRegistries.MOB_EFFECTS);
int duration = AriasEssentials.random.nextInt(5, 10) * 20;
int duration = AriasEssentials.random.nextInt(2, 5) * 20;
int amplifier = AriasEssentials.random.nextInt(1, 3);
if (effects.get(i).equals("minecraft:slow_falling"))

View file

@ -3,6 +3,7 @@ package dev.zontreck.essentials.commands.warps;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import dev.zontreck.essentials.Messages;
import dev.zontreck.essentials.events.CommandExecutionEvent;
import dev.zontreck.essentials.warps.NoSuchWarpException;
@ -29,7 +30,12 @@ public class DelWarpCommand {
private static int setWarp(CommandSourceStack source, String string) {
var exec = new CommandExecutionEvent(source.getPlayer(), "delwarp");
CommandExecutionEvent exec = null;
try {
exec = new CommandExecutionEvent(source.getPlayerOrException(), "delwarp");
} catch (CommandSyntaxException e) {
throw new RuntimeException(e);
}
if(MinecraftForge.EVENT_BUS.post(exec))
{
return 0;

View file

@ -7,6 +7,7 @@ import java.sql.SQLException;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import dev.zontreck.essentials.Messages;
import dev.zontreck.essentials.commands.teleport.TeleportDestination;
import dev.zontreck.essentials.events.CommandExecutionEvent;
@ -40,7 +41,12 @@ public class RTPWarpCommand {
private static int setWarp(CommandSourceStack source, String string) {
var exec = new CommandExecutionEvent(source.getPlayer(), "setwarp");
CommandExecutionEvent exec = null;
try {
exec = new CommandExecutionEvent(source.getPlayerOrException(), "setwarp");
} catch (CommandSyntaxException e) {
throw new RuntimeException(e);
}
if(MinecraftForge.EVENT_BUS.post(exec))
{
return 0;
@ -50,8 +56,8 @@ public class RTPWarpCommand {
Vec3 position = p.position();
Vec2 rot = p.getRotationVector();
TeleportDestination dest = new TeleportDestination(new Vector3(position), new Vector2(rot), p.serverLevel());
Warp warp = new Warp(p.getUUID(), string, true, true, dest, new ItemStack(p.getBlockStateOn().getBlock().asItem()));
TeleportDestination dest = new TeleportDestination(new Vector3(position), new Vector2(rot), p.getLevel());
Warp warp = new Warp(p.getUUID(), string, true, true, dest, new ItemStack(p.getFeetBlockState().getBlock().asItem()));
WarpCreatedEvent event = new WarpCreatedEvent(warp);
if(MinecraftForge.EVENT_BUS.post(event))
{

View file

@ -7,6 +7,7 @@ import java.sql.SQLException;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import dev.zontreck.essentials.Messages;
import dev.zontreck.essentials.commands.teleport.TeleportDestination;
import dev.zontreck.essentials.events.CommandExecutionEvent;
@ -22,6 +23,7 @@ import net.minecraft.commands.Commands;
import net.minecraft.network.chat.Component;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.Vec2;
import net.minecraft.world.phys.Vec3;
import net.minecraftforge.common.MinecraftForge;
@ -40,7 +42,12 @@ public class SetWarpCommand {
private static int setWarp(CommandSourceStack source, String string) {
var exec = new CommandExecutionEvent(source.getPlayer(), "setwarp");
CommandExecutionEvent exec = null;
try {
exec = new CommandExecutionEvent(source.getPlayerOrException(), "setwarp");
} catch (CommandSyntaxException e) {
throw new RuntimeException(e);
}
if(MinecraftForge.EVENT_BUS.post(exec))
{
return 0;
@ -51,8 +58,11 @@ public class SetWarpCommand {
Vec3 position = p.position();
Vec2 rot = p.getRotationVector();
TeleportDestination dest = new TeleportDestination(new Vector3(position), new Vector2(rot), p.serverLevel());
Warp w = new Warp(p.getUUID(), string, false, true, dest, new ItemStack(p.getBlockStateOn().getBlock().asItem()));
TeleportDestination dest = new TeleportDestination(new Vector3(position), new Vector2(rot), p.getLevel());
BlockState bs = p.getLevel().getBlockState(dest.Position.moveDown().asBlockPos());
Warp w = new Warp(p.getUUID(), string, false, true, dest, new ItemStack(bs.getBlock().asItem()));
WarpCreatedEvent event = new WarpCreatedEvent(w);
if(MinecraftForge.EVENT_BUS.post(event)){
ChatHelpers.broadcastTo(p.getUUID(), ChatHelpers.macro(Messages.WARP_CREATE_ERROR, event.denyReason), p.server);

View file

@ -64,7 +64,7 @@ public class WarpCommand {
if(type==1){
try {
var exec = new CommandExecutionEvent(source.getPlayer(), "rtp");
var exec = new CommandExecutionEvent(source.getPlayerOrException(), "rtp");
if(MinecraftForge.EVENT_BUS.post(exec))
{
return;
@ -78,7 +78,12 @@ public class WarpCommand {
}
}
var exec = new CommandExecutionEvent(source.getPlayer(), "warp");
CommandExecutionEvent exec = null;
try {
exec = new CommandExecutionEvent(source.getPlayerOrException(), "warp");
} catch (CommandSyntaxException e) {
throw new RuntimeException(e);
}
if(MinecraftForge.EVENT_BUS.post(exec))
{
return;

View file

@ -140,11 +140,8 @@ public class WarpsCommand {
)
.withInfo(new LoreEntry.Builder().text(ChatHelpers.macro(appendType, warp.destination.Dimension).getString()).build());
if(warps.size() > (2*9))
{
// Say to person
ChatHelpers.broadcastTo(p, warpMsg, p.server);
}else
ChatHelpers.broadcastTo(p, warpMsg, p.server);
if(!(warps.size() > (2*9)))
chestGui.withButton(button);
iconY++;

View file

@ -1,8 +1,9 @@
package dev.zontreck.essentials.configs.client;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import dev.zontreck.ariaslib.util.FileIO;
import dev.zontreck.essentials.util.EssentialsDatastore;
import dev.zontreck.essentials.util.FileHandler;
import dev.zontreck.libzontreck.util.SNbtIo;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtUtils;
@ -30,16 +31,7 @@ public class AEClientConfig
Path serverConfig = EssentialsDatastore.of("client.snbt");
if(serverConfig.toFile().exists())
{
try {
String snbt = FileHandler.readFile(serverConfig.toFile().getAbsolutePath());
inst = deserialize(NbtUtils.snbtToStructure(snbt));
} catch (CommandSyntaxException e) {
throw new RuntimeException(e);
}
inst = deserialize(SNbtIo.loadSnbt(serverConfig));
}else {
initNewConfig();
}
@ -68,9 +60,8 @@ public class AEClientConfig
CompoundTag tag = inst.serialize();
var snbt = NbtUtils.structureToSnbt(tag);
FileHandler.writeFile(serverConfig.toFile().getAbsolutePath(), snbt);
SNbtIo.writeSnbt(serverConfig, tag);
}
public CompoundTag serialize()

View file

@ -1,17 +1,14 @@
package dev.zontreck.essentials.configs.server;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import dev.zontreck.ariaslib.util.Lists;
import dev.zontreck.essentials.configs.server.sections.*;
import dev.zontreck.essentials.util.EssentialsDatastore;
import dev.zontreck.essentials.util.FileHandler;
import dev.zontreck.essentials.util.Maps;
import dev.zontreck.libzontreck.util.SNbtIo;
import net.minecraft.nbt.*;
import java.io.*;
import java.nio.file.Path;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class AEServerConfig
@ -52,15 +49,7 @@ public class AEServerConfig
if(serverConfig.toFile().exists())
{
try {
String snbt = FileHandler.readFile(serverConfig.toFile().getAbsolutePath());
inst = deserialize(NbtUtils.snbtToStructure(snbt));
} catch (CommandSyntaxException e) {
throw new RuntimeException(e);
}
inst = deserialize(SNbtIo.loadSnbt(serverConfig));
}else {
initNewConfig();
}
@ -87,7 +76,7 @@ public class AEServerConfig
back = new Back();
teleport = new Teleportation();
teleport.Effects = Lists.of(
"minecraft:darkness",
"minecraft:blindness",
"minecraft:levitation",
"minecraft:slow_falling",
"minecraft:hunger"
@ -112,9 +101,7 @@ public class AEServerConfig
CompoundTag tag = inst.serialize();
var snbt = NbtUtils.structureToSnbt(tag);
FileHandler.writeFile(serverConfig.toFile().getAbsolutePath(), snbt);
SNbtIo.writeSnbt(serverConfig, tag);
}
public CompoundTag serialize()

View file

@ -17,7 +17,7 @@ import dev.zontreck.essentials.configs.client.AEClientConfig;
import net.minecraft.Util;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.GuiComponent;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;
import net.minecraft.world.effect.MobEffectInstance;
@ -28,10 +28,8 @@ import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.entity.player.Player;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.client.event.RenderGuiOverlayEvent;
import net.minecraftforge.client.gui.overlay.ForgeGui;
import net.minecraftforge.client.gui.overlay.GuiOverlayManager;
import net.minecraftforge.client.gui.overlay.NamedGuiOverlay;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.client.gui.ForgeIngameGui;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.EventPriority;
import net.minecraftforge.eventbus.api.SubscribeEvent;
@ -44,7 +42,7 @@ public class HeartsRenderer {
"textures/gui/hearts.png");
private static final ResourceLocation ICON_ABSORB = new ResourceLocation(AriasEssentials.MODID,
"textures/gui/absorb.png");
private static final ResourceLocation ICON_VANILLA = Gui.GUI_ICONS_LOCATION;
private static final ResourceLocation ICON_VANILLA = GuiComponent.GUI_ICONS_LOCATION;
private final Minecraft mc = Minecraft.getInstance();
@ -67,8 +65,8 @@ public class HeartsRenderer {
* @param width Width to draw
* @param height Height to draw
*/
private void blit(GuiGraphics matrixStack, int x, int y, int textureX, int textureY, int width, int height, ResourceLocation resource) {
matrixStack.blit(resource, x, y, textureX, textureY, width, height);
private void blit(PoseStack matrixStack, int x, int y, int textureX, int textureY, int width, int height) {
Minecraft.getInstance().gui.blit(matrixStack, x, y, textureX, textureY, width, height);
}
/* HUD */
@ -79,28 +77,12 @@ public class HeartsRenderer {
* @param event Event instance
*/
@SubscribeEvent(priority = EventPriority.LOW)
public void renderHealthbar(RenderGuiOverlayEvent.Pre event) {
NamedGuiOverlay ActualOverlay = GuiOverlayManager.findOverlay(new ResourceLocation("minecraft:player_health"));
if (ActualOverlay == null) {
if (GuiOverlayManager.getOverlays() == null) {
AriasEssentials.LOGGER.info("Overlays non existent?!");
}
for (NamedGuiOverlay overlay : GuiOverlayManager.getOverlays()) {
// Next print
// LibZontreck.LOGGER.info("GUI OVERLAY: "+overlay.id().getPath());
if (overlay.id().getPath().equals("player_health")) {
ActualOverlay = overlay;
break;
}
}
}
if (event.isCanceled() || !AEClientConfig.getInstance().EnableHearts || event.getOverlay() != ActualOverlay) {
public void renderHealthbar(RenderGameOverlayEvent.PreLayer event) {
if (event.isCanceled() || !AEClientConfig.getInstance().EnableHearts || event.getOverlay() != ForgeIngameGui.PLAYER_HEALTH_ELEMENT) {
return;
}
// ensure its visible
if (!(mc.gui instanceof ForgeGui gui) || mc.options.hideGui || !gui.shouldDrawSurvivalElements()) {
if (!(mc.gui instanceof ForgeIngameGui gui) || mc.options.hideGui || !gui.shouldDrawSurvivalElements()) {
return;
}
Entity renderViewEnity = this.mc.getCameraEntity();
@ -112,7 +94,7 @@ public class HeartsRenderer {
this.mc.getProfiler().push("health");
// extra setup stuff from us
int left_height = gui.leftHeight;
int left_height = gui.left_height;
int width = this.mc.getWindow().getGuiScaledWidth();
int height = this.mc.getWindow().getGuiScaledHeight();
int updateCounter = this.mc.gui.getGuiTicks();
@ -121,13 +103,13 @@ public class HeartsRenderer {
// changes are indicated by comment
int health = Mth.ceil(player.getHealth());
boolean highlight = this.healthUpdateCounter > (long) updateCounter
&& (this.healthUpdateCounter - (long) updateCounter) / 3L % 2L == 1L;
boolean highlight = this.healthUpdateCounter > (long) updateCounter && (this.healthUpdateCounter - (long) updateCounter) / 3L % 2L == 1L;
if (health < this.playerHealth && player.invulnerableTime > 0) {
this.lastSystemTime = Util.getMillis();
this.healthUpdateCounter = (updateCounter + 20);
} else if (health > this.playerHealth && player.invulnerableTime > 0) {
}
else if (health > this.playerHealth && player.invulnerableTime > 0) {
this.lastSystemTime = Util.getMillis();
this.healthUpdateCounter = (updateCounter + 10);
}
@ -145,8 +127,7 @@ public class HeartsRenderer {
float healthMax = attrMaxHealth == null ? 0 : (float) attrMaxHealth.getValue();
float absorb = Mth.ceil(player.getAbsorptionAmount());
// CHANGE: simulate 10 hearts max if there's more, so vanilla only renders one
// row max
// CHANGE: simulate 10 hearts max if there's more, so vanilla only renders one row max
healthMax = Math.min(healthMax, 20f);
health = Math.min(health, 20);
absorb = Math.min(absorb, 20);
@ -158,10 +139,9 @@ public class HeartsRenderer {
int left = width / 2 - 91;
int top = height - left_height;
// change: these are unused below, unneeded? should these adjust the Forge
// variable?
// left_height += (healthRows * rowHeight);
// if (rowHeight != 10) left_height += 10 - rowHeight;
// change: these are unused below, unneeded? should these adjust the Forge variable?
//left_height += (healthRows * rowHeight);
//if (rowHeight != 10) left_height += 10 - rowHeight;
this.regen = -1;
if (player.hasEffect(MobEffects.REGENERATION)) {
@ -172,46 +152,46 @@ public class HeartsRenderer {
final int TOP = 9 * (this.mc.level.getLevelData().isHardcore() ? 5 : 0);
final int BACKGROUND = (highlight ? 25 : 16);
int MARGIN = 16;
if (player.hasEffect(MobEffects.POISON))
MARGIN += 36;
else if (player.hasEffect(MobEffects.WITHER))
MARGIN += 72;
if (player.hasEffect(MobEffects.POISON)) MARGIN += 36;
else if (player.hasEffect(MobEffects.WITHER)) MARGIN += 72;
float absorbRemaining = absorb;
GuiGraphics matrixStack = event.getGuiGraphics();
PoseStack matrixStack = event.getMatrixStack();
for (int i = Mth.ceil((healthMax + absorb) / 2.0F) - 1; i >= 0; --i) {
int row = Mth.ceil((float) (i + 1) / 10.0F) - 1;
int x = left + i % 10 * 8;
int y = top - row * rowHeight;
if (health <= 4)
y += this.rand.nextInt(2);
if (i == this.regen)
y -= 2;
if (health <= 4) y += this.rand.nextInt(2);
if (i == this.regen) y -= 2;
this.blit(matrixStack, x, y, BACKGROUND, TOP, 9, 9, ICON_VANILLA);
this.blit(matrixStack, x, y, BACKGROUND, TOP, 9, 9);
if (highlight) {
if (i * 2 + 1 < healthLast) {
this.blit(matrixStack, x, y, MARGIN + 54, TOP, 9, 9, ICON_VANILLA); // 6
} else if (i * 2 + 1 == healthLast) {
this.blit(matrixStack, x, y, MARGIN + 63, TOP, 9, 9, ICON_VANILLA); // 7
this.blit(matrixStack, x, y, MARGIN + 54, TOP, 9, 9); //6
}
else if (i * 2 + 1 == healthLast) {
this.blit(matrixStack, x, y, MARGIN + 63, TOP, 9, 9); //7
}
}
if (absorbRemaining > 0.0F) {
if (absorbRemaining == absorb && absorb % 2.0F == 1.0F) {
this.blit(matrixStack, x, y, MARGIN + 153, TOP, 9, 9, ICON_VANILLA); // 17
this.blit(matrixStack, x, y, MARGIN + 153, TOP, 9, 9); //17
absorbRemaining -= 1.0F;
} else {
this.blit(matrixStack, x, y, MARGIN + 144, TOP, 9, 9, ICON_VANILLA); // 16
}
else {
this.blit(matrixStack, x, y, MARGIN + 144, TOP, 9, 9); //16
absorbRemaining -= 2.0F;
}
} else {
}
else {
if (i * 2 + 1 < health) {
this.blit(matrixStack, x, y, MARGIN + 36, TOP, 9, 9, ICON_VANILLA); // 4
} else if (i * 2 + 1 == health) {
this.blit(matrixStack, x, y, MARGIN + 45, TOP, 9, 9, ICON_VANILLA); // 5
this.blit(matrixStack, x, y, MARGIN + 36, TOP, 9, 9); //4
}
else if (i * 2 + 1 == health) {
this.blit(matrixStack, x, y, MARGIN + 45, TOP, 9, 9); //5
}
}
}
@ -220,23 +200,22 @@ public class HeartsRenderer {
this.renderExtraAbsorption(matrixStack, left, top - rowHeight, player);
RenderSystem.setShaderTexture(0, ICON_VANILLA);
gui.leftHeight += 10;
gui.left_height += 10;
if (absorb > 0) {
gui.leftHeight += 10;
gui.left_height += 10;
}
event.setCanceled(true);
RenderSystem.disableBlend();
this.mc.getProfiler().pop();
MinecraftForge.EVENT_BUS
.post(new RenderGuiOverlayEvent.Post(mc.getWindow(), event.getGuiGraphics(), event.getPartialTick(), ActualOverlay));
MinecraftForge.EVENT_BUS.post(new RenderGameOverlayEvent.PostLayer(matrixStack, event, ForgeIngameGui.PLAYER_HEALTH_ELEMENT));
}
/**
* Gets the texture from potion effects
*
* @param player Player instance
* @return Texture offset for potion effects
* @param player Player instance
* @return Texture offset for potion effects
*/
private int getPotionOffset(Player player) {
int potionOffset = 0;
@ -257,13 +236,12 @@ public class HeartsRenderer {
/**
* Renders the health above 10 hearts
*
* @param matrixStack Matrix stack instance
* @param xBasePos Health bar top corner
* @param yBasePos Health bar top corner
* @param player Player instance
* @param matrixStack Matrix stack instance
* @param xBasePos Health bar top corner
* @param yBasePos Health bar top corner
* @param player Player instance
*/
private void renderExtraHearts(GuiGraphics matrixStack, int xBasePos, int yBasePos, Player player) {
private void renderExtraHearts(PoseStack matrixStack, int xBasePos, int yBasePos, Player player) {
int potionOffset = this.getPotionOffset(player);
// Extra hearts
@ -272,15 +250,15 @@ public class HeartsRenderer {
this.renderCustomHearts(matrixStack, xBasePos, yBasePos, potionOffset, hp, false);
}
/**
* Renders the absorption health above 10 hearts
*
* @param matrixStack Matrix stack instance
* @param xBasePos Health bar top corner
* @param yBasePos Health bar top corner
* @param player Player instance
* @param matrixStack Matrix stack instance
* @param xBasePos Health bar top corner
* @param yBasePos Health bar top corner
* @param player Player instance
*/
private void renderExtraAbsorption(GuiGraphics matrixStack, int xBasePos, int yBasePos, Player player) {
private void renderExtraAbsorption(PoseStack matrixStack, int xBasePos, int yBasePos, Player player) {
int potionOffset = this.getPotionOffset(player);
// Extra hearts
@ -291,9 +269,8 @@ public class HeartsRenderer {
/**
* Gets the texture offset from the regen effect
*
* @param i Heart index
* @param offset Current offset
* @param i Heart index
* @param offset Current offset
*/
private int getYRegenOffset(int i, int offset) {
return i + offset == this.regen ? -2 : 0;
@ -301,7 +278,6 @@ public class HeartsRenderer {
/**
* Shared logic to render custom hearts
*
* @param matrixStack Matrix stack instance
* @param xBasePos Health bar top corner
* @param yBasePos Health bar top corner
@ -309,8 +285,7 @@ public class HeartsRenderer {
* @param count Number to render
* @param absorb If true, render absorption hearts
*/
private void renderCustomHearts(GuiGraphics matrixStack, int xBasePos, int yBasePos, int potionOffset, int count,
boolean absorb) {
private void renderCustomHearts(PoseStack matrixStack, int xBasePos, int yBasePos, int potionOffset, int count, boolean absorb) {
int regenOffset = absorb ? 10 : 0;
for (int iter = 0; iter < count / 20; iter++) {
int renderHearts = (count - 20 * (iter + 1)) / 2;
@ -321,16 +296,16 @@ public class HeartsRenderer {
for (int i = 0; i < renderHearts; i++) {
int y = this.getYRegenOffset(i, regenOffset);
if (absorb) {
this.blit(matrixStack, xBasePos + 8 * i, yBasePos + y, 0, 54, 9, 9, ICON_ABSORB);
this.blit(matrixStack, xBasePos + 8 * i, yBasePos + y, 0, 54, 9, 9);
}
this.blit(matrixStack, xBasePos + 8 * i, yBasePos + y, 18 * heartIndex, potionOffset, 9, 9, ICON_HEARTS);
this.blit(matrixStack, xBasePos + 8 * i, yBasePos + y, 18 * heartIndex, potionOffset, 9, 9);
}
if (count % 2 == 1 && renderHearts < 10) {
int y = this.getYRegenOffset(renderHearts, regenOffset);
if (absorb) {
this.blit(matrixStack, xBasePos + 8 * renderHearts, yBasePos + y, 0, 54, 9, 9, ICON_ABSORB);
this.blit(matrixStack, xBasePos + 8 * renderHearts, yBasePos + y, 0, 54, 9, 9);
}
this.blit(matrixStack, xBasePos + 8 * renderHearts, yBasePos + y, 9 + 18 * heartIndex, potionOffset, 9, 9, ICON_HEARTS);
this.blit(matrixStack, xBasePos + 8 * renderHearts, yBasePos + y, 9 + 18 * heartIndex, potionOffset, 9, 9);
}
}
}

View file

@ -16,7 +16,7 @@ import java.util.concurrent.CompletableFuture;
public class HomesSuggestionProvider {
public static SuggestionProvider<CommandSourceStack> PROVIDER = (ctx,suggestionsBuilder)->{
Homes homes = HomesProvider.getHomesForPlayer(ctx.getSource().getPlayer().getUUID().toString());
Homes homes = HomesProvider.getHomesForPlayer(ctx.getSource().getPlayerOrException().getUUID().toString());
List<String> homesList = new ArrayList<>();

View file

@ -30,10 +30,10 @@ public class ModMessages {
net.messageBuilder(S2CUpdateHearts.class, id(), NetworkDirection.PLAY_TO_CLIENT)
.decoder(S2CUpdateHearts::new)
.encoder(S2CUpdateHearts::toBytes)
.consumerMainThread(S2CUpdateHearts::handle)
.add();
.decoder(S2CUpdateHearts::new)
.encoder(S2CUpdateHearts::toBytes)
.consumer(S2CUpdateHearts::handle)
.add();
}

View file

@ -8,6 +8,7 @@ import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.Vec3i;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
@ -20,124 +21,87 @@ import java.util.Iterator;
import java.util.List;
import java.util.Random;
/**
* As of v1.1.121823.x, this is now used for RTP
* <p>
* This ensures that RTP is only scanned once every so often. This is because RTP lags the server when it is having to check block positions.
* <p>
* If the RTP system scans each dimension (Not blacklisted), then it can build a list of safe locations that will be rotated out every 2 hours.
* <p>
* Every 10 minutes, a new RTP location is scanned. This ensures sufficiently semi-random locations. Eventually old locations will be removed from the list.
* <p>
* At server start, it will scan 10 RTP locations per dimension while there are no players.
*/
public class RTP
{
public RTP(ServerLevel level)
{
position = new WorldPosition(new Vector3(0,500,0), WorldPosition.getDim(level));
if(position.getActualDimension().dimensionType().hasCeiling())
{
heightMapType = Heightmap.Types.MOTION_BLOCKING_NO_LEAVES;
SearchDirection=-1;
}else {
heightMapType = Heightmap.Types.MOTION_BLOCKING_NO_LEAVES;
SearchDirection=1;
}
}
private final int SearchDirection;
private Thread containingThread;
public class RTP {
private static final List<Block> BLACKLIST = Lists.of(Blocks.LAVA, Blocks.WATER, Blocks.BEDROCK);
private final int SEARCH_DIRECTION;
private final Heightmap.Types heightMapType;
public WorldPosition position;
private final List<Block> BLACKLIST = Lists.of(Blocks.LAVA, Blocks.WATER, Blocks.BEDROCK);
protected int tries;
protected int lastThreadDelay = 15;
private final ServerLevel dimension;
private int tries;
protected RTP withThreadDelay(int delay)
{
lastThreadDelay=delay;
if(lastThreadDelay >= 60) lastThreadDelay = 60;
return this;
public RTP(ServerLevel level) {
position = new WorldPosition(new Vector3(0, -60, 0), WorldPosition.getDim(level));
dimension = position.getActualDimension();
if (position.getActualDimension().dimensionType().hasCeiling()) {
heightMapType = Heightmap.Types.MOTION_BLOCKING_NO_LEAVES;
SEARCH_DIRECTION = -1;
} else {
heightMapType = Heightmap.Types.MOTION_BLOCKING_NO_LEAVES;
SEARCH_DIRECTION = 1;
}
}
public boolean isDimension(ServerLevel level)
{
public boolean isDimension(ServerLevel level) {
String dim = WorldPosition.getDim(level);
return dim.equals(position.Dimension);
}
/**
* Searches for, and finds, a valid RTP location
* @param level The level to scan
* @return RTP data
*/
public static void find(ServerLevel level)
{
RandomPositionFactory.beginRTPSearch(level);
}
public BlockPos findSafeLandingLocation() {
BlockPos targetPos = position.Position.asBlockPos();
public static List<RTP> slicedByDimension(ServerLevel lvl)
{
List<RTP> slice = new ArrayList<>();
Iterator<RTP> it = RTPCaches.Locations.iterator();
while(it.hasNext())
{
RTP nxt = it.next();
if(nxt.isDimension(lvl))
{
slice.add(nxt);
}
// Search upward for a safe landing location
while (!isSafe(targetPos) || !isSafe(targetPos.above())) {
targetPos = targetPos.above();
}
return slice;
return targetPos;
}
public static RTP getRTP(ServerLevel level)
{
private boolean isSafe(BlockPos blockPos) {
BlockState blockState = dimension.getBlockState(blockPos);
BlockState blockStateAbove = dimension.getBlockState(blockPos.above());
BlockState blockStateBelow = dimension.getBlockState(blockPos.below());
if (blockState.isAir() && blockStateAbove.isAir()) {
if (!blockStateBelow.isAir()) {
return !BLACKLIST.contains(blockStateBelow.getBlock());
} else {
return false;
}
} else {
return false;
}
}
public static RTP getRTP(ServerLevel level) {
List<RTP> slice = slicedByDimension(level);
if(slice.size()>0)
{
RTP ret = slice.get(AriasEssentials.random.nextInt(0, slice.size()));
if (!slice.isEmpty()) {
RTP ret = slice.get(AriasEssentials.random.nextInt(slice.size()));
RTPCaches.Locations.remove(ret);
RandomPositionFactory.beginRTPSearch(ret.position.getActualDimension());
return ret;
} else return null;
}
public void moveDown() {
position.Position = position.Position.moveDown();
}
public void moveUp() {
position.Position = position.Position.moveUp();
}
public void move()
{
if(SearchDirection==1){
moveUp();
}else if(SearchDirection==0)
{
moveDown();
} else {
return null;
}
}
public void moveOpposite()
{
if(SearchDirection==1){
moveDown();
}else if(SearchDirection==0)
{
moveUp();
public void move() {
if (SEARCH_DIRECTION == 1) {
position.Position = position.Position.moveUp();
} else if (SEARCH_DIRECTION == -1) {
position.Position = position.Position.moveDown();
}
}
public void moveOpposite() {
move();
}
public void newPosition() {
if (!AriasEssentials.ALIVE || tries >= 25) return;
if (!AriasEssentials.ALIVE || tries >= 5) return;
containingThread = Thread.currentThread();
AriasEssentials.LOGGER.info("RTP starts looking for new position");
AriasEssentials.LOGGER.info("RTP starts looking for a new position");
Random rng = new Random(Instant.now().getEpochSecond());
@ -145,37 +109,27 @@ public class RTP
BlockPos bpos;
do {
pos = new Vector3(rng.nextDouble(0xFFFF), 150, rng.nextDouble(0xFFFF));
pos = new Vector3(rng.nextDouble(0xFFFF), -60, rng.nextDouble(0xFFFF));
pos = spiralPositions(pos);
position.Position = pos;
bpos = pos.asBlockPos();
} while (!isValidPosition(bpos));
if (pos.y < -30 || pos.y >= position.getActualDimension().getLogicalHeight()) {
newPosition();
return;
}
tries++;
AriasEssentials.LOGGER.info("RTP returns new position");
AriasEssentials.LOGGER.info("RTP returns a new position");
}
private boolean isValidPosition(BlockPos bpos) {
ServerLevel dimension = position.getActualDimension();
ChunkStatus status = ChunkStatus.SPAWN;
dimension.getChunk(bpos.getX() >> 4, bpos.getZ() >> 4, status);
Vector3 pos = new Vector3(dimension.getHeightmapPos(heightMapType, bpos));
return dimension.getWorldBorder().isWithinBounds(pos.asBlockPos());
}
private Vector3 spiralPositions(Vector3 position) {
Vec3i posi = position.asMinecraftVec3i();
ServerLevel dimension = this.position.getActualDimension();
BlockPos startBlockPos = new BlockPos(posi.getX(), dimension.getSeaLevel(), posi.getZ());
for (BlockPos pos : BlockPos.spiralAround(startBlockPos, 16, Direction.WEST, Direction.NORTH)) {
@ -188,32 +142,17 @@ public class RTP
return position;
}
public static List<RTP> slicedByDimension(ServerLevel lvl) {
List<RTP> slice = new ArrayList<>();
private boolean safe(BlockPos blockPos)
{
containingThread=Thread.currentThread();
BlockState b = position.getActualDimension().getBlockState(blockPos);
BlockState b2 = position.getActualDimension().getBlockState(blockPos.above());
BlockState b3 = position.getActualDimension().getBlockState(blockPos.below());
Iterator<RTP> it = RTPCaches.Locations.iterator();
while (it.hasNext()) {
RTP nxt = it.next();
if (nxt.isDimension(lvl)) {
slice.add(nxt);
}
}
if (b.isAir() && b2.isAir()) {
if (!b3.isAir()) {
return !BLACKLIST.contains(b3.getBlock());
} else
return false;
} else
return false;
}
public boolean isSafe(BlockPos blockPos) {
return safe(blockPos);
/*
boolean s = safe(blockPos);
if(s)
{
AriasEssentials.LOGGER.info("/!\\ SAFE /!\\");
}else AriasEssentials.LOGGER.info("/!\\ NOT SAFE /!\\");
return s;*/
return slice;
}
}

View file

@ -4,7 +4,9 @@ import dev.zontreck.essentials.AriasEssentials;
import dev.zontreck.essentials.Messages;
import dev.zontreck.essentials.commands.teleport.TeleportActioner;
import dev.zontreck.essentials.events.RTPFoundEvent;
import dev.zontreck.libzontreck.LibZontreck;
import dev.zontreck.libzontreck.util.ChatHelpers;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerLevel;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.TickEvent;
@ -19,6 +21,7 @@ public class RTPCachesEventHandlers
{
if(!AriasEssentials.ALIVE) return;
lastTick++;
MinecraftServer server = LibZontreck.THE_SERVER;
if(lastTick>=400)
{
lastTick=0;
@ -31,7 +34,7 @@ public class RTPCachesEventHandlers
firstRun=false;
AriasEssentials.LOGGER.info("Aria's Essentials startup is running. Scanning for initial RTP locations");
for(ServerLevel level : event.getServer().getAllLevels())
for(ServerLevel level : server.getAllLevels())
{
if(AriasEssentials.DEBUG)
{

View file

@ -1,24 +0,0 @@
package dev.zontreck.essentials.util;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
public class FileHandler
{
public static String readFile(String filePath) {
try {
byte[] fileBytes = Files.readAllBytes(Paths.get(filePath));
return new String(fileBytes);
} catch (IOException e) {
return "An error occurred: " + e.getMessage();
}
}
public static void writeFile(String filePath, String newContent) {
try {
Files.write(Paths.get(filePath), newContent.getBytes());
} catch (IOException e) {
}
}
}

View file

@ -1,5 +0,0 @@
public net.minecraft.client.gui.Gui
public net.minecraft.client.gui.Gui f_279580_ # GUI_ICONS_LOCATION
public net.minecraft.client.gui.Gui f_92974_ # displayHealth
public net.minecraft.client.gui.Gui f_92973_ # lastHealth
public net.minecraft.client.gui.Gui f_92976_ # healthBlinkTime

View file

@ -6,71 +6,67 @@
# 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="${loader_version_range}" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions.
loaderVersion="[40,)" #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="${mod_license}"
license="GPLv3"
# A URL to refer people to when problems occur with this mod
issueTrackerURL="https://github.com/zontreck/Arias-Essentials/issues/" #optional
#issueTrackerURL="https://change.me.to.your.issue.tracker.example.invalid/" #optional
# A list of mods - how many allowed here is determined by the individual mod loader
[[mods]] #mandatory
# The modid of the mod
modId="${mod_id}" #mandatory
# The version number of the mod
version="${mod_version}" #mandatory
modId="ariasessentials" #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="${mod_name}" #mandatory
# A URL to query for updates for this mod. See the JSON update specification https://docs.minecraftforge.net/en/latest/misc/updatechecker/
displayName="Aria's Essentials" #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
#displayURL="https://change.me.to.your.mods.homepage.example.invalid/" #optional
# A file name (in the root of the mod JAR) containing a logo for display
logoFile="ariasessentials.png" #optional
# A text field displayed in the mod UI
#credits="" #optional
credits="Thanks for this example mod goes to Java" #optional
# A text field displayed in the mod UI
authors="${mod_authors}" #optional
authors="Love, Cheese and small house plants" #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.
# IGNORE_ALL_VERSION means that your mod will not cause a red X if it's present on the client or the server. This is a special case and should only be used if your mod has no server component.
# NONE means that no display test is set on your mod. You need to do this yourself, see IExtensionPoint.DisplayTest for more information. You can define any scheme you wish with this value.
# IMPORTANT NOTE: this is NOT an instruction as to which environments (CLIENT or DEDICATED SERVER) your mod loads on. Your mod should load (and maybe do nothing!) whereever it finds itself.
#displayTest="MATCH_VERSION" # MATCH_VERSION is the default if nothing is specified (#optional)
displayTest="MATCH_VERSION" # MATCH_VERSION is the default if nothing is specified (#optional)
# The description text for the mod (multi line!) (#mandatory)
description='''${mod_description}'''
description='''
Aria's Essentials mod. This provides a bunch of essential functions and commands
'''
# A dependency - use the . to indicate dependency for a specific modid. Dependencies are optional.
[[dependencies.${mod_id}]] #optional
# the modid of the dependency
modId="forge" #mandatory
# Does this dependency have to exist - if not, ordering below must be specified
mandatory=true #mandatory
# The version range of the dependency
versionRange="${forge_version_range}" #mandatory
# An ordering relationship for the dependency - BEFORE or AFTER required if the dependency is not mandatory
# BEFORE - This mod is loaded BEFORE the dependency
# AFTER - This mod is loaded AFTER the dependency
ordering="NONE"
# Side this dependency is applied on - BOTH, CLIENT, or SERVER
side="BOTH"
[[dependencies.ariasessentials]] #optional
# the modid of the dependency
modId="forge" #mandatory
# Does this dependency have to exist - if not, ordering below must be specified
mandatory=true #mandatory
# The version range of the dependency
versionRange="[40,)" #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
side="BOTH"
# Here's another dependency
[[dependencies.${mod_id}]]
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="${minecraft_version_range}"
ordering="NONE"
side="BOTH"
[[dependencies.${mod_id}]]
modId="libzontreck"
mandatory=true
versionRange="[1.10,1.11)"
ordering="NONE"
side="BOTH"
# Features are specific properties of the game environment, that you may want to declare you require. This example declares
# that your mod requires GL version 3.2 or higher. Other features will be added. They are side aware so declaring this won't
# stop your mod loading on the server for example.
#[features.${mod_id}]
#openGLVersion="[3.2,)"
[[dependencies.ariasessentials]]
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.18.2,1.19)"
ordering="NONE"
side="BOTH"
[[dependencies.libzontreck]]
modId="libzontreck"
mandatory=true
versionRange="[1.10,1.11)"
ordering="NONE"
side="BOTH"

View file

@ -1,8 +1,8 @@
{
"pack": {
"description": {
"text": "${mod_id} resources"
},
"pack_format": 15
"description": "Aria's Essentials resources",
"pack_format": 9,
"forge:resource_pack_format": 8,
"forge:data_pack_format": 9
}
}