Some cleanups, fix pink wither not spawning

This commit is contained in:
Vincent Lee committed 2020-07-18 11:46:48 -05:00
1 parent d1889eec40
commit 7f9a7b1ec7
5 files changed
+27 -36

No files matched your search

@@ -17,6 +17,7 @@ import net.minecraft.entity.MobEntity;
import net.minecraft.entity.ai.attributes.Attribute;
import net.minecraft.entity.ai.attributes.Attributes;
import net.minecraft.entity.ai.attributes.GlobalEntityTypeAttributes;
import net.minecraft.entity.boss.WitherEntity;
import net.minecraft.inventory.container.ContainerType;
import net.minecraft.item.Item;
import net.minecraft.item.crafting.IRecipeSerializer;
@@ -221,6 +222,7 @@ public class Botania {
GlobalEntityTypeAttributes.put(ModEntities.PIXIE, MobEntity.func_233666_p_()
.func_233815_a_(Attributes.MAX_HEALTH, 2.0)
.func_233813_a_());
GlobalEntityTypeAttributes.put(ModEntities.PINK_WITHER, WitherEntity.func_234258_eI_().func_233813_a_());
ModBanners.init();
ColorHelper.init();
@@ -24,6 +24,7 @@ import net.minecraft.world.World;
import net.minecraftforge.fml.network.NetworkHooks;
import vazkii.botania.mixin.MixinGoalSelector;
import vazkii.botania.mixin.MixinWitherEntity;
import javax.annotation.Nonnull;
@@ -50,10 +51,10 @@ public class EntityPinkWither extends WitherEntity {
if (Math.random() < 0.1) {
for (int j = 0; j < 3; ++j) {
double d10 = getHeadX(j);
double d2 = getHeadY(j);
double d4 = getHeadZ(j);
world.addParticle(ParticleTypes.HEART, d10 + rand.nextGaussian() * 0.30000001192092896D, d2 + rand.nextGaussian() * 0.30000001192092896D, d4 + rand.nextGaussian() * 0.30000001192092896D, 0.0D, 0.0D, 0.0D);
double x = ((MixinWitherEntity) this).callGetHeadX(j);
double y = ((MixinWitherEntity) this).callGetHeadY(j);
double z = ((MixinWitherEntity) this).callGetHeadZ(j);
world.addParticle(ParticleTypes.HEART, x + rand.nextGaussian() * 0.3, y + rand.nextGaussian() * 0.3, z + rand.nextGaussian() * 0.3, 0.0D, 0.0D, 0.0D);
}
}
}
@@ -77,32 +78,6 @@ public class EntityPinkWither extends WitherEntity {
@Override
public void addTrackingPlayer(@Nonnull ServerPlayerEntity player) {}
// [VanillaCopy] super
private double getHeadX(int p_82214_1_) {
if (p_82214_1_ <= 0) {
return this.getPosX();
} else {
float f = (this.renderYawOffset + (float) (180 * (p_82214_1_ - 1))) * ((float) Math.PI / 180F);
float f1 = MathHelper.cos(f);
return this.getPosX() + (double) f1 * 1.3D;
}
}
private double getHeadY(int p_82208_1_) {
return p_82208_1_ <= 0 ? this.getPosY() + 3.0D : this.getPosY() + 2.2D;
}
private double getHeadZ(int p_82213_1_) {
if (p_82213_1_ <= 0) {
return this.getPosZ();
} else {
float f = (this.renderYawOffset + (float) (180 * (p_82213_1_ - 1))) * ((float) Math.PI / 180F);
float f1 = MathHelper.sin(f);
return this.getPosZ() + (double) f1 * 1.3D;
}
}
@Nonnull
@Override
public IPacket<?> createSpawnPacket() {
@@ -168,11 +168,7 @@ public final class ToolCommons {
return materialLevel * 100 + modifier * 10 + efficiency;
}
// [VanillaCopy] Exact Entity.func_213324_a but available serverside, partialTicks fixed to 1, and narrowed return type
public static BlockRayTraceResult raytraceFromEntity(Entity e, double distance, boolean fluids) {
Vector3d Vector3d = e.getEyePosition(1);
Vector3d Vector3d1 = e.getLook(1);
Vector3d Vector3d2 = Vector3d.add(Vector3d1.x * distance, Vector3d1.y * distance, Vector3d1.z * distance);
return e.world.rayTraceBlocks(new RayTraceContext(Vector3d, Vector3d2, RayTraceContext.BlockMode.OUTLINE, fluids ? RayTraceContext.FluidMode.ANY : RayTraceContext.FluidMode.NONE, e));
return (BlockRayTraceResult) e.pick(distance, 1, fluids);
}
}
@@ -0,0 +1,17 @@
package vazkii.botania.mixin;
import net.minecraft.entity.boss.WitherEntity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Invoker;
@Mixin(WitherEntity.class)
public interface MixinWitherEntity {
@Invoker
double callGetHeadX(int idx);
@Invoker
double callGetHeadY(int idx);
@Invoker
double callGetHeadZ(int idx);
}
@@ -17,7 +17,8 @@
"MixinLivingEntity",
"MixinMobEntity",
"MixinNearestAttackableTarget",
"MixinRecipeManager"
"MixinRecipeManager",
"MixinWitherEntity"
],
"client": [
"MixinBiomeGeneratorTypeScreens",