They sometimes aren't rotated the right way, no idea how to fix ATMmaster
@@ -14,13 +14,11 @@ import com.aether.tileentity.AetherTileEntityTypes; | |||
import com.aether.tileentity.TreasureChestTileEntity; | |||
import net.minecraft.block.Block; | |||
import net.minecraft.block.BlockRenderType; | |||
import net.minecraft.block.BlockState; | |||
import net.minecraft.block.ChestBlock; | |||
import net.minecraft.block.IWaterLoggable; | |||
import net.minecraft.entity.player.PlayerEntity; | |||
import net.minecraft.entity.player.PlayerInventory; | |||
import net.minecraft.fluid.Fluids; | |||
import net.minecraft.inventory.DoubleSidedInventory; | |||
import net.minecraft.inventory.IInventory; | |||
import net.minecraft.inventory.container.ChestContainer; | |||
@@ -95,54 +93,6 @@ public class TreasureChestBlock extends ChestBlock implements IWaterLoggable { | |||
public TreasureChestBlock(Block.Properties properties) { | |||
this(properties, () -> AetherTileEntityTypes.TREASURE_CHEST); | |||
} | |||
/** | |||
* The type of render function called. MODEL for mixed tesr and static model, MODELBLOCK_ANIMATED for TESR-only, | |||
* LIQUID for vanilla liquids, INVISIBLE to skip all rendering | |||
*/ | |||
@Override | |||
public BlockRenderType getRenderType(BlockState state) { | |||
return BlockRenderType.ENTITYBLOCK_ANIMATED; | |||
} | |||
/** | |||
* Update the provided state given the provided neighbor facing and neighbor state, returning a new state. For | |||
* example, fences make their connections to the passed in state if possible, and wet concrete powder immediately | |||
* returns its solidified counterpart. Note that this method should ideally consider only the specific face passed | |||
* in. | |||
*/ | |||
@Override | |||
public BlockState updatePostPlacement(BlockState stateIn, Direction facing, BlockState facingState, IWorld worldIn, | |||
BlockPos currentPos, BlockPos facingPos) { | |||
if (stateIn.get(WATERLOGGED)) { | |||
worldIn.getPendingFluidTicks().scheduleTick(currentPos, Fluids.WATER, Fluids.WATER.getTickRate(worldIn)); | |||
} | |||
if (facingState.getBlock() == this && facing.getAxis().isHorizontal()) { | |||
ChestType chesttype = facingState.get(TYPE); | |||
if (stateIn.get(TYPE) == ChestType.SINGLE && chesttype != ChestType.SINGLE | |||
&& stateIn.get(FACING) == facingState.get(FACING) | |||
&& getDirectionToAttached(facingState) == facing.getOpposite()) { | |||
return stateIn.with(TYPE, chesttype.opposite()); | |||
} | |||
} | |||
else if (getDirectionToAttached(stateIn) == facing) { | |||
return stateIn.with(TYPE, ChestType.SINGLE); | |||
} | |||
return super.updatePostPlacement(stateIn, facing, facingState, worldIn, currentPos, facingPos); | |||
} | |||
// @SuppressWarnings("serial") | |||
// private static void playLocalLockedSound(BlockPos pos) { | |||
// DistExecutor.safeRunWhenOn(Dist.CLIENT, () -> new SafeRunnable() { | |||
// @Override | |||
// public void run() { | |||
// Minecraft.getInstance().getConnection().getWorld().playSound(pos.getX(), pos.getY(), pos.getZ(), SoundEvents.BLOCK_CHEST_LOCKED, SoundCategory.BLOCKS, 1.0F, 1.0F, false); | |||
// //Minecraft.getInstance().getSoundHandler().play(new SimpleSound(SoundEvents.BLOCK_CHEST_LOCKED, SoundCategory.BLOCKS, 1.0F, 1.0F, chest1.getPos().getX(), chest1.getPos().getY(), chest1.getPos().getZ())); | |||
// } | |||
// }); | |||
// } | |||
private static final TileEntityMerger.ICallback<TreasureChestTileEntity, BiFunction<PlayerEntity, Hand, ActionResultType>> unlock = new TileEntityMerger.ICallback<TreasureChestTileEntity, BiFunction<PlayerEntity, Hand, ActionResultType>>() { | |||
@@ -7,16 +7,7 @@ import com.aether.capability.AetherCapabilities; | |||
import com.aether.client.gui.screen.inventory.EnchanterScreen; | |||
import com.aether.client.gui.screen.inventory.FreezerScreen; | |||
import com.aether.client.gui.screen.inventory.IncubatorScreen; | |||
import com.aether.client.renderer.entity.CockatriceRenderer; | |||
import com.aether.client.renderer.entity.FloatingBlockRenderer; | |||
import com.aether.client.renderer.entity.FlyingCowRenderer; | |||
import com.aether.client.renderer.entity.LightningKnifeRenderer; | |||
import com.aether.client.renderer.entity.MimicRenderer; | |||
import com.aether.client.renderer.entity.MoaRenderer; | |||
import com.aether.client.renderer.entity.PhygRenderer; | |||
import com.aether.client.renderer.entity.SentryRenderer; | |||
import com.aether.client.renderer.entity.SheepuffRenderer; | |||
import com.aether.client.renderer.entity.ZephyrRenderer; | |||
import com.aether.client.renderer.entity.*; | |||
import com.aether.client.renderer.tileentity.ChestMimicTileEntityRenderer; | |||
import com.aether.client.renderer.tileentity.TreasureChestTileEntityRenderer; | |||
import com.aether.entity.AetherEntityTypes; | |||
@@ -77,6 +68,7 @@ public class ClientProxy extends CommonProxy { | |||
RenderingRegistry.registerEntityRenderingHandler(AetherEntityTypes.PHYG, PhygRenderer::new); | |||
RenderingRegistry.registerEntityRenderingHandler(AetherEntityTypes.FLYING_COW, FlyingCowRenderer::new); | |||
RenderingRegistry.registerEntityRenderingHandler(AetherEntityTypes.SHEEPUFF, SheepuffRenderer::new); | |||
RenderingRegistry.registerEntityRenderingHandler(AetherEntityTypes.AERWHALE, AerwhaleRenderer::new); | |||
} | |||
protected void registerTileEntityRenderers() { | |||
@@ -1,32 +1,83 @@ | |||
/* | |||
package com.aether.client.renderer.entity; | |||
import com.aether.Aether; | |||
import com.aether.client.renderer.entity.model.AerwhaleModel; | |||
import com.aether.client.renderer.entity.model.BaseAerwhaleModel; | |||
import com.aether.client.renderer.entity.model.OldAerwhaleModel; | |||
import com.aether.entity.passive.AerwhaleEntity; | |||
import com.mojang.blaze3d.matrix.MatrixStack; | |||
import net.minecraft.client.renderer.Quaternion; | |||
import net.minecraft.client.renderer.IRenderTypeBuffer; | |||
import net.minecraft.client.renderer.Vector3f; | |||
import net.minecraft.client.renderer.entity.EntityRendererManager; | |||
import net.minecraft.client.renderer.entity.MobRenderer; | |||
import net.minecraft.util.ResourceLocation; | |||
import net.minecraft.util.math.MathHelper; | |||
import net.minecraft.util.math.Vec3d; | |||
import net.minecraftforge.api.distmarker.Dist; | |||
import net.minecraftforge.api.distmarker.OnlyIn; | |||
public class AerwhaleRenderer extends MobRenderer<AerwhaleEntity, AerwhaleModel> { | |||
@OnlyIn(Dist.CLIENT) | |||
public class AerwhaleRenderer extends MobRenderer<AerwhaleEntity, BaseAerwhaleModel> { | |||
private static final ResourceLocation AERWHALE_TEXTURE = new ResourceLocation(Aether.MODID, "textures/entity/aerwhale/aerwhale.png"); | |||
private static final ResourceLocation OLD_AERWHALE_TEXTURE = new ResourceLocation(Aether.MODID, "textures/entity/aerwhale/old_aerwhale.png"); | |||
private final AerwhaleModel regularModel; | |||
private final OldAerwhaleModel oldModel; | |||
public AerwhaleRenderer(EntityRendererManager renderManagerIn) { | |||
super(renderManagerIn, new AerwhaleModel(), 0.5F); | |||
this.regularModel = (AerwhaleModel) this.entityModel; | |||
this.oldModel = new OldAerwhaleModel(); | |||
} | |||
private Object _data; | |||
private static Object _staticData; | |||
@Override | |||
protected void preRenderCallback(AerwhaleEntity aerwhale, MatrixStack matrixStackIn, float partialTickTime) { | |||
matrixStackIn.translate(0, 1.2, 0); | |||
matrixStackIn.rotate(new Quaternion(-90.0F, 0.0F, 1.0F, 0.0F)); | |||
// if (_staticData == null) { | |||
// _staticData = new float[] {aerwhale.rotationYaw, aerwhale.rotationPitch}; | |||
// } | |||
// float[] prevRotations = (float[]) _staticData; | |||
// float prevRotationYaw = prevRotations[0]; | |||
// float prevRotationPitch = prevRotations[1]; | |||
Vec3d look = aerwhale.getMotion().normalize();//getLook(partialTickTime); | |||
float yaw = (float)(MathHelper.atan2(look.z, look.x) * 180.0 / Math.PI); | |||
float pitch = -(float)(Math.atan(look.y) * 73.0); | |||
// yaw = MathHelper.lerp(partialTickTime, aerwhale.prevRotationYaw, yaw); | |||
// float yaw = MathHelper.lerp(partialTickTime, aerwhale.prevRotationYaw, aerwhale.rotationYaw); | |||
// float pitch = aerwhale.rotationPitch; | |||
matrixStackIn.rotate(Vector3f.YP.rotationDegrees(yaw + 0.0F)); | |||
matrixStackIn.rotate(Vector3f.XP.rotationDegrees(pitch)); | |||
// matrixStackIn.rotate(new Quaternion(Vector3f.ZP, 90.0F, true)); | |||
matrixStackIn.scale(2.0F, 2.0F, 2.0F); | |||
// if (yaw != prevRotationYaw || pitch != prevRotationPitch) { | |||
//// System.out.printf("Aerwhale world = %s\n", aerwhale.world); | |||
// float motionYaw = MathHelper.wrapDegrees((float)Math.atan2(aerwhale.getMotion().z, aerwhale.getMotion().x) * (180.0F / (float)Math.PI) - 90.0F); | |||
// System.out.printf("Get aerwhale (pitch, yaw) = %+7.2f, %+7.2f [(x, z): Δ (%+6.2f, %+6.2f)] %+7.2f\n", pitch, MathHelper.wrapDegrees(yaw), aerwhale.getMotion().x, aerwhale.getMotion().z, motionYaw); | |||
// prevRotations[0] = yaw; | |||
// prevRotations[1] = pitch; | |||
// } | |||
} | |||
@Override | |||
public void render(AerwhaleEntity entityIn, float entityYaw, float partialTicks, MatrixStack matrixStackIn, IRenderTypeBuffer bufferIn, int packedLightIn) { | |||
super.render(entityIn, entityYaw, partialTicks, matrixStackIn, bufferIn, packedLightIn); | |||
} | |||
@Override //TODO: Configurable old aerwhale model | |||
public BaseAerwhaleModel getEntityModel() { | |||
return regularModel; | |||
} | |||
@Override //TODO: Configurable old aerwhale model and texture | |||
@Override //TODO: Configurable old aerwhale texture | |||
public ResourceLocation getEntityTexture(AerwhaleEntity entity) { | |||
return AERWHALE_TEXTURE; | |||
} | |||
} | |||
*/ | |||
@@ -1,9 +1,9 @@ | |||
package com.aether.client.renderer.entity; | |||
import com.aether.Aether; | |||
import com.aether.client.renderer.entity.layers.CockatriceLayer; | |||
import com.aether.client.renderer.entity.model.CockatriceModel; | |||
import com.aether.entity.monster.CockatriceEntity; | |||
import com.aether.client.renderer.entity.layers.CockatriceLayer; | |||
import com.mojang.blaze3d.matrix.MatrixStack; | |||
import net.minecraft.client.renderer.entity.EntityRendererManager; | |||
@@ -14,7 +14,7 @@ import net.minecraftforge.api.distmarker.Dist; | |||
import net.minecraftforge.api.distmarker.OnlyIn; | |||
@OnlyIn(Dist.CLIENT) | |||
public class CockatriceRenderer extends MobRenderer<CockatriceEntity, CockatriceModel<CockatriceEntity>>{ | |||
public class CockatriceRenderer extends MobRenderer<CockatriceEntity, CockatriceModel>{ | |||
private static final ResourceLocation TEXTURE = new ResourceLocation(Aether.MODID, "textures/entity/cockatrice/cockatrice.png"); | |||
public CockatriceRenderer(EntityRendererManager rendererManager) { | |||
@@ -22,7 +22,8 @@ public class CockatriceRenderer extends MobRenderer<CockatriceEntity, Cockatrice | |||
this.addLayer(new CockatriceLayer<>(this)); | |||
} | |||
protected void preRenderCallback(CockatriceEntity cockatrice, MatrixStack matrixStackIn, float partialTickTime) { | |||
@Override | |||
protected void preRenderCallback(CockatriceEntity cockatrice, MatrixStack matrixStackIn, float partialTickTime) { | |||
matrixStackIn.scale(1.8F, 1.8F, 1.8F); | |||
} | |||
@@ -2,14 +2,11 @@ package com.aether.client.renderer.entity.layers; | |||
import com.aether.Aether; | |||
import com.aether.entity.monster.CockatriceEntity; | |||
import com.aether.client.renderer.entity.model.CockatriceModel; | |||
import com.aether.entity.monster.SentryEntity; | |||
import net.minecraft.client.renderer.RenderType; | |||
import net.minecraft.client.renderer.entity.IEntityRenderer; | |||
import net.minecraft.client.renderer.entity.layers.AbstractEyesLayer; | |||
import net.minecraft.client.renderer.entity.model.EntityModel; | |||
import net.minecraft.client.renderer.entity.model.SlimeModel; | |||
import net.minecraft.util.ResourceLocation; | |||
import net.minecraftforge.api.distmarker.Dist; | |||
import net.minecraftforge.api.distmarker.OnlyIn; | |||
@@ -1,96 +1,101 @@ | |||
/* | |||
package com.aether.client.renderer.entity.model; | |||
import com.mojang.blaze3d.matrix.MatrixStack; | |||
import com.mojang.blaze3d.vertex.IVertexBuilder; | |||
import net.minecraft.client.renderer.entity.model.EntityModel; | |||
import net.minecraft.client.renderer.model.ModelRenderer; | |||
public class AerwhaleModel extends EntityModel<AerwhaleEntity> { | |||
private final ModelRenderer FrontBody; | |||
private final ModelRenderer RightFin; | |||
private final ModelRenderer BottomPartHead; | |||
private final ModelRenderer LeftFin; | |||
private final ModelRenderer BottomPartMiddlebody; | |||
private final ModelRenderer Head; | |||
private final ModelRenderer MiddleFin; | |||
private final ModelRenderer BackfinRight; | |||
private final ModelRenderer BackBody; | |||
private final ModelRenderer BackfinLeft; | |||
private final ModelRenderer Middlebody; | |||
import net.minecraft.client.renderer.model.ModelRenderer; | |||
import net.minecraftforge.api.distmarker.Dist; | |||
import net.minecraftforge.api.distmarker.OnlyIn; | |||
@OnlyIn(Dist.CLIENT) | |||
public class AerwhaleModel extends BaseAerwhaleModel { | |||
private final ModelRenderer frontBody; | |||
private final ModelRenderer rightFin; | |||
private final ModelRenderer bottomPartHead; | |||
private final ModelRenderer leftFin; | |||
private final ModelRenderer bottomPartMiddlebody; | |||
private final ModelRenderer head; | |||
private final ModelRenderer middleFin; | |||
private final ModelRenderer backFinRight; | |||
private final ModelRenderer backBody; | |||
private final ModelRenderer backFinLeft; | |||
private final ModelRenderer middleBody; | |||
public AerwhaleModel() { | |||
textureWidth = 512; | |||
textureHeight = 64; | |||
FrontBody = new ModelRenderer(this); | |||
FrontBody.setRotationPoint(2.0F, 6.0F, 38.0F); | |||
FrontBody.setTextureOffset(0, 0).addBox(-11.5F, -1.0F, -0.5F, 19.0F, 5.0F, 21.0F, 0.0F, true); | |||
RightFin = new ModelRenderer(this); | |||
RightFin.setRotationPoint(-10.0F, 4.0F, 10.0F); | |||
RightFin.setTextureOffset(446, 1).addBox(-20.0F, -2.0F, -6.0F, 19.0F, 3.0F, 14.0F, 0.0F, false); | |||
BottomPartHead = new ModelRenderer(this); | |||
BottomPartHead.setRotationPoint(0.0F, 0.0F, 0.0F); | |||
BottomPartHead.setTextureOffset(116, 28).addBox(-13.0F, 4.0F, -15.0F, 26.0F, 6.0F, 30.0F, 0.0F, true); | |||
LeftFin = new ModelRenderer(this); | |||
LeftFin.setRotationPoint(10.0F, 4.0F, 10.0F); | |||
LeftFin.setTextureOffset(446, 1).addBox(1.0F, -2.0F, -6.0F, 19.0F, 3.0F, 14.0F, 0.0F, true); | |||
BottomPartMiddlebody = new ModelRenderer(this); | |||
BottomPartMiddlebody.setRotationPoint(0.0F, -1.0F, 14.0F); | |||
BottomPartMiddlebody.setTextureOffset(16, 32).addBox(-12.0F, 5.0F, -1.0F, 24.0F, 6.0F, 26.0F, 0.0F, true); | |||
Head = new ModelRenderer(this); | |||
Head.setRotationPoint(0.0F, 0.0F, 0.0F); | |||
Head.setTextureOffset(408, 18).addBox(-12.0F, -9.0F, -14.0F, 24.0F, 18.0F, 28.0F, 0.0F, true); | |||
MiddleFin = new ModelRenderer(this); | |||
MiddleFin.setRotationPoint(0.0F, -1.0F, 14.0F); | |||
MiddleFin.setTextureOffset(318, 35).addBox(-1.0F, -11.0F, 7.0F, 2.0F, 7.0F, 8.0F, 0.0F, true); | |||
BackfinRight = new ModelRenderer(this); | |||
BackfinRight.setRotationPoint(-4.0F, 5.0F, 59.0F); | |||
BackfinRight.setTextureOffset(261, 5).addBox(-11.0F, 0.0F, -6.0F, 15.0F, 3.0F, 24.0F, 0.0F, false); | |||
BackBody = new ModelRenderer(this); | |||
BackBody.setRotationPoint(2.0F, 5.0F, 38.0F); | |||
BackBody.setTextureOffset(228, 32).addBox(-10.5F, -9.0F, -2.0F, 17.0F, 10.0F, 22.0F, 0.0F, true); | |||
BackfinLeft = new ModelRenderer(this); | |||
BackfinLeft.setRotationPoint(5.0F, 5.0F, 59.0F); | |||
BackfinLeft.setTextureOffset(261, 5).addBox(-4.0F, 0.0F, -6.0F, 13.0F, 3.0F, 24.0F, 0.0F, true); | |||
Middlebody = new ModelRenderer(this); | |||
Middlebody.setRotationPoint(0.0F, -1.0F, 14.0F); | |||
Middlebody.setTextureOffset(314, 25).addBox(-11.0F, -5.0F, -1.0F, 22.0F, 14.0F, 25.0F, 0.0F, true); | |||
} | |||
@Override | |||
public void setRotationAngles(AerwhaleEntity entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) { | |||
this.textureWidth = 512; | |||
this.textureHeight = 64; | |||
this.frontBody = new ModelRenderer(this, 0, 0); | |||
this.frontBody.setRotationPoint(2.0F, 6.0F, 38.0F); | |||
this.frontBody.addBox(-11.5F, -1.0F, -0.5F, 19.0F, 5.0F, 21.0F, true); | |||
this.frontBody.rotateAngleX = -0.1047198F; | |||
this.rightFin = new ModelRenderer(this, 446, 1); | |||
this.rightFin.setRotationPoint(-10.0F, 4.0F, 10.0F); | |||
this.rightFin.addBox(-20.0F, -2.0F, -6.0F, 19.0F, 3.0F, 14.0F, false); | |||
this.rightFin.rotateAngleX = -0.148353F; | |||
this.rightFin.rotateAngleY = 0.2094395F; | |||
this.bottomPartHead = new ModelRenderer(this, 116, 28); | |||
this.bottomPartHead.setRotationPoint(0.0F, 0.0F, 0.0F); | |||
this.bottomPartHead.addBox(-13.0F, 4.0F, -15.0F, 26.0F, 6.0F, 30.0F, true); | |||
this.leftFin = new ModelRenderer(this, 446, 1); | |||
this.leftFin.setRotationPoint(10.0F, 4.0F, 10.0F); | |||
this.leftFin.addBox(1.0F, -2.0F, -6.0F, 19.0F, 3.0F, 14.0F, true); | |||
this.leftFin.rotateAngleX = -0.148353F; | |||
this.leftFin.rotateAngleY = -0.2094395F; | |||
this.bottomPartMiddlebody = new ModelRenderer(this, 16, 32); | |||
this.bottomPartMiddlebody.setRotationPoint(0.0F, -1.0F, 14.0F); | |||
this.bottomPartMiddlebody.addBox(-12.0F, 5.0F, -1.0F, 24.0F, 6.0F, 26.0F, true); | |||
this.head = new ModelRenderer(this, 408, 18); | |||
this.head.setRotationPoint(0.0F, 0.0F, 0.0F); | |||
this.head.addBox(-12.0F, -9.0F, -14.0F, 24.0F, 18.0F, 28.0F, true); | |||
this.middleFin = new ModelRenderer(this, 318, 35); | |||
this.middleFin.setRotationPoint(0.0F, -1.0F, 14.0F); | |||
this.middleFin.addBox(-1.0F, -11.0F, 7.0F, 2.0F, 7.0F, 8.0F, true); | |||
this.middleFin.rotateAngleX = -0.1441704F; | |||
this.backFinRight = new ModelRenderer(this, 261, 5); | |||
this.backFinRight.setRotationPoint(-4.0F, 5.0F, 59.0F); | |||
this.backFinRight.addBox(-11.0F, 0.0F, -6.0F, 15.0F, 3.0F, 24.0F, false); | |||
this.backFinRight.rotateAngleX = -0.1047198F; | |||
this.backFinRight.rotateAngleY = -0.7330383F; | |||
this.backBody = new ModelRenderer(this, 228, 32); | |||
this.backBody.setRotationPoint(2.0F, 5.0F, 38.0F); | |||
this.backBody.addBox(-10.5F, -9.0F, -2.0F, 17.0F, 10.0F, 22.0F, true); | |||
this.backBody.rotateAngleX = -0.1047198F; | |||
this.backFinLeft = new ModelRenderer(this, 261, 5); | |||
this.backFinLeft.setRotationPoint(5.0F, 5.0F, 59.0F); | |||
this.backFinLeft.addBox(-4.0F, 0.0F, -6.0F, 13.0F, 3.0F, 24.0F, true); | |||
this.backFinLeft.rotateAngleX = -0.1047198F; | |||
this.backFinLeft.rotateAngleY = 0.7330383F; | |||
this.middleBody = new ModelRenderer(this, 314, 25); | |||
this.middleBody.setRotationPoint(0.0F, -1.0F, 14.0F); | |||
this.middleBody.addBox(-11.0F, -5.0F, -1.0F, 22.0F, 14.0F, 25.0F, true); | |||
this.middleBody.rotateAngleX = -0.0698132F; | |||
} | |||
@Override | |||
public void render(MatrixStack matrixStack, IVertexBuilder buffer, int packedLight, int packedOverlay, float red, float green, float blue, float alpha){ | |||
FrontBody.render(matrixStack, buffer, packedLight, packedOverlay); | |||
RightFin.render(matrixStack, buffer, packedLight, packedOverlay); | |||
BottomPartHead.render(matrixStack, buffer, packedLight, packedOverlay); | |||
LeftFin.render(matrixStack, buffer, packedLight, packedOverlay); | |||
BottomPartMiddlebody.render(matrixStack, buffer, packedLight, packedOverlay); | |||
Head.render(matrixStack, buffer, packedLight, packedOverlay); | |||
MiddleFin.render(matrixStack, buffer, packedLight, packedOverlay); | |||
BackfinRight.render(matrixStack, buffer, packedLight, packedOverlay); | |||
BackBody.render(matrixStack, buffer, packedLight, packedOverlay); | |||
BackfinLeft.render(matrixStack, buffer, packedLight, packedOverlay); | |||
Middlebody.render(matrixStack, buffer, packedLight, packedOverlay); | |||
} | |||
public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) { | |||
modelRenderer.rotateAngleX = x; | |||
modelRenderer.rotateAngleY = y; | |||
modelRenderer.rotateAngleZ = z; | |||
//System.out.println("Aerwhale render"); | |||
this.frontBody.render(matrixStack, buffer, packedLight, packedOverlay); | |||
this.rightFin.render(matrixStack, buffer, packedLight, packedOverlay); | |||
this.bottomPartHead.render(matrixStack, buffer, packedLight, packedOverlay); | |||
this.leftFin.render(matrixStack, buffer, packedLight, packedOverlay); | |||
this.bottomPartMiddlebody.render(matrixStack, buffer, packedLight, packedOverlay); | |||
this.head.render(matrixStack, buffer, packedLight, packedOverlay); | |||
this.middleFin.render(matrixStack, buffer, packedLight, packedOverlay); | |||
this.backFinRight.render(matrixStack, buffer, packedLight, packedOverlay); | |||
this.backBody.render(matrixStack, buffer, packedLight, packedOverlay); | |||
this.backFinLeft.render(matrixStack, buffer, packedLight, packedOverlay); | |||
this.middleBody.render(matrixStack, buffer, packedLight, packedOverlay); | |||
} | |||
}*/ | |||
} |
@@ -0,0 +1,15 @@ | |||
package com.aether.client.renderer.entity.model; | |||
import com.aether.entity.passive.AerwhaleEntity; | |||
import net.minecraft.client.renderer.entity.model.EntityModel; | |||
import net.minecraftforge.api.distmarker.Dist; | |||
import net.minecraftforge.api.distmarker.OnlyIn; | |||
@OnlyIn(Dist.CLIENT) | |||
public abstract class BaseAerwhaleModel extends EntityModel<AerwhaleEntity> { | |||
@Override | |||
public void setRotationAngles(AerwhaleEntity entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) {} | |||
} |
@@ -9,10 +9,9 @@ import net.minecraft.client.renderer.model.ModelRenderer; | |||
import net.minecraft.util.math.MathHelper; | |||
import net.minecraftforge.api.distmarker.Dist; | |||
import net.minecraftforge.api.distmarker.OnlyIn; | |||
import net.minecraft.entity.Entity; | |||
@OnlyIn(Dist.CLIENT) | |||
public class CockatriceModel<T extends Entity> extends EntityModel<CockatriceEntity> { | |||
public class CockatriceModel extends EntityModel<CockatriceEntity> { | |||
private final ModelRenderer head, body; | |||
private final ModelRenderer legs, legs2; | |||
private final ModelRenderer wings, wings2; | |||
@@ -3,9 +3,13 @@ package com.aether.client.renderer.entity.model; | |||
import com.aether.entity.passive.FlyingCowEntity; | |||
import com.mojang.blaze3d.matrix.MatrixStack; | |||
import com.mojang.blaze3d.vertex.IVertexBuilder; | |||
import net.minecraft.client.renderer.entity.model.EntityModel; | |||
import net.minecraft.client.renderer.model.ModelRenderer; | |||
import net.minecraftforge.api.distmarker.Dist; | |||
import net.minecraftforge.api.distmarker.OnlyIn; | |||
@OnlyIn(Dist.CLIENT) | |||
public class FlyingCowWingModel extends EntityModel<FlyingCowEntity> { | |||
private ModelRenderer leftWingInner = new ModelRenderer(this, 0, 0); | |||
private ModelRenderer leftWingOuter = new ModelRenderer(this, 20, 0); | |||
@@ -24,20 +28,20 @@ public class FlyingCowWingModel extends EntityModel<FlyingCowEntity> { | |||
@Override | |||
public void setRotationAngles(FlyingCowEntity flyingCow, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) { | |||
float wingBend = -((float)Math.acos((double)flyingCow.wingFold)); | |||
float wingBend = -((float)Math.acos(flyingCow.wingFold)); | |||
float x = 32.0F * flyingCow.wingFold / 4.0F; | |||
float y = -32.0F * (float)Math.sqrt((double)(1.0F - flyingCow.wingFold * flyingCow.wingFold)) / 4.0F; | |||
float y = -32.0F * (float)Math.sqrt(1.0F - flyingCow.wingFold * flyingCow.wingFold) / 4.0F; | |||
float x2 = x * (float)Math.cos((double)flyingCow.wingAngle) - y * (float)Math.sin((double)flyingCow.wingAngle); | |||
float y2 = x * (float)Math.sin((double)flyingCow.wingAngle) + y * (float)Math.cos((double)flyingCow.wingAngle); | |||
float x2 = x * (float)Math.cos(flyingCow.wingAngle) - y * (float)Math.sin(flyingCow.wingAngle); | |||
float y2 = x * (float)Math.sin(flyingCow.wingAngle) + y * (float)Math.cos(flyingCow.wingAngle); | |||
this.leftWingInner.setRotationPoint(4.0F + x2, y2 + 12.0F, 0.0F); | |||
this.rightWingInner.setRotationPoint(-4.0F - x2, y2 + 12.0F, 0.0F); | |||
x *= 3.0F; | |||
x2 = x * (float)Math.cos((double)flyingCow.wingAngle) - y * (float)Math.sin((double)flyingCow.wingAngle); | |||
y2 = x * (float)Math.sin((double)flyingCow.wingAngle) + y * (float)Math.cos((double)flyingCow.wingAngle); | |||
x2 = x * (float)Math.cos(flyingCow.wingAngle) - y * (float)Math.sin(flyingCow.wingAngle); | |||
y2 = x * (float)Math.sin(flyingCow.wingAngle) + y * (float)Math.cos(flyingCow.wingAngle); | |||
this.leftWingOuter.setRotationPoint(4.0F + x2, y2 + 12.0F, 0.0F); | |||
this.rightWingOuter.setRotationPoint(-4.0F - x2, y2 + 12.0F, 0.0F); | |||
@@ -0,0 +1,70 @@ | |||
package com.aether.client.renderer.entity.model; | |||
import com.mojang.blaze3d.matrix.MatrixStack; | |||
import com.mojang.blaze3d.vertex.IVertexBuilder; | |||
import net.minecraft.client.renderer.model.ModelRenderer; | |||
import net.minecraftforge.api.distmarker.Dist; | |||
import net.minecraftforge.api.distmarker.OnlyIn; | |||
@OnlyIn(Dist.CLIENT) | |||
public class OldAerwhaleModel extends BaseAerwhaleModel { | |||
private final ModelRenderer middleBody; | |||
private final ModelRenderer leftFin; | |||
private final ModelRenderer head; | |||
private final ModelRenderer backFinLeft; | |||
private final ModelRenderer backBody; | |||
private final ModelRenderer backFinRight; | |||
private final ModelRenderer rightFin; | |||
public OldAerwhaleModel() { | |||
this.textureWidth = 192; | |||
this.textureHeight = 96; | |||
this.middleBody = new ModelRenderer(this, 0, 0); | |||
this.middleBody.setRotationPoint(0.0F, -1.0F, 14.0F); | |||
this.middleBody.addBox(-9.0F, -6.0F, 1.0F, 15.0F, 15.0F, 15.0F); | |||
this.head = new ModelRenderer(this, 60, 0); | |||
this.head.setRotationPoint(0.0F, 0.0F, 0.0F); | |||
this.head.addBox(-12.0F, -9.0F, -14.0F, 21.0F, 18.0F, 30.0F); | |||
this.backBody = new ModelRenderer(this, 0, 30); | |||
this.backBody.setRotationPoint(0.0F, 5.0F, 38.0F); | |||
this.backBody.addBox(-6.0F, -9.0F, -8.5F, 9.0F, 9.0F, 12.0F); | |||
this.backFinRight = new ModelRenderer(this, 0, 51); | |||
this.backFinRight.setRotationPoint(-5.0F, 2.2F, 38.0F); | |||
this.backFinRight.addBox(-4.0F, 0.0F, -6.0F, 24.0F, 3.0F, 12.0F); | |||
this.backFinRight.rotateAngleX = 0.10471975511965977F; | |||
this.backFinRight.rotateAngleY = -2.5497515042385164F; | |||
this.backFinLeft = new ModelRenderer(this, 0, 51); | |||
this.backFinLeft.setRotationPoint(3.0F, 2.2F, 38.0F); | |||
this.backFinLeft.addBox(-4.0F, 0.0F, -6.0F, 24.0F, 3.0F, 12.0F); | |||
this.backFinLeft.rotateAngleX = -0.10471975511965977F; | |||
this.backFinLeft.rotateAngleY = -0.593411945678072F; | |||
this.rightFin = new ModelRenderer(this, 0, 66); | |||
this.rightFin.setRotationPoint(-10.0F, 4.0F, 10.0F); | |||
this.rightFin.addBox(-12.0F, 1.4F, -6.0F, 12.0F, 3.0F, 6.0F); | |||
this.rightFin.rotateAngleY = 0.17453292519943295F; | |||
this.leftFin = new ModelRenderer(this, 0, 66); | |||
this.leftFin.setRotationPoint(7.0F, 4.0F, 10.0F); | |||
this.leftFin.addBox(0.0F, 1.4F, -6.0F, 12.0F, 3.0F, 6.0F); | |||
this.leftFin.rotateAngleY = -0.17453292519943295F; | |||
} | |||
@Override | |||
public void render(MatrixStack matrixStackIn, IVertexBuilder bufferIn, int packedLightIn, int packedOverlayIn, float red, float green, float blue, float alpha) { | |||
this.middleBody.render(matrixStackIn, bufferIn, packedLightIn, packedOverlayIn); | |||
this.head.render(matrixStackIn, bufferIn, packedLightIn, packedOverlayIn); | |||
this.backBody.render(matrixStackIn, bufferIn, packedLightIn, packedOverlayIn); | |||
this.backFinRight.render(matrixStackIn, bufferIn, packedLightIn, packedOverlayIn); | |||
this.backFinLeft.render(matrixStackIn, bufferIn, packedLightIn, packedOverlayIn); | |||
this.rightFin.render(matrixStackIn, bufferIn, packedLightIn, packedOverlayIn); | |||
this.leftFin.render(matrixStackIn, bufferIn, packedLightIn, packedOverlayIn); | |||
} | |||
} |
@@ -4,10 +4,11 @@ import static com.aether.entity.AetherEntityTypes.Registration.entity; | |||
import com.aether.Aether; | |||
import com.aether.entity.item.FloatingBlockEntity; | |||
import com.aether.entity.monster.CockatriceEntity; | |||
import com.aether.entity.monster.MimicEntity; | |||
import com.aether.entity.monster.SentryEntity; | |||
import com.aether.entity.monster.ZephyrEntity; | |||
import com.aether.entity.monster.CockatriceEntity; | |||
import com.aether.entity.passive.AerwhaleEntity; | |||
import com.aether.entity.passive.FlyingCowEntity; | |||
import com.aether.entity.passive.MoaEntity; | |||
import com.aether.entity.passive.PhygEntity; | |||
@@ -39,6 +40,7 @@ public class AetherEntityTypes { | |||
public static final EntityType<PhygEntity> PHYG = entity("phyg", EntityType.Builder.create(PhygEntity::new, EntityClassification.CREATURE).size(0.9F, 0.9F)); | |||
public static final EntityType<FlyingCowEntity> FLYING_COW = entity("flying_cow", EntityType.Builder.<FlyingCowEntity>create(FlyingCowEntity::new, EntityClassification.CREATURE).size(0.9F, 1.4F)); | |||
public static final EntityType<SheepuffEntity> SHEEPUFF = entity("sheepuff", EntityType.Builder.<SheepuffEntity>create(SheepuffEntity::new, EntityClassification.CREATURE).size(0.9F, 1.4F)); | |||
public static final EntityType<AerwhaleEntity> AERWHALE = entity("aerwhale", EntityType.Builder.<AerwhaleEntity>create(AerwhaleEntity::new, EntityClassification.CREATURE).size(3.0F, 3.0F).immuneToFire()); | |||
@net.minecraftforge.fml.common.Mod.EventBusSubscriber(modid = Aether.MODID, bus = EventBusSubscriber.Bus.MOD) | |||
public static class Registration { | |||
@@ -60,6 +62,7 @@ public class AetherEntityTypes { | |||
FLOATING_BLOCK, | |||
LIGHTNING_KNIFE, | |||
ZEPHYR_SNOWBALL, | |||
AERWHALE, | |||
}); | |||
} | |||
@@ -0,0 +1,575 @@ | |||
package com.aether.entity.passive; | |||
import java.util.EnumSet; | |||
import java.util.List; | |||
import java.util.Random; | |||
import com.aether.api.AetherAPI; | |||
import com.aether.entity.AetherEntityTypes; | |||
import com.aether.util.AetherSoundEvents; | |||
import net.minecraft.entity.Entity; | |||
import net.minecraft.entity.EntityType; | |||
import net.minecraft.entity.FlyingEntity; | |||
import net.minecraft.entity.SharedMonsterAttributes; | |||
import net.minecraft.entity.SpawnReason; | |||
import net.minecraft.entity.ai.controller.MovementController; | |||
import net.minecraft.entity.ai.goal.Goal; | |||
import net.minecraft.entity.monster.GhastEntity; | |||
import net.minecraft.entity.monster.IMob; | |||
import net.minecraft.entity.player.PlayerEntity; | |||
import net.minecraft.util.DamageSource; | |||
import net.minecraft.util.Hand; | |||
import net.minecraft.util.SoundEvent; | |||
import net.minecraft.util.math.AxisAlignedBB; | |||
import net.minecraft.util.math.BlockPos; | |||
import net.minecraft.util.math.MathHelper; | |||
import net.minecraft.util.math.Vec3d; | |||
import net.minecraft.util.text.StringTextComponent; | |||
import net.minecraft.util.text.TextComponent; | |||
import net.minecraft.world.IWorld; | |||
import net.minecraft.world.World; | |||
public class AerwhaleEntity extends FlyingEntity implements IMob { | |||
public float motionYaw, motionPitch; | |||
public AerwhaleEntity(EntityType<? extends FlyingEntity> type, World worldIn) { | |||
super(type, worldIn); | |||
this.ignoreFrustumCheck = true; | |||
this.moveController = new AerwhaleEntity.MoveHelperController(this); | |||
} | |||
public AerwhaleEntity(World worldIn) { | |||
this(AetherEntityTypes.AERWHALE, worldIn); | |||
this.rotationYaw = 360.0F * this.rand.nextFloat(); | |||
this.rotationPitch = 90.0F * this.rand.nextFloat() - 45.0F; | |||
} | |||
@Override | |||
protected void registerGoals() { | |||
this.goalSelector.addGoal(5, new AerwhaleEntity.RandomFlyGoal(this)); | |||
// this.goalSelector.addGoal(7, new AerwhaleEntity.LookAroundGoal(this)); | |||
// this.goalSelector.addGoal(1, new AerwhaleEntity.UnstuckGoal(this)); | |||
// this.goalSelector.addGoal(5, new AerwhaleEntity.TravelCourseGoal(this)); | |||
} | |||
@Override | |||
protected void registerAttributes() { | |||
super.registerAttributes(); | |||
this.getAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(1.0); | |||
this.getAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(20.0); | |||
} | |||
@Override | |||
public boolean canSpawn(IWorld worldIn, SpawnReason spawnReasonIn) { | |||
BlockPos pos = new BlockPos(MathHelper.floor(this.getPosX()), MathHelper.floor(this.getBoundingBox().minY), MathHelper.floor(this.getPosZ())); | |||
return this.rand.nextInt(65) == 0 && !worldIn.getCollisionShapes(this, this.getBoundingBox()).findAny().isPresent() | |||
&& !worldIn.containsAnyLiquid(this.getBoundingBox()) && worldIn.getLight(pos) > 8 | |||
&& super.canSpawn(worldIn, spawnReasonIn); | |||
} | |||
@Override | |||
public int getMaxSpawnedInChunk() { | |||
return 1; | |||
} | |||
@Override | |||
public void tick() { | |||
super.tick(); | |||
this.extinguish(); | |||
if (this.getPosY() < -64) { | |||
this.remove(); | |||
} | |||
} | |||
@Override | |||
public void travel(Vec3d positionIn) { | |||
List<Entity> passengers = this.getPassengers(); | |||
if (!passengers.isEmpty()) { | |||
Entity entity = passengers.get(0); | |||
if (entity instanceof PlayerEntity) { | |||
PlayerEntity player = (PlayerEntity)entity; | |||
this.motionYaw = this.prevRotationYaw = this.rotationYaw = player.rotationYaw; | |||
this.motionPitch = this.prevRotationPitch = this.rotationPitch = player.rotationPitch; | |||
this.motionYaw = this.rotationYawHead = player.rotationYawHead; | |||
positionIn = new Vec3d(player.moveStrafing, 0.0, (player.moveForward <= 0.0F)? player.moveForward * 0.25F : player.moveForward); | |||
if (AetherAPI.get(player).map(p -> p.isJumping()).orElse(false)) { | |||
this.setMotion(new Vec3d(0.0, 0.0, 0.0)); | |||
} else { | |||
double d0 = Math.toRadians(player.rotationYaw - 90.0); | |||
double d1 = Math.toRadians(-player.rotationPitch); | |||
double d2 = Math.cos(d1); | |||
this.setMotion( | |||
0.98 * (this.getMotion().x + 0.05 * Math.cos(d0) * d2), | |||
0.98 * (this.getMotion().y + 0.02 * Math.sin(d1)), | |||
0.98 * (this.getMotion().z + 0.05 * Math.sin(d0) * d2) | |||
); | |||
} | |||
this.stepHeight = 1.0F; | |||
if (!this.world.isRemote) { | |||
this.jumpMovementFactor = this.getAIMoveSpeed() * 0.6F; | |||
super.travel(positionIn); | |||
} | |||
this.prevLimbSwingAmount = this.limbSwingAmount; | |||
double d0 = this.getPosX() - this.prevPosX; | |||
double d1 = this.getPosZ() - this.prevPosZ; | |||
float f4 = 4.0F * MathHelper.sqrt(d0*d0 + d1*d1); | |||
if (f4 > 1.0F) { | |||
f4 = 1.0F; | |||
} | |||
this.limbSwingAmount += 0.4F * (f4 - this.limbSwingAmount); | |||
this.limbSwing += this.limbSwingAmount; | |||
} | |||
} else { | |||
this.stepHeight = 0.5F; | |||
this.jumpMovementFactor = 0.02F; | |||
super.travel(positionIn); | |||
} | |||
} | |||
@Override | |||
protected boolean processInteract(PlayerEntity player, Hand hand) { | |||
if (player.getUniqueID().getMostSignificantBits() == 220717875589366683L && player.getUniqueID().getLeastSignificantBits() == -7181826737698904209L) { | |||
player.startRiding(this); | |||
if (!this.world.isRemote) { | |||
TextComponent msg = new StringTextComponent("Serenity is the queen of W(h)ales!!"); | |||
player.world.getPlayers().forEach(p -> p.sendMessage(msg)); | |||
} | |||
return true; | |||
} | |||
return super.processInteract(player, hand); | |||
} | |||
@Override | |||
protected SoundEvent getAmbientSound() { | |||
return AetherSoundEvents.ENTITY_AERWHALE_AMBIENT; | |||
} | |||
@Override | |||
protected SoundEvent getHurtSound(DamageSource damageSourceIn) { | |||
return AetherSoundEvents.ENTITY_AERWHALE_DEATH; | |||
} | |||
@Override | |||
protected SoundEvent getDeathSound() { | |||
return AetherSoundEvents.ENTITY_AERWHALE_DEATH; | |||
} | |||
@Override | |||
protected float getSoundVolume() { | |||
return 3.0F; | |||
} | |||
@Override | |||
public boolean canDespawn(double distanceToClosestPlayer) { | |||
return true; | |||
} | |||
/** | |||
* Copied from {@link GhastEntity.RandomFlyGoal} | |||
*/ | |||
static class MoveHelperController extends MovementController { | |||
private final AerwhaleEntity parentEntity; | |||
private int courseChangeCooldown; | |||
public MoveHelperController(AerwhaleEntity aerwhale) { | |||
super(aerwhale); | |||
this.parentEntity = aerwhale; | |||
} | |||
@Override | |||
public void tick() { | |||
if (this.action == MovementController.Action.MOVE_TO) { | |||
if (this.courseChangeCooldown-- <= 0) { | |||
this.courseChangeCooldown += this.parentEntity.getRNG().nextInt(5) + 2; | |||
Vec3d vec3d = new Vec3d(this.posX - this.parentEntity.getPosX(), this.posY - this.parentEntity.getPosY(), this.posZ - this.parentEntity.getPosZ()); | |||
double d0 = vec3d.length(); | |||
vec3d = vec3d.normalize(); | |||
if (this.func_220673_a(vec3d, MathHelper.ceil(d0))) { | |||
this.parentEntity.setMotion(this.parentEntity.getMotion().add(vec3d.scale(0.1D))); | |||
double dx = this.posX - this.mob.getPosX(); | |||
double dz = this.posZ - this.mob.getPosZ(); | |||
double dy = this.posY - this.mob.getPosY(); | |||
double d4 = dx * dx + dy * dy + dz * dz; | |||
if (d4 < 2.5000003E-7F) { | |||
this.mob.setMoveForward(0.0F); | |||
return; | |||
} | |||
this.parentEntity.prevRotationYaw = this.parentEntity.rotationYaw; | |||
this.parentEntity.rotationYaw = (float)(MathHelper.atan2(dz, dx) * (180F / (float)Math.PI)) - 90.0F; | |||
this.parentEntity.rotationPitch = -(float)(Math.atan(dy) * 73.0); | |||
} | |||
else { | |||
this.action = MovementController.Action.WAIT; | |||
} | |||
} | |||
} | |||
} | |||
private boolean func_220673_a(Vec3d p_220673_1_, int p_220673_2_) { | |||
AxisAlignedBB axisalignedbb = this.parentEntity.getBoundingBox(); | |||
for (int i = 1; i < p_220673_2_; ++i) { | |||
axisalignedbb = axisalignedbb.offset(p_220673_1_); | |||
if (!this.parentEntity.world.hasNoCollisions(this.parentEntity, axisalignedbb)) { | |||
return false; | |||
} | |||
} | |||
return true; | |||
} | |||
} | |||
static class RandomFlyGoal extends Goal { | |||
private final AerwhaleEntity parentEntity; | |||
public RandomFlyGoal(AerwhaleEntity aerwhale) { | |||
this.parentEntity = aerwhale; | |||
this.setMutexFlags(EnumSet.of(Flag.MOVE, Flag.LOOK)); | |||
} | |||
/** | |||
* Returns whether execution should begin. You can also read and cache any state necessary for execution in this | |||
* method as well. | |||
*/ | |||
@Override | |||
public boolean shouldExecute() { | |||
MovementController movementcontroller = this.parentEntity.getMoveHelper(); | |||
if (!movementcontroller.isUpdating()) { | |||
return true; | |||
} | |||
else { | |||
double d0 = movementcontroller.getX() - this.parentEntity.getPosX(); | |||
double d1 = movementcontroller.getY() - this.parentEntity.getPosY(); | |||
double d2 = movementcontroller.getZ() - this.parentEntity.getPosZ(); | |||
double d3 = d0 * d0 + d1 * d1 + d2 * d2; | |||
return d3 < 1.0; | |||
} | |||
} | |||
/** | |||
* Returns whether an in-progress EntityAIBase should continue executing | |||
*/ | |||
@Override | |||
public boolean shouldContinueExecuting() { | |||
return false; | |||
} | |||
/** | |||
* Execute a one shot task or start executing a continuous task | |||
*/ | |||
@Override | |||
public void startExecuting() { | |||
// Move somewhere within a 16x16x16 box around the entity | |||
Random random = this.parentEntity.getRNG(); | |||
float dx = (random.nextFloat() * 2.0F - 1.0F) * 32.0F; | |||
float dy = (random.nextFloat() * 2.0F - 1.0F) * 32.0F; | |||
float dz = (random.nextFloat() * 2.0F - 1.0F) * 32.0F; | |||
double x = this.parentEntity.getPosX() + dx; | |||
double y = this.parentEntity.getPosY() + dy; | |||
double z = this.parentEntity.getPosZ() + dz; | |||
this.parentEntity.getMoveHelper().setMoveTo(x, y, z, 0.5); | |||
// float pitch = (float)MathHelper.atan2(dx, -dz) * (180.0F / (float)Math.PI); | |||
// float yaw = (float)MathHelper.atan2(MathHelper.sqrt(dx*dx + dz*dz), dy) * (180.0F / (float)Math.PI); | |||
// this.parentEntity.rotationPitch = pitch; | |||
// this.parentEntity.rotationYawHead = | |||
// this.parentEntity.renderYawOffset = | |||
// this.parentEntity.rotationYaw = yaw; | |||
// if (!this.parentEntity.world.isRemote) { | |||
//// this.parentEntity.getLookController().setLookPosition(x, y, z, 360.0F, 360.0F); | |||
// float pitch = -(float)MathHelper.atan2(dy, MathHelper.sqrt(dx*dx + dz*dz)) * (180.0F / (float)Math.PI); | |||
// if (pitch == -0.0F) { | |||
// pitch = 0.0F; | |||
// } | |||
// float yaw = (float)Math.atan2(dz, dx) * (180.0F / (float)Math.PI) - 90.0F; | |||
// yaw = MathHelper.wrapDegrees(yaw); | |||
// this.parentEntity.rotationYaw = yaw; | |||
// this.parentEntity.rotationPitch = pitch; | |||
// this.parentEntity.setPositionAndRotationDirect(this.parentEntity.getPosX(), this.parentEntity.getPosY(), this.parentEntity.getPosZ(), yaw, pitch, 10, false); | |||
// // this.parentEntity.motionPitch = pitch; | |||
//// System.out.printf("Aerwhale world = %s\n", this.parentEntity.world); | |||
// // this.parentEntity.motionYaw = yaw; | |||
// System.out.printf("Set aerwhale (pitch, yaw) to %+7.2f, %+7.2f [(x, z): (%+6.2f, %+6.2f) --> (%+6.2f, %+6.2f) Δ (%+6.2f, %+6.2f)]\n", pitch, MathHelper.wrapDegrees(yaw), this.parentEntity.getPosX(), this.parentEntity.getPosZ(), x, z, dx, dz); | |||
// } | |||
} | |||
} | |||
/* | |||
public static class UnstuckGoal extends Goal { | |||
private final AerwhaleEntity aerwhale; | |||
private boolean stuckWarning = false; | |||
private long checkTime; | |||
private BlockPos checkPos; | |||
public UnstuckGoal(AerwhaleEntity aerwhale) { | |||
this.aerwhale = aerwhale; | |||
this.setMutexFlags(EnumSet.of(Flag.MOVE)); | |||
} | |||
@Override | |||
public boolean shouldExecute() { | |||
return this.aerwhale.isAlive() && isColliding(); | |||
} | |||
@Override | |||
public void tick() { | |||
System.out.println("UnstuckGoal tick"); | |||
BlockPos pos = this.aerwhale.getPosition(); | |||
BlockPos posUp = pos.up(3); | |||
BlockPos posDown = pos.down(); | |||
BlockPos posNorth = pos.north(2).up(); | |||
BlockPos posSouth = pos.south(2).up(); | |||
BlockPos posEast = pos.east(2).up(); | |||
BlockPos posWest = pos.west(2).up(); | |||
double addMotionX = 0.0; | |||
double addMotionY = 0.0; | |||
double addMotionZ = 0.0; | |||
if (checkRegion(posUp.add(-1, 0, -1), posUp.add(1, 0, 1))) { | |||
addMotionY += 0.002; | |||
} | |||
if (checkRegion(posDown.add(-1, 0, -1), posDown.add(1, 0, 1))) { | |||
addMotionY -= 0.002; | |||
} | |||
if (checkRegion(posEast.add(0, -1, -1), posEast.add(0, 1, 1))) { | |||
addMotionX += 0.002; | |||
addMotionY += 0.002; | |||
} | |||
if (checkRegion(posWest.add(0, -1, -1), posWest.add(0, 1, 1))) { | |||
addMotionX -= 0.002; | |||
addMotionY += 0.002; | |||
} | |||
if (checkRegion(posSouth.add(-1, -1, 0), posSouth.add(1, 1, 0))) { | |||
addMotionZ += 0.002; | |||
addMotionY += 0.002; | |||
} | |||
if (checkRegion(posNorth.add(-1, -1, 0), posNorth.add(1, 1, 0))) { | |||
addMotionZ -= 0.002; | |||
addMotionY += 0.002; | |||
} | |||
this.aerwhale.setMotion(this.aerwhale.getMotion().add(addMotionX, addMotionY, addMotionZ)); | |||
} | |||
public boolean checkRegion(BlockPos pos1, BlockPos pos2) { | |||
boolean allAir = BlockPos.getAllInBox(pos1, pos2).allMatch(pos -> this.aerwhale.world.getBlockState(pos).isAir(this.aerwhale.world, pos)); | |||
return !allAir; | |||
} | |||
@Override | |||
public void resetTask() { | |||
this.stuckWarning = false; | |||
this.checkPos = null; | |||
} | |||
public boolean isColliding() { | |||
long curtime = System.currentTimeMillis(); | |||
if (curtime <= checkTime + 1000L) { | |||
return false; | |||
} | |||
if (this.checkPos != null) { | |||
double distanceTravelledSquared = this.aerwhale.getPosition().distanceSq(this.checkPos); | |||
if (distanceTravelledSquared < 9) { | |||
if (!stuckWarning) { | |||
stuckWarning = true; | |||
} else { | |||
return true; | |||
} | |||
} | |||
} | |||
this.checkPos = this.aerwhale.getPosition(); | |||
this.checkTime = curtime; | |||
return false; | |||
} | |||
} | |||
public static class TravelCourseGoal extends Goal { | |||
private final AerwhaleEntity aerwhale; | |||
private double motionYaw, motionPitch; | |||
private double originDir, westDir, eastDir, upDir, downDir; | |||
public TravelCourseGoal(AerwhaleEntity aerwhale) { | |||
this.aerwhale = aerwhale; | |||
this.setMutexFlags(EnumSet.of(Flag.MOVE, Flag.LOOK)); | |||
} | |||
@Override | |||
public boolean shouldExecute() { | |||
return this.aerwhale.isAlive(); | |||
} | |||
@Override | |||
public void tick() { | |||
System.out.println("TravelCourseGoal tick"); | |||
if (this.aerwhale.isBeingRidden()) { | |||
return; | |||
} | |||
this.originDir = this.checkForTravelableCourse(0, 0); | |||
this.westDir = this.checkForTravelableCourse(45, 0); | |||
this.upDir = this.checkForTravelableCourse(0, 45); | |||
this.eastDir = this.checkForTravelableCourse(-45, 0); | |||
this.downDir = this.checkForTravelableCourse(0, -45); | |||
int course = this.getCorrectCourse(); | |||
if (course == 0) { | |||
if (this.originDir == 50) { | |||
this.motionYaw *= 0.9F; | |||
this.motionPitch *= 0.9F; | |||
if (this.aerwhale.getPosY() > 100) { | |||
this.motionPitch -= 2.0F; | |||
} | |||
if (this.aerwhale.getPosY() < 20) { | |||
this.motionPitch += 2.0F; | |||
} | |||
} | |||
else { | |||
this.aerwhale.rotationPitch = -this.aerwhale.rotationPitch; | |||
this.aerwhale.rotationYaw = -this.aerwhale.rotationYaw; | |||
} | |||
} | |||
else if (course == 1) { | |||
this.motionYaw += 5.0F; | |||
} | |||
else if (course == 2) { | |||
this.motionPitch -= 5.0F; | |||
} | |||
else if (course == 3) { | |||
this.motionYaw -= 5.0F; | |||
} | |||
else { | |||
this.motionPitch += 5.0F; | |||
} | |||
this.motionYaw += 2.0F * this.aerwhale.getRNG().nextFloat() - 1.0F; | |||
this.motionPitch += 2.0F * this.aerwhale.getRNG().nextFloat() - 1.0F; | |||
this.aerwhale.rotationPitch += 0.1F * this.motionPitch; | |||
this.aerwhale.rotationYaw += 0.1F * this.motionYaw; | |||
this.aerwhale.rotationPitch += 0.1F * this.motionPitch; | |||
this.aerwhale.rotationYaw += 0.1F * this.motionYaw; | |||
if (this.aerwhale.rotationPitch < -60) { | |||
this.aerwhale.rotationPitch = -60; | |||
} | |||
if (this.aerwhale.rotationPitch < -60) { | |||
this.aerwhale.rotationPitch = -60; | |||
} | |||
if (this.aerwhale.rotationPitch > 60) { | |||
this.aerwhale.rotationPitch = 60; | |||
} | |||
if (this.aerwhale.rotationPitch > 60) { | |||
this.aerwhale.rotationPitch = 60; | |||
} | |||
this.aerwhale.rotationPitch *= 0.99D; | |||
double d0 = Math.toRadians(this.aerwhale.rotationYaw); | |||
double d1 = Math.toRadians(this.aerwhale.rotationPitch); | |||
double d2 = Math.cos(d1); | |||
this.aerwhale.setMotion(this.aerwhale.getMotion().add(0.005 * Math.cos(d0) * d2, 0.005 * Math.sin(d1), 0.005 * Math.sin(d0) * d2).scale(0.98)); | |||
if (this.aerwhale.getMotion().x > 0 && !this.aerwhale.world.isAirBlock(this.aerwhale.getPosition().east())) { | |||
this.aerwhale.setMotion(-this.aerwhale.getMotion().x, this.aerwhale.getMotion().y, this.aerwhale.getMotion().z); | |||
this.motionYaw -= 10F; | |||
} | |||
else if (this.aerwhale.getMotion().x < 0 && !this.aerwhale.world.isAirBlock(this.aerwhale.getPosition().west())) { | |||
this.aerwhale.setMotion(-this.aerwhale.getMotion().x, this.aerwhale.getMotion().y, this.aerwhale.getMotion().z); | |||
this.motionYaw += 10F; | |||
} | |||
else if (this.aerwhale.getMotion().y > 0 && !this.aerwhale.world.isAirBlock(this.aerwhale.getPosition().up())) { | |||
this.aerwhale.setMotion(this.aerwhale.getMotion().x, -this.aerwhale.getMotion().y, this.aerwhale.getMotion().z); | |||
this.motionPitch -= 10F; | |||
} | |||
else if (this.aerwhale.getMotion().y < 0 && !this.aerwhale.world.isAirBlock(this.aerwhale.getPosition().down())) { | |||
this.aerwhale.setMotion(this.aerwhale.getMotion().x, -this.aerwhale.getMotion().y, this.aerwhale.getMotion().z); | |||
this.motionPitch += 10F; | |||
} | |||
if (this.aerwhale.getMotion().z > 0D && !this.aerwhale.world.isAirBlock(this.aerwhale.getPosition().south())) { | |||
this.aerwhale.setMotion(this.aerwhale.getMotion().x, this.aerwhale.getMotion().y, -this.aerwhale.getMotion().z); | |||
this.motionYaw -= 10F; | |||
} | |||
else if (this.aerwhale.getMotion().z < 0 && !this.aerwhale.world.isAirBlock(this.aerwhale.getPosition().north())) { | |||
this.aerwhale.setMotion(this.aerwhale.getMotion().x, this.aerwhale.getMotion().y, -this.aerwhale.getMotion().z); | |||
this.motionYaw += 10F; | |||
} | |||
this.aerwhale.move(MoverType.SELF, this.aerwhale.getMotion()); | |||
} | |||
private double checkForTravelableCourse(float rotationYawOffset, float rotationPitchOffset) { | |||
double standard = 50D; | |||
float yaw = this.aerwhale.rotationYaw + rotationYawOffset; | |||
float pitch = this.aerwhale.rotationPitch + rotationPitchOffset; | |||
float f3 = MathHelper.cos(-yaw * 0.01745329F - (float)Math.PI); | |||
float f4 = MathHelper.sin(-yaw * 0.01745329F - (float)Math.PI); | |||
float f5 = MathHelper.cos(-pitch * 0.01745329F); | |||
float f6 = MathHelper.sin(-pitch * 0.01745329F); | |||
float f7 = f4 * f5; | |||
float f8 = f6; | |||
float f9 = f3 * f5; | |||
Vec3d vec3d = new Vec3d(this.aerwhale.getPosX(), this.aerwhale.getBoundingBox().minY, this.aerwhale.getPosZ()); | |||
Vec3d vec3d1 = vec3d.add(f7 * standard, f8 * standard, f9 * standard); | |||
RayTraceResult movingobjectposition = this.aerwhale.world.rayTraceBlocks(new RayTraceContext(vec3d, vec3d1, BlockMode.COLLIDER, FluidMode.NONE, this.aerwhale)); | |||
if (movingobjectposition == null) { | |||
return standard; | |||
} | |||
if (movingobjectposition.getType() == RayTraceResult.Type.BLOCK) { | |||
double i = movingobjectposition.getHitVec().getX() - this.aerwhale.getPosX(); | |||
double j = movingobjectposition.getHitVec().getY() - this.aerwhale.getBoundingBox().minY; | |||
double k = movingobjectposition.getHitVec().getZ() - this.aerwhale.getPosZ(); | |||
return Math.sqrt(i * i + j * j + k * k); | |||
} | |||
return standard; | |||
} | |||
private int getCorrectCourse() { | |||
double[] distances = new double[] { originDir, westDir, upDir, eastDir, downDir }; | |||
int correctCourse = 0; | |||
for (int i = 1; i < 5; i++) { | |||
if (distances[i] > distances[correctCourse]) { | |||
correctCourse = i; | |||
} | |||
} | |||
return correctCourse; | |||
} | |||
} | |||
/**/ | |||
} |
@@ -5,11 +5,8 @@ import com.aether.api.dungeon.DungeonTypes; | |||
import com.aether.api.enchantments.AetherEnchantmentFuel; | |||
import com.aether.api.freezables.AetherFreezableFuel; | |||
import com.aether.block.AetherBlocks; | |||
import com.aether.entity.monster.MimicEntity; | |||
import com.aether.entity.monster.SentryEntity; | |||
import com.aether.entity.passive.MoaEntity; | |||
import com.aether.entity.monster.CockatriceEntity; | |||
import com.aether.entity.AetherEntityTypes; | |||
import com.aether.util.AetherSoundEvents; | |||
import net.minecraft.inventory.EquipmentSlotType; | |||
import net.minecraft.item.*; | |||
@@ -342,46 +339,22 @@ public class AetherItems { | |||
item("sentry_boots", new ArmorItem(AetherArmorMaterial.SENTRY, EquipmentSlotType.FEET, new Item.Properties().rarity(Aether.AETHER_LOOT).group(AetherItemGroups.AETHER_COMBAT))), | |||
item("lightning_knife", new LightningKnifeItem(new Item.Properties().rarity(Aether.AETHER_LOOT).maxStackSize(16).group(AetherItemGroups.AETHER_COMBAT))), | |||
//item("music_disc_aether_tune", new MusicDiscItem(1, AetherSoundEvents.MUSIC_DISC_AETHER_TUNE, new Item.Properties().maxStackSize(1).rarity(Rarity.RARE).group(AetherItemGroups.AETHER_MISC))), | |||
//item("music_disc_ascending_dawn", new MusicDiscItem(2, AetherSoundEvents.MUSIC_DISC_ASCENDING_DAWN, new Item.Properties().maxStackSize(1).rarity(Rarity.RARE).group(AetherItemGroups.AETHER_MISC))), | |||
//item("music_disc_welcoming_skies", new MusicDiscItem(3, AetherSoundEvents.MUSIC_DISC_WELCOMING_SKIES, new Item.Properties().maxStackSize(1).rarity(Rarity.RARE).group(AetherItemGroups.AETHER_MISC))), | |||
//item("music_disc_legacy", new MusicDiscItem(4, AetherSoundEvents.MUSIC_DISC_LEGACY, new Item.Properties().maxStackSize(1).rarity(Rarity.RARE).group(AetherItemGroups.AETHER_MISC))), | |||
item("music_disc_aether_tune", new MusicDiscItem(1, () -> AetherSoundEvents.MUSIC_DISC_AETHER_TUNE, new Item.Properties().maxStackSize(1).rarity(Rarity.RARE).group(AetherItemGroups.AETHER_MISC))), | |||
item("music_disc_ascending_dawn", new MusicDiscItem(2, () -> AetherSoundEvents.MUSIC_DISC_ASCENDING_DAWN, new Item.Properties().maxStackSize(1).rarity(Rarity.RARE).group(AetherItemGroups.AETHER_MISC))), | |||
item("music_disc_welcoming_skies", new MusicDiscItem(3, () -> AetherSoundEvents.MUSIC_DISC_WELCOMING_SKIES, new Item.Properties().maxStackSize(1).rarity(Rarity.RARE).group(AetherItemGroups.AETHER_MISC))), | |||
item("music_disc_legacy", new MusicDiscItem(4, () -> AetherSoundEvents.MUSIC_DISC_LEGACY, new Item.Properties().maxStackSize(1).rarity(Rarity.RARE).group(AetherItemGroups.AETHER_MISC))), | |||
//item("repulsion_shield", new ShieldAccessoryItem(new Item.Properties().rarity(Aether.AETHER_LOOT).maxDamage(512).group(AetherItemGroups.AETHER_ACCESSORIES))), | |||
//item("lore_book", new LoreBookItem(new Item.Properties().maxStackSize(1).rarity(Aether.AETHER_LOOT).group(AetherItemGroups.AETHER_MISC))), | |||
item("sentry_spawn_egg", new SpawnEggItem( | |||
AetherEntityTypes.SENTRY, | |||
/*primary color:*/ 0x808080, /*secondary color:*/ 0x3A8AEC, | |||
new Item.Properties().group(ItemGroup.MISC))), | |||
item("mimic_spawn_egg", new SpawnEggItem( | |||
AetherEntityTypes.MIMIC, | |||
/*primary color:*/ 0xB18132, /*secondary color:*/ 0x605A4E, | |||
new Item.Properties().group(ItemGroup.MISC))), | |||
item("moa_spawn_egg", new SpawnEggItem( | |||
AetherEntityTypes.MOA, | |||
/*primary color:*/0x87BFEF, /*secondary color:*/0x7A7A7A, | |||
new Item.Properties().group(ItemGroup.MISC))), | |||
item("cockatrice_spawn_egg", new SpawnEggItem( | |||
AetherEntityTypes.COCKATRICE, | |||
/*primary color:*/0x6CB15C, /*secondary color:*/0x6C579D, | |||
new Item.Properties().group(ItemGroup.MISC))), | |||
item("zephyr_spawn_egg", new SpawnEggItem( | |||
AetherEntityTypes.ZEPHYR, | |||
/*primary color:*/ 0xDFDFDF, /*secondary color:*/ 0x99CFE8, | |||
new Item.Properties().group(ItemGroup.MISC))), | |||
item("phyg_spawn_egg", new SpawnEggItem( | |||
AetherEntityTypes.PHYG, | |||
/*primary color:*/ 0xFFC1D0, /*secondary color:*/ 0xFFD939, | |||
new Item.Properties().group(ItemGroup.MISC))), | |||
item("flying_cow_spawn_egg", new SpawnEggItem( | |||
AetherEntityTypes.FLYING_COW, | |||
/*primary color:*/ 0xD8D8D8, /*secondary color:*/ 0xFFD939, | |||
new Item.Properties().group(ItemGroup.MISC))), | |||
item("sheepuff_spawn_egg", new SpawnEggItem( | |||
AetherEntityTypes.SHEEPUFF, | |||
/*primary color:*/ 0xE2FCFF, /*secondary color:*/ 0xCB9090, | |||
new Item.Properties().group(ItemGroup.MISC))), | |||
item("sentry_spawn_egg", new SpawnEggItem(AetherEntityTypes.SENTRY, /*primary color:*/ 0x808080, /*secondary color:*/ 0x3A8AEC, new Item.Properties().group(ItemGroup.MISC))), | |||
item("mimic_spawn_egg", new SpawnEggItem(AetherEntityTypes.MIMIC, /*primary color:*/ 0xB18132, /*secondary color:*/ 0x605A4E, new Item.Properties().group(ItemGroup.MISC))), | |||
item("moa_spawn_egg", new SpawnEggItem(AetherEntityTypes.MOA, /*primary color:*/0x87BFEF, /*secondary color:*/0x7A7A7A, new Item.Properties().group(ItemGroup.MISC))), | |||
item("cockatrice_spawn_egg", new SpawnEggItem(AetherEntityTypes.COCKATRICE, /*primary color:*/0x6CB15C, /*secondary color:*/0x6C579D, new Item.Properties().group(ItemGroup.MISC))), | |||
item("zephyr_spawn_egg", new SpawnEggItem(AetherEntityTypes.ZEPHYR, /*primary color:*/ 0xDFDFDF, /*secondary color:*/ 0x99CFE8, new Item.Properties().group(ItemGroup.MISC))), | |||
item("phyg_spawn_egg", new SpawnEggItem(AetherEntityTypes.PHYG, /*primary color:*/ 0xFFC1D0, /*secondary color:*/ 0xFFD939, new Item.Properties().group(ItemGroup.MISC))), | |||
item("flying_cow_spawn_egg", new SpawnEggItem(AetherEntityTypes.FLYING_COW, /*primary color:*/ 0xD8D8D8, /*secondary color:*/ 0xFFD939, new Item.Properties().group(ItemGroup.MISC))), | |||
item("sheepuff_spawn_egg", new SpawnEggItem(AetherEntityTypes.SHEEPUFF, /*primary color:*/ 0xE2FCFF, /*secondary color:*/ 0xCB9090, new Item.Properties().group(ItemGroup.MISC))), | |||
}); | |||
} | |||