some more directories
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
--- a/net/minecraft/network/syncher/SynchedEntityData.java
|
||||
+++ b/net/minecraft/network/syncher/SynchedEntityData.java
|
||||
@@ -45,7 +_,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
- private <T> SynchedEntityData.DataItem<T> getItem(EntityDataAccessor<T> key) {
|
||||
+ public <T> SynchedEntityData.DataItem<T> getItem(EntityDataAccessor<T> key) { // Paper - public
|
||||
return (SynchedEntityData.DataItem<T>)this.itemsById[key.id()];
|
||||
}
|
||||
|
||||
@@ -67,6 +_,13 @@
|
||||
}
|
||||
}
|
||||
|
||||
+ // CraftBukkit start - add method from above
|
||||
+ public <T> void markDirty(final EntityDataAccessor<T> entityDataAccessor) {
|
||||
+ this.getItem(entityDataAccessor).setDirty(true);
|
||||
+ this.isDirty = true;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public boolean isDirty() {
|
||||
return this.isDirty;
|
||||
}
|
||||
@@ -169,6 +_,20 @@
|
||||
return new SynchedEntityData(this.entity, this.itemsById);
|
||||
}
|
||||
}
|
||||
+
|
||||
+ // Paper start
|
||||
+ // We need to pack all as we cannot rely on "non default values" or "dirty" ones.
|
||||
+ // Because these values can possibly be desynced on the client.
|
||||
+ @Nullable
|
||||
+ public List<SynchedEntityData.DataValue<?>> packAll() {
|
||||
+ final List<SynchedEntityData.DataValue<?>> list = new ArrayList<>();
|
||||
+ for (final DataItem<?> dataItem : this.itemsById) {
|
||||
+ list.add(dataItem.value());
|
||||
+ }
|
||||
+
|
||||
+ return list;
|
||||
+ }
|
||||
+ // Paper end
|
||||
|
||||
public static class DataItem<T> {
|
||||
final EntityDataAccessor<T> accessor;
|
||||
@@ -0,0 +1,16 @@
|
||||
--- a/net/minecraft/world/entity/animal/frog/Frog.java
|
||||
+++ b/net/minecraft/world/entity/animal/frog/Frog.java
|
||||
@@ -270,7 +_,12 @@
|
||||
|
||||
@Override
|
||||
public void spawnChildFromBreeding(ServerLevel level, Animal mate) {
|
||||
- this.finalizeSpawnChildFromBreeding(level, mate, null);
|
||||
+ // Paper start - Add EntityFertilizeEggEvent event
|
||||
+ final io.papermc.paper.event.entity.EntityFertilizeEggEvent result = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityFertilizeEggEvent(this, mate);
|
||||
+ if (result.isCancelled()) return;
|
||||
+
|
||||
+ this.finalizeSpawnChildFromBreeding(level, mate, null, result.getExperience()); // Paper - use craftbukkit call that takes experience amount
|
||||
+ // Paper end - Add EntityFertilizeEggEvent event
|
||||
this.getBrain().setMemory(MemoryModuleType.IS_PREGNANT, Unit.INSTANCE);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
--- a/net/minecraft/world/entity/animal/frog/ShootTongue.java
|
||||
+++ b/net/minecraft/world/entity/animal/frog/ShootTongue.java
|
||||
@@ -96,7 +_,7 @@
|
||||
if (entity.isAlive()) {
|
||||
frog.doHurtTarget(level, entity);
|
||||
if (!entity.isAlive()) {
|
||||
- entity.remove(Entity.RemovalReason.KILLED);
|
||||
+ entity.remove(Entity.RemovalReason.KILLED, org.bukkit.event.entity.EntityRemoveEvent.Cause.DEATH); // CraftBukkit - add Bukkit remove cause
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
--- a/net/minecraft/world/entity/animal/frog/Tadpole.java
|
||||
+++ b/net/minecraft/world/entity/animal/frog/Tadpole.java
|
||||
@@ -62,6 +_,7 @@
|
||||
MemoryModuleType.BREED_TARGET,
|
||||
MemoryModuleType.IS_PANICKING
|
||||
);
|
||||
+ public boolean ageLocked; // Paper
|
||||
|
||||
public Tadpole(EntityType<? extends AbstractFish> entityType, Level level) {
|
||||
super(entityType, level);
|
||||
@@ -113,7 +_,7 @@
|
||||
@Override
|
||||
public void aiStep() {
|
||||
super.aiStep();
|
||||
- if (!this.level().isClientSide) {
|
||||
+ if (!this.level().isClientSide && !this.ageLocked) { // Paper
|
||||
this.setAge(this.age + 1);
|
||||
}
|
||||
}
|
||||
@@ -122,12 +_,14 @@
|
||||
public void addAdditionalSaveData(CompoundTag tag) {
|
||||
super.addAdditionalSaveData(tag);
|
||||
tag.putInt("Age", this.age);
|
||||
+ tag.putBoolean("AgeLocked", this.ageLocked); // Paper
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readAdditionalSaveData(CompoundTag tag) {
|
||||
super.readAdditionalSaveData(tag);
|
||||
this.setAge(tag.getInt("Age"));
|
||||
+ this.ageLocked = tag.getBoolean("AgeLocked"); // Paper
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -177,7 +_,12 @@
|
||||
@Override
|
||||
public void saveToBucketTag(ItemStack stack) {
|
||||
Bucketable.saveDefaultDataToBucketTag(this, stack);
|
||||
- CustomData.update(DataComponents.BUCKET_ENTITY_DATA, stack, compoundTag -> compoundTag.putInt("Age", this.getAge()));
|
||||
+ // Paper start - Save tadpole age
|
||||
+ CustomData.update(DataComponents.BUCKET_ENTITY_DATA, stack, compoundTag -> {
|
||||
+ compoundTag.putInt("Age", this.getAge());
|
||||
+ compoundTag.putBoolean("AgeLocked", this.ageLocked);
|
||||
+ });
|
||||
+ // Paper end - Save tadpole age
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -186,6 +_,7 @@
|
||||
if (tag.contains("Age")) {
|
||||
this.setAge(tag.getInt("Age"));
|
||||
}
|
||||
+ this.ageLocked = tag.getBoolean("AgeLocked"); // Paper
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -217,6 +_,7 @@
|
||||
}
|
||||
|
||||
private void ageUp(int offset) {
|
||||
+ if (this.ageLocked) return; // Paper
|
||||
this.setAge(this.age + offset * 20);
|
||||
}
|
||||
|
||||
@@ -229,12 +_,17 @@
|
||||
|
||||
private void ageUp() {
|
||||
if (this.level() instanceof ServerLevel serverLevel) {
|
||||
- this.convertTo(EntityType.FROG, ConversionParams.single(this, false, false), mob -> {
|
||||
+ Frog converted = this.convertTo(EntityType.FROG, ConversionParams.single(this, false, false), mob -> { // CraftBukkit
|
||||
mob.finalizeSpawn(serverLevel, this.level().getCurrentDifficultyAt(mob.blockPosition()), EntitySpawnReason.CONVERSION, null);
|
||||
mob.setPersistenceRequired();
|
||||
mob.fudgePositionAfterSizeChange(this.getDimensions(this.getPose()));
|
||||
this.playSound(SoundEvents.TADPOLE_GROW_UP, 0.15F, 1.0F);
|
||||
- });
|
||||
+ // CraftBukkit start
|
||||
+ }, org.bukkit.event.entity.EntityTransformEvent.TransformReason.METAMORPHOSIS, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.METAMORPHOSIS);
|
||||
+ if (converted == null) {
|
||||
+ this.setAge(0); // Sets the age to 0 for avoid a loop if the event is canceled
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
--- a/net/minecraft/world/level/gameevent/vibrations/VibrationSystem.java
|
||||
+++ b/net/minecraft/world/level/gameevent/vibrations/VibrationSystem.java
|
||||
@@ -214,7 +_,14 @@
|
||||
return false;
|
||||
} else {
|
||||
Vec3 vec3 = position.get();
|
||||
- if (!vibrationUser.canReceiveVibration(level, BlockPos.containing(pos), gameEvent, context)) {
|
||||
+ // CraftBukkit start
|
||||
+ boolean defaultCancel = !vibrationUser.canReceiveVibration(level, BlockPos.containing(pos), gameEvent, context);
|
||||
+ Entity entity = context.sourceEntity();
|
||||
+ org.bukkit.event.block.BlockReceiveGameEvent event1 = new org.bukkit.event.block.BlockReceiveGameEvent(org.bukkit.craftbukkit.CraftGameEvent.minecraftToBukkit(gameEvent.value()), org.bukkit.craftbukkit.block.CraftBlock.at(level, BlockPos.containing(vec3)), (entity == null) ? null : entity.getBukkitEntity());
|
||||
+ event1.setCancelled(defaultCancel);
|
||||
+ level.getCraftServer().getPluginManager().callEvent(event1);
|
||||
+ if (event1.isCancelled()) {
|
||||
+ // CraftBukkit end
|
||||
return false;
|
||||
} else if (isOccluded(level, pos, vec3)) {
|
||||
return false;
|
||||
@@ -0,0 +1,93 @@
|
||||
--- a/net/minecraft/world/level/levelgen/structure/placement/StructurePlacement.java
|
||||
+++ b/net/minecraft/world/level/levelgen/structure/placement/StructurePlacement.java
|
||||
@@ -79,14 +_,30 @@
|
||||
return this.exclusionZone;
|
||||
}
|
||||
|
||||
+ @Deprecated @io.papermc.paper.annotation.DoNotUse // Paper - Add missing structure set seed configs
|
||||
public boolean isStructureChunk(ChunkGeneratorStructureState structureState, int x, int z) {
|
||||
+ // Paper start - Add missing structure set seed configs
|
||||
+ return this.isStructureChunk(structureState, x, z, null);
|
||||
+ }
|
||||
+ public boolean isStructureChunk(ChunkGeneratorStructureState structureState, int x, int z, @org.jetbrains.annotations.Nullable net.minecraft.resources.ResourceKey<StructureSet> structureSetKey) {
|
||||
+ Integer saltOverride = null;
|
||||
+ if (structureSetKey != null) {
|
||||
+ if (structureSetKey == net.minecraft.world.level.levelgen.structure.BuiltinStructureSets.MINESHAFTS) {
|
||||
+ saltOverride = structureState.conf.mineshaftSeed;
|
||||
+ } else if (structureSetKey == net.minecraft.world.level.levelgen.structure.BuiltinStructureSets.BURIED_TREASURES) {
|
||||
+ saltOverride = structureState.conf.buriedTreasureSeed;
|
||||
+ }
|
||||
+ }
|
||||
+ // Paper end - Add missing structure set seed configs
|
||||
return this.isPlacementChunk(structureState, x, z)
|
||||
- && this.applyAdditionalChunkRestrictions(x, z, structureState.getLevelSeed())
|
||||
+ && this.applyAdditionalChunkRestrictions(x, z, structureState.getLevelSeed(), saltOverride) // Paper - Add missing structure set seed configs
|
||||
&& this.applyInteractionsWithOtherStructures(structureState, x, z);
|
||||
}
|
||||
|
||||
- public boolean applyAdditionalChunkRestrictions(int regionX, int regionZ, long levelSeed) {
|
||||
- return !(this.frequency < 1.0F) || this.frequencyReductionMethod.shouldGenerate(levelSeed, this.salt, regionX, regionZ, this.frequency);
|
||||
+ // Paper start - Add missing structure set seed configs
|
||||
+ public boolean applyAdditionalChunkRestrictions(int regionX, int regionZ, long levelSeed, @org.jetbrains.annotations.Nullable Integer saltOverride) {
|
||||
+ return !(this.frequency < 1.0F) || this.frequencyReductionMethod.shouldGenerate(levelSeed, this.salt, regionX, regionZ, this.frequency, saltOverride);
|
||||
+ // Paper end - Add missing structure set seed configs
|
||||
}
|
||||
|
||||
public boolean applyInteractionsWithOtherStructures(ChunkGeneratorStructureState structureState, int x, int z) {
|
||||
@@ -101,25 +_,31 @@
|
||||
|
||||
public abstract StructurePlacementType<?> type();
|
||||
|
||||
- private static boolean probabilityReducer(long levelSeed, int regionX, int regionZ, int salt, float probability) {
|
||||
+ private static boolean probabilityReducer(long levelSeed, int regionX, int regionZ, int salt, float probability, @org.jetbrains.annotations.Nullable Integer saltOverride) { // Paper - Add missing structure set seed configs; ignore here
|
||||
WorldgenRandom worldgenRandom = new WorldgenRandom(new LegacyRandomSource(0L));
|
||||
worldgenRandom.setLargeFeatureWithSalt(levelSeed, regionX, regionZ, salt);
|
||||
return worldgenRandom.nextFloat() < probability;
|
||||
}
|
||||
|
||||
- private static boolean legacyProbabilityReducerWithDouble(long baseSeed, int salt, int chunkX, int chunkZ, float probability) {
|
||||
+ private static boolean legacyProbabilityReducerWithDouble(long baseSeed, int salt, int chunkX, int chunkZ, float probability, @org.jetbrains.annotations.Nullable Integer saltOverride) { // Paper - Add missing structure set seed configs
|
||||
WorldgenRandom worldgenRandom = new WorldgenRandom(new LegacyRandomSource(0L));
|
||||
+ if (saltOverride == null) { // Paper - Add missing structure set seed configs
|
||||
worldgenRandom.setLargeFeatureSeed(baseSeed, chunkX, chunkZ);
|
||||
+ // Paper start - Add missing structure set seed configs
|
||||
+ } else {
|
||||
+ worldgenRandom.setLargeFeatureWithSalt(baseSeed, chunkX, chunkZ, saltOverride);
|
||||
+ }
|
||||
+ // Paper end - Add missing structure set seed configs
|
||||
return worldgenRandom.nextDouble() < probability;
|
||||
}
|
||||
|
||||
- private static boolean legacyArbitrarySaltProbabilityReducer(long levelSeed, int salt, int regionX, int regionZ, float probability) {
|
||||
+ private static boolean legacyArbitrarySaltProbabilityReducer(long levelSeed, int salt, int regionX, int regionZ, float probability, @org.jetbrains.annotations.Nullable Integer saltOverride) { // Paper - Add missing structure set seed configs
|
||||
WorldgenRandom worldgenRandom = new WorldgenRandom(new LegacyRandomSource(0L));
|
||||
- worldgenRandom.setLargeFeatureWithSalt(levelSeed, regionX, regionZ, 10387320);
|
||||
+ worldgenRandom.setLargeFeatureWithSalt(levelSeed, regionX, regionZ, saltOverride != null ? saltOverride : HIGHLY_ARBITRARY_RANDOM_SALT); // Paper - Add missing structure set seed configs
|
||||
return worldgenRandom.nextFloat() < probability;
|
||||
}
|
||||
|
||||
- private static boolean legacyPillagerOutpostReducer(long levelSeed, int salt, int regionX, int regionZ, float probability) {
|
||||
+ private static boolean legacyPillagerOutpostReducer(long levelSeed, int salt, int regionX, int regionZ, float probability, @org.jetbrains.annotations.Nullable Integer saltOverride) { // Paper - Add missing structure set seed configs; ignore here
|
||||
int i = regionX >> 4;
|
||||
int i1 = regionZ >> 4;
|
||||
WorldgenRandom worldgenRandom = new WorldgenRandom(new LegacyRandomSource(0L));
|
||||
@@ -147,7 +_,7 @@
|
||||
|
||||
@FunctionalInterface
|
||||
public interface FrequencyReducer {
|
||||
- boolean shouldGenerate(long levelSeed, int i, int salt, int regionX, float regionZ);
|
||||
+ boolean shouldGenerate(long levelSeed, int i, int salt, int regionX, float regionZ, @org.jetbrains.annotations.Nullable Integer saltOverride); // Paper - Add missing structure set seed configs
|
||||
}
|
||||
|
||||
public static enum FrequencyReductionMethod implements StringRepresentable {
|
||||
@@ -167,8 +_,8 @@
|
||||
this.reducer = reducer;
|
||||
}
|
||||
|
||||
- public boolean shouldGenerate(long levelSeed, int salt, int regionX, int regionZ, float probability) {
|
||||
- return this.reducer.shouldGenerate(levelSeed, salt, regionX, regionZ, probability);
|
||||
+ public boolean shouldGenerate(long levelSeed, int salt, int regionX, int regionZ, float probability, @org.jetbrains.annotations.Nullable Integer saltOverride) { // Paper - Add missing structure set seed configs
|
||||
+ return this.reducer.shouldGenerate(levelSeed, salt, regionX, regionZ, probability, saltOverride); // Paper - Add missing structure set seed configs
|
||||
}
|
||||
|
||||
@Override
|
||||
Reference in New Issue
Block a user