2020-07-17 03:55:31 +00:00
|
|
|
package com.thebrokenrail.energonrelics.client.block.entity.render;
|
2020-07-15 22:44:49 +00:00
|
|
|
|
|
|
|
import com.thebrokenrail.energonrelics.EnergonRelics;
|
|
|
|
import com.thebrokenrail.energonrelics.block.entity.DefensiveLaserBlockEntity;
|
|
|
|
import net.minecraft.block.entity.BlockEntity;
|
|
|
|
import net.minecraft.client.MinecraftClient;
|
|
|
|
import net.minecraft.client.render.VertexConsumerProvider;
|
|
|
|
import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher;
|
|
|
|
import net.minecraft.client.render.model.json.ModelTransformation;
|
|
|
|
import net.minecraft.client.util.math.MatrixStack;
|
|
|
|
import net.minecraft.client.util.math.Vector3f;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
|
|
|
|
public class DefensiveLaserBlockEntityRenderer extends HighlightBlockEntityRenderer {
|
|
|
|
public DefensiveLaserBlockEntityRenderer(BlockEntityRenderDispatcher dispatcher) {
|
|
|
|
super(dispatcher);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void render(BlockEntity entity, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay) {
|
2020-07-16 18:50:18 +00:00
|
|
|
super.render(entity, tickDelta, matrices, vertexConsumers, light, overlay);
|
2020-07-15 22:44:49 +00:00
|
|
|
matrices.push();
|
|
|
|
matrices.translate(0.5d, 0.5d, 0.5d);
|
2020-07-16 18:50:18 +00:00
|
|
|
matrices.scale(0.6f, 0.6f, 0.6f);
|
2020-07-15 22:44:49 +00:00
|
|
|
if (entity instanceof DefensiveLaserBlockEntity) {
|
|
|
|
DefensiveLaserBlockEntity laser = (DefensiveLaserBlockEntity) entity;
|
|
|
|
|
2020-07-16 18:50:18 +00:00
|
|
|
float yaw = (float) ((laser.rotation.getYaw()) * DefensiveLaserBlockEntity.DEG2RAD);
|
2020-07-15 22:44:49 +00:00
|
|
|
if (yaw != 0) {
|
|
|
|
matrices.multiply(Vector3f.POSITIVE_Y.getRadialQuaternion(yaw));
|
|
|
|
}
|
2020-07-16 18:50:18 +00:00
|
|
|
|
|
|
|
float pitch = (float) ((laser.rotation.getPitch() + 45) * DefensiveLaserBlockEntity.DEG2RAD);
|
2020-07-15 22:44:49 +00:00
|
|
|
if (pitch != 0) {
|
|
|
|
matrices.multiply(Vector3f.POSITIVE_X.getRadialQuaternion(pitch));
|
|
|
|
}
|
|
|
|
|
2020-07-16 18:50:18 +00:00
|
|
|
matrices.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(-90));
|
|
|
|
|
|
|
|
MinecraftClient.getInstance().getItemRenderer().renderItem(new ItemStack(EnergonRelics.DEFENSIVE_LASER_CORE_ITEM), ModelTransformation.Mode.FIXED, light, overlay, matrices, vertexConsumers);
|
2020-07-15 22:44:49 +00:00
|
|
|
}
|
|
|
|
matrices.pop();
|
|
|
|
}
|
|
|
|
}
|