Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/1.17' into 1.18
Browse files Browse the repository at this point in the history
  • Loading branch information
itsmeow committed Dec 28, 2021
2 parents d93211d + 441ffff commit 8d445d4
Show file tree
Hide file tree
Showing 18 changed files with 177 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -143,4 +144,8 @@ public EntityTypeContainer<EntityCrab> getContainer() {
return ModEntities.CRAB;
}

@Override
public EntityTypeContainerContainable<?, ?> getContainableContainer() {
return ModEntities.CRAB;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<EntityHorseshoeCrab> getContainer() {
return ModEntities.HORSESHOE_CRAB;
}

@Override
public EntityTypeContainerContainable<?, ?> getContainableContainer() {
return ModEntities.HORSESHOE_CRAB;
}
}
Original file line number Diff line number Diff line change
@@ -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<? extends EntityAnimalWithTypesContainable> 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"));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

import java.util.Random;

public abstract class EntityCrabLikeBase extends EntityAnimalWithTypes {
public abstract class EntityCrabLikeBase extends EntityAnimalWithTypesContainable {

public int snipTime = 0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<EntityCrab> CRAB = H.add(EntityCrab.class, EntityCrab::new, "crab", () -> Mob.createMobAttributes()
public static final EntityTypeContainerContainable<EntityCrab, ItemModFishBucket<EntityCrab>> 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)
Expand All @@ -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<EntityHorseshoeCrab> 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<EntityHorseshoeCrab, ItemModFishBucket<EntityHorseshoeCrab>> 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)
Expand All @@ -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<EntityShark> SHARK = H.add(EntityShark.class, EntityShark::new, "shark", () -> Mob.createMobAttributes()
.add(Attributes.MAX_HEALTH, 30D)
.add(Attributes.MOVEMENT_SPEED, 1.5D)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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)",
Expand Down Expand Up @@ -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"
}
Original file line number Diff line number Diff line change
Expand Up @@ -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": "Олень",
Expand Down Expand Up @@ -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": "Враждебен в дневное время"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "betteranimalsplus:items/crab_bucket"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "betteranimalsplus:items/horseshoecrab_bucket"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,8 @@
@Mixin(Entity.class)
public class EntityMixin {

@Shadow
public Level level;

@Unique
protected ArrayList<ItemEntity> drops = null;
public ArrayList<ItemEntity> 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<ItemEntity> callback, ItemEntity itemEntity) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,36 @@

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;

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<ItemEntity> drops = this.drops;
this.drops = null;
ArrayList<ItemEntity> drops = ((EntityMixin) (Object) this).drops;
((EntityMixin) (Object) this).drops = null;
CommonEventHandler.modifyDropsList(drops, source, (LivingEntity) (Object) this);
drops.forEach(level::addFreshEntity);
}
Expand Down

0 comments on commit 8d445d4

Please sign in to comment.