Skip to content

Commit 383c155

Browse files
committed
未雨屏未曾梦见🍄的爱
1 parent e78253f commit 383c155

7 files changed

Lines changed: 316 additions & 6 deletions

File tree

patches/net/minecraft/server/level/ServerLevel.java.patch

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
--- a/net/minecraft/server/level/ServerLevel.java
22
+++ b/net/minecraft/server/level/ServerLevel.java
3-
@@ -216,11 +_,17 @@
3+
@@ -181,8 +_,9 @@
4+
import net.minecraft.world.waypoints.WaypointTransmitter;
5+
import org.jspecify.annotations.Nullable;
6+
import org.slf4j.Logger;
7+
+import org.teneted.neotenet.injection.server.level.ServerLevelInjection;
8+
9+
-public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGetter {
10+
+public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGetter, ServerLevelInjection {
11+
public static final BlockPos END_SPAWN_POINT = new BlockPos(100, 50, 0);
12+
public static final IntProvider RAIN_DELAY = UniformInt.of(12000, 180000);
13+
public static final IntProvider RAIN_DURATION = UniformInt.of(12000, 24000);
14+
@@ -216,11 +_,20 @@
415
private boolean handlingTick;
516
private final List<CustomSpawner> customSpawners;
617
private @Nullable EnderDragonFight dragonFight;
@@ -16,6 +27,9 @@
1627
+ public java.util.OptionalLong getSeedOverride() {
1728
+ return this.seedOverride;
1829
+ }
30+
+ // CraftBukkit start
31+
+ public LevelStorageSource.LevelStorageAccess storageSource;
32+
+ public UUID uuid;
1933

2034
public ServerLevel(
2135
MinecraftServer server,
@@ -225,7 +239,7 @@
225239
this.neighborUpdater.updateNeighborsAtExceptFromFacing(pos, blockObject, skipDirection, orientation);
226240
}
227241

228-
@@ -1206,7 +_,7 @@
242+
@@ -1206,14 +_,17 @@
229243
Explosion.BlockInteraction blockInteraction = switch (interactionType) {
230244
case NONE -> Explosion.BlockInteraction.KEEP;
231245
case BLOCK -> this.getDestroyType(GameRules.BLOCK_EXPLOSION_DROP_DECAY);
@@ -234,7 +248,9 @@
234248
? this.getDestroyType(GameRules.MOB_EXPLOSION_DROP_DECAY)
235249
: Explosion.BlockInteraction.KEEP;
236250
case TNT -> this.getDestroyType(GameRules.TNT_EXPLOSION_DROP_DECAY);
237-
@@ -1214,6 +_,7 @@
251+
case TRIGGER -> Explosion.BlockInteraction.TRIGGER_BLOCK;
252+
+ // CraftBukkit start - handle custom explosion type
253+
+ case STANDARD -> Explosion.BlockInteraction.DESTROY;
238254
};
239255
Vec3 center = new Vec3(x, y, z);
240256
ServerExplosion explosion = new ServerExplosion(this, source, damageSource, damageCalculator, center, r, fire, blockInteraction);

patches/net/minecraft/world/entity/Entity.java.patch

Lines changed: 85 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,39 @@
11
--- a/net/minecraft/world/entity/Entity.java
22
+++ b/net/minecraft/world/entity/Entity.java
3-
@@ -158,6 +_,7 @@
3+
@@ -123,6 +_,7 @@
4+
import net.minecraft.world.level.entity.EntityInLevelCallback;
5+
import net.minecraft.world.level.gameevent.DynamicGameEventListener;
6+
import net.minecraft.world.level.gameevent.GameEvent;
7+
+import net.minecraft.world.level.gamerules.GameRules;
8+
import net.minecraft.world.level.levelgen.Heightmap;
9+
import net.minecraft.world.level.material.Fluid;
10+
import net.minecraft.world.level.material.FluidState;
11+
@@ -151,13 +_,16 @@
12+
import net.minecraft.world.scores.Scoreboard;
13+
import net.minecraft.world.scores.Team;
14+
import net.minecraft.world.waypoints.WaypointTransmitter;
15+
+import org.bukkit.command.CommandSender;
16+
import org.jetbrains.annotations.Contract;
17+
import org.jspecify.annotations.Nullable;
18+
import org.slf4j.Logger;
19+
420
import net.neoforged.neoforge.common.extensions.IEntityExtension;
21+
+import org.teneted.neotenet.injection.world.entity.EntityInjection;
522

623
public abstract class Entity
724
+ extends net.neoforged.neoforge.attachment.AttachmentHolder
825
implements Nameable,
926
EntityAccess,
1027
ScoreHolder,
28+
@@ -166,7 +_,7 @@
29+
ItemOwner,
30+
SlotProvider,
31+
DebugValueSource,
32+
- TypedInstance<EntityType<?>>, IEntityExtension {
33+
+ TypedInstance<EntityType<?>>, IEntityExtension, EntityInjection {
34+
private static final Logger LOGGER = LogUtils.getLogger();
35+
public static final String TAG_ID = "id";
36+
public static final String TAG_UUID = "UUID";
1137
@@ -207,6 +_,8 @@
1238
private static final int MAX_BLOCK_ITERATIONS_ALONG_TRAVEL_PER_TICK = 16;
1339
private static final double MAX_MOVEMENT_RESETTING_TRACE_DISTANCE = 8.0;
@@ -17,6 +43,28 @@
1743
private final EntityType<?> type;
1844
private boolean requiresPrecisePosition;
1945
private int id = 0;
46+
@@ -302,6 +_,21 @@
47+
private final LongSet visitedBlocks = new LongOpenHashSet();
48+
private final InsideBlockEffectApplier.StepBasedCollector insideEffectCollector = new InsideBlockEffectApplier.StepBasedCollector();
49+
private CustomData customData = CustomData.EMPTY;
50+
+ // CraftBukkit start
51+
+ public boolean forceDrops;
52+
+ public boolean persist = true;
53+
+ public boolean visibleByDefault = true;
54+
+ public boolean valid;
55+
+ public boolean inWorld = false;
56+
+ public boolean generation;
57+
+ public int maxAirTicks = getDefaultMaxAirSupply(); // CraftBukkit - SPIGOT-6907: re-implement LivingEntity#setMaximumAir()
58+
+ public org.bukkit.projectiles.ProjectileSource projectileSource; // For projectiles only
59+
+ public boolean lastDamageCancelled; // SPIGOT-5339, SPIGOT-6252, SPIGOT-6777: Keep track if the event was canceled
60+
+ public boolean persistentInvisibility = false;
61+
+ public BlockPos lastLavaContact;
62+
+ // Marks an entity, that it was removed by a plugin via Entity#remove
63+
+ // Main use case currently is for SPIGOT-7487, preventing dropping of leash when leash is removed
64+
+ public boolean pluginRemoved = false;
65+
66+
public Entity(EntityType<?> type, Level level) {
67+
this.type = type;
2068
@@ -323,7 +_,10 @@
2169
this.defineSynchedData(entityDataBuilder);
2270
this.entityData = entityDataBuilder.build();
@@ -274,6 +322,42 @@
274322
this.dimensions = newDim;
275323
this.eyeHeight = newDim.eyeHeight();
276324
this.reapplyPosition();
325+
@@ -3615,6 +_,35 @@
326+
return 0;
327+
}
328+
329+
+ // CraftBukkit start
330+
+ private final CommandSource commandSource = new CommandSource() {
331+
+
332+
+ @Override
333+
+ public void sendSystemMessage(Component component) {
334+
+ }
335+
+
336+
+ @Override
337+
+ public CommandSender getBukkitSender(CommandSourceStack wrapper) {
338+
+ return Entity.this.getBukkitEntity();
339+
+ }
340+
+
341+
+ @Override
342+
+ public boolean acceptsSuccess() {
343+
+ return ((ServerLevel) Entity.this.level()).getGameRules().get(GameRules.SEND_COMMAND_FEEDBACK);
344+
+ }
345+
+
346+
+ @Override
347+
+ public boolean acceptsFailure() {
348+
+ return true;
349+
+ }
350+
+
351+
+ @Override
352+
+ public boolean shouldInformAdmins() {
353+
+ return true;
354+
+ }
355+
+ };
356+
+ // CraftBukkit end
357+
+
358+
public CommandSourceStack createCommandSourceStackForNameResolution(ServerLevel level) {
359+
return new CommandSourceStack(
360+
CommandSource.NULL,
277361
@@ -3810,6 +_,10 @@
278362
}
279363
}

patches/net/minecraft/world/level/levelgen/structure/StructurePiece.java.patch

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
--- a/net/minecraft/world/level/levelgen/structure/StructurePiece.java
22
+++ b/net/minecraft/world/level/levelgen/structure/StructurePiece.java
3+
@@ -41,7 +_,7 @@
4+
private Rotation rotation;
5+
protected int genDepth;
6+
private final StructurePieceType type;
7+
- public static final Set<Block> SHAPE_CHECK_BLOCKS = ImmutableSet.<Block>builder()
8+
+ private static final Set<Block> SHAPE_CHECK_BLOCKS = ImmutableSet.<Block>builder()
9+
.add(Blocks.NETHER_BRICK_FENCE)
10+
.add(Blocks.TORCH)
11+
.add(Blocks.WALL_TORCH)
312
@@ -79,6 +_,9 @@
413
}
514

projects/neotenet/modified_class.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ net.minecraft.network.Connection # add fields
1010
net.minecraft.network.chat.TextColor # add fields and constructors
1111
net.minecraft.network.protocol.common.custom.DiscardedPayload # add fields and constructors
1212
net.minecraft.network.protocol.game.ClientboundSectionBlocksUpdatePacket # add constructors
13-
net.minecraft.server.level.ChunkMap # add inner class and fields
13+
net.minecraft.server.level.ChunkMap # add inner class and fields
14+
net.minecraft.world.entity.Entity # add fields
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
package org.teneted.neotenet.injection.server.level;
2+
3+
import net.minecraft.core.Holder;
4+
import net.minecraft.core.particles.ExplosionParticleInfo;
5+
import net.minecraft.core.particles.ParticleOptions;
6+
import net.minecraft.resources.Identifier;
7+
import net.minecraft.server.MinecraftServer;
8+
import net.minecraft.server.bossevents.CustomBossEvents;
9+
import net.minecraft.server.level.ServerPlayer;
10+
import net.minecraft.sounds.SoundEvent;
11+
import net.minecraft.util.RandomSource;
12+
import net.minecraft.util.random.WeightedList;
13+
import net.minecraft.world.RandomSequences;
14+
import net.minecraft.world.damagesource.DamageSource;
15+
import net.minecraft.world.entity.Entity;
16+
import net.minecraft.world.level.ExplosionDamageCalculator;
17+
import net.minecraft.world.level.Level;
18+
import net.minecraft.world.level.ServerExplosion;
19+
import net.minecraft.world.level.chunk.LevelChunk;
20+
import net.minecraft.world.level.levelgen.WorldGenSettings;
21+
import net.minecraft.world.level.storage.SavedDataStorage;
22+
import net.minecraft.world.level.timers.TimerQueue;
23+
import org.bukkit.event.entity.CreatureSpawnEvent;
24+
import org.bukkit.event.weather.LightningStrikeEvent;
25+
import org.jetbrains.annotations.Nullable;
26+
27+
public interface ServerLevelInjection {
28+
29+
default WorldGenSettings getWorldGenSettings() {
30+
throw new IllegalArgumentException("Not implemented");
31+
}
32+
33+
default CustomBossEvents getCustomBossEvents() {
34+
throw new IllegalArgumentException("Not implemented");
35+
}
36+
37+
default RandomSource getRandomSequence(Identifier key) {
38+
throw new IllegalArgumentException("Not implemented");
39+
}
40+
41+
default RandomSequences getRandomSequences() {
42+
throw new IllegalArgumentException("Not implemented");
43+
}
44+
45+
default void setWeatherParameters(int clearTime, int rainTime, boolean raining, boolean thundering) {
46+
throw new IllegalArgumentException("Not implemented");
47+
}
48+
49+
default TimerQueue<MinecraftServer> getScheduledEvents() {
50+
throw new IllegalArgumentException("Not implemented");
51+
}
52+
53+
default LevelChunk getChunkIfLoaded(int x, int z) {
54+
throw new IllegalArgumentException("Not implemented");
55+
}
56+
57+
default boolean addWithUUID(Entity entity, CreatureSpawnEvent.SpawnReason reason) {
58+
throw new IllegalArgumentException("Not implemented");
59+
}
60+
61+
default void addDuringTeleport(Entity entity, CreatureSpawnEvent.SpawnReason reason) {
62+
throw new IllegalArgumentException("Not implemented");
63+
}
64+
65+
default boolean addEntity(Entity entity, CreatureSpawnEvent.SpawnReason spawnReason) {
66+
throw new IllegalArgumentException("Not implemented");
67+
}
68+
69+
default boolean tryAddFreshEntityWithPassengers(Entity entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason) {
70+
throw new IllegalArgumentException("Not implemented");
71+
}
72+
73+
default boolean strikeLightning(Entity entitylightning) {
74+
throw new IllegalArgumentException("Not implemented");
75+
}
76+
77+
default boolean strikeLightning(Entity entitylightning, LightningStrikeEvent.Cause cause) {
78+
throw new IllegalArgumentException("Not implemented");
79+
}
80+
81+
default ServerExplosion explode0(@Nullable Entity source, @Nullable DamageSource damageSource, @Nullable ExplosionDamageCalculator damageCalculator, double x, double y, double z, float r, boolean fire, Level.ExplosionInteraction interactionType, ParticleOptions smallExplosionParticles, ParticleOptions largeExplosionParticles, WeightedList<ExplosionParticleInfo> blockParticles, Holder<SoundEvent> explosionSound) {
82+
throw new IllegalArgumentException("Not implemented");
83+
}
84+
85+
default <T extends ParticleOptions> int sendParticlesSource(ServerPlayer sender, T particle, boolean overrideLimiter, boolean alwaysShow, double x, double y, double z, int count, double xDist, double yDist, double zDist, double speed) {
86+
throw new IllegalArgumentException("Not implemented");
87+
}
88+
89+
default SavedDataStorage getWorldContainerDataStorage() {
90+
throw new IllegalArgumentException("Not implemented");
91+
}
92+
}
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
package org.teneted.neotenet.injection.world.entity;
2+
3+
import net.minecraft.server.level.ServerLevel;
4+
import net.minecraft.server.level.ServerPlayer;
5+
import net.minecraft.sounds.SoundEvent;
6+
import net.minecraft.world.entity.Entity;
7+
import net.minecraft.world.entity.Relative;
8+
import net.minecraft.world.entity.player.Player;
9+
import net.minecraft.world.level.storage.ValueInput;
10+
import net.minecraft.world.level.storage.ValueOutput;
11+
import org.bukkit.Location;
12+
import org.bukkit.craftbukkit.entity.CraftEntity;
13+
import org.bukkit.craftbukkit.event.CraftPortalEvent;
14+
import org.bukkit.event.entity.EntityRemoveEvent;
15+
import org.bukkit.event.entity.EntityUnleashEvent;
16+
import org.bukkit.event.player.PlayerTeleportEvent;
17+
import org.jetbrains.annotations.Nullable;
18+
19+
import java.util.Set;
20+
21+
public interface EntityInjection {
22+
23+
static boolean isLevelAtLeast(ValueInput tag, int level) {
24+
int updateLevel = tag.getIntOr("Bukkit.updateLevel", -1);
25+
return updateLevel != -1 && tag.getIntOr("Bukkit.updateLevel", -1) >= level;
26+
}
27+
28+
default CraftEntity getBukkitEntity() {
29+
throw new IllegalArgumentException("Not implemented");
30+
}
31+
32+
default int getDefaultMaxAirSupply() {
33+
throw new IllegalArgumentException("Not implemented");
34+
}
35+
36+
default float getBukkitYaw() {
37+
throw new IllegalArgumentException("Not implemented");
38+
}
39+
40+
default boolean isChunkLoaded() {
41+
throw new IllegalArgumentException("Not implemented");
42+
}
43+
44+
default void discard(EntityRemoveEvent.Cause cause) {
45+
throw new IllegalArgumentException("Not implemented");
46+
}
47+
48+
default void refreshEntityData(ServerPlayer to) {
49+
throw new IllegalArgumentException("Not implemented");
50+
}
51+
52+
default void remove(Entity.RemovalReason entity_removalreason, EntityRemoveEvent.Cause cause) {
53+
throw new IllegalArgumentException("Not implemented");
54+
}
55+
56+
default void postTick() {
57+
throw new IllegalArgumentException("Not implemented");
58+
}
59+
60+
default void igniteForSeconds(float numberOfSeconds, boolean callEvent) {
61+
throw new IllegalArgumentException("Not implemented");
62+
}
63+
64+
default SoundEvent getSwimSound0() {
65+
throw new IllegalArgumentException("Not implemented");
66+
}
67+
68+
default SoundEvent getSwimSplashSound0() {
69+
throw new IllegalArgumentException("Not implemented");
70+
}
71+
72+
default SoundEvent getSwimHighSpeedSplashSound0() {
73+
throw new IllegalArgumentException("Not implemented");
74+
}
75+
76+
default boolean canCollideWithBukkit(Entity entity) {
77+
throw new IllegalArgumentException("Not implemented");
78+
}
79+
80+
default boolean saveAsPassenger(ValueOutput output, boolean includeAll) {
81+
throw new IllegalArgumentException("Not implemented");
82+
}
83+
84+
default void saveWithoutId(ValueOutput output, boolean includeAll) {
85+
throw new IllegalArgumentException("Not implemented");
86+
}
87+
88+
default void addAdditionalSaveData(ValueOutput output, boolean includeAll) {
89+
throw new IllegalArgumentException("Not implemented");
90+
}
91+
92+
default boolean dropAllLeashConnections(@Nullable Player player, EntityUnleashEvent.UnleashReason reason) {
93+
throw new IllegalArgumentException("Not implemented");
94+
}
95+
96+
default CraftPortalEvent callPortalEvent(Entity entity, Location exit, PlayerTeleportEvent.TeleportCause cause, int searchRadius, int creationRadius) {
97+
throw new IllegalArgumentException("Not implemented");
98+
}
99+
100+
default boolean teleportTo(ServerLevel level, double x, double y, double z, Set<Relative> relatives, float newYRot, float newXRot, boolean resetCamera, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause cause) {
101+
throw new IllegalArgumentException("Not implemented");
102+
}
103+
104+
default void setRemoved(Entity.RemovalReason reason, EntityRemoveEvent.Cause cause) {
105+
throw new IllegalArgumentException("Not implemented");
106+
}
107+
}

src/main/resources/META-INF/accesstransformer.cfg

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -934,4 +934,5 @@ public-f net.minecraft.world.level.saveddata.maps.MapItemSavedData dimension
934934
public-f net.minecraft.world.level.saveddata.maps.MapItemSavedData locked
935935
public-f net.minecraft.world.level.saveddata.maps.MapItemSavedData scale
936936
public-f net.minecraft.world.level.saveddata.maps.MapItemSavedData trackingPosition
937-
public-f net.minecraft.world.level.saveddata.maps.MapItemSavedData unlimitedTracking
937+
public-f net.minecraft.world.level.saveddata.maps.MapItemSavedData unlimitedTracking
938+
public net.minecraft.world.level.levelgen.structure.StructurePiece SHAPE_CHECK_BLOCKS

0 commit comments

Comments
 (0)