From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Bud Gidiere Date: Thu, 6 Aug 2020 19:47:50 -0500 Subject: [PATCH] Yatopia-Server-Fixes diff --git a/src/main/java/co/aikar/timings/TimingsExport.java b/src/main/java/co/aikar/timings/TimingsExport.java index 5dfa0658838c4801cdf260eae8b98163f729e5af..b67f05f290db653cf75a89e85bd3decb5044a1e0 100644 --- a/src/main/java/co/aikar/timings/TimingsExport.java +++ b/src/main/java/co/aikar/timings/TimingsExport.java @@ -231,6 +231,7 @@ public class TimingsExport extends Thread { pair("bukkit", mapAsJSON(Bukkit.spigot().getBukkitConfig(), null)), pair("paper", mapAsJSON(Bukkit.spigot().getPaperConfig(), null)), // Tuinity - add config to timings report pair("tuinity", mapAsJSON(Bukkit.spigot().getTuinityConfig(), null)) // Tuinity - add config to timings report + , pair("purpur", mapAsJSON(Bukkit.spigot().getPurpurConfig(), null)) // Purpur - add config to timings report )); new TimingsExport(listeners, parent, history).start(); diff --git a/src/main/java/co/aikar/timings/TimingsExport.java.rej b/src/main/java/co/aikar/timings/TimingsExport.java.rej deleted file mode 100644 index 572780ca665c0fb254cc7431af3dd7759a94f26c..0000000000000000000000000000000000000000 --- a/src/main/java/co/aikar/timings/TimingsExport.java.rej +++ /dev/null @@ -1,9 +0,0 @@ -diff a/src/main/java/co/aikar/timings/TimingsExport.java b/src/main/java/co/aikar/timings/TimingsExport.java (rejected hunks) -@@ -230,6 +230,7 @@ public class TimingsExport extends Thread { - pair("spigot", mapAsJSON(Bukkit.spigot().getSpigotConfig(), null)), - pair("bukkit", mapAsJSON(Bukkit.spigot().getBukkitConfig(), null)), - pair("paper", mapAsJSON(Bukkit.spigot().getPaperConfig(), null)) -+ , pair("rainforest", mapAsJSON(Bukkit.spigot().getRainforestConfig(), null)) // Rainforest - )); - - new TimingsExport(listeners, parent, history).start(); diff --git a/src/main/java/com/destroystokyo/paper/PaperCommand.java.rej b/src/main/java/com/destroystokyo/paper/PaperCommand.java.rej deleted file mode 100644 index 8f31dba6a29514aad6e74e265bf000014cd1e3c3..0000000000000000000000000000000000000000 --- a/src/main/java/com/destroystokyo/paper/PaperCommand.java.rej +++ /dev/null @@ -1,26 +0,0 @@ -diff a/src/main/java/com/destroystokyo/paper/PaperCommand.java b/src/main/java/com/destroystokyo/paper/PaperCommand.java (rejected hunks) -@@ -429,18 +439,18 @@ public class PaperCommand extends Command { - ChunkProviderServer chunkProviderServer = world.getChunkProvider(); - - Collection entities = world.entitiesById.values(); -- entities.forEach(e -> { -- MinecraftKey key = e.getMinecraftKey(); -- if (e.shouldBeRemoved) return; // Paper -+ for (Entity entity : entities) { -+ MinecraftKey key = entity.getMinecraftKey(); -+ if (entity.shouldBeRemoved) continue; - - MutablePair> info = list.computeIfAbsent(key, k -> MutablePair.of(0, Maps.newHashMap())); -- ChunkCoordIntPair chunk = new ChunkCoordIntPair(e.getChunkX(), e.getChunkZ()); -+ ChunkCoordIntPair chunk = new ChunkCoordIntPair(entity.getChunkX(), entity.getChunkZ()); - info.left++; - info.right.put(chunk, info.right.getOrDefault(chunk, 0) + 1); -- if (!chunkProviderServer.isInEntityTickingChunk(e)) { -+ if (!chunkProviderServer.isInEntityTickingChunk(entity)) { - nonEntityTicking.merge(key, Integer.valueOf(1), Integer::sum); - } -- }); -+ } - - if (names.size() == 1) { - MinecraftKey name = names.iterator().next(); diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java index 60f03502a7fd622d2de3b2da9fe8014b289f3d31..cac599c1e90b261b673acecad7517d91ccd0516a 100644 --- a/src/main/java/com/destroystokyo/paper/PaperConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java @@ -446,4 +446,9 @@ public class PaperConfig { maxPlayerAutoSavePerTick = (playerAutoSaveRate == -1 || playerAutoSaveRate > 100) ? 10 : 20; } } + + public static boolean asyncAdvancements; + private static void asyncAdvancements() { + asyncAdvancements = getBoolean("settings.async-advancements", asyncAdvancements); + } } diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java.rej b/src/main/java/com/destroystokyo/paper/PaperConfig.java.rej deleted file mode 100644 index 3a518ca973dbef44126497057c52fc248aa2ebc1..0000000000000000000000000000000000000000 --- a/src/main/java/com/destroystokyo/paper/PaperConfig.java.rej +++ /dev/null @@ -1,11 +0,0 @@ -diff a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java (rejected hunks) -@@ -435,4 +435,9 @@ public class PaperConfig { - allowPistonDuplication = getBoolean("settings.unsupported-settings.allow-piston-duplication", config.getBoolean("settings.unsupported-settings.allow-tnt-duplication", false)); - set("settings.unsupported-settings.allow-tnt-duplication", null); - } -+ -+ public static boolean asyncAdvancements; -+ private static void asyncAdvancements() { -+ asyncAdvancements = getBoolean("settings.async-advancements", asyncAdvancements); -+ } - } diff --git a/src/main/java/com/destroystokyo/paper/server/ticklist/PaperTickList.java b/src/main/java/com/destroystokyo/paper/server/ticklist/PaperTickList.java index dee9655b89d061ec8218ea2c54660c6003e8548f..253b73cfc597d4c7106d969be7b18c68166128ae 100644 --- a/src/main/java/com/destroystokyo/paper/server/ticklist/PaperTickList.java +++ b/src/main/java/com/destroystokyo/paper/server/ticklist/PaperTickList.java @@ -295,7 +295,7 @@ public final class PaperTickList extends TickListServer { // extend to avo this.shortScheduledIndex = getNextIndex(this.shortScheduledIndex, SHORT_SCHEDULE_TICK_THRESHOLD); this.timingCleanup.stopTiming(); - this.world.getMethodProfiler().exitEnter("ticking"); + //this.world.getMethodProfiler().exitEnter("ticking"); // Akarin - remove caller this.timingTicking.startTiming(); for (final NextTickListEntry toTick : this.toTickThisTick) { diff --git a/src/main/java/com/destroystokyo/paper/server/ticklist/PaperTickList.java.rej b/src/main/java/com/destroystokyo/paper/server/ticklist/PaperTickList.java.rej deleted file mode 100644 index c9fa39c5b4b013b56720e339463ffcb5fd3c13f9..0000000000000000000000000000000000000000 --- a/src/main/java/com/destroystokyo/paper/server/ticklist/PaperTickList.java.rej +++ /dev/null @@ -1,10 +0,0 @@ -diff a/src/main/java/com/destroystokyo/paper/server/ticklist/PaperTickList.java b/src/main/java/com/destroystokyo/paper/server/ticklist/PaperTickList.java (rejected hunks) -@@ -283,7 +283,7 @@ public final class PaperTickList extends TickListServer { // extend to avo - this.nextTick = this.world.getTime() + 1; - - this.timingCleanup.stopTiming(); -- this.world.getMethodProfiler().exitEnter("ticking"); -+ //this.world.getMethodProfiler().exitEnter("ticking"); // Akarin - remove caller - this.timingTicking.startTiming(); - - for (final NextTickListEntry toTick : this.toTickThisTick) { diff --git a/src/main/java/com/proximyst/rainforest/RainforestConfig.java b/src/main/java/com/proximyst/rainforest/RainforestConfig.java index e0af5eb280dfd2ef6c9a80385e1705f7231a5338..f6623032e5d4034c104aa1fc6ff4265169e462ba 100644 --- a/src/main/java/com/proximyst/rainforest/RainforestConfig.java +++ b/src/main/java/com/proximyst/rainforest/RainforestConfig.java @@ -195,7 +195,7 @@ public final class RainforestConfig { allowSandDuping = getBoolean("allow-sand-duping", allowSandDuping); } - public static String brandName = "Rainforest"; + public static String brandName = "Yatopia"; // Yatopia private static void brandName() { brandName = getString("brand-name", brandName); } diff --git a/src/main/java/de/minebench/origami/OrigamiConfig.java b/src/main/java/de/minebench/origami/OrigamiConfig.java index fe7330fabe386966c2d203a190a00a785ea21be0..be8daf986eb9c83bd5974eca78a00f717e4f5061 100644 --- a/src/main/java/de/minebench/origami/OrigamiConfig.java +++ b/src/main/java/de/minebench/origami/OrigamiConfig.java @@ -16,7 +16,7 @@ public final class OrigamiConfig { private static final Object[] EMPTY = new Object[0]; private static File configFile; - private static YamlConfiguration config; + public static YamlConfiguration config; // Yatopia private static int configVersion; public static void init(final File file) { @@ -112,6 +112,20 @@ public final class OrigamiConfig { config.addDefault("worlds.default." + path, Double.valueOf(dfl)); return config.getDouble("worlds." + worldName + "." + path, config.getDouble("worlds.default." + path, dfl)); } + + // Yatopia start + public boolean tickEmptyHoppers = true; + public int fullHopperCooldown = 128; + private void hopperOptimizations() { + tickEmptyHoppers = getBoolean("tick-empty-hoppers", tickEmptyHoppers); + fullHopperCooldown = getInt("ticks-per.full-hopper-cooldown", fullHopperCooldown); + } + + public boolean fastFeatureSearchDontLoad = false; + private void fastFeatureSearchDontLoad() { + fastFeatureSearchDontLoad = getBoolean("fast-feature-search-dont-load", false); + } + // Yatopia end } } \ No newline at end of file diff --git a/src/main/java/de/minebench/origami/OrigamiConfig.java.rej b/src/main/java/de/minebench/origami/OrigamiConfig.java.rej deleted file mode 100644 index 8428d4bd05075e86b281312fa38106882c54735b..0000000000000000000000000000000000000000 --- a/src/main/java/de/minebench/origami/OrigamiConfig.java.rej +++ /dev/null @@ -1,14 +0,0 @@ -diff a/src/main/java/de/minebench/origami/OrigamiConfig.java b/src/main/java/de/minebench/origami/OrigamiConfig.java (rejected hunks) -@@ -169,6 +169,12 @@ public final class OrigamiConfig { - Bukkit.getLogger().info("Farm detection radius: " + pigmenFarmsRadius + ", count: " + pigmenFarmsCount); - } - } -+ public boolean tickEmptyHoppers = false; -+ public int fullHopperCooldown = 128; -+ private void hopperOptimizations() { -+ tickEmptyHoppers = getBoolean("tick-empty-hoppers", tickEmptyHoppers); -+ fullHopperCooldown = getInt("ticks-per.full-hopper-cooldown", fullHopperCooldown); -+ } - } - - public static boolean teleportingOfVehiclesWithPassenger = true; diff --git a/src/main/java/net/minecraft/server/BehaviorInteractDoor.java b/src/main/java/net/minecraft/server/BehaviorInteractDoor.java index 685351f11497a33ef4ba99055fa7da3a8de18af2..dba7cbb02b16dfc6b45efea7c3dd3304693d0ac7 100644 --- a/src/main/java/net/minecraft/server/BehaviorInteractDoor.java +++ b/src/main/java/net/minecraft/server/BehaviorInteractDoor.java @@ -127,13 +127,23 @@ public class BehaviorInteractDoor extends Behavior { private static boolean a(WorldServer worldserver, EntityLiving entityliving, BlockPosition blockposition) { BehaviorController behaviorcontroller = entityliving.getBehaviorController(); - return !behaviorcontroller.hasMemory(MemoryModuleType.MOBS) ? false : (behaviorcontroller.getMemory(MemoryModuleType.MOBS).get()).stream().filter((entityliving1) -> { // CraftBukkit - decompile error - return entityliving1.getEntityType() == entityliving.getEntityType(); - }).filter((entityliving1) -> { - return blockposition.a((IPosition) entityliving1.getPositionVector(), 2.0D); - }).anyMatch((entityliving1) -> { - return b(worldserver, entityliving1, blockposition); - }); + // Yatopia start - replaced logic + if (!behaviorcontroller.hasMemory(MemoryModuleType.MOBS)) { + return false; + } + + boolean match = false; + for (EntityLiving entityliving1 : behaviorcontroller.getMemory(MemoryModuleType.MOBS).get()) { + if (entityliving1.getEntityType() == entityliving.getEntityType() && blockposition.a(entityliving1.getPositionVector(), 2.0D)) { + match = b(worldserver, entityliving1, blockposition); + if (match) { + break; + } + } + } + + return match; + // Yatopia end } private static boolean b(WorldServer worldserver, EntityLiving entityliving, BlockPosition blockposition) { diff --git a/src/main/java/net/minecraft/server/BehaviorInteractDoor.java.rej b/src/main/java/net/minecraft/server/BehaviorInteractDoor.java.rej deleted file mode 100644 index 738aa0c089e2d1f1d8ecb983d3d6351a1d4f690c..0000000000000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/BehaviorInteractDoor.java.rej +++ /dev/null @@ -1,59 +0,0 @@ -diff a/src/main/java/net/minecraft/server/BehaviorInteractDoor.java b/src/main/java/net/minecraft/server/BehaviorInteractDoor.java (rejected hunks) -@@ -2,6 +2,10 @@ package net.minecraft.server; - - import com.google.common.collect.ImmutableMap; - import com.google.common.collect.Sets; -+import org.bukkit.craftbukkit.block.CraftBlock; -+import org.bukkit.event.entity.EntityInteractEvent; -+ -+import java.util.ArrayList; - import java.util.Iterator; - import java.util.List; - import java.util.Set; -@@ -19,9 +23,12 @@ public class BehaviorInteractDoor extends Behavior { - BehaviorController behaviorcontroller = entityliving.getBehaviorController(); - PathEntity pathentity = (PathEntity) behaviorcontroller.getMemory(MemoryModuleType.PATH).get(); - List list = (List) behaviorcontroller.getMemory(MemoryModuleType.INTERACTABLE_DOORS).get(); -- List list1 = (List) pathentity.d().stream().map((pathpoint) -> { -- return new BlockPosition(pathpoint.a, pathpoint.b, pathpoint.c); -- }).collect(Collectors.toList()); -+ List result = new ArrayList<>(); -+ for (PathPoint pathpoint : pathentity.d()) { -+ BlockPosition blockPosition = new BlockPosition(pathpoint.a, pathpoint.b, pathpoint.c); -+ result.add(blockPosition); -+ } -+ List list1 = (List) result; - Set set = this.a(worldserver, list, list1); - int j = pathentity.f() - 1; - -@@ -38,7 +45,7 @@ public class BehaviorInteractDoor extends Behavior { - } - - private void a(WorldServer worldserver, List list, Set set, int i, EntityLiving entityliving, BehaviorController behaviorcontroller) { -- set.forEach((blockposition) -> { -+ for (BlockPosition blockposition : set) { - int j = list.indexOf(blockposition); - IBlockData iblockdata = worldserver.getType(blockposition); - Block block = iblockdata.getBlock(); -@@ -47,10 +54,10 @@ public class BehaviorInteractDoor extends Behavior { - boolean flag = j >= i; - - // CraftBukkit start - entities opening doors -- org.bukkit.event.entity.EntityInteractEvent event = new org.bukkit.event.entity.EntityInteractEvent(entityliving.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(entityliving.world, blockposition)); -+ EntityInteractEvent event = new EntityInteractEvent(entityliving.getBukkitEntity(), CraftBlock.at(entityliving.world, blockposition)); - entityliving.world.getServer().getPluginManager().callEvent(event); - if (event.isCancelled()) { -- return; -+ continue; - } - // CaftBukkit end - ((BlockDoor) block).setDoor(worldserver, blockposition, flag); -@@ -70,7 +77,7 @@ public class BehaviorInteractDoor extends Behavior { - } - } - -- }); -+ } - a(worldserver, list, i, entityliving, behaviorcontroller); - } - diff --git a/src/main/java/net/minecraft/server/BiomeBase.java b/src/main/java/net/minecraft/server/BiomeBase.java index bdbb716a91cd320dd9ab39ed6b7442388c92d074..51eae26e05439cfcc16a3adbb01eed35aaf3f1e3 100644 --- a/src/main/java/net/minecraft/server/BiomeBase.java +++ b/src/main/java/net/minecraft/server/BiomeBase.java @@ -516,13 +516,13 @@ public final class BiomeBase { private static final Map e; static { - Map map = new HashMap<>(); + Map map = new java.util.HashMap<>(); // Yatopia for (Precipitation biomebase_precipitation : values()) { if (map.put(biomebase_precipitation.b(), biomebase_precipitation) != null) { throw new IllegalStateException("Duplicate key"); } } - e = (Map) map; + e = map; // Yatopia } private final String f; @@ -553,13 +553,13 @@ public final class BiomeBase { private static final Map s; static { - Map map = new HashMap<>(); + Map map = new java.util.HashMap<>(); // Yatopia for (Geography biomebase_geography : values()) { if (map.put(biomebase_geography.b(), biomebase_geography) != null) { throw new IllegalStateException("Duplicate key"); } } - s = (Map) map; + s = map; // Yatopia } private final String t; diff --git a/src/main/java/net/minecraft/server/BiomeBase.java.rej b/src/main/java/net/minecraft/server/BiomeBase.java.rej deleted file mode 100644 index 96bedf79efa73874a67a7ac6c7672497f3f94f67..0000000000000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/BiomeBase.java.rej +++ /dev/null @@ -1,74 +0,0 @@ -diff a/src/main/java/net/minecraft/server/BiomeBase.java b/src/main/java/net/minecraft/server/BiomeBase.java (rejected hunks) -@@ -7,15 +7,8 @@ import com.google.common.collect.Sets; - import com.mojang.serialization.Codec; - import com.mojang.serialization.codecs.RecordCodecBuilder; - import it.unimi.dsi.fastutil.longs.Long2FloatLinkedOpenHashMap; --import java.util.Arrays; --import java.util.Collection; --import java.util.Comparator; --import java.util.Iterator; --import java.util.List; --import java.util.Map; --import java.util.Optional; --import java.util.Random; --import java.util.Set; -+ -+import java.util.*; - import java.util.function.Function; - import java.util.stream.Collectors; - import java.util.stream.Stream; -@@ -41,7 +34,14 @@ public class BiomeBase { - WorldGenSurfaceComposite.a.fieldOf("surface_builder").forGetter(biome -> biome.m), - Codec.simpleMap(WorldGenStage.Features.c, WorldGenCarverWrapper.a.listOf().promotePartial(SystemUtils.a("Carver: ", LOGGER::error)), INamable.a(WorldGenStage.Features.values())).fieldOf("carvers").forGetter(biome -> biome.q), - Codec.simpleMap((Codec) k1, WorldGenFeatureConfigured.b.listOf().promotePartial(SystemUtils.a("Feature: ", LOGGER::error)), INamable.a(WorldGenStage.Decoration.values())).fieldOf("features").forGetter(biome -> biome.r), -- StructureFeature.a.listOf().promotePartial(SystemUtils.a("Structure start: ", LOGGER::error)).fieldOf("starts").forGetter(biome -> biome.u.values().stream().sorted(Comparator.comparing(cf -> IRegistry.STRUCTURE_FEATURE.getKey(cf.b))).collect(Collectors.toList())), -+ StructureFeature.a.listOf().promotePartial(SystemUtils.a("Structure start: ", LOGGER::error)).fieldOf("starts").forGetter(biome -> { -+ List> list = new ArrayList<>(); -+ for (StructureFeature structureFeature : biome.u.values()) { -+ list.add(structureFeature); -+ } -+ list.sort(Comparator.comparing(cf -> IRegistry.STRUCTURE_FEATURE.getKey(cf.b))); -+ return list; -+ }), - Codec.simpleMap(EnumCreatureType.g, BiomeMeta.b.listOf().promotePartial(SystemUtils.a("Spawn data: ", LOGGER::error)), INamable.a(EnumCreatureType.values())).fieldOf("spawners").forGetter(biome -> biome.v), - d.a.listOf().fieldOf("climate_parameters").forGetter(biome -> biome.x), - Codec.STRING.optionalFieldOf("parent").forGetter(biome -> Optional.ofNullable(biome.l)) -@@ -159,9 +159,13 @@ public class BiomeBase { - this.m = worldgensurfacecomposite; - this.q = map; - this.r = map1; -- this.u = (Map) list.stream().collect(Collectors.toMap((structurefeature) -> { -- return structurefeature.b; -- }, Function.identity())); -+ Map, StructureFeature> result = new HashMap<>(); -+ for (StructureFeature structurefeature : list) { -+ if (result.put(structurefeature.b, structurefeature) != null) { -+ throw new IllegalStateException("Duplicate key"); -+ } -+ } -+ this.u = (Map) result; - this.v = Maps.newEnumMap(EnumCreatureType.class); this.v.putAll(map2); // Paper - this.x = list1; - this.l = (String) optional.orElse(null); // Paper - decompile fix -@@ -727,9 +749,18 @@ public class BiomeBase { - - OCEAN("ocean"), COLD("cold"), MEDIUM("medium"), WARM("warm"); - -- private static final Map e = (Map) Arrays.stream(values()).collect(Collectors.toMap(BiomeBase.EnumTemperature::a, (biomebase_enumtemperature) -> { -- return biomebase_enumtemperature; -- })); -+ private static final Map e; -+ -+ static { -+ Map map = new HashMap<>(); -+ for (EnumTemperature biomebase_enumtemperature : values()) { -+ if (map.put(biomebase_enumtemperature.a(), biomebase_enumtemperature) != null) { -+ throw new IllegalStateException("Duplicate key"); -+ } -+ } -+ e = (Map) map; -+ } -+ - private final String f; - - private EnumTemperature(String s) { diff --git a/src/main/java/net/minecraft/server/Block.java.rej b/src/main/java/net/minecraft/server/Block.java.rej deleted file mode 100644 index 4cc30faacb1ee173cbc546cc57ff4ce032024587..0000000000000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/Block.java.rej +++ /dev/null @@ -1,37 +0,0 @@ -diff a/src/main/java/net/minecraft/server/Block.java b/src/main/java/net/minecraft/server/Block.java (rejected hunks) -@@ -198,9 +198,9 @@ public class Block extends BlockBase implements IMaterial { - - public static void c(IBlockData iblockdata, World world, BlockPosition blockposition) { - if (world instanceof WorldServer) { -- a(iblockdata, (WorldServer) world, blockposition, (TileEntity) null).forEach((itemstack) -> { -+ for (ItemStack itemstack : a(iblockdata, (WorldServer) world, blockposition, (TileEntity) null)) { - a(world, blockposition, itemstack); -- }); -+ } - } - - iblockdata.dropNaturally(world, blockposition, ItemStack.b); -@@ -208,9 +208,9 @@ public class Block extends BlockBase implements IMaterial { - public static void dropNaturally(IBlockData iblockdata, World world, BlockPosition blockposition, @Nullable TileEntity tileentity) { a(iblockdata, world, blockposition, tileentity); } - public static void a(IBlockData iblockdata, World world, BlockPosition blockposition, @Nullable TileEntity tileentity) { - if (world instanceof WorldServer) { -- a(iblockdata, (WorldServer) world, blockposition, tileentity).forEach((itemstack) -> { -+ for (ItemStack itemstack : a(iblockdata, (WorldServer) world, blockposition, tileentity)) { - a(world, blockposition, itemstack); -- }); -+ } - } - - iblockdata.dropNaturally(world, blockposition, ItemStack.b); -@@ -218,9 +218,9 @@ public class Block extends BlockBase implements IMaterial { - - public static void dropItems(IBlockData iblockdata, World world, BlockPosition blockposition, @Nullable TileEntity tileentity, Entity entity, ItemStack itemstack) { - if (world instanceof WorldServer) { -- getDrops(iblockdata, (WorldServer) world, blockposition, tileentity, entity, itemstack).forEach((itemstack1) -> { -+ for (ItemStack itemstack1 : getDrops(iblockdata, (WorldServer) world, blockposition, tileentity, entity, itemstack)) { - a(world, blockposition, itemstack1); -- }); -+ } - } - - iblockdata.dropNaturally(world, blockposition, itemstack); diff --git a/src/main/java/net/minecraft/server/BlockBase.java b/src/main/java/net/minecraft/server/BlockBase.java index 4641832a2d6d4b29a3a0e635f01f398900fd2589..5dda0a2d039d194c97a11898297aafcfe391aea0 100644 --- a/src/main/java/net/minecraft/server/BlockBase.java +++ b/src/main/java/net/minecraft/server/BlockBase.java @@ -715,9 +715,14 @@ public abstract class BlockBase { } this.b = block.c(iblockdata, BlockAccessAir.INSTANCE, BlockPosition.ZERO, VoxelShapeCollision.a()); - this.c = Arrays.stream(EnumDirection.EnumAxis.values()).anyMatch((enumdirection_enumaxis) -> { - return this.b.b(enumdirection_enumaxis) < 0.0D || this.b.c(enumdirection_enumaxis) > 1.0D; - }); + boolean result = false; + for (EnumDirection.EnumAxis enumdirection_enumaxis : EnumDirection.EnumAxis.values()) { + if (this.b.b(enumdirection_enumaxis) < 0.0D || this.b.c(enumdirection_enumaxis) > 1.0D) { + result = true; + break; + } + } + this.c = result; this.j = new boolean[BlockBase.BlockData.Cache.e.length * BlockBase.BlockData.Cache.f]; EnumDirection[] aenumdirection1 = BlockBase.BlockData.Cache.e; int k = aenumdirection1.length; diff --git a/src/main/java/net/minecraft/server/BlockBase.java.rej b/src/main/java/net/minecraft/server/BlockBase.java.rej deleted file mode 100644 index 4e6f3d695d5c1a888fe73ea81e936642f3667f48..0000000000000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/BlockBase.java.rej +++ /dev/null @@ -1,19 +0,0 @@ -diff a/src/main/java/net/minecraft/server/BlockBase.java b/src/main/java/net/minecraft/server/BlockBase.java (rejected hunks) -@@ -700,9 +700,14 @@ public abstract class BlockBase { - } - - this.b = block.c(iblockdata, BlockAccessAir.INSTANCE, BlockPosition.ZERO, VoxelShapeCollision.a()); -- this.c = Arrays.stream(EnumDirection.EnumAxis.values()).anyMatch((enumdirection_enumaxis) -> { -- return this.b.b(enumdirection_enumaxis) < 0.0D || this.b.c(enumdirection_enumaxis) > 1.0D; -- }); -+ boolean result = false; -+ for (EnumDirection.EnumAxis enumdirection_enumaxis : EnumDirection.EnumAxis.values()) { -+ if (this.b.b(enumdirection_enumaxis) < 0.0D || this.b.c(enumdirection_enumaxis) > 1.0D) { -+ result = true; -+ break; -+ } -+ } -+ this.c = result; - this.d = new boolean[6]; - EnumDirection[] aenumdirection1 = f; - int k = aenumdirection1.length; diff --git a/src/main/java/net/minecraft/server/BlockPosition.java b/src/main/java/net/minecraft/server/BlockPosition.java index 2291135eaef64c403183724cb6e413cd7e472672..6fcc7ed7c129e6a33386d65b37cbba4a44e96f0f 100644 --- a/src/main/java/net/minecraft/server/BlockPosition.java +++ b/src/main/java/net/minecraft/server/BlockPosition.java @@ -56,6 +56,12 @@ public class BlockPosition extends BaseBlockPosition { this(baseblockposition.getX(), baseblockposition.getY(), baseblockposition.getZ()); } + // Yatopia start - helper method + public BlockPosition(Entity entity) { + this(entity.locX(), entity.locY(), entity.locZ()); + } + // Yatopia end + public static long getAdjacent(int baseX, int baseY, int baseZ, EnumDirection enumdirection) { return asLong(baseX + enumdirection.getAdjacentX(), baseY + enumdirection.getAdjacentY(), baseZ + enumdirection.getAdjacentZ()); } // Paper public static long a(long i, EnumDirection enumdirection) { return a(i, enumdirection.getAdjacentX(), enumdirection.getAdjacentY(), enumdirection.getAdjacentZ()); diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java index dde38e0222e658b5a841a32af3fc5153ecb02392..5af513cb052382c34e157110265f80a1a2efef15 100644 --- a/src/main/java/net/minecraft/server/ChunkProviderServer.java +++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java @@ -739,11 +739,11 @@ public class ChunkProviderServer extends IChunkProvider { if (this.a(playerchunk, l)) { GameProfilerFiller gameprofilerfiller = this.world.getMethodProfiler(); - gameprofilerfiller.enter("chunkLoad"); + //gameprofilerfiller.enter("chunkLoad"); // Akarin - remove caller chunkMapDistance.delayDistanceManagerTick = false; // Paper - ensure this is never false this.tickDistanceManager(); playerchunk = this.getChunk(k); - gameprofilerfiller.exit(); + //gameprofilerfiller.exit(); // Akarin - remove caller if (this.a(playerchunk, l)) { this.chunkMapDistance.removeTicketAtLevel(TicketType.REQUIRED_LOAD, chunkcoordintpair, l, identifier); // Tuinity throw (IllegalStateException) SystemUtils.c((Throwable) (new IllegalStateException("No chunk holder after ticket has been added"))); @@ -981,11 +981,11 @@ public class ChunkProviderServer extends IChunkProvider { player.playerNaturallySpawnedEvent = event; } // Paper end - optimize isOutisdeRange - this.world.getMethodProfiler().enter("pollingChunks"); + //this.world.getMethodProfiler().enter("pollingChunks"); // Akarin - remove caller int k = this.world.getGameRules().getInt(GameRules.RANDOM_TICK_SPEED); boolean flag2 = world.ticksPerAnimalSpawns != 0L && worlddata.getTime() % world.ticksPerAnimalSpawns == 0L; // CraftBukkit - this.world.getMethodProfiler().enter("naturalSpawnCount"); + //this.world.getMethodProfiler().enter("naturalSpawnCount"); // Akarin - remove caller this.world.timings.countNaturalMobs.startTiming(); // Paper - timings int l = this.chunkMapDistance.b(); // Paper start - per player mob spawning diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java.rej b/src/main/java/net/minecraft/server/ChunkProviderServer.java.rej deleted file mode 100644 index 7dd44fa8dc734862bf87691f1d7f4a5dae53b152..0000000000000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/ChunkProviderServer.java.rej +++ /dev/null @@ -1,29 +0,0 @@ -diff a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java (rejected hunks) -@@ -732,11 +732,11 @@ public class ChunkProviderServer extends IChunkProvider { - if (this.a(playerchunk, l)) { - GameProfilerFiller gameprofilerfiller = this.world.getMethodProfiler(); - -- gameprofilerfiller.enter("chunkLoad"); -+ //gameprofilerfiller.enter("chunkLoad"); // Akarin - remove caller - chunkMapDistance.delayDistanceManagerTick = false; // Paper - ensure this is never false - this.tickDistanceManager(); - playerchunk = this.getChunk(k); -- gameprofilerfiller.exit(); -+ //gameprofilerfiller.exit(); // Akarin - remove caller - if (this.a(playerchunk, l)) { - this.chunkMapDistance.removeTicketAtLevel(TicketType.REQUIRED_LOAD, chunkcoordintpair, l, identifier); // Tuinity - throw (IllegalStateException) SystemUtils.c(new IllegalStateException("No chunk holder after ticket has been added")); -@@ -971,11 +971,11 @@ public class ChunkProviderServer extends IChunkProvider { - player.lastEntitySpawnRadiusSquared = (double)((range << 4) * (range << 4)); // used in isOutsideRange - } - // Paper end - optimize isOutisdeRange -- this.world.getMethodProfiler().enter("pollingChunks"); -+ //this.world.getMethodProfiler().enter("pollingChunks"); // Akarin - remove caller - int k = this.world.getGameRules().getInt(GameRules.RANDOM_TICK_SPEED); - boolean flag2 = world.ticksPerAnimalSpawns != 0L && worlddata.getTime() % world.ticksPerAnimalSpawns == 0L; // CraftBukkit - -- this.world.getMethodProfiler().enter("naturalSpawnCount"); -+ //this.world.getMethodProfiler().enter("naturalSpawnCount"); // Akarin - remove caller - this.world.timings.countNaturalMobs.startTiming(); // Paper - timings - int l = this.chunkMapDistance.b(); - // Paper start - per player mob spawning diff --git a/src/main/java/net/minecraft/server/ContainerSmithing.java b/src/main/java/net/minecraft/server/ContainerSmithing.java index a575dddb262021fd68b4db1435e67a1f0768c633..35e4182282064f49f35d42776edf4b38cd4dd6ea 100644 --- a/src/main/java/net/minecraft/server/ContainerSmithing.java +++ b/src/main/java/net/minecraft/server/ContainerSmithing.java @@ -73,9 +73,12 @@ public class ContainerSmithing extends ContainerAnvilAbstract { @Override protected boolean a(ItemStack itemstack) { - return this.i.stream().anyMatch((recipesmithing) -> { - return recipesmithing.a(itemstack); - }); + for (RecipeSmithing recipesmithing : this.i) { + if (recipesmithing.a(itemstack)) { + return true; + } + } + return false; } @Override diff --git a/src/main/java/net/minecraft/server/ContainerSmithing.java.rej b/src/main/java/net/minecraft/server/ContainerSmithing.java.rej deleted file mode 100644 index 2317638f225d0ccba97020c4e739d7dea99b78db..0000000000000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/ContainerSmithing.java.rej +++ /dev/null @@ -1,17 +0,0 @@ -diff a/src/main/java/net/minecraft/server/ContainerSmithing.java b/src/main/java/net/minecraft/server/ContainerSmithing.java (rejected hunks) -@@ -70,9 +70,12 @@ public class ContainerSmithing extends ContainerAnvilAbstract { - - @Override - protected boolean a(ItemStack itemstack) { -- return this.i.stream().anyMatch((recipesmithing) -> { -- return recipesmithing.a(itemstack); -- }); -+ for (RecipeSmithing recipesmithing : this.i) { -+ if (recipesmithing.a(itemstack)) { -+ return true; -+ } -+ } -+ return false; - } - - // CraftBukkit start diff --git a/src/main/java/net/minecraft/server/CraftingManager.java b/src/main/java/net/minecraft/server/CraftingManager.java index b0b49904e9590b91743ebafb7983a392a6c95083..2cbfef98508bcb07db1ad1e5bdafc4cc2bff1393 100644 --- a/src/main/java/net/minecraft/server/CraftingManager.java +++ b/src/main/java/net/minecraft/server/CraftingManager.java @@ -124,15 +124,22 @@ public class CraftingManager extends ResourceDataJson { } public Optional> getRecipe(MinecraftKey minecraftkey) { - return this.recipes.values().stream().map((map) -> { - return map.get(minecraftkey); // CraftBukkit - decompile error - }).filter(Objects::nonNull).findFirst(); + // CraftBukkit - decompile error + for (Object2ObjectLinkedOpenHashMap> map : this.recipes.values()) { + IRecipe iRecipe = map.get(minecraftkey); + if (iRecipe != null) { + return Optional.>of(iRecipe); + } + } + return Optional.empty(); } public Collection> b() { - return (Collection) this.recipes.values().stream().flatMap((map) -> { - return map.values().stream(); - }).collect(Collectors.toSet()); + Set> set = new HashSet<>(); + for (Object2ObjectLinkedOpenHashMap> map : this.recipes.values()) { + set.addAll(map.values()); + } + return set; } public Stream d() { diff --git a/src/main/java/net/minecraft/server/CraftingManager.java.rej b/src/main/java/net/minecraft/server/CraftingManager.java.rej deleted file mode 100644 index adeca862cc3a3d1001c9d515fa2083acef0520e2..0000000000000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/CraftingManager.java.rej +++ /dev/null @@ -1,32 +0,0 @@ -diff a/src/main/java/net/minecraft/server/CraftingManager.java b/src/main/java/net/minecraft/server/CraftingManager.java (rejected hunks) -@@ -127,15 +124,24 @@ public class CraftingManager extends ResourceDataJson { - } - - public Optional> a(MinecraftKey minecraftkey) { -- return this.recipes.values().stream().map((map) -> { -- return map.get(minecraftkey); // CraftBukkit - decompile error -- }).filter(Objects::nonNull).findFirst(); -+ // CraftBukkit - decompile error -+ for (Object2ObjectLinkedOpenHashMap> map : this.recipes.values()) { -+ IRecipe iRecipe = map.get(minecraftkey); -+ if (iRecipe != null) { -+ return Optional.>of(iRecipe); -+ } -+ } -+ return Optional.empty(); - } - - public Collection> b() { -- return (Collection) this.recipes.values().stream().flatMap((map) -> { -- return map.values().stream(); -- }).collect(Collectors.toSet()); -+ Set> set = new HashSet<>(); -+ for (Object2ObjectLinkedOpenHashMap> map : this.recipes.values()) { -+ for (IRecipe iRecipe : map.values()) { -+ set.add(iRecipe); -+ } -+ } -+ return (Collection) set; - } - - public Stream d() { diff --git a/src/main/java/net/minecraft/server/DedicatedServer.java.rej b/src/main/java/net/minecraft/server/DedicatedServer.java.rej deleted file mode 100644 index 4c2d5b3e080c925d687733ec40d4fb4b22552c96..0000000000000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/DedicatedServer.java.rej +++ /dev/null @@ -1,9 +0,0 @@ -diff a/src/main/java/net/minecraft/server/DedicatedServer.java b/src/main/java/net/minecraft/server/DedicatedServer.java (rejected hunks) -@@ -170,6 +170,7 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer - com.destroystokyo.paper.PaperConfig.registerCommands(); - com.destroystokyo.paper.VersionHistoryManager.INSTANCE.getClass(); // load version history now - // Paper end -+ com.proximyst.rainforest.RainforestConfig.init((java.io.File) options.valueOf("rainforest-settings")); // Rainforest - - this.setPVP(dedicatedserverproperties.pvp); - this.setAllowFlight(dedicatedserverproperties.allowFlight); diff --git a/src/main/java/net/minecraft/server/DispenserRegistry.java.rej b/src/main/java/net/minecraft/server/DispenserRegistry.java.rej deleted file mode 100644 index 8347faf8a7ee62d27cf5eb9f285695fddadfa624..0000000000000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/DispenserRegistry.java.rej +++ /dev/null @@ -1,13 +0,0 @@ -diff a/src/main/java/net/minecraft/server/DispenserRegistry.java b/src/main/java/net/minecraft/server/DispenserRegistry.java (rejected hunks) -@@ -156,9 +156,9 @@ public class DispenserRegistry { - throw new IllegalArgumentException("Not bootstrapped"); - } else { - if (SharedConstants.d) { -- b().forEach((s) -> { -+ for (String s : b()) { - DispenserRegistry.LOGGER.error("Missing translations: " + s); -- }); -+ } - } - - AttributeDefaults.a(); diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java index e04eec35e9dfe5c77274f2e1c198f4c18a9b3167..93e1b01b97b52c53a7c912faf9bb6454ef57f340 100644 --- a/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java @@ -441,7 +441,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke public void setPosition(double d0, double d1, double d2) { this.setPositionRaw(d0, d1, d2); //this.a(this.size.a(d0, d1, d2)); // Paper - move into setPositionRaw - if (valid) ((WorldServer) world).chunkCheck(this); // CraftBukkit + if (valid && !dead) ((WorldServer) world).chunkCheck(this); // CraftBukkit // Purpur } protected void ae() { @@ -1557,6 +1557,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke return MathHelper.c(f * f + f1 * f1 + f2 * f2); } + public double getDistanceSq(Entity entity) { return getDistanceSquared(entity.locX(), entity.locY(), entity.locZ()); } // Yatopia - helper method public double getDistanceSquared(double x, double y, double z) { return h(x, y, z); } // Paper - OBFHELPER public double h(double d0, double d1, double d2) { double d3 = this.locX() - d0; @@ -2796,7 +2797,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke entity.bukkitEntity = this.getBukkitEntity(); if (this instanceof EntityInsentient) { - ((EntityInsentient) this).unleash(true, true); // Paper drop lead + ((EntityInsentient) this).unleash(true, !RainforestConfig.allowRidableChestDuping); // Paper drop lead // Rainforest } // CraftBukkit end } @@ -3028,7 +3029,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke entity.a(entity1, Entity::teleportAndSync); } - } + }); // Yatopia } } diff --git a/src/main/java/net/minecraft/server/Entity.java.rej b/src/main/java/net/minecraft/server/Entity.java.rej deleted file mode 100644 index 6bf65fd7655f888bde6a21048e6f3bfbd7b5b5d4..0000000000000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/Entity.java.rej +++ /dev/null @@ -1,10 +0,0 @@ -diff a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java (rejected hunks) -@@ -2696,7 +2698,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke - entity.bukkitEntity = this.getBukkitEntity(); - - if (this instanceof EntityInsentient) { -- ((EntityInsentient)this).unleash(true, true); // Paper drop lead -+ ((EntityInsentient)this).unleash(true, !RainforestConfig.allowRidableChestDuping); // Paper drop lead // Rainforest - } - // CraftBukkit end - } diff --git a/src/main/java/net/minecraft/server/EntityCow.java b/src/main/java/net/minecraft/server/EntityCow.java index 91731cd5fbcea9d644cfb030f55db2027cbdadff..b3b3626c706c638cc4e1278c218a5a1f1b07101e 100644 --- a/src/main/java/net/minecraft/server/EntityCow.java +++ b/src/main/java/net/minecraft/server/EntityCow.java @@ -71,11 +71,80 @@ public class EntityCow extends EntityAnimal { entityhuman.a(enumhand, itemstack1); return EnumInteractionResult.a(this.world.isClientSide); + // Purpur start - feed mushroom to change to mooshroom + } else if (world.purpurConfig.cowFeedMushrooms > 0 && getEntityType() != EntityTypes.MOOSHROOM && isMushroom(itemstack)) { + return feedMushroom(entityhuman, itemstack); + // Purpur end } else { return super.b(entityhuman, enumhand); } } + // Purpur start - feed mushroom to change to mooshroom + private int redMushroomsFed = 0; + private int brownMushroomsFed = 0; + + private boolean isMushroom(ItemStack itemstack) { + return itemstack.getItem() == Blocks.RED_MUSHROOM.getItem() || itemstack.getItem() == Blocks.BROWN_MUSHROOM.getItem(); + } + + private int incrementFeedCount(ItemStack itemstack) { + if (itemstack.getItem() == Blocks.RED_MUSHROOM.getItem()) { + return ++redMushroomsFed; + } else { + return ++brownMushroomsFed; + } + } + + private EnumInteractionResult feedMushroom(EntityHuman entityhuman, ItemStack itemstack) { + world.broadcastEntityEffect(this, (byte) 18); // hearts + playSound(SoundEffects.ENTITY_COW_MILK, 1.0F, 1.0F); + if (incrementFeedCount(itemstack) < world.purpurConfig.cowFeedMushrooms) { + if (!entityhuman.abilities.canInstantlyBuild) { + itemstack.subtract(1); + } + return EnumInteractionResult.CONSUME; // require 5 mushrooms to transform (prevents mushroom duping) + } + EntityMushroomCow mooshroom = EntityTypes.MOOSHROOM.create(world); + if (mooshroom == null) { + return EnumInteractionResult.PASS; + } + if (itemstack.getItem() == Blocks.BROWN_MUSHROOM.getItem()) { + mooshroom.setVariant(EntityMushroomCow.Type.BROWN); + } else { + mooshroom.setVariant(EntityMushroomCow.Type.RED); + } + mooshroom.setPositionRotation(this.locX(), this.locY(), this.locZ(), this.yaw, this.pitch); + mooshroom.setHealth(this.getHealth()); + mooshroom.setAge(getAge()); + mooshroom.copyPositionRotation(this); + mooshroom.setRenderYawOffset(this.getRenderYawOffset()); + mooshroom.setHeadRotation(this.getHeadRotation()); + mooshroom.lastYaw = this.lastYaw; + mooshroom.lastPitch = this.lastPitch; + if (this.hasCustomName()) { + mooshroom.setCustomName(this.getCustomName()); + } + if (CraftEventFactory.callEntityTransformEvent(this, mooshroom, org.bukkit.event.entity.EntityTransformEvent.TransformReason.INFECTION).isCancelled()) { + return EnumInteractionResult.PASS; + } + if (!new com.destroystokyo.paper.event.entity.EntityTransformedEvent(this.getBukkitEntity(), mooshroom.getBukkitEntity(), com.destroystokyo.paper.event.entity.EntityTransformedEvent.TransformedReason.INFECTED).callEvent()) { + return EnumInteractionResult.PASS; + } + this.world.addEntity(mooshroom); + this.die(); + if (!entityhuman.abilities.canInstantlyBuild) { + itemstack.subtract(1); + } + for (int i = 0; i < 15; i++) { + ((WorldServer) world).sendParticles(((WorldServer) world).players, null, Particles.HAPPY_VILLAGER, + locX() + random.nextFloat(), locY() + (random.nextFloat() * 2), locZ() + random.nextFloat(), 1, + random.nextGaussian() * 0.05D, random.nextGaussian() * 0.05D, random.nextGaussian() * 0.05D, 0, true); + } + return EnumInteractionResult.SUCCESS; + } + // Purpur end + @Override public EntityCow createChild(WorldServer worldserver, EntityAgeable entityageable) { return (EntityCow) EntityTypes.COW.a((World) worldserver); diff --git a/src/main/java/net/minecraft/server/EntityCow.java.rej b/src/main/java/net/minecraft/server/EntityCow.java.rej deleted file mode 100644 index 4143bf4423c33134beb8fe615846fde75d6d9991..0000000000000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/EntityCow.java.rej +++ /dev/null @@ -1,82 +0,0 @@ -diff a/src/main/java/net/minecraft/server/EntityCow.java b/src/main/java/net/minecraft/server/EntityCow.java (rejected hunks) -@@ -70,11 +71,80 @@ public class EntityCow extends EntityAnimal { - - entityhuman.a(enumhand, itemstack1); - return EnumInteractionResult.a(this.world.isClientSide); -+ // Purpur start - feed mushroom to change to mooshroom -+ } else if (world.purpurConfig.cowFeedMushrooms > 0 && getEntityType() != EntityTypes.MOOSHROOM && isMushroom(itemstack)) { -+ return feedMushroom(entityhuman, itemstack); -+ // Purpur end - } else { - return super.b(entityhuman, enumhand); - } - } - -+ // Purpur start - feed mushroom to change to mooshroom -+ private int redMushroomsFed = 0; -+ private int brownMushroomsFed = 0; -+ -+ private boolean isMushroom(ItemStack itemstack) { -+ return itemstack.getItem() == Blocks.RED_MUSHROOM.getItem() || itemstack.getItem() == Blocks.BROWN_MUSHROOM.getItem(); -+ } -+ -+ private int incrementFeedCount(ItemStack itemstack) { -+ if (itemstack.getItem() == Blocks.RED_MUSHROOM.getItem()) { -+ return ++redMushroomsFed; -+ } else { -+ return ++brownMushroomsFed; -+ } -+ } -+ -+ private EnumInteractionResult feedMushroom(EntityHuman entityhuman, ItemStack itemstack) { -+ world.broadcastEntityEffect(this, (byte) 18); // hearts -+ playSound(SoundEffects.ENTITY_COW_MILK, 1.0F, 1.0F); -+ if (incrementFeedCount(itemstack) < world.purpurConfig.cowFeedMushrooms) { -+ if (!entityhuman.abilities.canInstantlyBuild) { -+ itemstack.subtract(1); -+ } -+ return EnumInteractionResult.CONSUME; // require 5 mushrooms to transform (prevents mushroom duping) -+ } -+ EntityMushroomCow mooshroom = EntityTypes.MOOSHROOM.create(world); -+ if (mooshroom == null) { -+ return EnumInteractionResult.PASS; -+ } -+ if (itemstack.getItem() == Blocks.BROWN_MUSHROOM.getItem()) { -+ mooshroom.setVariant(EntityMushroomCow.Type.BROWN); -+ } else { -+ mooshroom.setVariant(EntityMushroomCow.Type.RED); -+ } -+ mooshroom.setPositionRotation(this.locX(), this.locY(), this.locZ(), this.yaw, this.pitch); -+ mooshroom.setHealth(this.getHealth()); -+ mooshroom.setAge(getAge()); -+ mooshroom.copyPositionRotation(this); -+ mooshroom.setRenderYawOffset(this.getRenderYawOffset()); -+ mooshroom.setHeadRotation(this.getHeadRotation()); -+ mooshroom.lastYaw = this.lastYaw; -+ mooshroom.lastPitch = this.lastPitch; -+ if (this.hasCustomName()) { -+ mooshroom.setCustomName(this.getCustomName()); -+ } -+ if (CraftEventFactory.callEntityTransformEvent(this, mooshroom, org.bukkit.event.entity.EntityTransformEvent.TransformReason.INFECTION).isCancelled()) { -+ return EnumInteractionResult.PASS; -+ } -+ if (!new com.destroystokyo.paper.event.entity.EntityTransformedEvent(this.getBukkitEntity(), mooshroom.getBukkitEntity(), com.destroystokyo.paper.event.entity.EntityTransformedEvent.TransformedReason.INFECTED).callEvent()) { -+ return EnumInteractionResult.PASS; -+ } -+ this.world.addEntity(mooshroom); -+ this.die(); -+ if (!entityhuman.abilities.canInstantlyBuild) { -+ itemstack.subtract(1); -+ } -+ for (int i = 0; i < 15; ++i) { -+ ((WorldServer) world).sendParticles(((WorldServer) world).players, null, Particles.HAPPY_VILLAGER, -+ locX() + random.nextFloat(), locY() + (random.nextFloat() * 2), locZ() + random.nextFloat(), 1, -+ random.nextGaussian() * 0.05D, random.nextGaussian() * 0.05D, random.nextGaussian() * 0.05D, 0, true); -+ } -+ return EnumInteractionResult.SUCCESS; -+ } -+ // Purpur end -+ - @Override - public EntityCow createChild(EntityAgeable entityageable) { - return (EntityCow) EntityTypes.COW.a(this.world); diff --git a/src/main/java/net/minecraft/server/EntityCreeper.java b/src/main/java/net/minecraft/server/EntityCreeper.java index db64e0f6a9ae2efda926ac13ce2cbb4a3baa2f6b..9e68cb9284ad1e65d0166b6eeff1e2a6da941beb 100644 --- a/src/main/java/net/minecraft/server/EntityCreeper.java +++ b/src/main/java/net/minecraft/server/EntityCreeper.java @@ -25,12 +25,12 @@ public class EntityCreeper extends EntityMonster { // Purpur start @Override - public GroupDataEntity prepare(GeneratorAccess generatoraccess, DifficultyDamageScaler difficultydamagescaler, EnumMobSpawn enummobspawn, GroupDataEntity groupdataentity, NBTTagCompound nbttagcompound) { - double chance = generatoraccess.getMinecraftWorld().purpurConfig.creeperChargedChance; + public GroupDataEntity prepare(WorldAccess worldaccess, DifficultyDamageScaler difficultydamagescaler, EnumMobSpawn enummobspawn, GroupDataEntity groupdataentity, NBTTagCompound nbttagcompound) { + double chance = worldaccess.getMinecraftWorld().purpurConfig.creeperChargedChance; if (chance > 0D && random.nextDouble() <= chance) { setPowered(true); } - return super.prepare(generatoraccess, difficultydamagescaler, enummobspawn, groupdataentity, nbttagcompound); + return super.prepare(worldaccess, difficultydamagescaler, enummobspawn, groupdataentity, nbttagcompound); } // Purpur end diff --git a/src/main/java/net/minecraft/server/EntityEnderCrystal.java b/src/main/java/net/minecraft/server/EntityEnderCrystal.java index f726a3585f8c3006bed86c45881a3e88899a53ca..653028712fb663abca95a6c7339eaa7560a4f759 100644 --- a/src/main/java/net/minecraft/server/EntityEnderCrystal.java +++ b/src/main/java/net/minecraft/server/EntityEnderCrystal.java @@ -63,7 +63,7 @@ public class EntityEnderCrystal extends Entity { } if (targetPhantom == null) { - for (EntityPhantom phantom : world.getEntitiesInAABB(EntityPhantom.class, getBoundingBox().grow(world.purpurConfig.phantomAttackedByCrystalRadius))) { + for (EntityPhantom phantom : world.getEntities(EntityPhantom.class, getBoundingBox().grow(world.purpurConfig.phantomAttackedByCrystalRadius), null)) { if (phantom.hasLineOfSight(this)) { attackPhantom(phantom); break; diff --git a/src/main/java/net/minecraft/server/EntityEnderDragon.java b/src/main/java/net/minecraft/server/EntityEnderDragon.java index 6b2c5e8d4640e19d33cbfe76d2399e6100890dbc..8b8ebffb89f11cfbc51b470e77171ea490a9aa18 100644 --- a/src/main/java/net/minecraft/server/EntityEnderDragon.java +++ b/src/main/java/net/minecraft/server/EntityEnderDragon.java @@ -839,6 +839,7 @@ public class EntityEnderDragon extends EntityInsentient implements IMonster { if (nbttagcompound.hasKey("DragonPhase")) { this.bG.setControllerPhase(DragonControllerPhase.getById(nbttagcompound.getInt("DragonPhase"))); } + if (!world.rainforestConfig.allowEnderDragonExpDuping) // Rainforest this.deathAnimationTicks = nbttagcompound.getInt("Paper.DeathTick"); // Paper } diff --git a/src/main/java/net/minecraft/server/EntityEnderDragon.java.rej b/src/main/java/net/minecraft/server/EntityEnderDragon.java.rej deleted file mode 100644 index a8d2be07d45549cf7a8ac048b44284c4c0a96686..0000000000000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/EntityEnderDragon.java.rej +++ /dev/null @@ -1,9 +0,0 @@ -diff a/src/main/java/net/minecraft/server/EntityEnderDragon.java b/src/main/java/net/minecraft/server/EntityEnderDragon.java (rejected hunks) -@@ -839,6 +839,7 @@ public class EntityEnderDragon extends EntityInsentient implements IMonster { - if (nbttagcompound.hasKey("DragonPhase")) { - this.bN.setControllerPhase(DragonControllerPhase.getById(nbttagcompound.getInt("DragonPhase"))); - } -+ if (!world.rainforestConfig.allowEnderDragonExpDuping) // Rainforest - this.deathAnimationTicks = nbttagcompound.getInt("Paper.DeathTick"); // Paper - - } diff --git a/src/main/java/net/minecraft/server/EntityFox.java b/src/main/java/net/minecraft/server/EntityFox.java index b04f061859f2db52cdefb0192883f2a7c5117fea..080635ce047d25bd76baf371298d4f45375aa681 100644 --- a/src/main/java/net/minecraft/server/EntityFox.java +++ b/src/main/java/net/minecraft/server/EntityFox.java @@ -31,9 +31,9 @@ public class EntityFox extends EntityAnimal { private static final Predicate bv = (entity) -> { return !entity.bw() && IEntitySelector.e.test(entity); }; - private PathfinderGoal bw; - private PathfinderGoal bx; - private PathfinderGoal by; + private PathfinderGoal bw; private PathfinderGoal attackAnimalGoal() { return bw; } // Purpur - OBFHELPER + private PathfinderGoal bx; private PathfinderGoal attackTurtleGoal() { return bx; } // Purpur - OBFHELPER + private PathfinderGoal by; private PathfinderGoal attackFishGoal() { return by; } // Purpur - OBFHELPER private float bz; private float bA; private float bB; @@ -221,6 +221,11 @@ public class EntityFox extends EntityAnimal { } private void initializePathFinderGoals() { + // Purpur start - do not add duplicate goals + this.targetSelector.a(attackAnimalGoal()); + this.targetSelector.a(attackTurtleGoal()); + this.targetSelector.a(attackFishGoal()); + // Purpur end if (this.getFoxType() == EntityFox.Type.RED) { this.targetSelector.a(4, this.bw); this.targetSelector.a(4, this.bx); @@ -253,6 +258,7 @@ public class EntityFox extends EntityAnimal { public void setFoxType(EntityFox.Type entityfox_type) { this.datawatcher.set(EntityFox.bo, entityfox_type.b()); + initializePathFinderGoals(); // Purpur - fix API bug not updating pathfinders on type change } private List fa() { @@ -262,6 +268,29 @@ public class EntityFox extends EntityAnimal { list.add((this.datawatcher.get(EntityFox.SECOND_TRUSTED_PLAYER)).orElse(null)); // CraftBukkit - decompile error return list; } + + // Purpur start + @Override + public EnumInteractionResult b(EntityHuman entityhuman, EnumHand enumhand) { + if (world.purpurConfig.foxTypeChangesWithTulips) { + ItemStack itemstack = entityhuman.b(enumhand); + if (getFoxType() == Type.RED && itemstack.getItem() == Items.whiteTulip()) { + setFoxType(Type.SNOW); + if (!entityhuman.abilities.canInstantlyBuild) { + itemstack.subtract(1); + } + return EnumInteractionResult.SUCCESS; + } else if (getFoxType() == Type.SNOW && itemstack.getItem() == Items.orangeTulip()) { + setFoxType(Type.RED); + if (!entityhuman.abilities.canInstantlyBuild) { + itemstack.subtract(1); + } + return EnumInteractionResult.SUCCESS; + } + } + return super.b(entityhuman, enumhand); + } + // Purpur end private void b(@Nullable UUID uuid) { if (((Optional) this.datawatcher.get(EntityFox.FIRST_TRUSTED_PLAYER)).isPresent()) { diff --git a/src/main/java/net/minecraft/server/EntityFox.java.rej b/src/main/java/net/minecraft/server/EntityFox.java.rej deleted file mode 100644 index 641f24b3e166d895d795c73d46cdc26a7d87f0df..0000000000000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/EntityFox.java.rej +++ /dev/null @@ -1,62 +0,0 @@ -diff a/src/main/java/net/minecraft/server/EntityFox.java b/src/main/java/net/minecraft/server/EntityFox.java (rejected hunks) -@@ -37,9 +37,9 @@ public class EntityFox extends EntityAnimal { - private static final Predicate bC = (entity) -> { - return !entity.bt() && IEntitySelector.e.test(entity); - }; -- private PathfinderGoal bD; -- private PathfinderGoal bE; -- private PathfinderGoal bF; -+ private PathfinderGoal bD; private PathfinderGoal attackAnimalGoal() { return bD; } // Purpur - OBFHELPER -+ private PathfinderGoal bE; private PathfinderGoal attackTurtleGoal() { return bE; } // Purpur - OBFHELPER -+ private PathfinderGoal bF; private PathfinderGoal attackFishGoal() { return bF; } // Purpur - OBFHELPER - private float bG; - private float bH; - private float bI; -@@ -227,6 +227,11 @@ public class EntityFox extends EntityAnimal { - } - - private void initializePathFinderGoals() { -+ // Purpur start - do not add duplicate goals -+ this.targetSelector.a(attackAnimalGoal()); -+ this.targetSelector.a(attackTurtleGoal()); -+ this.targetSelector.a(attackFishGoal()); -+ // Purpur end - if (this.getFoxType() == EntityFox.Type.RED) { - this.targetSelector.a(4, this.bD); - this.targetSelector.a(4, this.bE); -@@ -259,6 +264,7 @@ public class EntityFox extends EntityAnimal { - - public void setFoxType(EntityFox.Type entityfox_type) { - this.datawatcher.set(EntityFox.bv, entityfox_type.c()); -+ initializePathFinderGoals(); // Purpur - fix API bug not updating pathfinders on type change - } - - private List fb() { -@@ -575,6 +581,27 @@ public class EntityFox extends EntityAnimal { - return this.fb().contains(uuid); - } - -+ @Override -+ public EnumInteractionResult b(EntityHuman entityhuman, EnumHand enumhand) { -+ if (world.purpurConfig.foxTypeChangesWithTulips) { -+ ItemStack itemstack = entityhuman.b(enumhand); -+ if (getFoxType() == Type.RED && itemstack.getItem() == Items.whiteTulip()) { -+ setFoxType(Type.SNOW); -+ if (!entityhuman.abilities.canInstantlyBuild) { -+ itemstack.subtract(1); -+ } -+ return EnumInteractionResult.SUCCESS; -+ } else if (getFoxType() == Type.SNOW && itemstack.getItem() == Items.orangeTulip()) { -+ setFoxType(Type.RED); -+ if (!entityhuman.abilities.canInstantlyBuild) { -+ itemstack.subtract(1); -+ } -+ return EnumInteractionResult.SUCCESS; -+ } -+ } -+ return super.b(entityhuman, enumhand); -+ } -+ - @Override - protected org.bukkit.event.entity.EntityDeathEvent d(DamageSource damagesource) { // Paper - ItemStack itemstack = this.getEquipment(EnumItemSlot.MAINHAND).cloneItemStack(); // Paper diff --git a/src/main/java/net/minecraft/server/EntityGiantZombie.java b/src/main/java/net/minecraft/server/EntityGiantZombie.java index e53d22447b8978a5389f03a438faf260e41bfa0d..e7455fe56c2479a226b794354328546ce67e84cf 100644 --- a/src/main/java/net/minecraft/server/EntityGiantZombie.java +++ b/src/main/java/net/minecraft/server/EntityGiantZombie.java @@ -4,8 +4,61 @@ public class EntityGiantZombie extends EntityMonster { public EntityGiantZombie(EntityTypes entitytypes, World world) { super(entitytypes, world); + // Purpur start + setStepHeight(world.purpurConfig.giantStepHeight); + // Purpur end } + // Purpur start + @Override + protected void initPathfinder() { + if (world.purpurConfig.giantHaveAI) { + this.goalSelector.a(0, new PathfinderGoalFloat(this)); + this.goalSelector.a(7, new PathfinderGoalRandomStrollLand(this, 1.0D)); + this.goalSelector.a(8, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 16.0F)); + this.goalSelector.a(8, new PathfinderGoalRandomLookaround(this)); + this.goalSelector.a(5, new PathfinderGoalMoveTowardsRestriction(this, 1.0D)); + if (world.purpurConfig.giantHaveHostileAI) { + this.goalSelector.a(2, new PathfinderGoalMeleeAttack(this, 1.0D, false)); + this.targetSelector.a(1, new PathfinderGoalHurtByTarget(this).a(EntityPigZombie.class)); + this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget<>(this, EntityHuman.class, true)); + this.targetSelector.a(3, new PathfinderGoalNearestAttackableTarget<>(this, EntityVillager.class, false)); + this.targetSelector.a(4, new PathfinderGoalNearestAttackableTarget<>(this, EntityIronGolem.class, true)); + this.targetSelector.a(5, new PathfinderGoalNearestAttackableTarget<>(this, EntityTurtle.class, true)); + } + } + } + + @Override + public GroupDataEntity prepare(WorldAccess world, DifficultyDamageScaler difficulty, EnumMobSpawn enummobspawn, GroupDataEntity groupDataEntity, NBTTagCompound nbt) { + GroupDataEntity groupData = super.prepare(world, difficulty, enummobspawn, groupDataEntity, nbt); + getAttributeMap().getAttribute(GenericAttributes.MAX_HEALTH).setValue(world.getMinecraftWorld().purpurConfig.giantMaxHealth); + getAttributeMap().getAttribute(GenericAttributes.MOVEMENT_SPEED).setValue(world.getMinecraftWorld().purpurConfig.giantMovementSpeed); + getAttributeMap().getAttribute(GenericAttributes.ATTACK_DAMAGE).setValue(world.getMinecraftWorld().purpurConfig.giantAttackDamage); + if (groupData == null) { + setEquipmentBasedOnDifficulty(difficulty); + setEnchantmentBasedOnDifficulty(difficulty); + } + return groupData; + } + + @Override + protected void setEquipmentBasedOnDifficulty(DifficultyDamageScaler difficulty) { + super.setEquipmentBasedOnDifficulty(difficulty); + // TODO make configurable + if (random.nextFloat() < (world.getDifficulty() == EnumDifficulty.HARD ? 0.1F : 0.05F)) { + setSlot(EnumItemSlot.MAINHAND, new ItemStack(Items.IRON_SWORD)); + } + } + + @Override + public float getJumpHeight() { + // make giants jump as high as everything else relative to their size + // 1.0 makes bottom of feet about as high as their waist when they jump + return world.purpurConfig.giantJumpHeight; + } + // Purpur end + @Override protected float b(EntityPose entitypose, EntitySize entitysize) { return 10.440001F; diff --git a/src/main/java/net/minecraft/server/EntityGiantZombie.java.rej b/src/main/java/net/minecraft/server/EntityGiantZombie.java.rej deleted file mode 100644 index 5e6b776924e7dd4080ccd465f2d52f572aa556c2..0000000000000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/EntityGiantZombie.java.rej +++ /dev/null @@ -1,71 +0,0 @@ -diff a/src/main/java/net/minecraft/server/EntityGiantZombie.java b/src/main/java/net/minecraft/server/EntityGiantZombie.java (rejected hunks) -@@ -4,9 +4,68 @@ public class EntityGiantZombie extends EntityMonster { - - public EntityGiantZombie(EntityTypes entitytypes, World world) { - super(entitytypes, world); -- this.safeFallDistance = 10.0F; // Purpur -+ // Purpur start -+ this.safeFallDistance = 10.0F; -+ setStepHeight(world.purpurConfig.giantStepHeight); -+ // Purpur end - } - -+ // Purpur start -+ @Override -+ protected void initPathfinder() { -+ if (world.purpurConfig.giantHaveAI) { -+ this.goalSelector.a(0, new PathfinderGoalFloat(this)); -+ this.goalSelector.a(7, new PathfinderGoalRandomStrollLand(this, 1.0D)); -+ this.goalSelector.a(8, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 16.0F)); -+ this.goalSelector.a(8, new PathfinderGoalRandomLookaround(this)); -+ this.goalSelector.a(5, new PathfinderGoalMoveTowardsRestriction(this, 1.0D)); -+ if (world.purpurConfig.giantHaveHostileAI) { -+ this.goalSelector.a(2, new PathfinderGoalMeleeAttack(this, 1.0D, false)); -+ this.targetSelector.a(1, new PathfinderGoalHurtByTarget(this).a(EntityPigZombie.class)); -+ this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget<>(this, EntityHuman.class, true)); -+ this.targetSelector.a(3, new PathfinderGoalNearestAttackableTarget<>(this, EntityVillager.class, false)); -+ this.targetSelector.a(4, new PathfinderGoalNearestAttackableTarget<>(this, EntityIronGolem.class, true)); -+ this.targetSelector.a(5, new PathfinderGoalNearestAttackableTarget<>(this, EntityTurtle.class, true)); -+ } -+ } -+ } -+ -+ @Override -+ protected void initAttributes(World world) { -+ if (world != null) { -+ getAttributeMap().getAttribute(GenericAttributes.MAX_HEALTH).setValue(world.purpurConfig.giantMaxHealth); -+ getAttributeMap().getAttribute(GenericAttributes.MOVEMENT_SPEED).setValue(world.purpurConfig.giantMovementSpeed); -+ getAttributeMap().getAttribute(GenericAttributes.ATTACK_DAMAGE).setValue(world.purpurConfig.giantAttackDamage); -+ } -+ } -+ -+ @Override -+ public GroupDataEntity prepare(GeneratorAccess world, DifficultyDamageScaler difficulty, EnumMobSpawn enummobspawn, GroupDataEntity groupDataEntity, NBTTagCompound nbt) { -+ GroupDataEntity groupData = super.prepare(world, difficulty, enummobspawn, groupDataEntity, nbt); -+ if (groupData == null) { -+ setEquipmentBasedOnDifficulty(difficulty); -+ setEnchantmentBasedOnDifficulty(difficulty); -+ } -+ return groupData; -+ } -+ -+ @Override -+ protected void setEquipmentBasedOnDifficulty(DifficultyDamageScaler difficulty) { -+ super.setEquipmentBasedOnDifficulty(difficulty); -+ // TODO make configurable -+ if (random.nextFloat() < (world.getDifficulty() == EnumDifficulty.HARD ? 0.1F : 0.05F)) { -+ setSlot(EnumItemSlot.MAINHAND, new ItemStack(Items.IRON_SWORD)); -+ } -+ } -+ -+ @Override -+ public float getJumpHeight() { -+ // make giants jump as high as everything else relative to their size -+ // 1.0 makes bottom of feet about as high as their waist when they jump -+ return world.purpurConfig.giantJumpHeight; -+ } -+ // Purpur end -+ - @Override - protected float b(EntityPose entitypose, EntitySize entitysize) { - return 10.440001F; diff --git a/src/main/java/net/minecraft/server/EntityHoglin.java b/src/main/java/net/minecraft/server/EntityHoglin.java index cf64c8ca2c5348782bf65a13f210564856b69311..5e3094198ce5b720a17db704ab295b1cd5a99ce9 100644 --- a/src/main/java/net/minecraft/server/EntityHoglin.java +++ b/src/main/java/net/minecraft/server/EntityHoglin.java @@ -13,7 +13,7 @@ public class EntityHoglin extends EntityAnimal implements IMonster, IOglin { public int conversionTicks = 0; public boolean cannotBeHunted = false; protected static final ImmutableList>> bo = ImmutableList.of(SensorType.c, SensorType.d, SensorType.n, SensorType.m); - protected static final ImmutableList> bp = ImmutableList.of(MemoryModuleType.BREED_TARGET, MemoryModuleType.MOBS, MemoryModuleType.VISIBLE_MOBS, MemoryModuleType.NEAREST_VISIBLE_PLAYER, MemoryModuleType.NEAREST_VISIBLE_TARGETABLE_PLAYER, MemoryModuleType.LOOK_TARGET, MemoryModuleType.WALK_TARGET, MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE, MemoryModuleType.PATH, MemoryModuleType.ATTACK_TARGET, MemoryModuleType.ATTACK_COOLING_DOWN, MemoryModuleType.NEAREST_VISIBLE_ADULT_PIGLIN, new MemoryModuleType[]{MemoryModuleType.AVOID_TARGET, MemoryModuleType.VISIBLE_ADULT_PIGLIN_COUNT, MemoryModuleType.VISIBLE_ADULT_HOGLIN_COUNT, MemoryModuleType.NEAREST_VISIBLE_ADULT_HOGLINS, MemoryModuleType.NEAREST_VISIBLE_ADULY, MemoryModuleType.NEAREST_REPELLENT, MemoryModuleType.PACIFIED}); + protected static final ImmutableList> bp = ImmutableList.of(MemoryModuleType.BREED_TARGET, MemoryModuleType.MOBS, MemoryModuleType.VISIBLE_MOBS, MemoryModuleType.NEAREST_VISIBLE_PLAYER, MemoryModuleType.NEAREST_VISIBLE_TARGETABLE_PLAYER, MemoryModuleType.LOOK_TARGET, MemoryModuleType.WALK_TARGET, MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE, MemoryModuleType.PATH, MemoryModuleType.ATTACK_TARGET, MemoryModuleType.ATTACK_COOLING_DOWN, MemoryModuleType.NEAREST_VISIBLE_ADULT_PIGLIN, new MemoryModuleType[]{MemoryModuleType.AVOID_TARGET, MemoryModuleType.VISIBLE_ADULT_PIGLIN_COUNT, MemoryModuleType.VISIBLE_ADULT_HOGLIN_COUNT, MemoryModuleType.NEAREST_VISIBLE_ADULT_HOGLINS, MemoryModuleType.NEAREST_VISIBLE_ADULY, MemoryModuleType.NEAREST_REPELLENT, MemoryModuleType.PACIFIED}); // Yatopia - decompile fix public EntityHoglin(EntityTypes entitytypes, World world) { super(entitytypes, world); @@ -77,14 +77,14 @@ public class EntityHoglin extends EntityAnimal implements IMonster, IOglin { @Override public BehaviorController getBehaviorController() { - return super.getBehaviorController(); + return (BehaviorController) super.getBehaviorController(); // Yatopia - decompile fix } @Override protected void mobTick() { - this.world.getMethodProfiler().enter("hoglinBrain"); - this.getBehaviorController().a((WorldServer) this.world, (EntityLiving) this); - this.world.getMethodProfiler().exit(); + //this.world.getMethodProfiler().enter("hoglinBrain"); // Akarin - remove caller + this.getBehaviorController().a((WorldServer) this.world, this); // Yatopia - decompile fix + //this.world.getMethodProfiler().exit(); // Akarin - remove caller HoglinAI.a(this); if (this.isConverting()) { ++this.conversionTicks; @@ -259,7 +259,7 @@ public class EntityHoglin extends EntityAnimal implements IMonster, IOglin { @Override protected SoundEffect getSoundAmbient() { - return this.world.isClientSide ? null : (SoundEffect) HoglinAI.b(this).orElse((Object) null); + return this.world.isClientSide ? null : (SoundEffect) HoglinAI.b(this).orElse(null); // Yatopia - decompile fix } @Override diff --git a/src/main/java/net/minecraft/server/EntityHoglin.java.rej b/src/main/java/net/minecraft/server/EntityHoglin.java.rej deleted file mode 100644 index be7a4b07540f6cc29c9ed76668bc1eaf9850013c..0000000000000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/EntityHoglin.java.rej +++ /dev/null @@ -1,13 +0,0 @@ -diff a/src/main/java/net/minecraft/server/EntityHoglin.java b/src/main/java/net/minecraft/server/EntityHoglin.java (rejected hunks) -@@ -83,9 +83,9 @@ public class EntityHoglin extends EntityAnimal implements IMonster, IOglin { - - @Override - protected void mobTick() { -- this.world.getMethodProfiler().enter("hoglinBrain"); -+ //this.world.getMethodProfiler().enter("hoglinBrain"); // Akarin - remove caller - this.getBehaviorController().a((WorldServer) this.world, this); // CraftBukkit - decompile error -- this.world.getMethodProfiler().exit(); -+ //this.world.getMethodProfiler().exit(); // Akarin - remove caller - HoglinAI.a(this); - if (this.eO()) { - ++this.bz; diff --git a/src/main/java/net/minecraft/server/EntityIllagerIllusioner.java b/src/main/java/net/minecraft/server/EntityIllagerIllusioner.java index 7b2c459adc489702137944602627e0fc54af26e8..6b4fad730cc43bf2c70e499adbf9bf28d8d111d7 100644 --- a/src/main/java/net/minecraft/server/EntityIllagerIllusioner.java +++ b/src/main/java/net/minecraft/server/EntityIllagerIllusioner.java @@ -19,17 +19,6 @@ public class EntityIllagerIllusioner extends EntityIllagerWizard implements IRan } - // Purpur start - @Override - protected void initAttributes(World world) { - if (world != null) { - getAttributeMap().getAttribute(GenericAttributes.MOVEMENT_SPEED).setValue(world.purpurConfig.illusionerMovementSpeed); - getAttributeMap().getAttribute(GenericAttributes.FOLLOW_RANGE).setValue(world.purpurConfig.illusionerFollowRange); - getAttributeMap().getAttribute(GenericAttributes.MAX_HEALTH).setValue(world.purpurConfig.illusionerMaxHealth); - } - } - // Purpur end - @Override protected void initPathfinder() { super.initPathfinder(); @@ -54,6 +43,11 @@ public class EntityIllagerIllusioner extends EntityIllagerWizard implements IRan @Override public GroupDataEntity prepare(WorldAccess worldaccess, DifficultyDamageScaler difficultydamagescaler, EnumMobSpawn enummobspawn, @Nullable GroupDataEntity groupdataentity, @Nullable NBTTagCompound nbttagcompound) { this.setSlot(EnumItemSlot.MAINHAND, new ItemStack(Items.BOW)); + // Purpur start + getAttributeMap().getAttribute(GenericAttributes.MOVEMENT_SPEED).setValue(world.purpurConfig.illusionerMovementSpeed); + getAttributeMap().getAttribute(GenericAttributes.FOLLOW_RANGE).setValue(world.purpurConfig.illusionerFollowRange); + getAttributeMap().getAttribute(GenericAttributes.MAX_HEALTH).setValue(world.purpurConfig.illusionerMaxHealth); + // Purpur end return super.prepare(worldaccess, difficultydamagescaler, enummobspawn, groupdataentity, nbttagcompound); } diff --git a/src/main/java/net/minecraft/server/EntityInsentient.java b/src/main/java/net/minecraft/server/EntityInsentient.java index 59696d93cf546c5f43648ddde19327de6a62f18c..393a5b127b2f04cf89ff1dbcc2d9bb16a0fed9b2 100644 --- a/src/main/java/net/minecraft/server/EntityInsentient.java +++ b/src/main/java/net/minecraft/server/EntityInsentient.java @@ -53,7 +53,7 @@ public abstract class EntityInsentient extends EntityLiving { private NBTTagCompound by; private BlockPosition bz; private float bA; - + public int ticksSinceLastInteraction; // Purpur public boolean aware = true; // CraftBukkit protected EntityInsentient(EntityTypes entitytypes, World world) { @@ -242,15 +242,41 @@ public abstract class EntityInsentient extends EntityLiving { @Override public void entityBaseTick() { super.entityBaseTick(); - this.world.getMethodProfiler().enter("mobBaseTick"); + //this.world.getMethodProfiler().enter("mobBaseTick"); // Akarin - remove caller if (this.isAlive() && this.random.nextInt(1000) < this.e++) { this.m(); this.F(); } - this.world.getMethodProfiler().exit(); + incrementTicksSinceLastInteraction(); // Purpur + //this.world.getMethodProfiler().exit(); // Akarin - remove caller + } + + // Purpur start + private void incrementTicksSinceLastInteraction() { + ticksSinceLastInteraction++; + if (!getAllPassengers().isEmpty()) { + ticksSinceLastInteraction = 0; + return; + } + if (world.purpurConfig.entityLifeSpan <= 0) { + return; // feature disabled + } + if (!isTypeNotPersistent(0) || isPersistent() || isSpecialPersistence() || hasCustomName()) { + return; // mob persistent + } + if (ticksSinceLastInteraction > world.purpurConfig.entityLifeSpan) { + this.dead = true; + } } + @Override + public boolean damageEntity(DamageSource damagesource, float f) { + if (damagesource.getEntity() instanceof EntityPlayer) this.ticksSinceLastInteraction = 0; + return super.damageEntity(damagesource, f); + } + // Purpur end + @Override protected void c(DamageSource damagesource) { this.m(); @@ -754,30 +780,30 @@ public abstract class EntityInsentient extends EntityLiving { return; } // Paper end - this.world.getMethodProfiler().enter("sensing"); + //this.world.getMethodProfiler().enter("sensing"); // Akarin - remove caller this.bo.a(); - this.world.getMethodProfiler().exit(); - this.world.getMethodProfiler().enter("targetSelector"); + //this.world.getMethodProfiler().exit(); // Akarin - remove caller + //this.world.getMethodProfiler().enter("targetSelector"); // Akarin - remove caller this.targetSelector.doTick(); - this.world.getMethodProfiler().exit(); - this.world.getMethodProfiler().enter("goalSelector"); + //this.world.getMethodProfiler().exit(); // Akarin - remove caller + //this.world.getMethodProfiler().enter("goalSelector"); // Akarin - remove caller this.goalSelector.doTick(); - this.world.getMethodProfiler().exit(); - this.world.getMethodProfiler().enter("navigation"); + //this.world.getMethodProfiler().exit(); // Akarin - remove caller + //this.world.getMethodProfiler().enter("navigation"); // Akarin - remove caller this.navigation.c(); - this.world.getMethodProfiler().exit(); - this.world.getMethodProfiler().enter("mob tick"); + //this.world.getMethodProfiler().exit(); // Akarin - remove caller + //this.world.getMethodProfiler().enter("mob tick"); // Akarin - remove caller this.mobTick(); - this.world.getMethodProfiler().exit(); - this.world.getMethodProfiler().enter("controls"); - this.world.getMethodProfiler().enter("move"); + //this.world.getMethodProfiler().exit(); // Akarin - remove caller + //this.world.getMethodProfiler().enter("controls"); // Akarin - remove caller + //this.world.getMethodProfiler().enter("move"); // Akarin - remove caller this.moveController.a(); - this.world.getMethodProfiler().exitEnter("look"); + //this.world.getMethodProfiler().exitEnter("look"); // Akarin - remove caller this.lookController.a(); - this.world.getMethodProfiler().exitEnter("jump"); + //this.world.getMethodProfiler().exitEnter("jump"); // Akarin - remove caller this.bi.b(); - this.world.getMethodProfiler().exit(); - this.world.getMethodProfiler().exit(); + //this.world.getMethodProfiler().exit(); // Akarin - remove caller + //this.world.getMethodProfiler().exit(); // Akarin - remove caller this.M(); } diff --git a/src/main/java/net/minecraft/server/EntityInsentient.java.rej b/src/main/java/net/minecraft/server/EntityInsentient.java.rej deleted file mode 100644 index 75ab781ad76caedf56f0a2da3a0a4eaa4500aea7..0000000000000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/EntityInsentient.java.rej +++ /dev/null @@ -1,47 +0,0 @@ -diff a/src/main/java/net/minecraft/server/EntityInsentient.java b/src/main/java/net/minecraft/server/EntityInsentient.java (rejected hunks) -@@ -53,7 +53,7 @@ public abstract class EntityInsentient extends EntityLiving { - private NBTTagCompound bF; - private BlockPosition bG; - private float bH; -- -+ public int ticksSinceLastInteraction; // Purpur - public boolean aware = true; // CraftBukkit - - protected EntityInsentient(EntityTypes entitytypes, World world) { -@@ -246,10 +247,35 @@ public abstract class EntityInsentient extends EntityLiving { - this.eJ(); - this.F(); - } -- -+ incrementTicksSinceLastInteraction(); // Purpur - this.world.getMethodProfiler().exit(); - } - -+ // Purpur start -+ private void incrementTicksSinceLastInteraction() { -+ ++ticksSinceLastInteraction; -+ if (hasRider()) { -+ ticksSinceLastInteraction = 0; -+ return; -+ } -+ if (world.purpurConfig.entityLifeSpan <= 0) { -+ return; // feature disabled -+ } -+ if (!isTypeNotPersistent(0) || isPersistent() || isSpecialPersistence() || hasCustomName()) { -+ return; // mob persistent -+ } -+ if (ticksSinceLastInteraction > world.purpurConfig.entityLifeSpan) { -+ this.dead = true; -+ } -+ } -+ -+ @Override -+ public boolean damageEntity(DamageSource damagesource, float f) { -+ if (damagesource.getEntity() instanceof EntityPlayer) this.ticksSinceLastInteraction = 0; // Purpur -+ return super.damageEntity(damagesource, f); -+ } -+ // Purpur end -+ - @Override - protected void c(DamageSource damagesource) { - this.eJ(); diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java index fa7d210dbd4f509418402e664b55e9e567bba4cf..f24f7f1230a380f46112e886fb5dff7c33edb2ce 100644 --- a/src/main/java/net/minecraft/server/EntityLiving.java +++ b/src/main/java/net/minecraft/server/EntityLiving.java @@ -80,7 +80,7 @@ public abstract class EntityLiving extends Entity { public int maxNoDamageTicks; public final float ay; public final float az; - public float aA; + public float aA; public float getRenderYawOffset() { return this.aA; } public void setRenderYawOffset(float f) { this.aA = f; } // Purpur - OBFHELPER public float aB; public float aC; public float aD; @@ -365,7 +365,7 @@ public abstract class EntityLiving extends Entity { this.aD = this.aC; this.lastYaw = this.yaw; this.lastPitch = this.pitch; - this.world.getMethodProfiler().exit(); + //this.world.getMethodProfiler().exit(); // Akarin - remove caller } public boolean cM() { @@ -2503,10 +2503,10 @@ public abstract class EntityLiving extends Entity { } this.aK += (f3 - this.aK) * 0.3F; - this.world.getMethodProfiler().enter("headTurn"); + //this.world.getMethodProfiler().enter("headTurn"); // Akarin - remove caller f2 = this.f(f1, f2); - this.world.getMethodProfiler().exit(); - this.world.getMethodProfiler().enter("rangeChecks"); + //this.world.getMethodProfiler().exit(); // Akarin - remove caller + //this.world.getMethodProfiler().enter("rangeChecks"); // Akarin - remove caller while (this.yaw - this.lastYaw < -180.0F) { this.lastYaw -= 360.0F; @@ -2540,7 +2540,7 @@ public abstract class EntityLiving extends Entity { this.aD += 360.0F; } - this.world.getMethodProfiler().exit(); + //this.world.getMethodProfiler().exit(); // Akarin - remove caller this.aL += f2; if (this.isGliding()) { ++this.be; @@ -2741,19 +2741,19 @@ public abstract class EntityLiving extends Entity { } this.setMot(d4, d5, d6); - this.world.getMethodProfiler().enter("ai"); + //this.world.getMethodProfiler().enter("ai"); // Akarin - remove caller if (this.isFrozen()) { this.jumping = false; this.aR = 0.0F; this.aT = 0.0F; } else if (this.doAITick()) { - this.world.getMethodProfiler().enter("newAi"); + //this.world.getMethodProfiler().enter("newAi"); // Akarin - remove caller this.doTick(); - this.world.getMethodProfiler().exit(); + //this.world.getMethodProfiler().exit(); // Akarin - remove caller } - this.world.getMethodProfiler().exit(); - this.world.getMethodProfiler().enter("jump"); + //this.world.getMethodProfiler().exit(); // Akarin - remove caller + //this.world.getMethodProfiler().enter("jump"); // Akarin - remove caller if (this.jumping && this.cS()) { double d7; @@ -2780,8 +2780,8 @@ public abstract class EntityLiving extends Entity { this.jumpTicks = 0; } - this.world.getMethodProfiler().exit(); - this.world.getMethodProfiler().enter("travel"); + //this.world.getMethodProfiler().exit(); // Akarin - remove caller + //this.world.getMethodProfiler().enter("travel"); // Akarin - remove caller this.aR *= 0.98F; this.aT *= 0.98F; this.r(); @@ -2790,15 +2790,15 @@ public abstract class EntityLiving extends Entity { // SpigotTimings.timerEntityAIMove.startTiming(); // Spigot // Paper this.g(new Vec3D((double) this.aR, (double) this.aS, (double) this.aT)); // SpigotTimings.timerEntityAIMove.stopTiming(); // Spigot // Paper - this.world.getMethodProfiler().exit(); - this.world.getMethodProfiler().enter("push"); + //this.world.getMethodProfiler().exit(); // Akarin - remove caller + //this.world.getMethodProfiler().enter("push"); // Akarin - remove caller if (this.bf > 0) { --this.bf; this.a(axisalignedbb, this.getBoundingBox()); } this.collideNearby(); - this.world.getMethodProfiler().exit(); + //this.world.getMethodProfiler().exit(); // Akarin - remove caller if (!this.world.isClientSide && this.dN() && this.aF()) { this.damageEntity(DamageSource.DROWN, 1.0F); } diff --git a/src/main/java/net/minecraft/server/EntityLiving.java.rej b/src/main/java/net/minecraft/server/EntityLiving.java.rej deleted file mode 100644 index 0f120b3a48c150e4120198e0b5a49e25291ac46d..0000000000000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/EntityLiving.java.rej +++ /dev/null @@ -1,10 +0,0 @@ -diff a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java (rejected hunks) -@@ -80,7 +80,7 @@ public abstract class EntityLiving extends Entity { - public int maxNoDamageTicks; - public final float aF; - public final float aG; -- public float aH; -+ public float aH; public float getRenderYawOffset() { return this.aH; } public void setRenderYawOffset(float f) { this.aH = f; } // Purpur - OBFHELPER - public float aI; - public float aJ; - public float aK; diff --git a/src/main/java/net/minecraft/server/EntityPhantom.java b/src/main/java/net/minecraft/server/EntityPhantom.java index 7a3f41bd8d5dbee9b0b045564f1bd3e9c3d0d50b..dac7f4a76bfbbae33202142afd4d51f1a0603c82 100644 --- a/src/main/java/net/minecraft/server/EntityPhantom.java +++ b/src/main/java/net/minecraft/server/EntityPhantom.java @@ -9,9 +9,10 @@ import javax.annotation.Nullable; public class EntityPhantom extends EntityFlying implements IMonster { private static final DataWatcherObject b = DataWatcher.a(EntityPhantom.class, DataWatcherRegistry.b); - private Vec3D c; - private BlockPosition d; - private EntityPhantom.AttackPhase bo; + private Vec3D c; public void setHomeOffset(Vec3D offset) { this.c = offset; } public Vec3D getHomeOffset() { return this.c; } // Purpur - OBFHELPER + private BlockPosition d; public void setHome(BlockPosition home) { this.d = home; } public BlockPosition getHome() { return this.d; } // Purpur - OBFHELPER + private EntityPhantom.AttackPhase bo; public AttackPhase getAttackPhase() { return this.bo; } // Purpur - OBFHELPER + private Vec3D crystalPosition; // Purpur public EntityPhantom(EntityTypes entitytypes, World world) { super(entitytypes, world); @@ -239,7 +240,7 @@ public class EntityPhantom extends EntityFlying implements IMonster { @Override public boolean a() { // shouldExecute double range = maxTargetRange(); - List crystals = world.getEntitiesInAABB(EntityEnderCrystal.class, phantom.getBoundingBox().grow(range)); + List crystals = world.getEntities(EntityEnderCrystal.class, phantom.getBoundingBox().grow(range), null); if (crystals.isEmpty()) { return false; } diff --git a/src/main/java/net/minecraft/server/EntityPhantom.java.rej b/src/main/java/net/minecraft/server/EntityPhantom.java.rej deleted file mode 100644 index bf6c6ecea998206d783fe42b96f34144123d48d6..0000000000000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/EntityPhantom.java.rej +++ /dev/null @@ -1,15 +0,0 @@ -diff a/src/main/java/net/minecraft/server/EntityPhantom.java b/src/main/java/net/minecraft/server/EntityPhantom.java (rejected hunks) -@@ -9,9 +9,10 @@ import javax.annotation.Nullable; - public class EntityPhantom extends EntityFlying implements IMonster { - - private static final DataWatcherObject b = DataWatcher.a(EntityPhantom.class, DataWatcherRegistry.b); -- private Vec3D c; -- private BlockPosition d; -- private EntityPhantom.AttackPhase bv; -+ private Vec3D c; public void setHomeOffset(Vec3D offset) { this.c = offset; } public Vec3D getHomeOffset() { return this.c; } // Purpur - OBFHELPER -+ private BlockPosition d; public void setHome(BlockPosition home) { this.d = home; } public BlockPosition getHome() { return this.d; } // Purpur - OBFHELPER -+ private EntityPhantom.AttackPhase bv; public AttackPhase getAttackPhase() { return this.bv; } // Purpur - OBFHELPER -+ private Vec3D crystalPosition; // Purpur - - public EntityPhantom(EntityTypes entitytypes, World world) { - super(entitytypes, world); diff --git a/src/main/java/net/minecraft/server/EntityPigZombie.java b/src/main/java/net/minecraft/server/EntityPigZombie.java index 13a2af03fc5a511f13a9be28a813e7275448d09d..aa9687f47bf30ef13f9ab90eb3d11212b5996a90 100644 --- a/src/main/java/net/minecraft/server/EntityPigZombie.java +++ b/src/main/java/net/minecraft/server/EntityPigZombie.java @@ -103,15 +103,15 @@ public class EntityPigZombie extends EntityZombie implements IEntityAngerable { double d0 = this.b(GenericAttributes.FOLLOW_RANGE); AxisAlignedBB axisalignedbb = AxisAlignedBB.a(this.getPositionVector()).grow(d0, 10.0D, d0); - this.world.b(EntityPigZombie.class, axisalignedbb).stream().filter((entitypigzombie) -> { - return entitypigzombie != this; - }).filter((entitypigzombie) -> { - return entitypigzombie.getGoalTarget() == null; - }).filter((entitypigzombie) -> { - return !entitypigzombie.r(this.getGoalTarget()); - }).forEach((entitypigzombie) -> { - entitypigzombie.setGoalTarget(this.getGoalTarget(), org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_NEARBY_ENTITY, true); // CraftBukkit - }); + for (EntityPigZombie entitypigzombie : this.world.b(EntityPigZombie.class, axisalignedbb)) { + if (entitypigzombie != this) { + if (entitypigzombie.getGoalTarget() == null) { + if (!entitypigzombie.r(this.getGoalTarget())) { + entitypigzombie.setGoalTarget(this.getGoalTarget(), EntityTargetEvent.TargetReason.TARGET_ATTACKED_NEARBY_ENTITY, true); + } + } + } + } } private void fa() { diff --git a/src/main/java/net/minecraft/server/EntityPigZombie.java.rej b/src/main/java/net/minecraft/server/EntityPigZombie.java.rej deleted file mode 100644 index 39ea87798a00d40a1512c337b74d10c41330cc99..0000000000000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/EntityPigZombie.java.rej +++ /dev/null @@ -1,27 +0,0 @@ -diff a/src/main/java/net/minecraft/server/EntityPigZombie.java b/src/main/java/net/minecraft/server/EntityPigZombie.java (rejected hunks) -@@ -101,15 +103,16 @@ public class EntityPigZombie extends EntityZombie implements IEntityAngerable { - double d0 = this.b(GenericAttributes.FOLLOW_RANGE); - AxisAlignedBB axisalignedbb = AxisAlignedBB.a(this.getPositionVector()).grow(d0, 10.0D, d0); - -- this.world.b(EntityPigZombie.class, axisalignedbb).stream().filter((entitypigzombie) -> { -- return entitypigzombie != this; -- }).filter((entitypigzombie) -> { -- return entitypigzombie.getGoalTarget() == null; -- }).filter((entitypigzombie) -> { -- return !entitypigzombie.r(this.getGoalTarget()); -- }).forEach((entitypigzombie) -> { -- entitypigzombie.setGoalTarget(this.getGoalTarget(), org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_NEARBY_ENTITY, true); // CraftBukkit -- }); -+ // CraftBukkit -+ for (EntityPigZombie entitypigzombie : this.world.b(EntityPigZombie.class, axisalignedbb)) { -+ if (entitypigzombie != this) { -+ if (entitypigzombie.getGoalTarget() == null) { -+ if (!entitypigzombie.r(this.getGoalTarget())) { -+ entitypigzombie.setGoalTarget(this.getGoalTarget(), EntityTargetEvent.TargetReason.TARGET_ATTACKED_NEARBY_ENTITY, true); -+ } -+ } -+ } -+ } - } - - private void fb() { diff --git a/src/main/java/net/minecraft/server/EntityPiglin.java b/src/main/java/net/minecraft/server/EntityPiglin.java index e1b4330074cf3c3de31dbfcd9e1b99feb7baf669..34407b03e527891a877c2f138520200f3396631e 100644 --- a/src/main/java/net/minecraft/server/EntityPiglin.java +++ b/src/main/java/net/minecraft/server/EntityPiglin.java @@ -143,7 +143,7 @@ public class EntityPiglin extends EntityPiglinAbstract implements ICrossbow { @Override public BehaviorController getBehaviorController() { - return super.getBehaviorController(); + return (BehaviorController) super.getBehaviorController(); // Yatopia - decompile fix } @Override @@ -202,7 +202,7 @@ public class EntityPiglin extends EntityPiglinAbstract implements ICrossbow { @Override protected void mobTick() { this.world.getMethodProfiler().enter("piglinBrain"); - this.getBehaviorController().a((WorldServer) this.world, (EntityLiving) this); + this.getBehaviorController().a((WorldServer) this.world, this); // Yatopia - decompile fix this.world.getMethodProfiler().exit(); PiglinAI.b(this); super.mobTick(); @@ -341,7 +341,7 @@ public class EntityPiglin extends EntityPiglinAbstract implements ICrossbow { @Override protected SoundEffect getSoundAmbient() { - return this.world.isClientSide ? null : (SoundEffect) PiglinAI.d(this).orElse((Object) null); + return this.world.isClientSide ? null : (SoundEffect) PiglinAI.d(this).orElse(null); // Yatopia - decompile fix } @Override diff --git a/src/main/java/net/minecraft/server/EntityPiglin.java.rej b/src/main/java/net/minecraft/server/EntityPiglin.java.rej deleted file mode 100644 index d1016d22fbb2dd15042fd6ccdf2ee7848351e518..0000000000000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/EntityPiglin.java.rej +++ /dev/null @@ -1,23 +0,0 @@ -diff a/src/main/java/net/minecraft/server/EntityPiglin.java b/src/main/java/net/minecraft/server/EntityPiglin.java (rejected hunks) -@@ -63,7 +63,9 @@ public class EntityPiglin extends EntityMonster implements ICrossbow { - @Override - protected void dropDeathLoot(DamageSource damagesource, int i, boolean flag) { - super.dropDeathLoot(damagesource, i, flag); -- this.bB.f().forEach(this::a); -+ for (ItemStack itemStack : this.bB.f()) { -+ a(itemStack); -+ } - } - - protected ItemStack k(ItemStack itemstack) { -@@ -259,7 +261,9 @@ public class EntityPiglin extends EntityMonster implements ICrossbow { - - private void b(WorldServer worldserver) { - PiglinAI.c(this); -- this.bB.f().forEach(this::a); -+ for (ItemStack itemStack : this.bB.f()) { -+ a(itemStack); -+ } - EntityPigZombie entitypigzombie = (EntityPigZombie) this.b(EntityTypes.ZOMBIFIED_PIGLIN); - - entitypigzombie.addEffect(new MobEffect(MobEffects.CONFUSION, 200, 0)); diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java index 2e642b2f8bd43a9425e025c4411f3b71a2c718ce..9c60cc51b824ed1af13e4faebd755064d444ba39 100644 --- a/src/main/java/net/minecraft/server/EntityPlayer.java +++ b/src/main/java/net/minecraft/server/EntityPlayer.java @@ -136,7 +136,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting { this.playerInteractManager = playerinteractmanager; this.server = minecraftserver; this.serverStatisticManager = minecraftserver.getPlayerList().getStatisticManager(this); - this.advancementDataPlayer = minecraftserver.getPlayerList().f(this); + this.advancementDataPlayerCompletableFuture = minecraftserver.getPlayerList().loadAdvancementDataPlayerAsync(this); // Paper - async advancements this.G = 1.0F; //this.c(worldserver); // Paper - don't move to spawn on login, only first join @@ -502,6 +502,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting { CriterionTriggers.u.a(this, this.cf, this.ticksLived - this.cg); } + if (areAdvancementsLoaded()) // Paper - async advancements: don't tick advancements until they're loaded this.advancementDataPlayer.b(this); } diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java.rej b/src/main/java/net/minecraft/server/EntityPlayer.java.rej deleted file mode 100644 index aecfc8a44a764aed92b4eead845c21dfb88651fe..0000000000000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/EntityPlayer.java.rej +++ /dev/null @@ -1,18 +0,0 @@ -diff a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java (rejected hunks) -@@ -130,7 +132,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting { - this.playerInteractManager = playerinteractmanager; - this.server = minecraftserver; - this.serverStatisticManager = minecraftserver.getPlayerList().getStatisticManager(this); -- this.advancementDataPlayer = minecraftserver.getPlayerList().f(this); -+ this.advancementDataPlayerCompletableFuture = minecraftserver.getPlayerList().loadAdvancementDataPlayerAsync(this); // Paper - async advancements - this.G = 1.0F; - //this.b(worldserver); // Paper - don't move to spawn on login, only first join - -@@ -494,6 +496,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting { - CriterionTriggers.u.a(this, this.cm, this.ticksLived - this.cn); - } - -+ if (areAdvancementsLoaded()) // Paper - async advancements: don't tick advancements until they're loaded - this.advancementDataPlayer.b(this); - } - diff --git a/src/main/java/net/minecraft/server/EntityPolarBear.java b/src/main/java/net/minecraft/server/EntityPolarBear.java index ae04cc1460999d85d59ac0010d96357297a34c8b..cd6d2e07eca793ae565e1ce07d87d33da606b793 100644 --- a/src/main/java/net/minecraft/server/EntityPolarBear.java +++ b/src/main/java/net/minecraft/server/EntityPolarBear.java @@ -23,6 +23,30 @@ public class EntityPolarBear extends EntityAnimal implements IEntityAngerable { super(entitytypes, world); } + // Purpur start + @Override + public boolean mate(EntityAnimal entityanimal) { + if (entityanimal == this) { + return false; + } else if (this.isStanding()) { + return false; + } else if (this.getGoalTarget() != null) { + return false; + } else if (!(entityanimal instanceof EntityPolarBear)) { + return false; + } else { + EntityPolarBear polarbear = (EntityPolarBear) entityanimal; + if (polarbear.isStanding()) { + return false; + } + if (polarbear.getGoalTarget() != null) { + return false; + } + return this.isInLove() && polarbear.isInLove(); + } + } + // Purpur end + @Override public EntityAgeable createChild(WorldServer worldserver, EntityAgeable entityageable) { return (EntityAgeable) EntityTypes.POLAR_BEAR.a((World) worldserver); @@ -186,10 +210,12 @@ public class EntityPolarBear extends EntityAnimal implements IEntityAngerable { return flag; } + public boolean isStanding() { return eM(); } // Purpur - OBFHELPER public boolean eM() { return (Boolean) this.datawatcher.get(EntityPolarBear.bo); } + public void setStanding(boolean standing) { t(standing); } // Purpur - OBFHELPER public void t(boolean flag) { this.datawatcher.set(EntityPolarBear.bo, flag); } diff --git a/src/main/java/net/minecraft/server/EntityPolarBear.java.rej b/src/main/java/net/minecraft/server/EntityPolarBear.java.rej deleted file mode 100644 index 9091182dc2396e53ef0a571b47c0c4cc91010269..0000000000000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/EntityPolarBear.java.rej +++ /dev/null @@ -1,45 +0,0 @@ -diff a/src/main/java/net/minecraft/server/EntityPolarBear.java b/src/main/java/net/minecraft/server/EntityPolarBear.java (rejected hunks) -@@ -21,6 +21,30 @@ public class EntityPolarBear extends EntityAnimal implements IEntityAngerable { - super(entitytypes, world); - } - -+ // Purpur start -+ @Override -+ public boolean mate(EntityAnimal entityanimal) { -+ if (entityanimal == this) { -+ return false; -+ } else if (this.isStanding()) { -+ return false; -+ } else if (this.getGoalTarget() != null) { -+ return false; -+ } else if (!(entityanimal instanceof EntityPolarBear)) { -+ return false; -+ } else { -+ EntityPolarBear polarbear = (EntityPolarBear) entityanimal; -+ if (polarbear.isStanding()) { -+ return false; -+ } -+ if (polarbear.getGoalTarget() != null) { -+ return false; -+ } -+ return this.isInLove() && polarbear.isInLove(); -+ } -+ } -+ // Purpur end -+ - @Override - public EntityAgeable createChild(EntityAgeable entityageable) { - return (EntityAgeable) EntityTypes.POLAR_BEAR.a(this.world); -@@ -178,10 +208,12 @@ public class EntityPolarBear extends EntityAnimal implements IEntityAngerable { - return flag; - } - -+ public boolean isStanding() { return eN(); } // Purpur - OBFHELPER - public boolean eN() { - return (Boolean) this.datawatcher.get(EntityPolarBear.bv); - } - -+ public void setStanding(boolean standing) { t(standing); } // Purpur - OBFHELPER - public void t(boolean flag) { - this.datawatcher.set(EntityPolarBear.bv, flag); - } diff --git a/src/main/java/net/minecraft/server/EntityRabbit.java b/src/main/java/net/minecraft/server/EntityRabbit.java index 851c7c23fa476b428d188c47253f812e8fecd768..9ccc7c0d18263437e200ea132cacc5bff0ed1918 100644 --- a/src/main/java/net/minecraft/server/EntityRabbit.java +++ b/src/main/java/net/minecraft/server/EntityRabbit.java @@ -297,6 +297,10 @@ public class EntityRabbit extends EntityAnimal { if (!this.hasCustomName()) { this.setCustomName(new ChatMessage(SystemUtils.a("entity", EntityRabbit.bp))); } + // Purpur start + } else if (i == 98) { + setCustomName(new ChatMessage("Toast")); + // Purpur end } this.datawatcher.set(EntityRabbit.bo, i); diff --git a/src/main/java/net/minecraft/server/EntityRabbit.java.rej b/src/main/java/net/minecraft/server/EntityRabbit.java.rej deleted file mode 100644 index d3528571a018c6ed99298bc499410e8eb67ed3f8..0000000000000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/EntityRabbit.java.rej +++ /dev/null @@ -1,12 +0,0 @@ -diff a/src/main/java/net/minecraft/server/EntityRabbit.java b/src/main/java/net/minecraft/server/EntityRabbit.java (rejected hunks) -@@ -297,6 +297,10 @@ public class EntityRabbit extends EntityAnimal { - if (!this.hasCustomName()) { - this.setCustomName(new ChatMessage(SystemUtils.a("entity", EntityRabbit.bw))); - } -+ // Purpur start -+ } else if (i == 98) { -+ setCustomName(new ChatMessage("Toast")); -+ // Purpur end - } - - this.datawatcher.set(EntityRabbit.bv, i); diff --git a/src/main/java/net/minecraft/server/EntitySheep.java.rej b/src/main/java/net/minecraft/server/EntitySheep.java.rej deleted file mode 100644 index 1137eb4819b638cd04d630ec1692b67ec40c740f..0000000000000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/EntitySheep.java.rej +++ /dev/null @@ -1,23 +0,0 @@ -diff a/src/main/java/net/minecraft/server/EntitySheep.java b/src/main/java/net/minecraft/server/EntitySheep.java (rejected hunks) -@@ -35,9 +33,18 @@ public class EntitySheep extends EntityAnimal implements IShearable { - enummap.put(EnumColor.RED, Blocks.RED_WOOL); - enummap.put(EnumColor.BLACK, Blocks.BLACK_WOOL); - }); -- private static final Map bx = Maps.newEnumMap((Map) Arrays.stream(EnumColor.values()).collect(Collectors.toMap((enumcolor) -> { -- return enumcolor; -- }, EntitySheep::c))); -+ private static final Map bx; -+ -+ static { -+ Map map = new HashMap<>(); -+ for (EnumColor enumcolor : EnumColor.values()) { -+ if (map.put(enumcolor, c(enumcolor)) != null) { -+ throw new IllegalStateException("Duplicate key"); -+ } -+ } -+ bx = Maps.newEnumMap((Map) map); -+ } -+ - private int by; - private PathfinderGoalEatTile bz; - diff --git a/src/main/java/net/minecraft/server/EntityVillager.java b/src/main/java/net/minecraft/server/EntityVillager.java index 94842538189abd5a1df3ac208d1f145c0a3953db..d32581ec7f521ec53692517811c8e01dc405afbb 100644 --- a/src/main/java/net/minecraft/server/EntityVillager.java +++ b/src/main/java/net/minecraft/server/EntityVillager.java @@ -175,9 +175,13 @@ public class EntityVillager extends EntityVillagerAbstract implements Reputation @Override protected void mobTick() { mobTick(false); } protected void mobTick(boolean inactive) { - this.world.getMethodProfiler().enter("villagerBrain"); + //this.world.getMethodProfiler().enter("villagerBrain"); // Akarin - remove caller + // Purpur start + boolean tick = (world.getTime() + brainTickOffset) % world.purpurConfig.villagerBrainTicks == 0; + if (world.getMinecraftServer().lagging ? tick : world.purpurConfig.villagerUseBrainTicksOnlyWhenLagging || tick) + // Purpur end if (!inactive) this.getBehaviorController().a((WorldServer) this.world, this); // CraftBukkit - decompile error // Paper - this.world.getMethodProfiler().exit(); + //this.world.getMethodProfiler().exit(); // Akarin - remove caller if (this.bF) { this.bF = false; } diff --git a/src/main/java/net/minecraft/server/EntityVillager.java.rej b/src/main/java/net/minecraft/server/EntityVillager.java.rej deleted file mode 100644 index 68f0fc0230a4148ab9fc4181736ce93297c7e1b9..0000000000000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/EntityVillager.java.rej +++ /dev/null @@ -1,12 +0,0 @@ -diff a/src/main/java/net/minecraft/server/EntityVillager.java b/src/main/java/net/minecraft/server/EntityVillager.java (rejected hunks) -@@ -166,6 +168,10 @@ public class EntityVillager extends EntityVillagerAbstract implements Reputation - protected void mobTick() { mobTick(false); } - protected void mobTick(boolean inactive) { - this.world.getMethodProfiler().enter("villagerBrain"); -+ // Purpur start -+ boolean tick = (world.getTime() + brainTickOffset) % world.purpurConfig.villagerBrainTicks == 0; -+ if (((WorldServer) world).getMinecraftServer().lagging ? tick : world.purpurConfig.villagerUseBrainTicksOnlyWhenLagging || tick) -+ // Purpur end - if (!inactive) this.getBehaviorController().a((WorldServer) this.world, this); // CraftBukkit - decompile error // Paper - if (this.bM) { - this.bM = false; diff --git a/src/main/java/net/minecraft/server/EntityVillagerTrader.java b/src/main/java/net/minecraft/server/EntityVillagerTrader.java index 74c2d89af516ffc252032d5cbd12b489ea46813e..fe37627cf10fe3e5cbc5da00e154581dc1f661dc 100644 --- a/src/main/java/net/minecraft/server/EntityVillagerTrader.java +++ b/src/main/java/net/minecraft/server/EntityVillagerTrader.java @@ -20,6 +20,13 @@ public class EntityVillagerTrader extends EntityVillagerAbstract { this.attachedToPlayer = true; } + // Purpur - start + @Override + public boolean a(EntityHuman entityhuman) { + return world.purpurConfig.villagerTraderCanBeLeashed && !this.isLeashed(); + } + // Purpur - end + @Override protected void initPathfinder() { this.goalSelector.a(0, new PathfinderGoalFloat(this)); diff --git a/src/main/java/net/minecraft/server/EntityVillagerTrader.java.rej b/src/main/java/net/minecraft/server/EntityVillagerTrader.java.rej deleted file mode 100644 index c432902ff89c1cb6d8e6f8f334828b96cd76e1b6..0000000000000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/EntityVillagerTrader.java.rej +++ /dev/null @@ -1,15 +0,0 @@ -diff a/src/main/java/net/minecraft/server/EntityVillagerTrader.java b/src/main/java/net/minecraft/server/EntityVillagerTrader.java (rejected hunks) -@@ -47,6 +47,13 @@ public class EntityVillagerTrader extends EntityVillagerAbstract { - this.goalSelector.a(10, new PathfinderGoalLookAtPlayer(this, EntityInsentient.class, 8.0F)); - } - -+ // Purpur - start -+ @Override -+ public boolean a(EntityHuman entityhuman) { -+ return world.purpurConfig.villagerTraderCanBeLeashed && !this.isLeashed(); -+ } -+ // Purpur - end -+ - @Nullable - @Override - public EntityAgeable createChild(EntityAgeable entityageable) { diff --git a/src/main/java/net/minecraft/server/Explosion.java b/src/main/java/net/minecraft/server/Explosion.java index 375f974e391f0f233ad5f0bd755471ec68d7bf6d..27a67512d93e82b24175f4d1d2497faebed779f7 100644 --- a/src/main/java/net/minecraft/server/Explosion.java +++ b/src/main/java/net/minecraft/server/Explosion.java @@ -105,7 +105,7 @@ public class Explosion { int i; int j; - if (this.a || this.b != Effect.NONE) { // EMC - don't run block processing if neither flag is set + if (this.b || this.c != Effect.NONE) { // EMC - don't run block processing if neither flag is set // Yatopia - fix for (int k = 0; k < 16; ++k) { for (i = 0; i < 16; ++i) { for (j = 0; j < 16; ++j) { @@ -284,7 +284,7 @@ public class Explosion { if (!iblockdata.isAir() && iblockdata.isDestroyable()) { // Paper BlockPosition blockposition1 = blockposition.immutableCopy(); - this.world.getMethodProfiler().enter("explosion_blocks"); + //this.world.getMethodProfiler().enter("explosion_blocks"); // Akarin - remove caller if (block.a(this) && this.world instanceof WorldServer) { TileEntity tileentity = block.isTileEntity() ? this.world.getTileEntity(blockposition) : null; LootTableInfo.Builder loottableinfo_builder = (new LootTableInfo.Builder((WorldServer) this.world)).a(this.world.random).set(LootContextParameters.ORIGIN, Vec3D.a((BaseBlockPosition) blockposition)).set(LootContextParameters.TOOL, ItemStack.b).setOptional(LootContextParameters.BLOCK_ENTITY, tileentity).setOptional(LootContextParameters.THIS_ENTITY, this.source); diff --git a/src/main/java/net/minecraft/server/Explosion.java.rej b/src/main/java/net/minecraft/server/Explosion.java.rej deleted file mode 100644 index 98a910fa6bfc9542b1d1cb56b6621809acd6b279..0000000000000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/Explosion.java.rej +++ /dev/null @@ -1,10 +0,0 @@ -diff a/src/main/java/net/minecraft/server/Explosion.java b/src/main/java/net/minecraft/server/Explosion.java (rejected hunks) -@@ -281,7 +281,7 @@ public class Explosion { - if (!iblockdata.isAir() && iblockdata.isDestroyable()) { // Paper - BlockPosition blockposition1 = blockposition.immutableCopy(); - -- this.world.getMethodProfiler().enter("explosion_blocks"); -+ //this.world.getMethodProfiler().enter("explosion_blocks"); // Akarin - remove caller - if (block.a(this) && this.world instanceof WorldServer) { - TileEntity tileentity = block.isTileEntity() ? this.world.getTileEntity(blockposition) : null; - LootTableInfo.Builder loottableinfo_builder = (new LootTableInfo.Builder((WorldServer) this.world)).a(this.world.random).set(LootContextParameters.POSITION, blockposition).set(LootContextParameters.TOOL, ItemStack.b).setOptional(LootContextParameters.BLOCK_ENTITY, tileentity).setOptional(LootContextParameters.THIS_ENTITY, this.source); diff --git a/src/main/java/net/minecraft/server/LightEngineThreaded.java.rej b/src/main/java/net/minecraft/server/LightEngineThreaded.java.rej deleted file mode 100644 index 74d10212e547adf96762155adb03c0158df00a16..0000000000000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/LightEngineThreaded.java.rej +++ /dev/null @@ -1,18 +0,0 @@ -diff a/src/main/java/net/minecraft/server/LightEngineThreaded.java b/src/main/java/net/minecraft/server/LightEngineThreaded.java (rejected hunks) -@@ -288,10 +288,14 @@ public class LightEngineThreaded extends LightEngine implements AutoCloseable { - int i = Math.min(queue.size(), 4); - boolean ran = false; - while (i-- > 0 && queue.poll(pre, post)) { -- pre.forEach(Runnable::run); -+ for (Runnable runnable1 : pre) { -+ runnable1.run(); -+ } - pre.clear(); - super.a(Integer.MAX_VALUE, true, true); -- post.forEach(Runnable::run); -+ for (Runnable runnable : post) { -+ runnable.run(); -+ } - post.clear(); - ran = true; - } diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java index 916053321ab4ec0065e954aca1537b4a5e5dfa6c..fb5d581fa1ded44fb87fad8fcb4994955c2e4a94 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -999,7 +999,13 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant> { } // Paper end + // Purpur start + private static final int MAX_PER_TICK = 3; // max joins per tick + private static int lastHit = 0; // unused for now + public static int thisTick; // current tick counter + private static int loginsThisTick = 0; + private static int currTick; + // Purpur end public void a() { + // Purpur start + if (currTick != thisTick) { + currTick = thisTick; + loginsThisTick = 0; + } + // Purpur end this.p(); if (this.packetListener instanceof LoginListener) { - ((LoginListener) this.packetListener).tick(); + // Purpur start + if (((LoginListener) this.packetListener).getLoginState() != LoginListener.EnumProtocolState.READY_TO_ACCEPT + || (thisTick > lastHit + 10 || loginsThisTick++ < MAX_PER_TICK)) { + ((LoginListener) this.packetListener).tick(); + } + // Purpur end } if (this.packetListener instanceof PlayerConnection) { diff --git a/src/main/java/net/minecraft/server/NetworkManager.java.rej b/src/main/java/net/minecraft/server/NetworkManager.java.rej deleted file mode 100644 index 8ac9dfb13e32d5304dd925ed97facbf962e2a7b5..0000000000000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/NetworkManager.java.rej +++ /dev/null @@ -1,27 +0,0 @@ -diff a/src/main/java/net/minecraft/server/NetworkManager.java b/src/main/java/net/minecraft/server/NetworkManager.java (rejected hunks) -@@ -412,10 +412,24 @@ public class NetworkManager extends SimpleChannelInboundHandler> { - } - // Paper end - -+ private static final int MAX_PER_TICK = 3; // max joins per tick -+ private static int lastHit = 0; // unused for now -+ public static int thisTick; // current tick counter -+ private static int loginsThisTick = 0; -+ private static int currTick; - public void a() { -+ if (currTick != thisTick) { -+ currTick = thisTick; -+ loginsThisTick = 0; -+ } -+ - this.o(); - if (this.packetListener instanceof LoginListener) { -- ((LoginListener) this.packetListener).tick(); -+ if ( ((LoginListener) this.packetListener).getLoginState() != LoginListener.EnumProtocolState.READY_TO_ACCEPT -+ || (thisTick > lastHit + 10 || loginsThisTick++ < MAX_PER_TICK) -+ ) { -+ ((LoginListener) this.packetListener).tick(); -+ } - } - - if (this.packetListener instanceof PlayerConnection) { diff --git a/src/main/java/net/minecraft/server/PiglinAI.java b/src/main/java/net/minecraft/server/PiglinAI.java index 0407fa1751d89a037da8cb01f5ceef9b9833dd18..65abc7fbddf78662c4eb2a918848f775a0cd2eb0 100644 --- a/src/main/java/net/minecraft/server/PiglinAI.java +++ b/src/main/java/net/minecraft/server/PiglinAI.java @@ -359,16 +359,17 @@ public class PiglinAI { public static void a(EntityHuman entityhuman, boolean flag) { List list = entityhuman.world.a(EntityPiglin.class, entityhuman.getBoundingBox().g(16.0D)); // CraftBukkit - decompile error - list.stream().filter(PiglinAI::d).filter((entitypiglin) -> { - return !flag || BehaviorUtil.c(entitypiglin, entityhuman); - }).forEach((entitypiglin) -> { - if (entitypiglin.world.getGameRules().getBoolean(GameRules.UNIVERSAL_ANGER)) { - d((EntityPiglinAbstract) entitypiglin, (EntityLiving) entityhuman); - } else { - c((EntityPiglinAbstract) entitypiglin, (EntityLiving) entityhuman); + for (EntityPiglinAbstract entitypiglin : list) { + if (d(entitypiglin)) { + if (!flag || BehaviorUtil.c(entitypiglin, entityhuman)) { + if (entitypiglin.world.getGameRules().getBoolean(GameRules.UNIVERSAL_ANGER)) { + d(entitypiglin, entityhuman); + } else { + c(entitypiglin, entityhuman); + } + } } - - }); + } } public static EnumInteractionResult a(EntityPiglin entitypiglin, EntityHuman entityhuman, EnumHand enumhand) { @@ -460,9 +461,13 @@ public class PiglinAI { } protected static boolean e(EntityPiglin entitypiglin) { - return entitypiglin.getBehaviorController().hasMemory(MemoryModuleType.HUNTED_RECENTLY) || m(entitypiglin).stream().anyMatch((entitypiglinabstract) -> { - return entitypiglinabstract.getBehaviorController().hasMemory(MemoryModuleType.HUNTED_RECENTLY); - }); + if (entitypiglin.getBehaviorController().hasMemory(MemoryModuleType.HUNTED_RECENTLY)) return true; + for (EntityPiglinAbstract entitypiglin1 : m(entitypiglin)) { + if (entitypiglin1.getBehaviorController().hasMemory(MemoryModuleType.HUNTED_RECENTLY)) { + return true; + } + } + return false; } private static List m(EntityPiglin entitypiglin) { diff --git a/src/main/java/net/minecraft/server/PiglinAI.java.rej b/src/main/java/net/minecraft/server/PiglinAI.java.rej deleted file mode 100644 index c15111ef7bbb8f71d1b5e5ce812f4526746a3651..0000000000000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/PiglinAI.java.rej +++ /dev/null @@ -1,90 +0,0 @@ -diff a/src/main/java/net/minecraft/server/PiglinAI.java b/src/main/java/net/minecraft/server/PiglinAI.java (rejected hunks) -@@ -358,16 +358,18 @@ public class PiglinAI { - public static void a(EntityHuman entityhuman, boolean flag) { - List list = entityhuman.world.a(EntityPiglin.class, entityhuman.getBoundingBox().g(16.0D)); - -- list.stream().filter(PiglinAI::k).filter((entitypiglin) -> { -- return !flag || BehaviorUtil.c(entitypiglin, entityhuman); -- }).forEach((entitypiglin) -> { -- if (entitypiglin.world.getGameRules().getBoolean(GameRules.UNIVERSAL_ANGER)) { -- f(entitypiglin, entityhuman); -- } else { -- c(entitypiglin, (EntityLiving) entityhuman); -- } -+ for (EntityPiglin entitypiglin : list) { -+ if (k(entitypiglin)) { -+ if (!flag || BehaviorUtil.c(entitypiglin, entityhuman)) { -+ if (entitypiglin.world.getGameRules().getBoolean(GameRules.UNIVERSAL_ANGER)) { -+ f(entitypiglin, entityhuman); -+ } else { -+ c(entitypiglin, entityhuman); -+ } - -- }); -+ } -+ } -+ } - } - - public static EnumInteractionResult a(EntityPiglin entitypiglin, EntityHuman entityhuman, EnumHand enumhand) { -@@ -459,9 +461,13 @@ public class PiglinAI { - } - - protected static boolean e(EntityPiglin entitypiglin) { -- return entitypiglin.getBehaviorController().hasMemory(MemoryModuleType.HUNTED_RECENTLY) || q(entitypiglin).stream().anyMatch((entitypiglin1) -> { -- return entitypiglin1.getBehaviorController().hasMemory(MemoryModuleType.HUNTED_RECENTLY); -- }); -+ if (entitypiglin.getBehaviorController().hasMemory(MemoryModuleType.HUNTED_RECENTLY)) return true; -+ for (EntityPiglin entitypiglin1 : q(entitypiglin)) { -+ if (entitypiglin1.getBehaviorController().hasMemory(MemoryModuleType.HUNTED_RECENTLY)) { -+ return true; -+ } -+ } -+ return false; - } - - private static List q(EntityPiglin entitypiglin) { -@@ -501,23 +507,25 @@ public class PiglinAI { - } - - protected static void b(EntityPiglin entitypiglin, EntityLiving entityliving) { -- r(entitypiglin).forEach((entitypiglin1) -> { -+ for (EntityPiglin entitypiglin1 : r(entitypiglin)) { - if (entityliving.getEntityType() != EntityTypes.HOGLIN || entitypiglin1.eN() && ((EntityHoglin) entityliving).eP()) { - g(entitypiglin1, entityliving); - } -- }); -+ } - } - - protected static void f(EntityPiglin entitypiglin) { -- r(entitypiglin).forEach((entitypiglin1) -> { -+ for (EntityPiglin entitypiglin1 : r(entitypiglin)) { - i(entitypiglin1).ifPresent((entityhuman) -> { -- c(entitypiglin1, (EntityLiving) entityhuman); -+ c(entitypiglin1, entityhuman); - }); -- }); -+ } - } - - protected static void g(EntityPiglin entitypiglin) { -- q(entitypiglin).forEach(PiglinAI::j); -+ for (EntityPiglin entityPiglin : q(entitypiglin)) { -+ j(entityPiglin); -+ } - } - - protected static void c(EntityPiglin entitypiglin, EntityLiving entityliving) { -@@ -568,9 +576,9 @@ public class PiglinAI { - } - - private static void h(EntityPiglin entitypiglin, EntityLiving entityliving) { -- q(entitypiglin).forEach((entitypiglin1) -> { -+ for (EntityPiglin entitypiglin1 : q(entitypiglin)) { - i(entitypiglin1, entityliving); -- }); -+ } - } - - private static void i(EntityPiglin entitypiglin, EntityLiving entityliving) { diff --git a/src/main/java/net/minecraft/server/PlayerChunk.java.rej b/src/main/java/net/minecraft/server/PlayerChunk.java.rej deleted file mode 100644 index fce02f5fcef5179e63997c0b06277601c911ecb7..0000000000000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/PlayerChunk.java.rej +++ /dev/null @@ -1,22 +0,0 @@ -diff a/src/main/java/net/minecraft/server/PlayerChunk.java b/src/main/java/net/minecraft/server/PlayerChunk.java (rejected hunks) -@@ -2,6 +2,7 @@ package net.minecraft.server; - - import com.mojang.datafixers.util.Either; - import java.util.List; -+import java.util.Map; - import java.util.Optional; - import java.util.concurrent.CompletableFuture; - import java.util.concurrent.atomic.AtomicReferenceArray; -@@ -745,7 +746,11 @@ public class PlayerChunk { - if (getCurrentPriority() != priority) { - this.v.a(this.location, this::getCurrentPriority, priority, this::setPriority); // use preferred priority - int neighborsPriority = getNeighborsPriority(); -- this.neighbors.forEach((neighbor, neighborDesired) -> neighbor.setNeighborPriority(this, neighborsPriority)); -+ for (Map.Entry entry : this.neighbors.entrySet()) { -+ PlayerChunk neighbor = entry.getKey(); -+ ChunkStatus neighborDesired = entry.getValue(); -+ neighbor.setNeighborPriority(this, neighborsPriority); -+ } - } - // Paper end - this.oldTicketLevel = this.ticketLevel; diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java.rej b/src/main/java/net/minecraft/server/PlayerChunkMap.java.rej deleted file mode 100644 index 759862aba781ec6f1ae0c9a76c4ab6352d603a4c..0000000000000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/PlayerChunkMap.java.rej +++ /dev/null @@ -1,84 +0,0 @@ -diff a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java (rejected hunks) -@@ -480,53 +471,53 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { - double playerChunkZ = MathHelper.floor(player.locZ()) >> 4; - pos.setValues(player.locX(), 0, player.locZ()); - double twoThirdModifier = 2D / 3D; -- MCUtil.getSpiralOutChunks(pos, Math.min(6, viewDistance)).forEach(coord -> { -- if (shouldSkipPrioritization(coord)) return; -+ for (ChunkCoordIntPair coordIntPair : MCUtil.getSpiralOutChunks(pos, Math.min(6, viewDistance))) { -+ if (shouldSkipPrioritization(coordIntPair)) continue; - -- double dist = MCUtil.distance(playerChunkX, 0, playerChunkZ, coord.x, 0, coord.z); -+ double dist = MCUtil.distance(playerChunkX, 0, playerChunkZ, coordIntPair.x, 0, coordIntPair.z); - // Prioritize immediate - if (dist <= 4 * 4) { -- updateChunkPriorityMap(priorities, coord.pair(), (int) (27 - Math.sqrt(dist))); -- return; -+ updateChunkPriorityMap(priorities, coordIntPair.pair(), (int) (27 - Math.sqrt(dist))); -+ continue; - } - - // Prioritize nearby chunks -- updateChunkPriorityMap(priorities, coord.pair(), (int) (20 - Math.sqrt(dist) * twoThirdModifier)); -- }); -+ updateChunkPriorityMap(priorities, coordIntPair.pair(), (int) (20 - Math.sqrt(dist) * twoThirdModifier)); -+ } - - // Prioritize Frustum near 3 - ChunkCoordIntPair front3 = player.getChunkInFront(3); - pos.setValues(front3.x << 4, 0, front3.z << 4); -- MCUtil.getSpiralOutChunks(pos, Math.min(5, viewDistance)).forEach(coord -> { -- if (shouldSkipPrioritization(coord)) return; -+ for (ChunkCoordIntPair chunkCoordIntPair : MCUtil.getSpiralOutChunks(pos, Math.min(5, viewDistance))) { -+ if (shouldSkipPrioritization(chunkCoordIntPair)) continue; - -- double dist = MCUtil.distance(playerChunkX, 0, playerChunkZ, coord.x, 0, coord.z); -- updateChunkPriorityMap(priorities, coord.pair(), (int) (25 - Math.sqrt(dist) * twoThirdModifier)); -- }); -+ double dist = MCUtil.distance(playerChunkX, 0, playerChunkZ, chunkCoordIntPair.x, 0, chunkCoordIntPair.z); -+ updateChunkPriorityMap(priorities, chunkCoordIntPair.pair(), (int) (25 - Math.sqrt(dist) * twoThirdModifier)); -+ } - - // Prioritize Frustum near 5 - if (viewDistance > 4) { - ChunkCoordIntPair front5 = player.getChunkInFront(5); - pos.setValues(front5.x << 4, 0, front5.z << 4); -- MCUtil.getSpiralOutChunks(pos, 4).forEach(coord -> { -- if (shouldSkipPrioritization(coord)) return; -+ for (ChunkCoordIntPair coord : MCUtil.getSpiralOutChunks(pos, 4)) { -+ if (shouldSkipPrioritization(coord)) continue; - - double dist = MCUtil.distance(playerChunkX, 0, playerChunkZ, coord.x, 0, coord.z); - updateChunkPriorityMap(priorities, coord.pair(), (int) (25 - Math.sqrt(dist) * twoThirdModifier)); -- }); -+ } - } - - // Prioritize Frustum far 7 - if (viewDistance > 6) { - ChunkCoordIntPair front7 = player.getChunkInFront(7); - pos.setValues(front7.x << 4, 0, front7.z << 4); -- MCUtil.getSpiralOutChunks(pos, 3).forEach(coord -> { -+ for (ChunkCoordIntPair coord : MCUtil.getSpiralOutChunks(pos, 3)) { - if (shouldSkipPrioritization(coord)) { -- return; -+ continue; - } - double dist = MCUtil.distance(playerChunkX, 0, playerChunkZ, coord.x, 0, coord.z); - updateChunkPriorityMap(priorities, coord.pair(), (int) (25 - Math.sqrt(dist) * twoThirdModifier)); -- }); -+ } - } - - pos.close(); -@@ -1122,7 +1131,9 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { - if (ioThrowable != null) { - com.destroystokyo.paper.util.SneakyThrow.sneaky(ioThrowable); - } -- chunkHolder.tasks.forEach(Runnable::run); -+ for (Runnable task : chunkHolder.tasks) { -+ task.run(); -+ } - // Paper end - - if (chunkHolder.protoChunk != null) {try (Timing ignored2 = this.world.timings.chunkLoadLevelTimer.startTimingIfSync()) { // Paper start - timings // Paper - chunk is created async diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java index 4c6e708b6d6af45159315dc6ab5fdf72320d9825..bf39ee4b22b69ff5da691aeac65bfdb34058a9fb 100644 --- a/src/main/java/net/minecraft/server/PlayerList.java +++ b/src/main/java/net/minecraft/server/PlayerList.java @@ -189,7 +189,7 @@ public abstract class PlayerList { // Spigot - view distance playerconnection.sendPacket(new PacketPlayOutLogin(entityplayer.getId(), entityplayer.playerInteractManager.getGameMode(), entityplayer.playerInteractManager.c(), BiomeManager.a(worldserver1.getSeed()), worlddata.isHardcore(), this.server.F(), this.s, worldserver1.getDimensionManager(), worldserver1.getDimensionKey(), this.getMaxPlayers(), worldserver1.getChunkProvider().playerChunkMap.getLoadViewDistance(), flag1, !flag, worldserver1.isDebugWorld(), worldserver1.isFlatWorld())); // Paper - no-tick view distance entityplayer.getBukkitEntity().sendSupportedChannels(); // CraftBukkit - playerconnection.sendPacket(new PacketPlayOutCustomPayload(PacketPlayOutCustomPayload.a, (new PacketDataSerializer(Unpooled.buffer())).a(this.getServer().getServerModName()))); + playerconnection.sendPacket(new PacketPlayOutCustomPayload(PacketPlayOutCustomPayload.a, (new PacketDataSerializer(Unpooled.buffer())).a(com.proximyst.rainforest.RainforestConfig.brandName))); // Rainforest - custom brand name playerconnection.sendPacket(new PacketPlayOutServerDifficulty(worlddata.getDifficulty(), worlddata.isDifficultyLocked())); playerconnection.sendPacket(new PacketPlayOutAbilities(entityplayer.abilities)); playerconnection.sendPacket(new PacketPlayOutHeldItemSlot(entityplayer.inventory.itemInHandIndex)); diff --git a/src/main/java/net/minecraft/server/PlayerList.java.rej b/src/main/java/net/minecraft/server/PlayerList.java.rej deleted file mode 100644 index 7c9d7ae5f875ba36b13d6b9b76581be0df903b49..0000000000000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/PlayerList.java.rej +++ /dev/null @@ -1,10 +0,0 @@ -diff a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java (rejected hunks) -@@ -189,7 +189,7 @@ public abstract class PlayerList { - // Spigot - view distance - playerconnection.sendPacket(new PacketPlayOutLogin(entityplayer.getId(), entityplayer.playerInteractManager.getGameMode(), entityplayer.playerInteractManager.c(), BiomeManager.a(worldserver1.getSeed()), worlddata.isHardcore(), this.server.E(), this.s, worldserver1.getTypeKey(), worldserver1.getDimensionKey(), this.getMaxPlayers(), worldserver1.getChunkProvider().playerChunkMap.getLoadViewDistance(), flag1, !flag, worldserver1.isDebugWorld(), worldserver1.isFlatWorld())); // Paper - no-tick view distance - entityplayer.getBukkitEntity().sendSupportedChannels(); // CraftBukkit -- playerconnection.sendPacket(new PacketPlayOutCustomPayload(PacketPlayOutCustomPayload.a, (new PacketDataSerializer(Unpooled.buffer())).a(this.getServer().getServerModName()))); -+ playerconnection.sendPacket(new PacketPlayOutCustomPayload(PacketPlayOutCustomPayload.a, (new PacketDataSerializer(Unpooled.buffer())).a(com.proximyst.rainforest.RainforestConfig.brandName))); // Rainforest - custom brand name - playerconnection.sendPacket(new PacketPlayOutServerDifficulty(worlddata.getDifficulty(), worlddata.isDifficultyLocked())); - playerconnection.sendPacket(new PacketPlayOutAbilities(entityplayer.abilities)); - playerconnection.sendPacket(new PacketPlayOutHeldItemSlot(entityplayer.inventory.itemInHandIndex)); diff --git a/src/main/java/net/minecraft/server/PortalTravelAgent.java b/src/main/java/net/minecraft/server/PortalTravelAgent.java index 62edfda9cc326a428cd267227054f03d94d22dce..5dce3c862166783e1fc479cd4ecce8b80daa90b2 100644 --- a/src/main/java/net/minecraft/server/PortalTravelAgent.java +++ b/src/main/java/net/minecraft/server/PortalTravelAgent.java @@ -22,16 +22,21 @@ public class PortalTravelAgent { // int i = flag ? 16 : 128; // CraftBukkit end - villageplace.a(this.world, blockposition, i); - Optional optional = villageplace.b((villageplacetype) -> { - return villageplacetype == VillagePlaceType.v; - }, blockposition, i, VillagePlace.Occupancy.ANY).sorted(Comparator.comparingDouble((VillagePlaceRecord villageplacerecord) -> { // CraftBukkit - decompile error + boolean seen = false; + VillagePlaceRecord best = null; + Comparator comparator = Comparator.comparingDouble((villageplacerecord) -> { // CraftBukkit - decompile error return villageplacerecord.f().j(blockposition); }).thenComparingInt((villageplacerecord) -> { return villageplacerecord.f().getY(); - })).filter((villageplacerecord) -> { - return this.world.getType(villageplacerecord.f()).b(BlockProperties.E); - }).findFirst(); + }); + java.util.List list = villageplace.b(type -> type == VillagePlaceType.v, blockposition, i, VillagePlace.Occupancy.ANY).collect(java.util.stream.Collectors.toList()); + for (VillagePlaceRecord villagePlaceRecord : list) { + if (!seen || comparator.compare(villagePlaceRecord, best) < 0) { + seen = true; + best = villagePlaceRecord; + } + } + Optional optional = seen ? Optional.of(best) : Optional.empty(); return optional.map((villageplacerecord) -> { BlockPosition blockposition1 = villageplacerecord.f(); diff --git a/src/main/java/net/minecraft/server/PortalTravelAgent.java.rej b/src/main/java/net/minecraft/server/PortalTravelAgent.java.rej deleted file mode 100644 index e8002e718bce73e4cfedcab7636a85a773dfb099..0000000000000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/PortalTravelAgent.java.rej +++ /dev/null @@ -1,24 +0,0 @@ -diff a/src/main/java/net/minecraft/server/PortalTravelAgent.java b/src/main/java/net/minecraft/server/PortalTravelAgent.java (rejected hunks) -@@ -57,11 +57,20 @@ public class PortalTravelAgent { - List list = (List) villageplace.b((villageplacetype) -> { - return villageplacetype == VillagePlaceType.v; - }, blockposition, searchRadius, VillagePlace.Occupancy.ANY).collect(Collectors.toList()); // CraftBukkit - searchRadius -- Optional optional = list.stream().min(Comparator.comparingDouble((villageplacerecord) -> { // CraftBukkit - decompile error -+ boolean seen = false; -+ VillagePlaceRecord best = null; -+ Comparator comparator = Comparator.comparingDouble((villageplacerecord) -> { // CraftBukkit - decompile error - return villageplacerecord.f().j(blockposition); - }).thenComparingInt((villageplacerecord) -> { - return villageplacerecord.f().getY(); -- })); -+ }); -+ for (VillagePlaceRecord villagePlaceRecord : list) { -+ if (!seen || comparator.compare(villagePlaceRecord, best) < 0) { -+ seen = true; -+ best = villagePlaceRecord; -+ } -+ } -+ Optional optional = seen ? Optional.of(best) : Optional.empty(); - - return (ShapeDetector.Shape) optional.map((villageplacerecord) -> { - BlockPosition blockposition1 = villageplacerecord.f(); diff --git a/src/main/java/net/minecraft/server/RegistryMaterials.java.rej b/src/main/java/net/minecraft/server/RegistryMaterials.java.rej deleted file mode 100644 index c29a9979eb97870b2b13c4b5fa68395aa40e8059..0000000000000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/RegistryMaterials.java.rej +++ /dev/null @@ -1,29 +0,0 @@ -diff a/src/main/java/net/minecraft/server/RegistryMaterials.java b/src/main/java/net/minecraft/server/RegistryMaterials.java (rejected hunks) -@@ -181,17 +181,22 @@ public class RegistryMaterials extends IRegistryWritable { - return Codec.unboundedMap(MinecraftKey.a.xmap(ResourceKey.a(resourcekey), ResourceKey::a), mapcodec.codec()).xmap((map) -> { - RegistryMaterials registrymaterials = new RegistryMaterials<>(resourcekey, lifecycle); - -- map.forEach((resourcekey1, object) -> { -+ for (Entry, T> entry : map.entrySet()) { -+ ResourceKey resourcekey1 = entry.getKey(); -+ T object = entry.getValue(); - registrymaterials.a(registrymaterials.bd, resourcekey1, object); - registrymaterials.d(resourcekey1); -- }); -+ } - return registrymaterials; - }, (registrymaterials) -> { - com.google.common.collect.ImmutableMap.Builder, T> com_google_common_collect_immutablemap_builder = ImmutableMap.builder(); - -- registrymaterials.bb.entrySet().stream().filter((entry) -> { -- return registrymaterials.c((ResourceKey) entry.getKey()); -- }).forEach(entry1 -> com_google_common_collect_immutablemap_builder.put((java.util.Map.Entry,? extends T>) entry1)); // Paper - compiler fix (expand method reference + add cast) -+ // Paper - compiler fix (expand method reference + add cast) -+ for (Entry, T> entry : registrymaterials.bb.entrySet()) { -+ if (registrymaterials.c(entry.getKey())) { -+ com_google_common_collect_immutablemap_builder.put(entry); -+ } -+ } - return com_google_common_collect_immutablemap_builder.build(); - }); - } diff --git a/src/main/java/net/minecraft/server/StructureGenerator.java b/src/main/java/net/minecraft/server/StructureGenerator.java index c3bd58069d8dbdf36f70f1dafd7c24000f31708b..f915cb4e1110e39178527903ae93508f9459d7ca 100644 --- a/src/main/java/net/minecraft/server/StructureGenerator.java +++ b/src/main/java/net/minecraft/server/StructureGenerator.java @@ -143,6 +143,11 @@ public abstract class StructureGenerator int j2 = i1 + k * l1; ChunkCoordIntPair chunkcoordintpair = this.a(structuresettingsfeature, j, seededrandom, i2, j2); if (!iworldreader.getWorldBorder().isChunkInBounds(chunkcoordintpair.x, chunkcoordintpair.z)) { continue; } // Paper + // Origami start - seed based feature search doesn't load + if (iworldreader instanceof World && ((World) iworldreader).origamiConfig.fastFeatureSearchDontLoad) { + return chunkcoordintpair.l(); + } + // Origami end IChunkAccess ichunkaccess = iworldreader.getChunkAt(chunkcoordintpair.x, chunkcoordintpair.z, ChunkStatus.STRUCTURE_STARTS); StructureStart structurestart = structuremanager.a(SectionPosition.a(ichunkaccess.getPos(), 0), this, ichunkaccess); diff --git a/src/main/java/net/minecraft/server/StructureGenerator.java.rej b/src/main/java/net/minecraft/server/StructureGenerator.java.rej deleted file mode 100644 index 8b5d001fb8ecb4a5b96bda6532cf8d5900816290..0000000000000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/StructureGenerator.java.rej +++ /dev/null @@ -1,13 +0,0 @@ -diff a/src/main/java/net/minecraft/server/StructureGenerator.java b/src/main/java/net/minecraft/server/StructureGenerator.java (rejected hunks) -@@ -139,6 +139,11 @@ public abstract class StructureGenerator - int j2 = i1 + k * l1; - ChunkCoordIntPair chunkcoordintpair = this.a(structuresettingsfeature, j, seededrandom, i2, j2); - if (!iworldreader.getWorldBorder().isChunkInBounds(chunkcoordintpair.x, chunkcoordintpair.z)) { continue; } // Paper -+ // Origami start - seed based feature search doesn't load -+ if (iworldreader instanceof World && ((World) iworldreader).origamiConfig.fastFeatureSearchDontLoad) { -+ return chunkcoordintpair.l(); -+ } -+ // Origami end - // Origami start - option to only find generated features to not generate new chunks - IChunkAccess ichunkaccess = iworldreader.getChunkAt(chunkcoordintpair.x, chunkcoordintpair.z, ChunkStatus.STRUCTURE_STARTS, !(iworldreader instanceof World) || !((World) iworldreader).origamiConfig.onlyFindGeneratedFeatures); - if (ichunkaccess == null) { diff --git a/src/main/java/net/minecraft/server/TileEntityHopper.java b/src/main/java/net/minecraft/server/TileEntityHopper.java index 299196ad134593a2979a867b86d44532a23a40f2..95bede605c6401af10f18b641cd12c9d8ec2f207 100644 --- a/src/main/java/net/minecraft/server/TileEntityHopper.java +++ b/src/main/java/net/minecraft/server/TileEntityHopper.java @@ -508,6 +508,7 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi entityitem = (EntityItem) iterator.next(); } while (!a((IInventory) ihopper, entityitem)); + if (ihopper instanceof TileEntityHopper) ((TileEntityHopper) ihopper).shouldTick = true; // Origami - don't tick empty hoppers return true; } return false; // EMC @@ -765,6 +766,7 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi BlockPosition blockposition = this.getPosition(); if (VoxelShapes.c(VoxelShapes.a(entity.getBoundingBox().d((double) (-blockposition.getX()), (double) (-blockposition.getY()), (double) (-blockposition.getZ()))), this.aa_(), OperatorBoolean.AND)) { + enableTicking(this, 0); // Origami - don't tick empty hoppers this.a(() -> { return a((IInventory) this, (EntityItem) entity); }); diff --git a/src/main/java/net/minecraft/server/TileEntityHopper.java.rej b/src/main/java/net/minecraft/server/TileEntityHopper.java.rej deleted file mode 100644 index 3f481f57d8e0b156b7d632085265e3acfb2f4fa8..0000000000000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/TileEntityHopper.java.rej +++ /dev/null @@ -1,17 +0,0 @@ -diff a/src/main/java/net/minecraft/server/TileEntityHopper.java b/src/main/java/net/minecraft/server/TileEntityHopper.java (rejected hunks) -@@ -466,6 +497,7 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi - entityitem = (EntityItem) iterator.next(); - } while (!a((IInventory) ihopper, entityitem)); - -+ if (ihopper instanceof TileEntityHopper) ((TileEntityHopper) ihopper).shouldTick = true; // Origami - don't tick empty hoppers - return true; - } - } -@@ -722,6 +754,7 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi - BlockPosition blockposition = this.getPosition(); - - if (VoxelShapes.c(VoxelShapes.a(entity.getBoundingBox().d((double) (-blockposition.getX()), (double) (-blockposition.getY()), (double) (-blockposition.getZ()))), this.ac_(), OperatorBoolean.AND)) { -+ enableTicking(this, 0); // Origami - don't tick empty hoppers - this.a(() -> { - return a((IInventory) this, (EntityItem) entity); - }); diff --git a/src/main/java/net/minecraft/server/TileEntityShulkerBox.java.rej b/src/main/java/net/minecraft/server/TileEntityShulkerBox.java.rej deleted file mode 100644 index bada470cba41cce9beb9eb04227b42c1d489d731..0000000000000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/TileEntityShulkerBox.java.rej +++ /dev/null @@ -1,22 +0,0 @@ -diff a/src/main/java/net/minecraft/server/TileEntityShulkerBox.java b/src/main/java/net/minecraft/server/TileEntityShulkerBox.java (rejected hunks) -@@ -10,7 +11,19 @@ import org.bukkit.entity.HumanEntity; - - public class TileEntityShulkerBox extends TileEntityLootable implements IWorldInventory, ITickable { - -- private static final int[] a = IntStream.range(0, 27).toArray(); -+ private static final int[] a; -+ -+ static { -+ int[] arr = new int[10]; -+ int count = 0; -+ for (int i1 = 0; i1 < 27; i1++) { -+ if (arr.length == count) arr = Arrays.copyOf(arr, count * 2); -+ arr[count++] = i1; -+ } -+ arr = Arrays.copyOfRange(arr, 0, count); -+ a = arr; -+ } -+ - private NonNullList contents; - private int c; - private TileEntityShulkerBox.AnimationPhase i; diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java index 4ccd7c6b7973d97bd3a2feea279953f307f7a9b4..5c67881cb9258b839e713b8bb0b4b380691d3fdd 100644 --- a/src/main/java/net/minecraft/server/World.java +++ b/src/main/java/net/minecraft/server/World.java @@ -97,6 +97,8 @@ public abstract class World implements GeneratorAccess, AutoCloseable { public final com.tuinity.tuinity.config.TuinityConfig.WorldConfig tuinityConfig; // Tuinity - Server Config public final net.pl3x.purpur.PurpurWorldConfig purpurConfig; // Purpur + public final de.minebench.origami.OrigamiConfig.WorldConfig origamiConfig; // Origami - World config + public final RainforestWorldConfig rainforestConfig; // Rainforest public final co.aikar.timings.WorldTimingsHandler timings; // Paper public static BlockPosition lastPhysicsProblem; // Spigot @@ -130,6 +132,9 @@ public abstract class World implements GeneratorAccess, AutoCloseable { this.paperConfig = new com.destroystokyo.paper.PaperWorldConfig((((WorldDataServer)worlddatamutable).getName()), this.spigotConfig); // Paper this.chunkPacketBlockController = this.paperConfig.antiXray ? new ChunkPacketBlockControllerAntiXray(this, executor) : ChunkPacketBlockController.NO_OPERATION_INSTANCE; // Paper - Anti-Xray this.tuinityConfig = new com.tuinity.tuinity.config.TuinityConfig.WorldConfig(((WorldDataServer)worlddatamutable).getName()); // Tuinity - Server Config + this.purpurConfig = new net.pl3x.purpur.PurpurWorldConfig(((WorldDataServer)worlddatamutable).getName()); // Purpur - world config + this.origamiConfig = new de.minebench.origami.OrigamiConfig.WorldConfig(((WorldDataServer)worlddatamutable).getName()); // Origami + this.rainforestConfig = new RainforestWorldConfig(((WorldDataServer)worlddatamutable).getName(), paperConfig); // Rainforest this.generator = gen; this.world = new CraftWorld((WorldServer) this, gen, env); this.ticksPerAnimalSpawns = this.getServer().getTicksPerAnimalSpawns(); // CraftBukkit @@ -614,6 +619,7 @@ public abstract class World implements GeneratorAccess, AutoCloseable { } + public final void neighborChanged(BlockPosition pos, Block blockIn, BlockPosition fromPos) { a(pos, blockIn, fromPos); } // Paper - OBFHELPER public void a(BlockPosition blockposition, Block block, BlockPosition blockposition1) { if (!this.isClientSide) { IBlockData iblockdata = this.getTypeIfLoaded(blockposition); // EMC diff --git a/src/main/java/net/minecraft/server/World.java.rej b/src/main/java/net/minecraft/server/World.java.rej deleted file mode 100644 index c632cd030e36d8abfd92a14948e4893d885823ad..0000000000000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/World.java.rej +++ /dev/null @@ -1,9 +0,0 @@ -diff a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java (rejected hunks) -@@ -646,6 +646,7 @@ public abstract class World implements GeneratorAccess, AutoCloseable { - - } - -+ public void neighborChanged(BlockPosition pos, Block blockIn, BlockPosition fromPos) { a(pos, blockIn, fromPos); } // Paper - OBFHELPER - public void a(BlockPosition blockposition, Block block, BlockPosition blockposition1) { - if (!this.isClientSide) { - IBlockData iblockdata = this.getType(blockposition); diff --git a/src/main/java/net/minecraft/server/WorldDataServer.java.rej b/src/main/java/net/minecraft/server/WorldDataServer.java.rej deleted file mode 100644 index ce6a0e3807550ef3652d4e1ab8695f7afe9fc8f8..0000000000000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/WorldDataServer.java.rej +++ /dev/null @@ -1,13 +0,0 @@ -diff a/src/main/java/net/minecraft/server/WorldDataServer.java b/src/main/java/net/minecraft/server/WorldDataServer.java (rejected hunks) -@@ -120,7 +120,10 @@ public class WorldDataServer implements IWorldDataServer, SaveData { - private void a(IRegistryCustom iregistrycustom, NBTTagCompound nbttagcompound, @Nullable NBTTagCompound nbttagcompound1) { - NBTTagList nbttaglist = new NBTTagList(); - -- this.B.stream().map(NBTTagString::a).forEach(nbttaglist::add); -+ for (String s : this.B) { -+ NBTTagString a = NBTTagString.a(s); -+ nbttaglist.add(a); -+ } - nbttagcompound.set("ServerBrands", nbttaglist); - nbttagcompound.setBoolean("WasModded", this.C); - NBTTagCompound nbttagcompound2 = new NBTTagCompound(); diff --git a/src/main/java/net/minecraft/server/WorldNBTStorage.java b/src/main/java/net/minecraft/server/WorldNBTStorage.java index d627a25830646d8808950238f451fa0adbab4ec6..a959672f5857b987001252c3fd7ace9e83e07c9b 100644 --- a/src/main/java/net/minecraft/server/WorldNBTStorage.java +++ b/src/main/java/net/minecraft/server/WorldNBTStorage.java @@ -61,7 +61,7 @@ public class WorldNBTStorage { } // Spigot End - if (file.exists() && file.isFile()) { + if (normalFile) { // Akarin - avoid double I/O operation nbttagcompound = NBTCompressedStreamTools.a(file); } // Spigot Start diff --git a/src/main/java/net/minecraft/server/WorldNBTStorage.java.rej b/src/main/java/net/minecraft/server/WorldNBTStorage.java.rej deleted file mode 100644 index 3a35169eaf680c45fe42922eb5f0014fa422c31c..0000000000000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/WorldNBTStorage.java.rej +++ /dev/null @@ -1,10 +0,0 @@ -diff a/src/main/java/net/minecraft/server/WorldNBTStorage.java b/src/main/java/net/minecraft/server/WorldNBTStorage.java (rejected hunks) -@@ -62,7 +63,7 @@ public class WorldNBTStorage { - } - // Spigot End - -- if (file.exists() && file.isFile()) { -+ if (normalFile) { // Akarin - avoid double I/O operation - nbttagcompound = NBTCompressedStreamTools.a((InputStream) (new FileInputStream(file))); - } - // Spigot Start diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java index 201e577d2e53b04532180553b72f6ae80f1cfb00..af87989796198229fbdf6fc5cf6da42bf2eeec98 100644 --- a/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java @@ -869,11 +869,11 @@ public class WorldServer extends World implements GeneratorAccessSeed { this.P(); this.b(); - gameprofilerfiller.exitEnter("chunkSource"); + //gameprofilerfiller.exitEnter("chunkSource"); // Akarin - remove caller this.timings.chunkProviderTick.startTiming(); // Paper - timings this.getChunkProvider().tick(booleansupplier); this.timings.chunkProviderTick.stopTiming(); // Paper - timings - gameprofilerfiller.exitEnter("tickPending"); + //gameprofilerfiller.exitEnter("tickPending"); // Akarin - remove caller timings.scheduledBlocks.startTiming(); // Paper if (!this.isDebugWorld()) { this.nextTickListBlock.b(); @@ -882,17 +882,17 @@ public class WorldServer extends World implements GeneratorAccessSeed { timings.scheduledBlocks.stopTiming(); // Paper // Tuinity - replace logic - gameprofilerfiller.exitEnter("raid"); + //gameprofilerfiller.exitEnter("raid"); // Akarin - remove caller this.timings.raids.startTiming(); // Paper - timings this.persistentRaid.a(); this.timings.raids.stopTiming(); // Paper - timings - gameprofilerfiller.exitEnter("blockEvents"); + //gameprofilerfiller.exitEnter("blockEvents"); // Akarin - remove caller timings.doSounds.startTiming(); // Spigot this.aj(); timings.doSounds.stopTiming(); // Spigot // Tuinity - replace logic this.ticking = false; - gameprofilerfiller.exitEnter("entities"); + //gameprofilerfiller.exitEnter("entities"); // Akarin - remove caller boolean flag3 = true || !this.players.isEmpty() || !this.getForceLoadedChunks().isEmpty(); // CraftBukkit - this prevents entity cleanup, other issues on servers with no players if (flag3) { @@ -924,7 +924,7 @@ public class WorldServer extends World implements GeneratorAccessSeed { } // CraftBukkit end */ - gameprofilerfiller.enter("checkDespawn"); + //gameprofilerfiller.enter("checkDespawn"); // Akarin - remove caller if (!entity.dead) { entity.checkDespawn(); // Tuinity start - optimise notify() @@ -936,7 +936,7 @@ public class WorldServer extends World implements GeneratorAccessSeed { // Tuinity end - optimise notify() } - gameprofilerfiller.exit(); + //gameprofilerfiller.exit(); // Akarin - remove caller if (entity1 != null) { if (!entity1.dead && entity1.w(entity)) { continue; @@ -945,13 +945,13 @@ public class WorldServer extends World implements GeneratorAccessSeed { entity.stopRiding(); } - gameprofilerfiller.enter("tick"); + //gameprofilerfiller.enter("tick"); // Akarin - remove caller if (!entity.dead && !(entity instanceof EntityComplexPart)) { this.a(this::entityJoinedWorld, entity); } - gameprofilerfiller.exit(); - gameprofilerfiller.enter("remove"); + //gameprofilerfiller.exit(); // Akarin - remove caller + //gameprofilerfiller.enter("remove"); // Akarin - remove caller if (entity.dead) { this.removeEntityFromChunk(entity); this.entitiesById.remove(entity.getId()); // Tuinity @@ -963,7 +963,7 @@ public class WorldServer extends World implements GeneratorAccessSeed { } // Tuinity end - optimise notify() - gameprofilerfiller.exit(); + //gameprofilerfiller.exit(); // Akarin - remove caller } timings.entityTick.stopTiming(); // Spigot @@ -1050,7 +1050,7 @@ public class WorldServer extends World implements GeneratorAccessSeed { int k = chunkcoordintpair.e(); GameProfilerFiller gameprofilerfiller = this.getMethodProfiler(); - gameprofilerfiller.enter("thunder"); + //gameprofilerfiller.enter("thunder"); // Akarin - remove caller final BlockPosition.MutableBlockPosition blockposition = this.chunkTickMutablePosition; // Paper - use mutable to reduce allocation rate, final to force compile fail on change if (!this.paperConfig.disableThunder && flag && this.V() && this.random.nextInt(100000) == 0) { // Paper - Disable thunder @@ -1401,7 +1401,7 @@ public class WorldServer extends World implements GeneratorAccessSeed { // Tuinity end } - this.getMethodProfiler().exit(); + //this.getMethodProfiler().exit(); // Akarin - remove caller } } diff --git a/src/main/java/net/minecraft/server/WorldServer.java.rej b/src/main/java/net/minecraft/server/WorldServer.java.rej deleted file mode 100644 index 6b024f18ebc32034d1d81ef98f7117944bc0cd0a..0000000000000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/WorldServer.java.rej +++ /dev/null @@ -1,94 +0,0 @@ -diff a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java (rejected hunks) -@@ -887,11 +887,11 @@ public class WorldServer extends World implements GeneratorAccessSeed { - - this.N(); - this.b(); -- gameprofilerfiller.exitEnter("chunkSource"); -+ //gameprofilerfiller.exitEnter("chunkSource"); // Akarin - remove caller - this.timings.chunkProviderTick.startTiming(); // Paper - timings - this.getChunkProvider().tick(booleansupplier); - this.timings.chunkProviderTick.stopTiming(); // Paper - timings -- gameprofilerfiller.exitEnter("tickPending"); -+ //gameprofilerfiller.exitEnter("tickPending"); // Akarin - remove caller - timings.scheduledBlocks.startTiming(); // Paper - if (!this.isDebugWorld()) { - this.nextTickListBlock.b(); -@@ -900,17 +900,17 @@ public class WorldServer extends World implements GeneratorAccessSeed { - timings.scheduledBlocks.stopTiming(); // Paper - - // Tuinity - replace logic -- gameprofilerfiller.exitEnter("raid"); -+ //gameprofilerfiller.exitEnter("raid"); // Akarin - remove caller - this.timings.raids.startTiming(); // Paper - timings - this.persistentRaid.a(); - this.timings.raids.stopTiming(); // Paper - timings -- gameprofilerfiller.exitEnter("blockEvents"); -+ //gameprofilerfiller.exitEnter("blockEvents"); // Akarin - remove caller - timings.doSounds.startTiming(); // Spigot - this.ah(); - timings.doSounds.stopTiming(); // Spigot - // Tuinity - replace logic - this.ticking = false; -- gameprofilerfiller.exitEnter("entities"); -+ //gameprofilerfiller.exitEnter("entities"); // Akarin - remove caller - boolean flag3 = true || !this.players.isEmpty() || !this.getForceLoadedChunks().isEmpty(); // CraftBukkit - this prevents entity cleanup, other issues on servers with no players - - if (flag3) { -@@ -943,12 +943,12 @@ public class WorldServer extends World implements GeneratorAccessSeed { - } - // CraftBukkit end */ - -- gameprofilerfiller.enter("checkDespawn"); -+ //gameprofilerfiller.enter("checkDespawn"); // Akarin - remove caller - if (!entity.dead) { - entity.checkDespawn(); - } - -- gameprofilerfiller.exit(); -+ //gameprofilerfiller.exit(); // Akarin - remove caller - if (entity1 != null) { - if (!entity1.dead && entity1.w(entity)) { - continue; -@@ -957,20 +957,20 @@ public class WorldServer extends World implements GeneratorAccessSeed { - entity.stopRiding(); - } - -- gameprofilerfiller.enter("tick"); -+ //gameprofilerfiller.enter("tick"); // Akarin - remove caller - if (!entity.dead && !(entity instanceof EntityComplexPart)) { - this.a(this::entityJoinedWorld, entity); - } - -- gameprofilerfiller.exit(); -- gameprofilerfiller.enter("remove"); -+ //gameprofilerfiller.exit(); // Akarin - remove caller -+ //gameprofilerfiller.enter("remove"); // Akarin - remove caller - if (entity.dead) { - this.removeEntityFromChunk(entity); - this.entitiesById.remove(entity.getId()); // Tuinity - this.unregisterEntity(entity); - } - -- gameprofilerfiller.exit(); -+ //gameprofilerfiller.exit(); // Akarin - remove caller - } - timings.entityTick.stopTiming(); // Spigot - -@@ -1049,7 +1049,7 @@ public class WorldServer extends World implements GeneratorAccessSeed { - int k = chunkcoordintpair.e(); - GameProfilerFiller gameprofilerfiller = this.getMethodProfiler(); - -- gameprofilerfiller.enter("thunder"); -+ //gameprofilerfiller.enter("thunder"); // Akarin - remove caller - final BlockPosition.MutableBlockPosition blockposition = this.chunkTickMutablePosition; // Paper - use mutable to reduce allocation rate, final to force compile fail on change - - if (!this.paperConfig.disableThunder && flag && this.T() && this.random.nextInt(100000) == 0) { // Paper - Disable thunder -@@ -1377,7 +1377,7 @@ public class WorldServer extends World implements GeneratorAccessSeed { - } - } - -- this.getMethodProfiler().exit(); -+ //this.getMethodProfiler().exit(); // Akarin - remove caller - } - } - diff --git a/src/main/java/net/pl3x/purpur/PurpurConfig.java b/src/main/java/net/pl3x/purpur/PurpurConfig.java index 00c7c90639f030ebb17476711dec813d7ec3cc22..ce945452a9e634d42fb541b86d347b987822c558 100644 --- a/src/main/java/net/pl3x/purpur/PurpurConfig.java +++ b/src/main/java/net/pl3x/purpur/PurpurConfig.java @@ -129,11 +129,6 @@ public class PurpurConfig { return config.getString(path, config.getString(path)); } - public static String timingsUrl = "https://timings.pl3x.net"; - private static void timingsSettings() { - timingsUrl = getString("settings.timings.url", timingsUrl); - } - public static boolean barrelSixRows = false; public static boolean enderChestSixRows = false; public static boolean enderChestPermissionRows = false; @@ -157,4 +152,24 @@ public class PurpurConfig { private static void fixItemPositionDesync() { fixItemPositionDesync = getBoolean("settings.fix-item-position-desync", fixItemPositionDesync); } + + public static boolean tpsCatchup = true; + private static void tpsCatchup() { + tpsCatchup = getBoolean("settings.tps-catchup", tpsCatchup); + } + + public static double laggingThreshold = 19.0D; + private static void tickLoopSettings() { + laggingThreshold = getDouble("settings.lagging-threshold", laggingThreshold); + } + + public static boolean useAlternateKeepAlive = false; + private static void useAlternateKeepAlive() { + useAlternateKeepAlive = getBoolean("settings.use-alternate-keepalive", useAlternateKeepAlive); + } + + public static boolean dontSendUselessEntityPackets = false; + private static void dontSendUselessEntityPackets() { + dontSendUselessEntityPackets = getBoolean("settings.dont-send-useless-entity-packets", dontSendUselessEntityPackets); + } } diff --git a/src/main/java/net/pl3x/purpur/PurpurConfig.java.rej b/src/main/java/net/pl3x/purpur/PurpurConfig.java.rej deleted file mode 100644 index ff05ff6aef1e0f61eb4437253020632745ee2bd2..0000000000000000000000000000000000000000 --- a/src/main/java/net/pl3x/purpur/PurpurConfig.java.rej +++ /dev/null @@ -1,11 +0,0 @@ -diff a/src/main/java/net/pl3x/purpur/PurpurConfig.java b/src/main/java/net/pl3x/purpur/PurpurConfig.java (rejected hunks) -@@ -194,4 +194,9 @@ public class PurpurConfig { - loggerSuppressInitLegacyMaterialError = getBoolean("settings.logger.suppress-init-legacy-material-errors", loggerSuppressInitLegacyMaterialError); - loggerSuppressIgnoredAdvancementWarnings = getBoolean("settings.logger.suppress-ignored-advancement-warnings", loggerSuppressIgnoredAdvancementWarnings); - } -+ -+ public static boolean tpsCatchup = true; -+ private static void tpsCatchup() { -+ tpsCatchup = getBoolean("settings.tps-catchup", tpsCatchup); -+ } - } diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java index 361f7857e461578e90cb71e15027dadaf794cb69..ba90aa43f2fdd44d0475b519a7e5e1701acd46fb 100644 --- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java +++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java @@ -1,7 +1,18 @@ package net.pl3x.purpur; -import org.bukkit.configuration.ConfigurationSection; +import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; +import java.util.logging.Level; +import net.minecraft.server.Block; +import net.minecraft.server.Explosion; +import net.minecraft.server.IRegistry; +import net.minecraft.server.Item; +import net.minecraft.server.Items; +import net.minecraft.server.MinecraftKey; +import org.bukkit.configuration.ConfigurationSection; + import static net.pl3x.purpur.PurpurConfig.log; public class PurpurWorldConfig { @@ -56,4 +67,178 @@ public class PurpurWorldConfig { PurpurConfig.config.addDefault("world-settings.default." + path, def); return PurpurConfig.config.getString("world-settings." + worldName + "." + path, PurpurConfig.config.getString("world-settings.default." + path)); } + + public int villagerBrainTicks = 1; + public boolean villagerUseBrainTicksOnlyWhenLagging = true; + public boolean villagerFollowEmeraldBlock = false; + public boolean villagerCanBeLeashed = false; + private void villagerSettings() { + villagerBrainTicks = getInt("mobs.villager.brain-ticks", villagerBrainTicks); + villagerUseBrainTicksOnlyWhenLagging = getBoolean("mobs.villager.use-brain-ticks-only-when-lagging", villagerUseBrainTicksOnlyWhenLagging); + villagerFollowEmeraldBlock = getBoolean("mobs.villager.follow-emerald-blocks", villagerFollowEmeraldBlock); + villagerCanBeLeashed = getBoolean("mobs.villager.can-be-leashed", villagerCanBeLeashed); + } + + public boolean villagerTraderFollowEmeraldBlock = false; + public boolean villagerTraderCanBeLeashed = false; + private void villagerTraderSettings() { + villagerTraderCanBeLeashed = getBoolean("mobs.wandering_trader.can-be-leashed", villagerTraderCanBeLeashed); + villagerTraderFollowEmeraldBlock = getBoolean("mobs.wandering_trader.follow-emerald-blocks", villagerTraderFollowEmeraldBlock); + } + + public boolean saveProjectilesToDisk = true; + public boolean milkCuresBadOmen = true; + private void miscGameplayMechanicsSettings() { + saveProjectilesToDisk = getBoolean("gameplay-mechanics.save-projectiles-to-disk", saveProjectilesToDisk); + milkCuresBadOmen = getBoolean("gameplay-mechanics.milk-cures-bad-omen", milkCuresBadOmen); + } + + public boolean anvilAllowColors = false; + private void anvilSettings() { + anvilAllowColors = getBoolean("blocks.anvil.allow-colors", anvilAllowColors); + } + + public boolean foxTypeChangesWithTulips = false; + private void foxSettings() { + foxTypeChangesWithTulips = getBoolean("mobs.fox.tulips-change-type", foxTypeChangesWithTulips); + } + + public float giantStepHeight = 2.0F; + public float giantJumpHeight = 1.0F; + public double giantMaxHealth = 100.0D; + public double giantMovementSpeed = 0.5D; + public double giantAttackDamage = 50.0D; + public boolean giantHaveAI = false; + public boolean giantHaveHostileAI = false; + private void giantSettings() { + giantStepHeight = (float) getDouble("mobs.giant.step-height", giantStepHeight); + giantJumpHeight = (float) getDouble("mobs.giant.jump-height", giantJumpHeight); + giantMaxHealth = getDouble("mobs.giant.max-health", giantMaxHealth); + giantMovementSpeed = getDouble("mobs.giant.movement-speed", giantMovementSpeed); + giantAttackDamage = getDouble("mobs.giant.attack-damage", giantAttackDamage); + giantHaveAI = getBoolean("mobs.giant.have-ai", giantHaveAI); + giantHaveHostileAI = getBoolean("mobs.giant.have-hostile-ai", giantHaveHostileAI); + } + + public double illusionerMaxHealth = 32.0D; + public double illusionerMovementSpeed = 0.5D; + public double illusionerFollowRange = 18.0D; + private void illusionerSettings() { + illusionerMaxHealth = getDouble("mobs.illusioner.max-health", illusionerMaxHealth); + illusionerMovementSpeed = getDouble("mobs.illusioner.movement-speed", illusionerMovementSpeed); + illusionerFollowRange = getDouble("mobs.illusioner.follow-range", illusionerFollowRange); + } + + public double zombieHorseSpawnChance = 0.0D; + private void zombieHorseSettings() { + zombieHorseSpawnChance = getDouble("mobs.zombie_horse.spawn-chance", zombieHorseSpawnChance); + } + + public double creeperChargedChance = 0.0D; + private void creeperSettings() { + creeperChargedChance = getDouble("mobs.creeper.naturally-charged-chance", creeperChargedChance); + } + + public double rabbitNaturalToast = 0.0D; + public double rabbitNaturalKiller = 0.0D; + private void rabbitSettings() { + rabbitNaturalToast = getDouble("mobs.rabbit.spawn-toast-chance", rabbitNaturalToast); + rabbitNaturalKiller = getDouble("mobs.rabbit.spawn-killer-rabbit-chance", rabbitNaturalKiller); + } + + public int cowFeedMushrooms = 0; + private void cowSettings() { + cowFeedMushrooms = getInt("mobs.cow.feed-mushrooms-for-mooshroom", cowFeedMushrooms); + } + + public boolean snowGolemDropsPumpkin = false; + public boolean snowGolemPutPumpkinBack = false; + private void snowGolemSettings() { + snowGolemDropsPumpkin = getBoolean("mobs.snow_golem.drop-pumpkin-when-sheared", snowGolemDropsPumpkin); + snowGolemPutPumpkinBack = getBoolean("mobs.snow_golem.pumpkin-can-be-added-back", snowGolemPutPumpkinBack); + } + + public boolean farmlandGetsMoistFromBelow = false; + private void farmlandSettings() { + farmlandGetsMoistFromBelow = getBoolean("blocks.farmland.gets-moist-from-below", farmlandGetsMoistFromBelow); + } + + public boolean respawnAnchorExplode = true; + public double respawnAnchorExplosionPower = 5.0D; + public boolean respawnAnchorExplosionFire = true; + public Explosion.Effect respawnAnchorExplosionEffect = Explosion.Effect.DESTROY; + private void respawnAnchorSettings() { + respawnAnchorExplode = getBoolean("blocks.respawn_anchor.explode", respawnAnchorExplode); + respawnAnchorExplosionPower = getDouble("blocks.respawn_anchor.explosion-power", respawnAnchorExplosionPower); + respawnAnchorExplosionFire = getBoolean("blocks.respawn_anchor.explosion-fire", respawnAnchorExplosionFire); + try { + respawnAnchorExplosionEffect = Explosion.Effect.valueOf(getString("blocks.respawn_anchor.explosion-effect", respawnAnchorExplosionEffect.name())); + } catch (IllegalArgumentException e) { + log(Level.SEVERE, "Unknown value for `blocks.respawn_anchor.explosion-effect`! Using default of `DESTROY`"); + respawnAnchorExplosionEffect = Explosion.Effect.DESTROY; + } + } + + public boolean bedExplode = true; + public double bedExplosionPower = 5.0D; + public boolean bedExplosionFire = true; + public Explosion.Effect bedExplosionEffect = Explosion.Effect.DESTROY; + private void bedSettings() { + bedExplode = getBoolean("blocks.bed.explode", bedExplode); + bedExplosionPower = getDouble("blocks.bed.explosion-power", bedExplosionPower); + bedExplosionFire = getBoolean("blocks.bed.explosion-fire", bedExplosionFire); + try { + bedExplosionEffect = Explosion.Effect.valueOf(getString("blocks.bed.explosion-effect", bedExplosionEffect.name())); + } catch (IllegalArgumentException e) { + log(Level.SEVERE, "Unknown value for `blocks.bed.explosion-effect`! Using default of `DESTROY`"); + bedExplosionEffect = Explosion.Effect.DESTROY; + } + } + + public int entityLifeSpan = 0; + private void entitySettings() { + entityLifeSpan = getInt("gameplay-mechanics.entity-lifespan", entityLifeSpan); + } + + public boolean spawnerDeactivateByRedstone = false; + private void spawnerSettings() { + spawnerDeactivateByRedstone = getBoolean("blocks.spawner.deactivate-by-redstone", spawnerDeactivateByRedstone); + } + + public String polarBearBreedableItemString = ""; + public Item polarBearBreedableItem = null; + private void polarBearSettings() { + polarBearBreedableItemString = getString("mobs.polar_bear.breedable-item", polarBearBreedableItemString); + Item item = IRegistry.ITEM.get(new MinecraftKey(polarBearBreedableItemString)); + if (item != Items.AIR) polarBearBreedableItem = item; + } + + public double phantomAttackedByCrystalRadius = 0.0D; + public float phantomAttackedByCrystalDamage = 1.0F; + public double phantomOrbitCrystalRadius = 0.0D; + private void phantomSettings() { + phantomAttackedByCrystalRadius = getDouble("mobs.phantom.attacked-by-crystal-range", phantomAttackedByCrystalRadius); + phantomAttackedByCrystalDamage = (float) getDouble("mobs.phantom.attacked-by-crystal-damage", phantomAttackedByCrystalDamage); + phantomOrbitCrystalRadius = getDouble("mobs.phantom.orbit-crystal-radius", phantomOrbitCrystalRadius); + } + + public boolean squidImmuneToEAR = true; + private void squidSettings() { + squidImmuneToEAR = getBoolean("mobs.squid.immune-to-EAR", squidImmuneToEAR); + } + + public Set noTickBlocks = new HashSet<>(); + private void noTickBlocks() { + getList("blocks.no-tick", new ArrayList<>()).forEach(key -> { + Block block = IRegistry.BLOCK.get(new MinecraftKey(key.toString())); + if (!block.getBlockData().isAir()) { + noTickBlocks.add(block); + } + }); + } + + public boolean dolphinDisableTreasureSearching = false; + private void dolphinSettings() { + dolphinDisableTreasureSearching = getBoolean("mobs.dolphin.disable-treasure-searching", dolphinDisableTreasureSearching); + } } diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java.rej b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java.rej deleted file mode 100644 index e7353bb8a2f004e6264433f094bc6a74034de502..0000000000000000000000000000000000000000 --- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java.rej +++ /dev/null @@ -1,13 +0,0 @@ -diff a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java (rejected hunks) -@@ -629,6 +629,11 @@ public class PurpurWorldConfig { - spiderRidableInWater = getBoolean("mobs.spider.ridable-in-water", spiderRidableInWater); - } - -+ public boolean squidImmuneToEAR = true; -+ private void squidSettings() { -+ squidImmuneToEAR = getBoolean("mobs.squid.immune-to-EAR", squidImmuneToEAR); -+ } -+ - public boolean strayRidable = false; - public boolean strayRidableInWater = false; - private void straySettings() { diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java index 624dd7632b9fcc1f60174b0dd82ed42dcf345bd1..6dda54fc22f61329389b50f58c776be2b2c350e8 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -835,6 +835,8 @@ public final class CraftServer implements Server { com.destroystokyo.paper.PaperConfig.init((File) console.options.valueOf("paper-settings")); // Paper com.tuinity.tuinity.config.TuinityConfig.init((File) console.options.valueOf("tuinity-settings")); // Tuinity - Server Config net.pl3x.purpur.PurpurConfig.init((File) console.options.valueOf("purpur-settings")); // Purpur + com.proximyst.rainforest.RainforestConfig.init((File) console.options.valueOf("rainforest-settings")); // Rainforest + de.minebench.origami.OrigamiConfig.init((File) console.options.valueOf("origami-settings")); // Origami for (WorldServer world : console.getWorlds()) { world.worldDataServer.setDifficulty(config.difficulty); world.setSpawnFlags(config.spawnMonsters, config.spawnAnimals); @@ -871,6 +873,8 @@ public final class CraftServer implements Server { world.paperConfig.init(); // Paper world.tuinityConfig.init(); // Tuinity - Server Config world.purpurConfig.init(); // Purpur + world.rainforestConfig.init(); // Rainforest + world.origamiConfig.init(); // Origami - World Config } Plugin[] pluginClone = pluginManager.getPlugins().clone(); // Paper @@ -2249,6 +2253,19 @@ public final class CraftServer implements Server { } // Purpur end + // Rainforest start + @Override + public YamlConfiguration getRainforestConfig() { + return com.proximyst.rainforest.RainforestConfig.config; + } + // Rainforest end + // Origami start + @Override + public YamlConfiguration getOrigamiConfig() { + return de.minebench.origami.OrigamiConfig.config; + } + // Origami end + @Override public void restart() { org.spigotmc.RestartCommand.restart(); @@ -2388,4 +2405,11 @@ public final class CraftServer implements Server { return mobGoals; } // Paper end + + // Purpur start + @Override + public boolean isLagging() { + return getServer().lagging; + } + // Purpur end } diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java.rej b/src/main/java/org/bukkit/craftbukkit/CraftServer.java.rej deleted file mode 100644 index a3c8dfd94f78b49341e5f5aba1735651096c9d70..0000000000000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java.rej +++ /dev/null @@ -1,31 +0,0 @@ -diff a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java (rejected hunks) -@@ -848,6 +848,7 @@ public final class CraftServer implements Server { - - org.spigotmc.SpigotConfig.init((File) console.options.valueOf("spigot-settings")); // Spigot - com.destroystokyo.paper.PaperConfig.init((File) console.options.valueOf("paper-settings")); // Paper -+ com.proximyst.rainforest.RainforestConfig.init((File) console.options.valueOf("rainforest-settings")); // Rainforest - for (WorldServer world : console.getWorlds()) { - world.worldDataServer.setDifficulty(config.difficulty); - world.setSpawnFlags(config.spawnMonsters, config.spawnAnimals); -@@ -882,6 +883,7 @@ public final class CraftServer implements Server { - } - world.spigotConfig.init(); // Spigot - world.paperConfig.init(); // Paper -+ world.rainforestConfig.init(); // Rainforest - } - - Plugin[] pluginClone = pluginManager.getPlugins().clone(); // Paper -@@ -2238,6 +2240,13 @@ public final class CraftServer implements Server { - return com.destroystokyo.paper.PaperConfig.config; - } - -+ // Rainforest start -+ @Override -+ public YamlConfiguration getRainforestConfig() { -+ return com.proximyst.rainforest.RainforestConfig.config; -+ } -+ // Rainforest end -+ - @Override - public void restart() { - org.spigotmc.RestartCommand.restart(); diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java index 25f12589ccf3458576b8653a637b6f83eb633630..63cbecc4cdd549247b58fd094c27683655667799 100644 --- a/src/main/java/org/bukkit/craftbukkit/Main.java +++ b/src/main/java/org/bukkit/craftbukkit/Main.java @@ -154,6 +154,21 @@ public class Main { .describedAs("Yml file"); // Purpur end + // Rainforest start + acceptsAll(asList("rainforest", "rainforest-settings"), "File for rainforest settings") + .withRequiredArg() + .ofType(File.class) + .defaultsTo(new File("rainforest.yml")) + .describedAs("Yml file"); + // Rainforest end + // Origami start + acceptsAll(asList("origami", "origami-settings"), "File for origami settings") + .withRequiredArg() + .ofType(File.class) + .defaultsTo(new File("origami.yml")) + .describedAs("Yml file"); + // Origami end + // Paper start acceptsAll(asList("server-name"), "Name of the server") .withRequiredArg() diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java.rej b/src/main/java/org/bukkit/craftbukkit/Main.java.rej deleted file mode 100644 index 916603085d652444027e4513b77293ece84a6c4f..0000000000000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/Main.java.rej +++ /dev/null @@ -1,16 +0,0 @@ -diff a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java (rejected hunks) -@@ -139,6 +139,14 @@ public class Main { - .describedAs("Yml file"); - // Paper end - -+ // Rainforest start -+ acceptsAll(asList("rainforest", "rainforest-settings"), "File for rainforest settings") -+ .withRequiredArg() -+ .ofType(File.class) -+ .defaultsTo(new File("rainforest.yml")) -+ .describedAs("Yml file"); -+ // Rainforest end -+ - // Paper start - acceptsAll(asList("server-name"), "Name of the server") - .withRequiredArg() diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java index 744b2a00fa0743598cabb46c539ae65238cdc736..1a311092aaa5763396503bd7fd2464b2e41058fc 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java @@ -670,8 +670,12 @@ public class CraftBlock implements Block { // Modelled off EntityHuman#hasBlock if (item == null || !iblockdata.isRequiresSpecialTool() || nms.canDestroySpecialBlock(iblockdata)) { - return net.minecraft.server.Block.getDrops(iblockdata, (WorldServer) world.getMinecraftWorld(), position, world.getTileEntity(position), entity == null ? null : ((CraftEntity) entity).getHandle(), nms) - .stream().map(CraftItemStack::asBukkitCopy).collect(Collectors.toList()); + List list = new ArrayList<>(); + for (net.minecraft.server.ItemStack itemStack : net.minecraft.server.Block.getDrops(iblockdata, world.getMinecraftWorld(), position, world.getTileEntity(position), entity == null ? null : ((CraftEntity) entity).getHandle(), nms)) { + ItemStack stack = CraftItemStack.asBukkitCopy(itemStack); + list.add(stack); + } + return list; } else { return Collections.emptyList(); } diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java.rej b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java.rej deleted file mode 100644 index a0c4f6c35175538d82f4019f306aeca122522e20..0000000000000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java.rej +++ /dev/null @@ -1,16 +0,0 @@ -diff a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java (rejected hunks) -@@ -675,8 +677,12 @@ public class CraftBlock implements Block { - - // Modelled off EntityHuman#hasBlock - if (item == null || !iblockdata.isAlwaysDestroyable() || nms.canDestroySpecialBlock(iblockdata)) { -- return net.minecraft.server.Block.getDrops(iblockdata, (WorldServer) world.getMinecraftWorld(), position, world.getTileEntity(position), entity == null ? null : ((CraftEntity) entity).getHandle(), nms) -- .stream().map(CraftItemStack::asBukkitCopy).collect(Collectors.toList()); -+ List list = new ArrayList<>(); -+ for (net.minecraft.server.ItemStack itemStack : net.minecraft.server.Block.getDrops(iblockdata, (WorldServer) world.getMinecraftWorld(), position, world.getTileEntity(position), entity == null ? null : ((CraftEntity) entity).getHandle(), nms)) { -+ ItemStack stack = CraftItemStack.asBukkitCopy(itemStack); -+ list.add(stack); -+ } -+ return list; - } else { - return Collections.emptyList(); - }