Backport to 1.18.2
This commit is contained in:
parent
ed20b4f5fb
commit
8eb93ff176
32 changed files with 276 additions and 242 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)-> {
|
||||
|
||||
|
|
|
@ -42,7 +42,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 +63,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 +73,9 @@ 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());
|
||||
|
||||
Home newhome = new Home(p, homeName, dest, new ItemStack(p.getBlockStateOn().getBlock().asItem()));
|
||||
Home newhome = new Home(p, homeName, dest, new ItemStack(p.getFeetBlockState().getBlock().asItem()));
|
||||
AriasEssentials.player_homes.get(p.getUUID()).add(newhome);
|
||||
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -2,6 +2,7 @@ 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.libzontreck.chestgui.ChestGUI;
|
||||
import dev.zontreck.libzontreck.chestgui.ChestGUIButton;
|
||||
import dev.zontreck.libzontreck.chestgui.ChestGUIIdentifier;
|
||||
|
@ -25,7 +26,12 @@ public class TPEffectsCommand
|
|||
|
||||
public static int tpeffects(CommandSourceStack source, boolean enabled)
|
||||
{
|
||||
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());
|
||||
|
|
|
@ -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"))
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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))
|
||||
{
|
||||
|
|
|
@ -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 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 +57,8 @@ 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());
|
||||
Warp w = new Warp(p.getUUID(), string, false, true, dest, new ItemStack(p.getFeetBlockState().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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -87,7 +87,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"
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<>();
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue