Update shuriken renderer to throw sideways
Ended up having to ditch the sprite renderer as did not want the camera rotation there
@@ -3,43 +3,37 @@ package slimeknights.tconstruct.gadgets.client;
import com.mojang.blaze3d.matrix.MatrixStack;
import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.ItemRenderer;
+import net.minecraft.client.renderer.entity.EntityRenderer;
import net.minecraft.client.renderer.entity.EntityRendererManager;
-import net.minecraft.client.renderer.entity.SpriteRenderer;
-import net.minecraft.util.math.vector.Quaternion;
+import net.minecraft.client.renderer.model.ItemCameraTransforms;
+import net.minecraft.client.renderer.texture.OverlayTexture;
+import net.minecraft.inventory.container.PlayerContainer;
+import net.minecraft.util.ResourceLocation;
+import net.minecraft.util.math.vector.Vector3f;
import slimeknights.tconstruct.gadgets.entity.shuriken.ShurikenEntityBase;
-public class RenderShuriken extends SpriteRenderer<ShurikenEntityBase> {
-
- public RenderShuriken(EntityRendererManager renderManagerIn, ItemRenderer itemRendererIn) {
- super(renderManagerIn, itemRendererIn);
+public class RenderShuriken extends EntityRenderer<ShurikenEntityBase> {
+ private final ItemRenderer itemRenderer;
+ public RenderShuriken(EntityRendererManager manager, ItemRenderer itemRenderer) {
+ super(manager);
+ this.itemRenderer = itemRenderer;
}
@Override
public void render(ShurikenEntityBase entity, float entityYaw, float partialTicks, MatrixStack matrixStackIn, IRenderTypeBuffer bufferIn, int packedLightIn) {
+ if (entity.ticksExisted >= 2 || !(this.renderManager.info.getRenderViewEntity().getDistanceSq(entity) < 12.25D)) {
matrixStackIn.push();
- matrixStackIn.scale(0.6F, 0.6F, 0.6F);
-
- // TODO Figure out rotation stuff if the current isn't good enough
- // original credits to Boni
- matrixStackIn.rotate(new Quaternion(1.0F, entity.rotationYaw, 0F, true));
- matrixStackIn.rotate(new Quaternion(-entity.rotationPitch, 1.0F, 0F, true));
-
- // add some diversity
- matrixStackIn.rotate(new Quaternion(entity.rotationPitch, 0F, 1.0F, true));
-
- // rotate it into a horizontal position
- matrixStackIn.rotate(new Quaternion(90.0F, 0.0F, 0.0F, true));
-// GL11.glRotatef(90f, 1f, 0f, 0f);
-
-// if(!entity.inGround) {
-// entity.spin += 20 * partialTicks;
-// }
-// float r = entity.spin;
-//
-// // shurikens spin around their center a lot. *spin*
-// GL11.glRotatef(r, 0f, 0f, 1f);
+ matrixStackIn.rotate(Vector3f.XP.rotationDegrees(90));
+ matrixStackIn.rotate(Vector3f.ZP.rotationDegrees(-(entity.ticksExisted + partialTicks) * 30 % 360));
+ matrixStackIn.translate(-0.03125, -0.09375, 0);
+ this.itemRenderer.renderItem(entity.getItem(), ItemCameraTransforms.TransformType.GROUND, packedLightIn, OverlayTexture.NO_OVERLAY, matrixStackIn, bufferIn);
matrixStackIn.pop();
super.render(entity, entityYaw, partialTicks, matrixStackIn, bufferIn, packedLightIn);
}
}
+ @Override
+ public ResourceLocation getEntityTexture(ShurikenEntityBase entity) {
+ return PlayerContainer.LOCATION_BLOCKS_TEXTURE;
+ }
+}
