Cleanup/remove old "spamless" chat message code.
This was quickly ported to use overlays in 1.19, this commit removes the old junk code.
This commit is contained in:
parent
357c86940d
commit
770ac2292f
15 changed files with 77 additions and 194 deletions
|
@ -140,18 +140,6 @@ public class ClientBoundPacketHandlers {
|
|||
});
|
||||
|
||||
ClientNetworkManager.registerClientBoundHandler(new Identifier("reborncore", "sync_chunks"), ChunkLoaderManager.CODEC, ClientChunkManager::setLoadedChunks);
|
||||
|
||||
ClientNetworkManager.registerClientBoundHandler(new Identifier("reborncore", "no_spam_chat"), (client, handler, buf, responseSender) -> {
|
||||
final int messageId = buf.readInt();
|
||||
final Text text = buf.readText();
|
||||
|
||||
client.execute(() -> {
|
||||
int deleteID = RebornCore.MOD_ID.hashCode() + messageId;
|
||||
MinecraftClient.getInstance().inGameHud.setOverlayMessage(text, false);
|
||||
});
|
||||
});
|
||||
|
||||
ClientNetworkManager.registerClientBoundHandler(new Identifier("reborncore", "stacks_to_render"), Codec.list(ItemStack.CODEC), ItemStackRenderManager.RENDER_QUEUE::addAll);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -82,13 +82,6 @@ public class ClientBoundPackets {
|
|||
return NetworkManager.createClientBoundPacket(new Identifier("reborncore", "sync_chunks"), ChunkLoaderManager.CODEC, chunks);
|
||||
}
|
||||
|
||||
public static IdentifiedPacket createPacketNoSpamMessage(int messageId, Text text) {
|
||||
return NetworkManager.createClientBoundPacket(new Identifier("reborncore", "no_spam_chat"), packetBuffer -> {
|
||||
packetBuffer.writeInt(messageId);
|
||||
packetBuffer.writeText(text);
|
||||
});
|
||||
}
|
||||
|
||||
public static IdentifiedPacket createPacketQueueItemStacksToRender(List<ItemStack> stacks) {
|
||||
return NetworkManager.createClientBoundPacket(new Identifier("reborncore", "stacks_to_render"), Codec.list(ItemStack.CODEC), stacks);
|
||||
}
|
||||
|
|
|
@ -1,37 +0,0 @@
|
|||
/*
|
||||
* This file is part of RebornCore, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2021 TeamReborn
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package reborncore.common.util;
|
||||
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.text.Text;
|
||||
import reborncore.common.network.ClientBoundPackets;
|
||||
import reborncore.common.network.NetworkManager;
|
||||
|
||||
public class ChatUtils {
|
||||
|
||||
public static void sendNoSpamMessage(ServerPlayerEntity player, int messageID, Text message) {
|
||||
NetworkManager.sendToPlayer(ClientBoundPackets.createPacketNoSpamMessage(messageID, message), player);
|
||||
}
|
||||
}
|
|
@ -160,9 +160,8 @@ public class ItemUtils {
|
|||
*
|
||||
* @param stack {@link ItemStack} Stack to check
|
||||
* @param cost {@link int} Cost of operation performed by tool
|
||||
* @param messageId {@link int} MessageID for sending no spam message
|
||||
*/
|
||||
public static void checkActive(ItemStack stack, int cost, int messageId, Entity player) {
|
||||
public static void checkActive(ItemStack stack, int cost, Entity player) {
|
||||
if (!ItemUtils.isActive(stack)) {
|
||||
return;
|
||||
}
|
||||
|
@ -171,14 +170,13 @@ public class ItemUtils {
|
|||
}
|
||||
|
||||
if (player instanceof ServerPlayerEntity serverPlayerEntity) {
|
||||
ChatUtils.sendNoSpamMessage(serverPlayerEntity, messageId, Text.translatable("reborncore.message.energyError")
|
||||
.formatted(Formatting.GRAY)
|
||||
.append(" ")
|
||||
.append(
|
||||
Text.translatable("reborncore.message.deactivating")
|
||||
.formatted(Formatting.GOLD)
|
||||
)
|
||||
);
|
||||
serverPlayerEntity.sendMessage(Text.translatable("reborncore.message.energyError")
|
||||
.formatted(Formatting.GRAY)
|
||||
.append(" ")
|
||||
.append(
|
||||
Text.translatable("reborncore.message.deactivating")
|
||||
.formatted(Formatting.GOLD)
|
||||
), true);
|
||||
}
|
||||
|
||||
stack.getOrCreateNbt().putBoolean("isActive", false);
|
||||
|
@ -189,35 +187,32 @@ public class ItemUtils {
|
|||
*
|
||||
* @param stack {@link ItemStack} Stack to switch state
|
||||
* @param cost {@code int} Cost of operation performed by tool
|
||||
* @param messageId {@code int} MessageID for sending no spam message
|
||||
*/
|
||||
public static void switchActive(ItemStack stack, int cost, int messageId, Entity entity) {
|
||||
ItemUtils.checkActive(stack, cost, messageId, entity);
|
||||
public static void switchActive(ItemStack stack, int cost, Entity entity) {
|
||||
ItemUtils.checkActive(stack, cost, entity);
|
||||
|
||||
if (!ItemUtils.isActive(stack)) {
|
||||
stack.getOrCreateNbt().putBoolean("isActive", true);
|
||||
|
||||
if (entity instanceof ServerPlayerEntity serverPlayerEntity) {
|
||||
ChatUtils.sendNoSpamMessage(serverPlayerEntity, messageId, Text.translatable("reborncore.message.setTo")
|
||||
.formatted(Formatting.GRAY)
|
||||
.append(" ")
|
||||
.append(
|
||||
Text.translatable("reborncore.message.active")
|
||||
.formatted(Formatting.GOLD)
|
||||
)
|
||||
);
|
||||
serverPlayerEntity.sendMessage(Text.translatable("reborncore.message.setTo")
|
||||
.formatted(Formatting.GRAY)
|
||||
.append(" ")
|
||||
.append(
|
||||
Text.translatable("reborncore.message.active")
|
||||
.formatted(Formatting.GOLD)
|
||||
), true);
|
||||
}
|
||||
} else {
|
||||
stack.getOrCreateNbt().putBoolean("isActive", false);
|
||||
if (entity instanceof ServerPlayerEntity serverPlayerEntity) {
|
||||
ChatUtils.sendNoSpamMessage(serverPlayerEntity, messageId, Text.translatable("reborncore.message.setTo")
|
||||
.formatted(Formatting.GRAY)
|
||||
.append(" ")
|
||||
.append(
|
||||
Text.translatable("reborncore.message.inactive")
|
||||
.formatted(Formatting.GOLD)
|
||||
)
|
||||
);
|
||||
serverPlayerEntity.sendMessage(Text.translatable("reborncore.message.setTo")
|
||||
.formatted(Formatting.GRAY)
|
||||
.append(" ")
|
||||
.append(
|
||||
Text.translatable("reborncore.message.inactive")
|
||||
.formatted(Formatting.GOLD)
|
||||
), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue