Skip to content

Commit d61b027

Browse files
committed
Add itemNoClip logger
1 parent 35dd2ef commit d61b027

4 files changed

Lines changed: 72 additions & 10 deletions

File tree

patches/net/minecraft/entity/item/EntityItem.java.patch

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,28 @@
11
--- a/net/minecraft/entity/item/EntityItem.java
22
+++ b/net/minecraft/entity/item/EntityItem.java
3-
@@ -2,6 +2,12 @@
3+
@@ -2,6 +2,13 @@
44

55
import java.util.UUID;
66
import javax.annotation.Nullable;
77
+
88
+import carpet.commands.lifetime.removal.LiteralRemovalReason;
99
+import carpet.commands.lifetime.removal.MobPickupRemovalReason;
1010
+import carpet.helpers.InventoryHelper;
11+
+import carpet.logging.itemNoClip.ItemNoClipLogger;
1112
+import carpet.settings.CarpetSettings;
1213
+import net.minecraft.block.BlockShulkerBox;
1314
import net.minecraft.entity.Entity;
1415
import net.minecraft.entity.EntityType;
1516
import net.minecraft.entity.MoverType;
16-
@@ -9,6 +15,7 @@
17+
@@ -9,6 +16,7 @@
1718
import net.minecraft.init.Items;
1819
import net.minecraft.init.SoundEvents;
1920
import net.minecraft.item.Item;
2021
+import net.minecraft.item.ItemBlock;
2122
import net.minecraft.item.ItemStack;
2223
import net.minecraft.nbt.NBTTagCompound;
2324
import net.minecraft.nbt.NBTUtil;
24-
@@ -37,6 +44,12 @@
25+
@@ -37,6 +45,12 @@
2526
private UUID owner;
2627
public float hoverStart = (float)(Math.random() * Math.PI * 2.0D);
2728

@@ -34,7 +35,7 @@
3435
public EntityItem(World worldIn)
3536
{
3637
super(EntityType.ITEM, worldIn);
37-
@@ -57,6 +70,15 @@
38+
@@ -57,6 +71,15 @@
3839
{
3940
this(worldIn, x, y, z);
4041
this.setItem(stack);
@@ -50,15 +51,32 @@
5051
}
5152

5253
protected boolean canTriggerWalking()
53-
@@ -166,6 +188,7 @@
54+
@@ -106,7 +129,16 @@
55+
}
56+
else
57+
{
58+
+ // TISCM itemNoClip logger
59+
+ boolean wasNoClip = this.noClip;
60+
+
61+
this.noClip = this.pushOutOfBlocks(this.posX, (this.getBoundingBox().minY + this.getBoundingBox().maxY) / 2.0D, this.posZ);
62+
+
63+
+ // TISCM itemNoClip logger
64+
+ if (!wasNoClip && this.noClip)
65+
+ {
66+
+ ItemNoClipLogger.getInstance().onItemBecomeNoClip(this);
67+
+ }
68+
}
69+
70+
this.move(MoverType.SELF, this.motionX, this.motionY, this.motionZ);
71+
@@ -166,6 +198,7 @@
5472

5573
if (!this.world.isRemote && this.age >= 6000)
5674
{
5775
+ this.recordRemoval(LiteralRemovalReason.DESPAWN_TIMEOUT); // TISCM lifetime tracker
5876
this.remove();
5977
}
6078
}
61-
@@ -205,8 +228,12 @@
79+
@@ -205,8 +238,12 @@
6280
{
6381
if (this.age != -32768 && other.age != -32768)
6482
{
@@ -72,7 +90,7 @@
7290
return false;
7391
}
7492
else if (itemstack1.hasTag() ^ itemstack.hasTag())
75-
@@ -229,12 +256,23 @@
93+
@@ -229,12 +266,23 @@
7694
{
7795
return false;
7896
}
@@ -96,15 +114,15 @@
96114
this.remove();
97115
return true;
98116
}
99-
@@ -282,6 +320,7 @@
117+
@@ -282,6 +330,7 @@
100118

101119
if (this.health <= 0)
102120
{
103121
+ this.setDeathDamageSource(source); // TISCM lifetime tracker
104122
this.remove();
105123
}
106124

