diff --git a/common/src/main/java/dev/itsmeow/betteranimalsplus/client/model/entity/ModelDeer.java b/common/src/main/java/dev/itsmeow/betteranimalsplus/client/model/entity/ModelDeer.java index 1adc15d6..50f1706f 100644 --- a/common/src/main/java/dev/itsmeow/betteranimalsplus/client/model/entity/ModelDeer.java +++ b/common/src/main/java/dev/itsmeow/betteranimalsplus/client/model/entity/ModelDeer.java @@ -264,13 +264,12 @@ public void setupAnim(T entity, float limbSwing, float limbSwingAmount, float ag this.head.xRot = rad(-65F); this.lowerJaw.xRot = rad(eatTime % 20F) + 0.1F; } else { - this.chest.xRot = -0.6829473363053812F; - this.neck.xRot = headPitch * 0.017453292F - 0.31869712141416456F; - this.head.xRot = -0.31869712141416456F; + this.chest.xRot = -0.8378F; + this.neck.xRot = -0.3142F; this.lowerJaw.xRot = 0F; + this.headPitch(head, headPitch, 1F, 0F); } } - this.headPitch(head, headPitch, 1F, -13F); } } diff --git a/common/src/main/java/dev/itsmeow/betteranimalsplus/common/entity/EntityCrab.java b/common/src/main/java/dev/itsmeow/betteranimalsplus/common/entity/EntityCrab.java index b6186fd2..e4798b10 100644 --- a/common/src/main/java/dev/itsmeow/betteranimalsplus/common/entity/EntityCrab.java +++ b/common/src/main/java/dev/itsmeow/betteranimalsplus/common/entity/EntityCrab.java @@ -4,6 +4,7 @@ import dev.itsmeow.betteranimalsplus.common.entity.util.abstracts.EntityCrabLikeBase; import dev.itsmeow.betteranimalsplus.init.ModEntities; import dev.itsmeow.imdlib.entity.EntityTypeContainer; +import dev.itsmeow.imdlib.entity.util.EntityTypeContainerContainable; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; @@ -143,4 +144,8 @@ public EntityTypeContainer getContainer() { return ModEntities.CRAB; } + @Override + public EntityTypeContainerContainable getContainableContainer() { + return ModEntities.CRAB; + } } diff --git a/common/src/main/java/dev/itsmeow/betteranimalsplus/common/entity/EntityHorseshoeCrab.java b/common/src/main/java/dev/itsmeow/betteranimalsplus/common/entity/EntityHorseshoeCrab.java index 0cea535d..b5350431 100644 --- a/common/src/main/java/dev/itsmeow/betteranimalsplus/common/entity/EntityHorseshoeCrab.java +++ b/common/src/main/java/dev/itsmeow/betteranimalsplus/common/entity/EntityHorseshoeCrab.java @@ -5,6 +5,8 @@ import dev.itsmeow.betteranimalsplus.init.ModEntities; import dev.itsmeow.betteranimalsplus.init.ModItems; import dev.itsmeow.imdlib.entity.EntityTypeContainer; +import dev.itsmeow.imdlib.entity.interfaces.IContainable; +import dev.itsmeow.imdlib.entity.util.EntityTypeContainerContainable; import net.minecraft.nbt.CompoundTag; import net.minecraft.world.DifficultyInstance; import net.minecraft.world.InteractionHand; @@ -72,9 +74,32 @@ public void addAdditionalSaveData(CompoundTag compound) { compound.putInt("BloodLeft", this.bloodLeft); } + @Override + public void setContainerData(ItemStack bucket) { + super.setContainerData(bucket); + CompoundTag tag = bucket.getTag(); + if(bucket.getTag() == null) { + tag = new CompoundTag(); + } + tag.putInt("HorseshoeCrabBloodLeft", this.bloodLeft); + bucket.setTag(tag); + } + + @Override + public void readFromContainerTag(CompoundTag tag) { + super.readFromContainerTag(tag); + if(tag.contains("HorseshoeCrabBloodLeft")) { + this.bloodLeft = tag.getInt("HorseshoeCrabBloodLeft"); + } + } + @Override public EntityTypeContainer getContainer() { return ModEntities.HORSESHOE_CRAB; } + @Override + public EntityTypeContainerContainable getContainableContainer() { + return ModEntities.HORSESHOE_CRAB; + } } diff --git a/common/src/main/java/dev/itsmeow/betteranimalsplus/common/entity/util/abstracts/EntityAnimalWithTypesContainable.java b/common/src/main/java/dev/itsmeow/betteranimalsplus/common/entity/util/abstracts/EntityAnimalWithTypesContainable.java new file mode 100644 index 00000000..297f4108 --- /dev/null +++ b/common/src/main/java/dev/itsmeow/betteranimalsplus/common/entity/util/abstracts/EntityAnimalWithTypesContainable.java @@ -0,0 +1,71 @@ +package dev.itsmeow.betteranimalsplus.common.entity.util.abstracts; + +import dev.itsmeow.imdlib.entity.interfaces.IContainable; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.Level; + +public abstract class EntityAnimalWithTypesContainable extends EntityAnimalWithTypes implements IContainable { + + public EntityAnimalWithTypesContainable(EntityType entityType, Level worldIn) { + super(entityType, worldIn); + } + + @Override + protected void defineSynchedData() { + super.defineSynchedData(); + this.registerFromContainerKey(); + } + + @Override + public void addAdditionalSaveData(CompoundTag compound) { + super.addAdditionalSaveData(compound); + this.writeFromContainerToEntity(compound); + } + + @Override + public void readAdditionalSaveData(CompoundTag compound) { + super.readAdditionalSaveData(compound); + this.readFromContainerToEntity(compound); + } + + @Override + public boolean removeWhenFarAway(double distanceToClosestPlayer) { + return !this.isFromContainer() && despawn(distanceToClosestPlayer); + } + + @Override + public boolean requiresCustomPersistence() { + return this.isFromContainer(); + } + + @Override + public void setContainerData(ItemStack bucket) { + IContainable.super.setContainerData(bucket); + CompoundTag tag = bucket.getTag(); + if(bucket.getTag() == null) { + tag = new CompoundTag(); + } + tag.putString("BucketVariantTag", this.getVariantNameOrEmpty()); + bucket.setTag(tag); + } + + @Override + public InteractionResult mobInteract(Player player, InteractionHand hand) { + if(this.processContainerInteract(player, hand)) { + return InteractionResult.SUCCESS; + } + return super.mobInteract(player, hand); + } + + @Override + public void readFromContainerTag(CompoundTag tag) { + if(tag.contains("BucketVariantTag")) { + this.setType(tag.getString("BucketVariantTag")); + } + } +} diff --git a/common/src/main/java/dev/itsmeow/betteranimalsplus/common/entity/util/abstracts/EntityCrabLikeBase.java b/common/src/main/java/dev/itsmeow/betteranimalsplus/common/entity/util/abstracts/EntityCrabLikeBase.java index 2a16952a..5125c584 100644 --- a/common/src/main/java/dev/itsmeow/betteranimalsplus/common/entity/util/abstracts/EntityCrabLikeBase.java +++ b/common/src/main/java/dev/itsmeow/betteranimalsplus/common/entity/util/abstracts/EntityCrabLikeBase.java @@ -15,7 +15,7 @@ import java.util.Random; -public abstract class EntityCrabLikeBase extends EntityAnimalWithTypes { +public abstract class EntityCrabLikeBase extends EntityAnimalWithTypesContainable { public int snipTime = 0; diff --git a/common/src/main/java/dev/itsmeow/betteranimalsplus/init/ModEntities.java b/common/src/main/java/dev/itsmeow/betteranimalsplus/init/ModEntities.java index b6d303e8..2bd6718b 100644 --- a/common/src/main/java/dev/itsmeow/betteranimalsplus/init/ModEntities.java +++ b/common/src/main/java/dev/itsmeow/betteranimalsplus/init/ModEntities.java @@ -107,7 +107,7 @@ public class ModEntities { .size(0.8F, 0.8F) .biomesOverworld(BiomeTypes.FOREST, BiomeTypes.PLAINS, BiomeTypes.SAVANNA) .variants("american", "european", "honey")); - public static final EntityTypeContainer CRAB = H.add(EntityCrab.class, EntityCrab::new, "crab", () -> Mob.createMobAttributes() + public static final EntityTypeContainerContainable> CRAB = H.addContainableB(EntityCrab.class, EntityCrab::new, "crab", () -> Mob.createMobAttributes() .add(Attributes.MAX_HEALTH, 6.5D) .add(Attributes.MOVEMENT_SPEED, 0.3D) .add(Attributes.ATTACK_DAMAGE) @@ -117,8 +117,9 @@ public class ModEntities { .egg(0xe21d16, 0x2d0504) .size(1F, 0.65F) .biomesOverworld(BiomeTypes.BEACH, BiomeTypes.SWAMP) - .variants(4)); - public static final EntityTypeContainer HORSESHOE_CRAB = H.add(EntityHorseshoeCrab.class, EntityHorseshoeCrab::new, "horseshoecrab", () -> Mob.createMobAttributes() + .variants("red", "pink", "brown", "blue") + .containers("%s_bucket", ItemModFishBucket.waterBucket(G), "", c -> Items.WATER_BUCKET)); + public static final EntityTypeContainerContainable> HORSESHOE_CRAB = H.addContainableB(EntityHorseshoeCrab.class, EntityHorseshoeCrab::new, "horseshoecrab", () -> Mob.createMobAttributes() .add(Attributes.MAX_HEALTH, 6.5D) .add(Attributes.MOVEMENT_SPEED, 0.3D) .add(Attributes.ATTACK_DAMAGE) @@ -128,7 +129,8 @@ public class ModEntities { .egg(0xba1111, 0x520807) .size(1F, 0.65F) .biomesOverworld(BiomeTypes.BEACH) - .variants("brown", "dark_brown", "green", "orange")); + .variants("brown", "dark_brown", "green", "orange") + .containers("%s_bucket", ItemModFishBucket.waterBucket(G), "", c -> Items.WATER_BUCKET)); public static final EntityTypeContainer SHARK = H.add(EntityShark.class, EntityShark::new, "shark", () -> Mob.createMobAttributes() .add(Attributes.MAX_HEALTH, 30D) .add(Attributes.MOVEMENT_SPEED, 1.5D) diff --git a/common/src/main/resources/assets/betteranimalsplus/lang/en_us.json b/common/src/main/resources/assets/betteranimalsplus/lang/en_us.json index 006aae03..7c910524 100644 --- a/common/src/main/resources/assets/betteranimalsplus/lang/en_us.json +++ b/common/src/main/resources/assets/betteranimalsplus/lang/en_us.json @@ -53,6 +53,8 @@ "item.betteranimalsplus.calamari_cooked": "Cooked Calamari", "item.betteranimalsplus.piranha_bucket": "Bucket of Piranha", "item.betteranimalsplus.horseshoe_crab_blood": "Horseshoe Crab Blood", + "item.betteranimalsplus.crab_bucket": "Bucket of Crab", + "item.betteranimalsplus.horseshoecrab_bucket": "Bucket of Horseshoe Crab", "block.betteranimalsplus.trillium": "Trillium", "block.betteranimalsplus.feralwolfhead": "Feral Wolf Head", @@ -133,6 +135,14 @@ "entity.betteranimalsplus.dragonfly.type.yellow_winged_darter": "Yellow Winged Darter", "entity.betteranimalsplus.flying_fish.type.yellow": "Yellow", "entity.betteranimalsplus.flying_fish.type.purple": "Purple", + "entity.betteranimalsplus.crab.type.red": "Red", + "entity.betteranimalsplus.crab.type.pink": "Pink", + "entity.betteranimalsplus.crab.type.brown": "Brown", + "entity.betteranimalsplus.crab.type.blue": "Blue", + "entity.betteranimalsplus.horseshoecrab.type.brown": "Brown", + "entity.betteranimalsplus.horseshoecrab.type.dark_brown": "Dark Brown", + "entity.betteranimalsplus.horseshoecrab.type.green": "Green", + "entity.betteranimalsplus.horseshoecrab.type.orange": "Orange", "entity.betteranimalsplus.coyote.message.currently_hostile": "This coyote is currently hostile. Perhaps it could be tamed outside of its hunting hours?", "entity.betteranimalsplus.coyote.message.always_hostile": "This coyote is always hostile. It cannot be tamed (server configuration)", @@ -169,5 +179,6 @@ "config.betteranimalsplus.target_chance": "Target Chance", "config.betteranimalsplus.pickup_blacklist": "Pickup Blacklist", "config.betteranimalsplus.create_snow": "Create Snow", - "config.betteranimalsplus.taming_items": "Taming Items" + "config.betteranimalsplus.taming_items": "Taming Items", + "config.betteranimalsplus.hostile_during_daytime": "Hostile During Daytime" } \ No newline at end of file diff --git a/common/src/main/resources/assets/betteranimalsplus/lang/ru_ru.json b/common/src/main/resources/assets/betteranimalsplus/lang/ru_ru.json index b25b4c8d..4cf73410 100644 --- a/common/src/main/resources/assets/betteranimalsplus/lang/ru_ru.json +++ b/common/src/main/resources/assets/betteranimalsplus/lang/ru_ru.json @@ -68,6 +68,9 @@ "block.betteranimalsplus.turkey_raw": "Сырая индейка", "block.betteranimalsplus.turkey_cooked": "Приготовленная индейка", + "entity.betteranimalsplus.tarantulahair": "Волос тарантула", + "entity.betteranimalsplus.badgerdirt": "Барсучья грязь", + "entity.betteranimalsplus.brownbear": "Бурый медведь", "entity.betteranimalsplus.blackbear": "Чёрный медведь", "entity.betteranimalsplus.deer": "Олень", @@ -142,5 +145,29 @@ "misc.betteranimalsplus.eggorder": "Яйцо призыва %s", "tooltip.betteranimalsplus.nectar": "Имеет нектар", - "tooltip.betteranimalsplus.cures_wither": "Лечит иссушение" + "tooltip.betteranimalsplus.cures_wither": "Лечит иссушение", + + "config.betteranimalsplus": "Better Animals Plus конфигурация", + "config.betteranimalsplus.can_despawn": "Может исчезнуть", + "config.betteranimalsplus.spawn_naturally": "Появляется естественным путём", + "config.betteranimalsplus.spawn_weight": "Вес появления", + "config.betteranimalsplus.minimum_group_size": "Минимальный размер группы", + "config.betteranimalsplus.maximum_group_size": "Максимальный размер группы", + "config.betteranimalsplus.spawn_biomes": "Биомы появления", + "config.betteranimalsplus.use_spawn_costs": "Использовать стоимости появления", + "config.betteranimalsplus.cost_per_spawn": "Стоимость за появление", + "config.betteranimalsplus.maximum_cost_per_biome": "Максимальная стоимость на биом", + "config.betteranimalsplus.betteranimalsplus-client": "Настройки клиента", + "config.betteranimalsplus.betteranimalsplus-server-default": "Настройки сервера по умолчанию", + "config.betteranimalsplus.entities": "Сущности", + "config.betteranimalsplus.biome_based_variants": "Варианты на основе биома", + "config.betteranimalsplus.spawning": "Настройки появления", + "config.betteranimalsplus.spawning.spawn_costs": "Стоимость появления", + "config.betteranimalsplus.nerf_options": "Параметры ослабления", + + "config.betteranimalsplus.breed_from_kill": "Размножается от убийства", + "config.betteranimalsplus.breed_from_crops": "Размножается от урожая", + "config.betteranimalsplus.eat_crops": "Ест урожай", + "config.betteranimalsplus.taming_items": "Предметы для приручения", + "config.betteranimalsplus.hostile_during_daytime": "Враждебен в дневное время" } diff --git a/common/src/main/resources/assets/betteranimalsplus/models/item/crab_bucket.json b/common/src/main/resources/assets/betteranimalsplus/models/item/crab_bucket.json new file mode 100644 index 00000000..9abd515b --- /dev/null +++ b/common/src/main/resources/assets/betteranimalsplus/models/item/crab_bucket.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/generated", + "textures": { + "layer0": "betteranimalsplus:items/crab_bucket" + } +} diff --git a/common/src/main/resources/assets/betteranimalsplus/models/item/horseshoecrab_bucket.json b/common/src/main/resources/assets/betteranimalsplus/models/item/horseshoecrab_bucket.json new file mode 100644 index 00000000..31da4ace --- /dev/null +++ b/common/src/main/resources/assets/betteranimalsplus/models/item/horseshoecrab_bucket.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/generated", + "textures": { + "layer0": "betteranimalsplus:items/horseshoecrab_bucket" + } +} diff --git a/common/src/main/resources/assets/betteranimalsplus/textures/entity/crab_4.png b/common/src/main/resources/assets/betteranimalsplus/textures/entity/crab_blue.png similarity index 100% rename from common/src/main/resources/assets/betteranimalsplus/textures/entity/crab_4.png rename to common/src/main/resources/assets/betteranimalsplus/textures/entity/crab_blue.png diff --git a/common/src/main/resources/assets/betteranimalsplus/textures/entity/crab_3.png b/common/src/main/resources/assets/betteranimalsplus/textures/entity/crab_brown.png similarity index 100% rename from common/src/main/resources/assets/betteranimalsplus/textures/entity/crab_3.png rename to common/src/main/resources/assets/betteranimalsplus/textures/entity/crab_brown.png diff --git a/common/src/main/resources/assets/betteranimalsplus/textures/entity/crab_2.png b/common/src/main/resources/assets/betteranimalsplus/textures/entity/crab_pink.png similarity index 100% rename from common/src/main/resources/assets/betteranimalsplus/textures/entity/crab_2.png rename to common/src/main/resources/assets/betteranimalsplus/textures/entity/crab_pink.png diff --git a/common/src/main/resources/assets/betteranimalsplus/textures/entity/crab_1.png b/common/src/main/resources/assets/betteranimalsplus/textures/entity/crab_red.png similarity index 100% rename from common/src/main/resources/assets/betteranimalsplus/textures/entity/crab_1.png rename to common/src/main/resources/assets/betteranimalsplus/textures/entity/crab_red.png diff --git a/common/src/main/resources/assets/betteranimalsplus/textures/items/crab_bucket.png b/common/src/main/resources/assets/betteranimalsplus/textures/items/crab_bucket.png new file mode 100644 index 00000000..0b95e373 Binary files /dev/null and b/common/src/main/resources/assets/betteranimalsplus/textures/items/crab_bucket.png differ diff --git a/common/src/main/resources/assets/betteranimalsplus/textures/items/horseshoecrab_bucket.png b/common/src/main/resources/assets/betteranimalsplus/textures/items/horseshoecrab_bucket.png new file mode 100644 index 00000000..7f678700 Binary files /dev/null and b/common/src/main/resources/assets/betteranimalsplus/textures/items/horseshoecrab_bucket.png differ diff --git a/fabric/src/main/java/dev/itsmeow/betteranimalsplus/mixin/fabric/EntityMixin.java b/fabric/src/main/java/dev/itsmeow/betteranimalsplus/mixin/fabric/EntityMixin.java index 64522a9c..81a4241c 100644 --- a/fabric/src/main/java/dev/itsmeow/betteranimalsplus/mixin/fabric/EntityMixin.java +++ b/fabric/src/main/java/dev/itsmeow/betteranimalsplus/mixin/fabric/EntityMixin.java @@ -17,11 +17,8 @@ @Mixin(Entity.class) public class EntityMixin { - @Shadow - public Level level; - @Unique - protected ArrayList drops = null; + public ArrayList drops = null; @Inject(at = @At(value = "FIELD", target = "Lnet/minecraft/world/entity/Entity;level:Lnet/minecraft/world/level/Level;", ordinal = 2), method = "spawnAtLocation(Lnet/minecraft/world/item/ItemStack;F)Lnet/minecraft/world/entity/item/ItemEntity;", cancellable = true, locals = LocalCapture.CAPTURE_FAILEXCEPTION) private void spawnAtLocation(ItemStack itemStack, float f, CallbackInfoReturnable callback, ItemEntity itemEntity) { diff --git a/fabric/src/main/java/dev/itsmeow/betteranimalsplus/mixin/fabric/LivingEntityMixin.java b/fabric/src/main/java/dev/itsmeow/betteranimalsplus/mixin/fabric/LivingEntityMixin.java index 9b2230c5..5e9432a4 100644 --- a/fabric/src/main/java/dev/itsmeow/betteranimalsplus/mixin/fabric/LivingEntityMixin.java +++ b/fabric/src/main/java/dev/itsmeow/betteranimalsplus/mixin/fabric/LivingEntityMixin.java @@ -2,9 +2,14 @@ import dev.itsmeow.betteranimalsplus.common.CommonEventHandler; import net.minecraft.world.damagesource.DamageSource; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.level.Level; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @@ -12,17 +17,21 @@ import java.util.ArrayList; @Mixin(LivingEntity.class) -public class LivingEntityMixin extends EntityMixin { +public abstract class LivingEntityMixin extends Entity { + + public LivingEntityMixin(EntityType entityType, Level level) { + super(entityType, level); + } @Inject(at = @At("HEAD"), method = "dropAllDeathLoot(Lnet/minecraft/world/damagesource/DamageSource;)V") private void dropAllDeathLootHead(DamageSource source, CallbackInfo callback) { - this.drops = new ArrayList<>(); + ((EntityMixin) (Object) this).drops = new ArrayList<>(); } @Inject(at = @At("RETURN"), method = "dropAllDeathLoot(Lnet/minecraft/world/damagesource/DamageSource;)V") private void dropAllDeathLootReturn(DamageSource source, CallbackInfo callback) { - ArrayList drops = this.drops; - this.drops = null; + ArrayList drops = ((EntityMixin) (Object) this).drops; + ((EntityMixin) (Object) this).drops = null; CommonEventHandler.modifyDropsList(drops, source, (LivingEntity) (Object) this); drops.forEach(level::addFreshEntity); }