Skip to content

Commit 841fd44

Browse files
committed
feat: bugfix
1 parent b679615 commit 841fd44

File tree

14 files changed

+112
-73
lines changed

14 files changed

+112
-73
lines changed

logs/latest.log

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
[21:00:10] [Test worker/INFO]: check 1
2-
[21:00:10] [Test worker/INFO]: running ItemStack tests 2
3-
[21:00:10] [Test worker/INFO]: item:
1+
[23:33:07] [Test worker/INFO]: check 1
2+
[23:33:07] [Test worker/INFO]: running ItemStack tests 2
3+
[23:33:07] [Test worker/INFO]: item:
44
==: org.bukkit.inventory.ItemStack
55
v: 3465
66
type: DIRT
@@ -9,10 +9,10 @@
99
meta-type: UNSPECIFIC
1010
PublicBukkitValues:
1111
infinityexpansion:display: 351372703i
12-
13-
[21:00:12] [Test worker/INFO]: Could not call method 'public static me.matl114.bukkitUtiils.BukkitMetaItem me.matl114.bukkitUtiils.BukkitMetaItem.deserialize(java.util.Map) throws java.lang.Throwable' of class me.matl114.bukkitUtiils.BukkitMetaItem for deserialization java.lang.ExceptionInInitializerError
14-
[21:00:12] [Test worker/INFO]: Could not call method 'public static me.matl114.bukkitUtiils.BukkitItemStack me.matl114.bukkitUtiils.BukkitItemStack.deserialize(java.util.Map)' of class me.matl114.bukkitUtiils.BukkitItemStack for deserialization java.lang.NoClassDefFoundError: Could not initialize class net.minecraft.item.Items
15-
[21:00:12] [Test worker/INFO]: null
16-
[21:00:12] [Test worker/INFO]: check 2
17-
[21:00:12] [Test worker/INFO]: running ItemStack tests 2
18-
[21:00:12] [Test worker/INFO]: Could not call method 'public static me.matl114.bukkitUtiils.BukkitMetaItem me.matl114.bukkitUtiils.BukkitMetaItem.deserialize(java.util.Map) throws java.lang.Throwable' of class me.matl114.bukkitUtiils.BukkitMetaItem for deserialization java.lang.NoClassDefFoundError: Could not initialize class net.minecraft.item.Items
12+
13+
[23:33:07] [Test worker/INFO]: Could not call method 'public static me.matl114.bukkitUtiils.BukkitMetaItem me.matl114.bukkitUtiils.BukkitMetaItem.deserialize(java.util.Map) throws java.lang.Throwable' of class me.matl114.bukkitUtiils.BukkitMetaItem for deserialization java.lang.ExceptionInInitializerError
14+
[23:33:07] [Test worker/INFO]: Could not call method 'public static me.matl114.bukkitUtiils.BukkitItemStack me.matl114.bukkitUtiils.BukkitItemStack.deserialize(java.util.Map)' of class me.matl114.bukkitUtiils.BukkitItemStack for deserialization java.lang.NoClassDefFoundError: Could not initialize class net.minecraft.item.Items
15+
[23:33:07] [Test worker/INFO]: null
16+
[23:33:07] [Test worker/INFO]: check 2
17+
[23:33:07] [Test worker/INFO]: running ItemStack tests 2
18+
[23:33:07] [Test worker/INFO]: Could not call method 'public static me.matl114.bukkitUtiils.BukkitMetaItem me.matl114.bukkitUtiils.BukkitMetaItem.deserialize(java.util.Map) throws java.lang.Throwable' of class me.matl114.bukkitUtiils.BukkitMetaItem for deserialization java.lang.NoClassDefFoundError: Could not initialize class net.minecraft.item.Items

src/main/java/me/matl114/gui/itemEdit/ItemEditScreen.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ protected void saveChanges() {
550550
stackTemplate.setNbt(origin.getNbt());
551551
}
552552
stackTemplate.setCount(count.getOriginValue());
553-
stackTemplate.setDamage(damage.getOriginValue());
553+
ItemStackUtils.setDamage(stackTemplate, damage.getOriginValue());
554554
ItemStackUtils.setSfId(stackTemplate, sfid.getOriginValue());
555555
ItemStackUtils.setUnbreakable(stackTemplate, this.unbreakable.getOriginValue());
556556
this.flags.applyChange(stackTemplate);

