updated to 1.14.3 pre 2, still issues with fabric spawn tracking mappings
This commit is contained in:
1 parent
a5d83a0c53
commit
f3da8b2576
31 files changed
+180
-173
No files matched your search
+2
-2
@@ -4,8 +4,8 @@ org.gradle.jvmargs=-Xmx1G
|
||||
# Fabric Properties
|
||||
# check these on https://fabricmc.net/use
|
||||
# or better: https://modmuss50.me/fabric.html
|
||||
minecraft_version=1.14.3-pre1
|
||||
yarn_mappings=1.14.3-pre1+build.1
|
||||
minecraft_version=1.14.3-pre2
|
||||
yarn_mappings=1.14.3-pre2+build.1
|
||||
loader_version=0.4.8+build.154
|
||||
|
||||
# Mod Properties
|
||||
|
||||
@@ -10,7 +10,7 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
import net.minecraft.server.command.CommandManager;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.network.chat.BaseComponent;
|
||||
import net.minecraft.text.BaseText;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -83,7 +83,7 @@ public class CarpetCommand
|
||||
|
||||
Arrays.stream(rule.getInfo()).forEach(s -> Messenger.m(player, "g "+s));
|
||||
|
||||
List<BaseComponent> tags = new ArrayList<>();
|
||||
List<BaseText> tags = new ArrayList<>();
|
||||
tags.add(Messenger.c("w Tags: "));
|
||||
for (String t: rule.getTags())
|
||||
{
|
||||
@@ -94,7 +94,7 @@ public class CarpetCommand
|
||||
Messenger.m(player, tags.toArray(new Object[0]));
|
||||
|
||||
Messenger.m(player, "w Current value: ",String.format("%s %s (%s value)",rule.getBoolValue()?"lb":"nb", rule.getStringValue(),rule.isDefault()?"default":"modified"));
|
||||
List<BaseComponent> options = new ArrayList<>();
|
||||
List<BaseText> options = new ArrayList<>();
|
||||
options.add(Messenger.c("w Options: ", "y [ "));
|
||||
for (String o: rule.getOptions())
|
||||
{
|
||||
@@ -133,7 +133,7 @@ public class CarpetCommand
|
||||
}
|
||||
|
||||
|
||||
private static BaseComponent displayInteractiveSetting(CarpetSettingEntry e)
|
||||
private static BaseText displayInteractiveSetting(CarpetSettingEntry e)
|
||||
{
|
||||
List<Object> args = new ArrayList<>();
|
||||
args.add("w - "+e.getName()+" ");
|
||||
|
||||
@@ -9,7 +9,7 @@ import net.minecraft.command.CommandException;
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
import net.minecraft.server.command.CommandManager;
|
||||
import net.minecraft.util.DyeColor;
|
||||
import net.minecraft.network.chat.BaseComponent;
|
||||
import net.minecraft.text.BaseText;
|
||||
|
||||
public class CounterCommand
|
||||
{
|
||||
@@ -42,7 +42,7 @@ public class CounterCommand
|
||||
HopperCounter counter = HopperCounter.getCounter(color);
|
||||
if (counter == null) throw new CommandException(Messenger.s("Unknown wool color: "+color));
|
||||
|
||||
for (BaseComponent message: counter.format(source.getMinecraftServer(), realtime, false))
|
||||
for (BaseText message: counter.format(source.getMinecraftServer(), realtime, false))
|
||||
{
|
||||
source.sendFeedback(message, false);
|
||||
}
|
||||
@@ -68,7 +68,7 @@ public class CounterCommand
|
||||
|
||||
private static int listAllCounters(ServerCommandSource source, boolean realtime)
|
||||
{
|
||||
for (BaseComponent message: HopperCounter.formatAll(source.getMinecraftServer(), realtime))
|
||||
for (BaseText message: HopperCounter.formatAll(source.getMinecraftServer(), realtime))
|
||||
{
|
||||
source.sendFeedback(message, false);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import carpet.utils.EntityInfo;
|
||||
import carpet.utils.Messenger;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import net.minecraft.network.chat.BaseComponent;
|
||||
import net.minecraft.text.BaseText;
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
import net.minecraft.command.arguments.BlockPosArgumentType;
|
||||
import net.minecraft.command.arguments.EntityArgumentType;
|
||||
@@ -55,9 +55,9 @@ public class InfoCommand
|
||||
dispatcher.register(command);
|
||||
}
|
||||
|
||||
public static void printEntity(List<BaseComponent> messages, ServerCommandSource source, String grep)
|
||||
public static void printEntity(List<BaseText> messages, ServerCommandSource source, String grep)
|
||||
{
|
||||
List<BaseComponent> actual = new ArrayList<>();
|
||||
List<BaseText> actual = new ArrayList<>();
|
||||
if (grep != null)
|
||||
{
|
||||
Pattern p = Pattern.compile(grep);
|
||||
@@ -65,7 +65,7 @@ public class InfoCommand
|
||||
boolean empty = true;
|
||||
for (int i = 1; i<messages.size(); i++)
|
||||
{
|
||||
BaseComponent line = messages.get(i);
|
||||
BaseText line = messages.get(i);
|
||||
Matcher m = p.matcher(line.getString());
|
||||
if (m.find())
|
||||
{
|
||||
@@ -86,7 +86,7 @@ public class InfoCommand
|
||||
Messenger.send(source, actual);
|
||||
}
|
||||
|
||||
public static void printBlock(List<BaseComponent> messages, ServerCommandSource source, String grep)
|
||||
public static void printBlock(List<BaseText> messages, ServerCommandSource source, String grep)
|
||||
{
|
||||
Messenger.m(source, "");
|
||||
if (grep != null)
|
||||
@@ -95,7 +95,7 @@ public class InfoCommand
|
||||
Messenger.m(source, messages.get(0));
|
||||
for (int i = 1; i<messages.size(); i++)
|
||||
{
|
||||
BaseComponent line = messages.get(i);
|
||||
BaseText line = messages.get(i);
|
||||
Matcher m = p.matcher(line.getString());
|
||||
if (m.find())
|
||||
{
|
||||
@@ -115,7 +115,7 @@ public class InfoCommand
|
||||
{
|
||||
for (Entity e: entities)
|
||||
{
|
||||
List<BaseComponent> report = EntityInfo.entityInfo(e, source.getWorld());
|
||||
List<BaseText> report = EntityInfo.entityInfo(e, source.getWorld());
|
||||
printEntity(report, source, grep);
|
||||
}
|
||||
return 1;
|
||||
|
||||
@@ -8,7 +8,7 @@ import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.network.chat.BaseComponent;
|
||||
import net.minecraft.text.BaseText;
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
|
||||
import static com.mojang.brigadier.arguments.FloatArgumentType.floatArg;
|
||||
@@ -86,7 +86,7 @@ public class TickCommand
|
||||
catch (CommandSyntaxException ignored)
|
||||
{
|
||||
}
|
||||
BaseComponent message = TickSpeed.tickrate_advance(player, advance, tail_command, source);
|
||||
BaseText message = TickSpeed.tickrate_advance(player, advance, tail_command, source);
|
||||
if (message != null)
|
||||
{
|
||||
source.sendFeedback(message, false);
|
||||
|
||||
@@ -7,8 +7,8 @@ import it.unimi.dsi.fastutil.objects.Object2LongMap;
|
||||
import net.minecraft.util.DyeColor;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.chat.BaseComponent;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.text.BaseText;
|
||||
import net.minecraft.text.TranslatableText;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -73,13 +73,13 @@ public class HopperCounter
|
||||
}
|
||||
}
|
||||
|
||||
public static List<BaseComponent> formatAll(MinecraftServer server, boolean realtime)
|
||||
public static List<BaseText> formatAll(MinecraftServer server, boolean realtime)
|
||||
{
|
||||
List<BaseComponent> text = new ArrayList<>();
|
||||
List<BaseText> text = new ArrayList<>();
|
||||
|
||||
for (HopperCounter counter : COUNTERS.values())
|
||||
{
|
||||
List<BaseComponent> temp = counter.format(server, realtime, false);
|
||||
List<BaseText> temp = counter.format(server, realtime, false);
|
||||
if (temp.size() > 1)
|
||||
{
|
||||
if (!text.isEmpty()) text.add(Messenger.s(""));
|
||||
@@ -93,7 +93,7 @@ public class HopperCounter
|
||||
return text;
|
||||
}
|
||||
|
||||
public List<BaseComponent> format(MinecraftServer server, boolean realTime, boolean brief)
|
||||
public List<BaseText> format(MinecraftServer server, boolean realTime, boolean brief)
|
||||
{
|
||||
if (counter.isEmpty())
|
||||
{
|
||||
@@ -120,14 +120,14 @@ public class HopperCounter
|
||||
return Collections.singletonList(Messenger.c(String.format("c %s: %d, %d/h, %.1f min ",
|
||||
color.getName(), total, total * (20 * 60 * 60) / ticks, ticks / (20.0 * 60.0))));
|
||||
}
|
||||
List<BaseComponent> items = new ArrayList<>();
|
||||
List<BaseText> items = new ArrayList<>();
|
||||
items.add(Messenger.c(String.format("w Items for %s (%.2f min.%s), total: %d, (%.1f/h):",
|
||||
color, ticks*1.0/(20*60), (realTime?" - real time":""), total, total*1.0*(20*60*60)/ticks),
|
||||
"nb [X]", "^g reset", "!/counter "+color+" reset"
|
||||
));
|
||||
items.addAll(counter.object2LongEntrySet().stream().map(e ->
|
||||
{
|
||||
BaseComponent itemName = new TranslatableComponent(e.getKey().getTranslationKey());
|
||||
BaseText itemName = new TranslatableText(e.getKey().getTranslationKey());
|
||||
long count = e.getLongValue();
|
||||
return Messenger.c("w - ", itemName, String.format("w : %d, %.1f/h",
|
||||
count,
|
||||
|
||||
@@ -6,7 +6,7 @@ import net.minecraft.server.command.ServerCommandSource;
|
||||
import net.minecraft.server.command.CommandManager;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.network.chat.BaseComponent;
|
||||
import net.minecraft.text.BaseText;
|
||||
|
||||
public class TickSpeed
|
||||
{
|
||||
@@ -48,7 +48,7 @@ public class TickSpeed
|
||||
}
|
||||
}
|
||||
|
||||
public static BaseComponent tickrate_advance(PlayerEntity player, int advance, String callback, ServerCommandSource source)
|
||||
public static BaseText tickrate_advance(PlayerEntity player, int advance, String callback, ServerCommandSource source)
|
||||
{
|
||||
if (0 == advance)
|
||||
{
|
||||
|
||||
@@ -2,7 +2,7 @@ package carpet.logging;
|
||||
|
||||
import carpet.utils.HUDController;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.network.chat.BaseComponent;
|
||||
import net.minecraft.text.BaseText;
|
||||
|
||||
public class HUDLogger extends Logger
|
||||
{
|
||||
@@ -20,9 +20,9 @@ public class HUDLogger extends Logger
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendPlayerMessage(PlayerEntity player, BaseComponent... messages)
|
||||
public void sendPlayerMessage(PlayerEntity player, BaseText... messages)
|
||||
{
|
||||
for (BaseComponent m:messages) HUDController.addMessage(player, m);
|
||||
for (BaseText m:messages) HUDController.addMessage(player, m);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ package carpet.logging;
|
||||
|
||||
import carpet.CarpetServer;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.network.chat.BaseComponent;
|
||||
import net.minecraft.text.BaseText;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
@@ -89,7 +89,7 @@ public class Logger
|
||||
* will repeat invocation for players that share the same option
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface lMessage { BaseComponent [] get(String playerOption, PlayerEntity player);}
|
||||
public interface lMessage { BaseText [] get(String playerOption, PlayerEntity player);}
|
||||
public void log(lMessage messagePromise)
|
||||
{
|
||||
for (Map.Entry<String,String> en : subscribedOnlinePlayers.entrySet())
|
||||
@@ -97,7 +97,7 @@ public class Logger
|
||||
PlayerEntity player = playerFromName(en.getKey());
|
||||
if (player != null)
|
||||
{
|
||||
BaseComponent [] messages = messagePromise.get(en.getValue(),player);
|
||||
BaseText [] messages = messagePromise.get(en.getValue(),player);
|
||||
if (messages != null)
|
||||
sendPlayerMessage(player, messages);
|
||||
}
|
||||
@@ -109,10 +109,10 @@ public class Logger
|
||||
* and served the same way to all other players subscribed to the same option
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface lMessageIgnorePlayer { BaseComponent [] get(String playerOption);}
|
||||
public interface lMessageIgnorePlayer { BaseText [] get(String playerOption);}
|
||||
public void log(lMessageIgnorePlayer messagePromise)
|
||||
{
|
||||
Map<String, BaseComponent[]> cannedMessages = new HashMap<>();
|
||||
Map<String, BaseText[]> cannedMessages = new HashMap<>();
|
||||
for (Map.Entry<String,String> en : subscribedOnlinePlayers.entrySet())
|
||||
{
|
||||
PlayerEntity player = playerFromName(en.getKey());
|
||||
@@ -123,7 +123,7 @@ public class Logger
|
||||
{
|
||||
cannedMessages.put(option,messagePromise.get(option));
|
||||
}
|
||||
BaseComponent [] messages = cannedMessages.get(option);
|
||||
BaseText [] messages = cannedMessages.get(option);
|
||||
if (messages != null)
|
||||
sendPlayerMessage(player, messages);
|
||||
}
|
||||
@@ -132,9 +132,9 @@ public class Logger
|
||||
/**
|
||||
* guarantees that message is evaluated once, so independent from the player and chosen option
|
||||
*/
|
||||
public void log(Supplier<BaseComponent[]> messagePromise)
|
||||
public void log(Supplier<BaseText[]> messagePromise)
|
||||
{
|
||||
BaseComponent [] cannedMessages = null;
|
||||
BaseText [] cannedMessages = null;
|
||||
for (Map.Entry<String,String> en : subscribedOnlinePlayers.entrySet())
|
||||
{
|
||||
PlayerEntity player = playerFromName(en.getKey());
|
||||
@@ -146,7 +146,7 @@ public class Logger
|
||||
}
|
||||
}
|
||||
|
||||
public void sendPlayerMessage(PlayerEntity player, BaseComponent ... messages)
|
||||
public void sendPlayerMessage(PlayerEntity player, BaseText ... messages)
|
||||
{
|
||||
Arrays.stream(messages).forEach(player::sendMessage);
|
||||
}
|
||||
|
||||
@@ -7,19 +7,19 @@ import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.damage.DamageSource;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.effect.StatusEffects;
|
||||
import net.minecraft.network.chat.BaseComponent;
|
||||
import net.minecraft.text.BaseText;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class DamageReporter
|
||||
{
|
||||
private static BaseComponent[] verifyAndProduceMessage(String option, PlayerEntity player, Entity from, Entity to, Supplier<BaseComponent> messageFuture)
|
||||
private static BaseText[] verifyAndProduceMessage(String option, PlayerEntity player, Entity from, Entity to, Supplier<BaseText> messageFuture)
|
||||
{
|
||||
if ("all".equalsIgnoreCase(option)
|
||||
|| ("players".equalsIgnoreCase(option) && (from instanceof PlayerEntity || to instanceof PlayerEntity))
|
||||
|| ("me".equalsIgnoreCase(option) && ( (from == player) || ( to == player) ) ))
|
||||
{
|
||||
return new BaseComponent[]{messageFuture.get()};
|
||||
return new BaseText[]{messageFuture.get()};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -2,25 +2,25 @@ package carpet.logging.logHelpers;
|
||||
|
||||
import carpet.logging.LoggerRegistry;
|
||||
import carpet.utils.Messenger;
|
||||
import net.minecraft.network.chat.BaseComponent;
|
||||
import net.minecraft.text.BaseText;
|
||||
|
||||
public class KillLogHelper {
|
||||
|
||||
public static void onSweep(String name, int count)
|
||||
{
|
||||
LoggerRegistry.getLogger("kills").log( () -> new BaseComponent[]{
|
||||
LoggerRegistry.getLogger("kills").log( () -> new BaseText[]{
|
||||
Messenger.c("g "+name+" smacked ","r "+count,"g entities with sweeping")});
|
||||
}
|
||||
|
||||
public static void onNonSweepAttack(String name)
|
||||
{
|
||||
LoggerRegistry.getLogger("kills").log( () -> new BaseComponent[]{
|
||||
LoggerRegistry.getLogger("kills").log( () -> new BaseText[]{
|
||||
Messenger.c("g "+name+" smacked ","r 1","g (no sweeping)")});
|
||||
}
|
||||
|
||||
public static void onDudHit(String name)
|
||||
{
|
||||
LoggerRegistry.getLogger("kills").log( () -> new BaseComponent[]{
|
||||
LoggerRegistry.getLogger("kills").log( () -> new BaseText[]{
|
||||
Messenger.c("g "+name+" dud hot = no one affected")});
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@ package carpet.logging.logHelpers;
|
||||
|
||||
import carpet.logging.LoggerRegistry;
|
||||
import carpet.utils.Messenger;
|
||||
import net.minecraft.network.chat.BaseComponent;
|
||||
import net.minecraft.text.BaseText;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
public class TNTLogHelper
|
||||
@@ -30,12 +30,12 @@ public class TNTLogHelper
|
||||
switch (option)
|
||||
{
|
||||
case "brief":
|
||||
return new BaseComponent[]{Messenger.c(
|
||||
return new BaseText[]{Messenger.c(
|
||||
"l P ",Messenger.dblt("l",primedX,primedY,primedZ),
|
||||
"w ",Messenger.dblt("l", primedAngle.x, primedAngle.y, primedAngle.z),
|
||||
"r E ",Messenger.dblt("r",x, y, z))};
|
||||
case "full":
|
||||
return new BaseComponent[]{Messenger.c(
|
||||
return new BaseText[]{Messenger.c(
|
||||
"l P ",Messenger.dblf("l",primedX,primedY,primedZ),
|
||||
"w ",Messenger.dblf("l", primedAngle.x, primedAngle.y, primedAngle.z),
|
||||
"r E ",Messenger.dblf("r",x, y, z))};
|
||||
|
||||
@@ -4,7 +4,7 @@ import carpet.logging.Logger;
|
||||
import carpet.logging.LoggerRegistry;
|
||||
import carpet.utils.Messenger;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.network.chat.BaseComponent;
|
||||
import net.minecraft.text.BaseText;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -39,7 +39,7 @@ public class TrajectoryLogHelper
|
||||
{
|
||||
if (!doLog) return;
|
||||
logger.log( (option) -> {
|
||||
List<BaseComponent> comp = new ArrayList<>();
|
||||
List<BaseText> comp = new ArrayList<>();
|
||||
switch (option)
|
||||
{
|
||||
case "brief":
|
||||
@@ -72,7 +72,7 @@ public class TrajectoryLogHelper
|
||||
}
|
||||
break;
|
||||
}
|
||||
return comp.toArray(new BaseComponent[0]);
|
||||
return comp.toArray(new BaseText[0]);
|
||||
});
|
||||
doLog = false;
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.damage.DamageSource;
|
||||
import net.minecraft.predicate.entity.EntityPredicates;
|
||||
import net.minecraft.world.GameRules;
|
||||
import net.minecraft.world.World;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@@ -32,7 +33,7 @@ public abstract class LivingEntity_maxCollisionsMixin extends Entity
|
||||
{
|
||||
List<Entity> list_1 = this.world.getEntities((Entity)this, this.getBoundingBox(), EntityPredicates.canBePushedBy(this));
|
||||
if (!list_1.isEmpty()) {
|
||||
int int_1 = this.world.getGameRules().getInteger("maxEntityCramming");
|
||||
int int_1 = this.world.getGameRules().getInteger(GameRules.MAX_ENTITY_CRAMMING);
|
||||
int int_2;
|
||||
if (int_1 > 0 && list_1.size() > int_1 - 1 && this.random.nextInt(4) == 0) {
|
||||
int_2 = 0;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import net.minecraft.client.network.packet.PlayerListHeaderS2CPacket;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.text.Text;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
@@ -9,8 +9,8 @@ import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
public interface PlayerListHeaderS2CPacketMixin
|
||||
{
|
||||
@Accessor("header")
|
||||
void setHeader(Component header);
|
||||
void setHeader(Text header);
|
||||
|
||||
@Accessor("footer")
|
||||
void setFooter(Component footer);
|
||||
void setFooter(Text footer);
|
||||
}
|
||||
@@ -1,16 +1,16 @@
|
||||
package carpet.mixins;
|
||||
import carpet.fakes.PlayerListHudInterface;
|
||||
import net.minecraft.client.gui.hud.PlayerListHud;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.text.Text;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
@Mixin(PlayerListHud.class)
|
||||
public abstract class PlayerListHudMixin implements PlayerListHudInterface
|
||||
{
|
||||
@Shadow private Component footer;
|
||||
@Shadow private Text footer;
|
||||
|
||||
@Shadow private Component header;
|
||||
@Shadow private Text header;
|
||||
|
||||
public boolean hasFooterOrHeader()
|
||||
{
|
||||
|
||||
@@ -3,7 +3,7 @@ package carpet.mixins;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.ClientConnection;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.text.TranslatableText;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.PlayerManager;
|
||||
import net.minecraft.server.network.ServerPlayNetworkHandler;
|
||||
@@ -72,7 +72,7 @@ public abstract class PlayerManagerMixin
|
||||
serverPlayerEntity_3.kill();
|
||||
continue;
|
||||
}
|
||||
serverPlayerEntity_3.networkHandler.disconnect(new TranslatableComponent("multiplayer.disconnect.duplicate_login", new Object[0]));
|
||||
serverPlayerEntity_3.networkHandler.disconnect(new TranslatableText("multiplayer.disconnect.duplicate_login", new Object[0]));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ public abstract class ServerChunkManagerMixin
|
||||
locals = LocalCapture.CAPTURE_FAILHARD,
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/server/world/ThreadedAnvilChunkStorage;entryIterator()Lit/unimi/dsi/fastutil/objects/ObjectBidirectionalIterator;",
|
||||
target = "Lnet/minecraft/server/world/ThreadedAnvilChunkStorage;entryIterator()Ljava/lang/Iterable;",
|
||||
shift = At.Shift.AFTER,
|
||||
ordinal = 0
|
||||
|
||||
@@ -75,6 +75,7 @@ public abstract class ServerChunkManagerMixin
|
||||
}
|
||||
}
|
||||
|
||||
/* problems in 1.14.3 pre 2 with mappings, I think // gnembon
|
||||
@Redirect(method = "tickChunks", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/SpawnHelper;spawnEntitiesInChunk(Lnet/minecraft/entity/EntityCategory;Lnet/minecraft/world/World;Lnet/minecraft/world/chunk/WorldChunk;Lnet/minecraft/util/math/BlockPos;)V"
|
||||
@@ -174,4 +175,7 @@ public abstract class ServerChunkManagerMixin
|
||||
SpawnReporter.local_spawns = null;
|
||||
}
|
||||
|
||||
|
||||
*/
|
||||
|
||||
}
|
||||
@@ -8,7 +8,7 @@ import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.mob.MobEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BoundingBox;
|
||||
import net.minecraft.util.math.Box;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.util.shape.VoxelShapes;
|
||||
import net.minecraft.world.SpawnHelper;
|
||||
@@ -22,13 +22,14 @@ import java.util.Map;
|
||||
@Mixin(SpawnHelper.class)
|
||||
public class SpawnHelperMixin
|
||||
{
|
||||
|
||||
// in World: private static Map<EntityType, Entity> precookedMobs= new HashMap<>();
|
||||
|
||||
@Redirect(method = "spawnEntitiesInChunk", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/World;doesNotCollide(Lnet/minecraft/util/math/BoundingBox;)Z"
|
||||
target = "Lnet/minecraft/world/World;doesNotCollide(Lnet/minecraft/util/math/Box;)Z"
|
||||
))
|
||||
private static boolean doesNotCollide(World world, BoundingBox bb)
|
||||
private static boolean doesNotCollide(World world, Box bb)
|
||||
{
|
||||
//.doesNotCollide is VERY expensive. On the other side - most worlds are not made of trapdoors in
|
||||
// various configurations, but solid and 'passable' blocks, like air, water grass, etc.
|
||||
|
||||
@@ -5,13 +5,14 @@ import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.LightningEntity;
|
||||
import net.minecraft.entity.mob.SkeletonHorseEntity;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.text.TranslatableText;
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
import net.minecraft.server.command.SummonCommand;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.GameRules;
|
||||
import net.minecraft.world.LocalDifficulty;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@@ -35,7 +36,7 @@ public class SummonCommandMixin
|
||||
ServerWorld world = source.getWorld();
|
||||
BlockPos at = new BlockPos(vec3d_1);
|
||||
LocalDifficulty localDifficulty_1 = source.getWorld().getLocalDifficulty(at);
|
||||
boolean boolean_2 = world.getGameRules().getBoolean("doMobSpawning") && world.random.nextDouble() < (double)localDifficulty_1.getLocalDifficulty() * 0.01D;
|
||||
boolean boolean_2 = world.getGameRules().getBoolean(GameRules.DO_MOB_SPAWNING) && world.random.nextDouble() < (double)localDifficulty_1.getLocalDifficulty() * 0.01D;
|
||||
if (boolean_2) {
|
||||
SkeletonHorseEntity skeletonHorseEntity_1 = (SkeletonHorseEntity) EntityType.SKELETON_HORSE.create(world);
|
||||
skeletonHorseEntity_1.setTrapped(true);
|
||||
@@ -44,7 +45,7 @@ public class SummonCommandMixin
|
||||
world.spawnEntity(skeletonHorseEntity_1);
|
||||
}
|
||||
world.addLightning(lightningEntity_1);
|
||||
source.sendFeedback(new TranslatableComponent("commands.summon.success", new Object[]{lightningEntity_1.getDisplayName()}), true);
|
||||
source.sendFeedback(new TranslatableText("commands.summon.success", new Object[]{lightningEntity_1.getDisplayName()}), true);
|
||||
cir.setReturnValue(1);
|
||||
cir.cancel();
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import net.minecraft.client.network.packet.EntitySetHeadYawS2CPacket;
|
||||
import net.minecraft.client.network.packet.PlayerListS2CPacket;
|
||||
import net.minecraft.entity.damage.DamageSource;
|
||||
import net.minecraft.network.NetworkSide;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.text.TranslatableText;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.ServerTask;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
@@ -65,7 +65,7 @@ public class EntityPlayerMPFake extends ServerPlayerEntity
|
||||
public static EntityPlayerMPFake createShadow(MinecraftServer server, ServerPlayerEntity player)
|
||||
{
|
||||
player.getServer().getPlayerManager().remove(player);
|
||||
player.networkHandler.disconnect(new TranslatableComponent("multiplayer.disconnect.duplicate_login"));
|
||||
player.networkHandler.disconnect(new TranslatableText("multiplayer.disconnect.duplicate_login"));
|
||||
ServerWorld worldIn = server.getWorld(player.dimension);
|
||||
ServerPlayerInteractionManager interactionManagerIn = new ServerPlayerInteractionManager(worldIn);
|
||||
GameProfile gameprofile = player.getGameProfile();
|
||||
|
||||
@@ -2,10 +2,10 @@ package carpet.patches;
|
||||
|
||||
import net.minecraft.network.ClientConnection;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.network.ServerPlayNetworkHandler;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
public class NetHandlerPlayServerFake extends ServerPlayNetworkHandler
|
||||
{
|
||||
@@ -20,7 +20,7 @@ public class NetHandlerPlayServerFake extends ServerPlayNetworkHandler
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disconnect(Component message)
|
||||
public void disconnect(Text message)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ import net.minecraft.state.StateFactory;
|
||||
import net.minecraft.predicate.entity.EntityPredicates;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.sound.SoundCategory;
|
||||
import net.minecraft.util.math.BoundingBox;
|
||||
import net.minecraft.util.math.Box;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
@@ -1128,7 +1128,7 @@ public class CarpetExpression
|
||||
NumericValue.asNumber(lv.get(2).evalValue(c)).getDouble(),
|
||||
NumericValue.asNumber(lv.get(3).evalValue(c)).getDouble()
|
||||
);
|
||||
BoundingBox area = new BoundingBox(center).expand(
|
||||
Box area = new Box(center).expand(
|
||||
NumericValue.asNumber(lv.get(4).evalValue(c)).getDouble(),
|
||||
NumericValue.asNumber(lv.get(5).evalValue(c)).getDouble(),
|
||||
NumericValue.asNumber(lv.get(6).evalValue(c)).getDouble()
|
||||
|
||||
@@ -32,7 +32,7 @@ import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.text.LiteralText;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -178,7 +178,7 @@ public class EntityValue extends Value
|
||||
put("width", (e, a) -> new NumericValue(e.getSize(EntityPose.STANDING).width));
|
||||
put("eye_height", (e, a) -> new NumericValue(e.getEyeHeight(EntityPose.STANDING)));
|
||||
put("age", (e, a) -> new NumericValue(e.age));
|
||||
put("item", (e, a) -> (e instanceof ItemEntity)?new StringValue(((ItemEntity) e).getStack().getCustomName().getString()):Value.NULL);
|
||||
put("item", (e, a) -> (e instanceof ItemEntity)?new StringValue(((ItemEntity) e).getStack().getName().getString()):Value.NULL);
|
||||
put("count", (e, a) -> (e instanceof ItemEntity)?new NumericValue(((ItemEntity) e).getStack().getCount()):Value.NULL);
|
||||
// ItemEntity -> despawn timer via ssGetAge
|
||||
put("is_baby", (e, a) -> (e instanceof LivingEntity)?new NumericValue(((LivingEntity) e).isBaby()):Value.NULL);
|
||||
@@ -308,8 +308,8 @@ public class EntityValue extends Value
|
||||
if (tags.size()==0)
|
||||
return Value.NULL;
|
||||
if (tags.size()==1)
|
||||
return new StringValue(tags.get(0).toTextComponent().getString());
|
||||
return ListValue.wrap(tags.stream().map((t) -> new StringValue(t.toTextComponent().getString())).collect(Collectors.toList()));
|
||||
return new StringValue(tags.get(0).toText().getString());
|
||||
return ListValue.wrap(tags.stream().map((t) -> new StringValue(t.toText().getString())).collect(Collectors.toList()));
|
||||
}
|
||||
catch (CommandSyntaxException ignored) { }
|
||||
return new StringValue(res);
|
||||
@@ -483,7 +483,7 @@ public class EntityValue extends Value
|
||||
String name = v.getString();
|
||||
if (name.isEmpty())
|
||||
e.setCustomName(null);
|
||||
e.setCustomName(new TextComponent(v.getString()));
|
||||
e.setCustomName(new LiteralText(v.getString()));
|
||||
});
|
||||
put("dismount", (e, v) -> e.stopRiding() );
|
||||
put("mount", (e, v) -> {
|
||||
|
||||
@@ -15,7 +15,7 @@ import net.minecraft.block.BlockPlacementEnvironment;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.network.chat.BaseComponent;
|
||||
import net.minecraft.text.BaseText;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -149,7 +149,7 @@ public class BlockInfo
|
||||
put(Material.CAKE , "cake" );
|
||||
}};
|
||||
|
||||
public static List<BaseComponent> blockInfo(BlockPos pos, World world)
|
||||
public static List<BaseText> blockInfo(BlockPos pos, World world)
|
||||
{
|
||||
BlockState state = world.getBlockState(pos);
|
||||
Material material = state.getMaterial();
|
||||
@@ -159,7 +159,7 @@ public class BlockInfo
|
||||
{
|
||||
metastring += ", "+iproperty.getName() + '='+state.get(iproperty);
|
||||
}
|
||||
List<BaseComponent> lst = new ArrayList<>();
|
||||
List<BaseText> lst = new ArrayList<>();
|
||||
lst.add(Messenger.s(""));
|
||||
lst.add(Messenger.s("====================================="));
|
||||
lst.add(Messenger.s(String.format("Block info for %s%s (id %d%s):",Registry.BLOCK.getId(block),metastring, Registry.BLOCK.getRawId(block), metastring )));
|
||||
@@ -198,7 +198,7 @@ public class BlockInfo
|
||||
return lst;
|
||||
}
|
||||
|
||||
private static BaseComponent wander_chances(BlockPos pos, World worldIn)
|
||||
private static BaseText wander_chances(BlockPos pos, World worldIn)
|
||||
{
|
||||
MobEntityWithAi creature = new ZombiePigmanEntity(EntityType.ZOMBIE_PIGMAN, worldIn);
|
||||
creature.initialize(worldIn, worldIn.getLocalDifficulty(pos), SpawnType.NATURAL, null, null);
|
||||
|
||||
@@ -3,7 +3,7 @@ package carpet.utils;
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.network.chat.BaseComponent;
|
||||
import net.minecraft.text.BaseText;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@@ -18,7 +18,7 @@ public class DistanceCalculator
|
||||
return START_POINT_STORAGE.containsKey(source.getName());
|
||||
}
|
||||
|
||||
public static List<BaseComponent> findDistanceBetweenTwoPoints(Vec3d pos1, Vec3d pos2)
|
||||
public static List<BaseText> findDistanceBetweenTwoPoints(Vec3d pos1, Vec3d pos2)
|
||||
{
|
||||
double dx = MathHelper.abs((float)pos1.x-(float)pos2.x);
|
||||
double dy = MathHelper.abs((float)pos1.y-(float)pos2.y);
|
||||
@@ -26,7 +26,7 @@ public class DistanceCalculator
|
||||
double manhattan = dx+dy+dz;
|
||||
double spherical = MathHelper.sqrt(dx*dx + dy*dy + dz*dz);
|
||||
double cylindrical = MathHelper.sqrt(dx*dx + dz*dz);
|
||||
List<BaseComponent> res = new ArrayList<>();
|
||||
List<BaseText> res = new ArrayList<>();
|
||||
res.add(Messenger.c("w Distance between ",
|
||||
Messenger.tp("c",pos1),"w and ",
|
||||
Messenger.tp("c",pos2),"w :"));
|
||||
|
||||
@@ -4,7 +4,7 @@ import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.chat.BaseComponent;
|
||||
import net.minecraft.text.BaseText;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -39,7 +39,7 @@ public class EntityInfo
|
||||
{
|
||||
return null;
|
||||
} // func_190916_E()
|
||||
String stackname = item.getCount()>1?String.format("%dx%s",item.getCount(), item.getCustomName().getString()):item.getCustomName().getString();
|
||||
String stackname = item.getCount()>1?String.format("%dx%s",item.getCount(), item.getName().getString()):item.getName().getString();
|
||||
if (item.isDamaged())
|
||||
{
|
||||
stackname += String.format(" %d/%d", item.getMaxUseTime()-item.getDamage(), item.getMaxUseTime());
|
||||
@@ -51,7 +51,7 @@ public class EntityInfo
|
||||
for (Enchantment e: enchants.keySet())
|
||||
{
|
||||
int level = enchants.get(e);
|
||||
String enstring = e.getTextComponent(level).getString();
|
||||
String enstring = e.getName(level).getString();
|
||||
stackname += enstring+" ";
|
||||
}
|
||||
stackname += ")";
|
||||
@@ -92,9 +92,9 @@ public class EntityInfo
|
||||
return 100*(internal-min)/(max-min);
|
||||
}
|
||||
|
||||
public static List<BaseComponent> entityInfo(Entity e, World source_world)
|
||||
public static List<BaseText> entityInfo(Entity e, World source_world)
|
||||
{
|
||||
List<BaseComponent> lst = new ArrayList<>();
|
||||
List<BaseText> lst = new ArrayList<>();
|
||||
lst.add(Messenger.s("w Use /data get entity command"));
|
||||
return lst;
|
||||
}
|
||||
|
||||
@@ -12,8 +12,8 @@ import net.minecraft.client.network.packet.PlayerListHeaderS2CPacket;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.Pair;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.network.chat.BaseComponent;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.text.BaseText;
|
||||
import net.minecraft.text.LiteralText;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -25,9 +25,9 @@ import java.util.Map;
|
||||
|
||||
public class HUDController
|
||||
{
|
||||
public static Map<PlayerEntity, List<BaseComponent>> player_huds = new HashMap<>();
|
||||
public static Map<PlayerEntity, List<BaseText>> player_huds = new HashMap<>();
|
||||
|
||||
public static void addMessage(PlayerEntity player, BaseComponent hudMessage)
|
||||
public static void addMessage(PlayerEntity player, BaseText hudMessage)
|
||||
{
|
||||
if (!player_huds.containsKey(player))
|
||||
{
|
||||
@@ -35,15 +35,15 @@ public class HUDController
|
||||
}
|
||||
else
|
||||
{
|
||||
player_huds.get(player).add(new TextComponent("\n"));
|
||||
player_huds.get(player).add(new LiteralText("\n"));
|
||||
}
|
||||
player_huds.get(player).add(hudMessage);
|
||||
}
|
||||
public static void clear_player(PlayerEntity player)
|
||||
{
|
||||
PlayerListHeaderS2CPacket packet = new PlayerListHeaderS2CPacket();
|
||||
((PlayerListHeaderS2CPacketMixin)packet).setHeader(new TextComponent(""));
|
||||
((PlayerListHeaderS2CPacketMixin)packet).setFooter(new TextComponent(""));
|
||||
((PlayerListHeaderS2CPacketMixin)packet).setHeader(new LiteralText(""));
|
||||
((PlayerListHeaderS2CPacketMixin)packet).setFooter(new LiteralText(""));
|
||||
((ServerPlayerEntity)player).networkHandler.sendPacket(packet);
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ public class HUDController
|
||||
dim = DimensionType.THE_END;
|
||||
break;
|
||||
}
|
||||
return new BaseComponent[]{SpawnReporter.printMobcapsForDimension(dim, false).get(0)};
|
||||
return new BaseText[]{SpawnReporter.printMobcapsForDimension(dim, false).get(0)};
|
||||
});
|
||||
|
||||
if(LoggerRegistry.__counter)
|
||||
@@ -85,30 +85,30 @@ public class HUDController
|
||||
for (PlayerEntity player: player_huds.keySet())
|
||||
{
|
||||
PlayerListHeaderS2CPacket packet = new PlayerListHeaderS2CPacket();
|
||||
((PlayerListHeaderS2CPacketMixin)packet).setHeader(new TextComponent(""));
|
||||
((PlayerListHeaderS2CPacketMixin)packet).setHeader(new LiteralText(""));
|
||||
((PlayerListHeaderS2CPacketMixin)packet).setFooter(Messenger.c(player_huds.get(player).toArray(new Object[0])));
|
||||
((ServerPlayerEntity)player).networkHandler.sendPacket(packet);
|
||||
}
|
||||
}
|
||||
private static BaseComponent [] send_tps_display(MinecraftServer server)
|
||||
private static BaseText [] send_tps_display(MinecraftServer server)
|
||||
{
|
||||
double MSPT = MathHelper.average(server.lastTickLengths) * 1.0E-6D;
|
||||
double TPS = 1000.0D / Math.max((TickSpeed.time_warp_start_time != 0)?0.0:TickSpeed.mspt, MSPT);
|
||||
String color = Messenger.heatmap_color(MSPT,TickSpeed.mspt);
|
||||
return new BaseComponent[]{Messenger.c(
|
||||
return new BaseText[]{Messenger.c(
|
||||
"g TPS: ", String.format(Locale.US, "%s %.1f",color, TPS),
|
||||
"g MSPT: ", String.format(Locale.US,"%s %.1f", color, MSPT))};
|
||||
}
|
||||
|
||||
private static BaseComponent [] send_counter_info(MinecraftServer server, String color)
|
||||
private static BaseText [] send_counter_info(MinecraftServer server, String color)
|
||||
{
|
||||
HopperCounter counter = HopperCounter.getCounter(color);
|
||||
List <BaseComponent> res = counter == null ? Collections.emptyList() : counter.format(server, false, true);
|
||||
return new BaseComponent[]{ Messenger.c(res.toArray(new Object[0]))};
|
||||
List <BaseText> res = counter == null ? Collections.emptyList() : counter.format(server, false, true);
|
||||
return new BaseText[]{ Messenger.c(res.toArray(new Object[0]))};
|
||||
}
|
||||
private static BaseComponent [] packetCounter()
|
||||
private static BaseText [] packetCounter()
|
||||
{
|
||||
BaseComponent [] ret = new BaseComponent[]{
|
||||
BaseText [] ret = new BaseText[]{
|
||||
Messenger.c("w I/" + PacketCounter.totalIn + " O/" + PacketCounter.totalOut),
|
||||
};
|
||||
PacketCounter.reset();
|
||||
|
||||
@@ -5,12 +5,12 @@ import net.minecraft.entity.EntityCategory;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.ChatFormat;
|
||||
import net.minecraft.network.chat.BaseComponent;
|
||||
import net.minecraft.text.LiteralText;
|
||||
import net.minecraft.util.Formatting;
|
||||
import net.minecraft.text.BaseText;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.network.chat.ClickEvent;
|
||||
import net.minecraft.network.chat.HoverEvent;
|
||||
import net.minecraft.text.ClickEvent;
|
||||
import net.minecraft.text.HoverEvent;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
@@ -51,7 +51,7 @@ public class Messenger
|
||||
/ = action added to the previous component
|
||||
*/
|
||||
|
||||
private static BaseComponent _applyStyleToTextComponent(BaseComponent comp, String style)
|
||||
private static BaseText _applyStyleToTextComponent(BaseText comp, String style)
|
||||
{
|
||||
//could be rewritten to be more efficient
|
||||
comp.getStyle().setItalic(style.indexOf('i')>=0);
|
||||
@@ -59,23 +59,23 @@ public class Messenger
|
||||
comp.getStyle().setUnderline(style.indexOf('u')>=0);
|
||||
comp.getStyle().setBold(style.indexOf('b')>=0);
|
||||
comp.getStyle().setObfuscated(style.indexOf('o')>=0);
|
||||
comp.getStyle().setColor(ChatFormat.WHITE);
|
||||
if (style.indexOf('w')>=0) comp.getStyle().setColor(ChatFormat.WHITE); // not needed
|
||||
if (style.indexOf('y')>=0) comp.getStyle().setColor(ChatFormat.YELLOW);
|
||||
if (style.indexOf('m')>=0) comp.getStyle().setColor(ChatFormat.LIGHT_PURPLE);
|
||||
if (style.indexOf('r')>=0) comp.getStyle().setColor(ChatFormat.RED);
|
||||
if (style.indexOf('c')>=0) comp.getStyle().setColor(ChatFormat.AQUA);
|
||||
if (style.indexOf('l')>=0) comp.getStyle().setColor(ChatFormat.GREEN);
|
||||
if (style.indexOf('t')>=0) comp.getStyle().setColor(ChatFormat.BLUE);
|
||||
if (style.indexOf('f')>=0) comp.getStyle().setColor(ChatFormat.DARK_GRAY);
|
||||
if (style.indexOf('g')>=0) comp.getStyle().setColor(ChatFormat.GRAY);
|
||||
if (style.indexOf('d')>=0) comp.getStyle().setColor(ChatFormat.GOLD);
|
||||
if (style.indexOf('p')>=0) comp.getStyle().setColor(ChatFormat.DARK_PURPLE);
|
||||
if (style.indexOf('n')>=0) comp.getStyle().setColor(ChatFormat.DARK_RED);
|
||||
if (style.indexOf('q')>=0) comp.getStyle().setColor(ChatFormat.DARK_AQUA);
|
||||
if (style.indexOf('e')>=0) comp.getStyle().setColor(ChatFormat.DARK_GREEN);
|
||||
if (style.indexOf('v')>=0) comp.getStyle().setColor(ChatFormat.DARK_BLUE);
|
||||
if (style.indexOf('k')>=0) comp.getStyle().setColor(ChatFormat.BLACK);
|
||||
comp.getStyle().setColor(Formatting.WHITE);
|
||||
if (style.indexOf('w')>=0) comp.getStyle().setColor(Formatting.WHITE); // not needed
|
||||
if (style.indexOf('y')>=0) comp.getStyle().setColor(Formatting.YELLOW);
|
||||
if (style.indexOf('m')>=0) comp.getStyle().setColor(Formatting.LIGHT_PURPLE);
|
||||
if (style.indexOf('r')>=0) comp.getStyle().setColor(Formatting.RED);
|
||||
if (style.indexOf('c')>=0) comp.getStyle().setColor(Formatting.AQUA);
|
||||
if (style.indexOf('l')>=0) comp.getStyle().setColor(Formatting.GREEN);
|
||||
if (style.indexOf('t')>=0) comp.getStyle().setColor(Formatting.BLUE);
|
||||
if (style.indexOf('f')>=0) comp.getStyle().setColor(Formatting.DARK_GRAY);
|
||||
if (style.indexOf('g')>=0) comp.getStyle().setColor(Formatting.GRAY);
|
||||
if (style.indexOf('d')>=0) comp.getStyle().setColor(Formatting.GOLD);
|
||||
if (style.indexOf('p')>=0) comp.getStyle().setColor(Formatting.DARK_PURPLE);
|
||||
if (style.indexOf('n')>=0) comp.getStyle().setColor(Formatting.DARK_RED);
|
||||
if (style.indexOf('q')>=0) comp.getStyle().setColor(Formatting.DARK_AQUA);
|
||||
if (style.indexOf('e')>=0) comp.getStyle().setColor(Formatting.DARK_GREEN);
|
||||
if (style.indexOf('v')>=0) comp.getStyle().setColor(Formatting.DARK_BLUE);
|
||||
if (style.indexOf('k')>=0) comp.getStyle().setColor(Formatting.BLACK);
|
||||
return comp;
|
||||
}
|
||||
public static String heatmap_color(double actual, double reference)
|
||||
@@ -103,11 +103,11 @@ public class Messenger
|
||||
return "w";
|
||||
}
|
||||
|
||||
private static BaseComponent _getChatComponentFromDesc(String message, BaseComponent previous_message)
|
||||
private static BaseText _getChatComponentFromDesc(String message, BaseText previous_message)
|
||||
{
|
||||
if (message.equalsIgnoreCase(""))
|
||||
{
|
||||
return new TextComponent("");
|
||||
return new LiteralText("");
|
||||
}
|
||||
String parts[] = message.split("\\s", 2);
|
||||
String desc = parts[0];
|
||||
@@ -137,27 +137,27 @@ public class Messenger
|
||||
previous_message.getStyle().setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, c(message.substring(1))));
|
||||
return previous_message;
|
||||
}
|
||||
BaseComponent txt = new TextComponent(str);
|
||||
BaseText txt = new LiteralText(str);
|
||||
return _applyStyleToTextComponent(txt, desc);
|
||||
}
|
||||
public static BaseComponent tp(String desc, Vec3d pos) { return tp(desc, pos.x, pos.y, pos.z); }
|
||||
public static BaseComponent tp(String desc, BlockPos pos) { return tp(desc, pos.getX(), pos.getY(), pos.getZ()); }
|
||||
public static BaseComponent tp(String desc, double x, double y, double z) { return tp(desc, (float)x, (float)y, (float)z);}
|
||||
public static BaseComponent tp(String desc, float x, float y, float z)
|
||||
public static BaseText tp(String desc, Vec3d pos) { return tp(desc, pos.x, pos.y, pos.z); }
|
||||
public static BaseText tp(String desc, BlockPos pos) { return tp(desc, pos.getX(), pos.getY(), pos.getZ()); }
|
||||
public static BaseText tp(String desc, double x, double y, double z) { return tp(desc, (float)x, (float)y, (float)z);}
|
||||
public static BaseText tp(String desc, float x, float y, float z)
|
||||
{
|
||||
return _getCoordsTextComponent(desc, x, y, z, false);
|
||||
}
|
||||
public static BaseComponent tp(String desc, int x, int y, int z)
|
||||
public static BaseText tp(String desc, int x, int y, int z)
|
||||
{
|
||||
return _getCoordsTextComponent(desc, (float)x, (float)y, (float)z, true);
|
||||
}
|
||||
|
||||
/// to be continued
|
||||
public static BaseComponent dbl(String style, double double_value)
|
||||
public static BaseText dbl(String style, double double_value)
|
||||
{
|
||||
return c(String.format("%s %.1f",style,double_value),String.format("^w %f",double_value));
|
||||
}
|
||||
public static BaseComponent dbls(String style, double ... doubles)
|
||||
public static BaseText dbls(String style, double ... doubles)
|
||||
{
|
||||
StringBuilder str = new StringBuilder(style + " [ ");
|
||||
String prefix = "";
|
||||
@@ -169,7 +169,7 @@ public class Messenger
|
||||
str.append(" ]");
|
||||
return c(str.toString());
|
||||
}
|
||||
public static BaseComponent dblf(String style, double ... doubles)
|
||||
public static BaseText dblf(String style, double ... doubles)
|
||||
{
|
||||
StringBuilder str = new StringBuilder(style + " [ ");
|
||||
String prefix = "";
|
||||
@@ -181,7 +181,7 @@ public class Messenger
|
||||
str.append(" ]");
|
||||
return c(str.toString());
|
||||
}
|
||||
public static BaseComponent dblt(String style, double ... doubles)
|
||||
public static BaseText dblt(String style, double ... doubles)
|
||||
{
|
||||
List<Object> components = new ArrayList<>();
|
||||
components.add(style+" [ ");
|
||||
@@ -199,7 +199,7 @@ public class Messenger
|
||||
return c(components.toArray(new Object[0]));
|
||||
}
|
||||
|
||||
private static BaseComponent _getCoordsTextComponent(String style, float x, float y, float z, boolean isInt)
|
||||
private static BaseText _getCoordsTextComponent(String style, float x, float y, float z, boolean isInt)
|
||||
{
|
||||
String text;
|
||||
String command;
|
||||
@@ -229,20 +229,20 @@ public class Messenger
|
||||
/*
|
||||
composes single line, multicomponent message, and returns as one chat messagge
|
||||
*/
|
||||
public static BaseComponent c(Object ... fields)
|
||||
public static BaseText c(Object ... fields)
|
||||
{
|
||||
BaseComponent message = new TextComponent("");
|
||||
BaseComponent previous_component = null;
|
||||
BaseText message = new LiteralText("");
|
||||
BaseText previous_component = null;
|
||||
for (Object o: fields)
|
||||
{
|
||||
if (o instanceof BaseComponent)
|
||||
if (o instanceof BaseText)
|
||||
{
|
||||
message.append((BaseComponent)o);
|
||||
previous_component = (BaseComponent)o;
|
||||
message.append((BaseText)o);
|
||||
previous_component = (BaseText)o;
|
||||
continue;
|
||||
}
|
||||
String txt = o.toString();
|
||||
BaseComponent comp = _getChatComponentFromDesc(txt,previous_component);
|
||||
BaseText comp = _getChatComponentFromDesc(txt,previous_component);
|
||||
if (comp != previous_component) message.append(comp);
|
||||
previous_component = comp;
|
||||
}
|
||||
@@ -251,13 +251,13 @@ public class Messenger
|
||||
|
||||
//simple text
|
||||
|
||||
public static BaseComponent s(String text)
|
||||
public static BaseText s(String text)
|
||||
{
|
||||
return s(text,"");
|
||||
}
|
||||
public static BaseComponent s(String text, String style)
|
||||
public static BaseText s(String text, String style)
|
||||
{
|
||||
BaseComponent message = new TextComponent(text);
|
||||
BaseText message = new LiteralText(text);
|
||||
_applyStyleToTextComponent(message, style);
|
||||
return message;
|
||||
}
|
||||
@@ -265,11 +265,11 @@ public class Messenger
|
||||
|
||||
|
||||
|
||||
public static void send(PlayerEntity player, Collection<BaseComponent> lines)
|
||||
public static void send(PlayerEntity player, Collection<BaseText> lines)
|
||||
{
|
||||
lines.forEach(player::sendMessage);
|
||||
}
|
||||
public static void send(ServerCommandSource source, Collection<BaseComponent> lines)
|
||||
public static void send(ServerCommandSource source, Collection<BaseText> lines)
|
||||
{
|
||||
lines.stream().forEachOrdered((s) -> source.sendFeedback(s, false));
|
||||
}
|
||||
@@ -279,14 +279,14 @@ public class Messenger
|
||||
{
|
||||
if (server == null)
|
||||
LOG.error("Message not delivered: "+message);
|
||||
server.sendMessage(new TextComponent(message));
|
||||
BaseComponent txt = c("gi "+message);
|
||||
server.sendMessage(new LiteralText(message));
|
||||
BaseText txt = c("gi "+message);
|
||||
for (PlayerEntity entityplayer : server.getPlayerManager().getPlayerList())
|
||||
{
|
||||
entityplayer.sendMessage(txt);
|
||||
}
|
||||
}
|
||||
public static void print_server_message(MinecraftServer server, BaseComponent message)
|
||||
public static void print_server_message(MinecraftServer server, BaseText message)
|
||||
{
|
||||
if (server == null)
|
||||
LOG.error("Message not delivered: "+message.getString());
|
||||
|
||||
@@ -14,7 +14,7 @@ import net.minecraft.entity.SpawnRestriction;
|
||||
import net.minecraft.entity.SpawnType;
|
||||
import net.minecraft.entity.mob.MobEntity;
|
||||
import net.minecraft.entity.passive.OcelotEntity;
|
||||
import net.minecraft.network.chat.BaseComponent;
|
||||
import net.minecraft.text.BaseText;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.util.DyeColor;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@@ -84,10 +84,10 @@ public class SpawnReporter
|
||||
}
|
||||
|
||||
|
||||
public static List<BaseComponent> printMobcapsForDimension(DimensionType dim, boolean multiline)
|
||||
public static List<BaseText> printMobcapsForDimension(DimensionType dim, boolean multiline)
|
||||
{
|
||||
String name = dim.toString();
|
||||
List<BaseComponent> lst = new ArrayList<>();
|
||||
List<BaseText> lst = new ArrayList<>();
|
||||
if (multiline)
|
||||
lst.add(Messenger.s(String.format("Mobcaps for %s:",name)));
|
||||
Object2IntMap<EntityCategory> dimCounts = mobCounts.get(dim);
|
||||
@@ -137,9 +137,9 @@ public class SpawnReporter
|
||||
return lst;
|
||||
}
|
||||
|
||||
public static List<BaseComponent> recent_spawns(World world, EntityCategory creature_type)
|
||||
public static List<BaseText> recent_spawns(World world, EntityCategory creature_type)
|
||||
{
|
||||
List<BaseComponent> lst = new ArrayList<>();
|
||||
List<BaseText> lst = new ArrayList<>();
|
||||
if ((track_spawns == 0L))
|
||||
{
|
||||
lst.add(Messenger.s("Spawn tracking not started"));
|
||||
@@ -165,7 +165,7 @@ public class SpawnReporter
|
||||
|
||||
}
|
||||
|
||||
public static List<BaseComponent> show_mobcaps(BlockPos pos, World worldIn)
|
||||
public static List<BaseText> show_mobcaps(BlockPos pos, World worldIn)
|
||||
{
|
||||
DyeColor under = WoolTool.getWoolColorAtPosition(worldIn, pos.down());
|
||||
if (under == null)
|
||||
@@ -254,9 +254,9 @@ public class SpawnReporter
|
||||
return get_type_string(get_creature_type_from_code(str));
|
||||
}
|
||||
|
||||
public static List<BaseComponent> printEntitiesByType(EntityCategory cat, World worldIn) //Class<?> entityType)
|
||||
public static List<BaseText> printEntitiesByType(EntityCategory cat, World worldIn) //Class<?> entityType)
|
||||
{
|
||||
List<BaseComponent> lst = new ArrayList<>();
|
||||
List<BaseText> lst = new ArrayList<>();
|
||||
lst.add( Messenger.s(String.format("Loaded entities for %s class:", get_type_string(cat))));
|
||||
for (Entity entity : ((ServerWorld)worldIn).getEntities(null, (e) -> e.getType().getCategory()==cat))
|
||||
{
|
||||
@@ -318,10 +318,10 @@ public class SpawnReporter
|
||||
track_spawns = 0L;
|
||||
}
|
||||
|
||||
public static List<BaseComponent> tracking_report(World worldIn)
|
||||
public static List<BaseText> tracking_report(World worldIn)
|
||||
{
|
||||
|
||||
List<BaseComponent> report = new ArrayList<>();
|
||||
List<BaseText> report = new ArrayList<>();
|
||||
if (track_spawns == 0L)
|
||||
{
|
||||
report.add(Messenger.c(
|
||||
@@ -395,9 +395,9 @@ public class SpawnReporter
|
||||
entity.remove();
|
||||
}
|
||||
|
||||
public static List<BaseComponent> report(BlockPos pos, World worldIn)
|
||||
public static List<BaseText> report(BlockPos pos, World worldIn)
|
||||
{
|
||||
List<BaseComponent> rep = new ArrayList<>();
|
||||
List<BaseText> rep = new ArrayList<>();
|
||||
int x = pos.getX(); int y = pos.getY(); int z = pos.getZ();
|
||||
Chunk chunk = worldIn.getChunk(pos);
|
||||
int lc = chunk.sampleHeightmap(Heightmap.Type.WORLD_SURFACE, x, z) + 1;
|
||||
|
||||
@@ -10,7 +10,7 @@ import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.util.DyeColor;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.network.chat.BaseComponent;
|
||||
import net.minecraft.text.BaseText;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -84,7 +84,7 @@ public class WoolTool
|
||||
HopperCounter counter = HopperCounter.getCounter(under.toString());
|
||||
if (counter == null) return;
|
||||
counter.reset(placer.getServer());
|
||||
List<BaseComponent> res = new ArrayList<>();
|
||||
List<BaseText> res = new ArrayList<>();
|
||||
res.add(Messenger.s(String.format("%s counter reset",under.toString())));
|
||||
Messenger.send(placer, res);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user