com.parzivail.util.entity.ai.SlowTurningMoveControl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pswg Show documentation
Show all versions of pswg Show documentation
Explore the galaxy with Galaxies: Parzi's Star Wars Mod!
package com.parzivail.util.entity.ai;
import net.minecraft.class_1308;
import net.minecraft.class_1335;
import net.minecraft.class_1408;
import net.minecraft.class_2338;
import net.minecraft.class_2350;
import net.minecraft.class_265;
import net.minecraft.class_2680;
import net.minecraft.class_3481;
import net.minecraft.class_3532;
import net.minecraft.class_5134;
import net.minecraft.class_7;
import net.minecraft.class_8;
public class SlowTurningMoveControl extends class_1335
{
private final float maxYawRate;
public SlowTurningMoveControl(class_1308 entity, float maxYawRate)
{
super(entity);
this.maxYawRate = maxYawRate;
}
private boolean isPathWalkable(float dX, float dZ)
{
class_1408 entityNavigation = this.field_6371.method_5942();
if (entityNavigation != null)
{
class_8 pathNodeMaker = entityNavigation.method_6342();
return pathNodeMaker == null
|| pathNodeMaker.method_17(
this.field_6371.method_37908(),
class_3532.method_15357(this.field_6371.method_23317() + (double)dX),
this.field_6371.method_31478(),
class_3532.method_15357(this.field_6371.method_23321() + (double)dZ)
) == class_7.field_12;
}
return true;
}
@Override
public void method_6240()
{
if (this.field_6374 == SlowTurningMoveControl.State.field_6376)
{
float f = (float)this.field_6371.method_26825(class_5134.field_23719);
float g = (float)this.field_6372 * f;
float h = this.field_6368;
float i = this.field_6373;
float j = class_3532.method_15355(h * h + i * i);
if (j < 1.0F)
{
j = 1.0F;
}
j = g / j;
h *= j;
i *= j;
float k = class_3532.method_15374(this.field_6371.method_36454() * (float)(Math.PI / 180.0));
float l = class_3532.method_15362(this.field_6371.method_36454() * (float)(Math.PI / 180.0));
float m = h * l - i * k;
float n = i * l + h * k;
if (!this.isPathWalkable(m, n))
{
this.field_6368 = 1.0F;
this.field_6373 = 0.0F;
}
this.field_6371.method_6125(g);
this.field_6371.method_5930(this.field_6368);
this.field_6371.method_5938(this.field_6373);
this.field_6374 = SlowTurningMoveControl.State.field_6377;
}
else if (this.field_6374 == SlowTurningMoveControl.State.field_6378)
{
this.field_6374 = SlowTurningMoveControl.State.field_6377;
double f = this.field_6370 - this.field_6371.method_23317();
double h = this.field_6367 - this.field_6371.method_23321();
double j = this.field_6369 - this.field_6371.method_23318();
double l = f * f + j * j + h * h;
if (l < 2.5000003E-7F)
{
this.field_6371.method_5930(0.0F);
return;
}
float n = (float)(class_3532.method_15349(h, f) * 180.0F / (float)Math.PI) - 90.0F;
this.field_6371.method_36456(this.method_6238(this.field_6371.method_36454(), n, maxYawRate));
this.field_6371.method_6125((float)(this.field_6372 * this.field_6371.method_26825(class_5134.field_23719)));
class_2338 blockPos = this.field_6371.method_24515();
class_2680 blockState = this.field_6371.method_37908().method_8320(blockPos);
class_265 voxelShape = blockState.method_26220(this.field_6371.method_37908(), blockPos);
if (j > (double)this.field_6371.method_49476() && f * f + h * h < (double)Math.max(1.0F, this.field_6371.method_17681())
|| !voxelShape.method_1110()
&& this.field_6371.method_23318() < voxelShape.method_1105(class_2350.class_2351.field_11052) + (double)blockPos.method_10264()
&& !blockState.method_26164(class_3481.field_15495)
&& !blockState.method_26164(class_3481.field_16584))
{
this.field_6371.method_5993().method_6233();
this.field_6374 = SlowTurningMoveControl.State.field_6379;
}
}
else if (this.field_6374 == SlowTurningMoveControl.State.field_6379)
{
this.field_6371.method_6125((float)(this.field_6372 * this.field_6371.method_26825(class_5134.field_23719)));
if (this.field_6371.method_24828())
{
this.field_6374 = SlowTurningMoveControl.State.field_6377;
}
}
else
{
this.field_6371.method_5930(0.0F);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy