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:
modmuss50 2022-11-16 21:19:12 +00:00
parent 357c86940d
commit 770ac2292f
15 changed files with 77 additions and 194 deletions

View file

@ -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;
}

View file

@ -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);
}
}

View file

@ -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);

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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);