107-
@@ -354,6 +393,12 @@
125+
@@ -354,6 +403,12 @@
108126

109127
if (itemstack.isEmpty())
110128
{
@@ -117,7 +135,7 @@
117135
this.remove();
118136
itemstack.setCount(i);
119137
}
120-
@@ -460,4 +505,44 @@
138+
@@ -460,4 +515,44 @@
121139
this.setInfinitePickupDelay();
122140
this.age = 5999;
123141
}

src/main/java/carpet/logging/LoggerRegistry.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import carpet.logging.commandblock.CommandBlockLogger;
44
import carpet.logging.ghostPlayer.GhostPlayerLogger;
55
import carpet.logging.instantfall.InstantFallLogger;
6+
import carpet.logging.itemNoClip.ItemNoClipLogger;
67
import carpet.logging.lifetime.LifeTimeHUDLogger;
78
import carpet.logging.microtiming.utils.MicroTimingStandardCarpetLogger;
89
import carpet.logging.phantom.PhantomLogger;
@@ -51,6 +52,7 @@ public class LoggerRegistry
5152
public static boolean __phantom;
5253
public static boolean __threadstone;
5354
public static boolean __instantFall;
55+
public static boolean __itemNoClip;
5456
public static boolean __playerCheckLight;
5557
public static boolean __ghostPlayer;
5658
public static boolean __portalCache;
@@ -83,6 +85,7 @@ public static void initLoggers()
8385
registerLogger("phantom", PhantomLogger.getInstance().createCarpetLogger());
8486
registerLogger(ThreadstoneLogger.NAME, ThreadstoneLogger.getInstance().createCarpetLogger());
8587
registerLogger(InstantFallLogger.NAME, InstantFallLogger.getInstance().createCarpetLogger());
88+
registerLogger(ItemNoClipLogger.NAME, ItemNoClipLogger.getInstance().createCarpetLogger());
8689
registerLogger(PlayerCheckLightLogger.NAME, PlayerCheckLightLogger.getInstance().createCarpetLogger());
8790
registerLogger(GhostPlayerLogger.NAME, GhostPlayerLogger.getInstance().createCarpetLogger());
8891
registerLogger(PortalCacheLogger.NAME, PortalCacheLogger.getInstance().createCarpetLogger());
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package carpet.logging.itemNoClip;
2+
3+
import carpet.logging.AbstractLogger;
4+
import carpet.logging.LoggerRegistry;
5+
import carpet.utils.Messenger;
6+
import net.minecraft.entity.item.EntityItem;
7+
import net.minecraft.util.math.Vec3d;
8+
import net.minecraft.util.text.ITextComponent;
9+
10+
public class ItemNoClipLogger extends AbstractLogger
11+
{
12+
public static final String NAME = "itemNoClip";
13+
private static final ItemNoClipLogger INSTANCE = new ItemNoClipLogger();
14+
15+
public ItemNoClipLogger()
16+
{
17+
super(NAME);
18+
}
19+
20+
public static ItemNoClipLogger getInstance()
21+
{
22+
return INSTANCE;
23+
}
24+
25+
public void onItemBecomeNoClip(EntityItem item)
26+
{
27+
if (!LoggerRegistry.__itemNoClip)
28+
{
29+
return;
30+
}
31+
this.log(() -> new ITextComponent[]{
32+
advTr(
33+
"become_no_clip", "%s changed to noClip state @ %s",
34+
Messenger.entity(item),
35+
Messenger.coord(new Vec3d(item.posX, item.posY, item.posZ), item.dimension)
36+
),
37+
});
38+
}
39+
}

src/main/resources/assets/carpet/lang/zh_cn.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,8 @@ logger:
594594
hint: 点击以启用
595595
instantfall:
596596
flag_changed: 瞬时落沙flag已切换为%s
597+
itemNoClip:
598+
become_no_clip: '%1$s已进入noClip状态 @ %2$s'
597599
portalCache:
598600
added: '地狱门缓存已创建: %s -> %s'
599601
added_hover: |-

0 commit comments

Comments
 (0)