Complete removal of /info entity, it's correspondent carpet and two small changes (#1047)
* Remove no longer needed language packet mixin * Make StringArgument properly return a StringArgument supplier, so `string` isn't `term` Fixes gnembon/fabric-carpet#1044 * Complete removal of `/info entity` and it's correspondent carpet Resolves gnembon/fabric-carpet#1033 * Remove yet another no longer needed mixin
This commit is contained in:
1 parent
4d9c5eb391
commit
d8c10c6e4a
9 files changed
+10
-231
No files matched your search
@@ -3,19 +3,14 @@ package carpet.commands;
|
||||
import carpet.CarpetSettings;
|
||||
import carpet.settings.SettingsManager;
|
||||
import carpet.utils.BlockInfo;
|
||||
import carpet.utils.EntityInfo;
|
||||
import carpet.utils.Messenger;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import net.minecraft.text.BaseText;
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
import net.minecraft.command.argument.BlockPosArgumentType;
|
||||
import net.minecraft.command.argument.EntityArgumentType;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
@@ -41,52 +36,11 @@ public class InfoCommand
|
||||
executes( (c) -> infoBlock(
|
||||
c.getSource(),
|
||||
BlockPosArgumentType.getBlockPos(c, "block position"),
|
||||
getString(c, "regexp"))))))).
|
||||
then(literal("entity").
|
||||
then(argument("entity selector", EntityArgumentType.entities()).
|
||||
executes( (c) -> infoEntities(
|
||||
c.getSource(), EntityArgumentType.getEntities(c,"entity selector"), null)).
|
||||
then(literal("grep").
|
||||
then(argument("regexp",greedyString()).
|
||||
executes( (c) -> infoEntities(
|
||||
c.getSource(),
|
||||
EntityArgumentType.getEntities(c,"entity selector"),
|
||||
getString(c, "regexp")))))));
|
||||
|
||||
dispatcher.register(command);
|
||||
}
|
||||
|
||||
public static void printEntity(List<BaseText> messages, ServerCommandSource source, String grep)
|
||||
{
|
||||
List<BaseText> actual = new ArrayList<>();
|
||||
if (grep != null)
|
||||
{
|
||||
Pattern p = Pattern.compile(grep);
|
||||
actual.add(messages.get(0));
|
||||
boolean empty = true;
|
||||
for (int i = 1; i<messages.size(); i++)
|
||||
{
|
||||
BaseText line = messages.get(i);
|
||||
Matcher m = p.matcher(line.getString());
|
||||
if (m.find())
|
||||
{
|
||||
empty = false;
|
||||
actual.add(line);
|
||||
}
|
||||
}
|
||||
if (empty)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
actual = messages;
|
||||
}
|
||||
Messenger.m(source, "");
|
||||
Messenger.send(source, actual);
|
||||
}
|
||||
|
||||
public static void printBlock(List<BaseText> messages, ServerCommandSource source, String grep)
|
||||
{
|
||||
Messenger.m(source, "");
|
||||
@@ -110,17 +64,6 @@ public class InfoCommand
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static int infoEntities(ServerCommandSource source, Collection<? extends Entity> entities, String grep)
|
||||
{
|
||||
for (Entity e: entities)
|
||||
{
|
||||
List<BaseText> report = EntityInfo.entityInfo(e, source.getWorld());
|
||||
printEntity(report, source, grep);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
private static int infoBlock(ServerCommandSource source, BlockPos pos, String grep)
|
||||
{
|
||||
printBlock(BlockInfo.blockInfo(pos, source.getWorld()),source, grep);
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
package carpet.fakes;
|
||||
|
||||
public interface ClientSettingsC2SPacketInterface {
|
||||
public String getLanguage();
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.fakes.ClientSettingsC2SPacketInterface;
|
||||
import net.minecraft.network.packet.c2s.play.ClientSettingsC2SPacket;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
@Mixin(ClientSettingsC2SPacket.class)
|
||||
public class ClientSettingsC2SPacket_scarpetMixin implements ClientSettingsC2SPacketInterface {
|
||||
@Shadow
|
||||
private String language;
|
||||
|
||||
@Override
|
||||
public String getLanguage(){
|
||||
return this.language;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.fakes.ClientSettingsC2SPacketInterface;
|
||||
import carpet.fakes.EntityInterface;
|
||||
import carpet.fakes.ServerPlayerEntityInterface;
|
||||
import carpet.script.EntityEventsGroup;
|
||||
@@ -19,6 +18,7 @@ import net.minecraft.util.registry.RegistryKey;
|
||||
import net.minecraft.world.World;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
@@ -35,6 +35,7 @@ public abstract class ServerPlayerEntity_scarpetEventMixin extends PlayerEntity
|
||||
{
|
||||
// to denote if the player reference is valid
|
||||
|
||||
@Unique
|
||||
private boolean isInvalidReference = false;
|
||||
|
||||
public ServerPlayerEntity_scarpetEventMixin(World world, BlockPos blockPos, float f, GameProfile gameProfile)
|
||||
@@ -130,14 +131,18 @@ public abstract class ServerPlayerEntity_scarpetEventMixin extends PlayerEntity
|
||||
}
|
||||
|
||||
//getting player language
|
||||
@Unique
|
||||
private String language;
|
||||
|
||||
public String getLanguage(){
|
||||
@Override
|
||||
public String getLanguage()
|
||||
{
|
||||
return this.language;
|
||||
}
|
||||
|
||||
@Inject(method = "setClientSettings", at = @At("HEAD"))
|
||||
public void setClientSettings(ClientSettingsC2SPacket packet, CallbackInfo ci){
|
||||
this.language = ((ClientSettingsC2SPacketInterface) packet).getLanguage();
|
||||
public void setLanguage(ClientSettingsC2SPacket packet, CallbackInfo ci)
|
||||
{
|
||||
this.language = packet.getLanguage();
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.patches.EntityPlayerMPFake;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.ServerTask;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@Mixin(ServerWorld.class)
|
||||
public abstract class ServerWorld_fakePlayersMixin
|
||||
{
|
||||
|
||||
@Shadow /*@Nonnull*/ public abstract MinecraftServer getServer();
|
||||
/*
|
||||
@Shadow private boolean inEntityTick;
|
||||
|
||||
@Redirect( method = "removePlayer", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/server/world/ServerWorld;removeEntity(Lnet/minecraft/entity/Entity;)V"
|
||||
))
|
||||
private void crashRemovePlayer(ServerWorld serverWorld, Entity entity_1, ServerPlayerEntity serverPlayerEntity_1)
|
||||
{
|
||||
if ( !(serverPlayerEntity_1 instanceof EntityPlayerMPFake) )
|
||||
serverWorld.removeEntity(entity_1);
|
||||
else
|
||||
getServer().send(new ServerTask(getServer().getTicks(), () ->
|
||||
{
|
||||
serverWorld.removeEntity(serverPlayerEntity_1);
|
||||
serverPlayerEntity_1.onTeleportationDone();
|
||||
}));
|
||||
|
||||
}*/
|
||||
}
|
||||
@@ -469,7 +469,7 @@ public abstract class CommandArgument
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Supplier<CommandArgument> factory() { return WordArgument::new; }
|
||||
protected Supplier<CommandArgument> factory() { return StringArgument::new; }
|
||||
}
|
||||
|
||||
private static class WordArgument extends StringArgument
|
||||
|
||||
@@ -1,101 +0,0 @@
|
||||
package carpet.utils;
|
||||
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.text.BaseText;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
// not really needed anymore
|
||||
public class EntityInfo
|
||||
{
|
||||
private static String makeTime(long ticks)
|
||||
{
|
||||
long secs = ticks/20;
|
||||
if (secs < 60)
|
||||
{
|
||||
return String.format("%d\"", secs);
|
||||
}
|
||||
if (secs < 60*60)
|
||||
{
|
||||
return String.format("%d'%d\"", secs/60, secs%60);
|
||||
}
|
||||
|
||||
return String.format("%dh%d'%d\"", secs/60/60, (secs % (60*60))/60,(secs % (60*60))%60 );
|
||||
}
|
||||
|
||||
private static String display_item(ItemStack item)
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (item.isEmpty()) // func_190926_b()
|
||||
{
|
||||
return null;
|
||||
} // func_190916_E()
|
||||
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());
|
||||
}
|
||||
if (item.hasEnchantments())
|
||||
{
|
||||
stackname += " ( ";
|
||||
Map<Enchantment, Integer> enchants = EnchantmentHelper.get(item);
|
||||
for (Enchantment e: enchants.keySet())
|
||||
{
|
||||
int level = enchants.get(e);
|
||||
String enstring = e.getName(level).getString();
|
||||
stackname += enstring+" ";
|
||||
}
|
||||
stackname += ")";
|
||||
}
|
||||
return stackname;
|
||||
}
|
||||
|
||||
public static String entity_short_string(Entity e)
|
||||
{
|
||||
if (e == null)
|
||||
{
|
||||
return "None";
|
||||
}
|
||||
return String.format("%s at [%.1f, %.1f, %.1f]",e.getDisplayName().getString(), e.getX(), e.getY(), e.getZ());
|
||||
}
|
||||
|
||||
private static double get_speed(double internal)
|
||||
{
|
||||
return 43.1*internal;
|
||||
}
|
||||
|
||||
private static double get_horse_speed_percent(double internal)
|
||||
{
|
||||
double min = 0.45*0.25;
|
||||
double max = (0.45+0.9)*0.25;
|
||||
return 100*(internal-min)/(max-min);
|
||||
}
|
||||
|
||||
private static double get_horse_jump(double x)
|
||||
{
|
||||
return -0.1817584952 * x*x*x + 3.689713992 * x*x + 2.128599134 * x - 0.343930367;
|
||||
}
|
||||
|
||||
private static double get_horse_jump_percent(double internal)
|
||||
{
|
||||
double min = 0.4;
|
||||
double max = 1.0;
|
||||
return 100*(internal-min)/(max-min);
|
||||
}
|
||||
|
||||
public static List<BaseText> entityInfo(Entity e, World source_world)
|
||||
{
|
||||
List<BaseText> lst = new ArrayList<>();
|
||||
lst.add(Messenger.c("r Use /data get entity command"));
|
||||
return lst;
|
||||
}
|
||||
}
|
||||
@@ -100,11 +100,6 @@ public class WoolTool
|
||||
case GRAY:
|
||||
if (!"false".equals(CarpetSettings.commandInfo))
|
||||
Messenger.send(placer, BlockInfo.blockInfo(pos.down(), worldIn));
|
||||
break;
|
||||
case YELLOW:
|
||||
if (!"false".equals(CarpetSettings.commandInfo))
|
||||
Messenger.m(placer, "r This used to show entity info around the player. Use data get entity command, sorry");
|
||||
//EntityInfo.issue_entity_info(placer);
|
||||
break;
|
||||
case GREEN:
|
||||
if (CarpetSettings.hopperCounters)
|
||||
|
||||
@@ -70,7 +70,6 @@
|
||||
"Memory_scarpetMixin",
|
||||
|
||||
"PlayerEntity_fakePlayersMixin",
|
||||
"ServerWorld_fakePlayersMixin",
|
||||
"ThrownEnderpearlEntity_fakePlayersMixin",
|
||||
|
||||
"ServerPlayNetworkHandler_coreMixin",
|
||||
@@ -81,7 +80,6 @@
|
||||
"ExperienceOrbEntityMixin",
|
||||
"PlayerActionC2SPacketMixin",
|
||||
"ServerPlayerEntityMixin",
|
||||
"ClientSettingsC2SPacket_scarpetMixin",
|
||||
"PlayerManager_coreMixin",
|
||||
"PlayerManager_fakePlayersMixin",
|
||||
"RedstoneWireBlockMixin",
|
||||
|
||||
Reference in new issue
Block a user