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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,12 +38,10 @@ import net.minecraft.util.Formatting;
|
|||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import reborncore.api.IToolDrop;
|
||||
import reborncore.common.util.ChatUtils;
|
||||
import techreborn.blocks.misc.BlockAlarm;
|
||||
import techreborn.init.ModSounds;
|
||||
import techreborn.init.TRBlockEntities;
|
||||
import techreborn.init.TRContent;
|
||||
import techreborn.utils.MessageIDs;
|
||||
|
||||
public class AlarmBlockEntity extends BlockEntity
|
||||
implements BlockEntityTicker<AlarmBlockEntity>, IToolDrop {
|
||||
|
@ -63,10 +61,10 @@ public class AlarmBlockEntity extends BlockEntity
|
|||
}
|
||||
|
||||
if (entity instanceof ServerPlayerEntity serverPlayerEntity) {
|
||||
ChatUtils.sendNoSpamMessage(serverPlayerEntity, MessageIDs.alarmID, Text.translatable("techreborn.message.alarm")
|
||||
.formatted(Formatting.GRAY)
|
||||
.append(" Alarm ")
|
||||
.append(String.valueOf(selectedSound)));
|
||||
serverPlayerEntity.sendMessage(Text.translatable("techreborn.message.alarm")
|
||||
.formatted(Formatting.GRAY)
|
||||
.append(" Alarm ")
|
||||
.append(String.valueOf(selectedSound)), true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -49,11 +49,9 @@ import reborncore.api.IToolDrop;
|
|||
import reborncore.api.ToolManager;
|
||||
import reborncore.api.blockentity.IMachineGuiHandler;
|
||||
import reborncore.common.blocks.BlockMachineBase;
|
||||
import reborncore.common.util.ChatUtils;
|
||||
import reborncore.common.util.StringUtils;
|
||||
import techreborn.blockentity.GuiType;
|
||||
import techreborn.blockentity.machine.tier1.PlayerDetectorBlockEntity;
|
||||
import techreborn.utils.MessageIDs;
|
||||
|
||||
public class PlayerDetectorBlock extends BlockMachineBase {
|
||||
|
||||
|
@ -124,15 +122,13 @@ public class PlayerDetectorBlock extends BlockMachineBase {
|
|||
}
|
||||
|
||||
if (playerIn instanceof ServerPlayerEntity serverPlayerEntity) {
|
||||
ChatUtils.sendNoSpamMessage(serverPlayerEntity, MessageIDs.playerDetectorID,
|
||||
Text.translatable("techreborn.message.detects")
|
||||
.formatted(Formatting.GRAY)
|
||||
.append(" ")
|
||||
.append(
|
||||
Text.literal(StringUtils.toFirstCapital(newType.asString()))
|
||||
.formatted(color)
|
||||
)
|
||||
);
|
||||
serverPlayerEntity.sendMessage(Text.translatable("techreborn.message.detects")
|
||||
.formatted(Formatting.GRAY)
|
||||
.append(" ")
|
||||
.append(
|
||||
Text.literal(StringUtils.toFirstCapital(newType.asString()))
|
||||
.formatted(color)
|
||||
), true);
|
||||
}
|
||||
|
||||
if (getGui() != null && !playerIn.isSneaking()) {
|
||||
|
|
|
@ -42,7 +42,6 @@ import reborncore.common.powerSystem.RcEnergyTier;
|
|||
import reborncore.common.util.ItemUtils;
|
||||
import techreborn.TechReborn;
|
||||
import techreborn.utils.InitUtils;
|
||||
import techreborn.utils.MessageIDs;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -62,7 +61,7 @@ public class BatteryItem extends Item implements RcEnergyItem {
|
|||
public TypedActionResult<ItemStack> use(final World world, final PlayerEntity player, final Hand hand) {
|
||||
final ItemStack stack = player.getStackInHand(hand);
|
||||
if (player.isSneaking()) {
|
||||
ItemUtils.switchActive(stack, 1, MessageIDs.poweredToolID, player);
|
||||
ItemUtils.switchActive(stack, 1, player);
|
||||
return new TypedActionResult<>(ActionResult.SUCCESS, stack);
|
||||
}
|
||||
return new TypedActionResult<>(ActionResult.PASS, stack);
|
||||
|
@ -70,7 +69,7 @@ public class BatteryItem extends Item implements RcEnergyItem {
|
|||
|
||||
@Override
|
||||
public void inventoryTick(ItemStack stack, World world, Entity entity, int slot, boolean selected) {
|
||||
ItemUtils.checkActive(stack, 1, MessageIDs.poweredToolID, entity);
|
||||
ItemUtils.checkActive(stack, 1, entity);
|
||||
if (world.isClient) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -39,9 +39,7 @@ import net.minecraft.util.registry.RegistryKey;
|
|||
import net.minecraft.world.World;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import reborncore.common.chunkloading.ChunkLoaderManager;
|
||||
import reborncore.common.util.ChatUtils;
|
||||
import techreborn.TechReborn;
|
||||
import techreborn.utils.MessageIDs;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
@ -64,17 +62,17 @@ public class FrequencyTransmitterItem extends Item {
|
|||
.ifPresent(tag -> stack.getOrCreateNbt().put("pos", tag));
|
||||
|
||||
if (context.getPlayer() instanceof ServerPlayerEntity serverPlayerEntity) {
|
||||
ChatUtils.sendNoSpamMessage(serverPlayerEntity, MessageIDs.freqTransmitterID, Text.translatable("techreborn.message.setTo")
|
||||
.append(Text.literal(" X:").formatted(Formatting.GRAY))
|
||||
.append(Text.literal(String.valueOf(pos.getX())).formatted(Formatting.GOLD))
|
||||
.append(Text.literal(" Y:").formatted(Formatting.GRAY))
|
||||
.append(Text.literal(String.valueOf(pos.getY())).formatted(Formatting.GOLD))
|
||||
.append(Text.literal(" Z:").formatted(Formatting.GRAY))
|
||||
.append(Text.literal(String.valueOf(pos.getZ())).formatted(Formatting.GOLD))
|
||||
.append(" ")
|
||||
.append(Text.translatable("techreborn.message.in").formatted(Formatting.GRAY))
|
||||
.append(" ")
|
||||
.append(Text.literal(getDimName(globalPos.getDimension()).toString()).formatted(Formatting.GOLD)));
|
||||
serverPlayerEntity.sendMessage(Text.translatable("techreborn.message.setTo")
|
||||
.append(Text.literal(" X:").formatted(Formatting.GRAY))
|
||||
.append(Text.literal(String.valueOf(pos.getX())).formatted(Formatting.GOLD))
|
||||
.append(Text.literal(" Y:").formatted(Formatting.GRAY))
|
||||
.append(Text.literal(String.valueOf(pos.getY())).formatted(Formatting.GOLD))
|
||||
.append(Text.literal(" Z:").formatted(Formatting.GRAY))
|
||||
.append(Text.literal(String.valueOf(pos.getZ())).formatted(Formatting.GOLD))
|
||||
.append(" ")
|
||||
.append(Text.translatable("techreborn.message.in").formatted(Formatting.GRAY))
|
||||
.append(" ")
|
||||
.append(Text.literal(getDimName(globalPos.getDimension()).toString()).formatted(Formatting.GOLD)), true);
|
||||
}
|
||||
|
||||
return ActionResult.SUCCESS;
|
||||
|
@ -95,15 +93,13 @@ public class FrequencyTransmitterItem extends Item {
|
|||
stack.setNbt(null);
|
||||
|
||||
if (player instanceof ServerPlayerEntity serverPlayerEntity) {
|
||||
ChatUtils.sendNoSpamMessage(serverPlayerEntity, MessageIDs.freqTransmitterID,
|
||||
Text.translatable("techreborn.message.coordsHaveBeen")
|
||||
.formatted(Formatting.GRAY)
|
||||
.append(" ")
|
||||
.append(
|
||||
Text.translatable("techreborn.message.cleared")
|
||||
.formatted(Formatting.GOLD)
|
||||
)
|
||||
);
|
||||
serverPlayerEntity.sendMessage(Text.translatable("techreborn.message.coordsHaveBeen")
|
||||
.formatted(Formatting.GRAY)
|
||||
.append(" ")
|
||||
.append(
|
||||
Text.translatable("techreborn.message.cleared")
|
||||
.formatted(Formatting.GOLD)
|
||||
), true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -35,9 +35,7 @@ import net.minecraft.util.Hand;
|
|||
import net.minecraft.util.TypedActionResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import reborncore.common.util.ChatUtils;
|
||||
import techreborn.TechReborn;
|
||||
import techreborn.utils.MessageIDs;
|
||||
|
||||
public class GpsItem extends Item {
|
||||
|
||||
|
@ -50,13 +48,12 @@ public class GpsItem extends Item {
|
|||
ItemStack stack = player.getStackInHand(hand);
|
||||
if (player instanceof ServerPlayerEntity serverPlayerEntity) {
|
||||
BlockPos pos = player.getBlockPos();
|
||||
ChatUtils.sendNoSpamMessage(serverPlayerEntity, MessageIDs.freqTransmitterID,
|
||||
Text.literal(" X:").formatted(Formatting.GRAY)
|
||||
.append(Text.literal(String.valueOf(pos.getX())).formatted(Formatting.GOLD))
|
||||
.append(Text.literal(" Y:").formatted(Formatting.GRAY))
|
||||
.append(Text.literal(String.valueOf(pos.getY())).formatted(Formatting.GOLD))
|
||||
.append(Text.literal(" Z:").formatted(Formatting.GRAY))
|
||||
.append(Text.literal(String.valueOf(pos.getZ())).formatted(Formatting.GOLD)));
|
||||
serverPlayerEntity.sendMessage(Text.literal(" X:").formatted(Formatting.GRAY)
|
||||
.append(Text.literal(String.valueOf(pos.getX())).formatted(Formatting.GOLD))
|
||||
.append(Text.literal(" Y:").formatted(Formatting.GRAY))
|
||||
.append(Text.literal(String.valueOf(pos.getY())).formatted(Formatting.GOLD))
|
||||
.append(Text.literal(" Z:").formatted(Formatting.GRAY))
|
||||
.append(Text.literal(String.valueOf(pos.getZ())).formatted(Formatting.GOLD)), true);
|
||||
return new TypedActionResult<>(ActionResult.SUCCESS, stack);
|
||||
}
|
||||
return new TypedActionResult<>(ActionResult.PASS, stack);
|
||||
|
|
|
@ -43,7 +43,6 @@ import reborncore.common.util.ItemUtils;
|
|||
import techreborn.config.TechRebornConfig;
|
||||
import techreborn.init.TRToolMaterials;
|
||||
import techreborn.items.tool.JackhammerItem;
|
||||
import techreborn.utils.MessageIDs;
|
||||
import techreborn.utils.ToolsUtil;
|
||||
|
||||
import java.util.Collections;
|
||||
|
@ -88,7 +87,7 @@ public class AdvancedJackhammerItem extends JackhammerItem implements MultiBlock
|
|||
public TypedActionResult<ItemStack> use(final World world, final PlayerEntity player, final Hand hand) {
|
||||
final ItemStack stack = player.getStackInHand(hand);
|
||||
if (player.isSneaking()) {
|
||||
ItemUtils.switchActive(stack, cost, MessageIDs.poweredToolID, player);
|
||||
ItemUtils.switchActive(stack, cost, player);
|
||||
return new TypedActionResult<>(ActionResult.SUCCESS, stack);
|
||||
}
|
||||
return new TypedActionResult<>(ActionResult.PASS, stack);
|
||||
|
@ -96,7 +95,7 @@ public class AdvancedJackhammerItem extends JackhammerItem implements MultiBlock
|
|||
|
||||
@Override
|
||||
public void inventoryTick(ItemStack stack, World world, Entity entity, int slot, boolean selected) {
|
||||
ItemUtils.checkActive(stack, cost, MessageIDs.poweredToolID, entity);
|
||||
ItemUtils.checkActive(stack, cost, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -45,7 +45,6 @@ import reborncore.common.util.ItemUtils;
|
|||
import techreborn.config.TechRebornConfig;
|
||||
import techreborn.init.TRToolMaterials;
|
||||
import techreborn.items.tool.ChainsawItem;
|
||||
import techreborn.utils.MessageIDs;
|
||||
import techreborn.utils.ToolsUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -127,7 +126,7 @@ public class IndustrialChainsawItem extends ChainsawItem {
|
|||
public TypedActionResult<ItemStack> use(final World world, final PlayerEntity player, final Hand hand) {
|
||||
final ItemStack stack = player.getStackInHand(hand);
|
||||
if (player.isSneaking()) {
|
||||
ItemUtils.switchActive(stack, cost, MessageIDs.poweredToolID, player);
|
||||
ItemUtils.switchActive(stack, cost, player);
|
||||
return new TypedActionResult<>(ActionResult.SUCCESS, stack);
|
||||
}
|
||||
return new TypedActionResult<>(ActionResult.PASS, stack);
|
||||
|
@ -135,7 +134,7 @@ public class IndustrialChainsawItem extends ChainsawItem {
|
|||
|
||||
@Override
|
||||
public void usageTick(World world, LivingEntity entity, ItemStack stack, int i) {
|
||||
ItemUtils.checkActive(stack, cost, MessageIDs.poweredToolID, entity);
|
||||
ItemUtils.checkActive(stack, cost, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -47,7 +47,6 @@ import techreborn.init.TRToolMaterials;
|
|||
import techreborn.items.tool.DrillItem;
|
||||
import techreborn.items.tool.MiningLevel;
|
||||
import techreborn.utils.InitUtils;
|
||||
import techreborn.utils.MessageIDs;
|
||||
import techreborn.utils.ToolsUtil;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -100,7 +99,7 @@ public class IndustrialDrillItem extends DrillItem {
|
|||
public TypedActionResult<ItemStack> use(final World world, final PlayerEntity player, final Hand hand) {
|
||||
final ItemStack stack = player.getStackInHand(hand);
|
||||
if (player.isSneaking()) {
|
||||
ItemUtils.switchActive(stack, cost, MessageIDs.poweredToolID, player);
|
||||
ItemUtils.switchActive(stack, cost, player);
|
||||
return new TypedActionResult<>(ActionResult.SUCCESS, stack);
|
||||
}
|
||||
return new TypedActionResult<>(ActionResult.PASS, stack);
|
||||
|
@ -108,7 +107,7 @@ public class IndustrialDrillItem extends DrillItem {
|
|||
|
||||
@Override
|
||||
public void usageTick(World world, LivingEntity entity, ItemStack stack, int i) {
|
||||
ItemUtils.checkActive(stack, cost, MessageIDs.poweredToolID, entity);
|
||||
ItemUtils.checkActive(stack, cost, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -41,12 +41,10 @@ import net.minecraft.world.World;
|
|||
import org.jetbrains.annotations.Nullable;
|
||||
import reborncore.common.misc.MultiBlockBreakingTool;
|
||||
import reborncore.common.powerSystem.RcEnergyTier;
|
||||
import reborncore.common.util.ChatUtils;
|
||||
import reborncore.common.util.ItemUtils;
|
||||
import techreborn.config.TechRebornConfig;
|
||||
import techreborn.init.TRToolMaterials;
|
||||
import techreborn.items.tool.JackhammerItem;
|
||||
import techreborn.utils.MessageIDs;
|
||||
import techreborn.utils.ToolsUtil;
|
||||
|
||||
import java.util.Collections;
|
||||
|
@ -61,22 +59,22 @@ public class IndustrialJackhammerItem extends JackhammerItem implements MultiBlo
|
|||
}
|
||||
|
||||
// Cycle Inactive, Active 3*3 and Active 5*5
|
||||
private void switchAOE(ItemStack stack, int cost, int messageId, Entity entity) {
|
||||
ItemUtils.checkActive(stack, cost, messageId, entity);
|
||||
private void switchAOE(ItemStack stack, int cost, Entity entity) {
|
||||
ItemUtils.checkActive(stack, cost, entity);
|
||||
if (!ItemUtils.isActive(stack)) {
|
||||
ItemUtils.switchActive(stack, cost, messageId, entity);
|
||||
ItemUtils.switchActive(stack, cost, entity);
|
||||
stack.getOrCreateNbt().putBoolean("AOE5", false);
|
||||
if (entity instanceof ServerPlayerEntity serverPlayerEntity) {
|
||||
ChatUtils.sendNoSpamMessage(serverPlayerEntity, messageId, Text.translatable("techreborn.message.setTo").formatted(Formatting.GRAY).append(" ").append(Text.literal("3*3").formatted(Formatting.GOLD)));
|
||||
serverPlayerEntity.sendMessage(Text.translatable("techreborn.message.setTo").formatted(Formatting.GRAY).append(" ").append(Text.literal("3*3").formatted(Formatting.GOLD)), true);
|
||||
}
|
||||
} else {
|
||||
if (isAOE5(stack)) {
|
||||
ItemUtils.switchActive(stack, cost, messageId, entity);
|
||||
ItemUtils.switchActive(stack, cost, entity);
|
||||
stack.getOrCreateNbt().putBoolean("AOE5", false);
|
||||
} else {
|
||||
stack.getOrCreateNbt().putBoolean("AOE5", true);
|
||||
if (entity instanceof ServerPlayerEntity serverPlayerEntity) {
|
||||
ChatUtils.sendNoSpamMessage(serverPlayerEntity, messageId, Text.translatable("techreborn.message.setTo").formatted(Formatting.GRAY).append(" ").append(Text.literal("5*5").formatted(Formatting.GOLD)));
|
||||
serverPlayerEntity.sendMessage(Text.translatable("techreborn.message.setTo").formatted(Formatting.GRAY).append(" ").append(Text.literal("5*5").formatted(Formatting.GOLD)), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -131,7 +129,7 @@ public class IndustrialJackhammerItem extends JackhammerItem implements MultiBlo
|
|||
public TypedActionResult<ItemStack> use(final World world, final PlayerEntity player, final Hand hand) {
|
||||
final ItemStack stack = player.getStackInHand(hand);
|
||||
if (player.isSneaking()) {
|
||||
switchAOE(stack, cost, MessageIDs.poweredToolID, player);
|
||||
switchAOE(stack, cost, player);
|
||||
return new TypedActionResult<>(ActionResult.SUCCESS, stack);
|
||||
}
|
||||
return new TypedActionResult<>(ActionResult.PASS, stack);
|
||||
|
@ -139,7 +137,7 @@ public class IndustrialJackhammerItem extends JackhammerItem implements MultiBlo
|
|||
|
||||
@Override
|
||||
public void inventoryTick(ItemStack stack, World world, Entity entity, int slot, boolean selected) {
|
||||
ItemUtils.checkActive(stack, cost, MessageIDs.poweredToolID, entity);
|
||||
ItemUtils.checkActive(stack, cost, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -56,7 +56,6 @@ import techreborn.TechReborn;
|
|||
import techreborn.config.TechRebornConfig;
|
||||
import techreborn.init.TRContent;
|
||||
import techreborn.init.TRToolMaterials;
|
||||
import techreborn.utils.MessageIDs;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -84,14 +83,14 @@ public class NanosaberItem extends SwordItem implements RcEnergyItem {
|
|||
// Item
|
||||
@Override
|
||||
public void inventoryTick(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) {
|
||||
ItemUtils.checkActive(stack, cost, MessageIDs.poweredToolID, entityIn);
|
||||
ItemUtils.checkActive(stack, cost, entityIn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypedActionResult<ItemStack> use(final World world, final PlayerEntity player, final Hand hand) {
|
||||
final ItemStack stack = player.getStackInHand(hand);
|
||||
if (player.isSneaking()) {
|
||||
ItemUtils.switchActive(stack, cost, MessageIDs.poweredToolID, player);
|
||||
ItemUtils.switchActive(stack, cost, player);
|
||||
return new TypedActionResult<>(ActionResult.SUCCESS, stack);
|
||||
}
|
||||
return new TypedActionResult<>(ActionResult.PASS, stack);
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
/*
|
||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2020 TechReborn
|
||||
*
|
||||
* 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 techreborn.utils;
|
||||
|
||||
/**
|
||||
* @author Prospector on 21/05/16
|
||||
*/
|
||||
public class MessageIDs {
|
||||
public static int freqTransmitterID = 0;
|
||||
public static int fluidPipeID = 1;
|
||||
public static int playerDetectorID = 2;
|
||||
public static int poweredToolID = 3;
|
||||
public static int alarmID = 4;
|
||||
}
|
Loading…
Reference in a new issue