From 01bfc33b28f663b7580ee8eda31585132615a8ed Mon Sep 17 00:00:00 2001 From: LexManos Date: Tue, 9 Dec 2025 18:18:19 -0800 Subject: [PATCH] 1.21.11 Mounts of Mayhem Release Lots of rendering related changes, specifically for BackedQuad and IQuadTransformers. Removed our deprecated model generators, modders should have been using vanilla's for a while. --- .github/workflows/publish.yml | 2 +- .../fml/util/thread/EffectiveSide.java | 7 +- .../fml/util/thread/SidedThreadGroups.java | 8 +- .../coremods/finalize_spawn_targets.json | 70 +- gradle.properties | 6 +- .../opengl/GlCommandEncoder.java.patch | 2 +- .../mojang/blaze3d/opengl/GlDebug.java.patch | 8 +- .../mojang/blaze3d/opengl/GlDevice.java.patch | 18 +- .../blaze3d/opengl/GlStateManager.java.patch | 2 +- .../blaze3d/opengl/GlTexture.java.patch | 22 +- .../blaze3d/pipeline/RenderTarget.java.patch | 12 +- .../blaze3d/systems/GpuDevice.java.patch | 8 +- .../blaze3d/textures/GpuTexture.java.patch | 2 +- .../blaze3d/vertex/VertexConsumer.java.patch | 16 +- .../blaze3d/vertex/VertexFormat.java.patch | 12 +- .../com/mojang/math/Transformation.java.patch | 14 +- .../RealmsGenericErrorScreen.java.patch | 4 +- .../screens/RealmsResetWorldScreen.java.patch | 11 + .../net/minecraft/SharedConstants.java.patch | 2 +- .../advancements/Advancement.java.patch | 8 +- .../AdvancementRewards.java.patch | 2 +- .../net/minecraft/client/Camera.java.patch | 8 +- .../minecraft/client/KeyMapping.java.patch | 43 +- .../client/KeyboardHandler.java.patch | 11 +- .../net/minecraft/client/Minecraft.java.patch | 195 +-- .../minecraft/client/MouseHandler.java.patch | 22 +- .../net/minecraft/client/Options.java.patch | 34 +- .../minecraft/client/Screenshot.java.patch | 10 +- .../net/minecraft/client/data/Main.java.patch | 2 +- .../models/ItemModelGenerators.java.patch | 2 +- .../data/models/ModelProvider.java.patch | 26 +- .../net/minecraft/client/gui/Font.java.patch | 4 +- .../net/minecraft/client/gui/Gui.java.patch | 26 +- .../client/gui/GuiGraphics.java.patch | 61 +- .../gui/components/AbstractButton.java.patch | 11 - .../gui/components/AbstractWidget.java.patch | 6 +- .../client/gui/components/Button.java.patch | 17 +- .../components/toasts/ToastManager.java.patch | 2 +- .../client/gui/render/GuiRenderer.java.patch | 2 +- .../gui/screens/ConnectScreen.java.patch | 2 +- .../gui/screens/LoadingOverlay.java.patch | 12 +- .../client/gui/screens/PauseScreen.java.patch | 2 +- .../client/gui/screens/Screen.java.patch | 10 +- .../client/gui/screens/TitleScreen.java.patch | 10 +- .../advancements/AdvancementTab.java.patch | 6 +- .../AdvancementsScreen.java.patch | 16 +- .../AbstractContainerScreen.java.patch | 26 +- .../CreativeModeInventoryScreen.java.patch | 62 +- .../inventory/EffectsInInventory.java.patch | 44 +- .../inventory/EnchantmentScreen.java.patch | 8 +- .../HangingSignEditScreen.java.patch | 4 +- .../inventory/MerchantScreen.java.patch | 2 +- .../ServerSelectionList.java.patch | 2 +- .../options/controls/KeyBindsList.java.patch | 6 +- .../controls/KeyBindsScreen.java.patch | 6 +- .../TransferableSelectionList.java.patch | 2 +- .../CreateWorldScreen.java.patch | 6 +- .../WorldCreationUiState.java.patch | 6 +- .../worldselection/WorldOpenFlows.java.patch | 2 +- .../WorldSelectionList.java.patch | 12 +- .../client/model/HumanoidModel.java.patch | 43 +- .../model/geom/LayerDefinitions.java.patch | 4 +- .../client/model/geom/ModelLayers.java.patch | 14 +- .../multiplayer/ClientChunkCache.java.patch | 2 +- .../ClientCommonPacketListenerImpl.java.patch | 2 +- ...ConfigurationPacketListenerImpl.java.patch | 2 +- ...ientHandshakePacketListenerImpl.java.patch | 4 +- .../client/multiplayer/ClientLevel.java.patch | 34 +- .../ClientPacketListener.java.patch | 18 +- .../client/multiplayer/PlayerInfo.java.patch | 2 +- .../client/multiplayer/ServerData.java.patch | 2 +- .../multiplayer/ServerStatusPinger.java.patch | 9 + .../multiplayer/SessionSearchTrees.java.patch | 2 +- .../client/particle/ParticleEngine.java.patch | 8 +- .../particle/ParticleResources.java.patch | 12 +- .../particle/TerrainParticle.java.patch | 4 +- .../player/AbstractClientPlayer.java.patch | 2 +- .../client/player/LocalPlayer.java.patch | 18 +- .../DimensionSpecialEffects.java.patch | 11 - .../client/renderer/GameRenderer.java.patch | 14 +- .../renderer/ItemBlockRenderTypes.java.patch | 36 +- .../renderer/ItemInHandRenderer.java.patch | 20 +- .../client/renderer/LevelRenderer.java.patch | 28 +- .../client/renderer/LightTexture.java.patch | 2 +- .../client/renderer/RenderType.java.patch | 56 - .../renderer/ScreenEffectRenderer.java.patch | 21 +- .../client/renderer/Sheets.java.patch | 8 +- .../SpriteCoordinateExpander.java.patch | 5 +- .../block/BlockRenderDispatcher.java.patch | 8 +- .../block/LiquidBlockRenderer.java.patch | 125 +- .../block/ModelBlockRenderer.java.patch | 6 +- .../renderer/block/model/BakedQuad.java.patch | 26 +- .../block/model/BlockElementFace.java.patch | 8 +- .../block/model/BlockModel.java.patch | 26 +- .../block/model/BlockModelPart.java.patch | 2 +- .../block/model/FaceBakery.java.patch | 22 +- .../block/model/SimpleModelWrapper.java.patch | 28 +- .../model/multipart/MultiPartModel.java.patch | 17 +- .../blockentity/SkullBlockRenderer.java.patch | 6 +- .../chunk/RenderSectionRegion.java.patch | 2 +- .../EntityHitboxDebugRenderer.java.patch | 13 + .../entity/EnderDragonRenderer.java.patch | 19 - .../entity/EntityRenderDispatcher.java.patch | 4 +- .../renderer/entity/EntityRenderer.java.patch | 12 +- .../entity/HumanoidMobRenderer.java.patch | 2 +- .../renderer/entity/ItemRenderer.java.patch | 11 - .../entity/LivingEntityRenderer.java.patch | 16 +- .../entity/layers/WingsLayer.java.patch | 8 +- .../entity/player/AvatarRenderer.java.patch | 32 +- .../renderer/fog/FogRenderer.java.patch | 4 +- .../rendertype/RenderSetup.java.patch | 67 + .../rendertype/RenderTypes.java.patch | 44 + .../state/BlockOutlineRenderState.java.patch | 2 +- .../texture/AbstractTexture.java.patch | 31 - .../texture/MipmapGenerator.java.patch | 12 +- .../texture/SpriteContents.java.patch | 32 +- .../renderer/texture/SpriteLoader.java.patch | 32 +- .../renderer/texture/Stitcher.java.patch | 6 +- .../renderer/texture/TextureAtlas.java.patch | 12 +- .../texture/TextureAtlasSprite.java.patch | 6 +- .../atlas/SpriteResourceLoader.java.patch | 6 +- .../client/resources/language/I18n.java.patch | 2 +- .../model/BlockStateDefinitions.java.patch | 6 +- .../resources/model/ModelBaker.java.patch | 2 +- .../resources/model/ModelDiscovery.java.patch | 8 +- .../resources/model/ModelManager.java.patch | 36 +- .../resources/model/ResolvedModel.java.patch | 4 +- .../resources/model/UnbakedModel.java.patch | 2 +- .../resources/sounds/SoundInstance.java.patch | 2 +- .../client/server/IntegratedServer.java.patch | 4 +- .../server/LanServerDetection.java.patch | 2 +- .../client/server/LanServerPinger.java.patch | 4 +- .../client/sounds/SoundEngine.java.patch | 10 +- .../commands/CommandSourceStack.java.patch | 8 +- .../minecraft/commands/Commands.java.patch | 8 +- .../SharedSuggestionProvider.java.patch | 11 - .../arguments/EntityArgument.java.patch | 10 +- .../arguments/MessageArgument.java.patch | 4 +- .../selector/EntitySelector.java.patch | 4 +- .../selector/EntitySelectorParser.java.patch | 4 +- .../net/minecraft/core/BlockPos.java.patch | 6 +- .../core/DefaultedMappedRegistry.java.patch | 6 +- .../net/minecraft/core/Holder.java.patch | 4 +- .../net/minecraft/core/HolderSet.java.patch | 8 +- .../minecraft/core/MappedRegistry.java.patch | 28 +- .../net/minecraft/core/Registry.java.patch | 2 +- .../core/RegistrySetBuilder.java.patch | 10 +- .../dispenser/DispenseItemBehavior.java.patch | 4 +- .../registries/BuiltInRegistries.java.patch | 20 +- .../core/registries/Registries.java.patch | 14 +- .../net/minecraft/data/HashCache.java.patch | 12 +- .../net/minecraft/data/Main.java.patch | 2 +- .../AdvancementProvider.java.patch | 2 +- .../data/loot/LootTableProvider.java.patch | 12 +- .../data/recipes/RecipeOutput.java.patch | 4 +- .../data/recipes/RecipeProvider.java.patch | 14 +- .../RegistriesDatapackGenerator.java.patch | 6 +- .../registries/VanillaRegistries.java.patch | 8 +- .../PaintingVariantTagsProvider.java.patch | 2 +- .../data/tags/TagAppender.java.patch | 4 +- .../data/tags/TagsProvider.java.patch | 30 +- .../VanillaEnchantmentTagsProvider.java.patch | 2 +- .../tags/VanillaItemTagsProvider.java.patch | 2 +- .../framework/GameTestHelper.java.patch | 8 +- .../framework/GameTestMainUtil.java.patch | 2 +- .../framework/GameTestServer.java.patch | 6 +- .../minecraft/network/Connection.java.patch | 42 +- .../network/FriendlyByteBuf.java.patch | 2 +- .../contents/TranslatableContents.java.patch | 2 +- .../ClientboundCustomPayloadPacket.java.patch | 8 +- .../ServerboundCustomPayloadPacket.java.patch | 4 +- .../custom/CustomPacketPayload.java.patch | 8 +- .../custom/DiscardedQueryPayload.java.patch | 8 +- .../syncher/EntityDataSerializers.java.patch | 7 +- .../resources/DelegatingOps.java.patch | 6 +- .../minecraft/resources/Identifier.java.patch | 13 + .../resources/RegistryDataLoader.java.patch | 26 +- .../resources/ResourceKey.java.patch | 10 +- .../resources/ResourceLocation.java.patch | 15 - .../net/minecraft/server/Main.java.patch | 14 +- .../server/MinecraftServer.java.patch | 48 +- .../server/PlayerAdvancements.java.patch | 10 +- .../ReloadableServerResources.java.patch | 14 +- .../dedicated/DedicatedServer.java.patch | 27 +- .../server/level/ChunkMap.java.patch | 14 +- .../server/level/DistanceManager.java.patch | 2 +- .../level/GenerationChunkHolder.java.patch | 4 +- .../server/level/ServerChunkCache.java.patch | 4 +- .../server/level/ServerLevel.java.patch | 64 +- .../server/level/ServerPlayer.java.patch | 84 +- .../level/ServerPlayerGameMode.java.patch | 20 +- .../server/level/WorldGenRegion.java.patch | 2 +- .../network/EventLoopGroupHolder.java.patch | 50 + ...ConfigurationPacketListenerImpl.java.patch | 15 +- .../ServerConnectionListener.java.patch | 21 +- .../ServerGamePacketListenerImpl.java.patch | 14 +- .../ServerLoginPacketListenerImpl.java.patch | 6 +- .../config/PrepareSpawnTask.java.patch | 2 +- .../packs/AbstractPackResources.java.patch | 2 +- .../server/packs/PackResources.java.patch | 2 +- .../server/packs/repository/Pack.java.patch | 14 +- .../packs/repository/PackDetector.java.patch | 8 +- .../repository/PackRepository.java.patch | 6 +- .../repository/ServerPacksSource.java.patch | 2 +- .../FallbackResourceManager.java.patch | 6 +- ...impleJsonResourceReloadListener.java.patch | 10 +- .../server/players/PlayerList.java.patch | 48 +- .../server/rcon/RconConsoleSource.java.patch | 2 +- .../tags/BannerPatternTags.java.patch | 6 +- .../net/minecraft/tags/BiomeTags.java.patch | 8 +- .../net/minecraft/tags/BlockTags.java.patch | 8 +- .../minecraft/tags/DamageTypeTags.java.patch | 6 +- .../minecraft/tags/EnchantmentTags.java.patch | 6 +- .../minecraft/tags/EntityTypeTags.java.patch | 8 +- .../FlatLevelGeneratorPresetTags.java.patch | 6 +- .../net/minecraft/tags/FluidTags.java.patch | 6 +- .../minecraft/tags/GameEventTags.java.patch | 6 +- .../minecraft/tags/InstrumentTags.java.patch | 6 +- .../net/minecraft/tags/ItemTags.java.patch | 8 +- .../tags/PaintingVariantTags.java.patch | 6 +- .../net/minecraft/tags/PoiTypeTags.java.patch | 6 +- .../minecraft/tags/StructureTags.java.patch | 6 +- .../net/minecraft/tags/TagBuilder.java.patch | 35 +- .../net/minecraft/tags/TagEntry.java.patch | 6 +- .../net/minecraft/tags/TagKey.java.patch | 4 +- .../net/minecraft/tags/TagLoader.java.patch | 12 +- .../minecraft/tags/WorldPresetTags.java.patch | 6 +- .../net/minecraft/{ => util}/Util.java.patch | 12 +- .../util/context/ContextMap.java.patch | 4 +- .../StructuresBecomeConfiguredFix.java.patch | 2 +- .../util/random/WeightedList.java.patch | 4 +- .../world/effect/MobEffect.java.patch | 6 +- .../minecraft/world/entity/Entity.java.patch | 78 +- .../world/entity/EntityType.java.patch | 22 +- .../world/entity/ExperienceOrb.java.patch | 4 +- .../world/entity/Leashable.java.patch | 2 +- .../world/entity/LightningBolt.java.patch | 8 +- .../world/entity/LivingEntity.java.patch | 178 +-- .../net/minecraft/world/entity/Mob.java.patch | 30 +- .../world/entity/SpawnPlacements.java.patch | 2 +- .../world/entity/TamableAnimal.java.patch | 4 +- .../world/entity/ai/Brain.java.patch | 23 +- .../attributes/AttributeSupplier.java.patch | 4 +- .../attributes/DefaultAttributes.java.patch | 2 +- .../ai/behavior/HarvestFarmland.java.patch | 14 +- .../entity/ai/goal/BreakDoorGoal.java.patch | 2 +- .../entity/ai/goal/EatBlockGoal.java.patch | 4 +- .../entity/ai/goal/RemoveBlockGoal.java.patch | 4 +- .../goal/target/HurtByTargetGoal.java.patch | 2 +- .../ai/navigation/PathNavigation.java.patch | 2 +- .../WallClimberNavigation.java.patch | 2 +- .../world/entity/animal/Animal.java.patch | 2 +- .../world/entity/animal/Pig.java.patch | 18 - .../entity/animal/allay/Allay.java.patch | 4 +- .../entity/animal/{ => bee}/Bee.java.patch | 12 +- .../entity/animal/camel/Camel.java.patch | 2 +- .../animal/{ => cow}/MushroomCow.java.patch | 34 +- .../AbstractHorse.java.patch | 42 +- .../entity/animal/equine/Llama.java.patch | 13 + .../SkeletonTrapGoal.java.patch | 4 +- .../entity/animal/{ => feline}/Cat.java.patch | 14 +- .../animal/{ => feline}/Ocelot.java.patch | 10 +- .../entity/animal/{ => fox}/Fox.java.patch | 16 +- .../CopperGolem.java.patch | 12 +- .../animal/{ => golem}/SnowGolem.java.patch | 19 +- .../entity/animal/horse/Llama.java.patch | 13 - .../animal/{ => parrot}/Parrot.java.patch | 10 +- .../world/entity/animal/pig/Pig.java.patch | 15 + .../animal/{ => rabbit}/Rabbit.java.patch | 12 +- .../world/entity/animal/wolf/Wolf.java.patch | 2 +- .../entity/boss/EnderDragonPart.java.patch | 18 - .../boss/enderdragon/EnderDragon.java.patch | 22 +- .../enderdragon/EnderDragonPart.java.patch | 18 + .../entity/boss/wither/WitherBoss.java.patch | 2 +- .../decoration/HangingEntity.java.patch | 6 +- .../entity/item/FallingBlockEntity.java.patch | 4 +- .../world/entity/item/ItemEntity.java.patch | 26 +- .../monster/CrossbowAttackMob.java.patch | 2 +- .../world/entity/monster/EnderMan.java.patch | 24 +- .../world/entity/monster/Husk.java.patch | 10 - .../world/entity/monster/MagmaCube.java.patch | 4 +- .../world/entity/monster/Monster.java.patch | 2 +- .../world/entity/monster/Ravager.java.patch | 4 +- .../world/entity/monster/Shulker.java.patch | 2 +- .../entity/monster/Silverfish.java.patch | 8 +- .../world/entity/monster/Slime.java.patch | 4 +- .../world/entity/monster/Spider.java.patch | 14 - .../monster/creaking/Creaking.java.patch | 6 +- .../entity/monster/hoglin/Hoglin.java.patch | 4 +- .../monster/{ => illager}/Evoker.java.patch | 6 +- .../{ => illager}/Illusioner.java.patch | 16 +- .../monster/{ => illager}/Pillager.java.patch | 6 +- .../monster/piglin/AbstractPiglin.java.patch | 12 +- .../entity/monster/piglin/Piglin.java.patch | 8 +- .../entity/monster/piglin/PiglinAi.java.patch | 6 +- .../AbstractSkeleton.java.patch | 18 +- .../monster/{ => skeleton}/Bogged.java.patch | 14 +- .../{ => skeleton}/Skeleton.java.patch | 6 +- .../entity/monster/spider/Spider.java.patch | 14 + .../entity/monster/zombie/Husk.java.patch | 10 + .../monster/{ => zombie}/Zombie.java.patch | 52 +- .../{ => zombie}/ZombieVillager.java.patch | 12 +- .../entity/npc/AbstractVillager.java.patch | 11 - .../world/entity/npc/Villager.java.patch | 20 - .../npc/villager/AbstractVillager.java.patch | 11 + .../entity/npc/villager/Villager.java.patch | 20 + .../{ => villager}/VillagerTrades.java.patch | 18 +- .../{ => villager}/VillagerType.java.patch | 8 +- .../world/entity/player/Player.java.patch | 154 +-- .../projectile/AbstractArrow.java.patch | 28 - .../FireworkRocketEntity.java.patch | 2 +- .../entity/projectile/FishingHook.java.patch | 10 +- .../entity/projectile/Projectile.java.patch | 4 +- .../projectile/ProjectileUtil.java.patch | 4 +- .../projectile/ShulkerBullet.java.patch | 2 +- .../entity/projectile/WitherSkull.java.patch | 11 - .../projectile/arrow/AbstractArrow.java.patch | 28 + .../AbstractHurtingProjectile.java.patch | 6 +- .../LargeFireball.java.patch | 10 +- .../SmallFireball.java.patch | 10 +- .../hurtingprojectile/WitherSkull.java.patch | 11 + .../ThrownEnderpearl.java.patch | 10 +- .../world/entity/raid/Raid.java.patch | 4 +- .../entity/vehicle/ContainerEntity.java.patch | 4 +- .../vehicle/MinecartCommandBlock.java.patch | 11 - .../entity/vehicle/MinecartSpawner.java.patch | 15 - .../{ => boat}/AbstractBoat.java.patch | 30 +- .../vehicle/{ => boat}/ChestBoat.java.patch | 8 +- .../AbstractMinecart.java.patch | 42 +- .../AbstractMinecartContainer.java.patch | 14 +- .../minecart/MinecartCommandBlock.java.patch | 11 + .../{ => minecart}/MinecartFurnace.java.patch | 4 +- .../minecart/MinecartSpawner.java.patch | 14 + .../NewMinecartBehavior.java.patch | 43 +- .../OldMinecartBehavior.java.patch | 32 +- .../AbstractContainerMenu.java.patch | 4 +- .../world/inventory/AnvilMenu.java.patch | 10 +- .../world/inventory/ArmorSlot.java.patch | 2 +- .../inventory/EnchantmentMenu.java.patch | 10 +- .../minecraft/world/inventory/Slot.java.patch | 12 +- .../minecraft/world/item/BlockItem.java.patch | 10 +- .../world/item/BoneMealItem.java.patch | 12 +- .../world/item/BucketItem.java.patch | 16 +- .../world/item/CreativeModeTab.java.patch | 42 +- .../item/DispensibleContainerItem.java.patch | 2 +- .../minecraft/world/item/DyeColor.java.patch | 2 +- .../net/minecraft/world/item/Item.java.patch | 28 +- .../world/item/ItemDisplayContext.java.patch | 4 +- .../minecraft/world/item/ItemStack.java.patch | 18 +- .../net/minecraft/world/item/Items.java.patch | 4 +- .../world/item/MobBucketItem.java.patch | 2 +- .../item/StandingAndWallBlockItem.java.patch | 2 +- .../item/crafting/RecipeManager.java.patch | 6 +- .../world/item/crafting/RecipeType.java.patch | 2 +- .../item/crafting/ShapedRecipe.java.patch | 4 +- .../item/crafting/ShapelessRecipe.java.patch | 10 +- .../enchantment/EnchantmentHelper.java.patch | 2 +- .../world/level/BaseSpawner.java.patch | 7 +- .../world/level/BlockGetter.java.patch | 8 +- .../minecraft/world/level/Level.java.patch | 34 +- .../world/level/LevelReader.java.patch | 9 +- .../world/level/LevelSettings.java.patch | 16 +- .../world/level/NaturalSpawner.java.patch | 6 +- .../world/level/ServerExplosion.java.patch | 28 +- .../world/level/biome/Biome.java.patch | 38 +- .../biome/BiomeSpecialEffects.java.patch | 28 +- .../level/biome/MobSpawnSettings.java.patch | 2 +- .../level/block/BambooStalkBlock.java.patch | 6 +- .../level/block/BaseRailBlock.java.patch | 4 +- .../world/level/block/Block.java.patch | 33 +- .../world/level/block/Blocks.java.patch | 2 +- .../world/level/block/BucketPickup.java.patch | 2 +- .../level/block/CampfireBlock.java.patch | 2 +- .../world/level/block/ChestBlock.java.patch | 2 +- .../level/block/ComparatorBlock.java.patch | 2 +- .../world/level/block/CrafterBlock.java.patch | 4 +- .../world/level/block/CropBlock.java.patch | 2 +- .../level/block/DoublePlantBlock.java.patch | 2 +- .../world/level/block/FarmBlock.java.patch | 2 +- .../world/level/block/FireBlock.java.patch | 76 +- .../level/block/FlowerPotBlock.java.patch | 16 +- .../level/block/PitcherCropBlock.java.patch | 2 +- .../world/level/block/RailState.java.patch | 12 +- .../level/block/RedStoneWireBlock.java.patch | 4 +- .../level/block/SculkCatalystBlock.java.patch | 2 +- .../level/block/SculkSensorBlock.java.patch | 2 +- .../level/block/SculkShriekerBlock.java.patch | 4 +- .../level/block/SeagrassBlock.java.patch | 2 +- .../world/level/block/SpawnerBlock.java.patch | 2 +- .../world/level/block/TntBlock.java.patch | 4 +- .../level/block/TurtleEggBlock.java.patch | 2 +- .../world/level/block/VineBlock.java.patch | 4 +- .../AbstractFurnaceBlockEntity.java.patch | 2 +- .../BaseContainerBlockEntity.java.patch | 2 +- .../block/entity/BeaconBlockEntity.java.patch | 2 +- .../level/block/entity/BlockEntity.java.patch | 12 +- .../entity/ConduitBlockEntity.java.patch | 2 +- .../block/entity/HopperBlockEntity.java.patch | 2 +- .../entity/ShulkerBoxBlockEntity.java.patch | 4 +- .../block/entity/SignBlockEntity.java.patch | 2 +- .../level/block/grower/TreeGrower.java.patch | 2 +- .../block/state/BlockBehaviour.java.patch | 14 +- .../world/level/chunk/ChunkAccess.java.patch | 7 +- .../level/chunk/ImposterProtoChunk.java.patch | 2 +- .../world/level/chunk/LevelChunk.java.patch | 38 +- .../dimension/end/EndDragonFight.java.patch | 6 +- .../level/levelgen/Beardifier.java.patch | 2 +- .../structure/StructurePiece.java.patch | 2 +- .../structure/StructureStart.java.patch | 2 +- .../StructureProcessor.java.patch | 11 +- .../StructureTemplate.java.patch | 16 +- .../world/level/material/Fluid.java.patch | 6 +- .../level/material/FluidState.java.patch | 4 +- .../world/level/material/LavaFluid.java.patch | 38 +- .../pathfinder/WalkNodeEvaluator.java.patch | 8 +- .../storage/DimensionDataStorage.java.patch | 2 +- .../storage/LevelStorageSource.java.patch | 6 +- .../level/storage/LevelSummary.java.patch | 4 +- .../storage/PlayerDataStorage.java.patch | 8 +- .../level/storage/PrimaryLevelData.java.patch | 8 +- .../level/storage/loot/LootContext.java.patch | 28 +- .../level/storage/loot/LootParams.java.patch | 2 +- .../level/storage/loot/LootTable.java.patch | 14 +- .../data/c/tags/item/enchantables.json | 2 +- .../data/minecraft/recipe/copper_spear.json | 17 + .../data/minecraft/recipe/diamond_spear.json | 17 + .../data/minecraft/recipe/golden_spear.json | 17 + .../data/minecraft/recipe/iron_spear.json | 17 + .../data/minecraft/recipe/stone_spear.json | 17 + .../data/minecraft/recipe/wooden_spear.json | 17 + src/main/generated/pack.mcmeta | 7 +- .../client/ClientCommandHandler.java | 2 +- .../client/ClientCommandSourceStack.java | 7 +- .../minecraftforge/client/ClientForgeMod.java | 6 +- .../DimensionSpecialEffectsManager.java | 56 - .../client/EntitySpectatorShaderManager.java | 8 +- .../client/ForgeHooksClient.java | 71 +- .../client/ForgeRenderTypes.java | 448 +++---- .../client/FramePassManager.java | 4 +- .../client/NamedRenderTypeManager.java | 18 +- .../client/RenderTypeGroup.java | 2 +- .../client/RenderTypeHelper.java | 14 +- .../client/event/AddFramePassEvent.java | 4 +- .../client/event/ClientChatReceivedEvent.java | 2 +- .../client/event/EntityRenderersEvent.java | 3 +- .../client/event/ForgeEventFactoryClient.java | 11 +- .../client/event/ModelEvent.java | 22 +- .../event/RegisterClientCommandsEvent.java | 4 +- .../RegisterDimensionSpecialEffectsEvent.java | 49 - .../RegisterEntitySpectatorShadersEvent.java | 8 +- .../event/RegisterGuiOverlaysEvent.java | 16 +- .../event/RegisterNamedRenderTypesEvent.java | 24 +- .../event/RegisterPresetEditorsEvent.java | 2 +- ...egisterTextureAtlasSpriteLoadersEvent.java | 14 +- .../client/event/RenderTooltipEvent.java | 14 +- .../client/event/TextureStitchEvent.java | 6 +- .../client/event/package-info.java | 9 +- .../client/event/sound/PlaySoundEvent.java | 2 +- .../event/sound/PlaySoundSourceEvent.java | 2 +- .../event/sound/PlayStreamingSourceEvent.java | 2 +- .../extensions/IForgeBlockStateModel.java | 2 +- .../client/extensions/IForgeGuiGraphics.java | 14 +- .../client/extensions/IForgePoseStack.java | 5 +- .../extensions/IForgeVertexConsumer.java | 40 +- .../common/IClientFluidTypeExtensions.java | 24 +- .../common/IClientMobEffectExtensions.java | 20 +- .../client/extensions/package-info.java | 9 +- .../client/gui/LoadingErrorScreen.java | 2 +- .../client/gui/ModListScreen.java | 89 +- .../gui/ModMismatchDisconnectedScreen.java | 25 +- .../gui/TitleScreenModUpdateIndicator.java | 4 +- .../client/gui/overlay/ForgeGui.java | 8 +- .../client/gui/overlay/ForgeLayeredDraw.java | 116 +- .../client/gui/overlay/GuiOverlayManager.java | 12 +- .../client/gui/overlay/NamedGuiOverlay.java | 4 +- .../client/gui/overlay/VanillaGuiOverlay.java | 8 +- .../client/gui/widget/ExtendedButton.java | 2 +- .../client/gui/widget/ForgeSlider.java | 3 +- .../client/gui/widget/ModListWidget.java | 4 +- .../client/gui/widget/ScrollPanel.java | 2 +- .../client/loading/ForgeLoadingOverlay.java | 3 +- .../model/DynamicFluidContainerModel.java | 17 +- .../client/model/ForgeBlockModelData.java | 6 +- .../client/model/ForgeFaceData.java | 21 +- .../client/model/IModelBuilder.java | 160 --- .../client/model/IQuadTransformer.java | 16 - .../client/model/ItemLayerGeometry.java | 18 +- .../client/model/QuadTransformers.java | 118 +- .../model/generators/BlockModelBuilder.java | 37 - .../model/generators/BlockModelProvider.java | 32 - .../model/generators/BlockStateProvider.java | 1136 ---------------- .../model/generators/ConfiguredModel.java | 323 ----- .../model/generators/CustomLoaderBuilder.java | 70 - .../generators/IGeneratedBlockState.java | 21 - .../model/generators/ItemModelBuilder.java | 94 -- .../model/generators/ItemModelProvider.java | 49 - .../client/model/generators/ModelBuilder.java | 1138 ----------------- .../client/model/generators/ModelFile.java | 77 -- .../model/generators/ModelProvider.java | 419 ------ .../MultiPartBlockStateBuilder.java | 264 ---- .../generators/VariantBlockStateBuilder.java | 332 ----- .../loaders/CompositeModelBuilder.java | 81 -- .../DynamicFluidContainerModelBuilder.java | 95 -- .../loaders/ItemLayerModelBuilder.java | 226 ---- .../generators/loaders/ObjModelBuilder.java | 109 -- .../SeparateTransformsModelBuilder.java | 75 -- .../model/geometry/GeometryLoaderManager.java | 10 +- .../geometry/IGeometryBakingContext.java | 8 +- .../client/model/geometry/ModelContext.java | 4 +- .../StandaloneGeometryBakingContext.java | 26 +- .../model/geometry/UnbakedGeometryHelper.java | 43 +- .../client/model/obj/ObjLoader.java | 8 +- .../client/model/obj/ObjModel.java | 25 +- .../client/model/obj/package-info.java | 7 +- .../client/model/package-info.java | 7 +- ...texConsumer.java => BakedQuadBuilder.java} | 120 +- .../model/pipeline/VertexConsumerWrapper.java | 36 +- .../client/model/pipeline/package-info.java | 7 +- .../renderable/BakedModelRenderable.java | 2 +- .../model/renderable/CompositeRenderable.java | 10 +- .../renderable/ITextureRenderTypeLookup.java | 9 +- .../client/settings/KeyModifier.java | 4 +- .../client/textures/ForgeTextureMetadata.java | 4 +- .../textures/ITextureAtlasSpriteLoader.java | 6 +- .../TextureAtlasSpriteLoaderManager.java | 10 +- .../textures/UnitTextureAtlasSprite.java | 6 +- .../minecraftforge/common/BiomeManager.java | 84 +- .../common/CreativeModeTabRegistry.java | 24 +- .../net/minecraftforge/common/ForgeHooks.java | 49 +- .../net/minecraftforge/common/ForgeMod.java | 60 +- .../common/TagConventionMappings.java | 16 +- .../common/TagConventionMigrationHelper.java | 4 +- .../java/net/minecraftforge/common/Tags.java | 24 +- .../common/VillagerTradingManager.java | 6 +- .../common/brewing/package-info.java | 7 +- .../capabilities/CapabilityDispatcher.java | 15 +- .../capabilities/CapabilityManager.java | 10 +- .../capabilities/CapabilityProvider.java | 7 +- .../crafting/ConditionalAdvancement.java | 4 +- .../common/crafting/ConditionalRecipe.java | 12 +- .../crafting/conditions/ICondition.java | 4 +- .../conditions/IConditionBuilder.java | 4 +- .../conditions/ItemExistsCondition.java | 6 +- .../conditions/TagEmptyCondition.java | 4 +- .../ingredients/PartialNBTIngredient.java | 2 +- .../common/crafting/package-info.java | 7 +- .../common/data/ExistingFileHelper.java | 23 +- .../common/data/ForgeAdvancementProvider.java | 4 +- .../common/data/ForgeBiomeTagsProvider.java | 4 +- .../data/ForgeBlockItemTagsProvider.java | 14 +- .../common/data/ForgeBlockTagsProvider.java | 6 +- .../data/ForgeEntityTypeTagsProvider.java | 4 +- .../common/data/ForgeFluidTagsProvider.java | 12 +- .../common/data/ForgeItemTagsProvider.java | 28 +- .../common/data/ForgeLootTableProvider.java | 6 +- .../common/data/ForgeRecipeProvider.java | 6 +- .../data/ForgeSpriteSourceProvider.java | 4 +- .../data/GlobalLootModifierProvider.java | 8 +- .../common/data/JsonCodecProvider.java | 16 +- .../data/ParticleDescriptionProvider.java | 24 +- .../common/data/SoundDefinition.java | 12 +- .../common/data/SoundDefinitionsProvider.java | 22 +- .../common/data/SpriteSourceProvider.java | 30 +- .../common/data/package-info.java | 6 +- .../common/extensions/IForgeAbstractBoat.java | 4 +- .../extensions/IForgeAbstractMinecart.java | 2 +- .../extensions/IForgeBaseRailBlock.java | 17 +- .../common/extensions/IForgeBlock.java | 5 +- .../extensions/IForgeCommandSourceStack.java | 4 +- .../common/extensions/IForgeEntity.java | 2 +- .../common/extensions/IForgeFluid.java | 2 +- .../common/extensions/IForgeFluidState.java | 4 +- .../extensions/IForgeGameTestHelper.java | 2 +- .../common/extensions/IForgeItem.java | 2 +- .../extensions/IForgePackResources.java | 2 +- .../extensions/IForgeRawTagBuilder.java | 6 +- .../common/extensions/IForgeTagAppender.java | 10 +- .../common/loot/LootModifier.java | 2 +- .../common/loot/LootModifierManager.java | 16 +- .../common/loot/LootTableIdCondition.java | 14 +- .../common/util/BlockSnapshot.java | 2 +- .../common/util/BrainBuilder.java | 10 +- .../common/util/LazyOptional.java | 7 +- .../common/util/LevelCapabilityData.java | 28 +- .../common/util/TransformationHelper.java | 244 ++-- .../world/BiomeSpecialEffectsBuilder.java | 110 +- .../common/world/ForgeBiomeModifiers.java | 4 - .../common/world/MobSpawnSettingsBuilder.java | 3 - .../data/loading/DatagenModLoader.java | 2 +- .../event/AttachCapabilitiesEvent.java | 10 +- .../event/ForgeEventFactory.java | 69 +- .../event/LootTableLoadEvent.java | 8 +- .../RegisterStructureConversionsEvent.java | 4 +- .../event/entity/EntityTeleportEvent.java | 2 +- .../entity/living/BabyEntitySpawnEvent.java | 2 +- .../event/entity/living/ZombieEvent.java | 2 +- .../player/PermissionsChangedEvent.java | 4 +- .../entity/player/TradeWithVillagerEvent.java | 2 +- .../ChannelRegistrationChangeEvent.java | 4 +- .../event/network/CustomPayloadEvent.java | 6 +- .../event/village/VillagerTradesEvent.java | 6 +- .../event/village/WandererTradesEvent.java | 4 +- .../net/minecraftforge/fluids/FluidStack.java | 6 +- .../net/minecraftforge/fluids/FluidType.java | 12 +- .../wrappers/BucketPickupHandlerWrapper.java | 2 +- .../gametest/ForgeGameTestHooks.java | 20 +- .../wrapper/ShulkerItemStackInvWrapper.java | 2 +- .../net/minecraftforge/network/Channel.java | 8 +- .../network/ChannelBuilder.java | 10 +- .../network/ChannelListManager.java | 20 +- .../network/EventNetworkChannel.java | 4 +- .../network/ForgePacketHandler.java | 20 +- .../minecraftforge/network/ForgePayload.java | 8 +- .../network/NetworkContext.java | 16 +- .../network/NetworkInitialization.java | 8 +- .../network/NetworkInstance.java | 14 +- .../network/NetworkProtocol.java | 4 +- .../network/NetworkRegistry.java | 34 +- .../network/PayloadChannel.java | 10 +- .../network/ServerStatusPing.java | 26 +- .../VanillaConnectionNetworkFilter.java | 6 +- .../filters/VanillaPacketSplitter.java | 4 +- .../network/packets/ChannelVersions.java | 8 +- .../network/packets/LoginWrapper.java | 12 +- .../network/packets/MismatchData.java | 10 +- .../network/packets/RegistryData.java | 8 +- .../network/packets/RegistryList.java | 10 +- .../network/tasks/SyncRegistriesTask.java | 4 +- .../registries/DeferredRegister.java | 62 +- .../registries/DeferredRegisterData.java | 26 +- .../registries/ForgeRegistries.java | 13 +- .../registries/ForgeRegistry.java | 124 +- .../registries/ForgeRegistryTag.java | 3 +- .../registries/ForgeRegistryTagManager.java | 6 +- .../minecraftforge/registries/GameData.java | 91 +- .../registries/IForgeRegistry.java | 32 +- .../registries/IForgeRegistryInternal.java | 4 +- .../registries/IForgeRegistryModifiable.java | 4 +- .../registries/IdMappingEvent.java | 18 +- .../registries/MissingMappingsEvent.java | 8 +- .../NamespacedDefaultedWrapper.java | 10 +- .../registries/NamespacedWrapper.java | 42 +- .../registries/ObjectHolderRegistry.java | 12 +- .../registries/RegisterEvent.java | 16 +- .../registries/RegistryBuilder.java | 24 +- .../registries/RegistryManager.java | 45 +- .../registries/RegistryObject.java | 64 +- .../registries/holdersets/AnyHolderSet.java | 2 +- .../registries/tags/ITagManager.java | 18 +- .../resource/DelegatingPackResources.java | 6 +- .../minecraftforge/resource/package-info.java | 8 +- .../minecraftforge/server/LanguageHook.java | 4 +- .../server/command/ChunkGenWorker.java | 2 +- .../server/command/CommandHelper.java | 4 +- .../server/command/ConfigCommand.java | 2 +- .../server/command/DimensionsCommand.java | 10 +- .../server/command/EntityCommand.java | 16 +- .../server/command/GenerateCommand.java | 2 +- .../server/command/ModListCommand.java | 2 +- .../server/command/TPSCommand.java | 4 +- .../server/command/TagsCommand.java | 40 +- .../server/command/TrackCommand.java | 8 +- .../server/command/package-info.java | 7 +- .../server/permission/PermissionAPI.java | 12 +- .../events/PermissionGatherEvent.java | 8 +- .../handler/DefaultPermissionHandler.java | 6 +- .../handler/IPermissionHandler.java | 4 +- .../permission/nodes/PermissionNode.java | 4 +- .../server/permission/package-info.java | 7 +- .../resources/META-INF/accesstransformer.cfg | 248 ++-- src/test/generated/mdk_datagen/pack.mcmeta | 7 +- .../generated/test_helper_mod/pack.mcmeta | 7 +- .../java/com/example/examplemod/Config.java | 6 +- .../debug/client/AdditionalModelTest.java | 8 +- .../debug/client/ModelRenderLayerTest.java | 14 +- .../debug/client/ModifyOverlayTest.java | 20 +- .../debug/client/ObjModelTest.java | 6 +- .../debug/client/RenderFrameLayerTest.java | 30 +- .../creativetabs/CreativeModeTabTest.java | 16 +- .../block/PlantTypePlacementTest.java | 6 +- .../crafting/ConditionalRecipeTest.java | 4 +- .../crafting/CustomIngredientsTest.java | 4 +- .../debug/gameplay/crafting/TagsTest.java | 4 +- .../criterion/BreakWithItemCriterion.java | 14 +- .../gameplay/criterion/CriterionTest.java | 13 +- .../DatapackBuiltinEntriesProviderTest.java | 8 +- .../gameplay/item/ItemCapabilityTest.java | 4 +- .../gameplay/item/ShearsBehaviorTest.java | 2 +- .../gameplay/item/ShieldDisablingTest.java | 2 +- .../loot/GlobalLootModifiersTest.java | 17 +- .../debug/gameplay/loot/LootEventsTest.java | 2 +- .../villager/VillagerTypeTestMod.java | 10 +- .../debug/network/PacketTest.java | 4 +- .../NetworkDatapackRegistryTest.java | 10 +- .../net/minecraftforge/test/BaseTestMod.java | 14 +- .../minecraftforge/test/ManifestProvider.java | 2 +- .../minecraftforge/test/ModuleProvider.java | 2 +- .../minecraftforge/test/TestHelperMod.java | 4 +- 698 files changed, 4892 insertions(+), 10126 deletions(-) create mode 100644 patches/minecraft/com/mojang/realmsclient/gui/screens/RealmsResetWorldScreen.java.patch delete mode 100644 patches/minecraft/net/minecraft/client/gui/components/AbstractButton.java.patch delete mode 100644 patches/minecraft/net/minecraft/client/renderer/DimensionSpecialEffects.java.patch delete mode 100644 patches/minecraft/net/minecraft/client/renderer/RenderType.java.patch create mode 100644 patches/minecraft/net/minecraft/client/renderer/debug/EntityHitboxDebugRenderer.java.patch delete mode 100644 patches/minecraft/net/minecraft/client/renderer/entity/EnderDragonRenderer.java.patch delete mode 100644 patches/minecraft/net/minecraft/client/renderer/entity/ItemRenderer.java.patch create mode 100644 patches/minecraft/net/minecraft/client/renderer/rendertype/RenderSetup.java.patch create mode 100644 patches/minecraft/net/minecraft/client/renderer/rendertype/RenderTypes.java.patch delete mode 100644 patches/minecraft/net/minecraft/client/renderer/texture/AbstractTexture.java.patch delete mode 100644 patches/minecraft/net/minecraft/commands/SharedSuggestionProvider.java.patch create mode 100644 patches/minecraft/net/minecraft/resources/Identifier.java.patch delete mode 100644 patches/minecraft/net/minecraft/resources/ResourceLocation.java.patch create mode 100644 patches/minecraft/net/minecraft/server/network/EventLoopGroupHolder.java.patch rename patches/minecraft/net/minecraft/{ => util}/Util.java.patch (50%) delete mode 100644 patches/minecraft/net/minecraft/world/entity/animal/Pig.java.patch rename patches/minecraft/net/minecraft/world/entity/animal/{ => bee}/Bee.java.patch (80%) rename patches/minecraft/net/minecraft/world/entity/animal/{ => cow}/MushroomCow.java.patch (63%) rename patches/minecraft/net/minecraft/world/entity/animal/{horse => equine}/AbstractHorse.java.patch (64%) create mode 100644 patches/minecraft/net/minecraft/world/entity/animal/equine/Llama.java.patch rename patches/minecraft/net/minecraft/world/entity/animal/{horse => equine}/SkeletonTrapGoal.java.patch (83%) rename patches/minecraft/net/minecraft/world/entity/animal/{ => feline}/Cat.java.patch (64%) rename patches/minecraft/net/minecraft/world/entity/animal/{ => feline}/Ocelot.java.patch (55%) rename patches/minecraft/net/minecraft/world/entity/animal/{ => fox}/Fox.java.patch (83%) rename patches/minecraft/net/minecraft/world/entity/animal/{coppergolem => golem}/CopperGolem.java.patch (80%) rename patches/minecraft/net/minecraft/world/entity/animal/{ => golem}/SnowGolem.java.patch (78%) delete mode 100644 patches/minecraft/net/minecraft/world/entity/animal/horse/Llama.java.patch rename patches/minecraft/net/minecraft/world/entity/animal/{ => parrot}/Parrot.java.patch (53%) create mode 100644 patches/minecraft/net/minecraft/world/entity/animal/pig/Pig.java.patch rename patches/minecraft/net/minecraft/world/entity/animal/{ => rabbit}/Rabbit.java.patch (67%) delete mode 100644 patches/minecraft/net/minecraft/world/entity/boss/EnderDragonPart.java.patch create mode 100644 patches/minecraft/net/minecraft/world/entity/boss/enderdragon/EnderDragonPart.java.patch delete mode 100644 patches/minecraft/net/minecraft/world/entity/monster/Husk.java.patch delete mode 100644 patches/minecraft/net/minecraft/world/entity/monster/Spider.java.patch rename patches/minecraft/net/minecraft/world/entity/monster/{ => illager}/Evoker.java.patch (71%) rename patches/minecraft/net/minecraft/world/entity/monster/{ => illager}/Illusioner.java.patch (55%) rename patches/minecraft/net/minecraft/world/entity/monster/{ => illager}/Pillager.java.patch (78%) rename patches/minecraft/net/minecraft/world/entity/monster/{ => skeleton}/AbstractSkeleton.java.patch (71%) rename patches/minecraft/net/minecraft/world/entity/monster/{ => skeleton}/Bogged.java.patch (75%) rename patches/minecraft/net/minecraft/world/entity/monster/{ => skeleton}/Skeleton.java.patch (70%) create mode 100644 patches/minecraft/net/minecraft/world/entity/monster/spider/Spider.java.patch create mode 100644 patches/minecraft/net/minecraft/world/entity/monster/zombie/Husk.java.patch rename patches/minecraft/net/minecraft/world/entity/monster/{ => zombie}/Zombie.java.patch (52%) rename patches/minecraft/net/minecraft/world/entity/monster/{ => zombie}/ZombieVillager.java.patch (63%) delete mode 100644 patches/minecraft/net/minecraft/world/entity/npc/AbstractVillager.java.patch delete mode 100644 patches/minecraft/net/minecraft/world/entity/npc/Villager.java.patch create mode 100644 patches/minecraft/net/minecraft/world/entity/npc/villager/AbstractVillager.java.patch create mode 100644 patches/minecraft/net/minecraft/world/entity/npc/villager/Villager.java.patch rename patches/minecraft/net/minecraft/world/entity/npc/{ => villager}/VillagerTrades.java.patch (65%) rename patches/minecraft/net/minecraft/world/entity/npc/{ => villager}/VillagerType.java.patch (67%) delete mode 100644 patches/minecraft/net/minecraft/world/entity/projectile/AbstractArrow.java.patch delete mode 100644 patches/minecraft/net/minecraft/world/entity/projectile/WitherSkull.java.patch create mode 100644 patches/minecraft/net/minecraft/world/entity/projectile/arrow/AbstractArrow.java.patch rename patches/minecraft/net/minecraft/world/entity/projectile/{ => hurtingprojectile}/AbstractHurtingProjectile.java.patch (65%) rename patches/minecraft/net/minecraft/world/entity/projectile/{ => hurtingprojectile}/LargeFireball.java.patch (53%) rename patches/minecraft/net/minecraft/world/entity/projectile/{ => hurtingprojectile}/SmallFireball.java.patch (59%) create mode 100644 patches/minecraft/net/minecraft/world/entity/projectile/hurtingprojectile/WitherSkull.java.patch rename patches/minecraft/net/minecraft/world/entity/projectile/{ => throwableitemprojectile}/ThrownEnderpearl.java.patch (83%) delete mode 100644 patches/minecraft/net/minecraft/world/entity/vehicle/MinecartCommandBlock.java.patch delete mode 100644 patches/minecraft/net/minecraft/world/entity/vehicle/MinecartSpawner.java.patch rename patches/minecraft/net/minecraft/world/entity/vehicle/{ => boat}/AbstractBoat.java.patch (85%) rename patches/minecraft/net/minecraft/world/entity/vehicle/{ => boat}/ChestBoat.java.patch (81%) rename patches/minecraft/net/minecraft/world/entity/vehicle/{ => minecart}/AbstractMinecart.java.patch (81%) rename patches/minecraft/net/minecraft/world/entity/vehicle/{ => minecart}/AbstractMinecartContainer.java.patch (71%) create mode 100644 patches/minecraft/net/minecraft/world/entity/vehicle/minecart/MinecartCommandBlock.java.patch rename patches/minecraft/net/minecraft/world/entity/vehicle/{ => minecart}/MinecartFurnace.java.patch (68%) create mode 100644 patches/minecraft/net/minecraft/world/entity/vehicle/minecart/MinecartSpawner.java.patch rename patches/minecraft/net/minecraft/world/entity/vehicle/{ => minecart}/NewMinecartBehavior.java.patch (52%) rename patches/minecraft/net/minecraft/world/entity/vehicle/{ => minecart}/OldMinecartBehavior.java.patch (86%) create mode 100644 src/main/generated/data/minecraft/recipe/copper_spear.json create mode 100644 src/main/generated/data/minecraft/recipe/diamond_spear.json create mode 100644 src/main/generated/data/minecraft/recipe/golden_spear.json create mode 100644 src/main/generated/data/minecraft/recipe/iron_spear.json create mode 100644 src/main/generated/data/minecraft/recipe/stone_spear.json create mode 100644 src/main/generated/data/minecraft/recipe/wooden_spear.json delete mode 100644 src/main/java/net/minecraftforge/client/DimensionSpecialEffectsManager.java delete mode 100644 src/main/java/net/minecraftforge/client/event/RegisterDimensionSpecialEffectsEvent.java delete mode 100644 src/main/java/net/minecraftforge/client/model/IModelBuilder.java delete mode 100644 src/main/java/net/minecraftforge/client/model/generators/BlockModelBuilder.java delete mode 100644 src/main/java/net/minecraftforge/client/model/generators/BlockModelProvider.java delete mode 100644 src/main/java/net/minecraftforge/client/model/generators/BlockStateProvider.java delete mode 100644 src/main/java/net/minecraftforge/client/model/generators/ConfiguredModel.java delete mode 100644 src/main/java/net/minecraftforge/client/model/generators/CustomLoaderBuilder.java delete mode 100644 src/main/java/net/minecraftforge/client/model/generators/IGeneratedBlockState.java delete mode 100644 src/main/java/net/minecraftforge/client/model/generators/ItemModelBuilder.java delete mode 100644 src/main/java/net/minecraftforge/client/model/generators/ItemModelProvider.java delete mode 100644 src/main/java/net/minecraftforge/client/model/generators/ModelBuilder.java delete mode 100644 src/main/java/net/minecraftforge/client/model/generators/ModelFile.java delete mode 100644 src/main/java/net/minecraftforge/client/model/generators/ModelProvider.java delete mode 100644 src/main/java/net/minecraftforge/client/model/generators/MultiPartBlockStateBuilder.java delete mode 100644 src/main/java/net/minecraftforge/client/model/generators/VariantBlockStateBuilder.java delete mode 100644 src/main/java/net/minecraftforge/client/model/generators/loaders/CompositeModelBuilder.java delete mode 100644 src/main/java/net/minecraftforge/client/model/generators/loaders/DynamicFluidContainerModelBuilder.java delete mode 100644 src/main/java/net/minecraftforge/client/model/generators/loaders/ItemLayerModelBuilder.java delete mode 100644 src/main/java/net/minecraftforge/client/model/generators/loaders/ObjModelBuilder.java delete mode 100644 src/main/java/net/minecraftforge/client/model/generators/loaders/SeparateTransformsModelBuilder.java rename src/main/java/net/minecraftforge/client/model/pipeline/{QuadBakingVertexConsumer.java => BakedQuadBuilder.java} (51%) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 04252fc68d..5fdf3fe6d6 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -2,7 +2,7 @@ name: Publish on: push: - branches: [ '1.21.x' ] + branches: [ '1.21.11' ] permissions: contents: read diff --git a/fmlcore/src/main/java/net/minecraftforge/fml/util/thread/EffectiveSide.java b/fmlcore/src/main/java/net/minecraftforge/fml/util/thread/EffectiveSide.java index 8a7696a90d..bb5607fcdf 100644 --- a/fmlcore/src/main/java/net/minecraftforge/fml/util/thread/EffectiveSide.java +++ b/fmlcore/src/main/java/net/minecraftforge/fml/util/thread/EffectiveSide.java @@ -7,8 +7,11 @@ package net.minecraftforge.fml.util.thread; import net.minecraftforge.fml.LogicalSide; -public class EffectiveSide -{ +/** + * Attempts to determine the effect side of the current thread, based on know threads in networking. + * This is not guaranteed to be correct, and modders should use other methods to determine the logical side when possible. + */ +public class EffectiveSide { public static LogicalSide get() { final ThreadGroup group = Thread.currentThread().getThreadGroup(); return group instanceof SidedThreadGroup ? ((SidedThreadGroup) group).getSide() : LogicalSide.CLIENT; diff --git a/fmlcore/src/main/java/net/minecraftforge/fml/util/thread/SidedThreadGroups.java b/fmlcore/src/main/java/net/minecraftforge/fml/util/thread/SidedThreadGroups.java index c9b41b10ae..b42d749d5b 100644 --- a/fmlcore/src/main/java/net/minecraftforge/fml/util/thread/SidedThreadGroups.java +++ b/fmlcore/src/main/java/net/minecraftforge/fml/util/thread/SidedThreadGroups.java @@ -7,11 +7,13 @@ package net.minecraftforge.fml.util.thread; import net.minecraftforge.fml.LogicalSide; -public final class SidedThreadGroups -{ +public final class SidedThreadGroups { public static final SidedThreadGroup CLIENT = new SidedThreadGroup(LogicalSide.CLIENT); public static final SidedThreadGroup SERVER = new SidedThreadGroup(LogicalSide.SERVER); - private SidedThreadGroups() { + public static SidedThreadGroup get(boolean client) { + return client ? CLIENT : SERVER; } + + private SidedThreadGroups() { } } 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 893ada6727..29d45372ac 100644 --- a/forge-transformers/src/main/resources/coremods/finalize_spawn_targets.json +++ b/forge-transformers/src/main/resources/coremods/finalize_spawn_targets.json @@ -1,4 +1,10 @@ [ + { + "class": "net/minecraft/gametest/framework/GameTestHelper", + "methods": [ + "spawn(Lnet/minecraft/world/entity/EntityType;Lnet/minecraft/world/phys/Vec3;Lnet/minecraft/world/entity/EntitySpawnReason;)Lnet/minecraft/world/entity/Entity;" + ] + }, { "class": "net/minecraft/server/commands/RaidCommand", "methods": [ @@ -23,31 +29,25 @@ "trySpawn(Lnet/minecraft/server/level/ServerLevel;)V" ] }, + { + "class": "net/minecraft/world/entity/animal/equine/SkeletonTrapGoal", + "methods": [ + "createHorse(Lnet/minecraft/world/DifficultyInstance;)Lnet/minecraft/world/entity/animal/equine/AbstractHorse;", + "createSkeleton(Lnet/minecraft/world/DifficultyInstance;Lnet/minecraft/world/entity/animal/equine/AbstractHorse;)Lnet/minecraft/world/entity/monster/skeleton/Skeleton;" + ] + }, + { + "class": "net/minecraft/world/entity/animal/equine/ZombieHorse", + "methods": [ + "finalizeSpawn(Lnet/minecraft/world/level/ServerLevelAccessor;Lnet/minecraft/world/DifficultyInstance;Lnet/minecraft/world/entity/EntitySpawnReason;Lnet/minecraft/world/entity/SpawnGroupData;)Lnet/minecraft/world/entity/SpawnGroupData;" + ] + }, { "class": "net/minecraft/world/entity/animal/frog/Tadpole", "methods": [ ] }, - { - "class": "net/minecraft/world/entity/animal/horse/SkeletonTrapGoal", - "methods": [ - "createHorse(Lnet/minecraft/world/DifficultyInstance;)Lnet/minecraft/world/entity/animal/horse/AbstractHorse;", - "createSkeleton(Lnet/minecraft/world/DifficultyInstance;Lnet/minecraft/world/entity/animal/horse/AbstractHorse;)Lnet/minecraft/world/entity/monster/Skeleton;" - ] - }, - { - "class": "net/minecraft/world/entity/monster/Evoker$EvokerSummonSpellGoal", - "methods": [ - "performSpellCasting()V" - ] - }, - { - "class": "net/minecraft/world/entity/monster/Spider", - "methods": [ - "finalizeSpawn(Lnet/minecraft/world/level/ServerLevelAccessor;Lnet/minecraft/world/DifficultyInstance;Lnet/minecraft/world/entity/EntitySpawnReason;Lnet/minecraft/world/entity/SpawnGroupData;)Lnet/minecraft/world/entity/SpawnGroupData;" - ] - }, { "class": "net/minecraft/world/entity/monster/Strider", "methods": [ @@ -55,14 +55,38 @@ ] }, { - "class": "net/minecraft/world/entity/monster/Zombie", + "class": "net/minecraft/world/entity/monster/illager/Evoker$EvokerSummonSpellGoal", + "methods": [ + "performSpellCasting()V" + ] + }, + { + "class": "net/minecraft/world/entity/monster/spider/Spider", + "methods": [ + "finalizeSpawn(Lnet/minecraft/world/level/ServerLevelAccessor;Lnet/minecraft/world/DifficultyInstance;Lnet/minecraft/world/entity/EntitySpawnReason;Lnet/minecraft/world/entity/SpawnGroupData;)Lnet/minecraft/world/entity/SpawnGroupData;" + ] + }, + { + "class": "net/minecraft/world/entity/monster/zombie/Drowned", + "methods": [ + "finalizeSpawn(Lnet/minecraft/world/level/ServerLevelAccessor;Lnet/minecraft/world/DifficultyInstance;Lnet/minecraft/world/entity/EntitySpawnReason;Lnet/minecraft/world/entity/SpawnGroupData;)Lnet/minecraft/world/entity/SpawnGroupData;" + ] + }, + { + "class": "net/minecraft/world/entity/monster/zombie/Husk", + "methods": [ + "finalizeSpawn(Lnet/minecraft/world/level/ServerLevelAccessor;Lnet/minecraft/world/DifficultyInstance;Lnet/minecraft/world/entity/EntitySpawnReason;Lnet/minecraft/world/entity/SpawnGroupData;)Lnet/minecraft/world/entity/SpawnGroupData;" + ] + }, + { + "class": "net/minecraft/world/entity/monster/zombie/Zombie", "methods": [ "hurtServer(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/damagesource/DamageSource;F)Z", "finalizeSpawn(Lnet/minecraft/world/level/ServerLevelAccessor;Lnet/minecraft/world/DifficultyInstance;Lnet/minecraft/world/entity/EntitySpawnReason;Lnet/minecraft/world/entity/SpawnGroupData;)Lnet/minecraft/world/entity/SpawnGroupData;" ] }, { - "class": "net/minecraft/world/entity/monster/ZombieVillager", + "class": "net/minecraft/world/entity/monster/zombie/ZombieVillager", "methods": [ ] @@ -74,9 +98,9 @@ ] }, { - "class": "net/minecraft/world/entity/npc/Villager", + "class": "net/minecraft/world/entity/npc/villager/Villager", "methods": [ - "getBreedOffspring(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/entity/AgeableMob;)Lnet/minecraft/world/entity/npc/Villager;" + "getBreedOffspring(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/entity/AgeableMob;)Lnet/minecraft/world/entity/npc/villager/Villager;" ] }, { diff --git a/gradle.properties b/gradle.properties index 06385534d5..5c339d84c2 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.10 +MC_VERSION=1.21.11 MC_NEXT_VERSION=1.22 -MCP_VERSION=20251007.101210 +MCP_VERSION=20251209.095502 MAPPING_CHANNEL=official -MAPPING_VERSION=1.21.10 +MAPPING_VERSION=1.21.11 # 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 c18b0cc3eb..acb6d73e19 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 -@@ -131,6 +_,9 @@ +@@ -133,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/GlDebug.java.patch b/patches/minecraft/com/mojang/blaze3d/opengl/GlDebug.java.patch index 8498af84a3..3b6b49a1d1 100644 --- a/patches/minecraft/com/mojang/blaze3d/opengl/GlDebug.java.patch +++ b/patches/minecraft/com/mojang/blaze3d/opengl/GlDebug.java.patch @@ -1,6 +1,6 @@ --- a/com/mojang/blaze3d/opengl/GlDebug.java +++ b/com/mojang/blaze3d/opengl/GlDebug.java -@@ -23,6 +_,14 @@ +@@ -24,6 +_,14 @@ @OnlyIn(Dist.CLIENT) public class GlDebug { @@ -24,10 +24,10 @@ } public List getLastOpenGlDebugMessages() { -@@ -121,6 +_,7 @@ +@@ -120,6 +_,7 @@ + } - @Nullable - public static GlDebug enableDebugCallback(int p_394351_, boolean p_393026_, Set p_393339_) { + public static @Nullable GlDebug enableDebugCallback(int p_394351_, boolean p_393026_, Set p_393339_) { + p_393026_ |= PRINT_STACKTRACE_ON_ERROR; if (p_394351_ <= 0) { return null; diff --git a/patches/minecraft/com/mojang/blaze3d/opengl/GlDevice.java.patch b/patches/minecraft/com/mojang/blaze3d/opengl/GlDevice.java.patch index 3f76d6bf8c..90fc76c760 100644 --- a/patches/minecraft/com/mojang/blaze3d/opengl/GlDevice.java.patch +++ b/patches/minecraft/com/mojang/blaze3d/opengl/GlDevice.java.patch @@ -1,8 +1,8 @@ --- a/com/mojang/blaze3d/opengl/GlDevice.java +++ b/com/mojang/blaze3d/opengl/GlDevice.java -@@ -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_ +@@ -124,8 +_,15 @@ + int p_407582_, + int p_408928_ ) { + return createTexture(p_397830_, p_394481_, p_394839_, p_391831_, p_395609_, p_407582_, p_408928_, false); + } @@ -17,23 +17,23 @@ ); } -@@ -99,6 +_,15 @@ +@@ -133,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_ + @Nullable String p_394142_, @GpuTexture.Usage int p_395535_, TextureFormat p_394951_, int p_393944_, int p_392329_, int p_408015_, int p_406483_ ) { + return createTexture(p_394142_, p_395535_, p_394951_, p_393944_, p_392329_, p_408015_, p_406483_, false); + } + + @Override + 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_, boolean stencil ++ @Nullable String p_394142_, @GpuTexture.Usage int p_395535_, TextureFormat p_394951_, int p_393944_, int p_392329_, int p_408015_, int p_406483_, boolean stencil + ) { + // Forge: stencil rendering is only for depth + stencil &= p_394951_.hasDepthAspect(); if (p_406483_ < 1) { throw new IllegalArgumentException("mipLevels must be at least 1"); } else if (p_408015_ < 1) { -@@ -149,11 +_,14 @@ +@@ -183,11 +_,14 @@ GlStateManager._texImage2D( k, l, @@ -48,7 +48,7 @@ GlConst.toGlType(p_394951_), null ); -@@ -164,11 +_,14 @@ +@@ -198,11 +_,14 @@ GlStateManager._texImage2D( j, i1, @@ -63,7 +63,7 @@ GlConst.toGlType(p_394951_), null ); -@@ -181,7 +_,7 @@ +@@ -215,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 e202072b3e..68d6d7ed49 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 -@@ -85,6 +_,11 @@ +@@ -86,6 +_,11 @@ } } diff --git a/patches/minecraft/com/mojang/blaze3d/opengl/GlTexture.java.patch b/patches/minecraft/com/mojang/blaze3d/opengl/GlTexture.java.patch index 54a2d90ad7..9e16177549 100644 --- a/patches/minecraft/com/mojang/blaze3d/opengl/GlTexture.java.patch +++ b/patches/minecraft/com/mojang/blaze3d/opengl/GlTexture.java.patch @@ -1,9 +1,9 @@ --- a/com/mojang/blaze3d/opengl/GlTexture.java +++ b/com/mojang/blaze3d/opengl/GlTexture.java -@@ -19,8 +_,13 @@ - private int views; - - protected GlTexture(int p_394590_, String p_393950_, TextureFormat p_392837_, int p_391379_, int p_391947_, int p_396659_, int p_408255_, int p_408889_) { +@@ -21,8 +_,13 @@ + protected GlTexture( + @GpuTexture.Usage int p_394590_, String p_393950_, TextureFormat p_392837_, int p_391379_, int p_391947_, int p_396659_, int p_408255_, int p_408889_ + ) { + this(p_394590_, p_393950_, p_392837_, p_391379_, p_391947_, p_396659_, p_408255_, p_408889_, false); + } + @@ -14,20 +14,16 @@ } @Override -@@ -93,6 +_,16 @@ - public void setTextureFilter(FilterMode p_394977_, FilterMode p_397175_, boolean p_393558_) { - super.setTextureFilter(p_394977_, p_397175_, p_393558_); - this.modesDirty = true; +@@ -89,5 +_,12 @@ + if (this.closed && this.views == 0) { + this.destroyImmediately(); + } + } + -+ -+ /* FORGE START */ -+ + private final boolean stencilEnabled; + + @Override + public boolean isStencilEnabled() { + return this.stencilEnabled; } - - @Override + } diff --git a/patches/minecraft/com/mojang/blaze3d/pipeline/RenderTarget.java.patch b/patches/minecraft/com/mojang/blaze3d/pipeline/RenderTarget.java.patch index 4cf33375a9..2e4484440d 100644 --- a/patches/minecraft/com/mojang/blaze3d/pipeline/RenderTarget.java.patch +++ b/patches/minecraft/com/mojang/blaze3d/pipeline/RenderTarget.java.patch @@ -1,17 +1,17 @@ --- a/com/mojang/blaze3d/pipeline/RenderTarget.java +++ b/com/mojang/blaze3d/pipeline/RenderTarget.java -@@ -86,7 +_,7 @@ +@@ -80,7 +_,7 @@ this.width = p_83951_; this.height = p_83952_; if (this.useDepth) { - this.depthTexture = gpudevice.createTexture(() -> this.label + " / Depth", 15, TextureFormat.DEPTH32, p_83951_, p_83952_, 1, 1); + this.depthTexture = gpudevice.createTexture(() -> this.label + " / Depth", 15, TextureFormat.DEPTH32, p_83951_, p_83952_, 1, 1, this.stencilEnabled); this.depthTextureView = gpudevice.createTextureView(this.depthTexture); - this.depthTexture.setTextureFilter(FilterMode.NEAREST, false); - this.depthTexture.setAddressMode(AddressMode.CLAMP_TO_EDGE); -@@ -155,5 +_,26 @@ - @Nullable - public GpuTextureView getDepthTextureView() { + } + +@@ -126,5 +_,26 @@ + + public @Nullable GpuTextureView getDepthTextureView() { return this.depthTextureView; + } + diff --git a/patches/minecraft/com/mojang/blaze3d/systems/GpuDevice.java.patch b/patches/minecraft/com/mojang/blaze3d/systems/GpuDevice.java.patch index 3c8be4fd1f..8859c3ec32 100644 --- a/patches/minecraft/com/mojang/blaze3d/systems/GpuDevice.java.patch +++ b/patches/minecraft/com/mojang/blaze3d/systems/GpuDevice.java.patch @@ -1,7 +1,7 @@ --- a/com/mojang/blaze3d/systems/GpuDevice.java +++ b/com/mojang/blaze3d/systems/GpuDevice.java -@@ -26,7 +_,17 @@ - @Nullable Supplier p_394357_, int p_395623_, TextureFormat p_395807_, int p_395802_, int p_396157_, int p_408810_, int p_407070_ +@@ -36,9 +_,19 @@ + int p_407070_ ); + /** Forge: same as {@link #createTexture(Supplier, int, TextureFormat, int, int, int)} but with stencil support */ @@ -9,7 +9,9 @@ + return this.createTexture(p_394357_, p_395623_, p_395807_, p_395802_, p_396157_, p_408810_, p_407070_); + } + - GpuTexture createTexture(@Nullable String p_391798_, int p_391800_, TextureFormat p_393333_, int p_395600_, int p_394065_, int p_408732_, int p_407125_); + GpuTexture createTexture( + @Nullable String p_391798_, @GpuTexture.Usage int p_391800_, TextureFormat p_393333_, int p_395600_, int p_394065_, int p_408732_, int p_407125_ + ); + + /** Forge: same as {@link #createTexture(String, int, TextureFormat, int, int, int)} but with stencil support */ + default GpuTexture createTexture(@Nullable String p_391798_, int p_391800_, TextureFormat p_393333_, int p_395600_, int p_394065_, int p_408732_, int p_407125_, boolean stencil) { diff --git a/patches/minecraft/com/mojang/blaze3d/textures/GpuTexture.java.patch b/patches/minecraft/com/mojang/blaze3d/textures/GpuTexture.java.patch index 5708d65b50..a53ef1fc42 100644 --- a/patches/minecraft/com/mojang/blaze3d/textures/GpuTexture.java.patch +++ b/patches/minecraft/com/mojang/blaze3d/textures/GpuTexture.java.patch @@ -1,6 +1,6 @@ --- a/com/mojang/blaze3d/textures/GpuTexture.java +++ b/com/mojang/blaze3d/textures/GpuTexture.java -@@ -6,7 +_,7 @@ +@@ -10,7 +_,7 @@ @OnlyIn(Dist.CLIENT) @DontObfuscate diff --git a/patches/minecraft/com/mojang/blaze3d/vertex/VertexConsumer.java.patch b/patches/minecraft/com/mojang/blaze3d/vertex/VertexConsumer.java.patch index 1d0ea72adc..36226d81e2 100644 --- a/patches/minecraft/com/mojang/blaze3d/vertex/VertexConsumer.java.patch +++ b/patches/minecraft/com/mojang/blaze3d/vertex/VertexConsumer.java.patch @@ -1,7 +1,7 @@ --- a/com/mojang/blaze3d/vertex/VertexConsumer.java +++ b/com/mojang/blaze3d/vertex/VertexConsumer.java -@@ -15,7 +_,7 @@ - import org.lwjgl.system.MemoryStack; +@@ -14,7 +_,7 @@ + import org.joml.Vector3fc; @OnlyIn(Dist.CLIENT) -public interface VertexConsumer { @@ -9,15 +9,3 @@ 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_); -@@ -131,9 +_,11 @@ - - int j1 = ARGB.color(k, (int)f3, (int)f4, (int)f5); - int k1 = LightTexture.lightCoordsWithEmission(p_331444_[i1], l); -+ k1 = applyBakedLighting(k1, bytebuffer); - float f10 = bytebuffer.getFloat(16); - float f9 = bytebuffer.getFloat(20); - Vector3f vector3f1 = matrix4f.transformPosition(f, f1, f2, new Vector3f()); -+ applyBakedNormals(vector3f, bytebuffer, p_85988_.normal()); - this.addVertex(vector3f1.x(), vector3f1.y(), vector3f1.z(), j1, f10, f9, p_85993_, k1, vector3f.x(), vector3f.y(), vector3f.z()); - } - } diff --git a/patches/minecraft/com/mojang/blaze3d/vertex/VertexFormat.java.patch b/patches/minecraft/com/mojang/blaze3d/vertex/VertexFormat.java.patch index 03ac8a282b..87f3add2da 100644 --- a/patches/minecraft/com/mojang/blaze3d/vertex/VertexFormat.java.patch +++ b/patches/minecraft/com/mojang/blaze3d/vertex/VertexFormat.java.patch @@ -9,15 +9,15 @@ public static final int UNKNOWN_ELEMENT = -1; private final List elements; private final List names; -@@ -31,6 +_,7 @@ - private GpuBuffer immediateDrawVertexBuffer; - @Nullable - private GpuBuffer immediateDrawIndexBuffer; +@@ -29,6 +_,7 @@ + private final int[] offsetsByElement = new int[32]; + private @Nullable GpuBuffer immediateDrawVertexBuffer; + private @Nullable GpuBuffer immediateDrawIndexBuffer; + private final com.google.common.collect.ImmutableMap elementMapping; VertexFormat(List p_343616_, List p_345241_, IntList p_345522_, int p_344162_) { this.elements = p_343616_; -@@ -43,6 +_,11 @@ +@@ -41,6 +_,11 @@ int j = vertexformatelement != null ? p_343616_.indexOf(vertexformatelement) : -1; this.offsetsByElement[i] = j != -1 ? p_345522_.getInt(j) : -1; } @@ -29,7 +29,7 @@ } public static VertexFormat.Builder builder() { -@@ -141,6 +_,9 @@ +@@ -139,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/math/Transformation.java.patch b/patches/minecraft/com/mojang/math/Transformation.java.patch index c5a29d0353..e93bfb6862 100644 --- a/patches/minecraft/com/mojang/math/Transformation.java.patch +++ b/patches/minecraft/com/mojang/math/Transformation.java.patch @@ -1,18 +1,18 @@ --- a/com/mojang/math/Transformation.java +++ b/com/mojang/math/Transformation.java -@@ -14,7 +_,7 @@ - import org.joml.Quaternionf; - import org.joml.Vector3f; +@@ -16,7 +_,7 @@ + import org.joml.Vector3fc; + import org.jspecify.annotations.Nullable; -public final class Transformation { +public final class Transformation implements net.minecraftforge.common.extensions.IForgeTransformation { private final Matrix4fc matrix; public static final Codec CODEC = RecordCodecBuilder.create( p_269604_ -> p_269604_.group( -@@ -174,5 +_,19 @@ - vector3f1.lerp(p_175938_.getScale(), p_175939_); - quaternionf1.slerp(p_175938_.getRightRotation(), p_175939_); - return new Transformation(vector3f, quaternionf, vector3f1, quaternionf1); +@@ -168,5 +_,19 @@ + this.getScale().lerp(p_175938_.getScale(), p_175939_, new Vector3f()), + this.getRightRotation().slerp(p_175938_.getRightRotation(), p_175939_, new Quaternionf()) + ); + } + + private Matrix3f normalTransform = null; 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 65c7122a5c..8c5b232669 100644 --- a/patches/minecraft/com/mojang/realmsclient/gui/screens/RealmsGenericErrorScreen.java.patch +++ b/patches/minecraft/com/mojang/realmsclient/gui/screens/RealmsGenericErrorScreen.java.patch @@ -1,6 +1,6 @@ --- a/com/mojang/realmsclient/gui/screens/RealmsGenericErrorScreen.java +++ b/com/mojang/realmsclient/gui/screens/RealmsGenericErrorScreen.java -@@ -71,6 +_,15 @@ +@@ -62,6 +_,15 @@ } @Override @@ -15,4 +15,4 @@ + @Override public void render(GuiGraphics p_283497_, int p_88680_, int p_88681_, float p_88682_) { super.render(p_283497_, p_88680_, p_88681_, p_88682_); - p_283497_.drawCenteredString(this.font, this.lines.title, this.width / 2, 80, -1); + p_283497_.drawCenteredString(this.font, this.title, this.width / 2, 80, -1); diff --git a/patches/minecraft/com/mojang/realmsclient/gui/screens/RealmsResetWorldScreen.java.patch b/patches/minecraft/com/mojang/realmsclient/gui/screens/RealmsResetWorldScreen.java.patch new file mode 100644 index 0000000000..f11de71060 --- /dev/null +++ b/patches/minecraft/com/mojang/realmsclient/gui/screens/RealmsResetWorldScreen.java.patch @@ -0,0 +1,11 @@ +--- a/com/mojang/realmsclient/gui/screens/RealmsResetWorldScreen.java ++++ b/com/mojang/realmsclient/gui/screens/RealmsResetWorldScreen.java +@@ -263,7 +_,7 @@ + int k = this.getY(); + p_282595_.blit(RenderPipelines.GUI_TEXTURED, this.image, j + 2, k + 2, 0.0F, 0.0F, 56, 56, 56, 56, 56, 56, i); + p_282595_.blitSprite(RenderPipelines.GUI_TEXTURED, SLOT_FRAME_SPRITE, j, k, 60, 60, i); +- int l = flag ? -6250336 : -1; ++ int l = getFGColor(); + p_282595_.drawCenteredString(RealmsResetWorldScreen.this.font, this.getMessage(), j + 28, k - 14, l); + } + } diff --git a/patches/minecraft/net/minecraft/SharedConstants.java.patch b/patches/minecraft/net/minecraft/SharedConstants.java.patch index a975e2d686..a22540af53 100644 --- a/patches/minecraft/net/minecraft/SharedConstants.java.patch +++ b/patches/minecraft/net/minecraft/SharedConstants.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/SharedConstants.java +++ b/net/minecraft/SharedConstants.java -@@ -224,6 +_,7 @@ +@@ -216,6 +_,7 @@ } static { diff --git a/patches/minecraft/net/minecraft/advancements/Advancement.java.patch b/patches/minecraft/net/minecraft/advancements/Advancement.java.patch index ad03bdbfce..83c55b6745 100644 --- a/patches/minecraft/net/minecraft/advancements/Advancement.java.patch +++ b/patches/minecraft/net/minecraft/advancements/Advancement.java.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/advancements/Advancement.java +++ b/net/minecraft/advancements/Advancement.java -@@ -233,7 +_,11 @@ +@@ -231,7 +_,11 @@ } public AdvancementHolder save(Consumer p_138390_, String p_138391_) { -- AdvancementHolder advancementholder = this.build(ResourceLocation.parse(p_138391_)); -+ return save(p_138390_, ResourceLocation.parse(p_138391_)); +- AdvancementHolder advancementholder = this.build(Identifier.parse(p_138391_)); ++ return save(p_138390_, Identifier.parse(p_138391_)); + } + -+ public AdvancementHolder save(Consumer p_138390_, ResourceLocation id) { ++ public AdvancementHolder save(Consumer p_138390_, Identifier id) { + AdvancementHolder advancementholder = this.build(id); p_138390_.accept(advancementholder); return advancementholder; diff --git a/patches/minecraft/net/minecraft/advancements/AdvancementRewards.java.patch b/patches/minecraft/net/minecraft/advancements/AdvancementRewards.java.patch index ace50cc35e..14ff7b8a36 100644 --- a/patches/minecraft/net/minecraft/advancements/AdvancementRewards.java.patch +++ b/patches/minecraft/net/minecraft/advancements/AdvancementRewards.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/advancements/AdvancementRewards.java +++ b/net/minecraft/advancements/AdvancementRewards.java -@@ -43,6 +_,7 @@ +@@ -44,6 +_,7 @@ LootParams lootparams = new LootParams.Builder(serverlevel) .withParameter(LootContextParams.THIS_ENTITY, p_9990_) .withParameter(LootContextParams.ORIGIN, p_9990_.position()) diff --git a/patches/minecraft/net/minecraft/client/Camera.java.patch b/patches/minecraft/net/minecraft/client/Camera.java.patch index 2a9cd3d7e0..577ff804ab 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 -@@ -132,9 +_,13 @@ +@@ -136,9 +_,13 @@ } protected void setRotation(float p_90573_, float p_90574_) { @@ -15,10 +15,10 @@ FORWARDS.rotate(this.rotation, this.forwards); UP.rotate(this.rotation, this.up); LEFT.rotate(this.rotation, this.left); -@@ -250,6 +_,13 @@ +@@ -168,6 +_,13 @@ - public float getPartialTickTime() { - return this.partialTickTime; + public float yRot() { + return this.yRot; + } + + public net.minecraft.world.level.block.state.BlockState getBlockAtCamera() { diff --git a/patches/minecraft/net/minecraft/client/KeyMapping.java.patch b/patches/minecraft/net/minecraft/client/KeyMapping.java.patch index 1be5648d31..8b764326c0 100644 --- a/patches/minecraft/net/minecraft/client/KeyMapping.java.patch +++ b/patches/minecraft/net/minecraft/client/KeyMapping.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/client/KeyMapping.java +++ b/net/minecraft/client/KeyMapping.java @@ -19,9 +_,9 @@ - import net.minecraftforge.api.distmarker.OnlyIn; + import org.jspecify.annotations.Nullable; @OnlyIn(Dist.CLIENT) -public class KeyMapping implements Comparable { @@ -12,7 +12,7 @@ private final String name; private final InputConstants.Key defaultKey; private final KeyMapping.Category category; -@@ -38,7 +_,7 @@ +@@ -39,7 +_,7 @@ } private static void forAllKeyMappings(InputConstants.Key p_424096_, Consumer p_427756_) { @@ -21,7 +21,7 @@ if (list != null && !list.isEmpty()) { for (KeyMapping keymapping : list) { p_427756_.accept(keymapping); -@@ -100,7 +_,7 @@ +@@ -106,7 +_,7 @@ } public boolean isDown() { @@ -30,12 +30,13 @@ } public KeyMapping.Category getCategory() { -@@ -140,7 +_,16 @@ - public int compareTo(KeyMapping p_90841_) { - return this.category == p_90841_.category - ? I18n.get(this.name).compareTo(I18n.get(p_90841_.name)) -- : Integer.compare(KeyMapping.Category.SORT_ORDER.indexOf(this.category), KeyMapping.Category.SORT_ORDER.indexOf(p_90841_.category)); -+ : compareSort(this.category, p_90841_.category); +@@ -149,8 +_,17 @@ + ? I18n.get(this.name).compareTo(I18n.get(p_90841_.name)) + : Integer.compare(this.order, p_90841_.order); + } else { +- return Integer.compare(KeyMapping.Category.SORT_ORDER.indexOf(this.category), KeyMapping.Category.SORT_ORDER.indexOf(p_90841_.category)); ++ return compareSort(this.category, p_90841_.category); + } + } + + private static int compareSort(Category c1, Category c2) { @@ -48,7 +49,7 @@ } public static Supplier createNameSupplier(String p_90843_) { -@@ -149,6 +_,20 @@ +@@ -159,6 +_,20 @@ } public boolean same(KeyMapping p_90851_) { @@ -69,7 +70,7 @@ return this.key.equals(p_90851_.key); } -@@ -167,11 +_,13 @@ +@@ -177,11 +_,13 @@ } public Component getTranslatedKeyMessage() { @@ -84,7 +85,7 @@ } public String saveString() { -@@ -183,12 +_,94 @@ +@@ -193,11 +_,94 @@ } private void registerMapping(InputConstants.Key p_423386_) { @@ -92,8 +93,7 @@ + MAP.put(p_423386_, this); } - @Nullable - public static KeyMapping get(String p_378660_) { + public static @Nullable KeyMapping get(String p_378660_) { return ALL.get(p_378660_); + } + @@ -104,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, Category category) { -+ this(description, keyConflictContext, inputType.getOrCreate(keyCode), category); ++ public KeyMapping(String description, net.minecraftforge.client.settings.IKeyConflictContext keyConflictContext, final InputConstants.Type inputType, final int keyCode, Category category, int order) { ++ this(description, keyConflictContext, inputType.getOrCreate(keyCode), category, order); + } + + /** + * Convenience constructor for creating KeyBindings with keyConflictContext set. + */ -+ 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); ++ public KeyMapping(String description, net.minecraftforge.client.settings.IKeyConflictContext keyConflictContext, InputConstants.Key keyCode, Category category, int order) { ++ this(description, keyConflictContext, net.minecraftforge.client.settings.KeyModifier.NONE, keyCode, category, order); + } + + /** + * 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, Category category) { -+ this(description, keyConflictContext, keyModifier, inputType.getOrCreate(keyCode), 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, int order) { ++ this(description, keyConflictContext, keyModifier, inputType.getOrCreate(keyCode), category, order); + } + + /** + * 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, Category category) { ++ public KeyMapping(String description, net.minecraftforge.client.settings.IKeyConflictContext keyConflictContext, net.minecraftforge.client.settings.KeyModifier keyModifier, InputConstants.Key keyCode, Category category, int order) { + this.name = description; + this.key = keyCode; + this.defaultKey = keyCode; @@ -133,6 +133,7 @@ + this.keyConflictContext = keyConflictContext; + this.keyModifier = keyModifier; + this.keyModifierDefault = keyModifier; ++ this.order = order; + if (this.keyModifier.matches(keyCode)) + this.keyModifier = net.minecraftforge.client.settings.KeyModifier.NONE; + ALL.put(description, this); diff --git a/patches/minecraft/net/minecraft/client/KeyboardHandler.java.patch b/patches/minecraft/net/minecraft/client/KeyboardHandler.java.patch index cb2201e73f..c69d99d906 100644 --- a/patches/minecraft/net/minecraft/client/KeyboardHandler.java.patch +++ b/patches/minecraft/net/minecraft/client/KeyboardHandler.java.patch @@ -1,12 +1,15 @@ --- a/net/minecraft/client/KeyboardHandler.java +++ b/net/minecraft/client/KeyboardHandler.java -@@ -499,12 +_,12 @@ +@@ -497,7 +_,7 @@ if (screen != null) { try { 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; + if (options.keyDebugModifier.matches(p_423534_)) { + this.usedDebugKeyAsModifier = false; + } +@@ -506,7 +_,7 @@ } } else { screen.afterKeyboardAction(); @@ -15,7 +18,7 @@ if (this.minecraft.screen == null) { InputConstants.Key inputconstants$key = InputConstants.getKey(p_423534_); KeyMapping.set(inputconstants$key, false); -@@ -568,6 +_,7 @@ +@@ -582,6 +_,7 @@ } } } @@ -23,7 +26,7 @@ } } -@@ -576,7 +_,7 @@ +@@ -590,7 +_,7 @@ Screen screen = this.minecraft.screen; if (screen != null && this.minecraft.getOverlay() == null) { try { diff --git a/patches/minecraft/net/minecraft/client/Minecraft.java.patch b/patches/minecraft/net/minecraft/client/Minecraft.java.patch index f796dd905a..931fff65d8 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 -@@ -260,7 +_,7 @@ +@@ -265,7 +_,7 @@ import org.slf4j.Logger; @OnlyIn(Dist.CLIENT) @@ -9,7 +9,7 @@ static Minecraft instance; private static final Logger LOGGER = LogUtils.getLogger(); private static final int MAX_TICKS_PER_UPDATE = 10; -@@ -439,7 +_,6 @@ +@@ -431,7 +_,6 @@ } }, Util.nonCriticalIoPool()); LOGGER.info("Setting user: {}", this.user.getName()); @@ -17,7 +17,7 @@ this.demo = p_91084_.game.demo; this.allowsMultiplayer = !p_91084_.game.disableMultiplayer; this.allowsChat = !p_91084_.game.disableChat; -@@ -491,10 +_,9 @@ +@@ -483,10 +_,9 @@ LOGGER.error("Couldn't set icon", (Throwable)ioexception); } @@ -29,7 +29,7 @@ RenderSystem.initRenderer( this.window.handle(), this.options.glDebugVerbosity, -@@ -505,6 +_,7 @@ +@@ -498,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,7 +37,7 @@ this.resourcePackRepository.reload(); this.options.loadSelectedResourcePacks(this.resourcePackRepository); this.languageManager = new LanguageManager(this.options.languageCode, p_340763_ -> { -@@ -593,6 +_,7 @@ +@@ -585,6 +_,7 @@ this.particleResources = new ParticleResources(); this.resourceManager.registerReloadListener(this.particleResources); this.particleEngine = new ParticleEngine(this.level, this.particleResources); @@ -45,7 +45,7 @@ this.particleResources.onReload(this.particleEngine::clearParticles); this.waypointStyles = new WaypointStyleManager(); this.resourceManager.registerReloadListener(this.waypointStyles); -@@ -604,6 +_,9 @@ +@@ -596,6 +_,9 @@ this.resourceManager.registerReloadListener(this.gpuWarnlistManager); this.resourceManager.registerReloadListener(this.regionalCompliancies); this.gui = new Gui(this); @@ -55,7 +55,7 @@ RealmsClient realmsclient = RealmsClient.getOrCreate(this); this.realmsDataFetcher = new RealmsDataFetcher(realmsclient); RenderSystem.setErrorCallback(this::onFullscreenError); -@@ -636,6 +_,7 @@ +@@ -628,6 +_,7 @@ } } @@ -63,14 +63,14 @@ this.window.updateVsync(this.options.enableVsync().get()); this.window.updateRawMouseInput(this.options.rawMouseInput().get()); this.window.setAllowCursorChanges(this.options.allowCursorChanges().get()); -@@ -659,16 +_,17 @@ +@@ -651,16 +_,17 @@ GameLoadTimesEvent.INSTANCE.beginStep(TelemetryProperty.LOAD_TIME_LOADING_OVERLAY_MS); Minecraft.GameLoadCookie minecraft$gameloadcookie = new Minecraft.GameLoadCookie(realmsclient, p_91084_.quickPlay); this.setOverlay( - new LoadingOverlay( -- this, reloadinstance, p_296164_ -> Util.ifElse(p_296164_, p_296162_ -> this.rollbackResourcePacks(p_296162_, minecraft$gameloadcookie), () -> { +- this, reloadinstance, p_447796_ -> Util.ifElse(p_447796_, p_296162_ -> this.rollbackResourcePacks(p_296162_, minecraft$gameloadcookie), () -> { + net.minecraftforge.fml.loading.ImmediateWindowHandler.loadingOverlay( -+ () -> this, () -> reloadinstance, p_296164_ -> Util.ifElse(p_296164_, p_296162_ -> this.rollbackResourcePacks(p_296162_, minecraft$gameloadcookie), () -> { ++ () -> this, () -> reloadinstance, p_296164_ -> Util.ifElse(p_296164_, p_447796_ -> this.rollbackResourcePacks(p_447796_, minecraft$gameloadcookie), () -> { if (SharedConstants.IS_RUNNING_IN_IDE) { this.selfTest(); } @@ -84,7 +84,7 @@ ); this.quickPlayLog = QuickPlayLog.of(p_91084_.quickPlay.logPath()); this.framerateLimitTracker = new FramerateLimitTracker(this.options, this); -@@ -787,6 +_,7 @@ +@@ -779,6 +_,7 @@ StringBuilder stringbuilder = new StringBuilder("Minecraft"); if (checkModStatus().shouldReportAsModified()) { stringbuilder.append("*"); @@ -92,7 +92,7 @@ } stringbuilder.append(" "); -@@ -810,6 +_,8 @@ +@@ -802,6 +_,8 @@ } private UserApiService createUserApiService(YggdrasilAuthenticationService p_193586_, GameConfig p_193587_) { @@ -101,16 +101,16 @@ return p_193587_.game.offlineDeveloperMode ? UserApiService.OFFLINE : p_193586_.createUserApiService(p_193587_.user.user.getAccessToken()); } -@@ -822,7 +_,7 @@ +@@ -814,7 +_,7 @@ } - private void rollbackResourcePacks(Throwable p_91240_, @Nullable Minecraft.GameLoadCookie p_299515_) { + private void rollbackResourcePacks(Throwable p_91240_, Minecraft.@Nullable GameLoadCookie p_299515_) { - if (this.resourcePackRepository.getSelectedIds().size() > 1) { + if (this.resourcePackRepository.getSelectedPacks().stream().anyMatch(e -> !e.isRequired())) { //Forge: This caused infinite loop if any resource packs are forced. Such as mod resources. So check if we can disable any. this.clearResourcePacksOnError(p_91240_, null, p_299515_); } else { Util.throwAsRuntime(p_91240_); -@@ -1108,12 +_,6 @@ +@@ -1100,12 +_,6 @@ LOGGER.error("setScreen called from non-game thread"); } @@ -123,7 +123,7 @@ if (p_91153_ == null) { if (this.clientLevelTeardownInProgress) { throw new IllegalStateException("Trying to return to in-game GUI during disconnection"); -@@ -1132,6 +_,23 @@ +@@ -1124,6 +_,23 @@ } } @@ -147,28 +147,28 @@ this.screen = p_91153_; if (this.screen != null) { this.screen.added(); -@@ -1214,6 +_,7 @@ - FreeTypeUtil.destroy(); +@@ -1207,6 +_,7 @@ Util.shutdownExecutors(); + RenderSystem.getSamplerCache().close(); RenderSystem.getDevice().close(); + net.minecraftforge.fml.config.ConfigTracker.INSTANCE.forceUnload(); } catch (Throwable throwable) { LOGGER.error("Shutdown failure!", throwable); throw throwable; -@@ -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); - this.gameRenderer.render(this.deltaTracker, p_91384_); -+ net.minecraftforge.client.event.ForgeEventFactoryClient.onRenderTickEnd(this.deltaTracker); - } +@@ -1289,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); + this.gameRenderer.render(this.deltaTracker, p_91384_); ++ net.minecraftforge.client.event.ForgeEventFactoryClient.onRenderTickEnd(this.deltaTracker); + } - profilerfiller.popPush("blit"); -@@ -1388,10 +_,12 @@ + profilerfiller.popPush("blit"); +@@ -1401,10 +_,12 @@ this.window.setGuiScale(i); if (this.screen != null) { - this.screen.resize(this, this.window.getGuiScaledWidth(), this.window.getGuiScaledHeight()); + this.screen.resize(this.window.getGuiScaledWidth(), this.window.getGuiScaledHeight()); + net.minecraftforge.client.ForgeHooksClient.resizeGuiLayers(this, this.window.getGuiScaledWidth(), this.window.getGuiScaledHeight()); } @@ -178,7 +178,7 @@ this.gameRenderer.resize(this.window.getWidth(), this.window.getHeight()); this.mouseHandler.setIgnoreFirstMove(); } -@@ -1529,6 +_,7 @@ +@@ -1542,6 +_,7 @@ } public void stop() { @@ -186,58 +186,59 @@ this.running = false; } -@@ -1556,10 +_,18 @@ - if (p_91387_ && this.hitResult != null && this.hitResult.getType() == HitResult.Type.BLOCK) { - BlockHitResult blockhitresult = (BlockHitResult)this.hitResult; - BlockPos blockpos = blockhitresult.getBlockPos(); -- if (!this.level.getBlockState(blockpos).isAir()) { -+ if (!this.level.isEmptyBlock(blockpos)) { +@@ -1571,10 +_,18 @@ + if (p_91387_ && this.hitResult != null && this.hitResult.getType() == HitResult.Type.BLOCK) { + BlockHitResult blockhitresult = (BlockHitResult)this.hitResult; + BlockPos blockpos = blockhitresult.getBlockPos(); +- if (!this.level.getBlockState(blockpos).isAir()) { ++ if (!this.level.isEmptyBlock(blockpos)) { ++ 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.level.addBreakingBlockEffect(blockpos, blockhitresult); ++ this.player.swing(InteractionHand.MAIN_HAND); ++ } ++ return; ++ } + Direction direction = blockhitresult.getDirection(); +- if (this.gameMode.continueDestroyBlock(blockpos, direction)) { +- this.level.addBreakingBlockEffect(blockpos, direction); ++ if (this.gameMode.continueDestroyBlock(blockpos, direction) && inputEvent.shouldSwingHand()) { ++ this.level.addBreakingBlockEffect(blockpos, blockhitresult); + this.player.swing(InteractionHand.MAIN_HAND); + } + } +@@ -1611,6 +_,8 @@ + this.player.swing(InteractionHand.MAIN_HAND); + return true; + } else { + 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.level.addBreakingBlockEffect(blockpos, blockhitresult); -+ this.player.swing(InteractionHand.MAIN_HAND); -+ } -+ return; -+ } - Direction direction = blockhitresult.getDirection(); -- if (this.gameMode.continueDestroyBlock(blockpos, direction)) { -- this.level.addBreakingBlockEffect(blockpos, direction); -+ if (this.gameMode.continueDestroyBlock(blockpos, direction) && inputEvent.shouldSwingHand()) { -+ this.level.addBreakingBlockEffect(blockpos, blockhitresult); ++ if (!net.minecraftforge.client.event.InputEvent.InteractionKeyMappingTriggered.BUS.post(inputEvent)) + switch (this.hitResult.getType()) { + case ENTITY: + AttackRange attackrange = itemstack.get(DataComponents.ATTACK_RANGE); +@@ -1621,7 +_,7 @@ + case BLOCK: + BlockHitResult blockhitresult = (BlockHitResult)this.hitResult; + BlockPos blockpos = blockhitresult.getBlockPos(); +- if (!this.level.getBlockState(blockpos).isAir()) { ++ if (!this.level.isEmptyBlock(blockpos)) { + this.gameMode.startDestroyBlock(blockpos, blockhitresult.getDirection()); + if (this.level.getBlockState(blockpos).isAir()) { + flag = true; +@@ -1634,9 +_,10 @@ + } + + this.player.resetAttackStrengthTicker(); ++ net.minecraftforge.event.ForgeEventFactory.onLeftClickEmpty(this.player); + } + +- if (!this.player.isSpectator()) { ++ if (!this.player.isSpectator() && inputEvent.shouldSwingHand()) { this.player.swing(InteractionHand.MAIN_HAND); } - } -@@ -1587,6 +_,8 @@ - return false; - } else { - boolean flag = false; -+ 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)) - switch (this.hitResult.getType()) { - case ENTITY: - this.gameMode.attack(this.player, ((EntityHitResult)this.hitResult).getEntity()); -@@ -1594,7 +_,7 @@ - case BLOCK: - BlockHitResult blockhitresult = (BlockHitResult)this.hitResult; - BlockPos blockpos = blockhitresult.getBlockPos(); -- if (!this.level.getBlockState(blockpos).isAir()) { -+ if (!this.level.isEmptyBlock(blockpos)) { - this.gameMode.startDestroyBlock(blockpos, blockhitresult.getDirection()); - if (this.level.getBlockState(blockpos).isAir()) { - flag = true; -@@ -1607,8 +_,10 @@ - } - this.player.resetAttackStrengthTicker(); -+ net.minecraftforge.event.ForgeEventFactory.onLeftClickEmpty(this.player); - } - -+ if (inputEvent.shouldSwingHand()) - this.player.swing(InteractionHand.MAIN_HAND); - return flag; - } -@@ -1624,6 +_,12 @@ +@@ -1655,6 +_,12 @@ } for (InteractionHand interactionhand : InteractionHand.values()) { @@ -250,16 +251,16 @@ ItemStack itemstack = this.player.getItemInHand(interactionhand); if (!itemstack.isItemEnabled(this.level.enabledFeatures())) { return; -@@ -1644,7 +_,7 @@ - } - - if (interactionresult instanceof InteractionResult.Success interactionresult$success2) { -- if (interactionresult$success2.swingSource() == InteractionResult.SwingSource.CLIENT) { -+ if (interactionresult$success2.swingSource() == InteractionResult.SwingSource.CLIENT && inputEvent.shouldSwingHand()) { - this.player.swing(interactionhand); +@@ -1676,7 +_,7 @@ } -@@ -1656,7 +_,7 @@ + if (interactionresult instanceof InteractionResult.Success interactionresult$success2) { +- if (interactionresult$success2.swingSource() == InteractionResult.SwingSource.CLIENT) { ++ if (interactionresult$success2.swingSource() == InteractionResult.SwingSource.CLIENT && inputEvent.shouldSwingHand()) { + this.player.swing(interactionhand); + } + +@@ -1689,7 +_,7 @@ int i = itemstack.getCount(); InteractionResult interactionresult1 = this.gameMode.useItemOn(this.player, interactionhand, blockhitresult); if (interactionresult1 instanceof InteractionResult.Success interactionresult$success) { @@ -268,7 +269,7 @@ this.player.swing(interactionhand); if (!itemstack.isEmpty() && (itemstack.getCount() != i || this.player.hasInfiniteMaterials())) { this.gameRenderer.itemInHandRenderer.itemUsed(interactionhand); -@@ -1672,6 +_,9 @@ +@@ -1705,6 +_,9 @@ } } @@ -278,7 +279,7 @@ if (!itemstack.isEmpty() && this.gameMode.useItem(this.player, interactionhand) instanceof InteractionResult.Success interactionresult$success1) { if (interactionresult$success1.swingSource() == InteractionResult.SwingSource.CLIENT) { -@@ -1701,6 +_,8 @@ +@@ -1734,6 +_,8 @@ } ProfilerFiller profilerfiller = Profiler.get(); @@ -287,7 +288,7 @@ profilerfiller.push("gui"); this.chatListener.tick(); this.gui.tick(this.pause); -@@ -1786,6 +_,7 @@ +@@ -1815,6 +_,7 @@ this.tutorial.tick(); @@ -295,7 +296,7 @@ try { this.level.tick(() -> true); } catch (Throwable throwable1) { -@@ -1799,6 +_,7 @@ +@@ -1828,6 +_,7 @@ throw new ReportedException(crashreport1); } @@ -303,7 +304,7 @@ } profilerfiller.popPush("animateTick"); -@@ -1823,6 +_,7 @@ +@@ -1852,6 +_,7 @@ profilerfiller.popPush("keyboard"); this.keyboardHandler.tick(); profilerfiller.pop(); @@ -311,7 +312,7 @@ } private boolean isLevelRunningNormally() { -@@ -2041,6 +_,7 @@ +@@ -2070,6 +_,7 @@ } public void setLevel(ClientLevel p_91157_) { @@ -319,7 +320,7 @@ this.level = p_91157_; this.updateLevelInEngines(p_91157_); } -@@ -2094,6 +_,7 @@ +@@ -2131,6 +_,7 @@ IntegratedServer integratedserver = this.singleplayerServer; this.singleplayerServer = null; this.gameRenderer.resetData(); @@ -327,7 +328,7 @@ this.gameMode = null; this.narrator.clear(); this.clientLevelTeardownInProgress = true; -@@ -2101,6 +_,7 @@ +@@ -2138,6 +_,7 @@ try { if (this.level != null) { this.gui.onDisconnected(); @@ -335,15 +336,15 @@ } if (integratedserver != null) { -@@ -2113,6 +_,7 @@ +@@ -2150,6 +_,7 @@ } profilerfiller.pop(); + net.minecraftforge.client.ForgeHooksClient.handleClientLevelClosing(this.level); } - this.setScreenAndShow(p_335030_); -@@ -2254,6 +_,7 @@ + this.setScreenAndShow(p_457642_); +@@ -2292,6 +_,7 @@ private void pickBlock() { if (this.hitResult != null && this.hitResult.getType() != HitResult.Type.MISS) { diff --git a/patches/minecraft/net/minecraft/client/MouseHandler.java.patch b/patches/minecraft/net/minecraft/client/MouseHandler.java.patch index 4de657a4c5..115936b269 100644 --- a/patches/minecraft/net/minecraft/client/MouseHandler.java.patch +++ b/patches/minecraft/net/minecraft/client/MouseHandler.java.patch @@ -8,16 +8,16 @@ if (this.minecraft.getOverlay() == null) { if (this.minecraft.screen == null) { if (!this.mouseGrabbed && flag) { -@@ -103,7 +_,7 @@ - try { - long i = Util.getMillis(); - boolean flag1 = i - this.lastClickTime < 250L && this.lastClickButton == mousebuttonevent.button(); +@@ -106,7 +_,7 @@ + && i - this.lastClick.time() < 250L + && this.lastClick.screen() == screen + && 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.lastClick = new MouseHandler.LastClick(i, screen); this.lastClickButton = mousebuttoninfo.button(); return; -@@ -118,7 +_,7 @@ +@@ -121,7 +_,7 @@ } } else { try { @@ -26,7 +26,7 @@ return; } } catch (Throwable throwable) { -@@ -148,6 +_,7 @@ +@@ -151,6 +_,7 @@ KeyMapping.click(inputconstants$key); } } @@ -34,7 +34,7 @@ } } -@@ -204,7 +_,9 @@ +@@ -207,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); -@@ -213,6 +_,7 @@ +@@ -216,6 +_,7 @@ } int i = vector2i.y == 0 ? -vector2i.x : vector2i.y; @@ -53,7 +53,7 @@ if (this.minecraft.player.isSpectator()) { if (this.minecraft.gui.getSpectatorGui().isMenuActive()) { this.minecraft.gui.getSpectatorGui().onMouseScrolled(-i); -@@ -321,7 +_,7 @@ +@@ -324,7 +_,7 @@ double d5 = getScaledYPos(window, this.accumulatedDY); try { @@ -62,7 +62,7 @@ } catch (Throwable throwable) { CrashReport crashreport1 = CrashReport.forThrowable(throwable, "mouseDragged event handler"); screen.fillCrashDetails(crashreport1); -@@ -408,6 +_,14 @@ +@@ -411,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 3e8c79d722..84379c7f31 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 -@@ -709,7 +_,8 @@ +@@ -816,7 +_,8 @@ }, new OptionInstance.LazyEnum<>( () -> Stream.concat(Stream.of(""), Minecraft.getInstance().getSoundManager().getAvailableSoundDevices().stream()).toList(), @@ -10,15 +10,15 @@ ? Optional.empty() : Optional.of(p_232011_), Codec.STRING -@@ -743,6 +_,7 @@ +@@ -848,6 +_,7 @@ ); public boolean syncWrites; public boolean startedCleanly = true; + private final Map unknownKeys = new java.util.HashMap<>(); - public OptionInstance darkMojangStudiosBackground() { - return this.darkMojangStudiosBackground; -@@ -1150,6 +_,7 @@ + private static void operateOnLevelRenderer(Consumer p_457625_) { + LevelRenderer levelrenderer = Minecraft.getInstance().levelRenderer; +@@ -1313,6 +_,7 @@ } public Options(Minecraft p_92138_, File p_92139_) { @@ -26,9 +26,9 @@ this.minecraft = p_92138_; this.optionsFile = new File(p_92139_, "options.txt"); boolean flag = Runtime.getRuntime().maxMemory() >= 1000000000L; -@@ -1290,15 +_,28 @@ +@@ -1463,15 +_,28 @@ this.startedCleanly = p_168428_.process("startedCleanly", this.startedCleanly); - p_168428_.process("showNowPlayingToast", this.showNowPlayingToast); + p_168428_.process("musicToast", this.musicToast); p_168428_.process("musicFrequency", this.musicFrequency); + processOptionsKeysOnly(p_168428_); + processOptionsEnd(p_168428_); @@ -56,7 +56,7 @@ for (SoundSource soundsource : SoundSource.values()) { p_168428_.process("soundCategory_" + soundsource.getName(), this.soundSourceVolumes.get(soundsource)); } -@@ -1313,6 +_,10 @@ +@@ -1486,6 +_,10 @@ } public void load() { @@ -67,17 +67,17 @@ try { if (!this.optionsFile.exists()) { return; -@@ -1337,7 +_,8 @@ - this.graphicsMode.set(isTrue(optional.get()) ? GraphicsStatus.FANCY : GraphicsStatus.FAST); +@@ -1505,7 +_,8 @@ } + final CompoundTag compoundtag1 = this.dataFix(compoundtag); - this.processOptions( + java.util.function.Consumer processor = limited ? this::processOptionsKeysOnly : this::processOptions; + processor.accept( new Options.FieldAccess() { - @Nullable - private String getValue(String p_394210_) { -@@ -1418,6 +_,17 @@ + private @Nullable String getValue(String p_394210_) { + Tag tag = compoundtag1.get(p_394210_); +@@ -1585,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); } -@@ -1445,9 +_,11 @@ +@@ -1612,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(':'); } -@@ -1503,6 +_,12 @@ +@@ -1670,6 +_,12 @@ if (s != null) { printwriter.println("fullscreenResolution:" + s); } @@ -120,7 +120,7 @@ } catch (Exception exception) { LOGGER.error("Failed to save options", (Throwable)exception); } -@@ -1541,6 +_,7 @@ +@@ -1707,6 +_,7 @@ } public void broadcastOptions() { @@ -128,7 +128,7 @@ if (this.minecraft.player != null) { this.minecraft.player.connection.broadcastClientInformation(this.buildPlayerInformation()); } -@@ -1654,6 +_,23 @@ +@@ -1820,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/Screenshot.java.patch b/patches/minecraft/net/minecraft/client/Screenshot.java.patch index cfe3460945..00d0e36e11 100644 --- a/patches/minecraft/net/minecraft/client/Screenshot.java.patch +++ b/patches/minecraft/net/minecraft/client/Screenshot.java.patch @@ -4,7 +4,7 @@ file2 = new File(file1, p_92297_); } -+ var event = new net.minecraftforge.client.event.ScreenshotEvent(p_389141_, file2); ++ var event = new net.minecraftforge.client.event.ScreenshotEvent(p_447863_, file2); + if (net.minecraftforge.client.event.ScreenshotEvent.BUS.post(event)) { + p_92301_.accept(event.getCancelMessage()); + return; @@ -15,12 +15,12 @@ .execute( () -> { @@ -50,10 +_,13 @@ - NativeImage $$4x = p_389141_; + NativeImage $$4x = p_447863_; try { -- p_389141_.writeToFile(file2); +- p_447863_.writeToFile(file2); - Component component = Component.literal(file2.getName()) -+ p_389141_.writeToFile(target); ++ p_447863_.writeToFile(target); + Component component = Component.literal(target.getName()) .withStyle(ChatFormatting.UNDERLINE) .withStyle(p_389149_ -> p_389149_.withClickEvent(new ClickEvent.OpenFile(file2.getAbsoluteFile()))); @@ -29,4 +29,4 @@ + else p_92301_.accept(Component.translatable("screenshot.success", component)); } catch (Throwable throwable1) { - if (p_389141_ != null) { + if (p_447863_ != null) { diff --git a/patches/minecraft/net/minecraft/client/data/Main.java.patch b/patches/minecraft/net/minecraft/client/data/Main.java.patch index 7c2c9e3a5a..bcf0229d80 100644 --- a/patches/minecraft/net/minecraft/client/data/Main.java.patch +++ b/patches/minecraft/net/minecraft/client/data/Main.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/data/Main.java +++ b/net/minecraft/client/data/Main.java -@@ -31,13 +_,18 @@ +@@ -30,13 +_,18 @@ OptionSpec optionspec1 = optionparser.accepts("client", "Include client generators"); OptionSpec optionspec2 = optionparser.accepts("all", "Include all generators"); OptionSpec optionspec3 = optionparser.accepts("output", "Output folder").withRequiredArg().defaultsTo("generated"); 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 0fa8c2ce96..0e51e543ac 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 -@@ -882,6 +_,9 @@ +@@ -912,6 +_,9 @@ this.declareCustomModelItem(Items.COD); this.declareCustomModelItem(Items.FEATHER); this.declareCustomModelItem(Items.LEAD); diff --git a/patches/minecraft/net/minecraft/client/data/models/ModelProvider.java.patch b/patches/minecraft/net/minecraft/client/data/models/ModelProvider.java.patch index 21bc63f439..10244c1a92 100644 --- a/patches/minecraft/net/minecraft/client/data/models/ModelProvider.java.patch +++ b/patches/minecraft/net/minecraft/client/data/models/ModelProvider.java.patch @@ -21,11 +21,11 @@ } + protected Stream getKnownBlocks() { -+ return BuiltInRegistries.BLOCK.stream().filter(block -> "minecraft".equals(block.builtInRegistryHolder().key().location().getNamespace())); ++ return BuiltInRegistries.BLOCK.stream().filter(block -> "minecraft".equals(block.builtInRegistryHolder().key().identifier().getNamespace())); + } + + protected Stream getKnownItems() { -+ return BuiltInRegistries.ITEM.stream().filter(item -> "minecraft".equals(item.builtInRegistryHolder().key().location().getNamespace())); ++ return BuiltInRegistries.ITEM.stream().filter(item -> "minecraft".equals(item.builtInRegistryHolder().key().identifier().getNamespace())); + } + + protected BlockModelGenerators getBlockModelGenerators(BlockStateGeneratorCollector blocks, ItemInfoCollector items, SimpleModelCollector models) { @@ -46,7 +46,7 @@ + private final Supplier> known; + + public BlockStateGeneratorCollector() { -+ this(() -> BuiltInRegistries.BLOCK.stream().filter(block -> "minecraft".equals(block.builtInRegistryHolder().key().location().getNamespace()))); ++ this(() -> BuiltInRegistries.BLOCK.stream().filter(block -> "minecraft".equals(block.builtInRegistryHolder().key().identifier().getNamespace()))); + } + + public BlockStateGeneratorCollector(Supplier> known) { @@ -61,8 +61,8 @@ public void validate() { - Stream> stream = BuiltInRegistries.BLOCK.listElements().filter(p_376480_ -> true); + Stream> stream = known.get().map(Block::builtInRegistryHolder); - List list = stream.filter(p_378423_ -> !this.generators.containsKey(p_378423_.value())) - .map(p_378200_ -> p_378200_.key().location()) + List list = stream.filter(p_378423_ -> !this.generators.containsKey(p_378423_.value())) + .map(p_447940_ -> p_447940_.key().identifier()) .toList(); @@ -97,6 +_,15 @@ public static class ItemInfoCollector implements ItemModelOutput { @@ -71,7 +71,7 @@ + private final Supplier> known; + + public ItemInfoCollector() { -+ this(() -> BuiltInRegistries.ITEM.stream().filter(item -> "minecraft".equals(item.builtInRegistryHolder().key().location().getNamespace()))); ++ this(() -> BuiltInRegistries.ITEM.stream().filter(item -> "minecraft".equals(item.builtInRegistryHolder().key().identifier().getNamespace()))); + } + + public ItemInfoCollector(Supplier> known) { @@ -79,16 +79,16 @@ + } @Override - public void accept(Item p_376450_, ItemModel.Unbaked p_378513_) { + public void accept(Item p_376450_, ItemModel.Unbaked p_378513_, ClientItem.Properties p_455809_) { @@ -115,7 +_,7 @@ this.copies.put(p_376965_, p_377438_); } - public void finalizeAndValidate() { + public void generateDefaultBlockModels() { - BuiltInRegistries.ITEM.forEach(p_378629_ -> { - if (!this.copies.containsKey(p_378629_)) { - if (p_378629_ instanceof BlockItem blockitem && !this.itemInfos.containsKey(blockitem)) { + BuiltInRegistries.ITEM.forEach(p_447944_ -> { + if (!this.copies.containsKey(p_447944_)) { + if (p_447944_ instanceof BlockItem blockitem && !this.itemInfos.containsKey(blockitem)) { @@ -124,6 +_,8 @@ } } @@ -102,10 +102,10 @@ this.register(p_376289_, clientitem); } }); -- List list = BuiltInRegistries.ITEM +- List list = BuiltInRegistries.ITEM - .listElements() -+ List list = known.get() ++ List list = known.get() + .map(item -> item.builtInRegistryHolder()) .filter(p_377225_ -> !this.itemInfos.containsKey(p_377225_.value())) - .map(p_378591_ -> p_378591_.key().location()) + .map(p_447943_ -> p_447943_.key().identifier()) .toList(); diff --git a/patches/minecraft/net/minecraft/client/gui/Font.java.patch b/patches/minecraft/net/minecraft/client/gui/Font.java.patch index 2734d1875c..b1f7cfe172 100644 --- a/patches/minecraft/net/minecraft/client/gui/Font.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/Font.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/client/gui/Font.java +++ b/net/minecraft/client/gui/Font.java -@@ -31,7 +_,7 @@ - import org.joml.Matrix4f; +@@ -32,7 +_,7 @@ + import org.jspecify.annotations.Nullable; @OnlyIn(Dist.CLIENT) -public class Font { diff --git a/patches/minecraft/net/minecraft/client/gui/Gui.java.patch b/patches/minecraft/net/minecraft/client/gui/Gui.java.patch index bd12945d45..2e4041d577 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; -@@ -196,6 +_,7 @@ +@@ -193,6 +_,7 @@ () -> new JumpableVehicleBarRenderer(p_330021_) ); this.resetTitleTimes(); @@ -17,7 +17,7 @@ } public void resetTitleTimes() { -@@ -206,6 +_,10 @@ +@@ -203,6 +_,10 @@ public void render(GuiGraphics p_282884_, DeltaTracker p_342095_) { if (!(this.minecraft.screen instanceof LevelLoadingScreen)) { @@ -28,16 +28,16 @@ if (!this.minecraft.options.hideGui) { this.renderCameraOverlays(p_282884_, p_342095_); this.renderCrosshair(p_282884_, p_342095_); -@@ -389,7 +_,7 @@ +@@ -386,7 +_,7 @@ int i = Mth.floor(this.minecraft.mouseHandler.getScaledXPos(window)); int j = Mth.floor(this.minecraft.mouseHandler.getScaledYPos(window)); p_329202_.nextStratum(); -- this.chat.render(p_329202_, this.tickCount, i, j, false); -+ net.minecraftforge.client.ForgeHooksClient.onCustomizeChatEvent(p_329202_, this.chat, window, i, j, this.tickCount); +- this.chat.render(p_329202_, this.getFont(), this.tickCount, i, j, false, false); ++ net.minecraftforge.client.ForgeHooksClient.onCustomizeChatEvent(p_329202_, this.chat, window, i, j, this.tickCount, this.getFont()); } } -@@ -477,6 +_,8 @@ +@@ -476,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; -@@ -507,6 +_,7 @@ +@@ -506,6 +_,7 @@ } } @@ -54,7 +54,7 @@ p_282812_.blitSprite(RenderPipelines.GUI_TEXTURED, getMobEffectSprite(holder), k + 3, l + 3, 18, 18, ARGB.white(f)); } } -@@ -603,6 +_,10 @@ +@@ -602,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()); -@@ -610,9 +_,13 @@ +@@ -609,9 +_,13 @@ mutablecomponent.withStyle(ChatFormatting.ITALIC); } @@ -81,16 +81,16 @@ if (!this.minecraft.gameMode.canHurtPlayer()) { k += 14; } -@@ -623,7 +_,7 @@ +@@ -622,7 +_,7 @@ } if (l > 0) { -- p_283501_.drawStringWithBackdrop(this.getFont(), mutablecomponent, j, k, i, ARGB.color(l, -1)); -+ p_283501_.drawStringWithBackdrop(font, highlightTip, j, k, i, ARGB.color(l, -1)); +- p_283501_.drawStringWithBackdrop(this.getFont(), mutablecomponent, j, k, i, ARGB.white(l)); ++ p_283501_.drawStringWithBackdrop(font, highlightTip, j, k, i, ARGB.white(l)); } } -@@ -1151,7 +_,7 @@ +@@ -1148,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 78a3380751..7a27b0d1fa 100644 --- a/patches/minecraft/net/minecraft/client/gui/GuiGraphics.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/GuiGraphics.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/client/gui/GuiGraphics.java +++ b/net/minecraft/client/gui/GuiGraphics.java -@@ -83,7 +_,7 @@ - import org.joml.Vector3f; +@@ -86,7 +_,7 @@ + import org.jspecify.annotations.Nullable; @OnlyIn(Dist.CLIENT) -public class GuiGraphics { +public class GuiGraphics implements net.minecraftforge.client.extensions.IForgeGuiGraphics { private static final int EXTRA_SPACE_AFTER_FIRST_TOOLTIP_LINE = 2; - private final Minecraft minecraft; + final Minecraft minecraft; private final Matrix3x2fStack pose; -@@ -950,6 +_,7 @@ +@@ -972,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); -@@ -968,6 +_,7 @@ +@@ -990,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 @@ } } -@@ -979,21 +_,30 @@ +@@ -1001,21 +_,30 @@ this.setTooltipForNextFrame(this.minecraft.font, p_407686_, DefaultTooltipPositioner.INSTANCE, p_410475_, p_407139_, false); } @@ -50,15 +50,15 @@ + } + public void setTooltipForNextFrame( - Font p_407847_, List p_408847_, Optional p_410489_, int p_409369_, int p_407472_, @Nullable ResourceLocation p_410303_ + Font p_408450_, List p_405939_, Optional p_456997_, int p_409519_, int p_410392_, @Nullable Identifier p_460731_ ) { -- List list = p_408847_.stream().map(Component::getVisualOrderText).map(ClientTooltipComponent::create).collect(Util.toMutableList()); -- p_410489_.ifPresent(p_325321_ -> list.add(list.isEmpty() ? 0 : 1, ClientTooltipComponent.create(p_325321_))); -+ List list = net.minecraftforge.client.ForgeHooksClient.gatherTooltipComponents(this.tooltipStack, p_408847_, p_410489_, p_409369_, guiWidth(), guiHeight(), p_407847_); - this.setTooltipForNextFrameInternal(p_407847_, list, p_409369_, p_407472_, DefaultTooltipPositioner.INSTANCE, p_410303_, false); +- List list = p_405939_.stream().map(Component::getVisualOrderText).map(ClientTooltipComponent::create).collect(Util.toMutableList()); +- p_456997_.ifPresent(p_325321_ -> list.add(list.isEmpty() ? 0 : 1, ClientTooltipComponent.create(p_325321_))); ++ List list = net.minecraftforge.client.ForgeHooksClient.gatherTooltipComponents(this.tooltipStack, p_405939_, p_456997_, p_409519_, guiWidth(), guiHeight(), p_408450_); + this.setTooltipForNextFrameInternal(p_408450_, list, p_409519_, p_410392_, DefaultTooltipPositioner.INSTANCE, p_460731_, false); } -@@ -1006,7 +_,22 @@ +@@ -1028,7 +_,22 @@ } public void setComponentTooltipForNextFrame(Font p_406239_, List p_410275_, int p_410594_, int p_409343_) { @@ -81,32 +81,33 @@ + this.tooltipStack = ItemStack.EMPTY; } - public void setComponentTooltipForNextFrame(Font p_408650_, List p_407512_, int p_406019_, int p_408123_, @Nullable ResourceLocation p_409993_) { -@@ -1056,9 +_,14 @@ + public void setComponentTooltipForNextFrame(Font p_408650_, List p_407512_, int p_406019_, int p_408123_, @Nullable Identifier p_456486_) { +@@ -1073,24 +_,31 @@ + int p_407794_, + int p_408784_, + ClientTooltipPositioner p_408798_, +- @Nullable Identifier p_451079_, ++ @Nullable Identifier p_456486_, + boolean p_410618_ ) { if (!p_409928_.isEmpty()) { if (this.deferredTooltip == null || p_410618_) { -- this.deferredTooltip = () -> this.renderTooltip(p_406605_, p_409928_, p_407794_, p_408784_, p_408798_, p_407676_); +- this.deferredTooltip = () -> this.renderTooltip(p_406605_, p_409928_, p_407794_, p_408784_, p_408798_, p_451079_); + final var stackContext = this.tooltipStack; -+ this.deferredTooltip = () -> this.renderTooltip(p_406605_, p_409928_, p_407794_, p_408784_, p_408798_, p_407676_, stackContext); ++ this.deferredTooltip = () -> this.renderTooltip(p_406605_, p_409928_, p_407794_, p_408784_, p_408798_, p_456486_, stackContext); } } + } + -+ public void renderTooltip(Font p_283128_, List p_282716_, int p_283678_, int p_281696_, ClientTooltipPositioner p_409451_, @Nullable ResourceLocation p_409298_) { -+ renderTooltip(p_283128_, p_282716_, p_283678_, p_281696_, p_409451_, p_409298_, ItemStack.EMPTY); ++ public void renderTooltip(Font p_283128_, List p_282716_, int p_283678_, int p_281696_, ClientTooltipPositioner p_409451_, @Nullable Identifier p_456486_) { ++ renderTooltip(p_283128_, p_282716_, p_283678_, p_281696_, p_409451_, p_456486_, ItemStack.EMPTY); } public void renderTooltip( -@@ -1067,13 +_,16 @@ - int p_283678_, - int p_281696_, - ClientTooltipPositioner p_409451_, -- @Nullable ResourceLocation p_409298_ -+ @Nullable ResourceLocation p_409298_, -+ ItemStack itemstack +- Font p_283128_, List p_282716_, int p_283678_, int p_281696_, ClientTooltipPositioner p_409451_, @Nullable Identifier p_459396_ ++ Font p_283128_, List p_282716_, int p_283678_, int p_281696_, ClientTooltipPositioner p_409451_, @Nullable Identifier p_459396_, ItemStack itemstack ) { -+ var preEvent = net.minecraftforge.client.ForgeHooksClient.onRenderTooltipPre(itemstack, this, p_283678_, p_281696_, guiWidth(), guiHeight(), p_282716_, p_283128_, p_409451_, p_409298_); ++ var preEvent = net.minecraftforge.client.ForgeHooksClient.onRenderTooltipPre(itemstack, this, p_283678_, p_281696_, guiWidth(), guiHeight(), p_282716_, p_283128_, p_409451_, p_459396_); + if (preEvent == null) return; int i = 0; int j = p_282716_.size() == 1 ? -2 : 0; @@ -117,7 +118,7 @@ if (k > i) { i = k; } -@@ -1083,16 +_,16 @@ +@@ -1100,16 +_,16 @@ int l1 = i; int i2 = j; @@ -126,7 +127,7 @@ int l = vector2ic.x(); int i1 = vector2ic.y(); this.pose.pushMatrix(); -- TooltipRenderUtil.renderTooltipBackground(this, l, i1, i, j, p_409298_); +- TooltipRenderUtil.renderTooltipBackground(this, l, i1, i, j, p_459396_); + TooltipRenderUtil.renderTooltipBackground(this, l, i1, i, j, preEvent.getBackground()); int j1 = i1; @@ -137,7 +138,7 @@ j1 += clienttooltipcomponent1.getHeight(p_283128_) + (k1 == 0 ? 2 : 0); } -@@ -1100,7 +_,7 @@ +@@ -1117,7 +_,7 @@ for (int j2 = 0; j2 < p_282716_.size(); j2++) { ClientTooltipComponent clienttooltipcomponent2 = p_282716_.get(j2); @@ -146,7 +147,7 @@ j1 += clienttooltipcomponent2.getHeight(p_283128_) + (j2 == 0 ? 2 : 0); } -@@ -1315,6 +_,14 @@ +@@ -1328,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())); diff --git a/patches/minecraft/net/minecraft/client/gui/components/AbstractButton.java.patch b/patches/minecraft/net/minecraft/client/gui/components/AbstractButton.java.patch deleted file mode 100644 index d0796a7aa7..0000000000 --- a/patches/minecraft/net/minecraft/client/gui/components/AbstractButton.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/client/gui/components/AbstractButton.java -+++ b/net/minecraft/client/gui/components/AbstractButton.java -@@ -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 8009eb3421..ec5506bcfb 100644 --- a/patches/minecraft/net/minecraft/client/gui/components/AbstractWidget.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/components/AbstractWidget.java.patch @@ -1,17 +1,16 @@ --- a/net/minecraft/client/gui/components/AbstractWidget.java +++ b/net/minecraft/client/gui/components/AbstractWidget.java -@@ -238,6 +_,25 @@ +@@ -221,6 +_,23 @@ this.focused = p_93693_; } -+ // Forge start + public static final int UNSET_FG_COLOR = -1; + + protected int packedFGColor = UNSET_FG_COLOR; + + public int getFGColor() { + if (packedFGColor != UNSET_FG_COLOR) return packedFGColor; -+ return net.minecraft.util.ARGB.color(this.alpha, this.active ? -1 : -6250336); // White : Light Grey ++ return this.active ? net.minecraft.util.CommonColors.WHITE : net.minecraft.util.CommonColors.LIGHT_GRAY; + } + + public void setFGColor(int color) { @@ -21,7 +20,6 @@ + public void clearFGColor() { + this.packedFGColor = UNSET_FG_COLOR; + } -+ // Forge end + @Override public NarratableEntry.NarrationPriority narrationPriority() { 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 44057893f7..4d0baf356f 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 -@@ -32,6 +_,12 @@ +@@ -33,6 +_,12 @@ this.createNarration = p_259552_; } @@ -17,10 +17,10 @@ } public Button build() { -- Button button = new Button(this.x, this.y, this.width, this.height, this.message, this.onPress, this.createNarration); +- Button button = new Button.Plain(this.x, this.y, this.width, this.height, this.message, this.onPress, this.createNarration); - button.setTooltip(this.tooltip); - return button; -+ return build(Button::new); ++ return build(Button.Plain::new); + } + + // Forge (GH-9238) @@ -29,3 +29,14 @@ } } +@@ -118,6 +_,10 @@ + int p_455297_, int p_455388_, int p_459653_, int p_452847_, Component p_459347_, Button.OnPress p_453378_, Button.CreateNarration p_456163_ + ) { + super(p_455297_, p_455388_, p_459653_, p_452847_, p_459347_, p_453378_, p_456163_); ++ } ++ ++ protected Plain(Builder builder) { ++ super(builder); + } + + @Override diff --git a/patches/minecraft/net/minecraft/client/gui/components/toasts/ToastManager.java.patch b/patches/minecraft/net/minecraft/client/gui/components/toasts/ToastManager.java.patch index 5cb30bc409..7748660371 100644 --- a/patches/minecraft/net/minecraft/client/gui/components/toasts/ToastManager.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/components/toasts/ToastManager.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/components/toasts/ToastManager.java +++ b/net/minecraft/client/gui/components/toasts/ToastManager.java -@@ -146,6 +_,7 @@ +@@ -142,6 +_,7 @@ } public void addToast(Toast p_360768_) { 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 81a3c754d6..ccc3b32802 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 -@@ -146,6 +_,7 @@ +@@ -138,6 +_,7 @@ builder.put((Class)pictureinpicturerenderer.getRenderStateClass(), pictureinpicturerenderer); } 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 f1d28cdee9..a25bf46104 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 -@@ -103,6 +_,8 @@ +@@ -102,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 f4dfc82a6a..02a700943b 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 -@@ -62,6 +_,8 @@ +@@ -63,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(); -@@ -102,6 +_,7 @@ +@@ -103,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; -@@ -117,6 +_,7 @@ +@@ -118,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,7 +25,7 @@ if (f >= 2.0F) { this.minecraft.setOverlay(null); -@@ -126,6 +_,7 @@ +@@ -127,6 +_,7 @@ @Override public void tick() { if (this.fadeOutStart == -1L && this.reload.isDone() && this.isReadyToFadeOut()) { @@ -33,11 +33,11 @@ try { this.reload.checkExceptions(); this.onFinish.accept(Optional.empty()); -@@ -133,7 +_,6 @@ +@@ -134,7 +_,6 @@ this.onFinish.accept(Optional.of(throwable)); } - this.fadeOutStart = Util.getMillis(); if (this.minecraft.screen != null) { Window window = this.minecraft.getWindow(); - this.minecraft.screen.init(this.minecraft, window.getGuiScaledWidth(), window.getGuiScaledHeight()); + this.minecraft.screen.init(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 785d1d480f..28f341ddfb 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 -@@ -103,6 +_,7 @@ +@@ -102,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 ad0e7b33e4..8aa9980d34 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/Screen.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/Screen.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/screens/Screen.java +++ b/net/minecraft/client/gui/screens/Screen.java -@@ -191,7 +_,7 @@ +@@ -194,7 +_,7 @@ } public void onClose() { @@ -9,7 +9,7 @@ } protected T addRenderableWidget(T p_169406_) { -@@ -343,8 +_,10 @@ +@@ -326,8 +_,10 @@ this.width = p_96608_; this.height = p_96609_; if (!this.initialized) { @@ -20,7 +20,7 @@ } else { this.repositionElements(); } -@@ -361,8 +_,10 @@ +@@ -344,8 +_,10 @@ protected void rebuildWidgets() { this.clearWidgets(); this.clearFocus(); @@ -31,7 +31,7 @@ } protected void fadeWidgets(float p_409453_) { -@@ -402,6 +_,8 @@ +@@ -385,6 +_,8 @@ this.renderMenuBackground(p_283688_); } @@ -40,7 +40,7 @@ this.minecraft.gui.renderDeferredSubtitles(); } -@@ -484,6 +_,19 @@ +@@ -467,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 8b4137dc69..69a6fe19d0 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 -@@ -55,6 +_,7 @@ +@@ -53,6 +_,7 @@ private boolean fading; private long fadeInStart; private final LogoRenderer logoRenderer; @@ -8,7 +8,7 @@ public TitleScreen() { this(false); -@@ -107,11 +_,15 @@ +@@ -105,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( -@@ -178,7 +_,7 @@ +@@ -176,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,11 +33,11 @@ .tooltip(tooltip) .build() ) -@@ -298,9 +_,18 @@ +@@ -295,9 +_,18 @@ s = s + I18n.get("menu.modded"); } -- p_282860_.drawString(this.font, s, 2, this.height - 10, ARGB.color(f, -1)); +- p_282860_.drawString(this.font, s, 2, this.height - 10, ARGB.white(f)); + final float f_f = f; + net.minecraftforge.internal.BrandingControl.forEachLine(true, true, (brd, brdline) -> + p_282860_.drawString(this.font, brd, 2, this.height - ( 10 + brdline * (this.font.lineHeight + 1)), ARGB.color(f_f, -1)) diff --git a/patches/minecraft/net/minecraft/client/gui/screens/advancements/AdvancementTab.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/advancements/AdvancementTab.java.patch index 4c47f4391e..f547d3f96a 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/advancements/AdvancementTab.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/advancements/AdvancementTab.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/screens/advancements/AdvancementTab.java +++ b/net/minecraft/client/gui/screens/advancements/AdvancementTab.java -@@ -39,6 +_,7 @@ +@@ -40,6 +_,7 @@ private int maxY = Integer.MIN_VALUE; private float fade; private boolean centered; @@ -8,7 +8,7 @@ public AdvancementTab( Minecraft p_97145_, AdvancementsScreen p_97146_, AdvancementTabType p_97147_, int p_97148_, AdvancementNode p_297568_, DisplayInfo p_97150_ -@@ -55,6 +_,15 @@ +@@ -56,6 +_,15 @@ this.addWidget(this.root, p_297568_.holder()); } @@ -24,7 +24,7 @@ public AdvancementTabType getType() { return this.type; } -@@ -145,8 +_,8 @@ +@@ -150,8 +_,8 @@ return null; } else { for (AdvancementTabType advancementtabtype : AdvancementTabType.values()) { 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 ac15ed16ab..9de20e03fc 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,14 +1,14 @@ --- a/net/minecraft/client/gui/screens/advancements/AdvancementsScreen.java +++ b/net/minecraft/client/gui/screens/advancements/AdvancementsScreen.java -@@ -53,6 +_,7 @@ - @Nullable - private AdvancementTab selectedTab; +@@ -52,6 +_,7 @@ + private final Map tabs = Maps.newLinkedHashMap(); + private @Nullable AdvancementTab selectedTab; private boolean isScrolling; + private static int tabPage, maxPages; public AdvancementsScreen(ClientAdvancements p_97340_) { this(p_97340_, null); -@@ -66,6 +_,19 @@ +@@ -65,6 +_,19 @@ @Override protected void init() { @@ -28,7 +28,7 @@ this.layout.addTitleHeader(TITLE, this.font); this.tabs.clear(); this.selectedTab = null; -@@ -110,7 +_,7 @@ +@@ -109,7 +_,7 @@ int j = (this.height - 140) / 2; for (AdvancementTab advancementtab : this.tabs.values()) { @@ -37,12 +37,12 @@ this.advancements.setSelectedTab(advancementtab.getRootNode().holder(), true); break; } -@@ -185,10 +_,12 @@ +@@ -200,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()) { + if (advancementtab.getPage() == tabPage) - advancementtab.drawTab(p_283395_, p_281890_, p_282532_, advancementtab == this.selectedTab); + advancementtab.drawTab(p_283395_, p_281890_, p_282532_, p_451461_, p_451545_, advancementtab == this.selectedTab); } for (AdvancementTab advancementtab1 : this.tabs.values()) { @@ -50,7 +50,7 @@ advancementtab1.drawIcon(p_283395_, p_281890_, p_282532_); } } -@@ -207,6 +_,7 @@ +@@ -222,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 61cd27175a..9e3b7bf433 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 -@@ -105,6 +_,7 @@ +@@ -102,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_); -@@ -117,6 +_,8 @@ +@@ -114,6 +_,8 @@ this.onStopHovering(slot); } @@ -17,7 +17,7 @@ p_409971_.pose().popMatrix(); } -@@ -200,7 +_,7 @@ +@@ -197,7 +_,7 @@ ItemStack itemstack = this.hoveredSlot.getItem(); if (this.menu.getCarried().isEmpty() || this.showTooltipWithItemInHand(itemstack)) { p_283594_.setTooltipForNextFrame( @@ -26,7 +26,7 @@ ); } } -@@ -216,7 +_,8 @@ +@@ -213,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,7 +36,7 @@ } protected void renderLabels(GuiGraphics p_281635_, int p_282681_, int p_283686_) { -@@ -317,7 +_,8 @@ +@@ -313,7 +_,8 @@ if (super.mouseClicked(p_427253_, p_427622_)) { return true; } else { @@ -46,7 +46,7 @@ Slot slot = this.getHoveredSlot(p_427253_.x(), p_427253_.y()); this.doubleclick = this.lastClickSlot == slot && p_427622_; this.skipNextRelease = false; -@@ -327,6 +_,7 @@ +@@ -323,6 +_,7 @@ int i = this.leftPos; int j = this.topPos; boolean flag1 = this.hasClickedOutside(p_427253_.x(), p_427253_.y(), i, j); @@ -54,7 +54,7 @@ int k = -1; if (slot != null) { k = slot.index; -@@ -352,7 +_,7 @@ +@@ -348,7 +_,7 @@ } } else if (!this.isQuickCrafting) { if (this.menu.getCarried().isEmpty()) { @@ -63,7 +63,7 @@ this.slotClicked(slot, k, p_427253_.button(), ClickType.CLONE); } else { boolean flag2 = k != -999 && p_427253_.hasShiftDown(); -@@ -376,7 +_,7 @@ +@@ -372,7 +_,7 @@ this.quickCraftingType = 0; } else if (p_427253_.button() == 1) { this.quickCraftingType = 1; @@ -72,7 +72,7 @@ this.quickCraftingType = 2; } } -@@ -453,10 +_,13 @@ +@@ -449,10 +_,13 @@ @Override public boolean mouseReleased(MouseButtonEvent p_430939_) { @@ -86,7 +86,7 @@ int k = -1; if (slot != null) { k = slot.index; -@@ -473,7 +_,7 @@ +@@ -469,7 +_,7 @@ if (slot2 != null && slot2.mayPickup(this.minecraft.player) && slot2.hasItem() @@ -95,7 +95,7 @@ && AbstractContainerMenu.canItemQuickReplace(slot2, this.lastQuickMoved, true)) { this.slotClicked(slot2, slot2.index, p_430939_.button(), ClickType.QUICK_MOVE); } -@@ -538,7 +_,7 @@ +@@ -534,7 +_,7 @@ this.slotClicked(null, -999, AbstractContainerMenu.getQuickcraftMask(2, this.quickCraftingType), ClickType.QUICK_CRAFT); } else if (!this.menu.getCarried().isEmpty()) { @@ -104,7 +104,7 @@ this.slotClicked(slot, k, p_430939_.button(), ClickType.CLONE); } else { boolean flag1 = k != -999 && p_430939_.hasShiftDown(); -@@ -609,7 +_,7 @@ +@@ -605,7 +_,7 @@ public boolean keyPressed(KeyEvent p_424324_) { if (super.keyPressed(p_424324_)) { return true; @@ -113,7 +113,7 @@ this.onClose(); return true; } else { -@@ -688,6 +_,13 @@ +@@ -684,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 821ed9da97..9259e62ba1 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 -@@ -116,6 +_,8 @@ +@@ -115,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); -@@ -164,7 +_,7 @@ +@@ -163,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_); -@@ -332,6 +_,36 @@ +@@ -329,6 +_,36 @@ protected void init() { if (this.minecraft.player.hasInfiniteMaterials()) { super.init(); @@ -55,7 +55,7 @@ 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); -@@ -378,7 +_,7 @@ +@@ -376,7 +_,7 @@ public boolean charTyped(CharacterEvent p_424087_) { if (this.ignoreTextInput) { return false; @@ -64,7 +64,7 @@ return false; } else { String s = this.searchBox.getValue(); -@@ -397,7 +_,7 @@ +@@ -395,7 +_,7 @@ @Override public boolean keyPressed(KeyEvent p_429237_) { this.ignoreTextInput = false; @@ -73,7 +73,7 @@ if (this.minecraft.options.keyChat.matches(p_429237_)) { this.ignoreTextInput = true; this.selectTab(CreativeModeTabs.searchTab()); -@@ -433,6 +_,7 @@ +@@ -431,6 +_,7 @@ } private void refreshSearchResults() { @@ -81,7 +81,7 @@ this.menu.items.clear(); this.visibleTags.clear(); String s = this.searchBox.getValue(); -@@ -445,10 +_,10 @@ +@@ -443,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))); -@@ -480,7 +_,8 @@ +@@ -478,7 +_,8 @@ @Override protected void renderLabels(GuiGraphics p_283168_, int p_281774_, int p_281466_) { if (selectedTab.showTitle()) { @@ -104,7 +104,7 @@ } } -@@ -490,7 +_,7 @@ +@@ -488,7 +_,7 @@ double d0 = p_430803_.x() - this.leftPos; double d1 = p_430803_.y() - this.topPos; @@ -113,7 +113,7 @@ if (this.checkTabClicked(creativemodetab, d0, d1)) { return true; } -@@ -512,7 +_,7 @@ +@@ -510,7 +_,7 @@ double d1 = p_423848_.y() - this.topPos; this.scrolling = false; @@ -122,7 +122,7 @@ if (this.checkTabClicked(creativemodetab, d0, d1)) { this.selectTab(creativemodetab); return true; -@@ -606,13 +_,15 @@ +@@ -604,13 +_,15 @@ this.originalSlots = null; } @@ -139,9 +139,9 @@ this.refreshSearchResults(); } else { -@@ -676,7 +_,14 @@ +@@ -673,7 +_,14 @@ + this.effects.render(p_283000_, p_281317_, p_282770_); super.render(p_283000_, p_281317_, p_282770_, p_281295_); - this.effects.renderTooltip(p_283000_, p_281317_, p_282770_); - for (CreativeModeTab creativemodetab : CreativeModeTabs.tabs()) { + if (this.pages.size() != 1) { @@ -155,7 +155,7 @@ if (this.checkTabHovering(p_283000_, creativemodetab, p_281317_, p_282770_)) { break; } -@@ -700,7 +_,7 @@ +@@ -697,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); -@@ -721,7 +_,7 @@ +@@ -718,7 +_,7 @@ int i = 1; for (CreativeModeTab creativemodetab : CreativeModeTabs.tabs()) { @@ -173,24 +173,24 @@ list1.add(i++, creativemodetab.getDisplayName().copy().withStyle(ChatFormatting.BLUE)); } } -@@ -732,7 +_,7 @@ +@@ -729,7 +_,7 @@ @Override protected void renderBg(GuiGraphics p_282663_, float p_282504_, int p_282089_, int p_282249_) { - for (CreativeModeTab creativemodetab : CreativeModeTabs.tabs()) { + for (CreativeModeTab creativemodetab : currentPage.getVisibleTabs()) { if (creativemodetab != selectedTab) { - this.renderTabButton(p_282663_, creativemodetab); + this.renderTabButton(p_282663_, p_282089_, p_282249_, creativemodetab); } -@@ -748,6 +_,7 @@ - p_282663_.blitSprite(RenderPipelines.GUI_TEXTURED, resourcelocation, j, k + (int)((i - k - 17) * this.scrollOffs), 12, 15); +@@ -749,6 +_,7 @@ + p_282663_.blitSprite(RenderPipelines.GUI_TEXTURED, identifier, j, k + (int)((i - k - 17) * this.scrollOffs), 12, 15); } + if (currentPage.getVisibleTabs().contains(selectedTab)) //Forge: only display tab selection when the selected tab is on the current page - this.renderTabButton(p_282663_, selectedTab); + this.renderTabButton(p_282663_, p_282089_, p_282249_, selectedTab); if (selectedTab.getType() == CreativeModeTab.Type.INVENTORY) { InventoryScreen.renderEntityInInventoryFollowsMouse( -@@ -766,7 +_,7 @@ +@@ -767,7 +_,7 @@ } private int getTabX(CreativeModeTab p_260136_) { @@ -199,7 +199,7 @@ int j = 27; int k = 27 * i; if (p_260136_.isAlignedRight()) { -@@ -778,7 +_,7 @@ +@@ -779,7 +_,7 @@ private int getTabY(CreativeModeTab p_260181_) { int i = 0; @@ -208,9 +208,9 @@ i -= 32; } else { i += this.imageHeight; -@@ -806,8 +_,8 @@ +@@ -807,8 +_,8 @@ - protected void renderTabButton(GuiGraphics p_283590_, CreativeModeTab p_283489_) { + protected void renderTabButton(GuiGraphics p_283590_, int p_454271_, int p_455485_, CreativeModeTab p_283489_) { boolean flag = p_283489_ == selectedTab; - boolean flag1 = p_283489_.row() == CreativeModeTab.Row.TOP; - int i = p_283489_.column(); @@ -218,16 +218,16 @@ + int i = currentPage.getColumn(p_283489_); int j = this.leftPos + this.getTabX(p_283489_); int k = this.topPos - (flag1 ? 28 : -(this.imageHeight - 4)); - ResourceLocation[] aresourcelocation; -@@ -817,6 +_,7 @@ - aresourcelocation = flag ? SELECTED_BOTTOM_TABS : UNSELECTED_BOTTOM_TABS; + Identifier[] aidentifier; +@@ -822,6 +_,7 @@ + p_283590_.requestCursor(CursorTypes.POINTING_HAND); } + com.mojang.blaze3d.opengl.GlStateManager._enableBlend(); //Forge: Make sure blend is enabled else tabs show a white border. - p_283590_.blitSprite(RenderPipelines.GUI_TEXTURED, aresourcelocation[Mth.clamp(i, 0, aresourcelocation.length)], j, k, 26, 32); + p_283590_.blitSprite(RenderPipelines.GUI_TEXTURED, aidentifier[Mth.clamp(i, 0, aidentifier.length)], j, k, 26, 32); int l = j + 13 - 8; int i1 = k + 16 - 8 + (flag1 ? 1 : -1); -@@ -853,6 +_,14 @@ +@@ -858,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_) { -@@ -1034,6 +_,22 @@ +@@ -1038,6 +_,22 @@ @Override public boolean mayPickup(Player p_98665_) { return this.target.mayPickup(p_98665_); @@ -259,7 +259,7 @@ + } + + @Override -+ public Slot setBackground(ResourceLocation sprite) { ++ public Slot setBackground(Identifier sprite) { + this.target.setBackground(sprite); + return this; } diff --git a/patches/minecraft/net/minecraft/client/gui/screens/inventory/EffectsInInventory.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/inventory/EffectsInInventory.java.patch index 5df0c85a09..ac6d20ff10 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/inventory/EffectsInInventory.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/inventory/EffectsInInventory.java.patch @@ -1,48 +1,36 @@ --- a/net/minecraft/client/gui/screens/inventory/EffectsInInventory.java +++ b/net/minecraft/client/gui/screens/inventory/EffectsInInventory.java @@ -47,12 +_,16 @@ + int j = this.screen.width - i; Collection collection = this.minecraft.player.getActiveEffects(); if (!collection.isEmpty() && j >= 32) { - boolean flag = j >= 120; -+ var event = net.minecraftforge.client.event.ForgeEventFactoryClient.onScreenEffectSize(this.screen, j, !flag, i); +- int k = j >= 120 ? j - 7 : 32; ++ var event = net.minecraftforge.client.event.ForgeEventFactoryClient.onScreenEffectSize(this.screen, j, j < 120, i); + if (event == null) return; -+ flag = !event.isCompact(); ++ int k = !event.isCompact() ? j - 7 : 32; + i = event.getHorizontalOffset(); - int k = 33; + int l = 33; if (collection.size() > 5) { - k = 132 / (collection.size() - 1); + l = 132 / (collection.size() - 1); } -- Iterable iterable = Ordering.natural().sortedCopy(collection); + Iterable iterable = collection.stream().filter(net.minecraftforge.client.ForgeHooksClient::shouldRenderEffect).sorted().toList(); - this.renderBackgrounds(p_362146_, i, k, iterable, flag); - this.renderIcons(p_362146_, i, k, iterable, flag); - if (flag) { -@@ -98,6 +_,11 @@ - int i = this.screen.topPos; + this.renderEffects(p_456221_, collection, i, l, p_453611_, p_457243_, k); + } + } +@@ -66,6 +_,11 @@ - for (MobEffectInstance mobeffectinstance : p_361981_) { + for (MobEffectInstance mobeffectinstance : iterable) { + boolean flag = mobeffectinstance.isAmbient(); + var renderer = net.minecraftforge.client.extensions.common.IClientMobEffectExtensions.of(mobeffectinstance); -+ if (renderer.renderInventoryIcon(mobeffectinstance, this, p_367085_, p_367644_ + (p_368681_ ? 6 : 7), i, 0)) { -+ i += p_367522_; -+ continue; -+ } - Holder holder = mobeffectinstance.getEffect(); - ResourceLocation resourcelocation = Gui.getMobEffectSprite(holder); - p_367085_.blitSprite(RenderPipelines.GUI_TEXTURED, resourcelocation, p_367644_ + (p_368681_ ? 6 : 7), i + 7, 18, 18); -@@ -109,6 +_,11 @@ - int i = this.screen.topPos; - - for (MobEffectInstance mobeffectinstance : p_365480_) { -+ var renderer = net.minecraftforge.client.extensions.common.IClientMobEffectExtensions.of(mobeffectinstance); -+ if (renderer.renderInventoryText(mobeffectinstance, this, p_361851_, p_367468_, i, 0)) { -+ i += p_365556_; ++ if (renderer.renderInventory(mobeffectinstance, this, p_362146_, p_370153_, i, 0)) { ++ i += p_365612_; + continue; + } Component component = this.getEffectName(mobeffectinstance); - p_361851_.drawString(this.screen.getFont(), component, p_367468_ + 10 + 18, i + 6, -1); Component component1 = MobEffectUtil.formatDuration(mobeffectinstance, 1.0F, this.minecraft.level.tickRateManager().tickrate()); -@@ -124,5 +_,9 @@ + int j = this.renderBackground(p_362146_, font, component, component1, p_370153_, i, flag, p_457235_); +@@ -123,5 +_,9 @@ } return mutablecomponent; 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 cb5d39718a..3c0b691404 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 -@@ -107,7 +_,7 @@ +@@ -108,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); -@@ -158,13 +_,16 @@ +@@ -160,13 +_,16 @@ .registryAccess() .lookupOrThrow(Registries.ENCHANTMENT) .get(this.menu.enchantClue[j]); @@ -17,8 +17,8 @@ + { int l = this.menu.levelClue[j]; int i1 = j + 1; -- if (this.isHovering(60, 14 + 19 * j, 108, 17, p_282491_, p_281953_) && k > 0 && l >= 0 && optional != null) { -+ if (this.isHovering(60, 14 + 19 * j, 108, 17, (double)p_282491_, (double)p_281953_) && k > 0) { +- if (this.isHovering(60, 14 + 19 * j, 108, 17, p_282491_, p_281953_) && k > 0 && l >= 0) { ++ if (this.isHovering(60, 14 + 19 * j, 108, 17, (double)p_282491_, (double)p_281953_) && l >= 0) { List list = Lists.newArrayList(); - list.add(Component.translatable("container.enchant.clue", Enchantment.getFullname(optional.get(), l)).withStyle(ChatFormatting.WHITE)); - if (!flag) { diff --git a/patches/minecraft/net/minecraft/client/gui/screens/inventory/HangingSignEditScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/inventory/HangingSignEditScreen.java.patch index 74155da1f7..a7c216573a 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/inventory/HangingSignEditScreen.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/inventory/HangingSignEditScreen.java.patch @@ -4,8 +4,8 @@ private static final Vector3f TEXT_SCALE = new Vector3f(1.0F, 1.0F, 1.0F); private static final int TEXTURE_WIDTH = 16; private static final int TEXTURE_HEIGHT = 16; -- private final ResourceLocation texture = ResourceLocation.withDefaultNamespace("textures/gui/hanging_signs/" + this.woodType.name() + ".png"); -+ private final ResourceLocation texture = ResourceLocation.parse(this.woodType.name() + ".png").withPrefix("textures/gui/hanging_signs/"); +- private final Identifier texture = Identifier.withDefaultNamespace("textures/gui/hanging_signs/" + this.woodType.name() + ".png"); ++ private final Identifier texture = Identifier.parse(this.woodType.name() + ".png").withPrefix("textures/gui/hanging_signs/"); public HangingSignEditScreen(SignBlockEntity p_278017_, boolean p_277942_, boolean p_277778_) { super(p_278017_, p_277942_, p_277778_, Component.translatable("hanging_sign.edit")); 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 9bd67b3e70..115fbc94d1 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 -@@ -230,6 +_,14 @@ +@@ -236,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 a25835e3ef..92346a5781 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,6 +1,6 @@ --- a/net/minecraft/client/gui/screens/multiplayer/ServerSelectionList.java +++ b/net/minecraft/client/gui/screens/multiplayer/ServerSelectionList.java -@@ -363,6 +_,8 @@ +@@ -361,6 +_,8 @@ p_425273_.setTooltipForNextFrame(Lists.transform(this.onlinePlayersTooltip, Component::getVisualOrderText), p_424268_, p_430737_); } 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 37b166c430..2ef27b141f 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 -@@ -115,9 +_,10 @@ +@@ -116,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_) -@@ -125,7 +_,7 @@ +@@ -126,7 +_,7 @@ ) .build(); this.resetButton = Button.builder(RESET_BUTTON_TITLE, p_357685_ -> { @@ -21,7 +21,7 @@ KeyBindsList.this.resetMappingAndUpdateButtons(); }).bounds(0, 0, 50, 20).createNarration(p_344192_ -> Component.translatable("narrator.controls.reset", p_343976_)).build(); this.refreshEntry(); -@@ -166,7 +_,8 @@ +@@ -167,7 +_,8 @@ MutableComponent mutablecomponent = Component.empty(); if (!this.key.isUnbound()) { for (KeyMapping keymapping : KeyBindsList.this.minecraft.options.keyMappings) { 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 6160881a14..5bc6d38767 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 -@@ -43,7 +_,7 @@ +@@ -42,7 +_,7 @@ protected void addFooter() { this.resetButton = Button.builder(Component.translatable("controls.resetAll"), p_343640_ -> { for (KeyMapping keymapping : this.options.keyMappings) { @@ -9,7 +9,7 @@ } this.keyBindsList.resetMappingAndUpdateButtons(); -@@ -75,11 +_,12 @@ +@@ -74,11 +_,12 @@ public boolean keyPressed(KeyEvent p_424487_) { if (this.selectedKey != null) { if (p_424487_.isEscape()) { @@ -24,7 +24,7 @@ this.selectedKey = null; this.lastKeySelection = Util.getMillis(); this.keyBindsList.resetMappingAndUpdateButtons(); -@@ -102,5 +_,18 @@ +@@ -101,5 +_,18 @@ } this.resetButton.active = flag; 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 index 260fc4fd59..b83455dd08 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/packs/TransferableSelectionList.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/packs/TransferableSelectionList.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/screens/packs/TransferableSelectionList.java +++ b/net/minecraft/client/gui/screens/packs/TransferableSelectionList.java -@@ -64,7 +_,7 @@ +@@ -65,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); diff --git a/patches/minecraft/net/minecraft/client/gui/screens/worldselection/CreateWorldScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/worldselection/CreateWorldScreen.java.patch index 7e26fdfda3..4634eeafe7 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/worldselection/CreateWorldScreen.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/worldselection/CreateWorldScreen.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/screens/worldselection/CreateWorldScreen.java +++ b/net/minecraft/client/gui/screens/worldselection/CreateWorldScreen.java -@@ -171,6 +_,7 @@ +@@ -173,6 +_,7 @@ WorldDataConfiguration worlddataconfiguration = SharedConstants.IS_RUNNING_IN_IDE ? new WorldDataConfiguration(new DataPackConfig(List.of("vanilla", "tests"), List.of()), FeatureFlags.DEFAULT_FLAGS) : WorldDataConfiguration.DEFAULT; @@ -8,7 +8,7 @@ WorldLoader.InitConfig worldloader$initconfig = createDefaultLoadConfig(packrepository, worlddataconfiguration); CompletableFuture completablefuture = WorldLoader.load( worldloader$initconfig, -@@ -471,7 +_,7 @@ +@@ -472,7 +_,7 @@ if (p_269627_) { p_270552_.accept(this.uiState.getSettings().dataConfiguration()); } else { @@ -17,7 +17,7 @@ } }, Component.translatable("dataPack.validation.failed"), -@@ -585,6 +_,7 @@ +@@ -584,6 +_,7 @@ if (path != null) { if (this.tempDataPackRepository == null) { this.tempDataPackRepository = ServerPacksSource.createPackRepository(path, this.packValidator); diff --git a/patches/minecraft/net/minecraft/client/gui/screens/worldselection/WorldCreationUiState.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/worldselection/WorldCreationUiState.java.patch index 41579607b6..ab9704c50d 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/worldselection/WorldCreationUiState.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/worldselection/WorldCreationUiState.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/client/gui/screens/worldselection/WorldCreationUiState.java +++ b/net/minecraft/client/gui/screens/worldselection/WorldCreationUiState.java -@@ -234,7 +_,7 @@ - @Nullable - public PresetEditor getPresetEditor() { +@@ -232,7 +_,7 @@ + + public @Nullable PresetEditor getPresetEditor() { Holder holder = this.getWorldType().preset(); - return holder != null ? PresetEditor.EDITORS.get(holder.unwrapKey()) : null; + return holder != null ? holder.unwrapKey().map(net.minecraftforge.client.PresetEditorManager::get).orElse(null) : null; // FORGE: redirect lookup to expanded map 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 df02cec970..7bd2834a28 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,6 +1,6 @@ --- a/net/minecraft/client/gui/screens/worldselection/WorldOpenFlows.java +++ b/net/minecraft/client/gui/screens/worldselection/WorldOpenFlows.java -@@ -329,6 +_,8 @@ +@@ -331,6 +_,8 @@ this.minecraft.setScreenAndShow(new GenericMessageScreen(Component.translatable("selectWorld.resource_load"))); PackRepository packrepository = ServerPacksSource.createPackRepository(p_333651_); 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 9dd7f50bdd..d01d5d550e 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,14 +1,14 @@ --- a/net/minecraft/client/gui/screens/worldselection/WorldSelectionList.java +++ b/net/minecraft/client/gui/screens/worldselection/WorldSelectionList.java -@@ -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"); +@@ -83,6 +_,7 @@ + static final Identifier JOIN_HIGHLIGHTED_SPRITE = Identifier.withDefaultNamespace("world_list/join_highlighted"); + static final Identifier JOIN_SPRITE = Identifier.withDefaultNamespace("world_list/join"); static final Logger LOGGER = LogUtils.getLogger(); -+ private static final ResourceLocation FORGE_EXPERIMENTAL_WARNING_ICON = ResourceLocation.fromNamespaceAndPath("forge","textures/gui/experimental_warning.png"); ++ private static final Identifier FORGE_EXPERIMENTAL_WARNING_ICON = Identifier.fromNamespaceAndPath("forge","textures/gui/experimental_warning.png"); 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); -@@ -494,6 +_,19 @@ +@@ -489,6 +_,19 @@ } } @@ -28,7 +28,7 @@ @Override public Component getNarration() { Component component = Component.translatable( -@@ -520,6 +_,7 @@ +@@ -515,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); diff --git a/patches/minecraft/net/minecraft/client/model/HumanoidModel.java.patch b/patches/minecraft/net/minecraft/client/model/HumanoidModel.java.patch index fa065b641c..7c9ca4033e 100644 --- a/patches/minecraft/net/minecraft/client/model/HumanoidModel.java.patch +++ b/patches/minecraft/net/minecraft/client/model/HumanoidModel.java.patch @@ -1,36 +1,36 @@ --- a/net/minecraft/client/model/HumanoidModel.java +++ b/net/minecraft/client/model/HumanoidModel.java -@@ -290,6 +_,8 @@ - case BRUSH: - this.rightArm.xRot = this.rightArm.xRot * 0.5F - (float) (Math.PI / 5); - this.rightArm.yRot = 0.0F; +@@ -308,6 +_,8 @@ + break; + case SPEAR: + SpearAnimations.thirdPersonHandUse(this.rightArm, this.head, true, p_362371_.getUseItemStackForArm(HumanoidArm.RIGHT), p_362371_); + default: -+ p_366231_.applyTransform(this, p_362371_, net.minecraft.world.entity.HumanoidArm.RIGHT); ++ p_362371_.rightArmPose.applyTransform(this, p_362371_, net.minecraft.world.entity.HumanoidArm.RIGHT); } } -@@ -334,6 +_,8 @@ - case BRUSH: - this.leftArm.xRot = this.leftArm.xRot * 0.5F - (float) (Math.PI / 5); - this.leftArm.yRot = 0.0F; +@@ -355,6 +_,8 @@ + break; + case SPEAR: + SpearAnimations.thirdPersonHandUse(this.leftArm, this.head, false, p_363560_.getUseItemStackForArm(HumanoidArm.LEFT), p_363560_); + default: -+ p_370002_.applyTransform(this, p_363560_, net.minecraft.world.entity.HumanoidArm.LEFT); ++ p_363560_.leftArmPose.applyTransform(this, p_363560_, net.minecraft.world.entity.HumanoidArm.LEFT); } } -@@ -402,7 +_,7 @@ +@@ -427,7 +_,7 @@ } @OnlyIn(Dist.CLIENT) - public static enum ArmPose { + public static enum ArmPose implements net.minecraftforge.common.IExtensibleEnum { - EMPTY(false), - ITEM(false), - BLOCK(false), -@@ -418,10 +_,28 @@ - - private ArmPose(final boolean p_102896_) { + EMPTY(false, false), + ITEM(false, false), + BLOCK(false, false), +@@ -453,10 +_,29 @@ + ArmPose(final boolean p_102896_, final boolean p_456170_) { this.twoHanded = p_102896_; + this.affectsOffhandPose = p_456170_; + this.forgeArmPose = null; } @@ -41,18 +41,19 @@ + @javax.annotation.Nullable + private final net.minecraftforge.client.IArmPoseTransformer forgeArmPose; + -+ private ArmPose(boolean twoHanded, @javax.annotation.Nonnull net.minecraftforge.client.IArmPoseTransformer forgeArmPose) { ++ private ArmPose(boolean twoHanded, boolean affectsOffhandPose, @javax.annotation.Nonnull net.minecraftforge.client.IArmPoseTransformer forgeArmPose) { + this.twoHanded = twoHanded; ++ this.affectsOffhandPose = affectsOffhandPose; + com.google.common.base.Preconditions.checkNotNull(forgeArmPose, "Cannot create new ArmPose with null transformer!"); + this.forgeArmPose = forgeArmPose; + } + -+ public static ArmPose create(String name, boolean twoHanded, @javax.annotation.Nonnull net.minecraftforge.client.IArmPoseTransformer forgeArmPose) { ++ public static ArmPose create(String name, boolean twoHanded, boolean affectsOffhandPose, @javax.annotation.Nonnull net.minecraftforge.client.IArmPoseTransformer forgeArmPose) { + throw new IllegalStateException("Enum not extended"); + } + + public void applyTransform(HumanoidModel model, T state, net.minecraft.world.entity.HumanoidArm arm) { + if (this.forgeArmPose != null) this.forgeArmPose.applyTransform(model, state, arm); } - } - } + + public boolean affectsOffhandPose() { 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 227de9d65d..cd7ef0833c 100644 --- a/patches/minecraft/net/minecraft/client/model/geom/LayerDefinitions.java.patch +++ b/patches/minecraft/net/minecraft/client/model/geom/LayerDefinitions.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/client/model/geom/LayerDefinitions.java +++ b/net/minecraft/client/model/geom/LayerDefinitions.java -@@ -506,6 +_,7 @@ - builder.put(ModelLayers.createHangingSignModelName(p_374591_, hangingsignrenderer$attachmenttype), layerdefinition57); +@@ -524,6 +_,7 @@ + builder.put(ModelLayers.createHangingSignModelName(p_374591_, hangingsignrenderer$attachmenttype), layerdefinition58); } }); + net.minecraftforge.client.ForgeHooksClient.loadLayerDefinitions(builder); 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 cc8f48ac45..d45ba84155 100644 --- a/patches/minecraft/net/minecraft/client/model/geom/ModelLayers.java.patch +++ b/patches/minecraft/net/minecraft/client/model/geom/ModelLayers.java.patch @@ -1,24 +1,24 @@ --- a/net/minecraft/client/model/geom/ModelLayers.java +++ b/net/minecraft/client/model/geom/ModelLayers.java -@@ -328,15 +_,18 @@ +@@ -341,15 +_,18 @@ } public static ModelLayerLocation createStandingSignModelName(WoodType p_171292_) { - return createLocation("sign/standing/" + p_171292_.name(), "main"); -+ ResourceLocation location = ResourceLocation.parse(p_171292_.name()); -+ return new ModelLayerLocation(ResourceLocation.fromNamespaceAndPath(location.getNamespace(), "sign/standing/" + location.getPath()), "main"); ++ Identifier location = Identifier.parse(p_171292_.name()); ++ return new ModelLayerLocation(Identifier.fromNamespaceAndPath(location.getNamespace(), "sign/standing/" + location.getPath()), "main"); } public static ModelLayerLocation createWallSignModelName(WoodType p_363532_) { - return createLocation("sign/wall/" + p_363532_.name(), "main"); -+ ResourceLocation location = ResourceLocation.parse(p_363532_.name()); -+ return new ModelLayerLocation(ResourceLocation.fromNamespaceAndPath(location.getNamespace(), "sign/wall/" + location.getPath()), "main"); ++ Identifier location = Identifier.parse(p_363532_.name()); ++ return new ModelLayerLocation(Identifier.fromNamespaceAndPath(location.getNamespace(), "sign/wall/" + location.getPath()), "main"); } public static ModelLayerLocation createHangingSignModelName(WoodType p_252225_, HangingSignRenderer.AttachmentType p_378070_) { - return createLocation("hanging_sign/" + p_252225_.name() + "/" + p_378070_.getSerializedName(), "main"); -+ ResourceLocation location = ResourceLocation.parse(p_252225_.name()); -+ return new ModelLayerLocation(ResourceLocation.fromNamespaceAndPath(location.getNamespace(), "hanging_sign/" + location.getPath() + "/" + p_378070_.getSerializedName()), "main"); ++ Identifier location = Identifier.parse(p_252225_.name()); ++ return new ModelLayerLocation(Identifier.fromNamespaceAndPath(location.getNamespace(), "hanging_sign/" + location.getPath() + "/" + p_378070_.getSerializedName()), "main"); } public static Stream getKnownLocations() { diff --git a/patches/minecraft/net/minecraft/client/multiplayer/ClientChunkCache.java.patch b/patches/minecraft/net/minecraft/client/multiplayer/ClientChunkCache.java.patch index 66bdf33a29..1769befafd 100644 --- a/patches/minecraft/net/minecraft/client/multiplayer/ClientChunkCache.java.patch +++ b/patches/minecraft/net/minecraft/client/multiplayer/ClientChunkCache.java.patch @@ -8,7 +8,7 @@ this.storage.drop(i, levelchunk); } } -@@ -125,6 +_,7 @@ +@@ -123,6 +_,7 @@ } this.level.onChunkLoaded(chunkpos); diff --git a/patches/minecraft/net/minecraft/client/multiplayer/ClientCommonPacketListenerImpl.java.patch b/patches/minecraft/net/minecraft/client/multiplayer/ClientCommonPacketListenerImpl.java.patch index 60d33c7b8e..dd4c4a84db 100644 --- a/patches/minecraft/net/minecraft/client/multiplayer/ClientCommonPacketListenerImpl.java.patch +++ b/patches/minecraft/net/minecraft/client/multiplayer/ClientCommonPacketListenerImpl.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/multiplayer/ClientCommonPacketListenerImpl.java +++ b/net/minecraft/client/multiplayer/ClientCommonPacketListenerImpl.java -@@ -160,6 +_,7 @@ +@@ -157,6 +_,7 @@ @Override public void handleCustomPayload(ClientboundCustomPayloadPacket p_298103_) { diff --git a/patches/minecraft/net/minecraft/client/multiplayer/ClientConfigurationPacketListenerImpl.java.patch b/patches/minecraft/net/minecraft/client/multiplayer/ClientConfigurationPacketListenerImpl.java.patch index 4fa16798d4..f2537afe36 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 -@@ -184,6 +_,7 @@ +@@ -182,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 82c6f016fe..8d0dfca66c 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 -@@ -214,6 +_,7 @@ +@@ -209,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_)); } -@@ -238,6 +_,7 @@ +@@ -233,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 97b24e81c7..a2ad588964 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 -@@ -145,6 +_,7 @@ +@@ -143,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(); -@@ -156,6 +_,8 @@ +@@ -155,6 +_,8 @@ private final int seaLevel; private boolean tickDayTime; private static final Set MARKER_PARTICLE_ITEMS = Set.of(Items.BARRIER, Items.LIGHT); @@ -17,16 +17,16 @@ public void handleBlockChangedAck(int p_233652_) { if (SharedConstants.DEBUG_BLOCK_BREAK) { -@@ -239,6 +_,8 @@ - this.serverSimulationDistance = p_364305_; - this.updateSkyBrightness(); - this.prepareWeather(); +@@ -240,6 +_,8 @@ + if (this.canHaveWeather()) { + this.prepareWeather(); + } + this.gatherCapabilities(); + net.minecraftforge.event.ForgeEventFactory.onLevelLoad(this); } - public void queueLightUpdate(Runnable p_194172_) { -@@ -343,6 +_,7 @@ + private EnvironmentAttributeSystem.Builder addEnvironmentAttributeLayers(EnvironmentAttributeSystem.Builder p_450625_) { +@@ -350,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(); -@@ -394,8 +_,10 @@ +@@ -401,8 +_,10 @@ } public void addEntity(Entity p_104741_) { @@ -71,7 +71,7 @@ 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_)); } -@@ -1032,7 +_,7 @@ +@@ -954,7 +_,7 @@ @Override public void addDestroyBlockEffect(BlockPos p_171667_, BlockState p_171668_) { @@ -80,7 +80,7 @@ VoxelShape voxelshape = p_171668_.getShape(this, p_171667_); double d0 = 0.25; voxelshape.forAllBoxes( -@@ -1067,6 +_,7 @@ +@@ -989,6 +_,7 @@ p_171668_, p_171667_ ) @@ -88,7 +88,7 @@ ); } } -@@ -1076,6 +_,13 @@ +@@ -998,6 +_,13 @@ } } @@ -102,7 +102,7 @@ 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 @@ +@@ -1033,7 +_,7 @@ d0 = i + aabb.maxX + 0.1F; } @@ -111,7 +111,7 @@ } } -@@ -1175,6 +_,16 @@ +@@ -1097,6 +_,16 @@ this.explosionTracker.track(p_429129_, p_428744_, p_431051_, p_431683_); } @@ -128,7 +128,7 @@ @OnlyIn(Dist.CLIENT) public static class ClientLevelData implements WritableLevelData { private final boolean hardcore; -@@ -1256,6 +_,7 @@ +@@ -1178,6 +_,7 @@ } public void setDifficulty(Difficulty p_104852_) { @@ -136,7 +136,7 @@ this.difficulty = p_104852_; } -@@ -1298,6 +_,12 @@ +@@ -1220,6 +_,12 @@ break; default: } @@ -149,7 +149,7 @@ } public void onTrackingEnd(Entity p_171716_) { -@@ -1310,6 +_,15 @@ +@@ -1232,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 1ea5a186a3..716329dbe6 100644 --- a/patches/minecraft/net/minecraft/client/multiplayer/ClientPacketListener.java.patch +++ b/patches/minecraft/net/minecraft/client/multiplayer/ClientPacketListener.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/multiplayer/ClientPacketListener.java +++ b/net/minecraft/client/multiplayer/ClientPacketListener.java -@@ -514,6 +_,7 @@ +@@ -527,6 +_,7 @@ this.debugSubscriber.clear(); this.minecraft.levelRenderer.debugRenderer.refreshRendererList(); this.minecraft.player.resetPos(); @@ -8,7 +8,7 @@ this.minecraft.player.setId(p_105030_.playerId()); this.level.addEntity(this.minecraft.player); this.minecraft.player.input = new KeyboardInput(this.minecraft.options); -@@ -1321,6 +_,8 @@ +@@ -1334,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); -@@ -1469,7 +_,7 @@ +@@ -1489,7 +_,7 @@ ProblemReporter.ScopedCollector problemreporter$scopedcollector = new ProblemReporter.ScopedCollector(p_404890_.problemPath(), LOGGER); try { @@ -26,7 +26,7 @@ } catch (Throwable throwable1) { try { problemreporter$scopedcollector.close(); -@@ -1646,7 +_,9 @@ +@@ -1666,7 +_,9 @@ @Override public void handleCommands(ClientboundCommandsPacket p_104990_) { PacketUtils.ensureRunningOnSameThread(p_104990_, this, this.minecraft.packetProcessor()); @@ -37,7 +37,7 @@ } @Override -@@ -1747,6 +_,7 @@ +@@ -1767,6 +_,7 @@ if (this.minecraft.screen instanceof RecipeUpdateListener recipeupdatelistener) { recipeupdatelistener.recipesUpdated(); } @@ -45,7 +45,7 @@ } @Override -@@ -1785,6 +_,8 @@ +@@ -1805,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 -@@ -2614,6 +_,8 @@ +@@ -2631,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(); -@@ -2622,6 +_,7 @@ +@@ -2639,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_)); -@@ -2638,6 +_,7 @@ +@@ -2655,6 +_,7 @@ } public void sendUnattendedCommand(String p_407213_, @Nullable Screen p_406262_) { diff --git a/patches/minecraft/net/minecraft/client/multiplayer/PlayerInfo.java.patch b/patches/minecraft/net/minecraft/client/multiplayer/PlayerInfo.java.patch index ec61033add..2c606bc9ac 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 -@@ -76,6 +_,7 @@ +@@ -72,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 1c302478c1..eb8bfd36b0 100644 --- a/patches/minecraft/net/minecraft/client/multiplayer/ServerData.java.patch +++ b/patches/minecraft/net/minecraft/client/multiplayer/ServerData.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/multiplayer/ServerData.java +++ b/net/minecraft/client/multiplayer/ServerData.java -@@ -38,6 +_,7 @@ +@@ -36,6 +_,7 @@ private ServerData.Type type; private int acceptedCodeOfConduct; private ServerData.State state = ServerData.State.INITIAL; diff --git a/patches/minecraft/net/minecraft/client/multiplayer/ServerStatusPinger.java.patch b/patches/minecraft/net/minecraft/client/multiplayer/ServerStatusPinger.java.patch index b21b1fe732..d8f717c01a 100644 --- a/patches/minecraft/net/minecraft/client/multiplayer/ServerStatusPinger.java.patch +++ b/patches/minecraft/net/minecraft/client/multiplayer/ServerStatusPinger.java.patch @@ -8,3 +8,12 @@ this.pingStart = Util.getMillis(); connection.send(new ServerboundPingRequestPacket(this.pingStart)); this.success = true; +@@ -152,7 +_,7 @@ + } + + void pingLegacyServer(InetSocketAddress p_171812_, final ServerAddress p_300887_, final ServerData p_171813_, EventLoopGroupHolder p_457463_) { +- new Bootstrap().group(p_457463_.eventLoopGroup()).handler(new ChannelInitializer() { ++ new Bootstrap().group(p_457463_.eventLoopGroup(true)).handler(new ChannelInitializer() { + @Override + protected void initChannel(Channel p_105498_) { + try { diff --git a/patches/minecraft/net/minecraft/client/multiplayer/SessionSearchTrees.java.patch b/patches/minecraft/net/minecraft/client/multiplayer/SessionSearchTrees.java.patch index f968d0a34a..67f10605e1 100644 --- a/patches/minecraft/net/minecraft/client/multiplayer/SessionSearchTrees.java.patch +++ b/patches/minecraft/net/minecraft/client/multiplayer/SessionSearchTrees.java.patch @@ -54,7 +54,7 @@ + this.creativeSearch.put(entry.getValue(), CompletableFuture.supplyAsync( () -> new FullTextSearchTree<>( p_345254_ -> getTooltipLines(Stream.of(p_345254_), item$tooltipcontext, tooltipflag), - p_344415_ -> p_344415_.getItemHolder().unwrapKey().map(ResourceKey::location).stream(), + p_344415_ -> p_344415_.getItemHolder().unwrapKey().map(ResourceKey::identifier).stream(), - p_342500_ + items ), diff --git a/patches/minecraft/net/minecraft/client/particle/ParticleEngine.java.patch b/patches/minecraft/net/minecraft/client/particle/ParticleEngine.java.patch index ed327812e7..3934a84305 100644 --- a/patches/minecraft/net/minecraft/client/particle/ParticleEngine.java.patch +++ b/patches/minecraft/net/minecraft/client/particle/ParticleEngine.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/client/particle/ParticleEngine.java +++ b/net/minecraft/client/particle/ParticleEngine.java -@@ -63,7 +_,7 @@ - private Particle makeParticle( +@@ -61,7 +_,7 @@ + private @Nullable 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.resourceManager.getProviders().get(BuiltInRegistries.PARTICLE_TYPE.getId(p_107396_.getType())); @@ -9,7 +9,7 @@ return particleprovider == null ? null : particleprovider.createParticle(p_107396_, this.level, p_107397_, p_107398_, p_107399_, p_107400_, p_107401_, p_107402_, this.random); -@@ -113,6 +_,8 @@ +@@ -111,6 +_,8 @@ return new ItemPickupParticleGroup(this); } else if (p_428647_ == ParticleRenderType.ELDER_GUARDIANS) { return new ElderGuardianParticleGroup(this); @@ -18,7 +18,7 @@ } else { return (ParticleGroup)(p_428647_ == ParticleRenderType.NO_RENDER ? new NoRenderParticleGroup(this) : new QuadParticleGroup(this, p_428647_)); } -@@ -122,8 +_,20 @@ +@@ -120,8 +_,20 @@ this.trackedParticleCounts.addTo(p_423291_, p_172283_); } diff --git a/patches/minecraft/net/minecraft/client/particle/ParticleResources.java.patch b/patches/minecraft/net/minecraft/client/particle/ParticleResources.java.patch index 357cb805c7..4549237bda 100644 --- a/patches/minecraft/net/minecraft/client/particle/ParticleResources.java.patch +++ b/patches/minecraft/net/minecraft/client/particle/ParticleResources.java.patch @@ -2,13 +2,13 @@ +++ 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 Map spriteSets = Maps.newHashMap(); private final Int2ObjectMap> providers = new Int2ObjectOpenHashMap<>(); -+ private final Map> providersByName = new java.util.HashMap<>(); - @Nullable - private Runnable onReload; ++ private final Map> providersByName = new java.util.HashMap<>(); + private @Nullable Runnable onReload; -@@ -174,14 +_,17 @@ + public ParticleResources() { +@@ -173,14 +_,17 @@ this.register(ParticleTypes.FIREFLY, FireflyParticle.FireflyProvider::new); } @@ -27,7 +27,7 @@ } @Override -@@ -274,8 +_,13 @@ +@@ -265,8 +_,13 @@ } } diff --git a/patches/minecraft/net/minecraft/client/particle/TerrainParticle.java.patch b/patches/minecraft/net/minecraft/client/particle/TerrainParticle.java.patch index a03512829c..175cec886b 100644 --- a/patches/minecraft/net/minecraft/client/particle/TerrainParticle.java.patch +++ b/patches/minecraft/net/minecraft/client/particle/TerrainParticle.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/particle/TerrainParticle.java +++ b/net/minecraft/client/particle/TerrainParticle.java -@@ -41,7 +_,7 @@ +@@ -43,7 +_,7 @@ this.rCol = 0.6F; this.gCol = 0.6F; this.bCol = 0.6F; @@ -9,7 +9,7 @@ int i = Minecraft.getInstance().getBlockColors().getColor(p_172458_, p_172451_, p_172459_, 0); this.rCol *= (i >> 16 & 0xFF) / 255.0F; this.gCol *= (i >> 8 & 0xFF) / 255.0F; -@@ -97,8 +_,14 @@ +@@ -99,8 +_,14 @@ ) { BlockState blockstate = p_331600_.getState(); return !blockstate.isAir() && !blockstate.is(Blocks.MOVING_PISTON) && blockstate.shouldSpawnTerrainParticles() diff --git a/patches/minecraft/net/minecraft/client/player/AbstractClientPlayer.java.patch b/patches/minecraft/net/minecraft/client/player/AbstractClientPlayer.java.patch index 61947829cd..702677d22b 100644 --- a/patches/minecraft/net/minecraft/client/player/AbstractClientPlayer.java.patch +++ b/patches/minecraft/net/minecraft/client/player/AbstractClientPlayer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/player/AbstractClientPlayer.java +++ b/net/minecraft/client/player/AbstractClientPlayer.java -@@ -138,7 +_,7 @@ +@@ -133,7 +_,7 @@ } } diff --git a/patches/minecraft/net/minecraft/client/player/LocalPlayer.java.patch b/patches/minecraft/net/minecraft/client/player/LocalPlayer.java.patch index bebc2a4a20..53c7a40455 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 -@@ -295,6 +_,7 @@ +@@ -310,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(); -@@ -482,7 +_,11 @@ +@@ -521,7 +_,11 @@ @Override public void playSound(SoundEvent p_108651_, float p_108652_, float p_108653_) { @@ -21,7 +21,7 @@ } @Override -@@ -720,6 +_,7 @@ +@@ -761,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) { -@@ -792,8 +_,9 @@ +@@ -833,8 +_,9 @@ } this.wasFallFlying = this.isFallFlying(); @@ -41,7 +41,7 @@ } if (this.isEyeInFluid(FluidTags.WATER)) { -@@ -859,7 +_,7 @@ +@@ -900,7 +_,7 @@ } private boolean shouldStopSwimSprinting() { @@ -50,7 +50,7 @@ } public Portal.Transition getActivePortalLocalTransition() { -@@ -902,6 +_,8 @@ +@@ -943,6 +_,8 @@ @Override public void rideTick() { super.rideTick(); @@ -59,16 +59,16 @@ this.handsBusy = false; if (this.getControlledVehicle() instanceof AbstractBoat abstractboat) { abstractboat.setInput( -@@ -1079,7 +_,7 @@ +@@ -1120,7 +_,7 @@ && this.isSprintingPossible(this.getAbilities().flying) - && !this.isUsingItem() + && !this.isSlowDueToUsingItem() && (!this.isFallFlying() || this.isUnderWater()) - && (!this.isMovingSlowly() || this.isUnderWater()); + && (!this.isMovingSlowly() || this.isUnderWater() || this.canStartSwimming()); } private boolean vehicleCanSprint(Entity p_265184_) { -@@ -1158,6 +_,17 @@ +@@ -1195,6 +_,17 @@ @Override public float getVisualRotationYInDegrees() { return this.getYRot(); diff --git a/patches/minecraft/net/minecraft/client/renderer/DimensionSpecialEffects.java.patch b/patches/minecraft/net/minecraft/client/renderer/DimensionSpecialEffects.java.patch deleted file mode 100644 index 00c1d7efeb..0000000000 --- a/patches/minecraft/net/minecraft/client/renderer/DimensionSpecialEffects.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/client/renderer/DimensionSpecialEffects.java -+++ b/net/minecraft/client/renderer/DimensionSpecialEffects.java -@@ -32,7 +_,7 @@ - } - - public static DimensionSpecialEffects forType(DimensionType p_108877_) { -- return EFFECTS.get(p_108877_.effectsLocation()); -+ return net.minecraftforge.client.DimensionSpecialEffectsManager.getForType(p_108877_.effectsLocation()); - } - - public boolean isSunriseOrSunset(float p_361903_) { diff --git a/patches/minecraft/net/minecraft/client/renderer/GameRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/GameRenderer.java.patch index 2755a0ce6a..793442238f 100644 --- a/patches/minecraft/net/minecraft/client/renderer/GameRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/GameRenderer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/renderer/GameRenderer.java +++ b/net/minecraft/client/renderer/GameRenderer.java -@@ -233,6 +_,9 @@ +@@ -242,6 +_,9 @@ case null: default: this.clearPostEffect(); @@ -10,7 +10,7 @@ } } -@@ -244,7 +_,13 @@ +@@ -253,7 +_,13 @@ public void processBlurEffect() { PostChain postchain = this.minecraft.getShaderManager().getPostChain(BLUR_POST_CHAIN_ID, LevelTargetBundle.MAIN_TARGETS); if (postchain != null) { @@ -24,7 +24,7 @@ } } -@@ -406,7 +_,7 @@ +@@ -377,7 +_,7 @@ f *= Mth.lerp(f2, 1.0F, 0.85714287F); } @@ -33,7 +33,7 @@ } } -@@ -557,7 +_,7 @@ +@@ -530,7 +_,7 @@ } } else if (flag && this.minecraft.screen != null) { try { @@ -42,7 +42,7 @@ } catch (Throwable throwable1) { CrashReport crashreport1 = CrashReport.forThrowable(throwable1, "Rendering screen"); CrashReportCategory crashreportcategory1 = crashreport1.addCategory("Screen render details"); -@@ -672,6 +_,10 @@ +@@ -696,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)); @@ -53,7 +53,7 @@ } } } -@@ -706,6 +_,9 @@ +@@ -736,6 +_,9 @@ if (this.minecraft.options.bobView().get()) { this.bobView(posestack, this.mainCamera.getPartialTickTime()); } @@ -62,4 +62,4 @@ + this.mainCamera.setRotation(cameraSetup.getYaw(), cameraSetup.getPitch(), cameraSetup.getRoll()); matrix4f.mul(posestack.last().pose()); - float f3 = this.minecraft.options.screenEffectScale().get().floatValue(); + float f2 = 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 02da9e195d..ad3708e390 100644 --- a/patches/minecraft/net/minecraft/client/renderer/ItemBlockRenderTypes.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/ItemBlockRenderTypes.java.patch @@ -5,26 +5,26 @@ @OnlyIn(Dist.CLIENT) public class ItemBlockRenderTypes { + @Deprecated - private static final Map TYPE_BY_BLOCK = Util.make(Maps.newHashMap(), p_420870_ -> { + private static final Map TYPE_BY_BLOCK = Util.make(Maps.newHashMap(), p_448152_ -> { ChunkSectionLayer chunksectionlayer = ChunkSectionLayer.TRIPWIRE; - p_420870_.put(Blocks.TRIPWIRE, chunksectionlayer); -@@ -357,12 +_,15 @@ - p_420870_.put(Blocks.BUBBLE_COLUMN, chunksectionlayer3); - p_420870_.put(Blocks.TINTED_GLASS, chunksectionlayer3); + p_448152_.put(Blocks.TRIPWIRE, chunksectionlayer); +@@ -356,12 +_,15 @@ + p_448152_.put(Blocks.BUBBLE_COLUMN, chunksectionlayer2); + p_448152_.put(Blocks.TINTED_GLASS, chunksectionlayer2); }); + @Deprecated private static final Map LAYER_BY_FLUID = Util.make(Maps.newHashMap(), p_404902_ -> { p_404902_.put(Fluids.FLOWING_WATER, ChunkSectionLayer.TRANSLUCENT); p_404902_.put(Fluids.WATER, ChunkSectionLayer.TRANSLUCENT); }); - private static boolean renderCutout; + private static boolean cutoutLeaves; + /** @deprecated Forge: Use {@link net.minecraft.client.resources.model.BakedModel#getRenderTypes(BlockState, net.minecraft.util.RandomSource, net.minecraftforge.client.model.data.ModelData)}. */ + @Deprecated // Note: this method does NOT support model-based render types public static ChunkSectionLayer getChunkRenderType(BlockState p_109283_) { Block block = p_109283_.getBlock(); if (block instanceof LeavesBlock) { -@@ -373,6 +_,8 @@ +@@ -372,6 +_,8 @@ } } @@ -33,7 +33,7 @@ public static RenderType getMovingBlockRenderType(BlockState p_109294_) { Block block = p_109294_.getBlock(); if (block instanceof LeavesBlock) { -@@ -393,11 +_,14 @@ +@@ -391,17 +_,78 @@ } } @@ -41,15 +41,7 @@ + @Deprecated // Note: this method does NOT support model-based render types public static RenderType getRenderType(BlockState p_364446_) { ChunkSectionLayer chunksectionlayer = getChunkRenderType(p_364446_); - return chunksectionlayer == ChunkSectionLayer.TRANSLUCENT ? Sheets.translucentItemSheet() : Sheets.cutoutBlockSheet(); - } - -+ /* Forge: Use {@link net.minecraft.client.resources.model.BakedModel#getRenderPasses(ItemStack, boolean)} and {@link net.minecraft.client.resources.model.BakedModel#getRenderTypes(ItemStack, boolean)}. */ - public static RenderType getRenderType(ItemStack p_363859_) { - if (p_363859_.getItem() instanceof BlockItem blockitem) { - Block block = blockitem.getBlock(); -@@ -407,12 +_,71 @@ - } + return chunksectionlayer == ChunkSectionLayer.TRANSLUCENT ? Sheets.translucentBlockItemSheet() : Sheets.cutoutBlockSheet(); } + // Note: this method does NOT support model-based render types @@ -59,16 +51,16 @@ return chunksectionlayer != null ? chunksectionlayer : ChunkSectionLayer.SOLID; } - public static void setFancy(boolean p_109292_) { - renderCutout = p_109292_; + public static void setCutoutLeaves(boolean p_454762_) { + cutoutLeaves = p_454762_; + } + + /** Forge: Check if we are running in {@linkplain net.minecraft.client.Minecraft#useFancyGraphics() fancy graphics} to account for fast graphics render types */ + public static boolean isFancy() { -+ return renderCutout; ++ return cutoutLeaves; + } + -+ private static final java.util.Collection CUTOUT_MIPPED = java.util.EnumSet.of(ChunkSectionLayer.CUTOUT_MIPPED); ++ private static final java.util.Collection CUTOUT_MIPPED = java.util.EnumSet.of(ChunkSectionLayer.CUTOUT); + private static final java.util.Collection SOLID = java.util.EnumSet.of(ChunkSectionLayer.SOLID); + private static final Map, java.util.Collection> BLOCK_RENDER_TYPES = Util.make(new it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap<>(TYPE_BY_BLOCK.size(), 0.5F), map -> { + map.defaultReturnValue(SOLID); @@ -85,7 +77,7 @@ + public static java.util.Collection getRenderLayers(BlockState state) { + Block block = state.getBlock(); + if (block instanceof LeavesBlock) { -+ return renderCutout ? CUTOUT_MIPPED : SOLID; ++ return cutoutLeaves ? CUTOUT_MIPPED : SOLID; + } else { + return BLOCK_RENDER_TYPES.get(net.minecraftforge.registries.ForgeRegistries.BLOCKS.getDelegateOrThrow(block)); + } diff --git a/patches/minecraft/net/minecraft/client/renderer/ItemInHandRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/ItemInHandRenderer.java.patch index 609abc9360..a9de77348a 100644 --- a/patches/minecraft/net/minecraft/client/renderer/ItemInHandRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/ItemInHandRenderer.java.patch @@ -1,41 +1,41 @@ --- a/net/minecraft/client/renderer/ItemInHandRenderer.java +++ b/net/minecraft/client/renderer/ItemInHandRenderer.java -@@ -328,12 +_,14 @@ +@@ -329,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); + float f5 = this.itemModelResolver.swapAnimationScale(this.mainHandItem) * (1.0F - Mth.lerp(p_109315_, this.oMainHandHeight, this.mainHandHeight)); + 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); + float f7 = this.itemModelResolver.swapAnimationScale(this.offHandItem) * (1.0F - Mth.lerp(p_109315_, this.oOffHandHeight, this.offHandHeight)); + 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_); } -@@ -400,7 +_,7 @@ +@@ -401,7 +_,7 @@ } else { 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) { + this.applyItemArmTransform(p_109379_, humanoidarm, p_109378_); boolean flag1 = CrossbowItem.isCharged(p_109377_); boolean flag2 = humanoidarm == HumanoidArm.RIGHT; - int i = flag2 ? 1 : -1; -@@ -445,6 +_,7 @@ +@@ -446,6 +_,7 @@ } else { boolean flag3 = humanoidarm == HumanoidArm.RIGHT; int j = flag3 ? 1 : -1; + if (!net.minecraftforge.client.extensions.common.IClientItemExtensions.of(p_109377_).applyForgeHandTransform(p_109379_, minecraft.player, humanoidarm, p_109377_, p_109373_, p_109378_, p_109376_)) // FORGE: Allow items to define custom arm animation if (p_109372_.isUsingItem() && p_109372_.getUseItemRemainingTicks() > 0 && p_109372_.getUsedItemHand() == p_109375_) { - switch (p_109377_.getUseAnimation()) { - case NONE: -@@ -572,8 +_,18 @@ + ItemUseAnimation itemuseanimation = p_109377_.getUseAnimation(); + if (!itemuseanimation.hasCustomArmTransform()) { +@@ -589,8 +_,18 @@ this.offHandHeight = Mth.clamp(this.offHandHeight - 0.4F, 0.0F, 1.0F); } else { - float f = localplayer.getAttackStrengthScale(1.0F); + float f = localplayer.getItemSwapScale(1.0F); - float f1 = this.mainHandItem != itemstack ? 0.0F : f * f * f; - float f2 = this.offHandItem != itemstack1 ? 0.0F : 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 a74f85c282..3fb670e20b 100644 --- a/patches/minecraft/net/minecraft/client/renderer/LevelRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/LevelRenderer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/renderer/LevelRenderer.java +++ b/net/minecraft/client/renderer/LevelRenderer.java -@@ -175,6 +_,7 @@ +@@ -184,6 +_,7 @@ this.submitNodeStorage = p_427160_.getSubmitNodeStorage(); this.levelRenderState = p_429507_; this.featureRenderDispatcher = p_427160_; @@ -8,7 +8,7 @@ } @Override -@@ -460,9 +_,10 @@ +@@ -485,9 +_,10 @@ profilerfiller.push("entities"); this.extractVisibleEntities(p_109604_, frustum, p_342180_, this.levelRenderState); profilerfiller.popPush("blockEntities"); @@ -21,32 +21,32 @@ profilerfiller.popPush("blockBreaking"); this.extractBlockDestroyAnimation(p_109604_, this.levelRenderState); profilerfiller.popPush("weather"); -@@ -534,6 +_,7 @@ +@@ -561,6 +_,7 @@ } - this.addLateDebugPass(framegraphbuilder, this.levelRenderState.cameraRenderState.pos, p_407881_, frustum); + this.addLateDebugPass(framegraphbuilder, this.levelRenderState.cameraRenderState, p_407881_, p_254120_); + net.minecraftforge.client.FramePassManager.insertForgePasses(framegraphbuilder, targets, this.levelRenderState); // Forge: Modded passes are inserted here. profilerfiller.popPush("executeFrameGraph"); framegraphbuilder.execute(p_367325_, new FrameGraphBuilder.Inspector() { @Override -@@ -801,7 +_,7 @@ +@@ -841,7 +_,7 @@ } } - 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(); + Vec3 vec3 = p_427254_.position(); double d0 = vec3.x(); double d1 = vec3.y(); -@@ -812,6 +_,7 @@ +@@ -852,6 +_,7 @@ List list = sectionrenderdispatcher$rendersection.getSectionMesh().getRenderableBlockEntities(); - if (!list.isEmpty()) { + if (!list.isEmpty() && !(sectionrenderdispatcher$rendersection.getVisibility(Util.getMillis()) < 0.3F)) { for (BlockEntity blockentity : list) { + if (!frustum.isVisible(blockentity.getRenderBoundingBox())) continue; BlockPos blockpos = blockentity.getBlockPos(); SortedSet sortedset = this.destructionProgress.get(blockpos.asLong()); ModelFeatureRenderer.CrumblingOverlay modelfeaturerenderer$crumblingoverlay; -@@ -839,6 +_,7 @@ +@@ -879,6 +_,7 @@ if (blockentity1.isRemoved()) { iterator.remove(); } else { @@ -54,7 +54,7 @@ BlockEntityRenderState blockentityrenderstate1 = this.blockEntityRenderDispatcher.tryExtractRenderState(blockentity1, p_426770_, null); if (blockentityrenderstate1 != null) { p_428920_.blockEntityRenderStates.add(blockentityrenderstate1); -@@ -895,13 +_,21 @@ +@@ -935,13 +_,21 @@ VertexConsumer vertexconsumer = new SheetedDecalTextureGenerator( p_365998_.getBuffer(ModelBakery.DESTROY_TYPES.get(blockbreakingrenderstate.progress)), posestack$pose, 1.0F ); @@ -78,7 +78,7 @@ if (this.minecraft.hitResult instanceof BlockHitResult blockhitresult) { if (blockhitresult.getType() != HitResult.Type.MISS) { BlockPos blockpos = blockhitresult.getBlockPos(); -@@ -927,6 +_,10 @@ +@@ -967,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) { @@ -89,7 +89,7 @@ if (blockoutlinerenderstate.isTranslucent() == p_368189_) { Vec3 vec3 = p_422597_.cameraRenderState.pos; if (blockoutlinerenderstate.highContrast()) { -@@ -1356,7 +_,7 @@ +@@ -1435,7 +_,7 @@ } else { int i = p_398213_.packedBrightness(p_109538_, p_109540_); int j = LightTexture.block(i); @@ -98,7 +98,7 @@ if (j < k) { int l = LightTexture.sky(i); return LightTexture.pack(k, l); -@@ -1418,6 +_,18 @@ +@@ -1492,6 +_,18 @@ public CloudRenderer getCloudRenderer() { return this.cloudRenderer; @@ -116,4 +116,4 @@ + this.weatherEffectRenderer = value; } - @FunctionalInterface + public Gizmos.TemporaryCollection collectPerFrameGizmos() { diff --git a/patches/minecraft/net/minecraft/client/renderer/LightTexture.java.patch b/patches/minecraft/net/minecraft/client/renderer/LightTexture.java.patch index e75daea9c8..c74d3334bd 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 -@@ -189,7 +_,7 @@ +@@ -171,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 deleted file mode 100644 index 4ecb04f181..0000000000 --- a/patches/minecraft/net/minecraft/client/renderer/RenderType.java.patch +++ /dev/null @@ -1,56 +0,0 @@ ---- a/net/minecraft/client/renderer/RenderType.java -+++ b/net/minecraft/client/renderer/RenderType.java -@@ -485,6 +_,11 @@ - private final int bufferSize; - private final boolean affectsCrumbling; - private final boolean sortOnUpload; -+ private int chunkLayerId = -1; -+ /** {@return the unique ID of this {@link RenderType} for chunk rendering purposes, or {@literal -1} if this is not a chunk {@link RenderType}} */ -+ public final int getChunkLayerId() { -+ return chunkLayerId; -+ } - - public static RenderType solid() { - return SOLID; -@@ -665,7 +_,7 @@ - } - - public static RenderType text(ResourceLocation p_110498_) { -- return TEXT.apply(p_110498_); -+ return net.minecraftforge.client.ForgeRenderTypes.getText(p_110498_); - } - - public static RenderType textBackground() { -@@ -673,19 +_,19 @@ - } - - public static RenderType textIntensity(ResourceLocation p_173238_) { -- return TEXT_INTENSITY.apply(p_173238_); -+ return net.minecraftforge.client.ForgeRenderTypes.getTextIntensity(p_173238_); - } - - public static RenderType textPolygonOffset(ResourceLocation p_181445_) { -- return TEXT_POLYGON_OFFSET.apply(p_181445_); -+ return net.minecraftforge.client.ForgeRenderTypes.getTextPolygonOffset(p_181445_); - } - - public static RenderType textIntensityPolygonOffset(ResourceLocation p_181447_) { -- return TEXT_INTENSITY_POLYGON_OFFSET.apply(p_181447_); -+ return net.minecraftforge.client.ForgeRenderTypes.getTextIntensityPolygonOffset(p_181447_); - } - - public static RenderType textSeeThrough(ResourceLocation p_110501_) { -- return TEXT_SEE_THROUGH.apply(p_110501_); -+ return net.minecraftforge.client.ForgeRenderTypes.getTextSeeThrough(p_110501_); - } - - public static RenderType textBackgroundSeeThrough() { -@@ -693,7 +_,7 @@ - } - - public static RenderType textIntensitySeeThrough(ResourceLocation p_173241_) { -- return TEXT_INTENSITY_SEE_THROUGH.apply(p_173241_); -+ return net.minecraftforge.client.ForgeRenderTypes.getTextIntensitySeeThrough(p_173241_); - } - - public static RenderType lightning() { diff --git a/patches/minecraft/net/minecraft/client/renderer/ScreenEffectRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/ScreenEffectRenderer.java.patch index 4d6bdb08f4..a165897504 100644 --- a/patches/minecraft/net/minecraft/client/renderer/ScreenEffectRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/ScreenEffectRenderer.java.patch @@ -27,20 +27,19 @@ renderFire(posestack, this.bufferSource, textureatlassprite); } } -@@ -121,6 +_,12 @@ +@@ -120,6 +_,11 @@ + } - @Nullable - private static BlockState getViewBlockingState(Player p_110717_) { + private static @Nullable BlockState getViewBlockingState(Player p_110717_) { + var ret = getOverlayBlock(p_110717_); + return ret == null ? null : ret.getLeft(); + } + -+ @Nullable -+ private static org.apache.commons.lang3.tuple.Pair getOverlayBlock(Player p_110717_) { ++ private static org.apache.commons.lang3.tuple.@Nullable Pair getOverlayBlock(Player p_110717_) { BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(); for (int i = 0; i < 8; i++) { -@@ -130,7 +_,7 @@ +@@ -129,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)) { @@ -49,23 +48,23 @@ } } -@@ -158,6 +_,10 @@ +@@ -157,6 +_,10 @@ } private static void renderWater(Minecraft p_110726_, PoseStack p_110727_, MultiBufferSource p_376402_) { + renderFluid(p_110726_, p_110727_, p_376402_, UNDERWATER_LOCATION); + } + -+ public static void renderFluid(Minecraft p_110726_, PoseStack p_110727_, MultiBufferSource p_376402_, ResourceLocation texture) { ++ public static void renderFluid(Minecraft p_110726_, PoseStack p_110727_, MultiBufferSource p_376402_, Identifier texture) { 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); -@@ -170,7 +_,7 @@ +@@ -169,7 +_,7 @@ float f7 = -p_110726_.player.getYRot() / 64.0F; float f8 = p_110726_.player.getXRot() / 64.0F; Matrix4f matrix4f = p_110727_.last().pose(); -- VertexConsumer vertexconsumer = p_376402_.getBuffer(RenderType.blockScreenEffect(UNDERWATER_LOCATION)); -+ VertexConsumer vertexconsumer = p_376402_.getBuffer(RenderType.blockScreenEffect(texture)); +- VertexConsumer vertexconsumer = p_376402_.getBuffer(RenderTypes.blockScreenEffect(UNDERWATER_LOCATION)); ++ VertexConsumer vertexconsumer = p_376402_.getBuffer(RenderTypes.blockScreenEffect(texture)); vertexconsumer.addVertex(matrix4f, -1.0F, -1.0F, -0.5F).setUv(4.0F + f7, 4.0F + f8).setColor(i); vertexconsumer.addVertex(matrix4f, 1.0F, -1.0F, -0.5F).setUv(0.0F + f7, 4.0F + f8).setColor(i); vertexconsumer.addVertex(matrix4f, 1.0F, 1.0F, -0.5F).setUv(0.0F + f7, 0.0F + f8).setColor(i); diff --git a/patches/minecraft/net/minecraft/client/renderer/Sheets.java.patch b/patches/minecraft/net/minecraft/client/renderer/Sheets.java.patch index f536356633..88f845440e 100644 --- a/patches/minecraft/net/minecraft/client/renderer/Sheets.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/Sheets.java.patch @@ -1,20 +1,20 @@ --- a/net/minecraft/client/renderer/Sheets.java +++ b/net/minecraft/client/renderer/Sheets.java -@@ -171,11 +_,11 @@ +@@ -179,11 +_,11 @@ } private static Material createSignMaterial(WoodType p_173386_) { - return SIGN_MAPPER.defaultNamespaceApply(p_173386_.name()); -+ return SIGN_MAPPER.apply(ResourceLocation.parse(p_173386_.name())); ++ return SIGN_MAPPER.apply(Identifier.parse(p_173386_.name())); } private static Material createHangingSignMaterial(WoodType p_251735_) { - return HANGING_SIGN_MAPPER.defaultNamespaceApply(p_251735_.name()); -+ return HANGING_SIGN_MAPPER.apply(ResourceLocation.parse(p_251735_.name())); ++ return HANGING_SIGN_MAPPER.apply(Identifier.parse(p_251735_.name())); } public static Material getSignMaterial(WoodType p_173382_) { -@@ -221,6 +_,23 @@ +@@ -228,6 +_,23 @@ case SINGLE: default: return p_110773_; diff --git a/patches/minecraft/net/minecraft/client/renderer/SpriteCoordinateExpander.java.patch b/patches/minecraft/net/minecraft/client/renderer/SpriteCoordinateExpander.java.patch index 5dfcc578fb..2127ec9e0e 100644 --- a/patches/minecraft/net/minecraft/client/renderer/SpriteCoordinateExpander.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/SpriteCoordinateExpander.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/renderer/SpriteCoordinateExpander.java +++ b/net/minecraft/client/renderer/SpriteCoordinateExpander.java -@@ -17,32 +_,38 @@ +@@ -17,12 +_,14 @@ @Override public VertexConsumer addVertex(float p_342932_, float p_342886_, float p_342696_) { @@ -16,6 +16,9 @@ + return this; // Forge: Fix MC-263524 not working with chained methods } + @Override +@@ -32,22 +_,26 @@ + @Override public VertexConsumer setUv(float p_343856_, float p_344420_) { - return this.delegate.setUv(this.sprite.getU(p_343856_), this.sprite.getV(p_344420_)); 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 1fe87c0feb..d8ed39f4d7 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 -@@ -51,12 +_,17 @@ +@@ -48,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); } } -@@ -99,7 +_,12 @@ +@@ -96,7 +_,12 @@ return this.blockModelShaper.getBlockModel(p_110911_); } @@ -28,11 +28,11 @@ + renderSingleBlock(p_110913_, p_110914_, p_110915_, p_110916_, p_110917_, net.minecraftforge.client.model.data.ModelData.EMPTY, null); + } + -+ public void renderSingleBlock(BlockState p_110913_, PoseStack p_110914_, MultiBufferSource p_110915_, int p_110916_, int p_110917_, net.minecraftforge.client.model.data.ModelData modelData, net.minecraft.client.renderer.RenderType renderType) { ++ public void renderSingleBlock(BlockState p_110913_, PoseStack p_110914_, MultiBufferSource p_110915_, int p_110916_, int p_110917_, net.minecraftforge.client.model.data.ModelData modelData, net.minecraft.client.renderer.rendertype.@Nullable RenderType renderType) { RenderShape rendershape = p_110913_.getRenderShape(); if (rendershape != RenderShape.INVISIBLE) { BlockStateModel blockstatemodel = this.getBlockModel(p_110913_); -@@ -107,8 +_,9 @@ +@@ -104,8 +_,9 @@ float f = (i >> 16 & 0xFF) / 255.0F; float f1 = (i >> 8 & 0xFF) / 255.0F; float f2 = (i & 0xFF) / 255.0F; diff --git a/patches/minecraft/net/minecraft/client/renderer/block/LiquidBlockRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/block/LiquidBlockRenderer.java.patch index b88ea9f657..e3cf8f2d86 100644 --- a/patches/minecraft/net/minecraft/client/renderer/block/LiquidBlockRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/block/LiquidBlockRenderer.java.patch @@ -1,96 +1,99 @@ --- a/net/minecraft/client/renderer/block/LiquidBlockRenderer.java +++ b/net/minecraft/client/renderer/block/LiquidBlockRenderer.java -@@ -70,8 +_,10 @@ +@@ -71,9 +_,12 @@ public void tesselate(BlockAndTintGetter p_234370_, BlockPos p_234371_, VertexConsumer p_234372_, BlockState p_234373_, FluidState p_234374_) { boolean flag = p_234374_.is(FluidTags.LAVA); -- TextureAtlasSprite[] atextureatlassprite = flag ? this.lavaIcons : this.waterIcons; +- TextureAtlasSprite textureatlassprite = flag ? this.lavaStill : this.waterStill; +- TextureAtlasSprite textureatlassprite1 = flag ? this.lavaFlowing : this.waterFlowing; - int i = flag ? 16777215 : BiomeColors.getAverageWaterColor(p_234370_, p_234371_); -+ TextureAtlasSprite[] atextureatlassprite = net.minecraftforge.client.ForgeHooksClient.getFluidSprites(p_234370_, p_234371_, p_234374_); ++ var sprites = net.minecraftforge.client.ForgeHooksClient.getFluidSprites(p_234370_, p_234371_, p_234374_); ++ TextureAtlasSprite textureatlassprite = sprites[0]; ++ TextureAtlasSprite textureatlassprite1 = sprites[1]; + int i = net.minecraftforge.client.extensions.common.IClientFluidTypeExtensions.of(p_234374_).getTintColor(p_234374_, p_234370_, p_234371_); + float alpha = (float)(i >> 24 & 255) / 255.0F; + float f = (i >> 16 & 0xFF) / 255.0F; float f1 = (i >> 8 & 0xFF) / 255.0F; float f2 = (i & 0xFF) / 255.0F; -@@ -180,15 +_,15 @@ - float f57 = f4 * f; - float f29 = f4 * f1; - float f30 = f4 * f2; -- this.vertex(p_234372_, f36 + 0.0F, f37 + f8, f38 + 0.0F, f57, f29, f30, f17, f21, l); -- this.vertex(p_234372_, f36 + 0.0F, f37 + f10, f38 + 1.0F, f57, f29, f30, f18, f22, l); -- this.vertex(p_234372_, f36 + 1.0F, f37 + f9, f38 + 1.0F, f57, f29, f30, f19, f23, l); -- this.vertex(p_234372_, f36 + 1.0F, f37 + f7, f38 + 0.0F, f57, f29, f30, f20, f24, l); -+ this.vertex(p_234372_, f36 + 0.0F, f37 + f8, f38 + 0.0F, f57, f29, f30, f17, f21, l, alpha); -+ this.vertex(p_234372_, f36 + 0.0F, f37 + f10, f38 + 1.0F, f57, f29, f30, f18, f22, l, alpha); -+ this.vertex(p_234372_, f36 + 1.0F, f37 + f9, f38 + 1.0F, f57, f29, f30, f19, f23, l, alpha); -+ this.vertex(p_234372_, f36 + 1.0F, f37 + f7, f38 + 0.0F, f57, f29, f30, f20, f24, l, alpha); +@@ -169,15 +_,15 @@ + float f54 = f4 * f; + float f55 = f4 * f1; + float f56 = f4 * f2; +- this.vertex(p_234372_, f37 + 0.0F, f38 + f8, f39 + 0.0F, f54, f55, f56, f17, f21, l); +- this.vertex(p_234372_, f37 + 0.0F, f38 + f10, f39 + 1.0F, f54, f55, f56, f18, f22, l); +- this.vertex(p_234372_, f37 + 1.0F, f38 + f9, f39 + 1.0F, f54, f55, f56, f19, f23, l); +- this.vertex(p_234372_, f37 + 1.0F, f38 + f7, f39 + 0.0F, f54, f55, f56, f20, f24, l); ++ this.vertex(p_234372_, f37 + 0.0F, f38 + f8, f39 + 0.0F, f54, f55, f56, f17, f21, l, alpha); ++ this.vertex(p_234372_, f37 + 0.0F, f38 + f10, f39 + 1.0F, f54, f55, f56, f18, f22, l, alpha); ++ this.vertex(p_234372_, f37 + 1.0F, f38 + f9, f39 + 1.0F, f54, f55, f56, f19, f23, l, alpha); ++ this.vertex(p_234372_, f37 + 1.0F, f38 + f7, f39 + 0.0F, f54, f55, f56, f20, f24, l, alpha); if (p_234374_.shouldRenderBackwardUpFace(p_234370_, p_234371_.above())) { -- this.vertex(p_234372_, f36 + 0.0F, f37 + f8, f38 + 0.0F, f57, f29, f30, f17, f21, l); -- this.vertex(p_234372_, f36 + 1.0F, f37 + f7, f38 + 0.0F, f57, f29, f30, f20, f24, l); -- this.vertex(p_234372_, f36 + 1.0F, f37 + f9, f38 + 1.0F, f57, f29, f30, f19, f23, l); -- this.vertex(p_234372_, f36 + 0.0F, f37 + f10, f38 + 1.0F, f57, f29, f30, f18, f22, l); -+ this.vertex(p_234372_, f36 + 0.0F, f37 + f8, f38 + 0.0F, f57, f29, f30, f17, f21, l, alpha); -+ this.vertex(p_234372_, f36 + 1.0F, f37 + f7, f38 + 0.0F, f57, f29, f30, f20, f24, l, alpha); -+ this.vertex(p_234372_, f36 + 1.0F, f37 + f9, f38 + 1.0F, f57, f29, f30, f19, f23, l, alpha); -+ this.vertex(p_234372_, f36 + 0.0F, f37 + f10, f38 + 1.0F, f57, f29, f30, f18, f22, l, alpha); +- this.vertex(p_234372_, f37 + 0.0F, f38 + f8, f39 + 0.0F, f54, f55, f56, f17, f21, l); +- this.vertex(p_234372_, f37 + 1.0F, f38 + f7, f39 + 0.0F, f54, f55, f56, f20, f24, l); +- this.vertex(p_234372_, f37 + 1.0F, f38 + f9, f39 + 1.0F, f54, f55, f56, f19, f23, l); +- this.vertex(p_234372_, f37 + 0.0F, f38 + f10, f39 + 1.0F, f54, f55, f56, f18, f22, l); ++ this.vertex(p_234372_, f37 + 0.0F, f38 + f8, f39 + 0.0F, f54, f55, f56, f17, f21, l, alpha); ++ this.vertex(p_234372_, f37 + 1.0F, f38 + f7, f39 + 0.0F, f54, f55, f56, f20, f24, l, alpha); ++ this.vertex(p_234372_, f37 + 1.0F, f38 + f9, f39 + 1.0F, f54, f55, f56, f19, f23, l, alpha); ++ this.vertex(p_234372_, f37 + 0.0F, f38 + f10, f39 + 1.0F, f54, f55, f56, f18, f22, l, alpha); } } -@@ -201,10 +_,10 @@ - float f46 = f3 * f; - float f48 = f3 * f1; - float f50 = f3 * f2; -- this.vertex(p_234372_, f36, f37 + f16, f38 + 1.0F, f46, f48, f50, f40, f43, k); -- this.vertex(p_234372_, f36, f37 + f16, f38, f46, f48, f50, f40, f42, k); -- this.vertex(p_234372_, f36 + 1.0F, f37 + f16, f38, f46, f48, f50, f41, f42, k); -- this.vertex(p_234372_, f36 + 1.0F, f37 + f16, f38 + 1.0F, f46, f48, f50, f41, f43, k); -+ this.vertex(p_234372_, f36, f37 + f16, f38 + 1.0F, f46, f48, f50, f40, f43, k, alpha); -+ this.vertex(p_234372_, f36, f37 + f16, f38, f46, f48, f50, f40, f42, k, alpha); -+ this.vertex(p_234372_, f36 + 1.0F, f37 + f16, f38, f46, f48, f50, f41, f42, k, alpha); -+ this.vertex(p_234372_, f36 + 1.0F, f37 + f16, f38 + 1.0F, f46, f48, f50, f41, f43, k, alpha); +@@ -190,10 +_,10 @@ + float f47 = f3 * f; + float f49 = f3 * f1; + float f51 = f3 * f2; +- this.vertex(p_234372_, f37, f38 + f16, f39 + 1.0F, f47, f49, f51, f41, f44, k); +- this.vertex(p_234372_, f37, f38 + f16, f39, f47, f49, f51, f41, f43, k); +- this.vertex(p_234372_, f37 + 1.0F, f38 + f16, f39, f47, f49, f51, f42, f43, k); +- this.vertex(p_234372_, f37 + 1.0F, f38 + f16, f39 + 1.0F, f47, f49, f51, f42, f44, k); ++ this.vertex(p_234372_, f37, f38 + f16, f39 + 1.0F, f47, f49, f51, f41, f44, k, alpha); ++ this.vertex(p_234372_, f37, f38 + f16, f39, f47, f49, f51, f41, f43, k, alpha); ++ this.vertex(p_234372_, f37 + 1.0F, f38 + f16, f39, f47, f49, f51, f42, f43, k, alpha); ++ this.vertex(p_234372_, f37 + 1.0F, f38 + f16, f39 + 1.0F, f47, f49, f51, f42, f44, k, alpha); } int j = this.getLightColor(p_234370_, p_234371_); -@@ -258,10 +_,9 @@ - if (flag7 && !isFaceOccludedByNeighbor(direction, Math.max(f44, f45), p_234370_.getBlockState(p_234371_.relative(direction)))) { +@@ -247,10 +_,9 @@ + if (flag7 && !isFaceOccludedByNeighbor(direction, Math.max(f45, f46), p_234370_.getBlockState(p_234371_.relative(direction)))) { BlockPos blockpos = p_234371_.relative(direction); - TextureAtlasSprite textureatlassprite2 = atextureatlassprite[1]; + TextureAtlasSprite textureatlassprite2 = textureatlassprite1; - if (!flag) { - Block block = p_234370_.getBlockState(blockpos).getBlock(); - if (block instanceof HalfTransparentBlock || block instanceof LeavesBlock) { - textureatlassprite2 = this.waterOverlay; -+ if (atextureatlassprite[2] != null) { ++ if (sprites[2] != null) { + if (p_234370_.getBlockState(blockpos).shouldDisplayFluidOverlay(p_234370_, blockpos, p_234374_)) { -+ textureatlassprite2 = atextureatlassprite[2]; ++ textureatlassprite2 = sprites[2]; } } -@@ -274,15 +_,15 @@ - float f33 = f4 * f32 * f; - float f34 = f4 * f32 * f1; - float f35 = f4 * f32 * f2; -- this.vertex(p_234372_, f47, f37 + f44, f49, f33, f34, f35, f56, f59, j); -- this.vertex(p_234372_, f51, f37 + f45, f52, f33, f34, f35, f58, f60, j); -- this.vertex(p_234372_, f51, f37 + f16, f52, f33, f34, f35, f58, f31, j); -- this.vertex(p_234372_, f47, f37 + f16, f49, f33, f34, f35, f56, f31, j); -+ this.vertex(p_234372_, f47, f37 + f44, f49, f33, f34, f35, f56, f59, j, alpha); -+ this.vertex(p_234372_, f51, f37 + f45, f52, f33, f34, f35, f58, f60, j, alpha); -+ this.vertex(p_234372_, f51, f37 + f16, f52, f33, f34, f35, f58, f31, j, alpha); -+ this.vertex(p_234372_, f47, f37 + f16, f49, f33, f34, f35, f56, f31, j, alpha); +@@ -263,15 +_,15 @@ + float f34 = f4 * f33 * f; + float f35 = f4 * f33 * f1; + float f36 = f4 * f33 * f2; +- this.vertex(p_234372_, f48, f38 + f45, f50, f34, f35, f36, f57, f30, j); +- this.vertex(p_234372_, f52, f38 + f46, f53, f34, f35, f36, f29, f31, j); +- this.vertex(p_234372_, f52, f38 + f16, f53, f34, f35, f36, f29, f32, j); +- this.vertex(p_234372_, f48, f38 + f16, f50, f34, f35, f36, f57, f32, j); ++ this.vertex(p_234372_, f48, f38 + f45, f50, f34, f35, f36, f57, f30, j, alpha); ++ this.vertex(p_234372_, f52, f38 + f46, f53, f34, f35, f36, f29, f31, j, alpha); ++ this.vertex(p_234372_, f52, f38 + f16, f53, f34, f35, f36, f29, f32, j, alpha); ++ this.vertex(p_234372_, f48, f38 + f16, f50, f34, f35, f36, f57, f32, j, alpha); if (textureatlassprite2 != this.waterOverlay) { -- this.vertex(p_234372_, f47, f37 + f16, f49, f33, f34, f35, f56, f31, j); -- this.vertex(p_234372_, f51, f37 + f16, f52, f33, f34, f35, f58, f31, j); -- this.vertex(p_234372_, f51, f37 + f45, f52, f33, f34, f35, f58, f60, j); -- this.vertex(p_234372_, f47, f37 + f44, f49, f33, f34, f35, f56, f59, j); -+ this.vertex(p_234372_, f47, f37 + f16, f49, f33, f34, f35, f56, f31, j, alpha); -+ this.vertex(p_234372_, f51, f37 + f16, f52, f33, f34, f35, f58, f31, j, alpha); -+ this.vertex(p_234372_, f51, f37 + f45, f52, f33, f34, f35, f58, f60, j, alpha); -+ this.vertex(p_234372_, f47, f37 + f44, f49, f33, f34, f35, f56, f59, j, alpha); +- this.vertex(p_234372_, f48, f38 + f16, f50, f34, f35, f36, f57, f32, j); +- this.vertex(p_234372_, f52, f38 + f16, f53, f34, f35, f36, f29, f32, j); +- this.vertex(p_234372_, f52, f38 + f46, f53, f34, f35, f36, f29, f31, j); +- this.vertex(p_234372_, f48, f38 + f45, f50, f34, f35, f36, f57, f30, j); ++ this.vertex(p_234372_, f48, f38 + f16, f50, f34, f35, f36, f57, f32, j, alpha); ++ this.vertex(p_234372_, f52, f38 + f16, f53, f34, f35, f36, f29, f32, j, alpha); ++ this.vertex(p_234372_, f52, f38 + f46, f53, f34, f35, f36, f29, f31, j, alpha); ++ this.vertex(p_234372_, f48, f38 + f45, f50, f34, f35, f36, f57, f30, j, alpha); } } } -@@ -344,10 +_,11 @@ +@@ -333,10 +_,11 @@ float p_343128_, float p_344448_, float p_344284_, diff --git a/patches/minecraft/net/minecraft/client/renderer/block/ModelBlockRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/block/ModelBlockRenderer.java.patch index ee887bd3a4..6f55593942 100644 --- a/patches/minecraft/net/minecraft/client/renderer/block/ModelBlockRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/block/ModelBlockRenderer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/renderer/block/ModelBlockRenderer.java +++ b/net/minecraft/client/renderer/block/ModelBlockRenderer.java -@@ -48,7 +_,7 @@ +@@ -49,7 +_,7 @@ int p_234389_ ) { if (!p_393688_.isEmpty()) { @@ -9,7 +9,7 @@ p_234384_.translate(p_234382_.getOffset(p_234383_)); try { -@@ -322,6 +_,11 @@ +@@ -319,6 +_,11 @@ } } @@ -21,7 +21,7 @@ public static void renderModel( PoseStack.Pose p_111068_, VertexConsumer p_111069_, -@@ -330,9 +_,11 @@ +@@ -327,9 +_,11 @@ float p_111073_, float p_111074_, int p_111075_, diff --git a/patches/minecraft/net/minecraft/client/renderer/block/model/BakedQuad.java.patch b/patches/minecraft/net/minecraft/client/renderer/block/model/BakedQuad.java.patch index 3017f12e04..441e567ab0 100644 --- a/patches/minecraft/net/minecraft/client/renderer/block/model/BakedQuad.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/block/model/BakedQuad.java.patch @@ -1,15 +1,21 @@ --- a/net/minecraft/client/renderer/block/model/BakedQuad.java +++ b/net/minecraft/client/renderer/block/model/BakedQuad.java -@@ -6,7 +_,11 @@ - import net.minecraftforge.api.distmarker.OnlyIn; - - @OnlyIn(Dist.CLIENT) --public record BakedQuad(int[] vertices, int tintIndex, Direction direction, TextureAtlasSprite sprite, boolean shade, int lightEmission) { -+public record BakedQuad(int[] vertices, int tintIndex, Direction direction, TextureAtlasSprite sprite, boolean shade, int lightEmission, boolean ambientOcclusion) { -+ public BakedQuad(int[] vertices, int tintIndex, Direction direction, TextureAtlasSprite sprite, boolean shade, int lightEmission) { -+ this(vertices, tintIndex, direction, sprite, shade, lightEmission, true); -+ } +@@ -20,9 +_,17 @@ + Direction direction, + TextureAtlasSprite sprite, + boolean shade, +- int lightEmission ++ int lightEmission, ++ boolean ambientOcclusion + ) { + public static final int VERTEX_COUNT = 4; + ++ public BakedQuad( ++ Vector3fc position0, Vector3fc position1, Vector3fc position2, Vector3fc position3, ++ long packedUV0, long packedUV1, long packedUV2, long packedUV3, ++ int tintIndex, Direction direction, TextureAtlasSprite sprite, boolean shade, int lightEmission) { ++ this(position0, position1, position2, position3, packedUV0, packedUV1, packedUV2, packedUV3, tintIndex, direction, sprite, shade, lightEmission, true); ++ } + public boolean isTinted() { return this.tintIndex != -1; - } diff --git a/patches/minecraft/net/minecraft/client/renderer/block/model/BlockElementFace.java.patch b/patches/minecraft/net/minecraft/client/renderer/block/model/BlockElementFace.java.patch index e8be6a9071..5246327b28 100644 --- a/patches/minecraft/net/minecraft/client/renderer/block/model/BlockElementFace.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/block/model/BlockElementFace.java.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/client/renderer/block/model/BlockElementFace.java +++ b/net/minecraft/client/renderer/block/model/BlockElementFace.java @@ -15,9 +_,18 @@ - import net.minecraftforge.api.distmarker.OnlyIn; + import org.jspecify.annotations.Nullable; @OnlyIn(Dist.CLIENT) --public record BlockElementFace(@Nullable Direction cullForDirection, int tintIndex, String texture, @Nullable BlockElementFace.UVs uvs, Quadrant rotation) { -+public record BlockElementFace(@Nullable Direction cullForDirection, int tintIndex, String texture, @Nullable BlockElementFace.UVs uvs, Quadrant rotation, @Nullable net.minecraftforge.client.model.ForgeFaceData data) { +-public record BlockElementFace(@Nullable Direction cullForDirection, int tintIndex, String texture, BlockElementFace.@Nullable UVs uvs, Quadrant rotation) { ++public record BlockElementFace(@Nullable Direction cullForDirection, int tintIndex, String texture, BlockElementFace.@Nullable UVs uvs, Quadrant rotation, net.minecraftforge.client.model.@Nullable ForgeFaceData data) { public static final int NO_TINT = -1; -+ public BlockElementFace(@Nullable Direction cullForDirection, int tintIndex, String texture, @Nullable BlockElementFace.UVs uvs, Quadrant rotation) { ++ public BlockElementFace(@Nullable Direction cullForDirection, int tintIndex, String texture, BlockElementFace.@Nullable UVs uvs, Quadrant rotation) { + this(cullForDirection, tintIndex, texture, uvs, rotation, null); + } + diff --git a/patches/minecraft/net/minecraft/client/renderer/block/model/BlockModel.java.patch b/patches/minecraft/net/minecraft/client/renderer/block/model/BlockModel.java.patch index c30bc4394f..3f11530b5a 100644 --- a/patches/minecraft/net/minecraft/client/renderer/block/model/BlockModel.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/block/model/BlockModel.java.patch @@ -1,20 +1,20 @@ --- a/net/minecraft/client/renderer/block/model/BlockModel.java +++ b/net/minecraft/client/renderer/block/model/BlockModel.java -@@ -28,8 +_,20 @@ +@@ -27,8 +_,20 @@ @Nullable Boolean ambientOcclusion, @Nullable ItemTransforms transforms, TextureSlots.Data textureSlots, -- @Nullable ResourceLocation parent -+ @Nullable ResourceLocation parent, -+ @Nullable net.minecraftforge.client.model.ForgeBlockModelData forgeData +- @Nullable Identifier parent ++ @Nullable Identifier parent, ++ net.minecraftforge.client.model.@Nullable ForgeBlockModelData forgeData ) implements UnbakedModel { + public BlockModel( + @Nullable UnbakedGeometry geometry, -+ @Nullable UnbakedModel.GuiLight guiLight, ++ UnbakedModel.@Nullable GuiLight guiLight, + @Nullable Boolean ambientOcclusion, + @Nullable ItemTransforms transforms, + TextureSlots.Data textureSlots, -+ @Nullable ResourceLocation parent ++ @Nullable Identifier parent + ) { + this(geometry, guiLight, ambientOcclusion, transforms, textureSlots, parent, null); + } @@ -22,21 +22,21 @@ @VisibleForTesting static final Gson GSON = new GsonBuilder() .registerTypeAdapter(BlockModel.class, new BlockModel.Deserializer()) -@@ -97,8 +_,9 @@ +@@ -91,8 +_,9 @@ unbakedmodel$guilight = UnbakedModel.GuiLight.getByName(GsonHelper.getAsString(jsonobject, "gui_light")); } + var forgeData = net.minecraftforge.client.ForgeHooksClient.deserializeBlockModel(jsonobject, p_111500_); - ResourceLocation resourcelocation = s.isEmpty() ? null : ResourceLocation.parse(s); -- return new BlockModel(unbakedgeometry, unbakedmodel$guilight, obool, itemtransforms, textureslots$data, resourcelocation); -+ return new BlockModel(unbakedgeometry, unbakedmodel$guilight, obool, itemtransforms, textureslots$data, resourcelocation, forgeData); + Identifier identifier = s.isEmpty() ? null : Identifier.parse(s); +- return new BlockModel(unbakedgeometry, unbakedmodel$guilight, obool, itemtransforms, textureslots$data, identifier); ++ return new BlockModel(unbakedgeometry, unbakedmodel$guilight, obool, itemtransforms, textureslots$data, identifier, forgeData); } private TextureSlots.Data getTextureMap(JsonObject p_111510_) { -@@ -121,6 +_,9 @@ +@@ -113,6 +_,9 @@ + } - @Nullable - protected UnbakedGeometry getElements(JsonDeserializationContext p_111507_, JsonObject p_111508_) { + protected @Nullable UnbakedGeometry getElements(JsonDeserializationContext p_111507_, JsonObject p_111508_) { + var geo = net.minecraftforge.client.ForgeHooksClient.deserializeBlockModelGeometry(p_111508_, p_111507_); + if (geo != null) + return geo; diff --git a/patches/minecraft/net/minecraft/client/renderer/block/model/BlockModelPart.java.patch b/patches/minecraft/net/minecraft/client/renderer/block/model/BlockModelPart.java.patch index 775c8f68f9..e9be8b4949 100644 --- a/patches/minecraft/net/minecraft/client/renderer/block/model/BlockModelPart.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/block/model/BlockModelPart.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/client/renderer/block/model/BlockModelPart.java +++ b/net/minecraft/client/renderer/block/model/BlockModelPart.java @@ -10,7 +_,7 @@ - import net.minecraftforge.api.distmarker.OnlyIn; + import org.jspecify.annotations.Nullable; @OnlyIn(Dist.CLIENT) -public interface BlockModelPart { diff --git a/patches/minecraft/net/minecraft/client/renderer/block/model/FaceBakery.java.patch b/patches/minecraft/net/minecraft/client/renderer/block/model/FaceBakery.java.patch index 4a6b471805..7c241afd8a 100644 --- a/patches/minecraft/net/minecraft/client/renderer/block/model/FaceBakery.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/block/model/FaceBakery.java.patch @@ -1,18 +1,12 @@ --- a/net/minecraft/client/renderer/block/model/FaceBakery.java +++ b/net/minecraft/client/renderer/block/model/FaceBakery.java -@@ -65,7 +_,14 @@ - recalculateWinding(aint, direction); - } - -- return new BakedQuad(aint, p_111603_.tintIndex(), direction, p_111604_, p_111608_, p_364904_); -+ var data = p_111603_.data(); -+ var quad = new BakedQuad(aint, p_111603_.tintIndex(), direction, p_111604_, p_111608_, p_364904_, data.ambientOcclusion()); -+ if (!net.minecraftforge.client.model.ForgeFaceData.DEFAULT.equals(data)) { -+ quad = net.minecraftforge.client.model.QuadTransformers.applyingLightmap(data.blockLight(), data.skyLight()) -+ .andThen(net.minecraftforge.client.model.QuadTransformers.applyingColor(data.color())) -+ .process(quad); -+ } -+ return quad; +@@ -93,7 +_,8 @@ + Objects.requireNonNullElse(direction, Direction.UP), + p_111604_, + p_111608_, +- p_364904_ ++ p_364904_, ++ p_111603_.data().ambientOcclusion() + ); } - private static BlockElementFace.UVs shrinkUVs(TextureAtlasSprite p_397002_, BlockElementFace.UVs p_394057_) { diff --git a/patches/minecraft/net/minecraft/client/renderer/block/model/SimpleModelWrapper.java.patch b/patches/minecraft/net/minecraft/client/renderer/block/model/SimpleModelWrapper.java.patch index ce2be91fb8..877aa5978a 100644 --- a/patches/minecraft/net/minecraft/client/renderer/block/model/SimpleModelWrapper.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/block/model/SimpleModelWrapper.java.patch @@ -1,24 +1,26 @@ --- a/net/minecraft/client/renderer/block/model/SimpleModelWrapper.java +++ b/net/minecraft/client/renderer/block/model/SimpleModelWrapper.java -@@ -13,14 +_,19 @@ - import net.minecraftforge.api.distmarker.OnlyIn; +@@ -18,7 +_,7 @@ + import org.slf4j.Logger; @OnlyIn(Dist.CLIENT) -public record SimpleModelWrapper(QuadCollection quads, boolean useAmbientOcclusion, TextureAtlasSprite particleIcon) implements BlockModelPart { +public record SimpleModelWrapper(QuadCollection quads, boolean useAmbientOcclusion, TextureAtlasSprite particleIcon, net.minecraft.client.renderer.chunk.ChunkSectionLayer layer, net.minecraft.client.renderer.chunk.ChunkSectionLayer layerFast) implements BlockModelPart { - public static SimpleModelWrapper bake(ModelBaker p_395631_, ResourceLocation p_396950_, ModelState p_396899_) { - ResolvedModel resolvedmodel = p_395631_.getModel(p_396950_); - TextureSlots textureslots = resolvedmodel.getTopTextureSlots(); - boolean flag = resolvedmodel.getTopAmbientOcclusion(); - TextureAtlasSprite textureatlassprite = resolvedmodel.resolveParticleSprite(textureslots, p_395631_); - QuadCollection quadcollection = resolvedmodel.bakeTopGeometry(textureslots, p_395631_, p_396899_); -- return new SimpleModelWrapper(quadcollection, flag, textureatlassprite); -+ var ctx = resolvedmodel.getContext(); -+ return new SimpleModelWrapper(quadcollection, flag, textureatlassprite, ctx.getRenderType().block(), ctx.getRenderTypeFast().block()); + private static final Logger LOGGER = LogUtils.getLogger(); + + public static BlockModelPart bake(ModelBaker p_395631_, Identifier p_457297_, ModelState p_396899_) { +@@ -44,8 +_,13 @@ + LOGGER.warn("Rejecting block model {}, since it contains sprites from outside of supported atlas: {}", p_457297_, multimap); + return p_395631_.missingBlockModelPart(); + } else { +- return new SimpleModelWrapper(quadcollection, flag, textureatlassprite); ++ var ctx = resolvedmodel.getContext(); ++ return new SimpleModelWrapper(quadcollection, flag, textureatlassprite, ctx.getRenderType().block(), ctx.getRenderTypeFast().block()); + } + } + -+ public SimpleModelWrapper(QuadCollection quads, boolean useAmbientOcclusion, TextureAtlasSprite particleIcon) { -+ this(quads, useAmbientOcclusion, particleIcon, null, null); ++ public SimpleModelWrapper(QuadCollection quadcollection, boolean useAmbientOcclusion, TextureAtlasSprite particleIcon) { ++ this(quadcollection, useAmbientOcclusion, particleIcon, null, null); } @Override diff --git a/patches/minecraft/net/minecraft/client/renderer/block/model/multipart/MultiPartModel.java.patch b/patches/minecraft/net/minecraft/client/renderer/block/model/multipart/MultiPartModel.java.patch index c084fc6f0d..03dbedf447 100644 --- a/patches/minecraft/net/minecraft/client/renderer/block/model/multipart/MultiPartModel.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/block/model/multipart/MultiPartModel.java.patch @@ -1,16 +1,15 @@ --- a/net/minecraft/client/renderer/block/model/multipart/MultiPartModel.java +++ b/net/minecraft/client/renderer/block/model/multipart/MultiPartModel.java -@@ -26,6 +_,9 @@ +@@ -25,6 +_,8 @@ + private final MultiPartModel.SharedBakedState shared; private final BlockState blockState; - @Nullable - private List models; + private @Nullable List models; + private boolean cacheKey = false; -+ @Nullable -+ private java.util.Collection cache; ++ private java.util.@Nullable Collection cache; MultiPartModel(MultiPartModel.SharedBakedState p_391554_, BlockState p_397918_) { this.shared = p_391554_; -@@ -38,6 +_,11 @@ +@@ -37,6 +_,11 @@ } @Override @@ -22,7 +21,7 @@ public void collectParts(RandomSource p_391247_, List p_397207_) { if (this.models == null) { this.models = this.shared.selectModels(this.blockState); -@@ -51,6 +_,33 @@ +@@ -50,6 +_,33 @@ } } @@ -56,7 +55,7 @@ @OnlyIn(Dist.CLIENT) public record Selector(Predicate condition, T model) { public MultiPartModel.Selector with(S p_393772_) { -@@ -62,6 +_,7 @@ +@@ -61,6 +_,7 @@ static final class SharedBakedState { private final List> selectors; final TextureAtlasSprite particleIcon; @@ -64,7 +63,7 @@ private final Map> subsets = new ConcurrentHashMap<>(); private static BlockStateModel getFirstModel(List> p_392132_) { -@@ -74,8 +_,8 @@ +@@ -73,8 +_,8 @@ public SharedBakedState(List> p_393647_) { this.selectors = p_393647_; 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 ae9cf16c1e..3cfc89f09f 100644 --- a/patches/minecraft/net/minecraft/client/renderer/blockentity/SkullBlockRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/blockentity/SkullBlockRenderer.java.patch @@ -1,13 +1,13 @@ --- a/net/minecraft/client/renderer/blockentity/SkullBlockRenderer.java +++ b/net/minecraft/client/renderer/blockentity/SkullBlockRenderer.java -@@ -36,6 +_,7 @@ +@@ -37,6 +_,7 @@ @OnlyIn(Dist.CLIENT) 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")); + public static final Map SKIN_BY_TYPE = Util.make(Maps.newHashMap(), p_340906_ -> { + p_340906_.put(SkullBlock.Types.SKELETON, Identifier.withDefaultNamespace("textures/entity/skeleton/skeleton.png")); @@ -61,7 +_,9 @@ case PIGLIN -> new PiglinHeadModel(p_376421_.bakeLayer(ModelLayers.PIGLIN_HEAD)); }); diff --git a/patches/minecraft/net/minecraft/client/renderer/chunk/RenderSectionRegion.java.patch b/patches/minecraft/net/minecraft/client/renderer/chunk/RenderSectionRegion.java.patch index bf894c0791..eda7b21805 100644 --- a/patches/minecraft/net/minecraft/client/renderer/chunk/RenderSectionRegion.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/chunk/RenderSectionRegion.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/renderer/chunk/RenderSectionRegion.java +++ b/net/minecraft/client/renderer/chunk/RenderSectionRegion.java -@@ -90,4 +_,9 @@ +@@ -89,4 +_,9 @@ public static int index(int p_409495_, int p_409337_, int p_407713_, int p_409077_, int p_406510_, int p_408332_) { return p_409077_ - p_409495_ + (p_406510_ - p_409337_) * 3 + (p_408332_ - p_407713_) * 3 * 3; } diff --git a/patches/minecraft/net/minecraft/client/renderer/debug/EntityHitboxDebugRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/debug/EntityHitboxDebugRenderer.java.patch new file mode 100644 index 0000000000..952a23e3c4 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/renderer/debug/EntityHitboxDebugRenderer.java.patch @@ -0,0 +1,13 @@ +--- a/net/minecraft/client/renderer/debug/EntityHitboxDebugRenderer.java ++++ b/net/minecraft/client/renderer/debug/EntityHitboxDebugRenderer.java +@@ -100,8 +_,8 @@ + ); + } + +- if (p_450643_ instanceof EnderDragon enderdragon) { +- for (EnderDragonPart enderdragonpart : enderdragon.getSubEntities()) { ++ if (p_450643_.isMultipartEntity()) { ++ for (var enderdragonpart : p_450643_.getParts()) { + Vec3 vec34 = enderdragonpart.position(); + Vec3 vec35 = enderdragonpart.getPosition(p_456396_); + Vec3 vec36 = vec35.subtract(vec34); diff --git a/patches/minecraft/net/minecraft/client/renderer/entity/EnderDragonRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/entity/EnderDragonRenderer.java.patch deleted file mode 100644 index 05b0a87312..0000000000 --- a/patches/minecraft/net/minecraft/client/renderer/entity/EnderDragonRenderer.java.patch +++ /dev/null @@ -1,19 +0,0 @@ ---- a/net/minecraft/client/renderer/entity/EnderDragonRenderer.java -+++ b/net/minecraft/client/renderer/entity/EnderDragonRenderer.java -@@ -238,11 +_,15 @@ - - protected void extractAdditionalHitboxes(EnderDragon p_394570_, Builder p_396096_, float p_397646_) { - super.extractAdditionalHitboxes(p_394570_, p_396096_, p_397646_); -+ } -+ -+ public static void extractAdditionalHitboxexGeneric(net.minecraft.world.entity.Entity p_394570_, Builder p_396096_, float p_397646_) { -+ if (!p_394570_.isMultipartEntity()) return; - double d0 = -Mth.lerp(p_397646_, p_394570_.xOld, p_394570_.getX()); - double d1 = -Mth.lerp(p_397646_, p_394570_.yOld, p_394570_.getY()); - double d2 = -Mth.lerp(p_397646_, p_394570_.zOld, p_394570_.getZ()); - -- for (EnderDragonPart enderdragonpart : p_394570_.getSubEntities()) { -+ for (var enderdragonpart : p_394570_.getParts()) { - AABB aabb = enderdragonpart.getBoundingBox(); - HitboxRenderState hitboxrenderstate = new HitboxRenderState( - aabb.minX - enderdragonpart.getX(), 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 1afd97cb71..470f778b86 100644 --- a/patches/minecraft/net/minecraft/client/renderer/entity/EntityRenderDispatcher.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/entity/EntityRenderDispatcher.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/renderer/entity/EntityRenderDispatcher.java +++ b/net/minecraft/client/renderer/entity/EntityRenderDispatcher.java -@@ -207,6 +_,14 @@ +@@ -201,6 +_,14 @@ return this.itemInHandRenderer; } @@ -15,7 +15,7 @@ @Override public void onResourceManagerReload(ResourceManager p_174004_) { EntityRendererProvider.Context entityrendererprovider$context = new EntityRendererProvider.Context( -@@ -224,5 +_,6 @@ +@@ -218,5 +_,6 @@ this.renderers = EntityRenderers.createEntityRenderers(entityrendererprovider$context); this.playerRenderers = EntityRenderers.createAvatarRenderers(entityrendererprovider$context); this.mannequinRenderers = EntityRenderers.createAvatarRenderers(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 7a736d30e8..1e2c38dba6 100644 --- a/patches/minecraft/net/minecraft/client/renderer/entity/EntityRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/entity/EntityRenderer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/renderer/entity/EntityRenderer.java +++ b/net/minecraft/client/renderer/entity/EntityRenderer.java -@@ -131,9 +_,10 @@ +@@ -125,9 +_,10 @@ } protected void submitNameTag(S p_429896_, PoseStack p_428845_, SubmitNodeCollector p_426439_, CameraRenderState p_428408_) { @@ -13,7 +13,7 @@ ); } } -@@ -184,7 +_,7 @@ +@@ -177,7 +_,7 @@ if (this.entityRenderDispatcher.camera != null) { p_367427_.distanceToCameraSq = this.entityRenderDispatcher.distanceToSqr(p_367571_); @@ -22,11 +22,3 @@ 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_) { -+ net.minecraft.client.renderer.entity.EnderDragonRenderer.extractAdditionalHitboxexGeneric(p_392955_, p_395671_, p_395030_); // Forge: Extract for our generic multi-part entity system - } - - @Nullable diff --git a/patches/minecraft/net/minecraft/client/renderer/entity/HumanoidMobRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/entity/HumanoidMobRenderer.java.patch index 1bfdbebfdb..bccb9fca61 100644 --- a/patches/minecraft/net/minecraft/client/renderer/entity/HumanoidMobRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/entity/HumanoidMobRenderer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/renderer/entity/HumanoidMobRenderer.java +++ b/net/minecraft/client/renderer/entity/HumanoidMobRenderer.java -@@ -51,7 +_,7 @@ +@@ -61,7 +_,7 @@ p_369040_.isCrouching = p_362179_.isCrouching(); p_369040_.isFallFlying = p_362179_.isFallFlying(); p_369040_.isVisuallySwimming = p_362179_.isVisuallySwimming(); diff --git a/patches/minecraft/net/minecraft/client/renderer/entity/ItemRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/entity/ItemRenderer.java.patch deleted file mode 100644 index fc6cccb768..0000000000 --- a/patches/minecraft/net/minecraft/client/renderer/entity/ItemRenderer.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/client/renderer/entity/ItemRenderer.java -+++ b/net/minecraft/client/renderer/entity/ItemRenderer.java -@@ -111,7 +_,7 @@ - f3 = 1.0F; - } - -- p_115164_.putBulkData(posestack$pose, bakedquad, f1, f2, f3, f, p_115167_, p_115168_); -+ 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 74f0203392..c79a00fe21 100644 --- a/patches/minecraft/net/minecraft/client/renderer/entity/LivingEntityRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/entity/LivingEntityRenderer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/renderer/entity/LivingEntityRenderer.java +++ b/net/minecraft/client/renderer/entity/LivingEntityRenderer.java -@@ -73,6 +_,7 @@ +@@ -72,6 +_,7 @@ } public void submit(S p_427824_, PoseStack p_423787_, SubmitNodeCollector p_424901_, CameraRenderState p_422963_) { @@ -8,7 +8,7 @@ p_423787_.pushPose(); if (p_427824_.hasPose(Pose.SLEEPING)) { Direction direction = p_427824_.bedOrientation; -@@ -108,6 +_,7 @@ +@@ -107,6 +_,7 @@ p_423787_.popPose(); super.submit(p_427824_, p_423787_, p_424901_, p_422963_); @@ -16,19 +16,11 @@ } protected boolean shouldRenderLayers(S p_360804_) { -@@ -286,6 +_,7 @@ +@@ -284,6 +_,7 @@ p_363057_.isFullyFrozen = p_368665_.isFullyFrozen(); p_363057_.isBaby = p_368665_.isBaby(); p_363057_.isInWater = p_368665_.isInWater(); + p_363057_.isInWater = p_368665_.isInWaterOrSwimmable(); p_363057_.isAutoSpinAttack = p_368665_.isAutoSpinAttack(); + p_363057_.ticksSinceKineticHitFeedback = p_368665_.getTicksSinceLastKineticHitFeedback(p_364497_); p_363057_.hasRedOverlay = p_368665_.hurtTime > 0 || p_368665_.deathTime > 0; - ItemStack itemstack = p_368665_.getItemBySlot(EquipmentSlot.HEAD); -@@ -309,6 +_,7 @@ - } - - protected void extractAdditionalHitboxes(T p_392957_, Builder p_396936_, float p_397822_) { -+ super.extractAdditionalHitboxes(p_392957_, p_396936_, p_397822_); - AABB aabb = p_392957_.getBoundingBox(); - float f = 0.01F; - HitboxRenderState hitboxrenderstate = new HitboxRenderState( 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 cf96a0200b..17f3d4ba89 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 -@@ -59,7 +_,7 @@ +@@ -58,7 +_,7 @@ + } } - @Nullable -- private static ResourceLocation getPlayerElytraTexture(HumanoidRenderState p_364125_) { -+ protected ResourceLocation getPlayerElytraTexture(HumanoidRenderState p_364125_) { +- protected static @Nullable Identifier getPlayerElytraTexture(HumanoidRenderState p_364125_) { ++ protected @Nullable Identifier getPlayerElytraTexture(HumanoidRenderState p_364125_) { 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 index ba3663b2b1..325552266b 100644 --- a/patches/minecraft/net/minecraft/client/renderer/entity/player/AvatarRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/entity/player/AvatarRenderer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/renderer/entity/player/AvatarRenderer.java +++ b/net/minecraft/client/renderer/entity/player/AvatarRenderer.java -@@ -92,7 +_,7 @@ +@@ -96,7 +_,7 @@ private static HumanoidModel.ArmPose getArmPose(Avatar p_422497_, ItemStack p_429700_, InteractionHand p_430481_) { if (p_429700_.isEmpty()) { return HumanoidModel.ArmPose.EMPTY; @@ -9,18 +9,18 @@ return HumanoidModel.ArmPose.CROSSBOW_HOLD; } else { if (p_422497_.getUsedItemHand() == p_430481_ && p_422497_.getUseItemRemainingTicks() > 0) { -@@ -126,6 +_,10 @@ - } +@@ -138,7 +_,9 @@ + if (swinganimation != null && swinganimation.type() == SwingAnimationType.STAB && p_422497_.swinging) { + return HumanoidModel.ArmPose.SPEAR; + } else { +- return p_429700_.is(ItemTags.SPEARS) ? HumanoidModel.ArmPose.SPEAR : HumanoidModel.ArmPose.ITEM; ++ if (p_429700_.is(ItemTags.SPEARS)) return HumanoidModel.ArmPose.SPEAR; ++ var pose = net.minecraftforge.client.extensions.common.IClientItemExtensions.of(p_429700_).getArmPose(p_422497_, p_430481_, p_429700_); ++ return pose == null ? HumanoidModel.ArmPose.ITEM : pose; } - -+ 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 @@ +@@ -162,9 +_,10 @@ p_423892_.translate(0.0F, 9.0F * 1.15F * 0.025F, 0.0F); } @@ -33,20 +33,20 @@ ); } -@@ -239,10 +_,12 @@ +@@ -252,10 +_,12 @@ } - public void renderRightHand(PoseStack p_428282_, SubmitNodeCollector p_424928_, int p_427204_, ResourceLocation p_423115_, boolean p_431039_) { + public void renderRightHand(PoseStack p_428282_, SubmitNodeCollector p_424928_, int p_427204_, Identifier p_450403_, 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_); + this.renderHand(p_428282_, p_424928_, p_427204_, p_450403_, this.model.rightArm, p_431039_); } - public void renderLeftHand(PoseStack p_424615_, SubmitNodeCollector p_425532_, int p_427068_, ResourceLocation p_425626_, boolean p_423290_) { + public void renderLeftHand(PoseStack p_424615_, SubmitNodeCollector p_425532_, int p_427068_, Identifier p_458705_, 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_); + this.renderHand(p_424615_, p_425532_, p_427068_, p_458705_, this.model.leftArm, p_423290_); } -@@ -295,5 +_,12 @@ +@@ -306,5 +_,12 @@ public static boolean isPlayerUpsideDown(Player p_424650_) { return isUpsideDownName(p_424650_.getGameProfile().name()); diff --git a/patches/minecraft/net/minecraft/client/renderer/fog/FogRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/fog/FogRenderer.java.patch index 68b76de594..6ffbf9c922 100644 --- a/patches/minecraft/net/minecraft/client/renderer/fog/FogRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/fog/FogRenderer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/renderer/fog/FogRenderer.java +++ b/net/minecraft/client/renderer/fog/FogRenderer.java -@@ -155,6 +_,13 @@ +@@ -151,6 +_,13 @@ f2 = Mth.lerp(f6, f2, f2 * f7); } @@ -14,7 +14,7 @@ return new Vector4f(f5, f1, f2, 1.0F); } } -@@ -181,6 +_,7 @@ +@@ -177,6 +_,7 @@ float f2 = Mth.clamp(f1 / 10.0F, 4.0F, 64.0F); fogdata.renderDistanceStart = f1 - f2; fogdata.renderDistanceEnd = f1; diff --git a/patches/minecraft/net/minecraft/client/renderer/rendertype/RenderSetup.java.patch b/patches/minecraft/net/minecraft/client/renderer/rendertype/RenderSetup.java.patch new file mode 100644 index 0000000000..df8809c429 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/renderer/rendertype/RenderSetup.java.patch @@ -0,0 +1,67 @@ +--- a/net/minecraft/client/renderer/rendertype/RenderSetup.java ++++ b/net/minecraft/client/renderer/rendertype/RenderSetup.java +@@ -32,6 +_,7 @@ + final boolean sortOnUpload; + final int bufferSize; + final LayeringTransform layeringTransform; ++ final Map texturesWithSamplers; + + RenderSetup( + RenderPipeline p_455545_, +@@ -44,7 +_,8 @@ + RenderSetup.OutlineProperty p_454071_, + boolean p_455910_, + boolean p_450946_, +- int p_453755_ ++ int p_453755_, ++ Map texturesWithSamplers + ) { + this.pipeline = p_455545_; + this.textures = p_455652_; +@@ -57,6 +_,7 @@ + this.affectsCrumbling = p_455910_; + this.sortOnUpload = p_450946_; + this.bufferSize = p_453755_; ++ this.texturesWithSamplers = texturesWithSamplers; + } + + @Override +@@ -114,6 +_,8 @@ + ); + } + ++ map.putAll(this.texturesWithSamplers); ++ + return map; + } + } +@@ -149,6 +_,7 @@ + private int bufferSize = 1536; + private RenderSetup.OutlineProperty outlineProperty = RenderSetup.OutlineProperty.NONE; + private final Map textures = new HashMap<>(); ++ private final Map texturesWithSamplers = new HashMap<>(); + + RenderSetupBuilder(RenderPipeline p_453804_) { + this.pipeline = p_453804_; +@@ -164,6 +_,11 @@ + return this; + } + ++ public RenderSetup.RenderSetupBuilder withTexture(String name, GpuTextureView textureView, GpuSampler sampler) { ++ this.texturesWithSamplers.put(name, new RenderSetup.TextureAndSampler(textureView, sampler)); ++ return this; ++ } ++ + public RenderSetup.RenderSetupBuilder useLightmap() { + this.useLightmap = true; + return this; +@@ -221,7 +_,8 @@ + this.outlineProperty, + this.affectsCrumbling, + this.sortOnUpload, +- this.bufferSize ++ this.bufferSize, ++ this.texturesWithSamplers + ); + } + } diff --git a/patches/minecraft/net/minecraft/client/renderer/rendertype/RenderTypes.java.patch b/patches/minecraft/net/minecraft/client/renderer/rendertype/RenderTypes.java.patch new file mode 100644 index 0000000000..d56743099a --- /dev/null +++ b/patches/minecraft/net/minecraft/client/renderer/rendertype/RenderTypes.java.patch @@ -0,0 +1,44 @@ +--- a/net/minecraft/client/renderer/rendertype/RenderTypes.java ++++ b/net/minecraft/client/renderer/rendertype/RenderTypes.java +@@ -542,7 +_,7 @@ + } + + public static RenderType text(Identifier p_456274_) { +- return TEXT.apply(p_456274_); ++ return net.minecraftforge.client.ForgeRenderTypes.getText(p_456274_); + } + + public static RenderType textBackground() { +@@ -550,19 +_,19 @@ + } + + public static RenderType textIntensity(Identifier p_460070_) { +- return TEXT_INTENSITY.apply(p_460070_); ++ return net.minecraftforge.client.ForgeRenderTypes.getTextIntensity(p_460070_); + } + + public static RenderType textPolygonOffset(Identifier p_450888_) { +- return TEXT_POLYGON_OFFSET.apply(p_450888_); ++ return net.minecraftforge.client.ForgeRenderTypes.getTextPolygonOffset(p_450888_); + } + + public static RenderType textIntensityPolygonOffset(Identifier p_457059_) { +- return TEXT_INTENSITY_POLYGON_OFFSET.apply(p_457059_); ++ return net.minecraftforge.client.ForgeRenderTypes.getTextIntensityPolygonOffset(p_457059_); + } + + public static RenderType textSeeThrough(Identifier p_452096_) { +- return TEXT_SEE_THROUGH.apply(p_452096_); ++ return net.minecraftforge.client.ForgeRenderTypes.getTextSeeThrough(p_452096_); + } + + public static RenderType textBackgroundSeeThrough() { +@@ -570,7 +_,7 @@ + } + + public static RenderType textIntensitySeeThrough(Identifier p_453978_) { +- return TEXT_INTENSITY_SEE_THROUGH.apply(p_453978_); ++ return net.minecraftforge.client.ForgeRenderTypes.getTextIntensitySeeThrough(p_453978_); + } + + public static RenderType lightning() { diff --git a/patches/minecraft/net/minecraft/client/renderer/state/BlockOutlineRenderState.java.patch b/patches/minecraft/net/minecraft/client/renderer/state/BlockOutlineRenderState.java.patch index 1b68c74453..f3a240d193 100644 --- a/patches/minecraft/net/minecraft/client/renderer/state/BlockOutlineRenderState.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/state/BlockOutlineRenderState.java.patch @@ -6,7 +6,7 @@ @Nullable VoxelShape occlusionShape, - @Nullable VoxelShape interactionShape + @Nullable VoxelShape interactionShape, -+ @Nullable net.minecraftforge.client.event.RenderHighlightEvent.Callback customRenderer ++ net.minecraftforge.client.event.RenderHighlightEvent.@Nullable 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); diff --git a/patches/minecraft/net/minecraft/client/renderer/texture/AbstractTexture.java.patch b/patches/minecraft/net/minecraft/client/renderer/texture/AbstractTexture.java.patch deleted file mode 100644 index cb66eaadd2..0000000000 --- a/patches/minecraft/net/minecraft/client/renderer/texture/AbstractTexture.java.patch +++ /dev/null @@ -1,31 +0,0 @@ ---- a/net/minecraft/client/renderer/texture/AbstractTexture.java -+++ b/net/minecraft/client/renderer/texture/AbstractTexture.java -@@ -27,6 +_,8 @@ - if (this.texture == null) { - throw new IllegalStateException("Texture does not exist, can't get change its filter before something initializes it"); - } else { -+ this.blur = p_117961_; -+ this.mipmap = p_117962_; - this.texture.setTextureFilter(p_117961_ ? FilterMode.LINEAR : FilterMode.NEAREST, p_117962_); - } - } -@@ -50,6 +_,19 @@ - this.textureView.close(); - this.textureView = null; - } -+ } -+ -+ // FORGE: This seems to have been stripped out, but we need it -+ private boolean blur, mipmap, lastBlur, lastMipmap; -+ -+ public void setBlurMipmap(boolean blur, boolean mipmap) { -+ this.lastBlur = this.blur; -+ this.lastMipmap = this.mipmap; -+ setFilter(blur, mipmap); -+ } -+ -+ public void restoreLastBlurMipmap() { -+ setFilter(this.lastBlur, this.lastMipmap); - } - - public GpuTexture getTexture() { diff --git a/patches/minecraft/net/minecraft/client/renderer/texture/MipmapGenerator.java.patch b/patches/minecraft/net/minecraft/client/renderer/texture/MipmapGenerator.java.patch index 74dc5c4615..21aed2a1a7 100644 --- a/patches/minecraft/net/minecraft/client/renderer/texture/MipmapGenerator.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/texture/MipmapGenerator.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/client/renderer/texture/MipmapGenerator.java +++ b/net/minecraft/client/renderer/texture/MipmapGenerator.java -@@ -26,12 +_,16 @@ - anativeimage[0] = p_251300_[0]; - boolean flag = hasTransparentPixel(anativeimage[0]); +@@ -112,12 +_,16 @@ + float f = p_450366_ == MipmapStrategy.STRICT_CUTOUT ? 0.3F : 0.5F; + float f1 = flag ? alphaTestCoverage(p_251300_[0], f, 1.0F) : 0.0F; + int maxMipmapLevel = net.minecraftforge.client.ForgeHooksClient.getMaxMipmapLevel(anativeimage[0].getWidth(), anativeimage[0].getHeight()); for (int i = 1; i <= p_252326_; i++) { @@ -18,9 +18,9 @@ int j = nativeimage1.getWidth(); int k = nativeimage1.getHeight(); -@@ -49,6 +_,7 @@ - ) - ); +@@ -136,6 +_,7 @@ + + nativeimage1.setPixel(l, i1, j2); } + } } 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 506f6754eb..b415440690 100644 --- a/patches/minecraft/net/minecraft/client/renderer/texture/SpriteContents.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/texture/SpriteContents.java.patch @@ -1,16 +1,6 @@ --- a/net/minecraft/client/renderer/texture/SpriteContents.java +++ b/net/minecraft/client/renderer/texture/SpriteContents.java -@@ -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++) { -+ // Forge: Skip uploading if the texture would be made invalid by mip level -+ if ((this.width >> i) <= 0 || (this.height >> i) <= 0) -+ break; - RenderSystem.getDevice() - .createCommandEncoder() - .writeToTexture( -@@ -167,6 +_,10 @@ +@@ -168,6 +_,10 @@ return this.name; } @@ -21,23 +11,3 @@ public IntStream getUniqueFrames() { return this.animatedTexture != null ? this.animatedTexture.getUniqueFrames() : IntStream.of(1); } -@@ -269,7 +_,8 @@ - for (int i = 0; i < this.activeFrame.length; i++) { - int j = SpriteContents.this.width >> i; - int k = SpriteContents.this.height >> i; -- this.activeFrame[i] = new NativeImage(j, k, false); -+ // Forge: Guard against invalid texture size, because we allow generating mipmaps regardless of texture sizes -+ this.activeFrame[i] = new NativeImage(Math.max(1, j), Math.max(1, k), false); - } - } - -@@ -284,6 +_,9 @@ - for (int k = 0; k < this.activeFrame.length; k++) { - int l = SpriteContents.this.width >> k; - int i1 = SpriteContents.this.height >> k; -+ // Forge: Guard against invalid texture size, because we allow generating mipmaps regardless of texture sizes -+ if (l < 1 || i1 < 1) -+ continue; - - for (int j1 = 0; j1 < i1; j1++) { - for (int k1 = 0; k1 < l; k1++) { 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 5be3471e41..76fbbceb4c 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 -@@ -76,7 +_,7 @@ +@@ -72,7 +_,7 @@ int j1 = Math.min(j, k); int k1 = Mth.log2(j1); int l1; @@ -9,30 +9,30 @@ LOGGER.warn("{}: dropping miplevel from {} to {}, because of minimum power of two: {}", this.location, p_261919_, k1, j1); l1 = k1; } else { -@@ -128,7 +_,8 @@ +@@ -126,7 +_,8 @@ public CompletableFuture loadAndStitch( - ResourceManager p_262108_, ResourceLocation p_261754_, int p_262104_, Executor p_261687_, Set> p_430900_ + ResourceManager p_262108_, Identifier p_459205_, 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_); ++ var sections = net.minecraftforge.client.ForgeHooksClient.getAtlastMetadataSections(p_459205_, 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<>(); + return CompletableFuture.>supplyAsync(() -> SpriteSourceList.load(p_262108_, p_459205_).list(p_262108_), p_261687_) + .thenCompose(p_296297_ -> runSpriteSuppliers(spriteresourceloader, (List)p_296297_, p_261687_)) + .thenApply(p_261393_ -> this.stitch((List)p_261393_, p_262104_, p_261687_)); +@@ -135,9 +_,14 @@ + private Map getStitchedSprites(Stitcher p_276117_, int p_276111_, int p_276112_) { + Map map = new HashMap<>(); p_276117_.gatherSprites( -- (p_251421_, p_250533_, p_251913_) -> map.put( -- p_251421_.name(), new TextureAtlasSprite(this.location, p_251421_, p_276111_, p_276112_, p_250533_, p_251913_) +- (p_448383_, p_448384_, p_448385_, p_448386_) -> map.put( +- p_448383_.name(), new TextureAtlasSprite(this.location, p_448383_, p_276111_, p_276112_, p_448384_, p_448385_, p_448386_) - ) -+ (p_251421_, p_250533_, p_251913_) -> { -+ TextureAtlasSprite sprite = net.minecraftforge.client.ForgeHooksClient.loadTextureAtlasSprite(this.location, p_251421_, p_276111_, p_276112_, p_250533_, p_251913_, p_251421_.byMipLevel.length - 1); ++ (p_448383_, p_448384_, p_448385_, p_448386_) -> { ++ TextureAtlasSprite sprite = net.minecraftforge.client.ForgeHooksClient.loadTextureAtlasSprite(this.location, p_448383_, p_276111_, p_276112_, p_448384_, p_448385_, p_448386_, p_448383_.byMipLevel.length - 1); + if (sprite != null) { -+ map.put(p_251421_.name(), sprite); ++ map.put(p_448383_.name(), sprite); + return; + } -+ map.put(p_251421_.name(), new TextureAtlasSprite(this.location, p_251421_, p_276111_, p_276112_, p_250533_, p_251913_)); ++ map.put(p_448383_.name(), new TextureAtlasSprite(this.location, p_448383_, p_276111_, p_276112_, p_448384_, p_448385_, p_448386_)); + } ); return map; diff --git a/patches/minecraft/net/minecraft/client/renderer/texture/Stitcher.java.patch b/patches/minecraft/net/minecraft/client/renderer/texture/Stitcher.java.patch index 0f8a47fcdf..1187eac0bd 100644 --- a/patches/minecraft/net/minecraft/client/renderer/texture/Stitcher.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/texture/Stitcher.java.patch @@ -7,8 +7,8 @@ + private static final org.slf4j.Logger LOGGER = com.mojang.logging.LogUtils.getLogger(); private static final Comparator> HOLDER_COMPARATOR = Comparator., Integer>comparing(p_118201_ -> -p_118201_.height) .thenComparing(p_118199_ -> -p_118199_.width) - .thenComparing(p_247945_ -> p_247945_.entry.name()); -@@ -48,6 +_,14 @@ + .thenComparing(p_448389_ -> p_448389_.entry.name()); +@@ -54,6 +_,14 @@ for (Stitcher.Holder holder : list) { if (!this.addToStorage(holder)) { @@ -23,7 +23,7 @@ throw new StitcherException(holder.entry, list.stream().map(p_247946_ -> p_247946_.entry).collect(ImmutableList.toImmutableList())); } } -@@ -87,7 +_,7 @@ +@@ -93,7 +_,7 @@ boolean flag4 = flag2 && j != l; boolean flag; if (flag3 ^ flag4) { 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 19e23c93ab..dc7f995bb9 100644 --- a/patches/minecraft/net/minecraft/client/renderer/texture/TextureAtlas.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/texture/TextureAtlas.java.patch @@ -1,21 +1,21 @@ --- a/net/minecraft/client/renderer/texture/TextureAtlas.java +++ b/net/minecraft/client/renderer/texture/TextureAtlas.java -@@ -92,6 +_,7 @@ - - this.sprites = List.copyOf(list); - this.animatedTextures = List.copyOf(list1); +@@ -119,6 +_,7 @@ + this.sprites = list; + this.animatedTexturesStates = List.copyOf(list1); + this.uploadInitialContents(); + net.minecraftforge.client.ForgeHooksClient.onTextureStitchedPost(this); if (SharedConstants.DEBUG_DUMP_TEXTURE_ATLAS) { Path path = TextureUtil.getDebugTexturePath(); -@@ -184,5 +_,10 @@ +@@ -304,5 +_,10 @@ int getHeight() { return this.height; + } + + /** {@return the set of sprites in this atlas} */ -+ public java.util.Set getTextureLocations() { ++ public java.util.Set getTextureLocations() { + return java.util.Collections.unmodifiableSet(texturesByName.keySet()); } } 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 3c0bc43131..14ee31eb43 100644 --- a/patches/minecraft/net/minecraft/client/renderer/texture/TextureAtlasSprite.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/texture/TextureAtlasSprite.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/client/renderer/texture/TextureAtlasSprite.java +++ b/net/minecraft/client/renderer/texture/TextureAtlasSprite.java -@@ -138,4 +_,13 @@ - @Override - void close(); +@@ -129,4 +_,13 @@ + public void close() { + this.contents.close(); } + + public int getPixelRGBA(int frameIndex, int x, int y) { 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 d7401294fc..4d4defe5dc 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 -@@ -65,6 +_,9 @@ +@@ -68,6 +_,9 @@ framesize = new FrameSize(nativeimage.getWidth(), nativeimage.getHeight()); } -+ SpriteContents contents = net.minecraftforge.client.ForgeHooksClient.loadSpriteContents(p_421043_, p_421044_, framesize, nativeimage, list); ++ SpriteContents contents = net.minecraftforge.client.ForgeHooksClient.loadSpriteContents(p_448404_, p_448405_, framesize, nativeimage, list); + if (contents != null) return contents; + - return new SpriteContents(p_421043_, framesize, nativeimage, optional, list); + return new SpriteContents(p_448404_, framesize, nativeimage, optional, list, optional1); }; } diff --git a/patches/minecraft/net/minecraft/client/resources/language/I18n.java.patch b/patches/minecraft/net/minecraft/client/resources/language/I18n.java.patch index 591a2bcf23..dfddf474e1 100644 --- a/patches/minecraft/net/minecraft/client/resources/language/I18n.java.patch +++ b/patches/minecraft/net/minecraft/client/resources/language/I18n.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/resources/language/I18n.java +++ b/net/minecraft/client/resources/language/I18n.java -@@ -14,6 +_,7 @@ +@@ -15,6 +_,7 @@ static void setLanguage(Language p_118942_) { language = p_118942_; diff --git a/patches/minecraft/net/minecraft/client/resources/model/BlockStateDefinitions.java.patch b/patches/minecraft/net/minecraft/client/resources/model/BlockStateDefinitions.java.patch index a4b5566887..c156208aa6 100644 --- a/patches/minecraft/net/minecraft/client/resources/model/BlockStateDefinitions.java.patch +++ b/patches/minecraft/net/minecraft/client/resources/model/BlockStateDefinitions.java.patch @@ -2,10 +2,10 @@ +++ b/net/minecraft/client/resources/model/BlockStateDefinitions.java @@ -33,6 +_,8 @@ - static Function> definitionLocationToBlockStateMapper() { - Map> map = new HashMap<>(STATIC_DEFINITIONS); + static Function> definitionLocationToBlockStateMapper() { + Map> map = new HashMap<>(STATIC_DEFINITIONS); + var event = net.minecraftforge.client.event.ForgeEventFactoryClient.onRegisterModeStateDefinitions(); + map.putAll(event.getStates()); for (Block block : BuiltInRegistries.BLOCK) { - map.put(block.builtInRegistryHolder().key().location(), block.getStateDefinition()); + map.put(block.builtInRegistryHolder().key().identifier(), block.getStateDefinition()); diff --git a/patches/minecraft/net/minecraft/client/resources/model/ModelBaker.java.patch b/patches/minecraft/net/minecraft/client/resources/model/ModelBaker.java.patch index e8a7a61485..e1a3b306fe 100644 --- a/patches/minecraft/net/minecraft/client/resources/model/ModelBaker.java.patch +++ b/patches/minecraft/net/minecraft/client/resources/model/ModelBaker.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/resources/model/ModelBaker.java +++ b/net/minecraft/client/resources/model/ModelBaker.java -@@ -17,4 +_,16 @@ +@@ -33,4 +_,16 @@ public interface SharedOperationKey { T compute(ModelBaker p_393089_); } diff --git a/patches/minecraft/net/minecraft/client/resources/model/ModelDiscovery.java.patch b/patches/minecraft/net/minecraft/client/resources/model/ModelDiscovery.java.patch index 24ceed714f..0a8a34b375 100644 --- a/patches/minecraft/net/minecraft/client/resources/model/ModelDiscovery.java.patch +++ b/patches/minecraft/net/minecraft/client/resources/model/ModelDiscovery.java.patch @@ -1,10 +1,10 @@ --- a/net/minecraft/client/resources/model/ModelDiscovery.java +++ b/net/minecraft/client/resources/model/ModelDiscovery.java -@@ -174,6 +_,14 @@ +@@ -172,6 +_,14 @@ return this.parent; } -+ @Nullable private net.minecraftforge.client.model.geometry.ModelContext context = null; ++ private net.minecraftforge.client.model.geometry.@Nullable ModelContext context = null; + @Override + public net.minecraftforge.client.model.geometry.IGeometryBakingContext getContext() { + if (context == null || context.parent() != parent) @@ -15,7 +15,7 @@ @Override public String debugName() { return this.id.toString(); -@@ -227,7 +_,7 @@ +@@ -224,7 +_,7 @@ private QuadCollection bakeDefaultState(TextureSlots p_392267_, ModelBaker p_393576_, ModelState p_391972_) { QuadCollection quadcollection = this.getSlot(KEY_DEFAULT_GEOMETRY); @@ -24,7 +24,7 @@ } @Override -@@ -236,7 +_,7 @@ +@@ -233,7 +_,7 @@ ? this.bakeDefaultState(p_396404_, p_391625_, p_396681_) : this.modelBakeCache.computeIfAbsent(p_396681_, p_394933_ -> { UnbakedGeometry unbakedgeometry = this.getTopGeometry(); 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 db0daf9710..ec3b515c80 100644 --- a/patches/minecraft/net/minecraft/client/resources/model/ModelManager.java.patch +++ b/patches/minecraft/net/minecraft/client/resources/model/ModelManager.java.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/client/resources/model/ModelManager.java +++ b/net/minecraft/client/resources/model/ModelManager.java -@@ -57,6 +_,7 @@ +@@ -58,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 Map bakedItemStackModels = Map.of(); ++ private Map bakedItemStackModelsView = Map.of(); + private Map itemProperties = Map.of(); private final AtlasManager atlasManager; private final PlayerSkinRenderCache playerSkinRenderCache; -@@ -66,6 +_,7 @@ +@@ -67,6 +_,7 @@ private SpecialBlockModelRenderer specialBlockModelRenderer = SpecialBlockModelRenderer.EMPTY; private ModelBakery.MissingModels missingModels; private Object2IntMap modelGroups = Object2IntMaps.emptyMap(); @@ -16,18 +16,18 @@ public ModelManager(BlockColors p_119407_, AtlasManager p_423190_, PlayerSkinRenderCache p_429874_) { this.blockColors = p_119407_; -@@ -82,6 +_,10 @@ - return this.bakedItemStackModels.getOrDefault(p_376816_, this.missingModels.item()); +@@ -83,6 +_,10 @@ + return this.bakedItemStackModels.getOrDefault(p_450917_, this.missingModels.item()); } -+ public Map getItemModels() { ++ public Map getItemModels() { + return this.bakedItemStackModelsView; + } + - public ClientItem.Properties getItemProperties(ResourceLocation p_378319_) { - return this.itemProperties.getOrDefault(p_378319_, ClientItem.Properties.DEFAULT); + public ClientItem.Properties getItemProperties(Identifier p_453916_) { + return this.itemProperties.getOrDefault(p_453916_, ClientItem.Properties.DEFAULT); } -@@ -94,6 +_,7 @@ +@@ -95,6 +_,7 @@ public final CompletableFuture reload( PreparableReloadListener.SharedState p_427489_, Executor p_250550_, PreparableReloadListener.PreparationBarrier p_249079_, Executor p_249221_ ) { @@ -35,7 +35,7 @@ ResourceManager resourcemanager = p_427489_.resourceManager(); CompletableFuture completablefuture = CompletableFuture.supplyAsync(EntityModelSet::vanilla, p_250550_); CompletableFuture completablefuture1 = completablefuture.thenApplyAsync( -@@ -229,6 +_,7 @@ +@@ -255,6 +_,7 @@ }, p_394729_) .thenApply( p_421082_ -> { @@ -43,7 +43,7 @@ multimap.asMap() .forEach( (p_376688_, p_252017_) -> LOGGER.warn( -@@ -249,7 +_,7 @@ +@@ -275,7 +_,7 @@ ) ); Map map = createBlockStateToModelDispatch(p_421082_.blockStateModels(), p_421082_.missingModels().block()); @@ -52,7 +52,7 @@ } ); } -@@ -284,10 +_,15 @@ +@@ -310,10 +_,15 @@ private void apply(ModelManager.ReloadState p_248996_) { ModelBakery.BakingResult modelbakery$bakingresult = p_248996_.bakedModels; @@ -68,7 +68,7 @@ this.blockModelShaper.replaceCache(p_248996_.modelCache); this.specialBlockModelRenderer = p_248996_.specialBlockModelRenderer; this.entityModelSet = p_248996_.entityModelSet; -@@ -311,6 +_,10 @@ +@@ -337,6 +_,10 @@ } } @@ -76,10 +76,10 @@ + return com.google.common.base.Preconditions.checkNotNull(modelBakery, "Attempted to query model bakery before it has been initialized."); + } + - public Supplier specialBlockModelRenderer() { - return () -> this.specialBlockModelRenderer; + public SpecialBlockModelRenderer specialBlockModelRenderer() { + return this.specialBlockModelRenderer; } -@@ -325,7 +_,8 @@ +@@ -351,7 +_,8 @@ Object2IntMap modelGroups, Map modelCache, EntityModelSet entityModelSet, 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 044dedb7e9..f9d51028d3 100644 --- a/patches/minecraft/net/minecraft/client/resources/model/ResolvedModel.java.patch +++ b/patches/minecraft/net/minecraft/client/resources/model/ResolvedModel.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/resources/model/ResolvedModel.java +++ b/net/minecraft/client/resources/model/ResolvedModel.java -@@ -86,7 +_,7 @@ +@@ -85,7 +_,7 @@ } default QuadCollection bakeTopGeometry(TextureSlots p_396041_, ModelBaker p_395367_, ModelState p_396505_) { @@ -9,7 +9,7 @@ } static TextureAtlasSprite resolveParticleSprite(TextureSlots p_391346_, ModelBaker p_396500_, ModelDebugName p_393309_) { -@@ -130,5 +_,9 @@ +@@ -129,5 +_,9 @@ default ItemTransforms getTopTransforms() { return findTopTransforms(this); diff --git a/patches/minecraft/net/minecraft/client/resources/model/UnbakedModel.java.patch b/patches/minecraft/net/minecraft/client/resources/model/UnbakedModel.java.patch index 3cec0c6d7e..afc2503b40 100644 --- a/patches/minecraft/net/minecraft/client/resources/model/UnbakedModel.java.patch +++ b/patches/minecraft/net/minecraft/client/resources/model/UnbakedModel.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/resources/model/UnbakedModel.java +++ b/net/minecraft/client/resources/model/UnbakedModel.java -@@ -64,5 +_,9 @@ +@@ -59,5 +_,9 @@ public boolean lightLikeBlock() { return this == SIDE; } diff --git a/patches/minecraft/net/minecraft/client/resources/sounds/SoundInstance.java.patch b/patches/minecraft/net/minecraft/client/resources/sounds/SoundInstance.java.patch index 853cfc7857..4e5ef3db75 100644 --- a/patches/minecraft/net/minecraft/client/resources/sounds/SoundInstance.java.patch +++ b/patches/minecraft/net/minecraft/client/resources/sounds/SoundInstance.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/resources/sounds/SoundInstance.java +++ b/net/minecraft/client/resources/sounds/SoundInstance.java -@@ -56,4 +_,8 @@ +@@ -54,4 +_,8 @@ NONE, LINEAR; } diff --git a/patches/minecraft/net/minecraft/client/server/IntegratedServer.java.patch b/patches/minecraft/net/minecraft/client/server/IntegratedServer.java.patch index 355cd3acb5..25740f720a 100644 --- a/patches/minecraft/net/minecraft/client/server/IntegratedServer.java.patch +++ b/patches/minecraft/net/minecraft/client/server/IntegratedServer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/server/IntegratedServer.java +++ b/net/minecraft/client/server/IntegratedServer.java -@@ -77,11 +_,12 @@ +@@ -83,11 +_,12 @@ LOGGER.info("Starting integrated minecraft server version {}", SharedConstants.getCurrentVersion().name()); this.setUsesAuthentication(true); this.initializeKeyPair(); @@ -14,7 +14,7 @@ } @Override -@@ -225,6 +_,7 @@ +@@ -242,6 +_,7 @@ @Override public void halt(boolean p_120053_) { diff --git a/patches/minecraft/net/minecraft/client/server/LanServerDetection.java.patch b/patches/minecraft/net/minecraft/client/server/LanServerDetection.java.patch index 9a4f399cef..6d066162c5 100644 --- a/patches/minecraft/net/minecraft/client/server/LanServerDetection.java.patch +++ b/patches/minecraft/net/minecraft/client/server/LanServerDetection.java.patch @@ -9,7 +9,7 @@ this.socket.setSoTimeout(5000); this.socket.joinGroup(this.pingGroup); } -@@ -88,7 +_,11 @@ +@@ -87,7 +_,11 @@ String s = LanServerPinger.parseMotd(p_120097_); String s1 = LanServerPinger.parseAddress(p_120097_); if (s1 != null) { diff --git a/patches/minecraft/net/minecraft/client/server/LanServerPinger.java.patch b/patches/minecraft/net/minecraft/client/server/LanServerPinger.java.patch index 6d704d9d41..43f23fa2e3 100644 --- a/patches/minecraft/net/minecraft/client/server/LanServerPinger.java.patch +++ b/patches/minecraft/net/minecraft/client/server/LanServerPinger.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/server/LanServerPinger.java +++ b/net/minecraft/client/server/LanServerPinger.java -@@ -13,7 +_,7 @@ +@@ -14,7 +_,7 @@ public class LanServerPinger extends Thread { private static final AtomicInteger UNIQUE_THREAD_ID = new AtomicInteger(0); private static final Logger LOGGER = LogUtils.getLogger(); @@ -9,7 +9,7 @@ public static final int PING_PORT = 4445; private static final long PING_INTERVAL = 1500L; private final String motd; -@@ -37,7 +_,7 @@ +@@ -38,7 +_,7 @@ while (!this.isInterrupted() && this.isRunning) { try { diff --git a/patches/minecraft/net/minecraft/client/sounds/SoundEngine.java.patch b/patches/minecraft/net/minecraft/client/sounds/SoundEngine.java.patch index e3a4688a6d..384d4d3a3e 100644 --- a/patches/minecraft/net/minecraft/client/sounds/SoundEngine.java.patch +++ b/patches/minecraft/net/minecraft/client/sounds/SoundEngine.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/sounds/SoundEngine.java +++ b/net/minecraft/client/sounds/SoundEngine.java -@@ -81,6 +_,7 @@ +@@ -82,6 +_,7 @@ this.soundManager = p_120236_; this.options = p_120237_; this.soundBuffers = new SoundBufferLibrary(p_249332_); @@ -8,7 +8,7 @@ } public void reload() { -@@ -98,6 +_,7 @@ +@@ -99,6 +_,7 @@ this.destroy(); this.loadLibrary(); @@ -16,7 +16,7 @@ } private synchronized void loadLibrary() { -@@ -343,6 +_,9 @@ +@@ -339,6 +_,9 @@ } else if (!p_120313_.canPlaySound()) { return SoundEngine.PlayResult.NOT_STARTED; } else { @@ -24,9 +24,9 @@ + if (p_120313_ == null || !p_120313_.canPlaySound()) + return SoundEngine.PlayResult.NOT_STARTED; WeighedSoundEvents weighedsoundevents = p_120313_.resolve(this.soundManager); - ResourceLocation resourcelocation = p_120313_.getLocation(); + Identifier identifier = p_120313_.getIdentifier(); if (weighedsoundevents == null) { -@@ -422,15 +_,18 @@ +@@ -418,15 +_,18 @@ p_194488_.setSelfPosition(vec3); p_194488_.setRelative(flag); }); diff --git a/patches/minecraft/net/minecraft/commands/CommandSourceStack.java.patch b/patches/minecraft/net/minecraft/commands/CommandSourceStack.java.patch index e343df59b0..78c3c8dfdc 100644 --- a/patches/minecraft/net/minecraft/commands/CommandSourceStack.java.patch +++ b/patches/minecraft/net/minecraft/commands/CommandSourceStack.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/commands/CommandSourceStack.java +++ b/net/minecraft/commands/CommandSourceStack.java -@@ -48,7 +_,7 @@ - import net.minecraft.world.phys.Vec2; +@@ -49,7 +_,7 @@ import net.minecraft.world.phys.Vec3; + import org.jspecify.annotations.Nullable; --public class CommandSourceStack implements ExecutionCommandSource, PermissionSource, SharedSuggestionProvider { -+public class CommandSourceStack implements ExecutionCommandSource, PermissionSource, SharedSuggestionProvider, net.minecraftforge.common.extensions.IForgeCommandSourceStack { +-public class CommandSourceStack implements ExecutionCommandSource, SharedSuggestionProvider { ++public class CommandSourceStack implements ExecutionCommandSource, SharedSuggestionProvider, net.minecraftforge.common.extensions.IForgeCommandSourceStack { public static final SimpleCommandExceptionType ERROR_NOT_PLAYER = new SimpleCommandExceptionType(Component.translatable("permissions.requires.player")); public static final SimpleCommandExceptionType ERROR_NOT_ENTITY = new SimpleCommandExceptionType(Component.translatable("permissions.requires.entity")); public final CommandSource source; diff --git a/patches/minecraft/net/minecraft/commands/Commands.java.patch b/patches/minecraft/net/minecraft/commands/Commands.java.patch index 260c26e04a..0181bc1f04 100644 --- a/patches/minecraft/net/minecraft/commands/Commands.java.patch +++ b/patches/minecraft/net/minecraft/commands/Commands.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/commands/Commands.java +++ b/net/minecraft/commands/Commands.java -@@ -255,7 +_,7 @@ +@@ -264,7 +_,7 @@ ChaseCommand.register(this.dispatcher); } @@ -9,7 +9,7 @@ RaidCommand.register(this.dispatcher, p_230944_); DebugPathCommand.register(this.dispatcher); DebugMobSpawningCommand.register(this.dispatcher); -@@ -288,6 +_,7 @@ +@@ -297,6 +_,7 @@ if (p_230943_.includeIntegrated) { PublishCommand.register(this.dispatcher); } @@ -17,7 +17,7 @@ this.dispatcher.setConsumer(ExecutionCommandSource.resultConsumer()); } -@@ -310,9 +_,18 @@ +@@ -319,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, -@@ -403,7 +_,10 @@ +@@ -413,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/SharedSuggestionProvider.java.patch b/patches/minecraft/net/minecraft/commands/SharedSuggestionProvider.java.patch deleted file mode 100644 index 8fc107c5b6..0000000000 --- a/patches/minecraft/net/minecraft/commands/SharedSuggestionProvider.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/commands/SharedSuggestionProvider.java -+++ b/net/minecraft/commands/SharedSuggestionProvider.java -@@ -98,7 +_,7 @@ - p_82948_.accept(t); - } - } else if (matchesSubStr(p_82946_, resourcelocation.getNamespace()) -- || resourcelocation.getNamespace().equals("minecraft") && matchesSubStr(p_82946_, resourcelocation.getPath())) { -+ || matchesSubStr(p_82946_, resourcelocation.getPath())) { // Forge: Removed "minecraft" namespace requirement for path searching to allow modded path suggestions to show up - p_82948_.accept(t); - } - } diff --git a/patches/minecraft/net/minecraft/commands/arguments/EntityArgument.java.patch b/patches/minecraft/net/minecraft/commands/arguments/EntityArgument.java.patch index 96a42d5415..675dedcf43 100644 --- a/patches/minecraft/net/minecraft/commands/arguments/EntityArgument.java.patch +++ b/patches/minecraft/net/minecraft/commands/arguments/EntityArgument.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/commands/arguments/EntityArgument.java +++ b/net/minecraft/commands/arguments/EntityArgument.java -@@ -123,7 +_,7 @@ - if (p_91482_.getSource() instanceof SharedSuggestionProvider sharedsuggestionprovider) { +@@ -125,7 +_,7 @@ StringReader stringreader = new StringReader(p_91483_.getInput()); stringreader.setCursor(p_91483_.getStart()); -- EntitySelectorParser entityselectorparser = new EntitySelectorParser(stringreader, EntitySelectorParser.allowSelectors(sharedsuggestionprovider)); -+ EntitySelectorParser entityselectorparser = new EntitySelectorParser(stringreader, net.minecraftforge.common.ForgeHooks.canUseEntitySelectors(sharedsuggestionprovider)); + EntitySelectorParser entityselectorparser = new EntitySelectorParser( +- stringreader, sharedsuggestionprovider.permissions().hasPermission(Permissions.COMMANDS_ENTITY_SELECTORS) ++ stringreader, net.minecraftforge.common.ForgeHooks.canUseEntitySelectors(sharedsuggestionprovider) + ); try { - entityselectorparser.parse(); diff --git a/patches/minecraft/net/minecraft/commands/arguments/MessageArgument.java.patch b/patches/minecraft/net/minecraft/commands/arguments/MessageArgument.java.patch index 48a8e2c782..cc38cd86c1 100644 --- a/patches/minecraft/net/minecraft/commands/arguments/MessageArgument.java.patch +++ b/patches/minecraft/net/minecraft/commands/arguments/MessageArgument.java.patch @@ -1,10 +1,10 @@ --- a/net/minecraft/commands/arguments/MessageArgument.java +++ b/net/minecraft/commands/arguments/MessageArgument.java -@@ -89,7 +_,7 @@ +@@ -90,7 +_,7 @@ public record Message(String text, MessageArgument.Part[] parts) { Component resolveComponent(CommandSourceStack p_232197_) throws CommandSyntaxException { -- return this.toComponent(p_232197_, EntitySelectorParser.allowSelectors(p_232197_)); +- return this.toComponent(p_232197_, p_232197_.permissions().hasPermission(Permissions.COMMANDS_ENTITY_SELECTORS)); + return this.toComponent(p_232197_, net.minecraftforge.common.ForgeHooks.canUseEntitySelectors(p_232197_)); } 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 dff030ca86..2373a9cd79 100644 --- a/patches/minecraft/net/minecraft/commands/arguments/selector/EntitySelector.java.patch +++ b/patches/minecraft/net/minecraft/commands/arguments/selector/EntitySelector.java.patch @@ -1,10 +1,10 @@ --- a/net/minecraft/commands/arguments/selector/EntitySelector.java +++ b/net/minecraft/commands/arguments/selector/EntitySelector.java -@@ -105,7 +_,7 @@ +@@ -102,7 +_,7 @@ } private void checkPermissions(CommandSourceStack p_121169_) throws CommandSyntaxException { -- if (this.usesSelector && !p_121169_.allowsSelectors()) { +- if (this.usesSelector && !p_121169_.permissions().hasPermission(Permissions.COMMANDS_ENTITY_SELECTORS)) { + if (this.usesSelector && !net.minecraftforge.common.ForgeHooks.canUseEntitySelectors(p_121169_)) { throw EntityArgument.ERROR_SELECTORS_NOT_ALLOWED.create(); } 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 cc355a2d29..b4bd7bc092 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 -@@ -480,6 +_,11 @@ +@@ -463,6 +_,11 @@ } this.reader.skip(); @@ -12,7 +12,7 @@ this.parseSelector(); } else { this.parseNameOrUUID(); -@@ -496,6 +_,7 @@ +@@ -479,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 8fb2621ff0..dbb24cb224 100644 --- a/patches/minecraft/net/minecraft/core/BlockPos.java.patch +++ b/patches/minecraft/net/minecraft/core/BlockPos.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/core/BlockPos.java +++ b/net/minecraft/core/BlockPos.java -@@ -32,7 +_,7 @@ - import org.slf4j.Logger; +@@ -30,7 +_,7 @@ + import org.apache.commons.lang3.tuple.Pair; @Immutable -public class BlockPos extends Vec3i { +public class BlockPos extends Vec3i implements net.minecraftforge.common.extensions.IForgeBlockPos { public static final Codec CODEC = Codec.INT_STREAM .comapFlatMap( - p_325638_ -> Util.fixedSize(p_325638_, 3).map(p_175270_ -> new BlockPos(p_175270_[0], p_175270_[1], p_175270_[2])), + p_448556_ -> Util.fixedSize(p_448556_, 3).map(p_175270_ -> new BlockPos(p_175270_[0], p_175270_[1], p_175270_[2])), diff --git a/patches/minecraft/net/minecraft/core/DefaultedMappedRegistry.java.patch b/patches/minecraft/net/minecraft/core/DefaultedMappedRegistry.java.patch index 66acdbabb1..aa424bfc94 100644 --- a/patches/minecraft/net/minecraft/core/DefaultedMappedRegistry.java.patch +++ b/patches/minecraft/net/minecraft/core/DefaultedMappedRegistry.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/core/DefaultedMappedRegistry.java +++ b/net/minecraft/core/DefaultedMappedRegistry.java -@@ -44,7 +_,7 @@ +@@ -41,7 +_,7 @@ @Override - public T getValue(@Nullable ResourceLocation p_365640_) { - T t = super.getValue(p_365640_); + public T getValue(@Nullable Identifier p_452628_) { + T t = super.getValue(p_452628_); - return t == null ? this.defaultValue.value() : t; + return t == null && this.defaultValue != null ? this.defaultValue.value() : t; // Add null check as it errors out in validation } diff --git a/patches/minecraft/net/minecraft/core/Holder.java.patch b/patches/minecraft/net/minecraft/core/Holder.java.patch index 7bb20cf603..0d2426e3ad 100644 --- a/patches/minecraft/net/minecraft/core/Holder.java.patch +++ b/patches/minecraft/net/minecraft/core/Holder.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/core/Holder.java +++ b/net/minecraft/core/Holder.java @@ -11,7 +_,22 @@ - import net.minecraft.resources.ResourceLocation; import net.minecraft.tags.TagKey; + import org.jspecify.annotations.Nullable; -public interface Holder { +public interface Holder extends java.util.function.Supplier, net.minecraftforge.registries.tags.IReverseTag { @@ -24,7 +24,7 @@ T value(); boolean isBound(); -@@ -241,6 +_,10 @@ +@@ -238,6 +_,10 @@ @Override public Stream> tags() { return this.boundTags().stream(); diff --git a/patches/minecraft/net/minecraft/core/HolderSet.java.patch b/patches/minecraft/net/minecraft/core/HolderSet.java.patch index a92cf1b2e5..f9a0aee9fd 100644 --- a/patches/minecraft/net/minecraft/core/HolderSet.java.patch +++ b/patches/minecraft/net/minecraft/core/HolderSet.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/core/HolderSet.java +++ b/net/minecraft/core/HolderSet.java @@ -15,7 +_,7 @@ - import net.minecraft.util.RandomSource; - import org.jetbrains.annotations.VisibleForTesting; + import net.minecraft.util.Util; + import org.jspecify.annotations.Nullable; -public interface HolderSet extends Iterable> { +public interface HolderSet extends Iterable>, net.minecraftforge.common.extensions.IForgeHolderSet { Stream> stream(); int size(); -@@ -174,6 +_,7 @@ +@@ -172,6 +_,7 @@ public void bind(List> p_205836_) { this.contents = List.copyOf(p_205836_); @@ -17,7 +17,7 @@ } public TagKey key() { -@@ -217,6 +_,12 @@ +@@ -215,6 +_,12 @@ @Override public boolean canSerializeIn(HolderOwner p_256542_) { return this.owner.canSerializeIn(p_256542_); diff --git a/patches/minecraft/net/minecraft/core/MappedRegistry.java.patch b/patches/minecraft/net/minecraft/core/MappedRegistry.java.patch index ea9ef57ccc..1648fad79c 100644 --- a/patches/minecraft/net/minecraft/core/MappedRegistry.java.patch +++ b/patches/minecraft/net/minecraft/core/MappedRegistry.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/core/MappedRegistry.java +++ b/net/minecraft/core/MappedRegistry.java @@ -30,6 +_,8 @@ - import net.minecraft.util.RandomSource; + import org.jspecify.annotations.Nullable; public class MappedRegistry implements WritableRegistry { + private static final org.apache.logging.log4j.Logger LOGGER = org.apache.logging.log4j.LogManager.getLogger(); @@ -9,7 +9,7 @@ private final ResourceKey> key; private final ObjectList> byId = new ObjectArrayList<>(256); private final Reference2IntMap toId = Util.make(new Reference2IntOpenHashMap<>(), p_308420_ -> p_308420_.defaultReturnValue(-1)); -@@ -85,6 +_,7 @@ +@@ -84,6 +_,7 @@ @Override public Holder.Reference register(ResourceKey p_256252_, T p_256591_, RegistrationInfo p_329661_) { @@ -17,7 +17,7 @@ this.validateWrite(p_256252_); Objects.requireNonNull(p_256252_); Objects.requireNonNull(p_256591_); -@@ -103,6 +_,8 @@ +@@ -102,6 +_,8 @@ reference.bindKey(p_256252_); } else { reference = this.byKey.computeIfAbsent(p_256252_, p_358082_ -> Holder.Reference.createStandAlone(this, (ResourceKey)p_358082_)); @@ -26,15 +26,15 @@ } this.byKey.put(p_256252_, reference); -@@ -274,7 +_,6 @@ +@@ -268,7 +_,6 @@ return this; } else { this.frozen = true; - this.byValue.forEach((p_247989_, p_247990_) -> p_247990_.bindValue((T)p_247989_)); - List list = this.byKey + List list = this.byKey .entrySet() .stream() -@@ -290,7 +_,8 @@ +@@ -284,7 +_,8 @@ throw new IllegalStateException("Some intrusive holders were not registered: " + this.unregisteredIntrusiveHolders.values()); } @@ -44,7 +44,7 @@ } if (this.allTags.isBound()) { -@@ -304,8 +_,9 @@ +@@ -298,8 +_,9 @@ .sorted() .toList(); if (!list1.isEmpty()) { @@ -56,7 +56,7 @@ this.allTags = MappedRegistry.TagSet.fromMap(this.frozenTags); this.refreshTagsInHolders(); return this; -@@ -315,6 +_,13 @@ +@@ -309,6 +_,13 @@ } } @@ -70,7 +70,7 @@ @Override public Holder.Reference createIntrusiveHolder(T p_205915_) { if (this.unregisteredIntrusiveHolders == null) { -@@ -389,6 +_,31 @@ +@@ -383,6 +_,31 @@ }; } @@ -78,8 +78,8 @@ + return this.unregisteredIntrusiveHolders != null; + } + -+ private static final Set KNOWN = new java.util.LinkedHashSet<>(); -+ public static Set getKnownRegistries() { ++ private static final Set KNOWN = new java.util.LinkedHashSet<>(); ++ public static Set getKnownRegistries() { + return java.util.Collections.unmodifiableSet(KNOWN); + } + @@ -88,8 +88,8 @@ + // So we have to have a last-in ordering. Simplest way is to just remove and re-add our selves. + // A copy of this map is then captured after vanilla bootstraping to freeze it hopefully before Modder's change the order. + // https://github.com/MinecraftForge/MinecraftForge/issues/10179 -+ KNOWN.remove(key().location()); -+ KNOWN.add(key().location()); ++ KNOWN.remove(key().identifier()); ++ KNOWN.add(key().identifier()); + } + + /** @deprecated Forge: For internal use only. Use the Register events when registering values. */ @@ -102,7 +102,7 @@ @Override public Registry.PendingTags prepareTagReload(TagLoader.LoadResult p_368827_) { if (!this.frozen) { -@@ -436,6 +_,11 @@ +@@ -430,6 +_,11 @@ @Override public HolderLookup.RegistryLookup lookup() { return registrylookup; diff --git a/patches/minecraft/net/minecraft/core/Registry.java.patch b/patches/minecraft/net/minecraft/core/Registry.java.patch index 4be66128c7..2b49a462f5 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 -@@ -176,5 +_,7 @@ +@@ -172,5 +_,7 @@ void apply(); int size(); diff --git a/patches/minecraft/net/minecraft/core/RegistrySetBuilder.java.patch b/patches/minecraft/net/minecraft/core/RegistrySetBuilder.java.patch index 5f1b3c9ca1..d94f347343 100644 --- a/patches/minecraft/net/minecraft/core/RegistrySetBuilder.java.patch +++ b/patches/minecraft/net/minecraft/core/RegistrySetBuilder.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/core/RegistrySetBuilder.java +++ b/net/minecraft/core/RegistrySetBuilder.java @@ -22,7 +_,8 @@ - import net.minecraft.tags.TagKey; import org.apache.commons.lang3.mutable.MutableObject; + import org.jspecify.annotations.Nullable; -public class RegistrySetBuilder { +public class RegistrySetBuilder implements net.minecraftforge.common.extensions.IForgeRegistrySetBuilder { @@ -56,7 +56,7 @@ RegistrySetBuilder.BuildState registrysetbuilder$buildstate = RegistrySetBuilder.BuildState.create( p_256400_, this.entries.stream().map(RegistrySetBuilder.RegistryStub::key) @@ -180,14 +_,16 @@ - throw new NullPointerException("No cloner for " + p_313093_.location()); + throw new NullPointerException("No cloner for " + p_313093_.identifier()); } else { Map, Holder.Reference> map = new HashMap<>(); - HolderLookup.RegistryLookup registrylookup = p_311682_.lookupOrThrow(p_313093_); @@ -64,7 +64,7 @@ registrylookup.listElements().forEach(p_308453_ -> { ResourceKey resourcekey = p_308453_.key(); RegistrySetBuilder.LazyHolder lazyholder = new RegistrySetBuilder.LazyHolder<>(p_312548_, resourcekey); - lazyholder.supplier = () -> cloner.clone((T)p_308453_.value(), p_311682_, p_311605_.getValue()); + lazyholder.supplier = () -> cloner.clone((T)p_308453_.value(), p_311682_, p_311605_.get()); map.put(resourcekey, lazyholder); }); - HolderLookup.RegistryLookup registrylookup1 = p_313198_.lookupOrThrow(p_313093_); @@ -87,12 +87,12 @@ @@ -265,6 +_,11 @@ @Override public HolderGetter lookup(ResourceKey> p_255961_) { - return (HolderGetter)BuildState.this.registries.getOrDefault(p_255961_.location(), BuildState.this.lookup); + return (HolderGetter)BuildState.this.registries.getOrDefault(p_255961_.identifier(), BuildState.this.lookup); + } + + @Override + public Optional> registryLookup(ResourceKey> registry) { -+ return Optional.ofNullable((HolderLookup.RegistryLookup) BuildState.this.registries.get(registry.location())); ++ return Optional.ofNullable((HolderLookup.RegistryLookup) BuildState.this.registries.get(registry.identifier())); } }; } diff --git a/patches/minecraft/net/minecraft/core/dispenser/DispenseItemBehavior.java.patch b/patches/minecraft/net/minecraft/core/dispenser/DispenseItemBehavior.java.patch index a93b6bc2a8..03ace695b3 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 -@@ -175,7 +_,7 @@ +@@ -179,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 { -@@ -226,8 +_,9 @@ +@@ -230,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 8888e3b63a..b67426a668 100644 --- a/patches/minecraft/net/minecraft/core/registries/BuiltInRegistries.java.patch +++ b/patches/minecraft/net/minecraft/core/registries/BuiltInRegistries.java.patch @@ -1,22 +1,22 @@ --- a/net/minecraft/core/registries/BuiltInRegistries.java +++ b/net/minecraft/core/registries/BuiltInRegistries.java -@@ -278,7 +_,9 @@ +@@ -294,7 +_,9 @@ ) { - Bootstrap.checkBootstrapCalled(() -> "registry " + p_259230_.location()); - ResourceLocation resourcelocation = p_259230_.location(); -- LOADERS.put(resourcelocation, () -> p_259210_.run(p_260327_)); + Bootstrap.checkBootstrapCalled(() -> "registry " + p_259230_.identifier()); + Identifier identifier = p_259230_.identifier(); +- LOADERS.put(identifier, () -> p_259210_.run(p_260327_)); + var maybeWrapped = net.minecraftforge.registries.GameData.getWrapper(p_259230_, p_260327_); + p_260327_ = maybeWrapped; -+ LOADERS.put(resourcelocation, () -> p_259210_.run(maybeWrapped)); ++ LOADERS.put(identifier, () -> p_259210_.run(maybeWrapped)); WRITABLE_REGISTRY.register((ResourceKey)p_259230_, p_260327_, RegistrationInfo.BUILT_IN); return p_260327_; } -@@ -314,7 +_,7 @@ +@@ -330,7 +_,7 @@ - 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); + if (p_448623_ instanceof DefaultedRegistry) { + Identifier identifier = ((DefaultedRegistry)p_448623_).getDefaultKey(); +- Objects.requireNonNull(p_448623_.getValue(identifier), "Missing default of DefaultedMappedRegistry: " + identifier); ++ Objects.requireNonNull(p_448623_.getValue(identifier), "Missing default of DefaultedMappedRegistry: " + p_448623_.key() + " - " + identifier); } }); } diff --git a/patches/minecraft/net/minecraft/core/registries/Registries.java.patch b/patches/minecraft/net/minecraft/core/registries/Registries.java.patch index b9f1670e9f..7b27eae612 100644 --- a/patches/minecraft/net/minecraft/core/registries/Registries.java.patch +++ b/patches/minecraft/net/minecraft/core/registries/Registries.java.patch @@ -1,17 +1,17 @@ --- a/net/minecraft/core/registries/Registries.java +++ b/net/minecraft/core/registries/Registries.java -@@ -281,10 +_,14 @@ +@@ -295,10 +_,14 @@ } public static String elementsDirPath(ResourceKey> p_343743_) { -+ if (!p_343743_.location().getNamespace().equals("minecraft")) -+ return p_343743_.location().getNamespace() + '/' + p_343743_.location().getPath(); - return p_343743_.location().getPath(); ++ if (!p_343743_.identifier().getNamespace().equals("minecraft")) ++ return p_343743_.identifier().getNamespace() + '/' + p_343743_.identifier().getPath(); + return p_343743_.identifier().getPath(); } public static String tagsDirPath(ResourceKey> p_343025_) { -+ if (!p_343025_.location().getNamespace().equals("minecraft")) -+ return "tags/" + p_343025_.location().getNamespace() + '/' + p_343025_.location().getPath(); - return "tags/" + p_343025_.location().getPath(); ++ if (!p_343025_.identifier().getNamespace().equals("minecraft")) ++ return "tags/" + p_343025_.identifier().getNamespace() + '/' + p_343025_.identifier().getPath(); + return "tags/" + p_343025_.identifier().getPath(); } } diff --git a/patches/minecraft/net/minecraft/data/HashCache.java.patch b/patches/minecraft/net/minecraft/data/HashCache.java.patch index 0f4b9a694d..6b67cc38cb 100644 --- a/patches/minecraft/net/minecraft/data/HashCache.java.patch +++ b/patches/minecraft/net/minecraft/data/HashCache.java.patch @@ -17,15 +17,15 @@ } @@ -106,6 +_,8 @@ - this.caches.forEach((p_253378_, p_253379_) -> { - if (this.cachesToWrite.contains(p_253378_)) { - Path path = this.getProviderCachePath(p_253378_); + this.caches.forEach((p_448628_, p_448629_) -> { + if (this.cachesToWrite.contains(p_448628_)) { + Path path = this.getProviderCachePath(p_448628_); + // Forge: Only rewrite the cache file if it changed or is missing -+ if (!p_253379_.equals(this.originalCaches.get(p_253378_)) || !Files.exists(path)) - p_253379_.save(this.rootDir, path, DateTimeFormatter.ISO_LOCAL_DATE_TIME.format(LocalDateTime.now()) + "\t" + p_253378_); ++ if (!p_448629_.equals(this.originalCaches.get(p_448628_)) || !Files.exists(path)) + p_448629_.save(this.rootDir, path, DateTimeFormatter.ISO_LOCAL_DATE_TIME.format(ZonedDateTime.now()) + "\t" + p_448628_); } -@@ -222,10 +_,11 @@ +@@ -221,10 +_,11 @@ bufferedwriter.write(p_236145_); bufferedwriter.newLine(); diff --git a/patches/minecraft/net/minecraft/data/Main.java.patch b/patches/minecraft/net/minecraft/data/Main.java.patch index 7a8721b6e9..efaa93b791 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 -@@ -77,14 +_,17 @@ +@@ -76,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/advancements/AdvancementProvider.java.patch b/patches/minecraft/net/minecraft/data/advancements/AdvancementProvider.java.patch index 3c8705107d..8e389b6555 100644 --- a/patches/minecraft/net/minecraft/data/advancements/AdvancementProvider.java.patch +++ b/patches/minecraft/net/minecraft/data/advancements/AdvancementProvider.java.patch @@ -2,7 +2,7 @@ +++ b/net/minecraft/data/advancements/AdvancementProvider.java @@ -16,6 +_,11 @@ import net.minecraft.data.PackOutput; - import net.minecraft.resources.ResourceLocation; + import net.minecraft.resources.Identifier; +/** + * @deprecated Forge: Use {@link net.minecraftforge.common.data.ForgeAdvancementProvider} instead, diff --git a/patches/minecraft/net/minecraft/data/loot/LootTableProvider.java.patch b/patches/minecraft/net/minecraft/data/loot/LootTableProvider.java.patch index 22c4a49a04..1fef36d81d 100644 --- a/patches/minecraft/net/minecraft/data/loot/LootTableProvider.java.patch +++ b/patches/minecraft/net/minecraft/data/loot/LootTableProvider.java.patch @@ -3,12 +3,12 @@ @@ -61,7 +_,7 @@ private CompletableFuture run(CachedOutput p_327970_, HolderLookup.Provider p_331092_) { WritableRegistry writableregistry = new MappedRegistry<>(Registries.LOOT_TABLE, Lifecycle.experimental()); - Map map = new Object2ObjectOpenHashMap<>(); -- this.subProviders.forEach(p_341016_ -> p_341016_.provider().apply(p_331092_).generate((p_358218_, p_358219_) -> { -+ this.getTables().forEach(p_341016_ -> p_341016_.provider().apply(p_331092_).generate((p_358218_, p_358219_) -> { - ResourceLocation resourcelocation = sequenceIdForLootTable(p_358218_); - ResourceLocation resourcelocation1 = map.put(RandomSequence.seedForKey(resourcelocation), resourcelocation); - if (resourcelocation1 != null) { + Map map = new Object2ObjectOpenHashMap<>(); +- this.subProviders.forEach(p_341016_ -> p_341016_.provider().apply(p_331092_).generate((p_448699_, p_448700_) -> { ++ this.getTables().forEach(p_341016_ -> p_341016_.provider().apply(p_331092_).generate((p_448699_, p_448700_) -> { + Identifier identifier = sequenceIdForLootTable(p_448699_); + Identifier identifier1 = map.put(RandomSequence.seedForKey(identifier), identifier); + if (identifier1 != null) { @@ -77,18 +_,8 @@ HolderGetter.Provider holdergetter$provider = new RegistryAccess.ImmutableRegistryAccess(List.of(writableregistry)).freeze(); ValidationContext validationcontext = new ValidationContext(problemreporter$collector, LootContextParamSets.ALL_PARAMS, holdergetter$provider); diff --git a/patches/minecraft/net/minecraft/data/recipes/RecipeOutput.java.patch b/patches/minecraft/net/minecraft/data/recipes/RecipeOutput.java.patch index 52d2892b79..42608fddb0 100644 --- a/patches/minecraft/net/minecraft/data/recipes/RecipeOutput.java.patch +++ b/patches/minecraft/net/minecraft/data/recipes/RecipeOutput.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/data/recipes/RecipeOutput.java +++ b/net/minecraft/data/recipes/RecipeOutput.java @@ -7,7 +_,19 @@ - import net.minecraft.world.item.crafting.Recipe; + import org.jspecify.annotations.Nullable; public interface RecipeOutput { - void accept(ResourceKey> p_367162_, Recipe p_360758_, @Nullable AdvancementHolder p_361155_); @@ -15,7 +15,7 @@ + } + } + -+ void accept(ResourceKey> id, Recipe recipe, @Nullable net.minecraft.resources.ResourceLocation advancementId, @Nullable com.google.gson.JsonElement advancement); ++ void accept(ResourceKey> id, Recipe recipe, net.minecraft.resources.@Nullable Identifier advancementId, com.google.gson.@Nullable JsonElement advancement); + + net.minecraft.core.HolderLookup.Provider registry(); diff --git a/patches/minecraft/net/minecraft/data/recipes/RecipeProvider.java.patch b/patches/minecraft/net/minecraft/data/recipes/RecipeProvider.java.patch index 3dd2923661..78e39d071b 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 -@@ -770,7 +_,7 @@ +@@ -787,7 +_,7 @@ RecipeBuilder create(RecipeProvider p_363045_, ItemLike p_362746_, ItemLike p_364674_); } @@ -9,14 +9,14 @@ private final PackOutput packOutput; private final CompletableFuture registries; -@@ -790,13 +_,13 @@ +@@ -807,13 +_,13 @@ final List> list = new ArrayList<>(); RecipeOutput recipeoutput = new RecipeOutput() { @Override - public void accept(ResourceKey> p_361204_, Recipe p_363495_, @Nullable AdvancementHolder p_364191_) { -+ public void accept(ResourceKey> p_361204_, Recipe p_363495_, @Nullable net.minecraft.resources.ResourceLocation advancementId, @Nullable com.google.gson.JsonElement advancement) { ++ public void accept(ResourceKey> p_361204_, Recipe p_363495_, net.minecraft.resources.@Nullable Identifier advancementId, com.google.gson.@Nullable JsonElement advancement) { if (!set.add(p_361204_)) { - throw new IllegalStateException("Duplicate recipe " + p_361204_.location()); + throw new IllegalStateException("Duplicate recipe " + p_361204_.identifier()); } else { this.saveRecipe(p_361204_, p_363495_); - if (p_364191_ != null) { @@ -26,7 +26,7 @@ } } } -@@ -811,7 +_,9 @@ +@@ -828,7 +_,9 @@ AdvancementHolder advancementholder = Advancement.Builder.recipeAdvancement() .addCriterion("impossible", CriteriaTriggers.IMPOSSIBLE.createCriterion(new ImpossibleTrigger.TriggerInstance())) .build(RecipeBuilder.ROOT_RECIPE_ADVANCEMENT); @@ -37,12 +37,12 @@ } private void saveRecipe(ResourceKey> p_368864_, Recipe p_368184_) { -@@ -822,16 +_,19 @@ +@@ -839,16 +_,19 @@ ); } - private void saveAdvancement(AdvancementHolder p_361824_) { -+ private void saveAdvancement(net.minecraft.resources.ResourceLocation id, com.google.gson.JsonElement advancement) { ++ private void saveAdvancement(net.minecraft.resources.Identifier id, com.google.gson.JsonElement advancement) { list.add( DataProvider.saveStable( p_363906_, diff --git a/patches/minecraft/net/minecraft/data/registries/RegistriesDatapackGenerator.java.patch b/patches/minecraft/net/minecraft/data/registries/RegistriesDatapackGenerator.java.patch index 029d03475d..2bca880f42 100644 --- a/patches/minecraft/net/minecraft/data/registries/RegistriesDatapackGenerator.java.patch +++ b/patches/minecraft/net/minecraft/data/registries/RegistriesDatapackGenerator.java.patch @@ -38,8 +38,8 @@ p_358460_.listElements() + .filter(holder -> shouldDump(holder.key())) .map( - p_256105_ -> dumpValue( - packoutput$pathprovider.json(p_256105_.key().location()), + p_448721_ -> dumpValue( + packoutput$pathprovider.json(p_448721_.key().identifier()), @@ -65,6 +_,10 @@ ); } @@ -47,7 +47,7 @@ + } + + protected boolean shouldDump(ResourceKey key) { -+ return this.namespacePredicate.test(key.location().getNamespace()); ++ return this.namespacePredicate.test(key.identifier().getNamespace()); } private static CompletableFuture dumpValue( diff --git a/patches/minecraft/net/minecraft/data/registries/VanillaRegistries.java.patch b/patches/minecraft/net/minecraft/data/registries/VanillaRegistries.java.patch index d036ad7ea8..2004582702 100644 --- a/patches/minecraft/net/minecraft/data/registries/VanillaRegistries.java.patch +++ b/patches/minecraft/net/minecraft/data/registries/VanillaRegistries.java.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/data/registries/VanillaRegistries.java +++ b/net/minecraft/data/registries/VanillaRegistries.java -@@ -90,6 +_,7 @@ - .add(Registries.FROG_VARIANT, FrogVariants::bootstrap) +@@ -94,6 +_,7 @@ .add(Registries.CAT_VARIANT, CatVariants::bootstrap) - .add(Registries.DIALOG, Dialogs::bootstrap); + .add(Registries.DIALOG, Dialogs::bootstrap) + .add(Registries.TIMELINE, Timelines::bootstrap); + public static final List>> DATAPACK_REGISTRY_KEYS = BUILDER.getEntryKeys(); private static void validateThatAllBiomeFeaturesHaveBiomeFilter(HolderLookup.Provider p_256242_) { validateThatAllBiomeFeaturesHaveBiomeFilter(p_256242_.lookupOrThrow(Registries.PLACED_FEATURE), p_256242_.lookupOrThrow(Registries.BIOME)); -@@ -121,5 +_,9 @@ +@@ -125,5 +_,9 @@ HolderLookup.Provider holderlookup$provider = BUILDER.build(registryaccess$frozen); validateThatAllBiomeFeaturesHaveBiomeFilter(holderlookup$provider); return holderlookup$provider; diff --git a/patches/minecraft/net/minecraft/data/tags/PaintingVariantTagsProvider.java.patch b/patches/minecraft/net/minecraft/data/tags/PaintingVariantTagsProvider.java.patch index d5f1d175ef..abbaf8405c 100644 --- a/patches/minecraft/net/minecraft/data/tags/PaintingVariantTagsProvider.java.patch +++ b/patches/minecraft/net/minecraft/data/tags/PaintingVariantTagsProvider.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/data/tags/PaintingVariantTagsProvider.java +++ b/net/minecraft/data/tags/PaintingVariantTagsProvider.java @@ -9,8 +_,13 @@ - import net.minecraft.world.entity.decoration.PaintingVariants; + import net.minecraft.world.entity.decoration.painting.PaintingVariants; public class PaintingVariantTagsProvider extends KeyTagProvider { + /** @deprecated Forge: Use the {@linkplain #PaintingVariantTagsProvider(PackOutput, CompletableFuture, String, net.minecraftforge.common.data.ExistingFileHelper) mod id variant} */ diff --git a/patches/minecraft/net/minecraft/data/tags/TagAppender.java.patch b/patches/minecraft/net/minecraft/data/tags/TagAppender.java.patch index f01ff184df..72a2c1aa43 100644 --- a/patches/minecraft/net/minecraft/data/tags/TagAppender.java.patch +++ b/patches/minecraft/net/minecraft/data/tags/TagAppender.java.patch @@ -19,7 +19,7 @@ + static TagAppender, T> forBuilder(final TagBuilder p_407840_, String source) { return new TagAppender, T>() { public TagAppender, T> add(ResourceKey p_406023_) { - p_407840_.addElement(p_406023_.location()); + p_407840_.addElement(p_406023_.identifier()); @@ -54,6 +_,21 @@ p_407840_.addOptionalTag(p_407223_.location()); return this; @@ -37,7 +37,7 @@ + + @Override + public TagAppender, T> remove(ResourceKey value) { -+ return this.remove(value.location()); ++ return this.remove(value.identifier()); + } }; } diff --git a/patches/minecraft/net/minecraft/data/tags/TagsProvider.java.patch b/patches/minecraft/net/minecraft/data/tags/TagsProvider.java.patch index 3b6d62518c..15e744b943 100644 --- a/patches/minecraft/net/minecraft/data/tags/TagsProvider.java.patch +++ b/patches/minecraft/net/minecraft/data/tags/TagsProvider.java.patch @@ -3,7 +3,7 @@ @@ -32,26 +_,57 @@ private final CompletableFuture> parentProvider; protected final ResourceKey> registryKey; - protected final Map builders = Maps.newLinkedHashMap(); + protected final Map builders = Maps.newLinkedHashMap(); + protected final String modId; + @org.jetbrains.annotations.Nullable + protected final net.minecraftforge.common.data.ExistingFileHelper existingFileHelper; @@ -50,14 +50,14 @@ + + // Forge: Allow customizing the path for a given tag or returning null + @org.jetbrains.annotations.Nullable -+ protected Path getPath(ResourceLocation id) { ++ protected Path getPath(Identifier id) { + return this.pathProvider.json(id); } @Override public String getName() { -- return "Tags for " + this.registryKey.location(); -+ return "Tags for " + this.registryKey.location() + " mod id " + this.modId; +- return "Tags for " + this.registryKey.identifier(); ++ return "Tags for " + this.registryKey.identifier() + " mod id " + this.modId; } protected abstract void addTags(HolderLookup.Provider p_256380_); @@ -69,15 +69,15 @@ + HolderLookup.RegistryLookup registrylookup = p_325926_.contents.lookup(this.registryKey).orElseThrow(() -> { + // FORGE: Throw a more descriptive error message if this is a Forge registry without tags enabled + if (net.minecraftforge.registries.RegistryManager.ACTIVE.getRegistry(this.registryKey) != null) { -+ return new IllegalStateException("Forge registry " + this.registryKey.location() + " does not have support for tags"); ++ return new IllegalStateException("Forge registry " + this.registryKey.identifier() + " does not have support for tags"); + } -+ return new IllegalStateException("Registry " + this.registryKey.location() + " not found"); ++ return new IllegalStateException("Registry " + this.registryKey.identifier() + " not found"); + }); - Predicate predicate = p_255496_ -> registrylookup.get(ResourceKey.create(this.registryKey, p_255496_)).isPresent(); - Predicate predicate1 = p_274776_ -> this.builders.containsKey(p_274776_) - || p_325926_.parent.contains(TagKey.create(this.registryKey, p_274776_)); + Predicate predicate = p_448741_ -> registrylookup.get(ResourceKey.create(this.registryKey, p_448741_)).isPresent(); + Predicate predicate1 = p_448739_ -> this.builders.containsKey(p_448739_) + || p_325926_.parent.contains(TagKey.create(this.registryKey, p_448739_)); @@ -82,7 +_,7 @@ - ResourceLocation resourcelocation = p_325931_.getKey(); + Identifier identifier = p_325931_.getKey(); TagBuilder tagbuilder = p_325931_.getValue(); List list = tagbuilder.build(); - List list1 = list.stream().filter(p_274771_ -> !p_274771_.verifyIfPresent(predicate, predicate1)).toList(); @@ -89,9 +89,9 @@ ) ); } else { -- Path path = this.pathProvider.json(resourcelocation); +- Path path = this.pathProvider.json(identifier); - return DataProvider.saveStable(p_253684_, p_325926_.contents, TagFile.CODEC, new TagFile(list, false), path); -+ Path path = this.getPath(resourcelocation); ++ Path path = this.getPath(identifier); + if (path == null) { + return CompletableFuture.completedFuture(null); // Forge: Allow running this data provider without writing it. Recipe provider needs valid tags. + } @@ -103,10 +103,10 @@ } protected TagBuilder getOrCreateRawBuilder(TagKey p_236452_) { -- return this.builders.computeIfAbsent(p_236452_.location(), p_236442_ -> TagBuilder.create()); -+ return this.builders.computeIfAbsent(p_236452_.location(), p_236442_ -> { +- return this.builders.computeIfAbsent(p_236452_.location(), p_460082_ -> TagBuilder.create()); ++ return this.builders.computeIfAbsent(p_236452_.location(), p_460082_ -> { + if (existingFileHelper != null) { -+ existingFileHelper.trackGenerated(p_236442_, resourceType); ++ existingFileHelper.trackGenerated(p_460082_, resourceType); + } + return TagBuilder.create(); + }); diff --git a/patches/minecraft/net/minecraft/data/tags/VanillaEnchantmentTagsProvider.java.patch b/patches/minecraft/net/minecraft/data/tags/VanillaEnchantmentTagsProvider.java.patch index 62eb7f71c2..2cb9a2cea5 100644 --- a/patches/minecraft/net/minecraft/data/tags/VanillaEnchantmentTagsProvider.java.patch +++ b/patches/minecraft/net/minecraft/data/tags/VanillaEnchantmentTagsProvider.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/data/tags/VanillaEnchantmentTagsProvider.java +++ b/net/minecraft/data/tags/VanillaEnchantmentTagsProvider.java -@@ -12,6 +_,10 @@ +@@ -11,6 +_,10 @@ super(p_335915_, p_330302_); } diff --git a/patches/minecraft/net/minecraft/data/tags/VanillaItemTagsProvider.java.patch b/patches/minecraft/net/minecraft/data/tags/VanillaItemTagsProvider.java.patch index bf03175948..e3bc094676 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() { -@@ -473,6 +_,12 @@ +@@ -485,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 e9b73d07a5..10b68733c4 100644 --- a/patches/minecraft/net/minecraft/gametest/framework/GameTestHelper.java.patch +++ b/patches/minecraft/net/minecraft/gametest/framework/GameTestHelper.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/gametest/framework/GameTestHelper.java +++ b/net/minecraft/gametest/framework/GameTestHelper.java -@@ -69,7 +_,7 @@ - import net.minecraft.world.phys.BlockHitResult; +@@ -68,7 +_,7 @@ import net.minecraft.world.phys.Vec3; + import org.jspecify.annotations.Nullable; -public class GameTestHelper { +public class GameTestHelper implements net.minecraftforge.common.extensions.IForgeGameTestHelper { private final GameTestInfo testInfo; private boolean finalCheckAdded; -@@ -988,6 +_,12 @@ +@@ -1008,6 +_,12 @@ return this.testInfo.getTick(); } @@ -22,7 +22,7 @@ public AABB getBounds() { return this.testInfo.getStructureBounds(); } -@@ -1030,5 +_,25 @@ +@@ -1050,5 +_,25 @@ if (either.right().isPresent()) { throw this.assertionException("test.error.set_biome"); } diff --git a/patches/minecraft/net/minecraft/gametest/framework/GameTestMainUtil.java.patch b/patches/minecraft/net/minecraft/gametest/framework/GameTestMainUtil.java.patch index 257439f08b..0fa6f4ca50 100644 --- a/patches/minecraft/net/minecraft/gametest/framework/GameTestMainUtil.java.patch +++ b/patches/minecraft/net/minecraft/gametest/framework/GameTestMainUtil.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/gametest/framework/GameTestMainUtil.java +++ b/net/minecraft/gametest/framework/GameTestMainUtil.java -@@ -69,6 +_,7 @@ +@@ -67,6 +_,7 @@ Bootstrap.bootStrap(); Util.startTimerHackThread(); diff --git a/patches/minecraft/net/minecraft/gametest/framework/GameTestServer.java.patch b/patches/minecraft/net/minecraft/gametest/framework/GameTestServer.java.patch index d58d7c8f12..54307c3b96 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 -@@ -90,7 +_,7 @@ +@@ -93,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); -@@ -150,6 +_,7 @@ +@@ -155,6 +_,7 @@ @Override public boolean initServer() { + if (!net.minecraftforge.server.ServerLifecycleHooks.handleServerAboutToStart(this)) return false; this.setPlayerList(new PlayerList(this, this.registries(), this.playerDataStorage, new EmptyNotificationService()) {}); + Gizmos.withCollector(GizmoCollector.NOOP); this.loadLevel(); - ServerLevel serverlevel = this.overworld(); diff --git a/patches/minecraft/net/minecraft/network/Connection.java.patch b/patches/minecraft/net/minecraft/network/Connection.java.patch index 8280914458..32fd674912 100644 --- a/patches/minecraft/net/minecraft/network/Connection.java.patch +++ b/patches/minecraft/net/minecraft/network/Connection.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/network/Connection.java +++ b/net/minecraft/network/Connection.java -@@ -105,9 +_,17 @@ - private volatile DisconnectionDetails delayedDisconnect; - @Nullable - BandwidthDebugMonitor bandwidthDebugMonitor; +@@ -81,9 +_,17 @@ + private boolean handlingFault; + private volatile @Nullable DisconnectionDetails delayedDisconnect; + @Nullable BandwidthDebugMonitor bandwidthDebugMonitor; + private java.util.function.Consumer activationHandler; + private final net.minecraftforge.common.util.PacketLogger packetLogger = new net.minecraftforge.common.util.PacketLogger(this); + private ProtocolInfo outboundProtocol = null; @@ -18,7 +18,7 @@ } @Override -@@ -115,6 +_,7 @@ +@@ -91,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); } -@@ -175,6 +_,7 @@ +@@ -151,6 +_,7 @@ } else { if (packetlistener.shouldHandleMessage(p_129488_)) { try { @@ -34,7 +34,7 @@ genericsFtw(p_129488_, packetlistener); } catch (RunningOnDifferentThreadException runningondifferentthreadexception) { } catch (RejectedExecutionException rejectedexecutionexception) { -@@ -224,6 +_,7 @@ +@@ -200,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( -@@ -247,6 +_,8 @@ +@@ -223,6 +_,8 @@ } else { UnconfiguredPipelineHandler.OutboundConfigurationTask unconfiguredpipelinehandler$outboundconfigurationtask = UnconfiguredPipelineHandler.setupOutboundProtocol( p_329145_ @@ -51,7 +51,7 @@ ); BundlerInfo bundlerinfo = p_329145_.bundlerInfo(); if (bundlerinfo != null) { -@@ -296,7 +_,8 @@ +@@ -272,7 +_,8 @@ this.disconnectListener = p_330656_; this.runOnceConnected(p_405096_ -> { this.setupInboundProtocol(p_329827_, p_330656_); @@ -61,7 +61,7 @@ this.setupOutboundProtocol(p_328134_); }); } -@@ -341,10 +_,13 @@ +@@ -317,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 @@ } } -@@ -413,7 +_,7 @@ +@@ -389,7 +_,7 @@ if (this.address == null) { return "local"; } else { @@ -84,24 +84,28 @@ } } -@@ -456,6 +_,8 @@ +@@ -432,7 +_,9 @@ } - public static ChannelFuture connect(InetSocketAddress p_290034_, boolean p_290035_, final Connection p_290031_) { + public static ChannelFuture connect(InetSocketAddress p_290034_, EventLoopGroupHolder p_450865_, final Connection p_290031_) { +- return new Bootstrap().group(p_450865_.eventLoopGroup()).handler(new ChannelInitializer() { + net.minecraftforge.network.DualStackUtils.checkIPv6(p_290034_.getAddress()); + p_290031_.activationHandler = net.minecraftforge.network.NetworkRegistry::onConnectionStart; - Class oclass; - EventLoopGroup eventloopgroup; - if (Epoll.isAvailable() && p_290035_) { -@@ -527,6 +_,7 @@ ++ return new Bootstrap().group(p_450865_.eventLoopGroup(true)).handler(new ChannelInitializer() { + @Override + protected void initChannel(Channel p_129552_) { + try { +@@ -493,7 +_,8 @@ public static Connection connectToLocalServer(SocketAddress p_129494_) { final Connection connection = new Connection(PacketFlow.CLIENTBOUND); +- new Bootstrap().group(EventLoopGroupHolder.local().eventLoopGroup()).handler(new ChannelInitializer() { + connection.activationHandler = net.minecraftforge.network.NetworkRegistry::onConnectionStart; - new Bootstrap().group(LOCAL_WORKER_GROUP.get()).handler(new ChannelInitializer() { ++ new Bootstrap().group(EventLoopGroupHolder.local().eventLoopGroup(true)).handler(new ChannelInitializer() { @Override protected void initChannel(Channel p_332618_) { -@@ -620,6 +_,22 @@ + ChannelPipeline channelpipeline = p_332618_.pipeline(); +@@ -584,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 dcb13496fa..936d1064ad 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 -@@ -1647,4 +_,8 @@ +@@ -1637,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 6d85923614..1cc54d0150 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 -@@ -139,6 +_,11 @@ +@@ -137,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 a7a4568deb..67b03aca63 100644 --- a/patches/minecraft/net/minecraft/network/protocol/common/ClientboundCustomPayloadPacket.java.patch +++ b/patches/minecraft/net/minecraft/network/protocol/common/ClientboundCustomPayloadPacket.java.patch @@ -4,14 +4,14 @@ 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), +- p_448776_ -> DiscardedPayload.codec(p_448776_, 1048576), ++ p_448776_ -> net.minecraftforge.common.ForgeHooks.getCustomPayloadCodec(p_448776_, 1048576), 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( -- p_331803_ -> DiscardedPayload.codec(p_331803_, 1048576), -+ p_331803_ -> net.minecraftforge.common.ForgeHooks.getCustomPayloadCodec(p_331803_, 1048576), +- p_448777_ -> DiscardedPayload.codec(p_448777_, 1048576), ++ p_448777_ -> net.minecraftforge.common.ForgeHooks.getCustomPayloadCodec(p_448777_, 1048576), List.of(new CustomPacketPayload.TypeAndCodec<>(BrandPayload.TYPE, BrandPayload.STREAM_CODEC)) ) .map(ClientboundCustomPayloadPacket::new, ClientboundCustomPayloadPacket::payload); diff --git a/patches/minecraft/net/minecraft/network/protocol/common/ServerboundCustomPayloadPacket.java.patch b/patches/minecraft/net/minecraft/network/protocol/common/ServerboundCustomPayloadPacket.java.patch index d15dbb6838..d115bddb2e 100644 --- a/patches/minecraft/net/minecraft/network/protocol/common/ServerboundCustomPayloadPacket.java.patch +++ b/patches/minecraft/net/minecraft/network/protocol/common/ServerboundCustomPayloadPacket.java.patch @@ -4,8 +4,8 @@ public record ServerboundCustomPayloadPacket(CustomPacketPayload payload) implements Packet { private static final int MAX_PAYLOAD_SIZE = 32767; public static final StreamCodec STREAM_CODEC = CustomPacketPayload.codec( -- p_335203_ -> DiscardedPayload.codec(p_335203_, 32767), -+ p_335203_ -> net.minecraftforge.common.ForgeHooks.getCustomPayloadCodec(p_335203_, 32767), +- p_448778_ -> DiscardedPayload.codec(p_448778_, 32767), ++ p_448778_ -> net.minecraftforge.common.ForgeHooks.getCustomPayloadCodec(p_448778_, 32767), Util.make(Lists.newArrayList(new CustomPacketPayload.TypeAndCodec<>(BrandPayload.TYPE, BrandPayload.STREAM_CODEC)), p_334419_ -> {}) ) .map(ServerboundCustomPayloadPacket::new, ServerboundCustomPayloadPacket::payload); diff --git a/patches/minecraft/net/minecraft/network/protocol/common/custom/CustomPacketPayload.java.patch b/patches/minecraft/net/minecraft/network/protocol/common/custom/CustomPacketPayload.java.patch index 8984f348dd..a32a900dec 100644 --- a/patches/minecraft/net/minecraft/network/protocol/common/custom/CustomPacketPayload.java.patch +++ b/patches/minecraft/net/minecraft/network/protocol/common/custom/CustomPacketPayload.java.patch @@ -4,15 +4,15 @@ } static CustomPacketPayload.Type createType(String p_331650_) { -- return new CustomPacketPayload.Type<>(ResourceLocation.withDefaultNamespace(p_331650_)); -+ return new CustomPacketPayload.Type<>(ResourceLocation.parse(p_331650_)); +- return new CustomPacketPayload.Type<>(Identifier.withDefaultNamespace(p_331650_)); ++ return new CustomPacketPayload.Type<>(Identifier.parse(p_331650_)); + } + + static CustomPacketPayload.Type createType(String namespace, String path) { -+ return new CustomPacketPayload.Type<>(ResourceLocation.fromNamespaceAndPath(namespace, path)); ++ return new CustomPacketPayload.Type<>(Identifier.fromNamespaceAndPath(namespace, path)); + } + -+ static CustomPacketPayload.Type createType(ResourceLocation name) { ++ static CustomPacketPayload.Type createType(Identifier name) { + return new CustomPacketPayload.Type<>(name); } diff --git a/patches/minecraft/net/minecraft/network/protocol/login/custom/DiscardedQueryPayload.java.patch b/patches/minecraft/net/minecraft/network/protocol/login/custom/DiscardedQueryPayload.java.patch index cba026e18e..eb8a8f804e 100644 --- a/patches/minecraft/net/minecraft/network/protocol/login/custom/DiscardedQueryPayload.java.patch +++ b/patches/minecraft/net/minecraft/network/protocol/login/custom/DiscardedQueryPayload.java.patch @@ -2,14 +2,14 @@ +++ b/net/minecraft/network/protocol/login/custom/DiscardedQueryPayload.java @@ -3,9 +_,21 @@ import net.minecraft.network.FriendlyByteBuf; - import net.minecraft.resources.ResourceLocation; + import net.minecraft.resources.Identifier; --public record DiscardedQueryPayload(ResourceLocation id) implements CustomQueryPayload { -+public record DiscardedQueryPayload(ResourceLocation id, +-public record DiscardedQueryPayload(Identifier id) implements CustomQueryPayload { ++public record DiscardedQueryPayload(Identifier id, + @org.jetbrains.annotations.Nullable FriendlyByteBuf data, + java.util.function.Consumer encoder +) implements CustomQueryPayload { -+ public DiscardedQueryPayload(ResourceLocation id) { ++ public DiscardedQueryPayload(Identifier id) { + this(id, null, buf -> {}); + } + diff --git a/patches/minecraft/net/minecraft/network/syncher/EntityDataSerializers.java.patch b/patches/minecraft/net/minecraft/network/syncher/EntityDataSerializers.java.patch index 61ace79133..bc463772d4 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 -@@ -124,16 +_,18 @@ - public static final EntityDataSerializer RESOLVABLE_PROFILE = EntityDataSerializer.forValueType(ResolvableProfile.STREAM_CODEC); +@@ -128,15 +_,17 @@ + public static final EntityDataSerializer HUMANOID_ARM = EntityDataSerializer.forValueType(HumanoidArm.STREAM_CODEC); public static void registerSerializer(EntityDataSerializer p_135051_) { + int id = @@ -9,8 +9,7 @@ + if (id >= 256) throw new RuntimeException("Vanilla DataSerializer ID limit exceeded"); } - @Nullable - public static EntityDataSerializer getSerializer(int p_135049_) { + public static @Nullable EntityDataSerializer getSerializer(int p_135049_) { - return SERIALIZERS.byId(p_135049_); + return net.minecraftforge.common.ForgeHooks.getSerializer(p_135049_, SERIALIZERS); } diff --git a/patches/minecraft/net/minecraft/resources/DelegatingOps.java.patch b/patches/minecraft/net/minecraft/resources/DelegatingOps.java.patch index 8fd3072fca..25bdc9f46c 100644 --- a/patches/minecraft/net/minecraft/resources/DelegatingOps.java.patch +++ b/patches/minecraft/net/minecraft/resources/DelegatingOps.java.patch @@ -5,10 +5,10 @@ } + // Forge start -+ java.util.Map ctx = new java.util.HashMap<>(); ++ java.util.Map ctx = new java.util.HashMap<>(); + + @SuppressWarnings("unchecked") -+ public R getContext(ResourceLocation rl) { ++ public R getContext(Identifier rl) { + var ret = (R)this.ctx.get(rl); + if (ret == null && this.delegate instanceof DelegatingOps parent) { + return (R)parent.getContext(rl); @@ -17,7 +17,7 @@ + } + + @SuppressWarnings("unchecked") -+ public R withContext(ResourceLocation key, Object ctx) { ++ public R withContext(Identifier key, Object ctx) { + this.ctx.put(key, ctx); + return (R)this; + } diff --git a/patches/minecraft/net/minecraft/resources/Identifier.java.patch b/patches/minecraft/net/minecraft/resources/Identifier.java.patch new file mode 100644 index 0000000000..2e06a42a49 --- /dev/null +++ b/patches/minecraft/net/minecraft/resources/Identifier.java.patch @@ -0,0 +1,13 @@ +--- a/net/minecraft/resources/Identifier.java ++++ b/net/minecraft/resources/Identifier.java +@@ -269,4 +_,10 @@ + return p_458379_; + } + } ++ ++ /** Normal compare sorts by path first, this compares namespace first. */ ++ public int compareNamespaced(Identifier o) { ++ int ret = this.namespace.compareTo(o.namespace); ++ return ret != 0 ? ret : this.path.compareTo(o.path); ++ } + } diff --git a/patches/minecraft/net/minecraft/resources/RegistryDataLoader.java.patch b/patches/minecraft/net/minecraft/resources/RegistryDataLoader.java.patch index d8a2e49240..2fa3da37e3 100644 --- a/patches/minecraft/net/minecraft/resources/RegistryDataLoader.java.patch +++ b/patches/minecraft/net/minecraft/resources/RegistryDataLoader.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/resources/RegistryDataLoader.java +++ b/net/minecraft/resources/RegistryDataLoader.java -@@ -89,7 +_,7 @@ +@@ -91,7 +_,7 @@ Lifecycle lifecycle = p_326161_.map(KnownPack::isVanilla).map(p_326166_ -> Lifecycle.stable()).orElse(Lifecycle.experimental()); return new RegistrationInfo(p_326161_, lifecycle); }); @@ -9,7 +9,7 @@ new RegistryDataLoader.RegistryData<>(Registries.DIMENSION_TYPE, DimensionType.DIRECT_CODEC), new RegistryDataLoader.RegistryData<>(Registries.BIOME, Biome.DIRECT_CODEC), new RegistryDataLoader.RegistryData<>(Registries.CHAT_TYPE, ChatType.DIRECT_CODEC), -@@ -130,7 +_,7 @@ +@@ -134,7 +_,7 @@ public static final List> DIMENSION_REGISTRIES = List.of( new RegistryDataLoader.RegistryData<>(Registries.LEVEL_STEM, LevelStem.CODEC) ); @@ -18,8 +18,8 @@ new RegistryDataLoader.RegistryData<>(Registries.BIOME, Biome.NETWORK_CODEC), new RegistryDataLoader.RegistryData<>(Registries.CHAT_TYPE, ChatType.DIRECT_CODEC), new RegistryDataLoader.RegistryData<>(Registries.TRIM_PATTERN, TrimPattern.DIRECT_CODEC), -@@ -154,6 +_,10 @@ - new RegistryDataLoader.RegistryData<>(Registries.DIALOG, Dialog.DIRECT_CODEC) +@@ -160,6 +_,10 @@ + new RegistryDataLoader.RegistryData<>(Registries.TIMELINE, Timeline.NETWORK_CODEC) ); + public static java.util.stream.Stream> getWorldGenAndDimensionStream() { @@ -29,7 +29,7 @@ public static RegistryAccess.Frozen load( ResourceManager p_252046_, List> p_250344_, List> p_366741_ ) { -@@ -270,7 +_,7 @@ +@@ -276,7 +_,7 @@ private static void loadElementFromResource( WritableRegistry p_330991_, @@ -38,7 +38,7 @@ RegistryOps p_332135_, ResourceKey p_332850_, Resource p_335244_, -@@ -278,7 +_,23 @@ +@@ -284,7 +_,23 @@ ) throws IOException { try (Reader reader = p_335244_.openAsReader()) { JsonElement jsonelement = StrictJsonParser.parse(reader); @@ -63,15 +63,15 @@ E e = dataresult.getOrThrow(); p_330991_.register(p_332850_, e, p_332222_); } -@@ -293,6 +_,7 @@ +@@ -299,6 +_,7 @@ ) { FileToIdConverter filetoidconverter = FileToIdConverter.registry(p_331358_.key()); RegistryOps registryops = RegistryOps.create(JsonOps.INSTANCE, p_333035_); + Decoder> conditional = net.minecraftforge.common.crafting.conditions.ConditionCodec.wrap(p_329404_); - for (Entry entry : filetoidconverter.listMatchingResources(p_335634_).entrySet()) { - ResourceLocation resourcelocation = entry.getKey(); -@@ -301,7 +_,7 @@ + for (Entry entry : filetoidconverter.listMatchingResources(p_335634_).entrySet()) { + Identifier identifier = entry.getKey(); +@@ -307,7 +_,7 @@ RegistrationInfo registrationinfo = REGISTRATION_INFO_CACHE.apply(resource.knownPackInfo()); try { @@ -80,7 +80,7 @@ } catch (Exception exception) { p_335074_.put( resourcekey, -@@ -324,7 +_,8 @@ +@@ -330,7 +_,8 @@ RegistryDataLoader.NetworkedRegistryData registrydataloader$networkedregistrydata = p_331925_.get(p_332518_.key()); if (registrydataloader$networkedregistrydata != null) { RegistryOps registryops = RegistryOps.create(NbtOps.INSTANCE, p_329253_); @@ -90,10 +90,10 @@ FileToIdConverter filetoidconverter = FileToIdConverter.registry(p_332518_.key()); for (RegistrySynchronization.PackedRegistryEntry registrysynchronization$packedregistryentry : registrydataloader$networkedregistrydata.elements) { -@@ -346,7 +_,7 @@ +@@ -352,7 +_,7 @@ try { - Resource resource = p_332010_.getResourceOrThrow(resourcelocation); + Resource resource = p_332010_.getResourceOrThrow(identifier); - loadElementFromResource(p_332518_, p_328898_, registryops1, resourcekey, resource, NETWORK_REGISTRATION_INFO); + loadElementFromResource(p_332518_, conditional, registryops1, resourcekey, resource, NETWORK_REGISTRATION_INFO); } catch (Exception exception1) { diff --git a/patches/minecraft/net/minecraft/resources/ResourceKey.java.patch b/patches/minecraft/net/minecraft/resources/ResourceKey.java.patch index 8776a57a65..cd8b023ff3 100644 --- a/patches/minecraft/net/minecraft/resources/ResourceKey.java.patch +++ b/patches/minecraft/net/minecraft/resources/ResourceKey.java.patch @@ -7,24 +7,24 @@ -public class ResourceKey { +public class ResourceKey implements Comparable>, net.minecraftforge.common.extensions.IForgeResourceKey { private static final ConcurrentMap> VALUES = new MapMaker().weakValues().makeMap(); - private final ResourceLocation registryName; - private final ResourceLocation location; + private final Identifier registryName; + private final Identifier identifier; @@ -67,5 +_,18 @@ } - record InternKey(ResourceLocation registry, ResourceLocation location) { + record InternKey(Identifier registry, Identifier identifier) { + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (!(obj instanceof ResourceKey resourceKey)) return false; -+ return location.equals(resourceKey.location) && registryName.equals(resourceKey.registryName); ++ return identifier.equals(resourceKey.identifier) && registryName.equals(resourceKey.registryName); + } + + @Override + public int compareTo(ResourceKey resourceKey) { + int ret = this.registryName.compareTo(resourceKey.registryName); -+ return ret == 0 ? this.location.compareTo(resourceKey.location) : ret; ++ return ret == 0 ? this.identifier.compareTo(resourceKey.identifier) : ret; } } diff --git a/patches/minecraft/net/minecraft/resources/ResourceLocation.java.patch b/patches/minecraft/net/minecraft/resources/ResourceLocation.java.patch deleted file mode 100644 index e1c1e9bc77..0000000000 --- a/patches/minecraft/net/minecraft/resources/ResourceLocation.java.patch +++ /dev/null @@ -1,15 +0,0 @@ ---- a/net/minecraft/resources/ResourceLocation.java -+++ b/net/minecraft/resources/ResourceLocation.java -@@ -154,6 +_,12 @@ - return i; - } - -+ /** Normal compare sorts by path first, this compares namespace first. */ -+ public int compareNamespaced(ResourceLocation o) { -+ int ret = this.namespace.compareTo(o.namespace); -+ return ret != 0 ? ret : this.path.compareTo(o.path); -+ } -+ - public String toDebugFileName() { - return this.toString().replace('/', '_').replace(':', '_'); - } diff --git a/patches/minecraft/net/minecraft/server/Main.java.patch b/patches/minecraft/net/minecraft/server/Main.java.patch index ea166c415f..5eeb7102c3 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 -@@ -86,6 +_,17 @@ +@@ -84,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_); -@@ -94,6 +_,14 @@ +@@ -92,6 +_,14 @@ return; } @@ -33,7 +33,7 @@ Path path = optionset.valueOf(optionspec14); if (path != null) { writePidFile(path); -@@ -108,24 +_,29 @@ +@@ -106,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; -@@ -176,6 +_,10 @@ +@@ -174,6 +_,10 @@ PackRepository packrepository = ServerPacksSource.createPackRepository(levelstoragesource$levelstorageaccess); @@ -81,7 +81,7 @@ WorldStem worldstem; try { WorldLoader.InitConfig worldloader$initconfig = loadOrCreateConfig(dedicatedserversettings.getProperties(), dynamic1, flag, packrepository); -@@ -224,17 +_,18 @@ +@@ -222,17 +_,18 @@ } levelstoragesource$levelstorageaccess.saveDataTag(registryaccess$frozen, worlddata); @@ -104,7 +104,7 @@ } return dedicatedserver1; -@@ -244,6 +_,7 @@ +@@ -242,6 +_,7 @@ @Override public void run() { dedicatedserver.halt(true); @@ -112,7 +112,7 @@ } }; thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(LOGGER)); -@@ -277,6 +_,16 @@ +@@ -275,6 +_,16 @@ worldoptions = p_427999_ ? dedicatedserverproperties.worldOptions.withBonusChest(true) : dedicatedserverproperties.worldOptions; worlddimensions = dedicatedserverproperties.createDimensions(p_423661_.datapackWorldgen()); } diff --git a/patches/minecraft/net/minecraft/server/MinecraftServer.java.patch b/patches/minecraft/net/minecraft/server/MinecraftServer.java.patch index 2fbdb483bd..ace963d40e 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 -@@ -281,7 +_,7 @@ +@@ -284,7 +_,7 @@ public static S spin(Function p_129873_) { AtomicReference atomicreference = new AtomicReference<>(); @@ -9,15 +9,15 @@ thread.setUncaughtExceptionHandler((p_177909_, p_177910_) -> LOGGER.error("Uncaught exception in server thread", p_177910_)); if (Runtime.getRuntime().availableProcessors() > 4) { thread.setPriority(8); -@@ -408,6 +_,7 @@ - DimensionDataStorage dimensiondatastorage = serverlevel.getDataStorage(); - this.readScoreboard(dimensiondatastorage); +@@ -407,6 +_,7 @@ + this.scoreboard.load(dimensiondatastorage.computeIfAbsent(ScoreboardSaveData.TYPE).getData()); this.commandStorage = new CommandStorage(dimensiondatastorage); + this.stopwatches = dimensiondatastorage.computeIfAbsent(Stopwatches.TYPE); + net.minecraftforge.event.ForgeEventFactory.onLevelLoad(levels.get(Level.OVERWORLD)); if (!serverleveldata.isInitialized()) { try { setInitialSpawn(serverlevel, serverleveldata, worldoptions.generateBonusChest(), flag, this.levelLoadListener); -@@ -448,6 +_,7 @@ +@@ -447,6 +_,7 @@ this, this.executor, this.storageSource, derivedleveldata, resourcekey1, entry.getValue(), flag, j, ImmutableList.of(), false, randomsequences ); this.levels.put(resourcekey1, serverlevel1); @@ -25,7 +25,7 @@ } else { serverlevel1 = serverlevel; } -@@ -491,6 +_,7 @@ +@@ -492,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(); @@ -33,7 +33,7 @@ ChunkPos chunkpos = new ChunkPos(serverchunkcache.randomState().sampler().findSpawnPosition()); p_431711_.start(LevelLoadListener.Stage.PREPARE_GLOBAL_SPAWN, 0); p_431711_.updateFocus(p_177897_.dimension(), chunkpos); -@@ -675,6 +_,7 @@ +@@ -677,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); -@@ -721,9 +_,11 @@ +@@ -723,9 +_,11 @@ throw new IllegalStateException("Failed to initialize server"); } @@ -53,7 +53,7 @@ while (this.running) { long i; -@@ -778,6 +_,8 @@ +@@ -774,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); -@@ -789,6 +_,7 @@ +@@ -785,6 +_,7 @@ LOGGER.error("We were unable to save this crash report to disk."); } @@ -70,7 +70,7 @@ this.onServerCrash(crashreport); } finally { try { -@@ -797,6 +_,7 @@ +@@ -793,6 +_,7 @@ } catch (Throwable throwable) { LOGGER.error("Exception stopping the server", throwable); } finally { @@ -78,7 +78,7 @@ this.onServerExit(); } } -@@ -994,12 +_,14 @@ +@@ -995,12 +_,14 @@ } } @@ -93,15 +93,15 @@ } this.ticksUntilAutosave--; -@@ -1017,6 +_,7 @@ +@@ -1018,6 +_,7 @@ this.smoothedTickTimeMillis = this.smoothedTickTimeMillis * 0.8F + (float)k / (float)TimeUtil.NANOSECONDS_PER_MILLISECOND * 0.19999999F; this.logTickMethodTime(i); profilerfiller.pop(); + net.minecraftforge.event.ForgeEventFactory.onPostServerTick(p_129871_, this); } - private void autoSave() { -@@ -1066,7 +_,8 @@ + public void processPacketsAndTick(boolean p_452829_) { +@@ -1079,7 +_,8 @@ Optional.of(serverstatus$players), Optional.of(ServerStatus.Version.current()), Optional.ofNullable(this.statusIcon), @@ -111,17 +111,17 @@ ); } -@@ -1098,7 +_,8 @@ +@@ -1111,7 +_,8 @@ profilerfiller.popPush("levels"); this.updateEffectiveRespawnData(); - for (ServerLevel serverlevel : this.getAllLevels()) { + for (ServerLevel serverlevel : this.getWorldArray()) { + long tickStart = Util.getNanos(); - profilerfiller.push(() -> serverlevel + " " + serverlevel.dimension().location()); + profilerfiller.push(() -> serverlevel + " " + serverlevel.dimension().identifier()); if (this.tickCount % 20 == 0) { profilerfiller.push("timeSync"); -@@ -1107,6 +_,7 @@ +@@ -1120,6 +_,7 @@ } profilerfiller.push("tick"); @@ -129,7 +129,7 @@ try { serverlevel.tick(p_129954_); -@@ -1115,9 +_,11 @@ +@@ -1128,9 +_,11 @@ serverlevel.fillReportDetails(crashreport); throw new ReportedException(crashreport); } @@ -141,7 +141,7 @@ } profilerfiller.popPush("connection"); -@@ -1126,7 +_,7 @@ +@@ -1139,7 +_,7 @@ this.playerList.tick(); profilerfiller.popPush("debugSubscribers"); this.debugSubscribers.tick(); @@ -150,7 +150,7 @@ profilerfiller.popPush("gameTests"); GameTestTicker.SINGLETON.tick(); } -@@ -1229,7 +_,7 @@ +@@ -1238,7 +_,7 @@ @DontObfuscate public String getServerModName() { @@ -159,7 +159,7 @@ } public SystemReport fillSystemReport(SystemReport p_177936_) { -@@ -1579,6 +_,7 @@ +@@ -1564,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()); @@ -167,7 +167,7 @@ }, this); if (this.isSameThread()) { this.managedBlock(completablefuture::isDone); -@@ -1588,12 +_,15 @@ +@@ -1573,12 +_,15 @@ } public static WorldDataConfiguration configurePackRepository(PackRepository p_248681_, WorldDataConfiguration p_331931_, boolean p_249869_, boolean p_330480_) { @@ -184,7 +184,7 @@ } else { Set set = Sets.newLinkedHashSet(); -@@ -2158,6 +_,48 @@ +@@ -2172,6 +_,48 @@ public ServerLinks serverLinks() { return ServerLinks.EMPTY; diff --git a/patches/minecraft/net/minecraft/server/PlayerAdvancements.java.patch b/patches/minecraft/net/minecraft/server/PlayerAdvancements.java.patch index 064beb4994..746ad52c8d 100644 --- a/patches/minecraft/net/minecraft/server/PlayerAdvancements.java.patch +++ b/patches/minecraft/net/minecraft/server/PlayerAdvancements.java.patch @@ -1,22 +1,22 @@ --- a/net/minecraft/server/PlayerAdvancements.java +++ b/net/minecraft/server/PlayerAdvancements.java -@@ -172,6 +_,7 @@ +@@ -171,6 +_,7 @@ this.unregisterListeners(p_298135_); this.progressChanged.add(p_298135_); flag = true; + net.minecraftforge.event.ForgeEventFactory.onAdvancementGrant(this.player, p_298135_, advancementprogress, p_135990_); if (!flag1 && advancementprogress.isDone()) { p_298135_.value().rewards().grant(this.player); - p_298135_.value().display().ifPresent(p_405125_ -> { -@@ -179,6 +_,7 @@ - this.playerList.broadcastSystemMessage(p_405125_.getType().createAnnouncement(p_298135_, this.player), false); + p_298135_.value().display().ifPresent(p_448826_ -> { +@@ -178,6 +_,7 @@ + this.playerList.broadcastSystemMessage(p_448826_.getType().createAnnouncement(p_298135_, this.player), false); } }); + net.minecraftforge.event.ForgeEventFactory.onAdvancementEarned(this.player, p_298135_); } } -@@ -197,6 +_,7 @@ +@@ -196,6 +_,7 @@ this.registerListeners(p_297905_); this.progressChanged.add(p_297905_); flag = true; diff --git a/patches/minecraft/net/minecraft/server/ReloadableServerResources.java.patch b/patches/minecraft/net/minecraft/server/ReloadableServerResources.java.patch index 51d7962f8b..f85a0fffc9 100644 --- a/patches/minecraft/net/minecraft/server/ReloadableServerResources.java.patch +++ b/patches/minecraft/net/minecraft/server/ReloadableServerResources.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/ReloadableServerResources.java +++ b/net/minecraft/server/ReloadableServerResources.java -@@ -26,6 +_,7 @@ +@@ -27,6 +_,7 @@ private final ServerAdvancementManager advancements; private final ServerFunctionLibrary functionLibrary; private final List> postponedTags; @@ -8,7 +8,7 @@ private ReloadableServerResources( LayeredRegistryAccess p_368059_, -@@ -37,9 +_,11 @@ +@@ -38,9 +_,11 @@ ) { this.fullRegistryHolder = new ReloadableServerRegistries.Holder(p_368059_.compositeAccess()); this.postponedTags = p_364269_; @@ -19,22 +19,22 @@ + this.context = new net.minecraftforge.common.crafting.conditions.ConditionContext(this.postponedTags); + this.recipes = new RecipeManager(p_363207_, this.context); + this.advancements = new ServerAdvancementManager(p_363207_, this.context); - this.functionLibrary = new ServerFunctionLibrary(p_206859_, this.commands.getDispatcher()); + this.functionLibrary = new ServerFunctionLibrary(p_453006_, this.commands.getDispatcher()); } -@@ -83,8 +_,10 @@ +@@ -84,8 +_,10 @@ ReloadableServerResources reloadableserverresources = new ReloadableServerResources( - p_358539_.layers(), p_358539_.lookupWithUpdatedTags(), p_250212_, p_249301_, p_366334_, p_251126_ + p_448843_.layers(), p_448843_.lookupWithUpdatedTags(), p_250212_, p_249301_, p_366334_, p_457868_ ); + var listeners = new java.util.ArrayList<>(reloadableserverresources.listeners()); -+ listeners.addAll(net.minecraftforge.event.ForgeEventFactory.onResourceReload(reloadableserverresources, p_358539_.lookupWithUpdatedTags())); ++ listeners.addAll(net.minecraftforge.event.ForgeEventFactory.onResourceReload(reloadableserverresources, p_448843_.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() ) .done() .thenApply(p_214306_ -> reloadableserverresources); -@@ -94,5 +_,14 @@ +@@ -95,5 +_,14 @@ public void updateStaticRegistryTags() { this.postponedTags.forEach(Registry.PendingTags::apply); diff --git a/patches/minecraft/net/minecraft/server/dedicated/DedicatedServer.java.patch b/patches/minecraft/net/minecraft/server/dedicated/DedicatedServer.java.patch index 04ea25d8d8..27f0612f62 100644 --- a/patches/minecraft/net/minecraft/server/dedicated/DedicatedServer.java.patch +++ b/patches/minecraft/net/minecraft/server/dedicated/DedicatedServer.java.patch @@ -1,23 +1,22 @@ --- a/net/minecraft/server/dedicated/DedicatedServer.java +++ b/net/minecraft/server/dedicated/DedicatedServer.java -@@ -97,6 +_,8 @@ - @Nullable - private ManagementServer jsonRpcServer; +@@ -93,6 +_,7 @@ + private final Map codeOfConductTexts; + private @Nullable ManagementServer jsonRpcServer; private long lastHeartbeat; -+ @Nullable -+ private net.minecraft.client.server.LanServerPinger dediLanPinger; ++ private net.minecraft.client.server.@Nullable LanServerPinger dediLanPinger; public DedicatedServer( Thread p_214789_, -@@ -192,6 +_,7 @@ +@@ -189,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 s3; -@@ -265,11 +_,13 @@ + String s4; +@@ -262,11 +_,13 @@ this.tickTimeLogger = new RemoteSampleLogger(TpsDebugDimensions.values().length, this.debugSubscribers(), RemoteDebugSampleType.TICK_TIME); long j = Util.getNanos(); this.services.nameToIdCache().resolveOfflineUsers(!this.usesAuthentication()); @@ -25,13 +24,13 @@ LOGGER.info("Preparing level \"{}\"", this.getLevelIdName()); this.loadLevel(); long k = Util.getNanos() - j; - String s2 = String.format(Locale.ROOT, "%.3fs", k / 1.0E9); - LOGGER.info("Done ({})! For help, type \"help\"", s2); + String s3 = String.format(Locale.ROOT, "%.3fs", k / 1.0E9); + LOGGER.info("Done ({})! For help, type \"help\"", s3); + 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); + this.worldData.getGameRules().set(GameRules.SHOW_ADVANCEMENT_MESSAGES, dedicatedserverproperties.announcePlayerAchievements, this); } -@@ -298,7 +_,12 @@ +@@ -295,7 +_,12 @@ } this.notificationManager().serverStarted(); @@ -45,7 +44,7 @@ } } -@@ -439,6 +_,13 @@ +@@ -436,6 +_,13 @@ LOGGER.error("Interrupted while stopping the management server", (Throwable)interruptedexception); } } @@ -59,7 +58,7 @@ } @Override -@@ -725,8 +_,13 @@ +@@ -717,8 +_,13 @@ @Override public void stopServer() { diff --git a/patches/minecraft/net/minecraft/server/level/ChunkMap.java.patch b/patches/minecraft/net/minecraft/server/level/ChunkMap.java.patch index 225b8dc03c..e4b026bff7 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 -@@ -393,6 +_,7 @@ +@@ -395,6 +_,7 @@ this.modified = true; } @@ -8,7 +8,7 @@ return p_140179_; } } -@@ -519,6 +_,7 @@ +@@ -521,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); -@@ -763,6 +_,7 @@ +@@ -765,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_421447_, p_421448_) -> { - if (p_421448_ != null) { - this.level.getServer().reportChunkSaveFailure(p_421448_, this.storageInfo(), chunkpos); -@@ -1114,7 +_,7 @@ + this.write(chunkpos, completablefuture::join).handle((p_449138_, p_449139_) -> { + if (p_449139_ != null) { + this.level.getServer().reportChunkSaveFailure(p_449139_, this.storageInfo(), chunkpos); +@@ -1143,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 af8f6056a9..c3e4756ad1 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 -@@ -191,6 +_,10 @@ +@@ -189,6 +_,10 @@ return this.ticketDispatcher.getDebugStatus(); } diff --git a/patches/minecraft/net/minecraft/server/level/GenerationChunkHolder.java.patch b/patches/minecraft/net/minecraft/server/level/GenerationChunkHolder.java.patch index 89763996a3..e6f7132fe8 100644 --- a/patches/minecraft/net/minecraft/server/level/GenerationChunkHolder.java.patch +++ b/patches/minecraft/net/minecraft/server/level/GenerationChunkHolder.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/server/level/GenerationChunkHolder.java +++ b/net/minecraft/server/level/GenerationChunkHolder.java -@@ -34,6 +_,9 @@ - private final AtomicReference task = new AtomicReference<>(); +@@ -33,6 +_,9 @@ + private final AtomicReference<@Nullable ChunkGenerationTask> task = new AtomicReference<>(); private final AtomicInteger generationRefCount = new AtomicInteger(); private volatile CompletableFuture generationSaveSyncFuture = CompletableFuture.completedFuture(null); + /** Forge: Used to bypass the future chain when loading chunks, because modders can do weird things that cause deadlocks, modders should never touch this **/ diff --git a/patches/minecraft/net/minecraft/server/level/ServerChunkCache.java.patch b/patches/minecraft/net/minecraft/server/level/ServerChunkCache.java.patch index 872f65af35..e893f6db03 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 -@@ -187,6 +_,10 @@ +@@ -182,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); -@@ -623,5 +_,17 @@ +@@ -616,5 +_,17 @@ return super.pollTask(); } } diff --git a/patches/minecraft/net/minecraft/server/level/ServerLevel.java.patch b/patches/minecraft/net/minecraft/server/level/ServerLevel.java.patch index ec924ce506..d89c4486ca 100644 --- a/patches/minecraft/net/minecraft/server/level/ServerLevel.java.patch +++ b/patches/minecraft/net/minecraft/server/level/ServerLevel.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java -@@ -209,11 +_,13 @@ - @Nullable - private EndDragonFight dragonFight; +@@ -215,11 +_,13 @@ + private final List customSpawners; + private @Nullable EndDragonFight dragonFight; final Int2ObjectMap dragonParts = new Int2ObjectOpenHashMap<>(); + final Int2ObjectMap> partEntities = new Int2ObjectOpenHashMap<>(); private final StructureManager structureManager; @@ -14,16 +14,16 @@ public ServerLevel( MinecraftServer p_214999_, -@@ -294,6 +_,18 @@ - this.gameEventDispatcher = new GameEventDispatcher(this); - this.randomSequences = Objects.requireNonNullElseGet(p_288977_, () -> this.getDataStorage().computeIfAbsent(RandomSequences.TYPE)); +@@ -304,6 +_,18 @@ this.waypointManager = new ServerWaypointManager(); + this.environmentAttributes = EnvironmentAttributeSystem.builder().addDefaultLayers(this).build(); + this.updateSkyBrightness(); + this.initCapabilities(); + } + + protected void initCapabilities() { + this.gatherCapabilities(); -+ capabilityData = this.getDataStorage().computeIfAbsent(net.minecraftforge.common.util.LevelCapabilityData.TYPE); ++ capabilityData = this.getDataStorage().computeIfAbsent(net.minecraftforge.common.util.LevelCapabilityData.type(this)); + } + + /** Forge: Internal method only for out capability storage system */ @@ -33,10 +33,10 @@ } @Deprecated -@@ -335,8 +_,8 @@ - int i = this.getGameRules().getInt(GameRules.RULE_PLAYERS_SLEEPING_PERCENTAGE); +@@ -350,8 +_,8 @@ + int i = this.getGameRules().get(GameRules.PLAYERS_SLEEPING_PERCENTAGE); if (this.sleepStatus.areEnoughSleeping(i) && this.sleepStatus.areEnoughDeepSleeping(i, this.players)) { - if (this.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT)) { + if (this.getGameRules().get(GameRules.ADVANCE_TIME)) { - long j = this.levelData.getDayTime() + 24000L; - this.setDayTime(j - j % 24000L); + long j = this.getDayTime() + 24000L; @@ -44,7 +44,7 @@ } this.wakeUpAllPlayers(); -@@ -407,6 +_,7 @@ +@@ -422,6 +_,7 @@ p_358707_.stopRiding(); } @@ -52,7 +52,7 @@ profilerfiller.push("tick"); this.guardEntityTick(this::tickNonPassenger, p_358707_); profilerfiller.pop(); -@@ -552,6 +_,7 @@ +@@ -572,6 +_,7 @@ BlockPos blockpos = this.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING, p_300602_); BlockPos blockpos1 = blockpos.below(); Biome biome = this.getBiome(blockpos).value(); @@ -60,7 +60,7 @@ if (biome.shouldFreeze(this, blockpos1)) { this.setBlockAndUpdate(blockpos1, Blocks.ICE.defaultBlockState()); } -@@ -731,8 +_,8 @@ +@@ -769,8 +_,8 @@ this.server.getPlayerList().broadcastAll(new ClientboundGameEventPacket(ClientboundGameEventPacket.START_RAINING, 0.0F)); } @@ -71,7 +71,7 @@ } } -@@ -769,6 +_,7 @@ +@@ -807,6 +_,7 @@ p_8648_.tickCount++; profilerfiller.push(() -> BuiltInRegistries.ENTITY_TYPE.getKey(p_8648_.getType()).toString()); profilerfiller.incrementCounter("tickNonPassenger"); @@ -79,7 +79,7 @@ p_8648_.tick(); profilerfiller.pop(); -@@ -786,6 +_,7 @@ +@@ -824,6 +_,7 @@ ProfilerFiller profilerfiller = Profiler.get(); profilerfiller.push(() -> BuiltInRegistries.ENTITY_TYPE.getKey(p_8664_.getType()).toString()); profilerfiller.incrementCounter("tickPassenger"); @@ -87,7 +87,7 @@ p_8664_.rideTick(); profilerfiller.pop(); -@@ -832,6 +_,7 @@ +@@ -870,6 +_,7 @@ } else { this.entityManager.autoSave(); } @@ -95,7 +95,7 @@ } } -@@ -926,6 +_,7 @@ +@@ -963,6 +_,7 @@ } private void addPlayer(ServerPlayer p_8854_) { @@ -103,7 +103,7 @@ Entity entity = this.getEntity(p_8854_.getUUID()); if (entity != null) { LOGGER.warn("Force-added player with duplicate UUID {}", p_8854_.getUUID()); -@@ -933,7 +_,8 @@ +@@ -970,7 +_,8 @@ this.removePlayerImmediately((ServerPlayer)entity, Entity.RemovalReason.DISCARDED); } @@ -113,7 +113,7 @@ } private boolean addEntity(Entity p_8873_) { -@@ -941,7 +_,12 @@ +@@ -978,7 +_,12 @@ LOGGER.warn("Tried to add entity {} but it was marked as removed already", EntityType.getKey(p_8873_.getType())); return false; } else { @@ -127,7 +127,7 @@ } } -@@ -990,6 +_,12 @@ +@@ -1027,6 +_,12 @@ float p_263520_, long p_263490_ ) { @@ -140,7 +140,7 @@ this.server .getPlayerList() .broadcast( -@@ -1007,6 +_,12 @@ +@@ -1044,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_ ) { @@ -153,7 +153,7 @@ this.server .getPlayerList() .broadcast( -@@ -1065,6 +_,7 @@ +@@ -1102,6 +_,7 @@ @Override public void gameEvent(Holder p_334475_, Vec3 p_215042_, GameEvent.Context p_215043_) { @@ -161,7 +161,7 @@ this.gameEventDispatcher.post(p_334475_, p_215042_, p_215043_); } -@@ -1103,16 +_,24 @@ +@@ -1140,16 +_,24 @@ @Override public void updateNeighborsAt(BlockPos p_215045_, Block p_215046_) { @@ -186,13 +186,13 @@ this.neighborUpdater.updateNeighborsAtExceptFromFacing(p_215052_, p_215053_, p_215054_, p_370072_); } -@@ -1159,12 +_,14 @@ +@@ -1196,12 +_,14 @@ Explosion.BlockInteraction explosion$blockinteraction = switch (p_255827_) { case NONE -> Explosion.BlockInteraction.KEEP; - case BLOCK -> this.getDestroyType(GameRules.RULE_BLOCK_EXPLOSION_DROP_DECAY); -- case MOB -> this.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) ? this.getDestroyType(GameRules.RULE_MOB_EXPLOSION_DROP_DECAY) : Explosion.BlockInteraction.KEEP; -+ case MOB -> net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this, p_256039_) ? this.getDestroyType(GameRules.RULE_MOB_EXPLOSION_DROP_DECAY) : Explosion.BlockInteraction.KEEP; - case TNT -> this.getDestroyType(GameRules.RULE_TNT_EXPLOSION_DROP_DECAY); + case BLOCK -> this.getDestroyType(GameRules.BLOCK_EXPLOSION_DROP_DECAY); +- case MOB -> this.getGameRules().get(GameRules.MOB_GRIEFING) ? this.getDestroyType(GameRules.MOB_EXPLOSION_DROP_DECAY) : Explosion.BlockInteraction.KEEP; ++ case MOB -> net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this, p_256039_) ? this.getDestroyType(GameRules.MOB_EXPLOSION_DROP_DECAY) : Explosion.BlockInteraction.KEEP; + case TNT -> this.getDestroyType(GameRules.TNT_EXPLOSION_DROP_DECAY); case TRIGGER -> Explosion.BlockInteraction.TRIGGER_BLOCK; }; Vec3 vec3 = new Vec3(p_256067_, p_256370_, p_256153_); @@ -202,8 +202,8 @@ int i = serverexplosion.explode(); ParticleOptions particleoptions = serverexplosion.isSmall() ? p_310962_ : p_310322_; -@@ -1792,6 +_,11 @@ - return this.debugSynchronizers; +@@ -1846,6 +_,11 @@ + return this.getGameRules().get(GameRules.SPAWNER_BLOCKS_WORK); } + @Override @@ -214,7 +214,7 @@ final class EntityCallbacks implements LevelCallback { public void onCreated(Entity p_143355_) { if (p_143355_ instanceof WaypointTransmitter waypointtransmitter && waypointtransmitter.isTransmittingWaypoint()) { -@@ -1847,6 +_,12 @@ +@@ -1901,6 +_,12 @@ } } @@ -227,7 +227,7 @@ p_143371_.updateDynamicGameEventListener(DynamicGameEventListener::add); } -@@ -1875,8 +_,17 @@ +@@ -1929,8 +_,17 @@ } } diff --git a/patches/minecraft/net/minecraft/server/level/ServerPlayer.java.patch b/patches/minecraft/net/minecraft/server/level/ServerPlayer.java.patch index 3b4eb9d3f1..bb85e8aaf1 100644 --- a/patches/minecraft/net/minecraft/server/level/ServerPlayer.java.patch +++ b/patches/minecraft/net/minecraft/server/level/ServerPlayer.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/server/level/ServerPlayer.java +++ b/net/minecraft/server/level/ServerPlayer.java -@@ -204,7 +_,8 @@ - import net.minecraft.world.scores.criteria.ObjectiveCriteria; +@@ -203,7 +_,8 @@ + import org.jspecify.annotations.Nullable; import org.slf4j.Logger; -public class ServerPlayer extends Player { @@ -10,23 +10,23 @@ 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; -@@ -874,6 +_,7 @@ +@@ -871,6 +_,7 @@ @Override public void die(DamageSource p_9035_) { + if (net.minecraftforge.event.ForgeEventFactory.onLivingDeath(this, p_9035_)) return; this.gameEvent(GameEvent.ENTITY_DIE); - boolean flag = this.level().getGameRules().getBoolean(GameRules.RULE_SHOWDEATHMESSAGES); + boolean flag = this.level().getGameRules().get(GameRules.SHOW_DEATH_MESSAGES); if (flag) { -@@ -1082,6 +_,7 @@ +@@ -1080,6 +_,7 @@ + } - @Nullable - public ServerPlayer teleport(TeleportTransition p_361322_) { + public @Nullable ServerPlayer teleport(TeleportTransition p_361322_) { + if (net.minecraftforge.event.ForgeEventFactory.onTravelToDimension(this, p_361322_.newLevel().dimension())) return null; if (this.isRemoved()) { return null; } else { -@@ -1109,7 +_,7 @@ +@@ -1107,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) { -@@ -1134,6 +_,7 @@ +@@ -1132,6 +_,7 @@ this.lastSentHealth = -1.0F; this.lastSentFood = -1; this.teleportSpectators(p_361322_, serverlevel1); @@ -43,7 +43,7 @@ return this; } } -@@ -1175,6 +_,9 @@ +@@ -1173,10 +_,13 @@ @Override public Either startSleepInBed(BlockPos p_9115_) { @@ -51,18 +51,14 @@ + var ret = net.minecraftforge.event.ForgeEventFactory.onPlayerSleepInBed(this, optAt); + if (ret != null) return Either.left(ret); Direction direction = this.level().getBlockState(p_9115_).getValue(HorizontalDirectionalBlock.FACING); - if (this.isSleeping() || !this.isAlive()) { - return Either.left(Player.BedSleepingProblem.OTHER_PROBLEM); -@@ -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()) { -@@ -1235,6 +_,7 @@ + if (!this.isSleeping() && this.isAlive()) { + BedRule bedrule = this.level().environmentAttributes().getValue(EnvironmentAttributes.BED_RULE, p_9115_); +- boolean flag = bedrule.canSleep(this.level()); ++ boolean flag = !net.minecraftforge.event.ForgeEventFactory.onSleepingTimeCheck(this, optAt, bedrule); + boolean flag1 = bedrule.canSetSpawn(this.level()); + if (!flag1 && !flag) { + return Either.left(bedrule.asProblem()); +@@ -1243,6 +_,7 @@ } private boolean bedInRange(BlockPos p_9117_, Direction p_9118_) { @@ -70,7 +66,7 @@ return this.isReachableBedBlock(p_9117_) || this.isReachableBedBlock(p_9117_.relative(p_9118_.getOpposite())); } -@@ -1338,6 +_,7 @@ +@@ -1346,6 +_,7 @@ this.connection.send(new ClientboundOpenScreenPacket(abstractcontainermenu.containerId, abstractcontainermenu.getType(), p_9033_.getDisplayName())); this.initMenu(abstractcontainermenu); this.containerMenu = abstractcontainermenu; @@ -78,7 +74,7 @@ return OptionalInt.of(this.containerCounter); } } -@@ -1387,6 +_,7 @@ +@@ -1408,6 +_,7 @@ public void doCloseContainer() { this.containerMenu.removed(this); this.inventoryMenu.transferState(this.containerMenu); @@ -86,10 +82,10 @@ this.containerMenu = this.inventoryMenu; } -@@ -1613,6 +_,15 @@ - this.setShoulderEntityLeft(p_9016_.getShoulderEntityLeft()); +@@ -1630,6 +_,15 @@ this.setShoulderEntityRight(p_9016_.getShoulderEntityRight()); this.setLastDeathLocation(p_9016_.getLastDeathLocation()); + this.waypointIcon().copyFrom(p_9016_.waypointIcon()); + + //Copy over a section of the Entity Data from the old player. + //Allows mods to specify data that persists after players respawn. @@ -101,8 +97,8 @@ + this.tabListFooter = p_9016_.tabListFooter; } - @Override -@@ -1712,6 +_,7 @@ + private void transferInventoryXpAndScore(Player p_460820_) { +@@ -1738,6 +_,7 @@ public boolean setGameMode(GameType p_143404_) { boolean flag = this.isSpectator(); @@ -110,7 +106,7 @@ if (!this.gameMode.changeGameModeForPlayer(p_143404_)) { return false; } else { -@@ -1864,6 +_,9 @@ +@@ -1891,6 +_,9 @@ public void setCamera(@Nullable Entity p_9214_) { Entity entity = this.getCamera(); this.camera = (Entity)(p_9214_ == null ? this : p_9214_); @@ -120,10 +116,10 @@ if (entity != this.camera) { if (this.camera.level() instanceof ServerLevel serverlevel) { this.teleportTo( -@@ -1902,7 +_,11 @@ +@@ -1928,7 +_,11 @@ + } - @Nullable - public Component getTabListDisplayName() { + public @Nullable Component getTabListDisplayName() { - return null; + if (!this.hasTabListName) { + this.tabListDisplayName = net.minecraftforge.event.ForgeEventFactory.getPlayerTabListDisplayName(this); @@ -133,31 +129,35 @@ } public int getTabListOrder() { -@@ -1937,6 +_,7 @@ +@@ -1962,6 +_,7 @@ } - public void setRespawnPosition(@Nullable ServerPlayer.RespawnConfig p_396560_, boolean p_9162_) { + public void setRespawnPosition(ServerPlayer.@Nullable RespawnConfig p_396560_, boolean p_9162_) { + if (net.minecraftforge.event.ForgeEventFactory.onPlayerSpawnSet(this, p_396560_)) return; if (p_9162_ && p_396560_ != null && !p_396560_.isSamePosition(this.respawnConfig)) { this.sendSystemMessage(SPAWN_SET_MESSAGE); } -@@ -2042,9 +_,12 @@ +@@ -2049,13 +_,16 @@ - public boolean drop(boolean p_182295_) { + public void drop(boolean p_182295_) { Inventory inventory = this.getInventory(); + ItemStack selected = inventory.getSelectedItem(); -+ if (selected.isEmpty() || !selected.onDroppedByPlayer(this)) return false; ++ if (selected.isEmpty() || !selected.onDroppedByPlayer(this)) return; + if (isUsingItem() && getUsedItemHand() == InteractionHand.MAIN_HAND && (p_182295_ || selected.getCount() == 1)) stopUsingItem(); // Forge: fix MC-231097 on the serverside ItemStack itemstack = inventory.removeFromSelected(p_182295_); this.containerMenu.findSlot(inventory, inventory.getSelectedSlot()).ifPresent(p_390148_ -> this.containerMenu.setRemoteSlot(p_390148_, inventory.getSelectedItem())); -- return this.drop(itemstack, false, true) != null; -+ return net.minecraftforge.common.ForgeHooks.onPlayerTossEvent(this, itemstack, true) != null; + if (this.useItem.isEmpty()) { + this.stopUsingItem(); + } + +- this.drop(itemstack, false, true); ++ net.minecraftforge.common.ForgeHooks.onPlayerTossEvent(this, itemstack, true); } @Override -@@ -2148,6 +_,75 @@ - @Nullable - public BlockPos getRaidOmenPosition() { +@@ -2157,6 +_,75 @@ + + public @Nullable BlockPos getRaidOmenPosition() { return this.raidOmenPosition; + } + diff --git a/patches/minecraft/net/minecraft/server/level/ServerPlayerGameMode.java.patch b/patches/minecraft/net/minecraft/server/level/ServerPlayerGameMode.java.patch index 6abacb0110..723a265226 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 -@@ -151,6 +_,10 @@ +@@ -149,6 +_,10 @@ } public void handleBlockBreakAction(BlockPos p_215120_, ServerboundPlayerActionPacket.Action p_215121_, Direction p_215122_, int p_215123_, int p_215124_) { @@ -8,10 +8,10 @@ + if (event == null) { + return; + } - if (!this.player.canInteractWithBlock(p_215120_, 1.0)) { + if (!this.player.isWithinBlockInteractionRange(p_215120_, 1.0)) { this.debugLogging(p_215120_, false, p_215124_, "too far"); } else if (p_215120_.getY() > p_215123_) { -@@ -179,6 +_,7 @@ +@@ -177,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(), -@@ -190,6 +_,7 @@ +@@ -188,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_); } -@@ -256,7 +_,8 @@ +@@ -254,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_); -@@ -264,34 +_,50 @@ +@@ -262,34 +_,50 @@ if (block instanceof GameMasterBlock && !this.player.canUseGameMasterBlocks()) { this.level.sendBlockUpdated(p_9281_, blockstate1, blockstate1, 3); return false; @@ -99,7 +99,7 @@ } public InteractionResult useItem(ServerPlayer p_9262_, Level p_9263_, ItemStack p_9264_, InteractionHand p_9265_) { -@@ -300,6 +_,8 @@ +@@ -298,6 +_,8 @@ } else if (p_9262_.getCooldowns().isOnCooldown(p_9264_)) { return InteractionResult.PASS; } else { @@ -108,7 +108,7 @@ int i = p_9264_.getCount(); int j = p_9264_.getDamageValue(); InteractionResult interactionresult = p_9264_.use(p_9263_, p_9262_, p_9265_); -@@ -338,6 +_,11 @@ +@@ -336,6 +_,11 @@ if (!blockstate.getBlock().isEnabled(p_9267_.enabledFeatures())) { return InteractionResult.FAIL; } else if (this.gameModeForPlayer == GameType.SPECTATOR) { @@ -120,7 +120,7 @@ MenuProvider menuprovider = blockstate.getMenuProvider(p_9267_, blockpos); if (menuprovider != null) { p_9266_.openMenu(menuprovider); -@@ -346,10 +_,16 @@ +@@ -344,10 +_,16 @@ return InteractionResult.PASS; } } else { @@ -138,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); -@@ -365,8 +_,8 @@ +@@ -363,8 +_,8 @@ } } diff --git a/patches/minecraft/net/minecraft/server/level/WorldGenRegion.java.patch b/patches/minecraft/net/minecraft/server/level/WorldGenRegion.java.patch index 77dfc22633..8edd68c597 100644 --- a/patches/minecraft/net/minecraft/server/level/WorldGenRegion.java.patch +++ b/patches/minecraft/net/minecraft/server/level/WorldGenRegion.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/WorldGenRegion.java +++ b/net/minecraft/server/level/WorldGenRegion.java -@@ -317,6 +_,7 @@ +@@ -314,6 +_,7 @@ @Override public boolean addFreshEntity(Entity p_9580_) { diff --git a/patches/minecraft/net/minecraft/server/network/EventLoopGroupHolder.java.patch b/patches/minecraft/net/minecraft/server/network/EventLoopGroupHolder.java.patch new file mode 100644 index 0000000000..dd2fe2fc5c --- /dev/null +++ b/patches/minecraft/net/minecraft/server/network/EventLoopGroupHolder.java.patch @@ -0,0 +1,50 @@ +--- a/net/minecraft/server/network/EventLoopGroupHolder.java ++++ b/net/minecraft/server/network/EventLoopGroupHolder.java +@@ -52,6 +_,7 @@ + private final Class channelCls; + private final Class serverChannelCls; + private volatile @Nullable EventLoopGroup group; ++ private volatile @Nullable EventLoopGroup groupClient; + + public static EventLoopGroupHolder remote(boolean p_453425_) { + if (p_453425_) { +@@ -77,24 +_,31 @@ + this.serverChannelCls = p_455144_; + } + +- private ThreadFactory createThreadFactory() { +- return new ThreadFactoryBuilder().setNameFormat("Netty " + this.type + " IO #%d").setDaemon(true).build(); ++ private ThreadFactory createThreadFactory(boolean client) { ++ return new ThreadFactoryBuilder().setNameFormat("Netty " + this.type + (client ? " Client" : " Server") + " IO #%d").setDaemon(true).setThreadFactory(net.minecraftforge.fml.util.thread.SidedThreadGroups.get(client)).build(); + } + + protected abstract IoHandlerFactory ioHandlerFactory(); + +- private EventLoopGroup createEventLoopGroup() { +- return new MultiThreadIoEventLoopGroup(this.createThreadFactory(), this.ioHandlerFactory()); ++ private EventLoopGroup createEventLoopGroup(boolean client) { ++ return new MultiThreadIoEventLoopGroup(this.createThreadFactory(client), this.ioHandlerFactory()); + } + + public EventLoopGroup eventLoopGroup() { +- EventLoopGroup eventloopgroup = this.group; ++ return eventLoopGroup(false); ++ } ++ ++ public EventLoopGroup eventLoopGroup(boolean client) { ++ EventLoopGroup eventloopgroup = client ? this.groupClient : this.group; + if (eventloopgroup == null) { + synchronized (this) { +- eventloopgroup = this.group; ++ eventloopgroup = client ? this.groupClient : this.group; + if (eventloopgroup == null) { +- eventloopgroup = this.createEventLoopGroup(); +- this.group = eventloopgroup; ++ eventloopgroup = this.createEventLoopGroup(client); ++ if (client) ++ this.groupClient = eventloopgroup; ++ else ++ this.group = eventloopgroup; + } + } + } diff --git a/patches/minecraft/net/minecraft/server/network/ServerConfigurationPacketListenerImpl.java.patch b/patches/minecraft/net/minecraft/server/network/ServerConfigurationPacketListenerImpl.java.patch index f0687b4725..211489b6f0 100644 --- a/patches/minecraft/net/minecraft/server/network/ServerConfigurationPacketListenerImpl.java.patch +++ b/patches/minecraft/net/minecraft/server/network/ServerConfigurationPacketListenerImpl.java.patch @@ -1,17 +1,16 @@ --- a/net/minecraft/server/network/ServerConfigurationPacketListenerImpl.java +++ b/net/minecraft/server/network/ServerConfigurationPacketListenerImpl.java -@@ -47,6 +_,7 @@ +@@ -47,17 +_,20 @@ 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 -@@ -56,11 +_,13 @@ - private SynchronizeRegistriesTask synchronizeRegistriesTask; - @Nullable - private PrepareSpawnTask prepareSpawnTask; + private @Nullable ConfigurationTask currentTask; + private ClientInformation clientInformation; + private @Nullable SynchronizeRegistriesTask synchronizeRegistriesTask; + private @Nullable PrepareSpawnTask prepareSpawnTask; + private final net.minecraftforge.network.config.ConfigurationTaskContext taskContext; public ServerConfigurationPacketListenerImpl(MinecraftServer p_301415_, Connection p_298106_, CommonListenerCookie p_301309_) { @@ -22,7 +21,7 @@ } @Override -@@ -84,18 +_,23 @@ +@@ -81,18 +_,23 @@ return this.connection.isConnected(); } @@ -48,7 +47,7 @@ this.addOptionalTasks(); this.returnToWorld(); } -@@ -211,7 +_,7 @@ +@@ -208,7 +_,7 @@ this.currentTask = configurationtask; try { diff --git a/patches/minecraft/net/minecraft/server/network/ServerConnectionListener.java.patch b/patches/minecraft/net/minecraft/server/network/ServerConnectionListener.java.patch index ee8d6f9eb8..6a617e090e 100644 --- a/patches/minecraft/net/minecraft/server/network/ServerConnectionListener.java.patch +++ b/patches/minecraft/net/minecraft/server/network/ServerConnectionListener.java.patch @@ -1,30 +1,23 @@ --- a/net/minecraft/server/network/ServerConnectionListener.java +++ b/net/minecraft/server/network/ServerConnectionListener.java -@@ -49,11 +_,12 @@ +@@ -37,6 +_,7 @@ + import org.slf4j.Logger; public class ServerConnectionListener { - private static final Logger LOGGER = LogUtils.getLogger(); + private static final int READ_TIMEOUT = Integer.parseInt(System.getProperty("forge.readTimeout", "30")); - public static final Supplier SERVER_EVENT_GROUP = Suppliers.memoize( -- () -> new NioEventLoopGroup(0, new ThreadFactoryBuilder().setNameFormat("Netty Server IO #%d").setDaemon(true).build()) -+ () -> new NioEventLoopGroup(0, new ThreadFactoryBuilder().setNameFormat("Netty Server IO #%d").setDaemon(true).setThreadFactory(net.minecraftforge.fml.util.thread.SidedThreadGroups.SERVER).build()) - ); - public static final Supplier SERVER_EPOLL_EVENT_GROUP = Suppliers.memoize( -- () -> new EpollEventLoopGroup(0, new ThreadFactoryBuilder().setNameFormat("Netty Epoll Server IO #%d").setDaemon(true).build()) -+ () -> new EpollEventLoopGroup(0, new ThreadFactoryBuilder().setNameFormat("Netty Epoll Server IO #%d").setDaemon(true).setThreadFactory(net.minecraftforge.fml.util.thread.SidedThreadGroups.SERVER).build()) - ); + private static final Logger LOGGER = LogUtils.getLogger(); final MinecraftServer server; public volatile boolean running; -@@ -66,6 +_,8 @@ +@@ -49,6 +_,8 @@ } public void startTcpServerListener(@Nullable InetAddress p_9712_, int p_9713_) throws IOException { + if (p_9712_ == null) p_9712_ = new java.net.InetSocketAddress(p_9713_).getAddress(); + net.minecraftforge.network.DualStackUtils.checkIPv6(p_9712_); synchronized (this.channels) { - Class oclass; - EventLoopGroup eventloopgroup; -@@ -87,7 +_,7 @@ + EventLoopGroupHolder eventloopgroupholder = EventLoopGroupHolder.remote(this.server.useNativeTransport()); + this.channels.add(new ServerBootstrap().channel(eventloopgroupholder.serverChannelCls()).childHandler(new ChannelInitializer() { +@@ -59,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 b8a70951de..694cede4fd 100644 --- a/patches/minecraft/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch +++ b/patches/minecraft/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch @@ -1,12 +1,12 @@ --- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -1175,9 +_,10 @@ - switch (serverboundplayeractionpacket$action) { +@@ -1213,9 +_,10 @@ + } case SWAP_ITEM_WITH_OFFHAND: if (!this.player.isSpectator()) { -- ItemStack itemstack = this.player.getItemInHand(InteractionHand.OFF_HAND); +- ItemStack itemstack1 = this.player.getItemInHand(InteractionHand.OFF_HAND); - this.player.setItemInHand(InteractionHand.OFF_HAND, this.player.getItemInHand(InteractionHand.MAIN_HAND)); -- this.player.setItemInHand(InteractionHand.MAIN_HAND, itemstack); +- this.player.setItemInHand(InteractionHand.MAIN_HAND, itemstack1); + var event = net.minecraftforge.event.ForgeEventFactory.onLivingSwapHandItems(this.player); + if (event == null) return; + this.player.setItemInHand(InteractionHand.OFF_HAND, event.getItemSwappedToOffHand()); @@ -14,7 +14,7 @@ this.player.stopUsingItem(); } -@@ -1376,8 +_,9 @@ +@@ -1414,8 +_,9 @@ } CompletableFuture completablefuture = this.filterTextPacket(playerchatmessage.signedContent()); @@ -25,7 +25,7 @@ PlayerChatMessage playerchatmessage1 = playerchatmessage.withUnsignedContent(component).filter(p_296589_.mask()); this.broadcastChatMessage(playerchatmessage1); }); -@@ -1707,7 +_,7 @@ +@@ -1745,7 +_,7 @@ @Override public void onInteraction(InteractionHand p_143682_, Vec3 p_143683_) { @@ -34,7 +34,7 @@ } @Override -@@ -2021,6 +_,7 @@ +@@ -2063,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 cd49971418..e0f4fc0e39 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 -@@ -184,7 +_,7 @@ +@@ -185,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"); -@@ -227,6 +_,7 @@ +@@ -228,6 +_,7 @@ @Override public void handleCustomQueryPacket(ServerboundCustomQueryAnswerPacket p_297965_) { @@ -17,7 +17,7 @@ this.disconnect(ServerCommonPacketListenerImpl.DISCONNECT_UNEXPECTED_QUERY); } -@@ -251,6 +_,11 @@ +@@ -252,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 index 223f75483a..b65bb874c4 100644 --- a/patches/minecraft/net/minecraft/server/network/config/PrepareSpawnTask.java.patch +++ b/patches/minecraft/net/minecraft/server/network/config/PrepareSpawnTask.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/network/config/PrepareSpawnTask.java +++ b/net/minecraft/server/network/config/PrepareSpawnTask.java -@@ -184,6 +_,7 @@ +@@ -181,6 +_,7 @@ .loadPlayerData(PrepareSpawnTask.this.nameAndId) .map(p_423730_ -> TagValueInput.create(problemreporter$scopedcollector, PrepareSpawnTask.this.server.registryAccess(), p_423730_)); optional.ifPresent(serverplayer::load); diff --git a/patches/minecraft/net/minecraft/server/packs/AbstractPackResources.java.patch b/patches/minecraft/net/minecraft/server/packs/AbstractPackResources.java.patch index 06fe719f00..843689eee5 100644 --- a/patches/minecraft/net/minecraft/server/packs/AbstractPackResources.java.patch +++ b/patches/minecraft/net/minecraft/server/packs/AbstractPackResources.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/packs/AbstractPackResources.java +++ b/net/minecraft/server/packs/AbstractPackResources.java -@@ -62,4 +_,9 @@ +@@ -60,4 +_,9 @@ public PackLocationInfo location() { return this.location; } diff --git a/patches/minecraft/net/minecraft/server/packs/PackResources.java.patch b/patches/minecraft/net/minecraft/server/packs/PackResources.java.patch index db7f011532..8b829869d3 100644 --- a/patches/minecraft/net/minecraft/server/packs/PackResources.java.patch +++ b/patches/minecraft/net/minecraft/server/packs/PackResources.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/packs/PackResources.java +++ b/net/minecraft/server/packs/PackResources.java @@ -11,7 +_,7 @@ - import net.minecraft.server.packs.repository.KnownPack; import net.minecraft.server.packs.resources.IoSupplier; + import org.jspecify.annotations.Nullable; -public interface PackResources extends AutoCloseable { +public interface PackResources extends AutoCloseable, net.minecraftforge.common.extensions.IForgePackResources { 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 959f44ed96..80cef14587 100644 --- a/patches/minecraft/net/minecraft/server/packs/repository/Pack.java.patch +++ b/patches/minecraft/net/minecraft/server/packs/repository/Pack.java.patch @@ -6,17 +6,17 @@ private final PackSelectionConfig selectionConfig; + private final boolean hidden; // Forge: Allow packs to be hidden from the UI entirely - @Nullable - public static Pack readMetaAndCreate(PackLocationInfo p_333251_, Pack.ResourcesSupplier p_252210_, PackType p_250595_, PackSelectionConfig p_334202_) { -@@ -36,6 +_,7 @@ + public static @Nullable Pack readMetaAndCreate(PackLocationInfo p_333251_, Pack.ResourcesSupplier p_252210_, PackType p_250595_, PackSelectionConfig p_334202_) { + PackFormat packformat = SharedConstants.getCurrentVersion().packVersion(p_250595_); +@@ -35,6 +_,7 @@ this.resources = p_249377_; this.metadata = p_330761_; this.selectionConfig = p_334769_; + this.hidden = p_330761_.isHidden(); } - @Nullable -@@ -58,7 +_,7 @@ + public static Pack.@Nullable Metadata readPackMetadata(PackLocationInfo p_330799_, Pack.ResourcesSupplier p_331172_, PackFormat p_425340_, PackType p_426910_) { +@@ -56,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(); @@ -25,7 +25,7 @@ } return pack$metadata; -@@ -120,6 +_,10 @@ +@@ -118,6 +_,10 @@ return this.location.source(); } @@ -36,7 +36,7 @@ @Override public boolean equals(Object p_10448_) { if (this == p_10448_) { -@@ -134,7 +_,10 @@ +@@ -132,7 +_,10 @@ return this.location.hashCode(); } diff --git a/patches/minecraft/net/minecraft/server/packs/repository/PackDetector.java.patch b/patches/minecraft/net/minecraft/server/packs/repository/PackDetector.java.patch index e3f8d3c983..926ea645a2 100644 --- a/patches/minecraft/net/minecraft/server/packs/repository/PackDetector.java.patch +++ b/patches/minecraft/net/minecraft/server/packs/repository/PackDetector.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/server/packs/repository/PackDetector.java +++ b/net/minecraft/server/packs/repository/PackDetector.java -@@ -20,6 +_,10 @@ +@@ -19,6 +_,10 @@ + } - @Nullable - public T detectPackResources(Path p_298083_, List p_297322_) throws IOException { + public @Nullable T detectPackResources(Path p_298083_, List p_297322_) throws IOException { + return detectPackResources(p_298083_, p_297322_, true); + } + @Nullable @@ -11,7 +11,7 @@ Path path = p_298083_; BasicFileAttributes basicfileattributes; -@@ -44,10 +_,11 @@ +@@ -43,10 +_,11 @@ if (!p_297322_.isEmpty()) { return null; } else { diff --git a/patches/minecraft/net/minecraft/server/packs/repository/PackRepository.java.patch b/patches/minecraft/net/minecraft/server/packs/repository/PackRepository.java.patch index a1e4e7d2b5..bd59447637 100644 --- a/patches/minecraft/net/minecraft/server/packs/repository/PackRepository.java.patch +++ b/patches/minecraft/net/minecraft/server/packs/repository/PackRepository.java.patch @@ -9,9 +9,9 @@ } public static String displayPackList(Collection p_331712_) { -@@ -120,6 +_,10 @@ - @Nullable - public Pack getPack(String p_10508_) { +@@ -119,6 +_,10 @@ + + public @Nullable Pack getPack(String p_10508_) { return this.available.get(p_10508_); + } + 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 93f159eb8f..79d34a47b0 100644 --- a/patches/minecraft/net/minecraft/server/packs/repository/ServerPacksSource.java.patch +++ b/patches/minecraft/net/minecraft/server/packs/repository/ServerPacksSource.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/packs/repository/ServerPacksSource.java +++ b/net/minecraft/server/packs/repository/ServerPacksSource.java -@@ -67,7 +_,9 @@ +@@ -65,7 +_,9 @@ } public static PackRepository createPackRepository(Path p_251569_, DirectoryValidator p_300268_) { diff --git a/patches/minecraft/net/minecraft/server/packs/resources/FallbackResourceManager.java.patch b/patches/minecraft/net/minecraft/server/packs/resources/FallbackResourceManager.java.patch index a724fdc81a..c0e602a546 100644 --- a/patches/minecraft/net/minecraft/server/packs/resources/FallbackResourceManager.java.patch +++ b/patches/minecraft/net/minecraft/server/packs/resources/FallbackResourceManager.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/packs/resources/FallbackResourceManager.java +++ b/net/minecraft/server/packs/resources/FallbackResourceManager.java -@@ -103,8 +_,11 @@ +@@ -101,8 +_,11 @@ for (int i = this.fallbacks.size() - 1; i >= 0; i--) { FallbackResourceManager.PackEntry fallbackresourcemanager$packentry = this.fallbacks.get(i); @@ -11,10 +11,10 @@ + var children = pack.getChildren(); + var packs = children == null ? List.of(pack) : children; + for (final PackResources packresources : packs) { - IoSupplier iosupplier = packresources.getResource(this.type, p_215367_); + IoSupplier iosupplier = packresources.getResource(this.type, p_458089_); if (iosupplier != null) { IoSupplier iosupplier1; -@@ -118,6 +_,7 @@ +@@ -116,6 +_,7 @@ } list.add(new Resource(packresources, iosupplier, iosupplier1)); diff --git a/patches/minecraft/net/minecraft/server/packs/resources/SimpleJsonResourceReloadListener.java.patch b/patches/minecraft/net/minecraft/server/packs/resources/SimpleJsonResourceReloadListener.java.patch index 3ea94afaf4..94801e6047 100644 --- a/patches/minecraft/net/minecraft/server/packs/resources/SimpleJsonResourceReloadListener.java.patch +++ b/patches/minecraft/net/minecraft/server/packs/resources/SimpleJsonResourceReloadListener.java.patch @@ -12,19 +12,19 @@ this(JsonOps.INSTANCE, p_370137_, p_375758_); } @@ -65,7 +_,15 @@ - ResourceLocation resourcelocation1 = p_377980_.fileToId(resourcelocation); + Identifier identifier1 = p_377980_.fileToId(identifier); try (Reader reader = entry.getValue().openAsReader()) { - p_376362_.parse(p_378080_, StrictJsonParser.parse(reader)).ifSuccess(p_370131_ -> { + var json = StrictJsonParser.parse(reader); + json = net.minecraftforge.common.ForgeHooks.readConditional(p_378080_, json); + if (json == null) { -+ LOGGER.debug("Skipping loading {} as its conditions were not met", resourcelocation); ++ LOGGER.debug("Skipping loading {} as its conditions were not met", identifier); + continue; + } + p_376362_.parse(p_378080_, json).ifSuccess(p_370131_ -> { -+ p_370131_ = net.minecraftforge.common.ForgeHooks.onJsonDataParsed(p_376362_, resourcelocation1, p_370131_); ++ p_370131_ = net.minecraftforge.common.ForgeHooks.onJsonDataParsed(p_376362_, identifier1, p_370131_); + if (p_370131_ == null) return; - if (p_377922_.putIfAbsent(resourcelocation1, (T)p_370131_) != null) { - throw new IllegalStateException("Duplicate data file ignored with ID " + resourcelocation1); + if (p_377922_.putIfAbsent(identifier1, (T)p_370131_) != null) { + throw new IllegalStateException("Duplicate data file ignored with ID " + identifier1); } diff --git a/patches/minecraft/net/minecraft/server/players/PlayerList.java.patch b/patches/minecraft/net/minecraft/server/players/PlayerList.java.patch index 1d1138ecb9..d2758334cc 100644 --- a/patches/minecraft/net/minecraft/server/players/PlayerList.java.patch +++ b/patches/minecraft/net/minecraft/server/players/PlayerList.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/players/PlayerList.java +++ b/net/minecraft/server/players/PlayerList.java -@@ -123,6 +_,7 @@ +@@ -127,6 +_,7 @@ private int simulationDistance; private boolean allowCommandsForAllPlayers; private int sendAllPlayerInfoIn; @@ -8,7 +8,7 @@ public PlayerList(MinecraftServer p_203842_, LayeredRegistryAccess p_251844_, PlayerDataStorage p_203844_, NotificationService p_425184_) { this.server = p_203842_; -@@ -180,6 +_,7 @@ +@@ -185,6 +_,7 @@ servergamepacketlistenerimpl.send(new ClientboundPlayerAbilitiesPacket(p_11263_.getAbilities())); servergamepacketlistenerimpl.send(new ClientboundSetHeldSlotPacket(p_11263_.getInventory().getSelectedSlot())); RecipeManager recipemanager = this.server.getRecipeManager(); @@ -16,15 +16,15 @@ servergamepacketlistenerimpl.send(new ClientboundUpdateRecipesPacket(recipemanager.getSynchronizedItemProperties(), recipemanager.getSynchronizedStonecutterRecipes())); this.sendPlayerPermissionLevel(p_11263_); p_11263_.getStats().markAllDirty(); -@@ -210,6 +_,7 @@ - this.sendActivePlayerEffects(p_11263_); +@@ -216,6 +_,7 @@ p_11263_.initInventoryMenu(); this.server.notificationManager().playerJoined(p_11263_); + servergamepacketlistenerimpl.resumeFlushing(); + net.minecraftforge.event.ForgeEventFactory.firePlayerLoggedIn(p_11263_); } protected void updateEntireScoreboard(ServerScoreboard p_11274_, ServerPlayer p_11275_) { -@@ -279,6 +_,7 @@ +@@ -285,6 +_,7 @@ } protected void save(ServerPlayer p_11277_) { @@ -32,7 +32,7 @@ this.playerIo.save(p_11277_); ServerStatsCounter serverstatscounter = this.stats.get(p_11277_.getUUID()); if (serverstatscounter != null) { -@@ -292,6 +_,7 @@ +@@ -298,6 +_,7 @@ } public void remove(ServerPlayer p_11287_) { @@ -40,7 +40,7 @@ ServerLevel serverlevel = p_11287_.level(); p_11287_.awardStat(Stats.LEAVE_GAME); this.save(p_11287_); -@@ -413,6 +_,7 @@ +@@ -418,6 +_,7 @@ this.playersByUUID.put(serverplayer.getUUID(), serverplayer); serverplayer.initInventoryMenu(); serverplayer.setHealth(serverplayer.getHealth()); @@ -48,37 +48,23 @@ ServerPlayer.RespawnConfig serverplayer$respawnconfig = serverplayer.getRespawnConfig(); if (!p_11238_ && serverplayer$respawnconfig != null) { LevelData.RespawnData leveldata$respawndata = serverplayer$respawnconfig.respawnData(); -@@ -526,6 +_,7 @@ +@@ -531,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; + public void op(NameAndId p_425211_, Optional p_427477_, Optional p_426308_) { ++ if (net.minecraftforge.event.ForgeEventFactory.onPermissionChanged(p_425211_, p_427477_.orElse(this.server.operatorUserPermissions()), this)) return; this.ops - .add(new ServerOpListEntry(p_425211_, p_427477_.orElse(this.server.operatorUserPermissionLevel()), p_426308_.orElse(this.ops.canBypassPlayerLimit(p_425211_)))); + .add(new ServerOpListEntry(p_425211_, p_427477_.orElse(this.server.operatorUserPermissions()), p_426308_.orElse(this.ops.canBypassPlayerLimit(p_425211_)))); ServerPlayer serverplayer = this.getPlayer(p_425211_.id()); -@@ -535,6 +_,7 @@ +@@ -540,6 +_,7 @@ } public void deop(NameAndId p_428113_) { -+ if (net.minecraftforge.event.ForgeEventFactory.onPermissionChanged(p_428113_, 0, this)) return; ++ if (net.minecraftforge.event.ForgeEventFactory.onPermissionChanged(p_428113_, null, 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, gameprofile.name() + ".json"); -- Path path = file3.toPath(); -- if (FileUtil.isPathNormalized(path) && FileUtil.isPathPortable(path) && path.startsWith(file1.getPath()) && file3.isFile()) { -- file3.renameTo(file2); -- } -- } - - serverstatscounter = new ServerStatsCounter(this.server, file2); - this.stats.put(uuid, serverstatscounter); -@@ -797,7 +_,7 @@ +@@ -804,7 +_,7 @@ } public List getPlayers() { @@ -86,8 +72,8 @@ + return this.playersView; //Unmodifiable view, we don't want people removing things without us knowing. } - @Nullable -@@ -825,6 +_,7 @@ + public @Nullable ServerPlayer getPlayer(UUID p_11260_) { +@@ -830,6 +_,7 @@ playeradvancements.reload(this.server.getAdvancements()); } @@ -95,7 +81,7 @@ this.broadcastAll(new ClientboundUpdateTagsPacket(TagNetworkSerialization.serializeTagsToNetwork(this.registries))); RecipeManager recipemanager = this.server.getRecipeManager(); ClientboundUpdateRecipesPacket clientboundupdaterecipespacket = new ClientboundUpdateRecipesPacket(recipemanager.getSynchronizedItemProperties(), recipemanager.getSynchronizedStonecutterRecipes()); -@@ -837,5 +_,9 @@ +@@ -842,5 +_,9 @@ public boolean isAllowCommandsForAllPlayers() { return this.allowCommandsForAllPlayers; diff --git a/patches/minecraft/net/minecraft/server/rcon/RconConsoleSource.java.patch b/patches/minecraft/net/minecraft/server/rcon/RconConsoleSource.java.patch index d07e031488..5ab640d010 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 -@@ -35,7 +_,7 @@ +@@ -44,7 +_,7 @@ @Override public void sendSystemMessage(Component p_215653_) { diff --git a/patches/minecraft/net/minecraft/tags/BannerPatternTags.java.patch b/patches/minecraft/net/minecraft/tags/BannerPatternTags.java.patch index 3e9f00ad8c..4ad4faaf66 100644 --- a/patches/minecraft/net/minecraft/tags/BannerPatternTags.java.patch +++ b/patches/minecraft/net/minecraft/tags/BannerPatternTags.java.patch @@ -2,14 +2,14 @@ +++ b/net/minecraft/tags/BannerPatternTags.java @@ -23,4 +_,12 @@ private static TagKey create(String p_215798_) { - return TagKey.create(Registries.BANNER_PATTERN, ResourceLocation.withDefaultNamespace(p_215798_)); + return TagKey.create(Registries.BANNER_PATTERN, Identifier.withDefaultNamespace(p_215798_)); } + + public static TagKey create(String namepsace, String path) { -+ return create(ResourceLocation.fromNamespaceAndPath(namepsace, path)); ++ return create(Identifier.fromNamespaceAndPath(namepsace, path)); + } + -+ public static TagKey create(ResourceLocation name) { ++ public static TagKey create(Identifier name) { + return TagKey.create(Registries.BANNER_PATTERN, name); + } } diff --git a/patches/minecraft/net/minecraft/tags/BiomeTags.java.patch b/patches/minecraft/net/minecraft/tags/BiomeTags.java.patch index 90c99016b4..c94bcb4ef6 100644 --- a/patches/minecraft/net/minecraft/tags/BiomeTags.java.patch +++ b/patches/minecraft/net/minecraft/tags/BiomeTags.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/tags/BiomeTags.java +++ b/net/minecraft/tags/BiomeTags.java -@@ -84,4 +_,12 @@ +@@ -80,4 +_,12 @@ private static TagKey create(String p_207631_) { - return TagKey.create(Registries.BIOME, ResourceLocation.withDefaultNamespace(p_207631_)); + return TagKey.create(Registries.BIOME, Identifier.withDefaultNamespace(p_207631_)); } + + public static TagKey create(String namepsace, String path) { -+ return create(ResourceLocation.fromNamespaceAndPath(namepsace, path)); ++ return create(Identifier.fromNamespaceAndPath(namepsace, path)); + } + -+ public static TagKey create(ResourceLocation name) { ++ public static TagKey create(Identifier name) { + return TagKey.create(Registries.BIOME, name); + } } diff --git a/patches/minecraft/net/minecraft/tags/BlockTags.java.patch b/patches/minecraft/net/minecraft/tags/BlockTags.java.patch index 3462e28fe6..d269b6c8b5 100644 --- a/patches/minecraft/net/minecraft/tags/BlockTags.java.patch +++ b/patches/minecraft/net/minecraft/tags/BlockTags.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/tags/BlockTags.java +++ b/net/minecraft/tags/BlockTags.java -@@ -215,4 +_,12 @@ +@@ -216,4 +_,12 @@ private static TagKey create(String p_203847_) { - return TagKey.create(Registries.BLOCK, ResourceLocation.withDefaultNamespace(p_203847_)); + return TagKey.create(Registries.BLOCK, Identifier.withDefaultNamespace(p_203847_)); } + + public static TagKey create(String namepsace, String path) { -+ return create(ResourceLocation.fromNamespaceAndPath(namepsace, path)); ++ return create(Identifier.fromNamespaceAndPath(namepsace, path)); + } + -+ public static TagKey create(ResourceLocation name) { ++ public static TagKey create(Identifier name) { + return TagKey.create(Registries.BLOCK, name); + } } diff --git a/patches/minecraft/net/minecraft/tags/DamageTypeTags.java.patch b/patches/minecraft/net/minecraft/tags/DamageTypeTags.java.patch index 0183498935..027b3570e0 100644 --- a/patches/minecraft/net/minecraft/tags/DamageTypeTags.java.patch +++ b/patches/minecraft/net/minecraft/tags/DamageTypeTags.java.patch @@ -2,14 +2,14 @@ +++ b/net/minecraft/tags/DamageTypeTags.java @@ -43,4 +_,12 @@ private static TagKey create(String p_270635_) { - return TagKey.create(Registries.DAMAGE_TYPE, ResourceLocation.withDefaultNamespace(p_270635_)); + return TagKey.create(Registries.DAMAGE_TYPE, Identifier.withDefaultNamespace(p_270635_)); } + + public static TagKey create(String namepsace, String path) { -+ return create(ResourceLocation.fromNamespaceAndPath(namepsace, path)); ++ return create(Identifier.fromNamespaceAndPath(namepsace, path)); + } + -+ public static TagKey create(ResourceLocation name) { ++ public static TagKey create(Identifier name) { + return TagKey.create(Registries.DAMAGE_TYPE, name); + } } diff --git a/patches/minecraft/net/minecraft/tags/EnchantmentTags.java.patch b/patches/minecraft/net/minecraft/tags/EnchantmentTags.java.patch index 6aa037ec76..fa03a20896 100644 --- a/patches/minecraft/net/minecraft/tags/EnchantmentTags.java.patch +++ b/patches/minecraft/net/minecraft/tags/EnchantmentTags.java.patch @@ -2,14 +2,14 @@ +++ b/net/minecraft/tags/EnchantmentTags.java @@ -45,4 +_,12 @@ private static TagKey create(String p_334094_) { - return TagKey.create(Registries.ENCHANTMENT, ResourceLocation.withDefaultNamespace(p_334094_)); + return TagKey.create(Registries.ENCHANTMENT, Identifier.withDefaultNamespace(p_334094_)); } + + public static TagKey create(String namepsace, String path) { -+ return create(ResourceLocation.fromNamespaceAndPath(namepsace, path)); ++ return create(Identifier.fromNamespaceAndPath(namepsace, path)); + } + -+ public static TagKey create(ResourceLocation name) { ++ public static TagKey create(Identifier name) { + return TagKey.create(Registries.ENCHANTMENT, name); + } } diff --git a/patches/minecraft/net/minecraft/tags/EntityTypeTags.java.patch b/patches/minecraft/net/minecraft/tags/EntityTypeTags.java.patch index 117320cb70..f1fa21f7e2 100644 --- a/patches/minecraft/net/minecraft/tags/EntityTypeTags.java.patch +++ b/patches/minecraft/net/minecraft/tags/EntityTypeTags.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/tags/EntityTypeTags.java +++ b/net/minecraft/tags/EntityTypeTags.java -@@ -51,4 +_,12 @@ +@@ -55,4 +_,12 @@ private static TagKey> create(String p_203849_) { - return TagKey.create(Registries.ENTITY_TYPE, ResourceLocation.withDefaultNamespace(p_203849_)); + return TagKey.create(Registries.ENTITY_TYPE, Identifier.withDefaultNamespace(p_203849_)); } + + public static TagKey> create(String namepsace, String path) { -+ return create(ResourceLocation.fromNamespaceAndPath(namepsace, path)); ++ return create(Identifier.fromNamespaceAndPath(namepsace, path)); + } + -+ public static TagKey> create(ResourceLocation name) { ++ public static TagKey> create(Identifier name) { + return TagKey.create(Registries.ENTITY_TYPE, name); + } } diff --git a/patches/minecraft/net/minecraft/tags/FlatLevelGeneratorPresetTags.java.patch b/patches/minecraft/net/minecraft/tags/FlatLevelGeneratorPresetTags.java.patch index aee534f9ac..059dd8d140 100644 --- a/patches/minecraft/net/minecraft/tags/FlatLevelGeneratorPresetTags.java.patch +++ b/patches/minecraft/net/minecraft/tags/FlatLevelGeneratorPresetTags.java.patch @@ -2,14 +2,14 @@ +++ b/net/minecraft/tags/FlatLevelGeneratorPresetTags.java @@ -13,4 +_,12 @@ private static TagKey create(String p_215852_) { - return TagKey.create(Registries.FLAT_LEVEL_GENERATOR_PRESET, ResourceLocation.withDefaultNamespace(p_215852_)); + return TagKey.create(Registries.FLAT_LEVEL_GENERATOR_PRESET, Identifier.withDefaultNamespace(p_215852_)); } + + public static TagKey create(String namepsace, String path) { -+ return create(ResourceLocation.fromNamespaceAndPath(namepsace, path)); ++ return create(Identifier.fromNamespaceAndPath(namepsace, path)); + } + -+ public static TagKey create(ResourceLocation name) { ++ public static TagKey create(Identifier name) { + return TagKey.create(Registries.FLAT_LEVEL_GENERATOR_PRESET, name); + } } diff --git a/patches/minecraft/net/minecraft/tags/FluidTags.java.patch b/patches/minecraft/net/minecraft/tags/FluidTags.java.patch index 88e866b86c..4cae59aac5 100644 --- a/patches/minecraft/net/minecraft/tags/FluidTags.java.patch +++ b/patches/minecraft/net/minecraft/tags/FluidTags.java.patch @@ -2,14 +2,14 @@ +++ b/net/minecraft/tags/FluidTags.java @@ -14,4 +_,12 @@ private static TagKey create(String p_203851_) { - return TagKey.create(Registries.FLUID, ResourceLocation.withDefaultNamespace(p_203851_)); + return TagKey.create(Registries.FLUID, Identifier.withDefaultNamespace(p_203851_)); } + + public static TagKey create(String namepsace, String path) { -+ return create(ResourceLocation.fromNamespaceAndPath(namepsace, path)); ++ return create(Identifier.fromNamespaceAndPath(namepsace, path)); + } + -+ public static TagKey create(ResourceLocation name) { ++ public static TagKey create(Identifier name) { + return TagKey.create(Registries.FLUID, name); + } } diff --git a/patches/minecraft/net/minecraft/tags/GameEventTags.java.patch b/patches/minecraft/net/minecraft/tags/GameEventTags.java.patch index c7d3a079f5..9650379723 100644 --- a/patches/minecraft/net/minecraft/tags/GameEventTags.java.patch +++ b/patches/minecraft/net/minecraft/tags/GameEventTags.java.patch @@ -2,14 +2,14 @@ +++ b/net/minecraft/tags/GameEventTags.java @@ -14,4 +_,12 @@ private static TagKey create(String p_203853_) { - return TagKey.create(Registries.GAME_EVENT, ResourceLocation.withDefaultNamespace(p_203853_)); + return TagKey.create(Registries.GAME_EVENT, Identifier.withDefaultNamespace(p_203853_)); } + + public static TagKey create(String namepsace, String path) { -+ return create(ResourceLocation.fromNamespaceAndPath(namepsace, path)); ++ return create(Identifier.fromNamespaceAndPath(namepsace, path)); + } + -+ public static TagKey create(ResourceLocation name) { ++ public static TagKey create(Identifier name) { + return TagKey.create(Registries.GAME_EVENT, name); + } } diff --git a/patches/minecraft/net/minecraft/tags/InstrumentTags.java.patch b/patches/minecraft/net/minecraft/tags/InstrumentTags.java.patch index c9c5f4fdda..809d68b6b8 100644 --- a/patches/minecraft/net/minecraft/tags/InstrumentTags.java.patch +++ b/patches/minecraft/net/minecraft/tags/InstrumentTags.java.patch @@ -2,14 +2,14 @@ +++ b/net/minecraft/tags/InstrumentTags.java @@ -12,4 +_,12 @@ private static TagKey create(String p_215861_) { - return TagKey.create(Registries.INSTRUMENT, ResourceLocation.withDefaultNamespace(p_215861_)); + return TagKey.create(Registries.INSTRUMENT, Identifier.withDefaultNamespace(p_215861_)); } + + public static TagKey create(String namepsace, String path) { -+ return create(ResourceLocation.fromNamespaceAndPath(namepsace, path)); ++ return create(Identifier.fromNamespaceAndPath(namepsace, path)); + } + -+ public static TagKey create(ResourceLocation name) { ++ public static TagKey create(Identifier name) { + return TagKey.create(Registries.INSTRUMENT, name); + } } diff --git a/patches/minecraft/net/minecraft/tags/ItemTags.java.patch b/patches/minecraft/net/minecraft/tags/ItemTags.java.patch index 5c19de52bd..acb7871b5e 100644 --- a/patches/minecraft/net/minecraft/tags/ItemTags.java.patch +++ b/patches/minecraft/net/minecraft/tags/ItemTags.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/tags/ItemTags.java +++ b/net/minecraft/tags/ItemTags.java -@@ -202,4 +_,12 @@ +@@ -210,4 +_,12 @@ private static TagKey bind(String p_203855_) { - return TagKey.create(Registries.ITEM, ResourceLocation.withDefaultNamespace(p_203855_)); + return TagKey.create(Registries.ITEM, Identifier.withDefaultNamespace(p_203855_)); } + + public static TagKey create(String namepsace, String path) { -+ return create(ResourceLocation.fromNamespaceAndPath(namepsace, path)); ++ return create(Identifier.fromNamespaceAndPath(namepsace, path)); + } + -+ public static TagKey create(ResourceLocation name) { ++ public static TagKey create(Identifier name) { + return TagKey.create(Registries.ITEM, name); + } } diff --git a/patches/minecraft/net/minecraft/tags/PaintingVariantTags.java.patch b/patches/minecraft/net/minecraft/tags/PaintingVariantTags.java.patch index 543f045749..4074eb74c0 100644 --- a/patches/minecraft/net/minecraft/tags/PaintingVariantTags.java.patch +++ b/patches/minecraft/net/minecraft/tags/PaintingVariantTags.java.patch @@ -2,14 +2,14 @@ +++ b/net/minecraft/tags/PaintingVariantTags.java @@ -13,4 +_,12 @@ private static TagKey create(String p_215874_) { - return TagKey.create(Registries.PAINTING_VARIANT, ResourceLocation.withDefaultNamespace(p_215874_)); + return TagKey.create(Registries.PAINTING_VARIANT, Identifier.withDefaultNamespace(p_215874_)); } + + public static TagKey create(String namepsace, String path) { -+ return create(ResourceLocation.fromNamespaceAndPath(namepsace, path)); ++ return create(Identifier.fromNamespaceAndPath(namepsace, path)); + } + -+ public static TagKey create(ResourceLocation name) { ++ public static TagKey create(Identifier name) { + return TagKey.create(Registries.PAINTING_VARIANT, name); + } } diff --git a/patches/minecraft/net/minecraft/tags/PoiTypeTags.java.patch b/patches/minecraft/net/minecraft/tags/PoiTypeTags.java.patch index f1caf02dde..649fc995b4 100644 --- a/patches/minecraft/net/minecraft/tags/PoiTypeTags.java.patch +++ b/patches/minecraft/net/minecraft/tags/PoiTypeTags.java.patch @@ -2,14 +2,14 @@ +++ b/net/minecraft/tags/PoiTypeTags.java @@ -15,4 +_,12 @@ private static TagKey create(String p_215881_) { - return TagKey.create(Registries.POINT_OF_INTEREST_TYPE, ResourceLocation.withDefaultNamespace(p_215881_)); + return TagKey.create(Registries.POINT_OF_INTEREST_TYPE, Identifier.withDefaultNamespace(p_215881_)); } + + public static TagKey create(String namepsace, String path) { -+ return create(ResourceLocation.fromNamespaceAndPath(namepsace, path)); ++ return create(Identifier.fromNamespaceAndPath(namepsace, path)); + } + -+ public static TagKey create(ResourceLocation name) { ++ public static TagKey create(Identifier name) { + return TagKey.create(Registries.POINT_OF_INTEREST_TYPE, name); + } } diff --git a/patches/minecraft/net/minecraft/tags/StructureTags.java.patch b/patches/minecraft/net/minecraft/tags/StructureTags.java.patch index ef3b03dca2..eb0fcad6c1 100644 --- a/patches/minecraft/net/minecraft/tags/StructureTags.java.patch +++ b/patches/minecraft/net/minecraft/tags/StructureTags.java.patch @@ -2,14 +2,14 @@ +++ b/net/minecraft/tags/StructureTags.java @@ -29,4 +_,12 @@ private static TagKey create(String p_215896_) { - return TagKey.create(Registries.STRUCTURE, ResourceLocation.withDefaultNamespace(p_215896_)); + return TagKey.create(Registries.STRUCTURE, Identifier.withDefaultNamespace(p_215896_)); } + + public static TagKey create(String namepsace, String path) { -+ return create(ResourceLocation.fromNamespaceAndPath(namepsace, path)); ++ return create(Identifier.fromNamespaceAndPath(namepsace, path)); + } + -+ public static TagKey create(ResourceLocation name) { ++ public static TagKey create(Identifier name) { + return TagKey.create(Registries.STRUCTURE, name); + } } diff --git a/patches/minecraft/net/minecraft/tags/TagBuilder.java.patch b/patches/minecraft/net/minecraft/tags/TagBuilder.java.patch index ac138195a3..5868bcf216 100644 --- a/patches/minecraft/net/minecraft/tags/TagBuilder.java.patch +++ b/patches/minecraft/net/minecraft/tags/TagBuilder.java.patch @@ -2,44 +2,17 @@ +++ b/net/minecraft/tags/TagBuilder.java @@ -4,7 +_,7 @@ import java.util.List; - import net.minecraft.resources.ResourceLocation; + import net.minecraft.resources.Identifier; -public class TagBuilder { +public class TagBuilder implements net.minecraftforge.common.extensions.IForgeRawTagBuilder { private final List entries = new ArrayList<>(); public static TagBuilder create() { -@@ -15,24 +_,48 @@ - return List.copyOf(this.entries); - } +@@ -34,5 +_,30 @@ -- public TagBuilder add(TagEntry p_215903_) { -- this.entries.add(p_215903_); -- return this; -- } -- - public TagBuilder addElement(ResourceLocation p_215901_) { -- return this.add(TagEntry.element(p_215901_)); -+ this.entries.add(TagEntry.element(p_215901_)); -+ return this; - } - - public TagBuilder addOptionalElement(ResourceLocation p_215906_) { -- return this.add(TagEntry.optionalElement(p_215906_)); -+ this.entries.add(TagEntry.optionalElement(p_215906_)); -+ return this; - } - - public TagBuilder addTag(ResourceLocation p_215908_) { -- return this.add(TagEntry.tag(p_215908_)); -+ this.entries.add(TagEntry.tag(p_215908_)); -+ return this; - } - - public TagBuilder addOptionalTag(ResourceLocation p_215910_) { -- return this.add(TagEntry.optionalTag(p_215910_)); -+ this.entries.add(TagEntry.optionalTag(p_215910_)); -+ return this; + public TagBuilder addOptionalTag(Identifier p_458048_) { + return this.add(TagEntry.optionalTag(p_458048_)); + } + + /** Forge: Used for datagen */ diff --git a/patches/minecraft/net/minecraft/tags/TagEntry.java.patch b/patches/minecraft/net/minecraft/tags/TagEntry.java.patch index c0351dbc9b..6ef8504735 100644 --- a/patches/minecraft/net/minecraft/tags/TagEntry.java.patch +++ b/patches/minecraft/net/minecraft/tags/TagEntry.java.patch @@ -4,7 +4,7 @@ return stringbuilder.toString(); } -+ public ResourceLocation getId() { ++ public Identifier getId() { + return id; + } + @@ -17,5 +17,5 @@ + } + public interface Lookup { - @Nullable - T element(ResourceLocation p_215956_, boolean p_362986_); + @Nullable T element(Identifier p_459727_, boolean p_362986_); + diff --git a/patches/minecraft/net/minecraft/tags/TagKey.java.patch b/patches/minecraft/net/minecraft/tags/TagKey.java.patch index 555214864c..2a7984115b 100644 --- a/patches/minecraft/net/minecraft/tags/TagKey.java.patch +++ b/patches/minecraft/net/minecraft/tags/TagKey.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/tags/TagKey.java +++ b/net/minecraft/tags/TagKey.java @@ -42,6 +_,10 @@ - return (TagKey)VALUES.intern(new TagKey<>(p_203883_, p_203884_)); + return (TagKey)VALUES.intern(new TagKey<>(p_203883_, p_451670_)); } + public static TagKey create(ResourceKey> registry, String namespace, String path) { -+ return create(registry, ResourceLocation.fromNamespaceAndPath(namespace, path)); ++ return create(registry, Identifier.fromNamespaceAndPath(namespace, path)); + } + public boolean isFor(ResourceKey> p_207646_) { diff --git a/patches/minecraft/net/minecraft/tags/TagLoader.java.patch b/patches/minecraft/net/minecraft/tags/TagLoader.java.patch index d43786da47..6aeaa0e28b 100644 --- a/patches/minecraft/net/minecraft/tags/TagLoader.java.patch +++ b/patches/minecraft/net/minecraft/tags/TagLoader.java.patch @@ -6,7 +6,7 @@ tagfile.entries().forEach(p_215997_ -> list.add(new TagLoader.EntryWithSource(p_215997_, s))); + tagfile.remove().forEach(e -> list.add(new TagLoader.EntryWithSource(e, s, true))); } catch (Exception exception) { - LOGGER.error("Couldn't read tag list {} from {} in data pack {}", resourcelocation1, resourcelocation, resource.sourcePackId(), exception); + LOGGER.error("Couldn't read tag list {} from {} in data pack {}", identifier1, identifier, resource.sourcePackId(), exception); } @@ -74,16 +_,17 @@ } @@ -28,17 +28,17 @@ + return list.isEmpty() ? Either.right(List.copyOf(builder)) : Either.left(list); } - public Map> build(Map> p_203899_) { -@@ -111,7 +_,7 @@ + public Map> build(Map> p_203899_) { +@@ -109,7 +_,7 @@ p_358772_ -> LOGGER.error( "Couldn't load tag {} as it is missing following references: {}", - p_358780_, + p_450305_, - p_358772_.stream().map(Objects::toString).collect(Collectors.joining(", ")) + p_358772_.stream().map(Objects::toString).collect(Collectors.joining(", \n\t")) ) ) - .ifRight(p_369415_ -> map.put(p_358780_, (List)p_369415_)) -@@ -188,7 +_,11 @@ + .ifRight(p_369415_ -> map.put(p_450305_, (List)p_369415_)) +@@ -185,7 +_,11 @@ } } diff --git a/patches/minecraft/net/minecraft/tags/WorldPresetTags.java.patch b/patches/minecraft/net/minecraft/tags/WorldPresetTags.java.patch index e0242ffec7..891560fe92 100644 --- a/patches/minecraft/net/minecraft/tags/WorldPresetTags.java.patch +++ b/patches/minecraft/net/minecraft/tags/WorldPresetTags.java.patch @@ -2,14 +2,14 @@ +++ b/net/minecraft/tags/WorldPresetTags.java @@ -14,4 +_,12 @@ private static TagKey create(String p_216058_) { - return TagKey.create(Registries.WORLD_PRESET, ResourceLocation.withDefaultNamespace(p_216058_)); + return TagKey.create(Registries.WORLD_PRESET, Identifier.withDefaultNamespace(p_216058_)); } + + public static TagKey create(String namepsace, String path) { -+ return create(ResourceLocation.fromNamespaceAndPath(namepsace, path)); ++ return create(Identifier.fromNamespaceAndPath(namepsace, path)); + } + -+ public static TagKey create(ResourceLocation name) { ++ public static TagKey create(Identifier name) { + return TagKey.create(Registries.WORLD_PRESET, name); + } } diff --git a/patches/minecraft/net/minecraft/Util.java.patch b/patches/minecraft/net/minecraft/util/Util.java.patch similarity index 50% rename from patches/minecraft/net/minecraft/Util.java.patch rename to patches/minecraft/net/minecraft/util/Util.java.patch index deec93a84a..37d8763388 100644 --- a/patches/minecraft/net/minecraft/Util.java.patch +++ b/patches/minecraft/net/minecraft/util/Util.java.patch @@ -1,11 +1,11 @@ ---- a/net/minecraft/Util.java -+++ b/net/minecraft/Util.java -@@ -266,7 +_,7 @@ +--- a/net/minecraft/util/Util.java ++++ b/net/minecraft/util/Util.java +@@ -268,7 +_,7 @@ .getSchema(DataFixUtils.makeKey(SharedConstants.getCurrentVersion().dataVersion().version())) - .getChoiceType(p_137552_, p_137553_); + .getChoiceType(p_457223_, p_460132_); } catch (IllegalArgumentException illegalargumentexception) { -- LOGGER.error("No data fixer registered for {}", p_137553_); -+ LOGGER.debug("No data fixer registered for {}", p_137553_); +- LOGGER.error("No data fixer registered for {}", p_460132_); ++ LOGGER.debug("No data fixer registered for {}", p_460132_); if (SharedConstants.IS_RUNNING_IN_IDE) { throw illegalargumentexception; } diff --git a/patches/minecraft/net/minecraft/util/context/ContextMap.java.patch b/patches/minecraft/net/minecraft/util/context/ContextMap.java.patch index 9230f0a2f4..70f74240d8 100644 --- a/patches/minecraft/net/minecraft/util/context/ContextMap.java.patch +++ b/patches/minecraft/net/minecraft/util/context/ContextMap.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/util/context/ContextMap.java +++ b/net/minecraft/util/context/ContextMap.java -@@ -39,6 +_,10 @@ +@@ -37,6 +_,10 @@ return (T)this.params.getOrDefault(p_368195_, p_368521_); } @@ -11,7 +11,7 @@ public static class Builder { private final Map, Object> params = new IdentityHashMap<>(); -@@ -83,6 +_,10 @@ +@@ -80,6 +_,10 @@ return new ContextMap(this.params); } } diff --git a/patches/minecraft/net/minecraft/util/datafix/fixes/StructuresBecomeConfiguredFix.java.patch b/patches/minecraft/net/minecraft/util/datafix/fixes/StructuresBecomeConfiguredFix.java.patch index 046f1724f1..7db9d9934c 100644 --- a/patches/minecraft/net/minecraft/util/datafix/fixes/StructuresBecomeConfiguredFix.java.patch +++ b/patches/minecraft/net/minecraft/util/datafix/fixes/StructuresBecomeConfiguredFix.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/util/datafix/fixes/StructuresBecomeConfiguredFix.java +++ b/net/minecraft/util/datafix/fixes/StructuresBecomeConfiguredFix.java -@@ -180,7 +_,17 @@ +@@ -179,7 +_,17 @@ String s = p_207725_.asString("UNKNOWN").toLowerCase(Locale.ROOT); StructuresBecomeConfiguredFix.Conversion structuresbecomeconfiguredfix$conversion = CONVERSION_MAP.get(s); if (structuresbecomeconfiguredfix$conversion == null) { diff --git a/patches/minecraft/net/minecraft/util/random/WeightedList.java.patch b/patches/minecraft/net/minecraft/util/random/WeightedList.java.patch index 784098f73a..37b93c017d 100644 --- a/patches/minecraft/net/minecraft/util/random/WeightedList.java.patch +++ b/patches/minecraft/net/minecraft/util/random/WeightedList.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/util/random/WeightedList.java +++ b/net/minecraft/util/random/WeightedList.java @@ -16,7 +_,7 @@ - import net.minecraft.util.ExtraCodecs; import net.minecraft.util.RandomSource; + import org.jspecify.annotations.Nullable; -public final class WeightedList { +public final class WeightedList implements net.minecraftforge.common.extensions.IForgeWeightedList { private static final int FLAT_THRESHOLD = 64; private final int totalWeight; private final List> items; -@@ -133,7 +_,7 @@ +@@ -132,7 +_,7 @@ return 31 * i + this.items.hashCode(); } diff --git a/patches/minecraft/net/minecraft/world/effect/MobEffect.java.patch b/patches/minecraft/net/minecraft/world/effect/MobEffect.java.patch index 7958de1284..c1d2031c4d 100644 --- a/patches/minecraft/net/minecraft/world/effect/MobEffect.java.patch +++ b/patches/minecraft/net/minecraft/world/effect/MobEffect.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/effect/MobEffect.java +++ b/net/minecraft/world/effect/MobEffect.java @@ -36,7 +_,8 @@ - import net.minecraft.world.flag.FeatureFlagSet; import net.minecraft.world.flag.FeatureFlags; + import org.jspecify.annotations.Nullable; -public class MobEffect implements FeatureElement { + @@ -10,7 +10,7 @@ public static final Codec> CODEC = BuiltInRegistries.MOB_EFFECT.holderByNameCodec(); public static final StreamCodec> STREAM_CODEC = ByteBufCodecs.holderRegistry(Registries.MOB_EFFECT); private static final int AMBIENT_ALPHA = Mth.floor(38.25F); -@@ -59,12 +_,14 @@ +@@ -58,12 +_,14 @@ int i = p_358853_.isAmbient() ? AMBIENT_ALPHA : 255; return ColorParticleOption.create(ParticleTypes.ENTITY_EFFECT, ARGB.color(i, p_19452_)); }; @@ -25,7 +25,7 @@ } public int getBlendInDurationTicks() { -@@ -203,4 +_,28 @@ +@@ -202,4 +_,28 @@ return new AttributeModifier(this.id, this.amount * (p_332230_ + 1), this.operation); } } diff --git a/patches/minecraft/net/minecraft/world/entity/Entity.java.patch b/patches/minecraft/net/minecraft/world/entity/Entity.java.patch index fb6dc2d5bc..ab003568f7 100644 --- a/patches/minecraft/net/minecraft/world/entity/Entity.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/Entity.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java -@@ -150,7 +_,7 @@ - import org.jetbrains.annotations.Contract; +@@ -153,7 +_,7 @@ + import org.jspecify.annotations.Nullable; import org.slf4j.Logger; --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 abstract class Entity implements SyncedDataHolder, DebugValueSource, Nameable, ItemOwner, SlotProvider, EntityAccess, ScoreHolder, DataComponentGetter { ++public abstract class Entity extends net.minecraftforge.common.capabilities.CapabilityProvider.Entities implements SyncedDataHolder, DebugValueSource, Nameable, ItemOwner, SlotProvider, 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"; -@@ -188,6 +_,7 @@ +@@ -191,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; @@ -17,7 +17,7 @@ private final EntityType type; private boolean requiresPrecisePosition; private int id = ENTITY_COUNTER.incrementAndGet(); -@@ -232,8 +_,10 @@ +@@ -233,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; -@@ -285,6 +_,7 @@ +@@ -286,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(); -@@ -304,6 +_,8 @@ +@@ -305,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_) { -@@ -402,6 +_,7 @@ +@@ -403,6 +_,7 @@ public void remove(Entity.RemovalReason p_146834_) { this.setRemoved(p_146834_); @@ -53,7 +53,7 @@ } public void onClientRemoval() { -@@ -516,7 +_,7 @@ +@@ -522,7 +_,7 @@ } if (this.isInLava()) { @@ -62,7 +62,7 @@ } this.checkBelowWorld(); -@@ -958,9 +_,7 @@ +@@ -977,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; } -@@ -1304,19 +_,19 @@ +@@ -1323,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()); } -@@ -1449,6 +_,10 @@ +@@ -1468,6 +_,10 @@ return this.wasTouchingWater; } @@ -110,7 +110,7 @@ boolean isInRain() { BlockPos blockpos = this.blockPosition(); return this.level().isRainingAt(blockpos) -@@ -1488,24 +_,32 @@ +@@ -1506,24 +_,32 @@ public void updateSwimming() { if (this.isSwimming()) { @@ -126,7 +126,7 @@ this.fluidHeight.clear(); + this.forgeFluidTypeHeight.clear(); this.updateInWaterStateAndDoWaterCurrentPushing(); -- double d0 = this.level().dimensionType().ultraWarm() ? 0.007 : 0.0023333333333333335; +- double d0 = this.level.environmentAttributes().getDimensionValue(EnvironmentAttributes.FAST_LAVA) ? 0.007 : 0.0023333333333333335; - boolean flag = this.updateFluidHeightAndDoFluidPushing(FluidTags.LAVA, d0); - return this.isInWater() || flag; + if (!(this.getVehicle() instanceof AbstractBoat)) { @@ -150,7 +150,7 @@ if (!this.wasTouchingWater && !this.firstTick) { this.doWaterSplashEffect(); } -@@ -1520,6 +_,7 @@ +@@ -1538,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 -@@ -1531,7 +_,7 @@ +@@ -1549,7 +_,7 @@ FluidState fluidstate = this.level().getFluidState(blockpos); double d1 = blockpos.getY() + fluidstate.getHeight(this.level(), blockpos); if (d1 > d0) { @@ -167,7 +167,7 @@ } } } -@@ -1585,12 +_,13 @@ +@@ -1603,12 +_,13 @@ } public boolean canSpawnSprintParticle() { @@ -182,7 +182,7 @@ if (blockstate.getRenderShape() != RenderShape.INVISIBLE) { Vec3 vec3 = this.getDeltaMovement(); BlockPos blockpos1 = this.blockPosition(); -@@ -1606,7 +_,7 @@ +@@ -1624,7 +_,7 @@ this.level() .addParticle( @@ -191,7 +191,7 @@ d0, this.getY() + 0.1, d1, -@@ -1617,12 +_,15 @@ +@@ -1635,12 +_,15 @@ } } @@ -208,7 +208,7 @@ } public void moveRelative(float p_19921_, Vec3 p_19922_) { -@@ -1987,6 +_,10 @@ +@@ -2009,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)); } -@@ -2062,6 +_,9 @@ +@@ -2084,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); -@@ -2114,6 +_,8 @@ +@@ -2132,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; } -@@ -2173,11 +_,11 @@ +@@ -2190,11 +_,11 @@ } ItemStack itemstack = p_19978_.getItemInHand(p_19979_); @@ -252,7 +252,7 @@ && mob.canShearEquipment(p_19978_) && !p_19978_.isSecondaryUseActive() && this.attemptToShearEquipment(p_19978_, p_19979_, itemstack, mob)) { -@@ -2282,6 +_,7 @@ +@@ -2302,6 +_,7 @@ public void rideTick() { this.setDeltaMovement(Vec3.ZERO); @@ -260,7 +260,7 @@ this.tick(); if (this.isPassenger()) { this.getVehicle().positionRider(this); -@@ -2342,6 +_,7 @@ +@@ -2362,6 +_,7 @@ } } @@ -268,7 +268,7 @@ if (p_19967_ || this.canRide(p_19966_) && p_19966_.canAddPassenger(this)) { if (this.isPassenger()) { this.stopRiding(); -@@ -2377,6 +_,7 @@ +@@ -2397,6 +_,7 @@ public void removeVehicle() { if (this.vehicle != null) { Entity entity = this.vehicle; @@ -276,7 +276,7 @@ this.vehicle = null; entity.removePassenger(this); Entity.RemovalReason entity$removalreason = this.getRemovalReason(); -@@ -2427,6 +_,8 @@ +@@ -2447,6 +_,8 @@ return this.passengers.isEmpty(); } @@ -285,7 +285,7 @@ protected boolean couldAcceptPassenger() { return true; } -@@ -2623,7 +_,7 @@ +@@ -2646,7 +_,7 @@ } public boolean isVisuallyCrawling() { @@ -294,7 +294,7 @@ } public void setSwimming(boolean p_20283_) { -@@ -2740,7 +_,7 @@ +@@ -2762,7 +_,7 @@ this.igniteForSeconds(8.0F); } @@ -303,7 +303,7 @@ } public void onAboveBubbleColumn(boolean p_392709_, BlockPos p_391902_) { -@@ -2873,7 +_,7 @@ +@@ -2895,7 +_,7 @@ } protected Component getTypeName() { @@ -312,7 +312,7 @@ } public boolean is(Entity p_20356_) { -@@ -3186,6 +_,7 @@ +@@ -3206,6 +_,7 @@ return this.stringUUID; } @@ -320,7 +320,7 @@ public boolean isPushedByFluid() { return true; } -@@ -3570,9 +_,17 @@ +@@ -3594,9 +_,17 @@ return Mth.lerp(p_344421_, this.yRotO, this.yRot); } @@ -339,7 +339,7 @@ } else { AABB aabb = this.getBoundingBox().deflate(0.001); int i = Mth.floor(aabb.minX); -@@ -3587,25 +_,28 @@ +@@ -3611,25 +_,28 @@ Vec3 vec3 = Vec3.ZERO; int k1 = 0; BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(); @@ -375,7 +375,7 @@ } } } -@@ -3613,27 +_,28 @@ +@@ -3637,27 +_,28 @@ } } @@ -414,7 +414,7 @@ } } -@@ -3646,7 +_,10 @@ +@@ -3670,7 +_,10 @@ return !this.level().hasChunksAt(i, k, j, l); } @@ -425,7 +425,7 @@ return this.fluidHeight.getDouble(p_204037_); } -@@ -3662,7 +_,9 @@ +@@ -3686,7 +_,9 @@ return this.dimensions.height(); } @@ -435,7 +435,7 @@ return new ClientboundAddEntityPacket(this, p_344981_); } -@@ -3793,6 +_,11 @@ +@@ -3821,6 +_,11 @@ } } } @@ -447,7 +447,7 @@ } public void checkDespawn() { -@@ -3967,6 +_,100 @@ +@@ -3993,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/EntityType.java.patch b/patches/minecraft/net/minecraft/world/entity/EntityType.java.patch index 75b540c93d..860403373e 100644 --- a/patches/minecraft/net/minecraft/world/entity/EntityType.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/EntityType.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/EntityType.java +++ b/net/minecraft/world/entity/EntityType.java -@@ -961,6 +_,11 @@ +@@ -979,6 +_,11 @@ private final FeatureFlagSet requiredFeatures; private final boolean allowedInPeaceful; @@ -12,7 +12,7 @@ private static EntityType register(ResourceKey> p_368406_, EntityType.Builder p_363129_) { return Registry.register(BuiltInRegistries.ENTITY_TYPE, p_368406_, p_363129_.build(p_368406_)); } -@@ -996,7 +_,8 @@ +@@ -1014,7 +_,8 @@ String p_367006_, Optional> p_364691_, FeatureFlagSet p_273518_, @@ -22,7 +22,7 @@ ) { this.factory = p_273268_; this.category = p_272918_; -@@ -1013,6 +_,10 @@ +@@ -1031,6 +_,10 @@ this.lootTable = p_364691_; this.requiredFeatures = p_273518_; this.allowedInPeaceful = p_430684_; @@ -32,8 +32,8 @@ + this.customClientFactory = builder == null ? null : builder.customClientFactory; } - @Nullable -@@ -1316,14 +_,26 @@ + public @Nullable T spawn( +@@ -1325,14 +_,26 @@ } public int clientTrackingRange() { @@ -60,7 +60,7 @@ return this != PLAYER && this != LLAMA_SPIT && this != WITHER -@@ -1383,6 +_,12 @@ +@@ -1391,6 +_,12 @@ return OP_ONLY_CUSTOM_DATA.contains(this); } @@ -73,9 +73,9 @@ public static class Builder { private final EntityType.EntityFactory factory; private final MobCategory category; -@@ -1402,6 +_,10 @@ +@@ -1410,6 +_,10 @@ ); - private final DependantName, String> descriptionId = p_358878_ -> Util.makeDescriptionId("entity", p_358878_.location()); + private final DependantName, String> descriptionId = p_449414_ -> Util.makeDescriptionId("entity", p_449414_.identifier()); private boolean allowedInPeaceful = true; + private java.util.function.Predicate> velocityUpdateSupplier = EntityType::defaultVelocitySupplier; + private java.util.function.ToIntFunction> trackingRangeSupplier = EntityType::defaultTrackingRangeSupplier; @@ -84,7 +84,7 @@ private Builder(EntityType.EntityFactory p_20696_, MobCategory p_20697_) { this.factory = p_20696_; -@@ -1520,6 +_,30 @@ +@@ -1528,6 +_,30 @@ return this; } @@ -114,8 +114,8 @@ + public EntityType build(ResourceKey> p_369693_) { if (this.serialize) { - Util.fetchChoiceType(References.ENTITY_TREE, p_369693_.location().toString()); -@@ -1540,7 +_,8 @@ + Util.fetchChoiceType(References.ENTITY_TREE, p_369693_.identifier().toString()); +@@ -1548,7 +_,8 @@ this.descriptionId.get(p_369693_), this.lootTable.get(p_369693_), this.requiredFeatures, diff --git a/patches/minecraft/net/minecraft/world/entity/ExperienceOrb.java.patch b/patches/minecraft/net/minecraft/world/entity/ExperienceOrb.java.patch index 68d5e4acfd..cb00ebf379 100644 --- a/patches/minecraft/net/minecraft/world/entity/ExperienceOrb.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/ExperienceOrb.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ExperienceOrb.java +++ b/net/minecraft/world/entity/ExperienceOrb.java -@@ -137,7 +_,8 @@ +@@ -136,7 +_,8 @@ this.applyEffectsFromBlocks(); float f = 0.98F; if (this.onGround()) { @@ -10,7 +10,7 @@ } this.setDeltaMovement(this.getDeltaMovement().scale(f)); -@@ -279,6 +_,7 @@ +@@ -278,6 +_,7 @@ public void playerTouch(Player p_20792_) { if (p_20792_ instanceof ServerPlayer serverplayer) { if (p_20792_.takeXpDelay == 0) { diff --git a/patches/minecraft/net/minecraft/world/entity/Leashable.java.patch b/patches/minecraft/net/minecraft/world/entity/Leashable.java.patch index dc8e0d4bf3..f23634428e 100644 --- a/patches/minecraft/net/minecraft/world/entity/Leashable.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/Leashable.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/Leashable.java +++ b/net/minecraft/world/entity/Leashable.java -@@ -186,7 +_,8 @@ +@@ -185,7 +_,8 @@ static float angularFriction(E p_408063_) { if (p_408063_.onGround()) { diff --git a/patches/minecraft/net/minecraft/world/entity/LightningBolt.java.patch b/patches/minecraft/net/minecraft/world/entity/LightningBolt.java.patch index 8b84f83a8f..150c1feeb4 100644 --- a/patches/minecraft/net/minecraft/world/entity/LightningBolt.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/LightningBolt.java.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/world/entity/LightningBolt.java +++ b/net/minecraft/world/entity/LightningBolt.java -@@ -39,6 +_,7 @@ - private ServerPlayer cause; +@@ -38,6 +_,7 @@ + private @Nullable ServerPlayer cause; private final Set hitEntities = Sets.newHashSet(); private int blocksSetOnFire; + private float damage = 5.0F; public LightningBolt(EntityType p_20865_, Level p_20866_) { super(p_20865_, p_20866_); -@@ -65,6 +_,14 @@ +@@ -63,6 +_,14 @@ this.cause = p_20880_; } @@ -23,7 +23,7 @@ private void powerLightningRod() { BlockPos blockpos = this.getStrikePosition(); BlockState blockstate = this.level().getBlockState(blockpos); -@@ -163,6 +_,7 @@ +@@ -161,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 ffa2328dd7..6adcbacc7d 100644 --- a/patches/minecraft/net/minecraft/world/entity/LivingEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/LivingEntity.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/entity/LivingEntity.java +++ b/net/minecraft/world/entity/LivingEntity.java -@@ -140,7 +_,7 @@ - import org.jetbrains.annotations.Contract; +@@ -143,7 +_,7 @@ + import org.jspecify.annotations.Nullable; import org.slf4j.Logger; -public abstract class LivingEntity extends Entity implements Attackable, WaypointTransmitter { @@ -9,25 +9,25 @@ private static final Logger LOGGER = LogUtils.getLogger(); private static final String TAG_ACTIVE_EFFECTS = "active_effects"; public static final String TAG_ATTRIBUTES = "attributes"; -@@ -184,6 +_,8 @@ - protected static final EntityDimensions SLEEPING_DIMENSIONS = EntityDimensions.fixed(0.2F, 0.2F).withEyeHeight(0.2F); +@@ -189,6 +_,8 @@ public static final float EXTRA_RENDER_CULLING_SIZE_WITH_BIG_HAT = 0.5F; public static final float DEFAULT_BABY_SCALE = 0.5F; + private static final float WATER_FLOAT_IMPULSE = 0.04F; + /** Forge: Use a variant that calls {@link ItemStack#isMonsterDisguise(Player, net.minecraft.world.entity.monster.Monster)} and {@link net.minecraftforge.event.entity.living.MonsterDisguiseEvent} */ + @Deprecated public static final Predicate PLAYER_NOT_WEARING_DISGUISE_ITEM = p_390518_ -> { if (p_390518_ instanceof Player player) { ItemStack itemstack = player.getItemBySlot(EquipmentSlot.HEAD); -@@ -268,7 +_,7 @@ +@@ -270,7 +_,7 @@ this.reapplyPosition(); - this.setYRot((float)(Math.random() * (float) (Math.PI * 2))); + this.setYRot(this.random.nextFloat() * (float) (Math.PI * 2)); this.yHeadRot = this.getYRot(); - this.brain = this.makeBrain(EMPTY_BRAIN); + this.brain = net.minecraftforge.common.ForgeHooks.onLivingMakeBrain(this, this.makeBrain(EMPTY_BRAIN), EMPTY_BRAIN); } - @Nullable -@@ -335,9 +_,10 @@ + @Override +@@ -334,9 +_,10 @@ .add(Attributes.EXPLOSION_KNOCKBACK_RESISTANCE) .add(Attributes.WATER_MOVEMENT_EFFICIENCY) .add(Attributes.MOVEMENT_EFFICIENCY) @@ -40,7 +40,7 @@ } @Override -@@ -364,7 +_,8 @@ +@@ -363,7 +_,8 @@ double d7 = Math.min(0.2F + d6 / 15.0, 2.5); int i = (int)(150.0 * d7); @@ -50,7 +50,7 @@ } } -@@ -374,6 +_,7 @@ +@@ -373,6 +_,7 @@ } } @@ -58,7 +58,7 @@ public boolean canBreatheUnderwater() { return this.getType().is(EntityTypeTags.CAN_BREATHE_UNDER_WATER); } -@@ -414,6 +_,10 @@ +@@ -413,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); -@@ -764,6 +_,9 @@ +@@ -759,6 +_,9 @@ } else { ItemEntity itementity = this.createItemStackToDrop(p_395943_, p_393118_, p_392158_); if (itementity != null) { @@ -79,7 +79,7 @@ this.level().addFreshEntity(itementity); } -@@ -805,7 +_,7 @@ +@@ -801,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"); -@@ -823,8 +_,10 @@ +@@ -825,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); } -@@ -904,6 +_,7 @@ +@@ -908,6 +_,7 @@ } } @@ -107,7 +107,7 @@ return d0; } -@@ -978,6 +_,7 @@ +@@ -981,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_); -@@ -994,6 +_,10 @@ +@@ -997,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)) { -@@ -1027,6 +_,9 @@ +@@ -1029,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)); -@@ -1071,6 +_,9 @@ +@@ -1073,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()) { -@@ -1118,6 +_,10 @@ +@@ -1120,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_); -@@ -1138,6 +_,9 @@ +@@ -1140,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()) { -@@ -1285,6 +_,10 @@ +@@ -1287,6 +_,10 @@ } float f = blocksattacks.resolveBlockedDamage(p_392511_, p_394545_, d0); @@ -178,7 +178,7 @@ blocksattacks.hurtBlockingItem(this.level(), itemstack, this, this.getUsedItemHand(), f); if (f > 0.0F && !p_392511_.is(DamageTypeTags.IS_PROJECTILE) && p_392511_.getDirectEntity() instanceof LivingEntity livingentity) { this.blockUsingItem(p_396198_, livingentity); -@@ -1319,7 +_,7 @@ +@@ -1320,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 { -@@ -1349,7 +_,7 @@ +@@ -1350,7 +_,7 @@ for (InteractionHand interactionhand : InteractionHand.values()) { ItemStack itemstack1 = this.getItemInHand(interactionhand); deathprotection = itemstack1.get(DataComponents.DEATH_PROTECTION); @@ -204,11 +204,11 @@ if (!this.isRemoved() && !this.dead) { Entity entity = p_21014_.getEntity(); LivingEntity livingentity = this.getKillCredit(); -@@ -1448,10 +_,10 @@ +@@ -1449,10 +_,10 @@ if (this.level() instanceof ServerLevel serverlevel) { boolean flag = false; if (p_21269_ instanceof WitherBoss) { -- if (serverlevel.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { +- if (serverlevel.getGameRules().get(GameRules.MOB_GRIEFING)) { + if (net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(serverlevel, p_21269_)) { BlockPos blockpos = this.blockPosition(); BlockState blockstate = Blocks.WITHER_ROSE.defaultBlockState(); @@ -217,7 +217,7 @@ this.level().setBlock(blockpos, blockstate, 3); flag = true; } -@@ -1466,6 +_,7 @@ +@@ -1467,6 +_,7 @@ } protected void dropAllDeathLoot(ServerLevel p_342160_, DamageSource p_21192_) { @@ -225,7 +225,7 @@ boolean flag = this.lastHurtByPlayerMemoryTime > 0; if (this.shouldDropLoot(p_342160_)) { this.dropFromLootTable(p_342160_, p_21192_, flag); -@@ -1474,6 +_,11 @@ +@@ -1475,6 +_,11 @@ this.dropEquipment(p_342160_); this.dropExperience(p_342160_, p_21192_.getEntity()); @@ -237,17 +237,17 @@ } protected void dropEquipment(ServerLevel p_365823_) { -@@ -1481,7 +_,8 @@ +@@ -1482,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))) { + if (!this.wasExperienceConsumed() && (this.isAlwaysExperienceDropper() || this.lastHurtByPlayerMemoryTime > 0 && this.shouldDropExperience() && p_370040_.getGameRules().get(GameRules.MOB_DROPS))) { - ExperienceOrb.award(p_370040_, this.position(), this.getExperienceReward(p_370040_, p_342525_)); + int reward = net.minecraftforge.event.ForgeEventFactory.getExperienceDrop(this, this.getLastHurtByPlayer(), this.getExperienceReward(p_370040_, p_342525_)); + ExperienceOrb.award(p_370040_, this.position(), reward); } } -@@ -1580,6 +_,11 @@ +@@ -1583,6 +_,11 @@ } public void knockback(double p_147241_, double p_147242_, double p_147243_) { @@ -258,8 +258,8 @@ + p_147243_ = event.getRatioZ(); p_147241_ *= 1.0 - this.getAttributeValue(Attributes.KNOCKBACK_RESISTANCE); if (!(p_147241_ <= 0.0)) { - this.hasImpulse = true; -@@ -1657,6 +_,13 @@ + this.needsSync = true; +@@ -1664,6 +_,13 @@ } else { BlockPos blockpos = this.blockPosition(); BlockState blockstate = this.getInBlockState(); @@ -270,10 +270,10 @@ + } else if (ladderPos != null) { + return false; + } - if (blockstate.is(BlockTags.CLIMBABLE)) { - this.lastClimbablePos = Optional.of(blockpos); - return true; -@@ -1711,6 +_,10 @@ + if (this.isFallFlying() && blockstate.is(BlockTags.CAN_GLIDE_THROUGH)) { + return false; + } else if (blockstate.is(BlockTags.CLIMBABLE)) { +@@ -1720,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) { -@@ -1741,9 +_,10 @@ +@@ -1750,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); } } -@@ -1801,9 +_,9 @@ +@@ -1810,9 +_,9 @@ float f2 = f1 - p_21194_; if (f2 > 0.0F && f2 < 3.4028235E37F) { if (this instanceof ServerPlayer) { @@ -309,7 +309,7 @@ } } } -@@ -1831,6 +_,8 @@ +@@ -1840,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); -@@ -1840,6 +_,7 @@ +@@ -1849,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); -@@ -1899,6 +_,8 @@ +@@ -1909,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; -@@ -2023,9 +_,10 @@ +@@ -2050,9 +_,10 @@ } private void swapHandItems() { @@ -349,10 +349,10 @@ } @Override -@@ -2231,15 +_,18 @@ +@@ -2265,15 +_,18 @@ } - this.hasImpulse = true; + this.needsSync = true; + net.minecraftforge.common.ForgeHooks.onLivingJump(this); } } @@ -370,18 +370,28 @@ } protected float getWaterSlowDown() { -@@ -2262,8 +_,8 @@ +@@ -2295,8 +_,9 @@ + } public void travel(Vec3 p_21280_) { - FluidState fluidstate = this.level().getFluidState(this.blockPosition()); -- if ((this.isInWater() || this.isInLava()) && this.isAffectedByFluids() && !this.canStandOnFluid(fluidstate)) { +- if (this.shouldTravelInFluid(this.level().getFluidState(this.blockPosition()))) { - this.travelInFluid(p_21280_); -+ if ((this.isInWater() || this.isInLava() || this.isInFluidType(fluidstate)) && this.isAffectedByFluids() && !this.canStandOnFluid(fluidstate)) { ++ var fluidstate = this.level().getFluidState(this.blockPosition()); ++ if (this.shouldTravelInFluid(fluidstate)) { + this.travelInFluid(p_21280_, fluidstate); } else if (this.isFallFlying()) { this.travelFallFlying(p_21280_); } else { -@@ -2293,7 +_,7 @@ +@@ -2305,7 +_,7 @@ + } + + protected boolean shouldTravelInFluid(FluidState p_453099_) { +- return (this.isInWater() || this.isInLava()) && this.isAffectedByFluids() && !this.canStandOnFluid(p_453099_); ++ return (this.isInWater() || this.isInLava() || this.isInFluidType(p_453099_)) && this.isAffectedByFluids() && !this.canStandOnFluid(p_453099_); + } + + protected void travelFlying(Vec3 p_407126_, float p_407105_) { +@@ -2330,7 +_,7 @@ private void travelInAir(Vec3 p_362087_) { BlockPos blockpos = this.getBlockPosBelowThatAffectsMyMovement(); @@ -390,7 +400,7 @@ float f1 = f * 0.91F; Vec3 vec3 = this.handleRelativeFrictionAndCalculateMovement(p_362087_, f); double d0 = vec3.y; -@@ -2316,10 +_,18 @@ +@@ -2353,10 +_,18 @@ } } @@ -408,17 +418,17 @@ + // Modded fluid handled it + } else if (this.isInWater()) { - float f = this.isSprinting() ? 0.9F : this.getWaterSlowDown(); - float f1 = 0.02F; -@@ -2337,6 +_,7 @@ - f = 0.96F; - } + this.travelInWater(p_362114_, d1, flag, d0); + this.floatInWaterWhileRidden(); +@@ -2382,6 +_,7 @@ + f = 0.96F; + } -+ f1 *= this.getAttributeValue(net.minecraftforge.common.ForgeMod.SWIM_SPEED.getHolder().get()); - this.moveRelative(f1, p_362114_); - this.move(MoverType.SELF, this.getDeltaMovement()); - Vec3 vec3 = this.getDeltaMovement(); -@@ -2495,7 +_,7 @@ ++ f1 *= this.getAttributeValue(net.minecraftforge.common.ForgeMod.SWIM_SPEED.getHolder().get()); + this.moveRelative(f1, p_451732_); + this.move(MoverType.SELF, this.getDeltaMovement()); + Vec3 vec3 = this.getDeltaMovement(); +@@ -2553,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 +437,7 @@ d2 = 0.0; } -@@ -2528,6 +_,7 @@ +@@ -2598,6 +_,7 @@ @Override public void tick() { @@ -435,7 +445,7 @@ super.tick(); this.updatingUsingItem(); this.updateSwimAmount(); -@@ -2659,6 +_,7 @@ +@@ -2786,6 +_,7 @@ ItemStack itemstack = this.lastEquipmentItems.get(equipmentslot); ItemStack itemstack1 = this.getItemBySlot(equipmentslot); if (this.equipmentHasChanged(itemstack, itemstack1)) { @@ -443,7 +453,7 @@ if (map == null) { map = Maps.newEnumMap(EquipmentSlot.class); } -@@ -2794,6 +_,10 @@ +@@ -2921,6 +_,10 @@ profilerfiller.push("jump"); if (this.jumping && this.isAffectedByFluids()) { double d3; @@ -454,7 +464,7 @@ if (this.isInLava()) { d3 = this.getFluidHeight(FluidTags.LAVA); } else { -@@ -2804,15 +_,22 @@ +@@ -2931,15 +_,22 @@ double d4 = this.getFluidJumpThreshold(); if (!flag || this.onGround() && !(d3 > d4)) { if (!this.isInLava() || this.onGround() && !(d3 > d4)) { @@ -479,7 +489,7 @@ } } else { this.noJumpDelay = 0; -@@ -3128,8 +_,11 @@ +@@ -3255,8 +_,11 @@ private void updatingUsingItem() { if (this.isUsingItem()) { @@ -492,7 +502,7 @@ this.updateUsingItem(this.useItem); } else { this.stopUsingItem(); -@@ -3173,8 +_,12 @@ +@@ -3299,8 +_,12 @@ } protected void updateUsingItem(ItemStack p_147201_) { @@ -506,7 +516,7 @@ this.completeUsingItem(); } } -@@ -3202,8 +_,10 @@ +@@ -3328,8 +_,10 @@ public void startUsingItem(InteractionHand p_21159_) { ItemStack itemstack = this.getItemInHand(p_21159_); if (!itemstack.isEmpty() && !this.isUsingItem()) { @@ -518,7 +528,7 @@ if (!this.level().isClientSide()) { this.setLivingEntityFlag(1, true); this.setLivingEntityFlag(2, p_21159_ == InteractionHand.OFF_HAND); -@@ -3255,6 +_,9 @@ +@@ -3384,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 +538,7 @@ this.level() .addParticle( new ItemParticleOption(ParticleTypes.ITEM, p_21061_), -@@ -3275,7 +_,9 @@ +@@ -3404,7 +_,9 @@ this.releaseUsingItem(); } else { if (!this.useItem.isEmpty() && this.isUsingItem()) { @@ -538,7 +548,7 @@ if (itemstack != this.useItem) { this.setItemInHand(interactionhand, itemstack); } -@@ -3305,7 +_,13 @@ +@@ -3438,7 +_,13 @@ ItemStack itemstack = this.getItemInHand(this.getUsedItemHand()); if (!this.useItem.isEmpty() && ItemStack.isSameItem(itemstack, this.useItem)) { this.useItem = itemstack; @@ -552,15 +562,15 @@ if (this.useItem.useOnRelease()) { this.updatingUsingItem(); } -@@ -3315,6 +_,7 @@ +@@ -3448,6 +_,7 @@ } public void stopUsingItem() { + if (this.isUsingItem() && !this.useItem.isEmpty()) this.useItem.onStopUsing(this, useItemRemaining); if (!this.level().isClientSide()) { boolean flag = this.isUsingItem(); - this.setLivingEntityFlag(1, false); -@@ -3483,8 +_,8 @@ + this.recentKineticEnemies = null; +@@ -3616,8 +_,8 @@ } BlockState blockstate = this.level().getBlockState(p_21141_); @@ -571,12 +581,12 @@ } this.setPose(Pose.SLEEPING); -@@ -3499,15 +_,15 @@ +@@ -3632,15 +_,15 @@ } private boolean checkBedExists() { -- 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); +- return this.getSleepingPos().map(p_449422_ -> this.level().getBlockState(p_449422_).getBlock() instanceof BedBlock).orElse(false); ++ return this.getSleepingPos().map(p_449422_ -> net.minecraftforge.event.ForgeEventFactory.fireSleepingLocationCheck(this, p_449422_)).orElse(false); } public void stopSleeping() { @@ -590,9 +600,9 @@ 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); -@@ -3528,7 +_,9 @@ - @Nullable - public Direction getBedOrientation() { +@@ -3660,7 +_,9 @@ + + public @Nullable Direction getBedOrientation() { BlockPos blockpos = this.getSleepingPos().orElse(null); - return blockpos != null ? BedBlock.getBedOrientation(this.level(), blockpos) : null; + if (blockpos == null) return Direction.UP; @@ -601,7 +611,7 @@ } @Override -@@ -3537,7 +_,7 @@ +@@ -3669,7 +_,7 @@ } public ItemStack getProjectile(ItemStack p_21272_) { @@ -610,7 +620,7 @@ } private static byte entityEventForEquipmentBreak(EquipmentSlot p_21267_) { -@@ -3589,6 +_,8 @@ +@@ -3721,6 +_,8 @@ } public final EquipmentSlot getEquipmentSlotForItem(ItemStack p_147234_) { @@ -619,7 +629,7 @@ Equippable equippable = p_147234_.get(DataComponents.EQUIPPABLE); return equippable != null && this.canUseSlot(equippable.slot()) ? equippable.slot() : EquipmentSlot.MAINHAND; } -@@ -3752,5 +_,42 @@ +@@ -3884,5 +_,42 @@ } public record Fallsounds(SoundEvent small, SoundEvent big) { @@ -633,7 +643,7 @@ + * @return If the player should orient the same direction as this entity. + */ + public boolean shouldRiderFaceForward(Player player) { -+ return this instanceof net.minecraft.world.entity.animal.Pig; ++ return this instanceof net.minecraft.world.entity.animal.pig.Pig; + } + + private net.minecraftforge.common.util.LazyOptional[] handlers = net.minecraftforge.items.wrapper.EntityEquipmentInvWrapper.create(this); diff --git a/patches/minecraft/net/minecraft/world/entity/Mob.java.patch b/patches/minecraft/net/minecraft/world/entity/Mob.java.patch index 6fe0db2916..c817e1f203 100644 --- a/patches/minecraft/net/minecraft/world/entity/Mob.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/Mob.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/entity/Mob.java +++ b/net/minecraft/world/entity/Mob.java @@ -137,6 +_,9 @@ - private Leashable.LeashData leashData; + private Leashable.@Nullable LeashData leashData; private BlockPos homePosition = BlockPos.ZERO; private int homeRadius = -1; + @Nullable @@ -10,7 +10,7 @@ protected Mob(EntityType p_21368_, Level p_21369_) { super(p_21368_, p_21369_); -@@ -233,7 +_,10 @@ +@@ -230,7 +_,10 @@ } public void setTarget(@Nullable LivingEntity p_21544_) { @@ -22,7 +22,7 @@ } @Override -@@ -373,6 +_,10 @@ +@@ -369,6 +_,10 @@ if (this.isNoAi()) { p_409238_.putBoolean("NoAI", this.isNoAi()); } @@ -33,7 +33,7 @@ } @Override -@@ -391,6 +_,13 @@ +@@ -387,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)); @@ -51,12 +51,12 @@ && this.canPickUpLoot() && this.isAlive() && !this.dead -- && serverlevel.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { +- && serverlevel.getGameRules().get(GameRules.MOB_GRIEFING)) { + && net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(serverlevel, this)) { Vec3i vec3i = this.getPickupReach(); for (ItemEntity itementity : this.level() -@@ -606,6 +_,14 @@ +@@ -641,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(); -@@ -998,6 +_,16 @@ +@@ -1032,6 +_,16 @@ } } @@ -85,10 +85,10 @@ + */ + @Deprecated + @org.jetbrains.annotations.ApiStatus.OverrideOnly - @Nullable - public SpawnGroupData finalizeSpawn(ServerLevelAccessor p_21434_, DifficultyInstance p_21435_, EntitySpawnReason p_369316_, @Nullable SpawnGroupData p_21437_) { - RandomSource randomsource = p_21434_.getRandom(); -@@ -1009,6 +_,7 @@ + public @Nullable SpawnGroupData finalizeSpawn( + ServerLevelAccessor p_21434_, DifficultyInstance p_21435_, EntitySpawnReason p_369316_, @Nullable SpawnGroupData p_21437_ + ) { +@@ -1044,6 +_,7 @@ } this.setLeftHanded(randomsource.nextFloat() < 0.05F); @@ -96,8 +96,8 @@ return p_21437_; } -@@ -1328,15 +_,25 @@ - return false; +@@ -1350,15 +_,25 @@ + return flag; } + @Deprecated // FORGE: use jumpInFluid instead @@ -123,8 +123,8 @@ @VisibleForTesting public void removeFreeWill() { this.removeAllGoals(p_341273_ -> true); -@@ -1364,6 +_,41 @@ - public ItemStack getPickResult() { +@@ -1385,6 +_,41 @@ + public @Nullable 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 513a1607e7..8a13eec47e 100644 --- a/patches/minecraft/net/minecraft/world/entity/SpawnPlacements.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/SpawnPlacements.java.patch @@ -18,7 +18,7 @@ } static { -@@ -166,5 +_,13 @@ +@@ -169,5 +_,13 @@ @FunctionalInterface public interface SpawnPredicate { boolean test(EntityType p_217081_, ServerLevelAccessor p_217082_, EntitySpawnReason p_365908_, BlockPos p_217084_, RandomSource p_217085_); diff --git a/patches/minecraft/net/minecraft/world/entity/TamableAnimal.java.patch b/patches/minecraft/net/minecraft/world/entity/TamableAnimal.java.patch index a1e829626e..a7004f7c2a 100644 --- a/patches/minecraft/net/minecraft/world/entity/TamableAnimal.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/TamableAnimal.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/TamableAnimal.java +++ b/net/minecraft/world/entity/TamableAnimal.java -@@ -212,13 +_,16 @@ +@@ -210,13 +_,16 @@ @Override public void die(DamageSource p_21809_) { @@ -10,7 +10,7 @@ + + if (this.dead) if (this.level() instanceof ServerLevel serverlevel - && serverlevel.getGameRules().getBoolean(GameRules.RULE_SHOWDEATHMESSAGES) + && serverlevel.getGameRules().get(GameRules.SHOW_DEATH_MESSAGES) && this.getOwner() instanceof ServerPlayer serverplayer) { - serverplayer.sendSystemMessage(this.getCombatTracker().getDeathMessage()); + serverplayer.sendSystemMessage(deathMessage); 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 b4cb367c6b..66f661d21d 100644 --- a/patches/minecraft/net/minecraft/world/entity/ai/Brain.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/ai/Brain.java.patch @@ -1,9 +1,22 @@ --- a/net/minecraft/world/entity/ai/Brain.java +++ b/net/minecraft/world/entity/ai/Brain.java -@@ -498,6 +_,30 @@ - return this.memories.isEmpty() && this.sensors.isEmpty() && this.availableBehaviorsByPriority.isEmpty(); +@@ -232,6 +_,10 @@ + this.schedule = p_455227_; } ++ public EnvironmentAttribute getSchedule() { ++ return this.schedule; ++ } ++ + public void setCoreActivities(Set p_21931_) { + this.coreActivities = p_21931_; + } +@@ -493,6 +_,30 @@ + + public boolean isBrainDead() { + return this.memories.isEmpty() && this.sensors.isEmpty() && this.availableBehaviorsByPriority.isEmpty(); ++ } ++ + public net.minecraftforge.common.util.BrainBuilder createBuilder() { + var builder = new net.minecraftforge.common.util.BrainBuilder<>(this); + builder.getMemoryTypes().addAll(this.memories.keySet()); @@ -26,8 +39,6 @@ + this.setCoreActivities(builder.getCoreActivities()); + this.setDefaultActivity(builder.getDefaultActivity()); + this.activeActivities.addAll(builder.getActiveActivites()); -+ } -+ + } + static final class MemoryValue { - private final MemoryModuleType type; - private final Optional> value; diff --git a/patches/minecraft/net/minecraft/world/entity/ai/attributes/AttributeSupplier.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/attributes/AttributeSupplier.java.patch index d842b1989e..be2f1cbdab 100644 --- a/patches/minecraft/net/minecraft/world/entity/ai/attributes/AttributeSupplier.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/ai/attributes/AttributeSupplier.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/attributes/AttributeSupplier.java +++ b/net/minecraft/world/entity/ai/attributes/AttributeSupplier.java -@@ -66,8 +_,24 @@ +@@ -65,8 +_,24 @@ } public static class Builder { @@ -26,7 +26,7 @@ private AttributeInstance create(Holder p_334904_) { AttributeInstance attributeinstance = new AttributeInstance(p_334904_, p_326800_ -> { -@@ -92,7 +_,8 @@ +@@ -91,7 +_,8 @@ public AttributeSupplier build() { this.instanceFrozen = true; 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 90071bb64b..8fd8ba9f24 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 -@@ -181,11 +_,12 @@ +@@ -188,11 +_,12 @@ .build(); public static AttributeSupplier getSupplier(EntityType p_22298_) { diff --git a/patches/minecraft/net/minecraft/world/entity/ai/behavior/HarvestFarmland.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/behavior/HarvestFarmland.java.patch index de94fe07e4..36dcf3b93f 100644 --- a/patches/minecraft/net/minecraft/world/entity/ai/behavior/HarvestFarmland.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/ai/behavior/HarvestFarmland.java.patch @@ -1,17 +1,17 @@ --- a/net/minecraft/world/entity/ai/behavior/HarvestFarmland.java +++ b/net/minecraft/world/entity/ai/behavior/HarvestFarmland.java -@@ -47,7 +_,7 @@ +@@ -46,7 +_,7 @@ } - protected boolean checkExtraStartConditions(ServerLevel p_23174_, Villager p_23175_) { -- if (!p_23174_.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { -+ if (!net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(p_23174_, p_23175_)) { + protected boolean checkExtraStartConditions(ServerLevel p_23174_, Villager p_460921_) { +- if (!p_23174_.getGameRules().get(GameRules.MOB_GRIEFING)) { ++ if (!net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(p_23174_, p_460921_)) { return false; - } else if (!p_23175_.getVillagerData().profession().is(VillagerProfession.FARMER)) { + } else if (!p_460921_.getVillagerData().profession().is(VillagerProfession.FARMER)) { return false; -@@ -118,6 +_,11 @@ +@@ -116,6 +_,11 @@ p_23196_.setBlockAndUpdate(this.aboveFarmlandPos, blockstate1); - p_23196_.gameEvent(GameEvent.BLOCK_PLACE, this.aboveFarmlandPos, GameEvent.Context.of(p_23197_, blockstate1)); + p_23196_.gameEvent(GameEvent.BLOCK_PLACE, this.aboveFarmlandPos, GameEvent.Context.of(p_457898_, blockstate1)); flag = true; + } else if (itemstack.getItem() instanceof net.minecraftforge.common.IPlantable) { + if (((net.minecraftforge.common.IPlantable) itemstack.getItem()).getPlantType(p_23196_, aboveFarmlandPos) == net.minecraftforge.common.PlantType.CROP) { diff --git a/patches/minecraft/net/minecraft/world/entity/ai/goal/BreakDoorGoal.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/goal/BreakDoorGoal.java.patch index 9415b1fb4c..1fea506727 100644 --- a/patches/minecraft/net/minecraft/world/entity/ai/goal/BreakDoorGoal.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/ai/goal/BreakDoorGoal.java.patch @@ -4,7 +4,7 @@ if (!super.canUse()) { return false; } else { -- return !getServerLevel(this.mob).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) +- return !getServerLevel(this.mob).getGameRules().get(GameRules.MOB_GRIEFING) + return !net.minecraftforge.common.ForgeHooks.canEntityDestroy(getServerLevel(this.mob.level()), this.doorPos, this.mob) ? false : this.isValidDifficulty(this.mob.level().getDifficulty()) && !this.isOpen(); diff --git a/patches/minecraft/net/minecraft/world/entity/ai/goal/EatBlockGoal.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/goal/EatBlockGoal.java.patch index 32a98074c0..74cd9f288c 100644 --- a/patches/minecraft/net/minecraft/world/entity/ai/goal/EatBlockGoal.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/ai/goal/EatBlockGoal.java.patch @@ -4,7 +4,7 @@ if (this.eatAnimationTick == this.adjustedTickDelay(4)) { BlockPos blockpos = this.mob.blockPosition(); if (IS_EDIBLE.test(this.level.getBlockState(blockpos))) { -- if (getServerLevel(this.level).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { +- if (getServerLevel(this.level).getGameRules().get(GameRules.MOB_GRIEFING)) { + if (net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(getServerLevel(this.level), this.mob)) { this.level.destroyBlock(blockpos, false); } @@ -13,7 +13,7 @@ } else { BlockPos blockpos1 = blockpos.below(); if (this.level.getBlockState(blockpos1).is(Blocks.GRASS_BLOCK)) { -- if (getServerLevel(this.level).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { +- if (getServerLevel(this.level).getGameRules().get(GameRules.MOB_GRIEFING)) { + if (net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(getServerLevel(this.level), this.mob)) { this.level.levelEvent(2001, blockpos1, Block.getId(Blocks.GRASS_BLOCK.defaultBlockState())); this.level.setBlock(blockpos1, Blocks.DIRT.defaultBlockState(), 2); diff --git a/patches/minecraft/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java.patch index ad9d78a170..719ac84f55 100644 --- a/patches/minecraft/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java.patch @@ -4,12 +4,12 @@ @Override public boolean canUse() { -- if (!getServerLevel(this.removerMob).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { +- if (!getServerLevel(this.removerMob).getGameRules().get(GameRules.MOB_GRIEFING)) { + if (!net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(getServerLevel(this.removerMob.level()), this.removerMob)) { return false; } else if (this.nextStartTick > 0) { this.nextStartTick--; -@@ -150,7 +_,8 @@ +@@ -149,7 +_,8 @@ ); return chunkaccess == null ? false diff --git a/patches/minecraft/net/minecraft/world/entity/ai/goal/target/HurtByTargetGoal.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/goal/target/HurtByTargetGoal.java.patch index d7e2732025..a91e71107a 100644 --- a/patches/minecraft/net/minecraft/world/entity/ai/goal/target/HurtByTargetGoal.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/ai/goal/target/HurtByTargetGoal.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/goal/target/HurtByTargetGoal.java +++ b/net/minecraft/world/entity/ai/goal/target/HurtByTargetGoal.java -@@ -84,6 +_,10 @@ +@@ -83,6 +_,10 @@ } mob = (Mob)iterator.next(); 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 3ecbb8b468..7b8b634eb4 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 -@@ -257,10 +_,10 @@ +@@ -245,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/navigation/WallClimberNavigation.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/navigation/WallClimberNavigation.java.patch index 304587b8f2..cae1e4fe1d 100644 --- a/patches/minecraft/net/minecraft/world/entity/ai/navigation/WallClimberNavigation.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/ai/navigation/WallClimberNavigation.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/navigation/WallClimberNavigation.java +++ b/net/minecraft/world/entity/ai/navigation/WallClimberNavigation.java -@@ -45,12 +_,8 @@ +@@ -44,12 +_,8 @@ super.tick(); } else { if (this.pathToPosition != null) { 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 9b9b1a83ee..a84ce982bc 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 -@@ -204,6 +_,17 @@ +@@ -208,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/Pig.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/Pig.java.patch deleted file mode 100644 index 6d9eaddb2f..0000000000 --- a/patches/minecraft/net/minecraft/world/entity/animal/Pig.java.patch +++ /dev/null @@ -1,18 +0,0 @@ ---- a/net/minecraft/world/entity/animal/Pig.java -+++ b/net/minecraft/world/entity/animal/Pig.java -@@ -206,13 +_,14 @@ - - @Override - 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_421808_ -> { - if (this.getMainHandItem().isEmpty()) { - p_421808_.setItemSlot(EquipmentSlot.MAINHAND, new ItemStack(Items.GOLDEN_SWORD)); - } - - 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 c6c8093792..520b623335 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,10 +1,10 @@ --- a/net/minecraft/world/entity/animal/allay/Allay.java +++ b/net/minecraft/world/entity/animal/allay/Allay.java -@@ -353,7 +_,7 @@ +@@ -352,7 +_,7 @@ public boolean wantsToPickUp(ServerLevel p_363882_, ItemStack p_218387_) { ItemStack itemstack = this.getItemInHand(InteractionHand.MAIN_HAND); return !itemstack.isEmpty() -- && p_363882_.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) +- && p_363882_.getGameRules().get(GameRules.MOB_GRIEFING) + && net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(p_363882_, this) && this.inventory.canAddItem(p_218387_) && this.allayConsidersItemEqual(itemstack, p_218387_); diff --git a/patches/minecraft/net/minecraft/world/entity/animal/Bee.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/bee/Bee.java.patch similarity index 80% rename from patches/minecraft/net/minecraft/world/entity/animal/Bee.java.patch rename to patches/minecraft/net/minecraft/world/entity/animal/bee/Bee.java.patch index 390fd93e44..a4b47ed9ab 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/Bee.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/bee/Bee.java.patch @@ -1,6 +1,6 @@ ---- a/net/minecraft/world/entity/animal/Bee.java -+++ b/net/minecraft/world/entity/animal/Bee.java -@@ -500,7 +_,9 @@ +--- a/net/minecraft/world/entity/animal/bee/Bee.java ++++ b/net/minecraft/world/entity/animal/bee/Bee.java +@@ -492,7 +_,9 @@ if (this.hivePos == null) { return null; } else { @@ -11,11 +11,11 @@ } } -@@ -663,13 +_,22 @@ +@@ -654,13 +_,22 @@ } @Override -- protected void jumpInLiquid(TagKey p_204061_) { +- protected void jumpInLiquid(TagKey p_453030_) { - this.setDeltaMovement(this.getDeltaMovement().add(0.0, 0.01, 0.0)); - } - @@ -38,4 +38,4 @@ + this.jumpInLiquidInternal(); } - boolean closerThan(BlockPos p_27817_, int p_27818_) { + boolean closerThan(BlockPos p_459558_, int p_453557_) { 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 d57ebe5df2..e6df583fb1 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 -@@ -343,7 +_,7 @@ +@@ -351,7 +_,7 @@ @Override protected void playStepSound(BlockPos p_252056_, BlockState p_251457_) { diff --git a/patches/minecraft/net/minecraft/world/entity/animal/MushroomCow.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/cow/MushroomCow.java.patch similarity index 63% rename from patches/minecraft/net/minecraft/world/entity/animal/MushroomCow.java.patch rename to patches/minecraft/net/minecraft/world/entity/animal/cow/MushroomCow.java.patch index 92575478e5..c2298b3999 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/MushroomCow.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/cow/MushroomCow.java.patch @@ -1,6 +1,6 @@ ---- a/net/minecraft/world/entity/animal/MushroomCow.java -+++ b/net/minecraft/world/entity/animal/MushroomCow.java -@@ -116,7 +_,7 @@ +--- a/net/minecraft/world/entity/animal/cow/MushroomCow.java ++++ b/net/minecraft/world/entity/animal/cow/MushroomCow.java +@@ -114,7 +_,7 @@ this.playSound(soundevent, 1.0F, 1.0F); return InteractionResult.SUCCESS; @@ -8,38 +8,38 @@ + } else if (false && itemstack.is(Items.SHEARS) && this.readyForShearing()) { if (this.level() instanceof ServerLevel serverlevel) { this.shear(serverlevel, SoundSource.PLAYERS, itemstack); - this.gameEvent(GameEvent.SHEAR, p_28941_); -@@ -172,15 +_,26 @@ + this.gameEvent(GameEvent.SHEAR, p_454203_); +@@ -170,15 +_,26 @@ @Override - public void shear(ServerLevel p_369641_, SoundSource p_28924_, ItemStack p_364876_) { -+ for (var stack : shearInternal(p_369641_, p_28924_, p_364876_)) { + public void shear(ServerLevel p_454992_, SoundSource p_460786_, ItemStack p_454795_) { ++ for (var stack : shearInternal(p_454992_, p_460786_, p_454795_)) { + for (int i = 0; i < stack.getCount(); i++) { + this.level().addFreshEntity(new ItemEntity(this.level(), this.getX(), this.getY(1.0D), this.getZ(), stack.copyWithCount(1))); + } + } + } + -+ private java.util.List shearInternal(ServerLevel p_369641_, SoundSource p_28924_, ItemStack p_364876_) { ++ private java.util.List shearInternal(ServerLevel p_454992_, SoundSource p_460786_, ItemStack p_454795_) { + var ret = new java.util.ArrayList(); + 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_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_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))); + p_454992_.playSound(null, this, SoundEvents.MOOSHROOM_SHEAR, p_460786_, 1.0F, 1.0F); + this.convertTo(EntityType.COW, ConversionParams.single(this, false, false), p_458024_ -> { + p_454992_.sendParticles(ParticleTypes.EXPLOSION, this.getX(), this.getY(0.5), this.getZ(), 1, 0.0, 0.0, 0.0, 0.0); + this.dropFromShearingLootTable(p_454992_, BuiltInLootTables.SHEAR_MOOSHROOM, p_454795_, (p_460709_, p_451895_) -> { +- for (int i = 0; i < p_451895_.getCount(); i++) { +- p_460709_.addFreshEntity(new ItemEntity(this.level(), this.getX(), this.getY(1.0), this.getZ(), p_451895_.copyWithCount(1))); - } -+ ret.add(p_421804_); ++ ret.add(p_451895_); }); -+ net.minecraftforge.event.ForgeEventFactory.onLivingConvert(this, p_421807_); ++ net.minecraftforge.event.ForgeEventFactory.onLivingConvert(this, p_458024_); }); + return ret; } @Override -@@ -258,6 +_,15 @@ +@@ -254,6 +_,15 @@ } return mushroomcow$variant2; diff --git a/patches/minecraft/net/minecraft/world/entity/animal/horse/AbstractHorse.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/equine/AbstractHorse.java.patch similarity index 64% rename from patches/minecraft/net/minecraft/world/entity/animal/horse/AbstractHorse.java.patch rename to patches/minecraft/net/minecraft/world/entity/animal/equine/AbstractHorse.java.patch index f0b5f6ae76..e61dec3c31 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/horse/AbstractHorse.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/equine/AbstractHorse.java.patch @@ -1,5 +1,5 @@ ---- a/net/minecraft/world/entity/animal/horse/AbstractHorse.java -+++ b/net/minecraft/world/entity/animal/horse/AbstractHorse.java +--- a/net/minecraft/world/entity/animal/equine/AbstractHorse.java ++++ b/net/minecraft/world/entity/animal/equine/AbstractHorse.java @@ -140,6 +_,7 @@ } @@ -8,48 +8,48 @@ } protected void addBehaviourGoals() { -@@ -275,6 +_,11 @@ +@@ -274,6 +_,11 @@ @Override - public boolean causeFallDamage(double p_391990_, float p_149499_, DamageSource p_149501_) { -+ var event = net.minecraftforge.event.ForgeEventFactory.onLivingFall(this, p_391990_, p_149499_); + public boolean causeFallDamage(double p_454114_, float p_458836_, DamageSource p_450439_) { ++ var event = net.minecraftforge.event.ForgeEventFactory.onLivingFall(this, p_454114_, p_458836_); + if (event == null) return false; -+ p_391990_ = event.getDistance(); -+ p_149499_ = event.getDamageMultiplier(); ++ p_454114_ = event.getDistance(); ++ p_458836_ = event.getDamageMultiplier(); + - if (p_391990_ > 1.0) { + if (p_454114_ > 1.0) { this.playSound(SoundEvents.HORSE_LAND, 0.4F, 1.0F); } -@@ -346,9 +_,9 @@ - protected void playStepSound(BlockPos p_30584_, BlockState p_30585_) { - if (!p_30585_.liquid()) { - BlockState blockstate = this.level().getBlockState(p_30584_.above()); -- SoundType soundtype = p_30585_.getSoundType(); -+ SoundType soundtype = p_30585_.getSoundType(level(), p_30584_, this); +@@ -339,9 +_,9 @@ + protected void playStepSound(BlockPos p_457686_, BlockState p_459257_) { + if (!p_459257_.liquid()) { + BlockState blockstate = this.level().getBlockState(p_457686_.above()); +- SoundType soundtype = p_459257_.getSoundType(); ++ SoundType soundtype = p_459257_.getSoundType(level(), p_457686_, this); if (blockstate.is(Blocks.SNOW)) { - soundtype = blockstate.getSoundType(); -+ soundtype = blockstate.getSoundType(level(), p_30584_.above(), this); ++ soundtype = blockstate.getSoundType(level(), p_457686_.above(), this); } if (this.isVehicle() && this.canGallop) { -@@ -777,6 +_,7 @@ +@@ -773,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_)); + this.setDeltaMovement(this.getDeltaMovement().add(-0.4F * f * p_452386_, 0.0, 0.4F * f1 * p_452386_)); } + net.minecraftforge.common.ForgeHooks.onLivingJump(this); } protected void playJumpSound() { -@@ -1019,6 +_,26 @@ +@@ -1013,6 +_,26 @@ - public boolean hasInventoryChanged(Container p_149512_) { - return this.inventory != p_149512_; + public boolean hasInventoryChanged(Container p_457588_) { + return this.inventory != p_457588_; + } + + private net.minecraftforge.common.util.LazyOptional itemHandler = null; + + @Override -+ public net.minecraftforge.common.util.LazyOptional getCapability(net.minecraftforge.common.capabilities.Capability capability, @Nullable net.minecraft.core.Direction facing) { ++ public net.minecraftforge.common.util.LazyOptional getCapability(net.minecraftforge.common.capabilities.Capability capability, net.minecraft.core.@Nullable Direction facing) { + if (capability == net.minecraftforge.common.capabilities.ForgeCapabilities.ITEM_HANDLER && itemHandler != null && this.isAlive()) { + return itemHandler.cast(); + } diff --git a/patches/minecraft/net/minecraft/world/entity/animal/equine/Llama.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/equine/Llama.java.patch new file mode 100644 index 0000000000..217f52ceec --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/animal/equine/Llama.java.patch @@ -0,0 +1,13 @@ +--- a/net/minecraft/world/entity/animal/equine/Llama.java ++++ b/net/minecraft/world/entity/animal/equine/Llama.java +@@ -370,6 +_,10 @@ + + @Override + public boolean causeFallDamage(double p_455330_, float p_456237_, DamageSource p_451412_) { ++ var event = net.minecraftforge.event.ForgeEventFactory.onLivingFall(this, p_455330_, p_456237_); ++ if (event == null) return false; ++ p_455330_ = event.getDistance(); ++ p_456237_ = event.getDamageMultiplier(); + int i = this.calculateFallDamage(p_455330_, p_456237_); + if (i <= 0) { + return false; diff --git a/patches/minecraft/net/minecraft/world/entity/animal/horse/SkeletonTrapGoal.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/equine/SkeletonTrapGoal.java.patch similarity index 83% rename from patches/minecraft/net/minecraft/world/entity/animal/horse/SkeletonTrapGoal.java.patch rename to patches/minecraft/net/minecraft/world/entity/animal/equine/SkeletonTrapGoal.java.patch index 2400f2c96e..09b0dbd893 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/horse/SkeletonTrapGoal.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/equine/SkeletonTrapGoal.java.patch @@ -1,5 +1,5 @@ ---- a/net/minecraft/world/entity/animal/horse/SkeletonTrapGoal.java -+++ b/net/minecraft/world/entity/animal/horse/SkeletonTrapGoal.java +--- a/net/minecraft/world/entity/animal/equine/SkeletonTrapGoal.java ++++ b/net/minecraft/world/entity/animal/equine/SkeletonTrapGoal.java @@ -31,6 +_,13 @@ @Override public void tick() { diff --git a/patches/minecraft/net/minecraft/world/entity/animal/Cat.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/feline/Cat.java.patch similarity index 64% rename from patches/minecraft/net/minecraft/world/entity/animal/Cat.java.patch rename to patches/minecraft/net/minecraft/world/entity/animal/feline/Cat.java.patch index ab69f2c59d..cb8fd80ef2 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/Cat.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/feline/Cat.java.patch @@ -1,23 +1,23 @@ ---- a/net/minecraft/world/entity/animal/Cat.java -+++ b/net/minecraft/world/entity/animal/Cat.java +--- a/net/minecraft/world/entity/animal/feline/Cat.java ++++ b/net/minecraft/world/entity/animal/feline/Cat.java @@ -385,10 +_,10 @@ } } else if (this.isFood(itemstack) && this.getHealth() < this.getMaxHealth()) { if (!this.level().isClientSide()) { -- this.usePlayerItem(p_28153_, p_28154_, itemstack); +- this.usePlayerItem(p_460113_, p_450900_, itemstack); FoodProperties foodproperties = itemstack.get(DataComponents.FOOD); this.heal(foodproperties != null ? foodproperties.nutrition() : 1.0F); this.playEatingSound(); -+ this.usePlayerItem(p_28153_, p_28154_, itemstack); ++ this.usePlayerItem(p_460113_, p_450900_, itemstack); } return InteractionResult.SUCCESS; @@ -449,7 +_,7 @@ } - private void tryToTame(Player p_333297_) { + private void tryToTame(Player p_451247_) { - if (this.random.nextInt(3) == 0) { -+ if (this.random.nextInt(3) == 0 && !net.minecraftforge.event.ForgeEventFactory.onAnimalTame(this, p_333297_)) { - this.tame(p_333297_); ++ if (this.random.nextInt(3) == 0 && !net.minecraftforge.event.ForgeEventFactory.onAnimalTame(this, p_451247_)) { + this.tame(p_451247_); this.setOrderedToSit(true); this.level().broadcastEntityEvent(this, (byte)7); diff --git a/patches/minecraft/net/minecraft/world/entity/animal/Ocelot.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/feline/Ocelot.java.patch similarity index 55% rename from patches/minecraft/net/minecraft/world/entity/animal/Ocelot.java.patch rename to patches/minecraft/net/minecraft/world/entity/animal/feline/Ocelot.java.patch index e08a8b2a62..b4cc899f23 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/Ocelot.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/feline/Ocelot.java.patch @@ -1,11 +1,11 @@ ---- a/net/minecraft/world/entity/animal/Ocelot.java -+++ b/net/minecraft/world/entity/animal/Ocelot.java +--- a/net/minecraft/world/entity/animal/feline/Ocelot.java ++++ b/net/minecraft/world/entity/animal/feline/Ocelot.java @@ -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.temptGoal == null || this.temptGoal.isRunning()) && !this.isTrusting() && this.isFood(itemstack) && p_454842_.distanceToSqr(this) < 9.0) { + this.usePlayerItem(p_454842_, p_450856_, itemstack); if (!this.level().isClientSide()) { - if (this.random.nextInt(3) == 0) { -+ if (this.random.nextInt(3) == 0 && !net.minecraftforge.event.ForgeEventFactory.onAnimalTame(this, p_29021_)) { ++ if (this.random.nextInt(3) == 0 && !net.minecraftforge.event.ForgeEventFactory.onAnimalTame(this, p_454842_)) { this.setTrusting(true); this.spawnTrustingParticles(true); this.level().broadcastEntityEvent(this, (byte)41); diff --git a/patches/minecraft/net/minecraft/world/entity/animal/Fox.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/fox/Fox.java.patch similarity index 83% rename from patches/minecraft/net/minecraft/world/entity/animal/Fox.java.patch rename to patches/minecraft/net/minecraft/world/entity/animal/fox/Fox.java.patch index 892a02f540..2f19bdfa0c 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/Fox.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/fox/Fox.java.patch @@ -1,9 +1,9 @@ ---- a/net/minecraft/world/entity/animal/Fox.java -+++ b/net/minecraft/world/entity/animal/Fox.java -@@ -855,6 +_,17 @@ +--- a/net/minecraft/world/entity/animal/fox/Fox.java ++++ b/net/minecraft/world/entity/animal/fox/Fox.java +@@ -861,6 +_,17 @@ + @Override protected void breed() { - ServerLevel serverlevel = this.level; - Fox fox = (Fox)this.animal.getBreedOffspring(serverlevel, this.partner); + Fox fox = (Fox)this.animal.getBreedOffspring(this.level, this.partner); + var event = new net.minecraftforge.event.entity.living.BabyEntitySpawnEvent(animal, partner, fox); + var eventWasCancelled = net.minecraftforge.event.entity.living.BabyEntitySpawnEvent.BUS.post(event); + fox = (Fox)event.getChild(); @@ -18,16 +18,16 @@ if (fox != null) { ServerPlayer serverplayer = this.animal.getLoveCause(); ServerPlayer serverplayer1 = this.partner.getLoveCause(); -@@ -938,7 +_,7 @@ +@@ -944,7 +_,7 @@ } protected void onReachedTarget() { -- if (getServerLevel(Fox.this.level()).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { +- if (getServerLevel(Fox.this.level()).getGameRules().get(GameRules.MOB_GRIEFING)) { + if (net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(getServerLevel(Fox.this.level()), Fox.this)) { BlockState blockstate = Fox.this.level().getBlockState(this.blockPos); if (blockstate.is(Blocks.SWEET_BERRY_BUSH)) { this.pickSweetBerries(blockstate); -@@ -997,7 +_,7 @@ +@@ -1003,7 +_,7 @@ @Override public boolean canUse() { diff --git a/patches/minecraft/net/minecraft/world/entity/animal/coppergolem/CopperGolem.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/golem/CopperGolem.java.patch similarity index 80% rename from patches/minecraft/net/minecraft/world/entity/animal/coppergolem/CopperGolem.java.patch rename to patches/minecraft/net/minecraft/world/entity/animal/golem/CopperGolem.java.patch index de161db9c8..0db0866f67 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/coppergolem/CopperGolem.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/golem/CopperGolem.java.patch @@ -1,6 +1,6 @@ ---- a/net/minecraft/world/entity/animal/coppergolem/CopperGolem.java -+++ b/net/minecraft/world/entity/animal/coppergolem/CopperGolem.java -@@ -216,7 +_,7 @@ +--- a/net/minecraft/world/entity/animal/golem/CopperGolem.java ++++ b/net/minecraft/world/entity/animal/golem/CopperGolem.java +@@ -213,7 +_,7 @@ } Level level = this.level(); @@ -8,11 +8,11 @@ + if (false && itemstack.is(Items.SHEARS) && this.readyForShearing()) { // Forge: Moved to onSheared if (level instanceof ServerLevel serverlevel) { this.shear(serverlevel, SoundSource.PLAYERS, itemstack); - this.gameEvent(GameEvent.SHEAR, p_430585_); -@@ -429,6 +_,18 @@ + this.gameEvent(GameEvent.SHEAR, p_458561_); +@@ -427,6 +_,18 @@ ItemStack itemstack = this.getItemBySlot(EQUIPMENT_SLOT_ANTENNA); this.setItemSlot(EQUIPMENT_SLOT_ANTENNA, ItemStack.EMPTY); - this.spawnAtLocation(p_428037_, itemstack, 1.5F); + this.spawnAtLocation(p_459970_, itemstack, 1.5F); + } + + @Override diff --git a/patches/minecraft/net/minecraft/world/entity/animal/SnowGolem.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/golem/SnowGolem.java.patch similarity index 78% rename from patches/minecraft/net/minecraft/world/entity/animal/SnowGolem.java.patch rename to patches/minecraft/net/minecraft/world/entity/animal/golem/SnowGolem.java.patch index e3caa5a0df..97d5aa552e 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/SnowGolem.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/golem/SnowGolem.java.patch @@ -1,8 +1,8 @@ ---- a/net/minecraft/world/entity/animal/SnowGolem.java -+++ b/net/minecraft/world/entity/animal/SnowGolem.java +--- a/net/minecraft/world/entity/animal/golem/SnowGolem.java ++++ b/net/minecraft/world/entity/animal/golem/SnowGolem.java @@ -42,7 +_,7 @@ - import net.minecraft.world.level.storage.loot.BuiltInLootTables; import net.minecraft.world.phys.Vec3; + import org.jspecify.annotations.Nullable; -public class SnowGolem extends AbstractGolem implements Shearable, RangedAttackMob { +public class SnowGolem extends AbstractGolem implements Shearable, RangedAttackMob, net.minecraftforge.common.IForgeShearable { @@ -13,7 +13,7 @@ this.hurtServer(serverlevel, this.damageSources().onFire(), 1.0F); } -- if (!serverlevel.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { +- if (!serverlevel.getGameRules().get(GameRules.MOB_GRIEFING)) { + if (!net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(serverlevel, this)) { return; } @@ -29,21 +29,20 @@ } @@ -136,7 +_,7 @@ @Override - protected InteractionResult mobInteract(Player p_29920_, InteractionHand p_29921_) { - ItemStack itemstack = p_29920_.getItemInHand(p_29921_); + protected InteractionResult mobInteract(Player p_458095_, InteractionHand p_457948_) { + ItemStack itemstack = p_458095_.getItemInHand(p_457948_); - if (itemstack.is(Items.SHEARS) && this.readyForShearing()) { + if (false && itemstack.is(Items.SHEARS) && this.readyForShearing()) { //Forge: Moved to onSheared if (this.level() instanceof ServerLevel serverlevel) { this.shear(serverlevel, SoundSource.PLAYERS, itemstack); - this.gameEvent(GameEvent.SHEAR, p_29920_); -@@ -196,4 +_,18 @@ + this.gameEvent(GameEvent.SHEAR, p_458095_); +@@ -193,4 +_,17 @@ public Vec3 getLeashOffset() { return new Vec3(0.0, 0.75F * this.getEyeHeight(), this.getBbWidth() * 0.4F); } + -+ @org.jetbrains.annotations.NotNull + @Override -+ public java.util.List onSheared(@Nullable Player player, @org.jetbrains.annotations.NotNull ItemStack item, Level world, BlockPos pos, int fortune) { ++ public java.util.@org.jspecify.annotations.NonNull List onSheared(@Nullable Player player, @org.jspecify.annotations.NonNull ItemStack item, Level world, BlockPos pos, int fortune) { + world.playSound(null, this, SoundEvents.SNOW_GOLEM_SHEAR, player == null ? SoundSource.BLOCKS : SoundSource.PLAYERS, 1.0F, 1.0F); + this.gameEvent(GameEvent.SHEAR, player); + if (!world.isClientSide() && world instanceof ServerLevel server) { diff --git a/patches/minecraft/net/minecraft/world/entity/animal/horse/Llama.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/horse/Llama.java.patch deleted file mode 100644 index 954890c9a4..0000000000 --- a/patches/minecraft/net/minecraft/world/entity/animal/horse/Llama.java.patch +++ /dev/null @@ -1,13 +0,0 @@ ---- a/net/minecraft/world/entity/animal/horse/Llama.java -+++ b/net/minecraft/world/entity/animal/horse/Llama.java -@@ -375,6 +_,10 @@ - - @Override - public boolean causeFallDamage(double p_396436_, float p_149538_, DamageSource p_149540_) { -+ var event = net.minecraftforge.event.ForgeEventFactory.onLivingFall(this, p_396436_, p_149538_); -+ if (event == null) return false; -+ p_396436_ = event.getDistance(); -+ p_149538_ = event.getDamageMultiplier(); - int i = this.calculateFallDamage(p_396436_, p_149538_); - if (i <= 0) { - return false; diff --git a/patches/minecraft/net/minecraft/world/entity/animal/Parrot.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/parrot/Parrot.java.patch similarity index 53% rename from patches/minecraft/net/minecraft/world/entity/animal/Parrot.java.patch rename to patches/minecraft/net/minecraft/world/entity/animal/parrot/Parrot.java.patch index c89d18f37c..d83d5a27f0 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/Parrot.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/parrot/Parrot.java.patch @@ -1,11 +1,11 @@ ---- a/net/minecraft/world/entity/animal/Parrot.java -+++ b/net/minecraft/world/entity/animal/Parrot.java -@@ -264,7 +_,7 @@ +--- a/net/minecraft/world/entity/animal/parrot/Parrot.java ++++ b/net/minecraft/world/entity/animal/parrot/Parrot.java +@@ -277,7 +_,7 @@ } 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_); ++ if (this.random.nextInt(10) == 0 && !net.minecraftforge.event.ForgeEventFactory.onAnimalTame(this, p_453025_)) { + this.tame(p_453025_); this.level().broadcastEntityEvent(this, (byte)7); } else { diff --git a/patches/minecraft/net/minecraft/world/entity/animal/pig/Pig.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/pig/Pig.java.patch new file mode 100644 index 0000000000..e5df2dd490 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/animal/pig/Pig.java.patch @@ -0,0 +1,15 @@ +--- a/net/minecraft/world/entity/animal/pig/Pig.java ++++ b/net/minecraft/world/entity/animal/pig/Pig.java +@@ -172,10 +_,11 @@ + + @Override + public void thunderHit(ServerLevel p_452901_, LightningBolt p_454063_) { +- if (p_452901_.getDifficulty() != Difficulty.PEACEFUL) { ++ if (p_452901_.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_456410_ -> { + p_456410_.populateDefaultEquipmentSlots(this.getRandom(), p_452901_.getCurrentDifficultyAt(this.blockPosition())); + p_456410_.setPersistenceRequired(); ++ net.minecraftforge.event.ForgeEventFactory.onLivingConvert(this, p_456410_); + }); + if (zombifiedpiglin == null) { + super.thunderHit(p_452901_, p_454063_); diff --git a/patches/minecraft/net/minecraft/world/entity/animal/Rabbit.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/rabbit/Rabbit.java.patch similarity index 67% rename from patches/minecraft/net/minecraft/world/entity/animal/Rabbit.java.patch rename to patches/minecraft/net/minecraft/world/entity/animal/rabbit/Rabbit.java.patch index f78e9b8fe0..4634f3740d 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/Rabbit.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/rabbit/Rabbit.java.patch @@ -1,20 +1,20 @@ ---- a/net/minecraft/world/entity/animal/Rabbit.java -+++ b/net/minecraft/world/entity/animal/Rabbit.java +--- a/net/minecraft/world/entity/animal/rabbit/Rabbit.java ++++ b/net/minecraft/world/entity/animal/rabbit/Rabbit.java @@ -555,7 +_,7 @@ @Override public boolean canUse() { if (this.nextStartTick <= 0) { -- if (!getServerLevel(this.rabbit).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { +- if (!getServerLevel(this.rabbit).getGameRules().get(GameRules.MOB_GRIEFING)) { + if (!net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(getServerLevel(this.rabbit.level()), this.rabbit)) { return false; } @@ -604,7 +_,7 @@ @Override - protected boolean isValidTarget(LevelReader p_29785_, BlockPos p_29786_) { - BlockState blockstate = p_29785_.getBlockState(p_29786_); + protected boolean isValidTarget(LevelReader p_457725_, BlockPos p_456006_) { + BlockState blockstate = p_457725_.getBlockState(p_456006_); - if (blockstate.is(Blocks.FARMLAND) && this.wantsToRaid && !this.canRaid) { + if (blockstate.getBlock() instanceof net.minecraft.world.level.block.FarmBlock && this.wantsToRaid && !this.canRaid) { - blockstate = p_29785_.getBlockState(p_29786_.above()); + blockstate = p_457725_.getBlockState(p_456006_.above()); if (blockstate.getBlock() instanceof CarrotBlock && ((CarrotBlock)blockstate.getBlock()).isMaxAge(blockstate)) { this.canRaid = true; diff --git a/patches/minecraft/net/minecraft/world/entity/animal/wolf/Wolf.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/wolf/Wolf.java.patch index 3d9b8106d1..1551ac29e7 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/wolf/Wolf.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/wolf/Wolf.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/wolf/Wolf.java +++ b/net/minecraft/world/entity/animal/wolf/Wolf.java -@@ -503,7 +_,7 @@ +@@ -502,7 +_,7 @@ } private void tryToTame(Player p_397321_) { diff --git a/patches/minecraft/net/minecraft/world/entity/boss/EnderDragonPart.java.patch b/patches/minecraft/net/minecraft/world/entity/boss/EnderDragonPart.java.patch deleted file mode 100644 index ca8cc470d8..0000000000 --- a/patches/minecraft/net/minecraft/world/entity/boss/EnderDragonPart.java.patch +++ /dev/null @@ -1,18 +0,0 @@ ---- a/net/minecraft/world/entity/boss/EnderDragonPart.java -+++ b/net/minecraft/world/entity/boss/EnderDragonPart.java -@@ -15,13 +_,13 @@ - import net.minecraft.world.level.storage.ValueInput; - import net.minecraft.world.level.storage.ValueOutput; - --public class EnderDragonPart extends Entity { -+public class EnderDragonPart extends net.minecraftforge.entity.PartEntity { - public final EnderDragon parentMob; - public final String name; - private final EntityDimensions size; - - public EnderDragonPart(EnderDragon p_31014_, String p_31015_, float p_31016_, float p_31017_) { -- super(p_31014_.getType(), p_31014_.level()); -+ super(p_31014_); - this.size = EntityDimensions.scalable(p_31016_, p_31017_); - this.refreshDimensions(); - this.parentMob = p_31014_; 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 afcf3ad431..2af7337ff7 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 @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java +++ b/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java -@@ -105,6 +_,15 @@ +@@ -102,6 +_,15 @@ this.setHealth(this.getMaxHealth()); this.noPhysics = true; this.phaseManager = new EnderDragonPhaseManager(this); @@ -16,11 +16,11 @@ } public void setDragonFight(EndDragonFight p_287736_) { -@@ -153,8 +_,26 @@ +@@ -150,8 +_,26 @@ p_330342_.define(DATA_PHASE, EnderDragonPhase.HOVERING.getId()); } -+ private @Nullable net.minecraft.world.entity.EntityReference unlimitedLastHurtByPlayer = null; ++ private net.minecraft.world.entity.@Nullable EntityReference unlimitedLastHurtByPlayer = null; + private @Nullable Player getUnlimitedLastHurtByPlayer() { + return net.minecraft.world.entity.EntityReference.get(this.unlimitedLastHurtByPlayer, this.level(), Player.class); + } @@ -43,36 +43,36 @@ this.processFlappingMovement(); if (this.level().isClientSide()) { this.setHealth(this.getHealth()); -@@ -441,7 +_,7 @@ +@@ -438,7 +_,7 @@ BlockPos blockpos = new BlockPos(k1, l1, i2); BlockState blockstate = p_363273_.getBlockState(blockpos); if (!blockstate.isAir() && !blockstate.is(BlockTags.DRAGON_TRANSPARENT)) { -- if (p_363273_.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) && !blockstate.is(BlockTags.DRAGON_IMMUNE)) { +- if (p_363273_.getGameRules().get(GameRules.MOB_GRIEFING) && !blockstate.is(BlockTags.DRAGON_IMMUNE)) { + if (net.minecraftforge.common.ForgeHooks.canEntityDestroy(p_363273_, blockpos, this) && !blockstate.is(BlockTags.DRAGON_IMMUNE)) { flag1 = p_363273_.removeBlock(blockpos, false) || flag1; } else { flag = true; -@@ -535,7 +_,8 @@ +@@ -532,7 +_,8 @@ if (this.level() instanceof ServerLevel serverlevel) { - if (this.dragonDeathTime > 150 && this.dragonDeathTime % 5 == 0 && serverlevel.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { + if (this.dragonDeathTime > 150 && this.dragonDeathTime % 5 == 0 && serverlevel.getGameRules().get(GameRules.MOB_DROPS)) { - ExperienceOrb.award(serverlevel, this.position(), Mth.floor(i * 0.08F)); + int award = net.minecraftforge.event.ForgeEventFactory.getExperienceDrop(this, this.getUnlimitedLastHurtByPlayer(), Mth.floor((float)i * 0.08F)); + ExperienceOrb.award(serverlevel, this.position(), award); } if (this.dragonDeathTime == 1 && !this.isSilent()) { -@@ -553,7 +_,8 @@ +@@ -550,7 +_,8 @@ if (this.dragonDeathTime == 200 && this.level() instanceof ServerLevel serverlevel1) { - if (serverlevel1.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { + if (serverlevel1.getGameRules().get(GameRules.MOB_DROPS)) { - ExperienceOrb.award(serverlevel1, this.position(), Mth.floor(i * 0.2F)); + int award = net.minecraftforge.event.ForgeEventFactory.getExperienceDrop(this, this.getUnlimitedLastHurtByPlayer(), Mth.floor((float)i * 0.2F)); + ExperienceOrb.award(serverlevel1, this.position(), award); } if (this.dragonFight != null) { -@@ -861,6 +_,7 @@ +@@ -856,6 +_,7 @@ @Override public void recreateFromPacket(ClientboundAddEntityPacket p_218825_) { super.recreateFromPacket(p_218825_); @@ -80,7 +80,7 @@ EnderDragonPart[] aenderdragonpart = this.getSubEntities(); for (int i = 0; i < aenderdragonpart.length; i++) { -@@ -876,5 +_,15 @@ +@@ -871,5 +_,15 @@ @Override protected float sanitizeScale(float p_333905_) { return 1.0F; diff --git a/patches/minecraft/net/minecraft/world/entity/boss/enderdragon/EnderDragonPart.java.patch b/patches/minecraft/net/minecraft/world/entity/boss/enderdragon/EnderDragonPart.java.patch new file mode 100644 index 0000000000..35f83b43b5 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/boss/enderdragon/EnderDragonPart.java.patch @@ -0,0 +1,18 @@ +--- a/net/minecraft/world/entity/boss/enderdragon/EnderDragonPart.java ++++ b/net/minecraft/world/entity/boss/enderdragon/EnderDragonPart.java +@@ -14,13 +_,13 @@ + import net.minecraft.world.level.storage.ValueOutput; + import org.jspecify.annotations.Nullable; + +-public class EnderDragonPart extends Entity { ++public class EnderDragonPart extends net.minecraftforge.entity.PartEntity { + public final EnderDragon parentMob; + public final String name; + private final EntityDimensions size; + + public EnderDragonPart(EnderDragon p_450227_, String p_453842_, float p_460816_, float p_454700_) { +- super(p_450227_.getType(), p_450227_.level()); ++ super(p_450227_); + this.size = EntityDimensions.scalable(p_460816_, p_454700_); + this.refreshDimensions(); + this.parentMob = p_450227_; diff --git a/patches/minecraft/net/minecraft/world/entity/boss/wither/WitherBoss.java.patch b/patches/minecraft/net/minecraft/world/entity/boss/wither/WitherBoss.java.patch index 2e0a872977..334415faa9 100644 --- a/patches/minecraft/net/minecraft/world/entity/boss/wither/WitherBoss.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/boss/wither/WitherBoss.java.patch @@ -4,7 +4,7 @@ if (this.destroyBlocksTick > 0) { this.destroyBlocksTick--; -- if (this.destroyBlocksTick == 0 && p_363567_.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { +- if (this.destroyBlocksTick == 0 && p_363567_.getGameRules().get(GameRules.MOB_GRIEFING)) { + if (this.destroyBlocksTick == 0 && net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(p_363567_, this)) { boolean flag = false; int l = Mth.floor(this.getBbWidth() / 2.0F + 1.0F); 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 696fde38ca..b5044da5c6 100644 --- a/patches/minecraft/net/minecraft/world/entity/decoration/HangingEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/decoration/HangingEntity.java.patch @@ -2,9 +2,9 @@ +++ b/net/minecraft/world/entity/decoration/HangingEntity.java @@ -85,6 +_,8 @@ } else { - 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())) + boolean flag = BlockPos.betweenClosedStream(this.calculateSupportBox()).allMatch(p_449679_ -> { + BlockState blockstate = this.level().getBlockState(p_449679_); ++ if (net.minecraft.world.level.block.Block.canSupportCenter(this.level(), p_449679_, this.getDirection())) + return true; return blockstate.isSolid() || DiodeBlock.isDiode(blockstate); }); diff --git a/patches/minecraft/net/minecraft/world/entity/item/FallingBlockEntity.java.patch b/patches/minecraft/net/minecraft/world/entity/item/FallingBlockEntity.java.patch index 963fb1d315..e44ece6bb3 100644 --- a/patches/minecraft/net/minecraft/world/entity/item/FallingBlockEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/item/FallingBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/item/FallingBlockEntity.java +++ b/net/minecraft/world/entity/item/FallingBlockEntity.java -@@ -159,7 +_,7 @@ +@@ -158,7 +_,7 @@ if (this.level() instanceof ServerLevel serverlevel && (this.isAlive() || this.forceTickAfterTeleportToDuplicate)) { BlockPos blockpos = this.blockPosition(); boolean flag = this.blockState.getBlock() instanceof ConcretePowderBlock; @@ -9,7 +9,7 @@ double d0 = this.getDeltaMovement().lengthSqr(); if (flag && d0 > 1.0) { BlockHitResult blockhitresult = this.level() -@@ -172,7 +_,7 @@ +@@ -171,7 +_,7 @@ this ) ); 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 eb460e352a..1013d2a63e 100644 --- a/patches/minecraft/net/minecraft/world/entity/item/ItemEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/item/ItemEntity.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/entity/item/ItemEntity.java +++ b/net/minecraft/world/entity/item/ItemEntity.java -@@ -53,6 +_,10 @@ - @Nullable - private UUID target; +@@ -51,6 +_,10 @@ + private @Nullable EntityReference thrower; + private @Nullable UUID target; 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,7 +11,7 @@ public ItemEntity(EntityType p_31991_, Level p_31992_) { super(p_31991_, p_31992_); -@@ -70,6 +_,7 @@ +@@ -68,6 +_,7 @@ this.setPos(p_149664_, p_149665_, p_149666_); this.setDeltaMovement(p_149668_, p_149669_, p_149670_); this.setItem(p_149667_); @@ -19,7 +19,7 @@ } @Override -@@ -108,6 +_,7 @@ +@@ -105,6 +_,7 @@ @Override public void tick() { @@ -27,7 +27,7 @@ if (this.getItem().isEmpty()) { this.discard(); } else { -@@ -120,6 +_,10 @@ +@@ -117,6 +_,10 @@ this.yo = this.getY(); this.zo = this.getZ(); Vec3 vec3 = this.getDeltaMovement(); @@ -38,7 +38,7 @@ if (this.isInWater() && this.getFluidHeight(FluidTags.WATER) > 0.1F) { this.setUnderwaterMovement(); } else if (this.isInLava() && this.getFluidHeight(FluidTags.LAVA) > 0.1F) { -@@ -142,7 +_,8 @@ +@@ -139,7 +_,8 @@ this.applyEffectsFromBlocks(); float f = 0.98F; if (this.onGround()) { @@ -48,7 +48,7 @@ } this.setDeltaMovement(this.getDeltaMovement().multiply(f, 0.98, f)); -@@ -174,7 +_,16 @@ +@@ -171,7 +_,16 @@ } } @@ -66,7 +66,7 @@ this.discard(); } } -@@ -282,7 +_,7 @@ +@@ -279,7 +_,7 @@ this.health = (int)(this.health - p_362683_); this.gameEvent(GameEvent.ENTITY_DAMAGE, p_364841_.getEntity()); if (this.health <= 0) { @@ -75,7 +75,7 @@ this.discard(); } -@@ -300,6 +_,7 @@ +@@ -297,6 +_,7 @@ p_408006_.putShort("Health", (short)this.health); p_408006_.putShort("Age", (short)this.age); p_408006_.putShort("PickupDelay", (short)this.pickupDelay); @@ -83,7 +83,7 @@ EntityReference.store(this.thrower, p_408006_, "Thrower"); p_408006_.storeNullable("Owner", UUIDUtil.CODEC, this.target); if (!this.getItem().isEmpty()) { -@@ -312,6 +_,7 @@ +@@ -309,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); @@ -91,7 +91,7 @@ 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)); -@@ -323,10 +_,17 @@ +@@ -320,10 +_,17 @@ @Override public void playerTouch(Player p_32040_) { if (!this.level().isClientSide()) { @@ -110,7 +110,7 @@ p_32040_.take(this, i); if (itemstack.isEmpty()) { this.discard(); -@@ -419,7 +_,7 @@ +@@ -415,7 +_,7 @@ public void makeFakeItem() { this.setNeverPickUp(); diff --git a/patches/minecraft/net/minecraft/world/entity/monster/CrossbowAttackMob.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/CrossbowAttackMob.java.patch index 1d2bccf5be..51619b7261 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/CrossbowAttackMob.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/CrossbowAttackMob.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/CrossbowAttackMob.java +++ b/net/minecraft/world/entity/monster/CrossbowAttackMob.java -@@ -17,9 +_,10 @@ +@@ -16,9 +_,10 @@ void onCrossbowAttackPerformed(); default void performCrossbowAttack(LivingEntity p_32337_, float p_32338_) { 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 249c7ca4c9..673cfc7942 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 -@@ -118,7 +_,6 @@ +@@ -117,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; -@@ -132,6 +_,7 @@ +@@ -131,6 +_,7 @@ attributeinstance.addTransientModifier(SPEED_MODIFIER_ATTACKING); } } @@ -16,16 +16,16 @@ } @Override -@@ -205,7 +_,7 @@ +@@ -203,7 +_,7 @@ } boolean isBeingStaredBy(Player p_368759_) { -- return !LivingEntity.PLAYER_NOT_WEARING_DISGUISE_ITEM.test(p_368759_) ? false : this.isLookingAtMe(p_368759_, 0.025, true, false, new double[]{this.getEyeY()}); -+ return !net.minecraftforge.common.ForgeHooks.isNotDisguised(this).test(p_368759_) ? false : this.isLookingAtMe(p_368759_, 0.025, true, false, new double[]{this.getEyeY()}); +- return !LivingEntity.PLAYER_NOT_WEARING_DISGUISE_ITEM.test(p_368759_) ? false : this.isLookingAtMe(p_368759_, 0.025, true, false, this.getEyeY()); ++ return !net.minecraftforge.common.ForgeHooks.isNotDisguised(this).test(p_368759_) ? false : this.isLookingAtMe(p_368759_, 0.025, true, false, this.getEyeY()); } @Override -@@ -283,8 +_,10 @@ +@@ -281,8 +_,10 @@ boolean flag = blockstate.blocksMotion(); boolean flag1 = blockstate.getFluidState().is(FluidTags.WATER); if (flag && !flag1) { @@ -37,16 +37,16 @@ if (flag2) { this.level().gameEvent(GameEvent.TELEPORT, vec3, GameEvent.Context.of(this)); if (!this.isSilent()) { -@@ -439,7 +_,7 @@ +@@ -435,7 +_,7 @@ if (this.enderman.getCarriedBlock() == null) { return false; } else { -- return !getServerLevel(this.enderman).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) ? false : this.enderman.getRandom().nextInt(reducedTickDelay(2000)) == 0; +- return !getServerLevel(this.enderman).getGameRules().get(GameRules.MOB_GRIEFING) ? false : this.enderman.getRandom().nextInt(reducedTickDelay(2000)) == 0; + return !net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(getServerLevel(this.enderman), this.enderman) ? false : this.enderman.getRandom().nextInt(reducedTickDelay(2000)) == 0; } } -@@ -457,7 +_,7 @@ +@@ -453,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); -@@ -469,6 +_,7 @@ +@@ -465,6 +_,7 @@ return p_32562_.isAir() && !p_32563_.isAir() && !p_32563_.is(Blocks.BEDROCK) @@ -63,11 +63,11 @@ && 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(); -@@ -578,7 +_,7 @@ +@@ -573,7 +_,7 @@ if (this.enderman.getCarriedBlock() != null) { return false; } else { -- return !getServerLevel(this.enderman).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) ? false : this.enderman.getRandom().nextInt(reducedTickDelay(20)) == 0; +- return !getServerLevel(this.enderman).getGameRules().get(GameRules.MOB_GRIEFING) ? false : this.enderman.getRandom().nextInt(reducedTickDelay(20)) == 0; + return !net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(getServerLevel(this.enderman), this.enderman) ? false : this.enderman.getRandom().nextInt(reducedTickDelay(20)) == 0; } } diff --git a/patches/minecraft/net/minecraft/world/entity/monster/Husk.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/Husk.java.patch deleted file mode 100644 index 1d70eedfc3..0000000000 --- a/patches/minecraft/net/minecraft/world/entity/monster/Husk.java.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- a/net/minecraft/world/entity/monster/Husk.java -+++ b/net/minecraft/world/entity/monster/Husk.java -@@ -69,6 +_,7 @@ - - @Override - protected void doUnderWaterConversion() { -+ if (!net.minecraftforge.event.ForgeEventFactory.canLivingConvert(this, EntityType.ZOMBIE, (timer) -> this.conversionTime = timer)) return; - this.convertToZombieType(EntityType.ZOMBIE); - if (!this.isSilent()) { - this.level().levelEvent(null, 1041, this.blockPosition(), 0); diff --git a/patches/minecraft/net/minecraft/world/entity/monster/MagmaCube.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/MagmaCube.java.patch index ea351355dc..ed552dbb7d 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/MagmaCube.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/MagmaCube.java.patch @@ -3,7 +3,7 @@ @@ -71,17 +_,28 @@ float f = this.getSize() * 0.1F; this.setDeltaMovement(vec3.x, this.getJumpPower() + f, vec3.z); - this.hasImpulse = true; + this.needsSync = true; + net.minecraftforge.common.ForgeHooks.onLivingJump(this); } @@ -18,7 +18,7 @@ + if (isLava.getAsBoolean()) { Vec3 vec3 = this.getDeltaMovement(); this.setDeltaMovement(vec3.x, 0.22F + this.getSize() * 0.05F, vec3.z); - this.hasImpulse = true; + this.needsSync = true; } else { - super.jumpInLiquid(p_204065_); + onSuper.run(); 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 09801abc5a..00e83fbd78 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 -@@ -135,9 +_,9 @@ +@@ -141,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/Ravager.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/Ravager.java.patch index 6655aabc1a..782b6329a8 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/Ravager.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/Ravager.java.patch @@ -1,10 +1,10 @@ --- a/net/minecraft/world/entity/monster/Ravager.java +++ b/net/minecraft/world/entity/monster/Ravager.java -@@ -140,7 +_,7 @@ +@@ -141,7 +_,7 @@ this.getAttribute(Attributes.MOVEMENT_SPEED).setBaseValue(Mth.lerp(0.1, d1, d0)); } -- if (this.level() instanceof ServerLevel serverlevel && this.horizontalCollision && serverlevel.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { +- if (this.level() instanceof ServerLevel serverlevel && this.horizontalCollision && serverlevel.getGameRules().get(GameRules.MOB_GRIEFING)) { + if (this.level() instanceof ServerLevel serverlevel && this.horizontalCollision && net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(serverlevel, this)) { boolean flag = false; AABB aabb = this.getBoundingBox().inflate(0.2); diff --git a/patches/minecraft/net/minecraft/world/entity/monster/Shulker.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/Shulker.java.patch index a69bb29d87..e3bb41e013 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/Shulker.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/Shulker.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/Shulker.java +++ b/net/minecraft/world/entity/monster/Shulker.java -@@ -382,6 +_,12 @@ +@@ -381,6 +_,12 @@ && this.level().noCollision(this, new AABB(blockpos1).deflate(1.0E-6))) { Direction direction = this.findAttachableSurface(blockpos1); if (direction != null) { diff --git a/patches/minecraft/net/minecraft/world/entity/monster/Silverfish.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/Silverfish.java.patch index df57972b65..a0e2a28d16 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/Silverfish.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/Silverfish.java.patch @@ -1,19 +1,19 @@ --- a/net/minecraft/world/entity/monster/Silverfish.java +++ b/net/minecraft/world/entity/monster/Silverfish.java -@@ -141,7 +_,7 @@ +@@ -139,7 +_,7 @@ return false; } else { RandomSource randomsource = this.mob.getRandom(); -- if (getServerLevel(this.mob).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) && randomsource.nextInt(reducedTickDelay(10)) == 0) { +- if (getServerLevel(this.mob).getGameRules().get(GameRules.MOB_GRIEFING) && randomsource.nextInt(reducedTickDelay(10)) == 0) { + if (net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(getServerLevel(this.mob.level()), this.mob) && randomsource.nextInt(reducedTickDelay(10)) == 0) { this.selectedDirection = Direction.getRandom(randomsource); BlockPos blockpos = BlockPos.containing(this.mob.getX(), this.mob.getY() + 0.5, this.mob.getZ()) .relative(this.selectedDirection); -@@ -214,7 +_,7 @@ +@@ -212,7 +_,7 @@ BlockState blockstate = level.getBlockState(blockpos1); Block block = blockstate.getBlock(); if (block instanceof InfestedBlock) { -- if (getServerLevel(level).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { +- if (getServerLevel(level).getGameRules().get(GameRules.MOB_GRIEFING)) { + if (net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(getServerLevel(level), this.silverfish)) { level.destroyBlock(blockpos1, true, this.silverfish); } else { 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 0cf0501cc2..52b737e116 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 -@@ -143,13 +_,15 @@ +@@ -144,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; -@@ -160,6 +_,12 @@ +@@ -161,6 +_,12 @@ this.wasOnGround = this.onGround(); this.decreaseSquish(); } diff --git a/patches/minecraft/net/minecraft/world/entity/monster/Spider.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/Spider.java.patch deleted file mode 100644 index b1fdb80cad..0000000000 --- a/patches/minecraft/net/minecraft/world/entity/monster/Spider.java.patch +++ /dev/null @@ -1,14 +0,0 @@ ---- a/net/minecraft/world/entity/monster/Spider.java -+++ b/net/minecraft/world/entity/monster/Spider.java -@@ -121,7 +_,10 @@ - - @Override - public boolean canBeAffected(MobEffectInstance p_33809_) { -- return p_33809_.is(MobEffects.POISON) ? false : super.canBeAffected(p_33809_); -+ if (p_33809_.getEffect() == MobEffects.POISON) { -+ return net.minecraftforge.event.ForgeEventFactory.onLivingEffectCanApply(this, p_33809_).getResult().isAllowed(); -+ } -+ return super.canBeAffected(p_33809_); - } - - public boolean isClimbing() { 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 885b9e67b3..2e11deed21 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,11 +1,11 @@ --- a/net/minecraft/world/entity/monster/creaking/Creaking.java +++ b/net/minecraft/world/entity/monster/creaking/Creaking.java -@@ -482,7 +_,7 @@ +@@ -463,7 +_,7 @@ for (Player player : list) { if (this.canAttack(player) && !this.isAlliedTo(player)) { flag1 = true; - if ((!flag || LivingEntity.PLAYER_NOT_WEARING_DISGUISE_ITEM.test(player)) + if ((!flag || net.minecraftforge.common.ForgeHooks.isNotDisguised(this).test(player)) && this.isLookingAtMe( - player, - 0.5, + player, 0.5, false, true, this.getEyeY(), this.getY() + 0.5 * this.getScale(), (this.getEyeY() + this.getY()) / 2.0 + )) { 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 40c36b8855..13743c5da7 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 -@@ -169,7 +_,7 @@ +@@ -170,7 +_,7 @@ HoglinAi.updateActivity(this); if (this.isConverting()) { this.timeInOverworld++; @@ -9,7 +9,7 @@ this.makeSound(SoundEvents.HOGLIN_CONVERTED_TO_ZOMBIFIED); this.finishConversion(); } -@@ -267,7 +_,10 @@ +@@ -269,7 +_,10 @@ this.convertTo( EntityType.ZOGLIN, ConversionParams.single(this, true, false), diff --git a/patches/minecraft/net/minecraft/world/entity/monster/Evoker.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/illager/Evoker.java.patch similarity index 71% rename from patches/minecraft/net/minecraft/world/entity/monster/Evoker.java.patch rename to patches/minecraft/net/minecraft/world/entity/monster/illager/Evoker.java.patch index 8687ea3a52..1cda40db41 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/Evoker.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/illager/Evoker.java.patch @@ -1,10 +1,10 @@ ---- a/net/minecraft/world/entity/monster/Evoker.java -+++ b/net/minecraft/world/entity/monster/Evoker.java +--- a/net/minecraft/world/entity/monster/illager/Evoker.java ++++ b/net/minecraft/world/entity/monster/illager/Evoker.java @@ -283,7 +_,7 @@ return false; } else { ServerLevel serverlevel = getServerLevel(Evoker.this.level()); -- if (!serverlevel.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { +- if (!serverlevel.getGameRules().get(GameRules.MOB_GRIEFING)) { + if (!net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(serverlevel, Evoker.this)) { return false; } else { diff --git a/patches/minecraft/net/minecraft/world/entity/monster/Illusioner.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/illager/Illusioner.java.patch similarity index 55% rename from patches/minecraft/net/minecraft/world/entity/monster/Illusioner.java.patch rename to patches/minecraft/net/minecraft/world/entity/monster/illager/Illusioner.java.patch index 8a4c413884..abcaebf7bf 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/Illusioner.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/illager/Illusioner.java.patch @@ -1,16 +1,16 @@ ---- a/net/minecraft/world/entity/monster/Illusioner.java -+++ b/net/minecraft/world/entity/monster/Illusioner.java -@@ -169,9 +_,12 @@ +--- a/net/minecraft/world/entity/monster/illager/Illusioner.java ++++ b/net/minecraft/world/entity/monster/illager/Illusioner.java +@@ -171,9 +_,12 @@ @Override - public void performRangedAttack(LivingEntity p_32918_, float p_32919_) { + public void performRangedAttack(LivingEntity p_454025_, float p_457552_) { - ItemStack itemstack = this.getItemInHand(ProjectileUtil.getWeaponHoldingHand(this, Items.BOW)); + ItemStack itemstack = this.getItemInHand(ProjectileUtil.getWeaponHoldingHand(this, item -> item instanceof net.minecraft.world.item.BowItem)); ItemStack itemstack1 = this.getProjectile(itemstack); - AbstractArrow abstractarrow = ProjectileUtil.getMobArrow(this, itemstack1, p_32919_, itemstack); + AbstractArrow abstractarrow = ProjectileUtil.getMobArrow(this, itemstack1, p_457552_, itemstack); + if (this.getMainHandItem().getItem() instanceof net.minecraft.world.item.BowItem bow) { + abstractarrow = bow.customArrow(abstractarrow); + } - double d0 = p_32918_.getX() - this.getX(); - double d1 = p_32918_.getY(0.3333333333333333) - abstractarrow.getY(); - double d2 = p_32918_.getZ() - this.getZ(); + double d0 = p_454025_.getX() - this.getX(); + double d1 = p_454025_.getY(0.3333333333333333) - abstractarrow.getY(); + double d2 = p_454025_.getZ() - this.getZ(); diff --git a/patches/minecraft/net/minecraft/world/entity/monster/Pillager.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/illager/Pillager.java.patch similarity index 78% rename from patches/minecraft/net/minecraft/world/entity/monster/Pillager.java.patch rename to patches/minecraft/net/minecraft/world/entity/monster/illager/Pillager.java.patch index 24133b9380..3ef9ac836e 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/Pillager.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/illager/Pillager.java.patch @@ -1,6 +1,6 @@ ---- a/net/minecraft/world/entity/monster/Pillager.java -+++ b/net/minecraft/world/entity/monster/Pillager.java -@@ -128,7 +_,7 @@ +--- a/net/minecraft/world/entity/monster/illager/Pillager.java ++++ b/net/minecraft/world/entity/monster/illager/Pillager.java +@@ -129,7 +_,7 @@ public AbstractIllager.IllagerArmPose getArmPose() { if (this.isChargingCrossbow()) { return AbstractIllager.IllagerArmPose.CROSSBOW_CHARGE; 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 7d5a92347f..0477ac0a59 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 -@@ -82,7 +_,7 @@ +@@ -83,7 +_,7 @@ this.timeInOverworld = 0; } @@ -9,14 +9,14 @@ this.playConvertedSound(); this.finishConversion(p_360786_); } -@@ -101,7 +_,10 @@ +@@ -102,7 +_,10 @@ this.convertTo( EntityType.ZOMBIFIED_PIGLIN, ConversionParams.single(this, true, true), -- p_390698_ -> p_390698_.addEffect(new MobEffectInstance(MobEffects.NAUSEA, 200, 0)) -+ p_390698_ -> { -+ p_390698_.addEffect(new MobEffectInstance(MobEffects.NAUSEA, 200, 0)); -+ net.minecraftforge.event.ForgeEventFactory.onLivingConvert(this, p_390698_); +- p_449701_ -> p_449701_.addEffect(new MobEffectInstance(MobEffects.NAUSEA, 200, 0)) ++ p_449701_ -> { ++ p_449701_.addEffect(new MobEffectInstance(MobEffects.NAUSEA, 200, 0)); ++ net.minecraftforge.event.ForgeEventFactory.onLivingConvert(this, p_449701_); + } ); } 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 74b0ccff8a..7791f199c2 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 -@@ -345,7 +_,7 @@ +@@ -352,7 +_,7 @@ } else if (this.isChargingCrossbow()) { return PiglinArmPose.CROSSBOW_CHARGE; } else { @@ -9,7 +9,7 @@ } } -@@ -382,7 +_,7 @@ +@@ -389,7 +_,7 @@ } protected void holdInOffHand(ItemStack p_34786_) { @@ -18,11 +18,11 @@ this.setItemSlot(EquipmentSlot.OFFHAND, p_34786_); this.setGuaranteedDrop(EquipmentSlot.OFFHAND); } else { -@@ -392,7 +_,7 @@ +@@ -399,7 +_,7 @@ @Override public boolean wantsToPickUp(ServerLevel p_369934_, ItemStack p_34777_) { -- return p_369934_.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) && this.canPickUpLoot() && PiglinAi.wantsToPickup(this, p_34777_); +- return p_369934_.getGameRules().get(GameRules.MOB_GRIEFING) && this.canPickUpLoot() && PiglinAi.wantsToPickup(this, p_34777_); + return net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(p_369934_, this) && this.canPickUpLoot() && PiglinAi.wantsToPickup(this, p_34777_); } diff --git a/patches/minecraft/net/minecraft/world/entity/monster/piglin/PiglinAi.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/piglin/PiglinAi.java.patch index de9a55aa5c..48c1d69ac2 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/piglin/PiglinAi.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/piglin/PiglinAi.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/piglin/PiglinAi.java +++ b/net/minecraft/world/entity/monster/piglin/PiglinAi.java -@@ -634,7 +_,7 @@ +@@ -640,7 +_,7 @@ public static boolean isWearingSafeArmor(LivingEntity p_365495_) { for (EquipmentSlot equipmentslot : EquipmentSlotGroup.ARMOR) { @@ -9,7 +9,7 @@ return true; } } -@@ -778,7 +_,7 @@ +@@ -784,7 +_,7 @@ } private static boolean hasCrossbow(LivingEntity p_34919_) { @@ -18,7 +18,7 @@ } private static void admireGoldItem(LivingEntity p_34939_) { -@@ -790,7 +_,7 @@ +@@ -796,7 +_,7 @@ } private static boolean isBarterCurrency(ItemStack p_149968_) { diff --git a/patches/minecraft/net/minecraft/world/entity/monster/AbstractSkeleton.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/skeleton/AbstractSkeleton.java.patch similarity index 71% rename from patches/minecraft/net/minecraft/world/entity/monster/AbstractSkeleton.java.patch rename to patches/minecraft/net/minecraft/world/entity/monster/skeleton/AbstractSkeleton.java.patch index 96ea961747..29813ac679 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/AbstractSkeleton.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/skeleton/AbstractSkeleton.java.patch @@ -1,6 +1,6 @@ ---- a/net/minecraft/world/entity/monster/AbstractSkeleton.java -+++ b/net/minecraft/world/entity/monster/AbstractSkeleton.java -@@ -161,7 +_,7 @@ +--- a/net/minecraft/world/entity/monster/skeleton/AbstractSkeleton.java ++++ b/net/minecraft/world/entity/monster/skeleton/AbstractSkeleton.java +@@ -133,7 +_,7 @@ if (this.level() != null && !this.level().isClientSide()) { this.goalSelector.removeGoal(this.meleeGoal); this.goalSelector.removeGoal(this.bowGoal); @@ -9,17 +9,17 @@ if (itemstack.is(Items.BOW)) { int i = this.getHardAttackInterval(); if (this.level().getDifficulty() != Difficulty.HARD) { -@@ -186,9 +_,12 @@ +@@ -158,9 +_,12 @@ @Override - public void performRangedAttack(LivingEntity p_32141_, float p_32142_) { + public void performRangedAttack(LivingEntity p_454925_, float p_452827_) { - ItemStack itemstack = this.getItemInHand(ProjectileUtil.getWeaponHoldingHand(this, Items.BOW)); + ItemStack itemstack = this.getItemInHand(ProjectileUtil.getWeaponHoldingHand(this, item -> item instanceof net.minecraft.world.item.BowItem)); ItemStack itemstack1 = this.getProjectile(itemstack); - AbstractArrow abstractarrow = this.getArrow(itemstack1, p_32142_, itemstack); + AbstractArrow abstractarrow = this.getArrow(itemstack1, p_452827_, itemstack); + if (this.getMainHandItem().getItem() instanceof net.minecraft.world.item.BowItem bow) { + abstractarrow = bow.customArrow(abstractarrow); + } - double d0 = p_32141_.getX() - this.getX(); - double d1 = p_32141_.getY(0.3333333333333333) - abstractarrow.getY(); - double d2 = p_32141_.getZ() - this.getZ(); + double d0 = p_454925_.getX() - this.getX(); + double d1 = p_454925_.getY(0.3333333333333333) - abstractarrow.getY(); + double d2 = p_454925_.getZ() - this.getZ(); diff --git a/patches/minecraft/net/minecraft/world/entity/monster/Bogged.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/skeleton/Bogged.java.patch similarity index 75% rename from patches/minecraft/net/minecraft/world/entity/monster/Bogged.java.patch rename to patches/minecraft/net/minecraft/world/entity/monster/skeleton/Bogged.java.patch index d66a368143..e89e35c83f 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/Bogged.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/skeleton/Bogged.java.patch @@ -1,15 +1,15 @@ ---- a/net/minecraft/world/entity/monster/Bogged.java -+++ b/net/minecraft/world/entity/monster/Bogged.java -@@ -72,7 +_,7 @@ +--- a/net/minecraft/world/entity/monster/skeleton/Bogged.java ++++ b/net/minecraft/world/entity/monster/skeleton/Bogged.java +@@ -70,7 +_,7 @@ @Override - protected InteractionResult mobInteract(Player p_335303_, InteractionHand p_335145_) { - ItemStack itemstack = p_335303_.getItemInHand(p_335145_); + protected InteractionResult mobInteract(Player p_453508_, InteractionHand p_459904_) { + ItemStack itemstack = p_453508_.getItemInHand(p_459904_); - if (itemstack.is(Items.SHEARS) && this.readyForShearing()) { + if (false && itemstack.is(Items.SHEARS) && this.readyForShearing()) { // Forge: move to onSheared if (this.level() instanceof ServerLevel serverlevel) { this.shear(serverlevel, SoundSource.PLAYERS, itemstack); - this.gameEvent(GameEvent.SHEAR, p_335303_); -@@ -139,5 +_,17 @@ + this.gameEvent(GameEvent.SHEAR, p_453508_); +@@ -137,5 +_,17 @@ @Override public boolean readyForShearing() { return !this.isSheared() && this.isAlive(); diff --git a/patches/minecraft/net/minecraft/world/entity/monster/Skeleton.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/skeleton/Skeleton.java.patch similarity index 70% rename from patches/minecraft/net/minecraft/world/entity/monster/Skeleton.java.patch rename to patches/minecraft/net/minecraft/world/entity/monster/skeleton/Skeleton.java.patch index c850bca21b..8dec6712af 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/Skeleton.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/skeleton/Skeleton.java.patch @@ -1,10 +1,10 @@ ---- a/net/minecraft/world/entity/monster/Skeleton.java -+++ b/net/minecraft/world/entity/monster/Skeleton.java +--- a/net/minecraft/world/entity/monster/skeleton/Skeleton.java ++++ b/net/minecraft/world/entity/monster/skeleton/Skeleton.java @@ -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_421860_ -> { + this.convertTo(EntityType.STRAY, ConversionParams.single(this, true, true), p_451505_ -> { if (!this.isSilent()) { this.level().levelEvent(null, 1048, this.blockPosition(), 0); diff --git a/patches/minecraft/net/minecraft/world/entity/monster/spider/Spider.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/spider/Spider.java.patch new file mode 100644 index 0000000000..aed72331a5 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/monster/spider/Spider.java.patch @@ -0,0 +1,14 @@ +--- a/net/minecraft/world/entity/monster/spider/Spider.java ++++ b/net/minecraft/world/entity/monster/spider/Spider.java +@@ -123,7 +_,10 @@ + + @Override + public boolean canBeAffected(MobEffectInstance p_454269_) { +- return p_454269_.is(MobEffects.POISON) ? false : super.canBeAffected(p_454269_); ++ if (p_454269_.getEffect() == MobEffects.POISON) { ++ return net.minecraftforge.event.ForgeEventFactory.onLivingEffectCanApply(this, p_454269_).getResult().isAllowed(); ++ } ++ return super.canBeAffected(p_454269_); + } + + public boolean isClimbing() { diff --git a/patches/minecraft/net/minecraft/world/entity/monster/zombie/Husk.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/zombie/Husk.java.patch new file mode 100644 index 0000000000..7ac9964b75 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/monster/zombie/Husk.java.patch @@ -0,0 +1,10 @@ +--- a/net/minecraft/world/entity/monster/zombie/Husk.java ++++ b/net/minecraft/world/entity/monster/zombie/Husk.java +@@ -71,6 +_,7 @@ + + @Override + protected void doUnderWaterConversion(ServerLevel p_454240_) { ++ if (!net.minecraftforge.event.ForgeEventFactory.canLivingConvert(this, EntityType.ZOMBIE, (timer) -> this.conversionTime = timer)) return; + this.convertToZombieType(p_454240_, EntityType.ZOMBIE); + if (!this.isSilent()) { + p_454240_.levelEvent(null, 1041, this.blockPosition(), 0); diff --git a/patches/minecraft/net/minecraft/world/entity/monster/Zombie.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/zombie/Zombie.java.patch similarity index 52% rename from patches/minecraft/net/minecraft/world/entity/monster/Zombie.java.patch rename to patches/minecraft/net/minecraft/world/entity/monster/zombie/Zombie.java.patch index 00700ee984..0dc14522a4 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/Zombie.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/zombie/Zombie.java.patch @@ -1,50 +1,48 @@ ---- a/net/minecraft/world/entity/monster/Zombie.java -+++ b/net/minecraft/world/entity/monster/Zombie.java -@@ -264,21 +_,28 @@ +--- a/net/minecraft/world/entity/monster/zombie/Zombie.java ++++ b/net/minecraft/world/entity/monster/zombie/Zombie.java +@@ -237,19 +_,26 @@ } - protected void convertToZombieType(EntityType p_34311_) { -+ if (!net.minecraftforge.event.ForgeEventFactory.canLivingConvert(this, p_34311_, timer -> this.conversionTime = timer)) return; + protected void convertToZombieType(ServerLevel p_455508_, EntityType p_460671_) { ++ if (!net.minecraftforge.event.ForgeEventFactory.canLivingConvert(this, p_460671_, timer -> this.conversionTime = timer)) return; this.convertTo( - p_34311_, - ConversionParams.single(this, true, true), -- 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_); +- p_460671_, ConversionParams.single(this, true, true), p_451761_ -> p_451761_.handleAttributes(p_455508_.getCurrentDifficultyAt(p_451761_.blockPosition()).getSpecialMultiplier()) ++ p_460671_, ConversionParams.single(this, true, true), p_451761_ -> { ++ p_451761_.handleAttributes(p_455508_.getCurrentDifficultyAt(p_451761_.blockPosition()).getSpecialMultiplier()); ++ net.minecraftforge.event.ForgeEventFactory.onLivingConvert(this, p_451761_); + } ); } @VisibleForTesting - public boolean convertVillagerToZombieVillager(ServerLevel p_369430_, Villager p_360910_) { -+ if (!net.minecraftforge.event.ForgeEventFactory.canLivingConvert(p_360910_, EntityType.ZOMBIE_VILLAGER, (timer) -> {})) + public boolean convertVillagerToZombieVillager(ServerLevel p_454968_, Villager p_452932_) { ++ if (!net.minecraftforge.event.ForgeEventFactory.canLivingConvert(p_452932_, EntityType.ZOMBIE_VILLAGER, (timer) -> {})) + return false; - ZombieVillager zombievillager = p_360910_.convertTo(EntityType.ZOMBIE_VILLAGER, ConversionParams.single(p_360910_, true, true), p_359258_ -> { - p_359258_.finalizeSpawn(p_369430_, p_369430_.getCurrentDifficultyAt(p_359258_.blockPosition()), EntitySpawnReason.CONVERSION, new Zombie.ZombieGroupData(false, true)); - p_359258_.setVillagerData(p_360910_.getVillagerData()); - p_359258_.setGossips(p_360910_.getGossips().copy()); - p_359258_.setTradeOffers(p_360910_.getOffers().copy()); - p_359258_.setVillagerXp(p_360910_.getVillagerXp()); -+ net.minecraftforge.event.ForgeEventFactory.onLivingConvert(p_360910_, p_359258_); + ZombieVillager zombievillager = p_452932_.convertTo(EntityType.ZOMBIE_VILLAGER, ConversionParams.single(p_452932_, true, true), p_458247_ -> { + p_458247_.finalizeSpawn(p_454968_, p_454968_.getCurrentDifficultyAt(p_458247_.blockPosition()), EntitySpawnReason.CONVERSION, new Zombie.ZombieGroupData(false, true)); + p_458247_.setVillagerData(p_452932_.getVillagerData()); + p_458247_.setGossips(p_452932_.getGossips().copy()); + p_458247_.setTradeOffers(p_452932_.getOffers().copy()); + p_458247_.setVillagerXp(p_452932_.getVillagerXp()); ++ net.minecraftforge.event.ForgeEventFactory.onLivingConvert(p_452932_, p_458247_); if (!this.isSilent()) { - p_369430_.levelEvent(null, 1026, this.blockPosition(), 0); + p_454968_.levelEvent(null, 1026, this.blockPosition(), 0); } -@@ -300,19 +_,26 @@ - livingentity = (LivingEntity)p_363403_.getEntity(); +@@ -271,19 +_,26 @@ + livingentity = (LivingEntity)p_458181_.getEntity(); } - if (livingentity != null + var vanilla = (livingentity != null - && p_363771_.getDifficulty() == Difficulty.HARD + && p_452619_.getDifficulty() == Difficulty.HARD && this.random.nextFloat() < this.getAttributeValue(Attributes.SPAWN_REINFORCEMENTS_CHANCE) -- && p_363771_.isSpawningMonsters()) { -+ && p_363771_.isSpawningMonsters()); +- && p_452619_.isSpawningMonsters()) { ++ && p_452619_.isSpawningMonsters()); int i = Mth.floor(this.getX()); int j = Mth.floor(this.getY()); int k = Mth.floor(this.getZ()); EntityType entitytype = this.getType(); -- Zombie zombie = entitytype.create(p_363771_, EntitySpawnReason.REINFORCEMENT); +- Zombie zombie = entitytype.create(p_452619_, EntitySpawnReason.REINFORCEMENT); - if (zombie == null) { - return true; - } diff --git a/patches/minecraft/net/minecraft/world/entity/monster/ZombieVillager.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/zombie/ZombieVillager.java.patch similarity index 63% rename from patches/minecraft/net/minecraft/world/entity/monster/ZombieVillager.java.patch rename to patches/minecraft/net/minecraft/world/entity/monster/zombie/ZombieVillager.java.patch index 18adb15f15..931eacd406 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/ZombieVillager.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/zombie/ZombieVillager.java.patch @@ -1,6 +1,6 @@ ---- a/net/minecraft/world/entity/monster/ZombieVillager.java -+++ b/net/minecraft/world/entity/monster/ZombieVillager.java -@@ -123,7 +_,7 @@ +--- a/net/minecraft/world/entity/monster/zombie/ZombieVillager.java ++++ b/net/minecraft/world/entity/monster/zombie/ZombieVillager.java +@@ -143,7 +_,7 @@ if (!this.level().isClientSide() && this.isAlive() && this.isConverting()) { int i = this.getConversionProgress(); this.villagerConversionTime -= i; @@ -9,11 +9,11 @@ this.finishConversion((ServerLevel)this.level()); } } -@@ -230,6 +_,7 @@ +@@ -252,6 +_,7 @@ if (!this.isSilent()) { - p_34399_.levelEvent(null, 1027, this.blockPosition(), 0); + p_457527_.levelEvent(null, 1027, this.blockPosition(), 0); } -+ net.minecraftforge.event.ForgeEventFactory.onLivingConvert(this, p_359261_); ++ net.minecraftforge.event.ForgeEventFactory.onLivingConvert(this, p_460761_); } ); } diff --git a/patches/minecraft/net/minecraft/world/entity/npc/AbstractVillager.java.patch b/patches/minecraft/net/minecraft/world/entity/npc/AbstractVillager.java.patch deleted file mode 100644 index 3776cf66bf..0000000000 --- a/patches/minecraft/net/minecraft/world/entity/npc/AbstractVillager.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/world/entity/npc/AbstractVillager.java -+++ b/net/minecraft/world/entity/npc/AbstractVillager.java -@@ -123,6 +_,8 @@ - if (this.tradingPlayer instanceof ServerPlayer) { - CriteriaTriggers.TRADE.trigger((ServerPlayer)this.tradingPlayer, this, p_35274_.getResult()); - } -+ -+ net.minecraftforge.event.ForgeEventFactory.onPlayerTradeWithVillager(this.tradingPlayer, p_35274_, this); - } - - protected abstract void rewardTradeXp(MerchantOffer p_35299_); diff --git a/patches/minecraft/net/minecraft/world/entity/npc/Villager.java.patch b/patches/minecraft/net/minecraft/world/entity/npc/Villager.java.patch deleted file mode 100644 index 2ae64b1144..0000000000 --- a/patches/minecraft/net/minecraft/world/entity/npc/Villager.java.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- a/net/minecraft/world/entity/npc/Villager.java -+++ b/net/minecraft/world/entity/npc/Villager.java -@@ -320,7 +_,7 @@ - @Override - public InteractionResult mobInteract(Player p_35472_, InteractionHand p_35473_) { - ItemStack itemstack = p_35472_.getItemInHand(p_35473_); -- if (itemstack.is(Items.VILLAGER_SPAWN_EGG) || !this.isAlive() || this.isTrading() || this.isSleeping()) { -+ if (itemstack.is(Items.VILLAGER_SPAWN_EGG) || !this.isAlive() || this.isTrading() || this.isSleeping() || p_35472_.isSecondaryUseActive()) { - return super.mobInteract(p_35472_, p_35473_); - } else if (this.isBaby()) { - this.setUnhappy(); -@@ -766,7 +_,7 @@ - - @Override - public void thunderHit(ServerLevel p_35409_, LightningBolt p_35410_) { -- 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_421901_ -> { - p_421901_.finalizeSpawn(p_35409_, p_35409_.getCurrentDifficultyAt(p_421901_.blockPosition()), EntitySpawnReason.CONVERSION, null); diff --git a/patches/minecraft/net/minecraft/world/entity/npc/villager/AbstractVillager.java.patch b/patches/minecraft/net/minecraft/world/entity/npc/villager/AbstractVillager.java.patch new file mode 100644 index 0000000000..37c260f5de --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/npc/villager/AbstractVillager.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/entity/npc/villager/AbstractVillager.java ++++ b/net/minecraft/world/entity/npc/villager/AbstractVillager.java +@@ -125,6 +_,8 @@ + if (this.tradingPlayer instanceof ServerPlayer) { + CriteriaTriggers.TRADE.trigger((ServerPlayer)this.tradingPlayer, this, p_459364_.getResult()); + } ++ ++ net.minecraftforge.event.ForgeEventFactory.onPlayerTradeWithVillager(this.tradingPlayer, p_459364_, this); + } + + protected abstract void rewardTradeXp(MerchantOffer p_458516_); diff --git a/patches/minecraft/net/minecraft/world/entity/npc/villager/Villager.java.patch b/patches/minecraft/net/minecraft/world/entity/npc/villager/Villager.java.patch new file mode 100644 index 0000000000..fb109a91ec --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/npc/villager/Villager.java.patch @@ -0,0 +1,20 @@ +--- a/net/minecraft/world/entity/npc/villager/Villager.java ++++ b/net/minecraft/world/entity/npc/villager/Villager.java +@@ -320,7 +_,7 @@ + @Override + public InteractionResult mobInteract(Player p_458495_, InteractionHand p_455648_) { + ItemStack itemstack = p_458495_.getItemInHand(p_455648_); +- if (itemstack.is(Items.VILLAGER_SPAWN_EGG) || !this.isAlive() || this.isTrading() || this.isSleeping()) { ++ if (itemstack.is(Items.VILLAGER_SPAWN_EGG) || !this.isAlive() || this.isTrading() || this.isSleeping() || p_458495_.isSecondaryUseActive()) { + return super.mobInteract(p_458495_, p_455648_); + } else if (this.isBaby()) { + this.setUnhappy(); +@@ -760,7 +_,7 @@ + + @Override + public void thunderHit(ServerLevel p_455159_, LightningBolt p_455393_) { +- if (p_455159_.getDifficulty() != Difficulty.PEACEFUL) { ++ if (p_455159_.getDifficulty() != Difficulty.PEACEFUL && net.minecraftforge.event.ForgeEventFactory.canLivingConvert(this, EntityType.WITCH, (timer) -> {})) { + LOGGER.info("Villager {} was struck by lightning {}.", this, p_455393_); + Witch witch = this.convertTo(EntityType.WITCH, ConversionParams.single(this, false, false), p_451416_ -> { + p_451416_.finalizeSpawn(p_455159_, p_455159_.getCurrentDifficultyAt(p_451416_.blockPosition()), EntitySpawnReason.CONVERSION, null); diff --git a/patches/minecraft/net/minecraft/world/entity/npc/VillagerTrades.java.patch b/patches/minecraft/net/minecraft/world/entity/npc/villager/VillagerTrades.java.patch similarity index 65% rename from patches/minecraft/net/minecraft/world/entity/npc/VillagerTrades.java.patch rename to patches/minecraft/net/minecraft/world/entity/npc/villager/VillagerTrades.java.patch index e7f6b3fa37..6dc98e6971 100644 --- a/patches/minecraft/net/minecraft/world/entity/npc/VillagerTrades.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/npc/villager/VillagerTrades.java.patch @@ -1,23 +1,23 @@ ---- a/net/minecraft/world/entity/npc/VillagerTrades.java -+++ b/net/minecraft/world/entity/npc/VillagerTrades.java -@@ -855,7 +_,7 @@ +--- a/net/minecraft/world/entity/npc/villager/VillagerTrades.java ++++ b/net/minecraft/world/entity/npc/villager/VillagerTrades.java +@@ -854,7 +_,7 @@ 5 ) ) - .build(); -+ .build().stream().collect(net.minecraft.Util.toMutableList()); // Forge: Turned into an ArrayList so it can be modified in VillagerTradingManager ++ .build().stream().collect(net.minecraft.util.Util.toMutableList()); // Forge: Turned into an ArrayList so it can be modified in VillagerTradingManager public static final Map, Int2ObjectMap> EXPERIMENTAL_TRADES = Map.of( VillagerProfession.LIBRARIAN, toIntMap( -@@ -1280,6 +_,7 @@ +@@ -1279,6 +_,7 @@ private final int villagerXp; - public EmeraldsForVillagerTypeItem(int p_35669_, int p_35670_, int p_35671_, Map, Item> p_35672_) { + public EmeraldsForVillagerTypeItem(int p_453689_, int p_451560_, int p_457573_, Map, Item> p_450639_) { + if (false) // FORGE: Modders can add custom villager types, so remove this validation - BuiltInRegistries.VILLAGER_TYPE.registryKeySet().stream().filter(p_397256_ -> !p_35672_.containsKey(p_397256_)).findAny().ifPresent(p_390730_ -> { - throw new IllegalStateException("Missing trade for villager type: " + p_390730_); + BuiltInRegistries.VILLAGER_TYPE.registryKeySet().stream().filter(p_455509_ -> !p_450639_.containsKey(p_455509_)).findAny().ifPresent(p_460167_ -> { + throw new IllegalStateException("Missing trade for villager type: " + p_460167_); }); -@@ -1297,7 +_,9 @@ +@@ -1295,7 +_,9 @@ if (resourcekey == null) { return null; } else { diff --git a/patches/minecraft/net/minecraft/world/entity/npc/VillagerType.java.patch b/patches/minecraft/net/minecraft/world/entity/npc/villager/VillagerType.java.patch similarity index 67% rename from patches/minecraft/net/minecraft/world/entity/npc/VillagerType.java.patch rename to patches/minecraft/net/minecraft/world/entity/npc/villager/VillagerType.java.patch index 72bb1c3e85..e836aa12ce 100644 --- a/patches/minecraft/net/minecraft/world/entity/npc/VillagerType.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/npc/villager/VillagerType.java.patch @@ -1,8 +1,8 @@ ---- a/net/minecraft/world/entity/npc/VillagerType.java -+++ b/net/minecraft/world/entity/npc/VillagerType.java +--- a/net/minecraft/world/entity/npc/villager/VillagerType.java ++++ b/net/minecraft/world/entity/npc/villager/VillagerType.java @@ -80,4 +_,9 @@ - public static ResourceKey byBiome(Holder p_204074_) { - return p_204074_.unwrapKey().map(BY_BIOME::get).orElse(PLAINS); + public static ResourceKey byBiome(Holder p_452045_) { + return p_452045_.unwrapKey().map(BY_BIOME::get).orElse(PLAINS); } + + /** FORGE: Registers the VillagerType that will spawn in the given biome. This method should be called during FMLCommonSetupEvent using event.enqueueWork() */ 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 ac2376eb1f..307635bf46 100644 --- a/patches/minecraft/net/minecraft/world/entity/player/Player.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/player/Player.java.patch @@ -1,16 +1,16 @@ --- a/net/minecraft/world/entity/player/Player.java +++ b/net/minecraft/world/entity/player/Player.java -@@ -119,7 +_,7 @@ - import net.minecraft.world.scores.PlayerTeam; +@@ -122,7 +_,7 @@ import net.minecraft.world.scores.Team; + import org.jspecify.annotations.Nullable; -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; +@@ -173,6 +_,9 @@ + public @Nullable Entity currentExplosionCause; private boolean ignoreFallDamageFromCurrentImpulse = false; private int currentImpulseContextResetGraceTime = 0; + private final java.util.Collection prefixes = new java.util.LinkedList<>(); @@ -19,7 +19,7 @@ public Player(Level p_250508_, GameProfile p_252153_) { super(EntityType.PLAYER, p_250508_); -@@ -183,6 +_,17 @@ +@@ -181,6 +_,17 @@ this.inventory = new Inventory(this, this.equipment); this.inventoryMenu = new InventoryMenu(this.inventory, !p_250508_.isClientSide(), this); this.containerMenu = this.inventoryMenu; @@ -37,7 +37,7 @@ } @Override -@@ -217,7 +_,8 @@ +@@ -215,7 +_,8 @@ .add(Attributes.MINING_EFFICIENCY) .add(Attributes.SWEEPING_DAMAGE_RATIO) .add(Attributes.WAYPOINT_TRANSMIT_RANGE, 6.0E7) @@ -47,7 +47,7 @@ } @Override -@@ -231,6 +_,7 @@ +@@ -229,6 +_,7 @@ @Override public void tick() { @@ -55,16 +55,16 @@ this.noPhysics = this.isSpectator(); if (this.isSpectator() || this.isPassenger()) { this.setOnGround(false); -@@ -246,7 +_,7 @@ +@@ -244,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().environmentAttributes().getValue(EnvironmentAttributes.BED_RULE, this.position()).canSleep(this.level())) { ++ if (!this.level().isClientSide() && !net.minecraftforge.event.ForgeEventFactory.onSleepingTimeCheck(this, getSleepingPos(), this.level().environmentAttributes().getValue(EnvironmentAttributes.BED_RULE, this.position()))) { this.stopSleepInBed(false, true); } } else if (this.sleepCounter > 0) { -@@ -284,6 +_,7 @@ +@@ -283,6 +_,7 @@ if (this.currentImpulseContextResetGraceTime > 0) { this.currentImpulseContextResetGraceTime--; } @@ -72,7 +72,7 @@ } @Override -@@ -343,6 +_,10 @@ +@@ -342,6 +_,10 @@ } protected void updatePlayerPose() { @@ -83,7 +83,7 @@ if (this.canPlayerFitWithinBlocksAndEntitiesWhen(Pose.SWIMMING)) { Pose pose = this.getDesiredPose(); Pose pose1; -@@ -531,6 +_,7 @@ +@@ -526,6 +_,7 @@ @Override public void die(DamageSource p_36152_) { @@ -91,10 +91,10 @@ super.die(p_36152_); this.reapplyPosition(); if (!this.isSpectator() && this.level() instanceof ServerLevel serverlevel) { -@@ -588,10 +_,15 @@ +@@ -582,10 +_,15 @@ + } - @Nullable - public ItemEntity drop(ItemStack p_36177_, boolean p_36178_) { + public @Nullable ItemEntity drop(ItemStack p_36177_, boolean p_36178_) { - return this.drop(p_36177_, false, p_36178_); + return net.minecraftforge.common.ForgeHooks.onPlayerTossEvent(this, p_36177_, 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); -@@ -620,11 +_,14 @@ +@@ -614,11 +_,14 @@ f /= 5.0F; } @@ -124,7 +124,7 @@ } @Override -@@ -691,6 +_,7 @@ +@@ -685,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)) { -@@ -759,10 +_,13 @@ +@@ -753,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)); -@@ -830,6 +_,10 @@ +@@ -827,6 +_,10 @@ return InteractionResult.PASS; } else { @@ -157,7 +157,7 @@ ItemStack itemstack = this.getItemInHand(p_36159_); ItemStack itemstack1 = itemstack.copy(); InteractionResult interactionresult = p_36158_.interact(this, p_36159_); -@@ -838,6 +_,10 @@ +@@ -835,6 +_,10 @@ itemstack.setCount(itemstack1.getCount()); } @@ -168,7 +168,7 @@ return interactionresult; } else { if (!itemstack.isEmpty() && p_36158_ instanceof LivingEntity) { -@@ -849,6 +_,7 @@ +@@ -846,6 +_,7 @@ if (interactionresult1.consumesAction()) { this.level().gameEvent(GameEvent.ENTITY_INTERACT, p_36158_.position(), GameEvent.Context.of(this)); if (itemstack.isEmpty() && !this.hasInfiniteMaterials()) { @@ -176,64 +176,64 @@ this.setItemInHand(p_36159_, ItemStack.EMPTY); } -@@ -948,6 +_,7 @@ +@@ -945,6 +_,7 @@ } public void attack(Entity p_36347_) { + if (!net.minecraftforge.common.ForgeHooks.onPlayerAttackTarget(this, p_36347_)) return; - if (p_36347_.isAttackable()) { - if (!p_36347_.skipAttackInteraction(this)) { - float f = this.isAutoSpinAttack() ? this.autoSpinAttackDmg : (float)this.getAttributeValue(Attributes.ATTACK_DAMAGE); -@@ -983,8 +_,10 @@ - && !this.isPassenger() - && p_36347_ instanceof LivingEntity - && !this.isSprinting(); -+ var hitResult = net.minecraftforge.common.ForgeHooks.getCriticalHit(this, p_36347_, flag1, flag1 ? 1.5F : 1.0F); -+ flag1 = hitResult != null; - if (flag1) { -- f *= 1.5F; -+ f *= hitResult.getDamageModifier(); - } + if (!this.cannotAttack(p_36347_)) { + float f = this.isAutoSpinAttack() ? this.autoSpinAttackDmg : (float)this.getAttributeValue(Attributes.ATTACK_DAMAGE); + ItemStack itemstack = this.getWeaponItem(); +@@ -966,8 +_,10 @@ - float f3 = f + f1; -@@ -992,7 +_,7 @@ - if (flag3 && !flag1 && !flag && this.onGround()) { - double d0 = this.getKnownMovement().horizontalDistanceSqr(); - double d1 = this.getSpeed() * 2.5; -- if (d0 < Mth.square(d1) && this.getItemInHand(InteractionHand.MAIN_HAND).is(ItemTags.SWORDS)) { -+ if (d0 < Mth.square(d1) && this.getItemInHand(InteractionHand.MAIN_HAND).canPerformAction(net.minecraftforge.common.ToolActions.SWORD_SWEEP)) { - flag2 = true; - } - } -@@ -1028,7 +_,7 @@ - if (flag2) { - float f6 = 1.0F + (float)this.getAttributeValue(Attributes.SWEEPING_DAMAGE_RATIO) * f; - -- for (LivingEntity livingentity2 : this.level().getEntitiesOfClass(LivingEntity.class, p_36347_.getBoundingBox().inflate(1.0, 0.25, 1.0))) { -+ for (LivingEntity livingentity2 : this.level().getEntitiesOfClass(LivingEntity.class, this.getItemInHand(InteractionHand.MAIN_HAND).getSweepHitBox(this, p_36347_))) { - if (livingentity2 != this - && livingentity2 != p_36347_ - && !this.isAlliedTo(livingentity2) -@@ -1079,8 +_,8 @@ - - this.setLastHurtMob(p_36347_); - Entity entity = p_36347_; -- if (p_36347_ instanceof EnderDragonPart) { -- entity = ((EnderDragonPart)p_36347_).parentMob; -+ if (p_36347_ instanceof net.minecraftforge.entity.PartEntity pe) { -+ entity = pe.getParent(); - } - - boolean flag5 = false; -@@ -1124,6 +_,7 @@ - } + f += itemstack.getItem().getAttackDamageBonus(p_36347_, f, damagesource); + boolean flag2 = flag && this.canCriticalAttack(p_36347_); ++ var hitResult = net.minecraftforge.common.ForgeHooks.getCriticalHit(this, p_36347_, flag2, flag2 ? 1.5F : 1.0F); ++ flag2 = hitResult != null; + if (flag2) { +- f *= 1.5F; ++ f *= hitResult.getDamageModifier(); } + + float f3 = f + f2; +@@ -1039,7 +_,7 @@ + double d0 = this.getKnownMovement().horizontalDistanceSqr(); + double d1 = this.getSpeed() * 2.5; + if (d0 < Mth.square(d1)) { +- return this.getItemInHand(InteractionHand.MAIN_HAND).is(ItemTags.SWORDS); ++ return this.getItemInHand(InteractionHand.MAIN_HAND).canPerformAction(net.minecraftforge.common.ToolActions.SWORD_SWEEP); + } + } + +@@ -1075,8 +_,8 @@ + + private void itemAttackInteraction(Entity p_456980_, ItemStack p_453550_, DamageSource p_453296_, boolean p_457792_) { + Entity entity = p_456980_; +- if (p_456980_ instanceof EnderDragonPart) { +- entity = ((EnderDragonPart)p_456980_).parentMob; ++ if (p_456980_ instanceof net.minecraftforge.entity.PartEntity pe) { ++ entity = pe.getParent(); + } + + boolean flag = false; +@@ -1101,6 +_,7 @@ + } else { + this.setItemInHand(InteractionHand.OFF_HAND, ItemStack.EMPTY); } + this.resetAttackStrengthTicker(); // FORGE: Moved from beginning of attack() so that getAttackStrengthScale() returns an accurate value during all attack events } } } -@@ -1230,6 +_,7 @@ +@@ -1141,7 +_,7 @@ + if (this.level() instanceof ServerLevel serverlevel) { + float f = 1.0F + (float)this.getAttributeValue(Attributes.SWEEPING_DAMAGE_RATIO) * p_451630_; + +- for (LivingEntity livingentity : this.level().getEntitiesOfClass(LivingEntity.class, p_451034_.getBoundingBox().inflate(1.0, 0.25, 1.0))) { ++ for (LivingEntity livingentity : this.level().getEntitiesOfClass(LivingEntity.class, this.getItemInHand(InteractionHand.MAIN_HAND).getSweepHitBox(this, p_451034_))) { + if (livingentity != this + && livingentity != p_451034_ + && !this.isAlliedTo(livingentity) +@@ -1307,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(); -@@ -1338,6 +_,7 @@ +@@ -1415,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) { -@@ -1392,13 +_,13 @@ +@@ -1469,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); } -@@ -1429,6 +_,12 @@ +@@ -1506,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); -@@ -1456,7 +_,7 @@ +@@ -1533,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; -@@ -1467,6 +_,12 @@ +@@ -1544,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; -@@ -1602,7 +_,13 @@ +@@ -1689,7 +_,13 @@ @Override public Component getDisplayName() { @@ -315,7 +315,7 @@ return this.decorateDisplayNameComponent(mutablecomponent); } -@@ -1765,18 +_,19 @@ +@@ -1869,18 +_,19 @@ Predicate predicate = ((ProjectileWeaponItem)p_36349_.getItem()).getSupportedHeldProjectiles(); ItemStack itemstack = ProjectileWeaponItem.getHeldProjectile(this, predicate); if (!itemstack.isEmpty()) { @@ -338,7 +338,7 @@ } } } -@@ -1935,6 +_,54 @@ +@@ -2035,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 deleted file mode 100644 index a6b07d44d9..0000000000 --- a/patches/minecraft/net/minecraft/world/entity/projectile/AbstractArrow.java.patch +++ /dev/null @@ -1,28 +0,0 @@ ---- a/net/minecraft/world/entity/projectile/AbstractArrow.java -+++ b/net/minecraft/world/entity/projectile/AbstractArrow.java -@@ -76,6 +_,7 @@ - private ItemStack pickupItemStack = this.getDefaultPickupItem(); - @Nullable - private ItemStack firedFromWeapon = null; -+ private final IntOpenHashSet ignoredEntities = new IntOpenHashSet(); - - protected AbstractArrow(EntityType p_332730_, Level p_335646_) { - super(p_332730_, p_335646_); -@@ -189,7 +_,7 @@ - this.shakeTime--; - } - -- if (this.isInWaterOrRain()) { -+ if (this.isInWaterOrRain() || this.isInFluidType((fluidType, height) -> this.canFluidExtinguish(fluidType))) { - this.clearFire(); - } - -@@ -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 -- : super.canHitEntity(p_36743_) && (this.piercingIgnoreEntityIds == null || !this.piercingIgnoreEntityIds.contains(p_36743_.getId())); -+ : super.canHitEntity(p_36743_) && (this.piercingIgnoreEntityIds == null || !this.piercingIgnoreEntityIds.contains(p_36743_.getId())) && !this.ignoredEntities.contains(p_36743_.getId()); - } - - @Override diff --git a/patches/minecraft/net/minecraft/world/entity/projectile/FireworkRocketEntity.java.patch b/patches/minecraft/net/minecraft/world/entity/projectile/FireworkRocketEntity.java.patch index 95c05189cd..43223d1376 100644 --- a/patches/minecraft/net/minecraft/world/entity/projectile/FireworkRocketEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/projectile/FireworkRocketEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/FireworkRocketEntity.java +++ b/net/minecraft/world/entity/projectile/FireworkRocketEntity.java -@@ -307,6 +_,13 @@ +@@ -306,6 +_,13 @@ } @Override 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 e9da1aa6b1..1458fb8a7e 100644 --- a/patches/minecraft/net/minecraft/world/entity/projectile/FishingHook.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/projectile/FishingHook.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/FishingHook.java +++ b/net/minecraft/world/entity/projectile/FishingHook.java -@@ -252,8 +_,8 @@ +@@ -249,8 +_,8 @@ if (p_37137_.canInteractWithLevel()) { ItemStack itemstack = p_37137_.getMainHandItem(); ItemStack itemstack1 = p_37137_.getOffhandItem(); @@ -11,7 +11,7 @@ if ((flag || flag1) && this.distanceToSqr(p_37137_) <= 1024.0) { return false; } -@@ -265,6 +_,7 @@ +@@ -262,6 +_,7 @@ private void checkCollision() { HitResult hitresult = ProjectileUtil.getHitResultOnMoveVector(this, this::canHitEntity); @@ -19,7 +19,7 @@ this.hitTargetOrDeflectSelf(hitresult); } -@@ -454,6 +_,7 @@ +@@ -451,6 +_,7 @@ Player player = this.getPlayerOwner(); if (!this.level().isClientSide() && player != null && !this.shouldStopFishing(player)) { int i = 0; @@ -27,7 +27,7 @@ if (this.hookedIn != null) { this.pullEntity(this.hookedIn); CriteriaTriggers.FISHING_ROD_HOOKED.trigger((ServerPlayer)player, p_37157_, this, Collections.emptyList()); -@@ -464,10 +_,16 @@ +@@ -461,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) { -@@ -497,7 +_,7 @@ +@@ -494,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 9ca3bc66fd..d2908e4058 100644 --- a/patches/minecraft/net/minecraft/world/entity/projectile/Projectile.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/projectile/Projectile.java.patch @@ -1,10 +1,10 @@ --- a/net/minecraft/world/entity/projectile/Projectile.java +++ b/net/minecraft/world/entity/projectile/Projectile.java -@@ -351,7 +_,7 @@ +@@ -349,7 +_,7 @@ @Override public boolean mayInteract(ServerLevel p_364907_, BlockPos p_150168_) { Entity entity = this.getOwner(); -- return entity instanceof Player ? entity.mayInteract(p_364907_, p_150168_) : entity == null || p_364907_.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING); +- return entity instanceof Player ? entity.mayInteract(p_364907_, p_150168_) : entity == null || p_364907_.getGameRules().get(GameRules.MOB_GRIEFING); + return entity instanceof Player ? entity.mayInteract(p_364907_, p_150168_) : entity == null || net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(p_364907_, entity); } diff --git a/patches/minecraft/net/minecraft/world/entity/projectile/ProjectileUtil.java.patch b/patches/minecraft/net/minecraft/world/entity/projectile/ProjectileUtil.java.patch index 6f5f0791db..8b9d1ecb0c 100644 --- a/patches/minecraft/net/minecraft/world/entity/projectile/ProjectileUtil.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/projectile/ProjectileUtil.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/ProjectileUtil.java +++ b/net/minecraft/world/entity/projectile/ProjectileUtil.java -@@ -79,7 +_,7 @@ +@@ -113,7 +_,7 @@ Vec3 vec31 = optional.get(); double d1 = p_37289_.distanceToSqr(vec31); if (d1 < d0 || d0 == 0.0) { @@ -9,7 +9,7 @@ if (d0 == 0.0) { entity = entity1; vec3 = vec31; -@@ -157,8 +_,13 @@ +@@ -240,8 +_,13 @@ } } diff --git a/patches/minecraft/net/minecraft/world/entity/projectile/ShulkerBullet.java.patch b/patches/minecraft/net/minecraft/world/entity/projectile/ShulkerBullet.java.patch index 23d39d369c..4faee46142 100644 --- a/patches/minecraft/net/minecraft/world/entity/projectile/ShulkerBullet.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/projectile/ShulkerBullet.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/ShulkerBullet.java +++ b/net/minecraft/world/entity/projectile/ShulkerBullet.java -@@ -220,7 +_,7 @@ +@@ -217,7 +_,7 @@ this.handlePortal(); } diff --git a/patches/minecraft/net/minecraft/world/entity/projectile/WitherSkull.java.patch b/patches/minecraft/net/minecraft/world/entity/projectile/WitherSkull.java.patch deleted file mode 100644 index 1893e1c4e2..0000000000 --- a/patches/minecraft/net/minecraft/world/entity/projectile/WitherSkull.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/world/entity/projectile/WitherSkull.java -+++ b/net/minecraft/world/entity/projectile/WitherSkull.java -@@ -49,7 +_,7 @@ - - @Override - public float getBlockExplosionResistance(Explosion p_37619_, BlockGetter p_37620_, BlockPos p_37621_, BlockState p_37622_, FluidState p_37623_, float p_37624_) { -- return this.isDangerous() && WitherBoss.canDestroy(p_37622_) ? Math.min(0.8F, p_37624_) : p_37624_; -+ return this.isDangerous() && p_37622_.canEntityDestroy(p_37620_, p_37621_, this) ? Math.min(0.8F, p_37624_) : p_37624_; - } - - @Override diff --git a/patches/minecraft/net/minecraft/world/entity/projectile/arrow/AbstractArrow.java.patch b/patches/minecraft/net/minecraft/world/entity/projectile/arrow/AbstractArrow.java.patch new file mode 100644 index 0000000000..bf9c1723a7 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/projectile/arrow/AbstractArrow.java.patch @@ -0,0 +1,28 @@ +--- a/net/minecraft/world/entity/projectile/arrow/AbstractArrow.java ++++ b/net/minecraft/world/entity/projectile/arrow/AbstractArrow.java +@@ -78,6 +_,7 @@ + private @Nullable List piercedAndKilledEntities; + private ItemStack pickupItemStack = this.getDefaultPickupItem(); + private @Nullable ItemStack firedFromWeapon = null; ++ private final IntOpenHashSet ignoredEntities = new IntOpenHashSet(); + + protected AbstractArrow(EntityType p_450750_, Level p_450850_) { + super(p_450750_, p_450850_); +@@ -191,7 +_,7 @@ + this.shakeTime--; + } + +- if (this.isInWaterOrRain()) { ++ if (this.isInWaterOrRain() || this.isInFluidType((fluidType, height) -> this.canFluidExtinguish(fluidType))) { + this.clearFire(); + } + +@@ -587,7 +_,7 @@ + protected boolean canHitEntity(Entity p_454713_) { + return p_454713_ instanceof Player && this.getOwner() instanceof Player player && !player.canHarmPlayer((Player)p_454713_) + ? false +- : super.canHitEntity(p_454713_) && (this.piercingIgnoreEntityIds == null || !this.piercingIgnoreEntityIds.contains(p_454713_.getId())); ++ : super.canHitEntity(p_454713_) && (this.piercingIgnoreEntityIds == null || !this.piercingIgnoreEntityIds.contains(p_454713_.getId())) && !this.ignoredEntities.contains(p_454713_.getId()); + } + + @Override diff --git a/patches/minecraft/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java.patch b/patches/minecraft/net/minecraft/world/entity/projectile/hurtingprojectile/AbstractHurtingProjectile.java.patch similarity index 65% rename from patches/minecraft/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java.patch rename to patches/minecraft/net/minecraft/world/entity/projectile/hurtingprojectile/AbstractHurtingProjectile.java.patch index 2829844829..8b0e968f86 100644 --- a/patches/minecraft/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/projectile/hurtingprojectile/AbstractHurtingProjectile.java.patch @@ -1,6 +1,6 @@ ---- a/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java -+++ b/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java -@@ -87,7 +_,7 @@ +--- a/net/minecraft/world/entity/projectile/hurtingprojectile/AbstractHurtingProjectile.java ++++ b/net/minecraft/world/entity/projectile/hurtingprojectile/AbstractHurtingProjectile.java +@@ -89,7 +_,7 @@ this.igniteForSeconds(1.0F); } diff --git a/patches/minecraft/net/minecraft/world/entity/projectile/LargeFireball.java.patch b/patches/minecraft/net/minecraft/world/entity/projectile/hurtingprojectile/LargeFireball.java.patch similarity index 53% rename from patches/minecraft/net/minecraft/world/entity/projectile/LargeFireball.java.patch rename to patches/minecraft/net/minecraft/world/entity/projectile/hurtingprojectile/LargeFireball.java.patch index 2751298908..7b339480ea 100644 --- a/patches/minecraft/net/minecraft/world/entity/projectile/LargeFireball.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/projectile/hurtingprojectile/LargeFireball.java.patch @@ -1,10 +1,10 @@ ---- a/net/minecraft/world/entity/projectile/LargeFireball.java -+++ b/net/minecraft/world/entity/projectile/LargeFireball.java +--- a/net/minecraft/world/entity/projectile/hurtingprojectile/LargeFireball.java ++++ b/net/minecraft/world/entity/projectile/hurtingprojectile/LargeFireball.java @@ -31,7 +_,7 @@ - protected void onHit(HitResult p_37218_) { - super.onHit(p_37218_); + protected void onHit(HitResult p_451111_) { + super.onHit(p_451111_); if (this.level() instanceof ServerLevel serverlevel) { -- boolean flag = serverlevel.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING); +- boolean flag = serverlevel.getGameRules().get(GameRules.MOB_GRIEFING); + boolean flag = net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(serverlevel, this.getOwner()); this.level().explode(this, this.getX(), this.getY(), this.getZ(), this.explosionPower, flag, Level.ExplosionInteraction.MOB); this.discard(); diff --git a/patches/minecraft/net/minecraft/world/entity/projectile/SmallFireball.java.patch b/patches/minecraft/net/minecraft/world/entity/projectile/hurtingprojectile/SmallFireball.java.patch similarity index 59% rename from patches/minecraft/net/minecraft/world/entity/projectile/SmallFireball.java.patch rename to patches/minecraft/net/minecraft/world/entity/projectile/hurtingprojectile/SmallFireball.java.patch index 7da181b8f2..515a0b7436 100644 --- a/patches/minecraft/net/minecraft/world/entity/projectile/SmallFireball.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/projectile/hurtingprojectile/SmallFireball.java.patch @@ -1,11 +1,11 @@ ---- a/net/minecraft/world/entity/projectile/SmallFireball.java -+++ b/net/minecraft/world/entity/projectile/SmallFireball.java +--- a/net/minecraft/world/entity/projectile/hurtingprojectile/SmallFireball.java ++++ b/net/minecraft/world/entity/projectile/hurtingprojectile/SmallFireball.java @@ -51,7 +_,7 @@ - super.onHitBlock(p_37384_); + super.onHitBlock(p_452526_); if (this.level() instanceof ServerLevel serverlevel) { Entity entity = this.getOwner(); -- if (!(entity instanceof Mob) || serverlevel.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { +- if (!(entity instanceof Mob) || serverlevel.getGameRules().get(GameRules.MOB_GRIEFING)) { + if (!(entity instanceof Mob) || net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(serverlevel, entity)) { - BlockPos blockpos = p_37384_.getBlockPos().relative(p_37384_.getDirection()); + BlockPos blockpos = p_452526_.getBlockPos().relative(p_452526_.getDirection()); if (this.level().isEmptyBlock(blockpos)) { this.level().setBlockAndUpdate(blockpos, BaseFireBlock.getState(this.level(), blockpos)); diff --git a/patches/minecraft/net/minecraft/world/entity/projectile/hurtingprojectile/WitherSkull.java.patch b/patches/minecraft/net/minecraft/world/entity/projectile/hurtingprojectile/WitherSkull.java.patch new file mode 100644 index 0000000000..12ad1714c0 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/projectile/hurtingprojectile/WitherSkull.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/entity/projectile/hurtingprojectile/WitherSkull.java ++++ b/net/minecraft/world/entity/projectile/hurtingprojectile/WitherSkull.java +@@ -49,7 +_,7 @@ + + @Override + public float getBlockExplosionResistance(Explosion p_459983_, BlockGetter p_451795_, BlockPos p_456538_, BlockState p_459565_, FluidState p_454710_, float p_453616_) { +- return this.isDangerous() && WitherBoss.canDestroy(p_459565_) ? Math.min(0.8F, p_453616_) : p_453616_; ++ return this.isDangerous() && p_459565_.canEntityDestroy(p_451795_, p_456538_, this) ? Math.min(0.8F, p_453616_) : p_453616_; + } + + @Override diff --git a/patches/minecraft/net/minecraft/world/entity/projectile/ThrownEnderpearl.java.patch b/patches/minecraft/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownEnderpearl.java.patch similarity index 83% rename from patches/minecraft/net/minecraft/world/entity/projectile/ThrownEnderpearl.java.patch rename to patches/minecraft/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownEnderpearl.java.patch index ec314ce6f3..f027d7a490 100644 --- a/patches/minecraft/net/minecraft/world/entity/projectile/ThrownEnderpearl.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownEnderpearl.java.patch @@ -1,10 +1,10 @@ ---- a/net/minecraft/world/entity/projectile/ThrownEnderpearl.java -+++ b/net/minecraft/world/entity/projectile/ThrownEnderpearl.java -@@ -106,6 +_,13 @@ +--- a/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownEnderpearl.java ++++ b/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownEnderpearl.java +@@ -104,6 +_,13 @@ Vec3 vec3 = this.oldPosition(); if (entity instanceof ServerPlayer serverplayer) { if (serverplayer.connection.isAcceptingMessages()) { -+ var event = net.minecraftforge.event.ForgeEventFactory.onEnderPearlLand(serverplayer, this.getX(), this.getY(), this.getZ(), this, 5.0F, p_37504_); ++ var event = net.minecraftforge.event.ForgeEventFactory.onEnderPearlLand(serverplayer, this.getX(), this.getY(), this.getZ(), this, 5.0F, p_451483_); + if (event == null) { + this.discard(); + return; @@ -14,7 +14,7 @@ if (this.random.nextFloat() < 0.05F && serverlevel.isSpawningMonsters()) { Endermite endermite = EntityType.ENDERMITE.create(serverlevel, EntitySpawnReason.TRIGGERED); if (endermite != null) { -@@ -132,7 +_,7 @@ +@@ -130,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 e72fd28ba4..a0897586ff 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 -@@ -823,7 +_,7 @@ +@@ -820,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}), -@@ -837,6 +_,20 @@ +@@ -834,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/ContainerEntity.java.patch b/patches/minecraft/net/minecraft/world/entity/vehicle/ContainerEntity.java.patch index d90c85b995..cf8ca9fbe4 100644 --- a/patches/minecraft/net/minecraft/world/entity/vehicle/ContainerEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/vehicle/ContainerEntity.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/entity/vehicle/ContainerEntity.java +++ b/net/minecraft/world/entity/vehicle/ContainerEntity.java -@@ -103,6 +_,9 @@ +@@ -102,6 +_,9 @@ this.setContainerLootTable(null); LootParams.Builder lootparams$builder = new LootParams.Builder((ServerLevel)this.level()).withParameter(LootContextParams.ORIGIN, this.position()); + // Forge: set the chest to killer_entity for loot context. -+ if (this instanceof AbstractMinecartContainer entityContainer) ++ if (this instanceof net.minecraft.world.entity.vehicle.minecart.AbstractMinecartContainer entityContainer) + lootparams$builder.withParameter(LootContextParams.ATTACKING_ENTITY, entityContainer); if (p_219950_ != null) { lootparams$builder.withLuck(p_219950_.getLuck()).withParameter(LootContextParams.THIS_ENTITY, p_219950_); diff --git a/patches/minecraft/net/minecraft/world/entity/vehicle/MinecartCommandBlock.java.patch b/patches/minecraft/net/minecraft/world/entity/vehicle/MinecartCommandBlock.java.patch deleted file mode 100644 index 52223a23a7..0000000000 --- a/patches/minecraft/net/minecraft/world/entity/vehicle/MinecartCommandBlock.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/world/entity/vehicle/MinecartCommandBlock.java -+++ b/net/minecraft/world/entity/vehicle/MinecartCommandBlock.java -@@ -84,6 +_,8 @@ - - @Override - public InteractionResult interact(Player p_38522_, InteractionHand p_38523_) { -+ InteractionResult ret = super.interact(p_38522_, p_38523_); -+ if (ret.consumesAction()) return ret; - return this.commandBlock.usedBy(p_38522_); - } - diff --git a/patches/minecraft/net/minecraft/world/entity/vehicle/MinecartSpawner.java.patch b/patches/minecraft/net/minecraft/world/entity/vehicle/MinecartSpawner.java.patch deleted file mode 100644 index cb4e7cc7b3..0000000000 --- a/patches/minecraft/net/minecraft/world/entity/vehicle/MinecartSpawner.java.patch +++ /dev/null @@ -1,15 +0,0 @@ ---- a/net/minecraft/world/entity/vehicle/MinecartSpawner.java -+++ b/net/minecraft/world/entity/vehicle/MinecartSpawner.java -@@ -19,6 +_,12 @@ - public void broadcastEvent(Level p_150342_, BlockPos p_150343_, int p_150344_) { - p_150342_.broadcastEntityEvent(MinecartSpawner.this, (byte)p_150344_); - } -+ -+ @Override -+ @org.jetbrains.annotations.Nullable -+ public net.minecraft.world.entity.Entity getSpawnerEntity() { -+ return MinecartSpawner.this; -+ } - }; - private final Runnable ticker; - diff --git a/patches/minecraft/net/minecraft/world/entity/vehicle/AbstractBoat.java.patch b/patches/minecraft/net/minecraft/world/entity/vehicle/boat/AbstractBoat.java.patch similarity index 85% rename from patches/minecraft/net/minecraft/world/entity/vehicle/AbstractBoat.java.patch rename to patches/minecraft/net/minecraft/world/entity/vehicle/boat/AbstractBoat.java.patch index ec8d3dc8ad..f89b1d587a 100644 --- a/patches/minecraft/net/minecraft/world/entity/vehicle/AbstractBoat.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/vehicle/boat/AbstractBoat.java.patch @@ -1,15 +1,15 @@ ---- a/net/minecraft/world/entity/vehicle/AbstractBoat.java -+++ b/net/minecraft/world/entity/vehicle/AbstractBoat.java -@@ -46,7 +_,7 @@ - import net.minecraft.world.phys.shapes.Shapes; +--- a/net/minecraft/world/entity/vehicle/boat/AbstractBoat.java ++++ b/net/minecraft/world/entity/vehicle/boat/AbstractBoat.java +@@ -48,7 +_,7 @@ import net.minecraft.world.phys.shapes.VoxelShape; + import org.jspecify.annotations.Nullable; -public abstract class AbstractBoat extends VehicleEntity implements Leashable { +public abstract class AbstractBoat extends VehicleEntity implements Leashable, net.minecraftforge.common.extensions.IForgeAbstractBoat { 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); -@@ -423,7 +_,7 @@ +@@ -422,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)); } -@@ -469,7 +_,7 @@ +@@ -468,7 +_,7 @@ voxelshape, BooleanOp.AND )) { @@ -27,7 +27,7 @@ k1++; } } -@@ -498,7 +_,7 @@ +@@ -497,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; -@@ -528,7 +_,7 @@ +@@ -526,7 +_,7 @@ for (int i2 = i1; i2 < j1; i2++) { blockpos$mutableblockpos.set(k1, l1, i2); FluidState fluidstate = this.level().getFluidState(blockpos$mutableblockpos); @@ -45,19 +45,19 @@ && d0 < blockpos$mutableblockpos.getY() + fluidstate.getHeight(this.level(), blockpos$mutableblockpos)) { if (!fluidstate.isSource()) { return AbstractBoat.Status.UNDER_FLOWING_WATER; -@@ -731,7 +_,7 @@ +@@ -729,7 +_,7 @@ if (!this.isPassenger()) { - if (p_361999_) { + if (p_455047_) { this.resetFallDistance(); -- } else if (!this.level().getFluidState(this.blockPosition().below()).is(FluidTags.WATER) && p_361830_ < 0.0) { -+ } else if (!this.canBoatInFluid(this.level().getFluidState(this.blockPosition().below())) && p_361830_ < 0.0) { - this.fallDistance -= (float)p_361830_; +- } else if (!this.level().getFluidState(this.blockPosition().below()).is(FluidTags.WATER) && p_456661_ < 0.0) { ++ } else if (!this.canBoatInFluid(this.level().getFluidState(this.blockPosition().below())) && p_456661_ < 0.0) { + this.fallDistance -= (float)p_456661_; } } -@@ -755,7 +_,7 @@ +@@ -753,7 +_,7 @@ @Override - protected boolean canAddPassenger(Entity p_366021_) { + protected boolean canAddPassenger(Entity p_457043_) { - return this.getPassengers().size() < this.getMaxPassengers() && !this.isEyeInFluid(FluidTags.WATER); + return this.getPassengers().size() < this.getMaxPassengers() && !this.canBoatInFluid(this.getEyeInFluidType()); } diff --git a/patches/minecraft/net/minecraft/world/entity/vehicle/ChestBoat.java.patch b/patches/minecraft/net/minecraft/world/entity/vehicle/boat/ChestBoat.java.patch similarity index 81% rename from patches/minecraft/net/minecraft/world/entity/vehicle/ChestBoat.java.patch rename to patches/minecraft/net/minecraft/world/entity/vehicle/boat/ChestBoat.java.patch index 2157ea10eb..58a9c754f5 100644 --- a/patches/minecraft/net/minecraft/world/entity/vehicle/ChestBoat.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/vehicle/boat/ChestBoat.java.patch @@ -1,8 +1,8 @@ ---- a/net/minecraft/world/entity/vehicle/ChestBoat.java -+++ b/net/minecraft/world/entity/vehicle/ChestBoat.java +--- a/net/minecraft/world/entity/vehicle/boat/ChestBoat.java ++++ b/net/minecraft/world/entity/vehicle/boat/ChestBoat.java @@ -15,4 +_,26 @@ - protected double rideHeight(EntityDimensions p_362135_) { - return p_362135_.height() / 3.0F; + protected double rideHeight(EntityDimensions p_451474_) { + return p_451474_.height() / 3.0F; } + + private net.minecraftforge.common.util.LazyOptional itemHandler = net.minecraftforge.common.util.LazyOptional.of(() -> new net.minecraftforge.items.wrapper.InvWrapper(this)); diff --git a/patches/minecraft/net/minecraft/world/entity/vehicle/AbstractMinecart.java.patch b/patches/minecraft/net/minecraft/world/entity/vehicle/minecart/AbstractMinecart.java.patch similarity index 81% rename from patches/minecraft/net/minecraft/world/entity/vehicle/AbstractMinecart.java.patch rename to patches/minecraft/net/minecraft/world/entity/vehicle/minecart/AbstractMinecart.java.patch index db1db9aa3b..4863cd479d 100644 --- a/patches/minecraft/net/minecraft/world/entity/vehicle/AbstractMinecart.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/vehicle/minecart/AbstractMinecart.java.patch @@ -1,33 +1,33 @@ ---- a/net/minecraft/world/entity/vehicle/AbstractMinecart.java -+++ b/net/minecraft/world/entity/vehicle/AbstractMinecart.java -@@ -43,7 +_,7 @@ - import net.minecraft.world.phys.AABB; +--- a/net/minecraft/world/entity/vehicle/minecart/AbstractMinecart.java ++++ b/net/minecraft/world/entity/vehicle/minecart/AbstractMinecart.java +@@ -46,7 +_,7 @@ import net.minecraft.world.phys.Vec3; + import org.jspecify.annotations.Nullable; -public abstract class AbstractMinecart extends VehicleEntity { +public abstract class AbstractMinecart extends VehicleEntity implements net.minecraftforge.common.extensions.IForgeAbstractMinecart { private static final Vec3 LOWERED_PASSENGER_ATTACHMENT = new Vec3(0.0, 0.0, 0.0); private static final EntityDataAccessor> DATA_ID_CUSTOM_DISPLAY_BLOCK = SynchedEntityData.defineId( AbstractMinecart.class, EntityDataSerializers.OPTIONAL_BLOCK_STATE -@@ -93,15 +_,12 @@ +@@ -96,15 +_,12 @@ } ) ); + private boolean canBePushed = true; - protected AbstractMinecart(EntityType p_38087_, Level p_38088_) { - super(p_38087_, p_38088_); + protected AbstractMinecart(EntityType p_452328_, Level p_453891_) { + super(p_452328_, p_453891_); this.blocksBuilding = true; -- if (useExperimentalMovement(p_38088_)) { +- if (useExperimentalMovement(p_453891_)) { - this.behavior = new NewMinecartBehavior(this); - } else { - this.behavior = new OldMinecartBehavior(this); - } -+ this.behavior = behaviorFactory.apply(this, p_38088_); ++ this.behavior = behaviorFactory.apply(this, p_453891_); } - protected AbstractMinecart(EntityType p_38090_, Level p_38091_, double p_38092_, double p_38093_, double p_38094_) { -@@ -164,7 +_,7 @@ + protected AbstractMinecart(EntityType p_455342_, Level p_453365_, double p_454565_, double p_451452_, double p_452544_) { +@@ -166,7 +_,7 @@ @Override public boolean isPushable() { @@ -36,12 +36,12 @@ } @Override -@@ -360,16 +_,24 @@ +@@ -363,16 +_,24 @@ } - protected void comeOffTrack(ServerLevel p_365684_) { -- double d0 = this.getMaxSpeed(p_365684_); -+ double d0 = this.onGround() ? this.getMaxSpeed(p_365684_) : getMaxSpeedAirLateral(); + protected void comeOffTrack(ServerLevel p_460723_) { +- double d0 = this.getMaxSpeed(p_460723_); ++ double d0 = this.onGround() ? this.getMaxSpeed(p_460723_) : getMaxSpeedAirLateral(); Vec3 vec3 = this.getDeltaMovement(); this.setDeltaMovement(Mth.clamp(vec3.x, -d0, d0), vec3.y, Mth.clamp(vec3.z, -d0, d0)); if (this.onGround()) { @@ -63,16 +63,16 @@ } } -@@ -426,7 +_,7 @@ - public Vec3 getRedstoneDirection(BlockPos p_369874_) { - BlockState blockstate = this.level().getBlockState(p_369874_); +@@ -429,7 +_,7 @@ + public Vec3 getRedstoneDirection(BlockPos p_456192_) { + BlockState blockstate = this.level().getBlockState(p_456192_); if (blockstate.is(Blocks.POWERED_RAIL) && blockstate.getValue(PoweredRailBlock.POWERED)) { - RailShape railshape = blockstate.getValue(((BaseRailBlock)blockstate.getBlock()).getShapeProperty()); -+ RailShape railshape = ((BaseRailBlock)blockstate.getBlock()).getRailDirection(blockstate, this.level(), p_369874_, this); ++ RailShape railshape = ((BaseRailBlock)blockstate.getBlock()).getRailDirection(blockstate, this.level(), p_456192_, this); if (railshape == RailShape.EAST_WEST) { - if (this.isRedstoneConductor(p_369874_.west())) { + if (this.isRedstoneConductor(p_456192_.west())) { return new Vec3(1.0, 0.0, 0.0); -@@ -598,5 +_,42 @@ +@@ -601,5 +_,42 @@ public boolean isFurnace() { return false; diff --git a/patches/minecraft/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java.patch b/patches/minecraft/net/minecraft/world/entity/vehicle/minecart/AbstractMinecartContainer.java.patch similarity index 71% rename from patches/minecraft/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java.patch rename to patches/minecraft/net/minecraft/world/entity/vehicle/minecart/AbstractMinecartContainer.java.patch index 54130e5438..2f6f01c6c6 100644 --- a/patches/minecraft/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/vehicle/minecart/AbstractMinecartContainer.java.patch @@ -1,15 +1,15 @@ ---- a/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java -+++ b/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java +--- a/net/minecraft/world/entity/vehicle/minecart/AbstractMinecartContainer.java ++++ b/net/minecraft/world/entity/vehicle/minecart/AbstractMinecartContainer.java @@ -94,6 +_,8 @@ @Override - public InteractionResult interact(Player p_38232_, InteractionHand p_38233_) { -+ var ret = super.interact(p_38232_, p_38233_); + public InteractionResult interact(Player p_452542_, InteractionHand p_458127_) { ++ var ret = super.interact(p_452542_, p_458127_); + if (ret.consumesAction()) return ret; - return this.interactWithContainerVehicle(p_38232_); + return this.interactWithContainerVehicle(p_452542_); } -@@ -164,5 +_,27 @@ +@@ -162,5 +_,27 @@ @Override public void clearItemStacks() { this.itemStacks = NonNullList.withSize(this.getContainerSize(), ItemStack.EMPTY); @@ -18,7 +18,7 @@ + private net.minecraftforge.common.util.LazyOptional itemHandler = net.minecraftforge.common.util.LazyOptional.of(() -> new net.minecraftforge.items.wrapper.InvWrapper(this)); + + @Override -+ public net.minecraftforge.common.util.LazyOptional getCapability(net.minecraftforge.common.capabilities.Capability capability, @Nullable net.minecraft.core.Direction facing) { ++ public net.minecraftforge.common.util.LazyOptional getCapability(net.minecraftforge.common.capabilities.Capability capability, net.minecraft.core.@Nullable Direction facing) { + if (capability == net.minecraftforge.common.capabilities.ForgeCapabilities.ITEM_HANDLER && this.isAlive()) { + return itemHandler.cast(); + } diff --git a/patches/minecraft/net/minecraft/world/entity/vehicle/minecart/MinecartCommandBlock.java.patch b/patches/minecraft/net/minecraft/world/entity/vehicle/minecart/MinecartCommandBlock.java.patch new file mode 100644 index 0000000000..0561fc1f25 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/vehicle/minecart/MinecartCommandBlock.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/entity/vehicle/minecart/MinecartCommandBlock.java ++++ b/net/minecraft/world/entity/vehicle/minecart/MinecartCommandBlock.java +@@ -84,6 +_,8 @@ + + @Override + public InteractionResult interact(Player p_459569_, InteractionHand p_455676_) { ++ InteractionResult ret = super.interact(p_459569_, p_455676_); ++ if (ret.consumesAction()) return ret; + if (!p_459569_.canUseGameMasterBlocks()) { + return InteractionResult.PASS; + } else { diff --git a/patches/minecraft/net/minecraft/world/entity/vehicle/MinecartFurnace.java.patch b/patches/minecraft/net/minecraft/world/entity/vehicle/minecart/MinecartFurnace.java.patch similarity index 68% rename from patches/minecraft/net/minecraft/world/entity/vehicle/MinecartFurnace.java.patch rename to patches/minecraft/net/minecraft/world/entity/vehicle/minecart/MinecartFurnace.java.patch index 6a4e7cad92..ace811b0d5 100644 --- a/patches/minecraft/net/minecraft/world/entity/vehicle/MinecartFurnace.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/vehicle/minecart/MinecartFurnace.java.patch @@ -1,5 +1,5 @@ ---- a/net/minecraft/world/entity/vehicle/MinecartFurnace.java -+++ b/net/minecraft/world/entity/vehicle/MinecartFurnace.java +--- a/net/minecraft/world/entity/vehicle/minecart/MinecartFurnace.java ++++ b/net/minecraft/world/entity/vehicle/minecart/MinecartFurnace.java @@ -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/entity/vehicle/minecart/MinecartSpawner.java.patch b/patches/minecraft/net/minecraft/world/entity/vehicle/minecart/MinecartSpawner.java.patch new file mode 100644 index 0000000000..d6fd72d553 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/vehicle/minecart/MinecartSpawner.java.patch @@ -0,0 +1,14 @@ +--- a/net/minecraft/world/entity/vehicle/minecart/MinecartSpawner.java ++++ b/net/minecraft/world/entity/vehicle/minecart/MinecartSpawner.java +@@ -19,6 +_,11 @@ + public void broadcastEvent(Level p_451201_, BlockPos p_454356_, int p_454162_) { + p_451201_.broadcastEntityEvent(MinecartSpawner.this, (byte)p_454162_); + } ++ ++ @Override ++ public net.minecraft.world.entity.@org.jspecify.annotations.Nullable Entity getSpawnerEntity() { ++ return MinecartSpawner.this; ++ } + }; + private final Runnable ticker; + diff --git a/patches/minecraft/net/minecraft/world/entity/vehicle/NewMinecartBehavior.java.patch b/patches/minecraft/net/minecraft/world/entity/vehicle/minecart/NewMinecartBehavior.java.patch similarity index 52% rename from patches/minecraft/net/minecraft/world/entity/vehicle/NewMinecartBehavior.java.patch rename to patches/minecraft/net/minecraft/world/entity/vehicle/minecart/NewMinecartBehavior.java.patch index 1891c81116..7d96ac3654 100644 --- a/patches/minecraft/net/minecraft/world/entity/vehicle/NewMinecartBehavior.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/vehicle/minecart/NewMinecartBehavior.java.patch @@ -1,45 +1,46 @@ ---- a/net/minecraft/world/entity/vehicle/NewMinecartBehavior.java -+++ b/net/minecraft/world/entity/vehicle/NewMinecartBehavior.java -@@ -170,7 +_,7 @@ +--- a/net/minecraft/world/entity/vehicle/minecart/NewMinecartBehavior.java ++++ b/net/minecraft/world/entity/vehicle/minecart/NewMinecartBehavior.java +@@ -169,7 +_,7 @@ - public void adjustToRails(BlockPos p_367561_, BlockState p_368130_, boolean p_364585_) { - if (BaseRailBlock.isRail(p_368130_)) { -- RailShape railshape = p_368130_.getValue(((BaseRailBlock)p_368130_.getBlock()).getShapeProperty()); -+ RailShape railshape = ((BaseRailBlock)p_368130_.getBlock()).getRailDirection(p_368130_, this.level(), p_367561_, this.minecart); + public void adjustToRails(BlockPos p_451133_, BlockState p_453781_, boolean p_453463_) { + if (BaseRailBlock.isRail(p_453781_)) { +- RailShape railshape = p_453781_.getValue(((BaseRailBlock)p_453781_.getBlock()).getShapeProperty()); ++ RailShape railshape = ((BaseRailBlock)p_453781_.getBlock()).getRailDirection(p_453781_, this.level(), p_451133_, this.minecart); Pair pair = AbstractMinecart.exits(railshape); Vec3 vec3 = new Vec3(pair.getFirst()).scale(0.5); Vec3 vec31 = new Vec3(pair.getSecond()).scale(0.5); -@@ -260,11 +_,11 @@ +@@ -259,12 +_,12 @@ if (flag) { this.minecart.resetFallDistance(); this.minecart.setOldPosAndRot(); - if (blockstate.is(Blocks.ACTIVATOR_RAIL)) { + if (blockstate.getBlock() instanceof PoweredRailBlock power && power.isActivatorRail()) { - this.minecart.activateMinecart(blockpos.getX(), blockpos.getY(), blockpos.getZ(), blockstate.getValue(PoweredRailBlock.POWERED)); + this.minecart + .activateMinecart(p_450194_, blockpos.getX(), blockpos.getY(), blockpos.getZ(), blockstate.getValue(PoweredRailBlock.POWERED)); } - RailShape railshape = blockstate.getValue(((BaseRailBlock)blockstate.getBlock()).getShapeProperty()); + RailShape railshape = ((BaseRailBlock)blockstate.getBlock()).getRailDirection(blockstate, this.level(), blockpos, this.minecart); - Vec3 vec31 = this.calculateTrackSpeed(p_369629_, vec3.horizontal(), newminecartbehavior$trackiteration, blockpos, blockstate, railshape); + Vec3 vec31 = this.calculateTrackSpeed(p_450194_, vec3.horizontal(), newminecartbehavior$trackiteration, blockpos, blockstate, railshape); if (newminecartbehavior$trackiteration.firstIteration) { newminecartbehavior$trackiteration.movementLeft = vec31.horizontalDistance(); @@ -393,7 +_,7 @@ } - private Vec3 calculateHaltTrackSpeed(Vec3 p_364212_, BlockState p_362846_) { -- if (p_362846_.is(Blocks.POWERED_RAIL) && !p_362846_.getValue(PoweredRailBlock.POWERED)) { -+ if (p_362846_.getBlock() instanceof PoweredRailBlock powered && !powered.isActivatorRail() && !p_362846_.getValue(PoweredRailBlock.POWERED)) { - return p_364212_.length() < 0.03 ? Vec3.ZERO : p_364212_.scale(0.5); + private Vec3 calculateHaltTrackSpeed(Vec3 p_460405_, BlockState p_457203_) { +- if (p_457203_.is(Blocks.POWERED_RAIL) && !p_457203_.getValue(PoweredRailBlock.POWERED)) { ++ if (p_457203_.getBlock() instanceof PoweredRailBlock powered && !powered.isActivatorRail() && !p_457203_.getValue(PoweredRailBlock.POWERED)) { + return p_460405_.length() < 0.03 ? Vec3.ZERO : p_460405_.scale(0.5); } else { - return p_364212_; + return p_460405_; @@ -401,7 +_,7 @@ } - private Vec3 calculateBoostTrackSpeed(Vec3 p_366761_, BlockPos p_361866_, BlockState p_368734_) { -- if (p_368734_.is(Blocks.POWERED_RAIL) && p_368734_.getValue(PoweredRailBlock.POWERED)) { -+ if (p_368734_.getBlock() instanceof PoweredRailBlock powered && !powered.isActivatorRail() && p_368734_.getValue(PoweredRailBlock.POWERED)) { - if (p_366761_.length() > 0.01) { - return p_366761_.normalize().scale(p_366761_.length() + 0.06); + private Vec3 calculateBoostTrackSpeed(Vec3 p_451672_, BlockPos p_453710_, BlockState p_457216_) { +- if (p_457216_.is(Blocks.POWERED_RAIL) && p_457216_.getValue(PoweredRailBlock.POWERED)) { ++ if (p_457216_.getBlock() instanceof PoweredRailBlock powered && !powered.isActivatorRail() && p_457216_.getValue(PoweredRailBlock.POWERED)) { + if (p_451672_.length() > 0.01) { + return p_451672_.normalize().scale(p_451672_.length() + 0.06); } else { @@ -453,7 +_,7 @@ BlockState blockstate = this.level().getBlockState(BlockPos.containing(vec36)); @@ -47,6 +48,6 @@ if (BaseRailBlock.isRail(blockstate)) { - RailShape railshape = blockstate.getValue(((BaseRailBlock)blockstate.getBlock()).getShapeProperty()); + RailShape railshape = ((BaseRailBlock)blockstate.getBlock()).getRailDirection(blockstate, this.level(), BlockPos.containing(vec36), this.minecart); - if (this.restAtVShape(p_363897_, railshape)) { + if (this.restAtVShape(p_452428_, railshape)) { return 0.0; } diff --git a/patches/minecraft/net/minecraft/world/entity/vehicle/OldMinecartBehavior.java.patch b/patches/minecraft/net/minecraft/world/entity/vehicle/minecart/OldMinecartBehavior.java.patch similarity index 86% rename from patches/minecraft/net/minecraft/world/entity/vehicle/OldMinecartBehavior.java.patch rename to patches/minecraft/net/minecraft/world/entity/vehicle/minecart/OldMinecartBehavior.java.patch index 3b8b8e8a2d..402ed08f47 100644 --- a/patches/minecraft/net/minecraft/world/entity/vehicle/OldMinecartBehavior.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/vehicle/minecart/OldMinecartBehavior.java.patch @@ -1,5 +1,5 @@ ---- a/net/minecraft/world/entity/vehicle/OldMinecartBehavior.java -+++ b/net/minecraft/world/entity/vehicle/OldMinecartBehavior.java +--- a/net/minecraft/world/entity/vehicle/minecart/OldMinecartBehavior.java ++++ b/net/minecraft/world/entity/vehicle/minecart/OldMinecartBehavior.java @@ -60,9 +_,9 @@ BlockState blockstate = this.level().getBlockState(blockpos); boolean $$4 = BaseRailBlock.isRail(blockstate); @@ -9,10 +9,10 @@ this.moveAlongTrack(serverlevel); - if (blockstate.is(Blocks.ACTIVATOR_RAIL)) { + if (blockstate.getBlock() instanceof PoweredRailBlock power && power.isActivatorRail()) { - this.minecart.activateMinecart(blockpos.getX(), blockpos.getY(), blockpos.getZ(), blockstate.getValue(PoweredRailBlock.POWERED)); - } - } else { -@@ -112,18 +_,19 @@ + this.minecart + .activateMinecart( + serverlevel, blockpos.getX(), blockpos.getY(), blockpos.getZ(), blockstate.getValue(PoweredRailBlock.POWERED) +@@ -115,18 +_,19 @@ d1 = blockpos.getY(); boolean flag = false; boolean flag1 = false; @@ -35,7 +35,7 @@ switch (railshape) { case ASCENDING_EAST: this.setDeltaMovement(vec31.add(-d3, 0.0, 0.0)); -@@ -175,7 +_,7 @@ +@@ -178,7 +_,7 @@ } } @@ -44,19 +44,19 @@ double d20 = this.getDeltaMovement().horizontalDistance(); if (d20 < 0.03) { this.setDeltaMovement(Vec3.ZERO); -@@ -204,10 +_,7 @@ +@@ -207,10 +_,7 @@ d0 = d21 + d4 * d12; d2 = d9 + d5 * d12; this.setPos(d0, d1, d2); - double d23 = this.minecart.isVehicle() ? 0.75 : 1.0; -- double d24 = this.minecart.getMaxSpeed(p_366781_); +- double d24 = this.minecart.getMaxSpeed(p_458640_); - vec31 = this.getDeltaMovement(); - this.minecart.move(MoverType.SELF, new Vec3(Mth.clamp(d23 * vec31.x, -d24, d24), 0.0, Mth.clamp(d23 * vec31.z, -d24, d24))); -+ this.moveMinecartOnRail(p_366781_); ++ this.moveMinecartOnRail(p_458640_); if (vec3i.getY() != 0 && Mth.floor(this.minecart.getX()) - blockpos.getX() == vec3i.getX() && Mth.floor(this.minecart.getZ()) - blockpos.getZ() == vec3i.getZ()) { -@@ -239,7 +_,11 @@ +@@ -242,7 +_,11 @@ this.setDeltaMovement(d25 * (j - blockpos.getX()), vec36.y, d25 * (i - blockpos.getZ())); } @@ -69,16 +69,16 @@ Vec3 vec37 = this.getDeltaMovement(); double d26 = vec37.horizontalDistance(); if (d26 > 0.01) { -@@ -283,7 +_,7 @@ +@@ -285,7 +_,7 @@ BlockState blockstate = this.level().getBlockState(new BlockPos(i, j, k)); if (BaseRailBlock.isRail(blockstate)) { - RailShape railshape = blockstate.getValue(((BaseRailBlock)blockstate.getBlock()).getShapeProperty()); + RailShape railshape = ((BaseRailBlock)blockstate.getBlock()).getRailDirection(blockstate, this.level(), new BlockPos(i, j, k), this.minecart); - p_364195_ = j; + p_458616_ = j; if (railshape.isSlope()) { - p_364195_ = j + 1; -@@ -322,7 +_,7 @@ + p_458616_ = j + 1; +@@ -323,7 +_,7 @@ BlockState blockstate = this.level().getBlockState(new BlockPos(i, j, k)); if (BaseRailBlock.isRail(blockstate)) { @@ -87,7 +87,7 @@ Pair pair = AbstractMinecart.exits(railshape); Vec3i vec3i = pair.getFirst(); Vec3i vec3i1 = pair.getSecond(); -@@ -415,5 +_,20 @@ +@@ -416,5 +_,20 @@ @Override public double getSlowdownFactor() { return this.minecart.isVehicle() ? 0.997 : 0.96; diff --git a/patches/minecraft/net/minecraft/world/inventory/AbstractContainerMenu.java.patch b/patches/minecraft/net/minecraft/world/inventory/AbstractContainerMenu.java.patch index 73ac30974b..68df0ef153 100644 --- a/patches/minecraft/net/minecraft/world/inventory/AbstractContainerMenu.java.patch +++ b/patches/minecraft/net/minecraft/world/inventory/AbstractContainerMenu.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/inventory/AbstractContainerMenu.java +++ b/net/minecraft/world/inventory/AbstractContainerMenu.java -@@ -441,6 +_,7 @@ +@@ -439,6 +_,7 @@ ItemStack itemstack10 = this.getCarried(); p_150434_.updateTutorialInventoryAction(itemstack10, slot7.getItem(), clickaction); if (!this.tryItemClickBehaviourOverride(p_150434_, clickaction, slot7, itemstack9, itemstack10)) { @@ -8,7 +8,7 @@ if (itemstack9.isEmpty()) { if (!itemstack10.isEmpty()) { int i3 = clickaction == ClickAction.PRIMARY ? itemstack10.getCount() : 1; -@@ -650,7 +_,7 @@ +@@ -648,7 +_,7 @@ ItemStack itemstack = slot.getItem(); if (!itemstack.isEmpty() && ItemStack.isSameItemSameComponents(p_38904_, itemstack)) { int j = itemstack.getCount() + p_38904_.getCount(); diff --git a/patches/minecraft/net/minecraft/world/inventory/AnvilMenu.java.patch b/patches/minecraft/net/minecraft/world/inventory/AnvilMenu.java.patch index dbbf1b001d..f7b3103b5d 100644 --- a/patches/minecraft/net/minecraft/world/inventory/AnvilMenu.java.patch +++ b/patches/minecraft/net/minecraft/world/inventory/AnvilMenu.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/inventory/AnvilMenu.java +++ b/net/minecraft/world/inventory/AnvilMenu.java -@@ -80,6 +_,8 @@ +@@ -79,6 +_,8 @@ p_150474_.giveExperienceLevels(-this.cost.get()); } @@ -9,7 +9,7 @@ if (this.repairItemCountCost > 0) { ItemStack itemstack = this.inputSlots.getItem(1); if (!itemstack.isEmpty() && itemstack.getCount() > this.repairItemCountCost) { -@@ -102,7 +_,7 @@ +@@ -101,7 +_,7 @@ this.inputSlots.setItem(0, ItemStack.EMPTY); this.access.execute((p_150479_, p_150480_) -> { BlockState blockstate = p_150479_.getBlockState(p_150480_); @@ -18,7 +18,7 @@ BlockState blockstate1 = AnvilBlock.damage(blockstate); if (blockstate1 == null) { p_150479_.removeBlock(p_150480_, false); -@@ -131,8 +_,11 @@ +@@ -130,8 +_,11 @@ ItemEnchantments.Mutable itemenchantments$mutable = new ItemEnchantments.Mutable(EnchantmentHelper.getEnchantmentsForCrafting(itemstack1)); j += (long)itemstack.getOrDefault(DataComponents.REPAIR_COST, 0).intValue() + itemstack2.getOrDefault(DataComponents.REPAIR_COST, 0).intValue(); this.repairItemCountCost = 0; @@ -31,7 +31,7 @@ if (itemstack1.isDamageableItem() && itemstack.isValidRepairItem(itemstack2)) { int l2 = Math.min(itemstack1.getDamageValue(), itemstack1.getMaxDamage() / 4); if (l2 <= 0) { -@@ -236,6 +_,10 @@ +@@ -235,6 +_,10 @@ itemstack1.remove(DataComponents.CUSTOM_NAME); } @@ -42,7 +42,7 @@ int k2 = i <= 0 ? 0 : (int)Mth.clamp(j + i, 0L, 2147483647L); this.cost.set(k2); if (i <= 0) { -@@ -308,5 +_,9 @@ +@@ -306,5 +_,9 @@ public int getCost() { return this.cost.get(); diff --git a/patches/minecraft/net/minecraft/world/inventory/ArmorSlot.java.patch b/patches/minecraft/net/minecraft/world/inventory/ArmorSlot.java.patch index 00c8151fba..90bff38906 100644 --- a/patches/minecraft/net/minecraft/world/inventory/ArmorSlot.java.patch +++ b/patches/minecraft/net/minecraft/world/inventory/ArmorSlot.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/inventory/ArmorSlot.java +++ b/net/minecraft/world/inventory/ArmorSlot.java -@@ -38,7 +_,7 @@ +@@ -37,7 +_,7 @@ @Override public boolean mayPlace(ItemStack p_344267_) { diff --git a/patches/minecraft/net/minecraft/world/inventory/EnchantmentMenu.java.patch b/patches/minecraft/net/minecraft/world/inventory/EnchantmentMenu.java.patch index 460e2871be..3c91be2590 100644 --- a/patches/minecraft/net/minecraft/world/inventory/EnchantmentMenu.java.patch +++ b/patches/minecraft/net/minecraft/world/inventory/EnchantmentMenu.java.patch @@ -11,15 +11,15 @@ @Override @@ -90,23 +_,25 @@ if (!itemstack.isEmpty() && itemstack.isEnchantable()) { - this.access.execute((p_341515_, p_341516_) -> { - IdMap> idmap = p_341515_.registryAccess().lookupOrThrow(Registries.ENCHANTMENT).asHolderIdMap(); + this.access.execute((p_449765_, p_449766_) -> { + IdMap> idmap = p_449765_.registryAccess().lookupOrThrow(Registries.ENCHANTMENT).asHolderIdMap(); - int j = 0; + float j = 0; for (BlockPos blockpos : EnchantingTableBlock.BOOKSHELF_OFFSETS) { - if (EnchantingTableBlock.isValidBookShelf(p_341515_, p_341516_, blockpos)) { + if (EnchantingTableBlock.isValidBookShelf(p_449765_, p_449766_, blockpos)) { j++; -+ j += p_341515_.getBlockState(p_341516_.offset(blockpos)).getEnchantPowerBonus(p_341515_, p_341516_.offset(blockpos)); ++ j += p_449765_.getBlockState(p_449766_.offset(blockpos)).getEnchantPowerBonus(p_449765_, p_449766_.offset(blockpos)); } } @@ -33,7 +33,7 @@ if (this.costs[k] < k + 1) { this.costs[k] = 0; } -+ this.costs[k] = net.minecraftforge.event.ForgeEventFactory.onEnchantmentLevelSet(p_341515_, p_341516_, k, (int)j, itemstack, costs[k]); ++ this.costs[k] = net.minecraftforge.event.ForgeEventFactory.onEnchantmentLevelSet(p_449765_, p_449766_, k, (int)j, itemstack, costs[k]); } for (int l = 0; l < 3; l++) { diff --git a/patches/minecraft/net/minecraft/world/inventory/Slot.java.patch b/patches/minecraft/net/minecraft/world/inventory/Slot.java.patch index b51036baf1..3d1e646679 100644 --- a/patches/minecraft/net/minecraft/world/inventory/Slot.java.patch +++ b/patches/minecraft/net/minecraft/world/inventory/Slot.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/inventory/Slot.java +++ b/net/minecraft/world/inventory/Slot.java -@@ -80,7 +_,7 @@ +@@ -79,7 +_,7 @@ + } - @Nullable - public ResourceLocation getNoItemIcon() { + public @Nullable Identifier getNoItemIcon() { - return null; + return background; } public ItemStack remove(int p_40227_) { -@@ -161,5 +_,36 @@ +@@ -160,5 +_,36 @@ public boolean isFake() { return false; @@ -34,14 +34,14 @@ + return this.container == other.container; + } + -+ private ResourceLocation background; ++ private Identifier background; + /** + * Sets the background atlas and sprite location. + * + * @param sprite The sprite located on that atlas. + * @return this, to allow chaining. + */ -+ public Slot setBackground(ResourceLocation sprite) { ++ public Slot setBackground(Identifier sprite) { + this.background = sprite; + return this; } diff --git a/patches/minecraft/net/minecraft/world/item/BlockItem.java.patch b/patches/minecraft/net/minecraft/world/item/BlockItem.java.patch index 8198a23389..b7af32585c 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 -@@ -76,9 +_,9 @@ +@@ -77,9 +_,9 @@ } } @@ -12,7 +12,7 @@ ); level.gameEvent(GameEvent.BLOCK_PLACE, blockpos, GameEvent.Context.of(player, blockstate1)); itemstack.consume(1, player); -@@ -88,10 +_,16 @@ +@@ -89,10 +_,16 @@ } } @@ -26,10 +26,10 @@ + return state.getSoundType(world, pos, entity).getPlaceSound(); + } + - @Nullable - public BlockPlaceContext updatePlacementContext(BlockPlaceContext p_40609_) { + public @Nullable BlockPlaceContext updatePlacementContext(BlockPlaceContext p_40609_) { return p_40609_; -@@ -186,6 +_,10 @@ + } +@@ -185,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 55eb1af407..b1534159e5 100644 --- a/patches/minecraft/net/minecraft/world/item/BoneMealItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/BoneMealItem.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/item/BoneMealItem.java +++ b/net/minecraft/world/item/BoneMealItem.java -@@ -37,7 +_,7 @@ - Level level = p_40637_.getLevel(); +@@ -38,7 +_,7 @@ BlockPos blockpos = p_40637_.getClickedPos(); BlockPos blockpos1 = blockpos.relative(p_40637_.getClickedFace()); -- if (growCrop(p_40637_.getItemInHand(), level, blockpos)) { -+ if (applyBonemeal(p_40637_.getItemInHand(), level, blockpos, p_40637_.getPlayer())) { + ItemStack itemstack = p_40637_.getItemInHand(); +- if (growCrop(itemstack, level, blockpos)) { ++ if (applyBonemeal(itemstack, level, blockpos, p_40637_.getPlayer())) { if (!level.isClientSide()) { - p_40637_.getPlayer().gameEvent(GameEvent.ITEM_INTERACT_FINISH); + itemstack.causeUseVibration(p_40637_.getPlayer(), GameEvent.ITEM_INTERACT_FINISH); level.levelEvent(1505, blockpos, 15); -@@ -60,8 +_,18 @@ +@@ -61,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 ab6ce16c5c..c78510c909 100644 --- a/patches/minecraft/net/minecraft/world/item/BucketItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/BucketItem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/BucketItem.java +++ b/net/minecraft/world/item/BucketItem.java -@@ -32,15 +_,29 @@ +@@ -33,15 +_,29 @@ public class BucketItem extends Item implements DispensibleContainerItem { private final Fluid content; @@ -30,7 +30,7 @@ if (blockhitresult.getType() == HitResult.Type.MISS) { return InteractionResult.PASS; } else if (blockhitresult.getType() != HitResult.Type.BLOCK) { -@@ -57,7 +_,7 @@ +@@ -58,7 +_,7 @@ ItemStack itemstack3 = bucketpickup.pickupBlock(p_40704_, p_40703_, blockpos, blockstate1); if (!itemstack3.isEmpty()) { p_40704_.awardStat(Stats.ITEM_USED.get(this)); @@ -39,7 +39,7 @@ p_40703_.gameEvent(p_40704_, GameEvent.FLUID_PICKUP, blockpos); ItemStack itemstack2 = ItemUtils.createFilledResult(itemstack, p_40704_, itemstack3); if (!p_40703_.isClientSide()) { -@@ -71,8 +_,8 @@ +@@ -72,8 +_,8 @@ return InteractionResult.FAIL; } else { BlockState blockstate = p_40703_.getBlockState(blockpos); @@ -50,7 +50,7 @@ this.checkExtraContent(p_40704_, p_40703_, itemstack, blockpos2); if (p_40704_ instanceof ServerPlayer) { CriteriaTriggers.PLACED_BLOCK.trigger((ServerPlayer)p_40704_, blockpos2, itemstack); -@@ -96,8 +_,13 @@ +@@ -97,8 +_,13 @@ public void checkExtraContent(@Nullable LivingEntity p_397951_, Level p_150712_, ItemStack p_150713_, BlockPos p_150714_) { } @@ -64,7 +64,7 @@ if (!(this.content instanceof FlowingFluid flowingfluid)) { return false; } else { -@@ -109,8 +_,12 @@ +@@ -110,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); @@ -75,10 +75,10 @@ + } else if (containedFluidStack.isPresent() && this.content.getFluidType().isVaporizedOnPlacement(p_150717_, p_150718_, containedFluidStack.get())) { + this.content.getFluidType().onVaporize(p_392717_, p_150717_, p_150718_, containedFluidStack.get()); + return true; - } else if (p_150717_.dimensionType().ultraWarm() && this.content.is(FluidTags.WATER)) { + } else if (p_150717_.environmentAttributes().getValue(EnvironmentAttributes.WATER_EVAPORATES, p_150718_) && this.content.is(FluidTags.WATER)) { int l = p_150718_.getX(); int i = p_150718_.getY(); -@@ -129,7 +_,7 @@ +@@ -138,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; -@@ -150,8 +_,33 @@ +@@ -159,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; diff --git a/patches/minecraft/net/minecraft/world/item/CreativeModeTab.java.patch b/patches/minecraft/net/minecraft/world/item/CreativeModeTab.java.patch index 7c4842ec95..a42456a195 100644 --- a/patches/minecraft/net/minecraft/world/item/CreativeModeTab.java.patch +++ b/patches/minecraft/net/minecraft/world/item/CreativeModeTab.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/CreativeModeTab.java +++ b/net/minecraft/world/item/CreativeModeTab.java -@@ -28,6 +_,12 @@ +@@ -27,6 +_,12 @@ private Set displayItemsSearchTab = ItemStackLinkedSet.createTypeAndComponentsSet(); private final Supplier iconGenerator; private final CreativeModeTab.DisplayItemsGenerator displayItemsGenerator; @@ -8,12 +8,12 @@ + private final int searchBarWidth; + private final int labelColor; + private final int slotColor; -+ public final java.util.List tabsBefore; -+ public final java.util.List tabsAfter; ++ public final java.util.List tabsBefore; ++ public final java.util.List tabsAfter; CreativeModeTab( CreativeModeTab.Row p_260217_, -@@ -35,7 +_,8 @@ +@@ -34,7 +_,8 @@ CreativeModeTab.Type p_260176_, Component p_260100_, Supplier p_259543_, @@ -23,7 +23,7 @@ ) { this.row = p_260217_; this.column = p_259557_; -@@ -43,12 +_,27 @@ +@@ -42,12 +_,27 @@ this.iconGenerator = p_259543_; this.displayItemsGenerator = p_259085_; this.type = p_260176_; @@ -43,15 +43,15 @@ + return new CreativeModeTab.Builder(Row.TOP, 0); } - public static ResourceLocation createTextureLocation(String p_343491_) { - return ResourceLocation.withDefaultNamespace("textures/gui/container/creative_inventory/tab_" + p_343491_ + ".png"); + public static Identifier createTextureLocation(String p_343491_) { + return Identifier.withDefaultNamespace("textures/gui/container/creative_inventory/tab_" + p_343491_ + ".png"); } + /** @deprecated Forge: use {@link #builder()} **/ public static CreativeModeTab.Builder builder(CreativeModeTab.Row p_259342_, int p_260312_) { return new CreativeModeTab.Builder(p_259342_, p_260312_); } -@@ -106,7 +_,7 @@ +@@ -105,7 +_,7 @@ ResourceKey resourcekey = BuiltInRegistries.CREATIVE_MODE_TAB .getResourceKey(this) .orElseThrow(() -> new IllegalStateException("Unregistered creative tab: " + this)); @@ -60,7 +60,7 @@ this.displayItems = creativemodetab$itemdisplaybuilder.tabContents; this.displayItemsSearchTab = creativemodetab$itemdisplaybuilder.searchTabContents; } -@@ -123,6 +_,22 @@ +@@ -122,6 +_,22 @@ return this.displayItemsSearchTab.contains(p_259317_); } @@ -83,22 +83,22 @@ public static class Builder { private static final CreativeModeTab.DisplayItemsGenerator EMPTY_GENERATOR = (p_270422_, p_259433_) -> {}; private final CreativeModeTab.Row row; -@@ -135,6 +_,14 @@ +@@ -134,6 +_,14 @@ private boolean alignedRight = false; private CreativeModeTab.Type type = CreativeModeTab.Type.CATEGORY; - private ResourceLocation backgroundTexture = CreativeModeTab.DEFAULT_BACKGROUND; + private Identifier backgroundTexture = CreativeModeTab.DEFAULT_BACKGROUND; + private boolean hasSearchBar = false; + private int searchBarWidth = 89; + private int labelColor = 0xff404040; + private int slotColor = -2130706433; + private java.util.function.Function tabFactory = + builder -> new CreativeModeTab(builder.row, builder.column, builder.type, builder.displayName, builder.iconGenerator, builder.displayItemsGenerator, builder); -+ private final java.util.List tabsBefore = new java.util.ArrayList<>(); -+ private final java.util.List tabsAfter = new java.util.ArrayList<>(); ++ private final java.util.List tabsBefore = new java.util.ArrayList<>(); ++ private final java.util.List tabsAfter = new java.util.ArrayList<>(); public Builder(CreativeModeTab.Row p_259171_, int p_259661_) { this.row = p_259171_; -@@ -173,6 +_,9 @@ +@@ -172,6 +_,9 @@ protected CreativeModeTab.Builder type(CreativeModeTab.Type p_259283_) { this.type = p_259283_; @@ -108,13 +108,13 @@ return this; } -@@ -181,13 +_,78 @@ +@@ -180,13 +_,80 @@ return this; } + /** + * Gives this tab a search bar. -+ *

Note that, if using a custom {@link #withBackgroundLocation(net.minecraft.resources.ResourceLocation) background image}, you will need to make sure that your image contains the input box and the scroll bar.

++ *

Note that, if using a custom {@link #withBackgroundLocation(net.minecraft.resources.Identifier) background image}, you will need to make sure that your image contains the input box and the scroll bar.

+ */ + public CreativeModeTab.Builder withSearchBar() { + this.hasSearchBar = true; @@ -154,13 +154,13 @@ + } + + /** Define tabs that should come before this tab. This tab will be placed after the {@code tabs}. **/ -+ public CreativeModeTab.Builder withTabsBefore(net.minecraft.resources.ResourceLocation... tabs) { ++ public CreativeModeTab.Builder withTabsBefore(net.minecraft.resources.Identifier... tabs) { + this.tabsBefore.addAll(java.util.List.of(tabs)); + return this; + } + + /** Define tabs that should come after this tab. This tab will be placed before the {@code tabs}.**/ -+ public CreativeModeTab.Builder withTabsAfter(net.minecraft.resources.ResourceLocation... tabs) { ++ public CreativeModeTab.Builder withTabsAfter(net.minecraft.resources.Identifier... tabs) { + this.tabsAfter.addAll(java.util.List.of(tabs)); + return this; + } @@ -168,14 +168,16 @@ + /** Define tabs that should come before this tab. This tab will be placed after the {@code tabs}. **/ + @SafeVarargs + public final CreativeModeTab.Builder withTabsBefore(net.minecraft.resources.ResourceKey... tabs) { -+ java.util.stream.Stream.of(tabs).map(net.minecraft.resources.ResourceKey::location).forEach(this.tabsBefore::add); ++ for (var tab : tabs) ++ this.tabsBefore.add(tab.identifier()); + return this; + } + + /** Define tabs that should come after this tab. This tab will be placed before the {@code tabs}.**/ + @SafeVarargs + public final CreativeModeTab.Builder withTabsAfter(net.minecraft.resources.ResourceKey... tabs) { -+ java.util.stream.Stream.of(tabs).map(net.minecraft.resources.ResourceKey::location).forEach(this.tabsAfter::add); ++ for (var tab : tabs) ++ this.tabsAfter.add(tab.identifier()); + return this; + } + diff --git a/patches/minecraft/net/minecraft/world/item/DispensibleContainerItem.java.patch b/patches/minecraft/net/minecraft/world/item/DispensibleContainerItem.java.patch index 8fd8f55a4c..503aa7307f 100644 --- a/patches/minecraft/net/minecraft/world/item/DispensibleContainerItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/DispensibleContainerItem.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/item/DispensibleContainerItem.java +++ b/net/minecraft/world/item/DispensibleContainerItem.java @@ -6,9 +_,10 @@ - import net.minecraft.world.level.Level; import net.minecraft.world.phys.BlockHitResult; + import org.jspecify.annotations.Nullable; -public interface DispensibleContainerItem { +public interface DispensibleContainerItem extends net.minecraftforge.common.extensions.IForgeDispensibleContainerItem { diff --git a/patches/minecraft/net/minecraft/world/item/DyeColor.java.patch b/patches/minecraft/net/minecraft/world/item/DyeColor.java.patch index 4461de134f..9dd5d9bfa8 100644 --- a/patches/minecraft/net/minecraft/world/item/DyeColor.java.patch +++ b/patches/minecraft/net/minecraft/world/item/DyeColor.java.patch @@ -18,7 +18,7 @@ } public int getId() { -@@ -110,6 +_,27 @@ +@@ -108,6 +_,27 @@ @Override public String getSerializedName() { return this.name; diff --git a/patches/minecraft/net/minecraft/world/item/Item.java.patch b/patches/minecraft/net/minecraft/world/item/Item.java.patch index cde8a75dd1..1ebf4958ee 100644 --- a/patches/minecraft/net/minecraft/world/item/Item.java.patch +++ b/patches/minecraft/net/minecraft/world/item/Item.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/item/Item.java +++ b/net/minecraft/world/item/Item.java -@@ -86,7 +_,7 @@ - import net.minecraft.world.phys.Vec3; +@@ -95,7 +_,7 @@ + import org.jspecify.annotations.Nullable; import org.slf4j.Logger; -public class Item implements FeatureElement, ItemLike { @@ -9,16 +9,16 @@ public static final Codec> CODEC = BuiltInRegistries.ITEM .holderByNameCodec() .validate( -@@ -96,7 +_,7 @@ +@@ -105,7 +_,7 @@ ); public static final StreamCodec> STREAM_CODEC = ByteBufCodecs.holderRegistry(Registries.ITEM); private static final Logger LOGGER = LogUtils.getLogger(); - public static final Map BY_BLOCK = Maps.newHashMap(); + public static final Map BY_BLOCK = net.minecraftforge.registries.GameData.ItemCallbacks.getBlockItemMap(); - 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 Identifier BASE_ATTACK_DAMAGE_ID = Identifier.withDefaultNamespace("base_attack_damage"); + public static final Identifier BASE_ATTACK_SPEED_ID = Identifier.withDefaultNamespace("base_attack_speed"); public static final int DEFAULT_MAX_STACK_SIZE = 64; -@@ -134,6 +_,7 @@ +@@ -142,6 +_,7 @@ LOGGER.error("Item classes should end with Item and {} doesn't.", s); } } @@ -26,7 +26,7 @@ } @Deprecated -@@ -141,17 +_,25 @@ +@@ -149,17 +_,25 @@ return this.builtInRegistryHolder; } @@ -54,7 +54,7 @@ public void onDestroyed(ItemEntity p_150887_) { } -@@ -264,6 +_,8 @@ +@@ -276,6 +_,8 @@ return BuiltInRegistries.ITEM.wrapAsHolder(this).getRegisteredName(); } @@ -63,7 +63,7 @@ public final ItemStack getCraftingRemainder() { return this.craftingRemainingItem == null ? ItemStack.EMPTY : new ItemStack(this.craftingRemainingItem); } -@@ -354,6 +_,30 @@ +@@ -366,6 +_,30 @@ return false; } @@ -92,9 +92,9 @@ + public void initializeClient(java.util.function.Consumer consumer) { } + 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()); -@@ -599,6 +_,11 @@ + private static final DependantName BLOCK_DESCRIPTION_ID = p_449793_ -> Util.makeDescriptionId("block", p_449793_.identifier()); + private static final DependantName ITEM_DESCRIPTION_ID = p_449792_ -> Util.makeDescriptionId("item", p_449792_.identifier()); +@@ -683,6 +_,11 @@ boolean isPeaceful(); @@ -103,10 +103,10 @@ + return null; + } + - static Item.TooltipContext of(@Nullable final Level p_332083_) { + static Item.TooltipContext of(final @Nullable Level p_332083_) { return p_332083_ == null ? EMPTY : new Item.TooltipContext() { @Override -@@ -619,6 +_,11 @@ +@@ -703,6 +_,11 @@ @Override public boolean isPeaceful() { return p_332083_.getDifficulty() == Difficulty.PEACEFUL; diff --git a/patches/minecraft/net/minecraft/world/item/ItemDisplayContext.java.patch b/patches/minecraft/net/minecraft/world/item/ItemDisplayContext.java.patch index 9bf3555089..7cafbc478e 100644 --- a/patches/minecraft/net/minecraft/world/item/ItemDisplayContext.java.patch +++ b/patches/minecraft/net/minecraft/world/item/ItemDisplayContext.java.patch @@ -37,7 +37,7 @@ + @javax.annotation.Nullable + private final ItemDisplayContext fallback; + -+ private ItemDisplayContext(net.minecraft.resources.ResourceLocation serializeName, ItemDisplayContext fallback) { ++ private ItemDisplayContext(net.minecraft.resources.Identifier serializeName, ItemDisplayContext fallback) { + this.id = 0; // If the context is never registered then it should be treated as the NONE one + this.name = java.util.Objects.requireNonNull(serializeName, "Modded ItemDisplayContexts must have a non-null serializeName").toString(); + this.isModded = true; @@ -52,7 +52,7 @@ + return fallback; + } + -+ public static ItemDisplayContext create(String keyName, net.minecraft.resources.ResourceLocation serializedName, @javax.annotation.Nullable ItemDisplayContext fallback) { ++ public static ItemDisplayContext create(String keyName, net.minecraft.resources.Identifier serializedName, @javax.annotation.Nullable ItemDisplayContext fallback) { + throw new IllegalStateException("Enum not extended!"); + } + diff --git a/patches/minecraft/net/minecraft/world/item/ItemStack.java.patch b/patches/minecraft/net/minecraft/world/item/ItemStack.java.patch index 0904df747b..dda9b33ea8 100644 --- a/patches/minecraft/net/minecraft/world/item/ItemStack.java.patch +++ b/patches/minecraft/net/minecraft/world/item/ItemStack.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/item/ItemStack.java +++ b/net/minecraft/world/item/ItemStack.java -@@ -98,7 +_,7 @@ - import org.apache.commons.lang3.mutable.MutableBoolean; +@@ -104,7 +_,7 @@ + import org.jspecify.annotations.Nullable; import org.slf4j.Logger; -public final class ItemStack implements DataComponentHolder { @@ -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), -@@ -268,12 +_,15 @@ +@@ -273,12 +_,15 @@ } private ItemStack(ItemLike p_331826_, int p_332766_, PatchedDataComponentMap p_333722_) { @@ -25,7 +25,7 @@ this.item = null; this.components = new PatchedDataComponentMap(DataComponentMap.EMPTY); } -@@ -354,13 +_,22 @@ +@@ -359,13 +_,22 @@ } public InteractionResult useOn(UseOnContext p_41662_) { @@ -49,7 +49,7 @@ if (player != null && interactionresult instanceof InteractionResult.Success interactionresult$success && interactionresult$success.wasItemInteraction()) { player.awardStat(Stats.ITEM_USED.get(item)); } -@@ -445,18 +_,26 @@ +@@ -450,18 +_,26 @@ } public void hurtAndBreak(int p_220158_, ServerLevel p_342197_, @Nullable ServerPlayer p_220160_, Consumer p_343361_) { @@ -77,7 +77,7 @@ return p_362423_ > 0 ? EnchantmentHelper.processDurabilityChange(p_364910_, this, p_362423_) : p_362423_; } } -@@ -496,7 +_,13 @@ +@@ -501,7 +_,13 @@ p_41623_, serverlevel, p_41624_ instanceof ServerPlayer serverplayer ? serverplayer : null, @@ -92,7 +92,7 @@ ); } } -@@ -820,6 +_,7 @@ +@@ -854,6 +_,7 @@ List list = Lists.newArrayList(); list.add(this.getStyledHoverName()); this.addDetailsToTooltip(p_331329_, tooltipdisplay, p_41652_, p_41653_, list::add); @@ -100,8 +100,8 @@ return list; } } -@@ -1065,6 +_,7 @@ - this.getItem().onUseTick(p_41732_, p_41733_, this, p_41734_); +@@ -1110,6 +_,7 @@ + } } + /** @deprecated Forge: Use {@linkplain net.minecraftforge.common.extensions.IForgeItemStack#onDestroyed(ItemEntity, net.minecraft.world.damagesource.DamageSource) damage source sensitive version} */ diff --git a/patches/minecraft/net/minecraft/world/item/Items.java.patch b/patches/minecraft/net/minecraft/world/item/Items.java.patch index 15d6930f5d..75a7691505 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 -@@ -2281,7 +_,25 @@ +@@ -2320,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); -@@ -2320,10 +_,6 @@ +@@ -2359,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/MobBucketItem.java.patch b/patches/minecraft/net/minecraft/world/item/MobBucketItem.java.patch index 15470fd311..d104208f6e 100644 --- a/patches/minecraft/net/minecraft/world/item/MobBucketItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/MobBucketItem.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/item/MobBucketItem.java +++ b/net/minecraft/world/item/MobBucketItem.java @@ -18,13 +_,18 @@ - import net.minecraft.world.level.material.Fluid; + import org.jspecify.annotations.Nullable; public class MobBucketItem extends BucketItem { - private final EntityType type; diff --git a/patches/minecraft/net/minecraft/world/item/StandingAndWallBlockItem.java.patch b/patches/minecraft/net/minecraft/world/item/StandingAndWallBlockItem.java.patch index 781b756bc0..2141a23708 100644 --- a/patches/minecraft/net/minecraft/world/item/StandingAndWallBlockItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/StandingAndWallBlockItem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/StandingAndWallBlockItem.java +++ b/net/minecraft/world/item/StandingAndWallBlockItem.java -@@ -50,4 +_,9 @@ +@@ -49,4 +_,9 @@ super.registerBlocks(p_43252_, p_43253_); p_43252_.put(this.wallBlock, p_43253_); } diff --git a/patches/minecraft/net/minecraft/world/item/crafting/RecipeManager.java.patch b/patches/minecraft/net/minecraft/world/item/crafting/RecipeManager.java.patch index e5a8406bbc..97d34f6909 100644 --- a/patches/minecraft/net/minecraft/world/item/crafting/RecipeManager.java.patch +++ b/patches/minecraft/net/minecraft/world/item/crafting/RecipeManager.java.patch @@ -17,12 +17,12 @@ } protected RecipeMap prepare(ResourceManager p_368640_, ProfilerFiller p_361102_) { - SortedMap> sortedmap = new TreeMap<>(); + SortedMap> sortedmap = new TreeMap<>(); - SimpleJsonResourceReloadListener.scanDirectory(p_368640_, RECIPE_LISTER, this.registries.createSerializationContext(JsonOps.INSTANCE), Recipe.CODEC, sortedmap); + SimpleJsonResourceReloadListener.scanDirectory(p_368640_, RECIPE_LISTER, this.context.wrap(this.registries.createSerializationContext(JsonOps.INSTANCE)), Recipe.CODEC, sortedmap); List> list = new ArrayList<>(sortedmap.size()); - sortedmap.forEach((p_359835_, p_359836_) -> { - ResourceKey> resourcekey = ResourceKey.create(Registries.RECIPE, p_359835_); + sortedmap.forEach((p_449831_, p_449832_) -> { + ResourceKey> resourcekey = ResourceKey.create(Registries.RECIPE, p_449831_); @@ -86,6 +_,7 @@ } diff --git a/patches/minecraft/net/minecraft/world/item/crafting/RecipeType.java.patch b/patches/minecraft/net/minecraft/world/item/crafting/RecipeType.java.patch index 1463899343..fdbaee08d9 100644 --- a/patches/minecraft/net/minecraft/world/item/crafting/RecipeType.java.patch +++ b/patches/minecraft/net/minecraft/world/item/crafting/RecipeType.java.patch @@ -5,7 +5,7 @@ }); } + -+ public static > RecipeType simple(final ResourceLocation name) { ++ public static > RecipeType simple(final Identifier name) { + final String toString = name.toString(); + return new RecipeType() { + @Override diff --git a/patches/minecraft/net/minecraft/world/item/crafting/ShapedRecipe.java.patch b/patches/minecraft/net/minecraft/world/item/crafting/ShapedRecipe.java.patch index e6ce51556a..50da8986b7 100644 --- a/patches/minecraft/net/minecraft/world/item/crafting/ShapedRecipe.java.patch +++ b/patches/minecraft/net/minecraft/world/item/crafting/ShapedRecipe.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/item/crafting/ShapedRecipe.java +++ b/net/minecraft/world/item/crafting/ShapedRecipe.java @@ -18,7 +_,19 @@ - import net.minecraft.world.item.crafting.display.SlotDisplay; import net.minecraft.world.level.Level; + import org.jspecify.annotations.Nullable; -public class ShapedRecipe implements CraftingRecipe { +public class ShapedRecipe implements CraftingRecipe, net.minecraftforge.common.crafting.IShapedRecipe { @@ -21,7 +21,7 @@ final ShapedRecipePattern pattern; final ItemStack result; final String group; -@@ -66,6 +_,16 @@ +@@ -65,6 +_,16 @@ } return this.placementInfo; diff --git a/patches/minecraft/net/minecraft/world/item/crafting/ShapelessRecipe.java.patch b/patches/minecraft/net/minecraft/world/item/crafting/ShapelessRecipe.java.patch index 3e2170acdb..8eb9db1949 100644 --- a/patches/minecraft/net/minecraft/world/item/crafting/ShapelessRecipe.java.patch +++ b/patches/minecraft/net/minecraft/world/item/crafting/ShapelessRecipe.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/world/item/crafting/ShapelessRecipe.java +++ b/net/minecraft/world/item/crafting/ShapelessRecipe.java -@@ -24,12 +_,14 @@ +@@ -23,12 +_,14 @@ + final ItemStack result; final List ingredients; - @Nullable - private PlacementInfo placementInfo; + private @Nullable PlacementInfo placementInfo; + private final boolean isSimple; public ShapelessRecipe(String p_249640_, CraftingBookCategory p_249390_, ItemStack p_252071_, List p_365863_) { @@ -15,7 +15,7 @@ } @Override -@@ -59,10 +_,12 @@ +@@ -58,10 +_,12 @@ public boolean matches(CraftingInput p_345423_, Level p_44263_) { if (p_345423_.ingredientCount() != this.ingredients.size()) { return false; @@ -31,7 +31,7 @@ } } -@@ -87,7 +_,7 @@ +@@ -86,7 +_,7 @@ Codec.STRING.optionalFieldOf("group", "").forGetter(p_299460_ -> p_299460_.group), CraftingBookCategory.CODEC.fieldOf("category").orElse(CraftingBookCategory.MISC).forGetter(p_297437_ -> p_297437_.category), ItemStack.STRICT_CODEC.fieldOf("result").forGetter(p_300770_ -> p_300770_.result), diff --git a/patches/minecraft/net/minecraft/world/item/enchantment/EnchantmentHelper.java.patch b/patches/minecraft/net/minecraft/world/item/enchantment/EnchantmentHelper.java.patch index 14206b9dc4..75acf09a5e 100644 --- a/patches/minecraft/net/minecraft/world/item/enchantment/EnchantmentHelper.java.patch +++ b/patches/minecraft/net/minecraft/world/item/enchantment/EnchantmentHelper.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/enchantment/EnchantmentHelper.java +++ b/net/minecraft/world/item/enchantment/EnchantmentHelper.java -@@ -572,7 +_,7 @@ +@@ -582,7 +_,7 @@ public static List getAvailableEnchantmentResults(int p_44818_, ItemStack p_44819_, Stream> p_342857_) { List list = Lists.newArrayList(); boolean flag = p_44819_.is(Items.BOOK); diff --git a/patches/minecraft/net/minecraft/world/level/BaseSpawner.java.patch b/patches/minecraft/net/minecraft/world/level/BaseSpawner.java.patch index d71e8ca49a..9c91bb9469 100644 --- a/patches/minecraft/net/minecraft/world/level/BaseSpawner.java.patch +++ b/patches/minecraft/net/minecraft/world/level/BaseSpawner.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/BaseSpawner.java +++ b/net/minecraft/world/level/BaseSpawner.java -@@ -156,13 +_,15 @@ +@@ -154,13 +_,15 @@ entity.snapTo(entity.getX(), entity.getY(), entity.getZ(), randomsource.nextFloat() * 360.0F, 0.0F); if (entity instanceof Mob mob) { @@ -19,7 +19,7 @@ } spawndata.getEquipment().ifPresent(mob::equip); -@@ -280,5 +_,15 @@ +@@ -277,5 +_,14 @@ public double getOSpin() { return this.oSpin; @@ -30,8 +30,7 @@ + return null; + } + -+ @Nullable -+ public net.minecraft.world.level.block.entity.BlockEntity getSpawnerBlockEntity() { ++ public net.minecraft.world.level.block.entity.@Nullable BlockEntity getSpawnerBlockEntity() { + return null; } } diff --git a/patches/minecraft/net/minecraft/world/level/BlockGetter.java.patch b/patches/minecraft/net/minecraft/world/level/BlockGetter.java.patch index 8512f298c2..b4dbf3f4d4 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 @@ -21,7 +_,7 @@ - import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.shapes.VoxelShape; + import org.jspecify.annotations.Nullable; -public interface BlockGetter extends LevelHeightAccessor { +public interface BlockGetter extends LevelHeightAccessor, net.minecraftforge.common.extensions.IForgeBlockGetter { - @Nullable - BlockEntity getBlockEntity(BlockPos p_45570_); + @Nullable BlockEntity getBlockEntity(BlockPos p_45570_); -@@ -35,7 +_,7 @@ + default Optional getBlockEntity(BlockPos p_151367_, BlockEntityType p_151368_) { +@@ -34,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 c69b1b064c..c8f5a899ba 100644 --- a/patches/minecraft/net/minecraft/world/level/Level.java.patch +++ b/patches/minecraft/net/minecraft/world/level/Level.java.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java -@@ -84,7 +_,7 @@ - import net.minecraft.world.scores.Scoreboard; +@@ -85,7 +_,7 @@ import org.apache.commons.lang3.mutable.MutableBoolean; + import org.jspecify.annotations.Nullable; -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")); + public static final ResourceKey OVERWORLD = ResourceKey.create(Registries.DIMENSION, Identifier.withDefaultNamespace("overworld")); + public static final ResourceKey NETHER = ResourceKey.create(Registries.DIMENSION, Identifier.withDefaultNamespace("the_nether")); @@ -125,6 +_,11 @@ private final DamageSources damageSources; private final PalettedContainerFactory palettedContainerFactory; @@ -28,8 +28,8 @@ + super(); this.levelData = p_270739_; this.dimensionTypeRegistration = p_270240_; - DimensionType dimensiontype = p_270240_.value(); -@@ -210,11 +_,35 @@ + this.dimension = p_270683_; +@@ -217,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); -@@ -241,9 +_,8 @@ +@@ -248,9 +_,8 @@ } this.updatePOIOnBlockStateChange(p_46605_, blockstate, blockstate1); @@ -76,7 +76,7 @@ } } } -@@ -491,8 +_,28 @@ +@@ -484,8 +_,28 @@ (this.tickingBlockEntities ? this.pendingBlockEntityTickers : this.blockEntityTickers).add(p_151526_); } @@ -105,7 +105,7 @@ if (!this.pendingBlockEntityTickers.isEmpty()) { this.blockEntityTickers.addAll(this.pendingBlockEntityTickers); this.pendingBlockEntityTickers.clear(); -@@ -515,12 +_,19 @@ +@@ -508,12 +_,19 @@ public void guardEntityTick(Consumer p_46654_, T p_46655_) { try { @@ -125,15 +125,15 @@ } } -@@ -677,6 +_,7 @@ - if (!this.isOutsideBuildHeight(p_46748_)) { +@@ -669,6 +_,7 @@ + if (this.isInValidBounds(p_46748_)) { this.getChunkAt(p_46748_).removeBlockEntity(p_46748_); } + this.updateNeighbourForOutputSignal(p_46748_, getBlockState(p_46748_).getBlock()); //Notify neighbors of changes } public boolean isLoaded(BlockPos p_46750_) { -@@ -755,9 +_,9 @@ +@@ -743,9 +_,9 @@ } }); @@ -145,7 +145,7 @@ && p_46538_.test(enderdragonpart) && p_46537_.intersects(enderdragonpart.getBoundingBox())) { list.add(enderdragonpart); -@@ -790,8 +_,8 @@ +@@ -778,8 +_,8 @@ } } @@ -156,7 +156,7 @@ T t = p_261885_.tryCast(enderdragonpart); if (t != null && p_261688_.test(t)) { p_262071_.add(t); -@@ -973,17 +_,16 @@ +@@ -952,17 +_,16 @@ public abstract Scoreboard getScoreboard(); public void updateNeighbourForOutputSignal(BlockPos p_46718_, Block p_46719_) { @@ -179,10 +179,10 @@ } } } -@@ -1080,6 +_,20 @@ +@@ -1047,6 +_,20 @@ } - public abstract PotionBrewing potionBrewing(); + public abstract EnvironmentAttributeSystem environmentAttributes(); + + private double maxEntityRadius = 2.0D; + @@ -198,5 +198,5 @@ + return maxEntityRadius; + } - public abstract FuelValues fuelValues(); + public abstract PotionBrewing potionBrewing(); diff --git a/patches/minecraft/net/minecraft/world/level/LevelReader.java.patch b/patches/minecraft/net/minecraft/world/level/LevelReader.java.patch index 4e66077d5f..25d7ad83d8 100644 --- a/patches/minecraft/net/minecraft/world/level/LevelReader.java.patch +++ b/patches/minecraft/net/minecraft/world/level/LevelReader.java.patch @@ -1,15 +1,14 @@ --- a/net/minecraft/world/level/LevelReader.java +++ b/net/minecraft/world/level/LevelReader.java -@@ -176,6 +_,12 @@ - : 15; +@@ -176,6 +_,11 @@ } -+ -+ @Deprecated + @Deprecated + default boolean isAreaLoaded(BlockPos center, int range) { + return this.hasChunksAt(center.offset(-range, -range, -range), center.offset(range, range, range)); + } + - @Deprecated ++ @Deprecated default boolean hasChunkAt(int p_151578_, int p_151579_) { return this.hasChunk(SectionPos.blockToSectionCoord(p_151578_), SectionPos.blockToSectionCoord(p_151579_)); + } diff --git a/patches/minecraft/net/minecraft/world/level/LevelSettings.java.patch b/patches/minecraft/net/minecraft/world/level/LevelSettings.java.patch index f72cea454c..12bcc24c8d 100644 --- a/patches/minecraft/net/minecraft/world/level/LevelSettings.java.patch +++ b/patches/minecraft/net/minecraft/world/level/LevelSettings.java.patch @@ -1,12 +1,12 @@ --- a/net/minecraft/world/level/LevelSettings.java +++ b/net/minecraft/world/level/LevelSettings.java -@@ -11,9 +_,16 @@ +@@ -15,9 +_,16 @@ private final boolean allowCommands; private final GameRules gameRules; private final WorldDataConfiguration dataConfiguration; - - public LevelSettings( -- String p_250485_, GameType p_250207_, boolean p_251631_, Difficulty p_252122_, boolean p_248961_, GameRules p_248536_, WorldDataConfiguration p_249797_ +- String p_250485_, GameType p_250207_, boolean p_251631_, Difficulty p_252122_, boolean p_248961_, GameRules p_457827_, WorldDataConfiguration p_249797_ + private final com.mojang.serialization.Lifecycle lifecycle; + + public LevelSettings( @@ -16,29 +16,29 @@ + } + + public LevelSettings( -+ String p_250485_, GameType p_250207_, boolean p_251631_, Difficulty p_252122_, boolean p_248961_, GameRules p_248536_, WorldDataConfiguration p_249797_, com.mojang.serialization.Lifecycle lifecycle ++ String p_250485_, GameType p_250207_, boolean p_251631_, Difficulty p_252122_, boolean p_248961_, GameRules p_457827_, WorldDataConfiguration p_249797_, com.mojang.serialization.Lifecycle lifecycle ) { this.levelName = p_250485_; this.gameType = p_250207_; -@@ -22,6 +_,7 @@ +@@ -26,6 +_,7 @@ this.allowCommands = p_248961_; - this.gameRules = p_248536_; + this.gameRules = p_457827_; this.dataConfiguration = p_249797_; + this.lifecycle = lifecycle; } public static LevelSettings parse(Dynamic p_46925_, WorldDataConfiguration p_251697_) { -@@ -33,7 +_,8 @@ +@@ -37,7 +_,8 @@ p_46925_.get("Difficulty").asNumber().map(p_46928_ -> Difficulty.byId(p_46928_.byteValue())).result().orElse(Difficulty.NORMAL), p_46925_.get("allowCommands").asBoolean(gametype == GameType.CREATIVE), - new GameRules(p_251697_.enabledFeatures(), p_46925_.get("GameRules")), + GameRules.codec(p_251697_.enabledFeatures()).parse(p_46925_.get("game_rules").orElseEmptyMap()).resultOrPartial(LOGGER::warn).orElseThrow(), - p_251697_ + p_251697_, + net.minecraftforge.common.ForgeHooks.parseLifecycle(p_46925_.get("forgeLifecycle").asString("stable")) ); } -@@ -66,20 +_,28 @@ +@@ -70,20 +_,28 @@ } public LevelSettings withGameType(GameType p_46923_) { diff --git a/patches/minecraft/net/minecraft/world/level/NaturalSpawner.java.patch b/patches/minecraft/net/minecraft/world/level/NaturalSpawner.java.patch index a49177ff03..02120817f7 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 -@@ -71,7 +_,7 @@ +@@ -72,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_ -> { -@@ -202,7 +_,7 @@ +@@ -203,7 +_,7 @@ l1++; p_47040_.addFreshEntityWithPassengers(mob); p_47044_.run(mob, p_47041_); @@ -53,7 +53,7 @@ spawngroupdata = mob.finalizeSpawn( p_220451_, p_220451_.getCurrentDifficultyAt(mob.blockPosition()), EntitySpawnReason.CHUNK_GENERATION, spawngroupdata ); -@@ -501,7 +_,7 @@ +@@ -499,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 ef0d414830..1c584b034e 100644 --- a/patches/minecraft/net/minecraft/world/level/ServerExplosion.java.patch +++ b/patches/minecraft/net/minecraft/world/level/ServerExplosion.java.patch @@ -6,21 +6,21 @@ - private void hurtEntities() { + private void hurtEntities(List blocks) { - 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); -@@ -178,7 +_,9 @@ - int i1 = Mth.floor(this.center.z - f - 1.0); - int j1 = Mth.floor(this.center.z + f + 1.0); + if (!(this.radius < 1.0E-5F)) { + float f = this.radius * 2.0F; + int i = Mth.floor(this.center.x - f - 1.0); +@@ -179,7 +_,9 @@ + int i1 = Mth.floor(this.center.z - f - 1.0); + int j1 = Mth.floor(this.center.z + f + 1.0); -- for (Entity entity : this.level.getEntities(this.source, new AABB(i, k, i1, j, l, j1))) { -+ var entities = this.level.getEntities(this.source, new AABB(i, k, i1, j, l, j1)); -+ net.minecraftforge.event.ForgeEventFactory.onExplosionDetonate(this.level, this, blocks, entities, f); -+ for (Entity entity : entities) { - if (!entity.ignoreExplosion(this)) { - double d0 = Math.sqrt(entity.distanceToSqr(this.center)) / f; - if (!(d0 > 1.0)) { -@@ -233,7 +_,7 @@ +- for (Entity entity : this.level.getEntities(this.source, new AABB(i, k, i1, j, l, j1))) { ++ var entities = this.level.getEntities(this.source, new AABB(i, k, i1, j, l, j1)); ++ net.minecraftforge.event.ForgeEventFactory.onExplosionDetonate(this.level, this, blocks, entities, f); ++ for (Entity entity : entities) { + if (!entity.ignoreExplosion(this)) { + double d0 = Math.sqrt(entity.distanceToSqr(this.center)) / f; + if (!(d0 > 1.0)) { +@@ -235,7 +_,7 @@ public int explode() { this.level.gameEvent(this.source, GameEvent.EXPLODE, this.center); List list = this.calculateExplodedPositions(); diff --git a/patches/minecraft/net/minecraft/world/level/biome/Biome.java.patch b/patches/minecraft/net/minecraft/world/level/biome/Biome.java.patch index de142370a0..6f7de28896 100644 --- a/patches/minecraft/net/minecraft/world/level/biome/Biome.java.patch +++ b/patches/minecraft/net/minecraft/world/level/biome/Biome.java.patch @@ -1,18 +1,19 @@ --- a/net/minecraft/world/level/biome/Biome.java +++ b/net/minecraft/world/level/biome/Biome.java -@@ -37,8 +_,8 @@ +@@ -36,9 +_,9 @@ public final class Biome { public static final Codec DIRECT_CODEC = RecordCodecBuilder.create( - p_220544_ -> p_220544_.group( + p_449877_ -> p_449877_.group( - Biome.ClimateSettings.CODEC.forGetter(p_151717_ -> p_151717_.climateSettings), -- BiomeSpecialEffects.CODEC.fieldOf("effects").forGetter(p_220550_ -> p_220550_.specialEffects), + Biome.ClimateSettings.CODEC.forGetter(p_151717_ -> p_151717_.modifiableBiomeInfo().getOriginalBiomeInfo().climateSettings()), // FORGE: Patch codec to ignore field redirect coremods. + EnvironmentAttributeMap.CODEC_ONLY_POSITIONAL.optionalFieldOf("attributes", EnvironmentAttributeMap.EMPTY).forGetter(p_449873_ -> p_449873_.attributes), +- BiomeSpecialEffects.CODEC.fieldOf("effects").forGetter(p_220550_ -> p_220550_.specialEffects), + BiomeSpecialEffects.CODEC.fieldOf("effects").forGetter(p_220550_ -> p_220550_.modifiableBiomeInfo().getOriginalBiomeInfo().effects()), // FORGE: Patch codec to ignore field redirect coremods. BiomeGenerationSettings.CODEC.forGetter(p_220548_ -> p_220548_.generationSettings), MobSpawnSettings.CODEC.forGetter(p_220546_ -> p_220546_.mobSettings) ) -@@ -60,8 +_,10 @@ - ) +@@ -62,8 +_,10 @@ + @Deprecated(forRemoval = true) public static final PerlinSimplexNoise BIOME_INFO_NOISE = new PerlinSimplexNoise(new WorldgenRandom(new LegacyRandomSource(2345L)), ImmutableList.of(0)); private static final int TEMPERATURE_CACHE_SIZE = 1024; + /** @deprecated Redirected to {@link #getModifiedClimateSettings()} by field_to_method.js */ @@ -20,33 +21,30 @@ private final BiomeGenerationSettings generationSettings; + /** @deprecated Redirected to {@link #getModifiedSpecialEffects()} by field_to_method.js */ private final MobSpawnSettings mobSettings; + private final EnvironmentAttributeMap attributes; private final BiomeSpecialEffects specialEffects; - private final ThreadLocal temperatureCache = ThreadLocal.withInitial(() -> Util.make(() -> { -@@ -73,12 +_,14 @@ +@@ -76,6 +_,7 @@ long2floatlinkedopenhashmap.defaultReturnValue(Float.NaN); return long2floatlinkedopenhashmap; - })); + }); + private final net.minecraftforge.common.world.ModifiableBiomeInfo modifiableBiomeInfo; - Biome(Biome.ClimateSettings p_220530_, BiomeSpecialEffects p_220531_, BiomeGenerationSettings p_220532_, MobSpawnSettings p_220533_) { - this.climateSettings = p_220530_; - this.generationSettings = p_220532_; + Biome( + Biome.ClimateSettings p_220530_, +@@ -89,10 +_,11 @@ this.mobSettings = p_220533_; + this.attributes = p_455689_; this.specialEffects = p_220531_; + this.modifiableBiomeInfo = new net.minecraftforge.common.world.ModifiableBiomeInfo(new net.minecraftforge.common.world.ModifiableBiomeInfo.BiomeInfo(p_220530_, p_220531_, p_220532_, p_220533_)); // FORGE: cache original biome info on construction so we can bypass our field read coremods where necessary } - public int getSkyColor() { -@@ -86,7 +_,7 @@ - } - public MobSpawnSettings getMobSettings() { - return this.mobSettings; + return this.modifiableBiomeInfo().get().mobSpawnSettings(); } public boolean hasPrecipitation() { -@@ -188,7 +_,7 @@ +@@ -194,7 +_,7 @@ } public BiomeGenerationSettings getGenerationSettings() { @@ -54,11 +52,11 @@ + return this.modifiableBiomeInfo().get().generationSettings(); } - public int getFogColor() { -@@ -269,6 +_,31 @@ + public int getGrassColor(double p_47465_, double p_47466_) { +@@ -247,6 +_,31 @@ - public float getBackgroundMusicVolume() { - return this.specialEffects.getBackgroundMusicVolume(); + public int getWaterColor() { + return this.specialEffects.waterColor(); + } + + /** diff --git a/patches/minecraft/net/minecraft/world/level/biome/BiomeSpecialEffects.java.patch b/patches/minecraft/net/minecraft/world/level/biome/BiomeSpecialEffects.java.patch index 70970fd618..4dd164fe4d 100644 --- a/patches/minecraft/net/minecraft/world/level/biome/BiomeSpecialEffects.java.patch +++ b/patches/minecraft/net/minecraft/world/level/biome/BiomeSpecialEffects.java.patch @@ -1,6 +1,28 @@ --- a/net/minecraft/world/level/biome/BiomeSpecialEffects.java +++ b/net/minecraft/world/level/biome/BiomeSpecialEffects.java -@@ -257,7 +_,7 @@ +@@ -24,6 +_,10 @@ + .apply(p_449881_, BiomeSpecialEffects::new) + ); + ++ public net.minecraftforge.common.world.BiomeSpecialEffectsBuilder copy() { ++ return net.minecraftforge.common.world.BiomeSpecialEffectsBuilder.copyOf(this); ++ } ++ + public static class Builder { + protected OptionalInt waterColor = OptionalInt.empty(); + protected Optional foliageColorOverride = Optional.empty(); +@@ -31,6 +_,10 @@ + protected Optional grassColorOverride = Optional.empty(); + protected BiomeSpecialEffects.GrassColorModifier grassColorModifier = BiomeSpecialEffects.GrassColorModifier.NONE; + ++ public static net.minecraftforge.common.world.BiomeSpecialEffectsBuilder create() { ++ return net.minecraftforge.common.world.BiomeSpecialEffectsBuilder.create(); ++ } ++ + public BiomeSpecialEffects.Builder waterColor(int p_48035_) { + this.waterColor = OptionalInt.of(p_48035_); + return this; +@@ -67,7 +_,7 @@ } } @@ -9,7 +31,7 @@ NONE("none") { @Override public int modifyColor(double p_48081_, double p_48082_, int p_48083_) { -@@ -279,11 +_,16 @@ +@@ -89,11 +_,16 @@ }; private final String name; @@ -29,7 +51,7 @@ GrassColorModifier(final String p_48058_) { this.name = p_48058_; -@@ -296,6 +_,30 @@ +@@ -106,6 +_,30 @@ @Override public String getSerializedName() { return this.name; diff --git a/patches/minecraft/net/minecraft/world/level/biome/MobSpawnSettings.java.patch b/patches/minecraft/net/minecraft/world/level/biome/MobSpawnSettings.java.patch index 39cfc1af83..8fa43b8e89 100644 --- a/patches/minecraft/net/minecraft/world/level/biome/MobSpawnSettings.java.patch +++ b/patches/minecraft/net/minecraft/world/level/biome/MobSpawnSettings.java.patch @@ -18,7 +18,7 @@ } public WeightedList getMobs(MobCategory p_151799_) { -@@ -64,6 +_,14 @@ +@@ -63,6 +_,14 @@ public float getCreatureProbability() { return this.creatureGenerationProbability; diff --git a/patches/minecraft/net/minecraft/world/level/block/BambooStalkBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/BambooStalkBlock.java.patch index a891704c68..e663ab770d 100644 --- a/patches/minecraft/net/minecraft/world/level/block/BambooStalkBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/BambooStalkBlock.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/level/block/BambooStalkBlock.java +++ b/net/minecraft/world/level/block/BambooStalkBlock.java @@ -24,7 +_,7 @@ - import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.VoxelShape; + import org.jspecify.annotations.Nullable; -public class BambooStalkBlock extends Block implements BonemealableBlock { +public class BambooStalkBlock extends Block implements BonemealableBlock, net.minecraftforge.common.IPlantable { public static final MapCodec CODEC = simpleCodec(BambooStalkBlock::new); private static final VoxelShape SHAPE_SMALL = Block.column(6.0, 0.0, 16.0); private static final VoxelShape SHAPE_LARGE = Block.column(10.0, 0.0, 16.0); -@@ -120,10 +_,12 @@ +@@ -119,10 +_,12 @@ @Override protected void randomTick(BlockState p_261931_, ServerLevel p_261751_, BlockPos p_261616_, RandomSource p_261766_) { if (p_261931_.getValue(STAGE) == 0) { @@ -24,7 +24,7 @@ } } } -@@ -226,5 +_,11 @@ +@@ -225,5 +_,11 @@ } return i; 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 c28edbc526..33240a7469 100644 --- a/patches/minecraft/net/minecraft/world/level/block/BaseRailBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/BaseRailBlock.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/level/block/BaseRailBlock.java +++ b/net/minecraft/world/level/block/BaseRailBlock.java @@ -24,7 +_,7 @@ - import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.VoxelShape; + import org.jspecify.annotations.Nullable; -public abstract class BaseRailBlock extends Block implements SimpleWaterloggedBlock { +public abstract class BaseRailBlock extends Block implements SimpleWaterloggedBlock, net.minecraftforge.common.extensions.IForgeBaseRailBlock { @@ -51,7 +51,7 @@ + } + + @Override -+ public RailShape getRailDirection(BlockState state, BlockGetter world, BlockPos pos, @org.jetbrains.annotations.Nullable net.minecraft.world.entity.vehicle.AbstractMinecart cart) { ++ public RailShape getRailDirection(BlockState state, BlockGetter world, BlockPos pos, net.minecraft.world.entity.vehicle.minecart.@Nullable AbstractMinecart cart) { + return state.getValue(getShapeProperty()); } } 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 3c5bd7b834..1de3d532b1 100644 --- a/patches/minecraft/net/minecraft/world/level/block/Block.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/Block.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/level/block/Block.java +++ b/net/minecraft/world/level/block/Block.java -@@ -70,11 +_,12 @@ - import net.minecraft.world.phys.shapes.VoxelShape; +@@ -74,11 +_,12 @@ + import org.jspecify.annotations.Nullable; import org.slf4j.Logger; -public class Block extends BlockBehaviour implements ItemLike { @@ -15,7 +15,7 @@ private static final LoadingCache SHAPE_FULL_BLOCK_CACHE = CacheBuilder.newBuilder() .maximumSize(512L) .weakKeys() -@@ -236,6 +_,7 @@ +@@ -245,6 +_,7 @@ LOGGER.error("Block classes should end with Block and {} doesn't.", s); } } @@ -23,7 +23,7 @@ } public static boolean isExceptionForConnection(BlockState p_152464_) { -@@ -286,12 +_,19 @@ +@@ -295,12 +_,19 @@ } } @@ -43,7 +43,7 @@ } else if (voxelshape == Shapes.empty()) { return true; } else { -@@ -379,9 +_,13 @@ +@@ -388,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,21 +58,21 @@ } } -@@ -409,7 +_,7 @@ +@@ -418,7 +_,7 @@ } private static void popResource(Level p_152441_, Supplier p_152442_, ItemStack p_152443_) { -- if (p_152441_ instanceof ServerLevel serverlevel && !p_152443_.isEmpty() && serverlevel.getGameRules().getBoolean(GameRules.RULE_DOBLOCKDROPS)) { -+ if (p_152441_ instanceof ServerLevel serverlevel && !p_152443_.isEmpty() && serverlevel.getGameRules().getBoolean(GameRules.RULE_DOBLOCKDROPS) && !p_152441_.restoringBlockSnapshots) { +- if (p_152441_ instanceof ServerLevel serverlevel && !p_152443_.isEmpty() && serverlevel.getGameRules().get(GameRules.BLOCK_DROPS)) { ++ if (p_152441_ instanceof ServerLevel serverlevel && !p_152443_.isEmpty() && serverlevel.getGameRules().get(GameRules.BLOCK_DROPS) && !p_152441_.restoringBlockSnapshots) { ItemEntity itementity = p_152442_.get(); itementity.setDefaultPickUpDelay(); p_152441_.addFreshEntity(itementity); -@@ -417,11 +_,12 @@ +@@ -426,11 +_,12 @@ } public void popExperience(ServerLevel p_49806_, BlockPos p_49807_, int p_49808_) { -- if (p_49806_.getGameRules().getBoolean(GameRules.RULE_DOBLOCKDROPS)) { -+ if (p_49806_.getGameRules().getBoolean(GameRules.RULE_DOBLOCKDROPS) && !p_49806_.restoringBlockSnapshots) { +- if (p_49806_.getGameRules().get(GameRules.BLOCK_DROPS)) { ++ if (p_49806_.getGameRules().get(GameRules.BLOCK_DROPS) && !p_49806_.restoringBlockSnapshots) { ExperienceOrb.award(p_49806_, Vec3.atCenterOf(p_49807_), p_49808_); } } @@ -81,7 +81,7 @@ public float getExplosionResistance() { return this.explosionResistance; } -@@ -440,7 +_,8 @@ +@@ -448,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_) { -@@ -462,6 +_,7 @@ +@@ -470,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; } -@@ -532,7 +_,7 @@ +@@ -540,7 +_,7 @@ this.item = Item.byBlock(this); } @@ -108,7 +108,7 @@ } public boolean hasDynamicShape() { -@@ -598,5 +_,78 @@ +@@ -606,6 +_,79 @@ public int hashCode() { return System.identityHashCode(this.first) * 31 + System.identityHashCode(this.second); } @@ -186,4 +186,5 @@ + public SoundType getSoundType(BlockState state, LevelReader level, BlockPos pos, @Nullable Entity entity) { + return getSoundType(state); } - } + + @Retention(RetentionPolicy.CLASS) 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 1bd8be3da9..575709c767 100644 --- a/patches/minecraft/net/minecraft/world/level/block/Blocks.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/Blocks.java.patch @@ -9,7 +9,7 @@ ); public static final Block DETECTOR_RAIL = register( "detector_rail", DetectorRailBlock::new, BlockBehaviour.Properties.of().noCollision().strength(0.7F).sound(SoundType.METAL) -@@ -6947,14 +_,5 @@ +@@ -6949,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/BucketPickup.java.patch b/patches/minecraft/net/minecraft/world/level/block/BucketPickup.java.patch index fe1638d74c..343ca9a931 100644 --- a/patches/minecraft/net/minecraft/world/level/block/BucketPickup.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/BucketPickup.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/level/block/BucketPickup.java +++ b/net/minecraft/world/level/block/BucketPickup.java @@ -9,8 +_,10 @@ - import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.level.block.state.BlockState; + import org.jspecify.annotations.Nullable; -public interface BucketPickup { +public interface BucketPickup extends net.minecraftforge.common.extensions.IForgeBucketPickup { diff --git a/patches/minecraft/net/minecraft/world/level/block/CampfireBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/CampfireBlock.java.patch index 3d074f9d32..054d255374 100644 --- a/patches/minecraft/net/minecraft/world/level/block/CampfireBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/CampfireBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/CampfireBlock.java +++ b/net/minecraft/world/level/block/CampfireBlock.java -@@ -263,7 +_,7 @@ +@@ -262,7 +_,7 @@ return true; } 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 4c41995ee0..2b5940a586 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 -@@ -370,7 +_,8 @@ +@@ -371,7 +_,8 @@ @Override protected BlockState mirror(BlockState p_51549_, Mirror p_51550_) { diff --git a/patches/minecraft/net/minecraft/world/level/block/ComparatorBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/ComparatorBlock.java.patch index fdb34bc963..c26336914c 100644 --- a/patches/minecraft/net/minecraft/world/level/block/ComparatorBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/ComparatorBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/ComparatorBlock.java +++ b/net/minecraft/world/level/block/ComparatorBlock.java -@@ -200,4 +_,16 @@ +@@ -199,4 +_,16 @@ protected void createBlockStateDefinition(StateDefinition.Builder p_51887_) { p_51887_.add(FACING, MODE, POWERED); } diff --git a/patches/minecraft/net/minecraft/world/level/block/CrafterBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/CrafterBlock.java.patch index 310406151f..f3d45a8a6d 100644 --- a/patches/minecraft/net/minecraft/world/level/block/CrafterBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/CrafterBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/CrafterBlock.java +++ b/net/minecraft/world/level/block/CrafterBlock.java -@@ -185,12 +_,15 @@ +@@ -184,12 +_,15 @@ ServerLevel p_336186_, BlockPos p_312358_, CrafterBlockEntity p_309887_, ItemStack p_310474_, BlockState p_310667_, RecipeHolder p_329387_ ) { Direction direction = p_310667_.getValue(ORIENTATION).front(); @@ -16,7 +16,7 @@ if (!itemstack1.isEmpty()) { break; } -@@ -201,10 +_,14 @@ +@@ -200,10 +_,14 @@ while (!itemstack.isEmpty()) { int i = itemstack.getCount(); itemstack = HopperBlockEntity.addItem(p_309887_, container, itemstack, direction.getOpposite()); diff --git a/patches/minecraft/net/minecraft/world/level/block/CropBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/CropBlock.java.patch index 465dfa460c..d0e0a1446f 100644 --- a/patches/minecraft/net/minecraft/world/level/block/CropBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/CropBlock.java.patch @@ -36,7 +36,7 @@ @Override protected void entityInside(BlockState p_52277_, Level p_52278_, BlockPos p_52279_, Entity p_52280_, InsideBlockEffectApplier p_391246_, boolean p_432051_) { -- if (p_52278_ instanceof ServerLevel serverlevel && p_52280_ instanceof Ravager && serverlevel.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { +- if (p_52278_ instanceof ServerLevel serverlevel && p_52280_ instanceof Ravager && serverlevel.getGameRules().get(GameRules.MOB_GRIEFING)) { + if (p_52278_ instanceof ServerLevel serverlevel && p_52280_ instanceof Ravager && net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(serverlevel, p_52280_)) { serverlevel.destroyBlock(p_52279_, true, p_52280_); } diff --git a/patches/minecraft/net/minecraft/world/level/block/DoublePlantBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/DoublePlantBlock.java.patch index b9261ddcd8..ae6f75ef2c 100644 --- a/patches/minecraft/net/minecraft/world/level/block/DoublePlantBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/DoublePlantBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/DoublePlantBlock.java +++ b/net/minecraft/world/level/block/DoublePlantBlock.java -@@ -80,6 +_,7 @@ +@@ -79,6 +_,7 @@ return super.canSurvive(p_52887_, p_52888_, p_52889_); } else { BlockState blockstate = p_52888_.getBlockState(p_52889_.below()); diff --git a/patches/minecraft/net/minecraft/world/level/block/FarmBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/FarmBlock.java.patch index 51d06f6c1f..c1f0d92e38 100644 --- a/patches/minecraft/net/minecraft/world/level/block/FarmBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/FarmBlock.java.patch @@ -6,7 +6,7 @@ if (p_153227_ instanceof ServerLevel serverlevel - && p_153227_.random.nextFloat() < p_394537_ - 0.5 - && p_153230_ instanceof LivingEntity -- && (p_153230_ instanceof Player || serverlevel.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) +- && (p_153230_ instanceof Player || serverlevel.getGameRules().get(GameRules.MOB_GRIEFING)) - && p_153230_.getBbWidth() * p_153230_.getBbWidth() * p_153230_.getBbHeight() > 0.512F) { + && net.minecraftforge.common.ForgeHooks.onFarmlandTrample(serverlevel, p_153229_, Blocks.DIRT.defaultBlockState(), p_394537_, p_153230_)) { // Forge: Move logic to Entity#canTrample turnToDirt(p_153230_, p_153228_, p_153227_, p_153229_); diff --git a/patches/minecraft/net/minecraft/world/level/block/FireBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/FireBlock.java.patch index 903de449ea..483dd82a6a 100644 --- a/patches/minecraft/net/minecraft/world/level/block/FireBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/FireBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/FireBlock.java +++ b/net/minecraft/world/level/block/FireBlock.java -@@ -117,13 +_,13 @@ +@@ -115,13 +_,13 @@ protected BlockState getStateForPlacement(BlockGetter p_53471_, BlockPos p_53472_) { BlockPos blockpos = p_53472_.below(); BlockState blockstate = p_53471_.getBlockState(blockpos); @@ -16,44 +16,44 @@ } } -@@ -149,7 +_,7 @@ - } +@@ -146,7 +_,7 @@ + } - BlockState blockstate = p_221161_.getBlockState(p_221162_.below()); -- boolean flag = blockstate.is(p_221161_.dimensionType().infiniburn()); -+ boolean flag = blockstate.isFireSource(p_221161_, p_221162_, Direction.UP); - int i = p_221160_.getValue(AGE); - if (!flag && p_221161_.isRaining() && this.isNearRain(p_221161_, p_221162_) && p_221163_.nextFloat() < 0.2F + i * 0.03F) { - p_221161_.removeBlock(p_221162_, false); -@@ -170,7 +_,7 @@ - return; - } + BlockState blockstate = p_221161_.getBlockState(p_221162_.below()); +- boolean flag = blockstate.is(p_221161_.dimensionType().infiniburn()); ++ boolean flag = blockstate.isFireSource(p_221161_, p_221162_, Direction.UP); + int i = p_221160_.getValue(AGE); + if (!flag && p_221161_.isRaining() && this.isNearRain(p_221161_, p_221162_) && p_221163_.nextFloat() < 0.2F + i * 0.03F) { + p_221161_.removeBlock(p_221162_, false); +@@ -167,7 +_,7 @@ + return; + } -- if (i == 15 && p_221163_.nextInt(4) == 0 && !this.canBurn(p_221161_.getBlockState(p_221162_.below()))) { -+ if (i == 15 && p_221163_.nextInt(4) == 0 && !this.canCatchFire(p_221161_, p_221162_.below(), Direction.UP)) { - p_221161_.removeBlock(p_221162_, false); - return; - } -@@ -178,12 +_,12 @@ +- if (i == 15 && p_221163_.nextInt(4) == 0 && !this.canBurn(p_221161_.getBlockState(p_221162_.below()))) { ++ if (i == 15 && p_221163_.nextInt(4) == 0 && !this.canCatchFire(p_221161_, p_221162_.below(), Direction.UP)) { + p_221161_.removeBlock(p_221162_, false); + return; + } +@@ -175,12 +_,12 @@ - boolean flag1 = p_221161_.getBiome(p_221162_).is(BiomeTags.INCREASED_FIRE_BURNOUT); - int k = flag1 ? -50 : 0; -- this.checkBurnOut(p_221161_, p_221162_.east(), 300 + k, p_221163_, i); -- this.checkBurnOut(p_221161_, p_221162_.west(), 300 + k, p_221163_, i); -- this.checkBurnOut(p_221161_, p_221162_.below(), 250 + k, p_221163_, i); -- this.checkBurnOut(p_221161_, p_221162_.above(), 250 + k, p_221163_, i); -- this.checkBurnOut(p_221161_, p_221162_.north(), 300 + k, p_221163_, i); -- this.checkBurnOut(p_221161_, p_221162_.south(), 300 + k, p_221163_, i); -+ this.checkBurnOut(p_221161_, p_221162_.east(), 300 + k, p_221163_, i, Direction.WEST); -+ this.checkBurnOut(p_221161_, p_221162_.west(), 300 + k, p_221163_, i, Direction.EAST); -+ this.checkBurnOut(p_221161_, p_221162_.below(), 250 + k, p_221163_, i, Direction.UP); -+ this.checkBurnOut(p_221161_, p_221162_.above(), 250 + k, p_221163_, i, Direction.DOWN); -+ this.checkBurnOut(p_221161_, p_221162_.north(), 300 + k, p_221163_, i, Direction.SOUTH); -+ this.checkBurnOut(p_221161_, p_221162_.south(), 300 + k, p_221163_, i, Direction.NORTH); - BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(); + boolean flag1 = p_221161_.environmentAttributes().getValue(EnvironmentAttributes.INCREASED_FIRE_BURNOUT, p_221162_); + int k = flag1 ? -50 : 0; +- this.checkBurnOut(p_221161_, p_221162_.east(), 300 + k, p_221163_, i); +- this.checkBurnOut(p_221161_, p_221162_.west(), 300 + k, p_221163_, i); +- this.checkBurnOut(p_221161_, p_221162_.below(), 250 + k, p_221163_, i); +- this.checkBurnOut(p_221161_, p_221162_.above(), 250 + k, p_221163_, i); +- this.checkBurnOut(p_221161_, p_221162_.north(), 300 + k, p_221163_, i); +- this.checkBurnOut(p_221161_, p_221162_.south(), 300 + k, p_221163_, i); ++ this.checkBurnOut(p_221161_, p_221162_.east(), 300 + k, p_221163_, i, Direction.WEST); ++ this.checkBurnOut(p_221161_, p_221162_.west(), 300 + k, p_221163_, i, Direction.EAST); ++ this.checkBurnOut(p_221161_, p_221162_.below(), 250 + k, p_221163_, i, Direction.UP); ++ this.checkBurnOut(p_221161_, p_221162_.above(), 250 + k, p_221163_, i, Direction.DOWN); ++ this.checkBurnOut(p_221161_, p_221162_.north(), 300 + k, p_221163_, i, Direction.SOUTH); ++ this.checkBurnOut(p_221161_, p_221162_.south(), 300 + k, p_221163_, i, Direction.NORTH); + BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(); - for (int l = -1; l <= 1; l++) { -@@ -227,33 +_,31 @@ + for (int l = -1; l <= 1; l++) { +@@ -223,33 +_,31 @@ || p_53429_.isRainingAt(p_53430_.south()); } @@ -92,7 +92,7 @@ } } -@@ -264,7 +_,7 @@ +@@ -260,7 +_,7 @@ private boolean isValidFireLocation(BlockGetter p_53486_, BlockPos p_53487_) { for (Direction direction : Direction.values()) { @@ -101,7 +101,7 @@ return true; } } -@@ -280,13 +_,14 @@ +@@ -276,13 +_,14 @@ for (Direction direction : Direction.values()) { BlockState blockstate = p_221157_.getBlockState(p_221158_.relative(direction)); @@ -117,7 +117,7 @@ @Override protected boolean canBurn(BlockState p_53489_) { return this.getIgniteOdds(p_53489_) > 0; -@@ -308,8 +_,21 @@ +@@ -304,8 +_,21 @@ } public void setFlammable(Block p_53445_, int p_53446_, int p_53447_) { diff --git a/patches/minecraft/net/minecraft/world/level/block/FlowerPotBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/FlowerPotBlock.java.patch index c1d3bf5f52..d411d232a1 100644 --- a/patches/minecraft/net/minecraft/world/level/block/FlowerPotBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/FlowerPotBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/FlowerPotBlock.java +++ b/net/minecraft/world/level/block/FlowerPotBlock.java -@@ -44,9 +_,31 @@ +@@ -45,9 +_,31 @@ } public FlowerPotBlock(Block p_53528_, BlockBehaviour.Properties p_53529_) { @@ -35,7 +35,7 @@ } @Override -@@ -59,7 +_,7 @@ +@@ -60,7 +_,7 @@ ItemStack p_329639_, BlockState p_328047_, Level p_328816_, BlockPos p_334572_, Player p_329206_, InteractionHand p_329142_, BlockHitResult p_330607_ ) { BlockState blockstate = (p_329639_.getItem() instanceof BlockItem blockitem @@ -44,7 +44,7 @@ : Blocks.AIR) .defaultBlockState(); if (blockstate.isAir()) { -@@ -85,7 +_,7 @@ +@@ -86,7 +_,7 @@ p_333787_.drop(itemstack, false); } @@ -53,7 +53,7 @@ p_334489_.gameEvent(p_333787_, GameEvent.BLOCK_CHANGE, p_330334_); return InteractionResult.SUCCESS; } -@@ -117,7 +_,7 @@ +@@ -118,7 +_,7 @@ } public Block getPotted() { @@ -62,13 +62,13 @@ } @Override -@@ -152,5 +_,24 @@ +@@ -153,5 +_,24 @@ } else { return p_376074_.is(Blocks.POTTED_CLOSED_EYEBLOSSOM) ? Blocks.POTTED_OPEN_EYEBLOSSOM.defaultBlockState() : p_376074_; } + } + -+ private final Map> fullPots; ++ private final Map> fullPots; + private final java.util.function.Supplier emptyPot; + private final java.util.function.Supplier flowerDelegate; + @@ -76,14 +76,14 @@ + return emptyPot == null ? this : emptyPot.get(); + } + -+ public void addPlant(net.minecraft.resources.ResourceLocation flower, java.util.function.Supplier fullPot) { ++ public void addPlant(net.minecraft.resources.Identifier flower, java.util.function.Supplier fullPot) { + if (getEmptyPot() != this) { + throw new IllegalArgumentException("Cannot add plant to non-empty pot: " + this); + } + fullPots.put(flower, fullPot); + } + -+ public Map> getFullPotsView() { ++ public Map> getFullPotsView() { + return java.util.Collections.unmodifiableMap(fullPots); } } diff --git a/patches/minecraft/net/minecraft/world/level/block/PitcherCropBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/PitcherCropBlock.java.patch index 608854560a..b0989645a5 100644 --- a/patches/minecraft/net/minecraft/world/level/block/PitcherCropBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/PitcherCropBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/PitcherCropBlock.java +++ b/net/minecraft/world/level/block/PitcherCropBlock.java -@@ -107,7 +_,7 @@ +@@ -106,7 +_,7 @@ @Override protected boolean mayPlaceOn(BlockState p_277418_, BlockGetter p_277461_, BlockPos p_277608_) { diff --git a/patches/minecraft/net/minecraft/world/level/block/RailState.java.patch b/patches/minecraft/net/minecraft/world/level/block/RailState.java.patch index 24c8a3719b..a87024673a 100644 --- a/patches/minecraft/net/minecraft/world/level/block/RailState.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/RailState.java.patch @@ -19,7 +19,7 @@ this.updateConnections(railshape); } -@@ -179,7 +_,7 @@ +@@ -178,7 +_,7 @@ } } @@ -28,7 +28,7 @@ if (BaseRailBlock.isRail(this.level, blockpos.above())) { railshape = RailShape.ASCENDING_NORTH; } -@@ -189,7 +_,7 @@ +@@ -188,7 +_,7 @@ } } @@ -37,7 +37,7 @@ if (BaseRailBlock.isRail(this.level, blockpos3.above())) { railshape = RailShape.ASCENDING_EAST; } -@@ -201,6 +_,11 @@ +@@ -200,6 +_,11 @@ if (railshape == null) { railshape = RailShape.NORTH_SOUTH; @@ -49,7 +49,7 @@ } this.state = this.state.setValue(this.block.getShapeProperty(), railshape); -@@ -305,7 +_,7 @@ +@@ -304,7 +_,7 @@ } } @@ -58,7 +58,7 @@ if (BaseRailBlock.isRail(this.level, blockpos.above())) { railshape = RailShape.ASCENDING_NORTH; } -@@ -315,7 +_,7 @@ +@@ -314,7 +_,7 @@ } } @@ -67,7 +67,7 @@ if (BaseRailBlock.isRail(this.level, blockpos3.above())) { railshape = RailShape.ASCENDING_EAST; } -@@ -325,7 +_,7 @@ +@@ -324,7 +_,7 @@ } } diff --git a/patches/minecraft/net/minecraft/world/level/block/RedStoneWireBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/RedStoneWireBlock.java.patch index 7440149dbf..7a6dd0f0ef 100644 --- a/patches/minecraft/net/minecraft/world/level/block/RedStoneWireBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/RedStoneWireBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/RedStoneWireBlock.java +++ b/net/minecraft/world/level/block/RedStoneWireBlock.java -@@ -239,7 +_,7 @@ +@@ -238,7 +_,7 @@ BlockState blockstate = p_55523_.getBlockState(blockpos); if (p_55526_) { boolean flag = blockstate.getBlock() instanceof TrapDoorBlock || this.canSurviveOn(p_55523_, blockpos, blockstate); @@ -9,7 +9,7 @@ if (blockstate.isFaceSturdy(p_55523_, blockpos, p_55525_.getOpposite())) { return RedstoneSide.UP; } -@@ -248,9 +_,14 @@ +@@ -247,9 +_,14 @@ } } diff --git a/patches/minecraft/net/minecraft/world/level/block/SculkCatalystBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/SculkCatalystBlock.java.patch index 5ccbcb116e..ba6a3d25cc 100644 --- a/patches/minecraft/net/minecraft/world/level/block/SculkCatalystBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/SculkCatalystBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/SculkCatalystBlock.java +++ b/net/minecraft/world/level/block/SculkCatalystBlock.java -@@ -61,8 +_,13 @@ +@@ -59,8 +_,13 @@ @Override protected void spawnAfterBreak(BlockState p_222109_, ServerLevel p_222110_, BlockPos p_222111_, ItemStack p_222112_, boolean p_222113_) { super.spawnAfterBreak(p_222109_, p_222110_, p_222111_, p_222112_, p_222113_); diff --git a/patches/minecraft/net/minecraft/world/level/block/SculkSensorBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/SculkSensorBlock.java.patch index b4e51f53e0..1eafb2b4ec 100644 --- a/patches/minecraft/net/minecraft/world/level/block/SculkSensorBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/SculkSensorBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/SculkSensorBlock.java +++ b/net/minecraft/world/level/block/SculkSensorBlock.java -@@ -283,8 +_,13 @@ +@@ -280,8 +_,13 @@ @Override protected void spawnAfterBreak(BlockState p_222142_, ServerLevel p_222143_, BlockPos p_222144_, ItemStack p_222145_, boolean p_222146_) { super.spawnAfterBreak(p_222142_, p_222143_, p_222144_, p_222145_, p_222146_); diff --git a/patches/minecraft/net/minecraft/world/level/block/SculkShriekerBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/SculkShriekerBlock.java.patch index fc175e4928..86d8ae810e 100644 --- a/patches/minecraft/net/minecraft/world/level/block/SculkShriekerBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/SculkShriekerBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/SculkShriekerBlock.java +++ b/net/minecraft/world/level/block/SculkShriekerBlock.java -@@ -128,7 +_,7 @@ +@@ -126,7 +_,7 @@ @Override protected void spawnAfterBreak(BlockState p_222192_, ServerLevel p_222193_, BlockPos p_222194_, ItemStack p_222195_, boolean p_222196_) { super.spawnAfterBreak(p_222192_, p_222193_, p_222194_, p_222195_, p_222196_); @@ -9,7 +9,7 @@ this.tryDropExperience(p_222193_, p_222194_, p_222195_, ConstantInt.of(5)); } } -@@ -143,5 +_,10 @@ +@@ -140,5 +_,10 @@ (p_281134_, p_281135_, p_281136_, p_281137_) -> VibrationSystem.Ticker.tick(p_281134_, p_281137_.getVibrationData(), p_281137_.getVibrationUser()) ) : null; diff --git a/patches/minecraft/net/minecraft/world/level/block/SeagrassBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/SeagrassBlock.java.patch index 7dcffdd0b3..ebc600e967 100644 --- a/patches/minecraft/net/minecraft/world/level/block/SeagrassBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/SeagrassBlock.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/level/block/SeagrassBlock.java +++ b/net/minecraft/world/level/block/SeagrassBlock.java @@ -23,7 +_,7 @@ - import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.VoxelShape; + import org.jspecify.annotations.Nullable; -public class SeagrassBlock extends VegetationBlock implements BonemealableBlock, LiquidBlockContainer { +public class SeagrassBlock extends VegetationBlock implements BonemealableBlock, LiquidBlockContainer, net.minecraftforge.common.IForgeShearable { diff --git a/patches/minecraft/net/minecraft/world/level/block/SpawnerBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/SpawnerBlock.java.patch index 15a2c8980e..db83564374 100644 --- a/patches/minecraft/net/minecraft/world/level/block/SpawnerBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/SpawnerBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/SpawnerBlock.java +++ b/net/minecraft/world/level/block/SpawnerBlock.java -@@ -39,9 +_,14 @@ +@@ -38,9 +_,14 @@ @Override protected void spawnAfterBreak(BlockState p_222477_, ServerLevel p_222478_, BlockPos p_222479_, ItemStack p_222480_, boolean p_222481_) { super.spawnAfterBreak(p_222477_, p_222478_, p_222479_, p_222480_, p_222481_); diff --git a/patches/minecraft/net/minecraft/world/level/block/TntBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/TntBlock.java.patch index bcc542a314..63964f8641 100644 --- a/patches/minecraft/net/minecraft/world/level/block/TntBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/TntBlock.java.patch @@ -38,7 +38,7 @@ + @Deprecated //Forge: Prefer using IForgeBlock#onCaughtFire private static boolean prime(Level p_396831_, BlockPos p_393566_, @Nullable LivingEntity p_395667_) { - if (p_396831_ instanceof ServerLevel serverlevel && serverlevel.getGameRules().getBoolean(GameRules.RULE_TNT_EXPLODES)) { + if (p_396831_ instanceof ServerLevel serverlevel && serverlevel.getGameRules().get(GameRules.TNT_EXPLODES)) { PrimedTnt primedtnt = new PrimedTnt(p_396831_, p_393566_.getX() + 0.5, p_393566_.getY(), p_393566_.getZ() + 0.5, p_395667_); @@ -102,7 +_,7 @@ if (!p_329029_.is(Items.FLINT_AND_STEEL) && !p_329029_.is(Items.FIRE_CHARGE)) { @@ -64,7 +64,7 @@ p_57464_.add(UNSTABLE); + } + -+ public boolean onCaughtFire(BlockState state, Level level, BlockPos pos, @Nullable net.minecraft.core.Direction face, @Nullable LivingEntity igniter) { ++ public boolean onCaughtFire(BlockState state, Level level, BlockPos pos, net.minecraft.core.@Nullable Direction face, @Nullable LivingEntity igniter) { + return prime(level, pos, igniter); } } diff --git a/patches/minecraft/net/minecraft/world/level/block/TurtleEggBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/TurtleEggBlock.java.patch index 56c130b84a..cb2efac4ce 100644 --- a/patches/minecraft/net/minecraft/world/level/block/TurtleEggBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/TurtleEggBlock.java.patch @@ -4,7 +4,7 @@ if (p_57769_ instanceof Turtle || p_57769_ instanceof Bat) { return false; } else { -- return !(p_57769_ instanceof LivingEntity) ? false : p_57769_ instanceof Player || p_366354_.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING); +- return !(p_57769_ instanceof LivingEntity) ? false : p_57769_ instanceof Player || p_366354_.getGameRules().get(GameRules.MOB_GRIEFING); + return !(p_57769_ instanceof LivingEntity) ? false : p_57769_ instanceof Player || net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(p_366354_, p_57769_); } } diff --git a/patches/minecraft/net/minecraft/world/level/block/VineBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/VineBlock.java.patch index 57058efe9e..87477d0b46 100644 --- a/patches/minecraft/net/minecraft/world/level/block/VineBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/VineBlock.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/level/block/VineBlock.java +++ b/net/minecraft/world/level/block/VineBlock.java @@ -23,7 +_,7 @@ - import net.minecraft.world.phys.shapes.Shapes; import net.minecraft.world.phys.shapes.VoxelShape; + import org.jspecify.annotations.Nullable; -public class VineBlock extends Block { +public class VineBlock extends Block implements net.minecraftforge.common.IForgeShearable { @@ -12,7 +12,7 @@ @@ -172,7 +_,7 @@ @Override protected void randomTick(BlockState p_222655_, ServerLevel p_222656_, BlockPos p_222657_, RandomSource p_222658_) { - if (p_222656_.getGameRules().getBoolean(GameRules.RULE_DO_VINES_SPREAD)) { + if (p_222656_.getGameRules().get(GameRules.SPREAD_VINES)) { - if (p_222658_.nextInt(4) == 0) { + if (p_222656_.random.nextInt(4) == 0 && p_222656_.isAreaLoaded(p_222657_, 4)) { // Forge: check area to prevent loading unloaded chunks Direction direction = Direction.getRandom(p_222658_); diff --git a/patches/minecraft/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java.patch b/patches/minecraft/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java.patch index 42110363ad..47d1fe2db8 100644 --- a/patches/minecraft/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java.patch @@ -121,7 +121,7 @@ } if (itemstack.is(Blocks.WET_SPONGE.asItem()) && !p_267073_.get(1).isEmpty() && p_267073_.get(1).is(Items.BUCKET)) { -@@ -388,6 +_,35 @@ +@@ -385,6 +_,35 @@ for (ItemStack itemstack : this.items) { p_363325_.accountStack(itemstack); } 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 d624e1605a..f302f8ba12 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 -@@ -168,4 +_,27 @@ +@@ -170,4 +_,27 @@ p_407613_.discard("lock"); p_407613_.discard("Items"); } diff --git a/patches/minecraft/net/minecraft/world/level/block/entity/BeaconBlockEntity.java.patch b/patches/minecraft/net/minecraft/world/level/block/entity/BeaconBlockEntity.java.patch index 5b0a99fce3..8687f0cde2 100644 --- a/patches/minecraft/net/minecraft/world/level/block/entity/BeaconBlockEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/entity/BeaconBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/BeaconBlockEntity.java +++ b/net/minecraft/world/level/block/entity/BeaconBlockEntity.java -@@ -139,8 +_,8 @@ +@@ -135,8 +_,8 @@ for (int i1 = 0; i1 < 10 && blockpos.getY() <= l; i1++) { BlockState blockstate = p_155108_.getBlockState(blockpos); 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 8038ce1580..44c7795464 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,7 +1,7 @@ --- a/net/minecraft/world/level/block/entity/BlockEntity.java +++ b/net/minecraft/world/level/block/entity/BlockEntity.java @@ -36,7 +_,7 @@ - import net.minecraft.world.level.storage.ValueOutput; + import org.jspecify.annotations.Nullable; import org.slf4j.Logger; -public abstract class BlockEntity implements DebugValueSource { @@ -9,7 +9,7 @@ private static final Codec> TYPE_CODEC = BuiltInRegistries.BLOCK_ENTITY_TYPE.byNameCodec(); private static final Logger LOGGER = LogUtils.getLogger(); private final BlockEntityType type; -@@ -48,10 +_,12 @@ +@@ -47,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_) { -@@ -61,7 +_,7 @@ +@@ -60,7 +_,7 @@ } public boolean isValidBlockState(BlockState p_345570_) { @@ -31,7 +31,7 @@ } public static BlockPos getPosFromTag(ChunkPos p_396083_, CompoundTag p_187473_) { -@@ -93,6 +_,7 @@ +@@ -91,6 +_,7 @@ } protected void loadAdditional(ValueInput p_409136_) { @@ -39,7 +39,7 @@ } public final void loadWithComponents(ValueInput p_409893_) { -@@ -105,6 +_,7 @@ +@@ -103,6 +_,7 @@ } protected void saveAdditional(ValueOutput p_407573_) { @@ -47,7 +47,7 @@ } public final CompoundTag saveWithFullMetadata(HolderLookup.Provider p_331193_) { -@@ -240,6 +_,13 @@ +@@ -236,6 +_,13 @@ public void setRemoved() { this.remove = true; diff --git a/patches/minecraft/net/minecraft/world/level/block/entity/ConduitBlockEntity.java.patch b/patches/minecraft/net/minecraft/world/level/block/entity/ConduitBlockEntity.java.patch index 959f93cb30..97e6cf97fb 100644 --- a/patches/minecraft/net/minecraft/world/level/block/entity/ConduitBlockEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/entity/ConduitBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/ConduitBlockEntity.java +++ b/net/minecraft/world/level/block/entity/ConduitBlockEntity.java -@@ -149,8 +_,8 @@ +@@ -148,8 +_,8 @@ BlockPos blockpos1 = p_155416_.offset(j1, k1, l1); BlockState blockstate = p_155415_.getBlockState(blockpos1); 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 7e6a308a01..36a3dfd7ec 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 @@ -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); -@@ -452,5 +_,14 @@ +@@ -446,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 89d7b12cf0..5777676d36 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 -@@ -235,7 +_,7 @@ +@@ -234,7 +_,7 @@ @Override public boolean canPlaceItemThroughFace(int p_59663_, ItemStack p_59664_, @Nullable Direction p_59665_) { @@ -9,7 +9,7 @@ } @Override -@@ -259,6 +_,11 @@ +@@ -257,6 +_,11 @@ public boolean isClosed() { return this.animationStatus == ShulkerBoxBlockEntity.AnimationStatus.CLOSED; diff --git a/patches/minecraft/net/minecraft/world/level/block/entity/SignBlockEntity.java.patch b/patches/minecraft/net/minecraft/world/level/block/entity/SignBlockEntity.java.patch index cc6abc4d65..56359d16a1 100644 --- a/patches/minecraft/net/minecraft/world/level/block/entity/SignBlockEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/entity/SignBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/SignBlockEntity.java +++ b/net/minecraft/world/level/block/entity/SignBlockEntity.java -@@ -274,6 +_,11 @@ +@@ -281,6 +_,11 @@ } } diff --git a/patches/minecraft/net/minecraft/world/level/block/grower/TreeGrower.java.patch b/patches/minecraft/net/minecraft/world/level/block/grower/TreeGrower.java.patch index 0aebf31220..f27797fe79 100644 --- a/patches/minecraft/net/minecraft/world/level/block/grower/TreeGrower.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/grower/TreeGrower.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/grower/TreeGrower.java +++ b/net/minecraft/world/level/block/grower/TreeGrower.java -@@ -130,6 +_,9 @@ +@@ -128,6 +_,9 @@ ResourceKey> resourcekey = this.getConfiguredMegaFeature(p_309951_); if (resourcekey != null) { Holder> holder = p_309830_.registryAccess().lookupOrThrow(Registries.CONFIGURED_FEATURE).get(resourcekey).orElse(null); 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 c81ada3611..ca9befbd7d 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 @@ -19,7 +19,7 @@ } } -@@ -347,12 +_,15 @@ +@@ -346,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_) { -@@ -388,6 +_,8 @@ +@@ -387,6 +_,8 @@ return this.isRandomlyTicking; } @@ -46,7 +46,7 @@ protected SoundType getSoundType(BlockState p_328629_) { return this.soundType; } -@@ -408,6 +_,10 @@ +@@ -407,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())); -@@ -560,12 +_,14 @@ +@@ -557,12 +_,14 @@ return this.useShapeForLightOcclusion; } @@ -73,7 +73,7 @@ } public boolean ignitedByLava() { -@@ -578,9 +_,11 @@ +@@ -575,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_); } -@@ -634,6 +_,8 @@ +@@ -631,6 +_,8 @@ } public PushReaction getPistonPushReaction() { @@ -95,7 +95,7 @@ return this.pushReaction; } -@@ -1002,7 +_,7 @@ +@@ -996,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 279915fe34..701236a2cd 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 -@@ -328,23 +_,28 @@ +@@ -318,23 +_,28 @@ @Override public final void findBlockLightSources(BiConsumer p_285269_) { @@ -33,14 +33,13 @@ } } } -@@ -503,5 +_,10 @@ +@@ -493,5 +_,9 @@ } public record PackedTicks(List> blocks, List> fluids) { + } + -+ @Nullable -+ public net.minecraft.world.level.LevelAccessor getWorldForge() { ++ public net.minecraft.world.level.@Nullable LevelAccessor getWorldForge() { + return null; } } 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 21c8642a34..c7377988a8 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 -@@ -284,4 +_,9 @@ +@@ -278,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 c60092fa76..8f33ba71eb 100644 --- a/patches/minecraft/net/minecraft/world/level/chunk/LevelChunk.java.patch +++ b/patches/minecraft/net/minecraft/world/level/chunk/LevelChunk.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/level/chunk/LevelChunk.java +++ b/net/minecraft/world/level/chunk/LevelChunk.java -@@ -62,7 +_,7 @@ - import net.minecraft.world.ticks.TickContainerAccess; +@@ -63,7 +_,7 @@ + import org.jspecify.annotations.Nullable; import org.slf4j.Logger; -public class LevelChunk extends ChunkAccess implements DebugValueSource { @@ -9,15 +9,15 @@ static final Logger LOGGER = LogUtils.getLogger(); private static final TickingBlockEntity NULL_TICKER = new TickingBlockEntity() { @Override -@@ -124,6 +_,7 @@ +@@ -123,6 +_,7 @@ this.postLoad = p_196861_; this.blockTicks = p_196857_; this.fluidTicks = p_196858_; + this.capProvider.initInternal(); } - public LevelChunk(ServerLevel p_196850_, ProtoChunk p_196851_, @Nullable LevelChunk.PostLoadProcessor p_196852_) { -@@ -321,7 +_,7 @@ + public LevelChunk(ServerLevel p_196850_, ProtoChunk p_196851_, LevelChunk.@Nullable PostLoadProcessor p_196852_) { +@@ -319,7 +_,7 @@ if (!levelchunksection.getBlockState(j, k, l).is(block)) { return null; } else { @@ -26,9 +26,9 @@ p_62866_.onPlace(this.level, p_62865_, blockstate, flag2); } -@@ -376,6 +_,12 @@ - @Nullable - public BlockEntity getBlockEntity(BlockPos p_62868_, LevelChunk.EntityCreationType p_62869_) { +@@ -371,6 +_,12 @@ + + public @Nullable BlockEntity getBlockEntity(BlockPos p_62868_, LevelChunk.EntityCreationType p_62869_) { BlockEntity blockentity = this.blockEntities.get(p_62868_); + + if (blockentity != null && blockentity.isRemoved()) { @@ -39,7 +39,7 @@ if (blockentity == null) { CompoundTag compoundtag = this.pendingBlockEntities.remove(p_62868_); if (compoundtag != null) { -@@ -393,9 +_,6 @@ +@@ -388,9 +_,6 @@ this.addAndRegisterBlockEntity(blockentity); } } @@ -49,7 +49,7 @@ } return blockentity; -@@ -410,6 +_,7 @@ +@@ -405,6 +_,7 @@ this.level.onBlockEntityAdded(p_156391_); this.updateBlockEntityTicker(p_156391_); @@ -57,8 +57,8 @@ } } -@@ -462,9 +_,14 @@ - public CompoundTag getBlockEntityNbtForSaving(BlockPos p_62932_, HolderLookup.Provider p_329605_) { +@@ -456,9 +_,14 @@ + public @Nullable CompoundTag getBlockEntityNbtForSaving(BlockPos p_62932_, HolderLookup.Provider p_329605_) { BlockEntity blockentity = this.getBlockEntity(p_62932_); if (blockentity != null && !blockentity.isRemoved()) { + try { @@ -72,7 +72,7 @@ } else { CompoundTag compoundtag = this.pendingBlockEntities.get(p_62932_); if (compoundtag != null) { -@@ -544,9 +_,10 @@ +@@ -538,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 @@ } } ); -@@ -684,6 +_,7 @@ +@@ -678,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)); -@@ -691,6 +_,7 @@ +@@ -685,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); -@@ -743,6 +_,24 @@ +@@ -737,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; -@@ -760,6 +_,7 @@ +@@ -754,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)) { -@@ -781,6 +_,11 @@ +@@ -775,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); } } -@@ -854,6 +_,33 @@ +@@ -848,6 +_,33 @@ public String toString() { return this.ticker + " "; } diff --git a/patches/minecraft/net/minecraft/world/level/dimension/end/EndDragonFight.java.patch b/patches/minecraft/net/minecraft/world/level/dimension/end/EndDragonFight.java.patch index faeeb1392d..20e99700e9 100644 --- a/patches/minecraft/net/minecraft/world/level/dimension/end/EndDragonFight.java.patch +++ b/patches/minecraft/net/minecraft/world/level/dimension/end/EndDragonFight.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/dimension/end/EndDragonFight.java +++ b/net/minecraft/world/level/dimension/end/EndDragonFight.java -@@ -541,6 +_,14 @@ +@@ -535,6 +_,14 @@ } } @@ -12,6 +12,6 @@ + this.dragonEvent.removePlayer(player); + } + - @Nullable - public UUID getDragonUUID() { + public @Nullable UUID getDragonUUID() { return this.dragonUUID; + } 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 71dc3e822f..fe7162dca5 100644 --- a/patches/minecraft/net/minecraft/world/level/levelgen/Beardifier.java.patch +++ b/patches/minecraft/net/minecraft/world/level/levelgen/Beardifier.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/levelgen/Beardifier.java +++ b/net/minecraft/world/level/levelgen/Beardifier.java -@@ -53,6 +_,11 @@ +@@ -52,6 +_,11 @@ for (StructurePiece structurepiece : structurestart.getPieces()) { if (structurepiece.isCloseToChunk(p_223939_, 12)) { diff --git a/patches/minecraft/net/minecraft/world/level/levelgen/structure/StructurePiece.java.patch b/patches/minecraft/net/minecraft/world/level/levelgen/structure/StructurePiece.java.patch index 7fe0db2309..8d0ec8177a 100644 --- a/patches/minecraft/net/minecraft/world/level/levelgen/structure/StructurePiece.java.patch +++ b/patches/minecraft/net/minecraft/world/level/levelgen/structure/StructurePiece.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/levelgen/structure/StructurePiece.java +++ b/net/minecraft/world/level/levelgen/structure/StructurePiece.java -@@ -81,6 +_,9 @@ +@@ -80,6 +_,9 @@ } public final CompoundTag createTag(StructurePieceSerializationContext p_192645_) { diff --git a/patches/minecraft/net/minecraft/world/level/levelgen/structure/StructureStart.java.patch b/patches/minecraft/net/minecraft/world/level/levelgen/structure/StructureStart.java.patch index 82e57865a9..b105dc649d 100644 --- a/patches/minecraft/net/minecraft/world/level/levelgen/structure/StructureStart.java.patch +++ b/patches/minecraft/net/minecraft/world/level/levelgen/structure/StructureStart.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/levelgen/structure/StructureStart.java +++ b/net/minecraft/world/level/levelgen/structure/StructureStart.java -@@ -100,6 +_,9 @@ +@@ -98,6 +_,9 @@ public CompoundTag createTag(StructurePieceSerializationContext p_192661_, ChunkPos p_192662_) { CompoundTag compoundtag = new CompoundTag(); if (this.isValid()) { diff --git a/patches/minecraft/net/minecraft/world/level/levelgen/structure/templatesystem/StructureProcessor.java.patch b/patches/minecraft/net/minecraft/world/level/levelgen/structure/templatesystem/StructureProcessor.java.patch index fe0c3bb24a..3aa259379b 100644 --- a/patches/minecraft/net/minecraft/world/level/levelgen/structure/templatesystem/StructureProcessor.java.patch +++ b/patches/minecraft/net/minecraft/world/level/levelgen/structure/templatesystem/StructureProcessor.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/level/levelgen/structure/templatesystem/StructureProcessor.java +++ b/net/minecraft/world/level/levelgen/structure/templatesystem/StructureProcessor.java @@ -7,6 +_,11 @@ - import net.minecraft.world.level.ServerLevelAccessor; + import org.jspecify.annotations.Nullable; public abstract class StructureProcessor { + @@ -9,10 +9,10 @@ + * @deprecated Forge: Use {@link #process(LevelReader, BlockPos, BlockPos, StructureTemplate.StructureBlockInfo, StructureTemplate.StructureBlockInfo, StructurePlaceSettings, StructureTemplate)} instead. + */ + @Deprecated - @Nullable - public StructureTemplate.StructureBlockInfo processBlock( + public StructureTemplate.@Nullable StructureBlockInfo processBlock( LevelReader p_74416_, -@@ -30,5 +_,22 @@ + BlockPos p_74417_, +@@ -29,5 +_,21 @@ StructurePlaceSettings p_277497_ ) { return p_278053_; @@ -30,8 +30,7 @@ + return entityInfo; + } + -+ @Nullable -+ public StructureTemplate.StructureBlockInfo process(LevelReader level, BlockPos seed, BlockPos offset, StructureTemplate.StructureBlockInfo rawBlock, StructureTemplate.StructureBlockInfo block, StructurePlaceSettings settings, @Nullable StructureTemplate template) { ++ public StructureTemplate.@Nullable StructureBlockInfo process(LevelReader level, BlockPos seed, BlockPos offset, StructureTemplate.StructureBlockInfo rawBlock, StructureTemplate.StructureBlockInfo block, StructurePlaceSettings settings, @Nullable StructureTemplate template) { + return processBlock(level, seed, offset, rawBlock, block, settings); } } 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 677d0dd13e..41829fb986 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 @@ -9,9 +9,9 @@ + } + public boolean placeInWorld( - ServerLevelAccessor p_230329_, BlockPos p_230330_, BlockPos p_230331_, StructurePlaceSettings p_230332_, RandomSource p_230333_, int p_230334_ - ) { -@@ -283,7 +_,7 @@ + ServerLevelAccessor p_230329_, + BlockPos p_230330_, +@@ -288,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) { -@@ -407,10 +_,10 @@ +@@ -412,10 +_,10 @@ p_230330_, p_230332_.getMirror(), p_230332_.getRotation(), @@ -33,7 +33,7 @@ ); } } -@@ -452,12 +_,21 @@ +@@ -457,12 +_,21 @@ ); } @@ -56,7 +56,7 @@ ) { List list = new ArrayList<>(); List list1 = new ArrayList<>(); -@@ -473,7 +_,7 @@ +@@ -478,7 +_,7 @@ while (structuretemplate$structureblockinfo1 != null && iterator.hasNext()) { structuretemplate$structureblockinfo1 = iterator.next() @@ -65,7 +65,7 @@ } if (structuretemplate$structureblockinfo1 != null) { -@@ -494,17 +_,17 @@ +@@ -499,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)); -@@ -526,6 +_,24 @@ +@@ -531,6 +_,24 @@ } } } diff --git a/patches/minecraft/net/minecraft/world/level/material/Fluid.java.patch b/patches/minecraft/net/minecraft/world/level/material/Fluid.java.patch index 6568cf75f5..6a9de15436 100644 --- a/patches/minecraft/net/minecraft/world/level/material/Fluid.java.patch +++ b/patches/minecraft/net/minecraft/world/level/material/Fluid.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/level/material/Fluid.java +++ b/net/minecraft/world/level/material/Fluid.java @@ -24,7 +_,7 @@ - import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.shapes.VoxelShape; + import org.jspecify.annotations.Nullable; -public abstract class Fluid { +public abstract class Fluid implements net.minecraftforge.common.extensions.IForgeFluid { @@ -17,8 +17,8 @@ + p_395108_.apply(net.minecraft.world.entity.InsideBlockEffectType.EXTINGUISH); } - @Nullable -@@ -132,5 +_,12 @@ + protected @Nullable ParticleOptions getDripParticle() { +@@ -130,5 +_,12 @@ @Deprecated public Holder.Reference builtInRegistryHolder() { return this.builtInRegistryHolder; diff --git a/patches/minecraft/net/minecraft/world/level/material/FluidState.java.patch b/patches/minecraft/net/minecraft/world/level/material/FluidState.java.patch index 20a715283c..74725d9260 100644 --- a/patches/minecraft/net/minecraft/world/level/material/FluidState.java.patch +++ b/patches/minecraft/net/minecraft/world/level/material/FluidState.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/level/material/FluidState.java +++ b/net/minecraft/world/level/material/FluidState.java @@ -25,7 +_,7 @@ - import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.shapes.VoxelShape; + import org.jspecify.annotations.Nullable; -public final class FluidState extends StateHolder { +public final class FluidState extends StateHolder implements net.minecraftforge.common.extensions.IForgeFluidState { public static final Codec CODEC = codec(BuiltInRegistries.FLUID.byNameCodec(), Fluid::defaultFluidState).stable(); public static final int AMOUNT_MAX = 9; public static final int AMOUNT_FULL = 8; -@@ -117,6 +_,7 @@ +@@ -116,6 +_,7 @@ return this.getType() == p_192918_; } 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 259109daae..520a3faf73 100644 --- a/patches/minecraft/net/minecraft/world/level/material/LavaFluid.java.patch +++ b/patches/minecraft/net/minecraft/world/level/material/LavaFluid.java.patch @@ -1,26 +1,26 @@ --- a/net/minecraft/world/level/material/LavaFluid.java +++ b/net/minecraft/world/level/material/LavaFluid.java @@ -92,7 +_,7 @@ - BlockState blockstate = p_367000_.getBlockState(blockpos); - if (blockstate.isAir()) { - if (this.hasFlammableNeighbours(p_367000_, blockpos)) { -- p_367000_.setBlockAndUpdate(blockpos, BaseFireBlock.getState(p_367000_, blockpos)); -+ p_367000_.setBlockAndUpdate(blockpos, net.minecraftforge.event.ForgeEventFactory.fireFluidPlaceBlockEvent(p_367000_, blockpos, p_230573_, Blocks.FIRE.defaultBlockState())); - return; - } - } else if (blockstate.blocksMotion()) { -@@ -106,8 +_,8 @@ + BlockState blockstate = p_367000_.getBlockState(blockpos); + if (blockstate.isAir()) { + if (this.hasFlammableNeighbours(p_367000_, blockpos)) { +- p_367000_.setBlockAndUpdate(blockpos, BaseFireBlock.getState(p_367000_, blockpos)); ++ p_367000_.setBlockAndUpdate(blockpos, net.minecraftforge.event.ForgeEventFactory.fireFluidPlaceBlockEvent(p_367000_, blockpos, p_230573_, Blocks.FIRE.defaultBlockState())); return; } + } else if (blockstate.blocksMotion()) { +@@ -106,8 +_,8 @@ + return; + } -- if (p_367000_.isEmptyBlock(blockpos1.above()) && this.isFlammable(p_367000_, blockpos1)) { -- p_367000_.setBlockAndUpdate(blockpos1.above(), BaseFireBlock.getState(p_367000_, blockpos1)); -+ if (p_367000_.isEmptyBlock(blockpos1.above()) && this.isFlammable(p_367000_, blockpos1, Direction.UP)) { -+ p_367000_.setBlockAndUpdate(blockpos1.above(), net.minecraftforge.event.ForgeEventFactory.fireFluidPlaceBlockEvent(p_367000_, blockpos1.above(), p_230573_, Blocks.FIRE.defaultBlockState())); - } +- if (p_367000_.isEmptyBlock(blockpos1.above()) && this.isFlammable(p_367000_, blockpos1)) { +- p_367000_.setBlockAndUpdate(blockpos1.above(), BaseFireBlock.getState(p_367000_, blockpos1)); ++ if (p_367000_.isEmptyBlock(blockpos1.above()) && this.isFlammable(p_367000_, blockpos1, Direction.UP)) { ++ p_367000_.setBlockAndUpdate(blockpos1.above(), net.minecraftforge.event.ForgeEventFactory.fireFluidPlaceBlockEvent(p_367000_, blockpos1.above(), p_230573_, Blocks.FIRE.defaultBlockState())); } } -@@ -124,7 +_,7 @@ + } +@@ -123,7 +_,7 @@ private boolean hasFlammableNeighbours(LevelReader p_76228_, BlockPos p_76229_) { for (Direction direction : Direction.values()) { @@ -29,7 +29,7 @@ return true; } } -@@ -132,10 +_,17 @@ +@@ -131,10 +_,17 @@ return false; } @@ -44,10 +44,10 @@ + : p_76246_.getBlockState(p_76247_).ignitedByLava() && p_76246_.getBlockState(p_76247_).isFlammable(p_76246_, p_76247_, face); + } + - @Nullable @Override - public ParticleOptions getDripParticle() { -@@ -207,7 +_,8 @@ + public @Nullable ParticleOptions getDripParticle() { + return ParticleTypes.DRIPPING_LAVA; +@@ -205,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/pathfinder/WalkNodeEvaluator.java.patch b/patches/minecraft/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java.patch index f177aedaec..b69c4f1bc6 100644 --- a/patches/minecraft/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java.patch +++ b/patches/minecraft/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java +++ b/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java -@@ -474,6 +_,16 @@ +@@ -471,6 +_,16 @@ for (int k = -1; k <= 1; k++) { if (i != 0 || k != 0) { PathType pathtype = p_334221_.getPathTypeFromState(p_336062_ + i, p_335259_ + j, p_336315_ + k); @@ -17,7 +17,7 @@ if (pathtype == PathType.DAMAGE_OTHER) { return PathType.DANGER_OTHER; } -@@ -500,6 +_,10 @@ +@@ -497,6 +_,10 @@ protected static PathType getPathTypeFromState(BlockGetter p_335222_, BlockPos p_331935_) { BlockState blockstate = p_335222_.getBlockState(p_331935_); Block block = blockstate.getBlock(); @@ -28,7 +28,7 @@ if (blockstate.isAir()) { return PathType.OPEN; } else if (blockstate.is(BlockTags.TRAPDOORS) || blockstate.is(Blocks.LILY_PAD) || blockstate.is(Blocks.BIG_DRIPLEAF)) { -@@ -514,6 +_,8 @@ +@@ -511,6 +_,8 @@ return PathType.COCOA; } else if (!blockstate.is(Blocks.WITHER_ROSE) && !blockstate.is(Blocks.POINTED_DRIPSTONE)) { FluidState fluidstate = blockstate.getFluidState(); @@ -37,7 +37,7 @@ if (fluidstate.is(FluidTags.LAVA)) { return PathType.LAVA; } else if (isBurningBlock(blockstate)) { -@@ -534,6 +_,8 @@ +@@ -531,6 +_,8 @@ if (!blockstate.isPathfindable(PathComputationType.LAND)) { return PathType.BLOCKED; } else { diff --git a/patches/minecraft/net/minecraft/world/level/storage/DimensionDataStorage.java.patch b/patches/minecraft/net/minecraft/world/level/storage/DimensionDataStorage.java.patch index 9ccc4bca23..3221b7d6e7 100644 --- a/patches/minecraft/net/minecraft/world/level/storage/DimensionDataStorage.java.patch +++ b/patches/minecraft/net/minecraft/world/level/storage/DimensionDataStorage.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/storage/DimensionDataStorage.java +++ b/net/minecraft/world/level/storage/DimensionDataStorage.java -@@ -119,6 +_,10 @@ +@@ -114,6 +_,10 @@ } int i = NbtUtils.getDataVersion(compoundtag, 1343); diff --git a/patches/minecraft/net/minecraft/world/level/storage/LevelStorageSource.java.patch b/patches/minecraft/net/minecraft/world/level/storage/LevelStorageSource.java.patch index 4d2debffd9..70a7d40342 100644 --- a/patches/minecraft/net/minecraft/world/level/storage/LevelStorageSource.java.patch +++ b/patches/minecraft/net/minecraft/world/level/storage/LevelStorageSource.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/storage/LevelStorageSource.java +++ b/net/minecraft/world/level/storage/LevelStorageSource.java -@@ -480,6 +_,11 @@ +@@ -475,6 +_,11 @@ return this.getDataTag(true); } @@ -12,7 +12,7 @@ private Dynamic getDataTag(boolean p_310699_) throws IOException { this.checkLock(); return LevelStorageSource.readLevelDataTagFixed(p_310699_ ? this.levelDirectory.oldDataFile() : this.levelDirectory.dataFile(), LevelStorageSource.this.fixerUpper); -@@ -493,6 +_,7 @@ +@@ -488,6 +_,7 @@ CompoundTag compoundtag = p_78292_.createTag(p_78291_, p_78293_); CompoundTag compoundtag1 = new CompoundTag(); compoundtag1.put("Data", compoundtag); @@ -20,7 +20,7 @@ this.saveLevelData(compoundtag1); } -@@ -512,6 +_,10 @@ +@@ -507,6 +_,10 @@ public Optional getIconFile() { return !this.lock.isValid() ? Optional.empty() : Optional.of(this.levelDirectory.iconFile()); diff --git a/patches/minecraft/net/minecraft/world/level/storage/LevelSummary.java.patch b/patches/minecraft/net/minecraft/world/level/storage/LevelSummary.java.patch index bb7d684f32..4c69b872bf 100644 --- a/patches/minecraft/net/minecraft/world/level/storage/LevelSummary.java.patch +++ b/patches/minecraft/net/minecraft/world/level/storage/LevelSummary.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/level/storage/LevelSummary.java +++ b/net/minecraft/world/level/storage/LevelSummary.java @@ -14,7 +_,7 @@ - import net.minecraft.world.level.LevelSettings; import org.apache.commons.lang3.StringUtils; + import org.jspecify.annotations.Nullable; -public class LevelSummary implements Comparable { +public class LevelSummary implements Comparable, net.minecraftforge.common.extensions.IForgeLevelSummary { public static final Component PLAY_WORLD = Component.translatable("selectWorld.select"); private final LevelSettings settings; private final LevelVersion levelVersion; -@@ -275,6 +_,12 @@ +@@ -274,6 +_,12 @@ public boolean canRecreate() { return false; } 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 00b6480c6d..2161bb9b81 100644 --- a/patches/minecraft/net/minecraft/world/level/storage/PlayerDataStorage.java.patch +++ b/patches/minecraft/net/minecraft/world/level/storage/PlayerDataStorage.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/storage/PlayerDataStorage.java +++ b/net/minecraft/world/level/storage/PlayerDataStorage.java -@@ -43,6 +_,7 @@ +@@ -41,6 +_,7 @@ Path path2 = path.resolve(p_78434_.getStringUUID() + ".dat"); Path path3 = path.resolve(p_78434_.getStringUUID() + ".dat_old"); Util.safeReplaceFile(path2, path1, path3); @@ -8,9 +8,9 @@ } catch (Exception exception) { LOGGER.warn("Failed to save player data for {}", p_78434_.getPlainTextName()); } -@@ -85,5 +_,9 @@ - int i = NbtUtils.getDataVersion(p_422259_, -1); - return DataFixTypes.PLAYER.updateToCurrentVersion(this.fixerUpper, p_422259_, i); +@@ -83,5 +_,9 @@ + int i = NbtUtils.getDataVersion(p_450065_); + return DataFixTypes.PLAYER.updateToCurrentVersion(this.fixerUpper, p_450065_, 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 16ddba3313..bfe7ef6f73 100644 --- a/patches/minecraft/net/minecraft/world/level/storage/PrimaryLevelData.java.patch +++ b/patches/minecraft/net/minecraft/world/level/storage/PrimaryLevelData.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/storage/PrimaryLevelData.java +++ b/net/minecraft/world/level/storage/PrimaryLevelData.java -@@ -73,6 +_,7 @@ +@@ -70,6 +_,7 @@ private boolean wasModded; private final Set removedFeatureFlags; private final TimerQueue scheduledEvents; @@ -8,7 +8,7 @@ private PrimaryLevelData( @Nullable CompoundTag p_277888_, -@@ -195,7 +_,7 @@ +@@ -192,7 +_,7 @@ p_251864_, p_250651_, p_78538_ @@ -17,7 +17,7 @@ } @Override -@@ -260,6 +_,8 @@ +@@ -257,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_) { -@@ -552,6 +_,16 @@ +@@ -546,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 cc91341633..509d91bd07 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 @@ -4,13 +4,13 @@ private final RandomSource random; private final HolderGetter.Provider lootDataResolver; private final Set> visitedElements = Sets.newLinkedHashSet(); -+ private ResourceLocation queriedLootTableId; ++ private Identifier queriedLootTableId; LootContext(LootParams p_287722_, RandomSource p_287702_, HolderGetter.Provider p_330439_) { + this(p_287722_, p_287702_, p_330439_, null); + } + -+ LootContext(LootParams p_287722_, RandomSource p_287702_, HolderGetter.Provider p_330439_, ResourceLocation queriedLootTableId) { ++ LootContext(LootParams p_287722_, RandomSource p_287702_, HolderGetter.Provider p_330439_, Identifier queriedLootTableId) { this.params = p_287722_; this.random = p_287702_; this.lootDataResolver = p_330439_; @@ -18,7 +18,7 @@ } public boolean hasParameter(ContextKey p_368930_) { -@@ -76,6 +_,10 @@ +@@ -75,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_); } -@@ -88,6 +_,18 @@ +@@ -87,6 +_,18 @@ return new LootContext.VisitedEntry<>(LootDataType.MODIFIER, p_279163_); } @@ -37,22 +37,22 @@ + return net.minecraftforge.common.ForgeHooks.getLootingLevel(getOptionalParameter(LootContextParams.THIS_ENTITY), getOptionalParameter(LootContextParams.ATTACKING_ENTITY), getOptionalParameter(LootContextParams.DAMAGE_SOURCE)); + } + -+ public void setQueriedLootTableId(ResourceLocation queriedLootTableId) { ++ public void setQueriedLootTableId(Identifier queriedLootTableId) { + if (this.queriedLootTableId == null && queriedLootTableId != null) this.queriedLootTableId = queriedLootTableId; + } + -+ public ResourceLocation getQueriedLootTableId() { ++ public Identifier getQueriedLootTableId() { + return this.queriedLootTableId == null ? net.minecraftforge.common.loot.LootTableIdCondition.UNKNOWN_LOOT_TABLE : this.queriedLootTableId; + } + - public static enum BlockEntityTarget implements StringRepresentable { + public static enum BlockEntityTarget implements StringRepresentable, LootContextArg.SimpleGetter { BLOCK_ENTITY("block_entity", LootContextParams.BLOCK_ENTITY); -@@ -113,11 +_,18 @@ +@@ -112,11 +_,18 @@ + public static class Builder { private final LootParams params; - @Nullable - private RandomSource random; -+ private ResourceLocation queriedLootTableId; // Forge: correctly pass around loot table ID with copy constructor + private @Nullable RandomSource random; ++ private Identifier queriedLootTableId; // Forge: correctly pass around loot table ID with copy constructor public Builder(LootParams p_287628_) { this.params = p_287628_; @@ -67,11 +67,11 @@ public LootContext.Builder withOptionalRandomSeed(long p_78966_) { if (p_78966_ != 0L) { this.random = RandomSource.create(p_78966_); -@@ -131,6 +_,11 @@ +@@ -130,6 +_,11 @@ return this; } -+ public LootContext.Builder withQueriedLootTableId(ResourceLocation queriedLootTableId) { ++ public LootContext.Builder withQueriedLootTableId(Identifier queriedLootTableId) { + this.queriedLootTableId = queriedLootTableId; + return this; + } @@ -79,7 +79,7 @@ public ServerLevel getLevel() { return this.params.getLevel(); } -@@ -139,7 +_,7 @@ +@@ -138,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/LootParams.java.patch b/patches/minecraft/net/minecraft/world/level/storage/loot/LootParams.java.patch index bae309e333..1c1ee23ac2 100644 --- a/patches/minecraft/net/minecraft/world/level/storage/loot/LootParams.java.patch +++ b/patches/minecraft/net/minecraft/world/level/storage/loot/LootParams.java.patch @@ -16,7 +16,7 @@ public ServerLevel getLevel() { return this.level; } -@@ -93,6 +_,10 @@ +@@ -92,6 +_,10 @@ public LootParams create(ContextKeySet p_367827_) { ContextMap contextmap = this.params.create(p_367827_); return new LootParams(this.level, contextmap, this.dynamicDrops, this.luck); diff --git a/patches/minecraft/net/minecraft/world/level/storage/loot/LootTable.java.patch b/patches/minecraft/net/minecraft/world/level/storage/loot/LootTable.java.patch index 8646801a50..76f70d25ed 100644 --- a/patches/minecraft/net/minecraft/world/level/storage/loot/LootTable.java.patch +++ b/patches/minecraft/net/minecraft/world/level/storage/loot/LootTable.java.patch @@ -1,16 +1,16 @@ --- a/net/minecraft/world/level/storage/loot/LootTable.java +++ b/net/minecraft/world/level/storage/loot/LootTable.java @@ -41,7 +_,7 @@ - p_327557_ -> p_327557_.group( + p_450068_ -> p_450068_.group( LootContextParamSets.CODEC.lenientOptionalFieldOf("type", DEFAULT_PARAM_SET).forGetter(p_297013_ -> p_297013_.paramSet), - ResourceLocation.CODEC.optionalFieldOf("random_sequence").forGetter(p_297014_ -> p_297014_.randomSequence), + Identifier.CODEC.optionalFieldOf("random_sequence").forGetter(p_297014_ -> p_297014_.randomSequence), - LootPool.CODEC.listOf().optionalFieldOf("pools", List.of()).forGetter(p_297012_ -> p_297012_.pools), + LootPool.CONDITIONAL_CODEC.listOf().optionalFieldOf("pools", List.of()).forGetter(p_297012_ -> p_297012_.pools), LootItemFunctions.ROOT_CODEC.listOf().optionalFieldOf("functions", List.of()).forGetter(p_297010_ -> p_297010_.functions) ) - .apply(p_327557_, LootTable::new) + .apply(p_450068_, LootTable::new) @@ -58,7 +_,7 @@ - LootTable(ContextKeySet p_365565_, Optional p_298628_, List p_298771_, List p_301234_) { + LootTable(ContextKeySet p_365565_, Optional p_298628_, List p_298771_, List p_301234_) { this.paramSet = p_365565_; this.randomSequence = p_298628_; - this.pools = p_298771_; @@ -66,15 +66,15 @@ return new LootTable.Builder(); + } + -+ private ResourceLocation lootTableId; -+ public void setLootTableId(final ResourceLocation id) { ++ private Identifier lootTableId; ++ public void setLootTableId(final Identifier id) { + if (this.lootTableId != null) { + throw new IllegalStateException("Attempted to rename loot table from '" + this.lootTableId + "' to '" + id + "': this is not supported"); + } + this.lootTableId = java.util.Objects.requireNonNull(id); + } + -+ public ResourceLocation getLootTableId() { ++ public Identifier getLootTableId() { + return this.lootTableId; + } + diff --git a/src/main/generated/data/c/tags/item/enchantables.json b/src/main/generated/data/c/tags/item/enchantables.json index f33d6e0c2d..e208f71050 100644 --- a/src/main/generated/data/c/tags/item/enchantables.json +++ b/src/main/generated/data/c/tags/item/enchantables.json @@ -3,7 +3,7 @@ "#minecraft:enchantable/armor", "#minecraft:enchantable/equippable", "#minecraft:enchantable/weapon", - "#minecraft:enchantable/sword", + "#minecraft:enchantable/sharp_weapon", "#minecraft:enchantable/mining", "#minecraft:enchantable/mining_loot", "#minecraft:enchantable/fishing", diff --git a/src/main/generated/data/minecraft/recipe/copper_spear.json b/src/main/generated/data/minecraft/recipe/copper_spear.json new file mode 100644 index 0000000000..6a3b1446a0 --- /dev/null +++ b/src/main/generated/data/minecraft/recipe/copper_spear.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_spear" + } +} \ No newline at end of file diff --git a/src/main/generated/data/minecraft/recipe/diamond_spear.json b/src/main/generated/data/minecraft/recipe/diamond_spear.json new file mode 100644 index 0000000000..38d7aa9389 --- /dev/null +++ b/src/main/generated/data/minecraft/recipe/diamond_spear.json @@ -0,0 +1,17 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "equipment", + "key": { + "#": "#c:rods/wooden", + "X": "#minecraft:diamond_tool_materials" + }, + "pattern": [ + " X", + " # ", + "# " + ], + "result": { + "count": 1, + "id": "minecraft:diamond_spear" + } +} \ No newline at end of file diff --git a/src/main/generated/data/minecraft/recipe/golden_spear.json b/src/main/generated/data/minecraft/recipe/golden_spear.json new file mode 100644 index 0000000000..477bbb3f6b --- /dev/null +++ b/src/main/generated/data/minecraft/recipe/golden_spear.json @@ -0,0 +1,17 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "equipment", + "key": { + "#": "#c:rods/wooden", + "X": "#minecraft:gold_tool_materials" + }, + "pattern": [ + " X", + " # ", + "# " + ], + "result": { + "count": 1, + "id": "minecraft:golden_spear" + } +} \ No newline at end of file diff --git a/src/main/generated/data/minecraft/recipe/iron_spear.json b/src/main/generated/data/minecraft/recipe/iron_spear.json new file mode 100644 index 0000000000..eca0174318 --- /dev/null +++ b/src/main/generated/data/minecraft/recipe/iron_spear.json @@ -0,0 +1,17 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "equipment", + "key": { + "#": "#c:rods/wooden", + "X": "#minecraft:iron_tool_materials" + }, + "pattern": [ + " X", + " # ", + "# " + ], + "result": { + "count": 1, + "id": "minecraft:iron_spear" + } +} \ No newline at end of file diff --git a/src/main/generated/data/minecraft/recipe/stone_spear.json b/src/main/generated/data/minecraft/recipe/stone_spear.json new file mode 100644 index 0000000000..c0f703f53d --- /dev/null +++ b/src/main/generated/data/minecraft/recipe/stone_spear.json @@ -0,0 +1,17 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "equipment", + "key": { + "#": "#c:rods/wooden", + "X": "#minecraft:stone_tool_materials" + }, + "pattern": [ + " X", + " # ", + "# " + ], + "result": { + "count": 1, + "id": "minecraft:stone_spear" + } +} \ No newline at end of file diff --git a/src/main/generated/data/minecraft/recipe/wooden_spear.json b/src/main/generated/data/minecraft/recipe/wooden_spear.json new file mode 100644 index 0000000000..6c9f4220e0 --- /dev/null +++ b/src/main/generated/data/minecraft/recipe/wooden_spear.json @@ -0,0 +1,17 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "equipment", + "key": { + "#": "#c:rods/wooden", + "X": "#minecraft:wooden_tool_materials" + }, + "pattern": [ + " X", + " # ", + "# " + ], + "result": { + "count": 1, + "id": "minecraft:wooden_spear" + } +} \ No newline at end of file diff --git a/src/main/generated/pack.mcmeta b/src/main/generated/pack.mcmeta index e8b22b0669..bd6dcb1db5 100644 --- a/src/main/generated/pack.mcmeta +++ b/src/main/generated/pack.mcmeta @@ -3,7 +3,10 @@ "description": { "translate": "pack.forge.description" }, - "max_format": 88, - "min_format": 88 + "max_format": 94, + "min_format": [ + 94, + 1 + ] } } \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/client/ClientCommandHandler.java b/src/main/java/net/minecraftforge/client/ClientCommandHandler.java index c050557b77..b08f53de82 100644 --- a/src/main/java/net/minecraftforge/client/ClientCommandHandler.java +++ b/src/main/java/net/minecraftforge/client/ClientCommandHandler.java @@ -129,7 +129,7 @@ public class ClientCommandHandler { }, player.position(), player.getRotationVector(), - player.getPermissionLevel(), + player.permissions(), player.getName().getString(), player.getDisplayName(), player diff --git a/src/main/java/net/minecraftforge/client/ClientCommandSourceStack.java b/src/main/java/net/minecraftforge/client/ClientCommandSourceStack.java index 800230c7c2..12961b964a 100644 --- a/src/main/java/net/minecraftforge/client/ClientCommandSourceStack.java +++ b/src/main/java/net/minecraftforge/client/ClientCommandSourceStack.java @@ -12,9 +12,10 @@ import net.minecraft.commands.CommandSourceStack; import net.minecraft.core.RegistryAccess; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerLevel; +import net.minecraft.server.permissions.PermissionSet; import net.minecraft.world.entity.Entity; import net.minecraft.world.level.Level; import net.minecraft.world.phys.Vec2; @@ -30,7 +31,7 @@ import java.util.stream.Collectors; * overrides for {@link CommandSourceStack} so that the methods will run successfully client side */ public class ClientCommandSourceStack extends CommandSourceStack { - public ClientCommandSourceStack(CommandSource source, Vec3 position, Vec2 rotation, int permission, String plainTextName, Component displayName, Entity executing) { + public ClientCommandSourceStack(CommandSource source, Vec3 position, Vec2 rotation, PermissionSet permission, String plainTextName, Component displayName, Entity executing) { super(source, position, rotation, null, permission, plainTextName, displayName, null, executing); } @@ -89,7 +90,7 @@ public class ClientCommandSourceStack extends CommandSourceStack { * {@return the advancement from the id from the client side where the advancement needs to be visible to the player} */ @Override - public AdvancementHolder getAdvancement(ResourceLocation id) { + public AdvancementHolder getAdvancement(Identifier id) { return Minecraft.getInstance().getConnection().getAdvancements().get(id); } diff --git a/src/main/java/net/minecraftforge/client/ClientForgeMod.java b/src/main/java/net/minecraftforge/client/ClientForgeMod.java index a05658496c..8f5239dec8 100644 --- a/src/main/java/net/minecraftforge/client/ClientForgeMod.java +++ b/src/main/java/net/minecraftforge/client/ClientForgeMod.java @@ -7,7 +7,7 @@ package net.minecraftforge.client; import net.minecraft.client.renderer.chunk.ChunkSectionLayer; import net.minecraft.client.resources.model.UnbakedGeometry; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.client.event.ModelEvent; import net.minecraftforge.client.event.RegisterClientReloadListenersEvent; @@ -38,7 +38,7 @@ public class ClientForgeMod { event.register(forgeRL("item_unlit"), ChunkSectionLayer.TRANSLUCENT, ForgeRenderTypes.ITEM_UNSORTED_UNLIT_TRANSLUCENT.get()); } - private static ResourceLocation forgeRL(String path) { - return ResourceLocation.fromNamespaceAndPath("forge", path); + private static Identifier forgeRL(String path) { + return Identifier.fromNamespaceAndPath("forge", path); } } diff --git a/src/main/java/net/minecraftforge/client/DimensionSpecialEffectsManager.java b/src/main/java/net/minecraftforge/client/DimensionSpecialEffectsManager.java deleted file mode 100644 index 28f887b7a3..0000000000 --- a/src/main/java/net/minecraftforge/client/DimensionSpecialEffectsManager.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) Forge Development LLC and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.minecraftforge.client; - -import net.minecraft.client.renderer.DimensionSpecialEffects; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.level.dimension.BuiltinDimensionTypes; -import net.minecraftforge.client.event.RegisterDimensionSpecialEffectsEvent; -import org.jetbrains.annotations.ApiStatus; - -import java.util.HashMap; -import java.util.Map; - -/** - * Manager for {@link DimensionSpecialEffects} instances. - *

- * Provides a lookup by dimension type. - */ -public final class DimensionSpecialEffectsManager { - private DimensionSpecialEffectsManager() {} - - private static Map EFFECTS; - private static DimensionSpecialEffects DEFAULT_EFFECTS; - - /** - * Finds the {@link DimensionSpecialEffects} for a given dimension type, or the default if none is registered. - */ - public static DimensionSpecialEffects getForType(ResourceLocation type) { - return EFFECTS.getOrDefault(type, DEFAULT_EFFECTS); - } - - @ApiStatus.Internal - public static void init() { - var effects = new HashMap(); - DEFAULT_EFFECTS = preRegisterVanillaEffects(effects); - var event = new RegisterDimensionSpecialEffectsEvent(effects); - RegisterDimensionSpecialEffectsEvent.BUS.post(event); - EFFECTS = Map.copyOf(effects); - } - - /** - * Pre-registers vanilla dimension effects and returns the default fallback effects instance. - *

- * Borrowed from {@link DimensionSpecialEffects#EFFECTS}. - */ - private static DimensionSpecialEffects preRegisterVanillaEffects(Map effects) { - var overworldEffects = new DimensionSpecialEffects.OverworldEffects(); - effects.put(BuiltinDimensionTypes.OVERWORLD_EFFECTS, overworldEffects); - effects.put(BuiltinDimensionTypes.NETHER_EFFECTS, new DimensionSpecialEffects.NetherEffects()); - effects.put(BuiltinDimensionTypes.END_EFFECTS, new DimensionSpecialEffects.EndEffects()); - return overworldEffects; - } -} diff --git a/src/main/java/net/minecraftforge/client/EntitySpectatorShaderManager.java b/src/main/java/net/minecraftforge/client/EntitySpectatorShaderManager.java index 4380674df1..1907edfd68 100644 --- a/src/main/java/net/minecraftforge/client/EntitySpectatorShaderManager.java +++ b/src/main/java/net/minecraftforge/client/EntitySpectatorShaderManager.java @@ -5,7 +5,7 @@ package net.minecraftforge.client; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.world.entity.EntityType; import net.minecraftforge.client.event.RegisterEntitySpectatorShadersEvent; import org.jetbrains.annotations.ApiStatus; @@ -24,19 +24,19 @@ import java.util.Map; public final class EntitySpectatorShaderManager { private EntitySpectatorShaderManager() {} - private static @Nullable Map, ResourceLocation> SHADERS; + private static @Nullable Map, Identifier> SHADERS; /** * Finds the path to the spectator mode shader used for the specified entity type, or null if none is registered. */ - public static @Nullable ResourceLocation get(EntityType entityType) { + public static @Nullable Identifier get(EntityType entityType) { assert SHADERS != null; return SHADERS.get(entityType); } @ApiStatus.Internal public static void init() { - var shaders = new HashMap, ResourceLocation>(); + var shaders = new HashMap, Identifier>(); RegisterEntitySpectatorShadersEvent.BUS.post(new RegisterEntitySpectatorShadersEvent(shaders)); 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 8a5ed900ff..93f6bd7fb6 100644 --- a/src/main/java/net/minecraftforge/client/ForgeHooksClient.java +++ b/src/main/java/net/minecraftforge/client/ForgeHooksClient.java @@ -16,7 +16,7 @@ import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.datafixers.util.Either; import com.mojang.math.Transformation; -import net.minecraft.FileUtil; +import net.minecraft.util.FileUtil; import net.minecraft.client.Camera; import net.minecraft.client.DeltaTracker; import net.minecraft.client.Minecraft; @@ -51,6 +51,7 @@ 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.block.model.BlockModelPart; import net.minecraft.client.renderer.chunk.ChunkSectionLayer; import net.minecraft.client.renderer.entity.state.HumanoidRenderState; import net.minecraft.client.renderer.fog.FogData; @@ -77,7 +78,7 @@ import net.minecraft.network.chat.Component; 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.resources.Identifier; import net.minecraft.server.packs.metadata.MetadataSectionType; import net.minecraft.server.packs.resources.ReloadableResourceManager; import net.minecraft.server.packs.resources.Resource; @@ -183,7 +184,7 @@ public class ForgeHooksClient { private static final Logger LOGGER = LogManager.getLogger(); private static final Marker CLIENTHOOKS = MarkerManager.getMarker("CLIENTHOOKS"); - //private static final ResourceLocation ITEM_GLINT = new ResourceLocation("textures/misc/enchanted_item_glint.png"); + //private static final Identifier ITEM_GLINT = new Identifier("textures/misc/enchanted_item_glint.png"); /** * Contains the *extra* GUI layers. @@ -192,7 +193,7 @@ public class ForgeHooksClient { private static final Stack guiLayers = new Stack<>(); public static void resizeGuiLayers(Minecraft minecraft, int width, int height) { - guiLayers.forEach(screen -> screen.resize(minecraft, width, height)); + guiLayers.forEach(screen -> screen.resize(width, height)); } public static void clearGuiLayers(Minecraft minecraft) { @@ -210,7 +211,7 @@ public class ForgeHooksClient { if (minecraft.screen != null) guiLayers.push(minecraft.screen); minecraft.screen = Objects.requireNonNull(screen); - screen.init(minecraft, minecraft.getWindow().getGuiScaledWidth(), minecraft.getWindow().getGuiScaledHeight()); + screen.init(minecraft.getWindow().getGuiScaledWidth(), minecraft.getWindow().getGuiScaledHeight()); minecraft.getNarrator().saySystemNow(screen.getNarrationMessage()); } @@ -241,7 +242,7 @@ public class ForgeHooksClient { } /* - public static ResourceLocation getArmorTexture(Entity entity, ItemStack armor, EquipmentSlot slot, ArmorMaterial.Layer layer, boolean inner) { + public static Identifier getArmorTexture(Entity entity, ItemStack armor, EquipmentSlot slot, ArmorMaterial.Layer layer, boolean inner) { var result = armor.getItem().getArmorTexture(armor, entity, slot, layer, inner); return result != null ? result : layer.texture(inner); } @@ -337,9 +338,9 @@ public class ForgeHooksClient { public static Vector3f getFogColor(Camera camera, float partialTick, ClientLevel level, int renderDistance, float darkenWorldAmount, float fogRed, float fogGreen, float fogBlue) { // Modify fog color depending on the fluid - FluidState state = level.getFluidState(camera.getBlockPosition()); + FluidState state = level.getFluidState(camera.blockPosition()); Vector3f fluidFogColor = new Vector3f(fogRed, fogGreen, fogBlue); - if (camera.getPosition().y < (double)((float)camera.getBlockPosition().getY() + state.getHeight(level, camera.getBlockPosition()))) + if (camera.position().y < (double)((float)camera.blockPosition().getY() + state.getHeight(level, camera.blockPosition()))) fluidFogColor = IClientFluidTypeExtensions.of(state).modifyFogColor(camera, partialTick, level, renderDistance, darkenWorldAmount, fluidFogColor); var event = ViewportEvent.ComputeFogColor.BUS.fire(new ViewportEvent.ComputeFogColor(camera, partialTick, fluidFogColor.x(), fluidFogColor.y(), fluidFogColor.z())); @@ -350,8 +351,8 @@ public class ForgeHooksClient { public static Vector4f setupFog(FogType type, Camera camera, DeltaTracker delta, FogData data, Vector4f color) { // Modify fog rendering depending on the fluid - FluidState state = camera.getEntity().level().getFluidState(camera.getBlockPosition()); - if (camera.getPosition().y < (double)((float)camera.getBlockPosition().getY() + state.getHeight(camera.getEntity().level(), camera.getBlockPosition()))) + FluidState state = camera.entity().level().getFluidState(camera.blockPosition()); + if (camera.position().y < (double)((float)camera.blockPosition().getY() + state.getHeight(camera.entity().level(), camera.blockPosition()))) IClientFluidTypeExtensions.of(state).modifyFogRender(camera, type, delta.getRealtimeDeltaTicks(), data, color); ViewportEvent.RenderFog.BUS.post(new ViewportEvent.RenderFog(type, camera, delta.getRealtimeDeltaTicks(), data, color)); @@ -368,7 +369,7 @@ public class ForgeHooksClient { public static TextureAtlasSprite[] getFluidSprites(BlockAndTintGetter level, BlockPos pos, FluidState fluidStateIn) { IClientFluidTypeExtensions props = IClientFluidTypeExtensions.of(fluidStateIn); - ResourceLocation overlayTexture = props.getOverlayTexture(fluidStateIn, level, pos); + Identifier overlayTexture = props.getOverlayTexture(fluidStateIn, level, pos); var atlas = Minecraft.getInstance().getAtlasManager().getAtlasOrThrow(AtlasIds.BLOCKS); return new TextureAtlasSprite[] { atlas.getSprite(props.getStillTexture(fluidStateIn, level, pos)), @@ -400,14 +401,14 @@ public class ForgeHooksClient { return CustomizeGuiOverlayEvent.BossEventProgress.BUS.post(evt) ? null : evt; } - public static void onCustomizeChatEvent(GuiGraphics guiGraphics, ChatComponent chat, Window window, int mouseX, int mouseY, int tickCount) { + public static void onCustomizeChatEvent(GuiGraphics guiGraphics, ChatComponent chat, Window window, int mouseX, int mouseY, int tickCount, Font font) { var minecraft = Minecraft.getInstance(); var evt = new CustomizeGuiOverlayEvent.Chat(window, guiGraphics, minecraft.getDeltaTracker().getRealtimeDeltaTicks(), 0, chat.getHeight() - 40); CustomizeGuiOverlayEvent.Chat.BUS.post(evt); guiGraphics.pose().pushMatrix(); // We give the absolute Y position of the chat component in the event and account for the chat component's own offsetting here. guiGraphics.pose().translate(evt.getPosX(), (float) ((evt.getPosY() - chat.getHeight() + 40) / chat.getScale())); - chat.render(guiGraphics, tickCount, mouseX, mouseY, false); + chat.render(guiGraphics, font, tickCount, mouseX, mouseY, false, false); guiGraphics.pose().popMatrix(); } @@ -463,7 +464,7 @@ public class ForgeHooksClient { return IClientMobEffectExtensions.of(effectInstance).isVisibleInInventory(effectInstance); } - public static Set> getAtlastMetadataSections(ResourceLocation atlasId, Set> vanilla) { + public static Set> getAtlastMetadataSections(Identifier atlasId, Set> vanilla) { var ret = new HashSet<>(vanilla); ret.add(ForgeTextureMetadata.TYPE); @@ -473,7 +474,7 @@ public class ForgeHooksClient { } @Nullable - public static SpriteContents loadSpriteContents(ResourceLocation name, Resource resource, FrameSize frameSize, NativeImage image, List> metadata) { + public static SpriteContents loadSpriteContents(Identifier 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) @@ -483,12 +484,12 @@ public class ForgeHooksClient { } @Nullable - public static TextureAtlasSprite loadTextureAtlasSprite(ResourceLocation atlasName, SpriteContents contents, int atlasWidth, int atlasHeight, int spriteX, int spriteY, int mipmapLevel) { + public static TextureAtlasSprite loadTextureAtlasSprite(Identifier atlasName, SpriteContents contents, int atlasWidth, int atlasHeight, int spriteX, int spriteY, int padding, int mipmapLevel) { var forgeMeta = contents.getAdditionalMetadata(ForgeTextureMetadata.TYPE).orElse(null); if (forgeMeta == null || forgeMeta.loader() == null) return null; - return forgeMeta.loader().makeSprite(atlasName, contents, atlasWidth, atlasHeight, spriteX, spriteY, mipmapLevel); + return forgeMeta.loader().makeSprite(atlasName, contents, atlasWidth, atlasHeight, spriteX, spriteY, padding, mipmapLevel); } private static final Map> layerDefinitions = new HashMap<>(); @@ -506,7 +507,7 @@ public class ForgeHooksClient { public static void processForgeListPingData(ServerStatus packet, ServerData target) { packet.forgeData().ifPresentOrElse(forgeData -> { final Map mods = forgeData.getRemoteModData(); - final Map remoteChannels = forgeData.getRemoteChannels(); + final Map remoteChannels = forgeData.getRemoteChannels(); final int fmlver = forgeData.getFMLNetworkVersion(); int wantedVer = NetworkInitialization.getVersion(); @@ -556,7 +557,7 @@ public class ForgeHooksClient { }, () -> target.forgeData = new ExtendedServerListData("VANILLA", NetworkRegistry.canConnectToVanillaServer(),0, null)); } - private static final ResourceLocation ICON_SHEET = ResourceLocation.fromNamespaceAndPath(ForgeVersion.MOD_ID, "textures/gui/icons.png"); + private static final Identifier ICON_SHEET = Identifier.fromNamespaceAndPath(ForgeVersion.MOD_ID, "textures/gui/icons.png"); public static void drawForgePingInfo(JoinMultiplayerScreen gui, ServerData target, GuiGraphics guiGraphics, int x, int y, int width, int relativeMouseX, int relativeMouseY) { int idx; String tooltip; @@ -658,7 +659,7 @@ public class ForgeHooksClient { return stackFont == null ? fallbackFont : stackFont; } - public static @Nullable RenderTooltipEvent.Pre onRenderTooltipPre(@NotNull ItemStack stack, GuiGraphics graphics, int x, int y, int screenWidth, int screenHeight, @NotNull List components, @NotNull Font fallbackFont, @NotNull ClientTooltipPositioner positioner, @Nullable ResourceLocation background) { + public static @Nullable RenderTooltipEvent.Pre onRenderTooltipPre(@NotNull ItemStack stack, GuiGraphics graphics, int x, int y, int screenWidth, int screenHeight, @NotNull List components, @NotNull Font fallbackFont, @NotNull ClientTooltipPositioner positioner, @Nullable Identifier background) { var preEvent = new RenderTooltipEvent.Pre(stack, graphics, x, y, screenWidth, screenHeight, getTooltipFont(stack, fallbackFont), components, positioner, background); return RenderTooltipEvent.Pre.BUS.post(preEvent) ? null : preEvent; } @@ -769,8 +770,8 @@ public class ForgeHooksClient { ); } - public static ResourceLocation getShaderImportLocation(String basePath, boolean isRelative, String importPath) { - final var loc = ResourceLocation.parse(importPath); + public static Identifier getShaderImportLocation(String basePath, boolean isRelative, String importPath) { + final var loc = Identifier.parse(importPath); final var normalised = FileUtil.normalizeResourcePath( (isRelative ? basePath : "shaders/include/") + loc.getPath()); return loc.withPath(normalised); @@ -793,7 +794,7 @@ public class ForgeHooksClient { EntitySpectatorShaderManager.init(); ForgeHooksClient.onRegisterKeyMappings(mc.options); //GuiOverlayManager.init(); - DimensionSpecialEffectsManager.init(); + //DimensionSpecialEffectsManager.init(); NamedRenderTypeManager.init(); ColorResolverManager.init(); ItemDecoratorHandler.init(); @@ -819,7 +820,7 @@ public class ForgeHooksClient { if (name == null) return null; - var loader = GeometryLoaderManager.get(ResourceLocation.parse(name)); + var loader = GeometryLoaderManager.get(Identifier.parse(name)); if (loader == null) throw new JsonParseException(String.format(Locale.ENGLISH, "Model loader '%s' not found. Registered loaders: %s", name, GeometryLoaderManager.getLoaderList())); @@ -829,19 +830,19 @@ public class ForgeHooksClient { @Nullable public static ForgeBlockModelData deserializeBlockModel(JsonObject json, JsonDeserializationContext context) { - Optional renderType = Optional.empty(); - Optional renderTypeFast = Optional.empty(); + Optional renderType = Optional.empty(); + Optional renderTypeFast = Optional.empty(); Optional> visibility = Optional.empty(); var transform = Optional.ofNullable(GsonHelper.getAsObject(json, "transform", null, context, Transformation.class)); var renderTypeName = GsonHelper.getAsString(json, "render_type", null); if (renderTypeName != null) - renderType = Optional.of(ResourceLocation.parse(renderTypeName)); + renderType = Optional.of(Identifier.parse(renderTypeName)); var renderTypeFastName = GsonHelper.getAsString(json, "render_type_fast", null); if (renderTypeFastName != null) - renderTypeFast = Optional.of(ResourceLocation.parse(renderTypeFastName)); + renderTypeFast = Optional.of(Identifier.parse(renderTypeFastName)); var visibilityJson = GsonHelper.getAsJsonObject(json, "visibility", null); if (visibilityJson != null) { @@ -878,7 +879,7 @@ public class ForgeHooksClient { return group; } - @Override public ResolvedModel getModel(ResourceLocation p_397309_) { + @Override public ResolvedModel getModel(Identifier p_397309_) { return parent.getModel(p_397309_); } @@ -891,9 +892,19 @@ public class ForgeHooksClient { public T compute(SharedOperationKey p_395456_) { return parent.compute(p_395456_); } + + @Override + public BlockModelPart missingBlockModelPart() { + return parent.missingBlockModelPart(); + } + + @Override + public PartCache parts() { + return parent.parts(); + } } - public static void addFramePass(ResourceLocation rl, FramePassManager.PassDefinition definition) { + public static void addFramePass(Identifier rl, FramePassManager.PassDefinition definition) { FramePassManager.addPass(rl, definition); } } diff --git a/src/main/java/net/minecraftforge/client/ForgeRenderTypes.java b/src/main/java/net/minecraftforge/client/ForgeRenderTypes.java index a066863049..71da1042df 100644 --- a/src/main/java/net/minecraftforge/client/ForgeRenderTypes.java +++ b/src/main/java/net/minecraftforge/client/ForgeRenderTypes.java @@ -5,34 +5,29 @@ package net.minecraftforge.client; -import com.mojang.blaze3d.opengl.GlConst; import com.mojang.blaze3d.pipeline.BlendFunction; import com.mojang.blaze3d.pipeline.RenderPipeline; import com.mojang.blaze3d.platform.DepthTestFunction; import com.mojang.blaze3d.platform.DestFactor; import com.mojang.blaze3d.platform.SourceFactor; -import com.mojang.blaze3d.systems.GpuDevice; import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.textures.GpuTexture; -import com.mojang.blaze3d.textures.GpuTextureView; +import com.mojang.blaze3d.textures.AddressMode; +import com.mojang.blaze3d.textures.FilterMode; +import com.mojang.blaze3d.textures.GpuSampler; import com.mojang.blaze3d.textures.TextureFormat; -import net.minecraft.Util; -import net.minecraft.client.Minecraft; +import net.minecraft.util.Util; import net.minecraft.client.renderer.RenderPipelines; -import net.minecraft.client.renderer.RenderStateShard.TextureStateShard; -import net.minecraft.client.renderer.RenderType; - +import net.minecraft.client.renderer.rendertype.RenderSetup; +import net.minecraft.client.renderer.rendertype.RenderType; import net.minecraft.client.renderer.texture.TextureAtlas; -import net.minecraft.client.renderer.texture.TextureManager; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraftforge.common.util.NonNullLazy; import net.minecraftforge.common.util.NonNullSupplier; import net.minecraftforge.fml.earlydisplay.DisplayWindow; import java.util.function.Function; import org.jetbrains.annotations.ApiStatus; -import org.lwjgl.opengl.GL30C; public enum ForgeRenderTypes { ITEM_LAYERED_SOLID(()-> getItemLayeredSolid(blockAtlas())), @@ -56,42 +51,42 @@ public enum ForgeRenderTypes { public static boolean enableTextTextureLinearFiltering = false; @SuppressWarnings("deprecation") - private static ResourceLocation blockAtlas() { + private static Identifier blockAtlas() { return TextureAtlas.LOCATION_BLOCKS; } /** * @return A RenderType fit for multi-layer solid item rendering. */ - public static RenderType getItemLayeredSolid(ResourceLocation textureLocation) { + public static RenderType getItemLayeredSolid(Identifier textureLocation) { return Internal.LAYERED_ITEM_SOLID.apply(textureLocation); } /** * @return A RenderType fit for multi-layer cutout item item rendering. */ - public static RenderType getItemLayeredCutout(ResourceLocation textureLocation) { + public static RenderType getItemLayeredCutout(Identifier textureLocation) { return Internal.LAYERED_ITEM_CUTOUT.apply(textureLocation); } /** * @return A RenderType fit for multi-layer cutout-mipped item rendering. */ - public static RenderType getItemLayeredCutoutMipped(ResourceLocation textureLocation) { + public static RenderType getItemLayeredCutoutMipped(Identifier textureLocation) { return Internal.LAYERED_ITEM_CUTOUT_MIPPED.apply(textureLocation); } /** * @return A RenderType fit for multi-layer translucent item rendering. */ - public static RenderType getItemLayeredTranslucent(ResourceLocation textureLocation) { + public static RenderType getItemLayeredTranslucent(Identifier textureLocation) { return Internal.LAYERED_ITEM_TRANSLUCENT.apply(textureLocation); } /** * @return A RenderType fit for translucent item/entity rendering, but with depth sorting disabled. */ - public static RenderType getUnsortedTranslucent(ResourceLocation textureLocation) { + public static RenderType getUnsortedTranslucent(Identifier textureLocation) { return Internal.UNSORTED_TRANSLUCENT.apply(textureLocation); } @@ -99,7 +94,7 @@ public enum ForgeRenderTypes { * @return A RenderType fit for translucent item/entity rendering, but with diffuse lighting disabled * so that fullbright quads look correct. */ - public static RenderType getUnlitTranslucent(ResourceLocation textureLocation) { + public static RenderType getUnlitTranslucent(Identifier textureLocation) { return Internal.UNLIT_TRANSLUCENT_SORTED.apply(textureLocation); } @@ -108,68 +103,68 @@ public enum ForgeRenderTypes { * so that fullbright quads look correct. * @param sortingEnabled If false, depth sorting will not be performed. */ - public static RenderType getUnlitTranslucent(ResourceLocation textureLocation, boolean sortingEnabled) { + public static RenderType getUnlitTranslucent(Identifier textureLocation, boolean sortingEnabled) { return (sortingEnabled ? Internal.UNLIT_TRANSLUCENT_SORTED : Internal.UNLIT_TRANSLUCENT_UNSORTED).apply(textureLocation); } /** - * @return Same as {@link RenderType#entityCutout(ResourceLocation)}, but with mipmapping enabled. + * @return Same as {@link RenderType#entityCutout(Identifier)}, but with mipmapping enabled. */ - public static RenderType getEntityCutoutMipped(ResourceLocation textureLocation) { + public static RenderType getEntityCutoutMipped(Identifier textureLocation) { return Internal.LAYERED_ITEM_CUTOUT_MIPPED.apply(textureLocation); } /** * @see #enableTextTextureLinearFiltering * - * @return Replacement of {@link RenderType#text(ResourceLocation)}, but with optional linear texture filtering. + * @return Replacement of {@link RenderType#text(Identifier)}, but with optional linear texture filtering. */ - public static RenderType getText(ResourceLocation locationIn) { + public static RenderType getText(Identifier locationIn) { return Internal.TEXT.apply(locationIn); } /** * @see #enableTextTextureLinearFiltering * - * @return Replacement of {@link RenderType#textIntensity(ResourceLocation)}, but with optional linear texture filtering. + * @return Replacement of {@link RenderType#textIntensity(Identifier)}, but with optional linear texture filtering. */ - public static RenderType getTextIntensity(ResourceLocation locationIn) { + public static RenderType getTextIntensity(Identifier locationIn) { return Internal.TEXT_INTENSITY.apply(locationIn); } /** * @see #enableTextTextureLinearFiltering * - * @return Replacement of {@link RenderType#textPolygonOffset(ResourceLocation)}, but with optional linear texture filtering. + * @return Replacement of {@link RenderType#textPolygonOffset(Identifier)}, but with optional linear texture filtering. */ - public static RenderType getTextPolygonOffset(ResourceLocation locationIn) { + public static RenderType getTextPolygonOffset(Identifier locationIn) { return Internal.TEXT_POLYGON_OFFSET.apply(locationIn); } /** * @see #enableTextTextureLinearFiltering * - * @return Replacement of {@link RenderType#textIntensityPolygonOffset(ResourceLocation)}, but with optional linear texture filtering. + * @return Replacement of {@link RenderType#textIntensityPolygonOffset(Identifier)}, but with optional linear texture filtering. */ - public static RenderType getTextIntensityPolygonOffset(ResourceLocation locationIn) { + public static RenderType getTextIntensityPolygonOffset(Identifier locationIn) { return Internal.TEXT_INTENSITY_POLYGON_OFFSET.apply(locationIn); } /** * @see #enableTextTextureLinearFiltering * - * @return Replacement of {@link RenderType#textSeeThrough(ResourceLocation)}, but with optional linear texture filtering. + * @return Replacement of {@link RenderType#textSeeThrough(Identifier)}, but with optional linear texture filtering. */ - public static RenderType getTextSeeThrough(ResourceLocation locationIn) { - return Internal.TEXT_SEETHROUGH.apply(locationIn); + public static RenderType getTextSeeThrough(Identifier locationIn) { + return Internal.TEXT_SEE_THROUGH.apply(locationIn); } /** * @see #enableTextTextureLinearFiltering * - * @return Replacement of {@link RenderType#textIntensitySeeThrough(ResourceLocation)}, but with optional linear texture filtering. + * @return Replacement of {@link RenderType#textIntensitySeeThrough(Identifier)}, but with optional linear texture filtering. */ - public static RenderType getTextIntensitySeeThrough(ResourceLocation locationIn) { + public static RenderType getTextIntensitySeeThrough(Identifier locationIn) { return Internal.TEXT_INTENSITY_SEE_THROUGH.apply(locationIn); } @@ -202,217 +197,175 @@ public enum ForgeRenderTypes { // This was done for the sake of consistency, but it may be wrong. Need validation. // Additionally, I am unsure if I have set all the flags correctly. Most of these don't have full docs on // what they are meant to be used for, so I had to guess how to remap them to the new system. - private static abstract class Internal extends RenderType { - // TODO: [VEN] This is really just here because argument names are stripped I guess? Just as a weird doc thing? - private Internal(String name, int bufferSize, boolean affectsCrumbling, boolean sortOnUpload, Runnable setupState, Runnable clearState) { - super(name, bufferSize, affectsCrumbling, sortOnUpload, setupState, clearState); - throw new IllegalStateException("This class must not be instantiated"); - } - - public static Function UNSORTED_TRANSLUCENT = Util.memoize(Internal::unsortedTranslucent); - private static RenderType unsortedTranslucent(ResourceLocation textureLocation) { - return create("forge_unsorted_translucent", - TRANSIENT_BUFFER_SIZE, - true, - false, - RenderPipelines.ENTITY_TRANSLUCENT, - CompositeState.builder() - .setTextureState(new TextureStateShard(textureLocation, false)) - .setLightmapState(LIGHTMAP) - .setOverlayState(OVERLAY) - .createCompositeState(true)); - } - - public static Function UNLIT_TRANSLUCENT_SORTED = Util.memoize(Internal::unlitTranslucentSorted); - private static RenderType unlitTranslucentSorted(ResourceLocation textureLocation) { - return create("forge_unlit_translucent_sorted", - TRANSIENT_BUFFER_SIZE, - true, - true, - RenderPipelines.ENTITY_TRANSLUCENT, - CompositeState.builder() - .setTextureState(new TextureStateShard(textureLocation, false)) - .setLightmapState(NO_LIGHTMAP) - .setOverlayState(OVERLAY) - .createCompositeState(true)); - } - - public static Function UNLIT_TRANSLUCENT_UNSORTED = Util.memoize(Internal::unlitTranslucentUnsorted); - private static RenderType unlitTranslucentUnsorted(ResourceLocation textureLocation) { - return create("forge_unlit_translucent_sorted", - TRANSIENT_BUFFER_SIZE, - true, - false, - RenderPipelines.ENTITY_TRANSLUCENT, - CompositeState.builder() - .setTextureState(new TextureStateShard(textureLocation, false)) - .setLightmapState(NO_LIGHTMAP) - .setOverlayState(OVERLAY) - .createCompositeState(true)); - } - - public static Function LAYERED_ITEM_SOLID = Util.memoize(Internal::layeredItemSolid); - private static RenderType layeredItemSolid(ResourceLocation locationIn) { - return create( - "forge_layered_item_soild", - TRANSIENT_BUFFER_SIZE, - true, - false, - RenderPipelines.ENTITY_SOLID, - CompositeState.builder() - .setTextureState(new TextureStateShard(locationIn, false)) - .setLightmapState(LIGHTMAP) - .setOverlayState(OVERLAY) - .createCompositeState(true) + private static abstract class Internal { + public static Function UNSORTED_TRANSLUCENT = Util.memoize(Internal::unsortedTranslucent); + private static RenderType unsortedTranslucent(Identifier texture) { + return RenderType.create("forge_unsorted_translucent", + RenderSetup.builder(RenderPipelines.ENTITY_TRANSLUCENT) + .bufferSize(RenderType.TRANSIENT_BUFFER_SIZE) + .withTexture("Sampler0", texture) + .bufferSize(RenderType.TRANSIENT_BUFFER_SIZE) + .affectsCrumbling() + .useLightmap() + .useOverlay() + .setOutline(RenderSetup.OutlineProperty.AFFECTS_OUTLINE) + .createRenderSetup() ); } - public static Function LAYERED_ITEM_CUTOUT = Util.memoize(Internal::layeredItemCutout); - private static RenderType layeredItemCutout(ResourceLocation locationIn) { - return create( - "forge_layered_item_cutout", - TRANSIENT_BUFFER_SIZE, - true, - false, - RenderPipelines.ENTITY_CUTOUT, - CompositeState.builder() - .setTextureState(new TextureStateShard(locationIn, false)) - .setLightmapState(LIGHTMAP) - .setOverlayState(OVERLAY) - .createCompositeState(true) + public static Function UNLIT_TRANSLUCENT_SORTED = Util.memoize(Internal::unlitTranslucentSorted); + private static RenderType unlitTranslucentSorted(Identifier texture) { + return RenderType.create("forge_unlit_translucent_sorted", + RenderSetup.builder(RenderPipelines.ENTITY_TRANSLUCENT) + .bufferSize(RenderType.TRANSIENT_BUFFER_SIZE) + .affectsCrumbling() + .sortOnUpload() + .withTexture("Sampler0", texture) + .useOverlay() + .setOutline(RenderSetup.OutlineProperty.AFFECTS_OUTLINE) + .createRenderSetup() ); } - public static Function LAYERED_ITEM_CUTOUT_MIPPED = Util.memoize(Internal::layeredItemCutoutMipped); - private static RenderType layeredItemCutoutMipped(ResourceLocation locationIn) { - return create( - "forge_layered_item_cutout_mipped", - TRANSIENT_BUFFER_SIZE, - true, - false, - RenderPipelines.ENTITY_SMOOTH_CUTOUT, - CompositeState.builder() - .setTextureState(new TextureStateShard(locationIn, true)) - .setLightmapState(LIGHTMAP) - .setOverlayState(OVERLAY) - .createCompositeState(true) + public static Function UNLIT_TRANSLUCENT_UNSORTED = Util.memoize(Internal::unlitTranslucentUnsorted); + private static RenderType unlitTranslucentUnsorted(Identifier texture) { + return RenderType.create("forge_unlit_translucent_sorted", + RenderSetup.builder(RenderPipelines.ENTITY_TRANSLUCENT) + .bufferSize(RenderType.TRANSIENT_BUFFER_SIZE) + .affectsCrumbling() + .withTexture("Sampler0", texture) + .useOverlay() + .setOutline(RenderSetup.OutlineProperty.AFFECTS_OUTLINE) + .createRenderSetup() ); } - public static Function LAYERED_ITEM_TRANSLUCENT = Util.memoize(Internal::layeredItemTranslucent); - private static RenderType layeredItemTranslucent(ResourceLocation locationIn) { - return create( - "forge_layered_item_translucent", - TRANSIENT_BUFFER_SIZE, - true, - true, - RenderPipelines.ITEM_ENTITY_TRANSLUCENT_CULL, - CompositeState.builder() - .setTextureState(new TextureStateShard(locationIn, false)) - .setLightmapState(LIGHTMAP) - .setOverlayState(OVERLAY) - .createCompositeState(true) + public static Function LAYERED_ITEM_SOLID = Util.memoize(Internal::layeredItemSolid); + private static RenderType layeredItemSolid(Identifier texture) { + return RenderType.create("forge_layered_item_soild", + RenderSetup.builder(RenderPipelines.ENTITY_SOLID) + .bufferSize(RenderType.TRANSIENT_BUFFER_SIZE) + .affectsCrumbling() + .withTexture("Sampler0", texture) + .useLightmap() + .useOverlay() + .setOutline(RenderSetup.OutlineProperty.AFFECTS_OUTLINE) + .createRenderSetup() ); } - public static Function TEXT = Util.memoize(Internal::getText); - private static RenderType getText(ResourceLocation locationIn) { - return create( - "forge_text", - SMALL_BUFFER_SIZE, - false, - true, - RenderPipelines.TEXT, - CompositeState.builder() - .setTextureState(new CustomizableTextureState(locationIn, false)) - .setLightmapState(LIGHTMAP) - .createCompositeState(false) + public static Function LAYERED_ITEM_CUTOUT = Util.memoize(Internal::layeredItemCutout); + private static RenderType layeredItemCutout(Identifier texture) { + return RenderType.create("forge_layered_item_cutout", + RenderSetup.builder(RenderPipelines.ENTITY_CUTOUT) + .bufferSize(RenderType.TRANSIENT_BUFFER_SIZE) + .affectsCrumbling() + .withTexture("Sampler0", texture) + .useLightmap() + .useOverlay() + .setOutline(RenderSetup.OutlineProperty.AFFECTS_OUTLINE) + .createRenderSetup() ); } - public static Function TEXT_INTENSITY = Util.memoize(Internal::getTextIntensity); - private static RenderType getTextIntensity(ResourceLocation locationIn) { - return create( - "forge_text_intensity", - SMALL_BUFFER_SIZE, - false, - false, - RenderPipelines.TEXT_INTENSITY, - CompositeState.builder() - .setTextureState(new CustomizableTextureState(locationIn, false)) - .setLightmapState(LIGHTMAP) - .createCompositeState(false) + public static Function LAYERED_ITEM_CUTOUT_MIPPED = Util.memoize(Internal::layeredItemCutoutMipped); + private static RenderType layeredItemCutoutMipped(Identifier texture) { + return RenderType.create("forge_layered_item_cutout_mipped", + RenderSetup.builder(RenderPipelines.ENTITY_SMOOTH_CUTOUT) + .bufferSize(RenderType.TRANSIENT_BUFFER_SIZE) + .affectsCrumbling() + .withTexture("Sampler0", texture) // Used to have mipmap = true + .useLightmap() + .useOverlay() + .setOutline(RenderSetup.OutlineProperty.AFFECTS_OUTLINE) + .createRenderSetup() ); } - public static Function TEXT_POLYGON_OFFSET = Util.memoize(Internal::getTextPolygonOffset); - private static RenderType getTextPolygonOffset(ResourceLocation locationIn) { - return create( - "forge_text_polygon_offset", - TRANSIENT_BUFFER_SIZE, - false, - true, - RenderPipelines.TEXT_POLYGON_OFFSET, - CompositeState.builder() - .setTextureState(new CustomizableTextureState(locationIn, false)) - .setLightmapState(LIGHTMAP) - .createCompositeState(false) + public static Function LAYERED_ITEM_TRANSLUCENT = Util.memoize(Internal::layeredItemTranslucent); + private static RenderType layeredItemTranslucent(Identifier texture) { + return RenderType.create("forge_layered_item_translucent", + RenderSetup.builder(RenderPipelines.ITEM_ENTITY_TRANSLUCENT_CULL) + .bufferSize(RenderType.TRANSIENT_BUFFER_SIZE) + .affectsCrumbling() + .sortOnUpload() + .withTexture("Sampler0", texture) + .useLightmap() + .useOverlay() + .setOutline(RenderSetup.OutlineProperty.AFFECTS_OUTLINE) + .createRenderSetup() ); } - public static Function TEXT_INTENSITY_POLYGON_OFFSET = Util.memoize(Internal::getTextIntensityPolygonOffset); - private static RenderType getTextIntensityPolygonOffset(ResourceLocation locationIn) { - return create( - "forge_text_intensity_polygon_offset", - TRANSIENT_BUFFER_SIZE, - false, - true, - RenderPipelines.TEXT_INTENSITY, - CompositeState.builder() - .setTextureState(new CustomizableTextureState(locationIn, false)) - .setLightmapState(LIGHTMAP) - .createCompositeState(false) + public static Function TEXT = Util.memoize(Internal::getText); + private static RenderType getText(Identifier texture) { + return RenderType.create( + "forge_text", + RenderSetup.builder(RenderPipelines.TEXT) + .withTexture("Sampler0", texture) + .useLightmap() + .bufferSize(RenderType.SMALL_BUFFER_SIZE) + .sortOnUpload() // This is what is different from RenderTypes.TEXT + .createRenderSetup() ); } - public static Function TEXT_SEE_THROUGH = Util.memoize(Internal::getTextSeeThrough); - /** - * Use {@link #TEXT_SEE_THROUGH} instead. - */ - @Deprecated - public static Function TEXT_SEETHROUGH = TEXT_SEE_THROUGH; - private static RenderType getTextSeeThrough(ResourceLocation locationIn) { - return create( - "forge_text_see_through", - TRANSIENT_BUFFER_SIZE, - false, - false, - RenderPipelines.TEXT_SEE_THROUGH, - CompositeState.builder() - .setTextureState(new CustomizableTextureState(locationIn, false)) - .setLightmapState(LIGHTMAP) - .createCompositeState(false) + public static Function TEXT_INTENSITY = Util.memoize(Internal::getTextIntensity); + private static RenderType getTextIntensity(Identifier texture) { + return RenderType.create("forge_text_intensity", + RenderSetup.builder(RenderPipelines.TEXT_INTENSITY) + .bufferSize(RenderType.SMALL_BUFFER_SIZE) + .withTexture("Sampler0", texture) + .useLightmap() + .useOverlay() + .createRenderSetup() ); } - public static Function TEXT_INTENSITY_SEE_THROUGH = Util.memoize(Internal::getTextIntensitySeeThrough); - /** - * Use {@link #TEXT_INTENSITY_SEE_THROUGH} instead. - */ - @SuppressWarnings("unused") - @Deprecated(forRemoval = true, since = "1.21.5") - public static Function TEXT_INTENSITY_SEETHROUGH = TEXT_INTENSITY_SEE_THROUGH; - private static RenderType getTextIntensitySeeThrough(ResourceLocation locationIn) { - return create( - "forge_text_intensity_see_through", - TRANSIENT_BUFFER_SIZE, - false, - true, - RenderPipelines.TEXT_INTENSITY_SEE_THROUGH, - CompositeState.builder() - .setTextureState(new CustomizableTextureState(locationIn, false)) - .setLightmapState(LIGHTMAP) - .createCompositeState(false) + public static Function TEXT_POLYGON_OFFSET = Util.memoize(Internal::getTextPolygonOffset); + private static RenderType getTextPolygonOffset(Identifier texture) { + return RenderType.create("forge_text_polygon_offset", + RenderSetup.builder(RenderPipelines.TEXT_POLYGON_OFFSET) + .bufferSize(RenderType.TRANSIENT_BUFFER_SIZE) + .sortOnUpload() + .withTexture("Sampler0", texture) + .useLightmap() + .createRenderSetup() + ); + } + + public static Function TEXT_INTENSITY_POLYGON_OFFSET = Util.memoize(Internal::getTextIntensityPolygonOffset); + private static RenderType getTextIntensityPolygonOffset(Identifier texture) { + return RenderType.create("forge_text_intensity_polygon_offset", + RenderSetup.builder(RenderPipelines.TEXT_INTENSITY) + .bufferSize(RenderType.TRANSIENT_BUFFER_SIZE) + .sortOnUpload() + .withTexture("Sampler0", texture) + .useLightmap() + .createRenderSetup() + ); + } + + public static Function TEXT_SEE_THROUGH = Util.memoize(Internal::getTextSeeThrough); + private static RenderType getTextSeeThrough(Identifier texture) { + return RenderType.create("forge_text_see_through", + RenderSetup.builder(RenderPipelines.TEXT_SEE_THROUGH) + .bufferSize(RenderType.TRANSIENT_BUFFER_SIZE) + .withTexture("Sampler0", texture) + .useLightmap() + .createRenderSetup() + ); + } + + public static Function TEXT_INTENSITY_SEE_THROUGH = Util.memoize(Internal::getTextIntensitySeeThrough); + private static RenderType getTextIntensitySeeThrough(Identifier texture) { + return RenderType.create("forge_text_intensity_see_through", + RenderSetup.builder(RenderPipelines.TEXT_INTENSITY_SEE_THROUGH) + .bufferSize(RenderType.TRANSIENT_BUFFER_SIZE) + .sortOnUpload() + .withTexture("Sampler0", texture) + .useLightmap() + .createRenderSetup() ); } @@ -423,51 +376,22 @@ public enum ForgeRenderTypes { .withDepthWrite(false) .build(); + private static final GpuSampler LOADING_SAMPLER = RenderSystem.getSamplerCache().getSampler(AddressMode.REPEAT, AddressMode.REPEAT, FilterMode.NEAREST, FilterMode.NEAREST, false); + private static final Identifier LOADING_TEXTURE = Identifier.fromNamespaceAndPath("forge", "loading_overlay"); + public static RenderType getLoadingOverlay(DisplayWindow window) { - return create( - "forge_loading_overlay", - TRANSIENT_BUFFER_SIZE, - false, - false, - LOADING_PIPELINE, - CompositeState.builder() - .setTextureState(new LoadingOverlayTextureState(window)) - .createCompositeState(false) + var gpu = RenderSystem.getDevice(); + var texture = gpu.createTexture(LOADING_TEXTURE.toString(), 5, TextureFormat.RGBA8, + window.context().width(), window.context().height(), + 1, window.getFramebufferTextureId()); + var textureView = gpu.createTextureView(texture); + + return RenderType.create("forge_loading_overlay", + RenderSetup.builder(LOADING_PIPELINE) + .bufferSize(RenderType.TRANSIENT_BUFFER_SIZE) + .withTexture("Sampler0", textureView, LOADING_SAMPLER) + .createRenderSetup() ); } } - - private static class CustomizableTextureState extends TextureStateShard { - private CustomizableTextureState(ResourceLocation resLoc, boolean mipmap) { - super(resLoc, mipmap); - this.setupState = () -> { - TextureManager manager = Minecraft.getInstance().getTextureManager(); - var texture = manager.getTexture(resLoc); - texture.setFilter(enableTextTextureLinearFiltering, this.mipmap); - RenderSystem.setShaderTexture(0, texture.getTextureView()); - }; - } - } - - private static class LoadingOverlayTextureState extends TextureStateShard { - private static final ResourceLocation LOADING_TEXTURE = ResourceLocation.fromNamespaceAndPath("forge", "loading_overlay"); - private final GpuTexture texture; - private final GpuTextureView textureView; - - private LoadingOverlayTextureState(DisplayWindow window) { - super(LOADING_TEXTURE, false); - - GpuDevice gpu = RenderSystem.getDevice(); - this.texture = gpu.createTexture(LOADING_TEXTURE.toString(), 5, TextureFormat.RGBA8, - window.context().width(), window.context().height(), - 1, window.getFramebufferTextureId()); - this.textureView = gpu.createTextureView(this.texture); - - this.setupState = () -> { - GL30C.glTexParameterIi(GlConst.GL_TEXTURE_2D, GlConst.GL_TEXTURE_MIN_FILTER, GlConst.GL_NEAREST); - GL30C.glTexParameterIi(GlConst.GL_TEXTURE_2D, GlConst.GL_TEXTURE_MAG_FILTER, GlConst.GL_NEAREST); - RenderSystem.setShaderTexture(0, this.textureView); - }; - } - } } diff --git a/src/main/java/net/minecraftforge/client/FramePassManager.java b/src/main/java/net/minecraftforge/client/FramePassManager.java index dca3d314b4..37b28c2f80 100644 --- a/src/main/java/net/minecraftforge/client/FramePassManager.java +++ b/src/main/java/net/minecraftforge/client/FramePassManager.java @@ -10,7 +10,7 @@ import com.mojang.blaze3d.framegraph.FramePass; import com.mojang.blaze3d.resource.ResourceHandle; import net.minecraft.client.renderer.LevelTargetBundle; import net.minecraft.client.renderer.state.LevelRenderState; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import org.jetbrains.annotations.ApiStatus; import org.jspecify.annotations.Nullable; @@ -20,7 +20,7 @@ import java.util.List; public class FramePassManager { private static final List addedPasses = new ArrayList<>(); - protected static void addPass(ResourceLocation name, PassDefinition pass) { + protected static void addPass(Identifier name, PassDefinition pass) { if (addedPasses.stream().noneMatch(info -> info.name.equals(name.toString()))) { addedPasses.add(new PassInfo(name.toString(), pass)); } else { diff --git a/src/main/java/net/minecraftforge/client/NamedRenderTypeManager.java b/src/main/java/net/minecraftforge/client/NamedRenderTypeManager.java index e6a04548bc..56868bf6c9 100644 --- a/src/main/java/net/minecraftforge/client/NamedRenderTypeManager.java +++ b/src/main/java/net/minecraftforge/client/NamedRenderTypeManager.java @@ -5,9 +5,8 @@ package net.minecraftforge.client; -import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.chunk.ChunkSectionLayer; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraftforge.client.event.RegisterNamedRenderTypesEvent; import org.jetbrains.annotations.ApiStatus; @@ -20,18 +19,18 @@ import java.util.Map; * Provides a lookup. */ public final class NamedRenderTypeManager { - private static Map RENDER_TYPES; + private static Map RENDER_TYPES; /** * Finds the {@link RenderTypeGroup} for a given name, or the {@link RenderTypeGroup#EMPTY empty group} if not found. */ - public static RenderTypeGroup get(ResourceLocation name) { + public static RenderTypeGroup get(Identifier name) { return RENDER_TYPES.getOrDefault(name, RenderTypeGroup.EMPTY); } @ApiStatus.Internal public static void init() { - var renderTypes = new HashMap(); + var renderTypes = new HashMap(); preRegisterVanillaRenderTypes(renderTypes); RegisterNamedRenderTypesEvent.BUS.post(new RegisterNamedRenderTypesEvent(renderTypes)); RENDER_TYPES = Map.copyOf(renderTypes); @@ -40,18 +39,15 @@ public final class NamedRenderTypeManager { /** * Pre-registers vanilla render types. */ - private static void preRegisterVanillaRenderTypes(Map blockRenderTypes) { + private static void preRegisterVanillaRenderTypes(Map blockRenderTypes) { blockRenderTypes.put(rl("solid"), new RenderTypeGroup(ChunkSectionLayer.SOLID, ForgeRenderTypes.ITEM_LAYERED_SOLID.get())); blockRenderTypes.put(rl("cutout"), new RenderTypeGroup(ChunkSectionLayer.CUTOUT, ForgeRenderTypes.ITEM_LAYERED_CUTOUT.get())); - // Generally entity/item rendering shouldn't use mipmaps, so cutout_mipped has them off by default. To enforce them, use cutout_mipped_all. - blockRenderTypes.put(rl("cutout_mipped"), new RenderTypeGroup(ChunkSectionLayer.CUTOUT_MIPPED, ForgeRenderTypes.ITEM_LAYERED_CUTOUT.get())); - blockRenderTypes.put(rl("cutout_mipped_all"), new RenderTypeGroup(ChunkSectionLayer.CUTOUT_MIPPED, ForgeRenderTypes.ITEM_LAYERED_CUTOUT_MIPPED.get())); blockRenderTypes.put(rl("translucent_moving_block"), new RenderTypeGroup(ChunkSectionLayer.TRANSLUCENT, ForgeRenderTypes.ITEM_LAYERED_TRANSLUCENT.get())); blockRenderTypes.put(rl("tripwire"), new RenderTypeGroup(ChunkSectionLayer.TRIPWIRE, ForgeRenderTypes.ITEM_LAYERED_TRANSLUCENT.get())); } - private static ResourceLocation rl(String path) { - return ResourceLocation.withDefaultNamespace(path); + private static Identifier rl(String path) { + return Identifier.withDefaultNamespace(path); } private NamedRenderTypeManager() {} diff --git a/src/main/java/net/minecraftforge/client/RenderTypeGroup.java b/src/main/java/net/minecraftforge/client/RenderTypeGroup.java index 16f6009eff..0290f6517d 100644 --- a/src/main/java/net/minecraftforge/client/RenderTypeGroup.java +++ b/src/main/java/net/minecraftforge/client/RenderTypeGroup.java @@ -5,8 +5,8 @@ package net.minecraftforge.client; -import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.chunk.ChunkSectionLayer; +import net.minecraft.client.renderer.rendertype.RenderType; /** * A set of functionally equivalent shaders. One using {@link com.mojang.blaze3d.vertex.DefaultVertexFormat#BLOCK}, diff --git a/src/main/java/net/minecraftforge/client/RenderTypeHelper.java b/src/main/java/net/minecraftforge/client/RenderTypeHelper.java index 0f9ef4b2f6..6a334a44ee 100644 --- a/src/main/java/net/minecraftforge/client/RenderTypeHelper.java +++ b/src/main/java/net/minecraftforge/client/RenderTypeHelper.java @@ -7,10 +7,11 @@ package net.minecraftforge.client; import com.mojang.blaze3d.vertex.DefaultVertexFormat; import net.minecraft.client.renderer.ItemBlockRenderTypes; -import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.Sheets; import net.minecraft.client.renderer.block.model.BlockStateModel; import net.minecraft.client.renderer.chunk.ChunkSectionLayer; +import net.minecraft.client.renderer.rendertype.RenderType; +import net.minecraft.client.renderer.rendertype.RenderTypes; import net.minecraft.util.RandomSource; import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.ItemStack; @@ -42,14 +43,13 @@ public final class RenderTypeHelper { @NotNull public static RenderType getMovingBlockRenderType(ChunkSectionLayer layer) { if (layer == null) - return RenderType.solid(); + return RenderTypes.solidMovingBlock(); return switch (layer) { - case SOLID -> RenderType.solid(); - case CUTOUT_MIPPED -> RenderType.cutoutMipped(); - case CUTOUT -> RenderType.cutout(); - case TRANSLUCENT -> RenderType.translucentMovingBlock(); - case TRIPWIRE -> RenderType.tripwire(); + case SOLID -> RenderTypes.solidMovingBlock(); + case CUTOUT -> RenderTypes.cutoutMovingBlock(); + case TRANSLUCENT -> RenderTypes.translucentMovingBlock(); + case TRIPWIRE -> RenderTypes.tripwireMovingBlock(); }; } diff --git a/src/main/java/net/minecraftforge/client/event/AddFramePassEvent.java b/src/main/java/net/minecraftforge/client/event/AddFramePassEvent.java index 02d323a59e..3031c9e835 100644 --- a/src/main/java/net/minecraftforge/client/event/AddFramePassEvent.java +++ b/src/main/java/net/minecraftforge/client/event/AddFramePassEvent.java @@ -5,7 +5,7 @@ package net.minecraftforge.client.event; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraftforge.client.ForgeHooksClient; import net.minecraftforge.client.FramePassManager; import net.minecraftforge.eventbus.api.bus.EventBus; @@ -29,7 +29,7 @@ public record AddFramePassEvent() implements RecordEvent { * @param definition see usages of {@linkplain com.mojang.blaze3d.framegraph.FramePass} in {@linkplain net.minecraft.client.renderer.LevelRenderer} * @throws IllegalArgumentException If the name is a duplicate. */ - public void addPass(ResourceLocation rl, FramePassManager.PassDefinition definition) { + public void addPass(Identifier rl, FramePassManager.PassDefinition definition) { ForgeHooksClient.addFramePass(rl, definition); } } \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/client/event/ClientChatReceivedEvent.java b/src/main/java/net/minecraftforge/client/event/ClientChatReceivedEvent.java index 76d38005f5..50390e12ac 100644 --- a/src/main/java/net/minecraftforge/client/event/ClientChatReceivedEvent.java +++ b/src/main/java/net/minecraftforge/client/event/ClientChatReceivedEvent.java @@ -5,7 +5,7 @@ package net.minecraftforge.client.event; -import net.minecraft.Util; +import net.minecraft.util.Util; import net.minecraft.network.chat.ChatType; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.PlayerChatMessage; diff --git a/src/main/java/net/minecraftforge/client/event/EntityRenderersEvent.java b/src/main/java/net/minecraftforge/client/event/EntityRenderersEvent.java index d0320f40cb..be52b81094 100644 --- a/src/main/java/net/minecraftforge/client/event/EntityRenderersEvent.java +++ b/src/main/java/net/minecraftforge/client/event/EntityRenderersEvent.java @@ -8,12 +8,11 @@ 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.model.object.skull.SkullModelBase; import net.minecraft.client.player.AbstractClientPlayer; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; import net.minecraft.client.renderer.blockentity.BlockEntityRenderers; diff --git a/src/main/java/net/minecraftforge/client/event/ForgeEventFactoryClient.java b/src/main/java/net/minecraftforge/client/event/ForgeEventFactoryClient.java index 1d472d48e1..4f8356a60b 100644 --- a/src/main/java/net/minecraftforge/client/event/ForgeEventFactoryClient.java +++ b/src/main/java/net/minecraftforge/client/event/ForgeEventFactoryClient.java @@ -5,16 +5,13 @@ package net.minecraftforge.client.event; -import java.util.List; import java.util.Map; import java.util.function.Function; import net.minecraftforge.client.gui.overlay.ForgeLayeredDraw; import net.minecraftforge.common.util.Result; import net.minecraftforge.event.TickEvent; -import net.minecraftforge.fml.ModLoader; import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import com.google.common.collect.ImmutableMap; @@ -27,19 +24,17 @@ 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.CharacterEvent; import net.minecraft.client.input.KeyEvent; import net.minecraft.client.input.MouseButtonEvent; import net.minecraft.client.input.MouseButtonInfo; import net.minecraft.client.model.EntityModel; -import net.minecraft.client.model.SkullModelBase; import net.minecraft.client.model.geom.EntityModelSet; +import net.minecraft.client.model.object.skull.SkullModelBase; import net.minecraft.client.multiplayer.MultiPlayerGameMode; import net.minecraft.client.player.AbstractClientPlayer; import net.minecraft.client.player.LocalPlayer; @@ -60,7 +55,6 @@ 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; @@ -68,7 +62,6 @@ 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; import net.minecraftforge.client.event.sound.PlaySoundSourceEvent; @@ -201,7 +194,7 @@ public final class ForgeEventFactoryClient { } public static ViewportEvent.ComputeCameraAngles fireComputeCameraAngles(GameRenderer renderer, Camera camera, float partial) { - return ViewportEvent.ComputeCameraAngles.BUS.fire(new ViewportEvent.ComputeCameraAngles(renderer, camera, partial, camera.getYRot(), camera.getXRot(), 0)); + return ViewportEvent.ComputeCameraAngles.BUS.fire(new ViewportEvent.ComputeCameraAngles(renderer, camera, partial, camera.yRot(), camera.xRot(), 0)); } public static > boolean onRenderLivingPre(S state, LivingEntityRenderer renderer, PoseStack poseStack, SubmitNodeCollector nodeCollector, CameraRenderState cameraState) { diff --git a/src/main/java/net/minecraftforge/client/event/ModelEvent.java b/src/main/java/net/minecraftforge/client/event/ModelEvent.java index f16ed0b8c1..bef1a40bc6 100644 --- a/src/main/java/net/minecraftforge/client/event/ModelEvent.java +++ b/src/main/java/net/minecraftforge/client/event/ModelEvent.java @@ -8,7 +8,7 @@ package net.minecraftforge.client.event; import com.google.common.base.Preconditions; import net.minecraft.client.resources.model.ModelBakery; import net.minecraft.client.resources.model.ModelManager; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.StateDefinition; @@ -102,8 +102,8 @@ public sealed interface ModelEvent { return BUS; } - private final Map> states = new HashMap<>(); - private final Map> view = Collections.unmodifiableMap(states); + private final Map> states = new HashMap<>(); + private final Map> view = Collections.unmodifiableMap(states); @ApiStatus.Internal public RegisterModelStateDefinitions() {} @@ -111,14 +111,14 @@ public sealed interface ModelEvent { /** * Returns a read only view of the extra registered models */ - public Map> getStates() { + public Map> getStates() { return this.view; } /** * Registers a StateDefinition for a synthetic block. */ - public void register(ResourceLocation key, StateDefinition value) { + public void register(Identifier key, StateDefinition value) { states.put(key, value); } } @@ -138,20 +138,20 @@ public sealed interface ModelEvent { return BUS; } - private final Map loaders; + private final Map loaders; @ApiStatus.Internal - public RegisterGeometryLoaders(Map loaders) { + public RegisterGeometryLoaders(Map loaders) { this.loaders = loaders; } /** * Registers a new geometry loader. - * @param resourceLocation The namespace should match your mod's namespace, such as your mod ID + * @param Identifier The namespace should match your mod's namespace, such as your mod ID */ - public void register(ResourceLocation resourceLocation, IGeometryLoader loader) { - Preconditions.checkArgument(!loaders.containsKey(resourceLocation), "Geometry loader already registered: " + resourceLocation); - loaders.put(resourceLocation, loader); + public void register(Identifier Identifier, IGeometryLoader loader) { + Preconditions.checkArgument(!loaders.containsKey(Identifier), "Geometry loader already registered: " + Identifier); + loaders.put(Identifier, loader); } } } diff --git a/src/main/java/net/minecraftforge/client/event/RegisterClientCommandsEvent.java b/src/main/java/net/minecraftforge/client/event/RegisterClientCommandsEvent.java index ce3ec91be5..d95900740d 100644 --- a/src/main/java/net/minecraftforge/client/event/RegisterClientCommandsEvent.java +++ b/src/main/java/net/minecraftforge/client/event/RegisterClientCommandsEvent.java @@ -10,7 +10,7 @@ import com.mojang.brigadier.context.CommandContext; import net.minecraft.commands.CommandBuildContext; import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.arguments.ObjectiveArgument; -import net.minecraft.commands.arguments.ResourceLocationArgument; +import net.minecraft.commands.arguments.IdentifierArgument; import net.minecraftforge.eventbus.api.bus.EventBus; import net.minecraftforge.eventbus.api.event.RecordEvent; import net.minecraftforge.fml.LogicalSide; @@ -22,7 +22,7 @@ import org.jspecify.annotations.NullMarked; * *

Some command arguments behave differently for the client commands dispatcher:

*
    - *
  • {@link ResourceLocationArgument#getId(CommandContext, String)} only returns advancements that are shown on + *
  • {@link IdentifierArgument#getId(CommandContext, String)} only returns advancements that are shown on * the advancements screen. *
  • {@link ObjectiveArgument#getObjective(com.mojang.brigadier.context.CommandContext, String)} only returns * objectives that are displayed to the player. diff --git a/src/main/java/net/minecraftforge/client/event/RegisterDimensionSpecialEffectsEvent.java b/src/main/java/net/minecraftforge/client/event/RegisterDimensionSpecialEffectsEvent.java deleted file mode 100644 index 76dc85f81f..0000000000 --- a/src/main/java/net/minecraftforge/client/event/RegisterDimensionSpecialEffectsEvent.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) Forge Development LLC and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.minecraftforge.client.event; - -import net.minecraft.client.renderer.DimensionSpecialEffects; -import net.minecraft.resources.ResourceLocation; -import net.minecraftforge.eventbus.api.bus.BusGroup; -import net.minecraftforge.eventbus.api.bus.EventBus; -import net.minecraftforge.eventbus.api.event.MutableEvent; -import net.minecraftforge.eventbus.api.event.characteristic.SelfDestructing; -import net.minecraftforge.fml.LogicalSide; -import net.minecraftforge.fml.event.IModBusEvent; -import org.jetbrains.annotations.ApiStatus; -import org.jspecify.annotations.NullMarked; - -import java.util.Map; - -/** - * Allows users to register custom {@link DimensionSpecialEffects} for their dimensions. - * - *

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

    - */ -@NullMarked -public final class RegisterDimensionSpecialEffectsEvent extends MutableEvent implements SelfDestructing { - public static final EventBus BUS = EventBus.create(RegisterDimensionSpecialEffectsEvent.class); - - /** @deprecated {@link RegisterDimensionSpecialEffectsEvent} 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 BUS; - } - - private final Map effects; - - @ApiStatus.Internal - public RegisterDimensionSpecialEffectsEvent(Map effects) { - this.effects = effects; - } - - /** - * Registers the effects for a given dimension type. - */ - public void register(ResourceLocation dimensionType, DimensionSpecialEffects effects) { - this.effects.put(dimensionType, effects); - } -} diff --git a/src/main/java/net/minecraftforge/client/event/RegisterEntitySpectatorShadersEvent.java b/src/main/java/net/minecraftforge/client/event/RegisterEntitySpectatorShadersEvent.java index 4418d15305..0b512a9600 100644 --- a/src/main/java/net/minecraftforge/client/event/RegisterEntitySpectatorShadersEvent.java +++ b/src/main/java/net/minecraftforge/client/event/RegisterEntitySpectatorShadersEvent.java @@ -5,7 +5,7 @@ package net.minecraftforge.client.event; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.world.entity.EntityType; import net.minecraftforge.eventbus.api.bus.BusGroup; import net.minecraftforge.eventbus.api.bus.EventBus; @@ -34,17 +34,17 @@ public final class RegisterEntitySpectatorShadersEvent extends MutableEvent impl return BUS; } - private final Map, ResourceLocation> shaders; + private final Map, Identifier> shaders; @ApiStatus.Internal - public RegisterEntitySpectatorShadersEvent(Map, ResourceLocation> shaders) { + public RegisterEntitySpectatorShadersEvent(Map, Identifier> shaders) { this.shaders = shaders; } /** * Registers a spectator shader for a given entity type. */ - public void register(EntityType entityType, ResourceLocation shader) { + public void register(EntityType entityType, Identifier shader) { shaders.put(entityType, shader); } } diff --git a/src/main/java/net/minecraftforge/client/event/RegisterGuiOverlaysEvent.java b/src/main/java/net/minecraftforge/client/event/RegisterGuiOverlaysEvent.java index 2d7c88b93f..01504070ab 100644 --- a/src/main/java/net/minecraftforge/client/event/RegisterGuiOverlaysEvent.java +++ b/src/main/java/net/minecraftforge/client/event/RegisterGuiOverlaysEvent.java @@ -7,7 +7,7 @@ package net.minecraftforge.client.event; import com.google.common.base.Preconditions; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraftforge.client.gui.overlay.IGuiOverlay; import net.minecraftforge.client.gui.overlay.VanillaGuiOverlay; import net.minecraftforge.eventbus.api.Cancelable; @@ -33,11 +33,11 @@ import java.util.Map; * / public class RegisterGuiOverlaysEvent extends Event implements IModBusEvent { - private final Map overlays; - private final List orderedOverlays; + private final Map overlays; + private final List orderedOverlays; @ApiStatus.Internal - public RegisterGuiOverlaysEvent(Map overlays, List orderedOverlays) + public RegisterGuiOverlaysEvent(Map overlays, List orderedOverlays) { this.overlays = overlays; this.orderedOverlays = orderedOverlays; @@ -62,7 +62,7 @@ public class RegisterGuiOverlaysEvent extends Event implements IModBusEvent * @param id A unique resource id for this overlay * @param overlay The overlay * / - public void registerBelow(@NotNull ResourceLocation other, @NotNull String id, @NotNull IGuiOverlay overlay) + public void registerBelow(@NotNull Identifier other, @NotNull String id, @NotNull IGuiOverlay overlay) { register(Ordering.BEFORE, other, id, overlay); } @@ -75,7 +75,7 @@ public class RegisterGuiOverlaysEvent extends Event implements IModBusEvent * @param id A unique resource id for this overlay * @param overlay The overlay * / - public void registerAbove(@NotNull ResourceLocation other, @NotNull String id, @NotNull IGuiOverlay overlay) + public void registerAbove(@NotNull Identifier other, @NotNull String id, @NotNull IGuiOverlay overlay) { register(Ordering.AFTER, other, id, overlay); } @@ -91,9 +91,9 @@ public class RegisterGuiOverlaysEvent extends Event implements IModBusEvent register(Ordering.AFTER, null, id, overlay); } - private void register(@NotNull Ordering ordering, @Nullable ResourceLocation other, @NotNull String id, @NotNull IGuiOverlay overlay) + private void register(@NotNull Ordering ordering, @Nullable Identifier other, @NotNull String id, @NotNull IGuiOverlay overlay) { - var key = new ResourceLocation(ModLoadingContext.get().getActiveNamespace(), id); + var key = new Identifier(ModLoadingContext.get().getActiveNamespace(), id); Preconditions.checkArgument(!overlays.containsKey(key), "Overlay already registered: " + key); int insertPosition; diff --git a/src/main/java/net/minecraftforge/client/event/RegisterNamedRenderTypesEvent.java b/src/main/java/net/minecraftforge/client/event/RegisterNamedRenderTypesEvent.java index 3b015881ab..610f4ca672 100644 --- a/src/main/java/net/minecraftforge/client/event/RegisterNamedRenderTypesEvent.java +++ b/src/main/java/net/minecraftforge/client/event/RegisterNamedRenderTypesEvent.java @@ -7,16 +7,14 @@ package net.minecraftforge.client.event; import com.google.common.base.Preconditions; import com.mojang.blaze3d.vertex.DefaultVertexFormat; -import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.chunk.ChunkSectionLayer; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.client.renderer.rendertype.RenderType; +import net.minecraft.resources.Identifier; import net.minecraftforge.client.RenderTypeGroup; -import net.minecraftforge.eventbus.api.bus.BusGroup; import net.minecraftforge.eventbus.api.bus.EventBus; import net.minecraftforge.eventbus.api.event.MutableEvent; import net.minecraftforge.eventbus.api.event.characteristic.SelfDestructing; import net.minecraftforge.fml.LogicalSide; -import net.minecraftforge.fml.event.IModBusEvent; import org.jetbrains.annotations.ApiStatus; import java.util.Map; @@ -29,28 +27,22 @@ import java.util.Map; public final class RegisterNamedRenderTypesEvent extends MutableEvent implements SelfDestructing { public static final EventBus BUS = EventBus.create(RegisterNamedRenderTypesEvent.class); - /** @deprecated {@link RegisterNamedRenderTypesEvent} 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 BUS; - } - - private final Map renderTypes; + private final Map renderTypes; @ApiStatus.Internal - public RegisterNamedRenderTypesEvent(Map renderTypes) { + public RegisterNamedRenderTypesEvent(Map renderTypes) { this.renderTypes = renderTypes; } /** * Registers a named {@link RenderTypeGroup}. * - * @param resourceLocation The namespace should match your mod's namespace, such as your mod ID + * @param Identifier The namespace should match your mod's namespace, such as your mod ID * @param blockRenderType What ChunkSectionLayer to render in * @param entityRenderType A {@link RenderType} using {@link DefaultVertexFormat#NEW_ENTITY} */ - public void register(ResourceLocation resourceLocation, ChunkSectionLayer blockRenderType, RenderType entityRenderType) { - register(resourceLocation, blockRenderType, entityRenderType, entityRenderType); + public void register(Identifier Identifier, ChunkSectionLayer blockRenderType, RenderType entityRenderType) { + register(Identifier, blockRenderType, entityRenderType, entityRenderType); } /** @@ -62,7 +54,7 @@ public final class RegisterNamedRenderTypesEvent extends MutableEvent implements * @param fabulousEntityRenderType A {@link RenderType} using {@link DefaultVertexFormat#NEW_ENTITY} for use when * "fabulous" rendering is enabled */ - public void register(ResourceLocation key, ChunkSectionLayer blockRenderType, RenderType entityRenderType, RenderType fabulousEntityRenderType) { + public void register(Identifier key, ChunkSectionLayer blockRenderType, RenderType entityRenderType, RenderType fabulousEntityRenderType) { Preconditions.checkArgument(!renderTypes.containsKey(key), "Render type already registered: " + key); Preconditions.checkArgument(entityRenderType.format() == DefaultVertexFormat.NEW_ENTITY, "The entity render type must use the NEW_ENTITY vertex format."); Preconditions.checkArgument(fabulousEntityRenderType.format() == DefaultVertexFormat.NEW_ENTITY, "The fabulous entity render type must use the NEW_ENTITY vertex format."); diff --git a/src/main/java/net/minecraftforge/client/event/RegisterPresetEditorsEvent.java b/src/main/java/net/minecraftforge/client/event/RegisterPresetEditorsEvent.java index 485f55cc1a..9bf91c7b8d 100644 --- a/src/main/java/net/minecraftforge/client/event/RegisterPresetEditorsEvent.java +++ b/src/main/java/net/minecraftforge/client/event/RegisterPresetEditorsEvent.java @@ -48,7 +48,7 @@ public final class RegisterPresetEditorsEvent implements SelfDestructing, IModBu public void register(ResourceKey key, PresetEditor editor) { PresetEditor old = this.editors.put(key, editor); if (old != null) { - LOGGER.debug("PresetEditor {} overridden by mod {}", key.location(), ModLoadingContext.get().getActiveNamespace()); + LOGGER.debug("PresetEditor {} overridden by mod {}", key.identifier(), ModLoadingContext.get().getActiveNamespace()); } } } diff --git a/src/main/java/net/minecraftforge/client/event/RegisterTextureAtlasSpriteLoadersEvent.java b/src/main/java/net/minecraftforge/client/event/RegisterTextureAtlasSpriteLoadersEvent.java index 08fc3ed448..e2beaae1d1 100644 --- a/src/main/java/net/minecraftforge/client/event/RegisterTextureAtlasSpriteLoadersEvent.java +++ b/src/main/java/net/minecraftforge/client/event/RegisterTextureAtlasSpriteLoadersEvent.java @@ -8,7 +8,7 @@ package net.minecraftforge.client.event; import com.google.common.base.Preconditions; import com.google.common.collect.BiMap; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraftforge.client.textures.ITextureAtlasSpriteLoader; import net.minecraftforge.eventbus.api.bus.BusGroup; import net.minecraftforge.eventbus.api.bus.EventBus; @@ -32,20 +32,20 @@ public final class RegisterTextureAtlasSpriteLoadersEvent extends MutableEvent i return BUS; } - private final BiMap loaders; + private final BiMap loaders; @ApiStatus.Internal - public RegisterTextureAtlasSpriteLoadersEvent(BiMap loaders) { + public RegisterTextureAtlasSpriteLoadersEvent(BiMap loaders) { this.loaders = loaders; } /** * Registers a custom {@link ITextureAtlasSpriteLoader sprite loader}. - * @param resourceLocation The namespace should match your mod's namespace, such as your mod ID + * @param Identifier The namespace should match your mod's namespace, such as your mod ID */ - public void register(ResourceLocation resourceLocation, ITextureAtlasSpriteLoader loader) { - Preconditions.checkArgument(!loaders.containsKey(resourceLocation), "Sprite loader already registered: " + resourceLocation); + public void register(Identifier Identifier, ITextureAtlasSpriteLoader loader) { + Preconditions.checkArgument(!loaders.containsKey(Identifier), "Sprite loader already registered: " + Identifier); Preconditions.checkArgument(!loaders.containsValue(loader), "Sprite loader already registered as " + loaders.inverse().get(loader)); - loaders.put(resourceLocation, loader); + loaders.put(Identifier, loader); } } diff --git a/src/main/java/net/minecraftforge/client/event/RenderTooltipEvent.java b/src/main/java/net/minecraftforge/client/event/RenderTooltipEvent.java index 27b771f531..82fb1e26ea 100644 --- a/src/main/java/net/minecraftforge/client/event/RenderTooltipEvent.java +++ b/src/main/java/net/minecraftforge/client/event/RenderTooltipEvent.java @@ -11,7 +11,7 @@ import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent; import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipPositioner; import net.minecraft.network.chat.FormattedText; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.world.inventory.tooltip.TooltipComponent; import net.minecraft.world.item.ItemStack; import net.minecraftforge.common.MinecraftForge; @@ -209,12 +209,12 @@ public abstract sealed class RenderTooltipEvent extends MutableEvent implements private final int screenHeight; private final ClientTooltipPositioner positioner; @Nullable - private ResourceLocation background; + private Identifier background; @Nullable - private ResourceLocation originalBackground; + private Identifier originalBackground; @ApiStatus.Internal - public Pre(ItemStack stack, GuiGraphics graphics, int x, int y, int screenWidth, int screenHeight, Font font, List components, ClientTooltipPositioner positioner, @Nullable ResourceLocation background) { + public Pre(ItemStack stack, GuiGraphics graphics, int x, int y, int screenWidth, int screenHeight, Font font, List components, ClientTooltipPositioner positioner, @Nullable Identifier background) { super(stack, graphics, x, y, font, components); this.screenWidth = screenWidth; this.screenHeight = screenHeight; @@ -274,21 +274,21 @@ public abstract sealed class RenderTooltipEvent extends MutableEvent implements /** * Sets the new prefix for the background texture */ - public void setBackground(@Nullable ResourceLocation background) { + public void setBackground(@Nullable Identifier background) { this.background = background; } /** * @return the potentially modified background's prefix, can be null for default */ - public @Nullable ResourceLocation getBackground() { + public @Nullable Identifier getBackground() { return this.background; } /** * @return the original tooltip background's prefix, can be null for default */ - public @Nullable ResourceLocation getOriginalBackground() { + public @Nullable Identifier getOriginalBackground() { return originalBackground; } } diff --git a/src/main/java/net/minecraftforge/client/event/TextureStitchEvent.java b/src/main/java/net/minecraftforge/client/event/TextureStitchEvent.java index 6429330aac..6a304ab686 100644 --- a/src/main/java/net/minecraftforge/client/event/TextureStitchEvent.java +++ b/src/main/java/net/minecraftforge/client/event/TextureStitchEvent.java @@ -35,10 +35,10 @@ public sealed interface TextureStitchEvent { // *

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

    // */ // public static class Pre extends TextureStitchEvent { - // private final Set sprites; + // private final Set sprites; // // @ApiStatus.Internal - // public Pre(TextureAtlas map, Set sprites) { + // public Pre(TextureAtlas map, Set sprites) { // super(map); // this.sprites = sprites; // } @@ -51,7 +51,7 @@ public sealed interface TextureStitchEvent { // * // * @param sprite the location of the sprite // */ - // public boolean addSprite(ResourceLocation sprite) { + // public boolean addSprite(Identifier sprite) { // return this.sprites.add(sprite); // } // } diff --git a/src/main/java/net/minecraftforge/client/event/package-info.java b/src/main/java/net/minecraftforge/client/event/package-info.java index 3cd3aed976..aefaaa983c 100644 --- a/src/main/java/net/minecraftforge/client/event/package-info.java +++ b/src/main/java/net/minecraftforge/client/event/package-info.java @@ -6,12 +6,7 @@ /** * Events fired only on the client-side, chiefly related to rendering and user interfaces (screens and input). */ -@FieldsAreNonnullByDefault -@MethodsReturnNonnullByDefault -@ParametersAreNonnullByDefault +@NullMarked package net.minecraftforge.client.event; -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/event/sound/PlaySoundEvent.java b/src/main/java/net/minecraftforge/client/event/sound/PlaySoundEvent.java index b32214a67e..c77f7af6c9 100644 --- a/src/main/java/net/minecraftforge/client/event/sound/PlaySoundEvent.java +++ b/src/main/java/net/minecraftforge/client/event/sound/PlaySoundEvent.java @@ -36,7 +36,7 @@ public final class PlaySoundEvent extends MutableEvent implements SoundEvent { public PlaySoundEvent(SoundEngine manager, SoundInstance sound) { this.manager = manager; this.originalSound = sound; - this.name = sound.getLocation().getPath(); + this.name = sound.getIdentifier().getPath(); this.setSound(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 4026ec9313..f29e8a9870 100644 --- a/src/main/java/net/minecraftforge/client/event/sound/PlaySoundSourceEvent.java +++ b/src/main/java/net/minecraftforge/client/event/sound/PlaySoundSourceEvent.java @@ -30,7 +30,7 @@ public record PlaySoundSourceEvent(SoundEngine getEngine, SoundInstance getSound @ApiStatus.Internal public PlaySoundSourceEvent(SoundEngine engine, SoundInstance sound, Channel channel) { - this(engine, sound, channel, sound.getLocation().getPath()); + this(engine, sound, channel, sound.getIdentifier().getPath()); } @ApiStatus.Internal 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 aeab3419da..9ab1548aa9 100644 --- a/src/main/java/net/minecraftforge/client/event/sound/PlayStreamingSourceEvent.java +++ b/src/main/java/net/minecraftforge/client/event/sound/PlayStreamingSourceEvent.java @@ -30,7 +30,7 @@ public record PlayStreamingSourceEvent(SoundEngine getEngine, SoundInstance getS @ApiStatus.Internal public PlayStreamingSourceEvent(SoundEngine engine, SoundInstance sound, Channel channel) { - this(engine, sound, channel, sound.getLocation().getPath()); + this(engine, sound, channel, sound.getIdentifier().getPath()); } @ApiStatus.Internal diff --git a/src/main/java/net/minecraftforge/client/extensions/IForgeBlockStateModel.java b/src/main/java/net/minecraftforge/client/extensions/IForgeBlockStateModel.java index 2bf2670548..bf9af02b42 100644 --- a/src/main/java/net/minecraftforge/client/extensions/IForgeBlockStateModel.java +++ b/src/main/java/net/minecraftforge/client/extensions/IForgeBlockStateModel.java @@ -6,7 +6,7 @@ package net.minecraftforge.client.extensions; import net.minecraft.client.renderer.ItemBlockRenderTypes; -import net.minecraft.client.renderer.RenderType; +import net.minecraft.client.renderer.rendertype.RenderType; import net.minecraft.client.renderer.block.model.BlockModelPart; import net.minecraft.client.renderer.block.model.BlockStateModel; import net.minecraft.client.renderer.chunk.ChunkSectionLayer; diff --git a/src/main/java/net/minecraftforge/client/extensions/IForgeGuiGraphics.java b/src/main/java/net/minecraftforge/client/extensions/IForgeGuiGraphics.java index 111ce664dd..b1b051b9b8 100644 --- a/src/main/java/net/minecraftforge/client/extensions/IForgeGuiGraphics.java +++ b/src/main/java/net/minecraftforge/client/extensions/IForgeGuiGraphics.java @@ -7,7 +7,7 @@ package net.minecraftforge.client.extensions; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.renderer.RenderPipelines; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; /** * Extension interface for {@link GuiGraphics}. @@ -35,7 +35,7 @@ public interface IForgeGuiGraphics { * Draws a textured box of any size (smallest size is borderSize * 2 square) * based on a fixed size textured box with continuous borders and filler. * - * @param texture the ResourceLocation object that contains the desired image + * @param texture the Identifier object that contains the desired image * @param x x-axis offset * @param y y-axis offset * @param u bound resource location image x offset @@ -46,7 +46,7 @@ public interface IForgeGuiGraphics { * @param textureHeight the height of the box texture in the resource location image * @param borderSize the size of the box's borders */ - default void blitWithBorder(ResourceLocation texture, int x, int y, int u, int v, int width, int height, int textureWidth, int textureHeight, int borderSize) { + default void blitWithBorder(Identifier texture, int x, int y, int u, int v, int width, int height, int textureWidth, int textureHeight, int borderSize) { this.blitWithBorder(texture, x, y, u, v, width, height, textureWidth, textureHeight, borderSize, borderSize, borderSize, borderSize); } @@ -54,7 +54,7 @@ public interface IForgeGuiGraphics { * Draws a textured box of any size (smallest size is borderSize * 2 square) * based on a fixed size textured box with continuous borders and filler. * - * @param texture the ResourceLocation object that contains the desired image + * @param texture the Identifier object that contains the desired image * @param x x-axis offset * @param y y-axis offset * @param u bound resource location image x offset @@ -68,7 +68,7 @@ public interface IForgeGuiGraphics { * @param leftBorder the size of the box's left border * @param rightBorder the size of the box's right border */ - default void blitWithBorder(ResourceLocation texture, int x, int y, int u, int v, int width, int height, int textureWidth, int textureHeight, int topBorder, int bottomBorder, int leftBorder, int rightBorder) { + default void blitWithBorder(Identifier texture, int x, int y, int u, int v, int width, int height, int textureWidth, int textureHeight, int topBorder, int bottomBorder, int leftBorder, int rightBorder) { int fillerWidth = textureWidth - leftBorder - rightBorder; int fillerHeight = textureHeight - topBorder - bottomBorder; int canvasWidth = width - leftBorder - rightBorder; @@ -108,11 +108,11 @@ public interface IForgeGuiGraphics { } } - default void blitInscribed(ResourceLocation texture, int x, int y, int boundsWidth, int boundsHeight, int rectWidth, int rectHeight) { + default void blitInscribed(Identifier texture, int x, int y, int boundsWidth, int boundsHeight, int rectWidth, int rectHeight) { this.blitInscribed(texture, x, y, boundsWidth, boundsHeight, rectWidth, rectHeight, true, true); } - default void blitInscribed(ResourceLocation texture, int x, int y, int boundsWidth, int boundsHeight, int rectWidth, int rectHeight, boolean centerX, boolean centerY) { + default void blitInscribed(Identifier texture, int x, int y, int boundsWidth, int boundsHeight, int rectWidth, int rectHeight, boolean centerX, boolean centerY) { if (rectWidth * boundsHeight > rectHeight * boundsWidth) { int h = boundsHeight; boundsHeight = (int) (boundsWidth * ((double) rectHeight / rectWidth)); diff --git a/src/main/java/net/minecraftforge/client/extensions/IForgePoseStack.java b/src/main/java/net/minecraftforge/client/extensions/IForgePoseStack.java index 897fc79eff..8a1e83f0a3 100644 --- a/src/main/java/net/minecraftforge/client/extensions/IForgePoseStack.java +++ b/src/main/java/net/minecraftforge/client/extensions/IForgePoseStack.java @@ -7,7 +7,6 @@ package net.minecraftforge.client.extensions; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.math.Transformation; -import org.joml.Vector3f; /** * Extension interface for {@link com.mojang.blaze3d.vertex.PoseStack}. @@ -27,12 +26,12 @@ public interface IForgePoseStack { final PoseStack self = self(); self.pushPose(); - Vector3f trans = transformation.getTranslation(); + var trans = transformation.getTranslation(); self.translate(trans.x(), trans.y(), trans.z()); self.mulPose(transformation.getLeftRotation()); - Vector3f scale = transformation.getScale(); + var scale = transformation.getScale(); self.scale(scale.x(), scale.y(), scale.z()); self.mulPose(transformation.getRightRotation()); diff --git a/src/main/java/net/minecraftforge/client/extensions/IForgeVertexConsumer.java b/src/main/java/net/minecraftforge/client/extensions/IForgeVertexConsumer.java index b9efeb089c..2611e192c4 100644 --- a/src/main/java/net/minecraftforge/client/extensions/IForgeVertexConsumer.java +++ b/src/main/java/net/minecraftforge/client/extensions/IForgeVertexConsumer.java @@ -7,13 +7,7 @@ package net.minecraftforge.client.extensions; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; -import com.mojang.blaze3d.vertex.VertexFormatElement; import net.minecraft.client.renderer.block.model.BakedQuad; -import net.minecraftforge.client.model.IQuadTransformer; -import org.joml.Matrix3f; -import org.joml.Vector3f; - -import java.nio.ByteBuffer; /** * Extension interface for {@link VertexConsumer}. @@ -23,40 +17,10 @@ public interface IForgeVertexConsumer { return (VertexConsumer)this; } - /** - * Consumes an unknown {@link VertexFormatElement} as a raw int data array. - *

    - * If the consumer needs to store the data for later use, it must copy it. There are no guarantees on immutability. - */ - default VertexConsumer misc(VertexFormatElement element, int... rawData) { - return self(); - } - /** * Variant with no per-vertex shading. */ - default void putBulkData(PoseStack.Pose pose, BakedQuad bakedQuad, float red, float green, float blue, float alpha, int packedLight, int packedOverlay, boolean readExistingColor) { - self().putBulkData(pose, bakedQuad, new float[] { 1.0F, 1.0F, 1.0F, 1.0F }, red, green, blue, alpha, new int[] { packedLight, packedLight, packedLight, packedLight }, packedOverlay, readExistingColor); - } - - default int applyBakedLighting(int packedLight, ByteBuffer data) { - int bl = packedLight & 0xFFFF; - int sl = (packedLight >> 16) & 0xFFFF; - int offset = IQuadTransformer.UV2 * 4; // int offset for vertex 0 * 4 bytes per int - int blBaked = Short.toUnsignedInt(data.getShort(offset)); - int slBaked = Short.toUnsignedInt(data.getShort(offset + 2)); - bl = Math.max(bl, blBaked); - sl = Math.max(sl, slBaked); - return bl | (sl << 16); - } - - default void applyBakedNormals(Vector3f generated, ByteBuffer data, Matrix3f normalTransform) { - byte nx = data.get(28); - byte ny = data.get(29); - byte nz = data.get(30); - if (nx != 0 || ny != 0 || nz != 0) { - generated.set(nx / 127f, ny / 127f, nz / 127f); - generated.mul(normalTransform); - } + default void putBulkData(PoseStack.Pose pose, BakedQuad bakedQuad, float red, float green, float blue, float alpha, int packedLight, int packedOverlay) { + self().putBulkData(pose, bakedQuad, new float[] { 1.0F, 1.0F, 1.0F, 1.0F }, red, green, blue, alpha, new int[] { packedLight, packedLight, packedLight, packedLight }, packedOverlay); } } diff --git a/src/main/java/net/minecraftforge/client/extensions/common/IClientFluidTypeExtensions.java b/src/main/java/net/minecraftforge/client/extensions/common/IClientFluidTypeExtensions.java index 3b521701c6..21494c0e3e 100644 --- a/src/main/java/net/minecraftforge/client/extensions/common/IClientFluidTypeExtensions.java +++ b/src/main/java/net/minecraftforge/client/extensions/common/IClientFluidTypeExtensions.java @@ -14,7 +14,7 @@ import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.ScreenEffectRenderer; import net.minecraft.client.renderer.fog.FogData; import net.minecraft.core.BlockPos; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.world.level.BlockAndTintGetter; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.FluidState; @@ -74,7 +74,7 @@ public interface IClientFluidTypeExtensions { * * @return the reference of the texture to apply to a source fluid */ - default ResourceLocation getStillTexture() { + default Identifier getStillTexture() { return null; } @@ -90,7 +90,7 @@ public interface IClientFluidTypeExtensions { * * @return the reference of the texture to apply to a flowing fluid */ - default ResourceLocation getFlowingTexture() { + default Identifier getFlowingTexture() { return null; } @@ -108,7 +108,7 @@ public interface IClientFluidTypeExtensions { * a non-opaque block */ @Nullable - default ResourceLocation getOverlayTexture() { + default Identifier getOverlayTexture() { return null; } @@ -125,7 +125,7 @@ public interface IClientFluidTypeExtensions { * within the fluid */ @Nullable - default ResourceLocation getRenderOverlayTexture(Minecraft mc) { + default Identifier getRenderOverlayTexture(Minecraft mc) { return null; } @@ -137,7 +137,7 @@ public interface IClientFluidTypeExtensions { * @param poseStack the transformations representing the current rendering position */ default void renderOverlay(Minecraft mc, PoseStack poseStack, MultiBufferSource buffer) { - ResourceLocation texture = this.getRenderOverlayTexture(mc); + Identifier texture = this.getRenderOverlayTexture(mc); if (texture != null) ScreenEffectRenderer.renderFluid(mc, poseStack, buffer, texture); } @@ -185,7 +185,7 @@ public interface IClientFluidTypeExtensions { * @param pos the position of the fluid * @return the reference of the texture to apply to a source fluid */ - default ResourceLocation getStillTexture(FluidState state, BlockAndTintGetter getter, BlockPos pos) { + default Identifier getStillTexture(FluidState state, BlockAndTintGetter getter, BlockPos pos) { return this.getStillTexture(); } @@ -204,7 +204,7 @@ public interface IClientFluidTypeExtensions { * @param pos the position of the fluid * @return the reference of the texture to apply to a flowing fluid */ - default ResourceLocation getFlowingTexture(FluidState state, BlockAndTintGetter getter, BlockPos pos) { + default Identifier getFlowingTexture(FluidState state, BlockAndTintGetter getter, BlockPos pos) { return this.getFlowingTexture(); } @@ -224,7 +224,7 @@ public interface IClientFluidTypeExtensions { * @return the reference of the texture to apply to a fluid directly touching * a non-opaque block */ - default ResourceLocation getOverlayTexture(FluidState state, BlockAndTintGetter getter, BlockPos pos) { + default Identifier getOverlayTexture(FluidState state, BlockAndTintGetter getter, BlockPos pos) { return this.getOverlayTexture(); } @@ -271,7 +271,7 @@ public interface IClientFluidTypeExtensions { * @param stack the stack the fluid is in * @return the reference of the texture to apply to a source fluid */ - default ResourceLocation getStillTexture(FluidStack stack) { + default Identifier getStillTexture(FluidStack stack) { return this.getStillTexture(); } @@ -288,7 +288,7 @@ public interface IClientFluidTypeExtensions { * @param stack the stack the fluid is in * @return the reference of the texture to apply to a flowing fluid */ - default ResourceLocation getFlowingTexture(FluidStack stack) { + default Identifier getFlowingTexture(FluidStack stack) { return this.getFlowingTexture(); } @@ -306,7 +306,7 @@ public interface IClientFluidTypeExtensions { * @return the reference of the texture to apply to a fluid directly touching * a non-opaque block */ - default ResourceLocation getOverlayTexture(FluidStack stack) { + default Identifier getOverlayTexture(FluidStack stack) { return this.getOverlayTexture(); } } diff --git a/src/main/java/net/minecraftforge/client/extensions/common/IClientMobEffectExtensions.java b/src/main/java/net/minecraftforge/client/extensions/common/IClientMobEffectExtensions.java index a4082e8f38..79feb1250a 100644 --- a/src/main/java/net/minecraftforge/client/extensions/common/IClientMobEffectExtensions.java +++ b/src/main/java/net/minecraftforge/client/extensions/common/IClientMobEffectExtensions.java @@ -49,8 +49,7 @@ public interface IClientMobEffectExtensions { } /** - * Renders the icon of the specified effect in the player's inventory. - * This can be used to render icons from your own texture sheet. + * Renders the text and icon of the specified effect in the player's inventory. * * @param instance The effect instance * @param effects The effect-rendering screen @@ -60,22 +59,7 @@ public interface IClientMobEffectExtensions { * @param blitOffset The blit offset * @return true to prevent default rendering, false otherwise */ - default boolean renderInventoryIcon(MobEffectInstance instance, EffectsInInventory effects, GuiGraphics guiGraphics, int x, int y, int blitOffset) { - return false; - } - - /** - * Renders the text of the specified effect in the player's inventory. - * - * @param instance The effect instance - * @param effects The effect-rendering screen - * @param guiGraphics The gui graphics - * @param x The x coordinate - * @param y The y coordinate - * @param blitOffset The blit offset - * @return true to prevent default rendering, false otherwise - */ - default boolean renderInventoryText(MobEffectInstance instance, EffectsInInventory effects, GuiGraphics guiGraphics, int x, int y, int blitOffset) { + default boolean renderInventory(MobEffectInstance instance, EffectsInInventory effects, GuiGraphics guiGraphics, int x, int y, int blitOffset) { return false; } diff --git a/src/main/java/net/minecraftforge/client/extensions/package-info.java b/src/main/java/net/minecraftforge/client/extensions/package-info.java index ebc0593df4..71d49efa29 100644 --- a/src/main/java/net/minecraftforge/client/extensions/package-info.java +++ b/src/main/java/net/minecraftforge/client/extensions/package-info.java @@ -15,12 +15,7 @@ * methods are usually {@code default} with an implementation in the interface itself, but methods may be implemented * in the target class instead if it requires access to (patched-in or original) fields in the instance.

    */ -@FieldsAreNonnullByDefault -@MethodsReturnNonnullByDefault -@ParametersAreNonnullByDefault +@NullMarked package net.minecraftforge.client.extensions; -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/gui/LoadingErrorScreen.java b/src/main/java/net/minecraftforge/client/gui/LoadingErrorScreen.java index c938fb2149..89a1550f45 100644 --- a/src/main/java/net/minecraftforge/client/gui/LoadingErrorScreen.java +++ b/src/main/java/net/minecraftforge/client/gui/LoadingErrorScreen.java @@ -12,7 +12,7 @@ import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.screens.ErrorScreen; import net.minecraft.client.gui.components.ObjectSelectionList; import net.minecraft.util.FormattedCharSequence; -import net.minecraft.Util; +import net.minecraft.util.Util; import net.minecraft.network.chat.Component; import net.minecraft.ChatFormatting; import net.minecraftforge.common.ForgeI18n; diff --git a/src/main/java/net/minecraftforge/client/gui/ModListScreen.java b/src/main/java/net/minecraftforge/client/gui/ModListScreen.java index 5a1bfe21b3..3194e93452 100644 --- a/src/main/java/net/minecraftforge/client/gui/ModListScreen.java +++ b/src/main/java/net/minecraftforge/client/gui/ModListScreen.java @@ -25,10 +25,10 @@ import net.minecraftforge.fml.loading.moddiscovery.ModFileInfo; import org.apache.maven.artifact.versioning.ComparableVersion; import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.ActiveTextCollector; 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; @@ -37,10 +37,9 @@ import net.minecraft.client.gui.components.StringWidget; import net.minecraft.client.renderer.texture.DynamicTexture; import com.mojang.blaze3d.platform.NativeImage; import net.minecraft.client.renderer.texture.TextureManager; -import net.minecraft.util.ARGB; import net.minecraft.util.FormattedCharSequence; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.Util; +import net.minecraft.resources.Identifier; +import net.minecraft.util.Util; import net.minecraftforge.common.ForgeHooks; import net.minecraftforge.common.util.Size2i; import net.minecraftforge.common.ForgeI18n; @@ -52,14 +51,11 @@ import net.minecraftforge.fml.loading.FMLPaths; import net.minecraftforge.fml.loading.StringUtils; import net.minecraftforge.forgespi.language.IModInfo; -import net.minecraft.locale.Language; -import net.minecraft.network.chat.ClickEvent; import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.Style; import org.slf4j.Logger; public class ModListScreen extends Screen { - private static final ResourceLocation LOGO = ResourceLocation.fromNamespaceAndPath("forge", "mod_logo"); + private static final Identifier LOGO = Identifier.fromNamespaceAndPath("forge", "mod_logo"); private static String stripControlCodes(String value) { return net.minecraft.util.StringUtil.stripColor(value); } private static final Logger LOGGER = LogUtils.getLogger(); private enum SortType implements Comparator { @@ -112,7 +108,7 @@ public class ModListScreen extends Screen { } class InfoPanel extends ScrollPanel { - private ResourceLocation logoPath; + private Identifier logoPath; private Size2i logoDims = new Size2i(0, 0); private List lines = Collections.emptyList(); @@ -120,7 +116,7 @@ public class ModListScreen extends Screen { super(mcIn, widthIn, heightIn, topIn, modList.getRight() + PADDING); } - void setInfo(List lines, ResourceLocation logoPath, Size2i logoDims) { + void setInfo(List lines, Identifier logoPath, Size2i logoDims) { this.logoPath = logoPath; this.logoDims = logoDims; this.lines = resizeContent(lines); @@ -143,7 +139,7 @@ public class ModListScreen extends Screen { Component chat = ForgeHooks.newChatWithLinks(line, false); int maxTextLength = this.width - 12; if (maxTextLength >= 0) - ret.addAll(Language.getInstance().getVisualOrder(font.getSplitter().splitLines(chat, maxTextLength, Style.EMPTY))); + ret.addAll(font.split(chat, maxTextLength)); } return ret; } @@ -172,45 +168,36 @@ public class ModListScreen extends Screen { relativeY += headerHeight + PADDING; } - for (FormattedCharSequence line : lines) { - if (line != null) - guiGraphics.drawString(ModListScreen.this.font, line, left + PADDING, relativeY, ARGB.white(1)); - relativeY += font.lineHeight; - } - - final Style component = findTextLine(mouseX, mouseY); - if (component!=null) - guiGraphics.renderComponentHoverEffect(ModListScreen.this.font, component, mouseX, mouseY); + visitText(guiGraphics.textRenderer(GuiGraphics.HoveredTextEffects.TOOLTIP_AND_CURSOR), relativeY); } - private Style findTextLine(final int mouseX, final int mouseY) { - if (!isMouseOver(mouseX, mouseY)) - return null; + private void visitText(ActiveTextCollector collector, int header) { + int x = left + PADDING; + int y = header; - double offset = (mouseY - top - PADDING - border) + scrollDistance; - if (logoPath != null) - offset -= 50; - if (offset <= 0) - return null; - - int lineIdx = (int) (offset / font.lineHeight); - if (lineIdx >= lines.size() || lineIdx < 0) - return null; - - FormattedCharSequence line = lines.get(lineIdx); - if (line != null) - return font.getSplitter().componentStyleAtWidth(line, mouseX - left - border); - return null; + for (int i = 0; i < this.lines.size(); i++) { + var line = this.lines.get(i); + if (line != null) + collector.accept(x, y, line); + y += font.lineHeight; + } } @Override - 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(info, recent); + protected boolean clickPanel(double mouseX, double mouseY, int button) { + var finder = new ActiveTextCollector.ClickableStyleFinder(font, (int)mouseX + left, (int)mouseY); + visitText(finder, logoPath == null ? 0 : 50 + PADDING); + var style = finder.result(); + + if (style == null || style.getClickEvent() == null) + return false; + + var event = style.getClickEvent(); + if (this.client.player == null) + defaultHandleClickEvent(event, this.client, ModListScreen.this); + else + defaultHandleGameClickEvent(event, this.client, ModListScreen.this); + return true; } @Override @@ -382,7 +369,7 @@ public class ModListScreen extends Screen { updateCache(); } - record Logo(ResourceLocation texture, Size2i size) {} + record Logo(Identifier texture, Size2i size) {} private static final Logo NONE = new Logo(null, new Size2i(0, 0)); private void updateCache() { @@ -480,11 +467,11 @@ public class ModListScreen extends Screen { } @Override - public void resize(Minecraft mc, int width, int height) { + public void resize(int width, int height) { String s = this.search.getValue(); SortType sort = this.sortType; ModListWidget.ModEntry selected = this.selected; - this.init(mc, width, height); + this.init(width, height); this.search.setValue(s); this.selected = selected; @@ -501,12 +488,4 @@ public class ModListScreen extends Screen { public void onClose() { this.minecraft.setScreen(this.parentScreen); } - - @Override - protected void handleClickEvent(Minecraft mc, ClickEvent event) { - if (mc.player == null) - defaultHandleClickEvent(event, mc, this); - else - defaultHandleGameClickEvent(event, mc, this); - } } diff --git a/src/main/java/net/minecraftforge/client/gui/ModMismatchDisconnectedScreen.java b/src/main/java/net/minecraftforge/client/gui/ModMismatchDisconnectedScreen.java index 521312aae1..4f5ecf4366 100644 --- a/src/main/java/net/minecraftforge/client/gui/ModMismatchDisconnectedScreen.java +++ b/src/main/java/net/minecraftforge/client/gui/ModMismatchDisconnectedScreen.java @@ -12,16 +12,16 @@ import java.nio.file.Paths; import java.util.ArrayList; import java.util.List; import java.util.Map; -import java.util.Optional; import java.util.stream.Collectors; import net.minecraftforge.client.gui.widget.ScrollPanel; import org.apache.commons.lang3.tuple.Pair; import net.minecraft.ChatFormatting; -import net.minecraft.Util; +import net.minecraft.util.Util; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.gui.TextAlignment; import net.minecraft.client.gui.components.Button; import net.minecraft.client.gui.components.MultiLineLabel; import net.minecraft.client.gui.narration.NarrationElementOutput; @@ -32,8 +32,7 @@ import net.minecraft.network.chat.Component; import net.minecraft.network.chat.HoverEvent; import net.minecraft.network.chat.MutableComponent; import net.minecraft.network.chat.Style; -import net.minecraft.network.chat.TextColor; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.util.FormattedCharSequence; import net.minecraftforge.common.ForgeI18n; import net.minecraftforge.fml.ModList; @@ -41,7 +40,8 @@ import net.minecraftforge.fml.loading.FMLPaths; import net.minecraftforge.network.NetworkContext.NetworkMismatchData; import net.minecraftforge.network.packets.ModVersions; -//TODO: Oh god... Whoever wrote this was on something very very strong. +//TODO: [Forge][Rendering] Rewrite entire ModMismatch screen +//Oh god... Whoever wrote this was on something very very strong. public class ModMismatchDisconnectedScreen extends Screen { private final Component reason; private MultiLineLabel message = MultiLineLabel.EMPTY; @@ -102,7 +102,8 @@ 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.render(guiGraphics, MultiLineLabel.Align.CENTER, this.width / 2, (this.height - this.listHeight - this.textHeight) / 2 - textYOffset, 9, true, -1); + var lineCollector = guiGraphics.textRenderer(GuiGraphics.HoveredTextEffects.notClickable(false)); + this.message.visitLines(TextAlignment.CENTER, this.width / 2, (this.height - this.listHeight - this.textHeight) / 2 - textYOffset, 9, lineCollector); super.render(guiGraphics, mouseX, mouseY, partialTicks); } @@ -134,7 +135,7 @@ public class ModMismatchDisconnectedScreen extends Screen { ) )); int i = 0; - for (ResourceLocation mod : data.missing()) { + for (Identifier mod : data.missing()) { rawTable.add(Pair.of( toModNameComponent(mod, data.mods().get(mod.getNamespace()).name(), i), Pair.of( @@ -223,7 +224,7 @@ public class ModMismatchDisconnectedScreen extends Screen { * @param color Defines the color of the returned style information. An odd number will result in a yellow, an even one in a gold color. This color variation makes it easier for users to distinguish different mod entries. * @return A component with the mod name as the main text component, and an assigned style which will be used for the whole content row. */ - private MutableComponent toModNameComponent(ResourceLocation id, String modName, int color) { + private MutableComponent toModNameComponent(Identifier id, String modName, int color) { String modId = id.getNamespace(); String tooltipId = id.getPath().isEmpty() ? id.getNamespace() : id.toString(); return Component.literal(modName).withStyle(color % 2 == 0 ? ChatFormatting.GOLD : ChatFormatting.YELLOW) @@ -257,7 +258,7 @@ public class ModMismatchDisconnectedScreen extends Screen { FormattedCharSequence name = line.getLeft(); Pair versions = line.getRight(); //Since font#draw does not respect the color of the given component, we have to read it out here and then use it as the last parameter - int color = Optional.ofNullable(font.getSplitter().componentStyleAtWidth(name, 0)).map(Style::getColor).map(TextColor::getValue).orElse(0xFFFFFF); + int color = 0xFFFFFF; //Optional.ofNullable(font.substrByWidth(name, 0)).map(Style::getColor).map(TextColor::getValue).orElse(0xFFFFFF); //Only indent the given name if a version string is present. This makes it easier to distinguish table section headers and mod entries int nameLeft = left + border + (versions == null ? 0 : nameIndent); guiGraphics.drawString(font, name, nameLeft, relativeY + i * 12, color, false); @@ -285,8 +286,8 @@ public class ModMismatchDisconnectedScreen extends Screen { if (slotIndex < contentSize) { //The relative x needs to take the potentially missing indent of the row into account. It does that by checking if the line has a version associated to it double relativeX = x - left - border - (lineTable.get(slotIndex).getRight() == null ? 0 : nameIndent); - if (relativeX >= 0) - return font.getSplitter().componentStyleAtWidth(lineTable.get(slotIndex).getLeft(), (int)relativeX); + //if (relativeX >= 0) + // return font.getSplitter().componentStyleAtWidth(lineTable.get(slotIndex).getLeft(), (int)relativeX); } } @@ -297,7 +298,7 @@ public class ModMismatchDisconnectedScreen extends Screen { public boolean mouseClicked(MouseButtonEvent info, boolean recent) { Style style = getComponentStyleAt(info.x(), info.y()); if (style != null) { - handleComponentClicked(style); + //handleComponentClicked(style); return true; } return super.mouseClicked(info, recent); diff --git a/src/main/java/net/minecraftforge/client/gui/TitleScreenModUpdateIndicator.java b/src/main/java/net/minecraftforge/client/gui/TitleScreenModUpdateIndicator.java index 688df71537..263c81a60d 100644 --- a/src/main/java/net/minecraftforge/client/gui/TitleScreenModUpdateIndicator.java +++ b/src/main/java/net/minecraftforge/client/gui/TitleScreenModUpdateIndicator.java @@ -11,7 +11,7 @@ import net.minecraft.client.gui.screens.TitleScreen; import net.minecraft.client.renderer.RenderPipelines; import net.minecraft.client.gui.screens.Screen; import net.minecraft.network.chat.Component; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraftforge.fml.loading.FMLConfig; import net.minecraftforge.versions.forge.ForgeVersion; import net.minecraftforge.fml.VersionChecker; @@ -19,7 +19,7 @@ import net.minecraftforge.client.loading.ClientModLoader; public class TitleScreenModUpdateIndicator extends Screen { - private static final ResourceLocation VERSION_CHECK_ICONS = ResourceLocation.fromNamespaceAndPath(ForgeVersion.MOD_ID, "textures/gui/version_check_icons.png"); + private static final Identifier VERSION_CHECK_ICONS = Identifier.fromNamespaceAndPath(ForgeVersion.MOD_ID, "textures/gui/version_check_icons.png"); private final Button modButton; private VersionChecker.Status showNotification = null; diff --git a/src/main/java/net/minecraftforge/client/gui/overlay/ForgeGui.java b/src/main/java/net/minecraftforge/client/gui/overlay/ForgeGui.java index 3c010cb736..6eca09eb36 100644 --- a/src/main/java/net/minecraftforge/client/gui/overlay/ForgeGui.java +++ b/src/main/java/net/minecraftforge/client/gui/overlay/ForgeGui.java @@ -18,7 +18,7 @@ import net.minecraft.client.renderer.GameRenderer; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.resources.language.I18n; import net.minecraft.network.chat.Component; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.util.Mth; import net.minecraft.util.StringUtil; import net.minecraft.world.effect.MobEffects; @@ -274,9 +274,9 @@ public class ForgeGui extends Gui { FoodData stats = minecraft.player.getFoodData(); int level = stats.getFoodLevel(); - ResourceLocation empty = FOOD_EMPTY_SPRITE; - ResourceLocation half = FOOD_HALF_SPRITE; - ResourceLocation full = FOOD_FULL_SPRITE; + Identifier empty = FOOD_EMPTY_SPRITE; + Identifier half = FOOD_HALF_SPRITE; + Identifier full = FOOD_FULL_SPRITE; if (player.hasEffect(MobEffects.HUNGER)) { empty = FOOD_EMPTY_HUNGER_SPRITE; 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 895473f94a..fa1eac0902 100644 --- a/src/main/java/net/minecraftforge/client/gui/overlay/ForgeLayeredDraw.java +++ b/src/main/java/net/minecraftforge/client/gui/overlay/ForgeLayeredDraw.java @@ -6,19 +6,17 @@ package net.minecraftforge.client.gui.overlay; import com.mojang.logging.LogUtils; -import net.minecraft.FieldsAreNonnullByDefault; -import net.minecraft.MethodsReturnNonnullByDefault; import net.minecraft.client.DeltaTracker; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.GuiGraphics; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraftforge.client.event.ForgeEventFactoryClient; import net.minecraftforge.client.event.AddGuiOverlayLayersEvent; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.NullMarked; -import javax.annotation.ParametersAreNonnullByDefault; import java.util.*; import java.util.function.BooleanSupplier; @@ -29,47 +27,45 @@ import java.util.function.BooleanSupplier; * Layers must be uniquely named per ForgeLayeredDraw, but may be duplicated across different instances. * Any change which would result in a duplicate will not be applied. * All methods which return a {@linkplain ForgeLayeredDraw} will return its caller's instance. - * To select a specific instance, use {@linkplain ForgeLayeredDraw#locateStack(ResourceLocation)} before adding + * To select a specific instance, use {@linkplain ForgeLayeredDraw#locateStack(Identifier)} before adding * or use the methods that include a stack identifier. */ -@FieldsAreNonnullByDefault -@MethodsReturnNonnullByDefault -@ParametersAreNonnullByDefault +@NullMarked public final class ForgeLayeredDraw implements ForgeLayer { - private final Map namedLayers = new HashMap<>(); - private final Map> subLayerStacks = new HashMap<>(); - private final List order = new LinkedList<>(); + private final Map namedLayers = new HashMap<>(); + private final Map> subLayerStacks = new HashMap<>(); + private final List order = new LinkedList<>(); private final List bakedLayers = new ArrayList<>(); - private final ResourceLocation name; + private final Identifier name; - public static final ResourceLocation PRE_SLEEP_STACK = ResourceLocation.withDefaultNamespace("pre_sleep_phase"); - public static final ResourceLocation CAMERA_OVERLAY = ResourceLocation.withDefaultNamespace("camera_overlay"); - public static final ResourceLocation CROSSHAIR = ResourceLocation.withDefaultNamespace("crosshair"); - public static final ResourceLocation CHANGE_STRATUM = ResourceLocation.withDefaultNamespace("stratum_change"); - public static final ResourceLocation HOTBAR_AND_DECOS = ResourceLocation.withDefaultNamespace("hotbar"); - public static final ResourceLocation POTION_EFFECTS = ResourceLocation.withDefaultNamespace("potion_effects"); - public static final ResourceLocation BOSS_OVERLAY = ResourceLocation.withDefaultNamespace("boss_overlay"); + public static final Identifier PRE_SLEEP_STACK = Identifier.withDefaultNamespace("pre_sleep_phase"); + public static final Identifier CAMERA_OVERLAY = Identifier.withDefaultNamespace("camera_overlay"); + public static final Identifier CROSSHAIR = Identifier.withDefaultNamespace("crosshair"); + public static final Identifier CHANGE_STRATUM = Identifier.withDefaultNamespace("stratum_change"); + public static final Identifier HOTBAR_AND_DECOS = Identifier.withDefaultNamespace("hotbar"); + public static final Identifier POTION_EFFECTS = Identifier.withDefaultNamespace("potion_effects"); + public static final Identifier BOSS_OVERLAY = Identifier.withDefaultNamespace("boss_overlay"); - public static final ResourceLocation POST_SLEEP_STACK = ResourceLocation.withDefaultNamespace("post_sleep_phase"); - public static final ResourceLocation DEMO_OVERLAY = ResourceLocation.withDefaultNamespace("demo"); - public static final ResourceLocation DEBUG_OVERLAY = ResourceLocation.withDefaultNamespace("debug"); - public static final ResourceLocation SCOREBOARD = ResourceLocation.withDefaultNamespace("scoreboard"); - public static final ResourceLocation HOTBAR_MESSAGE = ResourceLocation.withDefaultNamespace("hotbar_message"); - public static final ResourceLocation TITLE_OVERLAY = ResourceLocation.withDefaultNamespace("title"); - public static final ResourceLocation CHAT_OVERLAY = ResourceLocation.withDefaultNamespace("chat_overlay"); - public static final ResourceLocation TAB_LIST = ResourceLocation.withDefaultNamespace("tab_list"); - public static final ResourceLocation SUBTITLE_OVERLAY = ResourceLocation.withDefaultNamespace("subtitle"); + public static final Identifier POST_SLEEP_STACK = Identifier.withDefaultNamespace("post_sleep_phase"); + public static final Identifier DEMO_OVERLAY = Identifier.withDefaultNamespace("demo"); + public static final Identifier DEBUG_OVERLAY = Identifier.withDefaultNamespace("debug"); + public static final Identifier SCOREBOARD = Identifier.withDefaultNamespace("scoreboard"); + public static final Identifier HOTBAR_MESSAGE = Identifier.withDefaultNamespace("hotbar_message"); + public static final Identifier TITLE_OVERLAY = Identifier.withDefaultNamespace("title"); + public static final Identifier CHAT_OVERLAY = Identifier.withDefaultNamespace("chat_overlay"); + public static final Identifier TAB_LIST = Identifier.withDefaultNamespace("tab_list"); + public static final Identifier SUBTITLE_OVERLAY = Identifier.withDefaultNamespace("subtitle"); - public static final ResourceLocation VANILLA_ROOT = ResourceLocation.withDefaultNamespace("vanilla_root"); - public static final ResourceLocation SLEEP_OVERLAY = ResourceLocation.withDefaultNamespace("sleep_overlay"); + public static final Identifier VANILLA_ROOT = Identifier.withDefaultNamespace("vanilla_root"); + public static final Identifier SLEEP_OVERLAY = Identifier.withDefaultNamespace("sleep_overlay"); private static final ForgeLayeredDraw instance = new ForgeLayeredDraw(VANILLA_ROOT); /** - * Creates an empty draw list. Add entries with {@linkplain ForgeLayeredDraw#add(ResourceLocation, ForgeLayer)} + * Creates an empty draw list. Add entries with {@linkplain ForgeLayeredDraw#add(Identifier, ForgeLayer)} * @param name marker for which phase this is. */ - public ForgeLayeredDraw(ResourceLocation name) { + public ForgeLayeredDraw(Identifier name) { this.name = name; } @@ -81,7 +77,7 @@ public final class ForgeLayeredDraw implements ForgeLayer { * @param supplier condition for this stack to render * @return this */ - public ForgeLayeredDraw add(ResourceLocation name, ForgeLayeredDraw layeredDraw, BooleanSupplier supplier) { + public ForgeLayeredDraw add(Identifier name, ForgeLayeredDraw layeredDraw, BooleanSupplier supplier) { if (isNameAvailable(name)) { subLayerStacks.put(name, Map.entry(layeredDraw, supplier)); order.add(name); @@ -98,7 +94,7 @@ public final class ForgeLayeredDraw implements ForgeLayer { * @param layer layer render code, see {@linkplain ForgeLayer} and example usages in {@linkplain Gui} * @return this */ - public ForgeLayeredDraw add(ResourceLocation targetStack, ResourceLocation name, ForgeLayer layer) { + public ForgeLayeredDraw add(Identifier targetStack, Identifier name, ForgeLayer layer) { locateStack(targetStack).ifPresentOrElse((stack) -> stack.add(name, layer), () -> stackNotPresentWarning(targetStack)); return this; } @@ -106,12 +102,12 @@ public final class ForgeLayeredDraw implements ForgeLayer { /** * Helper method, assumes the intended draw stack instance is the caller. * Use any of the non-deprecated add methods if you want a specific instance, - * or call {@linkplain ForgeLayeredDraw#locateStack(ResourceLocation)} to get a reference to an instance. + * or call {@linkplain ForgeLayeredDraw#locateStack(Identifier)} to get a reference to an instance. * @param name RL of layer to add * @param layer layer render code, see {@linkplain ForgeLayer} and example usages in {@linkplain Gui} * @return this */ - public ForgeLayeredDraw add(ResourceLocation name, ForgeLayer layer) { + public ForgeLayeredDraw add(Identifier name, ForgeLayer layer) { if (isNameAvailable(name)) { namedLayers.put(name, layer); order.add(name); @@ -124,12 +120,12 @@ public final class ForgeLayeredDraw implements ForgeLayer { /** * Use to specify where your custom draw stack should go. Can also be used to re-order layers. * Both target and destination must be in the same draw stack. - * @param expectedStack Which ForgeLayeredDraw the target is expected to be in. If you already have a reference to it, you can use {@linkplain ForgeLayeredDraw#move(ResourceLocation, ResourceLocation, LayerOffset)} + * @param expectedStack Which ForgeLayeredDraw the target is expected to be in. If you already have a reference to it, you can use {@linkplain ForgeLayeredDraw#move(Identifier, Identifier, LayerOffset)} * @param target layer name to move * @param destination layer name to order against * @return this */ - public ForgeLayeredDraw putAbove(ResourceLocation expectedStack, ResourceLocation target, ResourceLocation destination) { + public ForgeLayeredDraw putAbove(Identifier expectedStack, Identifier target, Identifier destination) { locateStack(expectedStack).ifPresentOrElse((stack) -> stack.move(target, destination, LayerOffset.ABOVE), () -> stackNotPresentWarning(expectedStack)); return this; } @@ -137,12 +133,12 @@ public final class ForgeLayeredDraw implements ForgeLayer { /** * Use to specify where your custom draw stack should go. Can also be used to re-order layers. * Both target and destination must be in the same draw stack. - * @param expectedStack Which ForgeLayeredDraw the target is expected to be in. If you already have a reference to it, you can use {@linkplain ForgeLayeredDraw#move(ResourceLocation, ResourceLocation, LayerOffset)} + * @param expectedStack Which ForgeLayeredDraw the target is expected to be in. If you already have a reference to it, you can use {@linkplain ForgeLayeredDraw#move(Identifier, Identifier, LayerOffset)} * @param target layer name to move * @param destination layer name to order against * @return this */ - public ForgeLayeredDraw putBelow(ResourceLocation expectedStack, ResourceLocation target, ResourceLocation destination) { + public ForgeLayeredDraw putBelow(Identifier expectedStack, Identifier target, Identifier destination) { locateStack(expectedStack).ifPresentOrElse((stack) -> stack.move(target, destination, LayerOffset.BELOW), () -> stackNotPresentWarning(expectedStack)); return this; } @@ -155,7 +151,7 @@ public final class ForgeLayeredDraw implements ForgeLayer { * @param offset Self-explanatory * @return this */ - public ForgeLayeredDraw move(ResourceLocation target, ResourceLocation destination, LayerOffset offset) { + public ForgeLayeredDraw move(Identifier target, Identifier destination, LayerOffset offset) { if (!order.contains(target)) { layerNotPresentWarning(target); return this; @@ -179,7 +175,7 @@ public final class ForgeLayeredDraw implements ForgeLayer { * @param layer layer render code, see {@linkplain ForgeLayer} and example usages in {@linkplain Gui} * @return this */ - public ForgeLayeredDraw addAbove(ResourceLocation expectedStack, ResourceLocation newLayer, ResourceLocation otherLayer, ForgeLayer layer) { + public ForgeLayeredDraw addAbove(Identifier expectedStack, Identifier newLayer, Identifier otherLayer, ForgeLayer layer) { locateStack(expectedStack).ifPresentOrElse((stack) -> { if (!stack.isNameAvailable(otherLayer)) { stack.add(newLayer, layer).move(newLayer, otherLayer, LayerOffset.ABOVE); @@ -193,7 +189,7 @@ public final class ForgeLayeredDraw implements ForgeLayer { /** * Helper method, assumes intended draw stack is the caller */ - public ForgeLayeredDraw addAbove(ResourceLocation newLayer, ResourceLocation otherLayer, ForgeLayer layer) { + public ForgeLayeredDraw addAbove(Identifier newLayer, Identifier otherLayer, ForgeLayer layer) { return addAbove(name, newLayer, otherLayer, layer); } @@ -206,7 +202,7 @@ public final class ForgeLayeredDraw implements ForgeLayer { * @param layer layer render code, see {@linkplain ForgeLayer} and example usages in {@linkplain Gui} * @return this */ - public ForgeLayeredDraw addBelow(ResourceLocation expectedStack, ResourceLocation newLayer, ResourceLocation otherLayer, ForgeLayer layer) { + public ForgeLayeredDraw addBelow(Identifier expectedStack, Identifier newLayer, Identifier otherLayer, ForgeLayer layer) { locateStack(expectedStack).ifPresentOrElse((stack) -> { if (!stack.isNameAvailable(otherLayer)) { stack.add(newLayer, layer).move(newLayer, otherLayer, LayerOffset.BELOW); @@ -220,7 +216,7 @@ public final class ForgeLayeredDraw implements ForgeLayer { /** * Helper method, assumes intended draw stack is the caller */ - public ForgeLayeredDraw addBelow(ResourceLocation newLayer, ResourceLocation otherLayer, ForgeLayer layer) { + public ForgeLayeredDraw addBelow(Identifier newLayer, Identifier otherLayer, ForgeLayer layer) { return addBelow(name, newLayer, otherLayer, layer); } @@ -232,7 +228,7 @@ public final class ForgeLayeredDraw implements ForgeLayer { * @param condition supplier for the condition * @return this */ - public ForgeLayeredDraw addWithCondition(ResourceLocation targetStack, ResourceLocation name, ForgeLayer layer, BooleanSupplier condition) { + public ForgeLayeredDraw addWithCondition(Identifier targetStack, Identifier name, ForgeLayer layer, BooleanSupplier condition) { locateStack(targetStack).ifPresentOrElse((stack) -> stack.addWithCondition(name, layer, condition), () -> stackNotPresentWarning(targetStack)); return this; } @@ -244,7 +240,7 @@ public final class ForgeLayeredDraw implements ForgeLayer { * @param condition supplier for the condition * @return this */ - public ForgeLayeredDraw addWithCondition(ResourceLocation name, ForgeLayer layer, BooleanSupplier condition) { + public ForgeLayeredDraw addWithCondition(Identifier name, ForgeLayer layer, BooleanSupplier condition) { add(name, layer).addConditionTo(name, condition); return this; } @@ -257,20 +253,20 @@ public final class ForgeLayeredDraw implements ForgeLayer { * @param condition supplier for the condition * @return this */ - public ForgeLayeredDraw addConditionTo(ResourceLocation targetStack, ResourceLocation targetLayer, BooleanSupplier condition) { + public ForgeLayeredDraw addConditionTo(Identifier targetStack, Identifier targetLayer, BooleanSupplier condition) { locateStack(targetStack).ifPresentOrElse((stack) -> stack.addConditionTo(targetLayer, condition), () -> stackNotPresentWarning(targetStack)); return this; } /** * Assumes the correct stack is the caller of this method. - * Use {@linkplain ForgeLayeredDraw#addConditionTo(ResourceLocation, ResourceLocation, BooleanSupplier)} + * Use {@linkplain ForgeLayeredDraw#addConditionTo(Identifier, Identifier, BooleanSupplier)} * if you do not have a reference to the draw stack you want. * @param targetLayer name of layer to add condition to * @param condition supplier for the condition * @return this */ - public ForgeLayeredDraw addConditionTo(ResourceLocation targetLayer, BooleanSupplier condition) { + public ForgeLayeredDraw addConditionTo(Identifier targetLayer, BooleanSupplier condition) { var result = namedLayers.computeIfPresent(targetLayer, (name, layer) -> (guiGraphics, deltaTracker) -> { if (condition.getAsBoolean()) { @@ -303,7 +299,7 @@ public final class ForgeLayeredDraw implements ForgeLayer { * Parent layer stack {@linkplain ForgeLayeredDraw#VANILLA_ROOT} holds the results. */ private void resolveNested() { - for (ResourceLocation layerName : order) { + for (Identifier layerName : order) { if (subLayerStacks.containsKey(layerName)) { var entry = subLayerStacks.get(layerName); entry.getKey().resolveNested(); @@ -322,7 +318,7 @@ public final class ForgeLayeredDraw implements ForgeLayer { * @param targetStack Name of ForgeLayeredDraw to find * @return Filled Optional if target exists, empty otherwise. */ - public Optional locateStack(ResourceLocation targetStack) { + public Optional locateStack(Identifier targetStack) { if (!name.equals(targetStack)) { for (Map.Entry value : subLayerStacks.values()) { if (value.getKey() instanceof ForgeLayeredDraw searchable) { @@ -337,32 +333,32 @@ public final class ForgeLayeredDraw implements ForgeLayer { } @Nullable - public ForgeLayeredDraw getChild(ResourceLocation childName) { + public ForgeLayeredDraw getChild(Identifier childName) { return locateStack(childName).orElse(null); } @Nullable - public ForgeLayer getLayer(ResourceLocation layerName) { + public ForgeLayer getLayer(Identifier layerName) { return namedLayers.get(layerName); } - public ResourceLocation getName() { + public Identifier getName() { return name; } - private void stackNotPresentWarning(ResourceLocation stackName) { - LogUtils.getLogger().warn("Target stack {} was not present anywhere. Is your ResourceLocation correct?", stackName); + private void stackNotPresentWarning(Identifier stackName) { + LogUtils.getLogger().warn("Target stack {} was not present anywhere. Is your Identifier correct?", stackName); } - private void layerNotPresentWarning(ResourceLocation layer) { + private void layerNotPresentWarning(Identifier layer) { LogUtils.getLogger().warn("Expected layer {} was not found in stack {}, no layer modifications have been made.", layer, name); } - private void nameTakenWarning(ResourceLocation layer) { + private void nameTakenWarning(Identifier layer) { LogUtils.getLogger().warn("Name {} was already present in {} and cannot be re-used.", layer, name); } - private boolean isNameAvailable(ResourceLocation name) { + private boolean isNameAvailable(Identifier name) { return !namedLayers.containsKey(name) && !subLayerStacks.containsKey(name); } diff --git a/src/main/java/net/minecraftforge/client/gui/overlay/GuiOverlayManager.java b/src/main/java/net/minecraftforge/client/gui/overlay/GuiOverlayManager.java index d2d78911c1..0815c527d9 100644 --- a/src/main/java/net/minecraftforge/client/gui/overlay/GuiOverlayManager.java +++ b/src/main/java/net/minecraftforge/client/gui/overlay/GuiOverlayManager.java @@ -8,7 +8,7 @@ package net.minecraftforge.client.gui.overlay; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraftforge.client.event.RegisterGuiOverlaysEvent; import net.minecraftforge.fml.ModLoader; import org.jetbrains.annotations.ApiStatus; @@ -26,7 +26,7 @@ import java.util.function.Function; public final class GuiOverlayManager { private static ImmutableList OVERLAYS; - private static ImmutableMap OVERLAYS_BY_NAME; + private static ImmutableMap OVERLAYS_BY_NAME; /** * Retrieves an ordered list of all registered overlays. @@ -41,7 +41,7 @@ public final class GuiOverlayManager * Do not call this before {@link RegisterGuiOverlaysEvent} has finished firing. * / @Nullable - public static NamedGuiOverlay findOverlay(ResourceLocation id) + public static NamedGuiOverlay findOverlay(Identifier id) { return OVERLAYS_BY_NAME.get(id); } @@ -49,8 +49,8 @@ public final class GuiOverlayManager @ApiStatus.Internal public static void init() { - var overlays = new HashMap(); - var orderedOverlays = new ArrayList(); + var overlays = new HashMap(); + var orderedOverlays = new ArrayList(); preRegisterVanillaOverlays(overlays, orderedOverlays); var event = new RegisterGuiOverlaysEvent(overlays, orderedOverlays); ModLoader.get().postEventWrapContainerInModOrder(event); @@ -65,7 +65,7 @@ public final class GuiOverlayManager /** * Pre-registers vanilla overlays so they are available for ordering. * / - private static void preRegisterVanillaOverlays(HashMap overlays, ArrayList orderedOverlays) + private static void preRegisterVanillaOverlays(HashMap overlays, ArrayList orderedOverlays) { for (var entry : VanillaGuiOverlay.values()) { diff --git a/src/main/java/net/minecraftforge/client/gui/overlay/NamedGuiOverlay.java b/src/main/java/net/minecraftforge/client/gui/overlay/NamedGuiOverlay.java index a7c0a13968..432c42da5e 100644 --- a/src/main/java/net/minecraftforge/client/gui/overlay/NamedGuiOverlay.java +++ b/src/main/java/net/minecraftforge/client/gui/overlay/NamedGuiOverlay.java @@ -6,7 +6,7 @@ /** Forge 1.20.5 - Removed, Mojang created a layered rendering system that should make this all obsolete finally.. - Lex 042724 package net.minecraftforge.client.gui.overlay; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import org.jetbrains.annotations.ApiStatus; /** @@ -16,7 +16,7 @@ import org.jetbrains.annotations.ApiStatus; *

    * Users should not be instantiating this themselves. Retrieve from {@link GuiOverlayManager}. * / -public record NamedGuiOverlay(ResourceLocation id, IGuiOverlay overlay) +public record NamedGuiOverlay(Identifier id, IGuiOverlay overlay) { @ApiStatus.Internal public NamedGuiOverlay diff --git a/src/main/java/net/minecraftforge/client/gui/overlay/VanillaGuiOverlay.java b/src/main/java/net/minecraftforge/client/gui/overlay/VanillaGuiOverlay.java index 93231144f9..42a9364a59 100644 --- a/src/main/java/net/minecraftforge/client/gui/overlay/VanillaGuiOverlay.java +++ b/src/main/java/net/minecraftforge/client/gui/overlay/VanillaGuiOverlay.java @@ -8,7 +8,7 @@ package net.minecraftforge.client.gui.overlay; import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.client.Minecraft; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.util.Mth; import net.minecraft.world.effect.MobEffects; import net.minecraft.world.entity.Entity; @@ -216,17 +216,17 @@ public enum VanillaGuiOverlay { gui.renderPlayerList(screenWidth, screenHeight, guiGraphics); }); - private final ResourceLocation id; + private final Identifier id; final IGuiOverlay overlay; NamedGuiOverlay type; VanillaGuiOverlay(String id, IGuiOverlay overlay) { - this.id = new ResourceLocation("minecraft", id); + this.id = new Identifier("minecraft", id); this.overlay = overlay; } @NotNull - public ResourceLocation id() { + public Identifier id() { return id; } diff --git a/src/main/java/net/minecraftforge/client/gui/widget/ExtendedButton.java b/src/main/java/net/minecraftforge/client/gui/widget/ExtendedButton.java index 1ecc4fd5be..47646512d4 100644 --- a/src/main/java/net/minecraftforge/client/gui/widget/ExtendedButton.java +++ b/src/main/java/net/minecraftforge/client/gui/widget/ExtendedButton.java @@ -38,7 +38,7 @@ public class ExtendedButton extends Button { * Draws this button to the screen. */ @Override - public void renderWidget(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) { + public void renderContents(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) { Minecraft mc = Minecraft.getInstance(); guiGraphics.blitSprite(RenderPipelines.GUI_TEXTURED, SPRITES.get(this.active, this.isHoveredOrFocused()), this.getX(), this.getY(), this.getWidth(), this.getHeight()); 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 b822b436a7..77c33edf9c 100644 --- a/src/main/java/net/minecraftforge/client/gui/widget/ForgeSlider.java +++ b/src/main/java/net/minecraftforge/client/gui/widget/ForgeSlider.java @@ -198,10 +198,9 @@ public class ForgeSlider extends AbstractSliderButton { @Override public void renderWidget(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) { - final Minecraft mc = Minecraft.getInstance(); guiGraphics.blitSprite(RenderPipelines.GUI_TEXTURED, this.getSprite(), this.getX(), this.getY(), this.getWidth(), this.getHeight()); guiGraphics.blitSprite(RenderPipelines.GUI_TEXTURED, this.getHandleSprite(), this.getX() + (int)(this.value * (double)(this.width - 8)), this.getY(), 8, this.getHeight()); - renderScrollingString(guiGraphics, mc.font, 2, getFGColor() | Mth.ceil(this.alpha * 255.0F) << 24); + renderScrollingStringOverContents(guiGraphics.textRendererForWidget(this, GuiGraphics.HoveredTextEffects.NONE), this.getMessage(), 2); } } 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 7307c49d18..930b42579d 100644 --- a/src/main/java/net/minecraftforge/client/gui/widget/ModListWidget.java +++ b/src/main/java/net/minecraftforge/client/gui/widget/ModListWidget.java @@ -10,7 +10,7 @@ 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.resources.Identifier; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.FormattedText; import net.minecraft.locale.Language; @@ -22,7 +22,7 @@ import net.minecraftforge.forgespi.language.IModInfo; public class ModListWidget extends ObjectSelectionList { private static String stripControlCodes(String value) { return net.minecraft.util.StringUtil.stripColor(value); } - private static final ResourceLocation VERSION_CHECK_ICONS = ResourceLocation.fromNamespaceAndPath(ForgeVersion.MOD_ID, "textures/gui/version_check_icons.png"); + private static final Identifier VERSION_CHECK_ICONS = Identifier.fromNamespaceAndPath(ForgeVersion.MOD_ID, "textures/gui/version_check_icons.png"); private final int listWidth; private final ModListScreen parent; 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 b28db0fc9f..14603ece18 100644 --- a/src/main/java/net/minecraftforge/client/gui/widget/ScrollPanel.java +++ b/src/main/java/net/minecraftforge/client/gui/widget/ScrollPanel.java @@ -19,7 +19,7 @@ import java.util.List; * Abstract scroll panel class. */ public abstract class ScrollPanel extends AbstractContainerEventHandler implements Renderable, NarratableEntry { - private final Minecraft client; + protected final Minecraft client; protected final int width; protected final int height; protected final int top; diff --git a/src/main/java/net/minecraftforge/client/loading/ForgeLoadingOverlay.java b/src/main/java/net/minecraftforge/client/loading/ForgeLoadingOverlay.java index 3471617faa..530d75bf69 100644 --- a/src/main/java/net/minecraftforge/client/loading/ForgeLoadingOverlay.java +++ b/src/main/java/net/minecraftforge/client/loading/ForgeLoadingOverlay.java @@ -10,7 +10,7 @@ import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.screens.LoadingOverlay; -import net.minecraft.client.renderer.RenderType; +import net.minecraft.client.renderer.rendertype.RenderType; import net.minecraft.server.packs.resources.ReloadInstance; import net.minecraft.util.ARGB; import net.minecraft.util.Mth; @@ -33,6 +33,7 @@ import java.util.function.Supplier; * * It is somewhat a copy of the superclass render method. */ +@SuppressWarnings("unused") public class ForgeLoadingOverlay extends LoadingOverlay { private static final boolean ENABLE = false; //Boolean.parseBoolean("forge.enableForgeLoadingOverlay"); private final Minecraft minecraft; diff --git a/src/main/java/net/minecraftforge/client/model/DynamicFluidContainerModel.java b/src/main/java/net/minecraftforge/client/model/DynamicFluidContainerModel.java index ce057c7273..dbaeff1e4e 100644 --- a/src/main/java/net/minecraftforge/client/model/DynamicFluidContainerModel.java +++ b/src/main/java/net/minecraftforge/client/model/DynamicFluidContainerModel.java @@ -18,7 +18,7 @@ import net.minecraft.client.resources.model.ModelDebugName; import net.minecraft.client.resources.model.ModelState; import net.minecraft.client.resources.model.QuadCollection; import net.minecraft.client.resources.model.UnbakedGeometry; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.util.GsonHelper; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.Fluids; @@ -65,7 +65,7 @@ public class DynamicFluidContainerModel implements UnbakedGeometry { } @SuppressWarnings("deprecation") - private static Material getMaterial(ResourceLocation texture) { + private static Material getMaterial(Identifier texture) { return new Material(TextureAtlas.LOCATION_BLOCKS, texture); } @@ -116,7 +116,7 @@ public class DynamicFluidContainerModel implements UnbakedGeometry { if (baseSprite != null) { // Base texture var unbaked = UnbakedGeometryHelper.createUnbakedItemElements(0, baseSprite.contents()); - UnbakedGeometryHelper.bakeElements(unbaked, $ -> baseSprite, state, buf); + UnbakedGeometryHelper.bakeElements(baker.parts(), unbaked, $ -> baseSprite, state, buf); } if (fluidMaskLocation != null && fluidSprite != null) { @@ -126,10 +126,11 @@ public class DynamicFluidContainerModel implements UnbakedGeometry { var transformedState = new SimpleModelState(transformation.compose(FLUID_TRANSFORM)); var unbaked = UnbakedGeometryHelper.createUnbakedItemMaskElements(1, templateSprite.contents()); // Use template as mask - var emissive = applyFluidLuminosity && fluid.getFluidType().getLightLevel() > 0; - var transformer = emissive ? QuadTransformers.settingMaxEmissivity() : QuadTransformers.empty(); + //var emissive = applyFluidLuminosity && fluid.getFluidType().getLightLevel() > 0; + //var transformer = emissive ? QuadTransformers.settingMaxEmissivity() : QuadTransformers.empty(); + // TODO: [Forge][Rendering] Emissive fluid models - UnbakedGeometryHelper.bakeElements(unbaked, $ -> fluidSprite, transformedState, transformer, buf); // Bake with fluid texture + UnbakedGeometryHelper.bakeElements(baker.parts(), unbaked, $ -> fluidSprite, transformedState, buf); // Bake with fluid texture } } @@ -139,7 +140,7 @@ public class DynamicFluidContainerModel implements UnbakedGeometry { // Cover/overlay var transformedState = new SimpleModelState(transformation.compose(COVER_TRANSFORM)); var unbaked = UnbakedGeometryHelper.createUnbakedItemMaskElements(2, coverSprite.contents()); // Use cover as mask - UnbakedGeometryHelper.bakeElements(unbaked, $ -> sprite, transformedState, buf); // Bake with selected texture + UnbakedGeometryHelper.bakeElements(baker.parts(), unbaked, $ -> sprite, transformedState, buf); // Bake with selected texture } } @@ -154,7 +155,7 @@ public class DynamicFluidContainerModel implements UnbakedGeometry { @Override public UnbakedGeometry read(JsonObject jsonObject, JsonDeserializationContext deserializationContext) { - var fluidName = ResourceLocation.parse(GsonHelper.getAsString(jsonObject, "fluid")); + var fluidName = Identifier.parse(GsonHelper.getAsString(jsonObject, "fluid")); Fluid fluid = ForgeRegistries.FLUIDS.getValue(fluidName); diff --git a/src/main/java/net/minecraftforge/client/model/ForgeBlockModelData.java b/src/main/java/net/minecraftforge/client/model/ForgeBlockModelData.java index a231a87daf..58a1904262 100644 --- a/src/main/java/net/minecraftforge/client/model/ForgeBlockModelData.java +++ b/src/main/java/net/minecraftforge/client/model/ForgeBlockModelData.java @@ -10,12 +10,12 @@ import java.util.Optional; import com.mojang.math.Transformation; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; public record ForgeBlockModelData( Optional transform, - Optional renderType, - Optional renderTypeFast, + Optional renderType, + Optional renderTypeFast, Optional> visibility ) { public ForgeBlockModelData() { diff --git a/src/main/java/net/minecraftforge/client/model/ForgeFaceData.java b/src/main/java/net/minecraftforge/client/model/ForgeFaceData.java index bf2a533296..75762294f9 100644 --- a/src/main/java/net/minecraftforge/client/model/ForgeFaceData.java +++ b/src/main/java/net/minecraftforge/client/model/ForgeFaceData.java @@ -5,13 +5,10 @@ package net.minecraftforge.client.model; -import java.util.function.Function; - import javax.annotation.Nullable; import com.google.gson.JsonElement; import com.google.gson.JsonParseException; -import com.mojang.datafixers.util.Either; import com.mojang.serialization.Codec; import com.mojang.serialization.JsonOps; import com.mojang.serialization.codecs.RecordCodecBuilder; @@ -23,27 +20,17 @@ import net.minecraft.client.renderer.block.model.BlockElementFace; * Holds extra data that may be injected into a face.

    * Used by {@link ItemLayerGeometry}, {@link BlockElement} and {@link BlockElementFace} * - * @param color Color in ARGB format - * @param blockLight Block Light for this face from 0-15 (inclusive) - * @param skyLight Sky Light for this face from 0-15 (inclusive) * @param ambientOcclusion If this face has AO * @param calculateNormals If we should manually calculate the normals for this block or inherit facing normals like vanilla */ -public record ForgeFaceData(int color, int blockLight, int skyLight, boolean ambientOcclusion, boolean calculateNormals) { - public ForgeFaceData(int color, int blockLight, int skyLight, boolean ambientOcclusion) { - this(color, blockLight, skyLight, ambientOcclusion, false); +public record ForgeFaceData(boolean ambientOcclusion, boolean calculateNormals) { + public ForgeFaceData(boolean ambientOcclusion) { + this(ambientOcclusion, false); } - public static final ForgeFaceData DEFAULT = new ForgeFaceData(0xFFFFFFFF, 0, 0, true, false); - - public static final Codec COLOR = Codec.either(Codec.INT, Codec.STRING).xmap( - either -> either.map(Function.identity(), str -> (int) Long.parseLong(str, 16)), - color -> Either.right(Integer.toHexString(color))); + public static final ForgeFaceData DEFAULT = new ForgeFaceData(true, false); public static final Codec CODEC = RecordCodecBuilder.create(builder -> builder.group( - COLOR.optionalFieldOf("color", 0xFFFFFFFF).forGetter(ForgeFaceData::color), - Codec.intRange(0, 15).optionalFieldOf("block_light", 0).forGetter(ForgeFaceData::blockLight), - Codec.intRange(0, 15).optionalFieldOf("sky_light", 0).forGetter(ForgeFaceData::skyLight), Codec.BOOL.optionalFieldOf("ambient_occlusion", true).forGetter(ForgeFaceData::ambientOcclusion), Codec.BOOL.optionalFieldOf("calculate_normals", false).forGetter(ForgeFaceData::calculateNormals)) .apply(builder, ForgeFaceData::new)); diff --git a/src/main/java/net/minecraftforge/client/model/IModelBuilder.java b/src/main/java/net/minecraftforge/client/model/IModelBuilder.java deleted file mode 100644 index 0d8d4fd07d..0000000000 --- a/src/main/java/net/minecraftforge/client/model/IModelBuilder.java +++ /dev/null @@ -1,160 +0,0 @@ -/* - * Copyright (c) Forge Development LLC and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.minecraftforge.client.model; - -import net.minecraft.client.renderer.block.model.BakedQuad; -import net.minecraft.client.renderer.block.model.ItemTransforms; -import net.minecraft.client.renderer.block.model.SimpleModelWrapper; -import net.minecraft.client.renderer.item.EmptyModel; -import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.client.renderer.block.model.BlockModelPart; -import net.minecraft.client.resources.model.QuadCollection; -import net.minecraft.core.Direction; -import net.minecraft.resources.ResourceLocation; -import net.minecraftforge.client.RenderTypeGroup; - -import java.util.List; - -/** - * Base interface for any object that collects culled and unculled faces and bakes them into a model. - *

    - * Provides a generic base implementation via {@link #of(boolean, boolean, boolean, ItemTransforms, TextureAtlasSprite, RenderTypeGroup, RenderTypeGroup)} - * and a quad-collecting alternative via {@link #collecting(List)}. - * - * @deprecated Use {@link net.minecraft.client.resources.model.QuadCollection} instead. - */ -@Deprecated(forRemoval = true, since = "1.21.5") -public interface IModelBuilder> { - /** - * Creates a new model builder that uses the provided attributes in the final baked model. - */ - static IModelBuilder of( - boolean hasAmbientOcclusion, - boolean usesBlockLight, - boolean isGui3d, - ItemTransforms transforms, - TextureAtlasSprite particle - ){ - return of(hasAmbientOcclusion, usesBlockLight, isGui3d, transforms, particle, RenderTypeGroup.EMPTY); - } - - static IModelBuilder of( - boolean hasAmbientOcclusion, - boolean usesBlockLight, - boolean isGui3d, - ItemTransforms transforms, - TextureAtlasSprite particle, - RenderTypeGroup renderTypes - ){ - return new Simple(hasAmbientOcclusion, usesBlockLight, isGui3d, transforms, particle, renderTypes); - } - - static IModelBuilder of( - boolean hasAmbientOcclusion, - boolean usesBlockLight, - boolean isGui3d, - ItemTransforms transforms, - TextureAtlasSprite particle, - RenderTypeGroup renderTypes, - RenderTypeGroup renderTypesFast - ){ - return new Simple(hasAmbientOcclusion, usesBlockLight, isGui3d, transforms, particle, renderTypes, renderTypesFast); - } - - /** - * Creates a new model builder that collects quads to the provided list, returning - * {@linkplain EmptyModel#BAKED an empty model} if you call {@link #build()}. - */ - static IModelBuilder collecting(List quads) { - return new Collecting(quads); - } - - T addCulledFace(Direction facing, BakedQuad quad); - - T addUnculledFace(BakedQuad quad); - - BlockModelPart build(); - - class Simple implements IModelBuilder { - private final QuadCollection.Builder builder; - - private final boolean hasAmbientOcclusion; - - // TODO: [VEN] These are UNUSED, and this is GOING TO BREAK. - private final boolean usesBlockLight; - private final boolean isGui3d; - private final ItemTransforms transforms; - private final TextureAtlasSprite particle; - private final RenderTypeGroup renderTypes; - private final RenderTypeGroup renderTypesFast; - - private Simple( - boolean hasAmbientOcclusion, boolean usesBlockLight, boolean isGui3d, - ItemTransforms transforms, TextureAtlasSprite particle, RenderTypeGroup renderTypes - ) { - this(hasAmbientOcclusion, usesBlockLight, isGui3d, transforms, particle, renderTypes, RenderTypeGroup.EMPTY); - } - - private Simple( - boolean hasAmbientOcclusion, boolean usesBlockLight, boolean isGui3d, - ItemTransforms transforms, TextureAtlasSprite particle, RenderTypeGroup renderTypes, RenderTypeGroup renderTypesFast - ) { - this.builder = new QuadCollection.Builder(); - this.hasAmbientOcclusion = hasAmbientOcclusion; - this.usesBlockLight = usesBlockLight; - this.isGui3d = isGui3d; - this.transforms = transforms; - this.particle = particle; - this.renderTypes = renderTypes; - this.renderTypesFast = renderTypesFast; - } - - @Override - public Simple addCulledFace(Direction facing, BakedQuad quad) { - builder.addCulledFace(facing, quad); - return this; - } - - @Override - public Simple addUnculledFace(BakedQuad quad) { - builder.addUnculledFace(quad); - return this; - } - - @Override - public BlockModelPart build() { - var quads = builder.build(); - // TODO: [VEN] Models will NOT be complete here!!!! - return new SimpleModelWrapper(quads, hasAmbientOcclusion, particle); - } - } - - class Collecting implements IModelBuilder { - private static final BlockModelPart EMPTY = new SimpleModelWrapper(QuadCollection.EMPTY, false, new TextureAtlasSprite(ResourceLocation.fromNamespaceAndPath("forge", "empty"), null, 0, 0, 0, 0) {}); - private final List quads; - - private Collecting(List quads) { - this.quads = quads; - } - - @Override - public Collecting addCulledFace(Direction facing, BakedQuad quad) { - quads.add(quad); - return this; - } - - @Override - public Collecting addUnculledFace(BakedQuad quad) { - quads.add(quad); - return this; - } - - @Override - public BlockModelPart build() { - return EMPTY; - } - } -} diff --git a/src/main/java/net/minecraftforge/client/model/IQuadTransformer.java b/src/main/java/net/minecraftforge/client/model/IQuadTransformer.java index 222dfe498b..57e8797951 100644 --- a/src/main/java/net/minecraftforge/client/model/IQuadTransformer.java +++ b/src/main/java/net/minecraftforge/client/model/IQuadTransformer.java @@ -5,8 +5,6 @@ package net.minecraftforge.client.model; -import com.mojang.blaze3d.vertex.DefaultVertexFormat; -import com.mojang.blaze3d.vertex.VertexFormatElement; import net.minecraft.client.renderer.block.model.BakedQuad; import java.util.List; @@ -17,14 +15,6 @@ import java.util.List; */ @FunctionalInterface public interface IQuadTransformer { - int STRIDE = DefaultVertexFormat.BLOCK.getVertexSize() / 4; - int POSITION = findOffset(VertexFormatElement.POSITION); - int COLOR = findOffset(VertexFormatElement.COLOR); - int UV0 = findOffset(VertexFormatElement.UV0); - int UV1 = findOffset(VertexFormatElement.UV1); - int UV2 = findOffset(VertexFormatElement.UV2); - int NORMAL = findOffset(VertexFormatElement.NORMAL); - BakedQuad process(BakedQuad quad); default List process(List inputs) { @@ -34,10 +24,4 @@ public interface IQuadTransformer { default IQuadTransformer andThen(IQuadTransformer other) { return quad -> other.process(process(quad)); } - - private static int findOffset(VertexFormatElement element) { - // Divide by 4 because we want the int offset - var index = DefaultVertexFormat.BLOCK.getOffset(element); - return index < 0 ? -1 : index / 4; - } } diff --git a/src/main/java/net/minecraftforge/client/model/ItemLayerGeometry.java b/src/main/java/net/minecraftforge/client/model/ItemLayerGeometry.java index aac7241062..7911ec3164 100644 --- a/src/main/java/net/minecraftforge/client/model/ItemLayerGeometry.java +++ b/src/main/java/net/minecraftforge/client/model/ItemLayerGeometry.java @@ -12,7 +12,7 @@ import com.google.gson.JsonParseException; import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.Int2ObjectMaps; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; -import net.minecraft.client.renderer.RenderType; +import net.minecraft.client.renderer.rendertype.RenderType; import net.minecraft.client.renderer.block.model.ItemModelGenerator; import net.minecraft.client.renderer.block.model.SimpleUnbakedGeometry; import net.minecraft.client.renderer.block.model.TextureSlots; @@ -24,7 +24,7 @@ import net.minecraft.client.resources.model.ModelDebugName; import net.minecraft.client.resources.model.ModelState; import net.minecraft.client.resources.model.QuadCollection; import net.minecraft.client.resources.model.UnbakedGeometry; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraftforge.client.ForgeRenderTypes; import net.minecraftforge.client.RenderTypeGroup; import net.minecraftforge.client.model.geometry.IGeometryBakingContext; @@ -47,10 +47,10 @@ import org.jetbrains.annotations.Nullable; public class ItemLayerGeometry implements UnbakedGeometry { private static final ItemLayerGeometry INSTANCE = new ItemLayerGeometry(Int2ObjectMaps.emptyMap(), Int2ObjectMaps.emptyMap()); - private final Int2ObjectMap renderTypeNames; - private final Int2ObjectMap renderTypeFastNames; + private final Int2ObjectMap renderTypeNames; + private final Int2ObjectMap renderTypeFastNames; - private ItemLayerGeometry(Int2ObjectMap renderTypeNames, Int2ObjectMap renderTypeFastNames) { + private ItemLayerGeometry(Int2ObjectMap renderTypeNames, Int2ObjectMap renderTypeFastNames) { this.renderTypeNames = renderTypeNames; this.renderTypeFastNames = renderTypeFastNames; } @@ -69,7 +69,7 @@ public class ItemLayerGeometry implements UnbakedGeometry { elements.addAll(ItemModelGenerator.processFrames(i, layer, contents)); } - return SimpleUnbakedGeometry.bake(elements, textures, baker.sprites(), state, name); + return SimpleUnbakedGeometry.bake(elements, textures, baker, state, name); /* Material particleMaterial = spriteGetter.getMaterial("particle"); var particle = baker.sprites().get(particleMaterial == null ? textures.get(0) : particleMaterial, name); @@ -107,12 +107,12 @@ public class ItemLayerGeometry implements UnbakedGeometry { */ } - private static Int2ObjectMap readRenderTypeNames(JsonObject jsonObject, String key) { - var renderTypeNames = new Int2ObjectOpenHashMap(); + private static Int2ObjectMap readRenderTypeNames(JsonObject jsonObject, String key) { + var renderTypeNames = new Int2ObjectOpenHashMap(); if (jsonObject.has(key)) { var renderTypes = jsonObject.getAsJsonObject(key); for (var entry : renderTypes.entrySet()) { - var renderType = ResourceLocation.parse(entry.getKey()); + var renderType = Identifier.parse(entry.getKey()); for (var layer : entry.getValue().getAsJsonArray()) if (renderTypeNames.put(layer.getAsInt(), renderType) != null) throw new JsonParseException("Registered duplicate " + key + " for layer " + layer); diff --git a/src/main/java/net/minecraftforge/client/model/QuadTransformers.java b/src/main/java/net/minecraftforge/client/model/QuadTransformers.java index 7772864796..e222ede4aa 100644 --- a/src/main/java/net/minecraftforge/client/model/QuadTransformers.java +++ b/src/main/java/net/minecraftforge/client/model/QuadTransformers.java @@ -5,16 +5,12 @@ package net.minecraftforge.client.model; -import com.google.common.base.Preconditions; import com.mojang.math.Transformation; -import net.minecraft.Util; -import net.minecraft.client.renderer.LightTexture; import net.minecraft.client.renderer.block.model.BakedQuad; import org.joml.Vector3f; +import org.joml.Vector3fc; import org.joml.Vector4f; -import java.util.Arrays; - /** * A collection of {@link IQuadTransformer} implementations. * @@ -22,9 +18,6 @@ import java.util.Arrays; */ public final class QuadTransformers { private static final IQuadTransformer EMPTY = quad -> quad; - private static final IQuadTransformer[] EMISSIVE_TRANSFORMERS = Util.make(new IQuadTransformer[16], array -> { - Arrays.setAll(array, i -> applyingLightmap(LightTexture.pack(i, i))); - }); /** * {@return a {@link BakedQuad} transformer that does nothing} @@ -41,116 +34,19 @@ public final class QuadTransformers { return empty(); return quad -> { - var vertices = Arrays.copyOf(quad.vertices(), quad.vertices().length); + var positions = new Vector3fc[4]; for (int i = 0; i < 4; i++) { - int offset = i * IQuadTransformer.STRIDE + IQuadTransformer.POSITION; - float x = Float.intBitsToFloat(vertices[offset]); - float y = Float.intBitsToFloat(vertices[offset + 1]); - float z = Float.intBitsToFloat(vertices[offset + 2]); - - Vector4f pos = new Vector4f(x, y, z, 1); + var pos = new Vector4f(quad.position(i), 1); transform.transformPosition(pos); pos.div(pos.w); - - vertices[offset] = Float.floatToRawIntBits(pos.x()); - vertices[offset + 1] = Float.floatToRawIntBits(pos.y()); - vertices[offset + 2] = Float.floatToRawIntBits(pos.z()); + positions[i] = new Vector3f(pos.x(), pos.y(), pos.z()); } - for (int i = 0; i < 4; i++) { - int offset = i * IQuadTransformer.STRIDE + IQuadTransformer.NORMAL; - int normalIn = vertices[offset]; - if ((normalIn & 0x00FFFFFF) != 0) { // The ignored byte is padding and may be filled with user data - float x = ((byte) (normalIn & 0xFF)) / 127.0f; - float y = ((byte) ((normalIn >> 8) & 0xFF)) / 127.0f; - float z = ((byte) ((normalIn >> 16) & 0xFF)) / 127.0f; - - Vector3f pos = new Vector3f(x, y, z); - transform.transformNormal(pos); - - vertices[offset] = (((byte) (pos.x() * 127.0f)) & 0xFF) | - ((((byte) (pos.y() * 127.0f)) & 0xFF) << 8) | - ((((byte) (pos.z() * 127.0f)) & 0xFF) << 16) | - (normalIn & 0xFF000000); // Restore padding, just in case - } - } - - return new BakedQuad(vertices, quad.tintIndex(), quad.direction(), quad.sprite(), quad.shade(), quad.lightEmission(), quad.ambientOcclusion()); + return new BakedQuad(positions[0], positions[1], positions[2], positions[3], + quad.packedUV0(), quad.packedUV1(), quad.packedUV2(), quad.packedUV3(), + quad.tintIndex(), quad.direction(), quad.sprite(), quad.shade(), quad.lightEmission(), quad.ambientOcclusion()); }; } - - /** - * @return A new {@link BakedQuad} transformer that applies the specified packed light value. - */ - public static IQuadTransformer applyingLightmap(int packedLight) { - return quad -> { - var vertices = Arrays.copyOf(quad.vertices(), quad.vertices().length); - for (int i = 0; i < 4; i++) - vertices[i * IQuadTransformer.STRIDE + IQuadTransformer.UV2] = packedLight; - return new BakedQuad(vertices, quad.tintIndex(), quad.direction(), quad.sprite(), quad.shade(), quad.lightEmission(), quad.ambientOcclusion()); - }; - } - - /** - * @return A new {@link BakedQuad} transformer that applies the specified block and sky light values. - */ - public static IQuadTransformer applyingLightmap(int blockLight, int skyLight) { - return applyingLightmap(LightTexture.pack(blockLight, skyLight)); - } - - /** - * @return A {@link BakedQuad} transformer that sets the lightmap to the given emissivity (0-15) - */ - public static IQuadTransformer settingEmissivity(int emissivity) { - Preconditions.checkArgument(emissivity >= 0 && emissivity < 16, "Emissivity must be between 0 and 15."); - return EMISSIVE_TRANSFORMERS[emissivity]; - } - - /** - * @return A {@link BakedQuad} transformer that sets the lightmap to its max value - */ - public static IQuadTransformer settingMaxEmissivity() { - return EMISSIVE_TRANSFORMERS[15]; - } - - /** - * @param color The color in ARGB format. - * @return A {@link BakedQuad} transformer that sets the color to the specified value. - */ - public static IQuadTransformer applyingColor(int color) { - final int fixedColor = toABGR(color); - return quad -> { - var vertices = Arrays.copyOf(quad.vertices(), quad.vertices().length); - - for (int i = 0; i < 4; i++) - vertices[i * IQuadTransformer.STRIDE + IQuadTransformer.COLOR] = fixedColor; - - return new BakedQuad(vertices, quad.tintIndex(), quad.direction(), quad.sprite(), quad.shade(), quad.lightEmission(), quad.ambientOcclusion()); - }; - } - - /** - * This method supplies a default alpha value of 255 (no transparency) - * @param red The red value (0-255) - * @param green The green value (0-255) - * @param blue The blue value (0-255) - * @return A {@link BakedQuad} transformer that sets the color to the specified value. - */ - public static IQuadTransformer applyingColor(int red, int green, int blue) { - return applyingColor(255, red, green, blue); - } - - /** - * @param alpha The alpha value (0-255) - * @param red The red value (0-255) - * @param green The green value (0-255) - * @param blue The blue value (0-255) - * @return A {@link BakedQuad} transformer that sets the color to the specified value. - */ - public static IQuadTransformer applyingColor(int alpha, int red, int green, int blue) { - return applyingColor(alpha << 24 | red << 16 | green << 8 | blue); - } - /** * Converts an ARGB color to an ABGR color, as the commonly used color format is not the format colors end up packed into. * This function doubles as its own inverse. diff --git a/src/main/java/net/minecraftforge/client/model/generators/BlockModelBuilder.java b/src/main/java/net/minecraftforge/client/model/generators/BlockModelBuilder.java deleted file mode 100644 index c56532c64e..0000000000 --- a/src/main/java/net/minecraftforge/client/model/generators/BlockModelBuilder.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) Forge Development LLC and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.minecraftforge.client.model.generators; - -import com.google.gson.JsonObject; -import net.minecraft.resources.ResourceLocation; -import net.minecraftforge.common.data.ExistingFileHelper; - -/** - * Builder for block models, does not currently provide any additional - * functionality over {@link ModelBuilder}, purely a stub class with a concrete - * generic. - * - * @see ModelProvider - * @see ModelBuilder - * - * In 1.21.4 Mojang exposed their data generators for their models. So it should be feasible to just use theirs. - * If you find something lacking feel free to open a PR so that we can extend it. - * @deprecated Use Vanilla's providers {@link net.minecraft.client.data.models.ModelProvider} - */ -@Deprecated(since = "1.21.4", forRemoval = true) -public class BlockModelBuilder extends ModelBuilder -{ - public BlockModelBuilder(ResourceLocation outputLocation, ExistingFileHelper existingFileHelper) - { - super(outputLocation, existingFileHelper); - } - - @Override - public JsonObject toJson() - { - return super.toJson(); - } -} diff --git a/src/main/java/net/minecraftforge/client/model/generators/BlockModelProvider.java b/src/main/java/net/minecraftforge/client/model/generators/BlockModelProvider.java deleted file mode 100644 index 797f918394..0000000000 --- a/src/main/java/net/minecraftforge/client/model/generators/BlockModelProvider.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) Forge Development LLC and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.minecraftforge.client.model.generators; - -import net.minecraft.data.PackOutput; -import net.minecraftforge.common.data.ExistingFileHelper; -import org.jetbrains.annotations.NotNull; - -/** - * Stub class to extend for block model data providers, eliminates some - * boilerplate constructor parameters. - * - * In 1.21.4 Mojang exposed their data generators for their models. So it should be feasible to just use theirs. - * If you find something lacking feel free to open a PR so that we can extend it. - * @deprecated Use Vanilla's providers {@link net.minecraft.client.data.models.ModelProvider} - */ -@Deprecated(since = "1.21.4", forRemoval = true) -public abstract class BlockModelProvider extends ModelProvider { - - public BlockModelProvider(PackOutput output, String modid, ExistingFileHelper existingFileHelper) { - super(output, modid, BLOCK_FOLDER, BlockModelBuilder::new, existingFileHelper); - } - - @NotNull - @Override - public String getName() { - return "Block Models: " + modid; - } -} diff --git a/src/main/java/net/minecraftforge/client/model/generators/BlockStateProvider.java b/src/main/java/net/minecraftforge/client/model/generators/BlockStateProvider.java deleted file mode 100644 index 9066656f3f..0000000000 --- a/src/main/java/net/minecraftforge/client/model/generators/BlockStateProvider.java +++ /dev/null @@ -1,1136 +0,0 @@ -/* - * Copyright (c) Forge Development LLC and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.minecraftforge.client.model.generators; - -import com.google.common.base.Preconditions; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; - -import java.nio.file.Path; -import java.util.Arrays; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.CompletableFuture; -import java.util.function.Function; -import net.minecraft.core.Direction; -import net.minecraft.core.Direction.Axis; -import net.minecraft.data.CachedOutput; -import net.minecraft.data.DataProvider; -import net.minecraft.data.PackOutput; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.ButtonBlock; -import net.minecraft.world.level.block.CrossCollisionBlock; -import net.minecraft.world.level.block.DoorBlock; -import net.minecraft.world.level.block.FenceBlock; -import net.minecraft.world.level.block.FenceGateBlock; -import net.minecraft.world.level.block.IronBarsBlock; -import net.minecraft.world.level.block.PipeBlock; -import net.minecraft.world.level.block.PressurePlateBlock; -import net.minecraft.world.level.block.RotatedPillarBlock; -import net.minecraft.world.level.block.SlabBlock; -import net.minecraft.world.level.block.StairBlock; -import net.minecraft.world.level.block.StandingSignBlock; -import net.minecraft.world.level.block.TrapDoorBlock; -import net.minecraft.world.level.block.WallBlock; -import net.minecraft.world.level.block.WallSignBlock; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.block.state.properties.AttachFace; -import net.minecraft.world.level.block.state.properties.BlockStateProperties; -import net.minecraft.world.level.block.state.properties.DoorHingeSide; -import net.minecraft.world.level.block.state.properties.DoubleBlockHalf; -import net.minecraft.world.level.block.state.properties.Half; -import net.minecraft.world.level.block.state.properties.Property; -import net.minecraft.world.level.block.state.properties.SlabType; -import net.minecraft.world.level.block.state.properties.StairsShape; -import net.minecraft.world.level.block.state.properties.WallSide; -import net.minecraftforge.common.data.ExistingFileHelper; -import net.minecraftforge.registries.ForgeRegistries; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.VisibleForTesting; - -/** - * Data provider for blockstate files. Extends {@link BlockModelProvider} so that - * blockstates and their referenced models can be provided in tandem. - * - * In 1.21.4 Mojang exposed their data generators for their models. So it should be feasible to just use theirs. - * If you find something lacking feel free to open a PR so that we can extend it. - * @deprecated Use Vanilla's providers {@link net.minecraft.client.data.models.ModelProvider} - */ -@Deprecated(since = "1.21.4", forRemoval = true) -public abstract class BlockStateProvider implements DataProvider { - - @SuppressWarnings("unused") - private static final Logger LOGGER = LogManager.getLogger(); - @SuppressWarnings("unused") - private static final Gson GSON = (new GsonBuilder()).setPrettyPrinting().disableHtmlEscaping().create(); - - @VisibleForTesting - protected final Map registeredBlocks = new LinkedHashMap<>(); - - private final PackOutput output; - private final String modid; - private final BlockModelProvider blockModels; - private final ItemModelProvider itemModels; - - public BlockStateProvider(PackOutput output, String modid, ExistingFileHelper exFileHelper) { - this.output = output; - this.modid = modid; - this.blockModels = new BlockModelProvider(output, modid, exFileHelper) { - @Override public CompletableFuture run(CachedOutput cache) { return CompletableFuture.allOf(); } - - @Override protected void registerModels() {} - }; - this.itemModels = new ItemModelProvider(output, modid, this.blockModels.existingFileHelper) { - @Override protected void registerModels() {} - - @Override public CompletableFuture run(CachedOutput cache) { return CompletableFuture.allOf(); } - }; - } - - @Override - public CompletableFuture run(CachedOutput cache) { - models().clear(); - itemModels().clear(); - registeredBlocks.clear(); - registerStatesAndModels(); - CompletableFuture[] futures = new CompletableFuture[2 + this.registeredBlocks.size()]; - int i = 0; - futures[i++] = models().generateAll(cache); - futures[i++] = itemModels().generateAll(cache); - for (Map.Entry entry : registeredBlocks.entrySet()) { - futures[i++] = saveBlockState(cache, entry.getValue().toJson(), entry.getKey()); - } - return CompletableFuture.allOf(futures); - } - - protected abstract void registerStatesAndModels(); - - public VariantBlockStateBuilder getVariantBuilder(Block b) { - if (registeredBlocks.containsKey(b)) { - IGeneratedBlockState old = registeredBlocks.get(b); - Preconditions.checkState(old instanceof VariantBlockStateBuilder); - return (VariantBlockStateBuilder) old; - } else { - VariantBlockStateBuilder ret = new VariantBlockStateBuilder(b); - registeredBlocks.put(b, ret); - return ret; - } - } - - public MultiPartBlockStateBuilder getMultipartBuilder(Block b) { - if (registeredBlocks.containsKey(b)) { - IGeneratedBlockState old = registeredBlocks.get(b); - Preconditions.checkState(old instanceof MultiPartBlockStateBuilder); - return (MultiPartBlockStateBuilder) old; - } else { - MultiPartBlockStateBuilder ret = new MultiPartBlockStateBuilder(b); - registeredBlocks.put(b, ret); - return ret; - } - } - - public BlockModelProvider models() { - return blockModels; - } - - public ItemModelProvider itemModels() { - return itemModels; - } - - public ResourceLocation modLoc(String name) { - return ResourceLocation.fromNamespaceAndPath(modid, name); - } - - public ResourceLocation mcLoc(String name) { - return ResourceLocation.parse(name); - } - - private ResourceLocation key(Block block) { - return ForgeRegistries.BLOCKS.getKey(block); - } - - private String name(Block block) { - return key(block).getPath(); - } - - public ResourceLocation blockTexture(Block block) { - return key(block).withPath(p -> ModelProvider.BLOCK_FOLDER + '/' + p); - } - - private ResourceLocation extend(ResourceLocation rl, String suffix) { - return rl.withSuffix(suffix); - } - - public ModelFile cubeAll(Block block) { - return models().cubeAll(name(block), blockTexture(block)); - } - - public void simpleBlock(Block block) { - simpleBlock(block, cubeAll(block)); - } - - public void simpleBlock(Block block, Function expander) { - simpleBlock(block, expander.apply(cubeAll(block))); - } - - public void simpleBlock(Block block, ModelFile model) { - simpleBlock(block, new ConfiguredModel(model)); - } - - public void simpleBlockItem(Block block, ModelFile model) { - itemModels().getBuilder(key(block).getPath()).parent(model); - } - - public void simpleBlockWithItem(Block block, ModelFile model) { - simpleBlock(block, model); - simpleBlockItem(block, model); - } - - public void simpleBlock(Block block, ConfiguredModel... models) { - getVariantBuilder(block) - .partialState().setModels(models); - } - - public void axisBlock(RotatedPillarBlock block) { - axisBlock(block, blockTexture(block)); - } - - public void logBlock(RotatedPillarBlock block) { - axisBlock(block, blockTexture(block), extend(blockTexture(block), "_top")); - } - - public void axisBlock(RotatedPillarBlock block, ResourceLocation baseName) { - axisBlock(block, extend(baseName, "_side"), extend(baseName, "_end")); - } - - public void axisBlock(RotatedPillarBlock block, ResourceLocation side, ResourceLocation end) { - axisBlock(block, - models().cubeColumn(name(block), side, end), - models().cubeColumnHorizontal(name(block) + "_horizontal", side, end)); - } - - public void axisBlockWithRenderType(RotatedPillarBlock block, String renderType) { - axisBlockWithRenderType(block, blockTexture(block), renderType); - } - - public void logBlockWithRenderType(RotatedPillarBlock block, String renderType) { - axisBlockWithRenderType(block, blockTexture(block), extend(blockTexture(block), "_top"), renderType); - } - - public void axisBlockWithRenderType(RotatedPillarBlock block, ResourceLocation baseName, String renderType) { - axisBlockWithRenderType(block, extend(baseName, "_side"), extend(baseName, "_end"), renderType); - } - - public void axisBlockWithRenderType(RotatedPillarBlock block, ResourceLocation side, ResourceLocation end, String renderType) { - axisBlock(block, - models().cubeColumn(name(block), side, end).renderType(renderType), - models().cubeColumnHorizontal(name(block) + "_horizontal", side, end).renderType(renderType)); - } - - public void axisBlockWithRenderType(RotatedPillarBlock block, ResourceLocation renderType) { - axisBlockWithRenderType(block, blockTexture(block), renderType); - } - - public void logBlockWithRenderType(RotatedPillarBlock block, ResourceLocation renderType) { - axisBlockWithRenderType(block, blockTexture(block), extend(blockTexture(block), "_top"), renderType); - } - - public void axisBlockWithRenderType(RotatedPillarBlock block, ResourceLocation baseName, ResourceLocation renderType) { - axisBlockWithRenderType(block, extend(baseName, "_side"), extend(baseName, "_end"), renderType); - } - - public void axisBlockWithRenderType(RotatedPillarBlock block, ResourceLocation side, ResourceLocation end, ResourceLocation renderType) { - axisBlock(block, - models().cubeColumn(name(block), side, end).renderType(renderType), - models().cubeColumnHorizontal(name(block) + "_horizontal", side, end).renderType(renderType)); - } - - public void axisBlockWithRenderTypeAndFast(RotatedPillarBlock block, String renderType, String renderTypeFast) { - axisBlockWithRenderTypeAndFast(block, blockTexture(block), renderType, renderTypeFast); - } - - public void logBlockWithRenderTypeAndFast(RotatedPillarBlock block, String renderType, String renderTypeFast) { - axisBlockWithRenderTypeAndFast(block, blockTexture(block), extend(blockTexture(block), "_top"), renderType, renderTypeFast); - } - - public void axisBlockWithRenderTypeAndFast(RotatedPillarBlock block, ResourceLocation baseName, String renderType, String renderTypeFast) { - axisBlockWithRenderTypeAndFast(block, extend(baseName, "_side"), extend(baseName, "_end"), renderType, renderTypeFast); - } - - public void axisBlockWithRenderTypeAndFast(RotatedPillarBlock block, ResourceLocation side, ResourceLocation end, String renderType, String renderTypeFast) { - axisBlock(block, - models().cubeColumn(name(block), side, end).renderType(renderType, renderTypeFast), - models().cubeColumnHorizontal(name(block) + "_horizontal", side, end).renderType(renderType, renderTypeFast)); - } - - public void axisBlockWithRenderTypeAndFast(RotatedPillarBlock block, ResourceLocation renderType, ResourceLocation renderTypeFast) { - axisBlockWithRenderTypeAndFast(block, blockTexture(block), renderType, renderTypeFast); - } - - public void logBlockWithRenderType(RotatedPillarBlock block, ResourceLocation renderType, ResourceLocation renderTypeFast) { - axisBlockWithRenderTypeAndFast(block, blockTexture(block), extend(blockTexture(block), "_top"), renderType, renderTypeFast); - } - - public void axisBlockWithRenderTypeAndFast(RotatedPillarBlock block, ResourceLocation baseName, ResourceLocation renderType, ResourceLocation renderTypeFast) { - axisBlockWithRenderTypeAndFast(block, extend(baseName, "_side"), extend(baseName, "_end"), renderType, renderTypeFast); - } - - public void axisBlockWithRenderTypeAndFast(RotatedPillarBlock block, ResourceLocation side, ResourceLocation end, ResourceLocation renderType, ResourceLocation renderTypeFast) { - axisBlock(block, - models().cubeColumn(name(block), side, end).renderType(renderType, renderTypeFast), - models().cubeColumnHorizontal(name(block) + "_horizontal", side, end).renderType(renderType, renderTypeFast)); - } - - public void axisBlock(RotatedPillarBlock block, ModelFile vertical, ModelFile horizontal) { - getVariantBuilder(block) - .partialState().with(RotatedPillarBlock.AXIS, Axis.Y) - .modelForState().modelFile(vertical).addModel() - .partialState().with(RotatedPillarBlock.AXIS, Axis.Z) - .modelForState().modelFile(horizontal).rotationX(90).addModel() - .partialState().with(RotatedPillarBlock.AXIS, Axis.X) - .modelForState().modelFile(horizontal).rotationX(90).rotationY(90).addModel(); - } - - private static final int DEFAULT_ANGLE_OFFSET = 180; - - public void horizontalBlock(Block block, ResourceLocation side, ResourceLocation front, ResourceLocation top) { - horizontalBlock(block, models().orientable(name(block), side, front, top)); - } - - public void horizontalBlock(Block block, ModelFile model) { - horizontalBlock(block, model, DEFAULT_ANGLE_OFFSET); - } - - public void horizontalBlock(Block block, ModelFile model, int angleOffset) { - horizontalBlock(block, $ -> model, angleOffset); - } - - public void horizontalBlock(Block block, Function modelFunc) { - horizontalBlock(block, modelFunc, DEFAULT_ANGLE_OFFSET); - } - - public void horizontalBlock(Block block, Function modelFunc, int angleOffset) { - getVariantBuilder(block) - .forAllStates(state -> ConfiguredModel.builder() - .modelFile(modelFunc.apply(state)) - .rotationY(((int) state.getValue(BlockStateProperties.HORIZONTAL_FACING).toYRot() + angleOffset) % 360) - .build() - ); - } - - public void horizontalFaceBlock(Block block, ModelFile model) { - horizontalFaceBlock(block, model, DEFAULT_ANGLE_OFFSET); - } - - public void horizontalFaceBlock(Block block, ModelFile model, int angleOffset) { - horizontalFaceBlock(block, $ -> model, angleOffset); - } - - public void horizontalFaceBlock(Block block, Function modelFunc) { - horizontalFaceBlock(block, modelFunc, DEFAULT_ANGLE_OFFSET); - } - - public void horizontalFaceBlock(Block block, Function modelFunc, int angleOffset) { - getVariantBuilder(block) - .forAllStates(state -> ConfiguredModel.builder() - .modelFile(modelFunc.apply(state)) - .rotationX(state.getValue(BlockStateProperties.ATTACH_FACE).ordinal() * 90) - .rotationY((((int) state.getValue(BlockStateProperties.HORIZONTAL_FACING).toYRot() + angleOffset) + (state.getValue(BlockStateProperties.ATTACH_FACE) == AttachFace.CEILING ? 180 : 0)) % 360) - .build() - ); - } - - public void directionalBlock(Block block, ModelFile model) { - directionalBlock(block, model, DEFAULT_ANGLE_OFFSET); - } - - public void directionalBlock(Block block, ModelFile model, int angleOffset) { - directionalBlock(block, $ -> model, angleOffset); - } - - public void directionalBlock(Block block, Function modelFunc) { - directionalBlock(block, modelFunc, DEFAULT_ANGLE_OFFSET); - } - - public void directionalBlock(Block block, Function modelFunc, int angleOffset) { - getVariantBuilder(block) - .forAllStates(state -> { - Direction dir = state.getValue(BlockStateProperties.FACING); - return ConfiguredModel.builder() - .modelFile(modelFunc.apply(state)) - .rotationX(dir == Direction.DOWN ? 180 : dir.getAxis().isHorizontal() ? 90 : 0) - .rotationY(dir.getAxis().isVertical() ? 0 : (((int) dir.toYRot()) + angleOffset) % 360) - .build(); - }); - } - - public void stairsBlock(StairBlock block, ResourceLocation texture) { - stairsBlock(block, texture, texture, texture); - } - - public void stairsBlock(StairBlock block, String name, ResourceLocation texture) { - stairsBlock(block, name, texture, texture, texture); - } - - public void stairsBlock(StairBlock block, ResourceLocation side, ResourceLocation bottom, ResourceLocation top) { - stairsBlockInternal(block, key(block).toString(), side, bottom, top); - } - - public void stairsBlock(StairBlock block, String name, ResourceLocation side, ResourceLocation bottom, ResourceLocation top) { - stairsBlockInternal(block, name + "_stairs", side, bottom, top); - } - - public void stairsBlockWithRenderType(StairBlock block, ResourceLocation texture, String renderType) { - stairsBlockWithRenderType(block, texture, texture, texture, renderType); - } - - public void stairsBlockWithRenderType(StairBlock block, String name, ResourceLocation texture, String renderType) { - stairsBlockWithRenderType(block, name, texture, texture, texture, renderType); - } - - public void stairsBlockWithRenderType(StairBlock block, ResourceLocation side, ResourceLocation bottom, ResourceLocation top, String renderType) { - stairsBlockInternalWithRenderType(block, key(block).toString(), side, bottom, top, ResourceLocation.tryParse(renderType)); - } - - public void stairsBlockWithRenderType(StairBlock block, String name, ResourceLocation side, ResourceLocation bottom, ResourceLocation top, String renderType) { - stairsBlockInternalWithRenderType(block, name + "_stairs", side, bottom, top, ResourceLocation.tryParse(renderType)); - } - - public void stairsBlockWithRenderType(StairBlock block, ResourceLocation texture, ResourceLocation renderType) { - stairsBlockWithRenderType(block, texture, texture, texture, renderType); - } - - public void stairsBlockWithRenderType(StairBlock block, String name, ResourceLocation texture, ResourceLocation renderType) { - stairsBlockWithRenderType(block, name, texture, texture, texture, renderType); - } - - public void stairsBlockWithRenderType(StairBlock block, ResourceLocation side, ResourceLocation bottom, ResourceLocation top, ResourceLocation renderType) { - stairsBlockInternalWithRenderType(block, key(block).toString(), side, bottom, top, renderType); - } - - public void stairsBlockWithRenderType(StairBlock block, String name, ResourceLocation side, ResourceLocation bottom, ResourceLocation top, ResourceLocation renderType) { - stairsBlockInternalWithRenderType(block, name + "_stairs", side, bottom, top, renderType); - } - - public void stairsBlockWithRenderTypeAndFast(StairBlock block, ResourceLocation texture, String renderType, String renderTypeFast) { - stairsBlockWithRenderTypeAndFast(block, texture, texture, texture, renderType, renderTypeFast); - } - - public void stairsBlockWithRenderTypeAndFast(StairBlock block, String name, ResourceLocation texture, String renderType, String renderTypeFast) { - stairsBlockWithRenderTypeAndFast(block, name, texture, texture, texture, renderType, renderTypeFast); - } - - public void stairsBlockWithRenderTypeAndFast(StairBlock block, ResourceLocation side, ResourceLocation bottom, ResourceLocation top, String renderType, String renderTypeFast) { - stairsBlockInternalWithRenderTypeAndFast(block, key(block).toString(), side, bottom, top, ResourceLocation.tryParse(renderType), ResourceLocation.tryParse(renderTypeFast)); - } - - public void stairsBlockWithRenderTypeAndFast(StairBlock block, String name, ResourceLocation side, ResourceLocation bottom, ResourceLocation top, String renderType, String renderTypeFast) { - stairsBlockInternalWithRenderTypeAndFast(block, name + "_stairs", side, bottom, top, ResourceLocation.tryParse(renderType), ResourceLocation.tryParse(renderTypeFast)); - } - - public void stairsBlockWithRenderTypeAndFast(StairBlock block, ResourceLocation texture, ResourceLocation renderType, ResourceLocation renderTypeFast) { - stairsBlockWithRenderTypeAndFast(block, texture, texture, texture, renderType, renderTypeFast); - } - - public void stairsBlockWithRenderTypeAndFast(StairBlock block, String name, ResourceLocation texture, ResourceLocation renderType, ResourceLocation renderTypeFast) { - stairsBlockWithRenderTypeAndFast(block, name, texture, texture, texture, renderType, renderTypeFast); - } - - public void stairsBlockWithRenderTypeAndFast(StairBlock block, ResourceLocation side, ResourceLocation bottom, ResourceLocation top, ResourceLocation renderType, ResourceLocation renderTypeFast) { - stairsBlockInternalWithRenderTypeAndFast(block, key(block).toString(), side, bottom, top, renderType, renderTypeFast); - } - - public void stairsBlockWithRenderTypeAndFast(StairBlock block, String name, ResourceLocation side, ResourceLocation bottom, ResourceLocation top, ResourceLocation renderType, ResourceLocation renderTypeFast) { - stairsBlockInternalWithRenderTypeAndFast(block, name + "_stairs", side, bottom, top, renderType, renderTypeFast); - } - - private void stairsBlockInternal(StairBlock block, String baseName, ResourceLocation side, ResourceLocation bottom, ResourceLocation top) { - ModelFile stairs = models().stairs(baseName, side, bottom, top); - ModelFile stairsInner = models().stairsInner(baseName + "_inner", side, bottom, top); - ModelFile stairsOuter = models().stairsOuter(baseName + "_outer", side, bottom, top); - stairsBlock(block, stairs, stairsInner, stairsOuter); - } - - private void stairsBlockInternalWithRenderType(StairBlock block, String baseName, ResourceLocation side, ResourceLocation bottom, ResourceLocation top, ResourceLocation renderType) { - ModelFile stairs = models().stairs(baseName, side, bottom, top).renderType(renderType); - ModelFile stairsInner = models().stairsInner(baseName + "_inner", side, bottom, top).renderType(renderType); - ModelFile stairsOuter = models().stairsOuter(baseName + "_outer", side, bottom, top).renderType(renderType); - stairsBlock(block, stairs, stairsInner, stairsOuter); - } - - private void stairsBlockInternalWithRenderTypeAndFast(StairBlock block, String baseName, ResourceLocation side, ResourceLocation bottom, ResourceLocation top, ResourceLocation renderType, ResourceLocation renderTypeFast) { - ModelFile stairs = models().stairs(baseName, side, bottom, top).renderType(renderType, renderTypeFast); - ModelFile stairsInner = models().stairsInner(baseName + "_inner", side, bottom, top).renderType(renderType, renderTypeFast); - ModelFile stairsOuter = models().stairsOuter(baseName + "_outer", side, bottom, top).renderType(renderType, renderTypeFast); - stairsBlock(block, stairs, stairsInner, stairsOuter); - } - - public void stairsBlock(StairBlock block, ModelFile stairs, ModelFile stairsInner, ModelFile stairsOuter) { - getVariantBuilder(block) - .forAllStatesExcept(state -> { - Direction facing = state.getValue(StairBlock.FACING); - Half half = state.getValue(StairBlock.HALF); - StairsShape shape = state.getValue(StairBlock.SHAPE); - int yRot = (int) facing.getClockWise().toYRot(); // Stairs model is rotated 90 degrees clockwise for some reason - if (shape == StairsShape.INNER_LEFT || shape == StairsShape.OUTER_LEFT) { - yRot += 270; // Left facing stairs are rotated 90 degrees clockwise - } - if (shape != StairsShape.STRAIGHT && half == Half.TOP) { - yRot += 90; // Top stairs are rotated 90 degrees clockwise - } - yRot %= 360; - boolean uvlock = yRot != 0 || half == Half.TOP; // Don't set uvlock for states that have no rotation - return ConfiguredModel.builder() - .modelFile(shape == StairsShape.STRAIGHT ? stairs : shape == StairsShape.INNER_LEFT || shape == StairsShape.INNER_RIGHT ? stairsInner : stairsOuter) - .rotationX(half == Half.BOTTOM ? 0 : 180) - .rotationY(yRot) - .uvLock(uvlock) - .build(); - }, StairBlock.WATERLOGGED); - } - - public void slabBlock(SlabBlock block, ResourceLocation doubleslab, ResourceLocation texture) { - slabBlock(block, doubleslab, texture, texture, texture); - } - - public void slabBlock(SlabBlock block, ResourceLocation doubleslab, ResourceLocation side, ResourceLocation bottom, ResourceLocation top) { - slabBlock(block, models().slab(name(block), side, bottom, top), models().slabTop(name(block) + "_top", side, bottom, top), models().getExistingFile(doubleslab)); - } - - public void slabBlock(SlabBlock block, ModelFile bottom, ModelFile top, ModelFile doubleslab) { - getVariantBuilder(block) - .partialState().with(SlabBlock.TYPE, SlabType.BOTTOM).addModels(new ConfiguredModel(bottom)) - .partialState().with(SlabBlock.TYPE, SlabType.TOP).addModels(new ConfiguredModel(top)) - .partialState().with(SlabBlock.TYPE, SlabType.DOUBLE).addModels(new ConfiguredModel(doubleslab)); - } - - public void buttonBlock(ButtonBlock block, ResourceLocation texture) { - ModelFile button = models().button(name(block), texture); - ModelFile buttonPressed = models().buttonPressed(name(block) + "_pressed", texture); - buttonBlock(block, button, buttonPressed); - } - - public void buttonBlock(ButtonBlock block, ModelFile button, ModelFile buttonPressed) { - getVariantBuilder(block).forAllStates(state -> { - Direction facing = state.getValue(ButtonBlock.FACING); - AttachFace face = state.getValue(ButtonBlock.FACE); - boolean powered = state.getValue(ButtonBlock.POWERED); - - return ConfiguredModel.builder() - .modelFile(powered ? buttonPressed : button) - .rotationX(face == AttachFace.FLOOR ? 0 : (face == AttachFace.WALL ? 90 : 180)) - .rotationY((int) (face == AttachFace.CEILING ? facing : facing.getOpposite()).toYRot()) - .uvLock(face == AttachFace.WALL) - .build(); - }); - } - - public void pressurePlateBlock(PressurePlateBlock block, ResourceLocation texture) { - ModelFile pressurePlate = models().pressurePlate(name(block), texture); - ModelFile pressurePlateDown = models().pressurePlateDown(name(block) + "_down", texture); - pressurePlateBlock(block, pressurePlate, pressurePlateDown); - } - - public void pressurePlateBlock(PressurePlateBlock block, ModelFile pressurePlate, ModelFile pressurePlateDown) { - getVariantBuilder(block) - .partialState().with(PressurePlateBlock.POWERED, true).addModels(new ConfiguredModel(pressurePlateDown)) - .partialState().with(PressurePlateBlock.POWERED, false).addModels(new ConfiguredModel(pressurePlate)); - } - - public void signBlock(StandingSignBlock signBlock, WallSignBlock wallSignBlock, ResourceLocation texture) { - ModelFile sign = models().sign(name(signBlock), texture); - signBlock(signBlock, wallSignBlock, sign); - } - - public void signBlock(StandingSignBlock signBlock, WallSignBlock wallSignBlock, ModelFile sign) { - simpleBlock(signBlock, sign); - simpleBlock(wallSignBlock, sign); - } - - public void fourWayBlock(CrossCollisionBlock block, ModelFile post, ModelFile side) { - MultiPartBlockStateBuilder builder = getMultipartBuilder(block) - .part().modelFile(post).addModel().end(); - fourWayMultipart(builder, side); - } - - public void fourWayMultipart(MultiPartBlockStateBuilder builder, ModelFile side) { - PipeBlock.PROPERTY_BY_DIRECTION.entrySet().forEach(e -> { - Direction dir = e.getKey(); - if (dir.getAxis().isHorizontal()) { - builder.part().modelFile(side).rotationY((((int) dir.toYRot()) + 180) % 360).uvLock(true).addModel() - .condition(e.getValue(), true); - } - }); - } - - public void fenceBlock(FenceBlock block, ResourceLocation texture) { - String baseName = key(block).toString(); - fourWayBlock(block, - models().fencePost(baseName + "_post", texture), - models().fenceSide(baseName + "_side", texture)); - } - - public void fenceBlock(FenceBlock block, String name, ResourceLocation texture) { - fourWayBlock(block, - models().fencePost(name + "_fence_post", texture), - models().fenceSide(name + "_fence_side", texture)); - } - - public void fenceBlockWithRenderType(FenceBlock block, ResourceLocation texture, String renderType) { - String baseName = key(block).toString(); - fourWayBlock(block, - models().fencePost(baseName + "_post", texture).renderType(renderType), - models().fenceSide(baseName + "_side", texture).renderType(renderType)); - } - - public void fenceBlockWithRenderType(FenceBlock block, String name, ResourceLocation texture, String renderType) { - fourWayBlock(block, - models().fencePost(name + "_fence_post", texture).renderType(renderType), - models().fenceSide(name + "_fence_side", texture).renderType(renderType)); - } - - public void fenceBlockWithRenderType(FenceBlock block, ResourceLocation texture, ResourceLocation renderType) { - String baseName = key(block).toString(); - fourWayBlock(block, - models().fencePost(baseName + "_post", texture).renderType(renderType), - models().fenceSide(baseName + "_side", texture).renderType(renderType)); - } - - public void fenceBlockWithRenderType(FenceBlock block, String name, ResourceLocation texture, ResourceLocation renderType) { - fourWayBlock(block, - models().fencePost(name + "_fence_post", texture).renderType(renderType), - models().fenceSide(name + "_fence_side", texture).renderType(renderType)); - } - - public void fenceBlockWithRenderTypeAndFast(FenceBlock block, ResourceLocation texture, String renderType, String renderTypeFast) { - String baseName = key(block).toString(); - fourWayBlock(block, - models().fencePost(baseName + "_post", texture).renderType(renderType, renderTypeFast), - models().fenceSide(baseName + "_side", texture).renderType(renderType, renderTypeFast)); - } - - public void fenceBlockWithRenderTypeAndFast(FenceBlock block, String name, ResourceLocation texture, String renderType, String renderTypeFast) { - fourWayBlock(block, - models().fencePost(name + "_fence_post", texture).renderType(renderType, renderTypeFast), - models().fenceSide(name + "_fence_side", texture).renderType(renderType, renderTypeFast)); - } - - public void fenceBlockWithRenderTypeAndFast(FenceBlock block, ResourceLocation texture, ResourceLocation renderType, ResourceLocation renderTypeFast) { - String baseName = key(block).toString(); - fourWayBlock(block, - models().fencePost(baseName + "_post", texture).renderType(renderType, renderTypeFast), - models().fenceSide(baseName + "_side", texture).renderType(renderType, renderTypeFast)); - } - - public void fenceBlockWithRenderTypeAndFast(FenceBlock block, String name, ResourceLocation texture, ResourceLocation renderType, ResourceLocation renderTypeFast) { - fourWayBlock(block, - models().fencePost(name + "_fence_post", texture).renderType(renderType, renderTypeFast), - models().fenceSide(name + "_fence_side", texture).renderType(renderType, renderTypeFast)); - } - - public void fenceGateBlock(FenceGateBlock block, ResourceLocation texture) { - fenceGateBlockInternal(block, key(block).toString(), texture); - } - - public void fenceGateBlock(FenceGateBlock block, String name, ResourceLocation texture) { - fenceGateBlockInternal(block, name + "_fence_gate", texture); - } - - public void fenceGateBlockWithRenderType(FenceGateBlock block, ResourceLocation texture, String renderType) { - fenceGateBlockInternalWithRenderType(block, key(block).toString(), texture, ResourceLocation.tryParse(renderType)); - } - - public void fenceGateBlockWithRenderType(FenceGateBlock block, String name, ResourceLocation texture, String renderType) { - fenceGateBlockInternalWithRenderType(block, name + "_fence_gate", texture, ResourceLocation.tryParse(renderType)); - } - - public void fenceGateBlockWithRenderType(FenceGateBlock block, ResourceLocation texture, ResourceLocation renderType) { - fenceGateBlockInternalWithRenderType(block, key(block).toString(), texture, renderType); - } - - public void fenceGateBlockWithRenderType(FenceGateBlock block, String name, ResourceLocation texture, ResourceLocation renderType) { - fenceGateBlockInternalWithRenderType(block, name + "_fence_gate", texture, renderType); - } - - public void fenceGateBlockWithRenderTypeAndFast(FenceGateBlock block, ResourceLocation texture, String renderType, String renderTypeFast) { - fenceGateBlockInternalWithRenderTypeAndFast(block, key(block).toString(), texture, ResourceLocation.tryParse(renderType), ResourceLocation.tryParse(renderTypeFast)); - } - - public void fenceGateBlockWithRenderTypeAndFast(FenceGateBlock block, String name, ResourceLocation texture, String renderType, String renderTypeFast) { - fenceGateBlockInternalWithRenderTypeAndFast(block, name + "_fence_gate", texture, ResourceLocation.tryParse(renderType), ResourceLocation.tryParse(renderTypeFast)); - } - - public void fenceGateBlockWithRenderTypeAndFast(FenceGateBlock block, ResourceLocation texture, ResourceLocation renderType, ResourceLocation renderTypeFast) { - fenceGateBlockInternalWithRenderTypeAndFast(block, key(block).toString(), texture, renderType, renderTypeFast); - } - - public void fenceGateBlockWithRenderTypeAndFast(FenceGateBlock block, String name, ResourceLocation texture, ResourceLocation renderType, ResourceLocation renderTypeFast) { - fenceGateBlockInternalWithRenderTypeAndFast(block, name + "_fence_gate", texture, renderType, renderTypeFast); - } - - private void fenceGateBlockInternal(FenceGateBlock block, String baseName, ResourceLocation texture) { - ModelFile gate = models().fenceGate(baseName, texture); - ModelFile gateOpen = models().fenceGateOpen(baseName + "_open", texture); - ModelFile gateWall = models().fenceGateWall(baseName + "_wall", texture); - ModelFile gateWallOpen = models().fenceGateWallOpen(baseName + "_wall_open", texture); - fenceGateBlock(block, gate, gateOpen, gateWall, gateWallOpen); - } - - private void fenceGateBlockInternalWithRenderType(FenceGateBlock block, String baseName, ResourceLocation texture, ResourceLocation renderType) { - ModelFile gate = models().fenceGate(baseName, texture).renderType(renderType); - ModelFile gateOpen = models().fenceGateOpen(baseName + "_open", texture).renderType(renderType); - ModelFile gateWall = models().fenceGateWall(baseName + "_wall", texture).renderType(renderType); - ModelFile gateWallOpen = models().fenceGateWallOpen(baseName + "_wall_open", texture).renderType(renderType); - fenceGateBlock(block, gate, gateOpen, gateWall, gateWallOpen); - } - - private void fenceGateBlockInternalWithRenderTypeAndFast(FenceGateBlock block, String baseName, ResourceLocation texture, ResourceLocation renderType, ResourceLocation renderTypeFast) { - ModelFile gate = models().fenceGate(baseName, texture).renderType(renderType, renderTypeFast); - ModelFile gateOpen = models().fenceGateOpen(baseName + "_open", texture).renderType(renderType, renderTypeFast); - ModelFile gateWall = models().fenceGateWall(baseName + "_wall", texture).renderType(renderType, renderTypeFast); - ModelFile gateWallOpen = models().fenceGateWallOpen(baseName + "_wall_open", texture).renderType(renderType, renderTypeFast); - fenceGateBlock(block, gate, gateOpen, gateWall, gateWallOpen); - } - - public void fenceGateBlock(FenceGateBlock block, ModelFile gate, ModelFile gateOpen, ModelFile gateWall, ModelFile gateWallOpen) { - getVariantBuilder(block).forAllStatesExcept(state -> { - ModelFile model = gate; - if (state.getValue(FenceGateBlock.IN_WALL)) { - model = gateWall; - } - if (state.getValue(FenceGateBlock.OPEN)) { - model = model == gateWall ? gateWallOpen : gateOpen; - } - return ConfiguredModel.builder() - .modelFile(model) - .rotationY((int) state.getValue(FenceGateBlock.FACING).toYRot()) - .uvLock(true) - .build(); - }, FenceGateBlock.POWERED); - } - - public void wallBlock(WallBlock block, ResourceLocation texture) { - wallBlockInternal(block, key(block).toString(), texture); - } - - public void wallBlock(WallBlock block, String name, ResourceLocation texture) { - wallBlockInternal(block, name + "_wall", texture); - } - - public void wallBlockWithRenderType(WallBlock block, ResourceLocation texture, String renderType) { - wallBlockInternalWithRenderType(block, key(block).toString(), texture, ResourceLocation.tryParse(renderType)); - } - - public void wallBlockWithRenderType(WallBlock block, String name, ResourceLocation texture, String renderType) { - wallBlockInternalWithRenderType(block, name + "_wall", texture, ResourceLocation.tryParse(renderType)); - } - - public void wallBlockWithRenderType(WallBlock block, ResourceLocation texture, ResourceLocation renderType) { - wallBlockInternalWithRenderType(block, key(block).toString(), texture, renderType); - } - - public void wallBlockWithRenderType(WallBlock block, String name, ResourceLocation texture, ResourceLocation renderType) { - wallBlockInternalWithRenderType(block, name + "_wall", texture, renderType); - } - - public void wallBlockWithRenderTypeAndFast(WallBlock block, ResourceLocation texture, String renderType, String renderTypeFast) { - wallBlockInternalWithRenderTypeAndFast(block, key(block).toString(), texture, ResourceLocation.tryParse(renderType), ResourceLocation.tryParse(renderTypeFast)); - } - - public void wallBlockWithRenderTypeAndFast(WallBlock block, String name, ResourceLocation texture, String renderType, String renderTypeFast) { - wallBlockInternalWithRenderTypeAndFast(block, name + "_wall", texture, ResourceLocation.tryParse(renderType), ResourceLocation.tryParse(renderTypeFast)); - } - - public void wallBlockWithRenderTypeAndFast(WallBlock block, ResourceLocation texture, ResourceLocation renderType, ResourceLocation renderTypeFast) { - wallBlockInternalWithRenderTypeAndFast(block, key(block).toString(), texture, renderType, renderTypeFast); - } - - public void wallBlockWithRenderTypeAndFast(WallBlock block, String name, ResourceLocation texture, ResourceLocation renderType, ResourceLocation renderTypeFast) { - wallBlockInternalWithRenderTypeAndFast(block, name + "_wall", texture, renderType, renderTypeFast); - } - - private void wallBlockInternal(WallBlock block, String baseName, ResourceLocation texture) { - wallBlock(block, models().wallPost(baseName + "_post", texture), - models().wallSide(baseName + "_side", texture), - models().wallSideTall(baseName + "_side_tall", texture)); - } - - private void wallBlockInternalWithRenderType(WallBlock block, String baseName, ResourceLocation texture, ResourceLocation renderType) { - wallBlock(block, models().wallPost(baseName + "_post", texture).renderType(renderType), - models().wallSide(baseName + "_side", texture).renderType(renderType), - models().wallSideTall(baseName + "_side_tall", texture).renderType(renderType)); - } - - private void wallBlockInternalWithRenderTypeAndFast(WallBlock block, String baseName, ResourceLocation texture, ResourceLocation renderType, ResourceLocation renderTypeFast) { - wallBlock(block, models().wallPost(baseName + "_post", texture).renderType(renderType, renderTypeFast), - models().wallSide(baseName + "_side", texture).renderType(renderType, renderTypeFast), - models().wallSideTall(baseName + "_side_tall", texture).renderType(renderType, renderTypeFast)); - } - - public static final ImmutableMap> WALL_PROPS = ImmutableMap.>builder() - .put(Direction.EAST, BlockStateProperties.EAST_WALL) - .put(Direction.NORTH, BlockStateProperties.NORTH_WALL) - .put(Direction.SOUTH, BlockStateProperties.SOUTH_WALL) - .put(Direction.WEST, BlockStateProperties.WEST_WALL) - .build(); - - public void wallBlock(WallBlock block, ModelFile post, ModelFile side, ModelFile sideTall) { - MultiPartBlockStateBuilder builder = getMultipartBuilder(block) - .part().modelFile(post).addModel() - .condition(WallBlock.UP, true).end(); - WALL_PROPS.entrySet().stream() - .filter(e -> e.getKey().getAxis().isHorizontal()) - .forEach(e -> { - wallSidePart(builder, side, e, WallSide.LOW); - wallSidePart(builder, sideTall, e, WallSide.TALL); - }); - } - - private void wallSidePart(MultiPartBlockStateBuilder builder, ModelFile model, Map.Entry> entry, WallSide height) { - builder.part() - .modelFile(model) - .rotationY((((int) entry.getKey().toYRot()) + 180) % 360) - .uvLock(true) - .addModel() - .condition(entry.getValue(), height); - } - - public void paneBlock(IronBarsBlock block, ResourceLocation pane, ResourceLocation edge) { - paneBlockInternal(block, key(block).toString(), pane, edge); - } - - public void paneBlock(IronBarsBlock block, String name, ResourceLocation pane, ResourceLocation edge) { - paneBlockInternal(block, name + "_pane", pane, edge); - } - - public void paneBlockWithRenderType(IronBarsBlock block, ResourceLocation pane, ResourceLocation edge, String renderType) { - paneBlockInternalWithRenderType(block, key(block).toString(), pane, edge, ResourceLocation.tryParse(renderType)); - } - - public void paneBlockWithRenderType(IronBarsBlock block, String name, ResourceLocation pane, ResourceLocation edge, String renderType) { - paneBlockInternalWithRenderType(block, name + "_pane", pane, edge, ResourceLocation.tryParse(renderType)); - } - - public void paneBlockWithRenderType(IronBarsBlock block, ResourceLocation pane, ResourceLocation edge, ResourceLocation renderType) { - paneBlockInternalWithRenderType(block, key(block).toString(), pane, edge, renderType); - } - - public void paneBlockWithRenderType(IronBarsBlock block, String name, ResourceLocation pane, ResourceLocation edge, ResourceLocation renderType) { - paneBlockInternalWithRenderType(block, name + "_pane", pane, edge, renderType); - } - - public void paneBlockWithRenderTypeAndFast(IronBarsBlock block, ResourceLocation pane, ResourceLocation edge, String renderType, String renderTypeFast) { - paneBlockInternalWithRenderTypeAndFast(block, key(block).toString(), pane, edge, ResourceLocation.tryParse(renderType), ResourceLocation.tryParse(renderTypeFast)); - } - - public void paneBlockWithRenderTypeAndFast(IronBarsBlock block, String name, ResourceLocation pane, ResourceLocation edge, String renderType, String renderTypeFast) { - paneBlockInternalWithRenderTypeAndFast(block, name + "_pane", pane, edge, ResourceLocation.tryParse(renderType), ResourceLocation.tryParse(renderTypeFast)); - } - - public void paneBlockWithRenderTypeAndFast(IronBarsBlock block, ResourceLocation pane, ResourceLocation edge, ResourceLocation renderType, ResourceLocation renderTypeFast) { - paneBlockInternalWithRenderTypeAndFast(block, key(block).toString(), pane, edge, renderType, renderTypeFast); - } - - public void paneBlockWithRenderTypeAndFast(IronBarsBlock block, String name, ResourceLocation pane, ResourceLocation edge, ResourceLocation renderType, ResourceLocation renderTypeFast) { - paneBlockInternalWithRenderTypeAndFast(block, name + "_pane", pane, edge, renderType, renderTypeFast); - } - - private void paneBlockInternal(IronBarsBlock block, String baseName, ResourceLocation pane, ResourceLocation edge) { - ModelFile post = models().panePost(baseName + "_post", pane, edge); - ModelFile side = models().paneSide(baseName + "_side", pane, edge); - ModelFile sideAlt = models().paneSideAlt(baseName + "_side_alt", pane, edge); - ModelFile noSide = models().paneNoSide(baseName + "_noside", pane); - ModelFile noSideAlt = models().paneNoSideAlt(baseName + "_noside_alt", pane); - paneBlock(block, post, side, sideAlt, noSide, noSideAlt); - } - - private void paneBlockInternalWithRenderType(IronBarsBlock block, String baseName, ResourceLocation pane, ResourceLocation edge, ResourceLocation renderType) { - ModelFile post = models().panePost(baseName + "_post", pane, edge).renderType(renderType); - ModelFile side = models().paneSide(baseName + "_side", pane, edge).renderType(renderType); - ModelFile sideAlt = models().paneSideAlt(baseName + "_side_alt", pane, edge).renderType(renderType); - ModelFile noSide = models().paneNoSide(baseName + "_noside", pane).renderType(renderType); - ModelFile noSideAlt = models().paneNoSideAlt(baseName + "_noside_alt", pane).renderType(renderType); - paneBlock(block, post, side, sideAlt, noSide, noSideAlt); - } - - private void paneBlockInternalWithRenderTypeAndFast(IronBarsBlock block, String baseName, ResourceLocation pane, ResourceLocation edge, ResourceLocation renderType, ResourceLocation renderTypeFast) { - ModelFile post = models().panePost(baseName + "_post", pane, edge).renderType(renderType, renderTypeFast); - ModelFile side = models().paneSide(baseName + "_side", pane, edge).renderType(renderType, renderTypeFast); - ModelFile sideAlt = models().paneSideAlt(baseName + "_side_alt", pane, edge).renderType(renderType, renderTypeFast); - ModelFile noSide = models().paneNoSide(baseName + "_noside", pane).renderType(renderType, renderTypeFast); - ModelFile noSideAlt = models().paneNoSideAlt(baseName + "_noside_alt", pane).renderType(renderType, renderTypeFast); - paneBlock(block, post, side, sideAlt, noSide, noSideAlt); - } - - public void paneBlock(IronBarsBlock block, ModelFile post, ModelFile side, ModelFile sideAlt, ModelFile noSide, ModelFile noSideAlt) { - MultiPartBlockStateBuilder builder = getMultipartBuilder(block) - .part().modelFile(post).addModel().end(); - PipeBlock.PROPERTY_BY_DIRECTION.entrySet().forEach(e -> { - Direction dir = e.getKey(); - if (dir.getAxis().isHorizontal()) { - boolean alt = dir == Direction.SOUTH; - builder.part().modelFile(alt || dir == Direction.WEST ? sideAlt : side).rotationY(dir.getAxis() == Axis.X ? 90 : 0).addModel() - .condition(e.getValue(), true).end() - .part().modelFile(alt || dir == Direction.EAST ? noSideAlt : noSide).rotationY(dir == Direction.WEST ? 270 : dir == Direction.SOUTH ? 90 : 0).addModel() - .condition(e.getValue(), false); - } - }); - } - - public void doorBlock(DoorBlock block, ResourceLocation bottom, ResourceLocation top) { - doorBlockInternal(block, key(block).toString(), bottom, top); - } - - public void doorBlock(DoorBlock block, String name, ResourceLocation bottom, ResourceLocation top) { - doorBlockInternal(block, name + "_door", bottom, top); - } - - public void doorBlockWithRenderType(DoorBlock block, ResourceLocation bottom, ResourceLocation top, String renderType) { - doorBlockInternalWithRenderType(block, key(block).toString(), bottom, top, ResourceLocation.tryParse(renderType)); - } - - public void doorBlockWithRenderType(DoorBlock block, String name, ResourceLocation bottom, ResourceLocation top, String renderType) { - doorBlockInternalWithRenderType(block, name + "_door", bottom, top, ResourceLocation.tryParse(renderType)); - } - - public void doorBlockWithRenderType(DoorBlock block, ResourceLocation bottom, ResourceLocation top, ResourceLocation renderType) { - doorBlockInternalWithRenderType(block, key(block).toString(), bottom, top, renderType); - } - - public void doorBlockWithRenderType(DoorBlock block, String name, ResourceLocation bottom, ResourceLocation top, ResourceLocation renderType) { - doorBlockInternalWithRenderType(block, name + "_door", bottom, top, renderType); - } - - public void doorBlockWithRenderTypeAndFast(DoorBlock block, ResourceLocation bottom, ResourceLocation top, String renderType, String renderTypeFast) { - doorBlockInternalWithRenderTypeAndFast(block, key(block).toString(), bottom, top, ResourceLocation.tryParse(renderType), ResourceLocation.tryParse(renderTypeFast)); - } - - public void doorBlockWithRenderTypeAndFast(DoorBlock block, String name, ResourceLocation bottom, ResourceLocation top, String renderType, String renderTypeFast) { - doorBlockInternalWithRenderTypeAndFast(block, name + "_door", bottom, top, ResourceLocation.tryParse(renderType), ResourceLocation.tryParse(renderTypeFast)); - } - - public void doorBlockWithRenderTypeAndFast(DoorBlock block, ResourceLocation bottom, ResourceLocation top, ResourceLocation renderType, ResourceLocation renderTypeFast) { - doorBlockInternalWithRenderTypeAndFast(block, key(block).toString(), bottom, top, renderType, renderTypeFast); - } - - public void doorBlockWithRenderTypeAndFast(DoorBlock block, String name, ResourceLocation bottom, ResourceLocation top, ResourceLocation renderType, ResourceLocation renderTypeFast) { - doorBlockInternalWithRenderTypeAndFast(block, name + "_door", bottom, top, renderType, renderTypeFast); - } - - private void doorBlockInternal(DoorBlock block, String baseName, ResourceLocation bottom, ResourceLocation top) { - ModelFile bottomLeft = models().doorBottomLeft(baseName + "_bottom_left", bottom, top); - ModelFile bottomLeftOpen = models().doorBottomLeftOpen(baseName + "_bottom_left_open", bottom, top); - ModelFile bottomRight = models().doorBottomRight(baseName + "_bottom_right", bottom, top); - ModelFile bottomRightOpen = models().doorBottomRightOpen(baseName + "_bottom_right_open", bottom, top); - ModelFile topLeft = models().doorTopLeft(baseName + "_top_left", bottom, top); - ModelFile topLeftOpen = models().doorTopLeftOpen(baseName + "_top_left_open", bottom, top); - ModelFile topRight = models().doorTopRight(baseName + "_top_right", bottom, top); - ModelFile topRightOpen = models().doorTopRightOpen(baseName + "_top_right_open", bottom, top); - doorBlock(block, bottomLeft, bottomLeftOpen, bottomRight, bottomRightOpen, topLeft, topLeftOpen, topRight, topRightOpen); - } - - private void doorBlockInternalWithRenderType(DoorBlock block, String baseName, ResourceLocation bottom, ResourceLocation top, ResourceLocation renderType) { - ModelFile bottomLeft = models().doorBottomLeft(baseName + "_bottom_left", bottom, top).renderType(renderType); - ModelFile bottomLeftOpen = models().doorBottomLeftOpen(baseName + "_bottom_left_open", bottom, top).renderType(renderType); - ModelFile bottomRight = models().doorBottomRight(baseName + "_bottom_right", bottom, top).renderType(renderType); - ModelFile bottomRightOpen = models().doorBottomRightOpen(baseName + "_bottom_right_open", bottom, top).renderType(renderType); - ModelFile topLeft = models().doorTopLeft(baseName + "_top_left", bottom, top).renderType(renderType); - ModelFile topLeftOpen = models().doorTopLeftOpen(baseName + "_top_left_open", bottom, top).renderType(renderType); - ModelFile topRight = models().doorTopRight(baseName + "_top_right", bottom, top).renderType(renderType); - ModelFile topRightOpen = models().doorTopRightOpen(baseName + "_top_right_open", bottom, top).renderType(renderType); - doorBlock(block, bottomLeft, bottomLeftOpen, bottomRight, bottomRightOpen, topLeft, topLeftOpen, topRight, topRightOpen); - } - - private void doorBlockInternalWithRenderTypeAndFast(DoorBlock block, String baseName, ResourceLocation bottom, ResourceLocation top, ResourceLocation renderType, ResourceLocation renderTypeFast) { - ModelFile bottomLeft = models().doorBottomLeft(baseName + "_bottom_left", bottom, top).renderType(renderType, renderTypeFast); - ModelFile bottomLeftOpen = models().doorBottomLeftOpen(baseName + "_bottom_left_open", bottom, top).renderType(renderType, renderTypeFast); - ModelFile bottomRight = models().doorBottomRight(baseName + "_bottom_right", bottom, top).renderType(renderType, renderTypeFast); - ModelFile bottomRightOpen = models().doorBottomRightOpen(baseName + "_bottom_right_open", bottom, top).renderType(renderType, renderTypeFast); - ModelFile topLeft = models().doorTopLeft(baseName + "_top_left", bottom, top).renderType(renderType, renderTypeFast); - ModelFile topLeftOpen = models().doorTopLeftOpen(baseName + "_top_left_open", bottom, top).renderType(renderType, renderTypeFast); - ModelFile topRight = models().doorTopRight(baseName + "_top_right", bottom, top).renderType(renderType, renderTypeFast); - ModelFile topRightOpen = models().doorTopRightOpen(baseName + "_top_right_open", bottom, top).renderType(renderType, renderTypeFast); - doorBlock(block, bottomLeft, bottomLeftOpen, bottomRight, bottomRightOpen, topLeft, topLeftOpen, topRight, topRightOpen); - } - - public void doorBlock(DoorBlock block, ModelFile bottomLeft, ModelFile bottomLeftOpen, ModelFile bottomRight, ModelFile bottomRightOpen, ModelFile topLeft, ModelFile topLeftOpen, ModelFile topRight, ModelFile topRightOpen) { - getVariantBuilder(block).forAllStatesExcept(state -> { - int yRot = ((int) state.getValue(DoorBlock.FACING).toYRot()) + 90; - boolean right = state.getValue(DoorBlock.HINGE) == DoorHingeSide.RIGHT; - boolean open = state.getValue(DoorBlock.OPEN); - boolean lower = state.getValue(DoorBlock.HALF) == DoubleBlockHalf.LOWER; - if (open) { - yRot += 90; - } - if (right && open) { - yRot += 180; - } - yRot %= 360; - - ModelFile model = null; - if (lower && right && open) { - model = bottomRightOpen; - } else if (lower && !right && open) { - model = bottomLeftOpen; - } - if (lower && right && !open) { - model = bottomRight; - } else if (lower && !right && !open) { - model = bottomLeft; - } - if (!lower && right && open) { - model = topRightOpen; - } else if (!lower && !right && open) { - model = topLeftOpen; - } - if (!lower && right && !open) { - model = topRight; - } else if (!lower && !right && !open) { - model = topLeft; - } - - return ConfiguredModel.builder().modelFile(model) - .rotationY(yRot) - .build(); - }, DoorBlock.POWERED); - } - - public void trapdoorBlock(TrapDoorBlock block, ResourceLocation texture, boolean orientable) { - trapdoorBlockInternal(block, key(block).toString(), texture, orientable); - } - - public void trapdoorBlock(TrapDoorBlock block, String name, ResourceLocation texture, boolean orientable) { - trapdoorBlockInternal(block, name + "_trapdoor", texture, orientable); - } - - public void trapdoorBlockWithRenderType(TrapDoorBlock block, ResourceLocation texture, boolean orientable, String renderType) { - trapdoorBlockInternalWithRenderType(block, key(block).toString(), texture, orientable, ResourceLocation.tryParse(renderType)); - } - - public void trapdoorBlockWithRenderType(TrapDoorBlock block, String name, ResourceLocation texture, boolean orientable, String renderType) { - trapdoorBlockInternalWithRenderType(block, name + "_trapdoor", texture, orientable, ResourceLocation.tryParse(renderType)); - } - - public void trapdoorBlockWithRenderType(TrapDoorBlock block, ResourceLocation texture, boolean orientable, ResourceLocation renderType) { - trapdoorBlockInternalWithRenderType(block, key(block).toString(), texture, orientable, renderType); - } - - public void trapdoorBlockWithRenderType(TrapDoorBlock block, String name, ResourceLocation texture, boolean orientable, ResourceLocation renderType) { - trapdoorBlockInternalWithRenderType(block, name + "_trapdoor", texture, orientable, renderType); - } - - public void trapdoorBlockWithRenderTypeAndFast(TrapDoorBlock block, ResourceLocation texture, boolean orientable, String renderType, String renderTypeFast) { - trapdoorBlockInternalWithRenderTypeAndFast(block, key(block).toString(), texture, orientable, ResourceLocation.tryParse(renderType), ResourceLocation.tryParse(renderTypeFast)); - } - - public void trapdoorBlockWithRenderTypeAndFast(TrapDoorBlock block, String name, ResourceLocation texture, boolean orientable, String renderType, String renderTypeFast) { - trapdoorBlockInternalWithRenderTypeAndFast(block, name + "_trapdoor", texture, orientable, ResourceLocation.tryParse(renderType), ResourceLocation.tryParse(renderTypeFast)); - } - - public void trapdoorBlockWithRenderTypeAndFast(TrapDoorBlock block, ResourceLocation texture, boolean orientable, ResourceLocation renderType, ResourceLocation renderTypeFast) { - trapdoorBlockInternalWithRenderTypeAndFast(block, key(block).toString(), texture, orientable, renderType, renderTypeFast); - } - - public void trapdoorBlockWithRenderTypeAndFast(TrapDoorBlock block, String name, ResourceLocation texture, boolean orientable, ResourceLocation renderType, ResourceLocation renderTypeFast) { - trapdoorBlockInternalWithRenderTypeAndFast(block, name + "_trapdoor", texture, orientable, renderType, renderTypeFast); - } - - private void trapdoorBlockInternal(TrapDoorBlock block, String baseName, ResourceLocation texture, boolean orientable) { - ModelFile bottom = orientable ? models().trapdoorOrientableBottom(baseName + "_bottom", texture) : models().trapdoorBottom(baseName + "_bottom", texture); - ModelFile top = orientable ? models().trapdoorOrientableTop(baseName + "_top", texture) : models().trapdoorTop(baseName + "_top", texture); - ModelFile open = orientable ? models().trapdoorOrientableOpen(baseName + "_open", texture) : models().trapdoorOpen(baseName + "_open", texture); - trapdoorBlock(block, bottom, top, open, orientable); - } - - private void trapdoorBlockInternalWithRenderType(TrapDoorBlock block, String baseName, ResourceLocation texture, boolean orientable, ResourceLocation renderType) { - ModelFile bottom = orientable ? models().trapdoorOrientableBottom(baseName + "_bottom", texture).renderType(renderType) : models().trapdoorBottom(baseName + "_bottom", texture).renderType(renderType); - ModelFile top = orientable ? models().trapdoorOrientableTop(baseName + "_top", texture).renderType(renderType) : models().trapdoorTop(baseName + "_top", texture).renderType(renderType); - ModelFile open = orientable ? models().trapdoorOrientableOpen(baseName + "_open", texture).renderType(renderType) : models().trapdoorOpen(baseName + "_open", texture).renderType(renderType); - trapdoorBlock(block, bottom, top, open, orientable); - } - - private void trapdoorBlockInternalWithRenderTypeAndFast(TrapDoorBlock block, String baseName, ResourceLocation texture, boolean orientable, ResourceLocation renderType, ResourceLocation renderTypeFast) { - ModelFile bottom = orientable ? models().trapdoorOrientableBottom(baseName + "_bottom", texture).renderType(renderType, renderTypeFast) : models().trapdoorBottom(baseName + "_bottom", texture).renderType(renderType, renderTypeFast); - ModelFile top = orientable ? models().trapdoorOrientableTop(baseName + "_top", texture).renderType(renderType, renderTypeFast) : models().trapdoorTop(baseName + "_top", texture).renderType(renderType, renderTypeFast); - ModelFile open = orientable ? models().trapdoorOrientableOpen(baseName + "_open", texture).renderType(renderType, renderTypeFast) : models().trapdoorOpen(baseName + "_open", texture).renderType(renderType, renderTypeFast); - trapdoorBlock(block, bottom, top, open, orientable); - } - - public void trapdoorBlock(TrapDoorBlock block, ModelFile bottom, ModelFile top, ModelFile open, boolean orientable) { - getVariantBuilder(block).forAllStatesExcept(state -> { - int xRot = 0; - int yRot = ((int) state.getValue(TrapDoorBlock.FACING).toYRot()) + 180; - boolean isOpen = state.getValue(TrapDoorBlock.OPEN); - if (orientable && isOpen && state.getValue(TrapDoorBlock.HALF) == Half.TOP) { - xRot += 180; - yRot += 180; - } - if (!orientable && !isOpen) { - yRot = 0; - } - yRot %= 360; - return ConfiguredModel.builder().modelFile(isOpen ? open : state.getValue(TrapDoorBlock.HALF) == Half.TOP ? top : bottom) - .rotationX(xRot) - .rotationY(yRot) - .build(); - }, TrapDoorBlock.POWERED, TrapDoorBlock.WATERLOGGED); - } - - private CompletableFuture saveBlockState(CachedOutput cache, JsonObject stateJson, Block owner) { - ResourceLocation blockName = Preconditions.checkNotNull(key(owner)); - Path outputPath = this.output.getOutputFolder(PackOutput.Target.RESOURCE_PACK) - .resolve(blockName.getNamespace()).resolve("blockstates").resolve(blockName.getPath() + ".json"); - return DataProvider.saveStable(cache, stateJson, outputPath); - } - - @NotNull - @Override - public String getName() { - return "Block States: " + modid; - } - - public static class ConfiguredModelList { - private final List models; - - private ConfiguredModelList(List models) { - Preconditions.checkArgument(!models.isEmpty()); - this.models = models; - } - - public ConfiguredModelList(ConfiguredModel model) { - this(ImmutableList.of(model)); - } - - public ConfiguredModelList(ConfiguredModel... models) { - this(Arrays.asList(models)); - } - - public JsonElement toJSON() { - if (models.size()==1) { - return models.get(0).toJSON(false); - } else { - JsonArray ret = new JsonArray(); - for (ConfiguredModel m:models) { - ret.add(m.toJSON(true)); - } - return ret; - } - } - - public ConfiguredModelList append(ConfiguredModel... models) { - return new ConfiguredModelList(ImmutableList.builder().addAll(this.models).add(models).build()); - } - } -} \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/client/model/generators/ConfiguredModel.java b/src/main/java/net/minecraftforge/client/model/generators/ConfiguredModel.java deleted file mode 100644 index 02730b824f..0000000000 --- a/src/main/java/net/minecraftforge/client/model/generators/ConfiguredModel.java +++ /dev/null @@ -1,323 +0,0 @@ -/* - * Copyright (c) Forge Development LLC and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.minecraftforge.client.model.generators; - -import java.util.Arrays; -import java.util.List; -import java.util.function.Function; -import java.util.stream.IntStream; - - -import com.google.common.base.Preconditions; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ObjectArrays; -import com.google.gson.JsonObject; - -import com.mojang.math.Quadrant; -import net.minecraft.client.resources.model.BlockModelRotation; -import net.minecraft.util.Mth; -import net.minecraftforge.client.model.generators.MultiPartBlockStateBuilder.PartBuilder; -import net.minecraftforge.client.model.generators.VariantBlockStateBuilder.PartialBlockstate; -import org.jetbrains.annotations.Nullable; - -/** - * Represents a model with blockstate configurations, e.g. rotation, uvlock, and - * random weight. - *

    - * Can be manually constructed, created by static factory such as - * {@link #allYRotations(ModelFile, int, boolean)}, or created by builder via - * {@link #builder()}. - * - * In 1.21.4 Mojang exposed their data generators for their models. So it should be feasible to just use theirs. - * If you find something lacking feel free to open a PR so that we can extend it. - * @deprecated Use Vanilla's providers {@link net.minecraft.client.data.models.ModelProvider} - */ -@Deprecated(since = "1.21.4", forRemoval = true) -public final class ConfiguredModel { - - /** - * The default random weight of configured models, used by convenience - * overloads. - */ - public static final int DEFAULT_WEIGHT = 1; - - public final ModelFile model; - public final int rotationX; - public final int rotationY; - public final boolean uvLock; - public final int weight; - - private static IntStream validRotations() { - return IntStream.range(0, 4).map(i -> i * 90); - } - - public static ConfiguredModel[] allYRotations(ModelFile model, int x, boolean uvlock) { - return allYRotations(model, x, uvlock, DEFAULT_WEIGHT); - } - - public static ConfiguredModel[] allYRotations(ModelFile model, int x, boolean uvlock, int weight) { - return validRotations() - .mapToObj(y -> new ConfiguredModel(model, x, y, uvlock, weight)) - .toArray(ConfiguredModel[]::new); - } - - public static ConfiguredModel[] allRotations(ModelFile model, boolean uvlock) { - return allRotations(model, uvlock, DEFAULT_WEIGHT); - } - - public static ConfiguredModel[] allRotations(ModelFile model, boolean uvlock, int weight) { - return validRotations() - .mapToObj(x -> allYRotations(model, x, uvlock, weight)) - .flatMap(Arrays::stream) - .toArray(ConfiguredModel[]::new); - } - - /** - * Construct a new {@link ConfiguredModel}. - * - * @param model the underlying model - * @param rotationX x-rotation to apply to the model - * @param rotationY y-rotation to apply to the model - * @param uvLock if uvlock should be enabled - * @param weight the random weight of the model - * - * @throws NullPointerException if {@code model} is {@code null} - * @throws IllegalArgumentException if x and/or y rotation are not valid (see - * {@link BlockModelRotation}) - * @throws IllegalArgumentException if weight is less than or equal to zero - */ - public ConfiguredModel(ModelFile model, int rotationX, int rotationY, boolean uvLock, int weight) { - Preconditions.checkNotNull(model); - this.model = model; - checkRotation(rotationX, rotationY); - this.rotationX = rotationX; - this.rotationY = rotationY; - this.uvLock = uvLock; - checkWeight(weight); - this.weight = weight; - } - - /** - * Construct a new {@link ConfiguredModel} with the {@link #DEFAULT_WEIGHT - * default random weight}. - * - * @param model the underlying model - * @param rotationX x-rotation to apply to the model - * @param rotationY y-rotation to apply to the model - * @param uvLock if uvlock should be enabled - * - * @throws NullPointerException if {@code model} is {@code null} - * @throws IllegalArgumentException if x and/or y rotation are not valid (see - * {@link BlockModelRotation}) - */ - public ConfiguredModel(ModelFile model, int rotationX, int rotationY, boolean uvLock) { - this(model, rotationX, rotationY, uvLock, DEFAULT_WEIGHT); - } - - /** - * Construct a new {@link ConfiguredModel} with the default rotation (0, 0), - * uvlock (false), and {@link #DEFAULT_WEIGHT default random weight}. - * - * @throws NullPointerException if {@code model} is {@code null} - */ - public ConfiguredModel(ModelFile model) { - this(model, 0, 0, false); - } - - static void checkRotation(int rotationX, int rotationY) { - Preconditions.checkArgument(quadrantFromDeg(rotationX) == null || quadrantFromDeg(rotationY) == null, "Invalid model rotation x=%d, y=%d", rotationX, rotationY); - } - - static @Nullable Quadrant quadrantFromDeg(int degrees) { - return switch (Mth.positiveModulo(degrees, 360)) { - case 0 -> Quadrant.R0; - case 90 -> Quadrant.R90; - case 180 -> Quadrant.R180; - case 270 -> Quadrant.R270; - default -> null; - }; - } - - static void checkWeight(int weight) { - Preconditions.checkArgument(weight >= 1, "Model weight must be greater than or equal to 1. Found: %d", weight); - } - - JsonObject toJSON(boolean includeWeight) { - JsonObject modelJson = new JsonObject(); - modelJson.addProperty("model", model.getLocation().toString()); - if (rotationX != 0) - modelJson.addProperty("x", rotationX); - if (rotationY != 0) - modelJson.addProperty("y", rotationY); - if (uvLock) - modelJson.addProperty("uvlock", uvLock); - if (includeWeight && weight != DEFAULT_WEIGHT) - modelJson.addProperty("weight", weight); - return modelJson; - } - - /** - * Create a new unowned {@link Builder}. - * - * @return the builder - * @see Builder - */ - public static Builder builder() { - return new Builder<>(); - } - - static Builder builder(VariantBlockStateBuilder outer, PartialBlockstate state) { - return new Builder<>(models -> outer.setModels(state, models), ImmutableList.of()); - } - - static Builder builder(MultiPartBlockStateBuilder outer) { - return new Builder(models -> { - PartBuilder ret = outer.new PartBuilder(new BlockStateProvider.ConfiguredModelList(models)); - outer.addPart(ret); - return ret; - }, ImmutableList.of()); - } - - /** - * A builder for {@link ConfiguredModel}s, which can contain a callback for - * processing the finished result. If no callback is available (e.g. in the case - * of {@link ConfiguredModel#builder()}), some methods will not be available. - *

    - * Multiple models can be configured at once through the use of - * {@link #nextModel()}. - * - * @param the type of the owning builder, which supplied the callback, and - * will be returned upon completion. - */ - public static class Builder { - - private ModelFile model; - @Nullable - private final Function callback; - private final List otherModels; - private int rotationX; - private int rotationY; - private boolean uvLock; - private int weight = DEFAULT_WEIGHT; - - Builder() { - this(null, ImmutableList.of()); - } - - Builder(@Nullable Function callback, List otherModels) { - this.callback = callback; - this.otherModels = otherModels; - } - - /** - * Set the underlying model object for this configured model. - * - * @param model the model - * @return this builder - * @throws NullPointerException if {@code model} is {@code null} - */ - public Builder modelFile(ModelFile model) { - Preconditions.checkNotNull(model, "Model must not be null"); - this.model = model; - return this; - } - - /** - * Set the x-rotation for this model. - * - * @param value the x-rotation value - * @return this builder - * @throws IllegalArgumentException if {@code value} is not a valid x-rotation - * (see {@link BlockModelRotation}) - */ - public Builder rotationX(int value) { - checkRotation(value, rotationY); - rotationX = value; - return this; - } - - /** - * Set the y-rotation for this model. - * - * @param value the y-rotation value - * @return this builder - * @throws IllegalArgumentException if {@code value} is not a valid y-rotation - * (see {@link BlockModelRotation}) - */ - public Builder rotationY(int value) { - checkRotation(rotationX, value); - rotationY = value; - return this; - } - - public Builder uvLock(boolean value) { - uvLock = value; - return this; - } - - /** - * Set the random weight for this model. - * - * @param value the weight value - * @return this builder - * @throws IllegalArgumentException if {@code value} is less than or equal to - * zero - */ - public Builder weight(int value) { - checkWeight(value); - weight = value; - return this; - } - - /** - * Build the most recent model, as if {@link #nextModel()} was never called. - * Useful for single-model builders. - * - * @return the most recently configured model - */ - public ConfiguredModel buildLast() { - return new ConfiguredModel(model, rotationX, rotationY, uvLock, weight); - } - - /** - * Build all configured models and return them as an array. - * - * @return the array of built models. - */ - public ConfiguredModel[] build() { - return ObjectArrays.concat(otherModels.toArray(new ConfiguredModel[0]), buildLast()); - } - - /** - * Apply the contained callback and return the owning builder object. What the - * callback does is not defined by this class, but most likely it adds the built - * models to the current variant being configured. - *

    - * Known callbacks include: - *

      - *
    • {@link PartialBlockstate#modelForState()}
    • - *
    • {@link MultiPartBlockStateBuilder#part()}
    • - *
    - * - * @return the owning builder object - * @throws NullPointerException if there is no owning builder (and thus no callback) - */ - public T addModel() { - Preconditions.checkNotNull(callback, "Cannot use addModel() without an owning builder present"); - return callback.apply(build()); - } - - /** - * Complete the current model and return a new builder instance with the same - * callback, and storing all previously built models. - * - * @return a new builder for configuring the next model - */ - public Builder nextModel() { - return new Builder<>(callback, Arrays.asList(build())); - } - } -} diff --git a/src/main/java/net/minecraftforge/client/model/generators/CustomLoaderBuilder.java b/src/main/java/net/minecraftforge/client/model/generators/CustomLoaderBuilder.java deleted file mode 100644 index 2a258244dd..0000000000 --- a/src/main/java/net/minecraftforge/client/model/generators/CustomLoaderBuilder.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) Forge Development LLC and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.minecraftforge.client.model.generators; - -import com.google.common.base.Preconditions; -import com.google.gson.JsonObject; -import net.minecraft.resources.ResourceLocation; -import net.minecraftforge.common.data.ExistingFileHelper; - -import java.util.LinkedHashMap; -import java.util.Map; - -/** - * In 1.21.4 Mojang exposed their data generators for their models. So it should be feasible to just use theirs. - * If you find something lacking feel free to open a PR so that we can extend it. - * - * This is the only class that doesn't seem to have a vanilla alternative however, it should be a simple helper - * function to replace this functionality for your custom models - * - * @deprecated Use Vanilla's providers {@link net.minecraft.client.data.models.ModelProvider} - */ -@Deprecated(since = "1.21.4", forRemoval = true) -public abstract class CustomLoaderBuilder> -{ - protected final ResourceLocation loaderId; - protected final T parent; - protected final ExistingFileHelper existingFileHelper; - protected final Map visibility = new LinkedHashMap<>(); - - protected CustomLoaderBuilder(ResourceLocation loaderId, T parent, ExistingFileHelper existingFileHelper) - { - this.loaderId = loaderId; - this.parent = parent; - this.existingFileHelper = existingFileHelper; - } - - public CustomLoaderBuilder visibility(String partName, boolean show) - { - Preconditions.checkNotNull(partName, "partName must not be null"); - this.visibility.put(partName, show); - return this; - } - - public T end() - { - return parent; - } - - public JsonObject toJson(JsonObject json) - { - json.addProperty("loader", loaderId.toString()); - - if (!visibility.isEmpty()) - { - JsonObject visibilityObj = new JsonObject(); - - for(Map.Entry entry : visibility.entrySet()) - { - visibilityObj.addProperty(entry.getKey(), entry.getValue()); - } - - json.add("visibility", visibilityObj); - } - - return json; - } -} diff --git a/src/main/java/net/minecraftforge/client/model/generators/IGeneratedBlockState.java b/src/main/java/net/minecraftforge/client/model/generators/IGeneratedBlockState.java deleted file mode 100644 index 220b5f2413..0000000000 --- a/src/main/java/net/minecraftforge/client/model/generators/IGeneratedBlockState.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) Forge Development LLC and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.minecraftforge.client.model.generators; - -import com.google.gson.JsonObject; -import org.jetbrains.annotations.VisibleForTesting; - -/** - * In 1.21.4 Mojang exposed their data generators for their models. So it should be feasible to just use theirs. - * If you find something lacking feel free to open a PR so that we can extend it. - * @deprecated Use Vanilla's providers {@link net.minecraft.client.data.models.ModelProvider} - */ -@Deprecated(since = "1.21.4", forRemoval = true) -@VisibleForTesting -public interface IGeneratedBlockState -{ - JsonObject toJson(); -} diff --git a/src/main/java/net/minecraftforge/client/model/generators/ItemModelBuilder.java b/src/main/java/net/minecraftforge/client/model/generators/ItemModelBuilder.java deleted file mode 100644 index b7c6c2806e..0000000000 --- a/src/main/java/net/minecraftforge/client/model/generators/ItemModelBuilder.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (c) Forge Development LLC and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.minecraftforge.client.model.generators; - -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - -import com.google.common.base.Preconditions; -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; - -import net.minecraft.resources.ResourceLocation; -import net.minecraftforge.common.data.ExistingFileHelper; - -/** - * Builder for item models, adds the ability to build overrides via - * {@link #override()}. - * - * In 1.21.4 Mojang exposed their data generators for their models. So it should be feasible to just use theirs. - * If you find something lacking feel free to open a PR so that we can extend it. - * @deprecated Use Vanilla's providers {@link net.minecraft.client.data.models.ModelProvider} - */ -@Deprecated(since = "1.21.4", forRemoval = true) -public class ItemModelBuilder extends ModelBuilder { - - protected List overrides = new ArrayList<>(); - - public ItemModelBuilder(ResourceLocation outputLocation, ExistingFileHelper existingFileHelper) { - super(outputLocation, existingFileHelper); - } - - public OverrideBuilder override() { - OverrideBuilder ret = new OverrideBuilder(); - overrides.add(ret); - return ret; - } - - /** - * Get an existing override builder - * - * @param index the index of the existing override builder - * @return the override builder - * @throws IndexOutOfBoundsException if {@code} index is out of bounds - */ - public OverrideBuilder override(int index) { - Preconditions.checkElementIndex(index, overrides.size(), "override"); - return overrides.get(index); - } - - @Override - public JsonObject toJson() { - JsonObject root = super.toJson(); - if (!overrides.isEmpty()) { - JsonArray overridesJson = new JsonArray(); - overrides.stream().map(OverrideBuilder::toJson).forEach(overridesJson::add); - root.add("overrides", overridesJson); - } - return root; - } - - public class OverrideBuilder { - - private ModelFile model; - private final Map predicates = new LinkedHashMap<>(); - - public OverrideBuilder model(ModelFile model) { - this.model = model; - model.assertExistence(); - return this; - } - - public OverrideBuilder predicate(ResourceLocation key, float value) { - this.predicates.put(key, value); - return this; - } - - public ItemModelBuilder end() { return ItemModelBuilder.this; } - - JsonObject toJson() { - JsonObject ret = new JsonObject(); - JsonObject predicatesJson = new JsonObject(); - predicates.forEach((key, val) -> predicatesJson.addProperty(key.toString(), val)); - ret.add("predicate", predicatesJson); - ret.addProperty("model", model.getLocation().toString()); - return ret; - } - } - -} diff --git a/src/main/java/net/minecraftforge/client/model/generators/ItemModelProvider.java b/src/main/java/net/minecraftforge/client/model/generators/ItemModelProvider.java deleted file mode 100644 index 4dbb681e62..0000000000 --- a/src/main/java/net/minecraftforge/client/model/generators/ItemModelProvider.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) Forge Development LLC and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.minecraftforge.client.model.generators; - -import net.minecraft.data.PackOutput; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.item.Item; -import net.minecraftforge.common.data.ExistingFileHelper; -import net.minecraftforge.registries.ForgeRegistries; -import org.jetbrains.annotations.NotNull; - -import java.util.Objects; - -/** - * Stub class to extend for item model data providers, eliminates some - * boilerplate constructor parameters. - * - * In 1.21.4 Mojang exposed their data generators for their models. So it should be feasible to just use theirs. - * If you find something lacking feel free to open a PR so that we can extend it. - * @deprecated Use Vanilla's providers {@link net.minecraft.client.data.models.ModelProvider} - */ -@Deprecated(since = "1.21.4", forRemoval = true) -public abstract class ItemModelProvider extends ModelProvider { - - public ItemModelProvider(PackOutput output, String modid, ExistingFileHelper existingFileHelper) { - super(output, modid, ITEM_FOLDER, ItemModelBuilder::new, existingFileHelper); - } - - public ItemModelBuilder basicItem(Item item) - { - return basicItem(Objects.requireNonNull(ForgeRegistries.ITEMS.getKey(item))); - } - - public ItemModelBuilder basicItem(ResourceLocation item) - { - return getBuilder(item.toString()) - .parent(new ModelFile.UncheckedModelFile("item/generated")) - .texture("layer0", item.withPrefix("item/")); - } - - @NotNull - @Override - public String getName() { - return "Item Models: " + modid; - } -} diff --git a/src/main/java/net/minecraftforge/client/model/generators/ModelBuilder.java b/src/main/java/net/minecraftforge/client/model/generators/ModelBuilder.java deleted file mode 100644 index b50f0d4d45..0000000000 --- a/src/main/java/net/minecraftforge/client/model/generators/ModelBuilder.java +++ /dev/null @@ -1,1138 +0,0 @@ -/* - * Copyright (c) Forge Development LLC and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.minecraftforge.client.model.generators; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.function.BiConsumer; -import java.util.function.BiFunction; -import java.util.stream.Collectors; - -import com.google.common.base.Preconditions; -import com.google.gson.Gson; -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; -import com.mojang.math.Quadrant; -import com.mojang.math.Transformation; -import com.mojang.serialization.JsonOps; - -import net.minecraft.client.renderer.block.model.BlockElement; -import net.minecraft.client.renderer.block.model.BlockElementFace; -import net.minecraft.client.renderer.block.model.BlockElementRotation; -import net.minecraft.client.renderer.block.model.ItemTransform; -import net.minecraft.client.renderer.texture.MissingTextureAtlasSprite; -import net.minecraft.client.resources.model.UnbakedModel.GuiLight; -import net.minecraft.core.Direction; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.util.Mth; -import net.minecraft.world.item.ItemDisplayContext; -import net.minecraftforge.client.model.ForgeFaceData; -import net.minecraftforge.common.data.ExistingFileHelper; -import net.minecraftforge.common.util.TransformationHelper; -import org.jetbrains.annotations.Nullable; -import org.jetbrains.annotations.VisibleForTesting; -import org.joml.Quaternionf; -import org.joml.Vector3f; -import org.joml.Vector3fc; - -/** - * General purpose model builder, contains all the commonalities between item - * and block models. - * - * @see ModelProvider - * @see BlockModelBuilder - * @see ItemModelBuilder - * - * @param Self type, for simpler chaining of methods. - * - * In 1.21.4 Mojang exposed their data generators for their models. So it should be feasible to just use theirs. - * If you find something lacking feel free to open a PR so that we can extend it. - * @deprecated Use Vanilla's providers {@link net.minecraft.client.data.models.ModelProvider} - */ -@Deprecated(since = "1.21.4", forRemoval = true) -public class ModelBuilder> extends ModelFile { - - @Nullable - protected ModelFile parent; - protected final Map textures = new LinkedHashMap<>(); - protected final TransformsBuilder transforms = new TransformsBuilder(); - protected final ExistingFileHelper existingFileHelper; - - protected String renderType = null; - protected String renderTypeFast = null; - protected boolean ambientOcclusion = true; - protected GuiLight guiLight = null; - - protected final List elements = new ArrayList<>(); - - protected CustomLoaderBuilder customLoader = null; - - private final RootTransformsBuilder rootTransforms = new RootTransformsBuilder(); - - protected ModelBuilder(ResourceLocation outputLocation, ExistingFileHelper existingFileHelper) - { - super(outputLocation); - this.existingFileHelper = existingFileHelper; - } - - @SuppressWarnings("unchecked") - private T self() { return (T) this; } - - @Override - protected boolean exists() { - return true; - } - - /** - * Set the parent model for the current model. - * - * @param parent the parent model - * @return this builder - * @throws NullPointerException if {@code parent} is {@code null} - * @throws IllegalStateException if {@code parent} does not {@link ModelFile#assertExistence() exist} - */ - public T parent(ModelFile parent) { - Preconditions.checkNotNull(parent, "Parent must not be null"); - parent.assertExistence(); - this.parent = parent; - return self(); - } - - /** - * Set the texture for a given dictionary key. - * - * @param key the texture key - * @param texture the texture, can be another key e.g. {@code "#all"} - * @return this builder - * @throws NullPointerException if {@code key} is {@code null} - * @throws NullPointerException if {@code texture} is {@code null} - * @throws IllegalStateException if {@code texture} is not a key (does not start - * with {@code '#'}) and does not exist in any - * known resource pack - */ - public T texture(String key, String texture) { - Preconditions.checkNotNull(key, "Key must not be null"); - Preconditions.checkNotNull(texture, "Texture must not be null"); - if (texture.charAt(0) == '#') { - this.textures.put(key, texture); - return self(); - } else { - ResourceLocation asLoc; - if (texture.contains(":")) { - asLoc = ResourceLocation.parse(texture); - } else { - asLoc = ResourceLocation.fromNamespaceAndPath(getLocation().getNamespace(), texture); - } - return texture(key, asLoc); - } - } - - /** - * Set the texture for a given dictionary key. - * - * @param key the texture key - * @param texture the texture - * @return this builder - * @throws NullPointerException if {@code key} is {@code null} - * @throws NullPointerException if {@code texture} is {@code null} - * @throws IllegalStateException if {@code texture} is not a key (does not start - * with {@code '#'}) and does not exist in any - * known resource pack - */ - public T texture(String key, ResourceLocation texture) { - Preconditions.checkNotNull(key, "Key must not be null"); - Preconditions.checkNotNull(texture, "Texture must not be null"); - Preconditions.checkArgument(existingFileHelper.exists(texture, ModelProvider.TEXTURE), - "Texture %s does not exist in any known resource pack", texture); - this.textures.put(key, texture.toString()); - return self(); - } - - /** - * Set the render type for this model. Any render types to be used must be registered via - * {@link net.minecraftforge.client.event.RegisterNamedRenderTypesEvent RegisterNamedRenderTypesEvent}. - *

    - * Consider using {@linkplain #renderType(String, String)} if you need to set a render type for - * {@linkplain net.minecraft.client.GraphicsStatus#FAST fast graphics}. - * - * @param renderType the render type - * @return this builder - * - * @throws NullPointerException if {@code renderType} is {@code null} - * @see #renderType(String, String) - */ - public T renderType(String renderType) { - Preconditions.checkNotNull(renderType, "Render type must not be null"); - return renderType(ResourceLocation.parse(renderType)); - } - - /** - * Set the render types for this model. Any render types to be used must be registered via - * {@link net.minecraftforge.client.event.RegisterNamedRenderTypesEvent RegisterNamedRenderTypesEvent}. - * - * @param renderType the render type for {@linkplain net.minecraft.client.GraphicsStatus#FANCY fancy graphics} - * @param renderTypeFast the render type for {@linkplain net.minecraft.client.GraphicsStatus#FAST fast graphics} - * @return this builder - * - * @throws NullPointerException if {@code renderType} is {@code null} - */ - public T renderType(String renderType, String renderTypeFast) { - Preconditions.checkNotNull(renderType, "Render type must not be null"); - return renderType(ResourceLocation.parse(renderType), ResourceLocation.parse(renderTypeFast)); - } - - /** - * Set the render type for this model. Any render types to be used must be registered via - * {@link net.minecraftforge.client.event.RegisterNamedRenderTypesEvent RegisterNamedRenderTypesEvent}. - *

    - * Consider using {@linkplain #renderType(ResourceLocation, ResourceLocation)} if you need to set a render type for - * {@linkplain net.minecraft.client.GraphicsStatus#FAST fast graphics}. - * - * @param renderType the render type - * @return this builder - * - * @throws NullPointerException if {@code renderType} is {@code null} - * @see #renderType(ResourceLocation, ResourceLocation) - */ - public T renderType(ResourceLocation renderType) { - Preconditions.checkNotNull(renderType, "Render type must not be null"); - this.renderType = renderType.toString(); - this.renderTypeFast = null; - return self(); - } - - /** - * Set the render types for this model. Any render types to be used must be registered via - * {@link net.minecraftforge.client.event.RegisterNamedRenderTypesEvent RegisterNamedRenderTypesEvent}. - * - * @param renderType the render type for {@linkplain net.minecraft.client.GraphicsStatus#FANCY fancy graphics} - * @param renderTypeFast the render type for {@linkplain net.minecraft.client.GraphicsStatus#FAST fast graphics} - * @return this builder - * - * @throws NullPointerException if {@code renderType} is {@code null} - */ - public T renderType(ResourceLocation renderType, ResourceLocation renderTypeFast) { - Preconditions.checkNotNull(renderType, "Render type must not be null"); - Preconditions.checkNotNull(renderTypeFast, "Fast graphics render type must not be null"); - this.renderType = renderType.toString(); - this.renderTypeFast = renderType.toString(); - return self(); - } - - public TransformsBuilder transforms() { - return transforms; - } - - public T ao(boolean ao) { - this.ambientOcclusion = ao; - return self(); - } - - public T guiLight(GuiLight light) { - this.guiLight = light; - return self(); - } - - public ElementBuilder element() { - Preconditions.checkState(customLoader == null, "Cannot use elements and custom loaders at the same time"); - ElementBuilder ret = new ElementBuilder(); - elements.add(ret); - return ret; - } - - /** - * Get an existing element builder - * - * @param index the index of the existing element builder - * @return the element builder - * @throws IndexOutOfBoundsException if {@code} index is out of bounds - */ - public ElementBuilder element(int index) { - Preconditions.checkState(customLoader == null, "Cannot use elements and custom loaders at the same time"); - Preconditions.checkElementIndex(index, elements.size(), "Element index"); - return elements.get(index); - } - - /** - * {@return the number of elements in this model builder} - */ - public int getElementCount() - { - return elements.size(); - } - - /** - * Use a custom loader instead of the vanilla elements. - * @param customLoaderFactory function that returns the custom loader to set, given this and the {@link #existingFileHelper} - * @return the custom loader builder - */ - public > L customLoader(BiFunction customLoaderFactory) - { - Preconditions.checkState(elements.isEmpty(), "Cannot use elements and custom loaders at the same time"); - Preconditions.checkNotNull(customLoaderFactory, "customLoaderFactory must not be null"); - L customLoader = customLoaderFactory.apply(self(), existingFileHelper); - this.customLoader = customLoader; - return customLoader; - } - - public RootTransformsBuilder rootTransforms() - { - return rootTransforms; - } - - @VisibleForTesting - public JsonObject toJson() { - JsonObject root = new JsonObject(); - - if (this.parent != null) { - root.addProperty("parent", this.parent.getLocation().toString()); - } - - if (!this.ambientOcclusion) { - root.addProperty("ambientocclusion", this.ambientOcclusion); - } - - if (this.guiLight != null) { - root.addProperty("gui_light", this.guiLight.getSerializedName()); - } - - if (this.renderType != null) { - root.addProperty("render_type", this.renderType); - } - - Map transforms = this.transforms.build(); - if (!transforms.isEmpty()) { - JsonObject display = new JsonObject(); - for (Entry e : transforms.entrySet()) { - JsonObject transform = new JsonObject(); - ItemTransform vec = e.getValue(); - if (vec.equals(ItemTransform.NO_TRANSFORM)) continue; - var hasRightRotation = !vec.rightRotation().equals(ItemTransform.Deserializer.DEFAULT_ROTATION); - if (!vec.translation().equals(ItemTransform.Deserializer.DEFAULT_TRANSLATION)) { - transform.add("translation", serializeVector3f(e.getValue().translation())); - } - if (!vec.rotation().equals(ItemTransform.Deserializer.DEFAULT_ROTATION)) { - transform.add(hasRightRotation ? "left_rotation" : "rotation", serializeVector3f(vec.rotation())); - } - if (!vec.scale().equals(ItemTransform.Deserializer.DEFAULT_SCALE)) { - transform.add("scale", serializeVector3f(e.getValue().scale())); - } - if (hasRightRotation) { - transform.add("right_rotation", serializeVector3f(vec.rightRotation())); - } - display.add(e.getKey().getSerializedName(), transform); - } - root.add("display", display); - } - - if (!this.textures.isEmpty()) { - JsonObject textures = new JsonObject(); - for (Entry e : this.textures.entrySet()) { - textures.addProperty(e.getKey(), serializeLocOrKey(e.getValue())); - } - root.add("textures", textures); - } - - if (!this.elements.isEmpty()) { - JsonArray elements = new JsonArray(); - this.elements.stream().map(ElementBuilder::build).forEach(part -> { - JsonObject partObj = new JsonObject(); - partObj.add("from", serializeVector3f(part.from())); - partObj.add("to", serializeVector3f(part.to())); - - if (part.rotation() != null) { - JsonObject rotation = new JsonObject(); - rotation.add("origin", serializeVector3f(part.rotation().origin())); - rotation.addProperty("axis", part.rotation().axis().getSerializedName()); - rotation.addProperty("angle", part.rotation().angle()); - if (part.rotation().rescale()) { - rotation.addProperty("rescale", part.rotation().rescale()); - } - partObj.add("rotation", rotation); - } - - if (!part.shade()) { - partObj.addProperty("shade", part.shade()); - } - - JsonObject faces = new JsonObject(); - for (Direction dir : Direction.values()) { - BlockElementFace face = part.faces().get(dir); - if (face == null) continue; - - JsonObject faceObj = new JsonObject(); - faceObj.addProperty("texture", serializeLocOrKey(face.texture())); - if (!face.uvs().equals(part.faces().get(dir).uvs())) - faceObj.add("uv", new Gson().toJsonTree(new float[]{face.uvs().minU(), face.uvs().minV(), face.uvs().maxU(), face.uvs().maxV()})); - if (face.cullForDirection() != null) - faceObj.addProperty("cullface", face.cullForDirection().getSerializedName()); - if (face.rotation() != Quadrant.R0) - faceObj.addProperty("rotation", face.rotation().ordinal()); - if (face.tintIndex() != -1) - faceObj.addProperty("tintindex", face.tintIndex()); - if (!ForgeFaceData.DEFAULT.equals(face.data())) - faceObj.add("forge_data", ForgeFaceData.CODEC.encodeStart(JsonOps.INSTANCE, face.data()).result().get()); - faces.add(dir.getSerializedName(), faceObj); - } - if (!part.faces().isEmpty()) - partObj.add("faces", faces); - elements.add(partObj); - }); - root.add("elements", elements); - } - - // If there were any transform properties set, add them to the output. - JsonObject transform = rootTransforms.toJson(); - if (!transform.isEmpty()) - { - root.add("transform", transform); - } - - if (customLoader != null) - return customLoader.toJson(root); - - return root; - } - - private String serializeLocOrKey(String tex) { - if (tex.charAt(0) == '#') { - return tex; - } - return ResourceLocation.parse(tex).toString(); - } - - private JsonArray serializeVector3f(Vector3fc vec) { - JsonArray ret = new JsonArray(); - ret.add(serializeFloat(vec.x())); - ret.add(serializeFloat(vec.y())); - ret.add(serializeFloat(vec.z())); - return ret; - } - - private Number serializeFloat(float f) { - if ((int) f == f) { - return (int) f; - } - return f; - } - - public class ElementBuilder { - - private Vector3f from = new Vector3f(); - private Vector3f to = new Vector3f(16, 16, 16); - private final Map faces = new LinkedHashMap<>(); - private RotationBuilder rotation; - private boolean shade = true; - private ForgeFaceData data = ForgeFaceData.DEFAULT; - private int emission = 0; - - private void validateCoordinate(float coord, char name) { - Preconditions.checkArgument(!(coord < -16.0F) && !(coord > 32.0F), "Position " + name + " out of range, must be within [-16, 32]. Found: %d", coord); - } - - private void validatePosition(Vector3f pos) { - validateCoordinate(pos.x(), 'x'); - validateCoordinate(pos.y(), 'y'); - validateCoordinate(pos.z(), 'z'); - } - - /** - * Set the "from" position for this element. - * - * @param x x-position for this vector - * @param y y-position for this vector - * @param z z-position for this vector - * @return this builder - * @throws IllegalArgumentException if the vector is out of bounds (any - * coordinate not between -16 and 32, - * inclusive) - */ - public ElementBuilder from(float x, float y, float z) { - this.from = new Vector3f(x, y, z); - validatePosition(this.from); - return this; - } - - /** - * Set the "to" position for this element. - * - * @param x x-position for this vector - * @param y y-position for this vector - * @param z z-position for this vector - * @return this builder - * @throws IllegalArgumentException if the vector is out of bounds (any - * coordinate not between -16 and 32, - * inclusive) - */ - public ElementBuilder to(float x, float y, float z) { - this.to = new Vector3f(x, y, z); - validatePosition(this.to); - return this; - } - - /** - * Return or create the face builder for the given direction. - * - * @param dir the direction - * @return the face builder for the given direction - * @throws NullPointerException if {@code dir} is {@code null} - */ - public FaceBuilder face(Direction dir) { - Preconditions.checkNotNull(dir, "Direction must not be null"); - return faces.computeIfAbsent(dir, FaceBuilder::new); - } - - public RotationBuilder rotation() { - if (this.rotation == null) { - this.rotation = new RotationBuilder(); - } - return this.rotation; - } - - public ElementBuilder shade(boolean shade) { - this.shade = shade; - return this; - } - - /** - * Modify all possible faces dynamically using a function, creating new - * faces as necessary. - * - * @param action the function to apply to each direction - * @return this builder - * @throws NullPointerException if {@code action} is {@code null} - */ - public ElementBuilder allFaces(BiConsumer action) { - Arrays.stream(Direction.values()) - .forEach(d -> action.accept(d, face(d))); - return this; - } - - /** - * Modify all existing faces dynamically using a function. - * - * @param action the function to apply to each direction - * @return this builder - * @throws NullPointerException if {@code action} is {@code null} - */ - public ElementBuilder faces(BiConsumer action) { - faces.entrySet().stream() - .forEach(e -> action.accept(e.getKey(), e.getValue())); - return this; - } - - /** - * Texture all possible faces in the current element with the given - * texture, creating new faces where necessary. - * - * @param texture the texture - * @return this builder - * @throws NullPointerException if {@code texture} is {@code null} - */ - public ElementBuilder textureAll(String texture) { - return allFaces(addTexture(texture)); - } - - /** - * Texture all existing faces in the current element with the given - * texture. - * - * @param texture the texture - * @return this builder - * @throws NullPointerException if {@code texture} is {@code null} - */ - public ElementBuilder texture(String texture) { - return faces(addTexture(texture)); - } - - /** - * Create a typical cube element, creating new faces as needed, applying the - * given texture, and setting the cullface. - * - * @param texture the texture - * @return this builder - * @throws NullPointerException if {@code texture} is {@code null} - */ - public ElementBuilder cube(String texture) { - return allFaces(addTexture(texture).andThen((dir, f) -> f.cullface(dir))); - } - - /** - * Set the block and sky light of the element (0-15). - * Traditional "emissivity" values were set both of these to the same value. - * - * @param blockLight the block light - * @param skyLight the sky light - * @return this builder - */ - public ElementBuilder emissivity(int blockLight, int skyLight) { - return data(new ForgeFaceData(this.data.color(), blockLight, skyLight, this.data.ambientOcclusion(), this.data.calculateNormals())); - } - - /** - * Sets the color of the element. - * - * @param color the color in ARGB format. - * @return this builder - */ - public ElementBuilder color(int color) { - return data(new ForgeFaceData(color, this.data.blockLight(), this.data.skyLight(), this.data.ambientOcclusion(), this.data.calculateNormals())); - } - - /** - * Set the ambient occlusion of the element. - * - * @param ao the ambient occlusion - * @return this builder - */ - public ElementBuilder ao(boolean ao) { - return data(new ForgeFaceData(this.data.color(), this.data.blockLight(), this.data.skyLight(), ao, this.data.calculateNormals())); - } - - /** - * Sets whether we should calculate actual normals for the faces of this model or inherit them from facing the - * way vanilla does - * @param calc whether to calculate normals - * @return this builder - */ - public ElementBuilder calculateNormals(boolean calc) { - return data(new ForgeFaceData(this.data.color(), this.data.blockLight(), this.data.skyLight(), this.data.ambientOcclusion(), calc)); - } - - public ElementBuilder data(ForgeFaceData data) { - this.data = data; - return this; - } - - public ElementBuilder emission(int value) { - this.emission = value; - return this; - } - - private BiConsumer addTexture(String texture) { - return ($, f) -> f.texture(texture); - } - - BlockElement build() { - var faces = new LinkedHashMap(); - for (var entry : this.faces.entrySet()) { - if (faces.containsKey(entry.getKey())) - throw new IllegalArgumentException("Multiple faces defined for Direction: " + entry.getKey().getName()); - faces.put(entry.getKey(), entry.getValue().build()); - } - return new BlockElement(from, to, faces, rotation == null ? null : rotation.build(), shade, emission); - } - - public T end() { return self(); } - - public class FaceBuilder { - private Direction cullface; - private int tintindex = -1; - private String texture = MissingTextureAtlasSprite.getLocation().toString(); - private float[] uvs; - private FaceRotation rotation = FaceRotation.ZERO; - private ForgeFaceData data = ElementBuilder.this.data; - - FaceBuilder(Direction dir) { - // param unused for functional match - } - - public FaceBuilder cullface(@Nullable Direction dir) { - this.cullface = dir; - return this; - } - - public FaceBuilder tintindex(int index) { - this.tintindex = index; - return this; - } - - /** - * Set the texture for the current face. - * - * @param texture the texture - * @return this builder - * @throws NullPointerException if {@code texture} is {@code null} - */ - public FaceBuilder texture(String texture) { - Preconditions.checkNotNull(texture, "Texture must not be null"); - this.texture = texture; - return this; - } - - public FaceBuilder uvs(float u1, float v1, float u2, float v2) { - this.uvs = new float[] { u1, v1, u2, v2 }; - return this; - } - - /** - * Set the texture rotation for the current face. - * - * @param rot the rotation - * @return this builder - * @throws NullPointerException if {@code rot} is {@code null} - */ - public FaceBuilder rotation(FaceRotation rot) { - Preconditions.checkNotNull(rot, "Rotation must not be null"); - this.rotation = rot; - return this; - } - - /** - * Set the block and sky light of the face (0-15). - * Traditional "emissivity" values set both of these to the same value. - * - * @param blockLight the block light - * @param skyLight the sky light - * @return this builder - */ - public FaceBuilder emissivity(int blockLight, int skyLight) { - return data(new ForgeFaceData(this.data.color(), blockLight, skyLight, this.data.ambientOcclusion(), this.data.calculateNormals())); - } - - /** - * Sets the color of the face. - * - * @param color the color in ARGB format. - * @return this builder - */ - public FaceBuilder color(int color) { - return data(new ForgeFaceData(color, this.data.blockLight(), this.data.skyLight(), this.data.ambientOcclusion(), this.data.calculateNormals())); - } - - /** - * Set the ambient occlusion of the face. - * - * @param ao the ambient occlusion - * @return this builder - */ - public FaceBuilder ao(boolean ao) { - return data(new ForgeFaceData(this.data.color(), this.data.blockLight(), this.data.skyLight(), ao, this.data.calculateNormals())); - } - - /** - * Sets whether we should calculate actual normals for this face or inherit them from facing the - * way vanilla does - * @param calc whether to calculate normals - * @return this builder - */ - public FaceBuilder calculateNormals(boolean calc) { - return data(new ForgeFaceData(this.data.color(), this.data.blockLight(), this.data.skyLight(), this.data.ambientOcclusion(), calc)); - } - - public FaceBuilder data(ForgeFaceData data) { - this.data = data; - return this; - } - - BlockElementFace build() { - if (this.texture == null) - throw new IllegalStateException("A model face must have a texture"); - // TODO: [Forge][Rendering[[VEN] This is probably wrong, but it was BLAZING FAST!!! to write! - return new BlockElementFace(cullface, tintindex, texture, new BlockElementFace.UVs(uvs[0], uvs[1], uvs[2], uvs[3]), Quadrant.values()[rotation.rotation], this.data); - } - - public ElementBuilder end() { return ElementBuilder.this; } - } - - public class RotationBuilder { - - private Vector3f origin; - private Direction.Axis axis; - private float angle; - private boolean rescale; - - public RotationBuilder origin(float x, float y, float z) { - this.origin = new Vector3f(x, y, z); - return this; - } - - /** - * @param axis the axis of rotation - * @return this builder - * @throws NullPointerException if {@code axis} is {@code null} - */ - public RotationBuilder axis(Direction.Axis axis) { - Preconditions.checkNotNull(axis, "Axis must not be null"); - this.axis = axis; - return this; - } - - /** - * @param angle the rotation angle - * @return this builder - * @throws IllegalArgumentException if {@code angle} is invalid (not one of 0, +/-22.5, +/-45) - */ - public RotationBuilder angle(float angle) { - // Same logic from BlockPart.Deserializer#parseAngle - Preconditions.checkArgument(angle == 0.0F || Mth.abs(angle) == 22.5F || Mth.abs(angle) == 45.0F, "Invalid rotation %f found, only -45/-22.5/0/22.5/45 allowed", angle); - this.angle = angle; - return this; - } - - public RotationBuilder rescale(boolean rescale) { - this.rescale = rescale; - return this; - } - - BlockElementRotation build() { - return new BlockElementRotation(origin, axis, angle, rescale); - } - - public ElementBuilder end() { return ElementBuilder.this; } - } - } - - public enum FaceRotation { - ZERO(0), - CLOCKWISE_90(90), - UPSIDE_DOWN(180), - COUNTERCLOCKWISE_90(270), - ; - - final int rotation; - - private FaceRotation(int rotation) { - this.rotation = rotation; - } - } - - public class TransformsBuilder { - - private final Map transforms = new LinkedHashMap<>(); - - /** - * Begin building a new transform for the given perspective. - * - * @param type the perspective to create or return the builder for - * @return the builder for the given perspective - * @throws NullPointerException if {@code type} is {@code null} - */ - public TransformVecBuilder transform(ItemDisplayContext type) { - Preconditions.checkNotNull(type, "Perspective cannot be null"); - return transforms.computeIfAbsent(type, TransformVecBuilder::new); - } - - Map build() { - return this.transforms.entrySet().stream() - .collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue().build(), (k1, k2) -> { throw new IllegalArgumentException(); }, LinkedHashMap::new)); - } - - public T end() { return self(); } - - public class TransformVecBuilder { - - private Vector3f rotation = new Vector3f(ItemTransform.Deserializer.DEFAULT_ROTATION); - private Vector3f translation = new Vector3f(ItemTransform.Deserializer.DEFAULT_TRANSLATION); - private Vector3f scale = new Vector3f(ItemTransform.Deserializer.DEFAULT_SCALE); - private Vector3f rightRotation = new Vector3f(ItemTransform.Deserializer.DEFAULT_ROTATION); - - TransformVecBuilder(ItemDisplayContext type) { - // param unused for functional match - } - - public TransformVecBuilder rotation(float x, float y, float z) { - this.rotation = new Vector3f(x, y, z); - return this; - } - - public TransformVecBuilder leftRotation(float x, float y, float z) { - return rotation(x, y, z); - } - - public TransformVecBuilder translation(float x, float y, float z) { - this.translation = new Vector3f(x, y, z); - return this; - } - - public TransformVecBuilder scale(float sc) { - return scale(sc, sc, sc); - } - - public TransformVecBuilder scale(float x, float y, float z) { - this.scale = new Vector3f(x, y, z); - return this; - } - - public TransformVecBuilder rightRotation(float x, float y, float z) { - this.rightRotation = new Vector3f(x, y, z); - return this; - } - - ItemTransform build() { - return new ItemTransform(rotation, translation, scale, rightRotation); - } - - public TransformsBuilder end() { return TransformsBuilder.this; } - } - } - - public class RootTransformsBuilder { - private static final Vector3f ONE = new Vector3f(1, 1, 1); - - private Vector3f translation = new Vector3f(); - private Quaternionf leftRotation = new Quaternionf(); - private Quaternionf rightRotation = new Quaternionf(); - private Vector3f scale = ONE; - - private @Nullable TransformationHelper.TransformOrigin origin; - private @Nullable Vector3f originVec; - - RootTransformsBuilder() { } - - /** - * Sets the translation of the root transform. - * - * @param translation the translation - * @return this builder - * @throws NullPointerException if {@code translation} is {@code null} - */ - public RootTransformsBuilder translation(Vector3f translation) { - this.translation = Preconditions.checkNotNull(translation, "Translation must not be null"); - return this; - } - - /** - * Sets the translation of the root transform. - * - * @param x x translation - * @param y y translation - * @param z z translation - * @return this builder - */ - public RootTransformsBuilder translation(float x, float y, float z) { - return translation(new Vector3f(x, y, z)); - } - - /** - * Sets the left rotation of the root transform. - * - * @param rotation the left rotation - * @return this builder - * @throws NullPointerException if {@code rotation} is {@code null} - */ - public RootTransformsBuilder rotation(Quaternionf rotation) { - this.leftRotation = Preconditions.checkNotNull(rotation, "Rotation must not be null"); - return this; - } - - /** - * Sets the left rotation of the root transform. - * - * @param x x rotation - * @param y y rotation - * @param z z rotation - * @param isDegrees whether the rotation is in degrees or radians - * @return this builder - */ - public RootTransformsBuilder rotation(float x, float y, float z, boolean isDegrees) { - return rotation(TransformationHelper.quatFromXYZ(x, y, z, isDegrees)); - } - - /** - * Sets the left rotation of the root transform. - * - * @param leftRotation the left rotation - * @return this builder - * @throws NullPointerException if {@code leftRotation} is {@code null} - */ - public RootTransformsBuilder leftRotation(Quaternionf leftRotation) { - return rotation(leftRotation); - } - - /** - * Sets the left rotation of the root transform. - * - * @param x x rotation - * @param y y rotation - * @param z z rotation - * @param isDegrees whether the rotation is in degrees or radians - * @return this builder - */ - public RootTransformsBuilder leftRotation(float x, float y, float z, boolean isDegrees) { - return leftRotation(TransformationHelper.quatFromXYZ(x, y, z, isDegrees)); - } - - /** - * Sets the right rotation of the root transform. - * - * @param rightRotation the right rotation - * @return this builder - * @throws NullPointerException if {@code rightRotation} is {@code null} - */ - public RootTransformsBuilder rightRotation(Quaternionf rightRotation) { - this.rightRotation = Preconditions.checkNotNull(rightRotation, "Rotation must not be null"); - return this; - } - - /** - * Sets the right rotation of the root transform. - * - * @param x x rotation - * @param y y rotation - * @param z z rotation - * @param isDegrees whether the rotation is in degrees or radians - * @return this builder - */ - public RootTransformsBuilder rightRotation(float x, float y, float z, boolean isDegrees) { - return rightRotation(TransformationHelper.quatFromXYZ(x, y, z, isDegrees)); - } - - /** - * Sets the right rotation of the root transform. - * - * @param postRotation the right rotation - * @return this builder - * @throws NullPointerException if {@code rightRotation} is {@code null} - */ - public RootTransformsBuilder postRotation(Quaternionf postRotation) { - return rightRotation(postRotation); - } - - /** - * Sets the right rotation of the root transform. - * - * @param x x rotation - * @param y y rotation - * @param z z rotation - * @param isDegrees whether the rotation is in degrees or radians - * @return this builder - */ - public RootTransformsBuilder postRotation(float x, float y, float z, boolean isDegrees) { - return postRotation(TransformationHelper.quatFromXYZ(x, y, z, isDegrees)); - } - - /** - * Sets the scale of the root transform. - * - * @param scale the scale - * @return this builder - */ - public RootTransformsBuilder scale(float scale) { - return scale(new Vector3f(scale, scale, scale)); - } - - /** - * Sets the scale of the root transform. - * - * @param xScale x scale - * @param yScale y scale - * @param zScale z scale - * @return this builder - */ - public RootTransformsBuilder scale(float xScale, float yScale, float zScale) { - return scale(new Vector3f(xScale, yScale, zScale)); - } - - /** - * Sets the scale of the root transform. - * - * @param scale the scale vector - * @return this builder - * @throws NullPointerException if {@code scale} is {@code null} - */ - public RootTransformsBuilder scale(Vector3f scale) { - this.scale = Preconditions.checkNotNull(scale, "Scale must not be null"); - return this; - } - - /** - * Sets the root transform. - * - * @param transformation the transformation to use - * @return this builder - * @throws NullPointerException if {@code transformation} is {@code null} - */ - public RootTransformsBuilder transform(Transformation transformation) { - Preconditions.checkNotNull(transformation, "Transformation must not be null"); - this.translation = transformation.getTranslation(); - this.leftRotation = transformation.getLeftRotation(); - this.rightRotation = transformation.getRightRotation(); - this.scale = transformation.getScale(); - return this; - } - - /** - * Sets the origin of the root transform. - * - * @param origin the origin vector - * @return this builder - * @throws NullPointerException if {@code origin} is {@code null} - */ - public RootTransformsBuilder origin(Vector3f origin) { - this.originVec = Preconditions.checkNotNull(origin, "Origin must not be null"); - this.origin = null; - return this; - } - - /** - * Sets the origin of the root transform. - * - * @param origin the origin name - * @return this builder - * @throws NullPointerException if {@code origin} is {@code null} - * @throws IllegalArgumentException if {@code origin} is not {@code center}, {@code corner} or {@code opposing-corner} - */ - public RootTransformsBuilder origin(TransformationHelper.TransformOrigin origin) { - this.origin = Preconditions.checkNotNull(origin, "Origin must not be null"); - this.originVec = null; - return this; - } - - /** - * Finish configuring the parent builder - * @return the parent block model builder - */ - public ModelBuilder end() { - return ModelBuilder.this; - } - - public JsonObject toJson() { - // Write the transform to an object - JsonObject transform = new JsonObject(); - - if (!translation.equals(0, 0, 0)) - transform.add("translation", writeVec3(translation)); - - if (!scale.equals(ONE)) - transform.add("scale", writeVec3(scale)); - - if (!leftRotation.equals(0, 0, 0, 1)) - transform.add("rotation", writeQuaternion(leftRotation)); - - if (!rightRotation.equals(0, 0, 0, 1)) - transform.add("post_rotation", writeQuaternion(rightRotation)); - - if (origin != null) - transform.addProperty("origin", origin.getSerializedName()); - else if (originVec != null && !originVec.equals(0, 0, 0)) - transform.add("origin", writeVec3(originVec)); - - return transform; - } - - private static JsonArray writeVec3(Vector3f vector) { - JsonArray array = new JsonArray(); - array.add(vector.x()); - array.add(vector.y()); - array.add(vector.z()); - return array; - } - - private static JsonArray writeQuaternion(Quaternionf quaternion) { - JsonArray array = new JsonArray(); - array.add(quaternion.x()); - array.add(quaternion.y()); - array.add(quaternion.z()); - array.add(quaternion.w()); - return array; - } - } -} diff --git a/src/main/java/net/minecraftforge/client/model/generators/ModelFile.java b/src/main/java/net/minecraftforge/client/model/generators/ModelFile.java deleted file mode 100644 index 628e781d11..0000000000 --- a/src/main/java/net/minecraftforge/client/model/generators/ModelFile.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) Forge Development LLC and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.minecraftforge.client.model.generators; - -import com.google.common.base.Preconditions; - -import net.minecraft.resources.ResourceLocation; -import net.minecraftforge.common.data.ExistingFileHelper; - -/** - * In 1.21.4 Mojang exposed their data generators for their models. So it should be feasible to just use theirs. - * If you find something lacking feel free to open a PR so that we can extend it. - * @deprecated Use Vanilla's providers {@link net.minecraft.client.data.models.ModelProvider} - */ -@Deprecated(since = "1.21.4", forRemoval = true) -public abstract class ModelFile { - - protected ResourceLocation location; - - protected ModelFile(ResourceLocation location) { - this.location = location; - } - - protected abstract boolean exists(); - - public ResourceLocation getLocation() { - assertExistence(); - return location; - } - - /** - * Assert that this model exists. - * @throws IllegalStateException if this model does not exist - */ - public void assertExistence() { - Preconditions.checkState(exists(), "Model at %s does not exist", location); - } - - public ResourceLocation getUncheckedLocation() { - return location; - } - - public static class UncheckedModelFile extends ModelFile { - - public UncheckedModelFile(String location) { - this(ResourceLocation.parse(location)); - } - public UncheckedModelFile(ResourceLocation location) { - super(location); - } - - @Override - protected boolean exists() { - return true; - } - } - - public static class ExistingModelFile extends ModelFile { - private final ExistingFileHelper existingHelper; - - public ExistingModelFile(ResourceLocation location, ExistingFileHelper existingHelper) { - super(location); - this.existingHelper = existingHelper; - } - - @Override - protected boolean exists() { - if (getUncheckedLocation().getPath().contains(".")) - return existingHelper.exists(getUncheckedLocation(), ModelProvider.MODEL_WITH_EXTENSION); - else - return existingHelper.exists(getUncheckedLocation(), ModelProvider.MODEL); - } - } -} diff --git a/src/main/java/net/minecraftforge/client/model/generators/ModelProvider.java b/src/main/java/net/minecraftforge/client/model/generators/ModelProvider.java deleted file mode 100644 index 1ad1026d87..0000000000 --- a/src/main/java/net/minecraftforge/client/model/generators/ModelProvider.java +++ /dev/null @@ -1,419 +0,0 @@ -/* - * Copyright (c) Forge Development LLC and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.minecraftforge.client.model.generators; - -import com.google.common.base.Preconditions; -import java.nio.file.Path; -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.CompletableFuture; -import java.util.function.BiFunction; -import java.util.function.Function; -import net.minecraft.data.CachedOutput; -import net.minecraft.data.DataProvider; -import net.minecraft.data.PackOutput; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.server.packs.PackType; -import net.minecraftforge.common.data.ExistingFileHelper; -import net.minecraftforge.common.data.ExistingFileHelper.ResourceType; -import org.jetbrains.annotations.VisibleForTesting; - -/** - * In 1.21.4 Mojang exposed their data generators for their models. So it should be feasible to just use theirs. - * If you find something lacking feel free to open a PR so that we can extend it. - * @deprecated Use Vanilla's providers {@link net.minecraft.client.data.models.ModelProvider} - */ -@Deprecated(since = "1.21.4", forRemoval = true) -public abstract class ModelProvider> implements DataProvider { - - public static final String BLOCK_FOLDER = "block"; - public static final String ITEM_FOLDER = "item"; - - protected static final ResourceType TEXTURE = new ResourceType(PackType.CLIENT_RESOURCES, ".png", "textures"); - protected static final ResourceType MODEL = new ResourceType(PackType.CLIENT_RESOURCES, ".json", "models"); - protected static final ResourceType MODEL_WITH_EXTENSION = new ResourceType(PackType.CLIENT_RESOURCES, "", "models"); - - protected final PackOutput output; - protected final String modid; - protected final String folder; - protected final Function factory; - @VisibleForTesting - public final Map generatedModels = new HashMap<>(); - @VisibleForTesting - public final ExistingFileHelper existingFileHelper; - - protected abstract void registerModels(); - - public ModelProvider(PackOutput output, String modid, String folder, Function factory, ExistingFileHelper existingFileHelper) { - Preconditions.checkNotNull(output); - this.output = output; - Preconditions.checkNotNull(modid); - this.modid = modid; - Preconditions.checkNotNull(folder); - this.folder = folder; - Preconditions.checkNotNull(factory); - this.factory = factory; - Preconditions.checkNotNull(existingFileHelper); - this.existingFileHelper = existingFileHelper; - } - - public ModelProvider(PackOutput output, String modid, String folder, BiFunction builderFromModId, ExistingFileHelper existingFileHelper) { - this(output, modid, folder, loc->builderFromModId.apply(loc, existingFileHelper), existingFileHelper); - } - - public T getBuilder(String path) { - Preconditions.checkNotNull(path, "Path must not be null"); - ResourceLocation outputLoc = extendWithFolder(path.contains(":") ? ResourceLocation.parse(path) : ResourceLocation.fromNamespaceAndPath(modid, path)); - this.existingFileHelper.trackGenerated(outputLoc, MODEL); - return generatedModels.computeIfAbsent(outputLoc, factory); - } - - private ResourceLocation extendWithFolder(ResourceLocation rl) { - if (rl.getPath().contains("/")) { - return rl; - } - return rl.withPrefix(folder + '/'); - } - - public ResourceLocation modLoc(String name) { - return ResourceLocation.fromNamespaceAndPath(modid, name); - } - - public ResourceLocation mcLoc(String name) { - return ResourceLocation.parse(name); - } - - public T withExistingParent(String name, String parent) { - return withExistingParent(name, mcLoc(parent)); - } - - public T withExistingParent(String name, ResourceLocation parent) { - return getBuilder(name).parent(getExistingFile(parent)); - } - - public T cube(String name, ResourceLocation down, ResourceLocation up, ResourceLocation north, ResourceLocation south, ResourceLocation east, ResourceLocation west) { - return withExistingParent(name, "cube") - .texture("down", down) - .texture("up", up) - .texture("north", north) - .texture("south", south) - .texture("east", east) - .texture("west", west); - } - - private T singleTexture(String name, String parent, ResourceLocation texture) { - return singleTexture(name, mcLoc(parent), texture); - } - - public T singleTexture(String name, ResourceLocation parent, ResourceLocation texture) { - return singleTexture(name, parent, "texture", texture); - } - - private T singleTexture(String name, String parent, String textureKey, ResourceLocation texture) { - return singleTexture(name, mcLoc(parent), textureKey, texture); - } - - public T singleTexture(String name, ResourceLocation parent, String textureKey, ResourceLocation texture) { - return withExistingParent(name, parent) - .texture(textureKey, texture); - } - - public T cubeAll(String name, ResourceLocation texture) { - return singleTexture(name, BLOCK_FOLDER + "/cube_all", "all", texture); - } - - public T cubeTop(String name, ResourceLocation side, ResourceLocation top) { - return withExistingParent(name, BLOCK_FOLDER + "/cube_top") - .texture("side", side) - .texture("top", top); - } - - private T sideBottomTop(String name, String parent, ResourceLocation side, ResourceLocation bottom, ResourceLocation top) { - return withExistingParent(name, parent) - .texture("side", side) - .texture("bottom", bottom) - .texture("top", top); - } - - public T cubeBottomTop(String name, ResourceLocation side, ResourceLocation bottom, ResourceLocation top) { - return sideBottomTop(name, BLOCK_FOLDER + "/cube_bottom_top", side, bottom, top); - } - - public T cubeColumn(String name, ResourceLocation side, ResourceLocation end) { - return withExistingParent(name, BLOCK_FOLDER + "/cube_column") - .texture("side", side) - .texture("end", end); - } - - public T cubeColumnHorizontal(String name, ResourceLocation side, ResourceLocation end) { - return withExistingParent(name, BLOCK_FOLDER + "/cube_column_horizontal") - .texture("side", side) - .texture("end", end); - } - - public T orientableVertical(String name, ResourceLocation side, ResourceLocation front) { - return withExistingParent(name, BLOCK_FOLDER + "/orientable_vertical") - .texture("side", side) - .texture("front", front); - } - - public T orientableWithBottom(String name, ResourceLocation side, ResourceLocation front, ResourceLocation bottom, ResourceLocation top) { - return withExistingParent(name, BLOCK_FOLDER + "/orientable_with_bottom") - .texture("side", side) - .texture("front", front) - .texture("bottom", bottom) - .texture("top", top); - } - - public T orientable(String name, ResourceLocation side, ResourceLocation front, ResourceLocation top) { - return withExistingParent(name, BLOCK_FOLDER + "/orientable") - .texture("side", side) - .texture("front", front) - .texture("top", top); - } - - public T crop(String name, ResourceLocation crop) { - return singleTexture(name, BLOCK_FOLDER + "/crop", "crop", crop); - } - - public T cross(String name, ResourceLocation cross) { - return singleTexture(name, BLOCK_FOLDER + "/cross", "cross", cross); - } - - public T stairs(String name, ResourceLocation side, ResourceLocation bottom, ResourceLocation top) { - return sideBottomTop(name, BLOCK_FOLDER + "/stairs", side, bottom, top); - } - - public T stairsOuter(String name, ResourceLocation side, ResourceLocation bottom, ResourceLocation top) { - return sideBottomTop(name, BLOCK_FOLDER + "/outer_stairs", side, bottom, top); - } - - public T stairsInner(String name, ResourceLocation side, ResourceLocation bottom, ResourceLocation top) { - return sideBottomTop(name, BLOCK_FOLDER + "/inner_stairs", side, bottom, top); - } - - public T slab(String name, ResourceLocation side, ResourceLocation bottom, ResourceLocation top) { - return sideBottomTop(name, BLOCK_FOLDER + "/slab", side, bottom, top); - } - - public T slabTop(String name, ResourceLocation side, ResourceLocation bottom, ResourceLocation top) { - return sideBottomTop(name, BLOCK_FOLDER + "/slab_top", side, bottom, top); - } - - public T button(String name, ResourceLocation texture) { - return singleTexture(name, BLOCK_FOLDER + "/button", texture); - } - - public T buttonPressed(String name, ResourceLocation texture) { - return singleTexture(name, BLOCK_FOLDER + "/button_pressed", texture); - } - - public T buttonInventory(String name, ResourceLocation texture) { - return singleTexture(name, BLOCK_FOLDER + "/button_inventory", texture); - } - - public T pressurePlate(String name, ResourceLocation texture) { - return singleTexture(name, BLOCK_FOLDER + "/pressure_plate_up", texture); - } - - public T pressurePlateDown(String name, ResourceLocation texture) { - return singleTexture(name, BLOCK_FOLDER + "/pressure_plate_down", texture); - } - - public T sign(String name, ResourceLocation texture) { - return getBuilder(name).texture("particle", texture); - } - - public T fencePost(String name, ResourceLocation texture) { - return singleTexture(name, BLOCK_FOLDER + "/fence_post", texture); - } - - public T fenceSide(String name, ResourceLocation texture) { - return singleTexture(name, BLOCK_FOLDER + "/fence_side", texture); - } - - public T fenceInventory(String name, ResourceLocation texture) { - return singleTexture(name, BLOCK_FOLDER + "/fence_inventory", texture); - } - - public T fenceGate(String name, ResourceLocation texture) { - return singleTexture(name, BLOCK_FOLDER + "/template_fence_gate", texture); - } - - public T fenceGateOpen(String name, ResourceLocation texture) { - return singleTexture(name, BLOCK_FOLDER + "/template_fence_gate_open", texture); - } - - public T fenceGateWall(String name, ResourceLocation texture) { - return singleTexture(name, BLOCK_FOLDER + "/template_fence_gate_wall", texture); - } - - public T fenceGateWallOpen(String name, ResourceLocation texture) { - return singleTexture(name, BLOCK_FOLDER + "/template_fence_gate_wall_open", texture); - } - - public T wallPost(String name, ResourceLocation wall) { - return singleTexture(name, BLOCK_FOLDER + "/template_wall_post", "wall", wall); - } - - public T wallSide(String name, ResourceLocation wall) { - return singleTexture(name, BLOCK_FOLDER + "/template_wall_side", "wall", wall); - } - - public T wallSideTall(String name, ResourceLocation wall) { - return singleTexture(name, BLOCK_FOLDER + "/template_wall_side_tall", "wall", wall); - } - - public T wallInventory(String name, ResourceLocation wall) { - return singleTexture(name, BLOCK_FOLDER + "/wall_inventory", "wall", wall); - } - - private T pane(String name, String parent, ResourceLocation pane, ResourceLocation edge) { - return withExistingParent(name, BLOCK_FOLDER + "/" + parent) - .texture("pane", pane) - .texture("edge", edge); - } - - public T panePost(String name, ResourceLocation pane, ResourceLocation edge) { - return pane(name, "template_glass_pane_post", pane, edge); - } - - public T paneSide(String name, ResourceLocation pane, ResourceLocation edge) { - return pane(name, "template_glass_pane_side", pane, edge); - } - - public T paneSideAlt(String name, ResourceLocation pane, ResourceLocation edge) { - return pane(name, "template_glass_pane_side_alt", pane, edge); - } - - public T paneNoSide(String name, ResourceLocation pane) { - return singleTexture(name, BLOCK_FOLDER + "/template_glass_pane_noside", "pane", pane); - } - - public T paneNoSideAlt(String name, ResourceLocation pane) { - return singleTexture(name, BLOCK_FOLDER + "/template_glass_pane_noside_alt", "pane", pane); - } - - private T door(String name, String model, ResourceLocation bottom, ResourceLocation top) { - return withExistingParent(name, BLOCK_FOLDER + "/" + model) - .texture("bottom", bottom) - .texture("top", top); - } - - public T doorBottomLeft(String name, ResourceLocation bottom, ResourceLocation top) { - return door(name, "door_bottom_left", bottom, top); - } - - public T doorBottomLeftOpen(String name, ResourceLocation bottom, ResourceLocation top) { - return door(name, "door_bottom_left_open", bottom, top); - } - - public T doorBottomRight(String name, ResourceLocation bottom, ResourceLocation top) { - return door(name, "door_bottom_right", bottom, top); - } - - public T doorBottomRightOpen(String name, ResourceLocation bottom, ResourceLocation top) { - return door(name, "door_bottom_right_open", bottom, top); - } - - public T doorTopLeft(String name, ResourceLocation bottom, ResourceLocation top) { - return door(name, "door_top_left", bottom, top); - } - - public T doorTopLeftOpen(String name, ResourceLocation bottom, ResourceLocation top) { - return door(name, "door_top_left_open", bottom, top); - } - - public T doorTopRight(String name, ResourceLocation bottom, ResourceLocation top) { - return door(name, "door_top_right", bottom, top); - } - - public T doorTopRightOpen(String name, ResourceLocation bottom, ResourceLocation top) { - return door(name, "door_top_right_open", bottom, top); - } - - public T trapdoorBottom(String name, ResourceLocation texture) { - return singleTexture(name, BLOCK_FOLDER + "/template_trapdoor_bottom", texture); - } - - public T trapdoorTop(String name, ResourceLocation texture) { - return singleTexture(name, BLOCK_FOLDER + "/template_trapdoor_top", texture); - } - - public T trapdoorOpen(String name, ResourceLocation texture) { - return singleTexture(name, BLOCK_FOLDER + "/template_trapdoor_open", texture); - } - - public T trapdoorOrientableBottom(String name, ResourceLocation texture) { - return singleTexture(name, BLOCK_FOLDER + "/template_orientable_trapdoor_bottom", texture); - } - - public T trapdoorOrientableTop(String name, ResourceLocation texture) { - return singleTexture(name, BLOCK_FOLDER + "/template_orientable_trapdoor_top", texture); - } - - public T trapdoorOrientableOpen(String name, ResourceLocation texture) { - return singleTexture(name, BLOCK_FOLDER + "/template_orientable_trapdoor_open", texture); - } - - public T torch(String name, ResourceLocation torch) { - return singleTexture(name, BLOCK_FOLDER + "/template_torch", "torch", torch); - } - - public T torchWall(String name, ResourceLocation torch) { - return singleTexture(name, BLOCK_FOLDER + "/template_torch_wall", "torch", torch); - } - - public T carpet(String name, ResourceLocation wool) { - return singleTexture(name, BLOCK_FOLDER + "/carpet", "wool", wool); - } - - public T leaves(String name, ResourceLocation texture) { - return singleTexture(name, BLOCK_FOLDER + "/leaves", "all", texture) - .renderType("cutout_mipped", "solid"); - } - - /** - * {@return a model builder that's not directly saved to disk. Meant for use in custom model loaders.} - */ - public T nested() { - return factory.apply(ResourceLocation.fromNamespaceAndPath("dummy", "dummy")); - } - - public ModelFile.ExistingModelFile getExistingFile(ResourceLocation path) { - ModelFile.ExistingModelFile ret = new ModelFile.ExistingModelFile(extendWithFolder(path), existingFileHelper); - ret.assertExistence(); - return ret; - } - - protected void clear() { - generatedModels.clear(); - } - - @Override - public CompletableFuture run(CachedOutput cache) { - clear(); - registerModels(); - return generateAll(cache); - } - - protected CompletableFuture generateAll(CachedOutput cache) { - CompletableFuture[] futures = new CompletableFuture[this.generatedModels.size()]; - int i = 0; - - for (T model : this.generatedModels.values()) { - Path target = getPath(model); - futures[i++] = DataProvider.saveStable(cache, model.toJson(), target); - } - - return CompletableFuture.allOf(futures); - } - - protected Path getPath(T model) { - ResourceLocation loc = model.getLocation(); - return this.output.getOutputFolder(PackOutput.Target.RESOURCE_PACK).resolve(loc.getNamespace()).resolve("models").resolve(loc.getPath() + ".json"); - } -} \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/client/model/generators/MultiPartBlockStateBuilder.java b/src/main/java/net/minecraftforge/client/model/generators/MultiPartBlockStateBuilder.java deleted file mode 100644 index 0f5eb34d2f..0000000000 --- a/src/main/java/net/minecraftforge/client/model/generators/MultiPartBlockStateBuilder.java +++ /dev/null @@ -1,264 +0,0 @@ -/* - * Copyright (c) Forge Development LLC and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.minecraftforge.client.model.generators; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.List; -import java.util.Map.Entry; - -import com.google.common.base.Preconditions; -import com.google.common.collect.Multimap; -import com.google.common.collect.MultimapBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; - -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.state.properties.Property; - -/** - * In 1.21.4 Mojang exposed their data generators for their models. So it should be feasible to just use theirs. - * If you find something lacking feel free to open a PR so that we can extend it. - * @deprecated Use Vanilla's providers {@link net.minecraft.client.data.models.ModelProvider} - */ -@Deprecated(since = "1.21.4", forRemoval = true) -public final class MultiPartBlockStateBuilder implements IGeneratedBlockState { - private final List parts = new ArrayList<>(); - private final Block owner; - - public MultiPartBlockStateBuilder(Block owner) { - this.owner = owner; - } - - /** - * Creates a builder for models to assign to a {@link PartBuilder}, which when - * completed via {@link ConfiguredModel.Builder#addModel()} will assign the - * resultant set of models to the part and return it for further processing. - * - * @return the model builder - * @see ConfiguredModel.Builder - */ - public ConfiguredModel.Builder part() { - return ConfiguredModel.builder(this); - } - - MultiPartBlockStateBuilder addPart(PartBuilder part) { - this.parts.add(part); - return this; - } - - @Override - public JsonObject toJson() { - JsonArray variants = new JsonArray(); - for (PartBuilder part : parts) { - variants.add(part.toJson()); - } - JsonObject main = new JsonObject(); - main.add("multipart", variants); - return main; - } - - public class PartBuilder { - public BlockStateProvider.ConfiguredModelList models; - public boolean useOr; - public final Multimap, Comparable> conditions = MultimapBuilder.linkedHashKeys().arrayListValues().build(); - public final List nestedConditionGroups = new ArrayList<>(); - - PartBuilder(BlockStateProvider.ConfiguredModelList models) { - this.models = models; - } - - /** - * Makes this part get applied if any of the conditions/condition groups are true, instead of all of them needing to be true. - */ - public PartBuilder useOr() { - this.useOr = true; - return this; - } - - /** - * Set a condition for this part, which consists of a property and a set of - * valid values. Can be called multiple times for multiple different properties. - * - * @param the type of the property value - * @param prop the property - * @param values a set of valid values - * @return this builder - * @throws NullPointerException if {@code prop} is {@code null} - * @throws NullPointerException if {@code values} is {@code null} - * @throws IllegalArgumentException if {@code values} is empty - * @throws IllegalArgumentException if {@code prop} has already been configured - * @throws IllegalArgumentException if {@code prop} is not applicable to the - * current block's state - * @throws IllegalStateException if {@code !nestedConditionGroups.isEmpty()} - */ - @SafeVarargs - public final > PartBuilder condition(Property prop, T... values) { - Preconditions.checkNotNull(prop, "Property must not be null"); - Preconditions.checkNotNull(values, "Value list must not be null"); - Preconditions.checkArgument(values.length > 0, "Value list must not be empty"); - Preconditions.checkArgument(!conditions.containsKey(prop), "Cannot set condition for property \"%s\" more than once", prop.getName()); - Preconditions.checkArgument(canApplyTo(owner), "IProperty %s is not valid for the block %s", prop, owner); - Preconditions.checkState(nestedConditionGroups.isEmpty(), "Can't have normal conditions if there are already nested condition groups"); - this.conditions.putAll(prop, Arrays.asList(values)); - return this; - } - - /** - * Allows having nested groups of conditions if there are not any normal conditions. - * @throws IllegalStateException if {@code !conditions.isEmpty()} - */ - public final ConditionGroup nestedGroup() { - Preconditions.checkState(conditions.isEmpty(), "Can't have nested condition groups if there are already normal conditions"); - ConditionGroup group = new ConditionGroup(); - this.nestedConditionGroups.add(group); - return group; - } - - public MultiPartBlockStateBuilder end() { return MultiPartBlockStateBuilder.this; } - - JsonObject toJson() { - JsonObject out = new JsonObject(); - if (!conditions.isEmpty()) { - out.add("when", MultiPartBlockStateBuilder.toJson(this.conditions, this.useOr)); - } else if (!nestedConditionGroups.isEmpty()) { - out.add("when", MultiPartBlockStateBuilder.toJson(this.nestedConditionGroups, this.useOr)); - } - out.add("apply", models.toJSON()); - return out; - } - - public boolean canApplyTo(Block b) { - return b.getStateDefinition().getProperties().containsAll(conditions.keySet()); - } - - public class ConditionGroup { - public final Multimap, Comparable> conditions = MultimapBuilder.linkedHashKeys().arrayListValues().build(); - public final List nestedConditionGroups = new ArrayList<>(); - private ConditionGroup parent = null; - public boolean useOr; - - /** - * Set a condition for this part, which consists of a property and a set of - * valid values. Can be called multiple times for multiple different properties. - * - * @param the type of the property value - * @param prop the property - * @param values a set of valid values - * @return this builder - * @throws NullPointerException if {@code prop} is {@code null} - * @throws NullPointerException if {@code values} is {@code null} - * @throws IllegalArgumentException if {@code values} is empty - * @throws IllegalArgumentException if {@code prop} has already been configured - * @throws IllegalArgumentException if {@code prop} is not applicable to the - * current block's state - * @throws IllegalStateException if {@code !nestedConditionGroups.isEmpty()} - */ - @SafeVarargs - public final > ConditionGroup condition(Property prop, T... values) { - Preconditions.checkNotNull(prop, "Property must not be null"); - Preconditions.checkNotNull(values, "Value list must not be null"); - Preconditions.checkArgument(values.length > 0, "Value list must not be empty"); - Preconditions.checkArgument(!conditions.containsKey(prop), "Cannot set condition for property \"%s\" more than once", prop.getName()); - Preconditions.checkArgument(canApplyTo(owner), "IProperty %s is not valid for the block %s", prop, owner); - Preconditions.checkState(nestedConditionGroups.isEmpty(), "Can't have normal conditions if there are already nested condition groups"); - this.conditions.putAll(prop, Arrays.asList(values)); - return this; - } - - /** - * Allows having nested groups of conditions if there are not any normal conditions. - * @throws IllegalStateException if {@code !conditions.isEmpty()} - */ - public ConditionGroup nestedGroup() { - Preconditions.checkState(conditions.isEmpty(), "Can't have nested condition groups if there are already normal conditions"); - ConditionGroup group = new ConditionGroup(); - group.parent = this; - this.nestedConditionGroups.add(group); - return group; - } - - /** - * Ends this nested condition group and returns the parent condition group - * - * @throws IllegalStateException If this is not a nested condition group - */ - public ConditionGroup endNestedGroup() { - if (parent == null) - throw new IllegalStateException("This condition group is not nested, use end() instead"); - return parent; - } - - /** - * Ends this condition group and returns the part builder - * - * @throws IllegalStateException If this is a nested condition group - */ - public MultiPartBlockStateBuilder.PartBuilder end() { - if (this.parent != null) - throw new IllegalStateException("This is a nested condition group, use endNestedGroup() instead"); - return MultiPartBlockStateBuilder.PartBuilder.this; - } - - /** - * Makes this part get applied if any of the conditions/condition groups are true, instead of all of them needing to be true. - */ - public ConditionGroup useOr() { - this.useOr = true; - return this; - } - - JsonObject toJson() { - if (!this.conditions.isEmpty()) - return MultiPartBlockStateBuilder.toJson(this.conditions, this.useOr); - else if (!this.nestedConditionGroups.isEmpty()) - return MultiPartBlockStateBuilder.toJson(this.nestedConditionGroups, this.useOr); - return new JsonObject(); - } - } - } - - private static JsonObject toJson(List conditions, boolean useOr) { - JsonObject groupJson = new JsonObject(); - JsonArray innerGroupJson = new JsonArray(); - groupJson.add(useOr ? "OR" : "AND", innerGroupJson); - for (PartBuilder.ConditionGroup group : conditions) - innerGroupJson.add(group.toJson()); - return groupJson; - } - - private static JsonObject toJson(Multimap, Comparable> conditions, boolean useOr) { - JsonObject groupJson = new JsonObject(); - for (Entry, Collection>> e : conditions.asMap().entrySet()) { - StringBuilder activeString = new StringBuilder(); - for (Comparable val : e.getValue()) { - if (!activeString.isEmpty()) - activeString.append("|"); - activeString.append(getName(e.getKey(), val)); - } - groupJson.addProperty(e.getKey().getName(), activeString.toString()); - } - - if (useOr) { - JsonArray innerWhen = new JsonArray(); - for (Entry entry : groupJson.entrySet()) { - JsonObject obj = new JsonObject(); - obj.add(entry.getKey(), entry.getValue()); - innerWhen.add(obj); - } - groupJson = new JsonObject(); - groupJson.add("OR", innerWhen); - } - return groupJson; - } - - @SuppressWarnings({ "unchecked", "rawtypes" }) - private static String getName(Property key, Comparable value) { - return ((Property)key).getName((Comparable)value); - } -} diff --git a/src/main/java/net/minecraftforge/client/model/generators/VariantBlockStateBuilder.java b/src/main/java/net/minecraftforge/client/model/generators/VariantBlockStateBuilder.java deleted file mode 100644 index eef49b6391..0000000000 --- a/src/main/java/net/minecraftforge/client/model/generators/VariantBlockStateBuilder.java +++ /dev/null @@ -1,332 +0,0 @@ -/* - * Copyright (c) Forge Development LLC and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.minecraftforge.client.model.generators; - -import java.util.Comparator; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Objects; -import java.util.Set; -import java.util.SortedMap; -import java.util.SortedSet; -import java.util.TreeSet; -import java.util.function.Function; -import java.util.function.Predicate; - -import com.google.common.base.Preconditions; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; -import com.google.gson.JsonObject; - -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.block.state.properties.Property; -import net.minecraftforge.client.model.generators.BlockStateProvider.ConfiguredModelList; -import org.jetbrains.annotations.Nullable; - -/** - * Builder for variant-type blockstates, i.e. non-multipart blockstates. Should - * not be manually instantiated, instead use - * {@link BlockStateProvider#getVariantBuilder(Block)}. - *

    - * Variants can either be set via - * {@link #setModels(PartialBlockstate, ConfiguredModel...)} or - * {@link #addModels(PartialBlockstate, ConfiguredModel...)}, where model(s) can - * be assigned directly to {@link PartialBlockstate partial states}, or builder - * style via {@link #partialState()} and its subsequent methods. - *

    - * This class also provides the convenience methods - * {@link #forAllStates(Function)} and - * {@link #forAllStatesExcept(Function, Property...)} for cases where the model - * for each variant can be decided dynamically based on the state's property - * values. - * - * @see BlockStateProvider - * - * In 1.21.4 Mojang exposed their data generators for their models. So it should be feasible to just use theirs. - * If you find something lacking feel free to open a PR so that we can extend it. - * @deprecated Use Vanilla's providers {@link net.minecraft.client.data.models.ModelProvider} - */ -@Deprecated(since = "1.21.4", forRemoval = true) -public class VariantBlockStateBuilder implements IGeneratedBlockState -{ - - private final Block owner; - private final Map models = new LinkedHashMap<>(); - private final Set coveredStates = new HashSet<>(); - - VariantBlockStateBuilder(Block owner) { - this.owner = owner; - } - - public Map getModels() { - return models; - } - - public Block getOwner() { - return owner; - } - - @Override - public JsonObject toJson() { - List missingStates = Lists.newArrayList(owner.getStateDefinition().getPossibleStates()); - missingStates.removeAll(coveredStates); - Preconditions.checkState(missingStates.isEmpty(), "Blockstate for block %s does not cover all states. Missing: %s", owner, missingStates); - JsonObject variants = new JsonObject(); - getModels().entrySet().stream() - .sorted(Entry.comparingByKey(PartialBlockstate.comparingByProperties())) - .forEach(entry -> variants.add(entry.getKey().toString(), entry.getValue().toJSON())); - JsonObject main = new JsonObject(); - main.add("variants", variants); - return main; - } - - /** - * Assign some models to a given {@link PartialBlockstate partial state}. - * - * @param state The {@link PartialBlockstate partial state} for which to add - * the models - * @param models A set of models to add to this state - * @return this builder - * @throws NullPointerException if {@code state} is {@code null} - * @throws IllegalArgumentException if {@code models} is empty - * @throws IllegalArgumentException if {@code state}'s owning block differs from - * the builder's - * @throws IllegalArgumentException if {@code state} partially matches another - * state which has already been configured - */ - public VariantBlockStateBuilder addModels(PartialBlockstate state, ConfiguredModel... models) { - Preconditions.checkNotNull(state, "state must not be null"); - Preconditions.checkArgument(models.length > 0, "Cannot set models to empty array"); - Preconditions.checkArgument(state.getOwner() == owner, "Cannot set models for a different block. Found: %s, Current: %s", state.getOwner(), owner); - if (!this.models.containsKey(state)) { - Preconditions.checkArgument(disjointToAll(state), "Cannot set models for a state for which a partial match has already been configured"); - this.models.put(state, new ConfiguredModelList(models)); - for (BlockState fullState : owner.getStateDefinition().getPossibleStates()) { - if (state.test(fullState)) { - coveredStates.add(fullState); - } - } - } else { - this.models.compute(state, ($, cml) -> cml.append(models)); - } - return this; - } - - /** - * Assign some models to a given {@link PartialBlockstate partial state}, - * throwing an exception if the state has already been configured. Otherwise, - * simply calls {@link #addModels(PartialBlockstate, ConfiguredModel...)}. - * - * @param state The {@link PartialBlockstate partial state} for which to set - * the models - * @param model A set of models to assign to this state - * @return this builder - * @throws IllegalArgumentException if {@code state} has already been configured - * @see #addModels(PartialBlockstate, ConfiguredModel...) - */ - public VariantBlockStateBuilder setModels(PartialBlockstate state, ConfiguredModel... model) { - Preconditions.checkArgument(!models.containsKey(state), "Cannot set models for a state that has already been configured: %s", state); - addModels(state, model); - return this; - } - - private boolean disjointToAll(PartialBlockstate newState) { - return coveredStates.stream().noneMatch(newState); - } - - public PartialBlockstate partialState() { - return new PartialBlockstate(owner, this); - } - - public VariantBlockStateBuilder forAllStates(Function mapper) { - return forAllStatesExcept(mapper); - } - - public VariantBlockStateBuilder forAllStatesExcept(Function mapper, Property... ignored) { - Set seen = new HashSet<>(); - for (BlockState fullState : owner.getStateDefinition().getPossibleStates()) { - Map, Comparable> propertyValues = Maps.newLinkedHashMap(fullState.getValues()); - for (Property p : ignored) { - propertyValues.remove(p); - } - PartialBlockstate partialState = new PartialBlockstate(owner, propertyValues, this); - if (seen.add(partialState)) { - setModels(partialState, mapper.apply(fullState)); - } - } - return this; - } - - public static class PartialBlockstate implements Predicate { - private final Block owner; - private final SortedMap, Comparable> setStates; - @Nullable - private final VariantBlockStateBuilder outerBuilder; - - PartialBlockstate(Block owner, @Nullable VariantBlockStateBuilder outerBuilder) { - this(owner, ImmutableMap.of(), outerBuilder); - } - - PartialBlockstate(Block owner, Map, Comparable> setStates, @Nullable VariantBlockStateBuilder outerBuilder) { - this.owner = owner; - this.outerBuilder = outerBuilder; - for (Map.Entry, Comparable> entry : setStates.entrySet()) { - Property prop = entry.getKey(); - Comparable value = entry.getValue(); - Preconditions.checkArgument(owner.getStateDefinition().getProperties().contains(prop), "Property %s not found on block %s", entry, this.owner); - Preconditions.checkArgument(prop.getPossibleValues().contains(value), "%s is not a valid value for %s", value, prop); - } - this.setStates = Maps.newTreeMap(Comparator.comparing(Property::getName)); - this.setStates.putAll(setStates); - } - - public > PartialBlockstate with(Property prop, T value) { - Preconditions.checkArgument(!setStates.containsKey(prop), "Property %s has already been set", prop); - Map, Comparable> newState = new HashMap<>(setStates); - newState.put(prop, value); - return new PartialBlockstate(owner, newState, outerBuilder); - } - - private void checkValidOwner() { - Preconditions.checkNotNull(outerBuilder, "Partial blockstate must have a valid owner to perform this action"); - } - - /** - * Creates a builder for models to assign to this state, which when completed - * via {@link ConfiguredModel.Builder#addModel()} will assign the resultant set - * of models to this state. - * - * @return the model builder - * @see ConfiguredModel.Builder - */ - public ConfiguredModel.Builder modelForState() { - checkValidOwner(); - return ConfiguredModel.builder(outerBuilder, this); - } - - /** - * Add models to the current state's variant. For use when it is more convenient - * to add multiple sets of models, as a replacement for - * {@link #setModels(ConfiguredModel...)}. - * - * @param models The models to add. - * @return {@code this} - * @throws NullPointerException If the parent builder is {@code null} - */ - public PartialBlockstate addModels(ConfiguredModel... models) { - checkValidOwner(); - outerBuilder.addModels(this, models); - return this; - } - - /** - * Set this variant's models, and return the parent builder. - * - * @param models The models to set - * @return The parent builder instance - * @throws NullPointerException If the parent builder is {@code null} - */ - public VariantBlockStateBuilder setModels(ConfiguredModel... models) { - checkValidOwner(); - return outerBuilder.setModels(this, models); - } - - /** - * Complete this state without adding any new models, and return a new partial - * state via the parent builder. For use after calling - * {@link #addModels(ConfiguredModel...)}. - * - * @return A fresh partial state as specified by - * {@link VariantBlockStateBuilder#partialState()}. - * @throws NullPointerException If the parent builder is {@code null} - */ - public PartialBlockstate partialState() { - checkValidOwner(); - return outerBuilder.partialState(); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - PartialBlockstate that = (PartialBlockstate) o; - return owner.equals(that.owner) && - setStates.equals(that.setStates); - } - - @Override - public int hashCode() { - return Objects.hash(owner, setStates); - } - - public Block getOwner() { - return owner; - } - - public SortedMap, Comparable> getSetStates() { - return setStates; - } - - @Override - public boolean test(BlockState blockState) { - if (blockState.getBlock() != getOwner()) { - return false; - } - for (Map.Entry, Comparable> entry : setStates.entrySet()) { - if (blockState.getValue(entry.getKey()) != entry.getValue()) { - return false; - } - } - return true; - } - - @SuppressWarnings({ "unchecked", "rawtypes" }) - @Override - public String toString() { - StringBuilder ret = new StringBuilder(); - for (Map.Entry, Comparable> entry : setStates.entrySet()) { - if (!ret.isEmpty()) { - ret.append(','); - } - ret.append(entry.getKey().getName()) - .append('=') - .append(((Property) entry.getKey()).getName(entry.getValue())); - } - return ret.toString(); - } - - @SuppressWarnings({ "unchecked", "rawtypes" }) - public static Comparator comparingByProperties() { - // Sort variants inversely by property values, to approximate vanilla style - return (s1, s2) -> { - SortedSet> propUniverse = new TreeSet<>(s1.getSetStates().comparator().reversed()); - propUniverse.addAll(s1.getSetStates().keySet()); - propUniverse.addAll(s2.getSetStates().keySet()); - for (Property prop : propUniverse) { - Comparable val1 = s1.getSetStates().get(prop); - Comparable val2 = s2.getSetStates().get(prop); - if (val1 == null && val2 != null) { - return -1; - } else if (val2 == null && val1 != null) { - return 1; - } else if (val1 != null && val2 != null){ - int cmp = val1.compareTo(val2); - if (cmp != 0) { - return cmp; - } - } - } - return 0; - }; - } - } -} diff --git a/src/main/java/net/minecraftforge/client/model/generators/loaders/CompositeModelBuilder.java b/src/main/java/net/minecraftforge/client/model/generators/loaders/CompositeModelBuilder.java deleted file mode 100644 index c845ab0ce4..0000000000 --- a/src/main/java/net/minecraftforge/client/model/generators/loaders/CompositeModelBuilder.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) Forge Development LLC and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.minecraftforge.client.model.generators.loaders; - -import com.google.common.base.Preconditions; -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; -import net.minecraft.resources.ResourceLocation; -import net.minecraftforge.client.model.generators.CustomLoaderBuilder; -import net.minecraftforge.client.model.generators.ModelBuilder; -import net.minecraftforge.common.data.ExistingFileHelper; - -import java.util.*; - -/** - * In 1.21.4 Mojang exposed their data generators for their models. So it should be feasible to just use theirs. - * If you find something lacking feel free to open a PR so that we can extend it. - * @deprecated Use Vanilla's providers {@link net.minecraft.client.data.models.ModelProvider} - */ -public class CompositeModelBuilder> extends CustomLoaderBuilder -{ - private static final ResourceLocation NAME = ResourceLocation.fromNamespaceAndPath("forge", "composite"); - - public static > CompositeModelBuilder begin(T parent, ExistingFileHelper existingFileHelper) - { - return new CompositeModelBuilder<>(parent, existingFileHelper); - } - - private final Map childModels = new LinkedHashMap<>(); - private final List itemRenderOrder = new ArrayList<>(); - - protected CompositeModelBuilder(T parent, ExistingFileHelper existingFileHelper) - { - super(NAME, parent, existingFileHelper); - } - - public CompositeModelBuilder child(String name, T modelBuilder) - { - Preconditions.checkNotNull(name, "name must not be null"); - Preconditions.checkNotNull(modelBuilder, "modelBuilder must not be null"); - childModels.put(name, modelBuilder); - itemRenderOrder.add(name); - return this; - } - - public CompositeModelBuilder itemRenderOrder(String... names) - { - Preconditions.checkNotNull(names, "names must not be null"); - Preconditions.checkArgument(names.length > 0, "names must contain at least one element"); - for (String name : names) - if (!childModels.containsKey(name)) - throw new IllegalArgumentException("names contains \"" + name + "\", which is not a child of this model"); - itemRenderOrder.clear(); - itemRenderOrder.addAll(Arrays.asList(names)); - return this; - } - - @Override - public JsonObject toJson(JsonObject json) - { - json = super.toJson(json); - - JsonObject children = new JsonObject(); - for(Map.Entry entry : childModels.entrySet()) - { - children.add(entry.getKey(), entry.getValue().toJson()); - } - json.add("children", children); - - JsonArray itemRenderOrder = new JsonArray(); - for (String name : this.itemRenderOrder) { - itemRenderOrder.add(name); - } - json.add("item_render_order", itemRenderOrder); - - return json; - } -} diff --git a/src/main/java/net/minecraftforge/client/model/generators/loaders/DynamicFluidContainerModelBuilder.java b/src/main/java/net/minecraftforge/client/model/generators/loaders/DynamicFluidContainerModelBuilder.java deleted file mode 100644 index 2feb8001f2..0000000000 --- a/src/main/java/net/minecraftforge/client/model/generators/loaders/DynamicFluidContainerModelBuilder.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (c) Forge Development LLC and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.minecraftforge.client.model.generators.loaders; - -import com.google.common.base.Preconditions; -import com.google.gson.JsonObject; -import net.minecraft.world.level.material.Fluid; -import net.minecraft.resources.ResourceLocation; -import net.minecraftforge.client.model.generators.CustomLoaderBuilder; -import net.minecraftforge.client.model.generators.ModelBuilder; -import net.minecraftforge.common.data.ExistingFileHelper; -import net.minecraftforge.registries.ForgeRegistries; - -/** - * In 1.21.4 Mojang exposed their data generators for their models. So it should be feasible to just use theirs. - * If you find something lacking feel free to open a PR so that we can extend it. - * @deprecated Use Vanilla's providers {@link net.minecraft.client.data.models.ModelProvider} - */ -public class DynamicFluidContainerModelBuilder> extends CustomLoaderBuilder -{ - private static final ResourceLocation NAME = ResourceLocation.fromNamespaceAndPath("forge", "fluid_container"); - public static > DynamicFluidContainerModelBuilder begin(T parent, ExistingFileHelper existingFileHelper) - { - return new DynamicFluidContainerModelBuilder<>(parent, existingFileHelper); - } - - private ResourceLocation fluid; - private Boolean flipGas; - private Boolean applyTint; - private Boolean coverIsMask; - private Boolean applyFluidLuminosity; - - protected DynamicFluidContainerModelBuilder(T parent, ExistingFileHelper existingFileHelper) - { - super(NAME, parent, existingFileHelper); - } - - public DynamicFluidContainerModelBuilder fluid(Fluid fluid) - { - Preconditions.checkNotNull(fluid, "fluid must not be null"); - this.fluid = ForgeRegistries.FLUIDS.getKey(fluid); - return this; - } - - public DynamicFluidContainerModelBuilder flipGas(boolean flip) - { - this.flipGas = flip; - return this; - } - - public DynamicFluidContainerModelBuilder applyTint(boolean tint) - { - this.applyTint = tint; - return this; - } - - public DynamicFluidContainerModelBuilder coverIsMask(boolean coverIsMask) - { - this.coverIsMask = coverIsMask; - return this; - } - - public DynamicFluidContainerModelBuilder applyFluidLuminosity(boolean applyFluidLuminosity) - { - this.applyFluidLuminosity = applyFluidLuminosity; - return this; - } - - @Override - public JsonObject toJson(JsonObject json) - { - json = super.toJson(json); - - Preconditions.checkNotNull(fluid, "fluid must not be null"); - - json.addProperty("fluid", fluid.toString()); - - if (flipGas != null) - json.addProperty("flip_gas", flipGas); - - if (applyTint != null) - json.addProperty("apply_tint", applyTint); - - if (coverIsMask != null) - json.addProperty("cover_is_mask", coverIsMask); - - if (applyFluidLuminosity != null) - json.addProperty("apply_fluid_luminosity", applyFluidLuminosity); - - return json; - } -} diff --git a/src/main/java/net/minecraftforge/client/model/generators/loaders/ItemLayerModelBuilder.java b/src/main/java/net/minecraftforge/client/model/generators/loaders/ItemLayerModelBuilder.java deleted file mode 100644 index e97c686c13..0000000000 --- a/src/main/java/net/minecraftforge/client/model/generators/loaders/ItemLayerModelBuilder.java +++ /dev/null @@ -1,226 +0,0 @@ -/* - * Copyright (c) Forge Development LLC and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.minecraftforge.client.model.generators.loaders; - -import java.util.Arrays; -import java.util.LinkedHashMap; -import java.util.Map; - -import com.google.common.base.Preconditions; -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; -import com.mojang.serialization.JsonOps; - -import it.unimi.dsi.fastutil.ints.Int2ObjectMap; -import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; -import it.unimi.dsi.fastutil.ints.IntOpenHashSet; -import it.unimi.dsi.fastutil.ints.IntSet; -import net.minecraft.resources.ResourceLocation; -import net.minecraftforge.client.model.ForgeFaceData; -import net.minecraftforge.client.model.generators.CustomLoaderBuilder; -import net.minecraftforge.client.model.generators.ModelBuilder; -import net.minecraftforge.common.data.ExistingFileHelper; - -/** - * In 1.21.4 Mojang exposed their data generators for their models. So it should be feasible to just use theirs. - * If you find something lacking feel free to open a PR so that we can extend it. - * @deprecated Use Vanilla's providers {@link net.minecraft.client.data.models.ModelProvider} - */ -public class ItemLayerModelBuilder> extends CustomLoaderBuilder -{ - private static final ResourceLocation NAME = ResourceLocation.fromNamespaceAndPath("forge", "item_layers"); - public static > ItemLayerModelBuilder begin(T parent, ExistingFileHelper existingFileHelper) - { - return new ItemLayerModelBuilder<>(parent, existingFileHelper); - } - - private final Int2ObjectMap faceData = new Int2ObjectOpenHashMap<>(); - private final Map renderTypes = new LinkedHashMap<>(); - private final Map renderTypesFast = new LinkedHashMap<>(); - private final IntSet layersWithRenderTypes = new IntOpenHashSet(); - - protected ItemLayerModelBuilder(T parent, ExistingFileHelper existingFileHelper) - { - super(NAME, parent, existingFileHelper); - } - - /** - * Marks a set of layers to be rendered emissively. - * - * @param blockLight The block light (0-15) - * @param skyLight The sky light (0-15) - * @param layers the layers that will render unlit - * @return this builder - * @throws NullPointerException if {@code layers} is {@code null} - * @throws IllegalArgumentException if {@code layers} is empty - * @throws IllegalArgumentException if any entry in {@code layers} is smaller than 0 - */ - public ItemLayerModelBuilder emissive(int blockLight, int skyLight, int... layers) - { - Preconditions.checkNotNull(layers, "Layers must not be null"); - Preconditions.checkArgument(layers.length > 0, "At least one layer must be specified"); - Preconditions.checkArgument(Arrays.stream(layers).allMatch(i -> i >= 0), "All layers must be >= 0"); - for(int i : layers) - { - faceData.compute(i, (key, value) -> { - ForgeFaceData fallback = value == null ? ForgeFaceData.DEFAULT : value; - return new ForgeFaceData(fallback.color(), blockLight, skyLight, fallback.ambientOcclusion(), fallback.calculateNormals()); - }); - } - return this; - } - - /** - * Marks a set of layers to be rendered with a specific color. - * - * @param color The color, in ARGB. - * @param layers the layers that will render with color - * @return this builder - * @throws NullPointerException if {@code layers} is {@code null} - * @throws IllegalArgumentException if {@code layers} is empty - * @throws IllegalArgumentException if any entry in {@code layers} is smaller than 0 - */ - public ItemLayerModelBuilder color(int color, int... layers) - { - Preconditions.checkNotNull(layers, "Layers must not be null"); - Preconditions.checkArgument(layers.length > 0, "At least one layer must be specified"); - Preconditions.checkArgument(Arrays.stream(layers).allMatch(i -> i >= 0), "All layers must be >= 0"); - for(int i : layers) - { - faceData.compute(i, (key, value) -> { - ForgeFaceData fallback = value == null ? ForgeFaceData.DEFAULT : value; - return new ForgeFaceData(color, fallback.blockLight(), fallback.skyLight(), fallback.ambientOcclusion(), fallback.calculateNormals()); - }); - } - return this; - } - - /** - * Set the render type for a set of layers. - * - * @param renderType the render type. Must be registered via - * {@link net.minecraftforge.client.event.RegisterNamedRenderTypesEvent} - * @param layers the layers that will use this render type - * @return this builder - * @throws NullPointerException if {@code renderType} is {@code null} - * @throws NullPointerException if {@code layers} is {@code null} - * @throws IllegalArgumentException if {@code layers} is empty - * @throws IllegalArgumentException if any entry in {@code layers} is smaller than 0 - * @throws IllegalArgumentException if any entry in {@code layers} already has a render type - */ - public ItemLayerModelBuilder renderType(String renderType, int... layers) - { - Preconditions.checkNotNull(renderType, "Render type must not be null"); - ResourceLocation asLoc; - if (renderType.contains(":")) - asLoc = ResourceLocation.parse(renderType); - else - asLoc = parent.getLocation().withPath(renderType); - return renderType(asLoc, layers); - } - - public ItemLayerModelBuilder renderType(String renderType, String renderTypeFast, int... layers) - { - Preconditions.checkNotNull(renderType, "Render type must not be null"); - Preconditions.checkNotNull(renderTypeFast, "Fast graphics render type must not be null"); - ResourceLocation asLoc; - if (renderType.contains(":")) - asLoc = ResourceLocation.parse(renderType); - else - asLoc = parent.getLocation().withPath(renderType); - ResourceLocation asLocFast; - if (renderTypeFast.contains(":")) - asLocFast = ResourceLocation.parse(renderTypeFast); - else - asLocFast = parent.getLocation().withPath(renderTypeFast); - return renderType(asLoc, asLocFast, layers); - } - - /** - * Set the render type for a set of layers. - * - * @param renderType the render type. Must be registered via - * {@link net.minecraftforge.client.event.RegisterNamedRenderTypesEvent} - * @param layers the layers that will use this render type - * @return this builder - * @throws NullPointerException if {@code renderType} is {@code null} - * @throws NullPointerException if {@code layers} is {@code null} - * @throws IllegalArgumentException if {@code layers} is empty - * @throws IllegalArgumentException if any entry in {@code layers} is smaller than 0 - * @throws IllegalArgumentException if any entry in {@code layers} already has a render type - */ - public ItemLayerModelBuilder renderType(ResourceLocation renderType, int... layers) - { - Preconditions.checkNotNull(renderType, "Render type must not be null"); - Preconditions.checkNotNull(layers, "Layers must not be null"); - Preconditions.checkArgument(layers.length > 0, "At least one layer must be specified"); - Preconditions.checkArgument(Arrays.stream(layers).allMatch(i -> i >= 0), "All layers must be >= 0"); - var alreadyAssigned = Arrays.stream(layers).filter(layersWithRenderTypes::contains).toArray(); - Preconditions.checkArgument(alreadyAssigned.length == 0, "Attempted to re-assign layer render types: " + Arrays.toString(alreadyAssigned)); - var renderTypeLayers = renderTypes.computeIfAbsent(renderType, $ -> new IntOpenHashSet()); - Arrays.stream(layers).forEach(layer -> { - renderTypeLayers.add(layer); - layersWithRenderTypes.add(layer); - }); - return this; - } - - public ItemLayerModelBuilder renderType(ResourceLocation renderType, ResourceLocation renderTypeFast, int... layers) - { - Preconditions.checkNotNull(renderType, "Render type must not be null"); - Preconditions.checkNotNull(renderTypeFast, "Fast graphics render type must not be null"); - Preconditions.checkNotNull(layers, "Layers must not be null"); - Preconditions.checkArgument(layers.length > 0, "At least one layer must be specified"); - Preconditions.checkArgument(Arrays.stream(layers).allMatch(i -> i >= 0), "All layers must be >= 0"); - var alreadyAssigned = Arrays.stream(layers).filter(layersWithRenderTypes::contains).toArray(); - Preconditions.checkArgument(alreadyAssigned.length == 0, "Attempted to re-assign layer render types: " + Arrays.toString(alreadyAssigned)); - var renderTypeLayers = renderTypes.computeIfAbsent(renderType, $ -> new IntOpenHashSet()); - var renderTypeFastLayers = renderTypesFast.computeIfAbsent(renderType, $ -> new IntOpenHashSet()); - Arrays.stream(layers).forEach(layer -> { - renderTypeLayers.add(layer); - renderTypeFastLayers.add(layer); - layersWithRenderTypes.add(layer); - }); - return this; - } - - @Override - public JsonObject toJson(JsonObject json) - { - json = super.toJson(json); - - JsonObject forgeData = new JsonObject(); - JsonObject layerObj = new JsonObject(); - - for(Int2ObjectMap.Entry entry : this.faceData.int2ObjectEntrySet()) - { - layerObj.add(String.valueOf(entry.getIntKey()), ForgeFaceData.CODEC.encodeStart(JsonOps.INSTANCE, entry.getValue()).getOrThrow(s -> { - return new RuntimeException(); // Perhaps not the best way to deal with this? - MangoRage - })); - } - - forgeData.add("layers", layerObj); - json.add("forge_data", forgeData); - - JsonObject renderTypes = new JsonObject(); - this.renderTypes.forEach((renderType, layers) -> { - JsonArray array = new JsonArray(); - layers.intStream().sorted().forEach(array::add); - renderTypes.add(renderType.toString(), array); - }); - json.add("render_types", renderTypes); - - JsonObject renderTypesFast = new JsonObject(); - this.renderTypesFast.forEach((renderTypeFast, layers) -> { - JsonArray array = new JsonArray(); - layers.intStream().sorted().forEach(array::add); - renderTypesFast.add(renderTypeFast.toString(), array); - }); - json.add("render_types_fast", renderTypesFast); - - return json; - } -} diff --git a/src/main/java/net/minecraftforge/client/model/generators/loaders/ObjModelBuilder.java b/src/main/java/net/minecraftforge/client/model/generators/loaders/ObjModelBuilder.java deleted file mode 100644 index fdb217512e..0000000000 --- a/src/main/java/net/minecraftforge/client/model/generators/loaders/ObjModelBuilder.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (c) Forge Development LLC and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.minecraftforge.client.model.generators.loaders; - -import com.google.common.base.Preconditions; -import com.google.gson.JsonObject; -import net.minecraft.server.packs.PackType; -import net.minecraft.resources.ResourceLocation; -import net.minecraftforge.client.model.generators.CustomLoaderBuilder; -import net.minecraftforge.client.model.generators.ModelBuilder; -import net.minecraftforge.common.data.ExistingFileHelper; - -/** - * In 1.21.4 Mojang exposed their data generators for their models. So it should be feasible to just use theirs. - * If you find something lacking feel free to open a PR so that we can extend it. - * @deprecated Use Vanilla's providers {@link net.minecraft.client.data.models.ModelProvider} - */ -public class ObjModelBuilder> extends CustomLoaderBuilder -{ - private static final ResourceLocation NAME = ResourceLocation.fromNamespaceAndPath("forge", "obj"); - public static > ObjModelBuilder begin(T parent, ExistingFileHelper existingFileHelper) - { - return new ObjModelBuilder<>(parent, existingFileHelper); - } - - private ResourceLocation modelLocation; - private Boolean automaticCulling; - private Boolean shadeQuads; - private Boolean flipV; - private Boolean emissiveAmbient; - private ResourceLocation mtlOverride; - - protected ObjModelBuilder(T parent, ExistingFileHelper existingFileHelper) - { - super(NAME, parent, existingFileHelper); - } - - public ObjModelBuilder modelLocation(ResourceLocation modelLocation) - { - Preconditions.checkNotNull(modelLocation, "modelLocation must not be null"); - Preconditions.checkArgument(existingFileHelper.exists(modelLocation, PackType.CLIENT_RESOURCES), - "OBJ Model %s does not exist in any known resource pack", modelLocation); - this.modelLocation = modelLocation; - return this; - } - - public ObjModelBuilder automaticCulling(boolean automaticCulling) - { - this.automaticCulling = automaticCulling; - return this; - } - - public ObjModelBuilder shadeQuads(boolean shadeQuads) - { - this.shadeQuads = shadeQuads; - return this; - } - - public ObjModelBuilder flipV(boolean flipV) - { - this.flipV = flipV; - return this; - } - - public ObjModelBuilder emissiveAmbient(boolean ambientEmissive) - { - this.emissiveAmbient = ambientEmissive; - return this; - } - - public ObjModelBuilder overrideMaterialLibrary(ResourceLocation mtlOverride) - { - Preconditions.checkNotNull(mtlOverride, "mtlOverride must not be null"); - Preconditions.checkArgument(existingFileHelper.exists(mtlOverride, PackType.CLIENT_RESOURCES), - "OBJ Model %s does not exist in any known resource pack", mtlOverride); - this.mtlOverride = mtlOverride; - return this; - } - - @Override - public JsonObject toJson(JsonObject json) - { - json = super.toJson(json); - - Preconditions.checkNotNull(modelLocation, "modelLocation must not be null"); - - json.addProperty("model", modelLocation.toString()); - - if (automaticCulling != null) - json.addProperty("automatic_culling", automaticCulling); - - if (shadeQuads != null) - json.addProperty("shade_quads", shadeQuads); - - if (flipV != null) - json.addProperty("flip_v", flipV); - - if (emissiveAmbient != null) - json.addProperty("emissive_ambient", emissiveAmbient); - - if (mtlOverride != null) - json.addProperty("mtl_override", mtlOverride.toString()); - - return json; - } -} diff --git a/src/main/java/net/minecraftforge/client/model/generators/loaders/SeparateTransformsModelBuilder.java b/src/main/java/net/minecraftforge/client/model/generators/loaders/SeparateTransformsModelBuilder.java deleted file mode 100644 index 55384a02d4..0000000000 --- a/src/main/java/net/minecraftforge/client/model/generators/loaders/SeparateTransformsModelBuilder.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) Forge Development LLC and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.minecraftforge.client.model.generators.loaders; - -import com.google.common.base.Preconditions; -import com.google.gson.JsonObject; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.item.ItemDisplayContext; -import net.minecraftforge.client.model.generators.CustomLoaderBuilder; -import net.minecraftforge.client.model.generators.ModelBuilder; -import net.minecraftforge.common.data.ExistingFileHelper; - -import java.util.LinkedHashMap; -import java.util.Map; - -/** - * In 1.21.4 Mojang exposed their data generators for their models. So it should be feasible to just use theirs. - * If you find something lacking feel free to open a PR so that we can extend it. - * @deprecated Use Vanilla's providers {@link net.minecraft.client.data.models.ModelProvider} - */ -public class SeparateTransformsModelBuilder> extends CustomLoaderBuilder -{ - private static final ResourceLocation NAME = ResourceLocation.fromNamespaceAndPath("forge", "separate_transforms"); - - public static > SeparateTransformsModelBuilder begin(T parent, ExistingFileHelper existingFileHelper) - { - return new SeparateTransformsModelBuilder<>(parent, existingFileHelper); - } - - private T base; - private final Map childModels = new LinkedHashMap<>(); - - protected SeparateTransformsModelBuilder(T parent, ExistingFileHelper existingFileHelper) - { - super(NAME, parent, existingFileHelper); - } - - public SeparateTransformsModelBuilder base(T modelBuilder) - { - Preconditions.checkNotNull(modelBuilder, "modelBuilder must not be null"); - base = modelBuilder; - return this; - } - - public SeparateTransformsModelBuilder perspective(ItemDisplayContext perspective, T modelBuilder) - { - Preconditions.checkNotNull(perspective, "layer must not be null"); - Preconditions.checkNotNull(modelBuilder, "modelBuilder must not be null"); - childModels.put(perspective.getSerializedName(), modelBuilder); - return this; - } - - @Override - public JsonObject toJson(JsonObject json) - { - json = super.toJson(json); - - if (base != null) - { - json.add("base", base.toJson()); - } - - JsonObject parts = new JsonObject(); - for(Map.Entry entry : childModels.entrySet()) - { - parts.add(entry.getKey(), entry.getValue().toJson()); - } - json.add("perspectives", parts); - - return json; - } -} 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 12c3192735..d462977f8a 100644 --- a/src/main/java/net/minecraftforge/client/model/geometry/GeometryLoaderManager.java +++ b/src/main/java/net/minecraftforge/client/model/geometry/GeometryLoaderManager.java @@ -5,7 +5,7 @@ package net.minecraftforge.client.model.geometry; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraftforge.client.event.ModelEvent; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nullable; @@ -20,14 +20,14 @@ import java.util.stream.Collectors; * Provides a lookup. */ public final class GeometryLoaderManager { - private static Map LOADERS; + private static Map LOADERS; private static String LOADER_LIST; /** * Finds the {@link IGeometryLoader} for a given name, or null if not found. */ @Nullable - public static IGeometryLoader get(ResourceLocation name) { + public static IGeometryLoader get(Identifier name) { return LOADERS.get(name); } @@ -40,10 +40,10 @@ public final class GeometryLoaderManager { @ApiStatus.Internal public static void init() { - var loaders = new HashMap(); + var loaders = new HashMap(); ModelEvent.RegisterGeometryLoaders.BUS.post(new ModelEvent.RegisterGeometryLoaders(loaders)); LOADERS = Map.copyOf(loaders); - LOADER_LIST = loaders.keySet().stream().map(ResourceLocation::toString).collect(Collectors.joining(", ")); + LOADER_LIST = loaders.keySet().stream().map(Identifier::toString).collect(Collectors.joining(", ")); } private GeometryLoaderManager() {} diff --git a/src/main/java/net/minecraftforge/client/model/geometry/IGeometryBakingContext.java b/src/main/java/net/minecraftforge/client/model/geometry/IGeometryBakingContext.java index bb9524a212..942e9b530d 100644 --- a/src/main/java/net/minecraftforge/client/model/geometry/IGeometryBakingContext.java +++ b/src/main/java/net/minecraftforge/client/model/geometry/IGeometryBakingContext.java @@ -8,7 +8,7 @@ package net.minecraftforge.client.model.geometry; import com.mojang.math.Transformation; import net.minecraft.client.renderer.block.model.ItemTransforms; import net.minecraft.client.resources.model.Material; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraftforge.client.NamedRenderTypeManager; import net.minecraftforge.client.RenderTypeGroup; import org.jetbrains.annotations.Nullable; @@ -50,14 +50,14 @@ public interface IGeometryBakingContext { * {@return a hint of the render type this model should use. Custom loaders may ignore this.} */ @Nullable - ResourceLocation getRenderTypeHint(); + Identifier getRenderTypeHint(); /** * @return a hint of the {@linkplain net.minecraft.client.GraphicsStatus#FAST fast graphics} render type this model * should use. Custom loaders may ignore this. */ @Nullable - default ResourceLocation getRenderTypeFastHint() { return null; } + default Identifier getRenderTypeFastHint() { return null; } /** * Queries the visibility of a component of this model. @@ -71,7 +71,7 @@ public interface IGeometryBakingContext { /** * {@return a {@link RenderTypeGroup} with the given name, or the empty group if not found.} */ - default RenderTypeGroup getRenderType(ResourceLocation name) { + default RenderTypeGroup getRenderType(Identifier name) { return NamedRenderTypeManager.get(name); } diff --git a/src/main/java/net/minecraftforge/client/model/geometry/ModelContext.java b/src/main/java/net/minecraftforge/client/model/geometry/ModelContext.java index 8e9c108b27..e11b5c8040 100644 --- a/src/main/java/net/minecraftforge/client/model/geometry/ModelContext.java +++ b/src/main/java/net/minecraftforge/client/model/geometry/ModelContext.java @@ -14,7 +14,7 @@ import net.minecraft.client.renderer.block.model.BlockModel; import net.minecraft.client.renderer.block.model.ItemTransforms; import net.minecraft.client.resources.model.ModelDiscovery.ModelWrapper; import net.minecraft.client.resources.model.ResolvedModel; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraftforge.client.model.ForgeBlockModelData; @ApiStatus.Internal @@ -76,7 +76,7 @@ public record ModelContext( } @Override - public @Nullable ResourceLocation getRenderTypeHint() { + public @Nullable Identifier getRenderTypeHint() { return data == null ? null : data.renderType().orElse(null); } diff --git a/src/main/java/net/minecraftforge/client/model/geometry/StandaloneGeometryBakingContext.java b/src/main/java/net/minecraftforge/client/model/geometry/StandaloneGeometryBakingContext.java index 260d2b5868..d72cbb8acf 100644 --- a/src/main/java/net/minecraftforge/client/model/geometry/StandaloneGeometryBakingContext.java +++ b/src/main/java/net/minecraftforge/client/model/geometry/StandaloneGeometryBakingContext.java @@ -8,7 +8,7 @@ package net.minecraftforge.client.model.geometry; import com.mojang.math.Transformation; import it.unimi.dsi.fastutil.objects.Object2BooleanMap; import net.minecraft.client.renderer.block.model.ItemTransforms; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import org.jetbrains.annotations.Nullable; import java.util.function.BiPredicate; @@ -17,7 +17,7 @@ import java.util.function.BiPredicate; * A {@linkplain IGeometryBakingContext geometry baking context} that is not bound to block/item model loading. */ public class StandaloneGeometryBakingContext implements IGeometryBakingContext { - public static final ResourceLocation LOCATION = ResourceLocation.fromNamespaceAndPath("forge", "standalone"); + public static final Identifier LOCATION = Identifier.fromNamespaceAndPath("forge", "standalone"); public static final StandaloneGeometryBakingContext INSTANCE = builder().build(); @@ -27,16 +27,16 @@ public class StandaloneGeometryBakingContext implements IGeometryBakingContext { private final ItemTransforms transforms; private final Transformation rootTransform; @Nullable - private final ResourceLocation renderTypeHint; + private final Identifier renderTypeHint; @Nullable - private final ResourceLocation renderTypeFastHint; + private final Identifier renderTypeFastHint; private final BiPredicate visibilityTest; private StandaloneGeometryBakingContext( boolean isGui3d, boolean useBlockLight, boolean useAmbientOcclusion, ItemTransforms transforms, Transformation rootTransform, - @Nullable ResourceLocation renderTypeHint, + @Nullable Identifier renderTypeHint, BiPredicate visibilityTest ) { this(isGui3d, useBlockLight, useAmbientOcclusion, transforms, rootTransform, renderTypeHint, null, visibilityTest); @@ -46,8 +46,8 @@ public class StandaloneGeometryBakingContext implements IGeometryBakingContext { boolean isGui3d, boolean useBlockLight, boolean useAmbientOcclusion, ItemTransforms transforms, Transformation rootTransform, - @Nullable ResourceLocation renderTypeHint, - @Nullable ResourceLocation renderTypeFastHint, + @Nullable Identifier renderTypeHint, + @Nullable Identifier renderTypeFastHint, BiPredicate visibilityTest ) { this.isGui3d = isGui3d; @@ -87,13 +87,13 @@ public class StandaloneGeometryBakingContext implements IGeometryBakingContext { @Nullable @Override - public ResourceLocation getRenderTypeHint() { + public Identifier getRenderTypeHint() { return renderTypeHint; } @Nullable @Override - public ResourceLocation getRenderTypeFastHint() { + public Identifier getRenderTypeFastHint() { return renderTypeFastHint; } @@ -117,9 +117,9 @@ public class StandaloneGeometryBakingContext implements IGeometryBakingContext { private ItemTransforms transforms = ItemTransforms.NO_TRANSFORMS; private Transformation rootTransform = Transformation.identity(); @Nullable - private ResourceLocation renderTypeHint; + private Identifier renderTypeHint; @Nullable - private ResourceLocation renderTypeFastHint; + private Identifier renderTypeFastHint; private BiPredicate visibilityTest = (c, def) -> def; private Builder() { } @@ -160,12 +160,12 @@ public class StandaloneGeometryBakingContext implements IGeometryBakingContext { return this; } - public Builder withRenderTypeHint(ResourceLocation renderTypeHint) { + public Builder withRenderTypeHint(Identifier renderTypeHint) { this.renderTypeHint = renderTypeHint; return this; } - public Builder withRenderTypeHint(ResourceLocation renderTypeHint, ResourceLocation renderTypeFastHint) { + public Builder withRenderTypeHint(Identifier renderTypeHint, Identifier renderTypeFastHint) { this.renderTypeHint = renderTypeHint; this.renderTypeFastHint = renderTypeFastHint; return this; diff --git a/src/main/java/net/minecraftforge/client/model/geometry/UnbakedGeometryHelper.java b/src/main/java/net/minecraftforge/client/model/geometry/UnbakedGeometryHelper.java index 7324076e2f..e8c3327210 100644 --- a/src/main/java/net/minecraftforge/client/model/geometry/UnbakedGeometryHelper.java +++ b/src/main/java/net/minecraftforge/client/model/geometry/UnbakedGeometryHelper.java @@ -7,7 +7,7 @@ package net.minecraftforge.client.model.geometry; import com.mojang.math.Quadrant; import com.mojang.math.Transformation; -import net.minecraft.Util; +import net.minecraft.util.Util; import net.minecraft.client.renderer.block.model.BakedQuad; import net.minecraft.client.renderer.block.model.BlockElement; import net.minecraft.client.renderer.block.model.BlockElementFace; @@ -19,12 +19,11 @@ import net.minecraft.client.renderer.texture.SpriteContents; import net.minecraft.client.renderer.texture.TextureAtlas; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.resources.model.Material; +import net.minecraft.client.resources.model.ModelBaker; import net.minecraft.client.resources.model.ModelState; import net.minecraft.client.resources.model.QuadCollection; import net.minecraft.core.Direction; -import net.minecraft.resources.ResourceLocation; -import net.minecraftforge.client.model.IQuadTransformer; -import net.minecraftforge.client.model.QuadTransformers; +import net.minecraft.resources.Identifier; import net.minecraftforge.client.model.SimpleModelState; import org.jetbrains.annotations.ApiStatus; @@ -44,7 +43,7 @@ import java.util.regex.Pattern; public class UnbakedGeometryHelper { /** * Explanation: - * This takes anything that looks like a valid resourcepack texture location, and tries to extract a resourcelocation out of it. + * This takes anything that looks like a valid resourcepack texture location, and tries to extract a Identifier out of it. * 1. it will ignore anything up to and including an /assets/ folder, * 2. it will take the next path component as a namespace, * 3. it will match but skip the /textures/ part of the path, @@ -62,7 +61,7 @@ public class UnbakedGeometryHelper { private static final Material MISSING_MATERIAL = getMaterial(MissingTextureAtlasSprite.getLocation().toString()); /** - * Resolves a material that may have been defined with a filesystem path instead of a proper {@link ResourceLocation}. + * Resolves a material that may have been defined with a filesystem path instead of a proper {@link Identifier}. *

    * The target atlas will always be {@link TextureAtlas#LOCATION_BLOCKS}. */ @@ -73,7 +72,7 @@ public class UnbakedGeometryHelper { if (tex.startsWith("#")) return textures.getMaterial(tex); - // Attempt to convert a common (windows/linux/mac) filesystem path to a ResourceLocation. + // Attempt to convert a common (windows/linux/mac) filesystem path to a Identifier. // This makes no promises, if it doesn't work, too bad, fix your mtl file. Matcher match = FILESYSTEM_PATH_TO_RESLOC.matcher(tex); if (match.matches()) { @@ -159,34 +158,20 @@ public class UnbakedGeometryHelper { /** * Bakes a list of {@linkplain BlockElement block elements} and returns a {@link QuadCollection}. */ - public static QuadCollection bakeElements(List elements, Function spriteGetter, ModelState modelState) { - return bakeElements(elements, spriteGetter, modelState, QuadTransformers.empty()); - } - - /** - * Bakes a list of {@linkplain BlockElement block elements} and returns a {@link QuadCollection}. - */ - public static QuadCollection bakeElements(List elements, Function spriteGetter, ModelState modelState, IQuadTransformer transformer) { + public static QuadCollection bakeElements(ModelBaker.PartCache cache, List elements, Function spriteGetter, ModelState modelState) { var builder = new QuadCollection.Builder(); - bakeElements(elements, spriteGetter, modelState, builder); + bakeElements(cache, elements, spriteGetter, modelState, builder); return builder.build(); } /** * Adds a list of {@linkplain BlockElement block elements} int a {@link QuadCollection.Builder}. */ - public static void bakeElements(List elements, Function spriteGetter, ModelState modelState, QuadCollection.Builder builder) { - bakeElements(elements, spriteGetter, modelState, QuadTransformers.empty(), builder); - } - - /** - * Adds a list of {@linkplain BlockElement block elements} int a {@link QuadCollection.Builder}. - */ - public static void bakeElements(List elements, Function spriteGetter, ModelState modelState, IQuadTransformer transformer, QuadCollection.Builder builder) { + public static void bakeElements(ModelBaker.PartCache cache, List elements, Function spriteGetter, ModelState modelState, QuadCollection.Builder builder) { for (var element : elements) { element.faces().forEach((side, face) -> { var sprite = spriteGetter.apply(getMaterial(face.texture())); - var quad = bakeElementFace(element, face, sprite, side, modelState, element.lightEmission()); + var quad = bakeElementFace(cache, element, face, sprite, side, modelState, element.lightEmission()); if (face.cullForDirection() == null) builder.addUnculledFace(quad); else @@ -197,14 +182,14 @@ public class UnbakedGeometryHelper { @SuppressWarnings("deprecation") private static Material getMaterial(String texture) { - return new Material(TextureAtlas.LOCATION_BLOCKS, ResourceLocation.parse(texture)); + return new Material(TextureAtlas.LOCATION_BLOCKS, Identifier.parse(texture)); } /** * Turns a single {@link BlockElementFace} into a {@link BakedQuad}. */ - public static BakedQuad bakeElementFace(BlockElement element, BlockElementFace face, TextureAtlasSprite sprite, Direction direction, ModelState state, int lightEmission) { - return FaceBakery.bakeQuad(element.from(), element.to(), face, sprite, direction, state, element.rotation(), element.shade(), lightEmission); + public static BakedQuad bakeElementFace(ModelBaker.PartCache cache, BlockElement element, BlockElementFace face, TextureAtlasSprite sprite, Direction direction, ModelState state, int lightEmission) { + return FaceBakery.bakeQuad(cache, element.from(), element.to(), face, sprite, direction, state, element.rotation(), element.shade(), lightEmission); } /** @@ -215,6 +200,7 @@ public class UnbakedGeometryHelper { * @return an {@code IQuadTransformer} that applies the root transform to a baked quad that already has the * transformation of the given {@code ModelState} applied to it */ + /* public static IQuadTransformer applyRootTransform(ModelState modelState, Transformation rootTransform) { // Move the origin of the ModelState transform and its inverse from the negative corner to the block center // to replicate the way the ModelState transform is applied in the FaceBakery by moving the vertices such that @@ -222,6 +208,7 @@ public class UnbakedGeometryHelper { Transformation transform = modelState.transformation().applyOrigin(new Vector3f(.5F, .5F, .5F)); return QuadTransformers.applying(transform.compose(rootTransform).compose(transform.inverse())); } + */ /** * {@return a {@link ModelState} that combines the existing model state and the {@linkplain Transformation root transform}} diff --git a/src/main/java/net/minecraftforge/client/model/obj/ObjLoader.java b/src/main/java/net/minecraftforge/client/model/obj/ObjLoader.java index 0f804f2142..cda8c627a7 100644 --- a/src/main/java/net/minecraftforge/client/model/obj/ObjLoader.java +++ b/src/main/java/net/minecraftforge/client/model/obj/ObjLoader.java @@ -15,7 +15,7 @@ import net.minecraft.client.resources.model.ModelDebugName; import net.minecraft.client.resources.model.ModelState; import net.minecraft.client.resources.model.QuadCollection; import net.minecraft.client.resources.model.UnbakedGeometry; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.packs.resources.Resource; import net.minecraft.server.packs.resources.ResourceManager; import net.minecraft.server.packs.resources.ResourceManagerReloadListener; @@ -36,7 +36,7 @@ public class ObjLoader implements IGeometryLoader, ResourceManagerReloadListener public static ObjLoader INSTANCE = new ObjLoader(); private final Map modelCache = Maps.newConcurrentMap(); - private final Map materialCache = Maps.newConcurrentMap(); + private final Map materialCache = Maps.newConcurrentMap(); private ResourceManager manager = Minecraft.getInstance().getResourceManager(); @@ -49,7 +49,7 @@ public class ObjLoader implements IGeometryLoader, ResourceManagerReloadListener @Override public UnbakedGeometry read(JsonObject json, JsonDeserializationContext deserializationContext) { - var location = ResourceLocation.parse(GsonHelper.getAsString(json, "model")); + var location = Identifier.parse(GsonHelper.getAsString(json, "model")); boolean automaticCulling = GsonHelper.getAsBoolean(json, "automatic_culling", true); boolean shadeQuads = GsonHelper.getAsBoolean(json, "shade_quads", true); @@ -74,7 +74,7 @@ public class ObjLoader implements IGeometryLoader, ResourceManagerReloadListener }); } - public ObjMaterialLibrary loadMaterialLibrary(ResourceLocation materialLocation) { + public ObjMaterialLibrary loadMaterialLibrary(Identifier materialLocation) { return materialCache.computeIfAbsent(materialLocation, (location) -> { Resource resource = manager.getResource(location).orElseThrow(); try (ObjTokenizer rdr = new ObjTokenizer(resource.open())) { diff --git a/src/main/java/net/minecraftforge/client/model/obj/ObjModel.java b/src/main/java/net/minecraftforge/client/model/obj/ObjModel.java index 58e9350961..3ca61f1d06 100644 --- a/src/main/java/net/minecraftforge/client/model/obj/ObjModel.java +++ b/src/main/java/net/minecraftforge/client/model/obj/ObjModel.java @@ -19,13 +19,12 @@ import net.minecraft.client.resources.model.ModelDebugName; import net.minecraft.client.resources.model.ModelState; import net.minecraft.client.resources.model.QuadCollection; import net.minecraft.core.Direction; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.util.Mth; import net.minecraft.world.phys.Vec2; -import net.minecraftforge.client.model.IModelBuilder; import net.minecraftforge.client.model.geometry.IGeometryBakingContext; import net.minecraftforge.client.model.geometry.UnbakedGeometryHelper; -import net.minecraftforge.client.model.pipeline.QuadBakingVertexConsumer; +import net.minecraftforge.client.model.pipeline.BakedQuadBuilder; import net.minecraftforge.client.model.renderable.CompositeRenderable; import net.minecraftforge.client.textures.UnitTextureAtlasSprite; import org.apache.commons.lang3.tuple.Pair; @@ -50,7 +49,7 @@ import java.util.stream.Collectors; * A model loaded from an OBJ file. *

    * Supports positions, texture coordinates, normals and colors. The {@link ObjMaterialLibrary material library} - * has support for numerous features, including support for {@link ResourceLocation} textures (non-standard). + * has support for numerous features, including support for {@link Identifier} textures (non-standard). */ public class ObjModel { private static final Vector4f COLOR_WHITE = new Vector4f(1, 1, 1, 1); @@ -78,7 +77,7 @@ public class ObjModel { @Nullable public final String mtlOverride; - public final ResourceLocation modelLocation; + public final Identifier modelLocation; private ObjModel(ModelSettings settings) { this.modelLocation = settings.modelLocation; @@ -119,9 +118,9 @@ public class ObjModel { if (materialLibraryOverrideLocation != null) { String lib = materialLibraryOverrideLocation; if (lib.contains(":")) - mtllib = ObjLoader.INSTANCE.loadMaterialLibrary(ResourceLocation.parse(lib)); + mtllib = ObjLoader.INSTANCE.loadMaterialLibrary(Identifier.parse(lib)); else - mtllib = ObjLoader.INSTANCE.loadMaterialLibrary(ResourceLocation.fromNamespaceAndPath(modelDomain, modelPath + lib)); + mtllib = ObjLoader.INSTANCE.loadMaterialLibrary(Identifier.fromNamespaceAndPath(modelDomain, modelPath + lib)); } String[] line; @@ -133,9 +132,9 @@ public class ObjModel { String lib = line[1]; if (lib.contains(":")) - mtllib = ObjLoader.INSTANCE.loadMaterialLibrary(ResourceLocation.parse(lib)); + mtllib = ObjLoader.INSTANCE.loadMaterialLibrary(Identifier.parse(lib)); else - mtllib = ObjLoader.INSTANCE.loadMaterialLibrary(ResourceLocation.fromNamespaceAndPath(modelDomain, modelPath + lib)); + mtllib = ObjLoader.INSTANCE.loadMaterialLibrary(Identifier.fromNamespaceAndPath(modelDomain, modelPath + lib)); break; } case "usemtl": { // Sets the current material (starts new mesh) @@ -307,7 +306,7 @@ public class ObjModel { faceNormal = abs; } - var quadBaker = new QuadBakingVertexConsumer.Buffered(); + var quadBaker = new BakedQuadBuilder.Single(); quadBaker.setSprite(texture); quadBaker.setTintIndex(tintIndex); @@ -555,14 +554,14 @@ public class ObjModel { quads.add(pair.getLeft()); } - ResourceLocation textureLocation = UnbakedGeometryHelper.resolveDirtyMaterial(mat.diffuseColorMap, textures).texture(); - ResourceLocation texturePath = textureLocation.withPath(p -> "textures/" + p + ".png"); + Identifier textureLocation = UnbakedGeometryHelper.resolveDirtyMaterial(mat.diffuseColorMap, textures).texture(); + Identifier texturePath = textureLocation.withPath(p -> "textures/" + p + ".png"); builder.addMesh(texturePath, quads); } } - public record ModelSettings(@NotNull ResourceLocation modelLocation, + public record ModelSettings(@NotNull Identifier modelLocation, boolean automaticCulling, boolean shadeQuads, boolean flipV, boolean emissiveAmbient, @Nullable String mtlOverride) { } diff --git a/src/main/java/net/minecraftforge/client/model/obj/package-info.java b/src/main/java/net/minecraftforge/client/model/obj/package-info.java index 4659e97343..62c55ee01a 100644 --- a/src/main/java/net/minecraftforge/client/model/obj/package-info.java +++ b/src/main/java/net/minecraftforge/client/model/obj/package-info.java @@ -3,10 +3,7 @@ * SPDX-License-Identifier: LGPL-2.1-only */ -@ParametersAreNonnullByDefault -@MethodsReturnNonnullByDefault +@NullMarked package net.minecraftforge.client.model.obj; -import net.minecraft.MethodsReturnNonnullByDefault; - -import javax.annotation.ParametersAreNonnullByDefault; +import org.jspecify.annotations.NullMarked; diff --git a/src/main/java/net/minecraftforge/client/model/package-info.java b/src/main/java/net/minecraftforge/client/model/package-info.java index d89119f462..524c272649 100644 --- a/src/main/java/net/minecraftforge/client/model/package-info.java +++ b/src/main/java/net/minecraftforge/client/model/package-info.java @@ -3,10 +3,7 @@ * SPDX-License-Identifier: LGPL-2.1-only */ -@ParametersAreNonnullByDefault -@MethodsReturnNonnullByDefault +@NullMarked package net.minecraftforge.client.model; -import net.minecraft.MethodsReturnNonnullByDefault; - -import javax.annotation.ParametersAreNonnullByDefault; +import org.jspecify.annotations.NullMarked; diff --git a/src/main/java/net/minecraftforge/client/model/pipeline/QuadBakingVertexConsumer.java b/src/main/java/net/minecraftforge/client/model/pipeline/BakedQuadBuilder.java similarity index 51% rename from src/main/java/net/minecraftforge/client/model/pipeline/QuadBakingVertexConsumer.java rename to src/main/java/net/minecraftforge/client/model/pipeline/BakedQuadBuilder.java index 8cba3df305..a3cbb69015 100644 --- a/src/main/java/net/minecraftforge/client/model/pipeline/QuadBakingVertexConsumer.java +++ b/src/main/java/net/minecraftforge/client/model/pipeline/BakedQuadBuilder.java @@ -6,39 +6,30 @@ package net.minecraftforge.client.model.pipeline; import com.google.common.base.Preconditions; -import com.mojang.blaze3d.vertex.DefaultVertexFormat; import com.mojang.blaze3d.vertex.VertexConsumer; -import com.mojang.blaze3d.vertex.VertexFormatElement; -import net.minecraft.Util; +import net.minecraft.client.model.geom.builders.UVPair; import net.minecraft.client.renderer.block.model.BakedQuad; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.core.Direction; -import net.minecraftforge.client.model.IQuadTransformer; import net.minecraftforge.client.textures.UnitTextureAtlasSprite; -import java.util.IdentityHashMap; -import java.util.Map; import java.util.function.Consumer; +import org.joml.Vector3f; + /** * Vertex consumer that outputs {@linkplain BakedQuad baked quads}. *

    * This consumer accepts data in {@link com.mojang.blaze3d.vertex.DefaultVertexFormat#BLOCK} and is not picky about * ordering or missing elements, but will not automatically populate missing data (color will be black, for example). */ -public class QuadBakingVertexConsumer implements VertexConsumer { - private final Map ELEMENT_OFFSETS = Util.make(new IdentityHashMap<>(), map -> { - int i = 0; - for (var element : DefaultVertexFormat.BLOCK.getElements()) - map.put(element, DefaultVertexFormat.BLOCK.getOffset(i++) / 4); // Int offset - }); +public class BakedQuadBuilder implements VertexConsumer { private static final int MAX_VERTICES = 4; - private static final int QUAD_DATA_SIZE = IQuadTransformer.STRIDE * MAX_VERTICES; - private final Consumer quadConsumer; int vertexIndex = -1; - private int[] quadData = new int[QUAD_DATA_SIZE]; + private Vector3f[] positions; + private long[] uvs; private int tintIndex; private Direction direction = Direction.DOWN; @@ -47,8 +38,9 @@ public class QuadBakingVertexConsumer implements VertexConsumer { private boolean hasAmbientOcclusion; private int lightEmission; - public QuadBakingVertexConsumer(Consumer quadConsumer) { + public BakedQuadBuilder(Consumer quadConsumer) { this.quadConsumer = quadConsumer; + setup(); } @Override @@ -56,72 +48,76 @@ public class QuadBakingVertexConsumer implements VertexConsumer { if (vertexIndex++ == MAX_VERTICES) build(); - int offset = vertexIndex * IQuadTransformer.STRIDE + IQuadTransformer.POSITION; - quadData[offset] = Float.floatToRawIntBits((float) x); - quadData[offset + 1] = Float.floatToRawIntBits((float) y); - quadData[offset + 2] = Float.floatToRawIntBits((float) z); - return this; - } - - @Override - public VertexConsumer setNormal(float x, float y, float z) { - int offset = vertexIndex * IQuadTransformer.STRIDE + IQuadTransformer.NORMAL; - quadData[offset] = ((int) (x * 127.0f) & 0xFF) | - (((int) (y * 127.0f) & 0xFF) << 8) | - (((int) (z * 127.0f) & 0xFF) << 16); - return this; - } - - @Override - public VertexConsumer setColor(int r, int g, int b, int a) { - int offset = vertexIndex * IQuadTransformer.STRIDE + IQuadTransformer.COLOR; - quadData[offset] = ((a & 0xFF) << 24) | - ((b & 0xFF) << 16) | - ((g & 0xFF) << 8) | - (r & 0xFF); + var pos = this.positions[vertexIndex]; + pos.x = x; + pos.y = y; + pos.z = z; return this; } @Override public VertexConsumer setUv(float u, float v) { - int offset = vertexIndex * IQuadTransformer.STRIDE + IQuadTransformer.UV0; - quadData[offset] = Float.floatToRawIntBits(u); - quadData[offset + 1] = Float.floatToRawIntBits(v); + this.uvs[vertexIndex] = UVPair.pack(u, v); return this; } + /** Will not actually do anything, vanilla implementations ignore if passed invalid data so we do as well */ + @Override + public VertexConsumer setNormal(float x, float y, float z) { + //throw new IllegalStateException("Normal is not supported in BakedQuads anymore, vanilla never used this"); + return this; + } + + /** Will not actually do anything, vanilla implementations ignore if passed invalid data so we do as well */ + @Override + public VertexConsumer setColor(int r, int g, int b, int a) { + //throw new IllegalStateException("Per-vertex color is not supported in BakedQuads anymore, vanilla removed the feature"); + return this; + } + + /** Will not actually do anything, vanilla implementations ignore if passed invalid data so we do as well */ + @Override + public VertexConsumer setColor(int packed) { + //throw new IllegalStateException("Per-vertex color is not supported in BakedQuads anymore, vanilla removed the feature"); + return this; + } + + /** Will not actually do anything, vanilla implementations ignore if passed invalid data so we do as well */ + @Override + public VertexConsumer setLineWidth(float packed) { + //throw new IllegalStateException("Normal is not supported in BakedQuads anymore, vanilla never used this"); + return this; + } + + /** Will not actually do anything, vanilla implementations ignore if passed invalid data so we do as well */ @Override public VertexConsumer setUv1(int u, int v) { - if (IQuadTransformer.UV1 >= 0) { // Vanilla doesn't support this, but it may be added by a 3rd party - int offset = vertexIndex * IQuadTransformer.STRIDE + IQuadTransformer.UV1; - quadData[offset] = (u & 0xFFFF) | ((v & 0xFFFF) << 16); - } + //throw new IllegalStateException("UV1 is not supported in BakedQuads anymore, vanilla never used this"); return this; } + /** Will not actually do anything, vanilla implementations ignore if passed invalid data so we do as well */ @Override public VertexConsumer setUv2(int u, int v) { - int offset = vertexIndex * IQuadTransformer.STRIDE + IQuadTransformer.UV2; - quadData[offset] = (u & 0xFFFF) | ((v & 0xFFFF) << 16); + //throw new IllegalStateException("UV2 is not supported in BakedQuads anymore, you can't bake lighting per vertex anymore"); return this; } - @Override - public VertexConsumer misc(VertexFormatElement element, int... rawData) { - Integer baseOffset = ELEMENT_OFFSETS.get(element); - if (baseOffset != null) { - int offset = vertexIndex * IQuadTransformer.STRIDE + baseOffset; - System.arraycopy(rawData, 0, quadData, offset, rawData.length); - } - return this; + private void setup() { + this.positions = new Vector3f[]{ new Vector3f(), new Vector3f(), new Vector3f(), new Vector3f() }; + this.uvs = new long[4]; + this.vertexIndex = 0; } public BakedQuad build() { - BakedQuad quad = new BakedQuad(quadData, tintIndex, direction, sprite, shade, lightEmission, hasAmbientOcclusion); + BakedQuad quad = new BakedQuad( + this.positions[0], this.positions[1], this.positions[2], this.positions[3], + this.uvs[0], this.uvs[1], this.uvs[2], this.uvs[3], + tintIndex, direction, sprite, shade, lightEmission, hasAmbientOcclusion + ); + setup(); // We have a full quad, pass it to the consumer and reset quadConsumer.accept(quad); - vertexIndex = 0; - quadData = new int[QUAD_DATA_SIZE]; return quad; } @@ -149,14 +145,14 @@ public class QuadBakingVertexConsumer implements VertexConsumer { this.lightEmission = value; } - public static class Buffered extends QuadBakingVertexConsumer { + public static class Single extends BakedQuadBuilder { private final BakedQuad[] output; - public Buffered() { + public Single() { this(new BakedQuad[1]); } - private Buffered(BakedQuad[] output) { + private Single(BakedQuad[] output) { super(q -> output[0] = q); this.output = output; } diff --git a/src/main/java/net/minecraftforge/client/model/pipeline/VertexConsumerWrapper.java b/src/main/java/net/minecraftforge/client/model/pipeline/VertexConsumerWrapper.java index 0f3ac2d2f8..1dc8033b4a 100644 --- a/src/main/java/net/minecraftforge/client/model/pipeline/VertexConsumerWrapper.java +++ b/src/main/java/net/minecraftforge/client/model/pipeline/VertexConsumerWrapper.java @@ -6,68 +6,64 @@ package net.minecraftforge.client.model.pipeline; import com.mojang.blaze3d.vertex.VertexConsumer; -import com.mojang.blaze3d.vertex.VertexFormatElement; /** * Wrapper for {@link VertexConsumer} which delegates all operations to its parent. *

    * Useful for defining custom pipeline elements that only process certain data. */ -public abstract class VertexConsumerWrapper implements VertexConsumer -{ +public class VertexConsumerWrapper implements VertexConsumer { protected final VertexConsumer parent; - public VertexConsumerWrapper(VertexConsumer parent) - { + public VertexConsumerWrapper(VertexConsumer parent) { this.parent = parent; } @Override - public VertexConsumer addVertex(float x, float y, float z) - { + public VertexConsumer addVertex(float x, float y, float z) { parent.addVertex(x, y, z); return this; } @Override - public VertexConsumer setColor(int r, int g, int b, int a) - { + public VertexConsumer setColor(int color) { + parent.setColor(color); + return this; + } + + @Override + public VertexConsumer setColor(int r, int g, int b, int a) { parent.setColor(r, g, b, a); return this; } @Override - public VertexConsumer setUv(float u, float v) - { + public VertexConsumer setUv(float u, float v) { parent.setUv(u, v); return this; } @Override - public VertexConsumer setUv1(int u, int v) - { + public VertexConsumer setUv1(int u, int v) { parent.setUv1(u, v); return this; } @Override - public VertexConsumer setUv2(int u, int v) - { + public VertexConsumer setUv2(int u, int v) { parent.setUv2(u, v); return this; } @Override - public VertexConsumer setNormal(float x, float y, float z) - { + public VertexConsumer setNormal(float x, float y, float z) { parent.setNormal(x, y, z); return this; } @Override - public VertexConsumer misc(VertexFormatElement element, int... values) - { - parent.misc(element, values); + public VertexConsumer setLineWidth(float width) { + parent.setLineWidth(width); return this; } } diff --git a/src/main/java/net/minecraftforge/client/model/pipeline/package-info.java b/src/main/java/net/minecraftforge/client/model/pipeline/package-info.java index c1701196ee..1d86f3697b 100644 --- a/src/main/java/net/minecraftforge/client/model/pipeline/package-info.java +++ b/src/main/java/net/minecraftforge/client/model/pipeline/package-info.java @@ -3,10 +3,7 @@ * SPDX-License-Identifier: LGPL-2.1-only */ -@ParametersAreNonnullByDefault -@MethodsReturnNonnullByDefault +@NullMarked package net.minecraftforge.client.model.pipeline; -import net.minecraft.MethodsReturnNonnullByDefault; - -import javax.annotation.ParametersAreNonnullByDefault; +import org.jspecify.annotations.NullMarked; diff --git a/src/main/java/net/minecraftforge/client/model/renderable/BakedModelRenderable.java b/src/main/java/net/minecraftforge/client/model/renderable/BakedModelRenderable.java index 2d8a964b6b..a20e4473f5 100644 --- a/src/main/java/net/minecraftforge/client/model/renderable/BakedModelRenderable.java +++ b/src/main/java/net/minecraftforge/client/model/renderable/BakedModelRenderable.java @@ -67,7 +67,7 @@ public class BakedModelRenderable implements IRenderable quads = new ArrayList<>(); - public Mesh(ResourceLocation texture) { + public Mesh(Identifier texture) { this.texture = texture; } public void render(PoseStack poseStack, MultiBufferSource bufferSource, ITextureRenderTypeLookup textureRenderTypeLookup, int lightmap, int overlay) { var consumer = bufferSource.getBuffer(textureRenderTypeLookup.get(texture)); for (var quad : quads) - consumer.putBulkData(poseStack.last(), quad, 1, 1, 1, 1, lightmap, overlay, true); + consumer.putBulkData(poseStack.last(), quad, 1, 1, 1, 1, lightmap, overlay); } } @@ -111,7 +111,7 @@ public class CompositeRenderable implements IRenderable(this, child); } - public PartBuilder addMesh(ResourceLocation texture, List quads) { + public PartBuilder addMesh(Identifier texture, List quads) { var mesh = new Mesh(texture); mesh.quads.addAll(quads); component.meshes.add(mesh); diff --git a/src/main/java/net/minecraftforge/client/model/renderable/ITextureRenderTypeLookup.java b/src/main/java/net/minecraftforge/client/model/renderable/ITextureRenderTypeLookup.java index 02b48b308c..50211bb9a9 100644 --- a/src/main/java/net/minecraftforge/client/model/renderable/ITextureRenderTypeLookup.java +++ b/src/main/java/net/minecraftforge/client/model/renderable/ITextureRenderTypeLookup.java @@ -5,14 +5,13 @@ package net.minecraftforge.client.model.renderable; -import net.minecraft.client.renderer.RenderType; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.client.renderer.rendertype.RenderType; +import net.minecraft.resources.Identifier; /** * A generic lookup for {@link RenderType} implementations that use the specified texture. */ @FunctionalInterface -public interface ITextureRenderTypeLookup -{ - RenderType get(ResourceLocation name); +public interface ITextureRenderTypeLookup { + RenderType get(Identifier name); } diff --git a/src/main/java/net/minecraftforge/client/settings/KeyModifier.java b/src/main/java/net/minecraftforge/client/settings/KeyModifier.java index 1fb1142601..f763315421 100644 --- a/src/main/java/net/minecraftforge/client/settings/KeyModifier.java +++ b/src/main/java/net/minecraftforge/client/settings/KeyModifier.java @@ -21,7 +21,9 @@ public enum KeyModifier { CONTROL { @Override public boolean matches(InputConstants.Key key) { - return key.getValue() == InputQuirks.EDIT_SHORTCUT_KEY_LEFT || key.getValue() == InputQuirks.EDIT_SHORTCUT_KEY_RIGHT; + if (InputQuirks.REPLACE_CTRL_KEY_WITH_CMD_KEY) + return key.getValue() == 343 || key.getValue() == 347; + return key.getValue() == 341 || key.getValue() == 345; } @Override diff --git a/src/main/java/net/minecraftforge/client/textures/ForgeTextureMetadata.java b/src/main/java/net/minecraftforge/client/textures/ForgeTextureMetadata.java index 9b64cc4114..4470d239c2 100644 --- a/src/main/java/net/minecraftforge/client/textures/ForgeTextureMetadata.java +++ b/src/main/java/net/minecraftforge/client/textures/ForgeTextureMetadata.java @@ -5,7 +5,7 @@ package net.minecraftforge.client.textures; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.packs.metadata.MetadataSectionType; import net.minecraft.server.packs.resources.Resource; import com.mojang.serialization.Codec; @@ -29,7 +29,7 @@ public record ForgeTextureMetadata(@Nullable ITextureAtlasSpriteLoader loader) { var ret = TextureAtlasSpriteLoaderManager.getKey(loader); return ret == null ? null : ret.toString(); }, - name -> TextureAtlasSpriteLoaderManager.get(ResourceLocation.parse(name)) + name -> TextureAtlasSpriteLoaderManager.get(Identifier.parse(name)) ); private static final Codec CODEC = RecordCodecBuilder.create(i -> diff --git a/src/main/java/net/minecraftforge/client/textures/ITextureAtlasSpriteLoader.java b/src/main/java/net/minecraftforge/client/textures/ITextureAtlasSpriteLoader.java index 8d2c8361e3..b5317f6480 100644 --- a/src/main/java/net/minecraftforge/client/textures/ITextureAtlasSpriteLoader.java +++ b/src/main/java/net/minecraftforge/client/textures/ITextureAtlasSpriteLoader.java @@ -9,7 +9,7 @@ import com.mojang.blaze3d.platform.NativeImage; 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.resources.Identifier; import net.minecraft.server.packs.metadata.MetadataSectionType; import net.minecraft.server.packs.resources.Resource; import net.minecraftforge.client.event.RegisterTextureAtlasSpriteLoadersEvent; @@ -33,11 +33,11 @@ import org.jetbrains.annotations.NotNull; * @see RegisterTextureAtlasSpriteLoadersEvent */ public interface ITextureAtlasSpriteLoader { - SpriteContents loadContents(ResourceLocation name, Resource resource, FrameSize frameSize, NativeImage image, List> metadata); + SpriteContents loadContents(Identifier name, Resource resource, FrameSize frameSize, NativeImage image, List> metadata); /** * Creates a {@link TextureAtlasSprite} from the given {@link SpriteContents}. */ @NotNull - TextureAtlasSprite makeSprite(ResourceLocation atlasName, SpriteContents contents, int atlasWidth, int atlasHeight, int spriteX, int spriteY, int mipmapLevel); + TextureAtlasSprite makeSprite(Identifier atlasName, SpriteContents contents, int atlasWidth, int atlasHeight, int spriteX, int spriteY, int padding, int mipmapLevel); } diff --git a/src/main/java/net/minecraftforge/client/textures/TextureAtlasSpriteLoaderManager.java b/src/main/java/net/minecraftforge/client/textures/TextureAtlasSpriteLoaderManager.java index 0286806112..c795bd0b8f 100644 --- a/src/main/java/net/minecraftforge/client/textures/TextureAtlasSpriteLoaderManager.java +++ b/src/main/java/net/minecraftforge/client/textures/TextureAtlasSpriteLoaderManager.java @@ -8,7 +8,7 @@ package net.minecraftforge.client.textures; import com.google.common.collect.BiMap; import com.google.common.collect.HashBiMap; import com.google.common.collect.ImmutableBiMap; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraftforge.client.event.RegisterTextureAtlasSpriteLoadersEvent; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nullable; @@ -20,24 +20,24 @@ import org.jetbrains.annotations.Nullable; * TODO: Convert this into a proper registry */ public final class TextureAtlasSpriteLoaderManager { - private static BiMap LOADERS; + private static BiMap LOADERS; /** * Finds the loader with the given name, or null if none is registered. */ @Nullable - public static ITextureAtlasSpriteLoader get(ResourceLocation name) { + public static ITextureAtlasSpriteLoader get(Identifier name) { return LOADERS.get(name); } @Nullable - public static ResourceLocation getKey(ITextureAtlasSpriteLoader value) { + public static Identifier getKey(ITextureAtlasSpriteLoader value) { return LOADERS.inverse().get(value); } @ApiStatus.Internal public static void init() { - var loaders = HashBiMap.create(); + var loaders = HashBiMap.create(); RegisterTextureAtlasSpriteLoadersEvent.BUS.post(new RegisterTextureAtlasSpriteLoadersEvent(loaders)); 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 3dbe700a6b..3ac8ddc474 100644 --- a/src/main/java/net/minecraftforge/client/textures/UnitTextureAtlasSprite.java +++ b/src/main/java/net/minecraftforge/client/textures/UnitTextureAtlasSprite.java @@ -9,7 +9,7 @@ import com.mojang.blaze3d.platform.NativeImage; 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.resources.Identifier; /** * A helper sprite with UVs spanning the entire texture. @@ -17,11 +17,11 @@ import net.minecraft.resources.ResourceLocation; * Useful for baking quads that won't be used with an atlas. */ public class UnitTextureAtlasSprite extends TextureAtlasSprite { - public static final ResourceLocation LOCATION = ResourceLocation.fromNamespaceAndPath("forge", "unit"); + public static final Identifier LOCATION = Identifier.fromNamespaceAndPath("forge", "unit"); public static final UnitTextureAtlasSprite INSTANCE = new UnitTextureAtlasSprite(); private UnitTextureAtlasSprite() { - super(LOCATION, new SpriteContents(LOCATION, new FrameSize(1, 1), new NativeImage(1, 1, false)), 1, 1, 0, 0); + super(LOCATION, new SpriteContents(LOCATION, new FrameSize(1, 1), new NativeImage(1, 1, false)), 1, 1, 0, 0, 0); } @Override diff --git a/src/main/java/net/minecraftforge/common/BiomeManager.java b/src/main/java/net/minecraftforge/common/BiomeManager.java index 54f418c56c..a818d07223 100644 --- a/src/main/java/net/minecraftforge/common/BiomeManager.java +++ b/src/main/java/net/minecraftforge/common/BiomeManager.java @@ -13,20 +13,16 @@ import java.util.List; import com.google.common.collect.ImmutableList; -import net.minecraft.util.random.WeightedRandom; -import net.minecraft.world.entity.ai.behavior.ShufflingList; import net.minecraft.world.level.biome.Biomes; import net.minecraft.resources.ResourceKey; import net.minecraft.world.level.biome.Biome; -public class BiomeManager -{ +public class BiomeManager { private static final TrackedList[] biomes = setupBiomes(); private static final List> additionalOverworldBiomes = new ArrayList<>(); private static final List> additionalOverworldBiomesView = Collections.unmodifiableList(additionalOverworldBiomes); - private static TrackedList[] setupBiomes() - { + private static TrackedList[] setupBiomes() { @SuppressWarnings("unchecked") TrackedList[] currentBiomes = new TrackedList[BiomeType.values().length]; @@ -68,28 +64,22 @@ public class BiomeManager /** * Add biomes that you add to the overworld without using {@link BiomeManager#addBiome(BiomeType, BiomeEntry)} */ - public static void addAdditionalOverworldBiomes(ResourceKey biome) - { - if (!"minecraft".equals(biome.location().getNamespace()) && additionalOverworldBiomes.stream().noneMatch(entry -> entry.location().equals(biome.location()))) - { + public static void addAdditionalOverworldBiomes(ResourceKey biome) { + if (!"minecraft".equals(biome.identifier().getNamespace()) && additionalOverworldBiomes.stream().noneMatch(entry -> entry.identifier().equals(biome.identifier()))) additionalOverworldBiomes.add(biome); - } } - public static boolean addBiome(BiomeType type, BiomeEntry entry) - { + public static boolean addBiome(BiomeType type, BiomeEntry entry) { int idx = type.ordinal(); List list = idx > biomes.length ? null : biomes[idx]; - if (list != null) - { + if (list != null) { additionalOverworldBiomes.add(entry.key); return list.add(entry); } return false; } - public static boolean removeBiome(BiomeType type, BiomeEntry entry) - { + public static boolean removeBiome(BiomeType type, BiomeEntry entry) { int idx = type.ordinal(); List list = idx > biomes.length ? null : biomes[idx]; return list == null ? false : list.remove(entry); @@ -98,128 +88,108 @@ public class BiomeManager /** * @return list of biomes that might be generated in the overworld in addition to the vanilla biomes */ - public static List> getAdditionalOverworldBiomes() - { + public static List> getAdditionalOverworldBiomes() { return additionalOverworldBiomesView; } - public static ImmutableList getBiomes(BiomeType type) - { + public static ImmutableList getBiomes(BiomeType type) { int idx = type.ordinal(); List list = idx >= biomes.length ? null : biomes[idx]; return list != null ? ImmutableList.copyOf(list) : ImmutableList.of(); } - public static boolean isTypeListModded(BiomeType type) - { + public static boolean isTypeListModded(BiomeType type) { int idx = type.ordinal(); TrackedList list = idx > biomes.length ? null : biomes[idx]; return list == null ? false : list.isModded(); } - public static enum BiomeType - { + public static enum BiomeType { DESERT, DESERT_LEGACY, WARM, COOL, ICY; } - public static class BiomeEntry - { + public static class BiomeEntry { private final ResourceKey key; - public BiomeEntry(ResourceKey key, int weight) - { + public BiomeEntry(ResourceKey key, int weight) { this.key = key; } - public ResourceKey getKey() - { + public ResourceKey getKey() { return this.key; } } - private static class TrackedList extends ArrayList - { + private static class TrackedList extends ArrayList { private static final long serialVersionUID = 1L; private boolean isModded = false; @SafeVarargs - private TrackedList(T... c) - { + private TrackedList(T... c) { super(Arrays.asList(c)); } @Override - public E set(int index, E element) - { + public E set(int index, E element) { isModded = true; return super.set(index, element); } @Override - public boolean add(E e) - { + public boolean add(E e) { isModded = true; return super.add(e); } @Override - public void add(int index, E element) - { + public void add(int index, E element) { isModded = true; super.add(index, element); } @Override - public E remove(int index) - { + public E remove(int index) { isModded = true; return super.remove(index); } @Override - public boolean remove(Object o) - { + public boolean remove(Object o) { isModded = true; return super.remove(o); } @Override - public void clear() - { + public void clear() { isModded = true; super.clear(); } @Override - public boolean addAll(Collection c) - { + public boolean addAll(Collection c) { isModded = true; return super.addAll(c); } @Override - public boolean addAll(int index, Collection c) - { + public boolean addAll(int index, Collection c) { isModded = true; return super.addAll(index, c); } @Override - public boolean removeAll(Collection c) - { + public boolean removeAll(Collection c) { isModded = true; return super.removeAll(c); } @Override - public boolean retainAll(Collection c) - { + public boolean retainAll(Collection c) { isModded = true; return super.retainAll(c); } - public boolean isModded() - { + public boolean isModded() { return isModded; } } diff --git a/src/main/java/net/minecraftforge/common/CreativeModeTabRegistry.java b/src/main/java/net/minecraftforge/common/CreativeModeTabRegistry.java index 9cb27ac3ae..bc9af0186e 100644 --- a/src/main/java/net/minecraftforge/common/CreativeModeTabRegistry.java +++ b/src/main/java/net/minecraftforge/common/CreativeModeTabRegistry.java @@ -21,7 +21,7 @@ import java.util.Comparator; import net.minecraft.core.Holder; import net.minecraft.core.registries.BuiltInRegistries; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.MinecraftServer; import net.minecraft.server.packs.resources.PreparableReloadListener; import net.minecraft.server.packs.resources.Resource; @@ -49,7 +49,7 @@ import java.util.stream.Collectors; public final class CreativeModeTabRegistry { private static final Logger LOGGER = LogUtils.getLogger(); - private static final ResourceLocation CREATIVE_MODE_TAB_ORDERING_JSON = ResourceLocation.fromNamespaceAndPath("forge", "creative_mode_tab_ordering.json"); + private static final Identifier CREATIVE_MODE_TAB_ORDERING_JSON = Identifier.fromNamespaceAndPath("forge", "creative_mode_tab_ordering.json"); private static final List SORTED_TABS = new ArrayList<>(); private static final List SORTED_TABS_VIEW = Collections.unmodifiableList(SORTED_TABS); private static final List DEFAULT_TABS = new ArrayList<>(); @@ -71,7 +71,7 @@ public final class CreativeModeTabRegistry { * @param name the name to look up */ @Nullable - public static CreativeModeTab getTab(ResourceLocation name) { + public static CreativeModeTab getTab(Identifier name) { return BuiltInRegistries.CREATIVE_MODE_TAB.getValue(name); } @@ -81,11 +81,11 @@ public final class CreativeModeTabRegistry { * @param tab the tab to look up */ @Nullable - public static ResourceLocation getName(CreativeModeTab tab) { + public static Identifier getName(CreativeModeTab tab) { return BuiltInRegistries.CREATIVE_MODE_TAB.getKey(tab); } - private static final Multimap edges = HashMultimap.create(); + private static final Multimap edges = HashMultimap.create(); static PreparableReloadListener getReloadListener() { return new SimplePreparableReloadListener() { @@ -113,7 +113,7 @@ public final class CreativeModeTabRegistry { JsonArray order = GsonHelper.getAsJsonArray(data, "order"); List customOrder = new ArrayList<>(); for (JsonElement entry : order) { - ResourceLocation id = ResourceLocation.parse(entry.getAsString()); + Identifier id = Identifier.parse(entry.getAsString()); CreativeModeTab CreativeModeTab = getTab(id); if (CreativeModeTab == null) throw new IllegalStateException("CreativeModeTab not found with name " + id); @@ -192,24 +192,24 @@ public final class CreativeModeTabRegistry { for (int i = 0; i < vanillaTabs; i++) { // Vanilla ordering final Holder value = indexed.get(i); final CreativeModeTab tab = value.get(); - final ResourceLocation name = value.unwrapKey().orElseThrow().location(); + final Identifier name = value.unwrapKey().orElseThrow().identifier(); if (!tab.tabsBefore.isEmpty() || !tab.tabsAfter.isEmpty()) addTabOrder(tab, name); else { // If there is no order specified ensure vanilla ordering by specifying the previous and next indexed tab as edges if (i != 0) - edges.put(indexed.get(i - 1).unwrapKey().orElseThrow().location(), name); + edges.put(indexed.get(i - 1).unwrapKey().orElseThrow().identifier(), name); if (i + 1 < indexed.size()) - edges.put(name, indexed.get(i + 1).unwrapKey().orElseThrow().location()); + edges.put(name, indexed.get(i + 1).unwrapKey().orElseThrow().identifier()); } } - ResourceLocation lastVanilla = indexed.get(vanillaTabs - 1).unwrapKey().orElseThrow().location(); + Identifier lastVanilla = indexed.get(vanillaTabs - 1).unwrapKey().orElseThrow().identifier(); for (int i = vanillaTabs; i < indexed.size(); i++) { final Holder value = indexed.get(i); final CreativeModeTab tab = value.get(); - final ResourceLocation name = value.unwrapKey().orElseThrow().location(); + final Identifier name = value.unwrapKey().orElseThrow().identifier(); if (!tab.tabsBefore.isEmpty() || !tab.tabsAfter.isEmpty()) addTabOrder(tab, name); @@ -220,7 +220,7 @@ public final class CreativeModeTabRegistry { recalculateItemCreativeModeTabs(); } - private static void addTabOrder(CreativeModeTab tab, ResourceLocation name) { + private static void addTabOrder(CreativeModeTab tab, Identifier name) { for (var after : tab.tabsAfter) { edges.put(name, after); } diff --git a/src/main/java/net/minecraftforge/common/ForgeHooks.java b/src/main/java/net/minecraftforge/common/ForgeHooks.java index df4e4cee5d..e44f8c4a8c 100644 --- a/src/main/java/net/minecraftforge/common/ForgeHooks.java +++ b/src/main/java/net/minecraftforge/common/ForgeHooks.java @@ -63,6 +63,7 @@ import net.minecraft.network.chat.TextColor; import net.minecraft.network.chat.contents.PlainTextContents.LiteralContents; import net.minecraft.network.codec.StreamCodec; import net.minecraft.server.level.ServerLevel; +import net.minecraft.tags.BlockTags; import net.minecraft.tags.TagKey; import net.minecraft.util.CrudeIncrementalIntIdentityHashBiMap; import net.minecraft.util.GsonHelper; @@ -98,6 +99,7 @@ import net.minecraft.world.item.enchantment.EnchantmentHelper; import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.entity.player.Player; import net.minecraft.server.level.ServerPlayer; +import net.minecraft.server.permissions.Permissions; import net.minecraft.world.inventory.AnvilMenu; import net.minecraft.world.Container; import net.minecraft.world.item.context.UseOnContext; @@ -181,7 +183,7 @@ import org.apache.logging.log4j.MarkerManager; import net.minecraft.ChatFormatting; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.level.GameType; import net.minecraft.world.level.Level; @@ -282,6 +284,8 @@ public final class ForgeHooks { public static Optional isLivingOnLadder(@NotNull BlockState state, @NotNull Level level, @NotNull BlockPos pos, @NotNull LivingEntity entity) { boolean isSpectator = (entity instanceof Player && entity.isSpectator()); if (isSpectator) return Optional.empty(); + if (entity.isFallFlying() && state.is(BlockTags.CAN_GLIDE_THROUGH)) + return Optional.empty(); if (!ForgeConfig.SERVER.fullBoundingBoxLadders.get()) return state.isLadder(level, pos, entity) ? Optional.of(pos) : Optional.empty(); else { @@ -678,7 +682,7 @@ public final class ForgeHooks { @Nullable public static String getDefaultCreatorModId(@NotNull ItemStack itemStack) { Item item = itemStack.getItem(); - ResourceLocation registryName = ForgeRegistries.ITEMS.getKey(item); + Identifier registryName = ForgeRegistries.ITEMS.getKey(item); String modId = registryName == null ? null : registryName.getNamespace(); if ("minecraft".equals(modId)) { if (itemStack.is(Items.ENCHANTED_BOOK)) { @@ -687,18 +691,18 @@ public final class ForgeHooks { var enchant = enchants.keySet().iterator().next(); var name = enchant.unwrapKey(); if (name.isPresent()) - return name.get().location().getNamespace(); + return name.get().identifier().getNamespace(); } } else if (itemStack.has(DataComponents.POTION_CONTENTS)) { var potion = itemStack.get(DataComponents.POTION_CONTENTS).potion().orElse(null); if (potion != null && potion.unwrapKey().isPresent()) - return potion.unwrapKey().get().location().getNamespace(); + return potion.unwrapKey().get().identifier().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(); + var Identifier = EntityType.getKey(data.type()); + if (Identifier != null) + return Identifier.getNamespace(); } } } @@ -817,7 +821,7 @@ public final class ForgeHooks { fmlData.put("Registries", registries); LOGGER.debug(WORLDPERSISTENCE, "Gathering id map for writing to world save {}", worldData.getLevelName()); - for (Map.Entry e : RegistryManager.ACTIVE.takeSnapshot(true).entrySet()) + for (Map.Entry e : RegistryManager.ACTIVE.takeSnapshot(true).entrySet()) registries.put(e.getKey().toString(), e.getValue().write()); LOGGER.debug(WORLDPERSISTENCE, "ID Map collection complete {}", worldData.getLevelName()); levelTag.put("fml", fmlData); @@ -907,13 +911,13 @@ public final class ForgeHooks { } } - Multimap failedElements = null; + Multimap failedElements = null; if (tag.contains("Registries")) { - Map snapshot = new HashMap<>(); + Map snapshot = new HashMap<>(); CompoundTag regs = tag.getCompoundOrEmpty("Registries"); for (String key : regs.keySet()) - snapshot.put(ResourceLocation.parse(key), ForgeRegistry.Snapshot.read(regs.getCompoundOrEmpty(key))); + snapshot.put(Identifier.parse(key), ForgeRegistry.Snapshot.read(regs.getCompoundOrEmpty(key))); failedElements = GameData.injectSnapshot(snapshot, true, true); } @@ -980,12 +984,12 @@ public final class ForgeHooks { * @hidden For internal use only. */ public static boolean checkStructureNamespace(String biome) { - @Nullable ResourceLocation biomeLocation = ResourceLocation.tryParse(biome); - return biomeLocation != null && !biomeLocation.getNamespace().equals(ResourceLocation.DEFAULT_NAMESPACE); + @Nullable Identifier biomeLocation = Identifier.tryParse(biome); + return biomeLocation != null && !biomeLocation.getNamespace().equals(Identifier.DEFAULT_NAMESPACE); } public static boolean canUseEntitySelectors(SharedSuggestionProvider provider) { - if (EntitySelectorParser.allowSelectors(provider)) + if (provider.permissions().hasPermission(Permissions.COMMANDS_ENTITY_SELECTORS)) return true; else if (provider instanceof CommandSourceStack source && source.source instanceof ServerPlayer player) return PermissionAPI.getPermission(player, ForgeMod.USE_SELECTORS_PERMISSION); @@ -1073,7 +1077,7 @@ public final class ForgeHooks { } @ApiStatus.Internal - public static StreamCodec getCustomPayloadCodec(ResourceLocation id, int max) { + public static StreamCodec getCustomPayloadCodec(Identifier id, int max) { var channel = NetworkRegistry.findTarget(id); if (channel == null) return DiscardedPayload.codec(id, max); @@ -1111,13 +1115,6 @@ public final class ForgeHooks { @ApiStatus.Internal public static boolean onCustomPayload(CustomPayloadEvent event) { - var connection = event.getSource().getConnection(); - var expectedSide = connection.getReceiving() == PacketFlow.CLIENTBOUND ? LogicalSide.CLIENT : LogicalSide.SERVER; - if (expectedSide != EffectiveSide.get()) { - connection.disconnect(Component.literal("Illegal packet received, terminating connection")); - return false; - } - var channel = NetworkRegistry.findTarget(event.getChannel()); if (channel != null && channel.dispatch(event)) return true; @@ -1216,7 +1213,7 @@ public final class ForgeHooks { throw new IllegalArgumentException("Tried to write unregistered Ingredient to network: " + value); buf.writeVarInt(-1); // Our Marker - buf.writeResourceLocation(key); + buf.writeIdentifier(key); } serializer.write(buf, value); }, @@ -1227,7 +1224,7 @@ public final class ForgeHooks { if (size != -1) { buf.resetReaderIndex(); } else { - var key = buf.readResourceLocation(); + var key = buf.readIdentifier(); serializer = ForgeRegistries.INGREDIENT_SERIALIZERS.get().getValue(key); if (serializer == null) throw new DecoderException("Could not read ingredient of type: " + key); @@ -1257,7 +1254,7 @@ public final class ForgeHooks { } @SuppressWarnings("unchecked") - public static T onJsonDataParsed(Codec codec, ResourceLocation key, T value) { + public static T onJsonDataParsed(Codec codec, Identifier key, T value) { if (codec == LootDataType.TABLE.codec()) { var table = (LootTable)value; table.setLootTableId(key); @@ -1274,7 +1271,7 @@ public final class ForgeHooks { * * This is useful for game tests that need a structure, but want to create the contents in code. */ - public static Optional createEmptyStructure(ResourceLocation name) { + public static Optional createEmptyStructure(Identifier name) { if (name== null || !"forge".equals(name.getNamespace())) return Optional.empty(); diff --git a/src/main/java/net/minecraftforge/common/ForgeMod.java b/src/main/java/net/minecraftforge/common/ForgeMod.java index d089613c26..107a08503e 100644 --- a/src/main/java/net/minecraftforge/common/ForgeMod.java +++ b/src/main/java/net/minecraftforge/common/ForgeMod.java @@ -6,7 +6,6 @@ package net.minecraftforge.common; import net.minecraft.DetectedVersion; -import net.minecraft.SharedConstants; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.BiomeColors; import net.minecraft.commands.synchronization.ArgumentTypeInfo; @@ -22,6 +21,7 @@ import net.minecraft.network.chat.Component; import net.minecraft.server.packs.PackType; import net.minecraft.server.packs.metadata.pack.PackMetadataSection; import net.minecraft.sounds.SoundEvents; +import net.minecraft.world.attribute.EnvironmentAttributes; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Mob; import net.minecraft.commands.Commands; @@ -95,7 +95,7 @@ import org.apache.logging.log4j.Logger; import net.minecraft.data.DataGenerator; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraftforge.common.crafting.ConditionalRecipe; import net.minecraftforge.common.crafting.conditions.AndCondition; import net.minecraftforge.common.crafting.conditions.FalseCondition; @@ -232,29 +232,29 @@ public class ForgeMod { @Override public void initializeClient(Consumer consumer) { consumer.accept(new IClientFluidTypeExtensions() { - private static final ResourceLocation UNDERWATER_LOCATION = ResourceLocation.withDefaultNamespace("textures/misc/underwater.png"); - private static final ResourceLocation WATER_STILL = ResourceLocation.withDefaultNamespace("block/water_still"); - private static final ResourceLocation WATER_FLOW = ResourceLocation.withDefaultNamespace("block/water_flow"); - private static final ResourceLocation WATER_OVERLAY = ResourceLocation.withDefaultNamespace("block/water_overlay"); + private static final Identifier UNDERWATER_LOCATION = Identifier.withDefaultNamespace("textures/misc/underwater.png"); + private static final Identifier WATER_STILL = Identifier.withDefaultNamespace("block/water_still"); + private static final Identifier WATER_FLOW = Identifier.withDefaultNamespace("block/water_flow"); + private static final Identifier WATER_OVERLAY = Identifier.withDefaultNamespace("block/water_overlay"); @Override - public ResourceLocation getStillTexture() { + public Identifier getStillTexture() { return WATER_STILL; } @Override - public ResourceLocation getFlowingTexture() { + public Identifier getFlowingTexture() { return WATER_FLOW; } @Nullable @Override - public ResourceLocation getOverlayTexture() { + public Identifier getOverlayTexture() { return WATER_OVERLAY; } @Override - public ResourceLocation getRenderOverlayTexture(Minecraft mc) { + public Identifier getRenderOverlayTexture(Minecraft mc) { return UNDERWATER_LOCATION; } @@ -287,7 +287,7 @@ public class ForgeMod { { @Override public double motionScale(Entity entity) { - return entity.level().dimensionType().ultraWarm() ? 0.007D : 0.0023333333333333335D; + return entity.level().environmentAttributes().getDimensionValue(EnvironmentAttributes.WATER_EVAPORATES) ? 0.007D : 0.0023333333333333335D; } @Override @@ -299,16 +299,16 @@ public class ForgeMod { @Override public void initializeClient(Consumer consumer) { consumer.accept(new IClientFluidTypeExtensions() { - private static final ResourceLocation LAVA_STILL = ResourceLocation.withDefaultNamespace("block/lava_still"); - private static final ResourceLocation LAVA_FLOW = ResourceLocation.withDefaultNamespace("block/lava_flow"); + private static final Identifier LAVA_STILL = Identifier.withDefaultNamespace("block/lava_still"); + private static final Identifier LAVA_FLOW = Identifier.withDefaultNamespace("block/lava_flow"); @Override - public ResourceLocation getStillTexture() { + public Identifier getStillTexture() { return LAVA_STILL; } @Override - public ResourceLocation getFlowingTexture() { + public Identifier getFlowingTexture() { return LAVA_FLOW; } }); @@ -349,11 +349,11 @@ public class ForgeMod { private static boolean enableMilkFluid = false; - public static final RegistryObject BUCKET_EMPTY_MILK = RegistryObject.create(ResourceLocation.withDefaultNamespace("item.bucket.empty_milk"), ForgeRegistries.SOUND_EVENTS); - public static final RegistryObject BUCKET_FILL_MILK = RegistryObject.create(ResourceLocation.withDefaultNamespace("item.bucket.fill_milk"), ForgeRegistries.SOUND_EVENTS); - public static final RegistryObject MILK_TYPE = RegistryObject.createOptional(ResourceLocation.withDefaultNamespace("milk"), ForgeRegistries.Keys.FLUID_TYPES.location(), "minecraft"); - public static final RegistryObject MILK = RegistryObject.create(ResourceLocation.withDefaultNamespace("milk"), ForgeRegistries.FLUIDS); - public static final RegistryObject FLOWING_MILK = RegistryObject.create(ResourceLocation.withDefaultNamespace("flowing_milk"), ForgeRegistries.FLUIDS); + public static final RegistryObject BUCKET_EMPTY_MILK = RegistryObject.create(Identifier.withDefaultNamespace("item.bucket.empty_milk"), ForgeRegistries.SOUND_EVENTS); + public static final RegistryObject BUCKET_FILL_MILK = RegistryObject.create(Identifier.withDefaultNamespace("item.bucket.fill_milk"), ForgeRegistries.SOUND_EVENTS); + public static final RegistryObject MILK_TYPE = RegistryObject.createOptional(Identifier.withDefaultNamespace("milk"), ForgeRegistries.Keys.FLUID_TYPES.identifier(), "minecraft"); + public static final RegistryObject MILK = RegistryObject.create(Identifier.withDefaultNamespace("milk"), ForgeRegistries.FLUIDS); + public static final RegistryObject FLOWING_MILK = RegistryObject.create(Identifier.withDefaultNamespace("flowing_milk"), ForgeRegistries.FLUIDS); private static ForgeMod INSTANCE; public static ForgeMod getInstance() { @@ -419,8 +419,8 @@ public class ForgeMod { ForgeRegistries.ITEMS.tags().addOptionalTagDefaults(Tags.Items.ENCHANTING_FUELS, Set.of(ForgeRegistries.ITEMS.getDelegateOrThrow(Items.LAPIS_LAZULI))); // TODO: Remove when addAlias becomes proper API, as this should be done in the DR's above. - addAlias(ForgeRegistries.ATTRIBUTES, ResourceLocation.fromNamespaceAndPath("forge", "reach_distance"), ResourceLocation.fromNamespaceAndPath("forge", "block_reach")); - addAlias(ForgeRegistries.ATTRIBUTES, ResourceLocation.fromNamespaceAndPath("forge", "attack_range"), ResourceLocation.fromNamespaceAndPath("forge", "entity_reach")); + addAlias(ForgeRegistries.ATTRIBUTES, Identifier.fromNamespaceAndPath("forge", "reach_distance"), Identifier.fromNamespaceAndPath("forge", "block_reach")); + addAlias(ForgeRegistries.ATTRIBUTES, Identifier.fromNamespaceAndPath("forge", "attack_range"), Identifier.fromNamespaceAndPath("forge", "entity_reach")); } private static void preInit(FMLCommonSetupEvent evt) { @@ -480,16 +480,16 @@ public class ForgeMod { @Override public void initializeClient(Consumer consumer) { consumer.accept(new IClientFluidTypeExtensions() { - private static final ResourceLocation MILK_STILL = ResourceLocation.fromNamespaceAndPath("forge", "block/milk_still"); - private static final ResourceLocation MILK_FLOW = ResourceLocation.fromNamespaceAndPath("forge", "block/milk_flowing"); + private static final Identifier MILK_STILL = Identifier.fromNamespaceAndPath("forge", "block/milk_still"); + private static final Identifier MILK_FLOW = Identifier.fromNamespaceAndPath("forge", "block/milk_flowing"); @Override - public ResourceLocation getStillTexture() { + public Identifier getStillTexture() { return MILK_STILL; } @Override - public ResourceLocation getFlowingTexture() { + public Identifier getFlowingTexture() { return MILK_FLOW; } }); @@ -515,18 +515,18 @@ public class ForgeMod { Arrays.stream(ItemDisplayContext.values()) .filter(Predicate.not(ItemDisplayContext::isModded)) - .forEach(ctx -> forgeRegistry.register(ctx.getId(), ResourceLocation.fromNamespaceAndPath("minecraft", ctx.getSerializedName()), ctx)); + .forEach(ctx -> forgeRegistry.register(ctx.getId(), Identifier.fromNamespaceAndPath("minecraft", ctx.getSerializedName()), ctx)); } } public static final PermissionNode USE_SELECTORS_PERMISSION = new PermissionNode<>("forge", "use_entity_selectors", - PermissionTypes.BOOLEAN, (player, uuid, contexts) -> player != null && player.hasPermissions(Commands.LEVEL_GAMEMASTERS)); + PermissionTypes.BOOLEAN, (player, uuid, contexts) -> player != null && Commands.LEVEL_GAMEMASTERS.check(player.permissions())); /** - * TODO: Remove when {@link ForgeRegistry#addAlias(ResourceLocation, ResourceLocation)} is elevated to {@link IForgeRegistry}. + * TODO: Remove when {@link ForgeRegistry#addAlias(Identifier, Identifier)} is elevated to {@link IForgeRegistry}. */ //@Deprecated(forRemoval = true, since = "1.20") - private static void addAlias(IForgeRegistry registry, ResourceLocation from, ResourceLocation to) { + private static void addAlias(IForgeRegistry registry, Identifier from, Identifier to) { ForgeRegistry fReg = (ForgeRegistry) registry; fReg.addAlias(from, to); } diff --git a/src/main/java/net/minecraftforge/common/TagConventionMappings.java b/src/main/java/net/minecraftforge/common/TagConventionMappings.java index 865df2b532..9266376fac 100644 --- a/src/main/java/net/minecraftforge/common/TagConventionMappings.java +++ b/src/main/java/net/minecraftforge/common/TagConventionMappings.java @@ -8,7 +8,7 @@ package net.minecraftforge.common; import net.minecraft.core.Registry; import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.tags.TagKey; import java.util.List; @@ -365,22 +365,22 @@ public final class TagConventionMappings { * Example: {@code legacyToCommon(Registries.BLOCK, forgeRl("cobblestone"), Tags.Blocks.COBBLESTONES)} for {@code forge:cobblestone} -> {@code c:cobblestones} *

    * @param registryKey Example: {@link net.minecraft.core.registries.Registries.BLOCK} - * @param legacyTagResourceLocation Example: {@code forgeRl("cobblestone")} + * @param legacyTagIdentifier Example: {@code forgeRl("cobblestone")} * @param replacementTag Example: {@link Tags.Blocks#COBBLESTONES} * @return A map entry with the legacy tag's TagKey and the suggested replacement tag ID. */ private static Map.Entry, String> legacyToCommon(ResourceKey> registryKey, - ResourceLocation legacyTagResourceLocation, + Identifier legacyTagIdentifier, TagKey replacementTag) { - return Map.entry(TagKey.create(registryKey, legacyTagResourceLocation), replacementTag.toString()); + return Map.entry(TagKey.create(registryKey, legacyTagIdentifier), replacementTag.toString()); } /** - * Same as {@link #legacyToCommon(ResourceKey, ResourceLocation, TagKey)} but for multiple replacement tags. + * Same as {@link #legacyToCommon(ResourceKey, Identifier, TagKey)} but for multiple replacement tags. * This is useful when a single legacy tag is intended to be replaced by combining multiple common convention tags. */ private static Map.Entry, String> legacyToCommon(ResourceKey> registryKey, - ResourceLocation legacyTagRessourceLocation, + Identifier legacyTagRessourceLocation, List> replacementTags) { return Map.entry( TagKey.create(registryKey, legacyTagRessourceLocation), @@ -388,7 +388,7 @@ public final class TagConventionMappings { ); } - private static ResourceLocation forgeRl(String path) { - return ResourceLocation.fromNamespaceAndPath("forge", path); + private static Identifier forgeRl(String path) { + return Identifier.fromNamespaceAndPath("forge", path); } } diff --git a/src/main/java/net/minecraftforge/common/TagConventionMigrationHelper.java b/src/main/java/net/minecraftforge/common/TagConventionMigrationHelper.java index f404396d25..616304cebc 100644 --- a/src/main/java/net/minecraftforge/common/TagConventionMigrationHelper.java +++ b/src/main/java/net/minecraftforge/common/TagConventionMigrationHelper.java @@ -7,7 +7,7 @@ package net.minecraftforge.common; import net.minecraft.core.HolderSet; import net.minecraft.core.RegistryAccess; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.tags.TagKey; import net.minecraftforge.event.server.ServerStartingEvent; import net.minecraftforge.fml.loading.FMLLoader; @@ -46,7 +46,7 @@ public final class TagConventionMigrationHelper { private static void run(RegistryAccess.Frozen registryAccess) { registryAccess.registries().forEach(registryEntry -> { - if (registryEntry.key().location().getNamespace().equals(ResourceLocation.DEFAULT_NAMESPACE)) { + if (registryEntry.key().identifier().getNamespace().equals(Identifier.DEFAULT_NAMESPACE)) { FOUND_LEGACY_TAGS.addAll( registryEntry.value().getTags() .map(HolderSet.Named::key) diff --git a/src/main/java/net/minecraftforge/common/Tags.java b/src/main/java/net/minecraftforge/common/Tags.java index e860cfdf25..6fc8d3e1cc 100644 --- a/src/main/java/net/minecraftforge/common/Tags.java +++ b/src/main/java/net/minecraftforge/common/Tags.java @@ -7,7 +7,7 @@ package net.minecraftforge.common; import net.minecraft.core.BlockPos; import net.minecraft.core.registries.Registries; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.tags.BlockTags; import net.minecraft.tags.FluidTags; import net.minecraft.tags.ItemTags; @@ -398,11 +398,11 @@ public class Tags { //endregion private static TagKey cTag(String name) { - return BlockTags.create(ResourceLocation.fromNamespaceAndPath("c", name)); + return BlockTags.create(Identifier.fromNamespaceAndPath("c", name)); } private static TagKey forgeTag(String name) { - return BlockTags.create(ResourceLocation.fromNamespaceAndPath("forge", name)); + return BlockTags.create(Identifier.fromNamespaceAndPath("forge", name)); } } @@ -432,7 +432,7 @@ public class Tags { //endregion private static TagKey> cTag(String name) { - return TagKey.create(Registries.ENTITY_TYPE, ResourceLocation.fromNamespaceAndPath("c", name)); + return TagKey.create(Registries.ENTITY_TYPE, Identifier.fromNamespaceAndPath("c", name)); } } @@ -1103,11 +1103,11 @@ public class Tags { //endregion private static TagKey cTag(String name) { - return ItemTags.create(ResourceLocation.fromNamespaceAndPath("c", name)); + return ItemTags.create(Identifier.fromNamespaceAndPath("c", name)); } private static TagKey forgeTag(String name) { - return ItemTags.create(ResourceLocation.fromNamespaceAndPath("forge", name)); + return ItemTags.create(Identifier.fromNamespaceAndPath("forge", name)); } } @@ -1179,11 +1179,11 @@ public class Tags { //endregion private static TagKey cTag(String name) { - return FluidTags.create(ResourceLocation.fromNamespaceAndPath("c", name)); + return FluidTags.create(Identifier.fromNamespaceAndPath("c", name)); } private static TagKey forgeTag(String name) { - return FluidTags.create(ResourceLocation.fromNamespaceAndPath("forge", name)); + return FluidTags.create(Identifier.fromNamespaceAndPath("forge", name)); } } @@ -1223,7 +1223,7 @@ public class Tags { //endregion private static TagKey cTag(String name) { - return TagKey.create(Registries.ENCHANTMENT, ResourceLocation.fromNamespaceAndPath("c", name)); + return TagKey.create(Registries.ENCHANTMENT, Identifier.fromNamespaceAndPath("c", name)); } } @@ -1497,11 +1497,11 @@ public class Tags { //endregion private static TagKey cTag(String name) { - return TagKey.create(Registries.BIOME, ResourceLocation.fromNamespaceAndPath("c", name)); + return TagKey.create(Registries.BIOME, Identifier.fromNamespaceAndPath("c", name)); } private static TagKey forgeTag(String name) { - return TagKey.create(Registries.BIOME, ResourceLocation.fromNamespaceAndPath("forge", name)); + return TagKey.create(Registries.BIOME, Identifier.fromNamespaceAndPath("forge", name)); } } @@ -1525,7 +1525,7 @@ public class Tags { //endregion private static TagKey cTag(String name) { - return TagKey.create(Registries.STRUCTURE, ResourceLocation.fromNamespaceAndPath("c", name)); + return TagKey.create(Registries.STRUCTURE, Identifier.fromNamespaceAndPath("c", name)); } } } diff --git a/src/main/java/net/minecraftforge/common/VillagerTradingManager.java b/src/main/java/net/minecraftforge/common/VillagerTradingManager.java index c0bb3dfb4f..d792efff18 100644 --- a/src/main/java/net/minecraftforge/common/VillagerTradingManager.java +++ b/src/main/java/net/minecraftforge/common/VillagerTradingManager.java @@ -14,9 +14,9 @@ import java.util.Map; import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import net.minecraft.resources.ResourceKey; -import net.minecraft.world.entity.npc.VillagerProfession; -import net.minecraft.world.entity.npc.VillagerTrades; -import net.minecraft.world.entity.npc.VillagerTrades.ItemListing; +import net.minecraft.world.entity.npc.villager.VillagerProfession; +import net.minecraft.world.entity.npc.villager.VillagerTrades; +import net.minecraft.world.entity.npc.villager.VillagerTrades.ItemListing; import net.minecraft.core.NonNullList; import net.minecraftforge.event.village.VillagerTradesEvent; import net.minecraftforge.event.village.WandererTradesEvent; diff --git a/src/main/java/net/minecraftforge/common/brewing/package-info.java b/src/main/java/net/minecraftforge/common/brewing/package-info.java index 6c2313bd43..9e3d98f4bd 100644 --- a/src/main/java/net/minecraftforge/common/brewing/package-info.java +++ b/src/main/java/net/minecraftforge/common/brewing/package-info.java @@ -3,10 +3,7 @@ * SPDX-License-Identifier: LGPL-2.1-only */ -@ParametersAreNonnullByDefault -@MethodsReturnNonnullByDefault +@NullMarked package net.minecraftforge.common.brewing; -import net.minecraft.MethodsReturnNonnullByDefault; - -import javax.annotation.ParametersAreNonnullByDefault; +import org.jspecify.annotations.NullMarked; diff --git a/src/main/java/net/minecraftforge/common/capabilities/CapabilityDispatcher.java b/src/main/java/net/minecraftforge/common/capabilities/CapabilityDispatcher.java index ba97b0b5a3..05f4f3bf8f 100644 --- a/src/main/java/net/minecraftforge/common/capabilities/CapabilityDispatcher.java +++ b/src/main/java/net/minecraftforge/common/capabilities/CapabilityDispatcher.java @@ -5,22 +5,20 @@ package net.minecraftforge.common.capabilities; -import javax.annotation.ParametersAreNonnullByDefault; - import java.util.ArrayList; import java.util.List; import java.util.Locale; import java.util.Map; -import net.minecraft.MethodsReturnNonnullByDefault; import net.minecraft.nbt.Tag; import net.minecraft.nbt.CompoundTag; import net.minecraft.core.Direction; import net.minecraft.core.HolderLookup; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraftforge.common.util.INBTSerializable; import net.minecraftforge.common.util.LazyOptional; import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.NullMarked; /** * A high-speed implementation of a capability delegator. @@ -30,10 +28,9 @@ import org.jetbrains.annotations.Nullable; * our handlers using normal if statements. * * Internally the handlers are baked into arrays for fast iteration. - * The ResourceLocations will be used for the NBT Key when serializing. + * The Identifiers will be used for the NBT Key when serializing. */ -@ParametersAreNonnullByDefault -@MethodsReturnNonnullByDefault +@NullMarked @SuppressWarnings("deprecation") public final class CapabilityDispatcher implements INBTSerializable, ICapabilityProvider { private final ICapabilityProvider[] caps; @@ -41,12 +38,12 @@ public final class CapabilityDispatcher implements INBTSerializable private final String[] names; private final List listeners; - public CapabilityDispatcher(Map list, List listeners) { + public CapabilityDispatcher(Map list, List listeners) { this(list, listeners, null); } @SuppressWarnings("unchecked") - public CapabilityDispatcher(Map list, List listeners, @Nullable ICapabilityProvider parent) { + public CapabilityDispatcher(Map list, List listeners, @Nullable ICapabilityProvider parent) { List lstCaps = new ArrayList<>(); List> lstWriters = new ArrayList<>(); List lstNames = new ArrayList<>(); diff --git a/src/main/java/net/minecraftforge/common/capabilities/CapabilityManager.java b/src/main/java/net/minecraftforge/common/capabilities/CapabilityManager.java index 7dce7f777e..1337d9d6d5 100644 --- a/src/main/java/net/minecraftforge/common/capabilities/CapabilityManager.java +++ b/src/main/java/net/minecraftforge/common/capabilities/CapabilityManager.java @@ -5,7 +5,7 @@ package net.minecraftforge.common.capabilities; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraftforge.fml.Logging; import net.minecraftforge.fml.ModList; import net.minecraftforge.fml.ModLoader; @@ -39,19 +39,19 @@ public final class CapabilityManager { * distinguish between them. It is generally not safe to return your generic implementation for the root type when this is requested. */ public static Capability get(CapabilityToken type, String modid, String name) { - return get(type, ResourceLocation.fromNamespaceAndPath(modid, name)); + return get(type, Identifier.fromNamespaceAndPath(modid, name)); } /** * Retrieves a named capability of the specified type. This is useful when providers supply multiple instances of the same interface and want to * distinguish between them. It is generally not safe to return your generic implementation for the root type when this is requested. */ - public static Capability get(CapabilityToken type, ResourceLocation name) { + public static Capability get(CapabilityToken type, Identifier name) { return get(type.getType(), name, false); } @SuppressWarnings("unchecked") - static Capability get(String type, ResourceLocation name, boolean registering) { + static Capability get(String type, Identifier name, boolean registering) { Capability cap; synchronized (providers) { @@ -84,7 +84,7 @@ public final class CapabilityManager { } private static final Type AUTO_REGISTER = Type.getType(AutoRegisterCapability.class); - private record Key(String type, ResourceLocation name) {}; + private record Key(String type, Identifier name) {}; private static final Map> providers = new HashMap<>(); @ApiStatus.Internal diff --git a/src/main/java/net/minecraftforge/common/capabilities/CapabilityProvider.java b/src/main/java/net/minecraftforge/common/capabilities/CapabilityProvider.java index 40c248e483..50a886bf2d 100644 --- a/src/main/java/net/minecraftforge/common/capabilities/CapabilityProvider.java +++ b/src/main/java/net/minecraftforge/common/capabilities/CapabilityProvider.java @@ -5,9 +5,6 @@ package net.minecraftforge.common.capabilities; -import javax.annotation.ParametersAreNonnullByDefault; - -import net.minecraft.MethodsReturnNonnullByDefault; import net.minecraft.nbt.CompoundTag; import net.minecraft.core.Direction; import net.minecraft.core.HolderLookup; @@ -22,11 +19,11 @@ import net.minecraftforge.event.ForgeEventFactory; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.VisibleForTesting; +import org.jspecify.annotations.NullMarked; import java.util.function.Supplier; -@MethodsReturnNonnullByDefault -@ParametersAreNonnullByDefault +@NullMarked public abstract class CapabilityProvider> implements ICapabilityProviderImpl { @VisibleForTesting static boolean SUPPORTS_LAZY_CAPABILITIES = true; diff --git a/src/main/java/net/minecraftforge/common/crafting/ConditionalAdvancement.java b/src/main/java/net/minecraftforge/common/crafting/ConditionalAdvancement.java index 525132c37b..fc3240f28c 100644 --- a/src/main/java/net/minecraftforge/common/crafting/ConditionalAdvancement.java +++ b/src/main/java/net/minecraftforge/common/crafting/ConditionalAdvancement.java @@ -15,7 +15,7 @@ import com.mojang.serialization.JsonOps; import net.minecraft.advancements.Advancement; import net.minecraft.advancements.AdvancementHolder; import net.minecraft.core.HolderLookup; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraftforge.common.ForgeHooks; import net.minecraftforge.common.crafting.conditions.ICondition; @@ -35,7 +35,7 @@ public class ConditionalAdvancement { } public static class Builder { - private static final ResourceLocation DOESNT_MATTER = ResourceLocation.fromNamespaceAndPath("doesnt", "matter"); + private static final Identifier DOESNT_MATTER = Identifier.fromNamespaceAndPath("doesnt", "matter"); private List advancements = new ArrayList<>(); private ICondition condition; diff --git a/src/main/java/net/minecraftforge/common/crafting/ConditionalRecipe.java b/src/main/java/net/minecraftforge/common/crafting/ConditionalRecipe.java index 1208d4213b..377126e601 100644 --- a/src/main/java/net/minecraftforge/common/crafting/ConditionalRecipe.java +++ b/src/main/java/net/minecraftforge/common/crafting/ConditionalRecipe.java @@ -43,7 +43,7 @@ import net.minecraft.world.level.Level; import net.minecraft.network.RegistryFriendlyByteBuf; import net.minecraft.network.codec.StreamCodec; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraftforge.common.crafting.conditions.ConditionCodec; import net.minecraftforge.common.crafting.conditions.ICondition; import net.minecraftforge.common.crafting.conditions.ICondition.IContext; @@ -82,7 +82,7 @@ public class ConditionalRecipe { } @Override - public void accept(ResourceKey> id, Recipe recipe, ResourceLocation advancementId, JsonElement advancement) { + public void accept(ResourceKey> id, Recipe recipe, Identifier advancementId, JsonElement advancement) { AdvancementHolder holder = null; if (advancement != null) { Advancement adv = Advancement.CODEC.parse(JsonOps.INSTANCE, advancement).getOrThrow(JsonParseException::new); @@ -106,7 +106,7 @@ public class ConditionalRecipe { private ICondition mainCondition; @Nullable - private ResourceLocation advancementId; + private Identifier advancementId; public Builder mainCondition(ICondition value) { if (this.mainCondition != null) @@ -137,16 +137,16 @@ public class ConditionalRecipe { return this; } - public Builder advancement(ResourceLocation id) { + public Builder advancement(Identifier id) { this.advancementId = id; return this; } public void save(RecipeOutput out, String namespace, String path) { - save(out, ResourceLocation.fromNamespaceAndPath(namespace, path)); + save(out, Identifier.fromNamespaceAndPath(namespace, path)); } - public void save(RecipeOutput out, ResourceLocation id) { + public void save(RecipeOutput out, Identifier id) { if (condition != null) throw new IllegalStateException("Invalid ConditionalRecipe builder, Orphaned conditions"); diff --git a/src/main/java/net/minecraftforge/common/crafting/conditions/ICondition.java b/src/main/java/net/minecraftforge/common/crafting/conditions/ICondition.java index cf94482c0e..640c961e34 100644 --- a/src/main/java/net/minecraftforge/common/crafting/conditions/ICondition.java +++ b/src/main/java/net/minecraftforge/common/crafting/conditions/ICondition.java @@ -11,7 +11,7 @@ import com.mojang.serialization.MapCodec; import net.minecraft.core.Holder; import net.minecraft.resources.DelegatingOps; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.tags.TagKey; import net.minecraftforge.registries.ForgeRegistries; @@ -35,7 +35,7 @@ public interface ICondition { interface IContext { /* Key used to attach this context option to a DynamicOps instance */ @ApiStatus.Internal - public static ResourceLocation KEY = ResourceLocation.fromNamespaceAndPath("forge", "condition_context"); + public static Identifier KEY = Identifier.fromNamespaceAndPath("forge", "condition_context"); default > O wrap(O ops) { return ops.withContext(KEY, this); diff --git a/src/main/java/net/minecraftforge/common/crafting/conditions/IConditionBuilder.java b/src/main/java/net/minecraftforge/common/crafting/conditions/IConditionBuilder.java index 680701bd02..f48a71cdd3 100644 --- a/src/main/java/net/minecraftforge/common/crafting/conditions/IConditionBuilder.java +++ b/src/main/java/net/minecraftforge/common/crafting/conditions/IConditionBuilder.java @@ -7,7 +7,7 @@ package net.minecraftforge.common.crafting.conditions; import java.util.List; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.tags.TagKey; import net.minecraft.world.item.Item; @@ -33,7 +33,7 @@ public interface IConditionBuilder { } default ICondition itemExists(String namespace, String path) { - return new ItemExistsCondition(ResourceLocation.fromNamespaceAndPath(namespace, path)); + return new ItemExistsCondition(Identifier.fromNamespaceAndPath(namespace, path)); } default ICondition modLoaded(String modid) { diff --git a/src/main/java/net/minecraftforge/common/crafting/conditions/ItemExistsCondition.java b/src/main/java/net/minecraftforge/common/crafting/conditions/ItemExistsCondition.java index 24db37e188..3d5263b727 100644 --- a/src/main/java/net/minecraftforge/common/crafting/conditions/ItemExistsCondition.java +++ b/src/main/java/net/minecraftforge/common/crafting/conditions/ItemExistsCondition.java @@ -15,13 +15,13 @@ import net.minecraft.core.HolderGetter; import net.minecraft.core.registries.Registries; import net.minecraft.resources.RegistryOps; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.world.item.Item; import net.minecraftforge.registries.ForgeRegistries; -public record ItemExistsCondition(ResourceLocation item) implements ICondition { +public record ItemExistsCondition(Identifier item) implements ICondition { public static final MapCodec CODEC = RecordCodecBuilder.mapCodec(b -> b.group( - ResourceLocation.CODEC.fieldOf("item").forGetter(ItemExistsCondition::item) + Identifier.CODEC.fieldOf("item").forGetter(ItemExistsCondition::item) ).apply(b, ItemExistsCondition::new)); @Override diff --git a/src/main/java/net/minecraftforge/common/crafting/conditions/TagEmptyCondition.java b/src/main/java/net/minecraftforge/common/crafting/conditions/TagEmptyCondition.java index 6f03708402..4c9bbca4a8 100644 --- a/src/main/java/net/minecraftforge/common/crafting/conditions/TagEmptyCondition.java +++ b/src/main/java/net/minecraftforge/common/crafting/conditions/TagEmptyCondition.java @@ -10,13 +10,13 @@ import com.mojang.serialization.MapCodec; import com.mojang.serialization.codecs.RecordCodecBuilder; import net.minecraft.core.registries.Registries; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.tags.TagKey; import net.minecraft.world.item.Item; public record TagEmptyCondition(TagKey tag) implements ICondition { public static final MapCodec CODEC = RecordCodecBuilder.mapCodec(b -> b.group( - ResourceLocation.CODEC.xmap(loc -> TagKey.create(Registries.ITEM, loc), TagKey::location).fieldOf("tag").forGetter(TagEmptyCondition::tag) + Identifier.CODEC.xmap(loc -> TagKey.create(Registries.ITEM, loc), TagKey::location).fieldOf("tag").forGetter(TagEmptyCondition::tag) ).apply(b, TagEmptyCondition::new)); diff --git a/src/main/java/net/minecraftforge/common/crafting/ingredients/PartialNBTIngredient.java b/src/main/java/net/minecraftforge/common/crafting/ingredients/PartialNBTIngredient.java index baad5397a5..05d8de8fc4 100644 --- a/src/main/java/net/minecraftforge/common/crafting/ingredients/PartialNBTIngredient.java +++ b/src/main/java/net/minecraftforge/common/crafting/ingredients/PartialNBTIngredient.java @@ -8,7 +8,7 @@ package net.minecraftforge.common.crafting.ingredients; import com.mojang.serialization.MapCodec; import com.mojang.serialization.codecs.RecordCodecBuilder; -import net.minecraft.advancements.critereon.NbtPredicate; +import net.minecraft.advancements.criterion.NbtPredicate; import net.minecraft.core.HolderSet; import net.minecraft.core.component.DataComponents; import net.minecraft.core.registries.Registries; diff --git a/src/main/java/net/minecraftforge/common/crafting/package-info.java b/src/main/java/net/minecraftforge/common/crafting/package-info.java index 8dad2d115b..23545fd24d 100644 --- a/src/main/java/net/minecraftforge/common/crafting/package-info.java +++ b/src/main/java/net/minecraftforge/common/crafting/package-info.java @@ -3,10 +3,7 @@ * SPDX-License-Identifier: LGPL-2.1-only */ -@ParametersAreNonnullByDefault -@MethodsReturnNonnullByDefault +@NullMarked package net.minecraftforge.common.crafting; -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/common/data/ExistingFileHelper.java b/src/main/java/net/minecraftforge/common/data/ExistingFileHelper.java index 716fb64748..0de6e1b90c 100644 --- a/src/main/java/net/minecraftforge/common/data/ExistingFileHelper.java +++ b/src/main/java/net/minecraftforge/common/data/ExistingFileHelper.java @@ -35,8 +35,7 @@ import net.minecraft.server.packs.PackResources; import net.minecraft.server.packs.PackType; import net.minecraft.server.packs.PathPackResources.PathResourcesSupplier; import net.minecraft.server.packs.VanillaPackResources; -import net.minecraft.resources.ResourceLocation; -import net.minecraftforge.client.model.generators.ModelBuilder; +import net.minecraft.resources.Identifier; import net.minecraftforge.data.event.GatherDataEvent; import net.minecraftforge.fml.ModList; import net.minecraftforge.forgespi.language.IModFileInfo; @@ -83,7 +82,7 @@ public class ExistingFileHelper { private final MultiPackResourceManager clientResources, serverData; private final boolean enable; - private final Multimap generated = HashMultimap.create(); + private final Multimap generated = HashMultimap.create(); /** * Create a new helper. This should probably NOT be used by mods, as @@ -145,7 +144,7 @@ public class ExistingFileHelper { return packType == PackType.CLIENT_RESOURCES ? clientResources : serverData; } - private ResourceLocation getLocation(ResourceLocation base, String suffix, String prefix) { + private Identifier getLocation(Identifier base, String suffix, String prefix) { return base.withPath(p -> prefix + '/' + p + suffix); } @@ -158,7 +157,7 @@ public class ExistingFileHelper { * @return {@code true} if the resource exists in any pack, {@code false} * otherwise */ - public boolean exists(ResourceLocation loc, PackType packType) { + public boolean exists(Identifier loc, PackType packType) { return generated.get(packType).contains(loc) || getManager(packType).getResource(loc).isPresent(); } @@ -175,7 +174,7 @@ public class ExistingFileHelper { * @return {@code true} if the resource exists in any pack, {@code false} * otherwise */ - public boolean exists(ResourceLocation loc, IResourceType type) { + public boolean exists(Identifier loc, IResourceType type) { return exists(getLocation(loc, type.getSuffix(), type.getPrefix()), type.getPackType()); } @@ -191,7 +190,7 @@ public class ExistingFileHelper { * @return {@code true} if the resource exists in any pack, {@code false} * otherwise */ - public boolean exists(ResourceLocation loc, PackType packType, String pathSuffix, String pathPrefix) { + public boolean exists(Identifier loc, PackType packType, String pathSuffix, String pathPrefix) { return exists(getLocation(loc, pathSuffix, pathPrefix), packType); } @@ -214,7 +213,7 @@ public class ExistingFileHelper { * @param type a {@link IResourceType} describing how to form the path to the * resource */ - public void trackGenerated(ResourceLocation loc, IResourceType type) { + public void trackGenerated(Identifier loc, IResourceType type) { this.generated.put(type.getPackType(), getLocation(loc, type.getSuffix(), type.getPrefix())); } @@ -237,22 +236,22 @@ public class ExistingFileHelper { * @param pathPrefix a string to append before the path, before a slash, e.g. * {@code "models"} */ - public void trackGenerated(ResourceLocation loc, PackType packType, String pathSuffix, String pathPrefix) { + public void trackGenerated(Identifier loc, PackType packType, String pathSuffix, String pathPrefix) { this.generated.put(packType, getLocation(loc, pathSuffix, pathPrefix)); } @VisibleForTesting - public Resource getResource(ResourceLocation loc, PackType packType, String pathSuffix, String pathPrefix) throws FileNotFoundException { + public Resource getResource(Identifier loc, PackType packType, String pathSuffix, String pathPrefix) throws FileNotFoundException { return getResource(getLocation(loc, pathSuffix, pathPrefix), packType); } @VisibleForTesting - public Resource getResource(ResourceLocation loc, PackType packType) throws FileNotFoundException { + public Resource getResource(Identifier loc, PackType packType) throws FileNotFoundException { return getManager(packType).getResourceOrThrow(loc); } @VisibleForTesting - public List getResourceStack(ResourceLocation loc, PackType packType) { + public List getResourceStack(Identifier loc, PackType packType) { return getManager(packType).getResourceStack(loc); } diff --git a/src/main/java/net/minecraftforge/common/data/ForgeAdvancementProvider.java b/src/main/java/net/minecraftforge/common/data/ForgeAdvancementProvider.java index ffa9601deb..aad4500b28 100644 --- a/src/main/java/net/minecraftforge/common/data/ForgeAdvancementProvider.java +++ b/src/main/java/net/minecraftforge/common/data/ForgeAdvancementProvider.java @@ -10,7 +10,7 @@ import net.minecraft.core.HolderLookup; import net.minecraft.data.PackOutput; import net.minecraft.data.advancements.AdvancementProvider; import net.minecraft.data.advancements.AdvancementSubProvider; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import java.util.List; import java.util.concurrent.CompletableFuture; @@ -44,7 +44,7 @@ public class ForgeAdvancementProvider extends AdvancementProvider { public interface AdvancementGenerator { /** * A method used to generate advancements for a mod. Advancements should be - * built via {@link net.minecraftforge.common.extensions.IForgeAdvancementBuilder#save(Consumer, ResourceLocation, ExistingFileHelper)}. + * built via {@link net.minecraftforge.common.extensions.IForgeAdvancementBuilder#save(Consumer, Identifier, ExistingFileHelper)}. * * @param registries a lookup for registries and their objects * @param saver a consumer used to write advancements to a file diff --git a/src/main/java/net/minecraftforge/common/data/ForgeBiomeTagsProvider.java b/src/main/java/net/minecraftforge/common/data/ForgeBiomeTagsProvider.java index 5d89ce33b7..84b23e29b4 100644 --- a/src/main/java/net/minecraftforge/common/data/ForgeBiomeTagsProvider.java +++ b/src/main/java/net/minecraftforge/common/data/ForgeBiomeTagsProvider.java @@ -9,7 +9,7 @@ import net.minecraft.core.HolderLookup; import net.minecraft.data.PackOutput; import net.minecraft.data.tags.BiomeTagsProvider; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.tags.BiomeTags; import net.minecraft.tags.TagKey; import net.minecraft.world.level.biome.Biome; @@ -316,7 +316,7 @@ public final class ForgeBiomeTagsProvider extends BiomeTagsProvider { } private static TagKey forgeTagKey(String path) { - return BiomeTags.create(ResourceLocation.fromNamespaceAndPath("forge", path)); + return BiomeTags.create(Identifier.fromNamespaceAndPath("forge", path)); } @Override diff --git a/src/main/java/net/minecraftforge/common/data/ForgeBlockItemTagsProvider.java b/src/main/java/net/minecraftforge/common/data/ForgeBlockItemTagsProvider.java index 29f1f976cf..29361d2233 100644 --- a/src/main/java/net/minecraftforge/common/data/ForgeBlockItemTagsProvider.java +++ b/src/main/java/net/minecraftforge/common/data/ForgeBlockItemTagsProvider.java @@ -10,7 +10,7 @@ import java.util.function.Consumer; import net.minecraft.data.tags.BlockItemTagsProvider; import net.minecraft.data.tags.TagAppender; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.tags.BlockTags; import net.minecraft.tags.ItemTags; import net.minecraft.tags.TagKey; @@ -658,17 +658,17 @@ public abstract class ForgeBlockItemTagsProvider extends BlockItemTagsProvider { } private static TagKey forgeTagKey(String path) { - return BlockTags.create(ResourceLocation.fromNamespaceAndPath("forge", path)); + return BlockTags.create(Identifier.fromNamespaceAndPath("forge", path)); } private static TagKey tagKey(String name) { - return BlockTags.create(ResourceLocation.withDefaultNamespace(name)); + return BlockTags.create(Identifier.withDefaultNamespace(name)); } private void addColored(Consumer consumer, TagKey group, String pattern) { String prefix = group.location().getPath().toUpperCase(Locale.ENGLISH) + '_'; for (DyeColor color : DyeColor.values()) { - ResourceLocation key = ResourceLocation.fromNamespaceAndPath("minecraft", pattern.replace("{color}", color.getName())); + Identifier key = Identifier.fromNamespaceAndPath("minecraft", pattern.replace("{color}", color.getName())); TagKey blockTag = getForgeTag(Tags.Blocks.class, prefix + color.getName()); TagKey itemTag = getForgeTag(Tags.Items.class, prefix + color.getName()); Block block = ForgeRegistries.BLOCKS.getValue(key); @@ -689,8 +689,8 @@ public abstract class ForgeBlockItemTagsProvider extends BlockItemTagsProvider { } } - private static ResourceLocation forgeRl(String path) { - return ResourceLocation.fromNamespaceAndPath("forge", path); + private static Identifier forgeRl(String path) { + return Identifier.fromNamespaceAndPath("forge", path); } private TagAppender tag(TagKey block, TagKey item, TagKey oldBlock, TagKey oldItem) { @@ -738,7 +738,7 @@ public abstract class ForgeBlockItemTagsProvider extends BlockItemTagsProvider { } @Override - public TagAppender remove(ResourceLocation value) { + public TagAppender remove(Identifier value) { tag.remove(value); old.remove(value); return this; diff --git a/src/main/java/net/minecraftforge/common/data/ForgeBlockTagsProvider.java b/src/main/java/net/minecraftforge/common/data/ForgeBlockTagsProvider.java index 05d8c5aa73..1fc605d5ed 100644 --- a/src/main/java/net/minecraftforge/common/data/ForgeBlockTagsProvider.java +++ b/src/main/java/net/minecraftforge/common/data/ForgeBlockTagsProvider.java @@ -9,7 +9,7 @@ import net.minecraft.core.HolderLookup; import net.minecraft.data.PackOutput; import net.minecraft.data.tags.TagAppender; import net.minecraft.data.tags.VanillaBlockTagsProvider; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.tags.BlockTags; import net.minecraft.tags.TagKey; import net.minecraft.world.item.DyeColor; @@ -72,7 +72,7 @@ public final class ForgeBlockTagsProvider extends VanillaBlockTagsProvider { private void addColored(TagKey group, String pattern) { String prefix = group.location().getPath().toUpperCase(Locale.ENGLISH) + '_'; for (var color : DyeColor.values()) { - var key = ResourceLocation.fromNamespaceAndPath("minecraft", pattern.replace("{color}", color.getName())); + var key = Identifier.fromNamespaceAndPath("minecraft", pattern.replace("{color}", color.getName())); TagKey tag = getForgeTag(prefix + color.getName()); var block = ForgeRegistries.BLOCKS.getValue(key); if (block == null || block == Blocks.AIR) @@ -100,7 +100,7 @@ public final class ForgeBlockTagsProvider extends VanillaBlockTagsProvider { } private static TagKey forgeTagKey(String path) { - return BlockTags.create(ResourceLocation.fromNamespaceAndPath("forge", path)); + return BlockTags.create(Identifier.fromNamespaceAndPath("forge", path)); } @Override diff --git a/src/main/java/net/minecraftforge/common/data/ForgeEntityTypeTagsProvider.java b/src/main/java/net/minecraftforge/common/data/ForgeEntityTypeTagsProvider.java index 8033795ddf..84fd9d5132 100644 --- a/src/main/java/net/minecraftforge/common/data/ForgeEntityTypeTagsProvider.java +++ b/src/main/java/net/minecraftforge/common/data/ForgeEntityTypeTagsProvider.java @@ -8,7 +8,7 @@ package net.minecraftforge.common.data; import net.minecraft.core.HolderLookup; import net.minecraft.data.PackOutput; import net.minecraft.data.tags.EntityTypeTagsProvider; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.tags.EntityTypeTags; import net.minecraft.tags.TagKey; import net.minecraft.world.entity.EntityType; @@ -67,7 +67,7 @@ public final class ForgeEntityTypeTagsProvider extends EntityTypeTagsProvider { } private static TagKey> forgeTagKey(String path) { - return EntityTypeTags.create(ResourceLocation.fromNamespaceAndPath("forge", path)); + return EntityTypeTags.create(Identifier.fromNamespaceAndPath("forge", path)); } @Override diff --git a/src/main/java/net/minecraftforge/common/data/ForgeFluidTagsProvider.java b/src/main/java/net/minecraftforge/common/data/ForgeFluidTagsProvider.java index 436435fce7..85ae5aebf3 100644 --- a/src/main/java/net/minecraftforge/common/data/ForgeFluidTagsProvider.java +++ b/src/main/java/net/minecraftforge/common/data/ForgeFluidTagsProvider.java @@ -8,7 +8,7 @@ package net.minecraftforge.common.data; import net.minecraft.core.HolderLookup; import net.minecraft.data.PackOutput; import net.minecraft.data.tags.FluidTagsProvider; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.tags.FluidTags; import net.minecraft.tags.TagKey; import net.minecraft.world.level.material.Fluid; @@ -29,8 +29,8 @@ public final class ForgeFluidTagsProvider extends FluidTagsProvider { tag(WATER).add(net.minecraft.world.level.material.Fluids.WATER).add(net.minecraft.world.level.material.Fluids.FLOWING_WATER); tag(LAVA).add(net.minecraft.world.level.material.Fluids.LAVA).add(net.minecraft.world.level.material.Fluids.FLOWING_LAVA); tag(MILK) - .addOptional(ForgeMod.MILK.getKey().location()) - .addOptional(ForgeMod.FLOWING_MILK.getKey().location()); + .addOptional(ForgeMod.MILK.getKey().identifier()) + .addOptional(ForgeMod.FLOWING_MILK.getKey().identifier()); tag(GASEOUS); tag(HONEY); tag(POTION); @@ -43,12 +43,12 @@ public final class ForgeFluidTagsProvider extends FluidTagsProvider { // Backwards compat definitions for pre-1.21 legacy `forge:` tags. // TODO: Remove backwards compat tag entries in 1.22 tag(forgeTagKey("milk")) - .addOptional(ForgeMod.MILK.getKey().location()) - .addOptional(ForgeMod.FLOWING_MILK.getKey().location()); + .addOptional(ForgeMod.MILK.getKey().identifier()) + .addOptional(ForgeMod.FLOWING_MILK.getKey().identifier()); } private static TagKey forgeTagKey(String path) { - return FluidTags.create(ResourceLocation.fromNamespaceAndPath("forge", path)); + return FluidTags.create(Identifier.fromNamespaceAndPath("forge", path)); } @Override diff --git a/src/main/java/net/minecraftforge/common/data/ForgeItemTagsProvider.java b/src/main/java/net/minecraftforge/common/data/ForgeItemTagsProvider.java index c7b44c1dca..d3b61c7d2a 100644 --- a/src/main/java/net/minecraftforge/common/data/ForgeItemTagsProvider.java +++ b/src/main/java/net/minecraftforge/common/data/ForgeItemTagsProvider.java @@ -10,7 +10,7 @@ import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.data.PackOutput; import net.minecraft.data.tags.TagAppender; import net.minecraft.data.tags.VanillaItemTagsProvider; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.tags.ItemTags; import net.minecraft.tags.TagKey; import net.minecraft.world.item.DyeColor; @@ -283,7 +283,23 @@ public final class ForgeItemTagsProvider extends VanillaItemTagsProvider { tag(Tags.Items.ARMORS) .addTags(ItemTags.HEAD_ARMOR, ItemTags.CHEST_ARMOR, ItemTags.LEG_ARMOR, ItemTags.FOOT_ARMOR) .addOptionalTag(forgeItemTagKey("armors")); - tag(Tags.Items.ENCHANTABLES).addTags(ItemTags.ARMOR_ENCHANTABLE, ItemTags.EQUIPPABLE_ENCHANTABLE, ItemTags.WEAPON_ENCHANTABLE, ItemTags.SWORD_ENCHANTABLE, ItemTags.MINING_ENCHANTABLE, ItemTags.MINING_LOOT_ENCHANTABLE, ItemTags.FISHING_ENCHANTABLE, ItemTags.TRIDENT_ENCHANTABLE, ItemTags.BOW_ENCHANTABLE, ItemTags.CROSSBOW_ENCHANTABLE, ItemTags.MACE_ENCHANTABLE, ItemTags.FIRE_ASPECT_ENCHANTABLE, ItemTags.DURABILITY_ENCHANTABLE, ItemTags.VANISHING_ENCHANTABLE); + tag(Tags.Items.ENCHANTABLES) + .addTags( + ItemTags.ARMOR_ENCHANTABLE, + ItemTags.EQUIPPABLE_ENCHANTABLE, + ItemTags.WEAPON_ENCHANTABLE, + ItemTags.SHARP_WEAPON_ENCHANTABLE, + ItemTags.MINING_ENCHANTABLE, + ItemTags.MINING_LOOT_ENCHANTABLE, + ItemTags.FISHING_ENCHANTABLE, + ItemTags.TRIDENT_ENCHANTABLE, + ItemTags.BOW_ENCHANTABLE, + ItemTags.CROSSBOW_ENCHANTABLE, + ItemTags.MACE_ENCHANTABLE, + ItemTags.FIRE_ASPECT_ENCHANTABLE, + ItemTags.DURABILITY_ENCHANTABLE, + ItemTags.VANISHING_ENCHANTABLE + ); tag(forgeItemTagKey("bones")).add(Items.BONE); // Backwards compat definitions for pre-1.21 legacy `forge:` tags. @@ -365,7 +381,7 @@ public final class ForgeItemTagsProvider extends VanillaItemTagsProvider { private void addColored(TagKey group, String pattern) { String prefix = group.location().getPath().toUpperCase(Locale.ENGLISH) + '_'; for (DyeColor color : DyeColor.values()) { - ResourceLocation key = ResourceLocation.fromNamespaceAndPath("minecraft", pattern.replace("{color}", color.getName())); + Identifier key = Identifier.fromNamespaceAndPath("minecraft", pattern.replace("{color}", color.getName())); TagKey tag = getForgeItemTag(prefix + color.getName()); Item item = BuiltInRegistries.ITEM.getValue(key); if (item == null || item == Items.AIR) @@ -377,7 +393,7 @@ public final class ForgeItemTagsProvider extends VanillaItemTagsProvider { private void addColored(Consumer> consumer, TagKey group, String pattern) { String prefix = group.location().getPath() + '/'; for (DyeColor color : DyeColor.values()) { - ResourceLocation key = ResourceLocation.fromNamespaceAndPath("minecraft", pattern.replace("{color}", color.getName())); + Identifier key = Identifier.fromNamespaceAndPath("minecraft", pattern.replace("{color}", color.getName())); TagKey tag = forgeItemTagKey(prefix + color.getName()); Item item = ForgeRegistries.ITEMS.getValue(key); if (item == null || item == Items.AIR) @@ -405,8 +421,8 @@ public final class ForgeItemTagsProvider extends VanillaItemTagsProvider { } } - private static ResourceLocation forgeRl(String path) { - return ResourceLocation.fromNamespaceAndPath("forge", path); + private static Identifier forgeRl(String path) { + return Identifier.fromNamespaceAndPath("forge", path); } private static TagKey forgeItemTagKey(String path) { diff --git a/src/main/java/net/minecraftforge/common/data/ForgeLootTableProvider.java b/src/main/java/net/minecraftforge/common/data/ForgeLootTableProvider.java index ec98b4b4d5..b0238a8b72 100644 --- a/src/main/java/net/minecraftforge/common/data/ForgeLootTableProvider.java +++ b/src/main/java/net/minecraftforge/common/data/ForgeLootTableProvider.java @@ -5,7 +5,7 @@ package net.minecraftforge.common.data; -import net.minecraft.advancements.critereon.ItemPredicate; +import net.minecraft.advancements.criterion.ItemPredicate; import net.minecraft.core.HolderLookup; import net.minecraft.core.Registry; import net.minecraft.data.PackOutput; @@ -67,9 +67,9 @@ public final class ForgeLootTableProvider extends LootTableProvider { } private LootTableSubProvider replaceAndFilterChangesOnly(LootTableSubProvider subProvider) { - return (newConsumer) -> subProvider.generate((resourceLocation, builder) -> { + return (newConsumer) -> subProvider.generate((Identifier, builder) -> { if (findAndReplaceInLootTableBuilder(builder, Items.SHEARS, ToolActions.SHEARS_DIG)) { - newConsumer.accept(resourceLocation, builder); + newConsumer.accept(Identifier, builder); } }); } diff --git a/src/main/java/net/minecraftforge/common/data/ForgeRecipeProvider.java b/src/main/java/net/minecraftforge/common/data/ForgeRecipeProvider.java index 701e24e53a..85c5903508 100644 --- a/src/main/java/net/minecraftforge/common/data/ForgeRecipeProvider.java +++ b/src/main/java/net/minecraftforge/common/data/ForgeRecipeProvider.java @@ -20,7 +20,7 @@ import net.minecraft.data.recipes.RecipeOutput; import net.minecraft.data.recipes.RecipeProvider; import net.minecraft.data.recipes.packs.VanillaRecipeProvider; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.tags.TagKey; import net.minecraft.world.item.Item; import net.minecraft.world.item.Items; @@ -67,7 +67,7 @@ public final class ForgeRecipeProvider extends VanillaRecipeProvider { } private void exclude(String name) { - excludes.add(ResourceKey.create(Registries.RECIPE, ResourceLocation.parse(name))); + excludes.add(ResourceKey.create(Registries.RECIPE, Identifier.parse(name))); } private void replace(ItemLike item, TagKey tag) { @@ -225,7 +225,7 @@ public final class ForgeRecipeProvider extends VanillaRecipeProvider { } @Override - public void accept(ResourceKey> id, Recipe recipe, ResourceLocation advancementId, JsonElement advancement) { + public void accept(ResourceKey> id, Recipe recipe, Identifier advancementId, JsonElement advancement) { var modified = self.enhance(id, recipe); if (modified != null) wrapped.accept(id, modified, null); diff --git a/src/main/java/net/minecraftforge/common/data/ForgeSpriteSourceProvider.java b/src/main/java/net/minecraftforge/common/data/ForgeSpriteSourceProvider.java index 192c7c4345..15a5fa84b1 100644 --- a/src/main/java/net/minecraftforge/common/data/ForgeSpriteSourceProvider.java +++ b/src/main/java/net/minecraftforge/common/data/ForgeSpriteSourceProvider.java @@ -7,7 +7,7 @@ package net.minecraftforge.common.data; import net.minecraft.client.renderer.texture.atlas.sources.SingleFile; import net.minecraft.data.PackOutput; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import java.util.Optional; @@ -21,6 +21,6 @@ public class ForgeSpriteSourceProvider extends SpriteSourceProvider @Override protected void addSources() { - atlas(SpriteSourceProvider.BLOCKS_ATLAS).addSource(new SingleFile(ResourceLocation.parse("forge:white"), Optional.empty())); + atlas(SpriteSourceProvider.BLOCKS_ATLAS).addSource(new SingleFile(Identifier.parse("forge:white"), Optional.empty())); } } diff --git a/src/main/java/net/minecraftforge/common/data/GlobalLootModifierProvider.java b/src/main/java/net/minecraftforge/common/data/GlobalLootModifierProvider.java index 1c58697efb..37e367c340 100644 --- a/src/main/java/net/minecraftforge/common/data/GlobalLootModifierProvider.java +++ b/src/main/java/net/minecraftforge/common/data/GlobalLootModifierProvider.java @@ -15,7 +15,7 @@ import net.minecraft.core.HolderLookup; import net.minecraft.data.CachedOutput; import net.minecraft.data.DataProvider; import net.minecraft.data.PackOutput; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraftforge.common.loot.IGlobalLootModifier; import net.minecraftforge.common.loot.LootModifier; @@ -68,7 +68,7 @@ public abstract class GlobalLootModifierProvider implements DataProvider { Path forgePath = this.output.getOutputFolder(PackOutput.Target.DATA_PACK).resolve("forge/loot_modifiers/global_loot_modifiers.json"); Path modifierFolderPath = this.output.getOutputFolder(PackOutput.Target.DATA_PACK).resolve(this.modid).resolve("loot_modifiers"); - List entries = new ArrayList<>(); + List entries = new ArrayList<>(); ImmutableList.Builder> futuresBuilder = new ImmutableList.Builder<>(); @@ -78,14 +78,14 @@ public abstract class GlobalLootModifierProvider implements DataProvider { toSerialize.forEach(LamdbaExceptionUtils.rethrowBiConsumer((name, instance) -> { var json = codec.encodeStart(ops, instance).getOrThrow(); - entries.add(ResourceLocation.fromNamespaceAndPath(modid, name)); + entries.add(Identifier.fromNamespaceAndPath(modid, name)); Path modifierPath = modifierFolderPath.resolve(name + ".json"); futuresBuilder.add(DataProvider.saveStable(cache, json, modifierPath)); })); JsonObject forgeJson = new JsonObject(); forgeJson.addProperty("replace", this.replace); - forgeJson.add("entries", GSON.toJsonTree(entries.stream().map(ResourceLocation::toString).collect(Collectors.toList()))); + forgeJson.add("entries", GSON.toJsonTree(entries.stream().map(Identifier::toString).collect(Collectors.toList()))); futuresBuilder.add(DataProvider.saveStable(cache, forgeJson, forgePath)); diff --git a/src/main/java/net/minecraftforge/common/data/JsonCodecProvider.java b/src/main/java/net/minecraftforge/common/data/JsonCodecProvider.java index bf108915d6..3ee39c34a7 100644 --- a/src/main/java/net/minecraftforge/common/data/JsonCodecProvider.java +++ b/src/main/java/net/minecraftforge/common/data/JsonCodecProvider.java @@ -21,7 +21,7 @@ import net.minecraft.data.CachedOutput; import net.minecraft.data.DataGenerator; import net.minecraft.data.DataProvider; import net.minecraft.data.PackOutput; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.packs.PackType; import net.minecraftforge.common.crafting.conditions.ICondition; import net.minecraftforge.common.data.ExistingFileHelper.ResourceType; @@ -46,8 +46,8 @@ public class JsonCodecProvider implements DataProvider protected final PackType packType; protected final String directory; protected final Codec codec; - protected final Map entries; - protected Map conditions = Collections.emptyMap(); + protected final Map entries; + protected Map conditions = Collections.emptyMap(); /** * @param output {@linkplain PackOutput} provided by the {@link DataGenerator}. @@ -55,14 +55,14 @@ public class JsonCodecProvider implements DataProvider * @param packType PackType specifying whether to generate entries in assets or data. * @param directory String representing the directory to generate jsons in, e.g. "dimension" or "cheesemod/cheese". * @param codec Codec to encode values to jsons with using the provided DynamicOps. - * @param entries Map of named entries to serialize to jsons. Paths for values are derived from the ResourceLocation's entryid:entrypath as specified above. + * @param entries Map of named entries to serialize to jsons. Paths for values are derived from the Identifier's entryid:entrypath as specified above. */ public JsonCodecProvider(PackOutput output, ExistingFileHelper existingFileHelper, String modid, DynamicOps dynamicOps, PackType packType, - String directory, Codec codec, Map entries) + String directory, Codec codec, Map entries) { // Track generated data so other dataproviders can validate if needed. final ResourceType resourceType = new ResourceType(packType, ".json", directory); - for (ResourceLocation id : entries.keySet()) + for (Identifier id : entries.keySet()) { existingFileHelper.trackGenerated(id, resourceType); } @@ -108,7 +108,7 @@ public class JsonCodecProvider implements DataProvider return CompletableFuture.allOf(futuresBuilder.build().toArray(CompletableFuture[]::new)); } - protected void gather(BiConsumer consumer) + protected void gather(BiConsumer consumer) { this.entries.forEach(consumer); } @@ -125,7 +125,7 @@ public class JsonCodecProvider implements DataProvider * Null or empty arrays will not be written, and if the top-level json type is not JsonObject, attempting to add conditions will error. * @param conditions The name->condition map to apply. */ - public JsonCodecProvider setConditions(Map conditions) + public JsonCodecProvider setConditions(Map conditions) { this.conditions = conditions; return this; diff --git a/src/main/java/net/minecraftforge/common/data/ParticleDescriptionProvider.java b/src/main/java/net/minecraftforge/common/data/ParticleDescriptionProvider.java index 05dd6756df..c5b3ade544 100644 --- a/src/main/java/net/minecraftforge/common/data/ParticleDescriptionProvider.java +++ b/src/main/java/net/minecraftforge/common/data/ParticleDescriptionProvider.java @@ -8,14 +8,14 @@ package net.minecraftforge.common.data; import com.google.common.base.Preconditions; import com.google.gson.JsonArray; import com.google.gson.JsonObject; -import net.minecraft.Util; +import net.minecraft.util.Util; import net.minecraft.client.particle.ParticleEngine; import net.minecraft.client.particle.ParticleProvider; import net.minecraft.core.particles.ParticleType; import net.minecraft.data.CachedOutput; import net.minecraft.data.DataProvider; import net.minecraft.data.PackOutput; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.packs.PackType; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.registries.ForgeRegistries; @@ -37,17 +37,17 @@ import java.util.stream.Stream; * Then, register an instance using {@link net.minecraft.data.DataGenerator#addProvider(boolean, Factory)} * via the {@link net.minecraftforge.data.event.GatherDataEvent} on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod event bus}. * - *

    A description can be added to a {@link ParticleType} which uses a {@linkplain #sprite(ParticleType, ResourceLocation) sprite} + *

    A description can be added to a {@link ParticleType} which uses a {@linkplain #sprite(ParticleType, Identifier) sprite} * or {@linkplain #spriteSet(ParticleType, Iterable) sprite set}. * *

    {@code
      * @Override
      * protected void addDescriptions() {
      *     // Single sprite
    - *     this.sprite(ParticleTypes.DRIPPING_LAVA, new ResourceLocation("drip_hang"));
    + *     this.sprite(ParticleTypes.DRIPPING_LAVA, new Identifier("drip_hang"));
      *
      *     // Multiple sprites
    - *     this.spriteSet(ParticleTypes.CLOUD, new ResourceLocation("generic"), 8, true);
    + *     this.spriteSet(ParticleTypes.CLOUD, new Identifier("generic"), 8, true);
      * }
      * }
    * @@ -72,7 +72,7 @@ public abstract class ParticleDescriptionProvider implements DataProvider { @VisibleForTesting protected final ExistingFileHelper fileHelper; @VisibleForTesting - protected final Map> descriptions; + protected final Map> descriptions; /** * Creates an instance of the data provider. @@ -87,7 +87,7 @@ public abstract class ParticleDescriptionProvider implements DataProvider { } /** - * Registers the particle descriptions generated by {@link #sprite(ParticleType, ResourceLocation)} + * Registers the particle descriptions generated by {@link #sprite(ParticleType, Identifier)} * or one of the {@link #spriteSet(ParticleType, Iterable) sprite set methods}. */ protected abstract void addDescriptions(); @@ -107,7 +107,7 @@ public abstract class ParticleDescriptionProvider implements DataProvider { * file, or the particle type has already been * provided */ - protected void sprite(ParticleType type, ResourceLocation texture) { + protected void sprite(ParticleType type, Identifier texture) { this.spriteSet(type, texture); } @@ -137,7 +137,7 @@ public abstract class ParticleDescriptionProvider implements DataProvider { * file, or the particle type has already been * provided */ - protected void spriteSet(ParticleType type, ResourceLocation baseName, int numOfTextures, boolean reverse) { + protected void spriteSet(ParticleType type, Identifier baseName, int numOfTextures, boolean reverse) { Preconditions.checkArgument(numOfTextures > 0, "The number of textures to generate must be positive"); this.spriteSet(type, () -> new Iterator<>() { @@ -149,7 +149,7 @@ public abstract class ParticleDescriptionProvider implements DataProvider { } @Override - public ResourceLocation next() { + public Identifier next() { var texture = baseName.withSuffix("_" + (reverse ? numOfTextures - this.counter - 1 : this.counter)); this.counter++; return texture; @@ -175,7 +175,7 @@ public abstract class ParticleDescriptionProvider implements DataProvider { * file, or the particle type has already been * provided */ - protected void spriteSet(ParticleType type, ResourceLocation texture, ResourceLocation... textures) { + protected void spriteSet(ParticleType type, Identifier texture, Identifier... textures) { this.spriteSet(type, Stream.concat(Stream.of(texture), Arrays.stream(textures))::iterator); } @@ -195,7 +195,7 @@ public abstract class ParticleDescriptionProvider implements DataProvider { * does not have an associated PNG file, or * the particle type has already been provided */ - protected void spriteSet(ParticleType type, Iterable textures) { + protected void spriteSet(ParticleType type, Iterable textures) { // Make sure particle type is registered var particle = Preconditions.checkNotNull(ForgeRegistries.PARTICLE_TYPES.getKey(type), "The particle type is not registered"); diff --git a/src/main/java/net/minecraftforge/common/data/SoundDefinition.java b/src/main/java/net/minecraftforge/common/data/SoundDefinition.java index 3576af8414..4e6c4bb369 100644 --- a/src/main/java/net/minecraftforge/common/data/SoundDefinition.java +++ b/src/main/java/net/minecraftforge/common/data/SoundDefinition.java @@ -9,7 +9,7 @@ import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonPrimitive; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import org.jetbrains.annotations.Nullable; import java.util.ArrayList; @@ -48,7 +48,7 @@ public final class SoundDefinition private static final int DEFAULT_ATTENUATION_DISTANCE = 16; private static final boolean DEFAULT_PRELOAD = false; - private final ResourceLocation name; + private final Identifier name; private final SoundType type; // Optional parameters, available in specs @@ -59,7 +59,7 @@ public final class SoundDefinition private int attenuationDistance = DEFAULT_ATTENUATION_DISTANCE; private boolean preload = DEFAULT_PRELOAD; - private Sound(final ResourceLocation name, final SoundType type) + private Sound(final Identifier name, final SoundType type) { this.name = name; this.type = type; @@ -71,7 +71,7 @@ public final class SoundDefinition * @param name The name of the sound to create. * @param type The type of sound to create. */ - public static Sound sound(final ResourceLocation name, final SoundType type) + public static Sound sound(final Identifier name, final SoundType type) { return new Sound(name, type); } @@ -242,7 +242,7 @@ public final class SoundDefinition return this; } - ResourceLocation name() + Identifier name() { return this.name; } @@ -282,7 +282,7 @@ public final class SoundDefinition this.preload == DEFAULT_PRELOAD; } - private String stripMcPrefix(final ResourceLocation name) + private String stripMcPrefix(final Identifier name) { return "minecraft".equals(name.getNamespace()) ? name.getPath() : name.toString(); } diff --git a/src/main/java/net/minecraftforge/common/data/SoundDefinitionsProvider.java b/src/main/java/net/minecraftforge/common/data/SoundDefinitionsProvider.java index c9b0efb4d1..41d1f188d3 100644 --- a/src/main/java/net/minecraftforge/common/data/SoundDefinitionsProvider.java +++ b/src/main/java/net/minecraftforge/common/data/SoundDefinitionsProvider.java @@ -15,7 +15,7 @@ import java.util.function.Supplier; import net.minecraft.data.CachedOutput; import net.minecraft.data.DataProvider; import net.minecraft.data.PackOutput; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.packs.PackType; import net.minecraft.sounds.SoundEvent; import net.minecraftforge.registries.ForgeRegistries; @@ -84,7 +84,7 @@ public abstract class SoundDefinitionsProvider implements DataProvider { * @param name The name of the sound to create. * @param type The type of sound to create. */ - protected static SoundDefinition.Sound sound(final ResourceLocation name, final SoundDefinition.SoundType type) { + protected static SoundDefinition.Sound sound(final Identifier name, final SoundDefinition.SoundType type) { return SoundDefinition.Sound.sound(name, type); } @@ -94,7 +94,7 @@ public abstract class SoundDefinitionsProvider implements DataProvider { * * @param name The name of the sound to create. */ - protected static SoundDefinition.Sound sound(final ResourceLocation name) { + protected static SoundDefinition.Sound sound(final Identifier name) { return sound(name, SoundDefinition.SoundType.SOUND); } @@ -105,7 +105,7 @@ public abstract class SoundDefinitionsProvider implements DataProvider { * @param type The type of sound to create. */ protected static SoundDefinition.Sound sound(final String name, final SoundDefinition.SoundType type) { - return sound(ResourceLocation.parse(name), type); + return sound(Identifier.parse(name), type); } /** @@ -115,7 +115,7 @@ public abstract class SoundDefinitionsProvider implements DataProvider { * @param name The name of the sound to create. */ protected static SoundDefinition.Sound sound(final String name) { - return sound(ResourceLocation.parse(name)); + return sound(Identifier.parse(name)); } // Addition methods @@ -149,13 +149,13 @@ public abstract class SoundDefinitionsProvider implements DataProvider { } /** - * Adds the {@link SoundEvent} referenced by the given {@link ResourceLocation} with the + * Adds the {@link SoundEvent} referenced by the given {@link Identifier} with the * {@link SoundDefinition} to the list. * - * @param soundEvent The {@link ResourceLocation} that identifies the event. + * @param soundEvent The {@link Identifier} that identifies the event. * @param definition The {@link SoundDefinition} that defines the given event. */ - protected void add(final ResourceLocation soundEvent, final SoundDefinition definition) { + protected void add(final Identifier soundEvent, final SoundDefinition definition) { this.addSounds(soundEvent.getPath(), definition); } @@ -172,7 +172,7 @@ public abstract class SoundDefinitionsProvider implements DataProvider { * @param definition The {@link SoundDefinition} that defines the given event. */ protected void add(final String soundEvent, final SoundDefinition definition) { - this.add(ResourceLocation.parse(soundEvent), definition); + this.add(Identifier.parse(soundEvent), definition); } private void addSounds(final String soundEvent, final SoundDefinition definition) { @@ -207,7 +207,7 @@ public abstract class SoundDefinitionsProvider implements DataProvider { throw new IllegalArgumentException("The given sound '" + sound.name() + "' does not have a valid type: expected either SOUND or EVENT, but found " + sound.type()); } - private boolean validateSound(final String soundName, final ResourceLocation name) { + private boolean validateSound(final String soundName, final Identifier name) { final boolean valid = this.helper.exists(name, PackType.CLIENT_RESOURCES, ".ogg", "sounds"); if (!valid) { final String path = name.getNamespace() + ":sounds/" + name.getPath() + ".ogg"; @@ -216,7 +216,7 @@ public abstract class SoundDefinitionsProvider implements DataProvider { return valid; } - private boolean validateEvent(final String soundName, final ResourceLocation name) { + private boolean validateEvent(final String soundName, final Identifier name) { final boolean valid = this.sounds.containsKey(soundName) || ForgeRegistries.SOUND_EVENTS.containsKey(name); if (!valid) LOGGER.warn("Unable to find event '{}' referenced from '{}'", name, soundName); diff --git a/src/main/java/net/minecraftforge/common/data/SpriteSourceProvider.java b/src/main/java/net/minecraftforge/common/data/SpriteSourceProvider.java index 37843949f3..9d3cbc21e5 100644 --- a/src/main/java/net/minecraftforge/common/data/SpriteSourceProvider.java +++ b/src/main/java/net/minecraftforge/common/data/SpriteSourceProvider.java @@ -9,7 +9,7 @@ import com.mojang.serialization.JsonOps; import net.minecraft.client.renderer.texture.atlas.SpriteSource; import net.minecraft.client.renderer.texture.atlas.SpriteSources; import net.minecraft.data.PackOutput; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.packs.PackType; import java.util.ArrayList; @@ -27,18 +27,18 @@ import java.util.function.BiConsumer; */ public abstract class SpriteSourceProvider extends JsonCodecProvider> { - protected static final ResourceLocation BLOCKS_ATLAS = ResourceLocation.withDefaultNamespace("blocks"); - protected static final ResourceLocation BANNER_PATTERNS_ATLAS = ResourceLocation.withDefaultNamespace("banner_patterns"); - protected static final ResourceLocation BEDS_ATLAS = ResourceLocation.withDefaultNamespace("beds"); - protected static final ResourceLocation CHESTS_ATLAS = ResourceLocation.withDefaultNamespace("chests"); - protected static final ResourceLocation SHIELD_PATTERNS_ATLAS = ResourceLocation.withDefaultNamespace("shield_patterns"); - protected static final ResourceLocation SHULKER_BOXES_ATLAS = ResourceLocation.withDefaultNamespace("shulker_boxes"); - protected static final ResourceLocation SIGNS_ATLAS = ResourceLocation.withDefaultNamespace("signs"); - protected static final ResourceLocation MOB_EFFECTS_ATLAS = ResourceLocation.withDefaultNamespace("mob_effects"); - protected static final ResourceLocation PAINTINGS_ATLAS = ResourceLocation.withDefaultNamespace("paintings"); - protected static final ResourceLocation PARTICLES_ATLAS = ResourceLocation.withDefaultNamespace("particles"); + protected static final Identifier BLOCKS_ATLAS = Identifier.withDefaultNamespace("blocks"); + protected static final Identifier BANNER_PATTERNS_ATLAS = Identifier.withDefaultNamespace("banner_patterns"); + protected static final Identifier BEDS_ATLAS = Identifier.withDefaultNamespace("beds"); + protected static final Identifier CHESTS_ATLAS = Identifier.withDefaultNamespace("chests"); + protected static final Identifier SHIELD_PATTERNS_ATLAS = Identifier.withDefaultNamespace("shield_patterns"); + protected static final Identifier SHULKER_BOXES_ATLAS = Identifier.withDefaultNamespace("shulker_boxes"); + protected static final Identifier SIGNS_ATLAS = Identifier.withDefaultNamespace("signs"); + protected static final Identifier MOB_EFFECTS_ATLAS = Identifier.withDefaultNamespace("mob_effects"); + protected static final Identifier PAINTINGS_ATLAS = Identifier.withDefaultNamespace("paintings"); + protected static final Identifier PARTICLES_ATLAS = Identifier.withDefaultNamespace("particles"); - private final Map atlases = new HashMap<>(); + private final Map atlases = new HashMap<>(); public SpriteSourceProvider(PackOutput output, ExistingFileHelper fileHelper, String modid) { @@ -46,11 +46,11 @@ public abstract class SpriteSourceProvider extends JsonCodecProvider> consumer) + protected final void gather(BiConsumer> consumer) { addSources(); for (var entry : atlases.entrySet()) { - ResourceLocation atlas = entry.getKey(); + Identifier atlas = entry.getKey(); SourceList srcList = entry.getValue(); consumer.accept(atlas, srcList.sources); } @@ -64,7 +64,7 @@ public abstract class SpriteSourceProvider extends JsonCodecProvider new SourceList()); } diff --git a/src/main/java/net/minecraftforge/common/data/package-info.java b/src/main/java/net/minecraftforge/common/data/package-info.java index a9a3a47e30..58e43ace8b 100644 --- a/src/main/java/net/minecraftforge/common/data/package-info.java +++ b/src/main/java/net/minecraftforge/common/data/package-info.java @@ -3,9 +3,7 @@ * SPDX-License-Identifier: LGPL-2.1-only */ -@ParametersAreNonnullByDefault -@MethodsReturnNonnullByDefault +@NullMarked package net.minecraftforge.common.data; -import net.minecraft.MethodsReturnNonnullByDefault; -import javax.annotation.ParametersAreNonnullByDefault; +import org.jspecify.annotations.NullMarked; diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeAbstractBoat.java b/src/main/java/net/minecraftforge/common/extensions/IForgeAbstractBoat.java index 0e56d31e77..d1a7c80c37 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeAbstractBoat.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeAbstractBoat.java @@ -6,8 +6,8 @@ package net.minecraftforge.common.extensions; import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.vehicle.AbstractBoat; -import net.minecraft.world.entity.vehicle.Boat; +import net.minecraft.world.entity.vehicle.boat.AbstractBoat; +import net.minecraft.world.entity.vehicle.boat.Boat; import net.minecraft.world.level.material.FluidState; import net.minecraftforge.fluids.FluidType; diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeAbstractMinecart.java b/src/main/java/net/minecraftforge/common/extensions/IForgeAbstractMinecart.java index d5788eb9e3..9705384ea1 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeAbstractMinecart.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeAbstractMinecart.java @@ -5,7 +5,7 @@ package net.minecraftforge.common.extensions; -import net.minecraft.world.entity.vehicle.AbstractMinecart; +import net.minecraft.world.entity.vehicle.minecart.AbstractMinecart; import net.minecraft.tags.BlockTags; import net.minecraft.core.BlockPos; import net.minecraft.util.Mth; diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeBaseRailBlock.java b/src/main/java/net/minecraftforge/common/extensions/IForgeBaseRailBlock.java index 2aeab53b58..3c129ceede 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeBaseRailBlock.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeBaseRailBlock.java @@ -5,18 +5,16 @@ package net.minecraftforge.common.extensions; -import net.minecraft.world.entity.vehicle.MinecartFurnace; import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.entity.vehicle.AbstractMinecart; import net.minecraft.world.level.block.state.properties.RailShape; import net.minecraft.core.BlockPos; +import net.minecraft.world.entity.vehicle.minecart.AbstractMinecart; +import net.minecraft.world.entity.vehicle.minecart.MinecartFurnace; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; import org.jetbrains.annotations.Nullable; -public interface IForgeBaseRailBlock -{ - +public interface IForgeBaseRailBlock { /** * Return true if the rail can make corners. * Used by placement logic. @@ -33,8 +31,7 @@ public interface IForgeBaseRailBlock * @param pos Block's position in level * @return True if the rail can make slopes. */ - default boolean canMakeSlopes(BlockState state, BlockGetter level, BlockPos pos) - { + default boolean canMakeSlopes(BlockState state, BlockGetter level, BlockPos pos) { return true; } @@ -59,8 +56,7 @@ public interface IForgeBaseRailBlock * @param pos Block's position in level * @return The max speed of the current rail. */ - default float getRailMaxSpeed(BlockState state, Level level, BlockPos pos, AbstractMinecart cart) - { + default float getRailMaxSpeed(BlockState state, Level level, BlockPos pos, AbstractMinecart cart) { if (cart instanceof MinecartFurnace) return cart.isInWater() ? 0.15f : 0.2f; else return cart.isInWater() ? 0.2f : 0.4f; } @@ -82,8 +78,7 @@ public interface IForgeBaseRailBlock * @param shape The new RailShape * @return True when the given RailShape is valid */ - default boolean isValidRailShape(RailShape shape) - { + default boolean isValidRailShape(RailShape shape) { return true; } } diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeBlock.java b/src/main/java/net/minecraftforge/common/extensions/IForgeBlock.java index c661e9f6ad..f4a1159e12 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeBlock.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeBlock.java @@ -10,6 +10,7 @@ import java.util.function.BiConsumer; import net.minecraft.client.Camera; import net.minecraft.util.RandomSource; +import net.minecraft.world.attribute.EnvironmentAttributes; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.SpawnPlacementType; @@ -20,7 +21,7 @@ import net.minecraft.world.entity.boss.wither.WitherBoss; import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.projectile.FishingHook; -import net.minecraft.world.entity.projectile.WitherSkull; +import net.minecraft.world.entity.projectile.hurtingprojectile.WitherSkull; import net.minecraft.world.item.*; import net.minecraft.world.item.context.UseOnContext; import net.minecraft.world.level.SignalGetter; @@ -213,7 +214,7 @@ public interface IForgeBlock { * @return The spawn position or the empty optional if respawning here is not possible */ default Optional getRespawnPosition(BlockState state, EntityType type, LevelReader levelReader, BlockPos pos, float orientation, @Nullable LivingEntity entity) { - if (isBed(state, levelReader, pos, entity) && levelReader instanceof Level level && BedBlock.canSetSpawn(level)) { + if (isBed(state, levelReader, pos, entity) && levelReader instanceof Level level && level.environmentAttributes().getValue(EnvironmentAttributes.BED_RULE, pos).canSetSpawn(level)) { return BedBlock.findStandUpPosition(type, levelReader, pos, state.getValue(BedBlock.FACING), orientation); } return Optional.empty(); diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeCommandSourceStack.java b/src/main/java/net/minecraftforge/common/extensions/IForgeCommandSourceStack.java index f249d53759..37ce84f0f7 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeCommandSourceStack.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeCommandSourceStack.java @@ -7,7 +7,7 @@ package net.minecraftforge.common.extensions; import net.minecraft.advancements.AdvancementHolder; import net.minecraft.commands.CommandSourceStack; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.world.item.crafting.RecipeManager; import net.minecraft.world.level.Level; import net.minecraft.world.scores.Scoreboard; @@ -30,7 +30,7 @@ public interface IForgeCommandSourceStack { /** * @return the advancement from the id */ - default AdvancementHolder getAdvancement(ResourceLocation id) { + default AdvancementHolder getAdvancement(Identifier id) { return self().getServer().getAdvancements().get(id); } diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeEntity.java b/src/main/java/net/minecraftforge/common/extensions/IForgeEntity.java index 4ae6f0ebcc..d7d4976ef7 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeEntity.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeEntity.java @@ -12,7 +12,7 @@ import net.minecraft.sounds.SoundEvent; import net.minecraft.util.ProblemReporter; import net.minecraft.world.entity.boss.enderdragon.EnderDragon; import net.minecraft.world.entity.player.Player; -import net.minecraft.world.entity.vehicle.AbstractBoat; +import net.minecraft.world.entity.vehicle.boat.AbstractBoat; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.entity.Entity; diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeFluid.java b/src/main/java/net/minecraftforge/common/extensions/IForgeFluid.java index 781df3a2e3..6825d1aa00 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeFluid.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeFluid.java @@ -10,7 +10,7 @@ import net.minecraft.server.level.ServerLevel; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.Mob; -import net.minecraft.world.entity.vehicle.AbstractBoat; +import net.minecraft.world.entity.vehicle.boat.AbstractBoat; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Explosion; import net.minecraft.world.level.block.state.BlockState; diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeFluidState.java b/src/main/java/net/minecraftforge/common/extensions/IForgeFluidState.java index 6598218ac9..ab853ddf22 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeFluidState.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeFluidState.java @@ -10,8 +10,8 @@ import net.minecraft.server.level.ServerLevel; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.Mob; -import net.minecraft.world.entity.vehicle.AbstractBoat; -import net.minecraft.world.entity.vehicle.Boat; +import net.minecraft.world.entity.vehicle.boat.AbstractBoat; +import net.minecraft.world.entity.vehicle.boat.Boat; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Explosion; import net.minecraft.world.level.block.state.BlockState; diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeGameTestHelper.java b/src/main/java/net/minecraftforge/common/extensions/IForgeGameTestHelper.java index 37d18e56cf..05227969b7 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeGameTestHelper.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeGameTestHelper.java @@ -15,7 +15,7 @@ import java.util.function.Supplier; import net.minecraft.core.Registry; import net.minecraft.resources.ResourceKey; import net.minecraft.ChatFormatting; -import net.minecraft.Util; +import net.minecraft.util.Util; import net.minecraft.network.chat.MutableComponent; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeItem.java b/src/main/java/net/minecraftforge/common/extensions/IForgeItem.java index 52d66d05ac..2f3cadae81 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeItem.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeItem.java @@ -294,7 +294,7 @@ public interface IForgeItem { */ /* @Nullable - default ResourceLocation getArmorTexture(ItemStack stack, Entity entity, EquipmentSlot slot, EquipmentModel.Layer layer, boolean inner) { + default Identifier getArmorTexture(ItemStack stack, Entity entity, EquipmentSlot slot, EquipmentModel.Layer layer, boolean inner) { return null; } */ diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgePackResources.java b/src/main/java/net/minecraftforge/common/extensions/IForgePackResources.java index c98044daf2..76b11c19f7 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgePackResources.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgePackResources.java @@ -23,7 +23,7 @@ public interface IForgePackResources { * Gets a collection of {@code PackResource} instances nested inside this pack. * Used to merge several packs into one entry in the resource pack selection UI without * losing the ability for each pack to return a resource in - * {@link ResourceManager#getResourceStack(ResourceLocation)} + * {@link ResourceManager#getResourceStack(Identifier)} * @return Collection of nested {@code PackResource}, or null if this pack has no children * @see DelegatingPackResources */ diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeRawTagBuilder.java b/src/main/java/net/minecraftforge/common/extensions/IForgeRawTagBuilder.java index 7217831371..8fd641d365 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeRawTagBuilder.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeRawTagBuilder.java @@ -5,7 +5,7 @@ package net.minecraftforge.common.extensions; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.tags.TagBuilder; import net.minecraft.tags.TagEntry; @@ -30,7 +30,7 @@ public interface IForgeRawTagBuilder { * @param source The source of the caller for logging purposes (generally a modid) * @return The builder for chaining purposes */ - default TagBuilder removeElement(final ResourceLocation elementID, final String source) { + default TagBuilder removeElement(final Identifier elementID, final String source) { return this.remove(TagEntry.element(elementID), source); } @@ -40,7 +40,7 @@ public interface IForgeRawTagBuilder { * @param source The source of the caller for logging purposes (generally a modid) * @return The builder for chaining purposes */ - default TagBuilder removeTag(final ResourceLocation tagID, final String source) { + default TagBuilder removeTag(final Identifier tagID, final String source) { return this.remove(TagEntry.tag(tagID), source); } diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeTagAppender.java b/src/main/java/net/minecraftforge/common/extensions/IForgeTagAppender.java index e8181fc892..f861f2d107 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeTagAppender.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeTagAppender.java @@ -7,7 +7,7 @@ package net.minecraftforge.common.extensions; import net.minecraft.data.tags.TagAppender; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.tags.TagBuilder; import net.minecraft.tags.TagKey; @@ -62,7 +62,7 @@ public interface IForgeTagAppender { return builder; } - default TagAppender addOptional(ResourceLocation location) { + default TagAppender addOptional(Identifier location) { self().getInternalBuilder().addOptionalElement(location); return self(); } @@ -89,7 +89,7 @@ public interface IForgeTagAppender { * @param location The ID of the element to remove * @return The builder for chaining */ - default TagAppender remove(final ResourceLocation location) { + default TagAppender remove(final Identifier location) { var builder = self(); builder.getInternalBuilder().removeElement(location, builder.getSourceName()); return builder; @@ -100,7 +100,7 @@ public interface IForgeTagAppender { * @param locations The IDs of the elements to remove * @return The builder for chaining */ - default TagAppender remove(final ResourceLocation first, final ResourceLocation... locations) { + default TagAppender remove(final Identifier first, final Identifier... locations) { this.remove(first); for (var location : locations) this.remove(location); @@ -114,7 +114,7 @@ public interface IForgeTagAppender { * @return The appender for chaining */ default TagAppender remove(final ResourceKey resourceKey) { - this.remove(resourceKey.location()); + this.remove(resourceKey.identifier()); return self(); } diff --git a/src/main/java/net/minecraftforge/common/loot/LootModifier.java b/src/main/java/net/minecraftforge/common/loot/LootModifier.java index 9d884089d1..5787b6d2db 100644 --- a/src/main/java/net/minecraftforge/common/loot/LootModifier.java +++ b/src/main/java/net/minecraftforge/common/loot/LootModifier.java @@ -11,7 +11,7 @@ import java.util.function.Predicate; import com.mojang.datafixers.Products; import com.mojang.serialization.codecs.RecordCodecBuilder; import it.unimi.dsi.fastutil.objects.ObjectArrayList; -import net.minecraft.Util; +import net.minecraft.util.Util; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.levelgen.feature.trunkplacers.BendingTrunkPlacer; import net.minecraft.world.level.storage.loot.LootContext; diff --git a/src/main/java/net/minecraftforge/common/loot/LootModifierManager.java b/src/main/java/net/minecraftforge/common/loot/LootModifierManager.java index a36c0ed741..40935f4511 100644 --- a/src/main/java/net/minecraftforge/common/loot/LootModifierManager.java +++ b/src/main/java/net/minecraftforge/common/loot/LootModifierManager.java @@ -26,7 +26,7 @@ import net.minecraft.util.ExtraCodecs; import net.minecraft.util.GsonHelper; import net.minecraft.core.HolderLookup; import net.minecraft.resources.FileToIdConverter; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; public class LootModifierManager extends SimpleJsonResourceReloadListener { private static final Logger LOGGER = LogManager.getLogger(); @@ -34,7 +34,7 @@ public class LootModifierManager extends SimpleJsonResourceReloadListener modifiers = ImmutableMap.of(); + private Map modifiers = ImmutableMap.of(); public LootModifierManager(HolderLookup.Provider registries) { super(registries.createSerializationContext(JsonOps.INSTANCE), ExtraCodecs.JSON, FileToIdConverter.json(FOLDER)); @@ -42,10 +42,10 @@ public class LootModifierManager extends SimpleJsonResourceReloadListener prepare(ResourceManager resources, ProfilerFiller profilerFiller) { - var path = ResourceLocation.fromNamespaceAndPath("forge", FOLDER + "/global_loot_modifiers.json"); + protected Map prepare(ResourceManager resources, ProfilerFiller profilerFiller) { + var path = Identifier.fromNamespaceAndPath("forge", FOLDER + "/global_loot_modifiers.json"); - List toLoad = new ArrayList<>(); + List toLoad = new ArrayList<>(); //read in all data files from forge:loot_modifiers/global_loot_modifiers in order to do layering for (var resource : resources.getResourceStack(path)) { try (var reader = resource.openAsReader()) { @@ -55,7 +55,7 @@ public class LootModifierManager extends SimpleJsonResourceReloadListener resources, ResourceManager resourceManagerIn, ProfilerFiller profilerIn) { - Builder builder = ImmutableMap.builder(); + protected void apply(Map resources, ResourceManager resourceManagerIn, ProfilerFiller profilerIn) { + Builder builder = ImmutableMap.builder(); var ops = registries.createSerializationContext(JsonOps.INSTANCE); resources.forEach((location, json) -> { IGlobalLootModifier.DIRECT_CODEC.parse(ops, json) diff --git a/src/main/java/net/minecraftforge/common/loot/LootTableIdCondition.java b/src/main/java/net/minecraftforge/common/loot/LootTableIdCondition.java index 1f761948bd..fa757062b4 100644 --- a/src/main/java/net/minecraftforge/common/loot/LootTableIdCondition.java +++ b/src/main/java/net/minecraftforge/common/loot/LootTableIdCondition.java @@ -11,17 +11,17 @@ import com.mojang.serialization.codecs.RecordCodecBuilder; import net.minecraft.world.level.storage.loot.predicates.LootItemConditionType; import net.minecraft.world.level.storage.loot.LootContext; import net.minecraft.world.level.storage.loot.predicates.LootItemCondition; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; -public record LootTableIdCondition(ResourceLocation id) implements LootItemCondition { +public record LootTableIdCondition(Identifier id) implements LootItemCondition { public static final MapCodec CODEC = RecordCodecBuilder.mapCodec(b -> b.group( - ResourceLocation.CODEC.fieldOf("loot_table_id").forGetter(LootTableIdCondition::id) + Identifier.CODEC.fieldOf("loot_table_id").forGetter(LootTableIdCondition::id) ).apply(b, LootTableIdCondition::new)); // TODO Forge Registry at some point? public static final LootItemConditionType TYPE = new LootItemConditionType(CODEC); - public static final ResourceLocation UNKNOWN_LOOT_TABLE = ResourceLocation.fromNamespaceAndPath("forge", "unknown_loot_table"); + public static final Identifier UNKNOWN_LOOT_TABLE = Identifier.fromNamespaceAndPath("forge", "unknown_loot_table"); @Override public LootItemConditionType getType() { @@ -33,14 +33,14 @@ public record LootTableIdCondition(ResourceLocation id) implements LootItemCondi return ctx.getQueriedLootTableId().equals(this.id()); } - public static Builder builder(final ResourceLocation targetLootTableId) { + public static Builder builder(final Identifier targetLootTableId) { return new Builder(targetLootTableId); } public static class Builder implements LootItemCondition.Builder { - private final ResourceLocation id; + private final Identifier id; - public Builder(ResourceLocation id) { + public Builder(Identifier id) { if (id == null) throw new IllegalArgumentException("Target loot table must not be null"); this.id = id; diff --git a/src/main/java/net/minecraftforge/common/util/BlockSnapshot.java b/src/main/java/net/minecraftforge/common/util/BlockSnapshot.java index 72ff3e38cc..f5fdcb9a16 100644 --- a/src/main/java/net/minecraftforge/common/util/BlockSnapshot.java +++ b/src/main/java/net/minecraftforge/common/util/BlockSnapshot.java @@ -177,7 +177,7 @@ public class BlockSnapshot { if (toString == null) { this.toString = "BlockSnapshot[" + - "World:" + this.dim.location() + ',' + + "World:" + this.dim.identifier() + ',' + "Pos: " + this.pos + ',' + "State: " + this.block + ',' + "Flags: " + this.flags + ',' + diff --git a/src/main/java/net/minecraftforge/common/util/BrainBuilder.java b/src/main/java/net/minecraftforge/common/util/BrainBuilder.java index 57ad7f56a6..a70248b34d 100644 --- a/src/main/java/net/minecraftforge/common/util/BrainBuilder.java +++ b/src/main/java/net/minecraftforge/common/util/BrainBuilder.java @@ -9,6 +9,8 @@ import com.google.common.collect.Maps; import com.google.common.collect.Sets; import com.mojang.datafixers.util.Pair; import com.mojang.serialization.Dynamic; + +import net.minecraft.world.attribute.EnvironmentAttribute; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.ai.Brain; import net.minecraft.world.entity.ai.behavior.BehaviorControl; @@ -17,7 +19,6 @@ import net.minecraft.world.entity.ai.memory.MemoryStatus; import net.minecraft.world.entity.ai.sensing.Sensor; import net.minecraft.world.entity.ai.sensing.SensorType; import net.minecraft.world.entity.schedule.Activity; -import net.minecraft.world.entity.schedule.Schedule; import java.util.Collection; import java.util.HashSet; @@ -25,6 +26,7 @@ import java.util.Map; import java.util.Set; import org.jetbrains.annotations.ApiStatus; +import org.jspecify.annotations.Nullable; /** * This object is used to encapsulate state found inside a {@link Brain} instance, @@ -44,7 +46,7 @@ public class BrainBuilder { private final Collection> memoryTypes = new HashSet<>(); private final Collection>> sensorTypes = new HashSet<>(); private final Map>>> availableBehaviorsByPriority = Maps.newTreeMap(); - private Schedule schedule = Schedule.EMPTY; + private @Nullable EnvironmentAttribute schedule; private final Map, MemoryStatus>>> activityRequirements = Maps.newHashMap(); private final Map>> activityMemoriesToEraseWhenStopped = Maps.newHashMap(); private final Set coreActivities = Sets.newHashSet(); @@ -69,11 +71,11 @@ public class BrainBuilder { return this.availableBehaviorsByPriority; } - public Schedule getSchedule() { + public @Nullable EnvironmentAttribute getSchedule() { return this.schedule; } - public void setSchedule(Schedule schedule) { + public void setSchedule(@Nullable EnvironmentAttribute schedule) { this.schedule = schedule; } diff --git a/src/main/java/net/minecraftforge/common/util/LazyOptional.java b/src/main/java/net/minecraftforge/common/util/LazyOptional.java index d798f4594e..6ff44ab662 100644 --- a/src/main/java/net/minecraftforge/common/util/LazyOptional.java +++ b/src/main/java/net/minecraftforge/common/util/LazyOptional.java @@ -10,9 +10,6 @@ import java.util.Objects; import java.util.Optional; import java.util.Set; -import javax.annotation.ParametersAreNonnullByDefault; - -import net.minecraft.MethodsReturnNonnullByDefault; import net.minecraftforge.common.capabilities.Capability; import org.apache.commons.lang3.mutable.Mutable; import org.apache.commons.lang3.mutable.MutableObject; @@ -21,6 +18,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.NullMarked; /** * This object encapsulates a lazy value, with typical transformation operations @@ -38,8 +36,7 @@ import org.jetbrains.annotations.Nullable; * * @param The type of the optional value. */ -@ParametersAreNonnullByDefault -@MethodsReturnNonnullByDefault +@NullMarked public class LazyOptional { private final NonNullSupplier supplier; private final Object lock = new Object(); diff --git a/src/main/java/net/minecraftforge/common/util/LevelCapabilityData.java b/src/main/java/net/minecraftforge/common/util/LevelCapabilityData.java index 25cca35e73..ad6fa6586d 100644 --- a/src/main/java/net/minecraftforge/common/util/LevelCapabilityData.java +++ b/src/main/java/net/minecraftforge/common/util/LevelCapabilityData.java @@ -6,6 +6,7 @@ package net.minecraftforge.common.util; import net.minecraft.nbt.CompoundTag; +import net.minecraft.server.level.ServerLevel; import net.minecraft.world.level.saveddata.SavedData; import net.minecraft.world.level.saveddata.SavedDataType; @@ -15,33 +16,34 @@ import com.mojang.serialization.codecs.RecordCodecBuilder; @SuppressWarnings("deprecation") public class LevelCapabilityData extends SavedData { - public static final SavedDataType TYPE = new SavedDataType( - "capabilities", - LevelCapabilityData::new, - ctx -> + public static SavedDataType type(ServerLevel level) { + return new SavedDataType( + "capabilities", + () -> new LevelCapabilityData(level), RecordCodecBuilder.create(b -> b.group( CompoundTag.CODEC.fieldOf("data").forGetter(i -> { if (i.serializable == null) - return new CompoundTag(); - return i.serializable.serializeNBT(ctx.levelOrThrow().registryAccess()); + return new CompoundTag(); + return i.serializable.serializeNBT(level.registryAccess()); }) - ).apply(b, nbt -> new LevelCapabilityData(ctx, nbt)) + ).apply(b, nbt -> new LevelCapabilityData(level, nbt)) ), - null - ); + null + ); + } @Nullable private final INBTSerializable serializable; - private LevelCapabilityData(SavedData.Context ctx) { - this.serializable = ctx.levelOrThrow().getCapabilityDispatcher(); + private LevelCapabilityData(ServerLevel ctx) { + this.serializable = ctx.getCapabilityDispatcher(); } - private LevelCapabilityData(SavedData.Context ctx, CompoundTag data) { + private LevelCapabilityData(ServerLevel ctx, CompoundTag data) { this(ctx); if (this.serializable != null) - this.serializable.deserializeNBT(ctx.levelOrThrow().registryAccess(), data); + this.serializable.deserializeNBT(ctx.registryAccess(), data); } @Override diff --git a/src/main/java/net/minecraftforge/common/util/TransformationHelper.java b/src/main/java/net/minecraftforge/common/util/TransformationHelper.java index 913c339a8e..45382997b0 100644 --- a/src/main/java/net/minecraftforge/common/util/TransformationHelper.java +++ b/src/main/java/net/minecraftforge/common/util/TransformationHelper.java @@ -25,41 +25,33 @@ import org.joml.Matrix4f; import org.joml.Quaternionf; import org.joml.Quaternionfc; import org.joml.Vector3f; +import org.joml.Vector3fc; import org.joml.Vector4f; -public final class TransformationHelper -{ - public static Quaternionf quatFromXYZ(Vector3f xyz, boolean degrees) - { +public final class TransformationHelper { + public static Quaternionf quatFromXYZ(Vector3f xyz, boolean degrees) { return quatFromXYZ(xyz.x, xyz.y, xyz.z, degrees); } - public static Quaternionf quatFromXYZ(float[] xyz, boolean degrees) - { + public static Quaternionf quatFromXYZ(float[] xyz, boolean degrees) { return quatFromXYZ(xyz[0], xyz[1], xyz[2], degrees); } - public static Quaternionf quatFromXYZ(float x, float y, float z, boolean degrees) - { + public static Quaternionf quatFromXYZ(float x, float y, float z, boolean degrees) { float conversionFactor = degrees ? (float) Math.PI / 180 : 1; return new Quaternionf().rotationXYZ(x * conversionFactor, y * conversionFactor, z * conversionFactor); } - public static Quaternionf makeQuaternion(float[] values) - { + public static Quaternionf makeQuaternion(float[] values) { return new Quaternionf(values[0], values[1], values[2], values[3]); } - public static Vector3f lerp(Vector3f from, Vector3f to, float progress) - { - Vector3f res = new Vector3f(from); - res.lerp(to, progress); - return res; + public static Vector3f lerp(Vector3fc from, Vector3fc to, float progress) { + return new Vector3f(from).lerp(to, progress); } private static final double THRESHOLD = 0.9995; - public static Quaternionf slerp(Quaternionfc v0, Quaternionfc v1, float t) - { + public static Quaternionf slerp(Quaternionfc v0, Quaternionfc v1, float t) { // From https://en.wikipedia.org/w/index.php?title=Slerp&oldid=928959428 // License: CC BY-SA 3.0 https://creativecommons.org/licenses/by-sa/3.0/ @@ -102,8 +94,7 @@ public final class TransformationHelper ); } - public static Transformation slerp(Transformation one, Transformation that, float progress) - { + public static Transformation slerp(Transformation one, Transformation that, float progress) { return new Transformation( lerp(one.getTranslation(), that.getTranslation(), progress), slerp(one.getLeftRotation(), that.getLeftRotation(), progress), @@ -112,49 +103,40 @@ public final class TransformationHelper ); } - public static boolean epsilonEquals(Vector4f v1, Vector4f v2, float epsilon) - { + public static boolean epsilonEquals(Vector4f v1, Vector4f v2, float epsilon) { return Mth.abs(v1.x()-v2.x()) < epsilon && Mth.abs(v1.y()-v2.y()) < epsilon && Mth.abs(v1.z()-v2.z()) < epsilon && Mth.abs(v1.w()-v2.w()) < epsilon; } - public static class Deserializer implements JsonDeserializer - { + public static class Deserializer implements JsonDeserializer { @Override - public Transformation deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException - { - if (json.isJsonPrimitive() && json.getAsJsonPrimitive().isString()) - { + public Transformation deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { + if (json.isJsonPrimitive() && json.getAsJsonPrimitive().isString()) { String transform = json.getAsString(); - if(transform.equals("identity")) - { + if (transform.equals("identity")) return Transformation.identity(); - } - else - { - throw new JsonParseException("TRSR: unknown default string: " + transform); - } + throw new JsonParseException("TRSR: unknown default string: " + transform); } + + // direct matrix array if (json.isJsonArray()) - { - // direct matrix array return new Transformation(parseMatrix(json)); - } - if (!json.isJsonObject()) throw new JsonParseException("TRSR: expected array or object, got: " + json); + + if (!json.isJsonObject()) + throw new JsonParseException("TRSR: expected array or object, got: " + json); + JsonObject obj = json.getAsJsonObject(); Transformation ret; - if (obj.has("matrix")) - { + if (obj.has("matrix")) { // matrix as a sole key ret = new Transformation(parseMatrix(obj.get("matrix"))); if (obj.entrySet().size() > 1) - { throw new JsonParseException("TRSR: can't combine matrix and other keys"); - } return ret; } + Vector3f translation = null; Quaternionf leftRot = null; Vector3f scale = null; @@ -163,57 +145,48 @@ public final class TransformationHelper // This should probably be replaced with center in future versions. Vector3f origin = TransformOrigin.OPPOSING_CORNER.getVector(); // TODO: Changing this to ORIGIN_CENTER breaks models, function content needs changing too -C Set elements = new HashSet<>(obj.keySet()); - if (obj.has("translation")) - { + if (obj.has("translation")) { translation = new Vector3f(parseFloatArray(obj.get("translation"), 3, "Translation")); elements.remove("translation"); } - if (obj.has("rotation")) - { + + if (obj.has("rotation")) { leftRot = parseRotation(obj.get("rotation")); elements.remove("rotation"); - } - else if (obj.has("left_rotation")) - { + } else if (obj.has("left_rotation")) { leftRot = parseRotation(obj.get("left_rotation")); elements.remove("left_rotation"); } - if (obj.has("scale")) - { - if(!obj.get("scale").isJsonArray()) - { - try - { + + if (obj.has("scale")) { + if(!obj.get("scale").isJsonArray()) { + try { float s = obj.get("scale").getAsNumber().floatValue(); scale = new Vector3f(s, s, s); - } - catch (ClassCastException ex) - { + } catch (ClassCastException ex) { throw new JsonParseException("TRSR scale: expected number or array, got: " + obj.get("scale")); } - } - else - { + } else { scale = new Vector3f(parseFloatArray(obj.get("scale"), 3, "Scale")); } elements.remove("scale"); } - if (obj.has("right_rotation")) - { + + if (obj.has("right_rotation")) { rightRot = parseRotation(obj.get("right_rotation")); elements.remove("right_rotation"); - } - else if (obj.has("post-rotation")) - { + } else if (obj.has("post-rotation")) { rightRot = parseRotation(obj.get("post-rotation")); elements.remove("post-rotation"); } - if (obj.has("origin")) - { + + if (obj.has("origin")) { origin = parseOrigin(obj); elements.remove("origin"); } - if (!elements.isEmpty()) throw new JsonParseException("TRSR: can either have single 'matrix' key, or a combination of 'translation', 'rotation' OR 'left_rotation', 'scale', 'post-rotation' (legacy) OR 'right_rotation', 'origin'. Found: " + String.join(", ", elements)); + + if (!elements.isEmpty()) + throw new JsonParseException("TRSR: can either have single 'matrix' key, or a combination of 'translation', 'rotation' OR 'left_rotation', 'scale', 'post-rotation' (legacy) OR 'right_rotation', 'origin'. Found: " + String.join(", ", elements)); Transformation matrix = new Transformation(translation, leftRot, scale, rightRot); return matrix.applyOrigin(new Vector3f(origin)); @@ -224,131 +197,117 @@ public final class TransformationHelper // Two types supported: string ("center", "corner", "opposing-corner") and array ([x, y, z]) JsonElement originElement = obj.get("origin"); - if (originElement.isJsonArray()) - { + if (originElement.isJsonArray()) { origin = new Vector3f(parseFloatArray(originElement, 3, "Origin")); - } - else if (originElement.isJsonPrimitive()) - { + } else if (originElement.isJsonPrimitive()) { String originString = originElement.getAsString(); TransformOrigin originEnum = TransformOrigin.fromString(originString); if (originEnum == null) - { throw new JsonParseException("Origin: expected one of 'center', 'corner', 'opposing-corner'"); - } origin = originEnum.getVector(); - } - else - { + } else { throw new JsonParseException("Origin: expected an array or one of 'center', 'corner', 'opposing-corner'"); } return origin; } - public static Matrix4f parseMatrix(JsonElement e) - { - if (!e.isJsonArray()) throw new JsonParseException("Matrix: expected an array, got: " + e); + public static Matrix4f parseMatrix(JsonElement e) { + if (!e.isJsonArray()) + throw new JsonParseException("Matrix: expected an array, got: " + e); + JsonArray m = e.getAsJsonArray(); - if (m.size() != 3) throw new JsonParseException("Matrix: expected an array of length 3, got: " + m.size()); + + if (m.size() != 3) + throw new JsonParseException("Matrix: expected an array of length 3, got: " + m.size()); + Matrix4f matrix = new Matrix4f(); - for (int rowIdx = 0; rowIdx < 3; rowIdx++) - { - if (!m.get(rowIdx).isJsonArray()) throw new JsonParseException("Matrix row: expected an array, got: " + m.get(rowIdx)); + for (int rowIdx = 0; rowIdx < 3; rowIdx++) { + if (!m.get(rowIdx).isJsonArray()) + throw new JsonParseException("Matrix row: expected an array, got: " + m.get(rowIdx)); + JsonArray r = m.get(rowIdx).getAsJsonArray(); - if (r.size() != 4) throw new JsonParseException("Matrix row: expected an array of length 4, got: " + r.size()); - for (int columnIdx = 0; columnIdx < 4; columnIdx++) - { - try - { + if (r.size() != 4) + throw new JsonParseException("Matrix row: expected an array of length 4, got: " + r.size()); + + for (int columnIdx = 0; columnIdx < 4; columnIdx++) { + try { matrix.set(columnIdx, rowIdx, r.get(columnIdx).getAsNumber().floatValue()); - } - catch (ClassCastException ex) - { + } catch (ClassCastException ex) { throw new JsonParseException("Matrix element: expected number, got: " + r.get(columnIdx)); } } } + // JOML's unsafe matrix component setter does not recalculate these properties, so the matrix would stay marked as identity matrix.determineProperties(); return matrix; } - public static float[] parseFloatArray(JsonElement e, int length, String prefix) - { - if (!e.isJsonArray()) throw new JsonParseException(prefix + ": expected an array, got: " + e); + public static float[] parseFloatArray(JsonElement e, int length, String prefix) { + if (!e.isJsonArray()) + throw new JsonParseException(prefix + ": expected an array, got: " + e); + JsonArray t = e.getAsJsonArray(); - if (t.size() != length) throw new JsonParseException(prefix + ": expected an array of length " + length + ", got: " + t.size()); + if (t.size() != length) + throw new JsonParseException(prefix + ": expected an array of length " + length + ", got: " + t.size()); + float[] ret = new float[length]; - for (int i = 0; i < length; i++) - { - try - { + for (int i = 0; i < length; i++) { + try { ret[i] = t.get(i).getAsNumber().floatValue(); - } - catch (ClassCastException ex) - { + } catch (ClassCastException ex) { throw new JsonParseException(prefix + " element: expected number, got: " + t.get(i)); } } return ret; } - public static Quaternionf parseAxisRotation(JsonElement e) - { - if (!e.isJsonObject()) throw new JsonParseException("Axis rotation: object expected, got: " + e); + public static Quaternionf parseAxisRotation(JsonElement e) { + if (!e.isJsonObject()) + throw new JsonParseException("Axis rotation: object expected, got: " + e); + JsonObject obj = e.getAsJsonObject(); - if (obj.entrySet().size() != 1) throw new JsonParseException("Axis rotation: expected single axis object, got: " + e); + if (obj.entrySet().size() != 1) + throw new JsonParseException("Axis rotation: expected single axis object, got: " + e); + Map.Entry entry = obj.entrySet().iterator().next(); Quaternionf ret; - try - { + try { ret = switch (entry.getKey()) { case "x" -> Axis.XP.rotationDegrees(entry.getValue().getAsNumber().floatValue()); case "y" -> Axis.YP.rotationDegrees(entry.getValue().getAsNumber().floatValue()); case "z" -> Axis.ZP.rotationDegrees(entry.getValue().getAsNumber().floatValue()); default -> throw new JsonParseException("Axis rotation: expected single axis key, got: " + entry.getKey()); }; - } - catch(ClassCastException ex) - { + } catch(ClassCastException ex) { throw new JsonParseException("Axis rotation value: expected number, got: " + entry.getValue()); } return ret; } - public static Quaternionf parseRotation(JsonElement e) - { - if (e.isJsonArray()) - { - if (e.getAsJsonArray().get(0).isJsonObject()) - { + public static Quaternionf parseRotation(JsonElement e) { + if (e.isJsonArray()) { + if (e.getAsJsonArray().get(0).isJsonObject()) { Quaternionf ret = new Quaternionf(); for (JsonElement a : e.getAsJsonArray()) - { ret.mul(parseAxisRotation(a)); - } return ret; - } - else if (e.isJsonArray()) - { + } else if (e.isJsonArray()) { JsonArray array = e.getAsJsonArray(); if (array.size() == 3) //Vanilla rotation return quatFromXYZ(parseFloatArray(e, 3, "Rotation"), true); else // quaternion return makeQuaternion(parseFloatArray(e, 4, "Rotation")); - } - else throw new JsonParseException("Rotation: expected array or object, got: " + e); - } - else if (e.isJsonObject()) - { + } else + throw new JsonParseException("Rotation: expected array or object, got: " + e); + } else if (e.isJsonObject()) { return parseAxisRotation(e); } else throw new JsonParseException("Rotation: expected array or object, got: " + e); } } - public enum TransformOrigin implements StringRepresentable - { + public enum TransformOrigin implements StringRepresentable { CENTER(new Vector3f(.5f, .5f, .5f), "center"), CORNER(new Vector3f(), "corner"), OPPOSING_CORNER(new Vector3f(1, 1, 1), "opposing-corner"); @@ -356,38 +315,31 @@ public final class TransformationHelper private final Vector3f vec; private final String name; - TransformOrigin(Vector3f vec, String name) - { + TransformOrigin(Vector3f vec, String name) { this.vec = vec; this.name = name; } - public Vector3f getVector() - { + public Vector3f getVector() { return vec; } @Override @NotNull - public String getSerializedName() - { + public String getSerializedName() { return name; } - public static @Nullable TransformOrigin fromString(String originName) - { + public static @Nullable TransformOrigin fromString(String originName) { if (CENTER.getSerializedName().equals(originName)) - { return CENTER; - } + if (CORNER.getSerializedName().equals(originName)) - { return CORNER; - } + if (OPPOSING_CORNER.getSerializedName().equals(originName)) - { return OPPOSING_CORNER; - } + return null; } } diff --git a/src/main/java/net/minecraftforge/common/world/BiomeSpecialEffectsBuilder.java b/src/main/java/net/minecraftforge/common/world/BiomeSpecialEffectsBuilder.java index cda2b25a69..8eea8bfb94 100644 --- a/src/main/java/net/minecraftforge/common/world/BiomeSpecialEffectsBuilder.java +++ b/src/main/java/net/minecraftforge/common/world/BiomeSpecialEffectsBuilder.java @@ -6,14 +6,8 @@ package net.minecraftforge.common.world; import java.util.Optional; +import java.util.OptionalInt; -import net.minecraft.core.Holder; -import net.minecraft.sounds.Music; -import net.minecraft.sounds.SoundEvent; -import net.minecraft.util.random.WeightedList; -import net.minecraft.world.level.biome.AmbientAdditionsSettings; -import net.minecraft.world.level.biome.AmbientMoodSettings; -import net.minecraft.world.level.biome.AmbientParticleSettings; import net.minecraft.world.level.biome.BiomeSpecialEffects; /** @@ -22,75 +16,69 @@ import net.minecraft.world.level.biome.BiomeSpecialEffects; */ public class BiomeSpecialEffectsBuilder extends BiomeSpecialEffects.Builder { public static BiomeSpecialEffectsBuilder copyOf(BiomeSpecialEffects baseEffects) { - BiomeSpecialEffectsBuilder builder = BiomeSpecialEffectsBuilder.create(baseEffects.getFogColor(), baseEffects.getWaterColor(), baseEffects.getWaterFogColor(), baseEffects.getSkyColor()); - builder.grassColorModifier = baseEffects.getGrassColorModifier(); - baseEffects.getFoliageColorOverride().ifPresent(builder::foliageColorOverride); - baseEffects.getGrassColorOverride().ifPresent(builder::grassColorOverride); - baseEffects.getAmbientParticleSettings().ifPresent(builder::ambientParticle); - baseEffects.getAmbientLoopSoundEvent().ifPresent(builder::ambientLoopSound); - baseEffects.getAmbientMoodSettings().ifPresent(builder::ambientMoodSound); - baseEffects.getAmbientAdditionsSettings().ifPresent(builder::ambientAdditionsSound); - baseEffects.getBackgroundMusic().ifPresent(builder::backgroundMusic); - return builder; + var ret = create() + .waterColor(baseEffects.waterColor()) + .grassColorModifier(baseEffects.grassColorModifier()) + ; + + if (baseEffects.foliageColorOverride().isPresent()) + ret = ret.foliageColorOverride(baseEffects.foliageColorOverride().get()); + if (baseEffects.dryFoliageColorOverride().isPresent()) + ret = ret.dryFoliageColorOverride(baseEffects.dryFoliageColorOverride().get()); + if (baseEffects.grassColorOverride().isPresent()) + ret = ret.grassColorOverride(baseEffects.grassColorOverride().get()); + return ret; } - public static BiomeSpecialEffectsBuilder create(int fogColor, int waterColor, int waterFogColor, int skyColor) { - return new BiomeSpecialEffectsBuilder(fogColor, waterColor, waterFogColor, skyColor); + public static BiomeSpecialEffectsBuilder create() { + return new BiomeSpecialEffectsBuilder(); } - protected BiomeSpecialEffectsBuilder(int fogColor, int waterColor, int waterFogColor, int skyColor) { - super(); - this.fogColor(fogColor); - this.waterColor(waterColor); - this.waterFogColor(waterFogColor); - this.skyColor(skyColor); + protected BiomeSpecialEffectsBuilder() { } - public int getFogColor() { - return this.fogColor.getAsInt(); + public BiomeSpecialEffectsBuilder waterColor(int value) { + super.waterColor(value); + return this; } - public int waterColor() { - return this.waterColor.getAsInt(); + public OptionalInt waterColor() { + return this.waterColor; } - public int getWaterFogColor() { - return this.waterFogColor.getAsInt(); + public BiomeSpecialEffectsBuilder foliageColorOverride(int value) { + super.foliageColorOverride(value); + return this; } - public int getSkyColor() { - return this.skyColor.getAsInt(); + public Optional foliageColorOverride() { + return this.foliageColorOverride; + } + + public BiomeSpecialEffectsBuilder dryFoliageColorOverride(int value) { + super.dryFoliageColorOverride(value); + return this; + } + + public Optional dryFoliageColorOverride() { + return this.dryFoliageColorOverride; + } + + public BiomeSpecialEffectsBuilder grassColorOverride(int value) { + super.grassColorOverride(value); + return this; + } + + public Optional grassColorOverride() { + return this.grassColorOverride; + } + + public BiomeSpecialEffectsBuilder grassColorModifier(BiomeSpecialEffects.GrassColorModifier value) { + super.grassColorModifier(value); + return this; } public BiomeSpecialEffects.GrassColorModifier getGrassColorModifier() { return this.grassColorModifier; } - - public Optional getFoliageColorOverride() { - return this.foliageColorOverride; - } - - public Optional getGrassColorOverride() { - return this.grassColorOverride; - } - - public Optional getAmbientParticle() { - return this.ambientParticle; - } - - public Optional> getAmbientLoopSound() { - return this.ambientLoopSoundEvent; - } - - public Optional getAmbientMoodSound() { - return this.ambientMoodSettings; - } - - public Optional getAmbientAdditionsSound() { - return this.ambientAdditionsSettings; - } - - public Optional> getBackgroundMusic() { - return this.backgroundMusic; - } } \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/common/world/ForgeBiomeModifiers.java b/src/main/java/net/minecraftforge/common/world/ForgeBiomeModifiers.java index 4657c29696..4f700b08ea 100644 --- a/src/main/java/net/minecraftforge/common/world/ForgeBiomeModifiers.java +++ b/src/main/java/net/minecraftforge/common/world/ForgeBiomeModifiers.java @@ -8,15 +8,11 @@ package net.minecraftforge.common.world; import java.util.EnumSet; import java.util.List; import java.util.Set; -import java.util.function.Function; - import com.mojang.datafixers.util.Either; import com.mojang.serialization.Codec; import com.mojang.serialization.MapCodec; -import com.mojang.serialization.codecs.ListCodec; import com.mojang.serialization.codecs.RecordCodecBuilder; -import net.minecraft.Util; import net.minecraft.core.Holder; import net.minecraft.core.HolderSet; import net.minecraft.core.RegistryCodecs; diff --git a/src/main/java/net/minecraftforge/common/world/MobSpawnSettingsBuilder.java b/src/main/java/net/minecraftforge/common/world/MobSpawnSettingsBuilder.java index fba9361c46..dbd6a0d2b0 100644 --- a/src/main/java/net/minecraftforge/common/world/MobSpawnSettingsBuilder.java +++ b/src/main/java/net/minecraftforge/common/world/MobSpawnSettingsBuilder.java @@ -6,16 +6,13 @@ package net.minecraftforge.common.world; import java.util.Collections; -import java.util.List; import java.util.Set; -import net.minecraft.Util; import net.minecraft.util.random.WeightedList; import net.minecraft.world.entity.MobCategory; import net.minecraft.world.entity.EntityType; import net.minecraft.world.level.biome.MobSpawnSettings; import org.jetbrains.annotations.Nullable; -import org.jetbrains.annotations.Unmodifiable; public class MobSpawnSettingsBuilder extends MobSpawnSettings.Builder { private final Set typesView = Collections.unmodifiableSet(this.spawners.keySet()); diff --git a/src/main/java/net/minecraftforge/data/loading/DatagenModLoader.java b/src/main/java/net/minecraftforge/data/loading/DatagenModLoader.java index c938c59b93..59fd4b538e 100644 --- a/src/main/java/net/minecraftforge/data/loading/DatagenModLoader.java +++ b/src/main/java/net/minecraftforge/data/loading/DatagenModLoader.java @@ -5,7 +5,7 @@ package net.minecraftforge.data.loading; -import net.minecraft.Util; +import net.minecraft.util.Util; import net.minecraft.client.ClientBootstrap; import net.minecraft.data.registries.VanillaRegistries; import net.minecraft.server.Bootstrap; diff --git a/src/main/java/net/minecraftforge/event/AttachCapabilitiesEvent.java b/src/main/java/net/minecraftforge/event/AttachCapabilitiesEvent.java index fa560f4c43..a7c502be81 100644 --- a/src/main/java/net/minecraftforge/event/AttachCapabilitiesEvent.java +++ b/src/main/java/net/minecraftforge/event/AttachCapabilitiesEvent.java @@ -11,7 +11,7 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.world.entity.Entity; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; @@ -39,8 +39,8 @@ import org.jspecify.annotations.NullMarked; @NullMarked public abstract class AttachCapabilitiesEvent extends MutableEvent implements InheritableEvent { private final Object obj; - private final Map caps = new LinkedHashMap<>(); - private final Map view = Collections.unmodifiableMap(caps); + private final Map caps = new LinkedHashMap<>(); + private final Map view = Collections.unmodifiableMap(caps); private final List listeners = new ArrayList<>(); private final List listenersView = Collections.unmodifiableList(listeners); @@ -128,7 +128,7 @@ public abstract class AttachCapabilitiesEvent extends MutableEvent implements In * @param key The name of owner of this capability provider. * @param cap The capability provider */ - public void addCapability(ResourceLocation key, ICapabilityProvider cap) { + public void addCapability(Identifier key, ICapabilityProvider cap) { if (caps.containsKey(key)) throw new IllegalStateException("Duplicate Capability Key: " + key + " " + cap); this.caps.put(key, cap); @@ -137,7 +137,7 @@ public abstract class AttachCapabilitiesEvent extends MutableEvent implements In /** * A unmodifiable view of the capabilities that will be attached to this object. */ - public Map getCapabilities() { + public Map getCapabilities() { return view; } diff --git a/src/main/java/net/minecraftforge/event/ForgeEventFactory.java b/src/main/java/net/minecraftforge/event/ForgeEventFactory.java index 5650e1f9ad..12a1374f79 100644 --- a/src/main/java/net/minecraftforge/event/ForgeEventFactory.java +++ b/src/main/java/net/minecraftforge/event/ForgeEventFactory.java @@ -26,8 +26,8 @@ import net.minecraftforge.common.util.Result; 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 org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; import com.mojang.authlib.GameProfile; import com.mojang.brigadier.CommandDispatcher; @@ -46,7 +46,7 @@ import net.minecraft.network.Connection; import net.minecraft.network.chat.Component; import net.minecraft.network.protocol.game.ServerboundPlayerActionPacket; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.MinecraftServer; import net.minecraft.server.ReloadableServerResources; import net.minecraft.server.level.ChunkHolder; @@ -56,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.permissions.LevelBasedPermissionSet; import net.minecraft.server.players.NameAndId; import net.minecraft.server.players.PlayerList; import net.minecraft.sounds.SoundEvent; @@ -66,17 +67,18 @@ import net.minecraft.world.Difficulty; import net.minecraft.world.DifficultyInstance; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; +import net.minecraft.world.attribute.BedRule; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.effect.MobEffect; import net.minecraft.world.effect.MobEffectInstance; import net.minecraft.world.entity.animal.Animal; import net.minecraft.world.entity.item.ItemEntity; -import net.minecraft.world.entity.monster.Zombie; -import net.minecraft.world.entity.npc.AbstractVillager; +import net.minecraft.world.entity.monster.zombie.Zombie; +import net.minecraft.world.entity.npc.villager.AbstractVillager; import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.projectile.FishingHook; import net.minecraft.world.entity.projectile.Projectile; -import net.minecraft.world.entity.projectile.ThrownEnderpearl; +import net.minecraft.world.entity.projectile.throwableitemprojectile.ThrownEnderpearl; import net.minecraft.world.flag.FeatureFlagSet; import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.inventory.ClickAction; @@ -90,7 +92,6 @@ import net.minecraft.world.item.trading.MerchantOffer; import net.minecraft.world.level.BaseSpawner; import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.Explosion; -import net.minecraft.world.level.GameRules; import net.minecraft.world.level.Level; import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.level.LevelSimulatedReader; @@ -103,6 +104,7 @@ import net.minecraft.world.level.chunk.ChunkAccess; import net.minecraft.world.level.chunk.LevelChunk; import net.minecraft.world.level.chunk.status.ChunkType; import net.minecraft.world.level.gameevent.GameEvent; +import net.minecraft.world.level.gamerules.GameRules; import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; import net.minecraft.world.level.portal.PortalShape; import net.minecraft.world.level.storage.PlayerDataStorage; @@ -214,7 +216,7 @@ public final class ForgeEventFactory { return EntityMultiPlaceEvent.BUS.post(new EntityMultiPlaceEvent(blockSnapshots, placedAgainst, entity)); } - public static boolean onBlockPlace(@Nullable Entity entity, @NotNull BlockSnapshot blockSnapshot, @NotNull Direction direction) { + public static boolean onBlockPlace(@Nullable Entity entity, @NonNull BlockSnapshot blockSnapshot, @NonNull Direction direction) { var placedAgainst = blockSnapshot.getLevel().getBlockState(blockSnapshot.getPos().relative(direction.getOpposite())); return BlockEvent.EntityPlaceEvent.BUS.post(new BlockEvent.EntityPlaceEvent(blockSnapshot, placedAgainst, entity)); } @@ -232,11 +234,11 @@ public final class ForgeEventFactory { return PlayerEvent.BreakSpeed.BUS.post(event) ? -1 : event.getNewSpeed(); } - public static void onPlayerDestroyItem(Player player, @NotNull ItemStack stack, @Nullable InteractionHand hand) { + public static void onPlayerDestroyItem(Player player, @NonNull ItemStack stack, @Nullable InteractionHand hand) { onPlayerDestroyItem(player, stack, hand.asEquipmentSlot()); } - public static void onPlayerDestroyItem(Player player, @NotNull ItemStack stack, @Nullable EquipmentSlot slot) { + public static void onPlayerDestroyItem(Player player, @NonNull ItemStack stack, @Nullable EquipmentSlot slot) { PlayerDestroyItemEvent.BUS.post(new PlayerDestroyItemEvent(player, stack, slot)); } @@ -323,8 +325,7 @@ public final class ForgeEventFactory { * This overload is also the only way to pass through a {@link BaseSpawner} instance. * @see #onFinalizeSpawn */ - @Nullable - public static MobSpawnEvent.FinalizeSpawn onFinalizeSpawnSpawner(Mob mob, ServerLevelAccessor level, DifficultyInstance difficulty, @Nullable SpawnGroupData spawnData, @Nullable ValueInput spawnTag, BaseSpawner spawner) { + public static MobSpawnEvent.@Nullable FinalizeSpawn onFinalizeSpawnSpawner(Mob mob, ServerLevelAccessor level, DifficultyInstance difficulty, @Nullable SpawnGroupData spawnData, @Nullable ValueInput spawnTag, BaseSpawner spawner) { var event = new MobSpawnEvent.FinalizeSpawn(mob, level, mob.getX(), mob.getY(), mob.getZ(), difficulty, EntitySpawnReason.SPAWNER, spawnData, spawnTag, spawner); return MobSpawnEvent.FinalizeSpawn.BUS.post(event) ? null : event; } @@ -333,7 +334,7 @@ public final class ForgeEventFactory { return AllowDespawn.BUS.fire(new AllowDespawn(entity, level)).getResult(); } - public static int getItemBurnTime(@NotNull ItemStack itemStack, int burnTime, @Nullable RecipeType recipeType) { + public static int getItemBurnTime(@NonNull ItemStack itemStack, int burnTime, @Nullable RecipeType recipeType) { return FurnaceFuelBurnTimeEvent.BUS.fire(new FurnaceFuelBurnTimeEvent(itemStack, burnTime, recipeType)).getBurnTime(); } @@ -428,7 +429,7 @@ public final class ForgeEventFactory { } @Nullable - public static InteractionResult onBucketUse(@NotNull Player player, @NotNull Level level, @NotNull ItemStack stack, @Nullable HitResult target) { + public static InteractionResult onBucketUse(@NonNull Player player, @NonNull Level level, @NonNull ItemStack stack, @Nullable HitResult target) { var event = new FillBucketEvent(player, stack, level, target); if (FillBucketEvent.BUS.post(event)) return InteractionResult.FAIL; @@ -449,7 +450,7 @@ public final class ForgeEventFactory { return null; } - public static @Nullable PlayLevelSoundEvent.AtEntity onPlaySoundAtEntity(Level level, Entity entity, Holder name, SoundSource category, float volume, float pitch) { + public static PlayLevelSoundEvent.@Nullable AtEntity onPlaySoundAtEntity(Level level, Entity entity, Holder name, SoundSource category, float volume, float pitch) { var event = new PlayLevelSoundEvent.AtEntity(level, entity, name, category, volume, pitch); return PlayLevelSoundEvent.AtEntity.BUS.post(event) ? null : event; } @@ -459,7 +460,7 @@ public final class ForgeEventFactory { return PlayLevelSoundEvent.AtPosition.BUS.post(event) ? null : event; } - public static int onItemExpire(ItemEntity entity, @NotNull ItemStack item) { + public static int onItemExpire(ItemEntity entity, @NonNull ItemStack item) { if (item.isEmpty()) return -1; var event = new ItemExpireEvent(entity, (item.isEmpty() ? 6000 : item.getItem().getEntityLifespan(item, entity.level()))); if (!ItemExpireEvent.BUS.post(event)) return -1; @@ -586,13 +587,13 @@ public final class ForgeEventFactory { return canContinueSleep == Result.ALLOW; } - public static boolean onSleepingTimeCheck(Player player, Optional sleepingLocation) { + public static boolean onSleepingTimeCheck(Player player, Optional sleepingLocation, BedRule rule) { var evt = new SleepingTimeCheckEvent(player, sleepingLocation); SleepingTimeCheckEvent.BUS.post(evt); var canContinueSleep = evt.getResult(); if (canContinueSleep == Result.DEFAULT) - return !player.level().isBrightOutside(); + return !rule.canSleep(player.level()); else return canContinueSleep == Result.ALLOW; } @@ -619,7 +620,7 @@ public final class ForgeEventFactory { return onProjectileImpactResult(projectile, ray) != ProjectileImpactEvent.ImpactResult.DEFAULT; } - public static @Nullable LootTable onLoadLootTable(ResourceLocation name, LootTable table) { + public static @Nullable LootTable onLoadLootTable(Identifier name, LootTable table) { var event = new LootTableLoadEvent(name, table); return LootTableLoadEvent.BUS.post(event) ? null : event.getTable(); } @@ -644,10 +645,10 @@ public final class ForgeEventFactory { public static boolean getMobGriefingEvent(ServerLevel level, @Nullable Entity entity) { if (entity == null) - return level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING); + return level.getGameRules().get(GameRules.MOB_GRIEFING); var result = EntityMobGriefingEvent.BUS.fire(new EntityMobGriefingEvent(entity)).getResult(); - return result == Result.DEFAULT ? level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) : result == Result.ALLOW; + return result == Result.DEFAULT ? level.getGameRules().get(GameRules.MOB_GRIEFING) : result == Result.ALLOW; } @SuppressWarnings("removal") @@ -700,22 +701,22 @@ public final class ForgeEventFactory { LivingConversionEvent.Post.BUS.post(new LivingConversionEvent.Post(entity, outcome)); } - public static @Nullable EntityTeleportEvent.TeleportCommand onEntityTeleportCommand(Entity entity, double targetX, double targetY, double targetZ) { + public static EntityTeleportEvent.@Nullable TeleportCommand onEntityTeleportCommand(Entity entity, double targetX, double targetY, double targetZ) { var event = new EntityTeleportEvent.TeleportCommand(entity, targetX, targetY, targetZ); return EntityTeleportEvent.TeleportCommand.BUS.post(event) ? null : event; } - public static @Nullable EntityTeleportEvent.SpreadPlayersCommand onEntityTeleportSpreadPlayersCommand(Entity entity, double targetX, double targetY, double targetZ) { + public static EntityTeleportEvent.@Nullable SpreadPlayersCommand onEntityTeleportSpreadPlayersCommand(Entity entity, double targetX, double targetY, double targetZ) { var event = new EntityTeleportEvent.SpreadPlayersCommand(entity, targetX, targetY, targetZ); return EntityTeleportEvent.SpreadPlayersCommand.BUS.post(event) ? null : event; } - public static @Nullable EntityTeleportEvent.EnderEntity onEnderManTeleport(LivingEntity entity, double targetX, double targetY, double targetZ) { + public static EntityTeleportEvent.@Nullable EnderEntity onEnderManTeleport(LivingEntity entity, double targetX, double targetY, double targetZ) { var event = new EntityTeleportEvent.EnderEntity(entity, targetX, targetY, targetZ); return EntityTeleportEvent.EnderEntity.BUS.post(event) ? null : event; } - public static @Nullable EntityTeleportEvent.EnderPearl onEnderPearlLand(ServerPlayer entity, double targetX, double targetY, double targetZ, ThrownEnderpearl pearlEntity, float attackDamage, HitResult hitResult) { + public static EntityTeleportEvent.@Nullable EnderPearl onEnderPearlLand(ServerPlayer entity, double targetX, double targetY, double targetZ, ThrownEnderpearl pearlEntity, float attackDamage, HitResult hitResult) { var event = new EntityTeleportEvent.EnderPearl(entity, targetX, targetY, targetZ, pearlEntity, attackDamage, hitResult); return EntityTeleportEvent.EnderPearl.BUS.post(event) ? null : event; } @@ -724,7 +725,7 @@ public final class ForgeEventFactory { return EntityTeleportEvent.ChorusFruit.BUS.fire(new EntityTeleportEvent.ChorusFruit(entity, targetX, targetY, targetZ)); } - public static boolean onPermissionChanged(NameAndId gameProfile, int newLevel, PlayerList playerList) { + public static boolean onPermissionChanged(NameAndId gameProfile, @Nullable LevelBasedPermissionSet newLevel, PlayerList playerList) { var oldLevel = playerList.getServer().getProfilePermissions(gameProfile); var player = playerList.getPlayer(gameProfile.id()); if (newLevel != oldLevel && player != null) @@ -868,11 +869,11 @@ public final class ForgeEventFactory { ConnectionStartEvent.BUS.post(new ConnectionStartEvent(connection)); } - public static void onChannelRegistrationChange(Connection connection, ChannelRegistrationChangeEvent.Type changeType, HashSet changed) { + public static void onChannelRegistrationChange(Connection connection, ChannelRegistrationChangeEvent.Type changeType, HashSet changed) { ChannelRegistrationChangeEvent.BUS.post(new ChannelRegistrationChangeEvent(connection, changeType, changed)); } - public static @Nullable LivingSwapItemsEvent.Hands onLivingSwapHandItems(LivingEntity entity) { + public static LivingSwapItemsEvent.@Nullable Hands onLivingSwapHandItems(LivingEntity entity) { var event = new LivingSwapItemsEvent.Hands(entity); return LivingSwapItemsEvent.Hands.BUS.post(event) ? null : event; } @@ -920,7 +921,7 @@ public final class ForgeEventFactory { PlayerInteractEvent.LeftClickEmpty.BUS.post(new PlayerInteractEvent.LeftClickEmpty(player)); } - public static @Nullable PlayerInteractEvent.LeftClickBlock onLeftClickBlock(Player player, BlockPos pos, Direction face, ServerboundPlayerActionPacket.Action action) { + public static PlayerInteractEvent.@Nullable LeftClickBlock onLeftClickBlock(Player player, BlockPos pos, Direction face, ServerboundPlayerActionPacket.Action action) { var event = new PlayerInteractEvent.LeftClickBlock(player, pos, face, PlayerInteractEvent.LeftClickBlock.Action.convert(action)); return PlayerInteractEvent.LeftClickBlock.BUS.post(event) ? null : event; } @@ -1007,18 +1008,18 @@ public final class ForgeEventFactory { return LivingChangeTargetEvent.BUS.post(event) ? null : event; } - public static @Nullable PlayerXpEvent.XpChange onPlayerXpChange(Player player, int xp) { + public static PlayerXpEvent.@Nullable XpChange onPlayerXpChange(Player player, int xp) { var event = new PlayerXpEvent.XpChange(player, xp); return PlayerXpEvent.XpChange.BUS.post(event) ? null : event; } - public static @Nullable PlayerXpEvent.LevelChange onPlayerLevelChange(Player player, int levels) { + public static PlayerXpEvent.@Nullable LevelChange onPlayerLevelChange(Player player, int levels) { var event = new PlayerXpEvent.LevelChange(player, levels); return PlayerXpEvent.LevelChange.BUS.post(event) ? null : event; } - public static @Nullable GrindstoneEvent.OnPlaceItem onGrindstoneChange(@NotNull ItemStack top, @NotNull ItemStack bottom, Container outputSlot, int xp) { + public static GrindstoneEvent.@Nullable OnPlaceItem onGrindstoneChange(@NonNull ItemStack top, @NonNull ItemStack bottom, Container outputSlot, int xp) { var event = new GrindstoneEvent.OnPlaceItem(top, bottom, xp); return GrindstoneEvent.OnPlaceItem.BUS.post(event) ? null : event; } @@ -1031,12 +1032,12 @@ public final class ForgeEventFactory { return ItemStackedOnOtherEvent.BUS.post(new ItemStackedOnOtherEvent(carriedItem, stackedOnItem, slot, action, player, carriedSlotAccess)); } - public static @Nullable NoteBlockEvent.Play onNotePlay(Level world, BlockPos pos, BlockState state, int note, NoteBlockInstrument instrument) { + public static NoteBlockEvent.@Nullable Play onNotePlay(Level world, BlockPos pos, BlockState state, int note, NoteBlockInstrument instrument) { var event = new NoteBlockEvent.Play(world, pos, state, note, instrument); return NoteBlockEvent.Play.BUS.post(event) ? null : event; } - public static AnvilRepairEvent onAnvilRepair(Player player, @NotNull ItemStack output, @NotNull ItemStack left, @NotNull ItemStack right) { + public static AnvilRepairEvent onAnvilRepair(Player player, @NonNull ItemStack output, @NonNull ItemStack left, @NonNull ItemStack right) { return AnvilRepairEvent.BUS.fire(new AnvilRepairEvent(player, left, right, output)); } diff --git a/src/main/java/net/minecraftforge/event/LootTableLoadEvent.java b/src/main/java/net/minecraftforge/event/LootTableLoadEvent.java index 36cd5507fb..ab3a100cb7 100644 --- a/src/main/java/net/minecraftforge/event/LootTableLoadEvent.java +++ b/src/main/java/net/minecraftforge/event/LootTableLoadEvent.java @@ -5,7 +5,7 @@ package net.minecraftforge.event; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.world.level.storage.loot.LootTable; import net.minecraftforge.eventbus.api.bus.CancellableEventBus; import net.minecraftforge.eventbus.api.event.MutableEvent; @@ -27,15 +27,15 @@ import org.jspecify.annotations.Nullable; public final class LootTableLoadEvent extends MutableEvent implements Cancellable { public static final CancellableEventBus BUS = CancellableEventBus.create(LootTableLoadEvent.class); - private final ResourceLocation name; + private final Identifier name; private @Nullable LootTable table; - public LootTableLoadEvent(ResourceLocation name, LootTable table) { + public LootTableLoadEvent(Identifier name, LootTable table) { this.name = name; this.table = table; } - public ResourceLocation getName() { + public Identifier getName() { return this.name; } diff --git a/src/main/java/net/minecraftforge/event/RegisterStructureConversionsEvent.java b/src/main/java/net/minecraftforge/event/RegisterStructureConversionsEvent.java index 2487e3c506..cc998afc86 100644 --- a/src/main/java/net/minecraftforge/event/RegisterStructureConversionsEvent.java +++ b/src/main/java/net/minecraftforge/event/RegisterStructureConversionsEvent.java @@ -5,7 +5,7 @@ package net.minecraftforge.event; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.util.datafix.fixes.StructuresBecomeConfiguredFix; import java.util.Locale; @@ -22,7 +22,7 @@ import org.jspecify.annotations.NullMarked; * Fired for registering structure conversions for pre-1.18.2 worlds. This is used by {@link StructuresBecomeConfiguredFix} * for converting old structure IDs in pre-1.18.2 worlds to their new equivalents, which can be differentiated per biome. * - *

    By default, structures whose old ID has a namespace which is not equal to {@value ResourceLocation#DEFAULT_NAMESPACE} + *

    By default, structures whose old ID has a namespace which is not equal to {@value Identifier#DEFAULT_NAMESPACE} * will be assumed to belong to a modded structure and will be used as the new ID. Mods may choose to register structure * conversions for their structures, if they wish to override this default behavior.

    * diff --git a/src/main/java/net/minecraftforge/event/entity/EntityTeleportEvent.java b/src/main/java/net/minecraftforge/event/entity/EntityTeleportEvent.java index d5a2bf4d0e..495b8fcb3b 100644 --- a/src/main/java/net/minecraftforge/event/entity/EntityTeleportEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/EntityTeleportEvent.java @@ -7,7 +7,7 @@ package net.minecraftforge.event.entity; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LivingEntity; -import net.minecraft.world.entity.projectile.ThrownEnderpearl; +import net.minecraft.world.entity.projectile.throwableitemprojectile.ThrownEnderpearl; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.phys.HitResult; import net.minecraft.world.phys.Vec3; diff --git a/src/main/java/net/minecraftforge/event/entity/living/BabyEntitySpawnEvent.java b/src/main/java/net/minecraftforge/event/entity/living/BabyEntitySpawnEvent.java index fd8f9bbec7..5c8c6287c9 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/BabyEntitySpawnEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/BabyEntitySpawnEvent.java @@ -9,7 +9,7 @@ import net.minecraft.server.level.ServerLevel; import net.minecraft.world.entity.AgeableMob; import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.animal.Animal; -import net.minecraft.world.entity.animal.Fox; +import net.minecraft.world.entity.animal.fox.Fox; import net.minecraft.world.entity.player.Player; import net.minecraftforge.common.MinecraftForge; 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 72fac8cca9..f9ab2e5928 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/ZombieEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/ZombieEvent.java @@ -6,7 +6,7 @@ package net.minecraftforge.event.entity.living; import net.minecraft.world.entity.LivingEntity; -import net.minecraft.world.entity.monster.Zombie; +import net.minecraft.world.entity.monster.zombie.Zombie; import net.minecraft.world.level.Level; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.util.HasResult; 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 bc3d6d10af..af63b79d0d 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/PermissionsChangedEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/PermissionsChangedEvent.java @@ -6,10 +6,12 @@ package net.minecraftforge.event.entity.player; import net.minecraft.server.level.ServerPlayer; +import net.minecraft.server.permissions.LevelBasedPermissionSet; 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; +import org.jspecify.annotations.Nullable; /** * This event will fire when the player is opped or deopped. @@ -19,7 +21,7 @@ import org.jspecify.annotations.NullMarked; * @param getOldLevel The old permission level. */ @NullMarked -public record PermissionsChangedEvent(ServerPlayer getEntity, int getNewLevel, int getOldLevel) +public record PermissionsChangedEvent(ServerPlayer getEntity, @Nullable LevelBasedPermissionSet getNewLevel, @Nullable LevelBasedPermissionSet getOldLevel) implements Cancellable, PlayerEvent, RecordEvent { public static final CancellableEventBus BUS = CancellableEventBus.create(PermissionsChangedEvent.class); } 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 565f510979..7f700fa981 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/TradeWithVillagerEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/TradeWithVillagerEvent.java @@ -5,7 +5,7 @@ package net.minecraftforge.event.entity.player; -import net.minecraft.world.entity.npc.AbstractVillager; +import net.minecraft.world.entity.npc.villager.AbstractVillager; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.trading.MerchantOffer; import net.minecraftforge.eventbus.api.bus.EventBus; diff --git a/src/main/java/net/minecraftforge/event/network/ChannelRegistrationChangeEvent.java b/src/main/java/net/minecraftforge/event/network/ChannelRegistrationChangeEvent.java index f0d1bfc917..becf605e33 100644 --- a/src/main/java/net/minecraftforge/event/network/ChannelRegistrationChangeEvent.java +++ b/src/main/java/net/minecraftforge/event/network/ChannelRegistrationChangeEvent.java @@ -9,7 +9,7 @@ import java.util.Collections; import java.util.Set; import net.minecraft.network.Connection; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraftforge.eventbus.api.bus.EventBus; import net.minecraftforge.eventbus.api.event.RecordEvent; @@ -24,7 +24,7 @@ import net.minecraftforge.eventbus.api.event.RecordEvent; public record ChannelRegistrationChangeEvent( Connection getSource, Type getType, - Set getChannels + Set getChannels ) implements RecordEvent { public static final EventBus BUS = EventBus.create(ChannelRegistrationChangeEvent.class); diff --git a/src/main/java/net/minecraftforge/event/network/CustomPayloadEvent.java b/src/main/java/net/minecraftforge/event/network/CustomPayloadEvent.java index 3e92c606b2..b0d94e2f40 100644 --- a/src/main/java/net/minecraftforge/event/network/CustomPayloadEvent.java +++ b/src/main/java/net/minecraftforge/event/network/CustomPayloadEvent.java @@ -11,7 +11,7 @@ import io.netty.util.AttributeKey; import net.minecraft.server.level.ServerPlayer; import net.minecraft.network.PacketListener; import net.minecraft.network.protocol.PacketFlow; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.network.ServerGamePacketListenerImpl; import net.minecraft.network.Connection; import net.minecraft.network.FriendlyByteBuf; @@ -28,7 +28,7 @@ import java.util.concurrent.CompletableFuture; * If they do not handle it, then it is fired on its BUS. */ public record CustomPayloadEvent( - ResourceLocation getChannel, + Identifier getChannel, Object getPayloadObject, @Nullable FriendlyByteBuf getPayload, Context getSource, @@ -36,7 +36,7 @@ public record CustomPayloadEvent( ) implements RecordEvent { public static final EventBus BUS = EventBus.create(CustomPayloadEvent.class); - public CustomPayloadEvent(ResourceLocation channel, Object payload, Context source, int loginIndex) { + public CustomPayloadEvent(Identifier channel, Object payload, Context source, int loginIndex) { this(channel, payload, payload instanceof ForgePayload forge ? forge.data() : null, source, loginIndex); } diff --git a/src/main/java/net/minecraftforge/event/village/VillagerTradesEvent.java b/src/main/java/net/minecraftforge/event/village/VillagerTradesEvent.java index c874253599..696fa748e1 100644 --- a/src/main/java/net/minecraftforge/event/village/VillagerTradesEvent.java +++ b/src/main/java/net/minecraftforge/event/village/VillagerTradesEvent.java @@ -9,9 +9,9 @@ import java.util.List; import it.unimi.dsi.fastutil.ints.Int2ObjectMap; 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.minecraft.world.entity.npc.villager.VillagerData; +import net.minecraft.world.entity.npc.villager.VillagerProfession; +import net.minecraft.world.entity.npc.villager.VillagerTrades.ItemListing; import net.minecraftforge.event.server.ServerAboutToStartEvent; import net.minecraftforge.eventbus.api.bus.EventBus; import net.minecraftforge.eventbus.api.event.RecordEvent; diff --git a/src/main/java/net/minecraftforge/event/village/WandererTradesEvent.java b/src/main/java/net/minecraftforge/event/village/WandererTradesEvent.java index a88cfcaae2..b90983ec71 100644 --- a/src/main/java/net/minecraftforge/event/village/WandererTradesEvent.java +++ b/src/main/java/net/minecraftforge/event/village/WandererTradesEvent.java @@ -14,8 +14,8 @@ import net.minecraftforge.eventbus.api.event.InheritableEvent; import net.minecraftforge.eventbus.api.event.MutableEvent; import org.apache.commons.lang3.tuple.Pair; -import net.minecraft.Util; -import net.minecraft.world.entity.npc.VillagerTrades.ItemListing; +import net.minecraft.util.Util; +import net.minecraft.world.entity.npc.villager.VillagerTrades.ItemListing; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.server.ServerAboutToStartEvent; diff --git a/src/main/java/net/minecraftforge/fluids/FluidStack.java b/src/main/java/net/minecraftforge/fluids/FluidStack.java index bcf53a7792..6da3b04eb2 100644 --- a/src/main/java/net/minecraftforge/fluids/FluidStack.java +++ b/src/main/java/net/minecraftforge/fluids/FluidStack.java @@ -15,7 +15,7 @@ import net.minecraft.world.level.storage.ValueInput; import net.minecraft.world.level.storage.ValueOutput; import net.minecraft.world.item.ItemStack; import net.minecraft.nbt.CompoundTag; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.network.chat.Component; import net.minecraftforge.registries.ForgeRegistries; @@ -93,7 +93,7 @@ public class FluidStack { if (fluidNameString.isEmpty()) return EMPTY; - ResourceLocation fluidName = ResourceLocation.parse(fluidNameString.get()); + Identifier fluidName = Identifier.parse(fluidNameString.get()); Fluid fluid = ForgeRegistries.FLUIDS.getValue(fluidName); if (fluid == null) return EMPTY; @@ -112,7 +112,7 @@ public class FluidStack { if (fluidNameString.isEmpty()) return EMPTY; - ResourceLocation fluidName = ResourceLocation.parse(fluidNameString.get()); + Identifier fluidName = Identifier.parse(fluidNameString.get()); Fluid fluid = ForgeRegistries.FLUIDS.getValue(fluidName); if (fluid == null) return EMPTY; diff --git a/src/main/java/net/minecraftforge/fluids/FluidType.java b/src/main/java/net/minecraftforge/fluids/FluidType.java index 9fae7e0bf3..d10891e26c 100644 --- a/src/main/java/net/minecraftforge/fluids/FluidType.java +++ b/src/main/java/net/minecraftforge/fluids/FluidType.java @@ -6,21 +6,21 @@ package net.minecraftforge.fluids; import com.google.common.collect.ImmutableMap; -import net.minecraft.Util; import net.minecraft.core.BlockPos; import net.minecraft.core.particles.ParticleTypes; import net.minecraft.network.chat.Component; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvents; import net.minecraft.sounds.SoundSource; import net.minecraft.tags.FluidTags; +import net.minecraft.util.Util; +import net.minecraft.world.attribute.EnvironmentAttributes; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.item.ItemEntity; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.entity.vehicle.AbstractBoat; +import net.minecraft.world.entity.vehicle.boat.AbstractBoat; import net.minecraft.world.item.BucketItem; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Rarity; @@ -787,7 +787,7 @@ public class FluidType { * @see BucketItem#emptyContents(LivingEntity, Level, BlockPos, BlockHitResult) */ public boolean isVaporizedOnPlacement(Level level, BlockPos pos, FluidStack stack) { - if (level.dimensionType().ultraWarm()) { + if (level.environmentAttributes().getValue(EnvironmentAttributes.WATER_EVAPORATES, pos)) { return this == ForgeMod.WATER_TYPE.get() || this.getStateForPlacement(level, pos, stack).is(FluidTags.WATER); } return false; @@ -815,7 +815,7 @@ public class FluidType { @Override public String toString() { - @Nullable ResourceLocation name = ForgeRegistries.FLUID_TYPES.get().getKey(this); + @Nullable Identifier name = ForgeRegistries.FLUID_TYPES.get().getKey(this); return name != null ? name.toString() : "Unregistered FluidType"; } diff --git a/src/main/java/net/minecraftforge/fluids/capability/wrappers/BucketPickupHandlerWrapper.java b/src/main/java/net/minecraftforge/fluids/capability/wrappers/BucketPickupHandlerWrapper.java index 303e393f7a..ba80baf6f1 100644 --- a/src/main/java/net/minecraftforge/fluids/capability/wrappers/BucketPickupHandlerWrapper.java +++ b/src/main/java/net/minecraftforge/fluids/capability/wrappers/BucketPickupHandlerWrapper.java @@ -93,7 +93,7 @@ public class BucketPickupHandlerWrapper implements IFluidHandler { //Be loud if something went wrong LOGGER.error("Fluid removed without successfully being picked up. Fluid {} at {} in {} matched requested type, but after performing pickup was {}.", - ForgeRegistries.FLUIDS.getKey(fluidState.getType()), blockPos, world.dimension().location(), ForgeRegistries.FLUIDS.getKey(bucket.getFluid())); + ForgeRegistries.FLUIDS.getKey(fluidState.getType()), blockPos, world.dimension().identifier(), ForgeRegistries.FLUIDS.getKey(bucket.getFluid())); return FluidStack.EMPTY; } return extracted; diff --git a/src/main/java/net/minecraftforge/gametest/ForgeGameTestHooks.java b/src/main/java/net/minecraftforge/gametest/ForgeGameTestHooks.java index d31acf94d4..18f5e8c8dc 100644 --- a/src/main/java/net/minecraftforge/gametest/ForgeGameTestHooks.java +++ b/src/main/java/net/minecraftforge/gametest/ForgeGameTestHooks.java @@ -9,7 +9,7 @@ import net.minecraft.SharedConstants; import net.minecraft.gametest.framework.GameTestEnvironments; import net.minecraft.gametest.framework.GameTestHelper; import net.minecraft.gametest.framework.TestData; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.loading.FMLLoader; import org.jetbrains.annotations.ApiStatus; @@ -89,21 +89,21 @@ public class ForgeGameTestHooks { throw new IllegalArgumentException("Could not find modid for " + cls.getName()); } - private static ResourceLocation key(String namespace, String prefix, String path) { + private static Identifier key(String namespace, String prefix, String path) { if (path.indexOf(':') != -1) { - var rl = ResourceLocation.parse(path); + var rl = Identifier.parse(path); if (!prefix.isEmpty()) return rl.withPrefix(prefix); return rl; } - return ResourceLocation.fromNamespaceAndPath(namespace, prefix + path); + return Identifier.fromNamespaceAndPath(namespace, prefix + path); } - public record TestReference(Consumer consumer, TestData data) {} + public record TestReference(Consumer consumer, TestData data) {} - public static Map gatherTests(Class root, Object instance) { - var ret = new HashMap(); + public static Map gatherTests(Class root, Object instance) { + var ret = new HashMap(); var seen = new HashSet(); String class_prefix = getPrefix(root); String namespace = getNamespace(root); @@ -131,14 +131,14 @@ public class ForgeGameTestHooks { var name = key(namespace, prefix, gametest.name().isEmpty() ? snake(method.getName()) : gametest.name()); var structure = GameTest.DEFAULT_STRUCTURE.equals(gametest.structure()) - ? ResourceLocation.parse(gametest.structure()) + ? Identifier.parse(gametest.structure()) : key(namespace, "", gametest.structure()); var env = GameTestEnvironments.DEFAULT.equals(gametest.environment()) - ? ResourceLocation.withDefaultNamespace(gametest.environment()) + ? Identifier.withDefaultNamespace(gametest.environment()) : key(namespace, "", gametest.environment()); - var data = new TestData( + var data = new TestData( env, structure, gametest.maxTicks(), diff --git a/src/main/java/net/minecraftforge/items/wrapper/ShulkerItemStackInvWrapper.java b/src/main/java/net/minecraftforge/items/wrapper/ShulkerItemStackInvWrapper.java index 87ad4badee..4cfb9513e8 100644 --- a/src/main/java/net/minecraftforge/items/wrapper/ShulkerItemStackInvWrapper.java +++ b/src/main/java/net/minecraftforge/items/wrapper/ShulkerItemStackInvWrapper.java @@ -10,7 +10,7 @@ import net.minecraft.core.Direction; import net.minecraft.core.NonNullList; import net.minecraft.core.component.DataComponents; import net.minecraft.nbt.CompoundTag; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.world.ContainerHelper; import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.Item; diff --git a/src/main/java/net/minecraftforge/network/Channel.java b/src/main/java/net/minecraftforge/network/Channel.java index 1aee3cbdd4..29d1894313 100644 --- a/src/main/java/net/minecraftforge/network/Channel.java +++ b/src/main/java/net/minecraftforge/network/Channel.java @@ -18,7 +18,7 @@ import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.chat.Component; import net.minecraft.network.protocol.Packet; import net.minecraft.network.protocol.PacketFlow; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraftforge.event.network.CustomPayloadEvent; import net.minecraftforge.network.packets.LoginWrapper; @@ -31,16 +31,16 @@ public abstract class Channel { this.instance = instance; } - public ResourceLocation getName() { + public Identifier getName() { return instance.getChannelName(); } /** * Retrieves the channel name to use for the specified packet * This typically is the main channel's name, but in some cases - * you want to specify a custom one. If your channel has {@link NetworkInstance#addChild(ResourceLocation) children} + * you want to specify a custom one. If your channel has {@link NetworkInstance#addChild(Identifier) children} */ - ResourceLocation getName(MSG packet) { + Identifier getName(MSG packet) { return getName(); } diff --git a/src/main/java/net/minecraftforge/network/ChannelBuilder.java b/src/main/java/net/minecraftforge/network/ChannelBuilder.java index bc06773bf6..809f1cadb3 100644 --- a/src/main/java/net/minecraftforge/network/ChannelBuilder.java +++ b/src/main/java/net/minecraftforge/network/ChannelBuilder.java @@ -15,7 +15,7 @@ import java.util.function.Supplier; import io.netty.util.AttributeKey; import net.minecraft.network.Connection; import net.minecraft.network.protocol.common.custom.CustomPacketPayload; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraftforge.network.Channel.VersionTest; import net.minecraftforge.network.payload.PayloadConnection; @@ -23,7 +23,7 @@ import net.minecraftforge.network.payload.PayloadConnection; * Builder for constructing impl channels using a builder style API. */ public class ChannelBuilder { - private final ResourceLocation name; + private final Identifier name; private int networkProtocolVersion = 0; private Channel.VersionTest clientAcceptedVersions; private Channel.VersionTest serverAcceptedVersions; @@ -36,18 +36,18 @@ public class ChannelBuilder { * @param channelName The name of the channel */ public static ChannelBuilder named(String channelName) { - return named(ResourceLocation.parse(channelName)); + return named(Identifier.parse(channelName)); } /** * Creates a new channel builder, The name of the channel must be unique. * @param channelName The name of the channel */ - public static ChannelBuilder named(ResourceLocation channelName) { + public static ChannelBuilder named(Identifier channelName) { return new ChannelBuilder(channelName); } - private ChannelBuilder(ResourceLocation name) { + private ChannelBuilder(Identifier name) { this.name = name; } diff --git a/src/main/java/net/minecraftforge/network/ChannelListManager.java b/src/main/java/net/minecraftforge/network/ChannelListManager.java index 403ba1a296..c3dd34a05f 100644 --- a/src/main/java/net/minecraftforge/network/ChannelListManager.java +++ b/src/main/java/net/minecraftforge/network/ChannelListManager.java @@ -6,12 +6,12 @@ package net.minecraftforge.network; import com.mojang.logging.LogUtils; -import net.minecraft.ResourceLocationException; +import net.minecraft.IdentifierException; import net.minecraft.network.Connection; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.codec.StreamCodec; import net.minecraft.network.protocol.common.custom.CustomPacketPayload; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraftforge.event.ForgeEventFactory; import net.minecraftforge.event.network.ChannelRegistrationChangeEvent; import net.minecraftforge.event.network.CustomPayloadEvent; @@ -31,7 +31,7 @@ import java.util.List; public class ChannelListManager { private static final Logger LOGGER = LogUtils.getLogger(); - public static final ResourceLocation NAME = ResourceLocation.fromNamespaceAndPath("forge", "channel_registration"); + public static final Identifier NAME = Identifier.fromNamespaceAndPath("forge", "channel_registration"); static final Channel CHANNEL = ChannelBuilder .named(NAME) @@ -86,11 +86,11 @@ public class ChannelListManager { addChannels(connection, NetworkRegistry.buildRegisterList()); } - public static void addChannels(Connection connection, ResourceLocation... channels) { + public static void addChannels(Connection connection, Identifier... channels) { addChannels(connection, Arrays.asList(channels)); } - public static void addChannels(Connection connection, Collection channels) { + public static void addChannels(Connection connection, Collection channels) { var list = NetworkContext.get(connection); var toSend = new HashSet(); for (var channel : channels) { @@ -102,11 +102,11 @@ public class ChannelListManager { CHANNEL.send(new Register(toSend.stream().sorted().toList()), connection); } - public static void removeChannels(Connection connection, ResourceLocation... channels) { + public static void removeChannels(Connection connection, Identifier... channels) { removeChannels(connection, Arrays.asList(channels)); } - public static void removeChannels(Connection connection, Collection channels) { + public static void removeChannels(Connection connection, Collection channels) { var list = NetworkContext.get(connection); var toSend = new HashSet(); for (var channel : channels) { @@ -146,15 +146,15 @@ public class ChannelListManager { } private static void updateFrom(CustomPayloadEvent.Context source, List channels, final ChannelRegistrationChangeEvent.Type changeType) { - var changed = new HashSet(); + var changed = new HashSet(); for (var channel : channels) { // It also says nothing about the format of channels so ignore bad channels. if (channel.isEmpty()) continue; try { - changed.add(ResourceLocation.parse(channel)); - } catch (ResourceLocationException ex) { + changed.add(Identifier.parse(channel)); + } catch (IdentifierException ex) { // Vanilla packet deserializers now force this to be a resource location, so we should never get this, but just in case. LOGGER.warn("Invalid channel name received: {}. Ignoring", channel); } diff --git a/src/main/java/net/minecraftforge/network/EventNetworkChannel.java b/src/main/java/net/minecraftforge/network/EventNetworkChannel.java index f50bcd2c69..cc65d5bfe7 100644 --- a/src/main/java/net/minecraftforge/network/EventNetworkChannel.java +++ b/src/main/java/net/minecraftforge/network/EventNetworkChannel.java @@ -6,7 +6,7 @@ package net.minecraftforge.network; import net.minecraft.network.FriendlyByteBuf; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraftforge.event.network.CustomPayloadEvent; import java.util.function.Consumer; @@ -20,7 +20,7 @@ import java.util.function.Supplier; * {@link CustomPayloadEvent.Context#enqueueWork(Runnable)} can be used to handle the message on the main server or client * thread. * - * @see ChannelBuilder#newEventChannel(ResourceLocation, Supplier, Predicate, Predicate) + * @see ChannelBuilder#newEventChannel(Identifier, Supplier, Predicate, Predicate) */ public class EventNetworkChannel extends Channel { EventNetworkChannel(NetworkInstance instance) { diff --git a/src/main/java/net/minecraftforge/network/ForgePacketHandler.java b/src/main/java/net/minecraftforge/network/ForgePacketHandler.java index f85c268fb8..9e89f184fc 100644 --- a/src/main/java/net/minecraftforge/network/ForgePacketHandler.java +++ b/src/main/java/net/minecraftforge/network/ForgePacketHandler.java @@ -7,7 +7,7 @@ package net.minecraftforge.network; import net.minecraft.network.Connection; import net.minecraft.network.chat.Component; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraftforge.common.ForgeHooks; import net.minecraftforge.common.util.LogMessageAdapter; import net.minecraftforge.event.network.CustomPayloadEvent; @@ -58,8 +58,8 @@ public class ForgePacketHandler { private static final Logger LOGGER = LogManager.getLogger(); private static final Marker MARKER = MarkerManager.getMarker("FORGE_PACKET_HANDLER"); - private Set registriesToReceive; - private Map registrySnapshots = new HashMap<>(); + private Set registriesToReceive; + private Map registrySnapshots = new HashMap<>(); private int nextAckId = 0; private Int2ObjectMap> pendingAcknowledgments = new Int2ObjectOpenHashMap<>(); @@ -110,7 +110,7 @@ public class ForgePacketHandler { void handleChannelVersions(ChannelVersions list, CustomPayloadEvent.Context ctx) { ctx.setPacketHandled(true); - LOGGER.debug(MARKER, "Received {} connection with channels [{}]", ctx.isClientSide() ? "server" : "client", list.channels().keySet().stream().map(ResourceLocation::toString).sorted().collect(Collectors.joining(", "))); + LOGGER.debug(MARKER, "Received {} connection with channels [{}]", ctx.isClientSide() ? "server" : "client", list.channels().keySet().stream().map(Identifier::toString).sorted().collect(Collectors.joining(", "))); var nctx = NetworkContext.get(ctx.getConnection()); nctx.channelList.clear(); nctx.channelList.putAll(list.channels()); @@ -152,8 +152,8 @@ public class ForgePacketHandler { var clientDataPackRegistries = DataPackRegistriesHooks.getSyncedCustomRegistries(); for (var key : list.datapacks()) { if (!clientDataPackRegistries.contains(key)) { - LOGGER.error(MARKER, "Missing required datapack registry: {}", key.location()); - missing.add(key.location().toString()); + LOGGER.error(MARKER, "Missing required datapack registry: {}", key.identifier()); + missing.add(key.identifier().toString()); } } @@ -209,13 +209,13 @@ public class ForgePacketHandler { // The error screen just wants mods, so lets guess based on registry entry namespaces // TODO: Make this sane... and fully test var missingMods = missingData.values().stream() - .map(ResourceLocation::getNamespace) + .map(Identifier::getNamespace) .distinct() .toList(); - var mismatched = new HashMap(); - var missing = new HashSet(); + var mismatched = new HashMap(); + var missing = new HashSet(); for (var id : missingMods) { - var key = ResourceLocation.fromNamespaceAndPath(id, ""); + var key = Identifier.fromNamespaceAndPath(id, ""); var container = ModList.get().getModContainerById(id).orElse(null); if (container != null) mismatched.put(key, new NetworkMismatchData.Version(container.getModInfo().getVersion().toString(), "")); diff --git a/src/main/java/net/minecraftforge/network/ForgePayload.java b/src/main/java/net/minecraftforge/network/ForgePayload.java index 4f7203f791..095f0374fb 100644 --- a/src/main/java/net/minecraftforge/network/ForgePayload.java +++ b/src/main/java/net/minecraftforge/network/ForgePayload.java @@ -14,20 +14,20 @@ import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.protocol.common.custom.CustomPacketPayload; import net.minecraft.network.protocol.login.custom.CustomQueryAnswerPayload; import net.minecraft.network.protocol.login.custom.CustomQueryPayload; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; @ApiStatus.Internal public record ForgePayload ( - ResourceLocation id, + Identifier id, @Nullable FriendlyByteBuf data, Consumer encoder ) implements CustomPacketPayload, CustomQueryPayload, CustomQueryAnswerPayload { - public static ForgePayload create(ResourceLocation id, FriendlyByteBuf data) { + public static ForgePayload create(Identifier id, FriendlyByteBuf data) { return new ForgePayload(id, data, buf -> buf.writeBytes(data.slice())); } - public static ForgePayload create(ResourceLocation id, Consumer encoder) { + public static ForgePayload create(Identifier id, Consumer encoder) { return new ForgePayload(id, null, encoder); } diff --git a/src/main/java/net/minecraftforge/network/NetworkContext.java b/src/main/java/net/minecraftforge/network/NetworkContext.java index 77ddef410e..a155b96653 100644 --- a/src/main/java/net/minecraftforge/network/NetworkContext.java +++ b/src/main/java/net/minecraftforge/network/NetworkContext.java @@ -16,7 +16,7 @@ import org.jetbrains.annotations.ApiStatus; import io.netty.util.AttributeKey; import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; import net.minecraft.network.Connection; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.network.ConfigurationTask; import net.minecraft.server.network.ServerConfigurationPacketListenerImpl; import net.minecraftforge.network.packets.ModVersions; @@ -60,7 +60,7 @@ public class NetworkContext { return this.netVersion; } - public Set getRemoteChannels() { + public Set getRemoteChannels() { return this.remoteChannelsView; } @@ -110,18 +110,18 @@ public class NetworkContext { } @ApiStatus.Internal - Set remoteChannels = new HashSet<>(); - private Set remoteChannelsView = Collections.unmodifiableSet(this.remoteChannels); + Set remoteChannels = new HashSet<>(); + private Set remoteChannelsView = Collections.unmodifiableSet(this.remoteChannels); @ApiStatus.Internal - Set sentChannels = new HashSet<>(); + Set sentChannels = new HashSet<>(); @ApiStatus.Internal Map modList = new HashMap<>(); private Map modListView = Collections.unmodifiableMap(modList); @ApiStatus.Internal - Map channelList = new Object2IntOpenHashMap<>(); + Map channelList = new Object2IntOpenHashMap<>(); // TODO Make this official API? This is to allow us to finish a task in the packet handlers and not the task function itself. @ApiStatus.Internal @@ -147,8 +147,8 @@ public class NetworkContext { @ApiStatus.Internal public record NetworkMismatchData( - Map mismatched, - Set missing, + Map mismatched, + Set missing, boolean fromServer, Map mods ) { diff --git a/src/main/java/net/minecraftforge/network/NetworkInitialization.java b/src/main/java/net/minecraftforge/network/NetworkInitialization.java index 244c71b31a..d5777d128e 100644 --- a/src/main/java/net/minecraftforge/network/NetworkInitialization.java +++ b/src/main/java/net/minecraftforge/network/NetworkInitialization.java @@ -6,7 +6,7 @@ package net.minecraftforge.network; import io.netty.util.AttributeKey; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraftforge.event.network.CustomPayloadEvent; import net.minecraftforge.network.packets.*; import org.apache.logging.log4j.LogManager; @@ -21,9 +21,9 @@ import java.util.function.BiConsumer; public final class NetworkInitialization { private static final Logger LOGGER = LogManager.getLogger(); private static final Marker MARKER = MarkerManager.getMarker("FORGE_NETWORK"); - public static final ResourceLocation LOGIN_NAME = ResourceLocation.fromNamespaceAndPath("forge", "login"); - private static final ResourceLocation HANDSHAKE_NAME = ResourceLocation.fromNamespaceAndPath("forge", "handshake"); - //private static final ResourceLocation PLAY_NAME = new ResourceLocation("forge", "network"); + public static final Identifier LOGIN_NAME = Identifier.fromNamespaceAndPath("forge", "login"); + private static final Identifier HANDSHAKE_NAME = Identifier.fromNamespaceAndPath("forge", "handshake"); + //private static final Identifier PLAY_NAME = new Identifier("forge", "network"); public static final AttributeKey CONTEXT = AttributeKey.newInstance(HANDSHAKE_NAME.toString()); public static final SimpleChannel LOGIN = ChannelBuilder diff --git a/src/main/java/net/minecraftforge/network/NetworkInstance.java b/src/main/java/net/minecraftforge/network/NetworkInstance.java index d63a512d3c..63d6d15ce0 100644 --- a/src/main/java/net/minecraftforge/network/NetworkInstance.java +++ b/src/main/java/net/minecraftforge/network/NetworkInstance.java @@ -6,7 +6,7 @@ package net.minecraftforge.network; import net.minecraft.network.Connection; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraftforge.event.network.CustomPayloadEvent; import net.minecraftforge.network.Channel.VersionTest; @@ -32,16 +32,16 @@ public final class NetworkInstance { // Should this be changed so that modders can fire other channel's handlers? private Collection> listeners = new ArrayList<>(); - private final ResourceLocation channelName; + private final Identifier channelName; private final int networkProtocolVersion; final VersionTest clientAcceptedVersions; final VersionTest serverAcceptedVersions; final Map, Function> attributes; final Consumer channelHandler; final ServerStatusPing.ChannelData pingData; - private final Set ids = new HashSet<>(); + private final Set ids = new HashSet<>(); - NetworkInstance(ResourceLocation channelName, int networkProtocolVersion, + NetworkInstance(Identifier channelName, int networkProtocolVersion, VersionTest clientAcceptedVersions, VersionTest serverAcceptedVersions, Map, Function> attributes, Consumer channelHandler ) { @@ -68,13 +68,13 @@ public final class NetworkInstance { * Registers another name that will have its CustomPayloadEvents redirected to this channel. * Like the main name, this must be unique across all channels. */ - public NetworkInstance addChild(ResourceLocation name) { + public NetworkInstance addChild(Identifier name) { NetworkRegistry.register(this, name); this.ids.add(name); return this; } - ResourceLocation getChannelName() { + Identifier getChannelName() { return channelName; } @@ -82,7 +82,7 @@ public final class NetworkInstance { return networkProtocolVersion; } - void registrationChange(ResourceLocation name, boolean registered) { + void registrationChange(Identifier name, boolean registered) { // TODO: Expose to listeners? } diff --git a/src/main/java/net/minecraftforge/network/NetworkProtocol.java b/src/main/java/net/minecraftforge/network/NetworkProtocol.java index d1b28c1722..7032dec6ed 100644 --- a/src/main/java/net/minecraftforge/network/NetworkProtocol.java +++ b/src/main/java/net/minecraftforge/network/NetworkProtocol.java @@ -18,7 +18,7 @@ import net.minecraft.network.PacketListener; import net.minecraft.network.RegistryFriendlyByteBuf; import net.minecraft.network.protocol.login.ClientboundCustomQueryPacket; import net.minecraft.network.protocol.login.ServerboundCustomQueryAnswerPacket; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; public class NetworkProtocol { public static final NetworkProtocol PLAY = new NetworkProtocol<>(ConnectionProtocol.PLAY); @@ -45,7 +45,7 @@ public class NetworkProtocol { } @SuppressWarnings("unchecked") - public Packet buildPacket(PacketFlow direction, ResourceLocation name, Consumer encoder) { + public Packet buildPacket(PacketFlow direction, Identifier name, Consumer encoder) { var payload = ForgePayload.create(name, (Consumer)encoder); switch (this.protocol) { diff --git a/src/main/java/net/minecraftforge/network/NetworkRegistry.java b/src/main/java/net/minecraftforge/network/NetworkRegistry.java index 586a52de3a..e1487cec00 100644 --- a/src/main/java/net/minecraftforge/network/NetworkRegistry.java +++ b/src/main/java/net/minecraftforge/network/NetworkRegistry.java @@ -6,7 +6,7 @@ package net.minecraftforge.network; import net.minecraft.network.Connection; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraftforge.event.ForgeEventFactory; import net.minecraftforge.network.Channel.VersionTest; import net.minecraftforge.network.NetworkContext.NetworkMismatchData; @@ -41,8 +41,8 @@ public class NetworkRegistry { static final Logger LOGGER = LogManager.getLogger(); static final Marker NETREGISTRY = MarkerManager.getMarker("NETREGISTRY"); - private static Map instances = Collections.synchronizedMap(new HashMap<>()); - private static Map byName = Collections.synchronizedMap(new HashMap<>()); + private static Map instances = Collections.synchronizedMap(new HashMap<>()); + private static Map byName = Collections.synchronizedMap(new HashMap<>()); public static boolean acceptsVanillaClientConnections() { return listRejectedVanillaMods(n -> n.clientAcceptedVersions).isEmpty() && DataPackRegistriesHooks.getSyncedCustomRegistries().isEmpty(); @@ -53,12 +53,12 @@ public class NetworkRegistry { } @Nullable - public static NetworkInstance findTarget(ResourceLocation resourceLocation) { - return byName.get(resourceLocation); + public static NetworkInstance findTarget(Identifier Identifier) { + return byName.get(Identifier); } - static Map buildChannelVersionsForListPing() { - var ret = new HashMap(); + static Map buildChannelVersionsForListPing() { + var ret = new HashMap(); for (var channel : instances.values()) { ret.put(channel.getChannelName(), channel.pingData); } @@ -84,11 +84,11 @@ public class NetworkRegistry { } @Nullable - public static NetworkMismatchData validateChannels(Map incoming, boolean fromClient) { + public static NetworkMismatchData validateChannels(Map incoming, boolean fromClient) { var originName = fromClient ? "client" : "server"; - Set missing = new HashSet<>(); - Map results = new HashMap<>(); + Set missing = new HashSet<>(); + Map results = new HashMap<>(); for (var net : instances.values()) { var name = net.getChannelName(); VersionTest test = fromClient ? net.clientAcceptedVersions : net.serverAcceptedVersions; @@ -121,8 +121,8 @@ public class NetworkRegistry { return null; } - public static boolean checkListPingCompatibilityForClient(Map incoming) { - Set handled = new HashSet<>(); + public static boolean checkListPingCompatibilityForClient(Map incoming) { + Set handled = new HashSet<>(); var rejected = new ArrayList(); for (var net : instances.values()) { @@ -178,23 +178,23 @@ public class NetworkRegistry { } } - public static Map buildChannelVersions() { - var ret = new Object2IntOpenHashMap(instances.size()); + public static Map buildChannelVersions() { + var ret = new Object2IntOpenHashMap(instances.size()); for (var net : instances.values()) { ret.put(net.getChannelName(), net.getNetworkProtocolVersion()); } return ret; } - static List buildRegisterList() { - var ret = new ArrayList(byName.keySet().size()); + static List buildRegisterList() { + var ret = new ArrayList(byName.keySet().size()); for (var name : byName.keySet()) if (!"minecraft".equals(name.getNamespace())) ret.add(name); return ret; } - static void register(NetworkInstance instance, ResourceLocation name) { + static void register(NetworkInstance instance, Identifier name) { checkLock(instance); if (NetworkRegistry.byName.containsKey(name)) error("Payload name " + name + " already registered."); diff --git a/src/main/java/net/minecraftforge/network/PayloadChannel.java b/src/main/java/net/minecraftforge/network/PayloadChannel.java index 9002cfa132..fab17e7719 100644 --- a/src/main/java/net/minecraftforge/network/PayloadChannel.java +++ b/src/main/java/net/minecraftforge/network/PayloadChannel.java @@ -13,7 +13,7 @@ import net.minecraft.network.protocol.Packet; import net.minecraft.network.protocol.PacketFlow; import net.minecraft.network.protocol.common.custom.CustomPacketPayload; import net.minecraft.network.protocol.common.custom.CustomPacketPayload.Type; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraftforge.event.network.CustomPayloadEvent; import net.minecraftforge.event.network.CustomPayloadEvent.Context; import net.minecraftforge.network.simple.handler.SimplePacket; @@ -37,7 +37,7 @@ import java.util.function.BiConsumer; final class PayloadChannel extends Channel { private static final Logger LOGGER = LogManager.getLogger(); private static final Marker MARKER = MarkerManager.getMarker("PAYLOAD_CHANNEL"); - private final Map> payloads; + private final Map> payloads; @ApiStatus.Internal private PayloadChannel(Builder builder) { @@ -53,7 +53,7 @@ final class PayloadChannel extends Channel { private final static class Builder implements PayloadConnection { private final NetworkInstance instance; private boolean built = false; - private final Map> payloads = new HashMap<>(); + private final Map> payloads = new HashMap<>(); private Builder(NetworkInstance instance) { this.instance = instance; @@ -194,7 +194,7 @@ final class PayloadChannel extends Channel { BiConsumer consumer ){ }; - private Message get(ResourceLocation type, boolean send) { + private Message get(Identifier type, boolean send) { @SuppressWarnings("unchecked") var msg = (Message)payloads.get(type); @@ -229,7 +229,7 @@ final class PayloadChannel extends Channel { } @Override - ResourceLocation getName(CustomPacketPayload packet) { + Identifier getName(CustomPacketPayload packet) { return packet.type().id(); } diff --git a/src/main/java/net/minecraftforge/network/ServerStatusPing.java b/src/main/java/net/minecraftforge/network/ServerStatusPing.java index 36f246b6fd..2db987c848 100644 --- a/src/main/java/net/minecraftforge/network/ServerStatusPing.java +++ b/src/main/java/net/minecraftforge/network/ServerStatusPing.java @@ -9,9 +9,9 @@ import com.mojang.serialization.Codec; import com.mojang.serialization.codecs.RecordCodecBuilder; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; -import net.minecraft.Util; +import net.minecraft.util.Util; import net.minecraft.network.FriendlyByteBuf; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraftforge.fml.IExtensionPoint; import net.minecraftforge.fml.ModList; @@ -74,7 +74,7 @@ import java.util.stream.Collectors; // TODO: Rewrite to a simpler format And/Or remove when I rewrite DisplayTest public record ServerStatusPing( - Map channels, + Map channels, Map mods, int fmlNetworkVer, boolean truncated @@ -125,13 +125,13 @@ public record ServerStatusPing( return Objects.hash(channels, mods, fmlNetworkVer); } - private List> getChannelsForMod(String modId) { + private List> getChannelsForMod(String modId) { return channels.entrySet().stream() .filter(c -> c.getKey().getNamespace().equals(modId)) .toList(); } - private List> getNonModChannels() { + private List> getNonModChannels() { return channels.entrySet().stream() .filter(c -> !mods.containsKey(c.getKey().getNamespace())) .toList(); @@ -140,7 +140,7 @@ public record ServerStatusPing( public ByteBuf toBuf() { // The following techniques are used to keep the size down: // 1. Try and group channels by ModID, this relies on the assumption that a mod "examplemod" uses a channel - // like "examplemod:network". In that case only the "path" of the ResourceLocation is written + // like "examplemod:network". In that case only the "path" of the Identifier is written // 2. Avoid sending IGNORESERVERONLY in plain text, instead use a flag (if set, no version string is sent) // // The size can be estimated as follows (assuming there are no non-mod network channels) @@ -191,7 +191,7 @@ public record ServerStatusPing( buf.writeVarInt(nonModChannels.size()); for (var entry : nonModChannels) { - buf.writeResourceLocation(entry.getKey()); + buf.writeIdentifier(entry.getKey()); buf.writeVarInt(entry.getValue().version()); buf.writeBoolean(entry.getValue().required()); } @@ -209,7 +209,7 @@ public record ServerStatusPing( private static ServerStatusPing deserializeOptimized(int fmlNetworkVersion, ByteBuf bbuf) { var buf = new FriendlyByteBuf(bbuf); boolean truncated; - Map channels; + Map channels; Map mods; try { @@ -227,7 +227,7 @@ public record ServerStatusPing( var channelName = buf.readUtf(); var channelVersion = buf.readVarInt(); var requiredOnClient = buf.readBoolean(); - final ResourceLocation id = ResourceLocation.fromNamespaceAndPath(modId, channelName); + final Identifier id = Identifier.fromNamespaceAndPath(modId, channelName); channels.put(id, new ChannelData(id, channelVersion, requiredOnClient)); } @@ -236,7 +236,7 @@ public record ServerStatusPing( var nonModChannelCount = buf.readVarInt(); for (var i = 0; i < nonModChannelCount; i++) { - var channelName = buf.readResourceLocation(); + var channelName = buf.readIdentifier(); var channelVersion = buf.readVarInt(); var requiredOnClient = buf.readBoolean(); channels.put(channelName, new ChannelData(channelName, channelVersion, requiredOnClient)); @@ -315,7 +315,7 @@ public record ServerStatusPing( return buf; } - public Map getRemoteChannels() { + public Map getRemoteChannels() { return this.channels; } @@ -338,9 +338,9 @@ public record ServerStatusPing( ).apply(in, ModInfo::new)); } - public record ChannelData(ResourceLocation res, int version, boolean required) { + public record ChannelData(Identifier res, int version, boolean required) { public static final Codec CODEC = RecordCodecBuilder.create(in -> in.group( - ResourceLocation.CODEC.fieldOf("res").forGetter(ChannelData::res), + Identifier.CODEC.fieldOf("res").forGetter(ChannelData::res), Codec.INT.fieldOf("version").forGetter(ChannelData::version), Codec.BOOL.fieldOf("required").forGetter(ChannelData::required) ).apply(in, ChannelData::new)); diff --git a/src/main/java/net/minecraftforge/network/filters/VanillaConnectionNetworkFilter.java b/src/main/java/net/minecraftforge/network/filters/VanillaConnectionNetworkFilter.java index e6cc463086..f690c28301 100644 --- a/src/main/java/net/minecraftforge/network/filters/VanillaConnectionNetworkFilter.java +++ b/src/main/java/net/minecraftforge/network/filters/VanillaConnectionNetworkFilter.java @@ -12,7 +12,7 @@ import io.netty.channel.ChannelHandler; import net.minecraft.network.protocol.Packet; import net.minecraft.network.Connection; import net.minecraft.network.protocol.game.ClientboundUpdateAttributesPacket; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraftforge.network.ConnectionType; import net.minecraftforge.network.NetworkContext; import net.minecraftforge.registries.ForgeRegistries; @@ -50,7 +50,7 @@ public class VanillaConnectionNetworkFilter extends VanillaPacketFilter { ClientboundUpdateAttributesPacket newPacket = new ClientboundUpdateAttributesPacket(msg.getEntityId(), Collections.emptyList()); msg.getValues().stream() .filter(snapshot -> { - ResourceLocation key = ForgeRegistries.ATTRIBUTES.getKey(snapshot.attribute().get()); + Identifier key = ForgeRegistries.ATTRIBUTES.getKey(snapshot.attribute().get()); return key != null && key.getNamespace().equals("minecraft"); }) .forEach(snapshot -> newPacket.getValues().add(snapshot)); @@ -69,7 +69,7 @@ public class VanillaConnectionNetworkFilter extends VanillaPacketFilter { return new ClientboundUpdateTagsPacket(tags); } - private static boolean isVanillaRegistry(ResourceLocation location) { + private static boolean isVanillaRegistry(Identifier location) { // Checks if the registry name is contained within the static view of both BuiltInRegistries and VanillaRegistries return RegistryManager.getVanillaRegistryKeys().contains(location) || VanillaRegistries.DATAPACK_REGISTRY_KEYS.stream().anyMatch(k -> k.location().equals(location)); diff --git a/src/main/java/net/minecraftforge/network/filters/VanillaPacketSplitter.java b/src/main/java/net/minecraftforge/network/filters/VanillaPacketSplitter.java index 5a04228958..3f257076ed 100644 --- a/src/main/java/net/minecraftforge/network/filters/VanillaPacketSplitter.java +++ b/src/main/java/net/minecraftforge/network/filters/VanillaPacketSplitter.java @@ -14,7 +14,7 @@ import io.netty.buffer.Unpooled; import net.minecraft.network.*; import net.minecraft.network.protocol.Packet; import net.minecraft.network.protocol.PacketFlow; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraftforge.network.*; import net.minecraftforge.network.event.EventNetworkChannel; @@ -29,7 +29,7 @@ public class VanillaPacketSplitter { private static final Logger LOGGER = LogManager.getLogger(); - private static final ResourceLocation CHANNEL = new ResourceLocation("forge", "split"); + private static final Identifier CHANNEL = new Identifier("forge", "split"); private static final String VERSION = "1.1"; private static final int PROTOCOL_MAX = CompressionDecoder.MAXIMUM_UNCOMPRESSED_LENGTH; diff --git a/src/main/java/net/minecraftforge/network/packets/ChannelVersions.java b/src/main/java/net/minecraftforge/network/packets/ChannelVersions.java index 7df44aab2f..66b1f25dbb 100644 --- a/src/main/java/net/minecraftforge/network/packets/ChannelVersions.java +++ b/src/main/java/net/minecraftforge/network/packets/ChannelVersions.java @@ -12,10 +12,10 @@ import org.jetbrains.annotations.NotNull; import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.codec.StreamCodec; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraftforge.network.NetworkRegistry; -public record ChannelVersions(Map channels) { +public record ChannelVersions(Map channels) { public static StreamCodec STREAM_CODEC = StreamCodec.ofMember(ChannelVersions::encode, ChannelVersions::decode); public ChannelVersions() { @@ -23,10 +23,10 @@ public record ChannelVersions(Map channels) } public static ChannelVersions decode(FriendlyByteBuf buf) { - return new ChannelVersions(buf.readMap(Object2IntOpenHashMap::new, FriendlyByteBuf::readResourceLocation, FriendlyByteBuf::readVarInt)); + return new ChannelVersions(buf.readMap(Object2IntOpenHashMap::new, FriendlyByteBuf::readIdentifier, FriendlyByteBuf::readVarInt)); } public void encode(FriendlyByteBuf buf) { - buf.writeMap(channels, FriendlyByteBuf::writeResourceLocation, FriendlyByteBuf::writeVarInt); + buf.writeMap(channels, FriendlyByteBuf::writeIdentifier, FriendlyByteBuf::writeVarInt); } } \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/network/packets/LoginWrapper.java b/src/main/java/net/minecraftforge/network/packets/LoginWrapper.java index 17fdf6dcbe..0e54fc09d5 100644 --- a/src/main/java/net/minecraftforge/network/packets/LoginWrapper.java +++ b/src/main/java/net/minecraftforge/network/packets/LoginWrapper.java @@ -8,12 +8,12 @@ package net.minecraftforge.network.packets; import io.netty.buffer.Unpooled; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.codec.StreamCodec; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraftforge.network.Channel; public class LoginWrapper { public static final StreamCodec STREAM_CODEC = StreamCodec.ofMember(LoginWrapper::encode, LoginWrapper::new); - private final ResourceLocation name; + private final Identifier name; private FriendlyByteBuf data; private final Channel channel; private final Object packet; @@ -23,11 +23,11 @@ public class LoginWrapper { } private LoginWrapper(FriendlyByteBuf buf) { - this(buf.readResourceLocation(), buf.wrap(buf.readBytes(buf.readVarInt())), null, null); + this(buf.readIdentifier(), buf.wrap(buf.readBytes(buf.readVarInt())), null, null); } @SuppressWarnings("unchecked") - private LoginWrapper(ResourceLocation name, FriendlyByteBuf data, Channel channel, Object packet) { + private LoginWrapper(Identifier name, FriendlyByteBuf data, Channel channel, Object packet) { this.name = name; this.data = data; this.channel = (Channel)channel; @@ -35,7 +35,7 @@ public class LoginWrapper { } public void encode(FriendlyByteBuf buf) { - buf.writeResourceLocation(name); + buf.writeIdentifier(name); if (data == null) { data = buf.wrap(Unpooled.buffer()); @@ -46,7 +46,7 @@ public class LoginWrapper { buf.writeBytes(data.slice()); } - public ResourceLocation name() { + public Identifier name() { return this.name; } diff --git a/src/main/java/net/minecraftforge/network/packets/MismatchData.java b/src/main/java/net/minecraftforge/network/packets/MismatchData.java index 22812fef0d..3f9fdac5a9 100644 --- a/src/main/java/net/minecraftforge/network/packets/MismatchData.java +++ b/src/main/java/net/minecraftforge/network/packets/MismatchData.java @@ -11,7 +11,7 @@ import java.util.Set; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.codec.StreamCodec; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraftforge.network.NetworkContext.NetworkMismatchData; import net.minecraftforge.network.NetworkContext.NetworkMismatchData.Version; @@ -20,8 +20,8 @@ import net.minecraftforge.network.NetworkContext.NetworkMismatchData.Version; * This packet also sends the data of a channel mismatch (currently, the ids and versions of the mismatched channels) to the client for it to display the correct information in said screen. */ public record MismatchData( - Map mismatched, - Set missing + Map mismatched, + Set missing ) { public static final StreamCodec STREAM_CODEC = StreamCodec.ofMember(MismatchData::encode, MismatchData::decode); private static final int MAX_LENGTH = 0x100; @@ -32,14 +32,14 @@ public record MismatchData( public static MismatchData decode(FriendlyByteBuf buf) { var mismatched = buf.readMap( - i -> ResourceLocation.parse(i.readUtf(MAX_LENGTH)), + i -> Identifier.parse(i.readUtf(MAX_LENGTH)), i -> new Version( i.readUtf(MAX_LENGTH), i.readUtf(MAX_LENGTH) ) ); var missing = buf.readCollection(HashSet::new, - i -> ResourceLocation.parse(i.readUtf(MAX_LENGTH)) + i -> Identifier.parse(i.readUtf(MAX_LENGTH)) ); return new MismatchData(mismatched, missing); } diff --git a/src/main/java/net/minecraftforge/network/packets/RegistryData.java b/src/main/java/net/minecraftforge/network/packets/RegistryData.java index 7b0e38706d..736af10f5f 100644 --- a/src/main/java/net/minecraftforge/network/packets/RegistryData.java +++ b/src/main/java/net/minecraftforge/network/packets/RegistryData.java @@ -7,19 +7,19 @@ package net.minecraftforge.network.packets; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.codec.StreamCodec; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraftforge.registries.ForgeRegistry.Snapshot; -public record RegistryData(int token, ResourceLocation name, Snapshot data) { +public record RegistryData(int token, Identifier name, Snapshot data) { public static final StreamCodec STREAM_CODEC = StreamCodec.ofMember(RegistryData::encode, RegistryData::decode); public void encode(FriendlyByteBuf buf) { buf.writeVarInt(token); - buf.writeResourceLocation(name); + buf.writeIdentifier(name); buf.writeBytes(data.getPacketData()); } public static RegistryData decode(FriendlyByteBuf buf) { - return new RegistryData(buf.readVarInt(), buf.readResourceLocation(), Snapshot.read(buf)); + return new RegistryData(buf.readVarInt(), buf.readIdentifier(), Snapshot.read(buf)); } } \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/network/packets/RegistryList.java b/src/main/java/net/minecraftforge/network/packets/RegistryList.java index 8ef37486b8..8b0109ca0f 100644 --- a/src/main/java/net/minecraftforge/network/packets/RegistryList.java +++ b/src/main/java/net/minecraftforge/network/packets/RegistryList.java @@ -10,13 +10,13 @@ import net.minecraft.core.Registry; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.codec.StreamCodec; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraftforge.registries.DataPackRegistriesHooks; import net.minecraftforge.registries.RegistryManager; public record RegistryList( int token, - List normal, + List normal, List>> datapacks) { public static final StreamCodec STREAM_CODEC = StreamCodec.ofMember(RegistryList::encode, RegistryList::decode); @@ -27,14 +27,14 @@ public record RegistryList( public static RegistryList decode(FriendlyByteBuf buf) { var token = buf.readVarInt(); - var normal = buf.readList(FriendlyByteBuf::readResourceLocation); - List>> datapacks = buf.readList(b -> ResourceKey.createRegistryKey(buf.readResourceLocation())); + var normal = buf.readList(FriendlyByteBuf::readIdentifier); + List>> datapacks = buf.readList(b -> ResourceKey.createRegistryKey(buf.readIdentifier())); return new RegistryList(token, normal, datapacks); } public void encode(FriendlyByteBuf buf) { buf.writeVarInt(token()); - buf.writeCollection(normal(), FriendlyByteBuf::writeResourceLocation); + buf.writeCollection(normal(), FriendlyByteBuf::writeIdentifier); buf.writeCollection(datapacks(), FriendlyByteBuf::writeResourceKey); } } \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/network/tasks/SyncRegistriesTask.java b/src/main/java/net/minecraftforge/network/tasks/SyncRegistriesTask.java index 99d7a0d611..26a6920dd7 100644 --- a/src/main/java/net/minecraftforge/network/tasks/SyncRegistriesTask.java +++ b/src/main/java/net/minecraftforge/network/tasks/SyncRegistriesTask.java @@ -16,7 +16,7 @@ import org.jetbrains.annotations.ApiStatus; import net.minecraft.network.chat.Component; import net.minecraft.network.protocol.Packet; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.network.ConfigurationTask; import net.minecraftforge.event.network.CustomPayloadEvent; import net.minecraftforge.network.ForgePacketHandler; @@ -39,7 +39,7 @@ public class SyncRegistriesTask implements ConfigurationTask { public static final Type TYPE = new Type("forge:sync_registries"); private ConfigurationTaskContext taskCtx; - private Map snapshot; + private Map snapshot; private ForgePacketHandler handler; private int expectedToken; diff --git a/src/main/java/net/minecraftforge/registries/DeferredRegister.java b/src/main/java/net/minecraftforge/registries/DeferredRegister.java index b39406da62..03e7a468f5 100644 --- a/src/main/java/net/minecraftforge/registries/DeferredRegister.java +++ b/src/main/java/net/minecraftforge/registries/DeferredRegister.java @@ -10,7 +10,7 @@ import com.google.common.collect.SetMultimap; import net.minecraft.core.Registry; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.tags.TagKey; import net.minecraftforge.eventbus.api.bus.BusGroup; import net.minecraftforge.fml.javafmlmod.FMLModContainer; @@ -59,7 +59,7 @@ public class DeferredRegister { * @param reg the forge registry to wrap * @param modid the namespace for all objects registered to this DeferredRegister * @see #create(ResourceKey, String) - * @see #create(ResourceLocation, String) + * @see #create(Identifier, String) */ public static DeferredRegister create(IForgeRegistry reg, String modid) { return new DeferredRegister<>(reg, modid); @@ -71,7 +71,7 @@ public class DeferredRegister { * @param reg the forge registry to wrap * @param modid the namespace for all objects registered to this DeferredRegister * @see #create(ResourceKey, String) - * @see #create(ResourceLocation, String) + * @see #create(Identifier, String) */ public static DeferredRegister create(RegistryHolder reg, String modid) { if (reg instanceof RegistryHolder holder) @@ -90,7 +90,7 @@ public class DeferredRegister { * @param modid the namespace for all objects registered to this DeferredRegister * @see #createOptional(ResourceKey, String) * @see #create(IForgeRegistry, String) - * @see #create(ResourceLocation, String) + * @see #create(Identifier, String) */ public static DeferredRegister create(ResourceKey> key, String modid) { return new DeferredRegister<>(key, modid, false); @@ -107,7 +107,7 @@ public class DeferredRegister { * @param modid the namespace for all objects registered to this DeferredRegister * @see #create(ResourceKey, String) * @see #create(IForgeRegistry, String) - * @see #create(ResourceLocation, String) + * @see #create(Identifier, String) */ public static DeferredRegister createOptional(ResourceKey> key, String modid) { return new DeferredRegister<>(key, modid, true); @@ -118,15 +118,15 @@ public class DeferredRegister { * to lookup based on the provided registry name. Supports both registries that already exist or do not exist yet. *

    * If the registry is never created, any {@link RegistryObject}s made from this DeferredRegister will throw an exception. - * To allow the optional existence of a registry without error, use {@link #createOptional(ResourceLocation, String)}. + * To allow the optional existence of a registry without error, use {@link #createOptional(Identifier, String)}. * * @param registryName The name of the registry, should include namespace. May come from another DeferredRegister through {@link #getRegistryName()}. * @param modid The namespace for all objects registered to this DeferredRegister - * @see #createOptional(ResourceLocation, String) + * @see #createOptional(Identifier, String) * @see #create(IForgeRegistry, String) * @see #create(ResourceKey, String) */ - public static DeferredRegister create(ResourceLocation registryName, String modid) { + public static DeferredRegister create(Identifier registryName, String modid) { return new DeferredRegister<>(ResourceKey.createRegistryKey(registryName), modid, false); } @@ -139,11 +139,11 @@ public class DeferredRegister { * * @param registryName The name of the registry, should include namespace. May come from another DeferredRegister through {@link #getRegistryName()}. * @param modid The namespace for all objects registered to this DeferredRegister - * @see #create(ResourceLocation, String) + * @see #create(Identifier, String) * @see #create(IForgeRegistry, String) * @see #create(ResourceKey, String) */ - public static DeferredRegister createOptional(ResourceLocation registryName, String modid) { + public static DeferredRegister createOptional(Identifier registryName, String modid) { return new DeferredRegister<>(ResourceKey.createRegistryKey(registryName), modid, true); } @@ -184,7 +184,7 @@ public class DeferredRegister { requireNonNull("name", name); requireNonNull("factory", factory); - var key = ResourceLocation.fromNamespaceAndPath(modid, name); + var key = Identifier.fromNamespaceAndPath(modid, name); RegistryObject ret; if (this.optionalRegistry) @@ -208,19 +208,19 @@ public class DeferredRegister { * Will always return null until after the {@link NewRegistryEvent} event fires. */ public RegistryHolder makeRegistry(final Supplier> sup) { - return makeRegistry(this.registryKey.location(), sup); + return makeRegistry(this.registryKey.identifier(), sup); } /** * Creates a ResourceKey based on the current modid and provided path as the location and the registry name linked to this DeferredRegister. - * To control the namespace, use {@link #key(ResourceLocation)}. + * To control the namespace, use {@link #key(Identifier)}. * - * @see #key(ResourceLocation) + * @see #key(Identifier) */ @NotNull public ResourceKey key(@NotNull String path) { requireNonNull("path", path); - return key(ResourceLocation.fromNamespaceAndPath(this.modid, path)); + return key(Identifier.fromNamespaceAndPath(this.modid, path)); } /** @@ -230,22 +230,22 @@ public class DeferredRegister { * @see #key(String) */ @NotNull - public ResourceKey key(@NotNull ResourceLocation location) { + public ResourceKey key(@NotNull Identifier location) { requireNonNull("location", location); return ResourceKey.create(getRegistryKey(), location); } /** * Creates a tag key based on the current modid and provided path as the location and the registry name linked to this DeferredRegister. - * To control the namespace, use {@link #createTagKey(ResourceLocation)}. + * To control the namespace, use {@link #createTagKey(Identifier)}. * - * @see #createTagKey(ResourceLocation) + * @see #createTagKey(Identifier) * @see #createOptionalTagKey(String, Set) */ @NotNull public TagKey createTagKey(@NotNull String path) { requireNonNull("path", path); - return createTagKey(ResourceLocation.fromNamespaceAndPath(this.modid, path)); + return createTagKey(Identifier.fromNamespaceAndPath(this.modid, path)); } /** @@ -253,10 +253,10 @@ public class DeferredRegister { * To use the current modid as the namespace, use {@link #createTagKey(String)}. * * @see #createTagKey(String) - * @see #createOptionalTagKey(ResourceLocation, Set) + * @see #createOptionalTagKey(Identifier, Set) */ @NotNull - public TagKey createTagKey(@NotNull ResourceLocation location) { + public TagKey createTagKey(@NotNull Identifier location) { requireNonNull("location", location); return TagKey.create(this.registryKey, location); } @@ -264,17 +264,17 @@ public class DeferredRegister { /** * Creates a tag key with the current modid and provided path that will use the set of defaults if the tag is not loaded from any datapacks. * Useful on the client side when a server may not provide a specific tag. - * To control the namespace, use {@link #createOptionalTagKey(ResourceLocation, Set)}. + * To control the namespace, use {@link #createOptionalTagKey(Identifier, Set)}. * * @see #createTagKey(String) - * @see #createTagKey(ResourceLocation) - * @see #createOptionalTagKey(ResourceLocation, Set) + * @see #createTagKey(Identifier) + * @see #createOptionalTagKey(Identifier, Set) * @see #addOptionalTagDefaults(TagKey, Set) */ @NotNull public TagKey createOptionalTagKey(@NotNull String path, @NotNull Set> defaults) { requireNonNull("path", path); - return createOptionalTagKey(ResourceLocation.fromNamespaceAndPath(this.modid, path), defaults); + return createOptionalTagKey(Identifier.fromNamespaceAndPath(this.modid, path), defaults); } /** @@ -283,12 +283,12 @@ public class DeferredRegister { * To use the current modid as the namespace, use {@link #createOptionalTagKey(String, Set)}. * * @see #createTagKey(String) - * @see #createTagKey(ResourceLocation) + * @see #createTagKey(Identifier) * @see #createOptionalTagKey(String, Set) * @see #addOptionalTagDefaults(TagKey, Set) */ @NotNull - public TagKey createOptionalTagKey(@NotNull ResourceLocation location, @NotNull Set> defaults) { + public TagKey createOptionalTagKey(@NotNull Identifier location, @NotNull Set> defaults) { TagKey tagKey = createTagKey(location); addOptionalTagDefaults(tagKey, defaults); @@ -302,7 +302,7 @@ public class DeferredRegister { * Useful on the client side when a server may not provide a specific tag. * * @see #createOptionalTagKey(String, Set) - * @see #createOptionalTagKey(ResourceLocation, Set) + * @see #createOptionalTagKey(Identifier, Set) */ public void addOptionalTagDefaults(@NotNull TagKey name, @NotNull Set> defaults) { requireNonNull("defaults", defaults); @@ -343,11 +343,11 @@ public class DeferredRegister { * @return The registry name stored in this deferred register. Useful for creating new deferred registers based on an existing one. */ @NotNull - public ResourceLocation getRegistryName() { - return this.registryKey.location(); + public Identifier getRegistryName() { + return this.registryKey.identifier(); } - private RegistryHolder makeRegistry(final ResourceLocation registryName, final Supplier> sup) { + private RegistryHolder makeRegistry(final Identifier registryName, final Supplier> sup) { if (registryName == null) throw new IllegalStateException("Cannot create a registry without specifying a registry name"); if (RegistryManager.ACTIVE.getRegistry(registryName) != null || this.registryFactory != null) diff --git a/src/main/java/net/minecraftforge/registries/DeferredRegisterData.java b/src/main/java/net/minecraftforge/registries/DeferredRegisterData.java index 77cc7c513a..8555028689 100644 --- a/src/main/java/net/minecraftforge/registries/DeferredRegisterData.java +++ b/src/main/java/net/minecraftforge/registries/DeferredRegisterData.java @@ -10,7 +10,7 @@ import net.minecraft.core.Registry; import net.minecraft.core.RegistrySetBuilder.RegistryBootstrap; import net.minecraft.data.worldgen.BootstrapContext; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.tags.TagKey; import net.minecraftforge.common.extensions.IForgeRegistrySetBuilder; import org.jetbrains.annotations.NotNull; @@ -177,7 +177,7 @@ public class DeferredRegisterData implements RegistryBootstrap { throw new IllegalStateException("Cannot register new entries to DeferredRegister after it has been used. You should use this in a static context"); requireNonNull("name", name); - var key = ResourceLocation.fromNamespaceAndPath(modid, name); + var key = Identifier.fromNamespaceAndPath(modid, name); RegistryObject ret = new RegistryObject<>(key, this.registryKey, this.modid); @@ -190,14 +190,14 @@ public class DeferredRegisterData implements RegistryBootstrap { /** * Creates a ResourceKey based on the current modid and provided path as the location and the registry name linked to this DeferredRegister. - * To control the namespace, use {@link #key(ResourceLocation)}. + * To control the namespace, use {@link #key(Identifier)}. * - * @see #key(ResourceLocation) + * @see #key(Identifier) */ @NotNull public ResourceKey key(@NotNull String path) { requireNonNull("path", path); - return key(ResourceLocation.fromNamespaceAndPath(this.modid, path)); + return key(Identifier.fromNamespaceAndPath(this.modid, path)); } /** @@ -207,22 +207,22 @@ public class DeferredRegisterData implements RegistryBootstrap { * @see #key(String) */ @NotNull - public ResourceKey key(@NotNull ResourceLocation location) { + public ResourceKey key(@NotNull Identifier location) { requireNonNull("location", location); return ResourceKey.create(getRegistryKey(), location); } /** * Creates a tag key based on the current modid and provided path as the location and the registry name linked to this DeferredRegister. - * To control the namespace, use {@link #createTagKey(ResourceLocation)}. + * To control the namespace, use {@link #createTagKey(Identifier)}. * - * @see #createTagKey(ResourceLocation) + * @see #createTagKey(Identifier) * @see #createOptionalTagKey(String, Set) */ @NotNull public TagKey createTagKey(@NotNull String path) { requireNonNull("path", path); - return createTagKey(ResourceLocation.fromNamespaceAndPath(this.modid, path)); + return createTagKey(Identifier.fromNamespaceAndPath(this.modid, path)); } /** @@ -230,10 +230,10 @@ public class DeferredRegisterData implements RegistryBootstrap { * To use the current modid as the namespace, use {@link #createTagKey(String)}. * * @see #createTagKey(String) - * @see #createOptionalTagKey(ResourceLocation, Set) + * @see #createOptionalTagKey(Identifier, Set) */ @NotNull - public TagKey createTagKey(@NotNull ResourceLocation location) { + public TagKey createTagKey(@NotNull Identifier location) { requireNonNull("location", location); return TagKey.create(this.registryKey, location); } @@ -263,8 +263,8 @@ public class DeferredRegisterData implements RegistryBootstrap { * @return The registry name stored in this deferred register. Useful for creating new deferred registers based on an existing one. */ @NotNull - public ResourceLocation getRegistryName() { - return this.registryKey.location(); + public Identifier getRegistryName() { + return this.registryKey.identifier(); } private static T requireNonNull(String name, T value) { diff --git a/src/main/java/net/minecraftforge/registries/ForgeRegistries.java b/src/main/java/net/minecraftforge/registries/ForgeRegistries.java index 4f0c9f2636..9a578f714e 100644 --- a/src/main/java/net/minecraftforge/registries/ForgeRegistries.java +++ b/src/main/java/net/minecraftforge/registries/ForgeRegistries.java @@ -9,7 +9,7 @@ import com.mojang.serialization.MapCodec; import net.minecraft.commands.synchronization.ArgumentTypeInfo; import net.minecraft.network.syncher.EntityDataSerializer; -import net.minecraft.world.entity.decoration.PaintingVariant; +import net.minecraft.world.entity.decoration.painting.PaintingVariant; import net.minecraft.world.item.ItemDisplayContext; import net.minecraft.world.item.crafting.RecipeType; import net.minecraft.world.level.block.Block; @@ -17,9 +17,8 @@ import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.ai.attributes.Attribute; import net.minecraft.world.entity.ai.memory.MemoryModuleType; import net.minecraft.world.entity.schedule.Activity; -import net.minecraft.world.entity.schedule.Schedule; import net.minecraft.world.entity.ai.sensing.SensorType; -import net.minecraft.world.entity.npc.VillagerProfession; +import net.minecraft.world.entity.npc.villager.VillagerProfession; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.inventory.MenuType; import net.minecraft.server.Bootstrap; @@ -34,7 +33,7 @@ import net.minecraft.stats.StatType; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.chunk.status.ChunkStatus; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.sounds.SoundEvent; import net.minecraft.world.level.biome.Biome; import net.minecraft.world.level.levelgen.feature.stateproviders.BlockStateProviderType; @@ -68,7 +67,7 @@ public class ForgeRegistries { } static final List> registries = new ArrayList<>(); private static final RegistryHolder registry(ResourceKey> key, Supplier> factory) { - var dr = DeferredRegister.create(key, key.location().getNamespace()); + var dr = DeferredRegister.create(key, key.identifier().getNamespace()); registries.add(dr); return dr.makeRegistry(factory); } @@ -96,7 +95,6 @@ public class ForgeRegistries { public static final IForgeRegistry POI_TYPES = active(Keys.POI_TYPES); public static final IForgeRegistry> MEMORY_MODULE_TYPES = active(Keys.MEMORY_MODULE_TYPES); public static final IForgeRegistry> SENSOR_TYPES = active(Keys.SENSOR_TYPES); - public static final IForgeRegistry SCHEDULES = active(Keys.SCHEDULES); public static final IForgeRegistry ACTIVITIES = active(Keys.ACTIVITIES); // Worldgen @@ -143,7 +141,6 @@ public class ForgeRegistries { public static final ResourceKey> POI_TYPES = key("point_of_interest_type"); public static final ResourceKey>> MEMORY_MODULE_TYPES = key("memory_module_type"); public static final ResourceKey>> SENSOR_TYPES = key("sensor_type"); - public static final ResourceKey> SCHEDULES = key("schedule"); public static final ResourceKey> ACTIVITIES = key("activity"); public static final ResourceKey>> WORLD_CARVERS = key("worldgen/carver"); public static final ResourceKey>> FEATURES = key("worldgen/feature"); @@ -171,7 +168,7 @@ public class ForgeRegistries { public static final ResourceKey> STRUCTURE_MODIFIERS = key("forge:structure_modifier"); private static ResourceKey> key(String name) { - return ResourceKey.createRegistryKey(ResourceLocation.parse(name)); + return ResourceKey.createRegistryKey(Identifier.parse(name)); } private static void init() {} diff --git a/src/main/java/net/minecraftforge/registries/ForgeRegistry.java b/src/main/java/net/minecraftforge/registries/ForgeRegistry.java index 0fc39de7a7..6c10c9b8cc 100644 --- a/src/main/java/net/minecraftforge/registries/ForgeRegistry.java +++ b/src/main/java/net/minecraftforge/registries/ForgeRegistry.java @@ -49,7 +49,7 @@ import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.ListTag; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.core.Registry; import net.minecraftforge.common.util.TablePrinter; import org.apache.logging.log4j.LogManager; @@ -70,11 +70,11 @@ public class ForgeRegistry implements IForgeRegistryInternal, IForgeRegist private static final Logger LOGGER = LogManager.getLogger(); private final RegistryManager stage; private final BiMap ids = HashBiMap.create(); - private final BiMap names = HashBiMap.create(); + private final BiMap names = HashBiMap.create(); private final BiMap, V> keys = HashBiMap.create(); - private final Map aliases = new HashMap<>(); + private final Map aliases = new HashMap<>(); final Map, ?> slaves = new HashMap<>(); - private final ResourceLocation defaultKey; + private final Identifier defaultKey; //private final ResourceKey defaultResourceKey; private final CreateCallback create; private final AddCallback add; @@ -84,8 +84,8 @@ public class ForgeRegistry implements IForgeRegistryInternal, IForgeRegist private final MissingFactory missing; private final BitSet availabilityMap; private final IntSet blocked = new IntOpenHashSet(); - private final Multimap overrides = ArrayListMultimap.create(); - private final Map> delegatesByName = new HashMap<>(); + private final Multimap overrides = ArrayListMultimap.create(); + private final Map> delegatesByName = new HashMap<>(); private final Map> delegatesByValue = new HashMap<>(); private final BiMap, V> owners = HashBiMap.create(); private final ForgeRegistryTagManager tagManager; @@ -98,13 +98,13 @@ public class ForgeRegistry implements IForgeRegistryInternal, IForgeRegist private V defaultValue = null; boolean isFrozen = false; - private final ResourceLocation name; + private final Identifier name; private final ResourceKey> key; private final RegistryBuilder builder; private final Codec codec = new RegistryCodec(); - ForgeRegistry(RegistryManager stage, ResourceLocation name, RegistryBuilder builder) { + ForgeRegistry(RegistryManager stage, Identifier name, RegistryBuilder builder) { this.name = name; this.key = ResourceKey.createRegistryKey(name); this.builder = builder; @@ -134,7 +134,7 @@ public class ForgeRegistry implements IForgeRegistryInternal, IForgeRegist } @Override - public void register(ResourceLocation key, V value) { + public void register(Identifier key, V value) { add(-1, key, value); } @@ -164,7 +164,7 @@ public class ForgeRegistry implements IForgeRegistryInternal, IForgeRegist } @Override - public ResourceLocation getRegistryName() { + public Identifier getRegistryName() { return this.name; } @@ -179,7 +179,7 @@ public class ForgeRegistry implements IForgeRegistryInternal, IForgeRegist } @Override - public boolean containsKey(ResourceLocation key) { + public boolean containsKey(Identifier key) { while (key != null) { if (this.names.containsKey(key)) return true; @@ -203,7 +203,7 @@ public class ForgeRegistry implements IForgeRegistryInternal, IForgeRegist } @Override - public V getValue(ResourceLocation key) { + public V getValue(Identifier key) { V ret = this.names.get(key); key = this.aliases.get(key); while (ret == null && key != null) { @@ -214,8 +214,8 @@ public class ForgeRegistry implements IForgeRegistryInternal, IForgeRegist } @Override - public ResourceLocation getKey(V value) { - return getResourceKey(value).map(ResourceKey::location).orElse(this.defaultKey); + public Identifier getKey(V value) { + return getResourceKey(value).map(ResourceKey::identifier).orElse(this.defaultKey); } @NotNull @@ -257,7 +257,7 @@ public class ForgeRegistry implements IForgeRegistryInternal, IForgeRegist @NotNull @Override - public Optional> getHolder(ResourceLocation location) { + public Optional> getHolder(Identifier location) { return Optional.ofNullable(this.getWrapper()).flatMap(wrapper -> wrapper.get(location)); } @@ -275,7 +275,7 @@ public class ForgeRegistry implements IForgeRegistryInternal, IForgeRegist @NotNull @Override - public Set getKeys() { + public Set getKeys() { return Collections.unmodifiableSet(this.names.keySet()); } @@ -315,7 +315,7 @@ public class ForgeRegistry implements IForgeRegistryInternal, IForgeRegist return ret == null ? -1 : ret.intValue(); } - public int getID(ResourceLocation name) { + public int getID(Identifier name) { return getID(this.names.get(name)); } @@ -324,7 +324,7 @@ public class ForgeRegistry implements IForgeRegistryInternal, IForgeRegist return ret == null ? -1 : ret.intValue(); } - private int getIDRaw(ResourceLocation name) { + private int getIDRaw(Identifier name) { return getIDRaw(this.names.get(name)); } @@ -346,7 +346,7 @@ public class ForgeRegistry implements IForgeRegistryInternal, IForgeRegist } @Nullable - public ResourceLocation getDefaultKey() { + public Identifier getDefaultKey() { return this.defaultKey; } @@ -355,17 +355,17 @@ public class ForgeRegistry implements IForgeRegistryInternal, IForgeRegist } @Override - public void register(int id, ResourceLocation key, V value) { + public void register(int id, Identifier key, V value) { add(id, key, value, key.getNamespace()); } - int add(int id, ResourceLocation key, V value) { + int add(int id, Identifier key, V value) { @SuppressWarnings("removal") final String owner = ModLoadingContext.get().getActiveNamespace(); return add(id, key, value, owner); } - int add(int id, ResourceLocation key, V value, String owner) { + int add(int id, Identifier key, V value, String owner) { Preconditions.checkNotNull(key, "Can't use a null-name for the registry, object %s.", value); Preconditions.checkNotNull(value, "Can't add null-object to the registry, name %s.", key); @@ -430,7 +430,7 @@ public class ForgeRegistry implements IForgeRegistryInternal, IForgeRegist return idToUse; } - public V getRaw(ResourceLocation key) { + public V getRaw(Identifier key) { V ret = this.names.get(key); key = this.aliases.get(key); while (ret == null && key != null) { @@ -448,7 +448,7 @@ public class ForgeRegistry implements IForgeRegistryInternal, IForgeRegist * * TODO: Add as public API in IForgeRegistry and DeferredRegister. */ - public void addAlias(ResourceLocation src, ResourceLocation dst) { + public void addAlias(Identifier src, Identifier dst) { if (this.isLocked()) throw new IllegalStateException(String.format(Locale.ENGLISH, "Attempted to register the alias %s -> %s too late", src, dst)); @@ -464,7 +464,7 @@ public class ForgeRegistry implements IForgeRegistryInternal, IForgeRegist @NotNull @Override public Optional> getDelegate(ResourceKey rkey) { - return Optional.ofNullable(delegatesByName.get(rkey.location())); + return Optional.ofNullable(delegatesByName.get(rkey.identifier())); } @NotNull @@ -475,13 +475,13 @@ public class ForgeRegistry implements IForgeRegistryInternal, IForgeRegist @NotNull @Override - public Optional> getDelegate(ResourceLocation key) { + public Optional> getDelegate(Identifier key) { return Optional.ofNullable(delegatesByName.get(key)); } @NotNull @Override - public Holder.Reference getDelegateOrThrow(ResourceLocation key) { + public Holder.Reference getDelegateOrThrow(Identifier key) { return getDelegate(key).orElseThrow(() -> new IllegalArgumentException(String.format(Locale.ENGLISH, "No delegate exists for key %s", key))); } @@ -498,7 +498,7 @@ public class ForgeRegistry implements IForgeRegistryInternal, IForgeRegist } private Holder.Reference bindDelegate(ResourceKey rkey, V value) { - Holder.Reference delegate = delegatesByName.computeIfAbsent(rkey.location(), k -> Holder.Reference.createStandAlone(this.getWrapperOrThrow(), rkey)); + Holder.Reference delegate = delegatesByName.computeIfAbsent(rkey.identifier(), k -> Holder.Reference.createStandAlone(this.getWrapperOrThrow(), rkey)); delegate.bindKey(rkey); delegate.bindValue(value); delegatesByValue.put(value, delegate); @@ -512,7 +512,7 @@ public class ForgeRegistry implements IForgeRegistryInternal, IForgeRegist for (Entry, V> entry : this.keys.entrySet()) bindDelegate(entry.getKey(), entry.getValue()); - for (Entry entry : this.overrides.entries()) + for (Entry entry : this.overrides.entries()) bindDelegate(ResourceKey.create(this.key, entry.getKey()), entry.getValue()); } @@ -520,10 +520,10 @@ public class ForgeRegistry implements IForgeRegistryInternal, IForgeRegist return this.defaultValue; } - void validateContent(ResourceLocation registryName) { + void validateContent(Identifier registryName) { for (V obj : this) { int id = getID(obj); - ResourceLocation name = getKey(obj); + Identifier name = getKey(obj); // name lookup failed -> obj is not in the obj<->name map if (name == null) @@ -562,7 +562,7 @@ public class ForgeRegistry implements IForgeRegistryInternal, IForgeRegist this.bake.onBake(this, this.stage); } - void sync(ResourceLocation name, ForgeRegistry from) { + void sync(Identifier name, ForgeRegistry from) { LOGGER.debug(REGISTRIES,"Registry {} Sync: {} -> {}", this.name, this.stage.getName(), from.stage.getName()); if (this == from) throw new IllegalArgumentException("WTF We are the same!?!?!"); @@ -593,7 +593,7 @@ public class ForgeRegistry implements IForgeRegistryInternal, IForgeRegist boolean errored = false; - for (Entry entry : from.names.entrySet()) { + for (Entry entry : from.names.entrySet()) { List overrides = new ArrayList<>(from.overrides.get(entry.getKey())); int id = from.getID(entry.getKey()); if (overrides.isEmpty()) { @@ -646,7 +646,7 @@ public class ForgeRegistry implements IForgeRegistryInternal, IForgeRegist } @Override - public V remove(ResourceLocation key) { + public V remove(Identifier key) { if (!this.isModifiable) throw new UnsupportedOperationException("Attempted to remove from a non-modifiable Forge Registry"); @@ -697,7 +697,7 @@ public class ForgeRegistry implements IForgeRegistryInternal, IForgeRegist wrapper.locked = false; } - void dump(ResourceLocation name) { + void dump(Identifier name) { // Building a good looking table is not cheap, so only do it if the debug logger is enabled. if (LOGGER.isDebugEnabled(REGISTRYDUMP)) { TablePrinter tab = new TablePrinter() @@ -720,10 +720,10 @@ public class ForgeRegistry implements IForgeRegistryInternal, IForgeRegist private record DumpRow(String id, String key, String value) {} - public void loadIds(Object2IntMap ids, Map overrides, Object2IntMap missing, Map remapped, ForgeRegistry old, ResourceLocation name) { - Map ovs = new HashMap<>(overrides); - for (Object2IntMap.Entry entry : ids.object2IntEntrySet()) { - ResourceLocation itemName = entry.getKey(); + public void loadIds(Object2IntMap ids, Map overrides, Object2IntMap missing, Map remapped, ForgeRegistry old, Identifier name) { + Map ovs = new HashMap<>(overrides); + for (Object2IntMap.Entry entry : ids.object2IntEntrySet()) { + Identifier itemName = entry.getKey(); int newId = entry.getIntValue(); int currId = old.getIDRaw(itemName); @@ -772,8 +772,8 @@ public class ForgeRegistry implements IForgeRegistryInternal, IForgeRegist ovs.remove(itemName); } - for (Map.Entry entry : ovs.entrySet()) { - ResourceLocation itemName = entry.getKey(); + for (Map.Entry entry : ovs.entrySet()) { + Identifier itemName = entry.getKey(); String owner = entry.getValue(); String current = this.owners.inverse().get(this.getRaw(itemName)).owner; if (!owner.equals(current)) { @@ -807,9 +807,9 @@ public class ForgeRegistry implements IForgeRegistryInternal, IForgeRegist return ret; } - Map getOverrideOwners() { - Map ret = new HashMap<>(); - for (ResourceLocation key : this.overrides.keySet()) { + Map getOverrideOwners() { + Map ret = new HashMap<>(); + for (Identifier key : this.overrides.keySet()) { V obj = this.names.get(key); OverrideOwner owner = this.owners.inverse().get(obj); if (owner == null) @@ -831,7 +831,7 @@ public class ForgeRegistry implements IForgeRegistryInternal, IForgeRegist return DataResult.success(val); }).map(v -> Pair.of(v, ops.empty())); } else { - return ResourceLocation.CODEC.decode(ops, input).flatMap(keyValuePair -> !ForgeRegistry.this.containsKey(keyValuePair.getFirst()) + return Identifier.CODEC.decode(ops, input).flatMap(keyValuePair -> !ForgeRegistry.this.containsKey(keyValuePair.getFirst()) ? DataResult.error(() -> "Unknown registry key in " + ForgeRegistry.this.key + ": " + keyValuePair.getFirst()) : DataResult.success(keyValuePair.mapFirst(ForgeRegistry.this::getValue))); } @@ -839,7 +839,7 @@ public class ForgeRegistry implements IForgeRegistryInternal, IForgeRegist @Override public DataResult encode(V input, DynamicOps ops, T prefix) { - ResourceLocation key = getKey(input); + Identifier key = getKey(input); if (key == null) return DataResult.error(() -> "Unknown registry element in " + ForgeRegistry.this.key + ": " + input); T toMerge = ops.compressMaps() ? ops.createInt(getID(input)) : ops.createString(key.toString()); @@ -848,11 +848,11 @@ public class ForgeRegistry implements IForgeRegistryInternal, IForgeRegist } public static class Snapshot { - private static final Comparator sorter = ResourceLocation::compareNamespaced; - public final Object2IntMap ids = new Object2IntRBTreeMap<>(sorter); - public final Map aliases = new TreeMap<>(sorter); + private static final Comparator sorter = Identifier::compareNamespaced; + public final Object2IntMap ids = new Object2IntRBTreeMap<>(sorter); + public final Map aliases = new TreeMap<>(sorter); public final IntSet blocked = new IntRBTreeSet(); - public final Map overrides = new TreeMap<>(sorter); + public final Map overrides = new TreeMap<>(sorter); private FriendlyByteBuf binary = null; public CompoundTag write() { @@ -897,15 +897,15 @@ public class ForgeRegistry implements IForgeRegistryInternal, IForgeRegist return ret; nbt.getListOrEmpty("ids").compoundStream().forEach(comp -> - ret.ids.put(ResourceLocation.parse(comp.getString("K").orElseThrow()), comp.getIntOr("V", 0)) + ret.ids.put(Identifier.parse(comp.getString("K").orElseThrow()), comp.getIntOr("V", 0)) ); nbt.getListOrEmpty("aliases").compoundStream().forEach(comp -> - ret.aliases.put(ResourceLocation.parse(comp.getString("K").orElseThrow()), ResourceLocation.parse(comp.getString("V").orElseThrow())) + ret.aliases.put(Identifier.parse(comp.getString("K").orElseThrow()), Identifier.parse(comp.getString("V").orElseThrow())) ); nbt.getListOrEmpty("overrides").compoundStream().forEach(comp -> - ret.overrides.put(ResourceLocation.parse(comp.getString("K").orElseThrow()), comp.getString("V").orElseThrow()) + ret.overrides.put(Identifier.parse(comp.getString("K").orElseThrow()), comp.getString("V").orElseThrow()) ); nbt.getIntArray("blocked").ifPresent(blocked -> { @@ -919,9 +919,9 @@ public class ForgeRegistry implements IForgeRegistryInternal, IForgeRegist public synchronized FriendlyByteBuf getPacketData() { if (binary == null) { FriendlyByteBuf pkt = new FriendlyByteBuf(Unpooled.buffer()); - pkt.writeMap(this.ids, FriendlyByteBuf::writeResourceLocation, FriendlyByteBuf::writeVarInt); - pkt.writeMap(this.aliases, FriendlyByteBuf::writeResourceLocation, FriendlyByteBuf::writeResourceLocation); - pkt.writeMap(this.overrides, FriendlyByteBuf::writeResourceLocation, (b,v) -> b.writeUtf(v, 0x100)); + pkt.writeMap(this.ids, FriendlyByteBuf::writeIdentifier, FriendlyByteBuf::writeVarInt); + pkt.writeMap(this.aliases, FriendlyByteBuf::writeIdentifier, FriendlyByteBuf::writeIdentifier); + pkt.writeMap(this.overrides, FriendlyByteBuf::writeIdentifier, (b,v) -> b.writeUtf(v, 0x100)); pkt.writeCollection(this.blocked, FriendlyByteBuf::writeVarInt); this.binary = pkt; } @@ -934,23 +934,23 @@ public class ForgeRegistry implements IForgeRegistryInternal, IForgeRegist return new Snapshot(); var ret = new Snapshot(); - ret.ids.putAll(buf.readMap(FriendlyByteBuf::readResourceLocation, FriendlyByteBuf::readVarInt)); - ret.aliases.putAll(buf.readMap(FriendlyByteBuf::readResourceLocation, FriendlyByteBuf::readResourceLocation)); - ret.overrides.putAll(buf.readMap(FriendlyByteBuf::readResourceLocation, b -> b.readUtf(0x100))); + ret.ids.putAll(buf.readMap(FriendlyByteBuf::readIdentifier, FriendlyByteBuf::readVarInt)); + ret.aliases.putAll(buf.readMap(FriendlyByteBuf::readIdentifier, FriendlyByteBuf::readIdentifier)); + ret.overrides.putAll(buf.readMap(FriendlyByteBuf::readIdentifier, b -> b.readUtf(0x100))); ret.blocked.addAll(buf.readList(FriendlyByteBuf::readVarInt)); return ret; } } @SuppressWarnings("unchecked") - public MissingMappingsEvent getMissingEvent(ResourceLocation name, Object2IntMap map) { + public MissingMappingsEvent getMissingEvent(Identifier name, Object2IntMap map) { List> lst = new ArrayList<>(); ForgeRegistry pool = RegistryManager.ACTIVE.getRegistry(name); map.object2IntEntrySet().forEach(entry -> lst.add(new MissingMappingsEvent.Mapping<>(this, pool, entry.getKey(), entry.getIntValue()))); return new MissingMappingsEvent(ResourceKey.createRegistryKey(name), this, (Collection>) (Collection) lst); } - void processMissingEvent(ResourceLocation name, ForgeRegistry pool, List> mappings, Object2IntMap missing, Map remaps, Collection defaulted, Collection failed, boolean injectNetworkDummies) { + void processMissingEvent(Identifier name, ForgeRegistry pool, List> mappings, Object2IntMap missing, Map remaps, Collection defaulted, Collection failed, boolean injectNetworkDummies) { LOGGER.debug(REGISTRIES,"Processing missing event for {}:", name); int ignored = 0; @@ -960,7 +960,7 @@ public class ForgeRegistry implements IForgeRegistryInternal, IForgeRegist if (action == MissingMappingsEvent.Action.REMAP) { // entry re-mapped, finish the registration with the new name/object, but the old id int currId = getID(remap.target); - ResourceLocation newName = pool.getKey(remap.target); + Identifier newName = pool.getKey(remap.target); LOGGER.debug(REGISTRIES," Remapping {} -> {}.", remap.key, newName); missing.removeInt(remap.key); diff --git a/src/main/java/net/minecraftforge/registries/ForgeRegistryTag.java b/src/main/java/net/minecraftforge/registries/ForgeRegistryTag.java index d86bc9afb8..01240dfc78 100644 --- a/src/main/java/net/minecraftforge/registries/ForgeRegistryTag.java +++ b/src/main/java/net/minecraftforge/registries/ForgeRegistryTag.java @@ -5,7 +5,7 @@ package net.minecraftforge.registries; -import net.minecraft.Util; +import net.minecraft.util.Util; import net.minecraft.core.Holder; import net.minecraft.core.HolderSet; import net.minecraft.tags.TagKey; @@ -17,7 +17,6 @@ import org.jetbrains.annotations.Nullable; import java.util.Iterator; import java.util.List; import java.util.Optional; -import java.util.Random; import java.util.Spliterator; import java.util.stream.Stream; diff --git a/src/main/java/net/minecraftforge/registries/ForgeRegistryTagManager.java b/src/main/java/net/minecraftforge/registries/ForgeRegistryTagManager.java index 80b2a7103b..0fd9a33dc4 100644 --- a/src/main/java/net/minecraftforge/registries/ForgeRegistryTagManager.java +++ b/src/main/java/net/minecraftforge/registries/ForgeRegistryTagManager.java @@ -7,7 +7,7 @@ package net.minecraftforge.registries; import com.google.common.collect.Iterators; import net.minecraft.core.HolderSet; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.tags.TagKey; import net.minecraftforge.registries.tags.IReverseTag; import net.minecraftforge.registries.tags.ITag; @@ -100,14 +100,14 @@ class ForgeRegistryTagManager implements ITagManager { @NotNull @Override - public TagKey createTagKey(@NotNull ResourceLocation location) { + public TagKey createTagKey(@NotNull Identifier location) { Objects.requireNonNull(location); return TagKey.create(this.owner.getRegistryKey(), location); } @NotNull @Override - public TagKey createOptionalTagKey(@NotNull ResourceLocation location, @NotNull Set> defaults) { + public TagKey createOptionalTagKey(@NotNull Identifier location, @NotNull Set> defaults) { TagKey tagKey = createTagKey(location); addOptionalTagDefaults(tagKey, defaults); diff --git a/src/main/java/net/minecraftforge/registries/GameData.java b/src/main/java/net/minecraftforge/registries/GameData.java index 840af7cad6..ea39ca668b 100644 --- a/src/main/java/net/minecraftforge/registries/GameData.java +++ b/src/main/java/net/minecraftforge/registries/GameData.java @@ -36,7 +36,7 @@ import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.core.registries.Registries; import net.minecraft.network.syncher.EntityDataSerializer; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.SpawnPlacements; import net.minecraft.world.entity.ai.attributes.Attribute; @@ -88,8 +88,8 @@ public class GameData { private static boolean hasInit = false; private static final boolean DISABLE_VANILLA_REGISTRIES = Boolean.parseBoolean(System.getProperty("forge.disableVanillaGameData", "false")); // Use for unit tests/debugging - private static final BiConsumer> LOCK_VANILLA = (name, reg) -> reg.slaves.values().stream().filter(o -> o instanceof ILockableRegistry).forEach(o -> ((ILockableRegistry)o).lock()); - private static Set vanillaRegistryOrder = null; + private static final BiConsumer> LOCK_VANILLA = (name, reg) -> reg.slaves.values().stream().filter(o -> o instanceof ILockableRegistry).forEach(o -> ((ILockableRegistry)o).lock()); + private static Set vanillaRegistryOrder = null; static { init(); @@ -131,7 +131,6 @@ public class GameData { makeRegistry(Keys.POI_TYPES).addCallback(PoiTypeCallbacks.INSTANCE).disableSync().create(); makeRegistry(Keys.MEMORY_MODULE_TYPES, "dummy").disableSync().create(); makeRegistry(Keys.SENSOR_TYPES, "dummy").disableSaving().disableSync().create(); - makeRegistry(Keys.SCHEDULES).disableSaving().disableSync().create(); makeRegistry(Keys.ACTIVITIES).disableSaving().disableSync().create(); // Worldgen @@ -165,25 +164,25 @@ public class GameData { static RegistryBuilder getItemDisplayContextRegistryBuilder() { return new RegistryBuilder() .setMaxID(128 * 2) /* 0 -> 127 gets positive ID, 128 -> 256 gets negative ID */.disableOverrides().disableSaving() - .setDefaultKey(ResourceLocation.withDefaultNamespace("none")) + .setDefaultKey(Identifier.withDefaultNamespace("none")) .onAdd(ItemDisplayContext.ADD_CALLBACK); } private static RegistryBuilder makeRegistry(ResourceKey> key) { - return new RegistryBuilder().setName(key.location()).setMaxID(MAX_VARINT).hasWrapper(); + return new RegistryBuilder().setName(key.identifier()).setMaxID(MAX_VARINT).hasWrapper(); } private static RegistryBuilder makeRegistry(ResourceKey> key, int min, int max) { - return new RegistryBuilder().setName(key.location()).setIDRange(min, max).hasWrapper(); + return new RegistryBuilder().setName(key.identifier()).setIDRange(min, max).hasWrapper(); } private static RegistryBuilder makeRegistry(ResourceKey> key, String _default) { - return new RegistryBuilder().setName(key.location()).setMaxID(MAX_VARINT).hasWrapper().setDefaultKey(ResourceLocation.parse(_default)); + return new RegistryBuilder().setName(key.identifier()).setMaxID(MAX_VARINT).hasWrapper().setDefaultKey(Identifier.parse(_default)); } @SuppressWarnings("unchecked") public static > R getWrapper(ResourceKey> key, R vanilla) { - var reg = RegistryManager.ACTIVE.getRegistry(key.location()); + var reg = RegistryManager.ACTIVE.getRegistry(key.identifier()); if (reg == null) return vanilla; @@ -195,13 +194,13 @@ public class GameData { var wrapperD = wrapper instanceof DefaultedRegistry tmp ? tmp : null; if (vanillaD == null && wrapperD != null) - throw new IllegalStateException("Invalid wrapper " + key.location() + " was defaulted when not expected"); + throw new IllegalStateException("Invalid wrapper " + key.identifier() + " was defaulted when not expected"); if (vanillaD != null && wrapperD == null) - throw new IllegalStateException("Invalid wrapper " + key.location() + " was normal when should be expected"); + throw new IllegalStateException("Invalid wrapper " + key.identifier() + " was normal when should be expected"); if (vanillaD != null && !vanillaD.getDefaultKey().equals(wrapperD.getDefaultKey())) - throw new IllegalStateException("Invalid wrapper " + key.location() + " mismatched default key " + vanillaD.getDefaultKey() + " != " + wrapperD.getDefaultKey()); + throw new IllegalStateException("Invalid wrapper " + key.identifier() + " mismatched default key " + vanillaD.getDefaultKey() + " != " + wrapperD.getDefaultKey()); return (R)wrapper; } @@ -319,7 +318,7 @@ public class GameData { LOGGER.debug(REGISTRIES, "{} state restored.", target.getName()); } - public static void revert(RegistryManager state, ResourceLocation registry, boolean lock) { + public static void revert(RegistryManager state, Identifier registry, boolean lock) { LOGGER.debug(REGISTRIES, "Reverting {} to {}", registry, state.getName()); loadRegistry(registry, state, RegistryManager.ACTIVE, lock); LOGGER.debug(REGISTRIES, "Reverting complete"); @@ -327,22 +326,22 @@ public class GameData { @SuppressWarnings("deprecation") public static void postRegisterEvents() { - Set keySet = new HashSet<>(RegistryManager.ACTIVE.registries.keySet()); + Set keySet = new HashSet<>(RegistryManager.ACTIVE.registries.keySet()); keySet.addAll(RegistryManager.getVanillaRegistryKeys()); - Set ordered = new LinkedHashSet<>(vanillaRegistryOrder); + Set ordered = new LinkedHashSet<>(vanillaRegistryOrder); ordered.retainAll(keySet); - ordered.addAll(keySet.stream().sorted(ResourceLocation::compareNamespaced).toList()); + ordered.addAll(keySet.stream().sorted(Identifier::compareNamespaced).toList()); RuntimeException aggregate = new RuntimeException(); - for (ResourceLocation rootRegistryName : ordered) { + for (Identifier rootRegistryName : ordered) { try { ResourceKey> registryKey = ResourceKey.createRegistryKey(rootRegistryName); ForgeRegistry forgeRegistry = RegistryManager.ACTIVE.getRegistry(rootRegistryName); Registry vanillaRegistry = BuiltInRegistries.REGISTRY.getValue(rootRegistryName); RegisterEvent registerEvent = new RegisterEvent(registryKey, forgeRegistry, vanillaRegistry); - StartupMessageManager.modLoaderConsumer().ifPresent(s -> s.accept("REGISTERING " + registryKey.location())); + StartupMessageManager.modLoaderConsumer().ifPresent(s -> s.accept("REGISTERING " + registryKey.identifier())); if (forgeRegistry != null) forgeRegistry.unfreeze(); @@ -350,9 +349,9 @@ public class GameData { 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()); + LOGGER.debug(REGISTRIES, "Applying holder lookups: {}", registryKey.identifier()); + ObjectHolderRegistry.applyObjectHolders(registryKey.identifier()::equals); + LOGGER.debug(REGISTRIES, "Holder lookups applied: {}", registryKey.identifier()); } catch (Throwable t) { aggregate.addSuppressed(t); } @@ -405,7 +404,7 @@ public class GameData { StateDefinition newContainer = block.getStateDefinition(); // Test vanilla blockstates, if the number matches, make sure they also match in their string representations - if (key.location().getNamespace().equals("minecraft") && !oldContainer.getProperties().equals(newContainer.getProperties())) { + if (key.identifier().getNamespace().equals("minecraft") && !oldContainer.getProperties().equals(newContainer.getProperties())) { String oldSequence = oldContainer.getProperties().stream() .map(s -> String.format(Locale.ENGLISH, "%s={%s}", s.getName(), s.getPossibleValues().stream().map(Object::toString).collect(Collectors.joining( "," )))) @@ -416,7 +415,7 @@ public class GameData { .collect(Collectors.joining(";")); LOGGER.error(REGISTRIES,()-> LogMessageAdapter.adapt(sb-> { - sb.append("Registry replacements for vanilla block '").append(key.location()) + sb.append("Registry replacements for vanilla block '").append(key.identifier()) .append("' must not change the number or order of blockstates.\n"); sb.append("\tOld: ").append(oldSequence).append('\n'); sb.append("\tNew: ").append(newSequence); @@ -490,7 +489,7 @@ public class GameData { static final AttributeCallbacks INSTANCE = new AttributeCallbacks(); @Override - public void onValidate(IForgeRegistryInternal owner, RegistryManager stage, int id, ResourceLocation key, Attribute obj) { + public void onValidate(IForgeRegistryInternal owner, RegistryManager stage, int id, Identifier key, Attribute obj) { // some stuff hard patched in can cause this to derp if it's JUST vanilla, so skip if (stage != RegistryManager.VANILLA) DefaultAttributes.validate(); @@ -533,7 +532,7 @@ public class GameData { } } - private static void loadRegistry(final ResourceLocation registryName, final RegistryManager from, final RegistryManager to, boolean freeze) { + private static void loadRegistry(final Identifier registryName, final RegistryManager from, final RegistryManager to, boolean freeze) { ForgeRegistry fromRegistry = from.getRegistry(registryName); if (fromRegistry == null) { ForgeRegistry toRegistry = to.getRegistry(registryName); @@ -544,10 +543,10 @@ public class GameData { protected void printStackTrace(WrappedPrintStream stream) { stream.println("Looking For: " + registryName); stream.println("Found From:"); - for (ResourceLocation name : from.registries.keySet()) + for (Identifier name : from.registries.keySet()) stream.println(" " + name); stream.println("Found To:"); - for (ResourceLocation name : to.registries.keySet()) + for (Identifier name : to.registries.keySet()) stream.println(" " + name); } }; @@ -567,7 +566,7 @@ public class GameData { } - public static Multimap injectSnapshot(Map snapshot, boolean injectFrozenData, boolean isLocalWorld) { + public static Multimap injectSnapshot(Map snapshot, boolean injectFrozenData, boolean isLocalWorld) { LOGGER.info(REGISTRIES, "Injecting existing registry data into this {} instance", EffectiveSide.get()); RegistryManager.ACTIVE.registries.forEach((name, reg) -> reg.validateContent(name)); RegistryManager.ACTIVE.registries.forEach((name, reg) -> reg.dump(name)); @@ -579,7 +578,7 @@ public class GameData { .collect(Collectors.toMap(e -> RegistryManager.ACTIVE.updateLegacyName(e.getKey()), Map.Entry::getValue, (k1, k2) -> k1, LinkedHashMap::new)); if (isLocalWorld) { - ResourceLocation[] missingRegs = snapshot.keySet().stream().filter(name -> !RegistryManager.ACTIVE.registries.containsKey(name)).toArray(ResourceLocation[]::new); + Identifier[] missingRegs = snapshot.keySet().stream().filter(name -> !RegistryManager.ACTIVE.registries.containsKey(name)).toArray(Identifier[]::new); if (missingRegs.length > 0) { String header = "Forge Mod Loader detected missing/unknown registrie(s).\n\n" + @@ -589,7 +588,7 @@ public class GameData { StringBuilder text = new StringBuilder("Missing Registries:\n"); - for (ResourceLocation s : missingRegs) + for (Identifier s : missingRegs) text.append(s).append("\n"); LOGGER.warn(REGISTRIES, header); @@ -599,8 +598,8 @@ public class GameData { RegistryManager STAGING = new RegistryManager(); - final Map> remaps = new HashMap<>(); - final LinkedHashMap> missing = new LinkedHashMap<>(); + final Map> remaps = new HashMap<>(); + final LinkedHashMap> missing = new LinkedHashMap<>(); // Load the snapshot into the "STAGING" registry snapshot.forEach((key, value) -> { remaps.put(key, new LinkedHashMap<>()); @@ -611,13 +610,13 @@ public class GameData { int count = missing.values().stream().mapToInt(Map::size).sum(); if (count > 0) { LOGGER.debug(REGISTRIES,"There are {} mappings missing - attempting a mod remap", count); - Multimap defaulted = ArrayListMultimap.create(); - Multimap failed = ArrayListMultimap.create(); + Multimap defaulted = ArrayListMultimap.create(); + Multimap failed = ArrayListMultimap.create(); missing.entrySet().stream().filter(e -> !e.getValue().isEmpty()).forEach(m -> { - ResourceLocation name = m.getKey(); + Identifier name = m.getKey(); ForgeRegistry reg = STAGING.getRegistry(name); - Object2IntMap missingIds = m.getValue(); + Object2IntMap missingIds = m.getValue(); MissingMappingsEvent event = reg.getMissingEvent(name, missingIds); MissingMappingsEvent.BUS.post(event); @@ -650,7 +649,7 @@ public class GameData { StringBuilder buf = new StringBuilder(); defaulted.asMap().forEach((name, entries) -> { buf.append("Missing ").append(name).append(":\n"); - entries.stream().sorted(ResourceLocation::compareNamespaced).forEach(rl -> buf.append(" ").append(rl).append("\n")); + entries.stream().sorted(Identifier::compareNamespaced).forEach(rl -> buf.append(" ").append(rl).append("\n")); buf.append("\n"); }); @@ -677,7 +676,7 @@ public class GameData { STAGING.registries.forEach((name, reg) -> reg.validateContent(name)); // Load the STAGING registry into the ACTIVE registry - //for (Map.Entry>> r : RegistryManager.ACTIVE.registries.entrySet()) + //for (Map.Entry>> r : RegistryManager.ACTIVE.registries.entrySet()) RegistryManager.ACTIVE.registries.forEach((key, value) -> { loadRegistry(key, STAGING, RegistryManager.ACTIVE, true); }); @@ -698,12 +697,12 @@ public class GameData { return ArrayListMultimap.create(); } - private static void fireRemapEvent(final Map> remaps, final boolean isFreezing) { + private static void fireRemapEvent(final Map> remaps, final boolean isFreezing) { IdMappingEvent.BUS.post(new IdMappingEvent(remaps, isFreezing)); } //Has to be split because of generics, Yay! - private static void loadPersistentDataToStagingRegistry(RegistryManager pool, RegistryManager to, Map remaps, Object2IntMap missing, ResourceLocation name, ForgeRegistry.Snapshot snap) { + private static void loadPersistentDataToStagingRegistry(RegistryManager pool, RegistryManager to, Map remaps, Object2IntMap missing, Identifier name, ForgeRegistry.Snapshot snap) { ForgeRegistry active = pool.getRegistry(name); if (active == null) return; // We've already asked the user if they wish to continue. So if the reg isnt found just assume the user knows and accepted it. @@ -714,17 +713,17 @@ public class GameData { } //Another bouncer for generic reasons - private static void processMissing(ResourceLocation name, RegistryManager STAGING, MissingMappingsEvent e, Object2IntMap missing, Map remaps, Collection defaulted, Collection failed, boolean injectNetworkDummies) { + private static void processMissing(Identifier name, RegistryManager STAGING, MissingMappingsEvent e, Object2IntMap missing, Map remaps, Collection defaulted, Collection failed, boolean injectNetworkDummies) { List> mappings = e.getAllMappings(ResourceKey.createRegistryKey(name)); ForgeRegistry active = RegistryManager.ACTIVE.getRegistry(name); ForgeRegistry staging = STAGING.getRegistry(name); staging.processMissingEvent(name, active, mappings, missing, remaps, defaulted, failed, injectNetworkDummies); } - private static void loadFrozenDataToStagingRegistry(RegistryManager STAGING, ResourceLocation name, Map remaps) { + private static void loadFrozenDataToStagingRegistry(RegistryManager STAGING, Identifier name, Map remaps) { ForgeRegistry frozen = RegistryManager.FROZEN.getRegistry(name); ForgeRegistry newRegistry = STAGING.getRegistry(name, RegistryManager.FROZEN); - Object2IntMap _new = new Object2IntLinkedOpenHashMap<>(); + Object2IntMap _new = new Object2IntLinkedOpenHashMap<>(); frozen.getKeys().stream().filter(key -> !newRegistry.containsKey(key)).forEach(key -> _new.put(key, frozen.getID(key))); newRegistry.loadIds(_new, frozen.getOverrideOwners(), new Object2IntLinkedOpenHashMap<>(), remaps, frozen, name); } @@ -737,9 +736,9 @@ public class GameData { * @param warnOverrides If true, logs a warning if domain differs from that of * the currently currently active mod container * - * @return The {@link ResourceLocation} with given or inferred domain + * @return The {@link Identifier} with given or inferred domain */ - public static ResourceLocation checkPrefix(String name, boolean warnOverrides) { + public static Identifier checkPrefix(String name, boolean warnOverrides) { int index = name.lastIndexOf(':'); String oldPrefix = index == -1 ? "" : name.substring(0, index).toLowerCase(Locale.ROOT); name = index == -1 ? name : name.substring(index + 1); @@ -749,6 +748,6 @@ public class GameData { LogManager.getLogger().debug("Mod `{}` attempting to register `{}` to the namespace `{}`. This could be intended, but likely means an EventBusSubscriber without a modid.", prefix, name, oldPrefix); prefix = oldPrefix; } - return ResourceLocation.fromNamespaceAndPath(prefix, name); + return Identifier.fromNamespaceAndPath(prefix, name); } } diff --git a/src/main/java/net/minecraftforge/registries/IForgeRegistry.java b/src/main/java/net/minecraftforge/registries/IForgeRegistry.java index 3e823f9773..595ab1dd3a 100644 --- a/src/main/java/net/minecraftforge/registries/IForgeRegistry.java +++ b/src/main/java/net/minecraftforge/registries/IForgeRegistry.java @@ -9,7 +9,7 @@ import com.mojang.serialization.Codec; import net.minecraft.core.Holder; import net.minecraft.core.Registry; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraftforge.registries.tags.ITagManager; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -26,25 +26,25 @@ import java.util.Set; */ public interface IForgeRegistry extends Iterable { ResourceKey> getRegistryKey(); - ResourceLocation getRegistryName(); + Identifier getRegistryName(); /** * The supplied string key will be prefixed with the currently active mod's mod id. * If the supplied name already has a prefix that is different, it will be used and a warning will be logged. */ void register(String key, V value); - void register(ResourceLocation key, V value); + void register(Identifier key, V value); - boolean containsKey(ResourceLocation key); + boolean containsKey(Identifier key); boolean containsValue(V value); boolean isEmpty(); - @Nullable V getValue(ResourceLocation key); - @Nullable ResourceLocation getKey(V value); - @Nullable ResourceLocation getDefaultKey(); + @Nullable V getValue(Identifier key); + @Nullable Identifier getKey(V value); + @Nullable Identifier getDefaultKey(); @NotNull Optional> getResourceKey(V value); - @NotNull Set getKeys(); + @NotNull Set getKeys(); @NotNull Collection getValues(); @NotNull Set, V>> getEntries(); @@ -64,7 +64,7 @@ public interface IForgeRegistry extends Iterable { * This method exists purely as a stopgap for vanilla compatibility. * For anything tag related, use {@link #tags()}. */ - @NotNull Optional> getHolder(ResourceLocation location); + @NotNull Optional> getHolder(Identifier location); /** * This method exists purely as a stopgap for vanilla compatibility. * For anything tag related, use {@link #tags()}. @@ -78,8 +78,8 @@ public interface IForgeRegistry extends Iterable { @NotNull Optional> getDelegate(ResourceKey rkey); @NotNull Holder.Reference getDelegateOrThrow(ResourceKey rkey); - @NotNull Optional> getDelegate(ResourceLocation key); - @NotNull Holder.Reference getDelegateOrThrow(ResourceLocation key); + @NotNull Optional> getDelegate(Identifier key); + @NotNull Holder.Reference getDelegateOrThrow(Identifier key); @NotNull Optional> getDelegate(V value); @NotNull Holder.Reference getDelegateOrThrow(V value); @@ -124,7 +124,7 @@ public interface IForgeRegistry extends Iterable { */ @FunctionalInterface interface ValidateCallback { - void onValidate(IForgeRegistryInternal owner, RegistryManager stage, int id, ResourceLocation key, V obj); + void onValidate(IForgeRegistryInternal owner, RegistryManager stage, int id, Identifier key, V obj); } /** @@ -137,15 +137,15 @@ public interface IForgeRegistry extends Iterable { @FunctionalInterface interface MissingFactory { - V createMissing(ResourceLocation key, boolean isNetwork); + V createMissing(Identifier key, boolean isNetwork); } - public record SlaveKey(ResourceLocation name) { + public record SlaveKey(Identifier name) { public static SlaveKey create(String name) { - return create(ResourceLocation.parse(name)); + return create(Identifier.parse(name)); } - public static SlaveKey create(ResourceLocation name) { + public static SlaveKey create(Identifier name) { return new SlaveKey(name); } } diff --git a/src/main/java/net/minecraftforge/registries/IForgeRegistryInternal.java b/src/main/java/net/minecraftforge/registries/IForgeRegistryInternal.java index 931f8ee795..3236824f68 100644 --- a/src/main/java/net/minecraftforge/registries/IForgeRegistryInternal.java +++ b/src/main/java/net/minecraftforge/registries/IForgeRegistryInternal.java @@ -5,11 +5,11 @@ package net.minecraftforge.registries; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; public interface IForgeRegistryInternal extends IForgeRegistry { void setSlaveMap(SlaveKey name, T obj); - void register(int id, ResourceLocation key, V value); + void register(int id, Identifier key, V value); V getValue(int id); } diff --git a/src/main/java/net/minecraftforge/registries/IForgeRegistryModifiable.java b/src/main/java/net/minecraftforge/registries/IForgeRegistryModifiable.java index ad383b006f..85bff23eb6 100644 --- a/src/main/java/net/minecraftforge/registries/IForgeRegistryModifiable.java +++ b/src/main/java/net/minecraftforge/registries/IForgeRegistryModifiable.java @@ -5,11 +5,11 @@ package net.minecraftforge.registries; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; public interface IForgeRegistryModifiable extends IForgeRegistry { void clear(); - V remove(ResourceLocation key); + V remove(Identifier key); boolean isLocked(); } diff --git a/src/main/java/net/minecraftforge/registries/IdMappingEvent.java b/src/main/java/net/minecraftforge/registries/IdMappingEvent.java index 18b2446d41..d80cee6a02 100644 --- a/src/main/java/net/minecraftforge/registries/IdMappingEvent.java +++ b/src/main/java/net/minecraftforge/registries/IdMappingEvent.java @@ -8,7 +8,7 @@ package net.minecraftforge.registries; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Maps; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraftforge.eventbus.api.bus.EventBus; import net.minecraftforge.eventbus.api.event.MutableEvent; @@ -31,12 +31,12 @@ public final class IdMappingEvent extends MutableEvent { public static final EventBus BUS = EventBus.create(IdMappingEvent.class); public static final class ModRemapping { - public final ResourceLocation registry; - public final ResourceLocation key; + public final Identifier registry; + public final Identifier key; public final int oldId; public final int newId; - private ModRemapping(ResourceLocation registry, ResourceLocation key, int oldId, int newId) { + private ModRemapping(Identifier registry, Identifier key, int oldId, int newId) { this.registry = registry; this.key = key; this.oldId = oldId; @@ -46,12 +46,12 @@ public final class IdMappingEvent extends MutableEvent { public record IdRemapping(int currId, int newId) {} - private final Map> remaps; - private final ImmutableSet keys; + private final Map> remaps; + private final ImmutableSet keys; private final boolean isFrozen; - public IdMappingEvent(Map> remaps, boolean isFrozen) { + public IdMappingEvent(Map> remaps, boolean isFrozen) { this.isFrozen = isFrozen; this.remaps = Maps.newHashMap(); remaps.forEach((name, rm) -> { @@ -63,11 +63,11 @@ public final class IdMappingEvent extends MutableEvent { this.keys = ImmutableSet.copyOf(this.remaps.keySet()); } - public ImmutableSet getRegistries() { + public ImmutableSet getRegistries() { return this.keys; } - public ImmutableList getRemaps(ResourceLocation registry) { + public ImmutableList getRemaps(Identifier registry) { return this.remaps.get(registry); } diff --git a/src/main/java/net/minecraftforge/registries/MissingMappingsEvent.java b/src/main/java/net/minecraftforge/registries/MissingMappingsEvent.java index 65c4711152..1ecd66240e 100644 --- a/src/main/java/net/minecraftforge/registries/MissingMappingsEvent.java +++ b/src/main/java/net/minecraftforge/registries/MissingMappingsEvent.java @@ -7,7 +7,7 @@ package net.minecraftforge.registries; import net.minecraft.core.Registry; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraftforge.eventbus.api.bus.EventBus; import net.minecraftforge.eventbus.api.event.MutableEvent; import org.apache.commons.lang3.Validate; @@ -94,12 +94,12 @@ public final class MissingMappingsEvent extends MutableEvent { public static class Mapping implements Comparable> { private final IForgeRegistry registry; private final IForgeRegistry pool; - final ResourceLocation key; + final Identifier key; final int id; Action action = Action.DEFAULT; T target; - public Mapping(IForgeRegistry registry, IForgeRegistry pool, ResourceLocation key, int id) { + public Mapping(IForgeRegistry registry, IForgeRegistry pool, Identifier key, int id) { this.registry = registry; this.pool = pool; this.key = key; @@ -147,7 +147,7 @@ public final class MissingMappingsEvent extends MutableEvent { return this.registry; } - public ResourceLocation getKey() { + public Identifier getKey() { return key; } diff --git a/src/main/java/net/minecraftforge/registries/NamespacedDefaultedWrapper.java b/src/main/java/net/minecraftforge/registries/NamespacedDefaultedWrapper.java index a948fed80b..295060eeac 100644 --- a/src/main/java/net/minecraftforge/registries/NamespacedDefaultedWrapper.java +++ b/src/main/java/net/minecraftforge/registries/NamespacedDefaultedWrapper.java @@ -11,13 +11,13 @@ import java.util.function.Function; import net.minecraft.core.DefaultedRegistry; import net.minecraft.core.Holder; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.util.RandomSource; import org.jetbrains.annotations.Nullable; class NamespacedDefaultedWrapper extends NamespacedWrapper implements DefaultedRegistry { private final ForgeRegistry delegate; - private final ResourceLocation defaultKey; + private final Identifier defaultKey; private Holder.Reference defaultHolder; NamespacedDefaultedWrapper(ForgeRegistry fowner, Function> intrusiveHolderCallback, RegistryManager stage) { @@ -28,7 +28,7 @@ class NamespacedDefaultedWrapper extends NamespacedWrapper implements Defa // Reading Functions @Override - public T getValue(@Nullable ResourceLocation name) { + public T getValue(@Nullable Identifier name) { return this.delegate.getValue(name); //getOrDefault } @@ -41,7 +41,7 @@ class NamespacedDefaultedWrapper extends NamespacedWrapper implements Defa } @Override - public ResourceLocation getDefaultKey() { + public Identifier getDefaultKey() { return this.delegate.getDefaultKey(); } @@ -50,7 +50,7 @@ class NamespacedDefaultedWrapper extends NamespacedWrapper implements Defa Holder.Reference onAdded(RegistryManager stage, int id, ResourceKey key, T newValue, T oldValue) { Holder.Reference newHolder = super.onAdded(stage, id, key, newValue, oldValue); - if (newHolder != null && this.defaultKey != null && this.defaultKey.equals(key.location())) + if (newHolder != null && this.defaultKey != null && this.defaultKey.equals(key.identifier())) this.defaultHolder = newHolder; return newHolder; diff --git a/src/main/java/net/minecraftforge/registries/NamespacedWrapper.java b/src/main/java/net/minecraftforge/registries/NamespacedWrapper.java index 3c4fc68e25..2911d9c7b4 100644 --- a/src/main/java/net/minecraftforge/registries/NamespacedWrapper.java +++ b/src/main/java/net/minecraftforge/registries/NamespacedWrapper.java @@ -11,7 +11,6 @@ import com.google.common.collect.Multimaps; import com.mojang.serialization.Lifecycle; import it.unimi.dsi.fastutil.objects.ObjectArrayList; import it.unimi.dsi.fastutil.objects.ObjectList; -import net.minecraft.Util; import net.minecraft.core.Holder; import net.minecraft.core.HolderGetter; import net.minecraft.core.HolderLookup; @@ -20,10 +19,11 @@ import net.minecraft.core.MappedRegistry; import net.minecraft.core.RegistrationInfo; import net.minecraft.core.Registry; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.tags.TagKey; import net.minecraft.tags.TagLoader; import net.minecraft.util.RandomSource; +import net.minecraft.util.Util; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -58,7 +58,7 @@ class NamespacedWrapper extends MappedRegistry implements ILockableRegistr private boolean frozen = false; // Frozen is vanilla's variant of locked, but it can be unfrozen private List> holdersSorted; private final ObjectList> holdersById = new ObjectArrayList<>(256); - private final Map> holdersByName = new HashMap<>(); + private final Map> holdersByName = new HashMap<>(); private final Map> holders = new IdentityHashMap<>(); private final RegistryManager stage; private volatile Map, HolderSet.Named> tags = new IdentityHashMap<>(); @@ -83,7 +83,7 @@ class NamespacedWrapper extends MappedRegistry implements ILockableRegistr this.registrationInfos.put(key, info); this.registryLifecycle = this.registryLifecycle.add(info.lifecycle()); - this.delegate.add(-1, key.location(), value); + this.delegate.add(-1, key.identifier(), value); return getHolder(key, value); } @@ -91,24 +91,24 @@ class NamespacedWrapper extends MappedRegistry implements ILockableRegistr // Reading Functions @Override @Nullable - public T getValue(@Nullable ResourceLocation name) { + public T getValue(@Nullable Identifier name) { return this.delegate.getRaw(name); //get without default } @Override - public Optional getOptional(@Nullable ResourceLocation name) { + public Optional getOptional(@Nullable Identifier name) { return Optional.ofNullable(this.delegate.getRaw(name)); //get without default } @Override @Nullable public T getValue(@Nullable ResourceKey name) { - return name == null ? null : this.delegate.getRaw(name.location()); //get without default + return name == null ? null : this.delegate.getRaw(name.identifier()); //get without default } @Override @Nullable - public ResourceLocation getKey(T value) { + public Identifier getKey(T value) { return this.delegate.getKey(value); } @@ -118,13 +118,13 @@ class NamespacedWrapper extends MappedRegistry implements ILockableRegistr } @Override - public boolean containsKey(ResourceLocation key) { + public boolean containsKey(Identifier key) { return this.delegate.containsKey(key); } @Override public boolean containsKey(ResourceKey key) { - return this.delegate.getRegistryName().equals(key.registry()) && containsKey(key.location()); + return this.delegate.getRegistryName().equals(key.registry()) && containsKey(key.identifier()); } @Override @@ -149,7 +149,7 @@ class NamespacedWrapper extends MappedRegistry implements ILockableRegistr } @Override - public Set keySet() { + public Set keySet() { return this.delegate.getKeys(); } @@ -189,11 +189,11 @@ class NamespacedWrapper extends MappedRegistry implements ILockableRegistr @Override public Optional> get(ResourceKey key) { - return Optional.ofNullable(this.holdersByName.get(key.location())); + return Optional.ofNullable(this.holdersByName.get(key.identifier())); } @Override - public Optional> get(ResourceLocation p_333710_) { + public Optional> get(Identifier p_333710_) { return Optional.ofNullable(this.holdersByName.get(p_333710_)); } @@ -208,7 +208,7 @@ class NamespacedWrapper extends MappedRegistry implements ILockableRegistr return Optional.ofNullable(this.registrationInfos.get(p_331530_)); } - public Optional> getHolder(ResourceLocation location) { + public Optional> getHolder(Identifier location) { return Optional.ofNullable(this.holdersByName.get(location)); } @@ -240,16 +240,16 @@ class NamespacedWrapper extends MappedRegistry implements ILockableRegistr void validateWrite() { if (this.frozen) - throw new IllegalStateException("Registry " + this.key().location() + " is already frozen"); + throw new IllegalStateException("Registry " + this.key().identifier() + " is already frozen"); } void validateWrite(ResourceKey key) { if (this.frozen) - throw new IllegalStateException("Registry " + this.key().location() + " is already frozen (trying to add key " + key + ")"); + throw new IllegalStateException("Registry " + this.key().identifier() + " is already frozen (trying to add key " + key + ")"); } protected Holder.Reference getOrCreateHolderOrThrow(ResourceKey key) { - return this.holdersByName.computeIfAbsent(key.location(), k -> { + return this.holdersByName.computeIfAbsent(key.identifier(), k -> { if (this.isIntrusive()) { throw new IllegalStateException("This registry can't create new holders without value"); } else { @@ -296,12 +296,12 @@ class NamespacedWrapper extends MappedRegistry implements ILockableRegistr return this; this.frozen = true; - List unregistered = this.holdersByName.entrySet().stream() + List unregistered = this.holdersByName.entrySet().stream() .filter(e -> !e.getValue().isBound()) .map(Map.Entry::getKey).sorted().toList(); if (!unregistered.isEmpty()) - throw new IllegalStateException("Unbound values in registry " + this.key() + ": " + unregistered.stream().map(ResourceLocation::toString).collect(Collectors.joining(", \n\t"))); + throw new IllegalStateException("Unbound values in registry " + this.key() + ": " + unregistered.stream().map(Identifier::toString).collect(Collectors.joining(", \n\t"))); if (this.unregisteredIntrusiveHolders != null && this.unregisteredIntrusiveHolders.values().stream().anyMatch(r -> !r.isBound() && r.getType() == Holder.Reference.Type.INTRUSIVE)) { throw new IllegalStateException("Some intrusive holders were not registered: " + this.unregisteredIntrusiveHolders.values() + " Hint: Did you register all your registry objects? Registry stage: " + stage.getName()); @@ -504,7 +504,7 @@ class NamespacedWrapper extends MappedRegistry implements ILockableRegistr this.holdersById.size(Math.max(this.holdersById.size(), id + 1)); this.holdersById.set(id, newHolder); - this.holdersByName.put(key.location(), newHolder); + this.holdersByName.put(key.identifier(), newHolder); this.holders.put(newValue, newHolder); if (this.unregisteredIntrusiveHolders != null) { this.unregisteredIntrusiveHolders.remove(newValue); @@ -524,7 +524,7 @@ class NamespacedWrapper extends MappedRegistry implements ILockableRegistr if (this.isIntrusive()) return this.intrusiveHolderCallback.apply(value); - return this.holdersByName.computeIfAbsent(key.location(), k -> Holder.Reference.createStandAlone(this, key)); + return this.holdersByName.computeIfAbsent(key.identifier(), k -> Holder.Reference.createStandAlone(this, key)); } private List> getSortedHolders() { diff --git a/src/main/java/net/minecraftforge/registries/ObjectHolderRegistry.java b/src/main/java/net/minecraftforge/registries/ObjectHolderRegistry.java index 02a35a1f85..8af55397ba 100644 --- a/src/main/java/net/minecraftforge/registries/ObjectHolderRegistry.java +++ b/src/main/java/net/minecraftforge/registries/ObjectHolderRegistry.java @@ -10,7 +10,7 @@ import java.util.Set; import java.util.function.Consumer; import java.util.function.Predicate; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.jetbrains.annotations.ApiStatus; @@ -27,7 +27,7 @@ class ObjectHolderRegistry { * and hashCode function to de-duplicate callers here. * The default @ObjectHolder implementation uses the hashCode/equals for the field the annotation is on. */ - static synchronized void addHandler(Consumer> ref) { + static synchronized void addHandler(Consumer> ref) { objectHolders.add(ref); } @@ -40,7 +40,7 @@ class ObjectHolderRegistry { * * @return true if handler was matched and removed. */ - static synchronized boolean removeHandler(Consumer> ref) { + static synchronized boolean removeHandler(Consumer> ref) { return objectHolders.remove(ref); } @@ -49,7 +49,7 @@ class ObjectHolderRegistry { //============================================================== private static final Logger LOGGER = LogManager.getLogger(); - private static final Set>> objectHolders = new HashSet<>(); + private static final Set>> objectHolders = new HashSet<>(); static void applyObjectHolders() { try { @@ -62,9 +62,9 @@ class ObjectHolderRegistry { } } - static void applyObjectHolders(Predicate filter) { + static void applyObjectHolders(Predicate filter) { RuntimeException aggregate = new RuntimeException("Failed to apply some object holders, see suppressed exceptions for details"); - for (Consumer> objectHolder : objectHolders) { + for (Consumer> objectHolder : objectHolders) { try { objectHolder.accept(filter); } catch (Exception e) { diff --git a/src/main/java/net/minecraftforge/registries/RegisterEvent.java b/src/main/java/net/minecraftforge/registries/RegisterEvent.java index dbf09f27cb..f9b2b90c4e 100644 --- a/src/main/java/net/minecraftforge/registries/RegisterEvent.java +++ b/src/main/java/net/minecraftforge/registries/RegisterEvent.java @@ -7,7 +7,7 @@ package net.minecraftforge.registries; import net.minecraft.core.Registry; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraftforge.eventbus.api.bus.BusGroup; import net.minecraftforge.eventbus.api.bus.EventBus; import net.minecraftforge.fml.ModLoadingContext; @@ -24,7 +24,7 @@ import java.util.function.Supplier; *

    * Fired on the {@linkplain FMLJavaModLoadingContext#getModBusGroup() mod BusGroup}. * - * @see #register(ResourceKey, ResourceLocation, Supplier) + * @see #register(ResourceKey, Identifier, Supplier) * @see #register(ResourceKey, Consumer) */ public class RegisterEvent implements IModBusEvent { @@ -55,7 +55,7 @@ public class RegisterEvent implements IModBusEvent { * @see #register(ResourceKey, Consumer) a register variant making registration of multiple objects less redundant */ @SuppressWarnings({ "unchecked", "rawtypes" }) - public void register(ResourceKey> registryKey, ResourceLocation name, Supplier valueSupplier) { + public void register(ResourceKey> registryKey, Identifier name, Supplier valueSupplier) { if (this.registryKey.equals(registryKey)) { if (this.forgeRegistry != null) ((IForgeRegistry) this.forgeRegistry).register(name, valueSupplier.get()); @@ -69,7 +69,7 @@ public class RegisterEvent implements IModBusEvent { * * @param registryKey the key of the registry to register objects to * @param the type of the registry - * @see #register(ResourceKey, ResourceLocation, Supplier) a register variant targeted towards registering one or two objects + * @see #register(ResourceKey, Identifier, Supplier) a register variant targeted towards registering one or two objects */ public void register(ResourceKey> registryKey, Consumer> consumer) { if (this.registryKey.equals(registryKey)) @@ -112,14 +112,14 @@ public class RegisterEvent implements IModBusEvent { /** * Registers the given value with the given name to the registry. * The namespace is inferred based on the active mod container. - * If you wish to specify a namespace, use {@link #register(ResourceLocation, Object)} instead. + * If you wish to specify a namespace, use {@link #register(Identifier, Object)} instead. * * @param name the name of the object to register as its key with the namespaced inferred from the active mod container * @param value the object value */ @SuppressWarnings("removal") default void register(String name, T value) { - register(ResourceLocation.fromNamespaceAndPath(ModLoadingContext.get().getActiveNamespace(), name), value); + register(Identifier.fromNamespaceAndPath(ModLoadingContext.get().getActiveNamespace(), name), value); } /** @@ -129,7 +129,7 @@ public class RegisterEvent implements IModBusEvent { * @param value the object value */ default void register(ResourceKey key, T value) { - register(key.location(), value); + register(key.identifier(), value); } /** @@ -138,6 +138,6 @@ public class RegisterEvent implements IModBusEvent { * @param name the name of the object to register as its key * @param value the object value */ - void register(ResourceLocation name, T value); + void register(Identifier name, T value); } } diff --git a/src/main/java/net/minecraftforge/registries/RegistryBuilder.java b/src/main/java/net/minecraftforge/registries/RegistryBuilder.java index fd595f4dd3..7e631d5e27 100644 --- a/src/main/java/net/minecraftforge/registries/RegistryBuilder.java +++ b/src/main/java/net/minecraftforge/registries/RegistryBuilder.java @@ -6,7 +6,7 @@ package net.minecraftforge.registries; import net.minecraft.core.Holder; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraftforge.registries.IForgeRegistry.AddCallback; import net.minecraftforge.registries.IForgeRegistry.BakeCallback; import net.minecraftforge.registries.IForgeRegistry.ClearCallback; @@ -27,17 +27,17 @@ public class RegistryBuilder { } public static RegistryBuilder of(String name) { - return of(ResourceLocation.parse(name)); + return of(Identifier.parse(name)); } - public static RegistryBuilder of(ResourceLocation name) { + public static RegistryBuilder of(Identifier name) { return new RegistryBuilder().setName(name); } private static final int MAX_ID = Integer.MAX_VALUE - 1; - private ResourceLocation registryName; - private ResourceLocation optionalDefaultKey; + private Identifier registryName; + private Identifier optionalDefaultKey; private int minId = 0; private int maxId = MAX_ID; private final List> addCallback = new ArrayList<>(); @@ -51,11 +51,11 @@ public class RegistryBuilder { private boolean allowModifications = false; private boolean hasWrapper = false; private MissingFactory missingFactory; - private final Set legacyNames = new HashSet<>(); + private final Set legacyNames = new HashSet<>(); @Nullable private Function> intrusiveHolderCallback = null; - public RegistryBuilder setName(ResourceLocation name) { + public RegistryBuilder setName(Identifier name) { this.registryName = name; return this; } @@ -70,7 +70,7 @@ public class RegistryBuilder { return this.setIDRange(0, max); } - public RegistryBuilder setDefaultKey(ResourceLocation key) { + public RegistryBuilder setDefaultKey(Identifier key) { this.optionalDefaultKey = key; return this; } @@ -175,10 +175,10 @@ public class RegistryBuilder { } public RegistryBuilder legacyName(String name) { - return legacyName(ResourceLocation.parse(name)); + return legacyName(Identifier.parse(name)); } - public RegistryBuilder legacyName(ResourceLocation name) { + public RegistryBuilder legacyName(Identifier name) { this.legacyNames.add(name); return this; } @@ -284,7 +284,7 @@ public class RegistryBuilder { } @Nullable - public ResourceLocation getDefault() { + public Identifier getDefault() { return this.optionalDefaultKey; } @@ -317,7 +317,7 @@ public class RegistryBuilder { return sync; } - public Set getLegacyNames() { + public Set getLegacyNames() { return legacyNames; } diff --git a/src/main/java/net/minecraftforge/registries/RegistryManager.java b/src/main/java/net/minecraftforge/registries/RegistryManager.java index 08a8814692..ebed61262d 100644 --- a/src/main/java/net/minecraftforge/registries/RegistryManager.java +++ b/src/main/java/net/minecraftforge/registries/RegistryManager.java @@ -18,9 +18,8 @@ import net.minecraft.core.RegistrationInfo; import net.minecraft.core.WritableRegistry; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.core.Registry; -import net.minecraftforge.fml.ModLoader; import net.minecraftforge.registries.ForgeRegistry.Snapshot; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -31,13 +30,13 @@ public class RegistryManager { public static final RegistryManager ACTIVE = new RegistryManager("ACTIVE"); public static final RegistryManager VANILLA = new RegistryManager("VANILLA"); public static final RegistryManager FROZEN = new RegistryManager("FROZEN"); - private static Set vanillaRegistryKeys = Set.of(); + private static Set vanillaRegistryKeys = Set.of(); - BiMap> registries = HashBiMap.create(); - private final Map> registryView = Collections.unmodifiableMap(registries); - private final Set persisted = new HashSet<>(); - private final Set synced = new HashSet<>(); - private final Map legacyNames = new HashMap<>(); + BiMap> registries = HashBiMap.create(); + private final Map> registryView = Collections.unmodifiableMap(registries); + private final Set persisted = new HashSet<>(); + private final Set synced = new HashSet<>(); + private final Map legacyNames = new HashMap<>(); private final String name; RegistryManager() { @@ -57,28 +56,28 @@ public class RegistryManager { } @SuppressWarnings("unchecked") - public ForgeRegistry getRegistry(ResourceLocation key) { + public ForgeRegistry getRegistry(Identifier key) { return (ForgeRegistry)this.registries.get(key); } public ForgeRegistry getRegistry(ResourceKey> key) { - return getRegistry(key.location()); + return getRegistry(key.identifier()); } - public ResourceLocation getName(IForgeRegistry reg) { + public Identifier getName(IForgeRegistry reg) { return this.registries.inverse().get(reg); } - public Map> getRegistries() { + public Map> getRegistries() { return this.registryView; } - public static Set getVanillaRegistryKeys() { + public static Set getVanillaRegistryKeys() { return vanillaRegistryKeys; } - public ResourceLocation updateLegacyName(ResourceLocation legacyName) { - ResourceLocation originalName = legacyName; + public Identifier updateLegacyName(Identifier legacyName) { + Identifier originalName = legacyName; while (getRegistry(legacyName) == null) { legacyName = legacyNames.get(legacyName); if (legacyName == null) @@ -87,7 +86,7 @@ public class RegistryManager { return legacyName; } - public ForgeRegistry getRegistry(ResourceLocation key, RegistryManager other) { + public ForgeRegistry getRegistry(Identifier key, RegistryManager other) { if (!this.registries.containsKey(key)) { ForgeRegistry ot = other.getRegistry(key); if (ot == null) @@ -104,7 +103,7 @@ public class RegistryManager { return getRegistry(key); } - ForgeRegistry createRegistry(ResourceLocation name, RegistryBuilder builder) { + ForgeRegistry createRegistry(Identifier name, RegistryBuilder builder) { if (registries.containsKey(name)) throw new IllegalArgumentException("Attempted to register a registry for " + name + " but it already exists"); ForgeRegistry reg = new ForgeRegistry(this, name, builder); @@ -113,7 +112,7 @@ public class RegistryManager { this.persisted.add(name); if (builder.getSync()) this.synced.add(name); - for (ResourceLocation legacyName : builder.getLegacyNames()) + for (Identifier legacyName : builder.getLegacyNames()) addLegacyName(legacyName, name); return getRegistry(name); } @@ -140,16 +139,16 @@ public class RegistryManager { dataPackEvent.process(); } - private void addLegacyName(ResourceLocation legacyName, ResourceLocation name) { + private void addLegacyName(Identifier legacyName, Identifier name) { if (this.legacyNames.containsKey(legacyName)) throw new IllegalArgumentException("Legacy name conflict for registry " + name + ", upgrade path must be linear: " + legacyName); this.legacyNames.put(legacyName, name); } - public Map takeSnapshot(boolean savingToDisc) { - Map ret = new HashMap<>(); + public Map takeSnapshot(boolean savingToDisc) { + Map ret = new HashMap<>(); var keys = savingToDisc ? this.persisted : this.synced; - for (ResourceLocation key : keys) { + for (Identifier key : keys) { ret.put(key, getRegistry(key).makeSnapshot()); } return ret; @@ -164,7 +163,7 @@ public class RegistryManager { } @ApiStatus.Internal - public static List getRegistryNamesForSyncToClient() { + public static List getRegistryNamesForSyncToClient() { return ACTIVE.registries.keySet().stream().filter(ACTIVE.synced::contains).toList(); } } diff --git a/src/main/java/net/minecraftforge/registries/RegistryObject.java b/src/main/java/net/minecraftforge/registries/RegistryObject.java index a2af037b85..9c49544727 100644 --- a/src/main/java/net/minecraftforge/registries/RegistryObject.java +++ b/src/main/java/net/minecraftforge/registries/RegistryObject.java @@ -10,7 +10,7 @@ import net.minecraft.core.MappedRegistry; import net.minecraft.core.Registry; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -24,7 +24,7 @@ import java.util.stream.Stream; public final class RegistryObject implements Supplier { @Nullable - private final ResourceLocation name; + private final Identifier name; @Nullable private final ResourceKey key; private final boolean optionalRegistry; @@ -40,7 +40,7 @@ public final class RegistryObject implements Supplier { * @param registry the forge registry * @return a {@link RegistryObject} that stores the value of an object from the provided forge registry once it is ready */ - public static RegistryObject create(final ResourceLocation name, IForgeRegistry registry) { + public static RegistryObject create(final Identifier name, IForgeRegistry registry) { return new RegistryObject(name, registry); } @@ -48,18 +48,18 @@ public final class RegistryObject implements Supplier { * Factory for a {@link RegistryObject} that stores the value of an object from a registry once it is ready based on a lookup of the provided registry key. *

    * If a registry with the given key cannot be found, an exception will be thrown when trying to fill this RegistryObject. - * Use {@link #createOptional(ResourceLocation, ResourceKey, String)} for RegistryObjects of optional registries. + * Use {@link #createOptional(Identifier, ResourceKey, String)} for RegistryObjects of optional registries. * * @param name the name of the object to look up in a registry * @param registryKey the key of the registry. Supports lookups on {@link BuiltInRegistries} and {@link RegistryManager#ACTIVE}. * @param modid the mod id calling context * @return a {@link RegistryObject} that stores the value of an object from a registry once it is ready - * @see #createOptional(ResourceLocation, ResourceKey, String) - * @see #create(ResourceLocation, IForgeRegistry) - * @see #create(ResourceLocation, ResourceLocation, String) + * @see #createOptional(Identifier, ResourceKey, String) + * @see #create(Identifier, IForgeRegistry) + * @see #create(Identifier, Identifier, String) */ - public static RegistryObject create(final ResourceLocation name, final ResourceKey> registryKey, String modid) { - return new RegistryObject<>(name, registryKey.location(), modid, false); + public static RegistryObject create(final Identifier name, final ResourceKey> registryKey, String modid) { + return new RegistryObject<>(name, registryKey.identifier(), modid, false); } /** @@ -67,35 +67,35 @@ public final class RegistryObject implements Supplier { * based on a lookup of the provided registry key. *

    * If a registry with the given key cannot be found, it will be silently ignored and this RegistryObject will not be filled. - * Use {@link #create(ResourceLocation, ResourceKey, String)} for RegistryObjects that should throw exceptions on missing registry. + * Use {@link #create(Identifier, ResourceKey, String)} for RegistryObjects that should throw exceptions on missing registry. * * @param name the name of the object to look up in a registry * @param registryKey the key of the registry. Supports lookups on {@link BuiltInRegistries} and {@link RegistryManager#ACTIVE}. * @param modid the mod id calling context * @return a {@link RegistryObject} that stores the value of an object from a registry once it is ready - * @see #create(ResourceLocation, ResourceKey, String) - * @see #create(ResourceLocation, IForgeRegistry) - * @see #create(ResourceLocation, ResourceLocation, String) + * @see #create(Identifier, ResourceKey, String) + * @see #create(Identifier, IForgeRegistry) + * @see #create(Identifier, Identifier, String) */ - public static RegistryObject createOptional(final ResourceLocation name, final ResourceKey> registryKey, String modid) { - return new RegistryObject<>(name, registryKey.location(), modid, true); + public static RegistryObject createOptional(final Identifier name, final ResourceKey> registryKey, String modid) { + return new RegistryObject<>(name, registryKey.identifier(), modid, true); } /** * Factory for a {@link RegistryObject} that stores the value of an object from a registry once it is ready based on a lookup of the provided registry name. *

    * If a registry with the given name cannot be found, an exception will be thrown when trying to fill this RegistryObject. - * Use {@link #createOptional(ResourceLocation, ResourceLocation, String)} for RegistryObjects of optional registries. + * Use {@link #createOptional(Identifier, Identifier, String)} for RegistryObjects of optional registries. * * @param name the name of the object to look up in a registry * @param registryName the name of the registry. Supports lookups on {@link BuiltInRegistries} and {@link RegistryManager#ACTIVE}. * @param modid the mod id calling context * @return a {@link RegistryObject} that stores the value of an object from a registry once it is ready - * @see #createOptional(ResourceLocation, ResourceLocation, String) - * @see #create(ResourceLocation, IForgeRegistry) - * @see #create(ResourceLocation, ResourceKey, String) + * @see #createOptional(Identifier, Identifier, String) + * @see #create(Identifier, IForgeRegistry) + * @see #create(Identifier, ResourceKey, String) */ - public static RegistryObject create(final ResourceLocation name, final ResourceLocation registryName, String modid) { + public static RegistryObject create(final Identifier name, final Identifier registryName, String modid) { return new RegistryObject<>(name, registryName, modid, false); } @@ -104,17 +104,17 @@ public final class RegistryObject implements Supplier { * based on a lookup of the provided registry name. *

    * If a registry with the given name cannot be found, it will be silently ignored and this RegistryObject will not be filled. - * Use {@link #create(ResourceLocation, ResourceLocation, String)} for RegistryObjects that should throw exceptions on missing registry. + * Use {@link #create(Identifier, Identifier, String)} for RegistryObjects that should throw exceptions on missing registry. * * @param name the name of the object to look up in a registry * @param registryName the name of the registry. Supports lookups on {@link BuiltInRegistries} and {@link RegistryManager#ACTIVE}. * @param modid the mod id calling context * @return a {@link RegistryObject} that stores the value of an object from a registry once it is ready - * @see #create(ResourceLocation, ResourceLocation, String) - * @see #create(ResourceLocation, IForgeRegistry) - * @see #create(ResourceLocation, ResourceKey, String) + * @see #create(Identifier, Identifier, String) + * @see #create(Identifier, IForgeRegistry) + * @see #create(Identifier, ResourceKey, String) */ - public static RegistryObject createOptional(final ResourceLocation name, final ResourceLocation registryName, String modid) { + public static RegistryObject createOptional(final Identifier name, final Identifier registryName, String modid) { return new RegistryObject<>(name, registryName, modid, true); } @@ -133,7 +133,7 @@ public final class RegistryObject implements Supplier { } @SuppressWarnings("unchecked") - private RegistryObject(ResourceLocation name, IForgeRegistry registry) { + private RegistryObject(Identifier name, IForgeRegistry registry) { if (registry == null) throw new IllegalArgumentException("Invalid registry argument, must not be null"); this.name = name; @@ -146,7 +146,7 @@ public final class RegistryObject implements Supplier { this.updateReference((IForgeRegistry) registry); } - private RegistryObject(final ResourceLocation name, final ResourceLocation registryName, final String modid, boolean optionalRegistry) { + private RegistryObject(final Identifier name, final Identifier registryName, final String modid, boolean optionalRegistry) { this.name = name; this.key = ResourceKey.create(ResourceKey.createRegistryKey(registryName), name); this.optionalRegistry = optionalRegistry; @@ -156,7 +156,7 @@ public final class RegistryObject implements Supplier { private boolean invalidRegistry = false; @Override - public void accept(Predicate pred) { + public void accept(Predicate pred) { if (invalidRegistry) return; @@ -176,7 +176,7 @@ public final class RegistryObject implements Supplier { } /** Internal constructor used for {@link DeferredRegisterData} */ - RegistryObject(final ResourceLocation name, final ResourceKey> registry, final String modid) { + RegistryObject(final Identifier name, final ResourceKey> registry, final String modid) { this.name = name; @SuppressWarnings("unchecked") var typed = (ResourceKey>)registry; @@ -240,7 +240,7 @@ public final class RegistryObject implements Supplier { } @SuppressWarnings("unchecked") - void updateReference(ResourceLocation registryName) { + void updateReference(Identifier registryName) { if (this.name == null) return; @@ -279,12 +279,12 @@ public final class RegistryObject implements Supplier { this.holder = holder; } - private static boolean registryExists(ResourceLocation registryName) { + private static boolean registryExists(Identifier registryName) { return RegistryManager.ACTIVE.getRegistry(registryName) != null || BuiltInRegistries.REGISTRY.containsKey(registryName); } - public ResourceLocation getId() { + public Identifier getId() { return this.name; } diff --git a/src/main/java/net/minecraftforge/registries/holdersets/AnyHolderSet.java b/src/main/java/net/minecraftforge/registries/holdersets/AnyHolderSet.java index 9e74b3ea85..34d7fd6c0b 100644 --- a/src/main/java/net/minecraftforge/registries/holdersets/AnyHolderSet.java +++ b/src/main/java/net/minecraftforge/registries/holdersets/AnyHolderSet.java @@ -16,7 +16,7 @@ import com.mojang.datafixers.util.Either; import com.mojang.serialization.Codec; import com.mojang.serialization.MapCodec; -import net.minecraft.Util; +import net.minecraft.util.Util; import net.minecraft.core.Holder; import net.minecraft.core.HolderLookup; import net.minecraft.core.HolderOwner; diff --git a/src/main/java/net/minecraftforge/registries/tags/ITagManager.java b/src/main/java/net/minecraftforge/registries/tags/ITagManager.java index 7f72b58254..5505b51876 100644 --- a/src/main/java/net/minecraftforge/registries/tags/ITagManager.java +++ b/src/main/java/net/minecraftforge/registries/tags/ITagManager.java @@ -6,7 +6,7 @@ package net.minecraftforge.registries.tags; import net.minecraft.core.Holder; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.tags.TagKey; import net.minecraftforge.registries.DeferredRegister; import org.jetbrains.annotations.NotNull; @@ -59,23 +59,23 @@ public interface ITagManager extends Iterable> { /** * Creates a tag key based on the location and the forge registry linked to this tag manager. - * Custom registries can use {@link DeferredRegister#createTagKey(ResourceLocation)} to create tag keys before the tag manager is created. + * Custom registries can use {@link DeferredRegister#createTagKey(Identifier)} to create tag keys before the tag manager is created. * - * @see #createOptionalTagKey(ResourceLocation, Set) - * @see DeferredRegister#createTagKey(ResourceLocation) + * @see #createOptionalTagKey(Identifier, Set) + * @see DeferredRegister#createTagKey(Identifier) */ - @NotNull TagKey createTagKey(@NotNull ResourceLocation location); + @NotNull TagKey createTagKey(@NotNull Identifier location); /** * Creates a tag key that will use the set of defaults if the tag is not loaded from any datapacks. * Useful on the client side when a server may not provide a specific tag. * Custom registries can use {@link DeferredRegister#addOptionalTagDefaults(TagKey, Set)} to create tag keys before the tag manager is created. * - * @see #createTagKey(ResourceLocation) + * @see #createTagKey(Identifier) * @see #addOptionalTagDefaults(TagKey, Set) - * @see DeferredRegister#createOptionalTagKey(ResourceLocation, Set) + * @see DeferredRegister#createOptionalTagKey(Identifier, Set) */ - @NotNull TagKey createOptionalTagKey(@NotNull ResourceLocation location, @NotNull Set> defaults); + @NotNull TagKey createOptionalTagKey(@NotNull Identifier location, @NotNull Set> defaults); /** * Adds defaults to an existing tag key. @@ -83,7 +83,7 @@ public interface ITagManager extends Iterable> { * Useful on the client side when a server may not provide a specific tag. * Custom registries can use {@link DeferredRegister#addOptionalTagDefaults(TagKey, Set)} to add defaults before the tag manager is created. * - * @see #createOptionalTagKey(ResourceLocation, Set) + * @see #createOptionalTagKey(Identifier, Set) * @see DeferredRegister#addOptionalTagDefaults(TagKey, Set) */ void addOptionalTagDefaults(@NotNull TagKey name, @NotNull Set> defaults); diff --git a/src/main/java/net/minecraftforge/resource/DelegatingPackResources.java b/src/main/java/net/minecraftforge/resource/DelegatingPackResources.java index 125f0e40e2..078f25eecb 100644 --- a/src/main/java/net/minecraftforge/resource/DelegatingPackResources.java +++ b/src/main/java/net/minecraftforge/resource/DelegatingPackResources.java @@ -16,7 +16,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.packs.AbstractPackResources; import net.minecraft.server.packs.PackLocationInfo; import net.minecraft.server.packs.PackResources; @@ -88,7 +88,7 @@ public class DelegatingPackResources extends AbstractPackResources { @Nullable @Override - public IoSupplier getResource(PackType type, ResourceLocation location) { + public IoSupplier getResource(PackType type, Identifier location) { for (PackResources pack : getCandidatePacks(type, location)) { IoSupplier ioSupplier = pack.getResource(type, location); if (ioSupplier != null) @@ -103,7 +103,7 @@ public class DelegatingPackResources extends AbstractPackResources { return delegates; } - private List getCandidatePacks(PackType type, ResourceLocation location) { + private List getCandidatePacks(PackType type, Identifier location) { Map> map = type == PackType.CLIENT_RESOURCES ? namespacesAssets : namespacesData; List packsWithNamespace = map.get(location.getNamespace()); return packsWithNamespace == null ? Collections.emptyList() : packsWithNamespace; diff --git a/src/main/java/net/minecraftforge/resource/package-info.java b/src/main/java/net/minecraftforge/resource/package-info.java index cf572e3b40..3f66fda068 100644 --- a/src/main/java/net/minecraftforge/resource/package-info.java +++ b/src/main/java/net/minecraftforge/resource/package-info.java @@ -3,11 +3,7 @@ * SPDX-License-Identifier: LGPL-2.1-only */ -@ParametersAreNonnullByDefault -@MethodsReturnNonnullByDefault +@NullMarked package net.minecraftforge.resource; -import net.minecraft.MethodsReturnNonnullByDefault; - -import javax.annotation.ParametersAreNonnullByDefault; - +import org.jspecify.annotations.NullMarked; diff --git a/src/main/java/net/minecraftforge/server/LanguageHook.java b/src/main/java/net/minecraftforge/server/LanguageHook.java index 681514cb67..aef19ffb38 100644 --- a/src/main/java/net/minecraftforge/server/LanguageHook.java +++ b/src/main/java/net/minecraftforge/server/LanguageHook.java @@ -9,7 +9,7 @@ import com.google.gson.Gson; import com.google.gson.JsonElement; import com.google.gson.JsonObject; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.MinecraftServer; import net.minecraft.server.packs.PackResources; import net.minecraft.server.packs.PackType; @@ -80,7 +80,7 @@ public class LanguageHook { for (var entry : byNamespace.entrySet()) { var languages = new ArrayList>(); - var path = ResourceLocation.fromNamespaceAndPath(entry.getKey(), langFile); + var path = Identifier.fromNamespaceAndPath(entry.getKey(), langFile); for (var pack : entry.getValue()) { var io = pack.getResource(PackType.CLIENT_RESOURCES, path); if (io != null) diff --git a/src/main/java/net/minecraftforge/server/command/ChunkGenWorker.java b/src/main/java/net/minecraftforge/server/command/ChunkGenWorker.java index 385885b270..bc4460377a 100644 --- a/src/main/java/net/minecraftforge/server/command/ChunkGenWorker.java +++ b/src/main/java/net/minecraftforge/server/command/ChunkGenWorker.java @@ -106,7 +106,7 @@ public class ChunkGenWorker implements IWorker { } if (queue.isEmpty()) { - listener.sendSuccess(() -> Component.translatable("commands.forge.gen.complete", genned, total, dim.dimension().location()), true); + listener.sendSuccess(() -> Component.translatable("commands.forge.gen.complete", genned, total, dim.dimension().identifier()), true); return false; } return true; diff --git a/src/main/java/net/minecraftforge/server/command/CommandHelper.java b/src/main/java/net/minecraftforge/server/command/CommandHelper.java index cf6dd9d3ef..ee1dc8ebcd 100644 --- a/src/main/java/net/minecraftforge/server/command/CommandHelper.java +++ b/src/main/java/net/minecraftforge/server/command/CommandHelper.java @@ -20,7 +20,7 @@ import net.minecraft.commands.synchronization.ArgumentTypeInfo; import net.minecraft.commands.synchronization.ArgumentTypeInfos; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.network.Connection; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraftforge.network.ConnectionType; import net.minecraftforge.network.NetworkContext; @@ -113,7 +113,7 @@ public final class CommandHelper { return CommandTreeCleaner.cleanArgumentTypes(root, argType -> { ArgumentTypeInfo info = ArgumentTypeInfos.byClass(argType); - ResourceLocation id = BuiltInRegistries.COMMAND_ARGUMENT_TYPE.getKey(info); + Identifier id = BuiltInRegistries.COMMAND_ARGUMENT_TYPE.getKey(info); return id != null && (id.getNamespace().equals("minecraft") || id.getNamespace().equals("brigadier")); }); } diff --git a/src/main/java/net/minecraftforge/server/command/ConfigCommand.java b/src/main/java/net/minecraftforge/server/command/ConfigCommand.java index 39b067adfc..a055a81018 100644 --- a/src/main/java/net/minecraftforge/server/command/ConfigCommand.java +++ b/src/main/java/net/minecraftforge/server/command/ConfigCommand.java @@ -29,7 +29,7 @@ public class ConfigCommand { public static class ShowFile { static ArgumentBuilder register() { return Commands.literal("showfile"). - requires(cs->cs.hasPermission(0)). + requires(Commands.hasPermission(Commands.LEVEL_ALL)). then(Commands.argument("mod", ModIdArgument.modIdArgument()). then(Commands.argument("type", EnumArgument.enumArgument(ModConfig.Type.class)). executes(ShowFile::showFile) diff --git a/src/main/java/net/minecraftforge/server/command/DimensionsCommand.java b/src/main/java/net/minecraftforge/server/command/DimensionsCommand.java index 9fce6630ad..8b39580af9 100644 --- a/src/main/java/net/minecraftforge/server/command/DimensionsCommand.java +++ b/src/main/java/net/minecraftforge/server/command/DimensionsCommand.java @@ -9,7 +9,7 @@ import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.Commands; import net.minecraft.core.registries.Registries; import net.minecraft.network.chat.Component; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.core.Registry; import net.minecraft.world.level.dimension.DimensionType; import net.minecraft.server.level.ServerLevel; @@ -25,18 +25,18 @@ import com.mojang.brigadier.builder.ArgumentBuilder; class DimensionsCommand { static ArgumentBuilder register() { return Commands.literal("dimensions") - .requires(cs->cs.hasPermission(0)) //permission + .requires(Commands.hasPermission(Commands.LEVEL_ALL)) //permission .executes(ctx -> { ctx.getSource().sendSuccess(() -> Component.translatable("commands.forge.dimensions.list"), true); final Registry reg = ctx.getSource().registryAccess().lookupOrThrow(Registries.DIMENSION_TYPE); - Map> types = new HashMap<>(); + Map> types = new HashMap<>(); for (ServerLevel dim : ctx.getSource().getServer().getAllLevels()) { - types.computeIfAbsent(reg.getKey(dim.dimensionType()), k -> new ArrayList<>()).add(dim.dimension().location()); + types.computeIfAbsent(reg.getKey(dim.dimensionType()), k -> new ArrayList<>()).add(dim.dimension().identifier()); } types.keySet().stream().sorted().forEach(key -> { - ctx.getSource().sendSuccess(() -> Component.literal(key + ": " + types.get(key).stream().map(ResourceLocation::toString).sorted().collect(Collectors.joining(", "))), false); + ctx.getSource().sendSuccess(() -> Component.literal(key + ": " + types.get(key).stream().map(Identifier::toString).sorted().collect(Collectors.joining(", "))), false); }); return 0; }); diff --git a/src/main/java/net/minecraftforge/server/command/EntityCommand.java b/src/main/java/net/minecraftforge/server/command/EntityCommand.java index 85a9e4f99c..370eb90be7 100644 --- a/src/main/java/net/minecraftforge/server/command/EntityCommand.java +++ b/src/main/java/net/minecraftforge/server/command/EntityCommand.java @@ -25,7 +25,7 @@ import net.minecraft.commands.SharedSuggestionProvider; import net.minecraft.commands.arguments.DimensionArgument; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.Level; import net.minecraft.server.level.ServerLevel; @@ -50,9 +50,9 @@ class EntityCommand static ArgumentBuilder register() { return Commands.literal("list") - .requires(cs->cs.hasPermission(2)) //permission + .requires(Commands.hasPermission(Commands.LEVEL_GAMEMASTERS)) .then(Commands.argument("filter", StringArgumentType.string()) - .suggests((ctx, builder) -> SharedSuggestionProvider.suggest(ForgeRegistries.ENTITY_TYPES.getKeys().stream().map(ResourceLocation::toString).map(StringArgumentType::escapeIfRequired), builder)) + .suggests((ctx, builder) -> SharedSuggestionProvider.suggest(ForgeRegistries.ENTITY_TYPES.getKeys().stream().map(Identifier::toString).map(StringArgumentType::escapeIfRequired), builder)) .then(Commands.argument("dim", DimensionArgument.dimension()) .executes(ctx -> execute(ctx.getSource(), StringArgumentType.getString(ctx, "filter"), DimensionArgument.getDimension(ctx, "dim").dimension())) ) @@ -65,7 +65,7 @@ class EntityCommand { final String cleanFilter = filter.replace("?", ".?").replace("*", ".*?"); - Set names = ForgeRegistries.ENTITY_TYPES.getKeys().stream().filter(n -> n.toString().matches(cleanFilter)).collect(Collectors.toSet()); + Set names = ForgeRegistries.ENTITY_TYPES.getKeys().stream().filter(n -> n.toString().matches(cleanFilter)).collect(Collectors.toSet()); if (names.isEmpty()) throw INVALID_FILTER.create(); @@ -74,7 +74,7 @@ class EntityCommand if (level == null) throw INVALID_DIMENSION.create(dim); - Map>> list = Maps.newHashMap(); + Map>> list = Maps.newHashMap(); level.getEntities().getAll().forEach(e -> { MutablePair> info = list.computeIfAbsent(ForgeRegistries.ENTITY_TYPES.getKey(e.getType()), k -> MutablePair.of(0, Maps.newHashMap())); ChunkPos chunk = new ChunkPos(e.blockPosition()); @@ -84,7 +84,7 @@ class EntityCommand if (names.size() == 1) { - ResourceLocation name = names.iterator().next(); + Identifier name = names.iterator().next(); Pair> info = list.get(name); if (info == null) throw NO_ENTITIES.create(); @@ -110,11 +110,11 @@ class EntityCommand else { - List> info = new ArrayList<>(); + List> info = new ArrayList<>(); list.forEach((key, value) -> { if (names.contains(key)) { - Pair of = Pair.of(key, value.left); + Pair of = Pair.of(key, value.left); info.add(of); } }); diff --git a/src/main/java/net/minecraftforge/server/command/GenerateCommand.java b/src/main/java/net/minecraftforge/server/command/GenerateCommand.java index ebb56b8133..23ff34603c 100644 --- a/src/main/java/net/minecraftforge/server/command/GenerateCommand.java +++ b/src/main/java/net/minecraftforge/server/command/GenerateCommand.java @@ -20,7 +20,7 @@ import net.minecraftforge.common.WorldWorkerManager; class GenerateCommand { static ArgumentBuilder register() { return Commands.literal("generate") - .requires(cs->cs.hasPermission(4)) //permission + .requires(Commands.hasPermission(Commands.LEVEL_OWNERS)) .then(Commands.argument("pos", BlockPosArgument.blockPos()) .then(Commands.argument("count", IntegerArgumentType.integer(1)) .then(Commands.argument("dim", DimensionArgument.dimension()) diff --git a/src/main/java/net/minecraftforge/server/command/ModListCommand.java b/src/main/java/net/minecraftforge/server/command/ModListCommand.java index 585f4ee209..0d0875f664 100644 --- a/src/main/java/net/minecraftforge/server/command/ModListCommand.java +++ b/src/main/java/net/minecraftforge/server/command/ModListCommand.java @@ -18,7 +18,7 @@ class ModListCommand { static ArgumentBuilder register() { return Commands.literal("mods") - .requires(cs->cs.hasPermission(0)) //permission + .requires(Commands.hasPermission(Commands.LEVEL_ALL)) .executes(ctx -> { ctx.getSource().sendSuccess(() -> Component.translatable("commands.forge.mods.list", ModList.get().applyForEachModFile(modFile -> diff --git a/src/main/java/net/minecraftforge/server/command/TPSCommand.java b/src/main/java/net/minecraftforge/server/command/TPSCommand.java index ff00253bc0..0756dac090 100644 --- a/src/main/java/net/minecraftforge/server/command/TPSCommand.java +++ b/src/main/java/net/minecraftforge/server/command/TPSCommand.java @@ -25,7 +25,7 @@ class TPSCommand static ArgumentBuilder register() { return Commands.literal("tps") - .requires(cs->cs.hasPermission(0)) //permission + .requires(Commands.hasPermission(Commands.LEVEL_ALL)) .then(Commands.argument("dim", DimensionArgument.dimension()) .executes(ctx -> sendTime(ctx.getSource(), DimensionArgument.getDimension(ctx, "dim"))) ) @@ -53,7 +53,7 @@ class TPSCommand final Registry reg = cs.registryAccess().lookupOrThrow(Registries.DIMENSION_TYPE); double worldTickTime = mean(times) * 1.0E-6D; double worldTPS = Math.min(1000.0 / worldTickTime, 20); - cs.sendSuccess(() -> Component.translatable("commands.forge.tps.summary.named", dim.dimension().location().toString(), reg.getKey(dim.dimensionType()).toString(), TIME_FORMATTER.format(worldTickTime), TIME_FORMATTER.format(worldTPS)), false); + cs.sendSuccess(() -> Component.translatable("commands.forge.tps.summary.named", dim.dimension().identifier().toString(), reg.getKey(dim.dimensionType()).toString(), TIME_FORMATTER.format(worldTickTime), TIME_FORMATTER.format(worldTPS)), false); return 1; } diff --git a/src/main/java/net/minecraftforge/server/command/TagsCommand.java b/src/main/java/net/minecraftforge/server/command/TagsCommand.java index 8eb0bd5a14..7bc2635da7 100644 --- a/src/main/java/net/minecraftforge/server/command/TagsCommand.java +++ b/src/main/java/net/minecraftforge/server/command/TagsCommand.java @@ -19,14 +19,14 @@ import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.Commands; import net.minecraft.commands.SharedSuggestionProvider; import net.minecraft.commands.arguments.ResourceKeyArgument; -import net.minecraft.commands.arguments.ResourceLocationArgument; +import net.minecraft.commands.arguments.IdentifierArgument; import net.minecraft.core.Holder; import net.minecraft.core.HolderSet; import net.minecraft.core.Registry; import net.minecraft.core.RegistryAccess; import net.minecraft.network.chat.*; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.tags.TagKey; import net.minecraft.util.Mth; @@ -57,7 +57,7 @@ import java.util.stream.Stream; class TagsCommand { private static final long PAGE_SIZE = 8; private static final ResourceKey>> ROOT_REGISTRY_KEY = - ResourceKey.createRegistryKey(ResourceLocation.parse("root")); + ResourceKey.createRegistryKey(Identifier.parse("root")); private static final DynamicCommandExceptionType UNKNOWN_REGISTRY = new DynamicCommandExceptionType(key -> Component.translatable("commands.forge.tags.error.unknown_registry", key)); @@ -73,7 +73,7 @@ class TagsCommand { * /forge tags query [page] */ return Commands.literal("tags") - .requires(cs -> cs.hasPermission(2)) + .requires(Commands.hasPermission(Commands.LEVEL_GAMEMASTERS)) .then(Commands.argument("registry", ResourceKeyArgument.key(ROOT_REGISTRY_KEY)) .suggests(TagsCommand::suggestRegistries) .then(Commands.literal("list") @@ -83,7 +83,7 @@ class TagsCommand { ) ) .then(Commands.literal("get") - .then(Commands.argument("tag", ResourceLocationArgument.id()) + .then(Commands.argument("tag", IdentifierArgument.id()) .suggests(suggestFromRegistry(r -> r.getTags().map(t -> t.key().location())::iterator)) .executes(ctx -> listTagElements(ctx, 1)) .then(Commands.argument("page", IntegerArgumentType.integer(1)) @@ -92,7 +92,7 @@ class TagsCommand { ) ) .then(Commands.literal("query") - .then(Commands.argument("element", ResourceLocationArgument.id()) + .then(Commands.argument("element", IdentifierArgument.id()) .suggests(suggestFromRegistry(Registry::keySet)) .executes(ctx -> queryElementTags(ctx, 1)) .then(Commands.argument("page", IntegerArgumentType.integer(1)) @@ -107,12 +107,12 @@ class TagsCommand { final ResourceKey> registryKey = getResourceKey(ctx, "registry", ROOT_REGISTRY_KEY) .orElseThrow(); // Expect to be always retrieve a resource key for the root registry (registry key) final Registry registry = ctx.getSource().getServer().registryAccess().lookup(registryKey) - .orElseThrow(() -> UNKNOWN_REGISTRY.create(registryKey.location())); + .orElseThrow(() -> UNKNOWN_REGISTRY.create(registryKey.identifier())); final long tagCount = registry.getTags().count(); ctx.getSource().sendSuccess(() -> createMessage( - Component.translatable("commands.forge.tags.registry_key", Component.literal(registryKey.location().toString()).withStyle(ChatFormatting.GOLD)), + Component.translatable("commands.forge.tags.registry_key", Component.literal(registryKey.identifier().toString()).withStyle(ChatFormatting.GOLD)), "commands.forge.tags.tag_count", "commands.forge.tags.copy_tag_names", tagCount, @@ -130,24 +130,24 @@ class TagsCommand { final ResourceKey> registryKey = getResourceKey(ctx, "registry", ROOT_REGISTRY_KEY) .orElseThrow(); // Expect to be always retrieve a resource key for the root registry (registry key) final Registry registry = ctx.getSource().getServer().registryAccess().lookup(registryKey) - .orElseThrow(() -> UNKNOWN_REGISTRY.create(registryKey.location())); + .orElseThrow(() -> UNKNOWN_REGISTRY.create(registryKey.identifier())); - final ResourceLocation tagLocation = ResourceLocationArgument.getId(ctx, "tag"); + final Identifier tagLocation = IdentifierArgument.getId(ctx, "tag"); final TagKey tagKey = TagKey.create(cast(registryKey), tagLocation); final HolderSet.Named tag = registry.get(tagKey) - .orElseThrow(() -> UNKNOWN_TAG.create(tagKey.location(), registryKey.location())); + .orElseThrow(() -> UNKNOWN_TAG.create(tagKey.location(), registryKey.identifier())); ctx.getSource().sendSuccess(() -> createMessage( Component.translatable("commands.forge.tags.tag_key", - Component.literal(tagKey.registry().location().toString()).withStyle(ChatFormatting.GOLD), + Component.literal(tagKey.registry().identifier().toString()).withStyle(ChatFormatting.GOLD), Component.literal(tagKey.location().toString()).withStyle(ChatFormatting.DARK_GREEN)), "commands.forge.tags.element_count", "commands.forge.tags.copy_element_names", tag.size(), page, ChatFormatting.YELLOW, - () -> tag.stream().map(s -> s.unwrap().map(k -> k.location().toString(), Object::toString)) + () -> tag.stream().map(s -> s.unwrap().map(k -> k.identifier().toString(), Object::toString)) ), false); return tag.size(); @@ -157,19 +157,19 @@ class TagsCommand { final ResourceKey> registryKey = getResourceKey(ctx, "registry", ROOT_REGISTRY_KEY) .orElseThrow(); // Expect to be always retrieve a resource key for the root registry (registry key) final Registry registry = ctx.getSource().getServer().registryAccess().lookup(registryKey) - .orElseThrow(() -> UNKNOWN_REGISTRY.create(registryKey.location())); + .orElseThrow(() -> UNKNOWN_REGISTRY.create(registryKey.identifier())); - final ResourceLocation elementLocation = ResourceLocationArgument.getId(ctx, "element"); + final Identifier elementLocation = IdentifierArgument.getId(ctx, "element"); final ResourceKey elementKey = ResourceKey.create(cast(registryKey), elementLocation); final Holder elementHolder = registry.get(elementKey) - .orElseThrow(() -> UNKNOWN_ELEMENT.create(elementLocation, registryKey.location())); + .orElseThrow(() -> UNKNOWN_ELEMENT.create(elementLocation, registryKey.identifier())); final long containingTagsCount = elementHolder.tags().count(); ctx.getSource().sendSuccess(() -> createMessage( Component.translatable("commands.forge.tags.element", - Component.literal(registryKey.location().toString()).withStyle(ChatFormatting.GOLD), + Component.literal(registryKey.identifier().toString()).withStyle(ChatFormatting.GOLD), Component.literal(elementLocation.toString()).withStyle(ChatFormatting.YELLOW)), "commands.forge.tags.containing_tag_count", "commands.forge.tags.copy_tag_names", @@ -223,13 +223,13 @@ class TagsCommand { ) { ctx.getSource().registryAccess().registries() .map(RegistryAccess.RegistryEntry::key) - .map(ResourceKey::location) - .map(ResourceLocation::toString) + .map(ResourceKey::identifier) + .map(Identifier::toString) .forEach(builder::suggest); return builder.buildFuture(); } - private static SuggestionProvider suggestFromRegistry(final Function, Iterable> namesFunction) { + private static SuggestionProvider suggestFromRegistry(final Function, Iterable> namesFunction) { return (ctx, builder) -> { var key = getResourceKey(ctx, "registry", ROOT_REGISTRY_KEY).orElse(null); if (key == null) diff --git a/src/main/java/net/minecraftforge/server/command/TrackCommand.java b/src/main/java/net/minecraftforge/server/command/TrackCommand.java index 700b3e3a30..6d6e0f8c16 100644 --- a/src/main/java/net/minecraftforge/server/command/TrackCommand.java +++ b/src/main/java/net/minecraftforge/server/command/TrackCommand.java @@ -39,7 +39,7 @@ class TrackCommand { private static class StartTrackingCommand { static ArgumentBuilder register() { return Commands.literal("start") - .requires(cs->cs.hasPermission(2)) //permission + .requires(Commands.hasPermission(Commands.LEVEL_GAMEMASTERS)) .then(Commands.literal("te") .then(Commands.argument("duration", IntegerArgumentType.integer(1)) .executes(ctx -> { @@ -68,7 +68,7 @@ class TrackCommand { private static class ResetTrackingCommand { static ArgumentBuilder register() { return Commands.literal("reset") - .requires(cs->cs.hasPermission(2)) //permission + .requires(Commands.hasPermission(Commands.LEVEL_GAMEMASTERS)) .then(Commands.literal("te") .executes(ctx -> { TimeTracker.BLOCK_ENTITY_UPDATE.reset(); @@ -127,7 +127,7 @@ class TrackCommand { double averageTimings = data.getAverageTimings(); String tickTime = (averageTimings > 1000 ? TIME_FORMAT.format(averageTimings / 1000) : TIME_FORMAT.format(averageTimings)) + (averageTimings < 1000 ? "\u03bcs" : "ms"); - return Component.translatable("commands.forge.tracking.timing_entry", ForgeRegistries.ENTITY_TYPES.getKey(entity.getType()), entity.level().dimension().location().toString(), pos.getX(), pos.getY(), pos.getZ(), tickTime); + return Component.translatable("commands.forge.tracking.timing_entry", ForgeRegistries.ENTITY_TYPES.getKey(entity.getType()), entity.level().dimension().identifier().toString(), pos.getX(), pos.getY(), pos.getZ(), tickTime); })); } } @@ -143,7 +143,7 @@ class TrackCommand { double averageTimings = data.getAverageTimings(); String tickTime = (averageTimings > 1000 ? TIME_FORMAT.format(averageTimings / 1000) : TIME_FORMAT.format(averageTimings)) + (averageTimings < 1000 ? "\u03bcs" : "ms"); - return Component.translatable("commands.forge.tracking.timing_entry", ForgeRegistries.BLOCK_ENTITY_TYPES.getKey(be.getType()), be.getLevel().dimension().location().toString(), pos.getX(), pos.getY(), pos.getZ(), tickTime); + return Component.translatable("commands.forge.tracking.timing_entry", ForgeRegistries.BLOCK_ENTITY_TYPES.getKey(be.getType()), be.getLevel().dimension().identifier().toString(), pos.getX(), pos.getY(), pos.getZ(), tickTime); })); } } diff --git a/src/main/java/net/minecraftforge/server/command/package-info.java b/src/main/java/net/minecraftforge/server/command/package-info.java index 14ad4da3b5..faf15bde66 100644 --- a/src/main/java/net/minecraftforge/server/command/package-info.java +++ b/src/main/java/net/minecraftforge/server/command/package-info.java @@ -3,10 +3,7 @@ * SPDX-License-Identifier: LGPL-2.1-only */ -@ParametersAreNonnullByDefault -@MethodsReturnNonnullByDefault +@NullMarked package net.minecraftforge.server.command; -import net.minecraft.MethodsReturnNonnullByDefault; - -import javax.annotation.ParametersAreNonnullByDefault; +import org.jspecify.annotations.NullMarked; diff --git a/src/main/java/net/minecraftforge/server/permission/PermissionAPI.java b/src/main/java/net/minecraftforge/server/permission/PermissionAPI.java index 4fbcd55461..3488ff22e8 100644 --- a/src/main/java/net/minecraftforge/server/permission/PermissionAPI.java +++ b/src/main/java/net/minecraftforge/server/permission/PermissionAPI.java @@ -5,8 +5,8 @@ package net.minecraftforge.server.permission; -import net.minecraft.ResourceLocationException; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.IdentifierException; +import net.minecraft.resources.Identifier; import net.minecraft.server.level.ServerPlayer; import net.minecraftforge.common.ForgeConfig; import net.minecraftforge.common.MinecraftForge; @@ -45,7 +45,7 @@ public final class PermissionAPI * @return the Identifier of the currently active permission handler */ @Nullable - public static ResourceLocation getActivePermissionHandler() + public static Identifier getActivePermissionHandler() { return activeHandler == null ? null : activeHandler.getIdentifier(); } @@ -105,11 +105,11 @@ public final class PermissionAPI PermissionAPI.activeHandler = null; var handlerEvent = PermissionGatherEvent.Handler.BUS.fire(new PermissionGatherEvent.Handler()); - Map availableHandlers = handlerEvent.getAvailablePermissionHandlerFactories(); + Map availableHandlers = handlerEvent.getAvailablePermissionHandlerFactories(); try { - ResourceLocation selectedPermissionHandler = ResourceLocation.parse(ForgeConfig.SERVER.permissionHandler.get()); + Identifier selectedPermissionHandler = Identifier.parse(ForgeConfig.SERVER.permissionHandler.get()); if (!availableHandlers.containsKey(selectedPermissionHandler)) { LOGGER.error("Unable to find configured permission handler {}, will use {}", selectedPermissionHandler, DefaultPermissionHandler.IDENTIFIER); @@ -127,7 +127,7 @@ public final class PermissionAPI LOGGER.info("Successfully initialized permission handler {}", PermissionAPI.activeHandler.getIdentifier()); } - catch (ResourceLocationException e) + catch (IdentifierException e) { LOGGER.error("Error parsing config value 'permissionHandler'", e); } diff --git a/src/main/java/net/minecraftforge/server/permission/events/PermissionGatherEvent.java b/src/main/java/net/minecraftforge/server/permission/events/PermissionGatherEvent.java index 18ca0ca2ab..dac0cb79c5 100644 --- a/src/main/java/net/minecraftforge/server/permission/events/PermissionGatherEvent.java +++ b/src/main/java/net/minecraftforge/server/permission/events/PermissionGatherEvent.java @@ -6,7 +6,7 @@ package net.minecraftforge.server.permission.events; import com.google.common.base.Preconditions; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraftforge.eventbus.api.bus.EventBus; import net.minecraftforge.eventbus.api.event.InheritableEvent; import net.minecraftforge.eventbus.api.event.MutableEvent; @@ -37,17 +37,17 @@ public sealed class PermissionGatherEvent extends MutableEvent implements Inheri public static final class Handler extends PermissionGatherEvent { public static final EventBus BUS = EventBus.create(Handler.class); - private final Map availableHandlers = new HashMap<>(); + private final Map availableHandlers = new HashMap<>(); public Handler() { availableHandlers.put(DefaultPermissionHandler.IDENTIFIER, DefaultPermissionHandler::new); } - public Map getAvailablePermissionHandlerFactories() { + public Map getAvailablePermissionHandlerFactories() { return Collections.unmodifiableMap(availableHandlers); } - public void addPermissionHandler(ResourceLocation identifier, IPermissionHandlerFactory handlerFactory) { + public void addPermissionHandler(Identifier identifier, IPermissionHandlerFactory handlerFactory) { Preconditions.checkNotNull(identifier, "Permission handler identifier cannot be null!"); Preconditions.checkNotNull(handlerFactory, "Permission handler cannot be null!"); if (this.availableHandlers.containsKey(identifier)) diff --git a/src/main/java/net/minecraftforge/server/permission/handler/DefaultPermissionHandler.java b/src/main/java/net/minecraftforge/server/permission/handler/DefaultPermissionHandler.java index a7bd6cf9fd..51a7dc5ebf 100644 --- a/src/main/java/net/minecraftforge/server/permission/handler/DefaultPermissionHandler.java +++ b/src/main/java/net/minecraftforge/server/permission/handler/DefaultPermissionHandler.java @@ -5,7 +5,7 @@ package net.minecraftforge.server.permission.handler; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.level.ServerPlayer; import net.minecraftforge.server.permission.nodes.PermissionDynamicContext; import net.minecraftforge.server.permission.nodes.PermissionNode; @@ -14,7 +14,7 @@ import java.util.*; public final class DefaultPermissionHandler implements IPermissionHandler { - public static final ResourceLocation IDENTIFIER = ResourceLocation.fromNamespaceAndPath("forge", "default_handler");; + public static final Identifier IDENTIFIER = Identifier.fromNamespaceAndPath("forge", "default_handler");; private final Set> registeredNodes = new HashSet<>(); private Set> immutableRegisteredNodes = Collections.unmodifiableSet(this.registeredNodes); @@ -25,7 +25,7 @@ public final class DefaultPermissionHandler implements IPermissionHandler } @Override - public ResourceLocation getIdentifier() + public Identifier getIdentifier() { return IDENTIFIER; } diff --git a/src/main/java/net/minecraftforge/server/permission/handler/IPermissionHandler.java b/src/main/java/net/minecraftforge/server/permission/handler/IPermissionHandler.java index 96b4028a90..8a218a0fef 100644 --- a/src/main/java/net/minecraftforge/server/permission/handler/IPermissionHandler.java +++ b/src/main/java/net/minecraftforge/server/permission/handler/IPermissionHandler.java @@ -5,7 +5,7 @@ package net.minecraftforge.server.permission.handler; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.level.ServerPlayer; import net.minecraft.util.StringRepresentable; import net.minecraftforge.server.permission.PermissionAPI; @@ -30,7 +30,7 @@ public interface IPermissionHandler /** * {@return an identifier for the PermissionHandler} */ - ResourceLocation getIdentifier(); + Identifier getIdentifier(); /** * {@return an unmodifiable view of the collection of registered permission nodes} diff --git a/src/main/java/net/minecraftforge/server/permission/nodes/PermissionNode.java b/src/main/java/net/minecraftforge/server/permission/nodes/PermissionNode.java index 416cea81db..5c6bb99031 100644 --- a/src/main/java/net/minecraftforge/server/permission/nodes/PermissionNode.java +++ b/src/main/java/net/minecraftforge/server/permission/nodes/PermissionNode.java @@ -7,7 +7,7 @@ package net.minecraftforge.server.permission.nodes; import com.google.common.base.Preconditions; import net.minecraft.network.chat.Component; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.level.ServerPlayer; import net.minecraftforge.server.permission.events.PermissionGatherEvent; import net.minecraftforge.server.permission.handler.IPermissionHandler; @@ -57,7 +57,7 @@ public final class PermissionNode { * Calls {@link PermissionNode#PermissionNode(String, PermissionType, PermissionResolver, PermissionDynamicContextKey[])} * with "namespace.path" as the first parameter */ - public PermissionNode(ResourceLocation nodeName, PermissionType type, PermissionResolver defaultResolver, PermissionDynamicContextKey... dynamics) { + public PermissionNode(Identifier nodeName, PermissionType type, PermissionResolver defaultResolver, PermissionDynamicContextKey... dynamics) { this(nodeName.getNamespace(), nodeName.getPath(), type, defaultResolver, dynamics); } diff --git a/src/main/java/net/minecraftforge/server/permission/package-info.java b/src/main/java/net/minecraftforge/server/permission/package-info.java index 9969c64fcc..b9dc9184fa 100644 --- a/src/main/java/net/minecraftforge/server/permission/package-info.java +++ b/src/main/java/net/minecraftforge/server/permission/package-info.java @@ -3,10 +3,7 @@ * SPDX-License-Identifier: LGPL-2.1-only */ -@ParametersAreNonnullByDefault -@MethodsReturnNonnullByDefault +@NullMarked package net.minecraftforge.server.permission; -import net.minecraft.MethodsReturnNonnullByDefault; - -import javax.annotation.ParametersAreNonnullByDefault; \ No newline at end of file +import org.jspecify.annotations.NullMarked; diff --git a/src/main/resources/META-INF/accesstransformer.cfg b/src/main/resources/META-INF/accesstransformer.cfg index 9b2ba8e15f..9c80d51926 100644 --- a/src/main/resources/META-INF/accesstransformer.cfg +++ b/src/main/resources/META-INF/accesstransformer.cfg @@ -5,9 +5,8 @@ public-f net.minecraft.client.Options f_92059_ # keyMappings public net.minecraft.client.Options$FieldAccess public net.minecraft.client.color.item.ItemTintSources f_371619_ # ID_MAPPER #group protected net.minecraft.client.data.models.BlockModelGenerators *() -protected net.minecraft.client.data.models.BlockModelGenerators m_372042_(Lnet/minecraft/world/item/Item;Lnet/minecraft/resources/ResourceLocation;)V # registerSimpleItemModel +protected net.minecraft.client.data.models.BlockModelGenerators m_372042_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/resources/Identifier;)V # registerSimpleItemModel protected net.minecraft.client.data.models.BlockModelGenerators m_372065_()V # createCartographyTable -protected net.minecraft.client.data.models.BlockModelGenerators m_372079_(Lnet/minecraft/world/level/block/Block;I)Lnet/minecraft/resources/ResourceLocation; # lambda$createCropBlock$25 protected net.minecraft.client.data.models.BlockModelGenerators m_372090_()V # createPitcherCrop protected net.minecraft.client.data.models.BlockModelGenerators m_372114_(Lnet/minecraft/client/data/models/blockstates/MultiPartGenerator;Lnet/minecraft/client/renderer/block/model/multipart/Condition;Lnet/minecraft/client/renderer/block/model/VariantMutator;)V # addSlotStateAndRotationVariants protected net.minecraft.client.data.models.BlockModelGenerators m_372121_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/Block;)V # createWeightedPressurePlate @@ -19,8 +18,7 @@ protected net.minecraft.client.data.models.BlockModelGenerators m_372188_(Lnet/m protected net.minecraft.client.data.models.BlockModelGenerators m_372190_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/item/Item;)V # createMultiface protected net.minecraft.client.data.models.BlockModelGenerators m_372196_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/Block;)V # copyTrapdoorModel protected net.minecraft.client.data.models.BlockModelGenerators m_372199_()V # createStructureBlock -protected net.minecraft.client.data.models.BlockModelGenerators m_372209_(Lnet/minecraft/world/item/Item;Lnet/minecraft/world/level/block/Block;Ljava/lang/String;)Lnet/minecraft/resources/ResourceLocation; # createFlatItemModelWithBlockTexture -protected net.minecraft.client.data.models.BlockModelGenerators m_372211_(Lnet/minecraft/client/data/models/model/TextureMapping;)V # lambda$static$14 +protected net.minecraft.client.data.models.BlockModelGenerators m_372209_(Lnet/minecraft/world/item/Item;Lnet/minecraft/world/level/block/Block;Ljava/lang/String;)Lnet/minecraft/resources/Identifier; # createFlatItemModelWithBlockTexture protected net.minecraft.client.data.models.BlockModelGenerators m_372231_()Lnet/minecraft/client/data/models/blockstates/PropertyDispatch; # createRotatedPillar protected net.minecraft.client.data.models.BlockModelGenerators m_372234_(Lnet/minecraft/world/level/block/Block;)V # createRotatedMirroredVariantBlock protected net.minecraft.client.data.models.BlockModelGenerators m_372247_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/MultiVariant;)Lnet/minecraft/client/data/models/blockstates/BlockModelDefinitionGenerator; # createTrapdoor @@ -46,12 +44,9 @@ protected net.minecraft.client.data.models.BlockModelGenerators m_372503_(Lnet/m protected net.minecraft.client.data.models.BlockModelGenerators m_372507_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/item/Item;)V # createAirLikeBlock protected net.minecraft.client.data.models.BlockModelGenerators m_372519_()V # createGrindstone protected net.minecraft.client.data.models.BlockModelGenerators m_372527_(Lnet/minecraft/world/level/block/Block;)V # registerSimpleFlatItemModel -protected net.minecraft.client.data.models.BlockModelGenerators m_372530_(Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/client/data/models/model/TextureMapping;)V # lambda$createBarrel$23 protected net.minecraft.client.data.models.BlockModelGenerators m_372545_()V # createLightBlock protected net.minecraft.client.data.models.BlockModelGenerators m_372548_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/Block;)V # createCoral -protected net.minecraft.client.data.models.BlockModelGenerators m_372570_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/client/data/models/model/TextureMapping;)V # lambda$createMossyCarpet$51 protected net.minecraft.client.data.models.BlockModelGenerators m_372620_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/Block;)V # copyCopperBulbModel -protected net.minecraft.client.data.models.BlockModelGenerators m_372638_(Lnet/minecraft/client/data/models/model/TextureMapping;)V # lambda$static$13 protected net.minecraft.client.data.models.BlockModelGenerators m_372644_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/MultiVariant;)V # createGrassLikeBlock protected net.minecraft.client.data.models.BlockModelGenerators m_372663_()V # createFrostedIce protected net.minecraft.client.data.models.BlockModelGenerators m_372681_(Lnet/minecraft/client/data/models/model/TexturedModel$Provider;[Lnet/minecraft/world/level/block/Block;)V # createColoredBlockWithStateRotations @@ -60,7 +55,6 @@ protected net.minecraft.client.data.models.BlockModelGenerators m_372705_(Lnet/m protected net.minecraft.client.data.models.BlockModelGenerators m_372711_(Lnet/minecraft/world/level/block/Block;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/client/data/models/blockstates/BlockModelDefinitionGenerator; # createDoor protected net.minecraft.client.data.models.BlockModelGenerators m_372719_()V # createChorusFlower protected net.minecraft.client.data.models.BlockModelGenerators m_372720_()V # createCocoa -protected net.minecraft.client.data.models.BlockModelGenerators m_372723_(Lnet/minecraft/client/data/models/model/TextureMapping;)V # lambda$static$10 protected net.minecraft.client.data.models.BlockModelGenerators m_372724_()V # createSmallDripleaf protected net.minecraft.client.data.models.BlockModelGenerators m_372726_(Lnet/minecraft/world/level/block/Block;)V # createMultiface protected net.minecraft.client.data.models.BlockModelGenerators m_372729_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/Block;Lnet/minecraft/client/data/models/BlockModelGenerators$PlantType;)V # createGrowingPlant @@ -68,7 +62,6 @@ protected net.minecraft.client.data.models.BlockModelGenerators m_372730_()V # c protected net.minecraft.client.data.models.BlockModelGenerators m_372737_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/client/data/models/BlockModelGenerators$PlantType;)V # createCrossBlock protected net.minecraft.client.data.models.BlockModelGenerators m_372739_()V # createNetherPortalBlock protected net.minecraft.client.data.models.BlockModelGenerators m_372745_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/Block;)V # createNetherRoots -protected net.minecraft.client.data.models.BlockModelGenerators m_372746_(Lnet/minecraft/client/data/models/model/TextureMapping;Lnet/minecraft/resources/ResourceLocation;)Lnet/minecraft/client/data/models/model/TextureMapping; # lambda$createCommandBlock$21 protected net.minecraft.client.data.models.BlockModelGenerators m_372768_(Lnet/minecraft/world/level/block/Block;)V # createAmethystCluster protected net.minecraft.client.data.models.BlockModelGenerators m_372788_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/Block;)V # copyDoorModel protected net.minecraft.client.data.models.BlockModelGenerators m_372818_(Lnet/minecraft/world/level/block/Block;)Lnet/minecraft/client/data/models/MultiVariant; # createTopFireModels @@ -83,7 +76,7 @@ protected net.minecraft.client.data.models.BlockModelGenerators m_372876_()V # c protected net.minecraft.client.data.models.BlockModelGenerators m_372882_(Lnet/minecraft/client/data/models/model/TexturedModel$Provider;[Lnet/minecraft/world/level/block/Block;)V # createColoredBlockWithRandomRotations protected net.minecraft.client.data.models.BlockModelGenerators m_372884_()V # createLever protected net.minecraft.client.data.models.BlockModelGenerators m_372888_(Lnet/minecraft/core/FrontAndTop;)Lnet/minecraft/client/renderer/block/model/VariantMutator; # applyRotation -protected net.minecraft.client.data.models.BlockModelGenerators m_372908_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/Block;Lnet/minecraft/resources/ResourceLocation;Z)V # createChest +protected net.minecraft.client.data.models.BlockModelGenerators m_372908_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/Block;Lnet/minecraft/resources/Identifier;Z)V # createChest protected net.minecraft.client.data.models.BlockModelGenerators m_372933_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/Block;Lnet/minecraft/client/data/models/BlockModelGenerators$PlantType;)V # createPlantWithDefaultItem protected net.minecraft.client.data.models.BlockModelGenerators m_372942_()V # createStonecutter protected net.minecraft.client.data.models.BlockModelGenerators m_372944_(Lnet/minecraft/world/level/block/Block;)V # createCreakingHeart @@ -97,11 +90,10 @@ protected net.minecraft.client.data.models.BlockModelGenerators m_373004_(Lnet/m protected net.minecraft.client.data.models.BlockModelGenerators m_373008_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/item/DyeColor;)V # createShulkerBox protected net.minecraft.client.data.models.BlockModelGenerators m_373026_(Lnet/minecraft/world/item/Item;)V # registerSimpleFlatItemModel protected net.minecraft.client.data.models.BlockModelGenerators m_373035_(Lnet/minecraft/world/level/block/Block;)V # createItemWithGrassTint -protected net.minecraft.client.data.models.BlockModelGenerators m_373046_(Lnet/minecraft/world/item/Item;Lnet/minecraft/world/level/block/Block;Ljava/lang/String;)Lnet/minecraft/resources/ResourceLocation; # createFlatItemModelWithBlockTextureAndOverlay -protected net.minecraft.client.data.models.BlockModelGenerators m_373060_(Lnet/minecraft/client/data/models/model/TextureMapping;)V # lambda$static$12 +protected net.minecraft.client.data.models.BlockModelGenerators m_373046_(Lnet/minecraft/world/item/Item;Lnet/minecraft/world/level/block/Block;Ljava/lang/String;)Lnet/minecraft/resources/Identifier; # createFlatItemModelWithBlockTextureAndOverlay protected net.minecraft.client.data.models.BlockModelGenerators m_373071_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/client/data/models/BlockModelGenerators$PlantType;Lnet/minecraft/client/data/models/model/TextureMapping;)V # createCrossBlock protected net.minecraft.client.data.models.BlockModelGenerators m_373072_(Lnet/minecraft/world/level/block/Block;)V # createParticleOnlyBlock -protected net.minecraft.client.data.models.BlockModelGenerators m_373089_(Lnet/minecraft/world/item/Item;)Lnet/minecraft/resources/ResourceLocation; # createFlatItemModel +protected net.minecraft.client.data.models.BlockModelGenerators m_373089_(Lnet/minecraft/world/item/Item;)Lnet/minecraft/resources/Identifier; # createFlatItemModel protected net.minecraft.client.data.models.BlockModelGenerators m_373098_()V # createCaveVines protected net.minecraft.client.data.models.BlockModelGenerators m_373159_()V # createComposter protected net.minecraft.client.data.models.BlockModelGenerators m_373171_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/Block;Ljava/util/function/BiFunction;)V # createCraftingTableLike @@ -111,7 +103,6 @@ protected net.minecraft.client.data.models.BlockModelGenerators m_373188_()V # c protected net.minecraft.client.data.models.BlockModelGenerators m_373195_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/client/renderer/special/SpecialModelRenderer$Unbaked;)V # generateSimpleSpecialItemModel protected net.minecraft.client.data.models.BlockModelGenerators m_373216_(Lnet/minecraft/world/level/block/Block;)Lnet/minecraft/client/data/models/MultiVariant; # createFloorFireModels protected net.minecraft.client.data.models.BlockModelGenerators m_373228_(Lnet/minecraft/world/level/block/Block;)Lnet/minecraft/client/data/models/BlockModelGenerators$BlockFamilyProvider; # family -protected net.minecraft.client.data.models.BlockModelGenerators m_373247_(Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/client/data/models/model/TextureMapping;)V # lambda$createFurnace$27 protected net.minecraft.client.data.models.BlockModelGenerators m_373255_()V # createPumpkins protected net.minecraft.client.data.models.BlockModelGenerators m_373266_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/MultiVariant;)Lnet/minecraft/client/data/models/blockstates/BlockModelDefinitionGenerator; # createPressurePlate protected net.minecraft.client.data.models.BlockModelGenerators m_373285_(Lnet/minecraft/world/level/block/state/properties/Property;Ljava/lang/Comparable;Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/MultiVariant;)Lnet/minecraft/client/data/models/blockstates/PropertyDispatch; # createEmptyOrFullDispatch @@ -130,17 +121,14 @@ protected net.minecraft.client.data.models.BlockModelGenerators m_373367_(Lnet/m protected net.minecraft.client.data.models.BlockModelGenerators m_373371_(Lnet/minecraft/world/level/block/Block;)V # createNonTemplateModelBlock protected net.minecraft.client.data.models.BlockModelGenerators m_373393_()V # createRedstoneTorch protected net.minecraft.client.data.models.BlockModelGenerators m_373406_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/client/data/models/MultiVariant;)V # createAxisAlignedPillarBlockCustomModel -protected net.minecraft.client.data.models.BlockModelGenerators m_373410_(Lnet/minecraft/client/data/models/model/TextureMapping;)V # lambda$static$11 protected net.minecraft.client.data.models.BlockModelGenerators m_373413_(Lnet/minecraft/world/level/block/Block;)V # createMultifaceBlockStates protected net.minecraft.client.data.models.BlockModelGenerators m_373423_()V # createGrassBlocks protected net.minecraft.client.data.models.BlockModelGenerators m_373424_()V # createChiseledBookshelf protected net.minecraft.client.data.models.BlockModelGenerators m_373437_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/Block;)V # createNonTemplateModelBlock -protected net.minecraft.client.data.models.BlockModelGenerators m_373454_(Lnet/minecraft/client/data/models/model/TextureMapping;Lnet/minecraft/resources/ResourceLocation;)Lnet/minecraft/client/data/models/model/TextureMapping; # lambda$createChorusFlower$28 -protected net.minecraft.client.data.models.BlockModelGenerators m_373466_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/resources/ResourceLocation;)V # registerSimpleItemModel +protected net.minecraft.client.data.models.BlockModelGenerators m_373466_(Lnet/minecraft/world/item/Item;Lnet/minecraft/resources/Identifier;)V # registerSimpleItemModel protected net.minecraft.client.data.models.BlockModelGenerators m_373467_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/model/TextureMapping;)V # createPistonVariant -protected net.minecraft.client.data.models.BlockModelGenerators m_373468_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/client/color/item/ItemTintSource;)V # registerSimpleTintedItemModel +protected net.minecraft.client.data.models.BlockModelGenerators m_373468_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/resources/Identifier;Lnet/minecraft/client/color/item/ItemTintSource;)V # registerSimpleTintedItemModel protected net.minecraft.client.data.models.BlockModelGenerators m_373481_(Lnet/minecraft/world/level/block/Block;)V # createMushroomBlock -protected net.minecraft.client.data.models.BlockModelGenerators m_373512_(Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/client/data/models/model/TextureMapping;)V # lambda$createGrassBlocks$31 protected net.minecraft.client.data.models.BlockModelGenerators m_373523_()V # createRepeater protected net.minecraft.client.data.models.BlockModelGenerators m_373526_()V # createRedstoneLamp protected net.minecraft.client.data.models.BlockModelGenerators m_373558_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/client/data/models/model/TexturedModel$Provider;)V # createFurnace @@ -159,11 +147,11 @@ protected net.minecraft.client.data.models.BlockModelGenerators m_373707_(Lnet/m protected net.minecraft.client.data.models.BlockModelGenerators m_373721_(Lnet/minecraft/world/level/block/Block;)V # createNonTemplateHorizontalBlock protected net.minecraft.client.data.models.BlockModelGenerators m_373723_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/Block;)V # createGlassBlocks protected net.minecraft.client.data.models.BlockModelGenerators m_373729_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/client/data/models/model/TexturedModel$Provider;)V # createHorizontallyRotatedBlock -protected net.minecraft.client.data.models.BlockModelGenerators m_373730_(Lnet/minecraft/world/level/block/Block;Ljava/lang/String;Lnet/minecraft/client/data/models/model/ModelTemplate;Ljava/util/function/Function;)Lnet/minecraft/resources/ResourceLocation; # createSuffixedVariant +protected net.minecraft.client.data.models.BlockModelGenerators m_373730_(Lnet/minecraft/world/level/block/Block;Ljava/lang/String;Lnet/minecraft/client/data/models/model/ModelTemplate;Ljava/util/function/Function;)Lnet/minecraft/resources/Identifier; # createSuffixedVariant protected net.minecraft.client.data.models.BlockModelGenerators m_373795_(ILjava/lang/String;Lnet/minecraft/client/data/models/model/TextureMapping;)Lnet/minecraft/client/renderer/block/model/Variant; # createTurtleEggModel -protected net.minecraft.client.data.models.BlockModelGenerators m_373801_(Lnet/minecraft/world/item/Item;Lnet/minecraft/world/level/block/Block;)Lnet/minecraft/resources/ResourceLocation; # createFlatItemModelWithBlockTexture +protected net.minecraft.client.data.models.BlockModelGenerators m_373801_(Lnet/minecraft/world/item/Item;Lnet/minecraft/world/level/block/Block;)Lnet/minecraft/resources/Identifier; # createFlatItemModelWithBlockTexture protected net.minecraft.client.data.models.BlockModelGenerators m_373808_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/client/renderer/block/model/Variant;Lnet/minecraft/client/data/models/model/TextureMapping;Ljava/util/function/BiConsumer;)Lnet/minecraft/client/data/models/blockstates/BlockModelDefinitionGenerator; # createMirroredCubeGenerator -protected net.minecraft.client.data.models.BlockModelGenerators m_373813_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/SkullBlock$Type;Lnet/minecraft/resources/ResourceLocation;)V # createHead +protected net.minecraft.client.data.models.BlockModelGenerators m_373813_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/SkullBlock$Type;Lnet/minecraft/resources/Identifier;)V # createHead 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 @@ -176,7 +164,6 @@ protected net.minecraft.client.data.models.BlockModelGenerators m_373929_()V # c protected net.minecraft.client.data.models.BlockModelGenerators m_373936_()V # createLilyPad protected net.minecraft.client.data.models.BlockModelGenerators m_373941_(Lnet/minecraft/world/level/block/Block;)Lnet/minecraft/client/data/models/MultiVariant; # createSideFireModels protected net.minecraft.client.data.models.BlockModelGenerators m_373945_()V # createTurtleEgg -protected net.minecraft.client.data.models.BlockModelGenerators m_373961_(Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/client/data/models/model/TextureMapping;)V # lambda$createGrassBlocks$32 protected net.minecraft.client.data.models.BlockModelGenerators m_373974_()V # createBell 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 @@ -196,7 +183,7 @@ protected net.minecraft.client.data.models.BlockModelGenerators m_374177_()V # c protected net.minecraft.client.data.models.BlockModelGenerators m_374216_(Lnet/minecraft/world/level/block/Block;)V # createOrientableTrapdoor protected net.minecraft.client.data.models.BlockModelGenerators m_374249_()V # createChorusPlant protected net.minecraft.client.data.models.BlockModelGenerators m_374256_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/Block;)V # createFullAndCarpetBlocks -protected net.minecraft.client.data.models.BlockModelGenerators m_374265_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/resources/ResourceLocation;)V # createAirLikeBlock +protected net.minecraft.client.data.models.BlockModelGenerators m_374265_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/resources/Identifier;)V # createAirLikeBlock protected net.minecraft.client.data.models.BlockModelGenerators m_374268_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/item/DyeColor;)V # createBanner protected net.minecraft.client.data.models.BlockModelGenerators m_374273_()V # createNetherrack protected net.minecraft.client.data.models.BlockModelGenerators m_374284_()V # createInfestedDeepslate @@ -204,7 +191,6 @@ protected net.minecraft.client.data.models.BlockModelGenerators m_374293_()V # c protected net.minecraft.client.data.models.BlockModelGenerators m_374299_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/MultiVariant;)Lnet/minecraft/client/data/models/blockstates/BlockModelDefinitionGenerator; # createFence protected net.minecraft.client.data.models.BlockModelGenerators m_374303_(Lnet/minecraft/world/level/block/Block;)V # createNyliumBlock protected net.minecraft.client.data.models.BlockModelGenerators m_374308_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/Block;)V # createCandleAndCandleCake -protected net.minecraft.client.data.models.BlockModelGenerators m_374312_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/client/data/models/model/TextureMapping;)V # lambda$createMossyCarpet$52 protected net.minecraft.client.data.models.BlockModelGenerators m_374339_()V # createRedstoneWire protected net.minecraft.client.data.models.BlockModelGenerators m_374347_()V # createBarrel protected net.minecraft.client.data.models.BlockModelGenerators m_374348_()V # createRespawnAnchor @@ -227,42 +213,24 @@ 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$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_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 -protected net.minecraft.client.data.models.BlockModelGenerators m_382779_([ILnet/minecraft/world/level/block/Block;Lnet/minecraft/client/data/models/BlockModelGenerators$PlantType;Ljava/lang/Integer;)Lnet/minecraft/client/data/models/MultiVariant; # lambda$createCrossBlock$17 protected net.minecraft.client.data.models.BlockModelGenerators m_382780_(Ljava/util/function/Function;Lnet/minecraft/world/level/block/state/StateHolder;Lcom/google/common/collect/ImmutableMap$Builder;Lnet/minecraft/core/Direction;Lnet/minecraft/client/renderer/block/model/VariantMutator;)V # lambda$selectMultifaceProperties$47 -protected net.minecraft.client.data.models.BlockModelGenerators m_382781_(Lnet/minecraft/world/level/block/Block;Ljava/lang/Integer;)Lnet/minecraft/client/data/models/MultiVariant; # lambda$createBrushableBlock$15 -protected net.minecraft.client.data.models.BlockModelGenerators m_382782_(Ljava/lang/Integer;Ljava/lang/Boolean;Ljava/lang/Boolean;)Lnet/minecraft/client/data/models/MultiVariant; # lambda$createRepeater$37 protected net.minecraft.client.data.models.BlockModelGenerators m_382783_(Lnet/minecraft/client/renderer/block/model/Variant;)Lnet/minecraft/util/random/Weighted; # lambda$variants$9 -protected net.minecraft.client.data.models.BlockModelGenerators m_382784_(Lnet/minecraft/client/data/models/MultiVariant;Ljava/lang/Integer;)Lnet/minecraft/client/data/models/MultiVariant; # lambda$createSnowBlocks$38 -protected net.minecraft.client.data.models.BlockModelGenerators m_382785_(Lnet/minecraft/world/level/block/Block;Ljava/lang/Boolean;)Lnet/minecraft/client/data/models/MultiVariant; # lambda$createHangingMoss$54 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$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$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 -protected net.minecraft.client.data.models.BlockModelGenerators m_382799_([ILit/unimi/dsi/fastutil/ints/Int2ObjectMap;Lnet/minecraft/world/level/block/Block;Ljava/lang/Integer;)Lnet/minecraft/client/data/models/MultiVariant; # lambda$createCropBlock$26 protected net.minecraft.client.data.models.BlockModelGenerators m_382800_(Lnet/minecraft/client/data/models/blockstates/ConditionBuilder;)Lnet/minecraft/client/data/models/blockstates/ConditionBuilder; # lambda$static$8 protected net.minecraft.client.data.models.BlockModelGenerators m_382801_(Lnet/minecraft/client/data/models/blockstates/MultiPartGenerator;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$createMultifaceBlockStates$49 protected net.minecraft.client.data.models.BlockModelGenerators m_382802_(Lnet/minecraft/client/data/models/blockstates/ConditionBuilder;)Lnet/minecraft/client/data/models/blockstates/ConditionBuilder; # lambda$static$7 -protected net.minecraft.client.data.models.BlockModelGenerators m_382803_(Ljava/lang/Boolean;Ljava/lang/Boolean;)Lnet/minecraft/client/data/models/MultiVariant; # lambda$createTripwireHook$42 -protected net.minecraft.client.data.models.BlockModelGenerators m_382804_(Lnet/minecraft/world/level/block/state/properties/StructureMode;)Lnet/minecraft/client/data/models/MultiVariant; # lambda$createStructureBlock$39 -protected net.minecraft.client.data.models.BlockModelGenerators m_382805_(Ljava/lang/Integer;)Lnet/minecraft/client/data/models/MultiVariant; # lambda$createSnifferEgg$46 -protected net.minecraft.client.data.models.BlockModelGenerators m_382806_(Ljava/util/Map;Lnet/minecraft/world/level/block/state/properties/TestBlockMode;)Lnet/minecraft/client/data/models/MultiVariant; # lambda$createTestBlock$40 protected net.minecraft.client.data.models.BlockModelGenerators m_382807_(Lnet/minecraft/client/data/models/blockstates/ConditionBuilder;)Lnet/minecraft/client/data/models/blockstates/ConditionBuilder; # lambda$static$5 protected net.minecraft.client.data.models.BlockModelGenerators m_382808_(Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/MultiVariant;Ljava/lang/Boolean;)Lnet/minecraft/client/data/models/MultiVariant; # lambda$createSculkCatalyst$55 protected net.minecraft.client.data.models.BlockModelGenerators m_382809_(Lnet/minecraft/client/data/models/blockstates/ConditionBuilder;)Lnet/minecraft/client/data/models/blockstates/ConditionBuilder; # lambda$static$6 @@ -271,17 +239,15 @@ protected net.minecraft.client.data.models.BlockModelGenerators m_382811_(Lnet/m protected net.minecraft.client.data.models.BlockModelGenerators m_384704_(Lnet/minecraft/world/level/block/state/StateHolder;Ljava/util/function/Function;)Ljava/util/Map; # selectMultifaceProperties protected net.minecraft.client.data.models.BlockModelGenerators m_384866_()Lnet/minecraft/client/data/models/blockstates/ConditionBuilder; # condition protected net.minecraft.client.data.models.BlockModelGenerators m_385280_(Lnet/minecraft/client/renderer/block/model/Variant;)Lnet/minecraft/client/data/models/MultiVariant; # variant -protected net.minecraft.client.data.models.BlockModelGenerators m_385381_(Lnet/minecraft/resources/ResourceLocation;)Lnet/minecraft/client/data/models/MultiVariant; # plainVariant +protected net.minecraft.client.data.models.BlockModelGenerators m_385381_(Lnet/minecraft/resources/Identifier;)Lnet/minecraft/client/data/models/MultiVariant; # plainVariant protected net.minecraft.client.data.models.BlockModelGenerators m_385921_([Lnet/minecraft/client/renderer/block/model/Variant;)Lnet/minecraft/client/data/models/MultiVariant; # variants protected net.minecraft.client.data.models.BlockModelGenerators m_386106_()V # createTestBlock protected net.minecraft.client.data.models.BlockModelGenerators m_386644_([Lnet/minecraft/client/data/models/blockstates/ConditionBuilder;)Lnet/minecraft/client/renderer/block/model/multipart/Condition; # or -protected net.minecraft.client.data.models.BlockModelGenerators m_387650_(Lnet/minecraft/resources/ResourceLocation;)Lnet/minecraft/client/renderer/block/model/Variant; # plainModel +protected net.minecraft.client.data.models.BlockModelGenerators m_387650_(Lnet/minecraft/resources/Identifier;)Lnet/minecraft/client/renderer/block/model/Variant; # plainModel protected net.minecraft.client.data.models.BlockModelGenerators m_388125_(Lnet/minecraft/client/renderer/block/model/Variant;Lnet/minecraft/client/renderer/block/model/Variant;)Lnet/minecraft/client/data/models/MultiVariant; # createRotatedVariants -protected net.minecraft.client.data.models.BlockModelGenerators m_388369_(Lnet/minecraft/client/data/models/model/TexturedModel$Provider;Lnet/minecraft/world/level/block/Block;Ljava/lang/String;)Lnet/minecraft/resources/ResourceLocation; # createCreakingHeartModel +protected net.minecraft.client.data.models.BlockModelGenerators m_388369_(Lnet/minecraft/client/data/models/model/TexturedModel$Provider;Lnet/minecraft/world/level/block/Block;Ljava/lang/String;)Lnet/minecraft/resources/Identifier; # createCreakingHeartModel protected net.minecraft.client.data.models.BlockModelGenerators m_388485_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/client/data/models/MultiVariant;Ljava/util/function/Function;Lnet/minecraft/client/data/models/MultiVariant;Ljava/util/function/Function;Lnet/minecraft/client/data/models/MultiVariant;Ljava/util/function/Function;Lnet/minecraft/client/data/models/MultiVariant;Ljava/util/function/Function;)V # createSegmentedBlock protected net.minecraft.client.data.models.BlockModelGenerators m_389054_(Lnet/minecraft/client/renderer/block/model/Variant;)Lnet/minecraft/client/data/models/MultiVariant; # createRotatedVariants -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 @@ -293,7 +259,7 @@ protected net.minecraft.client.data.models.BlockModelGenerators m_416125_(Ljava/ 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_417208_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/resources/Identifier;Lnet/minecraft/resources/Identifier;Lnet/minecraft/resources/Identifier;Lnet/minecraft/resources/Identifier;Lnet/minecraft/resources/Identifier;Lnet/minecraft/resources/Identifier;)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 @@ -302,6 +268,40 @@ protected net.minecraft.client.data.models.BlockModelGenerators m_419661_()V # c 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 +protected net.minecraft.client.data.models.BlockModelGenerators m_437529_([ILit/unimi/dsi/fastutil/ints/Int2ObjectMap;Lnet/minecraft/world/level/block/Block;Ljava/lang/Integer;)Lnet/minecraft/client/data/models/MultiVariant; # lambda$createCropBlock$26 +protected net.minecraft.client.data.models.BlockModelGenerators m_437530_(Ljava/lang/Integer;)Lnet/minecraft/resources/Identifier; # lambda$createDriedGhastBlock$44 +protected net.minecraft.client.data.models.BlockModelGenerators m_437531_([Lnet/minecraft/resources/Identifier;Ljava/lang/Integer;)Lnet/minecraft/client/data/models/MultiVariant; # lambda$createRespawnAnchor$61 +protected net.minecraft.client.data.models.BlockModelGenerators m_437532_(Lnet/minecraft/resources/Identifier;Lnet/minecraft/client/data/models/model/TextureMapping;)V # lambda$createGrassBlocks$32 +protected net.minecraft.client.data.models.BlockModelGenerators m_437533_(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 +protected net.minecraft.client.data.models.BlockModelGenerators m_437534_(Lnet/minecraft/client/data/models/MultiVariant;Ljava/lang/Integer;)Lnet/minecraft/client/data/models/MultiVariant; # lambda$createSnowBlocks$38 +protected net.minecraft.client.data.models.BlockModelGenerators m_437535_(Ljava/lang/Boolean;Ljava/lang/Boolean;)Lnet/minecraft/client/data/models/MultiVariant; # lambda$createTripwireHook$42 +protected net.minecraft.client.data.models.BlockModelGenerators m_437536_(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_437537_(Lnet/minecraft/client/data/models/model/TextureMapping;)V # lambda$static$13 +protected net.minecraft.client.data.models.BlockModelGenerators m_437538_(Ljava/lang/Integer;)Lnet/minecraft/client/data/models/MultiVariant; # lambda$createSweetBerryBush$41 +protected net.minecraft.client.data.models.BlockModelGenerators m_437539_(Lnet/minecraft/client/data/models/model/TextureMapping;)V # lambda$static$12 +protected net.minecraft.client.data.models.BlockModelGenerators m_437540_(Lnet/minecraft/world/level/block/Block;Ljava/lang/Boolean;)Lnet/minecraft/client/data/models/MultiVariant; # lambda$createHangingMoss$54 +protected net.minecraft.client.data.models.BlockModelGenerators m_437541_(Lnet/minecraft/world/level/block/Block;Ljava/lang/Integer;)Lnet/minecraft/client/data/models/MultiVariant; # lambda$createBrushableBlock$15 +protected net.minecraft.client.data.models.BlockModelGenerators m_437542_(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/Identifier; # lambda$addBookSlotModel$60 +protected net.minecraft.client.data.models.BlockModelGenerators m_437543_(Lnet/minecraft/client/data/models/model/TextureMapping;)V # lambda$static$10 +protected net.minecraft.client.data.models.BlockModelGenerators m_437544_([ILnet/minecraft/world/level/block/Block;Lnet/minecraft/client/data/models/BlockModelGenerators$PlantType;Ljava/lang/Integer;)Lnet/minecraft/client/data/models/MultiVariant; # lambda$createCrossBlock$17 +protected net.minecraft.client.data.models.BlockModelGenerators m_437545_(Lnet/minecraft/resources/Identifier;Lnet/minecraft/client/data/models/model/TextureMapping;)V # lambda$createBarrel$23 +protected net.minecraft.client.data.models.BlockModelGenerators m_437546_(Ljava/util/function/Function;Ljava/lang/Integer;)Lnet/minecraft/client/data/models/MultiVariant; # lambda$createDriedGhastBlock$45 +protected net.minecraft.client.data.models.BlockModelGenerators m_437547_(Lnet/minecraft/client/data/models/model/TextureMapping;Lnet/minecraft/resources/Identifier;)Lnet/minecraft/client/data/models/model/TextureMapping; # lambda$createChorusFlower$28 +protected net.minecraft.client.data.models.BlockModelGenerators m_437548_(Lnet/minecraft/client/data/models/model/TextureMapping;)V # lambda$static$11 +protected net.minecraft.client.data.models.BlockModelGenerators m_437549_(Ljava/lang/Integer;)Lnet/minecraft/client/data/models/MultiVariant; # lambda$createSnifferEgg$46 +protected net.minecraft.client.data.models.BlockModelGenerators m_437550_(Lnet/minecraft/client/data/models/model/TextureMapping;)V # lambda$static$14 +protected net.minecraft.client.data.models.BlockModelGenerators m_437551_(Lnet/minecraft/world/level/block/state/properties/StructureMode;)Lnet/minecraft/client/data/models/MultiVariant; # lambda$createStructureBlock$39 +protected net.minecraft.client.data.models.BlockModelGenerators m_437552_(Lnet/minecraft/resources/Identifier;Lnet/minecraft/client/data/models/model/TextureMapping;)V # lambda$createGrassBlocks$31 +protected net.minecraft.client.data.models.BlockModelGenerators m_437553_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/client/data/models/model/TextureMapping;)V # lambda$createMossyCarpet$52 +protected net.minecraft.client.data.models.BlockModelGenerators m_437554_(Lnet/minecraft/client/data/models/model/TextureMapping;Lnet/minecraft/resources/Identifier;)Lnet/minecraft/client/data/models/model/TextureMapping; # lambda$createCommandBlock$21 +protected net.minecraft.client.data.models.BlockModelGenerators m_437555_(Ljava/util/Map;Lnet/minecraft/world/level/block/state/properties/TestBlockMode;)Lnet/minecraft/client/data/models/MultiVariant; # lambda$createTestBlock$40 +protected net.minecraft.client.data.models.BlockModelGenerators m_437556_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/client/data/models/model/TextureMapping;)V # lambda$createMossyCarpet$51 +protected net.minecraft.client.data.models.BlockModelGenerators m_437557_(Ljava/lang/String;I)Lnet/minecraft/util/random/Weighted; # lambda$createBambooModels$22 +protected net.minecraft.client.data.models.BlockModelGenerators m_437558_(Ljava/lang/Integer;Ljava/lang/Boolean;Ljava/lang/Boolean;)Lnet/minecraft/client/data/models/MultiVariant; # lambda$createRepeater$37 +protected net.minecraft.client.data.models.BlockModelGenerators m_437559_(Lnet/minecraft/world/level/block/Block;I)Lnet/minecraft/resources/Identifier; # lambda$createCropBlock$25 +protected net.minecraft.client.data.models.BlockModelGenerators m_437560_(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_437561_(Lnet/minecraft/resources/Identifier;Lnet/minecraft/client/data/models/model/TextureMapping;)V # lambda$createFurnace$27 +protected net.minecraft.client.data.models.BlockModelGenerators m_437562_(Lnet/minecraft/world/level/block/Block;Ljava/lang/String;Lnet/minecraft/client/data/models/model/TextureMapping;)V # lambda$createCreakingHeartModel$16 #endgroup protected net.minecraft.client.data.models.BlockModelGenerators f_371124_ # itemModelOutput protected net.minecraft.client.data.models.BlockModelGenerators f_371133_ # modelOutput @@ -309,11 +309,11 @@ protected net.minecraft.client.data.models.BlockModelGenerators f_371615_ # bloc public net.minecraft.client.data.models.BlockModelGenerators$BlockFamilyProvider #group protected net.minecraft.client.data.models.BlockModelGenerators$BlockFamilyProvider *() protected net.minecraft.client.data.models.BlockModelGenerators$BlockFamilyProvider m_372389_(Lnet/minecraft/world/level/block/Block;)V # trapdoor -protected net.minecraft.client.data.models.BlockModelGenerators$BlockFamilyProvider m_372633_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/client/data/models/model/ModelTemplate;)Lnet/minecraft/resources/ResourceLocation; # lambda$getOrCreateModel$0 protected net.minecraft.client.data.models.BlockModelGenerators$BlockFamilyProvider m_373052_(Lnet/minecraft/world/level/block/Block;)Lnet/minecraft/client/data/models/BlockModelGenerators$BlockFamilyProvider; # door -protected net.minecraft.client.data.models.BlockModelGenerators$BlockFamilyProvider m_373078_(Lnet/minecraft/client/data/models/model/ModelTemplate;Lnet/minecraft/world/level/block/Block;)Lnet/minecraft/resources/ResourceLocation; # getOrCreateModel +protected net.minecraft.client.data.models.BlockModelGenerators$BlockFamilyProvider m_373078_(Lnet/minecraft/client/data/models/model/ModelTemplate;Lnet/minecraft/world/level/block/Block;)Lnet/minecraft/resources/Identifier; # getOrCreateModel protected net.minecraft.client.data.models.BlockModelGenerators$BlockFamilyProvider m_373633_(Lnet/minecraft/data/BlockFamily$Variant;Lnet/minecraft/world/level/block/Block;)V # lambda$generateFor$1 protected net.minecraft.client.data.models.BlockModelGenerators$BlockFamilyProvider m_373732_(Lnet/minecraft/world/level/block/Block;)Lnet/minecraft/client/data/models/BlockModelGenerators$BlockFamilyProvider; # fullBlockVariant +protected net.minecraft.client.data.models.BlockModelGenerators$BlockFamilyProvider m_437563_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/client/data/models/model/ModelTemplate;)Lnet/minecraft/resources/Identifier; # lambda$getOrCreateModel$0 #endgroup public net.minecraft.client.data.models.BlockModelGenerators$PlantType public net.minecraft.client.data.models.BlockModelGenerators$WoodProvider @@ -322,20 +322,20 @@ protected net.minecraft.client.data.models.ItemModelGenerators m_372103_(Lnet/mi protected net.minecraft.client.data.models.ItemModelGenerators m_372177_(Lnet/minecraft/world/item/Item;)V # generateBundleModels protected net.minecraft.client.data.models.ItemModelGenerators m_372280_(Lnet/minecraft/world/item/Item;Lnet/minecraft/client/data/models/model/ModelTemplate;)V # generateFlatItem protected net.minecraft.client.data.models.ItemModelGenerators m_372299_(Lnet/minecraft/world/item/Item;)V # generateClockItem -protected net.minecraft.client.data.models.ItemModelGenerators m_372587_(Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/resources/ResourceLocation;)V # generateLayeredItem +protected net.minecraft.client.data.models.ItemModelGenerators m_372587_(Lnet/minecraft/resources/Identifier;Lnet/minecraft/resources/Identifier;Lnet/minecraft/resources/Identifier;Lnet/minecraft/resources/Identifier;)V # generateLayeredItem protected net.minecraft.client.data.models.ItemModelGenerators m_372592_(Lnet/minecraft/world/item/Item;)Ljava/util/List; # createCompassModels -protected net.minecraft.client.data.models.ItemModelGenerators m_372634_(Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/resources/ResourceLocation;)Lnet/minecraft/resources/ResourceLocation; # generateLayeredItem -protected net.minecraft.client.data.models.ItemModelGenerators m_372677_(Lnet/minecraft/world/item/Item;Lnet/minecraft/resources/ResourceLocation;)V # addPotionTint +protected net.minecraft.client.data.models.ItemModelGenerators m_372634_(Lnet/minecraft/resources/Identifier;Lnet/minecraft/resources/Identifier;Lnet/minecraft/resources/Identifier;)Lnet/minecraft/resources/Identifier; # generateLayeredItem +protected net.minecraft.client.data.models.ItemModelGenerators m_372677_(Lnet/minecraft/world/item/Item;Lnet/minecraft/resources/Identifier;)V # addPotionTint protected net.minecraft.client.data.models.ItemModelGenerators m_372690_(Lnet/minecraft/world/item/Item;)V # generateCrossbow protected net.minecraft.client.data.models.ItemModelGenerators m_372771_(Lnet/minecraft/world/item/Item;)V # generateGoatHorn protected net.minecraft.client.data.models.ItemModelGenerators m_372861_(Lnet/minecraft/world/item/Item;)V # generatePotion -protected net.minecraft.client.data.models.ItemModelGenerators m_372885_(Lnet/minecraft/world/item/Item;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/resources/ResourceLocation;)Lnet/minecraft/resources/ResourceLocation; # generateLayeredItem +protected net.minecraft.client.data.models.ItemModelGenerators m_372885_(Lnet/minecraft/world/item/Item;Lnet/minecraft/resources/Identifier;Lnet/minecraft/resources/Identifier;)Lnet/minecraft/resources/Identifier; # generateLayeredItem protected net.minecraft.client.data.models.ItemModelGenerators m_372915_(Lnet/minecraft/world/item/Item;Lnet/minecraft/client/color/item/ItemTintSource;)V # generateItemWithTintedOverlay -protected net.minecraft.client.data.models.ItemModelGenerators m_372919_(Lnet/minecraft/world/item/Item;Lnet/minecraft/resources/ResourceKey;Lnet/minecraft/resources/ResourceLocation;Z)V # generateTrimmableItem -protected net.minecraft.client.data.models.ItemModelGenerators m_372969_(Lnet/minecraft/world/item/Item;Ljava/lang/String;Lnet/minecraft/client/data/models/model/ModelTemplate;)Lnet/minecraft/resources/ResourceLocation; # createFlatItemModel +protected net.minecraft.client.data.models.ItemModelGenerators m_372919_(Lnet/minecraft/world/item/Item;Lnet/minecraft/resources/ResourceKey;Lnet/minecraft/resources/Identifier;Z)V # generateTrimmableItem +protected net.minecraft.client.data.models.ItemModelGenerators m_372969_(Lnet/minecraft/world/item/Item;Lnet/minecraft/world/item/Item;Lnet/minecraft/client/data/models/model/ModelTemplate;)Lnet/minecraft/resources/Identifier; # createFlatItemModel protected net.minecraft.client.data.models.ItemModelGenerators m_373030_(Lnet/minecraft/world/item/Item;)V # generateShield protected net.minecraft.client.data.models.ItemModelGenerators m_373037_(Lnet/minecraft/world/item/Item;)V # generateStandardCompassItem -protected net.minecraft.client.data.models.ItemModelGenerators m_373158_(Lnet/minecraft/world/item/Item;Lnet/minecraft/client/data/models/model/ModelTemplate;Ljava/lang/String;)Lnet/minecraft/resources/ResourceLocation; # generateBundleCoverModel +protected net.minecraft.client.data.models.ItemModelGenerators m_373158_(Lnet/minecraft/world/item/Item;Lnet/minecraft/client/data/models/model/ModelTemplate;Ljava/lang/String;)Lnet/minecraft/resources/Identifier; # generateBundleCoverModel protected net.minecraft.client.data.models.ItemModelGenerators m_373235_(Lnet/minecraft/world/item/Item;)V # generateTippedArrow protected net.minecraft.client.data.models.ItemModelGenerators m_373294_(Lnet/minecraft/client/renderer/item/ItemModel$Unbaked;Lnet/minecraft/client/renderer/item/ItemModel$Unbaked;)Lnet/minecraft/client/renderer/item/ItemModel$Unbaked; # createFlatModelDispatch protected net.minecraft.client.data.models.ItemModelGenerators m_373463_(Lnet/minecraft/world/item/Item;)V # declareCustomModelItem @@ -344,14 +344,16 @@ protected net.minecraft.client.data.models.ItemModelGenerators m_373727_(Lnet/mi protected net.minecraft.client.data.models.ItemModelGenerators m_373789_(Lnet/minecraft/world/item/Item;Lnet/minecraft/client/renderer/item/properties/conditional/ConditionalItemModelProperty;Lnet/minecraft/client/renderer/item/ItemModel$Unbaked;Lnet/minecraft/client/renderer/item/ItemModel$Unbaked;)V # generateBooleanDispatch protected net.minecraft.client.data.models.ItemModelGenerators m_373819_(Lnet/minecraft/world/item/Item;Ljava/lang/String;Lnet/minecraft/client/color/item/ItemTintSource;)V # generateItemWithTintedOverlay protected net.minecraft.client.data.models.ItemModelGenerators m_373839_(Lnet/minecraft/world/item/Item;)V # generateTrident -protected net.minecraft.client.data.models.ItemModelGenerators m_373858_(Lnet/minecraft/world/item/Item;Lnet/minecraft/client/data/models/model/ModelTemplate;)Lnet/minecraft/resources/ResourceLocation; # createFlatItemModel -protected net.minecraft.client.data.models.ItemModelGenerators m_373869_(Lnet/minecraft/world/item/Item;Lnet/minecraft/world/item/Item;Lnet/minecraft/client/data/models/model/ModelTemplate;)Lnet/minecraft/resources/ResourceLocation; # createFlatItemModel +protected net.minecraft.client.data.models.ItemModelGenerators m_373858_(Lnet/minecraft/world/item/Item;Ljava/lang/String;Lnet/minecraft/client/data/models/model/ModelTemplate;)Lnet/minecraft/resources/Identifier; # createFlatItemModel +protected net.minecraft.client.data.models.ItemModelGenerators m_373869_(Lnet/minecraft/world/item/Item;Lnet/minecraft/client/data/models/model/ModelTemplate;)Lnet/minecraft/resources/Identifier; # createFlatItemModel protected net.minecraft.client.data.models.ItemModelGenerators m_373892_(Lnet/minecraft/world/item/Item;)V # generateTwoLayerDyedItem protected net.minecraft.client.data.models.ItemModelGenerators m_374089_(Lnet/minecraft/world/item/Item;)V # generateBow protected net.minecraft.client.data.models.ItemModelGenerators m_374190_(Lnet/minecraft/world/item/Item;)V # generateFishingRod protected net.minecraft.client.data.models.ItemModelGenerators m_374289_(Lnet/minecraft/world/item/Item;)V # generateBrush protected net.minecraft.client.data.models.ItemModelGenerators m_374337_(Lnet/minecraft/world/item/Item;Lnet/minecraft/world/item/Item;Lnet/minecraft/client/data/models/model/ModelTemplate;)V # generateFlatItem protected net.minecraft.client.data.models.ItemModelGenerators m_374365_(Lnet/minecraft/world/item/Item;)V # generateRecoveryCompassItem +protected net.minecraft.client.data.models.ItemModelGenerators m_440296_(Lnet/minecraft/world/item/Item;)V # generateSpear +protected net.minecraft.client.data.models.ItemModelGenerators m_443417_(Lnet/minecraft/world/item/Item;I)V # generateItemWithTintedBaseLayer #endgroup protected net.minecraft.client.data.models.ItemModelGenerators f_370758_ # modelOutput protected net.minecraft.client.data.models.ItemModelGenerators f_370978_ # itemModelOutput @@ -368,7 +370,7 @@ public net.minecraft.client.gui.Gui m_232354_(Lnet/minecraft/client/gui/GuiGraph 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_280155_(Lnet/minecraft/client/gui/GuiGraphics;Lnet/minecraft/resources/Identifier;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 @@ -399,7 +401,6 @@ public net.minecraft.client.gui.Gui m_355810_(Lnet/minecraft/client/gui/GuiGraph 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 @@ -409,6 +410,7 @@ public net.minecraft.client.gui.Gui m_402918_()Lnet/minecraft/client/gui/Gui$Con 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_437571_(Lnet/minecraft/resources/Identifier;)Lnet/minecraft/resources/Identifier; # lambda$getMobEffectSprite$6 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 @@ -421,10 +423,11 @@ 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.AbstractSliderButton m_293290_()Lnet/minecraft/resources/Identifier; # getHandleSprite +protected net.minecraft.client.gui.components.AbstractSliderButton m_293389_()Lnet/minecraft/resources/Identifier; # getSprite +public net.minecraft.client.gui.components.ChatComponent m_93814_()I # getHeight +public net.minecraft.client.gui.components.ChatComponent m_93815_()D # getScale 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 @@ -441,8 +444,7 @@ public net.minecraft.client.multiplayer.SessionSearchTrees$Key ()V # const 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 -public net.minecraft.client.player.ClientInput f_381292_ #moveVector +public net.minecraft.client.player.ClientInput f_381292_ # moveVector 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 * @@ -467,52 +469,9 @@ public net.minecraft.client.renderer.RenderPipelines f_399373_ # ENTITY_EMISSIVE 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 +public net.minecraft.client.renderer.RenderPipelines f_434495_ # BLOCK_SNIPPET +public net.minecraft.client.renderer.RenderPipelines f_435549_ # GENERIC_BLOCKS_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_110127_ # WEATHER_TARGET -public net.minecraft.client.renderer.RenderStateShard f_110129_ # ITEM_ENTITY_TARGET -public net.minecraft.client.renderer.RenderStateShard f_110130_ # DEFAULT_LINE -protected-f net.minecraft.client.renderer.RenderStateShard f_110131_ # setupState -public net.minecraft.client.renderer.RenderStateShard f_110145_ # BLOCK_SHEET_MIPPED -public net.minecraft.client.renderer.RenderStateShard f_110146_ # BLOCK_SHEET -public net.minecraft.client.renderer.RenderStateShard f_110147_ # NO_TEXTURE -public net.minecraft.client.renderer.RenderStateShard f_110148_ # DEFAULT_TEXTURING -public net.minecraft.client.renderer.RenderStateShard f_110150_ # GLINT_TEXTURING -public net.minecraft.client.renderer.RenderStateShard f_110151_ # ENTITY_GLINT_TEXTURING -public net.minecraft.client.renderer.RenderStateShard f_110152_ # LIGHTMAP -public net.minecraft.client.renderer.RenderStateShard f_110153_ # NO_LIGHTMAP -public net.minecraft.client.renderer.RenderStateShard f_110154_ # OVERLAY -public net.minecraft.client.renderer.RenderStateShard f_110155_ # NO_OVERLAY -public net.minecraft.client.renderer.RenderStateShard f_347557_ # VIEW_OFFSET_Z_LAYERING_FORWARD -public net.minecraft.client.renderer.RenderStateShard f_381391_ # ARMOR_ENTITY_GLINT_TEXTURING -public net.minecraft.client.renderer.RenderStateShard$BooleanStateShard -public net.minecraft.client.renderer.RenderStateShard$EmptyTextureStateShard -public net.minecraft.client.renderer.RenderStateShard$LayeringStateShard -public net.minecraft.client.renderer.RenderStateShard$LightmapStateShard -public net.minecraft.client.renderer.RenderStateShard$MultiTextureStateShard -public net.minecraft.client.renderer.RenderStateShard$OffsetTexturingStateShard -public net.minecraft.client.renderer.RenderStateShard$OutputStateShard -public net.minecraft.client.renderer.RenderStateShard$OverlayStateShard -public net.minecraft.client.renderer.RenderStateShard$TextureStateShard -protected-f net.minecraft.client.renderer.RenderStateShard$TextureStateShard f_110330_ # mipmap -public net.minecraft.client.renderer.RenderStateShard$TexturingStateShard -public net.minecraft.client.renderer.RenderType m_173209_(Ljava/lang/String;ILcom/mojang/blaze3d/pipeline/RenderPipeline;Lnet/minecraft/client/renderer/RenderType$CompositeState;)Lnet/minecraft/client/renderer/RenderType$CompositeRenderType; # create -public net.minecraft.client.renderer.RenderType m_173215_(Ljava/lang/String;IZZLcom/mojang/blaze3d/pipeline/RenderPipeline;Lnet/minecraft/client/renderer/RenderType$CompositeState;)Lnet/minecraft/client/renderer/RenderType$CompositeRenderType; # create -public net.minecraft.client.renderer.RenderType$CompositeRenderType -public net.minecraft.client.renderer.RenderType$CompositeState -public net.minecraft.client.renderer.RenderType$CompositeState$CompositeStateBuilder ()V # constructor -public net.minecraft.client.renderer.RenderType$CompositeState$CompositeStateBuilder m_110669_(Lnet/minecraft/client/renderer/RenderStateShard$LayeringStateShard;)Lnet/minecraft/client/renderer/RenderType$CompositeState$CompositeStateBuilder; # setLayeringState -public net.minecraft.client.renderer.RenderType$CompositeState$CompositeStateBuilder m_110671_(Lnet/minecraft/client/renderer/RenderStateShard$LightmapStateShard;)Lnet/minecraft/client/renderer/RenderType$CompositeState$CompositeStateBuilder; # setLightmapState -public net.minecraft.client.renderer.RenderType$CompositeState$CompositeStateBuilder m_110673_(Lnet/minecraft/client/renderer/RenderStateShard$LineStateShard;)Lnet/minecraft/client/renderer/RenderType$CompositeState$CompositeStateBuilder; # setLineState -public net.minecraft.client.renderer.RenderType$CompositeState$CompositeStateBuilder m_110675_(Lnet/minecraft/client/renderer/RenderStateShard$OutputStateShard;)Lnet/minecraft/client/renderer/RenderType$CompositeState$CompositeStateBuilder; # setOutputState -public net.minecraft.client.renderer.RenderType$CompositeState$CompositeStateBuilder m_110677_(Lnet/minecraft/client/renderer/RenderStateShard$OverlayStateShard;)Lnet/minecraft/client/renderer/RenderType$CompositeState$CompositeStateBuilder; # setOverlayState -public net.minecraft.client.renderer.RenderType$CompositeState$CompositeStateBuilder m_110683_(Lnet/minecraft/client/renderer/RenderStateShard$TexturingStateShard;)Lnet/minecraft/client/renderer/RenderType$CompositeState$CompositeStateBuilder; # setTexturingState -public net.minecraft.client.renderer.RenderType$CompositeState$CompositeStateBuilder m_110689_(Lnet/minecraft/client/renderer/RenderType$OutlineProperty;)Lnet/minecraft/client/renderer/RenderType$CompositeState; # createCompositeState -public net.minecraft.client.renderer.RenderType$CompositeState$CompositeStateBuilder m_110691_(Z)Lnet/minecraft/client/renderer/RenderType$CompositeState; # createCompositeState -public net.minecraft.client.renderer.RenderType$CompositeState$CompositeStateBuilder m_173290_(Lnet/minecraft/client/renderer/RenderStateShard$EmptyTextureStateShard;)Lnet/minecraft/client/renderer/RenderType$CompositeState$CompositeStateBuilder; # setTextureState public net.minecraft.client.renderer.block.model.BlockElement$Deserializer public net.minecraft.client.renderer.block.model.BlockElement$Deserializer ()V # constructor public net.minecraft.client.renderer.block.model.BlockElementFace$Deserializer @@ -536,6 +495,8 @@ public net.minecraft.client.renderer.entity.EntityRenderers m_174036_(Lnet/minec public net.minecraft.client.renderer.entity.ItemRenderer m_115162_(Lcom/mojang/blaze3d/vertex/PoseStack;Lcom/mojang/blaze3d/vertex/VertexConsumer;Ljava/util/List;[III)V # renderQuadList public net.minecraft.client.renderer.entity.LivingEntityRenderer m_115326_(Lnet/minecraft/client/renderer/entity/layers/RenderLayer;)Z # addLayer protected net.minecraft.client.renderer.entity.layers.HumanoidArmorLayer m_117078_(Lnet/minecraft/client/renderer/entity/state/HumanoidRenderState;Lnet/minecraft/world/entity/EquipmentSlot;)Lnet/minecraft/client/model/HumanoidModel; # getArmorModel +protected net.minecraft.client.renderer.entity.layers.WingsLayer m_356494_(Lnet/minecraft/client/renderer/entity/state/HumanoidRenderState;)Lnet/minecraft/resources/Identifier; # getPlayerElytraTexture +public net.minecraft.client.renderer.rendertype.RenderType m_446098_(Ljava/lang/String;Lnet/minecraft/client/renderer/rendertype/RenderSetup;)Lnet/minecraft/client/renderer/rendertype/RenderType; # create public net.minecraft.client.renderer.texture.SpriteContents f_243731_ # byMipLevel default net.minecraft.client.renderer.texture.SpriteContents f_244575_ # animatedTexture default net.minecraft.client.renderer.texture.SpriteContents m_245088_()I # getFrameCount @@ -587,9 +548,7 @@ public-f net.minecraft.data.registries.RegistriesDatapackGenerator m_6055_()Ljav protected net.minecraft.data.tags.TagsProvider f_126543_ # builders public-f net.minecraft.data.tags.TagsProvider m_6055_()Ljava/lang/String; # getName public net.minecraft.data.tags.VanillaItemTagsProvider$BlockToItemConverter -public net.minecraft.resources.ResourceLocation m_135835_(C)Z # validNamespaceChar -public net.minecraft.resources.ResourceLocation m_135841_(Ljava/lang/String;)Z # isValidPath -public net.minecraft.resources.ResourceLocation m_135843_(Ljava/lang/String;)Z # isValidNamespace +public net.minecraft.resources.Identifier m_441545_(C)Z # validNamespaceChar protected net.minecraft.server.MinecraftServer f_302313_ # nextTickTimeNanos public net.minecraft.server.MinecraftServer f_303727_ # tickTimesNanos public net.minecraft.server.MinecraftServer$ReloadableResources @@ -618,23 +577,24 @@ public net.minecraft.world.entity.Mob f_21346_ # targetSelector public net.minecraft.world.entity.ai.memory.MemoryModuleType (Ljava/util/Optional;)V # constructor public net.minecraft.world.entity.ai.sensing.SensorType (Ljava/util/function/Supplier;)V # constructor protected net.minecraft.world.entity.item.PrimedTnt m_32103_()V # explode - make it easier to extend TNTEntity with custom explosion logic -protected net.minecraft.world.entity.monster.AbstractSkeleton m_7878_()Lnet/minecraft/sounds/SoundEvent; # getStepSound - make AbstractSkeletonEntity implementable -protected net.minecraft.world.entity.monster.Skeleton m_7878_()Lnet/minecraft/sounds/SoundEvent; # getStepSound - make AbstractSkeletonEntity implementable -protected net.minecraft.world.entity.monster.Stray m_7878_()Lnet/minecraft/sounds/SoundEvent; # getStepSound - make AbstractSkeletonEntity implementable -protected net.minecraft.world.entity.monster.WitherSkeleton m_7878_()Lnet/minecraft/sounds/SoundEvent; # getStepSound - make AbstractSkeletonEntity implementable -protected net.minecraft.world.entity.monster.Zombie f_34266_ # conversionTime -public net.minecraft.world.entity.npc.VillagerTrades$DyedArmorForEmeralds -public net.minecraft.world.entity.npc.VillagerTrades$EmeraldForItems -public net.minecraft.world.entity.npc.VillagerTrades$EmeraldsForVillagerTypeItem -public net.minecraft.world.entity.npc.VillagerTrades$EnchantBookForEmeralds -public net.minecraft.world.entity.npc.VillagerTrades$EnchantedItemForEmeralds -public net.minecraft.world.entity.npc.VillagerTrades$FailureItemListing -public net.minecraft.world.entity.npc.VillagerTrades$ItemsAndEmeraldsToItems -public net.minecraft.world.entity.npc.VillagerTrades$ItemsForEmeralds -public net.minecraft.world.entity.npc.VillagerTrades$SuspiciousStewForEmerald -public net.minecraft.world.entity.npc.VillagerTrades$TippedArrowForItemsAndEmeralds -public net.minecraft.world.entity.npc.VillagerTrades$TreasureMapForEmeralds -public net.minecraft.world.entity.npc.VillagerTrades$TypeSpecificTrade +protected net.minecraft.world.entity.monster.skeleton.AbstractSkeleton m_442492_()Lnet/minecraft/sounds/SoundEvent; # getStepSound - make AbstractSkeletonEntity implementable +protected net.minecraft.world.entity.monster.skeleton.Parched m_442492_()Lnet/minecraft/sounds/SoundEvent; # getStepSound - make AbstractSkeletonEntity implementable +protected net.minecraft.world.entity.monster.skeleton.Skeleton m_442492_()Lnet/minecraft/sounds/SoundEvent; # getStepSound - make AbstractSkeletonEntity implementable +protected net.minecraft.world.entity.monster.skeleton.Stray m_442492_()Lnet/minecraft/sounds/SoundEvent; # getStepSound - make AbstractSkeletonEntity implementable +protected net.minecraft.world.entity.monster.skeleton.WitherSkeleton m_442492_()Lnet/minecraft/sounds/SoundEvent; # getStepSound - make AbstractSkeletonEntity implementable +protected net.minecraft.world.entity.monster.zombie.Zombie f_436498_ # conversionTime +public net.minecraft.world.entity.npc.villager.VillagerTrades$DyedArmorForEmeralds +public net.minecraft.world.entity.npc.villager.VillagerTrades$EmeraldForItems +public net.minecraft.world.entity.npc.villager.VillagerTrades$EmeraldsForVillagerTypeItem +public net.minecraft.world.entity.npc.villager.VillagerTrades$EnchantBookForEmeralds +public net.minecraft.world.entity.npc.villager.VillagerTrades$EnchantedItemForEmeralds +public net.minecraft.world.entity.npc.villager.VillagerTrades$FailureItemListing +public net.minecraft.world.entity.npc.villager.VillagerTrades$ItemsAndEmeraldsToItems +public net.minecraft.world.entity.npc.villager.VillagerTrades$ItemsForEmeralds +public net.minecraft.world.entity.npc.villager.VillagerTrades$SuspiciousStewForEmerald +public net.minecraft.world.entity.npc.villager.VillagerTrades$TippedArrowForItemsAndEmeralds +public net.minecraft.world.entity.npc.villager.VillagerTrades$TreasureMapForEmeralds +public net.minecraft.world.entity.npc.villager.VillagerTrades$TypeSpecificTrade public net.minecraft.world.entity.player.Player m_6915_()V # closeContainer protected net.minecraft.world.entity.projectile.Projectile (Lnet/minecraft/world/entity/EntityType;Lnet/minecraft/world/level/Level;)V # constructor private-f net.minecraft.world.entity.raid.Raid$RaiderType f_37813_ # VALUES @@ -669,11 +629,6 @@ public net.minecraft.world.item.context.BlockPlaceContext (Lnet/minecraft/ public net.minecraft.world.item.context.UseOnContext (Lnet/minecraft/world/level/Level;Lnet/minecraft/world/entity/player/Player;Lnet/minecraft/world/InteractionHand;Lnet/minecraft/world/item/ItemStack;Lnet/minecraft/world/phys/BlockHitResult;)V # constructor public-f net.minecraft.world.item.crafting.Ingredient protected net.minecraft.world.item.crafting.Ingredient (Lnet/minecraft/core/HolderSet;)V # constructor -public net.minecraft.world.level.GameRules m_46189_(Ljava/lang/String;Lnet/minecraft/world/level/GameRules$Category;Lnet/minecraft/world/level/GameRules$Type;)Lnet/minecraft/world/level/GameRules$Key; # register -public net.minecraft.world.level.GameRules$BooleanValue m_46250_(Z)Lnet/minecraft/world/level/GameRules$Type; # create -public net.minecraft.world.level.GameRules$BooleanValue m_46252_(ZLjava/util/function/BiConsumer;)Lnet/minecraft/world/level/GameRules$Type; # create -public net.minecraft.world.level.GameRules$IntegerValue m_46294_(ILjava/util/function/BiConsumer;)Lnet/minecraft/world/level/GameRules$Type; # create -public net.minecraft.world.level.GameRules$IntegerValue m_46312_(I)Lnet/minecraft/world/level/GameRules$Type; # create public net.minecraft.world.level.Level f_46437_ # oRainLevel public net.minecraft.world.level.Level f_46438_ # rainLevel public net.minecraft.world.level.Level f_46439_ # oThunderLevel @@ -683,20 +638,11 @@ protected net.minecraft.world.level.biome.BiomeGenerationSettings$PlainBuilder f protected net.minecraft.world.level.biome.BiomeGenerationSettings$PlainBuilder f_254678_ # carvers protected net.minecraft.world.level.biome.BiomeGenerationSettings$PlainBuilder m_255276_(I)V # addFeatureStepsUpTo #group protected net.minecraft.world.level.biome.BiomeSpecialEffects$Builder * -protected net.minecraft.world.level.biome.BiomeSpecialEffects$Builder f_371299_ # backgroundMusicVolume protected net.minecraft.world.level.biome.BiomeSpecialEffects$Builder f_380225_ # dryFoliageColorOverride -protected net.minecraft.world.level.biome.BiomeSpecialEffects$Builder f_48005_ # fogColor protected net.minecraft.world.level.biome.BiomeSpecialEffects$Builder f_48006_ # waterColor -protected net.minecraft.world.level.biome.BiomeSpecialEffects$Builder f_48007_ # waterFogColor -protected net.minecraft.world.level.biome.BiomeSpecialEffects$Builder f_48008_ # skyColor protected net.minecraft.world.level.biome.BiomeSpecialEffects$Builder f_48009_ # foliageColorOverride protected net.minecraft.world.level.biome.BiomeSpecialEffects$Builder f_48010_ # grassColorOverride protected net.minecraft.world.level.biome.BiomeSpecialEffects$Builder f_48011_ # grassColorModifier -protected net.minecraft.world.level.biome.BiomeSpecialEffects$Builder f_48012_ # ambientParticle -protected net.minecraft.world.level.biome.BiomeSpecialEffects$Builder f_48013_ # ambientLoopSoundEvent -protected net.minecraft.world.level.biome.BiomeSpecialEffects$Builder f_48014_ # ambientMoodSettings -protected net.minecraft.world.level.biome.BiomeSpecialEffects$Builder f_48015_ # ambientAdditionsSettings -protected net.minecraft.world.level.biome.BiomeSpecialEffects$Builder f_48016_ # backgroundMusic #endgroup protected net.minecraft.world.level.biome.MobSpawnSettings$Builder f_48362_ # spawners protected net.minecraft.world.level.biome.MobSpawnSettings$Builder f_48363_ # mobSpawnCosts @@ -816,6 +762,11 @@ public net.minecraft.world.level.block.entity.HopperBlockEntity m_59409_()Z # is public net.minecraft.world.level.block.state.properties.BlockSetType m_272115_(Lnet/minecraft/world/level/block/state/properties/BlockSetType;)Lnet/minecraft/world/level/block/state/properties/BlockSetType; # register public net.minecraft.world.level.block.state.properties.WoodType m_61844_(Lnet/minecraft/world/level/block/state/properties/WoodType;)Lnet/minecraft/world/level/block/state/properties/WoodType; # register public net.minecraft.world.level.chunk.status.ChunkStatus (Lnet/minecraft/world/level/chunk/status/ChunkStatus;Ljava/util/EnumSet;Lnet/minecraft/world/level/chunk/status/ChunkType;)V # constructor +public net.minecraft.world.level.gamerules.GameRules m_439121_(Ljava/lang/String;Lnet/minecraft/world/level/gamerules/GameRuleCategory;III)Lnet/minecraft/world/level/gamerules/GameRule; # registerInteger +public net.minecraft.world.level.gamerules.GameRules m_441993_(Ljava/lang/String;Lnet/minecraft/world/level/gamerules/GameRuleCategory;IIILnet/minecraft/world/flag/FeatureFlagSet;)Lnet/minecraft/world/level/gamerules/GameRule; # registerInteger +public net.minecraft.world.level.gamerules.GameRules m_442919_(Ljava/lang/String;Lnet/minecraft/world/level/gamerules/GameRuleCategory;II)Lnet/minecraft/world/level/gamerules/GameRule; # registerInteger +public net.minecraft.world.level.gamerules.GameRules m_446320_(Ljava/lang/String;Lnet/minecraft/world/level/gamerules/GameRuleCategory;Z)Lnet/minecraft/world/level/gamerules/GameRule; # registerBoolean +public net.minecraft.world.level.gamerules.GameRules m_447562_(Ljava/lang/String;Lnet/minecraft/world/level/gamerules/GameRuleCategory;Lnet/minecraft/world/level/gamerules/GameRuleType;Lcom/mojang/brigadier/arguments/ArgumentType;Lcom/mojang/serialization/Codec;Ljava/lang/Object;Lnet/minecraft/world/flag/FeatureFlagSet;Lnet/minecraft/world/level/gamerules/GameRules$VisitorCaller;Ljava/util/function/ToIntFunction;)Lnet/minecraft/world/level/gamerules/GameRule; # register protected net.minecraft.world.level.levelgen.Aquifer$NoiseBasedAquifer f_157994_ # barrierNoise protected net.minecraft.world.level.levelgen.Aquifer$NoiseBasedAquifer f_157996_ # lavaNoise protected net.minecraft.world.level.levelgen.Aquifer$NoiseBasedAquifer f_157998_ # aquiferCache @@ -855,11 +806,12 @@ protected net.minecraft.world.level.portal.PortalForcer f_77648_ # level public net.minecraft.world.level.storage.LevelResource (Ljava/lang/String;)V # constructor private-f net.minecraft.world.level.storage.loot.LootPool f_79028_ # rolls private-f net.minecraft.world.level.storage.loot.LootPool f_79029_ # bonusRolls -public net.minecraft.world.level.storage.loot.functions.FilteredFunction (Ljava/util/List;Lnet/minecraft/advancements/critereon/ItemPredicate;Lnet/minecraft/world/level/storage/loot/functions/LootItemFunction;)V # constructor public net.minecraft.world.level.storage.loot.functions.LootItemConditionalFunction m_80683_(Ljava/util/function/Function;)Lnet/minecraft/world/level/storage/loot/functions/LootItemConditionalFunction$Builder; # simpleBuilder public net.minecraft.world.level.storage.loot.functions.ModifyContainerContents (Ljava/util/List;Lnet/minecraft/world/level/storage/loot/ContainerComponentManipulator;Lnet/minecraft/world/level/storage/loot/functions/LootItemFunction;)V # constructor public net.minecraft.world.level.storage.loot.functions.SetFireworksFunction (Ljava/util/List;Ljava/util/Optional;Ljava/util/Optional;)V # constructor public net.minecraft.world.level.storage.loot.functions.SetItemFunction (Ljava/util/List;Lnet/minecraft/core/Holder;)V # constructor public net.minecraft.world.level.storage.loot.functions.SetWritableBookPagesFunction (Ljava/util/List;Ljava/util/List;Lnet/minecraft/world/level/storage/loot/functions/ListOperation;)V # constructor public net.minecraft.world.level.storage.loot.functions.SetWrittenBookPagesFunction (Ljava/util/List;Ljava/util/List;Lnet/minecraft/world/level/storage/loot/functions/ListOperation;)V # constructor -public net.minecraft.world.level.storage.loot.functions.ToggleTooltips (Ljava/util/List;Ljava/util/Map;)V # constructor \ No newline at end of file +public net.minecraft.world.level.storage.loot.functions.ToggleTooltips (Ljava/util/List;Ljava/util/Map;)V # constructor +public net/minecraft/client/gui/components/debug/DebugScreenEntries m_419600_(Lnet/minecraft/resources/Identifier;Lnet/minecraft/client/gui/components/debug/DebugScreenEntry;)Lnet/minecraft/resources/Identifier; # register +public net/minecraft/world/entity/npc/villager/VillagerTrades$EmeraldsForVillagerTypeItem \ No newline at end of file diff --git a/src/test/generated/mdk_datagen/pack.mcmeta b/src/test/generated/mdk_datagen/pack.mcmeta index aad35698a5..a567fe20b0 100644 --- a/src/test/generated/mdk_datagen/pack.mcmeta +++ b/src/test/generated/mdk_datagen/pack.mcmeta @@ -1,7 +1,10 @@ { "pack": { "description": "${mod_id} resources", - "max_format": 88, - "min_format": 88 + "max_format": 94, + "min_format": [ + 94, + 1 + ] } } \ No newline at end of file diff --git a/src/test/generated/test_helper_mod/pack.mcmeta b/src/test/generated/test_helper_mod/pack.mcmeta index b842a44f9e..d575010cae 100644 --- a/src/test/generated/test_helper_mod/pack.mcmeta +++ b/src/test/generated/test_helper_mod/pack.mcmeta @@ -1,7 +1,10 @@ { "pack": { "description": "Forge tests resource pack", - "max_format": 88, - "min_format": 88 + "max_format": 94, + "min_format": [ + 94, + 1 + ] } } \ No newline at end of file diff --git a/src/test/java/com/example/examplemod/Config.java b/src/test/java/com/example/examplemod/Config.java index a117d0a86c..a5f8804550 100644 --- a/src/test/java/com/example/examplemod/Config.java +++ b/src/test/java/com/example/examplemod/Config.java @@ -1,6 +1,6 @@ package com.example.examplemod; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.world.item.Item; import net.minecraftforge.common.ForgeConfigSpec; import net.minecraftforge.eventbus.api.listener.SubscribeEvent; @@ -43,7 +43,7 @@ public class Config { public static Set items; private static boolean validateItemName(final Object obj) { - return obj instanceof final String itemName && ForgeRegistries.ITEMS.containsKey(ResourceLocation.tryParse(itemName)); + return obj instanceof final String itemName && ForgeRegistries.ITEMS.containsKey(Identifier.tryParse(itemName)); } @SubscribeEvent @@ -54,7 +54,7 @@ public class Config { // convert the list of strings into a set of items items = ITEM_STRINGS.get().stream() - .map(itemName -> ForgeRegistries.ITEMS.getValue(ResourceLocation.tryParse(itemName))) + .map(itemName -> ForgeRegistries.ITEMS.getValue(Identifier.tryParse(itemName))) .collect(Collectors.toSet()); } } diff --git a/src/test/java/net/minecraftforge/debug/client/AdditionalModelTest.java b/src/test/java/net/minecraftforge/debug/client/AdditionalModelTest.java index f172d30d2b..ac9434ccac 100644 --- a/src/test/java/net/minecraftforge/debug/client/AdditionalModelTest.java +++ b/src/test/java/net/minecraftforge/debug/client/AdditionalModelTest.java @@ -12,8 +12,8 @@ import net.minecraft.client.data.models.model.ItemModelUtils; import net.minecraft.client.data.models.model.ModelLocationUtils; import net.minecraft.client.data.models.model.ModelTemplates; import net.minecraft.client.data.models.model.TextureMapping; -import net.minecraft.client.model.CowModel; -import net.minecraft.client.model.PigModel; +import net.minecraft.client.model.animal.cow.CowModel; +import net.minecraft.client.model.animal.pig.PigModel; import net.minecraft.client.renderer.SubmitNodeCollector; import net.minecraft.client.renderer.block.MovingBlockRenderState; import net.minecraft.client.renderer.entity.LivingEntityRenderer; @@ -28,8 +28,8 @@ import net.minecraft.data.DataProvider; import net.minecraft.data.PackOutput; import net.minecraft.gametest.framework.GameTestHelper; import net.minecraft.world.entity.EntityType; -import net.minecraft.world.entity.animal.Cow; -import net.minecraft.world.entity.animal.Pig; +import net.minecraft.world.entity.animal.cow.Cow; +import net.minecraft.world.entity.animal.pig.Pig; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemDisplayContext; import net.minecraft.world.item.ItemStack; diff --git a/src/test/java/net/minecraftforge/debug/client/ModelRenderLayerTest.java b/src/test/java/net/minecraftforge/debug/client/ModelRenderLayerTest.java index de16223782..3ed1b416c0 100644 --- a/src/test/java/net/minecraftforge/debug/client/ModelRenderLayerTest.java +++ b/src/test/java/net/minecraftforge/debug/client/ModelRenderLayerTest.java @@ -116,13 +116,13 @@ public class ModelRenderLayerTest extends BaseTestMod { var state = BLOCK.get().defaultBlockState(); var random = helper.getLevel().random; boolean originalRenderState = ItemBlockRenderTypes.isFancy(); - helper.addCleanup(passed -> ItemBlockRenderTypes.setFancy(originalRenderState)); + helper.addCleanup(passed -> ItemBlockRenderTypes.setCutoutLeaves(originalRenderState)); - ItemBlockRenderTypes.setFancy(true); + ItemBlockRenderTypes.setCutoutLeaves(true); var layer = model.getRenderTypes(state, random, ModelData.EMPTY); helper.assertTrue(layer.contains(ChunkSectionLayer.CUTOUT), "Block model does not contain the correct render type for fancy graphics. Expected: cutout"); - ItemBlockRenderTypes.setFancy(false); + ItemBlockRenderTypes.setCutoutLeaves(false); layer = model.getRenderTypes(state, random, ModelData.EMPTY); helper.assertTrue(layer.contains(ChunkSectionLayer.SOLID), "Block model does not contain the correct render type for fast graphics. Expected: solid"); @@ -140,13 +140,13 @@ public class ModelRenderLayerTest extends BaseTestMod { var random = helper.getLevel().random; boolean originalRenderState = ItemBlockRenderTypes.isFancy(); - helper.addCleanup(passed -> ItemBlockRenderTypes.setFancy(originalRenderState)); + helper.addCleanup(passed -> ItemBlockRenderTypes.setCutoutLeaves(originalRenderState)); - ItemBlockRenderTypes.setFancy(true); + ItemBlockRenderTypes.setCutoutLeaves(true); var layer = model.getRenderTypes(state, random, ModelData.EMPTY); - helper.assertTrue(layer.contains(ChunkSectionLayer.CUTOUT_MIPPED), "Block model does not contain the correct render type for fancy graphics. Expected: cutout_mipped"); + helper.assertTrue(layer.contains(ChunkSectionLayer.CUTOUT), "Block model does not contain the correct render type for fancy graphics. Expected: cutout_mipped"); - ItemBlockRenderTypes.setFancy(false); + ItemBlockRenderTypes.setCutoutLeaves(false); layer = model.getRenderTypes(state, random, ModelData.EMPTY); helper.assertTrue(layer.contains(ChunkSectionLayer.SOLID), "Block model does not contain the correct render type for fast graphics. Expected: solid"); diff --git a/src/test/java/net/minecraftforge/debug/client/ModifyOverlayTest.java b/src/test/java/net/minecraftforge/debug/client/ModifyOverlayTest.java index 67a6d923a9..4dd35eb55c 100644 --- a/src/test/java/net/minecraftforge/debug/client/ModifyOverlayTest.java +++ b/src/test/java/net/minecraftforge/debug/client/ModifyOverlayTest.java @@ -6,7 +6,7 @@ package net.minecraftforge.debug.client; import net.minecraft.gametest.framework.GameTestHelper; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraftforge.client.event.AddGuiOverlayLayersEvent; import net.minecraftforge.client.gui.overlay.ForgeLayer; import net.minecraftforge.client.gui.overlay.ForgeLayeredDraw; @@ -28,16 +28,16 @@ import static net.minecraftforge.client.gui.overlay.ForgeLayeredDraw.*; public class ModifyOverlayTest extends BaseTestMod { public static final String MODID = "modify_overlay_test"; - private static final ResourceLocation myStackName = name("my_stack_name"); + private static final Identifier myStackName = name("my_stack_name"); private static final ForgeLayeredDraw myLayerStack = new ForgeLayeredDraw(myStackName); private static final ForgeLayer notAddedLayer = (gg, tr) -> {}; private static final ForgeLayer layerA = (gg,tr) -> {}; - private static final ResourceLocation layerAName = name("layer_a"); + private static final Identifier layerAName = name("layer_a"); private static final ForgeLayer layerB = (gg,tr) -> {}; - private static final ResourceLocation layerBName = name("layer_b"); + private static final Identifier layerBName = name("layer_b"); private static final ForgeLayer layerC = (gg,tr) -> {}; - private static final ResourceLocation layerCName = name("layer_c"); + private static final Identifier layerCName = name("layer_c"); private static final IForgeGameTestHelper.BoolFlag detectConditionFlag = new IForgeGameTestHelper.BoolFlag("det_cond_flag"); @@ -82,16 +82,16 @@ public class ModifyOverlayTest extends BaseTestMod { public static void ordered_layers(GameTestHelper helper) { // Test that layers are in the correct order. List internalLayersList = null; - Map check = null; + Map check = null; try { Class cls = drawStack.getClass(); var field = cls.getDeclaredField("subLayerStacks"); var field1 = cls.getDeclaredField("namedLayers"); field.setAccessible(true); field1.setAccessible(true); - Map> VROOT = ((Map>) field.get(drawStack)); + Map> VROOT = ((Map>) field.get(drawStack)); var PSS = ((ForgeLayeredDraw) VROOT.get(PRE_SLEEP_STACK).getKey()); - check = ((Map) field1.get(PSS)); + check = ((Map) field1.get(PSS)); internalLayersList = getInternalLayersList(PSS); } catch (Exception e) { helper.fail("Threw a " + e.getMessage() + " when trying to get the inner layer list."); @@ -155,8 +155,8 @@ public class ModifyOverlayTest extends BaseTestMod { } - private static ResourceLocation name(String name) { - return ResourceLocation.fromNamespaceAndPath(MODID, name); + private static Identifier name(String name) { + return Identifier.fromNamespaceAndPath(MODID, name); } @SuppressWarnings("unchecked") diff --git a/src/test/java/net/minecraftforge/debug/client/ObjModelTest.java b/src/test/java/net/minecraftforge/debug/client/ObjModelTest.java index be4c7618a4..2c10accb00 100644 --- a/src/test/java/net/minecraftforge/debug/client/ObjModelTest.java +++ b/src/test/java/net/minecraftforge/debug/client/ObjModelTest.java @@ -13,8 +13,8 @@ import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.texture.OverlayTexture; import net.minecraft.client.resources.model.BakedModel; -import net.minecraft.client.resources.model.ModelResourceLocation; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.client.resources.model.ModelIdentifier; +import net.minecraft.resources.Identifier; import net.minecraft.world.phys.Vec3; import net.minecraftforge.client.event.ModelEvent; import net.minecraftforge.client.model.data.ModelData; @@ -33,7 +33,7 @@ public class ObjModelTest { public static final String MODID = "obj_model_test"; private static final PoseStack POSE_STACK = new PoseStack(); - private static final ModelResourceLocation PYRAMID_MODEL_LOCATION = new ModelResourceLocation(ResourceLocation.fromNamespaceAndPath(MODID, "pyramid"), ""); + private static final ModelIdentifier PYRAMID_MODEL_LOCATION = new ModelIdentifier(Identifier.fromNamespaceAndPath(MODID, "pyramid"), ""); private static BakedModel pyramidModel; public ObjModelTest(FMLJavaModLoadingContext ctx) { diff --git a/src/test/java/net/minecraftforge/debug/client/RenderFrameLayerTest.java b/src/test/java/net/minecraftforge/debug/client/RenderFrameLayerTest.java index cd8bd36796..1c9b4e8cf8 100644 --- a/src/test/java/net/minecraftforge/debug/client/RenderFrameLayerTest.java +++ b/src/test/java/net/minecraftforge/debug/client/RenderFrameLayerTest.java @@ -10,20 +10,20 @@ import net.minecraft.client.renderer.state.LevelRenderState; import net.minecraftforge.client.FramePassManager; import net.minecraftforge.client.event.AddFramePassEvent; import net.minecraftforge.common.extensions.IForgeGameTestHelper; -import net.minecraftforge.eventbus.api.listener.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.gametest.GameTest; import net.minecraftforge.gametest.GameTestNamespace; import net.minecraftforge.test.BaseTestMod; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.RenderType; -import net.minecraft.client.renderer.ShapeRenderer; import net.minecraft.gametest.framework.GameTestHelper; +import net.minecraft.gizmos.GizmoStyle; +import net.minecraft.gizmos.Gizmos; +import net.minecraft.util.ARGB; +import net.minecraft.world.phys.AABB; + import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.framegraph.FramePass; - @GameTestNamespace("forge") @Mod(RenderFrameLayerTest.MODID) public class RenderFrameLayerTest extends BaseTestMod { @@ -61,11 +61,11 @@ public class RenderFrameLayerTest extends BaseTestMod { passOne.set(true); ps.translate(state.cameraRenderState.entityPos.multiply(-1,-1,-1)); ps.pushPose(); - var buffSource = Minecraft.getInstance().renderBuffers().bufferSource(); - var vc = buffSource.getBuffer(RenderType.lines()); - - ShapeRenderer.renderLineBox(ps.last(), vc, 0, -60, 0, 10, -50, 10, 1f, 1f, 1f, 1f); - buffSource.endBatch(); + Gizmos.cuboid( + new AABB(0, -60, 0, 10, -50, 10), + GizmoStyle.stroke(ARGB.colorFromFloat(1.0F, 0.9F, 0.9F, 0.9F)), + true + ); ps.popPose(); } }; @@ -82,11 +82,11 @@ public class RenderFrameLayerTest extends BaseTestMod { passTwo.set(true); ps.translate(state.cameraRenderState.entityPos.multiply(-1,-1,-1)); ps.pushPose(); - var buffSource = Minecraft.getInstance().renderBuffers().bufferSource(); - var vc = buffSource.getBuffer(RenderType.lines()); - - ShapeRenderer.renderLineBox(ps.last(), vc, 1, -61, 1, 9, -49, 9, 1f, 1f, 1f, 1f); - buffSource.endBatch(); + Gizmos.cuboid( + new AABB(0, -60, 0, 10, -50, 10).contract(1, 1, 1), + GizmoStyle.stroke(ARGB.colorFromFloat(1.0F, 0.9F, 0.9F, 0.9F)), + true + ); ps.popPose(); } }; diff --git a/src/test/java/net/minecraftforge/debug/creativetabs/CreativeModeTabTest.java b/src/test/java/net/minecraftforge/debug/creativetabs/CreativeModeTabTest.java index 7f22aa608a..a3de84b07b 100644 --- a/src/test/java/net/minecraftforge/debug/creativetabs/CreativeModeTabTest.java +++ b/src/test/java/net/minecraftforge/debug/creativetabs/CreativeModeTabTest.java @@ -9,7 +9,7 @@ import java.util.List; import net.minecraft.core.registries.Registries; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.world.item.CreativeModeTab; import net.minecraft.world.item.CreativeModeTab.TabVisibility; import net.minecraft.world.item.DyeColor; @@ -29,10 +29,10 @@ public class CreativeModeTabTest { public static final String MOD_ID = "creative_mode_tab_test"; private static final boolean ENABLED = true; - private static final ResourceKey LOGS = ResourceKey.create(Registries.CREATIVE_MODE_TAB, ResourceLocation.fromNamespaceAndPath(MOD_ID, "logs")); - private static final ResourceKey STONE = ResourceKey.create(Registries.CREATIVE_MODE_TAB, ResourceLocation.fromNamespaceAndPath(MOD_ID, "stone")); - private static final ResourceKey COLORS = ResourceKey.create(Registries.CREATIVE_MODE_TAB, ResourceLocation.fromNamespaceAndPath(MOD_ID, "colors")); - private static final ResourceKey SEARCH = ResourceKey.create(Registries.CREATIVE_MODE_TAB, ResourceLocation.fromNamespaceAndPath(MOD_ID, "search")); + private static final ResourceKey LOGS = ResourceKey.create(Registries.CREATIVE_MODE_TAB, Identifier.fromNamespaceAndPath(MOD_ID, "logs")); + private static final ResourceKey STONE = ResourceKey.create(Registries.CREATIVE_MODE_TAB, Identifier.fromNamespaceAndPath(MOD_ID, "stone")); + private static final ResourceKey COLORS = ResourceKey.create(Registries.CREATIVE_MODE_TAB, Identifier.fromNamespaceAndPath(MOD_ID, "colors")); + private static final ResourceKey SEARCH = ResourceKey.create(Registries.CREATIVE_MODE_TAB, Identifier.fromNamespaceAndPath(MOD_ID, "search")); public CreativeModeTabTest(FMLJavaModLoadingContext context) { if (!ENABLED) @@ -98,7 +98,7 @@ public class CreativeModeTabTest { List blocks = List.of(Blocks.GRANITE, Blocks.DIORITE, Blocks.ANDESITE, Blocks.COBBLESTONE); for (int i = 0; i < blocks.size(); i++) { Block block = blocks.get(i); - helper.register(ResourceLocation.fromNamespaceAndPath(MOD_ID, "dummy" + i), CreativeModeTab.builder() + helper.register(Identifier.fromNamespaceAndPath(MOD_ID, "dummy" + i), CreativeModeTab.builder() .title(Component.literal("Dummy " + i)) .icon(() -> new ItemStack(block)) .displayItems((params, output) -> output.accept(block)) @@ -106,8 +106,8 @@ public class CreativeModeTabTest { ); } - //final ResourceLocation custom_tabs_image = new ResourceLocation(MOD_ID, "textures/gui/container/creative_inventory/custom_tabs.png"); - helper.register(ResourceLocation.fromNamespaceAndPath(MOD_ID, "with_tabs_image"), CreativeModeTab.builder() + //final Identifier custom_tabs_image = new Identifier(MOD_ID, "textures/gui/container/creative_inventory/custom_tabs.png"); + helper.register(Identifier.fromNamespaceAndPath(MOD_ID, "with_tabs_image"), CreativeModeTab.builder() .title(Component.translatable("itemGroup.with_tabs_image")) .icon(() -> new ItemStack(Blocks.BRICKS)) .displayItems((params, output) -> output.accept(Blocks.BRICKS)) diff --git a/src/test/java/net/minecraftforge/debug/gameplay/block/PlantTypePlacementTest.java b/src/test/java/net/minecraftforge/debug/gameplay/block/PlantTypePlacementTest.java index eb628c1098..2a61645aca 100644 --- a/src/test/java/net/minecraftforge/debug/gameplay/block/PlantTypePlacementTest.java +++ b/src/test/java/net/minecraftforge/debug/gameplay/block/PlantTypePlacementTest.java @@ -5,7 +5,7 @@ package net.minecraftforge.debug.gameplay.block; -import net.minecraft.Util; +import net.minecraft.util.Util; import net.minecraft.core.BlockPos; import net.minecraft.core.Holder; import net.minecraft.core.registries.BuiltInRegistries; @@ -136,7 +136,7 @@ public class PlantTypePlacementTest extends BaseTestMod { public void coverage(GameTestHelper helper) { var vanilla = helper.registryLookup(Registries.BLOCK).entrySet() .stream() - .filter(e -> e.getValue() instanceof IPlantable && e.getKey().location().getNamespace().equals("minecraft")) + .filter(e -> e.getValue() instanceof IPlantable && e.getKey().identifier().getNamespace().equals("minecraft")) .map(Map.Entry::getValue) .collect(Collectors.groupingBy(Object::getClass)); @@ -501,7 +501,7 @@ public class PlantTypePlacementTest extends BaseTestMod { private static List testTag(GameTestHelper helper, TagKey tag, List expected) { var lookup = helper.registryLookup(Registries.BLOCK); var values = lookup.getOrThrow(tag).stream() - .filter(h -> h.unwrapKey().orElseThrow().location().getNamespace().equals("minecraft")) // Only vanilla entries + .filter(h -> h.unwrapKey().orElseThrow().identifier().getNamespace().equals("minecraft")) // Only vanilla entries .map(Holder::get) .toList(); helper.assertValueEqual(sort(expected), sort(values), tag.location().toString(), "Tag does not have expected values"); diff --git a/src/test/java/net/minecraftforge/debug/gameplay/crafting/ConditionalRecipeTest.java b/src/test/java/net/minecraftforge/debug/gameplay/crafting/ConditionalRecipeTest.java index cffdc0f39b..bc3ae3569e 100644 --- a/src/test/java/net/minecraftforge/debug/gameplay/crafting/ConditionalRecipeTest.java +++ b/src/test/java/net/minecraftforge/debug/gameplay/crafting/ConditionalRecipeTest.java @@ -27,7 +27,6 @@ import net.minecraft.world.item.crafting.Recipe; import net.minecraft.world.item.crafting.RecipeInput; import net.minecraft.world.item.crafting.RecipeType; import net.minecraft.world.item.crafting.SingleRecipeInput; -import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; import net.minecraftforge.common.Tags; import net.minecraftforge.common.crafting.ConditionalRecipe; @@ -36,7 +35,6 @@ import net.minecraftforge.common.crafting.conditions.IConditionBuilder; import net.minecraftforge.common.data.BlockTagsProvider; import net.minecraftforge.common.data.ExistingFileHelper; import net.minecraftforge.data.event.GatherDataEvent; -import net.minecraftforge.eventbus.api.listener.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.gametest.GameTest; @@ -70,7 +68,7 @@ public class ConditionalRecipeTest extends BaseTestMod { private static > void assertTrue(GameTestHelper helper, RecipeType type, C container) { var recipe = helper.getLevel().recipeAccess().getRecipeFor(type, container, helper.getLevel()); helper.assertTrue(recipe.isPresent(), "Did not find crafting recipe when expected!"); - helper.assertTrue(recipe.get().id().location().getNamespace().equals(MODID), "It wasn't our recipe: " + recipe.get().id()); + helper.assertTrue(recipe.get().id().identifier().getNamespace().equals(MODID), "It wasn't our recipe: " + recipe.get().id()); helper.succeed(); } diff --git a/src/test/java/net/minecraftforge/debug/gameplay/crafting/CustomIngredientsTest.java b/src/test/java/net/minecraftforge/debug/gameplay/crafting/CustomIngredientsTest.java index 9554e110de..888b64680a 100644 --- a/src/test/java/net/minecraftforge/debug/gameplay/crafting/CustomIngredientsTest.java +++ b/src/test/java/net/minecraftforge/debug/gameplay/crafting/CustomIngredientsTest.java @@ -88,8 +88,8 @@ public class CustomIngredientsTest extends BaseTestMod implements INBTBuilder { private static > void assertRecipeMatch(GameTestHelper helper, RecipeType type, C container, String name) { var recipe = helper.getLevel().recipeAccess().getRecipeFor(type, container, helper.getLevel()); helper.assertTrue(recipe.isPresent(), "Did not find crafting recipe when expected!"); - helper.assertTrue(recipe.get().id().location().getNamespace().equals(MODID), "It wasn't our recipe: " + recipe.get().id()); - helper.assertTrue(recipe.get().id().location().getPath().equals(name), "It wasn't the correct recipe expected: " + name + " got: " + recipe.get().id()); + helper.assertTrue(recipe.get().id().identifier().getNamespace().equals(MODID), "It wasn't our recipe: " + recipe.get().id()); + helper.assertTrue(recipe.get().id().identifier().getPath().equals(name), "It wasn't the correct recipe expected: " + name + " got: " + recipe.get().id()); helper.succeed(); } diff --git a/src/test/java/net/minecraftforge/debug/gameplay/crafting/TagsTest.java b/src/test/java/net/minecraftforge/debug/gameplay/crafting/TagsTest.java index 251a19c25e..db0ff22ade 100644 --- a/src/test/java/net/minecraftforge/debug/gameplay/crafting/TagsTest.java +++ b/src/test/java/net/minecraftforge/debug/gameplay/crafting/TagsTest.java @@ -6,7 +6,7 @@ package net.minecraftforge.debug.gameplay.crafting; import net.minecraft.gametest.framework.GameTestHelper; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.tags.ItemTags; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; @@ -28,7 +28,7 @@ public class TagsTest extends BaseTestMod { @GameTest public static void cobble_in_legacy(GameTestHelper helper) throws ReflectiveOperationException { var cobble = new ItemStack(Items.COBBLESTONE); - var forgeCobbleTag = ItemTags.create(ResourceLocation.fromNamespaceAndPath("forge", "cobblestone")); + var forgeCobbleTag = ItemTags.create(Identifier.fromNamespaceAndPath("forge", "cobblestone")); boolean isCobble = cobble.is(forgeCobbleTag); helper.assertTrue(isCobble, forgeCobbleTag + " is missing " + Items.COBBLESTONE); helper.succeed(); diff --git a/src/test/java/net/minecraftforge/debug/gameplay/criterion/BreakWithItemCriterion.java b/src/test/java/net/minecraftforge/debug/gameplay/criterion/BreakWithItemCriterion.java index 7cc7820db2..a7d239b1ce 100644 --- a/src/test/java/net/minecraftforge/debug/gameplay/criterion/BreakWithItemCriterion.java +++ b/src/test/java/net/minecraftforge/debug/gameplay/criterion/BreakWithItemCriterion.java @@ -7,22 +7,20 @@ package net.minecraftforge.debug.gameplay.criterion; import com.mojang.serialization.Codec; import com.mojang.serialization.codecs.RecordCodecBuilder; -import net.minecraft.MethodsReturnNonnullByDefault; +import org.jspecify.annotations.NullMarked; import net.minecraft.advancements.Criterion; -import net.minecraft.advancements.critereon.BlockPredicate; -import net.minecraft.advancements.critereon.ContextAwarePredicate; -import net.minecraft.advancements.critereon.ItemPredicate; -import net.minecraft.advancements.critereon.SimpleCriterionTrigger; +import net.minecraft.advancements.criterion.BlockPredicate; +import net.minecraft.advancements.criterion.ContextAwarePredicate; +import net.minecraft.advancements.criterion.ItemPredicate; +import net.minecraft.advancements.criterion.SimpleCriterionTrigger; import net.minecraft.core.BlockPos; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.InteractionHand; -import javax.annotation.ParametersAreNonnullByDefault; import java.util.Optional; -@ParametersAreNonnullByDefault -@MethodsReturnNonnullByDefault +@NullMarked public final class BreakWithItemCriterion extends SimpleCriterionTrigger { public Criterion instance(BlockPredicate block, ItemPredicate item, boolean offHand) { return this.createCriterion(new Instance(block, item, offHand)); 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 96cedf1a8a..3b0e0452c5 100644 --- a/src/test/java/net/minecraftforge/debug/gameplay/criterion/CriterionTest.java +++ b/src/test/java/net/minecraftforge/debug/gameplay/criterion/CriterionTest.java @@ -10,8 +10,8 @@ import net.minecraft.advancements.AdvancementHolder; import net.minecraft.advancements.AdvancementRequirements; import net.minecraft.advancements.AdvancementType; import net.minecraft.advancements.CriterionTrigger; -import net.minecraft.advancements.critereon.BlockPredicate; -import net.minecraft.advancements.critereon.ItemPredicate; +import net.minecraft.advancements.criterion.BlockPredicate; +import net.minecraft.advancements.criterion.ItemPredicate; import net.minecraft.core.BlockPos; import net.minecraft.core.HolderLookup; import net.minecraft.core.registries.BuiltInRegistries; @@ -19,13 +19,12 @@ import net.minecraft.core.registries.Registries; import net.minecraft.data.tags.VanillaItemTagsProvider; import net.minecraft.gametest.framework.GameTestHelper; import net.minecraft.network.chat.Component; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.level.ServerPlayer; 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; @@ -48,7 +47,7 @@ public final class CriterionTest extends BaseTestMod { private static final DeferredRegister> TRIGGERS = DeferredRegister.create(BuiltInRegistries.TRIGGER_TYPES.key(), MOD_ID); public static final RegistryObject CRITERION = TRIGGERS.register("criterion", BreakWithItemCriterion::new); public static final String TEST_CRITERION_ID = "break_glass_with_fish"; - public static final ResourceLocation TEST_ADVANCEMENT_ID = ResourceLocation.fromNamespaceAndPath(MOD_ID, TEST_CRITERION_ID); + public static final Identifier TEST_ADVANCEMENT_ID = Identifier.fromNamespaceAndPath(MOD_ID, TEST_CRITERION_ID); public CriterionTest(FMLJavaModLoadingContext context) { super(context, false, true); @@ -102,7 +101,7 @@ public final class CriterionTest extends BaseTestMod { } private void gatherData(GatherDataEvent event) { - var tag = TagKey.create(Registries.ITEM, ResourceLocation.fromNamespaceAndPath(MOD_ID, "fish")); + var tag = TagKey.create(Registries.ITEM, Identifier.fromNamespaceAndPath(MOD_ID, "fish")); event.getGenerator().addProvider(true, new VanillaItemTagsProvider(event.getGenerator().getPackOutput(), event.getLookupProvider(), MOD_ID, event.getExistingFileHelper()) { @Override @@ -118,7 +117,7 @@ public final class CriterionTest extends BaseTestMod { } }); - var STORY_ROOT = new AdvancementHolder(ResourceLocation.fromNamespaceAndPath("minecraft", "story/root"), null); + var STORY_ROOT = new AdvancementHolder(Identifier.fromNamespaceAndPath("minecraft", "story/root"), null); event.getGenerator().addProvider(true, new ForgeAdvancementProvider( diff --git a/src/test/java/net/minecraftforge/debug/gameplay/data/DatapackBuiltinEntriesProviderTest.java b/src/test/java/net/minecraftforge/debug/gameplay/data/DatapackBuiltinEntriesProviderTest.java index 8b39e2197c..991fc8b608 100644 --- a/src/test/java/net/minecraftforge/debug/gameplay/data/DatapackBuiltinEntriesProviderTest.java +++ b/src/test/java/net/minecraftforge/debug/gameplay/data/DatapackBuiltinEntriesProviderTest.java @@ -10,7 +10,7 @@ import net.minecraft.core.RegistrySetBuilder; import net.minecraft.core.registries.Registries; import net.minecraft.data.worldgen.BootstrapContext; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.tags.BiomeTags; import net.minecraft.tags.BlockTags; import net.minecraft.world.level.block.Blocks; @@ -38,10 +38,10 @@ public class DatapackBuiltinEntriesProviderTest extends BaseTestMod { public static final String MOD_ID = "datapack_builtin_entries_provider_test"; // Vanilla registry entries - public static final ResourceKey> MOSSY_STONE_FEATURE = ResourceKey.create(Registries.CONFIGURED_FEATURE, ResourceLocation.fromNamespaceAndPath(MOD_ID, "mossy_stone")); - public static final ResourceKey MOSSY_STONE_PLACEMENT = ResourceKey.create(Registries.PLACED_FEATURE, ResourceLocation.fromNamespaceAndPath(MOD_ID, "mossy_stone")); + public static final ResourceKey> MOSSY_STONE_FEATURE = ResourceKey.create(Registries.CONFIGURED_FEATURE, Identifier.fromNamespaceAndPath(MOD_ID, "mossy_stone")); + public static final ResourceKey MOSSY_STONE_PLACEMENT = ResourceKey.create(Registries.PLACED_FEATURE, Identifier.fromNamespaceAndPath(MOD_ID, "mossy_stone")); // Forge registry entries - public static final ResourceKey MOSSY_STONE_MODIFIER = ResourceKey.create(ForgeRegistries.Keys.BIOME_MODIFIERS, ResourceLocation.fromNamespaceAndPath(MOD_ID, "mossy_stone_modifier")); + public static final ResourceKey MOSSY_STONE_MODIFIER = ResourceKey.create(ForgeRegistries.Keys.BIOME_MODIFIERS, Identifier.fromNamespaceAndPath(MOD_ID, "mossy_stone_modifier")); // The ore targets public static final Supplier> MOSSY_STONE_TARGETS = () -> { return List.of( diff --git a/src/test/java/net/minecraftforge/debug/gameplay/item/ItemCapabilityTest.java b/src/test/java/net/minecraftforge/debug/gameplay/item/ItemCapabilityTest.java index 8caa48cee0..f47530e701 100644 --- a/src/test/java/net/minecraftforge/debug/gameplay/item/ItemCapabilityTest.java +++ b/src/test/java/net/minecraftforge/debug/gameplay/item/ItemCapabilityTest.java @@ -14,7 +14,7 @@ import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.RegistryFriendlyByteBuf; import net.minecraft.network.chat.Component; import net.minecraft.network.codec.ByteBufCodecs; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.util.ExtraCodecs; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; @@ -57,7 +57,7 @@ public class ItemCapabilityTest extends BaseTestMod { private static void onEvent(AttachCapabilitiesEvent.ItemStacks event) { if (event.getObject().getItem() == Items.COPPER_INGOT) { event.addCapability( - ResourceLocation.fromNamespaceAndPath("forge", "test"), + Identifier.fromNamespaceAndPath("forge", "test"), new MyProvider(event.getObject()) ); } diff --git a/src/test/java/net/minecraftforge/debug/gameplay/item/ShearsBehaviorTest.java b/src/test/java/net/minecraftforge/debug/gameplay/item/ShearsBehaviorTest.java index 2b2192dc75..d2317dec95 100644 --- a/src/test/java/net/minecraftforge/debug/gameplay/item/ShearsBehaviorTest.java +++ b/src/test/java/net/minecraftforge/debug/gameplay/item/ShearsBehaviorTest.java @@ -9,7 +9,7 @@ import net.minecraft.core.BlockPos; import net.minecraft.gametest.framework.GameTestHelper; import net.minecraft.world.InteractionHand; import net.minecraft.world.entity.EntityType; -import net.minecraft.world.entity.animal.coppergolem.CopperGolem; +import net.minecraft.world.entity.animal.golem.CopperGolem; import net.minecraft.world.entity.decoration.LeashFenceKnotEntity; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; diff --git a/src/test/java/net/minecraftforge/debug/gameplay/item/ShieldDisablingTest.java b/src/test/java/net/minecraftforge/debug/gameplay/item/ShieldDisablingTest.java index 4f5547ebde..cc9f1c2f8d 100644 --- a/src/test/java/net/minecraftforge/debug/gameplay/item/ShieldDisablingTest.java +++ b/src/test/java/net/minecraftforge/debug/gameplay/item/ShieldDisablingTest.java @@ -5,7 +5,7 @@ package net.minecraftforge.debug.gameplay.item; -import net.minecraft.Util; +import net.minecraft.util.Util; import net.minecraft.commands.arguments.EntityAnchorArgument; import net.minecraft.core.BlockPos; import net.minecraft.core.registries.Registries; 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 c9e09d2960..326b0f10fc 100644 --- a/src/test/java/net/minecraftforge/debug/gameplay/loot/GlobalLootModifiersTest.java +++ b/src/test/java/net/minecraftforge/debug/gameplay/loot/GlobalLootModifiersTest.java @@ -10,10 +10,10 @@ import com.mojang.serialization.Codec; import com.mojang.serialization.MapCodec; import com.mojang.serialization.codecs.RecordCodecBuilder; import it.unimi.dsi.fastutil.objects.ObjectArrayList; -import net.minecraft.advancements.critereon.DataComponentMatchers; -import net.minecraft.advancements.critereon.EnchantmentPredicate; -import net.minecraft.advancements.critereon.ItemPredicate; -import net.minecraft.advancements.critereon.MinMaxBounds; +import net.minecraft.advancements.criterion.DataComponentMatchers; +import net.minecraft.advancements.criterion.EnchantmentPredicate; +import net.minecraft.advancements.criterion.ItemPredicate; +import net.minecraft.advancements.criterion.MinMaxBounds; import net.minecraft.core.BlockPos; import net.minecraft.core.HolderLookup; import net.minecraft.core.RegistrySetBuilder; @@ -32,7 +32,7 @@ import net.minecraft.data.loot.LootTableProvider; import net.minecraft.data.registries.RegistryPatchGenerator; import net.minecraft.gametest.framework.GameTestHelper; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.tags.ItemTags; import net.minecraft.world.item.enchantment.Enchantment; import net.minecraft.world.item.enchantment.EnchantmentHelper; @@ -62,7 +62,6 @@ import net.minecraftforge.common.data.GlobalLootModifierProvider; import net.minecraftforge.common.loot.IGlobalLootModifier; import net.minecraftforge.common.loot.LootModifier; import net.minecraftforge.common.loot.LootTableIdCondition; -import net.minecraftforge.eventbus.api.listener.SubscribeEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.registries.RegistryObject; import net.minecraftforge.test.BaseTestMod; @@ -93,7 +92,7 @@ public class GlobalLootModifiersTest extends BaseTestMod { GLM.register("silk_touch_bamboo", SilkTouchTestModifier.CODEC); } - private static final ResourceKey SMELT = ResourceKey.create(Registries.ENCHANTMENT, ResourceLocation.fromNamespaceAndPath(MODID, "smelt")); + private static final ResourceKey SMELT = ResourceKey.create(Registries.ENCHANTMENT, Identifier.fromNamespaceAndPath(MODID, "smelt")); private static final Supplier ENCHANTMENTS = () -> new RegistrySetBuilder() .add(Registries.ENCHANTMENT, ctx -> { ctx.register(SMELT, Enchantment.enchantment( @@ -101,7 +100,7 @@ public class GlobalLootModifiersTest extends BaseTestMod { ctx.lookup(Registries.ITEM).getOrThrow(ItemTags.MINING_LOOT_ENCHANTABLE), 1, 1, Enchantment.constantCost(15), Enchantment.constantCost(15), 5, EquipmentSlotGroup.MAINHAND ) - ).build(SMELT.location())); + ).build(SMELT.identifier())); }); private static final DeferredRegister BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, MODID); @@ -247,7 +246,7 @@ public class GlobalLootModifiersTest extends BaseTestMod { // Tested by verifying that we drop 2 test blocks when broken instead of the default 1 add("multiply_loot", new MultiplyDropsModifier( new LootItemCondition[] { - LootTableIdCondition.builder(TEST_BLOCK.get().getLootTable().get().location()).build() + LootTableIdCondition.builder(TEST_BLOCK.get().getLootTable().get().identifier()).build() }, 2) ); 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 c0d589ea50..a9f5438953 100644 --- a/src/test/java/net/minecraftforge/debug/gameplay/loot/LootEventsTest.java +++ b/src/test/java/net/minecraftforge/debug/gameplay/loot/LootEventsTest.java @@ -80,7 +80,7 @@ public class LootEventsTest extends BaseTestMod { private class ForgeEvents { public static void onLootTableLoad(LootTableLoadEvent event) { - if (event.getName().equals(TEST_BLOCK.get().getLootTable().orElse(null).location())) { + if (event.getName().equals(TEST_BLOCK.get().getLootTable().orElse(null).identifier())) { event.getTable().removePool(0); event.getTable().addPool( LootPool.lootPool() diff --git a/src/test/java/net/minecraftforge/debug/gameplay/villager/VillagerTypeTestMod.java b/src/test/java/net/minecraftforge/debug/gameplay/villager/VillagerTypeTestMod.java index 222dcd7ede..cad9c3f6f2 100644 --- a/src/test/java/net/minecraftforge/debug/gameplay/villager/VillagerTypeTestMod.java +++ b/src/test/java/net/minecraftforge/debug/gameplay/villager/VillagerTypeTestMod.java @@ -11,9 +11,9 @@ import net.minecraft.core.registries.Registries; import net.minecraft.gametest.framework.GameTestHelper; import net.minecraft.network.chat.Component; import net.minecraft.world.entity.EntityType; -import net.minecraft.world.entity.npc.Villager; -import net.minecraft.world.entity.npc.VillagerTrades; -import net.minecraft.world.entity.npc.VillagerType; +import net.minecraft.world.entity.npc.villager.Villager; +import net.minecraft.world.entity.npc.villager.VillagerTrades; +import net.minecraft.world.entity.npc.villager.VillagerType; import net.minecraft.world.item.Items; import net.minecraft.world.level.biome.Biome; import net.minecraft.world.level.biome.Biomes; @@ -68,13 +68,13 @@ public class VillagerTypeTestMod extends BaseTestMod { // Should be a successful trade for dirt for our test villager var test = new Villager(EntityType.VILLAGER, helper.getLevel(), TEST_VILLAGER_TYPE.getKey()); - var test_offer = trade.getOffer(test, rnd); + var test_offer = trade.getOffer(helper.getLevel(), test, rnd); helper.assertFalse(test_offer == null, "Failed to retreive trade value for test profession"); helper.assertValueEqual(test_offer.getItemCostA().itemStack().getItem(), Items.DIRT, Component.literal("Offer did not return the expected item")); var plains = new Villager(EntityType.VILLAGER, helper.getLevel(), VillagerType.PLAINS); // This will NPE on unpatched code, we need to test that it returns null correctly - var plains_offer = trade.getOffer(plains, rnd); + var plains_offer = trade.getOffer(helper.getLevel(), plains, rnd); helper.assertTrue(plains_offer == null, "Offer should not be available for a plains villager"); helper.succeed(); diff --git a/src/test/java/net/minecraftforge/debug/network/PacketTest.java b/src/test/java/net/minecraftforge/debug/network/PacketTest.java index d77a8208f7..e9f467f773 100644 --- a/src/test/java/net/minecraftforge/debug/network/PacketTest.java +++ b/src/test/java/net/minecraftforge/debug/network/PacketTest.java @@ -15,7 +15,7 @@ import net.minecraft.network.RegistryFriendlyByteBuf; import net.minecraft.network.chat.Component; import net.minecraft.network.codec.StreamCodec; import net.minecraft.network.protocol.common.ClientboundCustomPayloadPacket; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.network.CommonListenerCookie; import net.minecraft.world.phys.Vec3; @@ -152,7 +152,7 @@ public class PacketTest extends BaseTestMod { } private static class TestChannel { - private static final ResourceLocation CHANNEL_NAME = rl(PacketTest.MODID, "main_channel"); + private static final Identifier CHANNEL_NAME = rl(PacketTest.MODID, "main_channel"); private static final int PROTOCOL_VERSION = 1; private static final SimpleChannel CHANNEL = ChannelBuilder diff --git a/src/test/java/net/minecraftforge/debug/registries/NetworkDatapackRegistryTest.java b/src/test/java/net/minecraftforge/debug/registries/NetworkDatapackRegistryTest.java index 4ec0137be6..9a035a81fe 100644 --- a/src/test/java/net/minecraftforge/debug/registries/NetworkDatapackRegistryTest.java +++ b/src/test/java/net/minecraftforge/debug/registries/NetworkDatapackRegistryTest.java @@ -17,7 +17,7 @@ import net.minecraft.core.Registry; import net.minecraft.gametest.framework.GameTestHelper; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.loading.FMLLoader; import net.minecraftforge.gametest.GameTest; @@ -34,7 +34,7 @@ public class NetworkDatapackRegistryTest extends BaseTestMod { public static final String MODID = "network_data_registry"; private static final ResourceKey> REGISTRY_KEY = ResourceKey.createRegistryKey(rl("registry")); - private static final ResourceLocation TEST_VALUE = rl("test_value_new"); + private static final Identifier TEST_VALUE = rl("test_value_new"); private static final DeferredRegisterData REGISTRY = DeferredRegisterData.create(REGISTRY_KEY, smodid()); private static final RegistryObject REGISTRY_ENTRY = REGISTRY.register("test_entry", () -> new DataObject(TEST_VALUE)); @@ -62,16 +62,16 @@ public class NetworkDatapackRegistryTest extends BaseTestMod { var mc = Minecraft.getInstance(); var level = mc.level; var reg = level.registryAccess().lookup(REGISTRY_KEY); - helper.assertTrue(reg.isPresent(), "Failed to find " + REGISTRY_KEY.location()); + helper.assertTrue(reg.isPresent(), "Failed to find " + REGISTRY_KEY.identifier()); var entry = reg.get().getValue(REGISTRY_ENTRY.getKey()); if (entry == null) helper.fail("Failed to find " + REGISTRY_ENTRY.getKey()); helper.assertValueEqual(entry.value, TEST_VALUE, Component.literal("Loaded entry does not contain expected value")); } - public static record DataObject(ResourceLocation value) { + public static record DataObject(Identifier value) { public static final Codec DIRECT_CODEC = RecordCodecBuilder.create(instance -> instance.group( - ResourceLocation.CODEC.fieldOf("value").forGetter(DataObject::value) + Identifier.CODEC.fieldOf("value").forGetter(DataObject::value) ).apply(instance, DataObject::new)); } } diff --git a/src/test/java/net/minecraftforge/test/BaseTestMod.java b/src/test/java/net/minecraftforge/test/BaseTestMod.java index a1596a27f6..06eb401f08 100644 --- a/src/test/java/net/minecraftforge/test/BaseTestMod.java +++ b/src/test/java/net/minecraftforge/test/BaseTestMod.java @@ -29,7 +29,7 @@ import net.minecraft.gametest.framework.FunctionGameTestInstance; import net.minecraft.gametest.framework.TestData; import net.minecraft.gametest.framework.TestEnvironmentDefinition; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.world.item.CreativeModeTab.TabVisibility; import net.minecraft.world.level.block.state.BlockBehaviour; import net.minecraftforge.common.data.DatapackBuiltinEntriesProvider; @@ -51,7 +51,7 @@ public abstract class BaseTestMod { protected final List>, DeferredRegisterData>> dataRegistries = new ArrayList<>(); protected final Set> myDataRegistries = new HashSet<>(); - protected final Map tests; + protected final Map tests; public BaseTestMod(FMLJavaModLoadingContext context) { this(context, true, true); @@ -132,13 +132,13 @@ public abstract class BaseTestMod { return mod.value(); } - protected static ResourceLocation rl(String path) { + protected static Identifier rl(String path) { var modid = modid(StackWalker.getInstance(StackWalker.Option.RETAIN_CLASS_REFERENCE).getCallerClass()); - return ResourceLocation.fromNamespaceAndPath(modid, path); + return Identifier.fromNamespaceAndPath(modid, path); } - protected static ResourceLocation rl(String namespace, String path) { - return ResourceLocation.fromNamespaceAndPath(namespace, path); + protected static Identifier rl(String namespace, String path) { + return Identifier.fromNamespaceAndPath(namespace, path); } protected static BlockBehaviour.Properties name(String namespace, String name, BlockBehaviour.Properties peops) { @@ -255,7 +255,7 @@ public abstract class BaseTestMod { @Override protected boolean shouldDump(ResourceKey key) { - return tests.containsKey(key.location()); + return tests.containsKey(key.identifier()); } }); } diff --git a/src/test/java/net/minecraftforge/test/ManifestProvider.java b/src/test/java/net/minecraftforge/test/ManifestProvider.java index 321a0bbbc1..8631bb4ded 100644 --- a/src/test/java/net/minecraftforge/test/ManifestProvider.java +++ b/src/test/java/net/minecraftforge/test/ManifestProvider.java @@ -12,7 +12,7 @@ import java.util.jar.JarFile; import java.util.jar.Manifest; import java.util.jar.Attributes; import com.google.common.hash.Hashing; -import net.minecraft.Util; +import net.minecraft.util.Util; import net.minecraft.data.CachedOutput; import net.minecraft.data.DataProvider; import net.minecraft.data.PackOutput; diff --git a/src/test/java/net/minecraftforge/test/ModuleProvider.java b/src/test/java/net/minecraftforge/test/ModuleProvider.java index 8c4341bb66..f4333c6109 100644 --- a/src/test/java/net/minecraftforge/test/ModuleProvider.java +++ b/src/test/java/net/minecraftforge/test/ModuleProvider.java @@ -26,7 +26,7 @@ import org.objectweb.asm.ClassWriter; import org.objectweb.asm.Opcodes; import com.google.common.hash.Hashing; -import net.minecraft.Util; +import net.minecraft.util.Util; import net.minecraft.data.CachedOutput; import net.minecraft.data.DataProvider; import net.minecraft.data.PackOutput; diff --git a/src/test/java/net/minecraftforge/test/TestHelperMod.java b/src/test/java/net/minecraftforge/test/TestHelperMod.java index 50ee45330c..fb636b4590 100644 --- a/src/test/java/net/minecraftforge/test/TestHelperMod.java +++ b/src/test/java/net/minecraftforge/test/TestHelperMod.java @@ -10,7 +10,7 @@ import net.minecraft.core.registries.Registries; import net.minecraft.data.metadata.PackMetadataGenerator; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.packs.PackType; import net.minecraft.server.packs.metadata.pack.PackMetadataSection; import net.minecraft.world.item.CreativeModeTab; @@ -26,7 +26,7 @@ import net.minecraftforge.registries.RegisterEvent; @Mod(TestHelperMod.MOD_ID) public class TestHelperMod extends BaseTestMod { public static final String MOD_ID = "test_helper_mod"; - public static final ResourceKey TAB = ResourceKey.create(Registries.CREATIVE_MODE_TAB, ResourceLocation.fromNamespaceAndPath(MOD_ID, "test_items")); + public static final ResourceKey TAB = ResourceKey.create(Registries.CREATIVE_MODE_TAB, Identifier.fromNamespaceAndPath(MOD_ID, "test_items")); public TestHelperMod(FMLJavaModLoadingContext context) { super(context);