diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 47b8507e7..777b0ae22 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -15,7 +15,7 @@ body: attributes: label: 'Minecraft version information' description: 'Please provide the exact minecraft version that you are using.' - placeholder: 'Example: 1.18-pre5' + placeholder: 'Example: 1.19.2' validations: required: true - type: dropdown @@ -25,8 +25,9 @@ body: description: 'Please choose the mod loader that you are using.' options: - Fabric - - Forge - Quilt + - Forge + - NeoForge validations: required: true - type: input diff --git a/.github/ISSUE_TEMPLATE/crash_report.yml b/.github/ISSUE_TEMPLATE/crash_report.yml index d1530b80a..4e404f150 100644 --- a/.github/ISSUE_TEMPLATE/crash_report.yml +++ b/.github/ISSUE_TEMPLATE/crash_report.yml @@ -15,7 +15,7 @@ body: attributes: label: 'Minecraft version information' description: 'Please provide the exact minecraft version that you are using.' - placeholder: 'Example: 1.18-pre5' + placeholder: 'Example: 1.19.2' validations: required: true - type: dropdown @@ -25,8 +25,9 @@ body: description: 'Please choose the mod loader that you are using.' options: - Fabric - - Forge - Quilt + - Forge + - NeoForge validations: required: true - type: input diff --git a/.github/versions.json b/.github/versions.json index 27f08795c..4623f6c0e 100644 --- a/.github/versions.json +++ b/.github/versions.json @@ -1,12 +1,12 @@ { - "1.20.1": "1.9.5", - "1.20": "1.9.5", - "1.19.4": "1.8.7", - "1.19.3": "1.8.7", - "1.19.2": "1.8.7", - "1.19.1": "1.8.7", - "1.19": "1.8.7", - "1.18.2": "1.4.7", + "1.20.1": "1.9.6", + "1.20": "1.9.6", + "1.19.4": "1.8.8", + "1.19.3": "1.8.8", + "1.19.2": "1.8.8", + "1.19.1": "1.8.8", + "1.19": "1.8.8", + "1.18.2": "1.4.8", "1.18.1": "1.2.5", "1.18": "1.2.5" } \ No newline at end of file diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 49c30806c..b029ad9fc 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -109,7 +109,7 @@ jobs: version-type: ${{ env.VERSION_TYPE }} loaders: ${{ env.FABRIC_LOADERS }} game-versions: ${{ env.GAME_VERSIONS }} - name: Friends&Foes ${{ github.ref_name }} (Fabric) + name: Friends&Foes ${{ github.ref_name }} (Fabric/Quilt) dependencies: ${{ env.FABRIC_DEPENDENCIES }} java: ${{ env.JAVA_VERSIONS }} @@ -141,7 +141,7 @@ jobs: version-type: ${{ env.VERSION_TYPE }} loaders: ${{ env.FABRIC_LOADERS }} game-versions: ${{ env.GAME_VERSIONS }} - name: Friends&Foes ${{ github.ref_name }} (Fabric) + name: Friends&Foes ${{ github.ref_name }} (Fabric/Quilt) version: fabric-${{ github.ref_name }} dependencies: ${{ env.FABRIC_DEPENDENCIES }} java: ${{ env.JAVA_VERSIONS }} @@ -189,7 +189,7 @@ jobs: version-type: ${{ env.VERSION_TYPE }} loaders: ${{ env.FORGE_LOADERS }} game-versions: ${{ env.GAME_VERSIONS }} - name: Friends&Foes ${{ github.ref_name }} (Forge) + name: Friends&Foes ${{ github.ref_name }} (Forge/NeoForge) java: ${{ env.JAVA_VERSIONS }} retry-attempts: ${{ env.RETRY_ATTEMPTS }} @@ -220,7 +220,7 @@ jobs: version-type: ${{ env.VERSION_TYPE }} loaders: ${{ env.FORGE_LOADERS }} game-versions: ${{ env.GAME_VERSIONS }} - name: Friends&Foes ${{ github.ref_name }} (Forge) + name: Friends&Foes ${{ github.ref_name }} (Forge/NeoForge) version: forge-${{ github.ref_name }} java: ${{ env.JAVA_VERSIONS }} retry-attempts: ${{ env.RETRY_ATTEMPTS }} diff --git a/README.md b/README.md index 26263c152..6fb8dfa51 100644 --- a/README.md +++ b/README.md @@ -14,8 +14,6 @@ You can check [wiki] for a detailed overview of implemented features. Also feel - [Modrinth (Fabric)] - [CurseForge (Forge)] - [Modrinth (Forge)] -- [CurseForge (Quilt)] -- [Modrinth (Quilt)] - [Discord] ## Support @@ -52,10 +50,6 @@ This mod would not exist in the state as it is without the following people: [Modrinth (Forge)]: https://modrinth.com/mod/friends-and-foes-forge -[CurseForge (Quilt)]: https://www.curseforge.com/minecraft/mc-mods/friends-and-foes-quilt - -[Modrinth (Quilt)]: https://modrinth.com/mod/friends-and-foes-quilt - [Discord]: https://discord.com/invite/QGwFvvMQCn [Patreon]: https://www.patreon.com/Faboslav diff --git a/common/build.gradle b/common/build.gradle index 575d4c845..bcbed6c35 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -10,7 +10,7 @@ dependencies { modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}" modImplementation("me.shedaniel.cloth:cloth-config-fabric:${rootProject.cloth_config_version}") - implementation(annotationProcessor("com.github.llamalad7.mixinextras:mixinextras-fabric:${rootProject.mixin_extras_version}")) + implementation(annotationProcessor("io.github.llamalad7:mixinextras-fabric:${rootProject.mixin_extras_version}")) } diff --git a/common/src/main/java/com/faboslav/friendsandfoes/entity/CopperGolemEntity.java b/common/src/main/java/com/faboslav/friendsandfoes/entity/CopperGolemEntity.java index 6bb908d5d..9aadeab3f 100644 --- a/common/src/main/java/com/faboslav/friendsandfoes/entity/CopperGolemEntity.java +++ b/common/src/main/java/com/faboslav/friendsandfoes/entity/CopperGolemEntity.java @@ -7,7 +7,6 @@ import com.faboslav.friendsandfoes.init.FriendsAndFoesSoundEvents; import com.faboslav.friendsandfoes.mixin.LimbAnimatorAccessor; import com.faboslav.friendsandfoes.util.ModelAnimationHelper; -import com.faboslav.friendsandfoes.util.RandomGenerator; import net.minecraft.block.BlockState; import net.minecraft.block.Oxidizable; import net.minecraft.entity.*; @@ -148,10 +147,10 @@ protected void initDataTracker() { this.dataTracker.startTracking(STRUCT_BY_LIGHTNING_TICKS, 0); this.dataTracker.startTracking(IS_WAXED, false); this.dataTracker.startTracking(IS_PRESSING_BUTTON, false); - this.dataTracker.startTracking(TICKS_UNTIL_CAN_PRESS_BUTTON, RandomGenerator.generateInt(MIN_TICKS_UNTIL_CAN_PRESS_BUTTON, MIN_TICKS_UNTIL_CAN_PRESS_BUTTON + MIN_TICKS_UNTIL_CAN_PRESS_BUTTON)); + this.dataTracker.startTracking(TICKS_UNTIL_CAN_PRESS_BUTTON, this.getRandom().nextBetween(MIN_TICKS_UNTIL_CAN_PRESS_BUTTON, MIN_TICKS_UNTIL_CAN_PRESS_BUTTON + MIN_TICKS_UNTIL_CAN_PRESS_BUTTON)); this.dataTracker.startTracking(IS_SPINNING_HEAD, false); this.dataTracker.startTracking(IS_MOVING, false); - this.dataTracker.startTracking(TICKS_UNTIL_NEXT_HEAD_SPIN, RandomGenerator.generateInt(MIN_TICKS_UNTIL_NEXT_HEAD_SPIN, MAX_TICKS_UNTIL_NEXT_HEAD_SPIN)); + this.dataTracker.startTracking(TICKS_UNTIL_NEXT_HEAD_SPIN, this.getRandom().nextBetween(MIN_TICKS_UNTIL_NEXT_HEAD_SPIN, MAX_TICKS_UNTIL_NEXT_HEAD_SPIN)); this.dataTracker.startTracking(BUTTON_PRESS_ANIMATION_PROGRESS, 0.0F); this.dataTracker.startTracking(LAST_BUTTON_PRESS_ANIMATION_PROGRESS, 0.0F); this.dataTracker.startTracking(HEAD_SPIN_ANIMATION_PROGRESS, 0.0F); @@ -444,7 +443,7 @@ public void tick() { if (this.isStructByLightning() && this.getEntityWorld().isClient() == false) { this.setStructByLightningTicks(this.getStructByLightningTicks() - 1); - if (RandomGenerator.generateRandomFloat() < SPARK_CHANCE) { + if (this.getRandom().nextFloat() < SPARK_CHANCE) { for (int i = 0; i < 7; i++) { ((ServerWorld) this.getWorld()).spawnParticles( ParticleTypes.ELECTRIC_SPARK, @@ -588,7 +587,7 @@ public void handleOxidationIncrease() { return; } - if (RandomGenerator.generateRandomFloat() < OXIDATION_CHANCE) { + if (this.getRandom().nextFloat() < OXIDATION_CHANCE) { int degradedOxidationLevelOrdinal = getOxidationLevel().ordinal() + 1; Oxidizable.OxidationLevel[] OxidationLevels = Oxidizable.OxidationLevel.values(); this.setOxidationLevel(OxidationLevels[degradedOxidationLevelOrdinal]); @@ -626,7 +625,7 @@ public int getStructByLightningTicks() { } public void refreshStructByLightningTicks() { - this.setStructByLightningTicks(RandomGenerator.generateInt(MIN_STRUCT_BY_LIGHTNING_TICKS, MAX_STRUCT_BY_LIGHTNING_TICKS)); + this.setStructByLightningTicks(this.getRandom().nextBetween(MIN_STRUCT_BY_LIGHTNING_TICKS, MAX_STRUCT_BY_LIGHTNING_TICKS)); } public boolean isStructByLightning() { diff --git a/common/src/main/java/com/faboslav/friendsandfoes/entity/GlareEntity.java b/common/src/main/java/com/faboslav/friendsandfoes/entity/GlareEntity.java index 68d1d92f1..e0c5afcb1 100644 --- a/common/src/main/java/com/faboslav/friendsandfoes/entity/GlareEntity.java +++ b/common/src/main/java/com/faboslav/friendsandfoes/entity/GlareEntity.java @@ -267,14 +267,14 @@ public void setTargetEyesPositionOffset(float xEyePositionOffset, float yEyePosi private void updateTargetEyesPositionOffset() { if ( this.age % MIN_EYE_ANIMATION_TICK_AMOUNT != 0 - || RandomGenerator.generateInt(0, 2) != 0 + || this.getRandom().nextBetween(0, 2) != 0 ) { return; } this.setTargetEyesPositionOffset( - RandomGenerator.generateFloat(-0.5F, 0.5F), - RandomGenerator.generateFloat(-0.4F, 0.4F) + -0.5F + this.getRandom().nextFloat() * (0.5F - -0.5F), + -0.4F + this.getRandom().nextFloat() * (0.4F - -0.4F) ); } @@ -637,7 +637,7 @@ public void setTicksUntilCanFindDarkSpot(int ticksUntilCanFindDarkSpot) { } public int generateRandomTicksUntilCanFindDarkSpot() { - return RandomGenerator.generateInt( + return this.getRandom().nextBetween( MIN_TICKS_UNTIL_CAN_FIND_DARK_SPOT, MAX_TICKS_UNTIL_CAN_FIND_DARK_SPOT ); @@ -652,7 +652,7 @@ public void setTicksUntilCanEatGlowBerries(int ticksUntilCanEatGlowBerries) { } public int generateRandomTicksUntilCanEatGlowBerries() { - return RandomGenerator.generateInt( + return this.getRandom().nextBetween( MIN_TICKS_UNTIL_CAN_EAT_GLOW_BERRIES, MAX_TICKS_UNTIL_CAN_EAT_GLOW_BERRIES ); diff --git a/common/src/main/java/com/faboslav/friendsandfoes/entity/MaulerEntity.java b/common/src/main/java/com/faboslav/friendsandfoes/entity/MaulerEntity.java index 5357806d2..a26dfc2d5 100644 --- a/common/src/main/java/com/faboslav/friendsandfoes/entity/MaulerEntity.java +++ b/common/src/main/java/com/faboslav/friendsandfoes/entity/MaulerEntity.java @@ -125,7 +125,7 @@ protected void initDataTracker() { this.dataTracker.startTracking(STORED_EXPERIENCE_POINTS, 0); this.dataTracker.startTracking(IS_MOVING, false); this.dataTracker.startTracking(IS_BURROWED_DOWN, false); - this.dataTracker.startTracking(TICKS_UNTIL_NEXT_BURROWING_DOWN, RandomGenerator.generateInt(MIN_TICKS_UNTIL_NEXT_BURROWING, MAX_TICKS_UNTIL_NEXT_BURROWING)); + this.dataTracker.startTracking(TICKS_UNTIL_NEXT_BURROWING_DOWN, this.getRandom().nextBetween(MIN_TICKS_UNTIL_NEXT_BURROWING, MAX_TICKS_UNTIL_NEXT_BURROWING)); this.dataTracker.startTracking(BURROWING_DOWN_ANIMATION_PROGRESS, 0.0F); } @@ -435,7 +435,7 @@ public void setAngerTime(int angerTime) { } public void chooseRandomAngerTime() { - int angerTime = RandomGenerator.generateInt(400, 1000); + int angerTime = this.getRandom().nextBetween(400, 1000); this.setAngerTime(angerTime); } diff --git a/common/src/main/java/com/faboslav/friendsandfoes/entity/MoobloomEntity.java b/common/src/main/java/com/faboslav/friendsandfoes/entity/MoobloomEntity.java index c26e30036..9c6920776 100644 --- a/common/src/main/java/com/faboslav/friendsandfoes/entity/MoobloomEntity.java +++ b/common/src/main/java/com/faboslav/friendsandfoes/entity/MoobloomEntity.java @@ -6,7 +6,6 @@ import com.faboslav.friendsandfoes.init.FriendsAndFoesBlocks; import com.faboslav.friendsandfoes.init.FriendsAndFoesEntityTypes; import com.faboslav.friendsandfoes.init.FriendsAndFoesSoundEvents; -import com.faboslav.friendsandfoes.util.RandomGenerator; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; @@ -201,7 +200,7 @@ public MoobloomEntity createChild( PassiveEntity entity ) { MoobloomVariant moobloomVariant = this.getVariant(); - if (RandomGenerator.generateInt(0, 1) == 0) { + if (this.getRandom().nextBetween(0, 1) == 0) { moobloomVariant = ((MoobloomEntity) entity).getVariant(); } @@ -234,7 +233,7 @@ public void tickMovement() { if (MoobloomVariants.getNumberOfVariants() == 1) { // 40% chance buttercup, 40% chance dandelion, 20% chance sunflower - int flowerChance = RandomGenerator.generateInt(1, 100); + int flowerChance = this.getRandom().nextBetween(1, 100); if (flowerChance >= 0 && flowerChance < 40) { this.getWorld().setBlockState(this.getBlockPos(), FriendsAndFoesBlocks.BUTTERCUP.get().getDefaultState()); diff --git a/common/src/main/java/com/faboslav/friendsandfoes/entity/TuffGolemEntity.java b/common/src/main/java/com/faboslav/friendsandfoes/entity/TuffGolemEntity.java index b93e6d119..c38d0b272 100644 --- a/common/src/main/java/com/faboslav/friendsandfoes/entity/TuffGolemEntity.java +++ b/common/src/main/java/com/faboslav/friendsandfoes/entity/TuffGolemEntity.java @@ -248,7 +248,7 @@ private SoundEvent getRepairSound() { } private void playRepairSound() { - this.playSound(this.getRepairSound(), 1.0F, 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.2F); + this.playSound(this.getRepairSound(), 1.0F, 1.0F + (this.getRandom().nextFloat() - this.getRandom().nextFloat()) * 0.2F); } public SoundEvent getWakeSound() { diff --git a/common/src/main/java/com/faboslav/friendsandfoes/entity/WildfireEntity.java b/common/src/main/java/com/faboslav/friendsandfoes/entity/WildfireEntity.java index fa88987b2..54ba8e8d0 100644 --- a/common/src/main/java/com/faboslav/friendsandfoes/entity/WildfireEntity.java +++ b/common/src/main/java/com/faboslav/friendsandfoes/entity/WildfireEntity.java @@ -257,8 +257,8 @@ public void tickMovement() { } if (this.getWorld().isClient()) { - if (this.random.nextInt(24) == 0 && !this.isSilent()) { - this.getWorld().playSound(this.getX() + 0.5, this.getY() + 0.5, this.getZ() + 0.5, SoundEvents.ENTITY_BLAZE_BURN, this.getSoundCategory(), 1.0F + this.random.nextFloat(), this.random.nextFloat() * 0.7F + 0.3F, false); + if (this.getRandom().nextInt(24) == 0 && !this.isSilent()) { + this.getWorld().playSound(this.getX() + 0.5, this.getY() + 0.5, this.getZ() + 0.5, SoundEvents.ENTITY_BLAZE_BURN, this.getSoundCategory(), 1.0F + this.getRandom().nextFloat(), this.getRandom().nextFloat() * 0.7F + 0.3F, false); } for (int i = 0; i < 2; ++i) { diff --git a/common/src/main/java/com/faboslav/friendsandfoes/entity/WildfireShieldDebrisEntity.java b/common/src/main/java/com/faboslav/friendsandfoes/entity/WildfireShieldDebrisEntity.java index 8162e2b98..b500a3bcb 100644 --- a/common/src/main/java/com/faboslav/friendsandfoes/entity/WildfireShieldDebrisEntity.java +++ b/common/src/main/java/com/faboslav/friendsandfoes/entity/WildfireShieldDebrisEntity.java @@ -100,7 +100,7 @@ private SoundEvent getImpactSound() { private void playImpactSound() { SoundEvent soundEvent = this.getImpactSound(); - this.playSound(soundEvent, 1.0F, RandomGenerator.generateFloat(0.95F, 1.05F)); + this.playSound(soundEvent, 1.0F, 0.95F + RandomGenerator.generateFloat(0.95F, 1.05F)); } } diff --git a/common/src/main/java/com/faboslav/friendsandfoes/entity/ai/brain/task/wildfire/WildfireSummonBlazeTask.java b/common/src/main/java/com/faboslav/friendsandfoes/entity/ai/brain/task/wildfire/WildfireSummonBlazeTask.java index 6ca3082a0..2349f9c3a 100644 --- a/common/src/main/java/com/faboslav/friendsandfoes/entity/ai/brain/task/wildfire/WildfireSummonBlazeTask.java +++ b/common/src/main/java/com/faboslav/friendsandfoes/entity/ai/brain/task/wildfire/WildfireSummonBlazeTask.java @@ -4,7 +4,6 @@ import com.faboslav.friendsandfoes.entity.WildfireEntity; import com.faboslav.friendsandfoes.entity.ai.brain.WildfireBrain; import com.faboslav.friendsandfoes.init.FriendsAndFoesMemoryModuleTypes; -import com.faboslav.friendsandfoes.util.RandomGenerator; import com.google.common.collect.ImmutableMap; import net.minecraft.entity.EntityType; import net.minecraft.entity.LivingEntity; @@ -82,7 +81,7 @@ protected void keepRunning(ServerWorld world, WildfireEntity wildfire, long time LookTargetUtil.lookAt(wildfire, this.attackTarget); ServerWorld serverWorld = (ServerWorld) wildfire.getWorld(); - int blazesToBeSummoned = Math.max(0, RandomGenerator.generateInt(MIN_BLAZES_TO_BE_SUMMONED, MAX_BLAZES_TO_BE_SUMMONED) - wildfire.getSummonedBlazesCount()); + int blazesToBeSummoned = Math.max(0, wildfire.getRandom().nextBetween(MIN_BLAZES_TO_BE_SUMMONED, MAX_BLAZES_TO_BE_SUMMONED) - wildfire.getSummonedBlazesCount()); if (blazesToBeSummoned > 0) { wildfire.playSummonBlazeSound(); diff --git a/common/src/main/java/com/faboslav/friendsandfoes/entity/ai/goal/bee/BeePollinateMoobloomGoal.java b/common/src/main/java/com/faboslav/friendsandfoes/entity/ai/goal/bee/BeePollinateMoobloomGoal.java index 267156db2..080d9d6e1 100644 --- a/common/src/main/java/com/faboslav/friendsandfoes/entity/ai/goal/bee/BeePollinateMoobloomGoal.java +++ b/common/src/main/java/com/faboslav/friendsandfoes/entity/ai/goal/bee/BeePollinateMoobloomGoal.java @@ -2,7 +2,6 @@ import com.faboslav.friendsandfoes.entity.MoobloomEntity; import com.faboslav.friendsandfoes.mixin.BeeEntityAccessor; -import com.faboslav.friendsandfoes.util.RandomGenerator; import net.minecraft.entity.ai.TargetPredicate; import net.minecraft.entity.ai.goal.Goal; import net.minecraft.entity.passive.BeeEntity; @@ -46,7 +45,7 @@ public boolean canStart() { return false; } else if (this.beeEntity.getWorld().isRaining()) { return false; - } else if (RandomGenerator.generateRandomFloat() < 0.5F) { + } else if (this.beeEntity.getRandom().nextFloat() < 0.5F) { return false; } else if (this.beeEntity.pollinateGoal.isRunning()) { return false; diff --git a/common/src/main/java/com/faboslav/friendsandfoes/entity/ai/goal/coppergolem/CopperGolemPressButtonGoal.java b/common/src/main/java/com/faboslav/friendsandfoes/entity/ai/goal/coppergolem/CopperGolemPressButtonGoal.java index 299d774e9..7891a49b4 100644 --- a/common/src/main/java/com/faboslav/friendsandfoes/entity/ai/goal/coppergolem/CopperGolemPressButtonGoal.java +++ b/common/src/main/java/com/faboslav/friendsandfoes/entity/ai/goal/coppergolem/CopperGolemPressButtonGoal.java @@ -3,7 +3,6 @@ import com.faboslav.friendsandfoes.block.CopperButtonBlock; import com.faboslav.friendsandfoes.entity.CopperGolemEntity; import com.faboslav.friendsandfoes.tag.FriendsAndFoesTags; -import com.faboslav.friendsandfoes.util.RandomGenerator; import net.minecraft.block.BlockState; import net.minecraft.block.HorizontalFacingBlock; import net.minecraft.entity.ai.goal.Goal; @@ -102,8 +101,8 @@ public void start() { this.copperButtonWasSuccessfullyPressed = false; int minIdleTicks = 20; int maxIdleTicks = 40; - this.idleTicksBeforeButtonPress = RandomGenerator.generateInt(minIdleTicks, maxIdleTicks); - this.idleTicksAfterButtonPress = RandomGenerator.generateInt(minIdleTicks, maxIdleTicks); + this.idleTicksBeforeButtonPress = this.copperGolem.getRandom().nextBetween(minIdleTicks, maxIdleTicks); + this.idleTicksAfterButtonPress = this.copperGolem.getRandom().nextBetween(minIdleTicks, maxIdleTicks); } @Override @@ -124,7 +123,7 @@ public void stop() { } int maxCooldownTicks = minCooldownTicks + CopperGolemEntity.MIN_TICKS_UNTIL_CAN_PRESS_BUTTON; - int cooldown = RandomGenerator.generateInt(minCooldownTicks, maxCooldownTicks); + int cooldown = this.copperGolem.getRandom().nextBetween(minCooldownTicks, maxCooldownTicks); this.copperGolem.setTicksUntilCanPressButton(cooldown); } @@ -258,7 +257,7 @@ private BlockPos getRandomCopperButtonToPress(ArrayList<BlockPos> copperButtons) return null; } - int randomCopperButtonIndex = RandomGenerator.generateInt(0, copperButtonsCount - 1); + int randomCopperButtonIndex = this.copperGolem.getRandom().nextBetween(0, copperButtonsCount - 1); return copperButtons.get(randomCopperButtonIndex); } diff --git a/common/src/main/java/com/faboslav/friendsandfoes/entity/ai/goal/coppergolem/CopperGolemSpinHeadGoal.java b/common/src/main/java/com/faboslav/friendsandfoes/entity/ai/goal/coppergolem/CopperGolemSpinHeadGoal.java index 3145bf504..750729179 100644 --- a/common/src/main/java/com/faboslav/friendsandfoes/entity/ai/goal/coppergolem/CopperGolemSpinHeadGoal.java +++ b/common/src/main/java/com/faboslav/friendsandfoes/entity/ai/goal/coppergolem/CopperGolemSpinHeadGoal.java @@ -2,7 +2,6 @@ import com.faboslav.friendsandfoes.entity.CopperGolemEntity; import com.faboslav.friendsandfoes.init.FriendsAndFoesSoundEvents; -import com.faboslav.friendsandfoes.util.RandomGenerator; import net.minecraft.entity.ai.goal.Goal; public final class CopperGolemSpinHeadGoal extends Goal @@ -22,7 +21,7 @@ public boolean canStart() { return false; } else if (this.copperGolem.pressButtonGoal.isRunning()) { return false; - } else if (RandomGenerator.generateRandomFloat() < 0.95) { + } else if (this.copperGolem.getRandom().nextFloat() < 0.95) { return false; } @@ -48,7 +47,7 @@ public void start() { public void stop() { this.copperGolem.setIsSpinningHead(false); this.copperGolem.setTicksUntilNextHeadSpin( - RandomGenerator.generateInt( + this.copperGolem.getRandom().nextBetween( CopperGolemEntity.MIN_TICKS_UNTIL_NEXT_HEAD_SPIN, CopperGolemEntity.MAX_TICKS_UNTIL_NEXT_HEAD_SPIN ) diff --git a/common/src/main/java/com/faboslav/friendsandfoes/entity/ai/goal/mauler/MaulerBurrowDownGoal.java b/common/src/main/java/com/faboslav/friendsandfoes/entity/ai/goal/mauler/MaulerBurrowDownGoal.java index 6ffcc75fc..b265a3de2 100644 --- a/common/src/main/java/com/faboslav/friendsandfoes/entity/ai/goal/mauler/MaulerBurrowDownGoal.java +++ b/common/src/main/java/com/faboslav/friendsandfoes/entity/ai/goal/mauler/MaulerBurrowDownGoal.java @@ -1,7 +1,6 @@ package com.faboslav.friendsandfoes.entity.ai.goal.mauler; import com.faboslav.friendsandfoes.entity.MaulerEntity; -import com.faboslav.friendsandfoes.util.RandomGenerator; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; @@ -33,7 +32,7 @@ public boolean canStart() { this.mauler.hasAngerTime() || this.mauler.getWorld().isNight() || this.mauler.getNavigation().isFollowingPath() - || RandomGenerator.generateRandomFloat() < 0.999 + || this.mauler.getRandom().nextFloat() < 0.999F || this.mauler.getTicksUntilNextBurrowingDown() > 0 ) { return false; @@ -63,7 +62,7 @@ public void start() { this.mauler.getNavigation().stop(); if (this.getBurrowedDownTicks() == 0) { - this.burrowedDownTicks = RandomGenerator.generateInt(600, 1200); + this.burrowedDownTicks = this.mauler.getRandom().nextBetween(600, 1200); } this.mauler.setBurrowedDown(true); @@ -83,7 +82,7 @@ public void stop() { this.mauler.setInvulnerable(false); this.mauler.setBurrowedDown(false); this.mauler.setTicksUntilNextBurrowingDown( - RandomGenerator.generateInt( + this.mauler.getRandom().nextBetween( MaulerEntity.MIN_TICKS_UNTIL_NEXT_BURROWING, MaulerEntity.MAX_TICKS_UNTIL_NEXT_BURROWING ) diff --git a/common/src/main/java/com/faboslav/friendsandfoes/mixin/BeeEntityMoveToFlowerGoalMixin.java b/common/src/main/java/com/faboslav/friendsandfoes/mixin/BeeEntityMoveToFlowerGoalMixin.java new file mode 100644 index 000000000..8db595edc --- /dev/null +++ b/common/src/main/java/com/faboslav/friendsandfoes/mixin/BeeEntityMoveToFlowerGoalMixin.java @@ -0,0 +1,35 @@ +package com.faboslav.friendsandfoes.mixin; + +import com.llamalad7.mixinextras.injector.ModifyReceiver; +import net.minecraft.entity.passive.BeeEntity; +import net.minecraft.util.math.random.Random; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; + +@Mixin(BeeEntity.MoveToFlowerGoal.class) +public class BeeEntityMoveToFlowerGoalMixin +{ + @Final + @Shadow(aliases = {"field_226508_a_", "field_20372", "f_28009_"}) + private BeeEntity this$0; + + /** + * Inspired by use in Bumblezone mod + * + * @author TelepathicGrunt + * @reason Always use the entity's own randomSource instead of world's when creating/initing entities or else you risk a crash from threaded worldgen entity spawning. Fixed this bug with vanilla bees. + * <a href="https://github.com/TelepathicGrunt/Bumblezone/blob/1.20-Arch/common/src/main/java/com/telepathicgrunt/the_bumblezone/mixin/entities/BeeHiveGoalMixin.java</a> + */ + @ModifyReceiver( + method = "<init>(Lnet/minecraft/entity/passive/BeeEntity;)V", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/util/math/random/Random;nextInt(I)I" + ) + ) + private Random friendsandfoes_fixGoalRandomSourceUsage1(Random randomSource, int range) { + return this$0.getRandom(); + } +} diff --git a/common/src/main/java/com/faboslav/friendsandfoes/mixin/BeeEntityMoveToHiveGoalMixin.java b/common/src/main/java/com/faboslav/friendsandfoes/mixin/BeeEntityMoveToHiveGoalMixin.java new file mode 100644 index 000000000..65a94d188 --- /dev/null +++ b/common/src/main/java/com/faboslav/friendsandfoes/mixin/BeeEntityMoveToHiveGoalMixin.java @@ -0,0 +1,35 @@ +package com.faboslav.friendsandfoes.mixin; + +import com.llamalad7.mixinextras.injector.ModifyReceiver; +import net.minecraft.entity.passive.BeeEntity; +import net.minecraft.util.math.random.Random; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; + +@Mixin(BeeEntity.MoveToHiveGoal.class) +public class BeeEntityMoveToHiveGoalMixin +{ + @Final + @Shadow(aliases = {"field_226508_a_", "field_20371", "f_27979_"}) + private BeeEntity this$0; + + /** + * Inspired by use in Bumblezone mod + * + * @author TelepathicGrunt + * @reason Always use the entity's own randomSource instead of world's when creating/initing entities or else you risk a crash from threaded worldgen entity spawning. Fixed this bug with vanilla bees. + * <a href="https://github.com/TelepathicGrunt/Bumblezone/blob/1.20-Arch/common/src/main/java/com/telepathicgrunt/the_bumblezone/mixin/entities/BeeGoToKnownFlowerGoalMixin.java</a> + */ + @ModifyReceiver( + method = "<init>(Lnet/minecraft/entity/passive/BeeEntity;)V", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/util/math/random/Random;nextInt(I)I" + ) + ) + private Random friendsandfoes_fixGoalRandomSourceUsage2(Random randomSource, int range) { + return this$0.getRandom(); + } +} diff --git a/common/src/main/java/com/faboslav/friendsandfoes/mixin/IllusionerEntityMixin.java b/common/src/main/java/com/faboslav/friendsandfoes/mixin/IllusionerEntityMixin.java index ff735a3c1..6bdd70dd4 100644 --- a/common/src/main/java/com/faboslav/friendsandfoes/mixin/IllusionerEntityMixin.java +++ b/common/src/main/java/com/faboslav/friendsandfoes/mixin/IllusionerEntityMixin.java @@ -2,7 +2,6 @@ import com.faboslav.friendsandfoes.FriendsAndFoes; import com.faboslav.friendsandfoes.entity.IllusionerEntityAccess; -import com.faboslav.friendsandfoes.util.RandomGenerator; import com.llamalad7.mixinextras.injector.WrapWithCondition; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityType; @@ -287,7 +286,7 @@ private void friendsandfoes_createIllusions() { Vec3d illusionerPosition = this.getPos(); float slice = 2.0F * (float) Math.PI / MAX_ILLUSIONS_COUNT; int radius = 9; - int randomPoint = RandomGenerator.generateInt(0, MAX_ILLUSIONS_COUNT - 1); + int randomPoint = this.getRandom().nextBetween(0, MAX_ILLUSIONS_COUNT - 1); for (int point = 0; point < MAX_ILLUSIONS_COUNT; ++point) { float angle = slice * point; diff --git a/common/src/main/java/com/faboslav/friendsandfoes/mixin/PlayerEntityMixin.java b/common/src/main/java/com/faboslav/friendsandfoes/mixin/PlayerEntityMixin.java index 8101a254a..d89b2f6c0 100644 --- a/common/src/main/java/com/faboslav/friendsandfoes/mixin/PlayerEntityMixin.java +++ b/common/src/main/java/com/faboslav/friendsandfoes/mixin/PlayerEntityMixin.java @@ -6,7 +6,6 @@ import com.faboslav.friendsandfoes.init.FriendsAndFoesSoundEvents; import com.faboslav.friendsandfoes.platform.TotemHelper; import com.faboslav.friendsandfoes.tag.FriendsAndFoesTags; -import com.faboslav.friendsandfoes.util.RandomGenerator; import net.minecraft.advancement.criterion.Criteria; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityType; @@ -183,7 +182,7 @@ private void friendsandfoes_createIllusions() { Vec3d illusionerPosition = this.getPos(); float slice = 2.0F * (float) Math.PI / MAX_ILLUSIONS_COUNT; int radius = 9; - int randomPoint = RandomGenerator.generateInt(0, MAX_ILLUSIONS_COUNT - 1); + int randomPoint = this.getRandom().nextBetween(0, MAX_ILLUSIONS_COUNT - 1); ArrayList<PlayerIllusionEntity> createdPlayerIllusions = new ArrayList<>(); diff --git a/common/src/main/java/com/faboslav/friendsandfoes/world/spawner/IceologerSpawner.java b/common/src/main/java/com/faboslav/friendsandfoes/world/spawner/IceologerSpawner.java index 5cbfe2f21..87826b8fa 100644 --- a/common/src/main/java/com/faboslav/friendsandfoes/world/spawner/IceologerSpawner.java +++ b/common/src/main/java/com/faboslav/friendsandfoes/world/spawner/IceologerSpawner.java @@ -3,7 +3,6 @@ import com.faboslav.friendsandfoes.FriendsAndFoes; import com.faboslav.friendsandfoes.init.FriendsAndFoesEntityTypes; import com.faboslav.friendsandfoes.tag.FriendsAndFoesTags; -import com.faboslav.friendsandfoes.util.RandomGenerator; import net.minecraft.block.BlockState; import net.minecraft.entity.SpawnReason; import net.minecraft.entity.mob.PatrolEntity; @@ -38,13 +37,13 @@ public int spawn(ServerWorld world, boolean spawnMonsters, boolean spawnAnimals) return 0; } - this.cooldown += 12000 + RandomGenerator.generateInt(0, 1000); + this.cooldown += 12000 + random.nextInt(1000); long l = world.getTimeOfDay() / 24000L; if ( l < 5L || world.isDay() == false - || RandomGenerator.generateInt(0, 1) != 0 + || random.nextBetween(0, 1) != 0 ) { return 0; } diff --git a/common/src/main/java/com/faboslav/friendsandfoes/world/spawner/IllusionerSpawner.java b/common/src/main/java/com/faboslav/friendsandfoes/world/spawner/IllusionerSpawner.java index 4c04cce87..b94e39305 100644 --- a/common/src/main/java/com/faboslav/friendsandfoes/world/spawner/IllusionerSpawner.java +++ b/common/src/main/java/com/faboslav/friendsandfoes/world/spawner/IllusionerSpawner.java @@ -2,7 +2,6 @@ import com.faboslav.friendsandfoes.FriendsAndFoes; import com.faboslav.friendsandfoes.tag.FriendsAndFoesTags; -import com.faboslav.friendsandfoes.util.RandomGenerator; import net.minecraft.block.BlockState; import net.minecraft.entity.EntityType; import net.minecraft.entity.SpawnReason; @@ -45,7 +44,7 @@ public int spawn(ServerWorld world, boolean spawnMonsters, boolean spawnAnimals) if ( l < 5L || world.isDay() == false - || RandomGenerator.generateInt(0, 1) != 0 + || random.nextBetween(0, 1) != 0 ) { return 0; } diff --git a/common/src/main/resources/friendsandfoes-common.mixins.json b/common/src/main/resources/friendsandfoes-common.mixins.json index f37b1b39b..ec0294f7c 100644 --- a/common/src/main/resources/friendsandfoes-common.mixins.json +++ b/common/src/main/resources/friendsandfoes-common.mixins.json @@ -10,6 +10,8 @@ "AxeItemMixin", "BeeEntityAccessor", "BeeEntityMixin", + "BeeEntityMoveToFlowerGoalMixin", + "BeeEntityMoveToHiveGoalMixin", "BlazeEntityMixin", "BlazeLivingEntityMixin", "BlindTargetGoalFactory", diff --git a/fabric/build.gradle b/fabric/build.gradle index dff278a9a..6e65218c8 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -6,6 +6,12 @@ allprojects { archivesBaseName = "${rootProject.mod_id}-fabric-mc${rootProject.minecraft_version}" } +configurations.all { + resolutionStrategy { + force "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}" + } +} + architectury { platformSetupLoomIde() fabric() @@ -27,11 +33,11 @@ dependencies { // Core dependencies modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}" modApi "net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_api_version}" - + // Trinkets modApi("dev.emi:trinkets:${rootProject.trinkets_version}") - include(implementation(annotationProcessor("com.github.llamalad7.mixinextras:mixinextras-fabric:${rootProject.mixin_extras_version}"))) + include(implementation(annotationProcessor("io.github.llamalad7:mixinextras-fabric:${rootProject.mixin_extras_version}"))) // Config dependencies modApi("com.terraformersmc:modmenu:${project.mod_menu_version}") diff --git a/forge/build.gradle b/forge/build.gradle index e41887ff4..e51817c60 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -36,8 +36,8 @@ dependencies { common(project(path: ":common", configuration: "namedElements")) { transitive false } shadowCommon(project(path: ":common", configuration: "transformProductionForge")) { transitive = false } - implementation(annotationProcessor("com.github.llamalad7.mixinextras:mixinextras-common:${rootProject.mixin_extras_version}")) - implementation(include("com.github.llamalad7.mixinextras:mixinextras-forge:${rootProject.mixin_extras_version}")) + implementation(annotationProcessor("io.github.llamalad7:mixinextras-common:${rootProject.mixin_extras_version}")) + implementation(include("io.github.llamalad7:mixinextras-forge:${rootProject.mixin_extras_version}")) // Curios modImplementation("top.theillusivec4.curios:curios-forge:${project.curios_version}:api") diff --git a/gradle.properties b/gradle.properties index e505ab073..7adfbf0ee 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,7 +8,7 @@ org.gradle.configureondemand=false # Mod mod_name=Friends&Foes mod_id=friendsandfoes -mod_version=1.9.5 +mod_version=1.9.6 mod_author=Faboslav mod_description=Adds outvoted and forgotten mobs from the mob votes in a believable vanilla plus style. maven_group=com.faboslav.friendsandfoes @@ -24,7 +24,7 @@ enabled_platforms=fabric,forge # Common cloth_config_version=11.0.99 -mixin_extras_version=0.2.0-beta.9 +mixin_extras_version=0.2.0-rc.5 trinkets_version=3.7.1 # Fabric https://fabricmc.net/versions.html @@ -33,7 +33,3 @@ fabric_api_version=0.85.0+1.20.1 # Forge https://files.minecraftforge.net/net/minecraftforge/forge/index_1.20.1.html forge_version=1.20.1-47.1.28 - -# Quilt https://lambdaurora.dev/tools/import_quilt.html -quilt_loader_version=0.19.3-beta.1 -quilt_fabric_api_version=7.0.6+0.85.0-1.20.1 \ No newline at end of file diff --git a/quilt/build.gradle b/quilt/build.gradle deleted file mode 100644 index a0833d5fe..000000000 --- a/quilt/build.gradle +++ /dev/null @@ -1,117 +0,0 @@ -plugins { - id "com.github.johnrengelman.shadow" version "8.1.1" -} - -allprojects { - archivesBaseName = "${rootProject.mod_id}-quilt-mc${rootProject.minecraft_version}" -} - -architectury { - platformSetupLoomIde() - loader("quilt") -} - -loom { - accessWidenerPath = project(":common").loom.accessWidenerPath -} - -configurations { - common - shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this. - compileClasspath.extendsFrom common - runtimeClasspath.extendsFrom common - developmentQuilt.extendsFrom common -} - -dependencies { - // Core dependencies - modImplementation "org.quiltmc:quilt-loader:${rootProject.quilt_loader_version}" - modApi "org.quiltmc.quilted-fabric-api:quilted-fabric-api:${rootProject.quilt_fabric_api_version}" - - // Trinkets - modApi("dev.emi:trinkets:${rootProject.trinkets_version}") - - // Mixins extras - include(implementation(annotationProcessor("com.github.llamalad7.mixinextras:mixinextras-fabric:${rootProject.mixin_extras_version}"))) - - common(project(path: ":common", configuration: "namedElements")) { transitive false } - shadowCommon(project(path: ":common", configuration: "transformProductionQuilt")) { transitive false } -} - -processResources { - inputs.property "group", rootProject.maven_group - inputs.property 'modId', rootProject.mod_id - inputs.property 'modName', rootProject.mod_name - inputs.property 'modDescription', rootProject.mod_description - inputs.property 'modVersion', rootProject.mod_version - inputs.property 'modAuthor', rootProject.mod_author - - filesMatching("quilt.mod.json") { - expand([ - 'group' : rootProject.maven_group, - 'modId' : rootProject.mod_id, - 'modName' : rootProject.mod_name, - 'modDescription': rootProject.mod_description, - 'modVersion' : rootProject.mod_version, - 'modAuthor' : rootProject.mod_author - ]) - } - - from(project(":common").sourceSets.main.resources) -} - -shadowJar { - exclude "architectury.common.json" - - configurations = [project.configurations.shadowCommon] - archiveClassifier.set("dev-shadow") -} - -remapJar { - injectAccessWidener = true - inputFile.set shadowJar.archiveFile - dependsOn shadowJar - archiveClassifier.set(null) -} - -jar { - archiveClassifier.set("dev") -} - -sourcesJar { - def commonSources = project(":common").sourcesJar - dependsOn commonSources - from commonSources.archiveFile.map { zipTree(it) } -} - -components.java { - withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) { - skip() - } -} - -repositories { - maven { url "https://maven.quiltmc.org/repository/release/" } - - maven { - name = "TerraformersMC" - url "https://maven.terraformersmc.com/releases/" - } - - maven { - name = "Ladysnake Libs" - url = 'https://maven.ladysnake.org/releases' - } -} - -publishing { - publications { - mavenFabric(MavenPublication) { - artifactId = rootProject.mod_id + "-" + project.name - from components.java - } - } - - repositories { - } -} diff --git a/quilt/gradle.properties b/quilt/gradle.properties deleted file mode 100644 index 96758ce85..000000000 --- a/quilt/gradle.properties +++ /dev/null @@ -1 +0,0 @@ -loom.platform=quilt \ No newline at end of file diff --git a/quilt/src/main/java/com/faboslav/friendsandfoes/mixin/quilt/AddCustomEntityPoseMixin.java b/quilt/src/main/java/com/faboslav/friendsandfoes/mixin/quilt/AddCustomEntityPoseMixin.java deleted file mode 100644 index 8af05c81a..000000000 --- a/quilt/src/main/java/com/faboslav/friendsandfoes/mixin/quilt/AddCustomEntityPoseMixin.java +++ /dev/null @@ -1,74 +0,0 @@ -package com.faboslav.friendsandfoes.mixin.quilt; - -import com.faboslav.friendsandfoes.entity.pose.TuffGolemEntityPose; -import net.minecraft.entity.EntityPose; -import org.objectweb.asm.Opcodes; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Mutable; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.gen.Invoker; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -import java.util.ArrayList; -import java.util.Arrays; - -@Mixin(EntityPose.class) -@SuppressWarnings({"ShadowTarget", "InvokerTarget"}) -public final class AddCustomEntityPoseMixin -{ - @Invoker("<init>") - private static EntityPose newEntityPose( - String internalName, - int internalId - ) { - throw new AssertionError(); - } - - @Shadow - private static @Final - @Mutable - EntityPose[] field_18083; - - @Inject( - method = "<clinit>", - at = @At( - value = "FIELD", - opcode = Opcodes.PUTSTATIC, - target = "Lnet/minecraft/entity/EntityPose;field_18083:[Lnet/minecraft/entity/EntityPose;", - shift = At.Shift.AFTER - ) - ) - private static void friendsandfoes_addCustomEntityPoses(CallbackInfo ci) { - var entityPoses = new ArrayList<>(Arrays.asList(field_18083)); - var lastEntityPose = entityPoses.get(entityPoses.size() - 1); - - var tuffGolemStanding = newEntityPose( - TuffGolemEntityPose.STANDING.getName(), - lastEntityPose.ordinal() + 1 - ); - entityPoses.add(tuffGolemStanding); - - var tuffGolemStandingWithItem = newEntityPose( - TuffGolemEntityPose.STANDING_WITH_ITEM.getName(), - lastEntityPose.ordinal() + 2 - ); - entityPoses.add(tuffGolemStandingWithItem); - - var tuffGolemSleeping = newEntityPose( - TuffGolemEntityPose.SLEEPING.getName(), - lastEntityPose.ordinal() + 3 - ); - entityPoses.add(tuffGolemSleeping); - - var tuffGolemSleepingWithItem = newEntityPose( - TuffGolemEntityPose.SLEEPING_WITH_ITEM.getName(), - lastEntityPose.ordinal() + 4 - ); - entityPoses.add(tuffGolemSleepingWithItem); - - field_18083 = entityPoses.toArray(new EntityPose[0]); - } -} diff --git a/quilt/src/main/java/com/faboslav/friendsandfoes/mixin/quilt/AddCustomRaidMemberMixin.java b/quilt/src/main/java/com/faboslav/friendsandfoes/mixin/quilt/AddCustomRaidMemberMixin.java deleted file mode 100644 index ea615e14e..000000000 --- a/quilt/src/main/java/com/faboslav/friendsandfoes/mixin/quilt/AddCustomRaidMemberMixin.java +++ /dev/null @@ -1,78 +0,0 @@ -package com.faboslav.friendsandfoes.mixin.quilt; - -import com.faboslav.friendsandfoes.FriendsAndFoes; -import com.faboslav.friendsandfoes.init.FriendsAndFoesEntityTypes; -import com.faboslav.friendsandfoes.util.CustomRaidMember; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.raid.RaiderEntity; -import net.minecraft.village.raid.Raid; -import org.objectweb.asm.Opcodes; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Mutable; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.gen.Invoker; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -import java.util.ArrayList; -import java.util.Arrays; - -@Mixin(Raid.Member.class) -@SuppressWarnings({"ShadowTarget", "InvokerTarget"}) -public final class AddCustomRaidMemberMixin -{ - @Invoker("<init>") - private static Raid.Member newRaidMember( - String internalName, - int internalId, - EntityType<? extends RaiderEntity> entityType, - int[] countInWave - ) { - throw new AssertionError(); - } - - @Shadow - private static @Final - @Mutable - Raid.Member[] field_16632; - - @Inject( - method = "<clinit>", - at = @At( - value = "FIELD", - opcode = Opcodes.PUTSTATIC, - target = "Lnet/minecraft/village/raid/Raid$Member;field_16632:[Lnet/minecraft/village/raid/Raid$Member;", - shift = At.Shift.AFTER - ) - ) - private static void friendsandfoes_addCustomRaidMembers(CallbackInfo ci) { - var raidMembers = new ArrayList<>(Arrays.asList(field_16632)); - var lastRaidMember = raidMembers.get(raidMembers.size() - 1); - - if (FriendsAndFoes.getConfig().enableIceologerInRaids) { - var iceologerRaidMember = newRaidMember( - CustomRaidMember.ICEOLOGER_INTERNAL_NAME, - lastRaidMember.ordinal() + 1, - FriendsAndFoesEntityTypes.ICEOLOGER.get(), - CustomRaidMember.ICEOLOGER_COUNT_IN_WAVE - ); - CustomRaidMember.ICEOLOGER = iceologerRaidMember; - raidMembers.add(iceologerRaidMember); - } - - if (FriendsAndFoes.getConfig().enableIllusionerInRaids) { - var illusionerRaidMember = newRaidMember( - CustomRaidMember.ILLUSIONER_INTERNAL_NAME, - lastRaidMember.ordinal() + 2, - EntityType.ILLUSIONER, - CustomRaidMember.ILLUSIONER_COUNT_IN_WAVE - ); - CustomRaidMember.ILLUSIONER = illusionerRaidMember; - raidMembers.add(illusionerRaidMember); - } - - field_16632 = raidMembers.toArray(new Raid.Member[0]); - } -} diff --git a/quilt/src/main/java/com/faboslav/friendsandfoes/mixin/quilt/AddCustomSpawnGroupMixin.java b/quilt/src/main/java/com/faboslav/friendsandfoes/mixin/quilt/AddCustomSpawnGroupMixin.java deleted file mode 100644 index d047a554b..000000000 --- a/quilt/src/main/java/com/faboslav/friendsandfoes/mixin/quilt/AddCustomSpawnGroupMixin.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.faboslav.friendsandfoes.mixin.quilt; - -import com.faboslav.friendsandfoes.platform.CustomSpawnGroup; -import com.faboslav.friendsandfoes.platform.fabric.CustomSpawnGroupImpl; -import net.minecraft.entity.SpawnGroup; -import org.objectweb.asm.Opcodes; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Mutable; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.gen.Invoker; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -import java.util.ArrayList; -import java.util.Arrays; - -@Mixin(SpawnGroup.class) -@SuppressWarnings({"ShadowTarget", "InvokerTarget"}) -public final class AddCustomSpawnGroupMixin -{ - @Invoker("<init>") - public static SpawnGroup newSpawnGroup( - String internalName, - int internalId, - String name, - int spawnCap, - boolean peaceful, - boolean rare, - int immediateDespawnRange - ) { - throw new AssertionError(); - } - - @Shadow - private static @Final - @Mutable - SpawnGroup[] field_6301; - - @Inject( - method = "<clinit>", - at = @At( - value = "FIELD", - opcode = Opcodes.PUTSTATIC, - target = "Lnet/minecraft/entity/SpawnGroup;field_6301:[Lnet/minecraft/entity/SpawnGroup;", - shift = At.Shift.AFTER - ) - ) - private static void friendsandfoes_addCustomSpawnGroup(CallbackInfo ci) { - var spawnGroups = new ArrayList<>(Arrays.asList(field_6301)); - var lastSpawnGroup = spawnGroups.get(spawnGroups.size() - 1); - - var glaresSpawnGroup = newSpawnGroup( - CustomSpawnGroup.GLARES_INTERNAL_NAME, - lastSpawnGroup.ordinal() + 1, - CustomSpawnGroup.NAME, - CustomSpawnGroup.SPAWN_CAP, - CustomSpawnGroup.PEACEFUL, - CustomSpawnGroup.RARE, - CustomSpawnGroup.IMMEDIATE_DESPAWN_RANGE - ); - CustomSpawnGroupImpl.GLARES = glaresSpawnGroup; - spawnGroups.add(glaresSpawnGroup); - - field_6301 = spawnGroups.toArray(new SpawnGroup[0]); - } -} \ No newline at end of file diff --git a/quilt/src/main/java/com/faboslav/friendsandfoes/mixin/quilt/StructureEntityProcessorMixin.java b/quilt/src/main/java/com/faboslav/friendsandfoes/mixin/quilt/StructureEntityProcessorMixin.java deleted file mode 100644 index df9854b0d..000000000 --- a/quilt/src/main/java/com/faboslav/friendsandfoes/mixin/quilt/StructureEntityProcessorMixin.java +++ /dev/null @@ -1,225 +0,0 @@ -package com.faboslav.friendsandfoes.mixin.quilt; - -import com.faboslav.friendsandfoes.world.processor.StructureEntityProcessor; -import net.fabricmc.loader.api.FabricLoader; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.SpawnReason; -import net.minecraft.entity.mob.MobEntity; -import net.minecraft.nbt.NbtCompound; -import net.minecraft.nbt.NbtDouble; -import net.minecraft.nbt.NbtList; -import net.minecraft.structure.StructurePlacementData; -import net.minecraft.structure.StructureTemplate; -import net.minecraft.structure.StructureTemplate.StructureEntityInfo; -import net.minecraft.structure.processor.StructureProcessor; -import net.minecraft.util.BlockMirror; -import net.minecraft.util.BlockRotation; -import net.minecraft.util.math.BlockBox; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Vec3d; -import net.minecraft.util.math.random.Random; -import net.minecraft.world.ServerWorldAccess; -import org.jetbrains.annotations.Nullable; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; - -/** - * Allows for processing entities in Jigsaw structures. - * Originally from YUNG's API by. - * YUNGNICKYOUNG(https://github.com/YUNG-GANG/YUNGs-API) - */ -@Mixin(StructureTemplate.class) -public final class StructureEntityProcessorMixin -{ - @Shadow - @Final - private List<StructureEntityInfo> entities; - - /** - * Reimplements vanilla behavior for spawning entities, - * but with additional behavior allowing for the use of entity processing ({@link StructureEntityProcessor}) - */ - @Inject( - method = "place", - at = @At( - value = "INVOKE", - target = "net/minecraft/structure/StructureTemplate.spawnEntities (Lnet/minecraft/world/ServerWorldAccess;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/BlockMirror;Lnet/minecraft/util/BlockRotation;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/math/BlockBox;Z)V" - ) - ) - private void friendsandfoes_processEntities( - ServerWorldAccess serverWorldAccess, - BlockPos structurePiecePos, - BlockPos structurePieceBottomCenterPos, - StructurePlacementData structurePlacementData, - Random random, - int flags, - CallbackInfoReturnable<Boolean> cir - ) { - if (FabricLoader.getInstance().isModLoaded("yungsapi") == false) { - for (StructureEntityInfo entityInfo : friendsandfoes_processEntityInfos( - serverWorldAccess, - structurePiecePos, - structurePieceBottomCenterPos, - structurePlacementData, - this.entities - )) { - BlockPos blockPos = entityInfo.blockPos; - - if ( - structurePlacementData.getBoundingBox() != null - && structurePlacementData.getBoundingBox().contains(blockPos) == false - ) { - continue; - } - - NbtCompound compoundTag = entityInfo.nbt.copy(); - Vec3d vec3d = entityInfo.pos; - - NbtList nbtList = new NbtList(); - nbtList.add(NbtDouble.of(vec3d.getX())); - nbtList.add(NbtDouble.of(vec3d.getY())); - nbtList.add(NbtDouble.of(vec3d.getZ())); - compoundTag.put("Pos", nbtList); - compoundTag.remove("UUID"); - - friendsandfoes_getEntity(serverWorldAccess, compoundTag).ifPresent((entity) -> { - float f = entity.applyMirror(structurePlacementData.getMirror()); - f += entity.getYaw() - entity.applyRotation(structurePlacementData.getRotation()); - entity.refreshPositionAndAngles( - vec3d.getX(), - vec3d.getY(), - vec3d.getZ(), - f, - entity.getPitch() - ); - if (structurePlacementData.shouldInitializeMobs() && entity instanceof MobEntity) { - ((MobEntity) entity).initialize( - serverWorldAccess, - serverWorldAccess.getLocalDifficulty( - new BlockPos( - (int) vec3d.getX(), - (int) vec3d.getY(), - (int) vec3d.getZ() - ) - ), - SpawnReason.STRUCTURE, - null, - compoundTag - ); - } - - serverWorldAccess.spawnEntityAndPassengers(entity); - }); - } - } - } - - /** - * Cancel spawning entities. - * This behavior is recreated in {@link #friendsandfoes_processEntities} - */ - @Inject( - method = "spawnEntities", - at = @At(value = "HEAD"), - cancellable = true - ) - private void friendsandfoes_cancelPlaceEntities( - ServerWorldAccess serverWorldAccess, - BlockPos structurePiecePos, - BlockMirror mirror, - BlockRotation rotation, - BlockPos pivot, - @Nullable BlockBox area, - boolean initializeMobs, - CallbackInfo ci - ) { - if (FabricLoader.getInstance().isModLoaded("yungsapi") == false) { - ci.cancel(); - } - } - - /** - * Applies placement data and {@link StructureEntityProcessor}s to entities in a structure. - */ - private List<StructureEntityInfo> friendsandfoes_processEntityInfos( - ServerWorldAccess serverWorldAccess, - BlockPos structurePiecePos, - BlockPos structurePieceBottomCenterPos, - StructurePlacementData structurePlacementData, - List<StructureEntityInfo> rawEntityList - ) { - List<StructureEntityInfo> processedEntities = new ArrayList<>(); - - for (StructureEntityInfo rawEntityItem : rawEntityList) { - // Calculate transformed position so processors have access to the actual global world coordinates of the entity - Vec3d globalPos = StructureTemplate - .transformAround( - rawEntityItem.pos, - structurePlacementData.getMirror(), - structurePlacementData.getRotation(), - structurePlacementData.getPosition() - ).add(Vec3d.of(structurePiecePos)); - BlockPos globalBlockPos = StructureTemplate - .transformAround( - rawEntityItem.blockPos, - structurePlacementData.getMirror(), - structurePlacementData.getRotation(), - structurePlacementData.getPosition() - ).add(structurePiecePos); - - StructureEntityInfo globalEntityInfo = new StructureEntityInfo( - globalPos, - globalBlockPos, - rawEntityItem.nbt - ); - - // Apply processors - for (StructureProcessor processor : structurePlacementData.getProcessors()) { - if (processor instanceof StructureEntityProcessor == false) { - continue; - } - - globalEntityInfo = ((StructureEntityProcessor) processor).processEntity( - serverWorldAccess, - structurePiecePos, - structurePieceBottomCenterPos, - rawEntityItem, - globalEntityInfo, - structurePlacementData - ); - - if (globalEntityInfo == null) { - break; - } - } - - // null value from processor indicates the entity should not be spawned - if (globalEntityInfo != null) { - processedEntities.add(globalEntityInfo); - } - } - - return processedEntities; - } - - private static Optional<Entity> friendsandfoes_getEntity( - ServerWorldAccess serverWorldAccess, - NbtCompound compoundTag - ) { - try { - return EntityType.getEntityFromNbt(compoundTag, serverWorldAccess.toServerWorld()); - } catch (Exception exception) { - return Optional.empty(); - } - } -} diff --git a/quilt/src/main/java/com/faboslav/friendsandfoes/platform/fabric/BiomeModificationsImpl.java b/quilt/src/main/java/com/faboslav/friendsandfoes/platform/fabric/BiomeModificationsImpl.java deleted file mode 100644 index 3ca4d32d7..000000000 --- a/quilt/src/main/java/com/faboslav/friendsandfoes/platform/fabric/BiomeModificationsImpl.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.faboslav.friendsandfoes.platform.fabric; - -import com.faboslav.friendsandfoes.FriendsAndFoes; -import net.fabricmc.fabric.api.biome.v1.BiomeModifications; -import net.fabricmc.fabric.api.biome.v1.ModificationPhase; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.SpawnGroup; -import net.minecraft.registry.RegistryKey; -import net.minecraft.registry.RegistryKeys; -import net.minecraft.registry.tag.BiomeTags; -import net.minecraft.registry.tag.TagKey; -import net.minecraft.world.biome.Biome; -import net.minecraft.world.gen.GenerationStep; - -public final class BiomeModificationsImpl -{ - public static void addMobSpawn( - TagKey<Biome> tag, - EntityType<?> entityType, - SpawnGroup spawnGroup, - int weight, - int minGroupSize, - int maxGroupSize - ) { - BiomeModifications.addSpawn(biomeSelector -> biomeSelector.hasTag(tag) && biomeSelector.hasTag(BiomeTags.IS_OVERWORLD), spawnGroup, entityType, weight, minGroupSize, maxGroupSize); - } - - public static void addButtercupFeature() { - TagKey<Biome> flowerForestTag = TagKey.of(RegistryKeys.BIOME, FriendsAndFoes.makeID("has_buttercup_patch")); - BiomeModifications.create(FriendsAndFoes.makeID("add_buttercup_patch")) - .add(ModificationPhase.ADDITIONS, - (context) -> context.hasTag(flowerForestTag), - context -> context.getGenerationSettings().addFeature( - GenerationStep.Feature.VEGETAL_DECORATION, - RegistryKey.of( - RegistryKeys.PLACED_FEATURE, - FriendsAndFoes.makeID("buttercup_patch") - ) - ) - ); - } -} diff --git a/quilt/src/main/java/com/faboslav/friendsandfoes/platform/fabric/ConfigDirectoryImpl.java b/quilt/src/main/java/com/faboslav/friendsandfoes/platform/fabric/ConfigDirectoryImpl.java deleted file mode 100644 index e8e065d2b..000000000 --- a/quilt/src/main/java/com/faboslav/friendsandfoes/platform/fabric/ConfigDirectoryImpl.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.faboslav.friendsandfoes.platform.fabric; - -import com.faboslav.friendsandfoes.platform.ConfigDirectory; -import net.fabricmc.loader.api.FabricLoader; - -import java.nio.file.Path; - -/** - * Temporary workaround for hardcoded ExpectPlatform - */ -public final class ConfigDirectoryImpl -{ - /** - * @see ConfigDirectory#getConfigDirectory() - */ - public static Path getConfigDirectory() { - return FabricLoader.getInstance().getConfigDir(); - } -} diff --git a/quilt/src/main/java/com/faboslav/friendsandfoes/platform/fabric/CustomSpawnGroupImpl.java b/quilt/src/main/java/com/faboslav/friendsandfoes/platform/fabric/CustomSpawnGroupImpl.java deleted file mode 100644 index d4c8f74f8..000000000 --- a/quilt/src/main/java/com/faboslav/friendsandfoes/platform/fabric/CustomSpawnGroupImpl.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.faboslav.friendsandfoes.platform.fabric; - -import com.faboslav.friendsandfoes.platform.CustomSpawnGroup; -import net.minecraft.entity.SpawnGroup; - -public final class CustomSpawnGroupImpl -{ - static { - SpawnGroup.values(); - } - - public static SpawnGroup GLARES; - - /** - * @see CustomSpawnGroup#getGlaresCategory() - */ - public static SpawnGroup getGlaresCategory() { - return GLARES; - } -} diff --git a/quilt/src/main/java/com/faboslav/friendsandfoes/platform/fabric/ModVersionImpl.java b/quilt/src/main/java/com/faboslav/friendsandfoes/platform/fabric/ModVersionImpl.java deleted file mode 100644 index dda19a62c..000000000 --- a/quilt/src/main/java/com/faboslav/friendsandfoes/platform/fabric/ModVersionImpl.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.faboslav.friendsandfoes.platform.fabric; - -import com.faboslav.friendsandfoes.FriendsAndFoes; -import net.fabricmc.loader.api.FabricLoader; -import org.jetbrains.annotations.Nullable; - -public final class ModVersionImpl -{ - @Nullable - public static String getModVersion() { - return FabricLoader.getInstance().getModContainer(FriendsAndFoes.MOD_ID).map(modContainer -> modContainer.getMetadata().getVersion().toString()).orElse(null); - } -} diff --git a/quilt/src/main/java/com/faboslav/friendsandfoes/platform/fabric/ProjectUrlProviderImpl.java b/quilt/src/main/java/com/faboslav/friendsandfoes/platform/fabric/ProjectUrlProviderImpl.java deleted file mode 100644 index 362687551..000000000 --- a/quilt/src/main/java/com/faboslav/friendsandfoes/platform/fabric/ProjectUrlProviderImpl.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.faboslav.friendsandfoes.platform.fabric; - -public final class ProjectUrlProviderImpl -{ - public static String getCurseForgeProjectLink() { - return "https://www.curseforge.com/minecraft/mc-mods/friends-and-foes-quilt"; - } - - public static String getModrinthProjectLink() { - return "https://modrinth.com/mod/friends-and-foes-quilt"; - } -} diff --git a/quilt/src/main/java/com/faboslav/friendsandfoes/platform/fabric/RegistryHelperImpl.java b/quilt/src/main/java/com/faboslav/friendsandfoes/platform/fabric/RegistryHelperImpl.java deleted file mode 100644 index 3b7726ffe..000000000 --- a/quilt/src/main/java/com/faboslav/friendsandfoes/platform/fabric/RegistryHelperImpl.java +++ /dev/null @@ -1,168 +0,0 @@ -package com.faboslav.friendsandfoes.platform.fabric; - -import com.faboslav.friendsandfoes.FriendsAndFoes; -import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap; -import net.fabricmc.fabric.api.client.rendering.v1.EntityModelLayerRegistry; -import net.fabricmc.fabric.api.client.rendering.v1.EntityRendererRegistry; -import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents; -import net.fabricmc.fabric.api.object.builder.v1.entity.FabricDefaultAttributeRegistry; -import net.fabricmc.fabric.api.registry.FlammableBlockRegistry; -import net.minecraft.block.Block; -import net.minecraft.block.BlockSetType; -import net.minecraft.client.model.TexturedModelData; -import net.minecraft.client.render.RenderLayer; -import net.minecraft.client.render.entity.EntityRendererFactory; -import net.minecraft.client.render.entity.model.EntityModelLayer; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.ai.brain.Activity; -import net.minecraft.entity.ai.brain.MemoryModuleType; -import net.minecraft.entity.attribute.DefaultAttributeContainer; -import net.minecraft.entity.mob.MobEntity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemGroup; -import net.minecraft.item.SpawnEggItem; -import net.minecraft.registry.Registries; -import net.minecraft.registry.Registry; -import net.minecraft.particle.DefaultParticleType; -import net.minecraft.registry.RegistryKey; -import net.minecraft.sound.SoundEvent; -import net.minecraft.structure.processor.StructureProcessor; -import net.minecraft.structure.processor.StructureProcessorType; -import net.minecraft.village.VillagerProfession; -import net.minecraft.world.gen.structure.Structure; -import net.minecraft.world.gen.structure.StructureType; -import net.minecraft.world.poi.PointOfInterestType; - -import java.util.function.Supplier; - -public final class RegistryHelperImpl -{ - public static void addToItemGroupBefore(RegistryKey<ItemGroup> itemGroup, Item item, Item before) { - ItemGroupEvents.modifyEntriesEvent(itemGroup).register((content) -> { - content.addBefore(before, item.getDefaultStack()); - }); - } - - public static void addToItemGroupAfter(RegistryKey<ItemGroup> itemGroup, Item item, Item after) { - ItemGroupEvents.modifyEntriesEvent(itemGroup).register((content) -> { - content.addAfter(after, item.getDefaultStack()); - }); - } - - public static <T extends Activity> Supplier<T> registerActivity(String name, Supplier<T> activity) { - var registry = Registry.register(Registries.ACTIVITY, FriendsAndFoes.makeID(name), activity.get()); - return () -> registry; - } - - public static <T extends Block> Supplier<T> registerBlock(String name, Supplier<T> block) { - var registry = Registry.register(Registries.BLOCK, FriendsAndFoes.makeID(name), block.get()); - return () -> registry; - } - - public static void registerBlockSetType(Supplier<BlockSetType> blockSetType) { - BlockSetType.register(blockSetType.get()); - } - - public static void registerEntityModelLayer(EntityModelLayer location, Supplier<TexturedModelData> definition) { - EntityModelLayerRegistry.registerModelLayer(location, definition::get); - } - - public static <T extends Entity> void registerEntityRenderer( - Supplier<EntityType<T>> type, - EntityRendererFactory<T> renderProvider - ) { - EntityRendererRegistry.register(type.get(), renderProvider); - } - - public static <T extends Entity> Supplier<EntityType<T>> registerEntityType( - String name, - Supplier<EntityType<T>> entityType - ) { - var registry = Registry.register(Registries.ENTITY_TYPE, FriendsAndFoes.makeID(name), entityType.get()); - return () -> registry; - } - - public static void registerEntityAttribute( - Supplier<? extends EntityType<? extends LivingEntity>> type, - Supplier<DefaultAttributeContainer.Builder> attribute - ) { - FabricDefaultAttributeRegistry.register(type.get(), attribute.get()); - } - - public static <T extends Item> Supplier<T> registerItem(String name, Supplier<T> item) { - var registry = Registry.register(Registries.ITEM, FriendsAndFoes.makeID(name), item.get()); - return () -> registry; - } - - public static <T extends Item> Supplier<T> registerSpawnEggItem( - String name, - Supplier<? extends EntityType<? extends MobEntity>> type, - int backgroundColor, - int highlightColor, - Item.Settings props - ) { - return (Supplier<T>) registerItem(name, () -> new SpawnEggItem(type.get(), backgroundColor, highlightColor, props)); - } - - public static <T extends MemoryModuleType<?>> Supplier<T> registerMemoryModuleType( - String name, - Supplier<T> memoryModuleType - ) { - var registry = Registry.register(Registries.MEMORY_MODULE_TYPE, FriendsAndFoes.makeID(name), memoryModuleType.get()); - return () -> registry; - } - - public static void registerParticleType(String name, DefaultParticleType particleType) { - Registry.register(Registries.PARTICLE_TYPE, FriendsAndFoes.makeStringID(name), particleType); - } - - public static <T extends PointOfInterestType> Supplier<T> registerPointOfInterestType( - String name, - Supplier<T> pointOfInterestType - ) { - var registry = Registry.register(Registries.POINT_OF_INTEREST_TYPE, FriendsAndFoes.makeID(name), pointOfInterestType.get()); - return () -> registry; - } - - public static void registerRenderType(RenderLayer type, Block... blocks) { - BlockRenderLayerMap.INSTANCE.putBlocks(type, blocks); - } - - public static <T extends SoundEvent> Supplier<T> registerSoundEvent(String name, Supplier<T> soundEvent) { - var registry = Registry.register(Registries.SOUND_EVENT, FriendsAndFoes.makeID(name), soundEvent.get()); - return () -> registry; - } - - public static <T extends VillagerProfession> Supplier<T> registerVillagerProfession( - String name, - Supplier<T> villagerProfession - ) { - var registry = Registry.register(Registries.VILLAGER_PROFESSION, FriendsAndFoes.makeID(name), villagerProfession.get()); - return () -> registry; - } - - public static <T extends Block> void registerFlammableBlock( - Block fireBlock, - Supplier<T> block, - int burnChance, - int spreadChance - ) { - FlammableBlockRegistry.getInstance(fireBlock).add(block.get(), burnChance, spreadChance); - } - - public static <T extends Structure> void registerStructureType( - String name, - StructureType<T> structureType - ) { - Registry.register(Registries.STRUCTURE_TYPE, FriendsAndFoes.makeID(name), structureType); - } - - public static <T extends StructureProcessor> void registerStructureProcessorType( - String name, - StructureProcessorType<T> structureProcessorType - ) { - Registry.register(Registries.STRUCTURE_PROCESSOR, FriendsAndFoes.makeID(name), structureProcessorType); - } -} diff --git a/quilt/src/main/java/com/faboslav/friendsandfoes/platform/fabric/StructureEntityProcessorTypesImpl.java b/quilt/src/main/java/com/faboslav/friendsandfoes/platform/fabric/StructureEntityProcessorTypesImpl.java deleted file mode 100644 index 07bbf271e..000000000 --- a/quilt/src/main/java/com/faboslav/friendsandfoes/platform/fabric/StructureEntityProcessorTypesImpl.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.faboslav.friendsandfoes.platform.fabric; - -import com.faboslav.friendsandfoes.platform.RegistryHelper; -import com.faboslav.friendsandfoes.world.processor.quilt.IceologerCabinArmorStandProcessor; -import com.faboslav.friendsandfoes.world.processor.quilt.IllusionerShackItemFrameProcessor; -import net.minecraft.structure.processor.StructureProcessorType; - -public final class StructureEntityProcessorTypesImpl -{ - public static StructureProcessorType<IceologerCabinArmorStandProcessor> ICEOLOGER_CABIN_ARMOR_STAND_PROCESSOR = () -> IceologerCabinArmorStandProcessor.CODEC; - public static StructureProcessorType<IllusionerShackItemFrameProcessor> ILLUSIONER_SHACK_ITEM_FRAME_PROCESSOR = () -> IllusionerShackItemFrameProcessor.CODEC; - - public static void init() { - RegistryHelper.registerStructureProcessorType("iceologer_cabin_armor_stand_processor", ICEOLOGER_CABIN_ARMOR_STAND_PROCESSOR); - RegistryHelper.registerStructureProcessorType("illusioner_shack_item_frame_processor", ILLUSIONER_SHACK_ITEM_FRAME_PROCESSOR); - } -} diff --git a/quilt/src/main/java/com/faboslav/friendsandfoes/platform/fabric/TotemHelperImpl.java b/quilt/src/main/java/com/faboslav/friendsandfoes/platform/fabric/TotemHelperImpl.java deleted file mode 100644 index d10c6cdcd..000000000 --- a/quilt/src/main/java/com/faboslav/friendsandfoes/platform/fabric/TotemHelperImpl.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.faboslav.friendsandfoes.platform.fabric; - -import com.faboslav.friendsandfoes.platform.TotemHelper; -import dev.emi.trinkets.api.SlotReference; -import dev.emi.trinkets.api.TrinketsApi; -import net.fabricmc.fabric.api.networking.v1.PacketByteBufs; -import net.fabricmc.fabric.api.networking.v1.PlayerLookup; -import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking; -import net.fabricmc.loader.api.FabricLoader; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.network.PacketByteBuf; -import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.util.Pair; -import org.jetbrains.annotations.Nullable; - -import java.util.List; -import java.util.function.Predicate; - -/** - * @see TotemHelper - */ -public final class TotemHelperImpl -{ - public static void sendTotemEffectPacket(ItemStack itemStack, LivingEntity livingEntity) { - PacketByteBuf buf = PacketByteBufs.create(); - buf.writeItemStack(itemStack); - buf.writeInt(livingEntity.getId()); - - if (livingEntity instanceof ServerPlayerEntity player) { - ServerPlayNetworking.send(player, TotemHelper.TOTEM_EFFECT_PACKET, buf); - } - - for (ServerPlayerEntity player : PlayerLookup.tracking((ServerWorld) livingEntity.getEntityWorld(), livingEntity.getBlockPos())) { - ServerPlayNetworking.send(player, TotemHelper.TOTEM_EFFECT_PACKET, buf); - } - } - - @Nullable - public static ItemStack getTotemFromModdedSlots(PlayerEntity player, Predicate<ItemStack> totemFilter) { - if (FabricLoader.getInstance().isModLoaded(TotemHelper.TRINKETS_MOD_ID)) { - return TrinketsApi.getTrinketComponent(player).map(component -> { - List<Pair<SlotReference, ItemStack>> res = component.getEquipped(totemFilter); - return res.size() > 0 ? res.get(0).getRight():null; - }).orElse(null); - } - - return null; - } -} - diff --git a/quilt/src/main/java/com/faboslav/friendsandfoes/quilt/FriendsAndFoesQuilt.java b/quilt/src/main/java/com/faboslav/friendsandfoes/quilt/FriendsAndFoesQuilt.java deleted file mode 100644 index 8c766e084..000000000 --- a/quilt/src/main/java/com/faboslav/friendsandfoes/quilt/FriendsAndFoesQuilt.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.faboslav.friendsandfoes.quilt; - -import com.faboslav.friendsandfoes.FriendsAndFoes; -import com.faboslav.friendsandfoes.init.FriendsAndFoesPointOfInterestTypes; -import com.faboslav.friendsandfoes.util.ServerWorldSpawnersUtil; -import com.faboslav.friendsandfoes.util.UpdateChecker; -import com.faboslav.friendsandfoes.world.spawner.IceologerSpawner; -import com.faboslav.friendsandfoes.world.spawner.IllusionerSpawner; -import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents; -import net.fabricmc.fabric.api.event.lifecycle.v1.ServerWorldEvents; -import net.minecraft.util.Util; -import net.minecraft.world.dimension.DimensionTypes; -import org.quiltmc.loader.api.ModContainer; -import org.quiltmc.qsl.base.api.entrypoint.ModInitializer; - -import static com.faboslav.friendsandfoes.FriendsAndFoes.serverTickDeltaCounter; - -public final class FriendsAndFoesQuilt implements ModInitializer -{ - @Override - public void onInitialize(ModContainer mod) { - UpdateChecker.checkForNewUpdates(); - FriendsAndFoes.init(); - FriendsAndFoes.postInit(); - FriendsAndFoesPointOfInterestTypes.postInit(); - - initSpawners(); - initTickDeltaCounter(); - } - - private static void initSpawners() { - ServerWorldEvents.LOAD.register(((server, world) -> { - if ( - world.isClient() - || world.getDimensionKey() != DimensionTypes.OVERWORLD - ) { - return; - } - - ServerWorldSpawnersUtil.register(world, new IceologerSpawner()); - ServerWorldSpawnersUtil.register(world, new IllusionerSpawner()); - })); - } - - private static void initTickDeltaCounter() { - ServerTickEvents.START_SERVER_TICK.register((server) -> { - serverTickDeltaCounter.beginRenderTick(Util.getMeasuringTimeMs()); - }); - } -} diff --git a/quilt/src/main/java/com/faboslav/friendsandfoes/quilt/FriendsAndFoesQuiltClient.java b/quilt/src/main/java/com/faboslav/friendsandfoes/quilt/FriendsAndFoesQuiltClient.java deleted file mode 100644 index fc39915be..000000000 --- a/quilt/src/main/java/com/faboslav/friendsandfoes/quilt/FriendsAndFoesQuiltClient.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.faboslav.friendsandfoes.quilt; - -import com.faboslav.friendsandfoes.FriendsAndFoesClient; -import com.faboslav.friendsandfoes.client.particle.FreezingTotemParticle; -import com.faboslav.friendsandfoes.client.particle.IllusionTotemParticle; -import com.faboslav.friendsandfoes.init.FriendsAndFoesItems; -import com.faboslav.friendsandfoes.init.FriendsAndFoesParticleTypes; -import com.faboslav.friendsandfoes.platform.TotemHelper; -import com.faboslav.friendsandfoes.util.TotemUtil; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; -import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking; -import net.fabricmc.fabric.api.client.particle.v1.ParticleFactoryRegistry; -import net.minecraft.entity.Entity; -import net.minecraft.item.ItemStack; -import org.quiltmc.loader.api.ModContainer; -import org.quiltmc.qsl.base.api.entrypoint.client.ClientModInitializer; - -public final class FriendsAndFoesQuiltClient implements ClientModInitializer -{ - @Override - @Environment(EnvType.CLIENT) - public void onInitializeClient(ModContainer mod) { - FriendsAndFoesClient.init(); - FriendsAndFoesClient.postInit(); - - this.registerParticleFactories(); - this.registerTotemPacket(); - } - - private void registerParticleFactories() { - ParticleFactoryRegistry.getInstance().register(FriendsAndFoesParticleTypes.TOTEM_OF_FREEZING, FreezingTotemParticle.Factory::new); - ParticleFactoryRegistry.getInstance().register(FriendsAndFoesParticleTypes.TOTEM_OF_ILLUSION, IllusionTotemParticle.Factory::new); - } - - private void registerTotemPacket() { - ClientPlayNetworking.registerGlobalReceiver(TotemHelper.TOTEM_EFFECT_PACKET, (client, handler, buf, responseSender) -> { - ItemStack itemStack = buf.readItemStack(); - assert client.world != null; - Entity entity = client.world.getEntityById(buf.readInt()); - - if (itemStack.getItem() == FriendsAndFoesItems.TOTEM_OF_ILLUSION.get()) { - client.execute(() -> TotemUtil.playActivateAnimation(itemStack, entity, FriendsAndFoesParticleTypes.TOTEM_OF_ILLUSION)); - } else if (itemStack.getItem() == FriendsAndFoesItems.TOTEM_OF_FREEZING.get()) { - client.execute(() -> TotemUtil.playActivateAnimation(itemStack, entity, FriendsAndFoesParticleTypes.TOTEM_OF_FREEZING)); - } - }); - } -} - diff --git a/quilt/src/main/java/com/faboslav/friendsandfoes/quilt/FriendsAndFoesQuiltServer.java b/quilt/src/main/java/com/faboslav/friendsandfoes/quilt/FriendsAndFoesQuiltServer.java deleted file mode 100644 index d19a7a450..000000000 --- a/quilt/src/main/java/com/faboslav/friendsandfoes/quilt/FriendsAndFoesQuiltServer.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.faboslav.friendsandfoes.quilt; - -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; -import org.quiltmc.loader.api.ModContainer; -import org.quiltmc.qsl.base.api.entrypoint.server.DedicatedServerModInitializer; - -public final class FriendsAndFoesQuiltServer implements DedicatedServerModInitializer -{ - @Override - @Environment(EnvType.SERVER) - public void onInitializeServer(ModContainer mod) { - } -} diff --git a/quilt/src/main/java/com/faboslav/friendsandfoes/world/processor/quilt/IceologerCabinArmorStandProcessor.java b/quilt/src/main/java/com/faboslav/friendsandfoes/world/processor/quilt/IceologerCabinArmorStandProcessor.java deleted file mode 100644 index f8a32d549..000000000 --- a/quilt/src/main/java/com/faboslav/friendsandfoes/world/processor/quilt/IceologerCabinArmorStandProcessor.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.faboslav.friendsandfoes.world.processor.quilt; - -import com.faboslav.friendsandfoes.platform.fabric.StructureEntityProcessorTypesImpl; -import com.faboslav.friendsandfoes.util.world.processor.IceologerCabinArmorStandProcessorHelper; -import com.faboslav.friendsandfoes.world.processor.StructureEntityProcessor; -import com.mojang.serialization.Codec; -import net.minecraft.structure.StructurePlacementData; -import net.minecraft.structure.StructureTemplate; -import net.minecraft.structure.processor.StructureProcessorType; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.ServerWorldAccess; -import net.minecraft.world.WorldView; -import org.jetbrains.annotations.Nullable; - -/** - * Inspired by use in Better Strongholds mod - * - * @author YUNGNICKYOUNG - * <a href="https://github.com/YUNG-GANG/YUNGs-Better-Strongholds">https://github.com/YUNG-GANG/YUNGs-Better-Strongholds</a> - */ -public final class IceologerCabinArmorStandProcessor extends StructureEntityProcessor -{ - public static final IceologerCabinArmorStandProcessor INSTANCE = new IceologerCabinArmorStandProcessor(); - public static final Codec<IceologerCabinArmorStandProcessor> CODEC = Codec.unit(() -> INSTANCE); - - @Override - public StructureTemplate.StructureEntityInfo processEntity( - ServerWorldAccess serverWorldAccess, - BlockPos structurePiecePos, - BlockPos structurePieceBottomCenterPos, - StructureTemplate.StructureEntityInfo localEntityInfo, - StructureTemplate.StructureEntityInfo globalEntityInfo, - StructurePlacementData structurePlacementData - ) { - return IceologerCabinArmorStandProcessorHelper.processEntity( - globalEntityInfo, - structurePlacementData - ); - } - - @Nullable - @Override - public StructureTemplate.StructureBlockInfo process( - WorldView world, - BlockPos pos, - BlockPos pivot, - StructureTemplate.StructureBlockInfo localEntityInfo, - StructureTemplate.StructureBlockInfo globalEntityInfo, - StructurePlacementData data - ) { - return globalEntityInfo; - } - - @Override - protected StructureProcessorType<?> getType() { - return StructureEntityProcessorTypesImpl.ICEOLOGER_CABIN_ARMOR_STAND_PROCESSOR; - } -} diff --git a/quilt/src/main/java/com/faboslav/friendsandfoes/world/processor/quilt/IllusionerShackItemFrameProcessor.java b/quilt/src/main/java/com/faboslav/friendsandfoes/world/processor/quilt/IllusionerShackItemFrameProcessor.java deleted file mode 100644 index 2ca2365d9..000000000 --- a/quilt/src/main/java/com/faboslav/friendsandfoes/world/processor/quilt/IllusionerShackItemFrameProcessor.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.faboslav.friendsandfoes.world.processor.quilt; - -import com.faboslav.friendsandfoes.platform.fabric.StructureEntityProcessorTypesImpl; -import com.faboslav.friendsandfoes.util.world.processor.IllusionerShackItemFrameProcessorHelper; -import com.faboslav.friendsandfoes.world.processor.StructureEntityProcessor; -import com.mojang.serialization.Codec; -import net.minecraft.structure.StructurePlacementData; -import net.minecraft.structure.StructureTemplate; -import net.minecraft.structure.StructureTemplate.StructureEntityInfo; -import net.minecraft.structure.processor.StructureProcessorType; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.ServerWorldAccess; -import net.minecraft.world.WorldView; -import org.jetbrains.annotations.Nullable; - -/** - * Inspired by use in Better Strongholds mod - * - * @author YUNGNICKYOUNG - * <a href="https://github.com/YUNG-GANG/YUNGs-Better-Strongholds">https://github.com/YUNG-GANG/YUNGs-Better-Strongholds</a> - */ -public final class IllusionerShackItemFrameProcessor extends StructureEntityProcessor -{ - public static final IllusionerShackItemFrameProcessor INSTANCE = new IllusionerShackItemFrameProcessor(); - public static final Codec<IllusionerShackItemFrameProcessor> CODEC = Codec.unit(() -> INSTANCE); - - @Override - public StructureEntityInfo processEntity( - ServerWorldAccess serverWorldAccess, - BlockPos structurePiecePos, - BlockPos structurePieceBottomCenterPos, - StructureEntityInfo localEntityInfo, - StructureEntityInfo globalEntityInfo, - StructurePlacementData structurePlacementData - ) { - return IllusionerShackItemFrameProcessorHelper.processEntity( - globalEntityInfo, - structurePlacementData - ); - } - - @Nullable - @Override - public StructureTemplate.StructureBlockInfo process( - WorldView world, - BlockPos pos, - BlockPos pivot, - StructureTemplate.StructureBlockInfo localEntityInfo, - StructureTemplate.StructureBlockInfo globalEntityInfo, - StructurePlacementData data - ) { - return globalEntityInfo; - } - - @Override - protected StructureProcessorType<?> getType() { - return StructureEntityProcessorTypesImpl.ILLUSIONER_SHACK_ITEM_FRAME_PROCESSOR; - } -} diff --git a/quilt/src/main/resources/friendsandfoes.mixins.json b/quilt/src/main/resources/friendsandfoes.mixins.json deleted file mode 100644 index 24b002caf..000000000 --- a/quilt/src/main/resources/friendsandfoes.mixins.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "required": true, - "package": "com.faboslav.friendsandfoes.mixin.quilt", - "compatibilityLevel": "JAVA_17", - "minVersion": "0.8", - "injectors": { - "defaultRequire": 1 - }, - "mixins": [ - "AddCustomEntityPoseMixin", - "AddCustomRaidMemberMixin", - "AddCustomSpawnGroupMixin", - "StructureEntityProcessorMixin" - ], - "plugin": "com.faboslav.friendsandfoes.util.plugin.MixinExtrasPlugin" -} \ No newline at end of file diff --git a/quilt/src/main/resources/quilt.mod.json b/quilt/src/main/resources/quilt.mod.json deleted file mode 100644 index 118865e61..000000000 --- a/quilt/src/main/resources/quilt.mod.json +++ /dev/null @@ -1,57 +0,0 @@ -{ - "schema_version": 1, - "mixin": [ - "friendsandfoes.mixins.json", - "friendsandfoes-common.mixins.json" - ], - "quilt_loader": { - "group": "${group}", - "id": "friendsandfoes", - "version": "${modVersion}", - "metadata": { - "name": "${modName}", - "description": "${modDescription}", - "authors": [ - "${modAuthor}" - ], - "contact": { - "homepage": "https://github.com/Faboslav/friends-and-foes", - "sources": "https://github.com/Faboslav/friends-and-foes", - "issues": "https://github.com/Faboslav/friends-and-foes/issues", - "wiki": "https://github.com/Faboslav/friends-and-foes/wiki" - }, - "license": "CC-BY-NC-ND-4.0", - "icon": "icon.jpg" - }, - "intermediate_mappings": "net.fabricmc:intermediary", - "entrypoints": { - "init": [ - "com.faboslav.friendsandfoes.quilt.FriendsAndFoesQuilt" - ], - "client_init": [ - "com.faboslav.friendsandfoes.quilt.FriendsAndFoesQuiltClient" - ], - "server_init": [ - "com.faboslav.friendsandfoes.quilt.FriendsAndFoesQuiltServer" - ] - }, - "depends": [ - { - "id": "java", - "version": ">=17" - }, - { - "id": "minecraft", - "version": ">=1.20" - }, - { - "id": "quilt_loader", - "version": "*" - }, - { - "id": "quilt_base", - "version": "*" - } - ] - } -} \ No newline at end of file