Continue mapping migration
This commit is contained in:
parent
99ade39404
commit
f03fd03bd0
499 changed files with 12567 additions and 12723 deletions
|
@ -2,143 +2,139 @@ package ru.betterend.entity;
|
|||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.world.entity.EntityData;
|
||||
import net.minecraft.world.entity.EntityDimensions;
|
||||
import net.minecraft.world.entity.EntityPose;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.ItemEntity;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.SpawnReason;
|
||||
import net.minecraft.world.entity.ai.control.MoveControl;
|
||||
import net.minecraft.world.entity.attribute.DefaultAttributeContainer;
|
||||
import net.minecraft.world.entity.attribute.Attributes;
|
||||
import net.minecraft.world.entity.damage.DamageSource;
|
||||
import net.minecraft.world.entity.data.DataTracker;
|
||||
import net.minecraft.world.entity.data.TrackedData;
|
||||
import net.minecraft.world.entity.data.TrackedDataHandlerRegistry;
|
||||
import net.minecraft.world.effect.MobEffectInstance;
|
||||
import net.minecraft.world.effect.MobEffects;
|
||||
import net.minecraft.world.entity.passive.SchoolingFishEntity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.packet.s2c.play.GameStateChangeS2CPacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundGameEventPacket;
|
||||
import net.minecraft.network.syncher.EntityDataAccessor;
|
||||
import net.minecraft.network.syncher.EntityDataSerializers;
|
||||
import net.minecraft.network.syncher.SynchedEntityData;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.tags.FluidTags;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.LocalDifficulty;
|
||||
import net.minecraft.world.level.ServerLevelAccessor;
|
||||
import net.minecraft.world.DifficultyInstance;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.effect.MobEffectInstance;
|
||||
import net.minecraft.world.effect.MobEffects;
|
||||
import net.minecraft.world.entity.EntityDimensions;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.MobSpawnType;
|
||||
import net.minecraft.world.entity.Pose;
|
||||
import net.minecraft.world.entity.SpawnGroupData;
|
||||
import net.minecraft.world.entity.ai.attributes.AttributeSupplier;
|
||||
import net.minecraft.world.entity.ai.attributes.Attributes;
|
||||
import net.minecraft.world.entity.ai.control.MoveControl;
|
||||
import net.minecraft.world.entity.animal.AbstractSchoolingFish;
|
||||
import net.minecraft.world.entity.item.ItemEntity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.ServerLevelAccessor;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import ru.betterend.registry.EndBiomes;
|
||||
import ru.betterend.registry.EndItems;
|
||||
|
||||
public class CubozoaEntity extends SchoolingFishEntity {
|
||||
public class CubozoaEntity extends AbstractSchoolingFish {
|
||||
public static final int VARIANTS = 2;
|
||||
private static final TrackedData<Byte> VARIANT = DataTracker.registerData(CubozoaEntity.class,
|
||||
TrackedDataHandlerRegistry.BYTE);
|
||||
private static final TrackedData<Byte> SCALE = DataTracker.registerData(CubozoaEntity.class,
|
||||
TrackedDataHandlerRegistry.BYTE);
|
||||
private static final EntityDataAccessor<Byte> VARIANT = SynchedEntityData.defineId(CubozoaEntity.class, EntityDataSerializers.BYTE);
|
||||
private static final EntityDataAccessor<Byte> SCALE = SynchedEntityData.defineId(CubozoaEntity.class, EntityDataSerializers.BYTE);
|
||||
|
||||
public CubozoaEntity(EntityType<CubozoaEntity> entityType, Level world) {
|
||||
super(entityType, world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityData initialize(ServerLevelAccessor world, LocalDifficulty difficulty, SpawnReason spawnReason,
|
||||
EntityData entityData, CompoundTag entityTag) {
|
||||
EntityData data = super.initialize(world, difficulty, spawnReason, entityData, entityTag);
|
||||
if (EndBiomes.getFromBiome(world.getBiome(getBlockPos())) == EndBiomes.SULPHUR_SPRINGS) {
|
||||
this.dataTracker.set(VARIANT, (byte) 1);
|
||||
public SpawnGroupData finalizeSpawn(ServerLevelAccessor world, DifficultyInstance difficulty, MobSpawnType spawnReason, SpawnGroupData entityData, CompoundTag entityTag) {
|
||||
SpawnGroupData data = super.finalizeSpawn(world, difficulty, spawnReason, entityData, entityTag);
|
||||
if (EndBiomes.getFromBiome(world.getBiome(blockPosition())) == EndBiomes.SULPHUR_SPRINGS) {
|
||||
this.entityData.set(VARIANT, (byte) 1);
|
||||
}
|
||||
this.calculateDimensions();
|
||||
this.refreshDimensions();
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initDataTracker() {
|
||||
super.initDataTracker();
|
||||
this.dataTracker.startTracking(VARIANT, (byte) 0);
|
||||
this.dataTracker.startTracking(SCALE, (byte) this.getRandom().nextInt(16));
|
||||
protected void defineSynchedData() {
|
||||
super.defineSynchedData();
|
||||
this.entityData.define(VARIANT, (byte) 0);
|
||||
this.entityData.define(SCALE, (byte) this.getRandom().nextInt(16));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeCustomDataToTag(CompoundTag tag) {
|
||||
super.writeCustomDataToTag(tag);
|
||||
public void addAdditionalSaveData(CompoundTag tag) {
|
||||
super.addAdditionalSaveData(tag);
|
||||
tag.putByte("Variant", (byte) getVariant());
|
||||
tag.putByte("Scale", (byte) getScale());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readCustomDataFromTag(CompoundTag tag) {
|
||||
super.readCustomDataFromTag(tag);
|
||||
public void readAdditionalSaveData(CompoundTag tag) {
|
||||
super.readAdditionalSaveData(tag);
|
||||
if (tag.contains("Variant")) {
|
||||
this.dataTracker.set(VARIANT, tag.getByte("Variant"));
|
||||
this.entityData.set(VARIANT, tag.getByte("Variant"));
|
||||
}
|
||||
if (tag.contains("Scale")) {
|
||||
this.dataTracker.set(SCALE, tag.getByte("Scale"));
|
||||
this.entityData.set(SCALE, tag.getByte("Scale"));
|
||||
}
|
||||
}
|
||||
|
||||
public static DefaultAttributeContainer.Builder createMobAttributes() {
|
||||
return LivingEntity.createLivingAttributes().add(Attributes.MAX_HEALTH, 2.0).add(Attributes.FOLLOW_RANGE, 16.0)
|
||||
public static AttributeSupplier.Builder createMobAttributes() {
|
||||
return LivingEntity.createLivingAttributes()
|
||||
.add(Attributes.MAX_HEALTH, 2.0)
|
||||
.add(Attributes.FOLLOW_RANGE, 16.0)
|
||||
.add(Attributes.MOVEMENT_SPEED, 0.5);
|
||||
}
|
||||
|
||||
public int getVariant() {
|
||||
return (int) this.dataTracker.get(VARIANT);
|
||||
return (int) this.entityData.get(VARIANT);
|
||||
}
|
||||
|
||||
public float getScale() {
|
||||
return this.dataTracker.get(SCALE) / 32F + 0.75F;
|
||||
return this.entityData.get(SCALE) / 32F + 0.75F;
|
||||
}
|
||||
|
||||
public static boolean canSpawn(EntityType<CubozoaEntity> type, ServerLevelAccessor world, SpawnReason spawnReason,
|
||||
BlockPos pos, Random random) {
|
||||
Box box = new Box(pos).expand(16);
|
||||
List<CubozoaEntity> list = world.getEntitiesByClass(CubozoaEntity.class, box, (entity) -> {
|
||||
public static boolean canSpawn(EntityType<CubozoaEntity> type, ServerLevelAccessor world, MobSpawnType spawnReason, BlockPos pos, Random random) {
|
||||
AABB box = new AABB(pos).inflate(16);
|
||||
List<CubozoaEntity> list = world.getEntitiesOfClass(CubozoaEntity.class, box, (entity) -> {
|
||||
return true;
|
||||
});
|
||||
return list.size() < 9;
|
||||
}
|
||||
|
||||
protected float getActiveEyeHeight(EntityPose pose, EntityDimensions dimensions) {
|
||||
protected float getStandingEyeHeight(Pose pose, EntityDimensions dimensions) {
|
||||
return dimensions.height * 0.5F;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void dropLoot(DamageSource source, boolean causedByPlayer) {
|
||||
protected void dropFromLootTable(DamageSource source, boolean causedByPlayer) {
|
||||
int count = random.nextInt(3);
|
||||
if (count > 0) {
|
||||
ItemEntity drop = new ItemEntity(world, getX(), getY(), getZ(), new ItemStack(EndItems.GELATINE, count));
|
||||
this.world.spawnEntity(drop);
|
||||
ItemEntity drop = new ItemEntity(level, getX(), getY(), getZ(), new ItemStack(EndItems.GELATINE, count));
|
||||
this.level.addFreshEntity(drop);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ItemStack getFishBucketItem() {
|
||||
protected ItemStack getBucketItemStack() {
|
||||
return new ItemStack(Items.WATER_BUCKET);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEvent getFlopSound() {
|
||||
return SoundEvents.ENTITY_SALMON_FLOP;
|
||||
return SoundEvents.SALMON_FLOP;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onPlayerCollision(Player player) {
|
||||
if (player instanceof ServerPlayer && player.damage(DamageSource.mob(this), 0.5F)) {
|
||||
public void playerTouch(Player player) {
|
||||
if (player instanceof ServerPlayer && player.hurt(DamageSource.mobAttack(this), 0.5F)) {
|
||||
if (!this.isSilent()) {
|
||||
((ServerPlayer) player).networkHandler
|
||||
.sendPacket(new GameStateChangeS2CPacket(GameStateChangeS2CPacket.PUFFERFISH_STING, 0.0F));
|
||||
((ServerPlayer) player).connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.PUFFER_FISH_STING, 0.0F));
|
||||
}
|
||||
if (random.nextBoolean()) {
|
||||
player.addMobEffect(new MobEffectInstance(MobEffects.POISON, 20, 0));
|
||||
player.addEffect(new MobEffectInstance(MobEffects.POISON, 20, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -149,30 +145,30 @@ public class CubozoaEntity extends SchoolingFishEntity {
|
|||
}
|
||||
|
||||
public void tick() {
|
||||
if (this.entity.isSubmergedIn(FluidTags.WATER)) {
|
||||
this.entity.setVelocity(this.entity.getVelocity().add(0.0D, 0.005D, 0.0D));
|
||||
if (this.mob.isEyeInFluid(FluidTags.WATER)) {
|
||||
this.mob.setDeltaMovement(this.mob.getDeltaMovement().add(0.0D, 0.005D, 0.0D));
|
||||
}
|
||||
|
||||
if (this.state == MoveControl.State.MOVE_TO && !this.entity.getNavigation().isIdle()) {
|
||||
float f = (float) (this.speed * this.entity.getAttributeValue(Attributes.MOVEMENT_SPEED));
|
||||
this.entity.setMovementSpeed(Mth.lerp(0.125F, this.entity.getMovementSpeed(), f));
|
||||
double d = this.targetX - this.entity.getX();
|
||||
double e = this.targetY - this.entity.getY();
|
||||
double g = this.targetZ - this.entity.getZ();
|
||||
if (this.operation == MoveControl.Operation.MOVE_TO && !this.mob.getNavigation().isDone()) {
|
||||
float f = (float) (this.speedModifier * this.mob.getAttributeValue(Attributes.MOVEMENT_SPEED));
|
||||
this.mob.setSpeed(Mth.lerp(0.125F, this.mob.getSpeed(), f));
|
||||
double d = this.wantedX - this.mob.getX();
|
||||
double e = this.wantedY - this.mob.getY();
|
||||
double g = this.wantedZ - this.mob.getZ();
|
||||
if (e != 0.0D) {
|
||||
double h = (double) Mth.sqrt(d * d + e * e + g * g);
|
||||
this.entity.setVelocity(this.entity.getVelocity().add(0.0D,
|
||||
(double) this.entity.getMovementSpeed() * (e / h) * 0.1D, 0.0D));
|
||||
this.mob.setDeltaMovement(this.mob.getDeltaMovement().add(0.0D, (double) this.mob.getSpeed() * (e / h) * 0.1D, 0.0D));
|
||||
}
|
||||
|
||||
if (d != 0.0D || g != 0.0D) {
|
||||
float i = (float) (Mth.atan2(g, d) * 57.2957763671875D) - 90.0F;
|
||||
this.entity.yaw = this.changeAngle(this.entity.yaw, i, 90.0F);
|
||||
this.entity.bodyYaw = this.entity.yaw;
|
||||
this.mob.yRot = this.rotlerp(this.mob.yRot, i, 90.0F);
|
||||
this.mob.yBodyRot = this.mob.yRot;
|
||||
}
|
||||
|
||||
} else {
|
||||
this.entity.setMovementSpeed(0.0F);
|
||||
}
|
||||
else {
|
||||
this.mob.setSpeed(0.0F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,36 +2,35 @@ package ru.betterend.entity;
|
|||
|
||||
import java.util.EnumSet;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.Flutterer;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.SpawnReason;
|
||||
import net.minecraft.world.entity.ai.TargetFinder;
|
||||
import net.minecraft.world.entity.ai.control.FlightMoveControl;
|
||||
import net.minecraft.world.entity.ai.control.LookControl;
|
||||
import net.minecraft.world.entity.ai.goal.AnimalMateGoal;
|
||||
import net.minecraft.world.entity.ai.goal.FollowParentGoal;
|
||||
import net.minecraft.world.entity.ai.goal.Goal;
|
||||
import net.minecraft.world.entity.ai.goal.SwimGoal;
|
||||
import net.minecraft.world.entity.ai.pathing.BirdNavigation;
|
||||
import net.minecraft.world.entity.ai.pathing.EntityNavigation;
|
||||
import net.minecraft.world.entity.ai.pathing.Path;
|
||||
import net.minecraft.world.entity.ai.pathing.PathNodeType;
|
||||
import net.minecraft.world.entity.attribute.DefaultAttributeContainer;
|
||||
import net.minecraft.world.entity.attribute.Attributes;
|
||||
import net.minecraft.world.entity.mob.MobEntity;
|
||||
import net.minecraft.world.entity.passive.AnimalEntity;
|
||||
import net.minecraft.world.entity.passive.PassiveEntity;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.Heightmap.Type;
|
||||
import net.minecraft.world.level.ServerLevelAccessor;
|
||||
import net.minecraft.world.entity.AgableMob;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.Mob;
|
||||
import net.minecraft.world.entity.MobSpawnType;
|
||||
import net.minecraft.world.entity.ai.attributes.AttributeSupplier;
|
||||
import net.minecraft.world.entity.ai.attributes.Attributes;
|
||||
import net.minecraft.world.entity.ai.control.FlyingMoveControl;
|
||||
import net.minecraft.world.entity.ai.control.LookControl;
|
||||
import net.minecraft.world.entity.ai.goal.BreedGoal;
|
||||
import net.minecraft.world.entity.ai.goal.FloatGoal;
|
||||
import net.minecraft.world.entity.ai.goal.FollowParentGoal;
|
||||
import net.minecraft.world.entity.ai.goal.Goal;
|
||||
import net.minecraft.world.entity.ai.navigation.FlyingPathNavigation;
|
||||
import net.minecraft.world.entity.ai.navigation.PathNavigation;
|
||||
import net.minecraft.world.entity.ai.util.RandomPos;
|
||||
import net.minecraft.world.entity.animal.Animal;
|
||||
import net.minecraft.world.entity.animal.FlyingAnimal;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.WorldView;
|
||||
import net.minecraft.world.level.LevelReader;
|
||||
import net.minecraft.world.level.ServerLevelAccessor;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.levelgen.Heightmap.Types;
|
||||
import net.minecraft.world.level.pathfinder.BlockPathTypes;
|
||||
import net.minecraft.world.level.pathfinder.Path;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import ru.betterend.entity.DragonflyEntity.DragonflyLookControl;
|
||||
import ru.betterend.entity.DragonflyEntity.WanderAroundGoal;
|
||||
import ru.betterend.registry.EndEntities;
|
||||
|
@ -39,51 +38,53 @@ import ru.betterend.registry.EndSounds;
|
|||
import ru.betterend.util.BlocksHelper;
|
||||
import ru.betterend.util.MHelper;
|
||||
|
||||
public class DragonflyEntity extends AnimalEntity implements Flutterer {
|
||||
public class DragonflyEntity extends Animal implements FlyingAnimal {
|
||||
public DragonflyEntity(EntityType<DragonflyEntity> entityType, Level world) {
|
||||
super(entityType, world);
|
||||
this.moveControl = new FlightMoveControl(this, 20, true);
|
||||
this.moveControl = new FlyingMoveControl(this, 20, true);
|
||||
this.lookControl = new DragonflyLookControl(this);
|
||||
this.setPathfindingPenalty(PathNodeType.WATER, -1.0F);
|
||||
this.setPathfindingPenalty(PathNodeType.DANGER_FIRE, -1.0F);
|
||||
this.experiencePoints = 1;
|
||||
this.setPathfindingMalus(BlockPathTypes.WATER, -1.0F);
|
||||
this.setPathfindingMalus(BlockPathTypes.DANGER_FIRE, -1.0F);
|
||||
this.xpReward = 1;
|
||||
}
|
||||
|
||||
public static DefaultAttributeContainer.Builder createMobAttributes() {
|
||||
return LivingEntity.createLivingAttributes().add(Attributes.MAX_HEALTH, 8.0D)
|
||||
.add(Attributes.FOLLOW_RANGE, 16.0D).add(Attributes.FLYING_SPEED, 1.0D)
|
||||
public static AttributeSupplier.Builder createMobAttributes() {
|
||||
return LivingEntity.createLivingAttributes()
|
||||
.add(Attributes.MAX_HEALTH, 8.0D)
|
||||
.add(Attributes.FOLLOW_RANGE, 16.0D)
|
||||
.add(Attributes.FLYING_SPEED, 1.0D)
|
||||
.add(Attributes.MOVEMENT_SPEED, 0.1D);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected EntityNavigation createNavigation(Level world) {
|
||||
BirdNavigation birdNavigation = new BirdNavigation(this, world) {
|
||||
public boolean isValidPosition(BlockPos pos) {
|
||||
BlockState state = this.world.getBlockState(pos);
|
||||
return state.isAir() || !state.getMaterial().blocksMovement();
|
||||
protected PathNavigation createNavigation(Level world) {
|
||||
FlyingPathNavigation birdNavigation = new FlyingPathNavigation(this, world) {
|
||||
public boolean isStableDestination(BlockPos pos) {
|
||||
BlockState state = this.level.getBlockState(pos);
|
||||
return state.isAir() || !state.getMaterial().blocksMotion();
|
||||
}
|
||||
|
||||
public void tick() {
|
||||
super.tick();
|
||||
}
|
||||
};
|
||||
birdNavigation.setCanPathThroughDoors(false);
|
||||
birdNavigation.setCanSwim(false);
|
||||
birdNavigation.setCanEnterOpenDoors(true);
|
||||
birdNavigation.setCanOpenDoors(false);
|
||||
birdNavigation.setCanFloat(false);
|
||||
birdNavigation.setCanPassDoors(true);
|
||||
return birdNavigation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getPathfindingFavor(BlockPos pos, WorldView world) {
|
||||
public float getWalkTargetValue(BlockPos pos, LevelReader world) {
|
||||
return world.getBlockState(pos).isAir() ? 10.0F : 0.0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initGoals() {
|
||||
this.goalSelector.add(1, new SwimGoal(this));
|
||||
this.goalSelector.add(2, new AnimalMateGoal(this, 1.0D));
|
||||
this.goalSelector.add(3, new FollowParentGoal(this, 1.0D));
|
||||
this.goalSelector.add(4, new WanderAroundGoal());
|
||||
protected void registerGoals() {
|
||||
this.goalSelector.addGoal(1, new FloatGoal(this));
|
||||
this.goalSelector.addGoal(2, new BreedGoal(this, 1.0D));
|
||||
this.goalSelector.addGoal(3, new FollowParentGoal(this, 1.0D));
|
||||
this.goalSelector.addGoal(4, new WanderAroundGoal());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -92,22 +93,22 @@ public class DragonflyEntity extends AnimalEntity implements Flutterer {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected boolean hasWings() {
|
||||
protected boolean makeFlySound() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleFallDamage(float fallDistance, float damageMultiplier) {
|
||||
public boolean causeFallDamage(float fallDistance, float damageMultiplier) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canClimb() {
|
||||
public boolean isMovementNoisy() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNoGravity() {
|
||||
public boolean isNoGravity() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -122,79 +123,78 @@ public class DragonflyEntity extends AnimalEntity implements Flutterer {
|
|||
}
|
||||
|
||||
class DragonflyLookControl extends LookControl {
|
||||
DragonflyLookControl(MobEntity entity) {
|
||||
DragonflyLookControl(Mob entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
protected boolean shouldStayHorizontal() {
|
||||
protected boolean resetXRotOnTick() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
class WanderAroundGoal extends Goal {
|
||||
WanderAroundGoal() {
|
||||
this.setControls(EnumSet.of(Goal.Control.MOVE));
|
||||
this.setFlags(EnumSet.of(Goal.Flag.MOVE));
|
||||
}
|
||||
|
||||
public boolean canStart() {
|
||||
return DragonflyEntity.this.navigation.isIdle() && DragonflyEntity.this.random.nextInt(10) == 0;
|
||||
public boolean canUse() {
|
||||
return DragonflyEntity.this.navigation.isDone() && DragonflyEntity.this.random.nextInt(10) == 0;
|
||||
}
|
||||
|
||||
public boolean shouldContinue() {
|
||||
return DragonflyEntity.this.navigation.isFollowingPath();
|
||||
public boolean canContinueToUse() {
|
||||
return DragonflyEntity.this.navigation.isInProgress();
|
||||
}
|
||||
|
||||
public void start() {
|
||||
Vec3d vec3d = this.getRandomLocation();
|
||||
Vec3 vec3d = this.getRandomLocation();
|
||||
if (vec3d != null) {
|
||||
BlockPos pos = new BlockPos(vec3d);
|
||||
try {
|
||||
Path path = DragonflyEntity.this.navigation.findPathTo(pos, 1);
|
||||
Path path = DragonflyEntity.this.navigation.createPath(pos, 1);
|
||||
if (path != null) {
|
||||
DragonflyEntity.this.navigation.startMovingAlong(path, 1.0D);
|
||||
DragonflyEntity.this.navigation.moveTo(path, 1.0D);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
catch (Exception e) {}
|
||||
}
|
||||
super.start();
|
||||
}
|
||||
|
||||
private Vec3d getRandomLocation() {
|
||||
int h = BlocksHelper.downRay(DragonflyEntity.this.world, DragonflyEntity.this.getBlockPos(), 16);
|
||||
Vec3d rotation = DragonflyEntity.this.getRotationVec(0.0F);
|
||||
Vec3d airPos = TargetFinder.findAirTarget(DragonflyEntity.this, 8, 7, rotation, 1.5707964F, 2, 1);
|
||||
private Vec3 getRandomLocation() {
|
||||
int h = BlocksHelper.downRay(DragonflyEntity.this.level, DragonflyEntity.this.blockPosition(), 16);
|
||||
Vec3 rotation = DragonflyEntity.this.getViewVector(0.0F);
|
||||
Vec3 airPos = RandomPos.getAboveLandPos(DragonflyEntity.this, 8, 7, rotation, 1.5707964F, 2, 1);
|
||||
if (airPos != null) {
|
||||
if (isInVoid(airPos)) {
|
||||
for (int i = 0; i < 8; i++) {
|
||||
airPos = TargetFinder.findAirTarget(DragonflyEntity.this, 16, 7, rotation, MHelper.PI2, 2, 1);
|
||||
airPos = RandomPos.getAboveLandPos(DragonflyEntity.this, 16, 7, rotation, MHelper.PI2, 2, 1);
|
||||
if (airPos != null && !isInVoid(airPos)) {
|
||||
return airPos;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
if (h > 5 && airPos.getY() >= DragonflyEntity.this.getBlockPos().getY()) {
|
||||
airPos = new Vec3d(airPos.x, airPos.y - h * 0.5, airPos.z);
|
||||
if (h > 5 && airPos.y() >= DragonflyEntity.this.blockPosition().getY()) {
|
||||
airPos = new Vec3(airPos.x, airPos.y - h * 0.5, airPos.z);
|
||||
}
|
||||
return airPos;
|
||||
}
|
||||
return TargetFinder.findGroundTarget(DragonflyEntity.this, 8, 4, -2, rotation, 1.5707963705062866D);
|
||||
return RandomPos.getAirPos(DragonflyEntity.this, 8, 4, -2, rotation, 1.5707963705062866D);
|
||||
}
|
||||
|
||||
private boolean isInVoid(Vec3d pos) {
|
||||
int h = BlocksHelper.downRay(DragonflyEntity.this.world, new BlockPos(pos), 128);
|
||||
private boolean isInVoid(Vec3 pos) {
|
||||
int h = BlocksHelper.downRay(DragonflyEntity.this.level, new BlockPos(pos), 128);
|
||||
return h > 100;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PassiveEntity createChild(ServerLevel world, PassiveEntity entity) {
|
||||
public AgableMob getBreedOffspring(ServerLevel world, AgableMob entity) {
|
||||
return EndEntities.DRAGONFLY.create(world);
|
||||
}
|
||||
|
||||
public static boolean canSpawn(EntityType<DragonflyEntity> type, ServerLevelAccessor world, SpawnReason spawnReason,
|
||||
BlockPos pos, Random random) {
|
||||
int y = world.getChunk(pos).sampleHeightmap(Type.WORLD_SURFACE, pos.getX() & 15, pos.getY() & 15);
|
||||
|
||||
public static boolean canSpawn(EntityType<DragonflyEntity> type, ServerLevelAccessor world, MobSpawnType spawnReason, BlockPos pos, Random random) {
|
||||
int y = world.getChunk(pos).getHeight(Types.WORLD_SURFACE, pos.getX() & 15, pos.getY() & 15);
|
||||
return y > 0 && pos.getY() >= y;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,143 +2,138 @@ package ru.betterend.entity;
|
|||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.entity.EntityData;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.ItemEntity;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.SpawnReason;
|
||||
import net.minecraft.world.entity.attribute.DefaultAttributeContainer;
|
||||
import net.minecraft.world.entity.attribute.Attributes;
|
||||
import net.minecraft.world.entity.damage.DamageSource;
|
||||
import net.minecraft.world.entity.data.DataTracker;
|
||||
import net.minecraft.world.entity.data.TrackedData;
|
||||
import net.minecraft.world.entity.data.TrackedDataHandlerRegistry;
|
||||
import net.minecraft.world.entity.passive.SchoolingFishEntity;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.particles.ParticleTypes;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.syncher.EntityDataAccessor;
|
||||
import net.minecraft.network.syncher.EntityDataSerializers;
|
||||
import net.minecraft.network.syncher.SynchedEntityData;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.LocalDifficulty;
|
||||
import net.minecraft.world.level.ServerLevelAccessor;
|
||||
import net.minecraft.world.DifficultyInstance;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.MobSpawnType;
|
||||
import net.minecraft.world.entity.SpawnGroupData;
|
||||
import net.minecraft.world.entity.ai.attributes.AttributeSupplier;
|
||||
import net.minecraft.world.entity.ai.attributes.Attributes;
|
||||
import net.minecraft.world.entity.animal.AbstractSchoolingFish;
|
||||
import net.minecraft.world.entity.item.ItemEntity;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.ServerLevelAccessor;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import ru.betterend.registry.EndBiomes;
|
||||
import ru.betterend.registry.EndItems;
|
||||
|
||||
public class EndFishEntity extends SchoolingFishEntity {
|
||||
public class EndFishEntity extends AbstractSchoolingFish {
|
||||
public static final int VARIANTS_NORMAL = 5;
|
||||
public static final int VARIANTS_SULPHUR = 3;
|
||||
public static final int VARIANTS = VARIANTS_NORMAL + VARIANTS_SULPHUR;
|
||||
private static final TrackedData<Byte> VARIANT = DataTracker.registerData(EndFishEntity.class,
|
||||
TrackedDataHandlerRegistry.BYTE);
|
||||
private static final TrackedData<Byte> SCALE = DataTracker.registerData(EndFishEntity.class,
|
||||
TrackedDataHandlerRegistry.BYTE);
|
||||
|
||||
private static final EntityDataAccessor<Byte> VARIANT = SynchedEntityData.defineId(EndFishEntity.class, EntityDataSerializers.BYTE);
|
||||
private static final EntityDataAccessor<Byte> SCALE = SynchedEntityData.defineId(EndFishEntity.class, EntityDataSerializers.BYTE);
|
||||
|
||||
public EndFishEntity(EntityType<EndFishEntity> entityType, Level world) {
|
||||
super(entityType, world);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public EntityData initialize(ServerLevelAccessor world, LocalDifficulty difficulty, SpawnReason spawnReason,
|
||||
EntityData entityData, CompoundTag entityTag) {
|
||||
EntityData data = super.initialize(world, difficulty, spawnReason, entityData, entityTag);
|
||||
if (EndBiomes.getFromBiome(world.getBiome(getBlockPos())) == EndBiomes.SULPHUR_SPRINGS) {
|
||||
this.dataTracker.set(VARIANT, (byte) (random.nextInt(VARIANTS_SULPHUR) + VARIANTS_NORMAL));
|
||||
public SpawnGroupData finalizeSpawn(ServerLevelAccessor world, DifficultyInstance difficulty, MobSpawnType spawnReason, SpawnGroupData entityData, CompoundTag entityTag) {
|
||||
SpawnGroupData data = super.finalizeSpawn(world, difficulty, spawnReason, entityData, entityTag);
|
||||
if (EndBiomes.getFromBiome(world.getBiome(blockPosition())) == EndBiomes.SULPHUR_SPRINGS) {
|
||||
this.entityData.set(VARIANT, (byte) (random.nextInt(VARIANTS_SULPHUR) + VARIANTS_NORMAL));
|
||||
}
|
||||
this.calculateDimensions();
|
||||
this.refreshDimensions();
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void initDataTracker() {
|
||||
super.initDataTracker();
|
||||
this.dataTracker.startTracking(VARIANT, (byte) this.getRandom().nextInt(VARIANTS_NORMAL));
|
||||
this.dataTracker.startTracking(SCALE, (byte) this.getRandom().nextInt(16));
|
||||
protected void defineSynchedData() {
|
||||
super.defineSynchedData();
|
||||
this.entityData.define(VARIANT, (byte) this.getRandom().nextInt(VARIANTS_NORMAL));
|
||||
this.entityData.define(SCALE, (byte) this.getRandom().nextInt(16));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void writeCustomDataToTag(CompoundTag tag) {
|
||||
super.writeCustomDataToTag(tag);
|
||||
public void addAdditionalSaveData(CompoundTag tag) {
|
||||
super.addAdditionalSaveData(tag);
|
||||
tag.putByte("Variant", (byte) getVariant());
|
||||
tag.putByte("Scale", (byte) getScale());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readCustomDataFromTag(CompoundTag tag) {
|
||||
super.readCustomDataFromTag(tag);
|
||||
public void readAdditionalSaveData(CompoundTag tag) {
|
||||
super.readAdditionalSaveData(tag);
|
||||
if (tag.contains("Variant")) {
|
||||
this.dataTracker.set(VARIANT, tag.getByte("Variant"));
|
||||
this.entityData.set(VARIANT, tag.getByte("Variant"));
|
||||
}
|
||||
if (tag.contains("Scale")) {
|
||||
this.dataTracker.set(SCALE, tag.getByte("Scale"));
|
||||
this.entityData.set(SCALE, tag.getByte("Scale"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ItemStack getFishBucketItem() {
|
||||
protected ItemStack getBucketItemStack() {
|
||||
return new ItemStack(EndItems.BUCKET_END_FISH);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEvent getFlopSound() {
|
||||
return SoundEvents.ENTITY_TROPICAL_FISH_FLOP;
|
||||
return SoundEvents.TROPICAL_FISH_FLOP;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEvent getAmbientSound() {
|
||||
return SoundEvents.ENTITY_SALMON_AMBIENT;
|
||||
return SoundEvents.SALMON_AMBIENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEvent getDeathSound() {
|
||||
return SoundEvents.ENTITY_SALMON_DEATH;
|
||||
return SoundEvents.SALMON_DEATH;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEvent getHurtSound(DamageSource source) {
|
||||
return SoundEvents.ENTITY_SALMON_HURT;
|
||||
return SoundEvents.SALMON_HURT;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
super.tick();
|
||||
if (random.nextInt(8) == 0 && getBlockState().is(Blocks.WATER)) {
|
||||
if (random.nextInt(8) == 0 && getFeetBlockState().is(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);
|
||||
level.addParticle(ParticleTypes.BUBBLE, x, y, z, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
public static DefaultAttributeContainer.Builder createMobAttributes() {
|
||||
return LivingEntity.createLivingAttributes().add(Attributes.MAX_HEALTH, 2.0).add(Attributes.FOLLOW_RANGE, 16.0)
|
||||
|
||||
public static AttributeSupplier.Builder createMobAttributes() {
|
||||
return LivingEntity.createLivingAttributes()
|
||||
.add(Attributes.MAX_HEALTH, 2.0)
|
||||
.add(Attributes.FOLLOW_RANGE, 16.0)
|
||||
.add(Attributes.MOVEMENT_SPEED, 0.75);
|
||||
}
|
||||
|
||||
|
||||
public int getVariant() {
|
||||
return (int) this.dataTracker.get(VARIANT);
|
||||
return (int) this.entityData.get(VARIANT);
|
||||
}
|
||||
|
||||
|
||||
public float getScale() {
|
||||
return this.dataTracker.get(SCALE) / 32F + 0.75F;
|
||||
return this.entityData.get(SCALE) / 32F + 0.75F;
|
||||
}
|
||||
|
||||
public static boolean canSpawn(EntityType<EndFishEntity> type, ServerLevelAccessor world, SpawnReason spawnReason,
|
||||
BlockPos pos, Random random) {
|
||||
Box box = new Box(pos).expand(16);
|
||||
List<EndFishEntity> list = world.getEntitiesByClass(EndFishEntity.class, box, (entity) -> {
|
||||
return true;
|
||||
});
|
||||
|
||||
public static boolean canSpawn(EntityType<EndFishEntity> type, ServerLevelAccessor world, MobSpawnType spawnReason, BlockPos pos, Random random) {
|
||||
AABB box = new AABB(pos).inflate(16);
|
||||
List<EndFishEntity> list = world.getEntitiesOfClass(EndFishEntity.class, box, (entity) -> { return true; });
|
||||
return list.size() < 9;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void dropLoot(DamageSource source, boolean causedByPlayer) {
|
||||
ItemEntity drop = new ItemEntity(world, getX(), getY(), getZ(), new ItemStack(EndItems.END_FISH_RAW));
|
||||
this.world.spawnEntity(drop);
|
||||
protected void dropFromLootTable(DamageSource source, boolean causedByPlayer) {
|
||||
ItemEntity drop = new ItemEntity(level, getX(), getY(), getZ(), new ItemStack(EndItems.END_FISH_RAW));
|
||||
this.level.addFreshEntity(drop);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,41 +3,40 @@ package ru.betterend.entity;
|
|||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.item.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.world.entity.EntityData;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.ItemEntity;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.SpawnReason;
|
||||
import net.minecraft.world.entity.ai.control.MoveControl;
|
||||
import net.minecraft.world.entity.ai.goal.FollowTargetGoal;
|
||||
import net.minecraft.world.entity.ai.goal.Goal;
|
||||
import net.minecraft.world.entity.attribute.DefaultAttributeContainer;
|
||||
import net.minecraft.world.entity.attribute.Attributes;
|
||||
import net.minecraft.world.entity.damage.DamageSource;
|
||||
import net.minecraft.world.entity.data.DataTracker;
|
||||
import net.minecraft.world.entity.data.TrackedData;
|
||||
import net.minecraft.world.entity.data.TrackedDataHandlerRegistry;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.BlockPos.MutableBlockPos;
|
||||
import net.minecraft.core.particles.ParticleOptions;
|
||||
import net.minecraft.core.particles.ParticleTypes;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.syncher.EntityDataAccessor;
|
||||
import net.minecraft.network.syncher.EntityDataSerializers;
|
||||
import net.minecraft.network.syncher.SynchedEntityData;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.DifficultyInstance;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.effect.MobEffects;
|
||||
import net.minecraft.world.entity.mob.SlimeEntity;
|
||||
import net.minecraft.world.entity.passive.IronGolemEntity;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.MobSpawnType;
|
||||
import net.minecraft.world.entity.SpawnGroupData;
|
||||
import net.minecraft.world.entity.ai.attributes.AttributeSupplier;
|
||||
import net.minecraft.world.entity.ai.attributes.Attributes;
|
||||
import net.minecraft.world.entity.ai.control.MoveControl;
|
||||
import net.minecraft.world.entity.ai.goal.Goal;
|
||||
import net.minecraft.world.entity.ai.goal.target.NearestAttackableTargetGoal;
|
||||
import net.minecraft.world.entity.animal.IronGolem;
|
||||
import net.minecraft.world.entity.item.ItemEntity;
|
||||
import net.minecraft.world.entity.monster.Slime;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.core.particles.ParticleOptions;
|
||||
import net.minecraft.core.particles.ParticleTypes;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.BlockPos.MutableBlockPos;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.LocalDifficulty;
|
||||
import net.minecraft.world.level.ServerLevelAccessor;
|
||||
import net.minecraft.world.item.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.ServerLevelAccessor;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import ru.betterend.entity.EndSlimeEntity.EndSlimeMoveControl;
|
||||
import ru.betterend.entity.EndSlimeEntity.FaceTowardTargetGoal;
|
||||
import ru.betterend.entity.EndSlimeEntity.MoveGoal;
|
||||
|
@ -49,131 +48,132 @@ import ru.betterend.util.BlocksHelper;
|
|||
import ru.betterend.util.MHelper;
|
||||
import ru.betterend.world.biome.EndBiome;
|
||||
|
||||
public class EndSlimeEntity extends SlimeEntity {
|
||||
private static final TrackedData<Byte> VARIANT = DataTracker.registerData(EndSlimeEntity.class,
|
||||
TrackedDataHandlerRegistry.BYTE);
|
||||
public class EndSlimeEntity extends Slime {
|
||||
private static final EntityDataAccessor<Byte> VARIANT = SynchedEntityData.defineId(EndSlimeEntity.class, EntityDataSerializers.BYTE);
|
||||
private static final MutableBlockPos POS = new MutableBlockPos();
|
||||
|
||||
|
||||
public EndSlimeEntity(EntityType<EndSlimeEntity> entityType, Level world) {
|
||||
super(entityType, world);
|
||||
this.moveControl = new EndSlimeMoveControl(this);
|
||||
}
|
||||
|
||||
protected void initGoals() {
|
||||
this.goalSelector.add(1, new SwimmingGoal());
|
||||
this.goalSelector.add(2, new FaceTowardTargetGoal());
|
||||
this.goalSelector.add(3, new RandomLookGoal());
|
||||
this.goalSelector.add(5, new MoveGoal());
|
||||
this.targetSelector.add(1, new FollowTargetGoal<Player>(this, Player.class, 10, true, false, (livingEntity) -> {
|
||||
|
||||
protected void registerGoals() {
|
||||
this.goalSelector.addGoal(1, new SwimmingGoal());
|
||||
this.goalSelector.addGoal(2, new FaceTowardTargetGoal());
|
||||
this.goalSelector.addGoal(3, new RandomLookGoal());
|
||||
this.goalSelector.addGoal(5, new MoveGoal());
|
||||
this.targetSelector.addGoal(1, new NearestAttackableTargetGoal<Player>(this, Player.class, 10, true, false, (livingEntity) -> {
|
||||
return Math.abs(livingEntity.getY() - this.getY()) <= 4.0D;
|
||||
}));
|
||||
this.targetSelector.add(3, new FollowTargetGoal<IronGolemEntity>(this, IronGolemEntity.class, true));
|
||||
this.targetSelector.addGoal(3, new NearestAttackableTargetGoal<IronGolem>(this, IronGolem.class, true));
|
||||
}
|
||||
|
||||
public static DefaultAttributeContainer.Builder createMobAttributes() {
|
||||
return LivingEntity.createLivingAttributes().add(Attributes.MAX_HEALTH, 1.0D)
|
||||
.add(Attributes.ATTACK_DAMAGE, 1.0D).add(Attributes.FOLLOW_RANGE, 16.0D)
|
||||
|
||||
public static AttributeSupplier.Builder createMobAttributes() {
|
||||
return LivingEntity.createLivingAttributes()
|
||||
.add(Attributes.MAX_HEALTH, 1.0D)
|
||||
.add(Attributes.ATTACK_DAMAGE, 1.0D)
|
||||
.add(Attributes.FOLLOW_RANGE, 16.0D)
|
||||
.add(Attributes.MOVEMENT_SPEED, 0.15D);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public EntityData initialize(ServerLevelAccessor world, LocalDifficulty difficulty, SpawnReason spawnReason,
|
||||
EntityData entityData, CompoundTag entityTag) {
|
||||
EntityData data = super.initialize(world, difficulty, spawnReason, entityData, entityTag);
|
||||
EndBiome biome = EndBiomes.getFromBiome(world.getBiome(getBlockPos()));
|
||||
public SpawnGroupData finalizeSpawn(ServerLevelAccessor world, DifficultyInstance difficulty, MobSpawnType spawnReason, SpawnGroupData entityData, CompoundTag entityTag) {
|
||||
SpawnGroupData data = super.finalizeSpawn(world, difficulty, spawnReason, entityData, entityTag);
|
||||
EndBiome biome = EndBiomes.getFromBiome(world.getBiome(blockPosition()));
|
||||
if (biome == EndBiomes.FOGGY_MUSHROOMLAND) {
|
||||
this.setMossy();
|
||||
} else if (biome == EndBiomes.MEGALAKE || biome == EndBiomes.MEGALAKE_GROVE) {
|
||||
}
|
||||
else if (biome == EndBiomes.MEGALAKE || biome == EndBiomes.MEGALAKE_GROVE) {
|
||||
this.setLake();
|
||||
} else if (biome == EndBiomes.AMBER_LAND) {
|
||||
}
|
||||
else if (biome == EndBiomes.AMBER_LAND) {
|
||||
this.setAmber(true);
|
||||
}
|
||||
this.calculateDimensions();
|
||||
this.refreshDimensions();
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initDataTracker() {
|
||||
super.initDataTracker();
|
||||
this.dataTracker.startTracking(VARIANT, (byte) 0);
|
||||
protected void defineSynchedData() {
|
||||
super.defineSynchedData();
|
||||
this.entityData.define(VARIANT, (byte) 0);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void writeCustomDataToTag(CompoundTag tag) {
|
||||
super.writeCustomDataToTag(tag);
|
||||
public void addAdditionalSaveData(CompoundTag tag) {
|
||||
super.addAdditionalSaveData(tag);
|
||||
tag.putByte("Variant", (byte) getSlimeType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readCustomDataFromTag(CompoundTag tag) {
|
||||
super.readCustomDataFromTag(tag);
|
||||
public void readAdditionalSaveData(CompoundTag tag) {
|
||||
super.readAdditionalSaveData(tag);
|
||||
if (tag.contains("Variant")) {
|
||||
this.dataTracker.set(VARIANT, tag.getByte("Variant"));
|
||||
this.entityData.set(VARIANT, tag.getByte("Variant"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ParticleOptions getParticles() {
|
||||
protected ParticleOptions getParticleType() {
|
||||
return ParticleTypes.PORTAL;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
int i = this.getSize();
|
||||
if (!this.world.isClientSide && i > 1 && this.isDead()) {
|
||||
Text text = this.getCustomName();
|
||||
boolean bl = this.isAiDisabled();
|
||||
if (!this.level.isClientSide && i > 1 && this.isDeadOrDying()) {
|
||||
Component text = this.getCustomName();
|
||||
boolean bl = this.isNoAi();
|
||||
float f = (float) i / 4.0F;
|
||||
int j = i / 2;
|
||||
int k = 2 + this.random.nextInt(3);
|
||||
int type = this.getSlimeType();
|
||||
|
||||
|
||||
for (int l = 0; l < k; ++l) {
|
||||
float g = ((float) (l % 2) - 0.5F) * f;
|
||||
float h = ((float) (l / 2) - 0.5F) * f;
|
||||
EndSlimeEntity slimeEntity = (EndSlimeEntity) this.getType().create(this.world);
|
||||
if (this.isPersistent()) {
|
||||
slimeEntity.setPersistent();
|
||||
EndSlimeEntity slimeEntity = (EndSlimeEntity) this.getType().create(this.level);
|
||||
if (this.isPersistenceRequired()) {
|
||||
slimeEntity.setPersistenceRequired();
|
||||
}
|
||||
|
||||
slimeEntity.setSlimeType(type);
|
||||
slimeEntity.setCustomName(text);
|
||||
slimeEntity.setAiDisabled(bl);
|
||||
slimeEntity.setNoAi(bl);
|
||||
slimeEntity.setInvulnerable(this.isInvulnerable());
|
||||
((ISlime) slimeEntity).beSetSlimeSize(j, true);
|
||||
slimeEntity.calculateDimensions();
|
||||
slimeEntity.refreshPositionAndAngles(this.getX() + (double) g, this.getY() + 0.5D,
|
||||
this.getZ() + (double) h, this.random.nextFloat() * 360.0F, 0.0F);
|
||||
this.world.spawnEntity(slimeEntity);
|
||||
slimeEntity.refreshDimensions();
|
||||
slimeEntity.moveTo(this.getX() + (double) g, this.getY() + 0.5D, this.getZ() + (double) h, this.random.nextFloat() * 360.0F, 0.0F);
|
||||
this.level.addFreshEntity(slimeEntity);
|
||||
}
|
||||
}
|
||||
this.removed = true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void dropLoot(DamageSource source, boolean causedByPlayer) {
|
||||
protected void dropFromLootTable(DamageSource source, boolean causedByPlayer) {
|
||||
int maxCount = this.getSize();
|
||||
int minCount = maxCount >> 1;
|
||||
if (minCount < 1) {
|
||||
minCount = 1;
|
||||
}
|
||||
if (causedByPlayer && this.attackingPlayer != null) {
|
||||
int looting = EnchantmentHelper.getLooting(this.attackingPlayer);
|
||||
if (causedByPlayer && this.lastHurtByPlayer != null) {
|
||||
int looting = EnchantmentHelper.getMobLooting(this.lastHurtByPlayer);
|
||||
minCount += looting;
|
||||
}
|
||||
int count = minCount < maxCount ? MHelper.randRange(minCount, maxCount, random) : maxCount;
|
||||
ItemEntity drop = new ItemEntity(world, getX(), getY(), getZ(), new ItemStack(Items.SLIME_BALL, count));
|
||||
this.world.spawnEntity(drop);
|
||||
ItemEntity drop = new ItemEntity(level, getX(), getY(), getZ(), new ItemStack(Items.SLIME_BALL, count));
|
||||
this.level.addFreshEntity(drop);
|
||||
}
|
||||
|
||||
|
||||
public int getSlimeType() {
|
||||
return this.dataTracker.get(VARIANT).intValue();
|
||||
return this.entityData.get(VARIANT).intValue();
|
||||
}
|
||||
|
||||
|
||||
public void setSlimeType(int value) {
|
||||
this.dataTracker.set(VARIANT, (byte) value);
|
||||
this.entityData.set(VARIANT, (byte) value);
|
||||
}
|
||||
|
||||
|
||||
protected void setMossy() {
|
||||
setSlimeType(1);
|
||||
}
|
||||
|
@ -181,7 +181,7 @@ public class EndSlimeEntity extends SlimeEntity {
|
|||
public boolean isMossy() {
|
||||
return getSlimeType() == 1;
|
||||
}
|
||||
|
||||
|
||||
protected void setLake() {
|
||||
setSlimeType(2);
|
||||
}
|
||||
|
@ -189,38 +189,34 @@ public class EndSlimeEntity extends SlimeEntity {
|
|||
public boolean isLake() {
|
||||
return getSlimeType() == 2;
|
||||
}
|
||||
|
||||
|
||||
protected void setAmber(boolean mossy) {
|
||||
this.dataTracker.set(VARIANT, (byte) 3);
|
||||
this.entityData.set(VARIANT, (byte) 3);
|
||||
}
|
||||
|
||||
public boolean isAmber() {
|
||||
return this.dataTracker.get(VARIANT) == 3;
|
||||
return this.entityData.get(VARIANT) == 3;
|
||||
}
|
||||
|
||||
|
||||
public boolean isChorus() {
|
||||
return this.dataTracker.get(VARIANT) == 0;
|
||||
return this.entityData.get(VARIANT) == 0;
|
||||
}
|
||||
|
||||
public static boolean canSpawn(EntityType<EndSlimeEntity> type, ServerLevelAccessor world, SpawnReason spawnReason,
|
||||
BlockPos pos, Random random) {
|
||||
return random.nextInt(16) == 0 || isPermanentBiome(world, pos)
|
||||
|| (notManyEntities(world, pos, 32, 3) && isWaterNear(world, pos, 32, 8));
|
||||
|
||||
public static boolean canSpawn(EntityType<EndSlimeEntity> type, ServerLevelAccessor world, MobSpawnType spawnReason, BlockPos pos, Random random) {
|
||||
return random.nextInt(16) == 0 || isPermanentBiome(world, pos) || (notManyEntities(world, pos, 32, 3) && isWaterNear(world, pos, 32, 8));
|
||||
}
|
||||
|
||||
|
||||
private static boolean isPermanentBiome(ServerLevelAccessor world, BlockPos pos) {
|
||||
Biome biome = world.getBiome(pos);
|
||||
return EndBiomes.getFromBiome(biome) == EndBiomes.CHORUS_FOREST;
|
||||
}
|
||||
|
||||
|
||||
private static boolean notManyEntities(ServerLevelAccessor world, BlockPos pos, int radius, int maxCount) {
|
||||
Box box = new Box(pos).expand(radius);
|
||||
List<EndSlimeEntity> list = world.getEntitiesByClass(EndSlimeEntity.class, box, (entity) -> {
|
||||
return true;
|
||||
});
|
||||
AABB box = new AABB(pos).inflate(radius);
|
||||
List<EndSlimeEntity> list = world.getEntitiesOfClass(EndSlimeEntity.class, box, (entity) -> { return true; });
|
||||
return list.size() <= maxCount;
|
||||
}
|
||||
|
||||
|
||||
private static boolean isWaterNear(ServerLevelAccessor world, BlockPos pos, int radius, int radius2) {
|
||||
for (int x = pos.getX() - radius; x <= pos.getX() + radius; x++) {
|
||||
POS.setX(x);
|
||||
|
@ -236,27 +232,27 @@ public class EndSlimeEntity extends SlimeEntity {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
class MoveGoal extends Goal {
|
||||
public MoveGoal() {
|
||||
this.setControls(EnumSet.of(Goal.Control.JUMP, Goal.Control.MOVE));
|
||||
this.setFlags(EnumSet.of(Goal.Flag.JUMP, Goal.Flag.MOVE));
|
||||
}
|
||||
|
||||
public boolean canStart() {
|
||||
if (EndSlimeEntity.this.hasVehicle()) {
|
||||
public boolean canUse() {
|
||||
if (EndSlimeEntity.this.isPassenger()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
float yaw = EndSlimeEntity.this.getHeadYaw();
|
||||
float speed = EndSlimeEntity.this.getMovementSpeed();
|
||||
|
||||
float yaw = EndSlimeEntity.this.getYHeadRot();
|
||||
float speed = EndSlimeEntity.this.getSpeed();
|
||||
if (speed > 0.1) {
|
||||
float dx = Mth.sin(-yaw * 0.017453292F);
|
||||
float dz = Mth.cos(-yaw * 0.017453292F);
|
||||
BlockPos pos = EndSlimeEntity.this.getBlockPos().add(dx * speed * 4, 0, dz * speed * 4);
|
||||
int down = BlocksHelper.downRay(EndSlimeEntity.this.world, pos, 16);
|
||||
BlockPos pos = EndSlimeEntity.this.blockPosition().offset(dx * speed * 4, 0, dz * speed * 4);
|
||||
int down = BlocksHelper.downRay(EndSlimeEntity.this.level, pos, 16);
|
||||
return down < 5;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -267,18 +263,19 @@ public class EndSlimeEntity extends SlimeEntity {
|
|||
|
||||
class SwimmingGoal extends Goal {
|
||||
public SwimmingGoal() {
|
||||
this.setControls(EnumSet.of(Goal.Control.JUMP, Goal.Control.MOVE));
|
||||
EndSlimeEntity.this.getNavigation().setCanSwim(true);
|
||||
this.setFlags(EnumSet.of(Goal.Flag.JUMP, Goal.Flag.MOVE));
|
||||
EndSlimeEntity.this.getNavigation().setCanFloat(true);
|
||||
}
|
||||
|
||||
public boolean canStart() {
|
||||
return (EndSlimeEntity.this.isTouchingWater() || EndSlimeEntity.this.isInLava())
|
||||
public boolean canUse() {
|
||||
return (EndSlimeEntity.this.isInWater()
|
||||
|| EndSlimeEntity.this.isInLava())
|
||||
&& EndSlimeEntity.this.getMoveControl() instanceof EndSlimeMoveControl;
|
||||
}
|
||||
|
||||
public void tick() {
|
||||
if (EndSlimeEntity.this.getRandom().nextFloat() < 0.8F) {
|
||||
EndSlimeEntity.this.getJumpControl().setActive();
|
||||
EndSlimeEntity.this.getJumpControl().jump();
|
||||
}
|
||||
|
||||
((EndSlimeMoveControl) EndSlimeEntity.this.getMoveControl()).move(1.2D);
|
||||
|
@ -290,14 +287,15 @@ public class EndSlimeEntity extends SlimeEntity {
|
|||
private int timer;
|
||||
|
||||
public RandomLookGoal() {
|
||||
this.setControls(EnumSet.of(Goal.Control.LOOK));
|
||||
this.setFlags(EnumSet.of(Goal.Flag.LOOK));
|
||||
}
|
||||
|
||||
public boolean canStart() {
|
||||
public boolean canUse() {
|
||||
return EndSlimeEntity.this.getTarget() == null
|
||||
&& (EndSlimeEntity.this.onGround || EndSlimeEntity.this.isTouchingWater()
|
||||
&& (EndSlimeEntity.this.onGround
|
||||
|| EndSlimeEntity.this.isInWater()
|
||||
|| EndSlimeEntity.this.isInLava()
|
||||
|| EndSlimeEntity.this.hasMobEffect(MobEffects.LEVITATION))
|
||||
|| EndSlimeEntity.this.hasEffect(MobEffects.LEVITATION))
|
||||
&& EndSlimeEntity.this.getMoveControl() instanceof EndSlimeMoveControl;
|
||||
}
|
||||
|
||||
|
@ -315,18 +313,19 @@ public class EndSlimeEntity extends SlimeEntity {
|
|||
private int ticksLeft;
|
||||
|
||||
public FaceTowardTargetGoal() {
|
||||
this.setControls(EnumSet.of(Goal.Control.LOOK));
|
||||
this.setFlags(EnumSet.of(Goal.Flag.LOOK));
|
||||
}
|
||||
|
||||
public boolean canStart() {
|
||||
public boolean canUse() {
|
||||
LivingEntity livingEntity = EndSlimeEntity.this.getTarget();
|
||||
if (livingEntity == null) {
|
||||
return false;
|
||||
} else if (!livingEntity.isAlive()) {
|
||||
}
|
||||
else if (!livingEntity.isAlive()) {
|
||||
return false;
|
||||
} else {
|
||||
return livingEntity instanceof Player && ((Player) livingEntity).abilities.invulnerable ? false
|
||||
: EndSlimeEntity.this.getMoveControl() instanceof EndSlimeMoveControl;
|
||||
}
|
||||
else {
|
||||
return livingEntity instanceof Player && ((Player) livingEntity).abilities.invulnerable ? false : EndSlimeEntity.this.getMoveControl() instanceof EndSlimeMoveControl;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -335,23 +334,25 @@ public class EndSlimeEntity extends SlimeEntity {
|
|||
super.start();
|
||||
}
|
||||
|
||||
public boolean shouldContinue() {
|
||||
public boolean canContinueToUse() {
|
||||
LivingEntity livingEntity = EndSlimeEntity.this.getTarget();
|
||||
if (livingEntity == null) {
|
||||
return false;
|
||||
} else if (!livingEntity.isAlive()) {
|
||||
}
|
||||
else if (!livingEntity.isAlive()) {
|
||||
return false;
|
||||
} else if (livingEntity instanceof Player && ((Player) livingEntity).abilities.invulnerable) {
|
||||
}
|
||||
else if (livingEntity instanceof Player && ((Player) livingEntity).abilities.invulnerable) {
|
||||
return false;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return --this.ticksLeft > 0;
|
||||
}
|
||||
}
|
||||
|
||||
public void tick() {
|
||||
EndSlimeEntity.this.lookAtEntity(EndSlimeEntity.this.getTarget(), 10.0F, 10.0F);
|
||||
((EndSlimeMoveControl) EndSlimeEntity.this.getMoveControl()).look(EndSlimeEntity.this.yaw,
|
||||
EndSlimeEntity.this.canAttack());
|
||||
EndSlimeEntity.this.lookAt(EndSlimeEntity.this.getTarget(), 10.0F, 10.0F);
|
||||
((EndSlimeMoveControl) EndSlimeEntity.this.getMoveControl()).look(EndSlimeEntity.this.yRot, EndSlimeEntity.this.isDealsDamage());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -362,7 +363,7 @@ public class EndSlimeEntity extends SlimeEntity {
|
|||
|
||||
public EndSlimeMoveControl(EndSlimeEntity slime) {
|
||||
super(slime);
|
||||
this.targetYaw = 180.0F * slime.yaw / 3.1415927F;
|
||||
this.targetYaw = 180.0F * slime.yRot / 3.1415927F;
|
||||
}
|
||||
|
||||
public void look(float targetYaw, boolean jumpOften) {
|
||||
|
@ -371,49 +372,48 @@ public class EndSlimeEntity extends SlimeEntity {
|
|||
}
|
||||
|
||||
public void move(double speed) {
|
||||
this.speed = speed;
|
||||
this.state = MoveControl.State.MOVE_TO;
|
||||
this.speedModifier = speed;
|
||||
this.operation = MoveControl.Operation.MOVE_TO;
|
||||
}
|
||||
|
||||
public void tick() {
|
||||
this.entity.yaw = this.changeAngle(this.entity.yaw, this.targetYaw, 90.0F);
|
||||
this.entity.headYaw = this.entity.yaw;
|
||||
this.entity.bodyYaw = this.entity.yaw;
|
||||
if (this.state != MoveControl.State.MOVE_TO) {
|
||||
this.entity.setForwardSpeed(0.0F);
|
||||
} else {
|
||||
this.state = MoveControl.State.WAIT;
|
||||
if (this.entity.isOnGround()) {
|
||||
this.entity.setMovementSpeed(
|
||||
(float) (this.speed * this.entity.getAttributeValue(Attributes.MOVEMENT_SPEED)));
|
||||
this.mob.yRot = this.rotlerp(this.mob.yRot, this.targetYaw, 90.0F);
|
||||
this.mob.yHeadRot = this.mob.yRot;
|
||||
this.mob.yBodyRot = this.mob.yRot;
|
||||
if (this.operation != MoveControl.Operation.MOVE_TO) {
|
||||
this.mob.setZza(0.0F);
|
||||
}
|
||||
else {
|
||||
this.operation = MoveControl.Operation.WAIT;
|
||||
if (this.mob.isOnGround()) {
|
||||
this.mob.setSpeed((float) (this.speedModifier * this.mob.getAttributeValue(Attributes.MOVEMENT_SPEED)));
|
||||
if (this.ticksUntilJump-- <= 0) {
|
||||
this.ticksUntilJump = EndSlimeEntity.this.getTicksUntilNextJump();
|
||||
this.ticksUntilJump = EndSlimeEntity.this.getJumpDelay();
|
||||
if (this.jumpOften) {
|
||||
this.ticksUntilJump /= 3;
|
||||
}
|
||||
|
||||
EndSlimeEntity.this.getJumpControl().setActive();
|
||||
if (EndSlimeEntity.this.makesJumpSound()) {
|
||||
EndSlimeEntity.this.playSound(EndSlimeEntity.this.getJumpSound(),
|
||||
EndSlimeEntity.this.getSoundVolume(), getJumpSoundPitch());
|
||||
EndSlimeEntity.this.getJumpControl().jump();
|
||||
if (EndSlimeEntity.this.doPlayJumpSound()) {
|
||||
EndSlimeEntity.this.playSound(EndSlimeEntity.this.getJumpSound(), EndSlimeEntity.this.getSoundVolume(), getJumpSoundPitch());
|
||||
}
|
||||
} else {
|
||||
EndSlimeEntity.this.sidewaysSpeed = 0.0F;
|
||||
EndSlimeEntity.this.forwardSpeed = 0.0F;
|
||||
this.entity.setMovementSpeed(0.0F);
|
||||
}
|
||||
} else {
|
||||
this.entity.setMovementSpeed(
|
||||
(float) (this.speed * this.entity.getAttributeValue(Attributes.MOVEMENT_SPEED)));
|
||||
else {
|
||||
EndSlimeEntity.this.xxa = 0.0F;
|
||||
EndSlimeEntity.this.zza = 0.0F;
|
||||
this.mob.setSpeed(0.0F);
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.mob.setSpeed((float) (this.speedModifier * this.mob.getAttributeValue(Attributes.MOVEMENT_SPEED)));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private float getJumpSoundPitch() {
|
||||
float f = EndSlimeEntity.this.isSmall() ? 1.4F : 0.8F;
|
||||
return ((EndSlimeEntity.this.random.nextFloat() - EndSlimeEntity.this.random.nextFloat()) * 0.2F + 1.0F)
|
||||
* f;
|
||||
float f = EndSlimeEntity.this.isTiny() ? 1.4F : 0.8F;
|
||||
return ((EndSlimeEntity.this.random.nextFloat() - EndSlimeEntity.this.random.nextFloat()) * 0.2F + 1.0F) * f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,64 +2,75 @@ package ru.betterend.entity;
|
|||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.particles.ParticleTypes;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.effect.MobEffectInstance;
|
||||
import net.minecraft.world.effect.MobEffects;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.SpawnReason;
|
||||
import net.minecraft.world.entity.ai.goal.FollowTargetGoal;
|
||||
import net.minecraft.world.entity.ai.goal.LookAroundGoal;
|
||||
import net.minecraft.world.entity.ai.goal.LookAtEntityGoal;
|
||||
import net.minecraft.world.entity.MobSpawnType;
|
||||
import net.minecraft.world.entity.ai.attributes.AttributeSupplier;
|
||||
import net.minecraft.world.entity.ai.attributes.Attributes;
|
||||
import net.minecraft.world.entity.ai.goal.LookAtPlayerGoal;
|
||||
import net.minecraft.world.entity.ai.goal.MeleeAttackGoal;
|
||||
import net.minecraft.world.entity.ai.goal.WanderAroundFarGoal;
|
||||
import net.minecraft.world.entity.attribute.DefaultAttributeContainer;
|
||||
import net.minecraft.world.entity.attribute.Attributes;
|
||||
import net.minecraft.world.entity.damage.DamageSource;
|
||||
import net.minecraft.world.effect.MobEffectInstance;
|
||||
import net.minecraft.world.effect.MobEffects;
|
||||
import net.minecraft.world.entity.mob.HostileEntity;
|
||||
import net.minecraft.world.entity.ai.goal.RandomLookAroundGoal;
|
||||
import net.minecraft.world.entity.ai.goal.WaterAvoidingRandomStrollGoal;
|
||||
import net.minecraft.world.entity.ai.goal.target.NearestAttackableTargetGoal;
|
||||
import net.minecraft.world.entity.monster.Monster;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.core.particles.ParticleTypes;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.level.ServerLevelAccessor;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.ServerLevelAccessor;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import ru.betterend.registry.EndSounds;
|
||||
import ru.betterend.util.MHelper;
|
||||
|
||||
public class ShadowWalkerEntity extends HostileEntity {
|
||||
public class ShadowWalkerEntity extends Monster {
|
||||
public ShadowWalkerEntity(EntityType<ShadowWalkerEntity> entityType, Level world) {
|
||||
super(entityType, world);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void initGoals() {
|
||||
this.goalSelector.add(2, new AttackGoal(this, 1.0D, false));
|
||||
this.goalSelector.add(7, new WanderAroundFarGoal(this, 1.0D));
|
||||
this.goalSelector.add(8, new LookAtEntityGoal(this, Player.class, 8.0F));
|
||||
this.goalSelector.add(8, new LookAroundGoal(this));
|
||||
this.targetSelector.add(2, new FollowTargetGoal<Player>(this, Player.class, true));
|
||||
protected void registerGoals() {
|
||||
this.goalSelector.addGoal(2, new AttackGoal(this, 1.0D, false));
|
||||
this.goalSelector.addGoal(7, new WaterAvoidingRandomStrollGoal(this, 1.0D));
|
||||
this.goalSelector.addGoal(8, new LookAtPlayerGoal(this, Player.class, 8.0F));
|
||||
this.goalSelector.addGoal(8, new RandomLookAroundGoal(this));
|
||||
this.targetSelector.addGoal(2, new NearestAttackableTargetGoal<Player>(this, Player.class, true));
|
||||
}
|
||||
|
||||
public static DefaultAttributeContainer.Builder createMobAttributes() {
|
||||
return HostileEntity.createHostileAttributes().add(Attributes.FOLLOW_RANGE, 35.0)
|
||||
.add(Attributes.MOVEMENT_SPEED, 0.15).add(Attributes.ATTACK_DAMAGE, 4.5).add(Attributes.ARMOR, 2.0)
|
||||
.add(Attributes.ZOMBIE_SPAWN_REINFORCEMENTS);
|
||||
public static AttributeSupplier.Builder createMobAttributes() {
|
||||
return Monster.createMonsterAttributes()
|
||||
.add(Attributes.FOLLOW_RANGE, 35.0)
|
||||
.add(Attributes.MOVEMENT_SPEED, 0.15)
|
||||
.add(Attributes.ATTACK_DAMAGE, 4.5)
|
||||
.add(Attributes.ARMOR, 2.0)
|
||||
.add(Attributes.SPAWN_REINFORCEMENTS_CHANCE);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
super.tick();
|
||||
world.addParticle(ParticleTypes.ASH, getX() + random.nextGaussian() * 0.2,
|
||||
getY() + random.nextGaussian() * 0.5 + 1, getZ() + random.nextGaussian() * 0.2, 0, 0, 0);
|
||||
world.addParticle(ParticleTypes.SMOKE, getX() + random.nextGaussian() * 0.2,
|
||||
getY() + random.nextGaussian() * 0.5 + 1, getZ() + random.nextGaussian() * 0.2, 0, 0, 0);
|
||||
world.addParticle(ParticleTypes.ENTITY_EFFECT, getX() + random.nextGaussian() * 0.2,
|
||||
getY() + random.nextGaussian() * 0.5 + 1, getZ() + random.nextGaussian() * 0.2, 0, 0, 0);
|
||||
level.addParticle(ParticleTypes.ASH,
|
||||
getX() + random.nextGaussian() * 0.2,
|
||||
getY() + random.nextGaussian() * 0.5 + 1,
|
||||
getZ() + random.nextGaussian() * 0.2,
|
||||
0, 0, 0);
|
||||
level.addParticle(ParticleTypes.SMOKE,
|
||||
getX() + random.nextGaussian() * 0.2,
|
||||
getY() + random.nextGaussian() * 0.5 + 1,
|
||||
getZ() + random.nextGaussian() * 0.2,
|
||||
0, 0, 0);
|
||||
level.addParticle(ParticleTypes.ENTITY_EFFECT,
|
||||
getX() + random.nextGaussian() * 0.2,
|
||||
getY() + random.nextGaussian() * 0.5 + 1,
|
||||
getZ() + random.nextGaussian() * 0.2,
|
||||
0, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected SoundEvent getAmbientSound() {
|
||||
return EndSounds.ENTITY_SHADOW_WALKER;
|
||||
|
@ -76,51 +87,47 @@ public class ShadowWalkerEntity extends HostileEntity {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void playStepSound(BlockPos pos, BlockState state) {
|
||||
}
|
||||
|
||||
protected void playStepSound(BlockPos pos, BlockState state) {}
|
||||
|
||||
@Override
|
||||
protected float getSoundVolume() {
|
||||
return MHelper.randRange(0.25F, 0.5F, random);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected float getSoundPitch() {
|
||||
protected float getVoicePitch() {
|
||||
return MHelper.randRange(0.75F, 1.25F, random);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean tryAttack(Entity target) {
|
||||
boolean attack = super.tryAttack(target);
|
||||
public boolean doHurtTarget(Entity target) {
|
||||
boolean attack = super.doHurtTarget(target);
|
||||
if (attack && target instanceof LivingEntity) {
|
||||
LivingEntity living = (LivingEntity) target;
|
||||
if (!(living.hasMobEffect(MobEffects.BLINDNESS))) {
|
||||
living.addMobEffect(new MobEffectInstance(MobEffects.BLINDNESS, 60));
|
||||
if (!(living.hasEffect(MobEffects.BLINDNESS))) {
|
||||
living.addEffect(new MobEffectInstance(MobEffects.BLINDNESS, 60));
|
||||
}
|
||||
}
|
||||
return attack;
|
||||
}
|
||||
|
||||
public static boolean canSpawn(EntityType<ShadowWalkerEntity> type, ServerLevelAccessor world,
|
||||
SpawnReason spawnReason, BlockPos pos, Random random) {
|
||||
if (HostileEntity.canSpawnInDark(type, world, spawnReason, pos, random)) {
|
||||
Box box = new Box(pos).expand(16);
|
||||
List<ShadowWalkerEntity> entities = world.getEntitiesByClass(ShadowWalkerEntity.class, box, (entity) -> {
|
||||
return true;
|
||||
});
|
||||
|
||||
public static boolean canSpawn(EntityType<ShadowWalkerEntity> type, ServerLevelAccessor world, MobSpawnType spawnReason, BlockPos pos, Random random) {
|
||||
if (Monster.checkMonsterSpawnRules(type, world, spawnReason, pos, random)) {
|
||||
AABB box = new AABB(pos).inflate(16);
|
||||
List<ShadowWalkerEntity> entities = world.getEntitiesOfClass(ShadowWalkerEntity.class, box, (entity) -> { return true; });
|
||||
return entities.size() < 6;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private final class AttackGoal extends MeleeAttackGoal {
|
||||
private final ShadowWalkerEntity walker;
|
||||
private int ticks;
|
||||
|
||||
public AttackGoal(ShadowWalkerEntity walker, double speed, boolean pauseWhenMobIdle) {
|
||||
super(walker, speed, pauseWhenMobIdle);
|
||||
this.walker = walker;
|
||||
}
|
||||
super(walker, speed, pauseWhenMobIdle);
|
||||
this.walker = walker;
|
||||
}
|
||||
|
||||
public void start() {
|
||||
super.start();
|
||||
|
@ -129,16 +136,17 @@ public class ShadowWalkerEntity extends HostileEntity {
|
|||
|
||||
public void stop() {
|
||||
super.stop();
|
||||
this.walker.setAttacking(false);
|
||||
this.walker.setAggressive(false);
|
||||
}
|
||||
|
||||
public void tick() {
|
||||
super.tick();
|
||||
++this.ticks;
|
||||
if (this.ticks >= 5 && this.method_28348() < this.method_28349() / 2) {
|
||||
this.walker.setAttacking(true);
|
||||
} else {
|
||||
this.walker.setAttacking(false);
|
||||
if (this.ticks >= 5 && this.getTicksUntilNextAttack() < this.getAttackInterval() / 2) {
|
||||
this.walker.setAggressive(true);
|
||||
}
|
||||
else {
|
||||
this.walker.setAggressive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,46 +5,45 @@ import java.util.List;
|
|||
import java.util.Random;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.item.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtUtils;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.entity.AgableMob;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.Flutterer;
|
||||
import net.minecraft.world.entity.ItemEntity;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.SpawnReason;
|
||||
import net.minecraft.world.entity.ai.TargetFinder;
|
||||
import net.minecraft.world.entity.ai.control.FlightMoveControl;
|
||||
import net.minecraft.world.entity.Mob;
|
||||
import net.minecraft.world.entity.MobSpawnType;
|
||||
import net.minecraft.world.entity.ai.attributes.AttributeSupplier;
|
||||
import net.minecraft.world.entity.ai.attributes.Attributes;
|
||||
import net.minecraft.world.entity.ai.control.FlyingMoveControl;
|
||||
import net.minecraft.world.entity.ai.control.LookControl;
|
||||
import net.minecraft.world.entity.ai.goal.AnimalMateGoal;
|
||||
import net.minecraft.world.entity.ai.goal.BreedGoal;
|
||||
import net.minecraft.world.entity.ai.goal.FloatGoal;
|
||||
import net.minecraft.world.entity.ai.goal.FollowParentGoal;
|
||||
import net.minecraft.world.entity.ai.goal.Goal;
|
||||
import net.minecraft.world.entity.ai.goal.SwimGoal;
|
||||
import net.minecraft.world.entity.ai.pathing.BirdNavigation;
|
||||
import net.minecraft.world.entity.ai.pathing.EntityNavigation;
|
||||
import net.minecraft.world.entity.ai.pathing.PathNodeType;
|
||||
import net.minecraft.world.entity.attribute.DefaultAttributeContainer;
|
||||
import net.minecraft.world.entity.attribute.Attributes;
|
||||
import net.minecraft.world.entity.damage.DamageSource;
|
||||
import net.minecraft.world.entity.mob.MobEntity;
|
||||
import net.minecraft.world.entity.passive.AnimalEntity;
|
||||
import net.minecraft.world.entity.passive.PassiveEntity;
|
||||
import net.minecraft.world.entity.ai.navigation.FlyingPathNavigation;
|
||||
import net.minecraft.world.entity.ai.navigation.PathNavigation;
|
||||
import net.minecraft.world.entity.ai.util.RandomPos;
|
||||
import net.minecraft.world.entity.animal.Animal;
|
||||
import net.minecraft.world.entity.animal.FlyingAnimal;
|
||||
import net.minecraft.world.entity.item.ItemEntity;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtHelper;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.state.property.Properties;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.world.Heightmap.Type;
|
||||
import net.minecraft.world.level.ServerLevelAccessor;
|
||||
import net.minecraft.world.item.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.ServerLevelAccessor;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||
import net.minecraft.world.level.levelgen.Heightmap.Types;
|
||||
import net.minecraft.world.level.pathfinder.BlockPathTypes;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import ru.betterend.BetterEnd;
|
||||
import ru.betterend.blocks.BlockProperties;
|
||||
import ru.betterend.entity.SilkMothEntity.MothLookControl;
|
||||
|
@ -56,77 +55,80 @@ import ru.betterend.registry.EndItems;
|
|||
import ru.betterend.util.BlocksHelper;
|
||||
import ru.betterend.util.MHelper;
|
||||
|
||||
public class SilkMothEntity extends AnimalEntity implements Flutterer {
|
||||
public class SilkMothEntity extends Animal implements FlyingAnimal {
|
||||
private BlockPos hivePos;
|
||||
private BlockPos entrance;
|
||||
private Level hiveWorld;
|
||||
|
||||
|
||||
public SilkMothEntity(EntityType<? extends SilkMothEntity> entityType, Level world) {
|
||||
super(entityType, world);
|
||||
this.moveControl = new FlightMoveControl(this, 20, true);
|
||||
this.moveControl = new FlyingMoveControl(this, 20, true);
|
||||
this.lookControl = new MothLookControl(this);
|
||||
this.setPathfindingPenalty(PathNodeType.WATER, -1.0F);
|
||||
this.setPathfindingPenalty(PathNodeType.DANGER_FIRE, -1.0F);
|
||||
this.experiencePoints = 1;
|
||||
this.setPathfindingMalus(BlockPathTypes.WATER, -1.0F);
|
||||
this.setPathfindingMalus(BlockPathTypes.DANGER_FIRE, -1.0F);
|
||||
this.xpReward = 1;
|
||||
}
|
||||
|
||||
public static DefaultAttributeContainer.Builder createMobAttributes() {
|
||||
return LivingEntity.createLivingAttributes().add(Attributes.MAX_HEALTH, 2.0D)
|
||||
.add(Attributes.FOLLOW_RANGE, 16.0D).add(Attributes.FLYING_SPEED, 0.4D)
|
||||
|
||||
public static AttributeSupplier.Builder createMobAttributes() {
|
||||
return LivingEntity.createLivingAttributes()
|
||||
.add(Attributes.MAX_HEALTH, 2.0D)
|
||||
.add(Attributes.FOLLOW_RANGE, 16.0D)
|
||||
.add(Attributes.FLYING_SPEED, 0.4D)
|
||||
.add(Attributes.MOVEMENT_SPEED, 0.1D);
|
||||
}
|
||||
|
||||
|
||||
public void setHive(Level world, BlockPos hive) {
|
||||
this.hivePos = hive;
|
||||
this.hiveWorld = world;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void writeCustomDataToTag(CompoundTag tag) {
|
||||
public void addAdditionalSaveData(CompoundTag tag) {
|
||||
if (hivePos != null) {
|
||||
tag.put("HivePos", NbtHelper.fromBlockPos(hivePos));
|
||||
tag.put("HivePos", NbtUtils.writeBlockPos(hivePos));
|
||||
tag.putString("HiveWorld", hiveWorld.dimension().location().toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void readCustomDataFromTag(CompoundTag tag) {
|
||||
public void readAdditionalSaveData(CompoundTag tag) {
|
||||
if (tag.contains("HivePos")) {
|
||||
hivePos = NbtHelper.toBlockPos(tag.getCompound("HivePos"));
|
||||
hivePos = NbtUtils.readBlockPos(tag.getCompound("HivePos"));
|
||||
ResourceLocation worldID = new ResourceLocation(tag.getString("HiveWorld"));
|
||||
try {
|
||||
hiveWorld = world.getServer().getLevel(ResourceKey.of(Registry.DIMENSION, worldID));
|
||||
} catch (Exception e) {
|
||||
BetterEnd.LOGGER.warning("Silk Moth Hive Level {} is missing!", worldID);
|
||||
hiveWorld = level.getServer().getLevel(ResourceKey.create(Registry.DIMENSION_REGISTRY, worldID));
|
||||
}
|
||||
catch (Exception e) {
|
||||
BetterEnd.LOGGER.warning("Silk Moth Hive World {} is missing!", worldID);
|
||||
hivePos = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initGoals() {
|
||||
this.goalSelector.add(1, new ReturnToHiveGoal());
|
||||
this.goalSelector.add(2, new AnimalMateGoal(this, 1.0D));
|
||||
this.goalSelector.add(5, new FollowParentGoal(this, 1.25D));
|
||||
this.goalSelector.add(8, new WanderAroundGoal());
|
||||
this.goalSelector.add(9, new SwimGoal(this));
|
||||
protected void registerGoals() {
|
||||
this.goalSelector.addGoal(1, new ReturnToHiveGoal());
|
||||
this.goalSelector.addGoal(2, new BreedGoal(this, 1.0D));
|
||||
this.goalSelector.addGoal(5, new FollowParentGoal(this, 1.25D));
|
||||
this.goalSelector.addGoal(8, new WanderAroundGoal());
|
||||
this.goalSelector.addGoal(9, new FloatGoal(this));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected EntityNavigation createNavigation(Level world) {
|
||||
BirdNavigation birdNavigation = new BirdNavigation(this, world) {
|
||||
public boolean isValidPosition(BlockPos pos) {
|
||||
BlockState state = this.world.getBlockState(pos);
|
||||
return state.isAir() || !state.getMaterial().blocksMovement();
|
||||
protected PathNavigation createNavigation(Level world) {
|
||||
FlyingPathNavigation birdNavigation = new FlyingPathNavigation(this, world) {
|
||||
public boolean isStableDestination(BlockPos pos) {
|
||||
BlockState state = this.level.getBlockState(pos);
|
||||
return state.isAir() || !state.getMaterial().blocksMotion();
|
||||
}
|
||||
|
||||
public void tick() {
|
||||
super.tick();
|
||||
}
|
||||
};
|
||||
birdNavigation.setCanPathThroughDoors(false);
|
||||
birdNavigation.setCanSwim(false);
|
||||
birdNavigation.setCanEnterOpenDoors(true);
|
||||
birdNavigation.setCanOpenDoors(false);
|
||||
birdNavigation.setCanFloat(false);
|
||||
birdNavigation.setCanPassDoors(true);
|
||||
return birdNavigation;
|
||||
}
|
||||
|
||||
|
@ -136,36 +138,36 @@ public class SilkMothEntity extends AnimalEntity implements Flutterer {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected boolean hasWings() {
|
||||
protected boolean makeFlySound() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleFallDamage(float fallDistance, float damageMultiplier) {
|
||||
public boolean causeFallDamage(float fallDistance, float damageMultiplier) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canClimb() {
|
||||
public boolean isMovementNoisy() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNoGravity() {
|
||||
public boolean isNoGravity() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PassiveEntity createChild(ServerLevel world, PassiveEntity entity) {
|
||||
public AgableMob getBreedOffspring(ServerLevel world, AgableMob entity) {
|
||||
return EndEntities.SILK_MOTH.create(world);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void dropLoot(DamageSource source, boolean causedByPlayer) {
|
||||
protected void dropFromLootTable(DamageSource source, boolean causedByPlayer) {
|
||||
int minCount = 0;
|
||||
int maxCount = 1;
|
||||
if (causedByPlayer && this.attackingPlayer != null) {
|
||||
int looting = EnchantmentHelper.getLooting(this.attackingPlayer);
|
||||
if (causedByPlayer && this.lastHurtByPlayer != null) {
|
||||
int looting = EnchantmentHelper.getMobLooting(this.lastHurtByPlayer);
|
||||
minCount += looting;
|
||||
maxCount += looting;
|
||||
if (maxCount > 2) {
|
||||
|
@ -173,111 +175,104 @@ public class SilkMothEntity extends AnimalEntity implements Flutterer {
|
|||
}
|
||||
}
|
||||
int count = minCount < maxCount ? MHelper.randRange(minCount, maxCount, random) : maxCount;
|
||||
ItemEntity drop = new ItemEntity(world, getX(), getY(), getZ(), new ItemStack(EndItems.SILK_FIBER, count));
|
||||
this.world.spawnEntity(drop);
|
||||
ItemEntity drop = new ItemEntity(level, getX(), getY(), getZ(), new ItemStack(EndItems.SILK_FIBER, count));
|
||||
this.level.addFreshEntity(drop);
|
||||
}
|
||||
|
||||
public static boolean canSpawn(EntityType<SilkMothEntity> type, ServerLevelAccessor world, SpawnReason spawnReason,
|
||||
BlockPos pos, Random random) {
|
||||
int y = world.getChunk(pos).sampleHeightmap(Type.WORLD_SURFACE, pos.getX() & 15, pos.getY() & 15);
|
||||
|
||||
public static boolean canSpawn(EntityType<SilkMothEntity> type, ServerLevelAccessor world, MobSpawnType spawnReason, BlockPos pos, Random random) {
|
||||
int y = world.getChunk(pos).getHeight(Types.WORLD_SURFACE, pos.getX() & 15, pos.getY() & 15);
|
||||
return y > 0 && pos.getY() >= y && notManyEntities(world, pos, 32, 1);
|
||||
}
|
||||
|
||||
|
||||
private static boolean notManyEntities(ServerLevelAccessor world, BlockPos pos, int radius, int maxCount) {
|
||||
Box box = new Box(pos).expand(radius);
|
||||
List<SilkMothEntity> list = world.getEntitiesByClass(SilkMothEntity.class, box, (entity) -> true);
|
||||
AABB box = new AABB(pos).inflate(radius);
|
||||
List<SilkMothEntity> list = world.getEntitiesOfClass(SilkMothEntity.class, box, (entity) -> true);
|
||||
return list.size() <= maxCount;
|
||||
}
|
||||
|
||||
|
||||
class MothLookControl extends LookControl {
|
||||
MothLookControl(MobEntity entity) {
|
||||
MothLookControl(Mob entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
protected boolean shouldStayHorizontal() {
|
||||
protected boolean resetXRotOnTick() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
class WanderAroundGoal extends Goal {
|
||||
WanderAroundGoal() {
|
||||
this.setControls(EnumSet.of(Goal.Control.MOVE));
|
||||
this.setFlags(EnumSet.of(Goal.Flag.MOVE));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canStart() {
|
||||
return SilkMothEntity.this.navigation.isIdle() && SilkMothEntity.this.random.nextInt(10) == 0;
|
||||
public boolean canUse() {
|
||||
return SilkMothEntity.this.navigation.isDone() && SilkMothEntity.this.random.nextInt(10) == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldContinue() {
|
||||
return SilkMothEntity.this.navigation.isFollowingPath();
|
||||
public boolean canContinueToUse() {
|
||||
return SilkMothEntity.this.navigation.isInProgress();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
Vec3d vec3d = null;
|
||||
if (SilkMothEntity.this.hivePos != null && SilkMothEntity.this.hiveWorld == SilkMothEntity.this.world) {
|
||||
if (SilkMothEntity.this.getPos().squaredDistanceTo(SilkMothEntity.this.hivePos.getX(),
|
||||
SilkMothEntity.this.hivePos.getY(), SilkMothEntity.this.hivePos.getZ()) > 16) {
|
||||
vec3d = SilkMothEntity.this.getPos().add(random.nextGaussian() * 2, 0, random.nextGaussian() * 2);
|
||||
Vec3 vec3d = null;
|
||||
if (SilkMothEntity.this.hivePos != null && SilkMothEntity.this.hiveWorld == SilkMothEntity.this.level) {
|
||||
if (SilkMothEntity.this.position().distanceToSqr(SilkMothEntity.this.hivePos.getX(), SilkMothEntity.this.hivePos.getY(), SilkMothEntity.this.hivePos.getZ()) > 16) {
|
||||
vec3d = SilkMothEntity.this.position().add(random.nextGaussian() * 2, 0, random.nextGaussian() * 2);
|
||||
}
|
||||
}
|
||||
vec3d = vec3d == null ? this.getRandomLocation() : vec3d;
|
||||
if (vec3d != null) {
|
||||
try {
|
||||
SilkMothEntity.this.navigation
|
||||
.startMovingAlong(SilkMothEntity.this.navigation.findPathTo(new BlockPos(vec3d), 1), 1.0D);
|
||||
} catch (Exception e) {
|
||||
SilkMothEntity.this.navigation.moveTo(SilkMothEntity.this.navigation.createPath(new BlockPos(vec3d), 1), 1.0D);
|
||||
}
|
||||
catch (Exception e) {}
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Vec3d getRandomLocation() {
|
||||
Vec3d vec3d3 = SilkMothEntity.this.getRotationVec(0.0F);
|
||||
Vec3d vec3d4 = TargetFinder.findAirTarget(SilkMothEntity.this, 8, 7, vec3d3, 1.5707964F, 2, 1);
|
||||
return vec3d4 != null ? vec3d4
|
||||
: TargetFinder.findGroundTarget(SilkMothEntity.this, 8, 4, -2, vec3d3, 1.5707963705062866D);
|
||||
private Vec3 getRandomLocation() {
|
||||
Vec3 vec3d3 = SilkMothEntity.this.getViewVector(0.0F);
|
||||
Vec3 vec3d4 = RandomPos.getAboveLandPos(SilkMothEntity.this, 8, 7, vec3d3, 1.5707964F, 2, 1);
|
||||
return vec3d4 != null ? vec3d4 : RandomPos.getAirPos(SilkMothEntity.this, 8, 4, -2, vec3d3, 1.5707963705062866D);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class ReturnToHiveGoal extends Goal {
|
||||
ReturnToHiveGoal() {
|
||||
this.setControls(EnumSet.of(Goal.Control.MOVE));
|
||||
this.setFlags(EnumSet.of(Goal.Flag.MOVE));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean canStart() {
|
||||
return SilkMothEntity.this.hivePos != null && SilkMothEntity.this.hiveWorld == SilkMothEntity.this.world
|
||||
&& SilkMothEntity.this.navigation.isIdle() && SilkMothEntity.this.random.nextInt(16) == 0
|
||||
&& SilkMothEntity.this.getPos().squaredDistanceTo(SilkMothEntity.this.hivePos.getX(),
|
||||
SilkMothEntity.this.hivePos.getY(), SilkMothEntity.this.hivePos.getZ()) < 64;
|
||||
public boolean canUse() {
|
||||
return SilkMothEntity.this.hivePos != null
|
||||
&& SilkMothEntity.this.hiveWorld == SilkMothEntity.this.level
|
||||
&& SilkMothEntity.this.navigation.isDone()
|
||||
&& SilkMothEntity.this.random.nextInt(16) == 0
|
||||
&& SilkMothEntity.this.position().distanceToSqr(SilkMothEntity.this.hivePos.getX(), SilkMothEntity.this.hivePos.getY(), SilkMothEntity.this.hivePos.getZ()) < 64;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean shouldContinue() {
|
||||
return SilkMothEntity.this.navigation.isFollowingPath() && world.getBlockState(entrance).isAir()
|
||||
&& (world.getBlockState(hivePos).is(EndBlocks.SILK_MOTH_NEST)
|
||||
|| world.getBlockState(hivePos).is(EndBlocks.SILK_MOTH_HIVE));
|
||||
public boolean canContinueToUse() {
|
||||
return SilkMothEntity.this.navigation.isInProgress() && level.getBlockState(entrance).isAir() && (level.getBlockState(hivePos).is(EndBlocks.SILK_MOTH_NEST) || level.getBlockState(hivePos).is(EndBlocks.SILK_MOTH_HIVE));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
BlockState state = SilkMothEntity.this.world.getBlockState(SilkMothEntity.this.hivePos);
|
||||
BlockState state = SilkMothEntity.this.level.getBlockState(SilkMothEntity.this.hivePos);
|
||||
if (!state.is(EndBlocks.SILK_MOTH_NEST) && !state.is(EndBlocks.SILK_MOTH_HIVE)) {
|
||||
SilkMothEntity.this.hivePos = null;
|
||||
return;
|
||||
}
|
||||
try {
|
||||
SilkMothEntity.this.entrance = SilkMothEntity.this.hivePos
|
||||
.offset(state.getValue(Properties.HORIZONTAL_FACING));
|
||||
SilkMothEntity.this.navigation.startMovingAlong(SilkMothEntity.this.navigation.findPathTo(entrance, 1),
|
||||
1.0D);
|
||||
} catch (Exception e) {
|
||||
SilkMothEntity.this.entrance = SilkMothEntity.this.hivePos.relative(state.getValue(BlockStateProperties.HORIZONTAL_FACING));
|
||||
SilkMothEntity.this.navigation.moveTo(SilkMothEntity.this.navigation.createPath(entrance, 1), 1.0D);
|
||||
}
|
||||
catch (Exception e) {}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
super.tick();
|
||||
|
@ -288,7 +283,7 @@ public class SilkMothEntity extends AnimalEntity implements Flutterer {
|
|||
double dy = Math.abs(SilkMothEntity.this.entrance.getY() - SilkMothEntity.this.getY());
|
||||
double dz = Math.abs(SilkMothEntity.this.entrance.getZ() - SilkMothEntity.this.getZ());
|
||||
if (dx + dy + dz < 1) {
|
||||
BlockState state = SilkMothEntity.this.world.getBlockState(hivePos);
|
||||
BlockState state = SilkMothEntity.this.level.getBlockState(hivePos);
|
||||
if (state.is(EndBlocks.SILK_MOTH_NEST) || state.is(EndBlocks.SILK_MOTH_HIVE)) {
|
||||
int fullness = state.getValue(BlockProperties.FULLNESS);
|
||||
boolean isHive = state.is(EndBlocks.SILK_MOTH_HIVE);
|
||||
|
@ -297,13 +292,12 @@ public class SilkMothEntity extends AnimalEntity implements Flutterer {
|
|||
if (fullness > 3) {
|
||||
fullness = 3;
|
||||
}
|
||||
BlocksHelper.setWithUpdate(SilkMothEntity.this.hiveWorld, SilkMothEntity.this.hivePos,
|
||||
state.with(BlockProperties.FULLNESS, fullness));
|
||||
BlocksHelper.setWithUpdate(SilkMothEntity.this.hiveWorld, SilkMothEntity.this.hivePos, state.setValue(BlockProperties.FULLNESS, fullness));
|
||||
}
|
||||
SilkMothEntity.this.world.playLocalSound(null, SilkMothEntity.this.entrance,
|
||||
SoundEvents.BLOCK_BEEHIVE_ENTER, SoundSource.BLOCKS, 1, 1);
|
||||
SilkMothEntity.this.level.playSound(null, SilkMothEntity.this.entrance, SoundEvents.BEEHIVE_ENTER, SoundSource.BLOCKS, 1, 1);
|
||||
SilkMothEntity.this.remove();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
SilkMothEntity.this.hivePos = null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,25 +1,24 @@
|
|||
package ru.betterend.entity.model;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
import net.minecraft.client.model.ModelPart;
|
||||
import net.minecraft.client.render.RenderLayer;
|
||||
import net.minecraft.client.render.entity.model.EntityModel;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.client.model.EntityModel;
|
||||
import net.minecraft.client.model.geom.ModelPart;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
|
||||
public abstract class BlockBenchModel<T extends Entity> extends EntityModel<T> {
|
||||
public BlockBenchModel() {
|
||||
super();
|
||||
}
|
||||
|
||||
public BlockBenchModel(Function<ResourceLocation, RenderLayer> function) {
|
||||
|
||||
public BlockBenchModel(Function<ResourceLocation, RenderType> function) {
|
||||
super(function);
|
||||
}
|
||||
|
||||
|
||||
protected void setRotationAngle(ModelPart modelRenderer, float x, float y, float z) {
|
||||
modelRenderer.pitch = x;
|
||||
modelRenderer.yaw = y;
|
||||
modelRenderer.roll = z;
|
||||
modelRenderer.xRot = x;
|
||||
modelRenderer.yRot = y;
|
||||
modelRenderer.zRot = z;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package ru.betterend.entity.model;
|
||||
|
||||
import net.minecraft.client.model.ModelPart;
|
||||
import net.minecraft.client.render.RenderLayer;
|
||||
import net.minecraft.client.render.VertexConsumer;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import net.minecraft.client.model.geom.ModelPart;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.util.Mth;
|
||||
import ru.betterend.entity.CubozoaEntity;
|
||||
|
||||
|
@ -22,81 +22,82 @@ public class CubozoaEntityModel extends BlockBenchModel<CubozoaEntity> {
|
|||
private float scaleXZ;
|
||||
|
||||
public CubozoaEntityModel() {
|
||||
super(RenderLayer::getEntityTranslucent);
|
||||
|
||||
textureWidth = 48;
|
||||
textureHeight = 48;
|
||||
|
||||
super(RenderType::entityTranslucent);
|
||||
|
||||
texWidth = 48;
|
||||
texHeight = 48;
|
||||
|
||||
model = new ModelPart(this);
|
||||
model.setPivot(0.0F, 24.0F, 0.0F);
|
||||
model.setTextureOffset(0, 17).addCuboid(-2.0F, -12.5F, -2.0F, 4.0F, 4.0F, 4.0F, 0.0F);
|
||||
model.setPos(0.0F, 24.0F, 0.0F);
|
||||
model.texOffs(0, 17).addBox(-2.0F, -12.5F, -2.0F, 4.0F, 4.0F, 4.0F, 0.0F);
|
||||
|
||||
main_cube_r1 = new ModelPart(this);
|
||||
main_cube_r1.setPivot(0.0F, -14.0F, 0.0F);
|
||||
main_cube_r1.setPos(0.0F, -14.0F, 0.0F);
|
||||
model.addChild(main_cube_r1);
|
||||
setRotationAngle(main_cube_r1, 0.0F, 0.0F, -3.1416F);
|
||||
main_cube_r1.setTextureOffset(0, 0).addCuboid(-5.0F, -7.0F, -5.0F, 10.0F, 7.0F, 10.0F, 0.0F);
|
||||
main_cube_r1.texOffs(0, 0).addBox(-5.0F, -7.0F, -5.0F, 10.0F, 7.0F, 10.0F, 0.0F);
|
||||
|
||||
tentacle_center_1 = new ModelPart(this);
|
||||
tentacle_center_1.setPivot(0.0F, 0.0F, 0.0F);
|
||||
tentacle_center_1.setPos(0.0F, 0.0F, 0.0F);
|
||||
model.addChild(tentacle_center_1);
|
||||
|
||||
|
||||
tentacle_1 = new ModelPart(this);
|
||||
tentacle_1.setPivot(0.0F, -7.0F, 4.5F);
|
||||
tentacle_1.setPos(0.0F, -7.0F, 4.5F);
|
||||
tentacle_center_1.addChild(tentacle_1);
|
||||
tentacle_1.setTextureOffset(16, 17).addCuboid(-4.0F, 0.0F, 0.0F, 8.0F, 7.0F, 0.0F, 0.0F);
|
||||
tentacle_1.texOffs(16, 17).addBox(-4.0F, 0.0F, 0.0F, 8.0F, 7.0F, 0.0F, 0.0F);
|
||||
|
||||
tentacle_center_2 = new ModelPart(this);
|
||||
tentacle_center_2.setPivot(0.0F, 0.0F, 0.0F);
|
||||
tentacle_center_2.setPos(0.0F, 0.0F, 0.0F);
|
||||
model.addChild(tentacle_center_2);
|
||||
setRotationAngle(tentacle_center_2, 0.0F, -1.5708F, 0.0F);
|
||||
|
||||
|
||||
tentacle_2 = new ModelPart(this);
|
||||
tentacle_2.setPivot(0.0F, -7.0F, 4.5F);
|
||||
tentacle_2.setPos(0.0F, -7.0F, 4.5F);
|
||||
tentacle_center_2.addChild(tentacle_2);
|
||||
tentacle_2.setTextureOffset(16, 17).addCuboid(-4.0F, 0.0F, 0.0F, 8.0F, 7.0F, 0.0F, 0.0F);
|
||||
tentacle_2.texOffs(16, 17).addBox(-4.0F, 0.0F, 0.0F, 8.0F, 7.0F, 0.0F, 0.0F);
|
||||
|
||||
tentacle_center_3 = new ModelPart(this);
|
||||
tentacle_center_3.setPivot(0.0F, 0.0F, 0.0F);
|
||||
tentacle_center_3.setPos(0.0F, 0.0F, 0.0F);
|
||||
model.addChild(tentacle_center_3);
|
||||
setRotationAngle(tentacle_center_3, 0.0F, 3.1416F, 0.0F);
|
||||
|
||||
|
||||
tentacle_3 = new ModelPart(this);
|
||||
tentacle_3.setPivot(0.0F, -7.0F, 4.5F);
|
||||
tentacle_3.setPos(0.0F, -7.0F, 4.5F);
|
||||
tentacle_center_3.addChild(tentacle_3);
|
||||
tentacle_3.setTextureOffset(16, 17).addCuboid(-4.0F, 0.0F, 0.0F, 8.0F, 7.0F, 0.0F, 0.0F);
|
||||
tentacle_3.texOffs(16, 17).addBox(-4.0F, 0.0F, 0.0F, 8.0F, 7.0F, 0.0F, 0.0F);
|
||||
|
||||
tentacle_center_4 = new ModelPart(this);
|
||||
tentacle_center_4.setPivot(0.0F, 0.0F, 0.0F);
|
||||
tentacle_center_4.setPos(0.0F, 0.0F, 0.0F);
|
||||
model.addChild(tentacle_center_4);
|
||||
setRotationAngle(tentacle_center_4, 0.0F, 1.5708F, 0.0F);
|
||||
|
||||
|
||||
tentacle_4 = new ModelPart(this);
|
||||
tentacle_4.setPivot(0.0F, -7.0F, 4.5F);
|
||||
tentacle_4.setPos(0.0F, -7.0F, 4.5F);
|
||||
tentacle_center_4.addChild(tentacle_4);
|
||||
tentacle_4.setTextureOffset(16, 17).addCuboid(-4.0F, 0.0F, 0.0F, 8.0F, 7.0F, 0.0F, 0.0F);
|
||||
tentacle_4.texOffs(16, 17).addBox(-4.0F, 0.0F, 0.0F, 8.0F, 7.0F, 0.0F, 0.0F);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setAngles(CubozoaEntity entity, float limbAngle, float limbDistance, float animationProgress,
|
||||
float headYaw, float headPitch) {
|
||||
public void setupAnim(CubozoaEntity entity, float limbAngle, float limbDistance, float animationProgress, float headYaw, float headPitch) {
|
||||
float sin = Mth.sin(animationProgress * 0.13F);
|
||||
scaleY = sin * 0.1F + 0.9F;
|
||||
scaleXZ = Mth.sin(animationProgress * 0.13F + 3.14F) * 0.1F + 0.9F;
|
||||
|
||||
tentacle_1.pitch = sin * 0.15F;
|
||||
tentacle_2.pitch = sin * 0.15F;
|
||||
tentacle_3.pitch = sin * 0.15F;
|
||||
tentacle_4.pitch = sin * 0.15F;
|
||||
|
||||
tentacle_1.xRot = sin * 0.15F;
|
||||
tentacle_2.xRot = sin * 0.15F;
|
||||
tentacle_3.xRot = sin * 0.15F;
|
||||
tentacle_4.xRot = sin * 0.15F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack matrices, VertexConsumer vertices, int light, int overlay, float red, float green,
|
||||
float blue, float alpha) {
|
||||
matrices.push();
|
||||
public void renderToBuffer(PoseStack matrices, VertexConsumer vertices, int light, int overlay, float red, float green, float blue, float alpha) {
|
||||
matrices.pushPose();
|
||||
matrices.scale(scaleXZ, scaleY, scaleXZ);
|
||||
model.render(matrices, vertices, light, overlay);
|
||||
matrices.pop();
|
||||
matrices.popPose();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package ru.betterend.entity.model;
|
||||
|
||||
import net.minecraft.client.model.ModelPart;
|
||||
import net.minecraft.client.render.RenderLayer;
|
||||
import net.minecraft.client.render.VertexConsumer;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import net.minecraft.client.model.geom.ModelPart;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import ru.betterend.entity.DragonflyEntity;
|
||||
|
||||
public class DragonflyEntityModel extends BlockBenchModel<DragonflyEntity> {
|
||||
|
@ -19,86 +19,87 @@ public class DragonflyEntityModel extends BlockBenchModel<DragonflyEntity> {
|
|||
private final ModelPart legs_2;
|
||||
|
||||
public DragonflyEntityModel() {
|
||||
super(RenderLayer::getEntityCutout);
|
||||
|
||||
textureWidth = 64;
|
||||
textureHeight = 64;
|
||||
super(RenderType::entityCutout);
|
||||
|
||||
texWidth = 64;
|
||||
texHeight = 64;
|
||||
|
||||
model = new ModelPart(this);
|
||||
model.setPivot(2.0F, 21.5F, -4.0F);
|
||||
model.setTextureOffset(0, 0).addCuboid(-4.0F, -4.0F, 0.0F, 4.0F, 4.0F, 9.0F, 0.0F);
|
||||
model.setPos(2.0F, 21.5F, -4.0F);
|
||||
model.texOffs(0, 0).addBox(-4.0F, -4.0F, 0.0F, 4.0F, 4.0F, 9.0F, 0.0F);
|
||||
|
||||
head = new ModelPart(this);
|
||||
head.setPivot(-2.0F, -2.0F, 0.0F);
|
||||
head.setPos(-2.0F, -2.0F, 0.0F);
|
||||
model.addChild(head);
|
||||
setRotationAngle(head, 0.3491F, 0.0F, 0.0F);
|
||||
head.setTextureOffset(17, 0).addCuboid(-1.5F, -1.5F, -2.5F, 3.0F, 3.0F, 3.0F, 0.0F);
|
||||
head.texOffs(17, 0).addBox(-1.5F, -1.5F, -2.5F, 3.0F, 3.0F, 3.0F, 0.0F);
|
||||
|
||||
tail = new ModelPart(this);
|
||||
tail.setPivot(-2.0F, -2.0F, 9.0F);
|
||||
tail.setPos(-2.0F, -2.0F, 9.0F);
|
||||
model.addChild(tail);
|
||||
tail.setTextureOffset(26, 0).addCuboid(-1.5F, -1.5F, 0.0F, 3.0F, 3.0F, 7.0F, 0.0F);
|
||||
tail.texOffs(26, 0).addBox(-1.5F, -1.5F, 0.0F, 3.0F, 3.0F, 7.0F, 0.0F);
|
||||
|
||||
tail_2 = new ModelPart(this);
|
||||
tail_2.setPivot(0.0F, 0.0F, 7.0F);
|
||||
tail_2.setPos(0.0F, 0.0F, 7.0F);
|
||||
tail.addChild(tail_2);
|
||||
tail_2.setTextureOffset(36, 0).addCuboid(-1.0F, -1.0F, 0.0F, 2.0F, 2.0F, 10.0F, 0.0F);
|
||||
tail_2.texOffs(36, 0).addBox(-1.0F, -1.0F, 0.0F, 2.0F, 2.0F, 10.0F, 0.0F);
|
||||
|
||||
wing_1 = new ModelPart(this);
|
||||
wing_1.setPivot(-2.0F, -4.0F, 4.0F);
|
||||
wing_1.setPos(-2.0F, -4.0F, 4.0F);
|
||||
model.addChild(wing_1);
|
||||
wing_1.setTextureOffset(0, 13).addCuboid(-15.0F, 0.0F, -3.0F, 15.0F, 0.0F, 4.0F, 0.0F);
|
||||
wing_1.texOffs(0, 13).addBox(-15.0F, 0.0F, -3.0F, 15.0F, 0.0F, 4.0F, 0.0F);
|
||||
|
||||
wing_2 = new ModelPart(this);
|
||||
wing_2.setPivot(-2.0F, -4.0F, 4.0F);
|
||||
wing_2.setPos(-2.0F, -4.0F, 4.0F);
|
||||
model.addChild(wing_2);
|
||||
wing_2.mirror = true;
|
||||
wing_2.setTextureOffset(0, 13).addCuboid(0.0F, 0.0F, -3.0F, 15.0F, 0.0F, 4.0F, 0.0F);
|
||||
wing_2.texOffs(0, 13).addBox(0.0F, 0.0F, -3.0F, 15.0F, 0.0F, 4.0F, 0.0F);
|
||||
|
||||
wing_3 = new ModelPart(this);
|
||||
wing_3.setPivot(-2.0F, -4.0F, 8.0F);
|
||||
wing_3.setPos(-2.0F, -4.0F, 8.0F);
|
||||
model.addChild(wing_3);
|
||||
wing_3.setTextureOffset(4, 17).addCuboid(-12.0F, 0.0F, -2.5F, 12.0F, 0.0F, 3.0F, 0.0F);
|
||||
wing_3.texOffs(4, 17).addBox(-12.0F, 0.0F, -2.5F, 12.0F, 0.0F, 3.0F, 0.0F);
|
||||
|
||||
wing_4 = new ModelPart(this);
|
||||
wing_4.setPivot(-2.0F, -4.0F, 8.0F);
|
||||
wing_4.setPos(-2.0F, -4.0F, 8.0F);
|
||||
model.addChild(wing_4);
|
||||
wing_4.mirror = true;
|
||||
wing_4.setTextureOffset(4, 17).addCuboid(0.0F, 0.0F, -2.5F, 12.0F, 0.0F, 3.0F, 0.0F);
|
||||
wing_4.texOffs(4, 17).addBox(0.0F, 0.0F, -2.5F, 12.0F, 0.0F, 3.0F, 0.0F);
|
||||
|
||||
legs_1 = new ModelPart(this);
|
||||
legs_1.setPivot(-1.0F, 0.0F, 1.0F);
|
||||
legs_1.setPos(-1.0F, 0.0F, 1.0F);
|
||||
model.addChild(legs_1);
|
||||
setRotationAngle(legs_1, 0.0F, 0.0F, -0.5236F);
|
||||
legs_1.setTextureOffset(50, 1).addCuboid(0.0F, 0.0F, 0.0F, 0.0F, 3.0F, 6.0F, 0.0F);
|
||||
legs_1.texOffs(50, 1).addBox(0.0F, 0.0F, 0.0F, 0.0F, 3.0F, 6.0F, 0.0F);
|
||||
|
||||
legs_2 = new ModelPart(this);
|
||||
legs_2.setPivot(-3.0F, 0.0F, 1.0F);
|
||||
legs_2.setPos(-3.0F, 0.0F, 1.0F);
|
||||
model.addChild(legs_2);
|
||||
setRotationAngle(legs_2, 0.0F, 0.0F, 0.5236F);
|
||||
legs_2.setTextureOffset(50, 1).addCuboid(0.0F, 0.0F, 0.0F, 0.0F, 3.0F, 6.0F, 0.0F);
|
||||
legs_2.texOffs(50, 1).addBox(0.0F, 0.0F, 0.0F, 0.0F, 3.0F, 6.0F, 0.0F);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setAngles(DragonflyEntity entity, float limbAngle, float limbDistance, float animationProgress, float headYaw, float headPitch) {
|
||||
public void setupAnim(DragonflyEntity entity, float limbAngle, float limbDistance, float animationProgress,
|
||||
float headYaw, float headPitch) {
|
||||
float progress = animationProgress * 2F;
|
||||
|
||||
wing_1.roll = 0.3491F + (float) Math.sin(progress) * 0.3491F;
|
||||
wing_2.roll = -wing_1.roll;
|
||||
|
||||
wing_3.roll = 0.3491F + (float) Math.cos(progress) * 0.3491F;
|
||||
wing_4.roll = -wing_3.roll;
|
||||
|
||||
|
||||
wing_1.zRot = 0.3491F + (float) Math.sin(progress) * 0.3491F;
|
||||
wing_2.zRot = -wing_1.zRot;
|
||||
|
||||
wing_3.zRot = 0.3491F + (float) Math.cos(progress) * 0.3491F;
|
||||
wing_4.zRot = -wing_3.zRot;
|
||||
|
||||
progress = animationProgress * 0.05F;
|
||||
|
||||
head.pitch = 0.3491F + (float) Math.sin(progress * 0.7F) * 0.1F;
|
||||
tail.pitch = (float) Math.cos(progress) * 0.05F - 0.05F;
|
||||
tail_2.pitch = -tail.pitch * 1.5F;
|
||||
|
||||
head.xRot = 0.3491F + (float) Math.sin(progress * 0.7F) * 0.1F;
|
||||
tail.xRot = (float) Math.cos(progress) * 0.05F - 0.05F;
|
||||
tail_2.xRot = -tail.xRot * 1.5F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack matrices, VertexConsumer vertices, int light, int overlay, float red, float green, float blue, float alpha) {
|
||||
public void renderToBuffer(PoseStack matrices, VertexConsumer vertices, int light, int overlay, float red,
|
||||
float green, float blue, float alpha) {
|
||||
model.render(matrices, vertices, light, overlay);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package ru.betterend.entity.model;
|
||||
|
||||
import net.minecraft.client.model.ModelPart;
|
||||
import net.minecraft.client.render.RenderLayer;
|
||||
import net.minecraft.client.render.VertexConsumer;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import net.minecraft.client.model.geom.ModelPart;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import ru.betterend.entity.EndFishEntity;
|
||||
|
||||
public class EndFishEntityModel extends BlockBenchModel<EndFishEntity> {
|
||||
|
@ -15,60 +15,61 @@ public class EndFishEntityModel extends BlockBenchModel<EndFishEntity> {
|
|||
private final ModelPart fin_left;
|
||||
|
||||
public EndFishEntityModel() {
|
||||
super(RenderLayer::getEntityCutout);
|
||||
|
||||
textureWidth = 32;
|
||||
textureHeight = 32;
|
||||
super(RenderType::entityCutout);
|
||||
|
||||
texWidth = 32;
|
||||
texHeight = 32;
|
||||
|
||||
model = new ModelPart(this);
|
||||
model.setPivot(0.0F, 20.0F, 0.0F);
|
||||
model.setTextureOffset(0, 0).addCuboid(-1.0F, -2.0F, -4.0F, 2.0F, 4.0F, 8.0F, 0.0F);
|
||||
model.setPos(0.0F, 20.0F, 0.0F);
|
||||
model.texOffs(0, 0).addBox(-1.0F, -2.0F, -4.0F, 2.0F, 4.0F, 8.0F, 0.0F);
|
||||
|
||||
fin_top = new ModelPart(this);
|
||||
fin_top.setPivot(0.0F, -2.0F, -4.0F);
|
||||
fin_top.setPos(0.0F, -2.0F, -4.0F);
|
||||
model.addChild(fin_top);
|
||||
setRotationAngle(fin_top, -0.6981F, 0.0F, 0.0F);
|
||||
fin_top.setTextureOffset(0, 6).addCuboid(0.0F, -8.0F, 0.0F, 0.0F, 8.0F, 6.0F, 0.0F);
|
||||
fin_top.texOffs(0, 6).addBox(0.0F, -8.0F, 0.0F, 0.0F, 8.0F, 6.0F, 0.0F);
|
||||
|
||||
fin_bottom = new ModelPart(this);
|
||||
fin_bottom.setPivot(0.0F, 2.0F, -4.0F);
|
||||
fin_bottom.setPos(0.0F, 2.0F, -4.0F);
|
||||
model.addChild(fin_bottom);
|
||||
setRotationAngle(fin_bottom, 0.6981F, 0.0F, 0.0F);
|
||||
fin_bottom.setTextureOffset(0, 6).addCuboid(0.0F, 0.0F, 0.0F, 0.0F, 8.0F, 6.0F, 0.0F);
|
||||
fin_bottom.texOffs(0, 6).addBox(0.0F, 0.0F, 0.0F, 0.0F, 8.0F, 6.0F, 0.0F);
|
||||
|
||||
flipper = new ModelPart(this);
|
||||
flipper.setPivot(0.0F, 0.0F, 2.0F);
|
||||
flipper.setPos(0.0F, 0.0F, 2.0F);
|
||||
model.addChild(flipper);
|
||||
setRotationAngle(flipper, -0.7854F, 0.0F, 0.0F);
|
||||
flipper.setTextureOffset(0, 15).addCuboid(0.0F, -5.0F, 0.0F, 0.0F, 5.0F, 5.0F, 0.0F);
|
||||
flipper.texOffs(0, 15).addBox(0.0F, -5.0F, 0.0F, 0.0F, 5.0F, 5.0F, 0.0F);
|
||||
|
||||
fin_right = new ModelPart(this);
|
||||
fin_right.setPivot(-1.0F, 0.0F, -1.0F);
|
||||
fin_right.setPos(-1.0F, 0.0F, -1.0F);
|
||||
model.addChild(fin_right);
|
||||
setRotationAngle(fin_right, 1.5708F, 0.7854F, 0.0F);
|
||||
fin_right.setTextureOffset(0, 25).addCuboid(-3.7071F, 0.7071F, -1.5F, 3.0F, 0.0F, 3.0F, 0.0F);
|
||||
fin_right.texOffs(0, 25).addBox(-3.7071F, 0.7071F, -1.5F, 3.0F, 0.0F, 3.0F, 0.0F);
|
||||
|
||||
fin_left = new ModelPart(this);
|
||||
fin_left.setPivot(1.0F, 0.0F, -1.0F);
|
||||
fin_left.setPos(1.0F, 0.0F, -1.0F);
|
||||
model.addChild(fin_left);
|
||||
setRotationAngle(fin_left, 1.5708F, -0.7854F, 0.0F);
|
||||
fin_left.setTextureOffset(0, 25).addCuboid(0.7071F, 0.7071F, -1.5F, 3.0F, 0.0F, 3.0F, 0.0F, true);
|
||||
fin_left.texOffs(0, 25).addBox(0.7071F, 0.7071F, -1.5F, 3.0F, 0.0F, 3.0F, 0.0F, true);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setAngles(EndFishEntity entity, float limbAngle, float limbDistance, float animationProgress, float headYaw, float headPitch) {
|
||||
public void setupAnim(EndFishEntity 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;
|
||||
flipper.yRot = s1 * 0.3F;
|
||||
fin_top.xRot = s2 * 0.02F - 0.6981F;
|
||||
fin_bottom.xRot = 0.6981F - s2 * 0.02F;
|
||||
fin_left.yRot = s1 * 0.3F - 0.7854F;
|
||||
fin_right.yRot = 0.7854F - s1 * 0.3F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack matrices, VertexConsumer vertices, int light, int overlay, float red, float green, float blue, float alpha) {
|
||||
public void renderToBuffer(PoseStack matrices, VertexConsumer vertices, int light, int overlay, float red,
|
||||
float green, float blue, float alpha) {
|
||||
model.render(matrices, vertices, light, overlay);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,26 +1,25 @@
|
|||
package ru.betterend.entity.model;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import net.minecraft.client.model.ModelPart;
|
||||
import net.minecraft.client.render.RenderLayer;
|
||||
import net.minecraft.client.render.VertexConsumer;
|
||||
import net.minecraft.client.render.entity.model.CompositeEntityModel;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import net.minecraft.client.model.ListModel;
|
||||
import net.minecraft.client.model.geom.ModelPart;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import ru.betterend.entity.EndSlimeEntity;
|
||||
import ru.betterend.util.MHelper;
|
||||
|
||||
public class EndSlimeEntityModel<T extends EndSlimeEntity> extends CompositeEntityModel<T> {
|
||||
public class EndSlimeEntityModel<T extends EndSlimeEntity> extends ListModel<T> {
|
||||
private final ModelPart flower;
|
||||
private final ModelPart crop;
|
||||
private final ModelPart innerCube;
|
||||
private final ModelPart rightEye;
|
||||
private final ModelPart leftEye;
|
||||
private final ModelPart mouth;
|
||||
|
||||
|
||||
public EndSlimeEntityModel(boolean onlyShell) {
|
||||
super(RenderLayer::getEntityCutout);
|
||||
|
||||
super(RenderType::entityCutout);
|
||||
|
||||
this.innerCube = new ModelPart(this, 0, 16);
|
||||
this.rightEye = new ModelPart(this, 32, 0);
|
||||
this.leftEye = new ModelPart(this, 32, 4);
|
||||
|
@ -29,54 +28,55 @@ public class EndSlimeEntityModel<T extends EndSlimeEntity> extends CompositeEnti
|
|||
this.crop = new ModelPart(this);
|
||||
|
||||
if (onlyShell) {
|
||||
this.innerCube.setTextureOffset(0, 0);
|
||||
this.innerCube.addCuboid(-4.0F, 16.0F, -4.0F, 8.0F, 8.0F, 8.0F);
|
||||
}
|
||||
else {
|
||||
this.innerCube.addCuboid(-3.0F, 17.0F, -3.0F, 6.0F, 6.0F, 6.0F);
|
||||
this.rightEye.addCuboid(-3.25F, 18.0F, -3.5F, 2.0F, 2.0F, 2.0F);
|
||||
this.leftEye.addCuboid(1.25F, 18.0F, -3.5F, 2.0F, 2.0F, 2.0F);
|
||||
this.mouth.addCuboid(0.0F, 21.0F, -3.5F, 1.0F, 1.0F, 1.0F);
|
||||
|
||||
this.innerCube.texOffs(0, 0);
|
||||
this.innerCube.addBox(-4.0F, 16.0F, -4.0F, 8.0F, 8.0F, 8.0F);
|
||||
} else {
|
||||
this.innerCube.addBox(-3.0F, 17.0F, -3.0F, 6.0F, 6.0F, 6.0F);
|
||||
this.rightEye.addBox(-3.25F, 18.0F, -3.5F, 2.0F, 2.0F, 2.0F);
|
||||
this.leftEye.addBox(1.25F, 18.0F, -3.5F, 2.0F, 2.0F, 2.0F);
|
||||
this.mouth.addBox(0.0F, 21.0F, -3.5F, 1.0F, 1.0F, 1.0F);
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
ModelPart petalRot = new ModelPart(this);
|
||||
petalRot.yaw = MHelper.degreesToRadians(i * 45F);
|
||||
|
||||
petalRot.yRot = MHelper.degreesToRadians(i * 45F);
|
||||
|
||||
ModelPart petal = new ModelPart(this, 40, 0);
|
||||
petal.setPivot(-4, 8, 0);
|
||||
petal.addCuboid(0.0F, 0.0F, 0.0F, 8.0F, 8.0F, 0.0F, 0.0F);
|
||||
|
||||
petal.setPos(-4, 8, 0);
|
||||
petal.addBox(0.0F, 0.0F, 0.0F, 8.0F, 8.0F, 0.0F, 0.0F);
|
||||
|
||||
this.flower.addChild(petalRot);
|
||||
petalRot.addChild(petal);
|
||||
}
|
||||
|
||||
|
||||
for (int i = 0; i < 2; i++) {
|
||||
ModelPart petalRot = new ModelPart(this);
|
||||
petalRot.yaw = MHelper.degreesToRadians(i * 90F + 45F);
|
||||
|
||||
petalRot.yRot = MHelper.degreesToRadians(i * 90F + 45F);
|
||||
|
||||
ModelPart petal = new ModelPart(this, 40, 0);
|
||||
petal.setPivot(-4, 8, 0);
|
||||
petal.addCuboid(0.0F, 0.0F, 0.0F, 8.0F, 8.0F, 0.0F, 0.0F);
|
||||
|
||||
petal.setPos(-4, 8, 0);
|
||||
petal.addBox(0.0F, 0.0F, 0.0F, 8.0F, 8.0F, 0.0F, 0.0F);
|
||||
|
||||
this.crop.addChild(petalRot);
|
||||
petalRot.addChild(petal);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setAngles(T entity, float limbAngle, float limbDistance, float animationProgress, float headYaw, float headPitch) {}
|
||||
|
||||
public void renderFlower(MatrixStack matrices, VertexConsumer vertices, int light, int overlay) {
|
||||
public void setupAnim(T entity, float limbAngle, float limbDistance, float animationProgress, float headYaw,
|
||||
float headPitch) {
|
||||
}
|
||||
|
||||
public void renderFlower(PoseStack matrices, VertexConsumer vertices, int light, int overlay) {
|
||||
flower.render(matrices, vertices, light, overlay);
|
||||
}
|
||||
|
||||
public void renderCrop(MatrixStack matrices, VertexConsumer vertices, int light, int overlay) {
|
||||
|
||||
public void renderCrop(PoseStack matrices, VertexConsumer vertices, int light, int overlay) {
|
||||
crop.render(matrices, vertices, light, overlay);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<ModelPart> getParts() {
|
||||
public Iterable<ModelPart> parts() {
|
||||
return ImmutableList.of(this.innerCube, this.rightEye, this.leftEye, this.mouth);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package ru.betterend.entity.model;
|
||||
|
||||
import net.minecraft.client.model.ModelPart;
|
||||
import net.minecraft.client.render.RenderLayer;
|
||||
import net.minecraft.client.render.VertexConsumer;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import net.minecraft.client.model.geom.ModelPart;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.util.Mth;
|
||||
import ru.betterend.entity.SilkMothEntity;
|
||||
|
||||
|
@ -25,110 +25,110 @@ public class SilkMothEntityModel extends BlockBenchModel<SilkMothEntity> {
|
|||
private final ModelPart abdomen_r1;
|
||||
|
||||
public SilkMothEntityModel() {
|
||||
super(RenderLayer::getEntityCutout);
|
||||
super(RenderType::entityCutout);
|
||||
|
||||
textureWidth = 64;
|
||||
textureHeight = 64;
|
||||
texWidth = 64;
|
||||
texHeight = 64;
|
||||
|
||||
legsL = new ModelPart(this);
|
||||
legsL.setPivot(1.5F, 19.9F, -0.45F);
|
||||
legsL.setPos(1.5F, 19.9F, -0.45F);
|
||||
setRotationAngle(legsL, 0.0F, 0.0F, 0.6981F);
|
||||
|
||||
cube_r1 = new ModelPart(this);
|
||||
cube_r1.setPivot(0.0F, 0.0F, -1.0F);
|
||||
cube_r1.setPos(0.0F, 0.0F, -1.0F);
|
||||
legsL.addChild(cube_r1);
|
||||
setRotationAngle(cube_r1, 0.0F, 0.2182F, 0.3927F);
|
||||
cube_r1.setTextureOffset(0, 13).addCuboid(0.0216F, 0.0F, -0.5976F, 3.0F, 0.0F, 1.0F, 0.0F);
|
||||
cube_r1.texOffs(0, 13).addBox(0.0216F, 0.0F, -0.5976F, 3.0F, 0.0F, 1.0F, 0.0F);
|
||||
|
||||
cube_r2 = new ModelPart(this);
|
||||
cube_r2.setPivot(0.5F, 0.1F, -0.05F);
|
||||
cube_r2.setPos(0.5F, 0.1F, -0.05F);
|
||||
legsL.addChild(cube_r2);
|
||||
setRotationAngle(cube_r2, 0.0F, 0.0F, 0.3927F);
|
||||
cube_r2.setTextureOffset(0, 15).addCuboid(0.0F, 0.0F, -0.6F, 3.0F, 0.0F, 1.0F, 0.0F);
|
||||
cube_r2.texOffs(0, 15).addBox(0.0F, 0.0F, -0.6F, 3.0F, 0.0F, 1.0F, 0.0F);
|
||||
|
||||
cube_r3 = new ModelPart(this);
|
||||
cube_r3.setPivot(0.0F, 0.0F, 0.9F);
|
||||
cube_r3.setPos(0.0F, 0.0F, 0.9F);
|
||||
legsL.addChild(cube_r3);
|
||||
setRotationAngle(cube_r3, 0.0F, -0.2182F, 0.3927F);
|
||||
cube_r3.setTextureOffset(0, 14).addCuboid(0.0F, 0.0F, -0.5F, 3.0F, 0.0F, 1.0F, 0.0F);
|
||||
cube_r3.texOffs(0, 14).addBox(0.0F, 0.0F, -0.5F, 3.0F, 0.0F, 1.0F, 0.0F);
|
||||
|
||||
legsR = new ModelPart(this);
|
||||
legsR.setPivot(-1.5F, 19.9F, -0.55F);
|
||||
legsR.setPos(-1.5F, 19.9F, -0.55F);
|
||||
setRotationAngle(legsR, 0.0F, 3.1416F, -0.6545F);
|
||||
|
||||
cube_r4 = new ModelPart(this);
|
||||
cube_r4.setPivot(0.0F, 0.0F, -1.0F);
|
||||
cube_r4.setPos(0.0F, 0.0F, -1.0F);
|
||||
legsR.addChild(cube_r4);
|
||||
setRotationAngle(cube_r4, 0.0F, 0.2182F, 0.3927F);
|
||||
cube_r4.setTextureOffset(0, 10).addCuboid(0.0F, 0.0F, -0.5F, 3.0F, 0.0F, 1.0F, 0.0F);
|
||||
cube_r4.texOffs(0, 10).addBox(0.0F, 0.0F, -0.5F, 3.0F, 0.0F, 1.0F, 0.0F);
|
||||
|
||||
cube_r5 = new ModelPart(this);
|
||||
cube_r5.setPivot(0.5F, 0.1F, -0.05F);
|
||||
cube_r5.setPos(0.5F, 0.1F, -0.05F);
|
||||
legsR.addChild(cube_r5);
|
||||
setRotationAngle(cube_r5, 0.0F, 0.0F, 0.3927F);
|
||||
cube_r5.setTextureOffset(0, 11).addCuboid(0.0F, 0.0F, -0.4F, 3.0F, 0.0F, 1.0F, 0.0F);
|
||||
cube_r5.texOffs(0, 11).addBox(0.0F, 0.0F, -0.4F, 3.0F, 0.0F, 1.0F, 0.0F);
|
||||
|
||||
cube_r6 = new ModelPart(this);
|
||||
cube_r6.setPivot(0.0F, 0.0F, 0.9F);
|
||||
cube_r6.setPos(0.0F, 0.0F, 0.9F);
|
||||
legsR.addChild(cube_r6);
|
||||
setRotationAngle(cube_r6, 0.0F, -0.2182F, 0.3927F);
|
||||
cube_r6.setTextureOffset(0, 12).addCuboid(0.0216F, 0.0F, -0.4024F, 3.0F, 0.0F, 1.0F, 0.0F);
|
||||
cube_r6.texOffs(0, 12).addBox(0.0216F, 0.0F, -0.4024F, 3.0F, 0.0F, 1.0F, 0.0F);
|
||||
|
||||
head_pivot = new ModelPart(this);
|
||||
head_pivot.setPivot(0.0F, 18.0F, -3.0F);
|
||||
head_pivot.setTextureOffset(15, 10).addCuboid(-1.5F, -1.5F, -2.0F, 3.0F, 3.0F, 3.0F, 0.0F);
|
||||
head_pivot.setPos(0.0F, 18.0F, -3.0F);
|
||||
head_pivot.texOffs(15, 10).addBox(-1.5F, -1.5F, -2.0F, 3.0F, 3.0F, 3.0F, 0.0F);
|
||||
|
||||
tendril_r_r1 = new ModelPart(this);
|
||||
tendril_r_r1.setPivot(1.0F, -1.15F, -1.0F);
|
||||
tendril_r_r1.setPos(1.0F, -1.15F, -1.0F);
|
||||
head_pivot.addChild(tendril_r_r1);
|
||||
setRotationAngle(tendril_r_r1, 0.0F, 0.0F, 0.3927F);
|
||||
tendril_r_r1.setTextureOffset(23, 0).addCuboid(-1.5F, -5.0F, 0.0F, 3.0F, 5.0F, 0.0F, 0.0F, true);
|
||||
tendril_r_r1.texOffs(23, 0).addBox(-1.5F, -5.0F, 0.0F, 3.0F, 5.0F, 0.0F, 0.0F, true);
|
||||
|
||||
tendril_r_r2 = new ModelPart(this);
|
||||
tendril_r_r2.setPivot(-1.0F, -1.15F, -1.0F);
|
||||
tendril_r_r2.setPos(-1.0F, -1.15F, -1.0F);
|
||||
head_pivot.addChild(tendril_r_r2);
|
||||
setRotationAngle(tendril_r_r2, 0.0F, 0.0F, -0.3927F);
|
||||
tendril_r_r2.setTextureOffset(23, 0).addCuboid(-1.5F, -5.0F, 0.0F, 3.0F, 5.0F, 0.0F, 0.0F);
|
||||
tendril_r_r2.texOffs(23, 0).addBox(-1.5F, -5.0F, 0.0F, 3.0F, 5.0F, 0.0F, 0.0F);
|
||||
|
||||
bb_main = new ModelPart(this);
|
||||
bb_main.setPivot(0.0F, 24.0F, 0.0F);
|
||||
bb_main.setTextureOffset(19, 19).addCuboid(-2.5F, -8.5F, -3.0F, 5.0F, 5.0F, 3.0F, 0.0F);
|
||||
bb_main.setPos(0.0F, 24.0F, 0.0F);
|
||||
bb_main.texOffs(19, 19).addBox(-2.5F, -8.5F, -3.0F, 5.0F, 5.0F, 3.0F, 0.0F);
|
||||
|
||||
wingR_r1 = new ModelPart(this);
|
||||
wingR_r1.setPivot(-1.5F, -6.5F, 0.5F);
|
||||
wingR_r1.setPos(-1.5F, -6.5F, 0.5F);
|
||||
bb_main.addChild(wingR_r1);
|
||||
setRotationAngle(wingR_r1, 0.0F, 0.0F, 0.3927F);
|
||||
wingR_r1.setTextureOffset(0, 5).addCuboid(-7.0F, 0.0F, -3.0F, 9.0F, 0.0F, 5.0F, 0.0F, true);
|
||||
wingR_r1.texOffs(0, 5).addBox(-7.0F, 0.0F, -3.0F, 9.0F, 0.0F, 5.0F, 0.0F, true);
|
||||
|
||||
wingL_r1 = new ModelPart(this);
|
||||
wingL_r1.setPivot(1.5F, -6.5F, 0.5F);
|
||||
wingL_r1.setPos(1.5F, -6.5F, 0.5F);
|
||||
bb_main.addChild(wingL_r1);
|
||||
setRotationAngle(wingL_r1, 0.0F, 0.0F, -0.3927F);
|
||||
wingL_r1.setTextureOffset(0, 5).addCuboid(-2.0F, 0.0F, -3.0F, 9.0F, 0.0F, 5.0F, 0.0F);
|
||||
wingL_r1.texOffs(0, 5).addBox(-2.0F, 0.0F, -3.0F, 9.0F, 0.0F, 5.0F, 0.0F);
|
||||
|
||||
abdomen_r1 = new ModelPart(this);
|
||||
abdomen_r1.setPivot(1.0F, -3.9F, 0.0F);
|
||||
abdomen_r1.setPos(1.0F, -3.9F, 0.0F);
|
||||
bb_main.addChild(abdomen_r1);
|
||||
setRotationAngle(abdomen_r1, -0.3927F, 0.0F, 0.0F);
|
||||
abdomen_r1.setTextureOffset(0, 10).addCuboid(-3.0F, -4.0F, -1.0F, 4.0F, 4.0F, 7.0F, 0.0F);
|
||||
abdomen_r1.texOffs(0, 10).addBox(-3.0F, -4.0F, -1.0F, 4.0F, 4.0F, 7.0F, 0.0F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAngles(SilkMothEntity entity, float limbAngle, float limbDistance, float animationProgress,
|
||||
public void setupAnim(SilkMothEntity entity, float limbAngle, float limbDistance, float animationProgress,
|
||||
float headYaw, float headPitch) {
|
||||
wingR_r1.roll = Mth.sin(animationProgress * 2F) * 0.4F + 0.3927F;
|
||||
wingL_r1.roll = -wingR_r1.roll;
|
||||
head_pivot.pitch = Mth.sin(animationProgress * 0.03F) * 0.1F;
|
||||
tendril_r_r1.roll = Mth.sin(animationProgress * 0.07F) * 0.2F + 0.3927F;
|
||||
tendril_r_r2.roll = -tendril_r_r1.roll;
|
||||
abdomen_r1.pitch = Mth.sin(animationProgress * 0.05F) * 0.1F - 0.3927F;
|
||||
legsR.roll = Mth.sin(animationProgress * 0.07F) * 0.1F - 0.6545F;
|
||||
legsL.roll = -legsR.roll;
|
||||
wingR_r1.zRot = Mth.sin(animationProgress * 2F) * 0.4F + 0.3927F;
|
||||
wingL_r1.zRot = -wingR_r1.zRot;
|
||||
head_pivot.xRot = Mth.sin(animationProgress * 0.03F) * 0.1F;
|
||||
tendril_r_r1.zRot = Mth.sin(animationProgress * 0.07F) * 0.2F + 0.3927F;
|
||||
tendril_r_r2.zRot = -tendril_r_r1.zRot;
|
||||
abdomen_r1.xRot = Mth.sin(animationProgress * 0.05F) * 0.1F - 0.3927F;
|
||||
legsR.zRot = Mth.sin(animationProgress * 0.07F) * 0.1F - 0.6545F;
|
||||
legsL.zRot = -legsR.zRot;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack matrices, VertexConsumer vertices, int light, int overlay, float red, float green,
|
||||
float blue, float alpha) {
|
||||
public void renderToBuffer(PoseStack matrices, VertexConsumer vertices, int light, int overlay, float red,
|
||||
float green, float blue, float alpha) {
|
||||
bb_main.render(matrices, vertices, light, overlay);
|
||||
head_pivot.render(matrices, vertices, light, overlay);
|
||||
legsL.render(matrices, vertices, light, overlay);
|
||||
|
|
|
@ -1,57 +1,54 @@
|
|||
package ru.betterend.entity.render;
|
||||
|
||||
import net.minecraft.client.render.OverlayTexture;
|
||||
import net.minecraft.client.render.RenderLayer;
|
||||
import net.minecraft.client.render.VertexConsumer;
|
||||
import net.minecraft.client.render.VertexConsumerProvider;
|
||||
import net.minecraft.client.render.entity.EntityRenderDispatcher;
|
||||
import net.minecraft.client.render.entity.MobEntityRenderer;
|
||||
import net.minecraft.client.render.entity.feature.EyesFeatureRenderer;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.entity.EntityRenderDispatcher;
|
||||
import net.minecraft.client.renderer.entity.MobRenderer;
|
||||
import net.minecraft.client.renderer.entity.layers.EyesLayer;
|
||||
import net.minecraft.client.renderer.texture.OverlayTexture;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import ru.betterend.BetterEnd;
|
||||
import ru.betterend.entity.CubozoaEntity;
|
||||
import ru.betterend.entity.model.CubozoaEntityModel;
|
||||
|
||||
public class RendererEntityCubozoa extends MobEntityRenderer<CubozoaEntity, CubozoaEntityModel> {
|
||||
public class RendererEntityCubozoa extends MobRenderer<CubozoaEntity, CubozoaEntityModel> {
|
||||
private static final ResourceLocation[] TEXTURE = new ResourceLocation[2];
|
||||
private static final RenderLayer[] GLOW = new RenderLayer[2];
|
||||
private static final RenderType[] GLOW = new RenderType[2];
|
||||
|
||||
public RendererEntityCubozoa(EntityRenderDispatcher entityRenderDispatcher) {
|
||||
super(entityRenderDispatcher, new CubozoaEntityModel(), 0.5f);
|
||||
this.addFeature(new EyesFeatureRenderer<CubozoaEntity, CubozoaEntityModel>(this) {
|
||||
this.addLayer(new EyesLayer<CubozoaEntity, CubozoaEntityModel>(this) {
|
||||
@Override
|
||||
public RenderLayer getEyesTexture() {
|
||||
public RenderType renderType() {
|
||||
return GLOW[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light,
|
||||
CubozoaEntity entity, float limbAngle, float limbDistance, float tickDelta, float animationProgress,
|
||||
float headYaw, float headPitch) {
|
||||
public void render(PoseStack matrices, MultiBufferSource vertexConsumers, int light, CubozoaEntity entity, float limbAngle, float limbDistance, float tickDelta, float animationProgress, float headYaw, float headPitch) {
|
||||
VertexConsumer vertexConsumer = vertexConsumers.getBuffer(GLOW[entity.getVariant()]);
|
||||
this.getContextModel().render(matrices, vertexConsumer, 15728640, OverlayTexture.DEFAULT_UV, 1.0F, 1.0F,
|
||||
1.0F, 1.0F);
|
||||
this.getParentModel().renderToBuffer(matrices, vertexConsumer, 15728640, OverlayTexture.NO_OVERLAY, 1.0F, 1.0F, 1.0F, 1.0F);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void scale(CubozoaEntity entity, MatrixStack matrixStack, float f) {
|
||||
protected void scale(CubozoaEntity entity, PoseStack matrixStack, float f) {
|
||||
float scale = entity.getScale();
|
||||
matrixStack.scale(scale, scale, scale);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getTexture(CubozoaEntity entity) {
|
||||
public ResourceLocation getTextureLocation(CubozoaEntity entity) {
|
||||
return TEXTURE[entity.getVariant()];
|
||||
}
|
||||
|
||||
|
||||
static {
|
||||
TEXTURE[0] = BetterEnd.makeID("textures/entity/cubozoa/cubozoa.png");
|
||||
TEXTURE[1] = BetterEnd.makeID("textures/entity/cubozoa/cubozoa_sulphur.png");
|
||||
|
||||
GLOW[0] = RenderLayer.getEyes(BetterEnd.makeID("textures/entity/cubozoa/cubozoa_glow.png"));
|
||||
GLOW[1] = RenderLayer.getEyes(BetterEnd.makeID("textures/entity/cubozoa/cubozoa_sulphur_glow.png"));
|
||||
|
||||
GLOW[0] = RenderType.eyes(BetterEnd.makeID("textures/entity/cubozoa/cubozoa_glow.png"));
|
||||
GLOW[1] = RenderType.eyes(BetterEnd.makeID("textures/entity/cubozoa/cubozoa_sulphur_glow.png"));
|
||||
}
|
||||
}
|
|
@ -1,30 +1,30 @@
|
|||
package ru.betterend.entity.render;
|
||||
|
||||
import net.minecraft.client.render.RenderLayer;
|
||||
import net.minecraft.client.render.entity.EntityRenderDispatcher;
|
||||
import net.minecraft.client.render.entity.MobEntityRenderer;
|
||||
import net.minecraft.client.render.entity.feature.EyesFeatureRenderer;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.entity.EntityRenderDispatcher;
|
||||
import net.minecraft.client.renderer.entity.MobRenderer;
|
||||
import net.minecraft.client.renderer.entity.layers.EyesLayer;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import ru.betterend.BetterEnd;
|
||||
import ru.betterend.entity.DragonflyEntity;
|
||||
import ru.betterend.entity.model.DragonflyEntityModel;
|
||||
|
||||
public class RendererEntityDragonfly extends MobEntityRenderer<DragonflyEntity, DragonflyEntityModel> {
|
||||
public class RendererEntityDragonfly extends MobRenderer<DragonflyEntity, DragonflyEntityModel> {
|
||||
private static final ResourceLocation TEXTURE = BetterEnd.makeID("textures/entity/dragonfly.png");
|
||||
private static final RenderLayer GLOW = RenderLayer.getEyes(BetterEnd.makeID("textures/entity/dragonfly_glow.png"));
|
||||
private static final RenderType GLOW = RenderType.eyes(BetterEnd.makeID("textures/entity/dragonfly_glow.png"));
|
||||
|
||||
public RendererEntityDragonfly(EntityRenderDispatcher entityRenderDispatcher) {
|
||||
super(entityRenderDispatcher, new DragonflyEntityModel(), 0.5f);
|
||||
this.addFeature(new EyesFeatureRenderer<DragonflyEntity, DragonflyEntityModel>(this) {
|
||||
this.addLayer(new EyesLayer<DragonflyEntity, DragonflyEntityModel>(this) {
|
||||
@Override
|
||||
public RenderLayer getEyesTexture() {
|
||||
public RenderType renderType() {
|
||||
return GLOW;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getTexture(DragonflyEntity entity) {
|
||||
public ResourceLocation getTextureLocation(DragonflyEntity entity) {
|
||||
return TEXTURE;
|
||||
}
|
||||
}
|
|
@ -1,56 +1,56 @@
|
|||
package ru.betterend.entity.render;
|
||||
|
||||
import net.minecraft.client.render.OverlayTexture;
|
||||
import net.minecraft.client.render.RenderLayer;
|
||||
import net.minecraft.client.render.VertexConsumer;
|
||||
import net.minecraft.client.render.VertexConsumerProvider;
|
||||
import net.minecraft.client.render.entity.EntityRenderDispatcher;
|
||||
import net.minecraft.client.render.entity.MobEntityRenderer;
|
||||
import net.minecraft.client.render.entity.feature.EyesFeatureRenderer;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.entity.EntityRenderDispatcher;
|
||||
import net.minecraft.client.renderer.entity.MobRenderer;
|
||||
import net.minecraft.client.renderer.entity.layers.EyesLayer;
|
||||
import net.minecraft.client.renderer.texture.OverlayTexture;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import ru.betterend.BetterEnd;
|
||||
import ru.betterend.entity.EndFishEntity;
|
||||
import ru.betterend.entity.model.EndFishEntityModel;
|
||||
|
||||
public class RendererEntityEndFish extends MobEntityRenderer<EndFishEntity, EndFishEntityModel> {
|
||||
public class RendererEntityEndFish extends MobRenderer<EndFishEntity, EndFishEntityModel> {
|
||||
private static final ResourceLocation[] TEXTURE = new ResourceLocation[EndFishEntity.VARIANTS];
|
||||
private static final RenderLayer[] GLOW = new RenderLayer[EndFishEntity.VARIANTS];
|
||||
private static final RenderType[] GLOW = new RenderType[EndFishEntity.VARIANTS];
|
||||
|
||||
public RendererEntityEndFish(EntityRenderDispatcher entityRenderDispatcher) {
|
||||
super(entityRenderDispatcher, new EndFishEntityModel(), 0.5f);
|
||||
this.addFeature(new EyesFeatureRenderer<EndFishEntity, EndFishEntityModel>(this) {
|
||||
this.addLayer(new EyesLayer<EndFishEntity, EndFishEntityModel>(this) {
|
||||
@Override
|
||||
public RenderLayer getEyesTexture() {
|
||||
public RenderType renderType() {
|
||||
return GLOW[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light,
|
||||
EndFishEntity entity, float limbAngle, float limbDistance, float tickDelta, float animationProgress,
|
||||
float headYaw, float headPitch) {
|
||||
public void render(PoseStack matrices, MultiBufferSource vertexConsumers, int light, EndFishEntity entity,
|
||||
float limbAngle, float limbDistance, float tickDelta, float animationProgress, float headYaw,
|
||||
float headPitch) {
|
||||
VertexConsumer vertexConsumer = vertexConsumers.getBuffer(GLOW[entity.getVariant()]);
|
||||
this.getContextModel().render(matrices, vertexConsumer, 15728640, OverlayTexture.DEFAULT_UV, 1.0F, 1.0F,
|
||||
1.0F, 1.0F);
|
||||
this.getParentModel().renderToBuffer(matrices, vertexConsumer, 15728640, OverlayTexture.NO_OVERLAY,
|
||||
1.0F, 1.0F, 1.0F, 1.0F);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void scale(EndFishEntity entity, MatrixStack matrixStack, float f) {
|
||||
protected void scale(EndFishEntity entity, PoseStack matrixStack, float f) {
|
||||
float scale = entity.getScale();
|
||||
matrixStack.scale(scale, scale, scale);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getTexture(EndFishEntity entity) {
|
||||
public ResourceLocation getTextureLocation(EndFishEntity entity) {
|
||||
return TEXTURE[entity.getVariant()];
|
||||
}
|
||||
|
||||
static {
|
||||
for (int i = 0; i < EndFishEntity.VARIANTS; i++) {
|
||||
TEXTURE[i] = BetterEnd.makeID("textures/entity/end_fish/end_fish_" + i + ".png");
|
||||
GLOW[i] = RenderLayer.getEyes(BetterEnd.makeID("textures/entity/end_fish/end_fish_" + i + "_glow.png"));
|
||||
GLOW[i] = RenderType.eyes(BetterEnd.makeID("textures/entity/end_fish/end_fish_" + i + "_glow.png"));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,103 +1,103 @@
|
|||
package ru.betterend.entity.render;
|
||||
|
||||
import net.minecraft.client.render.OverlayTexture;
|
||||
import net.minecraft.client.render.RenderLayer;
|
||||
import net.minecraft.client.render.VertexConsumer;
|
||||
import net.minecraft.client.render.VertexConsumerProvider;
|
||||
import net.minecraft.client.render.entity.EntityRenderDispatcher;
|
||||
import net.minecraft.client.render.entity.LivingEntityRenderer;
|
||||
import net.minecraft.client.render.entity.MobEntityRenderer;
|
||||
import net.minecraft.client.render.entity.feature.EyesFeatureRenderer;
|
||||
import net.minecraft.client.render.entity.feature.FeatureRenderer;
|
||||
import net.minecraft.client.render.entity.feature.FeatureRendererContext;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.entity.EntityRenderDispatcher;
|
||||
import net.minecraft.client.renderer.entity.LivingEntityRenderer;
|
||||
import net.minecraft.client.renderer.entity.MobRenderer;
|
||||
import net.minecraft.client.renderer.entity.RenderLayerParent;
|
||||
import net.minecraft.client.renderer.entity.layers.EyesLayer;
|
||||
import net.minecraft.client.renderer.entity.layers.RenderLayer;
|
||||
import net.minecraft.client.renderer.texture.OverlayTexture;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.Mth;
|
||||
import ru.betterend.BetterEnd;
|
||||
import ru.betterend.entity.EndSlimeEntity;
|
||||
import ru.betterend.entity.model.EndSlimeEntityModel;
|
||||
|
||||
public class RendererEntityEndSlime extends MobEntityRenderer<EndSlimeEntity, EndSlimeEntityModel<EndSlimeEntity>> {
|
||||
public class RendererEntityEndSlime extends MobRenderer<EndSlimeEntity, EndSlimeEntityModel<EndSlimeEntity>> {
|
||||
private static final ResourceLocation TEXTURE[] = new ResourceLocation[4];
|
||||
private static final RenderLayer GLOW[] = new RenderLayer[4];
|
||||
private static final RenderType GLOW[] = new RenderType[4];
|
||||
|
||||
public RendererEntityEndSlime(EntityRenderDispatcher entityRenderDispatcher) {
|
||||
super(entityRenderDispatcher, new EndSlimeEntityModel<EndSlimeEntity>(false), 0.25F);
|
||||
this.addFeature(new OverlayFeatureRenderer<EndSlimeEntity>(this));
|
||||
this.addFeature(new EyesFeatureRenderer<EndSlimeEntity, EndSlimeEntityModel<EndSlimeEntity>>(this) {
|
||||
this.addLayer(new OverlayFeatureRenderer<EndSlimeEntity>(this));
|
||||
this.addLayer(new EyesLayer<EndSlimeEntity, EndSlimeEntityModel<EndSlimeEntity>>(this) {
|
||||
@Override
|
||||
public RenderLayer getEyesTexture() {
|
||||
public RenderType renderType() {
|
||||
return GLOW[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light,
|
||||
EndSlimeEntity entity, float limbAngle, float limbDistance, float tickDelta,
|
||||
float animationProgress, float headYaw, float headPitch) {
|
||||
public void render(PoseStack matrices, MultiBufferSource vertexConsumers, int light, EndSlimeEntity entity,
|
||||
float limbAngle, float limbDistance, float tickDelta, float animationProgress, float headYaw,
|
||||
float headPitch) {
|
||||
VertexConsumer vertexConsumer = vertexConsumers.getBuffer(GLOW[entity.getSlimeType()]);
|
||||
this.getContextModel().render(matrices, vertexConsumer, 15728640, OverlayTexture.DEFAULT_UV, 1.0F, 1.0F,
|
||||
1.0F, 1.0F);
|
||||
this.getParentModel().renderToBuffer(matrices, vertexConsumer, 15728640, OverlayTexture.NO_OVERLAY,
|
||||
1.0F, 1.0F, 1.0F, 1.0F);
|
||||
if (entity.isLake()) {
|
||||
this.getContextModel().renderFlower(matrices, vertexConsumer, 15728640, OverlayTexture.DEFAULT_UV);
|
||||
this.getParentModel().renderFlower(matrices, vertexConsumer, 15728640, OverlayTexture.NO_OVERLAY);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getTexture(EndSlimeEntity entity) {
|
||||
public ResourceLocation getTextureLocation(EndSlimeEntity entity) {
|
||||
return TEXTURE[entity.getSlimeType()];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(EndSlimeEntity slimeEntity, float f, float g, MatrixStack matrixStack,
|
||||
VertexConsumerProvider vertexConsumerProvider, int i) {
|
||||
public void render(EndSlimeEntity slimeEntity, float f, float g, PoseStack matrixStack,
|
||||
MultiBufferSource vertexConsumerProvider, int i) {
|
||||
this.shadowRadius = 0.25F * (float) slimeEntity.getSize();
|
||||
super.render(slimeEntity, f, g, matrixStack, vertexConsumerProvider, i);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void scale(EndSlimeEntity slimeEntity, MatrixStack matrixStack, float f) {
|
||||
protected void scale(EndSlimeEntity slimeEntity, PoseStack matrixStack, float f) {
|
||||
matrixStack.scale(0.999F, 0.999F, 0.999F);
|
||||
matrixStack.translate(0.0D, 0.0010000000474974513D, 0.0D);
|
||||
float h = (float) slimeEntity.getSize();
|
||||
float i = Mth.lerp(f, slimeEntity.lastStretch, slimeEntity.stretch) / (h * 0.5F + 1.0F);
|
||||
float i = Mth.lerp(f, slimeEntity.oSquish, slimeEntity.squish) / (h * 0.5F + 1.0F);
|
||||
float j = 1.0F / (i + 1.0F);
|
||||
matrixStack.scale(j * h, 1.0F / j * h, j * h);
|
||||
}
|
||||
|
||||
private final class OverlayFeatureRenderer<T extends EndSlimeEntity>
|
||||
extends FeatureRenderer<T, EndSlimeEntityModel<T>> {
|
||||
extends RenderLayer<T, EndSlimeEntityModel<T>> {
|
||||
private final EndSlimeEntityModel<T> modelOrdinal = new EndSlimeEntityModel<T>(true);
|
||||
private final EndSlimeEntityModel<T> modelLake = new EndSlimeEntityModel<T>(true);
|
||||
|
||||
public OverlayFeatureRenderer(FeatureRendererContext<T, EndSlimeEntityModel<T>> featureRendererContext) {
|
||||
public OverlayFeatureRenderer(RenderLayerParent<T, EndSlimeEntityModel<T>> featureRendererContext) {
|
||||
super(featureRendererContext);
|
||||
}
|
||||
|
||||
public void render(MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i,
|
||||
T livingEntity, float f, float g, float h, float j, float k, float l) {
|
||||
public void render(PoseStack matrixStack, MultiBufferSource vertexConsumerProvider, int i, T livingEntity,
|
||||
float f, float g, float h, float j, float k, float l) {
|
||||
if (!livingEntity.isInvisible()) {
|
||||
if (livingEntity.isLake()) {
|
||||
VertexConsumer vertexConsumer = vertexConsumerProvider
|
||||
.getBuffer(RenderLayer.getEntityCutout(this.getTexture(livingEntity)));
|
||||
this.getContextModel().renderFlower(matrixStack, vertexConsumer, i,
|
||||
LivingEntityRenderer.getOverlay(livingEntity, 0.0F));
|
||||
.getBuffer(RenderType.entityCutout(this.getTextureLocation(livingEntity)));
|
||||
this.getParentModel().renderFlower(matrixStack, vertexConsumer, i,
|
||||
LivingEntityRenderer.getOverlayCoords(livingEntity, 0.0F));
|
||||
} else if (livingEntity.isAmber() || livingEntity.isChorus()) {
|
||||
VertexConsumer vertexConsumer = vertexConsumerProvider
|
||||
.getBuffer(RenderLayer.getEntityCutout(this.getTexture(livingEntity)));
|
||||
this.getContextModel().renderCrop(matrixStack, vertexConsumer, i,
|
||||
LivingEntityRenderer.getOverlay(livingEntity, 0.0F));
|
||||
.getBuffer(RenderType.entityCutout(this.getTextureLocation(livingEntity)));
|
||||
this.getParentModel().renderCrop(matrixStack, vertexConsumer, i,
|
||||
LivingEntityRenderer.getOverlayCoords(livingEntity, 0.0F));
|
||||
}
|
||||
|
||||
EndSlimeEntityModel<T> model = livingEntity.getSlimeType() == 1 ? modelLake : modelOrdinal;
|
||||
this.getContextModel().copyStateTo(model);
|
||||
model.animateModel(livingEntity, f, g, h);
|
||||
model.setAngles(livingEntity, f, g, j, k, l);
|
||||
this.getParentModel().copyPropertiesTo(model);
|
||||
model.prepareMobModel(livingEntity, f, g, h);
|
||||
model.setupAnim(livingEntity, f, g, j, k, l);
|
||||
VertexConsumer vertexConsumer = vertexConsumerProvider
|
||||
.getBuffer(RenderLayer.getEntityTranslucent(this.getTexture(livingEntity)));
|
||||
model.render(matrixStack, vertexConsumer, i, LivingEntityRenderer.getOverlay(livingEntity, 0.0F), 1.0F,
|
||||
1.0F, 1.0F, 1.0F);
|
||||
.getBuffer(RenderType.entityTranslucent(this.getTextureLocation(livingEntity)));
|
||||
model.renderToBuffer(matrixStack, vertexConsumer, i,
|
||||
LivingEntityRenderer.getOverlayCoords(livingEntity, 0.0F), 1.0F, 1.0F, 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -107,9 +107,9 @@ public class RendererEntityEndSlime extends MobEntityRenderer<EndSlimeEntity, En
|
|||
TEXTURE[1] = BetterEnd.makeID("textures/entity/end_slime/end_slime_mossy.png");
|
||||
TEXTURE[2] = BetterEnd.makeID("textures/entity/end_slime/end_slime_lake.png");
|
||||
TEXTURE[3] = BetterEnd.makeID("textures/entity/end_slime/end_slime_amber.png");
|
||||
GLOW[0] = RenderLayer.getEyes(BetterEnd.makeID("textures/entity/end_slime/end_slime_glow.png"));
|
||||
GLOW[0] = RenderType.eyes(BetterEnd.makeID("textures/entity/end_slime/end_slime_glow.png"));
|
||||
GLOW[1] = GLOW[0];
|
||||
GLOW[2] = RenderLayer.getEyes(BetterEnd.makeID("textures/entity/end_slime/end_slime_lake_glow.png"));
|
||||
GLOW[3] = RenderLayer.getEyes(BetterEnd.makeID("textures/entity/end_slime/end_slime_amber_glow.png"));
|
||||
GLOW[2] = RenderType.eyes(BetterEnd.makeID("textures/entity/end_slime/end_slime_lake_glow.png"));
|
||||
GLOW[3] = RenderType.eyes(BetterEnd.makeID("textures/entity/end_slime/end_slime_amber_glow.png"));
|
||||
}
|
||||
}
|
|
@ -1,22 +1,22 @@
|
|||
package ru.betterend.entity.render;
|
||||
|
||||
import net.minecraft.client.render.entity.BipedEntityRenderer;
|
||||
import net.minecraft.client.render.entity.EntityRenderDispatcher;
|
||||
import net.minecraft.client.render.entity.model.PlayerEntityModel;
|
||||
import net.minecraft.client.model.PlayerModel;
|
||||
import net.minecraft.client.renderer.entity.EntityRenderDispatcher;
|
||||
import net.minecraft.client.renderer.entity.HumanoidMobRenderer;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import ru.betterend.BetterEnd;
|
||||
import ru.betterend.entity.ShadowWalkerEntity;
|
||||
|
||||
public class RendererEntityShadowWalker
|
||||
extends BipedEntityRenderer<ShadowWalkerEntity, PlayerEntityModel<ShadowWalkerEntity>> {
|
||||
extends HumanoidMobRenderer<ShadowWalkerEntity, PlayerModel<ShadowWalkerEntity>> {
|
||||
private static final ResourceLocation TEXTURE = BetterEnd.makeID("textures/entity/shadow_walker.png");
|
||||
|
||||
public RendererEntityShadowWalker(EntityRenderDispatcher entityRenderDispatcher) {
|
||||
super(entityRenderDispatcher, new PlayerEntityModel<ShadowWalkerEntity>(0.0F, false), 0.5F);
|
||||
super(entityRenderDispatcher, new PlayerModel<ShadowWalkerEntity>(0.0F, false), 0.5F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getTexture(ShadowWalkerEntity zombieEntity) {
|
||||
public ResourceLocation getTextureLocation(ShadowWalkerEntity zombieEntity) {
|
||||
return TEXTURE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
package ru.betterend.entity.render;
|
||||
|
||||
import net.minecraft.client.render.entity.EntityRenderDispatcher;
|
||||
import net.minecraft.client.render.entity.MobEntityRenderer;
|
||||
import net.minecraft.client.renderer.entity.EntityRenderDispatcher;
|
||||
import net.minecraft.client.renderer.entity.MobRenderer;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import ru.betterend.BetterEnd;
|
||||
import ru.betterend.entity.SilkMothEntity;
|
||||
import ru.betterend.entity.model.SilkMothEntityModel;
|
||||
|
||||
public class SilkMothEntityRenderer extends MobEntityRenderer<SilkMothEntity, SilkMothEntityModel> {
|
||||
public class SilkMothEntityRenderer extends MobRenderer<SilkMothEntity, SilkMothEntityModel> {
|
||||
private static final ResourceLocation TEXTURE = BetterEnd.makeID("textures/entity/silk_moth.png");
|
||||
|
||||
public SilkMothEntityRenderer(EntityRenderDispatcher entityRenderDispatcher) {
|
||||
|
@ -15,7 +15,7 @@ public class SilkMothEntityRenderer extends MobEntityRenderer<SilkMothEntity, Si
|
|||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getTexture(SilkMothEntity entity) {
|
||||
public ResourceLocation getTextureLocation(SilkMothEntity entity) {
|
||||
return TEXTURE;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue