Skip to content

Commit ecce2a2

Browse files
committed
Add zombieReinforce logger
1 parent b521d0d commit ecce2a2

4 files changed

Lines changed: 87 additions & 6 deletions

File tree

patches/net/minecraft/entity/monster/EntityZombie.java.patch

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
--- a/net/minecraft/entity/monster/EntityZombie.java
22
+++ b/net/minecraft/entity/monster/EntityZombie.java
3-
@@ -5,6 +5,10 @@
3+
@@ -5,6 +5,11 @@
44
import java.util.List;
55
import java.util.UUID;
66
import javax.annotation.Nullable;
77
+
88
+import carpet.CarpetServer;
99
+import carpet.commands.lifetime.spawning.LiteralSpawningReason;
10+
+import carpet.logging.zombieReinforce.ZombieReinforceLogger;
1011
+import carpet.settings.CarpetSettings;
1112
import net.minecraft.block.Block;
1213
import net.minecraft.block.state.IBlockState;
1314
import net.minecraft.entity.CreatureAttribute;
14-
@@ -283,6 +287,12 @@
15+
@@ -283,6 +288,12 @@
1516
flag = false;
1617
}
1718

@@ -24,16 +25,36 @@
2425
if (flag)
2526
{
2627
this.setFire(8);
27-
@@ -368,6 +378,8 @@
28+
@@ -356,6 +367,8 @@
29+
int k = MathHelper.floor(this.posZ);
30+
EntityZombie entityzombie = new EntityZombie(this.world);
31+
32+
+ boolean reinforceSuccess = false; // TISCM zombieReinforce logger
33+
+
34+
for (int l = 0; l < 50; ++l)
35+
{
36+
int i1 = i + MathHelper.nextInt(this.rand, 7, 40) * MathHelper.nextInt(this.rand, -1, 1);
37+
@@ -368,6 +381,9 @@
2838

2939
if (!this.world.isAnyPlayerWithinRangeAt((double)i1, (double)j1, (double)k1, 7.0D) && this.world.checkNoEntityCollision(entityzombie, entityzombie.getBoundingBox()) && this.world.isCollisionBoxesEmpty(entityzombie, entityzombie.getBoundingBox()) && !this.world.containsAnyLiquid(entityzombie.getBoundingBox()))
3040
{
3141
+ entityzombie.recordSpawning(LiteralSpawningReason.ZOMBIE_REINFORCE); // TISCM lifetime tracker
42+
+ reinforceSuccess = true; // TISCM zombieReinforce logger
3243
+
3344
this.world.spawnEntity(entityzombie);
3445
entityzombie.setAttackTarget(entitylivingbase);
3546
entityzombie.onInitialSpawn(this.world.getDifficultyForLocation(new BlockPos(entityzombie)), (IEntityLivingData)null, (NBTTagCompound)null);
36-
@@ -548,7 +560,10 @@
47+
@@ -377,6 +393,9 @@
48+
}
49+
}
50+
}
51+
+
52+
+ // TISCM zombieReinforce logger
53+
+ ZombieReinforceLogger.getInstance().onZombieReinforceAttempt(this, entityzombie, reinforceSuccess);
54+
}
55+
56+
return true;
57+
@@ -548,7 +567,10 @@
3758

3859
if (entityLivingData == null)
3960
{
@@ -45,7 +66,7 @@
4566
}
4667

