Fish animation & egg
This commit is contained in:
parent
e76577328c
commit
112783835e
5 changed files with 79 additions and 7 deletions
|
@ -1,15 +1,20 @@
|
|||
package ru.betterend.entity;
|
||||
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.attribute.DefaultAttributeContainer;
|
||||
import net.minecraft.entity.attribute.EntityAttributes;
|
||||
import net.minecraft.entity.damage.DamageSource;
|
||||
import net.minecraft.entity.data.DataTracker;
|
||||
import net.minecraft.entity.data.TrackedData;
|
||||
import net.minecraft.entity.data.TrackedDataHandlerRegistry;
|
||||
import net.minecraft.entity.passive.SchoolingFishEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.particle.ParticleTypes;
|
||||
import net.minecraft.sound.SoundEvent;
|
||||
import net.minecraft.sound.SoundEvents;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class EntityEndFish extends SchoolingFishEntity {
|
||||
|
@ -25,7 +30,25 @@ public class EntityEndFish extends SchoolingFishEntity {
|
|||
protected void initDataTracker() {
|
||||
super.initDataTracker();
|
||||
this.dataTracker.startTracking(VARIANT, (byte) this.getRandom().nextInt(VARIANTS));
|
||||
this.dataTracker.startTracking(SCALE, (byte) this.getRandom().nextInt(255));
|
||||
this.dataTracker.startTracking(SCALE, (byte) this.getRandom().nextInt(16));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeCustomDataToTag(CompoundTag tag) {
|
||||
super.writeCustomDataToTag(tag);
|
||||
tag.putByte("Variant", (byte) getVariant());
|
||||
tag.putByte("Scale", (byte) getScale());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readCustomDataFromTag(CompoundTag tag) {
|
||||
super.readCustomDataFromTag(tag);
|
||||
if (tag.contains("Variant")) {
|
||||
this.dataTracker.set(VARIANT, tag.getByte("Variant"));
|
||||
}
|
||||
if (tag.contains("Scale")) {
|
||||
this.dataTracker.set(SCALE, tag.getByte("Scale"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -35,14 +58,40 @@ public class EntityEndFish extends SchoolingFishEntity {
|
|||
|
||||
@Override
|
||||
protected SoundEvent getFlopSound() {
|
||||
return null;
|
||||
return SoundEvents.ENTITY_TROPICAL_FISH_FLOP;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEvent getAmbientSound() {
|
||||
return SoundEvents.ENTITY_SALMON_AMBIENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEvent getDeathSound() {
|
||||
return SoundEvents.ENTITY_SALMON_DEATH;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEvent getHurtSound(DamageSource source) {
|
||||
return SoundEvents.ENTITY_SALMON_HURT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
super.tick();
|
||||
if (random.nextInt(8) == 0 && getBlockState().isOf(Blocks.WATER)) {
|
||||
double x = getX() + random.nextGaussian() * 0.2;
|
||||
double y = getY() + random.nextGaussian() * 0.2;
|
||||
double z = getZ() + random.nextGaussian() * 0.2;
|
||||
world.addParticle(ParticleTypes.BUBBLE, x, y, z, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
public static DefaultAttributeContainer.Builder createMobAttributes() {
|
||||
return LivingEntity.createLivingAttributes()
|
||||
.add(EntityAttributes.GENERIC_MAX_HEALTH, 2.0D)
|
||||
.add(EntityAttributes.GENERIC_FOLLOW_RANGE, 16.0D)
|
||||
.add(EntityAttributes.GENERIC_MOVEMENT_SPEED, 0.5D);
|
||||
.add(EntityAttributes.GENERIC_MAX_HEALTH, 2.0)
|
||||
.add(EntityAttributes.GENERIC_FOLLOW_RANGE, 16.0)
|
||||
.add(EntityAttributes.GENERIC_MOVEMENT_SPEED, 0.75);
|
||||
}
|
||||
|
||||
public int getVariant() {
|
||||
|
@ -50,6 +99,6 @@ public class EntityEndFish extends SchoolingFishEntity {
|
|||
}
|
||||
|
||||
public float getScale() {
|
||||
return ((int) this.dataTracker.get(SCALE) & 255) / 512F + 0.6F;
|
||||
return this.dataTracker.get(SCALE) / 32F + 0.75F;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package ru.betterend.entity.model;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
import net.minecraft.client.model.ModelPart;
|
||||
import net.minecraft.client.render.VertexConsumer;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
|
@ -97,6 +99,8 @@ public class ModelEntityDragonfly extends BlockBenchModel<EntityDragonfly> {
|
|||
|
||||
@Override
|
||||
public void render(MatrixStack matrices, VertexConsumer vertices, int light, int overlay, float red, float green, float blue, float alpha) {
|
||||
RenderSystem.enableCull();
|
||||
model.render(matrices, vertices, light, overlay);
|
||||
RenderSystem.disableCull();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,7 +58,13 @@ public class ModelEntityEndFish extends BlockBenchModel<EntityEndFish> {
|
|||
|
||||
@Override
|
||||
public void setAngles(EntityEndFish entity, float limbAngle, float limbDistance, float animationProgress, float headYaw, float headPitch) {
|
||||
|
||||
float s1 = (float) Math.sin(animationProgress * 0.1);
|
||||
float s2 = (float) Math.sin(animationProgress * 0.05);
|
||||
flipper.yaw = s1 * 0.3F;
|
||||
fin_top.pitch = s2 * 0.02F - 0.6981F;
|
||||
fin_bottom.pitch = 0.6981F - s2 * 0.02F;
|
||||
fin_left.yaw = s1 * 0.3F - 0.7854F;
|
||||
fin_right.yaw = 0.7854F - s1 * 0.3F;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
10
src/main/java/ru/betterend/item/ItemSpawnEgg.java
Normal file
10
src/main/java/ru/betterend/item/ItemSpawnEgg.java
Normal file
|
@ -0,0 +1,10 @@
|
|||
package ru.betterend.item;
|
||||
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.item.SpawnEggItem;
|
||||
|
||||
public abstract class ItemSpawnEgg extends SpawnEggItem {
|
||||
public ItemSpawnEgg(EntityType<?> type, int primaryColor, int secondaryColor, Settings settings) {
|
||||
super(type, primaryColor, secondaryColor, settings);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"parent": "item/template_spawn_egg"
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue