From 5cc8f1cdbb1933c57f991eb7a7f6c6aef61ee7a2 Mon Sep 17 00:00:00 2001 From: Thutmose Date: Thu, 2 Dec 2021 18:46:24 -0500 Subject: [PATCH] Initial pass of 1.18 update This cleans up most of the not-worldgen related errors from the direct update --- build.gradle | 18 +- gradle.properties | 8 +- gradle/wrapper/gradle-wrapper.properties | 2 +- .../java/pokecube/adventures/PokecubeAdv.java | 10 +- .../adventures/ai/poi/PointsOfInterest.java | 2 +- .../ai/tasks/battle/agro/BaseAgroTask.java | 63 +++-- .../adventures/blocks/BlockEventHandler.java | 2 +- .../blocks/genetics/cloner/ClonerBlock.java | 2 +- .../genetics/extractor/ExtractorBlock.java | 2 +- .../blocks/genetics/splicer/SplicerBlock.java | 2 +- .../adventures/blocks/siphon/SiphonBlock.java | 2 +- .../blocks/statue/PokemobStatue.java | 2 +- .../blocks/statue/StatueEntity.java | 2 +- .../capabilities/utils/GuiOpenAction.java | 2 +- .../adventures/entity/trainer/TrainerNpc.java | 2 +- .../events/TrainerEventHandler.java | 36 ++- .../events/TrainerSpawnHandler.java | 2 +- .../adventures/init/ClientSetupHandler.java | 4 +- .../adventures/network/PacketBag.java | 2 +- .../adventures/proxy/CommonProxy.java | 15 + .../adventures/utils/RecipePokeAdv.java | 2 +- src/main/java/pokecube/compat/cct/Impl.java | 4 +- .../compat/cct/modules/Extractor.java | 6 +- .../pokecube/compat/cct/modules/Splicer.java | 6 +- .../java/pokecube/compat/curios/Impl.java | 2 +- src/main/java/pokecube/compat/jei/Compat.java | 2 +- .../jei/categories/cloner/Category.java | 4 +- .../jei/categories/evolution/Category.java | 4 +- .../jei/categories/interaction/Category.java | 4 +- .../interaction/InteractRecipe.java | 2 +- .../compat/jei/categories/move/Category.java | 2 +- .../compat/jei/ingredients/Pokemob.java | 2 +- .../pokecube/compat/minecolonies/Impl.java | 4 +- .../pokecube/compat/thutessentials/Impl.java | 4 +- src/main/java/pokecube/core/PokecubeCore.java | 2 +- .../java/pokecube/core/PokecubeItems.java | 3 +- .../ai/brain/sensors/InterestingMobs.java | 4 +- .../pokecube/core/ai/pathing/FlyPathNavi.java | 2 +- .../core/ai/pathing/WalkPathNavi.java | 2 +- .../core/ai/poi/PointsOfInterest.java | 2 +- .../core/ai/tasks/ants/sensors/EggSensor.java | 3 +- .../core/ai/tasks/ants/tasks/work/Build.java | 5 +- .../core/ai/tasks/ants/tasks/work/Guard.java | 10 +- .../combat/management/CallForHelpTask.java | 11 +- .../combat/management/FindTargetsTask.java | 40 +-- .../core/ai/tasks/idle/GuardEggTask.java | 19 +- .../core/ai/tasks/idle/HungerTask.java | 12 +- .../core/ai/tasks/misc/LookAtMob.java | 18 +- .../core/blocks/healer/HealerBlock.java | 2 +- .../core/blocks/maxspot/MaxBlock.java | 2 +- .../pokecube/core/blocks/nests/NestTile.java | 2 +- .../java/pokecube/core/blocks/pc/PCBlock.java | 2 +- .../pokecube/core/blocks/tms/TMBlock.java | 2 +- .../core/blocks/trade/TraderBlock.java | 2 +- .../core/client/EventsHandlerClient.java | 18 +- .../core/client/gui/helper/GuardEntry.java | 6 +- .../core/client/gui/helper/TexButton.java | 6 +- .../client/render/mobs/RenderMobOverlays.java | 14 +- .../java/pokecube/core/commands/Count.java | 1 + .../core/database/resources/PackFinder.java | 20 +- .../java/pokecube/core/entity/npc/NpcMob.java | 4 +- .../entity/pokemobs/ContainerPokemob.java | 2 +- .../core/entity/pokemobs/EntityPokemob.java | 2 +- .../core/entity/pokemobs/PokemobType.java | 2 +- .../entity/pokemobs/helper/PokemobBase.java | 2 +- .../pokecube/core/handlers/RecipeHandler.java | 2 +- .../core/handlers/events/EventsHandler.java | 8 +- .../handlers/events/PokemobEventsHandler.java | 5 +- .../playerdata/PlayerPokemobCache.java | 9 +- .../core/init/ClientSetupHandler.java | 2 +- .../capabilities/impl/PokemobSexed.java | 4 +- .../core/inventory/pc/PCContainer.java | 2 +- .../items/pokecubes/EntityPokecubeBase.java | 46 +--- .../core/items/pokecubes/Pokecube.java | 31 ++- .../core/moves/PokemobTerrainEffects.java | 6 +- .../core/moves/animations/EntityMoveUse.java | 2 +- .../moves/animations/MoveAnimationHelper.java | 6 +- .../core/network/packets/PacketPC.java | 2 +- .../network/packets/PacketSyncRoutes.java | 2 +- .../network/pokemobs/PacketPokemobGui.java | 2 +- .../java/pokecube/core/proxy/CommonProxy.java | 28 +- .../pokecube/core/recipes/MoveRecipes.java | 2 +- .../core/utils/PokecubeSerializer.java | 4 +- .../core/world/gen/WorldgenFeatures.java | 2 +- .../core/world/gen/jigsaw/JigsawAssmbler.java | 5 +- .../pokecube/legends/PokecubeLegends.java | 4 +- .../containers/GenericBookshelfEmpty.java | 2 +- .../blocks/customblocks/RaidSpawnBlock.java | 2 +- .../legends/blocks/customblocks/Rotates.java | 2 +- .../blocks/normalblocks/DynaLeavesBlock.java | 55 ++-- .../blocks/plants/CrystallizedBush.java | 2 +- .../blocks/plants/CrystallizedCactus.java | 4 +- .../blocks/plants/TallCrystallizedBush.java | 2 +- .../blocks/plants/TemporalBambooBlock.java | 256 +++++++++--------- .../legends/entity/WormholeEntity.java | 2 +- .../java/pokecube/legends/init/BlockInit.java | 2 +- .../legends/init/ClientSetupHandler.java | 4 +- .../pokecube/legends/init/ContainerInit.java | 2 +- .../pokecube/legends/init/EntityInit.java | 2 +- .../java/pokecube/legends/init/FluidInit.java | 2 +- .../java/pokecube/legends/init/ItemInit.java | 2 +- .../pokecube/legends/init/ParticleInit.java | 2 +- .../pokecube/legends/init/PlantsInit.java | 2 +- .../pokecube/legends/init/TileEntityInit.java | 2 +- .../items/tools/ZamazentaShieldItem.java | 30 +- .../LegendsDistorticRecipeManager.java | 2 +- .../recipes/LegendsLootingRecipeManager.java | 2 +- .../legends/spawns/LegendarySpawn.java | 2 +- .../legends/tileentity/GenericBarrelTile.java | 2 +- .../legends/worldgen/WorldgenFeatures.java | 2 +- .../worldgen/features/LakeFeature.java | 3 +- .../worldgen/features/TaintedKelpFeature.java | 1 + .../features/TemporalBambooFeature.java | 1 + .../pokecube/mixin/MixinLakesFeature.java | 3 +- .../mobs/moves/world/ActionNaturePower.java | 5 +- .../pokecube/nbtedit/forge/ClientProxy.java | 2 +- .../pokecube/nbtedit/forge/CommonProxy.java | 15 + .../nbtedit/gui/GuiCharacterButton.java | 2 +- .../pokecube/nbtedit/gui/GuiNBTButton.java | 2 +- .../java/pokecube/nbtedit/gui/GuiNBTNode.java | 2 +- .../java/pokecube/nbtedit/gui/GuiNBTTree.java | 2 +- .../nbtedit/gui/GuiSaveSlotButton.java | 2 +- src/main/java/thut/api/ThutCaps.java | 2 +- src/main/java/thut/api/Tracker.java | 9 +- src/main/java/thut/api/entity/IAnimated.java | 3 +- .../entity/blockentity/BlockEntityBase.java | 6 +- .../world/BlockEntityChunkProvider.java | 4 +- .../entity/blockentity/world/EntityChunk.java | 11 +- .../entity/blockentity/world/WorldEntity.java | 33 ++- .../java/thut/api/inventory/big/Manager.java | 8 +- .../thut/api/particle/ParticleHandler.java | 12 +- .../thut/api/terrain/StructureManager.java | 2 +- src/main/java/thut/bling/GemRecipe.java | 2 +- .../thut/bling/bag/large/LargeContainer.java | 2 +- .../thut/bling/bag/small/SmallContainer.java | 2 +- .../thut/bling/bag/small/SmallManager.java | 4 +- .../java/thut/bling/client/render/Util.java | 3 +- .../java/thut/bling/network/PacketBag.java | 2 +- src/main/java/thut/core/common/Proxy.java | 13 +- src/main/java/thut/core/common/ThutCore.java | 6 +- .../common/handlers/PlayerDataHandler.java | 6 +- .../java/thut/core/common/network/Packet.java | 2 +- .../core/common/network/PacketAssembly.java | 4 +- .../core/common/network/PacketHandler.java | 6 +- .../thut/core/common/network/TileUpdate.java | 2 +- src/main/java/thut/core/init/ClientInit.java | 12 +- src/main/java/thut/core/init/CommonInit.java | 2 +- .../java/thut/core/proxy/CommonProxy.java | 15 + .../crafts/network/PacketCraftControl.java | 4 +- .../java/thut/crafts/proxy/ClientProxy.java | 10 +- src/main/java/thut/lib/CompatParser.java | 1 + src/main/java/thut/wearables/RecipeDye.java | 2 +- .../java/thut/wearables/ThutWearables.java | 2 +- .../thut/wearables/client/gui/GuiEvents.java | 26 +- .../client/gui/GuiWearableButton.java | 2 +- .../client/render/WearableEventHandler.java | 2 +- .../inventory/ContainerWearables.java | 2 +- .../java/thut/wearables/network/Packet.java | 2 +- .../thut/wearables/network/PacketGui.java | 2 +- .../thut/wearables/network/PacketHandler.java | 6 +- src/test/java/thut/bot/ThutBot.java | 3 +- .../entity/ai/modules/VillageRouteMaker.java | 3 +- .../java/thut/test/scripting/CmdListener.java | 8 +- 163 files changed, 660 insertions(+), 639 deletions(-) diff --git a/build.gradle b/build.gradle index 395950ec8d..e322f16adb 100644 --- a/build.gradle +++ b/build.gradle @@ -39,7 +39,7 @@ version = "${version_minecraft}-${VERSION_COMPILE}" group = 'thut' archivesBaseName = "${compile_name}" -java.toolchain.languageVersion = JavaLanguageVersion.of(16) +java.toolchain.languageVersion = JavaLanguageVersion.of(17) minecraft { mappings channel: "${channel_mappings}", version: "${version_mappings}" @@ -158,28 +158,28 @@ repositories { dependencies { minecraft "net.minecraftforge:forge:${version_minecraft}-${version_forge}" - annotationProcessor 'org.spongepowered:mixin:0.8.4:processor' + annotationProcessor 'org.spongepowered:mixin:0.8.5:processor' //Computer Craft Support. - implementation fg.deobf("org.squiddev:cc-tweaked-${version_cct_mc}:${version_cct}") + //implementation fg.deobf("org.squiddev:cc-tweaked-${version_cct_mc}:${version_cct}") //Lost Cities //implementation "blank:lostcities-1.16-4.0.7-beta" //Thut Essentials - implementation "${depstr_thutessentials}" + //implementation "${depstr_thutessentials}" //JEI // compile against the JEI API but do not include it at runtime - compileOnly fg.deobf("mezz.jei:jei-${version_jei_mc}:${version_jei}:api") + //compileOnly fg.deobf("mezz.jei:jei-${version_jei_mc}:${version_jei}:api") // at runtime, use the full JEI jar - runtimeOnly fg.deobf("mezz.jei:jei-${version_jei_mc}:${version_jei}") + //runtimeOnly fg.deobf("mezz.jei:jei-${version_jei_mc}:${version_jei}") //WHYLA - implementation fg.deobf("curse.maven:Jade-${version_jade}") + //implementation fg.deobf("curse.maven:Jade-${version_jade}") //Minecolonies - implementation "blank:minecolonies-1.17.1-1.0.23-ALPHA-api" + //implementation "blank:minecolonies-1.17.1-1.0.23-ALPHA-api" //Immersive Enginnering //implementation "blusunrize:ImmersiveEngineering:0.15-+" @@ -189,7 +189,7 @@ dependencies { //implementation "blank:LibVulpes-1.16.5-1.0.1-6-api" // Curios - Wearables Support - implementation fg.deobf("curse.maven:curios-${version_curios}") + //implementation fg.deobf("curse.maven:curios-${version_curios}") } sourceSets { diff --git a/gradle.properties b/gradle.properties index fd1f913439..978f4840c3 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,10 +3,10 @@ org.gradle.jvmargs=-Xmx3G org.gradle.daemon=false -version_forge=37.1.0 -version_minecraft=1.17.1 -version_mcsupport=[1.17.1,1.18) -version_mappings=1.17.1 +version_forge=38.0.8 +version_minecraft=1.18 +version_mcsupport=[1.18,1.19) +version_mappings=1.18 channel_mappings=official # Internal thutcore version for modloading purposes diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index ffed3a254e..e750102e09 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/main/java/pokecube/adventures/PokecubeAdv.java b/src/main/java/pokecube/adventures/PokecubeAdv.java index d4f540532b..aea66168e9 100644 --- a/src/main/java/pokecube/adventures/PokecubeAdv.java +++ b/src/main/java/pokecube/adventures/PokecubeAdv.java @@ -34,10 +34,10 @@ import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLLoadCompleteEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; -import net.minecraftforge.fmllegacy.RegistryObject; -import net.minecraftforge.fmllegacy.network.IContainerFactory; +import net.minecraftforge.network.IContainerFactory; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; +import net.minecraftforge.registries.RegistryObject; import pokecube.adventures.advancements.Triggers; import pokecube.adventures.ai.brain.MemoryTypes; import pokecube.adventures.ai.poi.PointsOfInterest; @@ -61,11 +61,11 @@ import pokecube.adventures.blocks.genetics.splicer.SplicerTile; import pokecube.adventures.blocks.siphon.SiphonBlock; import pokecube.adventures.blocks.siphon.SiphonTile; -import pokecube.adventures.blocks.warp_pad.WarpPadBlock; -import pokecube.adventures.blocks.warp_pad.WarpPadTile; import pokecube.adventures.blocks.statue.PokemobStatue; import pokecube.adventures.blocks.statue.StatueEntity; import pokecube.adventures.blocks.statue.StatueItem; +import pokecube.adventures.blocks.warp_pad.WarpPadBlock; +import pokecube.adventures.blocks.warp_pad.WarpPadTile; import pokecube.adventures.entity.trainer.LeaderNpc; import pokecube.adventures.entity.trainer.TrainerNpc; import pokecube.adventures.init.SetupHandler; @@ -148,7 +148,7 @@ public static void registerProfessions(final RegistryEvent.Register brain = this.entity.getBrain(); if (!brain.hasMemoryValue(MemoryTypes.BATTLETARGET)) return false; @@ -73,7 +72,8 @@ protected void start(final ServerLevel worldIn, final LivingEntity entityIn, fin { if (this.trainer.getCooldown() > gameTimeIn) return; if (worldIn.getRandom().nextDouble() > this.chance) return; - final List mobs = this.entity.getBrain().getMemory(MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES).get(); + final NearestVisibleLivingEntities mobs = this.entity.getBrain().getMemory( + MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES).get(); // Count tame mobs as their owners, rather than seperately mobs final Predicate tameChecker = mob -> @@ -94,37 +94,36 @@ protected void start(final ServerLevel worldIn, final LivingEntity entityIn, fin final int rep_cap = PokecubeAdv.config.trainer_max_rep; final int drep = rep_cap - rep_base; - for (LivingEntity mob : mobs) - if (this.isValidTarget(mob) && tameChecker.test(mob)) + for (LivingEntity mob : mobs.findAll(mob -> this.isValidTarget(mob) && tameChecker.test(mob))) + { + if (mob instanceof Player && this.entity instanceof Villager) + { + final Villager villager = (Villager) this.entity; + final int rep = villager.getPlayerReputation((Player) mob) + rep_base; + double s1 = s; + if (rep > rep_cap) s1 = 0; + else if (rep < rep_base) s1 *= 2; + else s1 *= (rep_cap - rep) / drep; + line = entityIn.getViewVector(1).multiply(s1, s1, s1); + end = start.add(line); + } + + final boolean lookingAt = mob.getBoundingBox().clip(start, end).isPresent(); + if (!lookingAt) { - if (mob instanceof Player && this.entity instanceof Villager) - { - final Villager villager = (Villager) this.entity; - final int rep = villager.getPlayerReputation((Player) mob) + rep_base; - double s1 = s; - if (rep > rep_cap) s1 = 0; - else if (rep < rep_base) s1 *= 2; - else s1 *= (rep_cap - rep) / drep; - line = entityIn.getViewVector(1).multiply(s1, s1, s1); - end = start.add(line); - } - - final boolean lookingAt = mob.getBoundingBox().clip(start, end).isPresent(); - if (!lookingAt) - { - BehaviorUtils.lookAtEntity(this.entity, mob); - return; - } - final IOwnable owned = OwnableCaps.getOwnable(mob); - LivingEntity owner; - // Agro the owner of the mob, instead of the mob itself in this - // case. - if (owned != null && (owner = owned.getOwner(worldIn)) != null) mob = owner; - this.timer = 0; - this.target = mob; - this.trainer.onSetTarget(mob); + BehaviorUtils.lookAtEntity(this.entity, mob); return; } + final IOwnable owned = OwnableCaps.getOwnable(mob); + LivingEntity owner; + // Agro the owner of the mob, instead of the mob itself in this + // case. + if (owned != null && (owner = owned.getOwner(worldIn)) != null) mob = owner; + this.timer = 0; + this.target = mob; + this.trainer.onSetTarget(mob); + return; + } } @Override diff --git a/src/main/java/pokecube/adventures/blocks/BlockEventHandler.java b/src/main/java/pokecube/adventures/blocks/BlockEventHandler.java index 4a05f4d2cf..bbf79f879d 100644 --- a/src/main/java/pokecube/adventures/blocks/BlockEventHandler.java +++ b/src/main/java/pokecube/adventures/blocks/BlockEventHandler.java @@ -15,8 +15,8 @@ import net.minecraftforge.eventbus.api.SubscribeEvent; import pokecube.adventures.PokecubeAdv; import pokecube.adventures.blocks.siphon.SiphonTile; -import pokecube.adventures.blocks.warp_pad.WarpPadTile; import pokecube.adventures.blocks.statue.StatueEntity; +import pokecube.adventures.blocks.warp_pad.WarpPadTile; import thut.api.IOwnable; import thut.api.LinkableCaps.ILinkStorage; import thut.api.LinkableCaps.Linkable; diff --git a/src/main/java/pokecube/adventures/blocks/genetics/cloner/ClonerBlock.java b/src/main/java/pokecube/adventures/blocks/genetics/cloner/ClonerBlock.java index abd0e86e30..5374359f15 100644 --- a/src/main/java/pokecube/adventures/blocks/genetics/cloner/ClonerBlock.java +++ b/src/main/java/pokecube/adventures/blocks/genetics/cloner/ClonerBlock.java @@ -160,7 +160,7 @@ public BlockState getStateForPlacement(final BlockPlaceContext context) public BlockState updateShape(final BlockState state, final Direction facing, final BlockState facingState, final LevelAccessor world, final BlockPos currentPos, final BlockPos facingPos) { - if (state.getValue(ClonerBlock.WATERLOGGED)) world.getLiquidTicks().scheduleTick(currentPos, Fluids.WATER, + if (state.getValue(ClonerBlock.WATERLOGGED)) world.scheduleTick(currentPos, Fluids.WATER, Fluids.WATER.getTickDelay(world)); return super.updateShape(state, facing, facingState, world, currentPos, facingPos); } diff --git a/src/main/java/pokecube/adventures/blocks/genetics/extractor/ExtractorBlock.java b/src/main/java/pokecube/adventures/blocks/genetics/extractor/ExtractorBlock.java index 92d405f3d0..cf495afb91 100644 --- a/src/main/java/pokecube/adventures/blocks/genetics/extractor/ExtractorBlock.java +++ b/src/main/java/pokecube/adventures/blocks/genetics/extractor/ExtractorBlock.java @@ -105,7 +105,7 @@ public BlockState getStateForPlacement(final BlockPlaceContext context) public BlockState updateShape(final BlockState state, final Direction facing, final BlockState facingState, final LevelAccessor world, final BlockPos currentPos, final BlockPos facingPos) { - if (state.getValue(ExtractorBlock.WATERLOGGED)) world.getLiquidTicks().scheduleTick(currentPos, Fluids.WATER, + if (state.getValue(ExtractorBlock.WATERLOGGED)) world.scheduleTick(currentPos, Fluids.WATER, Fluids.WATER.getTickDelay(world)); return super.updateShape(state, facing, facingState, world, currentPos, facingPos); } diff --git a/src/main/java/pokecube/adventures/blocks/genetics/splicer/SplicerBlock.java b/src/main/java/pokecube/adventures/blocks/genetics/splicer/SplicerBlock.java index e34ac4c4a9..c27dd05e9d 100644 --- a/src/main/java/pokecube/adventures/blocks/genetics/splicer/SplicerBlock.java +++ b/src/main/java/pokecube/adventures/blocks/genetics/splicer/SplicerBlock.java @@ -160,7 +160,7 @@ public BlockState getStateForPlacement(final BlockPlaceContext context) public BlockState updateShape(final BlockState state, final Direction facing, final BlockState facingState, final LevelAccessor world, final BlockPos currentPos, final BlockPos facingPos) { - if (state.getValue(SplicerBlock.WATERLOGGED)) world.getLiquidTicks().scheduleTick(currentPos, Fluids.WATER, Fluids.WATER.getTickDelay(world)); + if (state.getValue(SplicerBlock.WATERLOGGED)) world.scheduleTick(currentPos, Fluids.WATER, Fluids.WATER.getTickDelay(world)); return super.updateShape(state, facing, facingState, world, currentPos, facingPos); } diff --git a/src/main/java/pokecube/adventures/blocks/siphon/SiphonBlock.java b/src/main/java/pokecube/adventures/blocks/siphon/SiphonBlock.java index 1eec585bde..55ab4e125d 100644 --- a/src/main/java/pokecube/adventures/blocks/siphon/SiphonBlock.java +++ b/src/main/java/pokecube/adventures/blocks/siphon/SiphonBlock.java @@ -74,7 +74,7 @@ public BlockState getStateForPlacement(final BlockPlaceContext context) public BlockState updateShape(final BlockState state, final Direction facing, final BlockState facingState, final LevelAccessor world, final BlockPos currentPos, final BlockPos facingPos) { - if (state.getValue(SiphonBlock.WATERLOGGED)) world.getLiquidTicks().scheduleTick(currentPos, Fluids.WATER, + if (state.getValue(SiphonBlock.WATERLOGGED)) world.scheduleTick(currentPos, Fluids.WATER, Fluids.WATER.getTickDelay(world)); return super.updateShape(state, facing, facingState, world, currentPos, facingPos); } diff --git a/src/main/java/pokecube/adventures/blocks/statue/PokemobStatue.java b/src/main/java/pokecube/adventures/blocks/statue/PokemobStatue.java index 28fad21a86..d0523a989c 100644 --- a/src/main/java/pokecube/adventures/blocks/statue/PokemobStatue.java +++ b/src/main/java/pokecube/adventures/blocks/statue/PokemobStatue.java @@ -147,7 +147,7 @@ public VoxelShape getShape(final BlockState state, final BlockGetter worldIn, fi public BlockState updateShape(final BlockState state, final Direction facing, final BlockState facingState, final LevelAccessor world, final BlockPos currentPos, final BlockPos facingPos) { - if (state.getValue(BlockStateProperties.WATERLOGGED)) world.getLiquidTicks().scheduleTick(currentPos, + if (state.getValue(BlockStateProperties.WATERLOGGED)) world.scheduleTick(currentPos, Fluids.WATER, Fluids.WATER.getTickDelay(world)); return super.updateShape(state, facing, facingState, world, currentPos, facingPos); } diff --git a/src/main/java/pokecube/adventures/blocks/statue/StatueEntity.java b/src/main/java/pokecube/adventures/blocks/statue/StatueEntity.java index dc9b3777f6..25f4d30c30 100644 --- a/src/main/java/pokecube/adventures/blocks/statue/StatueEntity.java +++ b/src/main/java/pokecube/adventures/blocks/statue/StatueEntity.java @@ -92,7 +92,7 @@ public void checkMob() public ClientboundBlockEntityDataPacket getUpdatePacket() { this.checkMob(); - return new ClientboundBlockEntityDataPacket(this.worldPosition, 6, this.getUpdateTag()); + return ClientboundBlockEntityDataPacket.create(this); } @Override diff --git a/src/main/java/pokecube/adventures/capabilities/utils/GuiOpenAction.java b/src/main/java/pokecube/adventures/capabilities/utils/GuiOpenAction.java index e6dbe21cad..10597359f8 100644 --- a/src/main/java/pokecube/adventures/capabilities/utils/GuiOpenAction.java +++ b/src/main/java/pokecube/adventures/capabilities/utils/GuiOpenAction.java @@ -5,7 +5,7 @@ import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.SimpleMenuProvider; import net.minecraft.world.entity.Entity; -import net.minecraftforge.fmllegacy.network.NetworkHooks; +import net.minecraftforge.network.NetworkHooks; import pokecube.adventures.capabilities.CapabilityHasPokemobs.IHasPokemobs; import pokecube.adventures.capabilities.TrainerCaps; import pokecube.adventures.inventory.trainer.ContainerTrainer; diff --git a/src/main/java/pokecube/adventures/entity/trainer/TrainerNpc.java b/src/main/java/pokecube/adventures/entity/trainer/TrainerNpc.java index 8ea1bb763a..2a2303f3d9 100644 --- a/src/main/java/pokecube/adventures/entity/trainer/TrainerNpc.java +++ b/src/main/java/pokecube/adventures/entity/trainer/TrainerNpc.java @@ -16,7 +16,7 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.trading.MerchantOffer; import net.minecraft.world.level.Level; -import net.minecraftforge.fmllegacy.common.registry.IEntityAdditionalSpawnData; +import net.minecraftforge.entity.IEntityAdditionalSpawnData; import pokecube.adventures.PokecubeAdv; import pokecube.adventures.capabilities.CapabilityHasPokemobs.IHasPokemobs; import pokecube.adventures.capabilities.CapabilityNPCAIStates.IHasNPCAIStates; diff --git a/src/main/java/pokecube/adventures/events/TrainerEventHandler.java b/src/main/java/pokecube/adventures/events/TrainerEventHandler.java index 710d2b7d26..256b75c93f 100644 --- a/src/main/java/pokecube/adventures/events/TrainerEventHandler.java +++ b/src/main/java/pokecube/adventures/events/TrainerEventHandler.java @@ -15,13 +15,14 @@ import net.minecraft.world.InteractionResult; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.Entity.RemovalReason; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.MobSpawnType; -import net.minecraft.world.entity.Entity.RemovalReason; import net.minecraft.world.entity.ai.Brain; import net.minecraft.world.entity.ai.gossip.GossipType; import net.minecraft.world.entity.ai.memory.MemoryModuleType; +import net.minecraft.world.entity.ai.memory.NearestVisibleLivingEntities; import net.minecraft.world.entity.npc.Npc; import net.minecraft.world.entity.npc.Villager; import net.minecraft.world.entity.player.Player; @@ -37,7 +38,7 @@ import net.minecraftforge.event.entity.living.LivingHurtEvent; import net.minecraftforge.event.entity.player.PlayerEvent.StartTracking; import net.minecraftforge.event.entity.player.PlayerInteractEvent; -import net.minecraftforge.fmlserverevents.FMLServerStartedEvent; +import net.minecraftforge.event.server.ServerStartedEvent; import pokecube.adventures.Config; import pokecube.adventures.PokecubeAdv; import pokecube.adventures.ai.brain.MemoryTypes; @@ -277,10 +278,10 @@ public static void onLivingHurt(final LivingHurtEvent evt) { if (messages != null) { - messages.sendMessage(MessageState.HURT, evt.getSource().getEntity(), evt.getEntity() - .getDisplayName(), evt.getSource().getEntity().getDisplayName()); - messages.doAction(MessageState.HURT, new ActionContext((LivingEntity) evt.getSource().getEntity(), - evt.getEntityLiving(), evt.getSource())); + messages.sendMessage(MessageState.HURT, evt.getSource().getEntity(), evt.getEntity().getDisplayName(), + evt.getSource().getEntity().getDisplayName()); + messages.doAction(MessageState.HURT, new ActionContext((LivingEntity) evt.getSource().getEntity(), evt + .getEntityLiving(), evt.getSource())); } if (pokemobHolder != null && pokemobHolder.getTarget() == null) pokemobHolder.onSetTarget((LivingEntity) evt .getSource().getEntity()); @@ -311,17 +312,12 @@ public static void onLivingDeath(final LivingDeathEvent event) if (repGain != 0 && mob.getBrain().hasMemoryValue(MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES)) { final GossipType type = repGain > 0 ? GossipType.MINOR_POSITIVE : GossipType.MINOR_NEGATIVE; - final Optional> optional = mob.getBrain().getMemory(MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES); + final Optional optional = mob.getBrain().getMemory( + MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES); if (optional.isPresent()) { - final List mobs = optional.get(); - mobs.stream().filter((gossipTarget) -> - { - // TODO use reputation tracking later instead, once - // things support adding different types beyond the - // hardcoded villager system! - return gossipTarget instanceof Villager; - }).forEach((gossipTarget) -> + final Iterable mobs = optional.get().findAll(seen -> seen instanceof Villager); + mobs.forEach((gossipTarget) -> { final Villager villager = (Villager) gossipTarget; villager.getGossips().add(murderer.getUUID(), type, repGain); @@ -362,8 +358,8 @@ public static void onNpcTick(final LivingUpdateEvent event) { final LivingEntity npc = event.getEntityLiving(); final Brain brain = npc.getBrain(); - if (!brain.hasMemoryValue(MemoryTypes.BATTLETARGET) && brain.isActive(Activities.BATTLE)) brain.setActiveActivityIfPossible( - Activity.IDLE); + if (!brain.hasMemoryValue(MemoryTypes.BATTLETARGET) && brain.isActive(Activities.BATTLE)) brain + .setActiveActivityIfPossible(Activity.IDLE); pokemobHolder.onTick(); } } @@ -436,8 +432,8 @@ public static void processInteract(final PlayerInteractEvent evt, final Entity t // player.sendMessage(new StringTextComponent(" (" + rep + ")"), null); // } - if (evt.getItemStack().getItem() instanceof Linker && Linker.interact((ServerPlayer) evt.getPlayer(), - target, evt.getItemStack())) + if (evt.getItemStack().getItem() instanceof Linker && Linker.interact((ServerPlayer) evt.getPlayer(), target, + evt.getItemStack())) { evt.setCanceled(true); evt.setCancellationResult(InteractionResult.SUCCESS); @@ -496,7 +492,7 @@ public static void onPostDatabaseLoad(final InitDatabase.Post event) DBLoader.load(); } - public static void onPostServerStart(final FMLServerStartedEvent event) + public static void onPostServerStart(final ServerStartedEvent event) { TypeTrainer.postInitTrainers(); } diff --git a/src/main/java/pokecube/adventures/events/TrainerSpawnHandler.java b/src/main/java/pokecube/adventures/events/TrainerSpawnHandler.java index 350bb49b28..f443a264f3 100644 --- a/src/main/java/pokecube/adventures/events/TrainerSpawnHandler.java +++ b/src/main/java/pokecube/adventures/events/TrainerSpawnHandler.java @@ -17,10 +17,10 @@ import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.InteractionHand; import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.Entity.RemovalReason; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.MobSpawnType; import net.minecraft.world.entity.SpawnGroupData; -import net.minecraft.world.entity.Entity.RemovalReason; import net.minecraft.world.entity.SpawnPlacements.Type; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.Item; diff --git a/src/main/java/pokecube/adventures/init/ClientSetupHandler.java b/src/main/java/pokecube/adventures/init/ClientSetupHandler.java index 0569dee2a1..18543ba432 100644 --- a/src/main/java/pokecube/adventures/init/ClientSetupHandler.java +++ b/src/main/java/pokecube/adventures/init/ClientSetupHandler.java @@ -20,14 +20,14 @@ import net.minecraft.world.phys.EntityHitResult; import net.minecraft.world.phys.HitResult; import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.client.event.InputEvent; +import net.minecraftforge.client.ClientRegistry; import net.minecraftforge.client.event.EntityRenderersEvent.RegisterRenderers; +import net.minecraftforge.client.event.InputEvent; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.player.ItemTooltipEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; -import net.minecraftforge.fmlclient.registry.ClientRegistry; import pokecube.adventures.Config; import pokecube.adventures.PokecubeAdv; import pokecube.adventures.blocks.genetics.helper.ClonerHelper; diff --git a/src/main/java/pokecube/adventures/network/PacketBag.java b/src/main/java/pokecube/adventures/network/PacketBag.java index 7277584859..7bbfb60b4b 100644 --- a/src/main/java/pokecube/adventures/network/PacketBag.java +++ b/src/main/java/pokecube/adventures/network/PacketBag.java @@ -7,7 +7,7 @@ import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.SimpleMenuProvider; import net.minecraft.world.entity.player.Player; -import net.minecraftforge.fmllegacy.network.NetworkHooks; +import net.minecraftforge.network.NetworkHooks; import pokecube.adventures.items.bag.BagContainer; import pokecube.adventures.items.bag.BagInventory; import pokecube.adventures.items.bag.BagManager; diff --git a/src/main/java/pokecube/adventures/proxy/CommonProxy.java b/src/main/java/pokecube/adventures/proxy/CommonProxy.java index f2138c1536..6d716710f5 100644 --- a/src/main/java/pokecube/adventures/proxy/CommonProxy.java +++ b/src/main/java/pokecube/adventures/proxy/CommonProxy.java @@ -1,6 +1,7 @@ package pokecube.adventures.proxy; import net.minecraft.core.Direction; +import net.minecraft.server.MinecraftServer; import net.minecraft.world.item.ItemStack; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.ICapabilityProvider; @@ -53,4 +54,18 @@ public Wearable getWearable() { return new Wearable(); } + + private MinecraftServer server; + + @Override + public void setServer(final MinecraftServer server) + { + this.server = server; + } + + @Override + public MinecraftServer getServer() + { + return this.server; + } } diff --git a/src/main/java/pokecube/adventures/utils/RecipePokeAdv.java b/src/main/java/pokecube/adventures/utils/RecipePokeAdv.java index 6ce66ec6f2..bc9695b76f 100644 --- a/src/main/java/pokecube/adventures/utils/RecipePokeAdv.java +++ b/src/main/java/pokecube/adventures/utils/RecipePokeAdv.java @@ -7,9 +7,9 @@ import net.minecraft.world.item.crafting.Recipe; import net.minecraft.world.item.crafting.RecipeSerializer; import net.minecraft.world.item.crafting.SimpleRecipeSerializer; -import net.minecraftforge.fmllegacy.RegistryObject; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; +import net.minecraftforge.registries.RegistryObject; import pokecube.adventures.PokecubeAdv; import pokecube.adventures.blocks.genetics.helper.recipe.RecipeClone; import pokecube.adventures.blocks.genetics.helper.recipe.RecipeExtract; diff --git a/src/main/java/pokecube/compat/cct/Impl.java b/src/main/java/pokecube/compat/cct/Impl.java index 51589c275d..f5b9b6404c 100644 --- a/src/main/java/pokecube/compat/cct/Impl.java +++ b/src/main/java/pokecube/compat/cct/Impl.java @@ -3,10 +3,10 @@ import dan200.computercraft.api.ComputerCraftAPI; import dan200.computercraft.api.peripheral.IPeripheral; import dan200.computercraft.api.peripheral.IPeripheralProvider; -import net.minecraft.world.level.block.entity.BlockEntity; -import net.minecraft.core.Direction; import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraftforge.common.util.LazyOptional; import pokecube.adventures.blocks.commander.CommanderTile; import pokecube.adventures.blocks.genetics.extractor.ExtractorTile; diff --git a/src/main/java/pokecube/compat/cct/modules/Extractor.java b/src/main/java/pokecube/compat/cct/modules/Extractor.java index cb2fce5269..4e60bd4b60 100644 --- a/src/main/java/pokecube/compat/cct/modules/Extractor.java +++ b/src/main/java/pokecube/compat/cct/modules/Extractor.java @@ -6,13 +6,13 @@ import com.google.common.collect.Lists; import dan200.computercraft.api.lua.LuaException; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.Items; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.ListTag; import net.minecraft.nbt.StringTag; -import net.minecraft.resources.ResourceLocation; import net.minecraft.network.chat.TextComponent; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.IItemHandlerModifiable; import pokecube.adventures.blocks.genetics.extractor.ExtractorTile; diff --git a/src/main/java/pokecube/compat/cct/modules/Splicer.java b/src/main/java/pokecube/compat/cct/modules/Splicer.java index bf328ac99c..484ce4db52 100644 --- a/src/main/java/pokecube/compat/cct/modules/Splicer.java +++ b/src/main/java/pokecube/compat/cct/modules/Splicer.java @@ -6,13 +6,13 @@ import com.google.common.collect.Lists; import dan200.computercraft.api.lua.LuaException; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.Items; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.ListTag; import net.minecraft.nbt.StringTag; -import net.minecraft.resources.ResourceLocation; import net.minecraft.network.chat.TextComponent; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.IItemHandlerModifiable; import pokecube.adventures.blocks.genetics.helper.ClonerHelper; diff --git a/src/main/java/pokecube/compat/curios/Impl.java b/src/main/java/pokecube/compat/curios/Impl.java index fb6502743e..6b36a3d679 100644 --- a/src/main/java/pokecube/compat/curios/Impl.java +++ b/src/main/java/pokecube/compat/curios/Impl.java @@ -5,11 +5,11 @@ import com.google.common.collect.BiMap; import com.google.common.collect.HashBiMap; +import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.context.UseOnContext; -import net.minecraft.resources.ResourceLocation; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.InterModComms; import net.minecraftforge.fml.event.lifecycle.InterModEnqueueEvent; diff --git a/src/main/java/pokecube/compat/jei/Compat.java b/src/main/java/pokecube/compat/jei/Compat.java index f4ad819543..80d51c8ed9 100644 --- a/src/main/java/pokecube/compat/jei/Compat.java +++ b/src/main/java/pokecube/compat/jei/Compat.java @@ -12,8 +12,8 @@ import mezz.jei.api.registration.IRecipeCategoryRegistration; import mezz.jei.api.registration.IRecipeRegistration; import mezz.jei.api.registration.ISubtypeRegistration; -import net.minecraft.world.item.ItemStack; import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.ItemStack; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.fml.DistExecutor; import pokecube.adventures.PokecubeAdv; diff --git a/src/main/java/pokecube/compat/jei/categories/cloner/Category.java b/src/main/java/pokecube/compat/jei/categories/cloner/Category.java index 454ef53660..754acd0271 100644 --- a/src/main/java/pokecube/compat/jei/categories/cloner/Category.java +++ b/src/main/java/pokecube/compat/jei/categories/cloner/Category.java @@ -12,11 +12,11 @@ import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.recipe.category.IRecipeCategory; import net.minecraft.client.resources.language.I18n; -import net.minecraft.world.item.ItemStack; -import net.minecraft.resources.ResourceLocation; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.TextComponent; import net.minecraft.network.chat.TranslatableComponent; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.ItemStack; import pokecube.adventures.PokecubeAdv; import pokecube.compat.jei.ingredients.Pokemob; diff --git a/src/main/java/pokecube/compat/jei/categories/evolution/Category.java b/src/main/java/pokecube/compat/jei/categories/evolution/Category.java index 022d9cbf5a..7c3b8b2a0b 100644 --- a/src/main/java/pokecube/compat/jei/categories/evolution/Category.java +++ b/src/main/java/pokecube/compat/jei/categories/evolution/Category.java @@ -13,10 +13,10 @@ import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.recipe.category.IRecipeCategory; import net.minecraft.client.resources.language.I18n; -import net.minecraft.world.item.ItemStack; -import net.minecraft.resources.ResourceLocation; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.TextComponent; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.ItemStack; import pokecube.adventures.PokecubeAdv; import pokecube.compat.jei.ingredients.Pokemob; import pokecube.core.PokecubeItems; diff --git a/src/main/java/pokecube/compat/jei/categories/interaction/Category.java b/src/main/java/pokecube/compat/jei/categories/interaction/Category.java index 8d9acb742d..fd7c038e93 100644 --- a/src/main/java/pokecube/compat/jei/categories/interaction/Category.java +++ b/src/main/java/pokecube/compat/jei/categories/interaction/Category.java @@ -13,11 +13,11 @@ import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.recipe.category.IRecipeCategory; import net.minecraft.client.resources.language.I18n; -import net.minecraft.world.item.ItemStack; -import net.minecraft.resources.ResourceLocation; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.TextComponent; import net.minecraft.network.chat.TranslatableComponent; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.ItemStack; import pokecube.adventures.PokecubeAdv; import pokecube.compat.jei.ingredients.Pokemob; import pokecube.core.PokecubeCore; diff --git a/src/main/java/pokecube/compat/jei/categories/interaction/InteractRecipe.java b/src/main/java/pokecube/compat/jei/categories/interaction/InteractRecipe.java index f5d95ae1eb..92b219af4f 100644 --- a/src/main/java/pokecube/compat/jei/categories/interaction/InteractRecipe.java +++ b/src/main/java/pokecube/compat/jei/categories/interaction/InteractRecipe.java @@ -1,7 +1,7 @@ package pokecube.compat.jei.categories.interaction; -import net.minecraft.world.item.ItemStack; import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.ItemStack; import pokecube.compat.jei.ingredients.Pokemob; import pokecube.core.database.PokedexEntry; import pokecube.core.database.PokedexEntry.InteractionLogic.Interaction; diff --git a/src/main/java/pokecube/compat/jei/categories/move/Category.java b/src/main/java/pokecube/compat/jei/categories/move/Category.java index 4385d57c02..45b5d18ced 100644 --- a/src/main/java/pokecube/compat/jei/categories/move/Category.java +++ b/src/main/java/pokecube/compat/jei/categories/move/Category.java @@ -13,9 +13,9 @@ import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.recipe.category.IRecipeCategory; import net.minecraft.client.resources.language.I18n; -import net.minecraft.resources.ResourceLocation; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.TextComponent; +import net.minecraft.resources.ResourceLocation; import pokecube.adventures.PokecubeAdv; import pokecube.core.moves.MovesUtils; import pokecube.core.recipes.MoveRecipes.MoveRecipe; diff --git a/src/main/java/pokecube/compat/jei/ingredients/Pokemob.java b/src/main/java/pokecube/compat/jei/ingredients/Pokemob.java index 474fcfa4ed..9bf959c559 100644 --- a/src/main/java/pokecube/compat/jei/ingredients/Pokemob.java +++ b/src/main/java/pokecube/compat/jei/ingredients/Pokemob.java @@ -13,10 +13,10 @@ import mezz.jei.api.ingredients.IIngredientRenderer; import mezz.jei.api.ingredients.IIngredientType; import mezz.jei.api.ingredients.subtypes.UidContext; -import net.minecraft.world.item.TooltipFlag; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.TextComponent; import net.minecraft.network.chat.TranslatableComponent; +import net.minecraft.world.item.TooltipFlag; import pokecube.core.client.EventsHandlerClient; import pokecube.core.database.Database; import pokecube.core.database.PokedexEntry; diff --git a/src/main/java/pokecube/compat/minecolonies/Impl.java b/src/main/java/pokecube/compat/minecolonies/Impl.java index 009e483db7..ad7d86107b 100644 --- a/src/main/java/pokecube/compat/minecolonies/Impl.java +++ b/src/main/java/pokecube/compat/minecolonies/Impl.java @@ -9,9 +9,9 @@ import com.minecolonies.api.colony.buildings.IBuilding; import com.minecolonies.api.entity.citizen.AbstractEntityCitizen; -import net.minecraft.world.level.LevelAccessor; -import net.minecraft.world.level.Level; import net.minecraft.server.level.ServerChunkCache; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.LevelAccessor; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.eventbus.api.Event.Result; import pokecube.adventures.capabilities.utils.TypeTrainer; diff --git a/src/main/java/pokecube/compat/thutessentials/Impl.java b/src/main/java/pokecube/compat/thutessentials/Impl.java index 43b8735a8a..c1a3a7c741 100644 --- a/src/main/java/pokecube/compat/thutessentials/Impl.java +++ b/src/main/java/pokecube/compat/thutessentials/Impl.java @@ -4,10 +4,10 @@ import java.util.List; import java.util.UUID; -import net.minecraft.world.entity.Entity; import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.level.chunk.LevelChunk; import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.level.chunk.LevelChunk; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.event.entity.player.PlayerEvent.PlayerLoggedOutEvent; diff --git a/src/main/java/pokecube/core/PokecubeCore.java b/src/main/java/pokecube/core/PokecubeCore.java index dedfc5c541..79cc8317a5 100644 --- a/src/main/java/pokecube/core/PokecubeCore.java +++ b/src/main/java/pokecube/core/PokecubeCore.java @@ -321,7 +321,7 @@ public static void registerTileEntities(final RegistryEvent.Register this.path + if (this.canMoveDirectly(vec3d, vec3d1)) if (i - 1 > this.path .getNextNodeIndex()) this.path.setNextNodeIndex(i - 1); } super.followThePath(); diff --git a/src/main/java/pokecube/core/ai/pathing/WalkPathNavi.java b/src/main/java/pokecube/core/ai/pathing/WalkPathNavi.java index 221052c4fe..34931343d7 100644 --- a/src/main/java/pokecube/core/ai/pathing/WalkPathNavi.java +++ b/src/main/java/pokecube/core/ai/pathing/WalkPathNavi.java @@ -3,8 +3,8 @@ import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.ai.navigation.GroundPathNavigation; import net.minecraft.world.level.Level; -import net.minecraft.world.level.pathfinder.PathFinder; import net.minecraft.world.level.pathfinder.AmphibiousNodeEvaluator; +import net.minecraft.world.level.pathfinder.PathFinder; public class WalkPathNavi extends GroundPathNavigation { diff --git a/src/main/java/pokecube/core/ai/poi/PointsOfInterest.java b/src/main/java/pokecube/core/ai/poi/PointsOfInterest.java index cead3386d5..c2f6662763 100644 --- a/src/main/java/pokecube/core/ai/poi/PointsOfInterest.java +++ b/src/main/java/pokecube/core/ai/poi/PointsOfInterest.java @@ -3,9 +3,9 @@ import com.google.common.collect.Sets; import net.minecraft.world.entity.ai.village.poi.PoiType; -import net.minecraftforge.fmllegacy.RegistryObject; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; +import net.minecraftforge.registries.RegistryObject; import pokecube.core.PokecubeCore; import pokecube.core.PokecubeItems; diff --git a/src/main/java/pokecube/core/ai/tasks/ants/sensors/EggSensor.java b/src/main/java/pokecube/core/ai/tasks/ants/sensors/EggSensor.java index b5458dc4ce..ccc3fee93c 100644 --- a/src/main/java/pokecube/core/ai/tasks/ants/sensors/EggSensor.java +++ b/src/main/java/pokecube/core/ai/tasks/ants/sensors/EggSensor.java @@ -48,7 +48,8 @@ protected void doTick(final ServerLevel worldIn, final Mob entityIn) if (!eggRoom.isPresent()) return; final List eggs = Lists.newArrayList(); - final List mobs = brain.getMemory(MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES).get(); + final Iterable mobs = brain.getMemory(MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES).get() + .findAll(e -> true); mobs.forEach(e -> this.addIfEgg(e, eggs)); eggs.removeIf(egg -> EggSensor.isInEggRoomOrCarried(tile, hab, egg)); if (!eggs.isEmpty()) diff --git a/src/main/java/pokecube/core/ai/tasks/ants/tasks/work/Build.java b/src/main/java/pokecube/core/ai/tasks/ants/tasks/work/Build.java index 0eeacc531b..b7a2f9eeeb 100644 --- a/src/main/java/pokecube/core/ai/tasks/ants/tasks/work/Build.java +++ b/src/main/java/pokecube/core/ai/tasks/ants/tasks/work/Build.java @@ -13,6 +13,7 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.levelgen.LegacyRandomSource; import net.minecraft.world.level.levelgen.WorldgenRandom; import net.minecraftforge.items.IItemHandlerModifiable; import pokecube.core.PokecubeCore; @@ -62,7 +63,7 @@ default boolean validWall(final Node node, final ServerLevel world, final BlockP final int dz = pos.getZ() - mid.getZ(); boolean light = false; - final WorldgenRandom rng = new WorldgenRandom(); + final WorldgenRandom rng = new WorldgenRandom(new LegacyRandomSource(0L)); rng.setDecorationSeed(world.getSeed(), pos.getX(), pos.getZ()); final boolean tryLight = rng.nextDouble() > 0.9 || dx == 0 && dz == 0; if (tryLight) @@ -134,7 +135,7 @@ default boolean place(final Node node, final ServerLevel world, BlockState state final int dz = pos.getZ() - mid.getZ(); boolean light = false; - final WorldgenRandom rng = new WorldgenRandom(); + final WorldgenRandom rng = new WorldgenRandom(new LegacyRandomSource(0L)); rng.setDecorationSeed(world.getSeed(), pos.getX(), pos.getZ()); final boolean tryLight = rng.nextDouble() > 0.9 || dx == 0 && dz == 0; if (tryLight) diff --git a/src/main/java/pokecube/core/ai/tasks/ants/tasks/work/Guard.java b/src/main/java/pokecube/core/ai/tasks/ants/tasks/work/Guard.java index c036c6b6a9..e9ee8260d1 100644 --- a/src/main/java/pokecube/core/ai/tasks/ants/tasks/work/Guard.java +++ b/src/main/java/pokecube/core/ai/tasks/ants/tasks/work/Guard.java @@ -72,7 +72,8 @@ protected boolean checkGuard() // Disabled via the boolean config. if (!PokecubeCore.getConfig().guardModeEnabled) return false; - // TODO find out why this happens, the needed memories should have dealt with it... + // TODO find out why this happens, the needed memories should have dealt + // with it... if (!this.entity.getBrain().hasMemoryValue(MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES)) return false; // Select either owner or home position as the centre of the check, @@ -82,11 +83,12 @@ protected boolean checkGuard() centre.set(this.pokemob.getOwner()); final List ret = new ArrayList<>(); - final List pokemobs = this.entity.getBrain().getMemory(MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES).get(); + final Iterable pokemobs = this.entity.getBrain().getMemory( + MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES).get().findAll(e -> this.validGuardTarget.test(e) && e + .distanceTo(this.entity) <= Guard.ANTGUARDDIST); // Only allow valid guard targets. for (final LivingEntity o : pokemobs) - if (this.validGuardTarget.test(o)) ret.add(o); - ret.removeIf(e -> e.distanceTo(this.entity) > Guard.ANTGUARDDIST); + ret.add(o); if (ret.isEmpty()) return false; // This is already sorted by distance! diff --git a/src/main/java/pokecube/core/ai/tasks/combat/management/CallForHelpTask.java b/src/main/java/pokecube/core/ai/tasks/combat/management/CallForHelpTask.java index 59230515de..99c6424c70 100644 --- a/src/main/java/pokecube/core/ai/tasks/combat/management/CallForHelpTask.java +++ b/src/main/java/pokecube/core/ai/tasks/combat/management/CallForHelpTask.java @@ -44,13 +44,13 @@ public void reset() protected boolean checkForHelp(final LivingEntity from) { // No need to get help against null - if (from == null || !this.entity.getBrain().hasMemoryValue(MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES)) return false; + if (from == null || !this.entity.getBrain().hasMemoryValue(MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES)) + return false; // Not social. doesn't do this. if (!this.pokemob.getPokedexEntry().isSocial) return false; final List ret = new ArrayList<>(); - final List pokemobs = this.entity.getBrain().getMemory(MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES).get(); // We check for whether it is the same species and, has the same owner // (including null) or is on the team. @@ -67,10 +67,12 @@ protected boolean checkForHelp(final LivingEntity from) if (TeamManager.sameTeam(input, this.entity)) return true; return false; }; + // Only allow valid guard targets. + final Iterable pokemobs = this.entity.getBrain().getMemory( + MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES).get().findAll(relationCheck); pokemobs.forEach(o -> { - // Only allow valid guard targets. if (relationCheck.test(o)) ret.add(o); }); @@ -100,7 +102,8 @@ public void run() public boolean shouldRun() { this.target = BrainUtils.getAttackTarget(this.entity); - return this.target != null && this.entity.getBrain().hasMemoryValue(MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES); + return this.target != null && this.entity.getBrain().hasMemoryValue( + MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES); } } diff --git a/src/main/java/pokecube/core/ai/tasks/combat/management/FindTargetsTask.java b/src/main/java/pokecube/core/ai/tasks/combat/management/FindTargetsTask.java index f7ca5b3498..e685623baf 100644 --- a/src/main/java/pokecube/core/ai/tasks/combat/management/FindTargetsTask.java +++ b/src/main/java/pokecube/core/ai/tasks/combat/management/FindTargetsTask.java @@ -1,6 +1,5 @@ package pokecube.core.ai.tasks.combat.management; -import java.util.ArrayList; import java.util.List; import java.util.Optional; import java.util.UUID; @@ -185,17 +184,14 @@ protected boolean checkGuard() this.pokemob.getHome()); else centre.set(this.pokemob.getOwner()); - final List ret = new ArrayList<>(); - final List pokemobs = this.entity.getBrain().getMemory(MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES) - .get(); // Only allow valid guard targets. - for (final LivingEntity o : pokemobs) - if (this.validGuardTarget.test(o)) ret.add(o); - ret.removeIf(e -> e.distanceTo(this.entity) > PokecubeCore.getConfig().guardSearchDistance); - if (ret.isEmpty()) return false; + final Optional pokemobs = this.entity.getBrain().getMemory( + MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES).get().findClosest(e -> this.validGuardTarget.test(e) && e + .distanceTo(this.entity) <= PokecubeCore.getConfig().guardSearchDistance); + if (pokemobs.isEmpty()) return false; // This is already sorted by distance! - final LivingEntity newtarget = ret.get(0); + final LivingEntity newtarget = pokemobs.get(); // Agro the target. if (newtarget != null) { @@ -226,19 +222,16 @@ protected boolean checkOwner() // Disable via rate out of bounds, or not correct time in the rate. if (rate <= 0 || this.entity.tickCount % rate != 0) return false; - final List list = new ArrayList<>(); - final List pokemobs = this.entity.getBrain().getMemory(MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES) - .get(); - list.addAll(pokemobs); - list.removeIf(e -> e.distanceTo(this.entity) > PokecubeCore.getConfig().guardSearchDistance - && AITools.validTargets.test(e)); - if (list.isEmpty()) return false; + final Iterable pokemobs = this.entity.getBrain().getMemory( + MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES).get().findAll(e -> AITools.validTargets.test(e) && e + .distanceTo(this.entity) <= PokecubeCore.getConfig().guardSearchDistance); + if (!pokemobs.iterator().hasNext()) return false; final Entity old = BrainUtils.getAttackTarget(this.entity); final IOwnable oldOwnable = OwnableCaps.getOwnable(old); final Entity oldOwner = oldOwnable != null ? oldOwnable.getOwner(this.world) : null; - for (final LivingEntity entity : list) + for (final LivingEntity entity : pokemobs) { if (oldOwner != null && entity == oldOwner) continue; final LivingEntity targ = BrainUtils.getAttackTarget(entity); @@ -275,14 +268,11 @@ protected void checkSwitchedMob() // Give some time to look for a new pokemob if (this.switchTargetTimer++ < 2 * FindTargetsTask.DEAGROTIMER) { - final List list = new ArrayList<>(); - final List pokemobs = this.entity.getBrain().getMemory( - MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES).get(); - list.addAll(pokemobs); - list.removeIf(e -> e.distanceTo(this.entity) > PokecubeCore.getConfig().guardSearchDistance - && AITools.validTargets.test(e)); - - for (final LivingEntity entity : list) + final Iterable pokemobs = this.entity.getBrain().getMemory( + MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES).get().findAll(e -> AITools.validTargets.test( + e) && e.distanceTo(this.entity) <= PokecubeCore.getConfig().guardSearchDistance); + + for (final LivingEntity entity : pokemobs) { final LivingEntity owner = OwnableCaps.getOwner(entity); if (owner == this.targetOwner) diff --git a/src/main/java/pokecube/core/ai/tasks/idle/GuardEggTask.java b/src/main/java/pokecube/core/ai/tasks/idle/GuardEggTask.java index b2da8bc1d8..43b28ed907 100644 --- a/src/main/java/pokecube/core/ai/tasks/idle/GuardEggTask.java +++ b/src/main/java/pokecube/core/ai/tasks/idle/GuardEggTask.java @@ -1,7 +1,6 @@ package pokecube.core.ai.tasks.idle; -import java.util.ArrayList; -import java.util.List; +import java.util.Optional; import java.util.function.Predicate; import net.minecraft.world.entity.LivingEntity; @@ -72,17 +71,17 @@ public boolean shouldRun() if (this.pokemob.getSexe() == IPokemob.MALE) return false; this.eggSearchCooldown = GuardEggTask.SEARCHCOOLDOWN; - final List list = new ArrayList<>(); - final List pokemobs = this.entity.getBrain().getMemory(MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES).get(); - list.addAll(pokemobs); final Predicate isEgg = input -> input instanceof EntityPokemobEgg && GuardEggTask.this.entity - .getUUID().equals(((EntityPokemobEgg) input).getMotherId()) && input.isAlive(); - list.removeIf(e -> !isEgg.test(e)); - list.removeIf(e -> e.distanceTo(this.entity) > PokecubeCore.getConfig().guardSearchDistance); - if (list.isEmpty()) return false; + .getUUID().equals(((EntityPokemobEgg) input).getMotherId()) && input.isAlive() && input.distanceTo( + this.entity) <= PokecubeCore.getConfig().guardSearchDistance; + + final Optional pokemobs = this.entity.getBrain().getMemory( + MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES).get().findClosest(isEgg); + + if (pokemobs.isEmpty()) return false; // Select first egg found to guard, remove target, set not angry - this.egg = (EntityPokemobEgg) list.get(0); + this.egg = (EntityPokemobEgg) pokemobs.get(); this.egg.mother = this.pokemob; BrainUtils.deagro(this.pokemob.getEntity()); diff --git a/src/main/java/pokecube/core/ai/tasks/idle/HungerTask.java b/src/main/java/pokecube/core/ai/tasks/idle/HungerTask.java index 4640f095cc..12d5c0e4f1 100644 --- a/src/main/java/pokecube/core/ai/tasks/idle/HungerTask.java +++ b/src/main/java/pokecube/core/ai/tasks/idle/HungerTask.java @@ -135,8 +135,8 @@ protected boolean checkBait() { final AABB bb = this.v.set(this.entity).addTo(0, this.entity.getEyeHeight(), 0).getAABB().inflate( PokecubeCore.getConfig().fishHookBaitRange); - final List hooks = this.entity.getCommandSenderWorld().getEntitiesOfClass( - FishingHook.class, bb); + final List hooks = this.entity.getCommandSenderWorld().getEntitiesOfClass(FishingHook.class, + bb); if (!hooks.isEmpty()) { final double moveSpeed = 1.5; @@ -174,8 +174,8 @@ protected boolean checkHunt() if (this.pokemob.getPokedexEntry().hasPrey() && this.entity.getBrain().hasMemoryValue( MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES)) { - final List targets = this.entity.getBrain().getMemory( - MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES).get(); + final Iterable targets = this.entity.getBrain().getMemory( + MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES).get().findAll(e -> true); for (final LivingEntity mob : targets) { final IPokemob other = CapabilityPokemob.getPokemobFor(mob); @@ -439,8 +439,8 @@ public void tick() else if (this.lastMessageTick2 < this.entity.getCommandSenderWorld().getGameTime()) { this.lastMessageTick2 = (int) (this.entity.getCommandSenderWorld().getGameTime() + 100); - this.pokemob.displayMessageToOwner(new TranslatableComponent("pokemob.hungry.dead", - this.pokemob.getDisplayName())); + this.pokemob.displayMessageToOwner(new TranslatableComponent("pokemob.hungry.dead", this.pokemob + .getDisplayName())); } } } diff --git a/src/main/java/pokecube/core/ai/tasks/misc/LookAtMob.java b/src/main/java/pokecube/core/ai/tasks/misc/LookAtMob.java index ec607c8336..4677e63fb2 100644 --- a/src/main/java/pokecube/core/ai/tasks/misc/LookAtMob.java +++ b/src/main/java/pokecube/core/ai/tasks/misc/LookAtMob.java @@ -1,5 +1,6 @@ package pokecube.core.ai.tasks.misc; +import java.util.Optional; import java.util.function.Predicate; import com.google.common.collect.ImmutableMap; @@ -53,22 +54,21 @@ protected boolean canTimeOut() @Override protected boolean checkExtraStartConditions(final ServerLevel worldIn, final LivingEntity owner) { - return owner.getBrain().getMemory(MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES).get().stream().anyMatch(this.matcher); + return owner.getBrain().getMemory(MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES).get().findClosest( + this.matcher).isPresent(); } @Override protected void start(final ServerLevel worldIn, final LivingEntity entityIn, final long gameTimeIn) { final Brain brain = entityIn.getBrain(); - brain.getMemory(MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES).ifPresent((list) -> + + final Optional found = brain.getMemory(MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES).get() + .findClosest(this.matcher.and(mob -> mob.distanceToSqr(entityIn) <= this.distance_squared)); + + found.ifPresent((mob) -> { - list.stream().filter(this.matcher).filter((mob) -> - { - return mob.distanceToSqr(entityIn) <= this.distance_squared; - }).findFirst().ifPresent((mob) -> - { - brain.setMemory(MemoryModuleType.LOOK_TARGET, new EntityTracker(mob, true)); - }); + brain.setMemory(MemoryModuleType.LOOK_TARGET, new EntityTracker(mob, true)); }); } } diff --git a/src/main/java/pokecube/core/blocks/healer/HealerBlock.java b/src/main/java/pokecube/core/blocks/healer/HealerBlock.java index cdea8a182a..552a84ee4e 100644 --- a/src/main/java/pokecube/core/blocks/healer/HealerBlock.java +++ b/src/main/java/pokecube/core/blocks/healer/HealerBlock.java @@ -140,7 +140,7 @@ public BlockState getStateForPlacement(final BlockPlaceContext context) public BlockState updateShape(final BlockState state, final Direction facing, final BlockState facingState, final LevelAccessor world, final BlockPos currentPos, final BlockPos facingPos) { - if (state.getValue(HealerBlock.WATERLOGGED)) world.getLiquidTicks().scheduleTick(currentPos, Fluids.WATER, Fluids.WATER.getTickDelay(world)); + if (state.getValue(HealerBlock.WATERLOGGED)) world.scheduleTick(currentPos, Fluids.WATER, Fluids.WATER.getTickDelay(world)); return super.updateShape(state, facing, facingState, world, currentPos, facingPos); } diff --git a/src/main/java/pokecube/core/blocks/maxspot/MaxBlock.java b/src/main/java/pokecube/core/blocks/maxspot/MaxBlock.java index 86b5edbc3e..fc1020f697 100644 --- a/src/main/java/pokecube/core/blocks/maxspot/MaxBlock.java +++ b/src/main/java/pokecube/core/blocks/maxspot/MaxBlock.java @@ -118,7 +118,7 @@ public BlockState getStateForPlacement(final BlockPlaceContext context) public BlockState updateShape(final BlockState state, final Direction facing, final BlockState facingState, final LevelAccessor world, final BlockPos currentPos, final BlockPos facingPos) { - if (state.getValue(MaxBlock.WATERLOGGED)) world.getLiquidTicks().scheduleTick(currentPos, Fluids.WATER, Fluids.WATER.getTickDelay(world)); + if (state.getValue(MaxBlock.WATERLOGGED)) world.scheduleTick(currentPos, Fluids.WATER, Fluids.WATER.getTickDelay(world)); return super.updateShape(state, facing, facingState, world, currentPos, facingPos); } diff --git a/src/main/java/pokecube/core/blocks/nests/NestTile.java b/src/main/java/pokecube/core/blocks/nests/NestTile.java index 8c8560ff4e..1581950621 100644 --- a/src/main/java/pokecube/core/blocks/nests/NestTile.java +++ b/src/main/java/pokecube/core/blocks/nests/NestTile.java @@ -21,10 +21,10 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.BlockHitResult; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fmllegacy.network.NetworkHooks; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.IItemHandlerModifiable; +import net.minecraftforge.network.NetworkHooks; import pokecube.core.PokecubeItems; import pokecube.core.blocks.InteractableTile; import pokecube.core.database.PokedexEntry; diff --git a/src/main/java/pokecube/core/blocks/pc/PCBlock.java b/src/main/java/pokecube/core/blocks/pc/PCBlock.java index 9985c2899a..8dd4c989e5 100644 --- a/src/main/java/pokecube/core/blocks/pc/PCBlock.java +++ b/src/main/java/pokecube/core/blocks/pc/PCBlock.java @@ -121,7 +121,7 @@ public BlockState getStateForPlacement(final BlockPlaceContext context) public BlockState updateShape(final BlockState state, final Direction facing, final BlockState facingState, final LevelAccessor world, final BlockPos currentPos, final BlockPos facingPos) { - if (state.getValue(PCBlock.WATERLOGGED)) world.getLiquidTicks().scheduleTick(currentPos, Fluids.WATER, Fluids.WATER.getTickDelay(world)); + if (state.getValue(PCBlock.WATERLOGGED)) world.scheduleTick(currentPos, Fluids.WATER, Fluids.WATER.getTickDelay(world)); return super.updateShape(state, facing, facingState, world, currentPos, facingPos); } diff --git a/src/main/java/pokecube/core/blocks/tms/TMBlock.java b/src/main/java/pokecube/core/blocks/tms/TMBlock.java index 9cc42e7f66..f1c0837a76 100644 --- a/src/main/java/pokecube/core/blocks/tms/TMBlock.java +++ b/src/main/java/pokecube/core/blocks/tms/TMBlock.java @@ -103,7 +103,7 @@ public BlockState getStateForPlacement(final BlockPlaceContext context) public BlockState updateShape(final BlockState state, final Direction facing, final BlockState facingState, final LevelAccessor world, final BlockPos currentPos, final BlockPos facingPos) { - if (state.getValue(TMBlock.WATERLOGGED)) world.getLiquidTicks().scheduleTick(currentPos, Fluids.WATER, + if (state.getValue(TMBlock.WATERLOGGED)) world.scheduleTick(currentPos, Fluids.WATER, Fluids.WATER.getTickDelay(world)); return super.updateShape(state, facing, facingState, world, currentPos, facingPos); diff --git a/src/main/java/pokecube/core/blocks/trade/TraderBlock.java b/src/main/java/pokecube/core/blocks/trade/TraderBlock.java index 3f67a00226..1a75f7de3d 100644 --- a/src/main/java/pokecube/core/blocks/trade/TraderBlock.java +++ b/src/main/java/pokecube/core/blocks/trade/TraderBlock.java @@ -106,7 +106,7 @@ public BlockState getStateForPlacement(final BlockPlaceContext context) public BlockState updateShape(final BlockState state, final Direction facing, final BlockState facingState, final LevelAccessor world, final BlockPos currentPos, final BlockPos facingPos) { - if (state.getValue(TraderBlock.WATERLOGGED)) world.getLiquidTicks().scheduleTick(currentPos, Fluids.WATER, Fluids.WATER.getTickDelay(world)); + if (state.getValue(TraderBlock.WATERLOGGED)) world.scheduleTick(currentPos, Fluids.WATER, Fluids.WATER.getTickDelay(world)); return super.updateShape(state, facing, facingState, world, currentPos, facingPos); } diff --git a/src/main/java/pokecube/core/client/EventsHandlerClient.java b/src/main/java/pokecube/core/client/EventsHandlerClient.java index 9c10d3df42..21f458c134 100644 --- a/src/main/java/pokecube/core/client/EventsHandlerClient.java +++ b/src/main/java/pokecube/core/client/EventsHandlerClient.java @@ -36,18 +36,18 @@ import net.minecraft.world.level.Level; import net.minecraft.world.phys.HitResult.Type; import net.minecraftforge.client.event.EntityViewRenderEvent; -import net.minecraftforge.client.event.GuiScreenEvent; import net.minecraftforge.client.event.InputEvent.KeyInputEvent; import net.minecraftforge.client.event.InputEvent.RawMouseEvent; import net.minecraftforge.client.event.RenderGameOverlayEvent; import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType; import net.minecraftforge.client.event.RenderPlayerEvent; +import net.minecraftforge.client.event.ScreenEvent.DrawScreenEvent; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.AttachCapabilitiesEvent; import net.minecraftforge.event.TickEvent; import net.minecraftforge.event.TickEvent.Phase; +import net.minecraftforge.event.server.ServerAboutToStartEvent; import net.minecraftforge.eventbus.api.EventPriority; -import net.minecraftforge.fmlserverevents.FMLServerAboutToStartEvent; import pokecube.core.PokecubeCore; import pokecube.core.ai.brain.BrainUtils; import pokecube.core.ai.logic.LogicMountedControl; @@ -141,7 +141,7 @@ public static void register() MinecraftForge.EVENT_BUS.addListener(EventPriority.HIGHEST, EventsHandlerClient::serverAboutToStart); } - private static void serverAboutToStart(final FMLServerAboutToStartEvent event) + private static void serverAboutToStart(final ServerAboutToStartEvent event) { ClientProxy.pokecenter_sounds.clear(); } @@ -223,9 +223,9 @@ private static void onFogRender(final EntityViewRenderEvent.FogDensity evt) { IPokemob mount; - if (evt.getInfo().getEntity() instanceof Player && evt.getInfo().getEntity().getVehicle() != null - && (mount = CapabilityPokemob.getPokemobFor(evt.getInfo().getEntity().getVehicle())) != null) if (evt - .getInfo().getEntity().isInWater() && mount.canUseDive()) + if (evt.getCamera().getEntity() instanceof Player && evt.getCamera().getEntity().getVehicle() != null + && (mount = CapabilityPokemob.getPokemobFor(evt.getCamera().getEntity().getVehicle())) != null) if (evt + .getCamera().getEntity().isInWater() && mount.canUseDive()) { evt.setDensity(0.005f); evt.setCanceled(true); @@ -329,13 +329,13 @@ private static void onCapabilityAttach(final AttachCapabilitiesEvent eve new ShoulderHolder((Player) event.getObject())); } - private static void onRenderGUIScreenPre(final GuiScreenEvent.DrawScreenEvent.Post event) + private static void onRenderGUIScreenPre(final DrawScreenEvent.Post event) { try { - if (!(event.getGui() instanceof AbstractContainerScreen)) return; + if (!(event.getScreen() instanceof AbstractContainerScreen)) return; if (!Screen.hasAltDown()) return; - final AbstractContainerScreen gui = (AbstractContainerScreen) event.getGui(); + final AbstractContainerScreen gui = (AbstractContainerScreen) event.getScreen(); final List slots = gui.getMenu().slots; for (final Slot slot : slots) if (slot.hasItem() && PokecubeManager.isFilled(slot.getItem())) diff --git a/src/main/java/pokecube/core/client/gui/helper/GuardEntry.java b/src/main/java/pokecube/core/client/gui/helper/GuardEntry.java index 2472e1cae2..5f6eddda0d 100644 --- a/src/main/java/pokecube/core/client/gui/helper/GuardEntry.java +++ b/src/main/java/pokecube/core/client/gui/helper/GuardEntry.java @@ -106,9 +106,9 @@ public GuardEntry(final int index, final IGuardAICapability guard, final Entity public boolean keyPressed(final int keyCode, final int p_keyPressed_2_, final int p_keyPressed_3_) { if (keyCode != GLFW.GLFW_KEY_ENTER) return false; - boolean active = this.variation.isFocused() || this.variation.isHovered(); - active = active || this.location.isFocused() || this.location.isHovered(); - active = active || this.timeperiod.isFocused() || this.timeperiod.isHovered(); + boolean active = this.variation.isFocused() || this.variation.isHoveredOrFocused(); + active = active || this.location.isFocused() || this.location.isHoveredOrFocused(); + active = active || this.timeperiod.isFocused() || this.timeperiod.isHoveredOrFocused(); if (!active) return false; this.update(); return true; diff --git a/src/main/java/pokecube/core/client/gui/helper/TexButton.java b/src/main/java/pokecube/core/client/gui/helper/TexButton.java index 9e892648cc..faef9f60f9 100644 --- a/src/main/java/pokecube/core/client/gui/helper/TexButton.java +++ b/src/main/java/pokecube/core/client/gui/helper/TexButton.java @@ -90,7 +90,7 @@ default void render(final TexButton button, final PoseStack matrixStack, final i RenderSystem.enableBlend(); RenderSystem.defaultBlendFunc(); RenderSystem.enableDepthTest(); - final int i = button.getYImage(button.isHovered()); + final int i = button.getYImage(button.isHoveredOrFocused()); button.blit(matrixStack, button.x, button.y, button.uOffset, button.vOffset + i * button.vSize, @@ -124,7 +124,7 @@ public void render(final TexButton button, final PoseStack matrixStack, final in RenderSystem.enableBlend(); RenderSystem.defaultBlendFunc(); RenderSystem.enableDepthTest(); - final int i = button.getYImage(button.isHovered()); + final int i = button.getYImage(button.isHoveredOrFocused()); button.blit(matrixStack, button.x, button.y, this.u, this.v + i * this.h, this.w, this.h); } } @@ -206,6 +206,6 @@ public void renderButton(final PoseStack matrixStack, final int mouseX, final in fontrenderer.draw(matrixStack, msg, this.x + this.getWidth() / 2 - dx, this.y + (this.getHeight() - 8) / 2, j | 255 << 24); } - if (this.isHovered()) this.renderToolTip(matrixStack, mouseX, mouseY); + if (this.isHoveredOrFocused()) this.renderToolTip(matrixStack, mouseX, mouseY); } } diff --git a/src/main/java/pokecube/core/client/render/mobs/RenderMobOverlays.java b/src/main/java/pokecube/core/client/render/mobs/RenderMobOverlays.java index 33596f6154..301245d015 100644 --- a/src/main/java/pokecube/core/client/render/mobs/RenderMobOverlays.java +++ b/src/main/java/pokecube/core/client/render/mobs/RenderMobOverlays.java @@ -27,26 +27,26 @@ public static void renderSpecial(final RenderLivingEvent.Post) Status.render(event - .getRenderer(), mat, buf, pokemob, partialTicks, event.getLight()); + .getRenderer(), mat, buf, pokemob, partialTicks, event.getPackedLight()); } } diff --git a/src/main/java/pokecube/core/commands/Count.java b/src/main/java/pokecube/core/commands/Count.java index 2a0436ae6d..56e150d853 100644 --- a/src/main/java/pokecube/core/commands/Count.java +++ b/src/main/java/pokecube/core/commands/Count.java @@ -5,6 +5,7 @@ import java.util.Map; import java.util.Set; import java.util.UUID; + import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.collect.Sets; diff --git a/src/main/java/pokecube/core/database/resources/PackFinder.java b/src/main/java/pokecube/core/database/resources/PackFinder.java index be4a92331a..e623829b86 100644 --- a/src/main/java/pokecube/core/database/resources/PackFinder.java +++ b/src/main/java/pokecube/core/database/resources/PackFinder.java @@ -8,10 +8,7 @@ import java.util.Map; import java.util.Set; import java.util.function.Consumer; -import java.util.function.Function; import java.util.function.Predicate; -import java.util.stream.Collectors; - import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.collect.Sets; @@ -26,12 +23,11 @@ import net.minecraft.server.packs.resources.Resource; import net.minecraftforge.fml.ModList; import net.minecraftforge.fml.loading.FMLPaths; -import net.minecraftforge.fmllegacy.packs.ModFileResourcePack; -import net.minecraftforge.forgespi.locating.IModFile; +import net.minecraftforge.resource.PathResourcePack; +import net.minecraftforge.resource.ResourcePackLoader; import pokecube.core.PokecubeCore; import pokecube.core.database.Database; -@SuppressWarnings("removal") public class PackFinder implements RepositorySource { static final PackSource DECORATOR = PackSource.decorating("pack.source.pokecube.data"); @@ -59,9 +55,8 @@ public static List getResources(ResourceLocation l) throws IOException return Database.resourceManager.getResources(l); } - private Map modResourcePacks = Maps.newHashMap(); - public final List allPacks = Lists.newArrayList(); - public Set folderPacks = Sets.newHashSet(); + public final List allPacks = Lists.newArrayList(); + public Set folderPacks = Sets.newHashSet(); private final FolderRepositorySource folderFinder_old; private final FolderRepositorySource folderFinder_new; @@ -79,14 +74,13 @@ public PackFinder(final Pack.PackConstructor packInfoFactoryIn) this.init(packInfoFactoryIn); } - @SuppressWarnings({ "deprecation" }) public void init(final Pack.PackConstructor packInfoFactoryIn) { try { - this.modResourcePacks = ModList.get().getModFiles().stream().map(mf -> new ModFileResourcePack(mf - .getFile())).collect(Collectors.toMap(ModFileResourcePack::getModFile, Function.identity())); - this.allPacks.addAll(this.modResourcePacks.values()); + final List packs = Lists.newArrayList(); + ModList.get().getModFiles().stream().forEach(mf -> packs.add(ResourcePackLoader.createPackForMod(mf))); + this.allPacks.addAll(packs); } catch (final Exception e) { diff --git a/src/main/java/pokecube/core/entity/npc/NpcMob.java b/src/main/java/pokecube/core/entity/npc/NpcMob.java index 070edd797e..abfa7e8b79 100644 --- a/src/main/java/pokecube/core/entity/npc/NpcMob.java +++ b/src/main/java/pokecube/core/entity/npc/NpcMob.java @@ -46,8 +46,8 @@ import net.minecraft.world.item.trading.MerchantOffers; import net.minecraft.world.level.Level; import net.minecraft.world.level.ServerLevelAccessor; -import net.minecraftforge.fmllegacy.common.registry.IEntityAdditionalSpawnData; -import net.minecraftforge.fmllegacy.network.NetworkHooks; +import net.minecraftforge.entity.IEntityAdditionalSpawnData; +import net.minecraftforge.network.NetworkHooks; import pokecube.core.PokecubeCore; import pokecube.core.ai.npc.Activities; import pokecube.core.ai.npc.Schedules; diff --git a/src/main/java/pokecube/core/entity/pokemobs/ContainerPokemob.java b/src/main/java/pokecube/core/entity/pokemobs/ContainerPokemob.java index 20020e59eb..08d4270de5 100644 --- a/src/main/java/pokecube/core/entity/pokemobs/ContainerPokemob.java +++ b/src/main/java/pokecube/core/entity/pokemobs/ContainerPokemob.java @@ -10,7 +10,7 @@ import net.minecraft.world.inventory.Slot; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; -import net.minecraftforge.fmllegacy.network.IContainerFactory; +import net.minecraftforge.network.IContainerFactory; import pokecube.core.PokecubeItems; import pokecube.core.interfaces.IPokemob; import pokecube.core.interfaces.capabilities.CapabilityPokemob; diff --git a/src/main/java/pokecube/core/entity/pokemobs/EntityPokemob.java b/src/main/java/pokecube/core/entity/pokemobs/EntityPokemob.java index 7865fd6e67..4316a1e25e 100644 --- a/src/main/java/pokecube/core/entity/pokemobs/EntityPokemob.java +++ b/src/main/java/pokecube/core/entity/pokemobs/EntityPokemob.java @@ -47,7 +47,7 @@ import net.minecraft.world.phys.HitResult; import net.minecraft.world.phys.Vec3; import net.minecraftforge.eventbus.api.Event.Result; -import net.minecraftforge.fmllegacy.network.NetworkHooks; +import net.minecraftforge.network.NetworkHooks; import pokecube.core.PokecubeCore; import pokecube.core.ai.logic.LogicMountedControl; import pokecube.core.database.PokedexEntry; diff --git a/src/main/java/pokecube/core/entity/pokemobs/PokemobType.java b/src/main/java/pokecube/core/entity/pokemobs/PokemobType.java index 8d697ecab5..dd70e17ebb 100644 --- a/src/main/java/pokecube/core/entity/pokemobs/PokemobType.java +++ b/src/main/java/pokecube/core/entity/pokemobs/PokemobType.java @@ -8,7 +8,7 @@ import net.minecraft.world.entity.MobCategory; import net.minecraft.world.entity.TamableAnimal; import net.minecraft.world.level.Level; -import net.minecraftforge.fmllegacy.network.FMLPlayMessages.SpawnEntity; +import net.minecraftforge.network.PlayMessages.SpawnEntity; import pokecube.core.database.PokedexEntry; import pokecube.core.utils.PokeType; diff --git a/src/main/java/pokecube/core/entity/pokemobs/helper/PokemobBase.java b/src/main/java/pokecube/core/entity/pokemobs/helper/PokemobBase.java index 9272fab6cd..4f3e3b7782 100644 --- a/src/main/java/pokecube/core/entity/pokemobs/helper/PokemobBase.java +++ b/src/main/java/pokecube/core/entity/pokemobs/helper/PokemobBase.java @@ -7,7 +7,7 @@ import net.minecraft.world.entity.animal.FlyingAnimal; import net.minecraft.world.entity.animal.ShoulderRidingEntity; import net.minecraft.world.level.Level; -import net.minecraftforge.fmllegacy.common.registry.IEntityAdditionalSpawnData; +import net.minecraftforge.entity.IEntityAdditionalSpawnData; import pokecube.core.PokecubeCore; import pokecube.core.ai.logic.LogicMiscUpdate; import pokecube.core.interfaces.capabilities.DefaultPokemob; diff --git a/src/main/java/pokecube/core/handlers/RecipeHandler.java b/src/main/java/pokecube/core/handlers/RecipeHandler.java index 65c2e04517..eb40500e50 100644 --- a/src/main/java/pokecube/core/handlers/RecipeHandler.java +++ b/src/main/java/pokecube/core/handlers/RecipeHandler.java @@ -9,9 +9,9 @@ import net.minecraft.world.item.crafting.SimpleRecipeSerializer; import net.minecraftforge.common.brewing.BrewingRecipeRegistry; import net.minecraftforge.eventbus.api.IEventBus; -import net.minecraftforge.fmllegacy.RegistryObject; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; +import net.minecraftforge.registries.RegistryObject; import pokecube.core.PokecubeCore; import pokecube.core.items.berries.RecipeBrewBerries; import pokecube.core.items.pokecubes.RecipePokeseals; diff --git a/src/main/java/pokecube/core/handlers/events/EventsHandler.java b/src/main/java/pokecube/core/handlers/events/EventsHandler.java index b98132207f..8a6a8c9171 100644 --- a/src/main/java/pokecube/core/handlers/events/EventsHandler.java +++ b/src/main/java/pokecube/core/handlers/events/EventsHandler.java @@ -53,12 +53,12 @@ import net.minecraftforge.event.entity.player.PlayerEvent.StartTracking; import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.event.entity.player.PlayerWakeUpEvent; +import net.minecraftforge.event.server.ServerStartingEvent; +import net.minecraftforge.event.server.ServerStoppedEvent; import net.minecraftforge.event.world.WorldEvent; import net.minecraftforge.eventbus.api.Event.Result; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.LogicalSide; -import net.minecraftforge.fmlserverevents.FMLServerStartingEvent; -import net.minecraftforge.fmlserverevents.FMLServerStoppedEvent; import pokecube.core.PokecubeCore; import pokecube.core.PokecubeItems; import pokecube.core.ai.routes.IGuardAICapability; @@ -656,14 +656,14 @@ private static void onStartTracking(final StartTracking event) } } - private static void onServerStarting(final FMLServerStartingEvent event) + private static void onServerStarting(final ServerStartingEvent event) { PokecubeCore.LOGGER.info("Server Starting"); PokecubeItems.init(event.getServer()); EventsHandler.RUNNING = true; } - private static void onServerStopped(final FMLServerStoppedEvent event) + private static void onServerStopped(final ServerStoppedEvent event) { // Reset this. PokecubeSerializer.clearInstance(); diff --git a/src/main/java/pokecube/core/handlers/events/PokemobEventsHandler.java b/src/main/java/pokecube/core/handlers/events/PokemobEventsHandler.java index 53a3ce2f7a..4bce802656 100644 --- a/src/main/java/pokecube/core/handlers/events/PokemobEventsHandler.java +++ b/src/main/java/pokecube/core/handlers/events/PokemobEventsHandler.java @@ -63,8 +63,6 @@ import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.eventbus.api.Event.Result; import net.minecraftforge.eventbus.api.EventPriority; -import net.minecraftforge.fml.LogicalSide; -import net.minecraftforge.fmllegacy.LogicalSidedProvider; import net.minecraftforge.server.permission.IPermissionHandler; import net.minecraftforge.server.permission.PermissionAPI; import net.minecraftforge.server.permission.context.PlayerContext; @@ -115,6 +113,7 @@ import thut.api.maths.Vector3; import thut.api.maths.vecmath.Vector3f; import thut.api.terrain.TerrainManager; +import thut.core.common.ThutCore; import thut.core.common.network.EntityUpdate; public class PokemobEventsHandler @@ -518,7 +517,7 @@ private static long mean(final long[] values) private static void onServerTick(final ServerTickEvent event) { if (event.phase != Phase.END || !PokecubeCore.getConfig().doLoadBalancing) return; - final MinecraftServer server = LogicalSidedProvider.INSTANCE.get(LogicalSide.SERVER); + final MinecraftServer server = ThutCore.proxy.getServer(); final double meanTickTime = PokemobEventsHandler.mean(server.tickTimes) * 1.0E-6D; final double maxTick = PokecubeCore.getConfig().loadBalanceThreshold; if (meanTickTime > maxTick) diff --git a/src/main/java/pokecube/core/handlers/playerdata/PlayerPokemobCache.java b/src/main/java/pokecube/core/handlers/playerdata/PlayerPokemobCache.java index e6263d1a14..d7c3f75435 100644 --- a/src/main/java/pokecube/core/handlers/playerdata/PlayerPokemobCache.java +++ b/src/main/java/pokecube/core/handlers/playerdata/PlayerPokemobCache.java @@ -12,11 +12,10 @@ import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.item.ItemStack; -import net.minecraftforge.fml.LogicalSide; -import net.minecraftforge.fmllegacy.LogicalSidedProvider; import pokecube.core.PokecubeCore; import pokecube.core.interfaces.IPokemob; import pokecube.core.items.pokecubes.PokecubeManager; +import thut.core.common.ThutCore; import thut.core.common.handlers.PlayerDataHandler; import thut.core.common.handlers.PlayerDataHandler.PlayerData; @@ -28,7 +27,7 @@ public static void UpdateCache(final IPokemob mob) if (!mob.isPlayerOwned() || mob.getOwnerId() == null) return; if (!mob.getEntity().isEffectiveAi()) return; final ItemStack stack = PokecubeManager.pokemobToItem(mob); - final MinecraftServer server = LogicalSidedProvider.INSTANCE.get(LogicalSide.SERVER); + final MinecraftServer server = ThutCore.proxy.getServer(); // Schedule this to run at some point, as it takes a while. server.execute(() -> PlayerPokemobCache.UpdateCache(stack, false, false)); } @@ -36,7 +35,7 @@ public static void UpdateCache(final IPokemob mob) public static void UpdateCache(final ItemStack stack, final boolean pc, final boolean deleted) { if (!(PokecubeCore.proxy.getWorld() instanceof ServerLevel)) return; - final MinecraftServer server = LogicalSidedProvider.INSTANCE.get(LogicalSide.SERVER); + final MinecraftServer server = ThutCore.proxy.getServer(); server.execute(() -> PlayerPokemobCache.UpdateCacheImpl(stack, pc, deleted)); } @@ -70,7 +69,7 @@ public static void RemoveFromCache(final UUID owner, final IPokemob pokemob) if (!pokemob.isPlayerOwned() || pokemob.getOwnerId() == null || owner == null) return; if (!pokemob.getEntity().isEffectiveAi()) return; final ItemStack stack = PokecubeManager.pokemobToItem(pokemob); - final MinecraftServer server = LogicalSidedProvider.INSTANCE.get(LogicalSide.SERVER); + final MinecraftServer server = ThutCore.proxy.getServer(); // Schedule this to run at some point, as it takes a while. server.execute(() -> PlayerPokemobCache.Remove(owner, stack)); diff --git a/src/main/java/pokecube/core/init/ClientSetupHandler.java b/src/main/java/pokecube/core/init/ClientSetupHandler.java index 082e147a39..de2d836a09 100644 --- a/src/main/java/pokecube/core/init/ClientSetupHandler.java +++ b/src/main/java/pokecube/core/init/ClientSetupHandler.java @@ -16,6 +16,7 @@ import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.BlockState; import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.client.ClientRegistry; import net.minecraftforge.client.event.ColorHandlerEvent; import net.minecraftforge.client.event.EntityRenderersEvent.RegisterRenderers; import net.minecraftforge.common.capabilities.RegisterCapabilitiesEvent; @@ -23,7 +24,6 @@ import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; import net.minecraftforge.fml.event.lifecycle.FMLLoadCompleteEvent; -import net.minecraftforge.fmlclient.registry.ClientRegistry; import pokecube.core.PokecubeCore; import pokecube.core.PokecubeItems; import pokecube.core.client.EventsHandlerClient; diff --git a/src/main/java/pokecube/core/interfaces/capabilities/impl/PokemobSexed.java b/src/main/java/pokecube/core/interfaces/capabilities/impl/PokemobSexed.java index bd607c3bbf..40301ddc0b 100644 --- a/src/main/java/pokecube/core/interfaces/capabilities/impl/PokemobSexed.java +++ b/src/main/java/pokecube/core/interfaces/capabilities/impl/PokemobSexed.java @@ -9,8 +9,6 @@ import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.player.Player; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.LogicalSide; -import net.minecraftforge.fmllegacy.LogicalSidedProvider; import pokecube.core.PokecubeCore; import pokecube.core.ai.brain.BrainUtils; import pokecube.core.ai.tasks.idle.HungerTask; @@ -174,7 +172,7 @@ protected void mate(final IBreedingMob male) public void mateWith(final IBreedingMob male) { if (ThutCore.proxy.isClientSide()) return; - final MinecraftServer server = LogicalSidedProvider.INSTANCE.get(LogicalSide.SERVER); + final MinecraftServer server = ThutCore.proxy.getServer(); server.tell(new TickTask(0, () -> this.mate(male))); } diff --git a/src/main/java/pokecube/core/inventory/pc/PCContainer.java b/src/main/java/pokecube/core/inventory/pc/PCContainer.java index 3843f7affc..9aa7f719e1 100644 --- a/src/main/java/pokecube/core/inventory/pc/PCContainer.java +++ b/src/main/java/pokecube/core/inventory/pc/PCContainer.java @@ -19,7 +19,7 @@ import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.util.LazyOptional; -import net.minecraftforge.fmllegacy.network.IContainerFactory; +import net.minecraftforge.network.IContainerFactory; import pokecube.core.PokecubeCore; import pokecube.core.items.ItemPokedex; import pokecube.core.items.megastuff.IMegaCapability; diff --git a/src/main/java/pokecube/core/items/pokecubes/EntityPokecubeBase.java b/src/main/java/pokecube/core/items/pokecubes/EntityPokecubeBase.java index c928ceb1e4..4b81f34fd4 100644 --- a/src/main/java/pokecube/core/items/pokecubes/EntityPokecubeBase.java +++ b/src/main/java/pokecube/core/items/pokecubes/EntityPokecubeBase.java @@ -10,7 +10,6 @@ import com.google.common.collect.ImmutableSet; import net.minecraft.core.BlockPos; -import net.minecraft.core.Direction; import net.minecraft.core.NonNullList; import net.minecraft.core.particles.ParticleTypes; import net.minecraft.nbt.CompoundTag; @@ -33,6 +32,7 @@ import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.MoverType; import net.minecraft.world.entity.player.Player; +import net.minecraft.world.entity.projectile.ProjectileUtil; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.ClipContext; import net.minecraft.world.level.Level; @@ -632,19 +632,18 @@ public boolean isReleasing() public static HitResult rayTrace(final Entity projectile, final boolean checkEntityCollision, final boolean includeShooter, @Nullable final Entity shooter, final ClipContext.Block blockModeIn) { - return EntityPokecubeBase.rayTrace(projectile, checkEntityCollision, includeShooter, shooter, blockModeIn, true, - (p_221270_2_) -> - { - return !p_221270_2_.isSpectator() && p_221270_2_.isPickable() && (includeShooter || !p_221270_2_.is( - shooter)) && !p_221270_2_.noPhysics; - }, projectile.getBoundingBox().expandTowards(projectile.getDeltaMovement()).inflate(1.0D)); + final Predicate valid = (target) -> + { + return !target.isSpectator() && target.isPickable() && (includeShooter || !target.is( + shooter)) && !target.noPhysics; + }; + return ProjectileUtil.getHitResult(projectile, valid); } public static HitResult rayTrace(final Entity projectile, final AABB boundingBox, final Predicate filter, final ClipContext.Block blockModeIn, final boolean checkEntityCollision) { - return EntityPokecubeBase.rayTrace(projectile, checkEntityCollision, false, (Entity) null, blockModeIn, false, - filter, boundingBox); + return ProjectileUtil.getHitResult(projectile, filter); } /** @@ -658,35 +657,6 @@ public static EntityHitResult rayTraceEntities(final Level worldIn, final Entity Double.MAX_VALUE); } - private static HitResult rayTrace(final Entity projectile, final boolean checkEntityCollision, - final boolean includeShooter, @Nullable final Entity shooter, final ClipContext.Block blockModeIn, - final boolean p_221268_5_, final Predicate filter, final AABB boundingBox) - { - final Vec3 vec3d = projectile.getDeltaMovement(); - final Level world = projectile.level; - final Vec3 vec3d1 = projectile.position(); - if (p_221268_5_ && !world.noCollision(projectile, projectile.getBoundingBox(), e -> (!includeShooter - && shooter != null ? EntityPokecubeBase.getEntityAndMount(shooter) : ImmutableSet.of()).contains(e))) - return new BlockHitResult(vec3d1, Direction.getNearest(vec3d.x, vec3d.y, vec3d.z), new BlockPos(projectile - .position()), false); - else - { - Vec3 vec3d2 = vec3d1.add(vec3d); - HitResult raytraceresult = world.clip(new ClipContext(vec3d1, vec3d2, blockModeIn, ClipContext.Fluid.NONE, - projectile)); - if (checkEntityCollision) - { - if (raytraceresult.getType() != HitResult.Type.MISS) vec3d2 = raytraceresult.getLocation(); - - final HitResult raytraceresult1 = EntityPokecubeBase.rayTraceEntities(world, projectile, vec3d1, vec3d2, - boundingBox, filter); - if (raytraceresult1 != null) raytraceresult = raytraceresult1; - } - - return raytraceresult; - } - } - /** * Gets the EntityRayTraceResult representing the entity hit */ diff --git a/src/main/java/pokecube/core/items/pokecubes/Pokecube.java b/src/main/java/pokecube/core/items/pokecubes/Pokecube.java index 166d789ec5..277f67fb03 100644 --- a/src/main/java/pokecube/core/items/pokecubes/Pokecube.java +++ b/src/main/java/pokecube/core/items/pokecubes/Pokecube.java @@ -226,16 +226,27 @@ public double getCaptureModifier(final Entity mob, final ResourceLocation pokecu } @Override - public double getDurabilityForDisplay(final ItemStack stack) + public boolean isDamaged(final ItemStack stack) + { + return PokecubeManager.isFilled(stack); + } + + @Override + public int getDamage(final ItemStack stack) { if (stack.hasTag() && stack.getTag().contains("CHP")) { final float chp = stack.getTag().getFloat("CHP"); - final float mhp = stack.getTag().getFloat("MHP"); - if (chp == mhp) return 1 - 0.99999; - return 1 - chp / mhp; + return (int) chp; } - return super.getDurabilityForDisplay(stack); + return super.getDamage(stack); + } + + @Override + public int getMaxDamage(final ItemStack stack) + { + final float mhp = stack.getTag().getFloat("MHP"); + return (int) mhp; } @Override @@ -353,12 +364,6 @@ public boolean shouldOverrideMultiplayerNbt() return true; } - @Override - public boolean showDurabilityBar(final ItemStack stack) - { - return PokecubeManager.isFilled(stack); - } - @Override public EntityPokecubeBase throwPokecube(final Level world, final LivingEntity thrower, final ItemStack cube, final Vector3 direction, final float power) @@ -483,8 +488,8 @@ public EntityPokecubeBase throwPokecubeAt(final Level world, final LivingEntity { thrower.playSound(SoundEvents.EGG_THROW, 0.5F, 0.4F / (ThutCore.newRandom().nextFloat() * 0.4F + 0.8F)); world.addFreshEntity(entity); - if (PokecubeManager.isFilled(stack) && thrower instanceof Player) PlayerPokemobCache.UpdateCache( - stack, false, false); + if (PokecubeManager.isFilled(stack) && thrower instanceof Player) PlayerPokemobCache.UpdateCache(stack, + false, false); } } else if (!rightclick) return null; diff --git a/src/main/java/pokecube/core/moves/PokemobTerrainEffects.java b/src/main/java/pokecube/core/moves/PokemobTerrainEffects.java index b4879b3100..3425fd6916 100644 --- a/src/main/java/pokecube/core/moves/PokemobTerrainEffects.java +++ b/src/main/java/pokecube/core/moves/PokemobTerrainEffects.java @@ -25,7 +25,7 @@ import net.minecraft.world.entity.LivingEntity; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.client.event.RenderWorldLastEvent; +import net.minecraftforge.client.event.RenderLevelLastEvent; import pokecube.core.PokecubeCore; import pokecube.core.handlers.events.EventsHandler; import pokecube.core.interfaces.IMoveConstants; @@ -403,11 +403,11 @@ private void renderEffect(final VertexConsumer builder, final Matrix4f pos, fina } @OnlyIn(Dist.CLIENT) - public void renderTerrainEffects(final RenderWorldLastEvent event, final Vector3 origin) + public void renderTerrainEffects(final RenderLevelLastEvent event, final Vector3 origin) { if (this.hasEffects()) { - final PoseStack mat = event.getMatrixStack(); + final PoseStack mat = event.getPoseStack(); assert Minecraft.getInstance().player != null; final int time = Minecraft.getInstance().player.tickCount; diff --git a/src/main/java/pokecube/core/moves/animations/EntityMoveUse.java b/src/main/java/pokecube/core/moves/animations/EntityMoveUse.java index 3016d86a7c..182cc4c0b1 100644 --- a/src/main/java/pokecube/core/moves/animations/EntityMoveUse.java +++ b/src/main/java/pokecube/core/moves/animations/EntityMoveUse.java @@ -31,7 +31,7 @@ import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.extensions.IForgeBlockEntity; import net.minecraftforge.entity.PartEntity; -import net.minecraftforge.fmllegacy.network.NetworkHooks; +import net.minecraftforge.network.NetworkHooks; import pokecube.core.PokecubeCore; import pokecube.core.interfaces.IMoveAnimation.MovePacketInfo; import pokecube.core.interfaces.IMoveConstants; diff --git a/src/main/java/pokecube/core/moves/animations/MoveAnimationHelper.java b/src/main/java/pokecube/core/moves/animations/MoveAnimationHelper.java index 9f19a1b029..091354f0aa 100644 --- a/src/main/java/pokecube/core/moves/animations/MoveAnimationHelper.java +++ b/src/main/java/pokecube/core/moves/animations/MoveAnimationHelper.java @@ -16,7 +16,7 @@ import net.minecraft.world.phys.Vec3; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.client.event.RenderWorldLastEvent; +import net.minecraftforge.client.event.RenderLevelLastEvent; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.AttachCapabilitiesEvent; import net.minecraftforge.event.world.ChunkEvent; @@ -164,7 +164,7 @@ public void onCapabilityAttach(final AttachCapabilitiesEvent event) @OnlyIn(Dist.CLIENT) @SubscribeEvent - public void onRenderWorldPost(final RenderWorldLastEvent event) + public void onRenderWorldPost(final RenderLevelLastEvent event) { if (this.effects == 0) return; int num = 0; @@ -177,7 +177,7 @@ public void onRenderWorldPost(final RenderWorldLastEvent event) final Minecraft mc = Minecraft.getInstance(); final Vec3 projectedView = mc.gameRenderer.getMainCamera().getPosition(); - final PoseStack mat = event.getMatrixStack(); + final PoseStack mat = event.getPoseStack(); mat.pushPose(); mat.translate(-projectedView.x, -projectedView.y, -projectedView.z); final BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos(); diff --git a/src/main/java/pokecube/core/network/packets/PacketPC.java b/src/main/java/pokecube/core/network/packets/PacketPC.java index 1a49a20aed..7cc58f656a 100644 --- a/src/main/java/pokecube/core/network/packets/PacketPC.java +++ b/src/main/java/pokecube/core/network/packets/PacketPC.java @@ -10,7 +10,7 @@ import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.block.entity.BlockEntity; -import net.minecraftforge.fmllegacy.network.NetworkHooks; +import net.minecraftforge.network.NetworkHooks; import pokecube.core.PokecubeCore; import pokecube.core.blocks.pc.PCTile; import pokecube.core.inventory.pc.PCContainer; diff --git a/src/main/java/pokecube/core/network/packets/PacketSyncRoutes.java b/src/main/java/pokecube/core/network/packets/PacketSyncRoutes.java index 799f62b907..5e543cb8ca 100644 --- a/src/main/java/pokecube/core/network/packets/PacketSyncRoutes.java +++ b/src/main/java/pokecube/core/network/packets/PacketSyncRoutes.java @@ -9,7 +9,7 @@ import net.minecraft.world.SimpleMenuProvider; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.player.Player; -import net.minecraftforge.fmllegacy.network.NetworkHooks; +import net.minecraftforge.network.NetworkHooks; import pokecube.core.PokecubeCore; import pokecube.core.ai.routes.GuardAICapability.GuardTask; import pokecube.core.ai.routes.IGuardAICapability; diff --git a/src/main/java/pokecube/core/network/pokemobs/PacketPokemobGui.java b/src/main/java/pokecube/core/network/pokemobs/PacketPokemobGui.java index 4eb9482e70..6a8cce066d 100644 --- a/src/main/java/pokecube/core/network/pokemobs/PacketPokemobGui.java +++ b/src/main/java/pokecube/core/network/pokemobs/PacketPokemobGui.java @@ -7,7 +7,7 @@ import net.minecraft.world.entity.Entity; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.fmllegacy.network.NetworkHooks; +import net.minecraftforge.network.NetworkHooks; import pokecube.core.PokecubeCore; import pokecube.core.ai.tasks.utility.StoreTask; import pokecube.core.entity.pokemobs.ContainerPokemob; diff --git a/src/main/java/pokecube/core/proxy/CommonProxy.java b/src/main/java/pokecube/core/proxy/CommonProxy.java index 9d493e7023..91f6bd4d4b 100644 --- a/src/main/java/pokecube/core/proxy/CommonProxy.java +++ b/src/main/java/pokecube/core/proxy/CommonProxy.java @@ -6,16 +6,16 @@ import net.minecraft.server.MinecraftServer; import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.Level; +import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.RegistryEvent.NewRegistry; import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.fml.LogicalSide; import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fmllegacy.LogicalSidedProvider; import pokecube.core.PokecubeCore; import pokecube.core.blocks.healer.HealerTile; import pokecube.nbtedit.NBTEdit; +import thut.core.common.Proxy; -public class CommonProxy +public class CommonProxy implements Proxy { @Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD, modid = PokecubeCore.MODID) public static class RegistryEvents @@ -27,14 +27,29 @@ public static void onStart(final NewRegistry event) { PokecubeCore.proxy = new CommonProxy(); NBTEdit.proxy = new pokecube.nbtedit.forge.CommonProxy(); + MinecraftForge.EVENT_BUS.addListener(PokecubeCore.proxy::handleServerAboutToStart); + MinecraftForge.EVENT_BUS.addListener(NBTEdit.proxy::handleServerAboutToStart); } } } + private MinecraftServer server; + + @Override + public void setServer(final MinecraftServer server) + { + this.server = server; + } + + @Override + public MinecraftServer getServer() + { + return this.server; + } + public Player getPlayer(final UUID uuid) { - final MinecraftServer server = LogicalSidedProvider.INSTANCE.get(LogicalSide.SERVER); - return server.getPlayerList().getPlayer(uuid); + return this.getServer().getPlayerList().getPlayer(uuid); } public ResourceLocation getPlayerSkin(final String name) @@ -49,8 +64,7 @@ public ResourceLocation getUrlSkin(final String urlSkin) public Level getWorld() { - final MinecraftServer server = LogicalSidedProvider.INSTANCE.get(LogicalSide.SERVER); - return server.getLevel(Level.OVERWORLD); + return this.getServer().getLevel(Level.OVERWORLD); } public Player getPlayer() diff --git a/src/main/java/pokecube/core/recipes/MoveRecipes.java b/src/main/java/pokecube/core/recipes/MoveRecipes.java index ba6a625eb6..d8e232def0 100644 --- a/src/main/java/pokecube/core/recipes/MoveRecipes.java +++ b/src/main/java/pokecube/core/recipes/MoveRecipes.java @@ -25,8 +25,8 @@ import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.BlockState; -import net.minecraftforge.fmllegacy.RegistryObject; import net.minecraftforge.registries.ForgeRegistryEntry; +import net.minecraftforge.registries.RegistryObject; import pokecube.core.database.pokedex.PokedexEntryLoader; import pokecube.core.database.recipes.PokemobMoveRecipeParser; import pokecube.core.database.recipes.PokemobMoveRecipeParser.MoveMatcher; diff --git a/src/main/java/pokecube/core/utils/PokecubeSerializer.java b/src/main/java/pokecube/core/utils/PokecubeSerializer.java index f5967a3828..1d53de274a 100644 --- a/src/main/java/pokecube/core/utils/PokecubeSerializer.java +++ b/src/main/java/pokecube/core/utils/PokecubeSerializer.java @@ -29,8 +29,6 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import net.minecraft.world.level.storage.LevelResource; -import net.minecraftforge.fml.LogicalSide; -import net.minecraftforge.fmllegacy.LogicalSidedProvider; import pokecube.core.PokecubeCore; import pokecube.core.PokecubeItems; import pokecube.core.database.PokedexEntry; @@ -201,7 +199,7 @@ public boolean hasStarter(final Player player) public static File getSafeFile() { - final MinecraftServer server = LogicalSidedProvider.INSTANCE.get(LogicalSide.SERVER); + final MinecraftServer server = ThutCore.proxy.getServer(); Path path = server.getWorldPath(new LevelResource(PokecubeSerializer.POKECUBE)); // The directory the file is in final File dir = path.toFile(); diff --git a/src/main/java/pokecube/core/world/gen/WorldgenFeatures.java b/src/main/java/pokecube/core/world/gen/WorldgenFeatures.java index 63dcd7108f..ecfea45d04 100644 --- a/src/main/java/pokecube/core/world/gen/WorldgenFeatures.java +++ b/src/main/java/pokecube/core/world/gen/WorldgenFeatures.java @@ -24,9 +24,9 @@ import net.minecraft.world.level.levelgen.structure.templatesystem.StructureProcessor; import net.minecraft.world.level.levelgen.structure.templatesystem.StructureProcessorList; import net.minecraftforge.eventbus.api.IEventBus; -import net.minecraftforge.fmllegacy.RegistryObject; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; +import net.minecraftforge.registries.RegistryObject; import pokecube.core.PokecubeCore; import pokecube.core.blocks.berries.BerryGenManager; import pokecube.core.database.worldgen.WorldgenHandler.JigSawConfig; diff --git a/src/main/java/pokecube/core/world/gen/jigsaw/JigsawAssmbler.java b/src/main/java/pokecube/core/world/gen/jigsaw/JigsawAssmbler.java index e11fa491c6..ad4cb40376 100644 --- a/src/main/java/pokecube/core/world/gen/jigsaw/JigsawAssmbler.java +++ b/src/main/java/pokecube/core/world/gen/jigsaw/JigsawAssmbler.java @@ -45,10 +45,11 @@ import net.minecraft.world.phys.shapes.BooleanOp; import net.minecraft.world.phys.shapes.Shapes; import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraftforge.common.util.LogicalSidedProvider; import net.minecraftforge.fml.LogicalSide; -import net.minecraftforge.fmllegacy.LogicalSidedProvider; import pokecube.core.PokecubeCore; import pokecube.core.database.worldgen.WorldgenHandler.JigSawConfig; +import thut.core.common.ThutCore; public class JigsawAssmbler { @@ -71,7 +72,7 @@ private Entry(final PoolElementStructurePiece villagePieceIn, final MutableObjec public static ServerLevel getForGen(final ChunkGenerator chunkGen) { - final MinecraftServer server = LogicalSidedProvider.INSTANCE.get(LogicalSide.SERVER); + final MinecraftServer server = ThutCore.proxy.getServer(); for (final ServerLevel w : server.getAllLevels()) if (w.getChunkSource().generator == chunkGen) return w; throw new IllegalStateException("Did not find a world for this chunk generator!"); diff --git a/src/main/java/pokecube/legends/PokecubeLegends.java b/src/main/java/pokecube/legends/PokecubeLegends.java index 752dacdb02..2418be3474 100644 --- a/src/main/java/pokecube/legends/PokecubeLegends.java +++ b/src/main/java/pokecube/legends/PokecubeLegends.java @@ -36,13 +36,13 @@ import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.event.entity.EntityAttributeCreationEvent; import net.minecraftforge.event.entity.player.PlayerInteractEvent.RightClickBlock; +import net.minecraftforge.event.server.ServerStartingEvent; import net.minecraftforge.eventbus.api.Event.Result; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLLoadCompleteEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; -import net.minecraftforge.fmlserverevents.FMLServerStartingEvent; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; import pokecube.core.PokecubeCore; @@ -336,7 +336,7 @@ public double getCaptureModifier(final IPokemob mob) } @SubscribeEvent - public void serverStarting(final FMLServerStartingEvent event) + public void serverStarting(final ServerStartingEvent event) { PokecubeLegends.config.loaded = true; WormholeEntity.clear(); diff --git a/src/main/java/pokecube/legends/blocks/containers/GenericBookshelfEmpty.java b/src/main/java/pokecube/legends/blocks/containers/GenericBookshelfEmpty.java index 0cc928dd1d..465829c41a 100644 --- a/src/main/java/pokecube/legends/blocks/containers/GenericBookshelfEmpty.java +++ b/src/main/java/pokecube/legends/blocks/containers/GenericBookshelfEmpty.java @@ -120,7 +120,7 @@ public BlockState getStateForPlacement(final BlockPlaceContext context) public BlockState updateShape(final BlockState state, final Direction facing, final BlockState facingState, final LevelAccessor world, final BlockPos currentPos, final BlockPos facingPos) { - if (state.getValue(GenericBookshelfEmpty.WATERLOGGED)) world.getLiquidTicks().scheduleTick(currentPos, + if (state.getValue(GenericBookshelfEmpty.WATERLOGGED)) world.scheduleTick(currentPos, Fluids.WATER, Fluids.WATER.getTickDelay(world)); return super.updateShape(state, facing, facingState, world, currentPos, facingPos); } diff --git a/src/main/java/pokecube/legends/blocks/customblocks/RaidSpawnBlock.java b/src/main/java/pokecube/legends/blocks/customblocks/RaidSpawnBlock.java index a75970dff4..867a5ad668 100644 --- a/src/main/java/pokecube/legends/blocks/customblocks/RaidSpawnBlock.java +++ b/src/main/java/pokecube/legends/blocks/customblocks/RaidSpawnBlock.java @@ -126,7 +126,7 @@ public BlockState getStateForPlacement(final BlockPlaceContext context) public BlockState updateShape(final BlockState state, final Direction facing, final BlockState facingState, final LevelAccessor world, final BlockPos currentPos, final BlockPos facingPos) { - if (state.getValue(RaidSpawnBlock.WATERLOGGED)) world.getLiquidTicks().scheduleTick(currentPos, Fluids.WATER, Fluids.WATER.getTickDelay(world)); + if (state.getValue(RaidSpawnBlock.WATERLOGGED)) world.scheduleTick(currentPos, Fluids.WATER, Fluids.WATER.getTickDelay(world)); return super.updateShape(state, facing, facingState, world, currentPos, facingPos); } diff --git a/src/main/java/pokecube/legends/blocks/customblocks/Rotates.java b/src/main/java/pokecube/legends/blocks/customblocks/Rotates.java index 47b4271e20..cc599de6a1 100644 --- a/src/main/java/pokecube/legends/blocks/customblocks/Rotates.java +++ b/src/main/java/pokecube/legends/blocks/customblocks/Rotates.java @@ -115,7 +115,7 @@ public BlockState mirror(final BlockState state, final Mirror mirrorIn) public BlockState updateShape(final BlockState state, final Direction facing, final BlockState facingState, final LevelAccessor world, final BlockPos currentPos, final BlockPos facingPos) { - if (state.getValue(Rotates.WATERLOGGED)) world.getLiquidTicks().scheduleTick(currentPos, Fluids.WATER, + if (state.getValue(Rotates.WATERLOGGED)) world.scheduleTick(currentPos, Fluids.WATER, Fluids.WATER.getTickDelay(world)); return super.updateShape(state, facing, facingState, world, currentPos, facingPos); } diff --git a/src/main/java/pokecube/legends/blocks/normalblocks/DynaLeavesBlock.java b/src/main/java/pokecube/legends/blocks/normalblocks/DynaLeavesBlock.java index b7f0c45642..4a71a6c310 100644 --- a/src/main/java/pokecube/legends/blocks/normalblocks/DynaLeavesBlock.java +++ b/src/main/java/pokecube/legends/blocks/normalblocks/DynaLeavesBlock.java @@ -21,65 +21,58 @@ public class DynaLeavesBlock extends LeavesBlock implements IForgeShearable public static final IntegerProperty DISTANCE = BlockStateProperties.DISTANCE;; public static final BooleanProperty PERSISTENT = BlockStateProperties.PERSISTENT;; - public DynaLeavesBlock(Properties properties) + public DynaLeavesBlock(final Properties properties) { super(properties); - this.registerDefaultState((BlockState)((BlockState)((BlockState)((BlockState)this.stateDefinition.any()) - .setValue(SNOWY, false)).setValue(DISTANCE, 7)).setValue(PERSISTENT, false)); + this.registerDefaultState(this.stateDefinition.any() + .setValue(DynaLeavesBlock.SNOWY, false).setValue(DynaLeavesBlock.DISTANCE, 7).setValue(DynaLeavesBlock.PERSISTENT, false)); } @Override - public BlockState updateShape(BlockState state, Direction direction, BlockState state1, LevelAccessor world, BlockPos pos, BlockPos pos1) + public BlockState updateShape(final BlockState state, final Direction direction, final BlockState state1, final LevelAccessor world, final BlockPos pos, final BlockPos pos1) { - int i = getDistanceAt(state1) + 1; - if (i != 1 || (Integer)state.getValue(DISTANCE) != i) { - world.getBlockTicks().scheduleTick(pos, this, 1); - } + final int i = DynaLeavesBlock.getDistanceAt(state1) + 1; + if (i != 1 || state.getValue(DynaLeavesBlock.DISTANCE) != i) world.scheduleTick(pos, this, 1); return direction != Direction.UP ? super.updateShape(state, direction, state1, world, pos, pos1) : - (BlockState) state.setValue(SNOWY, state1.is(Blocks.SNOW_BLOCK) || state1.is(Blocks.SNOW)); + (BlockState) state.setValue(DynaLeavesBlock.SNOWY, state1.is(Blocks.SNOW_BLOCK) || state1.is(Blocks.SNOW)); } - public static int getDistanceAt(BlockState state) { - if (BlockTags.LOGS.contains(state.getBlock())) { - return 0; - } else { - return state.getBlock() instanceof LeavesBlock ? (Integer)state.getValue(DISTANCE) : 7; - } + public static int getDistanceAt(final BlockState state) { + if (BlockTags.LOGS.contains(state.getBlock())) return 0; + else return state.getBlock() instanceof LeavesBlock ? (Integer)state.getValue(DynaLeavesBlock.DISTANCE) : 7; } @Override - public BlockState getStateForPlacement(BlockPlaceContext context) + public BlockState getStateForPlacement(final BlockPlaceContext context) { - BlockState state = context.getLevel().getBlockState(context.getClickedPos().above()); + final BlockState state = context.getLevel().getBlockState(context.getClickedPos().above()); // return (BlockState)this.defaultBlockState().setValue(SNOWY, state.is(Blocks.SNOW_BLOCK) || state.is(Blocks.SNOW)); - return updateDistance((BlockState) this.defaultBlockState() - .setValue(SNOWY, state.is(Blocks.SNOW_BLOCK) || state.is(Blocks.SNOW)) - .setValue(PERSISTENT, true), context.getLevel(), context.getClickedPos()); + return DynaLeavesBlock.updateDistance(this.defaultBlockState() + .setValue(DynaLeavesBlock.SNOWY, state.is(Blocks.SNOW_BLOCK) || state.is(Blocks.SNOW)) + .setValue(DynaLeavesBlock.PERSISTENT, true), context.getLevel(), context.getClickedPos()); } - public static BlockState updateDistance(BlockState state, LevelAccessor world, BlockPos pos) { + public static BlockState updateDistance(final BlockState state, final LevelAccessor world, final BlockPos pos) { int i = 7; - BlockPos.MutableBlockPos blockpos$mutable = new BlockPos.MutableBlockPos(); - Direction[] var5 = Direction.values(); - int var6 = var5.length; + final BlockPos.MutableBlockPos blockpos$mutable = new BlockPos.MutableBlockPos(); + final Direction[] var5 = Direction.values(); + final int var6 = var5.length; for(int var7 = 0; var7 < var6; ++var7) { - Direction direction = var5[var7]; + final Direction direction = var5[var7]; blockpos$mutable.setWithOffset(pos, direction); - i = Math.min(i, getDistanceAt(world.getBlockState(blockpos$mutable)) + 1); - if (i == 1) { - break; - } + i = Math.min(i, DynaLeavesBlock.getDistanceAt(world.getBlockState(blockpos$mutable)) + 1); + if (i == 1) break; } - return (BlockState)state.setValue(DISTANCE, i); + return state.setValue(DynaLeavesBlock.DISTANCE, i); } @Override protected void createBlockStateDefinition(final StateDefinition.Builder builder) { - builder.add(DISTANCE, PERSISTENT, SNOWY); + builder.add(DynaLeavesBlock.DISTANCE, DynaLeavesBlock.PERSISTENT, DynaLeavesBlock.SNOWY); } } diff --git a/src/main/java/pokecube/legends/blocks/plants/CrystallizedBush.java b/src/main/java/pokecube/legends/blocks/plants/CrystallizedBush.java index c859f91b28..d555833042 100644 --- a/src/main/java/pokecube/legends/blocks/plants/CrystallizedBush.java +++ b/src/main/java/pokecube/legends/blocks/plants/CrystallizedBush.java @@ -100,7 +100,7 @@ public boolean mayPlaceOn(final BlockState state, final BlockGetter worldIn, fin public BlockState updateShape(final BlockState state, final Direction facing, final BlockState facingState, final LevelAccessor world, final BlockPos currentPos, final BlockPos facingPos) { - if (state.getValue(CrystallizedBush.WATERLOGGED)) world.getLiquidTicks().scheduleTick(currentPos, Fluids.WATER, Fluids.WATER.getTickDelay(world)); + if (state.getValue(CrystallizedBush.WATERLOGGED)) world.scheduleTick(currentPos, Fluids.WATER, Fluids.WATER.getTickDelay(world)); return super.updateShape(state, facing, facingState, world, currentPos, facingPos); } diff --git a/src/main/java/pokecube/legends/blocks/plants/CrystallizedCactus.java b/src/main/java/pokecube/legends/blocks/plants/CrystallizedCactus.java index e5c4049967..1131521add 100644 --- a/src/main/java/pokecube/legends/blocks/plants/CrystallizedCactus.java +++ b/src/main/java/pokecube/legends/blocks/plants/CrystallizedCactus.java @@ -108,8 +108,8 @@ public BlockState getStateForPlacement(final BlockPlaceContext context) public BlockState updateShape(final BlockState state, final Direction facing, final BlockState facingState, final LevelAccessor world, final BlockPos currentPos, final BlockPos facingPos) { - if (!state.canSurvive(world, currentPos)) world.getBlockTicks().scheduleTick(currentPos, this, 1); - if (state.getValue(CrystallizedCactus.WATERLOGGED)) world.getLiquidTicks().scheduleTick(currentPos, Fluids.WATER, Fluids.WATER.getTickDelay(world)); + if (!state.canSurvive(world, currentPos)) world.scheduleTick(currentPos, this, 1); + if (state.getValue(CrystallizedCactus.WATERLOGGED)) world.scheduleTick(currentPos, Fluids.WATER, Fluids.WATER.getTickDelay(world)); return super.updateShape(state, facing, facingState, world, currentPos, facingPos); } diff --git a/src/main/java/pokecube/legends/blocks/plants/TallCrystallizedBush.java b/src/main/java/pokecube/legends/blocks/plants/TallCrystallizedBush.java index 51ff9040df..c638304424 100644 --- a/src/main/java/pokecube/legends/blocks/plants/TallCrystallizedBush.java +++ b/src/main/java/pokecube/legends/blocks/plants/TallCrystallizedBush.java @@ -153,7 +153,7 @@ public boolean mayPlaceOn(final BlockState state, final BlockGetter worldIn, fin public BlockState updateShape(final BlockState state, final Direction facing, final BlockState facingState, final LevelAccessor world, final BlockPos currentPos, final BlockPos facingPos) { - if (state.getValue(TallCrystallizedBush.WATERLOGGED)) world.getLiquidTicks().scheduleTick(currentPos, Fluids.WATER, Fluids.WATER.getTickDelay(world)); + if (state.getValue(TallCrystallizedBush.WATERLOGGED)) world.scheduleTick(currentPos, Fluids.WATER, Fluids.WATER.getTickDelay(world)); return super.updateShape(state, facing, facingState, world, currentPos, facingPos); } diff --git a/src/main/java/pokecube/legends/blocks/plants/TemporalBambooBlock.java b/src/main/java/pokecube/legends/blocks/plants/TemporalBambooBlock.java index 0797d8b9bd..e738de5117 100644 --- a/src/main/java/pokecube/legends/blocks/plants/TemporalBambooBlock.java +++ b/src/main/java/pokecube/legends/blocks/plants/TemporalBambooBlock.java @@ -30,137 +30,135 @@ public class TemporalBambooBlock extends BambooBlock implements BonemealableBlock { - protected static final VoxelShape SMALL_SHAPE = Block.box(7, 0, 7, 9, 16, 9); - protected static final VoxelShape LARGE_SHAPE = Block.box(6.5, 0, 6.5, 9.5, 16, 9.5); - // Tags - public static Tag.Named TEMPORAL_BAMBOO_PLANTABLE_ON = BlockTags.createOptional(new ResourceLocation(Reference.ID, "temporal_bamboo_plantable_on")); - - public TemporalBambooBlock(BlockBehaviour.Properties properties) - { - super(properties); - this.registerDefaultState(this.stateDefinition.any().setValue(AGE, Integer.valueOf(0)).setValue(LEAVES, BambooLeaves.NONE).setValue(STAGE, Integer.valueOf(0))); - } - - @Override - public VoxelShape getShape(BlockState state, BlockGetter block, BlockPos pos, CollisionContext context) - { - VoxelShape voxelshape = state.getValue(AGE) == 1 ? LARGE_SHAPE : SMALL_SHAPE; - Vec3 vec3 = state.getOffset(block, pos); - return voxelshape.move(vec3.x, vec3.y, vec3.z); - } - - @Override - public VoxelShape getCollisionShape(BlockState state, BlockGetter block, BlockPos pos, CollisionContext context) - { - VoxelShape voxelshape = state.getValue(AGE) == 1 ? LARGE_SHAPE : SMALL_SHAPE; - Vec3 vec3 = state.getOffset(block, pos); - return voxelshape.move(vec3.x, vec3.y, vec3.z); - } - - @Override - @Nullable - public BlockState getStateForPlacement(BlockPlaceContext context) - { - FluidState fluid = context.getLevel().getFluidState(context.getClickedPos()); - if (!fluid.isEmpty()) - { - return null; - } else - { - BlockState state = context.getLevel().getBlockState(context.getClickedPos().below()); - if (state.is(TemporalBambooBlock.TEMPORAL_BAMBOO_PLANTABLE_ON) &! state.is(Blocks.BAMBOO_SAPLING)) - { - if (state.is(PlantsInit.TEMPORAL_BAMBOO_SHOOT.get())) + protected static final VoxelShape SMALL_SHAPE = Block.box(7, 0, 7, 9, 16, 9); + protected static final VoxelShape LARGE_SHAPE = Block.box(6.5, 0, 6.5, 9.5, 16, 9.5); + // Tags + public static Tag.Named TEMPORAL_BAMBOO_PLANTABLE_ON = BlockTags.createOptional(new ResourceLocation( + Reference.ID, "temporal_bamboo_plantable_on")); + + public TemporalBambooBlock(final BlockBehaviour.Properties properties) + { + super(properties); + this.registerDefaultState(this.stateDefinition.any().setValue(BambooBlock.AGE, Integer.valueOf(0)).setValue( + BambooBlock.LEAVES, BambooLeaves.NONE).setValue(BambooBlock.STAGE, Integer.valueOf(0))); + } + + @Override + public VoxelShape getShape(final BlockState state, final BlockGetter block, final BlockPos pos, + final CollisionContext context) + { + final VoxelShape voxelshape = state.getValue(BambooBlock.AGE) == 1 ? TemporalBambooBlock.LARGE_SHAPE + : TemporalBambooBlock.SMALL_SHAPE; + final Vec3 vec3 = state.getOffset(block, pos); + return voxelshape.move(vec3.x, vec3.y, vec3.z); + } + + @Override + public VoxelShape getCollisionShape(final BlockState state, final BlockGetter block, final BlockPos pos, + final CollisionContext context) + { + final VoxelShape voxelshape = state.getValue(BambooBlock.AGE) == 1 ? TemporalBambooBlock.LARGE_SHAPE + : TemporalBambooBlock.SMALL_SHAPE; + final Vec3 vec3 = state.getOffset(block, pos); + return voxelshape.move(vec3.x, vec3.y, vec3.z); + } + + @Override + @Nullable + public BlockState getStateForPlacement(final BlockPlaceContext context) + { + final FluidState fluid = context.getLevel().getFluidState(context.getClickedPos()); + if (!fluid.isEmpty()) return null; + else + { + final BlockState state = context.getLevel().getBlockState(context.getClickedPos().below()); + if (state.is(TemporalBambooBlock.TEMPORAL_BAMBOO_PLANTABLE_ON) & !state.is(Blocks.BAMBOO_SAPLING)) { - return this.defaultBlockState().setValue(AGE, Integer.valueOf(0)); - } else if (state.is(PlantsInit.TEMPORAL_BAMBOO.get())) - { - int i = state.getValue(AGE) > 0 ? 1 : 0; - return this.defaultBlockState().setValue(AGE, Integer.valueOf(i)); - } else - { - BlockState state1 = context.getLevel().getBlockState(context.getClickedPos().above()); - return state1.is(PlantsInit.TEMPORAL_BAMBOO.get()) ? this.defaultBlockState().setValue(AGE, state1.getValue(AGE)) - : PlantsInit.TEMPORAL_BAMBOO_SHOOT.get().defaultBlockState(); + if (state.is(PlantsInit.TEMPORAL_BAMBOO_SHOOT.get())) return this.defaultBlockState().setValue( + BambooBlock.AGE, Integer.valueOf(0)); + else if (state.is(PlantsInit.TEMPORAL_BAMBOO.get())) + { + final int i = state.getValue(BambooBlock.AGE) > 0 ? 1 : 0; + return this.defaultBlockState().setValue(BambooBlock.AGE, Integer.valueOf(i)); + } + else + { + final BlockState state1 = context.getLevel().getBlockState(context.getClickedPos().above()); + return state1.is(PlantsInit.TEMPORAL_BAMBOO.get()) ? this.defaultBlockState().setValue( + BambooBlock.AGE, state1.getValue(BambooBlock.AGE)) + : PlantsInit.TEMPORAL_BAMBOO_SHOOT.get().defaultBlockState(); + } } - } else - { - return null; - } - } - } - - @Override - public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) - { - return world.getBlockState(pos.below()).is(TemporalBambooBlock.TEMPORAL_BAMBOO_PLANTABLE_ON); - } - - @Override - public BlockState updateShape(BlockState state, Direction direction, BlockState state1, LevelAccessor world, BlockPos pos, BlockPos pos1) - { - if (!state.canSurvive(world, pos)) - { - world.getBlockTicks().scheduleTick(pos, this, 1); - } - - if (direction == Direction.UP && state1.is(PlantsInit.TEMPORAL_BAMBOO.get()) && state1.getValue(AGE) > state.getValue(AGE)) - { - world.setBlock(pos, state.cycle(AGE), 2); - } - - return super.updateShape(state, direction, state1, world, pos, pos1); - } - - @Override - public void growBamboo(BlockState state, Level world, BlockPos pos, Random random, int x) - { - BlockState state1 = world.getBlockState(pos.below()); - BlockPos pos1 = pos.below(2); - BlockState state2 = world.getBlockState(pos1); - BambooLeaves leaves = BambooLeaves.NONE; - if (x >= 1) - { - if (state1.is(PlantsInit.TEMPORAL_BAMBOO.get()) && state1.getValue(LEAVES) != BambooLeaves.NONE) - { - if (state1.is(PlantsInit.TEMPORAL_BAMBOO.get()) && state1.getValue(LEAVES) != BambooLeaves.NONE) + else return null; + } + } + + @Override + public boolean canSurvive(final BlockState state, final LevelReader world, final BlockPos pos) + { + return world.getBlockState(pos.below()).is(TemporalBambooBlock.TEMPORAL_BAMBOO_PLANTABLE_ON); + } + + @Override + public BlockState updateShape(final BlockState state, final Direction direction, final BlockState state1, + final LevelAccessor world, final BlockPos pos, final BlockPos pos1) + { + if (!state.canSurvive(world, pos)) world.scheduleTick(pos, this, 1); + + if (direction == Direction.UP && state1.is(PlantsInit.TEMPORAL_BAMBOO.get()) && state1.getValue( + BambooBlock.AGE) > state.getValue(BambooBlock.AGE)) world.setBlock(pos, state.cycle(BambooBlock.AGE), + 2); + + return super.updateShape(state, direction, state1, world, pos, pos1); + } + + @Override + public void growBamboo(final BlockState state, final Level world, final BlockPos pos, final Random random, + final int x) + { + final BlockState state1 = world.getBlockState(pos.below()); + final BlockPos pos1 = pos.below(2); + final BlockState state2 = world.getBlockState(pos1); + BambooLeaves leaves = BambooLeaves.NONE; + if (x >= 1) if (state1.is(PlantsInit.TEMPORAL_BAMBOO.get()) && state1.getValue( + BambooBlock.LEAVES) != BambooLeaves.NONE) + { + if (state1.is(PlantsInit.TEMPORAL_BAMBOO.get()) && state1.getValue(BambooBlock.LEAVES) != BambooLeaves.NONE) { - leaves = BambooLeaves.LARGE; - if (state2.is(PlantsInit.TEMPORAL_BAMBOO.get())) - { - world.setBlock(pos.below(), state1.setValue(LEAVES, BambooLeaves.SMALL), 3); - world.setBlock(pos1, state2.setValue(LEAVES, BambooLeaves.NONE), 3); - } + leaves = BambooLeaves.LARGE; + if (state2.is(PlantsInit.TEMPORAL_BAMBOO.get())) + { + world.setBlock(pos.below(), state1.setValue(BambooBlock.LEAVES, BambooLeaves.SMALL), 3); + world.setBlock(pos1, state2.setValue(BambooBlock.LEAVES, BambooLeaves.NONE), 3); + } } - } else - { - leaves = BambooLeaves.SMALL; - } - } - - int i = state.getValue(AGE) != 1 && !state2.is(PlantsInit.TEMPORAL_BAMBOO.get()) ? 0 : 1; - int j = (x < 11 || !(random.nextFloat() < 0.25F)) && x != 15 ? 0 : 1; - world.setBlock(pos.above(), this.defaultBlockState().setValue(AGE, Integer.valueOf(i)).setValue(LEAVES, leaves) - .setValue(STAGE, Integer.valueOf(j)), 3); - } - - @Override - public int getHeightAboveUpToMax(BlockGetter block, BlockPos pos) - { - int i; - for(i = 0; i < 16 && block.getBlockState(pos.above(i + 1)).is(PlantsInit.TEMPORAL_BAMBOO.get()); ++i) - { - } - - return i; - } - - @Override - public int getHeightBelowUpToMax(BlockGetter block, BlockPos pos) - { - int i; - for(i = 0; i < 16 && block.getBlockState(pos.below(i + 1)).is(PlantsInit.TEMPORAL_BAMBOO.get()); ++i) - {} - return i; - } + } + else leaves = BambooLeaves.SMALL; + + final int i = state.getValue(BambooBlock.AGE) != 1 && !state2.is(PlantsInit.TEMPORAL_BAMBOO.get()) ? 0 : 1; + final int j = (x < 11 || !(random.nextFloat() < 0.25F)) && x != 15 ? 0 : 1; + world.setBlock(pos.above(), this.defaultBlockState().setValue(BambooBlock.AGE, Integer.valueOf(i)).setValue( + BambooBlock.LEAVES, leaves).setValue(BambooBlock.STAGE, Integer.valueOf(j)), 3); + } + + @Override + public int getHeightAboveUpToMax(final BlockGetter block, final BlockPos pos) + { + int i; + for (i = 0; i < 16 && block.getBlockState(pos.above(i + 1)).is(PlantsInit.TEMPORAL_BAMBOO.get()); ++i) + { + } + + return i; + } + + @Override + public int getHeightBelowUpToMax(final BlockGetter block, final BlockPos pos) + { + int i; + for (i = 0; i < 16 && block.getBlockState(pos.below(i + 1)).is(PlantsInit.TEMPORAL_BAMBOO.get()); ++i) + { + } + return i; + } } diff --git a/src/main/java/pokecube/legends/entity/WormholeEntity.java b/src/main/java/pokecube/legends/entity/WormholeEntity.java index 093856ccdc..a2ca7109d2 100644 --- a/src/main/java/pokecube/legends/entity/WormholeEntity.java +++ b/src/main/java/pokecube/legends/entity/WormholeEntity.java @@ -45,7 +45,7 @@ import net.minecraftforge.energy.EnergyStorage; import net.minecraftforge.energy.IEnergyStorage; import net.minecraftforge.event.entity.EntityTeleportEvent; -import net.minecraftforge.fmllegacy.network.NetworkHooks; +import net.minecraftforge.network.NetworkHooks; import pokecube.core.PokecubeCore; import pokecube.core.handlers.events.EventsHandler; import pokecube.core.interfaces.IPokemob; diff --git a/src/main/java/pokecube/legends/init/BlockInit.java b/src/main/java/pokecube/legends/init/BlockInit.java index 8600f4f21a..b639cd4a41 100644 --- a/src/main/java/pokecube/legends/init/BlockInit.java +++ b/src/main/java/pokecube/legends/init/BlockInit.java @@ -33,7 +33,7 @@ import net.minecraft.world.level.material.MaterialColor; import net.minecraft.world.phys.shapes.Shapes; import net.minecraftforge.fml.event.lifecycle.FMLLoadCompleteEvent; -import net.minecraftforge.fmllegacy.RegistryObject; +import net.minecraftforge.registries.RegistryObject; import pokecube.core.PokecubeItems; import pokecube.core.handlers.ItemGenerator; import pokecube.core.handlers.ItemGenerator.GenericStairs; diff --git a/src/main/java/pokecube/legends/init/ClientSetupHandler.java b/src/main/java/pokecube/legends/init/ClientSetupHandler.java index ab10afb402..05167a6f7e 100644 --- a/src/main/java/pokecube/legends/init/ClientSetupHandler.java +++ b/src/main/java/pokecube/legends/init/ClientSetupHandler.java @@ -17,12 +17,12 @@ import net.minecraft.world.phys.shapes.Shapes; import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.client.event.ParticleFactoryRegisterEvent; import net.minecraftforge.client.event.EntityRenderersEvent.RegisterRenderers; +import net.minecraftforge.client.event.ParticleFactoryRegisterEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; -import net.minecraftforge.fmllegacy.RegistryObject; +import net.minecraftforge.registries.RegistryObject; import pokecube.core.handlers.ItemGenerator; import pokecube.legends.PokecubeLegends; import pokecube.legends.Reference; diff --git a/src/main/java/pokecube/legends/init/ContainerInit.java b/src/main/java/pokecube/legends/init/ContainerInit.java index b73372fe1c..117d923e00 100644 --- a/src/main/java/pokecube/legends/init/ContainerInit.java +++ b/src/main/java/pokecube/legends/init/ContainerInit.java @@ -1,7 +1,7 @@ package pokecube.legends.init; import net.minecraft.world.inventory.MenuType; -import net.minecraftforge.fmllegacy.RegistryObject; +import net.minecraftforge.registries.RegistryObject; import pokecube.legends.PokecubeLegends; import pokecube.legends.tileentity.CustomBarrelContainer; diff --git a/src/main/java/pokecube/legends/init/EntityInit.java b/src/main/java/pokecube/legends/init/EntityInit.java index 34c4a498d1..5069c6443d 100644 --- a/src/main/java/pokecube/legends/init/EntityInit.java +++ b/src/main/java/pokecube/legends/init/EntityInit.java @@ -5,7 +5,7 @@ import net.minecraft.world.entity.MobCategory; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.AttachCapabilitiesEvent; -import net.minecraftforge.fmllegacy.RegistryObject; +import net.minecraftforge.registries.RegistryObject; import pokecube.adventures.utils.EnergyHandler; import pokecube.legends.PokecubeLegends; import pokecube.legends.entity.WormholeEntity; diff --git a/src/main/java/pokecube/legends/init/FluidInit.java b/src/main/java/pokecube/legends/init/FluidInit.java index aa8e2bd41a..fd4ffa16bf 100644 --- a/src/main/java/pokecube/legends/init/FluidInit.java +++ b/src/main/java/pokecube/legends/init/FluidInit.java @@ -6,7 +6,7 @@ import net.minecraft.world.level.material.Material; import net.minecraft.world.level.material.MaterialColor; import net.minecraftforge.fluids.ForgeFlowingFluid; -import net.minecraftforge.fmllegacy.RegistryObject; +import net.minecraftforge.registries.RegistryObject; import pokecube.legends.PokecubeLegends; import pokecube.legends.fluids.DistorticWater; diff --git a/src/main/java/pokecube/legends/init/ItemInit.java b/src/main/java/pokecube/legends/init/ItemInit.java index 0843d8479a..63a3337117 100644 --- a/src/main/java/pokecube/legends/init/ItemInit.java +++ b/src/main/java/pokecube/legends/init/ItemInit.java @@ -20,7 +20,7 @@ import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.event.RegistryEvent; -import net.minecraftforge.fmllegacy.RegistryObject; +import net.minecraftforge.registries.RegistryObject; import pokecube.core.PokecubeItems; import pokecube.core.interfaces.Nature; import pokecube.core.utils.PokeType; diff --git a/src/main/java/pokecube/legends/init/ParticleInit.java b/src/main/java/pokecube/legends/init/ParticleInit.java index f72c57d832..52fe005c16 100644 --- a/src/main/java/pokecube/legends/init/ParticleInit.java +++ b/src/main/java/pokecube/legends/init/ParticleInit.java @@ -2,7 +2,7 @@ import net.minecraft.core.particles.SimpleParticleType; import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fmllegacy.RegistryObject; +import net.minecraftforge.registries.RegistryObject; import pokecube.legends.PokecubeLegends; import pokecube.legends.Reference; diff --git a/src/main/java/pokecube/legends/init/PlantsInit.java b/src/main/java/pokecube/legends/init/PlantsInit.java index d63be6c7e8..e1c7debb37 100644 --- a/src/main/java/pokecube/legends/init/PlantsInit.java +++ b/src/main/java/pokecube/legends/init/PlantsInit.java @@ -8,7 +8,7 @@ import net.minecraft.world.level.block.state.BlockBehaviour; import net.minecraft.world.level.material.Material; import net.minecraft.world.level.material.MaterialColor; -import net.minecraftforge.fmllegacy.RegistryObject; +import net.minecraftforge.registries.RegistryObject; import pokecube.legends.PokecubeLegends; import pokecube.legends.blocks.FlowerBase; import pokecube.legends.blocks.MushroomBase; diff --git a/src/main/java/pokecube/legends/init/TileEntityInit.java b/src/main/java/pokecube/legends/init/TileEntityInit.java index 39252921e7..d34bc84d40 100644 --- a/src/main/java/pokecube/legends/init/TileEntityInit.java +++ b/src/main/java/pokecube/legends/init/TileEntityInit.java @@ -1,7 +1,7 @@ package pokecube.legends.init; import net.minecraft.world.level.block.entity.BlockEntityType; -import net.minecraftforge.fmllegacy.RegistryObject; +import net.minecraftforge.registries.RegistryObject; import pokecube.legends.PokecubeLegends; import pokecube.legends.tileentity.GenericBarrelTile; import pokecube.legends.tileentity.GenericBookshelfEmptyTile; diff --git a/src/main/java/pokecube/legends/items/tools/ZamazentaShieldItem.java b/src/main/java/pokecube/legends/items/tools/ZamazentaShieldItem.java index eee0ff7605..df9149996d 100644 --- a/src/main/java/pokecube/legends/items/tools/ZamazentaShieldItem.java +++ b/src/main/java/pokecube/legends/items/tools/ZamazentaShieldItem.java @@ -9,7 +9,6 @@ import net.minecraft.network.chat.TranslatableComponent; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResultHolder; -import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ArmorItem; import net.minecraft.world.item.ItemStack; @@ -27,8 +26,8 @@ public class ZamazentaShieldItem extends ShieldItem { public final Tier tier; String tooltipname; boolean hasTooltip = false; - - public ZamazentaShieldItem(final Tier material, String name, Properties properties) { + + public ZamazentaShieldItem(final Tier material, final String name, final Properties properties) { super(properties); DispenserBlock.registerBehavior(this, ArmorItem.DISPENSE_ITEM_BEHAVIOR); this.tier = material; @@ -36,30 +35,33 @@ public ZamazentaShieldItem(final Tier material, String name, Properties properti this.tooltipname = name; } - public String getDescriptionId(ItemStack stack) { - return stack.getTagElement("BlockEntityTag") != null ? this.getDescriptionId() + '.' + getColor(stack).getName() : super.getDescriptionId(stack); + @Override + public String getDescriptionId(final ItemStack stack) { + return stack.getTagElement("BlockEntityTag") != null ? this.getDescriptionId() + '.' + ShieldItem.getColor(stack).getName() : super.getDescriptionId(stack); } - public UseAnim getUseAnimation(ItemStack stack) { + @Override + public UseAnim getUseAnimation(final ItemStack stack) { return UseAnim.BLOCK; } - public InteractionResultHolder use(Level world, Player playerIn, InteractionHand hand) { - ItemStack itemstack = playerIn.getItemInHand(hand); + @Override + public InteractionResultHolder use(final Level world, final Player playerIn, final InteractionHand hand) { + final ItemStack itemstack = playerIn.getItemInHand(hand); playerIn.startUsingItem(hand); return InteractionResultHolder.consume(itemstack); } @Override - public boolean isValidRepairItem(ItemStack item, ItemStack repair) { + public boolean isValidRepairItem(final ItemStack item, final ItemStack repair) { return this.tier.getRepairIngredient().test(repair) || super.isValidRepairItem(item, repair); } - + @Override - public boolean isShield(ItemStack stack, LivingEntity entity) { - return true; - } - + public boolean canPerformAction(final ItemStack stack, final net.minecraftforge.common.ToolAction toolAction) { + return net.minecraftforge.common.ToolActions.DEFAULT_SHIELD_ACTIONS.contains(toolAction); + } + @Override @OnlyIn(Dist.CLIENT) public void appendHoverText(final ItemStack stack, final Level worldIn, final List tooltip, diff --git a/src/main/java/pokecube/legends/recipes/LegendsDistorticRecipeManager.java b/src/main/java/pokecube/legends/recipes/LegendsDistorticRecipeManager.java index 32fd6d9bc0..e2576583a5 100644 --- a/src/main/java/pokecube/legends/recipes/LegendsDistorticRecipeManager.java +++ b/src/main/java/pokecube/legends/recipes/LegendsDistorticRecipeManager.java @@ -13,8 +13,8 @@ import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.fml.util.ObfuscationReflectionHelper; -import net.minecraftforge.fmllegacy.RegistryObject; import net.minecraftforge.items.ItemHandlerHelper; +import net.minecraftforge.registries.RegistryObject; import pokecube.legends.PokecubeLegends; import pokecube.legends.recipes.LegendsDistorticRecipeSerializer.SerializerDistortic; diff --git a/src/main/java/pokecube/legends/recipes/LegendsLootingRecipeManager.java b/src/main/java/pokecube/legends/recipes/LegendsLootingRecipeManager.java index 401a0a4e3a..3f62aaade9 100644 --- a/src/main/java/pokecube/legends/recipes/LegendsLootingRecipeManager.java +++ b/src/main/java/pokecube/legends/recipes/LegendsLootingRecipeManager.java @@ -15,8 +15,8 @@ import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.fml.util.ObfuscationReflectionHelper; -import net.minecraftforge.fmllegacy.RegistryObject; import net.minecraftforge.items.ItemHandlerHelper; +import net.minecraftforge.registries.RegistryObject; import pokecube.legends.PokecubeLegends; import pokecube.legends.recipes.LegendsLootingRecipeSerializer.SerializerLooting; diff --git a/src/main/java/pokecube/legends/spawns/LegendarySpawn.java b/src/main/java/pokecube/legends/spawns/LegendarySpawn.java index 34050526d2..7e44219241 100644 --- a/src/main/java/pokecube/legends/spawns/LegendarySpawn.java +++ b/src/main/java/pokecube/legends/spawns/LegendarySpawn.java @@ -19,7 +19,7 @@ import net.minecraftforge.eventbus.api.Event.Result; import net.minecraftforge.eventbus.api.EventPriority; import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.fmllegacy.RegistryObject; +import net.minecraftforge.registries.RegistryObject; import pokecube.core.PokecubeCore; import pokecube.core.database.Database; import pokecube.core.database.PokedexEntry; diff --git a/src/main/java/pokecube/legends/tileentity/GenericBarrelTile.java b/src/main/java/pokecube/legends/tileentity/GenericBarrelTile.java index e8e56659cd..43883211c3 100644 --- a/src/main/java/pokecube/legends/tileentity/GenericBarrelTile.java +++ b/src/main/java/pokecube/legends/tileentity/GenericBarrelTile.java @@ -113,7 +113,7 @@ public void startOpen(final Player player) private void scheduleRecheck() { - this.level.getBlockTicks().scheduleTick(this.getBlockPos(), this.getBlockState().getBlock(), 5); + this.level.scheduleTick(this.getBlockPos(), this.getBlockState().getBlock(), 5); } public void recheckOpen() diff --git a/src/main/java/pokecube/legends/worldgen/WorldgenFeatures.java b/src/main/java/pokecube/legends/worldgen/WorldgenFeatures.java index 4f499dbde1..36199a86fd 100644 --- a/src/main/java/pokecube/legends/worldgen/WorldgenFeatures.java +++ b/src/main/java/pokecube/legends/worldgen/WorldgenFeatures.java @@ -12,9 +12,9 @@ import net.minecraft.world.level.levelgen.surfacebuilders.SurfaceBuilder; import net.minecraft.world.level.levelgen.surfacebuilders.SurfaceBuilderBaseConfiguration; import net.minecraftforge.eventbus.api.IEventBus; -import net.minecraftforge.fmllegacy.RegistryObject; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; +import net.minecraftforge.registries.RegistryObject; import pokecube.legends.Reference; import pokecube.legends.worldgen.features.BasaltColumnsFeature; import pokecube.legends.worldgen.features.CrystallizedSandstoneBouldersFeature; diff --git a/src/main/java/pokecube/legends/worldgen/features/LakeFeature.java b/src/main/java/pokecube/legends/worldgen/features/LakeFeature.java index 50cd2140ac..5b4f0b39e8 100644 --- a/src/main/java/pokecube/legends/worldgen/features/LakeFeature.java +++ b/src/main/java/pokecube/legends/worldgen/features/LakeFeature.java @@ -12,7 +12,6 @@ import net.minecraft.world.level.biome.Biome; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.levelgen.BaseStoneSource; import net.minecraft.world.level.levelgen.feature.Feature; import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext; import net.minecraft.world.level.levelgen.feature.StructureFeature; @@ -101,7 +100,7 @@ public boolean place(final FeaturePlaceContext context) world.setBlock(pos1, flag1 ? LakeFeature.AIR : stateConfig.state, 2); if (flag1) { - world.getBlockTicks().scheduleTick(pos1, LakeFeature.AIR.getBlock(), 0); + world.scheduleTick(pos1, LakeFeature.AIR.getBlock(), 0); this.markAboveForPostProcessing(world, pos1); } } diff --git a/src/main/java/pokecube/legends/worldgen/features/TaintedKelpFeature.java b/src/main/java/pokecube/legends/worldgen/features/TaintedKelpFeature.java index 0e114815d8..f29b254901 100644 --- a/src/main/java/pokecube/legends/worldgen/features/TaintedKelpFeature.java +++ b/src/main/java/pokecube/legends/worldgen/features/TaintedKelpFeature.java @@ -1,6 +1,7 @@ package pokecube.legends.worldgen.features; import java.util.Random; + import com.mojang.serialization.Codec; import net.minecraft.core.BlockPos; diff --git a/src/main/java/pokecube/legends/worldgen/features/TemporalBambooFeature.java b/src/main/java/pokecube/legends/worldgen/features/TemporalBambooFeature.java index f0d21b1834..92f10a44d4 100644 --- a/src/main/java/pokecube/legends/worldgen/features/TemporalBambooFeature.java +++ b/src/main/java/pokecube/legends/worldgen/features/TemporalBambooFeature.java @@ -1,6 +1,7 @@ package pokecube.legends.worldgen.features; import java.util.Random; + import com.mojang.serialization.Codec; import net.minecraft.core.BlockPos; diff --git a/src/main/java/pokecube/mixin/MixinLakesFeature.java b/src/main/java/pokecube/mixin/MixinLakesFeature.java index 2214ffc2a0..5f6206dff3 100644 --- a/src/main/java/pokecube/mixin/MixinLakesFeature.java +++ b/src/main/java/pokecube/mixin/MixinLakesFeature.java @@ -15,6 +15,7 @@ import net.minecraft.world.level.levelgen.feature.configurations.BlockStateConfiguration; import pokecube.core.PokecubeCore; +@SuppressWarnings("deprecation") @Mixin(LakeFeature.class) public abstract class MixinLakesFeature extends Feature { @@ -40,7 +41,7 @@ private void checkForRSVillages(final FeaturePlaceContext context, final Call { if (!PokecubeCore.getConfig().lakeFeatureMixin) return; for (final StructureFeature village : StructureFeature.NOISE_AFFECTING_FEATURES) - if (context.level().startsForFeature(SectionPos.of(context.origin()), village).findAny().isPresent()) + if (!context.level().startsForFeature(SectionPos.of(context.origin()), village).isEmpty()) { cir.setReturnValue(false); break; diff --git a/src/main/java/pokecube/mobs/moves/world/ActionNaturePower.java b/src/main/java/pokecube/mobs/moves/world/ActionNaturePower.java index 1c0c522ba2..9402529790 100644 --- a/src/main/java/pokecube/mobs/moves/world/ActionNaturePower.java +++ b/src/main/java/pokecube/mobs/moves/world/ActionNaturePower.java @@ -145,7 +145,7 @@ public boolean apply(final BlockPos pos, final ServerLevel world) public static class HillsChanger implements IBiomeChanger { - static final ResourceKey HILLS = Biomes.MOUNTAINS; + static final ResourceKey HILLS = Biomes.STONY_PEAKS; public HillsChanger() { @@ -402,8 +402,9 @@ public boolean apply(final BlockPos pos, final ServerLevel world) { vec.addTo(i, 0, j); final Biome here = vec.getBiome(world); + // TODO climate sampler final Biome natural = world.getChunkSource().getGenerator().getBiomeSource().getNoiseBiome(vec - .intX(), vec.intY(), vec.intZ()); + .intX(), vec.intY(), vec.intZ(), null); if (natural != here) { vec.setBiome(natural, world); diff --git a/src/main/java/pokecube/nbtedit/forge/ClientProxy.java b/src/main/java/pokecube/nbtedit/forge/ClientProxy.java index bacaedf7b1..b291e4e967 100644 --- a/src/main/java/pokecube/nbtedit/forge/ClientProxy.java +++ b/src/main/java/pokecube/nbtedit/forge/ClientProxy.java @@ -17,10 +17,10 @@ import net.minecraft.world.phys.HitResult; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraftforge.client.ClientRegistry; import net.minecraftforge.client.event.InputEvent; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.fmlclient.registry.ClientRegistry; import pokecube.core.PokecubeCore; import pokecube.nbtedit.NBTEdit; import pokecube.nbtedit.gui.GuiEditNBTTree; diff --git a/src/main/java/pokecube/nbtedit/forge/CommonProxy.java b/src/main/java/pokecube/nbtedit/forge/CommonProxy.java index 73000709d7..05d9c25118 100644 --- a/src/main/java/pokecube/nbtedit/forge/CommonProxy.java +++ b/src/main/java/pokecube/nbtedit/forge/CommonProxy.java @@ -12,6 +12,7 @@ import net.minecraft.network.chat.Component; import net.minecraft.network.chat.TextColor; import net.minecraft.network.chat.TextComponent; +import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.player.Player; import net.minecraftforge.fml.loading.FMLPaths; @@ -83,4 +84,18 @@ public void setupClient() { } + + private MinecraftServer server; + + @Override + public void setServer(final MinecraftServer server) + { + this.server = server; + } + + @Override + public MinecraftServer getServer() + { + return this.server; + } } diff --git a/src/main/java/pokecube/nbtedit/gui/GuiCharacterButton.java b/src/main/java/pokecube/nbtedit/gui/GuiCharacterButton.java index e0eef1f999..70f648b904 100644 --- a/src/main/java/pokecube/nbtedit/gui/GuiCharacterButton.java +++ b/src/main/java/pokecube/nbtedit/gui/GuiCharacterButton.java @@ -32,7 +32,7 @@ public void render(final PoseStack mat, final int mx, final int my, final float RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); RenderSystem.setShaderTexture(0, GuiNBTNode.WIDGET_TEXTURE); - if (this.isHovered()) GuiComponent.fill(mat, this.x, this.y, this.x + GuiCharacterButton.WIDTH, this.y + if (this.isHoveredOrFocused()) GuiComponent.fill(mat, this.x, this.y, this.x + GuiCharacterButton.WIDTH, this.y + GuiCharacterButton.HEIGHT, 0x80ffffff); if (this.active) RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); diff --git a/src/main/java/pokecube/nbtedit/gui/GuiNBTButton.java b/src/main/java/pokecube/nbtedit/gui/GuiNBTButton.java index ee6a5bc677..6ac90b4a81 100644 --- a/src/main/java/pokecube/nbtedit/gui/GuiNBTButton.java +++ b/src/main/java/pokecube/nbtedit/gui/GuiNBTButton.java @@ -45,7 +45,7 @@ public byte getId() public void renderButton(final PoseStack mat, final int mx, final int my, final float tick) { // check if the mouse is over the button - if (this.isHovered()) + if (this.isHoveredOrFocused()) { // Draw a background GuiComponent.fill(mat, this.x, this.y, this.x + GuiNBTButton.WIDTH, this.y + GuiNBTButton.HEIGHT, 0x80ffffff); diff --git a/src/main/java/pokecube/nbtedit/gui/GuiNBTNode.java b/src/main/java/pokecube/nbtedit/gui/GuiNBTNode.java index 10c4599846..0e56d28767 100644 --- a/src/main/java/pokecube/nbtedit/gui/GuiNBTNode.java +++ b/src/main/java/pokecube/nbtedit/gui/GuiNBTNode.java @@ -77,7 +77,7 @@ public void render(final PoseStack mat, final int mx, final int my, final float this.x2 = mx; this.y2 = my; final boolean selected = this.tree.focusedNode() == this.node; - final boolean hover = this.isHovered(); + final boolean hover = this.isHoveredOrFocused(); final boolean chHover = this.inHideShowBounds(); final int color = selected ? 0xff : hover ? 16777120 : this.node.hasParent() ? 14737632 : -6250336; final int dx = this.node.hasChildren() ? 10 : 0; diff --git a/src/main/java/pokecube/nbtedit/gui/GuiNBTTree.java b/src/main/java/pokecube/nbtedit/gui/GuiNBTTree.java index 7f1ff5fea5..2aba02a90c 100644 --- a/src/main/java/pokecube/nbtedit/gui/GuiNBTTree.java +++ b/src/main/java/pokecube/nbtedit/gui/GuiNBTTree.java @@ -616,7 +616,7 @@ public void render(final PoseStack mat, final int mx, final int my, final float public boolean rightClick(final double x, final double y2, final int t) { for (int i = 0; i < 7; ++i) - if (this.saves[i].isHovered()) + if (this.saves[i].isHoveredOrFocused()) { this.setFocusedNode(null); if (this.focusedSlotIndex != -1) if (this.focusedSlotIndex != i) diff --git a/src/main/java/pokecube/nbtedit/gui/GuiSaveSlotButton.java b/src/main/java/pokecube/nbtedit/gui/GuiSaveSlotButton.java index b60fe9f072..5ff57375e1 100644 --- a/src/main/java/pokecube/nbtedit/gui/GuiSaveSlotButton.java +++ b/src/main/java/pokecube/nbtedit/gui/GuiSaveSlotButton.java @@ -74,7 +74,7 @@ public boolean charTyped(final char c, final int key) public void draw(final PoseStack mat, final int mx, final int my) { - int textColor = this.isHovered() ? 16777120 : 0xffffff; + int textColor = this.isHoveredOrFocused() ? 16777120 : 0xffffff; this.renderVanillaButton(mat, this.x, this.y, 0, 66, this.width, GuiSaveSlotButton.HEIGHT); GuiComponent.drawCenteredString(mat, this.mc.font, this.getMessage(), this.x + this.width / 2, this.y + 6, textColor); diff --git a/src/main/java/thut/api/ThutCaps.java b/src/main/java/thut/api/ThutCaps.java index 321fb0fe84..b3fbfdd1dc 100644 --- a/src/main/java/thut/api/ThutCaps.java +++ b/src/main/java/thut/api/ThutCaps.java @@ -14,8 +14,8 @@ import thut.api.entity.IMobTexturable; import thut.api.entity.IShearable; import thut.api.entity.genetics.IMobGenetics; -import thut.api.terrain.ITerrainAffected; import thut.api.terrain.CapabilityTerrain.ITerrainProvider; +import thut.api.terrain.ITerrainAffected; import thut.api.world.mobs.data.DataSync; public class ThutCaps diff --git a/src/main/java/thut/api/Tracker.java b/src/main/java/thut/api/Tracker.java index 88ef806b71..abd2b99899 100644 --- a/src/main/java/thut/api/Tracker.java +++ b/src/main/java/thut/api/Tracker.java @@ -15,10 +15,9 @@ import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.TickEvent.Phase; import net.minecraftforge.event.TickEvent.ServerTickEvent; +import net.minecraftforge.event.server.ServerStartedEvent; import net.minecraftforge.event.world.WorldEvent; -import net.minecraftforge.fml.LogicalSide; -import net.minecraftforge.fmllegacy.LogicalSidedProvider; -import net.minecraftforge.fmlserverevents.FMLServerStartedEvent; +import thut.core.common.ThutCore; public class Tracker { @@ -55,7 +54,7 @@ private static void onServerTick(final ServerTickEvent event) } // Load the time and set it. - private static void onServerStart(final FMLServerStartedEvent event) + private static void onServerStart(final ServerStartedEvent event) { final MinecraftServer server = event.getServer(); Path path = server.getWorldPath(new LevelResource("thutcore")); @@ -89,7 +88,7 @@ private static void onWorldSave(final WorldEvent.Save event) final ServerLevel world = (ServerLevel) event.getWorld(); if (world.dimension() != Level.OVERWORLD) return; - final MinecraftServer server = LogicalSidedProvider.INSTANCE.get(LogicalSide.SERVER); + final MinecraftServer server = ThutCore.proxy.getServer(); Path path = server.getWorldPath(new LevelResource("thutcore")); final File dir = path.toFile(); // and this if the file itself diff --git a/src/main/java/thut/api/entity/IAnimated.java b/src/main/java/thut/api/entity/IAnimated.java index cdceb19e7a..9504789fc6 100644 --- a/src/main/java/thut/api/entity/IAnimated.java +++ b/src/main/java/thut/api/entity/IAnimated.java @@ -2,8 +2,9 @@ import java.util.List; -import net.minecraft.world.entity.Entity; import javax.annotation.Nonnull; + +import net.minecraft.world.entity.Entity; import thut.api.entity.animation.Animation; public interface IAnimated diff --git a/src/main/java/thut/api/entity/blockentity/BlockEntityBase.java b/src/main/java/thut/api/entity/blockentity/BlockEntityBase.java index 6d1ca68fb0..6e28a56472 100644 --- a/src/main/java/thut/api/entity/blockentity/BlockEntityBase.java +++ b/src/main/java/thut/api/entity/blockentity/BlockEntityBase.java @@ -37,9 +37,9 @@ import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.fmllegacy.common.registry.IEntityAdditionalSpawnData; -import net.minecraftforge.fmllegacy.network.FMLPlayMessages.SpawnEntity; -import net.minecraftforge.fmllegacy.network.NetworkHooks; +import net.minecraftforge.entity.IEntityAdditionalSpawnData; +import net.minecraftforge.network.NetworkHooks; +import net.minecraftforge.network.PlayMessages.SpawnEntity; import thut.api.entity.blockentity.block.TempTile; import thut.api.entity.blockentity.world.IBlockEntityWorld; import thut.api.entity.blockentity.world.WorldEntity; diff --git a/src/main/java/thut/api/entity/blockentity/world/BlockEntityChunkProvider.java b/src/main/java/thut/api/entity/blockentity/world/BlockEntityChunkProvider.java index 3d3245a33d..e042aae01f 100644 --- a/src/main/java/thut/api/entity/blockentity/world/BlockEntityChunkProvider.java +++ b/src/main/java/thut/api/entity/blockentity/world/BlockEntityChunkProvider.java @@ -6,6 +6,7 @@ import com.google.common.collect.Maps; import net.minecraft.core.BlockPos; +import net.minecraft.core.Registry; import net.minecraft.world.entity.Entity; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.ChunkPos; @@ -73,7 +74,8 @@ public ChunkAccess getChunk(final int chunkX, final int chunkZ, final ChunkStatu LevelChunkSection storage = ret.getSections()[j >> 4]; if (storage == null) { - storage = new LevelChunkSection(j >> 4 << 4); + storage = new LevelChunkSection(j >> 4 << 4, this.world.world.registryAccess().registryOrThrow( + Registry.BIOME_REGISTRY)); ret.getSections()[j >> 4] = storage; } storage.setBlockState(i & 15, j & 15, k & 15, state, false); diff --git a/src/main/java/thut/api/entity/blockentity/world/EntityChunk.java b/src/main/java/thut/api/entity/blockentity/world/EntityChunk.java index a37cf66386..692a616ae1 100644 --- a/src/main/java/thut/api/entity/blockentity/world/EntityChunk.java +++ b/src/main/java/thut/api/entity/blockentity/world/EntityChunk.java @@ -10,7 +10,6 @@ import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.chunk.ChunkBiomeContainer; import net.minecraft.world.level.chunk.LevelChunk; import net.minecraft.world.level.chunk.ProtoChunk; import net.minecraft.world.level.chunk.UpgradeData; @@ -22,7 +21,7 @@ public static class EntityChunkPrimer extends ProtoChunk { public EntityChunkPrimer(final ChunkPos pos, final LevelHeightAccessor access) { - super(pos, new UpgradeData(new CompoundTag(), access), access); + super(pos, new UpgradeData(new CompoundTag(), access), access, null, null); } } @@ -30,7 +29,7 @@ public EntityChunkPrimer(final ChunkPos pos, final LevelHeightAccessor access) public EntityChunk(final IBlockEntityWorld worldIn_, final ChunkPos pos) { - super((Level) worldIn_, pos, worldIn_.getChunk(pos.x, pos.z).getBiomes()); + super((Level) worldIn_, pos); this.worldE = worldIn_; } @@ -91,12 +90,6 @@ public void setBlockEntity(final BlockEntity tile) } } - @Override - public ChunkBiomeContainer getBiomes() - { - return super.getBiomes(); - } - @Override public BlockEntity getBlockEntity(final BlockPos pos) { diff --git a/src/main/java/thut/api/entity/blockentity/world/WorldEntity.java b/src/main/java/thut/api/entity/blockentity/world/WorldEntity.java index f32a090256..351dae5c29 100644 --- a/src/main/java/thut/api/entity/blockentity/world/WorldEntity.java +++ b/src/main/java/thut/api/entity/blockentity/world/WorldEntity.java @@ -17,7 +17,6 @@ import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.Level; import net.minecraft.world.level.LightLayer; -import net.minecraft.world.level.TickList; import net.minecraft.world.level.biome.Biome; import net.minecraft.world.level.biome.BiomeManager; import net.minecraft.world.level.block.Block; @@ -36,6 +35,7 @@ import net.minecraft.world.level.material.FluidState; import net.minecraft.world.level.storage.LevelData; import net.minecraft.world.phys.AABB; +import net.minecraft.world.ticks.LevelTickAccess; import thut.api.entity.blockentity.IBlockEntity; public class WorldEntity implements IBlockEntityWorld @@ -106,18 +106,6 @@ public FluidState getFluidState(final BlockPos pos) return this.world.getFluidState(pos); } - @Override - public TickList getBlockTicks() - { - return this.world.getBlockTicks(); - } - - @Override - public TickList getLiquidTicks() - { - return this.world.getLiquidTicks(); - } - @Override public void levelEvent(final Player player, final int type, final BlockPos pos, final int data) { @@ -314,4 +302,23 @@ public boolean isFluidAtPosition(final BlockPos p_151584_, final Predicate getBlockTicks() + { + return this.world.getBlockTicks(); + } + + @Override + public LevelTickAccess getFluidTicks() + { + return this.world.getFluidTicks(); + } } \ No newline at end of file diff --git a/src/main/java/thut/api/inventory/big/Manager.java b/src/main/java/thut/api/inventory/big/Manager.java index ff3074fef8..3a22582715 100644 --- a/src/main/java/thut/api/inventory/big/Manager.java +++ b/src/main/java/thut/api/inventory/big/Manager.java @@ -18,10 +18,8 @@ import net.minecraft.world.entity.Entity; import net.minecraft.world.item.ItemStack; import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.server.ServerAboutToStartEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.fml.LogicalSide; -import net.minecraftforge.fmllegacy.LogicalSidedProvider; -import net.minecraftforge.fmlserverevents.FMLServerAboutToStartEvent; import thut.api.inventory.big.BigInventory.LoadFactory; import thut.api.inventory.big.BigInventory.NewFactory; import thut.core.common.ThutCore; @@ -89,7 +87,7 @@ protected void save(final UUID uuid) if (ThutCore.proxy.isClientSide()) return; final T save = this.get(uuid, false); if (save == null || !save.dirty) return; - final MinecraftServer server = LogicalSidedProvider.INSTANCE.get(LogicalSide.SERVER); + final MinecraftServer server = ThutCore.proxy.getServer(); try { @@ -154,7 +152,7 @@ public void clear() } @SubscribeEvent - protected void serverStarting(final FMLServerAboutToStartEvent event) + protected void serverStarting(final ServerAboutToStartEvent event) { this.clear(); } diff --git a/src/main/java/thut/api/particle/ParticleHandler.java b/src/main/java/thut/api/particle/ParticleHandler.java index 93cd4a52b4..b6468561f3 100644 --- a/src/main/java/thut/api/particle/ParticleHandler.java +++ b/src/main/java/thut/api/particle/ParticleHandler.java @@ -10,7 +10,7 @@ import net.minecraft.world.entity.player.Player; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.client.event.RenderWorldLastEvent; +import net.minecraftforge.client.event.RenderLevelLastEvent; import net.minecraftforge.event.world.WorldEvent.Unload; import net.minecraftforge.eventbus.api.SubscribeEvent; import thut.api.maths.Vector3; @@ -53,13 +53,13 @@ public static void clear() @OnlyIn(Dist.CLIENT) @SubscribeEvent - public static void onRenderWorldPost(final RenderWorldLastEvent event) + public static void onRenderWorldPost(final RenderLevelLastEvent event) { try { synchronized (ParticleHandler.particles) { - final PoseStack mat = event.getMatrixStack(); + final PoseStack mat = event.getPoseStack(); mat.pushPose(); final List list = Lists.newArrayList(); for (int i = 0; i < ParticleHandler.particles.size(); i++) @@ -79,9 +79,9 @@ public static void onRenderWorldPost(final RenderWorldLastEvent event) mat.pushPose(); source.set(target.subtract(source)); mat.translate(source.x, source.y, source.z); - final double d0 = (-player.getX() + player.xOld) * event.getPartialTicks(); - final double d1 = (-player.getY() + player.yOld) * event.getPartialTicks(); - final double d2 = (-player.getZ() + player.zOld) * event.getPartialTicks(); + final double d0 = (-player.getX() + player.xOld) * event.getPartialTick(); + final double d1 = (-player.getY() + player.yOld) * event.getPartialTick(); + final double d2 = (-player.getZ() + player.zOld) * event.getPartialTick(); source.set(d0, d1, d2); mat.translate(source.x, source.y, source.z); // particle.render(event.getRenderPartialTicks()); diff --git a/src/main/java/thut/api/terrain/StructureManager.java b/src/main/java/thut/api/terrain/StructureManager.java index b5a026fdb6..83ff3131e4 100644 --- a/src/main/java/thut/api/terrain/StructureManager.java +++ b/src/main/java/thut/api/terrain/StructureManager.java @@ -49,7 +49,7 @@ public StructureInfo(final Entry, StructureStart> entry) private BoundingBox inflate(final BoundingBox other, final int amt) { return new BoundingBox(other.minX(), other.minY(), other.minZ(), other.maxX(), other.maxY(), other.maxZ()) - .inflate(amt); + .inflatedBy(amt); } public boolean isNear(final BlockPos pos, final int distance) diff --git a/src/main/java/thut/bling/GemRecipe.java b/src/main/java/thut/bling/GemRecipe.java index a70c6ac06d..d0fc065614 100644 --- a/src/main/java/thut/bling/GemRecipe.java +++ b/src/main/java/thut/bling/GemRecipe.java @@ -15,9 +15,9 @@ import net.minecraft.world.item.crafting.RecipeSerializer; import net.minecraft.world.item.crafting.SimpleRecipeSerializer; import net.minecraft.world.level.Level; -import net.minecraftforge.fmllegacy.RegistryObject; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; +import net.minecraftforge.registries.RegistryObject; public class GemRecipe extends CustomRecipe { diff --git a/src/main/java/thut/bling/bag/large/LargeContainer.java b/src/main/java/thut/bling/bag/large/LargeContainer.java index 4efe7c499f..76c4d232d8 100644 --- a/src/main/java/thut/bling/bag/large/LargeContainer.java +++ b/src/main/java/thut/bling/bag/large/LargeContainer.java @@ -10,7 +10,7 @@ import net.minecraft.world.item.ItemStack; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.fmllegacy.network.IContainerFactory; +import net.minecraftforge.network.IContainerFactory; import thut.api.inventory.BaseContainer; import thut.api.item.ItemList; import thut.bling.ThutBling; diff --git a/src/main/java/thut/bling/bag/small/SmallContainer.java b/src/main/java/thut/bling/bag/small/SmallContainer.java index d67cba7ae5..c4dbed2490 100644 --- a/src/main/java/thut/bling/bag/small/SmallContainer.java +++ b/src/main/java/thut/bling/bag/small/SmallContainer.java @@ -8,7 +8,7 @@ import net.minecraft.world.inventory.MenuType; import net.minecraft.world.inventory.Slot; import net.minecraft.world.item.ItemStack; -import net.minecraftforge.fmllegacy.network.IContainerFactory; +import net.minecraftforge.network.IContainerFactory; import thut.api.item.ItemList; import thut.bling.ThutBling; import thut.bling.bag.large.BagSlot; diff --git a/src/main/java/thut/bling/bag/small/SmallManager.java b/src/main/java/thut/bling/bag/small/SmallManager.java index 55107bcaee..8c9cfaa1dd 100644 --- a/src/main/java/thut/bling/bag/small/SmallManager.java +++ b/src/main/java/thut/bling/bag/small/SmallManager.java @@ -11,8 +11,6 @@ import net.minecraft.nbt.NbtIo; import net.minecraft.server.MinecraftServer; import net.minecraft.world.level.storage.LevelResource; -import net.minecraftforge.fml.LogicalSide; -import net.minecraftforge.fmllegacy.LogicalSidedProvider; import thut.api.inventory.big.Manager; import thut.core.common.ThutCore; @@ -22,7 +20,7 @@ public class SmallManager extends Manager public static File getFileForUUID(final String uuid, final String fileName) { - final MinecraftServer server = LogicalSidedProvider.INSTANCE.get(LogicalSide.SERVER); + final MinecraftServer server = ThutCore.proxy.getServer(); Path path = server.getWorldPath(new LevelResource("thut_bling")); // This is to the uuid specific folder path = path.resolve(uuid); diff --git a/src/main/java/thut/bling/client/render/Util.java b/src/main/java/thut/bling/client/render/Util.java index 549c8b8bfc..93cc13fd56 100644 --- a/src/main/java/thut/bling/client/render/Util.java +++ b/src/main/java/thut/bling/client/render/Util.java @@ -128,8 +128,9 @@ public static void renderStandardModelWithGem(final PoseStack mat, final MultiBu if (stack.hasTag() && stack.getTag().contains("gemTag")) { gem = ItemStack.of(stack.getTag().getCompound("gemTag")); + @SuppressWarnings("deprecation") final ResourceLocation sprite = Minecraft.getInstance().getItemRenderer().getItemModelShaper() - .getParticleIcon(gem).getName(); + .getItemModel(gem).getParticleIcon().getName(); final String namespace = sprite.getNamespace(); final String val = "textures/" + sprite.getPath(); tex0 = new ResourceLocation(namespace, val + ".png"); diff --git a/src/main/java/thut/bling/network/PacketBag.java b/src/main/java/thut/bling/network/PacketBag.java index 4f0f733993..406e88fe26 100644 --- a/src/main/java/thut/bling/network/PacketBag.java +++ b/src/main/java/thut/bling/network/PacketBag.java @@ -12,7 +12,7 @@ import net.minecraft.world.inventory.ChestMenu; import net.minecraft.world.inventory.PlayerEnderChestContainer; import net.minecraft.world.item.ItemStack; -import net.minecraftforge.fmllegacy.network.NetworkHooks; +import net.minecraftforge.network.NetworkHooks; import thut.bling.bag.large.LargeContainer; import thut.bling.bag.large.LargeInventory; import thut.bling.bag.large.LargeManager; diff --git a/src/main/java/thut/core/common/Proxy.java b/src/main/java/thut/core/common/Proxy.java index edbb421c7c..a97c2a7c5d 100644 --- a/src/main/java/thut/core/common/Proxy.java +++ b/src/main/java/thut/core/common/Proxy.java @@ -2,15 +2,18 @@ import net.minecraft.core.RegistryAccess; import net.minecraft.server.MinecraftServer; +import net.minecraftforge.event.server.ServerAboutToStartEvent; import net.minecraftforge.fml.LogicalSide; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; import net.minecraftforge.fml.event.lifecycle.FMLLoadCompleteEvent; import net.minecraftforge.fml.util.thread.EffectiveSide; -import net.minecraftforge.fmllegacy.LogicalSidedProvider; public interface Proxy { + void setServer(MinecraftServer server); + + MinecraftServer getServer(); default boolean isClientSide() { @@ -26,8 +29,7 @@ default RegistryAccess getRegistries() { try { - final MinecraftServer server = LogicalSidedProvider.INSTANCE.get(LogicalSide.SERVER); - return server.registryAccess(); + return this.getServer().registryAccess(); } catch (final Exception e) { @@ -48,4 +50,9 @@ default void setup(final FMLCommonSetupEvent event) default void setupClient(final FMLClientSetupEvent event) { } + + default void handleServerAboutToStart(final ServerAboutToStartEvent event) + { + this.setServer(event.getServer()); + } } diff --git a/src/main/java/thut/core/common/ThutCore.java b/src/main/java/thut/core/common/ThutCore.java index e5abab1cc5..373b455af9 100644 --- a/src/main/java/thut/core/common/ThutCore.java +++ b/src/main/java/thut/core/common/ThutCore.java @@ -32,6 +32,7 @@ import net.minecraftforge.event.AttachCapabilitiesEvent; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.event.entity.player.PlayerInteractEvent.RightClickBlock; +import net.minecraftforge.event.server.ServerAboutToStartEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.common.Mod; @@ -39,7 +40,6 @@ import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.fml.loading.FMLPaths; -import net.minecraftforge.fmlserverevents.FMLServerAboutToStartEvent; import thut.api.AnimatedCaps; import thut.api.LinkableCaps; import thut.api.ThutCaps; @@ -254,6 +254,8 @@ public ThutCore() // in MinecraftForge.EVENT_BUS.register(this); + MinecraftForge.EVENT_BUS.addListener(ThutCore.proxy::handleServerAboutToStart); + Tracker.init(); // Register Config stuff @@ -267,7 +269,7 @@ private void doClientStuff(final FMLClientSetupEvent event) // You can use SubscribeEvent and let the Event Bus discover methods to call @SubscribeEvent - public void onServerAboutToStart(final FMLServerAboutToStartEvent event) + public void onServerAboutToStart(final ServerAboutToStartEvent event) { // do something when the server starts ThutCore.LOGGER.debug("Clearing terrain cache"); diff --git a/src/main/java/thut/core/common/handlers/PlayerDataHandler.java b/src/main/java/thut/core/common/handlers/PlayerDataHandler.java index da677cda05..8509a739b6 100644 --- a/src/main/java/thut/core/common/handlers/PlayerDataHandler.java +++ b/src/main/java/thut/core/common/handlers/PlayerDataHandler.java @@ -23,8 +23,6 @@ import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent; import net.minecraftforge.event.world.WorldEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.fml.LogicalSide; -import net.minecraftforge.fmllegacy.LogicalSidedProvider; import thut.core.common.ThutCore; public class PlayerDataHandler @@ -143,7 +141,7 @@ public static Set getDataIDs() public static File getFileForUUID(final String uuid, final String fileName) { - final MinecraftServer server = LogicalSidedProvider.INSTANCE.get(LogicalSide.SERVER); + final MinecraftServer server = ThutCore.proxy.getServer(); Path path = server.getWorldPath(new LevelResource("thutcore")); // This is to the uuid specific folder path = path.resolve(uuid); @@ -194,7 +192,7 @@ public void cleanupOfflineData(final WorldEvent.Save event) // something may have requested the manager for an offline player, which // would have loaded it. final Set toUnload = Sets.newHashSet(); - final MinecraftServer server = LogicalSidedProvider.INSTANCE.get(LogicalSide.SERVER); + final MinecraftServer server = ThutCore.proxy.getServer(); for (final String uuid : this.data.keySet()) { final ServerPlayer player = server.getPlayerList().getPlayer(UUID.fromString(uuid)); diff --git a/src/main/java/thut/core/common/network/Packet.java b/src/main/java/thut/core/common/network/Packet.java index dd56d45e53..6305c65532 100644 --- a/src/main/java/thut/core/common/network/Packet.java +++ b/src/main/java/thut/core/common/network/Packet.java @@ -4,7 +4,7 @@ import net.minecraft.network.FriendlyByteBuf; import net.minecraft.server.level.ServerPlayer; -import net.minecraftforge.fmllegacy.network.NetworkEvent; +import net.minecraftforge.network.NetworkEvent; import thut.core.common.ThutCore; public abstract class Packet diff --git a/src/main/java/thut/core/common/network/PacketAssembly.java b/src/main/java/thut/core/common/network/PacketAssembly.java index 4faa0808cd..662f7fbda0 100644 --- a/src/main/java/thut/core/common/network/PacketAssembly.java +++ b/src/main/java/thut/core/common/network/PacketAssembly.java @@ -19,8 +19,8 @@ import net.minecraft.server.level.ServerPlayer; import net.minecraft.util.Mth; import net.minecraft.world.entity.Entity; -import net.minecraftforge.fmllegacy.network.PacketDistributor; -import net.minecraftforge.fmllegacy.network.PacketDistributor.PacketTarget; +import net.minecraftforge.network.PacketDistributor; +import net.minecraftforge.network.PacketDistributor.PacketTarget; import thut.core.common.ThutCore; /** diff --git a/src/main/java/thut/core/common/network/PacketHandler.java b/src/main/java/thut/core/common/network/PacketHandler.java index f002c3862a..9e9a39fc78 100644 --- a/src/main/java/thut/core/common/network/PacketHandler.java +++ b/src/main/java/thut/core/common/network/PacketHandler.java @@ -8,9 +8,9 @@ import net.minecraft.world.entity.Entity; import net.minecraft.world.level.chunk.ChunkAccess; import net.minecraft.world.level.chunk.LevelChunk; -import net.minecraftforge.fmllegacy.network.NetworkRegistry; -import net.minecraftforge.fmllegacy.network.PacketDistributor; -import net.minecraftforge.fmllegacy.network.simple.SimpleChannel; +import net.minecraftforge.network.NetworkRegistry; +import net.minecraftforge.network.PacketDistributor; +import net.minecraftforge.network.simple.SimpleChannel; public class PacketHandler { diff --git a/src/main/java/thut/core/common/network/TileUpdate.java b/src/main/java/thut/core/common/network/TileUpdate.java index 618cccec32..69ed74f2ea 100644 --- a/src/main/java/thut/core/common/network/TileUpdate.java +++ b/src/main/java/thut/core/common/network/TileUpdate.java @@ -11,7 +11,7 @@ import net.minecraft.world.level.chunk.LevelChunk; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.fmllegacy.network.PacketDistributor; +import net.minecraftforge.network.PacketDistributor; import thut.core.common.ThutCore; public class TileUpdate extends NBTPacket diff --git a/src/main/java/thut/core/init/ClientInit.java b/src/main/java/thut/core/init/ClientInit.java index 14ffa3c011..2dd5d27451 100644 --- a/src/main/java/thut/core/init/ClientInit.java +++ b/src/main/java/thut/core/init/ClientInit.java @@ -29,8 +29,8 @@ import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.client.event.RenderGameOverlayEvent; import net.minecraftforge.client.event.RenderHandEvent; +import net.minecraftforge.client.event.RenderLevelLastEvent; import net.minecraftforge.client.event.RenderLivingEvent; -import net.minecraftforge.client.event.RenderWorldLastEvent; import net.minecraftforge.common.BiomeDictionary; import net.minecraftforge.event.world.WorldEvent.Load; import net.minecraftforge.eventbus.api.EventPriority; @@ -120,8 +120,8 @@ public static void renderMob(final RenderLivingEvent.Pre event) final LivingEntity entity = copied.getCopiedMob(); final boolean backup = event.getRenderer().entityRenderDispatcher.camera.isInitialized(); event.getRenderer().entityRenderDispatcher.setRenderShadow(false); - event.getRenderer().entityRenderDispatcher.render(entity, 0, 0, 0, 0, event.getPartialRenderTick(), event - .getMatrixStack(), event.getBuffers(), event.getLight()); + event.getRenderer().entityRenderDispatcher.render(entity, 0, 0, 0, 0, event.getPartialTick(), event + .getPoseStack(), event.getMultiBufferSource(), event.getPackedLight()); event.getRenderer().entityRenderDispatcher.setRenderShadow(backup); event.setCanceled(true); } @@ -136,7 +136,7 @@ public static void renderHand(final RenderHandEvent event) } @SubscribeEvent - public static void RenderBounds(final RenderWorldLastEvent event) + public static void RenderBounds(final RenderLevelLastEvent event) { ItemStack held; final Player player = Minecraft.getInstance().player; @@ -148,7 +148,7 @@ public static void RenderBounds(final RenderWorldLastEvent event) final Minecraft mc = Minecraft.getInstance(); final Vec3 projectedView = mc.gameRenderer.getMainCamera().getPosition(); Vec3 pointed = new Vec3(projectedView.x, projectedView.y, projectedView.z).add(mc.player.getViewVector( - event.getPartialTicks())); + event.getPartialTick())); if (mc.hitResult != null && mc.hitResult.getType() == Type.BLOCK) { final BlockHitResult result = (BlockHitResult) mc.hitResult; @@ -168,7 +168,7 @@ public static void RenderBounds(final RenderWorldLastEvent event) final double maxY = Math.max(one.maxY, two.maxY); final double maxZ = Math.max(one.maxZ, two.maxZ); - final PoseStack mat = event.getMatrixStack(); + final PoseStack mat = event.getPoseStack(); mat.translate(-projectedView.x, -projectedView.y, -projectedView.z); final List> lines = Lists.newArrayList(); diff --git a/src/main/java/thut/core/init/CommonInit.java b/src/main/java/thut/core/init/CommonInit.java index 80fda393b5..0c5d3fa716 100644 --- a/src/main/java/thut/core/init/CommonInit.java +++ b/src/main/java/thut/core/init/CommonInit.java @@ -10,13 +10,13 @@ import net.minecraft.world.level.Level; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; +import net.minecraftforge.entity.IEntityAdditionalSpawnData; import net.minecraftforge.event.entity.player.PlayerEvent.PlayerLoggedOutEvent; import net.minecraftforge.event.entity.player.PlayerEvent.StartTracking; import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus; -import net.minecraftforge.fmllegacy.common.registry.IEntityAdditionalSpawnData; import thut.api.Tracker; import thut.api.entity.blockentity.BlockEntityBase; import thut.api.entity.blockentity.IBlockEntity; diff --git a/src/main/java/thut/core/proxy/CommonProxy.java b/src/main/java/thut/core/proxy/CommonProxy.java index ae6e92b072..e12a87e29b 100644 --- a/src/main/java/thut/core/proxy/CommonProxy.java +++ b/src/main/java/thut/core/proxy/CommonProxy.java @@ -7,6 +7,7 @@ import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.TranslatableComponent; +import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.InteractionHand; import net.minecraft.world.entity.player.Player; @@ -154,4 +155,18 @@ public static void interactRightClickBlock(final PlayerInteractEvent.RightClickI itemstack.getTag().remove("min"); } } + + private MinecraftServer server; + + @Override + public void setServer(final MinecraftServer server) + { + this.server = server; + } + + @Override + public MinecraftServer getServer() + { + return this.server; + } } diff --git a/src/main/java/thut/crafts/network/PacketCraftControl.java b/src/main/java/thut/crafts/network/PacketCraftControl.java index 9ac460bc41..4001041b5d 100644 --- a/src/main/java/thut/crafts/network/PacketCraftControl.java +++ b/src/main/java/thut/crafts/network/PacketCraftControl.java @@ -5,7 +5,7 @@ import net.minecraft.network.FriendlyByteBuf; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.player.Player; -import net.minecraftforge.fmllegacy.network.NetworkEvent.Context; +import net.minecraftforge.network.NetworkEvent; import thut.core.common.network.Packet; import thut.crafts.ThutCrafts; import thut.crafts.entity.CraftController; @@ -55,7 +55,7 @@ public PacketCraftControl(final FriendlyByteBuf buffer) } @Override - public void handle(final Supplier ctx) + public void handle(final Supplier ctx) { ctx.get().enqueueWork(() -> { diff --git a/src/main/java/thut/crafts/proxy/ClientProxy.java b/src/main/java/thut/crafts/proxy/ClientProxy.java index e43245308d..ee5ff4efa7 100644 --- a/src/main/java/thut/crafts/proxy/ClientProxy.java +++ b/src/main/java/thut/crafts/proxy/ClientProxy.java @@ -24,8 +24,9 @@ import net.minecraft.world.phys.HitResult.Type; import net.minecraft.world.phys.Vec3; import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.client.ClientRegistry; import net.minecraftforge.client.event.EntityRenderersEvent.RegisterRenderers; -import net.minecraftforge.client.event.RenderWorldLastEvent; +import net.minecraftforge.client.event.RenderLevelLastEvent; import net.minecraftforge.client.settings.KeyConflictContext; import net.minecraftforge.event.TickEvent; import net.minecraftforge.event.TickEvent.Phase; @@ -33,7 +34,6 @@ import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; -import net.minecraftforge.fmlclient.registry.ClientRegistry; import thut.api.entity.blockentity.render.RenderBlockEntity; import thut.api.maths.Vector3; import thut.crafts.Reference; @@ -112,7 +112,7 @@ public static void clientTick(final TickEvent.PlayerTickEvent event) } @SubscribeEvent - public static void RenderBounds(final RenderWorldLastEvent event) + public static void RenderBounds(final RenderLevelLastEvent event) { ItemStack held; final Player player = Minecraft.getInstance().player; @@ -124,7 +124,7 @@ public static void RenderBounds(final RenderWorldLastEvent event) final Minecraft mc = Minecraft.getInstance(); final Vec3 projectedView = mc.gameRenderer.getMainCamera().getPosition(); Vec3 pointed = new Vec3(projectedView.x, projectedView.y, projectedView.z).add(mc.player.getViewVector( - event.getPartialTicks())); + event.getPartialTick())); if (mc.hitResult != null && mc.hitResult.getType() == Type.BLOCK) { final BlockHitResult result = (BlockHitResult) mc.hitResult; @@ -144,7 +144,7 @@ public static void RenderBounds(final RenderWorldLastEvent event) final double maxY = Math.max(one.maxY, two.maxY); final double maxZ = Math.max(one.maxZ, two.maxZ); - final PoseStack mat = event.getMatrixStack(); + final PoseStack mat = event.getPoseStack(); mat.translate(-projectedView.x, -projectedView.y, -projectedView.z); final List> lines = Lists.newArrayList(); diff --git a/src/main/java/thut/lib/CompatParser.java b/src/main/java/thut/lib/CompatParser.java index 1ff6b2d8c9..a9539f91e5 100644 --- a/src/main/java/thut/lib/CompatParser.java +++ b/src/main/java/thut/lib/CompatParser.java @@ -5,6 +5,7 @@ import java.util.Map; import java.util.Set; import java.util.function.BiFunction; + import com.google.common.collect.Lists; import com.google.common.collect.Maps; diff --git a/src/main/java/thut/wearables/RecipeDye.java b/src/main/java/thut/wearables/RecipeDye.java index 116c985cd5..cd049f2c45 100644 --- a/src/main/java/thut/wearables/RecipeDye.java +++ b/src/main/java/thut/wearables/RecipeDye.java @@ -21,9 +21,9 @@ import net.minecraft.world.item.crafting.SimpleRecipeSerializer; import net.minecraft.world.level.Level; import net.minecraftforge.common.Tags; -import net.minecraftforge.fmllegacy.RegistryObject; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; +import net.minecraftforge.registries.RegistryObject; public class RecipeDye extends CustomRecipe { diff --git a/src/main/java/thut/wearables/ThutWearables.java b/src/main/java/thut/wearables/ThutWearables.java index 0c73fb8b2e..fe39760bd3 100644 --- a/src/main/java/thut/wearables/ThutWearables.java +++ b/src/main/java/thut/wearables/ThutWearables.java @@ -148,7 +148,7 @@ public static void registerContainers(final RegistryEvent.Register> @SubscribeEvent public static void textureStitch(final TextureStitchEvent.Pre event) { - if (!event.getMap().location().toString().equals("minecraft:textures/atlas/blocks.png")) return; + if (!event.getAtlas().location().toString().equals("minecraft:textures/atlas/blocks.png")) return; for (int i = 0; i < EnumWearable.BYINDEX.length; i++) event.addSprite(new ResourceLocation(EnumWearable.getIcon(i))); } diff --git a/src/main/java/thut/wearables/client/gui/GuiEvents.java b/src/main/java/thut/wearables/client/gui/GuiEvents.java index 9a0b55e4ef..7ce75b658e 100644 --- a/src/main/java/thut/wearables/client/gui/GuiEvents.java +++ b/src/main/java/thut/wearables/client/gui/GuiEvents.java @@ -11,7 +11,7 @@ import net.minecraft.network.chat.TranslatableComponent; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.client.event.GuiScreenEvent; +import net.minecraftforge.client.event.ScreenEvent.InitScreenEvent; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.eventbus.api.SubscribeEvent; import thut.wearables.ThutWearables; @@ -40,28 +40,28 @@ public GuiEvents() @OnlyIn(value = Dist.CLIENT) @SubscribeEvent - public void guiPostInit(final GuiScreenEvent.InitGuiEvent.Post event) + public void guiPostInit(final InitScreenEvent.Post event) { if (!ThutWearables.config.hasButton) return; if (ThutWearables.config.noButton) return; - if (event.getGui() instanceof InventoryScreen || event.getGui() instanceof GuiWearables) + if (event.getScreen() instanceof InventoryScreen || event.getScreen() instanceof GuiWearables) { - this.active = event.getGui() instanceof GuiWearables; - final EffectRenderingInventoryScreen gui = (EffectRenderingInventoryScreen) event.getGui(); + this.active = event.getScreen() instanceof GuiWearables; + final EffectRenderingInventoryScreen gui = (EffectRenderingInventoryScreen) event.getScreen(); final GuiWearableButton button; - event.getGui().addRenderableWidget(button = new GuiWearableButton(gui.getGuiLeft() + ThutWearables.config.buttonPos - .get(0), gui.getGuiTop() + ThutWearables.config.buttonPos.get(1), 9, 9, - new TranslatableComponent(this.active ? "button.wearables.off" : "button.wearables.on"), + event.getScreen().addRenderableWidget(button = new GuiWearableButton(gui.getGuiLeft() + + ThutWearables.config.buttonPos.get(0), gui.getGuiTop() + ThutWearables.config.buttonPos.get(1), 9, + 9, new TranslatableComponent(this.active ? "button.wearables.off" : "button.wearables.on"), b -> this.pressButton(gui))); button.setFGColor(0xFFFF00FF); } - else if (event.getGui() instanceof CreativeModeInventoryScreen) + else if (event.getScreen() instanceof CreativeModeInventoryScreen) { - final CreativeModeInventoryScreen gui = (CreativeModeInventoryScreen) event.getGui(); - this.active = event.getGui() instanceof GuiWearables; + final CreativeModeInventoryScreen gui = (CreativeModeInventoryScreen) event.getScreen(); + this.active = event.getScreen() instanceof GuiWearables; GuiWearableButton button; - event.getGui().addRenderableWidget(button = new GuiWearableButton(gui.getGuiLeft() + 37, gui.getGuiTop() + 9, 9, 9, - new TranslatableComponent(this.active ? "button.wearables.off" : "button.wearables.on"), + event.getScreen().addRenderableWidget(button = new GuiWearableButton(gui.getGuiLeft() + 37, gui.getGuiTop() + + 9, 9, 9, new TranslatableComponent(this.active ? "button.wearables.off" : "button.wearables.on"), b -> this.pressButton(gui))); button.setFGColor(0xFFFF00FF); button.visible = button.active = gui.getSelectedTab() == 11; diff --git a/src/main/java/thut/wearables/client/gui/GuiWearableButton.java b/src/main/java/thut/wearables/client/gui/GuiWearableButton.java index 8238433999..7599845d27 100644 --- a/src/main/java/thut/wearables/client/gui/GuiWearableButton.java +++ b/src/main/java/thut/wearables/client/gui/GuiWearableButton.java @@ -28,7 +28,7 @@ public void renderButton(final PoseStack mat, final int p_renderButton_1_, final { RenderSystem.setShader(GameRenderer::getPositionTexShader); RenderSystem.setShaderTexture(0, GuiWearables.background); - final int i = this.getYImage(this.isHovered()); + final int i = this.getYImage(this.isHoveredOrFocused()); this.blit(mat, this.x, this.y, 0, i, this.width, this.height); } } \ No newline at end of file diff --git a/src/main/java/thut/wearables/client/render/WearableEventHandler.java b/src/main/java/thut/wearables/client/render/WearableEventHandler.java index bfe50155c1..b8c34ac03e 100644 --- a/src/main/java/thut/wearables/client/render/WearableEventHandler.java +++ b/src/main/java/thut/wearables/client/render/WearableEventHandler.java @@ -17,6 +17,7 @@ import net.minecraft.network.chat.TextComponent; import net.minecraft.resources.ResourceLocation; import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.client.ClientRegistry; import net.minecraftforge.client.event.EntityRenderersEvent.RegisterLayerDefinitions; import net.minecraftforge.client.event.InputEvent.KeyInputEvent; import net.minecraftforge.client.event.RenderLivingEvent; @@ -25,7 +26,6 @@ import net.minecraftforge.event.entity.player.ItemTooltipEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fmlclient.registry.ClientRegistry; import thut.wearables.EnumWearable; import thut.wearables.IWearable; import thut.wearables.Reference; diff --git a/src/main/java/thut/wearables/inventory/ContainerWearables.java b/src/main/java/thut/wearables/inventory/ContainerWearables.java index e28299fbca..c3aa90bba9 100644 --- a/src/main/java/thut/wearables/inventory/ContainerWearables.java +++ b/src/main/java/thut/wearables/inventory/ContainerWearables.java @@ -19,7 +19,7 @@ import net.minecraft.world.item.enchantment.EnchantmentHelper; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.fmllegacy.network.IContainerFactory; +import net.minecraftforge.network.IContainerFactory; import thut.wearables.EnumWearable; import thut.wearables.ThutWearables; diff --git a/src/main/java/thut/wearables/network/Packet.java b/src/main/java/thut/wearables/network/Packet.java index d80287415a..dc0ee746a0 100644 --- a/src/main/java/thut/wearables/network/Packet.java +++ b/src/main/java/thut/wearables/network/Packet.java @@ -4,7 +4,7 @@ import net.minecraft.network.FriendlyByteBuf; import net.minecraft.server.level.ServerPlayer; -import net.minecraftforge.fmllegacy.network.NetworkEvent; +import net.minecraftforge.network.NetworkEvent; import thut.core.common.ThutCore; public abstract class Packet diff --git a/src/main/java/thut/wearables/network/PacketGui.java b/src/main/java/thut/wearables/network/PacketGui.java index 9e5bf9130d..d3a00d5b37 100644 --- a/src/main/java/thut/wearables/network/PacketGui.java +++ b/src/main/java/thut/wearables/network/PacketGui.java @@ -20,7 +20,7 @@ import net.minecraft.world.phys.Vec3; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.fmllegacy.network.NetworkHooks; +import net.minecraftforge.network.NetworkHooks; import thut.wearables.EnumWearable; import thut.wearables.ThutWearables; import thut.wearables.inventory.ContainerWearables; diff --git a/src/main/java/thut/wearables/network/PacketHandler.java b/src/main/java/thut/wearables/network/PacketHandler.java index bdfe636e44..42a8f49094 100644 --- a/src/main/java/thut/wearables/network/PacketHandler.java +++ b/src/main/java/thut/wearables/network/PacketHandler.java @@ -8,9 +8,9 @@ import net.minecraft.world.entity.Entity; import net.minecraft.world.level.chunk.ChunkAccess; import net.minecraft.world.level.chunk.LevelChunk; -import net.minecraftforge.fmllegacy.network.NetworkRegistry; -import net.minecraftforge.fmllegacy.network.PacketDistributor; -import net.minecraftforge.fmllegacy.network.simple.SimpleChannel; +import net.minecraftforge.network.NetworkRegistry; +import net.minecraftforge.network.PacketDistributor; +import net.minecraftforge.network.simple.SimpleChannel; public class PacketHandler { diff --git a/src/test/java/thut/bot/ThutBot.java b/src/test/java/thut/bot/ThutBot.java index e19538097b..067079ce82 100644 --- a/src/test/java/thut/bot/ThutBot.java +++ b/src/test/java/thut/bot/ThutBot.java @@ -33,7 +33,6 @@ import net.minecraftforge.event.TickEvent.ServerTickEvent; import net.minecraftforge.fml.LogicalSide; import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fmllegacy.LogicalSidedProvider; import thut.bot.entity.BotPlayer; import thut.bot.entity.ai.IBotAI; import thut.bot.entity.ai.modules.VillageRouteMaker; @@ -54,7 +53,7 @@ private static void onServerTick(final ServerTickEvent event) { if (event.side == LogicalSide.CLIENT) return; if (event.phase == Phase.START) return; - final MinecraftServer server = LogicalSidedProvider.INSTANCE.get(LogicalSide.SERVER); + final MinecraftServer server = ThutCore.proxy.getServer(); final ServerLevel overworld = server.getLevel(Level.OVERWORLD); final UUID id = new UUID(2152346, 2344673); if (overworld.getPlayerByUUID(id) == null) diff --git a/src/test/java/thut/bot/entity/ai/modules/VillageRouteMaker.java b/src/test/java/thut/bot/entity/ai/modules/VillageRouteMaker.java index d3394eb4df..b1c13177c5 100644 --- a/src/test/java/thut/bot/entity/ai/modules/VillageRouteMaker.java +++ b/src/test/java/thut/bot/entity/ai/modules/VillageRouteMaker.java @@ -24,6 +24,7 @@ import net.minecraft.world.entity.PathfinderMob; import net.minecraft.world.entity.ai.navigation.PathNavigation; import net.minecraft.world.entity.ai.util.LandRandomPos; +import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.GameType; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.BlockState; @@ -396,7 +397,7 @@ private Node findNearestVillageNode(final BlockPos mid, final boolean skipKnownS for (final StructureInfo i : nearby) if (i.start.getFeature() == structure) { - village = i.start.getLocatePos(); + village = i.start.getFeature().getLocatePos(new ChunkPos(mid)); break infos; } } diff --git a/src/test/java/thut/test/scripting/CmdListener.java b/src/test/java/thut/test/scripting/CmdListener.java index 41456b1a7d..70221f51bc 100644 --- a/src/test/java/thut/test/scripting/CmdListener.java +++ b/src/test/java/thut/test/scripting/CmdListener.java @@ -13,8 +13,8 @@ import net.minecraft.server.MinecraftServer; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fmlserverevents.FMLServerStartingEvent; -import net.minecraftforge.fmlserverevents.FMLServerStoppedEvent; +import net.minecraftforge.event.server.ServerStartingEvent; +import net.minecraftforge.event.server.ServerStoppedEvent; import thut.test.scripting.handlers.CmdHandler; import thut.test.scripting.handlers.GetBlockHandler; import thut.test.scripting.handlers.GetPlayerHandler; @@ -176,7 +176,7 @@ public static void init() MinecraftForge.EVENT_BUS.addListener(CmdListener::onServerStopped); } - private static void onServerStarting(final FMLServerStartingEvent event) + private static void onServerStarting(final ServerStartingEvent event) { CmdListener.server.setServer(event.getServer()); CmdListener.listener = CmdListener.makeListener(); @@ -184,7 +184,7 @@ private static void onServerStarting(final FMLServerStartingEvent event) CmdListener.listener.start(); } - private static void onServerStopped(final FMLServerStoppedEvent event) + private static void onServerStopped(final ServerStoppedEvent event) { CmdListener.server.setServer(null); CmdListener.listener.interrupt();