4768
if (entityLivingData instanceof EntityZombie.GroupData)
48-
@@ -559,6 +574,9 @@
69+
@@ -559,6 +581,9 @@
4970
{
5071
this.setChild(true);
5172

@@ -55,7 +76,7 @@
5576
if ((double)this.world.rand.nextFloat() < 0.05D)
5677
{
5778
List<EntityChicken> list = this.world.getEntitiesWithinAABB(EntityChicken.class, this.getBoundingBox().grow(5.0D, 3.0D, 5.0D), EntitySelectors.IS_STANDALONE);
58-
@@ -570,7 +588,7 @@
79+
@@ -570,7 +595,7 @@
5980
this.startRiding(entitychicken);
6081
}
6182
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import carpet.logging.portalCache.PortalCacheLogger;
1212
import carpet.logging.threadstone.ThreadstoneLogger;
1313
import carpet.logging.tickwarp.TickWarpHUDLogger;
14+
import carpet.logging.zombieReinforce.ZombieReinforceLogger;
1415
import carpet.settings.CarpetSettings;
1516
import net.minecraft.entity.player.EntityPlayer;
1617
import net.minecraft.item.EnumDyeColor;
@@ -56,6 +57,7 @@ public class LoggerRegistry
5657
public static boolean __playerCheckLight;
5758
public static boolean __ghostPlayer;
5859
public static boolean __portalCache;
60+
public static boolean __zombieReinforce;
5961

6062
public static void initLoggers()
6163
{
@@ -89,6 +91,7 @@ public static void initLoggers()
8991
registerLogger(PlayerCheckLightLogger.NAME, PlayerCheckLightLogger.getInstance().createCarpetLogger());
9092
registerLogger(GhostPlayerLogger.NAME, GhostPlayerLogger.getInstance().createCarpetLogger());
9193
registerLogger(PortalCacheLogger.NAME, PortalCacheLogger.getInstance().createCarpetLogger());
94+
registerLogger(ZombieReinforceLogger.NAME, ZombieReinforceLogger.getInstance().createCarpetLogger());
9295
}
9396

9497
/**
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package carpet.logging.zombieReinforce;
2+
3+
import carpet.logging.AbstractLogger;
4+
import carpet.logging.LoggerRegistry;
5+
import carpet.utils.Messenger;
6+
import net.minecraft.entity.monster.EntityZombie;
7+
import net.minecraft.util.math.Vec3d;
8+
import net.minecraft.util.text.ITextComponent;
9+
10+
public class ZombieReinforceLogger extends AbstractLogger
11+
{
12+
public static final String NAME = "zombieReinforce";
13+
private static final ZombieReinforceLogger INSTANCE = new ZombieReinforceLogger();
14+
15+
public ZombieReinforceLogger()
16+
{
17+
super(NAME);
18+
}
19+
20+
public static ZombieReinforceLogger getInstance()
21+
{
22+
return INSTANCE;
23+
}
24+
25+
public void onZombieReinforceAttempt(EntityZombie source, EntityZombie fellow, boolean success)
26+
{
27+
if (!LoggerRegistry.__zombieReinforce)
28+
{
29+
return;
30+
}
31+
32+
if (success)
33+
{
34+
this.log(() -> new ITextComponent[]{
35+
advTr(
36+
"success", "%s at %s summoned zombie reinforce to %s",
37+
Messenger.entity(source),
38+
Messenger.coord(new Vec3d(source.posX, source.posY, source.posZ), source.dimension),
39+
Messenger.coord(new Vec3d(fellow.posX, fellow.posY, fellow.posZ), fellow.dimension)
40+
),
41+
});
42+
}
43+
else
44+
{
45+
this.log(() -> new ITextComponent[]{
46+
advTr(
47+
"fail", "%s at @s failed to summon zombie reinforce",
48+
Messenger.entity(source),
49+
Messenger.coord(new Vec3d(source.posX, source.posY, source.posZ), source.dimension)
50+
),
51+
});
52+
}
53+
}
54+
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,9 @@ logger:
607607
上次缓存更新时间: %s
608608
range: '%s中的对应范围:'
609609
destination_dimension: '传送目标维度: %s'
610+
zombieReinforce:
611+
success: '%s于%s成功召唤僵尸增援至%s'
612+
fail: '%s于%s召唤僵尸增援失败'
610613

611614
raid_invalidate_reason:
612615
difficulty_peaceful: 难度被设为和平

0 commit comments

Comments
 (0)