src/main/java/me/matl114/hackUtils/ChatTasks.java

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -265,8 +265,11 @@ public static boolean parseClientCommand(String command){
265265
}else if(command.startsWith("/!!")){
266266
dispatchClientCommand(command.substring(3));
267267
return true;
268-
}else if(command.startsWith("/") && parseVanillaCommands(command.substring(1))){
269-
return true;
268+
}else if(command.startsWith("/")){
269+
if(parseVanillaCommands(command.substring(1))){
270+
return true;
271+
}
272+
return checkCommandLength(command);
270273
}
271274
return checkMessageLength(command);
272275
}
@@ -296,16 +299,23 @@ public static CommandManager getVanillaCommandManager(){
296299
});
297300

298301
}
299-
private static boolean checkMessageLength(String command){
302+
private static boolean checkCommandLength(String command){
300303
if(MESSAGE_LENGTH.get() >0 && command.length() > MESSAGE_LENGTH.get()){
301-
Debug.chat(Text.literal("你的输入内容太长了! %d / 256".formatted(command.length())).formatted(Formatting.RED));
302-
if(command.startsWith("/give") || command.startsWith("/minecraft:give")){
304+
Debug.chat(Text.literal("你的输入内容太长了! %d / %d".formatted(command.length(), MESSAGE_LENGTH.get())).formatted(Formatting.RED));
305+
if(!EXECUTE_GIVE_CLIENTSIDE.get() &&(command.startsWith("/give") || command.startsWith("/minecraft:give"))){
303306
Debug.chat(Text.literal("可以在配置文件中启用客户端/give指令来执行长指令"));
304307
}
305308
return true;
306309
}
307310
return false;
308311
}
312+
private static boolean checkMessageLength(String command){
313+
if(MESSAGE_LENGTH.get() >0 && command.length() > MESSAGE_LENGTH.get()){
314+
Debug.chat(Text.literal("你的输入内容太长了! %d / %d".formatted(command.length(),MESSAGE_LENGTH.get())).formatted(Formatting.RED));
315+
return true;
316+
}
317+
return false;
318+
}
309319
private static boolean parseVanillaCommands(String command){
310320
if(EXECUTE_GIVE_CLIENTSIDE.get()){
311321
if(command.startsWith("minecraft:give") || command.startsWith("give")) {

src/main/java/me/matl114/hackUtils/HttpTasks.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import io.netty.channel.Channel;
44
import io.netty.channel.ChannelHandlerContext;
55
import io.netty.channel.ChannelInboundHandlerAdapter;
6+
import io.netty.channel.ChannelPipeline;
67
import io.netty.handler.proxy.HttpProxyHandler;
78
import io.netty.handler.proxy.Socks4ProxyHandler;
89
import io.netty.handler.proxy.Socks5ProxyHandler;
@@ -32,7 +33,7 @@ public class HttpTasks {
3233
static Config.StringRef proxyUser = Configs.HTTP_CONFIG.getString(Configs.HTTP_PROXY_USERNAME);
3334
static Config.StringRef proxyPassword = Configs.HTTP_CONFIG.getString(Configs.HTTP_PROXY_OPTIONAL_PASSWORD);
3435
static Config.StringRef proxyType = Configs.HTTP_CONFIG.getString(Configs.HTTP_PROXY_TYPE);
35-
public static void redirectIpPre(Channel ch){
36+
public static void redirectIpPre(ChannelPipeline ch){
3637
if(proxyEnable.get()){
3738
int port = proxyPort.get();
3839
if(port > 0){
@@ -42,17 +43,17 @@ public static void redirectIpPre(Channel ch){
4243
switch (proxyType.get()){
4344
case "socks":
4445
if(password == null || password.isEmpty()){
45-
ch.pipeline().addFirst("socks5CLientProxy", new Socks4ProxyHandler(
46+
ch.addFirst("socks5CLientProxy", new Socks4ProxyHandler(
4647
new InetSocketAddress(proxyIp.get(), port),userNo?null :username
4748
));
4849
}else {
49-
ch.pipeline().addFirst("socks5CLientProxy", new Socks5ProxyHandler(
50+
ch.addFirst("socks5CLientProxy", new Socks5ProxyHandler(
5051
new InetSocketAddress(proxyIp.get(), port), userNo? null: username, password
5152
));
5253
}
5354
break;
5455
case "http":
55-
ch.pipeline().addFirst("httpCLientProxy", new HttpProxyHandler(
56+
ch.addFirst("httpCLientProxy", new HttpProxyHandler(
5657
new InetSocketAddress(proxyIp.get(), port),userNo?null :username, (password == null || password.isEmpty())?null:password
5758
));
5859
break;

src/main/java/me/matl114/hackUtils/ItemEditTasks.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,22 @@
33
import me.matl114.access.ScreenAccess;
44
import me.matl114.gui.itemEdit.ItemEditScreen;
55
import me.matl114.utils.Debug;
6+
import me.matl114.utils.ScreenUtils;
67
import net.minecraft.client.network.ClientPlayerEntity;
78
import net.minecraft.item.ItemStack;
89
import net.minecraft.text.Text;
10+
import net.minecraft.util.Formatting;
911

1012
import java.util.function.Consumer;
1113

1214
public class ItemEditTasks {
1315
public static void openEditor(ClientPlayerEntity entity){
14-
openEditScreen(entity.getMainHandStack(), null);
16+
ItemStack stack = ScreenUtils.getSelectingItemOrHand();
17+
if (stack != null){
18+
openEditScreen(stack, null);
19+
}else {
20+
Debug.chat(Text.literal("你必须选择一个物品以打开").formatted(Formatting.RED));
21+
}
1522
}
1623
public static void openEditScreen(ItemStack item, Consumer<ItemStack> callback){
1724
if(item.isEmpty()){

src/main/java/me/matl114/hackUtils/SlimefunTasks.java

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -722,16 +722,22 @@ public static void handleMultiBlockExecute(){
722722
}
723723
BlockPos pos = tile.getPos();
724724
Block block = tile.getBlockType();
725+
boolean find = false;
725726
if(block == Blocks.DISPENSER || block == Blocks.DROPPER){
726727
for (var multiblock: MULTIBLOCK_REGISTRIES.values()){
727728
var optional = multiblock.getOptionalActionFromDispenser(mc.world, pos);
728729
if(optional.isEmpty())continue;
730+
find = true;
729731
for (var bp : optional){
730732
BlockHitResult result = MovTasks.createHitResult(bp);
731733
onClickBlockExecute(result, true);
732734
}
733735
}
734736
}
737+
if(!find){
738+
Debug.chat(Text.literal("[多方块执行] 当前多方块结构与已记录的多方块无法匹配").formatted(Formatting.RED));
739+
AUTO_EXECUTE = false;
740+
}
735741
}
736742
private static boolean AUTO_EXECUTE = false;
737743
public static boolean isMultiBlockAutoExecute(){
@@ -764,11 +770,14 @@ public static Collection<SlimefunTasks.MultiBlockEntry> getOptionalMultiBlockTyp
764770
return ans;
765771
}
766772

767-
public static final ItemStack GUIDE_ICON;
768-
public static final ItemStack RTYPE_ICON = new ItemStack(Items.KNOWLEDGE_BOOK);
769-
public static final ItemStack VTYPE_ICON = new ItemStack(Items.CRAFTING_TABLE);
770-
public static final ItemStack SAVED_ICON = new ItemStack(Items.CHAIN_COMMAND_BLOCK);
773+
public static ItemStack GUIDE_ICON;
774+
public static ItemStack RTYPE_ICON ;
775+
public static ItemStack VTYPE_ICON ;
776+
public static ItemStack SAVED_ICON ;
771777
static {
778+
779+
}
780+
private static void initIcon(){
772781
ItemStack ICON;
773782
try {
774783
ICON = ItemStack.fromNbt(StringNbtReader.parse( "{Count:1b,id:\"minecraft:enchanted_book\",tag:{CustomModelData:2200001,PublicBukkitValues:{\"slimefun:slimefun_guide_mode\":\"SURVIVAL_MODE\"},display:{Lore:['{\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"yellow\",\"text\":\"右键 \"},{\"italic\":false,\"color\":\"dark_gray\",\"text\":\"\"},{\"italic\":false,\"color\":\"gray\",\"text\":\"浏览物品\"}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"yellow\",\"text\":\"Shift + 右键 \"},{\"italic\":false,\"color\":\"dark_gray\",\"text\":\"\"},{\"italic\":false,\"color\":\"gray\",\"text\":\"打开 设置 / 关于\"}],\"text\":\"\"}'],Name:'{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"green\",\"text\":\"Slimefun 指南 \"},{\"italic\":false,\"color\":\"gray\",\"text\":\"(箱子界面)\"}],\"text\":\"\"}'}}}"));
@@ -777,6 +786,9 @@ public static Collection<SlimefunTasks.MultiBlockEntry> getOptionalMultiBlockTyp
777786
ICON = new ItemStack(Items.ENCHANTED_BOOK);
778787
}
779788
GUIDE_ICON = ICON;
789+
RTYPE_ICON = new ItemStack(Items.KNOWLEDGE_BOOK);
790+
VTYPE_ICON = new ItemStack(Items.CRAFTING_TABLE);
791+
SAVED_ICON = new ItemStack(Items.CHAIN_COMMAND_BLOCK);
780792
}
781793

782794

@@ -1402,20 +1414,13 @@ public static boolean clickToSaveItem(ClientPlayerEntity player){
14021414

14031415
if(player==null)return false;
14041416

1405-
ItemStack heldItem=null;
1406-
if(mc.currentScreen instanceof HandledScreen<?> s){
1407-
Point mouseCoord= ScreenUtils.getMouseCoord(mc);
1408-
Slot slot=HandledScreenAccess.of(s).reallyGetSlotAt(mouseCoord.x,mouseCoord.y);
1409-
if(slot!=null){
1410-
heldItem=slot.getStack();
1411-
}
1412-
}else{
1413-
heldItem=player.getStackInHand(Hand.MAIN_HAND);
1414-
}
1417+
ItemStack heldItem = ScreenUtils.getSelectingItemOrHand();
14151418

14161419
if(heldItem != null && !heldItem.isEmpty()){
14171420
handleSaveItem(heldItem);
14181421
return true;
1422+
}else if (heldItem != null){
1423+
Debug.chat(Text.literal("不能保存空物品").formatted(Formatting.RED));
14191424
}
14201425
return false;
14211426
}
@@ -1631,7 +1636,11 @@ public static void listenGuideRecipe(HandledScreen<?> screen){
16311636
});
16321637
MULTIBLOCK_REGEX = Pattern.compile(MULTIBLOCK_PATTERN.get());
16331638

1634-
loadData();
1639+
Tasks.scheduleDelayed(()->{
1640+
Debug.info("Running Slimefun Post Setup Tasks");
1641+
loadData();
1642+
initIcon();
1643+
},1);
16351644
//定时保存
16361645
Tasks.scheduleRepeated(SlimefunTasks::scheduledSave, 20* 60, 20*60* 5);
16371646
//退出服务器时保存

src/main/java/me/matl114/listenerUtils/Listener.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@ private static boolean unpackMultiPacket(ClientConnection connection,Packet<?> p
104104
return onSinglePacketListen(connection,packet,isS2C?listenerS2C:listenerC2S);
105105
}
106106
}
107+
108+
@Getter
109+
private static final ListenerPoint<Void> gameJoinPoint = new ListenerPoint<>();
110+
107111
@Getter
108112
private static final ListenerPoint<Void> serverDisconnectPoint = new ListenerPoint<>();
109113

src/main/java/me/matl114/mixins/HackMixin/ClientConnectionMixin.java

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -77,37 +77,11 @@ public PacketSizeLogger getPacketSizeLogger(){
7777
}
7878

7979

80-
@Inject(method = "connect(Ljava/net/InetSocketAddress;ZLnet/minecraft/network/ClientConnection;)Lio/netty/channel/ChannelFuture;",at = @At("HEAD"), cancellable = true)
81-
private static void proxyIp(InetSocketAddress address, boolean useEpoll, ClientConnection connection, CallbackInfoReturnable<ChannelFuture> cir){
82-
Class class_;
83-
EventLoopGroup eventLoopGroup;
84-
if (Epoll.isAvailable() && useEpoll) {
85-
class_ = EpollSocketChannel.class;
86-
eventLoopGroup = (EventLoopGroup)EPOLL_CLIENT_IO_GROUP.get();
87-
} else {
88-
class_ = NioSocketChannel.class;
89-
eventLoopGroup = (EventLoopGroup)CLIENT_IO_GROUP.get();
80+
@Inject(method = "addHandlers", at = @At("HEAD"))
81+
private static void proxyChannelIp(ChannelPipeline pipeline, NetworkSide side, PacketSizeLogger packetSizeLogger, CallbackInfo ci){
82+
if(side == NetworkSide.CLIENTBOUND){
83+
HttpTasks.redirectIpPre(pipeline);
9084
}
91-
92-
var returnValue1 = ((io.netty.bootstrap.Bootstrap)((io.netty.bootstrap.Bootstrap)((io.netty.bootstrap.Bootstrap)(new Bootstrap()).group(eventLoopGroup)).handler(new ChannelInitializer<Channel>() {
93-
protected void initChannel(Channel channel) {
94-
ClientConnection.setHandlers(channel);
95-
96-
try {
97-
channel.config().setOption(ChannelOption.TCP_NODELAY, true);
98-
} catch (ChannelException var3) {
99-
}
100-
// channel.pipeline().addFirst(new Sock)
101-
HttpTasks.redirectIpPre(channel);
102-
103-
ChannelPipeline channelPipeline = channel.pipeline().addLast("timeout", new ReadTimeoutHandler(30));
104-
ClientConnection.addHandlers(channelPipeline, NetworkSide.CLIENTBOUND, ClientConnectionAccess.of(connection).getPacketSizeLogger());
105-
connection.addFlowControlHandler(channelPipeline);
106-
}
107-
})).channel(class_));
108-
109-
var returnValue2 = returnValue1.connect(address.getAddress(), address.getPort());
110-
cir.setReturnValue(returnValue2);
11185
}
11286

11387

src/main/java/me/matl114/mixins/HackMixin/ClientPacketListenerMixin.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,7 @@
88
import net.minecraft.client.MinecraftClient;
99
import net.minecraft.client.gui.screen.ingame.HandledScreen;
1010
import net.minecraft.client.network.ClientPlayNetworkHandler;
11-
import net.minecraft.network.packet.s2c.play.CloseScreenS2CPacket;
12-
import net.minecraft.network.packet.s2c.play.InventoryS2CPacket;
13-
import net.minecraft.network.packet.s2c.play.OpenScreenS2CPacket;
14-
import net.minecraft.network.packet.s2c.play.ScreenHandlerSlotUpdateS2CPacket;
11+
import net.minecraft.network.packet.s2c.play.*;
1512
import org.apache.commons.lang3.mutable.MutableObject;
1613
import org.spongepowered.asm.mixin.Mixin;
1714
import org.spongepowered.asm.mixin.injection.*;
@@ -81,6 +78,7 @@ private String onChat0(String args){
8178
}
8279
return args;
8380
}
81+
//stop sending empty commands
8482
@Inject(method = "sendChatCommand",at = @At(value = "INVOKE", target = "Ljava/time/Instant;now()Ljava/time/Instant;"), cancellable = true)
8583
private void onChat1(String command, CallbackInfo ci){
8684
// empty command will be ignored
@@ -104,4 +102,8 @@ private void onChat3(String content, CallbackInfo ci){
104102
}
105103
}
106104

105+
@Inject(method = "onGameJoin", at = @At("RETURN"))
106+
private void onGameJoinEntryPoint(GameJoinS2CPacket packet, CallbackInfo ci){
107+
Listener.getGameJoinPoint().handleValue(null);
108+
}
107109
}

src/main/java/me/matl114/mixins/RenderMixin/BakedModelManagerMixin.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ public SpriteAtlasManager getSpriteAtlasManager(){
6969
// public final void reloadRewrite(ResourceReloader.Synchronizer synchronizer, ResourceManager manager, Profiler prepareProfiler, Profiler applyProfiler, Executor prepareExecutor, Executor applyExecutor, CallbackInfoReturnable<CompletableFuture<Void>> cir){
7070
//
7171
// }
72+
@Unique
7273
public final CompletableFuture<Void> myReload(ResourceReloader.Synchronizer synchronizer, ResourceManager manager, Profiler prepareProfiler, Profiler applyProfiler, Executor prepareExecutor, Executor applyExecutor) {
7374
Debug.info("execute MyReload");
7475
prepareProfiler.startTick();

0 commit comments

Comments
 (0)