diff --git a/common/src/main/java/com/faboslav/friendsandfoes/advancements/criterion/CompleteHideAndSeekGameCriterion.java b/common/src/main/java/com/faboslav/friendsandfoes/advancements/criterion/CompleteHideAndSeekGameCriterion.java index ae406ae1a..83f38d587 100644 --- a/common/src/main/java/com/faboslav/friendsandfoes/advancements/criterion/CompleteHideAndSeekGameCriterion.java +++ b/common/src/main/java/com/faboslav/friendsandfoes/advancements/criterion/CompleteHideAndSeekGameCriterion.java @@ -9,7 +9,7 @@ import net.minecraft.predicate.entity.AdvancementEntityPredicateDeserializer; import net.minecraft.predicate.entity.AdvancementEntityPredicateSerializer; import net.minecraft.predicate.entity.EntityPredicate; -import net.minecraft.predicate.entity.LootContextPredicate; +import net.minecraft.predicate.entity.EntityPredicate.Extended; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.util.Identifier; @@ -26,10 +26,10 @@ public Identifier getId() { public CompleteHideAndSeekGameCriterion.Conditions conditionsFromJson( JsonObject jsonObject, - LootContextPredicate extended, + Extended extended, AdvancementEntityPredicateDeserializer advancementEntityPredicateDeserializer ) { - LootContextPredicate extended2 = EntityPredicate.contextPredicateFromJson(jsonObject, "rascal", advancementEntityPredicateDeserializer); + Extended extended2 = Extended.getInJson(jsonObject, "rascal", advancementEntityPredicateDeserializer); return new CompleteHideAndSeekGameCriterion.Conditions(extended, extended2); } @@ -43,19 +43,19 @@ public void trigger(ServerPlayerEntity player, RascalEntity entity) { public static class Conditions extends AbstractCriterionConditions { - private final LootContextPredicate entity; + private final Extended entity; - public Conditions(LootContextPredicate player, LootContextPredicate entity) { + public Conditions(Extended player, Extended entity) { super(CompleteHideAndSeekGameCriterion.ID, player); this.entity = entity; } public static CompleteHideAndSeekGameCriterion.Conditions any() { - return new CompleteHideAndSeekGameCriterion.Conditions(LootContextPredicate.EMPTY, LootContextPredicate.EMPTY); + return new CompleteHideAndSeekGameCriterion.Conditions(Extended.EMPTY, Extended.EMPTY); } public static CompleteHideAndSeekGameCriterion.Conditions create(EntityPredicate entity) { - return new CompleteHideAndSeekGameCriterion.Conditions(LootContextPredicate.EMPTY, EntityPredicate.asLootContextPredicate(entity)); + return new CompleteHideAndSeekGameCriterion.Conditions(Extended.EMPTY, Extended.ofLegacy(entity)); } public boolean matches(LootContext entityContext) { diff --git a/common/src/main/java/com/faboslav/friendsandfoes/client/render/entity/model/CopperGolemEntityModel.java b/common/src/main/java/com/faboslav/friendsandfoes/client/render/entity/model/CopperGolemEntityModel.java index ba876258b..342ac4a55 100644 --- a/common/src/main/java/com/faboslav/friendsandfoes/client/render/entity/model/CopperGolemEntityModel.java +++ b/common/src/main/java/com/faboslav/friendsandfoes/client/render/entity/model/CopperGolemEntityModel.java @@ -132,7 +132,7 @@ public void setAngles( float rodPivotY = defaultRodPivotY + AnimationMath.absSin(animationProgress, 1.0F, 0.25F); this.animateModelPartYPositionBasedOnProgress(copperGolem, this.rod, rodPivotY, AnimationMath.absSin(animationProgress)); } else { - this.animateModelPartYPositionBasedOnTicks(copperGolem, this.rod, defaultRodPivotY, 10); + animateModelPartYPositionBasedOnTicks(copperGolem, this.rod, defaultRodPivotY, 10); } } diff --git a/common/src/main/java/com/faboslav/friendsandfoes/client/render/entity/model/GlareEntityModel.java b/common/src/main/java/com/faboslav/friendsandfoes/client/render/entity/model/GlareEntityModel.java index 32d551e8a..bfc0e38d8 100644 --- a/common/src/main/java/com/faboslav/friendsandfoes/client/render/entity/model/GlareEntityModel.java +++ b/common/src/main/java/com/faboslav/friendsandfoes/client/render/entity/model/GlareEntityModel.java @@ -138,14 +138,14 @@ private void animateHead( ModelPartAnimator.setYRotation(this.root, AnimationMath.sin(animationProgress, 0.05F)); } else { float targetPivotY = glare.isSitting() ? 3.0F:0.0F; - this.animateModelPartYPositionBasedOnTicks(glare, this.root, targetPivotY, 10); + animateModelPartYPositionBasedOnTicks(glare, this.root, targetPivotY, 10); } } private void animateEyes(T glare) { Vec2f targetEyesPositionOffset = glare.getTargetEyesPositionOffset(); - this.animateModelPartPositionBasedOnTicks( + animateModelPartPositionBasedOnTicks( glare, this.eyes, this.eyes.pivotX + targetEyesPositionOffset.x, diff --git a/common/src/main/java/com/faboslav/friendsandfoes/client/render/entity/model/MaulerEntityModel.java b/common/src/main/java/com/faboslav/friendsandfoes/client/render/entity/model/MaulerEntityModel.java index c8f46abeb..3c94a2fe2 100644 --- a/common/src/main/java/com/faboslav/friendsandfoes/client/render/entity/model/MaulerEntityModel.java +++ b/common/src/main/java/com/faboslav/friendsandfoes/client/render/entity/model/MaulerEntityModel.java @@ -113,11 +113,11 @@ public void setAngles( ) { float targetX = AnimationMath.toRadians(5) + AnimationMath.toRadians(-65) * AnimationMath.absSin(animationProgress, 1.0F, 0.35F); float delta = AnimationMath.absSin(animationProgress); - this.animateModelPartXRotationBasedOnProgress(mauler, this.upperJaw, targetX, delta); - this.animateModelPartXRotationBasedOnTicks(mauler, this.lowerJaw, AnimationMath.toRadians(-5), 10); + animateModelPartXRotationBasedOnProgress(mauler, this.upperJaw, targetX, delta); + animateModelPartXRotationBasedOnTicks(mauler, this.lowerJaw, AnimationMath.toRadians(-5), 10); } else { - this.animateModelPartXRotationBasedOnTicks(mauler, this.upperJaw, 0.0F, 10); - this.animateModelPartXRotationBasedOnTicks(mauler, this.lowerJaw, 0.0F, 10); + animateModelPartXRotationBasedOnTicks(mauler, this.upperJaw, 0.0F, 10); + animateModelPartXRotationBasedOnTicks(mauler, this.lowerJaw, 0.0F, 10); } } } \ No newline at end of file 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 dd2ba6434..43d2f8ad3 100644 --- a/common/src/main/java/com/faboslav/friendsandfoes/entity/GlareEntity.java +++ b/common/src/main/java/com/faboslav/friendsandfoes/entity/GlareEntity.java @@ -273,7 +273,7 @@ private void updateTargetEyesPositionOffset() { } this.setTargetEyesPositionOffset( - -0.5F + this.getRandom().nextFloat() * (0.5F - -0.5F), + -0.5F + this.getRandom().nextFloat(), -0.4F + this.getRandom().nextFloat() * (0.4F - -0.4F) ); } diff --git a/common/src/main/java/com/faboslav/friendsandfoes/entity/RascalEntity.java b/common/src/main/java/com/faboslav/friendsandfoes/entity/RascalEntity.java index ea30f1382..ff0924f03 100644 --- a/common/src/main/java/com/faboslav/friendsandfoes/entity/RascalEntity.java +++ b/common/src/main/java/com/faboslav/friendsandfoes/entity/RascalEntity.java @@ -29,9 +29,9 @@ import net.minecraft.nbt.NbtCompound; import net.minecraft.particle.ParticleEffect; import net.minecraft.particle.ParticleTypes; -import net.minecraft.registry.tag.StructureTags; import net.minecraft.server.world.ServerWorld; import net.minecraft.sound.SoundEvent; +import net.minecraft.tag.StructureTags; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Box; import net.minecraft.util.math.random.Random; @@ -100,9 +100,7 @@ public static boolean canSpawn( return false; } - if (blockPos.getY() < 63 && serverWorldAccess.isSkyVisible(blockPos) == false) { - return true; - } + return blockPos.getY() < 63 && serverWorldAccess.isSkyVisible(blockPos) == false; } return false; @@ -373,7 +371,7 @@ protected void playStepSound( ) { if ( this.isHidden() - || state.isLiquid() + || state.getMaterial().isLiquid() ) { return; } @@ -382,7 +380,7 @@ protected void playStepSound( } public boolean isHidden() { - return this.getBrain().getOptionalRegisteredMemory(MemoryModuleType.AVOID_TARGET).orElse(null) instanceof PlayerEntity; + return this.getBrain().getOptionalMemory(MemoryModuleType.AVOID_TARGET).orElse(null) instanceof PlayerEntity; } public int getCaughtCount() { 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 9b810cb71..b62a1f2fb 100644 --- a/common/src/main/java/com/faboslav/friendsandfoes/entity/TuffGolemEntity.java +++ b/common/src/main/java/com/faboslav/friendsandfoes/entity/TuffGolemEntity.java @@ -28,11 +28,11 @@ import net.minecraft.nbt.NbtCompound; import net.minecraft.particle.ParticleEffect; import net.minecraft.particle.ParticleTypes; -import net.minecraft.registry.tag.BlockTags; import net.minecraft.server.world.ServerWorld; import net.minecraft.sound.BlockSoundGroup; import net.minecraft.sound.SoundEvent; import net.minecraft.sound.SoundEvents; +import net.minecraft.tag.BlockTags; import net.minecraft.util.ActionResult; import net.minecraft.util.DyeColor; import net.minecraft.util.Hand; @@ -292,7 +292,7 @@ protected void playStepSound( ) { if ( this.isInSleepingPose() - || state.isLiquid() + || state.getMaterial().isLiquid() ) { return; } @@ -707,7 +707,7 @@ public boolean damage( if ( attacker == null || attacker instanceof LightningEntity - || source == this.getDamageSources().sweetBerryBush() + || source == DamageSource.SWEET_BERRY_BUSH ) { return false; } diff --git a/common/src/main/java/com/faboslav/friendsandfoes/entity/ai/brain/RascalBrain.java b/common/src/main/java/com/faboslav/friendsandfoes/entity/ai/brain/RascalBrain.java index 03ca550ab..a4cf2ed32 100644 --- a/common/src/main/java/com/faboslav/friendsandfoes/entity/ai/brain/RascalBrain.java +++ b/common/src/main/java/com/faboslav/friendsandfoes/entity/ai/brain/RascalBrain.java @@ -65,7 +65,7 @@ private static void addIdleActivities(Brain brain) { brain.setTaskList( Activity.IDLE, ImmutableList.of( - Pair.of(0, RascalFindInteractionTargetTask.create(6)), + Pair.of(0, new RascalFindInteractionTargetTask(6)), Pair.of(0, makeRandomWanderTask()) ) ); @@ -88,7 +88,7 @@ private static void addAvoidActivities(Brain brain) { Activity.AVOID, 10, ImmutableList.of( - GoToRememberedPositionTask.createEntityBased(MemoryModuleType.AVOID_TARGET, 1.0F, 32, true) + GoToRememberedPositionTask.toEntity(MemoryModuleType.AVOID_TARGET, 1.0F, 32, true) ), MemoryModuleType.AVOID_TARGET ); @@ -107,7 +107,7 @@ public static void updateActivities(RascalEntity rascal) { private static RandomTask makeRandomWanderTask() { return new RandomTask( ImmutableList.of( - Pair.of(StrollTask.create(0.6F), 2), + Pair.of(new StrollTask(0.6F), 2), Pair.of(new WaitTask(30, 60), 1) ) ); @@ -119,7 +119,7 @@ public static void setNodCooldown(RascalEntity rascal) { } public static boolean shouldRunAway(RascalEntity rascal) { - return rascal.getBrain().getOptionalRegisteredMemory(FriendsAndFoesMemoryModuleTypes.RASCAL_NOD_COOLDOWN.get()).isPresent(); + return rascal.getBrain().getOptionalMemory(FriendsAndFoesMemoryModuleTypes.RASCAL_NOD_COOLDOWN.get()).isPresent(); } public static void onCooldown(RascalEntity rascal) { @@ -131,7 +131,7 @@ public static void onCooldown(RascalEntity rascal) { return; } - LivingEntity nearestTarget = rascal.getBrain().getOptionalRegisteredMemory(MemoryModuleType.INTERACTION_TARGET).orElse(null); + LivingEntity nearestTarget = rascal.getBrain().getOptionalMemory(MemoryModuleType.INTERACTION_TARGET).orElse(null); if (nearestTarget == null) { return; diff --git a/common/src/main/java/com/faboslav/friendsandfoes/entity/ai/brain/task/rascal/RascalFindInteractionTargetTask.java b/common/src/main/java/com/faboslav/friendsandfoes/entity/ai/brain/task/rascal/RascalFindInteractionTargetTask.java index 76d5c06d4..23db0beff 100644 --- a/common/src/main/java/com/faboslav/friendsandfoes/entity/ai/brain/task/rascal/RascalFindInteractionTargetTask.java +++ b/common/src/main/java/com/faboslav/friendsandfoes/entity/ai/brain/task/rascal/RascalFindInteractionTargetTask.java @@ -1,34 +1,62 @@ package com.faboslav.friendsandfoes.entity.ai.brain.task.rascal; +import com.google.common.collect.ImmutableMap; +import net.minecraft.entity.EntityType; import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.ai.brain.EntityLookTarget; -import net.minecraft.entity.ai.brain.MemoryModuleType; +import net.minecraft.entity.ai.brain.*; import net.minecraft.entity.ai.brain.task.Task; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.server.world.ServerWorld; -import java.util.Optional; +import java.util.function.Predicate; -public final class RascalFindInteractionTargetTask +public class RascalFindInteractionTargetTask extends Task { - public static Task create(int maxDistance) { - int squaredMaxDistance = maxDistance * maxDistance; - return TaskTriggerer.task((context) -> { - return context.group(context.queryMemoryOptional(MemoryModuleType.LOOK_TARGET), context.queryMemoryAbsent(MemoryModuleType.INTERACTION_TARGET), context.queryMemoryValue(MemoryModuleType.VISIBLE_MOBS)).apply(context, (lookTarget, interactionTarget, visibleMobs) -> { - return (world, entity, time) -> { - Optional optional = context.getValue(visibleMobs).findFirst((target) -> { - return target.squaredDistanceTo(entity) <= (double) squaredMaxDistance && target instanceof PlayerEntity && !target.isSpectator() && !((PlayerEntity) target).isCreative(); - }); - - if (optional.isEmpty()) { - return false; - } else { - LivingEntity livingEntity = optional.get(); - interactionTarget.remember(livingEntity); - lookTarget.remember(new EntityLookTarget(livingEntity, true)); - return true; - } - }; + private final int maxSquaredDistance; + private final Predicate predicate; + private final Predicate shouldRunPredicate; + + public RascalFindInteractionTargetTask( + int maxDistance, + Predicate shouldRunPredicate, + Predicate predicate + ) { + super(ImmutableMap.of(MemoryModuleType.LOOK_TARGET, MemoryModuleState.REGISTERED, MemoryModuleType.INTERACTION_TARGET, MemoryModuleState.VALUE_ABSENT, MemoryModuleType.VISIBLE_MOBS, MemoryModuleState.VALUE_PRESENT)); + this.maxSquaredDistance = maxDistance * maxDistance; + this.predicate = predicate; + this.shouldRunPredicate = shouldRunPredicate; + } + + public RascalFindInteractionTargetTask(int maxDistance) { + this(maxDistance, (livingEntity) -> { + return true; + }, (livingEntity) -> { + return true; + }); + } + + public boolean shouldRun(ServerWorld world, LivingEntity entity) { + return this.shouldRunPredicate.test(entity) && this.getVisibleMobs(entity).anyMatch(this::test); + } + + public void run(ServerWorld world, LivingEntity entity, long time) { + super.run(world, entity, time); + Brain brain = entity.getBrain(); + brain.getOptionalMemory(MemoryModuleType.VISIBLE_MOBS).flatMap((livingTargetCache) -> { + return livingTargetCache.findFirst((target) -> { + return target.squaredDistanceTo(entity) <= (double) this.maxSquaredDistance && target instanceof PlayerEntity && !target.isSpectator() && !((PlayerEntity) target).isCreative(); }); + }).ifPresent((target) -> { + brain.remember(MemoryModuleType.INTERACTION_TARGET, target); + brain.remember(MemoryModuleType.LOOK_TARGET, new EntityLookTarget(target, true)); }); } -} \ No newline at end of file + + private boolean test(LivingEntity entity) { + return EntityType.PLAYER.equals(entity.getType()) && this.predicate.test(entity); + } + + private LivingTargetCache getVisibleMobs(LivingEntity entity) { + return entity.getBrain().getOptionalMemory(MemoryModuleType.VISIBLE_MOBS).get(); + } +} diff --git a/common/src/main/java/com/faboslav/friendsandfoes/entity/ai/brain/task/rascal/RascalWaitForPlayerTask.java b/common/src/main/java/com/faboslav/friendsandfoes/entity/ai/brain/task/rascal/RascalWaitForPlayerTask.java index 86117edcc..1107da336 100644 --- a/common/src/main/java/com/faboslav/friendsandfoes/entity/ai/brain/task/rascal/RascalWaitForPlayerTask.java +++ b/common/src/main/java/com/faboslav/friendsandfoes/entity/ai/brain/task/rascal/RascalWaitForPlayerTask.java @@ -13,7 +13,7 @@ import net.minecraft.entity.ai.brain.MemoryModuleState; import net.minecraft.entity.ai.brain.MemoryModuleType; import net.minecraft.entity.ai.brain.task.LookTargetUtil; -import net.minecraft.entity.ai.brain.task.MultiTickTask; +import net.minecraft.entity.ai.brain.task.Task; import net.minecraft.entity.effect.StatusEffectInstance; import net.minecraft.entity.effect.StatusEffects; import net.minecraft.entity.player.PlayerEntity; @@ -21,18 +21,18 @@ import net.minecraft.item.Items; import net.minecraft.loot.LootManager; import net.minecraft.loot.LootTable; -import net.minecraft.loot.context.LootContextParameterSet; +import net.minecraft.loot.context.LootContext; import net.minecraft.loot.context.LootContextParameters; import net.minecraft.loot.context.LootContextTypes; -import net.minecraft.registry.tag.StructureTags; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.world.ServerWorld; +import net.minecraft.tag.StructureTags; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3d; import net.minecraft.world.gen.StructureAccessor; -public final class RascalWaitForPlayerTask extends MultiTickTask +public final class RascalWaitForPlayerTask extends Task { private final static int NOD_DURATION = 90; public final static float NOD_RANGE = 4F; @@ -54,10 +54,10 @@ protected boolean shouldRun(ServerWorld world, RascalEntity rascal) { return false; } - LivingEntity nearestTarget = rascal.getBrain().getOptionalRegisteredMemory(MemoryModuleType.NEAREST_VISIBLE_TARGETABLE_PLAYER).orElse(null); + LivingEntity nearestTarget = rascal.getBrain().getOptionalMemory(MemoryModuleType.NEAREST_VISIBLE_TARGETABLE_PLAYER).orElse(null); if (nearestTarget == null) { - nearestTarget = rascal.getBrain().getOptionalRegisteredMemory(MemoryModuleType.INTERACTION_TARGET).orElse(null); + nearestTarget = rascal.getBrain().getOptionalMemory(MemoryModuleType.INTERACTION_TARGET).orElse(null); } if ( @@ -124,12 +124,12 @@ protected void keepRunning(ServerWorld world, RascalEntity rascal, long time) { LootManager lootManager = world.getServer().getLootManager(); if (lootManager != null) { - LootTable rascalGoodItemsLootTable = lootManager.getLootTable( + LootTable rascalGoodItemsLootTable = lootManager.getTable( FriendsAndFoes.makeID("rewards/rascal_good_reward") ); - LootContextParameterSet lootContextParameterSet = new LootContextParameterSet.Builder(world) - .add(LootContextParameters.ORIGIN, targetPos) - .add(LootContextParameters.THIS_ENTITY, this.nearestTarget) + LootContext lootContextParameterSet = new LootContext.Builder(world) + .parameter(LootContextParameters.ORIGIN, targetPos) + .parameter(LootContextParameters.THIS_ENTITY, this.nearestTarget) .build(LootContextTypes.GIFT); ObjectArrayList rascalGoodRewards = rascalGoodItemsLootTable.generateLoot(lootContextParameterSet); 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 466ac0cea..e5a5c2043 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 @@ -47,7 +47,7 @@ protected boolean shouldRun(ServerWorld world, WildfireEntity wildfire) { || ((PlayerEntity) attackTarget).isCreative() ) ) - || wildfire.getSummonedBlazesCount() == wildfire.MAXIMUM_SUMMONED_BLAZES_COUNT + || wildfire.getSummonedBlazesCount() == WildfireEntity.MAXIMUM_SUMMONED_BLAZES_COUNT ) { WildfireBrain.setSummonBlazeCooldown(wildfire); return false; diff --git a/common/src/main/java/com/faboslav/friendsandfoes/init/FriendsAndFoesItems.java b/common/src/main/java/com/faboslav/friendsandfoes/init/FriendsAndFoesItems.java index 14f3e60fb..44151872d 100644 --- a/common/src/main/java/com/faboslav/friendsandfoes/init/FriendsAndFoesItems.java +++ b/common/src/main/java/com/faboslav/friendsandfoes/init/FriendsAndFoesItems.java @@ -59,7 +59,7 @@ public final class FriendsAndFoesItems ILLUSIONER_SPAWN_EGG = RegistryHelper.registerItem("illusioner_spawn_egg", () -> new SpawnEggItem(EntityType.ILLUSIONER, 0x603E5C, 0x888E8E, new Item.Settings().maxCount(64).group(ItemGroup.MISC))); MAULER_SPAWN_EGG = RegistryHelper.registerItem("mauler_spawn_egg", () -> new SpawnEggItem(FriendsAndFoesEntityTypes.MAULER.get(), 0x534F25, 0x817B39, new Item.Settings().maxCount(64).group(ItemGroup.MISC))); MOOBLOOM_SPAWN_EGG = RegistryHelper.registerItem("moobloom_spawn_egg", () -> new SpawnEggItem(FriendsAndFoesEntityTypes.MOOBLOOM.get(), 0xF7EDC1, 0xFACA00, new Item.Settings().maxCount(64).group(ItemGroup.MISC))); - RASCAL_SPAWN_EGG = RegistryHelper.registerSpawnEggItem("rascal_spawn_egg", FriendsAndFoesEntityTypes.RASCAL, 0x05736A, 0x8A521C, new Item.Settings().maxCount(64)); + RASCAL_SPAWN_EGG = RegistryHelper.registerItem("rascal_spawn_egg", () -> new SpawnEggItem(FriendsAndFoesEntityTypes.RASCAL.get(), 0x05736A, 0x8A521C, new Item.Settings().maxCount(64).group(ItemGroup.MISC))); TUFF_GOLEM_SPAWN_EGG = RegistryHelper.registerItem("tuff_golem_spawn_egg", () -> new SpawnEggItem(FriendsAndFoesEntityTypes.TUFF_GOLEM.get(), 0xA0A297, 0x5D5D52, new Item.Settings().maxCount(64).group(ItemGroup.MISC))); WILDFIRE_SPAWN_EGG = RegistryHelper.registerItem("wildfire_spawn_egg", () -> new SpawnEggItem(FriendsAndFoesEntityTypes.WILDFIRE.get(), 0x6C3100, 0xFFD528, new Item.Settings().maxCount(64).group(ItemGroup.MISC))); BUTTERCUP = RegistryHelper.registerItem("buttercup", () -> new BlockItem(FriendsAndFoesBlocks.BUTTERCUP.get(), new Item.Settings().group(ItemGroup.DECORATIONS).maxCount(64))); diff --git a/common/src/main/resources/assets/friendsandfoes/sounds/entity/rascal/ambient1.ogg b/common/src/main/resources/assets/friendsandfoes/sounds/entity/rascal/ambient1.ogg new file mode 100644 index 000000000..ad2fe22d4 Binary files /dev/null and b/common/src/main/resources/assets/friendsandfoes/sounds/entity/rascal/ambient1.ogg differ diff --git a/common/src/main/resources/assets/friendsandfoes/sounds/entity/rascal/ambient2.ogg b/common/src/main/resources/assets/friendsandfoes/sounds/entity/rascal/ambient2.ogg new file mode 100644 index 000000000..c04118c54 Binary files /dev/null and b/common/src/main/resources/assets/friendsandfoes/sounds/entity/rascal/ambient2.ogg differ diff --git a/common/src/main/resources/assets/friendsandfoes/sounds/entity/rascal/ambient3.ogg b/common/src/main/resources/assets/friendsandfoes/sounds/entity/rascal/ambient3.ogg new file mode 100644 index 000000000..588afc3ee Binary files /dev/null and b/common/src/main/resources/assets/friendsandfoes/sounds/entity/rascal/ambient3.ogg differ diff --git a/common/src/main/resources/assets/friendsandfoes/sounds/entity/rascal/ambient4.ogg b/common/src/main/resources/assets/friendsandfoes/sounds/entity/rascal/ambient4.ogg new file mode 100644 index 000000000..16d62e4eb Binary files /dev/null and b/common/src/main/resources/assets/friendsandfoes/sounds/entity/rascal/ambient4.ogg differ diff --git a/common/src/main/resources/assets/friendsandfoes/sounds/entity/rascal/ambient5.ogg b/common/src/main/resources/assets/friendsandfoes/sounds/entity/rascal/ambient5.ogg new file mode 100644 index 000000000..e7be41501 Binary files /dev/null and b/common/src/main/resources/assets/friendsandfoes/sounds/entity/rascal/ambient5.ogg differ diff --git a/common/src/main/resources/assets/friendsandfoes/sounds/entity/rascal/disappear1.ogg b/common/src/main/resources/assets/friendsandfoes/sounds/entity/rascal/disappear1.ogg new file mode 100644 index 000000000..23d592857 Binary files /dev/null and b/common/src/main/resources/assets/friendsandfoes/sounds/entity/rascal/disappear1.ogg differ diff --git a/common/src/main/resources/assets/friendsandfoes/sounds/entity/rascal/disappear2.ogg b/common/src/main/resources/assets/friendsandfoes/sounds/entity/rascal/disappear2.ogg new file mode 100644 index 000000000..0491d29a8 Binary files /dev/null and b/common/src/main/resources/assets/friendsandfoes/sounds/entity/rascal/disappear2.ogg differ diff --git a/common/src/main/resources/assets/friendsandfoes/sounds/entity/rascal/hurt1.ogg b/common/src/main/resources/assets/friendsandfoes/sounds/entity/rascal/hurt1.ogg new file mode 100644 index 000000000..968ee55b9 Binary files /dev/null and b/common/src/main/resources/assets/friendsandfoes/sounds/entity/rascal/hurt1.ogg differ diff --git a/common/src/main/resources/assets/friendsandfoes/sounds/entity/rascal/hurt2.ogg b/common/src/main/resources/assets/friendsandfoes/sounds/entity/rascal/hurt2.ogg new file mode 100644 index 000000000..b9fe5b44b Binary files /dev/null and b/common/src/main/resources/assets/friendsandfoes/sounds/entity/rascal/hurt2.ogg differ diff --git a/common/src/main/resources/assets/friendsandfoes/sounds/entity/rascal/hurt3.ogg b/common/src/main/resources/assets/friendsandfoes/sounds/entity/rascal/hurt3.ogg new file mode 100644 index 000000000..92d022806 Binary files /dev/null and b/common/src/main/resources/assets/friendsandfoes/sounds/entity/rascal/hurt3.ogg differ diff --git a/common/src/main/resources/assets/friendsandfoes/sounds/entity/rascal/hurt4.ogg b/common/src/main/resources/assets/friendsandfoes/sounds/entity/rascal/hurt4.ogg new file mode 100644 index 000000000..37354c77e Binary files /dev/null and b/common/src/main/resources/assets/friendsandfoes/sounds/entity/rascal/hurt4.ogg differ diff --git a/common/src/main/resources/assets/friendsandfoes/sounds/entity/rascal/hurt5.ogg b/common/src/main/resources/assets/friendsandfoes/sounds/entity/rascal/hurt5.ogg new file mode 100644 index 000000000..72b2c8f98 Binary files /dev/null and b/common/src/main/resources/assets/friendsandfoes/sounds/entity/rascal/hurt5.ogg differ diff --git a/common/src/main/resources/assets/friendsandfoes/sounds/entity/rascal/nod1.ogg b/common/src/main/resources/assets/friendsandfoes/sounds/entity/rascal/nod1.ogg new file mode 100644 index 000000000..9595f8c6c Binary files /dev/null and b/common/src/main/resources/assets/friendsandfoes/sounds/entity/rascal/nod1.ogg differ diff --git a/common/src/main/resources/assets/friendsandfoes/sounds/entity/rascal/nod2.ogg b/common/src/main/resources/assets/friendsandfoes/sounds/entity/rascal/nod2.ogg new file mode 100644 index 000000000..2da81f102 Binary files /dev/null and b/common/src/main/resources/assets/friendsandfoes/sounds/entity/rascal/nod2.ogg differ diff --git a/common/src/main/resources/assets/friendsandfoes/sounds/entity/rascal/nod3.ogg b/common/src/main/resources/assets/friendsandfoes/sounds/entity/rascal/nod3.ogg new file mode 100644 index 000000000..6c0812f3f Binary files /dev/null and b/common/src/main/resources/assets/friendsandfoes/sounds/entity/rascal/nod3.ogg differ diff --git a/common/src/main/resources/assets/friendsandfoes/sounds/entity/rascal/nod4.ogg b/common/src/main/resources/assets/friendsandfoes/sounds/entity/rascal/nod4.ogg new file mode 100644 index 000000000..2f8e4696c Binary files /dev/null and b/common/src/main/resources/assets/friendsandfoes/sounds/entity/rascal/nod4.ogg differ diff --git a/common/src/main/resources/assets/friendsandfoes/sounds/entity/rascal/reappear1.ogg b/common/src/main/resources/assets/friendsandfoes/sounds/entity/rascal/reappear1.ogg new file mode 100644 index 000000000..4824defb8 Binary files /dev/null and b/common/src/main/resources/assets/friendsandfoes/sounds/entity/rascal/reappear1.ogg differ diff --git a/common/src/main/resources/assets/friendsandfoes/sounds/entity/rascal/reappear2.ogg b/common/src/main/resources/assets/friendsandfoes/sounds/entity/rascal/reappear2.ogg new file mode 100644 index 000000000..a3a55e835 Binary files /dev/null and b/common/src/main/resources/assets/friendsandfoes/sounds/entity/rascal/reappear2.ogg differ diff --git a/common/src/main/resources/assets/friendsandfoes/sounds/entity/rascal/reward1.ogg b/common/src/main/resources/assets/friendsandfoes/sounds/entity/rascal/reward1.ogg new file mode 100644 index 000000000..d269a3600 Binary files /dev/null and b/common/src/main/resources/assets/friendsandfoes/sounds/entity/rascal/reward1.ogg differ diff --git a/common/src/main/resources/assets/friendsandfoes/sounds/entity/rascal/reward2.ogg b/common/src/main/resources/assets/friendsandfoes/sounds/entity/rascal/reward2.ogg new file mode 100644 index 000000000..e63178752 Binary files /dev/null and b/common/src/main/resources/assets/friendsandfoes/sounds/entity/rascal/reward2.ogg differ diff --git a/common/src/main/resources/assets/friendsandfoes/sounds/entity/rascal/reward_bad1.ogg b/common/src/main/resources/assets/friendsandfoes/sounds/entity/rascal/reward_bad1.ogg new file mode 100644 index 000000000..06c723c66 Binary files /dev/null and b/common/src/main/resources/assets/friendsandfoes/sounds/entity/rascal/reward_bad1.ogg differ diff --git a/common/src/main/resources/assets/friendsandfoes/sounds/entity/rascal/reward_bad2.ogg b/common/src/main/resources/assets/friendsandfoes/sounds/entity/rascal/reward_bad2.ogg new file mode 100644 index 000000000..4aae2bb2d Binary files /dev/null and b/common/src/main/resources/assets/friendsandfoes/sounds/entity/rascal/reward_bad2.ogg differ diff --git a/common/src/main/resources/assets/friendsandfoes/sounds/entity/rascal/reward_bad3.ogg b/common/src/main/resources/assets/friendsandfoes/sounds/entity/rascal/reward_bad3.ogg new file mode 100644 index 000000000..8a5f68d0d Binary files /dev/null and b/common/src/main/resources/assets/friendsandfoes/sounds/entity/rascal/reward_bad3.ogg differ diff --git a/common/src/main/resources/assets/friendsandfoes/textures/entity/rascal/rascal.png b/common/src/main/resources/assets/friendsandfoes/textures/entity/rascal/rascal.png new file mode 100644 index 000000000..b01701881 Binary files /dev/null and b/common/src/main/resources/assets/friendsandfoes/textures/entity/rascal/rascal.png differ diff --git a/common/src/main/resources/data/friendsandfoes/advancements/adventure/complete_hide_and_seek_game.json b/common/src/main/resources/data/friendsandfoes/advancements/adventure/complete_hide_and_seek_game.json new file mode 100644 index 000000000..4e18353e9 --- /dev/null +++ b/common/src/main/resources/data/friendsandfoes/advancements/adventure/complete_hide_and_seek_game.json @@ -0,0 +1,33 @@ +{ + "parent": "minecraft:adventure/root", + "display": { + "icon": { + "item": "minecraft:bundle" + }, + "title": { + "translate": "advancements.adventure.complete_hide_and_seek_game.title" + }, + "description": { + "translate": "advancements.adventure.complete_hide_and_seek_game.description" + }, + "frame": "task", + "show_toast": true, + "announce_to_chat": true, + "hidden": false + }, + "criteria": { + "friendsandfoes:complete_hide_and_seek_game": { + "trigger": "friendsandfoes:complete_hide_and_seek_game", + "conditions": { + "entity": { + "type": "friendsandfoes:rascal" + } + } + } + }, + "requirements": [ + [ + "friendsandfoes:complete_hide_and_seek_game" + ] + ] +} diff --git a/common/src/main/resources/data/friendsandfoes/loot_tables/entities/rascal.json b/common/src/main/resources/data/friendsandfoes/loot_tables/entities/rascal.json new file mode 100644 index 000000000..5e4d1859d --- /dev/null +++ b/common/src/main/resources/data/friendsandfoes/loot_tables/entities/rascal.json @@ -0,0 +1,4 @@ +{ + "type": "minecraft:entity", + "pools": [] +} diff --git a/common/src/main/resources/data/friendsandfoes/loot_tables/rewards/rascal_good_reward.json b/common/src/main/resources/data/friendsandfoes/loot_tables/rewards/rascal_good_reward.json new file mode 100644 index 000000000..d100c2d4d --- /dev/null +++ b/common/src/main/resources/data/friendsandfoes/loot_tables/rewards/rascal_good_reward.json @@ -0,0 +1,55 @@ +{ + "type": "minecraft:empty", + "pools": [ + { + "rolls": 1, + "entries": [ + { + "weight": 4, + "type": "minecraft:item", + "name": "minecraft:iron_pickaxe", + "functions": [ + { + "function": "minecraft:enchant_with_levels", + "levels": { + "min": 18.0, + "max": 22.0, + "type": "minecraft:uniform" + } + } + ] + }, + { + "weight": 2, + "type": "minecraft:item", + "name": "minecraft:iron_ore", + "functions": [ + { + "function": "minecraft:set_count", + "count": { + "type": "minecraft:uniform", + "min": 5.0, + "max": 7.0 + } + } + ] + }, + { + "weight": 1, + "type": "minecraft:item", + "name": "minecraft:gold_ore", + "functions": [ + { + "function": "minecraft:set_count", + "count": { + "type": "minecraft:uniform", + "min": 3.0, + "max": 5.0 + } + } + ] + } + ] + } + ] +} diff --git a/common/src/main/resources/data/friendsandfoes/tags/worldgen/biome/has_rascal.json b/common/src/main/resources/data/friendsandfoes/tags/worldgen/biome/has_rascal.json new file mode 100644 index 000000000..466bb9d2f --- /dev/null +++ b/common/src/main/resources/data/friendsandfoes/tags/worldgen/biome/has_rascal.json @@ -0,0 +1,6 @@ +{ + "values": [ + "#minecraft:has_structure/mineshaft", + "#minecraft:has_structure/mineshaft_mesa" + ] +} \ No newline at end of file diff --git a/fabric/src/main/java/com/faboslav/friendsandfoes/mixin/fabric/AddCustomSpawnGroupMixin.java b/fabric/src/main/java/com/faboslav/friendsandfoes/mixin/fabric/AddCustomSpawnGroupMixin.java index 282f4185d..a91182f95 100644 --- a/fabric/src/main/java/com/faboslav/friendsandfoes/mixin/fabric/AddCustomSpawnGroupMixin.java +++ b/fabric/src/main/java/com/faboslav/friendsandfoes/mixin/fabric/AddCustomSpawnGroupMixin.java @@ -54,15 +54,27 @@ private static void friendsandfoes_addCustomSpawnGroup(CallbackInfo ci) { var glaresSpawnGroup = newSpawnGroup( CustomSpawnGroup.GLARES_INTERNAL_NAME, lastSpawnGroup.ordinal() + 1, - CustomSpawnGroup.NAME, - CustomSpawnGroup.SPAWN_CAP, - CustomSpawnGroup.PEACEFUL, - CustomSpawnGroup.RARE, - CustomSpawnGroup.IMMEDIATE_DESPAWN_RANGE + CustomSpawnGroup.GLARES_NAME, + CustomSpawnGroup.GLARES_SPAWN_CAP, + CustomSpawnGroup.GLARES_PEACEFUL, + CustomSpawnGroup.GLARES_RARE, + CustomSpawnGroup.GLARES_IMMEDIATE_DESPAWN_RANGE ); CustomSpawnGroupImpl.GLARES = glaresSpawnGroup; spawnGroups.add(glaresSpawnGroup); + var rascalsSpawnGroup = newSpawnGroup( + CustomSpawnGroup.RASCALS_INTERNAL_NAME, + lastSpawnGroup.ordinal() + 2, + CustomSpawnGroup.RASCALS_NAME, + CustomSpawnGroup.RASCALS_SPAWN_CAP, + CustomSpawnGroup.RASCALS_PEACEFUL, + CustomSpawnGroup.RASCALS_RARE, + CustomSpawnGroup.RASCALS_IMMEDIATE_DESPAWN_RANGE + ); + CustomSpawnGroupImpl.RASCALS = rascalsSpawnGroup; + spawnGroups.add(rascalsSpawnGroup); + field_6301 = spawnGroups.toArray(new SpawnGroup[0]); } } \ No newline at end of file diff --git a/fabric/src/main/java/com/faboslav/friendsandfoes/platform/fabric/CustomSpawnGroupImpl.java b/fabric/src/main/java/com/faboslav/friendsandfoes/platform/fabric/CustomSpawnGroupImpl.java index d4c8f74f8..94865e03a 100644 --- a/fabric/src/main/java/com/faboslav/friendsandfoes/platform/fabric/CustomSpawnGroupImpl.java +++ b/fabric/src/main/java/com/faboslav/friendsandfoes/platform/fabric/CustomSpawnGroupImpl.java @@ -11,10 +11,19 @@ public final class CustomSpawnGroupImpl public static SpawnGroup GLARES; + public static SpawnGroup RASCALS; + /** * @see CustomSpawnGroup#getGlaresCategory() */ public static SpawnGroup getGlaresCategory() { return GLARES; } -} + + /** + * @see CustomSpawnGroup#getRascalsCategory() + */ + public static SpawnGroup getRascalsCategory() { + return RASCALS; + } +} \ No newline at end of file diff --git a/forge/src/main/java/com/faboslav/friendsandfoes/platform/forge/CustomSpawnGroupImpl.java b/forge/src/main/java/com/faboslav/friendsandfoes/platform/forge/CustomSpawnGroupImpl.java index 637dd83fa..3cd89aceb 100644 --- a/forge/src/main/java/com/faboslav/friendsandfoes/platform/forge/CustomSpawnGroupImpl.java +++ b/forge/src/main/java/com/faboslav/friendsandfoes/platform/forge/CustomSpawnGroupImpl.java @@ -7,23 +7,45 @@ public final class CustomSpawnGroupImpl { public static SpawnGroup GLARES; + public static SpawnGroup RASCALS; + /** * @see CustomSpawnGroup#getGlaresCategory() */ public static SpawnGroup getGlaresCategory() { - var spawnGroup = SpawnGroup.byName(CustomSpawnGroup.NAME); + var spawnGroup = SpawnGroup.byName(CustomSpawnGroup.GLARES_NAME); + + if (spawnGroup == null) { + spawnGroup = SpawnGroup.create( + CustomSpawnGroup.GLARES_NAME, + CustomSpawnGroup.GLARES_NAME, + CustomSpawnGroup.GLARES_SPAWN_CAP, + CustomSpawnGroup.GLARES_PEACEFUL, + CustomSpawnGroup.GLARES_RARE, + CustomSpawnGroup.GLARES_IMMEDIATE_DESPAWN_RANGE + ); + } + + return spawnGroup; + } + + /** + * @see CustomSpawnGroup#getRascalsCategory() + */ + public static SpawnGroup getRascalsCategory() { + var spawnGroup = SpawnGroup.byName(CustomSpawnGroup.RASCALS_NAME); if (spawnGroup == null) { spawnGroup = SpawnGroup.create( - CustomSpawnGroup.NAME, - CustomSpawnGroup.NAME, - CustomSpawnGroup.SPAWN_CAP, - CustomSpawnGroup.PEACEFUL, - CustomSpawnGroup.RARE, - CustomSpawnGroup.IMMEDIATE_DESPAWN_RANGE + CustomSpawnGroup.RASCALS_NAME, + CustomSpawnGroup.RASCALS_NAME, + CustomSpawnGroup.RASCALS_SPAWN_CAP, + CustomSpawnGroup.RASCALS_PEACEFUL, + CustomSpawnGroup.RASCALS_RARE, + CustomSpawnGroup.RASCALS_IMMEDIATE_DESPAWN_RANGE ); } return spawnGroup; } -} +} \ No newline at end of file diff --git a/forge/src/main/resources/data/friendsandfoes/forge/biome_modifier/rascal.json b/forge/src/main/resources/data/friendsandfoes/forge/biome_modifier/rascal.json new file mode 100644 index 000000000..09db614fa --- /dev/null +++ b/forge/src/main/resources/data/friendsandfoes/forge/biome_modifier/rascal.json @@ -0,0 +1,11 @@ +{ + "type": "forge:add_spawns", + "biomes": "#friendsandfoes:has_rascal", + "spawners": { + "type": "friendsandfoes:rascal", + "minCount": 1, + "maxCount": 1, + "weight": 4 + }, + "category": "rascals" +} \ No newline at end of file