From b0ccf1a48006594408df32d8f9e7ef1021bfe711 Mon Sep 17 00:00:00 2001 From: LexManos Date: Wed, 1 Oct 2025 11:12:41 -0700 Subject: [PATCH] Minecraft 1.21.9 update. There a lot of performance improvements related to events. No more InheritableEvent for abstract events that you shouldn't add listeners to anyway, like EntityEvent. Use their sub-events. Made a lot more events records and interfaces. Mostly just a binary break, but has better performance. Mod bus posting methods are now static, no more ModLoader.get() for those. ObjectHolder was removed, use RegistryObject. Changed RuntimeEnumExtender to only target Minecraft classes. If you want other modders to interact with your API, use an Interface instead of Enum. Moved some abstract event methods to only the relevant sub-events now, e.g. can no longer check the side of a ClientTickEvent, because it'll always be client Rendering has changed a lot, they now batch most things together so that the game will render faster. RenderHighlightEvent changed a lot See https://github.com/MinecraftForge/MinecraftForge-Experimental/tree/1.21.9-dev for unsquashed commits. Co-authored-by: Paint_Ninja --- build_forge.gradle | 2 +- .../net/minecraftforge/fml/ModLoader.java | 11 +- .../common/asm/ObjectHolderDefinalize.java | 131 ----- .../fml/common/asm/RuntimeEnumExtender.java | 13 +- ...odlauncher.serviceapi.ILaunchPluginService | 1 - .../coremods/finalize_spawn_targets.json | 2 +- gradle.properties | 6 +- .../opengl/GlCommandEncoder.java.patch | 2 +- .../mojang/blaze3d/opengl/GlDevice.java.patch | 10 +- .../blaze3d/opengl/GlStateManager.java.patch | 4 +- .../blaze3d/pipeline/RenderTarget.java.patch | 6 +- .../mojang/blaze3d/platform/Window.java.patch | 14 +- .../blaze3d/vertex/VertexConsumer.java.patch | 2 +- .../blaze3d/vertex/VertexFormat.java.patch | 14 +- .../RealmsGenericErrorScreen.java.patch | 6 +- .../minecraft/CrashReportCategory.java.patch | 4 +- .../net/minecraft/SharedConstants.java.patch | 4 +- .../minecraft/net/minecraft/Util.java.patch | 2 +- .../advancements/Advancement.java.patch | 2 +- .../net/minecraft/client/Camera.java.patch | 4 +- .../minecraft/client/KeyMapping.java.patch | 81 ++- .../client/KeyboardHandler.java.patch | 37 +- .../net/minecraft/client/Minecraft.java.patch | 182 ++++--- .../minecraft/client/MouseHandler.java.patch | 42 +- .../net/minecraft/client/Options.java.patch | 22 +- .../client/ToggleKeyMapping.java.patch | 4 +- .../models/ItemModelGenerators.java.patch | 2 +- .../net/minecraft/client/gui/Font.java.patch | 2 +- .../net/minecraft/client/gui/Gui.java.patch | 20 +- .../client/gui/GuiGraphics.java.patch | 20 +- .../gui/components/AbstractButton.java.patch | 6 +- .../gui/components/AbstractWidget.java.patch | 2 +- .../client/gui/components/Button.java.patch | 6 +- .../components/DebugScreenOverlay.java.patch | 101 ---- .../DebugEntryLookingAtEntity.java.patch | 10 + .../client/gui/render/GuiRenderer.java.patch | 2 +- .../client/gui/screens/ChatScreen.java.patch | 8 +- .../gui/screens/ConnectScreen.java.patch | 2 +- .../gui/screens/LoadingOverlay.java.patch | 19 +- .../client/gui/screens/PauseScreen.java.patch | 2 +- .../client/gui/screens/Screen.java.patch | 15 +- .../client/gui/screens/TitleScreen.java.patch | 8 +- .../AdvancementsScreen.java.patch | 14 +- .../AbstractContainerScreen.java.patch | 85 ++-- .../CreativeModeInventoryScreen.java.patch | 56 +-- .../inventory/EnchantmentScreen.java.patch | 4 +- .../inventory/MerchantScreen.java.patch | 2 +- .../ServerSelectionList.java.patch | 12 +- .../options/controls/KeyBindsList.java.patch | 11 +- .../controls/KeyBindsScreen.java.patch | 22 +- .../packs/PackSelectionModel.java.patch | 4 +- .../packs/PackSelectionScreen.java.patch | 11 - .../TransferableSelectionList.java.patch | 11 + .../worldselection/WorldOpenFlows.java.patch | 2 +- .../WorldSelectionList.java.patch | 36 +- .../net/minecraft/client/main/Main.java.patch | 2 +- .../client/model/HumanoidModel.java.patch | 8 +- .../model/geom/LayerDefinitions.java.patch | 6 +- .../client/model/geom/ModelLayers.java.patch | 2 +- .../ClientCommonPacketListenerImpl.java.patch | 4 +- ...ConfigurationPacketListenerImpl.java.patch | 2 +- ...ientHandshakePacketListenerImpl.java.patch | 4 +- .../client/multiplayer/ClientLevel.java.patch | 66 ++- .../ClientPacketListener.java.patch | 24 +- .../MultiPlayerGameMode.java.patch | 41 +- .../client/multiplayer/PlayerInfo.java.patch | 2 +- .../client/multiplayer/ServerData.java.patch | 4 +- .../multiplayer/ServerStatusPinger.java.patch | 2 +- .../multiplayer/chat/ChatListener.java.patch | 6 +- .../particle/FireworkParticles.java.patch | 2 +- .../FlyTowardsPositionParticle.java.patch | 2 +- .../client/particle/Particle.java.patch | 10 +- .../client/particle/ParticleEngine.java.patch | 151 +----- .../particle/ParticleResources.java.patch | 43 ++ .../client/particle/PortalParticle.java.patch | 2 +- .../particle/ReversePortalParticle.java.patch | 2 +- .../VibrationSignalParticle.java.patch | 2 +- .../player/AbstractClientPlayer.java.patch | 5 +- .../client/player/LocalPlayer.java.patch | 40 +- .../client/renderer/GameRenderer.java.patch | 42 +- .../renderer/ItemBlockRenderTypes.java.patch | 16 +- .../renderer/ItemInHandRenderer.java.patch | 18 +- .../client/renderer/LevelRenderer.java.patch | 224 +++------ .../client/renderer/LightTexture.java.patch | 2 +- .../client/renderer/RenderType.java.patch | 8 +- .../renderer/ScreenEffectRenderer.java.patch | 13 +- .../client/renderer/Sheets.java.patch | 4 +- .../block/BlockRenderDispatcher.java.patch | 8 +- .../block/model/ItemTransforms.java.patch | 24 +- .../BlockEntityRenderers.java.patch | 10 +- .../blockentity/ChestRenderer.java.patch | 21 - .../blockentity/PistonHeadRenderer.java.patch | 21 - .../blockentity/SkullBlockRenderer.java.patch | 6 +- .../renderer/culling/Frustum.java.patch | 2 +- .../entity/EnderDragonRenderer.java.patch | 2 +- .../entity/EntityRenderDispatcher.java.patch | 16 +- .../renderer/entity/EntityRenderer.java.patch | 37 +- .../entity/ItemFrameRenderer.java.patch | 28 +- .../renderer/entity/ItemRenderer.java.patch | 4 +- .../entity/LivingEntityRenderer.java.patch | 24 +- .../layers/HumanoidArmorLayer.java.patch | 39 +- .../entity/layers/WingsLayer.java.patch | 8 +- .../entity/player/AvatarRenderer.java.patch | 61 +++ .../entity/player/PlayerRenderer.java.patch | 48 -- .../special/SpecialModelRenderers.java.patch | 6 +- .../state/BlockOutlineRenderState.java.patch | 18 + .../texture/SpriteContents.java.patch | 35 +- .../renderer/texture/SpriteLoader.java.patch | 14 +- .../renderer/texture/TextureAtlas.java.patch | 12 +- .../texture/TextureAtlasSprite.java.patch | 2 +- .../atlas/SpriteResourceLoader.java.patch | 6 +- .../resources/model/ModelManager.java.patch | 70 ++- .../resources/model/ResolvedModel.java.patch | 2 +- .../client/server/IntegratedServer.java.patch | 10 +- .../client/sounds/SoundEngine.java.patch | 42 +- .../minecraft/commands/Commands.java.patch | 14 +- .../selector/EntitySelector.java.patch | 2 +- .../selector/EntitySelectorParser.java.patch | 4 +- .../net/minecraft/core/BlockPos.java.patch | 2 +- .../net/minecraft/core/Direction.java.patch | 2 +- .../net/minecraft/core/Registry.java.patch | 2 +- .../dispenser/DispenseItemBehavior.java.patch | 4 +- .../registries/BuiltInRegistries.java.patch | 12 +- .../core/registries/Registries.java.patch | 2 +- .../net/minecraft/data/Main.java.patch | 2 +- .../data/loot/BlockLootSubProvider.java.patch | 2 +- .../data/recipes/RecipeProvider.java.patch | 8 +- .../tags/VanillaItemTagsProvider.java.patch | 2 +- .../framework/GameTestHelper.java.patch | 6 +- .../framework/GameTestServer.java.patch | 6 +- .../gametest/framework/TestCommand.java.patch | 2 +- .../minecraft/network/Connection.java.patch | 22 +- .../network/FriendlyByteBuf.java.patch | 2 +- .../contents/TranslatableContents.java.patch | 2 +- .../ClientboundCustomPayloadPacket.java.patch | 7 +- .../protocol/status/ServerStatus.java.patch | 4 +- .../syncher/EntityDataSerializers.java.patch | 4 +- .../net/minecraft/server/Main.java.patch | 70 ++- .../server/MinecraftServer.java.patch | 71 +-- .../ReloadableServerResources.java.patch | 2 +- .../commands/TeleportCommand.java.patch | 2 +- .../dedicated/DedicatedServer.java.patch | 41 +- .../server/level/ChunkMap.java.patch | 14 +- .../server/level/DistanceManager.java.patch | 2 +- .../server/level/ServerChunkCache.java.patch | 4 +- .../server/level/ServerEntity.java.patch | 4 +- .../server/level/ServerLevel.java.patch | 46 +- .../server/level/ServerPlayer.java.patch | 42 +- .../level/ServerPlayerGameMode.java.patch | 33 +- .../level/ThreadedLevelLightEngine.java.patch | 2 +- .../network/ConfigurationTask.java.patch | 2 +- .../network/PlayerChunkSender.java.patch | 8 +- .../ServerCommonPacketListenerImpl.java.patch | 4 +- ...ConfigurationPacketListenerImpl.java.patch | 32 +- .../ServerConnectionListener.java.patch | 6 +- .../ServerGamePacketListenerImpl.java.patch | 8 +- .../ServerLoginPacketListenerImpl.java.patch | 6 +- .../config/PrepareSpawnTask.java.patch | 10 + .../server/packs/repository/Pack.java.patch | 12 +- .../repository/ServerPacksSource.java.patch | 2 +- .../server/players/PlayerList.java.patch | 88 ++-- .../server/rcon/RconConsoleSource.java.patch | 2 +- .../net/minecraft/tags/BlockTags.java.patch | 2 +- .../minecraft/tags/EntityTypeTags.java.patch | 2 +- .../net/minecraft/tags/ItemTags.java.patch | 2 +- .../util/random/WeightedList.java.patch | 4 +- .../minecraft/world/entity/Entity.java.patch | 82 +-- .../world/entity/EntityEquipment.java.patch | 4 +- .../world/entity/EntityType.java.patch | 34 +- .../world/entity/LightningBolt.java.patch | 6 +- .../world/entity/LivingEntity.java.patch | 132 ++--- .../net/minecraft/world/entity/Mob.java.patch | 20 +- .../world/entity/SpawnPlacements.java.patch | 2 +- .../world/entity/ai/Brain.java.patch | 4 +- .../attributes/DefaultAttributes.java.patch | 2 +- .../ai/navigation/PathNavigation.java.patch | 2 +- .../entity/ai/village/poi/PoiTypes.java.patch | 6 +- .../world/entity/animal/Animal.java.patch | 2 +- .../world/entity/animal/Bee.java.patch | 4 +- .../entity/animal/MushroomCow.java.patch | 18 +- .../world/entity/animal/Ocelot.java.patch | 2 +- .../world/entity/animal/Parrot.java.patch | 2 +- .../world/entity/animal/Pig.java.patch | 8 +- .../entity/animal/allay/Allay.java.patch | 2 +- .../entity/animal/camel/Camel.java.patch | 2 +- .../animal/horse/AbstractHorse.java.patch | 4 +- .../entity/animal/sniffer/Sniffer.java.patch | 7 +- .../boss/enderdragon/EnderDragon.java.patch | 2 +- .../decoration/HangingEntity.java.patch | 10 +- .../world/entity/item/ItemEntity.java.patch | 36 +- .../monster/AbstractSkeleton.java.patch | 2 +- .../world/entity/monster/EnderMan.java.patch | 16 +- .../world/entity/monster/Husk.java.patch | 2 +- .../world/entity/monster/Monster.java.patch | 2 +- .../world/entity/monster/Skeleton.java.patch | 4 +- .../world/entity/monster/Slime.java.patch | 4 +- .../world/entity/monster/Zombie.java.patch | 16 +- .../entity/monster/ZombieVillager.java.patch | 6 +- .../monster/creaking/Creaking.java.patch | 2 +- .../entity/monster/hoglin/Hoglin.java.patch | 4 +- .../monster/piglin/AbstractPiglin.java.patch | 4 +- .../entity/monster/piglin/Piglin.java.patch | 6 +- .../world/entity/npc/CatSpawner.java.patch | 2 +- .../world/entity/npc/Villager.java.patch | 4 +- .../world/entity/player/Inventory.java.patch | 8 +- .../world/entity/player/Player.java.patch | 84 ++-- .../projectile/AbstractArrow.java.patch | 2 +- .../entity/projectile/FishingHook.java.patch | 32 +- .../entity/projectile/Projectile.java.patch | 2 +- .../projectile/ThrownEnderpearl.java.patch | 6 +- .../world/entity/raid/Raid.java.patch | 4 +- .../entity/vehicle/AbstractBoat.java.patch | 14 +- .../vehicle/AbstractMinecart.java.patch | 6 +- .../vehicle/MinecartCommandBlock.java.patch | 2 +- .../entity/vehicle/MinecartFurnace.java.patch | 2 +- .../minecraft/world/item/AxeItem.java.patch | 13 +- .../minecraft/world/item/BlockItem.java.patch | 6 +- .../world/item/BoneMealItem.java.patch | 2 +- .../world/item/BucketItem.java.patch | 15 +- .../world/item/FishingRodItem.java.patch | 10 +- .../minecraft/world/item/HoeItem.java.patch | 6 +- .../net/minecraft/world/item/Item.java.patch | 20 +- .../world/item/ItemDisplayContext.java.patch | 8 +- .../minecraft/world/item/ItemStack.java.patch | 17 +- .../net/minecraft/world/item/Items.java.patch | 4 +- .../world/item/ShearsItem.java.patch | 4 +- .../world/item/ShovelItem.java.patch | 4 +- .../world/item/SpawnEggItem.java.patch | 13 - .../world/level/BaseSpawner.java.patch | 2 +- .../world/level/BlockGetter.java.patch | 8 +- .../minecraft/world/level/Level.java.patch | 38 +- .../world/level/NaturalSpawner.java.patch | 12 +- .../world/level/ServerExplosion.java.patch | 10 +- .../level/block/BaseFireBlock.java.patch | 4 +- .../level/block/BaseRailBlock.java.patch | 2 +- .../world/level/block/BeehiveBlock.java.patch | 12 +- .../world/level/block/Block.java.patch | 22 +- .../world/level/block/Blocks.java.patch | 8 +- .../world/level/block/ChestBlock.java.patch | 2 +- .../block/EnchantingTableBlock.java.patch | 2 +- .../world/level/block/LiquidBlock.java.patch | 10 +- .../world/level/block/NoteBlock.java.patch | 2 +- .../world/level/block/PumpkinBlock.java.patch | 6 +- .../world/level/block/SoundType.java.patch | 2 +- .../block/SweetBerryBushBlock.java.patch | 2 +- .../level/block/TripWireBlock.java.patch | 4 +- .../BaseContainerBlockEntity.java.patch | 2 +- .../level/block/entity/BlockEntity.java.patch | 16 +- .../entity/BrewingStandBlockEntity.java.patch | 6 +- .../block/entity/ChestBlockEntity.java.patch | 2 +- .../ChiseledBookShelfBlockEntity.java.patch | 2 +- .../block/entity/HopperBlockEntity.java.patch | 6 +- .../entity/ShulkerBoxBlockEntity.java.patch | 4 +- .../block/state/BlockBehaviour.java.patch | 18 +- .../world/level/chunk/ChunkAccess.java.patch | 4 +- .../level/chunk/ImposterProtoChunk.java.patch | 2 +- .../world/level/chunk/LevelChunk.java.patch | 36 +- .../chunk/status/ChunkStatusTasks.java.patch | 2 +- .../level/levelgen/Beardifier.java.patch | 22 +- .../StructureTemplate.java.patch | 14 +- .../StructureTemplateManager.java.patch | 2 +- .../level/material/FlowingFluid.java.patch | 6 +- .../world/level/material/LavaFluid.java.patch | 6 +- .../storage/PlayerDataStorage.java.patch | 21 +- .../level/storage/PrimaryLevelData.java.patch | 6 +- .../level/storage/loot/LootContext.java.patch | 15 +- .../nbt/ContextNbtProvider.java.patch | 11 - .../generated/data/c/tags/block/chains.json | 10 +- .../generated/data/c/tags/item/chains.json | 10 +- .../data/minecraft/recipe/copper_axe.json | 17 + .../data/minecraft/recipe/copper_bars.json | 15 + .../data/minecraft/recipe/copper_boots.json | 15 + .../data/minecraft/recipe/copper_chain.json | 17 + .../data/minecraft/recipe/copper_chest.json | 17 + .../minecraft/recipe/copper_chestplate.json | 16 + .../data/minecraft/recipe/copper_helmet.json | 15 + .../data/minecraft/recipe/copper_hoe.json | 17 + .../minecraft/recipe/copper_leggings.json | 16 + .../data/minecraft/recipe/copper_nugget.json | 11 + .../data/minecraft/recipe/copper_pickaxe.json | 17 + .../data/minecraft/recipe/copper_shovel.json | 17 + .../data/minecraft/recipe/copper_sword.json | 17 + .../data/minecraft/recipe/copper_torch.json | 21 + .../minecraft/recipe/copper_trapdoor.json | 6 +- .../recipe/{chain.json => iron_chain.json} | 2 +- src/main/generated/pack.mcmeta | 3 +- .../client/ClientCommandSourceStack.java | 2 +- .../client/ColorResolverManager.java | 2 +- .../DimensionSpecialEffectsManager.java | 2 +- .../client/EntitySpectatorShaderManager.java | 2 +- .../client/ForgeHooksClient.java | 136 ++--- .../client/ForgeRenderTypes.java | 30 +- .../client/ItemDecoratorHandler.java | 2 +- .../client/NamedRenderTypeManager.java | 2 +- .../client/PresetEditorManager.java | 2 +- .../event/AddGuiOverlayLayersEvent.java | 13 +- .../client/event/ClientPauseChangeEvent.java | 51 +- .../event/ClientPlayerNetworkEvent.java | 92 ++-- .../client/event/ContainerScreenEvent.java | 68 +-- .../event/CustomizeGuiOverlayEvent.java | 123 ++--- .../client/event/EntityRenderersEvent.java | 51 +- .../client/event/ForgeEventFactoryClient.java | 84 ++-- .../GatherAtlasMetadataSectionsEvent.java | 29 ++ .../client/event/InputEvent.java | 157 ++---- .../client/event/ModelEvent.java | 80 +-- .../event/MovementInputUpdateEvent.java | 26 +- .../event/RegisterColorHandlersEvent.java | 20 +- .../event/RegisterParticleProvidersEvent.java | 31 +- .../client/event/RenderArmEvent.java | 8 +- .../client/event/RenderAvatarEvent.java | 100 ++++ .../client/event/RenderHandEvent.java | 4 +- .../client/event/RenderHighlightEvent.java | 99 ++-- .../client/event/RenderItemInFrameEvent.java | 9 +- .../client/event/RenderLivingEvent.java | 81 ++- .../client/event/RenderNameTagEvent.java | 31 +- .../client/event/RenderPlayerEvent.java | 118 ----- .../client/event/RenderTooltipEvent.java | 100 ++-- .../client/event/ScreenEvent.java | 471 ++++++------------ .../client/event/TextureStitchEvent.java | 46 +- .../client/event/ViewportEvent.java | 134 +++-- .../client/event/sound/PlaySoundEvent.java | 17 +- .../event/sound/PlaySoundSourceEvent.java | 10 +- .../event/sound/PlayStreamingSourceEvent.java | 10 +- .../event/sound/SoundEngineLoadEvent.java | 14 +- .../client/event/sound/SoundEvent.java | 43 +- .../client/event/sound/package-info.java | 9 +- .../client/extensions/IForgeKeyMapping.java | 6 +- .../common/IClientItemExtensions.java | 3 +- .../gui/ClientTooltipComponentManager.java | 2 +- .../client/gui/LoadingErrorScreen.java | 4 +- .../client/gui/ModListScreen.java | 7 +- .../gui/ModMismatchDisconnectedScreen.java | 9 +- .../client/gui/overlay/ForgeLayeredDraw.java | 9 +- .../client/gui/widget/ForgeSlider.java | 18 +- .../client/gui/widget/ModListWidget.java | 23 +- .../client/gui/widget/ScrollPanel.java | 19 +- .../client/loading/ClientModLoader.java | 7 +- .../client/model/data/ModelDataManager.java | 2 +- .../model/geometry/GeometryLoaderManager.java | 2 +- .../client/settings/KeyModifier.java | 17 +- .../textures/ITextureAtlasSpriteLoader.java | 7 +- .../TextureAtlasSpriteLoaderManager.java | 2 +- .../textures/UnitTextureAtlasSprite.java | 3 +- .../common/FarmlandWaterManager.java | 2 +- .../net/minecraftforge/common/ForgeHooks.java | 26 +- .../common/ForgeInternalHandler.java | 4 +- .../net/minecraftforge/common/ForgeMod.java | 6 +- .../common/ForgeStatesProvider.java | 6 +- .../common/IExtensibleEnum.java | 3 +- .../capabilities/CapabilityManager.java | 2 +- .../data/ForgeBlockItemTagsProvider.java | 3 +- .../common/extensions/IForgeBlock.java | 4 +- .../common/extensions/IForgeBlockEntity.java | 5 +- .../extensions/IForgeGameTestHelper.java | 42 +- .../common/extensions/IForgeServerPlayer.java | 2 +- .../data/loading/DatagenModLoader.java | 2 +- .../event/AddPackFindersEvent.java | 22 +- .../event/AddReloadListenerEvent.java | 51 +- .../BuildCreativeModeTabContentsEvent.java | 5 +- .../minecraftforge/event/CommandEvent.java | 14 +- .../event/DifficultyChangeEvent.java | 6 +- .../event/ForgeEventFactory.java | 40 +- .../event/LootTableLoadEvent.java | 15 +- .../event/PlayLevelSoundEvent.java | 7 +- .../RegisterStructureConversionsEvent.java | 9 +- .../minecraftforge/event/ServerChatEvent.java | 10 +- .../event/TagsUpdatedEvent.java | 33 +- .../net/minecraftforge/event/TickEvent.java | 186 ++----- .../brewing/PlayerBrewedPotionEvent.java | 22 +- .../event/brewing/PotionBrewEvent.java | 6 +- .../event/entity/EntityEvent.java | 75 +-- .../event/entity/EntityJoinLevelEvent.java | 17 +- .../event/entity/EntityLeaveLevelEvent.java | 17 +- .../event/entity/EntityMobGriefingEvent.java | 15 +- .../event/entity/EntityMountEvent.java | 49 +- .../entity/EntityStruckByLightningEvent.java | 32 +- .../event/entity/EntityTeleportEvent.java | 73 +-- .../entity/EntityTravelToDimensionEvent.java | 30 +- .../event/entity/ProjectileImpactEvent.java | 10 +- .../event/entity/item/ItemEvent.java | 23 +- .../event/entity/item/ItemExpireEvent.java | 19 +- .../event/entity/item/ItemTossEvent.java | 30 +- .../event/entity/living/AnimalTameEvent.java | 26 +- .../entity/living/LivingAttackEvent.java | 33 +- .../entity/living/LivingBreatheEvent.java | 18 +- .../living/LivingChangeTargetEvent.java | 18 +- .../entity/living/LivingConversionEvent.java | 75 ++- .../entity/living/LivingDamageEvent.java | 18 +- .../event/entity/living/LivingDeathEvent.java | 30 +- .../living/LivingDestroyBlockEvent.java | 34 +- .../event/entity/living/LivingDropsEvent.java | 48 +- .../event/entity/living/LivingDrownEvent.java | 11 +- .../living/LivingEntityUseItemEvent.java | 12 +- .../living/LivingEquipmentChangeEvent.java | 48 +- .../event/entity/living/LivingEvent.java | 61 +-- .../living/LivingExperienceDropEvent.java | 18 +- .../event/entity/living/LivingFallEvent.java | 19 +- .../living/LivingGetProjectileEvent.java | 17 +- .../event/entity/living/LivingHealEvent.java | 21 +- .../event/entity/living/LivingHurtEvent.java | 20 +- .../entity/living/LivingKnockBackEvent.java | 16 +- .../entity/living/LivingMakeBrainEvent.java | 18 +- .../entity/living/LivingPackSizeEvent.java | 11 +- .../entity/living/LivingSwapItemsEvent.java | 18 +- .../entity/living/LivingUseTotemEvent.java | 31 +- .../entity/living/LootingLevelEvent.java | 18 +- .../event/entity/living/MobEffectEvent.java | 91 ++-- .../event/entity/living/MobSpawnEvent.java | 9 +- .../entity/living/MonsterDisguiseEvent.java | 30 +- .../event/entity/living/ShieldBlockEvent.java | 11 +- .../event/entity/living/ZombieEvent.java | 8 +- .../event/entity/player/AdvancementEvent.java | 77 +-- .../event/entity/player/AnvilRepairEvent.java | 22 +- .../event/entity/player/ArrowLooseEvent.java | 22 +- .../event/entity/player/ArrowNockEvent.java | 16 +- .../entity/player/AttackEntityEvent.java | 22 +- .../event/entity/player/BonemealEvent.java | 11 +- .../event/entity/player/CriticalHitEvent.java | 19 +- .../entity/player/EntityItemPickupEvent.java | 11 +- .../event/entity/player/FillBucketEvent.java | 11 +- .../event/entity/player/ItemFishedEvent.java | 19 +- .../event/entity/player/ItemTooltipEvent.java | 8 +- .../player/PermissionsChangedEvent.java | 30 +- .../entity/player/PlayerContainerEvent.java | 28 +- .../entity/player/PlayerDestroyItemEvent.java | 38 +- .../event/entity/player/PlayerEvent.java | 277 +++------- .../entity/player/PlayerFlyableFallEvent.java | 14 +- .../entity/player/PlayerInteractEvent.java | 15 +- .../entity/player/PlayerSetSpawnEvent.java | 25 +- .../entity/player/PlayerSleepInBedEvent.java | 18 +- .../player/PlayerSpawnPhantomsEvent.java | 14 +- .../entity/player/PlayerWakeUpEvent.java | 15 +- .../event/entity/player/PlayerXpEvent.java | 47 +- .../player/SleepingLocationCheckEvent.java | 11 +- .../entity/player/SleepingTimeCheckEvent.java | 11 +- .../entity/player/TradeWithVillagerEvent.java | 40 +- .../furnace/FurnaceFuelBurnTimeEvent.java | 12 +- .../event/level/AlterGroundEvent.java | 3 +- .../event/level/BlockEvent.java | 273 +++++----- .../event/level/ChunkDataEvent.java | 52 +- .../event/level/ChunkEvent.java | 85 +--- .../level/ChunkTicketLevelUpdatedEvent.java | 73 +-- .../event/level/ChunkWatchEvent.java | 51 +- .../event/level/ExplosionEvent.java | 79 +-- .../event/level/LevelEvent.java | 73 +-- .../event/level/NoteBlockEvent.java | 27 +- .../event/level/PistonEvent.java | 99 ++-- .../event/level/SaplingGrowTreeEvent.java | 13 +- .../event/level/SleepFinishedTimeEvent.java | 11 +- .../GatherLoginConfigurationTasksEvent.java | 20 +- .../event/server/ServerAboutToStartEvent.java | 6 +- .../event/server/ServerLifecycleEvent.java | 15 +- .../event/server/ServerStartedEvent.java | 6 +- .../event/server/ServerStartingEvent.java | 6 +- .../event/server/ServerStoppedEvent.java | 6 +- .../event/server/ServerStoppingEvent.java | 6 +- .../event/village/VillagerTradesEvent.java | 28 +- .../net/minecraftforge/fluids/FluidUtil.java | 2 +- .../fml/event/config/ModConfigEvent.java | 31 +- .../event/lifecycle/ModLifecycleEvent.java | 4 +- .../lifecycle/ParallelDispatchEvent.java | 4 +- .../items/ItemHandlerHelper.java | 2 +- .../items/wrapper/PlayerMainInvWrapper.java | 2 +- .../items/wrapper/RecipeWrapper.java | 44 +- .../network/PacketDistributor.java | 6 +- .../network/packets/SpawnEntity.java | 2 +- .../minecraftforge/registries/GameData.java | 9 +- .../registries/ObjectHolder.java | 51 -- .../registries/ObjectHolderRef.java | 130 ----- .../registries/ObjectHolderRegistry.java | 242 --------- .../registries/RegistryManager.java | 4 +- .../registries/RegistryObject.java | 26 - .../resource/ResourcePackLoader.java | 9 +- .../resources/META-INF/accesstransformer.cfg | 114 ++++- .../generated/closed_module/module-info.dat | Bin 555 -> 555 bytes src/test/generated/mdk_datagen/pack.mcmeta | 3 +- .../generated/test_helper_mod/pack.mcmeta | 3 +- .../debug/client/AdditionalModelTest.java | 20 +- .../debug/client/ModelRenderLayerTest.java | 2 +- .../debug/client/ModifyOverlayTest.java | 2 +- .../debug/client/RenderFrameLayerTest.java | 6 +- .../gameplay/criterion/CriterionTest.java | 1 + .../gameplay/item/PreventItemDamageTest.java | 4 +- .../gameplay/loot/ConditionalLootPools.java | 3 +- .../loot/GlobalLootModifiersTest.java | 7 +- .../debug/gameplay/loot/LootEventsTest.java | 3 +- .../debug/gameplay/loot/ShearsLootTests.java | 3 +- .../java/net/minecraftforge/mdk/Datagen.java | 7 +- .../minecraftforge/test/ModuleProvider.java | 14 +- .../minecraftforge/test/TestHelperMod.java | 9 +- 490 files changed, 4601 insertions(+), 6528 deletions(-) delete mode 100644 fmlloader/src/main/java/net/minecraftforge/fml/common/asm/ObjectHolderDefinalize.java delete mode 100644 patches/minecraft/net/minecraft/client/gui/components/DebugScreenOverlay.java.patch create mode 100644 patches/minecraft/net/minecraft/client/gui/components/debug/DebugEntryLookingAtEntity.java.patch delete mode 100644 patches/minecraft/net/minecraft/client/gui/screens/packs/PackSelectionScreen.java.patch create mode 100644 patches/minecraft/net/minecraft/client/gui/screens/packs/TransferableSelectionList.java.patch create mode 100644 patches/minecraft/net/minecraft/client/particle/ParticleResources.java.patch delete mode 100644 patches/minecraft/net/minecraft/client/renderer/blockentity/ChestRenderer.java.patch delete mode 100644 patches/minecraft/net/minecraft/client/renderer/blockentity/PistonHeadRenderer.java.patch create mode 100644 patches/minecraft/net/minecraft/client/renderer/entity/player/AvatarRenderer.java.patch delete mode 100644 patches/minecraft/net/minecraft/client/renderer/entity/player/PlayerRenderer.java.patch create mode 100644 patches/minecraft/net/minecraft/client/renderer/state/BlockOutlineRenderState.java.patch create mode 100644 patches/minecraft/net/minecraft/server/network/config/PrepareSpawnTask.java.patch delete mode 100644 patches/minecraft/net/minecraft/world/item/SpawnEggItem.java.patch delete mode 100644 patches/minecraft/net/minecraft/world/level/storage/loot/providers/nbt/ContextNbtProvider.java.patch create mode 100644 src/main/generated/data/minecraft/recipe/copper_axe.json create mode 100644 src/main/generated/data/minecraft/recipe/copper_bars.json create mode 100644 src/main/generated/data/minecraft/recipe/copper_boots.json create mode 100644 src/main/generated/data/minecraft/recipe/copper_chain.json create mode 100644 src/main/generated/data/minecraft/recipe/copper_chest.json create mode 100644 src/main/generated/data/minecraft/recipe/copper_chestplate.json create mode 100644 src/main/generated/data/minecraft/recipe/copper_helmet.json create mode 100644 src/main/generated/data/minecraft/recipe/copper_hoe.json create mode 100644 src/main/generated/data/minecraft/recipe/copper_leggings.json create mode 100644 src/main/generated/data/minecraft/recipe/copper_nugget.json create mode 100644 src/main/generated/data/minecraft/recipe/copper_pickaxe.json create mode 100644 src/main/generated/data/minecraft/recipe/copper_shovel.json create mode 100644 src/main/generated/data/minecraft/recipe/copper_sword.json create mode 100644 src/main/generated/data/minecraft/recipe/copper_torch.json rename src/main/generated/data/minecraft/recipe/{chain.json => iron_chain.json} (86%) create mode 100644 src/main/java/net/minecraftforge/client/event/GatherAtlasMetadataSectionsEvent.java create mode 100644 src/main/java/net/minecraftforge/client/event/RenderAvatarEvent.java delete mode 100644 src/main/java/net/minecraftforge/client/event/RenderPlayerEvent.java delete mode 100644 src/main/java/net/minecraftforge/registries/ObjectHolder.java delete mode 100644 src/main/java/net/minecraftforge/registries/ObjectHolderRef.java delete mode 100644 src/main/java/net/minecraftforge/registries/ObjectHolderRegistry.java diff --git a/build_forge.gradle b/build_forge.gradle index f7bfab8ec4..4be10a27a6 100644 --- a/build_forge.gradle +++ b/build_forge.gradle @@ -415,7 +415,7 @@ tasks.register('extractInheritance', ExtractInheritance) { } tasks.register("findFinalizeSpawnTargets", BytecodePredicateFinder) { jar = createClientOfficial.output - output = rootProject.file('src/main/resources/coremods/finalize_spawn_targets.json') + output = rootProject.file('forge-transformers/src/main/resources/coremods/finalize_spawn_targets.json') predicate = { parent, node, insn -> return 'net/minecraft/world/level/BaseSpawner' != parent.name // Ignore this class as we special case it. diff --git a/fmlcore/src/main/java/net/minecraftforge/fml/ModLoader.java b/fmlcore/src/main/java/net/minecraftforge/fml/ModLoader.java index aa3266e38a..978cf1271f 100644 --- a/fmlcore/src/main/java/net/minecraftforge/fml/ModLoader.java +++ b/fmlcore/src/main/java/net/minecraftforge/fml/ModLoader.java @@ -358,7 +358,7 @@ public class ModLoader { return completedStates.contains(state); } - public void runEventGenerator(Function generator) { + public static void runEventGenerator(Function generator) { if (!loadingStateValid) { LOGGER.error("Cowardly refusing to send event generator to a broken mod state"); return; @@ -367,8 +367,7 @@ public class ModLoader { mod.acceptEvent(generator.apply(mod)); } - public void postEvent(T e) { - var cls = e.getClass(); + public static void postEvent(T e) { if (!loadingStateValid) { LOGGER.error("Cowardly refusing to send event {} to a broken mod state", e.getClass().getName()); return; @@ -377,7 +376,7 @@ public class ModLoader { mod.acceptEvent(e); } - public T postEventWithReturn(T e) { + public static T postEventWithReturn(T e) { if (!loadingStateValid) { LOGGER.error("Cowardly refusing to send event {} to a broken mod state", e.getClass().getName()); return e; @@ -388,14 +387,14 @@ public class ModLoader { } @SuppressWarnings("removal") - public void postEventWrapContainerInModOrder(T event) { + public static void postEventWrapContainerInModOrder(T event) { postEventWithWrapInModOrder(event, (mc, e) -> ModLoadingContext.get().setActiveContainer(mc), (mc, e) -> ModLoadingContext.get().setActiveContainer(null) ); } - public void postEventWithWrapInModOrder(T e, BiConsumer pre, BiConsumer post) { + public static void postEventWithWrapInModOrder(T e, BiConsumer pre, BiConsumer post) { if (!loadingStateValid) { LOGGER.error("Cowardly refusing to send event {} to a broken mod state", e.getClass().getName()); return; diff --git a/fmlloader/src/main/java/net/minecraftforge/fml/common/asm/ObjectHolderDefinalize.java b/fmlloader/src/main/java/net/minecraftforge/fml/common/asm/ObjectHolderDefinalize.java deleted file mode 100644 index 70cf3bbee9..0000000000 --- a/fmlloader/src/main/java/net/minecraftforge/fml/common/asm/ObjectHolderDefinalize.java +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Copyright (c) Forge Development LLC and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.minecraftforge.fml.common.asm; - -import java.util.EnumSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.function.Function; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -import org.objectweb.asm.Opcodes; -import org.objectweb.asm.Type; -import org.objectweb.asm.tree.AnnotationNode; -import org.objectweb.asm.tree.ClassNode; -import cpw.mods.modlauncher.serviceapi.ILaunchPluginService; - -/** - * Removes the final modifier from fields with the @ObjectHolder annotation, prevents the JITer from in lining them so our runtime replacements can work. - * Will also de-finalize all fields in on class level annotations. - */ -public class ObjectHolderDefinalize implements ILaunchPluginService { - // Hardcoded map of vanilla classes that should have object holders for each field of the given registry type. - // IMPORTANT: Updates to this collection must be reflected in ObjectHolderRegistry. Duplicated cuz classloaders, yay! - // Classnames are validated in ObjectHolderRegistry. - private static final Map VANILLA_OBJECT_HOLDERS = Stream.of( - new VanillaObjectHolderData("net.minecraft.world.level.block.Blocks", "block", "net.minecraft.world.level.block.Block"), - new VanillaObjectHolderData("net.minecraft.world.item.Items", "item", "net.minecraft.world.item.Item"), - new VanillaObjectHolderData("net.minecraft.world.item.enchantment.Enchantments", "enchantment", "net.minecraft.world.item.enchantment.Enchantment"), - new VanillaObjectHolderData("net.minecraft.world.effect.MobEffects", "mob_effect", "net.minecraft.world.effect.MobEffect"), - new VanillaObjectHolderData("net.minecraft.core.particles.ParticleTypes", "particle_type", "net.minecraft.core.particles.ParticleType"), - new VanillaObjectHolderData("net.minecraft.sounds.SoundEvents", "sound_event", "net.minecraft.sounds.SoundEvent") - ).collect(Collectors.toUnmodifiableMap(VanillaObjectHolderData::holderClass, Function.identity())); - private static final Set VANILLA_OBJECT_HOLDER_CLASSES = VANILLA_OBJECT_HOLDERS.keySet().stream() - .map(it -> it.replace('.', '/')) - .collect(Collectors.toUnmodifiableSet()); - private static final String OBJECT_HOLDER = "Lnet/minecraftforge/registries/ObjectHolder;"; //Don't directly reference this to prevent class loading. - private static final int PUBLIC_STATIC_FINAL_FLAGS = Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC | Opcodes.ACC_FINAL; - - @Override - public String name() { - return "object_holder_definalize"; - } - - private static final EnumSet YAY = EnumSet.of(Phase.AFTER); - private static final EnumSet NAY = EnumSet.noneOf(Phase.class); - - @Override - public EnumSet handlesClass(Type classType, boolean isEmpty) { - if (isEmpty) - return NAY; - - // Let's skip processing classes that definitely don't have object holders - String internalName = classType.getInternalName(); - - // Forge classes that aren't in the debug package (that package is used for tests) - if (internalName.startsWith("net/minecraftforge/") && !internalName.substring(18).contains("debug")) - return NAY; - - // Vanilla classes that don't have object holders - if (internalName.startsWith("com/mojang/")) - return NAY; - - // ...except specific ones we added to the VANILLA_OBJECT_HOLDERS map - if (internalName.startsWith("net/minecraft/") && !VANILLA_OBJECT_HOLDER_CLASSES.contains(internalName)) - return NAY; - - return YAY; - } - - private static boolean hasHolder(List lst) { - return lst != null && lst.stream().anyMatch(n -> n.desc.equals(OBJECT_HOLDER)); - } - - @SuppressWarnings("unused") - private String getValue(List lst) - { - AnnotationNode ann = lst.stream().filter(n -> n.desc.equals(OBJECT_HOLDER)).findFirst().get(); - if (ann.values != null) - { - for (int x = 0; x < ann.values.size() - 1; x += 2) { - if (ann.values.get(x).equals("value")) { - return (String)ann.values.get(x + 1); - } - } - } - return null; - } - - @Override - public int processClassWithFlags(final Phase phase, final ClassNode classNode, final Type classType, final String reason) - { - final AtomicBoolean changes = new AtomicBoolean(); - //Must be public static finals, and non-array objects - - //Fix Annotated Fields before injecting from class level - classNode.fields.stream().filter(f -> ((f.access & PUBLIC_STATIC_FINAL_FLAGS) == PUBLIC_STATIC_FINAL_FLAGS) && f.desc.startsWith("L") && hasHolder(f.visibleAnnotations)).forEach(f -> - { - int prev = f.access; - f.access &= ~Opcodes.ACC_FINAL; //Strip final - f.access |= Opcodes.ACC_SYNTHETIC; //Add Synthetic so we can check in runtime. ? Good idea? - changes.compareAndSet(false, prev != f.access); - }); - - if (VANILLA_OBJECT_HOLDERS.containsKey(classType.getClassName())) //Class level, de-finalize all fields and add @ObjectHolder to them! - { - classNode.fields.stream().filter(f -> ((f.access & PUBLIC_STATIC_FINAL_FLAGS) == PUBLIC_STATIC_FINAL_FLAGS) && f.desc.startsWith("L")).forEach(f -> - { - int prev = f.access; - f.access &= ~Opcodes.ACC_FINAL; - f.access |= Opcodes.ACC_SYNTHETIC; - /*if (!hasHolder(f.visibleAnnotations)) //Add field level annotation, doesn't do anything until after we figure out how ASMDataTable is gatherered - { - if (value == null) - f.visitAnnotation(OBJECT_HOLDER, true); - else - f.visitAnnotation(OBJECT_HOLDER, true).visit("value", value + ":" + f.name.toLowerCase()); - }*/ - changes.compareAndSet(false, prev != f.access); - }); - } - return changes.get() ? ComputeFlags.SIMPLE_REWRITE : ComputeFlags.NO_REWRITE; - } - - private record VanillaObjectHolderData(String holderClass, String registryName, String registryType) {} -} diff --git a/fmlloader/src/main/java/net/minecraftforge/fml/common/asm/RuntimeEnumExtender.java b/fmlloader/src/main/java/net/minecraftforge/fml/common/asm/RuntimeEnumExtender.java index a3ff28e60f..78e0d15df2 100644 --- a/fmlloader/src/main/java/net/minecraftforge/fml/common/asm/RuntimeEnumExtender.java +++ b/fmlloader/src/main/java/net/minecraftforge/fml/common/asm/RuntimeEnumExtender.java @@ -7,11 +7,9 @@ package net.minecraftforge.fml.common.asm; import java.util.EnumSet; import java.util.List; -import java.util.stream.Collectors; import com.mojang.logging.LogUtils; import net.minecraftforge.fml.loading.LoadingModList; -import net.minecraftforge.fml.loading.moddiscovery.ModInfo; import org.objectweb.asm.Label; import org.objectweb.asm.Opcodes; import org.objectweb.asm.Type; @@ -60,10 +58,10 @@ public class RuntimeEnumExtender implements ILaunchPluginService { return NAY; String internalName = classType.getInternalName(); - if (internalName.startsWith("net/minecraftforge/") || internalName.startsWith("com/mojang/")) - return NAY; + if (internalName.startsWith("net/minecraft/client/model") || internalName.startsWith("net/minecraft/world")) + return YAY; - return YAY; + return NAY; } @Override @@ -75,11 +73,6 @@ public class RuntimeEnumExtender implements ILaunchPluginService { if (!classNode.interfaces.contains(MARKER_IFACE.getInternalName())) return ComputeFlags.NO_REWRITE; - if (!classNode.name.startsWith("net/minecraft/")) { - LOGGER.warn("IExtensibleEnum found on non-Minecraft class: {}", classType.getClassName()); - LOGGER.warn("This behaviour is deprecated for removal and will have no effect in a future MC release. Please use a record with static final field instances instead."); - } - Type array = Type.getType("[" + classType.getDescriptor()); String arrayDesc = array.getDescriptor(); diff --git a/fmlloader/src/main/resources/META-INF/services/cpw.mods.modlauncher.serviceapi.ILaunchPluginService b/fmlloader/src/main/resources/META-INF/services/cpw.mods.modlauncher.serviceapi.ILaunchPluginService index 92c39f2307..326f760108 100644 --- a/fmlloader/src/main/resources/META-INF/services/cpw.mods.modlauncher.serviceapi.ILaunchPluginService +++ b/fmlloader/src/main/resources/META-INF/services/cpw.mods.modlauncher.serviceapi.ILaunchPluginService @@ -1,5 +1,4 @@ net.minecraftforge.fml.loading.log4j.SLF4JFixerLaunchPluginService net.minecraftforge.fml.loading.RuntimeDistCleaner net.minecraftforge.fml.common.asm.RuntimeEnumExtender -net.minecraftforge.fml.common.asm.ObjectHolderDefinalize net.minecraftforge.fml.common.asm.CapabilityTokenSubclass \ No newline at end of file diff --git a/forge-transformers/src/main/resources/coremods/finalize_spawn_targets.json b/forge-transformers/src/main/resources/coremods/finalize_spawn_targets.json index fcca4a9b81..893ada6727 100644 --- a/forge-transformers/src/main/resources/coremods/finalize_spawn_targets.json +++ b/forge-transformers/src/main/resources/coremods/finalize_spawn_targets.json @@ -107,7 +107,7 @@ { "class": "net/minecraft/world/level/levelgen/PhantomSpawner", "methods": [ - "tick(Lnet/minecraft/server/level/ServerLevel;ZZ)V" + "tick(Lnet/minecraft/server/level/ServerLevel;Z)V" ] }, { diff --git a/gradle.properties b/gradle.properties index 464f0ab183..efdf527e77 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,11 +5,11 @@ org.gradle.daemon=false org.gradle.parallel=true JAVA_VERSION=21 -MC_VERSION=1.21.8 +MC_VERSION=1.21.9 MC_NEXT_VERSION=1.22 -MCP_VERSION=20250717.105350 +MCP_VERSION=20250930.103108 MAPPING_CHANNEL=official -MAPPING_VERSION=1.21.8 +MAPPING_VERSION=1.21.9 # Set to true before the first build of a new MC version, so we don't do compatibility checks CHECK_COMPATIBILITY=false diff --git a/patches/minecraft/com/mojang/blaze3d/opengl/GlCommandEncoder.java.patch b/patches/minecraft/com/mojang/blaze3d/opengl/GlCommandEncoder.java.patch index d8070c4429..c18b0cc3eb 100644 --- a/patches/minecraft/com/mojang/blaze3d/opengl/GlCommandEncoder.java.patch +++ b/patches/minecraft/com/mojang/blaze3d/opengl/GlCommandEncoder.java.patch @@ -1,6 +1,6 @@ --- a/com/mojang/blaze3d/opengl/GlCommandEncoder.java +++ b/com/mojang/blaze3d/opengl/GlCommandEncoder.java -@@ -132,6 +_,9 @@ +@@ -131,6 +_,9 @@ GlStateManager._colorMask(true, true, true, true); GlStateManager._clear(16384); GlStateManager._glFramebufferTexture2D(36160, 36064, 3553, 0, 0); diff --git a/patches/minecraft/com/mojang/blaze3d/opengl/GlDevice.java.patch b/patches/minecraft/com/mojang/blaze3d/opengl/GlDevice.java.patch index 99f620647b..3f76d6bf8c 100644 --- a/patches/minecraft/com/mojang/blaze3d/opengl/GlDevice.java.patch +++ b/patches/minecraft/com/mojang/blaze3d/opengl/GlDevice.java.patch @@ -1,6 +1,6 @@ --- a/com/mojang/blaze3d/opengl/GlDevice.java +++ b/com/mojang/blaze3d/opengl/GlDevice.java -@@ -89,8 +_,15 @@ +@@ -90,8 +_,15 @@ public GpuTexture createTexture( @Nullable Supplier p_397830_, int p_394481_, TextureFormat p_394839_, int p_391831_, int p_395609_, int p_407582_, int p_408928_ ) { @@ -17,7 +17,7 @@ ); } -@@ -98,6 +_,15 @@ +@@ -99,6 +_,15 @@ public GpuTexture createTexture( @Nullable String p_394142_, int p_395535_, TextureFormat p_394951_, int p_393944_, int p_392329_, int p_408015_, int p_406483_ ) { @@ -33,7 +33,7 @@ if (p_406483_ < 1) { throw new IllegalArgumentException("mipLevels must be at least 1"); } else if (p_408015_ < 1) { -@@ -148,11 +_,14 @@ +@@ -149,11 +_,14 @@ GlStateManager._texImage2D( k, l, @@ -48,7 +48,7 @@ GlConst.toGlType(p_394951_), null ); -@@ -163,11 +_,14 @@ +@@ -164,11 +_,14 @@ GlStateManager._texImage2D( j, i1, @@ -63,7 +63,7 @@ GlConst.toGlType(p_394951_), null ); -@@ -180,7 +_,7 @@ +@@ -181,7 +_,7 @@ } else if (j1 != 0) { throw new IllegalStateException("OpenGL error " + j1); } else { diff --git a/patches/minecraft/com/mojang/blaze3d/opengl/GlStateManager.java.patch b/patches/minecraft/com/mojang/blaze3d/opengl/GlStateManager.java.patch index 1dbc35f1c0..e202072b3e 100644 --- a/patches/minecraft/com/mojang/blaze3d/opengl/GlStateManager.java.patch +++ b/patches/minecraft/com/mojang/blaze3d/opengl/GlStateManager.java.patch @@ -1,6 +1,6 @@ --- a/com/mojang/blaze3d/opengl/GlStateManager.java +++ b/com/mojang/blaze3d/opengl/GlStateManager.java -@@ -89,6 +_,11 @@ +@@ -85,6 +_,11 @@ } } @@ -12,7 +12,7 @@ public static void _disableBlend() { RenderSystem.assertOnRenderThread(); BLEND.mode.disable(); -@@ -404,9 +_,17 @@ +@@ -371,9 +_,17 @@ } } diff --git a/patches/minecraft/com/mojang/blaze3d/pipeline/RenderTarget.java.patch b/patches/minecraft/com/mojang/blaze3d/pipeline/RenderTarget.java.patch index 0051e96798..4cf33375a9 100644 --- a/patches/minecraft/com/mojang/blaze3d/pipeline/RenderTarget.java.patch +++ b/patches/minecraft/com/mojang/blaze3d/pipeline/RenderTarget.java.patch @@ -1,6 +1,6 @@ --- a/com/mojang/blaze3d/pipeline/RenderTarget.java +++ b/com/mojang/blaze3d/pipeline/RenderTarget.java -@@ -92,7 +_,7 @@ +@@ -86,7 +_,7 @@ this.width = p_83951_; this.height = p_83952_; if (this.useDepth) { @@ -9,7 +9,7 @@ this.depthTextureView = gpudevice.createTextureView(this.depthTexture); this.depthTexture.setTextureFilter(FilterMode.NEAREST, false); this.depthTexture.setAddressMode(AddressMode.CLAMP_TO_EDGE); -@@ -166,5 +_,26 @@ +@@ -155,5 +_,26 @@ @Nullable public GpuTextureView getDepthTextureView() { return this.depthTextureView; @@ -25,7 +25,7 @@ + public void enableStencil() { + if (stencilEnabled) return; + stencilEnabled = true; -+ this.resize(viewWidth, viewHeight); ++ this.resize(width, height); + } + + /** diff --git a/patches/minecraft/com/mojang/blaze3d/platform/Window.java.patch b/patches/minecraft/com/mojang/blaze3d/platform/Window.java.patch index d6ce34c689..98e1d80871 100644 --- a/patches/minecraft/com/mojang/blaze3d/platform/Window.java.patch +++ b/patches/minecraft/com/mojang/blaze3d/platform/Window.java.patch @@ -1,16 +1,16 @@ --- a/com/mojang/blaze3d/platform/Window.java +++ b/com/mojang/blaze3d/platform/Window.java -@@ -88,7 +_,8 @@ - GLFW.glfwWindowHint(139267, 2); +@@ -91,7 +_,8 @@ + GLFW.glfwWindowHint(139267, 3); GLFW.glfwWindowHint(139272, 204801); GLFW.glfwWindowHint(139270, 1); -- this.window = GLFW.glfwCreateWindow(this.width, this.height, p_85376_, this.fullscreen && monitor != null ? monitor.getMonitor() : 0L, 0L); -+ this.window = net.minecraftforge.fml.loading.ImmediateWindowHandler.setupMinecraftWindow(()->this.width, ()->this.height, ()->p_85376_, ()->this.fullscreen && monitor != null ? monitor.getMonitor() : 0L); +- this.handle = GLFW.glfwCreateWindow(this.width, this.height, p_85376_, this.fullscreen && monitor != null ? monitor.getMonitor() : 0L, 0L); ++ this.handle = net.minecraftforge.fml.loading.ImmediateWindowHandler.setupMinecraftWindow(()->this.width, ()->this.height, ()->p_85376_, ()->this.fullscreen && monitor != null ? monitor.getMonitor() : 0L); + if (!net.minecraftforge.fml.loading.ImmediateWindowHandler.positionWindow(Optional.ofNullable(monitor), w->this.width = this.windowedWidth = w, h->this.height = this.windowedHeight = h, x->this.x = this.windowedX = x, y->this.y = this.windowedY = y)) { if (monitor != null) { VideoMode videomode = monitor.getPreferredVidMode(this.fullscreen ? this.preferredFullscreenVideoMode : Optional.empty()); this.windowedX = this.x = monitor.getX() + videomode.getWidth() / 2 - this.width / 2; -@@ -100,6 +_,7 @@ +@@ -103,6 +_,7 @@ this.windowedX = this.x = aint1[0]; this.windowedY = this.y = aint[0]; } @@ -18,8 +18,8 @@ this.setMode(); this.refreshFramebufferSize(); -@@ -266,6 +_,9 @@ - GLFW.glfwGetFramebufferSize(this.window, aint, aint1); +@@ -269,6 +_,9 @@ + GLFW.glfwGetFramebufferSize(this.handle, aint, aint1); this.framebufferWidth = aint[0] > 0 ? aint[0] : 1; this.framebufferHeight = aint1[0] > 0 ? aint1[0] : 1; + if (this.framebufferHeight == 0 || this.framebufferWidth == 0) { diff --git a/patches/minecraft/com/mojang/blaze3d/vertex/VertexConsumer.java.patch b/patches/minecraft/com/mojang/blaze3d/vertex/VertexConsumer.java.patch index 0d80a4fe87..1d0ea72adc 100644 --- a/patches/minecraft/com/mojang/blaze3d/vertex/VertexConsumer.java.patch +++ b/patches/minecraft/com/mojang/blaze3d/vertex/VertexConsumer.java.patch @@ -9,7 +9,7 @@ VertexConsumer addVertex(float p_344294_, float p_342213_, float p_344859_); VertexConsumer setColor(int p_342749_, int p_344324_, int p_343336_, int p_342831_); -@@ -135,9 +_,11 @@ +@@ -131,9 +_,11 @@ int j1 = ARGB.color(k, (int)f3, (int)f4, (int)f5); int k1 = LightTexture.lightCoordsWithEmission(p_331444_[i1], l); diff --git a/patches/minecraft/com/mojang/blaze3d/vertex/VertexFormat.java.patch b/patches/minecraft/com/mojang/blaze3d/vertex/VertexFormat.java.patch index c3e55621c2..03ac8a282b 100644 --- a/patches/minecraft/com/mojang/blaze3d/vertex/VertexFormat.java.patch +++ b/patches/minecraft/com/mojang/blaze3d/vertex/VertexFormat.java.patch @@ -1,15 +1,15 @@ --- a/com/mojang/blaze3d/vertex/VertexFormat.java +++ b/com/mojang/blaze3d/vertex/VertexFormat.java -@@ -21,7 +_,7 @@ +@@ -20,7 +_,7 @@ @OnlyIn(Dist.CLIENT) @DontObfuscate -public class VertexFormat { +public class VertexFormat implements net.minecraftforge.client.extensions.IForgeVertexFormat { public static final int UNKNOWN_ELEMENT = -1; - private static final boolean USE_STAGING_BUFFER_WORKAROUND = Util.getPlatform() == Util.OS.WINDOWS && Util.isAarch64(); - @Nullable -@@ -35,6 +_,7 @@ + private final List elements; + private final List names; +@@ -31,6 +_,7 @@ private GpuBuffer immediateDrawVertexBuffer; @Nullable private GpuBuffer immediateDrawIndexBuffer; @@ -17,7 +17,7 @@ VertexFormat(List p_343616_, List p_345241_, IntList p_345522_, int p_344162_) { this.elements = p_343616_; -@@ -47,6 +_,11 @@ +@@ -43,6 +_,11 @@ int j = vertexformatelement != null ? p_343616_.indexOf(vertexformatelement) : -1; this.offsetsByElement[i] = j != -1 ? p_345522_.getInt(j) : -1; } @@ -29,8 +29,8 @@ } public static VertexFormat.Builder builder() { -@@ -169,6 +_,9 @@ - ); +@@ -141,6 +_,9 @@ + this.immediateDrawIndexBuffer = uploadToBuffer(this.immediateDrawIndexBuffer, p_391835_, 72, () -> "Immediate index buffer for " + this); return this.immediateDrawIndexBuffer; } + diff --git a/patches/minecraft/com/mojang/realmsclient/gui/screens/RealmsGenericErrorScreen.java.patch b/patches/minecraft/com/mojang/realmsclient/gui/screens/RealmsGenericErrorScreen.java.patch index e28eada9d5..65c7122a5c 100644 --- a/patches/minecraft/com/mojang/realmsclient/gui/screens/RealmsGenericErrorScreen.java.patch +++ b/patches/minecraft/com/mojang/realmsclient/gui/screens/RealmsGenericErrorScreen.java.patch @@ -4,12 +4,12 @@ } @Override -+ public boolean keyPressed(int key, int scanCode, int modifiers) { -+ if (key == org.lwjgl.glfw.GLFW.GLFW_KEY_ESCAPE) { ++ public boolean keyPressed(net.minecraft.client.input.KeyEvent event) { ++ if (event.key() == org.lwjgl.glfw.GLFW.GLFW_KEY_ESCAPE) { + minecraft.setScreen(this.nextScreen); + return true; + } -+ return super.keyPressed(key, scanCode, modifiers); ++ return super.keyPressed(event); + } + + @Override diff --git a/patches/minecraft/net/minecraft/CrashReportCategory.java.patch b/patches/minecraft/net/minecraft/CrashReportCategory.java.patch index f00e05ece7..3979566f0b 100644 --- a/patches/minecraft/net/minecraft/CrashReportCategory.java.patch +++ b/patches/minecraft/net/minecraft/CrashReportCategory.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/CrashReportCategory.java +++ b/net/minecraft/CrashReportCategory.java -@@ -112,8 +_,10 @@ +@@ -116,8 +_,10 @@ if (astacktraceelement.length <= 0) { return 0; } else { @@ -13,7 +13,7 @@ return this.stackTrace.length; } } -@@ -160,16 +_,16 @@ +@@ -164,16 +_,16 @@ if (this.stackTrace != null && this.stackTrace.length > 0) { p_128169_.append("\nStacktrace:"); diff --git a/patches/minecraft/net/minecraft/SharedConstants.java.patch b/patches/minecraft/net/minecraft/SharedConstants.java.patch index 1a3df787be..a975e2d686 100644 --- a/patches/minecraft/net/minecraft/SharedConstants.java.patch +++ b/patches/minecraft/net/minecraft/SharedConstants.java.patch @@ -1,10 +1,10 @@ --- a/net/minecraft/SharedConstants.java +++ b/net/minecraft/SharedConstants.java -@@ -175,6 +_,7 @@ +@@ -224,6 +_,7 @@ } static { + if (System.getProperty("io.netty.leakDetection.level") == null) // Forge: allow level to be manually specified ResourceLeakDetector.setLevel(NETTY_LEAK_DETECTION); - CommandSyntaxException.ENABLE_COMMAND_STACK_TRACES = false; + CommandSyntaxException.ENABLE_COMMAND_STACK_TRACES = COMMAND_STACK_TRACES; CommandSyntaxException.BUILT_IN_EXCEPTIONS = new BrigadierExceptions(); diff --git a/patches/minecraft/net/minecraft/Util.java.patch b/patches/minecraft/net/minecraft/Util.java.patch index 5fc137a640..deec93a84a 100644 --- a/patches/minecraft/net/minecraft/Util.java.patch +++ b/patches/minecraft/net/minecraft/Util.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/Util.java +++ b/net/minecraft/Util.java -@@ -268,7 +_,7 @@ +@@ -266,7 +_,7 @@ .getSchema(DataFixUtils.makeKey(SharedConstants.getCurrentVersion().dataVersion().version())) .getChoiceType(p_137552_, p_137553_); } catch (IllegalArgumentException illegalargumentexception) { diff --git a/patches/minecraft/net/minecraft/advancements/Advancement.java.patch b/patches/minecraft/net/minecraft/advancements/Advancement.java.patch index 454fffd962..ad03bdbfce 100644 --- a/patches/minecraft/net/minecraft/advancements/Advancement.java.patch +++ b/patches/minecraft/net/minecraft/advancements/Advancement.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/advancements/Advancement.java +++ b/net/minecraft/advancements/Advancement.java -@@ -226,7 +_,11 @@ +@@ -233,7 +_,11 @@ } public AdvancementHolder save(Consumer p_138390_, String p_138391_) { diff --git a/patches/minecraft/net/minecraft/client/Camera.java.patch b/patches/minecraft/net/minecraft/client/Camera.java.patch index b6e7ca64a8..2a9cd3d7e0 100644 --- a/patches/minecraft/net/minecraft/client/Camera.java.patch +++ b/patches/minecraft/net/minecraft/client/Camera.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/Camera.java +++ b/net/minecraft/client/Camera.java -@@ -133,9 +_,13 @@ +@@ -132,9 +_,13 @@ } protected void setRotation(float p_90573_, float p_90574_) { @@ -15,7 +15,7 @@ FORWARDS.rotate(this.rotation, this.forwards); UP.rotate(this.rotation, this.up); LEFT.rotate(this.rotation, this.left); -@@ -251,6 +_,13 @@ +@@ -250,6 +_,13 @@ public float getPartialTickTime() { return this.partialTickTime; diff --git a/patches/minecraft/net/minecraft/client/KeyMapping.java.patch b/patches/minecraft/net/minecraft/client/KeyMapping.java.patch index 77ab4376bd..1be5648d31 100644 --- a/patches/minecraft/net/minecraft/client/KeyMapping.java.patch +++ b/patches/minecraft/net/minecraft/client/KeyMapping.java.patch @@ -1,35 +1,27 @@ --- a/net/minecraft/client/KeyMapping.java +++ b/net/minecraft/client/KeyMapping.java -@@ -15,9 +_,9 @@ +@@ -19,9 +_,9 @@ import net.minecraftforge.api.distmarker.OnlyIn; @OnlyIn(Dist.CLIENT) -public class KeyMapping implements Comparable { +public class KeyMapping implements Comparable, net.minecraftforge.client.extensions.IForgeKeyMapping { private static final Map ALL = Maps.newHashMap(); -- private static final Map MAP = Maps.newHashMap(); +- private static final Map> MAP = Maps.newHashMap(); + private static final net.minecraftforge.client.settings.KeyMappingLookup MAP = new net.minecraftforge.client.settings.KeyMappingLookup(); - private static final Set CATEGORIES = Sets.newHashSet(); - public static final String CATEGORY_MOVEMENT = "key.categories.movement"; - public static final String CATEGORY_MISC = "key.categories.misc"; -@@ -43,14 +_,14 @@ - private int clickCount; - - public static void click(InputConstants.Key p_90836_) { -- KeyMapping keymapping = MAP.get(p_90836_); -+ for (KeyMapping keymapping : MAP.getAll(p_90836_)) - if (keymapping != null) { - keymapping.clickCount++; - } + private final String name; + private final InputConstants.Key defaultKey; + private final KeyMapping.Category category; +@@ -38,7 +_,7 @@ } - public static void set(InputConstants.Key p_90838_, boolean p_90839_) { -- KeyMapping keymapping = MAP.get(p_90838_); -+ for (KeyMapping keymapping : MAP.getAll(p_90838_)) - if (keymapping != null) { - keymapping.setDown(p_90839_); - } -@@ -101,7 +_,7 @@ + private static void forAllKeyMappings(InputConstants.Key p_424096_, Consumer p_427756_) { +- List list = MAP.get(p_424096_); ++ List list = MAP.getAll(p_424096_); + if (list != null && !list.isEmpty()) { + for (KeyMapping keymapping : list) { + p_427756_.accept(keymapping); +@@ -100,7 +_,7 @@ } public boolean isDown() { @@ -37,26 +29,26 @@ + return this.isDown && isConflictContextAndModifierActive(); } - public String getCategory() { -@@ -137,7 +_,16 @@ + public KeyMapping.Category getCategory() { +@@ -140,7 +_,16 @@ public int compareTo(KeyMapping p_90841_) { - return this.category.equals(p_90841_.category) + return this.category == p_90841_.category ? I18n.get(this.name).compareTo(I18n.get(p_90841_.name)) -- : CATEGORY_SORT_ORDER.get(this.category).compareTo(CATEGORY_SORT_ORDER.get(p_90841_.category)); +- : Integer.compare(KeyMapping.Category.SORT_ORDER.indexOf(this.category), KeyMapping.Category.SORT_ORDER.indexOf(p_90841_.category)); + : compareSort(this.category, p_90841_.category); + } + -+ private static int compareSort(String c1, String c2) { -+ Integer o1 = CATEGORY_SORT_ORDER.get(c1); -+ Integer o2 = CATEGORY_SORT_ORDER.get(c2); -+ if (o1 == null && o2 != null) return 1; -+ if (o1 != null && o2 == null) return -1; -+ if (o1 == null && o2 == null) return I18n.get(c1).compareTo(I18n.get(c2)); -+ return o1.compareTo(o2); ++ private static int compareSort(Category c1, Category c2) { ++ int o1 = KeyMapping.Category.SORT_ORDER.indexOf(c1); ++ int o2 = KeyMapping.Category.SORT_ORDER.indexOf(c2); ++ if (o1 == -1 && o2 != -1) return 1; ++ if (o1 != -1 && o2 == -1) return -1; ++ if (o1 == -1 && o2 == -1) return I18n.get(c1.id().toLanguageKey("key.category")).compareTo(I18n.get(c1.id().toLanguageKey("key.category"))); ++ return o1 - o2; } public static Supplier createNameSupplier(String p_90843_) { -@@ -146,6 +_,20 @@ +@@ -149,6 +_,20 @@ } public boolean same(KeyMapping p_90851_) { @@ -77,7 +69,7 @@ return this.key.equals(p_90851_.key); } -@@ -164,11 +_,13 @@ +@@ -167,11 +_,13 @@ } public Component getTranslatedKeyMessage() { @@ -92,7 +84,14 @@ } public String saveString() { -@@ -182,5 +_,88 @@ +@@ -183,12 +_,94 @@ + } + + private void registerMapping(InputConstants.Key p_423386_) { +- MAP.computeIfAbsent(p_423386_, p_420623_ -> new ArrayList<>()).add(this); ++ MAP.put(p_423386_, this); + } + @Nullable public static KeyMapping get(String p_378660_) { return ALL.get(p_378660_); @@ -105,28 +104,28 @@ + /** + * Convenience constructor for creating KeyBindings with keyConflictContext set. + */ -+ public KeyMapping(String description, net.minecraftforge.client.settings.IKeyConflictContext keyConflictContext, final InputConstants.Type inputType, final int keyCode, String category) { ++ public KeyMapping(String description, net.minecraftforge.client.settings.IKeyConflictContext keyConflictContext, final InputConstants.Type inputType, final int keyCode, Category category) { + this(description, keyConflictContext, inputType.getOrCreate(keyCode), category); + } + + /** + * Convenience constructor for creating KeyBindings with keyConflictContext set. + */ -+ public KeyMapping(String description, net.minecraftforge.client.settings.IKeyConflictContext keyConflictContext, InputConstants.Key keyCode, String category) { ++ public KeyMapping(String description, net.minecraftforge.client.settings.IKeyConflictContext keyConflictContext, InputConstants.Key keyCode, Category category) { + this(description, keyConflictContext, net.minecraftforge.client.settings.KeyModifier.NONE, keyCode, category); + } + + /** + * Convenience constructor for creating KeyBindings with keyConflictContext and keyModifier set. + */ -+ public KeyMapping(String description, net.minecraftforge.client.settings.IKeyConflictContext keyConflictContext, net.minecraftforge.client.settings.KeyModifier keyModifier, final InputConstants.Type inputType, final int keyCode, String category) { ++ public KeyMapping(String description, net.minecraftforge.client.settings.IKeyConflictContext keyConflictContext, net.minecraftforge.client.settings.KeyModifier keyModifier, final InputConstants.Type inputType, final int keyCode, Category category) { + this(description, keyConflictContext, keyModifier, inputType.getOrCreate(keyCode), category); + } + + /** + * Convenience constructor for creating KeyBindings with keyConflictContext and keyModifier set. + */ -+ public KeyMapping(String description, net.minecraftforge.client.settings.IKeyConflictContext keyConflictContext, net.minecraftforge.client.settings.KeyModifier keyModifier, InputConstants.Key keyCode, String category) { ++ public KeyMapping(String description, net.minecraftforge.client.settings.IKeyConflictContext keyConflictContext, net.minecraftforge.client.settings.KeyModifier keyModifier, InputConstants.Key keyCode, Category category) { + this.name = description; + this.key = keyCode; + this.defaultKey = keyCode; @@ -138,7 +137,6 @@ + this.keyModifier = net.minecraftforge.client.settings.KeyModifier.NONE; + ALL.put(description, this); + MAP.put(keyCode, this); -+ CATEGORIES.add(category); + } + + @Override @@ -180,4 +178,5 @@ + + MAP.put(keyCode, this); } - } + + @OnlyIn(Dist.CLIENT) diff --git a/patches/minecraft/net/minecraft/client/KeyboardHandler.java.patch b/patches/minecraft/net/minecraft/client/KeyboardHandler.java.patch index d1cfa7addd..cb2201e73f 100644 --- a/patches/minecraft/net/minecraft/client/KeyboardHandler.java.patch +++ b/patches/minecraft/net/minecraft/client/KeyboardHandler.java.patch @@ -1,39 +1,34 @@ --- a/net/minecraft/client/KeyboardHandler.java +++ b/net/minecraft/client/KeyboardHandler.java -@@ -440,12 +_,12 @@ +@@ -499,12 +_,12 @@ if (screen != null) { try { - if (p_90897_ != 1 && p_90897_ != 2) { -- if (p_90897_ == 0 && screen.keyReleased(p_90895_, p_90896_, p_90898_)) { -+ if (p_90897_ == 0 && net.minecraftforge.client.ForgeHooksClient.onScreenKeyReleased(screen, p_90895_, p_90896_, p_90898_)) { + if (p_90895_ != 1 && p_90895_ != 2) { +- if (p_90895_ == 0 && screen.keyReleased(p_423534_)) { ++ if (p_90895_ == 0 && net.minecraftforge.client.ForgeHooksClient.onScreenKeyReleased(screen, p_423534_)) { return; } } else { screen.afterKeyboardAction(); -- if (screen.keyPressed(p_90895_, p_90896_, p_90898_)) { -+ if (net.minecraftforge.client.ForgeHooksClient.onScreenKeyPressed(screen, p_90895_, p_90896_, p_90898_)) { - return; - } - } -@@ -504,6 +_,7 @@ +- if (screen.keyPressed(p_423534_)) { ++ if (net.minecraftforge.client.ForgeHooksClient.onScreenKeyPressed(screen, p_423534_)) { + if (this.minecraft.screen == null) { + InputConstants.Key inputconstants$key = InputConstants.getKey(p_423534_); + KeyMapping.set(inputconstants$key, false); +@@ -568,6 +_,7 @@ } } } -+ net.minecraftforge.client.ForgeHooksClient.onKeyInput(p_90895_, p_90896_, p_90897_, p_90898_); ++ net.minecraftforge.client.ForgeHooksClient.onKeyInput(p_423534_, p_90895_); } } -@@ -513,10 +_,10 @@ +@@ -576,7 +_,7 @@ + Screen screen = this.minecraft.screen; if (screen != null && this.minecraft.getOverlay() == null) { try { - if (Character.isBmpCodePoint(p_90891_)) { -- screen.charTyped((char)p_90891_, p_90892_); -+ net.minecraftforge.client.ForgeHooksClient.onScreenCharTyped(screen, (char)p_90891_, p_90892_); - } else if (Character.isValidCodePoint(p_90891_)) { -- screen.charTyped(Character.highSurrogate(p_90891_), p_90892_); -- screen.charTyped(Character.lowSurrogate(p_90891_), p_90892_); -+ net.minecraftforge.client.ForgeHooksClient.onScreenCharTyped(screen, Character.highSurrogate(p_90891_), p_90892_); -+ net.minecraftforge.client.ForgeHooksClient.onScreenCharTyped(screen, Character.lowSurrogate(p_90891_), p_90892_); - } +- screen.charTyped(p_427531_); ++ net.minecraftforge.client.ForgeHooksClient.onScreenCharTyped(screen, p_427531_); } catch (Throwable throwable) { CrashReport crashreport = CrashReport.forThrowable(throwable, "charTyped event handler"); + screen.fillCrashDetails(crashreport); diff --git a/patches/minecraft/net/minecraft/client/Minecraft.java.patch b/patches/minecraft/net/minecraft/client/Minecraft.java.patch index 14f54a5979..f796dd905a 100644 --- a/patches/minecraft/net/minecraft/client/Minecraft.java.patch +++ b/patches/minecraft/net/minecraft/client/Minecraft.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/Minecraft.java +++ b/net/minecraft/client/Minecraft.java -@@ -256,7 +_,7 @@ +@@ -260,7 +_,7 @@ import org.slf4j.Logger; @OnlyIn(Dist.CLIENT) @@ -8,8 +8,8 @@ +public class Minecraft extends ReentrantBlockableEventLoop implements WindowEventHandler, net.minecraftforge.client.extensions.IForgeMinecraft { static Minecraft instance; private static final Logger LOGGER = LogUtils.getLogger(); - public static final boolean ON_OSX = Util.getPlatform() == Util.OS.OSX; -@@ -435,7 +_,6 @@ + private static final int MAX_TICKS_PER_UPDATE = 10; +@@ -439,7 +_,6 @@ } }, Util.nonCriticalIoPool()); LOGGER.info("Setting user: {}", this.user.getName()); @@ -17,19 +17,19 @@ this.demo = p_91084_.game.demo; this.allowsMultiplayer = !p_91084_.game.disableMultiplayer; this.allowsChat = !p_91084_.game.disableChat; -@@ -486,10 +_,9 @@ +@@ -491,10 +_,9 @@ LOGGER.error("Couldn't set icon", (Throwable)ioexception); } + // FORGE: Move mouse and keyboard handler setup further below this.mouseHandler = new MouseHandler(this); -- this.mouseHandler.setup(this.window.getWindow()); +- this.mouseHandler.setup(this.window); this.keyboardHandler = new KeyboardHandler(this); -- this.keyboardHandler.setup(this.window.getWindow()); +- this.keyboardHandler.setup(this.window); RenderSystem.initRenderer( - this.window.getWindow(), + this.window.handle(), this.options.glDebugVerbosity, -@@ -500,6 +_,7 @@ +@@ -505,6 +_,7 @@ LOGGER.info("Using optional rendering extensions: {}", String.join(", ", RenderSystem.getDevice().getEnabledExtensions())); this.mainRenderTarget = new MainTarget(this.window.getWidth(), this.window.getHeight()); this.resourceManager = new ReloadableResourceManager(PackType.CLIENT_RESOURCES); @@ -37,33 +37,33 @@ this.resourcePackRepository.reload(); this.options.loadSelectedResourcePacks(this.resourcePackRepository); this.languageManager = new LanguageManager(this.options.languageCode, p_340763_ -> { -@@ -578,6 +_,7 @@ - this.blockEntityRenderDispatcher = new BlockEntityRenderDispatcher(this.font, this.modelManager.entityModels(), this.blockRenderer, this.itemModelResolver, this.itemRenderer, this.entityRenderDispatcher); - this.resourceManager.registerReloadListener(this.blockEntityRenderDispatcher); - this.particleEngine = new ParticleEngine(this.level, this.textureManager); -+ net.minecraftforge.client.ForgeHooksClient.onRegisterParticleProviders(this.particleEngine); - this.resourceManager.registerReloadListener(this.particleEngine); - this.paintingTextures = new PaintingTextureManager(this.textureManager); - this.resourceManager.registerReloadListener(this.paintingTextures); -@@ -593,6 +_,9 @@ +@@ -593,6 +_,7 @@ + this.particleResources = new ParticleResources(); + this.resourceManager.registerReloadListener(this.particleResources); + this.particleEngine = new ParticleEngine(this.level, this.particleResources); ++ net.minecraftforge.client.ForgeHooksClient.onRegisterParticleProviders(this.particleResources); + this.particleResources.onReload(this.particleEngine::clearParticles); + this.waypointStyles = new WaypointStyleManager(); + this.resourceManager.registerReloadListener(this.waypointStyles); +@@ -604,6 +_,9 @@ this.resourceManager.registerReloadListener(this.gpuWarnlistManager); this.resourceManager.registerReloadListener(this.regionalCompliancies); this.gui = new Gui(this); + // FORGE: Moved keyboard and mouse handler setup below ingame gui creation to prevent NPEs in them. -+ this.mouseHandler.setup(this.window.getWindow()); -+ this.keyboardHandler.setup(this.window.getWindow()); - this.debugRenderer = new DebugRenderer(this); ++ this.mouseHandler.setup(this.window); ++ this.keyboardHandler.setup(this.window); RealmsClient realmsclient = RealmsClient.getOrCreate(this); this.realmsDataFetcher = new RealmsDataFetcher(realmsclient); -@@ -626,6 +_,7 @@ + RenderSystem.setErrorCallback(this::onFullscreenError); +@@ -636,6 +_,7 @@ } } + net.minecraftforge.client.ForgeHooksClient.initClientHooks(this, this.resourceManager); this.window.updateVsync(this.options.enableVsync().get()); this.window.updateRawMouseInput(this.options.rawMouseInput().get()); - this.window.setDefaultErrorCallback(); -@@ -648,16 +_,17 @@ + this.window.setAllowCursorChanges(this.options.allowCursorChanges().get()); +@@ -659,16 +_,17 @@ GameLoadTimesEvent.INSTANCE.beginStep(TelemetryProperty.LOAD_TIME_LOADING_OVERLAY_MS); Minecraft.GameLoadCookie minecraft$gameloadcookie = new Minecraft.GameLoadCookie(realmsclient, p_91084_.quickPlay); this.setOverlay( @@ -84,7 +84,7 @@ ); this.quickPlayLog = QuickPlayLog.of(p_91084_.quickPlay.logPath()); this.framerateLimitTracker = new FramerateLimitTracker(this.options, this); -@@ -759,6 +_,7 @@ +@@ -787,6 +_,7 @@ StringBuilder stringbuilder = new StringBuilder("Minecraft"); if (checkModStatus().shouldReportAsModified()) { stringbuilder.append("*"); @@ -92,16 +92,16 @@ } stringbuilder.append(" "); -@@ -782,6 +_,8 @@ +@@ -810,6 +_,8 @@ } private UserApiService createUserApiService(YggdrasilAuthenticationService p_193586_, GameConfig p_193587_) { + if ("0".equals(p_193587_.user.user.getAccessToken())) // Forge: We use "0" in dev. Short circuit to stop exception spam. + return UserApiService.OFFLINE; - return p_193587_.user.user.getType() != User.Type.MSA - ? UserApiService.OFFLINE - : p_193586_.createUserApiService(p_193587_.user.user.getAccessToken()); -@@ -792,7 +_,7 @@ + return p_193587_.game.offlineDeveloperMode ? UserApiService.OFFLINE : p_193586_.createUserApiService(p_193587_.user.user.getAccessToken()); + } + +@@ -822,7 +_,7 @@ } private void rollbackResourcePacks(Throwable p_91240_, @Nullable Minecraft.GameLoadCookie p_299515_) { @@ -110,7 +110,7 @@ this.clearResourcePacksOnError(p_91240_, null, p_299515_); } else { Util.throwAsRuntime(p_91240_); -@@ -1078,12 +_,6 @@ +@@ -1108,12 +_,6 @@ LOGGER.error("setScreen called from non-game thread"); } @@ -120,34 +120,34 @@ - this.setLastInputType(InputType.NONE); - } - - if (p_91153_ == null && this.clientLevelTeardownInProgress) { - throw new IllegalStateException("Trying to return to in-game GUI during disconnection"); - } else { -@@ -1097,6 +_,23 @@ - } + if (p_91153_ == null) { + if (this.clientLevelTeardownInProgress) { + throw new IllegalStateException("Trying to return to in-game GUI during disconnection"); +@@ -1132,6 +_,23 @@ } + } -+ net.minecraftforge.client.ForgeHooksClient.clearGuiLayers(this); -+ Screen old = this.screen; -+ if (p_91153_ != null) { -+ var event = net.minecraftforge.client.event.ForgeEventFactoryClient.onScreenOpening(old, p_91153_); -+ if (event == null) return; -+ p_91153_ = event; -+ } ++ net.minecraftforge.client.ForgeHooksClient.clearGuiLayers(this); ++ Screen old = this.screen; ++ if (p_91153_ != null) { ++ var event = net.minecraftforge.client.event.ForgeEventFactoryClient.onScreenOpening(old, p_91153_); ++ if (event == null) return; ++ p_91153_ = event; ++ } + -+ if (p_91153_ != old) { -+ if (old != null) { -+ net.minecraftforge.client.event.ForgeEventFactoryClient.onScreenClose(old); -+ old.removed(); -+ } else { -+ this.setLastInputType(InputType.NONE); -+ } ++ if (p_91153_ != old) { ++ if (old != null) { ++ net.minecraftforge.client.event.ForgeEventFactoryClient.onScreenClose(old); ++ old.removed(); ++ } else { ++ this.setLastInputType(InputType.NONE); + } ++ } + - this.screen = p_91153_; - if (this.screen != null) { - this.screen.added(); -@@ -1180,6 +_,7 @@ + this.screen = p_91153_; + if (this.screen != null) { + this.screen.added(); +@@ -1214,6 +_,7 @@ FreeTypeUtil.destroy(); Util.shutdownExecutors(); RenderSystem.getDevice().close(); @@ -155,19 +155,17 @@ } catch (Throwable throwable) { LOGGER.error("Shutdown failure!", throwable); throw throwable; -@@ -1248,9 +_,11 @@ - this.mouseHandler.handleAccumulatedMovement(); - profilerfiller.pop(); +@@ -1278,7 +_,9 @@ + RenderSystem.getDevice().createCommandEncoder().clearColorAndDepthTextures(rendertarget.getColorTexture(), 0, rendertarget.getDepthTexture(), 1.0); + profilerfiller.push("gameRenderer"); if (!this.noRender) { + net.minecraftforge.client.event.ForgeEventFactoryClient.onRenderTickStart(this.deltaTracker); - profilerfiller.popPush("gameRenderer"); this.gameRenderer.render(this.deltaTracker, p_91384_); - profilerfiller.pop(); + net.minecraftforge.client.event.ForgeEventFactoryClient.onRenderTickEnd(this.deltaTracker); } - profilerfiller.push("blit"); -@@ -1379,10 +_,12 @@ + profilerfiller.popPush("blit"); +@@ -1388,10 +_,12 @@ this.window.setGuiScale(i); if (this.screen != null) { this.screen.resize(this, this.window.getGuiScaledWidth(), this.window.getGuiScaledHeight()); @@ -180,7 +178,7 @@ this.gameRenderer.resize(this.window.getWidth(), this.window.getHeight()); this.mouseHandler.setIgnoreFirstMove(); } -@@ -1520,6 +_,7 @@ +@@ -1529,6 +_,7 @@ } public void stop() { @@ -188,7 +186,7 @@ this.running = false; } -@@ -1547,10 +_,18 @@ +@@ -1556,10 +_,18 @@ if (p_91387_ && this.hitResult != null && this.hitResult.getType() == HitResult.Type.BLOCK) { BlockHitResult blockhitresult = (BlockHitResult)this.hitResult; BlockPos blockpos = blockhitresult.getBlockPos(); @@ -197,20 +195,20 @@ + var inputEvent = new net.minecraftforge.client.event.InputEvent.InteractionKeyMappingTriggered(0, this.options.keyAttack, InteractionHand.MAIN_HAND); + if (net.minecraftforge.client.event.InputEvent.InteractionKeyMappingTriggered.BUS.post(inputEvent)) { + if (inputEvent.shouldSwingHand()) { -+ this.particleEngine.addBlockHitEffects(blockpos, blockhitresult); ++ this.level.addBreakingBlockEffect(blockpos, blockhitresult); + this.player.swing(InteractionHand.MAIN_HAND); + } + return; + } Direction direction = blockhitresult.getDirection(); - if (this.gameMode.continueDestroyBlock(blockpos, direction)) { -- this.particleEngine.crack(blockpos, direction); +- this.level.addBreakingBlockEffect(blockpos, direction); + if (this.gameMode.continueDestroyBlock(blockpos, direction) && inputEvent.shouldSwingHand()) { -+ this.particleEngine.addBlockHitEffects(blockpos, blockhitresult); ++ this.level.addBreakingBlockEffect(blockpos, blockhitresult); this.player.swing(InteractionHand.MAIN_HAND); } } -@@ -1578,6 +_,8 @@ +@@ -1587,6 +_,8 @@ return false; } else { boolean flag = false; @@ -219,7 +217,7 @@ switch (this.hitResult.getType()) { case ENTITY: this.gameMode.attack(this.player, ((EntityHitResult)this.hitResult).getEntity()); -@@ -1585,7 +_,7 @@ +@@ -1594,7 +_,7 @@ case BLOCK: BlockHitResult blockhitresult = (BlockHitResult)this.hitResult; BlockPos blockpos = blockhitresult.getBlockPos(); @@ -228,7 +226,7 @@ this.gameMode.startDestroyBlock(blockpos, blockhitresult.getDirection()); if (this.level.getBlockState(blockpos).isAir()) { flag = true; -@@ -1598,8 +_,10 @@ +@@ -1607,8 +_,10 @@ } this.player.resetAttackStrengthTicker(); @@ -239,7 +237,7 @@ this.player.swing(InteractionHand.MAIN_HAND); return flag; } -@@ -1615,6 +_,12 @@ +@@ -1624,6 +_,12 @@ } for (InteractionHand interactionhand : InteractionHand.values()) { @@ -252,7 +250,7 @@ ItemStack itemstack = this.player.getItemInHand(interactionhand); if (!itemstack.isItemEnabled(this.level.enabledFeatures())) { return; -@@ -1635,7 +_,7 @@ +@@ -1644,7 +_,7 @@ } if (interactionresult instanceof InteractionResult.Success interactionresult$success2) { @@ -261,7 +259,7 @@ this.player.swing(interactionhand); } -@@ -1647,7 +_,7 @@ +@@ -1656,7 +_,7 @@ int i = itemstack.getCount(); InteractionResult interactionresult1 = this.gameMode.useItemOn(this.player, interactionhand, blockhitresult); if (interactionresult1 instanceof InteractionResult.Success interactionresult$success) { @@ -270,7 +268,7 @@ this.player.swing(interactionhand); if (!itemstack.isEmpty() && (itemstack.getCount() != i || this.player.hasInfiniteMaterials())) { this.gameRenderer.itemInHandRenderer.itemUsed(interactionhand); -@@ -1663,6 +_,9 @@ +@@ -1672,6 +_,9 @@ } } @@ -280,7 +278,7 @@ if (!itemstack.isEmpty() && this.gameMode.useItem(this.player, interactionhand) instanceof InteractionResult.Success interactionresult$success1) { if (interactionresult$success1.swingSource() == InteractionResult.SwingSource.CLIENT) { -@@ -1692,6 +_,8 @@ +@@ -1701,6 +_,8 @@ } ProfilerFiller profilerfiller = Profiler.get(); @@ -289,7 +287,7 @@ profilerfiller.push("gui"); this.chatListener.tick(); this.gui.tick(this.pause); -@@ -1778,6 +_,7 @@ +@@ -1786,6 +_,7 @@ this.tutorial.tick(); @@ -297,7 +295,7 @@ try { this.level.tick(() -> true); } catch (Throwable throwable1) { -@@ -1791,6 +_,7 @@ +@@ -1799,6 +_,7 @@ throw new ReportedException(crashreport1); } @@ -305,7 +303,7 @@ } profilerfiller.popPush("animateTick"); -@@ -1815,6 +_,7 @@ +@@ -1823,6 +_,7 @@ profilerfiller.popPush("keyboard"); this.keyboardHandler.tick(); profilerfiller.pop(); @@ -313,15 +311,15 @@ } private boolean isLevelRunningNormally() { -@@ -2031,6 +_,7 @@ +@@ -2041,6 +_,7 @@ } - public void setLevel(ClientLevel p_91157_, ReceivingLevelScreen.Reason p_335893_) { + public void setLevel(ClientLevel p_91157_) { + if (this.level != null) net.minecraftforge.event.ForgeEventFactory.onLevelUnload(this.level); - this.updateScreenAndTick(new ReceivingLevelScreen(() -> false, p_335893_)); this.level = p_91157_; this.updateLevelInEngines(p_91157_); -@@ -2068,6 +_,7 @@ + } +@@ -2094,6 +_,7 @@ IntegratedServer integratedserver = this.singleplayerServer; this.singleplayerServer = null; this.gameRenderer.resetData(); @@ -329,27 +327,27 @@ this.gameMode = null; this.narrator.clear(); this.clientLevelTeardownInProgress = true; -@@ -2075,6 +_,7 @@ +@@ -2101,6 +_,7 @@ try { - this.updateScreenAndTick(p_335030_); if (this.level != null) { -+ net.minecraftforge.event.ForgeEventFactory.onLevelUnload(this.level); - if (integratedserver != null) { - ProfilerFiller profilerfiller = Profiler.get(); - profilerfiller.push("waitForServer"); -@@ -2088,6 +_,7 @@ - this.gui.onDisconnected(); - this.isLocalServer = false; ++ net.minecraftforge.event.ForgeEventFactory.onLevelUnload(this.level); + } + + if (integratedserver != null) { +@@ -2113,6 +_,7 @@ + } + + profilerfiller.pop(); + net.minecraftforge.client.ForgeHooksClient.handleClientLevelClosing(this.level); } - this.level = null; -@@ -2236,6 +_,7 @@ + this.setScreenAndShow(p_335030_); +@@ -2254,6 +_,7 @@ private void pickBlock() { if (this.hitResult != null && this.hitResult.getType() != HitResult.Type.MISS) { + if (net.minecraftforge.client.event.ForgeEventFactoryClient.onClickInputPickBlock(this.options.keyPickItem)) return; - boolean flag = Screen.hasControlDown(); + boolean flag = this.hasControlDown(); switch (this.hitResult) { case BlockHitResult blockhitresult: diff --git a/patches/minecraft/net/minecraft/client/MouseHandler.java.patch b/patches/minecraft/net/minecraft/client/MouseHandler.java.patch index b25442cb1a..bf2f91a838 100644 --- a/patches/minecraft/net/minecraft/client/MouseHandler.java.patch +++ b/patches/minecraft/net/minecraft/client/MouseHandler.java.patch @@ -1,40 +1,40 @@ --- a/net/minecraft/client/MouseHandler.java +++ b/net/minecraft/client/MouseHandler.java -@@ -90,6 +_,7 @@ - this.activeButton = -1; +@@ -87,6 +_,7 @@ + this.activeButton = null; } -+ if (net.minecraftforge.client.event.ForgeEventFactoryClient.onMouseButtonPre(p_91532_, p_91533_, p_91534_)) return; ++ if (net.minecraftforge.client.event.ForgeEventFactoryClient.onMouseButtonPre(mousebuttoninfo.button(), p_423948_, mousebuttoninfo.modifiers())) return; if (this.minecraft.getOverlay() == null) { if (this.minecraft.screen == null) { if (!this.mouseGrabbed && flag) { @@ -103,7 +_,7 @@ - screen.afterMouseAction(); - try { -- if (screen.mouseClicked(d0, d1, i)) { -+ if (net.minecraftforge.client.event.ForgeEventFactoryClient.onScreenMouseClicked(screen, d0, d1, i)) { + long i = Util.getMillis(); + boolean flag1 = i - this.lastClickTime < 250L && this.lastClickButton == mousebuttonevent.button(); +- if (screen.mouseClicked(mousebuttonevent, flag1)) { ++ if (net.minecraftforge.client.event.ForgeEventFactoryClient.onScreenMouseClicked(screen, d0, d1, mousebuttonevent, flag1)) { + this.lastClickTime = i; + this.lastClickButton = mousebuttoninfo.button(); return; - } - } catch (Throwable throwable1) { -@@ -116,7 +_,7 @@ +@@ -118,7 +_,7 @@ } } else { try { -- if (screen.mouseReleased(d0, d1, i)) { -+ if (net.minecraftforge.client.event.ForgeEventFactoryClient.onScreenMouseReleased(screen, d0, d1, i)) { +- if (screen.mouseReleased(mousebuttonevent)) { ++ if (net.minecraftforge.client.event.ForgeEventFactoryClient.onScreenMouseReleased(screen, d0, d1, mousebuttonevent)) { return; } } catch (Throwable throwable) { -@@ -150,6 +_,7 @@ +@@ -148,6 +_,7 @@ + KeyMapping.click(inputconstants$key); } } ++ net.minecraftforge.client.event.ForgeEventFactoryClient.onMouseButtonPost(mousebuttoninfo.button(), p_423948_, mousebuttoninfo.modifiers()); } -+ net.minecraftforge.client.event.ForgeEventFactoryClient.onMouseButtonPost(p_91532_, p_91533_, p_91534_); } - public void fillMousePositionDetails(CrashReportCategory p_398230_, Window p_398216_) { -@@ -189,7 +_,9 @@ +@@ -204,7 +_,9 @@ if (this.minecraft.screen != null) { double d3 = this.getScaledXPos(this.minecraft.getWindow()); double d4 = this.getScaledYPos(this.minecraft.getWindow()); @@ -45,7 +45,7 @@ this.minecraft.screen.afterMouseAction(); } else if (this.minecraft.player != null) { Vector2i vector2i = this.scrollWheelHandler.onMouseScroll(d1, d2); -@@ -198,6 +_,7 @@ +@@ -213,6 +_,7 @@ } int i = vector2i.y == 0 ? -vector2i.x : vector2i.y; @@ -53,16 +53,16 @@ if (this.minecraft.player.isSpectator()) { if (this.minecraft.gui.getSpectatorGui().isMenuActive()) { this.minecraft.gui.getSpectatorGui().onMouseScrolled(-i); -@@ -303,7 +_,7 @@ +@@ -321,7 +_,7 @@ double d5 = getScaledYPos(window, this.accumulatedDY); try { -- screen.mouseDragged(d2, d3, this.activeButton, d4, d5); -+ net.minecraftforge.client.ForgeHooksClient.onScreenMouseDrag(screen, d2, d3, this.activeButton, d4, d5); +- screen.mouseDragged(new MouseButtonEvent(d2, d3, this.activeButton), d4, d5); ++ net.minecraftforge.client.ForgeHooksClient.onScreenMouseDrag(screen, new MouseButtonEvent(d2, d3, this.activeButton), d4, d5); } catch (Throwable throwable) { CrashReport crashreport1 = CrashReport.forThrowable(throwable, "mouseDragged event handler"); screen.fillCrashDetails(crashreport1); -@@ -393,6 +_,14 @@ +@@ -408,6 +_,14 @@ public double ypos() { return this.ypos; diff --git a/patches/minecraft/net/minecraft/client/Options.java.patch b/patches/minecraft/net/minecraft/client/Options.java.patch index 038f1fb07a..3e8c79d722 100644 --- a/patches/minecraft/net/minecraft/client/Options.java.patch +++ b/patches/minecraft/net/minecraft/client/Options.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/Options.java +++ b/net/minecraft/client/Options.java -@@ -671,7 +_,8 @@ +@@ -709,7 +_,8 @@ }, new OptionInstance.LazyEnum<>( () -> Stream.concat(Stream.of(""), Minecraft.getInstance().getSoundManager().getAvailableSoundDevices().stream()).toList(), @@ -10,7 +10,7 @@ ? Optional.empty() : Optional.of(p_232011_), Codec.STRING -@@ -705,6 +_,7 @@ +@@ -743,6 +_,7 @@ ); public boolean syncWrites; public boolean startedCleanly = true; @@ -18,7 +18,7 @@ public OptionInstance darkMojangStudiosBackground() { return this.darkMojangStudiosBackground; -@@ -1088,6 +_,7 @@ +@@ -1150,6 +_,7 @@ } public Options(Minecraft p_92138_, File p_92139_) { @@ -26,7 +26,7 @@ this.minecraft = p_92138_; this.optionsFile = new File(p_92139_, "options.txt"); boolean flag = Runtime.getRuntime().maxMemory() >= 1000000000L; -@@ -1222,15 +_,28 @@ +@@ -1290,15 +_,28 @@ this.startedCleanly = p_168428_.process("startedCleanly", this.startedCleanly); p_168428_.process("showNowPlayingToast", this.showNowPlayingToast); p_168428_.process("musicFrequency", this.musicFrequency); @@ -56,7 +56,7 @@ for (SoundSource soundsource : SoundSource.values()) { p_168428_.process("soundCategory_" + soundsource.getName(), this.soundSourceVolumes.get(soundsource)); } -@@ -1245,6 +_,10 @@ +@@ -1313,6 +_,10 @@ } public void load() { @@ -67,7 +67,7 @@ try { if (!this.optionsFile.exists()) { return; -@@ -1269,7 +_,8 @@ +@@ -1337,7 +_,8 @@ this.graphicsMode.set(isTrue(optional.get()) ? GraphicsStatus.FANCY : GraphicsStatus.FAST); } @@ -77,7 +77,7 @@ new Options.FieldAccess() { @Nullable private String getValue(String p_394210_) { -@@ -1350,6 +_,17 @@ +@@ -1418,6 +_,17 @@ ); compoundtag1.getString("fullscreenResolution").ifPresent(p_389133_ -> this.fullscreenVideoModeString = p_389133_); KeyMapping.resetMapping(); @@ -95,7 +95,7 @@ } catch (Exception exception) { LOGGER.error("Failed to load options", (Throwable)exception); } -@@ -1377,9 +_,11 @@ +@@ -1445,9 +_,11 @@ public void save() { try (final PrintWriter printwriter = new PrintWriter(new OutputStreamWriter(new FileOutputStream(this.optionsFile), StandardCharsets.UTF_8))) { printwriter.println("version:" + SharedConstants.getCurrentVersion().dataVersion().version()); @@ -107,7 +107,7 @@ printwriter.print(p_168491_); printwriter.print(':'); } -@@ -1435,6 +_,12 @@ +@@ -1503,6 +_,12 @@ if (s != null) { printwriter.println("fullscreenResolution:" + s); } @@ -120,7 +120,7 @@ } catch (Exception exception) { LOGGER.error("Failed to save options", (Throwable)exception); } -@@ -1473,6 +_,7 @@ +@@ -1541,6 +_,7 @@ } public void broadcastOptions() { @@ -128,7 +128,7 @@ if (this.minecraft.player != null) { this.minecraft.player.connection.broadcastClientInformation(this.buildPlayerInformation()); } -@@ -1586,6 +_,23 @@ +@@ -1654,6 +_,23 @@ public static Component genericValueLabel(Component p_231901_, int p_231902_) { return genericValueLabel(p_231901_, Component.literal(Integer.toString(p_231902_))); diff --git a/patches/minecraft/net/minecraft/client/ToggleKeyMapping.java.patch b/patches/minecraft/net/minecraft/client/ToggleKeyMapping.java.patch index 69459c3aea..698cb7c847 100644 --- a/patches/minecraft/net/minecraft/client/ToggleKeyMapping.java.patch +++ b/patches/minecraft/net/minecraft/client/ToggleKeyMapping.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/ToggleKeyMapping.java +++ b/net/minecraft/client/ToggleKeyMapping.java -@@ -17,7 +_,7 @@ +@@ -31,7 +_,7 @@ @Override public void setDown(boolean p_92534_) { if (this.needsToggle.getAsBoolean()) { @@ -9,7 +9,7 @@ super.setDown(!this.isDown()); } } else { -@@ -27,5 +_,9 @@ +@@ -56,5 +_,9 @@ protected void reset() { super.setDown(false); diff --git a/patches/minecraft/net/minecraft/client/data/models/ItemModelGenerators.java.patch b/patches/minecraft/net/minecraft/client/data/models/ItemModelGenerators.java.patch index 3aec965395..0fa8c2ce96 100644 --- a/patches/minecraft/net/minecraft/client/data/models/ItemModelGenerators.java.patch +++ b/patches/minecraft/net/minecraft/client/data/models/ItemModelGenerators.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/data/models/ItemModelGenerators.java +++ b/net/minecraft/client/data/models/ItemModelGenerators.java -@@ -871,6 +_,9 @@ +@@ -882,6 +_,9 @@ this.declareCustomModelItem(Items.COD); this.declareCustomModelItem(Items.FEATHER); this.declareCustomModelItem(Items.LEAD); diff --git a/patches/minecraft/net/minecraft/client/gui/Font.java.patch b/patches/minecraft/net/minecraft/client/gui/Font.java.patch index 7d0721236f..2734d1875c 100644 --- a/patches/minecraft/net/minecraft/client/gui/Font.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/Font.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/Font.java +++ b/net/minecraft/client/gui/Font.java -@@ -32,7 +_,7 @@ +@@ -31,7 +_,7 @@ import org.joml.Matrix4f; @OnlyIn(Dist.CLIENT) diff --git a/patches/minecraft/net/minecraft/client/gui/Gui.java.patch b/patches/minecraft/net/minecraft/client/gui/Gui.java.patch index bbb465a3bd..bd12945d45 100644 --- a/patches/minecraft/net/minecraft/client/gui/Gui.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/Gui.java.patch @@ -9,7 +9,7 @@ private final SubtitleOverlay subtitleOverlay; private final SpectatorGui spectatorGui; private final PlayerTabOverlay tabList; -@@ -194,6 +_,7 @@ +@@ -196,6 +_,7 @@ () -> new JumpableVehicleBarRenderer(p_330021_) ); this.resetTitleTimes(); @@ -17,10 +17,10 @@ } public void resetTitleTimes() { -@@ -204,6 +_,10 @@ +@@ -206,6 +_,10 @@ public void render(GuiGraphics p_282884_, DeltaTracker p_342095_) { - if (this.minecraft.screen == null || !(this.minecraft.screen instanceof ReceivingLevelScreen)) { + if (!(this.minecraft.screen instanceof LevelLoadingScreen)) { + if (Boolean.valueOf(true)) { + net.minecraftforge.client.gui.overlay.ForgeLayeredDraw.beginRender(p_282884_, p_342095_); + return; @@ -28,7 +28,7 @@ if (!this.minecraft.options.hideGui) { this.renderCameraOverlays(p_282884_, p_342095_); this.renderCrosshair(p_282884_, p_342095_); -@@ -377,7 +_,7 @@ +@@ -389,7 +_,7 @@ int i = Mth.floor(this.minecraft.mouseHandler.getScaledXPos(window)); int j = Mth.floor(this.minecraft.mouseHandler.getScaledYPos(window)); p_329202_.nextStratum(); @@ -37,7 +37,7 @@ } } -@@ -472,6 +_,8 @@ +@@ -477,6 +_,8 @@ for (MobEffectInstance mobeffectinstance : Ordering.natural().reverse().sortedCopy(collection)) { Holder holder = mobeffectinstance.getEffect(); @@ -46,7 +46,7 @@ if (mobeffectinstance.showIcon()) { int k = p_282812_.guiWidth(); int l = 1; -@@ -502,6 +_,7 @@ +@@ -507,6 +_,7 @@ } } @@ -54,7 +54,7 @@ p_282812_.blitSprite(RenderPipelines.GUI_TEXTURED, getMobEffectSprite(holder), k + 3, l + 3, 18, 18, ARGB.white(f)); } } -@@ -598,6 +_,10 @@ +@@ -603,6 +_,10 @@ } public void renderSelectedItemName(GuiGraphics p_283501_) { @@ -65,7 +65,7 @@ Profiler.get().push("selectedItemName"); if (this.toolHighlightTimer > 0 && !this.lastToolHighlight.isEmpty()) { MutableComponent mutablecomponent = Component.empty().append(this.lastToolHighlight.getHoverName()).withStyle(this.lastToolHighlight.getRarity().color()); -@@ -605,9 +_,13 @@ +@@ -610,9 +_,13 @@ mutablecomponent.withStyle(ChatFormatting.ITALIC); } @@ -81,7 +81,7 @@ if (!this.minecraft.gameMode.canHurtPlayer()) { k += 14; } -@@ -618,7 +_,7 @@ +@@ -623,7 +_,7 @@ } if (l > 0) { @@ -90,7 +90,7 @@ } } -@@ -1146,7 +_,7 @@ +@@ -1151,7 +_,7 @@ ItemStack itemstack = this.minecraft.player.getInventory().getSelectedItem(); if (itemstack.isEmpty()) { this.toolHighlightTimer = 0; diff --git a/patches/minecraft/net/minecraft/client/gui/GuiGraphics.java.patch b/patches/minecraft/net/minecraft/client/gui/GuiGraphics.java.patch index 9a2857019a..da44fe24fa 100644 --- a/patches/minecraft/net/minecraft/client/gui/GuiGraphics.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/GuiGraphics.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/GuiGraphics.java +++ b/net/minecraft/client/gui/GuiGraphics.java -@@ -72,7 +_,7 @@ +@@ -83,7 +_,7 @@ import org.joml.Vector3f; @OnlyIn(Dist.CLIENT) @@ -9,7 +9,7 @@ private static final int EXTRA_SPACE_AFTER_FIRST_TOOLTIP_LINE = 2; private final Minecraft minecraft; private final Matrix3x2fStack pose; -@@ -875,6 +_,7 @@ +@@ -950,6 +_,7 @@ CrashReport crashreport = CrashReport.forThrowable(throwable, "Rendering item"); CrashReportCategory crashreportcategory = crashreport.addCategory("Item being rendered"); crashreportcategory.setDetail("Item Type", () -> String.valueOf(p_283653_.getItem())); @@ -17,7 +17,7 @@ crashreportcategory.setDetail("Item Components", () -> String.valueOf(p_283653_.getComponents())); crashreportcategory.setDetail("Item Foil", () -> String.valueOf(p_283653_.hasFoil())); throw new ReportedException(crashreport); -@@ -893,6 +_,7 @@ +@@ -968,6 +_,7 @@ this.renderItemCooldown(p_283349_, p_282641_, p_282146_); this.renderItemCount(p_282005_, p_283349_, p_282641_, p_282146_, p_282803_); this.pose.popMatrix(); @@ -25,7 +25,7 @@ } } -@@ -904,21 +_,30 @@ +@@ -979,21 +_,30 @@ this.setTooltipForNextFrame(this.minecraft.font, p_407686_, DefaultTooltipPositioner.INSTANCE, p_410475_, p_407139_, false); } @@ -58,7 +58,7 @@ this.setTooltipForNextFrameInternal(p_407847_, list, p_409369_, p_407472_, DefaultTooltipPositioner.INSTANCE, p_410303_, false); } -@@ -931,7 +_,22 @@ +@@ -1006,7 +_,22 @@ } public void setComponentTooltipForNextFrame(Font p_406239_, List p_410275_, int p_410594_, int p_409343_) { @@ -82,7 +82,7 @@ } public void setComponentTooltipForNextFrame(Font p_408650_, List p_407512_, int p_406019_, int p_408123_, @Nullable ResourceLocation p_409993_) { -@@ -994,11 +_,13 @@ +@@ -1069,11 +_,13 @@ ClientTooltipPositioner p_409451_, @Nullable ResourceLocation p_409298_ ) { @@ -97,7 +97,7 @@ if (k > i) { i = k; } -@@ -1008,16 +_,17 @@ +@@ -1083,16 +_,17 @@ int l1 = i; int i2 = j; @@ -118,7 +118,7 @@ j1 += clienttooltipcomponent1.getHeight(p_283128_) + (k1 == 0 ? 2 : 0); } -@@ -1025,7 +_,7 @@ +@@ -1100,7 +_,7 @@ for (int j2 = 0; j2 < p_282716_.size(); j2++) { ClientTooltipComponent clienttooltipcomponent2 = p_282716_.get(j2); @@ -127,7 +127,7 @@ j1 += clienttooltipcomponent2.getHeight(p_283128_) + (j2 == 0 ? 2 : 0); } -@@ -1222,6 +_,14 @@ +@@ -1315,6 +_,14 @@ public void submitProfilerChartRenderState(List p_408565_, int p_410147_, int p_406156_, int p_407365_, int p_408180_) { this.guiRenderState.submitPicturesInPictureState(new GuiProfilerChartRenderState(p_408565_, p_410147_, p_406156_, p_407365_, p_408180_, this.scissorStack.peek())); @@ -141,4 +141,4 @@ + return this.scissorStack; } - @OnlyIn(Dist.CLIENT) + public TextureAtlasSprite getSprite(Material p_430745_) { diff --git a/patches/minecraft/net/minecraft/client/gui/components/AbstractButton.java.patch b/patches/minecraft/net/minecraft/client/gui/components/AbstractButton.java.patch index 1a2a95782b..d0796a7aa7 100644 --- a/patches/minecraft/net/minecraft/client/gui/components/AbstractButton.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/components/AbstractButton.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/client/gui/components/AbstractButton.java +++ b/net/minecraft/client/gui/components/AbstractButton.java -@@ -38,7 +_,7 @@ +@@ -41,7 +_,7 @@ this.getHeight(), ARGB.white(this.alpha) ); - int i = ARGB.color(this.alpha, this.active ? -1 : -6250336); + int i = getFGColor(); this.renderString(p_281670_, minecraft.font, i); - } - + if (this.isHovered()) { + p_281670_.requestCursor(this.isActive() ? CursorTypes.POINTING_HAND : CursorTypes.NOT_ALLOWED); diff --git a/patches/minecraft/net/minecraft/client/gui/components/AbstractWidget.java.patch b/patches/minecraft/net/minecraft/client/gui/components/AbstractWidget.java.patch index 25ed7fdd42..8009eb3421 100644 --- a/patches/minecraft/net/minecraft/client/gui/components/AbstractWidget.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/components/AbstractWidget.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/components/AbstractWidget.java +++ b/net/minecraft/client/gui/components/AbstractWidget.java -@@ -236,6 +_,25 @@ +@@ -238,6 +_,25 @@ this.focused = p_93693_; } diff --git a/patches/minecraft/net/minecraft/client/gui/components/Button.java.patch b/patches/minecraft/net/minecraft/client/gui/components/Button.java.patch index b021bbc94d..44057893f7 100644 --- a/patches/minecraft/net/minecraft/client/gui/components/Button.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/components/Button.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/components/Button.java +++ b/net/minecraft/client/gui/components/Button.java -@@ -31,6 +_,12 @@ +@@ -32,6 +_,12 @@ this.createNarration = p_259552_; } @@ -11,9 +11,9 @@ + } + @Override - public void onPress() { + public void onPress(InputWithModifiers p_424878_) { this.onPress.onPress(this); -@@ -95,9 +_,12 @@ +@@ -96,9 +_,12 @@ } public Button build() { diff --git a/patches/minecraft/net/minecraft/client/gui/components/DebugScreenOverlay.java.patch b/patches/minecraft/net/minecraft/client/gui/components/DebugScreenOverlay.java.patch deleted file mode 100644 index b93cc32e5e..0000000000 --- a/patches/minecraft/net/minecraft/client/gui/components/DebugScreenOverlay.java.patch +++ /dev/null @@ -1,101 +0,0 @@ ---- a/net/minecraft/client/gui/components/DebugScreenOverlay.java -+++ b/net/minecraft/client/gui/components/DebugScreenOverlay.java -@@ -139,9 +_,9 @@ - @Nullable - private CompletableFuture serverChunk; - private boolean renderDebug; -- private boolean renderProfilerChart; -- private boolean renderFpsCharts; -- private boolean renderNetworkCharts; -+ protected boolean renderProfilerChart; -+ protected boolean renderFpsCharts; -+ protected boolean renderNetworkCharts; - private final LocalSampleLogger frameTimeLogger = new LocalSampleLogger(1); - private final LocalSampleLogger tickTimeLogger = new LocalSampleLogger(TpsDebugDimensions.values().length); - private final LocalSampleLogger pingLogger = new LocalSampleLogger(1); -@@ -183,15 +_,19 @@ - this.clientChunk = null; - } - -- public void render(GuiGraphics p_281427_) { -- ProfilerFiller profilerfiller = Profiler.get(); -- profilerfiller.push("debug"); -+ protected void update() { - Entity entity = this.minecraft.getCameraEntity(); - this.block = entity.pick(20.0, 0.0F, false); - this.liquid = entity.pick(20.0, 0.0F, true); -+ } -+ -+ protected void drawText(ProfilerFiller profilerfiller, GuiGraphics p_281427_) { - this.drawGameInformation(p_281427_); - this.drawSystemInformation(p_281427_); - p_281427_.nextStratum(); -+ } -+ -+ protected void drawFPSCharts(ProfilerFiller profilerfiller, GuiGraphics p_281427_) { - this.profilerPieChart.setBottomOffset(10); - if (this.renderFpsCharts) { - int i = p_281427_.guiWidth(); -@@ -204,7 +_,9 @@ - - this.profilerPieChart.setBottomOffset(this.tpsChart.getFullHeight()); - } -+ } - -+ protected void drawNetworkCharts(ProfilerFiller profilerfiller, GuiGraphics p_281427_) { - if (this.renderNetworkCharts) { - int l = p_281427_.guiWidth(); - int i1 = l / 2; -@@ -220,12 +_,22 @@ - try (Zone zone = profilerfiller.zone("profilerPie")) { - this.profilerPieChart.render(p_281427_); - } -+ } -+ -+ public void render(GuiGraphics p_281427_) { -+ ProfilerFiller profilerfiller = Profiler.get(); -+ profilerfiller.push("debug"); -+ this.update(); -+ -+ this.drawText(profilerfiller, p_281427_); -+ this.drawFPSCharts(profilerfiller, p_281427_); -+ this.drawNetworkCharts(profilerfiller, p_281427_); - - profilerfiller.pop(); - } - -- protected void drawGameInformation(GuiGraphics p_281525_) { -- List list = this.getGameInformation(); -+ protected List getOverlayHelp() { -+ List list = Lists.newArrayList(); - list.add(""); - boolean flag = this.minecraft.getSingleplayerServer() != null; - list.add( -@@ -239,11 +_,18 @@ - + (this.renderNetworkCharts ? " visible" : " hidden") - ); - list.add("For help: press F3 + Q"); -- this.renderLines(p_281525_, list, true); -+ return list; -+ } -+ protected void drawGameInformation(GuiGraphics p_281525_) { -+ List list = this.getGameInformation(); -+ list.addAll(this.getOverlayHelp()); -+ net.minecraftforge.client.ForgeHooksClient.onCustomizeDebugEvent(p_281525_, minecraft.getWindow(), minecraft.getDeltaTracker().getRealtimeDeltaTicks(), list, true); -+ this.renderLines(p_281525_, list, true); - } - - protected void drawSystemInformation(GuiGraphics p_281261_) { - List list = this.getSystemInformation(); -+ net.minecraftforge.client.ForgeHooksClient.onCustomizeDebugEvent(p_281261_, minecraft.getWindow(), minecraft.getDeltaTracker().getRealtimeDeltaTicks(), list, false); - this.renderLines(p_281261_, list, false); - } - -@@ -597,6 +_,7 @@ - list.add(""); - list.add(ChatFormatting.UNDERLINE + "Targeted Entity"); - list.add(String.valueOf(BuiltInRegistries.ENTITY_TYPE.getKey(entity.getType()))); -+ entity.getType().builtInRegistryHolder().tags().forEach(t -> list.add("#" + t.location())); - } - - return list; diff --git a/patches/minecraft/net/minecraft/client/gui/components/debug/DebugEntryLookingAtEntity.java.patch b/patches/minecraft/net/minecraft/client/gui/components/debug/DebugEntryLookingAtEntity.java.patch new file mode 100644 index 0000000000..5e7fbe8aa2 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/gui/components/debug/DebugEntryLookingAtEntity.java.patch @@ -0,0 +1,10 @@ +--- a/net/minecraft/client/gui/components/debug/DebugEntryLookingAtEntity.java ++++ b/net/minecraft/client/gui/components/debug/DebugEntryLookingAtEntity.java +@@ -25,6 +_,7 @@ + if (entity != null) { + list.add(ChatFormatting.UNDERLINE + "Targeted Entity"); + list.add(String.valueOf(BuiltInRegistries.ENTITY_TYPE.getKey(entity.getType()))); ++ entity.getType().builtInRegistryHolder().tags().forEach(t -> list.add("#" + t.location())); + } + + p_426755_.addToGroup(GROUP, list); diff --git a/patches/minecraft/net/minecraft/client/gui/render/GuiRenderer.java.patch b/patches/minecraft/net/minecraft/client/gui/render/GuiRenderer.java.patch index b0f4689786..81a3c754d6 100644 --- a/patches/minecraft/net/minecraft/client/gui/render/GuiRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/render/GuiRenderer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/render/GuiRenderer.java +++ b/net/minecraft/client/gui/render/GuiRenderer.java -@@ -134,6 +_,7 @@ +@@ -146,6 +_,7 @@ builder.put((Class)pictureinpicturerenderer.getRenderStateClass(), pictureinpicturerenderer); } diff --git a/patches/minecraft/net/minecraft/client/gui/screens/ChatScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/ChatScreen.java.patch index db2f9d0fde..d09f7af5d3 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/ChatScreen.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/ChatScreen.java.patch @@ -1,10 +1,10 @@ --- a/net/minecraft/client/gui/screens/ChatScreen.java +++ b/net/minecraft/client/gui/screens/ChatScreen.java -@@ -89,6 +_,7 @@ - return true; - } else if (p_95591_ == 257 || p_95591_ == 335) { +@@ -115,6 +_,7 @@ + } else if (p_426273_.isConfirmation()) { this.handleChatInput(this.input.getValue(), true); + this.exitReason = ChatScreen.ExitReason.DONE; + if (this.minecraft.screen == this) // FORGE: Prevent closing the screen if another screen has been opened. this.minecraft.setScreen(null); return true; - } else if (p_95591_ == 265) { + } else { diff --git a/patches/minecraft/net/minecraft/client/gui/screens/ConnectScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/ConnectScreen.java.patch index a25bf46104..f1d28cdee9 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/ConnectScreen.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/ConnectScreen.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/screens/ConnectScreen.java +++ b/net/minecraft/client/gui/screens/ConnectScreen.java -@@ -102,6 +_,8 @@ +@@ -103,6 +_,8 @@ } if (optional.isEmpty()) { diff --git a/patches/minecraft/net/minecraft/client/gui/screens/LoadingOverlay.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/LoadingOverlay.java.patch index f0b053d095..f4dfc82a6a 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/LoadingOverlay.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/LoadingOverlay.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/screens/LoadingOverlay.java +++ b/net/minecraft/client/gui/screens/LoadingOverlay.java -@@ -61,6 +_,8 @@ +@@ -62,6 +_,8 @@ return p_169325_ & 16777215 | p_169326_ << 24; } @@ -9,7 +9,7 @@ @Override public void render(GuiGraphics p_281839_, int p_282704_, int p_283650_, float p_283394_) { int i = p_281839_.guiWidth(); -@@ -97,6 +_,7 @@ +@@ -102,6 +_,7 @@ f2 = 1.0F; } @@ -17,7 +17,7 @@ int l2 = (int)(p_281839_.guiWidth() * 0.5); int i1 = (int)(p_281839_.guiHeight() * 0.5); double d0 = Math.min(p_281839_.guiWidth() * 0.75, (double)p_281839_.guiHeight()) * 0.25; -@@ -112,12 +_,14 @@ +@@ -117,6 +_,7 @@ if (f < 1.0F) { this.drawProgressBar(p_281839_, i / 2 - k1, i2 - 5, i / 2 + k1, i2 + 5, 1.0F - Mth.clamp(f, 0.0F, 1.0F)); } @@ -25,18 +25,19 @@ if (f >= 2.0F) { this.minecraft.setOverlay(null); - } - - if (this.fadeOutStart == -1L && this.reload.isDone() && (!this.fadeIn || f1 >= 2.0F)) { +@@ -126,6 +_,7 @@ + @Override + public void tick() { + if (this.fadeOutStart == -1L && this.reload.isDone() && this.isReadyToFadeOut()) { + this.fadeOutStart = Util.getMillis(); // Forge: Moved up to guard against inf loops caused by callback try { this.reload.checkExceptions(); this.onFinish.accept(Optional.empty()); -@@ -125,7 +_,6 @@ +@@ -133,7 +_,6 @@ this.onFinish.accept(Optional.of(throwable)); } - this.fadeOutStart = Util.getMillis(); if (this.minecraft.screen != null) { - this.minecraft.screen.init(this.minecraft, p_281839_.guiWidth(), p_281839_.guiHeight()); - } + Window window = this.minecraft.getWindow(); + this.minecraft.screen.init(this.minecraft, window.getGuiScaledWidth(), window.getGuiScaledHeight()); diff --git a/patches/minecraft/net/minecraft/client/gui/screens/PauseScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/PauseScreen.java.patch index 85d8c4b622..785d1d480f 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/PauseScreen.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/PauseScreen.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/screens/PauseScreen.java +++ b/net/minecraft/client/gui/screens/PauseScreen.java -@@ -105,6 +_,7 @@ +@@ -103,6 +_,7 @@ } else { gridlayout$rowhelper.addChild(this.openScreenButton(PLAYER_REPORTING, () -> new SocialInteractionsScreen(this))); } diff --git a/patches/minecraft/net/minecraft/client/gui/screens/Screen.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/Screen.java.patch index c5f5674379..ad0e7b33e4 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/Screen.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/Screen.java.patch @@ -9,7 +9,7 @@ } protected T addRenderableWidget(T p_169406_) { -@@ -339,8 +_,10 @@ +@@ -343,8 +_,10 @@ this.width = p_96608_; this.height = p_96609_; if (!this.initialized) { @@ -20,7 +20,7 @@ } else { this.repositionElements(); } -@@ -353,8 +_,10 @@ +@@ -361,8 +_,10 @@ protected void rebuildWidgets() { this.clearWidgets(); this.clearFocus(); @@ -31,15 +31,16 @@ } protected void fadeWidgets(float p_409453_) { -@@ -389,6 +_,7 @@ +@@ -402,6 +_,8 @@ + this.renderMenuBackground(p_283688_); + } - this.renderBlurredBackground(p_283688_); - this.renderMenuBackground(p_283688_); + net.minecraftforge.client.event.ForgeEventFactoryClient.onRenderScreenBackground(this, p_283688_); ++ + this.minecraft.gui.renderDeferredSubtitles(); } - protected void renderBlurredBackground(GuiGraphics p_407253_) { -@@ -492,6 +_,19 @@ +@@ -484,6 +_,19 @@ } public void onFilesDrop(List p_96591_) { diff --git a/patches/minecraft/net/minecraft/client/gui/screens/TitleScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/TitleScreen.java.patch index f7d61b141b..8b4137dc69 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/TitleScreen.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/TitleScreen.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/screens/TitleScreen.java +++ b/net/minecraft/client/gui/screens/TitleScreen.java -@@ -54,6 +_,7 @@ +@@ -55,6 +_,7 @@ private boolean fading; private long fadeInStart; private final LogoRenderer logoRenderer; @@ -8,7 +8,7 @@ public TitleScreen() { this(false); -@@ -106,11 +_,15 @@ +@@ -107,11 +_,15 @@ int j = this.width - i - 2; int k = 24; int l = this.height / 4 + 48; @@ -24,7 +24,7 @@ l = this.createTestWorldButton(l, 24); SpriteIconButton spriteiconbutton = this.addRenderableWidget( -@@ -175,7 +_,7 @@ +@@ -178,7 +_,7 @@ }).bounds(this.width / 2 - 100, i = p_96764_ + p_96765_, 200, 20).tooltip(tooltip).build()).active = flag; this.addRenderableWidget( Button.builder(Component.translatable("menu.online"), p_325369_ -> this.minecraft.setScreen(new RealmsMainScreen(this))) @@ -33,7 +33,7 @@ .tooltip(tooltip) .build() ) -@@ -295,9 +_,18 @@ +@@ -298,9 +_,18 @@ s = s + I18n.get("menu.modded"); } diff --git a/patches/minecraft/net/minecraft/client/gui/screens/advancements/AdvancementsScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/advancements/AdvancementsScreen.java.patch index 953ef41261..ac15ed16ab 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/advancements/AdvancementsScreen.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/advancements/AdvancementsScreen.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/screens/advancements/AdvancementsScreen.java +++ b/net/minecraft/client/gui/screens/advancements/AdvancementsScreen.java -@@ -51,6 +_,7 @@ +@@ -53,6 +_,7 @@ @Nullable private AdvancementTab selectedTab; private boolean isScrolling; @@ -8,7 +8,7 @@ public AdvancementsScreen(ClientAdvancements p_97340_) { this(p_97340_, null); -@@ -64,6 +_,19 @@ +@@ -66,6 +_,19 @@ @Override protected void init() { @@ -28,16 +28,16 @@ this.layout.addTitleHeader(TITLE, this.font); this.tabs.clear(); this.selectedTab = null; -@@ -108,7 +_,7 @@ +@@ -110,7 +_,7 @@ int j = (this.height - 140) / 2; for (AdvancementTab advancementtab : this.tabs.values()) { -- if (advancementtab.isMouseOver(i, j, p_97343_, p_97344_)) { -+ if (advancementtab.getPage() == tabPage && advancementtab.isMouseOver(i, j, p_97343_, p_97344_)) { +- if (advancementtab.isMouseOver(i, j, p_431395_.x(), p_431395_.y())) { ++ if (advancementtab.getPage() == tabPage && advancementtab.isMouseOver(i, j, p_431395_.x(), p_431395_.y())) { this.advancements.setSelectedTab(advancementtab.getRootNode().holder(), true); break; } -@@ -183,10 +_,12 @@ +@@ -185,10 +_,12 @@ p_283395_.blit(RenderPipelines.GUI_TEXTURED, WINDOW_LOCATION, p_281890_, p_282532_, 0.0F, 0.0F, 252, 140, 256, 256); if (this.tabs.size() > 1) { for (AdvancementTab advancementtab : this.tabs.values()) { @@ -50,7 +50,7 @@ advancementtab1.drawIcon(p_283395_, p_281890_, p_282532_); } } -@@ -205,6 +_,7 @@ +@@ -207,6 +_,7 @@ if (this.tabs.size() > 1) { for (AdvancementTab advancementtab : this.tabs.values()) { diff --git a/patches/minecraft/net/minecraft/client/gui/screens/inventory/AbstractContainerScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/inventory/AbstractContainerScreen.java.patch index 7cd3a6d178..61cd27175a 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/inventory/AbstractContainerScreen.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/inventory/AbstractContainerScreen.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/screens/inventory/AbstractContainerScreen.java +++ b/net/minecraft/client/gui/screens/inventory/AbstractContainerScreen.java -@@ -107,6 +_,7 @@ +@@ -105,6 +_,7 @@ int i = this.leftPos; int j = this.topPos; super.render(p_409971_, p_409213_, p_408205_, p_408282_); @@ -8,7 +8,7 @@ p_409971_.pose().pushMatrix(); p_409971_.pose().translate(i, j); this.renderLabels(p_409971_, p_409213_, p_408205_); -@@ -119,6 +_,8 @@ +@@ -117,6 +_,8 @@ this.onStopHovering(slot); } @@ -17,7 +17,7 @@ p_409971_.pose().popMatrix(); } -@@ -202,7 +_,7 @@ +@@ -200,7 +_,7 @@ ItemStack itemstack = this.hoveredSlot.getItem(); if (this.menu.getCarried().isEmpty() || this.showTooltipWithItemInHand(itemstack)) { p_283594_.setTooltipForNextFrame( @@ -26,7 +26,7 @@ ); } } -@@ -218,7 +_,8 @@ +@@ -216,7 +_,8 @@ private void renderFloatingItem(GuiGraphics p_282567_, ItemStack p_281330_, int p_281772_, int p_281689_, @Nullable String p_282568_) { p_282567_.renderItem(p_281330_, p_281772_, p_281689_); @@ -36,87 +36,84 @@ } protected void renderLabels(GuiGraphics p_281635_, int p_282681_, int p_283686_) { -@@ -319,7 +_,8 @@ - if (super.mouseClicked(p_97748_, p_97749_, p_97750_)) { +@@ -317,7 +_,8 @@ + if (super.mouseClicked(p_427253_, p_427622_)) { return true; } else { -- boolean flag = this.minecraft.options.keyPickItem.matchesMouse(p_97750_) && this.minecraft.player.hasInfiniteMaterials(); -+ InputConstants.Key mouseKey = InputConstants.Type.MOUSE.getOrCreate(p_97750_); -+ boolean flag = this.minecraft.options.keyPickItem.isActiveAndMatches(mouseKey); - Slot slot = this.getHoveredSlot(p_97748_, p_97749_); - long i = Util.getMillis(); - this.doubleclick = this.lastClickSlot == slot && i - this.lastClickTime < 250L && this.lastClickButton == p_97750_; -@@ -330,6 +_,7 @@ - int j = this.leftPos; - int k = this.topPos; - boolean flag1 = this.hasClickedOutside(p_97748_, p_97749_, j, k, p_97750_); +- boolean flag = this.minecraft.options.keyPickItem.matchesMouse(p_427253_) && this.minecraft.player.hasInfiniteMaterials(); ++ var mouseKey = com.mojang.blaze3d.platform.InputConstants.Type.MOUSE.getOrCreate(p_427253_.button()); ++ boolean flag = this.minecraft.options.keyPickItem.isActiveAndMatches(mouseKey) && this.minecraft.player.hasInfiniteMaterials(); + Slot slot = this.getHoveredSlot(p_427253_.x(), p_427253_.y()); + this.doubleclick = this.lastClickSlot == slot && p_427622_; + this.skipNextRelease = false; +@@ -327,6 +_,7 @@ + int i = this.leftPos; + int j = this.topPos; + boolean flag1 = this.hasClickedOutside(p_427253_.x(), p_427253_.y(), i, j); + if (slot != null) flag1 = false; // Forge, prevent dropping of items through slots outside of GUI boundaries - int l = -1; + int k = -1; if (slot != null) { - l = slot.index; -@@ -355,7 +_,7 @@ + k = slot.index; +@@ -352,7 +_,7 @@ } } else if (!this.isQuickCrafting) { if (this.menu.getCarried().isEmpty()) { - if (flag) { + if (this.minecraft.options.keyPickItem.isActiveAndMatches(mouseKey)) { - this.slotClicked(slot, l, p_97750_, ClickType.CLONE); + this.slotClicked(slot, k, p_427253_.button(), ClickType.CLONE); } else { - boolean flag2 = l != -999 -@@ -383,7 +_,7 @@ + boolean flag2 = k != -999 && p_427253_.hasShiftDown(); +@@ -376,7 +_,7 @@ this.quickCraftingType = 0; - } else if (p_97750_ == 1) { + } else if (p_427253_.button() == 1) { this.quickCraftingType = 1; - } else if (flag) { + } else if (this.minecraft.options.keyPickItem.isActiveAndMatches(mouseKey)) { this.quickCraftingType = 2; } } -@@ -459,10 +_,13 @@ +@@ -453,10 +_,13 @@ @Override - public boolean mouseReleased(double p_97812_, double p_97813_, int p_97814_) { -+ super.mouseReleased(p_97812_, p_97813_, p_97814_); //Forge, Call parent to release buttons - Slot slot = this.getHoveredSlot(p_97812_, p_97813_); + public boolean mouseReleased(MouseButtonEvent p_430939_) { ++ super.mouseReleased(p_430939_); //Forge, Call parent to release buttons + Slot slot = this.getHoveredSlot(p_430939_.x(), p_430939_.y()); int i = this.leftPos; int j = this.topPos; - boolean flag = this.hasClickedOutside(p_97812_, p_97813_, i, j, p_97814_); + boolean flag = this.hasClickedOutside(p_430939_.x(), p_430939_.y(), i, j); + if (slot != null) flag = false; // Forge, prevent dropping of items through slots outside of GUI boundaries -+ InputConstants.Key mouseKey = InputConstants.Type.MOUSE.getOrCreate(p_97814_); ++ var mouseKey = com.mojang.blaze3d.platform.InputConstants.Type.MOUSE.getOrCreate(p_430939_.button()); int k = -1; if (slot != null) { k = slot.index; -@@ -479,7 +_,7 @@ +@@ -473,7 +_,7 @@ if (slot2 != null && slot2.mayPickup(this.minecraft.player) && slot2.hasItem() - && slot2.container == slot.container + && slot2.isSameInventory(slot) && AbstractContainerMenu.canItemQuickReplace(slot2, this.lastQuickMoved, true)) { - this.slotClicked(slot2, slot2.index, p_97814_, ClickType.QUICK_MOVE); + this.slotClicked(slot2, slot2.index, p_430939_.button(), ClickType.QUICK_MOVE); } -@@ -545,7 +_,7 @@ +@@ -538,7 +_,7 @@ this.slotClicked(null, -999, AbstractContainerMenu.getQuickcraftMask(2, this.quickCraftingType), ClickType.QUICK_CRAFT); } else if (!this.menu.getCarried().isEmpty()) { -- if (this.minecraft.options.keyPickItem.matchesMouse(p_97814_)) { +- if (this.minecraft.options.keyPickItem.matchesMouse(p_430939_)) { + if (this.minecraft.options.keyPickItem.isActiveAndMatches(mouseKey)) { - this.slotClicked(slot, k, p_97814_, ClickType.CLONE); + this.slotClicked(slot, k, p_430939_.button(), ClickType.CLONE); } else { - boolean flag1 = k != -999 -@@ -622,9 +_,10 @@ - - @Override - public boolean keyPressed(int p_97765_, int p_97766_, int p_97767_) { -+ InputConstants.Key mouseKey = InputConstants.getKey(p_97765_, p_97766_); - if (super.keyPressed(p_97765_, p_97766_, p_97767_)) { + boolean flag1 = k != -999 && p_430939_.hasShiftDown(); +@@ -609,7 +_,7 @@ + public boolean keyPressed(KeyEvent p_424324_) { + if (super.keyPressed(p_424324_)) { return true; -- } else if (this.minecraft.options.keyInventory.matches(p_97765_, p_97766_)) { -+ } else if (this.minecraft.options.keyInventory.isActiveAndMatches(mouseKey)) { +- } else if (this.minecraft.options.keyInventory.matches(p_424324_)) { ++ } else if (this.minecraft.options.keyInventory.isActiveAndMatches(com.mojang.blaze3d.platform.InputConstants.getKey(p_424324_))) { this.onClose(); return true; } else { -@@ -698,6 +_,13 @@ +@@ -688,6 +_,13 @@ super.onClose(); } diff --git a/patches/minecraft/net/minecraft/client/gui/screens/inventory/CreativeModeInventoryScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/inventory/CreativeModeInventoryScreen.java.patch index 775cc3a71f..821ed9da97 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/inventory/CreativeModeInventoryScreen.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/inventory/CreativeModeInventoryScreen.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/screens/inventory/CreativeModeInventoryScreen.java +++ b/net/minecraft/client/gui/screens/inventory/CreativeModeInventoryScreen.java -@@ -113,6 +_,8 @@ +@@ -116,6 +_,8 @@ private final Set> visibleTags = new HashSet<>(); private final boolean displayOperatorCreativeTab; private final EffectsInInventory effects; @@ -9,7 +9,7 @@ public CreativeModeInventoryScreen(LocalPlayer p_344408_, FeatureFlagSet p_260074_, boolean p_259569_) { super(new CreativeModeInventoryScreen.ItemPickerMenu(p_344408_), p_344408_.getInventory(), CommonComponents.EMPTY); -@@ -161,7 +_,7 @@ +@@ -164,7 +_,7 @@ private void refreshCurrentTabContents(Collection p_261591_) { int i = this.menu.getRowIndexForScroll(this.scrollOffs); this.menu.items.clear(); @@ -18,7 +18,7 @@ this.refreshSearchResults(); } else { this.menu.items.addAll(p_261591_); -@@ -329,6 +_,36 @@ +@@ -332,6 +_,36 @@ protected void init() { if (this.minecraft.player.hasInfiniteMaterials()) { super.init(); @@ -55,8 +55,8 @@ this.searchBox = new EditBox(this.font, this.leftPos + 82, this.topPos + 6, 80, 9, Component.translatable("itemGroup.search")); this.searchBox.setMaxLength(50); this.searchBox.setBordered(false); -@@ -375,7 +_,7 @@ - public boolean charTyped(char p_98521_, int p_98522_) { +@@ -378,7 +_,7 @@ + public boolean charTyped(CharacterEvent p_424087_) { if (this.ignoreTextInput) { return false; - } else if (selectedTab.getType() != CreativeModeTab.Type.SEARCH) { @@ -64,16 +64,16 @@ return false; } else { String s = this.searchBox.getValue(); -@@ -394,7 +_,7 @@ +@@ -397,7 +_,7 @@ @Override - public boolean keyPressed(int p_98547_, int p_98548_, int p_98549_) { + public boolean keyPressed(KeyEvent p_429237_) { this.ignoreTextInput = false; - if (selectedTab.getType() != CreativeModeTab.Type.SEARCH) { + if (!selectedTab.hasSearchBar()) { - if (this.minecraft.options.keyChat.matches(p_98547_, p_98548_)) { + if (this.minecraft.options.keyChat.matches(p_429237_)) { this.ignoreTextInput = true; this.selectTab(CreativeModeTabs.searchTab()); -@@ -430,6 +_,7 @@ +@@ -433,6 +_,7 @@ } private void refreshSearchResults() { @@ -81,7 +81,7 @@ this.menu.items.clear(); this.visibleTags.clear(); String s = this.searchBox.getValue(); -@@ -442,10 +_,10 @@ +@@ -445,10 +_,10 @@ SearchTree searchtree; if (s.startsWith("#")) { s = s.substring(1); @@ -94,7 +94,7 @@ } this.menu.items.addAll(searchtree.search(s.toLowerCase(Locale.ROOT))); -@@ -477,7 +_,8 @@ +@@ -480,7 +_,8 @@ @Override protected void renderLabels(GuiGraphics p_283168_, int p_281774_, int p_281466_) { if (selectedTab.showTitle()) { @@ -104,17 +104,17 @@ } } -@@ -487,7 +_,7 @@ - double d0 = p_98531_ - this.leftPos; - double d1 = p_98532_ - this.topPos; +@@ -490,7 +_,7 @@ + double d0 = p_430803_.x() - this.leftPos; + double d1 = p_430803_.y() - this.topPos; - for (CreativeModeTab creativemodetab : CreativeModeTabs.tabs()) { + for (CreativeModeTab creativemodetab : currentPage.getVisibleTabs()) { if (this.checkTabClicked(creativemodetab, d0, d1)) { return true; } -@@ -509,7 +_,7 @@ - double d1 = p_98623_ - this.topPos; +@@ -512,7 +_,7 @@ + double d1 = p_423848_.y() - this.topPos; this.scrolling = false; - for (CreativeModeTab creativemodetab : CreativeModeTabs.tabs()) { @@ -122,7 +122,7 @@ if (this.checkTabClicked(creativemodetab, d0, d1)) { this.selectTab(creativemodetab); return true; -@@ -603,13 +_,15 @@ +@@ -606,13 +_,15 @@ this.originalSlots = null; } @@ -139,7 +139,7 @@ this.refreshSearchResults(); } else { -@@ -673,7 +_,14 @@ +@@ -676,7 +_,14 @@ super.render(p_283000_, p_281317_, p_282770_, p_281295_); this.effects.renderTooltip(p_283000_, p_281317_, p_282770_); @@ -155,7 +155,7 @@ if (this.checkTabHovering(p_283000_, creativemodetab, p_281317_, p_282770_)) { break; } -@@ -697,7 +_,7 @@ +@@ -700,7 +_,7 @@ public List getTooltipFromContainerItem(ItemStack p_281769_) { boolean flag = this.hoveredSlot != null && this.hoveredSlot instanceof CreativeModeInventoryScreen.CustomCreativeSlot; boolean flag1 = selectedTab.getType() == CreativeModeTab.Type.CATEGORY; @@ -164,7 +164,7 @@ TooltipFlag.Default tooltipflag$default = this.minecraft.options.advancedItemTooltips ? TooltipFlag.Default.ADVANCED : TooltipFlag.Default.NORMAL; TooltipFlag tooltipflag = flag ? tooltipflag$default.asCreative() : tooltipflag$default; List list = p_281769_.getTooltipLines(Item.TooltipContext.of(this.minecraft.level), this.minecraft.player, tooltipflag); -@@ -718,7 +_,7 @@ +@@ -721,7 +_,7 @@ int i = 1; for (CreativeModeTab creativemodetab : CreativeModeTabs.tabs()) { @@ -173,7 +173,7 @@ list1.add(i++, creativemodetab.getDisplayName().copy().withStyle(ChatFormatting.BLUE)); } } -@@ -729,7 +_,7 @@ +@@ -732,7 +_,7 @@ @Override protected void renderBg(GuiGraphics p_282663_, float p_282504_, int p_282089_, int p_282249_) { @@ -182,7 +182,7 @@ if (creativemodetab != selectedTab) { this.renderTabButton(p_282663_, creativemodetab); } -@@ -745,6 +_,7 @@ +@@ -748,6 +_,7 @@ p_282663_.blitSprite(RenderPipelines.GUI_TEXTURED, resourcelocation, j, k + (int)((i - k - 17) * this.scrollOffs), 12, 15); } @@ -190,7 +190,7 @@ this.renderTabButton(p_282663_, selectedTab); if (selectedTab.getType() == CreativeModeTab.Type.INVENTORY) { InventoryScreen.renderEntityInInventoryFollowsMouse( -@@ -763,7 +_,7 @@ +@@ -766,7 +_,7 @@ } private int getTabX(CreativeModeTab p_260136_) { @@ -199,7 +199,7 @@ int j = 27; int k = 27 * i; if (p_260136_.isAlignedRight()) { -@@ -775,7 +_,7 @@ +@@ -778,7 +_,7 @@ private int getTabY(CreativeModeTab p_260181_) { int i = 0; @@ -208,7 +208,7 @@ i -= 32; } else { i += this.imageHeight; -@@ -803,8 +_,8 @@ +@@ -806,8 +_,8 @@ protected void renderTabButton(GuiGraphics p_283590_, CreativeModeTab p_283489_) { boolean flag = p_283489_ == selectedTab; @@ -219,7 +219,7 @@ int j = this.leftPos + this.getTabX(p_283489_); int k = this.topPos - (flag1 ? 28 : -(this.imageHeight - 4)); ResourceLocation[] aresourcelocation; -@@ -814,6 +_,7 @@ +@@ -817,6 +_,7 @@ aresourcelocation = flag ? SELECTED_BOTTOM_TABS : UNSELECTED_BOTTOM_TABS; } @@ -227,7 +227,7 @@ p_283590_.blitSprite(RenderPipelines.GUI_TEXTURED, aresourcelocation[Mth.clamp(i, 0, aresourcelocation.length)], j, k, 26, 32); int l = j + 13 - 8; int i1 = k + 16 - 8 + (flag1 ? 1 : -1); -@@ -850,6 +_,14 @@ +@@ -853,6 +_,14 @@ } } @@ -242,7 +242,7 @@ @OnlyIn(Dist.CLIENT) static class CustomCreativeSlot extends Slot { public CustomCreativeSlot(Container p_98633_, int p_98634_, int p_98635_, int p_98636_) { -@@ -1031,6 +_,22 @@ +@@ -1034,6 +_,22 @@ @Override public boolean mayPickup(Player p_98665_) { return this.target.mayPickup(p_98665_); diff --git a/patches/minecraft/net/minecraft/client/gui/screens/inventory/EnchantmentScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/inventory/EnchantmentScreen.java.patch index f8d0c4866c..cb5d39718a 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/inventory/EnchantmentScreen.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/inventory/EnchantmentScreen.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/screens/inventory/EnchantmentScreen.java +++ b/net/minecraft/client/gui/screens/inventory/EnchantmentScreen.java -@@ -106,7 +_,7 @@ +@@ -107,7 +_,7 @@ int l1 = 86 - this.font.width(s); FormattedText formattedtext = EnchantmentNames.getInstance().getRandomName(this.font, l1); int i2 = -9937334; @@ -9,7 +9,7 @@ p_282430_.blitSprite(RenderPipelines.GUI_TEXTURED, ENCHANTMENT_SLOT_DISABLED_SPRITE, i1, j + 14 + 19 * l, 108, 19); p_282430_.blitSprite(RenderPipelines.GUI_TEXTURED, DISABLED_LEVEL_SPRITES[l], i1 + 1, j + 15 + 19 * l, 16, 16); p_282430_.drawWordWrap(this.font, formattedtext, j1, j + 16 + 19 * l, l1, ARGB.opaque((i2 & 16711422) >> 1), false); -@@ -157,13 +_,16 @@ +@@ -158,13 +_,16 @@ .registryAccess() .lookupOrThrow(Registries.ENCHANTMENT) .get(this.menu.enchantClue[j]); diff --git a/patches/minecraft/net/minecraft/client/gui/screens/inventory/MerchantScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/inventory/MerchantScreen.java.patch index 7209688fef..9bd67b3e70 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/inventory/MerchantScreen.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/inventory/MerchantScreen.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/screens/inventory/MerchantScreen.java +++ b/net/minecraft/client/gui/screens/inventory/MerchantScreen.java -@@ -229,6 +_,14 @@ +@@ -230,6 +_,14 @@ } else { p_281357_.renderItemDecorations(this.font, p_282046_, p_282403_, p_283601_, p_282046_.getCount() == 1 ? "1" : null); p_281357_.renderItemDecorations(this.font, p_283466_, p_282403_ + 14, p_283601_, p_283466_.getCount() == 1 ? "1" : null); diff --git a/patches/minecraft/net/minecraft/client/gui/screens/multiplayer/ServerSelectionList.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/multiplayer/ServerSelectionList.java.patch index d3272eaf0f..a25835e3ef 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/multiplayer/ServerSelectionList.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/multiplayer/ServerSelectionList.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/client/gui/screens/multiplayer/ServerSelectionList.java +++ b/net/minecraft/client/gui/screens/multiplayer/ServerSelectionList.java -@@ -371,6 +_,8 @@ - p_281406_.setTooltipForNextFrame(Lists.transform(this.onlinePlayersTooltip, Component::getVisualOrderText), p_283567_, p_282864_); +@@ -363,6 +_,8 @@ + p_425273_.setTooltipForNextFrame(Lists.transform(this.onlinePlayersTooltip, Component::getVisualOrderText), p_424268_, p_430737_); } -+ net.minecraftforge.client.ForgeHooksClient.drawForgePingInfo(this.screen, serverData, p_281406_, p_281363_, p_282921_, p_283596_, p_283567_ - p_281363_, p_282864_ - p_282921_); ++ net.minecraftforge.client.ForgeHooksClient.drawForgePingInfo(this.screen, serverData, p_425273_, this.getContentX(), this.getContentY(), this.getContentWidth(), p_424268_ - this.getContentX(), p_430737_ - this.getContentY()); + - if (this.minecraft.options.touchscreen().get() || p_282999_) { - p_281406_.fill(p_281363_, p_282921_, p_281363_ + 32, p_282921_ + 32, -1601138544); - int l = p_283567_ - p_281363_; + if (this.minecraft.options.touchscreen().get() || p_425246_) { + p_425273_.fill(this.getContentX(), this.getContentY(), this.getContentX() + 32, this.getContentY() + 32, -1601138544); + int i1 = p_424268_ - this.getContentX(); diff --git a/patches/minecraft/net/minecraft/client/gui/screens/options/controls/KeyBindsList.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/options/controls/KeyBindsList.java.patch index f0cff3c860..37b166c430 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/options/controls/KeyBindsList.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/options/controls/KeyBindsList.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/screens/options/controls/KeyBindsList.java +++ b/net/minecraft/client/gui/screens/options/controls/KeyBindsList.java -@@ -148,9 +_,10 @@ +@@ -115,9 +_,10 @@ this.name = p_343976_; this.changeButton = Button.builder(p_343976_, p_342196_ -> { KeyBindsList.this.keyBindsScreen.selectedKey = p_343088_; @@ -12,7 +12,7 @@ .createNarration( p_342179_ -> p_343088_.isUnbound() ? Component.translatable("narrator.controls.unbound", p_343976_) -@@ -158,7 +_,7 @@ +@@ -125,7 +_,7 @@ ) .build(); this.resetButton = Button.builder(RESET_BUTTON_TITLE, p_357685_ -> { @@ -21,12 +21,13 @@ KeyBindsList.this.resetMappingAndUpdateButtons(); }).bounds(0, 0, 50, 20).createNarration(p_344192_ -> Component.translatable("narrator.controls.reset", p_343976_)).build(); this.refreshEntry(); -@@ -210,7 +_,7 @@ +@@ -166,7 +_,8 @@ MutableComponent mutablecomponent = Component.empty(); if (!this.key.isUnbound()) { for (KeyMapping keymapping : KeyBindsList.this.minecraft.options.keyMappings) { -- if (keymapping != this.key && this.key.same(keymapping)) { -+ if ((keymapping != this.key && this.key.same(keymapping)) || keymapping.hasKeyModifierConflict(this.key)) { // FORGE: gracefully handle conflicts like SHIFT vs SHIFT+G +- if (keymapping != this.key && this.key.same(keymapping) && (!keymapping.isDefault() || !this.key.isDefault())) { ++ var vanillConflict = keymapping != this.key && this.key.same(keymapping) && (!keymapping.isDefault() || !this.key.isDefault()); ++ if (vanillConflict || keymapping.hasKeyModifierConflict(this.key)) { // FORGE: gracefully handle conflicts like SHIFT vs SHIFT+G if (this.hasCollision) { mutablecomponent.append(", "); } diff --git a/patches/minecraft/net/minecraft/client/gui/screens/options/controls/KeyBindsScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/options/controls/KeyBindsScreen.java.patch index f670b5c7e6..6160881a14 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/options/controls/KeyBindsScreen.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/options/controls/KeyBindsScreen.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/screens/options/controls/KeyBindsScreen.java +++ b/net/minecraft/client/gui/screens/options/controls/KeyBindsScreen.java -@@ -41,7 +_,7 @@ +@@ -43,7 +_,7 @@ protected void addFooter() { this.resetButton = Button.builder(Component.translatable("controls.resetAll"), p_343640_ -> { for (KeyMapping keymapping : this.options.keyMappings) { @@ -9,37 +9,37 @@ } this.keyBindsList.resetMappingAndUpdateButtons(); -@@ -73,11 +_,12 @@ - public boolean keyPressed(int p_342715_, int p_342862_, int p_345515_) { +@@ -75,11 +_,12 @@ + public boolean keyPressed(KeyEvent p_424487_) { if (this.selectedKey != null) { - if (p_342715_ == 256) { + if (p_424487_.isEscape()) { - this.selectedKey.setKey(InputConstants.UNKNOWN); + this.selectedKey.setKeyModifierAndCode(null, InputConstants.UNKNOWN); } else { -- this.selectedKey.setKey(InputConstants.getKey(p_342715_, p_342862_)); -+ this.selectedKey.setKeyModifierAndCode(null, InputConstants.getKey(p_342715_, p_342862_)); +- this.selectedKey.setKey(InputConstants.getKey(p_424487_)); ++ this.selectedKey.setKeyModifierAndCode(null, InputConstants.getKey(p_424487_)); } -+ if (p_342715_ == 256 || !net.minecraftforge.client.settings.KeyModifier.isKeyCodeModifier(this.selectedKey.getKey())) ++ if (p_424487_.isEscape() || !net.minecraftforge.client.settings.KeyModifier.isKeyCodeModifier(this.selectedKey.getKey())) this.selectedKey = null; this.lastKeySelection = Util.getMillis(); this.keyBindsList.resetMappingAndUpdateButtons(); -@@ -100,5 +_,18 @@ +@@ -102,5 +_,18 @@ } this.resetButton.active = flag; + } + + @Override -+ public boolean keyReleased(int keyCode, int scanCode, int modifiers) { ++ public boolean keyReleased(KeyEvent event) { + // Forge: We wait for a second key above if the first press is a modifier + // but if they release the modifier then set it explicitly. -+ var key = InputConstants.getKey(keyCode, scanCode); ++ var key = InputConstants.getKey(event); + if (this.selectedKey != null && this.selectedKey.getKey() == key) { + this.selectedKey = null; + this.lastKeySelection = Util.getMillis(); + this.keyBindsList.resetMappingAndUpdateButtons(); + } -+ return super.keyReleased(keyCode, scanCode, modifiers); ++ return super.keyReleased(event); } } diff --git a/patches/minecraft/net/minecraft/client/gui/screens/packs/PackSelectionModel.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/packs/PackSelectionModel.java.patch index 48508ec11a..4e595b6635 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/packs/PackSelectionModel.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/packs/PackSelectionModel.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/screens/packs/PackSelectionModel.java +++ b/net/minecraft/client/gui/screens/packs/PackSelectionModel.java -@@ -106,6 +_,10 @@ +@@ -108,6 +_,10 @@ boolean canMoveUp(); boolean canMoveDown(); @@ -11,7 +11,7 @@ } @OnlyIn(Dist.CLIENT) -@@ -205,6 +_,11 @@ +@@ -207,6 +_,11 @@ @Override public void moveDown() { this.move(1); diff --git a/patches/minecraft/net/minecraft/client/gui/screens/packs/PackSelectionScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/packs/PackSelectionScreen.java.patch deleted file mode 100644 index f4b8047cfe..0000000000 --- a/patches/minecraft/net/minecraft/client/gui/screens/packs/PackSelectionScreen.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/client/gui/screens/packs/PackSelectionScreen.java -+++ b/net/minecraft/client/gui/screens/packs/PackSelectionScreen.java -@@ -159,7 +_,7 @@ - TransferableSelectionList.PackEntry transferableselectionlist$packentry = p_100014_.getSelected(); - String s = transferableselectionlist$packentry == null ? "" : transferableselectionlist$packentry.getPackId(); - p_100014_.setSelected(null); -- p_100015_.forEach( -+ p_100015_.filter(PackSelectionModel.Entry::notHidden).forEach( - p_404866_ -> { - TransferableSelectionList.PackEntry transferableselectionlist$packentry1 = new TransferableSelectionList.PackEntry( - this.minecraft, p_100014_, p_404866_ diff --git a/patches/minecraft/net/minecraft/client/gui/screens/packs/TransferableSelectionList.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/packs/TransferableSelectionList.java.patch new file mode 100644 index 0000000000..260fc4fd59 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/gui/screens/packs/TransferableSelectionList.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/client/gui/screens/packs/TransferableSelectionList.java ++++ b/net/minecraft/client/gui/screens/packs/TransferableSelectionList.java +@@ -64,7 +_,7 @@ + Component component = Component.empty().append(this.title).withStyle(ChatFormatting.UNDERLINE, ChatFormatting.BOLD); + this.addEntry(new TransferableSelectionList.HeaderEntry(this.minecraft.font, component), (int)(9.0F * 1.5F)); + this.setSelected(null); +- p_429245_.forEach(p_430444_ -> { ++ p_429245_.filter(PackSelectionModel.Entry::notHidden).forEach(p_430444_ -> { + TransferableSelectionList.PackEntry transferableselectionlist$packentry = new TransferableSelectionList.PackEntry(this.minecraft, this, p_430444_); + this.addEntry(transferableselectionlist$packentry); + if (p_430177_ != null && p_430177_.getId().equals(p_430444_.getId())) { diff --git a/patches/minecraft/net/minecraft/client/gui/screens/worldselection/WorldOpenFlows.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/worldselection/WorldOpenFlows.java.patch index d33ff54196..df02cec970 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/worldselection/WorldOpenFlows.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/worldselection/WorldOpenFlows.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/client/gui/screens/worldselection/WorldOpenFlows.java +++ b/net/minecraft/client/gui/screens/worldselection/WorldOpenFlows.java @@ -329,6 +_,8 @@ - this.minecraft.forceSetScreen(new GenericMessageScreen(Component.translatable("selectWorld.resource_load"))); + this.minecraft.setScreenAndShow(new GenericMessageScreen(Component.translatable("selectWorld.resource_load"))); PackRepository packrepository = ServerPacksSource.createPackRepository(p_333651_); + net.minecraftforge.common.ForgeHooks.readAdditionalLevelSaveData(p_333651_, p_333651_.getLevelDirectory()); diff --git a/patches/minecraft/net/minecraft/client/gui/screens/worldselection/WorldSelectionList.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/worldselection/WorldSelectionList.java.patch index bdc822f29a..9dd7f50bdd 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/worldselection/WorldSelectionList.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/worldselection/WorldSelectionList.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/screens/worldselection/WorldSelectionList.java +++ b/net/minecraft/client/gui/screens/worldselection/WorldSelectionList.java -@@ -75,6 +_,7 @@ +@@ -79,6 +_,7 @@ static final ResourceLocation JOIN_HIGHLIGHTED_SPRITE = ResourceLocation.withDefaultNamespace("world_list/join_highlighted"); static final ResourceLocation JOIN_SPRITE = ResourceLocation.withDefaultNamespace("world_list/join"); static final Logger LOGGER = LogUtils.getLogger(); @@ -8,31 +8,31 @@ static final Component FROM_NEWER_TOOLTIP_1 = Component.translatable("selectWorld.tooltip.fromNewerVersion1").withStyle(ChatFormatting.RED); static final Component FROM_NEWER_TOOLTIP_2 = Component.translatable("selectWorld.tooltip.fromNewerVersion2").withStyle(ChatFormatting.RED); static final Component SNAPSHOT_TOOLTIP_1 = Component.translatable("selectWorld.tooltip.snapshot1").withStyle(ChatFormatting.GOLD); -@@ -400,6 +_,7 @@ - p_281612_.drawString(this.minecraft.font, s1, p_282820_ + 32 + 3, p_283181_ + 9 + 3, -8355712); - p_281612_.drawString(this.minecraft.font, component, p_282820_ + 32 + 3, p_283181_ + 9 + 9 + 3, -8355712); - p_281612_.blit(RenderPipelines.GUI_TEXTURED, this.icon.textureLocation(), p_282820_, p_283181_, 0.0F, 0.0F, 32, 32, 32, 32); -+ renderExperimentalWarning(p_281612_, p_283204_, p_283025_, p_283181_, p_282820_); - if (this.minecraft.options.touchscreen().get() || p_283396_) { - p_281612_.fill(p_282820_, p_283181_, p_282820_ + 32, p_283181_ + 32, -1601138544); - int j = p_283204_ - p_282820_; -@@ -450,6 +_,19 @@ - p_281612_.blitSprite(RenderPipelines.GUI_TEXTURED, resourcelocation, p_282820_, p_283181_, 32, 32); - } +@@ -494,6 +_,19 @@ } -+ } -+ + } + + // FORGE: Patch in experimental warning icon for worlds in the world selection screen + private void renderExperimentalWarning(GuiGraphics guiGraphics, int mouseX, int mouseY, int top, int left) { + if (this.summary.isLifecycleExperimental()) { -+ int leftStart = left + WorldSelectionList.this.getRowWidth(); ++ int leftStart = left + this.list.getRowWidth(); + guiGraphics.blit(RenderPipelines.GUI_TEXTURED, WorldSelectionList.FORGE_EXPERIMENTAL_WARNING_ICON, leftStart - 36, top, 0.0F, 0.0F, 32, 32, 32, 32); -+ if (WorldSelectionList.this.getEntryAtPosition(mouseX, mouseY) == this && mouseX > leftStart - 36 && mouseX < leftStart) { ++ if (this.list.getEntryAtPosition(mouseX, mouseY) == this && mouseX > leftStart - 36 && mouseX < leftStart) { + var font = Minecraft.getInstance().font; + List tooltip = font.split(Component.translatable("forge.experimentalsettings.tooltip"), 200); + guiGraphics.setTooltipForNextFrame(font, tooltip, mouseX, mouseY); + } + } - } - ++ } ++ @Override + public Component getNarration() { + Component component = Component.translatable( +@@ -520,6 +_,7 @@ + this.infoText.setPosition(i, this.getContentY() + 9 + 9 + 3); + this.infoText.render(p_424437_, p_425443_, p_425024_, p_424775_); + p_424437_.blit(RenderPipelines.GUI_TEXTURED, this.icon.textureLocation(), this.getContentX(), this.getContentY(), 0.0F, 0.0F, 32, 32, 32, 32); ++ renderExperimentalWarning(p_424437_, p_425443_, p_425024_, this.getContentY(), this.getContentX()); + if (this.list.entryType == WorldSelectionList.EntryType.SINGLEPLAYER && (this.minecraft.options.touchscreen().get() || p_430261_)) { + p_424437_.fill(this.getContentX(), this.getContentY(), this.getContentX() + 32, this.getContentY() + 32, -1601138544); + int j = p_425443_ - this.getContentX(); diff --git a/patches/minecraft/net/minecraft/client/main/Main.java.patch b/patches/minecraft/net/minecraft/client/main/Main.java.patch index e6af997fa7..5aff77b2c4 100644 --- a/patches/minecraft/net/minecraft/client/main/Main.java.patch +++ b/patches/minecraft/net/minecraft/client/main/Main.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/main/Main.java +++ b/net/minecraft/client/main/Main.java -@@ -123,8 +_,8 @@ +@@ -116,8 +_,8 @@ CrashReport.preload(); logger = LogUtils.getLogger(); s1 = "Bootstrap"; diff --git a/patches/minecraft/net/minecraft/client/model/HumanoidModel.java.patch b/patches/minecraft/net/minecraft/client/model/HumanoidModel.java.patch index b1c8dc5313..fa065b641c 100644 --- a/patches/minecraft/net/minecraft/client/model/HumanoidModel.java.patch +++ b/patches/minecraft/net/minecraft/client/model/HumanoidModel.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/model/HumanoidModel.java +++ b/net/minecraft/client/model/HumanoidModel.java -@@ -255,6 +_,8 @@ +@@ -290,6 +_,8 @@ case BRUSH: this.rightArm.xRot = this.rightArm.xRot * 0.5F - (float) (Math.PI / 5); this.rightArm.yRot = 0.0F; @@ -9,7 +9,7 @@ } } -@@ -299,6 +_,8 @@ +@@ -334,6 +_,8 @@ case BRUSH: this.leftArm.xRot = this.leftArm.xRot * 0.5F - (float) (Math.PI / 5); this.leftArm.yRot = 0.0F; @@ -18,7 +18,7 @@ } } -@@ -377,7 +_,7 @@ +@@ -402,7 +_,7 @@ } @OnlyIn(Dist.CLIENT) @@ -27,7 +27,7 @@ EMPTY(false), ITEM(false), BLOCK(false), -@@ -393,10 +_,28 @@ +@@ -418,10 +_,28 @@ private ArmPose(final boolean p_102896_) { this.twoHanded = p_102896_; diff --git a/patches/minecraft/net/minecraft/client/model/geom/LayerDefinitions.java.patch b/patches/minecraft/net/minecraft/client/model/geom/LayerDefinitions.java.patch index 4db8ff6800..227de9d65d 100644 --- a/patches/minecraft/net/minecraft/client/model/geom/LayerDefinitions.java.patch +++ b/patches/minecraft/net/minecraft/client/model/geom/LayerDefinitions.java.patch @@ -1,10 +1,10 @@ --- a/net/minecraft/client/model/geom/LayerDefinitions.java +++ b/net/minecraft/client/model/geom/LayerDefinitions.java -@@ -505,6 +_,7 @@ - builder.put(ModelLayers.createHangingSignModelName(p_374591_, hangingsignrenderer$attachmenttype), layerdefinition60); +@@ -506,6 +_,7 @@ + builder.put(ModelLayers.createHangingSignModelName(p_374591_, hangingsignrenderer$attachmenttype), layerdefinition57); } }); + net.minecraftforge.client.ForgeHooksClient.loadLayerDefinitions(builder); ImmutableMap immutablemap = builder.build(); - List list = ModelLayers.getKnownLocations().filter(p_171117_ -> !immutablemap.containsKey(p_171117_)).collect(Collectors.toList()); + List list = ModelLayers.getKnownLocations().filter(p_171117_ -> !immutablemap.containsKey(p_171117_)).toList(); if (!list.isEmpty()) { diff --git a/patches/minecraft/net/minecraft/client/model/geom/ModelLayers.java.patch b/patches/minecraft/net/minecraft/client/model/geom/ModelLayers.java.patch index 5b72e719bd..cc8f48ac45 100644 --- a/patches/minecraft/net/minecraft/client/model/geom/ModelLayers.java.patch +++ b/patches/minecraft/net/minecraft/client/model/geom/ModelLayers.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/model/geom/ModelLayers.java +++ b/net/minecraft/client/model/geom/ModelLayers.java -@@ -336,15 +_,18 @@ +@@ -328,15 +_,18 @@ } public static ModelLayerLocation createStandingSignModelName(WoodType p_171292_) { diff --git a/patches/minecraft/net/minecraft/client/multiplayer/ClientCommonPacketListenerImpl.java.patch b/patches/minecraft/net/minecraft/client/multiplayer/ClientCommonPacketListenerImpl.java.patch index 71d7815ee4..60d33c7b8e 100644 --- a/patches/minecraft/net/minecraft/client/multiplayer/ClientCommonPacketListenerImpl.java.patch +++ b/patches/minecraft/net/minecraft/client/multiplayer/ClientCommonPacketListenerImpl.java.patch @@ -1,10 +1,10 @@ --- a/net/minecraft/client/multiplayer/ClientCommonPacketListenerImpl.java +++ b/net/minecraft/client/multiplayer/ClientCommonPacketListenerImpl.java -@@ -153,6 +_,7 @@ +@@ -160,6 +_,7 @@ @Override public void handleCustomPayload(ClientboundCustomPayloadPacket p_298103_) { + if (net.minecraftforge.common.ForgeHooks.onCustomPayload(p_298103_.payload(), this.connection)) return; CustomPacketPayload custompacketpayload = p_298103_.payload(); if (!(custompacketpayload instanceof DiscardedPayload)) { - PacketUtils.ensureRunningOnSameThread(p_298103_, this, this.minecraft); + PacketUtils.ensureRunningOnSameThread(p_298103_, this, this.minecraft.packetProcessor()); diff --git a/patches/minecraft/net/minecraft/client/multiplayer/ClientConfigurationPacketListenerImpl.java.patch b/patches/minecraft/net/minecraft/client/multiplayer/ClientConfigurationPacketListenerImpl.java.patch index a279702d69..4fa16798d4 100644 --- a/patches/minecraft/net/minecraft/client/multiplayer/ClientConfigurationPacketListenerImpl.java.patch +++ b/patches/minecraft/net/minecraft/client/multiplayer/ClientConfigurationPacketListenerImpl.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/multiplayer/ClientConfigurationPacketListenerImpl.java +++ b/net/minecraft/client/multiplayer/ClientConfigurationPacketListenerImpl.java -@@ -157,6 +_,7 @@ +@@ -184,6 +_,7 @@ return true; } })); diff --git a/patches/minecraft/net/minecraft/client/multiplayer/ClientHandshakePacketListenerImpl.java.patch b/patches/minecraft/net/minecraft/client/multiplayer/ClientHandshakePacketListenerImpl.java.patch index 56d09764a0..82c6f016fe 100644 --- a/patches/minecraft/net/minecraft/client/multiplayer/ClientHandshakePacketListenerImpl.java.patch +++ b/patches/minecraft/net/minecraft/client/multiplayer/ClientHandshakePacketListenerImpl.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/multiplayer/ClientHandshakePacketListenerImpl.java +++ b/net/minecraft/client/multiplayer/ClientHandshakePacketListenerImpl.java -@@ -208,6 +_,7 @@ +@@ -214,6 +_,7 @@ Component component = this.wasTransferredTo ? CommonComponents.TRANSFER_CONNECT_FAILED : CommonComponents.CONNECT_FAILED; if (this.serverData != null && this.serverData.isRealm()) { this.minecraft.setScreen(new DisconnectedScreen(this.parent, component, p_342266_.reason(), CommonComponents.GUI_BACK)); @@ -8,7 +8,7 @@ } else { this.minecraft.setScreen(new DisconnectedScreen(this.parent, component, p_342266_)); } -@@ -232,6 +_,7 @@ +@@ -238,6 +_,7 @@ @Override public void handleCustomQuery(ClientboundCustomQueryPacket p_104545_) { diff --git a/patches/minecraft/net/minecraft/client/multiplayer/ClientLevel.java.patch b/patches/minecraft/net/minecraft/client/multiplayer/ClientLevel.java.patch index 0315f3865a..97b24e81c7 100644 --- a/patches/minecraft/net/minecraft/client/multiplayer/ClientLevel.java.patch +++ b/patches/minecraft/net/minecraft/client/multiplayer/ClientLevel.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/multiplayer/ClientLevel.java +++ b/net/minecraft/client/multiplayer/ClientLevel.java -@@ -130,6 +_,7 @@ +@@ -145,6 +_,7 @@ p_389331_.put(BiomeColors.FOLIAGE_COLOR_RESOLVER, new BlockTintCache(p_194177_ -> this.calculateBlockTint(p_194177_, BiomeColors.FOLIAGE_COLOR_RESOLVER))); p_389331_.put(BiomeColors.DRY_FOLIAGE_COLOR_RESOLVER, new BlockTintCache(p_389335_ -> this.calculateBlockTint(p_389335_, BiomeColors.DRY_FOLIAGE_COLOR_RESOLVER))); p_389331_.put(BiomeColors.WATER_COLOR_RESOLVER, new BlockTintCache(p_194168_ -> this.calculateBlockTint(p_194168_, BiomeColors.WATER_COLOR_RESOLVER))); @@ -8,7 +8,7 @@ }); private final ClientChunkCache chunkSource; private final Deque lightUpdateQueue = Queues.newArrayDeque(); -@@ -139,6 +_,8 @@ +@@ -156,6 +_,8 @@ private final int seaLevel; private boolean tickDayTime; private static final Set MARKER_PARTICLE_ITEMS = Set.of(Items.BARRIER, Items.LIGHT); @@ -16,8 +16,8 @@ + private final net.minecraftforge.client.model.data.ModelDataManager modelDataManager = new net.minecraftforge.client.model.data.ModelDataManager(this); public void handleBlockChangedAck(int p_233652_) { - this.blockStatePredictionHandler.endPredictionsUpTo(p_233652_, this); -@@ -217,6 +_,8 @@ + if (SharedConstants.DEBUG_BLOCK_BREAK) { +@@ -239,6 +_,8 @@ this.serverSimulationDistance = p_364305_; this.updateSkyBrightness(); this.prepareWeather(); @@ -26,7 +26,7 @@ } public void queueLightUpdate(Runnable p_194172_) { -@@ -299,6 +_,7 @@ +@@ -343,6 +_,7 @@ p_104640_.setOldPosAndRot(); p_104640_.tickCount++; Profiler.get().push(() -> BuiltInRegistries.ENTITY_TYPE.getKey(p_104640_.getType()).toString()); @@ -34,7 +34,7 @@ p_104640_.tick(); Profiler.get().pop(); -@@ -350,8 +_,10 @@ +@@ -394,8 +_,10 @@ } public void addEntity(Entity p_104741_) { @@ -45,7 +45,7 @@ } public void removeEntity(int p_171643_, Entity.RemovalReason p_171644_) { -@@ -532,6 +_,12 @@ +@@ -576,6 +_,12 @@ float p_263349_, long p_263408_ ) { @@ -58,7 +58,7 @@ if (p_394722_ == this.minecraft.player) { this.playSound(p_263372_, p_263404_, p_263365_, p_263335_.value(), p_263417_, p_263416_, p_263349_, false, p_263408_); } -@@ -541,6 +_,12 @@ +@@ -585,6 +_,12 @@ public void playSeededSound( @Nullable Entity p_263536_, Entity p_396496_, Holder p_263518_, SoundSource p_263487_, float p_263538_, float p_263524_, long p_263509_ ) { @@ -71,8 +71,48 @@ if (p_263536_ == this.minecraft.player) { this.minecraft.getSoundManager().play(new EntityBoundSoundInstance(p_263518_.value(), p_263487_, p_263538_, p_263524_, p_396496_, p_263509_)); } -@@ -991,6 +_,16 @@ - this.connection.registerForCleaning(p_396040_); +@@ -1032,7 +_,7 @@ + + @Override + public void addDestroyBlockEffect(BlockPos p_171667_, BlockState p_171668_) { +- if (!p_171668_.isAir() && p_171668_.shouldSpawnTerrainParticles()) { ++ if (!p_171668_.isAir() && !net.minecraftforge.client.extensions.common.IClientBlockExtensions.of(p_171668_).addDestroyEffects(p_171668_, this, p_171667_, this.minecraft.particleEngine)) { + VoxelShape voxelshape = p_171668_.getShape(this, p_171667_); + double d0 = 0.25; + voxelshape.forAllBoxes( +@@ -1067,6 +_,7 @@ + p_171668_, + p_171667_ + ) ++ .updateSprite(p_171668_, p_171667_) + ); + } + } +@@ -1076,6 +_,13 @@ + } + } + ++ public void addBreakingBlockEffect(BlockPos pos, net.minecraft.world.phys.BlockHitResult target) { ++ var state = this.getBlockState(pos); ++ if (!net.minecraftforge.client.extensions.common.IClientBlockExtensions.of(state).addHitEffects(state, this, target, this.minecraft.particleEngine)) ++ addBreakingBlockEffect(pos, target.getDirection()); ++ } ++ ++ /** @deprecated Forge - Use crack(BlockPos, BlockHitResult) as it has more context and gives more control to modders */ + public void addBreakingBlockEffect(BlockPos p_425440_, Direction p_431745_) { + BlockState blockstate = this.getBlockState(p_425440_); + if (blockstate.getRenderShape() != RenderShape.INVISIBLE && blockstate.shouldSpawnTerrainParticles()) { +@@ -1111,7 +_,7 @@ + d0 = i + aabb.maxX + 0.1F; + } + +- this.minecraft.particleEngine.add(new TerrainParticle(this, d0, d1, d2, 0.0, 0.0, 0.0, blockstate, p_425440_).setPower(0.2F).scale(0.6F)); ++ this.minecraft.particleEngine.add(new TerrainParticle(this, d0, d1, d2, 0.0, 0.0, 0.0, blockstate, p_425440_).updateSprite(blockstate, p_425440_).setPower(0.2F).scale(0.6F)); + } + } + +@@ -1175,6 +_,16 @@ + this.explosionTracker.track(p_429129_, p_428744_, p_431051_, p_431683_); } + @Override @@ -88,7 +128,7 @@ @OnlyIn(Dist.CLIENT) public static class ClientLevelData implements WritableLevelData { private final boolean hardcore; -@@ -1079,6 +_,7 @@ +@@ -1256,6 +_,7 @@ } public void setDifficulty(Difficulty p_104852_) { @@ -96,7 +136,7 @@ this.difficulty = p_104852_; } -@@ -1121,6 +_,12 @@ +@@ -1298,6 +_,12 @@ break; default: } @@ -109,7 +149,7 @@ } public void onTrackingEnd(Entity p_171716_) { -@@ -1133,6 +_,15 @@ +@@ -1310,6 +_,15 @@ ClientLevel.this.dragonParts.removeAll(Arrays.asList(enderdragon.getSubEntities())); break; default: diff --git a/patches/minecraft/net/minecraft/client/multiplayer/ClientPacketListener.java.patch b/patches/minecraft/net/minecraft/client/multiplayer/ClientPacketListener.java.patch index 533255383b..1ea5a186a3 100644 --- a/patches/minecraft/net/minecraft/client/multiplayer/ClientPacketListener.java.patch +++ b/patches/minecraft/net/minecraft/client/multiplayer/ClientPacketListener.java.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/client/multiplayer/ClientPacketListener.java +++ b/net/minecraft/client/multiplayer/ClientPacketListener.java -@@ -528,6 +_,7 @@ - - this.minecraft.debugRenderer.clear(); +@@ -514,6 +_,7 @@ + this.debugSubscriber.clear(); + this.minecraft.levelRenderer.debugRenderer.refreshRendererList(); this.minecraft.player.resetPos(); + net.minecraftforge.client.event.ForgeEventFactoryClient.firePlayerLogin(this.minecraft.gameMode, this.minecraft.player, this.minecraft.getConnection().connection); this.minecraft.player.setId(p_105030_.playerId()); this.level.addEntity(this.minecraft.player); this.minecraft.player.input = new KeyboardInput(this.minecraft.options); -@@ -1315,6 +_,8 @@ +@@ -1321,6 +_,8 @@ localplayer1.getAttributes().assignBaseValues(localplayer.getAttributes()); } @@ -17,7 +17,7 @@ this.level.addEntity(localplayer1); localplayer1.input = new KeyboardInput(this.minecraft.options); this.minecraft.gameMode.adjustPlayer(localplayer1); -@@ -1462,7 +_,7 @@ +@@ -1469,7 +_,7 @@ ProblemReporter.ScopedCollector problemreporter$scopedcollector = new ProblemReporter.ScopedCollector(p_404890_.problemPath(), LOGGER); try { @@ -26,10 +26,10 @@ } catch (Throwable throwable1) { try { problemreporter$scopedcollector.close(); -@@ -1630,7 +_,9 @@ +@@ -1646,7 +_,9 @@ @Override public void handleCommands(ClientboundCommandsPacket p_104990_) { - PacketUtils.ensureRunningOnSameThread(p_104990_, this, this.minecraft); + PacketUtils.ensureRunningOnSameThread(p_104990_, this, this.minecraft.packetProcessor()); - this.commands = new CommandDispatcher<>(p_104990_.getRoot(CommandBuildContext.simple(this.registryAccess, this.enabledFeatures), COMMAND_NODE_BUILDER)); + var context = CommandBuildContext.simple(this.registryAccess, this.enabledFeatures); + this.commands = new CommandDispatcher<>(p_104990_.getRoot(context, COMMAND_NODE_BUILDER)); @@ -37,7 +37,7 @@ } @Override -@@ -1731,6 +_,7 @@ +@@ -1747,6 +_,7 @@ if (this.minecraft.screen instanceof RecipeUpdateListener recipeupdatelistener) { recipeupdatelistener.recipesUpdated(); } @@ -45,7 +45,7 @@ } @Override -@@ -1769,6 +_,8 @@ +@@ -1785,6 +_,8 @@ this.fuelValues = FuelValues.vanillaBurnTimes(this.registryAccess, this.enabledFeatures); List list1 = List.copyOf(CreativeModeTabs.searchTab().getDisplayItems()); this.searchTrees.updateCreativeTags(list1); @@ -54,7 +54,7 @@ } @Override -@@ -2617,6 +_,8 @@ +@@ -2614,6 +_,8 @@ } public void sendChat(String p_249888_) { @@ -63,7 +63,7 @@ Instant instant = Instant.now(); long i = Crypt.SaltSupplier.getLong(); LastSeenMessagesTracker.Update lastseenmessagestracker$update = this.lastSeenMessages.generateAndApplyUpdate(); -@@ -2625,6 +_,7 @@ +@@ -2622,6 +_,7 @@ } public void sendCommand(String p_250092_) { @@ -71,7 +71,7 @@ SignableCommand signablecommand = SignableCommand.of(this.commands.parse(p_250092_, this.suggestionsProvider)); if (signablecommand.arguments().isEmpty()) { this.send(new ServerboundChatCommandPacket(p_250092_)); -@@ -2641,6 +_,7 @@ +@@ -2638,6 +_,7 @@ } public void sendUnattendedCommand(String p_407213_, @Nullable Screen p_406262_) { diff --git a/patches/minecraft/net/minecraft/client/multiplayer/MultiPlayerGameMode.java.patch b/patches/minecraft/net/minecraft/client/multiplayer/MultiPlayerGameMode.java.patch index 04c7d256d0..3edc8e15d7 100644 --- a/patches/minecraft/net/minecraft/client/multiplayer/MultiPlayerGameMode.java.patch +++ b/patches/minecraft/net/minecraft/client/multiplayer/MultiPlayerGameMode.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/multiplayer/MultiPlayerGameMode.java +++ b/net/minecraft/client/multiplayer/MultiPlayerGameMode.java -@@ -111,6 +_,7 @@ +@@ -112,6 +_,7 @@ } public boolean destroyBlock(BlockPos p_105268_) { @@ -8,7 +8,7 @@ if (this.minecraft.player.blockActionRestricted(this.minecraft.level, p_105268_, this.localPlayerMode)) { return false; } else { -@@ -125,9 +_,8 @@ +@@ -126,9 +_,8 @@ } else if (blockstate.isAir()) { return false; } else { @@ -19,15 +19,15 @@ if (flag) { block.destroy(level, p_105268_, blockstate); } -@@ -148,6 +_,7 @@ - BlockState blockstate = this.minecraft.level.getBlockState(p_105270_); - this.minecraft.getTutorial().onDestroyBlock(this.minecraft.level, p_105270_, blockstate, 1.0F); +@@ -157,6 +_,7 @@ + } + this.startPrediction(this.minecraft.level, p_233757_ -> { + if (!net.minecraftforge.event.ForgeEventFactory.isLeftClickBlockCancelled(this.minecraft.player, p_105270_, p_105271_, ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK)) this.destroyBlock(p_105270_); return new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK, p_105270_, p_105271_, p_233757_); }); -@@ -157,15 +_,18 @@ +@@ -170,6 +_,7 @@ this.connection .send(new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.ABORT_DESTROY_BLOCK, this.destroyBlockPos, p_105271_)); } @@ -35,6 +35,7 @@ BlockState blockstate1 = this.minecraft.level.getBlockState(p_105270_); this.minecraft.getTutorial().onDestroyBlock(this.minecraft.level, p_105270_, blockstate1, 0.0F); +@@ -180,9 +_,11 @@ this.startPrediction(this.minecraft.level, p_233728_ -> { boolean flag = !blockstate1.isAir(); if (flag && this.destroyProgress == 0.0F) { @@ -46,7 +47,7 @@ if (flag && blockstate1.getDestroyProgress(this.minecraft.player, this.minecraft.player.level(), p_105270_) >= 1.0F) { this.destroyBlock(p_105270_); } else { -@@ -176,6 +_,7 @@ +@@ -193,6 +_,7 @@ this.destroyTicks = 0.0F; this.minecraft.level.destroyBlockProgress(this.minecraft.player.getId(), this.destroyBlockPos, this.getDestroyStage()); } @@ -54,15 +55,15 @@ return new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK, p_105270_, p_105271_, p_233728_); }); -@@ -208,6 +_,7 @@ - BlockState blockstate1 = this.minecraft.level.getBlockState(p_105284_); - this.minecraft.getTutorial().onDestroyBlock(this.minecraft.level, p_105284_, blockstate1, 1.0F); +@@ -233,6 +_,7 @@ + } + this.startPrediction(this.minecraft.level, p_233753_ -> { + if (!net.minecraftforge.event.ForgeEventFactory.isLeftClickBlockCancelled(this.minecraft.player, p_105284_, p_105285_, ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK)) this.destroyBlock(p_105284_); return new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK, p_105284_, p_105285_, p_233753_); }); -@@ -220,7 +_,7 @@ +@@ -245,7 +_,7 @@ } else { this.destroyProgress = this.destroyProgress + blockstate.getDestroyProgress(this.minecraft.player, this.minecraft.player.level(), p_105284_); if (this.destroyTicks % 4.0F == 0.0F) { @@ -71,15 +72,15 @@ this.minecraft .getSoundManager() .play( -@@ -237,6 +_,7 @@ +@@ -262,6 +_,7 @@ this.destroyTicks++; this.minecraft.getTutorial().onDestroyBlock(this.minecraft.level, p_105284_, blockstate, Mth.clamp(this.destroyProgress, 0.0F, 1.0F)); + if (net.minecraftforge.event.ForgeEventFactory.onLeftClickBlockHold(this.minecraft.player, p_105284_, p_105285_).getUseItem().isDenied()) return true; if (this.destroyProgress >= 1.0F) { this.isDestroying = false; - this.startPrediction(this.minecraft.level, p_233739_ -> { -@@ -275,7 +_,7 @@ + if (SharedConstants.DEBUG_BLOCK_BREAK) { +@@ -304,7 +_,7 @@ private boolean sameDestroyTarget(BlockPos p_105282_) { ItemStack itemstack = this.minecraft.player.getMainHandItem(); @@ -88,7 +89,7 @@ } private void ensureHasSentCarriedItem() { -@@ -303,12 +_,23 @@ +@@ -332,12 +_,23 @@ private InteractionResult performUseItemOn(LocalPlayer p_233747_, InteractionHand p_233748_, BlockHitResult p_233749_) { BlockPos blockpos = p_233749_.getBlockPos(); ItemStack itemstack = p_233747_.getItemInHand(p_233748_); @@ -114,7 +115,7 @@ BlockState blockstate = this.minecraft.level.getBlockState(blockpos); if (!this.connection.isFeatureEnabled(blockstate.getBlock().requiredFeatures())) { return InteractionResult.FAIL; -@@ -329,8 +_,10 @@ +@@ -358,8 +_,10 @@ } } @@ -127,7 +128,7 @@ InteractionResult interactionresult2; if (p_233747_.hasInfiniteMaterials()) { int i = itemstack.getCount(); -@@ -364,6 +_,11 @@ +@@ -393,6 +_,11 @@ mutableobject.setValue(InteractionResult.PASS); return serverbounduseitempacket; } else { @@ -139,7 +140,7 @@ InteractionResult interactionresult = itemstack.use(this.minecraft.level, p_233722_, p_233723_); ItemStack itemstack1; if (interactionresult instanceof InteractionResult.Success interactionresult$success) { -@@ -374,6 +_,9 @@ +@@ -403,6 +_,9 @@ if (itemstack1 != itemstack) { p_233722_.setItemInHand(p_233723_, itemstack1); @@ -149,7 +150,7 @@ } mutableobject.setValue(interactionresult); -@@ -405,6 +_,10 @@ +@@ -434,6 +_,10 @@ public InteractionResult interact(Player p_105227_, Entity p_105228_, InteractionHand p_105229_) { this.ensureHasSentCarriedItem(); this.connection.send(ServerboundInteractPacket.createInteractionPacket(p_105228_, p_105227_.isShiftKeyDown(), p_105229_)); @@ -160,7 +161,7 @@ return (InteractionResult)(this.localPlayerMode == GameType.SPECTATOR ? InteractionResult.PASS : p_105227_.interactOn(p_105228_, p_105229_)); } -@@ -412,6 +_,10 @@ +@@ -441,6 +_,10 @@ this.ensureHasSentCarriedItem(); Vec3 vec3 = p_105233_.getLocation().subtract(p_105232_.getX(), p_105232_.getY(), p_105232_.getZ()); this.connection.send(ServerboundInteractPacket.createInteractionPacket(p_105232_, p_105231_.isShiftKeyDown(), p_105234_, vec3)); diff --git a/patches/minecraft/net/minecraft/client/multiplayer/PlayerInfo.java.patch b/patches/minecraft/net/minecraft/client/multiplayer/PlayerInfo.java.patch index 4695d7e5ef..ec61033add 100644 --- a/patches/minecraft/net/minecraft/client/multiplayer/PlayerInfo.java.patch +++ b/patches/minecraft/net/minecraft/client/multiplayer/PlayerInfo.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/multiplayer/PlayerInfo.java +++ b/net/minecraft/client/multiplayer/PlayerInfo.java -@@ -88,6 +_,7 @@ +@@ -76,6 +_,7 @@ } protected void setGameMode(GameType p_105318_) { diff --git a/patches/minecraft/net/minecraft/client/multiplayer/ServerData.java.patch b/patches/minecraft/net/minecraft/client/multiplayer/ServerData.java.patch index 75c176cbff..1c302478c1 100644 --- a/patches/minecraft/net/minecraft/client/multiplayer/ServerData.java.patch +++ b/patches/minecraft/net/minecraft/client/multiplayer/ServerData.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/client/multiplayer/ServerData.java +++ b/net/minecraft/client/multiplayer/ServerData.java -@@ -37,6 +_,7 @@ - private byte[] iconBytes; +@@ -38,6 +_,7 @@ private ServerData.Type type; + private int acceptedCodeOfConduct; private ServerData.State state = ServerData.State.INITIAL; + public net.minecraftforge.client.ExtendedServerListData forgeData = null; diff --git a/patches/minecraft/net/minecraft/client/multiplayer/ServerStatusPinger.java.patch b/patches/minecraft/net/minecraft/client/multiplayer/ServerStatusPinger.java.patch index a9f9e6b913..b21b1fe732 100644 --- a/patches/minecraft/net/minecraft/client/multiplayer/ServerStatusPinger.java.patch +++ b/patches/minecraft/net/minecraft/client/multiplayer/ServerStatusPinger.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/multiplayer/ServerStatusPinger.java +++ b/net/minecraft/client/multiplayer/ServerStatusPinger.java -@@ -99,6 +_,7 @@ +@@ -107,6 +_,7 @@ p_105461_.run(); } }); diff --git a/patches/minecraft/net/minecraft/client/multiplayer/chat/ChatListener.java.patch b/patches/minecraft/net/minecraft/client/multiplayer/chat/ChatListener.java.patch index 0776c332e6..bcc66ef5e3 100644 --- a/patches/minecraft/net/minecraft/client/multiplayer/chat/ChatListener.java.patch +++ b/patches/minecraft/net/minecraft/client/multiplayer/chat/ChatListener.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/multiplayer/chat/ChatListener.java +++ b/net/minecraft/client/multiplayer/chat/ChatListener.java -@@ -124,7 +_,9 @@ +@@ -133,7 +_,9 @@ Instant instant = Instant.now(); this.handleMessage(null, () -> { Component component = p_251256_.decorate(p_250375_); @@ -11,7 +11,7 @@ this.narrateChatMessage(p_251256_, p_250375_); this.logSystemMessage(component, instant); this.previousMessageTime = Util.getMillis(); -@@ -143,12 +_,16 @@ +@@ -152,12 +_,16 @@ MessageSignature messagesignature = p_249430_.signature(); FilterMask filtermask = p_249430_.filterMask(); if (filtermask.isEmpty()) { @@ -30,7 +30,7 @@ this.narrateChatMessage(p_251766_, component); } } -@@ -181,6 +_,8 @@ +@@ -190,6 +_,8 @@ public void handleSystemMessage(Component p_240522_, boolean p_240642_) { if (!this.minecraft.options.hideMatchedNames().get() || !this.minecraft.isBlocked(this.guessChatUUID(p_240522_))) { diff --git a/patches/minecraft/net/minecraft/client/particle/FireworkParticles.java.patch b/patches/minecraft/net/minecraft/client/particle/FireworkParticles.java.patch index dc8fb908f3..ea28f7412e 100644 --- a/patches/minecraft/net/minecraft/client/particle/FireworkParticles.java.patch +++ b/patches/minecraft/net/minecraft/client/particle/FireworkParticles.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/particle/FireworkParticles.java +++ b/net/minecraft/client/particle/FireworkParticles.java -@@ -263,6 +_,10 @@ +@@ -268,6 +_,10 @@ intlist = IntList.of(DyeColor.BLACK.getFireworkColor()); } diff --git a/patches/minecraft/net/minecraft/client/particle/FlyTowardsPositionParticle.java.patch b/patches/minecraft/net/minecraft/client/particle/FlyTowardsPositionParticle.java.patch index 8fd52f5f15..39f12380da 100644 --- a/patches/minecraft/net/minecraft/client/particle/FlyTowardsPositionParticle.java.patch +++ b/patches/minecraft/net/minecraft/client/particle/FlyTowardsPositionParticle.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/particle/FlyTowardsPositionParticle.java +++ b/net/minecraft/client/particle/FlyTowardsPositionParticle.java -@@ -104,6 +_,7 @@ +@@ -114,6 +_,7 @@ this.x = this.xStart + this.xd * f; this.y = this.yStart + this.yd * f - f1 * 1.2F; this.z = this.zStart + this.zd * f; diff --git a/patches/minecraft/net/minecraft/client/particle/Particle.java.patch b/patches/minecraft/net/minecraft/client/particle/Particle.java.patch index 353390c723..5eab6734d0 100644 --- a/patches/minecraft/net/minecraft/client/particle/Particle.java.patch +++ b/patches/minecraft/net/minecraft/client/particle/Particle.java.patch @@ -1,17 +1,9 @@ --- a/net/minecraft/client/particle/Particle.java +++ b/net/minecraft/client/particle/Particle.java -@@ -248,6 +_,18 @@ +@@ -207,6 +_,10 @@ return Optional.empty(); } -+ /** -+ * Forge added method that controls if a particle should be culled to it's bounding box. -+ * Default behaviour is culling enabled -+ */ -+ public boolean shouldCull() { -+ return true; -+ } -+ + public net.minecraft.world.phys.Vec3 getPos() { + return new net.minecraft.world.phys.Vec3(this.x, this.y, this.z); + } diff --git a/patches/minecraft/net/minecraft/client/particle/ParticleEngine.java.patch b/patches/minecraft/net/minecraft/client/particle/ParticleEngine.java.patch index f195225c68..c9d66eac3e 100644 --- a/patches/minecraft/net/minecraft/client/particle/ParticleEngine.java.patch +++ b/patches/minecraft/net/minecraft/client/particle/ParticleEngine.java.patch @@ -1,148 +1,29 @@ --- a/net/minecraft/client/particle/ParticleEngine.java +++ b/net/minecraft/client/particle/ParticleEngine.java -@@ -72,10 +_,10 @@ - private static final int MAX_PARTICLES_PER_LAYER = 16384; - private static final List RENDER_ORDER = List.of(ParticleRenderType.TERRAIN_SHEET, ParticleRenderType.PARTICLE_SHEET_OPAQUE, ParticleRenderType.PARTICLE_SHEET_TRANSLUCENT); +@@ -26,7 +_,7 @@ + public class ParticleEngine { + private static final List RENDER_ORDER = List.of(ParticleRenderType.SINGLE_QUADS, ParticleRenderType.ITEM_PICKUP, ParticleRenderType.ELDER_GUARDIANS); protected ClientLevel level; -- private final Map> particles = Maps.newIdentityHashMap(); -+ private final Map> particles = Maps.newTreeMap(net.minecraftforge.client.ForgeHooksClient.makeParticleRenderTypeComparator(RENDER_ORDER)); +- private final Map> particles = Maps.newIdentityHashMap(); ++ private final Map> particles = Maps.newTreeMap(net.minecraftforge.client.ForgeHooksClient.makeParticleRenderTypeComparator(RENDER_ORDER)); private final Queue trackingEmitters = Queues.newArrayDeque(); - private final RandomSource random = RandomSource.create(); -- private final Int2ObjectMap> providers = new Int2ObjectOpenHashMap<>(); -+ private final Map> providers = new java.util.HashMap<>(); private final Queue particlesToAdd = Queues.newArrayDeque(); - private final Map spriteSets = Maps.newHashMap(); - private final TextureAtlas textureAtlas; -@@ -205,10 +_,14 @@ - this.register(ParticleTypes.FIREFLY, FireflyParticle.FireflyProvider::new); - } - -+ /** @deprecated Register via {@link net.minecraftforge.client.event.RegisterParticleProvidersEvent} */ -+ @Deprecated - public void register(ParticleType p_107382_, ParticleProvider p_107383_) { -- this.providers.put(BuiltInRegistries.PARTICLE_TYPE.getId(p_107382_), p_107383_); -+ this.providers.put(BuiltInRegistries.PARTICLE_TYPE.getKey(p_107382_), p_107383_); - } - -+ /** @deprecated Register via {@link net.minecraftforge.client.event.RegisterParticleProvidersEvent} */ -+ @Deprecated - public void register(ParticleType p_273423_, ParticleProvider.Sprite p_273134_) { - this.register( - p_273423_, -@@ -225,10 +_,12 @@ - ); - } - -+ /** @deprecated Register via {@link net.minecraftforge.client.event.RegisterParticleProvidersEvent} */ -+ @Deprecated - public void register(ParticleType p_107379_, ParticleEngine.SpriteParticleRegistration p_107380_) { - ParticleEngine.MutableSpriteSet particleengine$mutablespriteset = new ParticleEngine.MutableSpriteSet(); - this.spriteSets.put(BuiltInRegistries.PARTICLE_TYPE.getKey(p_107379_), particleengine$mutablespriteset); -- this.providers.put(BuiltInRegistries.PARTICLE_TYPE.getId(p_107379_), p_107380_.create(particleengine$mutablespriteset)); -+ this.providers.put(BuiltInRegistries.PARTICLE_TYPE.getKey(p_107379_), p_107380_.create(particleengine$mutablespriteset)); - } - - @Override -@@ -348,7 +_,7 @@ + private final Object2IntOpenHashMap trackedParticleCounts = new Object2IntOpenHashMap<>(); +@@ -63,7 +_,7 @@ private Particle makeParticle( T p_107396_, double p_107397_, double p_107398_, double p_107399_, double p_107400_, double p_107401_, double p_107402_ ) { -- ParticleProvider particleprovider = (ParticleProvider)this.providers.get(BuiltInRegistries.PARTICLE_TYPE.getId(p_107396_.getType())); -+ ParticleProvider particleprovider = (ParticleProvider)this.providers.get(BuiltInRegistries.PARTICLE_TYPE.getKey(p_107396_.getType())); +- ParticleProvider particleprovider = (ParticleProvider)this.resourceManager.getProviders().get(BuiltInRegistries.PARTICLE_TYPE.getId(p_107396_.getType())); ++ ParticleProvider particleprovider = (ParticleProvider)this.resourceManager.getProvider(p_107396_.getType()); return particleprovider == null ? null - : particleprovider.createParticle(p_107396_, this.level, p_107397_, p_107398_, p_107399_, p_107400_, p_107401_, p_107402_); -@@ -424,28 +_,36 @@ - } + : particleprovider.createParticle(p_107396_, this.level, p_107397_, p_107398_, p_107399_, p_107400_, p_107401_, p_107402_, this.random); +@@ -123,7 +_,7 @@ } -+ /**@deprecated Forge: use {@link #render(Camera, float, net.minecraft.client.renderer.culling.Frustum)} with Frustum as additional parameter*/ -+ @Deprecated - public void render(Camera p_107340_, float p_107341_, MultiBufferSource.BufferSource p_377798_) { + public void extract(ParticlesRenderState p_423938_, Frustum p_424803_, Camera p_430521_, float p_426823_) { - for (ParticleRenderType particlerendertype : RENDER_ORDER) { -+ render(p_107340_, p_107341_, p_377798_, null); -+ } -+ -+ public void render(Camera p_107340_, float p_107341_, MultiBufferSource.BufferSource p_377798_, @Nullable net.minecraft.client.renderer.culling.Frustum frustum) { -+ for (ParticleRenderType particlerendertype : this.particles.keySet()) { // Forge: allow custom IParticleRenderType's -+ if (particlerendertype.renderType() == null) continue; - Queue queue = this.particles.get(particlerendertype); - if (queue != null && !queue.isEmpty()) { -- renderParticleType(p_107340_, p_107341_, p_377798_, particlerendertype, queue); -+ renderParticleType(p_107340_, p_107341_, p_377798_, particlerendertype, queue, frustum); - } - } - - Queue queue1 = this.particles.get(ParticleRenderType.CUSTOM); - if (queue1 != null && !queue1.isEmpty()) { -- renderCustomParticles(p_107340_, p_107341_, p_377798_, queue1); -+ renderCustomParticles(p_107340_, p_107341_, p_377798_, queue1, frustum); - } - - p_377798_.endBatch(); - } - - private static void renderParticleType( -- Camera p_376120_, float p_375470_, MultiBufferSource.BufferSource p_377543_, ParticleRenderType p_378369_, Queue p_376283_ -+ Camera p_376120_, float p_375470_, MultiBufferSource.BufferSource p_377543_, ParticleRenderType p_378369_, Queue p_376283_, @Nullable net.minecraft.client.renderer.culling.Frustum frustum - ) { - VertexConsumer vertexconsumer = p_377543_.getBuffer(Objects.requireNonNull(p_378369_.renderType())); - - for (Particle particle : p_376283_) { -+ if (frustum != null && particle.shouldCull() && !frustum.isVisible(particle.getBoundingBox())) continue; - try { - particle.render(vertexconsumer, p_376120_, p_375470_); - } catch (Throwable throwable) { -@@ -458,10 +_,11 @@ - } - } - -- private static void renderCustomParticles(Camera p_377913_, float p_376893_, MultiBufferSource.BufferSource p_376978_, Queue p_375784_) { -+ private static void renderCustomParticles(Camera p_377913_, float p_376893_, MultiBufferSource.BufferSource p_376978_, Queue p_375784_, @Nullable net.minecraft.client.renderer.culling.Frustum frustum) { - PoseStack posestack = new PoseStack(); - - for (Particle particle : p_375784_) { -+ if (frustum != null && particle.shouldCull() && !frustum.isVisible(particle.getBoundingBox())) continue; - try { - particle.renderCustom(posestack, p_376978_, p_377913_, p_376893_); - } catch (Throwable throwable) { -@@ -481,7 +_,7 @@ - } - - public void destroy(BlockPos p_107356_, BlockState p_107357_) { -- if (!p_107357_.isAir() && p_107357_.shouldSpawnTerrainParticles()) { -+ if (!p_107357_.isAir() && !net.minecraftforge.client.extensions.common.IClientBlockExtensions.of(p_107357_).addDestroyEffects(p_107357_, this.level, p_107356_, this)) { - VoxelShape voxelshape = p_107357_.getShape(this.level, p_107356_); - double d0 = 0.25; - voxelshape.forAllBoxes( -@@ -514,6 +_,7 @@ - p_107357_, - p_107356_ - ) -+ .updateSprite(p_107357_, p_107356_) - ); - } - } -@@ -523,6 +_,13 @@ - } - } - -+ public void addBlockHitEffects(BlockPos pos, net.minecraft.world.phys.BlockHitResult target) { -+ var state = level.getBlockState(pos); -+ if (!net.minecraftforge.client.extensions.common.IClientBlockExtensions.of(state).addHitEffects(state, level, target, this)) -+ crack(pos, target.getDirection()); -+ } -+ -+ @Deprecated // Forge - Use addBlockHitEffects as it has more context and gives more control to modders - public void crack(BlockPos p_107368_, Direction p_107369_) { - BlockState blockstate = this.level.getBlockState(p_107368_); - if (blockstate.getRenderShape() != RenderShape.INVISIBLE && blockstate.shouldSpawnTerrainParticles()) { -@@ -558,7 +_,7 @@ - d0 = i + aabb.maxX + 0.1F; - } - -- this.add(new TerrainParticle(this.level, d0, d1, d2, 0.0, 0.0, 0.0, blockstate, p_107368_).setPower(0.2F).scale(0.6F)); -+ this.add(new TerrainParticle(this.level, d0, d1, d2, 0.0, 0.0, 0.0, blockstate, p_107368_).updateSprite(blockstate, p_107368_).setPower(0.2F).scale(0.6F)); - } - } - ++ for (ParticleRenderType particlerendertype : this.particles.keySet()) { // Forge: allow custom ParticleRenderType's + ParticleGroup particlegroup = this.particles.get(particlerendertype); + if (particlegroup != null && !particlegroup.isEmpty()) { + p_423938_.add(particlegroup.extractRenderState(p_424803_, p_430521_, p_426823_)); diff --git a/patches/minecraft/net/minecraft/client/particle/ParticleResources.java.patch b/patches/minecraft/net/minecraft/client/particle/ParticleResources.java.patch new file mode 100644 index 0000000000..357cb805c7 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/particle/ParticleResources.java.patch @@ -0,0 +1,43 @@ +--- a/net/minecraft/client/particle/ParticleResources.java ++++ b/net/minecraft/client/particle/ParticleResources.java +@@ -45,6 +_,7 @@ + private static final FileToIdConverter PARTICLE_LISTER = FileToIdConverter.json("particles"); + private final Map spriteSets = Maps.newHashMap(); + private final Int2ObjectMap> providers = new Int2ObjectOpenHashMap<>(); ++ private final Map> providersByName = new java.util.HashMap<>(); + @Nullable + private Runnable onReload; + +@@ -174,14 +_,17 @@ + this.register(ParticleTypes.FIREFLY, FireflyParticle.FireflyProvider::new); + } + ++ /** @deprecated Register via {@link net.minecraftforge.client.event.RegisterParticleProvidersEvent} */ + public void register(ParticleType p_427222_, ParticleProvider p_423729_) { + this.providers.put(BuiltInRegistries.PARTICLE_TYPE.getId(p_427222_), p_423729_); ++ this.providersByName.put(BuiltInRegistries.PARTICLE_TYPE.getKey(p_427222_), p_423729_); + } + ++ /** @deprecated Register via {@link net.minecraftforge.client.event.RegisterParticleProvidersEvent} */ + public void register(ParticleType p_427223_, ParticleResources.SpriteParticleRegistration p_423156_) { + ParticleResources.MutableSpriteSet particleresources$mutablespriteset = new ParticleResources.MutableSpriteSet(); + this.spriteSets.put(BuiltInRegistries.PARTICLE_TYPE.getKey(p_427223_), particleresources$mutablespriteset); +- this.providers.put(BuiltInRegistries.PARTICLE_TYPE.getId(p_427223_), p_423156_.create(particleresources$mutablespriteset)); ++ register(p_427223_, p_423156_.create(particleresources$mutablespriteset)); + } + + @Override +@@ -274,8 +_,13 @@ + } + } + ++ /** @deprecated Use getProvider(ProviderType) as these ids may not be in sync with servers */ + public Int2ObjectMap> getProviders() { + return this.providers; ++ } ++ ++ public ParticleProvider getProvider(ParticleType type) { ++ return (ParticleProvider)this.providersByName.get(BuiltInRegistries.PARTICLE_TYPE.getKey(type)); + } + + @OnlyIn(Dist.CLIENT) diff --git a/patches/minecraft/net/minecraft/client/particle/PortalParticle.java.patch b/patches/minecraft/net/minecraft/client/particle/PortalParticle.java.patch index ebaf5cc8d8..ccff6769f1 100644 --- a/patches/minecraft/net/minecraft/client/particle/PortalParticle.java.patch +++ b/patches/minecraft/net/minecraft/client/particle/PortalParticle.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/particle/PortalParticle.java +++ b/net/minecraft/client/particle/PortalParticle.java -@@ -80,6 +_,7 @@ +@@ -91,6 +_,7 @@ this.x = this.xStart + this.xd * f2; this.y = this.yStart + this.yd * f2 + (1.0F - f); this.z = this.zStart + this.zd * f2; diff --git a/patches/minecraft/net/minecraft/client/particle/ReversePortalParticle.java.patch b/patches/minecraft/net/minecraft/client/particle/ReversePortalParticle.java.patch index 2f584aba76..bd115b3485 100644 --- a/patches/minecraft/net/minecraft/client/particle/ReversePortalParticle.java.patch +++ b/patches/minecraft/net/minecraft/client/particle/ReversePortalParticle.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/particle/ReversePortalParticle.java +++ b/net/minecraft/client/particle/ReversePortalParticle.java -@@ -31,6 +_,7 @@ +@@ -42,6 +_,7 @@ this.x = this.x + this.xd * f; this.y = this.y + this.yd * f; this.z = this.z + this.zd * f; diff --git a/patches/minecraft/net/minecraft/client/particle/VibrationSignalParticle.java.patch b/patches/minecraft/net/minecraft/client/particle/VibrationSignalParticle.java.patch index 05b6502a67..b8a6f0704d 100644 --- a/patches/minecraft/net/minecraft/client/particle/VibrationSignalParticle.java.patch +++ b/patches/minecraft/net/minecraft/client/particle/VibrationSignalParticle.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/particle/VibrationSignalParticle.java +++ b/net/minecraft/client/particle/VibrationSignalParticle.java -@@ -76,6 +_,7 @@ +@@ -80,6 +_,7 @@ this.x = Mth.lerp(d0, this.x, vec3.x()); this.y = Mth.lerp(d0, this.y, vec3.y()); this.z = Mth.lerp(d0, this.z, vec3.z()); diff --git a/patches/minecraft/net/minecraft/client/player/AbstractClientPlayer.java.patch b/patches/minecraft/net/minecraft/client/player/AbstractClientPlayer.java.patch index f36c796aca..61947829cd 100644 --- a/patches/minecraft/net/minecraft/client/player/AbstractClientPlayer.java.patch +++ b/patches/minecraft/net/minecraft/client/player/AbstractClientPlayer.java.patch @@ -1,10 +1,11 @@ --- a/net/minecraft/client/player/AbstractClientPlayer.java +++ b/net/minecraft/client/player/AbstractClientPlayer.java -@@ -86,6 +_,6 @@ +@@ -138,7 +_,7 @@ } } - return Mth.lerp(p_362521_, 1.0F, f); + return net.minecraftforge.client.event.ForgeEventFactoryClient.fireFovModifierEvent(this, f, p_362521_).getNewFovModifier(); } - } + + @Override diff --git a/patches/minecraft/net/minecraft/client/player/LocalPlayer.java.patch b/patches/minecraft/net/minecraft/client/player/LocalPlayer.java.patch index 6fa16a050f..bebc2a4a20 100644 --- a/patches/minecraft/net/minecraft/client/player/LocalPlayer.java.patch +++ b/patches/minecraft/net/minecraft/client/player/LocalPlayer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/player/LocalPlayer.java +++ b/net/minecraft/client/player/LocalPlayer.java -@@ -297,6 +_,7 @@ +@@ -295,6 +_,7 @@ ServerboundPlayerActionPacket.Action serverboundplayeractionpacket$action = p_108701_ ? ServerboundPlayerActionPacket.Action.DROP_ALL_ITEMS : ServerboundPlayerActionPacket.Action.DROP_ITEM; @@ -8,7 +8,7 @@ ItemStack itemstack = this.getInventory().removeFromSelected(p_108701_); this.connection.send(new ServerboundPlayerActionPacket(serverboundplayeractionpacket$action, BlockPos.ZERO, Direction.DOWN)); return !itemstack.isEmpty(); -@@ -478,7 +_,11 @@ +@@ -482,7 +_,11 @@ @Override public void playSound(SoundEvent p_108651_, float p_108652_, float p_108653_) { @@ -21,7 +21,7 @@ } @Override -@@ -716,6 +_,7 @@ +@@ -720,6 +_,7 @@ && this.canPlayerFitWithinBlocksAndEntitiesWhen(Pose.CROUCHING) && (this.isShiftKeyDown() || !this.isSleeping() && !this.canPlayerFitWithinBlocksAndEntitiesWhen(Pose.STANDING)); this.input.tick(); @@ -29,7 +29,7 @@ this.minecraft.getTutorial().onInput(this.input); boolean flag3 = false; if (this.autoJumpTime > 0) { -@@ -788,8 +_,9 @@ +@@ -792,8 +_,9 @@ } this.wasFallFlying = this.isFallFlying(); @@ -41,24 +41,16 @@ } if (this.isEyeInFluid(FluidTags.WATER)) { -@@ -856,13 +_,14 @@ - || !this.input.hasForwardImpulse() - || !this.hasEnoughFoodToSprint() - || this.horizontalCollision && !this.minorHorizontalCollision -- || this.isInWater() && !this.isUnderWater(); -+ || this.isInWater() && !this.isUnderWater() -+ || this.isInFluidType((fluidType, height) -> this.canSwimInFluidType(fluidType)) && !this.canStartSwimming(); +@@ -859,7 +_,7 @@ } private boolean shouldStopSwimSprinting() { - return this.hasBlindness() - || this.isPassenger() && !this.vehicleCanSprint(this.getVehicle()) -- || !this.isInWater() -+ || !this.isInWaterOrSwimmable() - || !this.input.hasForwardImpulse() && !this.onGround() && !this.input.keyPresses.shift() - || !this.hasEnoughFoodToSprint(); +- return !this.isSprintingPossible(true) || !this.isInWater() || !this.input.hasForwardImpulse() && !this.onGround() && !this.input.keyPresses.shift(); ++ return !this.isSprintingPossible(true) || !this.isInWaterOrSwimmable() || !this.input.hasForwardImpulse() && !this.onGround() && !this.input.keyPresses.shift(); } -@@ -914,6 +_,8 @@ + + public Portal.Transition getActivePortalLocalTransition() { +@@ -902,6 +_,8 @@ @Override public void rideTick() { super.rideTick(); @@ -67,16 +59,16 @@ this.handsBusy = false; if (this.getControlledVehicle() instanceof AbstractBoat abstractboat) { abstractboat.setInput( -@@ -1090,7 +_,7 @@ - && (!this.isPassenger() || this.vehicleCanSprint(this.getVehicle())) +@@ -1079,7 +_,7 @@ + && this.isSprintingPossible(this.getAbilities().flying) + && !this.isUsingItem() && (!this.isFallFlying() || this.isUnderWater()) - && (!this.isMovingSlowly() || this.isUnderWater()) -- && (!this.isInWater() || this.isUnderWater()); -+ && (!this.isInWater() || this.isUnderWater() || this.canStartSwimming()); +- && (!this.isMovingSlowly() || this.isUnderWater()); ++ && (!this.isMovingSlowly() || this.isUnderWater() || this.canStartSwimming()); } private boolean vehicleCanSprint(Entity p_265184_) { -@@ -1169,6 +_,17 @@ +@@ -1158,6 +_,17 @@ @Override public float getVisualRotationYInDegrees() { return this.getYRot(); diff --git a/patches/minecraft/net/minecraft/client/renderer/GameRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/GameRenderer.java.patch index aae10ebe77..2755a0ce6a 100644 --- a/patches/minecraft/net/minecraft/client/renderer/GameRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/GameRenderer.java.patch @@ -1,17 +1,16 @@ --- a/net/minecraft/client/renderer/GameRenderer.java +++ b/net/minecraft/client/renderer/GameRenderer.java -@@ -194,6 +_,10 @@ - this.setPostEffect(ResourceLocation.withDefaultNamespace("spider")); - } else if (p_109107_ instanceof EnderMan) { - this.setPostEffect(ResourceLocation.withDefaultNamespace("invert")); -+ } else if (p_109107_ != null) { -+ var rl = net.minecraftforge.client.EntitySpectatorShaderManager.get(p_109107_.getType()); -+ if (rl != null) -+ this.setPostEffect(rl); +@@ -233,6 +_,9 @@ + case null: + default: + this.clearPostEffect(); ++ var rl = p_109107_ == null ? null : net.minecraftforge.client.EntitySpectatorShaderManager.get(p_109107_.getType()); ++ if (rl != null) ++ this.setPostEffect(rl); } } -@@ -205,7 +_,13 @@ +@@ -244,7 +_,13 @@ public void processBlurEffect() { PostChain postchain = this.minecraft.getShaderManager().getPostChain(BLUR_POST_CHAIN_ID, LevelTargetBundle.MAIN_TARGETS); if (postchain != null) { @@ -25,7 +24,7 @@ } } -@@ -364,7 +_,7 @@ +@@ -406,7 +_,7 @@ f *= Mth.lerp(f2, 1.0F, 0.85714287F); } @@ -34,22 +33,33 @@ } } -@@ -512,7 +_,7 @@ +@@ -557,7 +_,7 @@ } } else if (flag && this.minecraft.screen != null) { try { -- this.minecraft.screen.renderWithTooltip(guigraphics, i, j, p_343467_.getGameTimeDeltaTicks()); +- this.minecraft.screen.renderWithTooltipAndSubtitles(guigraphics, i, j, p_343467_.getGameTimeDeltaTicks()); + net.minecraftforge.client.ForgeHooksClient.drawScreen(this.minecraft.screen, guigraphics, i, j, p_343467_.getRealtimeDeltaTicks()); } catch (Throwable throwable1) { CrashReport crashreport1 = CrashReport.forThrowable(throwable1, "Rendering screen"); CrashReportCategory crashreportcategory1 = crashreport1.addCategory("Screen render details"); -@@ -646,6 +_,9 @@ +@@ -672,6 +_,10 @@ + BlockInWorld blockinworld = new BlockInWorld(this.minecraft.level, blockpos, false); + Registry registry = this.minecraft.level.registryAccess().lookupOrThrow(Registries.BLOCK); + flag = !itemstack.isEmpty() && (itemstack.canBreakBlockInAdventureMode(blockinworld) || itemstack.canPlaceOnBlockInAdventureMode(blockinworld)); ++ if (!flag && blockstate.hasBlockEntity()) { ++ var blockEntity = this.minecraft.level.getBlockEntity(blockpos); ++ flag = blockEntity != null && blockEntity.hasCustomOutlineRendering(); ++ } + } + } + } +@@ -706,6 +_,9 @@ if (this.minecraft.options.bobView().get()) { - this.bobView(posestack, camera.getPartialTickTime()); + this.bobView(posestack, this.mainCamera.getPartialTickTime()); } + -+ var cameraSetup = net.minecraftforge.client.event.ForgeEventFactoryClient.fireComputeCameraAngles(this, camera, f); -+ camera.setRotation(cameraSetup.getYaw(), cameraSetup.getPitch(), cameraSetup.getRoll()); ++ var cameraSetup = net.minecraftforge.client.event.ForgeEventFactoryClient.fireComputeCameraAngles(this, this.mainCamera, f); ++ this.mainCamera.setRotation(cameraSetup.getYaw(), cameraSetup.getPitch(), cameraSetup.getRoll()); matrix4f.mul(posestack.last().pose()); float f3 = this.minecraft.options.screenEffectScale().get().floatValue(); diff --git a/patches/minecraft/net/minecraft/client/renderer/ItemBlockRenderTypes.java.patch b/patches/minecraft/net/minecraft/client/renderer/ItemBlockRenderTypes.java.patch index 973cbe31e2..02da9e195d 100644 --- a/patches/minecraft/net/minecraft/client/renderer/ItemBlockRenderTypes.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/ItemBlockRenderTypes.java.patch @@ -5,12 +5,12 @@ @OnlyIn(Dist.CLIENT) public class ItemBlockRenderTypes { + @Deprecated - private static final Map TYPE_BY_BLOCK = Util.make(Maps.newHashMap(), p_389364_ -> { + private static final Map TYPE_BY_BLOCK = Util.make(Maps.newHashMap(), p_420870_ -> { ChunkSectionLayer chunksectionlayer = ChunkSectionLayer.TRIPWIRE; - p_389364_.put(Blocks.TRIPWIRE, chunksectionlayer); -@@ -353,12 +_,15 @@ - p_389364_.put(Blocks.BUBBLE_COLUMN, chunksectionlayer3); - p_389364_.put(Blocks.TINTED_GLASS, chunksectionlayer3); + p_420870_.put(Blocks.TRIPWIRE, chunksectionlayer); +@@ -357,12 +_,15 @@ + p_420870_.put(Blocks.BUBBLE_COLUMN, chunksectionlayer3); + p_420870_.put(Blocks.TINTED_GLASS, chunksectionlayer3); }); + @Deprecated private static final Map LAYER_BY_FLUID = Util.make(Maps.newHashMap(), p_404902_ -> { @@ -24,7 +24,7 @@ public static ChunkSectionLayer getChunkRenderType(BlockState p_109283_) { Block block = p_109283_.getBlock(); if (block instanceof LeavesBlock) { -@@ -369,6 +_,8 @@ +@@ -373,6 +_,8 @@ } } @@ -33,7 +33,7 @@ public static RenderType getMovingBlockRenderType(BlockState p_109294_) { Block block = p_109294_.getBlock(); if (block instanceof LeavesBlock) { -@@ -389,11 +_,14 @@ +@@ -393,11 +_,14 @@ } } @@ -48,7 +48,7 @@ public static RenderType getRenderType(ItemStack p_363859_) { if (p_363859_.getItem() instanceof BlockItem blockitem) { Block block = blockitem.getBlock(); -@@ -403,12 +_,71 @@ +@@ -407,12 +_,71 @@ } } diff --git a/patches/minecraft/net/minecraft/client/renderer/ItemInHandRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/ItemInHandRenderer.java.patch index 016515ca10..609abc9360 100644 --- a/patches/minecraft/net/minecraft/client/renderer/ItemInHandRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/ItemInHandRenderer.java.patch @@ -1,30 +1,30 @@ --- a/net/minecraft/client/renderer/ItemInHandRenderer.java +++ b/net/minecraft/client/renderer/ItemInHandRenderer.java -@@ -336,12 +_,14 @@ +@@ -328,12 +_,14 @@ if (iteminhandrenderer$handrenderselection.renderMainHand) { float f4 = interactionhand == InteractionHand.MAIN_HAND ? f : 0.0F; float f5 = 1.0F - Mth.lerp(p_109315_, this.oMainHandHeight, this.mainHandHeight); -+ if (!net.minecraftforge.client.ForgeHooksClient.renderSpecificFirstPersonHand(InteractionHand.MAIN_HAND, p_109316_, p_109317_, p_109319_, p_109315_, f1, f4, f5, this.mainHandItem)) - this.renderArmWithItem(p_109318_, p_109315_, f1, InteractionHand.MAIN_HAND, f4, this.mainHandItem, f5, p_109316_, p_109317_, p_109319_); ++ if (!net.minecraftforge.client.ForgeHooksClient.renderSpecificFirstPersonHand(InteractionHand.MAIN_HAND, p_109316_, p_424174_, p_109319_, p_109315_, f1, f4, f5, this.mainHandItem)) + this.renderArmWithItem(p_109318_, p_109315_, f1, InteractionHand.MAIN_HAND, f4, this.mainHandItem, f5, p_109316_, p_424174_, p_109319_); } if (iteminhandrenderer$handrenderselection.renderOffHand) { float f6 = interactionhand == InteractionHand.OFF_HAND ? f : 0.0F; float f7 = 1.0F - Mth.lerp(p_109315_, this.oOffHandHeight, this.offHandHeight); -+ if (!net.minecraftforge.client.ForgeHooksClient.renderSpecificFirstPersonHand(InteractionHand.OFF_HAND, p_109316_, p_109317_, p_109319_, p_109315_, f1, f6, f7, this.offHandItem)) - this.renderArmWithItem(p_109318_, p_109315_, f1, InteractionHand.OFF_HAND, f6, this.offHandItem, f7, p_109316_, p_109317_, p_109319_); ++ if (!net.minecraftforge.client.ForgeHooksClient.renderSpecificFirstPersonHand(InteractionHand.OFF_HAND, p_109316_, p_424174_, p_109319_, p_109315_, f1, f6, f7, this.offHandItem)) + this.renderArmWithItem(p_109318_, p_109315_, f1, InteractionHand.OFF_HAND, f6, this.offHandItem, f7, p_109316_, p_424174_, p_109319_); } -@@ -407,7 +_,7 @@ +@@ -400,7 +_,7 @@ } else { - this.renderOneHandedMap(p_109379_, p_109380_, p_109381_, p_109378_, humanoidarm, p_109376_, p_109377_); + this.renderOneHandedMap(p_109379_, p_425151_, p_109381_, p_109378_, humanoidarm, p_109376_, p_109377_); } - } else if (p_109377_.is(Items.CROSSBOW)) { + } else if (p_109377_.getItem() instanceof CrossbowItem) { boolean flag1 = CrossbowItem.isCharged(p_109377_); boolean flag2 = humanoidarm == HumanoidArm.RIGHT; int i = flag2 ? 1 : -1; -@@ -452,6 +_,7 @@ +@@ -445,6 +_,7 @@ } else { boolean flag3 = humanoidarm == HumanoidArm.RIGHT; int j = flag3 ? 1 : -1; @@ -32,7 +32,7 @@ if (p_109372_.isUsingItem() && p_109372_.getUseItemRemainingTicks() > 0 && p_109372_.getUsedItemHand() == p_109375_) { switch (p_109377_.getUseAnimation()) { case NONE: -@@ -579,8 +_,18 @@ +@@ -572,8 +_,18 @@ this.offHandHeight = Mth.clamp(this.offHandHeight - 0.4F, 0.0F, 1.0F); } else { float f = localplayer.getAttackStrengthScale(1.0F); diff --git a/patches/minecraft/net/minecraft/client/renderer/LevelRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/LevelRenderer.java.patch index 7dc9a5d23c..1da7501ee2 100644 --- a/patches/minecraft/net/minecraft/client/renderer/LevelRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/LevelRenderer.java.patch @@ -1,187 +1,95 @@ --- a/net/minecraft/client/renderer/LevelRenderer.java +++ b/net/minecraft/client/renderer/LevelRenderer.java -@@ -121,7 +_,7 @@ - private final SkyRenderer skyRenderer = new SkyRenderer(); - private final CloudRenderer cloudRenderer = new CloudRenderer(); - private final WorldBorderRenderer worldBorderRenderer = new WorldBorderRenderer(); -- private final WeatherEffectRenderer weatherEffectRenderer = new WeatherEffectRenderer(); -+ private WeatherEffectRenderer weatherEffectRenderer = new WeatherEffectRenderer(); - @Nullable - private ClientLevel level; - private final SectionOcclusionGraph sectionOcclusionGraph = new SectionOcclusionGraph(); -@@ -161,6 +_,7 @@ - this.entityRenderDispatcher = p_234246_; - this.blockEntityRenderDispatcher = p_234247_; - this.renderBuffers = p_234248_; +@@ -175,6 +_,7 @@ + this.submitNodeStorage = p_427160_.getSubmitNodeStorage(); + this.levelRenderState = p_429507_; + this.featureRenderDispatcher = p_427160_; + net.minecraftforge.client.event.ForgeEventFactoryClient.onInitLevelRenderer(); } - public void tickParticles(Camera p_369538_) { -@@ -480,7 +_,7 @@ - postchain1.addToFrame(framegraphbuilder, i, j, this.targets); + @Override +@@ -460,9 +_,10 @@ + profilerfiller.push("entities"); + this.extractVisibleEntities(p_109604_, frustum, p_342180_, this.levelRenderState); + profilerfiller.popPush("blockEntities"); +- this.extractVisibleBlockEntities(p_109604_, f, this.levelRenderState); ++ this.extractVisibleBlockEntities(p_109604_, f, this.levelRenderState, frustum); + profilerfiller.popPush("blockOutline"); +- this.extractBlockOutline(p_109604_, this.levelRenderState); ++ this.extractBlockOutline(p_109604_, this.levelRenderState, p_109603_); ++ p_109603_ = this.levelRenderState.blockOutlineRenderState != null; + profilerfiller.popPush("blockBreaking"); + this.extractBlockDestroyAnimation(p_109604_, this.levelRenderState); + profilerfiller.popPush("weather"); +@@ -534,6 +_,7 @@ } -- this.addParticlesPass(framegraphbuilder, p_109604_, f, p_407881_); -+ this.addParticlesPass(framegraphbuilder, p_109604_, f, p_407881_, frustum); - CloudStatus cloudstatus = this.minecraft.options.getCloudsType(); - if (cloudstatus != CloudStatus.OFF) { - Optional optional = this.level.dimensionType().cloudHeight(); -@@ -497,6 +_,7 @@ - } - - this.addLateDebugPass(framegraphbuilder, vec3, p_407881_); + this.addLateDebugPass(framegraphbuilder, this.levelRenderState.cameraRenderState.pos, p_407881_, frustum); + net.minecraftforge.client.FramePassManager.insertForgePasses(framegraphbuilder, targets); // Forge: Modded passes are inserted here. - profilerfiller.popPush("framegraph"); + profilerfiller.popPush("executeFrameGraph"); framegraphbuilder.execute(p_367325_, new FrameGraphBuilder.Inspector() { @Override -@@ -577,7 +_,7 @@ - multibuffersource$buffersource.endLastBatch(); - this.checkPoseStack(posestack); - p_369478_.popPush("blockentities"); -- this.renderBlockEntities(posestack, multibuffersource$buffersource, multibuffersource$buffersource1, p_364769_, f); -+ var renderOutline = this.renderBlockEntities(posestack, multibuffersource$buffersource, multibuffersource$buffersource1, p_364769_, f, p_363733_) || p_362593_; - multibuffersource$buffersource.endLastBatch(); - this.checkPoseStack(posestack); - multibuffersource$buffersource.endBatch(RenderType.solid()); -@@ -591,8 +_,8 @@ - multibuffersource$buffersource.endBatch(Sheets.hangingSignSheet()); - multibuffersource$buffersource.endBatch(Sheets.chestSheet()); - this.renderBuffers.outlineBufferSource().endOutlineBatch(); -- if (p_362593_) { -- this.renderBlockOutline(p_364769_, multibuffersource$buffersource, posestack, false); -+ if (renderOutline) { -+ this.renderBlockOutline(p_364769_, multibuffersource$buffersource, posestack, false, f); - } - - p_369478_.popPush("debug"); -@@ -620,8 +_,8 @@ - chunksectionstorender.renderGroup(ChunkSectionLayerGroup.TRANSLUCENT); - p_369478_.popPush("string"); - chunksectionstorender.renderGroup(ChunkSectionLayerGroup.TRIPWIRE); -- if (p_362593_) { -- this.renderBlockOutline(p_364769_, multibuffersource$buffersource, posestack, true); -+ if (renderOutline) { -+ this.renderBlockOutline(p_364769_, multibuffersource$buffersource, posestack, true, f); - } - - multibuffersource$buffersource.endBatch(); -@@ -629,7 +_,7 @@ - }); - } - -- private void addParticlesPass(FrameGraphBuilder p_366471_, Camera p_363128_, float p_365755_, GpuBufferSlice p_405857_) { -+ private void addParticlesPass(FrameGraphBuilder p_366471_, Camera p_363128_, float p_365755_, GpuBufferSlice p_405857_, Frustum frustum) { - FramePass framepass = p_366471_.addPass("particles"); - if (this.targets.particles != null) { - this.targets.particles = framepass.readsAndWrites(this.targets.particles); -@@ -646,7 +_,7 @@ - resourcehandle1.get().copyDepthFrom(resourcehandle.get()); - } - -- this.minecraft.particleEngine.render(p_363128_, p_365755_, this.renderBuffers.bufferSource()); -+ this.minecraft.particleEngine.render(p_363128_, p_365755_, this.renderBuffers.bufferSource(), frustum); - }); - } - -@@ -716,9 +_,9 @@ - || p_365712_.isDetached() - || p_365712_.getEntity() instanceof LivingEntity && ((LivingEntity)p_365712_.getEntity()).isSleeping() - ) -- && (!(entity instanceof LocalPlayer) || p_365712_.getEntity() == entity)) { -+ && (!(entity instanceof LocalPlayer) || p_365712_.getEntity() == entity || (entity == minecraft.player && !minecraft.player.isSpectator()))) { //FORGE: render local player entity when it is not the renderViewEntity - p_368622_.add(entity); -- if (flag1 && this.minecraft.shouldEntityAppearGlowing(entity)) { -+ if (flag1 && (this.minecraft.shouldEntityAppearGlowing(entity) || entity.hasCustomOutlineRendering(this.minecraft.player))) { - flag = true; - } - } -@@ -758,9 +_,10 @@ +@@ -801,7 +_,7 @@ } } -- private void renderBlockEntities( -- PoseStack p_366168_, MultiBufferSource.BufferSource p_362022_, MultiBufferSource.BufferSource p_369016_, Camera p_369847_, float p_367074_ -+ private boolean renderBlockEntities( -+ PoseStack p_366168_, MultiBufferSource.BufferSource p_362022_, MultiBufferSource.BufferSource p_369016_, Camera p_369847_, float p_367074_, Frustum frustum - ) { -+ boolean customOutline = false; - Vec3 vec3 = p_369847_.getPosition(); +- private void extractVisibleBlockEntities(Camera p_427254_, float p_426770_, LevelRenderState p_428920_) { ++ private void extractVisibleBlockEntities(Camera p_427254_, float p_426770_, LevelRenderState p_428920_, Frustum frustum) { + Vec3 vec3 = p_427254_.getPosition(); double d0 = vec3.x(); double d1 = vec3.y(); -@@ -770,6 +_,7 @@ +@@ -812,6 +_,7 @@ List list = sectionrenderdispatcher$rendersection.getSectionMesh().getRenderableBlockEntities(); if (!list.isEmpty()) { for (BlockEntity blockentity : list) { + if (!frustum.isVisible(blockentity.getRenderBoundingBox())) continue; BlockPos blockpos = blockentity.getBlockPos(); - MultiBufferSource multibuffersource = p_362022_; - p_366168_.pushPose(); -@@ -789,6 +_,9 @@ - } - } - -+ if (!customOutline && this.shouldShowEntityOutlines() && blockentity.hasCustomOutlineRendering(this.minecraft.player)) -+ customOutline = true; -+ - this.blockEntityRenderDispatcher.render(blockentity, p_367074_, p_366168_, multibuffersource); - p_366168_.popPose(); - } -@@ -802,13 +_,18 @@ + SortedSet sortedset = this.destructionProgress.get(blockpos.asLong()); + ModelFeatureRenderer.CrumblingOverlay modelfeaturerenderer$crumblingoverlay; +@@ -839,6 +_,7 @@ if (blockentity1.isRemoved()) { iterator.remove(); } else { + if (!frustum.isVisible(blockentity1.getRenderBoundingBox())) continue; - BlockPos blockpos1 = blockentity1.getBlockPos(); - p_366168_.pushPose(); - p_366168_.translate(blockpos1.getX() - d0, blockpos1.getY() - d1, blockpos1.getZ() - d2); -+ if (!customOutline && this.shouldShowEntityOutlines() && blockentity1.hasCustomOutlineRendering(this.minecraft.player)) -+ customOutline = true; - this.blockEntityRenderDispatcher.render(blockentity1, p_367074_, p_366168_, p_362022_); - p_366168_.popPose(); - } + BlockEntityRenderState blockentityrenderstate1 = this.blockEntityRenderDispatcher.tryExtractRenderState(blockentity1, p_426770_, null); + if (blockentityrenderstate1 != null) { + p_428920_.blockEntityRenderStates.add(blockentityrenderstate1); +@@ -895,13 +_,21 @@ + VertexConsumer vertexconsumer = new SheetedDecalTextureGenerator( + p_365998_.getBuffer(ModelBakery.DESTROY_TYPES.get(blockbreakingrenderstate.progress)), posestack$pose, 1.0F + ); +- this.minecraft.getBlockRenderer().renderBreakingTexture(blockbreakingrenderstate.blockState, blockpos, blockbreakingrenderstate, p_366956_, vertexconsumer); ++ this.minecraft.getBlockRenderer().renderBreakingTexture(blockbreakingrenderstate.blockState, blockpos, blockbreakingrenderstate, p_366956_, vertexconsumer, level.getModelDataManager().getAtOrEmpty(blockpos)); + p_366956_.popPose(); } + } + +- private void extractBlockOutline(Camera p_428965_, LevelRenderState p_424419_) { ++ private void extractBlockOutline(Camera p_428965_, LevelRenderState p_424419_, boolean shouldRender) { + p_424419_.blockOutlineRenderState = null; ++ var custom = net.minecraftforge.client.ForgeHooksClient.onExtractBlockOutline(this, p_428965_, p_424419_, this.minecraft.hitResult); ++ if (custom != null) { ++ p_424419_.blockOutlineRenderState = new BlockOutlineRenderState(BlockPos.ZERO, false, false, net.minecraft.world.phys.shapes.Shapes.empty(), null, null, null, custom); ++ return; ++ } else if (!shouldRender) { ++ return; ++ } + -+ return customOutline; - } - - private void renderBlockDestroyAnimation(PoseStack p_366956_, Camera p_369324_, MultiBufferSource.BufferSource p_365998_) { -@@ -827,14 +_,14 @@ - p_366956_.translate(blockpos.getX() - d0, blockpos.getY() - d1, blockpos.getZ() - d2); - PoseStack.Pose posestack$pose = p_366956_.last(); - VertexConsumer vertexconsumer = new SheetedDecalTextureGenerator(p_365998_.getBuffer(ModelBakery.DESTROY_TYPES.get(i)), posestack$pose, 1.0F); -- this.minecraft.getBlockRenderer().renderBreakingTexture(this.level.getBlockState(blockpos), blockpos, this.level, p_366956_, vertexconsumer); -+ this.minecraft.getBlockRenderer().renderBreakingTexture(this.level.getBlockState(blockpos), blockpos, this.level, p_366956_, vertexconsumer, level.getModelDataManager().getAtOrEmpty(blockpos)); - p_366956_.popPose(); - } - } - } - } - -- private void renderBlockOutline(Camera p_367935_, MultiBufferSource.BufferSource p_367206_, PoseStack p_365062_, boolean p_368189_) { -+ private void renderBlockOutline(Camera p_367935_, MultiBufferSource.BufferSource p_367206_, PoseStack p_365062_, boolean p_368189_, float partialTicks) { if (this.minecraft.hitResult instanceof BlockHitResult blockhitresult) { if (blockhitresult.getType() != HitResult.Type.MISS) { BlockPos blockpos = blockhitresult.getBlockPos(); -@@ -845,6 +_,9 @@ - return; - } - -+ if (net.minecraftforge.client.ForgeHooksClient.onDrawHighlight(this, p_367935_, blockhitresult, partialTicks, p_365062_, p_367206_)) -+ return; -+ - Vec3 vec3 = p_367935_.getPosition(); - Boolean obool = this.minecraft.options.highContrastBlockOutline().get(); - if (obool) { -@@ -860,6 +_,8 @@ - p_367206_.endLastBatch(); - } - } -+ } else if (this.minecraft.hitResult instanceof net.minecraft.world.phys.EntityHitResult entity) { -+ net.minecraftforge.client.ForgeHooksClient.onDrawHighlight(this, p_367935_, entity, partialTicks, p_365062_, p_367206_); - } - } - -@@ -1344,7 +_,7 @@ +@@ -927,6 +_,10 @@ + private void renderBlockOutline(MultiBufferSource.BufferSource p_367206_, PoseStack p_365062_, boolean p_368189_, LevelRenderState p_422597_) { + BlockOutlineRenderState blockoutlinerenderstate = p_422597_.blockOutlineRenderState; + if (blockoutlinerenderstate != null) { ++ if (blockoutlinerenderstate.customRenderer() != null) { ++ blockoutlinerenderstate.customRenderer().render(p_367206_, p_365062_, p_368189_, p_422597_); ++ return; ++ } + if (blockoutlinerenderstate.isTranslucent() == p_368189_) { + Vec3 vec3 = p_422597_.cameraRenderState.pos; + if (blockoutlinerenderstate.highContrast()) { +@@ -1356,7 +_,7 @@ } else { int i = p_398213_.packedBrightness(p_109538_, p_109540_); int j = LightTexture.block(i); @@ -190,16 +98,12 @@ if (j < k) { int l = LightTexture.sky(i); return LightTexture.pack(k, l); -@@ -1406,6 +_,22 @@ +@@ -1418,6 +_,18 @@ public CloudRenderer getCloudRenderer() { return this.cloudRenderer; + } + -+ public Frustum getFrustum() { -+ return this.capturedFrustum != null ? this.capturedFrustum : this.cullingFrustum; -+ } -+ + public int getTicks() { + return this.ticks; + } diff --git a/patches/minecraft/net/minecraft/client/renderer/LightTexture.java.patch b/patches/minecraft/net/minecraft/client/renderer/LightTexture.java.patch index c74d3334bd..e75daea9c8 100644 --- a/patches/minecraft/net/minecraft/client/renderer/LightTexture.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/LightTexture.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/renderer/LightTexture.java +++ b/net/minecraft/client/renderer/LightTexture.java -@@ -171,7 +_,7 @@ +@@ -189,7 +_,7 @@ } public static int block(int p_109884_) { diff --git a/patches/minecraft/net/minecraft/client/renderer/RenderType.java.patch b/patches/minecraft/net/minecraft/client/renderer/RenderType.java.patch index 5e8d3b6a3d..4ecb04f181 100644 --- a/patches/minecraft/net/minecraft/client/renderer/RenderType.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/RenderType.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/renderer/RenderType.java +++ b/net/minecraft/client/renderer/RenderType.java -@@ -521,6 +_,11 @@ +@@ -485,6 +_,11 @@ private final int bufferSize; private final boolean affectsCrumbling; private final boolean sortOnUpload; @@ -12,7 +12,7 @@ public static RenderType solid() { return SOLID; -@@ -701,7 +_,7 @@ +@@ -665,7 +_,7 @@ } public static RenderType text(ResourceLocation p_110498_) { @@ -21,7 +21,7 @@ } public static RenderType textBackground() { -@@ -709,19 +_,19 @@ +@@ -673,19 +_,19 @@ } public static RenderType textIntensity(ResourceLocation p_173238_) { @@ -45,7 +45,7 @@ } public static RenderType textBackgroundSeeThrough() { -@@ -729,7 +_,7 @@ +@@ -693,7 +_,7 @@ } public static RenderType textIntensitySeeThrough(ResourceLocation p_173241_) { diff --git a/patches/minecraft/net/minecraft/client/renderer/ScreenEffectRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/ScreenEffectRenderer.java.patch index bd971ff8f8..4d6bdb08f4 100644 --- a/patches/minecraft/net/minecraft/client/renderer/ScreenEffectRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/ScreenEffectRenderer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/renderer/ScreenEffectRenderer.java +++ b/net/minecraft/client/renderer/ScreenEffectRenderer.java -@@ -55,18 +_,24 @@ +@@ -59,19 +_,25 @@ Player player = this.minecraft.player; if (this.minecraft.options.getCameraType().isFirstPerson() && !p_409640_) { if (!player.noPhysics) { @@ -22,11 +22,12 @@ } if (this.minecraft.player.isOnFire()) { + TextureAtlasSprite textureatlassprite = this.materials.get(ModelBakery.FIRE_1); + if (!net.minecraftforge.client.ForgeHooksClient.renderFireOverlay(player, posestack)) - renderFire(posestack, this.bufferSource); + renderFire(posestack, this.bufferSource, textureatlassprite); } } -@@ -116,6 +_,12 @@ +@@ -121,6 +_,12 @@ @Nullable private static BlockState getViewBlockingState(Player p_110717_) { @@ -39,7 +40,7 @@ BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(); for (int i = 0; i < 8; i++) { -@@ -125,7 +_,7 @@ +@@ -130,7 +_,7 @@ blockpos$mutableblockpos.set(d0, d1, d2); BlockState blockstate = p_110717_.level().getBlockState(blockpos$mutableblockpos); if (blockstate.getRenderShape() != RenderShape.INVISIBLE && blockstate.isViewBlocking(p_110717_.level(), blockpos$mutableblockpos)) { @@ -48,7 +49,7 @@ } } -@@ -153,6 +_,10 @@ +@@ -158,6 +_,10 @@ } private static void renderWater(Minecraft p_110726_, PoseStack p_110727_, MultiBufferSource p_376402_) { @@ -59,7 +60,7 @@ BlockPos blockpos = BlockPos.containing(p_110726_.player.getX(), p_110726_.player.getEyeY(), p_110726_.player.getZ()); float f = LightTexture.getBrightness(p_110726_.player.level().dimensionType(), p_110726_.player.level().getMaxLocalRawBrightness(blockpos)); int i = ARGB.colorFromFloat(0.1F, f, f, f); -@@ -165,7 +_,7 @@ +@@ -170,7 +_,7 @@ float f7 = -p_110726_.player.getYRot() / 64.0F; float f8 = p_110726_.player.getXRot() / 64.0F; Matrix4f matrix4f = p_110727_.last().pose(); diff --git a/patches/minecraft/net/minecraft/client/renderer/Sheets.java.patch b/patches/minecraft/net/minecraft/client/renderer/Sheets.java.patch index f6d7a7b6f6..51b14fc932 100644 --- a/patches/minecraft/net/minecraft/client/renderer/Sheets.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/Sheets.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/renderer/Sheets.java +++ b/net/minecraft/client/renderer/Sheets.java -@@ -157,11 +_,11 @@ +@@ -171,11 +_,11 @@ } private static Material createSignMaterial(WoodType p_173386_) { @@ -14,7 +14,7 @@ } public static Material getSignMaterial(WoodType p_173382_) { -@@ -206,6 +_,23 @@ +@@ -221,6 +_,23 @@ case SINGLE: default: return p_110773_; diff --git a/patches/minecraft/net/minecraft/client/renderer/block/BlockRenderDispatcher.java.patch b/patches/minecraft/net/minecraft/client/renderer/block/BlockRenderDispatcher.java.patch index 64177d30b2..1fe87c0feb 100644 --- a/patches/minecraft/net/minecraft/client/renderer/block/BlockRenderDispatcher.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/block/BlockRenderDispatcher.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/renderer/block/BlockRenderDispatcher.java +++ b/net/minecraft/client/renderer/block/BlockRenderDispatcher.java -@@ -49,12 +_,17 @@ +@@ -51,12 +_,17 @@ return this.blockModelShaper; } @@ -19,7 +19,7 @@ this.modelRenderer.tesselateBlock(p_110921_, this.singleThreadPartList, p_110919_, p_110920_, p_110922_, p_110923_, true, OverlayTexture.NO_OVERLAY); } } -@@ -97,7 +_,12 @@ +@@ -99,7 +_,12 @@ return this.blockModelShaper.getBlockModel(p_110911_); } @@ -32,7 +32,7 @@ RenderShape rendershape = p_110913_.getRenderShape(); if (rendershape != RenderShape.INVISIBLE) { BlockStateModel blockstatemodel = this.getBlockModel(p_110913_); -@@ -105,8 +_,9 @@ +@@ -107,8 +_,9 @@ float f = (i >> 16 & 0xFF) / 255.0F; float f1 = (i >> 8 & 0xFF) / 255.0F; float f2 = (i & 0xFF) / 255.0F; @@ -41,5 +41,5 @@ - p_110914_.last(), p_110915_.getBuffer(ItemBlockRenderTypes.getRenderType(p_110913_)), blockstatemodel, f, f1, f2, p_110916_, p_110917_ + p_110914_.last(), p_110915_.getBuffer(renderType != null ? renderType : net.minecraftforge.client.RenderTypeHelper.getEntityRenderType(rt)), blockstatemodel, f, f1, f2, p_110916_, p_110917_, modelData, rt ); - this.specialBlockModelRenderer.get().renderByBlock(p_110913_.getBlock(), ItemDisplayContext.NONE, p_110914_, p_110915_, p_110916_, p_110917_); } + } diff --git a/patches/minecraft/net/minecraft/client/renderer/block/model/ItemTransforms.java.patch b/patches/minecraft/net/minecraft/client/renderer/block/model/ItemTransforms.java.patch index 94d09650c9..fdce149e72 100644 --- a/patches/minecraft/net/minecraft/client/renderer/block/model/ItemTransforms.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/block/model/ItemTransforms.java.patch @@ -1,35 +1,35 @@ --- a/net/minecraft/client/renderer/block/model/ItemTransforms.java +++ b/net/minecraft/client/renderer/block/model/ItemTransforms.java -@@ -19,8 +_,15 @@ - ItemTransform head, +@@ -20,8 +_,15 @@ ItemTransform gui, ItemTransform ground, -- ItemTransform fixed -+ ItemTransform fixed, + ItemTransform fixed, +- ItemTransform fixedFromBottom ++ ItemTransform fixedFromBottom, + com.google.common.collect.ImmutableMap moddedTransforms ) { + + @Deprecated -+ public ItemTransforms(ItemTransform thirdPersonLeftHand, ItemTransform thirdPersonRightHand, ItemTransform firstPersonLeftHand, ItemTransform firstPersonRightHand, ItemTransform head, ItemTransform gui, ItemTransform ground, ItemTransform fixed) { -+ this(thirdPersonLeftHand, thirdPersonRightHand, firstPersonLeftHand, firstPersonRightHand, head, gui, ground, fixed, com.google.common.collect.ImmutableMap.of()); ++ public ItemTransforms(ItemTransform thirdPersonLeftHand, ItemTransform thirdPersonRightHand, ItemTransform firstPersonLeftHand, ItemTransform firstPersonRightHand, ItemTransform head, ItemTransform gui, ItemTransform ground, ItemTransform fixed, ItemTransform fixedFromBottom) { ++ this(thirdPersonLeftHand, thirdPersonRightHand, firstPersonLeftHand, firstPersonRightHand, head, gui, ground, fixed, fixedFromBottom, com.google.common.collect.ImmutableMap.of()); + } + public static final ItemTransforms NO_TRANSFORMS = new ItemTransforms( ItemTransform.NO_TRANSFORM, ItemTransform.NO_TRANSFORM, -@@ -42,7 +_,7 @@ - case GUI -> this.gui; +@@ -45,7 +_,7 @@ case GROUND -> this.ground; case FIXED -> this.fixed; + case ON_SHELF -> this.fixedFromBottom; - default -> ItemTransform.NO_TRANSFORM; + default -> moddedTransforms.getOrDefault(p_270619_, ItemTransform.NO_TRANSFORM); }; } -@@ -66,8 +_,22 @@ - ItemTransform itemtransform5 = this.getTransform(p_111822_, jsonobject, ItemDisplayContext.GUI); +@@ -70,8 +_,22 @@ ItemTransform itemtransform6 = this.getTransform(p_111822_, jsonobject, ItemDisplayContext.GROUND); ItemTransform itemtransform7 = this.getTransform(p_111822_, jsonobject, ItemDisplayContext.FIXED); + ItemTransform itemtransform8 = this.getTransform(p_111822_, jsonobject, ItemDisplayContext.ON_SHELF); + var builder = com.google.common.collect.ImmutableMap.builder(); + for (ItemDisplayContext type : ItemDisplayContext.values()) { + if (type.isModded()) { @@ -45,8 +45,8 @@ + } + return new ItemTransforms( -- itemtransform1, itemtransform, itemtransform3, itemtransform2, itemtransform4, itemtransform5, itemtransform6, itemtransform7 -+ itemtransform1, itemtransform, itemtransform3, itemtransform2, itemtransform4, itemtransform5, itemtransform6, itemtransform7, builder.build() +- itemtransform1, itemtransform, itemtransform3, itemtransform2, itemtransform4, itemtransform5, itemtransform6, itemtransform7, itemtransform8 ++ itemtransform1, itemtransform, itemtransform3, itemtransform2, itemtransform4, itemtransform5, itemtransform6, itemtransform7, itemtransform8, builder.build() ); } diff --git a/patches/minecraft/net/minecraft/client/renderer/blockentity/BlockEntityRenderers.java.patch b/patches/minecraft/net/minecraft/client/renderer/blockentity/BlockEntityRenderers.java.patch index a7aa026710..ab526d9673 100644 --- a/patches/minecraft/net/minecraft/client/renderer/blockentity/BlockEntityRenderers.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/blockentity/BlockEntityRenderers.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/client/renderer/blockentity/BlockEntityRenderers.java +++ b/net/minecraft/client/renderer/blockentity/BlockEntityRenderers.java -@@ -12,7 +_,7 @@ +@@ -13,7 +_,7 @@ @OnlyIn(Dist.CLIENT) public class BlockEntityRenderers { -- private static final Map, BlockEntityRendererProvider> PROVIDERS = Maps.newHashMap(); -+ private static final Map, BlockEntityRendererProvider> PROVIDERS = new java.util.concurrent.ConcurrentHashMap<>(); +- private static final Map, BlockEntityRendererProvider> PROVIDERS = Maps.newHashMap(); ++ private static final Map, BlockEntityRendererProvider> PROVIDERS = new java.util.concurrent.ConcurrentHashMap<>(); - public static void register(BlockEntityType p_173591_, BlockEntityRendererProvider p_173592_) { - PROVIDERS.put(p_173591_, p_173592_); + public static void register( + BlockEntityType p_173591_, BlockEntityRendererProvider p_173592_ diff --git a/patches/minecraft/net/minecraft/client/renderer/blockentity/ChestRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/blockentity/ChestRenderer.java.patch deleted file mode 100644 index 39227c83c1..0000000000 --- a/patches/minecraft/net/minecraft/client/renderer/blockentity/ChestRenderer.java.patch +++ /dev/null @@ -1,21 +0,0 @@ ---- a/net/minecraft/client/renderer/blockentity/ChestRenderer.java -+++ b/net/minecraft/client/renderer/blockentity/ChestRenderer.java -@@ -67,7 +_,7 @@ - f1 = 1.0F - f1; - f1 = 1.0F - f1 * f1 * f1; - int i = neighborcombineresult.apply(new BrightnessCombiner<>()).applyAsInt(p_112367_); -- Material material = Sheets.chooseMaterial(p_112363_, chesttype, this.xmasTextures); -+ Material material = this.getMaterial(p_112363_, chesttype); - VertexConsumer vertexconsumer = material.buffer(p_112366_, RenderType::entityCutout); - if (flag1) { - if (chesttype == ChestType.LEFT) { -@@ -86,5 +_,9 @@ - private void render(PoseStack p_112370_, VertexConsumer p_112371_, ChestModel p_363333_, float p_112375_, int p_112376_, int p_112377_) { - p_363333_.setupAnim(p_112375_); - p_363333_.renderToBuffer(p_112370_, p_112371_, p_112376_, p_112377_); -+ } -+ -+ protected Material getMaterial(T blockEntity, ChestType chestType) { -+ return Sheets.chooseMaterial(blockEntity, chestType, this.xmasTextures); - } - } diff --git a/patches/minecraft/net/minecraft/client/renderer/blockentity/PistonHeadRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/blockentity/PistonHeadRenderer.java.patch deleted file mode 100644 index f151d43ac6..0000000000 --- a/patches/minecraft/net/minecraft/client/renderer/blockentity/PistonHeadRenderer.java.patch +++ /dev/null @@ -1,21 +0,0 @@ ---- a/net/minecraft/client/renderer/blockentity/PistonHeadRenderer.java -+++ b/net/minecraft/client/renderer/blockentity/PistonHeadRenderer.java -@@ -70,10 +_,15 @@ - private void renderBlock( - BlockPos p_112459_, BlockState p_112460_, PoseStack p_112461_, MultiBufferSource p_112462_, Level p_112463_, boolean p_112464_, int p_112465_ - ) { -- RenderType rendertype = ItemBlockRenderTypes.getMovingBlockRenderType(p_112460_); -- VertexConsumer vertexconsumer = p_112462_.getBuffer(rendertype); -- List list = this.blockRenderer.getBlockModel(p_112460_).collectParts(RandomSource.create(p_112460_.getSeed(p_112459_))); -+ var model = this.blockRenderer.getBlockModel(p_112460_); -+ var rand = RandomSource.create(p_112460_.getSeed(p_112459_)); -+ var data = net.minecraftforge.client.model.data.ModelData.EMPTY; -+ for (var rendertype : model.getRenderTypes(p_112460_, rand, data)) { -+ rand = RandomSource.create(p_112460_.getSeed(p_112459_)); // Reset rand to keep -+ VertexConsumer vertexconsumer = p_112462_.getBuffer(net.minecraftforge.client.RenderTypeHelper.getMovingBlockRenderType(rendertype)); -+ List list = model.collectParts(rand, data, rendertype); - this.blockRenderer.getModelRenderer().tesselateBlock(p_112463_, list, p_112460_, p_112459_, p_112461_, vertexconsumer, p_112464_, p_112465_); -+ } - } - - @Override diff --git a/patches/minecraft/net/minecraft/client/renderer/blockentity/SkullBlockRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/blockentity/SkullBlockRenderer.java.patch index 895a416d39..ae9cf16c1e 100644 --- a/patches/minecraft/net/minecraft/client/renderer/blockentity/SkullBlockRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/blockentity/SkullBlockRenderer.java.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/client/renderer/blockentity/SkullBlockRenderer.java +++ b/net/minecraft/client/renderer/blockentity/SkullBlockRenderer.java -@@ -34,6 +_,7 @@ +@@ -36,6 +_,7 @@ @OnlyIn(Dist.CLIENT) - public class SkullBlockRenderer implements BlockEntityRenderer { + public class SkullBlockRenderer implements BlockEntityRenderer { + private static Map> customModels; private final Function modelByType; public static final Map SKIN_BY_TYPE = Util.make(Maps.newHashMap(), p_340906_ -> { p_340906_.put(SkullBlock.Types.SKELETON, ResourceLocation.withDefaultNamespace("textures/entity/skeleton/skeleton.png")); -@@ -58,7 +_,9 @@ +@@ -61,7 +_,9 @@ case PIGLIN -> new PiglinHeadModel(p_376421_.bakeLayer(ModelLayers.PIGLIN_HEAD)); }); } else { diff --git a/patches/minecraft/net/minecraft/client/renderer/culling/Frustum.java.patch b/patches/minecraft/net/minecraft/client/renderer/culling/Frustum.java.patch index 6ef8b31af8..56c8e797d6 100644 --- a/patches/minecraft/net/minecraft/client/renderer/culling/Frustum.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/culling/Frustum.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/renderer/culling/Frustum.java +++ b/net/minecraft/client/renderer/culling/Frustum.java -@@ -71,6 +_,8 @@ +@@ -78,6 +_,8 @@ } public boolean isVisible(AABB p_113030_) { diff --git a/patches/minecraft/net/minecraft/client/renderer/entity/EnderDragonRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/entity/EnderDragonRenderer.java.patch index ab17b9a353..05b0a87312 100644 --- a/patches/minecraft/net/minecraft/client/renderer/entity/EnderDragonRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/entity/EnderDragonRenderer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/renderer/entity/EnderDragonRenderer.java +++ b/net/minecraft/client/renderer/entity/EnderDragonRenderer.java -@@ -225,11 +_,15 @@ +@@ -238,11 +_,15 @@ protected void extractAdditionalHitboxes(EnderDragon p_394570_, Builder p_396096_, float p_397646_) { super.extractAdditionalHitboxes(p_394570_, p_396096_, p_397646_); diff --git a/patches/minecraft/net/minecraft/client/renderer/entity/EntityRenderDispatcher.java.patch b/patches/minecraft/net/minecraft/client/renderer/entity/EntityRenderDispatcher.java.patch index 2fc2896391..1afd97cb71 100644 --- a/patches/minecraft/net/minecraft/client/renderer/entity/EntityRenderDispatcher.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/entity/EntityRenderDispatcher.java.patch @@ -1,20 +1,24 @@ --- a/net/minecraft/client/renderer/entity/EntityRenderDispatcher.java +++ b/net/minecraft/client/renderer/entity/EntityRenderDispatcher.java -@@ -492,6 +_,10 @@ +@@ -207,6 +_,14 @@ return this.itemInHandRenderer; } -+ public Map> getSkinMap() { ++ public Map> getPlayerRenderers() { + return java.util.Collections.unmodifiableMap(playerRenderers); + } ++ ++ public Map> getMannequinRenderers() { ++ return java.util.Collections.unmodifiableMap(mannequinRenderers); ++ } + @Override public void onResourceManagerReload(ResourceManager p_174004_) { EntityRendererProvider.Context entityrendererprovider$context = new EntityRendererProvider.Context( -@@ -499,5 +_,6 @@ - ); +@@ -224,5 +_,6 @@ this.renderers = EntityRenderers.createEntityRenderers(entityrendererprovider$context); - this.playerRenderers = EntityRenderers.createPlayerRenderers(entityrendererprovider$context); -+ net.minecraftforge.client.event.ForgeEventFactoryClient.onGatherLayers(renderers, playerRenderers, entityrendererprovider$context); + this.playerRenderers = EntityRenderers.createAvatarRenderers(entityrendererprovider$context); + this.mannequinRenderers = EntityRenderers.createAvatarRenderers(entityrendererprovider$context); ++ net.minecraftforge.client.event.ForgeEventFactoryClient.onGatherLayers(renderers, playerRenderers, mannequinRenderers, entityrendererprovider$context); } } diff --git a/patches/minecraft/net/minecraft/client/renderer/entity/EntityRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/entity/EntityRenderer.java.patch index 93f2945054..7a736d30e8 100644 --- a/patches/minecraft/net/minecraft/client/renderer/entity/EntityRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/entity/EntityRenderer.java.patch @@ -1,27 +1,28 @@ --- a/net/minecraft/client/renderer/entity/EntityRenderer.java +++ b/net/minecraft/client/renderer/entity/EntityRenderer.java -@@ -113,8 +_,9 @@ - } - } - -- if (p_370221_.nameTag != null) { -- this.renderNameTag(p_370221_, p_370221_.nameTag, p_114488_, p_114489_, p_114490_); -+ var event = net.minecraftforge.client.event.ForgeEventFactoryClient.fireRenderNameTagEvent(p_370221_, p_370221_.nameTag, this, p_114488_, p_114489_, p_114490_); -+ if (!event.getResult().isDenied() && (event.getResult().isAllowed() || p_370221_.nameTag != null)) { -+ this.renderNameTag(p_370221_, event.getContent(), p_114488_, p_114489_, p_114490_); - } +@@ -131,9 +_,10 @@ } -@@ -252,7 +_,7 @@ + protected void submitNameTag(S p_429896_, PoseStack p_428845_, SubmitNodeCollector p_426439_, CameraRenderState p_428408_) { +- if (p_429896_.nameTag != null) { ++ var event = net.minecraftforge.client.event.ForgeEventFactoryClient.fireRenderNameTagEvent(p_429896_, p_429896_.nameTag, this, p_428845_, p_426439_, p_428408_); ++ if (!event.getResult().isDenied() && (event.getResult().isAllowed() || p_429896_.nameTag != null)) { + p_426439_.submitNameTag( +- p_428845_, p_429896_.nameTagAttachment, 0, p_429896_.nameTag, !p_429896_.isDiscrete, p_429896_.lightCoords, p_429896_.distanceToCameraSq, p_428408_ ++ p_428845_, p_429896_.nameTagAttachment, 0, event.getContent(), !p_429896_.isDiscrete, p_429896_.lightCoords, p_429896_.distanceToCameraSq, p_428408_ + ); } + } +@@ -184,7 +_,7 @@ - p_367427_.distanceToCameraSq = this.entityRenderDispatcher.distanceToSqr(p_367571_); -- boolean flag1 = p_367427_.distanceToCameraSq < 4096.0 && this.shouldShowName(p_367571_, p_367427_.distanceToCameraSq); -+ boolean flag1 = net.minecraftforge.client.ForgeHooksClient.isNameplateInRenderDistance(p_367571_, p_367427_.distanceToCameraSq) && this.shouldShowName(p_367571_, p_367427_.distanceToCameraSq); - if (flag1) { - p_367427_.nameTag = this.getNameTag(p_367571_); - p_367427_.nameTagAttachment = p_367571_.getAttachments().getNullable(EntityAttachment.NAME_TAG, 0, p_367571_.getYRot(p_363243_)); -@@ -387,6 +_,7 @@ + if (this.entityRenderDispatcher.camera != null) { + p_367427_.distanceToCameraSq = this.entityRenderDispatcher.distanceToSqr(p_367571_); +- boolean flag1 = p_367427_.distanceToCameraSq < 4096.0 && this.shouldShowName(p_367571_, p_367427_.distanceToCameraSq); ++ boolean flag1 = net.minecraftforge.client.ForgeHooksClient.isNameplateInRenderDistance(p_367571_, p_367427_.distanceToCameraSq) && this.shouldShowName(p_367571_, p_367427_.distanceToCameraSq); + if (flag1) { + p_367427_.nameTag = this.getNameTag(p_367571_); + p_367427_.nameTagAttachment = p_367571_.getAttachments().getNullable(EntityAttachment.NAME_TAG, 0, p_367571_.getYRot(p_363243_)); +@@ -408,6 +_,7 @@ } protected void extractAdditionalHitboxes(T p_392955_, Builder p_395671_, float p_395030_) { diff --git a/patches/minecraft/net/minecraft/client/renderer/entity/ItemFrameRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/entity/ItemFrameRenderer.java.patch index 059c92d64c..6d263bb72f 100644 --- a/patches/minecraft/net/minecraft/client/renderer/entity/ItemFrameRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/entity/ItemFrameRenderer.java.patch @@ -1,18 +1,18 @@ --- a/net/minecraft/client/renderer/entity/ItemFrameRenderer.java +++ b/net/minecraft/client/renderer/entity/ItemFrameRenderer.java -@@ -94,6 +_,7 @@ - if (p_361692_.mapId != null) { - int j = p_361692_.rotation % 4 * 2; - p_115061_.mulPose(Axis.ZP.rotationDegrees(j * 360.0F / 8.0F)); -+ if (!net.minecraftforge.client.event.ForgeEventFactoryClient.onRenderItemInFrame(p_361692_, this, p_115061_, p_115062_, p_115063_)) { - p_115061_.mulPose(Axis.ZP.rotationDegrees(180.0F)); +@@ -95,6 +_,7 @@ + if (p_430553_.mapId != null) { + int j = p_430553_.rotation % 4 * 2; + p_431616_.mulPose(Axis.ZP.rotationDegrees(j * 360.0F / 8.0F)); ++ if (!net.minecraftforge.client.event.ForgeEventFactoryClient.onRenderItemInFrame(p_430553_, this, p_431616_, p_423714_, p_430553_.lightCoords)) { + p_431616_.mulPose(Axis.ZP.rotationDegrees(180.0F)); float f2 = 0.0078125F; - p_115061_.scale(0.0078125F, 0.0078125F, 0.0078125F); -@@ -101,6 +_,7 @@ - p_115061_.translate(0.0F, 0.0F, -1.0F); - int i = this.getLightCoords(p_361692_.isGlowFrame, 15728850, p_115063_); - this.mapRenderer.render(p_361692_.mapRenderState, p_115061_, p_115062_, true, i); + p_431616_.scale(0.0078125F, 0.0078125F, 0.0078125F); +@@ -102,6 +_,7 @@ + p_431616_.translate(0.0F, 0.0F, -1.0F); + int i = this.getLightCoords(p_430553_.isGlowFrame, 15728850, p_430553_.lightCoords); + this.mapRenderer.render(p_430553_.mapRenderState, p_431616_, p_423714_, true, i); + } - } else if (!p_361692_.item.isEmpty()) { - p_115061_.mulPose(Axis.ZP.rotationDegrees(p_361692_.rotation * 360.0F / 8.0F)); - int k = this.getLightCoords(p_361692_.isGlowFrame, 15728880, p_115063_); + } else if (!p_430553_.item.isEmpty()) { + p_431616_.mulPose(Axis.ZP.rotationDegrees(p_430553_.rotation * 360.0F / 8.0F)); + int k = this.getLightCoords(p_430553_.isGlowFrame, 15728880, p_430553_.lightCoords); diff --git a/patches/minecraft/net/minecraft/client/renderer/entity/ItemRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/entity/ItemRenderer.java.patch index dea6a8307b..fc6cccb768 100644 --- a/patches/minecraft/net/minecraft/client/renderer/entity/ItemRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/entity/ItemRenderer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/renderer/entity/ItemRenderer.java +++ b/net/minecraft/client/renderer/entity/ItemRenderer.java -@@ -116,7 +_,7 @@ +@@ -111,7 +_,7 @@ f3 = 1.0F; } @@ -8,4 +8,4 @@ + p_115164_.putBulkData(posestack$pose, bakedquad, f1, f2, f3, f, p_115167_, p_115168_, true); } } - + } diff --git a/patches/minecraft/net/minecraft/client/renderer/entity/LivingEntityRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/entity/LivingEntityRenderer.java.patch index 2eee9ca8cc..74f0203392 100644 --- a/patches/minecraft/net/minecraft/client/renderer/entity/LivingEntityRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/entity/LivingEntityRenderer.java.patch @@ -1,22 +1,22 @@ --- a/net/minecraft/client/renderer/entity/LivingEntityRenderer.java +++ b/net/minecraft/client/renderer/entity/LivingEntityRenderer.java -@@ -75,6 +_,7 @@ +@@ -73,6 +_,7 @@ } - public void render(S p_364280_, PoseStack p_115311_, MultiBufferSource p_115312_, int p_115313_) { -+ if (net.minecraftforge.client.event.ForgeEventFactoryClient.onRenderLivingPre(p_364280_, this, p_115311_, p_115312_, p_115313_)) return; - p_115311_.pushPose(); - if (p_364280_.hasPose(Pose.SLEEPING)) { - Direction direction = p_364280_.bedOrientation; -@@ -110,6 +_,7 @@ + public void submit(S p_427824_, PoseStack p_423787_, SubmitNodeCollector p_424901_, CameraRenderState p_422963_) { ++ if (net.minecraftforge.client.event.ForgeEventFactoryClient.onRenderLivingPre(p_427824_, this, p_423787_, p_424901_, p_422963_)) return; + p_423787_.pushPose(); + if (p_427824_.hasPose(Pose.SLEEPING)) { + Direction direction = p_427824_.bedOrientation; +@@ -108,6 +_,7 @@ - p_115311_.popPose(); - super.render(p_364280_, p_115311_, p_115312_, p_115313_); -+ net.minecraftforge.client.event.ForgeEventFactoryClient.onRenderLivingPost(p_364280_, this, p_115311_, p_115312_, p_115313_); + p_423787_.popPose(); + super.submit(p_427824_, p_423787_, p_424901_, p_422963_); ++ net.minecraftforge.client.event.ForgeEventFactoryClient.onRenderLivingPost(p_427824_, this, p_423787_, p_424901_, p_422963_); } protected boolean shouldRenderLayers(S p_360804_) { -@@ -291,6 +_,7 @@ +@@ -286,6 +_,7 @@ p_363057_.isFullyFrozen = p_368665_.isFullyFrozen(); p_363057_.isBaby = p_368665_.isBaby(); p_363057_.isInWater = p_368665_.isInWater(); @@ -24,7 +24,7 @@ p_363057_.isAutoSpinAttack = p_368665_.isAutoSpinAttack(); p_363057_.hasRedOverlay = p_368665_.hurtTime > 0 || p_368665_.deathTime > 0; ItemStack itemstack = p_368665_.getItemBySlot(EquipmentSlot.HEAD); -@@ -315,6 +_,7 @@ +@@ -309,6 +_,7 @@ } protected void extractAdditionalHitboxes(T p_392957_, Builder p_396936_, float p_397822_) { diff --git a/patches/minecraft/net/minecraft/client/renderer/entity/layers/HumanoidArmorLayer.java.patch b/patches/minecraft/net/minecraft/client/renderer/entity/layers/HumanoidArmorLayer.java.patch index c038c82521..4ed5219f12 100644 --- a/patches/minecraft/net/minecraft/client/renderer/entity/layers/HumanoidArmorLayer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/entity/layers/HumanoidArmorLayer.java.patch @@ -1,36 +1,23 @@ --- a/net/minecraft/client/renderer/entity/layers/HumanoidArmorLayer.java +++ b/net/minecraft/client/renderer/entity/layers/HumanoidArmorLayer.java -@@ -44,22 +_,23 @@ - } - - public void render(PoseStack p_117085_, MultiBufferSource p_117086_, int p_117087_, S p_364101_, float p_117089_, float p_117090_) { -- this.renderArmorPiece(p_117085_, p_117086_, p_364101_.chestEquipment, EquipmentSlot.CHEST, p_117087_, this.getArmorModel(p_364101_, EquipmentSlot.CHEST)); -- this.renderArmorPiece(p_117085_, p_117086_, p_364101_.legsEquipment, EquipmentSlot.LEGS, p_117087_, this.getArmorModel(p_364101_, EquipmentSlot.LEGS)); -- this.renderArmorPiece(p_117085_, p_117086_, p_364101_.feetEquipment, EquipmentSlot.FEET, p_117087_, this.getArmorModel(p_364101_, EquipmentSlot.FEET)); -- this.renderArmorPiece(p_117085_, p_117086_, p_364101_.headEquipment, EquipmentSlot.HEAD, p_117087_, this.getArmorModel(p_364101_, EquipmentSlot.HEAD)); -+ this.renderArmorPiece(p_117085_, p_117086_, p_364101_.chestEquipment, EquipmentSlot.CHEST, p_117087_, this.getArmorModel(p_364101_, EquipmentSlot.CHEST), p_364101_); -+ this.renderArmorPiece(p_117085_, p_117086_, p_364101_.legsEquipment, EquipmentSlot.LEGS, p_117087_, this.getArmorModel(p_364101_, EquipmentSlot.LEGS), p_364101_); -+ this.renderArmorPiece(p_117085_, p_117086_, p_364101_.feetEquipment, EquipmentSlot.FEET, p_117087_, this.getArmorModel(p_364101_, EquipmentSlot.FEET), p_364101_); -+ this.renderArmorPiece(p_117085_, p_117086_, p_364101_.headEquipment, EquipmentSlot.HEAD, p_117087_, this.getArmorModel(p_364101_, EquipmentSlot.HEAD), p_364101_); - } - -- private void renderArmorPiece(PoseStack p_117119_, MultiBufferSource p_117120_, ItemStack p_366444_, EquipmentSlot p_117122_, int p_117123_, A p_117124_) { -+ private void renderArmorPiece(PoseStack p_117119_, MultiBufferSource p_117120_, ItemStack p_366444_, EquipmentSlot p_117122_, int p_117123_, A p_117124_, S state) { +@@ -51,6 +_,7 @@ Equippable equippable = p_366444_.get(DataComponents.EQUIPPABLE); if (equippable != null && shouldRender(equippable, p_117122_)) { - this.getParentModel().copyPropertiesTo(p_117124_); - this.setPartVisibility(p_117124_, p_117122_); -+ var model = this.getArmorModel(state, p_117122_, p_366444_, p_117124_); + A a = this.getArmorModel(p_423438_, p_117122_); ++ var model = this.getArmorModel(p_423438_, p_117122_, p_366444_, a); EquipmentClientInfo.LayerType equipmentclientinfo$layertype = this.usesInnerModel(p_117122_) ? EquipmentClientInfo.LayerType.HUMANOID_LEGGINGS : EquipmentClientInfo.LayerType.HUMANOID; - this.equipmentRenderer -- .renderLayers(equipmentclientinfo$layertype, equippable.assetId().orElseThrow(), p_117124_, p_366444_, p_117119_, p_117120_, p_117123_); -+ .renderLayers(equipmentclientinfo$layertype, equippable.assetId().orElseThrow(), model, p_366444_, p_117119_, p_117120_, p_117123_); - } - } - -@@ -96,5 +_,12 @@ +@@ -58,7 +_,7 @@ + .renderLayers( + equipmentclientinfo$layertype, + equippable.assetId().orElseThrow(), +- a, ++ model, + p_423438_, + p_366444_, + p_117119_, +@@ -75,5 +_,12 @@ private boolean usesInnerModel(EquipmentSlot p_117129_) { return p_117129_ == EquipmentSlot.LEGS; diff --git a/patches/minecraft/net/minecraft/client/renderer/entity/layers/WingsLayer.java.patch b/patches/minecraft/net/minecraft/client/renderer/entity/layers/WingsLayer.java.patch index eca443d613..cf96a0200b 100644 --- a/patches/minecraft/net/minecraft/client/renderer/entity/layers/WingsLayer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/entity/layers/WingsLayer.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/client/renderer/entity/layers/WingsLayer.java +++ b/net/minecraft/client/renderer/entity/layers/WingsLayer.java -@@ -57,7 +_,7 @@ +@@ -59,7 +_,7 @@ } @Nullable - private static ResourceLocation getPlayerElytraTexture(HumanoidRenderState p_364125_) { + protected ResourceLocation getPlayerElytraTexture(HumanoidRenderState p_364125_) { - if (p_364125_ instanceof PlayerRenderState playerrenderstate) { - PlayerSkin playerskin = playerrenderstate.skin; - if (playerskin.elytraTexture() != null) { + if (p_364125_ instanceof AvatarRenderState avatarrenderstate) { + PlayerSkin playerskin = avatarrenderstate.skin; + if (playerskin.elytra() != null) { diff --git a/patches/minecraft/net/minecraft/client/renderer/entity/player/AvatarRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/entity/player/AvatarRenderer.java.patch new file mode 100644 index 0000000000..ba3663b2b1 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/renderer/entity/player/AvatarRenderer.java.patch @@ -0,0 +1,61 @@ +--- a/net/minecraft/client/renderer/entity/player/AvatarRenderer.java ++++ b/net/minecraft/client/renderer/entity/player/AvatarRenderer.java +@@ -92,7 +_,7 @@ + private static HumanoidModel.ArmPose getArmPose(Avatar p_422497_, ItemStack p_429700_, InteractionHand p_430481_) { + if (p_429700_.isEmpty()) { + return HumanoidModel.ArmPose.EMPTY; +- } else if (!p_422497_.swinging && p_429700_.is(Items.CROSSBOW) && CrossbowItem.isCharged(p_429700_)) { ++ } else if (!p_422497_.swinging && p_429700_.getItem() instanceof CrossbowItem && CrossbowItem.isCharged(p_429700_)) { + return HumanoidModel.ArmPose.CROSSBOW_HOLD; + } else { + if (p_422497_.getUsedItemHand() == p_430481_ && p_422497_.getUseItemRemainingTicks() > 0) { +@@ -126,6 +_,10 @@ + } + } + ++ var pose = net.minecraftforge.client.extensions.common.IClientItemExtensions.of(p_429700_).getArmPose(p_422497_, p_430481_, p_429700_); ++ if (pose != null) ++ return pose; ++ + return HumanoidModel.ArmPose.ITEM; + } + } +@@ -149,9 +_,10 @@ + p_423892_.translate(0.0F, 9.0F * 1.15F * 0.025F, 0.0F); + } + +- if (p_425306_.nameTag != null) { ++ var event = net.minecraftforge.client.event.ForgeEventFactoryClient.fireRenderNameTagEvent(p_425306_, p_425306_.nameTag, this, p_423892_, p_428344_, p_426061_); ++ if (!event.getResult().isDenied() && (event.getResult().isAllowed() || p_425306_.nameTag != null)) { + p_428344_.submitNameTag( +- p_423892_, p_425306_.nameTagAttachment, i, p_425306_.nameTag, !p_425306_.isDiscrete, p_425306_.lightCoords, p_425306_.distanceToCameraSq, p_426061_ ++ p_423892_, p_425306_.nameTagAttachment, i, event.getContent(), !p_425306_.isDiscrete, p_425306_.lightCoords, p_425306_.distanceToCameraSq, p_426061_ + ); + } + +@@ -239,10 +_,12 @@ + } + + public void renderRightHand(PoseStack p_428282_, SubmitNodeCollector p_424928_, int p_427204_, ResourceLocation p_423115_, boolean p_431039_) { ++ if (!net.minecraftforge.client.event.ForgeEventFactoryClient.onRenderArm(p_428282_, p_424928_, p_427204_, HumanoidArm.RIGHT)) + this.renderHand(p_428282_, p_424928_, p_427204_, p_423115_, this.model.rightArm, p_431039_); + } + + public void renderLeftHand(PoseStack p_424615_, SubmitNodeCollector p_425532_, int p_427068_, ResourceLocation p_425626_, boolean p_423290_) { ++ if (!net.minecraftforge.client.event.ForgeEventFactoryClient.onRenderArm(p_424615_, p_425532_, p_427068_, HumanoidArm.LEFT)) + this.renderHand(p_424615_, p_425532_, p_427068_, p_425626_, this.model.leftArm, p_423290_); + } + +@@ -295,5 +_,12 @@ + + public static boolean isPlayerUpsideDown(Player p_424650_) { + return isUpsideDownName(p_424650_.getGameProfile().name()); ++ } ++ ++ @Override ++ public void submit(AvatarRenderState state, PoseStack pose, SubmitNodeCollector source, CameraRenderState camera) { ++ if (net.minecraftforge.client.event.ForgeEventFactoryClient.onRenderAvatarPre(state, this, pose, source, camera)) return; ++ super.submit(state, pose, source, camera); ++ net.minecraftforge.client.event.ForgeEventFactoryClient.onRenderAvatarPost(state, this, pose, source, camera); + } + } diff --git a/patches/minecraft/net/minecraft/client/renderer/entity/player/PlayerRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/entity/player/PlayerRenderer.java.patch deleted file mode 100644 index 193f7fc697..0000000000 --- a/patches/minecraft/net/minecraft/client/renderer/entity/player/PlayerRenderer.java.patch +++ /dev/null @@ -1,48 +0,0 @@ ---- a/net/minecraft/client/renderer/entity/player/PlayerRenderer.java -+++ b/net/minecraft/client/renderer/entity/player/PlayerRenderer.java -@@ -98,7 +_,7 @@ - private static HumanoidModel.ArmPose getArmPose(Player p_376602_, ItemStack p_376446_, InteractionHand p_361073_) { - if (p_376446_.isEmpty()) { - return HumanoidModel.ArmPose.EMPTY; -- } else if (!p_376602_.swinging && p_376446_.is(Items.CROSSBOW) && CrossbowItem.isCharged(p_376446_)) { -+ } else if (!p_376602_.swinging && p_376446_.getItem() instanceof CrossbowItem && CrossbowItem.isCharged(p_376446_)) { - return HumanoidModel.ArmPose.CROSSBOW_HOLD; - } else { - if (p_376602_.getUsedItemHand() == p_361073_ && p_376602_.getUseItemRemainingTicks() > 0) { -@@ -132,6 +_,10 @@ - } - } - -+ var pose = net.minecraftforge.client.extensions.common.IClientItemExtensions.of(p_376446_).getArmPose(p_376602_, p_361073_, p_376446_); -+ if (pose != null) -+ return pose; -+ - return HumanoidModel.ArmPose.ITEM; - } - } -@@ -253,10 +_,12 @@ - } - - public void renderRightHand(PoseStack p_117771_, MultiBufferSource p_117772_, int p_117773_, ResourceLocation p_364347_, boolean p_367689_) { -+ if (!net.minecraftforge.client.event.ForgeEventFactoryClient.onRenderArm(p_117771_, p_117772_, p_117773_, HumanoidArm.RIGHT)) - this.renderHand(p_117771_, p_117772_, p_117773_, p_364347_, this.model.rightArm, p_367689_); - } - - public void renderLeftHand(PoseStack p_117814_, MultiBufferSource p_117815_, int p_117816_, ResourceLocation p_368419_, boolean p_362915_) { -+ if (!net.minecraftforge.client.event.ForgeEventFactoryClient.onRenderArm(p_117814_, p_117815_, p_117816_, HumanoidArm.LEFT)) - this.renderHand(p_117814_, p_117815_, p_117816_, p_368419_, this.model.leftArm, p_362915_); - } - -@@ -295,5 +_,12 @@ - } else { - super.setupRotations(p_369667_, p_117803_, p_117804_, p_117805_); - } -+ } -+ -+ @Override -+ public void render(PlayerRenderState state, PoseStack pose, MultiBufferSource source, int p_115313_) { -+ if (net.minecraftforge.client.event.ForgeEventFactoryClient.onRenderPlayerPre(state, this, pose, source, p_115313_)) return; -+ super.render(state, pose, source, p_115313_); -+ net.minecraftforge.client.event.ForgeEventFactoryClient.onRenderPlayerPost(state, this, pose, source, p_115313_); - } - } diff --git a/patches/minecraft/net/minecraft/client/renderer/special/SpecialModelRenderers.java.patch b/patches/minecraft/net/minecraft/client/renderer/special/SpecialModelRenderers.java.patch index 08d16bc5eb..ff3ba08284 100644 --- a/patches/minecraft/net/minecraft/client/renderer/special/SpecialModelRenderers.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/special/SpecialModelRenderers.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/client/renderer/special/SpecialModelRenderers.java +++ b/net/minecraft/client/renderer/special/SpecialModelRenderers.java -@@ -181,6 +_,8 @@ +@@ -199,6 +_,8 @@ map.put(Blocks.TRAPPED_CHEST, GIFT_CHEST); } + net.minecraftforge.client.event.ForgeEventFactoryClient.onCreateSpecialBlockRenderers(map); + Builder> builder = ImmutableMap.builder(); - map.forEach((p_377014_, p_376072_) -> { - SpecialModelRenderer specialmodelrenderer = p_376072_.bake(p_378538_); + map.forEach((p_421033_, p_421034_) -> { + SpecialModelRenderer specialmodelrenderer = p_421034_.bake(p_431302_); diff --git a/patches/minecraft/net/minecraft/client/renderer/state/BlockOutlineRenderState.java.patch b/patches/minecraft/net/minecraft/client/renderer/state/BlockOutlineRenderState.java.patch new file mode 100644 index 0000000000..1b68c74453 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/renderer/state/BlockOutlineRenderState.java.patch @@ -0,0 +1,18 @@ +--- a/net/minecraft/client/renderer/state/BlockOutlineRenderState.java ++++ b/net/minecraft/client/renderer/state/BlockOutlineRenderState.java +@@ -14,9 +_,14 @@ + VoxelShape shape, + @Nullable VoxelShape collisionShape, + @Nullable VoxelShape occlusionShape, +- @Nullable VoxelShape interactionShape ++ @Nullable VoxelShape interactionShape, ++ @Nullable net.minecraftforge.client.event.RenderHighlightEvent.Callback customRenderer + ) { + public BlockOutlineRenderState(BlockPos p_425529_, boolean p_426298_, boolean p_426881_, VoxelShape p_424013_) { + this(p_425529_, p_426298_, p_426881_, p_424013_, null, null, null); ++ } ++ ++ public BlockOutlineRenderState(BlockPos pos, boolean isTranslucent, boolean highContrast, VoxelShape shape, @Nullable VoxelShape collisionShape, @Nullable VoxelShape occlusionShape, @Nullable VoxelShape interactionShape) { ++ this(pos, isTranslucent, highContrast, shape, collisionShape, occlusionShape, interactionShape, null); + } + } diff --git a/patches/minecraft/net/minecraft/client/renderer/texture/SpriteContents.java.patch b/patches/minecraft/net/minecraft/client/renderer/texture/SpriteContents.java.patch index f3ff887709..506f6754eb 100644 --- a/patches/minecraft/net/minecraft/client/renderer/texture/SpriteContents.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/texture/SpriteContents.java.patch @@ -1,33 +1,6 @@ --- a/net/minecraft/client/renderer/texture/SpriteContents.java +++ b/net/minecraft/client/renderer/texture/SpriteContents.java -@@ -36,8 +_,18 @@ - @Nullable - final SpriteContents.AnimatedTexture animatedTexture; - private final ResourceMetadata metadata; -+ @Nullable -+ public final net.minecraftforge.client.textures.ForgeTextureMetadata forgeMeta; - -+ /** -+ * @deprecated Forge: Use the {@linkplain SpriteContents#SpriteContents(ResourceLocation, FrameSize, NativeImage, AnimationMetadataSection, net.minecraftforge.client.textures.ForgeTextureMetadata) overload with Forge metadata parameter} to properly forward custom loaders. -+ */ -+ @Deprecated - public SpriteContents(ResourceLocation p_249787_, FrameSize p_251031_, NativeImage p_252131_, ResourceMetadata p_299427_) { -+ this(p_249787_, p_251031_, p_252131_, p_299427_, null); -+ } -+ -+ public SpriteContents(ResourceLocation p_249787_, FrameSize p_251031_, NativeImage p_252131_, ResourceMetadata p_299427_, @Nullable net.minecraftforge.client.textures.ForgeTextureMetadata forgeMeta) { - this.name = p_249787_; - this.width = p_251031_.width(); - this.height = p_251031_.height(); -@@ -47,6 +_,7 @@ - .orElse(null); - this.originalImage = p_252131_; - this.byMipLevel = new NativeImage[]{this.originalImage}; -+ this.forgeMeta = forgeMeta; - } - - public void increaseMipLevel(int p_248864_) { -@@ -132,6 +_,9 @@ +@@ -144,6 +_,9 @@ void upload(int p_248895_, int p_250245_, int p_250458_, int p_251337_, NativeImage[] p_248825_, GpuTexture p_392525_) { for (int i = 0; i < this.byMipLevel.length; i++) { @@ -37,7 +10,7 @@ RenderSystem.getDevice() .createCommandEncoder() .writeToTexture( -@@ -155,6 +_,10 @@ +@@ -167,6 +_,10 @@ return this.name; } @@ -48,7 +21,7 @@ public IntStream getUniqueFrames() { return this.animatedTexture != null ? this.animatedTexture.getUniqueFrames() : IntStream.of(1); } -@@ -250,7 +_,8 @@ +@@ -269,7 +_,8 @@ for (int i = 0; i < this.activeFrame.length; i++) { int j = SpriteContents.this.width >> i; int k = SpriteContents.this.height >> i; @@ -58,7 +31,7 @@ } } -@@ -265,6 +_,9 @@ +@@ -284,6 +_,9 @@ for (int k = 0; k < this.activeFrame.length; k++) { int l = SpriteContents.this.width >> k; int i1 = SpriteContents.this.height >> k; diff --git a/patches/minecraft/net/minecraft/client/renderer/texture/SpriteLoader.java.patch b/patches/minecraft/net/minecraft/client/renderer/texture/SpriteLoader.java.patch index b587d2ab8d..5be3471e41 100644 --- a/patches/minecraft/net/minecraft/client/renderer/texture/SpriteLoader.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/texture/SpriteLoader.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/renderer/texture/SpriteLoader.java +++ b/net/minecraft/client/renderer/texture/SpriteLoader.java -@@ -78,7 +_,7 @@ +@@ -76,7 +_,7 @@ int j1 = Math.min(j, k); int k1 = Mth.log2(j1); int l1; @@ -9,7 +9,17 @@ LOGGER.warn("{}: dropping miplevel from {} to {}, because of minimum power of two: {}", this.location, p_261919_, k1, j1); l1 = k1; } else { -@@ -145,9 +_,14 @@ +@@ -128,7 +_,8 @@ + public CompletableFuture loadAndStitch( + ResourceManager p_262108_, ResourceLocation p_261754_, int p_262104_, Executor p_261687_, Set> p_430900_ + ) { +- SpriteResourceLoader spriteresourceloader = SpriteResourceLoader.create(p_430900_); ++ var sections = net.minecraftforge.client.ForgeHooksClient.getAtlastMetadataSections(p_261754_, p_430900_); ++ SpriteResourceLoader spriteresourceloader = SpriteResourceLoader.create(sections); + return CompletableFuture.>>supplyAsync( + () -> SpriteSourceList.load(p_262108_, p_261754_).list(p_262108_), p_261687_ + ) +@@ -139,9 +_,14 @@ private Map getStitchedSprites(Stitcher p_276117_, int p_276111_, int p_276112_) { Map map = new HashMap<>(); p_276117_.gatherSprites( diff --git a/patches/minecraft/net/minecraft/client/renderer/texture/TextureAtlas.java.patch b/patches/minecraft/net/minecraft/client/renderer/texture/TextureAtlas.java.patch index 18ee7f4f66..19e23c93ab 100644 --- a/patches/minecraft/net/minecraft/client/renderer/texture/TextureAtlas.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/texture/TextureAtlas.java.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/client/renderer/texture/TextureAtlas.java +++ b/net/minecraft/client/renderer/texture/TextureAtlas.java -@@ -91,6 +_,7 @@ +@@ -92,6 +_,7 @@ + this.sprites = List.copyOf(list); this.animatedTextures = List.copyOf(list1); - } -+ net.minecraftforge.client.ForgeHooksClient.onTextureStitchedPost(this); - } ++ net.minecraftforge.client.ForgeHooksClient.onTextureStitchedPost(this); + if (SharedConstants.DEBUG_DUMP_TEXTURE_ATLAS) { + Path path = TextureUtil.getDebugTexturePath(); - @Override -@@ -168,5 +_,10 @@ +@@ -184,5 +_,10 @@ int getHeight() { return this.height; diff --git a/patches/minecraft/net/minecraft/client/renderer/texture/TextureAtlasSprite.java.patch b/patches/minecraft/net/minecraft/client/renderer/texture/TextureAtlasSprite.java.patch index 2aa4c30281..3c0bc43131 100644 --- a/patches/minecraft/net/minecraft/client/renderer/texture/TextureAtlasSprite.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/texture/TextureAtlasSprite.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/renderer/texture/TextureAtlasSprite.java +++ b/net/minecraft/client/renderer/texture/TextureAtlasSprite.java -@@ -145,4 +_,13 @@ +@@ -138,4 +_,13 @@ @Override void close(); } diff --git a/patches/minecraft/net/minecraft/client/renderer/texture/atlas/SpriteResourceLoader.java.patch b/patches/minecraft/net/minecraft/client/renderer/texture/atlas/SpriteResourceLoader.java.patch index bbdccff52f..d7401294fc 100644 --- a/patches/minecraft/net/minecraft/client/renderer/texture/atlas/SpriteResourceLoader.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/texture/atlas/SpriteResourceLoader.java.patch @@ -1,12 +1,12 @@ --- a/net/minecraft/client/renderer/texture/atlas/SpriteResourceLoader.java +++ b/net/minecraft/client/renderer/texture/atlas/SpriteResourceLoader.java -@@ -62,6 +_,9 @@ +@@ -65,6 +_,9 @@ framesize = new FrameSize(nativeimage.getWidth(), nativeimage.getHeight()); } -+ SpriteContents contents = net.minecraftforge.client.ForgeHooksClient.loadSpriteContents(p_374679_, p_374680_, framesize, nativeimage, resourcemetadata); ++ SpriteContents contents = net.minecraftforge.client.ForgeHooksClient.loadSpriteContents(p_421043_, p_421044_, framesize, nativeimage, list); + if (contents != null) return contents; + - return new SpriteContents(p_374679_, framesize, nativeimage, resourcemetadata); + return new SpriteContents(p_421043_, framesize, nativeimage, optional, list); }; } diff --git a/patches/minecraft/net/minecraft/client/resources/model/ModelManager.java.patch b/patches/minecraft/net/minecraft/client/resources/model/ModelManager.java.patch index aa15a750e7..db0daf9710 100644 --- a/patches/minecraft/net/minecraft/client/resources/model/ModelManager.java.patch +++ b/patches/minecraft/net/minecraft/client/resources/model/ModelManager.java.patch @@ -1,22 +1,22 @@ --- a/net/minecraft/client/resources/model/ModelManager.java +++ b/net/minecraft/client/resources/model/ModelManager.java -@@ -77,6 +_,7 @@ - AtlasIds.BLOCKS - ); +@@ -57,6 +_,7 @@ + private static final Logger LOGGER = LogUtils.getLogger(); + private static final FileToIdConverter MODEL_LISTER = FileToIdConverter.json("models"); private Map bakedItemStackModels = Map.of(); + private Map bakedItemStackModelsView = Map.of(); private Map itemProperties = Map.of(); - private final AtlasSet atlases; - private final BlockModelShaper blockModelShaper; -@@ -86,6 +_,7 @@ - private int maxMipmapLevels; + private final AtlasManager atlasManager; + private final PlayerSkinRenderCache playerSkinRenderCache; +@@ -66,6 +_,7 @@ + private SpecialBlockModelRenderer specialBlockModelRenderer = SpecialBlockModelRenderer.EMPTY; private ModelBakery.MissingModels missingModels; private Object2IntMap modelGroups = Object2IntMaps.emptyMap(); + private ModelBakery modelBakery; - public ModelManager(TextureManager p_119406_, BlockColors p_119407_, int p_119408_) { + public ModelManager(BlockColors p_119407_, AtlasManager p_423190_, PlayerSkinRenderCache p_429874_) { this.blockColors = p_119407_; -@@ -102,6 +_,10 @@ +@@ -82,6 +_,10 @@ return this.bakedItemStackModels.getOrDefault(p_376816_, this.missingModels.item()); } @@ -27,34 +27,34 @@ public ClientItem.Properties getItemProperties(ResourceLocation p_378319_) { return this.itemProperties.getOrDefault(p_378319_, ClientItem.Properties.DEFAULT); } -@@ -114,6 +_,7 @@ +@@ -94,6 +_,7 @@ public final CompletableFuture reload( - PreparableReloadListener.PreparationBarrier p_249079_, ResourceManager p_251134_, Executor p_250550_, Executor p_249221_ + PreparableReloadListener.SharedState p_427489_, Executor p_250550_, PreparableReloadListener.PreparationBarrier p_249079_, Executor p_249221_ ) { + net.minecraftforge.client.model.geometry.GeometryLoaderManager.init(); + ResourceManager resourcemanager = p_427489_.resourceManager(); CompletableFuture completablefuture = CompletableFuture.supplyAsync(EntityModelSet::vanilla, p_250550_); - CompletableFuture completablefuture1 = completablefuture.thenApplyAsync(SpecialBlockModelRenderer::vanilla, p_250550_); - CompletableFuture> completablefuture2 = loadBlockModels(p_251134_, p_250550_); -@@ -251,6 +_,7 @@ + CompletableFuture completablefuture1 = completablefuture.thenApplyAsync( +@@ -229,6 +_,7 @@ }, p_394729_) .thenApply( - p_389636_ -> { -+ net.minecraftforge.client.ForgeHooksClient.onModifyBakingResult(p_248945_, p_389636_); + p_421082_ -> { ++ net.minecraftforge.client.ForgeHooksClient.onModifyBakingResult(p_248945_, p_421082_); multimap.asMap() .forEach( (p_376688_, p_252017_) -> LOGGER.warn( -@@ -271,7 +_,7 @@ +@@ -249,7 +_,7 @@ ) ); - Map map = createBlockStateToModelDispatch(p_389636_.blockStateModels(), p_389636_.missingModels().block()); -- return new ModelManager.ReloadState(p_389636_, p_361513_, map, p_250646_, p_378097_, p_377275_, completablefuture); -+ return new ModelManager.ReloadState(p_389636_, p_361513_, map, p_250646_, p_378097_, p_377275_, completablefuture, p_248945_); + Map map = createBlockStateToModelDispatch(p_421082_.blockStateModels(), p_421082_.missingModels().block()); +- return new ModelManager.ReloadState(p_421082_, p_361513_, map, p_378097_, p_377275_); ++ return new ModelManager.ReloadState(p_421082_, p_361513_, map, p_378097_, p_377275_, p_248945_); } ); } -@@ -308,10 +_,15 @@ - p_251960_.push("upload"); - p_248996_.atlasPreparations.values().forEach(AtlasSet.StitchResult::upload); +@@ -284,10 +_,15 @@ + + private void apply(ModelManager.ReloadState p_248996_) { ModelBakery.BakingResult modelbakery$bakingresult = p_248996_.bakedModels; + // TODO [BlockState Models] fix + //this.bakedBlockStateModelsView = java.util.Collections.unmodifiableMap(this.bakedBlockStateModels); @@ -65,19 +65,11 @@ this.missingModels = modelbakery$bakingresult.missingModels(); + this.modelBakery = p_248996_.modelBakery(); + net.minecraftforge.client.ForgeHooksClient.onModelBake(this, this.modelBakery); - p_251960_.popPush("cache"); this.blockModelShaper.replaceCache(p_248996_.modelCache); this.specialBlockModelRenderer = p_248996_.specialBlockModelRenderer; -@@ -338,6 +_,7 @@ - } - - public TextureAtlas getAtlas(ResourceLocation p_119429_) { -+ if (this.atlases == null) throw new RuntimeException("getAtlasTexture called too early!"); - return this.atlases.getAtlas(p_119429_); - } - -@@ -350,6 +_,10 @@ - this.maxMipmapLevels = p_119411_; + this.entityModelSet = p_248996_.entityModelSet; +@@ -311,6 +_,10 @@ + } } + public ModelBakery getModelBakery() { @@ -87,12 +79,12 @@ public Supplier specialBlockModelRenderer() { return () -> this.specialBlockModelRenderer; } -@@ -366,7 +_,8 @@ - Map atlasPreparations, +@@ -325,7 +_,8 @@ + Object2IntMap modelGroups, + Map modelCache, EntityModelSet entityModelSet, - SpecialBlockModelRenderer specialBlockModelRenderer, -- CompletableFuture readyForUpload -+ CompletableFuture readyForUpload, +- SpecialBlockModelRenderer specialBlockModelRenderer ++ SpecialBlockModelRenderer specialBlockModelRenderer, + ModelBakery modelBakery ) { } diff --git a/patches/minecraft/net/minecraft/client/resources/model/ResolvedModel.java.patch b/patches/minecraft/net/minecraft/client/resources/model/ResolvedModel.java.patch index e264c5367f..044dedb7e9 100644 --- a/patches/minecraft/net/minecraft/client/resources/model/ResolvedModel.java.patch +++ b/patches/minecraft/net/minecraft/client/resources/model/ResolvedModel.java.patch @@ -9,7 +9,7 @@ } static TextureAtlasSprite resolveParticleSprite(TextureSlots p_391346_, ModelBaker p_396500_, ModelDebugName p_393309_) { -@@ -127,5 +_,9 @@ +@@ -130,5 +_,9 @@ default ItemTransforms getTopTransforms() { return findTopTransforms(this); diff --git a/patches/minecraft/net/minecraft/client/server/IntegratedServer.java.patch b/patches/minecraft/net/minecraft/client/server/IntegratedServer.java.patch index b2486624c3..355cd3acb5 100644 --- a/patches/minecraft/net/minecraft/client/server/IntegratedServer.java.patch +++ b/patches/minecraft/net/minecraft/client/server/IntegratedServer.java.patch @@ -1,20 +1,20 @@ --- a/net/minecraft/client/server/IntegratedServer.java +++ b/net/minecraft/client/server/IntegratedServer.java -@@ -71,11 +_,12 @@ - this.setPvpAllowed(true); - this.setFlightAllowed(true); +@@ -77,11 +_,12 @@ + LOGGER.info("Starting integrated minecraft server version {}", SharedConstants.getCurrentVersion().name()); + this.setUsesAuthentication(true); this.initializeKeyPair(); + if (!net.minecraftforge.server.ServerLifecycleHooks.handleServerAboutToStart(this)) return false; this.loadLevel(); GameProfile gameprofile = this.getSingleplayerProfile(); String s = this.getWorldData().getLevelName(); - this.setMotd(gameprofile != null ? gameprofile.getName() + " - " + s : s); + this.setMotd(gameprofile != null ? gameprofile.name() + " - " + s : s); - return true; + return net.minecraftforge.server.ServerLifecycleHooks.handleServerStarting(this); } @Override -@@ -218,6 +_,7 @@ +@@ -225,6 +_,7 @@ @Override public void halt(boolean p_120053_) { diff --git a/patches/minecraft/net/minecraft/client/sounds/SoundEngine.java.patch b/patches/minecraft/net/minecraft/client/sounds/SoundEngine.java.patch index 0740452a8d..a14da84aa8 100644 --- a/patches/minecraft/net/minecraft/client/sounds/SoundEngine.java.patch +++ b/patches/minecraft/net/minecraft/client/sounds/SoundEngine.java.patch @@ -4,7 +4,7 @@ this.soundManager = p_120236_; this.options = p_120237_; this.soundBuffers = new SoundBufferLibrary(p_249332_); -+ net.minecraftforge.fml.ModLoader.get().postEvent(new net.minecraftforge.client.event.sound.SoundEngineLoadEvent(this)); ++ net.minecraftforge.fml.ModLoader.postEvent(new net.minecraftforge.client.event.sound.SoundEngineLoadEvent(this)); } public void reload() { @@ -12,11 +12,11 @@ this.destroy(); this.loadLibrary(); -+ net.minecraftforge.fml.ModLoader.get().postEvent(new net.minecraftforge.client.event.sound.SoundEngineLoadEvent(this)); ++ net.minecraftforge.fml.ModLoader.postEvent(new net.minecraftforge.client.event.sound.SoundEngineLoadEvent(this)); } private synchronized void loadLibrary() { -@@ -352,6 +_,9 @@ +@@ -343,6 +_,9 @@ } else if (!p_120313_.canPlaySound()) { return SoundEngine.PlayResult.NOT_STARTED; } else { @@ -26,22 +26,22 @@ WeighedSoundEvents weighedsoundevents = p_120313_.resolve(this.soundManager); ResourceLocation resourcelocation = p_120313_.getLocation(); if (weighedsoundevents == null) { -@@ -430,15 +_,18 @@ - p_194488_.setSelfPosition(vec3); - p_194488_.setRelative(flag); - }); -+ SoundInstance soundinstance = p_120313_; - if (!flag1) { - this.soundBuffers.getCompleteBuffer(sound.getPath()).thenAccept(p_377326_ -> channelaccess$channelhandle.execute(p_194495_ -> { - p_194495_.attachStaticBuffer(p_377326_); - p_194495_.play(); -+ net.minecraftforge.client.event.ForgeEventFactoryClient.onPlaySoundSource(this, soundinstance, p_194495_); - })); - } else { - this.soundBuffers.getStream(sound.getPath(), flag3).thenAccept(p_376862_ -> channelaccess$channelhandle.execute(p_194498_ -> { - p_194498_.attachBufferStream(p_376862_); - p_194498_.play(); -+ net.minecraftforge.client.event.ForgeEventFactoryClient.onPlayStreamingSource(this, soundinstance, p_194498_); - })); - } +@@ -422,15 +_,18 @@ + p_194488_.setSelfPosition(vec3); + p_194488_.setRelative(flag); + }); ++ SoundInstance soundinstance = p_120313_; + if (!flag1) { + this.soundBuffers.getCompleteBuffer(sound.getPath()).thenAccept(p_422528_ -> channelaccess$channelhandle.execute(p_194495_ -> { + p_194495_.attachStaticBuffer(p_422528_); + p_194495_.play(); ++ net.minecraftforge.client.event.ForgeEventFactoryClient.onPlaySoundSource(this, soundinstance, p_194495_); + })); + } else { + this.soundBuffers.getStream(sound.getPath(), flag3).thenAccept(p_430918_ -> channelaccess$channelhandle.execute(p_194498_ -> { + p_194498_.attachBufferStream(p_430918_); + p_194498_.play(); ++ net.minecraftforge.client.event.ForgeEventFactoryClient.onPlayStreamingSource(this, soundinstance, p_194498_); + })); + } diff --git a/patches/minecraft/net/minecraft/commands/Commands.java.patch b/patches/minecraft/net/minecraft/commands/Commands.java.patch index f0d83019e1..260c26e04a 100644 --- a/patches/minecraft/net/minecraft/commands/Commands.java.patch +++ b/patches/minecraft/net/minecraft/commands/Commands.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/commands/Commands.java +++ b/net/minecraft/commands/Commands.java -@@ -248,7 +_,7 @@ - JfrCommand.register(this.dispatcher); +@@ -255,7 +_,7 @@ + ChaseCommand.register(this.dispatcher); } -- if (SharedConstants.IS_RUNNING_IN_IDE) { -+ if (net.minecraftforge.gametest.ForgeGameTestHooks.isGametestEnabled()) { +- if (SharedConstants.DEBUG_DEV_COMMANDS || SharedConstants.IS_RUNNING_IN_IDE) { ++ if (SharedConstants.DEBUG_DEV_COMMANDS || net.minecraftforge.gametest.ForgeGameTestHooks.isGametestEnabled()) { RaidCommand.register(this.dispatcher, p_230944_); DebugPathCommand.register(this.dispatcher); DebugMobSpawningCommand.register(this.dispatcher); -@@ -281,6 +_,7 @@ +@@ -288,6 +_,7 @@ if (p_230943_.includeIntegrated) { PublishCommand.register(this.dispatcher); } @@ -17,7 +17,7 @@ this.dispatcher.setConsumer(ExecutionCommandSource.resultConsumer()); } -@@ -303,9 +_,18 @@ +@@ -310,9 +_,18 @@ public void performCommand(ParseResults p_242844_, String p_242841_) { CommandSourceStack commandsourcestack = p_242844_.getContext().getSource(); Profiler.get().push(() -> "/" + p_242841_); @@ -37,7 +37,7 @@ if (contextchain != null) { executeCommandInContext( commandsourcestack, -@@ -396,7 +_,10 @@ +@@ -403,7 +_,10 @@ Map, CommandNode> map = new HashMap<>(); RootCommandNode rootcommandnode = new RootCommandNode<>(); map.put(this.dispatcher.getRoot(), rootcommandnode); diff --git a/patches/minecraft/net/minecraft/commands/arguments/selector/EntitySelector.java.patch b/patches/minecraft/net/minecraft/commands/arguments/selector/EntitySelector.java.patch index 82bf9377fc..dff030ca86 100644 --- a/patches/minecraft/net/minecraft/commands/arguments/selector/EntitySelector.java.patch +++ b/patches/minecraft/net/minecraft/commands/arguments/selector/EntitySelector.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/commands/arguments/selector/EntitySelector.java +++ b/net/minecraft/commands/arguments/selector/EntitySelector.java -@@ -104,7 +_,7 @@ +@@ -105,7 +_,7 @@ } private void checkPermissions(CommandSourceStack p_121169_) throws CommandSyntaxException { diff --git a/patches/minecraft/net/minecraft/commands/arguments/selector/EntitySelectorParser.java.patch b/patches/minecraft/net/minecraft/commands/arguments/selector/EntitySelectorParser.java.patch index 70e77fad8a..cc355a2d29 100644 --- a/patches/minecraft/net/minecraft/commands/arguments/selector/EntitySelectorParser.java.patch +++ b/patches/minecraft/net/minecraft/commands/arguments/selector/EntitySelectorParser.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/commands/arguments/selector/EntitySelectorParser.java +++ b/net/minecraft/commands/arguments/selector/EntitySelectorParser.java -@@ -473,6 +_,11 @@ +@@ -480,6 +_,11 @@ } this.reader.skip(); @@ -12,7 +12,7 @@ this.parseSelector(); } else { this.parseNameOrUUID(); -@@ -489,6 +_,7 @@ +@@ -496,6 +_,7 @@ p_121248_.suggest("@s", Component.translatable("argument.entity.selector.self")); p_121248_.suggest("@e", Component.translatable("argument.entity.selector.allEntities")); p_121248_.suggest("@n", Component.translatable("argument.entity.selector.nearestEntity")); diff --git a/patches/minecraft/net/minecraft/core/BlockPos.java.patch b/patches/minecraft/net/minecraft/core/BlockPos.java.patch index 1ef54a492f..8fb2621ff0 100644 --- a/patches/minecraft/net/minecraft/core/BlockPos.java.patch +++ b/patches/minecraft/net/minecraft/core/BlockPos.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/core/BlockPos.java +++ b/net/minecraft/core/BlockPos.java -@@ -31,7 +_,7 @@ +@@ -32,7 +_,7 @@ import org.slf4j.Logger; @Immutable diff --git a/patches/minecraft/net/minecraft/core/Direction.java.patch b/patches/minecraft/net/minecraft/core/Direction.java.patch index ffc687973e..16d588de9b 100644 --- a/patches/minecraft/net/minecraft/core/Direction.java.patch +++ b/patches/minecraft/net/minecraft/core/Direction.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/core/Direction.java +++ b/net/minecraft/core/Direction.java -@@ -54,6 +_,15 @@ +@@ -57,6 +_,15 @@ private final Vec3 normalVec3; private final Vector3fc normalVec3f; private static final Direction[] VALUES = values(); diff --git a/patches/minecraft/net/minecraft/core/Registry.java.patch b/patches/minecraft/net/minecraft/core/Registry.java.patch index 2ca4381be8..4be66128c7 100644 --- a/patches/minecraft/net/minecraft/core/Registry.java.patch +++ b/patches/minecraft/net/minecraft/core/Registry.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/core/Registry.java +++ b/net/minecraft/core/Registry.java -@@ -180,5 +_,7 @@ +@@ -176,5 +_,7 @@ void apply(); int size(); diff --git a/patches/minecraft/net/minecraft/core/dispenser/DispenseItemBehavior.java.patch b/patches/minecraft/net/minecraft/core/dispenser/DispenseItemBehavior.java.patch index c2dd740353..a93b6bc2a8 100644 --- a/patches/minecraft/net/minecraft/core/dispenser/DispenseItemBehavior.java.patch +++ b/patches/minecraft/net/minecraft/core/dispenser/DispenseItemBehavior.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/core/dispenser/DispenseItemBehavior.java +++ b/net/minecraft/core/dispenser/DispenseItemBehavior.java -@@ -172,7 +_,7 @@ +@@ -175,7 +_,7 @@ DispensibleContainerItem dispensiblecontaineritem = (DispensibleContainerItem)p_334276_.getItem(); BlockPos blockpos = p_334868_.pos().relative(p_334868_.state().getValue(DispenserBlock.FACING)); Level level = p_334868_.level(); @@ -9,7 +9,7 @@ dispensiblecontaineritem.checkExtraContent(null, level, p_334276_, blockpos); return this.consumeWithRemainder(p_334868_, p_334276_, new ItemStack(Items.BUCKET)); } else { -@@ -223,8 +_,9 @@ +@@ -226,8 +_,9 @@ } else if (CampfireBlock.canLight(blockstate) || CandleBlock.canLight(blockstate) || CandleCakeBlock.canLight(blockstate)) { serverlevel.setBlockAndUpdate(blockpos, blockstate.setValue(BlockStateProperties.LIT, true)); serverlevel.gameEvent(null, GameEvent.BLOCK_CHANGE, blockpos); diff --git a/patches/minecraft/net/minecraft/core/registries/BuiltInRegistries.java.patch b/patches/minecraft/net/minecraft/core/registries/BuiltInRegistries.java.patch index eefab0a61d..8888e3b63a 100644 --- a/patches/minecraft/net/minecraft/core/registries/BuiltInRegistries.java.patch +++ b/patches/minecraft/net/minecraft/core/registries/BuiltInRegistries.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/core/registries/BuiltInRegistries.java +++ b/net/minecraft/core/registries/BuiltInRegistries.java -@@ -269,7 +_,9 @@ +@@ -278,7 +_,9 @@ ) { Bootstrap.checkBootstrapCalled(() -> "registry " + p_259230_.location()); ResourceLocation resourcelocation = p_259230_.location(); @@ -11,12 +11,12 @@ WRITABLE_REGISTRY.register((ResourceKey)p_259230_, p_260327_, RegistrationInfo.BUILT_IN); return p_260327_; } -@@ -305,7 +_,7 @@ +@@ -314,7 +_,7 @@ - if (p_358159_ instanceof DefaultedRegistry) { - ResourceLocation resourcelocation = ((DefaultedRegistry)p_358159_).getDefaultKey(); -- Validate.notNull(p_358159_.getValue(resourcelocation), "Missing default of DefaultedMappedRegistry: " + resourcelocation); -+ Validate.notNull(p_358159_.get(resourcelocation), "Missing default of DefaultedMappedRegistry: " + p_358159_.key() + " - " + resourcelocation); + if (p_421118_ instanceof DefaultedRegistry) { + ResourceLocation resourcelocation = ((DefaultedRegistry)p_421118_).getDefaultKey(); +- Objects.requireNonNull(p_421118_.getValue(resourcelocation), "Missing default of DefaultedMappedRegistry: " + resourcelocation); ++ Objects.requireNonNull(p_421118_.getValue(resourcelocation), "Missing default of DefaultedMappedRegistry: " + p_421118_.key() + " - " + resourcelocation); } }); } diff --git a/patches/minecraft/net/minecraft/core/registries/Registries.java.patch b/patches/minecraft/net/minecraft/core/registries/Registries.java.patch index f47095905a..b9f1670e9f 100644 --- a/patches/minecraft/net/minecraft/core/registries/Registries.java.patch +++ b/patches/minecraft/net/minecraft/core/registries/Registries.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/core/registries/Registries.java +++ b/net/minecraft/core/registries/Registries.java -@@ -275,10 +_,14 @@ +@@ -281,10 +_,14 @@ } public static String elementsDirPath(ResourceKey> p_343743_) { diff --git a/patches/minecraft/net/minecraft/data/Main.java.patch b/patches/minecraft/net/minecraft/data/Main.java.patch index efaa93b791..7a8721b6e9 100644 --- a/patches/minecraft/net/minecraft/data/Main.java.patch +++ b/patches/minecraft/net/minecraft/data/Main.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/data/Main.java +++ b/net/minecraft/data/Main.java -@@ -76,14 +_,17 @@ +@@ -77,14 +_,17 @@ OptionSpec optionspec4 = optionparser.accepts("all", "Include all generators"); OptionSpec optionspec5 = optionparser.accepts("output", "Output folder").withRequiredArg().defaultsTo("generated"); OptionSpec optionspec6 = optionparser.accepts("input", "Input folder").withRequiredArg(); diff --git a/patches/minecraft/net/minecraft/data/loot/BlockLootSubProvider.java.patch b/patches/minecraft/net/minecraft/data/loot/BlockLootSubProvider.java.patch index 244bffed05..f801a3041e 100644 --- a/patches/minecraft/net/minecraft/data/loot/BlockLootSubProvider.java.patch +++ b/patches/minecraft/net/minecraft/data/loot/BlockLootSubProvider.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/data/loot/BlockLootSubProvider.java +++ b/net/minecraft/data/loot/BlockLootSubProvider.java -@@ -700,12 +_,16 @@ +@@ -718,12 +_,16 @@ protected abstract void generate(); diff --git a/patches/minecraft/net/minecraft/data/recipes/RecipeProvider.java.patch b/patches/minecraft/net/minecraft/data/recipes/RecipeProvider.java.patch index 6cf26ff1bd..3dd2923661 100644 --- a/patches/minecraft/net/minecraft/data/recipes/RecipeProvider.java.patch +++ b/patches/minecraft/net/minecraft/data/recipes/RecipeProvider.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/data/recipes/RecipeProvider.java +++ b/net/minecraft/data/recipes/RecipeProvider.java -@@ -759,7 +_,7 @@ +@@ -770,7 +_,7 @@ RecipeBuilder create(RecipeProvider p_363045_, ItemLike p_362746_, ItemLike p_364674_); } @@ -9,7 +9,7 @@ private final PackOutput packOutput; private final CompletableFuture registries; -@@ -779,13 +_,13 @@ +@@ -790,13 +_,13 @@ final List> list = new ArrayList<>(); RecipeOutput recipeoutput = new RecipeOutput() { @Override @@ -26,7 +26,7 @@ } } } -@@ -800,7 +_,9 @@ +@@ -811,7 +_,9 @@ AdvancementHolder advancementholder = Advancement.Builder.recipeAdvancement() .addCriterion("impossible", CriteriaTriggers.IMPOSSIBLE.createCriterion(new ImpossibleTrigger.TriggerInstance())) .build(RecipeBuilder.ROOT_RECIPE_ADVANCEMENT); @@ -37,7 +37,7 @@ } private void saveRecipe(ResourceKey> p_368864_, Recipe p_368184_) { -@@ -811,16 +_,19 @@ +@@ -822,16 +_,19 @@ ); } diff --git a/patches/minecraft/net/minecraft/data/tags/VanillaItemTagsProvider.java.patch b/patches/minecraft/net/minecraft/data/tags/VanillaItemTagsProvider.java.patch index 8e0b3cae21..bf03175948 100644 --- a/patches/minecraft/net/minecraft/data/tags/VanillaItemTagsProvider.java.patch +++ b/patches/minecraft/net/minecraft/data/tags/VanillaItemTagsProvider.java.patch @@ -11,7 +11,7 @@ @Override protected void addTags(HolderLookup.Provider p_255639_) { (new BlockItemTagsProvider() { -@@ -459,6 +_,12 @@ +@@ -473,6 +_,12 @@ @Override public TagAppender addOptionalTag(TagKey p_407315_) { this.itemAppender.addOptionalTag(blockTagToItemTag(p_407315_)); diff --git a/patches/minecraft/net/minecraft/gametest/framework/GameTestHelper.java.patch b/patches/minecraft/net/minecraft/gametest/framework/GameTestHelper.java.patch index b02a66f9ac..e9b73d07a5 100644 --- a/patches/minecraft/net/minecraft/gametest/framework/GameTestHelper.java.patch +++ b/patches/minecraft/net/minecraft/gametest/framework/GameTestHelper.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/gametest/framework/GameTestHelper.java +++ b/net/minecraft/gametest/framework/GameTestHelper.java -@@ -66,7 +_,7 @@ +@@ -69,7 +_,7 @@ import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.Vec3; @@ -9,7 +9,7 @@ private final GameTestInfo testInfo; private boolean finalCheckAdded; -@@ -963,6 +_,12 @@ +@@ -988,6 +_,12 @@ return this.testInfo.getTick(); } @@ -22,7 +22,7 @@ public AABB getBounds() { return this.testInfo.getStructureBounds(); } -@@ -1005,5 +_,25 @@ +@@ -1030,5 +_,25 @@ if (either.right().isPresent()) { throw this.assertionException("test.error.set_biome"); } diff --git a/patches/minecraft/net/minecraft/gametest/framework/GameTestServer.java.patch b/patches/minecraft/net/minecraft/gametest/framework/GameTestServer.java.patch index ccf79d7e88..d58d7c8f12 100644 --- a/patches/minecraft/net/minecraft/gametest/framework/GameTestServer.java.patch +++ b/patches/minecraft/net/minecraft/gametest/framework/GameTestServer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/gametest/framework/GameTestServer.java +++ b/net/minecraft/gametest/framework/GameTestServer.java -@@ -80,7 +_,7 @@ +@@ -90,7 +_,7 @@ Thread p_206607_, LevelStorageSource.LevelStorageAccess p_206608_, PackRepository p_206609_, Optional p_392741_, boolean p_392375_ ) { p_206609_.reload(); @@ -9,11 +9,11 @@ arraylist.remove("vanilla"); arraylist.addFirst("vanilla"); WorldDataConfiguration worlddataconfiguration = new WorldDataConfiguration(new DataPackConfig(arraylist, List.of()), ENABLED_FEATURES); -@@ -140,6 +_,7 @@ +@@ -150,6 +_,7 @@ @Override public boolean initServer() { + if (!net.minecraftforge.server.ServerLifecycleHooks.handleServerAboutToStart(this)) return false; - this.setPlayerList(new PlayerList(this, this.registries(), this.playerDataStorage, 1) {}); + this.setPlayerList(new PlayerList(this, this.registries(), this.playerDataStorage, new EmptyNotificationService()) {}); this.loadLevel(); ServerLevel serverlevel = this.overworld(); diff --git a/patches/minecraft/net/minecraft/gametest/framework/TestCommand.java.patch b/patches/minecraft/net/minecraft/gametest/framework/TestCommand.java.patch index 67e01f3e44..a5926fcf51 100644 --- a/patches/minecraft/net/minecraft/gametest/framework/TestCommand.java.patch +++ b/patches/minecraft/net/minecraft/gametest/framework/TestCommand.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/gametest/framework/TestCommand.java +++ b/net/minecraft/gametest/framework/TestCommand.java -@@ -485,7 +_,12 @@ +@@ -487,7 +_,12 @@ return Optional.empty(); } else { Holder.Reference reference = optional.get(); diff --git a/patches/minecraft/net/minecraft/network/Connection.java.patch b/patches/minecraft/net/minecraft/network/Connection.java.patch index 6209c3ed41..8280914458 100644 --- a/patches/minecraft/net/minecraft/network/Connection.java.patch +++ b/patches/minecraft/net/minecraft/network/Connection.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/network/Connection.java +++ b/net/minecraft/network/Connection.java -@@ -106,9 +_,17 @@ +@@ -105,9 +_,17 @@ private volatile DisconnectionDetails delayedDisconnect; @Nullable BandwidthDebugMonitor bandwidthDebugMonitor; @@ -18,7 +18,7 @@ } @Override -@@ -116,6 +_,7 @@ +@@ -115,6 +_,7 @@ super.channelActive(p_129525_); this.channel = p_129525_.channel(); this.address = this.channel.remoteAddress(); @@ -26,7 +26,7 @@ if (this.delayedDisconnect != null) { this.disconnect(this.delayedDisconnect); } -@@ -176,6 +_,7 @@ +@@ -175,6 +_,7 @@ } else { if (packetlistener.shouldHandleMessage(p_129488_)) { try { @@ -34,7 +34,7 @@ genericsFtw(p_129488_, packetlistener); } catch (RunningOnDifferentThreadException runningondifferentthreadexception) { } catch (RejectedExecutionException rejectedexecutionexception) { -@@ -225,6 +_,7 @@ +@@ -224,6 +_,7 @@ if (p_333271_.flow() != this.getReceiving()) { throw new IllegalStateException("Invalid inbound protocol: " + p_333271_.id()); } else { @@ -42,7 +42,7 @@ this.packetListener = p_330962_; this.disconnectListener = null; UnconfiguredPipelineHandler.InboundConfigurationTask unconfiguredpipelinehandler$inboundconfigurationtask = UnconfiguredPipelineHandler.setupInboundProtocol( -@@ -248,6 +_,8 @@ +@@ -247,6 +_,8 @@ } else { UnconfiguredPipelineHandler.OutboundConfigurationTask unconfiguredpipelinehandler$outboundconfigurationtask = UnconfiguredPipelineHandler.setupOutboundProtocol( p_329145_ @@ -51,7 +51,7 @@ ); BundlerInfo bundlerinfo = p_329145_.bundlerInfo(); if (bundlerinfo != null) { -@@ -297,7 +_,8 @@ +@@ -296,7 +_,8 @@ this.disconnectListener = p_330656_; this.runOnceConnected(p_405096_ -> { this.setupInboundProtocol(p_329827_, p_330656_); @@ -61,7 +61,7 @@ this.setupOutboundProtocol(p_328134_); }); } -@@ -342,10 +_,13 @@ +@@ -341,10 +_,13 @@ if (p_405953_ != null) { ChannelFuture channelfuture = p_299937_ ? this.channel.writeAndFlush(p_243260_) : this.channel.write(p_243260_); channelfuture.addListener(p_405953_); @@ -75,7 +75,7 @@ } } -@@ -414,7 +_,7 @@ +@@ -413,7 +_,7 @@ if (this.address == null) { return "local"; } else { @@ -84,7 +84,7 @@ } } -@@ -457,6 +_,8 @@ +@@ -456,6 +_,8 @@ } public static ChannelFuture connect(InetSocketAddress p_290034_, boolean p_290035_, final Connection p_290031_) { @@ -93,7 +93,7 @@ Class oclass; EventLoopGroup eventloopgroup; if (Epoll.isAvailable() && p_290035_) { -@@ -528,6 +_,7 @@ +@@ -527,6 +_,7 @@ public static Connection connectToLocalServer(SocketAddress p_129494_) { final Connection connection = new Connection(PacketFlow.CLIENTBOUND); @@ -101,7 +101,7 @@ new Bootstrap().group(LOCAL_WORKER_GROUP.get()).handler(new ChannelInitializer() { @Override protected void initChannel(Channel p_332618_) { -@@ -621,6 +_,22 @@ +@@ -620,6 +_,22 @@ public float getAverageSentPackets() { return this.averageSentPackets; diff --git a/patches/minecraft/net/minecraft/network/FriendlyByteBuf.java.patch b/patches/minecraft/net/minecraft/network/FriendlyByteBuf.java.patch index 7096c2322f..dcb13496fa 100644 --- a/patches/minecraft/net/minecraft/network/FriendlyByteBuf.java.patch +++ b/patches/minecraft/net/minecraft/network/FriendlyByteBuf.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/network/FriendlyByteBuf.java +++ b/net/minecraft/network/FriendlyByteBuf.java -@@ -1649,4 +_,8 @@ +@@ -1647,4 +_,8 @@ public boolean release(int p_130347_) { return this.source.release(p_130347_); } diff --git a/patches/minecraft/net/minecraft/network/chat/contents/TranslatableContents.java.patch b/patches/minecraft/net/minecraft/network/chat/contents/TranslatableContents.java.patch index 4981978146..6d85923614 100644 --- a/patches/minecraft/net/minecraft/network/chat/contents/TranslatableContents.java.patch +++ b/patches/minecraft/net/minecraft/network/chat/contents/TranslatableContents.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/network/chat/contents/TranslatableContents.java +++ b/net/minecraft/network/chat/contents/TranslatableContents.java -@@ -140,6 +_,11 @@ +@@ -139,6 +_,11 @@ j = l; } diff --git a/patches/minecraft/net/minecraft/network/protocol/common/ClientboundCustomPayloadPacket.java.patch b/patches/minecraft/net/minecraft/network/protocol/common/ClientboundCustomPayloadPacket.java.patch index bc2cea99d1..a7a4568deb 100644 --- a/patches/minecraft/net/minecraft/network/protocol/common/ClientboundCustomPayloadPacket.java.patch +++ b/patches/minecraft/net/minecraft/network/protocol/common/ClientboundCustomPayloadPacket.java.patch @@ -1,15 +1,12 @@ --- a/net/minecraft/network/protocol/common/ClientboundCustomPayloadPacket.java +++ b/net/minecraft/network/protocol/common/ClientboundCustomPayloadPacket.java -@@ -36,7 +_,7 @@ +@@ -17,12 +_,12 @@ public record ClientboundCustomPayloadPacket(CustomPacketPayload payload) implements Packet { private static final int MAX_PAYLOAD_SIZE = 1048576; public static final StreamCodec GAMEPLAY_STREAM_CODEC = CustomPacketPayload.codec( - p_330149_ -> DiscardedPayload.codec(p_330149_, 1048576), + p_330149_ -> net.minecraftforge.common.ForgeHooks.getCustomPayloadCodec(p_330149_, 1048576), - Util.make( - Lists.newArrayList( - new CustomPacketPayload.TypeAndCodec<>(BrandPayload.TYPE, BrandPayload.STREAM_CODEC), -@@ -65,7 +_,7 @@ + Util.make(Lists.newArrayList(new CustomPacketPayload.TypeAndCodec<>(BrandPayload.TYPE, BrandPayload.STREAM_CODEC)), p_333496_ -> {}) ) .map(ClientboundCustomPayloadPacket::new, ClientboundCustomPayloadPacket::payload); public static final StreamCodec CONFIG_STREAM_CODEC = CustomPacketPayload.codec( diff --git a/patches/minecraft/net/minecraft/network/protocol/status/ServerStatus.java.patch b/patches/minecraft/net/minecraft/network/protocol/status/ServerStatus.java.patch index 663c75020a..1dd136c8a6 100644 --- a/patches/minecraft/net/minecraft/network/protocol/status/ServerStatus.java.patch +++ b/patches/minecraft/net/minecraft/network/protocol/status/ServerStatus.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/network/protocol/status/ServerStatus.java +++ b/net/minecraft/network/protocol/status/ServerStatus.java -@@ -21,7 +_,8 @@ +@@ -20,7 +_,8 @@ Optional players, Optional version, Optional favicon, @@ -10,7 +10,7 @@ ) { public static final Codec CODEC = RecordCodecBuilder.create( p_326135_ -> p_326135_.group( -@@ -29,7 +_,8 @@ +@@ -28,7 +_,8 @@ ServerStatus.Players.CODEC.lenientOptionalFieldOf("players").forGetter(ServerStatus::players), ServerStatus.Version.CODEC.lenientOptionalFieldOf("version").forGetter(ServerStatus::version), ServerStatus.Favicon.CODEC.lenientOptionalFieldOf("favicon").forGetter(ServerStatus::favicon), diff --git a/patches/minecraft/net/minecraft/network/syncher/EntityDataSerializers.java.patch b/patches/minecraft/net/minecraft/network/syncher/EntityDataSerializers.java.patch index 4931cbb477..61ace79133 100644 --- a/patches/minecraft/net/minecraft/network/syncher/EntityDataSerializers.java.patch +++ b/patches/minecraft/net/minecraft/network/syncher/EntityDataSerializers.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/network/syncher/EntityDataSerializers.java +++ b/net/minecraft/network/syncher/EntityDataSerializers.java -@@ -129,16 +_,18 @@ - public static final EntityDataSerializer QUATERNION = EntityDataSerializer.forValueType(ByteBufCodecs.QUATERNIONF); +@@ -124,16 +_,18 @@ + public static final EntityDataSerializer RESOLVABLE_PROFILE = EntityDataSerializer.forValueType(ResolvableProfile.STREAM_CODEC); public static void registerSerializer(EntityDataSerializer p_135051_) { + int id = diff --git a/patches/minecraft/net/minecraft/server/Main.java.patch b/patches/minecraft/net/minecraft/server/Main.java.patch index c3827a7322..ea166c415f 100644 --- a/patches/minecraft/net/minecraft/server/Main.java.patch +++ b/patches/minecraft/net/minecraft/server/Main.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/Main.java +++ b/net/minecraft/server/Main.java -@@ -88,6 +_,17 @@ +@@ -86,6 +_,17 @@ OptionSpec optionspec13 = optionparser.accepts("jfrProfile"); OptionSpec optionspec14 = optionparser.accepts("pidFile").withRequiredArg().withValuesConvertedBy(new PathConverter()); OptionSpec optionspec15 = optionparser.nonOptions(); @@ -18,7 +18,7 @@ try { OptionSet optionset = optionparser.parse(p_129699_); -@@ -96,6 +_,14 @@ +@@ -94,6 +_,14 @@ return; } @@ -33,7 +33,7 @@ Path path = optionset.valueOf(optionspec14); if (path != null) { writePidFile(path); -@@ -110,24 +_,29 @@ +@@ -108,24 +_,29 @@ Bootstrap.validate(); Util.startTimerHackThread(); Path path1 = Paths.get("server.properties"); @@ -70,7 +70,7 @@ LevelStorageSource levelstoragesource = LevelStorageSource.createDefault(file1.toPath()); LevelStorageSource.LevelStorageAccess levelstoragesource$levelstorageaccess = levelstoragesource.validateAndCreateAccess(s); Dynamic dynamic; -@@ -178,6 +_,10 @@ +@@ -176,6 +_,10 @@ PackRepository packrepository = ServerPacksSource.createPackRepository(levelstoragesource$levelstorageaccess); @@ -81,47 +81,19 @@ WorldStem worldstem; try { WorldLoader.InitConfig worldloader$initconfig = loadOrCreateConfig(dedicatedserversettings.getProperties(), dynamic1, flag, packrepository); -@@ -217,6 +_,16 @@ - worlddimensions = dedicatedserverproperties.createDimensions(p_358511_.datapackWorldgen()); - } - -+ //Forge: Do a write-read-cycle to inject modded dimensions on first start of a dedicated server into its generated world dimensions list. -+ var dynamicops = net.minecraft.resources.RegistryOps.create(net.minecraft.nbt.NbtOps.INSTANCE, p_358511_.datapackWorldgen()); -+ worlddimensions = WorldDimensions.CODEC.encoder() -+ .encodeStart(dynamicops, worlddimensions) -+ .flatMap((writtenPayloadWithModdedDimensions) -> -+ WorldDimensions.CODEC.decoder().parse(dynamicops, writtenPayloadWithModdedDimensions) -+ ) -+ .resultOrPartial(LOGGER::error) -+ .orElse(worlddimensions); -+ - WorldDimensions.Complete worlddimensions$complete = worlddimensions.bake(registry); - Lifecycle lifecycle = worlddimensions$complete.lifecycle().add(p_358511_.datapackWorldgen().allRegistriesLifecycle()); - return new WorldLoader.DataLoadOutput<>( -@@ -255,9 +_,20 @@ +@@ -224,17 +_,18 @@ } levelstoragesource$levelstorageaccess.saveDataTag(registryaccess$frozen, worlddata); - final DedicatedServer dedicatedserver = MinecraftServer.spin( + final MinecraftServer dedicatedserver = MinecraftServer.spin( - p_405123_ -> { + p_421274_ -> { - DedicatedServer dedicatedserver1 = new DedicatedServer( + MinecraftServer dedicatedserver1; -+ // TODO: [Forge][GameTest] URGENT !!! FIX GAME TESTS !!! -+ /* -+ if (gametestEnabled) { -+ net.minecraftforge.gametest.ForgeGameTestHooks.registerGametests(); -+ var tests = net.minecraft.gametest.framework.GameTestRegistry.getAllTestFunctions(); -+ var spawnPos = optionset.valueOf(spawnPosOpt); -+ dedicatedserver1 = net.minecraft.gametest.framework.GameTestServer.create(p_296433_, levelstoragesource$levelstorageaccess, packrepository, tests, spawnPos); -+ -+ } else { -+ */ + dedicatedserver1 = new DedicatedServer( - p_405123_, - levelstoragesource$levelstorageaccess, - packrepository, -@@ -271,8 +_,8 @@ + p_421274_, levelstoragesource$levelstorageaccess, packrepository, worldstem, dedicatedserversettings, DataFixers.getDataFixer(), services + ); + dedicatedserver1.setPort(optionset.valueOf(optionspec11)); dedicatedserver1.setDemo(optionset.has(optionspec2)); dedicatedserver1.setId(optionset.valueOf(optionspec12)); boolean flag2 = !optionset.has(optionspec) && !optionset.valuesOf(optionspec15).contains("nogui"); @@ -131,15 +103,29 @@ + ds.showGui(); } - GameTestTicker.SINGLETON.startTicking(); -@@ -282,7 +_,10 @@ - Thread thread = new Thread("Server Shutdown Thread") { + return dedicatedserver1; +@@ -244,6 +_,7 @@ @Override public void run() { -+ // FORGE: Halting as GameTestServer will cause issues as it always calls System#exit on both crash and normal exit, so skip it -+ if (!(dedicatedserver instanceof net.minecraft.gametest.framework.GameTestServer)) dedicatedserver.halt(true); + org.apache.logging.log4j.LogManager.shutdown(); // we're manually managing the logging shutdown on the server. Make sure we do it here at the end. } }; thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(LOGGER)); +@@ -277,6 +_,16 @@ + worldoptions = p_427999_ ? dedicatedserverproperties.worldOptions.withBonusChest(true) : dedicatedserverproperties.worldOptions; + worlddimensions = dedicatedserverproperties.createDimensions(p_423661_.datapackWorldgen()); + } ++ ++ //Forge: Do a write-read-cycle to inject modded dimensions on first start of a dedicated server into its generated world dimensions list. ++ var dynamicops = net.minecraft.resources.RegistryOps.create(net.minecraft.nbt.NbtOps.INSTANCE, p_423661_.datapackWorldgen()); ++ worlddimensions = WorldDimensions.CODEC.encoder() ++ .encodeStart(dynamicops, worlddimensions) ++ .flatMap((writtenPayloadWithModdedDimensions) -> ++ WorldDimensions.CODEC.decoder().parse(dynamicops, writtenPayloadWithModdedDimensions) ++ ) ++ .resultOrPartial(LOGGER::error) ++ .orElse(worlddimensions); + + WorldDimensions.Complete worlddimensions$complete = worlddimensions.bake(p_422717_); + Lifecycle lifecycle = worlddimensions$complete.lifecycle().add(p_423661_.datapackWorldgen().allRegistriesLifecycle()); diff --git a/patches/minecraft/net/minecraft/server/MinecraftServer.java.patch b/patches/minecraft/net/minecraft/server/MinecraftServer.java.patch index 33871c0779..899eac188e 100644 --- a/patches/minecraft/net/minecraft/server/MinecraftServer.java.patch +++ b/patches/minecraft/net/minecraft/server/MinecraftServer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java -@@ -274,7 +_,7 @@ +@@ -281,7 +_,7 @@ public static S spin(Function p_129873_) { AtomicReference atomicreference = new AtomicReference<>(); @@ -9,31 +9,31 @@ thread.setUncaughtExceptionHandler((p_177909_, p_177910_) -> LOGGER.error("Uncaught exception in server thread", p_177910_)); if (Runtime.getRuntime().availableProcessors() > 4) { thread.setPriority(8); -@@ -380,6 +_,7 @@ +@@ -408,6 +_,7 @@ + DimensionDataStorage dimensiondatastorage = serverlevel.getDataStorage(); this.readScoreboard(dimensiondatastorage); this.commandStorage = new CommandStorage(dimensiondatastorage); - WorldBorder worldborder = serverlevel.getWorldBorder(); + net.minecraftforge.event.ForgeEventFactory.onLevelLoad(levels.get(Level.OVERWORLD)); if (!serverleveldata.isInitialized()) { try { - setInitialSpawn(serverlevel, serverleveldata, worldoptions.generateBonusChest(), flag); -@@ -429,6 +_,7 @@ + setInitialSpawn(serverlevel, serverleveldata, worldoptions.generateBonusChest(), flag, this.levelLoadListener); +@@ -448,6 +_,7 @@ + this, this.executor, this.storageSource, derivedleveldata, resourcekey1, entry.getValue(), flag, j, ImmutableList.of(), false, randomsequences ); - worldborder.addListener(new BorderChangeListener.DelegateBorderChangeListener(serverlevel1.getWorldBorder())); this.levels.put(resourcekey1, serverlevel1); + net.minecraftforge.event.ForgeEventFactory.onLevelLoad(serverlevel1); + } else { + serverlevel1 = serverlevel; } - } - -@@ -440,6 +_,7 @@ - p_177898_.setSpawn(BlockPos.ZERO.above(80), 0.0F); +@@ -491,6 +_,7 @@ + p_177898_.setSpawn(LevelData.RespawnData.of(p_177897_.dimension(), BlockPos.ZERO.above(80), 0.0F, 0.0F)); } else { ServerChunkCache serverchunkcache = p_177897_.getChunkSource(); + if (net.minecraftforge.event.ForgeEventFactory.onCreateWorldSpawn(p_177897_, p_177898_)) return; ChunkPos chunkpos = new ChunkPos(serverchunkcache.randomState().sampler().findSpawnPosition()); - int i = serverchunkcache.getGenerator().getSpawnHeight(p_177897_); - if (i < p_177897_.getMinY()) { -@@ -622,6 +_,7 @@ + p_431711_.start(LevelLoadListener.Stage.PREPARE_GLOBAL_SPAWN, 0); + p_431711_.updateFocus(p_177897_.dimension(), chunkpos); +@@ -675,6 +_,7 @@ for (ServerLevel serverlevel2 : this.getAllLevels()) { if (serverlevel2 != null) { try { @@ -41,7 +41,7 @@ serverlevel2.close(); } catch (IOException ioexception1) { LOGGER.error("Exception closing the level", (Throwable)ioexception1); -@@ -668,9 +_,11 @@ +@@ -721,9 +_,11 @@ throw new IllegalStateException("Failed to initialize server"); } @@ -53,7 +53,7 @@ while (this.running) { long i; -@@ -722,6 +_,8 @@ +@@ -775,6 +_,8 @@ this.isReady = true; JvmProfiler.INSTANCE.onServerTick(this.smoothedTickTimeMillis); } @@ -62,7 +62,7 @@ } catch (Throwable throwable2) { LOGGER.error("Encountered an unexpected exception", throwable2); CrashReport crashreport = constructOrExtractCrashReport(throwable2); -@@ -733,6 +_,7 @@ +@@ -786,6 +_,7 @@ LOGGER.error("We were unable to save this crash report to disk."); } @@ -70,15 +70,15 @@ this.onServerCrash(crashreport); } finally { try { -@@ -745,6 +_,7 @@ - this.services.profileCache().clearExecutor(); - } - +@@ -794,6 +_,7 @@ + } catch (Throwable throwable) { + LOGGER.error("Exception stopping the server", throwable); + } finally { + net.minecraftforge.server.ServerLifecycleHooks.handleServerStopped(this); this.onServerExit(); } } -@@ -934,12 +_,14 @@ +@@ -991,12 +_,14 @@ } } @@ -93,7 +93,7 @@ } this.ticksUntilAutosave--; -@@ -957,6 +_,7 @@ +@@ -1014,6 +_,7 @@ this.smoothedTickTimeMillis = this.smoothedTickTimeMillis * 0.8F + (float)k / (float)TimeUtil.NANOSECONDS_PER_MILLISECOND * 0.19999999F; this.logTickMethodTime(i); profilerfiller.pop(); @@ -101,7 +101,7 @@ } private void autoSave() { -@@ -1006,7 +_,8 @@ +@@ -1063,7 +_,8 @@ Optional.of(serverstatus$players), Optional.of(ServerStatus.Version.current()), Optional.ofNullable(this.statusIcon), @@ -111,9 +111,9 @@ ); } -@@ -1037,7 +_,8 @@ - this.getFunctions().tick(); +@@ -1095,7 +_,8 @@ profilerfiller.popPush("levels"); + this.updateEffectiveRespawnData(); - for (ServerLevel serverlevel : this.getAllLevels()) { + for (ServerLevel serverlevel : this.getWorldArray()) { @@ -121,7 +121,7 @@ profilerfiller.push(() -> serverlevel + " " + serverlevel.dimension().location()); if (this.tickCount % 20 == 0) { profilerfiller.push("timeSync"); -@@ -1046,6 +_,7 @@ +@@ -1104,6 +_,7 @@ } profilerfiller.push("tick"); @@ -129,7 +129,7 @@ try { serverlevel.tick(p_129954_); -@@ -1054,16 +_,18 @@ +@@ -1112,9 +_,11 @@ serverlevel.fillReportDetails(crashreport); throw new ReportedException(crashreport); } @@ -141,15 +141,16 @@ } profilerfiller.popPush("connection"); - this.tickConnection(); - profilerfiller.popPush("players"); +@@ -1123,7 +_,7 @@ this.playerList.tick(); + profilerfiller.popPush("debugSubscribers"); + this.debugSubscribers.tick(); - if (this.tickRateManager.runsNormally()) { + if (net.minecraftforge.gametest.ForgeGameTestHooks.isGametestEnabled() && this.tickRateManager.runsNormally()) { + profilerfiller.popPush("gameTests"); GameTestTicker.SINGLETON.tick(); } - -@@ -1164,7 +_,7 @@ +@@ -1226,7 +_,7 @@ @DontObfuscate public String getServerModName() { @@ -158,7 +159,7 @@ } public SystemReport fillSystemReport(SystemReport p_177936_) { -@@ -1516,6 +_,7 @@ +@@ -1576,6 +_,7 @@ this.functionManager.replaceLibrary(this.resources.managers.getFunctionLibrary()); this.structureTemplateManager.onResourceManagerReload(this.resources.resourceManager); this.fuelValues = FuelValues.vanillaBurnTimes(this.registries.compositeAccess(), this.worldData.enabledFeatures()); @@ -166,7 +167,7 @@ }, this); if (this.isSameThread()) { this.managedBlock(completablefuture::isDone); -@@ -1525,12 +_,15 @@ +@@ -1585,12 +_,15 @@ } public static WorldDataConfiguration configurePackRepository(PackRepository p_248681_, WorldDataConfiguration p_331931_, boolean p_249869_, boolean p_330480_) { @@ -183,7 +184,7 @@ } else { Set set = Sets.newLinkedHashSet(); -@@ -2038,6 +_,48 @@ +@@ -2155,6 +_,48 @@ public ServerLinks serverLinks() { return ServerLinks.EMPTY; @@ -231,4 +232,4 @@ + return resources; } - protected int pauseWhileEmptySeconds() { + protected int pauseWhenEmptySeconds() { diff --git a/patches/minecraft/net/minecraft/server/ReloadableServerResources.java.patch b/patches/minecraft/net/minecraft/server/ReloadableServerResources.java.patch index e4c0cf1d5b..51d7962f8b 100644 --- a/patches/minecraft/net/minecraft/server/ReloadableServerResources.java.patch +++ b/patches/minecraft/net/minecraft/server/ReloadableServerResources.java.patch @@ -27,7 +27,7 @@ p_358539_.layers(), p_358539_.lookupWithUpdatedTags(), p_250212_, p_249301_, p_366334_, p_251126_ ); + var listeners = new java.util.ArrayList<>(reloadableserverresources.listeners()); -+ listeners.addAll(net.minecraftforge.event.ForgeEventFactory.onResourceReload(reloadableserverresources, p_358539_.lookupWithUpdatedTags(), p_330376_.compositeAccess())); ++ listeners.addAll(net.minecraftforge.event.ForgeEventFactory.onResourceReload(reloadableserverresources, p_358539_.lookupWithUpdatedTags())); return SimpleReloadInstance.create( - p_248588_, reloadableserverresources.listeners(), p_249136_, p_249601_, DATA_RELOAD_INITIAL_TASK, LOGGER.isDebugEnabled() + p_248588_, listeners, p_249136_, p_249601_, DATA_RELOAD_INITIAL_TASK, LOGGER.isDebugEnabled() diff --git a/patches/minecraft/net/minecraft/server/commands/TeleportCommand.java.patch b/patches/minecraft/net/minecraft/server/commands/TeleportCommand.java.patch index 1b2746057e..4b3ffe081b 100644 --- a/patches/minecraft/net/minecraft/server/commands/TeleportCommand.java.patch +++ b/patches/minecraft/net/minecraft/server/commands/TeleportCommand.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/commands/TeleportCommand.java +++ b/net/minecraft/server/commands/TeleportCommand.java -@@ -275,6 +_,9 @@ +@@ -248,6 +_,9 @@ float p_139023_, @Nullable LookAt p_365991_ ) throws CommandSyntaxException { diff --git a/patches/minecraft/net/minecraft/server/dedicated/DedicatedServer.java.patch b/patches/minecraft/net/minecraft/server/dedicated/DedicatedServer.java.patch index 49a052cf1a..b63d4dab84 100644 --- a/patches/minecraft/net/minecraft/server/dedicated/DedicatedServer.java.patch +++ b/patches/minecraft/net/minecraft/server/dedicated/DedicatedServer.java.patch @@ -1,40 +1,40 @@ --- a/net/minecraft/server/dedicated/DedicatedServer.java +++ b/net/minecraft/server/dedicated/DedicatedServer.java -@@ -79,6 +_,8 @@ +@@ -97,6 +_,8 @@ @Nullable - private DebugSampleSubscriptionTracker debugSampleSubscriptionTracker; - private final ServerLinks serverLinks; + private ManagementServer jsonRpcServer; + private long lastHeartbeat; + @Nullable + private net.minecraft.client.server.LanServerPinger dediLanPinger; public DedicatedServer( Thread p_214789_, -@@ -102,6 +_,7 @@ - Thread thread = new Thread("Server console handler") { +@@ -192,6 +_,7 @@ + Thread thread1 = new Thread("Server console handler") { @Override public void run() { + if (net.minecraftforge.server.console.TerminalHandler.handleCommands(DedicatedServer.this)) return; BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(System.in, StandardCharsets.UTF_8)); - String s1; -@@ -182,11 +_,13 @@ - long i = Util.getNanos(); - SkullBlockEntity.setup(this.services, this); - GameProfileCache.setUsesAuthentication(this.usesAuthentication()); + String s3; +@@ -265,11 +_,13 @@ + this.tickTimeLogger = new RemoteSampleLogger(TpsDebugDimensions.values().length, this.debugSubscribers(), RemoteDebugSampleType.TICK_TIME); + long j = Util.getNanos(); + this.services.nameToIdCache().resolveOfflineUsers(!this.usesAuthentication()); + if (!net.minecraftforge.server.ServerLifecycleHooks.handleServerAboutToStart(this)) return false; LOGGER.info("Preparing level \"{}\"", this.getLevelIdName()); this.loadLevel(); - long j = Util.getNanos() - i; - String s = String.format(Locale.ROOT, "%.3fs", j / 1.0E9); - LOGGER.info("Done ({})! For help, type \"help\"", s); + long k = Util.getNanos() - j; + String s2 = String.format(Locale.ROOT, "%.3fs", k / 1.0E9); + LOGGER.info("Done ({})! For help, type \"help\"", s2); + this.nextTickTimeNanos = Util.getNanos(); //Forge: Update server time to prevent watchdog/spaming during long load. if (dedicatedserverproperties.announcePlayerAchievements != null) { this.getGameRules().getRule(GameRules.RULE_ANNOUNCE_ADVANCEMENTS).set(dedicatedserverproperties.announcePlayerAchievements, this); } -@@ -214,7 +_,12 @@ - LOGGER.info("JMX monitoring enabled"); +@@ -298,7 +_,12 @@ } + this.notificationManager().serverStarted(); - return true; + if (net.minecraftforge.common.ForgeConfig.SERVER.advertiseDedicatedServerToLan.get()) { + this.dediLanPinger = new net.minecraft.client.server.LanServerPinger(this.getMotd(), String.valueOf(this.getServerPort())); @@ -45,9 +45,9 @@ } } -@@ -275,6 +_,13 @@ - if (this.queryThreadGs4 != null) { - this.queryThreadGs4.stop(); +@@ -510,6 +_,13 @@ + if (this.gui == null) { + this.gui = MinecraftServerGui.showFrameFor(this); } + + if (this.dediLanPinger != null) { @@ -59,16 +59,17 @@ } @Override -@@ -528,7 +_,12 @@ +@@ -725,8 +_,13 @@ @Override public void stopServer() { + net.minecraftforge.event.GameShuttingDownEvent.BUS.post(new net.minecraftforge.event.GameShuttingDownEvent()); + this.notificationManager().serverShuttingDown(); super.stopServer(); + if (this.dediLanPinger != null) { + this.dediLanPinger.interrupt(); + this.dediLanPinger = null; + } Util.shutdownExecutors(); - SkullBlockEntity.clear(); } + diff --git a/patches/minecraft/net/minecraft/server/level/ChunkMap.java.patch b/patches/minecraft/net/minecraft/server/level/ChunkMap.java.patch index 27de7e071d..225b8dc03c 100644 --- a/patches/minecraft/net/minecraft/server/level/ChunkMap.java.patch +++ b/patches/minecraft/net/minecraft/server/level/ChunkMap.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/ChunkMap.java +++ b/net/minecraft/server/level/ChunkMap.java -@@ -391,6 +_,7 @@ +@@ -393,6 +_,7 @@ this.modified = true; } @@ -8,7 +8,7 @@ return p_140179_; } } -@@ -517,6 +_,7 @@ +@@ -519,6 +_,7 @@ if (this.pendingUnloads.remove(p_140182_, p_140183_) && chunkaccess != null) { if (chunkaccess instanceof LevelChunk levelchunk) { levelchunk.setLoaded(false); @@ -16,15 +16,15 @@ } this.save(chunkaccess); -@@ -767,6 +_,7 @@ +@@ -763,6 +_,7 @@ this.activeChunkWrites.incrementAndGet(); SerializableChunkData serializablechunkdata = SerializableChunkData.copyOf(this.level, p_140259_); CompletableFuture completablefuture = CompletableFuture.supplyAsync(serializablechunkdata::write, Util.backgroundExecutor()); + net.minecraftforge.event.ForgeEventFactory.onChunkDataSave(p_140259_, p_140259_.getWorldForge() != null ? p_140259_.getWorldForge() : this.level, serializablechunkdata); - this.write(chunkpos, completablefuture::join).handle((p_358676_, p_358677_) -> { - if (p_358677_ != null) { - this.level.getServer().reportChunkSaveFailure(p_358677_, this.storageInfo(), chunkpos); -@@ -1122,7 +_,7 @@ + this.write(chunkpos, completablefuture::join).handle((p_421447_, p_421448_) -> { + if (p_421448_ != null) { + this.level.getServer().reportChunkSaveFailure(p_421448_, this.storageInfo(), chunkpos); +@@ -1114,7 +_,7 @@ } protected void addEntity(Entity p_140200_) { diff --git a/patches/minecraft/net/minecraft/server/level/DistanceManager.java.patch b/patches/minecraft/net/minecraft/server/level/DistanceManager.java.patch index c3e4756ad1..af8f6056a9 100644 --- a/patches/minecraft/net/minecraft/server/level/DistanceManager.java.patch +++ b/patches/minecraft/net/minecraft/server/level/DistanceManager.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/DistanceManager.java +++ b/net/minecraft/server/level/DistanceManager.java -@@ -189,6 +_,10 @@ +@@ -191,6 +_,10 @@ return this.ticketDispatcher.getDebugStatus(); } diff --git a/patches/minecraft/net/minecraft/server/level/ServerChunkCache.java.patch b/patches/minecraft/net/minecraft/server/level/ServerChunkCache.java.patch index 76e7e9f82d..872f65af35 100644 --- a/patches/minecraft/net/minecraft/server/level/ServerChunkCache.java.patch +++ b/patches/minecraft/net/minecraft/server/level/ServerChunkCache.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/ServerChunkCache.java +++ b/net/minecraft/server/level/ServerChunkCache.java -@@ -205,6 +_,10 @@ +@@ -187,6 +_,10 @@ if (chunkholder == null) { return null; } else { @@ -11,7 +11,7 @@ ChunkAccess chunkaccess1 = chunkholder.getChunkIfPresent(ChunkStatus.FULL); if (chunkaccess1 != null) { this.storeInCache(i, chunkaccess1, ChunkStatus.FULL); -@@ -624,5 +_,17 @@ +@@ -623,5 +_,17 @@ return super.pollTask(); } } diff --git a/patches/minecraft/net/minecraft/server/level/ServerEntity.java.patch b/patches/minecraft/net/minecraft/server/level/ServerEntity.java.patch index 7413ea0a14..a46a07c1f7 100644 --- a/patches/minecraft/net/minecraft/server/level/ServerEntity.java.patch +++ b/patches/minecraft/net/minecraft/server/level/ServerEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/ServerEntity.java +++ b/net/minecraft/server/level/ServerEntity.java -@@ -264,6 +_,7 @@ +@@ -250,6 +_,7 @@ public void removePairing(ServerPlayer p_8535_) { this.entity.stopSeenByPlayer(p_8535_); p_8535_.connection.send(new ClientboundRemoveEntitiesPacket(this.entity.getId())); @@ -8,7 +8,7 @@ } public void addPairing(ServerPlayer p_8542_) { -@@ -271,6 +_,7 @@ +@@ -257,6 +_,7 @@ this.sendPairingData(p_8542_, list::add); p_8542_.connection.send(new ClientboundBundlePacket(list)); this.entity.startSeenByPlayer(p_8542_); diff --git a/patches/minecraft/net/minecraft/server/level/ServerLevel.java.patch b/patches/minecraft/net/minecraft/server/level/ServerLevel.java.patch index 01f3d05329..ec924ce506 100644 --- a/patches/minecraft/net/minecraft/server/level/ServerLevel.java.patch +++ b/patches/minecraft/net/minecraft/server/level/ServerLevel.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java -@@ -203,10 +_,12 @@ +@@ -209,11 +_,13 @@ @Nullable private EndDragonFight dragonFight; final Int2ObjectMap dragonParts = new Int2ObjectOpenHashMap<>(); @@ -9,11 +9,12 @@ private final StructureCheck structureCheck; private final boolean tickTime; private final RandomSequences randomSequences; + final LevelDebugSynchronizers debugSynchronizers = new LevelDebugSynchronizers(this); + private net.minecraftforge.common.util.LevelCapabilityData capabilityData; public ServerLevel( MinecraftServer p_214999_, -@@ -290,6 +_,18 @@ +@@ -294,6 +_,18 @@ this.gameEventDispatcher = new GameEventDispatcher(this); this.randomSequences = Objects.requireNonNullElseGet(p_288977_, () -> this.getDataStorage().computeIfAbsent(RandomSequences.TYPE)); this.waypointManager = new ServerWaypointManager(); @@ -32,7 +33,7 @@ } @Deprecated -@@ -331,8 +_,8 @@ +@@ -335,8 +_,8 @@ int i = this.getGameRules().getInt(GameRules.RULE_PLAYERS_SLEEPING_PERCENTAGE); if (this.sleepStatus.areEnoughSleeping(i) && this.sleepStatus.areEnoughDeepSleeping(i, this.players)) { if (this.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT)) { @@ -43,7 +44,7 @@ } this.wakeUpAllPlayers(); -@@ -399,6 +_,7 @@ +@@ -407,6 +_,7 @@ p_358707_.stopRiding(); } @@ -51,7 +52,7 @@ profilerfiller.push("tick"); this.guardEntityTick(this::tickNonPassenger, p_358707_); profilerfiller.pop(); -@@ -534,6 +_,7 @@ +@@ -552,6 +_,7 @@ BlockPos blockpos = this.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING, p_300602_); BlockPos blockpos1 = blockpos.below(); Biome biome = this.getBiome(blockpos).value(); @@ -59,7 +60,7 @@ if (biome.shouldFreeze(this, blockpos1)) { this.setBlockAndUpdate(blockpos1, Blocks.ICE.defaultBlockState()); } -@@ -713,8 +_,8 @@ +@@ -731,8 +_,8 @@ this.server.getPlayerList().broadcastAll(new ClientboundGameEventPacket(ClientboundGameEventPacket.START_RAINING, 0.0F)); } @@ -70,7 +71,7 @@ } } -@@ -751,6 +_,7 @@ +@@ -769,6 +_,7 @@ p_8648_.tickCount++; profilerfiller.push(() -> BuiltInRegistries.ENTITY_TYPE.getKey(p_8648_.getType()).toString()); profilerfiller.incrementCounter("tickNonPassenger"); @@ -78,7 +79,7 @@ p_8648_.tick(); profilerfiller.pop(); -@@ -768,6 +_,7 @@ +@@ -786,6 +_,7 @@ ProfilerFiller profilerfiller = Profiler.get(); profilerfiller.push(() -> BuiltInRegistries.ENTITY_TYPE.getKey(p_8664_.getType()).toString()); profilerfiller.incrementCounter("tickPassenger"); @@ -86,7 +87,7 @@ p_8664_.rideTick(); profilerfiller.pop(); -@@ -814,6 +_,7 @@ +@@ -832,6 +_,7 @@ } else { this.entityManager.autoSave(); } @@ -94,7 +95,7 @@ } } -@@ -908,6 +_,7 @@ +@@ -926,6 +_,7 @@ } private void addPlayer(ServerPlayer p_8854_) { @@ -102,7 +103,7 @@ Entity entity = this.getEntity(p_8854_.getUUID()); if (entity != null) { LOGGER.warn("Force-added player with duplicate UUID {}", p_8854_.getUUID()); -@@ -915,7 +_,8 @@ +@@ -933,7 +_,8 @@ this.removePlayerImmediately((ServerPlayer)entity, Entity.RemovalReason.DISCARDED); } @@ -112,7 +113,7 @@ } private boolean addEntity(Entity p_8873_) { -@@ -923,7 +_,12 @@ +@@ -941,7 +_,12 @@ LOGGER.warn("Tried to add entity {} but it was marked as removed already", EntityType.getKey(p_8873_.getType())); return false; } else { @@ -126,7 +127,7 @@ } } -@@ -971,6 +_,12 @@ +@@ -990,6 +_,12 @@ float p_263520_, long p_263490_ ) { @@ -139,7 +140,7 @@ this.server .getPlayerList() .broadcast( -@@ -988,6 +_,12 @@ +@@ -1007,6 +_,12 @@ public void playSeededSound( @Nullable Entity p_392657_, Entity p_394285_, Holder p_263412_, SoundSource p_263338_, float p_263352_, float p_263390_, long p_263403_ ) { @@ -152,7 +153,7 @@ this.server .getPlayerList() .broadcast( -@@ -1046,6 +_,7 @@ +@@ -1065,6 +_,7 @@ @Override public void gameEvent(Holder p_334475_, Vec3 p_215042_, GameEvent.Context p_215043_) { @@ -160,7 +161,7 @@ this.gameEventDispatcher.post(p_334475_, p_215042_, p_215043_); } -@@ -1084,16 +_,24 @@ +@@ -1103,16 +_,24 @@ @Override public void updateNeighborsAt(BlockPos p_215045_, Block p_215046_) { @@ -185,7 +186,7 @@ this.neighborUpdater.updateNeighborsAtExceptFromFacing(p_215052_, p_215053_, p_215054_, p_370072_); } -@@ -1139,12 +_,14 @@ +@@ -1159,12 +_,14 @@ Explosion.BlockInteraction explosion$blockinteraction = switch (p_255827_) { case NONE -> Explosion.BlockInteraction.KEEP; case BLOCK -> this.getDestroyType(GameRules.RULE_BLOCK_EXPLOSION_DROP_DECAY); @@ -198,11 +199,11 @@ ServerExplosion serverexplosion = new ServerExplosion(this, p_256039_, p_255778_, p_256002_, vec3, p_256045_, p_255686_, explosion$blockinteraction); + if (net.minecraftforge.event.ForgeEventFactory.onExplosionStart(this, serverexplosion)) + return; - serverexplosion.explode(); + int i = serverexplosion.explode(); ParticleOptions particleoptions = serverexplosion.isSmall() ? p_310962_ : p_310322_; -@@ -1737,6 +_,11 @@ - return this.chunkSource.getGenerator().getSeaLevel(); +@@ -1792,6 +_,11 @@ + return this.debugSynchronizers; } + @Override @@ -213,7 +214,7 @@ final class EntityCallbacks implements LevelCallback { public void onCreated(Entity p_143355_) { if (p_143355_ instanceof WaypointTransmitter waypointtransmitter && waypointtransmitter.isTransmittingWaypoint()) { -@@ -1792,6 +_,12 @@ +@@ -1847,6 +_,12 @@ } } @@ -226,7 +227,7 @@ p_143371_.updateDynamicGameEventListener(DynamicGameEventListener::add); } -@@ -1820,7 +_,16 @@ +@@ -1875,8 +_,17 @@ } } @@ -237,6 +238,7 @@ + } + p_143375_.updateDynamicGameEventListener(DynamicGameEventListener::remove); + ServerLevel.this.debugSynchronizers.dropEntity(p_143375_); + + p_143375_.onRemovedFromWorld(); + net.minecraftforge.event.ForgeEventFactory.onEntityLeaveLevel(p_143375_, ServerLevel.this); diff --git a/patches/minecraft/net/minecraft/server/level/ServerPlayer.java.patch b/patches/minecraft/net/minecraft/server/level/ServerPlayer.java.patch index 94682be64f..3b4eb9d3f1 100644 --- a/patches/minecraft/net/minecraft/server/level/ServerPlayer.java.patch +++ b/patches/minecraft/net/minecraft/server/level/ServerPlayer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/ServerPlayer.java +++ b/net/minecraft/server/level/ServerPlayer.java -@@ -196,7 +_,8 @@ +@@ -204,7 +_,8 @@ import net.minecraft.world.scores.criteria.ObjectiveCriteria; import org.slf4j.Logger; @@ -10,7 +10,7 @@ private static final Logger LOGGER = LogUtils.getLogger(); private static final int NEUTRAL_MOB_DEATH_NOTIFICATION_RADII_XZ = 32; private static final int NEUTRAL_MOB_DEATH_NOTIFICATION_RADII_Y = 10; -@@ -813,6 +_,7 @@ +@@ -874,6 +_,7 @@ @Override public void die(DamageSource p_9035_) { @@ -18,7 +18,7 @@ this.gameEvent(GameEvent.ENTITY_DIE); boolean flag = this.level().getGameRules().getBoolean(GameRules.RULE_SHOWDEATHMESSAGES); if (flag) { -@@ -1010,6 +_,7 @@ +@@ -1082,6 +_,7 @@ @Nullable public ServerPlayer teleport(TeleportTransition p_361322_) { @@ -26,7 +26,7 @@ if (this.isRemoved()) { return null; } else { -@@ -1037,7 +_,7 @@ +@@ -1109,7 +_,7 @@ PlayerList playerlist = this.server.getPlayerList(); playerlist.sendPlayerPermissionLevel(this); serverlevel1.removePlayerImmediately(this, Entity.RemovalReason.CHANGED_DIMENSION); @@ -35,7 +35,7 @@ ProfilerFiller profilerfiller = Profiler.get(); profilerfiller.push("moving"); if (resourcekey == Level.OVERWORLD && serverlevel.dimension() == Level.NETHER) { -@@ -1062,6 +_,7 @@ +@@ -1134,6 +_,7 @@ this.lastSentHealth = -1.0F; this.lastSentFood = -1; this.teleportSpectators(p_361322_, serverlevel1); @@ -43,7 +43,7 @@ return this; } } -@@ -1102,6 +_,9 @@ +@@ -1175,6 +_,9 @@ @Override public Either startSleepInBed(BlockPos p_9115_) { @@ -53,16 +53,16 @@ Direction direction = this.level().getBlockState(p_9115_).getValue(HorizontalDirectionalBlock.FACING); if (this.isSleeping() || !this.isAlive()) { return Either.left(Player.BedSleepingProblem.OTHER_PROBLEM); -@@ -1113,7 +_,7 @@ - return Either.left(Player.BedSleepingProblem.OBSTRUCTED); - } else { - this.setRespawnPosition(new ServerPlayer.RespawnConfig(this.level().dimension(), p_9115_, this.getYRot(), false), true); +@@ -1189,7 +_,7 @@ + new ServerPlayer.RespawnConfig(LevelData.RespawnData.of(this.level().dimension(), p_9115_, this.getYRot(), this.getXRot()), false), + true + ); - if (this.level().isBrightOutside()) { + if (!net.minecraftforge.event.ForgeEventFactory.onSleepingTimeCheck(this, optAt)) { return Either.left(Player.BedSleepingProblem.NOT_POSSIBLE_NOW); } else { if (!this.isCreative()) { -@@ -1159,6 +_,7 @@ +@@ -1235,6 +_,7 @@ } private boolean bedInRange(BlockPos p_9117_, Direction p_9118_) { @@ -70,7 +70,7 @@ return this.isReachableBedBlock(p_9117_) || this.isReachableBedBlock(p_9117_.relative(p_9118_.getOpposite())); } -@@ -1262,6 +_,7 @@ +@@ -1338,6 +_,7 @@ this.connection.send(new ClientboundOpenScreenPacket(abstractcontainermenu.containerId, abstractcontainermenu.getType(), p_9033_.getDisplayName())); this.initMenu(abstractcontainermenu); this.containerMenu = abstractcontainermenu; @@ -78,7 +78,7 @@ return OptionalInt.of(this.containerCounter); } } -@@ -1311,6 +_,7 @@ +@@ -1387,6 +_,7 @@ public void doCloseContainer() { this.containerMenu.removed(this); this.inventoryMenu.transferState(this.containerMenu); @@ -86,7 +86,7 @@ this.containerMenu = this.inventoryMenu; } -@@ -1536,6 +_,15 @@ +@@ -1613,6 +_,15 @@ this.setShoulderEntityLeft(p_9016_.getShoulderEntityLeft()); this.setShoulderEntityRight(p_9016_.getShoulderEntityRight()); this.setLastDeathLocation(p_9016_.getLastDeathLocation()); @@ -102,7 +102,7 @@ } @Override -@@ -1635,6 +_,7 @@ +@@ -1712,6 +_,7 @@ public boolean setGameMode(GameType p_143404_) { boolean flag = this.isSpectator(); @@ -110,7 +110,7 @@ if (!this.gameMode.changeGameModeForPlayer(p_143404_)) { return false; } else { -@@ -1787,6 +_,9 @@ +@@ -1864,6 +_,9 @@ public void setCamera(@Nullable Entity p_9214_) { Entity entity = this.getCamera(); this.camera = (Entity)(p_9214_ == null ? this : p_9214_); @@ -120,7 +120,7 @@ if (entity != this.camera) { if (this.camera.level() instanceof ServerLevel serverlevel) { this.teleportTo( -@@ -1825,7 +_,11 @@ +@@ -1902,7 +_,11 @@ @Nullable public Component getTabListDisplayName() { @@ -133,7 +133,7 @@ } public int getTabListOrder() { -@@ -1860,6 +_,7 @@ +@@ -1937,6 +_,7 @@ } public void setRespawnPosition(@Nullable ServerPlayer.RespawnConfig p_396560_, boolean p_9162_) { @@ -141,7 +141,7 @@ if (p_9162_ && p_396560_ != null && !p_396560_.isSamePosition(this.respawnConfig)) { this.sendSystemMessage(SPAWN_SET_MESSAGE); } -@@ -1969,9 +_,12 @@ +@@ -2042,9 +_,12 @@ public boolean drop(boolean p_182295_) { Inventory inventory = this.getInventory(); @@ -155,7 +155,7 @@ } @Override -@@ -2075,6 +_,75 @@ +@@ -2148,6 +_,75 @@ @Nullable public BlockPos getRaidOmenPosition() { return this.raidOmenPosition; @@ -226,7 +226,7 @@ + Component oldName = this.tabListDisplayName; + this.tabListDisplayName = net.minecraftforge.event.ForgeEventFactory.getPlayerTabListDisplayName(this); + if (!java.util.Objects.equals(oldName, this.tabListDisplayName)) { -+ this.getServer().getPlayerList().broadcastAll(new net.minecraft.network.protocol.game.ClientboundPlayerInfoUpdatePacket(net.minecraft.network.protocol.game.ClientboundPlayerInfoUpdatePacket.Action.UPDATE_DISPLAY_NAME, this)); ++ this.level().getServer().getPlayerList().broadcastAll(new net.minecraft.network.protocol.game.ClientboundPlayerInfoUpdatePacket(net.minecraft.network.protocol.game.ClientboundPlayerInfoUpdatePacket.Action.UPDATE_DISPLAY_NAME, this)); + } } diff --git a/patches/minecraft/net/minecraft/server/level/ServerPlayerGameMode.java.patch b/patches/minecraft/net/minecraft/server/level/ServerPlayerGameMode.java.patch index 93accc091d..6abacb0110 100644 --- a/patches/minecraft/net/minecraft/server/level/ServerPlayerGameMode.java.patch +++ b/patches/minecraft/net/minecraft/server/level/ServerPlayerGameMode.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/ServerPlayerGameMode.java +++ b/net/minecraft/server/level/ServerPlayerGameMode.java -@@ -131,6 +_,10 @@ +@@ -151,6 +_,10 @@ } public void handleBlockBreakAction(BlockPos p_215120_, ServerboundPlayerActionPacket.Action p_215121_, Direction p_215122_, int p_215123_, int p_215124_) { @@ -11,7 +11,7 @@ if (!this.player.canInteractWithBlock(p_215120_, 1.0)) { this.debugLogging(p_215120_, false, p_215124_, "too far"); } else if (p_215120_.getY() > p_215123_) { -@@ -159,6 +_,7 @@ +@@ -179,6 +_,7 @@ float f = 1.0F; BlockState blockstate = this.level.getBlockState(p_215120_); if (!blockstate.isAir()) { @@ -19,7 +19,7 @@ EnchantmentHelper.onHitBlock( this.level, this.player.getMainHandItem(), -@@ -170,6 +_,7 @@ +@@ -190,6 +_,7 @@ p_343810_ -> this.player.onEquippedItemBroken(p_343810_, EquipmentSlot.MAINHAND) ); blockstate.attack(this.level, p_215120_, this.player); @@ -27,7 +27,7 @@ f = blockstate.getDestroyProgress(this.player, this.player.level(), p_215120_); } -@@ -236,7 +_,8 @@ +@@ -256,7 +_,8 @@ public boolean destroyBlock(BlockPos p_9281_) { BlockState blockstate1 = this.level.getBlockState(p_9281_); @@ -37,7 +37,7 @@ return false; } else { BlockEntity blockentity = this.level.getBlockEntity(p_9281_); -@@ -244,30 +_,47 @@ +@@ -264,34 +_,50 @@ if (block instanceof GameMasterBlock && !this.player.canUseGameMasterBlocks()) { this.level.sendBlockUpdated(p_9281_, blockstate1, blockstate1, 3); return false; @@ -48,6 +48,10 @@ } else { - BlockState blockstate = block.playerWillDestroy(this.level, p_9281_, blockstate1, this.player); - boolean flag1 = this.level.removeBlock(p_9281_, false); +- if (SharedConstants.DEBUG_BLOCK_BREAK) { +- LOGGER.info("server broke {} {} -> {}", p_9281_, blockstate, this.level.getBlockState(p_9281_)); +- } +- - if (flag1) { - block.destroy(this.level, p_9281_, blockstate); - } @@ -82,17 +86,20 @@ } + } + -+ private boolean removeBlock(BlockPos p_180235_1_, boolean canHarvest) { -+ BlockState state = this.level.getBlockState(p_180235_1_); -+ boolean removed = state.onDestroyedByPlayer(this.level, p_180235_1_, this.player, canHarvest, this.level.getFluidState(p_180235_1_)); ++ private boolean removeBlock(BlockPos pos, boolean canHarvest) { ++ BlockState state = this.level.getBlockState(pos); ++ boolean removed = state.onDestroyedByPlayer(this.level, pos, this.player, canHarvest, this.level.getFluidState(pos)); + if (removed) { -+ state.getBlock().destroy(this.level, p_180235_1_, state); ++ if (SharedConstants.DEBUG_BLOCK_BREAK) { ++ LOGGER.info("server broke {} {} -> {}", pos, state, this.level.getBlockState(pos)); ++ } ++ state.getBlock().destroy(this.level, pos, state); + } + return removed; } public InteractionResult useItem(ServerPlayer p_9262_, Level p_9263_, ItemStack p_9264_, InteractionHand p_9265_) { -@@ -276,6 +_,8 @@ +@@ -300,6 +_,8 @@ } else if (p_9262_.getCooldowns().isOnCooldown(p_9264_)) { return InteractionResult.PASS; } else { @@ -101,7 +108,7 @@ int i = p_9264_.getCount(); int j = p_9264_.getDamageValue(); InteractionResult interactionresult = p_9264_.use(p_9263_, p_9262_, p_9265_); -@@ -314,6 +_,11 @@ +@@ -338,6 +_,11 @@ if (!blockstate.getBlock().isEnabled(p_9267_.enabledFeatures())) { return InteractionResult.FAIL; } else if (this.gameModeForPlayer == GameType.SPECTATOR) { @@ -113,7 +120,7 @@ MenuProvider menuprovider = blockstate.getMenuProvider(p_9267_, blockpos); if (menuprovider != null) { p_9266_.openMenu(menuprovider); -@@ -322,10 +_,16 @@ +@@ -346,10 +_,16 @@ return InteractionResult.PASS; } } else { @@ -131,7 +138,7 @@ InteractionResult interactionresult = blockstate.useItemOn(p_9266_.getItemInHand(p_9269_), p_9267_, p_9266_, p_9269_, p_9270_); if (interactionresult.consumesAction()) { CriteriaTriggers.ITEM_USED_ON_BLOCK.trigger(p_9266_, blockpos, itemstack); -@@ -341,8 +_,8 @@ +@@ -365,8 +_,8 @@ } } diff --git a/patches/minecraft/net/minecraft/server/level/ThreadedLevelLightEngine.java.patch b/patches/minecraft/net/minecraft/server/level/ThreadedLevelLightEngine.java.patch index 308661d58d..106618b1e4 100644 --- a/patches/minecraft/net/minecraft/server/level/ThreadedLevelLightEngine.java.patch +++ b/patches/minecraft/net/minecraft/server/level/ThreadedLevelLightEngine.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/ThreadedLevelLightEngine.java +++ b/net/minecraft/server/level/ThreadedLevelLightEngine.java -@@ -171,6 +_,7 @@ +@@ -176,6 +_,7 @@ }, () -> "lightChunk " + chunkpos + " " + p_9355_)); return CompletableFuture.supplyAsync(() -> { p_9354_.setLightCorrect(true); diff --git a/patches/minecraft/net/minecraft/server/network/ConfigurationTask.java.patch b/patches/minecraft/net/minecraft/server/network/ConfigurationTask.java.patch index 4a6ae71c38..03ccb6d590 100644 --- a/patches/minecraft/net/minecraft/server/network/ConfigurationTask.java.patch +++ b/patches/minecraft/net/minecraft/server/network/ConfigurationTask.java.patch @@ -10,4 +10,4 @@ + void start(Consumer> p_299398_); - ConfigurationTask.Type type(); + default boolean tick() { diff --git a/patches/minecraft/net/minecraft/server/network/PlayerChunkSender.java.patch b/patches/minecraft/net/minecraft/server/network/PlayerChunkSender.java.patch index 151d0e5d14..28b9533f0f 100644 --- a/patches/minecraft/net/minecraft/server/network/PlayerChunkSender.java.patch +++ b/patches/minecraft/net/minecraft/server/network/PlayerChunkSender.java.patch @@ -8,10 +8,10 @@ } } -@@ -77,6 +_,7 @@ - p_299748_.send(new ClientboundLevelChunkWithLightPacket(p_297712_, p_298120_.getLightEngine(), null, null)); - ChunkPos chunkpos = p_297712_.getPos(); - DebugPackets.sendPoiPacketsForChunk(p_298120_, chunkpos); +@@ -81,6 +_,7 @@ + } + + p_298120_.debugSynchronizers().startTrackingChunk(p_299748_.player, p_297712_.getPos()); + net.minecraftforge.event.ForgeEventFactory.fireChunkWatch(p_299748_.player, p_297712_, p_298120_); } diff --git a/patches/minecraft/net/minecraft/server/network/ServerCommonPacketListenerImpl.java.patch b/patches/minecraft/net/minecraft/server/network/ServerCommonPacketListenerImpl.java.patch index 8d77df36e5..8c96fcb402 100644 --- a/patches/minecraft/net/minecraft/server/network/ServerCommonPacketListenerImpl.java.patch +++ b/patches/minecraft/net/minecraft/server/network/ServerCommonPacketListenerImpl.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/network/ServerCommonPacketListenerImpl.java +++ b/net/minecraft/server/network/ServerCommonPacketListenerImpl.java -@@ -92,6 +_,7 @@ +@@ -93,6 +_,7 @@ @Override public void handleCustomPayload(ServerboundCustomPayloadPacket p_300164_) { @@ -8,7 +8,7 @@ } @Override -@@ -201,5 +_,9 @@ +@@ -202,5 +_,9 @@ protected CommonListenerCookie createCookie(ClientInformation p_297318_) { return new CommonListenerCookie(this.playerProfile(), this.latency, p_297318_, this.transferred); diff --git a/patches/minecraft/net/minecraft/server/network/ServerConfigurationPacketListenerImpl.java.patch b/patches/minecraft/net/minecraft/server/network/ServerConfigurationPacketListenerImpl.java.patch index a917068e1c..f0687b4725 100644 --- a/patches/minecraft/net/minecraft/server/network/ServerConfigurationPacketListenerImpl.java.patch +++ b/patches/minecraft/net/minecraft/server/network/ServerConfigurationPacketListenerImpl.java.patch @@ -1,17 +1,17 @@ --- a/net/minecraft/server/network/ServerConfigurationPacketListenerImpl.java +++ b/net/minecraft/server/network/ServerConfigurationPacketListenerImpl.java -@@ -41,6 +_,7 @@ - public class ServerConfigurationPacketListenerImpl extends ServerCommonPacketListenerImpl implements ServerConfigurationPacketListener, TickablePacketListener { +@@ -47,6 +_,7 @@ private static final Logger LOGGER = LogUtils.getLogger(); private static final Component DISCONNECT_REASON_INVALID_DATA = Component.translatable("multiplayer.disconnect.invalid_player_data"); + private static final Component DISCONNECT_REASON_CONFIGURATION_ERROR = Component.translatable("multiplayer.disconnect.configuration_error"); + private static final ConfigurationTask.Type VANILLA_START = new ConfigurationTask.Type("vanilla_start"); private final GameProfile gameProfile; private final Queue configurationTasks = new ConcurrentLinkedQueue<>(); @Nullable -@@ -48,11 +_,13 @@ - private ClientInformation clientInformation; - @Nullable +@@ -56,11 +_,13 @@ private SynchronizeRegistriesTask synchronizeRegistriesTask; + @Nullable + private PrepareSpawnTask prepareSpawnTask; + private final net.minecraftforge.network.config.ConfigurationTaskContext taskContext; public ServerConfigurationPacketListenerImpl(MinecraftServer p_301415_, Connection p_298106_, CommonListenerCookie p_301309_) { @@ -22,7 +22,7 @@ } @Override -@@ -71,18 +_,23 @@ +@@ -84,18 +_,23 @@ return this.connection.isConnected(); } @@ -46,14 +46,14 @@ this.configurationTasks.add(this.synchronizeRegistriesTask); + this.configurationTasks.add(new net.minecraftforge.network.config.SimpleConfigurationTask(VANILLA_START, this::vanillaStart)); this.addOptionalTasks(); - this.configurationTasks.add(new JoinWorldTask()); - this.startNextTask(); -@@ -161,7 +_,7 @@ - ConfigurationTask configurationtask = this.configurationTasks.poll(); - if (configurationtask != null) { - this.currentTask = configurationtask; -- configurationtask.start(this::send); -+ configurationtask.start(this.taskContext); - } - } + this.returnToWorld(); } +@@ -211,7 +_,7 @@ + this.currentTask = configurationtask; + + try { +- configurationtask.start(this::send); ++ configurationtask.start(this.taskContext); + } catch (Exception exception) { + LOGGER.error("Failed to start configuration task {}", configurationtask.type(), exception); + this.disconnect(DISCONNECT_REASON_CONFIGURATION_ERROR); diff --git a/patches/minecraft/net/minecraft/server/network/ServerConnectionListener.java.patch b/patches/minecraft/net/minecraft/server/network/ServerConnectionListener.java.patch index 1cf7db3895..ee8d6f9eb8 100644 --- a/patches/minecraft/net/minecraft/server/network/ServerConnectionListener.java.patch +++ b/patches/minecraft/net/minecraft/server/network/ServerConnectionListener.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/network/ServerConnectionListener.java +++ b/net/minecraft/server/network/ServerConnectionListener.java -@@ -48,11 +_,12 @@ +@@ -49,11 +_,12 @@ public class ServerConnectionListener { private static final Logger LOGGER = LogUtils.getLogger(); @@ -15,7 +15,7 @@ ); final MinecraftServer server; public volatile boolean running; -@@ -65,6 +_,8 @@ +@@ -66,6 +_,8 @@ } public void startTcpServerListener(@Nullable InetAddress p_9712_, int p_9713_) throws IOException { @@ -24,7 +24,7 @@ synchronized (this.channels) { Class oclass; EventLoopGroup eventloopgroup; -@@ -86,7 +_,7 @@ +@@ -87,7 +_,7 @@ } catch (ChannelException channelexception) { } diff --git a/patches/minecraft/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch b/patches/minecraft/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch index 6e63a38bcf..b8a70951de 100644 --- a/patches/minecraft/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch +++ b/patches/minecraft/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -1168,9 +_,10 @@ +@@ -1175,9 +_,10 @@ switch (serverboundplayeractionpacket$action) { case SWAP_ITEM_WITH_OFFHAND: if (!this.player.isSpectator()) { @@ -14,7 +14,7 @@ this.player.stopUsingItem(); } -@@ -1368,8 +_,9 @@ +@@ -1376,8 +_,9 @@ } CompletableFuture completablefuture = this.filterTextPacket(playerchatmessage.signedContent()); @@ -25,7 +25,7 @@ PlayerChatMessage playerchatmessage1 = playerchatmessage.withUnsignedContent(component).filter(p_296589_.mask()); this.broadcastChatMessage(playerchatmessage1); }); -@@ -1699,7 +_,7 @@ +@@ -1707,7 +_,7 @@ @Override public void onInteraction(InteractionHand p_143682_, Vec3 p_143683_) { @@ -34,7 +34,7 @@ } @Override -@@ -2011,6 +_,7 @@ +@@ -2021,6 +_,7 @@ @Override public void handleCustomPayload(ServerboundCustomPayloadPacket p_329963_) { diff --git a/patches/minecraft/net/minecraft/server/network/ServerLoginPacketListenerImpl.java.patch b/patches/minecraft/net/minecraft/server/network/ServerLoginPacketListenerImpl.java.patch index 5ee7b87953..cd49971418 100644 --- a/patches/minecraft/net/minecraft/server/network/ServerLoginPacketListenerImpl.java.patch +++ b/patches/minecraft/net/minecraft/server/network/ServerLoginPacketListenerImpl.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/network/ServerLoginPacketListenerImpl.java +++ b/net/minecraft/server/network/ServerLoginPacketListenerImpl.java -@@ -183,7 +_,7 @@ +@@ -184,7 +_,7 @@ throw new IllegalStateException("Protocol error", cryptexception); } @@ -9,7 +9,7 @@ @Override public void run() { String s1 = Objects.requireNonNull(ServerLoginPacketListenerImpl.this.requestedUsername, "Player name not initialized"); -@@ -226,6 +_,7 @@ +@@ -227,6 +_,7 @@ @Override public void handleCustomQueryPacket(ServerboundCustomQueryAnswerPacket p_297965_) { @@ -17,7 +17,7 @@ this.disconnect(ServerCommonPacketListenerImpl.DISCONNECT_UNEXPECTED_QUERY); } -@@ -250,6 +_,11 @@ +@@ -251,6 +_,11 @@ @Override public void handleCookieResponse(ServerboundCookieResponsePacket p_333672_) { this.disconnect(ServerCommonPacketListenerImpl.DISCONNECT_UNEXPECTED_QUERY); diff --git a/patches/minecraft/net/minecraft/server/network/config/PrepareSpawnTask.java.patch b/patches/minecraft/net/minecraft/server/network/config/PrepareSpawnTask.java.patch new file mode 100644 index 0000000000..223f75483a --- /dev/null +++ b/patches/minecraft/net/minecraft/server/network/config/PrepareSpawnTask.java.patch @@ -0,0 +1,10 @@ +--- a/net/minecraft/server/network/config/PrepareSpawnTask.java ++++ b/net/minecraft/server/network/config/PrepareSpawnTask.java +@@ -184,6 +_,7 @@ + .loadPlayerData(PrepareSpawnTask.this.nameAndId) + .map(p_423730_ -> TagValueInput.create(problemreporter$scopedcollector, PrepareSpawnTask.this.server.registryAccess(), p_423730_)); + optional.ifPresent(serverplayer::load); ++ optional.ifPresent(v -> net.minecraftforge.event.ForgeEventFactory.firePlayerLoadingEvent(serverplayer, PrepareSpawnTask.this.server.getPlayerList().getPlayerIo().getPlayerDataFolder(), PrepareSpawnTask.this.nameAndId.id().toString())); + serverplayer.snapTo(this.spawnPosition, this.spawnAngle.x, this.spawnAngle.y); + PrepareSpawnTask.this.server.getPlayerList().placeNewPlayer(p_429818_, serverplayer, p_430225_); + optional.ifPresent(p_422988_ -> { diff --git a/patches/minecraft/net/minecraft/server/packs/repository/Pack.java.patch b/patches/minecraft/net/minecraft/server/packs/repository/Pack.java.patch index d702d88be2..959f44ed96 100644 --- a/patches/minecraft/net/minecraft/server/packs/repository/Pack.java.patch +++ b/patches/minecraft/net/minecraft/server/packs/repository/Pack.java.patch @@ -16,16 +16,16 @@ } @Nullable -@@ -55,7 +_,7 @@ - PackCompatibility packcompatibility = PackCompatibility.forVersion(inclusiverange, p_333544_); - OverlayMetadataSection overlaymetadatasection = packresources.getMetadataSection(OverlayMetadataSection.TYPE); - List list = overlaymetadatasection != null ? overlaymetadatasection.overlaysForVersion(p_333544_) : List.of(); +@@ -58,7 +_,7 @@ + PackCompatibility packcompatibility = PackCompatibility.forVersion(packmetadatasection.supportedFormats(), p_425340_); + OverlayMetadataSection overlaymetadatasection = packresources.getMetadataSection(OverlayMetadataSection.forPackType(p_426910_)); + List list = overlaymetadatasection != null ? overlaymetadatasection.overlaysForVersion(p_425340_) : List.of(); - pack$metadata = new Pack.Metadata(packmetadatasection.description(), packcompatibility, featureflagset, list); + pack$metadata = new Pack.Metadata(packmetadatasection.description(), packcompatibility, featureflagset, list, packresources.isHidden()); } return pack$metadata; -@@ -132,6 +_,10 @@ +@@ -120,6 +_,10 @@ return this.location.source(); } @@ -36,7 +36,7 @@ @Override public boolean equals(Object p_10448_) { if (this == p_10448_) { -@@ -146,7 +_,10 @@ +@@ -134,7 +_,10 @@ return this.location.hashCode(); } diff --git a/patches/minecraft/net/minecraft/server/packs/repository/ServerPacksSource.java.patch b/patches/minecraft/net/minecraft/server/packs/repository/ServerPacksSource.java.patch index 3d75cba5ad..28766a19a1 100644 --- a/patches/minecraft/net/minecraft/server/packs/repository/ServerPacksSource.java.patch +++ b/patches/minecraft/net/minecraft/server/packs/repository/ServerPacksSource.java.patch @@ -6,7 +6,7 @@ public static PackRepository createPackRepository(Path p_251569_, DirectoryValidator p_300268_) { - return new PackRepository(new ServerPacksSource(p_300268_), new FolderRepositorySource(p_251569_, PackType.SERVER_DATA, PackSource.WORLD, p_300268_)); + var ret = new PackRepository(new ServerPacksSource(p_300268_), new FolderRepositorySource(p_251569_, PackType.SERVER_DATA, PackSource.WORLD, p_300268_)); -+ net.minecraftforge.fml.ModLoader.get().postEvent(new net.minecraftforge.event.AddPackFindersEvent(PackType.SERVER_DATA, ret::addPackFinder)); ++ net.minecraftforge.fml.ModLoader.postEvent(new net.minecraftforge.event.AddPackFindersEvent(PackType.SERVER_DATA, ret::addPackFinder)); + return ret; } diff --git a/patches/minecraft/net/minecraft/server/players/PlayerList.java.patch b/patches/minecraft/net/minecraft/server/players/PlayerList.java.patch index 64c6341a6d..1d1138ecb9 100644 --- a/patches/minecraft/net/minecraft/server/players/PlayerList.java.patch +++ b/patches/minecraft/net/minecraft/server/players/PlayerList.java.patch @@ -1,38 +1,30 @@ --- a/net/minecraft/server/players/PlayerList.java +++ b/net/minecraft/server/players/PlayerList.java -@@ -128,6 +_,7 @@ +@@ -123,6 +_,7 @@ + private int simulationDistance; private boolean allowCommandsForAllPlayers; - private static final boolean ALLOW_LOGOUTIVATOR = false; private int sendAllPlayerInfoIn; + private final List playersView = java.util.Collections.unmodifiableList(players); - public PlayerList(MinecraftServer p_203842_, LayeredRegistryAccess p_251844_, PlayerDataStorage p_203844_, int p_203845_) { + public PlayerList(MinecraftServer p_203842_, LayeredRegistryAccess p_251844_, PlayerDataStorage p_203844_, NotificationService p_425184_) { this.server = p_203842_; -@@ -207,6 +_,7 @@ - servergamepacketlistenerimpl.send(new ClientboundPlayerAbilitiesPacket(p_11263_.getAbilities())); - servergamepacketlistenerimpl.send(new ClientboundSetHeldSlotPacket(p_11263_.getInventory().getSelectedSlot())); - RecipeManager recipemanager = this.server.getRecipeManager(); -+ net.minecraftforge.event.OnDatapackSyncEvent.BUS.post(new net.minecraftforge.event.OnDatapackSyncEvent(this, p_11263_)); - servergamepacketlistenerimpl.send(new ClientboundUpdateRecipesPacket(recipemanager.getSynchronizedItemProperties(), recipemanager.getSynchronizedStonecutterRecipes())); - this.sendPlayerPermissionLevel(p_11263_); - p_11263_.getStats().markAllDirty(); -@@ -241,6 +_,7 @@ - }); - p_11263_.initInventoryMenu(); - } +@@ -180,6 +_,7 @@ + servergamepacketlistenerimpl.send(new ClientboundPlayerAbilitiesPacket(p_11263_.getAbilities())); + servergamepacketlistenerimpl.send(new ClientboundSetHeldSlotPacket(p_11263_.getInventory().getSelectedSlot())); + RecipeManager recipemanager = this.server.getRecipeManager(); ++ net.minecraftforge.event.OnDatapackSyncEvent.BUS.post(new net.minecraftforge.event.OnDatapackSyncEvent(this, p_11263_)); + servergamepacketlistenerimpl.send(new ClientboundUpdateRecipesPacket(recipemanager.getSynchronizedItemProperties(), recipemanager.getSynchronizedStonecutterRecipes())); + this.sendPlayerPermissionLevel(p_11263_); + p_11263_.getStats().markAllDirty(); +@@ -210,6 +_,7 @@ + this.sendActivePlayerEffects(p_11263_); + p_11263_.initInventoryMenu(); + this.server.notificationManager().playerJoined(p_11263_); + net.minecraftforge.event.ForgeEventFactory.firePlayerLoggedIn(p_11263_); } protected void updateEntireScoreboard(ServerScoreboard p_11274_, ServerPlayer p_11275_) { -@@ -307,6 +_,7 @@ - optional = Optional.of(valueinput); - p_11225_.load(valueinput); - LOGGER.debug("loading single player"); -+ net.minecraftforge.event.ForgeEventFactory.firePlayerLoadingEvent(p_11225_, this.playerIo, p_11225_.getUUID().toString()); - } else { - optional = this.playerIo.load(p_11225_, p_410534_); - } -@@ -315,6 +_,7 @@ +@@ -279,6 +_,7 @@ } protected void save(ServerPlayer p_11277_) { @@ -40,7 +32,7 @@ this.playerIo.save(p_11277_); ServerStatsCounter serverstatscounter = this.stats.get(p_11277_.getUUID()); if (serverstatscounter != null) { -@@ -328,6 +_,7 @@ +@@ -292,6 +_,7 @@ } public void remove(ServerPlayer p_11287_) { @@ -48,36 +40,36 @@ ServerLevel serverlevel = p_11287_.level(); p_11287_.awardStat(Stats.LEAVE_GAME); this.save(p_11287_); -@@ -449,6 +_,7 @@ +@@ -413,6 +_,7 @@ this.playersByUUID.put(serverplayer.getUUID(), serverplayer); serverplayer.initInventoryMenu(); serverplayer.setHealth(serverplayer.getHealth()); + net.minecraftforge.event.ForgeEventFactory.firePlayerRespawnEvent(serverplayer, p_11238_); ServerPlayer.RespawnConfig serverplayer$respawnconfig = serverplayer.getRespawnConfig(); if (!p_11238_ && serverplayer$respawnconfig != null) { - ServerLevel serverlevel2 = this.server.getLevel(serverplayer$respawnconfig.dimension()); -@@ -558,6 +_,7 @@ + LevelData.RespawnData leveldata$respawndata = serverplayer$respawnconfig.respawnData(); +@@ -526,6 +_,7 @@ } - public void op(GameProfile p_11254_) { -+ if (net.minecraftforge.event.ForgeEventFactory.onPermissionChanged(p_11254_, this.server.getOperatorUserPermissionLevel(), this)) return; - this.ops.add(new ServerOpListEntry(p_11254_, this.server.getOperatorUserPermissionLevel(), this.ops.canBypassPlayerLimit(p_11254_))); - ServerPlayer serverplayer = this.getPlayer(p_11254_.getId()); - if (serverplayer != null) { -@@ -566,6 +_,7 @@ + public void op(NameAndId p_425211_, Optional p_427477_, Optional p_426308_) { ++ if (net.minecraftforge.event.ForgeEventFactory.onPermissionChanged(p_425211_, this.server.operatorUserPermissionLevel(), this)) return; + this.ops + .add(new ServerOpListEntry(p_425211_, p_427477_.orElse(this.server.operatorUserPermissionLevel()), p_426308_.orElse(this.ops.canBypassPlayerLimit(p_425211_)))); + ServerPlayer serverplayer = this.getPlayer(p_425211_.id()); +@@ -535,6 +_,7 @@ } - public void deop(GameProfile p_11281_) { -+ if (net.minecraftforge.event.ForgeEventFactory.onPermissionChanged(p_11281_, 0, this)) return; - this.ops.remove(p_11281_); - ServerPlayer serverplayer = this.getPlayer(p_11281_.getId()); - if (serverplayer != null) { -@@ -779,13 +_,6 @@ + public void deop(NameAndId p_428113_) { ++ if (net.minecraftforge.event.ForgeEventFactory.onPermissionChanged(p_428113_, 0, this)) return; + if (this.ops.remove(p_428113_)) { + ServerPlayer serverplayer = this.getPlayer(p_428113_.id()); + if (serverplayer != null) { +@@ -746,13 +_,6 @@ if (serverstatscounter == null) { File file1 = this.server.getWorldPath(LevelResource.PLAYER_STATS_DIR).toFile(); File file2 = new File(file1, uuid + ".json"); - if (!file2.exists()) { -- File file3 = new File(file1, p_11240_.getName().getString() + ".json"); +- File file3 = new File(file1, gameprofile.name() + ".json"); - Path path = file3.toPath(); - if (FileUtil.isPathNormalized(path) && FileUtil.isPathPortable(path) && path.startsWith(file1.getPath()) && file3.isFile()) { - file3.renameTo(file2); @@ -86,7 +78,7 @@ serverstatscounter = new ServerStatsCounter(this.server, file2); this.stats.put(uuid, serverstatscounter); -@@ -830,7 +_,7 @@ +@@ -797,7 +_,7 @@ } public List getPlayers() { @@ -95,7 +87,7 @@ } @Nullable -@@ -847,6 +_,7 @@ +@@ -825,6 +_,7 @@ playeradvancements.reload(this.server.getAdvancements()); } @@ -103,3 +95,13 @@ this.broadcastAll(new ClientboundUpdateTagsPacket(TagNetworkSerialization.serializeTagsToNetwork(this.registries))); RecipeManager recipemanager = this.server.getRecipeManager(); ClientboundUpdateRecipesPacket clientboundupdaterecipespacket = new ClientboundUpdateRecipesPacket(recipemanager.getSynchronizedItemProperties(), recipemanager.getSynchronizedStonecutterRecipes()); +@@ -837,5 +_,9 @@ + + public boolean isAllowCommandsForAllPlayers() { + return this.allowCommandsForAllPlayers; ++ } ++ ++ public PlayerDataStorage getPlayerIo() { ++ return this.playerIo; + } + } diff --git a/patches/minecraft/net/minecraft/server/rcon/RconConsoleSource.java.patch b/patches/minecraft/net/minecraft/server/rcon/RconConsoleSource.java.patch index 7f77373c9b..d07e031488 100644 --- a/patches/minecraft/net/minecraft/server/rcon/RconConsoleSource.java.patch +++ b/patches/minecraft/net/minecraft/server/rcon/RconConsoleSource.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/rcon/RconConsoleSource.java +++ b/net/minecraft/server/rcon/RconConsoleSource.java -@@ -33,7 +_,7 @@ +@@ -35,7 +_,7 @@ @Override public void sendSystemMessage(Component p_215653_) { diff --git a/patches/minecraft/net/minecraft/tags/BlockTags.java.patch b/patches/minecraft/net/minecraft/tags/BlockTags.java.patch index 3c90de5b9f..3462e28fe6 100644 --- a/patches/minecraft/net/minecraft/tags/BlockTags.java.patch +++ b/patches/minecraft/net/minecraft/tags/BlockTags.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/tags/BlockTags.java +++ b/net/minecraft/tags/BlockTags.java -@@ -206,4 +_,12 @@ +@@ -215,4 +_,12 @@ private static TagKey create(String p_203847_) { return TagKey.create(Registries.BLOCK, ResourceLocation.withDefaultNamespace(p_203847_)); } diff --git a/patches/minecraft/net/minecraft/tags/EntityTypeTags.java.patch b/patches/minecraft/net/minecraft/tags/EntityTypeTags.java.patch index c252acc12f..117320cb70 100644 --- a/patches/minecraft/net/minecraft/tags/EntityTypeTags.java.patch +++ b/patches/minecraft/net/minecraft/tags/EntityTypeTags.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/tags/EntityTypeTags.java +++ b/net/minecraft/tags/EntityTypeTags.java -@@ -48,4 +_,12 @@ +@@ -51,4 +_,12 @@ private static TagKey> create(String p_203849_) { return TagKey.create(Registries.ENTITY_TYPE, ResourceLocation.withDefaultNamespace(p_203849_)); } diff --git a/patches/minecraft/net/minecraft/tags/ItemTags.java.patch b/patches/minecraft/net/minecraft/tags/ItemTags.java.patch index cdf43dcd61..5c19de52bd 100644 --- a/patches/minecraft/net/minecraft/tags/ItemTags.java.patch +++ b/patches/minecraft/net/minecraft/tags/ItemTags.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/tags/ItemTags.java +++ b/net/minecraft/tags/ItemTags.java -@@ -191,4 +_,12 @@ +@@ -202,4 +_,12 @@ private static TagKey bind(String p_203855_) { return TagKey.create(Registries.ITEM, ResourceLocation.withDefaultNamespace(p_203855_)); } diff --git a/patches/minecraft/net/minecraft/util/random/WeightedList.java.patch b/patches/minecraft/net/minecraft/util/random/WeightedList.java.patch index 3ced836c38..784098f73a 100644 --- a/patches/minecraft/net/minecraft/util/random/WeightedList.java.patch +++ b/patches/minecraft/net/minecraft/util/random/WeightedList.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/util/random/WeightedList.java +++ b/net/minecraft/util/random/WeightedList.java -@@ -13,7 +_,7 @@ +@@ -16,7 +_,7 @@ import net.minecraft.util.ExtraCodecs; import net.minecraft.util.RandomSource; @@ -9,7 +9,7 @@ private static final int FLAT_THRESHOLD = 64; private final int totalWeight; private final List> items; -@@ -126,7 +_,7 @@ +@@ -133,7 +_,7 @@ return 31 * i + this.items.hashCode(); } diff --git a/patches/minecraft/net/minecraft/world/entity/Entity.java.patch b/patches/minecraft/net/minecraft/world/entity/Entity.java.patch index 0cc141b684..2c642bb145 100644 --- a/patches/minecraft/net/minecraft/world/entity/Entity.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/Entity.java.patch @@ -1,23 +1,23 @@ --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java -@@ -148,7 +_,7 @@ +@@ -150,7 +_,7 @@ import org.jetbrains.annotations.Contract; import org.slf4j.Logger; --public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess, ScoreHolder, DataComponentGetter { -+public abstract class Entity extends net.minecraftforge.common.capabilities.CapabilityProvider.Entities implements SyncedDataHolder, Nameable, EntityAccess, ScoreHolder, DataComponentGetter, net.minecraftforge.common.extensions.IForgeEntity { +-public abstract class Entity implements SyncedDataHolder, DebugValueSource, Nameable, ItemOwner, EntityAccess, ScoreHolder, DataComponentGetter { ++public abstract class Entity extends net.minecraftforge.common.capabilities.CapabilityProvider.Entities implements SyncedDataHolder, DebugValueSource, Nameable, ItemOwner, EntityAccess, ScoreHolder, DataComponentGetter, net.minecraftforge.common.extensions.IForgeEntity { public static final Logger LOGGER = LogUtils.getLogger(); public static final String TAG_ID = "id"; public static final String TAG_UUID = "UUID"; -@@ -185,6 +_,7 @@ - private static final double LAVA_FAST_FLOW_SCALE = 0.007; - private static final double LAVA_SLOW_FLOW_SCALE = 0.0023333333333333335; +@@ -188,6 +_,7 @@ + private static final int MAX_BLOCK_ITERATIONS_ALONG_TRAVEL_PER_TICK = 16; + private static final double MAX_MOVEMENT_RESETTING_TRACE_DISTANCE = 8.0; private static double viewScale = 1.0; + @Deprecated // Forge: Use the getter to allow overriding in mods private final EntityType type; private boolean requiresPrecisePosition; private int id = ENTITY_COUNTER.incrementAndGet(); -@@ -229,8 +_,10 @@ +@@ -232,8 +_,10 @@ public int tickCount; private int remainingFireTicks; protected boolean wasTouchingWater; @@ -28,7 +28,7 @@ private final Set> fluidOnEyes = new HashSet<>(); public int invulnerableTime; protected boolean firstTick = true; -@@ -282,6 +_,7 @@ +@@ -285,6 +_,7 @@ private CustomData customData = CustomData.EMPTY; public Entity(EntityType p_19870_, Level p_19871_) { @@ -36,7 +36,7 @@ this.type = p_19870_; this.level = p_19871_; this.dimensions = p_19870_.getDimensions(); -@@ -301,6 +_,8 @@ +@@ -304,6 +_,8 @@ this.entityData = synchedentitydata$builder.build(); this.setPos(0.0, 0.0, 0.0); this.eyeHeight = this.dimensions.eyeHeight(); @@ -45,7 +45,7 @@ } public boolean isColliding(BlockPos p_20040_, BlockState p_20041_) { -@@ -395,6 +_,7 @@ +@@ -402,6 +_,7 @@ public void remove(Entity.RemovalReason p_146834_) { this.setRemoved(p_146834_); @@ -53,7 +53,7 @@ } public void onClientRemoval() { -@@ -509,7 +_,7 @@ +@@ -516,7 +_,7 @@ } if (this.isInLava()) { @@ -62,7 +62,7 @@ } this.checkBelowWorld(); -@@ -946,9 +_,7 @@ +@@ -955,9 +_,7 @@ return blockpos; } else { BlockState blockstate = this.level().getBlockState(blockpos); @@ -73,7 +73,7 @@ ? blockpos.atY(Mth.floor(this.position.y - p_216987_)) : blockpos; } -@@ -1253,19 +_,19 @@ +@@ -1299,19 +_,19 @@ return !blockstate.is(BlockTags.INSIDE_STEP_SOUND_BLOCKS) && !blockstate.is(BlockTags.COMBINATION_STEP_SOUND_BLOCKS) ? p_278049_ : blockpos; } @@ -99,7 +99,7 @@ this.playSound(soundtype.getStepSound(), soundtype.getVolume() * 0.15F, soundtype.getPitch()); } -@@ -1398,6 +_,10 @@ +@@ -1444,6 +_,10 @@ return this.wasTouchingWater; } @@ -110,7 +110,7 @@ boolean isInRain() { BlockPos blockpos = this.blockPosition(); return this.level().isRainingAt(blockpos) -@@ -1433,24 +_,32 @@ +@@ -1483,24 +_,32 @@ public void updateSwimming() { if (this.isSwimming()) { @@ -150,7 +150,7 @@ if (!this.wasTouchingWater && !this.firstTick) { this.doWaterSplashEffect(); } -@@ -1465,6 +_,7 @@ +@@ -1515,6 +_,7 @@ private void updateFluidOnEyes() { this.wasEyeInWater = this.isEyeInFluid(FluidTags.WATER); this.fluidOnEyes.clear(); @@ -158,7 +158,7 @@ double d0 = this.getEyeY(); if (!( this.getVehicle() instanceof AbstractBoat abstractboat -@@ -1476,7 +_,7 @@ +@@ -1526,7 +_,7 @@ FluidState fluidstate = this.level().getFluidState(blockpos); double d1 = blockpos.getY() + fluidstate.getHeight(this.level(), blockpos); if (d1 > d0) { @@ -167,7 +167,7 @@ } } } -@@ -1530,12 +_,13 @@ +@@ -1580,12 +_,13 @@ } public boolean canSpawnSprintParticle() { @@ -182,7 +182,7 @@ if (blockstate.getRenderShape() != RenderShape.INVISIBLE) { Vec3 vec3 = this.getDeltaMovement(); BlockPos blockpos1 = this.blockPosition(); -@@ -1551,7 +_,7 @@ +@@ -1601,7 +_,7 @@ this.level() .addParticle( @@ -191,7 +191,7 @@ d0, this.getY() + 0.1, d1, -@@ -1562,12 +_,15 @@ +@@ -1612,12 +_,15 @@ } } @@ -208,7 +208,7 @@ } public void moveRelative(float p_19921_, Vec3 p_19922_) { -@@ -1932,6 +_,10 @@ +@@ -1982,6 +_,10 @@ p_409187_.putBoolean("HasVisualFire", this.hasVisualFire); } @@ -219,7 +219,7 @@ if (!this.tags.isEmpty()) { p_409187_.store("Tags", TAG_LIST_CODEC, List.copyOf(this.tags)); } -@@ -2007,6 +_,9 @@ +@@ -2057,6 +_,9 @@ this.setGlowingTag(p_408698_.getBooleanOr("Glowing", false)); this.setTicksFrozen(p_408698_.getIntOr("TicksFrozen", 0)); this.hasVisualFire = p_408698_.getBooleanOr("HasVisualFire", false); @@ -229,7 +229,7 @@ this.customData = p_408698_.read("data", CustomData.CODEC).orElse(CustomData.EMPTY); this.tags.clear(); p_408698_.read("Tags", TAG_LIST_CODEC).ifPresent(this.tags::addAll); -@@ -2064,6 +_,8 @@ +@@ -2109,6 +_,8 @@ p_409579_, this.getX() + p_408228_.x, this.getY() + p_408228_.y, this.getZ() + p_408228_.z, p_407826_ ); itementity.setDefaultPickUpDelay(); @@ -238,7 +238,7 @@ p_409579_.addFreshEntity(itementity); return itementity; } -@@ -2127,7 +_,7 @@ +@@ -2172,7 +_,7 @@ itemstack.hurtAndBreak(1, p_19978_, p_19979_); return InteractionResult.SUCCESS; } else if (this instanceof Mob mob @@ -247,7 +247,7 @@ && mob.canShearEquipment(p_19978_) && !p_19978_.isSecondaryUseActive() && this.attemptToShearEquipment(p_19978_, p_19979_, itemstack, mob)) { -@@ -2232,6 +_,7 @@ +@@ -2277,6 +_,7 @@ public void rideTick() { this.setDeltaMovement(Vec3.ZERO); @@ -255,7 +255,7 @@ this.tick(); if (this.isPassenger()) { this.getVehicle().positionRider(this); -@@ -2292,6 +_,7 @@ +@@ -2337,6 +_,7 @@ } } @@ -263,15 +263,15 @@ if (p_19967_ || this.canRide(p_19966_) && p_19966_.canAddPassenger(this)) { if (this.isPassenger()) { this.stopRiding(); -@@ -2323,6 +_,7 @@ +@@ -2372,6 +_,7 @@ public void removeVehicle() { if (this.vehicle != null) { Entity entity = this.vehicle; + if (!net.minecraftforge.event.ForgeEventFactory.canMountEntity(this, entity, false)) return; this.vehicle = null; entity.removePassenger(this); - } -@@ -2372,6 +_,8 @@ + Entity.RemovalReason entity$removalreason = this.getRemovalReason(); +@@ -2422,6 +_,8 @@ return this.passengers.isEmpty(); } @@ -280,7 +280,7 @@ protected boolean couldAcceptPassenger() { return true; } -@@ -2551,7 +_,7 @@ +@@ -2618,7 +_,7 @@ } public boolean isVisuallyCrawling() { @@ -289,7 +289,7 @@ } public void setSwimming(boolean p_20283_) { -@@ -2668,7 +_,7 @@ +@@ -2735,7 +_,7 @@ this.igniteForSeconds(8.0F); } @@ -298,7 +298,7 @@ } public void onAboveBubbleColumn(boolean p_392709_, BlockPos p_391902_) { -@@ -2801,7 +_,7 @@ +@@ -2868,7 +_,7 @@ } protected Component getTypeName() { @@ -307,7 +307,7 @@ } public boolean is(Entity p_20356_) { -@@ -3106,6 +_,7 @@ +@@ -3181,6 +_,7 @@ return this.stringUUID; } @@ -315,7 +315,7 @@ public boolean isPushedByFluid() { return true; } -@@ -3500,9 +_,17 @@ +@@ -3565,9 +_,17 @@ return Mth.lerp(p_344421_, this.yRotO, this.yRot); } @@ -334,7 +334,7 @@ } else { AABB aabb = this.getBoundingBox().deflate(0.001); int i = Mth.floor(aabb.minX); -@@ -3517,25 +_,28 @@ +@@ -3582,25 +_,28 @@ Vec3 vec3 = Vec3.ZERO; int k1 = 0; BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(); @@ -370,7 +370,7 @@ } } } -@@ -3543,27 +_,28 @@ +@@ -3608,27 +_,28 @@ } } @@ -409,7 +409,7 @@ } } -@@ -3576,7 +_,10 @@ +@@ -3641,7 +_,10 @@ return !this.level().hasChunksAt(i, k, j, l); } @@ -420,7 +420,7 @@ return this.fluidHeight.getDouble(p_204037_); } -@@ -3592,7 +_,9 @@ +@@ -3657,7 +_,9 @@ return this.dimensions.height(); } @@ -430,19 +430,19 @@ return new ClientboundAddEntityPacket(this, p_344981_); } -@@ -3722,6 +_,11 @@ +@@ -3788,6 +_,11 @@ } } } + + // Forge - ensure target chunk is loaded. -+ if (this.isAddedToWorld() && !this.level.isClientSide && !this.isRemoved()) { ++ if (this.isAddedToWorld() && !this.level.isClientSide() && !this.isRemoved()) { + this.level.getChunk((int) Math.floor(p_20344_) >> 4, (int) Math.floor(p_20346_) >> 4); + } } public void checkDespawn() { -@@ -3895,6 +_,100 @@ +@@ -3962,6 +_,100 @@ float f1 = (float)Mth.lerp(d0, this.getXRot(), p_298926_); this.setPos(d1, d2, d3); this.setRot(f, f1); diff --git a/patches/minecraft/net/minecraft/world/entity/EntityEquipment.java.patch b/patches/minecraft/net/minecraft/world/entity/EntityEquipment.java.patch index d03973831f..09f8a9cd02 100644 --- a/patches/minecraft/net/minecraft/world/entity/EntityEquipment.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/EntityEquipment.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/EntityEquipment.java +++ b/net/minecraft/world/entity/EntityEquipment.java -@@ -50,7 +_,7 @@ +@@ -49,7 +_,7 @@ for (Entry entry : this.items.entrySet()) { ItemStack itemstack = entry.getValue(); if (!itemstack.isEmpty()) { @@ -9,7 +9,7 @@ } } } -@@ -70,5 +_,9 @@ +@@ -69,5 +_,9 @@ public void clear() { this.items.replaceAll((p_393205_, p_394162_) -> ItemStack.EMPTY); diff --git a/patches/minecraft/net/minecraft/world/entity/EntityType.java.patch b/patches/minecraft/net/minecraft/world/entity/EntityType.java.patch index 06f29bd348..75b540c93d 100644 --- a/patches/minecraft/net/minecraft/world/entity/EntityType.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/EntityType.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/entity/EntityType.java +++ b/net/minecraft/world/entity/EntityType.java -@@ -887,6 +_,11 @@ - private final float spawnDimensionsScale; +@@ -961,6 +_,11 @@ private final FeatureFlagSet requiredFeatures; + private final boolean allowedInPeaceful; + private final java.util.function.Predicate> velocityUpdateSupplier; + private final java.util.function.ToIntFunction> trackingRangeSupplier; @@ -12,20 +12,20 @@ private static EntityType register(ResourceKey> p_368406_, EntityType.Builder p_363129_) { return Registry.register(BuiltInRegistries.ENTITY_TYPE, p_368406_, p_363129_.build(p_368406_)); } -@@ -921,7 +_,8 @@ - int p_273451_, +@@ -996,7 +_,8 @@ String p_367006_, Optional> p_364691_, -- FeatureFlagSet p_273518_ -+ FeatureFlagSet p_273518_, + FeatureFlagSet p_273518_, +- boolean p_430684_ ++ boolean p_430684_, + Builder builder ) { this.factory = p_273268_; this.category = p_272918_; -@@ -937,6 +_,10 @@ - this.descriptionId = p_367006_; +@@ -1013,6 +_,10 @@ this.lootTable = p_364691_; this.requiredFeatures = p_273518_; + this.allowedInPeaceful = p_430684_; + this.velocityUpdateSupplier = builder == null || builder.velocityUpdateSupplier == null ? EntityType::defaultVelocitySupplier : builder.velocityUpdateSupplier; + this.trackingRangeSupplier = builder == null || builder.trackingRangeSupplier == null ? EntityType::defaultTrackingRangeSupplier : builder.trackingRangeSupplier; + this.updateIntervalSupplier = builder == null || builder.updateIntervalSupplier == null ? EntityType::defaultUpdateIntervalSupplier : builder.updateIntervalSupplier; @@ -33,7 +33,7 @@ } @Nullable -@@ -1197,14 +_,26 @@ +@@ -1316,14 +_,26 @@ } public int clientTrackingRange() { @@ -60,7 +60,7 @@ return this != PLAYER && this != LLAMA_SPIT && this != WITHER -@@ -1260,6 +_,12 @@ +@@ -1383,6 +_,12 @@ return OP_ONLY_CUSTOM_DATA.contains(this); } @@ -73,10 +73,10 @@ public static class Builder { private final EntityType.EntityFactory factory; private final MobCategory category; -@@ -1278,6 +_,10 @@ - ResourceKey.create(Registries.LOOT_TABLE, p_358877_.location().withPrefix("entities/")) +@@ -1402,6 +_,10 @@ ); private final DependantName, String> descriptionId = p_358878_ -> Util.makeDescriptionId("entity", p_358878_.location()); + private boolean allowedInPeaceful = true; + private java.util.function.Predicate> velocityUpdateSupplier = EntityType::defaultVelocitySupplier; + private java.util.function.ToIntFunction> trackingRangeSupplier = EntityType::defaultTrackingRangeSupplier; + private java.util.function.ToIntFunction> updateIntervalSupplier = EntityType::defaultUpdateIntervalSupplier; @@ -84,7 +84,7 @@ private Builder(EntityType.EntityFactory p_20696_, MobCategory p_20697_) { this.factory = p_20696_; -@@ -1391,6 +_,30 @@ +@@ -1520,6 +_,30 @@ return this; } @@ -115,12 +115,12 @@ public EntityType build(ResourceKey> p_369693_) { if (this.serialize) { Util.fetchChoiceType(References.ENTITY_TREE, p_369693_.location().toString()); -@@ -1410,7 +_,8 @@ - this.updateInterval, +@@ -1540,7 +_,8 @@ this.descriptionId.get(p_369693_), this.lootTable.get(p_369693_), -- this.requiredFeatures -+ this.requiredFeatures, + this.requiredFeatures, +- this.allowedInPeaceful ++ this.allowedInPeaceful, + this ); } diff --git a/patches/minecraft/net/minecraft/world/entity/LightningBolt.java.patch b/patches/minecraft/net/minecraft/world/entity/LightningBolt.java.patch index 4cded85e32..8b84f83a8f 100644 --- a/patches/minecraft/net/minecraft/world/entity/LightningBolt.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/LightningBolt.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/LightningBolt.java +++ b/net/minecraft/world/entity/LightningBolt.java -@@ -40,6 +_,7 @@ +@@ -39,6 +_,7 @@ private ServerPlayer cause; private final Set hitEntities = Sets.newHashSet(); private int blocksSetOnFire; @@ -8,7 +8,7 @@ public LightningBolt(EntityType p_20865_, Level p_20866_) { super(p_20865_, p_20866_); -@@ -66,6 +_,14 @@ +@@ -65,6 +_,14 @@ this.cause = p_20880_; } @@ -23,7 +23,7 @@ private void powerLightningRod() { BlockPos blockpos = this.getStrikePosition(); BlockState blockstate = this.level().getBlockState(blockpos); -@@ -164,6 +_,7 @@ +@@ -163,6 +_,7 @@ ); for (Entity entity : list1) { diff --git a/patches/minecraft/net/minecraft/world/entity/LivingEntity.java.patch b/patches/minecraft/net/minecraft/world/entity/LivingEntity.java.patch index a124758b0c..ffa2328dd7 100644 --- a/patches/minecraft/net/minecraft/world/entity/LivingEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/LivingEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/LivingEntity.java +++ b/net/minecraft/world/entity/LivingEntity.java -@@ -139,7 +_,7 @@ +@@ -140,7 +_,7 @@ import org.jetbrains.annotations.Contract; import org.slf4j.Logger; @@ -9,7 +9,7 @@ private static final Logger LOGGER = LogUtils.getLogger(); private static final String TAG_ACTIVE_EFFECTS = "active_effects"; public static final String TAG_ATTRIBUTES = "attributes"; -@@ -183,6 +_,8 @@ +@@ -184,6 +_,8 @@ protected static final EntityDimensions SLEEPING_DIMENSIONS = EntityDimensions.fixed(0.2F, 0.2F).withEyeHeight(0.2F); public static final float EXTRA_RENDER_CULLING_SIZE_WITH_BIG_HAT = 0.5F; public static final float DEFAULT_BABY_SCALE = 0.5F; @@ -18,7 +18,7 @@ public static final Predicate PLAYER_NOT_WEARING_DISGUISE_ITEM = p_390518_ -> { if (p_390518_ instanceof Player player) { ItemStack itemstack = player.getItemBySlot(EquipmentSlot.HEAD); -@@ -267,7 +_,7 @@ +@@ -268,7 +_,7 @@ this.reapplyPosition(); this.setYRot((float)(Math.random() * (float) (Math.PI * 2))); this.yHeadRot = this.getYRot(); @@ -26,8 +26,8 @@ + this.brain = net.minecraftforge.common.ForgeHooks.onLivingMakeBrain(this, this.makeBrain(EMPTY_BRAIN), EMPTY_BRAIN); } - @Contract( -@@ -328,9 +_,10 @@ + @Nullable +@@ -335,9 +_,10 @@ .add(Attributes.EXPLOSION_KNOCKBACK_RESISTANCE) .add(Attributes.WATER_MOVEMENT_EFFICIENCY) .add(Attributes.MOVEMENT_EFFICIENCY) @@ -40,7 +40,7 @@ } @Override -@@ -357,7 +_,8 @@ +@@ -364,7 +_,8 @@ double d7 = Math.min(0.2F + d6 / 15.0, 2.5); int i = (int)(150.0 * d7); @@ -50,7 +50,7 @@ } } -@@ -367,6 +_,7 @@ +@@ -374,6 +_,7 @@ } } @@ -58,7 +58,7 @@ public boolean canBreatheUnderwater() { return this.getType().is(EntityTypeTags.CAN_BREATHE_UNDER_WATER); } -@@ -411,6 +_,10 @@ +@@ -414,6 +_,10 @@ } } @@ -69,7 +69,7 @@ if (this.isEyeInFluid(FluidTags.WATER) && !serverlevel1.getBlockState(BlockPos.containing(this.getX(), this.getEyeY(), this.getZ())).is(Blocks.BUBBLE_COLUMN)) { boolean flag1 = !this.canBreatheUnderwater() && !MobEffectUtil.hasWaterBreathing(this) && (!flag || !((Player)this).getAbilities().invulnerable); -@@ -757,6 +_,9 @@ +@@ -764,6 +_,9 @@ } else { ItemEntity itementity = this.createItemStackToDrop(p_395943_, p_393118_, p_392158_); if (itementity != null) { @@ -79,7 +79,7 @@ this.level().addFreshEntity(itementity); } -@@ -798,7 +_,7 @@ +@@ -805,7 +_,7 @@ this.setPosToBed(p_390515_); } }, this::clearSleepingPos); @@ -88,7 +88,7 @@ this.lastHurtByPlayer = EntityReference.read(p_406679_, "last_hurt_by_player"); this.lastHurtByPlayerMemoryTime = p_406679_.getIntOr("last_hurt_by_player_memory_time", 0); this.lastHurtByMob = EntityReference.read(p_406679_, "last_hurt_by_mob"); -@@ -816,8 +_,10 @@ +@@ -823,8 +_,10 @@ Holder holder = iterator.next(); MobEffectInstance mobeffectinstance = this.activeEffects.get(holder); if (!mobeffectinstance.tickServer(serverlevel, this, () -> this.onEffectUpdated(mobeffectinstance, true, null))) { @@ -99,7 +99,7 @@ } else if (mobeffectinstance.getDuration() % 600 == 0) { this.onEffectUpdated(mobeffectinstance, false, null); } -@@ -897,6 +_,7 @@ +@@ -904,6 +_,7 @@ } } @@ -107,7 +107,7 @@ return d0; } -@@ -971,6 +_,7 @@ +@@ -978,6 +_,7 @@ } else { MobEffectInstance mobeffectinstance = this.activeEffects.get(p_147208_.getEffect()); boolean flag = false; @@ -115,7 +115,7 @@ if (mobeffectinstance == null) { this.activeEffects.put(p_147208_.getEffect(), p_147208_); this.onEffectAdded(p_147208_, p_147209_); -@@ -987,6 +_,10 @@ +@@ -994,6 +_,10 @@ } public boolean canBeAffected(MobEffectInstance p_21197_) { @@ -126,7 +126,7 @@ if (this.getType().is(EntityTypeTags.IMMUNE_TO_INFESTED)) { return !p_21197_.is(MobEffects.INFESTED); } else if (this.getType().is(EntityTypeTags.IMMUNE_TO_OOZING)) { -@@ -1020,6 +_,9 @@ +@@ -1027,6 +_,9 @@ } public boolean removeEffect(Holder p_335910_) { @@ -136,7 +136,7 @@ MobEffectInstance mobeffectinstance = this.removeEffectNoUpdate(p_335910_); if (mobeffectinstance != null) { this.onEffectsRemoved(List.of(mobeffectinstance)); -@@ -1064,6 +_,9 @@ +@@ -1071,6 +_,9 @@ this.effectsDirty = true; for (MobEffectInstance mobeffectinstance : p_364717_) { @@ -146,7 +146,7 @@ mobeffectinstance.getEffect().value().removeAttributeModifiers(this.getAttributes()); for (Entity entity : this.getPassengers()) { -@@ -1111,6 +_,10 @@ +@@ -1118,6 +_,10 @@ } public void heal(float p_21116_) { @@ -157,7 +157,7 @@ float f = this.getHealth(); if (f > 0.0F) { this.setHealth(f + p_21116_); -@@ -1131,6 +_,9 @@ +@@ -1138,6 +_,9 @@ @Override public boolean hurtServer(ServerLevel p_361743_, DamageSource p_361865_, float p_365677_) { @@ -167,7 +167,7 @@ if (this.isInvulnerableTo(p_361743_, p_361865_)) { return false; } else if (this.isDeadOrDying()) { -@@ -1277,6 +_,10 @@ +@@ -1285,6 +_,10 @@ } float f = blocksattacks.resolveBlockedDamage(p_392511_, p_394545_, d0); @@ -176,9 +176,9 @@ + f = ev.getBlockedDamage(); + if (ev.shieldTakesDamage()) blocksattacks.hurtBlockingItem(this.level(), itemstack, this, this.getUsedItemHand(), f); - if (!p_392511_.is(DamageTypeTags.IS_PROJECTILE) && p_392511_.getDirectEntity() instanceof LivingEntity livingentity) { + if (f > 0.0F && !p_392511_.is(DamageTypeTags.IS_PROJECTILE) && p_392511_.getDirectEntity() instanceof LivingEntity livingentity) { this.blockUsingItem(p_396198_, livingentity); -@@ -1311,7 +_,7 @@ +@@ -1319,7 +_,7 @@ Entity entity = p_378258_.getEntity(); if (entity instanceof Player player) { this.setLastHurtByPlayer(player, 100); @@ -187,7 +187,7 @@ if (wolf.getOwnerReference() != null) { this.setLastHurtByPlayer(wolf.getOwnerReference().getUUID(), 100); } else { -@@ -1341,7 +_,7 @@ +@@ -1349,7 +_,7 @@ for (InteractionHand interactionhand : InteractionHand.values()) { ItemStack itemstack1 = this.getItemInHand(interactionhand); deathprotection = itemstack1.get(DataComponents.DEATH_PROTECTION); @@ -196,7 +196,7 @@ itemstack = itemstack1.copy(); itemstack1.shrink(1); break; -@@ -1405,6 +_,7 @@ +@@ -1413,6 +_,7 @@ } public void die(DamageSource p_21014_) { @@ -204,7 +204,7 @@ if (!this.isRemoved() && !this.dead) { Entity entity = p_21014_.getEntity(); LivingEntity livingentity = this.getKillCredit(); -@@ -1440,10 +_,10 @@ +@@ -1448,10 +_,10 @@ if (this.level() instanceof ServerLevel serverlevel) { boolean flag = false; if (p_21269_ instanceof WitherBoss) { @@ -217,15 +217,15 @@ this.level().setBlock(blockpos, blockstate, 3); flag = true; } -@@ -1458,6 +_,7 @@ +@@ -1466,6 +_,7 @@ } protected void dropAllDeathLoot(ServerLevel p_342160_, DamageSource p_21192_) { + this.captureDrops(new java.util.ArrayList<>()); boolean flag = this.lastHurtByPlayerMemoryTime > 0; - if (this.shouldDropLoot() && p_342160_.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { + if (this.shouldDropLoot(p_342160_)) { this.dropFromLootTable(p_342160_, p_21192_, flag); -@@ -1466,6 +_,11 @@ +@@ -1474,6 +_,11 @@ this.dropEquipment(p_342160_); this.dropExperience(p_342160_, p_21192_.getEntity()); @@ -237,7 +237,7 @@ } protected void dropEquipment(ServerLevel p_365823_) { -@@ -1473,7 +_,8 @@ +@@ -1481,7 +_,8 @@ protected void dropExperience(ServerLevel p_370040_, @Nullable Entity p_342525_) { if (!this.wasExperienceConsumed() && (this.isAlwaysExperienceDropper() || this.lastHurtByPlayerMemoryTime > 0 && this.shouldDropExperience() && p_370040_.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT))) { @@ -247,7 +247,7 @@ } } -@@ -1550,6 +_,11 @@ +@@ -1580,6 +_,11 @@ } public void knockback(double p_147241_, double p_147242_, double p_147243_) { @@ -259,7 +259,7 @@ p_147241_ *= 1.0 - this.getAttributeValue(Attributes.KNOCKBACK_RESISTANCE); if (!(p_147241_ <= 0.0)) { this.hasImpulse = true; -@@ -1627,6 +_,13 @@ +@@ -1657,6 +_,13 @@ } else { BlockPos blockpos = this.blockPosition(); BlockState blockstate = this.getInBlockState(); @@ -273,7 +273,7 @@ if (blockstate.is(BlockTags.CLIMBABLE)) { this.lastClimbablePos = Optional.of(blockpos); return true; -@@ -1681,6 +_,10 @@ +@@ -1711,6 +_,10 @@ @Override public boolean causeFallDamage(double p_393354_, float p_147187_, DamageSource p_147189_) { @@ -284,7 +284,7 @@ boolean flag = super.causeFallDamage(p_393354_, p_147187_, p_147189_); int i = this.calculateFallDamage(p_393354_, p_147187_); if (i > 0) { -@@ -1711,9 +_,10 @@ +@@ -1741,9 +_,10 @@ int i = Mth.floor(this.getX()); int j = Mth.floor(this.getY() - 0.2F); int k = Mth.floor(this.getZ()); @@ -297,7 +297,7 @@ this.playSound(soundtype.getFallSound(), soundtype.getVolume() * 0.5F, soundtype.getPitch() * 0.75F); } } -@@ -1771,9 +_,9 @@ +@@ -1801,9 +_,9 @@ float f2 = f1 - p_21194_; if (f2 > 0.0F && f2 < 3.4028235E37F) { if (this instanceof ServerPlayer) { @@ -309,7 +309,7 @@ } } } -@@ -1801,6 +_,8 @@ +@@ -1831,6 +_,8 @@ protected void actuallyHurt(ServerLevel p_365124_, DamageSource p_21240_, float p_21241_) { if (!this.isInvulnerableTo(p_365124_, p_21240_)) { @@ -318,7 +318,7 @@ p_21241_ = this.getDamageAfterArmorAbsorb(p_21240_, p_21241_); p_21241_ = this.getDamageAfterMagicAbsorb(p_21240_, p_21241_); float f1 = Math.max(p_21241_ - this.getAbsorptionAmount(), 0.0F); -@@ -1810,6 +_,7 @@ +@@ -1840,6 +_,7 @@ serverplayer.awardStat(Stats.DAMAGE_DEALT_ABSORBED, Math.round(f * 10.0F)); } @@ -326,7 +326,7 @@ if (f1 != 0.0F) { this.getCombatTracker().recordDamage(p_21240_, f1); this.setHealth(this.getHealth() - f1); -@@ -1869,6 +_,8 @@ +@@ -1899,6 +_,8 @@ } public void swing(InteractionHand p_21012_, boolean p_21013_) { @@ -335,7 +335,7 @@ if (!this.swinging || this.swingTime >= this.getCurrentSwingDuration() / 2 || this.swingTime < 0) { this.swingTime = -1; this.swinging = true; -@@ -1993,9 +_,10 @@ +@@ -2023,9 +_,10 @@ } private void swapHandItems() { @@ -349,7 +349,7 @@ } @Override -@@ -2201,15 +_,18 @@ +@@ -2231,15 +_,18 @@ } this.hasImpulse = true; @@ -370,7 +370,7 @@ } protected float getWaterSlowDown() { -@@ -2232,8 +_,8 @@ +@@ -2262,8 +_,8 @@ public void travel(Vec3 p_21280_) { FluidState fluidstate = this.level().getFluidState(this.blockPosition()); @@ -381,7 +381,7 @@ } else if (this.isFallFlying()) { this.travelFallFlying(p_21280_); } else { -@@ -2263,7 +_,7 @@ +@@ -2293,7 +_,7 @@ private void travelInAir(Vec3 p_362087_) { BlockPos blockpos = this.getBlockPosBelowThatAffectsMyMovement(); @@ -390,7 +390,7 @@ float f1 = f * 0.91F; Vec3 vec3 = this.handleRelativeFrictionAndCalculateMovement(p_362087_, f); double d0 = vec3.y; -@@ -2286,10 +_,18 @@ +@@ -2316,10 +_,18 @@ } } @@ -410,7 +410,7 @@ if (this.isInWater()) { float f = this.isSprinting() ? 0.9F : this.getWaterSlowDown(); float f1 = 0.02F; -@@ -2307,6 +_,7 @@ +@@ -2337,6 +_,7 @@ f = 0.96F; } @@ -418,7 +418,7 @@ this.moveRelative(f1, p_362114_); this.move(MoverType.SELF, this.getDeltaMovement()); Vec3 vec3 = this.getDeltaMovement(); -@@ -2465,7 +_,7 @@ +@@ -2495,7 +_,7 @@ double d0 = Mth.clamp(p_21298_.x, -0.15F, 0.15F); double d1 = Mth.clamp(p_21298_.z, -0.15F, 0.15F); double d2 = Math.max(p_21298_.y, -0.15F); @@ -427,7 +427,7 @@ d2 = 0.0; } -@@ -2498,6 +_,7 @@ +@@ -2528,6 +_,7 @@ @Override public void tick() { @@ -435,7 +435,7 @@ super.tick(); this.updatingUsingItem(); this.updateSwimAmount(); -@@ -2629,6 +_,7 @@ +@@ -2659,6 +_,7 @@ ItemStack itemstack = this.lastEquipmentItems.get(equipmentslot); ItemStack itemstack1 = this.getItemBySlot(equipmentslot); if (this.equipmentHasChanged(itemstack, itemstack1)) { @@ -443,7 +443,7 @@ if (map == null) { map = Maps.newEnumMap(EquipmentSlot.class); } -@@ -2764,6 +_,10 @@ +@@ -2794,6 +_,10 @@ profilerfiller.push("jump"); if (this.jumping && this.isAffectedByFluids()) { double d3; @@ -454,7 +454,7 @@ if (this.isInLava()) { d3 = this.getFluidHeight(FluidTags.LAVA); } else { -@@ -2774,15 +_,22 @@ +@@ -2804,15 +_,22 @@ double d4 = this.getFluidJumpThreshold(); if (!flag || this.onGround() && !(d3 > d4)) { if (!this.isInLava() || this.onGround() && !(d3 > d4)) { @@ -479,7 +479,7 @@ } } else { this.noJumpDelay = 0; -@@ -3098,8 +_,11 @@ +@@ -3128,8 +_,11 @@ private void updatingUsingItem() { if (this.isUsingItem()) { @@ -492,7 +492,7 @@ this.updateUsingItem(this.useItem); } else { this.stopUsingItem(); -@@ -3143,8 +_,12 @@ +@@ -3173,8 +_,12 @@ } protected void updateUsingItem(ItemStack p_147201_) { @@ -501,12 +501,12 @@ + } + if (this.getUseItemRemainingTicks() > 0) p_147201_.onUseTick(this.level(), this, this.getUseItemRemainingTicks()); -- if (--this.useItemRemaining == 0 && !this.level().isClientSide && !p_147201_.useOnRelease()) { -+ if (--this.useItemRemaining <= 0 && !this.level().isClientSide && !p_147201_.useOnRelease()) { +- if (--this.useItemRemaining == 0 && !this.level().isClientSide() && !p_147201_.useOnRelease()) { ++ if (--this.useItemRemaining <= 0 && !this.level().isClientSide() && !p_147201_.useOnRelease()) { this.completeUsingItem(); } } -@@ -3172,8 +_,10 @@ +@@ -3202,8 +_,10 @@ public void startUsingItem(InteractionHand p_21159_) { ItemStack itemstack = this.getItemInHand(p_21159_); if (!itemstack.isEmpty() && !this.isUsingItem()) { @@ -515,10 +515,10 @@ this.useItem = itemstack; - this.useItemRemaining = itemstack.getUseDuration(this); + this.useItemRemaining = duration; - if (!this.level().isClientSide) { + if (!this.level().isClientSide()) { this.setLivingEntityFlag(1, true); this.setLivingEntityFlag(2, p_21159_ == InteractionHand.OFF_HAND); -@@ -3225,6 +_,9 @@ +@@ -3255,6 +_,9 @@ vec31 = vec31.xRot(-this.getXRot() * (float) (Math.PI / 180.0)); vec31 = vec31.yRot(-this.getYRot() * (float) (Math.PI / 180.0)); vec31 = vec31.add(this.getX(), this.getEyeY(), this.getZ()); @@ -528,7 +528,7 @@ this.level() .addParticle( new ItemParticleOption(ParticleTypes.ITEM, p_21061_), -@@ -3245,7 +_,9 @@ +@@ -3275,7 +_,9 @@ this.releaseUsingItem(); } else { if (!this.useItem.isEmpty() && this.isUsingItem()) { @@ -538,7 +538,7 @@ if (itemstack != this.useItem) { this.setItemInHand(interactionhand, itemstack); } -@@ -3275,7 +_,13 @@ +@@ -3305,7 +_,13 @@ ItemStack itemstack = this.getItemInHand(this.getUsedItemHand()); if (!this.useItem.isEmpty() && ItemStack.isSameItem(itemstack, this.useItem)) { this.useItem = itemstack; @@ -552,15 +552,15 @@ if (this.useItem.useOnRelease()) { this.updatingUsingItem(); } -@@ -3285,6 +_,7 @@ +@@ -3315,6 +_,7 @@ } public void stopUsingItem() { + if (this.isUsingItem() && !this.useItem.isEmpty()) this.useItem.onStopUsing(this, useItemRemaining); - if (!this.level().isClientSide) { + if (!this.level().isClientSide()) { boolean flag = this.isUsingItem(); this.setLivingEntityFlag(1, false); -@@ -3453,8 +_,8 @@ +@@ -3483,8 +_,8 @@ } BlockState blockstate = this.level().getBlockState(p_21141_); @@ -571,12 +571,12 @@ } this.setPose(Pose.SLEEPING); -@@ -3469,15 +_,15 @@ +@@ -3499,15 +_,15 @@ } private boolean checkBedExists() { -- return this.getSleepingPos().map(p_405281_ -> this.level().getBlockState(p_405281_).getBlock() instanceof BedBlock).orElse(false); -+ return this.getSleepingPos().map(p_405281_ -> net.minecraftforge.event.ForgeEventFactory.fireSleepingLocationCheck(this, p_405281_)).orElse(false); +- return this.getSleepingPos().map(p_421591_ -> this.level().getBlockState(p_421591_).getBlock() instanceof BedBlock).orElse(false); ++ return this.getSleepingPos().map(p_421591_ -> net.minecraftforge.event.ForgeEventFactory.fireSleepingLocationCheck(this, p_421591_)).orElse(false); } public void stopSleeping() { @@ -590,7 +590,7 @@ Vec3 vec31 = BedBlock.findStandUpPosition(this.getType(), this.level(), p_261435_, direction, this.getYRot()).orElseGet(() -> { BlockPos blockpos = p_261435_.above(); return new Vec3(blockpos.getX() + 0.5, blockpos.getY() + 0.1, blockpos.getZ() + 0.5); -@@ -3498,7 +_,9 @@ +@@ -3528,7 +_,9 @@ @Nullable public Direction getBedOrientation() { BlockPos blockpos = this.getSleepingPos().orElse(null); @@ -601,7 +601,7 @@ } @Override -@@ -3507,7 +_,7 @@ +@@ -3537,7 +_,7 @@ } public ItemStack getProjectile(ItemStack p_21272_) { @@ -610,7 +610,7 @@ } private static byte entityEventForEquipmentBreak(EquipmentSlot p_21267_) { -@@ -3563,6 +_,8 @@ +@@ -3589,6 +_,8 @@ } public final EquipmentSlot getEquipmentSlotForItem(ItemStack p_147234_) { @@ -619,7 +619,7 @@ Equippable equippable = p_147234_.get(DataComponents.EQUIPPABLE); return equippable != null && this.canUseSlot(equippable.slot()) ? equippable.slot() : EquipmentSlot.MAINHAND; } -@@ -3726,5 +_,42 @@ +@@ -3752,5 +_,42 @@ } public record Fallsounds(SoundEvent small, SoundEvent big) { diff --git a/patches/minecraft/net/minecraft/world/entity/Mob.java.patch b/patches/minecraft/net/minecraft/world/entity/Mob.java.patch index dbb4a8cf79..6fe0db2916 100644 --- a/patches/minecraft/net/minecraft/world/entity/Mob.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/Mob.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/Mob.java +++ b/net/minecraft/world/entity/Mob.java -@@ -127,6 +_,9 @@ +@@ -137,6 +_,9 @@ private Leashable.LeashData leashData; private BlockPos homePosition = BlockPos.ZERO; private int homeRadius = -1; @@ -10,7 +10,7 @@ protected Mob(EntityType p_21368_, Level p_21369_) { super(p_21368_, p_21369_); -@@ -223,7 +_,10 @@ +@@ -233,7 +_,10 @@ } public void setTarget(@Nullable LivingEntity p_21544_) { @@ -22,7 +22,7 @@ } @Override -@@ -363,6 +_,10 @@ +@@ -373,6 +_,10 @@ if (this.isNoAi()) { p_409238_.putBoolean("NoAI", this.isNoAi()); } @@ -33,7 +33,7 @@ } @Override -@@ -381,6 +_,13 @@ +@@ -391,6 +_,13 @@ this.lootTable = p_408489_.read("DeathLootTable", LootTable.KEY_CODEC); this.lootTableSeed = p_408489_.getLongOr("DeathLootTableSeed", 0L); this.setNoAi(p_408489_.getBooleanOr("NoAI", false)); @@ -47,7 +47,7 @@ } @Override -@@ -435,7 +_,7 @@ +@@ -445,7 +_,7 @@ && this.canPickUpLoot() && this.isAlive() && !this.dead @@ -56,7 +56,7 @@ Vec3i vec3i = this.getPickupReach(); for (ItemEntity itementity : this.level() -@@ -600,6 +_,14 @@ +@@ -606,6 +_,14 @@ this.discard(); } else if (!this.isPersistenceRequired() && !this.requiresCustomPersistence()) { Entity entity = this.level().getNearestPlayer(this, -1.0); @@ -71,7 +71,7 @@ if (entity != null) { double d0 = entity.distanceToSqr(this); int i = this.getType().getCategory().getDespawnDistance(); -@@ -994,6 +_,16 @@ +@@ -998,6 +_,16 @@ } } @@ -88,7 +88,7 @@ @Nullable public SpawnGroupData finalizeSpawn(ServerLevelAccessor p_21434_, DifficultyInstance p_21435_, EntitySpawnReason p_369316_, @Nullable SpawnGroupData p_21437_) { RandomSource randomsource = p_21434_.getRandom(); -@@ -1005,6 +_,7 @@ +@@ -1009,6 +_,7 @@ } this.setLeftHanded(randomsource.nextFloat() < 0.05F); @@ -96,7 +96,7 @@ return p_21437_; } -@@ -1314,15 +_,25 @@ +@@ -1328,15 +_,25 @@ return false; } @@ -123,7 +123,7 @@ @VisibleForTesting public void removeFreeWill() { this.removeAllGoals(p_341273_ -> true); -@@ -1350,6 +_,41 @@ +@@ -1364,6 +_,41 @@ public ItemStack getPickResult() { SpawnEggItem spawneggitem = SpawnEggItem.byId(this.getType()); return spawneggitem == null ? null : new ItemStack(spawneggitem); diff --git a/patches/minecraft/net/minecraft/world/entity/SpawnPlacements.java.patch b/patches/minecraft/net/minecraft/world/entity/SpawnPlacements.java.patch index 10bdc850c3..1823c9d6ac 100644 --- a/patches/minecraft/net/minecraft/world/entity/SpawnPlacements.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/SpawnPlacements.java.patch @@ -28,7 +28,7 @@ + public static void fireSpawnPlacementEvent() { + Map, net.minecraftforge.event.entity.SpawnPlacementRegisterEvent.MergedSpawnPredicate> map = Maps.newHashMap(); + DATA_BY_TYPE.forEach((type, data) -> map.put(type, new net.minecraftforge.event.entity.SpawnPlacementRegisterEvent.MergedSpawnPredicate<>(data.predicate, data.placement, data.heightMap))); -+ net.minecraftforge.fml.ModLoader.get().postEvent(new net.minecraftforge.event.entity.SpawnPlacementRegisterEvent(map)); ++ net.minecraftforge.fml.ModLoader.postEvent(new net.minecraftforge.event.entity.SpawnPlacementRegisterEvent(map)); + map.forEach(((entityType, merged) -> DATA_BY_TYPE.put(entityType, new SpawnPlacements.Data(merged.getHeightmapType(), merged.getSpawnType(), merged.build())))); } } diff --git a/patches/minecraft/net/minecraft/world/entity/ai/Brain.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/Brain.java.patch index 2f9211a67b..b4cb367c6b 100644 --- a/patches/minecraft/net/minecraft/world/entity/ai/Brain.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/ai/Brain.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/entity/ai/Brain.java +++ b/net/minecraft/world/entity/ai/Brain.java -@@ -494,6 +_,30 @@ - return builder.build(); +@@ -498,6 +_,30 @@ + return this.memories.isEmpty() && this.sensors.isEmpty() && this.availableBehaviorsByPriority.isEmpty(); } + public net.minecraftforge.common.util.BrainBuilder createBuilder() { diff --git a/patches/minecraft/net/minecraft/world/entity/ai/attributes/DefaultAttributes.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/attributes/DefaultAttributes.java.patch index 26f9e10049..90071bb64b 100644 --- a/patches/minecraft/net/minecraft/world/entity/ai/attributes/DefaultAttributes.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/ai/attributes/DefaultAttributes.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/attributes/DefaultAttributes.java +++ b/net/minecraft/world/entity/ai/attributes/DefaultAttributes.java -@@ -178,11 +_,12 @@ +@@ -181,11 +_,12 @@ .build(); public static AttributeSupplier getSupplier(EntityType p_22298_) { diff --git a/patches/minecraft/net/minecraft/world/entity/ai/navigation/PathNavigation.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/navigation/PathNavigation.java.patch index 36a855eea6..3ecbb8b468 100644 --- a/patches/minecraft/net/minecraft/world/entity/ai/navigation/PathNavigation.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/ai/navigation/PathNavigation.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/navigation/PathNavigation.java +++ b/net/minecraft/world/entity/ai/navigation/PathNavigation.java -@@ -252,10 +_,10 @@ +@@ -257,10 +_,10 @@ Vec3 vec3 = this.getTempMobPos(); this.maxDistanceToWaypoint = this.mob.getBbWidth() > 0.75F ? this.mob.getBbWidth() / 2.0F : 0.75F - this.mob.getBbWidth() / 2.0F; Vec3i vec3i = this.path.getNextNodePos(); diff --git a/patches/minecraft/net/minecraft/world/entity/ai/village/poi/PoiTypes.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/village/poi/PoiTypes.java.patch index ffef283c38..cda058566e 100644 --- a/patches/minecraft/net/minecraft/world/entity/ai/village/poi/PoiTypes.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/ai/village/poi/PoiTypes.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/entity/ai/village/poi/PoiTypes.java +++ b/net/minecraft/world/entity/ai/village/poi/PoiTypes.java -@@ -67,7 +_,7 @@ +@@ -73,7 +_,7 @@ .stream() - .flatMap(p_218093_ -> p_218093_.getStateDefinition().getPossibleStates().stream()) + .flatMap(p_421797_ -> p_421797_.getStateDefinition().getPossibleStates().stream()) .collect(ImmutableSet.toImmutableSet()); - private static final Map> TYPE_BY_STATE = Maps.newHashMap(); + private static final Map> TYPE_BY_STATE = net.minecraftforge.registries.GameData.PoiTypeCallbacks.getStateToPoi(); private static Set getBlockStates(Block p_218074_) { return ImmutableSet.copyOf(p_218074_.getStateDefinition().getPossibleStates()); -@@ -80,7 +_,6 @@ +@@ -86,7 +_,6 @@ private static PoiType register(Registry p_218085_, ResourceKey p_218086_, Set p_218087_, int p_218088_, int p_218089_) { PoiType poitype = new PoiType(p_218087_, p_218088_, p_218089_); Registry.register(p_218085_, p_218086_, poitype); diff --git a/patches/minecraft/net/minecraft/world/entity/animal/Animal.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/Animal.java.patch index fda0bf4551..9b9b1a83ee 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/Animal.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/Animal.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/Animal.java +++ b/net/minecraft/world/entity/animal/Animal.java -@@ -216,6 +_,17 @@ +@@ -204,6 +_,17 @@ public void spawnChildFromBreeding(ServerLevel p_27564_, Animal p_27565_) { AgeableMob ageablemob = this.getBreedOffspring(p_27564_, p_27565_); diff --git a/patches/minecraft/net/minecraft/world/entity/animal/Bee.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/Bee.java.patch index b495e96f03..390fd93e44 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/Bee.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/Bee.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/Bee.java +++ b/net/minecraft/world/entity/animal/Bee.java -@@ -504,7 +_,9 @@ +@@ -500,7 +_,9 @@ if (this.hivePos == null) { return null; } else { @@ -11,7 +11,7 @@ } } -@@ -667,13 +_,22 @@ +@@ -663,13 +_,22 @@ } @Override diff --git a/patches/minecraft/net/minecraft/world/entity/animal/MushroomCow.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/MushroomCow.java.patch index 9b0503a431..92575478e5 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/MushroomCow.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/MushroomCow.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/MushroomCow.java +++ b/net/minecraft/world/entity/animal/MushroomCow.java -@@ -115,7 +_,7 @@ +@@ -116,7 +_,7 @@ this.playSound(soundevent, 1.0F, 1.0F); return InteractionResult.SUCCESS; @@ -9,7 +9,7 @@ if (this.level() instanceof ServerLevel serverlevel) { this.shear(serverlevel, SoundSource.PLAYERS, itemstack); this.gameEvent(GameEvent.SHEAR, p_28941_); -@@ -170,15 +_,26 @@ +@@ -172,15 +_,26 @@ @Override public void shear(ServerLevel p_369641_, SoundSource p_28924_, ItemStack p_364876_) { @@ -25,21 +25,21 @@ + if (!net.minecraftforge.event.ForgeEventFactory.canLivingConvert(this, EntityType.COW, time -> {})) + return ret; p_369641_.playSound(null, this, SoundEvents.MOOSHROOM_SHEAR, p_28924_, 1.0F, 1.0F); - this.convertTo(EntityType.COW, ConversionParams.single(this, false, false), p_405458_ -> { + this.convertTo(EntityType.COW, ConversionParams.single(this, false, false), p_421807_ -> { p_369641_.sendParticles(ParticleTypes.EXPLOSION, this.getX(), this.getY(0.5), this.getZ(), 1, 0.0, 0.0, 0.0, 0.0); - this.dropFromShearingLootTable(p_369641_, BuiltInLootTables.SHEAR_MOOSHROOM, p_364876_, (p_405454_, p_405455_) -> { -- for (int i = 0; i < p_405455_.getCount(); i++) { -- p_405454_.addFreshEntity(new ItemEntity(this.level(), this.getX(), this.getY(1.0), this.getZ(), p_405455_.copyWithCount(1))); + this.dropFromShearingLootTable(p_369641_, BuiltInLootTables.SHEAR_MOOSHROOM, p_364876_, (p_421803_, p_421804_) -> { +- for (int i = 0; i < p_421804_.getCount(); i++) { +- p_421803_.addFreshEntity(new ItemEntity(this.level(), this.getX(), this.getY(1.0), this.getZ(), p_421804_.copyWithCount(1))); - } -+ ret.add(p_405455_); ++ ret.add(p_421804_); }); -+ net.minecraftforge.event.ForgeEventFactory.onLivingConvert(this, p_405458_); ++ net.minecraftforge.event.ForgeEventFactory.onLivingConvert(this, p_421807_); }); + return ret; } @Override -@@ -256,6 +_,15 @@ +@@ -258,6 +_,15 @@ } return mushroomcow$variant2; diff --git a/patches/minecraft/net/minecraft/world/entity/animal/Ocelot.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/Ocelot.java.patch index d3d80dfadf..e08a8b2a62 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/Ocelot.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/Ocelot.java.patch @@ -3,7 +3,7 @@ @@ -161,7 +_,7 @@ if ((this.temptGoal == null || this.temptGoal.isRunning()) && !this.isTrusting() && this.isFood(itemstack) && p_29021_.distanceToSqr(this) < 9.0) { this.usePlayerItem(p_29021_, p_29022_, itemstack); - if (!this.level().isClientSide) { + if (!this.level().isClientSide()) { - if (this.random.nextInt(3) == 0) { + if (this.random.nextInt(3) == 0 && !net.minecraftforge.event.ForgeEventFactory.onAnimalTame(this, p_29021_)) { this.setTrusting(true); diff --git a/patches/minecraft/net/minecraft/world/entity/animal/Parrot.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/Parrot.java.patch index f176d3624b..c89d18f37c 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/Parrot.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/Parrot.java.patch @@ -3,7 +3,7 @@ @@ -264,7 +_,7 @@ } - if (!this.level().isClientSide) { + if (!this.level().isClientSide()) { - if (this.random.nextInt(10) == 0) { + if (this.random.nextInt(10) == 0 && !net.minecraftforge.event.ForgeEventFactory.onAnimalTame(this, p_29414_)) { this.tame(p_29414_); diff --git a/patches/minecraft/net/minecraft/world/entity/animal/Pig.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/Pig.java.patch index d25c06b49a..6d9eaddb2f 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/Pig.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/Pig.java.patch @@ -6,13 +6,13 @@ public void thunderHit(ServerLevel p_29473_, LightningBolt p_29474_) { - if (p_29473_.getDifficulty() != Difficulty.PEACEFUL) { + if (p_29473_.getDifficulty() != Difficulty.PEACEFUL && net.minecraftforge.event.ForgeEventFactory.canLivingConvert(this, EntityType.ZOMBIFIED_PIGLIN, (timer) -> {})) { - ZombifiedPiglin zombifiedpiglin = this.convertTo(EntityType.ZOMBIFIED_PIGLIN, ConversionParams.single(this, false, true), p_405460_ -> { + ZombifiedPiglin zombifiedpiglin = this.convertTo(EntityType.ZOMBIFIED_PIGLIN, ConversionParams.single(this, false, true), p_421808_ -> { if (this.getMainHandItem().isEmpty()) { - p_405460_.setItemSlot(EquipmentSlot.MAINHAND, new ItemStack(Items.GOLDEN_SWORD)); + p_421808_.setItemSlot(EquipmentSlot.MAINHAND, new ItemStack(Items.GOLDEN_SWORD)); } - p_405460_.setPersistenceRequired(); -+ net.minecraftforge.event.ForgeEventFactory.onLivingConvert(this, p_405460_); + p_421808_.setPersistenceRequired(); ++ net.minecraftforge.event.ForgeEventFactory.onLivingConvert(this, p_421808_); }); if (zombifiedpiglin == null) { super.thunderHit(p_29473_, p_29474_); diff --git a/patches/minecraft/net/minecraft/world/entity/animal/allay/Allay.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/allay/Allay.java.patch index 1fefd6266c..c6c8093792 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/allay/Allay.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/allay/Allay.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/allay/Allay.java +++ b/net/minecraft/world/entity/animal/allay/Allay.java -@@ -354,7 +_,7 @@ +@@ -353,7 +_,7 @@ public boolean wantsToPickUp(ServerLevel p_363882_, ItemStack p_218387_) { ItemStack itemstack = this.getItemInHand(InteractionHand.MAIN_HAND); return !itemstack.isEmpty() diff --git a/patches/minecraft/net/minecraft/world/entity/animal/camel/Camel.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/camel/Camel.java.patch index 38e85ee168..d57ebe5df2 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/camel/Camel.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/camel/Camel.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/camel/Camel.java +++ b/net/minecraft/world/entity/animal/camel/Camel.java -@@ -344,7 +_,7 @@ +@@ -343,7 +_,7 @@ @Override protected void playStepSound(BlockPos p_252056_, BlockState p_251457_) { diff --git a/patches/minecraft/net/minecraft/world/entity/animal/horse/AbstractHorse.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/horse/AbstractHorse.java.patch index e3ae570a2b..f0b5f6ae76 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/horse/AbstractHorse.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/horse/AbstractHorse.java.patch @@ -32,7 +32,7 @@ } if (this.isVehicle() && this.canGallop) { -@@ -771,6 +_,7 @@ +@@ -777,6 +_,7 @@ float f1 = Mth.cos(this.getYRot() * (float) (Math.PI / 180.0)); this.setDeltaMovement(this.getDeltaMovement().add(-0.4F * f * p_248808_, 0.0, 0.4F * f1 * p_248808_)); } @@ -40,7 +40,7 @@ } protected void playJumpSound() { -@@ -1013,6 +_,26 @@ +@@ -1019,6 +_,26 @@ public boolean hasInventoryChanged(Container p_149512_) { return this.inventory != p_149512_; diff --git a/patches/minecraft/net/minecraft/world/entity/animal/sniffer/Sniffer.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/sniffer/Sniffer.java.patch index 08e79d02e9..b67df9220e 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/sniffer/Sniffer.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/sniffer/Sniffer.java.patch @@ -1,12 +1,11 @@ --- a/net/minecraft/world/entity/animal/sniffer/Sniffer.java +++ b/net/minecraft/world/entity/animal/sniffer/Sniffer.java -@@ -297,8 +_,7 @@ - } +@@ -297,7 +_,7 @@ if (this.tickCount % 10 == 0) { -- this.level() + this.level() - .playLocalSound(this.getX(), this.getY(), this.getZ(), blockstate.getSoundType().getHitSound(), this.getSoundSource(), 0.5F, 0.5F, false); -+ this.level().playLocalSound(this.getX(), this.getY(), this.getZ(), blockstate.getSoundType(level(), blockpos.below(), this).getHitSound(), this.getSoundSource(), 0.5F, 0.5F, false); ++ .playLocalSound(this.getX(), this.getY(), this.getZ(), blockstate.getSoundType(level(), blockpos.below(), this).getHitSound(), this.getSoundSource(), 0.5F, 0.5F, false); } } } diff --git a/patches/minecraft/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java.patch b/patches/minecraft/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java.patch index 905df29a26..afcf3ad431 100644 --- a/patches/minecraft/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java.patch @@ -41,7 +41,7 @@ + } + this.processFlappingMovement(); - if (this.level().isClientSide) { + if (this.level().isClientSide()) { this.setHealth(this.getHealth()); @@ -441,7 +_,7 @@ BlockPos blockpos = new BlockPos(k1, l1, i2); diff --git a/patches/minecraft/net/minecraft/world/entity/decoration/HangingEntity.java.patch b/patches/minecraft/net/minecraft/world/entity/decoration/HangingEntity.java.patch index abce3e8efc..696fde38ca 100644 --- a/patches/minecraft/net/minecraft/world/entity/decoration/HangingEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/decoration/HangingEntity.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/entity/decoration/HangingEntity.java +++ b/net/minecraft/world/entity/decoration/HangingEntity.java -@@ -86,6 +_,8 @@ +@@ -85,6 +_,8 @@ } else { - boolean flag = BlockPos.betweenClosedStream(this.calculateSupportBox()).allMatch(p_405497_ -> { - BlockState blockstate = this.level().getBlockState(p_405497_); -+ if (net.minecraft.world.level.block.Block.canSupportCenter(this.level(), p_405497_, this.getDirection())) + boolean flag = BlockPos.betweenClosedStream(this.calculateSupportBox()).allMatch(p_421846_ -> { + BlockState blockstate = this.level().getBlockState(p_421846_); ++ if (net.minecraft.world.level.block.Block.canSupportCenter(this.level(), p_421846_, this.getDirection())) + return true; return blockstate.isSolid() || DiodeBlock.isDiode(blockstate); }); - return !flag ? false : this.level().getEntities(this, this.getBoundingBox(), HANGING_ENTITY).isEmpty(); + return flag && this.canCoexist(false); diff --git a/patches/minecraft/net/minecraft/world/entity/item/ItemEntity.java.patch b/patches/minecraft/net/minecraft/world/entity/item/ItemEntity.java.patch index bcc0f9d764..eb460e352a 100644 --- a/patches/minecraft/net/minecraft/world/entity/item/ItemEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/item/ItemEntity.java.patch @@ -3,7 +3,7 @@ @@ -53,6 +_,10 @@ @Nullable private UUID target; - public final float bobOffs; + public final float bobOffs = this.random.nextFloat() * (float) Math.PI * 2.0F; + /** + * The maximum age of this EntityItem. The item is expired once this is reached. + */ @@ -11,23 +11,15 @@ public ItemEntity(EntityType p_31991_, Level p_31992_) { super(p_31991_, p_31992_); -@@ -71,6 +_,7 @@ +@@ -70,6 +_,7 @@ this.setPos(p_149664_, p_149665_, p_149666_); this.setDeltaMovement(p_149668_, p_149669_, p_149670_); this.setItem(p_149667_); + this.lifespan = (p_149667_.getItem() == null ? ItemEntity.LIFETIME : p_149667_.getEntityLifespan(p_149663_)); } - private ItemEntity(ItemEntity p_31994_) { -@@ -79,6 +_,7 @@ - this.copyPosition(p_31994_); - this.age = p_31994_.age; - this.bobOffs = p_31994_.bobOffs; -+ this.lifespan = p_31994_.lifespan; - } - @Override -@@ -117,6 +_,7 @@ +@@ -108,6 +_,7 @@ @Override public void tick() { @@ -35,7 +27,7 @@ if (this.getItem().isEmpty()) { this.discard(); } else { -@@ -129,6 +_,10 @@ +@@ -120,6 +_,10 @@ this.yo = this.getY(); this.zo = this.getZ(); Vec3 vec3 = this.getDeltaMovement(); @@ -46,7 +38,7 @@ if (this.isInWater() && this.getFluidHeight(FluidTags.WATER) > 0.1F) { this.setUnderwaterMovement(); } else if (this.isInLava() && this.getFluidHeight(FluidTags.LAVA) > 0.1F) { -@@ -151,7 +_,8 @@ +@@ -142,7 +_,8 @@ this.applyEffectsFromBlocks(); float f = 0.98F; if (this.onGround()) { @@ -56,13 +48,13 @@ } this.setDeltaMovement(this.getDeltaMovement().multiply(f, 0.98, f)); -@@ -183,7 +_,16 @@ +@@ -174,7 +_,16 @@ } } -- if (!this.level().isClientSide && this.age >= 6000) { +- if (!this.level().isClientSide() && this.age >= 6000) { + ItemStack item = this.getItem(); -+ if (!this.level().isClientSide && this.age >= lifespan) { ++ if (!this.level().isClientSide() && this.age >= lifespan) { + int hook = net.minecraftforge.event.ForgeEventFactory.onItemExpire(this, item); + if (hook < 0) { + this.discard(); @@ -74,7 +66,7 @@ this.discard(); } } -@@ -291,7 +_,7 @@ +@@ -282,7 +_,7 @@ this.health = (int)(this.health - p_362683_); this.gameEvent(GameEvent.ENTITY_DAMAGE, p_364841_.getEntity()); if (this.health <= 0) { @@ -83,7 +75,7 @@ this.discard(); } -@@ -309,6 +_,7 @@ +@@ -300,6 +_,7 @@ p_408006_.putShort("Health", (short)this.health); p_408006_.putShort("Age", (short)this.age); p_408006_.putShort("PickupDelay", (short)this.pickupDelay); @@ -91,7 +83,7 @@ EntityReference.store(this.thrower, p_408006_, "Thrower"); p_408006_.storeNullable("Owner", UUIDUtil.CODEC, this.target); if (!this.getItem().isEmpty()) { -@@ -321,6 +_,7 @@ +@@ -312,6 +_,7 @@ this.health = p_408031_.getShortOr("Health", (short)5); this.age = p_408031_.getShortOr("Age", (short)0); this.pickupDelay = p_408031_.getShortOr("PickupDelay", (short)0); @@ -99,10 +91,10 @@ this.target = p_408031_.read("Owner", UUIDUtil.CODEC).orElse(null); this.thrower = EntityReference.read(p_408031_, "Thrower"); this.setItem(p_408031_.read("Item", ItemStack.CODEC).orElse(ItemStack.EMPTY)); -@@ -332,10 +_,17 @@ +@@ -323,10 +_,17 @@ @Override public void playerTouch(Player p_32040_) { - if (!this.level().isClientSide) { + if (!this.level().isClientSide()) { + if (this.pickupDelay > 0) return; ItemStack itemstack = this.getItem(); Item item = itemstack.getItem(); @@ -118,7 +110,7 @@ p_32040_.take(this, i); if (itemstack.isEmpty()) { this.discard(); -@@ -428,7 +_,7 @@ +@@ -419,7 +_,7 @@ public void makeFakeItem() { this.setNeverPickUp(); diff --git a/patches/minecraft/net/minecraft/world/entity/monster/AbstractSkeleton.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/AbstractSkeleton.java.patch index a68dbb1485..96ea961747 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/AbstractSkeleton.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/AbstractSkeleton.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/entity/monster/AbstractSkeleton.java +++ b/net/minecraft/world/entity/monster/AbstractSkeleton.java @@ -161,7 +_,7 @@ - if (this.level() != null && !this.level().isClientSide) { + if (this.level() != null && !this.level().isClientSide()) { this.goalSelector.removeGoal(this.meleeGoal); this.goalSelector.removeGoal(this.bowGoal); - ItemStack itemstack = this.getItemInHand(ProjectileUtil.getWeaponHoldingHand(this, Items.BOW)); diff --git a/patches/minecraft/net/minecraft/world/entity/monster/EnderMan.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/EnderMan.java.patch index b369f97b73..249c7ca4c9 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/EnderMan.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/EnderMan.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/EnderMan.java +++ b/net/minecraft/world/entity/monster/EnderMan.java -@@ -112,7 +_,6 @@ +@@ -118,7 +_,6 @@ @Override public void setTarget(@Nullable LivingEntity p_32537_) { @@ -8,7 +8,7 @@ AttributeInstance attributeinstance = this.getAttribute(Attributes.MOVEMENT_SPEED); if (p_32537_ == null) { this.targetChangeTime = 0; -@@ -126,6 +_,7 @@ +@@ -132,6 +_,7 @@ attributeinstance.addTransientModifier(SPEED_MODIFIER_ATTACKING); } } @@ -16,7 +16,7 @@ } @Override -@@ -199,7 +_,7 @@ +@@ -205,7 +_,7 @@ } boolean isBeingStaredBy(Player p_368759_) { @@ -25,7 +25,7 @@ } @Override -@@ -277,8 +_,10 @@ +@@ -283,8 +_,10 @@ boolean flag = blockstate.blocksMotion(); boolean flag1 = blockstate.getFluidState().is(FluidTags.WATER); if (flag && !flag1) { @@ -37,7 +37,7 @@ if (flag2) { this.level().gameEvent(GameEvent.TELEPORT, vec3, GameEvent.Context.of(this)); if (!this.isSilent()) { -@@ -433,7 +_,7 @@ +@@ -439,7 +_,7 @@ if (this.enderman.getCarriedBlock() == null) { return false; } else { @@ -46,7 +46,7 @@ } } -@@ -451,7 +_,7 @@ +@@ -457,7 +_,7 @@ BlockState blockstate2 = this.enderman.getCarriedBlock(); if (blockstate2 != null) { blockstate2 = Block.updateFromNeighbourShapes(blockstate2, this.enderman.level(), blockpos); @@ -55,7 +55,7 @@ level.setBlock(blockpos, blockstate2, 3); level.gameEvent(GameEvent.BLOCK_PLACE, blockpos, GameEvent.Context.of(this.enderman, blockstate2)); this.enderman.setCarriedBlock(null); -@@ -463,6 +_,7 @@ +@@ -469,6 +_,7 @@ return p_32562_.isAir() && !p_32563_.isAir() && !p_32563_.is(Blocks.BEDROCK) @@ -63,7 +63,7 @@ && p_32563_.isCollisionShapeFullBlock(p_32559_, p_32564_) && p_32561_.canSurvive(p_32559_, p_32560_) && p_32559_.getEntities(this.enderman, AABB.unitCubeFromLowerCorner(Vec3.atLowerCornerOf(p_32560_))).isEmpty(); -@@ -572,7 +_,7 @@ +@@ -578,7 +_,7 @@ if (this.enderman.getCarriedBlock() != null) { return false; } else { diff --git a/patches/minecraft/net/minecraft/world/entity/monster/Husk.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/Husk.java.patch index 29b20e2df3..1d70eedfc3 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/Husk.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/Husk.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/Husk.java +++ b/net/minecraft/world/entity/monster/Husk.java -@@ -70,6 +_,7 @@ +@@ -69,6 +_,7 @@ @Override protected void doUnderWaterConversion() { diff --git a/patches/minecraft/net/minecraft/world/entity/monster/Monster.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/Monster.java.patch index f3d9d62e08..09801abc5a 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/Monster.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/Monster.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/Monster.java +++ b/net/minecraft/world/entity/monster/Monster.java -@@ -139,9 +_,9 @@ +@@ -135,9 +_,9 @@ if (p_33038_.getItem() instanceof ProjectileWeaponItem) { Predicate predicate = ((ProjectileWeaponItem)p_33038_.getItem()).getSupportedHeldProjectiles(); ItemStack itemstack = ProjectileWeaponItem.getHeldProjectile(this, predicate); diff --git a/patches/minecraft/net/minecraft/world/entity/monster/Skeleton.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/Skeleton.java.patch index b1211378cb..c850bca21b 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/Skeleton.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/Skeleton.java.patch @@ -1,10 +1,10 @@ --- a/net/minecraft/world/entity/monster/Skeleton.java +++ b/net/minecraft/world/entity/monster/Skeleton.java -@@ -94,6 +_,7 @@ +@@ -92,6 +_,7 @@ } protected void doFreezeConversion() { + if (!net.minecraftforge.event.ForgeEventFactory.canLivingConvert(this, EntityType.STRAY, (timer) -> this.conversionTime = timer)) return; - this.convertTo(EntityType.STRAY, ConversionParams.single(this, true, true), p_405508_ -> { + this.convertTo(EntityType.STRAY, ConversionParams.single(this, true, true), p_421860_ -> { if (!this.isSilent()) { this.level().levelEvent(null, 1048, this.blockPosition(), 0); diff --git a/patches/minecraft/net/minecraft/world/entity/monster/Slime.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/Slime.java.patch index 306369e8b2..0cf0501cc2 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/Slime.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/Slime.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/Slime.java +++ b/net/minecraft/world/entity/monster/Slime.java -@@ -148,13 +_,15 @@ +@@ -143,13 +_,15 @@ float f = this.getDimensions(this.getPose()).width() * 2.0F; float f1 = f / 2.0F; @@ -23,7 +23,7 @@ this.playSound(this.getSquishSound(), this.getSoundVolume(), ((this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F) / 0.8F); this.targetSquish = -0.5F; -@@ -165,6 +_,12 @@ +@@ -160,6 +_,12 @@ this.wasOnGround = this.onGround(); this.decreaseSquish(); } diff --git a/patches/minecraft/net/minecraft/world/entity/monster/Zombie.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/Zombie.java.patch index 9f1c019ef1..00700ee984 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/Zombie.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/Zombie.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/Zombie.java +++ b/net/minecraft/world/entity/monster/Zombie.java -@@ -265,21 +_,28 @@ +@@ -264,21 +_,28 @@ } protected void convertToZombieType(EntityType p_34311_) { @@ -8,10 +8,10 @@ this.convertTo( p_34311_, ConversionParams.single(this, true, true), -- p_405517_ -> p_405517_.handleAttributes(p_405517_.level().getCurrentDifficultyAt(p_405517_.blockPosition()).getSpecialMultiplier()) -+ p_375145_ -> { -+ p_375145_.handleAttributes(p_375145_.level().getCurrentDifficultyAt(p_375145_.blockPosition()).getSpecialMultiplier()); -+ net.minecraftforge.event.ForgeEventFactory.onLivingConvert(this, p_375145_); +- p_421869_ -> p_421869_.handleAttributes(p_421869_.level().getCurrentDifficultyAt(p_421869_.blockPosition()).getSpecialMultiplier()) ++ p_421869_ -> { ++ p_421869_.handleAttributes(p_421869_.level().getCurrentDifficultyAt(p_421869_.blockPosition()).getSpecialMultiplier()); ++ net.minecraftforge.event.ForgeEventFactory.onLivingConvert(this, p_421869_); + } ); } @@ -30,7 +30,7 @@ if (!this.isSilent()) { p_369430_.levelEvent(null, 1026, this.blockPosition(), 0); } -@@ -301,19 +_,26 @@ +@@ -300,19 +_,26 @@ livingentity = (LivingEntity)p_363403_.getEntity(); } @@ -38,8 +38,8 @@ + var vanilla = (livingentity != null && p_363771_.getDifficulty() == Difficulty.HARD && this.random.nextFloat() < this.getAttributeValue(Attributes.SPAWN_REINFORCEMENTS_CHANCE) -- && p_363771_.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING)) { -+ && p_363771_.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING)); +- && p_363771_.isSpawningMonsters()) { ++ && p_363771_.isSpawningMonsters()); int i = Mth.floor(this.getX()); int j = Mth.floor(this.getY()); int k = Mth.floor(this.getZ()); diff --git a/patches/minecraft/net/minecraft/world/entity/monster/ZombieVillager.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/ZombieVillager.java.patch index fa3ee270d0..18adb15f15 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/ZombieVillager.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/ZombieVillager.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/entity/monster/ZombieVillager.java +++ b/net/minecraft/world/entity/monster/ZombieVillager.java -@@ -115,7 +_,7 @@ - if (!this.level().isClientSide && this.isAlive() && this.isConverting()) { +@@ -123,7 +_,7 @@ + if (!this.level().isClientSide() && this.isAlive() && this.isConverting()) { int i = this.getConversionProgress(); this.villagerConversionTime -= i; - if (this.villagerConversionTime <= 0) { @@ -9,7 +9,7 @@ this.finishConversion((ServerLevel)this.level()); } } -@@ -222,6 +_,7 @@ +@@ -230,6 +_,7 @@ if (!this.isSilent()) { p_34399_.levelEvent(null, 1027, this.blockPosition(), 0); } diff --git a/patches/minecraft/net/minecraft/world/entity/monster/creaking/Creaking.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/creaking/Creaking.java.patch index 510e1ccfae..885b9e67b3 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/creaking/Creaking.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/creaking/Creaking.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/creaking/Creaking.java +++ b/net/minecraft/world/entity/monster/creaking/Creaking.java -@@ -489,7 +_,7 @@ +@@ -482,7 +_,7 @@ for (Player player : list) { if (this.canAttack(player) && !this.isAlliedTo(player)) { flag1 = true; diff --git a/patches/minecraft/net/minecraft/world/entity/monster/hoglin/Hoglin.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/hoglin/Hoglin.java.patch index 38a639ebad..40c36b8855 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/hoglin/Hoglin.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/hoglin/Hoglin.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/hoglin/Hoglin.java +++ b/net/minecraft/world/entity/monster/hoglin/Hoglin.java -@@ -170,7 +_,7 @@ +@@ -169,7 +_,7 @@ HoglinAi.updateActivity(this); if (this.isConverting()) { this.timeInOverworld++; @@ -9,7 +9,7 @@ this.makeSound(SoundEvents.HOGLIN_CONVERTED_TO_ZOMBIFIED); this.finishConversion(); } -@@ -268,7 +_,10 @@ +@@ -267,7 +_,10 @@ this.convertTo( EntityType.ZOGLIN, ConversionParams.single(this, true, false), diff --git a/patches/minecraft/net/minecraft/world/entity/monster/piglin/AbstractPiglin.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/piglin/AbstractPiglin.java.patch index 42b5612db4..7d5a92347f 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/piglin/AbstractPiglin.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/piglin/AbstractPiglin.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/piglin/AbstractPiglin.java +++ b/net/minecraft/world/entity/monster/piglin/AbstractPiglin.java -@@ -83,7 +_,7 @@ +@@ -82,7 +_,7 @@ this.timeInOverworld = 0; } @@ -9,7 +9,7 @@ this.playConvertedSound(); this.finishConversion(p_360786_); } -@@ -102,7 +_,10 @@ +@@ -101,7 +_,10 @@ this.convertTo( EntityType.ZOMBIFIED_PIGLIN, ConversionParams.single(this, true, true), diff --git a/patches/minecraft/net/minecraft/world/entity/monster/piglin/Piglin.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/piglin/Piglin.java.patch index 1802051606..74b0ccff8a 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/piglin/Piglin.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/piglin/Piglin.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/piglin/Piglin.java +++ b/net/minecraft/world/entity/monster/piglin/Piglin.java -@@ -357,7 +_,7 @@ +@@ -345,7 +_,7 @@ } else if (this.isChargingCrossbow()) { return PiglinArmPose.CROSSBOW_CHARGE; } else { @@ -9,7 +9,7 @@ } } -@@ -394,7 +_,7 @@ +@@ -382,7 +_,7 @@ } protected void holdInOffHand(ItemStack p_34786_) { @@ -18,7 +18,7 @@ this.setItemSlot(EquipmentSlot.OFFHAND, p_34786_); this.setGuaranteedDrop(EquipmentSlot.OFFHAND); } else { -@@ -404,7 +_,7 @@ +@@ -392,7 +_,7 @@ @Override public boolean wantsToPickUp(ServerLevel p_369934_, ItemStack p_34777_) { diff --git a/patches/minecraft/net/minecraft/world/entity/npc/CatSpawner.java.patch b/patches/minecraft/net/minecraft/world/entity/npc/CatSpawner.java.patch index a23064d1fc..b763963b50 100644 --- a/patches/minecraft/net/minecraft/world/entity/npc/CatSpawner.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/npc/CatSpawner.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/npc/CatSpawner.java +++ b/net/minecraft/world/entity/npc/CatSpawner.java -@@ -69,12 +_,12 @@ +@@ -66,12 +_,12 @@ private void spawnCat(BlockPos p_35334_, ServerLevel p_35335_, boolean p_392522_) { Cat cat = EntityType.CAT.create(p_35335_, EntitySpawnReason.NATURAL); if (cat != null) { diff --git a/patches/minecraft/net/minecraft/world/entity/npc/Villager.java.patch b/patches/minecraft/net/minecraft/world/entity/npc/Villager.java.patch index 511401dc68..2ae64b1144 100644 --- a/patches/minecraft/net/minecraft/world/entity/npc/Villager.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/npc/Villager.java.patch @@ -16,5 +16,5 @@ - if (p_35409_.getDifficulty() != Difficulty.PEACEFUL) { + if (p_35409_.getDifficulty() != Difficulty.PEACEFUL && net.minecraftforge.event.ForgeEventFactory.canLivingConvert(this, EntityType.WITCH, (timer) -> {})) { LOGGER.info("Villager {} was struck by lightning {}.", this, p_35410_); - Witch witch = this.convertTo(EntityType.WITCH, ConversionParams.single(this, false, false), p_405546_ -> { - p_405546_.finalizeSpawn(p_35409_, p_35409_.getCurrentDifficultyAt(p_405546_.blockPosition()), EntitySpawnReason.CONVERSION, null); + Witch witch = this.convertTo(EntityType.WITCH, ConversionParams.single(this, false, false), p_421901_ -> { + p_421901_.finalizeSpawn(p_35409_, p_35409_.getCurrentDifficultyAt(p_421901_.blockPosition()), EntitySpawnReason.CONVERSION, null); diff --git a/patches/minecraft/net/minecraft/world/entity/player/Inventory.java.patch b/patches/minecraft/net/minecraft/world/entity/player/Inventory.java.patch index 1690254d98..ccf24a7062 100644 --- a/patches/minecraft/net/minecraft/world/entity/player/Inventory.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/player/Inventory.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/player/Inventory.java +++ b/net/minecraft/world/entity/player/Inventory.java -@@ -90,6 +_,10 @@ +@@ -91,6 +_,10 @@ return this.items; } @@ -11,7 +11,7 @@ private boolean hasRemainingSpaceForItem(ItemStack p_36015_, ItemStack p_36016_) { return !p_36015_.isEmpty() && ItemStack.isSameItemSameComponents(p_36015_, p_36016_) && p_36015_.isStackable() && p_36015_.getCount() < this.getMaxStackSize(p_36015_); } -@@ -165,7 +_,7 @@ +@@ -166,7 +_,7 @@ for (int k = 0; k < 9; k++) { int l = (this.selected + k) % 9; @@ -20,7 +20,7 @@ return l; } } -@@ -236,7 +_,7 @@ +@@ -237,7 +_,7 @@ for (int i = 0; i < this.items.size(); i++) { ItemStack itemstack = this.getItem(i); if (!itemstack.isEmpty()) { @@ -29,7 +29,7 @@ } } } -@@ -286,6 +_,8 @@ +@@ -287,6 +_,8 @@ } catch (Throwable throwable) { CrashReport crashreport = CrashReport.forThrowable(throwable, "Adding item to inventory"); CrashReportCategory crashreportcategory = crashreport.addCategory("Item being added"); diff --git a/patches/minecraft/net/minecraft/world/entity/player/Player.java.patch b/patches/minecraft/net/minecraft/world/entity/player/Player.java.patch index 25fa14e1d9..ac2376eb1f 100644 --- a/patches/minecraft/net/minecraft/world/entity/player/Player.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/player/Player.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/entity/player/Player.java +++ b/net/minecraft/world/entity/player/Player.java -@@ -126,7 +_,7 @@ +@@ -119,7 +_,7 @@ + import net.minecraft.world.scores.PlayerTeam; import net.minecraft.world.scores.Team; - import org.slf4j.Logger; --public abstract class Player extends LivingEntity { -+public abstract class Player extends LivingEntity implements net.minecraftforge.common.extensions.IForgePlayer { - private static final Logger LOGGER = LogUtils.getLogger(); - public static final HumanoidArm DEFAULT_MAIN_HAND = HumanoidArm.RIGHT; - public static final int DEFAULT_MODEL_CUSTOMIZATION = 0; -@@ -216,6 +_,9 @@ +-public abstract class Player extends Avatar implements ContainerUser { ++public abstract class Player extends Avatar implements ContainerUser, net.minecraftforge.common.extensions.IForgePlayer { + public static final int MAX_HEALTH = 20; + public static final int SLEEP_DURATION = 100; + public static final int WAKE_UP_DURATION = 10; +@@ -175,6 +_,9 @@ public Entity currentExplosionCause; private boolean ignoreFallDamageFromCurrentImpulse = false; private int currentImpulseContextResetGraceTime = 0; @@ -19,9 +19,9 @@ public Player(Level p_250508_, GameProfile p_252153_) { super(EntityType.PLAYER, p_250508_); -@@ -224,6 +_,17 @@ +@@ -183,6 +_,17 @@ this.inventory = new Inventory(this, this.equipment); - this.inventoryMenu = new InventoryMenu(this.inventory, !p_250508_.isClientSide, this); + this.inventoryMenu = new InventoryMenu(this.inventory, !p_250508_.isClientSide(), this); this.containerMenu = this.inventoryMenu; + + // Forge: wrapped inventories moved to constructor as the inventory init was moved in here too @@ -37,7 +37,7 @@ } @Override -@@ -258,7 +_,8 @@ +@@ -217,7 +_,8 @@ .add(Attributes.MINING_EFFICIENCY) .add(Attributes.SWEEPING_DAMAGE_RATIO) .add(Attributes.WAYPOINT_TRANSMIT_RANGE, 6.0E7) @@ -47,7 +47,7 @@ } @Override -@@ -274,6 +_,7 @@ +@@ -231,6 +_,7 @@ @Override public void tick() { @@ -55,16 +55,16 @@ this.noPhysics = this.isSpectator(); if (this.isSpectator() || this.isPassenger()) { this.setOnGround(false); -@@ -289,7 +_,7 @@ +@@ -246,7 +_,7 @@ this.sleepCounter = 100; } -- if (!this.level().isClientSide && this.level().isBrightOutside()) { -+ if (!this.level().isClientSide && !net.minecraftforge.event.ForgeEventFactory.onSleepingTimeCheck(this, getSleepingPos())) { +- if (!this.level().isClientSide() && this.level().isBrightOutside()) { ++ if (!this.level().isClientSide() && !net.minecraftforge.event.ForgeEventFactory.onSleepingTimeCheck(this, getSleepingPos())) { this.stopSleepInBed(false, true); } } else if (this.sleepCounter > 0) { -@@ -350,6 +_,7 @@ +@@ -284,6 +_,7 @@ if (this.currentImpulseContextResetGraceTime > 0) { this.currentImpulseContextResetGraceTime--; } @@ -72,7 +72,7 @@ } @Override -@@ -452,6 +_,10 @@ +@@ -343,6 +_,10 @@ } protected void updatePlayerPose() { @@ -83,7 +83,7 @@ if (this.canPlayerFitWithinBlocksAndEntitiesWhen(Pose.SWIMMING)) { Pose pose = this.getDesiredPose(); Pose pose1; -@@ -670,6 +_,7 @@ +@@ -531,6 +_,7 @@ @Override public void die(DamageSource p_36152_) { @@ -91,7 +91,7 @@ super.die(p_36152_); this.reapplyPosition(); if (!this.isSpectator() && this.level() instanceof ServerLevel serverlevel) { -@@ -727,10 +_,15 @@ +@@ -588,10 +_,15 @@ @Nullable public ItemEntity drop(ItemStack p_36177_, boolean p_36178_) { @@ -108,7 +108,7 @@ float f = this.inventory.getSelectedItem().getDestroySpeed(p_36282_); if (f > 1.0F) { f += (float)this.getAttributeValue(Attributes.MINING_EFFICIENCY); -@@ -759,11 +_,14 @@ +@@ -620,11 +_,14 @@ f /= 5.0F; } @@ -124,7 +124,7 @@ } @Override -@@ -840,6 +_,7 @@ +@@ -691,6 +_,7 @@ @Override public boolean hurtServer(ServerLevel p_369360_, DamageSource p_364544_, float p_368576_) { @@ -132,7 +132,7 @@ if (this.isInvulnerableTo(p_369360_, p_364544_)) { return false; } else if (this.abilities.invulnerable && !p_364544_.is(DamageTypeTags.BYPASSES_INVULNERABILITY)) { -@@ -908,10 +_,13 @@ +@@ -759,10 +_,13 @@ @Override protected void actuallyHurt(ServerLevel p_365751_, DamageSource p_36312_, float p_36313_) { if (!this.isInvulnerableTo(p_365751_, p_36312_)) { @@ -146,7 +146,7 @@ float f = p_36313_ - f1; if (f > 0.0F && f < 3.4028235E37F) { this.awardStat(Stats.DAMAGE_ABSORBED, Math.round(f * 10.0F)); -@@ -979,6 +_,10 @@ +@@ -830,6 +_,10 @@ return InteractionResult.PASS; } else { @@ -157,26 +157,26 @@ ItemStack itemstack = this.getItemInHand(p_36159_); ItemStack itemstack1 = itemstack.copy(); InteractionResult interactionresult = p_36158_.interact(this, p_36159_); -@@ -987,6 +_,10 @@ +@@ -838,6 +_,10 @@ itemstack.setCount(itemstack1.getCount()); } + if (!this.abilities.instabuild && itemstack.isEmpty()) { -+ net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(this, itemstack1, getSlotForHand(p_36159_)); ++ net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(this, itemstack1, p_36159_.asEquipmentSlot()); + } + return interactionresult; } else { if (!itemstack.isEmpty() && p_36158_ instanceof LivingEntity) { -@@ -998,6 +_,7 @@ +@@ -849,6 +_,7 @@ if (interactionresult1.consumesAction()) { this.level().gameEvent(GameEvent.ENTITY_INTERACT, p_36158_.position(), GameEvent.Context.of(this)); if (itemstack.isEmpty() && !this.hasInfiniteMaterials()) { -+ net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(this, itemstack1, getSlotForHand(p_36159_)); ++ net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(this, itemstack1, p_36159_.asEquipmentSlot()); this.setItemInHand(p_36159_, ItemStack.EMPTY); } -@@ -1097,6 +_,7 @@ +@@ -948,6 +_,7 @@ } public void attack(Entity p_36347_) { @@ -184,7 +184,7 @@ if (p_36347_.isAttackable()) { if (!p_36347_.skipAttackInteraction(this)) { float f = this.isAutoSpinAttack() ? this.autoSpinAttackDmg : (float)this.getAttributeValue(Attributes.ATTACK_DAMAGE); -@@ -1132,8 +_,10 @@ +@@ -983,8 +_,10 @@ && !this.isPassenger() && p_36347_ instanceof LivingEntity && !this.isSprinting(); @@ -196,7 +196,7 @@ } float f3 = f + f1; -@@ -1141,7 +_,7 @@ +@@ -992,7 +_,7 @@ if (flag3 && !flag1 && !flag && this.onGround()) { double d0 = this.getKnownMovement().horizontalDistanceSqr(); double d1 = this.getSpeed() * 2.5; @@ -205,7 +205,7 @@ flag2 = true; } } -@@ -1177,7 +_,7 @@ +@@ -1028,7 +_,7 @@ if (flag2) { float f6 = 1.0F + (float)this.getAttributeValue(Attributes.SWEEPING_DAMAGE_RATIO) * f; @@ -214,7 +214,7 @@ if (livingentity2 != this && livingentity2 != p_36347_ && !this.isAlliedTo(livingentity2) -@@ -1228,8 +_,8 @@ +@@ -1079,8 +_,8 @@ this.setLastHurtMob(p_36347_); Entity entity = p_36347_; @@ -225,7 +225,7 @@ } boolean flag5 = false; -@@ -1273,6 +_,7 @@ +@@ -1124,6 +_,7 @@ } } } @@ -233,7 +233,7 @@ } } } -@@ -1375,6 +_,7 @@ +@@ -1230,6 +_,7 @@ } public void stopSleepInBed(boolean p_36226_, boolean p_36227_) { @@ -241,7 +241,7 @@ super.stopSleeping(); if (this.level() instanceof ServerLevel && p_36227_) { ((ServerLevel)this.level()).updateSleepingPlayerList(); -@@ -1483,6 +_,7 @@ +@@ -1338,6 +_,7 @@ @Override public boolean causeFallDamage(double p_391627_, float p_150093_, DamageSource p_150095_) { if (this.abilities.mayfly) { @@ -249,7 +249,7 @@ return false; } else { if (p_391627_ >= 2.0) { -@@ -1537,13 +_,13 @@ +@@ -1392,13 +_,13 @@ protected void playStepSound(BlockPos p_282121_, BlockState p_282194_) { if (this.isInWater()) { this.waterSwimSound(); @@ -265,7 +265,7 @@ } else { super.playStepSound(blockpos, blockstate); } -@@ -1574,6 +_,12 @@ +@@ -1429,6 +_,12 @@ } public void giveExperiencePoints(int p_36291_) { @@ -278,7 +278,7 @@ this.increaseScore(p_36291_); this.experienceProgress = this.experienceProgress + (float)p_36291_ / this.getXpNeededForNextLevel(); this.totalExperience = Mth.clamp(this.totalExperience + p_36291_, 0, Integer.MAX_VALUE); -@@ -1601,7 +_,7 @@ +@@ -1456,7 +_,7 @@ } public void onEnchantmentPerformed(ItemStack p_36172_, int p_36173_) { @@ -287,7 +287,7 @@ if (this.experienceLevel < 0) { this.experienceLevel = 0; this.experienceProgress = 0.0F; -@@ -1612,6 +_,12 @@ +@@ -1467,6 +_,12 @@ } public void giveExperienceLevels(int p_36276_) { @@ -300,7 +300,7 @@ this.experienceLevel = IntMath.saturatedAdd(this.experienceLevel, p_36276_); if (this.experienceLevel < 0) { this.experienceLevel = 0; -@@ -1791,7 +_,13 @@ +@@ -1602,7 +_,13 @@ @Override public Component getDisplayName() { @@ -315,7 +315,7 @@ return this.decorateDisplayNameComponent(mutablecomponent); } -@@ -1953,18 +_,19 @@ +@@ -1765,18 +_,19 @@ Predicate predicate = ((ProjectileWeaponItem)p_36349_.getItem()).getSupportedHeldProjectiles(); ItemStack itemstack = ProjectileWeaponItem.getHeldProjectile(this, predicate); if (!itemstack.isEmpty()) { @@ -338,7 +338,7 @@ } } } -@@ -2109,6 +_,54 @@ +@@ -1935,6 +_,54 @@ this.currentImpulseImpactPos = null; this.ignoreFallDamageFromCurrentImpulse = false; } diff --git a/patches/minecraft/net/minecraft/world/entity/projectile/AbstractArrow.java.patch b/patches/minecraft/net/minecraft/world/entity/projectile/AbstractArrow.java.patch index ddbd779e36..a6b07d44d9 100644 --- a/patches/minecraft/net/minecraft/world/entity/projectile/AbstractArrow.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/projectile/AbstractArrow.java.patch @@ -17,7 +17,7 @@ this.clearFire(); } -@@ -566,7 +_,7 @@ +@@ -568,7 +_,7 @@ protected boolean canHitEntity(Entity p_36743_) { return p_36743_ instanceof Player && this.getOwner() instanceof Player player && !player.canHarmPlayer((Player)p_36743_) ? false diff --git a/patches/minecraft/net/minecraft/world/entity/projectile/FishingHook.java.patch b/patches/minecraft/net/minecraft/world/entity/projectile/FishingHook.java.patch index 700a1200bb..e9da1aa6b1 100644 --- a/patches/minecraft/net/minecraft/world/entity/projectile/FishingHook.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/projectile/FishingHook.java.patch @@ -1,17 +1,17 @@ --- a/net/minecraft/world/entity/projectile/FishingHook.java +++ b/net/minecraft/world/entity/projectile/FishingHook.java -@@ -251,8 +_,8 @@ - private boolean shouldStopFishing(Player p_37137_) { - ItemStack itemstack = p_37137_.getMainHandItem(); - ItemStack itemstack1 = p_37137_.getOffhandItem(); -- boolean flag = itemstack.is(Items.FISHING_ROD); -- boolean flag1 = itemstack1.is(Items.FISHING_ROD); -+ boolean flag = itemstack.canPerformAction(net.minecraftforge.common.ToolActions.FISHING_ROD_CAST); -+ boolean flag1 = itemstack1.canPerformAction(net.minecraftforge.common.ToolActions.FISHING_ROD_CAST); - if (!p_37137_.isRemoved() && p_37137_.isAlive() && (flag || flag1) && !(this.distanceToSqr(p_37137_) > 1024.0)) { - return false; - } else { -@@ -263,6 +_,7 @@ +@@ -252,8 +_,8 @@ + if (p_37137_.canInteractWithLevel()) { + ItemStack itemstack = p_37137_.getMainHandItem(); + ItemStack itemstack1 = p_37137_.getOffhandItem(); +- boolean flag = itemstack.is(Items.FISHING_ROD); +- boolean flag1 = itemstack1.is(Items.FISHING_ROD); ++ boolean flag = itemstack.canPerformAction(net.minecraftforge.common.ToolActions.FISHING_ROD_CAST); ++ boolean flag1 = itemstack1.canPerformAction(net.minecraftforge.common.ToolActions.FISHING_ROD_CAST); + if ((flag || flag1) && this.distanceToSqr(p_37137_) <= 1024.0) { + return false; + } +@@ -265,6 +_,7 @@ private void checkCollision() { HitResult hitresult = ProjectileUtil.getHitResultOnMoveVector(this, this::canHitEntity); @@ -19,15 +19,15 @@ this.hitTargetOrDeflectSelf(hitresult); } -@@ -452,6 +_,7 @@ +@@ -454,6 +_,7 @@ Player player = this.getPlayerOwner(); - if (!this.level().isClientSide && player != null && !this.shouldStopFishing(player)) { + if (!this.level().isClientSide() && player != null && !this.shouldStopFishing(player)) { int i = 0; + net.minecraftforge.event.entity.player.ItemFishedEvent event = null; if (this.hookedIn != null) { this.pullEntity(this.hookedIn); CriteriaTriggers.FISHING_ROD_HOOKED.trigger((ServerPlayer)player, p_37157_, this, Collections.emptyList()); -@@ -462,10 +_,16 @@ +@@ -464,10 +_,16 @@ .withParameter(LootContextParams.ORIGIN, this.position()) .withParameter(LootContextParams.TOOL, p_37157_) .withParameter(LootContextParams.THIS_ENTITY, this) @@ -44,7 +44,7 @@ CriteriaTriggers.FISHING_ROD_HOOKED.trigger((ServerPlayer)player, p_37157_, this, list); for (ItemStack itemstack : list) { -@@ -495,7 +_,7 @@ +@@ -497,7 +_,7 @@ } this.discard(); diff --git a/patches/minecraft/net/minecraft/world/entity/projectile/Projectile.java.patch b/patches/minecraft/net/minecraft/world/entity/projectile/Projectile.java.patch index 5e7fff0f10..9ca3bc66fd 100644 --- a/patches/minecraft/net/minecraft/world/entity/projectile/Projectile.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/projectile/Projectile.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/Projectile.java +++ b/net/minecraft/world/entity/projectile/Projectile.java -@@ -345,7 +_,7 @@ +@@ -351,7 +_,7 @@ @Override public boolean mayInteract(ServerLevel p_364907_, BlockPos p_150168_) { Entity entity = this.getOwner(); diff --git a/patches/minecraft/net/minecraft/world/entity/projectile/ThrownEnderpearl.java.patch b/patches/minecraft/net/minecraft/world/entity/projectile/ThrownEnderpearl.java.patch index ac3ec46c50..ec314ce6f3 100644 --- a/patches/minecraft/net/minecraft/world/entity/projectile/ThrownEnderpearl.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/projectile/ThrownEnderpearl.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/ThrownEnderpearl.java +++ b/net/minecraft/world/entity/projectile/ThrownEnderpearl.java -@@ -119,6 +_,13 @@ +@@ -106,6 +_,13 @@ Vec3 vec3 = this.oldPosition(); if (entity instanceof ServerPlayer serverplayer) { if (serverplayer.connection.isAcceptingMessages()) { @@ -11,10 +11,10 @@ + } + vec3 = event.getTarget(); + - if (this.random.nextFloat() < 0.05F && serverlevel.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING)) { + if (this.random.nextFloat() < 0.05F && serverlevel.isSpawningMonsters()) { Endermite endermite = EntityType.ENDERMITE.create(serverlevel, EntitySpawnReason.TRIGGERED); if (endermite != null) { -@@ -145,7 +_,7 @@ +@@ -132,7 +_,7 @@ if (serverplayer1 != null) { serverplayer1.resetFallDistance(); serverplayer1.resetCurrentImpulseContext(); diff --git a/patches/minecraft/net/minecraft/world/entity/raid/Raid.java.patch b/patches/minecraft/net/minecraft/world/entity/raid/Raid.java.patch index 2549652b4f..e72fd28ba4 100644 --- a/patches/minecraft/net/minecraft/world/entity/raid/Raid.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/raid/Raid.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/raid/Raid.java +++ b/net/minecraft/world/entity/raid/Raid.java -@@ -801,7 +_,7 @@ +@@ -823,7 +_,7 @@ } } @@ -9,7 +9,7 @@ VINDICATOR(EntityType.VINDICATOR, new int[]{0, 0, 2, 0, 1, 4, 2, 5}), EVOKER(EntityType.EVOKER, new int[]{0, 0, 0, 0, 0, 1, 1, 2}), PILLAGER(EntityType.PILLAGER, new int[]{0, 4, 3, 3, 4, 4, 4, 2}), -@@ -815,6 +_,20 @@ +@@ -837,6 +_,20 @@ private RaiderType(final EntityType p_37821_, final int[] p_37822_) { this.entityType = p_37821_; this.spawnsPerWaveBeforeBonus = p_37822_; diff --git a/patches/minecraft/net/minecraft/world/entity/vehicle/AbstractBoat.java.patch b/patches/minecraft/net/minecraft/world/entity/vehicle/AbstractBoat.java.patch index 2421658abc..ec8d3dc8ad 100644 --- a/patches/minecraft/net/minecraft/world/entity/vehicle/AbstractBoat.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/vehicle/AbstractBoat.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/vehicle/AbstractBoat.java +++ b/net/minecraft/world/entity/vehicle/AbstractBoat.java -@@ -48,7 +_,7 @@ +@@ -46,7 +_,7 @@ import net.minecraft.world.phys.shapes.Shapes; import net.minecraft.world.phys.shapes.VoxelShape; @@ -9,7 +9,7 @@ private static final EntityDataAccessor DATA_ID_PADDLE_LEFT = SynchedEntityData.defineId(AbstractBoat.class, EntityDataSerializers.BOOLEAN); private static final EntityDataAccessor DATA_ID_PADDLE_RIGHT = SynchedEntityData.defineId(AbstractBoat.class, EntityDataSerializers.BOOLEAN); private static final EntityDataAccessor DATA_ID_BUBBLE_TIME = SynchedEntityData.defineId(AbstractBoat.class, EntityDataSerializers.INT); -@@ -427,7 +_,7 @@ +@@ -423,7 +_,7 @@ for (int i2 = i1; i2 < j1; i2++) { blockpos$mutableblockpos.set(l1, k1, i2); FluidState fluidstate = this.level().getFluidState(blockpos$mutableblockpos); @@ -18,7 +18,7 @@ f = Math.max(f, fluidstate.getHeight(this.level(), blockpos$mutableblockpos)); } -@@ -473,7 +_,7 @@ +@@ -469,7 +_,7 @@ voxelshape, BooleanOp.AND )) { @@ -27,7 +27,7 @@ k1++; } } -@@ -502,7 +_,7 @@ +@@ -498,7 +_,7 @@ for (int i2 = i1; i2 < j1; i2++) { blockpos$mutableblockpos.set(k1, l1, i2); FluidState fluidstate = this.level().getFluidState(blockpos$mutableblockpos); @@ -36,7 +36,7 @@ float f = l1 + fluidstate.getHeight(this.level(), blockpos$mutableblockpos); this.waterLevel = Math.max((double)f, this.waterLevel); flag |= aabb.minY < f; -@@ -532,7 +_,7 @@ +@@ -528,7 +_,7 @@ for (int i2 = i1; i2 < j1; i2++) { blockpos$mutableblockpos.set(k1, l1, i2); FluidState fluidstate = this.level().getFluidState(blockpos$mutableblockpos); @@ -45,7 +45,7 @@ && d0 < blockpos$mutableblockpos.getY() + fluidstate.getHeight(this.level(), blockpos$mutableblockpos)) { if (!fluidstate.isSource()) { return AbstractBoat.Status.UNDER_FLOWING_WATER; -@@ -735,7 +_,7 @@ +@@ -731,7 +_,7 @@ if (!this.isPassenger()) { if (p_361999_) { this.resetFallDistance(); @@ -54,7 +54,7 @@ this.fallDistance -= (float)p_361830_; } } -@@ -759,7 +_,7 @@ +@@ -755,7 +_,7 @@ @Override protected boolean canAddPassenger(Entity p_366021_) { diff --git a/patches/minecraft/net/minecraft/world/entity/vehicle/AbstractMinecart.java.patch b/patches/minecraft/net/minecraft/world/entity/vehicle/AbstractMinecart.java.patch index 25e99e9b83..db1db9aa3b 100644 --- a/patches/minecraft/net/minecraft/world/entity/vehicle/AbstractMinecart.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/vehicle/AbstractMinecart.java.patch @@ -36,7 +36,7 @@ } @Override -@@ -361,16 +_,24 @@ +@@ -360,16 +_,24 @@ } protected void comeOffTrack(ServerLevel p_365684_) { @@ -63,7 +63,7 @@ } } -@@ -427,7 +_,7 @@ +@@ -426,7 +_,7 @@ public Vec3 getRedstoneDirection(BlockPos p_369874_) { BlockState blockstate = this.level().getBlockState(p_369874_); if (blockstate.is(Blocks.POWERED_RAIL) && blockstate.getValue(PoweredRailBlock.POWERED)) { @@ -72,7 +72,7 @@ if (railshape == RailShape.EAST_WEST) { if (this.isRedstoneConductor(p_369874_.west())) { return new Vec3(1.0, 0.0, 0.0); -@@ -599,5 +_,42 @@ +@@ -598,5 +_,42 @@ public boolean isFurnace() { return false; diff --git a/patches/minecraft/net/minecraft/world/entity/vehicle/MinecartCommandBlock.java.patch b/patches/minecraft/net/minecraft/world/entity/vehicle/MinecartCommandBlock.java.patch index b018066b44..52223a23a7 100644 --- a/patches/minecraft/net/minecraft/world/entity/vehicle/MinecartCommandBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/vehicle/MinecartCommandBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/vehicle/MinecartCommandBlock.java +++ b/net/minecraft/world/entity/vehicle/MinecartCommandBlock.java -@@ -83,6 +_,8 @@ +@@ -84,6 +_,8 @@ @Override public InteractionResult interact(Player p_38522_, InteractionHand p_38523_) { diff --git a/patches/minecraft/net/minecraft/world/entity/vehicle/MinecartFurnace.java.patch b/patches/minecraft/net/minecraft/world/entity/vehicle/MinecartFurnace.java.patch index e2a4bab32a..6a4e7cad92 100644 --- a/patches/minecraft/net/minecraft/world/entity/vehicle/MinecartFurnace.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/vehicle/MinecartFurnace.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/vehicle/MinecartFurnace.java +++ b/net/minecraft/world/entity/vehicle/MinecartFurnace.java -@@ -149,4 +_,9 @@ +@@ -157,4 +_,9 @@ public BlockState getDefaultDisplayBlockState() { return Blocks.FURNACE.defaultBlockState().setValue(FurnaceBlock.FACING, Direction.NORTH).setValue(FurnaceBlock.LIT, this.hasFuel()); } diff --git a/patches/minecraft/net/minecraft/world/item/AxeItem.java.patch b/patches/minecraft/net/minecraft/world/item/AxeItem.java.patch index 3cba279507..8903a80916 100644 --- a/patches/minecraft/net/minecraft/world/item/AxeItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/AxeItem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/AxeItem.java +++ b/net/minecraft/world/item/AxeItem.java -@@ -62,7 +_,7 @@ +@@ -64,7 +_,7 @@ if (playerHasBlockingItemUseIntent(p_40529_)) { return InteractionResult.PASS; } else { @@ -9,7 +9,7 @@ if (optional.isEmpty()) { return InteractionResult.PASS; } else { -@@ -88,18 +_,25 @@ +@@ -90,17 +_,24 @@ } private Optional evaluateNewBlockState(Level p_312809_, BlockPos p_313114_, @Nullable Player p_312029_, BlockState p_311198_) { @@ -28,8 +28,7 @@ + var scrape = ctx == null ? null : p_311198_.getToolModifiedState(ctx, net.minecraftforge.common.ToolActions.AXE_STRIP, false); + Optional optional1 = scrape != null ? Optional.of(scrape) : WeatheringCopper.getPrevious(p_311198_); if (optional1.isPresent()) { - p_312809_.playSound(p_312029_, p_313114_, SoundEvents.AXE_SCRAPE, SoundSource.BLOCKS, 1.0F, 1.0F); - p_312809_.levelEvent(p_312029_, 3005, p_313114_, 0); + spawnSoundAndParticle(p_312809_, p_313114_, p_312029_, p_311198_, SoundEvents.AXE_SCRAPE, 3005); return optional1; } else { - Optional optional2 = Optional.ofNullable(HoneycombItem.WAX_OFF_BY_BLOCK.get().get(p_311198_.getBlock())) @@ -37,8 +36,8 @@ + Optional optional2 = waxOff != null ? Optional.of(waxOff) : Optional.ofNullable(HoneycombItem.WAX_OFF_BY_BLOCK.get().get(p_311198_.getBlock())) .map(p_150694_ -> p_150694_.withPropertiesOf(p_311198_)); if (optional2.isPresent()) { - p_312809_.playSound(p_312029_, p_313114_, SoundEvents.AXE_WAX_OFF, SoundSource.BLOCKS, 1.0F, 1.0F); -@@ -115,5 +_,21 @@ + spawnSoundAndParticle(p_312809_, p_313114_, p_312029_, p_311198_, SoundEvents.AXE_WAX_OFF, 3004); +@@ -125,5 +_,21 @@ private Optional getStripped(BlockState p_150691_) { return Optional.ofNullable(STRIPPABLES.get(p_150691_.getBlock())) .map(p_359378_ -> p_359378_.defaultBlockState().setValue(RotatedPillarBlock.AXIS, p_150691_.getValue(RotatedPillarBlock.AXIS))); @@ -56,7 +55,7 @@ + } + + @Override -+ public boolean canDisableShield(ItemStack stack, ItemStack shield, LivingEntity entity, LivingEntity attacker) { ++ public boolean canDisableShield(ItemStack stack, ItemStack shield, net.minecraft.world.entity.LivingEntity entity, net.minecraft.world.entity.LivingEntity attacker) { + return true; } } diff --git a/patches/minecraft/net/minecraft/world/item/BlockItem.java.patch b/patches/minecraft/net/minecraft/world/item/BlockItem.java.patch index a1becfb7f0..8198a23389 100644 --- a/patches/minecraft/net/minecraft/world/item/BlockItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/BlockItem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/BlockItem.java +++ b/net/minecraft/world/item/BlockItem.java -@@ -77,9 +_,9 @@ +@@ -76,9 +_,9 @@ } } @@ -12,7 +12,7 @@ ); level.gameEvent(GameEvent.BLOCK_PLACE, blockpos, GameEvent.Context.of(player, blockstate1)); itemstack.consume(1, player); -@@ -89,10 +_,16 @@ +@@ -88,10 +_,16 @@ } } @@ -29,7 +29,7 @@ @Nullable public BlockPlaceContext updatePlacementContext(BlockPlaceContext p_40609_) { return p_40609_; -@@ -193,6 +_,10 @@ +@@ -186,6 +_,10 @@ public void registerBlocks(Map p_40607_, Item p_40608_) { p_40607_.put(this.getBlock(), p_40608_); diff --git a/patches/minecraft/net/minecraft/world/item/BoneMealItem.java.patch b/patches/minecraft/net/minecraft/world/item/BoneMealItem.java.patch index bbcd50db6d..55eb1af407 100644 --- a/patches/minecraft/net/minecraft/world/item/BoneMealItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/BoneMealItem.java.patch @@ -6,7 +6,7 @@ BlockPos blockpos1 = blockpos.relative(p_40637_.getClickedFace()); - if (growCrop(p_40637_.getItemInHand(), level, blockpos)) { + if (applyBonemeal(p_40637_.getItemInHand(), level, blockpos, p_40637_.getPlayer())) { - if (!level.isClientSide) { + if (!level.isClientSide()) { p_40637_.getPlayer().gameEvent(GameEvent.ITEM_INTERACT_FINISH); level.levelEvent(1505, blockpos, 15); @@ -60,8 +_,18 @@ diff --git a/patches/minecraft/net/minecraft/world/item/BucketItem.java.patch b/patches/minecraft/net/minecraft/world/item/BucketItem.java.patch index 0f89e29902..ab6ce16c5c 100644 --- a/patches/minecraft/net/minecraft/world/item/BucketItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/BucketItem.java.patch @@ -38,7 +38,7 @@ + bucketpickup.getPickupSound(blockstate1).ifPresent(p_150709_ -> p_40704_.playSound(p_150709_, 1.0F, 1.0F)); p_40703_.gameEvent(p_40704_, GameEvent.FLUID_PICKUP, blockpos); ItemStack itemstack2 = ItemUtils.createFilledResult(itemstack, p_40704_, itemstack3); - if (!p_40703_.isClientSide) { + if (!p_40703_.isClientSide()) { @@ -71,8 +_,8 @@ return InteractionResult.FAIL; } else { @@ -64,12 +64,12 @@ if (!(this.content instanceof FlowingFluid flowingfluid)) { return false; } else { -@@ -108,8 +_,12 @@ - || $$8 +@@ -109,8 +_,12 @@ || $$7 instanceof LiquidBlockContainer liquidblockcontainer && liquidblockcontainer.canPlaceLiquid(p_392717_, p_150717_, p_150718_, blockstate, this.content); + boolean flag3 = blockstate.isAir() || flag2 && (!flag1 || p_150719_ == null); + java.util.Optional containedFluidStack = java.util.Optional.ofNullable(container).flatMap(net.minecraftforge.fluids.FluidUtil::getFluidContained); - if (!flag1) { + if (!flag3) { - return p_150719_ != null && this.emptyContents(p_392717_, p_150717_, p_150719_.getBlockPos().relative(p_150719_.getDirection()), null); + return p_150719_ != null && this.emptyContents(p_392717_, p_150717_, p_150719_.getBlockPos().relative(p_150719_.getDirection()), null, container); + } else if (containedFluidStack.isPresent() && this.content.getFluidType().isVaporizedOnPlacement(p_150717_, p_150718_, containedFluidStack.get())) { @@ -78,7 +78,7 @@ } else if (p_150717_.dimensionType().ultraWarm() && this.content.is(FluidTags.WATER)) { int l = p_150718_.getX(); int i = p_150718_.getY(); -@@ -128,7 +_,7 @@ +@@ -129,7 +_,7 @@ } return true; @@ -87,7 +87,7 @@ liquidblockcontainer1.placeLiquid(p_150717_, p_150718_, blockstate, flowingfluid.getSource(false)); this.playEmptySound(p_392717_, p_150717_, p_150718_); return true; -@@ -149,7 +_,32 @@ +@@ -150,8 +_,33 @@ protected void playEmptySound(@Nullable LivingEntity p_393933_, LevelAccessor p_40697_, BlockPos p_40698_) { SoundEvent soundevent = this.content.is(FluidTags.LAVA) ? SoundEvents.BUCKET_EMPTY_LAVA : SoundEvents.BUCKET_EMPTY; @@ -119,4 +119,5 @@ + protected boolean canBlockContainFluid(Level worldIn, BlockPos posIn, BlockState blockstate) { + return blockstate.getBlock() instanceof LiquidBlockContainer liquid && liquid.canPlaceLiquid(null, worldIn, posIn, blockstate, this.content); } - } + + public Fluid getContent() { diff --git a/patches/minecraft/net/minecraft/world/item/FishingRodItem.java.patch b/patches/minecraft/net/minecraft/world/item/FishingRodItem.java.patch index 4d87ab5e0c..6f042c101a 100644 --- a/patches/minecraft/net/minecraft/world/item/FishingRodItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/FishingRodItem.java.patch @@ -1,18 +1,18 @@ --- a/net/minecraft/world/item/FishingRodItem.java +++ b/net/minecraft/world/item/FishingRodItem.java -@@ -25,7 +_,11 @@ +@@ -24,7 +_,11 @@ if (p_41291_.fishing != null) { - if (!p_41290_.isClientSide) { + if (!p_41290_.isClientSide()) { int i = p_41291_.fishing.retrieve(itemstack); + ItemStack original = itemstack.copy(); - itemstack.hurtAndBreak(i, p_41291_, LivingEntity.getSlotForHand(p_41292_)); + itemstack.hurtAndBreak(i, p_41291_, p_41292_.asEquipmentSlot()); + if (itemstack.isEmpty()) { -+ net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(p_41291_, original, LivingEntity.getSlotForHand(p_41292_)); ++ net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(p_41291_, original, p_41292_.asEquipmentSlot()); + } } p_41290_.playSound( -@@ -61,5 +_,10 @@ +@@ -60,5 +_,10 @@ } return InteractionResult.SUCCESS; diff --git a/patches/minecraft/net/minecraft/world/item/HoeItem.java.patch b/patches/minecraft/net/minecraft/world/item/HoeItem.java.patch index 4e76a0ba91..d99cd9c232 100644 --- a/patches/minecraft/net/minecraft/world/item/HoeItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/HoeItem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/HoeItem.java +++ b/net/minecraft/world/item/HoeItem.java -@@ -22,6 +_,12 @@ +@@ -21,6 +_,12 @@ import net.minecraft.world.level.gameevent.GameEvent; public class HoeItem extends Item { @@ -13,7 +13,7 @@ protected static final Map, Consumer>> TILLABLES = Maps.newHashMap( ImmutableMap.of( Blocks.GRASS_BLOCK, -@@ -45,7 +_,8 @@ +@@ -44,7 +_,8 @@ public InteractionResult useOn(UseOnContext p_41341_) { Level level = p_41341_.getLevel(); BlockPos blockpos = p_41341_.getClickedPos(); @@ -23,7 +23,7 @@ if (pair == null) { return InteractionResult.PASS; } else { -@@ -85,5 +_,10 @@ +@@ -84,5 +_,10 @@ public static boolean onlyIfAirAbove(UseOnContext p_150857_) { return p_150857_.getClickedFace() != Direction.DOWN && p_150857_.getLevel().getBlockState(p_150857_.getClickedPos().above()).isAir(); diff --git a/patches/minecraft/net/minecraft/world/item/Item.java.patch b/patches/minecraft/net/minecraft/world/item/Item.java.patch index 49ee643be4..cde8a75dd1 100644 --- a/patches/minecraft/net/minecraft/world/item/Item.java.patch +++ b/patches/minecraft/net/minecraft/world/item/Item.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/Item.java +++ b/net/minecraft/world/item/Item.java -@@ -83,7 +_,7 @@ +@@ -86,7 +_,7 @@ import net.minecraft.world.phys.Vec3; import org.slf4j.Logger; @@ -9,7 +9,7 @@ public static final Codec> CODEC = BuiltInRegistries.ITEM .holderByNameCodec() .validate( -@@ -93,7 +_,7 @@ +@@ -96,7 +_,7 @@ ); public static final StreamCodec> STREAM_CODEC = ByteBufCodecs.holderRegistry(Registries.ITEM); private static final Logger LOGGER = LogUtils.getLogger(); @@ -18,7 +18,7 @@ public static final ResourceLocation BASE_ATTACK_DAMAGE_ID = ResourceLocation.withDefaultNamespace("base_attack_damage"); public static final ResourceLocation BASE_ATTACK_SPEED_ID = ResourceLocation.withDefaultNamespace("base_attack_speed"); public static final int DEFAULT_MAX_STACK_SIZE = 64; -@@ -131,6 +_,7 @@ +@@ -134,6 +_,7 @@ LOGGER.error("Item classes should end with Item and {} doesn't.", s); } } @@ -26,7 +26,7 @@ } @Deprecated -@@ -138,17 +_,25 @@ +@@ -141,17 +_,25 @@ return this.builtInRegistryHolder; } @@ -94,9 +94,9 @@ public static class Properties { private static final DependantName BLOCK_DESCRIPTION_ID = p_367498_ -> Util.makeDescriptionId("block", p_367498_.location()); private static final DependantName ITEM_DESCRIPTION_ID = p_367603_ -> Util.makeDescriptionId("item", p_367603_.location()); -@@ -588,6 +_,11 @@ - @Nullable - MapItemSavedData mapData(MapId p_335695_); +@@ -599,6 +_,11 @@ + + boolean isPeaceful(); + @Nullable + default Level level() { @@ -106,10 +106,10 @@ static Item.TooltipContext of(@Nullable final Level p_332083_) { return p_332083_ == null ? EMPTY : new Item.TooltipContext() { @Override -@@ -603,6 +_,11 @@ +@@ -619,6 +_,11 @@ @Override - public MapItemSavedData mapData(MapId p_330171_) { - return p_332083_.getMapData(p_330171_); + public boolean isPeaceful() { + return p_332083_.getDifficulty() == Difficulty.PEACEFUL; + } + + @Override diff --git a/patches/minecraft/net/minecraft/world/item/ItemDisplayContext.java.patch b/patches/minecraft/net/minecraft/world/item/ItemDisplayContext.java.patch index c536db2c89..9bf3555089 100644 --- a/patches/minecraft/net/minecraft/world/item/ItemDisplayContext.java.patch +++ b/patches/minecraft/net/minecraft/world/item/ItemDisplayContext.java.patch @@ -9,9 +9,9 @@ NONE(0, "none"), THIRD_PERSON_LEFT_HAND(1, "thirdperson_lefthand"), THIRD_PERSON_RIGHT_HAND(2, "thirdperson_righthand"), -@@ -16,14 +_,16 @@ - GROUND(7, "ground"), - FIXED(8, "fixed"); +@@ -17,14 +_,16 @@ + FIXED(8, "fixed"), + ON_SHELF(9, "on_shelf"); - public static final Codec CODEC = StringRepresentable.fromEnum(ItemDisplayContext::values); - public static final IntFunction BY_ID = ByIdMap.continuous(ItemDisplayContext::getId, values(), ByIdMap.OutOfBoundsStrategy.ZERO); @@ -28,7 +28,7 @@ } @Override -@@ -42,4 +_,29 @@ +@@ -43,4 +_,29 @@ public boolean leftHand() { return this == FIRST_PERSON_LEFT_HAND || this == THIRD_PERSON_LEFT_HAND; } diff --git a/patches/minecraft/net/minecraft/world/item/ItemStack.java.patch b/patches/minecraft/net/minecraft/world/item/ItemStack.java.patch index 9fbb271d0a..0904df747b 100644 --- a/patches/minecraft/net/minecraft/world/item/ItemStack.java.patch +++ b/patches/minecraft/net/minecraft/world/item/ItemStack.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/ItemStack.java +++ b/net/minecraft/world/item/ItemStack.java -@@ -96,7 +_,7 @@ +@@ -98,7 +_,7 @@ import org.apache.commons.lang3.mutable.MutableBoolean; import org.slf4j.Logger; @@ -9,7 +9,7 @@ private static final List OP_NBT_WARNING = List.of( Component.translatable("item.op_warning.line1").withStyle(ChatFormatting.RED, ChatFormatting.BOLD), Component.translatable("item.op_warning.line2").withStyle(ChatFormatting.RED), -@@ -266,13 +_,16 @@ +@@ -268,12 +_,15 @@ } private ItemStack(ItemLike p_331826_, int p_332766_, PatchedDataComponentMap p_333722_) { @@ -17,7 +17,6 @@ this.item = p_331826_.asItem(); this.count = p_332766_; this.components = p_333722_; - this.getItem().verifyComponentsAfterLoad(this); + gatherCapabilities(() -> this.item.getCapabilityProvider(this)); } @@ -26,11 +25,11 @@ this.item = null; this.components = new PatchedDataComponentMap(DataComponentMap.EMPTY); } -@@ -353,13 +_,22 @@ +@@ -354,13 +_,22 @@ } public InteractionResult useOn(UseOnContext p_41662_) { -+ if (!p_41662_.getLevel().isClientSide) return net.minecraftforge.common.ForgeHooks.onPlaceItemIntoWorld(p_41662_); ++ if (!p_41662_.getLevel().isClientSide()) return net.minecraftforge.common.ForgeHooks.onPlaceItemIntoWorld(p_41662_); + return onItemUse(p_41662_, (c) -> getItem().useOn(p_41662_)); + } + @@ -50,7 +49,7 @@ if (player != null && interactionresult instanceof InteractionResult.Success interactionresult$success && interactionresult$success.wasItemInteraction()) { player.awardStat(Stats.ITEM_USED.get(item)); } -@@ -444,18 +_,26 @@ +@@ -445,18 +_,26 @@ } public void hurtAndBreak(int p_220158_, ServerLevel p_342197_, @Nullable ServerPlayer p_220160_, Consumer p_343361_) { @@ -78,7 +77,7 @@ return p_362423_ > 0 ? EnchantmentHelper.processDurabilityChange(p_364910_, this, p_362423_) : p_362423_; } } -@@ -495,7 +_,13 @@ +@@ -496,7 +_,13 @@ p_41623_, serverlevel, p_41624_ instanceof ServerPlayer serverplayer ? serverplayer : null, @@ -93,7 +92,7 @@ ); } } -@@ -818,6 +_,7 @@ +@@ -820,6 +_,7 @@ List list = Lists.newArrayList(); list.add(this.getStyledHoverName()); this.addDetailsToTooltip(p_331329_, tooltipdisplay, p_41652_, p_41653_, list::add); @@ -101,7 +100,7 @@ return list; } } -@@ -1061,6 +_,7 @@ +@@ -1065,6 +_,7 @@ this.getItem().onUseTick(p_41732_, p_41733_, this, p_41734_); } diff --git a/patches/minecraft/net/minecraft/world/item/Items.java.patch b/patches/minecraft/net/minecraft/world/item/Items.java.patch index 44afb6a568..15d6930f5d 100644 --- a/patches/minecraft/net/minecraft/world/item/Items.java.patch +++ b/patches/minecraft/net/minecraft/world/item/Items.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/Items.java +++ b/net/minecraft/world/item/Items.java -@@ -2155,7 +_,25 @@ +@@ -2281,7 +_,25 @@ } public static Item registerBlock(Block p_252092_, Block... p_248886_) { @@ -27,7 +27,7 @@ for (Block block : p_248886_) { Item.BY_BLOCK.put(block, item); -@@ -2194,10 +_,6 @@ +@@ -2320,10 +_,6 @@ public static Item registerItem(ResourceKey p_364577_, Function p_366144_, Item.Properties p_369845_) { Item item = p_366144_.apply(p_369845_.setId(p_364577_)); diff --git a/patches/minecraft/net/minecraft/world/item/ShearsItem.java.patch b/patches/minecraft/net/minecraft/world/item/ShearsItem.java.patch index 66709dce0b..2705968866 100644 --- a/patches/minecraft/net/minecraft/world/item/ShearsItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/ShearsItem.java.patch @@ -8,7 +8,7 @@ + @Override + public InteractionResult interactLivingEntity(ItemStack stack, Player playerIn, LivingEntity entity, net.minecraft.world.InteractionHand hand) { + if (entity instanceof net.minecraftforge.common.IForgeShearable target) { -+ if (entity.level().isClientSide) { ++ if (entity.level().isClientSide()) { + return InteractionResult.SUCCESS; + } + var serverLevel = (net.minecraft.server.level.ServerLevel)entity.level(); @@ -23,7 +23,7 @@ + ent.setDeltaMovement(ent.getDeltaMovement().add((double)((rand.nextFloat() - rand.nextFloat()) * 0.1F), (double)(rand.nextFloat() * 0.05F), (double)((rand.nextFloat() - rand.nextFloat()) * 0.1F))); + } + if (!drops.isEmpty()) -+ stack.hurtAndBreak(1, playerIn, LivingEntity.getSlotForHand(hand)); ++ stack.hurtAndBreak(1, playerIn, hand.asEquipmentSlot()); + } + return InteractionResult.SUCCESS; + } diff --git a/patches/minecraft/net/minecraft/world/item/ShovelItem.java.patch b/patches/minecraft/net/minecraft/world/item/ShovelItem.java.patch index 232d485abd..c4ceaa3010 100644 --- a/patches/minecraft/net/minecraft/world/item/ShovelItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/ShovelItem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/ShovelItem.java +++ b/net/minecraft/world/item/ShovelItem.java -@@ -43,9 +_,9 @@ +@@ -42,9 +_,9 @@ return InteractionResult.PASS; } else { Player player = p_43119_.getPlayer(); @@ -12,7 +12,7 @@ level.playSound(player, blockpos, SoundEvents.SHOVEL_FLATTEN, SoundSource.BLOCKS, 1.0F, 1.0F); blockstate2 = blockstate1; } else if (blockstate.getBlock() instanceof CampfireBlock && blockstate.getValue(CampfireBlock.LIT)) { -@@ -71,5 +_,15 @@ +@@ -70,5 +_,15 @@ return InteractionResult.PASS; } } diff --git a/patches/minecraft/net/minecraft/world/item/SpawnEggItem.java.patch b/patches/minecraft/net/minecraft/world/item/SpawnEggItem.java.patch deleted file mode 100644 index e4b78cdd22..0000000000 --- a/patches/minecraft/net/minecraft/world/item/SpawnEggItem.java.patch +++ /dev/null @@ -1,13 +0,0 @@ ---- a/net/minecraft/world/item/SpawnEggItem.java -+++ b/net/minecraft/world/item/SpawnEggItem.java -@@ -143,6 +_,10 @@ - return this.defaultType; - } - -+ public EntityType getDefaultType() { -+ return this.defaultType; -+ } -+ - @Override - public FeatureFlagSet requiredFeatures() { - return this.defaultType.requiredFeatures(); diff --git a/patches/minecraft/net/minecraft/world/level/BaseSpawner.java.patch b/patches/minecraft/net/minecraft/world/level/BaseSpawner.java.patch index a422a833ff..d71e8ca49a 100644 --- a/patches/minecraft/net/minecraft/world/level/BaseSpawner.java.patch +++ b/patches/minecraft/net/minecraft/world/level/BaseSpawner.java.patch @@ -21,7 +21,7 @@ spawndata.getEquipment().ifPresent(mob::equip); @@ -280,5 +_,15 @@ - public double getoSpin() { + public double getOSpin() { return this.oSpin; + } + diff --git a/patches/minecraft/net/minecraft/world/level/BlockGetter.java.patch b/patches/minecraft/net/minecraft/world/level/BlockGetter.java.patch index bf152c3be5..8512f298c2 100644 --- a/patches/minecraft/net/minecraft/world/level/BlockGetter.java.patch +++ b/patches/minecraft/net/minecraft/world/level/BlockGetter.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/level/BlockGetter.java +++ b/net/minecraft/world/level/BlockGetter.java -@@ -20,7 +_,7 @@ +@@ -21,7 +_,7 @@ import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.shapes.VoxelShape; -public interface BlockGetter extends LevelHeightAccessor { +public interface BlockGetter extends LevelHeightAccessor, net.minecraftforge.common.extensions.IForgeBlockGetter { - int MAX_BLOCK_ITERATIONS_ALONG_TRAVEL = 16; - @Nullable -@@ -36,7 +_,7 @@ + BlockEntity getBlockEntity(BlockPos p_45570_); + +@@ -35,7 +_,7 @@ FluidState getFluidState(BlockPos p_45569_); default int getLightEmission(BlockPos p_45572_) { diff --git a/patches/minecraft/net/minecraft/world/level/Level.java.patch b/patches/minecraft/net/minecraft/world/level/Level.java.patch index df7f8edc07..c69b1b064c 100644 --- a/patches/minecraft/net/minecraft/world/level/Level.java.patch +++ b/patches/minecraft/net/minecraft/world/level/Level.java.patch @@ -1,17 +1,17 @@ --- a/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java -@@ -83,7 +_,7 @@ - import net.minecraft.world.phys.Vec3; +@@ -84,7 +_,7 @@ import net.minecraft.world.scores.Scoreboard; + import org.apache.commons.lang3.mutable.MutableBoolean; --public abstract class Level implements LevelAccessor, UUIDLookup, AutoCloseable { -+public abstract class Level extends net.minecraftforge.common.capabilities.CapabilityProvider.Levels implements LevelAccessor, UUIDLookup, AutoCloseable, net.minecraftforge.common.extensions.IForgeLevel { +-public abstract class Level implements LevelAccessor, AutoCloseable { ++public abstract class Level extends net.minecraftforge.common.capabilities.CapabilityProvider.Levels implements LevelAccessor, AutoCloseable, net.minecraftforge.common.extensions.IForgeLevel { public static final Codec> RESOURCE_KEY_CODEC = ResourceKey.codec(Registries.DIMENSION); public static final ResourceKey OVERWORLD = ResourceKey.create(Registries.DIMENSION, ResourceLocation.withDefaultNamespace("overworld")); public static final ResourceKey NETHER = ResourceKey.create(Registries.DIMENSION, ResourceLocation.withDefaultNamespace("the_nether")); -@@ -120,6 +_,11 @@ - private final RegistryAccess registryAccess; +@@ -125,6 +_,11 @@ private final DamageSources damageSources; + private final PalettedContainerFactory palettedContainerFactory; private long subTickCount; + public boolean restoringBlockSnapshots = false; + public boolean captureBlockSnapshots = false; @@ -21,15 +21,15 @@ protected Level( WritableLevelData p_270739_, -@@ -131,6 +_,7 @@ +@@ -136,6 +_,7 @@ long p_270248_, int p_270466_ ) { + super(); this.levelData = p_270739_; this.dimensionTypeRegistration = p_270240_; - final DimensionType dimensiontype = p_270240_.value(); -@@ -220,11 +_,35 @@ + DimensionType dimensiontype = p_270240_.value(); +@@ -210,11 +_,35 @@ } else { LevelChunk levelchunk = this.getChunkAt(p_46605_); Block block = p_46606_.getBlock(); @@ -65,7 +65,7 @@ if (blockstate1 == p_46606_) { if (blockstate != blockstate1) { this.setBlocksDirty(p_46605_, blockstate, blockstate1); -@@ -251,9 +_,8 @@ +@@ -241,9 +_,8 @@ } this.updatePOIOnBlockStateChange(p_46605_, blockstate, blockstate1); @@ -76,7 +76,7 @@ } } } -@@ -501,10 +_,30 @@ +@@ -491,8 +_,28 @@ (this.tickingBlockEntities ? this.pendingBlockEntityTickers : this.blockEntityTickers).add(p_151526_); } @@ -88,9 +88,7 @@ + } + } + - protected void tickBlockEntities() { - ProfilerFiller profilerfiller = Profiler.get(); - profilerfiller.push("blockEntities"); + public void tickBlockEntities() { + + if (!this.pendingFreshBlockEntities.isEmpty()) { + this.freshBlockEntities.addAll(this.pendingFreshBlockEntities); @@ -107,7 +105,7 @@ if (!this.pendingBlockEntityTickers.isEmpty()) { this.blockEntityTickers.addAll(this.pendingBlockEntityTickers); this.pendingBlockEntityTickers.clear(); -@@ -528,12 +_,19 @@ +@@ -515,12 +_,19 @@ public void guardEntityTick(Consumer p_46654_, T p_46655_) { try { @@ -127,7 +125,7 @@ } } -@@ -685,6 +_,7 @@ +@@ -677,6 +_,7 @@ if (!this.isOutsideBuildHeight(p_46748_)) { this.getChunkAt(p_46748_).removeBlockEntity(p_46748_); } @@ -135,7 +133,7 @@ } public boolean isLoaded(BlockPos p_46750_) { -@@ -762,9 +_,9 @@ +@@ -755,9 +_,9 @@ } }); @@ -147,7 +145,7 @@ && p_46538_.test(enderdragonpart) && p_46537_.intersects(enderdragonpart.getBoundingBox())) { list.add(enderdragonpart); -@@ -797,8 +_,8 @@ +@@ -790,8 +_,8 @@ } } @@ -158,7 +156,7 @@ T t = p_261885_.tryCast(enderdragonpart); if (t != null && p_261688_.test(t)) { p_262071_.add(t); -@@ -946,17 +_,16 @@ +@@ -973,17 +_,16 @@ public abstract Scoreboard getScoreboard(); public void updateNeighbourForOutputSignal(BlockPos p_46718_, Block p_46719_) { @@ -181,7 +179,7 @@ } } } -@@ -1058,6 +_,20 @@ +@@ -1080,6 +_,20 @@ } public abstract PotionBrewing potionBrewing(); diff --git a/patches/minecraft/net/minecraft/world/level/NaturalSpawner.java.patch b/patches/minecraft/net/minecraft/world/level/NaturalSpawner.java.patch index 30737568ff..a49177ff03 100644 --- a/patches/minecraft/net/minecraft/world/level/NaturalSpawner.java.patch +++ b/patches/minecraft/net/minecraft/world/level/NaturalSpawner.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/NaturalSpawner.java +++ b/net/minecraft/world/level/NaturalSpawner.java -@@ -69,7 +_,7 @@ +@@ -71,7 +_,7 @@ for (Entity entity : p_186526_) { if (!(entity instanceof Mob mob && (mob.isPersistenceRequired() || mob.requiresCustomPersistence()))) { @@ -9,7 +9,7 @@ if (mobcategory != MobCategory.MISC) { BlockPos blockpos = entity.blockPosition(); p_186527_.query(ChunkPos.asLong(blockpos), p_275163_ -> { -@@ -200,7 +_,7 @@ +@@ -202,7 +_,7 @@ l1++; p_47040_.addFreshEntityWithPassengers(mob); p_47044_.run(mob, p_47041_); @@ -18,7 +18,7 @@ return; } -@@ -270,7 +_,7 @@ +@@ -276,7 +_,7 @@ private static boolean isValidPositionForMob(ServerLevel p_46992_, Mob p_46993_, double p_46994_) { return p_46994_ > p_46993_.getType().getCategory().getDespawnDistance() * p_46993_.getType().getCategory().getDespawnDistance() && p_46993_.removeWhenFarAway(p_46994_) ? false @@ -27,7 +27,7 @@ } private static Optional getRandomSpawnMobAt( -@@ -301,9 +_,13 @@ +@@ -307,9 +_,13 @@ BlockPos p_220448_, @Nullable Holder p_220449_ ) { @@ -44,7 +44,7 @@ } public static boolean isInNetherFortressBounds(BlockPos p_220456_, ServerLevel p_220457_, MobCategory p_220458_, StructureManager p_220459_) { -@@ -389,7 +_,7 @@ +@@ -395,7 +_,7 @@ } entity.snapTo(d0, blockpos.getY(), d1, p_220454_.nextFloat() * 360.0F, 0.0F); @@ -53,7 +53,7 @@ spawngroupdata = mob.finalizeSpawn( p_220451_, p_220451_.getCurrentDifficultyAt(mob.blockPosition()), EntitySpawnReason.CHUNK_GENERATION, spawngroupdata ); -@@ -495,7 +_,7 @@ +@@ -501,7 +_,7 @@ } this.spawnPotential.addCharge(blockpos, d0); diff --git a/patches/minecraft/net/minecraft/world/level/ServerExplosion.java.patch b/patches/minecraft/net/minecraft/world/level/ServerExplosion.java.patch index 43d5e07c0e..ef0d414830 100644 --- a/patches/minecraft/net/minecraft/world/level/ServerExplosion.java.patch +++ b/patches/minecraft/net/minecraft/world/level/ServerExplosion.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/ServerExplosion.java +++ b/net/minecraft/world/level/ServerExplosion.java -@@ -167,7 +_,7 @@ +@@ -169,7 +_,7 @@ return new ObjectArrayList<>(set); } @@ -9,7 +9,7 @@ float f = this.radius * 2.0F; int i = Mth.floor(this.center.x - f - 1.0); int j = Mth.floor(this.center.x + f + 1.0); -@@ -176,7 +_,9 @@ +@@ -178,7 +_,9 @@ int i1 = Mth.floor(this.center.z - f - 1.0); int j1 = Mth.floor(this.center.z + f + 1.0); @@ -19,9 +19,9 @@ + for (Entity entity : entities) { if (!entity.ignoreExplosion(this)) { double d0 = Math.sqrt(entity.distanceToSqr(this.center)) / f; - if (d0 <= 1.0) { -@@ -245,7 +_,7 @@ - public void explode() { + if (!(d0 > 1.0)) { +@@ -233,7 +_,7 @@ + public int explode() { this.level.gameEvent(this.source, GameEvent.EXPLODE, this.center); List list = this.calculateExplodedPositions(); - this.hurtEntities(); diff --git a/patches/minecraft/net/minecraft/world/level/block/BaseFireBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/BaseFireBlock.java.patch index c521d8071a..045538f3cf 100644 --- a/patches/minecraft/net/minecraft/world/level/block/BaseFireBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/BaseFireBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BaseFireBlock.java +++ b/net/minecraft/world/level/block/BaseFireBlock.java -@@ -153,6 +_,7 @@ +@@ -154,6 +_,7 @@ if (!p_49282_.is(p_49279_.getBlock())) { if (inPortalDimension(p_49280_)) { Optional optional = PortalShape.findEmptyPortalShape(p_49280_, p_49281_, Direction.Axis.X); @@ -8,7 +8,7 @@ if (optional.isPresent()) { optional.get().createPortalBlocks(p_49280_); return; -@@ -195,7 +_,7 @@ +@@ -196,7 +_,7 @@ boolean flag = false; for (Direction direction : Direction.values()) { diff --git a/patches/minecraft/net/minecraft/world/level/block/BaseRailBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/BaseRailBlock.java.patch index 10cd0a7d5d..c28edbc526 100644 --- a/patches/minecraft/net/minecraft/world/level/block/BaseRailBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/BaseRailBlock.java.patch @@ -12,7 +12,7 @@ @@ -79,7 +_,7 @@ @Override protected void neighborChanged(BlockState p_49377_, Level p_49378_, BlockPos p_49379_, Block p_49380_, @Nullable Orientation p_362860_, boolean p_49382_) { - if (!p_49378_.isClientSide && p_49378_.getBlockState(p_49379_).is(this)) { + if (!p_49378_.isClientSide() && p_49378_.getBlockState(p_49379_).is(this)) { - RailShape railshape = p_49377_.getValue(this.getShapeProperty()); + RailShape railshape = getRailDirection(p_49377_, p_49378_, p_49379_, null); if (shouldBeRemoved(p_49379_, p_49378_, railshape)) { diff --git a/patches/minecraft/net/minecraft/world/level/block/BeehiveBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/BeehiveBlock.java.patch index d82c7097d1..f8c40511f1 100644 --- a/patches/minecraft/net/minecraft/world/level/block/BeehiveBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/BeehiveBlock.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/level/block/BeehiveBlock.java +++ b/net/minecraft/world/level/block/BeehiveBlock.java -@@ -137,7 +_,7 @@ +@@ -146,7 +_,7 @@ boolean flag = false; if (i >= 5) { Item item = p_331014_.getItem(); -- if (p_331014_.is(Items.SHEARS)) { -+ if (p_331014_.canPerformAction(net.minecraftforge.common.ToolActions.SHEARS_HARVEST)) { - p_329187_.playSound( - p_336201_, p_336201_.getX(), p_336201_.getY(), p_336201_.getZ(), SoundEvents.BEEHIVE_SHEAR, SoundSource.BLOCKS, 1.0F, 1.0F - ); +- if (p_329187_ instanceof ServerLevel serverlevel && p_331014_.is(Items.SHEARS)) { ++ if (p_329187_ instanceof ServerLevel serverlevel && p_331014_.canPerformAction(net.minecraftforge.common.ToolActions.SHEARS_HARVEST)) { + dropHoneycomb(serverlevel, p_331014_, p_328141_, p_329187_.getBlockEntity(p_335985_), p_336201_, p_335985_); + p_329187_.playSound(null, p_336201_.getX(), p_336201_.getY(), p_336201_.getZ(), SoundEvents.BEEHIVE_SHEAR, SoundSource.BLOCKS, 1.0F, 1.0F); + p_331014_.hurtAndBreak(1, p_336201_, p_333071_.asEquipmentSlot()); diff --git a/patches/minecraft/net/minecraft/world/level/block/Block.java.patch b/patches/minecraft/net/minecraft/world/level/block/Block.java.patch index 6828dd5d76..3c5bd7b834 100644 --- a/patches/minecraft/net/minecraft/world/level/block/Block.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/Block.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/Block.java +++ b/net/minecraft/world/level/block/Block.java -@@ -66,11 +_,12 @@ +@@ -70,11 +_,12 @@ import net.minecraft.world.phys.shapes.VoxelShape; import org.slf4j.Logger; @@ -15,7 +15,7 @@ private static final LoadingCache SHAPE_FULL_BLOCK_CACHE = CacheBuilder.newBuilder() .maximumSize(512L) .weakKeys() -@@ -232,6 +_,7 @@ +@@ -236,6 +_,7 @@ LOGGER.error("Block classes should end with Block and {} doesn't.", s); } } @@ -23,8 +23,8 @@ } public static boolean isExceptionForConnection(BlockState p_152464_) { -@@ -244,12 +_,19 @@ - || p_152464_.is(BlockTags.SHULKER_BOXES); +@@ -286,12 +_,19 @@ + } } + @Deprecated // FORGE: use shouldRenderFace with level and block pos instead @@ -43,7 +43,7 @@ } else if (voxelshape == Shapes.empty()) { return true; } else { -@@ -337,9 +_,13 @@ +@@ -379,9 +_,13 @@ public static void dropResources( BlockState p_49882_, Level p_49883_, BlockPos p_49884_, @Nullable BlockEntity p_49885_, @Nullable Entity p_49886_, ItemStack p_49887_ ) { @@ -58,7 +58,7 @@ } } -@@ -367,7 +_,7 @@ +@@ -409,7 +_,7 @@ } private static void popResource(Level p_152441_, Supplier p_152442_, ItemStack p_152443_) { @@ -67,7 +67,7 @@ ItemEntity itementity = p_152442_.get(); itementity.setDefaultPickUpDelay(); p_152441_.addFreshEntity(itementity); -@@ -375,11 +_,12 @@ +@@ -417,11 +_,12 @@ } public void popExperience(ServerLevel p_49806_, BlockPos p_49807_, int p_49808_) { @@ -81,7 +81,7 @@ public float getExplosionResistance() { return this.explosionResistance; } -@@ -398,7 +_,8 @@ +@@ -440,7 +_,8 @@ public void playerDestroy(Level p_49827_, Player p_49828_, BlockPos p_49829_, BlockState p_49830_, @Nullable BlockEntity p_49831_, ItemStack p_49832_) { p_49828_.awardStat(Stats.BLOCK_MINED.get(this)); p_49828_.causeFoodExhaustion(0.005F); @@ -91,7 +91,7 @@ } public void setPlacedBy(Level p_49847_, BlockPos p_49848_, BlockState p_49849_, @Nullable LivingEntity p_49850_, ItemStack p_49851_) { -@@ -420,6 +_,7 @@ +@@ -462,6 +_,7 @@ p_49822_.setDeltaMovement(p_49822_.getDeltaMovement().multiply(1.0, 0.0, 1.0)); } @@ -99,7 +99,7 @@ public float getFriction() { return this.friction; } -@@ -490,7 +_,7 @@ +@@ -532,7 +_,7 @@ this.item = Item.byBlock(this); } @@ -108,7 +108,7 @@ } public boolean hasDynamicShape() { -@@ -556,5 +_,78 @@ +@@ -598,5 +_,78 @@ public int hashCode() { return System.identityHashCode(this.first) * 31 + System.identityHashCode(this.second); } diff --git a/patches/minecraft/net/minecraft/world/level/block/Blocks.java.patch b/patches/minecraft/net/minecraft/world/level/block/Blocks.java.patch index 69cbf9b5ed..1bd8be3da9 100644 --- a/patches/minecraft/net/minecraft/world/level/block/Blocks.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/Blocks.java.patch @@ -4,12 +4,12 @@ public static final Block RED_BED = registerBed("red_bed", DyeColor.RED); public static final Block BLACK_BED = registerBed("black_bed", DyeColor.BLACK); public static final Block POWERED_RAIL = register( -- "powered_rail", PoweredRailBlock::new, BlockBehaviour.Properties.of().noCollission().strength(0.7F).sound(SoundType.METAL) -+ "powered_rail", prop -> new PoweredRailBlock(prop, true), BlockBehaviour.Properties.of().noCollission().strength(0.7F).sound(SoundType.METAL) +- "powered_rail", PoweredRailBlock::new, BlockBehaviour.Properties.of().noCollision().strength(0.7F).sound(SoundType.METAL) ++ "powered_rail", prop -> new PoweredRailBlock(prop, true), BlockBehaviour.Properties.of().noCollision().strength(0.7F).sound(SoundType.METAL) ); public static final Block DETECTOR_RAIL = register( - "detector_rail", DetectorRailBlock::new, BlockBehaviour.Properties.of().noCollission().strength(0.7F).sound(SoundType.METAL) -@@ -6685,14 +_,5 @@ + "detector_rail", DetectorRailBlock::new, BlockBehaviour.Properties.of().noCollision().strength(0.7F).sound(SoundType.METAL) +@@ -6947,14 +_,5 @@ private static Block register(String p_50796_, BlockBehaviour.Properties p_362760_) { return register(p_50796_, Block::new, p_362760_); diff --git a/patches/minecraft/net/minecraft/world/level/block/ChestBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/ChestBlock.java.patch index 864c64fcfb..4c41995ee0 100644 --- a/patches/minecraft/net/minecraft/world/level/block/ChestBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/ChestBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/ChestBlock.java +++ b/net/minecraft/world/level/block/ChestBlock.java -@@ -340,7 +_,8 @@ +@@ -370,7 +_,8 @@ @Override protected BlockState mirror(BlockState p_51549_, Mirror p_51550_) { diff --git a/patches/minecraft/net/minecraft/world/level/block/EnchantingTableBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/EnchantingTableBlock.java.patch index 92207f6d2a..7dfb7f2916 100644 --- a/patches/minecraft/net/minecraft/world/level/block/EnchantingTableBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/EnchantingTableBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/EnchantingTableBlock.java +++ b/net/minecraft/world/level/block/EnchantingTableBlock.java -@@ -47,7 +_,7 @@ +@@ -46,7 +_,7 @@ } public static boolean isValidBookShelf(Level p_328191_, BlockPos p_328702_, BlockPos p_336071_) { diff --git a/patches/minecraft/net/minecraft/world/level/block/LiquidBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/LiquidBlock.java.patch index 0a778957e0..a5fe8e1b69 100644 --- a/patches/minecraft/net/minecraft/world/level/block/LiquidBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/LiquidBlock.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/level/block/LiquidBlock.java +++ b/net/minecraft/world/level/block/LiquidBlock.java @@ -53,7 +_,8 @@ - p_360438_ -> p_360438_.group(FLOWING_FLUID.fieldOf("fluid").forGetter(p_312827_ -> p_312827_.fluid), propertiesCodec()).apply(p_360438_, LiquidBlock::new) + p_422116_ -> p_422116_.group(FLOWING_FLUID.fieldOf("fluid").forGetter(p_312827_ -> p_312827_.fluid), propertiesCodec()).apply(p_422116_, LiquidBlock::new) ); public static final IntegerProperty LEVEL = BlockStateProperties.LEVEL; - protected final FlowingFluid fluid; @@ -38,7 +38,7 @@ } @Override -@@ -109,6 +_,7 @@ +@@ -113,6 +_,7 @@ @Override protected FluidState getFluidState(BlockState p_54765_) { int i = p_54765_.getValue(LEVEL); @@ -46,7 +46,7 @@ return this.stateCache.get(Math.min(i, 8)); } -@@ -134,7 +_,7 @@ +@@ -138,7 +_,7 @@ @Override protected void onPlace(BlockState p_54754_, Level p_54755_, BlockPos p_54756_, BlockState p_54757_, boolean p_54758_) { @@ -55,7 +55,7 @@ p_54755_.scheduleTick(p_54756_, p_54754_.getFluidState().getType(), this.fluid.getTickDelay(p_54755_)); } } -@@ -159,11 +_,12 @@ +@@ -163,11 +_,12 @@ @Override protected void neighborChanged(BlockState p_54709_, Level p_54710_, BlockPos p_54711_, Block p_54712_, @Nullable Orientation p_368724_, boolean p_54714_) { @@ -69,7 +69,7 @@ private boolean shouldSpreadLiquid(Level p_54697_, BlockPos p_54698_, BlockState p_54699_) { if (this.fluid.is(FluidTags.LAVA)) { boolean flag = p_54697_.getBlockState(p_54698_.below()).is(Blocks.SOUL_SOIL); -@@ -210,5 +_,24 @@ +@@ -214,5 +_,24 @@ @Override public Optional getPickupSound() { return this.fluid.getPickupSound(); diff --git a/patches/minecraft/net/minecraft/world/level/block/NoteBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/NoteBlock.java.patch index e1513147aa..83c9a6f116 100644 --- a/patches/minecraft/net/minecraft/world/level/block/NoteBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/NoteBlock.java.patch @@ -3,7 +3,7 @@ @@ -115,7 +_,9 @@ @Override protected InteractionResult useWithoutItem(BlockState p_331116_, Level p_332131_, BlockPos p_333586_, Player p_329332_, BlockHitResult p_331978_) { - if (!p_332131_.isClientSide) { + if (!p_332131_.isClientSide()) { - p_331116_ = p_331116_.cycle(NOTE); + int _new = net.minecraftforge.common.ForgeHooks.onNoteChange(p_332131_, p_333586_, p_331116_, p_331116_.getValue(NOTE), p_331116_.cycle(NOTE).getValue(NOTE)); + if (_new == -1) return InteractionResult.FAIL; diff --git a/patches/minecraft/net/minecraft/world/level/block/PumpkinBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/PumpkinBlock.java.patch index 04e3829c08..a0cff8e709 100644 --- a/patches/minecraft/net/minecraft/world/level/block/PumpkinBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/PumpkinBlock.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/level/block/PumpkinBlock.java +++ b/net/minecraft/world/level/block/PumpkinBlock.java -@@ -35,7 +_,7 @@ +@@ -36,7 +_,7 @@ protected InteractionResult useItemOn( ItemStack p_330568_, BlockState p_330263_, Level p_327756_, BlockPos p_328675_, Player p_334049_, InteractionHand p_331851_, BlockHitResult p_329008_ ) { - if (!p_330568_.is(Items.SHEARS)) { + if (p_330568_.canPerformAction(net.minecraftforge.common.ToolActions.SHEARS_CARVE)) { return super.useItemOn(p_330568_, p_330263_, p_327756_, p_328675_, p_334049_, p_331851_, p_329008_); - } else if (p_327756_.isClientSide) { - return InteractionResult.SUCCESS; + } else if (p_327756_ instanceof ServerLevel serverlevel) { + Direction direction = p_329008_.getDirection(); diff --git a/patches/minecraft/net/minecraft/world/level/block/SoundType.java.patch b/patches/minecraft/net/minecraft/world/level/block/SoundType.java.patch index 55528d8a6b..402e3f848c 100644 --- a/patches/minecraft/net/minecraft/world/level/block/SoundType.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/SoundType.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/SoundType.java +++ b/net/minecraft/world/level/block/SoundType.java -@@ -375,6 +_,7 @@ +@@ -381,6 +_,7 @@ private final SoundEvent hitSound; private final SoundEvent fallSound; diff --git a/patches/minecraft/net/minecraft/world/level/block/SweetBerryBushBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/SweetBerryBushBlock.java.patch index a0fe047e75..7a53fe205a 100644 --- a/patches/minecraft/net/minecraft/world/level/block/SweetBerryBushBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/SweetBerryBushBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/SweetBerryBushBlock.java +++ b/net/minecraft/world/level/block/SweetBerryBushBlock.java -@@ -70,10 +_,11 @@ +@@ -71,10 +_,11 @@ @Override protected void randomTick(BlockState p_222563_, ServerLevel p_222564_, BlockPos p_222565_, RandomSource p_222566_) { int i = p_222563_.getValue(AGE); diff --git a/patches/minecraft/net/minecraft/world/level/block/TripWireBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/TripWireBlock.java.patch index 299b61bfb7..2c92f09ff9 100644 --- a/patches/minecraft/net/minecraft/world/level/block/TripWireBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/TripWireBlock.java.patch @@ -4,8 +4,8 @@ @Override public BlockState playerWillDestroy(Level p_57615_, BlockPos p_57616_, BlockState p_57617_, Player p_57618_) { -- if (!p_57615_.isClientSide && !p_57618_.getMainHandItem().isEmpty() && p_57618_.getMainHandItem().is(Items.SHEARS)) { -+ if (!p_57615_.isClientSide && !p_57618_.getMainHandItem().isEmpty() && p_57618_.getMainHandItem().canPerformAction(net.minecraftforge.common.ToolActions.SHEARS_DISARM)) { +- if (!p_57615_.isClientSide() && !p_57618_.getMainHandItem().isEmpty() && p_57618_.getMainHandItem().is(Items.SHEARS)) { ++ if (!p_57615_.isClientSide() && !p_57618_.getMainHandItem().isEmpty() && p_57618_.getMainHandItem().canPerformAction(net.minecraftforge.common.ToolActions.SHEARS_DISARM)) { p_57615_.setBlock(p_57616_, p_57617_.setValue(DISARMED, true), 260); p_57615_.gameEvent(p_57618_, GameEvent.SHEAR, p_57616_); } diff --git a/patches/minecraft/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java.patch b/patches/minecraft/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java.patch index 376a42c06c..d624e1605a 100644 --- a/patches/minecraft/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java +++ b/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java -@@ -164,4 +_,27 @@ +@@ -168,4 +_,27 @@ p_407613_.discard("lock"); p_407613_.discard("Items"); } diff --git a/patches/minecraft/net/minecraft/world/level/block/entity/BlockEntity.java.patch b/patches/minecraft/net/minecraft/world/level/block/entity/BlockEntity.java.patch index 9e629a5670..8038ce1580 100644 --- a/patches/minecraft/net/minecraft/world/level/block/entity/BlockEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/entity/BlockEntity.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/level/block/entity/BlockEntity.java +++ b/net/minecraft/world/level/block/entity/BlockEntity.java -@@ -34,7 +_,7 @@ +@@ -36,7 +_,7 @@ import net.minecraft.world.level.storage.ValueOutput; import org.slf4j.Logger; --public abstract class BlockEntity { -+public abstract class BlockEntity extends net.minecraftforge.common.capabilities.CapabilityProvider.BlockEntities implements net.minecraftforge.common.extensions.IForgeBlockEntity { +-public abstract class BlockEntity implements DebugValueSource { ++public abstract class BlockEntity extends net.minecraftforge.common.capabilities.CapabilityProvider.BlockEntities implements DebugValueSource, net.minecraftforge.common.extensions.IForgeBlockEntity { private static final Codec> TYPE_CODEC = BuiltInRegistries.BLOCK_ENTITY_TYPE.byNameCodec(); private static final Logger LOGGER = LogUtils.getLogger(); private final BlockEntityType type; -@@ -46,10 +_,12 @@ +@@ -48,10 +_,12 @@ private DataComponentMap components = DataComponentMap.EMPTY; public BlockEntity(BlockEntityType p_155228_, BlockPos p_155229_, BlockState p_155230_) { @@ -22,7 +22,7 @@ } private void validateBlockState(BlockState p_345558_) { -@@ -59,7 +_,7 @@ +@@ -61,7 +_,7 @@ } public boolean isValidBlockState(BlockState p_345570_) { @@ -31,7 +31,7 @@ } public static BlockPos getPosFromTag(ChunkPos p_396083_, CompoundTag p_187473_) { -@@ -91,6 +_,7 @@ +@@ -93,6 +_,7 @@ } protected void loadAdditional(ValueInput p_409136_) { @@ -39,7 +39,7 @@ } public final void loadWithComponents(ValueInput p_409893_) { -@@ -103,6 +_,7 @@ +@@ -105,6 +_,7 @@ } protected void saveAdditional(ValueOutput p_407573_) { @@ -47,7 +47,7 @@ } public final CompoundTag saveWithFullMetadata(HolderLookup.Provider p_331193_) { -@@ -238,6 +_,13 @@ +@@ -240,6 +_,13 @@ public void setRemoved() { this.remove = true; diff --git a/patches/minecraft/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java.patch b/patches/minecraft/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java.patch index edd5661d5c..7bddbf19eb 100644 --- a/patches/minecraft/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java +++ b/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java -@@ -173,15 +_,18 @@ +@@ -174,15 +_,18 @@ for (int i = 0; i < 3; i++) { p_155293_.set(i, potionbrewing.mix(itemstack, p_155293_.get(i))); } @@ -21,7 +21,7 @@ } p_155293_.set(3, itemstack); -@@ -214,6 +_,9 @@ +@@ -215,6 +_,9 @@ if (p_59017_ == 3) { PotionBrewing potionbrewing = this.level != null ? this.level.potionBrewing() : PotionBrewing.EMPTY; return potionbrewing.isIngredient(p_59018_); @@ -31,7 +31,7 @@ } else { return p_59017_ == 4 ? p_59018_.is(ItemTags.BREWING_FUEL) -@@ -249,5 +_,34 @@ +@@ -250,5 +_,34 @@ @Override protected AbstractContainerMenu createMenu(int p_58990_, Inventory p_58991_) { return new BrewingStandMenu(p_58990_, p_58991_, this, this.dataAccess); diff --git a/patches/minecraft/net/minecraft/world/level/block/entity/ChestBlockEntity.java.patch b/patches/minecraft/net/minecraft/world/level/block/entity/ChestBlockEntity.java.patch index 4874830f39..43631d1675 100644 --- a/patches/minecraft/net/minecraft/world/level/block/entity/ChestBlockEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/entity/ChestBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/ChestBlockEntity.java +++ b/net/minecraft/world/level/block/entity/ChestBlockEntity.java -@@ -183,4 +_,43 @@ +@@ -194,4 +_,43 @@ Block block = p_155335_.getBlock(); p_155333_.blockEvent(p_155334_, block, 1, p_155337_); } diff --git a/patches/minecraft/net/minecraft/world/level/block/entity/ChiseledBookShelfBlockEntity.java.patch b/patches/minecraft/net/minecraft/world/level/block/entity/ChiseledBookShelfBlockEntity.java.patch index ba2c184fd6..b23a9cf71f 100644 --- a/patches/minecraft/net/minecraft/world/level/block/entity/ChiseledBookShelfBlockEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/entity/ChiseledBookShelfBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/ChiseledBookShelfBlockEntity.java +++ b/net/minecraft/world/level/block/entity/ChiseledBookShelfBlockEntity.java -@@ -160,4 +_,28 @@ +@@ -135,4 +_,28 @@ public void removeComponentsFromTag(ValueOutput p_405909_) { p_405909_.discard("Items"); } diff --git a/patches/minecraft/net/minecraft/world/level/block/entity/HopperBlockEntity.java.patch b/patches/minecraft/net/minecraft/world/level/block/entity/HopperBlockEntity.java.patch index dadccc848b..7e6a308a01 100644 --- a/patches/minecraft/net/minecraft/world/level/block/entity/HopperBlockEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/entity/HopperBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/HopperBlockEntity.java +++ b/net/minecraft/world/level/block/entity/HopperBlockEntity.java -@@ -138,6 +_,7 @@ +@@ -139,6 +_,7 @@ } private static boolean ejectItems(Level p_155563_, BlockPos p_155564_, HopperBlockEntity p_329427_) { @@ -8,7 +8,7 @@ Container container = getAttachedContainer(p_155563_, p_155564_, p_329427_); if (container == null) { return false; -@@ -213,6 +_,8 @@ +@@ -214,6 +_,8 @@ } public static boolean suckInItems(Level p_155553_, Hopper p_155554_) { @@ -17,7 +17,7 @@ BlockPos blockpos = BlockPos.containing(p_155554_.getLevelX(), p_155554_.getLevelY() + 1.0, p_155554_.getLevelZ()); BlockState blockstate = p_155553_.getBlockState(blockpos); Container container = getSourceContainer(p_155553_, p_155554_, blockpos, blockstate); -@@ -451,5 +_,14 @@ +@@ -452,5 +_,14 @@ @Override protected AbstractContainerMenu createMenu(int p_59312_, Inventory p_59313_) { return new HopperMenu(p_59312_, p_59313_, this); diff --git a/patches/minecraft/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java.patch b/patches/minecraft/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java.patch index c68fd0e61c..89d7b12cf0 100644 --- a/patches/minecraft/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java +++ b/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java -@@ -234,7 +_,7 @@ +@@ -235,7 +_,7 @@ @Override public boolean canPlaceItemThroughFace(int p_59663_, ItemStack p_59664_, @Nullable Direction p_59665_) { @@ -9,7 +9,7 @@ } @Override -@@ -258,6 +_,11 @@ +@@ -259,6 +_,11 @@ public boolean isClosed() { return this.animationStatus == ShulkerBoxBlockEntity.AnimationStatus.CLOSED; diff --git a/patches/minecraft/net/minecraft/world/level/block/state/BlockBehaviour.java.patch b/patches/minecraft/net/minecraft/world/level/block/state/BlockBehaviour.java.patch index 284fd2f60f..c81ada3611 100644 --- a/patches/minecraft/net/minecraft/world/level/block/state/BlockBehaviour.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/state/BlockBehaviour.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/state/BlockBehaviour.java +++ b/net/minecraft/world/level/block/state/BlockBehaviour.java -@@ -178,7 +_,7 @@ +@@ -177,7 +_,7 @@ if (!p_310712_.isAir() && p_312709_.getBlockInteraction() != Explosion.BlockInteraction.TRIGGER_BLOCK) { Block block = p_310712_.getBlock(); boolean flag = p_312709_.getIndirectSourceEntity() instanceof Player; @@ -9,7 +9,7 @@ BlockEntity blockentity = p_310712_.hasBlockEntity() ? p_367589_.getBlockEntity(p_311490_) : null; LootParams.Builder lootparams$builder = new LootParams.Builder(p_367589_) .withParameter(LootContextParams.ORIGIN, Vec3.atCenterOf(p_311490_)) -@@ -193,8 +_,7 @@ +@@ -192,8 +_,7 @@ p_310712_.getDrops(lootparams$builder).forEach(p_309419_ -> p_311277_.accept(p_309419_, p_311490_)); } @@ -19,7 +19,7 @@ } } -@@ -344,12 +_,15 @@ +@@ -347,12 +_,15 @@ if (f == -1.0F) { return 0.0F; } else { @@ -37,7 +37,7 @@ } protected void attack(BlockState p_60499_, Level p_60500_, BlockPos p_60501_, Player p_60502_) { -@@ -385,6 +_,8 @@ +@@ -388,6 +_,8 @@ return this.isRandomlyTicking; } @@ -46,7 +46,7 @@ protected SoundType getSoundType(BlockState p_328629_) { return this.soundType; } -@@ -405,6 +_,10 @@ +@@ -408,6 +_,10 @@ return this.properties.destroyTime; } @@ -57,7 +57,7 @@ public abstract static class BlockStateBase extends StateHolder { private static final Direction[] DIRECTIONS = Direction.values(); private static final VoxelShape[] EMPTY_OCCLUSION_SHAPES = Util.make(new VoxelShape[DIRECTIONS.length], p_368402_ -> Arrays.fill(p_368402_, Shapes.empty())); -@@ -557,12 +_,14 @@ +@@ -560,12 +_,14 @@ return this.useShapeForLightOcclusion; } @@ -73,7 +73,7 @@ } public boolean ignitedByLava() { -@@ -575,9 +_,11 @@ +@@ -578,9 +_,11 @@ } public MapColor getMapColor(BlockGetter p_285002_, BlockPos p_285293_) { @@ -86,7 +86,7 @@ public BlockState rotate(Rotation p_60718_) { return this.getBlock().rotate(this.asState(), p_60718_); } -@@ -631,6 +_,8 @@ +@@ -634,6 +_,8 @@ } public PushReaction getPistonPushReaction() { @@ -95,7 +95,7 @@ return this.pushReaction; } -@@ -996,7 +_,7 @@ +@@ -1002,7 +_,7 @@ BlockBehaviour.StateArgumentPredicate> isValidSpawn = (p_360542_, p_360543_, p_360544_, p_360545_) -> p_360542_.isFaceSturdy( p_360543_, p_360544_, Direction.UP ) diff --git a/patches/minecraft/net/minecraft/world/level/chunk/ChunkAccess.java.patch b/patches/minecraft/net/minecraft/world/level/chunk/ChunkAccess.java.patch index e8708ab799..279915fe34 100644 --- a/patches/minecraft/net/minecraft/world/level/chunk/ChunkAccess.java.patch +++ b/patches/minecraft/net/minecraft/world/level/chunk/ChunkAccess.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/chunk/ChunkAccess.java +++ b/net/minecraft/world/level/chunk/ChunkAccess.java -@@ -329,23 +_,28 @@ +@@ -328,23 +_,28 @@ @Override public final void findBlockLightSources(BiConsumer p_285269_) { @@ -33,7 +33,7 @@ } } } -@@ -504,5 +_,10 @@ +@@ -503,5 +_,10 @@ } public record PackedTicks(List> blocks, List> fluids) { diff --git a/patches/minecraft/net/minecraft/world/level/chunk/ImposterProtoChunk.java.patch b/patches/minecraft/net/minecraft/world/level/chunk/ImposterProtoChunk.java.patch index 3dcaa1b97b..21c8642a34 100644 --- a/patches/minecraft/net/minecraft/world/level/chunk/ImposterProtoChunk.java.patch +++ b/patches/minecraft/net/minecraft/world/level/chunk/ImposterProtoChunk.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/chunk/ImposterProtoChunk.java +++ b/net/minecraft/world/level/chunk/ImposterProtoChunk.java -@@ -291,4 +_,9 @@ +@@ -284,4 +_,9 @@ public ChunkSkyLightSources getSkyLightSources() { return this.wrapped.getSkyLightSources(); } diff --git a/patches/minecraft/net/minecraft/world/level/chunk/LevelChunk.java.patch b/patches/minecraft/net/minecraft/world/level/chunk/LevelChunk.java.patch index 54e17e5a3f..c60092fa76 100644 --- a/patches/minecraft/net/minecraft/world/level/chunk/LevelChunk.java.patch +++ b/patches/minecraft/net/minecraft/world/level/chunk/LevelChunk.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/level/chunk/LevelChunk.java +++ b/net/minecraft/world/level/chunk/LevelChunk.java -@@ -55,7 +_,7 @@ +@@ -62,7 +_,7 @@ import net.minecraft.world.ticks.TickContainerAccess; import org.slf4j.Logger; --public class LevelChunk extends ChunkAccess { -+public class LevelChunk extends ChunkAccess implements net.minecraftforge.common.capabilities.ICapabilityProviderImpl { +-public class LevelChunk extends ChunkAccess implements DebugValueSource { ++public class LevelChunk extends ChunkAccess implements DebugValueSource, net.minecraftforge.common.capabilities.ICapabilityProviderImpl { static final Logger LOGGER = LogUtils.getLogger(); private static final TickingBlockEntity NULL_TICKER = new TickingBlockEntity() { @Override -@@ -117,6 +_,7 @@ +@@ -124,6 +_,7 @@ this.postLoad = p_196861_; this.blockTicks = p_196857_; this.fluidTicks = p_196858_; @@ -17,16 +17,16 @@ } public LevelChunk(ServerLevel p_196850_, ProtoChunk p_196851_, @Nullable LevelChunk.PostLoadProcessor p_196852_) { -@@ -314,7 +_,7 @@ +@@ -321,7 +_,7 @@ if (!levelchunksection.getBlockState(j, k, l).is(block)) { return null; } else { -- if (!this.level.isClientSide && (p_393998_ & 512) == 0) { -+ if (!this.level.isClientSide && (p_393998_ & 512) == 0 && !this.level.captureBlockSnapshots) { +- if (!this.level.isClientSide() && (p_393998_ & 512) == 0) { ++ if (!this.level.isClientSide() && (p_393998_ & 512) == 0 && !this.level.captureBlockSnapshots) { p_62866_.onPlace(this.level, p_62865_, blockstate, flag2); } -@@ -369,6 +_,12 @@ +@@ -376,6 +_,12 @@ @Nullable public BlockEntity getBlockEntity(BlockPos p_62868_, LevelChunk.EntityCreationType p_62869_) { BlockEntity blockentity = this.blockEntities.get(p_62868_); @@ -39,7 +39,7 @@ if (blockentity == null) { CompoundTag compoundtag = this.pendingBlockEntities.remove(p_62868_); if (compoundtag != null) { -@@ -386,9 +_,6 @@ +@@ -393,9 +_,6 @@ this.addAndRegisterBlockEntity(blockentity); } } @@ -49,7 +49,7 @@ } return blockentity; -@@ -403,6 +_,7 @@ +@@ -410,6 +_,7 @@ this.level.onBlockEntityAdded(p_156391_); this.updateBlockEntityTicker(p_156391_); @@ -57,7 +57,7 @@ } } -@@ -455,9 +_,14 @@ +@@ -462,9 +_,14 @@ public CompoundTag getBlockEntityNbtForSaving(BlockPos p_62932_, HolderLookup.Provider p_329605_) { BlockEntity blockentity = this.getBlockEntity(p_62932_); if (blockentity != null && !blockentity.isRemoved()) { @@ -72,7 +72,7 @@ } else { CompoundTag compoundtag = this.pendingBlockEntities.get(p_62932_); if (compoundtag != null) { -@@ -536,9 +_,10 @@ +@@ -544,9 +_,10 @@ (p_405747_, p_405748_, p_405749_) -> { BlockEntity blockentity = this.getBlockEntity(p_405747_, LevelChunk.EntityCreationType.IMMEDIATE); if (blockentity != null && p_405749_ != null && blockentity.getType() == p_405748_) { @@ -84,7 +84,7 @@ } } ); -@@ -650,6 +_,7 @@ +@@ -684,6 +_,7 @@ } public void clearAllBlockEntities() { @@ -92,7 +92,7 @@ this.blockEntities.values().forEach(BlockEntity::setRemoved); this.blockEntities.clear(); this.tickersInLevel.values().forEach(p_187966_ -> p_187966_.rebind(NULL_TICKER)); -@@ -657,6 +_,7 @@ +@@ -691,6 +_,7 @@ } public void registerAllBlockEntitiesAfterLevelLoad() { @@ -100,7 +100,7 @@ this.blockEntities.values().forEach(p_405750_ -> { if (this.level instanceof ServerLevel serverlevel) { this.addGameEventListener(p_405750_, serverlevel); -@@ -709,6 +_,24 @@ +@@ -743,6 +_,24 @@ return new LevelChunk.BoundTickingBlockEntity<>(p_156376_, p_156377_); } @@ -125,7 +125,7 @@ class BoundTickingBlockEntity implements TickingBlockEntity { private final T blockEntity; private final BlockEntityTicker ticker; -@@ -726,6 +_,7 @@ +@@ -760,6 +_,7 @@ if (LevelChunk.this.isTicking(blockpos)) { try { ProfilerFiller profilerfiller = Profiler.get(); @@ -133,7 +133,7 @@ profilerfiller.push(this::getType); BlockState blockstate = LevelChunk.this.getBlockState(blockpos); if (this.blockEntity.getType().isValid(blockstate)) { -@@ -747,6 +_,11 @@ +@@ -781,6 +_,11 @@ CrashReport crashreport = CrashReport.forThrowable(throwable, "Ticking block entity"); CrashReportCategory crashreportcategory = crashreport.addCategory("Block entity being ticked"); this.blockEntity.fillCrashReportCategory(crashreportcategory); @@ -145,7 +145,7 @@ throw new ReportedException(crashreport); } } -@@ -820,6 +_,33 @@ +@@ -854,6 +_,33 @@ public String toString() { return this.ticker + " "; } diff --git a/patches/minecraft/net/minecraft/world/level/chunk/status/ChunkStatusTasks.java.patch b/patches/minecraft/net/minecraft/world/level/chunk/status/ChunkStatusTasks.java.patch index 6ef5a0eacc..d5fa13b353 100644 --- a/patches/minecraft/net/minecraft/world/level/chunk/status/ChunkStatusTasks.java.patch +++ b/patches/minecraft/net/minecraft/world/level/chunk/status/ChunkStatusTasks.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/chunk/status/ChunkStatusTasks.java +++ b/net/minecraft/world/level/chunk/status/ChunkStatusTasks.java -@@ -199,9 +_,15 @@ +@@ -203,9 +_,15 @@ levelchunk.setFullStatus(generationchunkholder::getFullStatus); levelchunk.runPostLoad(); levelchunk.setLoaded(true); diff --git a/patches/minecraft/net/minecraft/world/level/levelgen/Beardifier.java.patch b/patches/minecraft/net/minecraft/world/level/levelgen/Beardifier.java.patch index c4a5f6f425..71dc3e822f 100644 --- a/patches/minecraft/net/minecraft/world/level/levelgen/Beardifier.java.patch +++ b/patches/minecraft/net/minecraft/world/level/levelgen/Beardifier.java.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/world/level/levelgen/Beardifier.java +++ b/net/minecraft/world/level/levelgen/Beardifier.java -@@ -42,6 +_,11 @@ +@@ -53,6 +_,11 @@ - for (StructurePiece structurepiece : p_223936_.getPieces()) { - if (structurepiece.isCloseToChunk(p_223939_, 12)) { -+ if (structurepiece instanceof net.minecraftforge.common.world.PieceBeardifierModifier pieceBeardifierModifier) { -+ if (pieceBeardifierModifier.getTerrainAdjustment() != TerrainAdjustment.NONE) { -+ objectlist.add(new Beardifier.Rigid(pieceBeardifierModifier.getBeardifierBox(), pieceBeardifierModifier.getTerrainAdjustment(), pieceBeardifierModifier.getGroundLevelDelta())); -+ } -+ } else - if (structurepiece instanceof PoolElementStructurePiece poolelementstructurepiece) { - StructureTemplatePool.Projection structuretemplatepool$projection = poolelementstructurepiece.getElement().getProjection(); - if (structuretemplatepool$projection == StructureTemplatePool.Projection.RIGID) { + for (StructurePiece structurepiece : structurestart.getPieces()) { + if (structurepiece.isCloseToChunk(p_223939_, 12)) { ++ if (structurepiece instanceof net.minecraftforge.common.world.PieceBeardifierModifier pieceBeardifierModifier) { ++ if (pieceBeardifierModifier.getTerrainAdjustment() != TerrainAdjustment.NONE) { ++ list1.add(new Beardifier.Rigid(pieceBeardifierModifier.getBeardifierBox(), pieceBeardifierModifier.getTerrainAdjustment(), pieceBeardifierModifier.getGroundLevelDelta())); ++ } ++ } else + if (structurepiece instanceof PoolElementStructurePiece poolelementstructurepiece) { + StructureTemplatePool.Projection structuretemplatepool$projection = poolelementstructurepiece.getElement().getProjection(); + if (structuretemplatepool$projection == StructureTemplatePool.Projection.RIGID) { diff --git a/patches/minecraft/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java.patch b/patches/minecraft/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java.patch index dfc761c6c4..677d0dd13e 100644 --- a/patches/minecraft/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java.patch +++ b/patches/minecraft/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java +++ b/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java -@@ -261,6 +_,10 @@ +@@ -262,6 +_,10 @@ return transform(p_74565_, p_74564_.getMirror(), p_74564_.getRotation(), p_74564_.getRotationPivot()); } @@ -11,7 +11,7 @@ public boolean placeInWorld( ServerLevelAccessor p_230329_, BlockPos p_230330_, BlockPos p_230331_, StructurePlaceSettings p_230332_, RandomSource p_230333_, int p_230334_ ) { -@@ -282,7 +_,7 @@ +@@ -283,7 +_,7 @@ int l = Integer.MIN_VALUE; int i1 = Integer.MIN_VALUE; int j1 = Integer.MIN_VALUE; @@ -20,7 +20,7 @@ try (ProblemReporter.ScopedCollector problemreporter$scopedcollector = new ProblemReporter.ScopedCollector(LOGGER)) { for (StructureTemplate.StructureBlockInfo structuretemplate$structureblockinfo : list4) { -@@ -406,10 +_,10 @@ +@@ -407,10 +_,10 @@ p_230330_, p_230332_.getMirror(), p_230332_.getRotation(), @@ -33,7 +33,7 @@ ); } } -@@ -451,12 +_,21 @@ +@@ -452,12 +_,21 @@ ); } @@ -56,7 +56,7 @@ ) { List list = new ArrayList<>(); List list1 = new ArrayList<>(); -@@ -472,7 +_,7 @@ +@@ -473,7 +_,7 @@ while (structuretemplate$structureblockinfo1 != null && iterator.hasNext()) { structuretemplate$structureblockinfo1 = iterator.next() @@ -65,7 +65,7 @@ } if (structuretemplate$structureblockinfo1 != null) { -@@ -493,17 +_,17 @@ +@@ -494,17 +_,17 @@ BlockPos p_74525_, Mirror p_74526_, Rotation p_74527_, @@ -89,7 +89,7 @@ ListTag listtag = new ListTag(); listtag.add(DoubleTag.valueOf(vec31.x)); listtag.add(DoubleTag.valueOf(vec31.y)); -@@ -523,6 +_,24 @@ +@@ -526,6 +_,24 @@ } } } diff --git a/patches/minecraft/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplateManager.java.patch b/patches/minecraft/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplateManager.java.patch index 3fa1eef5a1..2670169129 100644 --- a/patches/minecraft/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplateManager.java.patch +++ b/patches/minecraft/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplateManager.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplateManager.java +++ b/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplateManager.java -@@ -76,6 +_,7 @@ +@@ -78,6 +_,7 @@ } builder.add(new StructureTemplateManager.Source(this::loadFromResource, this::listResources)); diff --git a/patches/minecraft/net/minecraft/world/level/material/FlowingFluid.java.patch b/patches/minecraft/net/minecraft/world/level/material/FlowingFluid.java.patch index bc9d730f82..8b5b2cf18b 100644 --- a/patches/minecraft/net/minecraft/world/level/material/FlowingFluid.java.patch +++ b/patches/minecraft/net/minecraft/world/level/material/FlowingFluid.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/material/FlowingFluid.java +++ b/net/minecraft/world/level/material/FlowingFluid.java -@@ -170,7 +_,7 @@ +@@ -171,7 +_,7 @@ BlockState blockstate = p_369574_.getBlockState(blockpos); FluidState fluidstate = blockstate.getFluidState(); if (fluidstate.getType().isSame(this) && canPassThroughWall(direction, p_369574_, p_76037_, p_76038_, blockpos, blockstate)) { @@ -9,7 +9,7 @@ j++; } -@@ -178,7 +_,7 @@ +@@ -179,7 +_,7 @@ } } @@ -18,7 +18,7 @@ BlockState blockstate1 = p_369574_.getBlockState(blockpos$mutableblockpos.setWithOffset(p_76037_, Direction.DOWN)); FluidState fluidstate1 = blockstate1.getFluidState(); if (blockstate1.isSolid() || this.isSourceBlockOfThisType(fluidstate1)) { -@@ -252,6 +_,15 @@ +@@ -257,6 +_,15 @@ return this.getSource().defaultFluidState().setValue(FALLING, p_76069_); } diff --git a/patches/minecraft/net/minecraft/world/level/material/LavaFluid.java.patch b/patches/minecraft/net/minecraft/world/level/material/LavaFluid.java.patch index 6fef676e2a..259109daae 100644 --- a/patches/minecraft/net/minecraft/world/level/material/LavaFluid.java.patch +++ b/patches/minecraft/net/minecraft/world/level/material/LavaFluid.java.patch @@ -20,7 +20,7 @@ } } } -@@ -123,7 +_,7 @@ +@@ -124,7 +_,7 @@ private boolean hasFlammableNeighbours(LevelReader p_76228_, BlockPos p_76229_) { for (Direction direction : Direction.values()) { @@ -29,7 +29,7 @@ return true; } } -@@ -131,10 +_,17 @@ +@@ -132,10 +_,17 @@ return false; } @@ -47,7 +47,7 @@ @Nullable @Override public ParticleOptions getDripParticle() { -@@ -206,7 +_,8 @@ +@@ -207,7 +_,8 @@ FluidState fluidstate = p_76220_.getFluidState(p_76221_); if (this.is(FluidTags.LAVA) && fluidstate.is(FluidTags.WATER)) { if (p_76222_.getBlock() instanceof LiquidBlock) { diff --git a/patches/minecraft/net/minecraft/world/level/storage/PlayerDataStorage.java.patch b/patches/minecraft/net/minecraft/world/level/storage/PlayerDataStorage.java.patch index b2d9a5198d..00b6480c6d 100644 --- a/patches/minecraft/net/minecraft/world/level/storage/PlayerDataStorage.java.patch +++ b/patches/minecraft/net/minecraft/world/level/storage/PlayerDataStorage.java.patch @@ -1,27 +1,16 @@ --- a/net/minecraft/world/level/storage/PlayerDataStorage.java +++ b/net/minecraft/world/level/storage/PlayerDataStorage.java -@@ -42,6 +_,7 @@ +@@ -43,6 +_,7 @@ Path path2 = path.resolve(p_78434_.getStringUUID() + ".dat"); Path path3 = path.resolve(p_78434_.getStringUUID() + ".dat_old"); Util.safeReplaceFile(path2, path1, path3); + net.minecraftforge.event.ForgeEventFactory.firePlayerSavingEvent(p_78434_, playerDir, p_78434_.getStringUUID()); } catch (Exception exception) { - LOGGER.warn("Failed to save player data for {}", p_78434_.getName().getString()); + LOGGER.warn("Failed to save player data for {}", p_78434_.getPlainTextName()); } -@@ -64,7 +_,9 @@ - File file1 = new File(this.playerDir, p_329651_.getStringUUID() + p_330353_); - if (file1.exists() && file1.isFile()) { - try { -- return Optional.of(NbtIo.readCompressed(file1.toPath(), NbtAccounter.unlimitedHeap())); -+ var ret = Optional.of(NbtIo.readCompressed(file1.toPath(), NbtAccounter.unlimitedHeap())); -+ net.minecraftforge.event.ForgeEventFactory.firePlayerLoadingEvent(p_329651_, playerDir, p_329651_.getStringUUID()); -+ return ret; - } catch (Exception exception) { - LOGGER.warn("Failed to load player data for {}", p_329651_.getName().getString()); - } -@@ -86,5 +_,9 @@ - p_78436_.load(valueinput); - return valueinput; +@@ -85,5 +_,9 @@ + int i = NbtUtils.getDataVersion(p_422259_, -1); + return DataFixTypes.PLAYER.updateToCurrentVersion(this.fixerUpper, p_422259_, i); }); + } + diff --git a/patches/minecraft/net/minecraft/world/level/storage/PrimaryLevelData.java.patch b/patches/minecraft/net/minecraft/world/level/storage/PrimaryLevelData.java.patch index 572f491100..16ddba3313 100644 --- a/patches/minecraft/net/minecraft/world/level/storage/PrimaryLevelData.java.patch +++ b/patches/minecraft/net/minecraft/world/level/storage/PrimaryLevelData.java.patch @@ -8,7 +8,7 @@ private PrimaryLevelData( @Nullable CompoundTag p_277888_, -@@ -199,7 +_,7 @@ +@@ -195,7 +_,7 @@ p_251864_, p_250651_, p_78538_ @@ -17,7 +17,7 @@ } @Override -@@ -267,6 +_,8 @@ +@@ -260,6 +_,8 @@ p_78547_.putInt("WanderingTraderSpawnDelay", this.wanderingTraderSpawnDelay); p_78547_.putInt("WanderingTraderSpawnChance", this.wanderingTraderSpawnChance); p_78547_.storeNullable("WanderingTraderId", UUIDUtil.CODEC, this.wanderingTraderId); @@ -26,7 +26,7 @@ } private static ListTag stringCollectionToTag(Set p_277880_) { -@@ -565,6 +_,16 @@ +@@ -552,6 +_,16 @@ public LevelSettings getLevelSettings() { return this.settings.copy(); } diff --git a/patches/minecraft/net/minecraft/world/level/storage/loot/LootContext.java.patch b/patches/minecraft/net/minecraft/world/level/storage/loot/LootContext.java.patch index c3a9c0e404..cc91341633 100644 --- a/patches/minecraft/net/minecraft/world/level/storage/loot/LootContext.java.patch +++ b/patches/minecraft/net/minecraft/world/level/storage/loot/LootContext.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/storage/loot/LootContext.java +++ b/net/minecraft/world/level/storage/loot/LootContext.java -@@ -23,11 +_,17 @@ +@@ -24,11 +_,17 @@ private final RandomSource random; private final HolderGetter.Provider lootDataResolver; private final Set> visitedElements = Sets.newLinkedHashSet(); @@ -18,7 +18,7 @@ } public boolean hasParameter(ContextKey p_368930_) { -@@ -75,6 +_,10 @@ +@@ -76,6 +_,10 @@ return this.params.getLevel(); } @@ -29,7 +29,7 @@ public static LootContext.VisitedEntry createVisitedEntry(LootTable p_279327_) { return new LootContext.VisitedEntry<>(LootDataType.TABLE, p_279327_); } -@@ -87,15 +_,34 @@ +@@ -88,6 +_,18 @@ return new LootContext.VisitedEntry<>(LootDataType.MODIFIER, p_279163_); } @@ -45,7 +45,10 @@ + return this.queriedLootTableId == null ? net.minecraftforge.common.loot.LootTableIdCondition.UNKNOWN_LOOT_TABLE : this.queriedLootTableId; + } + - public static class Builder { + public static enum BlockEntityTarget implements StringRepresentable { + BLOCK_ENTITY("block_entity", LootContextParams.BLOCK_ENTITY); + +@@ -113,11 +_,18 @@ private final LootParams params; @Nullable private RandomSource random; @@ -64,7 +67,7 @@ public LootContext.Builder withOptionalRandomSeed(long p_78966_) { if (p_78966_ != 0L) { this.random = RandomSource.create(p_78966_); -@@ -109,6 +_,11 @@ +@@ -131,6 +_,11 @@ return this; } @@ -76,7 +79,7 @@ public ServerLevel getLevel() { return this.params.getLevel(); } -@@ -117,7 +_,7 @@ +@@ -139,7 +_,7 @@ ServerLevel serverlevel = this.getLevel(); MinecraftServer minecraftserver = serverlevel.getServer(); RandomSource randomsource = Optional.ofNullable(this.random).or(() -> p_299315_.map(serverlevel::getRandomSequence)).orElseGet(serverlevel::getRandom); diff --git a/patches/minecraft/net/minecraft/world/level/storage/loot/providers/nbt/ContextNbtProvider.java.patch b/patches/minecraft/net/minecraft/world/level/storage/loot/providers/nbt/ContextNbtProvider.java.patch deleted file mode 100644 index 2235d284f0..0000000000 --- a/patches/minecraft/net/minecraft/world/level/storage/loot/providers/nbt/ContextNbtProvider.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/world/level/storage/loot/providers/nbt/ContextNbtProvider.java -+++ b/net/minecraft/world/level/storage/loot/providers/nbt/ContextNbtProvider.java -@@ -59,7 +_,7 @@ - - @Override - public String getId() { -- return p_165578_.name(); -+ return p_165578_.getSerializedName(); - } - - @Override diff --git a/src/main/generated/data/c/tags/block/chains.json b/src/main/generated/data/c/tags/block/chains.json index 63bbe5b427..58c2b30a5a 100644 --- a/src/main/generated/data/c/tags/block/chains.json +++ b/src/main/generated/data/c/tags/block/chains.json @@ -1,5 +1,13 @@ { "values": [ - "minecraft:chain" + "minecraft:iron_chain", + "minecraft:copper_chain", + "minecraft:waxed_copper_chain", + "minecraft:exposed_copper_chain", + "minecraft:waxed_exposed_copper_chain", + "minecraft:weathered_copper_chain", + "minecraft:waxed_weathered_copper_chain", + "minecraft:oxidized_copper_chain", + "minecraft:waxed_oxidized_copper_chain" ] } \ No newline at end of file diff --git a/src/main/generated/data/c/tags/item/chains.json b/src/main/generated/data/c/tags/item/chains.json index 63bbe5b427..58c2b30a5a 100644 --- a/src/main/generated/data/c/tags/item/chains.json +++ b/src/main/generated/data/c/tags/item/chains.json @@ -1,5 +1,13 @@ { "values": [ - "minecraft:chain" + "minecraft:iron_chain", + "minecraft:copper_chain", + "minecraft:waxed_copper_chain", + "minecraft:exposed_copper_chain", + "minecraft:waxed_exposed_copper_chain", + "minecraft:weathered_copper_chain", + "minecraft:waxed_weathered_copper_chain", + "minecraft:oxidized_copper_chain", + "minecraft:waxed_oxidized_copper_chain" ] } \ No newline at end of file diff --git a/src/main/generated/data/minecraft/recipe/copper_axe.json b/src/main/generated/data/minecraft/recipe/copper_axe.json new file mode 100644 index 0000000000..98bae5923d --- /dev/null +++ b/src/main/generated/data/minecraft/recipe/copper_axe.json @@ -0,0 +1,17 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "equipment", + "key": { + "#": "#c:rods/wooden", + "X": "#minecraft:copper_tool_materials" + }, + "pattern": [ + "XX", + "X#", + " #" + ], + "result": { + "count": 1, + "id": "minecraft:copper_axe" + } +} \ No newline at end of file diff --git a/src/main/generated/data/minecraft/recipe/copper_bars.json b/src/main/generated/data/minecraft/recipe/copper_bars.json new file mode 100644 index 0000000000..57c1a88ba8 --- /dev/null +++ b/src/main/generated/data/minecraft/recipe/copper_bars.json @@ -0,0 +1,15 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "misc", + "key": { + "#": "#c:ingots/copper" + }, + "pattern": [ + "###", + "###" + ], + "result": { + "count": 16, + "id": "minecraft:copper_bars" + } +} \ No newline at end of file diff --git a/src/main/generated/data/minecraft/recipe/copper_boots.json b/src/main/generated/data/minecraft/recipe/copper_boots.json new file mode 100644 index 0000000000..d6dede53ee --- /dev/null +++ b/src/main/generated/data/minecraft/recipe/copper_boots.json @@ -0,0 +1,15 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "equipment", + "key": { + "X": "#c:ingots/copper" + }, + "pattern": [ + "X X", + "X X" + ], + "result": { + "count": 1, + "id": "minecraft:copper_boots" + } +} \ No newline at end of file diff --git a/src/main/generated/data/minecraft/recipe/copper_chain.json b/src/main/generated/data/minecraft/recipe/copper_chain.json new file mode 100644 index 0000000000..7b30fb1115 --- /dev/null +++ b/src/main/generated/data/minecraft/recipe/copper_chain.json @@ -0,0 +1,17 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "misc", + "key": { + "I": "#c:ingots/copper", + "N": "minecraft:copper_nugget" + }, + "pattern": [ + "N", + "I", + "N" + ], + "result": { + "count": 1, + "id": "minecraft:copper_chain" + } +} \ No newline at end of file diff --git a/src/main/generated/data/minecraft/recipe/copper_chest.json b/src/main/generated/data/minecraft/recipe/copper_chest.json new file mode 100644 index 0000000000..543686cdd0 --- /dev/null +++ b/src/main/generated/data/minecraft/recipe/copper_chest.json @@ -0,0 +1,17 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "misc", + "key": { + "#": "#c:ingots/copper", + "X": "#c:chests/wooden" + }, + "pattern": [ + "###", + "#X#", + "###" + ], + "result": { + "count": 1, + "id": "minecraft:copper_chest" + } +} \ No newline at end of file diff --git a/src/main/generated/data/minecraft/recipe/copper_chestplate.json b/src/main/generated/data/minecraft/recipe/copper_chestplate.json new file mode 100644 index 0000000000..996c150fcf --- /dev/null +++ b/src/main/generated/data/minecraft/recipe/copper_chestplate.json @@ -0,0 +1,16 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "equipment", + "key": { + "X": "#c:ingots/copper" + }, + "pattern": [ + "X X", + "XXX", + "XXX" + ], + "result": { + "count": 1, + "id": "minecraft:copper_chestplate" + } +} \ No newline at end of file diff --git a/src/main/generated/data/minecraft/recipe/copper_helmet.json b/src/main/generated/data/minecraft/recipe/copper_helmet.json new file mode 100644 index 0000000000..fe31d6caca --- /dev/null +++ b/src/main/generated/data/minecraft/recipe/copper_helmet.json @@ -0,0 +1,15 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "equipment", + "key": { + "X": "#c:ingots/copper" + }, + "pattern": [ + "XXX", + "X X" + ], + "result": { + "count": 1, + "id": "minecraft:copper_helmet" + } +} \ No newline at end of file diff --git a/src/main/generated/data/minecraft/recipe/copper_hoe.json b/src/main/generated/data/minecraft/recipe/copper_hoe.json new file mode 100644 index 0000000000..4eaf00f663 --- /dev/null +++ b/src/main/generated/data/minecraft/recipe/copper_hoe.json @@ -0,0 +1,17 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "equipment", + "key": { + "#": "#c:rods/wooden", + "X": "#minecraft:copper_tool_materials" + }, + "pattern": [ + "XX", + " #", + " #" + ], + "result": { + "count": 1, + "id": "minecraft:copper_hoe" + } +} \ No newline at end of file diff --git a/src/main/generated/data/minecraft/recipe/copper_leggings.json b/src/main/generated/data/minecraft/recipe/copper_leggings.json new file mode 100644 index 0000000000..aa4cb1e52f --- /dev/null +++ b/src/main/generated/data/minecraft/recipe/copper_leggings.json @@ -0,0 +1,16 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "equipment", + "key": { + "X": "#c:ingots/copper" + }, + "pattern": [ + "XXX", + "X X", + "X X" + ], + "result": { + "count": 1, + "id": "minecraft:copper_leggings" + } +} \ No newline at end of file diff --git a/src/main/generated/data/minecraft/recipe/copper_nugget.json b/src/main/generated/data/minecraft/recipe/copper_nugget.json new file mode 100644 index 0000000000..6309a958a8 --- /dev/null +++ b/src/main/generated/data/minecraft/recipe/copper_nugget.json @@ -0,0 +1,11 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "misc", + "ingredients": [ + "#c:ingots/copper" + ], + "result": { + "count": 9, + "id": "minecraft:copper_nugget" + } +} \ No newline at end of file diff --git a/src/main/generated/data/minecraft/recipe/copper_pickaxe.json b/src/main/generated/data/minecraft/recipe/copper_pickaxe.json new file mode 100644 index 0000000000..2238f2cf5e --- /dev/null +++ b/src/main/generated/data/minecraft/recipe/copper_pickaxe.json @@ -0,0 +1,17 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "equipment", + "key": { + "#": "#c:rods/wooden", + "X": "#minecraft:copper_tool_materials" + }, + "pattern": [ + "XXX", + " # ", + " # " + ], + "result": { + "count": 1, + "id": "minecraft:copper_pickaxe" + } +} \ No newline at end of file diff --git a/src/main/generated/data/minecraft/recipe/copper_shovel.json b/src/main/generated/data/minecraft/recipe/copper_shovel.json new file mode 100644 index 0000000000..581a606f5d --- /dev/null +++ b/src/main/generated/data/minecraft/recipe/copper_shovel.json @@ -0,0 +1,17 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "equipment", + "key": { + "#": "#c:rods/wooden", + "X": "#minecraft:copper_tool_materials" + }, + "pattern": [ + "X", + "#", + "#" + ], + "result": { + "count": 1, + "id": "minecraft:copper_shovel" + } +} \ No newline at end of file diff --git a/src/main/generated/data/minecraft/recipe/copper_sword.json b/src/main/generated/data/minecraft/recipe/copper_sword.json new file mode 100644 index 0000000000..123e70b648 --- /dev/null +++ b/src/main/generated/data/minecraft/recipe/copper_sword.json @@ -0,0 +1,17 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "equipment", + "key": { + "#": "#c:rods/wooden", + "X": "#minecraft:copper_tool_materials" + }, + "pattern": [ + "X", + "X", + "#" + ], + "result": { + "count": 1, + "id": "minecraft:copper_sword" + } +} \ No newline at end of file diff --git a/src/main/generated/data/minecraft/recipe/copper_torch.json b/src/main/generated/data/minecraft/recipe/copper_torch.json new file mode 100644 index 0000000000..4bde6043d5 --- /dev/null +++ b/src/main/generated/data/minecraft/recipe/copper_torch.json @@ -0,0 +1,21 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "misc", + "key": { + "#": "#c:rods/wooden", + "C": "minecraft:copper_nugget", + "X": [ + "minecraft:coal", + "minecraft:charcoal" + ] + }, + "pattern": [ + "C", + "X", + "#" + ], + "result": { + "count": 4, + "id": "minecraft:copper_torch" + } +} \ No newline at end of file diff --git a/src/main/generated/data/minecraft/recipe/copper_trapdoor.json b/src/main/generated/data/minecraft/recipe/copper_trapdoor.json index 2a117e7c5b..00b43cd5a3 100644 --- a/src/main/generated/data/minecraft/recipe/copper_trapdoor.json +++ b/src/main/generated/data/minecraft/recipe/copper_trapdoor.json @@ -5,11 +5,11 @@ "#": "#c:ingots/copper" }, "pattern": [ - "###", - "###" + "##", + "##" ], "result": { - "count": 2, + "count": 1, "id": "minecraft:copper_trapdoor" } } \ No newline at end of file diff --git a/src/main/generated/data/minecraft/recipe/chain.json b/src/main/generated/data/minecraft/recipe/iron_chain.json similarity index 86% rename from src/main/generated/data/minecraft/recipe/chain.json rename to src/main/generated/data/minecraft/recipe/iron_chain.json index bf70b9d5e3..5aab56a86f 100644 --- a/src/main/generated/data/minecraft/recipe/chain.json +++ b/src/main/generated/data/minecraft/recipe/iron_chain.json @@ -12,6 +12,6 @@ ], "result": { "count": 1, - "id": "minecraft:chain" + "id": "minecraft:iron_chain" } } \ No newline at end of file diff --git a/src/main/generated/pack.mcmeta b/src/main/generated/pack.mcmeta index 37db12f5d3..e8b22b0669 100644 --- a/src/main/generated/pack.mcmeta +++ b/src/main/generated/pack.mcmeta @@ -3,6 +3,7 @@ "description": { "translate": "pack.forge.description" }, - "pack_format": 81 + "max_format": 88, + "min_format": 88 } } \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/client/ClientCommandSourceStack.java b/src/main/java/net/minecraftforge/client/ClientCommandSourceStack.java index 9f25195c69..800230c7c2 100644 --- a/src/main/java/net/minecraftforge/client/ClientCommandSourceStack.java +++ b/src/main/java/net/minecraftforge/client/ClientCommandSourceStack.java @@ -57,7 +57,7 @@ public class ClientCommandSourceStack extends CommandSourceStack { */ @Override public Collection getOnlinePlayerNames() { - return Minecraft.getInstance().getConnection().getOnlinePlayers().stream().map((player) -> player.getProfile().getName()).collect(Collectors.toList()); + return Minecraft.getInstance().getConnection().getOnlinePlayers().stream().map((player) -> player.getProfile().name()).collect(Collectors.toList()); } /** diff --git a/src/main/java/net/minecraftforge/client/ColorResolverManager.java b/src/main/java/net/minecraftforge/client/ColorResolverManager.java index 802717c75b..19ff2706fb 100644 --- a/src/main/java/net/minecraftforge/client/ColorResolverManager.java +++ b/src/main/java/net/minecraftforge/client/ColorResolverManager.java @@ -27,7 +27,7 @@ public final class ColorResolverManager { @ApiStatus.Internal public static void init() { var builder = new ArrayList(); - ModLoader.get().postEvent(new RegisterColorHandlersEvent.ColorResolvers(builder)); + ModLoader.postEvent(new RegisterColorHandlersEvent.ColorResolvers(builder)); colorResolvers = List.copyOf(builder); } diff --git a/src/main/java/net/minecraftforge/client/DimensionSpecialEffectsManager.java b/src/main/java/net/minecraftforge/client/DimensionSpecialEffectsManager.java index 28358ab717..4fbe217172 100644 --- a/src/main/java/net/minecraftforge/client/DimensionSpecialEffectsManager.java +++ b/src/main/java/net/minecraftforge/client/DimensionSpecialEffectsManager.java @@ -38,7 +38,7 @@ public final class DimensionSpecialEffectsManager { var effects = new HashMap(); DEFAULT_EFFECTS = preRegisterVanillaEffects(effects); var event = new RegisterDimensionSpecialEffectsEvent(effects); - ModLoader.get().postEventWrapContainerInModOrder(event); + ModLoader.postEventWrapContainerInModOrder(event); EFFECTS = Map.copyOf(effects); } diff --git a/src/main/java/net/minecraftforge/client/EntitySpectatorShaderManager.java b/src/main/java/net/minecraftforge/client/EntitySpectatorShaderManager.java index fd2fee10ab..28a22da860 100644 --- a/src/main/java/net/minecraftforge/client/EntitySpectatorShaderManager.java +++ b/src/main/java/net/minecraftforge/client/EntitySpectatorShaderManager.java @@ -37,7 +37,7 @@ public final class EntitySpectatorShaderManager { public static void init() { var shaders = new HashMap, ResourceLocation>(); var event = new RegisterEntitySpectatorShadersEvent(shaders); - ModLoader.get().postEventWrapContainerInModOrder(event); + ModLoader.postEventWrapContainerInModOrder(event); SHADERS = Map.copyOf(shaders); } } diff --git a/src/main/java/net/minecraftforge/client/ForgeHooksClient.java b/src/main/java/net/minecraftforge/client/ForgeHooksClient.java index b1edb60f67..15719b1016 100644 --- a/src/main/java/net/minecraftforge/client/ForgeHooksClient.java +++ b/src/main/java/net/minecraftforge/client/ForgeHooksClient.java @@ -33,6 +33,9 @@ import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent; import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipPositioner; import net.minecraft.client.gui.screens.multiplayer.JoinMultiplayerScreen; +import net.minecraft.client.input.CharacterEvent; +import net.minecraft.client.input.KeyEvent; +import net.minecraft.client.input.MouseButtonEvent; import net.minecraft.client.model.HumanoidModel; import net.minecraft.client.model.Model; import net.minecraft.client.model.geom.ModelLayerLocation; @@ -42,13 +45,16 @@ import net.minecraft.client.multiplayer.PlayerInfo; import net.minecraft.client.multiplayer.ServerData; import net.minecraft.client.particle.ParticleEngine; import net.minecraft.client.particle.ParticleRenderType; +import net.minecraft.client.particle.ParticleResources; import net.minecraft.client.player.ClientInput; import net.minecraft.client.renderer.LevelRenderer; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderPipelines; +import net.minecraft.client.renderer.SubmitNodeCollector; import net.minecraft.client.renderer.chunk.ChunkSectionLayer; import net.minecraft.client.renderer.entity.state.HumanoidRenderState; import net.minecraft.client.renderer.fog.FogData; +import net.minecraft.client.renderer.state.LevelRenderState; import net.minecraft.client.renderer.texture.SpriteContents; import net.minecraft.client.renderer.texture.TextureAtlas; import net.minecraft.client.renderer.texture.TextureAtlasSprite; @@ -62,6 +68,7 @@ import net.minecraft.client.resources.model.UnbakedGeometry; import net.minecraft.client.resources.sounds.SoundInstance; import net.minecraft.client.sounds.SoundEngine; import net.minecraft.core.BlockPos; +import net.minecraft.data.AtlasIds; import net.minecraft.locale.Language; import net.minecraft.network.Connection; import net.minecraft.network.chat.ChatType; @@ -71,6 +78,7 @@ import net.minecraft.network.chat.FormattedText; import net.minecraft.network.chat.PlayerChatMessage; import net.minecraft.network.protocol.status.ServerStatus; import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.packs.metadata.MetadataSectionType; import net.minecraft.server.packs.resources.ReloadableResourceManager; import net.minecraft.server.packs.resources.Resource; import net.minecraft.server.packs.resources.ResourceMetadata; @@ -103,6 +111,7 @@ import net.minecraftforge.client.event.SystemMessageReceivedEvent; import net.minecraftforge.client.event.CustomizeGuiOverlayEvent; import net.minecraftforge.client.event.EntityRenderersEvent; import net.minecraftforge.client.event.ForgeEventFactoryClient; +import net.minecraftforge.client.event.GatherAtlasMetadataSectionsEvent; import net.minecraftforge.client.event.InputEvent; import net.minecraftforge.client.event.ModelEvent; import net.minecraftforge.client.event.MovementInputUpdateEvent; @@ -160,6 +169,7 @@ import java.util.Locale; import java.util.Map; import java.util.Objects; import java.util.Optional; +import java.util.Set; import java.util.Stack; import java.util.UUID; import java.util.concurrent.atomic.AtomicBoolean; @@ -237,29 +247,33 @@ public class ForgeHooksClient { } */ - public static boolean onDrawHighlight(LevelRenderer context, Camera camera, HitResult target, float partialTick, PoseStack poseStack, MultiBufferSource bufferSource) { - switch (target.getType()) { - case BLOCK: - if (!(target instanceof BlockHitResult blockTarget)) return false; - return RenderHighlightEvent.Block.BUS.post(new RenderHighlightEvent.Block(context, camera, blockTarget, partialTick, poseStack, bufferSource)); - case ENTITY: - if (!(target instanceof EntityHitResult entityTarget)) return false; - return RenderHighlightEvent.Entity.BUS.post(new RenderHighlightEvent.Entity(context, camera, entityTarget, partialTick, poseStack, bufferSource)); - default: - return false; // NO-OP - This doesn't even get called for anything other than blocks and entities + private static final RenderHighlightEvent.Callback NOOP_HIGHLIGHTER = (source, stack, translucent, state) -> { }; + + public static RenderHighlightEvent.Callback onExtractBlockOutline(LevelRenderer context, Camera camera, LevelRenderState state, HitResult target) { + if (target instanceof BlockHitResult blockTarget) { + var event = new RenderHighlightEvent.Block(context, camera, state, blockTarget); + if (RenderHighlightEvent.Block.BUS.post(event)) + return NOOP_HIGHLIGHTER; + return event.getCustomRenderer(); + } else if (target instanceof EntityHitResult entityTarget) { + var event = new RenderHighlightEvent.Entity(context, camera, state, entityTarget); + if (RenderHighlightEvent.Entity.BUS.post(event)) + return NOOP_HIGHLIGHTER; + return event.getCustomRenderer(); } + return null; } - public static boolean renderSpecificFirstPersonHand(InteractionHand hand, PoseStack poseStack, MultiBufferSource bufferSource, int packedLight, float partialTick, float interpPitch, float swingProgress, float equipProgress, ItemStack stack) { - return RenderHandEvent.BUS.post(new RenderHandEvent(hand, poseStack, bufferSource, packedLight, partialTick, interpPitch, swingProgress, equipProgress, stack)); + public static boolean renderSpecificFirstPersonHand(InteractionHand hand, PoseStack poseStack, SubmitNodeCollector nodeCollector, int packedLight, float partialTick, float interpPitch, float swingProgress, float equipProgress, ItemStack stack) { + return RenderHandEvent.BUS.post(new RenderHandEvent(hand, poseStack, nodeCollector, packedLight, partialTick, interpPitch, swingProgress, equipProgress, stack)); } public static void onTextureStitchedPost(TextureAtlas map) { - ModLoader.get().postEvent(new TextureStitchEvent.Post(map)); + ModLoader.postEvent(new TextureStitchEvent.Post(map)); } public static void onBlockColorsInit(BlockColors blockColors) { - ModLoader.get().postEvent(new RegisterColorHandlersEvent.Block(blockColors)); + ModLoader.postEvent(new RegisterColorHandlersEvent.Block(blockColors)); } public static Model getArmorModel(HumanoidRenderState state, ItemStack itemStack, EquipmentSlot slot, HumanoidModel _default) { @@ -267,6 +281,7 @@ public class ForgeHooksClient { } /** Copies humanoid model properties from the original model to another, used for armor models */ + /* Mojang removied copying in 1.21.9 @SuppressWarnings("unchecked") public static void copyModelProperties(HumanoidModel original, HumanoidModel replacement) { // this function does not make use of the generic, so the unchecked cast should be safe @@ -279,6 +294,7 @@ public class ForgeHooksClient { replacement.rightLeg.visible = original.rightLeg.visible; replacement.leftLeg.visible = original.leftLeg.visible; } + */ //This properly moves the domain, if provided, to the front of the string before concatenating public static String fixDomain(String base, String complex) { @@ -315,7 +331,7 @@ public class ForgeHooksClient { private static void drawScreenInternal(Screen screen, GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) { if (!ScreenEvent.Render.Pre.BUS.post(new ScreenEvent.Render.Pre(screen, guiGraphics, mouseX, mouseY, partialTick))) - screen.renderWithTooltip(guiGraphics, mouseX, mouseY, partialTick); + screen.renderWithTooltipAndSubtitles(guiGraphics, mouseX, mouseY, partialTick); ScreenEvent.Render.Post.BUS.post(new ScreenEvent.Render.Post(screen, guiGraphics, mouseX, mouseY, partialTick)); } @@ -343,23 +359,21 @@ public class ForgeHooksClient { } public static void onModifyBakingResult(ModelBakery modelBakery, ModelBakery.BakingResult results) { - ModLoader.get().postEvent(new ModelEvent.ModifyBakingResult(modelBakery, results)); + ModLoader.postEvent(new ModelEvent.ModifyBakingResult(modelBakery, results)); } public static void onModelBake(ModelManager modelManager, ModelBakery modelBakery) { - ModLoader.get().postEvent(new ModelEvent.BakingCompleted(modelManager, modelBakery)); + ModLoader.postEvent(new ModelEvent.BakingCompleted(modelManager, modelBakery)); } public static TextureAtlasSprite[] getFluidSprites(BlockAndTintGetter level, BlockPos pos, FluidState fluidStateIn) { IClientFluidTypeExtensions props = IClientFluidTypeExtensions.of(fluidStateIn); ResourceLocation overlayTexture = props.getOverlayTexture(fluidStateIn, level, pos); - @SuppressWarnings("deprecation") - var BLOCKS = TextureAtlas.LOCATION_BLOCKS; - var atlas = Minecraft.getInstance().getTextureAtlas(BLOCKS); + var atlas = Minecraft.getInstance().getAtlasManager().getAtlasOrThrow(AtlasIds.BLOCKS); return new TextureAtlasSprite[] { - atlas.apply(props.getStillTexture(fluidStateIn, level, pos)), - atlas.apply(props.getFlowingTexture(fluidStateIn, level, pos)), - overlayTexture == null ? null : atlas.apply(overlayTexture), + atlas.getSprite(props.getStillTexture(fluidStateIn, level, pos)), + atlas.getSprite(props.getFlowingTexture(fluidStateIn, level, pos)), + overlayTexture == null ? null : atlas.getSprite(overlayTexture), }; } @@ -413,26 +427,26 @@ public class ForgeHooksClient { MovementInputUpdateEvent.BUS.post(new MovementInputUpdateEvent(player, movementInput)); } - public static boolean onScreenKeyPressed(Screen screen, int keyCode, int scanCode, int modifiers) { - return ForgeEventFactoryClient.onScreenKeyPressedPre(screen, keyCode, scanCode, modifiers) - || screen.keyPressed(keyCode, scanCode, modifiers) - || ForgeEventFactoryClient.onScreenKeyPressedPost(screen, keyCode, scanCode, modifiers); + public static boolean onScreenKeyPressed(Screen screen, KeyEvent info) { + return ForgeEventFactoryClient.onScreenKeyPressedPre(screen, info.key(), info.scancode(), info.modifiers()) + || screen.keyPressed(info) + || ForgeEventFactoryClient.onScreenKeyPressedPost(screen, info.key(), info.scancode(), info.modifiers()); } - public static boolean onScreenKeyReleased(Screen screen, int keyCode, int scanCode, int modifiers) { - return ForgeEventFactoryClient.onScreenKeyReleasedPre(screen, keyCode, scanCode, modifiers) - || screen.keyReleased(keyCode, scanCode, modifiers) - || ForgeEventFactoryClient.onScreenKeyReleasedPost(screen, keyCode, scanCode, modifiers); + public static boolean onScreenKeyReleased(Screen screen, KeyEvent info) { + return ForgeEventFactoryClient.onScreenKeyReleasedPre(screen, info.key(), info.scancode(), info.modifiers()) + || screen.keyReleased(info) + || ForgeEventFactoryClient.onScreenKeyReleasedPost(screen, info.key(), info.scancode(), info.modifiers()); } - public static boolean onScreenCharTyped(Screen screen, char codePoint, int modifiers) { - return ForgeEventFactoryClient.onScreenCharTypedPre(screen, codePoint, modifiers) - || screen.charTyped(codePoint, modifiers) - || ForgeEventFactoryClient.onScreenCharTypedPost(screen, codePoint, modifiers); + public static boolean onScreenCharTyped(Screen screen, CharacterEvent info) { + return ForgeEventFactoryClient.onScreenCharTypedPre(screen, (char)info.codepoint(), info.modifiers()) + || screen.charTyped(info) + || ForgeEventFactoryClient.onScreenCharTypedPost(screen, (char)info.codepoint(), info.modifiers()); } - public static void onKeyInput(int key, int scanCode, int action, int modifiers) { - InputEvent.Key.BUS.post(new InputEvent.Key(key, scanCode, action, modifiers)); + public static void onKeyInput(KeyEvent info, int action) { + InputEvent.Key.BUS.post(new InputEvent.Key(info.key(), info.scancode(), action, info.modifiers())); } public static boolean isNameplateInRenderDistance(Entity entity, double squareDistance) { @@ -449,24 +463,32 @@ public class ForgeHooksClient { return IClientMobEffectExtensions.of(effectInstance).isVisibleInInventory(effectInstance); } + public static Set> getAtlastMetadataSections(ResourceLocation atlasId, Set> vanilla) { + var ret = new HashSet<>(vanilla); + ret.add(ForgeTextureMetadata.TYPE); + + var event = new GatherAtlasMetadataSectionsEvent(ret); + GatherAtlasMetadataSectionsEvent.BUS.post(event); + return Set.of(ret.toArray(new MetadataSectionType[0])); + } + @Nullable - public static SpriteContents loadSpriteContents(ResourceLocation name, Resource resource, FrameSize frameSize, NativeImage image, ResourceMetadata animationMeta) { - try { - ForgeTextureMetadata forgeMeta = ForgeTextureMetadata.forResource(resource); - return forgeMeta.loader() == null ? null : forgeMeta.loader().loadContents(name, resource, frameSize, image, animationMeta, forgeMeta); - } catch (IOException e) { - LOGGER.error("Unable to get Forge metadata for {}, falling back to vanilla loading", name); - e.printStackTrace(); - return null; + public static SpriteContents loadSpriteContents(ResourceLocation name, Resource resource, FrameSize frameSize, NativeImage image, List> metadata) { + for (var meta : metadata) { + var forgeMeta = meta.unwrapToType(ForgeTextureMetadata.TYPE).orElse(null); + if (forgeMeta != null && forgeMeta.loader() != null) + return forgeMeta.loader().loadContents(name, resource, frameSize, image, metadata); } + return null; } @Nullable public static TextureAtlasSprite loadTextureAtlasSprite(ResourceLocation atlasName, SpriteContents contents, int atlasWidth, int atlasHeight, int spriteX, int spriteY, int mipmapLevel) { - if (contents.forgeMeta == null || contents.forgeMeta.loader() == null) + var forgeMeta = contents.getAdditionalMetadata(ForgeTextureMetadata.TYPE).orElse(null); + if (forgeMeta == null || forgeMeta.loader() == null) return null; - return contents.forgeMeta.loader().makeSprite(atlasName, contents, atlasWidth, atlasHeight, spriteX, spriteY, mipmapLevel); + return forgeMeta.loader().makeSprite(atlasName, contents, atlasWidth, atlasHeight, spriteX, spriteY, mipmapLevel); } private static final Map> layerDefinitions = new HashMap<>(); @@ -592,12 +614,12 @@ public class ForgeHooksClient { GameData.revertToFrozen(); } - public static void onRegisterParticleProviders(ParticleEngine particleEngine) { - ModLoader.get().postEvent(new RegisterParticleProvidersEvent(particleEngine)); + public static void onRegisterParticleProviders(ParticleResources particles) { + ModLoader.postEvent(new RegisterParticleProvidersEvent(particles)); } public static void onRegisterKeyMappings(Options options) { - ModLoader.get().postEvent(new RegisterKeyMappingsEvent(options)); + ModLoader.postEvent(new RegisterKeyMappingsEvent(options)); } public static void onRegisterPictureInPictureRenderers(List> renderers, @@ -777,9 +799,9 @@ public class ForgeHooksClient { throw new IllegalStateException("Client hooks initialized more than once"); initializedClientHooks = true; - ModLoader.get().postEvent(new RegisterClientReloadListenersEvent(resourceManager)); - ModLoader.get().postEvent(new EntityRenderersEvent.RegisterLayerDefinitions()); - ModLoader.get().postEvent(new EntityRenderersEvent.RegisterRenderers()); + ModLoader.postEvent(new RegisterClientReloadListenersEvent(resourceManager)); + ModLoader.postEvent(new EntityRenderersEvent.RegisterLayerDefinitions()); + ModLoader.postEvent(new EntityRenderersEvent.RegisterRenderers()); TextureAtlasSpriteLoaderManager.init(); ClientTooltipComponentManager.init(); EntitySpectatorShaderManager.init(); @@ -800,10 +822,10 @@ public class ForgeHooksClient { return true; } - public static boolean onScreenMouseDrag(Screen screen, double mouseX, double mouseY, int mouseButton, double dragX, double dragY) { - return ForgeEventFactoryClient.onScreenMouseDragPre(screen, mouseX, mouseY, mouseButton, dragX, dragY) - || screen.mouseDragged(mouseX, mouseY, mouseButton, dragX, dragY) - || ForgeEventFactoryClient.onScreenMouseDragPost(screen, mouseX, mouseY, mouseButton, dragX, dragY); + public static boolean onScreenMouseDrag(Screen screen, MouseButtonEvent info, double dragX, double dragY) { + return ForgeEventFactoryClient.onScreenMouseDragPre(screen, info.x(), info.y(), info.button(), dragX, dragY) + || screen.mouseDragged(info, dragX, dragY) + || ForgeEventFactoryClient.onScreenMouseDragPost(screen, info.x(), info.y(), info.button(), dragX, dragY); } public static @Nullable UnbakedGeometry deserializeBlockModelGeometry(JsonObject json, JsonDeserializationContext context) { diff --git a/src/main/java/net/minecraftforge/client/ForgeRenderTypes.java b/src/main/java/net/minecraftforge/client/ForgeRenderTypes.java index cd4a85c793..a066863049 100644 --- a/src/main/java/net/minecraftforge/client/ForgeRenderTypes.java +++ b/src/main/java/net/minecraftforge/client/ForgeRenderTypes.java @@ -20,7 +20,6 @@ import com.mojang.blaze3d.textures.TextureFormat; import net.minecraft.Util; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.RenderPipelines; -import net.minecraft.client.renderer.RenderStateShard; import net.minecraft.client.renderer.RenderStateShard.TextureStateShard; import net.minecraft.client.renderer.RenderType; @@ -42,8 +41,7 @@ public enum ForgeRenderTypes { ITEM_LAYERED_TRANSLUCENT(()-> getItemLayeredTranslucent(blockAtlas())), ITEM_UNSORTED_TRANSLUCENT(()-> getUnsortedTranslucent(blockAtlas())), ITEM_UNLIT_TRANSLUCENT(()-> getUnlitTranslucent(blockAtlas())), - ITEM_UNSORTED_UNLIT_TRANSLUCENT(()-> getUnlitTranslucent(blockAtlas(), false)), - TRANSLUCENT_ON_PARTICLES_TARGET(() -> getTranslucentParticlesTarget(blockAtlas())); + ITEM_UNSORTED_UNLIT_TRANSLUCENT(()-> getUnlitTranslucent(blockAtlas(), false)); /** * Controls the texture filtering state for certain {@link RenderType Render Types}. @@ -175,16 +173,6 @@ public enum ForgeRenderTypes { return Internal.TEXT_INTENSITY_SEE_THROUGH.apply(locationIn); } - /** - * @see #enableTextTextureLinearFiltering - * - * @return A variation of {@link RenderType#translucent()} that uses {@link RenderStateShard.OutputStateShard#PARTICLES_TARGET} - */ - public static RenderType getTranslucentParticlesTarget(ResourceLocation locationIn) { - return Internal.TRANSLUCENT_PARTICLES_TARGET.apply(locationIn); - } - - /** * Render type for rendering the early loading screen, not for modder consumption. * @@ -428,22 +416,6 @@ public enum ForgeRenderTypes { ); } - public static Function TRANSLUCENT_PARTICLES_TARGET = Util.memoize(Internal::getTranslucentParticlesTarget); - private static RenderType getTranslucentParticlesTarget(ResourceLocation locationIn) { - return create( - "forge_translucent_particles_target", - TRANSIENT_BUFFER_SIZE, - true, - true, - RenderPipelines.TRANSLUCENT_PARTICLE, - CompositeState.builder() - .setTextureState(new TextureStateShard(locationIn, false)) - .setOutputState(PARTICLES_TARGET) - .setLightmapState(LIGHTMAP) - .createCompositeState(true) - ); - } - private static final RenderPipeline LOADING_PIPELINE = RenderPipeline.builder(RenderPipelines.GUI_TEXTURED_SNIPPET) .withLocation("pipeline/forge/loading_overlay") .withBlend(new BlendFunction(SourceFactor.SRC_ALPHA, DestFactor.ONE)) diff --git a/src/main/java/net/minecraftforge/client/ItemDecoratorHandler.java b/src/main/java/net/minecraftforge/client/ItemDecoratorHandler.java index 1a790516b0..6fac05bdb0 100644 --- a/src/main/java/net/minecraftforge/client/ItemDecoratorHandler.java +++ b/src/main/java/net/minecraftforge/client/ItemDecoratorHandler.java @@ -38,7 +38,7 @@ public final class ItemDecoratorHandler { public static void init() { var decorators = new HashMap>(); var event = new RegisterItemDecorationsEvent(decorators); - ModLoader.get().postEventWrapContainerInModOrder(event); + ModLoader.postEventWrapContainerInModOrder(event); var builder = new ImmutableMap.Builder(); for (var entry : decorators.entrySet()) { Item item = entry.getKey(); diff --git a/src/main/java/net/minecraftforge/client/NamedRenderTypeManager.java b/src/main/java/net/minecraftforge/client/NamedRenderTypeManager.java index bf1b98e59d..dbce387fe3 100644 --- a/src/main/java/net/minecraftforge/client/NamedRenderTypeManager.java +++ b/src/main/java/net/minecraftforge/client/NamedRenderTypeManager.java @@ -36,7 +36,7 @@ public final class NamedRenderTypeManager { var renderTypes = new HashMap(); preRegisterVanillaRenderTypes(renderTypes); var event = new RegisterNamedRenderTypesEvent(renderTypes); - ModLoader.get().postEventWrapContainerInModOrder(event); + ModLoader.postEventWrapContainerInModOrder(event); RENDER_TYPES = ImmutableMap.copyOf(renderTypes); } diff --git a/src/main/java/net/minecraftforge/client/PresetEditorManager.java b/src/main/java/net/minecraftforge/client/PresetEditorManager.java index 4a690bc609..1e3a7f8468 100644 --- a/src/main/java/net/minecraftforge/client/PresetEditorManager.java +++ b/src/main/java/net/minecraftforge/client/PresetEditorManager.java @@ -37,7 +37,7 @@ public final class PresetEditorManager { // Gather mods' entries RegisterPresetEditorsEvent event = new RegisterPresetEditorsEvent(gatheredEditors); - ModLoader.get().postEventWrapContainerInModOrder(event); + ModLoader.postEventWrapContainerInModOrder(event); editors = Map.copyOf(gatheredEditors); } diff --git a/src/main/java/net/minecraftforge/client/event/AddGuiOverlayLayersEvent.java b/src/main/java/net/minecraftforge/client/event/AddGuiOverlayLayersEvent.java index d3192d0d14..4b6fbb3cf4 100644 --- a/src/main/java/net/minecraftforge/client/event/AddGuiOverlayLayersEvent.java +++ b/src/main/java/net/minecraftforge/client/event/AddGuiOverlayLayersEvent.java @@ -18,17 +18,22 @@ import org.jspecify.annotations.NullMarked; * Fired when the {@linkplain ForgeLayeredDraw#VANILLA_ROOT}'s order is resolved during{@link ForgeLayeredDraw#resolveLayers(). * This can be used to add additional or move gui layers and entire layer stacks as needed. * - *

This event is fired on the {@linkplain IModBusEvent mod event bus}, - * only on the {@linkplain net.minecraftforge.fml.LogicalSide logical client}.

+ *

This event is fired only on the {@linkplain net.minecraftforge.fml.LogicalSide logical client}.

* * @param getLayedDraw The provided {@linkplain ForgeLayeredDraw#instance}. By default will be {@linkplain ForgeLayeredDraw#VANILLA_ROOT}. */ @NullMarked -public record AddGuiOverlayLayersEvent(ForgeLayeredDraw getLayeredDraw) implements IModBusEvent, SelfDestructing, RecordEvent { +public record AddGuiOverlayLayersEvent(ForgeLayeredDraw getLayeredDraw) implements SelfDestructing, RecordEvent { + public static final EventBus BUS = EventBus.create(AddGuiOverlayLayersEvent.class); + @ApiStatus.Internal public AddGuiOverlayLayersEvent {} + /** + * @deprecated {@link AddGuiOverlayLayersEvent} is no longer an {@link IModBusEvent}, so use {@link #BUS} directly. + */ + @Deprecated(forRemoval = true, since = "1.21.9") public static EventBus getBus(BusGroup modBusGroup) { - return IModBusEvent.getBus(modBusGroup, AddGuiOverlayLayersEvent.class); + return BUS; } } diff --git a/src/main/java/net/minecraftforge/client/event/ClientPauseChangeEvent.java b/src/main/java/net/minecraftforge/client/event/ClientPauseChangeEvent.java index bad108bf01..88e0bf11b9 100644 --- a/src/main/java/net/minecraftforge/client/event/ClientPauseChangeEvent.java +++ b/src/main/java/net/minecraftforge/client/event/ClientPauseChangeEvent.java @@ -5,71 +5,48 @@ package net.minecraftforge.client.event; -import net.minecraftforge.common.MinecraftForge; - import net.minecraft.client.Minecraft; import net.minecraftforge.eventbus.api.bus.CancellableEventBus; import net.minecraftforge.eventbus.api.bus.EventBus; import net.minecraftforge.eventbus.api.event.InheritableEvent; -import net.minecraftforge.eventbus.api.event.MutableEvent; +import net.minecraftforge.eventbus.api.event.RecordEvent; import net.minecraftforge.eventbus.api.event.characteristic.Cancellable; import net.minecraftforge.fml.LogicalSide; /** * Fired when pause is about to change * - *

These events are fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus}, - * only on the {@linkplain LogicalSide#CLIENT logical client}.

+ *

These events are fired only on the {@linkplain LogicalSide#CLIENT logical client}.

* * @see ClientPauseChangeEvent.Pre * @see ClientPauseChangeEvent.Post */ -public abstract sealed class ClientPauseChangeEvent extends MutableEvent implements InheritableEvent { - public static final EventBus BUS = EventBus.create(ClientPauseChangeEvent.class); +public sealed interface ClientPauseChangeEvent extends InheritableEvent { + EventBus BUS = EventBus.create(ClientPauseChangeEvent.class); - private final boolean pause; - - public ClientPauseChangeEvent(boolean pause) { - this.pause = pause; - } + /** + * {@return whether the game is paused} + */ + boolean isPaused(); /** * Fired when {@linkplain Minecraft#pause pause} is going to change * - *

This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.

+ *

This event is {@linkplain Cancellable cancellable}.

* Cancelling this event will prevent the game change pause state even if the conditions match * - *

This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus}, - * only on the {@linkplain LogicalSide#CLIENT logical client}.

+ *

This event is fired only on the {@linkplain LogicalSide#CLIENT logical client}.

*/ - public static final class Pre extends ClientPauseChangeEvent implements Cancellable { + record Pre(boolean isPaused) implements Cancellable, RecordEvent, ClientPauseChangeEvent { public static final CancellableEventBus
 BUS = CancellableEventBus.create(Pre.class);
-
-        public Pre(boolean pause) {
-            super(pause);
-        }
     }
 
     /**
      * Fired when {@linkplain Minecraft#pause pause} is already changed
      *
-     * 

This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.

- * - *

This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus}, - * only on the {@linkplain LogicalSide#CLIENT logical client}.

+ *

This event is fired only on the {@linkplain LogicalSide#CLIENT logical client}.

*/ - public static final class Post extends ClientPauseChangeEvent { + record Post(boolean isPaused) implements RecordEvent, ClientPauseChangeEvent { public static final EventBus BUS = EventBus.create(Post.class); - - public Post(boolean pause) { - super(pause); - } } - - /** - * {@return game is paused} - */ - public boolean isPaused() { - return pause; - } -} \ No newline at end of file +} diff --git a/src/main/java/net/minecraftforge/client/event/ClientPlayerNetworkEvent.java b/src/main/java/net/minecraftforge/client/event/ClientPlayerNetworkEvent.java index 2b2857d5ad..14d1bb9741 100644 --- a/src/main/java/net/minecraftforge/client/event/ClientPlayerNetworkEvent.java +++ b/src/main/java/net/minecraftforge/client/event/ClientPlayerNetworkEvent.java @@ -11,10 +11,10 @@ import net.minecraft.network.Connection; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.eventbus.api.bus.EventBus; import net.minecraftforge.eventbus.api.event.InheritableEvent; -import net.minecraftforge.eventbus.api.event.MutableEvent; import net.minecraftforge.fml.LogicalSide; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.NullMarked; /** * Fired for different client connectivity events. @@ -27,75 +27,57 @@ import org.jetbrains.annotations.Nullable; * @see LoggingOut * @see Clone **/ -public abstract sealed class ClientPlayerNetworkEvent extends MutableEvent implements InheritableEvent { - public static final EventBus BUS = EventBus.create(ClientPlayerNetworkEvent.class); - - private final MultiPlayerGameMode multiPlayerGameMode; - private final LocalPlayer player; - private final Connection connection; - - @ApiStatus.Internal - protected ClientPlayerNetworkEvent(final MultiPlayerGameMode multiPlayerGameMode, final LocalPlayer player, final Connection connection) { - this.multiPlayerGameMode = multiPlayerGameMode; - this.player = player; - this.connection = connection; - } +public sealed interface ClientPlayerNetworkEvent extends InheritableEvent { + EventBus BUS = EventBus.create(ClientPlayerNetworkEvent.class); /** * {@return the multiplayer game mode controller for the player} */ - public MultiPlayerGameMode getMultiPlayerGameMode() { - return multiPlayerGameMode; - } + MultiPlayerGameMode getMultiPlayerGameMode(); /** * {@return the player instance} */ - public LocalPlayer getPlayer() { - return player; - } + LocalPlayer getPlayer(); /** * {@return the network connection for the player} */ - public Connection getConnection() { - return connection; - } + Connection getConnection(); /** * Fired when the client player logs in to the server. The player should be initialized. * - *

This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.

- * *

This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus}, * only on the {@linkplain LogicalSide#CLIENT logical client}.

*/ - public static final class LoggingIn extends ClientPlayerNetworkEvent { + @NullMarked + record LoggingIn(MultiPlayerGameMode getMultiPlayerGameMode, LocalPlayer getPlayer, Connection getConnection) + implements ClientPlayerNetworkEvent { public static final EventBus BUS = EventBus.create(LoggingIn.class); @ApiStatus.Internal - public LoggingIn(final MultiPlayerGameMode controller, final LocalPlayer player, final Connection networkManager) { - super(controller, player, networkManager); - } + public LoggingIn {} } /** * Fired when the client player logs out. This event may also fire when a new integrated server is being created. * - *

This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.

- * *

This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus}, * only on the {@linkplain LogicalSide#CLIENT logical client}.

*/ @SuppressWarnings("NullableProblems") // Shush IntelliJ, we override non-nullables as nullables in this specific event; see later comment - public static final class LoggingOut extends ClientPlayerNetworkEvent { + record LoggingOut( + @Nullable MultiPlayerGameMode getMultiPlayerGameMode, + @Nullable LocalPlayer getPlayer, + @Nullable Connection getConnection + ) implements ClientPlayerNetworkEvent { public static final EventBus BUS = EventBus.create(LoggingOut.class); @ApiStatus.Internal - public LoggingOut(@Nullable final MultiPlayerGameMode controller, @Nullable final LocalPlayer player, @Nullable final Connection networkManager) { + public LoggingOut { //noinspection ConstantConditions we know these are nullable, but we don't want to annotate the super as nullable since this is the only event with nullables - super(controller, player, networkManager); } /** @@ -106,7 +88,7 @@ public abstract sealed class ClientPlayerNetworkEvent extends MutableEvent imple @Nullable @Override public MultiPlayerGameMode getMultiPlayerGameMode() { - return super.getMultiPlayerGameMode(); + return getMultiPlayerGameMode; } /** @@ -117,7 +99,7 @@ public abstract sealed class ClientPlayerNetworkEvent extends MutableEvent imple @Nullable @Override public LocalPlayer getPlayer() { - return super.getPlayer(); + return getPlayer; } /** @@ -128,42 +110,30 @@ public abstract sealed class ClientPlayerNetworkEvent extends MutableEvent imple @Nullable @Override public Connection getConnection() { - return super.getConnection(); + return getConnection; } } /** * Fired when the client player respawns, creating a new player instance to replace the old player instance. * - *

This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.

- * *

This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus}, * only on the {@linkplain LogicalSide#CLIENT logical client}.

+ * + * @param getOldPlayer the previous player instance + * @param getNewPlayer the newly created player instance */ - public static final class Clone extends ClientPlayerNetworkEvent { + @NullMarked + record Clone( + MultiPlayerGameMode getMultiPlayerGameMode, + LocalPlayer getOldPlayer, + LocalPlayer getNewPlayer, + Connection getConnection + ) implements ClientPlayerNetworkEvent { public static final EventBus BUS = EventBus.create(Clone.class); - private final LocalPlayer oldPlayer; - @ApiStatus.Internal - public Clone(final MultiPlayerGameMode pc, final LocalPlayer oldPlayer, final LocalPlayer newPlayer, final Connection networkManager) { - super(pc, newPlayer, networkManager); - this.oldPlayer = oldPlayer; - } - - /** - * {@return the previous player instance} - */ - public LocalPlayer getOldPlayer() { - return oldPlayer; - } - - /** - * {@return the newly created player instance} - */ - public LocalPlayer getNewPlayer() { - return super.getPlayer(); - } + public Clone {} /** * {@return the newly created player instance} @@ -172,7 +142,7 @@ public abstract sealed class ClientPlayerNetworkEvent extends MutableEvent imple */ @Override public LocalPlayer getPlayer() { - return super.getPlayer(); + return getNewPlayer; } } } diff --git a/src/main/java/net/minecraftforge/client/event/ContainerScreenEvent.java b/src/main/java/net/minecraftforge/client/event/ContainerScreenEvent.java index 32518c2219..8a0fd0fe0d 100644 --- a/src/main/java/net/minecraftforge/client/event/ContainerScreenEvent.java +++ b/src/main/java/net/minecraftforge/client/event/ContainerScreenEvent.java @@ -9,8 +9,7 @@ import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.eventbus.api.bus.EventBus; -import net.minecraftforge.eventbus.api.event.InheritableEvent; -import net.minecraftforge.eventbus.api.event.MutableEvent; +import net.minecraftforge.eventbus.api.event.RecordEvent; import net.minecraftforge.fml.LogicalSide; import org.jetbrains.annotations.ApiStatus; @@ -24,22 +23,11 @@ import org.jetbrains.annotations.ApiStatus; * @see Render.Foreground * @see Render.Background */ -public abstract sealed class ContainerScreenEvent extends MutableEvent implements InheritableEvent { - public static final EventBus BUS = EventBus.create(ContainerScreenEvent.class); - - private final AbstractContainerScreen containerScreen; - - @ApiStatus.Internal - protected ContainerScreenEvent(AbstractContainerScreen containerScreen) { - this.containerScreen = containerScreen; - } - +public sealed interface ContainerScreenEvent { /** * {@return the container screen} */ - public AbstractContainerScreen getContainerScreen() { - return containerScreen; - } + AbstractContainerScreen getContainerScreen(); /** * Fired every time an {@link AbstractContainerScreen} renders. @@ -51,41 +39,21 @@ public abstract sealed class ContainerScreenEvent extends MutableEvent implement * @see Foreground * @see Background */ - public static abstract sealed class Render extends ContainerScreenEvent { - public static final EventBus BUS = EventBus.create(Render.class); - - private final GuiGraphics guiGraphics; - private final int mouseX; - private final int mouseY; - - @ApiStatus.Internal - protected Render(AbstractContainerScreen guiContainer, GuiGraphics guiGraphics, int mouseX, int mouseY) { - super(guiContainer); - this.guiGraphics = guiGraphics; - this.mouseX = mouseX; - this.mouseY = mouseY; - } - + sealed interface Render extends ContainerScreenEvent { /** * {@return the gui graphics used for rendering} */ - public GuiGraphics getGuiGraphics() { - return guiGraphics; - } + GuiGraphics getGuiGraphics(); /** * {@return the X coordinate of the mouse pointer} */ - public int getMouseX() { - return mouseX; - } + int getMouseX(); /** * {@return the Y coordinate of the mouse pointer} */ - public int getMouseY() { - return mouseY; - } + int getMouseY(); /** * Fired after the container screen's foreground layer and elements are drawn, but @@ -99,13 +67,16 @@ public abstract sealed class ContainerScreenEvent extends MutableEvent implement *

This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus}, * only on the {@linkplain LogicalSide#CLIENT logical client}.

*/ - public static final class Foreground extends Render { + record Foreground( + AbstractContainerScreen getContainerScreen, + GuiGraphics getGuiGraphics, + int getMouseX, + int getMouseY + ) implements RecordEvent, Render { public static final EventBus BUS = EventBus.create(Foreground.class); @ApiStatus.Internal - public Foreground(AbstractContainerScreen guiContainer, GuiGraphics guiGraphics, int mouseX, int mouseY) { - super(guiContainer, guiGraphics, mouseX, mouseY); - } + public Foreground {} } /** @@ -117,13 +88,16 @@ public abstract sealed class ContainerScreenEvent extends MutableEvent implement *

This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus}, * only on the {@linkplain LogicalSide#CLIENT logical client}.

*/ - public static final class Background extends Render { + record Background( + AbstractContainerScreen getContainerScreen, + GuiGraphics getGuiGraphics, + int getMouseX, + int getMouseY + ) implements RecordEvent, Render { public static final EventBus BUS = EventBus.create(Background.class); @ApiStatus.Internal - public Background(AbstractContainerScreen guiContainer, GuiGraphics guiGraphics, int mouseX, int mouseY) { - super(guiContainer, guiGraphics, mouseX, mouseY); - } + public Background {} } } } diff --git a/src/main/java/net/minecraftforge/client/event/CustomizeGuiOverlayEvent.java b/src/main/java/net/minecraftforge/client/event/CustomizeGuiOverlayEvent.java index e04d93ecda..6f921864bc 100644 --- a/src/main/java/net/minecraftforge/client/event/CustomizeGuiOverlayEvent.java +++ b/src/main/java/net/minecraftforge/client/event/CustomizeGuiOverlayEvent.java @@ -10,8 +10,9 @@ import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.LerpingBossEvent; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.eventbus.api.bus.CancellableEventBus; -import net.minecraftforge.eventbus.api.event.InheritableEvent; +import net.minecraftforge.eventbus.api.bus.EventBus; import net.minecraftforge.eventbus.api.event.MutableEvent; +import net.minecraftforge.eventbus.api.event.RecordEvent; import net.minecraftforge.eventbus.api.event.characteristic.Cancellable; import net.minecraftforge.fml.LogicalSide; import org.jetbrains.annotations.ApiStatus; @@ -25,44 +26,28 @@ import java.util.List; * @see DebugText * @see Chat */ -public abstract sealed class CustomizeGuiOverlayEvent extends MutableEvent implements Cancellable, InheritableEvent { - public static final CancellableEventBus BUS = CancellableEventBus.create(CustomizeGuiOverlayEvent.class); +public sealed interface CustomizeGuiOverlayEvent { + Window getWindow(); - private final Window window; - private final GuiGraphics guiGraphics; - private final float partialTick; + GuiGraphics getGuiGraphics(); - @ApiStatus.Internal - protected CustomizeGuiOverlayEvent(Window window, GuiGraphics guiGraphics, float partialTick) { - this.window = window; - this.guiGraphics = guiGraphics; - this.partialTick = partialTick; - } - - public Window getWindow() { - return window; - } - - public GuiGraphics getGuiGraphics() { - return guiGraphics; - } - - public float getPartialTick() { - return partialTick; - } + float getPartialTick(); /** * Fired before a boss health bar is rendered to the screen. * - *

This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. + *

This event is {@linkplain Cancellable cancellable}. * Cancelling this event will prevent the given bar from rendering.

* *

This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus}, * only on the {@linkplain LogicalSide#CLIENT logical client}.

*/ - public static final class BossEventProgress extends CustomizeGuiOverlayEvent { + final class BossEventProgress implements Cancellable, CustomizeGuiOverlayEvent, RecordEvent { public static final CancellableEventBus BUS = CancellableEventBus.create(BossEventProgress.class); + private final Window window; + private final GuiGraphics guiGraphics; + private final float partialTick; private final LerpingBossEvent bossEvent; private final int x; private final int y; @@ -70,13 +55,30 @@ public abstract sealed class CustomizeGuiOverlayEvent extends MutableEvent imple @ApiStatus.Internal public BossEventProgress(Window window, GuiGraphics guiGraphics, float partialTick, LerpingBossEvent bossEvent, int x, int y, int increment) { - super(window, guiGraphics, partialTick); + this.window = window; + this.guiGraphics = guiGraphics; + this.partialTick = partialTick; this.bossEvent = bossEvent; this.x = x; this.y = y; this.increment = increment; } + @Override + public Window getWindow() { + return window; + } + + @Override + public GuiGraphics getGuiGraphics() { + return guiGraphics; + } + + @Override + public float getPartialTick() { + return partialTick; + } + /** * @return the boss health bar currently being rendered */ @@ -119,38 +121,23 @@ public abstract sealed class CustomizeGuiOverlayEvent extends MutableEvent imple * Fired before textual information is rendered to the debug screen. * This can be used to add or remove text information. * - *

This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.

- * *

This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus}, * only on the {@linkplain LogicalSide#CLIENT logical client}.

+ * + * @param getText the modifiable list of text to render on the side + * @param getSide the side of the text getting rendered */ - public static final class DebugText extends CustomizeGuiOverlayEvent { - public static final CancellableEventBus BUS = CancellableEventBus.create(DebugText.class); - - private final List text; - - private final Side side; + record DebugText( + Window getWindow, + GuiGraphics getGuiGraphics, + float getPartialTick, + List getText, + Side getSide + ) implements RecordEvent, CustomizeGuiOverlayEvent { + public static final EventBus BUS = EventBus.create(DebugText.class); @ApiStatus.Internal - public DebugText(Window window, GuiGraphics guiGraphics, float partialTick, List text, Side side) { - super(window, guiGraphics, partialTick); - this.text = text; - this.side = side; - } - - /** - * @return the modifiable list of text to render on the side - */ - public List getText() { - return this.text; - } - - /** - * @return the side of the text getting rendered. - */ - public Side getSide() { - return this.side; - } + public DebugText {} public enum Side { Left, @@ -161,24 +148,42 @@ public abstract sealed class CustomizeGuiOverlayEvent extends MutableEvent imple /** * Fired before the chat messages overlay is rendered to the screen. * - *

This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.

- * *

This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus}, * only on the {@linkplain LogicalSide#CLIENT logical client}.

*/ - public static final class Chat extends CustomizeGuiOverlayEvent { - public static final CancellableEventBus BUS = CancellableEventBus.create(Chat.class); + final class Chat extends MutableEvent implements CustomizeGuiOverlayEvent { + public static final EventBus BUS = EventBus.create(Chat.class); + private final Window window; + private final GuiGraphics guiGraphics; + private final float partialTick; private int posX; private int posY; @ApiStatus.Internal public Chat(Window window, GuiGraphics guiGraphics, float partialTick, int posX, int posY) { - super(window, guiGraphics, partialTick); + this.window = window; + this.guiGraphics = guiGraphics; + this.partialTick = partialTick; this.setPosX(posX); this.setPosY(posY); } + @Override + public Window getWindow() { + return window; + } + + @Override + public GuiGraphics getGuiGraphics() { + return guiGraphics; + } + + @Override + public float getPartialTick() { + return partialTick; + } + /** * @return the X position of the chat messages overlay */ diff --git a/src/main/java/net/minecraftforge/client/event/EntityRenderersEvent.java b/src/main/java/net/minecraftforge/client/event/EntityRenderersEvent.java index 2af68dcbb1..d050904912 100644 --- a/src/main/java/net/minecraftforge/client/event/EntityRenderersEvent.java +++ b/src/main/java/net/minecraftforge/client/event/EntityRenderersEvent.java @@ -6,24 +6,28 @@ package net.minecraftforge.client.event; import com.google.common.collect.ImmutableMap; + +import net.minecraft.client.entity.ClientMannequin; import net.minecraft.client.model.SkullModel; import net.minecraft.client.model.SkullModelBase; import net.minecraft.client.model.geom.EntityModelSet; import net.minecraft.client.model.geom.ModelLayerLocation; import net.minecraft.client.model.geom.ModelLayers; import net.minecraft.client.model.geom.builders.LayerDefinition; +import net.minecraft.client.player.AbstractClientPlayer; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; import net.minecraft.client.renderer.blockentity.BlockEntityRenderers; +import net.minecraft.client.renderer.blockentity.state.BlockEntityRenderState; import net.minecraft.client.renderer.entity.EntityRenderer; import net.minecraft.client.renderer.entity.EntityRendererProvider; import net.minecraft.client.renderer.entity.EntityRenderers; -import net.minecraft.client.renderer.entity.player.PlayerRenderer; +import net.minecraft.client.renderer.entity.player.AvatarRenderer; import net.minecraft.client.renderer.entity.state.EntityRenderState; -import net.minecraft.client.resources.PlayerSkin; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.player.Player; +import net.minecraft.world.entity.player.PlayerModelType; import net.minecraft.world.level.block.SkullBlock; import net.minecraft.world.level.block.SkullBlock.Type; import net.minecraft.world.level.block.entity.BlockEntity; @@ -118,7 +122,7 @@ public abstract sealed class EntityRenderersEvent implements IModBusEvent { * @param blockEntityType the block entity type to register a renderer for * @param blockEntityRendererProvider the renderer provider */ - public void registerBlockEntityRenderer(BlockEntityType blockEntityType, BlockEntityRendererProvider blockEntityRendererProvider) { + public void registerBlockEntityRenderer(BlockEntityType blockEntityType, BlockEntityRendererProvider blockEntityRendererProvider) { BlockEntityRenderers.register(blockEntityType, blockEntityRendererProvider); } } @@ -138,41 +142,54 @@ public abstract sealed class EntityRenderersEvent implements IModBusEvent { } private final Map, EntityRenderer> renderers; - private final Map> skinMap; + private final Map> playerRenderers; + private final Map> mannequinRenderers; private final EntityRendererProvider.Context context; @ApiStatus.Internal - public AddLayers(Map, EntityRenderer> renderers, Map> playerRenderers, EntityRendererProvider.Context context) { + public AddLayers(Map, EntityRenderer> renderers, Map> playerRenderers, Map> mannequinRenderers, EntityRendererProvider.Context context) { this.renderers = renderers; - this.skinMap = playerRenderers; + this.playerRenderers = playerRenderers; + this.mannequinRenderers = mannequinRenderers; this.context = context; } /** - * {@return the set of player skin names which have a renderer} + * {@return the set of player model types which have a renderer} *

- * Minecraft provides two default skin names: {@code default} for the + * Minecraft provides two default types: {@code wide} for the * {@linkplain ModelLayers#PLAYER regular player model} and {@code slim} for the * {@linkplain ModelLayers#PLAYER_SLIM slim player model}. */ - public Set getSkins() { - return skinMap.keySet(); + public Set getModelTypes() { + return playerRenderers.keySet(); } /** - * Returns a player skin renderer for the given skin name. + * Returns a renderer for the given model type used for normal players. * - * @param skinName the name of the skin to get the renderer for - * @param the type of the skin renderer, usually {@link PlayerRenderer} - * @return the skin renderer, or {@code null} if no renderer is registered for that skin name - * @see #getSkins() + * @param modelType the type to get the renderer for + * @param the type of the model renderer, usually {@link AvatarRenderer} + * @see #getModelTypes() */ @Nullable @SuppressWarnings("unchecked") - public > R getPlayerSkin(PlayerSkin.Model skinName) { - return (R)skinMap.get(skinName); + public > R getPlayerRenderer(PlayerModelType modelType) { + return (R)playerRenderers.get(modelType); } + /** + * Returns a Mannequin renderer for the given model type. + * + * @param modelType the type to get the renderer for + * @param the type of the model renderer, usually {@link AvatarRenderer} + * @see #getModelTypes() + */ + @Nullable + @SuppressWarnings("unchecked") + public > R getMannequinRenderer(PlayerModelType modelType) { + return (R)mannequinRenderers.get(modelType); + } /** * Returns an entity renderer for the given entity type. * diff --git a/src/main/java/net/minecraftforge/client/event/ForgeEventFactoryClient.java b/src/main/java/net/minecraftforge/client/event/ForgeEventFactoryClient.java index dd0461020a..f38088c8d3 100644 --- a/src/main/java/net/minecraftforge/client/event/ForgeEventFactoryClient.java +++ b/src/main/java/net/minecraftforge/client/event/ForgeEventFactoryClient.java @@ -5,65 +5,66 @@ package net.minecraftforge.client.event; -import java.io.File; import java.util.List; import java.util.Map; import java.util.function.Function; -import net.minecraftforge.client.FramePassManager; import net.minecraftforge.client.gui.overlay.ForgeLayeredDraw; -import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.util.Result; import net.minecraftforge.event.TickEvent; import net.minecraftforge.fml.ModLoader; -import net.minecraftforge.fml.event.IModBusEvent; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import com.google.common.collect.ImmutableMap; import com.mojang.blaze3d.audio.Channel; -import com.mojang.blaze3d.platform.NativeImage; import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.Camera; import net.minecraft.client.ClientRecipeBook; import net.minecraft.client.DeltaTracker; import net.minecraft.client.KeyMapping; import net.minecraft.client.MouseHandler; +import net.minecraft.client.entity.ClientAvatarEntity; +import net.minecraft.client.entity.ClientMannequin; import net.minecraft.client.gui.Font; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.toasts.Toast; import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent; +import net.minecraft.client.input.MouseButtonEvent; import net.minecraft.client.model.EntityModel; import net.minecraft.client.model.SkullModelBase; import net.minecraft.client.model.geom.EntityModelSet; import net.minecraft.client.multiplayer.MultiPlayerGameMode; +import net.minecraft.client.player.AbstractClientPlayer; import net.minecraft.client.player.LocalPlayer; import net.minecraft.client.renderer.GameRenderer; -import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.renderer.SubmitNodeCollector; import net.minecraft.client.renderer.entity.EntityRenderer; import net.minecraft.client.renderer.entity.EntityRendererProvider.Context; import net.minecraft.client.renderer.entity.ItemFrameRenderer; import net.minecraft.client.renderer.entity.LivingEntityRenderer; -import net.minecraft.client.renderer.entity.player.PlayerRenderer; +import net.minecraft.client.renderer.entity.player.AvatarRenderer; +import net.minecraft.client.renderer.entity.state.AvatarRenderState; import net.minecraft.client.renderer.entity.state.EntityRenderState; import net.minecraft.client.renderer.entity.state.ItemFrameRenderState; import net.minecraft.client.renderer.entity.state.LivingEntityRenderState; -import net.minecraft.client.renderer.entity.state.PlayerRenderState; import net.minecraft.client.renderer.special.SpecialModelRenderer; -import net.minecraft.client.resources.PlayerSkin.Model; +import net.minecraft.client.renderer.state.CameraRenderState; import net.minecraft.client.resources.sounds.SoundInstance; import net.minecraft.client.sounds.SoundEngine; import net.minecraft.network.Connection; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.InteractionHand; +import net.minecraft.world.entity.Avatar; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.HumanoidArm; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.player.Player; +import net.minecraft.world.entity.player.PlayerModelType; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.SkullBlock.Type; @@ -72,37 +73,28 @@ import net.minecraftforge.client.event.sound.PlayStreamingSourceEvent; @ApiStatus.Internal public final class ForgeEventFactoryClient { - private static final ModLoader ML = ModLoader.get(); - private ForgeEventFactoryClient() {} - /** - * Post an event to the {@link ModLoader#get()} event bus - */ - private static T fireModBus(T e) { - return ML.postEventWithReturn(e); - } - - public static void onGatherLayers(Map, EntityRenderer> renderers, Map> playerRenderers, Context context) { + public static void onGatherLayers(Map, EntityRenderer> renderers, Map> playerRenderers, Map> mannequinRenderers, Context context) { // TODO: Why is this a ModLoader event... - fireModBus(new EntityRenderersEvent.AddLayers(renderers, playerRenderers, context)); + ModLoader.postEvent(new EntityRenderersEvent.AddLayers(renderers, playerRenderers, mannequinRenderers, context)); } - public static boolean onScreenMouseReleased(Screen screen, double mouseX, double mouseY, int button) { - if (ScreenEvent.MouseButtonReleased.Pre.BUS.post(new ScreenEvent.MouseButtonReleased.Pre(screen, mouseX, mouseY, button))) + public static boolean onScreenMouseReleased(Screen screen, double mouseX, double mouseY, MouseButtonEvent event) { + if (ScreenEvent.MouseButtonReleased.Pre.BUS.post(new ScreenEvent.MouseButtonReleased.Pre(screen, mouseX, mouseY, event.button()))) return true; - var ret = screen.mouseReleased(mouseX, mouseY, button); - var result = ScreenEvent.MouseButtonReleased.Post.BUS.fire(new ScreenEvent.MouseButtonReleased.Post(screen, mouseX, mouseY, button, ret)).getResult(); + var ret = screen.mouseReleased(event); + var result = ScreenEvent.MouseButtonReleased.Post.BUS.fire(new ScreenEvent.MouseButtonReleased.Post(screen, mouseX, mouseY, event.button(), ret)).getResult(); return result == Result.DEFAULT ? ret : result == Result.ALLOW; } - public static boolean onScreenMouseClicked(Screen screen, double mouseX, double mouseY, int button) { - var ret = ScreenEvent.MouseButtonPressed.Pre.BUS.post(new ScreenEvent.MouseButtonPressed.Pre(screen, mouseX, mouseY, button)); + public static boolean onScreenMouseClicked(Screen screen, double mouseX, double mouseY, MouseButtonEvent info, boolean repeate) { + var ret = ScreenEvent.MouseButtonPressed.Pre.BUS.post(new ScreenEvent.MouseButtonPressed.Pre(screen, mouseX, mouseY, info.button())); if (!ret) - ret = screen.mouseClicked(mouseX, mouseY, button); + ret = screen.mouseClicked(info, repeate); - var result = ScreenEvent.MouseButtonPressed.Post.BUS.fire(new ScreenEvent.MouseButtonPressed.Post(screen, mouseX, mouseY, button, ret)).getResult(); + var result = ScreenEvent.MouseButtonPressed.Post.BUS.fire(new ScreenEvent.MouseButtonPressed.Post(screen, mouseX, mouseY, info.button(), ret)).getResult(); return result == Result.DEFAULT ? ret : result == Result.ALLOW; } @@ -202,7 +194,7 @@ public final class ForgeEventFactoryClient { ClientPlayerNetworkEvent.Clone.BUS.post(new ClientPlayerNetworkEvent.Clone(pc, oldPlayer, newPlayer, networkManager)); } - public static ViewportEvent.ComputeFov fireComputeFov(GameRenderer renderer, Camera camera, double partialTick, float fov, boolean usedConfiguredFov) { + public static ViewportEvent.ComputeFov fireComputeFov(GameRenderer renderer, Camera camera, float partialTick, float fov, boolean usedConfiguredFov) { return ViewportEvent.ComputeFov.BUS.fire(new ViewportEvent.ComputeFov(renderer, camera, partialTick, fov, usedConfiguredFov)); } @@ -210,32 +202,32 @@ public final class ForgeEventFactoryClient { return ViewportEvent.ComputeCameraAngles.BUS.fire(new ViewportEvent.ComputeCameraAngles(renderer, camera, partial, camera.getYRot(), camera.getXRot(), 0)); } - public static > boolean onRenderLivingPre(S state, LivingEntityRenderer renderer, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight) { - return RenderLivingEvent.Pre.BUS.post(new RenderLivingEvent.Pre(state, renderer, poseStack, multiBufferSource, packedLight)); + public static > boolean onRenderLivingPre(S state, LivingEntityRenderer renderer, PoseStack poseStack, SubmitNodeCollector nodeCollector, CameraRenderState cameraState) { + return RenderLivingEvent.Pre.BUS.post(new RenderLivingEvent.Pre(state, renderer, poseStack, nodeCollector, cameraState)); } - public static > boolean onRenderLivingPost(S state, LivingEntityRenderer renderer, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight) { - return RenderLivingEvent.Post.BUS.post(new RenderLivingEvent.Post(state, renderer, poseStack, multiBufferSource, packedLight)); + public static > boolean onRenderLivingPost(S state, LivingEntityRenderer renderer, PoseStack poseStack, SubmitNodeCollector nodeCollector, CameraRenderState cameraState) { + return RenderLivingEvent.Post.BUS.post(new RenderLivingEvent.Post(state, renderer, poseStack, nodeCollector, cameraState)); } - public static boolean onRenderPlayerPre(PlayerRenderState player, PlayerRenderer renderer, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight) { - return RenderPlayerEvent.Pre.BUS.post(new RenderPlayerEvent.Pre(player, renderer, poseStack, multiBufferSource, packedLight)); + public static boolean onRenderAvatarPre(AvatarRenderState player, AvatarRenderer renderer, PoseStack poseStack, SubmitNodeCollector nodeCollector, CameraRenderState camera) { + return RenderAvatarEvent.Pre.BUS.post(new RenderAvatarEvent.Pre(player, renderer, poseStack, nodeCollector, camera)); } - public static boolean onRenderPlayerPost(PlayerRenderState player, PlayerRenderer renderer, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight) { - return RenderPlayerEvent.Post.BUS.post(new RenderPlayerEvent.Post(player, renderer, poseStack, multiBufferSource, packedLight)); + public static boolean onRenderAvatarPost(AvatarRenderState player, AvatarRenderer renderer, PoseStack poseStack, SubmitNodeCollector nodeCollector, CameraRenderState camera) { + return RenderAvatarEvent.Post.BUS.post(new RenderAvatarEvent.Post(player, renderer, poseStack, nodeCollector, camera)); } - public static boolean onRenderArm(PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight, HumanoidArm arm) { - return RenderArmEvent.BUS.post(new RenderArmEvent(poseStack, multiBufferSource, packedLight, arm)); + public static boolean onRenderArm(PoseStack poseStack, SubmitNodeCollector nodeCollector, int packedLight, HumanoidArm arm) { + return RenderArmEvent.BUS.post(new RenderArmEvent(poseStack, nodeCollector, packedLight, arm)); } - public static boolean onRenderItemInFrame(ItemFrameRenderState state, ItemFrameRenderer renderItemFrame, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight) { - return RenderItemInFrameEvent.BUS.post(new RenderItemInFrameEvent(state, renderItemFrame, poseStack, multiBufferSource, packedLight)); + public static boolean onRenderItemInFrame(ItemFrameRenderState state, ItemFrameRenderer renderItemFrame, PoseStack poseStack, SubmitNodeCollector nodeCollector, int packedLight) { + return RenderItemInFrameEvent.BUS.post(new RenderItemInFrameEvent(state, renderItemFrame, poseStack, nodeCollector, packedLight)); } - public static RenderNameTagEvent fireRenderNameTagEvent(EntityRenderState state, Component content, EntityRenderer entityRenderer, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight) { - return RenderNameTagEvent.BUS.fire(new RenderNameTagEvent(state, content, entityRenderer, poseStack, multiBufferSource, packedLight)); + public static RenderNameTagEvent fireRenderNameTagEvent(EntityRenderState state, Component content, EntityRenderer entityRenderer, PoseStack poseStack, SubmitNodeCollector nodeCollector, CameraRenderState cameraState) { + return RenderNameTagEvent.BUS.fire(new RenderNameTagEvent(state, content, entityRenderer, poseStack, nodeCollector, cameraState)); } public static void onRenderScreenBackground(Screen screen, GuiGraphics guiGraphics) { @@ -277,13 +269,13 @@ public final class ForgeEventFactoryClient { public static Map> onCreateSkullModels() { var builder = ImmutableMap.>builder(); - fireModBus(new EntityRenderersEvent.CreateSkullModels(builder)); + ModLoader.postEvent(new EntityRenderersEvent.CreateSkullModels(builder)); return builder.build(); } public static ModelEvent.RegisterModelStateDefinitions onRegisterModeStateDefinitions() { // This is on the mod bus because it happens during the initial texture reload, which is while the Forge bus is shut down. - return fireModBus(new ModelEvent.RegisterModelStateDefinitions()); + return ModLoader.postEventWithReturn(new ModelEvent.RegisterModelStateDefinitions()); } public static void onInitLevelRenderer() { @@ -291,6 +283,6 @@ public final class ForgeEventFactoryClient { } public static void onComputeLayerOrder(ForgeLayeredDraw layeredDraw) { - fireModBus(new AddGuiOverlayLayersEvent(layeredDraw)); + AddGuiOverlayLayersEvent.BUS.post(new AddGuiOverlayLayersEvent(layeredDraw)); } } diff --git a/src/main/java/net/minecraftforge/client/event/GatherAtlasMetadataSectionsEvent.java b/src/main/java/net/minecraftforge/client/event/GatherAtlasMetadataSectionsEvent.java new file mode 100644 index 0000000000..03bba3ef7e --- /dev/null +++ b/src/main/java/net/minecraftforge/client/event/GatherAtlasMetadataSectionsEvent.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) Forge Development LLC and contributors + * SPDX-License-Identifier: LGPL-2.1-only + */ + +package net.minecraftforge.client.event; + +import net.minecraft.server.packs.metadata.MetadataSectionType; +import net.minecraftforge.eventbus.api.bus.EventBus; +import net.minecraftforge.eventbus.api.event.MutableEvent; +import java.util.Set; + +/** + * Fired when an Atlas is being loaded. + * This allows you to add custom metadata sections that will be loaded from the sprite's .mcmeta file. + */ +public final class GatherAtlasMetadataSectionsEvent extends MutableEvent { + public static final EventBus BUS = EventBus.create(GatherAtlasMetadataSectionsEvent.class); + + private final Set> types; + + public GatherAtlasMetadataSectionsEvent(Set> types) { + this.types = types; + } + + public void addType(MetadataSectionType definition) { + this.types.add(definition); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/client/event/InputEvent.java b/src/main/java/net/minecraftforge/client/event/InputEvent.java index d1200dad0a..c40680dfd1 100644 --- a/src/main/java/net/minecraftforge/client/event/InputEvent.java +++ b/src/main/java/net/minecraftforge/client/event/InputEvent.java @@ -10,8 +10,8 @@ import net.minecraft.client.KeyMapping; import net.minecraft.world.InteractionHand; import net.minecraftforge.eventbus.api.bus.CancellableEventBus; import net.minecraftforge.eventbus.api.bus.EventBus; -import net.minecraftforge.eventbus.api.event.InheritableEvent; import net.minecraftforge.eventbus.api.event.MutableEvent; +import net.minecraftforge.eventbus.api.event.RecordEvent; import net.minecraftforge.eventbus.api.event.characteristic.Cancellable; import net.minecraftforge.fml.LogicalSide; import org.jetbrains.annotations.ApiStatus; @@ -26,12 +26,7 @@ import org.lwjgl.glfw.GLFW; * @see Key * @see InteractionKeyMappingTriggered */ -public abstract sealed class InputEvent extends MutableEvent implements InheritableEvent { - public static final EventBus BUS = EventBus.create(InputEvent.class); - - @ApiStatus.Internal - protected InputEvent() {} - +public sealed interface InputEvent { /** * Fired when a mouse button is pressed/released. Sub-events get fired {@link Pre before} and {@link Post after} this happens. * @@ -41,29 +36,14 @@ public abstract sealed class InputEvent extends MutableEvent implements Inherita * @see Pre * @see Post */ - public static abstract sealed class MouseButton extends InputEvent { - public static final EventBus BUS = EventBus.create(MouseButton.class); - - private final int button; - private final int action; - private final int modifiers; - - @ApiStatus.Internal - protected MouseButton(int button, int action, int modifiers) { - this.button = button; - this.action = action; - this.modifiers = modifiers; - } - + sealed interface MouseButton extends InputEvent { /** * {@return the mouse button's input code} * * @see GLFW mouse constants starting with 'GLFW_MOUSE_BUTTON_' * @see the online GLFW documentation */ - public int getButton() { - return this.button; - } + int getButton(); /** * {@return the mouse button's action} @@ -71,9 +51,7 @@ public abstract sealed class InputEvent extends MutableEvent implements Inherita * @see InputConstants#PRESS * @see InputConstants#RELEASE */ - public int getAction() { - return this.action; - } + int getAction(); /** * {@return a bit field representing the active modifier keys} @@ -86,9 +64,7 @@ public abstract sealed class InputEvent extends MutableEvent implements Inherita * @see GLFW#GLFW_KEY_NUM_LOCK NUM LOCK modifier key bit * @see the online GLFW documentation */ - public int getModifiers() { - return this.modifiers; - } + int getModifiers(); /** * Fired when a mouse button is pressed/released, before being processed by vanilla. @@ -99,13 +75,11 @@ public abstract sealed class InputEvent extends MutableEvent implements Inherita * * @see the online GLFW documentation */ - public static final class Pre extends MouseButton implements Cancellable { + record Pre(int getButton, int getAction, int getModifiers) implements Cancellable, MouseButton, RecordEvent { public static final CancellableEventBus

 BUS = CancellableEventBus.create(Pre.class);
 
             @ApiStatus.Internal
-            public Pre(int button, int action, int modifiers) {
-                super(button, action, modifiers);
-            }
+            public Pre {}
         }
 
         /**
@@ -115,13 +89,11 @@ public abstract sealed class InputEvent extends MutableEvent implements Inherita
          *
          * @see the online GLFW documentation
          */
-        public static final class Post extends MouseButton {
+        record Post(int getButton, int getAction, int getModifiers) implements MouseButton, RecordEvent {
             public static final EventBus BUS = EventBus.create(Post.class);
 
             @ApiStatus.Internal
-            public Post(int button, int action, int modifiers) {
-                super(button, action, modifiers);
-            }
+            public Post {}
         }
     }
 
@@ -134,77 +106,28 @@ public abstract sealed class InputEvent extends MutableEvent implements Inherita
      * 

This event is fired only on the {@linkplain LogicalSide#CLIENT logical client}.

* * @see the online GLFW documentation + * + * @param getDeltaX the amount of change / delta of the mouse scroll in the vertical direction + * @param getDeltaY the amount of change / delta of the mouse scroll in the horizontal direction + * @param isLeftDown {@code true} if the left mouse button is pressed + * @param isMiddleDown {@code true} if the middle mouse button is pressed + * @param isRightDown {@code true} if the right mouse button is pressed + * @param getMouseX the X position of the mouse cursor + * @param getMouseY the Y position of the mouse cursor */ - public static final class MouseScrollingEvent extends InputEvent implements Cancellable { + record MouseScrollingEvent( + double getDeltaX, + double getDeltaY, + boolean isLeftDown, + boolean isMiddleDown, + boolean isRightDown, + double getMouseX, + double getMouseY + ) implements Cancellable, InputEvent, RecordEvent { public static final CancellableEventBus BUS = CancellableEventBus.create(MouseScrollingEvent.class); - private final double deltaX; - private final double deltaY; - private final double mouseX; - private final double mouseY; - private final boolean leftDown; - private final boolean middleDown; - private final boolean rightDown; - @ApiStatus.Internal - public MouseScrollingEvent(double deltaX, double deltaY, boolean leftDown, boolean middleDown, boolean rightDown, double mouseX, double mouseY) { - this.deltaX = deltaX; - this.deltaY = deltaY; - this.leftDown = leftDown; - this.middleDown = middleDown; - this.rightDown = rightDown; - this.mouseX = mouseX; - this.mouseY = mouseY; - } - - /** - * {@return the amount of change / delta of the mouse scroll in the vertical direction} - */ - public double getDeltaX() { - return this.deltaX; - } - - /** - * {@return the amount of change / delta of the mouse scroll in the horizontal direction} - */ - public double getDeltaY() { - return this.deltaY; - } - - /** - * {@return {@code true} if the left mouse button is pressed} - */ - public boolean isLeftDown() { - return this.leftDown; - } - - /** - * {@return {@code true} if the right mouse button is pressed} - */ - public boolean isRightDown() { - return this.rightDown; - } - - /** - * {@return {@code true} if the middle mouse button is pressed} - */ - public boolean isMiddleDown() { - return this.middleDown; - } - - /** - * {@return the X position of the mouse cursor} - */ - public double getMouseX() { - return this.mouseX; - } - - /** - * {@return the Y position of the mouse cursor} - */ - public double getMouseY() { - return this.mouseY; - } + public MouseScrollingEvent {} } /** @@ -212,21 +135,11 @@ public abstract sealed class InputEvent extends MutableEvent implements Inherita * *

This event is fired only on the {@linkplain LogicalSide#CLIENT logical client}.

*/ - public static final class Key extends InputEvent { + record Key(int getKey, int getScanCode, int getAction, int getModifiers) implements RecordEvent, InputEvent { public static final EventBus BUS = EventBus.create(Key.class); - private final int key; - private final int scanCode; - private final int action; - private final int modifiers; - @ApiStatus.Internal - public Key(int key, int scanCode, int action, int modifiers) { - this.key = key; - this.scanCode = scanCode; - this.action = action; - this.modifiers = modifiers; - } + public Key {} /** * {@return the {@code GLFW} (platform-agnostic) key code} @@ -236,7 +149,7 @@ public abstract sealed class InputEvent extends MutableEvent implements Inherita * @see the online GLFW documentation */ public int getKey() { - return this.key; + return getKey; } /** @@ -249,7 +162,7 @@ public abstract sealed class InputEvent extends MutableEvent implements Inherita * @see InputConstants#getKey(int, int) */ public int getScanCode() { - return this.scanCode; + return getScanCode; } /** @@ -260,7 +173,7 @@ public abstract sealed class InputEvent extends MutableEvent implements Inherita * @see InputConstants#REPEAT */ public int getAction() { - return this.action; + return getAction; } /** @@ -275,7 +188,7 @@ public abstract sealed class InputEvent extends MutableEvent implements Inherita * @see the online GLFW documentation */ public int getModifiers() { - return this.modifiers; + return getModifiers; } } @@ -295,7 +208,7 @@ public abstract sealed class InputEvent extends MutableEvent implements Inherita *

This event is fired only on the {@linkplain LogicalSide#CLIENT logical client}.

*/ // TODO: Change the 'button' to sub events. - Lex 0422202 - public static final class InteractionKeyMappingTriggered extends InputEvent implements Cancellable { + final class InteractionKeyMappingTriggered extends MutableEvent implements Cancellable, InputEvent { public static final CancellableEventBus BUS = CancellableEventBus.create(InteractionKeyMappingTriggered.class); private final int button; diff --git a/src/main/java/net/minecraftforge/client/event/ModelEvent.java b/src/main/java/net/minecraftforge/client/event/ModelEvent.java index c4e4f75995..d9d8cc0ae4 100644 --- a/src/main/java/net/minecraftforge/client/event/ModelEvent.java +++ b/src/main/java/net/minecraftforge/client/event/ModelEvent.java @@ -18,7 +18,6 @@ import net.minecraftforge.eventbus.api.bus.EventBus; import net.minecraftforge.fml.LogicalSide; import net.minecraftforge.fml.ModLoadingContext; import net.minecraftforge.fml.event.IModBusEvent; -import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import org.jetbrains.annotations.ApiStatus; import java.util.Collections; @@ -28,10 +27,7 @@ import java.util.Map; /** * Houses events related to models. */ -public abstract sealed class ModelEvent { - @ApiStatus.Internal - protected ModelEvent() {} - +public sealed interface ModelEvent { /** * Fired while the {@link ModelManager} is reloading models, after the model registry is set up, but before it's * passed to the {@link net.minecraft.client.renderer.block.BlockModelShaper} for caching. @@ -43,38 +39,19 @@ public abstract sealed class ModelEvent { * must therefore not be accessed in this event. *

* - *

This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.

+ *

This event is fired only on the {@linkplain LogicalSide#CLIENT logical client}.

* - *

This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus}, - * only on the {@linkplain LogicalSide#CLIENT logical client}.

+ * @param getModelBakery the model loader + * @param getResults the modifiable registry map of models and their model names */ - public static final class ModifyBakingResult extends ModelEvent implements IModBusEvent { + record ModifyBakingResult(ModelBakery getModelBakery, ModelBakery.BakingResult getResults) + implements IModBusEvent, ModelEvent { public static EventBus getBus(BusGroup modBusGroup) { return IModBusEvent.getBus(modBusGroup, ModifyBakingResult.class); } - private final ModelBakery modelBakery; - private final ModelBakery.BakingResult results; - @ApiStatus.Internal - public ModifyBakingResult(ModelBakery modelBakery, ModelBakery.BakingResult results) { - this.modelBakery = modelBakery; - this.results = results; - } - - /** - * @return the modifiable registry map of models and their model names - */ - public ModelBakery.BakingResult getResults() { - return results; - } - - /** - * @return the model loader - */ - public ModelBakery getModelBakery() { - return modelBakery; - } + public ModifyBakingResult {} } /** @@ -83,38 +60,19 @@ public abstract sealed class ModelEvent { * The model registry given by this event is unmodifiable. To modify the model registry, use * {@link ModelEvent.ModifyBakingResult} instead. * - *

This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.

+ *

This event is fired only on the {@linkplain LogicalSide#CLIENT logical client}.

* - *

This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus}, - * only on the {@linkplain LogicalSide#CLIENT logical client}.

+ * @param getModelManager the model manager + * @param getModelBakery the model loader */ - public static final class BakingCompleted extends ModelEvent implements IModBusEvent { + record BakingCompleted(ModelManager getModelManager, ModelBakery getModelBakery) + implements IModBusEvent, ModelEvent { public static EventBus getBus(BusGroup modBusGroup) { return IModBusEvent.getBus(modBusGroup, BakingCompleted.class); } - private final ModelManager modelManager; - private final ModelBakery modelBakery; - @ApiStatus.Internal - public BakingCompleted(ModelManager modelManager, ModelBakery modelBakery) { - this.modelManager = modelManager; - this.modelBakery = modelBakery; - } - - /** - * @return the model manager - */ - public ModelManager getModelManager() { - return modelManager; - } - - /** - * @return the model loader - */ - public ModelBakery getModelBakery() { - return modelBakery; - } + public BakingCompleted {} } /** @@ -123,10 +81,9 @@ public abstract sealed class ModelEvent { * This is designed to allow for extra models to be loaded in connection with a blockstates json file. This is not intended to allow * overriding or modification of StateDefinitions from registered Blocks * - *

This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus}, - * only on the {@linkplain LogicalSide#CLIENT logical client}.

+ *

This event is fired only on the {@linkplain LogicalSide#CLIENT logical client}.

*/ - public static final class RegisterModelStateDefinitions extends ModelEvent implements IModBusEvent { + final class RegisterModelStateDefinitions implements IModBusEvent, ModelEvent { public static EventBus getBus(BusGroup modBusGroup) { return IModBusEvent.getBus(modBusGroup, RegisterModelStateDefinitions.class); } @@ -155,12 +112,9 @@ public abstract sealed class ModelEvent { /** * Allows users to register their own {@link IGeometryLoader geometry loaders} for use in block/item models. * - *

This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.

- * - *

This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus}, - * only on the {@linkplain LogicalSide#CLIENT logical client}.

+ *

This event is fired only on the {@linkplain LogicalSide#CLIENT logical client}.

*/ - public static final class RegisterGeometryLoaders extends ModelEvent implements IModBusEvent { + final class RegisterGeometryLoaders implements IModBusEvent, ModelEvent { public static EventBus getBus(BusGroup modBusGroup) { return IModBusEvent.getBus(modBusGroup, RegisterGeometryLoaders.class); } diff --git a/src/main/java/net/minecraftforge/client/event/MovementInputUpdateEvent.java b/src/main/java/net/minecraftforge/client/event/MovementInputUpdateEvent.java index d8e9efb129..f77fb54d63 100644 --- a/src/main/java/net/minecraftforge/client/event/MovementInputUpdateEvent.java +++ b/src/main/java/net/minecraftforge/client/event/MovementInputUpdateEvent.java @@ -7,35 +7,21 @@ package net.minecraftforge.client.event; import net.minecraft.client.player.ClientInput; import net.minecraft.world.entity.player.Player; -import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.player.PlayerEvent; import net.minecraftforge.eventbus.api.bus.EventBus; +import net.minecraftforge.eventbus.api.event.RecordEvent; import net.minecraftforge.fml.LogicalSide; import org.jetbrains.annotations.ApiStatus; /** - *

Fired after the player's movement inputs are updated.

+ * Fired after the player's movement inputs are updated. + *

This event is fired only on the {@linkplain LogicalSide#CLIENT logical client}.

* - *

This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.

- * - *

This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus}, - * only on the {@linkplain LogicalSide#CLIENT logical client}.

+ * @param getInput the player's movement inputs */ -public final class MovementInputUpdateEvent extends PlayerEvent { +public record MovementInputUpdateEvent(Player getEntity, ClientInput getInput) implements RecordEvent, PlayerEvent { public static final EventBus BUS = EventBus.create(MovementInputUpdateEvent.class); - private final ClientInput input; - @ApiStatus.Internal - public MovementInputUpdateEvent(Player player, ClientInput input) { - super(player); - this.input = input; - } - - /** - * {@return the player's movement inputs} - */ - public ClientInput getInput() { - return input; - } + public MovementInputUpdateEvent {} } diff --git a/src/main/java/net/minecraftforge/client/event/RegisterColorHandlersEvent.java b/src/main/java/net/minecraftforge/client/event/RegisterColorHandlersEvent.java index b8667bdade..c357d5d72e 100644 --- a/src/main/java/net/minecraftforge/client/event/RegisterColorHandlersEvent.java +++ b/src/main/java/net/minecraftforge/client/event/RegisterColorHandlersEvent.java @@ -5,7 +5,6 @@ package net.minecraftforge.client.event; -import com.google.common.collect.ImmutableList; import net.minecraft.client.color.block.BlockColor; import net.minecraft.client.color.block.BlockColors; import net.minecraft.core.BlockPos; @@ -31,10 +30,7 @@ import java.util.ArrayList; * @see RegisterColorHandlersEvent.Block * @see RegisterColorHandlersEvent.ColorResolvers */ -public abstract sealed class RegisterColorHandlersEvent implements IModBusEvent { - @ApiStatus.Internal - protected RegisterColorHandlersEvent() {} - +public sealed interface RegisterColorHandlersEvent extends IModBusEvent { /** * Fired for registering block color handlers. * @@ -43,17 +39,13 @@ public abstract sealed class RegisterColorHandlersEvent implements IModBusEvent *

This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus}, * only on the {@linkplain LogicalSide#CLIENT logical client}.

*/ - public static final class Block extends RegisterColorHandlersEvent { + record Block(BlockColors getBlockColors) implements RegisterColorHandlersEvent { public static EventBus getBus(BusGroup modBusGroup) { return IModBusEvent.getBus(modBusGroup, Block.class); } - private final BlockColors blockColors; - @ApiStatus.Internal - public Block(BlockColors blockColors) { - this.blockColors = blockColors; - } + public Block {} /** * {@return the block colors registry} @@ -61,7 +53,7 @@ public abstract sealed class RegisterColorHandlersEvent implements IModBusEvent * @see BlockColors#register(BlockColor, net.minecraft.world.level.block.Block...) */ public BlockColors getBlockColors() { - return blockColors; + return getBlockColors; } /** @@ -72,7 +64,7 @@ public abstract sealed class RegisterColorHandlersEvent implements IModBusEvent */ @SuppressWarnings("deprecation") public void register(BlockColor blockColor, net.minecraft.world.level.block.Block... blocks) { - blockColors.register(blockColor, blocks); + getBlockColors.register(blockColor, blocks); } } @@ -81,7 +73,7 @@ public abstract sealed class RegisterColorHandlersEvent implements IModBusEvent * {@link net.minecraft.world.level.BlockAndTintGetter#getBlockTint(BlockPos, ColorResolver)}. */ @NullMarked - public static final class ColorResolvers extends RegisterColorHandlersEvent implements SelfDestructing { + final class ColorResolvers implements RegisterColorHandlersEvent, SelfDestructing { public static EventBus getBus(BusGroup modBusGroup) { return IModBusEvent.getBus(modBusGroup, ColorResolvers.class); } diff --git a/src/main/java/net/minecraftforge/client/event/RegisterParticleProvidersEvent.java b/src/main/java/net/minecraftforge/client/event/RegisterParticleProvidersEvent.java index 99d095c5bf..85120ac381 100644 --- a/src/main/java/net/minecraftforge/client/event/RegisterParticleProvidersEvent.java +++ b/src/main/java/net/minecraftforge/client/event/RegisterParticleProvidersEvent.java @@ -5,9 +5,8 @@ package net.minecraftforge.client.event; -import net.minecraft.client.particle.ParticleEngine; import net.minecraft.client.particle.ParticleProvider; -import net.minecraft.client.particle.TextureSheetParticle; +import net.minecraft.client.particle.ParticleResources; import net.minecraft.core.particles.ParticleOptions; import net.minecraft.core.particles.ParticleType; import net.minecraftforge.eventbus.api.bus.BusGroup; @@ -34,11 +33,11 @@ public final class RegisterParticleProvidersEvent implements IModBusEvent { return IModBusEvent.getBus(modBusGroup, RegisterParticleProvidersEvent.class); } - private final ParticleEngine particleEngine; + private final ParticleResources particles; @ApiStatus.Internal - public RegisterParticleProvidersEvent(ParticleEngine particleEngine) { - this.particleEngine = particleEngine; + public RegisterParticleProvidersEvent(ParticleResources particles) { + this.particles = particles; } /** @@ -54,23 +53,7 @@ public final class RegisterParticleProvidersEvent implements IModBusEvent { */ @SuppressWarnings("deprecation") public void registerSpecial(ParticleType type, ParticleProvider provider) { - particleEngine.register(type, provider); - } - - /** - *

Registers a ParticleProvider for a json-based ParticleType with a single texture; - * the resulting {@link TextureSheetParticle}s will use that texture when created.

- * - *

A particle json with an ID matching the ParticleType must exist in the particles asset folder, - * or a missing texture list error will occur when particle jsons load.

- * - * @param ParticleOptions used by the ParticleType and Sprite function. - * @param type ParticleType to register a ParticleProvider for. - * @param sprite Sprite function responsible for providing that ParticleType's particles. - */ - @SuppressWarnings("deprecation") - public void registerSprite(ParticleType type, ParticleProvider.Sprite sprite) { - particleEngine.register(type, sprite); + particles.register(type, provider); } /** @@ -85,7 +68,7 @@ public final class RegisterParticleProvidersEvent implements IModBusEvent { * @param registration SpriteParticleRegistration function responsible for providing that ParticleType's particles. */ @SuppressWarnings("deprecation") - public void registerSpriteSet(ParticleType type, ParticleEngine.SpriteParticleRegistration registration) { - particleEngine.register(type, registration); + public void registerSpriteSet(ParticleType type, ParticleResources.SpriteParticleRegistration registration) { + particles.register(type, registration); } } diff --git a/src/main/java/net/minecraftforge/client/event/RenderArmEvent.java b/src/main/java/net/minecraftforge/client/event/RenderArmEvent.java index 4f89de8778..96e6db3750 100644 --- a/src/main/java/net/minecraftforge/client/event/RenderArmEvent.java +++ b/src/main/java/net/minecraftforge/client/event/RenderArmEvent.java @@ -7,7 +7,7 @@ package net.minecraftforge.client.event; import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.renderer.LightTexture; -import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.renderer.SubmitNodeCollector; import net.minecraft.world.entity.HumanoidArm; import net.minecraftforge.eventbus.api.bus.CancellableEventBus; import net.minecraftforge.eventbus.api.event.RecordEvent; @@ -23,14 +23,10 @@ import org.jetbrains.annotations.ApiStatus; *

This event is {@linkplain Cancellable cancellable}. If this event is cancelled, then the arm will not be rendered.

* *

This event is fired only on the {@linkplain LogicalSide#CLIENT logical client}.

- * - * @param getPoseStack The pose stack used for rendering - * @param getMultiBufferSource The source of rendering buffers - * @param getArm The arm being rendered */ public record RenderArmEvent( PoseStack getPoseStack, - MultiBufferSource getMultiBufferSource, + SubmitNodeCollector getNodeCollector, int getPackedLight, HumanoidArm getArm ) implements Cancellable, RecordEvent { diff --git a/src/main/java/net/minecraftforge/client/event/RenderAvatarEvent.java b/src/main/java/net/minecraftforge/client/event/RenderAvatarEvent.java new file mode 100644 index 0000000000..99b08612fa --- /dev/null +++ b/src/main/java/net/minecraftforge/client/event/RenderAvatarEvent.java @@ -0,0 +1,100 @@ +/* + * Copyright (c) Forge Development LLC and contributors + * SPDX-License-Identifier: LGPL-2.1-only + */ + +package net.minecraftforge.client.event; + +import com.mojang.blaze3d.vertex.PoseStack; + +import net.minecraft.client.entity.ClientAvatarEntity; +import net.minecraft.client.renderer.SubmitNodeCollector; +import net.minecraft.client.renderer.entity.player.AvatarRenderer; +import net.minecraft.client.renderer.entity.state.AvatarRenderState; +import net.minecraft.client.renderer.state.CameraRenderState; +import net.minecraft.world.entity.Avatar; +import net.minecraftforge.eventbus.api.bus.CancellableEventBus; +import net.minecraftforge.eventbus.api.bus.EventBus; +import net.minecraftforge.eventbus.api.event.RecordEvent; +import net.minecraftforge.eventbus.api.event.characteristic.Cancellable; +import net.minecraftforge.fml.LogicalSide; +import org.jetbrains.annotations.ApiStatus; + +/** + * Fired when a Avatar is being rendered, typically a player or a mannequin. + * See the two subclasses for listening for before and after rendering. + * + * @see RenderAvatarEvent.Pre + * @see RenderAvatarEvent.Post + * @see AvatarRenderer + */ +public sealed interface RenderAvatarEvent { + AvatarRenderState getState(); + + /** + * {@return the player entity renderer} + */ + AvatarRenderer getRenderer(); + + @SuppressWarnings("unchecked") + default AvatarRenderer getRendererTyped() { + return (AvatarRenderer) getRenderer(); + } + + /** + * {@return the pose stack used for rendering} + */ + PoseStack getPoseStack(); + + /** + * {@return the collector you should render to} + */ + SubmitNodeCollector getNodeCollector(); + + /** + * {@return State related to the current camera} + * + */ + CameraRenderState getCameraState(); + + /** + * Fired before the player is rendered. + * This can be used for rendering additional effects or suppressing rendering. + * + *

This event is {@linkplain Cancellable cancellable}. + * If this event is cancelled, then the player will not be rendered and the corresponding + * {@link RenderAvatarEvent.Post} will not be fired.

+ * + *

This event is fired only on the {@linkplain LogicalSide#CLIENT logical client}.

+ */ + record Pre( + AvatarRenderState getState, + AvatarRenderer getRenderer, + PoseStack getPoseStack, + SubmitNodeCollector getNodeCollector, + CameraRenderState getCameraState + ) implements Cancellable, RecordEvent, RenderAvatarEvent { + public static final CancellableEventBus
 BUS = CancellableEventBus.create(Pre.class);
+
+        @ApiStatus.Internal
+        public Pre {}
+    }
+
+    /**
+     * Fired after the player is rendered, if the corresponding {@link RenderAvatarEvent.Pre} is not cancelled.
+     *
+     * 

This event is only on the {@linkplain LogicalSide#CLIENT logical client}.

+ */ + record Post( + AvatarRenderState getState, + AvatarRenderer getRenderer, + PoseStack getPoseStack, + SubmitNodeCollector getNodeCollector, + CameraRenderState getCameraState + ) implements RecordEvent, RenderAvatarEvent { + public static final EventBus BUS = EventBus.create(Post.class); + + @ApiStatus.Internal + public Post {} + } +} diff --git a/src/main/java/net/minecraftforge/client/event/RenderHandEvent.java b/src/main/java/net/minecraftforge/client/event/RenderHandEvent.java index 45569c3609..b755dce91c 100644 --- a/src/main/java/net/minecraftforge/client/event/RenderHandEvent.java +++ b/src/main/java/net/minecraftforge/client/event/RenderHandEvent.java @@ -7,7 +7,7 @@ package net.minecraftforge.client.event; import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.renderer.LightTexture; -import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.renderer.SubmitNodeCollector; import net.minecraft.world.InteractionHand; import net.minecraft.world.item.ItemStack; import net.minecraftforge.eventbus.api.bus.CancellableEventBus; @@ -37,7 +37,7 @@ import org.jetbrains.annotations.ApiStatus; public record RenderHandEvent( InteractionHand getHand, PoseStack getPoseStack, - MultiBufferSource getMultiBufferSource, + SubmitNodeCollector getNodeCollector, int getPackedLight, float getPartialTick, float getInterpolatedPitch, diff --git a/src/main/java/net/minecraftforge/client/event/RenderHighlightEvent.java b/src/main/java/net/minecraftforge/client/event/RenderHighlightEvent.java index a5b47d4789..dc1fb92ce3 100644 --- a/src/main/java/net/minecraftforge/client/event/RenderHighlightEvent.java +++ b/src/main/java/net/minecraftforge/client/event/RenderHighlightEvent.java @@ -8,102 +8,102 @@ package net.minecraftforge.client.event; import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.Camera; import net.minecraft.client.renderer.LevelRenderer; -import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.renderer.MultiBufferSource.BufferSource; +import net.minecraft.client.renderer.state.LevelRenderState; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.EntityHitResult; import net.minecraft.world.phys.HitResult; -import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.eventbus.api.bus.CancellableEventBus; import net.minecraftforge.eventbus.api.event.InheritableEvent; import net.minecraftforge.eventbus.api.event.MutableEvent; import net.minecraftforge.eventbus.api.event.characteristic.Cancellable; import net.minecraftforge.fml.LogicalSide; import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Nullable; /** * Fired before a selection highlight is rendered. + * You should extract your custom data here so that you can use it in the render callback without effecting world state. + * * See the two subclasses to listen for blocks or entities. * * @see Block * @see Entity */ -public abstract sealed class RenderHighlightEvent extends MutableEvent implements Cancellable, InheritableEvent { - public static final CancellableEventBus BUS = CancellableEventBus.create(RenderHighlightEvent.class); +public sealed abstract class RenderHighlightEvent extends MutableEvent implements Cancellable, InheritableEvent permits RenderHighlightEvent.Block, RenderHighlightEvent.Entity { + CancellableEventBus BUS = CancellableEventBus.create(RenderHighlightEvent.class); private final LevelRenderer levelRenderer; private final Camera camera; - private final HitResult target; - private final float partialTick; - private final PoseStack poseStack; - private final MultiBufferSource multiBufferSource; + private final LevelRenderState levelRenderState; + private Callback customRenderer; - @ApiStatus.Internal - protected RenderHighlightEvent(LevelRenderer levelRenderer, Camera camera, HitResult target, float partialTick, PoseStack poseStack, MultiBufferSource multiBufferSource) { + private RenderHighlightEvent(LevelRenderer levelRenderer, Camera camera, LevelRenderState levelRenderState) { this.levelRenderer = levelRenderer; this.camera = camera; - this.target = target; - this.partialTick = partialTick; - this.poseStack = poseStack; - this.multiBufferSource = multiBufferSource; + this.levelRenderState = levelRenderState; } /** * {@return the level renderer} */ public LevelRenderer getLevelRenderer() { - return levelRenderer; + return this.levelRenderer; + } + + /** + * {@return the level renderer state} + */ + public LevelRenderState getLevelRenderState() { + return this.levelRenderState; } /** * {@return the camera information} */ public Camera getCamera() { - return camera; + return this.camera; } /** * {@return the hit result which triggered the selection highlight} */ - public HitResult getTarget() { - return target; + abstract HitResult getTarget(); + + /** + * {@return the custom renderer that an event listener has set} + */ + @Nullable + public Callback getCustomRenderer() { + return this.customRenderer; } /** - * {@return the partial tick} + * Set a custom renderer to render the selection highlight. + * May be null to clear a previously set custom renderer. + * + * If the callback is set, it will be invoked instead of the vanilla rendering. */ - public float getPartialTick() { - return partialTick; - } - - /** - * {@return the pose stack used for rendering} - */ - public PoseStack getPoseStack() { - return poseStack; - } - - /** - * {@return the source of rendering buffers} - */ - public MultiBufferSource getMultiBufferSource() { - return multiBufferSource; + public void setCustomRenderer(@Nullable Callback value) { + this.customRenderer = value; } /** * Fired before a block's selection highlight is rendered. * - *

This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. + *

This event is {@linkplain Cancellable cancellable}. * If the event is cancelled, then the selection highlight will not be rendered.

* - *

This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus}, - * only on the {@linkplain LogicalSide#CLIENT logical client}.

+ *

This event is fired only on the {@linkplain LogicalSide#CLIENT logical client}.

*/ public static final class Block extends RenderHighlightEvent { public static final CancellableEventBus BUS = CancellableEventBus.create(Block.class); + private final BlockHitResult target; @ApiStatus.Internal - public Block(LevelRenderer levelRenderer, Camera camera, BlockHitResult target, float partialTick, PoseStack poseStack, MultiBufferSource bufferSource) { - super(levelRenderer, camera, target, partialTick, poseStack, bufferSource); + public Block(LevelRenderer levelRenderer, Camera camera, LevelRenderState levelRenderState, BlockHitResult target) { + super(levelRenderer, camera, levelRenderState); + this.target = target; } /** @@ -111,24 +111,25 @@ public abstract sealed class RenderHighlightEvent extends MutableEvent implement */ @Override public BlockHitResult getTarget() { - return (BlockHitResult) super.target; + return target; } } /** * Fired before an entity's selection highlight is rendered. * - *

This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.

+ *

This event is not {@linkplain Cancellable cancellable}.

* - *

This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus}, - * only on the {@linkplain LogicalSide#CLIENT logical client}.

+ *

This event is fired only on the {@linkplain LogicalSide#CLIENT logical client}.

*/ public static final class Entity extends RenderHighlightEvent { public static final CancellableEventBus BUS = CancellableEventBus.create(Entity.class); + private final EntityHitResult target; @ApiStatus.Internal - public Entity(LevelRenderer levelRenderer, Camera camera, EntityHitResult target, float partialTick, PoseStack poseStack, MultiBufferSource bufferSource) { - super(levelRenderer, camera, target, partialTick, poseStack, bufferSource); + public Entity(LevelRenderer levelRenderer, Camera camera, LevelRenderState levelRenderState, EntityHitResult target) { + super(levelRenderer, camera, levelRenderState); + this.target = target; } /** @@ -136,7 +137,11 @@ public abstract sealed class RenderHighlightEvent extends MutableEvent implement */ @Override public EntityHitResult getTarget() { - return (EntityHitResult) super.target; + return target; } } + + public interface Callback { + void render(BufferSource source, PoseStack stack, boolean translucent, LevelRenderState state); + } } diff --git a/src/main/java/net/minecraftforge/client/event/RenderItemInFrameEvent.java b/src/main/java/net/minecraftforge/client/event/RenderItemInFrameEvent.java index caec0a5a30..531ac38432 100644 --- a/src/main/java/net/minecraftforge/client/event/RenderItemInFrameEvent.java +++ b/src/main/java/net/minecraftforge/client/event/RenderItemInFrameEvent.java @@ -7,7 +7,7 @@ package net.minecraftforge.client.event; import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.renderer.LightTexture; -import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.renderer.SubmitNodeCollector; import net.minecraft.client.renderer.entity.ItemFrameRenderer; import net.minecraft.client.renderer.entity.state.ItemFrameRenderState; import net.minecraftforge.eventbus.api.bus.CancellableEventBus; @@ -24,18 +24,13 @@ import org.jetbrains.annotations.ApiStatus; * *

This event is fired only on the {@linkplain LogicalSide#CLIENT logical client}.

* - * @param getItemFrameState The item frame entity - * @param getRenderer The renderer for the item frame entity - * @param getPoseStack The pose stack used for rendering - * @param getMultiBufferSource The source of rendering buffers - * * @see ItemFrameRenderer */ public record RenderItemInFrameEvent( ItemFrameRenderState getItemFrameState, ItemFrameRenderer getRenderer, PoseStack getPoseStack, - MultiBufferSource getMultiBufferSource, + SubmitNodeCollector getNodeCollector, int getPackedLight ) implements Cancellable, RecordEvent { public static final CancellableEventBus BUS = CancellableEventBus.create(RenderItemInFrameEvent.class); diff --git a/src/main/java/net/minecraftforge/client/event/RenderLivingEvent.java b/src/main/java/net/minecraftforge/client/event/RenderLivingEvent.java index 71449c43e0..a3122a1fa2 100644 --- a/src/main/java/net/minecraftforge/client/event/RenderLivingEvent.java +++ b/src/main/java/net/minecraftforge/client/event/RenderLivingEvent.java @@ -8,15 +8,15 @@ package net.minecraftforge.client.event; import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.model.EntityModel; import net.minecraft.client.renderer.LightTexture; -import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.renderer.SubmitNodeCollector; import net.minecraft.client.renderer.entity.LivingEntityRenderer; import net.minecraft.client.renderer.entity.state.LivingEntityRenderState; +import net.minecraft.client.renderer.state.CameraRenderState; import net.minecraft.world.entity.LivingEntity; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.eventbus.api.bus.CancellableEventBus; import net.minecraftforge.eventbus.api.bus.EventBus; -import net.minecraftforge.eventbus.api.event.InheritableEvent; -import net.minecraftforge.eventbus.api.event.MutableEvent; +import net.minecraftforge.eventbus.api.event.RecordEvent; import net.minecraftforge.eventbus.api.event.characteristic.Cancellable; import net.minecraftforge.fml.LogicalSide; import org.jetbrains.annotations.ApiStatus; @@ -32,69 +32,40 @@ import org.jetbrains.annotations.ApiStatus; * @param the model for the living entity * @see RenderLivingEvent.Pre * @see RenderLivingEvent.Post - * @see RenderPlayerEvent + * @see RenderAvatarEvent * @see LivingEntityRenderer */ -public abstract sealed class RenderLivingEvent> extends MutableEvent implements InheritableEvent { - public static final EventBus BUS = EventBus.create(RenderLivingEvent.class); - - private final S state; - private final LivingEntityRenderer renderer; - private final PoseStack poseStack; - private final MultiBufferSource multiBufferSource; - private final int packedLight; - - @ApiStatus.Internal - protected RenderLivingEvent(S state, LivingEntityRenderer renderer, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight) { - this.state = state; - this.renderer = renderer; - this.poseStack = poseStack; - this.multiBufferSource = multiBufferSource; - this.packedLight = packedLight; - } - +public sealed interface RenderLivingEvent> { /** * @return the living entity being rendered */ - public S getState() { - return state; - } + S getState(); /** * @return the renderer for the living entity */ - public LivingEntityRenderer getRenderer() { - return renderer; - } + LivingEntityRenderer getRenderer(); /** * {@return the pose stack used for rendering} */ - public PoseStack getPoseStack() { - return poseStack; - } + PoseStack getPoseStack(); /** - * {@return the source of rendering buffers} + * {@return The render buffer that is collecting the model data. So that things can be batched} */ - public MultiBufferSource getMultiBufferSource() { - return multiBufferSource; - } + SubmitNodeCollector getNodeCollector(); /** - * {@return the amount of packed (sky and block) light for rendering} - * - * @see LightTexture + * {@return Various state infomration about the camera} */ - public int getPackedLight() { - return packedLight; - } + CameraRenderState getCameraState(); /** * Fired before an entity is rendered. * This can be used to render additional effects or suppress rendering. * - *

This event is {@linkplain Cancelable cancelable}, and does not {@linkplain HasResult have a result}. + *

This event is {@linkplain Cancellable cancelable}. * If this event is cancelled, then the entity will not be rendered and the corresponding * {@link RenderLivingEvent.Post} will not be fired.

* @@ -104,32 +75,38 @@ public abstract sealed class RenderLivingEvent the living entity that is being rendered * @param the model for the living entity */ - public static final class Pre> extends RenderLivingEvent implements Cancellable { + record Pre>( + S getState, + LivingEntityRenderer getRenderer, + PoseStack getPoseStack, + SubmitNodeCollector getNodeCollector, + CameraRenderState getCameraState + ) implements Cancellable, RenderLivingEvent, RecordEvent { public static final CancellableEventBus
 BUS = CancellableEventBus.create(Pre.class);
 
         @ApiStatus.Internal
-        public Pre(S state, LivingEntityRenderer renderer, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight) {
-            super(state, renderer, poseStack, multiBufferSource, packedLight);
-        }
+        public Pre {}
     }
 
     /**
      * Fired after an entity is rendered, if the corresponding {@link RenderLivingEvent.Post} is not cancelled.
      *
-     * 

This event is not {@linkplain Cancelable cancelable}, and does not {@linkplain HasResult have a result}.

- * *

This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus}, * only on the {@linkplain LogicalSide#CLIENT logical client}.

* * @param the living entity that was rendered * @param the model for the living entity */ - public static final class Post> extends RenderLivingEvent { + record Post>( + S getState, + LivingEntityRenderer getRenderer, + PoseStack getPoseStack, + SubmitNodeCollector getNodeCollector, + CameraRenderState getCameraState + ) implements RecordEvent, RenderLivingEvent { public static final EventBus BUS = EventBus.create(Post.class); @ApiStatus.Internal - public Post(S state, LivingEntityRenderer renderer, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight) { - super(state, renderer, poseStack, multiBufferSource, packedLight); - } + public Post {} } } diff --git a/src/main/java/net/minecraftforge/client/event/RenderNameTagEvent.java b/src/main/java/net/minecraftforge/client/event/RenderNameTagEvent.java index 46b65acc45..1136eab7f0 100644 --- a/src/main/java/net/minecraftforge/client/event/RenderNameTagEvent.java +++ b/src/main/java/net/minecraftforge/client/event/RenderNameTagEvent.java @@ -6,11 +6,11 @@ package net.minecraftforge.client.event; import com.mojang.blaze3d.vertex.PoseStack; -import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.renderer.SubmitNodeCollector; import net.minecraft.client.renderer.entity.EntityRenderer; import net.minecraft.client.renderer.entity.state.EntityRenderState; +import net.minecraft.client.renderer.state.CameraRenderState; import net.minecraft.network.chat.Component; -import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.util.HasResult; import net.minecraftforge.common.util.Result; import net.minecraftforge.eventbus.api.bus.EventBus; @@ -28,8 +28,7 @@ import org.jetbrains.annotations.ApiStatus; *
  • {@link Result#DENY} - the nameplate will not be rendered.
  • * * - *

    This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus}, - * only on the {@linkplain LogicalSide#CLIENT logical client}.

    + *

    This event is fired only on the {@linkplain LogicalSide#CLIENT logical client}.

    * * @see EntityRenderer */ @@ -41,19 +40,19 @@ public final class RenderNameTagEvent extends MutableEvent implements HasResult private final Component originalContent; private final EntityRenderer entityRenderer; private final PoseStack poseStack; - private final MultiBufferSource multiBufferSource; - private final int packedLight; + private final SubmitNodeCollector nodeCollector; + private final CameraRenderState cameraState; private Result result = Result.DEFAULT; @ApiStatus.Internal - public RenderNameTagEvent(EntityRenderState state, Component content, EntityRenderer entityRenderer, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight) { + public RenderNameTagEvent(EntityRenderState state, Component content, EntityRenderer entityRenderer, PoseStack poseStack, SubmitNodeCollector nodeCollector, CameraRenderState cameraState) { this.state = state; this.originalContent = content; this.setContent(this.originalContent); this.entityRenderer = entityRenderer; this.poseStack = poseStack; - this.multiBufferSource = multiBufferSource; - this.packedLight = packedLight; + this.nodeCollector = nodeCollector; + this.cameraState = cameraState; } @SuppressWarnings("unchecked") @@ -99,19 +98,17 @@ public final class RenderNameTagEvent extends MutableEvent implements HasResult } /** - * {@return the source of rendering buffers} + * {@return the node collector that you should render to} */ - public MultiBufferSource getMultiBufferSource() { - return this.multiBufferSource; + public SubmitNodeCollector getNodeCollector() { + return this.nodeCollector; } /** - * {@return the amount of packed (sky and block) light for rendering} - * - * @see net.minecraft.client.renderer.LightTexture + * {@return CameraState for the current render frame} */ - public int getPackedLight() { - return this.packedLight; + public CameraRenderState getCameraState() { + return this.cameraState; } @Override diff --git a/src/main/java/net/minecraftforge/client/event/RenderPlayerEvent.java b/src/main/java/net/minecraftforge/client/event/RenderPlayerEvent.java deleted file mode 100644 index a3d0dc5981..0000000000 --- a/src/main/java/net/minecraftforge/client/event/RenderPlayerEvent.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright (c) Forge Development LLC and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.minecraftforge.client.event; - -import com.mojang.blaze3d.vertex.PoseStack; -import net.minecraft.client.renderer.LightTexture; -import net.minecraft.client.renderer.MultiBufferSource; -import net.minecraft.client.renderer.entity.player.PlayerRenderer; -import net.minecraft.client.renderer.entity.state.PlayerRenderState; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.eventbus.api.bus.CancellableEventBus; -import net.minecraftforge.eventbus.api.bus.EventBus; -import net.minecraftforge.eventbus.api.event.InheritableEvent; -import net.minecraftforge.eventbus.api.event.MutableEvent; -import net.minecraftforge.eventbus.api.event.characteristic.Cancellable; -import net.minecraftforge.fml.LogicalSide; -import org.jetbrains.annotations.ApiStatus; - -/** - * Fired when a player is being rendered. - * See the two subclasses for listening for before and after rendering. - * - * @see RenderPlayerEvent.Pre - * @see RenderPlayerEvent.Post - * @see PlayerRenderer - */ -public abstract sealed class RenderPlayerEvent extends MutableEvent implements InheritableEvent { - public static final EventBus BUS = EventBus.create(RenderPlayerEvent.class); - - private final PlayerRenderState state; - private final PlayerRenderer renderer; - private final PoseStack poseStack; - private final MultiBufferSource multiBufferSource; - private final int packedLight; - - @ApiStatus.Internal - protected RenderPlayerEvent(PlayerRenderState state, PlayerRenderer renderer, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight) { - this.state = state; - this.renderer = renderer; - this.poseStack = poseStack; - this.multiBufferSource = multiBufferSource; - this.packedLight = packedLight; - } - - public PlayerRenderState getState() { - return this.state; - } - - /** - * {@return the player entity renderer} - */ - public PlayerRenderer getRenderer() { - return renderer; - } - - /** - * {@return the pose stack used for rendering} - */ - public PoseStack getPoseStack() { - return poseStack; - } - - /** - * {@return the source of rendering buffers} - */ - public MultiBufferSource getMultiBufferSource() { - return multiBufferSource; - } - - /** - * {@return the amount of packed (sky and block) light for rendering} - * - * @see LightTexture - */ - public int getPackedLight() { - return packedLight; - } - - /** - * Fired before the player is rendered. - * This can be used for rendering additional effects or suppressing rendering. - * - *

    This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. - * If this event is cancelled, then the player will not be rendered and the corresponding - * {@link RenderPlayerEvent.Post} will not be fired.

    - * - *

    This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus}, - * only on the {@linkplain LogicalSide#CLIENT logical client}.

    - */ - public static final class Pre extends RenderPlayerEvent implements Cancellable { - public static final CancellableEventBus
     BUS = CancellableEventBus.create(Pre.class);
    -
    -        @ApiStatus.Internal
    -        public Pre(PlayerRenderState state, PlayerRenderer renderer, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight) {
    -            super(state, renderer, poseStack, multiBufferSource, packedLight);
    -        }
    -    }
    -
    -    /**
    -     * Fired after the player is rendered, if the corresponding {@link RenderPlayerEvent.Pre} is not cancelled.
    -     *
    -     * 

    This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.

    - * - *

    This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus}, - * only on the {@linkplain LogicalSide#CLIENT logical client}.

    - */ - public static final class Post extends RenderPlayerEvent { - public static final EventBus BUS = EventBus.create(Post.class); - - @ApiStatus.Internal - public Post(PlayerRenderState state, PlayerRenderer renderer, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight) { - super(state, renderer, poseStack, multiBufferSource, packedLight); - } - } -} diff --git a/src/main/java/net/minecraftforge/client/event/RenderTooltipEvent.java b/src/main/java/net/minecraftforge/client/event/RenderTooltipEvent.java index b7ccbc3366..d1abbe423f 100644 --- a/src/main/java/net/minecraftforge/client/event/RenderTooltipEvent.java +++ b/src/main/java/net/minecraftforge/client/event/RenderTooltipEvent.java @@ -23,8 +23,8 @@ import net.minecraftforge.eventbus.api.event.MutableEvent; import net.minecraftforge.eventbus.api.event.characteristic.Cancellable; import net.minecraftforge.fml.LogicalSide; import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; import java.util.Collections; import java.util.List; @@ -37,10 +37,10 @@ import java.util.List; * @see RenderTooltipEvent.Pre * @see RenderTooltipEvent.Background */ +@NullMarked public abstract sealed class RenderTooltipEvent extends MutableEvent implements InheritableEvent { public static final EventBus BUS = EventBus.create(RenderTooltipEvent.class); - @NotNull protected final ItemStack itemStack; protected final GuiGraphics graphics; protected int x; @@ -49,8 +49,7 @@ public abstract sealed class RenderTooltipEvent extends MutableEvent implements protected final List components; @ApiStatus.Internal - protected RenderTooltipEvent(@NotNull ItemStack itemStack, GuiGraphics graphics, int x, int y, @NotNull Font font, @NotNull List components) - { + protected RenderTooltipEvent(ItemStack itemStack, GuiGraphics graphics, int x, int y, Font font, List components) { this.itemStack = itemStack; this.graphics = graphics; this.components = Collections.unmodifiableList(components); @@ -63,18 +62,23 @@ public abstract sealed class RenderTooltipEvent extends MutableEvent implements * {@return the item stack which the tooltip is being rendered for, or an {@linkplain ItemStack#isEmpty() empty * item stack} if there is no associated item stack} */ - @NotNull - public ItemStack getItemStack() - { + + public ItemStack getItemStack() { return itemStack; } + /** + * {@return the gui graphics helper for the gui} + */ + public GuiGraphics getGuiGraphics() { + return graphics; + } + /** * {@return the graphics helper for the gui} */ - public GuiGraphics getGraphics() - { - return this.graphics; + public GuiGraphics getGraphics() { + return graphics; } /** @@ -82,34 +86,28 @@ public abstract sealed class RenderTooltipEvent extends MutableEvent implements * *

    Use {@link ItemTooltipEvent} or {@link GatherComponents} to modify tooltip contents or components.

    */ - @NotNull - public List getComponents() - { + public List getComponents() { return components; } /** * {@return the X position of the tooltip box} By default, this is the mouse X position. */ - public int getX() - { + public int getX() { return x; } /** * {@return the Y position of the tooltip box} By default, this is the mouse Y position. */ - public int getY() - { + public int getY() { return y; } /** * {@return The font used to render the text} */ - @NotNull - public Font getFont() - { + public Font getFont() { return font; } @@ -117,7 +115,7 @@ public abstract sealed class RenderTooltipEvent extends MutableEvent implements * Fired when a tooltip gathers the {@link TooltipComponent}s to be rendered, before any text wrapping or processing. * The list of components and the maximum width of the tooltip can be modified through this event. * - *

    This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. + *

    This event is {@linkplain Cancellable cancellable}. * If this event is cancelled, then the list of components will be empty, causing the tooltip to not be rendered and * the corresponding {@link RenderTooltipEvent.Pre} and {@link RenderTooltipEvent.Background} to not be fired.

    * @@ -134,8 +132,7 @@ public abstract sealed class RenderTooltipEvent extends MutableEvent implements private int maxWidth; @ApiStatus.Internal - public GatherComponents(ItemStack itemStack, int screenWidth, int screenHeight, List> tooltipElements, int maxWidth) - { + public GatherComponents(ItemStack itemStack, int screenWidth, int screenHeight, List> tooltipElements, int maxWidth) { this.itemStack = itemStack; this.screenWidth = screenWidth; this.screenHeight = screenHeight; @@ -147,8 +144,7 @@ public abstract sealed class RenderTooltipEvent extends MutableEvent implements * {@return the item stack which the tooltip is being rendered for, or an {@linkplain ItemStack#isEmpty() empty * item stack} if there is no associated item stack} */ - public ItemStack getItemStack() - { + public ItemStack getItemStack() { return itemStack; } @@ -157,8 +153,7 @@ public abstract sealed class RenderTooltipEvent extends MutableEvent implements * The lines of text within the tooltip are wrapped to be within the screen width, and the tooltip box itself * is moved to be within the screen width. */ - public int getScreenWidth() - { + public int getScreenWidth() { return screenWidth; } @@ -166,8 +161,7 @@ public abstract sealed class RenderTooltipEvent extends MutableEvent implements * {@return the height of the screen} * The tooltip box is moved to be within the screen height. */ - public int getScreenHeight() - { + public int getScreenHeight() { return screenHeight; } @@ -175,8 +169,7 @@ public abstract sealed class RenderTooltipEvent extends MutableEvent implements * {@return the modifiable list of elements to be rendered on the tooltip} These elements can be either * formatted text or custom tooltip components. */ - public List> getTooltipElements() - { + public List> getTooltipElements() { return tooltipElements; } @@ -186,8 +179,7 @@ public abstract sealed class RenderTooltipEvent extends MutableEvent implements *

    A value of {@code -1} means an unlimited maximum width. However, an unlimited maximum width will still * be wrapped to be within the screen bounds.

    */ - public int getMaxWidth() - { + public int getMaxWidth() { return maxWidth; } @@ -196,8 +188,7 @@ public abstract sealed class RenderTooltipEvent extends MutableEvent implements * * @param maxWidth the new maximum width */ - public void setMaxWidth(int maxWidth) - { + public void setMaxWidth(int maxWidth) { this.maxWidth = maxWidth; } } @@ -206,7 +197,7 @@ public abstract sealed class RenderTooltipEvent extends MutableEvent implements * Fired before the tooltip is rendered. * This can be used to modify the positioning and font of the tooltip. * - *

    This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. + *

    This event is {@linkplain Cancellable cancellable}. * If this event is cancelled, then the tooltip will not be rendered and the corresponding * {@link RenderTooltipEvent.Background} will not be fired.

    * @@ -221,8 +212,7 @@ public abstract sealed class RenderTooltipEvent extends MutableEvent implements private final ClientTooltipPositioner positioner; @ApiStatus.Internal - public Pre(@NotNull ItemStack stack, GuiGraphics graphics, int x, int y, int screenWidth, int screenHeight, @NotNull Font font, @NotNull List components, @NotNull ClientTooltipPositioner positioner) - { + public Pre(ItemStack stack, GuiGraphics graphics, int x, int y, int screenWidth, int screenHeight, Font font, List components, ClientTooltipPositioner positioner) { super(stack, graphics, x, y, font, components); this.screenWidth = screenWidth; this.screenHeight = screenHeight; @@ -234,8 +224,7 @@ public abstract sealed class RenderTooltipEvent extends MutableEvent implements * The lines of text within the tooltip are wrapped to be within the screen width, and the tooltip box itself * is moved to be within the screen width. */ - public int getScreenWidth() - { + public int getScreenWidth() { return screenWidth; } @@ -243,13 +232,11 @@ public abstract sealed class RenderTooltipEvent extends MutableEvent implements * {@return the height of the screen} * The tooltip box is moved to be within the screen height. */ - public int getScreenHeight() - { + public int getScreenHeight() { return screenHeight; } - public ClientTooltipPositioner getTooltipPositioner() - { + public ClientTooltipPositioner getTooltipPositioner() { return positioner; } @@ -258,8 +245,7 @@ public abstract sealed class RenderTooltipEvent extends MutableEvent implements * * @param fr the new font */ - public void setFont(@NotNull Font fr) - { + public void setFont(Font fr) { this.font = fr; } @@ -268,8 +254,7 @@ public abstract sealed class RenderTooltipEvent extends MutableEvent implements * * @param x the new X origin */ - public void setX(int x) - { + public void setX(int x) { this.x = x; } @@ -278,8 +263,7 @@ public abstract sealed class RenderTooltipEvent extends MutableEvent implements * * @param y the new Y origin */ - public void setY(int y) - { + public void setY(int y) { this.y = y; } } @@ -288,19 +272,17 @@ public abstract sealed class RenderTooltipEvent extends MutableEvent implements * Fired when the tooltip background prefix is determined. * This can be used to modify the textures to be used for the tooltip background. * - *

    This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.

    - * *

    This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus}, * only on the {@linkplain LogicalSide#CLIENT logical client}.

    */ public static final class Background extends RenderTooltipEvent { public static final EventBus BUS = EventBus.create(Background.class); - private final ResourceLocation originalBackground; - private ResourceLocation background; + private final @Nullable ResourceLocation originalBackground; + private @Nullable ResourceLocation background; @ApiStatus.Internal - public Background(@NotNull ItemStack stack, GuiGraphics graphics, int x, int y, @NotNull Font fr, @NotNull List components, @Nullable ResourceLocation background) { + public Background(ItemStack stack, GuiGraphics graphics, int x, int y, Font fr, List components, @Nullable ResourceLocation background) { super(stack, graphics, x, y, fr, components); this.originalBackground = background; this.background = background; @@ -309,21 +291,21 @@ public abstract sealed class RenderTooltipEvent extends MutableEvent implements /** * Sets the new prefix for the background texture */ - public void setBackground(ResourceLocation background) { + public void setBackground(@Nullable ResourceLocation background) { this.background = background; } /** * @return the potentially modified background's prefix, can be null for default */ - public ResourceLocation getBackground() { + public @Nullable ResourceLocation getBackground() { return this.background; } /** * @return the original tooltip background's prefix, can be null for default */ - public ResourceLocation getOriginalBackground() { + public @Nullable ResourceLocation getOriginalBackground() { return originalBackground; } } diff --git a/src/main/java/net/minecraftforge/client/event/ScreenEvent.java b/src/main/java/net/minecraftforge/client/event/ScreenEvent.java index 98347c2f39..8d211e85cb 100644 --- a/src/main/java/net/minecraftforge/client/event/ScreenEvent.java +++ b/src/main/java/net/minecraftforge/client/event/ScreenEvent.java @@ -15,15 +15,16 @@ import net.minecraftforge.common.util.Result; import net.minecraftforge.eventbus.api.bus.CancellableEventBus; import net.minecraftforge.eventbus.api.bus.EventBus; import net.minecraftforge.eventbus.api.event.MutableEvent; +import net.minecraftforge.eventbus.api.event.RecordEvent; import net.minecraftforge.eventbus.api.event.characteristic.Cancellable; import net.minecraftforge.fml.LogicalSide; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.NonNull; import org.lwjgl.glfw.GLFW; import java.util.Collections; import java.util.List; -import java.util.Objects; import java.util.function.Consumer; /** @@ -39,22 +40,12 @@ import java.util.function.Consumer; * @see MouseInput * @see KeyInput */ -public abstract sealed class ScreenEvent extends MutableEvent { - public static final EventBus BUS = EventBus.create(ScreenEvent.class); - - private final Screen screen; - - @ApiStatus.Internal - protected ScreenEvent(Screen screen) { - this.screen = Objects.requireNonNull(screen); - } - +public sealed interface ScreenEvent { /** * {@return the screen that caused this event} */ - public Screen getScreen() { - return screen; - } + @NonNull + Screen getScreen(); /** * Fired when a screen is being initialized. @@ -67,7 +58,9 @@ public abstract sealed class ScreenEvent extends MutableEvent { * @see Init.Pre * @see Init.Post */ - public static abstract sealed class Init extends ScreenEvent { + abstract sealed class Init extends MutableEvent implements ScreenEvent { + private final Screen screen; + private final Consumer add; private final Consumer remove; @@ -75,12 +68,17 @@ public abstract sealed class ScreenEvent extends MutableEvent { @ApiStatus.Internal protected Init(Screen screen, List listenerList, Consumer add, Consumer remove) { - super(screen); + this.screen = screen; this.listenerList = Collections.unmodifiableList(listenerList); this.add = add; this.remove = remove; } + @Override + public Screen getScreen() { + return screen; + } + /** * {@return unmodifiable view of list of event listeners on the screen} */ @@ -109,7 +107,7 @@ public abstract sealed class ScreenEvent extends MutableEvent { /** * Fired before the screen's overridable initialization method is fired. * - *

    This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. + *

    This event is {@linkplain Cancellable cancellable}, and does not {@linkplain HasResult have a result}. * If the event is cancelled, the initialization method will not be called, and the widgets and children lists * will not be cleared.

    * @@ -128,7 +126,7 @@ public abstract sealed class ScreenEvent extends MutableEvent { /** * Fired after the screen's overridable initialization method is called. * - *

    This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.

    + *

    This event is not {@linkplain Cancellable cancellable}, and does not {@linkplain HasResult have a result}.

    * *

    This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus}, * only on the {@linkplain LogicalSide#CLIENT logical client}.

    @@ -150,82 +148,58 @@ public abstract sealed class ScreenEvent extends MutableEvent { * @see Render.Pre * @see Render.Post */ - public static abstract sealed class Render extends ScreenEvent { - private final GuiGraphics guiGraphics; - private final int mouseX; - private final int mouseY; - private final float partialTick; - - @ApiStatus.Internal - protected Render(Screen screen, GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) { - super(screen); - this.guiGraphics = guiGraphics; - this.mouseX = mouseX; - this.mouseY = mouseY; - this.partialTick = partialTick; - } - + sealed interface Render extends ScreenEvent { /** * {@return the gui graphics used for rendering} */ - public GuiGraphics getGuiGraphics() { - return guiGraphics; - } + GuiGraphics getGuiGraphics(); /** * {@return the X coordinate of the mouse pointer} */ - public int getMouseX() { - return mouseX; - } + int getMouseX(); /** * {@return the Y coordinate of the mouse pointer} */ - public int getMouseY() { - return mouseY; - } + int getMouseY(); /** * {@return the partial tick} */ - public float getPartialTick() { - return partialTick; - } + float getPartialTick(); /** * Fired before the screen is drawn. * - *

    This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. + *

    This event is {@linkplain Cancellable cancellable}, and does not {@linkplain HasResult have a result}. * If the event is cancelled, the screen will not be drawn.

    * *

    This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus}, * only on the {@linkplain LogicalSide#CLIENT logical client}.

    */ - public static final class Pre extends Render implements Cancellable { + record Pre(Screen getScreen, GuiGraphics getGuiGraphics, int getMouseX, int getMouseY, float getPartialTick) + implements Cancellable, Render, RecordEvent { public static final CancellableEventBus
     BUS = CancellableEventBus.create(Pre.class);
     
                 @ApiStatus.Internal
    -            public Pre(Screen screen, GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) {
    -                super(screen, guiGraphics, mouseX, mouseY, partialTick);
    -            }
    +            public Pre {}
             }
     
             /**
              * Fired after the screen is drawn.
              *
    -         * 

    This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.

    + *

    This event is not {@linkplain Cancellable cancellable}, and does not {@linkplain HasResult have a result}.

    * *

    This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus}, * only on the {@linkplain LogicalSide#CLIENT logical client}.

    */ - public static final class Post extends Render { + record Post(Screen getScreen, GuiGraphics getGuiGraphics, int getMouseX, int getMouseY, float getPartialTick) + implements Render, RecordEvent { public static final EventBus BUS = EventBus.create(Post.class); @ApiStatus.Internal - public Post(Screen screen, GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) { - super(screen, guiGraphics, mouseX, mouseY, partialTick); - } + public Post {} } } @@ -233,28 +207,16 @@ public abstract sealed class ScreenEvent extends MutableEvent { * Fired directly after the background of the screen is drawn. * Can be used for drawing above the background but below the tooltips. * - *

    This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.

    - * *

    This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus}, * only on the {@linkplain LogicalSide#CLIENT logical client}.

    + * + * @param getGuiGraphics the gui graphics used for rendering */ - public static final class BackgroundRendered extends ScreenEvent { + record BackgroundRendered(Screen getScreen, GuiGraphics getGuiGraphics) implements RecordEvent, ScreenEvent { public static final EventBus BUS = EventBus.create(BackgroundRendered.class); - private final GuiGraphics guiGraphics; - @ApiStatus.Internal - public BackgroundRendered(Screen screen, GuiGraphics guiGraphics) { - super(screen); - this.guiGraphics = guiGraphics; - } - - /** - * {@return the gui graphics used for rendering} - */ - public GuiGraphics getGuiGraphics() { - return guiGraphics; - } + public BackgroundRendered {} } /** @@ -262,27 +224,32 @@ public abstract sealed class ScreenEvent extends MutableEvent { * Can be used to select the size of the effects display (full or compact) or even hide or replace vanilla's rendering entirely. * This event can also be used to modify the horizontal position of the stack of effects being rendered. * - *

    This event is {@linkplain Cancelable cancellable} and does not {@linkplain HasResult have a result}. - * Cancelling this event will prevent vanilla rendering.

    + *

    This event is {@linkplain Cancellable cancellable}. Cancelling this event will prevent vanilla rendering.

    * *

    This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus}, * only on the {@linkplain LogicalSide#CLIENT logical client}.

    */ - public static final class RenderInventoryMobEffects extends ScreenEvent implements Cancellable { + final class RenderInventoryMobEffects extends MutableEvent implements Cancellable, ScreenEvent { public static final CancellableEventBus BUS = CancellableEventBus.create(RenderInventoryMobEffects.class); + private final Screen screen; private final int availableSpace; private boolean compact; private int horizontalOffset; @ApiStatus.Internal public RenderInventoryMobEffects(Screen screen, int availableSpace, boolean compact, int horizontalOffset) { - super(screen); + this.screen = screen; this.availableSpace = availableSpace; this.compact = compact; this.horizontalOffset = horizontalOffset; } + @Override + public Screen getScreen() { + return screen; + } + /** * The available space to the right of the inventory. */ @@ -335,30 +302,16 @@ public abstract sealed class ScreenEvent extends MutableEvent { * @see MouseDragged * @see MouseScrolled */ - private static abstract sealed class MouseInput extends ScreenEvent { - private final double mouseX; - private final double mouseY; - - @ApiStatus.Internal - protected MouseInput(Screen screen, double mouseX, double mouseY) { - super(screen); - this.mouseX = mouseX; - this.mouseY = mouseY; - } - + sealed interface MouseInput extends ScreenEvent { /** * {@return the X position of the mouse cursor, relative to the screen} */ - public double getMouseX() { - return mouseX; - } + double getMouseX(); /** * {@return the Y position of the mouse cursor, relative to the screen} */ - public double getMouseY() { - return mouseY; - } + double getMouseY(); } /** @@ -368,49 +321,38 @@ public abstract sealed class ScreenEvent extends MutableEvent { * @see MouseButtonPressed.Pre * @see MouseButtonPressed.Post */ - public static abstract sealed class MouseButtonPressed extends MouseInput { - private final int button; - - @ApiStatus.Internal - public MouseButtonPressed(Screen screen, double mouseX, double mouseY, int button) { - super(screen, mouseX, mouseY); - this.button = button; - } - + sealed interface MouseButtonPressed extends MouseInput { /** * {@return the mouse button's input code} * * @see GLFW mouse constants starting with 'GLFW_MOUSE_BUTTON_' * @see the online GLFW documentation */ - public int getButton() { - return button; - } + int getButton(); /** * Fired before the mouse click is handled by the screen. * - *

    This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. + *

    This event is {@linkplain Cancellable cancellable}, and does not {@linkplain HasResult have a result}. * If the event is cancelled, the screen's mouse click handler will be bypassed * and the corresponding {@link MouseButtonPressed.Post} will not be fired.

    * *

    This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus}, * only on the {@linkplain LogicalSide#CLIENT logical client}.

    */ - public static final class Pre extends MouseButtonPressed implements Cancellable { + record Pre(Screen getScreen, double getMouseX, double getMouseY, int getButton) + implements Cancellable, MouseButtonPressed, RecordEvent { public static final CancellableEventBus
     BUS = CancellableEventBus.create(Pre.class);
     
                 @ApiStatus.Internal
    -            public Pre(Screen screen, double mouseX, double mouseY, int button) {
    -                super(screen, mouseX, mouseY, button);
    -            }
    +            public Pre {}
             }
     
             /**
              * Fired after the mouse click is handled, if the corresponding {@link MouseButtonPressed.Pre} was not
              * cancelled.
              *
    -         * 

    This event is not {@linkplain Cancelable cancellable}, {@linkplain HasResult has a result}.

    + *

    This event is not {@linkplain Cancellable cancellable}, {@linkplain HasResult has a result}.

    *
      *
    • {@link Result#ALLOW} - forcibly sets the mouse click as handled
    • *
    • {@link Result#DEFAULT} - defaults to the return value of @@ -421,33 +363,26 @@ public abstract sealed class ScreenEvent extends MutableEvent { *

      This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus}, * only on the {@linkplain LogicalSide#CLIENT logical client}.

      */ - public static final class Post extends MouseButtonPressed implements HasResult { + record Post( + Screen getScreen, + double getMouseX, + double getMouseY, + int getButton, + boolean wasHandled, + Result.Holder resultHolder + ) implements HasResult.Record, MouseButtonPressed, RecordEvent { public static final EventBus BUS = EventBus.create(Post.class); - private final boolean handled; - private Result result = Result.DEFAULT; - @ApiStatus.Internal public Post(Screen screen, double mouseX, double mouseY, int button, boolean handled) { - super(screen, mouseX, mouseY, button); - this.handled = handled; + this(screen, mouseX, mouseY, button, handled, new Result.Holder()); } /** * {@return {@code true} if the mouse click was already handled by its screen} */ public boolean wasHandled() { - return handled; - } - - @Override - public Result getResult() { - return result; - } - - @Override - public void setResult(Result result) { - this.result = result; + return wasHandled; } } } @@ -459,49 +394,38 @@ public abstract sealed class ScreenEvent extends MutableEvent { * @see MouseButtonReleased.Pre * @see MouseButtonReleased.Post */ - public static abstract sealed class MouseButtonReleased extends MouseInput { - private final int button; - - @ApiStatus.Internal - public MouseButtonReleased(Screen screen, double mouseX, double mouseY, int button) { - super(screen, mouseX, mouseY); - this.button = button; - } - + sealed interface MouseButtonReleased extends MouseInput { /** * {@return the mouse button's input code} * * @see GLFW mouse constants starting with 'GLFW_MOUSE_BUTTON_' * @see the online GLFW documentation */ - public int getButton() { - return button; - } + int getButton(); /** * Fired before the mouse release is handled by the screen. * - *

      This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. + *

      This event is {@linkplain Cancellable cancellable}, and does not {@linkplain HasResult have a result}. * If the event is cancelled, the screen's mouse release handler will be bypassed * and the corresponding {@link MouseButtonReleased.Post} will not be fired.

      * *

      This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus}, * only on the {@linkplain LogicalSide#CLIENT logical client}.

      */ - public static final class Pre extends MouseButtonReleased implements Cancellable { + record Pre(Screen getScreen, double getMouseX, double getMouseY, int getButton) + implements Cancellable, MouseButtonReleased, RecordEvent { public static final CancellableEventBus
       BUS = CancellableEventBus.create(Pre.class);
       
                   @ApiStatus.Internal
      -            public Pre(Screen screen, double mouseX, double mouseY, int button) {
      -                super(screen, mouseX, mouseY, button);
      -            }
      +            public Pre {}
               }
       
               /**
                * Fired after the mouse release is handled, if the corresponding {@link MouseButtonReleased.Pre} was
                * not cancelled.
                *
      -         * 

      This event is not {@linkplain Cancelable cancellable}, {@linkplain HasResult has a result}.

      + *

      This event is not {@linkplain Cancellable cancellable}, {@linkplain HasResult has a result}.

      *
        *
      • {@link Result#ALLOW} - forcibly sets the mouse release as handled
      • *
      • {@link Result#DEFAULT} - defaults to the return value of @@ -512,33 +436,26 @@ public abstract sealed class ScreenEvent extends MutableEvent { *

        This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus}, * only on the {@linkplain LogicalSide#CLIENT logical client}.

        */ - public static final class Post extends MouseButtonReleased implements HasResult { + record Post( + Screen getScreen, + double getMouseX, + double getMouseY, + int getButton, + boolean wasHandled, + Result.Holder resultHolder + ) implements MouseButtonReleased, RecordEvent, HasResult.Record { public static final EventBus BUS = EventBus.create(Post.class); - private final boolean handled; - private Result result = Result.DEFAULT; - @ApiStatus.Internal public Post(Screen screen, double mouseX, double mouseY, int button, boolean handled) { - super(screen, mouseX, mouseY, button); - this.handled = handled; + this(screen, mouseX, mouseY, button, handled, new Result.Holder()); } /** * @return {@code true} if the mouse release was already handled by its screen */ public boolean wasHandled() { - return handled; - } - - @Override - public Result getResult() { - return result; - } - - @Override - public void setResult(Result result) { - this.result = result; + return wasHandled; } } } @@ -550,79 +467,71 @@ public abstract sealed class ScreenEvent extends MutableEvent { * @see MouseDragged.Pre * @see MouseDragged.Post */ - public static abstract sealed class MouseDragged extends MouseInput { - private final int mouseButton; - private final double dragX; - private final double dragY; - - @ApiStatus.Internal - public MouseDragged(Screen screen, double mouseX, double mouseY, int mouseButton, double dragX, double dragY) { - super(screen, mouseX, mouseY); - this.mouseButton = mouseButton; - this.dragX = dragX; - this.dragY = dragY; - } - + sealed interface MouseDragged extends MouseInput { /** * {@return the mouse button's input code} * * @see GLFW mouse constants starting with 'GLFW_MOUSE_BUTTON_' * @see the online GLFW documentation */ - public int getMouseButton() { - return mouseButton; - } + int getMouseButton(); /** * {@return amount of mouse drag along the X axis} */ - public double getDragX() { - return dragX; - } + double getDragX(); /** * {@return amount of mouse drag along the Y axis} */ - public double getDragY() { - return dragY; - } + double getDragY(); /** * Fired before the mouse drag is handled by the screen. * - *

        This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. + *

        This event is {@linkplain Cancellable cancellable}, and does not {@linkplain HasResult have a result}. * If the event is cancelled, the screen's mouse drag handler will be bypassed * and the corresponding {@link MouseDragged.Post} will not be fired.

        * *

        This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus}, * only on the {@linkplain LogicalSide#CLIENT logical client}.

        */ - public static final class Pre extends MouseDragged implements Cancellable { + record Pre( + Screen getScreen, + double getMouseX, + double getMouseY, + int getMouseButton, + double getDragX, + double getDragY + ) implements Cancellable, MouseDragged, RecordEvent { public static final CancellableEventBus
         BUS = CancellableEventBus.create(Pre.class);
         
                     @ApiStatus.Internal
        -            public Pre(Screen screen, double mouseX, double mouseY, int mouseButton, double dragX, double dragY) {
        -                super(screen, mouseX, mouseY, mouseButton, dragX, dragY);
        -            }
        +            public Pre {}
                 }
         
                 /**
                  * Fired after the mouse drag is handled, if not handled by the screen
                  * and the corresponding {@link MouseDragged.Pre} is not cancelled.
                  *
        -         * 

        This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. + *

        This event is not {@linkplain Cancellable cancellable}, and does not {@linkplain HasResult have a result}. * If the event is cancelled, the mouse drag will be set as handled.

        * *

        This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus}, * only on the {@linkplain LogicalSide#CLIENT logical client}.

        */ - public static final class Post extends MouseDragged { + record Post( + Screen getScreen, + double getMouseX, + double getMouseY, + int getMouseButton, + double getDragX, + double getDragY + ) implements MouseDragged, RecordEvent { public static final EventBus BUS = EventBus.create(Post.class); @ApiStatus.Internal - public Post(Screen screen, double mouseX, double mouseY, int mouseButton, double dragX, double dragY) { - super(screen, mouseX, mouseY, mouseButton, dragX, dragY); - } + public Post {} } } @@ -633,67 +542,51 @@ public abstract sealed class ScreenEvent extends MutableEvent { * @see MouseScrolled.Pre * @see MouseScrolled.Post */ - public static abstract sealed class MouseScrolled extends MouseInput { - private final double deltaX; - private final double deltaY; - - @ApiStatus.Internal - public MouseScrolled(Screen screen, double mouseX, double mouseY, double deltaX, double deltaY) { - super(screen, mouseX, mouseY); - this.deltaX = deltaX; - this.deltaY = deltaY; - } - + sealed interface MouseScrolled extends MouseInput { /** * {@return the amount of change / delta of the mouse scroll in the vertical direction} */ - public double getDeltaX() { - return deltaX; - } + double getDeltaX(); /** * {@return the amount of change / delta of the mouse scroll in the horizontal direction} */ - public double getDeltaY() { - return deltaY; - } + double getDeltaY(); /** * Fired before the mouse scroll is handled by the screen. * - *

        This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. + *

        This event is {@linkplain Cancellable cancellable}, and does not {@linkplain HasResult have a result}. * If the event is cancelled, the screen's mouse scroll handler will be bypassed * and the corresponding {@link MouseScrolled.Post} will not be fired.

        * *

        This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus}, * only on the {@linkplain LogicalSide#CLIENT logical client}.

        */ - public static final class Pre extends MouseScrolled implements Cancellable { + record Pre(Screen getScreen, double getMouseX, double getMouseY, double getDeltaX, double getDeltaY) + implements Cancellable, MouseScrolled, RecordEvent { public static final CancellableEventBus
         BUS = CancellableEventBus.create(Pre.class);
         
                     @ApiStatus.Internal
        -            public Pre(Screen screen, double mouseX, double mouseY, double deltaX, double deltaY) {
        -                super(screen, mouseX, mouseY, deltaX, deltaY);
        -            }
        +            public Pre {}
                 }
         
                 /**
                  * Fired after the mouse scroll is handled, if not handled by the screen
                  * and the corresponding {@link MouseScrolled.Pre} is not cancelled.
                  *
        -         * 

        This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. + *

        This event is not {@linkplain Cancellable cancellable}, and does not {@linkplain HasResult have a result}. * If the event is cancelled, the mouse scroll will be set as handled.

        * *

        This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus}, * only on the {@linkplain LogicalSide#CLIENT logical client}.

        */ - public static final class Post extends MouseScrolled { + record Post(Screen getScreen, double getMouseX, double getMouseY, double getDeltaX, double getDeltaY) + implements MouseScrolled, RecordEvent { public static final EventBus BUS = EventBus.create(Post.class); @ApiStatus.Internal - public Post(Screen screen, double mouseX, double mouseY, double deltaX, double deltaY) { - super(screen, mouseX, mouseY, deltaX, deltaY); - } + public Post {} } } @@ -706,19 +599,7 @@ public abstract sealed class ScreenEvent extends MutableEvent { * @see InputConstants * @see the online GLFW documentation */ - private static abstract sealed class KeyInput extends ScreenEvent { - private final int keyCode; - private final int scanCode; - private final int modifiers; - - @ApiStatus.Internal - protected KeyInput(Screen screen, int keyCode, int scanCode, int modifiers) { - super(screen); - this.keyCode = keyCode; - this.scanCode = scanCode; - this.modifiers = modifiers; - } - + sealed interface KeyInput extends ScreenEvent { /** * {@return the {@code GLFW} (platform-agnostic) key code} * @@ -726,9 +607,7 @@ public abstract sealed class ScreenEvent extends MutableEvent { * @see GLFW key constants starting with {@code GLFW_KEY_} * @see the online GLFW documentation */ - public int getKeyCode() { - return keyCode; - } + int getKeyCode(); /** * {@return the platform-specific scan code} @@ -739,9 +618,7 @@ public abstract sealed class ScreenEvent extends MutableEvent { * * @see InputConstants#getKey(int, int) */ - public int getScanCode() { - return scanCode; - } + int getScanCode(); /** * {@return a bit field representing the active modifier keys} @@ -754,9 +631,7 @@ public abstract sealed class ScreenEvent extends MutableEvent { * @see GLFW#GLFW_KEY_NUM_LOCK NUM LOCK modifier key bit * @see the online GLFW documentation */ - public int getModifiers() { - return modifiers; - } + int getModifiers(); } /** @@ -766,48 +641,41 @@ public abstract sealed class ScreenEvent extends MutableEvent { * @see KeyPressed.Pre * @see KeyPressed.Post */ - public static abstract sealed class KeyPressed extends KeyInput { - @ApiStatus.Internal - public KeyPressed(Screen screen, int keyCode, int scanCode, int modifiers) { - super(screen, keyCode, scanCode, modifiers); - } - + sealed interface KeyPressed extends KeyInput { /** * Fired before the key press is handled by the screen. * - *

        This event is {@linkplain Cancelable cancellable} and does not {@linkplain HasResult have a result}. + *

        This event is {@linkplain Cancellable cancellable} and does not {@linkplain HasResult have a result}. * If the event is cancelled, the screen's key press handler will be bypassed * and the corresponding {@link KeyPressed.Post} will not be fired.

        * *

        This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus}, * only on the {@linkplain LogicalSide#CLIENT logical client}.

        */ - public static final class Pre extends KeyPressed implements Cancellable { + record Pre(Screen getScreen, int getKeyCode, int getScanCode, int getModifiers) + implements Cancellable, KeyPressed, RecordEvent { public static final CancellableEventBus
         BUS = CancellableEventBus.create(Pre.class);
         
                     @ApiStatus.Internal
        -            public Pre(Screen screen, int keyCode, int scanCode, int modifiers) {
        -                super(screen, keyCode, scanCode, modifiers);
        -            }
        +            public Pre {}
                 }
         
                 /**
                  * Fired after the key press is handled, if not handled by the screen
                  * and the corresponding {@link KeyPressed.Pre} is not cancelled.
                  *
        -         * 

        This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. + *

        This event is {@linkplain Cancellable cancellable}, and does not {@linkplain HasResult have a result}. * If the event is cancelled, the key press will be set as handled.

        * *

        This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus}, * only on the {@linkplain LogicalSide#CLIENT logical client}.

        */ - public static final class Post extends KeyPressed implements Cancellable { + record Post(Screen getScreen, int getKeyCode, int getScanCode, int getModifiers) + implements Cancellable, KeyPressed, RecordEvent { public static final CancellableEventBus BUS = CancellableEventBus.create(Post.class); @ApiStatus.Internal - public Post(Screen screen, int keyCode, int scanCode, int modifiers) { - super(screen, keyCode, scanCode, modifiers); - } + public Post {} } } @@ -818,48 +686,41 @@ public abstract sealed class ScreenEvent extends MutableEvent { * @see KeyReleased.Pre * @see KeyReleased.Post */ - public static abstract sealed class KeyReleased extends KeyInput { - @ApiStatus.Internal - public KeyReleased(Screen screen, int keyCode, int scanCode, int modifiers) { - super(screen, keyCode, scanCode, modifiers); - } - + sealed interface KeyReleased extends KeyInput { /** * Fired before the key release is handled by the screen. * - *

        This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. + *

        This event is {@linkplain Cancellable cancellable}, and does not {@linkplain HasResult have a result}. * If the event is cancelled, the screen's key release handler will be bypassed * and the corresponding {@link KeyReleased.Post} will not be fired.

        * *

        This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus}, * only on the {@linkplain LogicalSide#CLIENT logical client}.

        */ - public static final class Pre extends KeyReleased implements Cancellable { + record Pre(Screen getScreen, int getKeyCode, int getScanCode, int getModifiers) + implements Cancellable, KeyReleased, RecordEvent { public static final CancellableEventBus
         BUS = CancellableEventBus.create(Pre.class);
         
                     @ApiStatus.Internal
        -            public Pre(Screen screen, int keyCode, int scanCode, int modifiers) {
        -                super(screen, keyCode, scanCode, modifiers);
        -            }
        +            public Pre {}
                 }
         
                 /**
                  * Fired after the key release is handled, if not handled by the screen
                  * and the corresponding {@link KeyReleased.Pre} is not cancelled.
                  *
        -         * 

        This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. + *

        This event is {@linkplain Cancellable cancellable}, and does not {@linkplain HasResult have a result}. * If the event is cancelled, the key release will be set as handled.

        * *

        This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus}, * only on the {@linkplain LogicalSide#CLIENT logical client}.

        */ - public static final class Post extends KeyReleased implements Cancellable { + record Post(Screen getScreen, int getKeyCode, int getScanCode, int getModifiers) + implements Cancellable, KeyReleased, RecordEvent { public static final CancellableEventBus BUS = CancellableEventBus.create(Post.class); @ApiStatus.Internal - public Post(Screen screen, int keyCode, int scanCode, int modifiers) { - super(screen, keyCode, scanCode, modifiers); - } + public Post {} } } @@ -871,23 +732,11 @@ public abstract sealed class ScreenEvent extends MutableEvent { * @see CharacterTyped.Post * @see the online GLFW documentation */ - public static sealed class CharacterTyped extends ScreenEvent { - private final char codePoint; - private final int modifiers; - - @ApiStatus.Internal - public CharacterTyped(Screen screen, char codePoint, int modifiers) { - super(screen); - this.codePoint = codePoint; - this.modifiers = modifiers; - } - + sealed interface CharacterTyped extends ScreenEvent { /** * {@return the character code point} */ - public char getCodePoint() { - return codePoint; - } + char getCodePoint(); /** * {@return a bit field representing the active modifier keys} @@ -900,46 +749,41 @@ public abstract sealed class ScreenEvent extends MutableEvent { * @see GLFW#GLFW_KEY_NUM_LOCK NUM LOCK modifier key bit * @see the online GLFW documentation */ - public int getModifiers() { - return modifiers; - } + int getModifiers(); /** * Fired before the character input is handled by the screen. * - *

        This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. + *

        This event is {@linkplain Cancellable cancellable}, and does not {@linkplain HasResult have a result}. * If the event is cancelled, the screen's character input handler will be bypassed * and the corresponding {@link CharacterTyped.Post} will not be fired.

        * *

        This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus}, * only on the {@linkplain LogicalSide#CLIENT logical client}.

        */ - public static final class Pre extends CharacterTyped implements Cancellable { + record Pre(Screen getScreen, char getCodePoint, int getModifiers) + implements Cancellable, CharacterTyped, RecordEvent { public static final CancellableEventBus
         BUS = CancellableEventBus.create(Pre.class);
         
                     @ApiStatus.Internal
        -            public Pre(Screen screen, char codePoint, int modifiers) {
        -                super(screen, codePoint, modifiers);
        -            }
        +            public Pre {}
                 }
         
                 /**
                  * Fired after the character input is handled, if not handled by the screen
                  * and the corresponding {@link CharacterTyped.Pre} is not cancelled.
                  *
        -         * 

        This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. + *

        This event is {@linkplain Cancellable cancellable}, and does not {@linkplain HasResult have a result}. * If the event is cancelled, the character input will be set as handled.

        * *

        This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus}, * only on the {@linkplain LogicalSide#CLIENT logical client}.

        */ - public static final class Post extends CharacterTyped { + record Post(Screen getScreen, char getCodePoint, int getModifiers) implements CharacterTyped, RecordEvent { public static final EventBus BUS = EventBus.create(Post.class); @ApiStatus.Internal - public Post(Screen screen, char codePoint, int modifiers) { - super(screen, codePoint, modifiers); - } + public Post {} } } @@ -947,7 +791,7 @@ public abstract sealed class ScreenEvent extends MutableEvent { * Fired before any {@link Screen} is opened, to allow changing it or preventing it from being opened. * All screen layers on the screen are closed before this event is fired. * - *

        This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. + *

        This event is {@linkplain Cancellable cancellable}, and does not {@linkplain HasResult have a result}. * If this event is cancelled, then the {@code Screen} shall be prevented from opening and any previous screen * will remain open. However, cancelling this event will not prevent the closing of screen layers which happened before * this event fired.

        @@ -955,20 +799,25 @@ public abstract sealed class ScreenEvent extends MutableEvent { *

        This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus}, * only on the {@linkplain LogicalSide#CLIENT logical client}.

        */ - public static final class Opening extends ScreenEvent implements Cancellable { + final class Opening extends MutableEvent implements Cancellable, ScreenEvent { public static final CancellableEventBus BUS = CancellableEventBus.create(Opening.class); - @Nullable - private final Screen currentScreen; + private final Screen screen; + private final @Nullable Screen currentScreen; private Screen newScreen; @ApiStatus.Internal public Opening(@Nullable Screen currentScreen, Screen screen) { - super(screen); + this.screen = screen; this.currentScreen = currentScreen; this.newScreen = screen; } + @Override + public Screen getScreen() { + return screen; + } + /** * Gets the currently open screen at the time of the event being fired. *

        @@ -999,17 +848,15 @@ public abstract sealed class ScreenEvent extends MutableEvent { * Fired before a {@link Screen} is closed. * All screen layers on the screen are closed before this event is fired. * - *

        This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.

        + *

        This event is not {@linkplain Cancellable cancellable}, and does not {@linkplain HasResult have a result}.

        * *

        This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus}, * only on the {@linkplain LogicalSide#CLIENT logical client}.

        */ - public static final class Closing extends ScreenEvent { + record Closing(Screen getScreen) implements ScreenEvent, RecordEvent { public static final EventBus BUS = EventBus.create(Closing.class); @ApiStatus.Internal - public Closing(Screen screen) { - super(screen); - } + public Closing {} } } diff --git a/src/main/java/net/minecraftforge/client/event/TextureStitchEvent.java b/src/main/java/net/minecraftforge/client/event/TextureStitchEvent.java index 5b0ab189e0..4f2226516a 100644 --- a/src/main/java/net/minecraftforge/client/event/TextureStitchEvent.java +++ b/src/main/java/net/minecraftforge/client/event/TextureStitchEvent.java @@ -6,12 +6,12 @@ package net.minecraftforge.client.event; import net.minecraft.client.renderer.texture.TextureAtlas; -import net.minecraftforge.eventbus.api.event.InheritableEvent; -import net.minecraftforge.eventbus.api.event.MutableEvent; +import net.minecraftforge.eventbus.api.bus.BusGroup; +import net.minecraftforge.eventbus.api.bus.EventBus; import net.minecraftforge.fml.LogicalSide; import net.minecraftforge.fml.event.IModBusEvent; -import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import org.jetbrains.annotations.ApiStatus; +import org.jspecify.annotations.NullMarked; /** * Fired after a texture atlas is stitched together. @@ -19,38 +19,26 @@ import org.jetbrains.annotations.ApiStatus; * @see TextureStitchEvent.Post * @see TextureAtlas */ -public sealed class TextureStitchEvent extends MutableEvent implements IModBusEvent, InheritableEvent { - private final TextureAtlas atlas; - - @ApiStatus.Internal - public TextureStitchEvent(TextureAtlas atlas) { - this.atlas = atlas; - } - +@NullMarked +public sealed interface TextureStitchEvent { /** * {@return the texture atlas} */ - public TextureAtlas getAtlas() { - return atlas; - } + TextureAtlas getAtlas(); // Use atlas info JSON files instead // /** // *

        Fired before a texture atlas is stitched together. // * This can be used to add custom sprites to be stitched into the atlas.

        // * - // *

        This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.

        - // * // *

        This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus()} mod-specific event bus}, // * only on the {@linkplain LogicalSide#CLIENT logical client}.

        // */ - // public static class Pre extends TextureStitchEvent - // { + // public static class Pre extends TextureStitchEvent { // private final Set sprites; // // @ApiStatus.Internal - // public Pre(TextureAtlas map, Set sprites) - // { + // public Pre(TextureAtlas map, Set sprites) { // super(map); // this.sprites = sprites; // } @@ -63,8 +51,7 @@ public sealed class TextureStitchEvent extends MutableEvent implements IModBusEv // * // * @param sprite the location of the sprite // */ - // public boolean addSprite(ResourceLocation sprite) - // { + // public boolean addSprite(ResourceLocation sprite) { // return this.sprites.add(sprite); // } // } @@ -72,15 +59,14 @@ public sealed class TextureStitchEvent extends MutableEvent implements IModBusEv /** * Fired after a texture atlas is stitched together and all textures therein has been loaded. * - *

        This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.

        - * - *

        This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus()} mod-specific event bus}, - * only on the {@linkplain LogicalSide#CLIENT logical client}.

        + *

        This event is fired only on the {@linkplain LogicalSide#CLIENT logical client}.

        */ - public static final class Post extends TextureStitchEvent { - @ApiStatus.Internal - public Post(TextureAtlas map) { - super(map); + record Post(TextureAtlas getAtlas) implements TextureStitchEvent, IModBusEvent { + public static EventBus getBus(BusGroup modBusGroup) { + return IModBusEvent.getBus(modBusGroup, Post.class); } + + @ApiStatus.Internal + public Post {} } } diff --git a/src/main/java/net/minecraftforge/client/event/ViewportEvent.java b/src/main/java/net/minecraftforge/client/event/ViewportEvent.java index 142f35a788..d4ded86a01 100644 --- a/src/main/java/net/minecraftforge/client/event/ViewportEvent.java +++ b/src/main/java/net/minecraftforge/client/event/ViewportEvent.java @@ -13,8 +13,8 @@ import net.minecraft.world.level.material.FogType; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.eventbus.api.bus.CancellableEventBus; import net.minecraftforge.eventbus.api.bus.EventBus; -import net.minecraftforge.eventbus.api.event.InheritableEvent; import net.minecraftforge.eventbus.api.event.MutableEvent; +import net.minecraftforge.eventbus.api.event.RecordEvent; import net.minecraftforge.eventbus.api.event.characteristic.Cancellable; import net.minecraftforge.fml.LogicalSide; import org.jetbrains.annotations.ApiStatus; @@ -33,40 +33,21 @@ import org.joml.Vector4f; * @see ComputeCameraAngles * @see ComputeFov */ -public abstract sealed class ViewportEvent extends MutableEvent implements InheritableEvent { - public static final EventBus BUS = EventBus.create(ViewportEvent.class); - - private final GameRenderer renderer; - private final Camera camera; - private final double partialTick; - - @ApiStatus.Internal - public ViewportEvent(GameRenderer renderer, Camera camera, double partialTick) { - this.renderer = renderer; - this.camera = camera; - this.partialTick = partialTick; - } - +public sealed interface ViewportEvent { /** * {@return the game renderer} */ - public GameRenderer getRenderer() { - return renderer; - } + GameRenderer getRenderer(); /** * {@return the camera information} */ - public Camera getCamera() { - return camera; - } + Camera getCamera(); /** * {@return the partial tick} */ - public double getPartialTick() { - return partialTick; - } + float getPartialTick(); /** * Fired for rendering custom fog. The plane distances are based on the player's render distance. @@ -77,35 +58,30 @@ public abstract sealed class ViewportEvent extends MutableEvent implements Inher *

        This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus}, * only on the {@linkplain LogicalSide#CLIENT logical client}.

        */ - public static final class RenderFog extends ViewportEvent implements Cancellable { + record RenderFog( + GameRenderer getRenderer, + Camera getCamera, + float getPartialTick, + FogType getType, + FogData getData, + Vector4f getColor + ) implements Cancellable, ViewportEvent, RecordEvent { public static final CancellableEventBus BUS = CancellableEventBus.create(RenderFog.class); - private final FogType type; - private final FogData data; - private final Vector4f color; - @SuppressWarnings("resource") @ApiStatus.Internal public RenderFog(FogType type, Camera camera, float partialTicks, FogData data, Vector4f color) { - super(Minecraft.getInstance().gameRenderer, camera, partialTicks); - this.type = type; - this.data = data; - this.color = color; + this(Minecraft.getInstance().gameRenderer, camera, partialTicks, type, data, color); } - public FogData getData() { - return data; - } - - public Vector4f getColor() { - return color; - } + @ApiStatus.Internal + public RenderFog {} /** * {@return the type of fog being rendered} */ public FogType getType() { - return type; + return getType; } /** @@ -169,9 +145,12 @@ public abstract sealed class ViewportEvent extends MutableEvent implements Inher *

        This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus}, * only on the {@linkplain LogicalSide#CLIENT logical client}.

        */ - public static final class ComputeFogColor extends ViewportEvent { + final class ComputeFogColor extends MutableEvent implements ViewportEvent { public static final EventBus BUS = EventBus.create(ComputeFogColor.class); + private final GameRenderer renderer; + private final Camera camera; + private final float partialTicks; private float red; private float green; private float blue; @@ -179,12 +158,29 @@ public abstract sealed class ViewportEvent extends MutableEvent implements Inher @SuppressWarnings("resource") @ApiStatus.Internal public ComputeFogColor(Camera camera, float partialTicks, float red, float green, float blue) { - super(Minecraft.getInstance().gameRenderer, camera, partialTicks); + this.renderer = Minecraft.getInstance().gameRenderer; + this.camera = camera; + this.partialTicks = partialTicks; this.setRed(red); this.setGreen(green); this.setBlue(blue); } + @Override + public GameRenderer getRenderer() { + return renderer; + } + + @Override + public Camera getCamera() { + return camera; + } + + @Override + public float getPartialTick() { + return partialTicks; + } + /** * {@return the red color value of the fog} */ @@ -243,21 +239,41 @@ public abstract sealed class ViewportEvent extends MutableEvent implements Inher *

        This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus}, * only on the {@linkplain LogicalSide#CLIENT logical client}.

        */ - public static final class ComputeCameraAngles extends ViewportEvent { + final class ComputeCameraAngles extends MutableEvent implements ViewportEvent { public static final EventBus BUS = EventBus.create(ComputeCameraAngles.class); + private final GameRenderer renderer; + private final Camera camera; + private final float partialTicks; private float yaw; private float pitch; private float roll; @ApiStatus.Internal - public ComputeCameraAngles(GameRenderer renderer, Camera camera, double renderPartialTicks, float yaw, float pitch, float roll) { - super(renderer, camera, renderPartialTicks); + public ComputeCameraAngles(GameRenderer renderer, Camera camera, float renderPartialTicks, float yaw, float pitch, float roll) { + this.renderer = renderer; + this.camera = camera; + this.partialTicks = renderPartialTicks; this.setYaw(yaw); this.setPitch(pitch); this.setRoll(roll); } + @Override + public GameRenderer getRenderer() { + return renderer; + } + + @Override + public Camera getCamera() { + return camera; + } + + @Override + public float getPartialTick() { + return partialTicks; + } + /** * {@return the yaw of the player's camera} */ @@ -318,19 +334,39 @@ public abstract sealed class ViewportEvent extends MutableEvent implements Inher * * @see ComputeFovModifierEvent */ - public static final class ComputeFov extends ViewportEvent { + final class ComputeFov extends MutableEvent implements ViewportEvent { public static final EventBus BUS = EventBus.create(ComputeFov.class); + private final GameRenderer renderer; + private final Camera camera; + private final float partialTicks; private final boolean usedConfiguredFov; private float fov; @ApiStatus.Internal - public ComputeFov(GameRenderer renderer, Camera camera, double renderPartialTicks, float fov, boolean usedConfiguredFov) { - super(renderer, camera, renderPartialTicks); + public ComputeFov(GameRenderer renderer, Camera camera, float renderPartialTicks, float fov, boolean usedConfiguredFov) { + this.renderer = renderer; + this.camera = camera; + this.partialTicks = renderPartialTicks; this.usedConfiguredFov = usedConfiguredFov; this.setFOV(fov); } + @Override + public GameRenderer getRenderer() { + return renderer; + } + + @Override + public Camera getCamera() { + return camera; + } + + @Override + public float getPartialTick() { + return partialTicks; + } + /** * {@return the raw field of view value} */ diff --git a/src/main/java/net/minecraftforge/client/event/sound/PlaySoundEvent.java b/src/main/java/net/minecraftforge/client/event/sound/PlaySoundEvent.java index c85f76aae4..b32214a67e 100644 --- a/src/main/java/net/minecraftforge/client/event/sound/PlaySoundEvent.java +++ b/src/main/java/net/minecraftforge/client/event/sound/PlaySoundEvent.java @@ -7,8 +7,8 @@ package net.minecraftforge.client.event.sound; import net.minecraft.client.resources.sounds.SoundInstance; import net.minecraft.client.sounds.SoundEngine; -import net.minecraftforge.common.util.HasResult; import net.minecraftforge.eventbus.api.bus.EventBus; +import net.minecraftforge.eventbus.api.event.MutableEvent; import net.minecraftforge.fml.LogicalSide; import org.jetbrains.annotations.ApiStatus; import org.jspecify.annotations.Nullable; @@ -19,29 +19,32 @@ import org.jspecify.annotations.Nullable; * others). This can be used to change or prevent (by passing {@code null)} a sound from being played through * {@link #setSound(SoundInstance)}). * - *

        This event is not {@linkplain Cancellable cancellable}, and does not {@linkplain HasResult have a result}.

        - * - *

        This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus}, - * only on the {@linkplain LogicalSide#CLIENT logical client}.

        + *

        This event is fired only on the {@linkplain LogicalSide#CLIENT logical client}.

        * * @see PlaySoundSourceEvent * @see PlayStreamingSourceEvent */ -public final class PlaySoundEvent extends SoundEvent { +public final class PlaySoundEvent extends MutableEvent implements SoundEvent { public static final EventBus BUS = EventBus.create(PlaySoundEvent.class); + private final SoundEngine manager; private final String name; private final SoundInstance originalSound; private @Nullable SoundInstance sound; @ApiStatus.Internal public PlaySoundEvent(SoundEngine manager, SoundInstance sound) { - super(manager); + this.manager = manager; this.originalSound = sound; this.name = sound.getLocation().getPath(); this.setSound(sound); } + @Override + public SoundEngine getEngine() { + return manager; + } + /** * {@return the name of the original sound} This is equivalent to the path of the location of the original sound. */ diff --git a/src/main/java/net/minecraftforge/client/event/sound/PlaySoundSourceEvent.java b/src/main/java/net/minecraftforge/client/event/sound/PlaySoundSourceEvent.java index 34ca42c212..4026ec9313 100644 --- a/src/main/java/net/minecraftforge/client/event/sound/PlaySoundSourceEvent.java +++ b/src/main/java/net/minecraftforge/client/event/sound/PlaySoundSourceEvent.java @@ -19,18 +19,20 @@ import org.jetbrains.annotations.ApiStatus; * in a buffer before being played, and used for most sounds of short length such as sound effects for clicking * buttons. * - *

        This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.

        - * *

        This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus}, * only on the {@linkplain LogicalSide#CLIENT logical client}.

        * * @see PlayStreamingSourceEvent */ -public final class PlaySoundSourceEvent extends SoundSourceEvent { +public record PlaySoundSourceEvent(SoundEngine getEngine, SoundInstance getSound, Channel getChannel, String getName) + implements SoundSourceEvent { public static final EventBus BUS = EventBus.create(PlaySoundSourceEvent.class); @ApiStatus.Internal public PlaySoundSourceEvent(SoundEngine engine, SoundInstance sound, Channel channel) { - super(engine, sound, channel); + this(engine, sound, channel, sound.getLocation().getPath()); } + + @ApiStatus.Internal + public PlaySoundSourceEvent {} } diff --git a/src/main/java/net/minecraftforge/client/event/sound/PlayStreamingSourceEvent.java b/src/main/java/net/minecraftforge/client/event/sound/PlayStreamingSourceEvent.java index c671f628fa..aeab3419da 100644 --- a/src/main/java/net/minecraftforge/client/event/sound/PlayStreamingSourceEvent.java +++ b/src/main/java/net/minecraftforge/client/event/sound/PlayStreamingSourceEvent.java @@ -19,18 +19,20 @@ import org.jetbrains.annotations.ApiStatus; * (such as a file), and used for sounds of long length which are unsuitable to keep fully loaded in-memory in a buffer * (as is done for regular non-streaming sounds), such as background music or music discs. * - *

        This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.

        - * *

        This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus}, * only on the {@linkplain LogicalSide#CLIENT logical client}.

        * * @see PlayStreamingSourceEvent */ -public final class PlayStreamingSourceEvent extends SoundSourceEvent { +public record PlayStreamingSourceEvent(SoundEngine getEngine, SoundInstance getSound, Channel getChannel, String getName) + implements SoundSourceEvent { public static final EventBus BUS = EventBus.create(PlayStreamingSourceEvent.class); @ApiStatus.Internal public PlayStreamingSourceEvent(SoundEngine engine, SoundInstance sound, Channel channel) { - super(engine, sound, channel); + this(engine, sound, channel, sound.getLocation().getPath()); } + + @ApiStatus.Internal + public PlayStreamingSourceEvent {} } diff --git a/src/main/java/net/minecraftforge/client/event/sound/SoundEngineLoadEvent.java b/src/main/java/net/minecraftforge/client/event/sound/SoundEngineLoadEvent.java index e2135344ad..dc39aea5df 100644 --- a/src/main/java/net/minecraftforge/client/event/sound/SoundEngineLoadEvent.java +++ b/src/main/java/net/minecraftforge/client/event/sound/SoundEngineLoadEvent.java @@ -6,31 +6,23 @@ package net.minecraftforge.client.event.sound; import net.minecraft.client.sounds.SoundEngine; -import net.minecraftforge.common.util.HasResult; import net.minecraftforge.eventbus.api.bus.BusGroup; import net.minecraftforge.eventbus.api.bus.EventBus; -import net.minecraftforge.eventbus.api.event.characteristic.Cancellable; import net.minecraftforge.fml.LogicalSide; import net.minecraftforge.fml.event.IModBusEvent; -import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import org.jetbrains.annotations.ApiStatus; /** * Fired when the {@link SoundEngine} is constructed or (re)loaded, such as during game initialization or when the sound * output device is changed. * - *

        This event is not {@linkplain Cancellable cancellable}, and does not {@linkplain HasResult have a result}.

        - * - *

        This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus}, - * only on the {@linkplain LogicalSide#CLIENT logical client}.

        + *

        This event is fired only on the {@linkplain LogicalSide#CLIENT logical client}.

        */ -public final class SoundEngineLoadEvent extends SoundEvent implements IModBusEvent { +public record SoundEngineLoadEvent(SoundEngine getEngine) implements IModBusEvent, SoundEvent { public static EventBus getBus(BusGroup modBusGroup) { return IModBusEvent.getBus(modBusGroup, SoundEngineLoadEvent.class); } @ApiStatus.Internal - public SoundEngineLoadEvent(SoundEngine manager) { - super(manager); - } + public SoundEngineLoadEvent {} } diff --git a/src/main/java/net/minecraftforge/client/event/sound/SoundEvent.java b/src/main/java/net/minecraftforge/client/event/sound/SoundEvent.java index 98b46ad0f4..16ab583530 100644 --- a/src/main/java/net/minecraftforge/client/event/sound/SoundEvent.java +++ b/src/main/java/net/minecraftforge/client/event/sound/SoundEvent.java @@ -25,22 +25,11 @@ import org.jetbrains.annotations.ApiStatus; * @see PlaySoundEvent * @see SoundEngineLoadEvent */ -public abstract class SoundEvent extends MutableEvent implements InheritableEvent { - public static final EventBus BUS = EventBus.create(SoundEvent.class); - - private final SoundEngine engine; - - @ApiStatus.Internal - protected SoundEvent(SoundEngine engine) { - this.engine = engine; - } - +public sealed interface SoundEvent permits PlaySoundEvent, SoundEngineLoadEvent, SoundEvent.SoundSourceEvent { /** * {@return the sound engine} */ - public SoundEngine getEngine() { - return engine; - } + SoundEngine getEngine(); /** * Superclass for when a sound has started to play on an audio channel. @@ -51,40 +40,22 @@ public abstract class SoundEvent extends MutableEvent implements InheritableEven * @see PlaySoundSourceEvent * @see PlayStreamingSourceEvent */ - public static abstract class SoundSourceEvent extends SoundEvent { - public static final EventBus BUS = EventBus.create(SoundSourceEvent.class); - - private final SoundInstance sound; - private final Channel channel; - private final String name; - - @ApiStatus.Internal - protected SoundSourceEvent(SoundEngine engine, SoundInstance sound, Channel channel) { - super(engine); - this.name = sound.getLocation().getPath(); - this.sound = sound; - this.channel = channel; - } + sealed interface SoundSourceEvent extends SoundEvent, InheritableEvent permits PlaySoundSourceEvent, PlayStreamingSourceEvent { + EventBus BUS = EventBus.create(SoundSourceEvent.class); /** * {@return the sound being played} */ - public SoundInstance getSound() { - return sound; - } + SoundInstance getSound(); /** * {@return the audio channel on which the sound is playing on} */ - public Channel getChannel() { - return channel; - } + Channel getChannel(); /** * {@return the name of the sound being played} This is equivalent to the path of the location of the original sound. */ - public String getName() { - return name; - } + String getName(); } } diff --git a/src/main/java/net/minecraftforge/client/event/sound/package-info.java b/src/main/java/net/minecraftforge/client/event/sound/package-info.java index 64e886a2c5..031da5f7c0 100644 --- a/src/main/java/net/minecraftforge/client/event/sound/package-info.java +++ b/src/main/java/net/minecraftforge/client/event/sound/package-info.java @@ -6,12 +6,7 @@ /** * Client-only events relating to sounds. */ -@FieldsAreNonnullByDefault -@MethodsReturnNonnullByDefault -@ParametersAreNonnullByDefault +@NullMarked package net.minecraftforge.client.event.sound; -import net.minecraft.FieldsAreNonnullByDefault; -import net.minecraft.MethodsReturnNonnullByDefault; - -import javax.annotation.ParametersAreNonnullByDefault; \ No newline at end of file +import org.jspecify.annotations.NullMarked; diff --git a/src/main/java/net/minecraftforge/client/extensions/IForgeKeyMapping.java b/src/main/java/net/minecraftforge/client/extensions/IForgeKeyMapping.java index 707b53e6b2..ce98123cd0 100644 --- a/src/main/java/net/minecraftforge/client/extensions/IForgeKeyMapping.java +++ b/src/main/java/net/minecraftforge/client/extensions/IForgeKeyMapping.java @@ -25,7 +25,11 @@ public interface IForgeKeyMapping { * {@return true if the key conflict context and modifier are active and the keyCode matches this binding, false otherwise} */ default boolean isActiveAndMatches(InputConstants.Key keyCode) { - return keyCode != InputConstants.UNKNOWN && keyCode.equals(getKey()) && getKeyConflictContext().isActive() && getKeyModifier().isActive(getKeyConflictContext()); + return keyCode != InputConstants.UNKNOWN && keyCode.equals(getKey()) && isActive(); + } + + default boolean isActive() { + return getKeyConflictContext().isActive() && getKeyModifier().isActive(getKeyConflictContext()); } default void setToDefault() { diff --git a/src/main/java/net/minecraftforge/client/extensions/common/IClientItemExtensions.java b/src/main/java/net/minecraftforge/client/extensions/common/IClientItemExtensions.java index 748ebfb880..40dad3827c 100644 --- a/src/main/java/net/minecraftforge/client/extensions/common/IClientItemExtensions.java +++ b/src/main/java/net/minecraftforge/client/extensions/common/IClientItemExtensions.java @@ -19,7 +19,6 @@ import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; -import net.minecraftforge.client.ForgeHooksClient; import net.minecraftforge.client.IArmPoseTransformer; import net.minecraftforge.fml.LogicalSide; import org.jetbrains.annotations.NotNull; @@ -119,7 +118,7 @@ public interface IClientItemExtensions { default Model getGenericArmorModel(HumanoidRenderState state, ItemStack itemStack, EquipmentSlot equipmentSlot, HumanoidModel original) { HumanoidModel replacement = getHumanoidArmorModel(state, itemStack, equipmentSlot, original); if (replacement != original) { - ForgeHooksClient.copyModelProperties(original, replacement); + //ForgeHooksClient.copyModelProperties(original, replacement); return replacement; } return original; diff --git a/src/main/java/net/minecraftforge/client/gui/ClientTooltipComponentManager.java b/src/main/java/net/minecraftforge/client/gui/ClientTooltipComponentManager.java index 2f8c8d6016..6415e7a18e 100644 --- a/src/main/java/net/minecraftforge/client/gui/ClientTooltipComponentManager.java +++ b/src/main/java/net/minecraftforge/client/gui/ClientTooltipComponentManager.java @@ -40,7 +40,7 @@ public final class ClientTooltipComponentManager { public static void init() { var factories = new HashMap, Function>(); var event = new RegisterClientTooltipComponentFactoriesEvent(factories); - ModLoader.get().postEventWrapContainerInModOrder(event); + ModLoader.postEventWrapContainerInModOrder(event); FACTORIES = ImmutableMap.copyOf(factories); } diff --git a/src/main/java/net/minecraftforge/client/gui/LoadingErrorScreen.java b/src/main/java/net/minecraftforge/client/gui/LoadingErrorScreen.java index d1a117c134..c938fb2149 100644 --- a/src/main/java/net/minecraftforge/client/gui/LoadingErrorScreen.java +++ b/src/main/java/net/minecraftforge/client/gui/LoadingErrorScreen.java @@ -127,7 +127,9 @@ public class LoadingErrorScreen extends ErrorScreen { } @Override - public void render(GuiGraphics guiGraphics, int entryIdx, int top, int left, final int entryWidth, final int entryHeight, final int mouseX, final int mouseY, final boolean p_194999_5_, final float partialTick) { + public void renderContent(GuiGraphics guiGraphics, int mouseX, int mouseY, boolean isMouseOver, float partialTick) { + int top = this.getContentY(); + int left = this.getContentX(); var mc = Minecraft.getInstance(); Font font = mc.font; var strings = font.split(message, LoadingEntryList.this.width - 20); diff --git a/src/main/java/net/minecraftforge/client/gui/ModListScreen.java b/src/main/java/net/minecraftforge/client/gui/ModListScreen.java index 84c2944c36..5a1bfe21b3 100644 --- a/src/main/java/net/minecraftforge/client/gui/ModListScreen.java +++ b/src/main/java/net/minecraftforge/client/gui/ModListScreen.java @@ -28,6 +28,7 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Font; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.screens.Screen; +import net.minecraft.client.input.MouseButtonEvent; import net.minecraft.client.gui.components.EditBox; import net.minecraft.client.gui.components.Button; import net.minecraft.client.gui.components.ObjectSelectionList; @@ -203,13 +204,13 @@ public class ModListScreen extends Screen { } @Override - public boolean mouseClicked(final double mouseX, final double mouseY, final int button) { - final Style component = findTextLine((int) mouseX, (int) mouseY); + public boolean mouseClicked(MouseButtonEvent info, boolean recent) { + final Style component = findTextLine((int)info.x(), (int)info.y()); if (component != null) { ModListScreen.this.handleComponentClicked(component); return true; } - return super.mouseClicked(mouseX, mouseY, button); + return super.mouseClicked(info, recent); } @Override diff --git a/src/main/java/net/minecraftforge/client/gui/ModMismatchDisconnectedScreen.java b/src/main/java/net/minecraftforge/client/gui/ModMismatchDisconnectedScreen.java index 6601211880..521312aae1 100644 --- a/src/main/java/net/minecraftforge/client/gui/ModMismatchDisconnectedScreen.java +++ b/src/main/java/net/minecraftforge/client/gui/ModMismatchDisconnectedScreen.java @@ -26,6 +26,7 @@ import net.minecraft.client.gui.components.Button; import net.minecraft.client.gui.components.MultiLineLabel; import net.minecraft.client.gui.narration.NarrationElementOutput; import net.minecraft.client.gui.screens.Screen; +import net.minecraft.client.input.MouseButtonEvent; import net.minecraft.network.chat.ClickEvent; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.HoverEvent; @@ -101,7 +102,7 @@ public class ModMismatchDisconnectedScreen extends Screen { this.renderBackground(guiGraphics, mouseX, mouseY, partialTicks); int textYOffset = hasMismatches ? 18 : 0; guiGraphics.drawCenteredString(this.font, this.title, this.width / 2, (this.height - this.listHeight - this.textHeight) / 2 - textYOffset - 9 * 2, 0xAAAAAA); - this.message.renderCentered(guiGraphics, this.width / 2, (this.height - this.listHeight - this.textHeight) / 2 - textYOffset); + this.message.render(guiGraphics, MultiLineLabel.Align.CENTER, this.width / 2, (this.height - this.listHeight - this.textHeight) / 2 - textYOffset, 9, true, -1); super.render(guiGraphics, mouseX, mouseY, partialTicks); } @@ -293,13 +294,13 @@ public class ModMismatchDisconnectedScreen extends Screen { } @Override - public boolean mouseClicked(final double mouseX, final double mouseY, final int button) { - Style style = getComponentStyleAt(mouseX, mouseY); + public boolean mouseClicked(MouseButtonEvent info, boolean recent) { + Style style = getComponentStyleAt(info.x(), info.y()); if (style != null) { handleComponentClicked(style); return true; } - return super.mouseClicked(mouseX, mouseY, button); + return super.mouseClicked(info, recent); } @Override diff --git a/src/main/java/net/minecraftforge/client/gui/overlay/ForgeLayeredDraw.java b/src/main/java/net/minecraftforge/client/gui/overlay/ForgeLayeredDraw.java index 62746dfbc8..895473f94a 100644 --- a/src/main/java/net/minecraftforge/client/gui/overlay/ForgeLayeredDraw.java +++ b/src/main/java/net/minecraftforge/client/gui/overlay/ForgeLayeredDraw.java @@ -394,17 +394,20 @@ public final class ForgeLayeredDraw implements ForgeLayer { .add(BOSS_OVERLAY, gui::renderBossOverlay); var postSleepDraw = new ForgeLayeredDraw(POST_SLEEP_STACK) .add(DEMO_OVERLAY, gui::renderDemoOverlay) - .add(DEBUG_OVERLAY, gui::renderDebugOverlay) .add(SCOREBOARD, gui::renderScoreboardSidebar) .add(HOTBAR_MESSAGE, gui::renderOverlayMessage) .add(TITLE_OVERLAY, gui::renderTitle) .add(CHAT_OVERLAY, gui::renderChat) .add(TAB_LIST, gui::renderTabList) - .add(SUBTITLE_OVERLAY, gui::renderSubtitleOverlay); + .add(SUBTITLE_OVERLAY, (gfx, delta) -> gui.renderSubtitleOverlay(gfx, minecraft.screen != null && minecraft.screen.isInGameUi())); instance .add(PRE_SLEEP_STACK, preSleepDraw, () -> !minecraft.options.hideGui) .add(SLEEP_OVERLAY, gui::renderSleepOverlay) - .add(POST_SLEEP_STACK, postSleepDraw, () -> !minecraft.options.hideGui); + .add(POST_SLEEP_STACK, postSleepDraw, () -> !minecraft.options.hideGui) + .add(SUBTITLE_OVERLAY, (gfx, delta) -> { + if (minecraft.options.hideGui && minecraft.screen != null && minecraft.screen.isInGameUi()) + gui.renderSubtitleOverlay(gfx, true); + }); instance.resolveLayers(); } } diff --git a/src/main/java/net/minecraftforge/client/gui/widget/ForgeSlider.java b/src/main/java/net/minecraftforge/client/gui/widget/ForgeSlider.java index 14f3e4d821..b822b436a7 100644 --- a/src/main/java/net/minecraftforge/client/gui/widget/ForgeSlider.java +++ b/src/main/java/net/minecraftforge/client/gui/widget/ForgeSlider.java @@ -8,6 +8,8 @@ package net.minecraftforge.client.gui.widget; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.AbstractSliderButton; +import net.minecraft.client.input.KeyEvent; +import net.minecraft.client.input.MouseButtonEvent; import net.minecraft.client.renderer.RenderPipelines; import net.minecraft.network.chat.Component; import net.minecraft.util.Mth; @@ -121,20 +123,20 @@ public class ForgeSlider extends AbstractSliderButton { } @Override - public void onClick(double mouseX, double mouseY) { - this.setValueFromMouse(mouseX); + public void onClick(MouseButtonEvent info, boolean recent) { + this.setValueFromMouse(info.x()); } @Override - protected void onDrag(double mouseX, double mouseY, double dragX, double dragY) { - super.onDrag(mouseX, mouseY, dragX, dragY); - this.setValueFromMouse(mouseX); + protected void onDrag(MouseButtonEvent info, double dragX, double dragY) { + super.onDrag(info, dragX, dragY); + this.setValueFromMouse(info.x()); } @Override - public boolean keyPressed(int keyCode, int scanCode, int modifiers) { - boolean flag = keyCode == GLFW.GLFW_KEY_LEFT; - if (flag || keyCode == GLFW.GLFW_KEY_RIGHT) { + public boolean keyPressed(KeyEvent info) { + boolean flag = info.key() == GLFW.GLFW_KEY_LEFT; + if (flag || info.key() == GLFW.GLFW_KEY_RIGHT) { if (this.minValue > this.maxValue) flag = !flag; float f = flag ? -1F : 1F; diff --git a/src/main/java/net/minecraftforge/client/gui/widget/ModListWidget.java b/src/main/java/net/minecraftforge/client/gui/widget/ModListWidget.java index 581153ebbc..7307c49d18 100644 --- a/src/main/java/net/minecraftforge/client/gui/widget/ModListWidget.java +++ b/src/main/java/net/minecraftforge/client/gui/widget/ModListWidget.java @@ -8,6 +8,7 @@ package net.minecraftforge.client.gui.widget; import net.minecraft.client.gui.Font; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.ObjectSelectionList; +import net.minecraft.client.input.MouseButtonEvent; import net.minecraft.client.renderer.RenderPipelines; import net.minecraft.resources.ResourceLocation; import net.minecraft.network.chat.Component; @@ -44,12 +45,14 @@ public class ModListWidget extends ObjectSelectionList { } @Override - protected void renderSelection(GuiGraphics gui, int top, int rowWidth, int height, int borderColor, int backgroundColor) { - int barOffset = this.scrollbarVisible() ? 6 : 0; - int left = this.getX() + (this.width - rowWidth) / 2; - int right = this.getX() + (this.width + rowWidth) / 2 - barOffset; - gui.fill(left, top - 2, right, top + height + 2, borderColor); - gui.fill(left + 1, top - 1, right - 1, top + height + 1, backgroundColor); + protected void renderSelection(GuiGraphics gui, ModListWidget.ModEntry entry, int color) { + int widthOffset = this.scrollbarVisible() ? 11 : 4; + int top = entry.getContentY(); + int left = entry.getContentX(); + int right = left + entry.getWidth() - widthOffset; + int bottom = top + entry.getHeight(); + gui.fill(left, top - 2, right, bottom + 2, color); + gui.fill(left + 1, top - 1, right - 1, bottom + 1, /*backgroundColor*/ 0xFF000000); } public void refreshList() { @@ -72,7 +75,11 @@ public class ModListWidget extends ObjectSelectionList { } @Override - public void render(GuiGraphics guiGraphics, int entryIdx, int top, int left, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean isMouseOver, float partialTick) { + public void renderContent(GuiGraphics guiGraphics, int mouseX, int mouseY, boolean isMouseOver, float partialTick) { + int top = this.getContentY(); + int left = this.getContentX(); + int entryHeight = this.getContentBottom(); + Component name = Component.literal(stripControlCodes(modInfo.getDisplayName())); Component version = Component.literal(stripControlCodes(MavenVersionStringHelper.artifactVersionToString(modInfo.getVersion()))); VersionChecker.CheckResult vercheck = VersionChecker.getResult(modInfo); @@ -90,7 +97,7 @@ public class ModListWidget extends ObjectSelectionList { } @Override - public boolean mouseClicked(double p_mouseClicked_1_, double p_mouseClicked_3_, int p_mouseClicked_5_) { + public boolean mouseClicked(MouseButtonEvent info, boolean recent) { parent.setSelected(this); ModListWidget.this.setSelected(this); return false; diff --git a/src/main/java/net/minecraftforge/client/gui/widget/ScrollPanel.java b/src/main/java/net/minecraftforge/client/gui/widget/ScrollPanel.java index 96bcd8ddeb..b28db0fc9f 100644 --- a/src/main/java/net/minecraftforge/client/gui/widget/ScrollPanel.java +++ b/src/main/java/net/minecraftforge/client/gui/widget/ScrollPanel.java @@ -11,6 +11,7 @@ import net.minecraft.client.gui.components.Renderable; import net.minecraft.client.gui.components.events.AbstractContainerEventHandler; import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraft.client.gui.narration.NarratableEntry; +import net.minecraft.client.input.MouseButtonEvent; import java.util.Collections; import java.util.List; @@ -196,23 +197,23 @@ public abstract class ScrollPanel extends AbstractContainerEventHandler implemen } @Override - public boolean mouseClicked(double mouseX, double mouseY, int button) { - if (super.mouseClicked(mouseX, mouseY, button)) + public boolean mouseClicked(MouseButtonEvent info, boolean recent) { + if (super.mouseClicked(info, recent)) return true; - this.scrolling = button == 0 && mouseX >= barLeft && mouseX < barLeft + barWidth; + this.scrolling = info.button() == 0 && info.x() >= barLeft && info.x() < barLeft + barWidth; if (this.scrolling) return true; - int mouseListY = ((int)mouseY) - this.top - this.getContentHeight() + (int)this.scrollDistance - border; - if (mouseX >= left && mouseX <= right && mouseListY < 0) - return this.clickPanel(mouseX - left, mouseY - this.top + (int)this.scrollDistance - border, button); + int mouseListY = ((int)info.y()) - this.top - this.getContentHeight() + (int)this.scrollDistance - border; + if (info.x() >= left && info.x() <= right && mouseListY < 0) + return this.clickPanel(info.x() - left, info.y() - this.top + (int)this.scrollDistance - border, info.button()); return false; } @Override - public boolean mouseReleased(double mouseX, double mouseY, int button) { - if (super.mouseReleased(mouseX, mouseY, button)) + public boolean mouseReleased(MouseButtonEvent info) { + if (super.mouseReleased(info)) return true; boolean ret = this.scrolling; @@ -232,7 +233,7 @@ public abstract class ScrollPanel extends AbstractContainerEventHandler implemen } @Override - public boolean mouseDragged(double mouseX, double mouseY, int button, double deltaX, double deltaY) { + public boolean mouseDragged(MouseButtonEvent info, double deltaX, double deltaY) { if (this.scrolling) { int maxScroll = height - getBarHeight(); double moved = deltaY / maxScroll; diff --git a/src/main/java/net/minecraftforge/client/loading/ClientModLoader.java b/src/main/java/net/minecraftforge/client/loading/ClientModLoader.java index 5a743db64d..f80d20e5f0 100644 --- a/src/main/java/net/minecraftforge/client/loading/ClientModLoader.java +++ b/src/main/java/net/minecraftforge/client/loading/ClientModLoader.java @@ -9,8 +9,8 @@ import java.io.File; import java.util.Collections; import java.util.concurrent.*; import net.minecraft.server.packs.resources.PreparableReloadListener; +import net.minecraft.server.packs.resources.PreparableReloadListener.SharedState; import net.minecraft.server.packs.resources.ReloadableResourceManager; -import net.minecraft.server.packs.resources.ResourceManager; import net.minecraft.server.packs.repository.PackRepository; import net.minecraft.world.level.DataPackConfig; import net.minecraftforge.event.AddPackFindersEvent; @@ -26,7 +26,6 @@ import org.apache.logging.log4j.Logger; import net.minecraft.client.Minecraft; import net.minecraft.server.packs.PackType; import net.minecraftforge.common.ForgeConfig; -import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.client.gui.LoadingErrorScreen; import net.minecraftforge.resource.ResourcePackLoader; import net.minecraftforge.server.LanguageHook; @@ -49,14 +48,14 @@ public class ClientModLoader { createRunnableWithCatch(()->ModLoader.get().gatherAndInitializeMods(ModWorkManager.syncExecutor(), ModWorkManager.parallelExecutor(), ImmediateWindowHandler::renderTick)).run(); if (error == null) { ResourcePackLoader.loadResourcePacks(defaultResourcePacks, true); - ModLoader.get().postEvent(new AddPackFindersEvent(PackType.CLIENT_RESOURCES, defaultResourcePacks::addPackFinder)); + ModLoader.postEvent(new AddPackFindersEvent(PackType.CLIENT_RESOURCES, defaultResourcePacks::addPackFinder)); DataPackConfig.DEFAULT.addModPacks(ResourcePackLoader.getPackNames()); mcResourceManager.registerReloadListener(ClientModLoader::onResourceReload); mcResourceManager.registerReloadListener(BrandingControl.resourceManagerReloadListener()); } } - private static CompletableFuture onResourceReload(final PreparableReloadListener.PreparationBarrier stage, final ResourceManager resourceManager, final Executor asyncExecutor, final Executor syncExecutor) { + private static CompletableFuture onResourceReload(SharedState state, final Executor asyncExecutor, final PreparableReloadListener.PreparationBarrier stage, final Executor syncExecutor) { return CompletableFuture.runAsync(createRunnableWithCatch(() -> startModLoading(ModWorkManager.wrappedExecutor(syncExecutor), asyncExecutor)), ModWorkManager.parallelExecutor()) .thenCompose(stage::wait) .thenRunAsync(() -> finishModLoading(ModWorkManager.wrappedExecutor(syncExecutor), asyncExecutor), ModWorkManager.parallelExecutor()); diff --git a/src/main/java/net/minecraftforge/client/model/data/ModelDataManager.java b/src/main/java/net/minecraftforge/client/model/data/ModelDataManager.java index ab0473e887..91d8719158 100644 --- a/src/main/java/net/minecraftforge/client/model/data/ModelDataManager.java +++ b/src/main/java/net/minecraftforge/client/model/data/ModelDataManager.java @@ -77,7 +77,7 @@ public class ModelDataManager { } public Map getAt(ChunkPos pos) { - Preconditions.checkArgument(level.isClientSide, "Cannot request model data for server level"); + Preconditions.checkArgument(level.isClientSide(), "Cannot request model data for server level"); refreshAt(pos); return modelDataCache.getOrDefault(pos, Collections.emptyMap()); } diff --git a/src/main/java/net/minecraftforge/client/model/geometry/GeometryLoaderManager.java b/src/main/java/net/minecraftforge/client/model/geometry/GeometryLoaderManager.java index 34e53f833d..13a8b91cd9 100644 --- a/src/main/java/net/minecraftforge/client/model/geometry/GeometryLoaderManager.java +++ b/src/main/java/net/minecraftforge/client/model/geometry/GeometryLoaderManager.java @@ -43,7 +43,7 @@ public final class GeometryLoaderManager { public static void init() { var loaders = new HashMap(); var event = new ModelEvent.RegisterGeometryLoaders(loaders); - ModLoader.get().postEventWrapContainerInModOrder(event); + ModLoader.postEventWrapContainerInModOrder(event); LOADERS = ImmutableMap.copyOf(loaders); LOADER_LIST = loaders.keySet().stream().map(ResourceLocation::toString).collect(Collectors.joining(", ")); } diff --git a/src/main/java/net/minecraftforge/client/settings/KeyModifier.java b/src/main/java/net/minecraftforge/client/settings/KeyModifier.java index 577d672d75..1fb1142601 100644 --- a/src/main/java/net/minecraftforge/client/settings/KeyModifier.java +++ b/src/main/java/net/minecraftforge/client/settings/KeyModifier.java @@ -9,7 +9,8 @@ import java.util.List; import java.util.function.Supplier; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.screens.Screen; +import net.minecraft.client.input.InputQuirks; + import com.mojang.blaze3d.platform.InputConstants; import net.minecraft.network.chat.Component; @@ -20,21 +21,17 @@ public enum KeyModifier { CONTROL { @Override public boolean matches(InputConstants.Key key) { - int keyCode = key.getValue(); - if (Minecraft.ON_OSX) - return keyCode == GLFW.GLFW_KEY_LEFT_SUPER || keyCode == GLFW.GLFW_KEY_RIGHT_SUPER; - else - return keyCode == GLFW.GLFW_KEY_LEFT_CONTROL || keyCode == GLFW.GLFW_KEY_RIGHT_CONTROL; + return key.getValue() == InputQuirks.EDIT_SHORTCUT_KEY_LEFT || key.getValue() == InputQuirks.EDIT_SHORTCUT_KEY_RIGHT; } @Override public boolean isActive(@Nullable IKeyConflictContext conflictContext) { - return Screen.hasControlDown(); + return Minecraft.getInstance().hasControlDown(); } @Override public Component getCombinedName(InputConstants.Key key, Supplier defaultLogic) { - String localizationFormatKey = Minecraft.ON_OSX ? "forge.controlsgui.control.mac" : "forge.controlsgui.control"; + String localizationFormatKey = InputQuirks.REPLACE_CTRL_KEY_WITH_CMD_KEY ? "forge.controlsgui.control.mac" : "forge.controlsgui.control"; return Component.translatable(localizationFormatKey, defaultLogic.get()); } }, @@ -46,7 +43,7 @@ public enum KeyModifier { @Override public boolean isActive(@Nullable IKeyConflictContext conflictContext) { - return Screen.hasShiftDown(); + return Minecraft.getInstance().hasShiftDown(); } @Override @@ -62,7 +59,7 @@ public enum KeyModifier { @Override public boolean isActive(@Nullable IKeyConflictContext conflictContext) { - return Screen.hasAltDown(); + return Minecraft.getInstance().hasAltDown(); } @Override diff --git a/src/main/java/net/minecraftforge/client/textures/ITextureAtlasSpriteLoader.java b/src/main/java/net/minecraftforge/client/textures/ITextureAtlasSpriteLoader.java index dbcae06f7b..8d2c8361e3 100644 --- a/src/main/java/net/minecraftforge/client/textures/ITextureAtlasSpriteLoader.java +++ b/src/main/java/net/minecraftforge/client/textures/ITextureAtlasSpriteLoader.java @@ -10,9 +10,12 @@ import net.minecraft.client.renderer.texture.SpriteContents; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.resources.metadata.animation.FrameSize; import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.packs.metadata.MetadataSectionType; import net.minecraft.server.packs.resources.Resource; -import net.minecraft.server.packs.resources.ResourceMetadata; import net.minecraftforge.client.event.RegisterTextureAtlasSpriteLoadersEvent; + +import java.util.List; + import org.jetbrains.annotations.NotNull; /** @@ -30,7 +33,7 @@ import org.jetbrains.annotations.NotNull; * @see RegisterTextureAtlasSpriteLoadersEvent */ public interface ITextureAtlasSpriteLoader { - SpriteContents loadContents(ResourceLocation name, Resource resource, FrameSize frameSize, NativeImage image, ResourceMetadata animationMeta, ForgeTextureMetadata forgeMeta); + SpriteContents loadContents(ResourceLocation name, Resource resource, FrameSize frameSize, NativeImage image, List> metadata); /** * Creates a {@link TextureAtlasSprite} from the given {@link SpriteContents}. diff --git a/src/main/java/net/minecraftforge/client/textures/TextureAtlasSpriteLoaderManager.java b/src/main/java/net/minecraftforge/client/textures/TextureAtlasSpriteLoaderManager.java index c1306a657f..9b7da9f3ac 100644 --- a/src/main/java/net/minecraftforge/client/textures/TextureAtlasSpriteLoaderManager.java +++ b/src/main/java/net/minecraftforge/client/textures/TextureAtlasSpriteLoaderManager.java @@ -40,7 +40,7 @@ public final class TextureAtlasSpriteLoaderManager { public static void init() { var loaders = HashBiMap.create(); var event = new RegisterTextureAtlasSpriteLoadersEvent(loaders); - ModLoader.get().postEventWrapContainerInModOrder(event); + ModLoader.postEventWrapContainerInModOrder(event); LOADERS = ImmutableBiMap.copyOf(loaders); } diff --git a/src/main/java/net/minecraftforge/client/textures/UnitTextureAtlasSprite.java b/src/main/java/net/minecraftforge/client/textures/UnitTextureAtlasSprite.java index 9585c51714..3dbe700a6b 100644 --- a/src/main/java/net/minecraftforge/client/textures/UnitTextureAtlasSprite.java +++ b/src/main/java/net/minecraftforge/client/textures/UnitTextureAtlasSprite.java @@ -10,7 +10,6 @@ import net.minecraft.client.renderer.texture.SpriteContents; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.resources.metadata.animation.FrameSize; import net.minecraft.resources.ResourceLocation; -import net.minecraft.server.packs.resources.ResourceMetadata; /** * A helper sprite with UVs spanning the entire texture. @@ -22,7 +21,7 @@ public class UnitTextureAtlasSprite extends TextureAtlasSprite { public static final UnitTextureAtlasSprite INSTANCE = new UnitTextureAtlasSprite(); private UnitTextureAtlasSprite() { - super(LOCATION, new SpriteContents(LOCATION, new FrameSize(1, 1), new NativeImage(1, 1, false), ResourceMetadata.EMPTY, null), 1, 1, 0, 0); + super(LOCATION, new SpriteContents(LOCATION, new FrameSize(1, 1), new NativeImage(1, 1, false)), 1, 1, 0, 0); } @Override diff --git a/src/main/java/net/minecraftforge/common/FarmlandWaterManager.java b/src/main/java/net/minecraftforge/common/FarmlandWaterManager.java index 54c7703ee6..fa4e7d65fc 100644 --- a/src/main/java/net/minecraftforge/common/FarmlandWaterManager.java +++ b/src/main/java/net/minecraftforge/common/FarmlandWaterManager.java @@ -46,7 +46,7 @@ public class FarmlandWaterManager @SuppressWarnings("unchecked") public static> T addCustomTicket(Level level, T ticket, ChunkPos masterChunk, ChunkPos... additionalChunks) { - Preconditions.checkArgument(!level.isClientSide, "Water region is only determined server-side"); + Preconditions.checkArgument(!level.isClientSide(), "Water region is only determined server-side"); Map> ticketMap = customWaterHandler.computeIfAbsent(level, id -> new MapMaker().weakValues().makeMap()); ChunkTicketManager[] additionalTickets = new ChunkTicketManager[additionalChunks.length]; for (int i = 0; i < additionalChunks.length; i++) diff --git a/src/main/java/net/minecraftforge/common/ForgeHooks.java b/src/main/java/net/minecraftforge/common/ForgeHooks.java index 4ba0f29a37..271da6de55 100644 --- a/src/main/java/net/minecraftforge/common/ForgeHooks.java +++ b/src/main/java/net/minecraftforge/common/ForgeHooks.java @@ -102,7 +102,6 @@ import net.minecraft.world.inventory.AnvilMenu; import net.minecraft.world.Container; import net.minecraft.world.item.context.UseOnContext; import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.IntTag; import net.minecraft.nbt.ListTag; import net.minecraft.network.protocol.Packet; import net.minecraft.network.protocol.PacketFlow; @@ -322,14 +321,14 @@ public final class ForgeHooks { if (ItemTossEvent.BUS.post(event)) return null; - if (!player.level().isClientSide) + if (!player.level().isClientSide()) player.level().addFreshEntity(event.getEntity()); return event.getEntity(); } @Nullable public static Component onServerChatSubmittedEvent(ServerPlayer player, Component message) { - var plain = message.getContents() instanceof LiteralContents literalContents ? literalContents.text() : ""; + var plain = message.getContents() instanceof LiteralContents(String text) ? text : ""; var event = new ServerChatEvent(player, plain, message); return ServerChatEvent.BUS.post(event) ? null : event.getMessage(); } @@ -694,10 +693,13 @@ public final class ForgeHooks { var potion = itemStack.get(DataComponents.POTION_CONTENTS).potion().orElse(null); if (potion != null && potion.unwrapKey().isPresent()) return potion.unwrapKey().get().location().getNamespace(); - } else if (item instanceof SpawnEggItem egg) { - var resourceLocation = EntityType.getKey(egg.getDefaultType()); - if (resourceLocation != null) - return resourceLocation.getNamespace(); + } else if (item instanceof SpawnEggItem) { + var data = item.components().get(DataComponents.ENTITY_DATA); + if (data != null && data.type() != null) { + var resourceLocation = EntityType.getKey(data.type()); + if (resourceLocation != null) + return resourceLocation.getNamespace(); + } } } return modId; @@ -788,9 +790,9 @@ public final class ForgeHooks { @Deprecated public static void modifyAttributes() { - ModLoader.get().postEvent(new EntityAttributeCreationEvent(FORGE_ATTRIBUTES)); + ModLoader.postEvent(new EntityAttributeCreationEvent(FORGE_ATTRIBUTES)); Map, AttributeSupplier.Builder> finalMap = new HashMap<>(); - ModLoader.get().postEvent(new EntityAttributeModificationEvent(finalMap)); + ModLoader.postEvent(new EntityAttributeModificationEvent(finalMap)); finalMap.forEach((k, v) -> { AttributeSupplier supplier = DefaultAttributes.getSupplier(k); @@ -858,7 +860,7 @@ public final class ForgeHooks { } final var mismatchEvent = new ModMismatchEvent(levelDirectory, mismatchedVersions, missingVersions); - ModLoader.get().postEvent(mismatchEvent); + ModLoader.postEvent(mismatchEvent); StringBuilder resolved = new StringBuilder("The following mods have version differences that were marked resolved:"); StringBuilder unresolved = new StringBuilder("The following mods have version differences that were not resolved:"); @@ -1043,7 +1045,7 @@ public final class ForgeHooks { } } - if (!isAir && !entity.level().isClientSide && entity.isPassenger() && entity.getVehicle() != null && !entity.getVehicle().canBeRiddenUnderFluidType(entity.getEyeInFluidType(), entity)) { + if (!isAir && !entity.level().isClientSide() && entity.isPassenger() && entity.getVehicle() != null && !entity.getVehicle().canBeRiddenUnderFluidType(entity.getEyeInFluidType(), entity)) { entity.stopRiding(); } } @@ -1064,7 +1066,7 @@ public final class ForgeHooks { entries.put(stack, vis); }); - ModLoader.get().postEvent(new BuildCreativeModeTabContentsEvent(tab, tabKey, params, entries)); + ModLoader.postEvent(new BuildCreativeModeTabContentsEvent(tab, tabKey, params, entries)); for (var entry : entries) output.accept(entry.getKey(), entry.getValue()); diff --git a/src/main/java/net/minecraftforge/common/ForgeInternalHandler.java b/src/main/java/net/minecraftforge/common/ForgeInternalHandler.java index 2cbe51bd27..607b585687 100644 --- a/src/main/java/net/minecraftforge/common/ForgeInternalHandler.java +++ b/src/main/java/net/minecraftforge/common/ForgeInternalHandler.java @@ -49,7 +49,7 @@ public final class ForgeInternalHandler { if (newEntity != null) { entity.discard(); @SuppressWarnings("resource") - var executor = LogicalSidedProvider.WORKQUEUE.get(event.getLevel().isClientSide ? LogicalSide.CLIENT : LogicalSide.SERVER); + var executor = LogicalSidedProvider.WORKQUEUE.get(event.getLevel().isClientSide() ? LogicalSide.CLIENT : LogicalSide.SERVER); executor.schedule(new TickTask(0, () -> event.getLevel().addFreshEntity(newEntity))); return true; } @@ -80,7 +80,7 @@ public final class ForgeInternalHandler { @SubscribeEvent static void playerLogin(PlayerEvent.PlayerLoggedInEvent event) { - UsernameCache.setUsername(event.getEntity().getUUID(), event.getEntity().getGameProfile().getName()); + UsernameCache.setUsername(event.getEntity().getUUID(), event.getEntity().getGameProfile().name()); } @SubscribeEvent diff --git a/src/main/java/net/minecraftforge/common/ForgeMod.java b/src/main/java/net/minecraftforge/common/ForgeMod.java index eea85b3080..f9f5c64502 100644 --- a/src/main/java/net/minecraftforge/common/ForgeMod.java +++ b/src/main/java/net/minecraftforge/common/ForgeMod.java @@ -5,6 +5,7 @@ package net.minecraftforge.common; +import net.minecraft.DetectedVersion; import net.minecraft.SharedConstants; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.BiomeColors; @@ -441,10 +442,9 @@ public class ForgeMod { ExistingFileHelper existingFileHelper = event.getExistingFileHelper(); gen.addProvider(true, new PackMetadataGenerator(packOutput) - .add(PackMetadataSection.TYPE, new PackMetadataSection( + .add(PackMetadataSection.SERVER_TYPE, new PackMetadataSection( Component.translatable("pack.forge.description"), - SharedConstants.getCurrentVersion().packVersion(PackType.SERVER_DATA), - Optional.empty() //Arrays.stream(PackType.values()).collect(Collectors.toMap(Function.identity(), DetectedVersion.BUILT_IN::getPackVersion)) + DetectedVersion.BUILT_IN.packVersion(PackType.SERVER_DATA).minorRange() )) ); ForgeBlockTagsProvider blockTags = new ForgeBlockTagsProvider(packOutput, lookupProvider, existingFileHelper); diff --git a/src/main/java/net/minecraftforge/common/ForgeStatesProvider.java b/src/main/java/net/minecraftforge/common/ForgeStatesProvider.java index 3cd2196c4e..d4bc1f0468 100644 --- a/src/main/java/net/minecraftforge/common/ForgeStatesProvider.java +++ b/src/main/java/net/minecraftforge/common/ForgeStatesProvider.java @@ -14,13 +14,11 @@ import net.minecraftforge.fml.ModLoadingState; import net.minecraftforge.fml.core.ModStateProvider; import net.minecraftforge.network.NetworkRegistry; import net.minecraftforge.registries.GameData; -import net.minecraftforge.registries.ObjectHolderRegistry; import net.minecraftforge.registries.RegistryManager; public class ForgeStatesProvider implements IModStateProvider { public static final ModLoadingState CREATE_REGISTRIES = gather("CREATE_REGISTRIES", ModStateProvider.CONSTRUCT, RegistryManager::postNewRegistryEvent); - public static final ModLoadingState OBJECT_HOLDERS = gather("OBJECT_HOLDERS", CREATE_REGISTRIES, ObjectHolderRegistry::findObjectHolders); - public static final ModLoadingState INJECT_CAPABILITIES = gather("INJECT_CAPABILITIES", OBJECT_HOLDERS).withInline(CapabilityManager::injectCapabilities); + public static final ModLoadingState INJECT_CAPABILITIES = gather("INJECT_CAPABILITIES", CREATE_REGISTRIES).withInline(CapabilityManager::injectCapabilities); public static final ModLoadingState UNFREEZE_DATA = gather("UNFREEZE_DATA", INJECT_CAPABILITIES, GameData::unfreezeData); public static final ModLoadingState LOAD_REGISTRIES = gather("LOAD_REGISTRIES", UNFREEZE_DATA, GameData::postRegisterEvents); public static final ModLoadingState FREEZE_DATA = complete("FREEZE_DATA", ModStateProvider.COMPLETE, GameData::freezeData); @@ -44,6 +42,6 @@ public class ForgeStatesProvider implements IModStateProvider { @Override public List getAllStates() { - return List.of(CREATE_REGISTRIES, OBJECT_HOLDERS, INJECT_CAPABILITIES, UNFREEZE_DATA, LOAD_REGISTRIES, FREEZE_DATA, NETWORK_LOCK); + return List.of(CREATE_REGISTRIES, INJECT_CAPABILITIES, UNFREEZE_DATA, LOAD_REGISTRIES, FREEZE_DATA, NETWORK_LOCK); } } diff --git a/src/main/java/net/minecraftforge/common/IExtensibleEnum.java b/src/main/java/net/minecraftforge/common/IExtensibleEnum.java index a091dbbb05..73a94635db 100644 --- a/src/main/java/net/minecraftforge/common/IExtensibleEnum.java +++ b/src/main/java/net/minecraftforge/common/IExtensibleEnum.java @@ -23,8 +23,7 @@ import java.util.function.Supplier; * require the method: * *
        - * public static MyEnum create(String name, Object foo)
        - * {
        + * public static MyEnum create(String name, Object foo) {
          *     throw new IllegalStateException("Enum not extended");
          * }
          * 
        diff --git a/src/main/java/net/minecraftforge/common/capabilities/CapabilityManager.java b/src/main/java/net/minecraftforge/common/capabilities/CapabilityManager.java index 47f2830424..21178e04c2 100644 --- a/src/main/java/net/minecraftforge/common/capabilities/CapabilityManager.java +++ b/src/main/java/net/minecraftforge/common/capabilities/CapabilityManager.java @@ -103,7 +103,7 @@ public final class CapabilityManager { @SuppressWarnings("removal") var event = new RegisterCapabilitiesEvent(); - ModLoader.get().postEvent(event); + ModLoader.postEvent(event); } private static void error(String message) { diff --git a/src/main/java/net/minecraftforge/common/data/ForgeBlockItemTagsProvider.java b/src/main/java/net/minecraftforge/common/data/ForgeBlockItemTagsProvider.java index eb506ac194..29f1f976cf 100644 --- a/src/main/java/net/minecraftforge/common/data/ForgeBlockItemTagsProvider.java +++ b/src/main/java/net/minecraftforge/common/data/ForgeBlockItemTagsProvider.java @@ -41,7 +41,8 @@ public abstract class ForgeBlockItemTagsProvider extends BlockItemTagsProvider { .add(Blocks.MEDIUM_AMETHYST_BUD) .add(Blocks.LARGE_AMETHYST_BUD); tag(Tags.Blocks.CHAINS, Tags.Items.CHAINS) - .add(Blocks.CHAIN); + .add(Blocks.IRON_CHAIN) + .addAll(Blocks.COPPER_CHAIN.asList()); tag(Tags.Blocks.CHESTS, Tags.Items.CHESTS) .addTags( Tags.Blocks.CHESTS_ENDER, diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeBlock.java b/src/main/java/net/minecraftforge/common/extensions/IForgeBlock.java index c13b07afd1..c661e9f6ad 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeBlock.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeBlock.java @@ -182,7 +182,7 @@ public interface IForgeBlock { */ default boolean onDestroyedByPlayer(BlockState state, Level level, BlockPos pos, Player player, boolean willHarvest, FluidState fluid) { self().playerWillDestroy(level, pos, state, player); - return level.setBlock(pos, fluid.createLegacyBlock(), level.isClientSide ? 11 : 3); + return level.setBlock(pos, fluid.createLegacyBlock(), level.isClientSide() ? 11 : 3); } /** @@ -713,7 +713,7 @@ public interface IForgeBlock { // Logic copied from HoeItem#TILLABLES; needs to be kept in sync during updating Block block = state.getBlock(); if (block == Blocks.ROOTED_DIRT) { - if (!simulate && !context.getLevel().isClientSide) { + if (!simulate && !context.getLevel().isClientSide()) { Block.popResourceFromFace(context.getLevel(), context.getClickedPos(), context.getClickedFace(), new ItemStack(Items.HANGING_ROOTS)); } return Blocks.DIRT.defaultBlockState(); diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeBlockEntity.java b/src/main/java/net/minecraftforge/common/extensions/IForgeBlockEntity.java index d30c449608..6139cae4e3 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeBlockEntity.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeBlockEntity.java @@ -114,7 +114,7 @@ public interface IForgeBlockEntity extends ICapabilityProvider { default void requestModelDataUpdate() { BlockEntity te = self(); Level level = te.getLevel(); - if (level != null && level.isClientSide) { + if (level != null && level.isClientSide()) { var modelDataManager = level.getModelDataManager(); if (modelDataManager != null) { modelDataManager.requestRefresh(te); @@ -136,10 +136,9 @@ public interface IForgeBlockEntity extends ICapabilityProvider { /** * Returns whether this {@link BlockEntity} has custom outline rendering behavior. * - * @param player the local player currently viewing this {@code BlockEntity} * @return {@code true} to enable outline processing */ - default boolean hasCustomOutlineRendering(Player player) { + default boolean hasCustomOutlineRendering() { return false; } } diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeGameTestHelper.java b/src/main/java/net/minecraftforge/common/extensions/IForgeGameTestHelper.java index 7aea3d116b..37d18e56cf 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeGameTestHelper.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeGameTestHelper.java @@ -41,6 +41,7 @@ import net.minecraft.network.protocol.game.GameProtocols; import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.network.CommonListenerCookie; import net.minecraft.server.network.ServerGamePacketListenerImpl; +import net.minecraft.world.level.GameType; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.entity.BaseContainerBlockEntity; @@ -50,6 +51,8 @@ import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.capabilities.ForgeCapabilities; import net.minecraftforge.eventbus.api.bus.EventBus; import net.minecraftforge.eventbus.api.event.InheritableEvent; +import net.minecraftforge.eventbus.api.event.MutableEvent; +import net.minecraftforge.eventbus.api.event.RecordEvent; public interface IForgeGameTestHelper { private GameTestHelper self() { @@ -144,22 +147,24 @@ public interface IForgeGameTestHelper { return this.self().getLevel().registryAccess().lookupOrThrow(registryKey); } + /** + * Create a mock server player in creative mode + */ default ServerPlayer makeMockServerPlayer() { - return makeMockServerPlayer(true); + return makeMockServerPlayer(GameType.CREATIVE); } + /** + * Create a mock server player in creative mode + */ default ServerPlayer makeMockServerPlayer(boolean creative) { + return makeMockServerPlayer(creative ? GameType.CREATIVE : GameType.SURVIVAL); + } + + default ServerPlayer makeMockServerPlayer(GameType type) { var level = self().getLevel(); var cookie = CommonListenerCookie.createInitial(new GameProfile(UUID.randomUUID(), "test-mock-player"), false); - var player = new ServerPlayer(level.getServer(), level, cookie.gameProfile(), cookie.clientInformation()) { - public boolean isSpectator() { - return false; - } - - public boolean isCreative() { - return creative; - } - }; + var player = new ServerPlayer(level.getServer(), level, cookie.gameProfile(), cookie.clientInformation()); var connection = new Connection(PacketFlow.SERVERBOUND); @SuppressWarnings("unused") // The constructor has side effects var channel = new EmbeddedChannel(connection); @@ -168,6 +173,7 @@ public interface IForgeGameTestHelper { var listener = new ServerGamePacketListenerImpl(server, connection, player, cookie); var info = GameProtocols.SERVERBOUND_TEMPLATE.bind(RegistryFriendlyByteBuf.decorator(server.registryAccess()), listener); connection.setupInboundProtocol(info, listener); + player.setGameMode(type); return player; } @@ -179,6 +185,22 @@ public interface IForgeGameTestHelper { self().addCleanup(success -> bus.removeListener(key)); } + /** + * Registers an event listener that will be unregistered when the test is finished running. + */ + default void addMutableListener(EventBus bus, Consumer consumer) { + var key = bus.addListener(consumer); + self().addCleanup(success -> bus.removeListener(key)); + } + + /** + * Registers an event listener that will be unregistered when the test is finished running. + */ + default void addRecordListener(EventBus bus, Consumer consumer) { + var key = bus.addListener(consumer); + self().addCleanup(success -> bus.removeListener(key)); + } + /** * Registers an event listener that will be unregistered when the test is finished running. */ diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeServerPlayer.java b/src/main/java/net/minecraftforge/common/extensions/IForgeServerPlayer.java index b963110e9f..aeb1775d9f 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeServerPlayer.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeServerPlayer.java @@ -51,7 +51,7 @@ public interface IForgeServerPlayer { @SuppressWarnings("resource") default void openMenu(MenuProvider containerSupplier, Consumer extraDataWriter) { var player = self(); - if (player.level().isClientSide) return; + if (player.level().isClientSide()) return; player.doCloseContainer(); player.nextContainerCounter(); int openContainerId = player.containerCounter; diff --git a/src/main/java/net/minecraftforge/data/loading/DatagenModLoader.java b/src/main/java/net/minecraftforge/data/loading/DatagenModLoader.java index a81c2a214e..c938c59b93 100644 --- a/src/main/java/net/minecraftforge/data/loading/DatagenModLoader.java +++ b/src/main/java/net/minecraftforge/data/loading/DatagenModLoader.java @@ -116,7 +116,7 @@ public class DatagenModLoader { } existingFileHelper = new ExistingFileHelper(existingPacks, existingMods, validate, assetIndex, assetsDir); - ModLoader.get().runEventGenerator(mc -> new GatherDataEvent( + ModLoader.runEventGenerator(mc -> new GatherDataEvent( mc, config.makeGenerator( p -> config.isFlat() ? p : p.resolve(mc.getModId()), diff --git a/src/main/java/net/minecraftforge/event/AddPackFindersEvent.java b/src/main/java/net/minecraftforge/event/AddPackFindersEvent.java index c1adb20b28..9f6b0138c7 100644 --- a/src/main/java/net/minecraftforge/event/AddPackFindersEvent.java +++ b/src/main/java/net/minecraftforge/event/AddPackFindersEvent.java @@ -16,32 +16,20 @@ import java.util.function.Consumer; /** * Fired on {@link PackRepository} creation to allow mods to add new pack finders. + * + * @param getPackType the {@link PackType} of the pack repository being constructed. */ -public final class AddPackFindersEvent implements IModBusEvent { +public record AddPackFindersEvent(PackType getPackType, Consumer sourceAdder) implements IModBusEvent { public static EventBus getBus(BusGroup modBusGroup) { return IModBusEvent.getBus(modBusGroup, AddPackFindersEvent.class); } - private final PackType packType; - private final Consumer sources; - - public AddPackFindersEvent(PackType packType, Consumer sources) { - this.packType = packType; - this.sources = sources; - } - /** * Adds a new source to the list of pack finders. + * * @param source the pack finder */ public void addRepositorySource(RepositorySource source) { - sources.accept(source); - } - - /** - * @return the {@link PackType} of the pack repository being constructed. - */ - public PackType getPackType() { - return packType; + sourceAdder.accept(source); } } diff --git a/src/main/java/net/minecraftforge/event/AddReloadListenerEvent.java b/src/main/java/net/minecraftforge/event/AddReloadListenerEvent.java index 3ce1669bb4..bf099cda38 100644 --- a/src/main/java/net/minecraftforge/event/AddReloadListenerEvent.java +++ b/src/main/java/net/minecraftforge/event/AddReloadListenerEvent.java @@ -5,19 +5,14 @@ package net.minecraftforge.event; -import com.google.common.collect.ImmutableList; import net.minecraft.core.HolderLookup; -import net.minecraft.core.LayeredRegistryAccess; -import net.minecraft.core.RegistryAccess; -import net.minecraft.server.RegistryLayer; import net.minecraft.server.ReloadableServerResources; import net.minecraft.server.packs.resources.PreparableReloadListener; -import net.minecraft.server.packs.resources.ResourceManager; -import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.crafting.conditions.ICondition; import net.minecraftforge.eventbus.api.bus.EventBus; import net.minecraftforge.eventbus.api.event.MutableEvent; import net.minecraftforge.fml.ModLoader; +import org.jspecify.annotations.NullMarked; import java.util.ArrayList; import java.util.List; @@ -26,10 +21,9 @@ import java.util.concurrent.Executor; /** * The main ResourceManager is recreated on each reload, just after {@link ReloadableServerResources}'s creation. - * - * The event is fired on each reload and lets modders add their own ReloadListeners, for server-side resources. - * The event is fired on the {@link MinecraftForge#EVENT_BUS} + *

        The event is fired on each reload and lets modders add their own ReloadListeners, for server-side resources.

        */ +@NullMarked public final class AddReloadListenerEvent extends MutableEvent { public static final EventBus BUS = EventBus.create(AddReloadListenerEvent.class); @@ -37,30 +31,10 @@ public final class AddReloadListenerEvent extends MutableEvent { private final ReloadableServerResources serverResources; private final HolderLookup.Provider registries; - @Deprecated(forRemoval = true, since = "1.21.4") - private final RegistryAccess registryAccess; - /** @deprecated Does not provide additional context. Use {@link #AddReloadListenerEvent(ReloadableServerResources, HolderLookup.Provider, RegistryAccess)} instead. */ - @Deprecated(forRemoval = true, since = "1.21.4") - public AddReloadListenerEvent( - ReloadableServerResources serverResources, - RegistryAccess registryAccess - ) { - this( - serverResources, - registryAccess, - registryAccess - ); - } - - public AddReloadListenerEvent( - ReloadableServerResources serverResources, - HolderLookup.Provider registries, - @Deprecated(forRemoval = true, since = "1.21.4") RegistryAccess registryAccess - ) { + public AddReloadListenerEvent(ReloadableServerResources serverResources, HolderLookup.Provider registries) { this.serverResources = serverResources; this.registries = registries; - this.registryAccess = registryAccess; } /** @@ -71,7 +45,7 @@ public final class AddReloadListenerEvent extends MutableEvent { } public List getListeners() { - return ImmutableList.copyOf(listeners); + return List.copyOf(listeners); } /** @@ -98,23 +72,12 @@ public final class AddReloadListenerEvent extends MutableEvent { return registries; } - /** - * Provides access to the loaded registries associated with these server resources. - * All built-in and dynamic registries are loaded and frozen by this point. - * @return The RegistryAccess context for the currently active reload. - * @deprecated Does not contain updated tags. Use {@link #getRegistries()} instead. - */ - @Deprecated(forRemoval = true, since = "1.21.4") - public RegistryAccess getRegistryAccess() { - return registryAccess; - } - private record WrappedStateAwareListener(PreparableReloadListener wrapped) implements PreparableReloadListener { @Override - public CompletableFuture reload(final PreparationBarrier stage, final ResourceManager resourceManager, final Executor backgroundExecutor, final Executor gameExecutor) { + public CompletableFuture reload(SharedState state, Executor backgroundExecutor, PreparationBarrier stage, Executor gameExecutor) { if (ModLoader.isLoadingStateValid()) - return wrapped.reload(stage, resourceManager, backgroundExecutor, gameExecutor); + return wrapped.reload(state, backgroundExecutor, stage, gameExecutor); else return CompletableFuture.completedFuture(null); } diff --git a/src/main/java/net/minecraftforge/event/BuildCreativeModeTabContentsEvent.java b/src/main/java/net/minecraftforge/event/BuildCreativeModeTabContentsEvent.java index 2e1b4239f8..22d865862e 100644 --- a/src/main/java/net/minecraftforge/event/BuildCreativeModeTabContentsEvent.java +++ b/src/main/java/net/minecraftforge/event/BuildCreativeModeTabContentsEvent.java @@ -24,10 +24,7 @@ import java.util.function.Supplier; * Fired when the contents of a specific creative mode tab are being populated. * This event may be fired multiple times if the operator status of the local player or enabled feature flags changes. *

        - * This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. - *

        - * This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus}, - * only on the {@linkplain LogicalSide#CLIENT logical client}. + * This event is fired only on the {@linkplain LogicalSide#CLIENT logical client}. */ public final class BuildCreativeModeTabContentsEvent implements IModBusEvent, CreativeModeTab.Output { public static EventBus getBus(BusGroup modBusGroup) { diff --git a/src/main/java/net/minecraftforge/event/CommandEvent.java b/src/main/java/net/minecraftforge/event/CommandEvent.java index b4c435117d..49668375f9 100644 --- a/src/main/java/net/minecraftforge/event/CommandEvent.java +++ b/src/main/java/net/minecraftforge/event/CommandEvent.java @@ -8,29 +8,27 @@ package net.minecraftforge.event; import com.mojang.brigadier.ParseResults; import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.Commands; -import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.eventbus.api.bus.CancellableEventBus; import net.minecraftforge.eventbus.api.event.MutableEvent; import net.minecraftforge.eventbus.api.event.characteristic.Cancellable; import net.minecraftforge.fml.LogicalSide; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; /** * CommandEvent is fired after a command is parsed, but before it is executed. * This event is fired during the invocation of {@link Commands#performCommand(ParseResults, String)}. *

        - * This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. - * If the event is cancelled, the command will not be executed. + * This event is {@linkplain Cancellable cancellable}. If the event is cancelled, the command will not be executed. *

        - * This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus}, - * only on the {@linkplain LogicalSide#SERVER logical server}. + * This event is fired only on the {@linkplain LogicalSide#SERVER logical server}. **/ +@NullMarked public final class CommandEvent extends MutableEvent implements Cancellable { public static final CancellableEventBus BUS = CancellableEventBus.create(CommandEvent.class); private ParseResults parse; - @Nullable - private Throwable exception; + private @Nullable Throwable exception; public CommandEvent(ParseResults parse) { this.parse = parse; diff --git a/src/main/java/net/minecraftforge/event/DifficultyChangeEvent.java b/src/main/java/net/minecraftforge/event/DifficultyChangeEvent.java index c59c49ad77..e6f8317496 100644 --- a/src/main/java/net/minecraftforge/event/DifficultyChangeEvent.java +++ b/src/main/java/net/minecraftforge/event/DifficultyChangeEvent.java @@ -15,11 +15,7 @@ import net.minecraftforge.eventbus.api.event.RecordEvent; * DifficultyChangeEvent is fired when difficulty is changing.
        *
        * This event is fired via the {@link ForgeHooks#onDifficultyChange(Difficulty, Difficulty)}.
        - *
        - * This event does not have a result. {@link HasResult}
        - *
        - * This event is fired on the {@link MinecraftForge#EVENT_BUS}. - **/ + */ public record DifficultyChangeEvent(Difficulty getDifficulty, Difficulty getOldDifficulty) implements RecordEvent { public static final EventBus BUS = EventBus.create(DifficultyChangeEvent.class); } diff --git a/src/main/java/net/minecraftforge/event/ForgeEventFactory.java b/src/main/java/net/minecraftforge/event/ForgeEventFactory.java index 279db4c1ae..8f763b0d1f 100644 --- a/src/main/java/net/minecraftforge/event/ForgeEventFactory.java +++ b/src/main/java/net/minecraftforge/event/ForgeEventFactory.java @@ -13,6 +13,7 @@ import java.util.List; import java.util.Optional; import java.util.function.BooleanSupplier; import java.util.function.Consumer; +import java.util.function.IntConsumer; import net.minecraft.core.HolderLookup; import net.minecraft.core.component.DataComponentMap; @@ -55,6 +56,7 @@ import net.minecraft.server.network.ConfigurationTask; import net.minecraft.server.packs.PackType; import net.minecraft.server.packs.repository.RepositorySource; import net.minecraft.server.packs.resources.PreparableReloadListener; +import net.minecraft.server.players.NameAndId; import net.minecraft.server.players.PlayerList; import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundSource; @@ -204,17 +206,8 @@ import net.minecraftforge.fml.LogicalSide; @ApiStatus.Internal public final class ForgeEventFactory { - private static final ModLoader ML = ModLoader.get(); - private ForgeEventFactory() {} - /** - * Post an event to the {@link ModLoader#get()} event bus - */ - private static void postModBus(T e) { - ML.postEvent(e); - } - public static boolean onMultiBlockPlace(@Nullable Entity entity, List blockSnapshots, Direction direction) { var snap = blockSnapshots.getFirst(); var placedAgainst = snap.getLevel().getBlockState(snap.getPos().relative(direction.getOpposite())); @@ -240,7 +233,7 @@ public final class ForgeEventFactory { } public static void onPlayerDestroyItem(Player player, @NotNull ItemStack stack, @Nullable InteractionHand hand) { - onPlayerDestroyItem(player, stack, LivingEntity.getSlotForHand(hand)); + onPlayerDestroyItem(player, stack, hand.asEquipmentSlot()); } public static void onPlayerDestroyItem(Player player, @NotNull ItemStack stack, @Nullable EquipmentSlot slot) { @@ -414,10 +407,6 @@ public final class ForgeEventFactory { PlayerEvent.SaveToFile.BUS.post(new PlayerEvent.SaveToFile(player, playerDirectory, uuidString)); } - public static void firePlayerLoadingEvent(Player player, PlayerDataStorage playerFileData, String uuidString) { - PlayerEvent.LoadFromFile.BUS.post(new PlayerEvent.LoadFromFile(player, playerFileData.getPlayerDataFolder(), uuidString)); - } - @Nullable public static BlockState onToolUse(BlockState originalState, UseOnContext context, ToolAction toolAction, boolean simulate) { var event = new BlockToolModificationEvent(originalState, context, toolAction, simulate); @@ -431,7 +420,7 @@ public final class ForgeEventFactory { var event = new BonemealEvent(player, level, pos, state, stack); if (BonemealEvent.BUS.post(event)) return -1; if (event.getResult() == Result.ALLOW) { - if (!level.isClientSide) + if (!level.isClientSide()) stack.shrink(1); return 1; } @@ -695,20 +684,15 @@ public final class ForgeEventFactory { return SleepFinishedTimeEvent.BUS.fire(new SleepFinishedTimeEvent(level, newTime, minTime)).getNewTime(); } - @Deprecated(forRemoval = true, since = "1.21.4") - public static List onResourceReload(ReloadableServerResources serverResources, RegistryAccess registryAccess) { - return AddReloadListenerEvent.BUS.fire(new AddReloadListenerEvent(serverResources, registryAccess)).getListeners(); - } - - public static List onResourceReload(ReloadableServerResources serverResources, HolderLookup.Provider lookupProvider, @Deprecated(forRemoval = true, since = "1.21.4") RegistryAccess registryAccess) { - return AddReloadListenerEvent.BUS.fire(new AddReloadListenerEvent(serverResources, lookupProvider, registryAccess)).getListeners(); + public static List onResourceReload(ReloadableServerResources serverResources, HolderLookup.Provider lookupProvider) { + return AddReloadListenerEvent.BUS.fire(new AddReloadListenerEvent(serverResources, lookupProvider)).getListeners(); } public static void onCommandRegister(CommandDispatcher dispatcher, Commands.CommandSelection environment, CommandBuildContext context) { RegisterCommandsEvent.BUS.post(new RegisterCommandsEvent(dispatcher, environment, context)); } - public static boolean canLivingConvert(LivingEntity entity, EntityType outcome, Consumer timer) { + public static boolean canLivingConvert(LivingEntity entity, EntityType outcome, IntConsumer timer) { return !LivingConversionEvent.Pre.BUS.post(new LivingConversionEvent.Pre(entity, outcome, timer)); } @@ -740,9 +724,9 @@ public final class ForgeEventFactory { return EntityTeleportEvent.ChorusFruit.BUS.fire(new EntityTeleportEvent.ChorusFruit(entity, targetX, targetY, targetZ)); } - public static boolean onPermissionChanged(GameProfile gameProfile, int newLevel, PlayerList playerList) { + public static boolean onPermissionChanged(NameAndId gameProfile, int newLevel, PlayerList playerList) { var oldLevel = playerList.getServer().getProfilePermissions(gameProfile); - var player = playerList.getPlayer(gameProfile.getId()); + var player = playerList.getPlayer(gameProfile.id()); if (newLevel != oldLevel && player != null) return PermissionsChangedEvent.BUS.post(new PermissionsChangedEvent(player, newLevel, oldLevel)); return false; @@ -785,11 +769,11 @@ public final class ForgeEventFactory { } public static void onPreLevelTick(Level level, BooleanSupplier haveTime) { - TickEvent.LevelTickEvent.Pre.BUS.post(new TickEvent.LevelTickEvent.Pre(level.isClientSide ? LogicalSide.CLIENT : LogicalSide.SERVER, level, haveTime)); + TickEvent.LevelTickEvent.Pre.BUS.post(new TickEvent.LevelTickEvent.Pre(level.isClientSide() ? LogicalSide.CLIENT : LogicalSide.SERVER, level, haveTime)); } public static void onPostLevelTick(Level level, BooleanSupplier haveTime) { - TickEvent.LevelTickEvent.Post.BUS.post(new TickEvent.LevelTickEvent.Post(level.isClientSide ? LogicalSide.CLIENT : LogicalSide.SERVER, level, haveTime)); + TickEvent.LevelTickEvent.Post.BUS.post(new TickEvent.LevelTickEvent.Post(level.isClientSide() ? LogicalSide.CLIENT : LogicalSide.SERVER, level, haveTime)); } public static void onPreClientTick() { @@ -960,7 +944,7 @@ public final class ForgeEventFactory { // TODO: Remove from mod bus - Lex 04222024 public static void addPackFindersServer(Consumer consumer) { - postModBus(new AddPackFindersEvent(PackType.SERVER_DATA, consumer)); + ModLoader.postEvent(new AddPackFindersEvent(PackType.SERVER_DATA, consumer)); } public static boolean onEntityJoinLevel(Entity entity, Level level) { diff --git a/src/main/java/net/minecraftforge/event/LootTableLoadEvent.java b/src/main/java/net/minecraftforge/event/LootTableLoadEvent.java index 1962e575dd..36cd5507fb 100644 --- a/src/main/java/net/minecraftforge/event/LootTableLoadEvent.java +++ b/src/main/java/net/minecraftforge/event/LootTableLoadEvent.java @@ -7,28 +7,28 @@ package net.minecraftforge.event; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.level.storage.loot.LootTable; -import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.eventbus.api.bus.CancellableEventBus; import net.minecraftforge.eventbus.api.event.MutableEvent; import net.minecraftforge.eventbus.api.event.characteristic.Cancellable; import net.minecraftforge.fml.LogicalSide; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; /** * Fired when a {@link LootTable} is loaded from JSON. * Loot tables loaded from world save datapacks will not fire this event as they are considered user configuration files. * This event is fired whenever server resources are loaded or reloaded. * - *

        This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. - * If the event is cancelled, the loot table will be made empty.

        + *

        This event is {@linkplain Cancellable cancellable}. If the event is cancelled, the loot table will be made empty.

        * - *

        This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus}, - * only on the {@linkplain LogicalSide#SERVER logical server}.

        + *

        This event is fired only on the {@linkplain LogicalSide#SERVER logical server}.

        */ +@NullMarked public final class LootTableLoadEvent extends MutableEvent implements Cancellable { public static final CancellableEventBus BUS = CancellableEventBus.create(LootTableLoadEvent.class); private final ResourceLocation name; - private LootTable table; + private @Nullable LootTable table; public LootTableLoadEvent(ResourceLocation name, LootTable table) { this.name = name; @@ -39,11 +39,12 @@ public final class LootTableLoadEvent extends MutableEvent implements Cancellabl return this.name; } + @Nullable public LootTable getTable() { return this.table; } - public void setTable(LootTable table) { + public void setTable(@Nullable LootTable table) { this.table = table; } } diff --git a/src/main/java/net/minecraftforge/event/PlayLevelSoundEvent.java b/src/main/java/net/minecraftforge/event/PlayLevelSoundEvent.java index 0dd73edb9c..7e4ee0a2e6 100644 --- a/src/main/java/net/minecraftforge/event/PlayLevelSoundEvent.java +++ b/src/main/java/net/minecraftforge/event/PlayLevelSoundEvent.java @@ -33,12 +33,7 @@ import java.util.Objects; * {@link #getNewVolume()} contains the volume the sound will be played at. * {@link #getNewPitch()} contains the pitch the sound will be played at. *

        - * This event is {@link Cancelable cancelable}. - * If this event is canceled, the sound is not played. - *

        - * This event does not have a result. - *

        - * This event is fired on the {@link MinecraftForge#EVENT_BUS}. + * This event is {@linkplain Cancellable cancellable}. If this event is cancelled, the sound is not played. */ public sealed class PlayLevelSoundEvent extends MutableEvent implements Cancellable, InheritableEvent { public static final CancellableEventBus BUS = CancellableEventBus.create(PlayLevelSoundEvent.class); diff --git a/src/main/java/net/minecraftforge/event/RegisterStructureConversionsEvent.java b/src/main/java/net/minecraftforge/event/RegisterStructureConversionsEvent.java index 69b6ee352a..2487e3c506 100644 --- a/src/main/java/net/minecraftforge/event/RegisterStructureConversionsEvent.java +++ b/src/main/java/net/minecraftforge/event/RegisterStructureConversionsEvent.java @@ -7,7 +7,6 @@ package net.minecraftforge.event; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.datafix.fixes.StructuresBecomeConfiguredFix; -import net.minecraftforge.common.MinecraftForge; import java.util.Locale; import java.util.Map; @@ -15,7 +14,9 @@ import java.util.Map; import com.google.common.base.Preconditions; import net.minecraftforge.eventbus.api.bus.EventBus; import net.minecraftforge.eventbus.api.event.MutableEvent; +import net.minecraftforge.fml.LogicalSide; import org.jetbrains.annotations.ApiStatus; +import org.jspecify.annotations.NullMarked; /** * Fired for registering structure conversions for pre-1.18.2 worlds. This is used by {@link StructuresBecomeConfiguredFix} @@ -28,14 +29,12 @@ import org.jetbrains.annotations.ApiStatus; *

        This event will only fire if {@link StructuresBecomeConfiguredFix} is used, as a result of converting a * pre-1.18.2 world to the current version.

        * - *

        This event is not {@linkplain Cancelable cancelable}, and does not {@linkplain HasResult have a result}.

        - * - *

        This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus}, - * only on the {@linkplain net.minecraftforge.fml.LogicalSide#SERVER logical server}.

        + *

        This event is fired only on the {@linkplain LogicalSide#SERVER logical server}.

        * * @see StructuresBecomeConfiguredFix * @see #register(String, StructuresBecomeConfiguredFix.Conversion) */ +@NullMarked public final class RegisterStructureConversionsEvent extends MutableEvent { public static final EventBus BUS = EventBus.create(RegisterStructureConversionsEvent.class); diff --git a/src/main/java/net/minecraftforge/event/ServerChatEvent.java b/src/main/java/net/minecraftforge/event/ServerChatEvent.java index e6f580af8d..4bf438eb6e 100644 --- a/src/main/java/net/minecraftforge/event/ServerChatEvent.java +++ b/src/main/java/net/minecraftforge/event/ServerChatEvent.java @@ -9,23 +9,23 @@ import java.util.Objects; import net.minecraft.network.chat.Component; import net.minecraft.network.protocol.game.ServerboundChatPacket; import net.minecraft.server.level.ServerPlayer; -import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.eventbus.api.bus.CancellableEventBus; import net.minecraftforge.eventbus.api.event.MutableEvent; import net.minecraftforge.eventbus.api.event.characteristic.Cancellable; import net.minecraftforge.fml.LogicalSide; import org.jetbrains.annotations.ApiStatus; +import org.jspecify.annotations.NullMarked; /** * This event is fired whenever a {@link ServerboundChatPacket} is received from a client * who has submitted their chat message. *

        - * This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. + * This event is {@linkplain Cancellable cancellable}. * If the event is cancelled, the message will not be sent to clients. *

        - * This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus}, - * only on the {@linkplain LogicalSide#SERVER logical server}. + * This event is fired only on the {@linkplain LogicalSide#SERVER logical server}. **/ +@NullMarked public final class ServerChatEvent extends MutableEvent implements Cancellable { public static final CancellableEventBus BUS = CancellableEventBus.create(ServerChatEvent.class); @@ -37,7 +37,7 @@ public final class ServerChatEvent extends MutableEvent implements Cancellable { @ApiStatus.Internal public ServerChatEvent(ServerPlayer player, String rawText, Component message) { this.player = player; - this.username = player.getGameProfile().getName(); + this.username = player.getGameProfile().name(); this.rawText = rawText; this.message = message; } diff --git a/src/main/java/net/minecraftforge/event/TagsUpdatedEvent.java b/src/main/java/net/minecraftforge/event/TagsUpdatedEvent.java index cf1ab704fb..1290ab86ce 100644 --- a/src/main/java/net/minecraftforge/event/TagsUpdatedEvent.java +++ b/src/main/java/net/minecraftforge/event/TagsUpdatedEvent.java @@ -7,36 +7,21 @@ package net.minecraftforge.event; import net.minecraft.core.RegistryAccess; import net.minecraftforge.eventbus.api.bus.EventBus; -import net.minecraftforge.eventbus.api.event.MutableEvent; +import net.minecraftforge.eventbus.api.event.RecordEvent; /** * Fired when tags are updated on either server or client. This event can be used to refresh data that depends on tags. + * + * @param getRegistryAccess the dynamic registries that have had their tags rebound + * @param getUpdateCause the cause for this tag update + * @param isIntegratedServer whether this event is being fired on an integrated server */ -public final class TagsUpdatedEvent extends MutableEvent { +public record TagsUpdatedEvent(RegistryAccess getRegistryAccess, UpdateCause getUpdateCause, boolean isIntegratedServer) + implements RecordEvent { public static final EventBus BUS = EventBus.create(TagsUpdatedEvent.class); - private final RegistryAccess registryAccess; - private final UpdateCause updateCause; - private final boolean integratedServer; - public TagsUpdatedEvent(RegistryAccess registryAccess, boolean fromClientPacket, boolean isIntegratedServerConnection) { - this.registryAccess = registryAccess; - this.updateCause = fromClientPacket ? UpdateCause.CLIENT_PACKET_RECEIVED : UpdateCause.SERVER_DATA_LOAD; - this.integratedServer = isIntegratedServerConnection; - } - - /** - * @return The dynamic registries that have had their tags rebound. - */ - public RegistryAccess getRegistryAccess() { - return registryAccess; - } - - /** - * @return the cause for this tag update - */ - public UpdateCause getUpdateCause() { - return updateCause; + this(registryAccess, fromClientPacket ? UpdateCause.CLIENT_PACKET_RECEIVED : UpdateCause.SERVER_DATA_LOAD, isIntegratedServerConnection); } /** @@ -44,7 +29,7 @@ public final class TagsUpdatedEvent extends MutableEvent { * result of this event. Effectively this means that in single player only the server-side updates this data. */ public boolean shouldUpdateStaticData() { - return updateCause == UpdateCause.SERVER_DATA_LOAD || !integratedServer; + return getUpdateCause == UpdateCause.SERVER_DATA_LOAD || !isIntegratedServer; } /** diff --git a/src/main/java/net/minecraftforge/event/TickEvent.java b/src/main/java/net/minecraftforge/event/TickEvent.java index 278f02fdda..7f3f554895 100644 --- a/src/main/java/net/minecraftforge/event/TickEvent.java +++ b/src/main/java/net/minecraftforge/event/TickEvent.java @@ -14,135 +14,56 @@ import java.util.function.BooleanSupplier; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.level.Level; import net.minecraftforge.eventbus.api.bus.EventBus; -import net.minecraftforge.eventbus.api.event.InheritableEvent; -import net.minecraftforge.eventbus.api.event.MutableEvent; +import net.minecraftforge.eventbus.api.event.RecordEvent; import net.minecraftforge.fml.LogicalSide; +import org.jspecify.annotations.NullMarked; -public sealed class TickEvent extends MutableEvent implements InheritableEvent { - /** - * @deprecated Use one of the subclasses instead, as subscribing to the abstract {@link TickEvent} class will call - * your listener possibly hundreds of times per tick which is inefficient/slow and probably not what you want - */ - @Deprecated(forRemoval = true, since = "1.21.6") - public static final EventBus BUS = EventBus.create(TickEvent.class); - - public enum Type { - LEVEL, PLAYER, CLIENT, SERVER, RENDER - } - - public enum Phase { - START, END - } - - public final Type type; - public final LogicalSide side; - - /** - * @deprecated For better performance, add listeners to the Pre or Post event subclasses instead of checking the phase - */ - @Deprecated(forRemoval = true, since = "1.21.6") - public final Phase phase; - - public TickEvent(Type type, LogicalSide side, Phase phase) { - this.type = type; - this.side = side; - this.phase = phase; - } - - public static sealed class ServerTickEvent extends TickEvent { - /** - * @deprecated Use {@link ServerTickEvent.Pre} or {@link ServerTickEvent.Post} instead - */ - @Deprecated(forRemoval = true, since = "1.21.6") - public static final EventBus BUS = EventBus.create(ServerTickEvent.class); - - private final BooleanSupplier haveTime; - private final MinecraftServer server; - - protected ServerTickEvent(BooleanSupplier haveTime, MinecraftServer server, Phase phase) { - super(Type.SERVER, LogicalSide.SERVER, phase); - this.haveTime = haveTime; - this.server = server; - } +@NullMarked +public sealed interface TickEvent { + sealed interface ServerTickEvent extends TickEvent { + BooleanSupplier haveTimeSupplier(); /** * @return {@code true} whether the server has enough time to perform any * additional tasks (usually IO related) during the current tick, * otherwise {@code false} */ - public boolean haveTime() { - return this.haveTime.getAsBoolean(); + default boolean haveTime() { + return haveTimeSupplier().getAsBoolean(); } /** * {@return the server instance} */ - public MinecraftServer getServer() { - return server; - } + MinecraftServer server(); - public static final class Pre extends ServerTickEvent { + record Pre(BooleanSupplier haveTimeSupplier, MinecraftServer server) implements RecordEvent, ServerTickEvent { public static final EventBus

         BUS = EventBus.create(Pre.class);
        -
        -            public Pre(BooleanSupplier haveTime, MinecraftServer server) {
        -                super(haveTime, server, Phase.START);
        -            }
                 }
         
        -        public static final class Post extends ServerTickEvent {
        +        record Post(BooleanSupplier haveTimeSupplier, MinecraftServer server) implements RecordEvent, ServerTickEvent {
                     public static final EventBus BUS = EventBus.create(Post.class);
        -
        -            public Post(BooleanSupplier haveTime, MinecraftServer server) {
        -                super(haveTime, server, Phase.END);
        -            }
                 }
             }
         
        -    public static sealed class ClientTickEvent extends TickEvent {
        -        /**
        -         * @deprecated Use {@link ClientTickEvent.Pre} or {@link ClientTickEvent.Post} instead
        -         */
        -        @Deprecated(forRemoval = true, since = "1.21.6")
        -        public static final EventBus BUS = EventBus.create(ClientTickEvent.class);
        -
        -        protected ClientTickEvent(Phase phase) {
        -            super(Type.CLIENT, LogicalSide.CLIENT, phase);
        -        }
        -
        -        public static final class Pre extends ClientTickEvent {
        +    sealed interface ClientTickEvent extends TickEvent {
        +        record Pre() implements RecordEvent, ClientTickEvent {
                     public static final EventBus
         BUS = EventBus.create(Pre.class);
                     public static final Pre INSTANCE = new Pre();
        -
        -            public Pre() {
        -                super(Phase.START);
        -            }
                 }
         
        -        public static final class Post extends ClientTickEvent {
        +        record Post() implements RecordEvent, ClientTickEvent {
                     public static final EventBus BUS = EventBus.create(Post.class);
                     public static final Post INSTANCE = new Post();
        -
        -            public Post() {
        -                super(Phase.END);
        -            }
                 }
             }
         
        -    public static sealed class LevelTickEvent extends TickEvent {
        -        /**
        -         * @deprecated Use {@link LevelTickEvent.Pre} or {@link LevelTickEvent.Post} instead
        -         */
        -        @Deprecated(forRemoval = true, since = "1.21.6")
        -        public static final EventBus BUS = EventBus.create(LevelTickEvent.class);
        +    sealed interface LevelTickEvent extends TickEvent {
        +        LogicalSide side();
         
        -        public final Level level;
        -        private final BooleanSupplier haveTime;
        +        Level level();
         
        -        protected LevelTickEvent(LogicalSide side, Level level, BooleanSupplier haveTime, Phase phase) {
        -            super(Type.LEVEL, side, phase);
        -            this.level = level;
        -            this.haveTime = haveTime;
        -        }
        +        BooleanSupplier haveTimeSupplier();
         
                 /**
                  * @return {@code true} whether the server has enough time to perform any
        @@ -150,91 +71,46 @@ public sealed class TickEvent extends MutableEvent implements InheritableEvent {
                  * otherwise {@code false}
                  * @see ServerTickEvent#haveTime()
                  */
        -        public boolean haveTime() {
        -            return this.haveTime.getAsBoolean();
        +        default boolean haveTime() {
        +            return haveTimeSupplier().getAsBoolean();
                 }
         
        -        public static final class Pre extends LevelTickEvent {
        +        record Pre(LogicalSide side, Level level, BooleanSupplier haveTimeSupplier) implements RecordEvent, LevelTickEvent {
                     public static final EventBus
         BUS = EventBus.create(Pre.class);
        -
        -            public Pre(LogicalSide side, Level level, BooleanSupplier haveTime) {
        -                super(side, level, haveTime, Phase.START);
        -            }
                 }
         
        -        public static final class Post extends LevelTickEvent {
        +        record Post(LogicalSide side, Level level, BooleanSupplier haveTimeSupplier) implements RecordEvent, LevelTickEvent {
                     public static final EventBus BUS = EventBus.create(Post.class);
        -
        -            public Post(LogicalSide side, Level level, BooleanSupplier haveTime) {
        -                super(side, level, haveTime, Phase.END);
        -            }
                 }
             }
         
        -    public static sealed class PlayerTickEvent extends TickEvent {
        -        /**
        -         * @deprecated Use {@link PlayerTickEvent.Pre} or {@link PlayerTickEvent.Post} instead
        -         */
        -        @Deprecated(forRemoval = true, since = "1.21.6")
        -        public static final EventBus BUS = EventBus.create(PlayerTickEvent.class);
        +    sealed interface PlayerTickEvent extends TickEvent {
        +        LogicalSide side();
         
        -        public final Player player;
        -
        -        protected PlayerTickEvent(Player player, Phase phase) {
        -            super(Type.PLAYER, player instanceof ServerPlayer ? LogicalSide.SERVER : LogicalSide.CLIENT, phase);
        -            this.player = player;
        -        }
        -
        -        public static final class Pre extends PlayerTickEvent {
        +        record Pre(Player player, LogicalSide side) implements RecordEvent, PlayerTickEvent {
                     public static final EventBus
         BUS = EventBus.create(Pre.class);
         
                     public Pre(Player player) {
        -                super(player, Phase.START);
        +                this(player, player instanceof ServerPlayer ? LogicalSide.SERVER : LogicalSide.CLIENT);
                     }
                 }
         
        -        public static final class Post extends PlayerTickEvent {
        +        record Post(Player player, LogicalSide side) implements RecordEvent, PlayerTickEvent {
                     public static final EventBus BUS = EventBus.create(Post.class);
         
                     public Post(Player player) {
        -                super(player, Phase.END);
        +                this(player, player instanceof ServerPlayer ? LogicalSide.SERVER : LogicalSide.CLIENT);
                     }
                 }
             }
         
        -    public static sealed abstract class RenderTickEvent extends TickEvent {
        -        /**
        -         * @deprecated Use {@link RenderTickEvent.Pre} or {@link RenderTickEvent.Post} instead
        -         */
        -        @Deprecated(forRemoval = true, since = "1.21.6")
        -        public static final EventBus BUS = EventBus.create(RenderTickEvent.class);
        -
        -        private final DeltaTracker timer;
        -
        -        private RenderTickEvent(Phase phase, DeltaTracker timer) {
        -            super(Type.RENDER, LogicalSide.CLIENT, phase);
        -            this.timer = timer;
        -        }
        -
        -        public DeltaTracker getTimer() {
        -            return this.timer;
        -        }
        -
        -        public static final class Pre extends RenderTickEvent {
        +    sealed interface RenderTickEvent extends TickEvent {
        +        record Pre(DeltaTracker timer) implements RecordEvent, RenderTickEvent {
                     public static final EventBus
         BUS = EventBus.create(Pre.class);
        -
        -            public Pre(DeltaTracker timer) {
        -                super(Phase.START, timer);
        -            }
                 }
         
        -        public static final class Post extends RenderTickEvent {
        +        record Post(DeltaTracker timer) implements RecordEvent, RenderTickEvent {
                     public static final EventBus BUS = EventBus.create(Post.class);
        -
        -            public Post(DeltaTracker timer) {
        -                super(Phase.END, timer);
        -            }
                 }
        -
             }
         }
        diff --git a/src/main/java/net/minecraftforge/event/brewing/PlayerBrewedPotionEvent.java b/src/main/java/net/minecraftforge/event/brewing/PlayerBrewedPotionEvent.java
        index 66ff872095..85751cebe6 100644
        --- a/src/main/java/net/minecraftforge/event/brewing/PlayerBrewedPotionEvent.java
        +++ b/src/main/java/net/minecraftforge/event/brewing/PlayerBrewedPotionEvent.java
        @@ -9,26 +9,14 @@ import net.minecraft.world.entity.player.Player;
         import net.minecraft.world.item.ItemStack;
         import net.minecraftforge.event.entity.player.PlayerEvent;
         import net.minecraftforge.eventbus.api.bus.EventBus;
        -import org.jetbrains.annotations.NotNull;
        +import net.minecraftforge.eventbus.api.event.RecordEvent;
        +import org.jspecify.annotations.NullMarked;
         
         /**
          * This event is called when a player picks up a potion from a brewing stand.
        + * @param getStack The ItemStack of the potion.
          */
        -public final class PlayerBrewedPotionEvent extends PlayerEvent {
        +@NullMarked
        +public record PlayerBrewedPotionEvent(Player getEntity, ItemStack getStack) implements RecordEvent, PlayerEvent {
             public static final EventBus BUS = EventBus.create(PlayerBrewedPotionEvent.class);
        -
        -    private final ItemStack stack;
        -
        -    public PlayerBrewedPotionEvent(Player player, @NotNull ItemStack stack) {
        -        super(player);
        -        this.stack = stack;
        -    }
        -
        -    /**
        -     * The ItemStack of the potion.
        -     */
        -    @NotNull
        -    public ItemStack getStack() {
        -        return stack;
        -    }
         }
        diff --git a/src/main/java/net/minecraftforge/event/brewing/PotionBrewEvent.java b/src/main/java/net/minecraftforge/event/brewing/PotionBrewEvent.java
        index 46389df637..3d81cb587b 100644
        --- a/src/main/java/net/minecraftforge/event/brewing/PotionBrewEvent.java
        +++ b/src/main/java/net/minecraftforge/event/brewing/PotionBrewEvent.java
        @@ -13,8 +13,9 @@ import net.minecraftforge.eventbus.api.bus.EventBus;
         import net.minecraftforge.eventbus.api.event.InheritableEvent;
         import net.minecraftforge.eventbus.api.event.MutableEvent;
         import net.minecraftforge.eventbus.api.event.characteristic.Cancellable;
        -import org.jetbrains.annotations.NotNull;
        +import org.jspecify.annotations.NullMarked;
         
        +@NullMarked
         public sealed abstract class PotionBrewEvent extends MutableEvent implements InheritableEvent {
             public static final EventBus BUS = EventBus.create(PotionBrewEvent.class);
         
        @@ -24,13 +25,12 @@ public sealed abstract class PotionBrewEvent extends MutableEvent implements Inh
                 this.stacks = stacks;
             }
         
        -    @NotNull
             public ItemStack getItem(int index) {
                 if (index < 0 || index >= stacks.size()) return ItemStack.EMPTY;
                 return stacks.get(index);
             }
         
        -    public void setItem(int index, @NotNull ItemStack stack) {
        +    public void setItem(int index, ItemStack stack) {
                 if (index < stacks.size()) {
                     stacks.set(index, stack);
                 }
        diff --git a/src/main/java/net/minecraftforge/event/entity/EntityEvent.java b/src/main/java/net/minecraftforge/event/entity/EntityEvent.java
        index 59a262548b..e6ab1306f1 100644
        --- a/src/main/java/net/minecraftforge/event/entity/EntityEvent.java
        +++ b/src/main/java/net/minecraftforge/event/entity/EntityEvent.java
        @@ -7,49 +7,24 @@ package net.minecraftforge.event.entity;
         
         import net.minecraft.core.SectionPos;
         import net.minecraft.world.entity.Entity;
        -import net.minecraftforge.common.MinecraftForge;
         import net.minecraftforge.eventbus.api.bus.EventBus;
        -import net.minecraftforge.eventbus.api.event.InheritableEvent;
        -import net.minecraftforge.eventbus.api.event.MutableEvent;
        +import net.minecraftforge.eventbus.api.event.RecordEvent;
         
         /**
        - * EntityEvent is fired when an event involving any Entity occurs.
        - * If a method utilizes this {@link net.minecraftforge.eventbus.api.Event} as its parameter, the method will - * receive every child event of this class.
        - *
        - * {@link #entity} contains the entity that caused this event to occur.
        - *
        - * All children of this event are fired on the {@link MinecraftForge#EVENT_BUS}.
        - **/ -public class EntityEvent extends MutableEvent implements InheritableEvent { - public static final EventBus BUS = EventBus.create(EntityEvent.class); - - private final Entity entity; - - public EntityEvent(Entity entity) { - this.entity = entity; - } - - public Entity getEntity() { - return entity; - } + * EntityEvent is fired when an event involving any Entity occurs. + */ +public interface EntityEvent { + /** + * @return the entity that caused this event to occur. + */ + Entity getEntity(); /** - * EntityConstructing is fired when an Entity is being created.
        - * This event is fired within the constructor of the Entity.
        - *
        - * This event is not {@link net.minecraftforge.eventbus.api.Cancelable}.
        - *
        - * This event does not have a result. {@link HasResult}
        - *
        - * This event is fired on the {@link MinecraftForge#EVENT_BUS}.
        + * EntityConstructing is fired when an Entity is being created. + *

        This event is fired within the constructor of the Entity.

        **/ - public static final class EntityConstructing extends EntityEvent { + record EntityConstructing(Entity getEntity) implements RecordEvent, EntityEvent { public static final EventBus BUS = EventBus.create(EntityConstructing.class); - - public EntityConstructing(Entity entity) { - super(entity); - } } /** @@ -57,32 +32,18 @@ public class EntityEvent extends MutableEvent implements InheritableEvent { * Sections are 16x16x16 block grids of the world.
        * This event does not fire when a new entity is spawned, only when an entity moves from one section to another one. * Use {@link EntityJoinLevelEvent} to detect new entities joining the world. - *
        - * This event is not {@link net.minecraftforge.eventbus.api.Cancelable}.
        - *
        - * This event does not have a result. {@link HasResult} - *
        - * This event is fired on the {@link net.minecraftforge.common.MinecraftForge#EVENT_BUS}.
        **/ - public static final class EnteringSection extends EntityEvent { + record EnteringSection(Entity getEntity, long getPackedOldPos, long getPackedNewPos) + implements RecordEvent, EntityEvent { public static final EventBus BUS = EventBus.create(EnteringSection.class); - private final long packedOldPos; - private final long packedNewPos; - - public EnteringSection(Entity entity, long packedOldPos, long packedNewPos) { - super(entity); - this.packedOldPos = packedOldPos; - this.packedNewPos = packedNewPos; - } - /** * A packed version of the old section's position. This is to be used with the various methods in {@link SectionPos}, * such as {@link SectionPos#of(long)} or {@link SectionPos#x(long)} to avoid allocation. * @return the packed position of the old section */ public long getPackedOldPos() { - return packedOldPos; + return getPackedOldPos; } /** @@ -91,21 +52,21 @@ public class EntityEvent extends MutableEvent implements InheritableEvent { * @return the packed position of the new section */ public long getPackedNewPos() { - return packedNewPos; + return getPackedNewPos; } /** * @return the position of the old section */ public SectionPos getOldPos() { - return SectionPos.of(packedOldPos); + return SectionPos.of(getPackedOldPos); } /** * @return the position of the new section */ public SectionPos getNewPos() { - return SectionPos.of(packedNewPos); + return SectionPos.of(getPackedNewPos); } /** @@ -113,7 +74,7 @@ public class EntityEvent extends MutableEvent implements InheritableEvent { * section has changed. */ public boolean didChunkChange() { - return SectionPos.x(packedOldPos) != SectionPos.x(packedNewPos) || SectionPos.z(packedOldPos) != SectionPos.z(packedNewPos); + return SectionPos.x(getPackedOldPos) != SectionPos.x(getPackedNewPos) || SectionPos.z(getPackedOldPos) != SectionPos.z(getPackedNewPos); } } } diff --git a/src/main/java/net/minecraftforge/event/entity/EntityJoinLevelEvent.java b/src/main/java/net/minecraftforge/event/entity/EntityJoinLevelEvent.java index 014135e4cc..7497a2a664 100644 --- a/src/main/java/net/minecraftforge/event/entity/EntityJoinLevelEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/EntityJoinLevelEvent.java @@ -10,6 +10,7 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.chunk.LevelChunk; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.eventbus.api.bus.CancellableEventBus; +import net.minecraftforge.eventbus.api.event.RecordEvent; import net.minecraftforge.eventbus.api.event.characteristic.Cancellable; import net.minecraftforge.fml.LogicalSide; @@ -21,33 +22,25 @@ import net.minecraftforge.fml.LogicalSide; * Note: This event may be called before the underlying {@link LevelChunk} is promoted to {@link ChunkStatus#FULL}. * You will cause chunk loading deadlocks if you do not delay your world interactions. *

        - * This event is {@linkplain Cancelable cancellable} and does not {@linkplain HasResult have a result}. + * This event is {@linkplain Cancellable cancellable}. * If the event is canceled, the entity will not be added to the level. *

        * This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus} * on both logical sides. **/ -public final class EntityJoinLevelEvent extends EntityEvent implements Cancellable { +public record EntityJoinLevelEvent(Entity getEntity, Level getLevel, boolean loadedFromDisk) + implements Cancellable, EntityEvent, RecordEvent { public static final CancellableEventBus BUS = CancellableEventBus.create(EntityJoinLevelEvent.class); - private final Level level; - private final boolean loadedFromDisk; - public EntityJoinLevelEvent(Entity entity, Level level) { this(entity, level, false); } - public EntityJoinLevelEvent(Entity entity, Level level, boolean loadedFromDisk) { - super(entity); - this.level = level; - this.loadedFromDisk = loadedFromDisk; - } - /** * {@return the level that the entity is set to join} */ public Level getLevel() { - return level; + return getLevel; } /** diff --git a/src/main/java/net/minecraftforge/event/entity/EntityLeaveLevelEvent.java b/src/main/java/net/minecraftforge/event/entity/EntityLeaveLevelEvent.java index 17be51e519..c7b60649e0 100644 --- a/src/main/java/net/minecraftforge/event/entity/EntityLeaveLevelEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/EntityLeaveLevelEvent.java @@ -10,30 +10,21 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.entity.LevelCallback; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.eventbus.api.bus.EventBus; +import net.minecraftforge.eventbus.api.event.RecordEvent; /** * This event is fired whenever an {@link Entity} leaves a {@link Level}. * This event is fired whenever an entity is removed from the level in {@link LevelCallback#onTrackingEnd(Object)}. *

        - * This event is not {@linkplain Cancelable cancellable} and does not {@linkplain net.minecraftforge.eventbus.api.Event.HasResult have a result}. - *

        - * This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus} - * on both logical sides. + * This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus} on both logical sides. **/ -public final class EntityLeaveLevelEvent extends EntityEvent { +public record EntityLeaveLevelEvent(Entity getEntity, Level getLevel) implements RecordEvent, EntityEvent { public static final EventBus BUS = EventBus.create(EntityLeaveLevelEvent.class); - private final Level level; - - public EntityLeaveLevelEvent(Entity entity, Level level) { - super(entity); - this.level = level; - } - /** * {@return the level the entity is set to leave} */ public Level getLevel() { - return level; + return getLevel; } } diff --git a/src/main/java/net/minecraftforge/event/entity/EntityMobGriefingEvent.java b/src/main/java/net/minecraftforge/event/entity/EntityMobGriefingEvent.java index da59a89101..ec5695754a 100644 --- a/src/main/java/net/minecraftforge/event/entity/EntityMobGriefingEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/EntityMobGriefingEvent.java @@ -6,10 +6,11 @@ package net.minecraftforge.event.entity; import net.minecraft.world.entity.Entity; -import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.util.HasResult; import net.minecraftforge.common.util.Result; import net.minecraftforge.eventbus.api.bus.EventBus; +import net.minecraftforge.eventbus.api.event.MutableEvent; +import org.jspecify.annotations.NullMarked; /** * EntityMobGriefingEvent is fired when mob griefing is about to occur and allows an event listener to specify whether it should or not.
        @@ -21,15 +22,21 @@ import net.minecraftforge.eventbus.api.bus.EventBus; *

      • {@link Result#DEFAULT} means the {@code mobGriefing} game rule is used to determine the behaviour.
      • *
      • {@link Result#DENY} means this instance of mob griefing is not allowed.
      • *
      - * This event is fired on the {@link MinecraftForge#EVENT_BUS}. */ -public final class EntityMobGriefingEvent extends EntityEvent implements HasResult { +@NullMarked +public final class EntityMobGriefingEvent extends MutableEvent implements EntityEvent, HasResult { public static final EventBus BUS = EventBus.create(EntityMobGriefingEvent.class); + private final Entity entity; private Result result = Result.DEFAULT; public EntityMobGriefingEvent(Entity entity) { - super(entity); + this.entity = entity; + } + + @Override + public Entity getEntity() { + return entity; } @Override diff --git a/src/main/java/net/minecraftforge/event/entity/EntityMountEvent.java b/src/main/java/net/minecraftforge/event/entity/EntityMountEvent.java index f5cee87687..7d98123c08 100644 --- a/src/main/java/net/minecraftforge/event/entity/EntityMountEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/EntityMountEvent.java @@ -7,8 +7,8 @@ package net.minecraftforge.event.entity; import net.minecraft.world.entity.Entity; import net.minecraft.world.level.Level; -import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.eventbus.api.bus.CancellableEventBus; +import net.minecraftforge.eventbus.api.event.RecordEvent; import net.minecraftforge.eventbus.api.event.characteristic.Cancellable; /** @@ -16,48 +16,23 @@ import net.minecraftforge.eventbus.api.event.characteristic.Cancellable; * entityBeingMounted can be null, be sure to check for that. *
      *
      - * This event is {@link net.minecraftforge.eventbus.api.Cancelable}.
      - * If this event is canceled, the entity does not mount/dismount the other entity.
      - *
      - * This event does not have a result. {@link HasResult}
      - *
      - * This event is fired on the {@link MinecraftForge#EVENT_BUS}. - * + * This event is {@linkplain Cancellable cancellable}.
      + * If this event is cancelled, the entity does not mount/dismount the other entity. */ -public final class EntityMountEvent extends EntityEvent implements Cancellable { +public record EntityMountEvent( + Entity getEntityMounting, + Entity getEntityBeingMounted, + Level getLevel, + boolean isMounting +) implements Cancellable, EntityEvent, RecordEvent { public static final CancellableEventBus BUS = CancellableEventBus.create(EntityMountEvent.class); - private final Entity entityMounting; - private final Entity entityBeingMounted; - private final Level level; - - private final boolean isMounting; - - public EntityMountEvent(Entity entityMounting, Entity entityBeingMounted, Level level, boolean isMounting) { - super(entityMounting); - this.entityMounting = entityMounting; - this.entityBeingMounted = entityBeingMounted; - this.level = level; - this.isMounting = isMounting; - } - - public boolean isMounting() { - return isMounting; + @Override + public Entity getEntity() { + return getEntityMounting; } public boolean isDismounting() { return !isMounting; } - - public Entity getEntityMounting() { - return entityMounting; - } - - public Entity getEntityBeingMounted() { - return entityBeingMounted; - } - - public Level getLevel() { - return level; - } } diff --git a/src/main/java/net/minecraftforge/event/entity/EntityStruckByLightningEvent.java b/src/main/java/net/minecraftforge/event/entity/EntityStruckByLightningEvent.java index c458a0b981..9780cc6b3b 100644 --- a/src/main/java/net/minecraftforge/event/entity/EntityStruckByLightningEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/EntityStruckByLightningEvent.java @@ -7,36 +7,22 @@ package net.minecraftforge.event.entity; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LightningBolt; -import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.ForgeEventFactory; import net.minecraftforge.eventbus.api.bus.CancellableEventBus; +import net.minecraftforge.eventbus.api.event.RecordEvent; import net.minecraftforge.eventbus.api.event.characteristic.Cancellable; /** - * EntityStruckByLightningEvent is fired when an Entity is about to be struck by lightening.
      + * EntityStruckByLightningEvent is fired when an Entity is about to be struck by lightning.
      * This event is fired whenever an EntityLightningBolt is updated to strike an Entity in * {@link LightningBolt#tick()} via {@link ForgeEventFactory#onEntityStruckByLightning(Entity, LightningBolt)}.
      *
      - * {@link #lightning} contains the instance of EntityLightningBolt attempting to strike an entity.
      - *
      - * This event is {@link Cancelable}.
      - * If this event is canceled, the Entity is not struck by the lightening.
      - *
      - * This event does not have a result. {@link HasResult}
      - *
      - * This event is fired on the {@link MinecraftForge#EVENT_BUS}.
      - **/ -public final class EntityStruckByLightningEvent extends EntityEvent implements Cancellable { + * This event is {@linkplain Cancellable cancellable}.
      + * If this event is cancelled, the Entity is not struck by the lightning.
      + * + * @param getLightning the instance of EntityLightningBolt attempting to strike an entity. + */ +public record EntityStruckByLightningEvent(Entity getEntity, LightningBolt getLightning) + implements Cancellable, EntityEvent, RecordEvent { public static final CancellableEventBus BUS = CancellableEventBus.create(EntityStruckByLightningEvent.class); - - private final LightningBolt lightning; - - public EntityStruckByLightningEvent(Entity entity, LightningBolt lightning) { - super(entity); - this.lightning = lightning; - } - - public LightningBolt getLightning() { - return lightning; - } } diff --git a/src/main/java/net/minecraftforge/event/entity/EntityTeleportEvent.java b/src/main/java/net/minecraftforge/event/entity/EntityTeleportEvent.java index 09fc73ea62..d5a2bf4d0e 100644 --- a/src/main/java/net/minecraftforge/event/entity/EntityTeleportEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/EntityTeleportEvent.java @@ -13,6 +13,7 @@ import net.minecraft.world.phys.HitResult; import net.minecraft.world.phys.Vec3; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.eventbus.api.bus.CancellableEventBus; +import net.minecraftforge.eventbus.api.event.InheritableEvent; import net.minecraftforge.eventbus.api.event.characteristic.Cancellable; import net.minecraftforge.fml.LogicalSide; import org.jetbrains.annotations.ApiStatus; @@ -20,28 +21,29 @@ import org.jetbrains.annotations.Nullable; /** * EntityTeleportEvent is fired when an event involving any teleportation of an Entity occurs.
      - * If a method utilizes this {@link Event} as its parameter, the method will - * receive every child event of this class.
      - *
      * {@link #getTarget()} contains the target destination.
      * {@link #getPrev()} contains the entity's current position.
      - *
      - * All children of this event are fired on the {@link MinecraftForge#EVENT_BUS}.
      **/ -public sealed class EntityTeleportEvent extends EntityEvent implements Cancellable { +public sealed abstract class EntityTeleportEvent implements Cancellable, EntityEvent, InheritableEvent { public static final CancellableEventBus BUS = CancellableEventBus.create(EntityTeleportEvent.class); + private final Entity entity; protected double targetX; protected double targetY; protected double targetZ; - public EntityTeleportEvent(Entity entity, double targetX, double targetY, double targetZ) { - super(entity); + protected EntityTeleportEvent(Entity entity, double targetX, double targetY, double targetZ) { + this.entity = entity; this.targetX = targetX; this.targetY = targetY; this.targetZ = targetZ; } + @Override + public Entity getEntity() { + return entity; + } + public double getTargetX() { return targetX; } public void setTargetX(double targetX) { this.targetX = targetX; } public double getTargetY() { return targetY; } @@ -58,16 +60,9 @@ public sealed class EntityTeleportEvent extends EntityEvent implements Cancellab * EntityTeleportEvent.TeleportCommand is fired before a living entity is teleported * from use of {@link net.minecraft.server.commands.TeleportCommand}. *
      - * This event is {@link Cancelable}.
      - * If the event is not canceled, the entity will be teleported. + * This event is {@link Cancellable}. If the event is cancelled, the entity will not be teleported. *
      - * This event does not have a result. {@link HasResult}
      - *
      - * This event is fired on the {@link MinecraftForge#EVENT_BUS}.
      - *
      - * This event is only fired on the {@link LogicalSide#SERVER} side.
      - *
      - * If this event is canceled, the entity will not be teleported. + * This event is only fired on the {@link LogicalSide#SERVER} side. */ public static final class TeleportCommand extends EntityTeleportEvent { public static final CancellableEventBus BUS = CancellableEventBus.create(TeleportCommand.class); @@ -81,16 +76,9 @@ public sealed class EntityTeleportEvent extends EntityEvent implements Cancellab * EntityTeleportEvent.SpreadPlayersCommand is fired before a living entity is teleported * from use of {@link net.minecraft.server.commands.SpreadPlayersCommand}. *
      - * This event is {@link Cancelable}.
      - * If the event is not canceled, the entity will be teleported. + * This event is {@linkplain Cancellable cancellable}. If the event is cancelled, the entity will not be teleported. *
      - * This event does not have a result. {@link HasResult}
      - *
      - * This event is fired on the {@link MinecraftForge#EVENT_BUS}.
      - *
      - * This event is only fired on the {@link LogicalSide#SERVER} side.
      - *
      - * If this event is canceled, the entity will not be teleported. + * This event is only fired on the {@link LogicalSide#SERVER} side. */ public static final class SpreadPlayersCommand extends EntityTeleportEvent { public static final CancellableEventBus BUS = CancellableEventBus.create(SpreadPlayersCommand.class); @@ -103,16 +91,9 @@ public sealed class EntityTeleportEvent extends EntityEvent implements Cancellab /** * EntityTeleportEvent.EnderEntity is fired before an Enderman or Shulker randomly teleports. *
      - * This event is {@link Cancelable}.
      - * If the event is not canceled, the entity will be teleported. + * This event is {@linkplain Cancellable cancelable}. If the event is cancelled, the entity will not be teleported. *
      - * This event does not have a result. {@link HasResult}
      - *
      - * This event is fired on the {@link MinecraftForge#EVENT_BUS}.
      - *
      - * This event is only fired on the {@link LogicalSide#SERVER} side.
      - *
      - * If this event is canceled, the entity will not be teleported. + * This event is only fired on the {@link LogicalSide#SERVER} side. */ public static final class EnderEntity extends EntityTeleportEvent { public static final CancellableEventBus BUS = CancellableEventBus.create(EnderEntity.class); @@ -132,16 +113,9 @@ public sealed class EntityTeleportEvent extends EntityEvent implements Cancellab /** * EntityTeleportEvent.EnderPearl is fired before an Entity is teleported from an EnderPearlEntity. *
      - * This event is {@link Cancelable}.
      - * If the event is not canceled, the entity will be teleported. + * This event is {@linkplain Cancellable cancellable}. If the event is cancelled, the entity will not be teleported. *
      - * This event does not have a result. {@link HasResult}
      - *
      - * This event is fired on the {@link MinecraftForge#EVENT_BUS}.
      - *
      - * This event is only fired on the {@link LogicalSide#SERVER} side.
      - *
      - * If this event is canceled, the entity will not be teleported. + * This event is only fired on the {@link LogicalSide#SERVER} side. */ public static final class EnderPearl extends EntityTeleportEvent { public static final CancellableEventBus BUS = CancellableEventBus.create(EnderPearl.class); @@ -185,16 +159,9 @@ public sealed class EntityTeleportEvent extends EntityEvent implements Cancellab /** * EntityTeleportEvent.ChorusFruit is fired before a LivingEntity is teleported due to consuming Chorus Fruit. *
      - * This event is {@link Cancelable}.
      - * If the event is not canceled, the entity will be teleported. + * This event is {@linkplain Cancellable cancellable}. If the event is cancelled, the entity will not be teleported. *
      - * This event does not have a result. {@link HasResult}
      - *
      - * This event is fired on the {@link MinecraftForge#EVENT_BUS}.
      - *
      - * This event is only fired on the {@link LogicalSide#SERVER} side.
      - *
      - * If this event is canceled, the entity will not be teleported. + * This event is only fired on the {@link LogicalSide#SERVER} side. */ public static final class ChorusFruit extends EntityTeleportEvent { public static final CancellableEventBus BUS = CancellableEventBus.create(ChorusFruit.class); diff --git a/src/main/java/net/minecraftforge/event/entity/EntityTravelToDimensionEvent.java b/src/main/java/net/minecraftforge/event/entity/EntityTravelToDimensionEvent.java index 0f53c0d3d3..3cb6eba45b 100644 --- a/src/main/java/net/minecraftforge/event/entity/EntityTravelToDimensionEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/EntityTravelToDimensionEvent.java @@ -8,33 +8,19 @@ package net.minecraftforge.event.entity; import net.minecraft.world.entity.Entity; import net.minecraft.resources.ResourceKey; import net.minecraft.world.level.Level; -import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.eventbus.api.bus.CancellableEventBus; +import net.minecraftforge.eventbus.api.event.RecordEvent; import net.minecraftforge.eventbus.api.event.characteristic.Cancellable; /** * EntityTravelToDimensionEvent is fired before an Entity travels to a dimension.
      *
      - * {@link #dimension} contains the id of the dimension the entity is traveling to.
      - *
      - * This event is {@link net.minecraftforge.eventbus.api.Cancelable}.
      - * If this event is canceled, the Entity does not travel to the dimension.
      - *
      - * This event does not have a result. {@link HasResult}
      - *
      - * This event is fired on the {@link MinecraftForge#EVENT_BUS}.
      - **/ -public final class EntityTravelToDimensionEvent extends EntityEvent implements Cancellable { + * This event is {@linkplain Cancellable cancellable}.
      + * If this event is cancelled, the Entity does not travel to the dimension. + * + * @param getDimension the dimension the entity is travelling to + */ +public record EntityTravelToDimensionEvent(Entity getEntity, ResourceKey getDimension) + implements Cancellable, EntityEvent, RecordEvent { public static final CancellableEventBus BUS = CancellableEventBus.create(EntityTravelToDimensionEvent.class); - - private final ResourceKey dimension; - - public EntityTravelToDimensionEvent(Entity entity, ResourceKey dimension) { - super(entity); - this.dimension = dimension; - } - - public ResourceKey getDimension() { - return dimension; - } } diff --git a/src/main/java/net/minecraftforge/event/entity/ProjectileImpactEvent.java b/src/main/java/net/minecraftforge/event/entity/ProjectileImpactEvent.java index 16ef14e9a2..cb85587455 100644 --- a/src/main/java/net/minecraftforge/event/entity/ProjectileImpactEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/ProjectileImpactEvent.java @@ -5,11 +5,13 @@ package net.minecraftforge.event.entity; +import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.projectile.Projectile; import net.minecraft.world.phys.HitResult; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.ForgeEventFactory; import net.minecraftforge.eventbus.api.bus.EventBus; +import net.minecraftforge.eventbus.api.event.MutableEvent; import org.jetbrains.annotations.NotNull; import java.util.Objects; @@ -23,7 +25,7 @@ import java.util.Objects; * You can also directly set the {@link ImpactResult} to change the impact behaviour. * @see #setImpactResult(ImpactResult) */ -public final class ProjectileImpactEvent extends EntityEvent { +public final class ProjectileImpactEvent extends MutableEvent implements EntityEvent { public static final EventBus BUS = EventBus.create(ProjectileImpactEvent.class); private final HitResult ray; @@ -32,11 +34,15 @@ public final class ProjectileImpactEvent extends EntityEvent { private ImpactResult result = ImpactResult.DEFAULT; public ProjectileImpactEvent(Projectile projectile, HitResult ray) { - super(projectile); this.ray = ray; this.projectile = projectile; } + @Override + public Entity getEntity() { + return projectile; + } + public HitResult getRayTraceResult() { return ray; } diff --git a/src/main/java/net/minecraftforge/event/entity/item/ItemEvent.java b/src/main/java/net/minecraftforge/event/entity/item/ItemEvent.java index b51abe5bc6..99f67625e0 100644 --- a/src/main/java/net/minecraftforge/event/entity/item/ItemEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/item/ItemEvent.java @@ -7,7 +7,7 @@ package net.minecraftforge.event.entity.item; import net.minecraft.world.entity.item.ItemEntity; import net.minecraftforge.event.entity.EntityEvent; -import net.minecraftforge.eventbus.api.bus.EventBus; +import org.jspecify.annotations.NullMarked; /** * Base class for all {@link ItemEntity} events. Contains a reference to the @@ -15,26 +15,11 @@ import net.minecraftforge.eventbus.api.bus.EventBus; * additional useful data from the firing method that isn't already contained * within the ItemEntity instance. */ -public sealed class ItemEvent extends EntityEvent permits ItemExpireEvent, ItemTossEvent { - public static final EventBus BUS = EventBus.create(ItemEvent.class); - - private final ItemEntity itemEntity; - - /** - * Creates a new event for an {@link ItemEntity}. - * - * @param itemEntity The ItemEntity for this event - */ - public ItemEvent(ItemEntity itemEntity) { - super(itemEntity); - this.itemEntity = itemEntity; - } - +@NullMarked +public sealed interface ItemEvent extends EntityEvent permits ItemExpireEvent, ItemTossEvent { /** * The relevant {@link ItemEntity} for this event. */ @Override - public ItemEntity getEntity() { - return itemEntity; - } + ItemEntity getEntity(); } diff --git a/src/main/java/net/minecraftforge/event/entity/item/ItemExpireEvent.java b/src/main/java/net/minecraftforge/event/entity/item/ItemExpireEvent.java index 97e58df041..aeb8eaaf08 100644 --- a/src/main/java/net/minecraftforge/event/entity/item/ItemExpireEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/item/ItemExpireEvent.java @@ -7,17 +7,21 @@ package net.minecraftforge.event.entity.item; import net.minecraft.world.entity.item.ItemEntity; import net.minecraftforge.eventbus.api.bus.CancellableEventBus; +import net.minecraftforge.eventbus.api.event.MutableEvent; import net.minecraftforge.eventbus.api.event.characteristic.Cancellable; +import org.jspecify.annotations.NullMarked; /** * Event that is fired when an EntityItem's age has reached its maximum - * lifespan. Canceling this event will prevent the EntityItem from being - * flagged as dead, thus staying it's removal from the world. If canceled - * it will add more time to the entities life equal to extraLife. + * lifespan. Cancelling this event will prevent the EntityItem from being + * flagged as dead, thus staying its removal from the world.
      + * If cancelled, it will add more time to the entity's life equal to extraLife. */ -public final class ItemExpireEvent extends ItemEvent implements Cancellable { +@NullMarked +public final class ItemExpireEvent extends MutableEvent implements Cancellable, ItemEvent { public static final CancellableEventBus BUS = CancellableEventBus.create(ItemExpireEvent.class); + private final ItemEntity entityItem; private int extraLife; /** @@ -27,10 +31,15 @@ public final class ItemExpireEvent extends ItemEvent implements Cancellable { * @param extraLife The amount of time to be added to this entities lifespan if the event is canceled. */ public ItemExpireEvent(ItemEntity entityItem, int extraLife) { - super(entityItem); + this.entityItem = entityItem; this.setExtraLife(extraLife); } + @Override + public ItemEntity getEntity() { + return entityItem; + } + public int getExtraLife() { return extraLife; } diff --git a/src/main/java/net/minecraftforge/event/entity/item/ItemTossEvent.java b/src/main/java/net/minecraftforge/event/entity/item/ItemTossEvent.java index 60851aa293..08c3c126c9 100644 --- a/src/main/java/net/minecraftforge/event/entity/item/ItemTossEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/item/ItemTossEvent.java @@ -8,34 +8,20 @@ package net.minecraftforge.event.entity.item; import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.entity.player.Player; import net.minecraftforge.eventbus.api.bus.CancellableEventBus; +import net.minecraftforge.eventbus.api.event.RecordEvent; import net.minecraftforge.eventbus.api.event.characteristic.Cancellable; +import org.jspecify.annotations.NullMarked; /** * Event that is fired whenever a player tosses (Q) an item or drag-n-drops a - * stack of items outside the inventory GUI screens. Canceling the event will + * stack of items outside the inventory GUI screens. Cancelling the event will * stop the items from entering the world, but will not prevent them being * removed from the inventory - and thus removed from the system. + * + * @param getEntity The EntityItem being tossed. + * @param getPlayer The player tossing the item. */ -public final class ItemTossEvent extends ItemEvent implements Cancellable { +@NullMarked +public record ItemTossEvent(ItemEntity getEntity, Player getPlayer) implements Cancellable, ItemEvent, RecordEvent { public static final CancellableEventBus BUS = CancellableEventBus.create(ItemTossEvent.class); - - private final Player player; - - /** - * Creates a new event for EntityItems tossed by a player. - * - * @param entityItem The EntityItem being tossed. - * @param player The player tossing the item. - */ - public ItemTossEvent(ItemEntity entityItem, Player player) { - super(entityItem); - this.player = player; - } - - /** - * The player tossing the item. - */ - public Player getPlayer() { - return player; - } } diff --git a/src/main/java/net/minecraftforge/event/entity/living/AnimalTameEvent.java b/src/main/java/net/minecraftforge/event/entity/living/AnimalTameEvent.java index bea4e208b1..593154fa79 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/AnimalTameEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/AnimalTameEvent.java @@ -5,37 +5,25 @@ package net.minecraftforge.event.entity.living; +import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.animal.Animal; import net.minecraft.world.entity.player.Player; -import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.ForgeEventFactory; import net.minecraftforge.eventbus.api.bus.CancellableEventBus; +import net.minecraftforge.eventbus.api.event.RecordEvent; import net.minecraftforge.eventbus.api.event.characteristic.Cancellable; /** * This event is fired when an {@link Animal} is tamed.
      * It is fired via {@link ForgeEventFactory#onAnimalTame(Animal, Player)}. * Forge fires this event for applicable vanilla animals, mods need to fire it themselves. - * This event is {@link net.minecraftforge.eventbus.api.Cancelable}. If canceled, taming the animal will fail. - * This event is fired on the {@link MinecraftForge#EVENT_BUS}. + * This event is {@linkplain Cancellable cancellable}. If cancelled, taming the animal will fail. */ -public final class AnimalTameEvent extends LivingEvent implements Cancellable { +public record AnimalTameEvent(Animal getAnimal, Player getTamer) implements Cancellable, LivingEvent, RecordEvent { public static final CancellableEventBus BUS = CancellableEventBus.create(AnimalTameEvent.class); - private final Animal animal; - private final Player tamer; - - public AnimalTameEvent(Animal animal, Player tamer) { - super(animal); - this.animal = animal; - this.tamer = tamer; - } - - public Animal getAnimal() { - return animal; - } - - public Player getTamer() { - return tamer; + @Override + public LivingEntity getEntity() { + return getAnimal; } } diff --git a/src/main/java/net/minecraftforge/event/entity/living/LivingAttackEvent.java b/src/main/java/net/minecraftforge/event/entity/living/LivingAttackEvent.java index e772819b86..d16396a84d 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/LivingAttackEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/LivingAttackEvent.java @@ -7,10 +7,10 @@ package net.minecraftforge.event.entity.living; import net.minecraft.world.entity.player.Player; import net.minecraftforge.common.ForgeHooks; -import net.minecraftforge.common.MinecraftForge; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.LivingEntity; import net.minecraftforge.eventbus.api.bus.CancellableEventBus; +import net.minecraftforge.eventbus.api.event.RecordEvent; import net.minecraftforge.eventbus.api.event.characteristic.Cancellable; /** @@ -21,28 +21,13 @@ import net.minecraftforge.eventbus.api.event.characteristic.Cancellable; *
      * This event is fired via the {@link ForgeHooks#onLivingAttack(LivingEntity, DamageSource, float)}.
      *
      - * {@link #source} contains the DamageSource of the attack.
      - * {@link #amount} contains the amount of damage dealt to the entity.
      - *
      - * This event is {@link net.minecraftforge.eventbus.api.Cancelable}.
      - * If this event is canceled, the Entity does not take attack damage.
      - *
      - * This event does not have a result. {@link HasResult}
      - *
      - * This event is fired on the {@link MinecraftForge#EVENT_BUS}. - **/ -public final class LivingAttackEvent extends LivingEvent implements Cancellable { + * This event is {@linkplain Cancellable cancellable}.
      + * If this event is canceled, the Entity does not take attack damage. + * + * @param getSource the source of the attack + * @param getAmount the amount of damage dealt to the entity + */ +public record LivingAttackEvent(LivingEntity getEntity, DamageSource getSource, float getAmount) + implements Cancellable, LivingEvent, RecordEvent { public static final CancellableEventBus BUS = CancellableEventBus.create(LivingAttackEvent.class); - - private final DamageSource source; - private final float amount; - - public LivingAttackEvent(LivingEntity entity, DamageSource source, float amount) { - super(entity); - this.source = source; - this.amount = amount; - } - - public DamageSource getSource() { return source; } - public float getAmount() { return amount; } } diff --git a/src/main/java/net/minecraftforge/event/entity/living/LivingBreatheEvent.java b/src/main/java/net/minecraftforge/event/entity/living/LivingBreatheEvent.java index 30ca0d9176..0ed8a77ad5 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/LivingBreatheEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/LivingBreatheEvent.java @@ -6,26 +6,21 @@ package net.minecraftforge.event.entity.living; import net.minecraftforge.eventbus.api.bus.EventBus; +import net.minecraftforge.eventbus.api.event.MutableEvent; import org.jetbrains.annotations.ApiStatus; import net.minecraft.world.entity.LivingEntity; import net.minecraftforge.common.ForgeHooks; -import net.minecraftforge.common.MinecraftForge; /** * LivingBreatheEvent is fired whenever a living entity ticks.
      *
      * This event is fired via {@link ForgeHooks#onLivingBreathe(LivingEntity, int, int)}.
      - *
      - * This event is not {@link Cancelable}.
      - *
      - * This event does not have a result. {@link HasResult} - *
      - * This event is fired on {@link MinecraftForge#EVENT_BUS} */ -public final class LivingBreatheEvent extends LivingEvent { +public final class LivingBreatheEvent extends MutableEvent implements LivingEvent { public static final EventBus BUS = EventBus.create(LivingBreatheEvent.class); + private final LivingEntity entity; private boolean canBreathe; private boolean canRefillAir; private int consumeAirAmount; @@ -33,13 +28,18 @@ public final class LivingBreatheEvent extends LivingEvent { @ApiStatus.Internal public LivingBreatheEvent(LivingEntity entity, boolean canBreathe, int consumeAirAmount, int refillAirAmount, boolean canRefillAir) { - super(entity); + this.entity = entity; this.canBreathe = canBreathe; this.canRefillAir = canRefillAir; this.consumeAirAmount = Math.max(consumeAirAmount, 0); this.refillAirAmount = Math.max(refillAirAmount, 0); } + @Override + public LivingEntity getEntity() { + return entity; + } + /** * If the entity can breathe and {@link #canRefillAir()} returns true, their air value will be increased by {@link #getRefillAirAmount()}.
      * If the entity can breathe and {@link #canRefillAir()} returns false, their air value will stay the same.
      diff --git a/src/main/java/net/minecraftforge/event/entity/living/LivingChangeTargetEvent.java b/src/main/java/net/minecraftforge/event/entity/living/LivingChangeTargetEvent.java index 852d5343eb..42800e7fa6 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/LivingChangeTargetEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/LivingChangeTargetEvent.java @@ -9,8 +9,8 @@ import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.ai.behavior.StartAttacking; import net.minecraftforge.common.ForgeHooks; -import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.eventbus.api.bus.CancellableEventBus; +import net.minecraftforge.eventbus.api.event.MutableEvent; import net.minecraftforge.eventbus.api.event.characteristic.Cancellable; /** @@ -25,29 +25,31 @@ import net.minecraftforge.eventbus.api.event.characteristic.Cancellable; * The return value can be affected by calling {@link #setNewTarget(LivingEntity)}.
      * {@link #getTargetType()} returns the target type that caused the change of targets.
      *
      - * This event is {@link net.minecraftforge.eventbus.api.Cancelable}.
      + * This event is {@linkplain Cancellable cancellable}.
      *
      * If you cancel this event, the target will not be changed and it will stay the same. * Cancelling this event will prevent {@link LivingSetAttackTargetEvent} from being posted.
      - *
      - * This event does not have a result. {@link HasResult}
      - *
      - * This event is fired on the {@link MinecraftForge#EVENT_BUS}. */ -public final class LivingChangeTargetEvent extends LivingEvent implements Cancellable { +public final class LivingChangeTargetEvent extends MutableEvent implements Cancellable, LivingEvent { public static final CancellableEventBus BUS = CancellableEventBus.create(LivingChangeTargetEvent.class); + private final LivingEntity entity; private final ILivingTargetType targetType; private final LivingEntity originalTarget; private LivingEntity newTarget; public LivingChangeTargetEvent(LivingEntity entity, LivingEntity originalTarget, ILivingTargetType targetType) { - super(entity); + this.entity = entity; this.originalTarget = originalTarget; this.newTarget = originalTarget; this.targetType = targetType; } + @Override + public LivingEntity getEntity() { + return entity; + } + /** * {@return the new target of this entity.} */ diff --git a/src/main/java/net/minecraftforge/event/entity/living/LivingConversionEvent.java b/src/main/java/net/minecraftforge/event/entity/living/LivingConversionEvent.java index a39a0ac7a9..6c994a22c1 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/LivingConversionEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/LivingConversionEvent.java @@ -12,52 +12,55 @@ import net.minecraftforge.eventbus.api.bus.EventBus; import net.minecraftforge.eventbus.api.event.InheritableEvent; import net.minecraftforge.eventbus.api.event.characteristic.Cancellable; -import java.util.function.Consumer; +import java.util.function.IntConsumer; /** * Currently known conversions: - * Pig -> Zombie Piglin when struck by lightning - * Villager -> Zombie Villager when killed by a zombie - * Zombie -> Drowned when under water - * Husk -> Zombie when under water - * Zombie Villager -> Villager - * Hoglin -> Zogline when in overworld - * Piglin/Piglin Brute -> Zombie Pigman when in overworld - * Villager -> Witch when struck by lightning - * Skeleton -> Stray when sitting in snow - * Tadpole -> Frog when it grows up - * Mushroom Cow -> Cow when sheared + *
        + *
      • Pig -> Zombie Piglin when struck by lightning
      • + *
      • Villager -> Zombie Villager when killed by a zombie
      • + *
      • Zombie -> Drowned when under water
      • + *
      • Husk -> Zombie when under water
      • + *
      • Zombie Villager -> Villager
      • + *
      • Hoglin -> Zoglin when in overworld
      • + *
      • Piglin/Piglin Brute -> Zombie Pigman when in overworld
      • + *
      • Villager -> Witch when struck by lightning
      • + *
      • Skeleton -> Stray when sitting in snow
      • + *
      • Tadpole -> Frog when it grows up
      • + *
      • Mushroom Cow -> Cow when sheared
      • + *
      */ -public sealed class LivingConversionEvent extends LivingEvent implements InheritableEvent { - public static final EventBus BUS = EventBus.create(LivingConversionEvent.class); - - public LivingConversionEvent(LivingEntity entity) { - super(entity); - } +public sealed interface LivingConversionEvent extends LivingEvent, InheritableEvent { + EventBus BUS = EventBus.create(LivingConversionEvent.class); /** * LivingConversionEvent.Pre is triggered when an entity is trying * to replace itself with another entity - * + *
      * This event may trigger every tick even if it was cancelled last tick * for entities like Zombies and Hoglins. To prevent it, the conversion * timer needs to be changed or reset - * - * This event is {@link Cancelable} - * If cancelled, the replacement will not occur + *
      + * This event is {@linkplain Cancellable}. If cancelled, the replacement will not occur */ - public static final class Pre extends LivingConversionEvent implements Cancellable { + final class Pre implements Cancellable, LivingConversionEvent { public static final CancellableEventBus
       BUS = CancellableEventBus.create(Pre.class);
       
      +        private final LivingEntity entity;
               private final EntityType outcome;
      -        private final Consumer timer;
      +        private final IntConsumer timer;
       
      -        public Pre(LivingEntity entity, EntityType outcome, Consumer timer) {
      -            super(entity);
      +        public Pre(LivingEntity entity, EntityType outcome, IntConsumer timer) {
      +            this.entity = entity;
                   this.outcome = outcome;
                   this.timer = timer;
               }
       
      +        @Override
      +        public LivingEntity getEntity() {
      +            return entity;
      +        }
      +
               /**
                * Gets the entity type of the new entity this living entity is
                * converting to
      @@ -84,24 +87,10 @@ public sealed class LivingConversionEvent extends LivingEvent implements Inherit
            * LivingConversionEvent.Post is triggered when an entity is replacing
            * itself with another entity.
            * The old living entity is likely to be removed right after this event.
      +     *
      +     * @param getOutcome Gets the finalized new entity (with all data like potion effect and equipments set)
            */
      -    public static final class Post extends LivingConversionEvent {
      +    record Post(LivingEntity getEntity, LivingEntity getOutcome) implements LivingConversionEvent {
               public static final EventBus BUS = EventBus.create(Post.class);
      -
      -        private final LivingEntity outcome;
      -
      -        public Post(LivingEntity entity, LivingEntity outcome) {
      -            super(entity);
      -            this.outcome = outcome;
      -        }
      -
      -        /**
      -         * Gets the finalized new entity (with all data like potion
      -         * effect and equipments set)
      -         * @return the finalized new entity
      -         */
      -        public LivingEntity getOutcome() {
      -            return outcome;
      -        }
           }
       }
      diff --git a/src/main/java/net/minecraftforge/event/entity/living/LivingDamageEvent.java b/src/main/java/net/minecraftforge/event/entity/living/LivingDamageEvent.java
      index 212faf0e53..4dc7bc9b37 100644
      --- a/src/main/java/net/minecraftforge/event/entity/living/LivingDamageEvent.java
      +++ b/src/main/java/net/minecraftforge/event/entity/living/LivingDamageEvent.java
      @@ -9,6 +9,7 @@ import net.minecraftforge.common.ForgeHooks;
       import net.minecraft.world.damagesource.DamageSource;
       import net.minecraft.world.entity.LivingEntity;
       import net.minecraftforge.eventbus.api.bus.CancellableEventBus;
      +import net.minecraftforge.eventbus.api.event.MutableEvent;
       import net.minecraftforge.eventbus.api.event.characteristic.Cancellable;
       
       /**
      @@ -24,24 +25,29 @@ import net.minecraftforge.eventbus.api.event.characteristic.Cancellable;
        * {@link #source} contains the DamageSource that caused this Entity to be hurt. 
      * {@link #amount} contains the final amount of damage that will be dealt to entity.
      *
      - * This event is {@link Cancelable}.
      - * If this event is canceled, the Entity is not hurt. Used resources WILL NOT be restored.
      - *
      - * This event does not have a result. {@link HasResult}
      + * This event is {@linkplain Cancellable cancellable}.
      + * If this event is cancelled, the Entity is not hurt. Used resources WILL NOT be restored.
      + * * @see LivingHurtEvent **/ -public final class LivingDamageEvent extends LivingEvent implements Cancellable { +public final class LivingDamageEvent extends MutableEvent implements Cancellable, LivingEvent { public static final CancellableEventBus BUS = CancellableEventBus.create(LivingDamageEvent.class); + private final LivingEntity entity; private final DamageSource source; private float amount; public LivingDamageEvent(LivingEntity entity, DamageSource source, float amount) { - super(entity); + this.entity = entity; this.source = source; this.amount = amount; } + @Override + public LivingEntity getEntity() { + return entity; + } + public DamageSource getSource() { return source; } public float getAmount() { return amount; } diff --git a/src/main/java/net/minecraftforge/event/entity/living/LivingDeathEvent.java b/src/main/java/net/minecraftforge/event/entity/living/LivingDeathEvent.java index e5652c0e56..2f8d69047b 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/LivingDeathEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/LivingDeathEvent.java @@ -7,11 +7,11 @@ package net.minecraftforge.event.entity.living; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.player.Player; -import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.ForgeEventFactory; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.LivingEntity; import net.minecraftforge.eventbus.api.bus.CancellableEventBus; +import net.minecraftforge.eventbus.api.event.RecordEvent; import net.minecraftforge.eventbus.api.event.characteristic.Cancellable; /** @@ -23,27 +23,11 @@ import net.minecraftforge.eventbus.api.event.characteristic.Cancellable; *
      * This event is fired via the {@link ForgeEventFactory#onLivingDeath(LivingEntity, DamageSource)}.
      *
      - * {@link #source} contains the DamageSource that caused the entity to die.
      - *
      - * This event is {@link Cancelable}.
      - * If this event is canceled, the Entity does not die.
      - *
      - * This event does not have a result. {@link HasResult}
      - *
      - * This event is fired on the {@link MinecraftForge#EVENT_BUS}. - **/ -public final class LivingDeathEvent extends LivingEvent implements Cancellable { + * This event is {@linkplain Cancellable cancellable}. If this event is cancelled, the Entity does not die. + * + * @param getSource the source of the damage that caused the entity to die + */ +public record LivingDeathEvent(LivingEntity getEntity, DamageSource getSource) + implements Cancellable, LivingEvent, RecordEvent { public static final CancellableEventBus BUS = CancellableEventBus.create(LivingDeathEvent.class); - - private final DamageSource source; - - public LivingDeathEvent(LivingEntity entity, DamageSource source) { - super(entity); - this.source = source; - } - - public DamageSource getSource() - { - return source; - } } diff --git a/src/main/java/net/minecraftforge/event/entity/living/LivingDestroyBlockEvent.java b/src/main/java/net/minecraftforge/event/entity/living/LivingDestroyBlockEvent.java index c09dfcbfef..4cdea3752a 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/LivingDestroyBlockEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/LivingDestroyBlockEvent.java @@ -11,39 +11,17 @@ import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.entity.LivingEntity; import net.minecraft.core.BlockPos; -import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.eventbus.api.bus.CancellableEventBus; +import net.minecraftforge.eventbus.api.event.RecordEvent; import net.minecraftforge.eventbus.api.event.characteristic.Cancellable; /** - * Fired when the ender dragon or wither attempts to destroy a block and when ever a zombie attempts to break a door. Basically a event version of {@link Block#canEntityDestroy(BlockState, BlockGetter, BlockPos, Entity)}
      + * Fired when the ender dragon or wither attempts to destroy a block and when ever a zombie attempts to break a door. + * Basically an event version of {@link Block#canEntityDestroy(BlockState, BlockGetter, BlockPos, Entity)}
      *
      - * This event is {@link Cancelable}.
      - * If this event is canceled, the block will not be destroyed.
      - *
      - * This event does not have a result. {@link HasResult}
      - *
      - * This event is fired on the {@link MinecraftForge#EVENT_BUS}. + * This event is {@linkplain Cancellable cancellable}. If this event is cancelled, the block will not be destroyed. **/ -public final class LivingDestroyBlockEvent extends LivingEvent implements Cancellable { +public record LivingDestroyBlockEvent(LivingEntity getEntity, BlockPos getPos, BlockState getState) + implements Cancellable, LivingEvent, RecordEvent { public static final CancellableEventBus BUS = CancellableEventBus.create(LivingDestroyBlockEvent.class); - - private final BlockPos pos; - private final BlockState state; - - public LivingDestroyBlockEvent(LivingEntity entity, BlockPos pos, BlockState state) { - super(entity); - this.pos = pos; - this.state = state; - } - - public BlockState getState() - { - return state; - } - - public BlockPos getPos() - { - return pos; - } } diff --git a/src/main/java/net/minecraftforge/event/entity/living/LivingDropsEvent.java b/src/main/java/net/minecraftforge/event/entity/living/LivingDropsEvent.java index 1f36157fa8..48f78adaab 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/LivingDropsEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/LivingDropsEvent.java @@ -10,9 +10,9 @@ import java.util.Collection; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.entity.LivingEntity; -import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.ForgeEventFactory; import net.minecraftforge.eventbus.api.bus.CancellableEventBus; +import net.minecraftforge.eventbus.api.event.RecordEvent; import net.minecraftforge.eventbus.api.event.characteristic.Cancellable; /** @@ -22,41 +22,17 @@ import net.minecraftforge.eventbus.api.event.characteristic.Cancellable; *
      * This event is fired via the {@link ForgeEventFactory#onLivingDrops(LivingEntity, DamageSource, Collection, int, boolean)} .
      *
      - * {@link #source} contains the DamageSource that caused the drop to occur.
      - * {@link #drops} contains the ArrayList of EntityItems that will be dropped.
      - * {@link #lootingLevel} contains the amount of loot that will be dropped.
      - * {@link #recentlyHit} determines whether the Entity doing the drop has recently been damaged.
      + * @param getSource contains the DamageSource that caused the drop to occur. + * @param getDrops contains the ArrayList of EntityItems that will be dropped. + * @param isRecentlyHit determines whether the Entity doing the drop has recently been damaged. *
      - * This event is {@link Cancelable}.
      - * If this event is canceled, the Entity does not drop anything.
      - *
      - * This event does not have a result. {@link HasResult}
      - *
      - * This event is fired on the {@link MinecraftForge#EVENT_BUS}. - **/ -public final class LivingDropsEvent extends LivingEvent implements Cancellable { + * This event is {@linkplain Cancellable cancellable}. If this event is cancelled, the Entity does not drop anything. + */ +public record LivingDropsEvent( + LivingEntity getEntity, + DamageSource getSource, + Collection getDrops, + boolean isRecentlyHit +) implements Cancellable, LivingEvent, RecordEvent { public static final CancellableEventBus BUS = CancellableEventBus.create(LivingDropsEvent.class); - - private final DamageSource source; - private final Collection drops; - private final boolean recentlyHit; - - public LivingDropsEvent(LivingEntity entity, DamageSource source, Collection drops, boolean recentlyHit) { - super(entity); - this.source = source; - this.drops = drops; - this.recentlyHit = recentlyHit; - } - - public DamageSource getSource() { - return source; - } - - public Collection getDrops() { - return drops; - } - - public boolean isRecentlyHit() { - return recentlyHit; - } } diff --git a/src/main/java/net/minecraftforge/event/entity/living/LivingDrownEvent.java b/src/main/java/net/minecraftforge/event/entity/living/LivingDrownEvent.java index 107c684ad7..372c51d140 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/LivingDrownEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/LivingDrownEvent.java @@ -6,6 +6,7 @@ package net.minecraftforge.event.entity.living; import net.minecraftforge.eventbus.api.bus.CancellableEventBus; +import net.minecraftforge.eventbus.api.event.MutableEvent; import net.minecraftforge.eventbus.api.event.characteristic.Cancellable; import org.jetbrains.annotations.ApiStatus; @@ -24,9 +25,10 @@ import net.minecraftforge.common.ForgeHooks; * a value of {@code false}. *

      **/ -public final class LivingDrownEvent extends LivingEvent implements Cancellable { +public final class LivingDrownEvent extends MutableEvent implements Cancellable, LivingEvent { public static final CancellableEventBus BUS = CancellableEventBus.create(LivingDrownEvent.class); + private final LivingEntity entity; private boolean isDrowning; private float damageAmount; private int bubbleCount; @@ -41,12 +43,17 @@ public final class LivingDrownEvent extends LivingEvent implements Cancellable { */ @ApiStatus.Internal public LivingDrownEvent(LivingEntity entity, boolean isDrowning, float damageAmount, int bubbleCount) { - super(entity); + this.entity = entity; this.isDrowning = isDrowning; this.damageAmount = damageAmount; this.bubbleCount = bubbleCount; } + @Override + public LivingEntity getEntity() { + return entity; + } + /** * This method returns true if the entity is "actively" drowning.
      * For most entities, this happens when their air supply reaches -20.
      diff --git a/src/main/java/net/minecraftforge/event/entity/living/LivingEntityUseItemEvent.java b/src/main/java/net/minecraftforge/event/entity/living/LivingEntityUseItemEvent.java index 87a8ea5d9c..0f537a3be4 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/LivingEntityUseItemEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/LivingEntityUseItemEvent.java @@ -9,21 +9,29 @@ import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.item.ItemStack; import net.minecraftforge.eventbus.api.bus.CancellableEventBus; import net.minecraftforge.eventbus.api.bus.EventBus; +import net.minecraftforge.eventbus.api.event.InheritableEvent; +import net.minecraftforge.eventbus.api.event.MutableEvent; import net.minecraftforge.eventbus.api.event.characteristic.Cancellable; import org.jetbrains.annotations.NotNull; -public sealed abstract class LivingEntityUseItemEvent extends LivingEvent { +public sealed abstract class LivingEntityUseItemEvent extends MutableEvent implements LivingEvent, InheritableEvent { public static final EventBus BUS = EventBus.create(LivingEntityUseItemEvent.class); + private final LivingEntity entity; private final ItemStack item; private int duration; private LivingEntityUseItemEvent(LivingEntity entity, @NotNull ItemStack item, int duration) { - super(entity); + this.entity = entity; this.item = item; this.setDuration(duration); } + @Override + public LivingEntity getEntity() { + return entity; + } + @NotNull public ItemStack getItem() { return item; diff --git a/src/main/java/net/minecraftforge/event/entity/living/LivingEquipmentChangeEvent.java b/src/main/java/net/minecraftforge/event/entity/living/LivingEquipmentChangeEvent.java index d0d9250a00..97ae551429 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/LivingEquipmentChangeEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/LivingEquipmentChangeEvent.java @@ -8,8 +8,8 @@ package net.minecraftforge.event.entity.living; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.item.ItemStack; -import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.eventbus.api.bus.EventBus; +import net.minecraftforge.eventbus.api.event.RecordEvent; import org.jetbrains.annotations.NotNull; /** @@ -18,41 +18,15 @@ import org.jetbrains.annotations.NotNull; * This also includes entities joining the World, as well as being cloned.
      * This event is fired on server-side only.
      *
      - * {@link #slot} contains the affected {@link EquipmentSlot}.
      - * {@link #from} contains the {@link ItemStack} that was equipped previously.
      - * {@link #to} contains the {@link ItemStack} that is equipped now.
      - *
      - * This event is not {@link Cancelable}.
      - *
      - * This event does not have a result. {@link HasResult}
      - *
      - * This event is fired on the {@link MinecraftForge#EVENT_BUS}. - **/ -public final class LivingEquipmentChangeEvent extends LivingEvent { + * @param getSlot contains the affected {@link EquipmentSlot}. + * @param getFrom contains the {@link ItemStack} that was equipped previously. + * @param getTo contains the {@link ItemStack} that is equipped now. + */ +public record LivingEquipmentChangeEvent( + LivingEntity getEntity, + EquipmentSlot getSlot, + @NotNull ItemStack getFrom, + @NotNull ItemStack getTo +) implements LivingEvent, RecordEvent { public static final EventBus BUS = EventBus.create(LivingEquipmentChangeEvent.class); - - private final EquipmentSlot slot; - private final ItemStack from; - private final ItemStack to; - - public LivingEquipmentChangeEvent(LivingEntity entity, EquipmentSlot slot, @NotNull ItemStack from, @NotNull ItemStack to) { - super(entity); - this.slot = slot; - this.from = from; - this.to = to; - } - - public EquipmentSlot getSlot() { - return this.slot; - } - - @NotNull - public ItemStack getFrom() { - return this.from; - } - - @NotNull - public ItemStack getTo() { - return this.to; - } } diff --git a/src/main/java/net/minecraftforge/event/entity/living/LivingEvent.java b/src/main/java/net/minecraftforge/event/entity/living/LivingEvent.java index 4d9fb6ca84..c8f3f19e2a 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/LivingEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/LivingEvent.java @@ -7,53 +7,32 @@ package net.minecraftforge.event.entity.living; import net.minecraft.world.entity.Entity; import net.minecraftforge.common.ForgeHooks; -import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.ForgeEventFactory; import net.minecraft.world.entity.LivingEntity; import net.minecraftforge.event.entity.EntityEvent; import net.minecraftforge.eventbus.api.bus.CancellableEventBus; import net.minecraftforge.eventbus.api.bus.EventBus; +import net.minecraftforge.eventbus.api.event.MutableEvent; +import net.minecraftforge.eventbus.api.event.RecordEvent; import net.minecraftforge.eventbus.api.event.characteristic.Cancellable; import org.jetbrains.annotations.Nullable; /** - * LivingEvent is fired whenever an event involving a {@link LivingEntity} occurs.
      - * If a method utilizes this {@link Event} as its parameter, the method will - * receive every child event of this class.
      - *
      - * All children of this event are fired on the {@link MinecraftForge#EVENT_BUS}.
      - **/ -public class LivingEvent extends EntityEvent { - public static final EventBus BUS = EventBus.create(LivingEvent.class); - - private final LivingEntity livingEntity; - - public LivingEvent(LivingEntity entity) { - super(entity); - livingEntity = entity; - } - + * LivingEvent is fired whenever an event involving a {@link LivingEntity} occurs. + */ +public interface LivingEvent extends EntityEvent { @Override - public LivingEntity getEntity() { - return livingEntity; - } + LivingEntity getEntity(); /** * LivingUpdateEvent is fired when a LivingEntity is ticked in {@link LivingEntity#tick()}.
      *
      * This event is fired via the {@link ForgeEventFactory#onLivingTick(LivingEntity)}.
      *
      - * This event is {@link Cancelable}.
      - * If this event is canceled, the Entity does not update.
      - *
      - * This event does not have a result. {@link HasResult}
      - *
      - * This event is fired on the {@link MinecraftForge#EVENT_BUS}. - **/ - public static final class LivingTickEvent extends LivingEvent implements Cancellable { + * This event is {@linkplain Cancellable cancellable}. If this event is cancelled, the Entity does not update. + */ + record LivingTickEvent(LivingEntity getEntity) implements Cancellable, LivingEvent, RecordEvent { public static final CancellableEventBus BUS = CancellableEventBus.create(LivingTickEvent.class); - - public LivingTickEvent(LivingEntity e) { super(e); } } /** @@ -62,33 +41,31 @@ public class LivingEvent extends EntityEvent { * {@code LivingEntity#jumpFromGround()}, {@code MagmaCube#jumpFromGround()}, * and {@code Horse#jumpFromGround()}.
      *
      - * This event is fired via the {@link ForgeHooks#onLivingJump(LivingEntity)}.
      - *
      - * This event is not {@link Cancelable}.
      - *
      - * This event does not have a result. {@link HasResult}
      - *
      - * This event is fired on the {@link MinecraftForge#EVENT_BUS}. + * This event is fired via the {@link ForgeHooks#onLivingJump(LivingEntity)}. **/ - public static final class LivingJumpEvent extends LivingEvent { + record LivingJumpEvent(LivingEntity getEntity) implements LivingEvent, RecordEvent { public static final EventBus BUS = EventBus.create(LivingJumpEvent.class); - - public LivingJumpEvent(LivingEntity e) { super(e); } } - public static final class LivingVisibilityEvent extends LivingEvent { + final class LivingVisibilityEvent extends MutableEvent implements LivingEvent { public static final EventBus BUS = EventBus.create(LivingVisibilityEvent.class); + private final LivingEntity livingEntity; private double visibilityModifier; @Nullable private final Entity lookingEntity; public LivingVisibilityEvent(LivingEntity livingEntity, @Nullable Entity lookingEntity, double originalMultiplier) { - super(livingEntity); + this.livingEntity = livingEntity; this.visibilityModifier = originalMultiplier; this.lookingEntity = lookingEntity; } + @Override + public LivingEntity getEntity() { + return livingEntity; + } + /** * @param mod Is multiplied with the current modifier */ diff --git a/src/main/java/net/minecraftforge/event/entity/living/LivingExperienceDropEvent.java b/src/main/java/net/minecraftforge/event/entity/living/LivingExperienceDropEvent.java index 072942d066..77b26b8456 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/LivingExperienceDropEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/LivingExperienceDropEvent.java @@ -8,29 +8,37 @@ package net.minecraftforge.event.entity.living; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.player.Player; import net.minecraftforge.eventbus.api.bus.CancellableEventBus; +import net.minecraftforge.eventbus.api.event.MutableEvent; import net.minecraftforge.eventbus.api.event.characteristic.Cancellable; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; /** * Event for when an entity drops experience on its death, can be used to change * the amount of experience points dropped or completely prevent dropping of experience * by canceling the event. */ -public final class LivingExperienceDropEvent extends LivingEvent implements Cancellable { +@NullMarked +public final class LivingExperienceDropEvent extends MutableEvent implements Cancellable, LivingEvent { public static final CancellableEventBus BUS = CancellableEventBus.create(LivingExperienceDropEvent.class); - @Nullable private final Player attackingPlayer; + private final LivingEntity entity; + private final @Nullable Player attackingPlayer; private final int originalExperiencePoints; private int droppedExperiencePoints; public LivingExperienceDropEvent(LivingEntity entity, @Nullable Player attackingPlayer, int originalExperience) { - super(entity); - + this.entity = entity; this.attackingPlayer = attackingPlayer; this.originalExperiencePoints = this.droppedExperiencePoints = originalExperience; } + @Override + public LivingEntity getEntity() { + return entity; + } + public int getDroppedExperience() { return droppedExperiencePoints; } diff --git a/src/main/java/net/minecraftforge/event/entity/living/LivingFallEvent.java b/src/main/java/net/minecraftforge/event/entity/living/LivingFallEvent.java index e7e36c4460..b3db82354a 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/LivingFallEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/LivingFallEvent.java @@ -6,9 +6,9 @@ package net.minecraftforge.event.entity.living; import net.minecraft.world.damagesource.DamageSource; -import net.minecraftforge.common.MinecraftForge; import net.minecraft.world.entity.LivingEntity; import net.minecraftforge.eventbus.api.bus.CancellableEventBus; +import net.minecraftforge.eventbus.api.event.MutableEvent; import net.minecraftforge.eventbus.api.event.characteristic.Cancellable; /** @@ -20,25 +20,26 @@ import net.minecraftforge.eventbus.api.event.characteristic.Cancellable; *
      * {@link #distance} contains the distance the Entity is to fall. If this event is canceled, this value is set to 0.0F. *
      - * This event is {@link net.minecraftforge.eventbus.api.Cancelable}.
      - * If this event is canceled, the Entity does not fall.
      - *
      - * This event does not have a result. {@link HasResult}
      - *
      - * This event is fired on the {@link MinecraftForge#EVENT_BUS}. + * This event is {@linkplain Cancellable cancellable}. If this event is canceled, the Entity does not fall. **/ -public final class LivingFallEvent extends LivingEvent implements Cancellable { +public final class LivingFallEvent extends MutableEvent implements Cancellable, LivingEvent { public static final CancellableEventBus BUS = CancellableEventBus.create(LivingFallEvent.class); + private final LivingEntity entity; private double distance; private float damageMultiplier; public LivingFallEvent(LivingEntity entity, double distance, float damageMultiplier) { - super(entity); + this.entity = entity; this.distance = distance; this.damageMultiplier = damageMultiplier; } + @Override + public LivingEntity getEntity() { + return entity; + } + public double getDistance() { return this.distance; } public void setDistance(double distance) { this.distance = distance; } public float getDamageMultiplier() { return damageMultiplier; } diff --git a/src/main/java/net/minecraftforge/event/entity/living/LivingGetProjectileEvent.java b/src/main/java/net/minecraftforge/event/entity/living/LivingGetProjectileEvent.java index 9703b4ed36..3c10545f94 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/LivingGetProjectileEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/LivingGetProjectileEvent.java @@ -8,31 +8,32 @@ package net.minecraftforge.event.entity.living; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.item.ItemStack; import net.minecraftforge.eventbus.api.bus.EventBus; +import net.minecraftforge.eventbus.api.event.MutableEvent; /** * This event is fired when a living entity attempts to get a projectile with the * {@link LivingEntity#getProjectile(ItemStack)} method. The item stack given is usually the item stack of a * {@link net.minecraft.world.item.ProjectileWeaponItem} and the item stack returned is usually the item stack of a * {@link net.minecraft.world.entity.projectile.Projectile}. - *

      - * This event is not {@link net.minecraftforge.eventbus.api.Cancelable}. - *

      - * This event does not have a result. {@link net.minecraftforge.eventbus.api.Event.HasResult} - *

      - * This event is fired on the {@link net.minecraftforge.common.MinecraftForge#EVENT_BUS}. */ -public final class LivingGetProjectileEvent extends LivingEvent { +public final class LivingGetProjectileEvent extends MutableEvent implements LivingEvent { public static final EventBus BUS = EventBus.create(LivingGetProjectileEvent.class); + private final LivingEntity entity; private final ItemStack projectileWeaponItemStack; private ItemStack projectileItemStack; public LivingGetProjectileEvent(LivingEntity livingEntity, ItemStack projectileWeaponItemStack, ItemStack ammo) { - super(livingEntity); + this.entity = livingEntity; this.projectileWeaponItemStack = projectileWeaponItemStack; this.projectileItemStack = ammo; } + @Override + public LivingEntity getEntity() { + return entity; + } + /** * @return The itemstack of the itrm that is looking for a projectile. With vanilla behavior, this usually returns * an itemstack of a {@link net.minecraft.world.item.ProjectileWeaponItem}, but it's possible for that to not be the diff --git a/src/main/java/net/minecraftforge/event/entity/living/LivingHealEvent.java b/src/main/java/net/minecraftforge/event/entity/living/LivingHealEvent.java index 2c555cd82c..78843cf427 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/LivingHealEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/LivingHealEvent.java @@ -5,11 +5,12 @@ package net.minecraftforge.event.entity.living; -import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.ForgeEventFactory; import net.minecraft.world.entity.LivingEntity; import net.minecraftforge.eventbus.api.bus.CancellableEventBus; +import net.minecraftforge.eventbus.api.event.MutableEvent; import net.minecraftforge.eventbus.api.event.characteristic.Cancellable; +import org.jspecify.annotations.NullMarked; /** * LivingHealEvent is fired when an Entity is set to be healed.
      @@ -19,23 +20,25 @@ import net.minecraftforge.eventbus.api.event.characteristic.Cancellable; *
      * {@link #amount} contains the amount of healing done to the Entity that was healed.
      *
      - * This event is {@link net.minecraftforge.eventbus.api.Cancelable}.
      - * If this event is canceled, the Entity is not healed.
      - *
      - * This event does not have a result. {@link HasResult}
      - *
      - * This event is fired on the {@link MinecraftForge#EVENT_BUS}. + * This event is {@linkplain Cancellable cancellable}. If this event is cancelled, the Entity is not healed. **/ -public final class LivingHealEvent extends LivingEvent implements Cancellable { +@NullMarked +public final class LivingHealEvent extends MutableEvent implements Cancellable, LivingEvent { public static final CancellableEventBus BUS = CancellableEventBus.create(LivingHealEvent.class); + private final LivingEntity entity; private float amount; public LivingHealEvent(LivingEntity entity, float amount) { - super(entity); + this.entity = entity; this.setAmount(amount); } + @Override + public LivingEntity getEntity() { + return entity; + } + public float getAmount() { return amount; } diff --git a/src/main/java/net/minecraftforge/event/entity/living/LivingHurtEvent.java b/src/main/java/net/minecraftforge/event/entity/living/LivingHurtEvent.java index b8fb612aa5..e17be8e02a 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/LivingHurtEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/LivingHurtEvent.java @@ -8,8 +8,8 @@ package net.minecraftforge.event.entity.living; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.LivingEntity; import net.minecraftforge.common.ForgeHooks; -import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.eventbus.api.bus.CancellableEventBus; +import net.minecraftforge.eventbus.api.event.MutableEvent; import net.minecraftforge.eventbus.api.event.characteristic.Cancellable; /** @@ -23,26 +23,28 @@ import net.minecraftforge.eventbus.api.event.characteristic.Cancellable; * {@link #source} contains the DamageSource that caused this Entity to be hurt.
      * {@link #amount} contains the amount of damage dealt to the Entity that was hurt.
      *
      - * This event is {@link Cancelable}.
      - * If this event is canceled, the Entity is not hurt.
      - *
      - * This event does not have a result. {@link HasResult}
      - *
      - * This event is fired on the {@link MinecraftForge#EVENT_BUS}. + * This event is {@linkplain Cancellable cancellable}. If this event is cancelled, the Entity is not hurt.
      + * * @see LivingDamageEvent **/ -public final class LivingHurtEvent extends LivingEvent implements Cancellable { +public final class LivingHurtEvent extends MutableEvent implements Cancellable, LivingEvent { public static final CancellableEventBus BUS = CancellableEventBus.create(LivingHurtEvent.class); + private final LivingEntity entity; private final DamageSource source; private float amount; public LivingHurtEvent(LivingEntity entity, DamageSource source, float amount) { - super(entity); + this.entity = entity; this.source = source; this.amount = amount; } + @Override + public LivingEntity getEntity() { + return entity; + } + public DamageSource getSource() { return source; } public float getAmount() { return amount; } diff --git a/src/main/java/net/minecraftforge/event/entity/living/LivingKnockBackEvent.java b/src/main/java/net/minecraftforge/event/entity/living/LivingKnockBackEvent.java index 6e114299d2..c321b698f0 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/LivingKnockBackEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/LivingKnockBackEvent.java @@ -11,8 +11,8 @@ import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.player.Player; import net.minecraftforge.common.ForgeHooks; -import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.eventbus.api.bus.CancellableEventBus; +import net.minecraftforge.eventbus.api.event.MutableEvent; import net.minecraftforge.eventbus.api.event.characteristic.Cancellable; /** @@ -29,25 +29,29 @@ import net.minecraftforge.eventbus.api.event.characteristic.Cancellable; * {@link #ratioX} contains the x ratio of the knock back.
      * {@link #ratioZ} contains the z ratio of the knock back.
      *
      - * If this event is canceled, the entity is not knocked back.
      - *
      - * This event is fired on the {@link MinecraftForge#EVENT_BUS}. + * If this event is cancelled, the entity is not knocked back.
      **/ -public class LivingKnockBackEvent extends LivingEvent implements Cancellable { +public class LivingKnockBackEvent extends MutableEvent implements Cancellable, LivingEvent { public static final CancellableEventBus BUS = CancellableEventBus.create(LivingKnockBackEvent.class); + private final LivingEntity target; protected float strength; protected double ratioX, ratioZ; protected final float originalStrength; protected final double originalRatioX, originalRatioZ; public LivingKnockBackEvent(LivingEntity target, float strength, double ratioX, double ratioZ) { - super(target); + this.target = target; this.strength = this.originalStrength = strength; this.ratioX = this.originalRatioX = ratioX; this.ratioZ = this.originalRatioZ = ratioZ; } + @Override + public LivingEntity getEntity() { + return target; + } + public float getStrength() {return this.strength;} public double getRatioX() {return this.ratioX;} diff --git a/src/main/java/net/minecraftforge/event/entity/living/LivingMakeBrainEvent.java b/src/main/java/net/minecraftforge/event/entity/living/LivingMakeBrainEvent.java index 6b22cddbec..133c4a7487 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/LivingMakeBrainEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/LivingMakeBrainEvent.java @@ -9,9 +9,9 @@ import com.mojang.serialization.Dynamic; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.ai.Brain; import net.minecraftforge.common.ForgeHooks; -import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.util.BrainBuilder; import net.minecraftforge.eventbus.api.bus.EventBus; +import net.minecraftforge.eventbus.api.event.MutableEvent; /** * LivingMakeBrainEvent is fired whenever a new {@link net.minecraft.world.entity.ai.Brain} instance is created using {@link LivingEntity#makeBrain(Dynamic)}.
      @@ -24,23 +24,23 @@ import net.minecraftforge.eventbus.api.bus.EventBus; * and replace the previously created Brain instance for the entity.
      *
      * This event is fired via the {@link ForgeHooks#onLivingMakeBrain(LivingEntity, Brain, Dynamic)}.
      - *
      - * This event is not {@link Cancelable}.
      - *
      - * This event does not have a result. {@link HasResult}
      - *
      - * This event is fired on the {@link MinecraftForge#EVENT_BUS}. **/ -public final class LivingMakeBrainEvent extends LivingEvent { +public final class LivingMakeBrainEvent extends MutableEvent implements LivingEvent { public static final EventBus BUS = EventBus.create(LivingMakeBrainEvent.class); + private final LivingEntity entity; private final BrainBuilder brainBuilder; public LivingMakeBrainEvent(LivingEntity entity, BrainBuilder brainBuilder) { - super(entity); + this.entity = entity; this.brainBuilder = brainBuilder; } + @Override + public LivingEntity getEntity() { + return entity; + } + @SuppressWarnings("unchecked") public BrainBuilder getTypedBrainBuilder(E ignoredEntity) { return (BrainBuilder) this.brainBuilder; diff --git a/src/main/java/net/minecraftforge/event/entity/living/LivingPackSizeEvent.java b/src/main/java/net/minecraftforge/event/entity/living/LivingPackSizeEvent.java index a7916b2f42..38ab54d011 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/LivingPackSizeEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/LivingPackSizeEvent.java @@ -9,17 +9,24 @@ import net.minecraftforge.common.util.HasResult; import net.minecraft.world.entity.Mob; import net.minecraftforge.common.util.Result; import net.minecraftforge.eventbus.api.bus.EventBus; +import net.minecraftforge.eventbus.api.event.MutableEvent; import org.jspecify.annotations.NullMarked; @NullMarked -public final class LivingPackSizeEvent extends LivingEvent implements HasResult { +public final class LivingPackSizeEvent extends MutableEvent implements LivingEvent, HasResult { public static final EventBus BUS = EventBus.create(LivingPackSizeEvent.class); + private final Mob entity; private int maxPackSize; private Result result = Result.DEFAULT; public LivingPackSizeEvent(Mob entity) { - super(entity); + this.entity = entity; + } + + @Override + public Mob getEntity() { + return entity; } /** diff --git a/src/main/java/net/minecraftforge/event/entity/living/LivingSwapItemsEvent.java b/src/main/java/net/minecraftforge/event/entity/living/LivingSwapItemsEvent.java index 4d195fa836..9c1eb76f9f 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/LivingSwapItemsEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/LivingSwapItemsEvent.java @@ -9,24 +9,28 @@ import net.minecraft.server.network.ServerGamePacketListenerImpl; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.item.ItemStack; import net.minecraftforge.eventbus.api.bus.CancellableEventBus; -import net.minecraftforge.eventbus.api.bus.EventBus; +import net.minecraftforge.eventbus.api.event.MutableEvent; import net.minecraftforge.eventbus.api.event.characteristic.Cancellable; import org.jetbrains.annotations.ApiStatus; -public sealed class LivingSwapItemsEvent extends LivingEvent { - public static final EventBus EVENT_BUS = EventBus.create(LivingSwapItemsEvent.class); +public sealed abstract class LivingSwapItemsEvent extends MutableEvent implements LivingEvent { + private final LivingEntity entity; @ApiStatus.Internal - public LivingSwapItemsEvent(LivingEntity entity) - { - super(entity); + protected LivingSwapItemsEvent(LivingEntity entity) { + this.entity = entity; + } + + @Override + public LivingEntity getEntity() { + return entity; } /** * This event is fired when a living entity is about to swap the items in their main and offhand. * This event is executed in {@link ServerGamePacketListenerImpl#handlePlayerAction} * - *

      This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. + *

      This event is {@linkplain Cancellable cancellable}. */ public static final class Hands extends LivingSwapItemsEvent implements Cancellable { public static final CancellableEventBus BUS = CancellableEventBus.create(Hands.class); diff --git a/src/main/java/net/minecraftforge/event/entity/living/LivingUseTotemEvent.java b/src/main/java/net/minecraftforge/event/entity/living/LivingUseTotemEvent.java index 5a6b1074c1..63ca8f4c19 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/LivingUseTotemEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/LivingUseTotemEvent.java @@ -9,52 +9,45 @@ import net.minecraft.world.InteractionHand; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.item.ItemStack; -import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.eventbus.api.bus.CancellableEventBus; +import net.minecraftforge.eventbus.api.event.RecordEvent; import net.minecraftforge.eventbus.api.event.characteristic.Cancellable; import net.minecraftforge.fml.LogicalSide; /** * Fired when an Entity attempts to use a totem to prevent its death. * - *

      This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. + *

      This event is {@linkplain Cancellable cancellable}. * If this event is cancelled, the totem will not prevent the entity's death.

      * - *

      This event is fired on the {@linkplain MinecraftForge#EVENT_BUS Forge event bus}, - * only on the {@linkplain LogicalSide#SERVER logical server}.

      + *

      This event is fired only on the {@linkplain LogicalSide#SERVER logical server}.

      */ -public final class LivingUseTotemEvent extends LivingEvent implements Cancellable { +public record LivingUseTotemEvent( + LivingEntity getEntity, + DamageSource getSource, + ItemStack getTotem, + InteractionHand getHandHolding +) implements Cancellable, LivingEvent, RecordEvent { public static final CancellableEventBus BUS = CancellableEventBus.create(LivingUseTotemEvent.class); - private final DamageSource source; - private final ItemStack totem; - private final InteractionHand hand; - - public LivingUseTotemEvent(LivingEntity entity, DamageSource source, ItemStack totem, InteractionHand hand) { - super(entity); - this.source = source; - this.totem = totem; - this.hand = hand; - } - /** * {@return the damage source that caused the entity to die} */ public DamageSource getSource() { - return source; + return getSource; } /** * {@return the totem of undying being used from the entity's inventory} */ public ItemStack getTotem() { - return totem; + return getTotem; } /** * {@return the hand holding the totem} */ public InteractionHand getHandHolding() { - return hand; + return getHandHolding; } } diff --git a/src/main/java/net/minecraftforge/event/entity/living/LootingLevelEvent.java b/src/main/java/net/minecraftforge/event/entity/living/LootingLevelEvent.java index a111bd5d11..60e34dff2f 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/LootingLevelEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/LootingLevelEvent.java @@ -9,22 +9,30 @@ import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.damagesource.DamageSource; import net.minecraftforge.eventbus.api.bus.EventBus; -import org.jetbrains.annotations.Nullable; +import net.minecraftforge.eventbus.api.event.MutableEvent; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; -public final class LootingLevelEvent extends LivingEvent { +@NullMarked +public final class LootingLevelEvent extends MutableEvent implements LivingEvent { public static final EventBus BUS = EventBus.create(LootingLevelEvent.class); - @Nullable - private final DamageSource damageSource; + private final LivingEntity entity; + private final @Nullable DamageSource damageSource; private int lootingLevel; public LootingLevelEvent(LivingEntity entity, @Nullable DamageSource damageSource, int lootingLevel) { - super(entity); + this.entity = entity; this.damageSource = damageSource; this.lootingLevel = lootingLevel; } + @Override + public LivingEntity getEntity() { + return entity; + } + @Nullable public DamageSource getDamageSource() { return damageSource; diff --git a/src/main/java/net/minecraftforge/event/entity/living/MobEffectEvent.java b/src/main/java/net/minecraftforge/event/entity/living/MobEffectEvent.java index 48d279612a..cdb353d289 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/MobEffectEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/MobEffectEvent.java @@ -15,6 +15,7 @@ import net.minecraftforge.common.util.HasResult; import net.minecraftforge.common.util.Result; import net.minecraftforge.eventbus.api.bus.CancellableEventBus; import net.minecraftforge.eventbus.api.bus.EventBus; +import net.minecraftforge.eventbus.api.event.InheritableEvent; import net.minecraftforge.eventbus.api.event.characteristic.Cancellable; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -24,47 +25,36 @@ import org.jetbrains.annotations.Nullable; *

      * All children of this event are fired on the {@link MinecraftForge#EVENT_BUS}. */ -public sealed class MobEffectEvent extends LivingEvent { - public static final EventBus BUS = EventBus.create(MobEffectEvent.class); +public sealed interface MobEffectEvent extends LivingEvent, InheritableEvent { + EventBus BUS = EventBus.create(MobEffectEvent.class); @Nullable - protected final MobEffectInstance effectInstance; - - public MobEffectEvent(LivingEntity living, MobEffectInstance effectInstance) { - super(living); - this.effectInstance = effectInstance; - } - - @Nullable - public MobEffectInstance getEffectInstance() { - return effectInstance; - } + MobEffectInstance getEffectInstance(); /** - * This Event is fired when a {@link MobEffect} is about to get removed from an Entity. - * This Event is {@link Cancelable}. If canceled, the effect will not be removed. - * This Event does not have a result. + * This event is fired when a {@link MobEffect} is about to get removed from an Entity. + * This event is {@linkplain Cancellable cancellable}. If cancelled, the effect will not be removed. */ - public static final class Remove extends MobEffectEvent implements Cancellable { + record Remove( + LivingEntity getEntity, + MobEffect getEffect, + MobEffectInstance getEffectInstance + ) implements Cancellable, MobEffectEvent { public static final CancellableEventBus BUS = CancellableEventBus.create(Remove.class); - private final MobEffect effect; - public Remove(LivingEntity living, MobEffect effect) { - super(living, living.getEffect(BuiltInRegistries.MOB_EFFECT.wrapAsHolder(effect))); - this.effect = effect; + this(living, effect, living.getEffect(BuiltInRegistries.MOB_EFFECT.wrapAsHolder(effect))); } public Remove(LivingEntity living, MobEffectInstance effectInstance) { - super(living, effectInstance); - this.effect = effectInstance.getEffect().get(); + this(living, effectInstance.getEffect().get(), effectInstance); } /** * @return the {@link MobEffectEvent} which is being removed from the entity */ public MobEffect getEffect() { - return this.effect; + return getEffect; } /** @@ -73,7 +63,7 @@ public sealed class MobEffectEvent extends LivingEvent { @Override @Nullable public MobEffectInstance getEffectInstance() { - return super.getEffectInstance(); + return getEffectInstance; } } @@ -86,19 +76,27 @@ public sealed class MobEffectEvent extends LivingEvent { * {@link Result#DENY DENY} will not apply this mob effect. * {@link Result#DEFAULT DEFAULT} will run vanilla logic to determine if this mob effect is applicable in {@link LivingEntity#canBeAffected}. */ - public static final class Applicable extends MobEffectEvent implements HasResult { + final class Applicable implements MobEffectEvent, HasResult { public static final EventBus BUS = EventBus.create(Applicable.class); + private final LivingEntity living; + private final MobEffectInstance effectInstance; private Result result = Result.DEFAULT; public Applicable(LivingEntity living, @NotNull MobEffectInstance effectInstance) { - super(living, effectInstance); + this.living = living; + this.effectInstance = effectInstance; + } + + @Override + public LivingEntity getEntity() { + return living; } @Override @NotNull public MobEffectInstance getEffectInstance() { - return super.getEffectInstance(); + return effectInstance; } @Override @@ -113,30 +111,24 @@ public sealed class MobEffectEvent extends LivingEvent { } /** - * This event is fired when a new {@link MobEffectInstance} is added to an entity. + * This event is fired when a new {@link MobEffectInstance} is added to an entity.
      * This event is also fired if an entity already has the effect but with a different duration or amplifier. - * This event is not {@link Cancelable}. - * This event does not have a result. */ - public static final class Added extends MobEffectEvent { + record Added( + LivingEntity getEntity, + @Nullable MobEffectInstance getOldEffectInstance, + @NotNull MobEffectInstance getEffectInstance, + @Nullable Entity getEffectSource + ) implements MobEffectEvent { public static final EventBus BUS = EventBus.create(Added.class); - private final MobEffectInstance oldEffectInstance; - private final Entity source; - - public Added(LivingEntity living, MobEffectInstance oldEffectInstance, MobEffectInstance newEffectInstance, Entity source) { - super(living, newEffectInstance); - this.oldEffectInstance = oldEffectInstance; - this.source = source; - } - /** * @return the added {@link MobEffectInstance}. This is the unmerged MobEffectInstance if the old MobEffectInstance is not null. */ @Override @NotNull public MobEffectInstance getEffectInstance() { - return super.getEffectInstance(); + return getEffectInstance; } /** @@ -144,7 +136,7 @@ public sealed class MobEffectEvent extends LivingEvent { */ @Nullable public MobEffectInstance getOldEffectInstance() { - return oldEffectInstance; + return getOldEffectInstance; } /** @@ -152,20 +144,17 @@ public sealed class MobEffectEvent extends LivingEvent { */ @Nullable public Entity getEffectSource() { - return source; + return getEffectSource; } } /** * This event is fired when a {@link MobEffectInstance} expires on an entity. - * This event is not {@link Cancelable}. - * This event does not have a result. */ - public static final class Expired extends MobEffectEvent { + record Expired( + LivingEntity getEntity, + MobEffectInstance getEffectInstance + ) implements MobEffectEvent { public static final EventBus BUS = EventBus.create(Expired.class); - - public Expired(LivingEntity living, MobEffectInstance effect) { - super(living, effect); - } } } diff --git a/src/main/java/net/minecraftforge/event/entity/living/MobSpawnEvent.java b/src/main/java/net/minecraftforge/event/entity/living/MobSpawnEvent.java index 093b33633b..0efaafd904 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/MobSpawnEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/MobSpawnEvent.java @@ -40,9 +40,8 @@ import net.minecraftforge.fml.LogicalSide; *

      * {@link AllowDespawn} is not related to the mob spawn event flow, as it fires when a despawn is attempted. */ -public abstract sealed class MobSpawnEvent extends EntityEvent { - public static final EventBus BUS = EventBus.create(MobSpawnEvent.class); - +public abstract sealed class MobSpawnEvent extends MutableEvent implements EntityEvent { + private final Mob entity; private final ServerLevelAccessor level; private final double x; private final double y; @@ -50,7 +49,7 @@ public abstract sealed class MobSpawnEvent extends EntityEvent { @ApiStatus.Internal protected MobSpawnEvent(Mob mob, ServerLevelAccessor level, double x, double y, double z) { - super(mob); + this.entity = mob; this.level = level; this.x = x; this.y = y; @@ -59,7 +58,7 @@ public abstract sealed class MobSpawnEvent extends EntityEvent { @Override public Mob getEntity() { - return (Mob)super.getEntity(); + return entity; } /** diff --git a/src/main/java/net/minecraftforge/event/entity/living/MonsterDisguiseEvent.java b/src/main/java/net/minecraftforge/event/entity/living/MonsterDisguiseEvent.java index 18b55e523f..442e7d3d51 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/MonsterDisguiseEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/MonsterDisguiseEvent.java @@ -9,36 +9,18 @@ import net.minecraft.world.entity.monster.Monster; import net.minecraft.world.entity.player.Player; import net.minecraftforge.common.extensions.IForgeItem; import net.minecraftforge.eventbus.api.bus.CancellableEventBus; +import net.minecraftforge.eventbus.api.event.RecordEvent; import net.minecraftforge.eventbus.api.event.characteristic.Cancellable; /** * This event is fired on the forge bus before an Monster detects that a player is looking at them. * It will not be fired if the detection is already prevented by {@link IForgeItem#isEnderMask} *

      - * This event is {@link Cancelable}. - * If this event is canceled, the Monster will not target the player. - *

      - * This event does not have a {@link Result}. + * This event is {@linkplain Cancellable cancellable}. + * If this event is cancelled, the Monster will not target the player. + * + * @param getPlayer The player that is being checked. */ -public final class MonsterDisguiseEvent extends LivingEvent implements Cancellable { +public record MonsterDisguiseEvent(Monster getEntity, Player getPlayer) implements Cancellable, LivingEvent, RecordEvent { public static final CancellableEventBus BUS = CancellableEventBus.create(MonsterDisguiseEvent.class); - - private final Player player; - - public MonsterDisguiseEvent(Monster monster, Player player) { - super(monster); - this.player = player; - } - - /** - * The player that is being checked. - */ - public Player getPlayer() { - return player; - } - - @Override - public Monster getEntity() { - return (Monster) super.getEntity(); - } } diff --git a/src/main/java/net/minecraftforge/event/entity/living/ShieldBlockEvent.java b/src/main/java/net/minecraftforge/event/entity/living/ShieldBlockEvent.java index a87316733b..54b5c2949b 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/ShieldBlockEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/ShieldBlockEvent.java @@ -10,6 +10,7 @@ import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.item.ItemStack; import net.minecraftforge.eventbus.api.bus.CancellableEventBus; +import net.minecraftforge.eventbus.api.event.MutableEvent; import net.minecraftforge.eventbus.api.event.characteristic.Cancellable; /** @@ -19,9 +20,10 @@ import net.minecraftforge.eventbus.api.event.characteristic.Cancellable; * Note: The shield item stack "should" be available from {@link LivingEntity#getUseItem()} * at least for players. */ -public final class ShieldBlockEvent extends LivingEvent implements Cancellable { +public final class ShieldBlockEvent extends MutableEvent implements Cancellable, LivingEvent { public static final CancellableEventBus BUS = CancellableEventBus.create(ShieldBlockEvent.class); + private final LivingEntity blocker; private final DamageSource source; private final float originalBlocked; private float dmgBlocked; @@ -29,13 +31,18 @@ public final class ShieldBlockEvent extends LivingEvent implements Cancellable { private final ItemStack blockedWith; public ShieldBlockEvent(LivingEntity blocker, DamageSource source, float blocked, ItemStack blockedWith) { - super(blocker); + this.blocker = blocker; this.source = source; this.originalBlocked = blocked; this.dmgBlocked = blocked; this.blockedWith = blockedWith; } + @Override + public LivingEntity getEntity() { + return this.blocker; + } + /** @return The damage source. */ public DamageSource getDamageSource() { return this.source; diff --git a/src/main/java/net/minecraftforge/event/entity/living/ZombieEvent.java b/src/main/java/net/minecraftforge/event/entity/living/ZombieEvent.java index b2e1949e7f..3f8881c09f 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/ZombieEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/ZombieEvent.java @@ -14,21 +14,19 @@ import net.minecraftforge.common.util.Result; import net.minecraftforge.event.ForgeEventFactory; import net.minecraftforge.event.entity.EntityEvent; import net.minecraftforge.eventbus.api.bus.EventBus; +import net.minecraftforge.eventbus.api.event.InheritableEvent; /** * ZombieEvent is fired whenever a zombie is spawned for aid. * If a method utilizes this event as its parameter, the method will * receive every child event of this class. - * - * All children of this event are fired on the {@link MinecraftForge#EVENT_BUS}. **/ -public sealed class ZombieEvent extends EntityEvent { +public sealed abstract class ZombieEvent implements EntityEvent, InheritableEvent { public static final EventBus BUS = EventBus.create(ZombieEvent.class); private final Zombie zombie; - public ZombieEvent(Zombie zombie) { - super(zombie); + protected ZombieEvent(Zombie zombie) { this.zombie = zombie; } diff --git a/src/main/java/net/minecraftforge/event/entity/player/AdvancementEvent.java b/src/main/java/net/minecraftforge/event/entity/player/AdvancementEvent.java index 2c2b4c36f9..13e4116a7b 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/AdvancementEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/AdvancementEvent.java @@ -9,27 +9,17 @@ import net.minecraft.advancements.Advancement; import net.minecraft.advancements.AdvancementHolder; import net.minecraft.advancements.AdvancementProgress; import net.minecraft.world.entity.player.Player; -import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.eventbus.api.bus.EventBus; +import net.minecraftforge.eventbus.api.event.RecordEvent; +import net.minecraftforge.fml.LogicalSide; /** * Base class used for advancement-related events. Should not be used directly. * @see AdvancementEarnEvent * @see AdvancementProgressEvent */ -public sealed class AdvancementEvent extends PlayerEvent { - public static final EventBus BUS = EventBus.create(AdvancementEvent.class); - - private final AdvancementHolder advancement; - - public AdvancementEvent(Player player, AdvancementHolder advancement) { - super(player); - this.advancement = advancement; - } - - public AdvancementHolder getAdvancement() { - return advancement; - } +public sealed interface AdvancementEvent extends PlayerEvent { + AdvancementHolder getAdvancement(); /** * Fired when the player earns an advancement. An advancement is earned once its requirements are complete. @@ -37,68 +27,37 @@ public sealed class AdvancementEvent extends PlayerEvent { *

      Note that advancements may be hidden from the player or used in background mechanics, such as recipe * advancements for unlocking recipes in the recipe book.

      * - *

      This event is not {@linkplain net.minecraftforge.eventbus.api.Cancelable cancellable}, and does not {@linkplain HasResult have a result}.

      - * - *

      This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus}, - * only on the {@linkplain net.minecraftforge.fml.LogicalSide#SERVER logical server}.

      + *

      This event is fired only on the {@linkplain LogicalSide#SERVER logical server}.

      * * @see AdvancementProgress#isDone() */ - public static final class AdvancementEarnEvent extends AdvancementEvent { + record AdvancementEarnEvent(Player getEntity, AdvancementHolder getAdvancement) + implements RecordEvent, AdvancementEvent { public static final EventBus BUS = EventBus.create(AdvancementEarnEvent.class); - - public AdvancementEarnEvent(Player player, AdvancementHolder earned) { - super(player, earned); - } } /** * Fired when the player's progress on an advancement criterion is granted or revoked. * - *

      This event is not {@linkplain net.minecraftforge.eventbus.api.Cancelable cancellable}, and does not {@linkplain HasResult have a result}.

      + *

      This event is fired only on the {@linkplain LogicalSide#SERVER logical server}.

      * - *

      This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus}, - * only on the {@linkplain net.minecraftforge.fml.LogicalSide#SERVER logical server}.

      + * @param getAdvancementProgress the progress of the advancement + * @param getCriterionName the name of the criterion that was progressed + * @param getProgressType the type of progress for the criterion in this event * * @see AdvancementEarnEvent * @see net.minecraft.server.PlayerAdvancements#award(Advancement, String) * @see net.minecraft.server.PlayerAdvancements#revoke(Advancement, String) */ - public static final class AdvancementProgressEvent extends AdvancementEvent { + record AdvancementProgressEvent( + Player getEntity, + AdvancementHolder getAdvancement, + AdvancementProgress getAdvancementProgress, + String getCriterionName, + ProgressType getProgressType + ) implements RecordEvent, AdvancementEvent { public static final EventBus BUS = EventBus.create(AdvancementProgressEvent.class); - private final AdvancementProgress advancementProgress; - private final String criterionName; - private final AdvancementEvent.AdvancementProgressEvent.ProgressType progressType; - - public AdvancementProgressEvent(Player player, AdvancementHolder progressed, AdvancementProgress advancementProgress, String criterionName, AdvancementEvent.AdvancementProgressEvent.ProgressType progressType) { - super(player, progressed); - this.advancementProgress = advancementProgress; - this.criterionName = criterionName; - this.progressType = progressType; - } - - /** - * {@return the progress of the advancement} - */ - public AdvancementProgress getAdvancementProgress() { - return advancementProgress; - } - - /** - * {@return name of the criterion that was progressed} - */ - public String getCriterionName() { - return criterionName; - } - - /** - * {@return The type of progress for the criterion in this event} - */ - public ProgressType getProgressType() { - return progressType; - } - public enum ProgressType { GRANT, REVOKE } diff --git a/src/main/java/net/minecraftforge/event/entity/player/AnvilRepairEvent.java b/src/main/java/net/minecraftforge/event/entity/player/AnvilRepairEvent.java index 54d1bfc33a..4e479dcfc7 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/AnvilRepairEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/AnvilRepairEvent.java @@ -8,7 +8,8 @@ package net.minecraftforge.event.entity.player; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraftforge.eventbus.api.bus.EventBus; -import org.jetbrains.annotations.NotNull; +import net.minecraftforge.eventbus.api.event.MutableEvent; +import org.jspecify.annotations.NullMarked; /** * Fired when the player removes a "repaired" item from the Anvil's Output slot. @@ -17,44 +18,45 @@ import org.jetbrains.annotations.NotNull; * * ItemStacks are the inputs/output from the anvil. They cannot be edited. */ -public final class AnvilRepairEvent extends PlayerEvent { +@NullMarked +public final class AnvilRepairEvent extends MutableEvent implements PlayerEvent { public static final EventBus BUS = EventBus.create(AnvilRepairEvent.class); - @NotNull + private final Player player; private final ItemStack left; // The left side of the input - @NotNull private final ItemStack right; // The right side of the input - @NotNull private final ItemStack output; // Set this to set the output stack private float breakChance; // Anvil's chance to break (reduced by 1 durability) when this is complete. Default is 12% (0.12f) - public AnvilRepairEvent(Player player, @NotNull ItemStack left, @NotNull ItemStack right, @NotNull ItemStack output) { - super(player); + public AnvilRepairEvent(Player player, ItemStack left, ItemStack right, ItemStack output) { + this.player = player; this.output = output; this.left = left; this.right = right; this.setBreakChance(0.12f); } + @Override + public Player getEntity() { + return player; + } + /** * Get the output result from the anvil * @return the output */ - @NotNull public ItemStack getOutput() { return output; } /** * Get the first item input into the anvil * @return the first input slot */ - @NotNull public ItemStack getLeft() { return left; } /** * Get the second item input into the anvil * @return the second input slot */ - @NotNull public ItemStack getRight() { return right; } public float getBreakChance() { return breakChance; } diff --git a/src/main/java/net/minecraftforge/event/entity/player/ArrowLooseEvent.java b/src/main/java/net/minecraftforge/event/entity/player/ArrowLooseEvent.java index 0e1cb423b3..ff92586fea 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/ArrowLooseEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/ArrowLooseEvent.java @@ -7,11 +7,11 @@ package net.minecraftforge.event.entity.player; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.item.BowItem; -import net.minecraftforge.common.MinecraftForge; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import net.minecraftforge.eventbus.api.bus.CancellableEventBus; +import net.minecraftforge.eventbus.api.event.MutableEvent; import net.minecraftforge.eventbus.api.event.characteristic.Cancellable; import org.jetbrains.annotations.NotNull; @@ -23,30 +23,32 @@ import org.jetbrains.annotations.NotNull; * {@link #bow} contains the ItemBow ItemStack that was used in this event.
      * {@link #charge} contains the value for how much the player had charged before stopping the shot.
      *
      - * This event is {@link Cancelable}.
      - * If this event is canceled, the player does not stop using the bow.
      + * This event is {@linkplain Cancellable cancellable}.
      + * If this event is cancelled, the player does not stop using the bow.
      * For crossbows, the charge will always be 1; Set it to -1 in order to prevent firing the arrow.
      - *
      - * This event does not have a result. {@link HasResult}
      - *
      - * This event is fired on the {@link MinecraftForge#EVENT_BUS}. - **/ -public final class ArrowLooseEvent extends PlayerEvent implements Cancellable { + */ +public final class ArrowLooseEvent extends MutableEvent implements Cancellable, PlayerEvent { public static final CancellableEventBus BUS = CancellableEventBus.create(ArrowLooseEvent.class); + private final Player player; private final ItemStack bow; private final Level level; private final boolean hasAmmo; private int charge; public ArrowLooseEvent(Player player, @NotNull ItemStack bow, Level level, int charge, boolean hasAmmo) { - super(player); + this.player = player; this.bow = bow; this.level = level; this.charge = charge; this.hasAmmo = hasAmmo; } + @Override + public Player getEntity() { + return player; + } + @NotNull public ItemStack getBow() { return this.bow; } public Level getLevel() { return this.level; } diff --git a/src/main/java/net/minecraftforge/event/entity/player/ArrowNockEvent.java b/src/main/java/net/minecraftforge/event/entity/player/ArrowNockEvent.java index 5a99a7bc50..2557a2e955 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/ArrowNockEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/ArrowNockEvent.java @@ -11,20 +11,19 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.level.Level; -import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.eventbus.api.bus.EventBus; +import net.minecraftforge.eventbus.api.event.MutableEvent; import org.jetbrains.annotations.NotNull; /** * ArrowNockEvent is fired when a player begins using a bow.
      * This event is fired whenever a player begins using a bow in - * {@link BowItem#use(Level, Player, InteractionHand)}.
      - *
      - * This event is fired on the {@link MinecraftForge#EVENT_BUS}. + * {@link BowItem#use(Level, Player, InteractionHand)}. **/ -public final class ArrowNockEvent extends PlayerEvent { +public final class ArrowNockEvent extends MutableEvent implements PlayerEvent { public static final EventBus BUS = EventBus.create(ArrowNockEvent.class); + private final Player player; private final ItemStack bow; private final InteractionHand hand; private final Level level; @@ -32,13 +31,18 @@ public final class ArrowNockEvent extends PlayerEvent { private InteractionResult action; public ArrowNockEvent(Player player, @NotNull ItemStack item, InteractionHand hand, Level level, boolean hasAmmo) { - super(player); + this.player = player; this.bow = item; this.hand = hand; this.level = level; this.hasAmmo = hasAmmo; } + @Override + public Player getEntity() { + return player; + } + @NotNull public ItemStack getBow() { return this.bow; } public Level getLevel() { return this.level; } diff --git a/src/main/java/net/minecraftforge/event/entity/player/AttackEntityEvent.java b/src/main/java/net/minecraftforge/event/entity/player/AttackEntityEvent.java index def4d71e59..ef956f8224 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/AttackEntityEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/AttackEntityEvent.java @@ -5,10 +5,10 @@ package net.minecraftforge.event.entity.player; -import net.minecraftforge.common.MinecraftForge; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.player.Player; import net.minecraftforge.eventbus.api.bus.CancellableEventBus; +import net.minecraftforge.eventbus.api.event.RecordEvent; import net.minecraftforge.eventbus.api.event.characteristic.Cancellable; /** @@ -18,24 +18,8 @@ import net.minecraftforge.eventbus.api.event.characteristic.Cancellable; *
      * {@link #target} contains the Entity that was damaged by the player.
      *
      - * This event is {@link Cancelable}.
      - * If this event is canceled, the player does not attack the Entity.
      - *
      - * This event does not have a result. {@link HasResult}
      - *
      - * This event is fired on the {@link MinecraftForge#EVENT_BUS}. + * This event is {@linkplain Cancellable cancellable}. If this event is cancelled, the player does not attack the Entity. **/ -public final class AttackEntityEvent extends PlayerEvent implements Cancellable { +public record AttackEntityEvent(Player getEntity, Entity getTarget) implements Cancellable, PlayerEvent, RecordEvent { public static final CancellableEventBus BUS = CancellableEventBus.create(AttackEntityEvent.class); - - private final Entity target; - - public AttackEntityEvent(Player player, Entity target) { - super(player); - this.target = target; - } - - public Entity getTarget() { - return target; - } } diff --git a/src/main/java/net/minecraftforge/event/entity/player/BonemealEvent.java b/src/main/java/net/minecraftforge/event/entity/player/BonemealEvent.java index e63bfd081c..c015b7642a 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/BonemealEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/BonemealEvent.java @@ -13,6 +13,7 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.core.BlockPos; import net.minecraft.world.level.Level; import net.minecraftforge.eventbus.api.bus.CancellableEventBus; +import net.minecraftforge.eventbus.api.event.MutableEvent; import net.minecraftforge.eventbus.api.event.characteristic.Cancellable; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -27,9 +28,10 @@ import org.jetbrains.annotations.Nullable; * setResult(ALLOW) is the same as the old setHandled() */ // TODO: Redesign BonemealEvent the whole thing, it doens't make sense. -public final class BonemealEvent extends PlayerEvent implements Cancellable, HasResult { +public final class BonemealEvent extends MutableEvent implements Cancellable, PlayerEvent, HasResult { public static final CancellableEventBus BUS = CancellableEventBus.create(BonemealEvent.class); + private final Player player; private final Level level; private final BlockPos pos; private final BlockState block; @@ -37,13 +39,18 @@ public final class BonemealEvent extends PlayerEvent implements Cancellable, Has private Result result = Result.DEFAULT; public BonemealEvent(@Nullable Player player, Level level, BlockPos pos, BlockState block, ItemStack stack) { - super(player); + this.player = player; this.level = level; this.pos = pos; this.block = block; this.stack = stack; } + @Override + public Player getEntity() { + return player; + } + public Level getLevel() { return level; } diff --git a/src/main/java/net/minecraftforge/event/entity/player/CriticalHitEvent.java b/src/main/java/net/minecraftforge/event/entity/player/CriticalHitEvent.java index 9426e82330..fb4b357b7d 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/CriticalHitEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/CriticalHitEvent.java @@ -5,26 +5,26 @@ package net.minecraftforge.event.entity.player; -import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.util.HasResult; import net.minecraftforge.common.util.Result; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.player.Player; +import net.minecraftforge.eventbus.api.bus.EventBus; +import net.minecraftforge.eventbus.api.event.MutableEvent; /** * This event is fired whenever a player attacks an Entity in * EntityPlayer#attackTargetEntityWithCurrentItem(Entity).
      *
      - * This event is not {@link Cancelable}.
      - *
      * This event has a result. {@link HasResult}
      * DEFAULT: means the vanilla logic will determine if this a critical hit.
      * DENY: it will not be a critical hit but the player still will attack
      * ALLOW: this attack is forced to be critical - *
      - * This event is fired on the {@link MinecraftForge#EVENT_BUS}. **/ -public final class CriticalHitEvent extends PlayerEvent implements HasResult { +public final class CriticalHitEvent extends MutableEvent implements PlayerEvent, HasResult { + public static final EventBus BUS = EventBus.create(CriticalHitEvent.class); + + private final Player player; private float damageModifier; private final float oldDamageModifier; private final Entity target; @@ -32,12 +32,17 @@ public final class CriticalHitEvent extends PlayerEvent implements HasResult { private Result result = Result.DEFAULT; public CriticalHitEvent(Player player, Entity target, float damageModifier, boolean vanillaCritical) { - super(player); + this.player = player; this.target = target; this.damageModifier = damageModifier; this.oldDamageModifier = damageModifier; this.vanillaCritical = vanillaCritical; } + + @Override + public Player getEntity() { + return player; + } /** * The Entity that was damaged by the player. diff --git a/src/main/java/net/minecraftforge/event/entity/player/EntityItemPickupEvent.java b/src/main/java/net/minecraftforge/event/entity/player/EntityItemPickupEvent.java index 6f9c6934dc..be9570cff2 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/EntityItemPickupEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/EntityItemPickupEvent.java @@ -10,6 +10,7 @@ import net.minecraftforge.common.util.Result; import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.entity.player.Player; import net.minecraftforge.eventbus.api.bus.CancellableEventBus; +import net.minecraftforge.eventbus.api.event.MutableEvent; import net.minecraftforge.eventbus.api.event.characteristic.Cancellable; /** @@ -22,17 +23,23 @@ import net.minecraftforge.eventbus.api.event.characteristic.Cancellable; * * setResult(ALLOW) is the same as the old setHandled() */ -public final class EntityItemPickupEvent extends PlayerEvent implements Cancellable, HasResult { +public final class EntityItemPickupEvent extends MutableEvent implements Cancellable, PlayerEvent, HasResult { public static final CancellableEventBus BUS = CancellableEventBus.create(EntityItemPickupEvent.class); + private final Player player; private final ItemEntity item; private Result result = Result.DEFAULT; public EntityItemPickupEvent(Player player, ItemEntity item) { - super(player); + this.player = player; this.item = item; } + @Override + public Player getEntity() { + return player; + } + public ItemEntity getItem() { return item; } diff --git a/src/main/java/net/minecraftforge/event/entity/player/FillBucketEvent.java b/src/main/java/net/minecraftforge/event/entity/player/FillBucketEvent.java index afaa628fa8..ef22066c7f 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/FillBucketEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/FillBucketEvent.java @@ -12,6 +12,7 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.phys.HitResult; import net.minecraft.world.level.Level; import net.minecraftforge.eventbus.api.bus.CancellableEventBus; +import net.minecraftforge.eventbus.api.event.MutableEvent; import net.minecraftforge.eventbus.api.event.characteristic.Cancellable; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -25,9 +26,10 @@ import org.jetbrains.annotations.Nullable; * ItemStack to your inventory and reducing the stack size to process. * setResult(ALLOW) is the same as the old setHandled(); */ -public final class FillBucketEvent extends PlayerEvent implements Cancellable, HasResult { +public final class FillBucketEvent extends MutableEvent implements Cancellable, PlayerEvent, HasResult { public static final CancellableEventBus BUS = CancellableEventBus.create(FillBucketEvent.class); + private final Player player; private final ItemStack current; private final Level level; @Nullable @@ -37,12 +39,17 @@ public final class FillBucketEvent extends PlayerEvent implements Cancellable, H private Result eventResult = Result.DEFAULT; public FillBucketEvent(Player player, @NotNull ItemStack current, Level level, @Nullable HitResult target) { - super(player); + this.player = player; this.current = current; this.level = level; this.target = target; } + @Override + public Player getEntity() { + return player; + } + @NotNull public ItemStack getEmptyBucket() { return this.current; } public Level getLevel(){ return this.level; } diff --git a/src/main/java/net/minecraftforge/event/entity/player/ItemFishedEvent.java b/src/main/java/net/minecraftforge/event/entity/player/ItemFishedEvent.java index 66daef50ff..14ffd146c3 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/ItemFishedEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/ItemFishedEvent.java @@ -6,10 +6,12 @@ package net.minecraftforge.event.entity.player; import com.google.common.base.Preconditions; +import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.projectile.FishingHook; import net.minecraft.world.item.ItemStack; import net.minecraft.core.NonNullList; import net.minecraftforge.eventbus.api.bus.CancellableEventBus; +import net.minecraftforge.eventbus.api.event.MutableEvent; import net.minecraftforge.eventbus.api.event.characteristic.Cancellable; import javax.annotation.Nonnegative; @@ -17,25 +19,30 @@ import java.util.List; /** * This event is called when a player fishes an item. - * - * This event is {@link net.minecraftforge.eventbus.api.Cancelable} - * Canceling the event will cause the player to receive no items at all. - * The hook will still take the damage specified + *
      + * This event is {@linkplain Cancellable cancellable}. If cancelled, the player will not receive any items, but the hook + * will still take the damage specified */ -public final class ItemFishedEvent extends PlayerEvent implements Cancellable { +public final class ItemFishedEvent extends MutableEvent implements Cancellable, PlayerEvent { public static final CancellableEventBus BUS = CancellableEventBus.create(ItemFishedEvent.class); + private final Player player; private final NonNullList stacks = NonNullList.create(); private final FishingHook hook; private int rodDamage; public ItemFishedEvent(List stacks, int rodDamage, FishingHook hook) { - super(hook.getPlayerOwner()); + this.player = hook.getPlayerOwner(); this.stacks.addAll(stacks); this.rodDamage = rodDamage; this.hook = hook; } + @Override + public Player getEntity() { + return player; + } + /** * Get the damage the rod will take. * @return The damage the rod will take diff --git a/src/main/java/net/minecraftforge/event/entity/player/ItemTooltipEvent.java b/src/main/java/net/minecraftforge/event/entity/player/ItemTooltipEvent.java index 020191bde5..204d9cc808 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/ItemTooltipEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/ItemTooltipEvent.java @@ -13,12 +13,14 @@ import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.network.chat.Component; import net.minecraftforge.eventbus.api.bus.EventBus; +import net.minecraftforge.eventbus.api.event.MutableEvent; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -public final class ItemTooltipEvent extends PlayerEvent { +public final class ItemTooltipEvent extends MutableEvent implements PlayerEvent { public static final EventBus BUS = EventBus.create(ItemTooltipEvent.class); + private final Player player; private final TooltipFlag flags; @NotNull private final ItemStack itemStack; @@ -30,7 +32,7 @@ public final class ItemTooltipEvent extends PlayerEvent { */ public ItemTooltipEvent(@NotNull ItemStack itemStack, @Nullable Player player, List list, TooltipFlag flags) { - super(player); + this.player = player; this.itemStack = itemStack; this.toolTip = list; this.flags = flags; @@ -68,6 +70,6 @@ public final class ItemTooltipEvent extends PlayerEvent { @Nullable public Player getEntity() { - return super.getEntity(); + return player; } } diff --git a/src/main/java/net/minecraftforge/event/entity/player/PermissionsChangedEvent.java b/src/main/java/net/minecraftforge/event/entity/player/PermissionsChangedEvent.java index 325668be04..bc3d6d10af 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/PermissionsChangedEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/PermissionsChangedEvent.java @@ -7,35 +7,19 @@ package net.minecraftforge.event.entity.player; import net.minecraft.server.level.ServerPlayer; import net.minecraftforge.eventbus.api.bus.CancellableEventBus; +import net.minecraftforge.eventbus.api.event.RecordEvent; import net.minecraftforge.eventbus.api.event.characteristic.Cancellable; +import org.jspecify.annotations.NullMarked; /** * This event will fire when the player is opped or deopped. *

      * This event is cancelable which will stop the op or deop from happening. + * @param getNewLevel The new permission level. + * @param getOldLevel The old permission level. */ -public final class PermissionsChangedEvent extends PlayerEvent implements Cancellable { +@NullMarked +public record PermissionsChangedEvent(ServerPlayer getEntity, int getNewLevel, int getOldLevel) + implements Cancellable, PlayerEvent, RecordEvent { public static final CancellableEventBus BUS = CancellableEventBus.create(PermissionsChangedEvent.class); - - private final int newLevel; - private final int oldLevel; - - public PermissionsChangedEvent(ServerPlayer player, int newLevel, int oldLevel) { - super(player); - this.oldLevel = oldLevel; - this.newLevel = newLevel; - } - - /** - * @return The new permission level. - */ - public int getNewLevel() { - return newLevel; - } - /** - * @return The old permission level. - */ - public int getOldLevel() { - return oldLevel; - } } diff --git a/src/main/java/net/minecraftforge/event/entity/player/PlayerContainerEvent.java b/src/main/java/net/minecraftforge/event/entity/player/PlayerContainerEvent.java index 8e02813c51..4794253c7c 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/PlayerContainerEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/PlayerContainerEvent.java @@ -8,34 +8,18 @@ package net.minecraftforge.event.entity.player; import net.minecraft.world.entity.player.Player; import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraftforge.eventbus.api.bus.EventBus; +import net.minecraftforge.eventbus.api.event.InheritableEvent; -public sealed class PlayerContainerEvent extends PlayerEvent { - public static final EventBus BUS = EventBus.create(PlayerContainerEvent.class); +public sealed interface PlayerContainerEvent extends PlayerEvent, InheritableEvent { + EventBus BUS = EventBus.create(PlayerContainerEvent.class); - private final AbstractContainerMenu container; + AbstractContainerMenu getContainer(); - public PlayerContainerEvent(Player player, AbstractContainerMenu container) { - super(player); - this.container = container; - } - - public static final class Open extends PlayerContainerEvent { + record Open(Player getEntity, AbstractContainerMenu getContainer) implements PlayerContainerEvent { public static final EventBus BUS = EventBus.create(Open.class); - - public Open(Player player, AbstractContainerMenu container) { - super(player, container); - } } - public static final class Close extends PlayerContainerEvent { + record Close(Player getEntity, AbstractContainerMenu getContainer) implements PlayerContainerEvent { public static final EventBus BUS = EventBus.create(Close.class); - - public Close(Player player, AbstractContainerMenu container) { - super(player, container); - } - } - - public AbstractContainerMenu getContainer() { - return container; } } diff --git a/src/main/java/net/minecraftforge/event/entity/player/PlayerDestroyItemEvent.java b/src/main/java/net/minecraftforge/event/entity/player/PlayerDestroyItemEvent.java index b528cd36eb..d79d81e789 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/PlayerDestroyItemEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/PlayerDestroyItemEvent.java @@ -18,11 +18,11 @@ import net.minecraft.world.InteractionHand; import net.minecraft.world.level.Level; import net.minecraft.world.phys.BlockHitResult; import net.minecraftforge.common.ForgeHooks; -import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.ForgeEventFactory; import net.minecraftforge.eventbus.api.bus.EventBus; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import net.minecraftforge.eventbus.api.event.RecordEvent; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; /** * PlayerDestroyItemEvent is fired when a player destroys an item.
      @@ -41,34 +41,12 @@ import org.jetbrains.annotations.Nullable; * {@link #original} contains the original ItemStack before the item was destroyed.
      * (@link #hand) contains the hand that the current item was held in.
      *
      - * This event is not {@link Cancelable}.
      - *
      - * This event does not have a result. {@link HasResult}
      - *
      * This event is fired from {@link ForgeEventFactory#onPlayerDestroyItem(Player, ItemStack, InteractionHand)}.
      - * This event is fired on the {@link MinecraftForge#EVENT_BUS}. + * + * @param getSlot May be null if this player destroys the item by any use besides holding it. **/ -public final class PlayerDestroyItemEvent extends PlayerEvent { +@NullMarked +public record PlayerDestroyItemEvent(Player getEntity, ItemStack getOriginal, @Nullable EquipmentSlot getSlot) + implements PlayerEvent, RecordEvent { public static final EventBus BUS = EventBus.create(PlayerDestroyItemEvent.class); - - @NotNull - private final ItemStack original; - @Nullable - private final EquipmentSlot slot; // May be null if this player destroys the item by any use besides holding it. - - public PlayerDestroyItemEvent(Player player, @NotNull ItemStack original, @Nullable EquipmentSlot slot) { - super(player); - this.original = original; - this.slot = slot; - } - - @NotNull - public ItemStack getOriginal() { - return this.original; - } - - @Nullable - public EquipmentSlot getSlot() { - return this.slot; - } } diff --git a/src/main/java/net/minecraftforge/event/entity/player/PlayerEvent.java b/src/main/java/net/minecraftforge/event/entity/player/PlayerEvent.java index e116002fc0..33236758c8 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/PlayerEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/PlayerEvent.java @@ -15,7 +15,6 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.resources.ResourceKey; import net.minecraft.world.level.GameType; import net.minecraft.world.level.Level; -import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.ForgeEventFactory; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.entity.Entity; @@ -25,29 +24,21 @@ import net.minecraft.network.chat.Component; import net.minecraftforge.event.entity.living.LivingEvent; import net.minecraftforge.eventbus.api.bus.CancellableEventBus; import net.minecraftforge.eventbus.api.bus.EventBus; +import net.minecraftforge.eventbus.api.event.MutableEvent; +import net.minecraftforge.eventbus.api.event.RecordEvent; import net.minecraftforge.eventbus.api.event.characteristic.Cancellable; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.NullMarked; /** * PlayerEvent is fired whenever an event involving a {@link Player} occurs.
      * If a method utilizes this {@link net.minecraftforge.eventbus.api.Event} as its parameter, the method will * receive every child event of this class.
      **/ -public class PlayerEvent extends LivingEvent { - public static final EventBus BUS = EventBus.create(PlayerEvent.class); - - private final Player player; - - public PlayerEvent(Player player) { - super(player); - this.player = player; - } - +public interface PlayerEvent extends LivingEvent { @Override - public Player getEntity() { - return player; - } + Player getEntity(); /** * HarvestCheck is fired when a player attempts to harvest a block.
      @@ -59,18 +50,24 @@ public class PlayerEvent extends LivingEvent { * {@link #state} contains the {@link BlockState} that is being checked for harvesting.
      * {@link #success} contains the boolean value for whether the Block will be successfully harvested.
      **/ - public static final class HarvestCheck extends PlayerEvent { + final class HarvestCheck extends MutableEvent implements PlayerEvent { public static final EventBus BUS = EventBus.create(HarvestCheck.class); + private final Player player; private final BlockState state; private boolean success; public HarvestCheck(Player player, BlockState state, boolean success) { - super(player); + this.player = player; this.state = state; this.success = success; } + @Override + public Player getEntity() { + return this.player; + } + public BlockState getTargetBlock() { return this.state; } public boolean canHarvest() { return this.success; } public void setCanHarvest(boolean success) { this.success = success; } @@ -88,25 +85,30 @@ public class PlayerEvent extends LivingEvent { * {@link #newSpeed} contains the newSpeed at which the player will break the block.
      * {@link #pos} contains the coordinates at which this event is occurring. Optional value.
      *
      - * If it is canceled, the player is unable to break the block.
      + * If it is cancelled, the player is unable to break the block.
      **/ - public static final class BreakSpeed extends PlayerEvent implements Cancellable { + final class BreakSpeed extends MutableEvent implements Cancellable, PlayerEvent { public static final CancellableEventBus BUS = CancellableEventBus.create(BreakSpeed.class); - private static final BlockPos LEGACY_UNKNOWN = new BlockPos(0, -1, 0); + private final Player player; private final BlockState state; private final float originalSpeed; private float newSpeed = 0.0f; private final Optional pos; // Y position of -1 notes unknown location public BreakSpeed(Player player, BlockState state, float original, @Nullable BlockPos pos) { - super(player); + this.player = player; this.state = state; this.originalSpeed = original; this.setNewSpeed(original); this.pos = Optional.ofNullable(pos); } + @Override + public Player getEntity() { + return this.player; + } + public BlockState getState() { return state; } public float getOriginalSpeed() { return originalSpeed; } public float getNewSpeed() { return newSpeed; } @@ -124,18 +126,24 @@ public class PlayerEvent extends LivingEvent { * {@link #username} contains the username of the player. * {@link #displayname} contains the display name of the player. **/ - public static final class NameFormat extends PlayerEvent { + final class NameFormat extends MutableEvent implements PlayerEvent { public static final EventBus BUS = EventBus.create(NameFormat.class); + private final Player player; private final Component username; private Component displayname; public NameFormat(Player player, Component username) { - super(player); + this.player = player; this.username = username; this.setDisplayname(username); } + @Override + public Player getEntity() { + return this.player; + } + public Component getUsername() { return username; } @@ -158,14 +166,21 @@ public class PlayerEvent extends LivingEvent { *
      * {@link #getDisplayName()} contains the display name of the player or null if the client should determine the display name itself. **/ - public static final class TabListNameFormat extends PlayerEvent { + final class TabListNameFormat extends MutableEvent implements PlayerEvent { public static final EventBus BUS = EventBus.create(TabListNameFormat.class); + private final Player player; + @Nullable private Component displayName; public TabListNameFormat(Player player) { - super(player); + this.player = player; + } + + @Override + public Player getEntity() { + return player; } @Nullable @@ -181,77 +196,30 @@ public class PlayerEvent extends LivingEvent { /** * Fired when the EntityPlayer is cloned, typically caused by the impl sending a RESPAWN_PLAYER event. * Either caused by death, or by traveling from the End to the overworld. + * + * @param getOriginal The old EntityPlayer that this new entity is a clone of. + * @param isWasDeath True if this event was fired because the player died. False if it was fired because the entity switched dimensions. */ - public static final class Clone extends PlayerEvent { + record Clone(Player getEntity, Player getOriginal, boolean isWasDeath) implements RecordEvent, PlayerEvent { public static final EventBus BUS = EventBus.create(Clone.class); - - private final Player original; - private final boolean wasDeath; - - public Clone(Player _new, Player oldPlayer, boolean wasDeath) { - super(_new); - this.original = oldPlayer; - this.wasDeath = wasDeath; - } - - /** - * The old EntityPlayer that this new entity is a clone of. - */ - public Player getOriginal() { - return original; - } - - /** - * True if this event was fired because the player died. - * False if it was fired because the entity switched dimensions. - */ - public boolean isWasDeath() { - return wasDeath; - } } /** * Fired when an Entity is started to be "tracked" by this player (the player receives updates about this entity, e.g. motion). * + * @param getTarget The entity now being tracked. */ - public static final class StartTracking extends PlayerEvent { + record StartTracking(Player getEntity, Entity getTarget) implements RecordEvent, PlayerEvent { public static final EventBus BUS = EventBus.create(StartTracking.class); - - private final Entity target; - - public StartTracking(Player player, Entity target) { - super(player); - this.target = target; - } - - /** - * The Entity now being tracked. - */ - public Entity getTarget() { - return target; - } } /** * Fired when an Entity is stopped to be "tracked" by this player (the player no longer receives updates about this entity, e.g. motion). * + * @param getTarget The entity no longer being tracked. */ - public static final class StopTracking extends PlayerEvent { + record StopTracking(Player getEntity, Entity getTarget) implements RecordEvent, PlayerEvent { public static final EventBus BUS = EventBus.create(StopTracking.class); - - private final Entity target; - - public StopTracking(Player player, Entity target) { - super(player); - this.target = target; - } - - /** - * The Entity no longer being tracked. - */ - public Entity getTarget() { - return target; - } } /** @@ -260,18 +228,9 @@ public class PlayerEvent extends LivingEvent { * allow mods to load an additional file from the players directory * containing additional mod related player data. */ - public static final class LoadFromFile extends PlayerEvent { + record LoadFromFile(Player getEntity, File getPlayerDirectory, String getPlayerUUID) implements RecordEvent, PlayerEvent { public static final EventBus BUS = EventBus.create(LoadFromFile.class); - private final File playerDirectory; - private final String playerUUID; - - public LoadFromFile(Player player, File originDirectory, String playerUUID) { - super(player); - this.playerDirectory = originDirectory; - this.playerUUID = playerUUID; - } - /** * Construct and return a recommended file for the supplied suffix * @param suffix The suffix to use. @@ -286,7 +245,7 @@ public class PlayerEvent extends LivingEvent { * to locate your mod additional file. */ public File getPlayerDirectory() { - return playerDirectory; + return getPlayerDirectory; } /** @@ -294,7 +253,7 @@ public class PlayerEvent extends LivingEvent { * It is broken out here for convenience for quick file generation. */ public String getPlayerUUID() { - return playerUUID; + return getPlayerUUID; } } /** @@ -310,18 +269,9 @@ public class PlayerEvent extends LivingEvent { * WARNING: Do not overwrite the player's .dat file here. You will * corrupt the world state. */ - public static final class SaveToFile extends PlayerEvent { + record SaveToFile(Player getEntity, File getPlayerDirectory, String getPlayerUUID) implements RecordEvent, PlayerEvent { public static final EventBus BUS = EventBus.create(SaveToFile.class); - private final File playerDirectory; - private final String playerUUID; - - public SaveToFile(Player player, File originDirectory, String playerUUID) { - super(player); - this.playerDirectory = originDirectory; - this.playerUUID = playerUUID; - } - /** * Construct and return a recommended file for the supplied suffix * @param suffix The suffix to use. @@ -336,7 +286,7 @@ public class PlayerEvent extends LivingEvent { * to locate your mod additional file. */ public File getPlayerDirectory() { - return playerDirectory; + return getPlayerDirectory; } /** @@ -344,149 +294,76 @@ public class PlayerEvent extends LivingEvent { * It is broken out here for convenience for quick file generation. */ public String getPlayerUUID() { - return playerUUID; + return getPlayerUUID; } } - public static final class ItemPickupEvent extends PlayerEvent { + /** + * @param getOriginalEntity Original EntityItem with current remaining stack size + * @param getStack Clone item stack, containing the item and amount picked up + */ + record ItemPickupEvent(Player getEntity, ItemEntity getOriginalEntity, ItemStack getStack) + implements RecordEvent, PlayerEvent { public static final EventBus BUS = EventBus.create(ItemPickupEvent.class); - - /** - * Original EntityItem with current remaining stack size - */ - private final ItemEntity originalEntity; - /** - * Clone item stack, containing the item and amount picked up - */ - private final ItemStack stack; - - public ItemPickupEvent(Player player, ItemEntity entPickedUp, ItemStack stack) { - super(player); - this.originalEntity = entPickedUp; - this.stack = stack; - } - - public ItemStack getStack() { - return stack; - } - - public ItemEntity getOriginalEntity() { - return originalEntity; - } } - public static final class ItemCraftedEvent extends PlayerEvent { + record ItemCraftedEvent(Player getEntity, @NotNull ItemStack getCrafting, Container getContainer) + implements RecordEvent, PlayerEvent { public static final EventBus BUS = EventBus.create(ItemCraftedEvent.class); - - @NotNull - private final ItemStack crafting; - private final Container craftMatrix; - - public ItemCraftedEvent(Player player, @NotNull ItemStack crafting, Container craftMatrix) { - super(player); - this.crafting = crafting; - this.craftMatrix = craftMatrix; - } - - @NotNull - public ItemStack getCrafting() { - return this.crafting; - } - - public Container getInventory() { - return this.craftMatrix; - } } - public static final class ItemSmeltedEvent extends PlayerEvent { + @NullMarked + record ItemSmeltedEvent(Player getEntity, ItemStack getSmelting) implements RecordEvent, PlayerEvent { public static final EventBus BUS = EventBus.create(ItemSmeltedEvent.class); - - @NotNull - private final ItemStack smelting; - - public ItemSmeltedEvent(Player player, @NotNull ItemStack crafting) { - super(player); - this.smelting = crafting; - } - - @NotNull - public ItemStack getSmelting() { - return this.smelting; - } } - public static final class PlayerLoggedInEvent extends PlayerEvent { + record PlayerLoggedInEvent(Player getEntity) implements RecordEvent, PlayerEvent { public static final EventBus BUS = EventBus.create(PlayerLoggedInEvent.class); - - public PlayerLoggedInEvent(Player player) { - super(player); - } } - public static final class PlayerLoggedOutEvent extends PlayerEvent { + record PlayerLoggedOutEvent(Player getEntity) implements RecordEvent, PlayerEvent { public static final EventBus BUS = EventBus.create(PlayerLoggedOutEvent.class); - - public PlayerLoggedOutEvent(Player player) { - super(player); - } } - public static final class PlayerRespawnEvent extends PlayerEvent { + record PlayerRespawnEvent(Player getEntity, boolean isEndConquered) implements RecordEvent, PlayerEvent { public static final EventBus BUS = EventBus.create(PlayerRespawnEvent.class); - private final boolean endConquered; - - public PlayerRespawnEvent(Player player, boolean endConquered) { - super(player); - this.endConquered = endConquered; - } - /** * Did this respawn event come from the player conquering the end? * @return if this respawn was because the player conquered the end */ public boolean isEndConquered() { - return this.endConquered; + return isEndConquered; } } - public static final class PlayerChangedDimensionEvent extends PlayerEvent { + record PlayerChangedDimensionEvent(Player getEntity, ResourceKey getFrom, ResourceKey getTo) + implements RecordEvent, PlayerEvent { public static final EventBus BUS = EventBus.create(PlayerChangedDimensionEvent.class); - - private final ResourceKey fromDim; - private final ResourceKey toDim; - - public PlayerChangedDimensionEvent(Player player, ResourceKey fromDim, ResourceKey toDim) { - super(player); - this.fromDim = fromDim; - this.toDim = toDim; - } - - public ResourceKey getFrom() { - return this.fromDim; - } - - public ResourceKey getTo() { - return this.toDim; - } } /** * Fired when the game type of a server player is changed to a different value than what it was previously. Eg Creative to Survival, not Survival to Survival. * If the event is cancelled the game mode of the player is not changed and the value of newGameMode is ignored. */ - public static final class PlayerChangeGameModeEvent extends PlayerEvent implements Cancellable { + final class PlayerChangeGameModeEvent extends MutableEvent implements Cancellable, PlayerEvent { public static final CancellableEventBus BUS = CancellableEventBus.create(PlayerChangeGameModeEvent.class); + private final Player player; private final GameType currentGameMode; private GameType newGameMode; public PlayerChangeGameModeEvent(Player player, GameType currentGameMode, GameType newGameMode) { - super(player); + this.player = player; this.currentGameMode = currentGameMode; this.newGameMode = newGameMode; } + @Override + public Player getEntity() { + return this.player; + } + public GameType getCurrentGameMode() { return currentGameMode; } diff --git a/src/main/java/net/minecraftforge/event/entity/player/PlayerFlyableFallEvent.java b/src/main/java/net/minecraftforge/event/entity/player/PlayerFlyableFallEvent.java index fffb4df28f..2b7a48e90f 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/PlayerFlyableFallEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/PlayerFlyableFallEvent.java @@ -7,24 +7,32 @@ package net.minecraftforge.event.entity.player; import net.minecraft.world.entity.player.Player; import net.minecraftforge.eventbus.api.bus.EventBus; +import net.minecraftforge.eventbus.api.event.MutableEvent; +import org.jspecify.annotations.NullMarked; /** * Occurs when a player falls, but is able to fly. Doesn't need to be cancelable, this is mainly for notification purposes. * @author Mithion - * */ -public final class PlayerFlyableFallEvent extends PlayerEvent { +@NullMarked +public final class PlayerFlyableFallEvent extends MutableEvent implements PlayerEvent { public static final EventBus BUS = EventBus.create(PlayerFlyableFallEvent.class); + private final Player player; private float distance; private float multiplier; public PlayerFlyableFallEvent(Player player, float distance, float multiplier) { - super(player); + this.player = player; this.distance = distance; this.multiplier = multiplier; } + @Override + public Player getEntity() { + return player; + } + public float getDistance() { return distance;} public void setDistance(float distance) { this.distance = distance; } public float getMultiplier() { return multiplier; } diff --git a/src/main/java/net/minecraftforge/event/entity/player/PlayerInteractEvent.java b/src/main/java/net/minecraftforge/event/entity/player/PlayerInteractEvent.java index 298656cf7e..00bc8bb10a 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/PlayerInteractEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/PlayerInteractEvent.java @@ -28,6 +28,7 @@ import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.util.Result; import net.minecraftforge.eventbus.api.bus.CancellableEventBus; import net.minecraftforge.eventbus.api.bus.EventBus; +import net.minecraftforge.eventbus.api.event.InheritableEvent; import net.minecraftforge.eventbus.api.event.characteristic.Cancellable; import net.minecraftforge.fml.LogicalSide; @@ -35,14 +36,17 @@ import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.util.Objects; + /** * PlayerInteractEvent is fired when a player interacts in some way. * All subclasses are fired on {@link MinecraftForge#EVENT_BUS}. * See the individual documentation on each subevent for more details. **/ -public sealed class PlayerInteractEvent extends PlayerEvent { +public sealed abstract class PlayerInteractEvent implements PlayerEvent, InheritableEvent { public static final EventBus BUS = EventBus.create(PlayerInteractEvent.class); + private final Player player; private final InteractionHand hand; private final BlockPos pos; @Nullable @@ -50,12 +54,17 @@ public sealed class PlayerInteractEvent extends PlayerEvent { private InteractionResult cancellationResult = InteractionResult.PASS; private PlayerInteractEvent(Player player, InteractionHand hand, BlockPos pos, @Nullable Direction face) { - super(Preconditions.checkNotNull(player, "Null player in PlayerInteractEvent!")); + this.player = Objects.requireNonNull(player, "Null player in PlayerInteractEvent!"); this.hand = Preconditions.checkNotNull(hand, "Null hand in PlayerInteractEvent!"); this.pos = Preconditions.checkNotNull(pos, "Null position in PlayerInteractEvent!"); this.face = face; } + @Override + public Player getEntity() { + return player; + } + /** * This event is fired on both sides whenever a player right clicks an entity. * @@ -362,7 +371,7 @@ public sealed class PlayerInteractEvent extends PlayerEvent { * @return The effective, i.e. logical, side of this interaction. This will be {@link LogicalSide#CLIENT} on the client thread, and {@link LogicalSide#SERVER} on the server thread. */ public LogicalSide getSide() { - return getLevel().isClientSide ? LogicalSide.CLIENT : LogicalSide.SERVER; + return getLevel().isClientSide() ? LogicalSide.CLIENT : LogicalSide.SERVER; } /** diff --git a/src/main/java/net/minecraftforge/event/entity/player/PlayerSetSpawnEvent.java b/src/main/java/net/minecraftforge/event/entity/player/PlayerSetSpawnEvent.java index e4b32535c4..193db7b4f7 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/PlayerSetSpawnEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/PlayerSetSpawnEvent.java @@ -7,9 +7,11 @@ package net.minecraftforge.event.entity.player; import net.minecraft.resources.ResourceKey; import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.Level; import net.minecraft.core.BlockPos; import net.minecraftforge.eventbus.api.bus.CancellableEventBus; +import net.minecraftforge.eventbus.api.event.MutableEvent; import net.minecraftforge.eventbus.api.event.characteristic.Cancellable; import org.jetbrains.annotations.Nullable; @@ -18,9 +20,10 @@ import org.jetbrains.annotations.Nullable; *

      * The event can be canceled, which will prevent the spawn point from being changed. */ -public final class PlayerSetSpawnEvent extends PlayerEvent implements Cancellable { +public final class PlayerSetSpawnEvent extends MutableEvent implements Cancellable, PlayerEvent { public static final CancellableEventBus BUS = CancellableEventBus.create(PlayerSetSpawnEvent.class); + private final Player player; private final @Nullable ServerPlayer.RespawnConfig config; @Deprecated(forRemoval = true, since = "1.21.5") @@ -31,13 +34,23 @@ public final class PlayerSetSpawnEvent extends PlayerEvent implements Cancellabl private final @Nullable BlockPos newSpawn; public PlayerSetSpawnEvent(ServerPlayer player, @Nullable ServerPlayer.RespawnConfig config) { - super(player); + this.player = player; this.config = config; - boolean hasConfig = config != null; - this.forced = hasConfig && config.forced(); - this.spawnLevel = hasConfig ? config.dimension() : Level.OVERWORLD; - this.newSpawn = hasConfig ? config.pos() : null; + if (config == null) { + this.forced = false; + this.spawnLevel = Level.OVERWORLD; + this.newSpawn = null; + } else { + this.forced = config.forced(); + this.spawnLevel = config.respawnData().dimension(); + this.newSpawn = config.respawnData().pos(); + } + } + + @Override + public Player getEntity() { + return player; } /** @return The config for the player respawn */ diff --git a/src/main/java/net/minecraftforge/event/entity/player/PlayerSleepInBedEvent.java b/src/main/java/net/minecraftforge/event/entity/player/PlayerSleepInBedEvent.java index a75cf9db21..d3f0e9c16e 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/PlayerSleepInBedEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/PlayerSleepInBedEvent.java @@ -8,8 +8,8 @@ package net.minecraftforge.event.entity.player; import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player.BedSleepingProblem; import net.minecraft.core.BlockPos; -import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.eventbus.api.bus.EventBus; +import net.minecraftforge.eventbus.api.event.MutableEvent; import java.util.Optional; @@ -20,22 +20,24 @@ import java.util.Optional; * {@link Player#startSleeping(BlockPos)}.
      *
      * {@link #result} contains whether the player is able to sleep.
      - *
      - * This event does not have a result. {@link HasResult} - *
      - * This event is fired on the {@link MinecraftForge#EVENT_BUS}. - **/ -public final class PlayerSleepInBedEvent extends PlayerEvent { + */ +public final class PlayerSleepInBedEvent extends MutableEvent implements PlayerEvent { public static final EventBus BUS = EventBus.create(PlayerSleepInBedEvent.class); + private final Player player; private BedSleepingProblem result = null; private final Optional pos; public PlayerSleepInBedEvent(Player player, Optional pos) { - super(player); + this.player = player; this.pos = pos; } + @Override + public Player getEntity() { + return this.player; + } + public BedSleepingProblem getResultStatus() { return result; } diff --git a/src/main/java/net/minecraftforge/event/entity/player/PlayerSpawnPhantomsEvent.java b/src/main/java/net/minecraftforge/event/entity/player/PlayerSpawnPhantomsEvent.java index 7b2abc24a1..ac6702a07e 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/PlayerSpawnPhantomsEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/PlayerSpawnPhantomsEvent.java @@ -7,10 +7,10 @@ package net.minecraftforge.event.entity.player; import net.minecraft.world.level.levelgen.PhantomSpawner; import net.minecraft.world.entity.player.Player; -import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.util.HasResult; import net.minecraftforge.common.util.Result; import net.minecraftforge.eventbus.api.bus.EventBus; +import net.minecraftforge.eventbus.api.event.MutableEvent; import org.jetbrains.annotations.NotNull; /** @@ -20,21 +20,25 @@ import org.jetbrains.annotations.NotNull; * This event is fired before any per-player checks (but after {@link Player#isSpectator()}), but after all global checks.
      * The behavior of {@link PhantomSpawner} is determined by the result of this event.
      * See {@link #setResult} for documentation.
      - *

      - * This event is fired on the {@link MinecraftForge#EVENT_BUS}.
      * @see PlayerSpawnPhantomsEvent#setResult for the effects of each result. */ -public final class PlayerSpawnPhantomsEvent extends PlayerEvent implements HasResult { +public final class PlayerSpawnPhantomsEvent extends MutableEvent implements PlayerEvent, HasResult { public static final EventBus BUS = EventBus.create(PlayerSpawnPhantomsEvent.class); + private final Player player; private int phantomsToSpawn; private Result result = Result.DEFAULT; public PlayerSpawnPhantomsEvent(Player player, int phantomsToSpawn) { - super(player); + this.player = player; this.phantomsToSpawn = phantomsToSpawn; } + @Override + public Player getEntity() { + return player; + } + /** * @return How many phantoms will be spawned, if spawning is successful. The default value is randomly generated. */ diff --git a/src/main/java/net/minecraftforge/event/entity/player/PlayerWakeUpEvent.java b/src/main/java/net/minecraftforge/event/entity/player/PlayerWakeUpEvent.java index 6792cb33c7..7a306f271e 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/PlayerWakeUpEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/PlayerWakeUpEvent.java @@ -7,24 +7,19 @@ package net.minecraftforge.event.entity.player; import net.minecraft.world.entity.player.Player; import net.minecraftforge.eventbus.api.bus.EventBus; +import net.minecraftforge.eventbus.api.event.RecordEvent; +import org.jspecify.annotations.NullMarked; /** * This event is fired when the player is waking up.
      * This is merely for purposes of listening for this to happen.
      * There is nothing that can be manipulated with this event. */ -public final class PlayerWakeUpEvent extends PlayerEvent { +@NullMarked +public record PlayerWakeUpEvent(Player getEntity, boolean wakeImmediately, boolean updateLevel) + implements RecordEvent, PlayerEvent { public static final EventBus BUS = EventBus.create(PlayerWakeUpEvent.class); - private final boolean wakeImmediately; - private final boolean updateLevel; - - public PlayerWakeUpEvent(Player player, boolean wakeImmediately, boolean updateLevel) { - super(player); - this.wakeImmediately = wakeImmediately; - this.updateLevel = updateLevel; - } - /** * Used for the 'wake up animation'. * This is false if the player is considered 'sleepy' and the overlay should slowly fade away. diff --git a/src/main/java/net/minecraftforge/event/entity/player/PlayerXpEvent.java b/src/main/java/net/minecraftforge/event/entity/player/PlayerXpEvent.java index 1b1213967b..f0bcdc97b5 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/PlayerXpEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/PlayerXpEvent.java @@ -10,7 +10,10 @@ import net.minecraft.world.entity.player.Player; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.eventbus.api.bus.CancellableEventBus; import net.minecraftforge.eventbus.api.bus.EventBus; +import net.minecraftforge.eventbus.api.event.MutableEvent; +import net.minecraftforge.eventbus.api.event.RecordEvent; import net.minecraftforge.eventbus.api.event.characteristic.Cancellable; +import org.jspecify.annotations.NullMarked; /** * PlayerXpEvent is fired whenever an event involving player experience occurs.
      @@ -19,46 +22,37 @@ import net.minecraftforge.eventbus.api.event.characteristic.Cancellable; *
      * All children of this event are fired on the {@link MinecraftForge#EVENT_BUS}. */ -public sealed class PlayerXpEvent extends PlayerEvent { - public static final EventBus BUS = EventBus.create(PlayerXpEvent.class); - - public PlayerXpEvent(Player player) { - super(player); - } - +public sealed interface PlayerXpEvent extends PlayerEvent { /** * This event is fired after the player collides with an experience orb, but before the player has been given the experience. * It can be cancelled, and no further processing will be done. */ - public static final class PickupXp extends PlayerXpEvent implements Cancellable { + @NullMarked + record PickupXp(Player getEntity, ExperienceOrb getOrb) implements Cancellable, PlayerXpEvent, RecordEvent { public static final CancellableEventBus BUS = CancellableEventBus.create(PickupXp.class); - - private final ExperienceOrb orb; - - public PickupXp(Player player, ExperienceOrb orb) { - super(player); - this.orb = orb; - } - - public ExperienceOrb getOrb() { - return orb; - } } /** * This event is fired when the player's experience changes through the {@link Player#giveExperiencePoints(int)} method. * It can be cancelled, and no further processing will be done. */ - public static final class XpChange extends PlayerXpEvent implements Cancellable { + @NullMarked + final class XpChange extends MutableEvent implements Cancellable, PlayerXpEvent { public static final CancellableEventBus BUS = CancellableEventBus.create(XpChange.class); + private final Player player; private int amount; public XpChange(Player player, int amount) { - super(player); + this.player = player; this.amount = amount; } + @Override + public Player getEntity() { + return this.player; + } + public int getAmount() { return this.amount; } @@ -72,16 +66,23 @@ public sealed class PlayerXpEvent extends PlayerEvent { * This event is fired when the player's experience level changes through the {@link Player#giveExperienceLevels(int)} method. * It can be cancelled, and no further processing will be done. */ - public static final class LevelChange extends PlayerXpEvent implements Cancellable { + @NullMarked + final class LevelChange extends MutableEvent implements Cancellable, PlayerXpEvent { public static final CancellableEventBus BUS = CancellableEventBus.create(LevelChange.class); + private final Player player; private int levels; public LevelChange(Player player, int levels) { - super(player); + this.player = player; this.levels = levels; } + @Override + public Player getEntity() { + return this.player; + } + public int getLevels() { return this.levels; } diff --git a/src/main/java/net/minecraftforge/event/entity/player/SleepingLocationCheckEvent.java b/src/main/java/net/minecraftforge/event/entity/player/SleepingLocationCheckEvent.java index e7e7f6a648..c8febe1e4b 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/SleepingLocationCheckEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/SleepingLocationCheckEvent.java @@ -15,6 +15,7 @@ import net.minecraftforge.common.util.HasResult; import net.minecraftforge.common.util.Result; import net.minecraftforge.event.entity.living.LivingEvent; import net.minecraftforge.eventbus.api.bus.EventBus; +import net.minecraftforge.eventbus.api.event.MutableEvent; /** * This event is fired when game checks, if sleeping player should be still considered "in bed".
      @@ -25,17 +26,23 @@ import net.minecraftforge.eventbus.api.bus.EventBus; * setResult(ALLOW) informs game that player is still "in bed"
      * setResult(DEFAULT) causes game to check {@link Block#isBed(BlockState, BlockGetter, BlockPos, Entity)} instead */ -public final class SleepingLocationCheckEvent extends LivingEvent implements HasResult { +public final class SleepingLocationCheckEvent extends MutableEvent implements LivingEvent, HasResult { public static final EventBus BUS = EventBus.create(SleepingLocationCheckEvent.class); + private final LivingEntity entity; private final BlockPos sleepingLocation; private Result result = Result.DEFAULT; public SleepingLocationCheckEvent(LivingEntity player, BlockPos sleepingLocation) { - super(player); + this.entity = player; this.sleepingLocation = sleepingLocation; } + @Override + public LivingEntity getEntity() { + return entity; + } + public BlockPos getSleepingLocation() { return sleepingLocation; } diff --git a/src/main/java/net/minecraftforge/event/entity/player/SleepingTimeCheckEvent.java b/src/main/java/net/minecraftforge/event/entity/player/SleepingTimeCheckEvent.java index b5b42807a3..94b7c520ec 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/SleepingTimeCheckEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/SleepingTimeCheckEvent.java @@ -11,6 +11,7 @@ import net.minecraft.world.level.Level; import net.minecraftforge.common.util.HasResult; import net.minecraftforge.common.util.Result; import net.minecraftforge.eventbus.api.bus.EventBus; +import net.minecraftforge.eventbus.api.event.MutableEvent; import java.util.Optional; @@ -23,17 +24,23 @@ import java.util.Optional; * setResult(ALLOW) informs game that player can sleep at this time.
      * setResult(DEFAULT) causes game to check !{@link Level#isDay()} instead. */ -public final class SleepingTimeCheckEvent extends PlayerEvent implements HasResult { +public final class SleepingTimeCheckEvent extends MutableEvent implements PlayerEvent, HasResult { public static final EventBus BUS = EventBus.create(SleepingTimeCheckEvent.class); + private final Player player; private final Optional sleepingLocation; private Result result = Result.DEFAULT; public SleepingTimeCheckEvent(Player player, Optional sleepingLocation) { - super(player); + this.player = player; this.sleepingLocation = sleepingLocation; } + @Override + public Player getEntity() { + return player; + } + /** * Note that the sleeping location may be an approximated one. * @return The player's sleeping location. diff --git a/src/main/java/net/minecraftforge/event/entity/player/TradeWithVillagerEvent.java b/src/main/java/net/minecraftforge/event/entity/player/TradeWithVillagerEvent.java index 04885497de..565f510979 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/TradeWithVillagerEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/TradeWithVillagerEvent.java @@ -8,42 +8,26 @@ package net.minecraftforge.event.entity.player; import net.minecraft.world.entity.npc.AbstractVillager; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.trading.MerchantOffer; -import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.eventbus.api.bus.EventBus; +import net.minecraftforge.eventbus.api.event.RecordEvent; +import net.minecraftforge.fml.LogicalSide; import org.jetbrains.annotations.ApiStatus; /** * Fired when a player trades with an {@link AbstractVillager}. * - *

      This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain Event.HasResult have a result}.

      + *

      This event is fired only on the {@linkplain LogicalSide#SERVER logical server}.

      * - *

      This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus}, - * only on the {@linkplain LogicalSide#SERVER logical server}.

      + * @param getMerchantOffer the {@link MerchantOffer} selected by the player to trade with + * @param getAbstractVillager the villager the player traded with */ -public final class TradeWithVillagerEvent extends PlayerEvent { +public record TradeWithVillagerEvent( + Player getEntity, + MerchantOffer getMerchantOffer, + AbstractVillager getAbstractVillager +) implements RecordEvent, PlayerEvent { public static final EventBus BUS = EventBus.create(TradeWithVillagerEvent.class); - private final MerchantOffer offer; - private final AbstractVillager abstractVillager; - @ApiStatus.Internal - public TradeWithVillagerEvent(Player player, MerchantOffer offer, AbstractVillager abstractVillager) { - super(player); - this.offer = offer; - this.abstractVillager = abstractVillager; - } - - /** - * {@return the {@link MerchantOffer} selected by the player to trade with} - */ - public MerchantOffer getMerchantOffer() { - return offer; - } - - /** - * {@return the villager the player traded with} - */ - public AbstractVillager getAbstractVillager() { - return abstractVillager; - } -} \ No newline at end of file + public TradeWithVillagerEvent {} +} diff --git a/src/main/java/net/minecraftforge/event/furnace/FurnaceFuelBurnTimeEvent.java b/src/main/java/net/minecraftforge/event/furnace/FurnaceFuelBurnTimeEvent.java index 3bdcd7894b..2a3c64072f 100644 --- a/src/main/java/net/minecraftforge/event/furnace/FurnaceFuelBurnTimeEvent.java +++ b/src/main/java/net/minecraftforge/event/furnace/FurnaceFuelBurnTimeEvent.java @@ -12,8 +12,8 @@ import net.minecraftforge.event.ForgeEventFactory; import net.minecraftforge.eventbus.api.bus.CancellableEventBus; import net.minecraftforge.eventbus.api.event.MutableEvent; import net.minecraftforge.eventbus.api.event.characteristic.Cancellable; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; /** * {@link FurnaceFuelBurnTimeEvent} is fired when determining the fuel value for an ItemStack.
      @@ -24,16 +24,15 @@ import org.jetbrains.annotations.Nullable; *
      * This event is {@link Cancellable} to prevent later handlers from changing the value. **/ +@NullMarked public final class FurnaceFuelBurnTimeEvent extends MutableEvent implements Cancellable { public static final CancellableEventBus BUS = CancellableEventBus.create(FurnaceFuelBurnTimeEvent.class); - @NotNull private final ItemStack itemStack; - @Nullable - private final RecipeType recipeType; + private final @Nullable RecipeType recipeType; private int burnTime; - public FurnaceFuelBurnTimeEvent(@NotNull ItemStack itemStack, int burnTime, @Nullable RecipeType recipeType) { + public FurnaceFuelBurnTimeEvent(ItemStack itemStack, int burnTime, @Nullable RecipeType recipeType) { this.itemStack = itemStack; this.burnTime = burnTime; this.recipeType = recipeType; @@ -42,7 +41,6 @@ public final class FurnaceFuelBurnTimeEvent extends MutableEvent implements Canc /** * Get the ItemStack "fuel" in question. */ - @NotNull public ItemStack getItemStack() { return itemStack; } diff --git a/src/main/java/net/minecraftforge/event/level/AlterGroundEvent.java b/src/main/java/net/minecraftforge/event/level/AlterGroundEvent.java index c7d2edfdda..f2169183a3 100644 --- a/src/main/java/net/minecraftforge/event/level/AlterGroundEvent.java +++ b/src/main/java/net/minecraftforge/event/level/AlterGroundEvent.java @@ -13,13 +13,14 @@ import net.minecraft.world.level.levelgen.feature.treedecorators.TreeDecorator; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.eventbus.api.bus.EventBus; import net.minecraftforge.eventbus.api.event.MutableEvent; +import net.minecraftforge.eventbus.api.event.characteristic.Cancellable; import org.jetbrains.annotations.ApiStatus; /** * This event is fired when {@link net.minecraft.world.level.levelgen.feature.treedecorators.AlterGroundDecorator#placeBlockAt(TreeDecorator.Context, BlockPos)} * attempts to alter a ground block when generating a feature. An example of this would be large spruce trees converting grass blocks into podzol. *

      - * This event is not {@linkplain Cancelable cancellable}. + * This event is not {@linkplain Cancellable cancellable}. *

      * This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus} * only on the {@linkplain net.minecraftforge.fml.LogicalSide#SERVER logical server}. diff --git a/src/main/java/net/minecraftforge/event/level/BlockEvent.java b/src/main/java/net/minecraftforge/event/level/BlockEvent.java index 6a77e72f47..50ffcc8392 100644 --- a/src/main/java/net/minecraftforge/event/level/BlockEvent.java +++ b/src/main/java/net/minecraftforge/event/level/BlockEvent.java @@ -9,7 +9,6 @@ import java.util.EnumSet; import java.util.List; import net.minecraft.core.registries.Registries; -import net.minecraft.server.level.ServerLevel; import net.minecraft.world.item.context.UseOnContext; import net.minecraft.world.item.enchantment.EnchantmentHelper; import net.minecraft.world.level.block.BaseFireBlock; @@ -30,7 +29,6 @@ import net.minecraftforge.common.util.BlockSnapshot; import net.minecraftforge.common.util.HasResult; import net.minecraftforge.common.util.Result; -import com.google.common.collect.ImmutableList; import net.minecraftforge.eventbus.api.bus.CancellableEventBus; import net.minecraftforge.eventbus.api.bus.EventBus; import net.minecraftforge.eventbus.api.event.InheritableEvent; @@ -40,47 +38,38 @@ import net.minecraftforge.eventbus.api.event.characteristic.Cancellable; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -public class BlockEvent extends MutableEvent implements InheritableEvent { - public static final EventBus BUS = EventBus.create(BlockEvent.class); +public sealed interface BlockEvent + permits BlockEvent.BlockToolModificationEvent, BlockEvent.BreakEvent, BlockEvent.CropGrowEvent, + BlockEvent.EntityPlaceEvent, BlockEvent.FarmlandTrampleEvent, BlockEvent.FluidPlaceBlockEvent, + BlockEvent.NeighborNotifyEvent, BlockEvent.PortalSpawnEvent, NoteBlockEvent, PistonEvent { + boolean DEBUG = Boolean.parseBoolean(System.getProperty("forge.debugBlockEvent", "false")); - private static final boolean DEBUG = Boolean.parseBoolean(System.getProperty("forge.debugBlockEvent", "false")); + LevelAccessor getLevel(); - private final LevelAccessor level; - private final BlockPos pos; - private final BlockState state; + BlockPos getPos(); - public BlockEvent(LevelAccessor level, BlockPos pos, BlockState state) { - this.pos = pos; - this.level = level; - this.state = state; - } - - public LevelAccessor getLevel() { - return level; - } - - public BlockPos getPos() { - return pos; - } - - public BlockState getState() { - return state; - } + BlockState getState(); /** * Event that is fired when an Block is about to be broken by a player * Setting the result to {@link Result#DENY} will prevent the Block from being broken. */ - public static final class BreakEvent extends BlockEvent implements Cancellable, HasResult { + final class BreakEvent extends MutableEvent implements Cancellable, BlockEvent, HasResult { public static final CancellableEventBus BUS = CancellableEventBus.create(BreakEvent.class); + private final LevelAccessor level; + private final BlockPos pos; + private final BlockState state; + /** Reference to the Player who broke the block. If no player is available, use a EntityFakePlayer */ private final Player player; private int exp; private Result result; public BreakEvent(Level level, BlockPos pos, BlockState state, Player player, Result result) { - super(level, pos, state); + this.level = level; + this.pos = pos; + this.state = state; this.player = player; this.result = result; @@ -95,6 +84,21 @@ public class BlockEvent extends MutableEvent implements InheritableEvent { } } + @Override + public LevelAccessor getLevel() { + return level; + } + + @Override + public BlockPos getPos() { + return pos; + } + + @Override + public BlockState getState() { + return state; + } + public Player getPlayer() { return player; } @@ -133,16 +137,20 @@ public class BlockEvent extends MutableEvent implements InheritableEvent { * * If a Block Place event is cancelled, the block will not be placed. */ - public static sealed class EntityPlaceEvent extends BlockEvent implements Cancellable { + sealed class EntityPlaceEvent extends MutableEvent implements Cancellable, BlockEvent { public static final CancellableEventBus BUS = CancellableEventBus.create(EntityPlaceEvent.class); + private final LevelAccessor level; + private final BlockPos pos; + private final Entity entity; private final BlockSnapshot blockSnapshot; private final BlockState placedBlock; private final BlockState placedAgainst; public EntityPlaceEvent(@NotNull BlockSnapshot blockSnapshot, @NotNull BlockState placedAgainst, @Nullable Entity entity) { - super(blockSnapshot.getLevel(), blockSnapshot.getPos(), !(entity instanceof Player) ? blockSnapshot.getReplacedBlock() : blockSnapshot.getCurrentBlock()); + this.level = blockSnapshot.getLevel(); + this.pos = blockSnapshot.getPos(); this.entity = entity; this.blockSnapshot = blockSnapshot; this.placedBlock = !(entity instanceof Player) ? blockSnapshot.getReplacedBlock() : blockSnapshot.getCurrentBlock(); @@ -153,6 +161,21 @@ public class BlockEvent extends MutableEvent implements InheritableEvent { } } + @Override + public LevelAccessor getLevel() { + return level; + } + + @Override + public BlockPos getPos() { + return pos; + } + + @Override + public BlockState getState() { + return placedBlock; + } + @Nullable public Entity getEntity() { return entity; } public BlockSnapshot getBlockSnapshot() { return blockSnapshot; } @@ -167,14 +190,14 @@ public class BlockEvent extends MutableEvent implements InheritableEvent { * the placed block would exist if the placement only affected a single * block. */ - public static final class EntityMultiPlaceEvent extends EntityPlaceEvent implements Cancellable { + final class EntityMultiPlaceEvent extends EntityPlaceEvent implements Cancellable { public static final CancellableEventBus BUS = CancellableEventBus.create(EntityMultiPlaceEvent.class); private final List blockSnapshots; public EntityMultiPlaceEvent(@NotNull List blockSnapshots, @NotNull BlockState placedAgainst, @Nullable Entity entity) { - super(blockSnapshots.get(0), placedAgainst, entity); - this.blockSnapshots = ImmutableList.copyOf(blockSnapshots); + super(blockSnapshots.getFirst(), placedAgainst, entity); + this.blockSnapshots = List.copyOf(blockSnapshots); if (DEBUG) { System.out.printf("Created EntityMultiPlaceEvent - [PlacedAgainst: %s ][Entity: %s ]\n", placedAgainst, entity); } @@ -195,35 +218,18 @@ public class BlockEvent extends MutableEvent implements InheritableEvent { * Fired when a physics update occurs on a block. This event acts as * a way for mods to detect physics updates, in the same way a BUD switch * does. This event is only called on the server. + * + * @param getNotifiedSides list of directions from the base block that updates will occur upon + * @param getForceRedstoneUpdate if the flag was set during setBlock call (0x16 to flags) */ - public static final class NeighborNotifyEvent extends BlockEvent implements Cancellable { + record NeighborNotifyEvent( + LevelAccessor getLevel, + BlockPos getPos, + BlockState getState, + EnumSet getNotifiedSides, + boolean getForceRedstoneUpdate + ) implements Cancellable, BlockEvent, RecordEvent { public static final CancellableEventBus BUS = CancellableEventBus.create(NeighborNotifyEvent.class); - - private final EnumSet notifiedSides; - private final boolean forceRedstoneUpdate; - - public NeighborNotifyEvent(Level level, BlockPos pos, BlockState state, EnumSet notifiedSides, boolean forceRedstoneUpdate) { - super(level, pos, state); - this.notifiedSides = notifiedSides; - this.forceRedstoneUpdate = forceRedstoneUpdate; - } - - /** - * Gets a list of directions from the base block that updates will occur upon. - * - * @return list of notified directions - */ - public EnumSet getNotifiedSides() { - return notifiedSides; - } - - /** - * Get if redstone update was forced during setBlock call (0x16 to flags) - * @return if the flag was set - */ - public boolean getForceRedstoneUpdate() { - return forceRedstoneUpdate; - } } /** @@ -232,7 +238,8 @@ public class BlockEvent extends MutableEvent implements InheritableEvent { * usually doesn't do that (like lava), and a result of DENY prevents creation * even if the liquid usually does do that (like water). */ - public record CreateFluidSourceEvent(Level getLevel, BlockPos getPos, BlockState getState, Result.Holder resultHolder) implements RecordEvent, HasResult.Record { + record CreateFluidSourceEvent(Level getLevel, BlockPos getPos, BlockState getState, Result.Holder resultHolder) + implements RecordEvent, HasResult.Record { public static final EventBus BUS = EventBus.create(CreateFluidSourceEvent.class); public CreateFluidSourceEvent(Level level, BlockPos pos, BlockState state) { @@ -248,20 +255,41 @@ public class BlockEvent extends MutableEvent implements InheritableEvent { * {@link #getState()} will return the block that was originally going to be placed. * {@link #getPos()} will return the position of the block to be changed. */ - public static final class FluidPlaceBlockEvent extends BlockEvent implements Cancellable { + final class FluidPlaceBlockEvent extends MutableEvent implements Cancellable, BlockEvent { public static final CancellableEventBus BUS = CancellableEventBus.create(FluidPlaceBlockEvent.class); + private final LevelAccessor level; + private final BlockPos pos; + private final BlockState state; + private final BlockPos liquidPos; private BlockState newState; private final BlockState origState; public FluidPlaceBlockEvent(LevelAccessor level, BlockPos pos, BlockPos liquidPos, BlockState state) { - super(level, pos, state); + this.level = level; + this.pos = pos; + this.state = state; this.liquidPos = liquidPos; this.newState = state; this.origState = level.getBlockState(pos); } + @Override + public LevelAccessor getLevel() { + return level; + } + + @Override + public BlockPos getPos() { + return pos; + } + + @Override + public BlockState getState() { + return state; + } + /** * @return The position of the liquid this event originated from. This may be the same as {@link #getPos()}. */ @@ -290,14 +318,9 @@ public class BlockEvent extends MutableEvent implements InheritableEvent { /** * Fired when a crop block grows. See subevents. - * */ - public static sealed class CropGrowEvent extends BlockEvent { - public static final EventBus BUS = EventBus.create(CropGrowEvent.class); - - public CropGrowEvent(Level level, BlockPos pos, BlockState state) { - super(level, pos, state); - } + sealed interface CropGrowEvent extends BlockEvent, InheritableEvent { + EventBus BUS = EventBus.create(CropGrowEvent.class); /** * Fired when any "growing age" blocks (for example cacti, chorus plants, or crops @@ -307,26 +330,13 @@ public class BlockEvent extends MutableEvent implements InheritableEvent { * {@link Result#ALLOW} will force the plant to advance a growth stage.
      * {@link Result#DENY} will prevent the plant from advancing a growth stage.
      *
      - * This event is not {@link Cancelable}.
      - *
      */ - public static final class Pre extends CropGrowEvent implements HasResult { + record Pre(LevelAccessor getLevel, BlockPos getPos, BlockState getState, Result.Holder resultHolder) + implements CropGrowEvent, HasResult.Record { public static final EventBus

       BUS = EventBus.create(Pre.class);
       
      -            private Result result = Result.DEFAULT;
      -
                   public Pre(Level level, BlockPos pos, BlockState state) {
      -                super(level, pos, state);
      -            }
      -
      -            @Override
      -            public Result getResult() {
      -                return result;
      -            }
      -
      -            @Override
      -            public void setResult(Result result) {
      -                this.result = result;
      +                this(level, pos, state, new Result.Holder());
                   }
               }
       
      @@ -334,71 +344,34 @@ public class BlockEvent extends MutableEvent implements InheritableEvent {
                * Fired when "growing age" blocks (for example cacti, chorus plants, or crops
                * in vanilla) have successfully grown. The block's original state is available,
                * in addition to its new state.
      - *
      - * This event is not {@link Cancelable}.
      - *
      - * This event does not have a result. {@link HasResult}
      */ - public static final class Post extends CropGrowEvent { + record Post(LevelAccessor getLevel, BlockPos getPos, BlockState getState, BlockState getOriginalState) + implements CropGrowEvent { public static final EventBus BUS = EventBus.create(Post.class); - - private final BlockState originalState; - - public Post(Level level, BlockPos pos, BlockState original, BlockState state) { - super(level, pos, state); - originalState = original; - } - - public BlockState getOriginalState() { - return originalState; - } } } /** - * Fired when when farmland gets trampled - * This event is {@link Cancelable} + * Fired when farmland gets trampled */ - public static final class FarmlandTrampleEvent extends BlockEvent implements Cancellable { + record FarmlandTrampleEvent( + LevelAccessor getLevel, + BlockPos getPos, + BlockState getState, + double getFallDistance, + Entity getEntity + ) implements Cancellable, BlockEvent, RecordEvent { public static final CancellableEventBus BUS = CancellableEventBus.create(FarmlandTrampleEvent.class); - - private final Entity entity; - private final double fallDistance; - - public FarmlandTrampleEvent(ServerLevel level, BlockPos pos, BlockState state, double fallDistance, Entity entity) { - super(level, pos, state); - this.entity = entity; - this.fallDistance = fallDistance; - } - - public Entity getEntity() { - return entity; - } - - public double getFallDistance() { - return fallDistance; - } - } /** Fired when an attempt is made to spawn a nether portal from * {@link BaseFireBlock#onPlace(BlockState, Level, BlockPos, BlockState, boolean)}. - * + *
      * If cancelled, the portal will not be spawned. */ - public static final class PortalSpawnEvent extends BlockEvent implements Cancellable { + record PortalSpawnEvent(LevelAccessor getLevel, BlockPos getPos, BlockState getState, PortalShape getPortalSize) + implements Cancellable, BlockEvent, RecordEvent { public static final CancellableEventBus BUS = CancellableEventBus.create(PortalSpawnEvent.class); - - private final PortalShape size; - - public PortalSpawnEvent(LevelAccessor level, BlockPos pos, BlockState state, PortalShape size) { - super(level, pos, state); - this.size = size; - } - - public PortalShape getPortalSize() { - return size; - } } /** @@ -408,25 +381,47 @@ public class BlockEvent extends MutableEvent implements InheritableEvent { *

      * Care must be taken to ensure level-modifying events are only performed if {@link #isSimulated()} returns {@code false}. *

      - * This event is {@link Cancelable}. If canceled, this will prevent the tool - * from changing the block's state. + * This event is {@linkplain Cancellable cancellable}. If cancelled, this will prevent the tool from changing + * the block's state. */ - public static final class BlockToolModificationEvent extends BlockEvent implements Cancellable { + final class BlockToolModificationEvent extends MutableEvent implements Cancellable, BlockEvent { public static final CancellableEventBus BUS = CancellableEventBus.create(BlockToolModificationEvent.class); + private final LevelAccessor level; + private final BlockPos pos; + private final BlockState originalState; + private final UseOnContext context; private final ToolAction toolAction; private final boolean simulate; private BlockState state; public BlockToolModificationEvent(BlockState originalState, @NotNull UseOnContext context, ToolAction toolAction, boolean simulate) { - super(context.getLevel(), context.getClickedPos(), originalState); + this.level = context.getLevel(); + this.pos = context.getClickedPos(); + this.originalState = originalState; + this.context = context; this.state = originalState; this.toolAction = toolAction; this.simulate = simulate; } + @Override + public LevelAccessor getLevel() { + return level; + } + + @Override + public BlockPos getPos() { + return pos; + } + + @Override + public BlockState getState() { + return originalState; + } + /** * @return the player using the tool. * May be null based on what was provided by {@link #getContext() the use on context}. diff --git a/src/main/java/net/minecraftforge/event/level/ChunkDataEvent.java b/src/main/java/net/minecraftforge/event/level/ChunkDataEvent.java index 6f2a3e3ca1..01badb1b38 100644 --- a/src/main/java/net/minecraftforge/event/level/ChunkDataEvent.java +++ b/src/main/java/net/minecraftforge/event/level/ChunkDataEvent.java @@ -12,67 +12,31 @@ import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.level.chunk.status.ChunkType; import net.minecraft.world.level.chunk.ChunkAccess; import net.minecraft.world.level.chunk.storage.SerializableChunkData; -import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.eventbus.api.bus.EventBus; /** - * ChunkDataEvent is fired when an event involving chunk data occurs.
      - * If a method utilizes this {@link Event} as its parameter, the method will - * receive every child event of this class.
      - *
      - * {@link #data} contains the NBTTagCompound containing the chunk data for this event.
      - *
      - * All children of this event are fired on the {@link MinecraftForge#EVENT_BUS}.
      + * ChunkDataEvent is fired when an event involving chunk data occurs. **/ -public sealed class ChunkDataEvent extends ChunkEvent { - public static final EventBus BUS = EventBus.create(ChunkDataEvent.class); +public sealed interface ChunkDataEvent extends ChunkEvent { + EventBus BUS = EventBus.create(ChunkDataEvent.class); - private final SerializableChunkData data; - - public ChunkDataEvent(ChunkAccess chunk, SerializableChunkData data) { - super(chunk); - this.data = data; - } - - public ChunkDataEvent(ChunkAccess chunk, LevelAccessor world, SerializableChunkData data) { - super(chunk, world); - this.data = data; - } - - public SerializableChunkData getData() { - return data; - } + SerializableChunkData getData(); /** * ChunkDataEvent.Load is fired when vanilla Minecraft attempts to load Chunk data.
      * This event is fired during chunk loading in * {@link ChunkSerializer#read(ServerLevel, PoiManager, ChunkPos, SerializableChunkData)} which means it is async, so be careful.
      - **/ - public static final class Load extends ChunkDataEvent { + */ + record Load(ChunkAccess getChunk, SerializableChunkData getData, ChunkType getStatus) implements ChunkDataEvent { public static final EventBus BUS = EventBus.create(ChunkDataEvent.Load.class); - - private final ChunkType status; - - public Load(ChunkAccess chunk, SerializableChunkData data, ChunkType status) { - super(chunk, data); - this.status = status; - } - - public ChunkType getStatus() { - return this.status; - } } /** * ChunkDataEvent.Save is fired when vanilla Minecraft attempts to save Chunk data.
      * This event is fired during chunk saving in * {@code ChunkMap#save(ChunkAccess)}.
      - **/ - public static final class Save extends ChunkDataEvent { + */ + record Save(ChunkAccess getChunk, LevelAccessor getLevel, SerializableChunkData getData) implements ChunkDataEvent { public static final EventBus BUS = EventBus.create(ChunkDataEvent.Save.class); - - public Save(ChunkAccess chunk, LevelAccessor world, SerializableChunkData data) { - super(chunk, world, data); - } } } diff --git a/src/main/java/net/minecraftforge/event/level/ChunkEvent.java b/src/main/java/net/minecraftforge/event/level/ChunkEvent.java index 2e5d0175a2..e0d5861268 100644 --- a/src/main/java/net/minecraftforge/event/level/ChunkEvent.java +++ b/src/main/java/net/minecraftforge/event/level/ChunkEvent.java @@ -8,61 +8,38 @@ package net.minecraftforge.event.level; import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.level.chunk.ChunkAccess; import net.minecraft.world.level.chunk.LevelChunk; -import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.eventbus.api.bus.EventBus; import org.jetbrains.annotations.ApiStatus; /** - * ChunkEvent is fired when an event involving a chunk occurs.
      - * If a method utilizes this {@link Event} as its parameter, the method will - * receive every child event of this class.
      - *
      - * {@link #chunk} contains the Chunk this event is affecting.
      - *
      - * All children of this event are fired on the {@link MinecraftForge#EVENT_BUS}.
      + * ChunkEvent is fired when an event involving a chunk occurs. **/ -public class ChunkEvent extends LevelEvent { - public static final EventBus BUS = EventBus.create(ChunkEvent.class); +public sealed interface ChunkEvent extends LevelEvent + permits ChunkEvent.Load, ChunkEvent.Unload, ChunkEvent.LightingCalculated, ChunkDataEvent { + EventBus BUS = EventBus.create(ChunkEvent.class); - private final ChunkAccess chunk; - - public ChunkEvent(ChunkAccess chunk) { - super(chunk.getWorldForge()); - this.chunk = chunk; + @Override + default LevelAccessor getLevel() { + return getChunk().getWorldForge(); } - public ChunkEvent(ChunkAccess chunk, LevelAccessor level) { - super(level); - this.chunk = chunk; - } - - public ChunkAccess getChunk() { - return chunk; - } + /** + * @return the Chunk this event is affecting. + */ + ChunkAccess getChunk(); /** * ChunkEvent.Load is fired when vanilla Minecraft attempts to load a Chunk into the level.
      * This event is fired during chunk loading in
      * * Chunk.onChunkLoad().
      - * Note: This event may be called before the underlying {@link LevelChunk} is promoted to {@link ChunkStatus#FULL}. You will cause chunk loading deadlocks if you don't delay your level interactions.
      - *
      - * This event is not {@link Cancelable}.
      - *
      - * This event does not have a result. {@link HasResult}
      - *
      - * This event is fired on the {@link MinecraftForge#EVENT_BUS}.
      - **/ - public static final class Load extends ChunkEvent { + * Note: This event may be called before the underlying {@link LevelChunk} is promoted to {@link ChunkStatus#FULL}. You will cause chunk loading deadlocks if you don't delay your level interactions. + */ + record Load(ChunkAccess getChunk, boolean isNewChunk) implements ChunkEvent { public static final EventBus BUS = EventBus.create(ChunkEvent.Load.class); - private final boolean newChunk; - @ApiStatus.Internal - public Load(ChunkAccess chunk, boolean newChunk) { - super(chunk); - this.newChunk = newChunk; - } + public Load {} /** * Check whether the Chunk is newly generated, and being loaded for the first time. @@ -72,27 +49,17 @@ public class ChunkEvent extends LevelEvent { * @return whether the Chunk is newly generated */ public boolean isNewChunk() { - return newChunk; + return isNewChunk; } } /** * ChunkEvent.Unload is fired when vanilla Minecraft attempts to unload a Chunk from the level.
      * This event is fired during chunk unloading in
      - * Chunk.onChunkUnload().
      - *
      - * This event is not {@link Cancelable}.
      - *
      - * This event does not have a result. {@link HasResult}
      - *
      - * This event is fired on the {@link MinecraftForge#EVENT_BUS}.
      - **/ - public static final class Unload extends ChunkEvent { + * Chunk.onChunkUnload(). + */ + record Unload(ChunkAccess getChunk) implements ChunkEvent { public static final EventBus BUS = EventBus.create(ChunkEvent.Unload.class); - - public Unload(ChunkAccess chunk) { - super(chunk); - } } /** @@ -101,18 +68,8 @@ public class ChunkEvent extends LevelEvent { * the ChunkAccess isLightCorrect to true.
      *
      * The game test for this event is lighting_event_test in net.minecraftforge.debug.chunk
      - *
      - * This event is not {@link Cancelable}.
      - *
      - * This event does not have a result. {@link HasResult}
      - *
      - * This event is fired on the {@link MinecraftForge#EVENT_BUS}.
      - **/ - public static final class LightingCalculated extends ChunkEvent { + */ + record LightingCalculated(ChunkAccess getChunk) implements ChunkEvent { public static final EventBus BUS = EventBus.create(ChunkEvent.LightingCalculated.class); - - public LightingCalculated(ChunkAccess chunk) { - super(chunk); - } } } diff --git a/src/main/java/net/minecraftforge/event/level/ChunkTicketLevelUpdatedEvent.java b/src/main/java/net/minecraftforge/event/level/ChunkTicketLevelUpdatedEvent.java index 14665a3703..40554dee44 100644 --- a/src/main/java/net/minecraftforge/event/level/ChunkTicketLevelUpdatedEvent.java +++ b/src/main/java/net/minecraftforge/event/level/ChunkTicketLevelUpdatedEvent.java @@ -9,9 +9,10 @@ import net.minecraft.server.level.ChunkHolder; import net.minecraft.server.level.ServerLevel; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.eventbus.api.bus.EventBus; -import net.minecraftforge.eventbus.api.event.MutableEvent; +import net.minecraftforge.eventbus.api.event.RecordEvent; import net.minecraftforge.fml.LogicalSide; import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.NullMarked; /** * This event is fired whenever a chunk has its ticket level changed via the server's ChunkMap. @@ -24,62 +25,22 @@ import org.jetbrains.annotations.Nullable; * is by first changing it from 31 to 46, and then queuing the update from 46 to 32. However, when going from 32 to 31, * vanilla is able to go directly. *

      - * This event is not {@linkplain Cancelable cancellable} and does not {@linkplain HasResult have a result}. - *

      * This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus} * only on the {@linkplain LogicalSide#SERVER logical server}. - **/ -public final class ChunkTicketLevelUpdatedEvent extends MutableEvent { + * + * @param getLevel the server level containing the chunk + * @param getChunkPos the long representation of the chunk position the ticket level changed for + * @param getOldTicketLevel the previous ticket level the chunk had + * @param getNewTicketLevel the new ticket level the chunk has + * @param getChunkHolder the chunk that had its ticket level updated, may be null + */ +@NullMarked +public record ChunkTicketLevelUpdatedEvent( + ServerLevel getLevel, + long getChunkPos, + int getOldTicketLevel, + int getNewTicketLevel, + @Nullable ChunkHolder getChunkHolder +) implements RecordEvent { public static final EventBus BUS = EventBus.create(ChunkTicketLevelUpdatedEvent.class); - - private final ServerLevel level; - private final long chunkPos; - private final int oldTicketLevel; - private final int newTicketLevel; - @Nullable - private final ChunkHolder chunkHolder; - - public ChunkTicketLevelUpdatedEvent(ServerLevel level, long chunkPos, int oldTicketLevel, int newTicketLevel, @Nullable ChunkHolder chunkHolder) { - this.level = level; - this.chunkPos = chunkPos; - this.oldTicketLevel = oldTicketLevel; - this.newTicketLevel = newTicketLevel; - this.chunkHolder = chunkHolder; - } - - /** - * {@return the server level containing the chunk} - */ - public ServerLevel getLevel() { - return this.level; - } - - /** - * {@return the long representation of the chunk position the ticket level changed for} - */ - public long getChunkPos() { - return this.chunkPos; - } - - /** - * {@return the previous ticket level the chunk had} - */ - public int getOldTicketLevel() { - return this.oldTicketLevel; - } - - /** - * {@return the new ticket level for the chunk} - */ - public int getNewTicketLevel() { - return this.newTicketLevel; - } - - /** - * {@return chunk that had its ticket level updated} - */ - @Nullable - public ChunkHolder getChunkHolder() { - return this.chunkHolder; - } } diff --git a/src/main/java/net/minecraftforge/event/level/ChunkWatchEvent.java b/src/main/java/net/minecraftforge/event/level/ChunkWatchEvent.java index 710ebe271f..0e8e9eaa3a 100644 --- a/src/main/java/net/minecraftforge/event/level/ChunkWatchEvent.java +++ b/src/main/java/net/minecraftforge/event/level/ChunkWatchEvent.java @@ -12,7 +12,6 @@ import net.minecraft.world.level.chunk.LevelChunk; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.eventbus.api.bus.EventBus; import net.minecraftforge.eventbus.api.event.InheritableEvent; -import net.minecraftforge.eventbus.api.event.MutableEvent; import net.minecraftforge.fml.LogicalSide; /** @@ -21,83 +20,51 @@ import net.minecraftforge.fml.LogicalSide; * The {@linkplain #getPlayer() player}'s level may not be the same as the {@linkplain #getLevel() level of the chunk} * when the player is teleporting to another dimension. *

      - * This event is not {@linkplain Cancelable cancellable} and does not {@linkplain HasResult have a result}. - *

      * This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus} * only on the {@linkplain LogicalSide#SERVER logical server}. **/ -public sealed class ChunkWatchEvent extends MutableEvent implements InheritableEvent { - public static final EventBus BUS = EventBus.create(ChunkWatchEvent.class); - - private final ServerLevel level; - private final ServerPlayer player; - private final ChunkPos pos; - - public ChunkWatchEvent(ServerPlayer player, ChunkPos pos, ServerLevel level) { - this.player = player; - this.pos = pos; - this.level = level; - } +public sealed interface ChunkWatchEvent extends InheritableEvent { + EventBus BUS = EventBus.create(ChunkWatchEvent.class); /** * {@return the server player involved with the watch action} */ - public ServerPlayer getPlayer() { - return this.player; - } + ServerPlayer getPlayer(); /** * {@return the chunk position this watch event is affecting} */ - public ChunkPos getPos() { - return this.pos; - } + ChunkPos getPos(); /** * {@return the server level containing the chunk} */ - public ServerLevel getLevel() { - return this.level; - } + ServerLevel getLevel(); /** * This event is fired when chunk data is sent to the {@link ServerPlayer} (see {@link net.minecraft.server.network.PlayerChunkSender}). *

      * This event may be used to send additional chunk-related data to the client. *

      - * This event is not {@linkplain Cancelable cancellable} and does not {@linkplain HasResult have a result}. - *

      * This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus} * only on the {@linkplain LogicalSide#SERVER logical server}. **/ - public static final class Watch extends ChunkWatchEvent { + record Watch(ServerPlayer getPlayer, ChunkPos getPos, LevelChunk getChunk, ServerLevel getLevel) + implements ChunkWatchEvent { public static final EventBus BUS = EventBus.create(Watch.class); - private final LevelChunk chunk; - public Watch(ServerPlayer player, LevelChunk chunk, ServerLevel level) { - super(player, chunk.getPos(), level); - this.chunk = chunk; - } - - public LevelChunk getChunk() { - return this.chunk; + this(player, chunk.getPos(), chunk, level); } } /** * This event is fired when server sends "forget chunk" packet to the {@link ServerPlayer}. *

      - * This event is not {@linkplain Cancelable cancellable} and does not {@linkplain HasResult have a result}. - *

      * This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus} * only on the {@linkplain LogicalSide#SERVER logical server}. **/ - public static final class UnWatch extends ChunkWatchEvent { + record UnWatch(ServerPlayer getPlayer, ChunkPos getPos, ServerLevel getLevel) implements ChunkWatchEvent { public static final EventBus BUS = EventBus.create(UnWatch.class); - - public UnWatch(ServerPlayer player, ChunkPos pos, ServerLevel level) { - super(player, pos, level); - } } } diff --git a/src/main/java/net/minecraftforge/event/level/ExplosionEvent.java b/src/main/java/net/minecraftforge/event/level/ExplosionEvent.java index 10e7feae3e..795d912a2f 100644 --- a/src/main/java/net/minecraftforge/event/level/ExplosionEvent.java +++ b/src/main/java/net/minecraftforge/event/level/ExplosionEvent.java @@ -7,7 +7,6 @@ package net.minecraftforge.event.level; import java.util.List; -import net.minecraftforge.common.MinecraftForge; import net.minecraft.world.entity.Entity; import net.minecraft.core.BlockPos; import net.minecraft.world.level.Explosion; @@ -15,7 +14,6 @@ import net.minecraft.world.level.Level; import net.minecraftforge.eventbus.api.bus.CancellableEventBus; import net.minecraftforge.eventbus.api.bus.EventBus; import net.minecraftforge.eventbus.api.event.InheritableEvent; -import net.minecraftforge.eventbus.api.event.MutableEvent; import net.minecraftforge.eventbus.api.event.characteristic.Cancellable; /** ExplosionEvent triggers when an explosion happens in the level.
      @@ -23,70 +21,37 @@ import net.minecraftforge.eventbus.api.event.characteristic.Cancellable; * ExplosionEvent.Start is fired before the explosion actually occurs.
      * ExplosionEvent.Detonate is fired once the explosion has a list of affected blocks and entities.
      *
      - * ExplosionEvent.Start is {@link Cancelable}.
      - * ExplosionEvent.Detonate can modify the affected blocks and entities.
      - * Children do not use {@link HasResult}.
      - * Children of this event are fired on the {@link MinecraftForge#EVENT_BUS}.
      + * ExplosionEvent.Start is {@link Cancellable}.
      + * ExplosionEvent.Detonate can modify the affected blocks and entities. */ -public sealed class ExplosionEvent extends MutableEvent implements InheritableEvent { - public static final EventBus BUS = EventBus.create(ExplosionEvent.class); +public sealed interface ExplosionEvent extends InheritableEvent { + EventBus BUS = EventBus.create(ExplosionEvent.class); - private final Level level; - private final Explosion explosion; + Level getLevel(); - public ExplosionEvent(Level level, Explosion explosion) { - this.level = level; - this.explosion = explosion; - } + Explosion getExplosion(); - public Level getLevel() { - return level; - } - - public Explosion getExplosion() { - return explosion; - } - - /** ExplosionEvent.Start is fired before the explosion actually occurs. Canceling this event will stop the explosion.
      - *
      - * This event is {@link Cancelable}.
      - * This event does not use {@link HasResult}.
      - * This event is fired on the {@link MinecraftForge#EVENT_BUS}.
      + /** + * ExplosionEvent.Start is fired before the explosion actually occurs.
      + * This event is {@linkplain Cancellable cancellable}. Cancelling this event will stop the explosion. */ - public static final class Start extends ExplosionEvent implements Cancellable { + record Start(Level getLevel, Explosion getExplosion) implements Cancellable, ExplosionEvent { public static final CancellableEventBus BUS = CancellableEventBus.create(Start.class); - - public Start(Level level, Explosion explosion) { - super(level, explosion); - } } - /** ExplosionEvent.Detonate is fired once the explosion has a list of affected blocks and entities. These lists can be modified to change the outcome.
      - *
      - * This event is not {@link Cancelable}.
      - * This event does not use {@link HasResult}.
      - * This event is fired on the {@link MinecraftForge#EVENT_BUS}.
      + /** + * ExplosionEvent.Detonate is fired once the explosion has a list of affected blocks and entities. + * These lists can be modified to change the outcome. + * + * @param getAffectedBlocks the modifiable list of blocks affected by the explosion + * @param getAffectedEntities the modifiable list of entities affected by the explosion */ - public static final class Detonate extends ExplosionEvent { + record Detonate( + Level getLevel, + Explosion getExplosion, + List getAffectedBlocks, + List getAffectedEntities + ) implements ExplosionEvent { public static final EventBus BUS = EventBus.create(Detonate.class); - - private final List blocks; - private final List entityList; - - public Detonate(Level level, Explosion explosion, List blocks, List entityList) { - super(level, explosion); - this.blocks = blocks; - this.entityList = entityList; - } - - /** return the list of blocks affected by the explosion. */ - public List getAffectedBlocks() { - return blocks; - } - - /** return the list of entities affected by the explosion. */ - public List getAffectedEntities() { - return entityList; - } } } diff --git a/src/main/java/net/minecraftforge/event/level/LevelEvent.java b/src/main/java/net/minecraftforge/event/level/LevelEvent.java index 19e46902ec..2197622234 100644 --- a/src/main/java/net/minecraftforge/event/level/LevelEvent.java +++ b/src/main/java/net/minecraftforge/event/level/LevelEvent.java @@ -10,7 +10,6 @@ import java.util.Collections; import java.util.List; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.screens.ReceivingLevelScreen; import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.core.BlockPos; @@ -30,46 +29,35 @@ import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.eventbus.api.bus.CancellableEventBus; import net.minecraftforge.eventbus.api.bus.EventBus; import net.minecraftforge.eventbus.api.event.InheritableEvent; -import net.minecraftforge.eventbus.api.event.MutableEvent; import net.minecraftforge.eventbus.api.event.characteristic.Cancellable; import net.minecraftforge.fml.LogicalSide; import org.jetbrains.annotations.UnmodifiableView; +import org.jspecify.annotations.NullMarked; /** * This event is fired whenever an event involving a {@link LevelAccessor} occurs. - *

      - * All children of this event are fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus}. */ -public class LevelEvent extends MutableEvent implements InheritableEvent { - public static final EventBus BUS = EventBus.create(LevelEvent.class); - - private final LevelAccessor level; - - public LevelEvent(LevelAccessor level) { - this.level = level; - } +@NullMarked +public sealed interface LevelEvent extends InheritableEvent + permits ChunkEvent, LevelEvent.CreateSpawnPosition, LevelEvent.Load, LevelEvent.PotentialSpawns, LevelEvent.Save, + LevelEvent.Unload, SaplingGrowTreeEvent, SleepFinishedTimeEvent { + EventBus BUS = EventBus.create(LevelEvent.class); /** * {@return the level this event is affecting} */ - public LevelAccessor getLevel() { - return level; - } + LevelAccessor getLevel(); /** * This event is fired whenever a level loads. * This event is fired whenever a level loads in ClientLevel's constructor and * {@literal MinecraftServer#createLevels(ChunkProgressListener)}. *

      - * This event is not {@linkplain Cancelable cancellable} and does not {@linkplain HasResult have a result}. - *

      * This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus} * on both logical sides. **/ - public static final class Load extends LevelEvent { + record Load(LevelAccessor getLevel) implements LevelEvent { public static final EventBus BUS = EventBus.create(Load.class); - - public Load(LevelAccessor level) { super(level); } } /** @@ -79,15 +67,11 @@ public class LevelEvent extends MutableEvent implements InheritableEvent { * {@link MinecraftServer#stopServer()}, * {@link Minecraft#clearClientLevel(Screen)}. *

      - * This event is not {@linkplain Cancelable cancellable} and does not {@linkplain HasResult have a result}. - *

      * This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus} * on both logical sides. **/ - public static final class Unload extends LevelEvent { + record Unload(LevelAccessor getLevel) implements LevelEvent { public static final EventBus BUS = EventBus.create(Unload.class); - - public Unload(LevelAccessor level) { super(level); } } /** @@ -95,42 +79,27 @@ public class LevelEvent extends MutableEvent implements InheritableEvent { * This event is fired when a level is saved in * {@link ServerLevel#save(ProgressListener, boolean, boolean)}. *

      - * This event is not {@linkplain Cancelable cancellable} and does not {@linkplain HasResult have a result}. - *

      * This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus} * only on the {@linkplain LogicalSide#SERVER logical server}. **/ - public static final class Save extends LevelEvent { + record Save(LevelAccessor getLevel) implements LevelEvent { public static final EventBus BUS = EventBus.create(Save.class); - - public Save(LevelAccessor level) { super(level); } } /** * This event fires whenever a {@link ServerLevel} is initialized for the first time * and a spawn position needs to be chosen. *

      - * This event is {@linkplain Cancelable cancellable} and does not {@linkplain HasResult have a result}. - * If the event is canceled, the vanilla logic to choose a spawn position will be skipped. + * This event is {@linkplain Cancellable cancellable}. + * If the event is cancelled, the vanilla logic to choose a spawn position will be skipped. *

      * This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus} * only on the {@linkplain LogicalSide#SERVER logical server}. * * @see ServerLevelData#isInitialized() */ - public static final class CreateSpawnPosition extends LevelEvent implements Cancellable { + record CreateSpawnPosition(LevelAccessor getLevel, ServerLevelData getSettings) implements Cancellable, LevelEvent { public static final CancellableEventBus BUS = CancellableEventBus.create(CreateSpawnPosition.class); - - private final ServerLevelData settings; - - public CreateSpawnPosition(LevelAccessor level, ServerLevelData settings) { - super(level); - this.settings = settings; - } - - public ServerLevelData getSettings() { - return settings; - } } /** @@ -140,20 +109,21 @@ public class LevelEvent extends MutableEvent implements InheritableEvent { * * The event is called in {@link net.minecraft.world.level.NaturalSpawner#mobsAt(ServerLevel, StructureManager, * ChunkGenerator, MobCategory, BlockPos, Holder)}.

      - * - *

      This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. - * Canceling the event will result in an empty list, meaning no entity will be spawned.

      + * + *

      This event is {@linkplain Cancellable cancellable}. + * Cancelling the event will result in an empty list, meaning no entity will be spawned.

      */ - public static final class PotentialSpawns extends LevelEvent implements Cancellable { + final class PotentialSpawns implements Cancellable, LevelEvent { public static final CancellableEventBus BUS = CancellableEventBus.create(PotentialSpawns.class); + private final LevelAccessor level; private final MobCategory mobcategory; private final BlockPos pos; private final List> list; private final @UnmodifiableView List> view; public PotentialSpawns(LevelAccessor level, MobCategory category, BlockPos pos, WeightedList oldList) { - super(level); + this.level = level; this.pos = pos; this.mobcategory = category; if (!oldList.isEmpty()) @@ -164,6 +134,11 @@ public class LevelEvent extends MutableEvent implements InheritableEvent { this.view = Collections.unmodifiableList(list); } + @Override + public LevelAccessor getLevel() { + return this.level; + } + /** @return the category of the mobs in the spawn list. */ public MobCategory getMobCategory() { return this.mobcategory; diff --git a/src/main/java/net/minecraftforge/event/level/NoteBlockEvent.java b/src/main/java/net/minecraftforge/event/level/NoteBlockEvent.java index 7971802775..63943525c3 100644 --- a/src/main/java/net/minecraftforge/event/level/NoteBlockEvent.java +++ b/src/main/java/net/minecraftforge/event/level/NoteBlockEvent.java @@ -5,6 +5,7 @@ package net.minecraftforge.event.level; +import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.properties.NoteBlockInstrument; import net.minecraft.core.BlockPos; @@ -13,21 +14,43 @@ import net.minecraft.world.level.Level; import com.google.common.base.Preconditions; import net.minecraftforge.eventbus.api.bus.CancellableEventBus; import net.minecraftforge.eventbus.api.bus.EventBus; +import net.minecraftforge.eventbus.api.event.InheritableEvent; import net.minecraftforge.eventbus.api.event.characteristic.Cancellable; /** * Base class for Noteblock Events */ -public sealed abstract class NoteBlockEvent extends BlockEvent { +public sealed abstract class NoteBlockEvent implements InheritableEvent, BlockEvent { public static final EventBus BUS = EventBus.create(NoteBlockEvent.class); + private final Level world; + private final BlockPos pos; + private final BlockState state; + private int noteId; protected NoteBlockEvent(Level world, BlockPos pos, BlockState state, int note) { - super(world, pos, state); + this.world = world; + this.pos = pos; + this.state = state; this.noteId = note; } + @Override + public LevelAccessor getLevel() { + return world; + } + + @Override + public BlockPos getPos() { + return pos; + } + + @Override + public BlockState getState() { + return state; + } + /** * Get the Note the Noteblock is tuned to * @return the Note diff --git a/src/main/java/net/minecraftforge/event/level/PistonEvent.java b/src/main/java/net/minecraftforge/event/level/PistonEvent.java index ffa09f63bb..6b12bba88d 100644 --- a/src/main/java/net/minecraftforge/event/level/PistonEvent.java +++ b/src/main/java/net/minecraftforge/event/level/PistonEvent.java @@ -5,99 +5,104 @@ package net.minecraftforge.event.level; +import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.level.block.piston.PistonStructureResolver; import net.minecraft.core.Direction; import net.minecraft.core.BlockPos; import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.state.BlockState; import net.minecraftforge.eventbus.api.bus.CancellableEventBus; import net.minecraftforge.eventbus.api.bus.EventBus; +import net.minecraftforge.eventbus.api.event.RecordEvent; import net.minecraftforge.eventbus.api.event.characteristic.Cancellable; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; /** * Base piston event, use {@link PistonEvent.Post} and {@link PistonEvent.Pre} */ -public abstract sealed class PistonEvent extends BlockEvent { - public static final EventBus BUS = EventBus.create(PistonEvent.class); - - private final Direction direction; - private final PistonMoveType moveType; +@NullMarked +public sealed interface PistonEvent extends BlockEvent { + /** + * @return The position of the piston + */ + @Override + BlockPos getPos(); /** - * @param pos - The position of the piston - * @param direction - The move direction of the piston + * @return The move direction of the piston */ - public PistonEvent(Level world, BlockPos pos, Direction direction, PistonMoveType moveType) { - super(world, pos, world.getBlockState(pos)); - this.direction = direction; - this.moveType = moveType; - } - - /** - * @return The direction of the piston block - */ - public Direction getDirection() { - return this.direction; - } + Direction getDirection(); /** * Helper method that gets the piston position offset by its facing */ - public BlockPos getFaceOffsetPos() { - return this.getPos().relative(direction); + default BlockPos getFaceOffsetPos() { + return this.getPos().relative(getDirection()); } /** * @return The movement type of the piston (extension, retraction) */ - public PistonMoveType getPistonMoveType() { - return moveType; - } + PistonMoveType getPistonMoveType(); /** * @return A piston structure helper for this movement. Returns null if the world stored is not a {@link Level} */ @Nullable - public PistonStructureResolver getStructureHelper() { - if (this.getLevel() instanceof Level) { - return new PistonStructureResolver((Level) this.getLevel(), this.getPos(), this.getDirection(), this.getPistonMoveType().isExtend); + default PistonStructureResolver getStructureHelper() { + if (getLevel() instanceof Level) { + return new PistonStructureResolver((Level) getLevel(), getPos(), getDirection(), getPistonMoveType().isExtend()); } else { return null; } } /** - * Fires after the piston has moved and set surrounding states. This will not fire if {@link PistonEvent.Pre} is cancelled. + * Fires before the piston has updated block states. Cancellation prevents movement. */ - public static final class Post extends PistonEvent { - public static final EventBus BUS = EventBus.create(Post.class); + record Pre( + LevelAccessor getLevel, + BlockPos getPos, + BlockState getState, + Direction getDirection, + PistonMoveType getPistonMoveType + ) implements Cancellable, PistonEvent, RecordEvent { + public static final CancellableEventBus
       BUS = CancellableEventBus.create(Pre.class);
       
      -        public Post(Level world, BlockPos pos, Direction direction, PistonMoveType moveType) {
      -            super(world, pos, direction, moveType);
      +        public Pre(Level world, BlockPos pos, Direction direction, PistonMoveType moveType) {
      +            this(world, pos, world.getBlockState(pos), direction, moveType);
               }
           }
       
           /**
      -     * Fires before the piston has updated block states. Cancellation prevents movement.
      +     * Fires after the piston has moved and set surrounding states. This will not fire if {@link PistonEvent.Pre} is cancelled.
            */
      -    public static final class Pre extends PistonEvent implements Cancellable {
      -        public static final CancellableEventBus
       BUS = CancellableEventBus.create(Pre.class);
      +    record Post(
      +            LevelAccessor getLevel,
      +            BlockPos getPos,
      +            BlockState getState,
      +            Direction getDirection,
      +            PistonMoveType getPistonMoveType
      +    ) implements RecordEvent, PistonEvent {
      +        public static final EventBus BUS = EventBus.create(Post.class);
       
      -        public Pre(Level world, BlockPos pos, Direction direction, PistonMoveType moveType) {
      -            super(world, pos, direction, moveType);
      +        public Post(Level world, BlockPos pos, Direction direction, PistonMoveType moveType) {
      +            this(world, pos, world.getBlockState(pos), direction, moveType);
               }
      -
           }
       
      -    public enum PistonMoveType {
      -        EXTEND(true),
      -        RETRACT(false);
      +    enum PistonMoveType {
      +        EXTEND {
      +            @Override
      +            public final boolean isExtend() {
      +                return true;
      +            }
      +        },
      +        RETRACT;
       
      -        public final boolean isExtend;
      -
      -        PistonMoveType(boolean isExtend)
      -        {
      -            this.isExtend = isExtend;
      +        public boolean isExtend() {
      +            return false;
               }
           }
       }
      diff --git a/src/main/java/net/minecraftforge/event/level/SaplingGrowTreeEvent.java b/src/main/java/net/minecraftforge/event/level/SaplingGrowTreeEvent.java
      index 7cf1b5d4e9..25a3398a00 100644
      --- a/src/main/java/net/minecraftforge/event/level/SaplingGrowTreeEvent.java
      +++ b/src/main/java/net/minecraftforge/event/level/SaplingGrowTreeEvent.java
      @@ -16,12 +16,13 @@ import net.minecraftforge.common.MinecraftForge;
       import net.minecraftforge.common.util.HasResult;
       import net.minecraftforge.common.util.Result;
       import net.minecraftforge.eventbus.api.bus.EventBus;
      +import net.minecraftforge.eventbus.api.event.characteristic.Cancellable;
       import org.jetbrains.annotations.Nullable;
       
       /**
        * This event is fired whenever a sapling, fungus, mushroom or azalea grows into a tree.
        * 

      - * This event is not {@linkplain Cancelable cancellable} but does {@linkplain HasResult have a result}. + * This event is not {@linkplain Cancellable cancellable} but does {@linkplain HasResult have a result}. * {@linkplain Result#ALLOW ALLOW} and {@linkplain Result#DEFAULT DEFAULT} will allow the sapling to grow * using the features set on the event. * {@linkplain Result#DENY DENY} will prevent the sapling from growing. @@ -31,9 +32,10 @@ import org.jetbrains.annotations.Nullable; */ // TODO: Rename to BlockFeatureGrowEvent in 1.20 @Deprecated(forRemoval = true, since = "1.21.1") // Dont remove, rename -public final class SaplingGrowTreeEvent extends LevelEvent implements HasResult { +public final class SaplingGrowTreeEvent implements LevelEvent, HasResult { public static final EventBus BUS = EventBus.create(SaplingGrowTreeEvent.class); + private final LevelAccessor level; private final RandomSource randomSource; private final BlockPos pos; @Nullable @@ -41,12 +43,17 @@ public final class SaplingGrowTreeEvent extends LevelEvent implements HasResult private Result result = Result.DEFAULT; public SaplingGrowTreeEvent(LevelAccessor level, RandomSource randomSource, BlockPos pos, @Nullable Holder> feature) { - super(level); + this.level = level; this.randomSource = randomSource; this.pos = pos; this.feature = feature; } + @Override + public LevelAccessor getLevel() { + return level; + } + /** * {@return the random source which initiated the sapling growth} */ diff --git a/src/main/java/net/minecraftforge/event/level/SleepFinishedTimeEvent.java b/src/main/java/net/minecraftforge/event/level/SleepFinishedTimeEvent.java index 990fc6e8f2..e74848eaef 100644 --- a/src/main/java/net/minecraftforge/event/level/SleepFinishedTimeEvent.java +++ b/src/main/java/net/minecraftforge/event/level/SleepFinishedTimeEvent.java @@ -6,6 +6,7 @@ package net.minecraftforge.event.level; import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.level.LevelAccessor; import net.minecraftforge.eventbus.api.bus.EventBus; /** @@ -13,18 +14,24 @@ import net.minecraftforge.eventbus.api.bus.EventBus; * * setWakeUpTime(wakeUpTime) sets a new time that will be added to the dayTime.
      */ -public final class SleepFinishedTimeEvent extends LevelEvent { +public final class SleepFinishedTimeEvent implements LevelEvent { public static final EventBus BUS = EventBus.create(SleepFinishedTimeEvent.class); + private final ServerLevel level; private long newTime; private final long minTime; public SleepFinishedTimeEvent(ServerLevel level, long newTime, long minTime) { - super(level); + this.level = level; this.newTime = newTime; this.minTime = minTime; } + @Override + public LevelAccessor getLevel() { + return level; + } + /** * @return the new time */ diff --git a/src/main/java/net/minecraftforge/event/network/GatherLoginConfigurationTasksEvent.java b/src/main/java/net/minecraftforge/event/network/GatherLoginConfigurationTasksEvent.java index 3a5affbab3..5302427f7f 100644 --- a/src/main/java/net/minecraftforge/event/network/GatherLoginConfigurationTasksEvent.java +++ b/src/main/java/net/minecraftforge/event/network/GatherLoginConfigurationTasksEvent.java @@ -10,28 +10,18 @@ import java.util.function.Consumer; import net.minecraft.network.Connection; import net.minecraft.server.network.ConfigurationTask; import net.minecraftforge.eventbus.api.bus.EventBus; -import net.minecraftforge.eventbus.api.event.MutableEvent; +import net.minecraftforge.eventbus.api.event.RecordEvent; +import org.jspecify.annotations.NullMarked; /** * Gathers tasks that need to be run during the initial login configuration. * @see net.minecraft.server.network.ServerConfigurationPacketListenerImpl#startConfiguration() startConfiguration */ -public final class GatherLoginConfigurationTasksEvent extends MutableEvent { +@NullMarked +public record GatherLoginConfigurationTasksEvent(Connection getConnection, Consumer taskAdder) implements RecordEvent { public static final EventBus BUS = EventBus.create(GatherLoginConfigurationTasksEvent.class); - private final Connection connection; - private final Consumer add; - - public GatherLoginConfigurationTasksEvent(Connection connection, Consumer add) { - this.connection = connection; - this.add = add; - } - - public Connection getConnection() { - return this.connection; - } - public void addTask(ConfigurationTask task) { - this.add.accept(task); + taskAdder.accept(task); } } diff --git a/src/main/java/net/minecraftforge/event/server/ServerAboutToStartEvent.java b/src/main/java/net/minecraftforge/event/server/ServerAboutToStartEvent.java index c8f799b0f5..35b252db8e 100644 --- a/src/main/java/net/minecraftforge/event/server/ServerAboutToStartEvent.java +++ b/src/main/java/net/minecraftforge/event/server/ServerAboutToStartEvent.java @@ -16,10 +16,6 @@ import net.minecraftforge.fml.event.lifecycle.InterModProcessEvent; * You can obtain a reference to the server with this event. * @author cpw */ -public final class ServerAboutToStartEvent extends ServerLifecycleEvent { +public record ServerAboutToStartEvent(MinecraftServer getServer) implements ServerLifecycleEvent { public static final EventBus BUS = EventBus.create(ServerAboutToStartEvent.class); - - public ServerAboutToStartEvent(MinecraftServer server) { - super(server); - } } diff --git a/src/main/java/net/minecraftforge/event/server/ServerLifecycleEvent.java b/src/main/java/net/minecraftforge/event/server/ServerLifecycleEvent.java index 926dd73c95..0c489b7022 100644 --- a/src/main/java/net/minecraftforge/event/server/ServerLifecycleEvent.java +++ b/src/main/java/net/minecraftforge/event/server/ServerLifecycleEvent.java @@ -8,19 +8,10 @@ package net.minecraftforge.event.server; import net.minecraft.server.MinecraftServer; import net.minecraftforge.eventbus.api.bus.EventBus; import net.minecraftforge.eventbus.api.event.InheritableEvent; -import net.minecraftforge.eventbus.api.event.MutableEvent; -public sealed class ServerLifecycleEvent extends MutableEvent implements InheritableEvent +public sealed interface ServerLifecycleEvent extends InheritableEvent permits ServerAboutToStartEvent, ServerStartedEvent, ServerStartingEvent, ServerStoppedEvent, ServerStoppingEvent { - public static final EventBus BUS = EventBus.create(ServerLifecycleEvent.class); + EventBus BUS = EventBus.create(ServerLifecycleEvent.class); - protected final MinecraftServer server; - - public ServerLifecycleEvent(MinecraftServer server) { - this.server = server; - } - - public MinecraftServer getServer() { - return server; - } + MinecraftServer getServer(); } diff --git a/src/main/java/net/minecraftforge/event/server/ServerStartedEvent.java b/src/main/java/net/minecraftforge/event/server/ServerStartedEvent.java index 9a962143bc..95fd9d7ecb 100644 --- a/src/main/java/net/minecraftforge/event/server/ServerStartedEvent.java +++ b/src/main/java/net/minecraftforge/event/server/ServerStartedEvent.java @@ -13,10 +13,6 @@ import net.minecraftforge.eventbus.api.bus.EventBus; * * @author cpw */ -public final class ServerStartedEvent extends ServerLifecycleEvent { +public record ServerStartedEvent(MinecraftServer getServer) implements ServerLifecycleEvent { public static final EventBus BUS = EventBus.create(ServerStartedEvent.class); - - public ServerStartedEvent(final MinecraftServer server) { - super(server); - } } diff --git a/src/main/java/net/minecraftforge/event/server/ServerStartingEvent.java b/src/main/java/net/minecraftforge/event/server/ServerStartingEvent.java index 071b878519..e42a62f068 100644 --- a/src/main/java/net/minecraftforge/event/server/ServerStartingEvent.java +++ b/src/main/java/net/minecraftforge/event/server/ServerStartingEvent.java @@ -16,10 +16,6 @@ import net.minecraftforge.eventbus.api.bus.EventBus; * * @author cpw */ -public final class ServerStartingEvent extends ServerLifecycleEvent { +public record ServerStartingEvent(MinecraftServer getServer) implements ServerLifecycleEvent { public static final EventBus BUS = EventBus.create(ServerStartingEvent.class); - - public ServerStartingEvent(final MinecraftServer server) { - super(server); - } } diff --git a/src/main/java/net/minecraftforge/event/server/ServerStoppedEvent.java b/src/main/java/net/minecraftforge/event/server/ServerStoppedEvent.java index 48d792a110..8a457aaf83 100644 --- a/src/main/java/net/minecraftforge/event/server/ServerStoppedEvent.java +++ b/src/main/java/net/minecraftforge/event/server/ServerStoppedEvent.java @@ -15,10 +15,6 @@ import net.minecraftforge.eventbus.api.bus.EventBus; * * @author cpw */ -public final class ServerStoppedEvent extends ServerLifecycleEvent { +public record ServerStoppedEvent(MinecraftServer getServer) implements ServerLifecycleEvent { public static final EventBus BUS = EventBus.create(ServerStoppedEvent.class); - - public ServerStoppedEvent(MinecraftServer server) { - super(server); - } } diff --git a/src/main/java/net/minecraftforge/event/server/ServerStoppingEvent.java b/src/main/java/net/minecraftforge/event/server/ServerStoppingEvent.java index 179c94ca69..4898a08f29 100644 --- a/src/main/java/net/minecraftforge/event/server/ServerStoppingEvent.java +++ b/src/main/java/net/minecraftforge/event/server/ServerStoppingEvent.java @@ -13,10 +13,6 @@ import net.minecraftforge.eventbus.api.bus.EventBus; * * @author cpw */ -public final class ServerStoppingEvent extends ServerLifecycleEvent { +public record ServerStoppingEvent(MinecraftServer getServer) implements ServerLifecycleEvent { public static final EventBus BUS = EventBus.create(ServerStoppingEvent.class); - - public ServerStoppingEvent(MinecraftServer server) { - super(server); - } } diff --git a/src/main/java/net/minecraftforge/event/village/VillagerTradesEvent.java b/src/main/java/net/minecraftforge/event/village/VillagerTradesEvent.java index 3b7448f7b9..c874253599 100644 --- a/src/main/java/net/minecraftforge/event/village/VillagerTradesEvent.java +++ b/src/main/java/net/minecraftforge/event/village/VillagerTradesEvent.java @@ -12,15 +12,13 @@ import net.minecraft.resources.ResourceKey; import net.minecraft.world.entity.npc.VillagerData; import net.minecraft.world.entity.npc.VillagerProfession; import net.minecraft.world.entity.npc.VillagerTrades.ItemListing; -import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.server.ServerAboutToStartEvent; import net.minecraftforge.eventbus.api.bus.EventBus; -import net.minecraftforge.eventbus.api.event.InheritableEvent; -import net.minecraftforge.eventbus.api.event.MutableEvent; +import net.minecraftforge.eventbus.api.event.RecordEvent; +import org.jspecify.annotations.NullMarked; /** * VillagerTradesEvent is fired during the {@link ServerAboutToStartEvent}. It is used to gather the trade lists for each profession. - *

      It is fired on the {@link MinecraftForge#EVENT_BUS}.

      *

      It is fired once for each registered villager profession.

      *

      Villagers pick two trades from their trade map, based on their level.

      *

      Villager level is increased by successful trades.

      @@ -28,22 +26,10 @@ import net.minecraftforge.eventbus.api.event.MutableEvent; *

      Levels outside of this range do nothing, as specified by {@link VillagerData#canLevelUp(int)} which is called before attempting to level up.

      *

      To add trades to the merchant, simply add new trades to the list.

      */ -public class VillagerTradesEvent extends MutableEvent implements InheritableEvent { +@NullMarked +public record VillagerTradesEvent( + Int2ObjectMap> getTrades, + ResourceKey getType +) implements RecordEvent { public static final EventBus BUS = EventBus.create(VillagerTradesEvent.class); - - protected Int2ObjectMap> trades; - protected ResourceKey type; - - public VillagerTradesEvent(Int2ObjectMap> trades, ResourceKey type) { - this.trades = trades; - this.type = type; - } - - public Int2ObjectMap> getTrades() { - return this.trades; - } - - public ResourceKey getType() { - return this.type; - } } diff --git a/src/main/java/net/minecraftforge/fluids/FluidUtil.java b/src/main/java/net/minecraftforge/fluids/FluidUtil.java index eaed4a94cd..95d3860698 100644 --- a/src/main/java/net/minecraftforge/fluids/FluidUtil.java +++ b/src/main/java/net/minecraftforge/fluids/FluidUtil.java @@ -640,7 +640,7 @@ public class FluidUtil */ public static void destroyBlockOnFluidPlacement(Level level, BlockPos pos) { - if (!level.isClientSide) + if (!level.isClientSide()) { BlockState destBlockState = level.getBlockState(pos); boolean isDestNonSolid = !destBlockState.isSolid(); diff --git a/src/main/java/net/minecraftforge/fml/event/config/ModConfigEvent.java b/src/main/java/net/minecraftforge/fml/event/config/ModConfigEvent.java index 203ec3e422..dc3cce2e06 100644 --- a/src/main/java/net/minecraftforge/fml/event/config/ModConfigEvent.java +++ b/src/main/java/net/minecraftforge/fml/event/config/ModConfigEvent.java @@ -11,30 +11,15 @@ import net.minecraftforge.fml.config.IConfigEvent; import net.minecraftforge.fml.config.ModConfig; import net.minecraftforge.fml.event.IModBusEvent; -public sealed class ModConfigEvent implements IModBusEvent, IConfigEvent { - private final ModConfig config; - - ModConfigEvent(final ModConfig config) { - this.config = config; - } - - @Override - public ModConfig getConfig() { - return config; - } - +public sealed interface ModConfigEvent extends IModBusEvent, IConfigEvent { /** * Fired during mod and server loading, depending on {@link ModConfig.Type} of config file. * Any Config objects associated with this will be valid and can be queried directly. */ - public static final class Loading extends ModConfigEvent { + record Loading(ModConfig getConfig) implements ModConfigEvent { public static EventBus getBus(BusGroup modBusGroup) { return IModBusEvent.getBus(modBusGroup, Loading.class); } - - public Loading(final ModConfig config) { - super(config); - } } /** @@ -43,14 +28,10 @@ public sealed class ModConfigEvent implements IModBusEvent, IConfigEvent { * and may not even be on the server or client threads. Ensure you properly synchronize * any resultant changes. */ - public static final class Reloading extends ModConfigEvent { + record Reloading(ModConfig getConfig) implements ModConfigEvent { public static EventBus getBus(BusGroup modBusGroup) { return IModBusEvent.getBus(modBusGroup, Reloading.class); } - - public Reloading(final ModConfig config) { - super(config); - } } /** @@ -59,13 +40,9 @@ public sealed class ModConfigEvent implements IModBusEvent, IConfigEvent { * server goes away, though it will fire on the dedicated server as well. * The config file will be saved after this event has fired. */ - public static final class Unloading extends ModConfigEvent { + record Unloading(ModConfig getConfig) implements ModConfigEvent { public static EventBus getBus(BusGroup modBusGroup) { return IModBusEvent.getBus(modBusGroup, Unloading.class); } - - public Unloading(final ModConfig config) { - super(config); - } } } diff --git a/src/main/java/net/minecraftforge/fml/event/lifecycle/ModLifecycleEvent.java b/src/main/java/net/minecraftforge/fml/event/lifecycle/ModLifecycleEvent.java index 3a4507a629..b8659265c6 100644 --- a/src/main/java/net/minecraftforge/fml/event/lifecycle/ModLifecycleEvent.java +++ b/src/main/java/net/minecraftforge/fml/event/lifecycle/ModLifecycleEvent.java @@ -16,10 +16,10 @@ import java.util.stream.Stream; * Parent type to all ModLifecycle events. This is based on Forge EventBus. They fire through the * ModContainer's eventbus instance. */ -public class ModLifecycleEvent implements IModBusEvent { +public abstract class ModLifecycleEvent implements IModBusEvent { private final ModContainer container; - public ModLifecycleEvent(ModContainer container) { + protected ModLifecycleEvent(ModContainer container) { this.container = container; } diff --git a/src/main/java/net/minecraftforge/fml/event/lifecycle/ParallelDispatchEvent.java b/src/main/java/net/minecraftforge/fml/event/lifecycle/ParallelDispatchEvent.java index 8023c9ec2c..27f3e5cc59 100644 --- a/src/main/java/net/minecraftforge/fml/event/lifecycle/ParallelDispatchEvent.java +++ b/src/main/java/net/minecraftforge/fml/event/lifecycle/ParallelDispatchEvent.java @@ -13,10 +13,10 @@ import java.util.Optional; import java.util.concurrent.CompletableFuture; import java.util.function.Supplier; -public class ParallelDispatchEvent extends ModLifecycleEvent { +public abstract class ParallelDispatchEvent extends ModLifecycleEvent { private final ModLoadingStage modLoadingStage; - public ParallelDispatchEvent(final ModContainer container, final ModLoadingStage stage) { + protected ParallelDispatchEvent(final ModContainer container, final ModLoadingStage stage) { super(container); this.modLoadingStage = stage; } diff --git a/src/main/java/net/minecraftforge/items/ItemHandlerHelper.java b/src/main/java/net/minecraftforge/items/ItemHandlerHelper.java index c689e8b79a..77e30187d7 100644 --- a/src/main/java/net/minecraftforge/items/ItemHandlerHelper.java +++ b/src/main/java/net/minecraftforge/items/ItemHandlerHelper.java @@ -127,7 +127,7 @@ public class ItemHandlerHelper { } // drop remaining itemstack into the level - if (!remainder.isEmpty() && !level.isClientSide) { + if (!remainder.isEmpty() && !level.isClientSide()) { ItemEntity entityitem = new ItemEntity(level, player.getX(), player.getY() + 0.5, player.getZ(), remainder); entityitem.setPickUpDelay(40); entityitem.setDeltaMovement(entityitem.getDeltaMovement().multiply(0, 1, 0)); diff --git a/src/main/java/net/minecraftforge/items/wrapper/PlayerMainInvWrapper.java b/src/main/java/net/minecraftforge/items/wrapper/PlayerMainInvWrapper.java index 34ecf7a208..acebf0dd2b 100644 --- a/src/main/java/net/minecraftforge/items/wrapper/PlayerMainInvWrapper.java +++ b/src/main/java/net/minecraftforge/items/wrapper/PlayerMainInvWrapper.java @@ -31,7 +31,7 @@ public class PlayerMainInvWrapper extends RangedWrapper { ItemStack inSlot = getStackInSlot(slot); if(!inSlot.isEmpty()) { var world = getInventoryPlayer().player.level(); - if (world.isClientSide) { + if (world.isClientSide()) { inSlot.setPopTime(5); } else if (getInventoryPlayer().player instanceof ServerPlayer) { getInventoryPlayer().player.containerMenu.broadcastChanges(); diff --git a/src/main/java/net/minecraftforge/items/wrapper/RecipeWrapper.java b/src/main/java/net/minecraftforge/items/wrapper/RecipeWrapper.java index f1e4c71514..cfc7133570 100644 --- a/src/main/java/net/minecraftforge/items/wrapper/RecipeWrapper.java +++ b/src/main/java/net/minecraftforge/items/wrapper/RecipeWrapper.java @@ -11,11 +11,9 @@ import net.minecraft.world.item.ItemStack; import net.minecraftforge.items.IItemHandlerModifiable; public class RecipeWrapper implements Container { - protected final IItemHandlerModifiable inv; - public RecipeWrapper(IItemHandlerModifiable inv) - { + public RecipeWrapper(IItemHandlerModifiable inv) { this.inv = inv; } @@ -23,8 +21,7 @@ public class RecipeWrapper implements Container { * Returns the size of this inventory. */ @Override - public int getContainerSize() - { + public int getContainerSize() { return inv.getSlots(); } @@ -32,8 +29,7 @@ public class RecipeWrapper implements Container { * Returns the stack in this slot. This stack should be a modifiable reference, not a copy of a stack in your inventory. */ @Override - public ItemStack getItem(int slot) - { + public ItemStack getItem(int slot) { return inv.getStackInSlot(slot); } @@ -41,8 +37,7 @@ public class RecipeWrapper implements Container { * Attempts to remove n items from the specified slot. Returns the split stack that was removed. Modifies the inventory. */ @Override - public ItemStack removeItem(int slot, int count) - { + public ItemStack removeItem(int slot, int count) { ItemStack stack = inv.getStackInSlot(slot); return stack.isEmpty() ? ItemStack.EMPTY : stack.split(count); } @@ -51,8 +46,7 @@ public class RecipeWrapper implements Container { * Sets the contents of this slot to the provided stack. */ @Override - public void setItem(int slot, ItemStack stack) - { + public void setItem(int slot, ItemStack stack) { inv.setStackInSlot(slot, stack); } @@ -60,37 +54,32 @@ public class RecipeWrapper implements Container { * Removes the stack contained in this slot from the underlying handler, and returns it. */ @Override - public ItemStack removeItemNoUpdate(int index) - { + public ItemStack removeItemNoUpdate(int index) { ItemStack s = getItem(index); - if(s.isEmpty()) return ItemStack.EMPTY; + if (s.isEmpty()) + return ItemStack.EMPTY; setItem(index, ItemStack.EMPTY); return s; } @Override - public boolean isEmpty() - { - for(int i = 0; i < inv.getSlots(); i++) - { - if(!inv.getStackInSlot(i).isEmpty()) return false; + public boolean isEmpty() { + for (int i = 0; i < inv.getSlots(); i++) { + if (!inv.getStackInSlot(i).isEmpty()) + return false; } return true; } @Override - public boolean canPlaceItem(int slot, ItemStack stack) - { + public boolean canPlaceItem(int slot, ItemStack stack) { return inv.isItemValid(slot, stack); } @Override - public void clearContent() - { + public void clearContent() { for(int i = 0; i < inv.getSlots(); i++) - { inv.setStackInSlot(i, ItemStack.EMPTY); - } } //The following methods are never used by vanilla in crafting. They are defunct as mods need not override them. @@ -100,9 +89,4 @@ public class RecipeWrapper implements Container { public void setChanged() {} @Override public boolean stillValid(Player player) { return false; } - @Override - public void startOpen(Player player) {} - @Override - public void stopOpen(Player player) {} - } diff --git a/src/main/java/net/minecraftforge/network/PacketDistributor.java b/src/main/java/net/minecraftforge/network/PacketDistributor.java index db98731b77..fe6e4db3ed 100644 --- a/src/main/java/net/minecraftforge/network/PacketDistributor.java +++ b/src/main/java/net/minecraftforge/network/PacketDistributor.java @@ -157,12 +157,14 @@ public record PacketDistributor(BiFunction, T, Consumer< return p -> getServer().getPlayerList().broadcast(tp.excluded, tp.x, tp.y, tp.z, tp.r2, tp.dim, p); } + @SuppressWarnings({"rawtypes", "unchecked"}) // This should only ever be used during PLAY and the vanilla code forces it to be ClientGamePacketListener, so do an unsafe cast private Consumer> trackingEntity(Entity entity) { - return p -> ((ServerChunkCache)entity.level().getChunkSource()).broadcast(entity, p); + return p -> ((ServerChunkCache)entity.level().getChunkSource()).sendToTrackingPlayers(entity, (Packet)p); } + @SuppressWarnings({"rawtypes", "unchecked"}) // This should only ever be used during PLAY and the vanilla code forces it to be ClientGamePacketListener, so do an unsafe cast private Consumer> trackingEntityAndSelf(Entity entity) { - return p -> ((ServerChunkCache)entity.level().getChunkSource()).broadcastAndSend(entity, p); + return p -> ((ServerChunkCache)entity.level().getChunkSource()).sendToTrackingPlayersAndSelf(entity, (Packet)p); } @SuppressWarnings("resource") diff --git a/src/main/java/net/minecraftforge/network/packets/SpawnEntity.java b/src/main/java/net/minecraftforge/network/packets/SpawnEntity.java index 60b7e7a0c6..62b9cf1fe2 100644 --- a/src/main/java/net/minecraftforge/network/packets/SpawnEntity.java +++ b/src/main/java/net/minecraftforge/network/packets/SpawnEntity.java @@ -147,7 +147,7 @@ public class SpawnEntity { e.setUUID(msg.uuid); if (world.orElse(null) instanceof ClientLevel cworld) cworld.addEntity(e); - e.lerpMotion(msg.velX / 8000.0, msg.velY / 8000.0, msg.velZ / 8000.0); + //e.lerpMotion(msg.velX / 8000.0, msg.velY / 8000.0, msg.velZ / 8000.0); if (e instanceof IEntityAdditionalSpawnData entityAdditionalSpawnData) entityAdditionalSpawnData.readSpawnData(msg.buf); } finally { diff --git a/src/main/java/net/minecraftforge/registries/GameData.java b/src/main/java/net/minecraftforge/registries/GameData.java index e88e65d840..d0ef606f7d 100644 --- a/src/main/java/net/minecraftforge/registries/GameData.java +++ b/src/main/java/net/minecraftforge/registries/GameData.java @@ -313,7 +313,6 @@ public class GameData { // the id mapping has reverted, fire remap events for those that care about id changes if (fireEvents) { fireRemapEvent(ImmutableMap.of(), true); - ObjectHolderRegistry.applyObjectHolders(); } // the id mapping has reverted, ensure we sync up the object holders @@ -347,13 +346,10 @@ public class GameData { if (forgeRegistry != null) forgeRegistry.unfreeze(); - ModLoader.get().postEventWrapContainerInModOrder(registerEvent); + ModLoader.postEventWrapContainerInModOrder(registerEvent); if (forgeRegistry != null) forgeRegistry.freeze(); - LOGGER.debug(REGISTRIES, "Applying holder lookups: {}", registryKey.location()); - ObjectHolderRegistry.applyObjectHolders(registryKey.location()::equals); - LOGGER.debug(REGISTRIES, "Holder lookups applied: {}", registryKey.location()); } catch (Throwable t) { aggregate.addSuppressed(t); } @@ -692,9 +688,6 @@ public class GameData { // Tell mods that the ids have changed fireRemapEvent(remaps, false); - // The id map changed, ensure we apply object holders - ObjectHolderRegistry.applyObjectHolders(); - // Return an empty list, because we're good return ArrayListMultimap.create(); } diff --git a/src/main/java/net/minecraftforge/registries/ObjectHolder.java b/src/main/java/net/minecraftforge/registries/ObjectHolder.java deleted file mode 100644 index 887f2ddefa..0000000000 --- a/src/main/java/net/minecraftforge/registries/ObjectHolder.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) Forge Development LLC and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.minecraftforge.registries; - -import net.minecraft.resources.ResourceLocation; -import net.minecraftforge.fml.common.Mod; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * ObjectHolder can be used to automatically populate public static final fields with entries - * from the registry. These values can then be referred within mod code directly. - * @deprecated Use {@link DeferredRegister} or {@link RegistryObject} instead. Refer to the MDK for more detailed examples. - *
      - * Example usage of alternatives: - *
      {@code
      - * // To register something
      - * public static final DeferredRegister ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MODID);
      - * public static final RegistryObject EXAMPLE_ITEM = ITEMS.register("example_item", () -> new Item(new Item.Properties()));
      - *
      - * // To get a RegistryObject that you didn't register yourself:
      - * public static final RegistryObject DIRT = RegistryObject.create(ResourceLocation.withDefaultNamespace("dirt"), ForgeRegistries.BLOCKS);
      - * }
      - */ -@Deprecated(since = "1.21.4", forRemoval = true) -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.FIELD) -public @interface ObjectHolder -{ - /** - * The name of the registry to load registry entries from. - * This string is parsed as a {@link ResourceLocation} and can contain a namespace. - * - * @return the registry name - */ - String registryName(); - - /** - * Represents a name in the form of a {@link ResourceLocation} which points to a registry object from the registry given by {@link #registryName()}. - * Must specify the modid if not inside a class annotated with {@link Mod}. - * - * @return a name in the form of a {@link ResourceLocation} - */ - String value(); -} diff --git a/src/main/java/net/minecraftforge/registries/ObjectHolderRef.java b/src/main/java/net/minecraftforge/registries/ObjectHolderRef.java deleted file mode 100644 index 929610e9a6..0000000000 --- a/src/main/java/net/minecraftforge/registries/ObjectHolderRef.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright (c) Forge Development LLC and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.minecraftforge.registries; - -import java.lang.reflect.Field; -import java.lang.reflect.Modifier; -import java.util.Locale; -import java.util.function.Consumer; -import java.util.function.Predicate; - -import net.minecraft.resources.ResourceLocation; -import net.minecraft.ResourceLocationException; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.jetbrains.annotations.Nullable; - -@SuppressWarnings("rawtypes") -class ObjectHolderRef implements Consumer> -{ - private static final Logger LOGGER = LogManager.getLogger(); - private final Field field; - private final ResourceLocation injectedObject; - private final ForgeRegistry registry; - - @SuppressWarnings("unchecked") - @Nullable - static ObjectHolderRef create(ResourceLocation registryName, Field field, String injectedObject, boolean extractFromExistingValues) - { - ForgeRegistry registry = RegistryManager.ACTIVE.getRegistry(registryName); - if (registry == null) - return null; - - ResourceLocation injectedObjectName; - if (extractFromExistingValues) - { - try - { - Object existing = field.get(null); - // Nothing is ever allowed to replace AIR - if (existing == null || existing == registry.getDefault()) - return null; - injectedObjectName = ((ForgeRegistry) registry).getKey(existing); - } - catch (IllegalAccessException e) - { - throw new RuntimeException(e); - } - } - else - { - try - { - injectedObjectName = ResourceLocation.parse(injectedObject); - } - catch (ResourceLocationException e) - { - throw new IllegalArgumentException("Invalid @ObjectHolder annotation on \"" + field.toString() + "\"", e); - } - } - - if (injectedObjectName == null) - throw new IllegalStateException(String.format(Locale.ENGLISH, "The ObjectHolder annotation cannot apply to a field that does not map to a registry. Ensure the registry was created during NewRegistryEvent. (found : %s at %s.%s)", field.getType().getName(), field.getDeclaringClass().getName(), field.getName())); - - field.setAccessible(true); - - if (Modifier.isFinal(field.getModifiers())) - { - throw new RuntimeException("@ObjectHolder on final field, our transformer did not run? " + field.getDeclaringClass().getName() + "/" + field.getName()); - } - - return new ObjectHolderRef(registry, field, injectedObjectName); - } - - private ObjectHolderRef(ForgeRegistry registry, Field field, ResourceLocation injectedObject) - { - this.registry = registry; - this.field = field; - this.injectedObject = injectedObject; - } - - @Override - public void accept(Predicate filter) - { - if (registry == null || !filter.test(registry.getRegistryName())) - return; - - Object thing; - if (registry.containsKey(injectedObject)) - { - thing = registry.getValue(injectedObject); - } - else - { - thing = null; - } - - if (thing == null) - { - LOGGER.debug("Unable to lookup {} for {}. This means the object wasn't registered. It's likely just mod options.", injectedObject, field); - return; - } - try - { - field.set(null, thing); - } - catch (IllegalArgumentException | ReflectiveOperationException e) - { - LOGGER.warn("Unable to set {} with value {} ({})", this.field, thing, this.injectedObject, e); - } - } - - @Override - public int hashCode() - { - return field.hashCode(); - } - - @Override - public boolean equals(Object other) - { - if (!(other instanceof ObjectHolderRef)) - return false; - ObjectHolderRef o = (ObjectHolderRef)other; - return this.field.equals(o.field); - } -} diff --git a/src/main/java/net/minecraftforge/registries/ObjectHolderRegistry.java b/src/main/java/net/minecraftforge/registries/ObjectHolderRegistry.java deleted file mode 100644 index 1f4ae73ebc..0000000000 --- a/src/main/java/net/minecraftforge/registries/ObjectHolderRegistry.java +++ /dev/null @@ -1,242 +0,0 @@ -/* - * Copyright (c) Forge Development LLC and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.minecraftforge.registries; - -import java.lang.annotation.ElementType; -import java.lang.reflect.Field; -import java.util.Collection; -import java.util.HashSet; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.Set; -import java.util.function.Consumer; -import java.util.function.Predicate; - -import net.minecraft.resources.ResourceLocation; -import net.minecraftforge.fml.ModList; -import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.forgespi.language.ModFileScanData; - -import com.google.common.collect.Maps; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.jetbrains.annotations.Nullable; -import org.objectweb.asm.Opcodes; -import org.objectweb.asm.Type; - -/** - * Internal registry for tracking {@link ObjectHolder} references - */ -public class ObjectHolderRegistry -{ - /** - * Exposed to allow modders to register their own notification handlers. - * This runnable will be called after a registry snapshot has been injected and finalized. - * The internal list is backed by a HashSet so it is HIGHLY recommended you implement a proper equals - * and hashCode function to de-duplicate callers here. - * The default @ObjectHolder implementation uses the hashCode/equals for the field the annotation is on. - */ - public static synchronized void addHandler(Consumer> ref) - { - objectHolders.add(ref); - } - - /** - * Removed the specified handler from the notification list. - * - * The internal list is backed by a hash set, and so proper hashCode and equals operations are required for success. - * - * The default @ObjectHolder implementation uses the hashCode/equals for the field the annotation is on. - * - * @return true if handler was matched and removed. - */ - public static synchronized boolean removeHandler(Consumer> ref) - { - return objectHolders.remove(ref); - } - - //============================================================== - // Everything below is internal, do not use. - //============================================================== - - private static final Logger LOGGER = LogManager.getLogger(); - private static final Set>> objectHolders = new HashSet<>(); - private static final Type OBJECT_HOLDER = Type.getType(ObjectHolder.class); - private static final Type MOD = Type.getType(Mod.class); - // Hardcoded list of vanilla classes that should have object holders for each field of the given registry type. - // IMPORTANT: Updates to this collection must be reflected in ObjectHolderDefinalize. Duplicated cuz classloaders, yay! - // Classnames are validated below. - private static final List VANILLA_OBJECT_HOLDERS = List.of( - new VanillaObjectHolderData("net.minecraft.world.level.block.Blocks", "block", "net.minecraft.world.level.block.Block"), - new VanillaObjectHolderData("net.minecraft.world.item.Items", "item", "net.minecraft.world.item.Item"), - new VanillaObjectHolderData("net.minecraft.world.item.enchantment.Enchantments", "enchantment", "net.minecraft.world.item.enchantment.Enchantment"), - new VanillaObjectHolderData("net.minecraft.world.effect.MobEffects", "mob_effect", "net.minecraft.world.effect.MobEffect"), - new VanillaObjectHolderData("net.minecraft.core.particles.ParticleTypes", "particle_type", "net.minecraft.core.particles.ParticleType"), - new VanillaObjectHolderData("net.minecraft.sounds.SoundEvents", "sound_event", "net.minecraft.sounds.SoundEvent") - ); - - public static void findObjectHolders() - { - LOGGER.debug(ForgeRegistry.REGISTRIES,"Processing ObjectHolder annotations"); - final List annotations = ModList.get().getAllScanData().stream() - .map(ModFileScanData::getAnnotations) - .flatMap(Collection::stream) - .filter(a -> OBJECT_HOLDER.equals(a.annotationType()) || MOD.equals(a.annotationType())) - .toList(); - - if (annotations.stream().noneMatch(a -> OBJECT_HOLDER.equals(a.annotationType()))) - return; // No object holders found, skip the rest of the processing - - Map classModIds = Maps.newHashMap(); - Map> classCache = Maps.newHashMap(); - - // Gather all @Mod classes so that @ObjectHolder's in those classes don't need to specify the mod id; modder convenience - annotations.stream() - .filter(a -> MOD.equals(a.annotationType())) - .forEach(data -> classModIds.put(data.clazz(), (String)data.annotationData().get("value"))); - - // Validate all the vanilla class-level object holders then scan those first - VANILLA_OBJECT_HOLDERS.forEach(data -> { - try - { - Class holderClass = Class.forName(data.holderClass(), true, ObjectHolderRegistry.class.getClassLoader()); - Class registryClass = Class.forName(data.registryType(), true, ObjectHolderRegistry.class.getClassLoader()); - - Type holderType = Type.getType(holderClass); - classCache.put(holderType, holderClass); - scanTarget(classModIds, classCache, holderType, null, registryClass, data.registryName(), "minecraft", true, true); - } - catch (ClassNotFoundException e) - { - throw new RuntimeException("Vanilla class not found, should not be possible", e); - } - }); - - // Scan actual fields annotated with @ObjectHolder second - annotations.stream() - .filter(a -> OBJECT_HOLDER.equals(a.annotationType())).filter(a -> a.targetType() == ElementType.FIELD) - .forEach(data -> scanTarget(classModIds, classCache, data.clazz(), - data.memberName(), null, (String)data.annotationData().get("registryName"), - (String)data.annotationData().get("value"), false, false)); - - LOGGER.debug(ForgeRegistry.REGISTRIES,"Found {} ObjectHolder annotations", objectHolders.size()); - } - - private static void scanTarget(Map classModIds, Map> classCache, Type type, - @Nullable String annotationTarget, @Nullable Class registryClass, String registryName, - String value, boolean isClass, boolean extractFromValue) - { - Class clazz; - if (classCache.containsKey(type)) - { - clazz = classCache.get(type); - } - else - { - try - { - clazz = Class.forName(type.getClassName(), extractFromValue, ObjectHolderRegistry.class.getClassLoader()); - classCache.put(type, clazz); - } - catch (ClassNotFoundException ex) - { - // unpossible? - throw new RuntimeException(ex); - } - } - if (isClass) - { - scanClassForFields(classModIds, type, ResourceLocation.parse(registryName), registryClass, value, clazz, extractFromValue); - } - else - { - if (value.indexOf(':') == -1) - { - String prefix = classModIds.get(type); - if (prefix == null) - { - LOGGER.warn(ForgeRegistry.REGISTRIES,"Found an unqualified ObjectHolder annotation ({}) without a modid context at {}.{}, ignoring", value, type, annotationTarget); - throw new IllegalStateException("Unqualified reference to ObjectHolder"); - } - value = prefix + ':' + value; - } - try - { - Field f = clazz.getDeclaredField(annotationTarget); - ObjectHolderRef ref = ObjectHolderRef.create(ResourceLocation.parse(registryName), f, value, extractFromValue); - if (ref != null) - addHandler(ref); - } - catch (NoSuchFieldException ex) - { - // unpossible? - throw new RuntimeException(ex); - } - } - } - - private static void scanClassForFields(Map classModIds, Type targetClass, - ResourceLocation registryName, Class registryClass, String value, Class clazz, boolean extractFromExistingValues) - { - classModIds.put(targetClass, value); - final int flags = Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC | Opcodes.ACC_SYNTHETIC; - for (Field f : clazz.getFields()) - { - if (((f.getModifiers() & flags) != flags) || f.isAnnotationPresent(ObjectHolder.class) || !registryClass.isAssignableFrom(f.getType())) - continue; - ObjectHolderRef ref = ObjectHolderRef.create(registryName, f, value + ':' + f.getName().toLowerCase(Locale.ENGLISH), extractFromExistingValues); - if (ref != null) - addHandler(ref); - } - } - - private static ResourceLocation getRegistryName(Map classRegistryNames, @Nullable String registryName, - Type targetClass, Object declaration) - { - if (registryName != null) - return ResourceLocation.parse(registryName); - - if (classRegistryNames.containsKey(targetClass)) - return classRegistryNames.get(targetClass); - - throw new IllegalStateException("No registry name was declared for " + declaration); - } - - public static void applyObjectHolders() - { - try - { - LOGGER.debug(ForgeRegistry.REGISTRIES, "Applying holder lookups"); - applyObjectHolders(key -> true); - LOGGER.debug(ForgeRegistry.REGISTRIES, "Holder lookups applied"); - } catch (RuntimeException e) - { - // It is more important that the calling contexts continue without exception to prevent further cascading errors - LOGGER.error("", e); - } - } - - public static void applyObjectHolders(Predicate filter) - { - RuntimeException aggregate = new RuntimeException("Failed to apply some object holders, see suppressed exceptions for details"); - for (Consumer> objectHolder : objectHolders) { - try { - objectHolder.accept(filter); - } catch (Exception e) { - aggregate.addSuppressed(e); - } - } - - if (aggregate.getSuppressed().length > 0) - { - throw aggregate; - } - } - - private record VanillaObjectHolderData(String holderClass, String registryName, String registryType) {} -} diff --git a/src/main/java/net/minecraftforge/registries/RegistryManager.java b/src/main/java/net/minecraftforge/registries/RegistryManager.java index 8efe2ca511..d35f06b1c1 100644 --- a/src/main/java/net/minecraftforge/registries/RegistryManager.java +++ b/src/main/java/net/minecraftforge/registries/RegistryManager.java @@ -135,8 +135,8 @@ public class RegistryManager { DataPackRegistryEvent.NewRegistry dataPackEvent = new DataPackRegistryEvent.NewRegistry(); vanillaRegistryKeys = Set.copyOf(BuiltInRegistries.REGISTRY.keySet()); - ModLoader.get().postEventWrapContainerInModOrder(event); - ModLoader.get().postEventWrapContainerInModOrder(dataPackEvent); + ModLoader.postEventWrapContainerInModOrder(event); + ModLoader.postEventWrapContainerInModOrder(dataPackEvent); event.fill(); dataPackEvent.process(); diff --git a/src/main/java/net/minecraftforge/registries/RegistryObject.java b/src/main/java/net/minecraftforge/registries/RegistryObject.java index a2af037b85..a57fc9779a 100644 --- a/src/main/java/net/minecraftforge/registries/RegistryObject.java +++ b/src/main/java/net/minecraftforge/registries/RegistryObject.java @@ -139,10 +139,6 @@ public final class RegistryObject implements Supplier { this.name = name; this.key = (ResourceKey) ResourceKey.create(registry.getRegistryKey(), name); this.optionalRegistry = false; - ObjectHolderRegistry.addHandler(pred -> { - if (pred.test(registry.getRegistryName())) - this.updateReference((IForgeRegistry) registry); - }); this.updateReference((IForgeRegistry) registry); } @@ -150,28 +146,6 @@ public final class RegistryObject implements Supplier { this.name = name; this.key = ResourceKey.create(ResourceKey.createRegistryKey(registryName), name); this.optionalRegistry = optionalRegistry; - final Throwable callerStack = new Throwable("Calling Site from mod: " + modid); - ObjectHolderRegistry.addHandler(new Consumer<>() { - private boolean registryExists = false; - private boolean invalidRegistry = false; - - @Override - public void accept(Predicate pred) { - if (invalidRegistry) - return; - - if (!RegistryObject.this.optionalRegistry && !registryExists) { - if (!registryExists(registryName)) { - invalidRegistry = true; - throw new IllegalStateException("Unable to find registry with key " + registryName + " for mod \"" + modid + "\". Check the 'caused by' to see further stack.", callerStack); - } - registryExists = true; - } - - if (pred.test(registryName)) - RegistryObject.this.updateReference(registryName); - } - }); this.updateReference(registryName); } diff --git a/src/main/java/net/minecraftforge/resource/ResourcePackLoader.java b/src/main/java/net/minecraftforge/resource/ResourcePackLoader.java index 8a8632fb79..4203d986b5 100644 --- a/src/main/java/net/minecraftforge/resource/ResourcePackLoader.java +++ b/src/main/java/net/minecraftforge/resource/ResourcePackLoader.java @@ -16,7 +16,7 @@ import java.util.stream.Collectors; import it.unimi.dsi.fastutil.objects.Object2IntMap; import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; import net.minecraft.server.packs.repository.Pack.Position; -import net.minecraft.SharedConstants; +import net.minecraft.DetectedVersion; import net.minecraft.network.chat.Component; import net.minecraft.server.packs.PackLocationInfo; import net.minecraft.server.packs.PackResources; @@ -79,7 +79,7 @@ public class ResourcePackLoader { private static void findPacks(Consumer packAcceptor, boolean client) { var type = client ? PackType.CLIENT_RESOURCES : PackType.SERVER_DATA; - var version = SharedConstants.getCurrentVersion().packVersion(type); + var version = DetectedVersion.BUILT_IN.packVersion(PackType.CLIENT_RESOURCES); var hiddenPacks = new ArrayList(); for (var mod : ModList.get().getModFiles()) { @@ -94,7 +94,7 @@ public class ResourcePackLoader { var modinfo = file.getModInfos().get(0); var name = "mod:" + modinfo.getModId(); var info = new PackLocationInfo(name, Component.literal(file.getFileName()), PackSource.DEFAULT, Optional.empty()); - var meta = Pack.readPackMetadata(info, supplier, version); + var meta = Pack.readPackMetadata(info, supplier, version, type); Pack pack = null; if (meta != null) pack = new Pack(info, supplier, meta, new PackSelectionConfig(false, Position.BOTTOM, false)); @@ -118,8 +118,7 @@ public class ResourcePackLoader { var delegating = new DelegatingPackResources(info, new PackMetadataSection( Component.translatable("fml.resources.modresources", hiddenPacks.size()), - version, - Optional.empty() + version.minorRange() ), hiddenPacks ); diff --git a/src/main/resources/META-INF/accesstransformer.cfg b/src/main/resources/META-INF/accesstransformer.cfg index 3efc47bdf2..2e1ef64faf 100644 --- a/src/main/resources/META-INF/accesstransformer.cfg +++ b/src/main/resources/META-INF/accesstransformer.cfg @@ -14,7 +14,6 @@ protected net.minecraft.client.data.models.BlockModelGenerators m_372121_(Lnet/m protected net.minecraft.client.data.models.BlockModelGenerators m_372128_()V # createSmithingTable protected net.minecraft.client.data.models.BlockModelGenerators m_372129_()V # createPetrifiedOakSlab protected net.minecraft.client.data.models.BlockModelGenerators m_372134_()V # createFarmland -protected net.minecraft.client.data.models.BlockModelGenerators m_372151_()V # createIronBars protected net.minecraft.client.data.models.BlockModelGenerators m_372158_()V # createBookshelf protected net.minecraft.client.data.models.BlockModelGenerators m_372188_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/client/data/models/MultiVariant;)Lnet/minecraft/client/data/models/blockstates/BlockModelDefinitionGenerator; # createAxisAlignedPillarBlock protected net.minecraft.client.data.models.BlockModelGenerators m_372190_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/item/Item;)V # createMultiface @@ -168,7 +167,7 @@ protected net.minecraft.client.data.models.BlockModelGenerators m_373813_(Lnet/m protected net.minecraft.client.data.models.BlockModelGenerators m_373825_(Lnet/minecraft/world/level/block/Block;)V # createAnvil protected net.minecraft.client.data.models.BlockModelGenerators m_373827_()V # createTallSeagrass protected net.minecraft.client.data.models.BlockModelGenerators m_373843_()V # createHeads -protected net.minecraft.client.data.models.BlockModelGenerators m_373844_()V # createLightningRod +protected net.minecraft.client.data.models.BlockModelGenerators m_373844_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/Block;)V # createLightningRod protected net.minecraft.client.data.models.BlockModelGenerators m_373862_()V # createFire protected net.minecraft.client.data.models.BlockModelGenerators m_373864_()V # createBrewingStand protected net.minecraft.client.data.models.BlockModelGenerators m_373879_()V # createMagmaBlock @@ -182,7 +181,7 @@ protected net.minecraft.client.data.models.BlockModelGenerators m_373974_()V # c protected net.minecraft.client.data.models.BlockModelGenerators m_373984_(Lnet/minecraft/world/level/block/Block;)V # createPassiveRail protected net.minecraft.client.data.models.BlockModelGenerators m_373989_(Lnet/minecraft/world/level/block/Block;)V # createRotatableColumn protected net.minecraft.client.data.models.BlockModelGenerators m_374000_(Lnet/minecraft/world/level/block/Block;)V # createRotatedVariantBlock -protected net.minecraft.client.data.models.BlockModelGenerators m_374002_(Lnet/minecraft/data/BlockFamily;)V # lambda$run$60 +protected net.minecraft.client.data.models.BlockModelGenerators m_374002_(Lnet/minecraft/data/BlockFamily;)V # lambda$run$62 protected net.minecraft.client.data.models.BlockModelGenerators m_374004_()V # createCalibratedSculkSensor protected net.minecraft.client.data.models.BlockModelGenerators m_374006_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/client/data/models/model/TextureMapping;)V # createPumpkinVariant protected net.minecraft.client.data.models.BlockModelGenerators m_374030_()V # createChests @@ -228,12 +227,11 @@ protected net.minecraft.client.data.models.BlockModelGenerators m_374498_(Lnet/m protected net.minecraft.client.data.models.BlockModelGenerators m_374511_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/client/data/models/BlockModelGenerators$PlantType;Lnet/minecraft/world/level/block/state/properties/Property;[I)V # createCrossBlock protected net.minecraft.client.data.models.BlockModelGenerators m_374514_(Lnet/minecraft/world/level/block/Block;)V # createActiveRail protected net.minecraft.client.data.models.BlockModelGenerators m_374532_(Lnet/minecraft/client/data/models/blockstates/MultiPartGenerator;Lnet/minecraft/client/renderer/block/model/multipart/Condition;Lnet/minecraft/client/renderer/block/model/VariantMutator;Lnet/minecraft/world/level/block/state/properties/BooleanProperty;Lnet/minecraft/client/data/models/model/ModelTemplate;Z)V # addBookSlotModel -protected net.minecraft.client.data.models.BlockModelGenerators m_374541_(Lnet/minecraft/client/data/models/model/ModelTemplate;Ljava/lang/String;Lnet/minecraft/client/data/models/model/TextureMapping;Lnet/minecraft/client/data/models/BlockModelGenerators$BookSlotModelCacheKey;)Lnet/minecraft/resources/ResourceLocation; # lambda$addBookSlotModel$58 +protected net.minecraft.client.data.models.BlockModelGenerators m_374541_(Lnet/minecraft/client/data/models/model/ModelTemplate;Ljava/lang/String;Lnet/minecraft/client/data/models/model/TextureMapping;Lnet/minecraft/client/data/models/BlockModelGenerators$BookSlotModelCacheKey;)Lnet/minecraft/resources/ResourceLocation; # lambda$addBookSlotModel$60 protected net.minecraft.client.data.models.BlockModelGenerators m_374546_()V # createCakeBlock protected net.minecraft.client.data.models.BlockModelGenerators m_382772_(Ljava/lang/String;I)Lnet/minecraft/util/random/Weighted; # lambda$createBambooModels$22 protected net.minecraft.client.data.models.BlockModelGenerators m_382773_(Ljava/lang/Integer;)Lnet/minecraft/client/data/models/MultiVariant; # lambda$createSweetBerryBush$41 protected net.minecraft.client.data.models.BlockModelGenerators m_382774_(Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/world/level/block/entity/vault/VaultState;Ljava/lang/Boolean;)Lnet/minecraft/client/data/models/MultiVariant; # lambda$createVault$34 -protected net.minecraft.client.data.models.BlockModelGenerators m_382775_(Lnet/minecraft/client/data/models/blockstates/MultiPartGenerator;Lnet/minecraft/client/data/models/MultiVariant;Lcom/mojang/datafixers/util/Pair;)V # lambda$createChiseledBookshelf$56 protected net.minecraft.client.data.models.BlockModelGenerators m_382776_(Lnet/minecraft/world/level/block/Block;Ljava/lang/String;Lnet/minecraft/client/data/models/model/TextureMapping;)V # lambda$createCreakingHeartModel$16 protected net.minecraft.client.data.models.BlockModelGenerators m_382777_(Lnet/minecraft/client/data/models/blockstates/ConditionBuilder;Lnet/minecraft/world/level/block/state/properties/Property;Lnet/minecraft/client/renderer/block/model/VariantMutator;)V # lambda$createMultifaceBlockStates$48 protected net.minecraft.client.data.models.BlockModelGenerators m_382778_(Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/world/level/block/state/properties/SculkSensorPhase;)Lnet/minecraft/client/data/models/MultiVariant; # lambda$createSculkSensor$35 @@ -247,13 +245,13 @@ protected net.minecraft.client.data.models.BlockModelGenerators m_382785_(Lnet/m protected net.minecraft.client.data.models.BlockModelGenerators m_382786_(Lnet/minecraft/client/data/models/blockstates/ConditionBuilder;)Lnet/minecraft/client/data/models/blockstates/ConditionBuilder; # lambda$static$3 protected net.minecraft.client.data.models.BlockModelGenerators m_382787_(Lnet/minecraft/client/data/models/blockstates/ConditionBuilder;)Lnet/minecraft/client/data/models/blockstates/ConditionBuilder; # lambda$static$2 protected net.minecraft.client.data.models.BlockModelGenerators m_382788_(Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/MultiVariant;Ljava/lang/Boolean;Lnet/minecraft/world/level/block/state/properties/RailShape;)Lnet/minecraft/client/data/models/MultiVariant; # lambda$createActiveRail$20 -protected net.minecraft.client.data.models.BlockModelGenerators m_382789_([Lnet/minecraft/resources/ResourceLocation;Ljava/lang/Integer;)Lnet/minecraft/client/data/models/MultiVariant; # lambda$createRespawnAnchor$59 +protected net.minecraft.client.data.models.BlockModelGenerators m_382789_([Lnet/minecraft/resources/ResourceLocation;Ljava/lang/Integer;)Lnet/minecraft/client/data/models/MultiVariant; # lambda$createRespawnAnchor$61 protected net.minecraft.client.data.models.BlockModelGenerators m_382790_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/client/data/models/MultiVariant;Ljava/lang/Boolean;Ljava/lang/Integer;)Lnet/minecraft/client/data/models/MultiVariant; # lambda$createMangrovePropagule$30 protected net.minecraft.client.data.models.BlockModelGenerators m_382791_(Lnet/minecraft/client/data/models/blockstates/ConditionBuilder;Lnet/minecraft/world/level/block/state/properties/Property;Lnet/minecraft/client/renderer/block/model/VariantMutator;)V # lambda$createMossyCarpet$50 protected net.minecraft.client.data.models.BlockModelGenerators m_382792_(Ljava/lang/Integer;Ljava/lang/Integer;)Lnet/minecraft/client/data/models/MultiVariant; # lambda$createTurtleEgg$43 protected net.minecraft.client.data.models.BlockModelGenerators m_382793_(Lnet/minecraft/client/data/models/blockstates/MultiPartGenerator;Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/blockstates/ConditionBuilder;Lnet/minecraft/world/level/block/state/properties/Property;Lnet/minecraft/client/renderer/block/model/VariantMutator;)V # lambda$createMossyCarpet$53 protected net.minecraft.client.data.models.BlockModelGenerators m_382794_(Lnet/minecraft/client/data/models/blockstates/ConditionBuilder;)Lnet/minecraft/client/data/models/blockstates/ConditionBuilder; # lambda$static$4 -protected net.minecraft.client.data.models.BlockModelGenerators m_382795_(Lnet/minecraft/client/data/models/blockstates/MultiPartGenerator;Lnet/minecraft/client/renderer/block/model/multipart/Condition;Lnet/minecraft/client/renderer/block/model/VariantMutator;Lcom/mojang/datafixers/util/Pair;)V # lambda$addSlotStateAndRotationVariants$57 +protected net.minecraft.client.data.models.BlockModelGenerators m_382795_(Lnet/minecraft/client/data/models/blockstates/MultiPartGenerator;Lnet/minecraft/client/renderer/block/model/multipart/Condition;Lnet/minecraft/client/renderer/block/model/VariantMutator;Lcom/mojang/datafixers/util/Pair;)V # lambda$addSlotStateAndRotationVariants$59 protected net.minecraft.client.data.models.BlockModelGenerators m_382796_(Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/world/level/block/state/properties/SculkSensorPhase;)Lnet/minecraft/client/data/models/MultiVariant; # lambda$createCalibratedSculkSensor$36 protected net.minecraft.client.data.models.BlockModelGenerators m_382797_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/client/data/models/model/TextureMapping;Ljava/lang/Integer;)Lnet/minecraft/client/data/models/MultiVariant; # lambda$createStems$18 protected net.minecraft.client.data.models.BlockModelGenerators m_382798_(Lnet/minecraft/world/level/block/Block;Ljava/lang/Integer;Lnet/minecraft/world/level/block/state/properties/DoubleBlockHalf;)Lnet/minecraft/client/data/models/MultiVariant; # lambda$createPitcherCrop$19 @@ -285,6 +283,25 @@ protected net.minecraft.client.data.models.BlockModelGenerators m_389054_(Lnet/m protected net.minecraft.client.data.models.BlockModelGenerators m_400568_(Ljava/lang/Integer;)Lnet/minecraft/resources/ResourceLocation; # lambda$createDriedGhastBlock$44 protected net.minecraft.client.data.models.BlockModelGenerators m_400569_(Ljava/util/function/Function;Ljava/lang/Integer;)Lnet/minecraft/client/data/models/MultiVariant; # lambda$createDriedGhastBlock$45 protected net.minecraft.client.data.models.BlockModelGenerators m_402965_()V # createDriedGhastBlock +protected net.minecraft.client.data.models.BlockModelGenerators m_414128_(Ljava/util/function/BiConsumer;Lcom/mojang/datafixers/util/Pair;)V # lambda$forEachHorizontalDirection$57 +protected net.minecraft.client.data.models.BlockModelGenerators m_414129_(Lnet/minecraft/client/data/models/blockstates/MultiPartGenerator;Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/core/Direction;Lnet/minecraft/client/renderer/block/model/VariantMutator;)V # lambda$createChiseledBookshelf$58 +protected net.minecraft.client.data.models.BlockModelGenerators m_414130_(Lnet/minecraft/client/data/models/blockstates/MultiPartGenerator;Ljava/lang/Boolean;Lnet/minecraft/world/level/block/state/properties/SideChainPart;Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/core/Direction;Lnet/minecraft/client/renderer/block/model/VariantMutator;)V # lambda$addShelfPart$56 +protected net.minecraft.client.data.models.BlockModelGenerators m_415593_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/Block;)V # createCopperLantern +protected net.minecraft.client.data.models.BlockModelGenerators m_416066_(Lnet/minecraft/core/Direction;Ljava/lang/Boolean;Lnet/minecraft/world/level/block/state/properties/SideChainPart;)Lnet/minecraft/client/renderer/block/model/multipart/Condition; # shelfCondition +protected net.minecraft.client.data.models.BlockModelGenerators m_416075_(Lnet/minecraft/world/level/block/Block;)V # createBarsAndItem +protected net.minecraft.client.data.models.BlockModelGenerators m_416125_(Ljava/util/function/BiConsumer;)V # forEachHorizontalDirection +protected net.minecraft.client.data.models.BlockModelGenerators m_416737_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/Block;)V # createCopperChain +protected net.minecraft.client.data.models.BlockModelGenerators m_416934_(Lnet/minecraft/world/level/block/state/properties/EnumProperty;Ljava/lang/Enum;[Ljava/lang/Enum;)Lnet/minecraft/client/data/models/blockstates/ConditionBuilder; # condition +protected net.minecraft.client.data.models.BlockModelGenerators m_416996_()V # createCopperChests +protected net.minecraft.client.data.models.BlockModelGenerators m_417208_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/resources/ResourceLocation;)V # createBars +protected net.minecraft.client.data.models.BlockModelGenerators m_417848_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/WeatheringCopper$WeatherState;)V # createCopperGolemStatue +protected net.minecraft.client.data.models.BlockModelGenerators m_418505_(Lnet/minecraft/world/level/block/state/properties/BooleanProperty;Z)Lnet/minecraft/client/data/models/blockstates/ConditionBuilder; # condition +protected net.minecraft.client.data.models.BlockModelGenerators m_418983_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/Block;)V # createShelf +protected net.minecraft.client.data.models.BlockModelGenerators m_419554_(Lnet/minecraft/world/item/Item;Lnet/minecraft/world/item/Item;)V # createCopperChainItem +protected net.minecraft.client.data.models.BlockModelGenerators m_419661_()V # createCopperGolemStatues +protected net.minecraft.client.data.models.BlockModelGenerators m_420119_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/client/data/models/model/TextureMapping;Lnet/minecraft/client/data/models/blockstates/MultiPartGenerator;Lnet/minecraft/client/data/models/model/ModelTemplate;Ljava/lang/Boolean;Lnet/minecraft/world/level/block/state/properties/SideChainPart;)V # addShelfPart +protected net.minecraft.client.data.models.BlockModelGenerators m_420286_([Lnet/minecraft/client/data/models/blockstates/ConditionBuilder;)Lnet/minecraft/client/renderer/block/model/multipart/Condition; # and +protected net.minecraft.client.data.models.BlockModelGenerators m_420564_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/Block;)V # createBarsAndItem #endgroup protected net.minecraft.client.data.models.BlockModelGenerators f_371124_ # itemModelOutput protected net.minecraft.client.data.models.BlockModelGenerators f_371133_ # modelOutput @@ -344,16 +361,70 @@ public net.minecraft.client.data.models.ModelProvider$ItemInfoCollector public net.minecraft.client.data.models.ModelProvider$ItemInfoCollector ()V # constructor public net.minecraft.client.data.models.ModelProvider$SimpleModelCollector public net.minecraft.client.data.models.ModelProvider$SimpleModelCollector ()V # constructor -public net.minecraft.client.gui.Gui *() # render methods +#group public net.minecraft.client.gui.Gui *() +public net.minecraft.client.gui.Gui m_168688_(Lnet/minecraft/client/gui/GuiGraphics;Lnet/minecraft/world/entity/player/Player;IIIIFIIIZ)V # renderHearts +public net.minecraft.client.gui.Gui m_193836_()V # tickAutosaveIndicator +public net.minecraft.client.gui.Gui m_232354_(Lnet/minecraft/client/gui/GuiGraphics;Lnet/minecraft/world/entity/player/Player;IIII)V # renderArmor +public net.minecraft.client.gui.Gui m_280030_(Lnet/minecraft/client/gui/GuiGraphics;Lnet/minecraft/world/scores/Objective;)V # displayScoreboardSidebar +public net.minecraft.client.gui.Gui m_280130_(Lnet/minecraft/client/gui/GuiGraphics;Lnet/minecraft/client/DeltaTracker;)V # renderCrosshair +public net.minecraft.client.gui.Gui m_280154_(Lnet/minecraft/client/gui/GuiGraphics;Lnet/minecraft/world/entity/Entity;)V # renderVignette +public net.minecraft.client.gui.Gui m_280155_(Lnet/minecraft/client/gui/GuiGraphics;Lnet/minecraft/resources/ResourceLocation;F)V # renderTextureOverlay +public net.minecraft.client.gui.Gui m_280173_(Lnet/minecraft/client/gui/GuiGraphics;)V # renderPlayerHealth +public net.minecraft.client.gui.Gui m_280250_(Lnet/minecraft/client/gui/GuiGraphics;)V # renderVehicleHealth +public net.minecraft.client.gui.Gui m_280278_(Lnet/minecraft/client/gui/GuiGraphics;F)V # renderSpyglassOverlay +public net.minecraft.client.gui.Gui m_280295_(Lnet/minecraft/client/gui/GuiGraphics;)V # renderSelectedItemName +public net.minecraft.client.gui.Gui m_280339_(Lnet/minecraft/client/gui/GuiGraphics;Lnet/minecraft/client/DeltaTracker;)V # renderDemoOverlay +public net.minecraft.client.gui.Gui m_280379_(Lnet/minecraft/client/gui/GuiGraphics;F)V # renderPortalOverlay +public net.minecraft.client.gui.Gui m_280523_(Lnet/minecraft/client/gui/GuiGraphics;Lnet/minecraft/client/DeltaTracker;)V # renderEffects +public net.minecraft.client.gui.Gui m_280585_(Lnet/minecraft/client/gui/GuiGraphics;IILnet/minecraft/client/DeltaTracker;Lnet/minecraft/world/entity/player/Player;Lnet/minecraft/world/item/ItemStack;I)V # renderSlot +public net.minecraft.client.gui.Gui m_280593_(Lnet/minecraft/client/gui/GuiGraphics;Lnet/minecraft/client/gui/Gui$HeartType;IIZZZ)V # renderHeart +public net.minecraft.client.gui.Gui m_303979_(Lnet/minecraft/world/scores/PlayerScoreEntry;)Z # lambda$displayScoreboardSidebar$7 +public net.minecraft.client.gui.Gui m_303980_(I)[Lnet/minecraft/client/gui/Gui$1DisplayEntry; # lambda$displayScoreboardSidebar$9 +public net.minecraft.client.gui.Gui m_303981_(Lnet/minecraft/world/scores/Scoreboard;Lnet/minecraft/network/chat/numbers/NumberFormat;Lnet/minecraft/world/scores/PlayerScoreEntry;)Lnet/minecraft/client/gui/Gui$1DisplayEntry; # lambda$displayScoreboardSidebar$8 +public net.minecraft.client.gui.Gui m_318727_(Lnet/minecraft/client/gui/GuiGraphics;Lnet/minecraft/client/DeltaTracker;)V # renderCameraOverlays +public net.minecraft.client.gui.Gui m_319215_(Lnet/minecraft/client/gui/GuiGraphics;Lnet/minecraft/client/DeltaTracker;)V # renderHotbarAndDecorations +public net.minecraft.client.gui.Gui m_320053_(Lnet/minecraft/client/gui/GuiGraphics;Lnet/minecraft/client/DeltaTracker;)V # renderTabList +public net.minecraft.client.gui.Gui m_320133_(Lnet/minecraft/client/gui/GuiGraphics;Lnet/minecraft/world/entity/player/Player;II)V # renderFood +public net.minecraft.client.gui.Gui m_320668_(Lnet/minecraft/client/gui/GuiGraphics;Lnet/minecraft/client/DeltaTracker;)V # renderTitle +public net.minecraft.client.gui.Gui m_322096_(Lnet/minecraft/client/gui/GuiGraphics;Lnet/minecraft/client/DeltaTracker;)V # renderChat +public net.minecraft.client.gui.Gui m_322680_(Lnet/minecraft/client/gui/GuiGraphics;Lnet/minecraft/client/DeltaTracker;)V # renderSleepOverlay +public net.minecraft.client.gui.Gui m_323286_(Lnet/minecraft/client/gui/GuiGraphics;Lnet/minecraft/client/DeltaTracker;)V # renderScoreboardSidebar +public net.minecraft.client.gui.Gui m_324281_(Lnet/minecraft/client/gui/GuiGraphics;Lnet/minecraft/client/DeltaTracker;)V # renderOverlayMessage +public net.minecraft.client.gui.Gui m_324469_(Lnet/minecraft/client/gui/GuiGraphics;Lnet/minecraft/client/DeltaTracker;)V # renderItemHotbar +public net.minecraft.client.gui.Gui m_349660_(Ljava/lang/String;)Ljava/lang/String; # lambda$renderCameraOverlays$5 +public net.minecraft.client.gui.Gui m_351658_(III)I # getCurrentAirSupplyBubble +public net.minecraft.client.gui.Gui m_352455_(ILnet/minecraft/world/entity/player/Player;I)V # playAirBubblePoppedSound +public net.minecraft.client.gui.Gui m_353157_(IZ)I # getEmptyBubbleDelayDuration +public net.minecraft.client.gui.Gui m_355810_(Lnet/minecraft/client/gui/GuiGraphics;Lnet/minecraft/world/entity/player/Player;III)V # renderAirBubbles +public net.minecraft.client.gui.Gui m_355965_(II)I # getAirBubbleYLine +public net.minecraft.client.gui.Gui m_356285_(Lnet/minecraft/client/gui/GuiGraphics;F)V # renderConfusionOverlay +public net.minecraft.client.gui.Gui m_400570_(Lnet/minecraft/client/Minecraft;)Lnet/minecraft/client/gui/contextualbar/ContextualBarRenderer; # lambda$new$3 +public net.minecraft.client.gui.Gui m_400571_(Lnet/minecraft/resources/ResourceLocation;)Lnet/minecraft/resources/ResourceLocation; # lambda$getMobEffectSprite$6 +public net.minecraft.client.gui.Gui m_400572_(Lnet/minecraft/client/Minecraft;)Lnet/minecraft/client/gui/contextualbar/ContextualBarRenderer; # lambda$new$2 +public net.minecraft.client.gui.Gui m_400573_(Lnet/minecraft/client/Minecraft;)Lnet/minecraft/client/gui/contextualbar/ContextualBarRenderer; # lambda$new$1 +public net.minecraft.client.gui.Gui m_400574_()Lnet/minecraft/client/gui/contextualbar/ContextualBarRenderer; # lambda$new$0 +public net.minecraft.client.gui.Gui m_401964_(Lnet/minecraft/client/gui/GuiGraphics;Lnet/minecraft/client/DeltaTracker;)V # renderBossOverlay +public net.minecraft.client.gui.Gui m_402852_()Z # willPrioritizeExperienceInfo +public net.minecraft.client.gui.Gui m_402918_()Lnet/minecraft/client/gui/Gui$ContextualInfo; # nextContextualInfoState +public net.minecraft.client.gui.Gui m_403208_()Z # willPrioritizeJumpInfo +public net.minecraft.client.gui.Gui m_403250_(Lnet/minecraft/client/gui/GuiGraphics;Z)V # renderSubtitleOverlay +public net.minecraft.client.gui.Gui m_414133_(Lnet/minecraft/client/gui/GuiGraphics;)V # lambda$renderSubtitleOverlay$4 +public net.minecraft.client.gui.Gui m_93012_(I)I # getVisibleVehicleHeartRows +public net.minecraft.client.gui.Gui m_93020_(Lnet/minecraft/world/entity/Entity;)V # updateVignetteBrightness +public net.minecraft.client.gui.Gui m_93022_(Lnet/minecraft/world/entity/LivingEntity;)I # getVehicleMaxHearts +public net.minecraft.client.gui.Gui m_93024_(Lnet/minecraft/world/phys/HitResult;)Z # canRenderCrosshairForSpectator +public net.minecraft.client.gui.Gui m_93066_()V # tick +public net.minecraft.client.gui.Gui m_93092_()Lnet/minecraft/world/entity/player/Player; # getCameraPlayer +public net.minecraft.client.gui.Gui m_93093_()Lnet/minecraft/world/entity/LivingEntity; # getPlayerVehicleWithHealth +#endgroup public net.minecraft.client.gui.GuiGraphics$ScissorStack public net.minecraft.client.gui.GuiGraphics$ScissorStack ()V # constructor protected net.minecraft.client.gui.components.AbstractButton f_290895_ # SPRITES protected net.minecraft.client.gui.components.AbstractSelectionList$Entry f_93521_ # list protected net.minecraft.client.gui.components.AbstractSliderButton m_293290_()Lnet/minecraft/resources/ResourceLocation; # getHandleSprite protected net.minecraft.client.gui.components.AbstractSliderButton m_293389_()Lnet/minecraft/resources/ResourceLocation; # getSprite -protected net.minecraft.client.gui.components.DebugScreenOverlay f_94032_ # block -protected net.minecraft.client.gui.components.DebugScreenOverlay f_94033_ # liquid protected net.minecraft.client.gui.components.DebugScreenOverlay m_286013_(Lnet/minecraft/client/gui/GuiGraphics;Ljava/util/List;Z)V # renderLines +public net.minecraft.client.gui.components.debug.DebugScreenEntries m_416512_(Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/client/gui/components/debug/DebugScreenEntry;)Lnet/minecraft/resources/ResourceLocation; # register public net.minecraft.client.gui.screens.MenuScreens m_96206_(Lnet/minecraft/world/inventory/MenuType;Lnet/minecraft/client/gui/screens/MenuScreens$ScreenConstructor;)V # register public net.minecraft.client.gui.screens.MenuScreens$ScreenConstructor public net.minecraft.client.gui.screens.Screen f_169369_ # renderables @@ -367,11 +438,11 @@ public net.minecraft.client.multiplayer.SessionSearchTrees f_336706_ # CREATIVE_ public net.minecraft.client.multiplayer.SessionSearchTrees f_337599_ # CREATIVE_NAMES public net.minecraft.client.multiplayer.SessionSearchTrees$Key public net.minecraft.client.multiplayer.SessionSearchTrees$Key ()V # constructor -public net.minecraft.client.particle.ParticleEngine m_107378_(Lnet/minecraft/core/particles/ParticleType;Lnet/minecraft/client/particle/ParticleEngine$SpriteParticleRegistration;)V # register -public net.minecraft.client.particle.ParticleEngine m_107381_(Lnet/minecraft/core/particles/ParticleType;Lnet/minecraft/client/particle/ParticleProvider;)V # register -public net.minecraft.client.particle.ParticleEngine m_272137_(Lnet/minecraft/core/particles/ParticleType;Lnet/minecraft/client/particle/ParticleProvider$Sprite;)V # register -public net.minecraft.client.particle.ParticleEngine$SpriteParticleRegistration +public net.minecraft.client.particle.ParticleResources m_415611_(Lnet/minecraft/core/particles/ParticleType;Lnet/minecraft/client/particle/ParticleResources$SpriteParticleRegistration;)V # register +public net.minecraft.client.particle.ParticleResources m_419483_(Lnet/minecraft/core/particles/ParticleType;Lnet/minecraft/client/particle/ParticleProvider;)V # register +public net.minecraft.client.particle.ParticleResources$SpriteParticleRegistration public net.minecraft.client.player.LocalPlayer m_9242_()I # getPermissionLevel +private-f net.minecraft.client.renderer.LevelRenderer f_348825_ # weatherEffectRenderer public net.minecraft.client.renderer.LevelRenderer m_109817_()Z # shouldShowEntityOutlines #group public net.minecraft.client.renderer.RenderPipelines * public net.minecraft.client.renderer.RenderPipelines f_379621_ # GUI_TEXTURED_SNIPPET @@ -394,13 +465,12 @@ public net.minecraft.client.renderer.RenderPipelines f_399346_ # GLOBALS_SNIPPET public net.minecraft.client.renderer.RenderPipelines f_399373_ # ENTITY_EMISSIVE_SNIPPET public net.minecraft.client.renderer.RenderPipelines f_400011_ # MATRICES_FOG_LIGHT_DIR_SNIPPET public net.minecraft.client.renderer.RenderPipelines f_400219_ # MATRICES_FOG_SNIPPET +public net.minecraft.client.renderer.RenderPipelines f_412883_ # GUI_TEXT_SNIPPET #endgroup public net.minecraft.client.renderer.RenderStateShard f_110117_ # NO_LAYERING public net.minecraft.client.renderer.RenderStateShard f_110119_ # VIEW_OFFSET_Z_LAYERING public net.minecraft.client.renderer.RenderStateShard f_110123_ # MAIN_TARGET public net.minecraft.client.renderer.RenderStateShard f_110124_ # OUTLINE_TARGET -public net.minecraft.client.renderer.RenderStateShard f_110125_ # TRANSLUCENT_TARGET -public net.minecraft.client.renderer.RenderStateShard f_110126_ # PARTICLES_TARGET public net.minecraft.client.renderer.RenderStateShard f_110127_ # WEATHER_TARGET public net.minecraft.client.renderer.RenderStateShard f_110129_ # ITEM_ENTITY_TARGET public net.minecraft.client.renderer.RenderStateShard f_110130_ # DEFAULT_LINE @@ -458,7 +528,7 @@ public net.minecraft.client.renderer.block.model.ItemTransforms$Deserializer public net.minecraft.client.renderer.block.model.ItemTransforms$Deserializer ()V # constructor public net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher f_112253_ # fontRenderer - needed for rendering text in TESR items before entering world public net.minecraft.client.renderer.blockentity.BlockEntityRenderers m_173590_(Lnet/minecraft/world/level/block/entity/BlockEntityType;Lnet/minecraft/client/renderer/blockentity/BlockEntityRendererProvider;)V # register -private-f net.minecraft.client.renderer.blockentity.PistonHeadRenderer f_112441_ # blockRenderer - it's static so we need to un-finalize in case this class loads to early. +protected net.minecraft.client.renderer.blockentity.ChestRenderer m_420143_(Lnet/minecraft/world/level/block/entity/BlockEntity;Z)Lnet/minecraft/client/renderer/blockentity/state/ChestRenderState$ChestMaterialType; # getChestMaterial public net.minecraft.client.renderer.blockentity.SkullBlockRenderer f_112519_ # SKIN_BY_TYPE public net.minecraft.client.renderer.entity.EntityRenderDispatcher f_114362_ # renderers public net.minecraft.client.renderer.entity.EntityRenderers m_174036_(Lnet/minecraft/world/entity/EntityType;Lnet/minecraft/client/renderer/entity/EntityRendererProvider;)V # register @@ -469,7 +539,6 @@ public net.minecraft.client.renderer.texture.SpriteContents f_243731_ # byMipLev default net.minecraft.client.renderer.texture.SpriteContents f_244575_ # animatedTexture default net.minecraft.client.renderer.texture.SpriteContents m_245088_()I # getFrameCount public net.minecraft.client.resources.ClientPackSource m_246691_(Ljava/nio/file/Path;)Lnet/minecraft/server/packs/VanillaPackResources; # createVanillaPackSource -protected net.minecraft.client.resources.TextureAtlasHolder f_118884_ # textureAtlas public net.minecraft.client.resources.model.ModelDiscovery$ModelWrapper public net.minecraft.client.sounds.SoundEngine f_120217_ # soundManager public net.minecraft.commands.CommandSourceStack f_81288_ # source @@ -648,7 +717,7 @@ public net.minecraft.world.level.block.CakeBlock (Lnet/minecraft/world/lev public net.minecraft.world.level.block.CandleCakeBlock (Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.CartographyTableBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.CarvedPumpkinBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor -public net.minecraft.world.level.block.ChestBlock (Ljava/util/function/Supplier;Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.ChestBlock (Ljava/util/function/Supplier;Lnet/minecraft/sounds/SoundEvent;Lnet/minecraft/sounds/SoundEvent;Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.ChorusFlowerBlock (Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.ChorusPlantBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.CoralFanBlock (Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor @@ -668,7 +737,6 @@ public net.minecraft.world.level.block.EndPortalBlock (Lnet/minecraft/worl public net.minecraft.world.level.block.EndRodBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.EnderChestBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.FarmBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor -public net.minecraft.world.level.block.FletchingTableBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.FlowerBedBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.FungusBlock (Lnet/minecraft/resources/ResourceKey;Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.FurnaceBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor @@ -724,9 +792,13 @@ public net.minecraft.world.level.block.WallSkullBlock (Lnet/minecraft/worl public net.minecraft.world.level.block.WallTorchBlock (Lnet/minecraft/core/particles/SimpleParticleType;Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.WaterlilyBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.WaterloggedTransparentBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.WeatheringCopperBarsBlock (Lnet/minecraft/world/level/block/WeatheringCopper$WeatherState;Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.WeatheringCopperChainBlock (Lnet/minecraft/world/level/block/WeatheringCopper$WeatherState;Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.WeatheringCopperDoorBlock (Lnet/minecraft/world/level/block/state/properties/BlockSetType;Lnet/minecraft/world/level/block/WeatheringCopper$WeatherState;Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.WeatheringCopperGrateBlock (Lnet/minecraft/world/level/block/WeatheringCopper$WeatherState;Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.WeatheringCopperTrapDoorBlock (Lnet/minecraft/world/level/block/state/properties/BlockSetType;Lnet/minecraft/world/level/block/WeatheringCopper$WeatherState;Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.WeatheringLanternBlock (Lnet/minecraft/world/level/block/WeatheringCopper$WeatherState;Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.WeatheringLightningRodBlock (Lnet/minecraft/world/level/block/WeatheringCopper$WeatherState;Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.WeightedPressurePlateBlock (ILnet/minecraft/world/level/block/state/properties/BlockSetType;Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.WetSpongeBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.WitherSkullBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor @@ -758,8 +830,6 @@ protected net.minecraft.world.level.levelgen.Aquifer$NoiseBasedAquifer m_158027_ protected net.minecraft.world.level.levelgen.Aquifer$NoiseBasedAquifer m_158039_(I)I # gridX protected net.minecraft.world.level.levelgen.Aquifer$NoiseBasedAquifer m_158045_(I)I # gridY protected net.minecraft.world.level.levelgen.Aquifer$NoiseBasedAquifer m_158047_(I)I # gridZ -protected net.minecraft.world.level.levelgen.Beardifier f_158065_ # pieceIterator -protected net.minecraft.world.level.levelgen.Beardifier f_158066_ # junctionIterator protected net.minecraft.world.level.levelgen.Beardifier m_223925_(IIII)D # getBeardContribution private-f net.minecraft.world.level.levelgen.DebugLevelSource f_64114_ # ALL_BLOCKS private-f net.minecraft.world.level.levelgen.DebugLevelSource f_64115_ # GRID_WIDTH diff --git a/src/test/generated/closed_module/module-info.dat b/src/test/generated/closed_module/module-info.dat index 27639b2fc4ca4e39997a599ebac4b6ef7ef88114..123568ee3e961bcb053e8e30d1f607366b6367d0 100644 GIT binary patch delta 19 acmZ3@vYKTB7ZbYxgAjuVgV pig = event.getEntityRenderer(EntityType.PIG); pig.addLayer(new RenderLayer<>(pig) { @Override - public void render(PoseStack stack, MultiBufferSource source, int light, PigRenderState state, float xRot, float yRot) { + public void submit(PoseStack stack, SubmitNodeCollector source, int light, PigRenderState state, float xRot, float yRot) { var part = this.getParentModel().root().createPartLookup().apply("head"); if (part != null) { var manager = Minecraft.getInstance().getModelManager(); @@ -152,11 +149,9 @@ public class AdditionalModelTest extends BaseTestMod { LivingEntityRenderer cow = event.getEntityRenderer(EntityType.COW); cow.addLayer(new RenderLayer<>(cow) { @Override - public void render(PoseStack stack, MultiBufferSource source, int light, LivingEntityRenderState state, float xRot, float yRot) { + public void submit(PoseStack stack, SubmitNodeCollector source, int light, LivingEntityRenderState cowState, float xRot, float yRot) { var part = this.getParentModel().root().createPartLookup().apply("head"); if (part != null) { - var manager = Minecraft.getInstance().getModelManager(); - stack.pushPose(); this.getParentModel().root().translateAndRotate(stack); @@ -165,10 +160,9 @@ public class AdditionalModelTest extends BaseTestMod { stack.translate(-0.5, -0.5, -0.5); stack.translate(0, -1, -0.5); - var model = manager.getBlockModelShaper().getBlockModel(COW_HEAD_STATE.any()); - - var consumer = source.getBuffer(RenderType.solid()); - ModelBlockRenderer.renderModel(stack.last(), consumer, model, 1.0F, 1.0F, 1.0F, light, OverlayTexture.NO_OVERLAY, ModelData.EMPTY, null); + var state = new MovingBlockRenderState(); + state.blockState = COW_HEAD_STATE.any(); + source.submitMovingBlock(stack, state); stack.popPose(); } } diff --git a/src/test/java/net/minecraftforge/debug/client/ModelRenderLayerTest.java b/src/test/java/net/minecraftforge/debug/client/ModelRenderLayerTest.java index ecf5b8ba4e..de16223782 100644 --- a/src/test/java/net/minecraftforge/debug/client/ModelRenderLayerTest.java +++ b/src/test/java/net/minecraftforge/debug/client/ModelRenderLayerTest.java @@ -63,7 +63,7 @@ public class ModelRenderLayerTest extends BaseTestMod { BlockBehaviour.Properties.of() .setId(BLOCKS.key(BLOCK_NAME)) .mapColor(MapColor.PLANT) - .noCollission() + .noCollision() .randomTicks() .instabreak() .sound(SoundType.GRASS) diff --git a/src/test/java/net/minecraftforge/debug/client/ModifyOverlayTest.java b/src/test/java/net/minecraftforge/debug/client/ModifyOverlayTest.java index a6651fb073..2dfac51b7e 100644 --- a/src/test/java/net/minecraftforge/debug/client/ModifyOverlayTest.java +++ b/src/test/java/net/minecraftforge/debug/client/ModifyOverlayTest.java @@ -50,7 +50,7 @@ public class ModifyOverlayTest extends BaseTestMod { public ModifyOverlayTest(FMLJavaModLoadingContext context) { super(context, false, false); - AddGuiOverlayLayersEvent.getBus(context.getModBusGroup()).addListener(this::overlayTestListener); + AddGuiOverlayLayersEvent.BUS.addListener(this::overlayTestListener); } @GameTest diff --git a/src/test/java/net/minecraftforge/debug/client/RenderFrameLayerTest.java b/src/test/java/net/minecraftforge/debug/client/RenderFrameLayerTest.java index 5ad401bde8..b0dd493481 100644 --- a/src/test/java/net/minecraftforge/debug/client/RenderFrameLayerTest.java +++ b/src/test/java/net/minecraftforge/debug/client/RenderFrameLayerTest.java @@ -4,7 +4,7 @@ */ package net.minecraftforge.debug.client; - + import net.minecraft.client.renderer.LevelTargetBundle; import net.minecraftforge.client.FramePassManager; import net.minecraftforge.client.event.AddFramePassEvent; @@ -64,7 +64,7 @@ public class RenderFrameLayerTest extends BaseTestMod { var buffSource = Minecraft.getInstance().renderBuffers().bufferSource(); var vc = buffSource.getBuffer(RenderType.lines()); - ShapeRenderer.renderLineBox(ps, vc, 0, -60, 0, 10, -50, 10, 1f, 1f, 1f, 1f); + ShapeRenderer.renderLineBox(ps.last(), vc, 0, -60, 0, 10, -50, 10, 1f, 1f, 1f, 1f); buffSource.endBatch(); ps.popPose(); } @@ -85,7 +85,7 @@ public class RenderFrameLayerTest extends BaseTestMod { var buffSource = Minecraft.getInstance().renderBuffers().bufferSource(); var vc = buffSource.getBuffer(RenderType.lines()); - ShapeRenderer.renderLineBox(ps, vc, 1, -61, 1, 9, -49, 9, 1f, 1f, 1f, 1f); + ShapeRenderer.renderLineBox(ps.last(), vc, 1, -61, 1, 9, -49, 9, 1f, 1f, 1f, 1f); buffSource.endBatch(); ps.popPose(); } diff --git a/src/test/java/net/minecraftforge/debug/gameplay/criterion/CriterionTest.java b/src/test/java/net/minecraftforge/debug/gameplay/criterion/CriterionTest.java index 79031a38f1..96cedf1a8a 100644 --- a/src/test/java/net/minecraftforge/debug/gameplay/criterion/CriterionTest.java +++ b/src/test/java/net/minecraftforge/debug/gameplay/criterion/CriterionTest.java @@ -25,6 +25,7 @@ import net.minecraft.tags.TagKey; import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; +import net.minecraft.world.level.GameType; import net.minecraft.world.level.block.Blocks; import net.minecraftforge.common.Tags; import net.minecraftforge.common.data.ForgeAdvancementProvider; diff --git a/src/test/java/net/minecraftforge/debug/gameplay/item/PreventItemDamageTest.java b/src/test/java/net/minecraftforge/debug/gameplay/item/PreventItemDamageTest.java index 8c491c7d16..4d43654182 100644 --- a/src/test/java/net/minecraftforge/debug/gameplay/item/PreventItemDamageTest.java +++ b/src/test/java/net/minecraftforge/debug/gameplay/item/PreventItemDamageTest.java @@ -76,7 +76,7 @@ public class PreventItemDamageTest extends BaseTestMod { firedLivingEntityUseItem.set(true); event.setDuration(event.getDuration() - 100); }); - helper.addEventListener(PlayerDestroyItemEvent.BUS, event -> { + helper.addRecordListener(PlayerDestroyItemEvent.BUS, event -> { if (event.getEntity() != player) return; helper.assertTrue(event.getOriginal() == shield, () -> "Player destroyed an item, but it's not the fake shield! Check the game test impl."); @@ -117,7 +117,7 @@ public class PreventItemDamageTest extends BaseTestMod { helper.makeFloor(); // setup player - var player = helper.makeMockServerPlayer(); + var player = helper.makeMockServerPlayer(GameType.SURVIVAL); // setup shield var shield = FAKE_SHIELD.get().getDefaultInstance(); diff --git a/src/test/java/net/minecraftforge/debug/gameplay/loot/ConditionalLootPools.java b/src/test/java/net/minecraftforge/debug/gameplay/loot/ConditionalLootPools.java index 2d728d2835..160e3a5529 100644 --- a/src/test/java/net/minecraftforge/debug/gameplay/loot/ConditionalLootPools.java +++ b/src/test/java/net/minecraftforge/debug/gameplay/loot/ConditionalLootPools.java @@ -14,6 +14,7 @@ import net.minecraft.gametest.framework.GameTestHelper; import net.minecraft.network.chat.Component; import net.minecraft.world.flag.FeatureFlags; import net.minecraft.world.item.Items; +import net.minecraft.world.level.GameType; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.BlockBehaviour; import net.minecraft.world.level.storage.loot.LootPool; @@ -59,7 +60,7 @@ public class ConditionalLootPools extends BaseTestMod { helper.setBlock(center, TEST_BLOCK.get()); helper.assertBlock(center, block -> block == TEST_BLOCK.get(), block -> Component.literal("Failed to set block, was " + block.getDescriptionId())); - var player = helper.makeMockServerPlayer(); + var player = helper.makeMockServerPlayer(GameType.SURVIVAL); player.gameMode.destroyBlock(helper.absolutePos(center)); helper.assertItemEntityPresent(Items.GOLDEN_APPLE, center, 1.0); diff --git a/src/test/java/net/minecraftforge/debug/gameplay/loot/GlobalLootModifiersTest.java b/src/test/java/net/minecraftforge/debug/gameplay/loot/GlobalLootModifiersTest.java index 104665d295..c9e09d2960 100644 --- a/src/test/java/net/minecraftforge/debug/gameplay/loot/GlobalLootModifiersTest.java +++ b/src/test/java/net/minecraftforge/debug/gameplay/loot/GlobalLootModifiersTest.java @@ -22,6 +22,7 @@ import net.minecraft.core.component.predicates.DataComponentPredicates; import net.minecraft.core.component.predicates.EnchantmentsPredicate; import net.minecraft.core.registries.Registries; import net.minecraft.util.ExtraCodecs; +import net.minecraft.world.level.GameType; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.BlockBehaviour; @@ -138,7 +139,7 @@ public class GlobalLootModifiersTest extends BaseTestMod { // Tests the Enchantment condition, as well as the ability to completely override the returned values. @GameTest public static void smellting(GameTestHelper helper) { - var player = helper.makeMockServerPlayer(); + var player = helper.makeMockServerPlayer(GameType.SURVIVAL); var center = new BlockPos(1, 1, 1); var enchants = helper.getLevel().holderLookup(Registries.ENCHANTMENT); var smelt = getSmelterAxe(enchants, true); @@ -166,7 +167,7 @@ public class GlobalLootModifiersTest extends BaseTestMod { @GameTest public static void condition_table_name(GameTestHelper helper) { var center = new BlockPos(1, 1, 1); - var player = helper.makeMockServerPlayer(); + var player = helper.makeMockServerPlayer(GameType.SURVIVAL); // Should be doubled helper.setBlock(center, TEST_BLOCK.get()); @@ -185,7 +186,7 @@ public class GlobalLootModifiersTest extends BaseTestMod { @GameTest public static void silk_reentrant(GameTestHelper helper) { var center = new BlockPos(1, 1, 1); - var player = helper.makeMockServerPlayer(); + var player = helper.makeMockServerPlayer(GameType.SURVIVAL); var bamboo = new ItemStack(Items.BAMBOO); var normal = new ItemStack(Items.IRON_AXE); diff --git a/src/test/java/net/minecraftforge/debug/gameplay/loot/LootEventsTest.java b/src/test/java/net/minecraftforge/debug/gameplay/loot/LootEventsTest.java index 4024814ac5..c0d589ea50 100644 --- a/src/test/java/net/minecraftforge/debug/gameplay/loot/LootEventsTest.java +++ b/src/test/java/net/minecraftforge/debug/gameplay/loot/LootEventsTest.java @@ -21,6 +21,7 @@ import net.minecraft.gametest.framework.GameTestHelper; import net.minecraft.network.chat.Component; import net.minecraft.world.flag.FeatureFlags; import net.minecraft.world.item.Items; +import net.minecraft.world.level.GameType; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.BlockBehaviour; import net.minecraft.world.level.storage.loot.LootPool; @@ -68,7 +69,7 @@ public class LootEventsTest extends BaseTestMod { helper.setBlock(center, TEST_BLOCK.get()); helper.assertBlock(center, block -> block == TEST_BLOCK.get(), block -> Component.literal("Failed to set block, was " + block.getDescriptionId())); - var player = helper.makeMockServerPlayer(); + var player = helper.makeMockServerPlayer(GameType.SURVIVAL); player.gameMode.destroyBlock(helper.absolutePos(center)); helper.assertItemEntityPresent(Items.GOLDEN_APPLE, center, 1.0); diff --git a/src/test/java/net/minecraftforge/debug/gameplay/loot/ShearsLootTests.java b/src/test/java/net/minecraftforge/debug/gameplay/loot/ShearsLootTests.java index a4a2292147..8a163dac86 100644 --- a/src/test/java/net/minecraftforge/debug/gameplay/loot/ShearsLootTests.java +++ b/src/test/java/net/minecraftforge/debug/gameplay/loot/ShearsLootTests.java @@ -15,6 +15,7 @@ import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.item.ShearsItem; +import net.minecraft.world.level.GameType; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.DoublePlantBlock; @@ -85,7 +86,7 @@ public class ShearsLootTests extends BaseTestMod { }; helper.makeFloor(); // Seagrass makes water - var player = helper.makeMockServerPlayer(false); // Plants prevent loot for creative players + var player = helper.makeMockServerPlayer(GameType.SURVIVAL); // Plants prevent loot for creative players var center = new BlockPos(1, 1, 1); player.setItemSlot(EquipmentSlot.MAINHAND, new ItemStack(MODDED_SHEARS.get())); diff --git a/src/test/java/net/minecraftforge/mdk/Datagen.java b/src/test/java/net/minecraftforge/mdk/Datagen.java index 82772ae53f..8977c8f9b7 100644 --- a/src/test/java/net/minecraftforge/mdk/Datagen.java +++ b/src/test/java/net/minecraftforge/mdk/Datagen.java @@ -14,8 +14,6 @@ import net.minecraftforge.data.event.GatherDataEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; -import java.util.Optional; - @Mod(Datagen.MOD_ID) public class Datagen { static final String MOD_ID = "mdk_datagen"; @@ -28,10 +26,9 @@ public class Datagen { var gen = event.getGenerator(); var packOutput = gen.getPackOutput(); gen.addProvider(true, new PackMetadataGenerator(packOutput) - .add(PackMetadataSection.TYPE, new PackMetadataSection( + .add(PackMetadataSection.SERVER_TYPE, new PackMetadataSection( Component.literal("${mod_id} resources"), - DetectedVersion.BUILT_IN.packVersion(PackType.CLIENT_RESOURCES), - Optional.empty() + DetectedVersion.BUILT_IN.packVersion(PackType.SERVER_DATA).minorRange() )) ); } diff --git a/src/test/java/net/minecraftforge/test/ModuleProvider.java b/src/test/java/net/minecraftforge/test/ModuleProvider.java index 137f13afc9..8c4341bb66 100644 --- a/src/test/java/net/minecraftforge/test/ModuleProvider.java +++ b/src/test/java/net/minecraftforge/test/ModuleProvider.java @@ -69,24 +69,24 @@ public class ModuleProvider implements DataProvider { desc.mainClass().ifPresent(module::visitMainClass); - for (var pkg : sorted(desc.packages(), Function.identity())) + for (var pkg : sorted(desc.packages())) module.visitPackage(binary(pkg)); for (var req : sorted(desc.requires(), Requires::name)) module.visitRequire(req.name(), flags(req.accessFlags()), version(req.compiledVersion(), req.rawCompiledVersion())); for (var exp : sorted(desc.exports(), Exports::source)) - module.visitExport(binary(exp.source()), flags(exp.accessFlags()), array(exp.targets())); + module.visitExport(binary(exp.source()), flags(exp.accessFlags()), array(sorted(exp.targets()))); for (var open : sorted(desc.opens(), Opens::source)) - module.visitOpen(binary(open.source()), flags(open.accessFlags()), array(open.targets())); + module.visitOpen(binary(open.source()), flags(open.accessFlags()), array(sorted(open.targets()))); - for (var uses : sorted(desc.uses(), Function.identity())) + for (var uses : sorted(desc.uses())) module.visitUse(binary(uses)); for (var provide : sorted(desc.provides(), Provides::service)) { var providers = new ArrayList(); - for (var provider : provide.providers()) + for (var provider : sorted(provide.providers())) providers.add(binary(provider)); module.visitProvide(provide.service(), array(providers)); @@ -119,6 +119,10 @@ public class ModuleProvider implements DataProvider { return version; } + private static List sorted(Collection data) { + return sorted(data, Function.identity()); + } + private static List sorted(Collection data, Function toString) { var ret = new ArrayList(); ret.addAll(data); diff --git a/src/test/java/net/minecraftforge/test/TestHelperMod.java b/src/test/java/net/minecraftforge/test/TestHelperMod.java index ec848a9b8e..50ee45330c 100644 --- a/src/test/java/net/minecraftforge/test/TestHelperMod.java +++ b/src/test/java/net/minecraftforge/test/TestHelperMod.java @@ -5,10 +5,7 @@ package net.minecraftforge.test; -import java.util.Optional; - import net.minecraft.DetectedVersion; -import net.minecraft.SharedConstants; import net.minecraft.core.registries.Registries; import net.minecraft.data.metadata.PackMetadataGenerator; import net.minecraft.network.chat.Component; @@ -52,11 +49,9 @@ public class TestHelperMod extends BaseTestMod { var packOutput = gen.getPackOutput(); gen.addProvider(true, new PackMetadataGenerator(packOutput) - .add(PackMetadataSection.TYPE, new PackMetadataSection( + .add(PackMetadataSection.SERVER_TYPE, new PackMetadataSection( Component.literal("Forge tests resource pack"), - SharedConstants.getCurrentVersion().packVersion(PackType.CLIENT_RESOURCES), - Optional.empty() - //Arrays.stream(PackType.values()).collect(Collectors.toMap(Function.identity(), DetectedVersion.BUILT_IN::getPackVersion)) + DetectedVersion.BUILT_IN.packVersion(PackType.SERVER_DATA).minorRange() )) ); }