fix meteor explosion, modify hardcore death system a bit and add title system
This commit is contained in:
1 parent
4dbdd93918
commit
6b3746b287
11 files changed
+41
-13
No files matched your search
@@ -22,7 +22,6 @@ public class NexiaTeams implements ModInitializer {
|
||||
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
|
||||
ServerLifecycleEvents.SERVER_STARTED.register(ServerTime::firstTick);
|
||||
ServerLifecycleEvents.SERVER_STOPPING.register(ServerTime::stopServer);
|
||||
ServerTickEvents.END_SERVER_TICK.register(ServerTime::everyTick);
|
||||
|
||||
@@ -3,8 +3,6 @@ package com.nexia.teams.commands;
|
||||
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
|
||||
import net.fabricmc.fabric.api.event.Event;
|
||||
|
||||
import java.util.Calendar;
|
||||
|
||||
public class CommandLoader {
|
||||
public static void registerCommands() {
|
||||
Event<CommandRegistrationCallback> callbackEvent = CommandRegistrationCallback.EVENT;
|
||||
|
||||
@@ -17,6 +17,7 @@ public class EndCommand {
|
||||
private static int execute(CommandContext<CommandSourceStack> context) {
|
||||
NexiaTeams.endDisabled = !NexiaTeams.endDisabled;
|
||||
context.getSource().sendSystemMessage(ChatFormat.convertComponent(ChatFormat.nexiaMessage.append(Component.text((NexiaTeams.endDisabled ? "Disabled" : "Enabled") + " end."))));
|
||||
ChatFormat.nexiaTitle("End has been " + (NexiaTeams.endDisabled ? "disabled" : "enabled"));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,7 @@ public class HardcoreCommand {
|
||||
private static int execute(CommandContext<CommandSourceStack> context) {
|
||||
NexiaTeams.hardcoreEnabled = !NexiaTeams.hardcoreEnabled;
|
||||
context.getSource().sendSystemMessage(ChatFormat.convertComponent(ChatFormat.nexiaMessage.append(Component.text((NexiaTeams.hardcoreEnabled ? "Enabled" : "Disabled") + " hardcore death system."))));
|
||||
ChatFormat.nexiaTitle("Hardcore has been " + (NexiaTeams.hardcoreEnabled ? "enabled" : "disabled"));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,7 @@ public class NetherCommand {
|
||||
private static int execute(CommandContext<CommandSourceStack> context) {
|
||||
NexiaTeams.netherDisabled = !NexiaTeams.netherDisabled;
|
||||
context.getSource().sendSystemMessage(ChatFormat.convertComponent(ChatFormat.nexiaMessage.append(Component.text((NexiaTeams.netherDisabled ? "Disabled" : "Enabled") + " nether."))));
|
||||
ChatFormat.nexiaTitle("Nether has been " + (NexiaTeams.netherDisabled ? "disabled" : "enabled"));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,7 @@ public class PvpCommand {
|
||||
private static int execute(CommandContext<CommandSourceStack> context) {
|
||||
NexiaTeams.pvpEnabled = !NexiaTeams.pvpEnabled;
|
||||
context.getSource().sendSystemMessage(ChatFormat.convertComponent(ChatFormat.nexiaMessage.append(Component.text((NexiaTeams.hardcoreEnabled ? "Enabled" : "Disabled") + " pvp."))));
|
||||
ChatFormat.nexiaTitle("PVP has been " + (NexiaTeams.pvpEnabled ? "enabled" : "disabled"));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -5,12 +5,14 @@ import com.nexia.teams.utilities.chat.ChatFormat;
|
||||
import com.nexia.teams.utilities.time.ServerTime;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.entity.Display;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.decoration.ArmorStand;
|
||||
import net.minecraft.world.entity.projectile.LargeFireball;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.joml.Quaternionf;
|
||||
import org.joml.Vector3f;
|
||||
|
||||
@@ -56,15 +58,18 @@ public abstract class Meteor {
|
||||
Transformation transformation = new Transformation(new Vector3f(-2, -4, -2), new Quaternionf(0, 0, 0, 1), new Vector3f(4, 4, 4), new Quaternionf(0, 0, 0, 1));
|
||||
blockDisplay.setTransformation(transformation);
|
||||
blockDisplay.setPos(meteorCoordinates[0], meteorCoordinates[1], meteorCoordinates[2]);
|
||||
//AABB boundingBox = blockDisplay.getBoundingBox();
|
||||
//blockDisplay.setBoundingBox(new AABB(boundingBox.minX + 2, boundingBox.minY, boundingBox.minZ + 2, boundingBox.maxX - 2, boundingBox.maxY -4, boundingBox.maxZ - 2));
|
||||
|
||||
ArmorStand armorStand = new ArmorStand(world, meteorCoordinates[0], meteorCoordinates[1], meteorCoordinates[2]);
|
||||
armorStand.setInvisible(true);
|
||||
armorStand.setInvulnerable(true);
|
||||
|
||||
LargeFireball largeFireball = new LargeFireball(EntityType.FIREBALL, world);
|
||||
largeFireball.explosionPower = 20;
|
||||
largeFireball.explosionPower = 12;
|
||||
largeFireball.setPos(meteorCoordinates[0], meteorCoordinates[1], meteorCoordinates[2]);
|
||||
largeFireball.yPower = -1.35;
|
||||
largeFireball.setDeltaMovement(calculateViewVector(90, 0).normalize());
|
||||
largeFireball.yPower = largeFireball.getDeltaMovement().y * 0.1;
|
||||
|
||||
world.addFreshEntity(blockDisplay);
|
||||
world.addFreshEntity(armorStand);
|
||||
@@ -73,4 +78,14 @@ public abstract class Meteor {
|
||||
blockDisplay.startRiding(armorStand);
|
||||
armorStand.startRiding(largeFireball);
|
||||
}
|
||||
|
||||
public static Vec3 calculateViewVector(float f, float g) {
|
||||
float h = f * ((float)Math.PI / 180);
|
||||
float i = -g * ((float)Math.PI / 180);
|
||||
float j = Mth.cos(i);
|
||||
float k = Mth.sin(i);
|
||||
float l = Mth.cos(h);
|
||||
float m = Mth.sin(h);
|
||||
return new Vec3(k * l, -m, j * l);
|
||||
}
|
||||
}
|
||||
@@ -15,8 +15,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
public abstract class EndPortalBlockMixin {
|
||||
@Inject(method = "entityInside", at = @At("HEAD"), cancellable = true)
|
||||
private void disableEnd(BlockState blockState, Level level, BlockPos blockPos, Entity entity, CallbackInfo ci) {
|
||||
if (NexiaTeams.endDisabled) {
|
||||
ci.cancel();
|
||||
}
|
||||
if (NexiaTeams.endDisabled) ci.cancel();
|
||||
}
|
||||
}
|
||||
@@ -15,8 +15,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
public abstract class NetherPortalBlockMixin {
|
||||
@Inject(method = "entityInside", at = @At("HEAD"), cancellable = true)
|
||||
private void disableNetherPortal(BlockState blockState, Level level, BlockPos blockPos, Entity entity, CallbackInfo ci) {
|
||||
if (NexiaTeams.netherDisabled) {
|
||||
ci.cancel();
|
||||
}
|
||||
if (NexiaTeams.netherDisabled) ci.cancel();
|
||||
}
|
||||
}
|
||||
@@ -22,9 +22,11 @@ import org.spongepowered.asm.mixin.injection.ModifyArg;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(ServerGamePacketListenerImpl.class)
|
||||
public class ServerGamePacketListenerMixin {
|
||||
public abstract class ServerGamePacketListenerMixin {
|
||||
@Shadow public ServerPlayer player;
|
||||
|
||||
@Shadow public abstract ServerPlayer getPlayer();
|
||||
|
||||
@Inject(method = "handleUseItem", at = @At("TAIL"))
|
||||
public void pearlCooldownMessage(ServerboundUseItemPacket serverboundUseItemPacket, CallbackInfo ci) {
|
||||
InteractionHand interactionHand = serverboundUseItemPacket.getHand();
|
||||
@@ -52,6 +54,6 @@ public class ServerGamePacketListenerMixin {
|
||||
|
||||
@ModifyArg(method = "handleClientCommand", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ServerPlayer;setGameMode(Lnet/minecraft/world/level/GameType;)Z"))
|
||||
public GameType deathSystem(GameType gameType) {
|
||||
return NexiaTeams.hardcoreEnabled ? GameType.SPECTATOR : GameType.SURVIVAL;
|
||||
return NexiaTeams.hardcoreEnabled ? GameType.SPECTATOR : this.getPlayer().gameMode.getGameModeForPlayer();
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,17 @@
|
||||
package com.nexia.teams.utilities.chat;
|
||||
|
||||
import com.nexia.teams.utilities.time.ServerTime;
|
||||
import net.kyori.adventure.text.format.TextColor;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
|
||||
/*
|
||||
* Directly taken from Nexus and Nexia-Mod
|
||||
@@ -77,4 +83,12 @@ public abstract class ChatFormat {
|
||||
default -> primary;
|
||||
};
|
||||
}
|
||||
|
||||
public static void nexiaTitle(String message) {
|
||||
Component messageComponent = convertComponent(MiniMessage.miniMessage().deserialize(String.format("<bold><gradient:%s:%s>%s</gradient></bold>", ChatFormat.brandColor1, ChatFormat.brandColor2, message)));
|
||||
|
||||
for (ServerPlayer serverPlayer : ServerTime.minecraftServer.getPlayerList().getPlayers()) {
|
||||
serverPlayer.sendSystemMessage(messageComponent, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user