diff --git a/build.gradle b/build.gradle index 3cb3c4f..35b1a14 100644 --- a/build.gradle +++ b/build.gradle @@ -3,7 +3,7 @@ plugins { id 'eclipse' id 'idea' id 'maven-publish' - id 'net.neoforged.gradle.userdev' version '7.0.105' + id 'net.neoforged.gradle.userdev' version '7.0.140' } version = mod_version diff --git a/changelog-1.20.5.txt b/changelog-1.20.5.txt index 8d1d214..f5c0a2e 100644 --- a/changelog-1.20.5.txt +++ b/changelog-1.20.5.txt @@ -1,9 +1 @@ -- Added Komodo Dragon (Alexs Mobs) to mob blacklist -- Added separate config option for mobs attacking guards -- Update to 1.20.5 -- Adjusted range of Crossbow guards firing arrows -- Made iron golems float and walk back to nearest land when in water -- Fixed guards not returning back to checkpoint -- Added advancement to recruiting a guard -- Made guards not attack zombified piglins -- Enabled illagers attacking animals during raids by default \ No newline at end of file +- Update to 1.20.6 \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 12e7e54..7a09d51 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,13 +9,13 @@ org.gradle.debug=false ## Environment Properties # You can find the latest versions here: https://projects.neoforged.net/neoforged/neoforge # The Minecraft version must agree with the Neo version to get a valid artifact -minecraft_version=1.20.5 +minecraft_version=1.21 # The Minecraft version range can use any release version of Minecraft as bounds. # Snapshots, pre-releases, and release candidates are not guaranteed to sort properly # as they do not follow standard versioning conventions. -minecraft_version_range=[1.20.5,1.21) +minecraft_version_range=[1.21, 1.22) # The Neo version must agree with the Minecraft version to get a valid artifact -neo_version=20.5.5-beta +neo_version=21.0.0-beta # The Neo version range can use any version of Neo as bounds neo_version_range=[20.4,) # The loader version range can only use the major version of FML as bounds @@ -32,7 +32,7 @@ mod_name=Guard Villagers # The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default. mod_license=MIT for code, assets are ARR # The mod version. See https://semver.org/ -mod_version=2.1.1-1.20.5 +mod_version=2.2.0 # The group ID for the mod. It is only important when publishing as an artifact to a Maven repository. # This should match the base package used for the mod sources. # See https://maven.apache.org/guides/mini/guide-naming-conventions.html diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 509c4a2..20db9ad 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/main/java/tallestegg/guardvillagers/GuardItems.java b/src/main/java/tallestegg/guardvillagers/GuardItems.java index 933ec15..f89e688 100644 --- a/src/main/java/tallestegg/guardvillagers/GuardItems.java +++ b/src/main/java/tallestegg/guardvillagers/GuardItems.java @@ -1,15 +1,12 @@ package tallestegg.guardvillagers; import com.google.common.base.Predicate; -import net.minecraft.core.Holder; -import net.minecraft.core.Registry; import net.minecraft.core.registries.Registries; import net.minecraft.world.InteractionHand; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.item.Item; import net.minecraft.world.item.SpawnEggItem; -import net.neoforged.fml.common.Mod; import net.neoforged.neoforge.common.DeferredSpawnEggItem; import net.neoforged.neoforge.registries.DeferredHolder; import net.neoforged.neoforge.registries.DeferredRegister; diff --git a/src/main/java/tallestegg/guardvillagers/GuardLootTables.java b/src/main/java/tallestegg/guardvillagers/GuardLootTables.java index 96b1dc9..b3be5ba 100644 --- a/src/main/java/tallestegg/guardvillagers/GuardLootTables.java +++ b/src/main/java/tallestegg/guardvillagers/GuardLootTables.java @@ -27,14 +27,14 @@ public class GuardLootTables { public static final ResourceKey GUARD_FEET = registerLootTable("entities/guard_feet"); public static ResourceKey registerLootTable(String id) { - return ResourceKey.create(Registries.LOOT_TABLE, new ResourceLocation(GuardVillagers.MODID, id)); + return ResourceKey.create(Registries.LOOT_TABLE, ResourceLocation.fromNamespaceAndPath(GuardVillagers.MODID, id)); } public static LootContextParamSet register(String p_81429_, Consumer p_81430_) { LootContextParamSet.Builder lootcontextparamset$builder = new LootContextParamSet.Builder(); p_81430_.accept(lootcontextparamset$builder); LootContextParamSet lootcontextparamset = lootcontextparamset$builder.build(); - ResourceLocation resourcelocation = new ResourceLocation(GuardVillagers.MODID + p_81429_); + ResourceLocation resourcelocation = ResourceLocation.parse(GuardVillagers.MODID + p_81429_); LootContextParamSet lootcontextparamset1 = REGISTRY.put(resourcelocation, lootcontextparamset); if (lootcontextparamset1 != null) { throw new IllegalStateException("Loot table parameter set " + resourcelocation + " is already registered"); diff --git a/src/main/java/tallestegg/guardvillagers/HandlerEvents.java b/src/main/java/tallestegg/guardvillagers/HandlerEvents.java index c34ca8d..e98e65b 100644 --- a/src/main/java/tallestegg/guardvillagers/HandlerEvents.java +++ b/src/main/java/tallestegg/guardvillagers/HandlerEvents.java @@ -37,6 +37,7 @@ import net.neoforged.neoforge.event.entity.living.LivingEvent; import net.neoforged.neoforge.event.entity.living.LivingHurtEvent; import net.neoforged.neoforge.event.entity.player.PlayerInteractEvent; +import net.neoforged.neoforge.event.tick.EntityTickEvent; import tallestegg.guardvillagers.common.entities.Guard; import tallestegg.guardvillagers.common.entities.ai.goals.AttackEntityDaytimeGoal; import tallestegg.guardvillagers.common.entities.ai.goals.GetOutOfWaterGoal; @@ -96,7 +97,7 @@ public static void onEntityHurt(LivingHurtEvent event) { } @SubscribeEvent - public static void onLivingTick(LivingEvent.LivingTickEvent event) { + public static void onLivingTick(EntityTickEvent.Pre event) { if (event.getEntity() instanceof AbstractHorse horse) { Vec3 vec3 = new Vec3(horse.xxa, horse.yya, horse.zza); if (horse.hasControllingPassenger() && horse.getControllingPassenger() instanceof Guard) { diff --git a/src/main/java/tallestegg/guardvillagers/client/GuardClientEvents.java b/src/main/java/tallestegg/guardvillagers/client/GuardClientEvents.java index 3984e85..48ec394 100644 --- a/src/main/java/tallestegg/guardvillagers/client/GuardClientEvents.java +++ b/src/main/java/tallestegg/guardvillagers/client/GuardClientEvents.java @@ -17,13 +17,13 @@ @EventBusSubscriber(value = Dist.CLIENT, bus = EventBusSubscriber.Bus.MOD) public class GuardClientEvents { public static ModelLayerLocation GUARD = new ModelLayerLocation( - new ResourceLocation(GuardVillagers.MODID + "guard"), "guard"); + ResourceLocation.parse(GuardVillagers.MODID + "guard"), "guard"); public static ModelLayerLocation GUARD_STEVE = new ModelLayerLocation( - new ResourceLocation(GuardVillagers.MODID + "guard_steve"), "guard_steve"); + ResourceLocation.parse(GuardVillagers.MODID + "guard_steve"), "guard_steve"); public static ModelLayerLocation GUARD_ARMOR_OUTER = new ModelLayerLocation( - new ResourceLocation(GuardVillagers.MODID + "guard_armor_outer"), "guard_armor_outer"); + ResourceLocation.parse(GuardVillagers.MODID + "guard_armor_outer"), "guard_armor_outer"); public static ModelLayerLocation GUARD_ARMOR_INNER = new ModelLayerLocation( - new ResourceLocation(GuardVillagers.MODID + "guard_armor_inner"), "guard_armor_inner"); + ResourceLocation.parse(GuardVillagers.MODID + "guard_armor_inner"), "guard_armor_inner"); @SubscribeEvent public static void layerDefinitions(EntityRenderersEvent.RegisterLayerDefinitions event) { diff --git a/src/main/java/tallestegg/guardvillagers/client/GuardSounds.java b/src/main/java/tallestegg/guardvillagers/client/GuardSounds.java index 4197366..5dc901b 100644 --- a/src/main/java/tallestegg/guardvillagers/client/GuardSounds.java +++ b/src/main/java/tallestegg/guardvillagers/client/GuardSounds.java @@ -14,7 +14,7 @@ //@Mod.EventBusSubscriber(modid = GuardVillagers.MODID, bus = Mod.EventBusSubscriber.Bus.MOD) public class GuardSounds { public static final DeferredRegister SOUNDS = DeferredRegister.create(Registries.SOUND_EVENT, GuardVillagers.MODID); - public static final Holder GUARD_AMBIENT = SOUNDS.register("entity.guard.ambient", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation(GuardVillagers.MODID, "entity.guard.ambient"))); - public static final Holder GUARD_DEATH = SOUNDS.register("entity.guard.death", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation(GuardVillagers.MODID, "entity.guard.death"))); - public static final Holder GUARD_HURT = SOUNDS.register("entity.guard.hurt", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation(GuardVillagers.MODID, "entity.guard.hurt"))); + public static final Holder GUARD_AMBIENT = SOUNDS.register("entity.guard.ambient", () -> SoundEvent.createVariableRangeEvent(ResourceLocation.fromNamespaceAndPath(GuardVillagers.MODID, "entity.guard.ambient"))); + public static final Holder GUARD_DEATH = SOUNDS.register("entity.guard.death", () -> SoundEvent.createVariableRangeEvent(ResourceLocation.fromNamespaceAndPath(GuardVillagers.MODID, "entity.guard.death"))); + public static final Holder GUARD_HURT = SOUNDS.register("entity.guard.hurt", () -> SoundEvent.createVariableRangeEvent(ResourceLocation.fromNamespaceAndPath(GuardVillagers.MODID, "entity.guard.hurt"))); } diff --git a/src/main/java/tallestegg/guardvillagers/client/gui/GuardInventoryScreen.java b/src/main/java/tallestegg/guardvillagers/client/gui/GuardInventoryScreen.java index 868ee06..cfc9144 100644 --- a/src/main/java/tallestegg/guardvillagers/client/gui/GuardInventoryScreen.java +++ b/src/main/java/tallestegg/guardvillagers/client/gui/GuardInventoryScreen.java @@ -22,11 +22,11 @@ import tallestegg.guardvillagers.networking.GuardSetPatrolPosPacket; public class GuardInventoryScreen extends AbstractContainerScreen { - private static final ResourceLocation GUARD_GUI_TEXTURES = new ResourceLocation(GuardVillagers.MODID, "textures/container/inventory.png"); - private static final WidgetSprites GUARD_FOLLOWING_ICONS = new WidgetSprites(new ResourceLocation(GuardVillagers.MODID, "following/following"), new ResourceLocation(GuardVillagers.MODID, "following/following_highlighted")); - private static final WidgetSprites GUARD_NOT_FOLLOWING_ICONS = new WidgetSprites(new ResourceLocation(GuardVillagers.MODID, "following/not_following"), new ResourceLocation(GuardVillagers.MODID, "following/not_following_highlighted")); - private static final WidgetSprites GUARD_PATROLLING_ICONS = new WidgetSprites(new ResourceLocation(GuardVillagers.MODID, "patrolling/patrolling1"), new ResourceLocation(GuardVillagers.MODID, "patrolling/patrolling2")); - private static final WidgetSprites GUARD_NOT_PATROLLING_ICONS = new WidgetSprites(new ResourceLocation(GuardVillagers.MODID, "patrolling/notpatrolling1"), new ResourceLocation(GuardVillagers.MODID, "patrolling/notpatrolling2")); + private static final ResourceLocation GUARD_GUI_TEXTURES = ResourceLocation.fromNamespaceAndPath(GuardVillagers.MODID, "textures/container/inventory.png"); + private static final WidgetSprites GUARD_FOLLOWING_ICONS = new WidgetSprites(ResourceLocation.fromNamespaceAndPath(GuardVillagers.MODID, "following/following"), ResourceLocation.fromNamespaceAndPath(GuardVillagers.MODID, "following/following_highlighted")); + private static final WidgetSprites GUARD_NOT_FOLLOWING_ICONS = new WidgetSprites(ResourceLocation.fromNamespaceAndPath(GuardVillagers.MODID, "following/not_following"), ResourceLocation.fromNamespaceAndPath(GuardVillagers.MODID, "following/not_following_highlighted")); + private static final WidgetSprites GUARD_PATROLLING_ICONS = new WidgetSprites(ResourceLocation.fromNamespaceAndPath(GuardVillagers.MODID, "patrolling/patrolling1"), ResourceLocation.fromNamespaceAndPath(GuardVillagers.MODID, "patrolling/patrolling2")); + private static final WidgetSprites GUARD_NOT_PATROLLING_ICONS = new WidgetSprites(ResourceLocation.fromNamespaceAndPath(GuardVillagers.MODID, "patrolling/notpatrolling1"), ResourceLocation.fromNamespaceAndPath(GuardVillagers.MODID, "patrolling/notpatrolling2")); private final Guard guard; private Player player; private float mousePosX; diff --git a/src/main/java/tallestegg/guardvillagers/client/renderer/GuardRenderer.java b/src/main/java/tallestegg/guardvillagers/client/renderer/GuardRenderer.java index 32ffd88..c822681 100644 --- a/src/main/java/tallestegg/guardvillagers/client/renderer/GuardRenderer.java +++ b/src/main/java/tallestegg/guardvillagers/client/renderer/GuardRenderer.java @@ -117,9 +117,9 @@ protected void scale(Guard entitylivingbaseIn, PoseStack matrixStackIn, float pa @Override public ResourceLocation getTextureLocation(Guard entity) { return !GuardConfig.CLIENT.GuardSteve.get() - ? new ResourceLocation(GuardVillagers.MODID, + ? ResourceLocation.fromNamespaceAndPath(GuardVillagers.MODID, "textures/entity/guard/guard_" + entity.getGuardVariant() + ".png") - : new ResourceLocation(GuardVillagers.MODID, + : ResourceLocation.fromNamespaceAndPath(GuardVillagers.MODID, "textures/entity/guard/guard_steve_" + entity.getGuardVariant() + ".png"); } } diff --git a/src/main/java/tallestegg/guardvillagers/common/entities/Guard.java b/src/main/java/tallestegg/guardvillagers/common/entities/Guard.java index 7873402..6324dcc 100644 --- a/src/main/java/tallestegg/guardvillagers/common/entities/Guard.java +++ b/src/main/java/tallestegg/guardvillagers/common/entities/Guard.java @@ -13,6 +13,7 @@ import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.resources.ResourceKey; +import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; @@ -49,7 +50,9 @@ import net.minecraft.world.entity.projectile.AbstractArrow; import net.minecraft.world.entity.projectile.ProjectileUtil; import net.minecraft.world.entity.raid.Raider; +import net.minecraft.world.food.FoodProperties; import net.minecraft.world.item.*; +import net.minecraft.world.item.enchantment.EnchantmentEffectComponents; import net.minecraft.world.item.enchantment.EnchantmentHelper; import net.minecraft.world.item.enchantment.Enchantments; import net.minecraft.world.level.Level; @@ -67,6 +70,7 @@ import org.jetbrains.annotations.NotNull; import tallestegg.guardvillagers.GuardItems; import tallestegg.guardvillagers.GuardLootTables; +import tallestegg.guardvillagers.GuardVillagers; import tallestegg.guardvillagers.client.GuardSounds; import tallestegg.guardvillagers.common.entities.ai.goals.*; import tallestegg.guardvillagers.configuration.GuardConfig; @@ -79,7 +83,7 @@ public class Guard extends PathfinderMob implements CrossbowAttackMob, RangedAttackMob, NeutralMob, ContainerListener, ReputationEventHandler { protected static final EntityDataAccessor> OWNER_UNIQUE_ID = SynchedEntityData.defineId(Guard.class, EntityDataSerializers.OPTIONAL_UUID); private static final UUID MODIFIER_UUID = UUID.fromString("5CD17E52-A79A-43D3-A529-90FDE04B181E"); - private static final AttributeModifier USE_ITEM_SPEED_PENALTY = new AttributeModifier(MODIFIER_UUID, "Use item speed penalty", -0.25D, AttributeModifier.Operation.ADD_VALUE); + private static final AttributeModifier USE_ITEM_SPEED_PENALTY = new AttributeModifier(ResourceLocation.fromNamespaceAndPath(GuardVillagers.MODID, "item_slow_down"), -0.25D, AttributeModifier.Operation.ADD_VALUE); private static final EntityDataAccessor> GUARD_POS = SynchedEntityData.defineId(Guard.class, EntityDataSerializers.OPTIONAL_BLOCK_POS); private static final EntityDataAccessor PATROLLING = SynchedEntityData.defineId(Guard.class, EntityDataSerializers.BOOLEAN); private static final EntityDataAccessor GUARD_VARIANT = SynchedEntityData.defineId(Guard.class, EntityDataSerializers.INT); @@ -160,7 +164,7 @@ public static AttributeSupplier.Builder createAttributes() { public SpawnGroupData finalizeSpawn(@NotNull ServerLevelAccessor worldIn, @NotNull DifficultyInstance difficultyIn, @NotNull MobSpawnType reason, @Nullable SpawnGroupData spawnDataIn) { this.setPersistenceRequired(); int type = !GuardConfig.COMMON.guardVariantRandomSpawning.get() ? - getRandomTypeForBiome(level(), this.blockPosition()) : this.random.nextInt(6); + getRandomTypeForBiome(level(), this.blockPosition()) : this.random.nextInt(6); if (spawnDataIn instanceof GuardData) { type = ((GuardData) spawnDataIn).variantData; spawnDataIn = new GuardData(type); @@ -206,11 +210,11 @@ protected SoundEvent getDeathSound() { } @Override - protected void dropCustomDeathLoot(DamageSource source, int looting, boolean recentlyHitIn) { + protected void dropCustomDeathLoot(ServerLevel level, DamageSource source, boolean recentlyHitIn) { for (int i = 0; i < this.guardInventory.getContainerSize(); ++i) { ItemStack itemstack = this.guardInventory.getItem(i); RandomSource randomsource = level().getRandom(); - if (!itemstack.isEmpty() && !EnchantmentHelper.hasVanishingCurse(itemstack) && randomsource.nextFloat() < GuardConfig.COMMON.chanceToDropEquipment.get().floatValue()) + if (!itemstack.isEmpty() && EnchantmentHelper.has(itemstack, EnchantmentEffectComponents.PREVENT_EQUIPMENT_DROP) && randomsource.nextFloat() < GuardConfig.COMMON.chanceToDropEquipment.get().floatValue()) this.spawnAtLocation(itemstack); } } @@ -259,7 +263,7 @@ public void readAdditionalSaveData(@NotNull CompoundTag compound) { for (int i = 0; i < this.armorItems.size(); ++i) { ItemStack stack = ItemStack.parseOptional(this.registryAccess(), armorItems.getCompound(i)); if (!stack.isEmpty()) { - int index = Guard.slotToInventoryIndex(Mob.getEquipmentSlotForItem(ItemStack.parse(this.registryAccess(), armorItems.getCompound(i)).orElse(ItemStack.EMPTY))); + int index = Guard.slotToInventoryIndex(this.getEquipmentSlotForItem(ItemStack.parse(this.registryAccess(), armorItems.getCompound(i)).orElse(ItemStack.EMPTY))); this.guardInventory.setItem(index, stack); } else { listtag.add(new CompoundTag()); @@ -435,7 +439,7 @@ public void die(DamageSource source) { } @Override - public ItemStack eat(Level world, ItemStack stack) { + public final ItemStack eat(Level world, ItemStack stack, FoodProperties foodProperties) { if (stack.getUseAnimation() == UseAnim.EAT) { this.heal((float) stack.getItem().getFoodProperties(stack, this).nutrition()); } @@ -456,7 +460,6 @@ public void aiStep() { for (EquipmentSlot equipmentslottype : EquipmentSlot.values()) { for (ItemStack stack : this.getItemsFromLootTable(equipmentslottype, (ServerLevel) this.level())) { this.setItemSlot(equipmentslottype, stack); - this.setShieldBanners(this.getOffhandItem()); } } this.spawnWithArmor = false; @@ -481,7 +484,7 @@ public EntityDimensions getDefaultDimensions(Pose pose) { protected void blockUsingShield(LivingEntity entityIn) { super.blockUsingShield(entityIn); this.playSound(SoundEvents.SHIELD_BLOCK, 1.0F, 1.0F); - if (entityIn.getMainHandItem().canDisableShield(this.useItem, this, entityIn)) this.disableShield(true); + if (entityIn.getMainHandItem().canDisableShield(this.useItem, this, entityIn)) this.disableShield(); } @Override @@ -518,18 +521,14 @@ public void startUsingItem(InteractionHand hand) { @Override public void stopUsingItem() { super.stopUsingItem(); - if (this.getAttribute(Attributes.MOVEMENT_SPEED).hasModifier(USE_ITEM_SPEED_PENALTY)) + if (this.getAttribute(Attributes.MOVEMENT_SPEED).hasModifier(USE_ITEM_SPEED_PENALTY.id())) this.getAttribute(Attributes.MOVEMENT_SPEED).removeModifier(USE_ITEM_SPEED_PENALTY); } - public void disableShield(boolean increase) { - float chance = 0.25F + (float) EnchantmentHelper.getBlockEfficiency(this) * 0.05F; - if (increase) chance += 0.75; - if (this.random.nextFloat() < chance) { - this.shieldCoolDown = 100; - this.stopUsingItem(); - this.level().broadcastEntityEvent(this, (byte) 30); - } + public void disableShield() { + this.shieldCoolDown = 100; + this.stopUsingItem(); + this.level().broadcastEntityEvent(this, (byte) 30); } @Override @@ -574,8 +573,9 @@ public List getItemsFromLootTable(EquipmentSlot slot, ServerLevel lev LootTable loot = serverlevel.getServer().reloadableRegistries().getLootTable(EQUIPMENT_SLOT_ITEMS.get(slot)); LootParams lootcontext$builder = (new LootParams.Builder(level).withParameter(LootContextParams.THIS_ENTITY, this).create(GuardLootTables.SLOT)); return loot.getRandomItems(lootcontext$builder); + } else { + return Collections.singletonList(ItemStack.EMPTY); } - return Collections.singletonList(ItemStack.EMPTY); } @@ -656,7 +656,7 @@ public boolean canContinueToUse() { } @Override - public boolean canBeLeashed(Player player) { + public boolean mayBeLeashed() { return false; } @@ -667,15 +667,8 @@ public void performRangedAttack(LivingEntity target, float distanceFactor) { if (this.getMainHandItem().getItem() instanceof BowItem) { ItemStack itemstack = this.getProjectile(this.getItemInHand(GuardItems.getHandWith(this, item -> item instanceof BowItem))); ItemStack hand = this.getMainHandItem(); - AbstractArrow abstractarrowentity = ProjectileUtil.getMobArrow(this, itemstack, distanceFactor); + AbstractArrow abstractarrowentity = ProjectileUtil.getMobArrow(this, itemstack, distanceFactor, itemstack); abstractarrowentity = ((BowItem) this.getMainHandItem().getItem()).customArrow(abstractarrowentity, itemstack); - int powerLevel = itemstack.getEnchantmentLevel(Enchantments.POWER); - if (powerLevel > 0) - abstractarrowentity.setBaseDamage(abstractarrowentity.getBaseDamage() + (double) powerLevel * 0.5D + 0.5D); - int punchLevel = itemstack.getEnchantmentLevel(Enchantments.PUNCH); - if (punchLevel > 0) abstractarrowentity.setKnockback(punchLevel); - if (itemstack.getEnchantmentLevel(Enchantments.FLAME) > 0) - abstractarrowentity.setRemainingFireTicks(100); double d0 = target.getX() - this.getX(); double d1 = target.getY(0.3333333333333333D) - abstractarrowentity.getY(); double d2 = target.getZ() - this.getZ(); @@ -821,19 +814,7 @@ public void containerChanged(Container invBasic) { @Override protected void hurtArmor(DamageSource damageSource, float damage) { - if (damage >= 0.0F) { - damage = damage / 4.0F; - if (damage < 1.0F) { - damage = 1.0F; - } - for (int i = 0; i < this.guardInventory.getContainerSize(); ++i) { - ItemStack itemstack = this.guardInventory.getItem(i); - if ((!damageSource.is(DamageTypes.ON_FIRE) || !itemstack.getItem().components().has(DataComponents.FIRE_RESISTANT)) && itemstack.getItem() instanceof ArmorItem) { - int j = i; - itemstack.hurtAndBreak((int) damage, this, EquipmentSlot.byTypeAndIndex(EquipmentSlot.Type.ARMOR, j)); - } - } - } + this.doHurtEquipment(damageSource, damage, EquipmentSlot.FEET, EquipmentSlot.LEGS, EquipmentSlot.CHEST, EquipmentSlot.HEAD); } @Override diff --git a/src/main/java/tallestegg/guardvillagers/common/entities/ai/goals/RaiseShieldGoal.java b/src/main/java/tallestegg/guardvillagers/common/entities/ai/goals/RaiseShieldGoal.java index 23fc55f..6bfdf16 100644 --- a/src/main/java/tallestegg/guardvillagers/common/entities/ai/goals/RaiseShieldGoal.java +++ b/src/main/java/tallestegg/guardvillagers/common/entities/ai/goals/RaiseShieldGoal.java @@ -24,7 +24,7 @@ public RaiseShieldGoal(Guard guard) { @Override public boolean canUse() { return !CrossbowItem.isCharged(guard.getMainHandItem()) && (guard.getOffhandItem().getItem().canPerformAction(guard.getOffhandItem(), ToolActions.SHIELD_BLOCK) && raiseShield() && guard.shieldCoolDown == 0 - && !guard.getOffhandItem().getItem().equals(Registries.ITEM.registry().equals(new ResourceLocation("bigbrain:buckler")))); + && !guard.getOffhandItem().getItem().equals(Registries.ITEM.registry().equals(ResourceLocation.fromNamespaceAndPath("piglinproliferation", "buckler")))); } @Override diff --git a/src/main/java/tallestegg/guardvillagers/common/entities/ai/goals/RangedCrossbowAttackPassiveGoal.java b/src/main/java/tallestegg/guardvillagers/common/entities/ai/goals/RangedCrossbowAttackPassiveGoal.java index a928807..fe3d5ce 100644 --- a/src/main/java/tallestegg/guardvillagers/common/entities/ai/goals/RangedCrossbowAttackPassiveGoal.java +++ b/src/main/java/tallestegg/guardvillagers/common/entities/ai/goals/RangedCrossbowAttackPassiveGoal.java @@ -140,7 +140,7 @@ public void tick() { } int i = this.mob.getTicksUsingItem(); ItemStack itemstack = this.mob.getUseItem(); - if (i >= CrossbowItem.getChargeDuration(itemstack) || CrossbowItem.isCharged(itemstack)) { + if (i >= CrossbowItem.getChargeDuration(itemstack, this.mob) || CrossbowItem.isCharged(itemstack)) { this.mob.releaseUsingItem(); this.crossbowState = CrossbowState.CHARGED; this.attackDelay = 10 + this.mob.getRandom().nextInt(5); diff --git a/src/main/java/tallestegg/guardvillagers/mixins/VillagerModelMixin.java b/src/main/java/tallestegg/guardvillagers/mixins/VillagerModelMixin.java index 81a7411..26320cf 100644 --- a/src/main/java/tallestegg/guardvillagers/mixins/VillagerModelMixin.java +++ b/src/main/java/tallestegg/guardvillagers/mixins/VillagerModelMixin.java @@ -18,13 +18,14 @@ public abstract class VillagerModelMixin extends HierarchicalM @Shadow @Final private ModelPart head; - + @Override - public void renderToBuffer(PoseStack pose, VertexConsumer consumer, int light, int packedOverlay, float red, float blue, float green, float alpha) { + public void renderToBuffer(PoseStack p_170625_, VertexConsumer p_170626_, int p_170627_, int p_170628_, int p_350603_) { float scale = this.young && GuardConfig.CLIENT.bigHeadBabyVillager.get() ? 1.5F : 1.0F; this.head.xScale = scale; this.head.yScale = scale; this.head.zScale = scale; - super.renderToBuffer(pose, consumer, light, packedOverlay, red, blue, green, alpha); + super.renderToBuffer(p_170625_, p_170626_, p_170627_, p_170628_, p_350603_); + } } diff --git a/src/main/java/tallestegg/guardvillagers/networking/GuardFollowPacket.java b/src/main/java/tallestegg/guardvillagers/networking/GuardFollowPacket.java index 49e4333..b37c93a 100644 --- a/src/main/java/tallestegg/guardvillagers/networking/GuardFollowPacket.java +++ b/src/main/java/tallestegg/guardvillagers/networking/GuardFollowPacket.java @@ -14,7 +14,7 @@ import tallestegg.guardvillagers.common.entities.Guard; public record GuardFollowPacket(int entityId) implements CustomPacketPayload { - public static final Type TYPE = new Type<>(new ResourceLocation(GuardVillagers.MODID, "following")); + public static final Type TYPE = new Type<>(ResourceLocation.fromNamespaceAndPath(GuardVillagers.MODID, "following")); public static final StreamCodec STREAM_CODEC = StreamCodec.composite( ByteBufCodecs.INT, GuardFollowPacket::entityId, GuardFollowPacket::new diff --git a/src/main/java/tallestegg/guardvillagers/networking/GuardOpenInventoryPacket.java b/src/main/java/tallestegg/guardvillagers/networking/GuardOpenInventoryPacket.java index c49eec7..26d7be0 100644 --- a/src/main/java/tallestegg/guardvillagers/networking/GuardOpenInventoryPacket.java +++ b/src/main/java/tallestegg/guardvillagers/networking/GuardOpenInventoryPacket.java @@ -10,7 +10,7 @@ import tallestegg.guardvillagers.GuardVillagers; public record GuardOpenInventoryPacket(int id, int size, int entityId) implements CustomPacketPayload { - public static final Type TYPE = new Type<>(new ResourceLocation(GuardVillagers.MODID, "open_inventory")); + public static final Type TYPE = new Type<>(ResourceLocation.fromNamespaceAndPath(GuardVillagers.MODID, "open_inventory")); public static final StreamCodec STREAM_CODEC = StreamCodec.composite( ByteBufCodecs.INT, GuardOpenInventoryPacket::id, diff --git a/src/main/java/tallestegg/guardvillagers/networking/GuardSetPatrolPosPacket.java b/src/main/java/tallestegg/guardvillagers/networking/GuardSetPatrolPosPacket.java index bf92be8..bd90f5a 100644 --- a/src/main/java/tallestegg/guardvillagers/networking/GuardSetPatrolPosPacket.java +++ b/src/main/java/tallestegg/guardvillagers/networking/GuardSetPatrolPosPacket.java @@ -14,7 +14,7 @@ import tallestegg.guardvillagers.common.entities.Guard; public record GuardSetPatrolPosPacket(int entityId, boolean pressed) implements CustomPacketPayload { - public static final Type TYPE = new Type<>(new ResourceLocation(GuardVillagers.MODID, "set_patrol")); + public static final Type TYPE = new Type<>(ResourceLocation.fromNamespaceAndPath(GuardVillagers.MODID, "set_patrol")); public static final StreamCodec STREAM_CODEC = StreamCodec.composite( ByteBufCodecs.INT, GuardSetPatrolPosPacket::entityId, ByteBufCodecs.BOOL, GuardSetPatrolPosPacket::pressed, diff --git a/src/main/resources/data/guardvillagers/advancements/adventure/recruit_guard.json b/src/main/resources/data/guardvillagers/advancement/adventure/recruit_guard.json similarity index 100% rename from src/main/resources/data/guardvillagers/advancements/adventure/recruit_guard.json rename to src/main/resources/data/guardvillagers/advancement/adventure/recruit_guard.json diff --git a/src/main/resources/data/guardvillagers/loot_tables/entities/guard.json b/src/main/resources/data/guardvillagers/loot_table/entities/guard.json similarity index 100% rename from src/main/resources/data/guardvillagers/loot_tables/entities/guard.json rename to src/main/resources/data/guardvillagers/loot_table/entities/guard.json diff --git a/src/main/resources/data/guardvillagers/loot_tables/entities/guard_chestplate.json b/src/main/resources/data/guardvillagers/loot_table/entities/guard_chestplate.json similarity index 100% rename from src/main/resources/data/guardvillagers/loot_tables/entities/guard_chestplate.json rename to src/main/resources/data/guardvillagers/loot_table/entities/guard_chestplate.json diff --git a/src/main/resources/data/guardvillagers/loot_tables/entities/guard_feet.json b/src/main/resources/data/guardvillagers/loot_table/entities/guard_feet.json similarity index 100% rename from src/main/resources/data/guardvillagers/loot_tables/entities/guard_feet.json rename to src/main/resources/data/guardvillagers/loot_table/entities/guard_feet.json diff --git a/src/main/resources/data/guardvillagers/loot_tables/entities/guard_helmet.json b/src/main/resources/data/guardvillagers/loot_table/entities/guard_helmet.json similarity index 100% rename from src/main/resources/data/guardvillagers/loot_tables/entities/guard_helmet.json rename to src/main/resources/data/guardvillagers/loot_table/entities/guard_helmet.json diff --git a/src/main/resources/data/guardvillagers/loot_tables/entities/guard_legs.json b/src/main/resources/data/guardvillagers/loot_table/entities/guard_legs.json similarity index 100% rename from src/main/resources/data/guardvillagers/loot_tables/entities/guard_legs.json rename to src/main/resources/data/guardvillagers/loot_table/entities/guard_legs.json diff --git a/src/main/resources/data/guardvillagers/loot_tables/entities/guard_main_hand.json b/src/main/resources/data/guardvillagers/loot_table/entities/guard_main_hand.json similarity index 100% rename from src/main/resources/data/guardvillagers/loot_tables/entities/guard_main_hand.json rename to src/main/resources/data/guardvillagers/loot_table/entities/guard_main_hand.json diff --git a/src/main/resources/data/guardvillagers/loot_tables/entities/guard_off_hand.json b/src/main/resources/data/guardvillagers/loot_table/entities/guard_off_hand.json similarity index 100% rename from src/main/resources/data/guardvillagers/loot_tables/entities/guard_off_hand.json rename to src/main/resources/data/guardvillagers/loot_table/entities/guard_off_hand.json