use of xyz.przemyk.simpleplanes.upgrades.Upgrade in project simple-planes by przemykomo.
the class CommonEventHandler method interact.
@SubscribeEvent
public static void interact(PlayerInteractEvent.RightClickItem event) {
Player player = event.getPlayer();
Entity entity = player.getRootVehicle();
if (entity instanceof PlaneEntity) {
ItemStack itemStack = player.getItemInHand(event.getHand());
if (!itemStack.isEmpty()) {
if (itemStack.getItem() == Items.TNT && entity instanceof LargePlaneEntity && ((LargePlaneEntity) entity).tryToAddTNT(player, itemStack)) {
return;
}
PlaneEntity planeEntity = (PlaneEntity) entity;
for (Upgrade upgrade : planeEntity.upgrades.values()) {
upgrade.onItemRightClick(event);
}
}
}
}
use of xyz.przemyk.simpleplanes.upgrades.Upgrade in project simple-planes by przemykomo.
the class PlaneRenderer method render.
@Override
public void render(T planeEntity, float entityYaw, float partialTicks, PoseStack poseStack, MultiBufferSource buffer, int packedLight) {
poseStack.pushPose();
poseStack.translate(0.0D, 0.375D, 0.0D);
poseStack.scale(-1.0F, -1.0F, 1.0F);
poseStack.translate(0, -0.5, 0);
poseStack.mulPose(Vector3f.YP.rotationDegrees(180));
double firstPersonYOffset = -0.7D;
boolean isPlayerRidingInFirstPersonView = Minecraft.getInstance().player != null && planeEntity.hasPassenger(Minecraft.getInstance().player) && (Minecraft.getInstance()).options.cameraType == CameraType.FIRST_PERSON;
if (isPlayerRidingInFirstPersonView) {
poseStack.translate(0.0D, firstPersonYOffset, 0.0D);
}
Quaternion q = MathUtil.lerpQ(partialTicks, planeEntity.getQ_Prev(), planeEntity.getQ_Client());
poseStack.mulPose(q);
float rockingAngle = planeEntity.getRockingAngle(partialTicks);
if (!Mth.equal(rockingAngle, 0.0F)) {
poseStack.mulPose(new Quaternion(new Vector3f(1.0F, 0.0F, 1.0F), rockingAngle, true));
}
float f = (float) planeEntity.getTimeSinceHit() - partialTicks;
float f1 = planeEntity.getDamageTaken() - partialTicks;
if (f1 < 0.1F) {
f1 = 0.1F;
}
if (f > 0.0F) {
float angle = Mth.clamp(f * f1 / 200.0F, -30, 30);
f = planeEntity.tickCount + partialTicks;
poseStack.mulPose(Vector3f.ZP.rotationDegrees(Mth.sin(f) * angle));
}
poseStack.translate(0, -0.6, 0);
if (isPlayerRidingInFirstPersonView) {
poseStack.translate(0.0D, -firstPersonYOffset, 0.0D);
}
VertexConsumer vertexConsumer = buffer.getBuffer(planeEntityModel.renderType(getMaterialTexture(planeEntity)));
planeEntityModel.setupAnim(planeEntity, partialTicks, 0, 0, 0, 0);
planeEntityModel.renderToBuffer(poseStack, vertexConsumer, packedLight, OverlayTexture.NO_OVERLAY, 1.0F, 1.0F, 1.0F, 1.0F);
for (Upgrade upgrade : planeEntity.upgrades.values()) {
upgrade.render(poseStack, buffer, packedLight, partialTicks);
}
vertexConsumer = ItemRenderer.getArmorFoilBuffer(buffer, planeEntityModel.renderType(PROPELLER_TEXTURE), false, planeEntity.isNoGravity());
propellerModel.setupAnim(planeEntity, partialTicks, 0, 0, 0, 0);
propellerModel.renderToBuffer(poseStack, vertexConsumer, packedLight, OverlayTexture.NO_OVERLAY, 1.0F, 1.0F, 1.0F, 1.0F);
poseStack.pushPose();
poseStack.popPose();
poseStack.popPose();
super.render(planeEntity, 0, partialTicks, poseStack, buffer, packedLight);
}
Aggregations