Skip to content

Commit

Permalink
raven machine unbroke
Browse files Browse the repository at this point in the history
  • Loading branch information
Arathain committed May 9, 2022
1 parent d45f3c2 commit bb60817
Show file tree
Hide file tree
Showing 28 changed files with 314 additions and 84 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public void render(StringKnotEntity stringKnotEntity, float yaw, float tickDelta
// Render the knot
if (stringKnotEntity.shouldRenderKnot()) {
matrices.push();
Vec3d leashOffset = stringKnotEntity.getLeashPos(tickDelta).subtract(stringKnotEntity.getLerpedPos(tickDelta));
Vec3d leashOffset = stringKnotEntity.method_30951(tickDelta).subtract(stringKnotEntity.getLerpedPos(tickDelta));
matrices.translate(leashOffset.x, leashOffset.y + 6.5 / 16f, leashOffset.z);
// The model is 6 px wide, but it should be rendered at 5px
matrices.scale(5 / 6f, 1, 5 / 6f);
Expand Down Expand Up @@ -121,7 +121,7 @@ private void renderStringLink(StringLink link, float tickDelta, MatrixStack matr
if (toEntity instanceof AbstractDecorationEntity) {
dstPos = toEntity.getPos().add(toEntity.getLeashOffset());
} else {
dstPos = toEntity.getLeashPos(tickDelta);
dstPos = toEntity.method_30951(tickDelta);
}

// The leash pos offset
Expand Down Expand Up @@ -172,7 +172,7 @@ private void renderStringLink(StringLink link, float tickDelta, MatrixStack matr
*/
private void drawDebugVector(MatrixStack matrices, Entity fromEntity, Entity toEntity, VertexConsumer buffer) {
if (toEntity == null) return;
Matrix4f modelMat = matrices.peek().getPositionMatrix();
Matrix4f modelMat = matrices.peek().getModel();
Vec3d vec = toEntity.getPos().subtract(fromEntity.getPos());
Vec3d normal = vec.normalize();
buffer.vertex(modelMat, 0, 0, 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ public StringModel(float[] vertices, float[] uvs) {
}

public void render(VertexConsumer buffer, MatrixStack matrices, int bLight0, int bLight1, int sLight0, int sLight1) {
Matrix4f modelMatrix = matrices.peek().getPositionMatrix();
Matrix3f normalMatrix = matrices.peek().getNormalMatrix();
Matrix4f modelMatrix = matrices.peek().getModel();
Matrix3f normalMatrix = matrices.peek().getNormal();
int count = vertices.length / 3;
for (int i = 0; i < count; i++) {
// divide by 2 because chain has 2 face sets
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ private RavenFeatherParticle(ClientWorld world, double x, double y, double z, do
@Override
public void tick() {
if (this.age > this.maxAge / 2) {
this.setAlpha(1.0F - ((float)this.age - (float)(this.maxAge / 2)) / (float)this.maxAge);
this.setColorAlpha(1.0F - ((float)this.age - (float)(this.maxAge / 2)) / (float)this.maxAge);
}
this.angle = (float) (this.prevAngle + Math.sin(this.age / 20f)/ 10);
super.tick();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package net.arathain.tot.common.effect;

import net.minecraft.entity.effect.StatusEffect;
import net.minecraft.entity.effect.StatusEffectCategory;
import net.minecraft.entity.effect.StatusEffectType;

public class DriderCurseStatusEffect extends StatusEffect {
public DriderCurseStatusEffect(StatusEffectCategory category, int color) {
public DriderCurseStatusEffect(StatusEffectType category, int color) {
super(category, color);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,8 @@ protected void initGoals() {
this.goalSelector.add(6, new LookAtEntityGoal(this, PlayerEntity.class, 8.0f));
this.goalSelector.add(6, new LookAroundGoal(this));
this.targetSelector.add(1, new RevengeGoal(this, SpiderEntity.class).setGroupRevenge());
this.targetSelector.add(2, new ActiveTargetGoal<>(this, PlayerEntity.class, 10, true, false, player -> !ToTUtil.isDrider(player)));
this.targetSelector.add(2, new ActiveTargetGoal<>(this, IronGolemEntity.class, true));
this.targetSelector.add(3, new TargetGoal<>(this, IronGolemEntity.class));
this.targetSelector.add(2, new TargetGoal<>(this, PlayerEntity.class, 10, true, false, player -> !ToTUtil.isDrider(player)));
this.targetSelector.add(2, new TargetGoal<>(this, IronGolemEntity.class, true));
}

@Override
Expand Down Expand Up @@ -333,22 +332,6 @@ public int tickTimer() {
return age;
}

static class TargetGoal<T extends LivingEntity>
extends ActiveTargetGoal<T> {
public TargetGoal(SpiderEntity spider, Class<T> targetEntityClass) {
super((MobEntity)spider, targetEntityClass, true);
}

@Override
public boolean canStart() {
float f = this.mob.getBrightnessAtEyes();
if (f >= 0.5f) {
return false;
}
return super.canStart();
}
}

public enum Type {
DARK,
ALBINO,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ protected void initGoals() {
this.goalSelector.add(6, new LookAtEntityGoal(this, DriderEntity.class, 6.0f));
this.goalSelector.add(6, new LookAroundGoal(this));
this.targetSelector.add(1, new ArachneRevengeGoal(this, SpiderEntity.class).setGroupRevenge());
this.targetSelector.add(2, new ActiveTargetGoal<>(this, PlayerEntity.class, 10, true, false, player -> !ToTUtil.isDrider(player)));
this.targetSelector.add(2, new ActiveTargetGoal<>(this, IronGolemEntity.class, true));
this.targetSelector.add(2, new TargetGoal<>(this, PlayerEntity.class, 10, true, false, player -> !ToTUtil.isDrider(player)));
this.targetSelector.add(2, new TargetGoal<>(this, IronGolemEntity.class, true));
}

@Override
Expand Down Expand Up @@ -183,7 +183,7 @@ public void setRestingPos(BlockPos pos) {
}
private boolean isAtRestingPos() {
Optional<BlockPos> restPos = getRestingPos();
return restPos.filter(blockPos -> blockPos.getSquaredDistance(getPos()) < 9).isPresent();
return restPos.filter(blockPos -> blockPos.getSquaredDistanceToCenter(this.getPos()) < 9).isPresent();
}

private void updateRestingPos() {
Expand Down Expand Up @@ -281,9 +281,6 @@ public void onStartedTrackingBy(ServerPlayerEntity player) {
super.onStartedTrackingBy(player);
this.bossBar.addPlayer(player);
}
public double getAngleBetweenEntities(Entity first, Entity second) {
return Math.atan2(second.getZ() - first.getZ(), second.getX() - first.getX()) * (180 / Math.PI) + 90;
}

@Override
public void onDeath(DamageSource source) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ protected void initGoals() {
this.goalSelector.add(6, new LookAtEntityGoal(this, PlayerEntity.class, 8.0f));
this.goalSelector.add(6, new LookAroundGoal(this));
this.targetSelector.add(1, new ObedientRevengeGoal(this, DriderEntity.class).setGroupRevenge());
this.targetSelector.add(1, new ActiveTargetGoal<>(this, AnimalEntity.class, true));
this.targetSelector.add(2, new ActiveTargetGoal<>(this, PlayerEntity.class, 10, true, false, player -> !ToTUtil.isDrider(player)));
this.targetSelector.add(2, new ActiveTargetGoal<>(this, IronGolemEntity.class, 10, true, false, golem -> true));
this.targetSelector.add(1, new TargetGoal<>(this, AnimalEntity.class, true));
this.targetSelector.add(2, new TargetGoal<>(this, PlayerEntity.class, 10, true, false, player -> !ToTUtil.isDrider(player)));
this.targetSelector.add(2, new TargetGoal<>(this, IronGolemEntity.class, 10, true, false, golem -> true));
}

@Override
Expand All @@ -57,7 +57,7 @@ public void tick() {
}
}
public void growUp() {
WeavethrallEntity grown = new WeavethrallEntity(ToTEntities.WEAVETHRALL, this.getEntityWorld());
WeavethrallEntity grown = new WeavethrallEntity(ToTEntities.WEAVETHRALL, this.getWorld());
grown.updatePositionAndAngles(this.getX(), this.getY(), this.getZ(), this.getYaw(), this.getPitch());
world.spawnEntity(grown);
this.remove(RemovalReason.DISCARDED);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@ protected void initGoals() {
this.targetSelector.add(1, new ObedientRevengeGoal(this, DriderEntity.class).setGroupRevenge(ZombifiedPiglinEntity.class));
this.targetSelector.add(1, new TamedTrackAttackerGoal(this));
this.targetSelector.add(2, new TamedAttackWithOwnerGoal<>(this));
this.targetSelector.add(1, new ActiveTargetGoal<>(this, AnimalEntity.class, 10, true, false, animol -> {
this.targetSelector.add(1, new TargetGoal<>(this, AnimalEntity.class, 10, true, false, animol -> {
if (isTamed()) return false;
if (!(animol instanceof TameableEntity)) return true;
TameableEntity tameable = (TameableEntity) animol;
return tameable.getOwner() == null || tameable.getOwner() != null && !ToTUtil.isDrider(tameable.getOwner());
}));
this.targetSelector.add(2, new ActiveTargetGoal<>(this, PlayerEntity.class, 10, true, false, player -> !ToTUtil.isDrider(player) && !isTamed()));
this.targetSelector.add(2, new ActiveTargetGoal<>(this, IronGolemEntity.class, 10, true, false, golem -> !isTamed()));
this.targetSelector.add(2, new TargetGoal<>(this, PlayerEntity.class, 10, true, false, player -> !ToTUtil.isDrider(player) && !isTamed()));
this.targetSelector.add(2, new TargetGoal<>(this, IronGolemEntity.class, 10, true, false, golem -> !isTamed()));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ public boolean shouldContinue() {
this.goalSelector.add(6, new LookAtEntityGoal(this, PlayerEntity.class, 8.0f));
this.goalSelector.add(6, new LookAroundGoal(this));
this.targetSelector.add(1, new RevengeGoal(this, SpiderEntity.class).setGroupRevenge());
this.targetSelector.add(2, new ActiveTargetGoal<>(this, PlayerEntity.class, 10, true, false, player -> !ToTUtil.isDrider(player)));
this.targetSelector.add(2, new ActiveTargetGoal<>(this, IronGolemEntity.class, true));
this.targetSelector.add(2, new TargetGoal<>(this, PlayerEntity.class, 10, true, false, player -> !ToTUtil.isDrider(player)));
this.targetSelector.add(2, new TargetGoal<>(this, IronGolemEntity.class, true));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class WebbingEntity extends Entity {

public WebbingEntity(EntityType<? extends WebbingEntity> type, World world) {
super(type, world);
this.intersectionChecked = true;
this.inanimate = true;
}

public WebbingEntity(World world, double x, double y, double z) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public void tick() {
BlockState state = world.getBlockState(pos);
BlockState stateAbove = world.getBlockState(abovePos);
if (state.getMaterial() != Material.AIR && state.isOpaqueFullCube(world, pos) && world.getBlockEntity(abovePos) == null && !stateAbove.getMaterial().blocksMovement()) {
FallingBlockEntity fallingBlock = FallingBlockEntity.spawnFromBlock(world, pos.add(0, 1, 0), state);
FallingBlockEntity fallingBlock = FallingBlockEntity.fall(world, pos.add(0, 1, 0), state);
fallingBlock.setPosition(hitX + 0.5, hitY + 1, hitZ + 0.5);
// world.setBlockState()
fallingBlock.setVelocity(0, 0.4 + factor * 0.2, 0);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package net.arathain.tot.common.entity.living.goal;

import net.arathain.tot.common.entity.living.raven.NevermoreEntity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.ai.goal.Goal;
import net.minecraft.sound.SoundEvent;

public abstract class NevermoreAttackGoal extends Goal {
protected final NevermoreEntity nevermore;
protected int attackCooldown;
protected int nextAttackTime;

public NevermoreAttackGoal(NevermoreEntity quothed) {
nevermore = quothed;
}
@Override
public void start() {
this.attackCooldown = this.getWarmupTime();
this.nextAttackTime = this.nevermore.age + this.getCooldown();
this.nevermore.playSound(this.getChargeSound(), 1.0F, 1.0F);
this.nevermore.setAttackState(this.getAttackId());
}
@Override
public boolean canStart() {
LivingEntity target = this.nevermore.getTarget();
if (target != null && target.isAlive() && this.nevermore.getAttackState() == 0) {
return this.nevermore.age >= this.nextAttackTime;
} else {
return false;
}
}

@Override
public boolean shouldContinue() {
LivingEntity target = this.nevermore.getTarget();
return target != null && target.isAlive() && this.attackCooldown > 0;
}

protected abstract SoundEvent getChargeSound();
protected abstract int getAttackId();

@Override
public void stop() {
this.nevermore.setAttackState(0);
}

@Override
public void tick() {
--this.attackCooldown;
if (this.attackCooldown == 0) {
this.attack();
this.nevermore.playSound(this.nevermore.getAttackSound(), 1.0F, 1.0F);
this.nevermore.stopAnger();
}
}
protected abstract int getCooldown();

protected abstract int getWarmupTime();

protected abstract void attack();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package net.arathain.tot.common.entity.living.goal;

import net.arathain.tot.common.entity.living.raven.NevermoreEntity;
import net.minecraft.entity.ai.goal.Goal;

import java.util.EnumSet;

public class NevermoreLookAtTargetGoal extends Goal {
private final NevermoreEntity nevermore;

public NevermoreLookAtTargetGoal(NevermoreEntity aaa) {
this.nevermore = aaa;
this.setControls(EnumSet.of(Goal.Control.MOVE, Goal.Control.LOOK));
}

@Override
public boolean canStart() {
return this.nevermore.getAttackState() != 0;
}

@Override
public void start() {
super.start();
this.nevermore.getNavigation().stop();
}

@Override
public void tick() {
if (this.nevermore.getTarget() != null) {
this.nevermore.getLookControl().lookAt(this.nevermore.getTarget(), (float)this.nevermore.getLookYawSpeed(), (float)this.nevermore.getLookPitchSpeed());
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package net.arathain.tot.common.entity.living.goal;

import net.arathain.tot.common.entity.living.raven.NevermoreEntity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.attribute.EntityAttributes;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.sound.SoundEvent;
import net.minecraft.sound.SoundEvents;

public class NevermoreYeetGoal extends NevermoreAttackGoal {
public NevermoreYeetGoal(NevermoreEntity quothed) {
super(quothed);
}

@Override
protected SoundEvent getChargeSound() {
return SoundEvents.ENTITY_IRON_GOLEM_REPAIR;
}

@Override
protected int getAttackId() {
return 1;
}

@Override
protected int getCooldown() {
return 60;
}

@Override
protected int getWarmupTime() {

return 16;
}

@Override
public void start() {
LivingEntity target = this.nevermore.getTarget();
if (target != null) {
this.nevermore.teleportTo(target);
}
super.start();
}

@Override
protected void attack() {
LivingEntity target = this.nevermore.getTarget();
if (target != null && this.nevermore.squaredDistanceTo(target) < 4) {
float f = (float) this.nevermore.getAttributeValue(EntityAttributes.GENERIC_ATTACK_DAMAGE);
float g = (int)f > 0 ? f / 2.0F + (float)this.nevermore.getRandom().nextInt((int)f) : f;
boolean bl = target.damage(DamageSource.mob(this.nevermore), g);
if (bl) {
target.setVelocity(target.getVelocity().add(0.0D, 1.2000000059604645D, 0.0D));
this.nevermore.applyDamageEffects(this.nevermore, target);
}

this.nevermore.playSound(nevermore.getAttackSound(), 1.0F, 1.0F);
}
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public void stop() {
}

public void tick() {
this.tameable.getLookControl().lookAt(this.receiver, 10.0F, (float) this.tameable.getMaxLookPitchChange());
this.tameable.getLookControl().lookAt(this.receiver, 10.0F, (float) this.tameable.getLookPitchSpeed());
if (--this.updateCountdownTicks <= 0) {
this.updateCountdownTicks = 10;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public void stop() {
}

public void tick() {
this.tameable.getLookControl().lookAt(this.owner, 10.0F, (float) this.tameable.getMaxLookPitchChange());
this.tameable.getLookControl().lookAt(this.owner, 10.0F, (float) this.tameable.getLookPitchSpeed());
if (--this.updateCountdownTicks <= 0) {
this.updateCountdownTicks = 10;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ private BlockPos tweakToProperPos(BlockPos pos, BlockView world) {
}

@Override
public double getDesiredDistanceToTarget() {
public double getDesiredSquaredDistanceToTarget() {
return 1;
}

Expand Down
Loading

0 comments on commit bb60817

Please sign in to comment.