Turbine rendering, thanks Spearkiller for the textures and model

This commit is contained in:
modmuss50 2020-01-12 18:40:21 +00:00
parent 3b4d135fd4
commit bd25b11908
19 changed files with 145 additions and 33 deletions

View file

@ -47,8 +47,9 @@ import reborncore.client.hud.StackInfoHUD;
import reborncore.client.multiblock.MultiblockRenderer;
import techreborn.client.render.DynamicBucketBakedModel;
import techreborn.client.render.DynamicCellBakedModel;
import techreborn.client.render.entitys.CableCoverEntityRenderer;
import techreborn.client.render.entitys.StorageUnitEntityRenderer;
import techreborn.client.render.entitys.CableCoverRenderer;
import techreborn.client.render.entitys.StorageUnitRenderer;
import techreborn.client.render.entitys.TurbineRenderer;
import techreborn.events.StackToolTipHandler;
import techreborn.init.ModFluids;
import techreborn.init.TRBlockEntities;
@ -156,8 +157,9 @@ public class TechRebornClient implements ClientModInitializer {
BlockEntityRendererRegistry.INSTANCE.register(TRBlockEntities.DISTILLATION_TOWER, MultiblockRenderer::new);
BlockEntityRendererRegistry.INSTANCE.register(TRBlockEntities.IMPLOSION_COMPRESSOR, MultiblockRenderer::new);
BlockEntityRendererRegistry.INSTANCE.register(TRBlockEntities.GREENHOUSE_CONTROLLER, MultiblockRenderer::new);
BlockEntityRendererRegistry.INSTANCE.register(TRBlockEntities.STORAGE_UNIT, StorageUnitEntityRenderer::new);
BlockEntityRendererRegistry.INSTANCE.register(TRBlockEntities.CABLE, CableCoverEntityRenderer::new);
BlockEntityRendererRegistry.INSTANCE.register(TRBlockEntities.STORAGE_UNIT, StorageUnitRenderer::new);
BlockEntityRendererRegistry.INSTANCE.register(TRBlockEntities.CABLE, CableCoverRenderer::new);
BlockEntityRendererRegistry.INSTANCE.register(TRBlockEntities.WIND_MILL, TurbineRenderer::new);
}

View file

@ -39,6 +39,9 @@ import techreborn.init.TRBlockEntities;
public class WindMillBlockEntity extends PowerAcceptorBlockEntity implements IToolDrop {
public float bladeAngle;
public float spinSpeed;
public WindMillBlockEntity() {
super(TRBlockEntities.WIND_MILL);
}
@ -46,7 +49,20 @@ public class WindMillBlockEntity extends PowerAcceptorBlockEntity implements ITo
@Override
public void tick() {
super.tick();
if (pos.getY() > 64) {
boolean generating = pos.getY() > 64;
if(world.isClient) {
bladeAngle += spinSpeed;
if (generating) {
spinSpeed = Math.min(0.2F, spinSpeed + 0.002f);
} else {
spinSpeed = Math.max(0.0f, spinSpeed - 0.005f);
}
}
if (generating) {
int actualPower = TechRebornConfig.windMillBaseEnergy;
if (world.isThundering()) {
actualPower *= TechRebornConfig.windMillThunderMultiplier;

View file

@ -16,9 +16,9 @@ import techreborn.blocks.cable.CableBlock;
import java.util.Random;
public class CableCoverEntityRenderer extends BlockEntityRenderer<CableBlockEntity> {
public class CableCoverRenderer extends BlockEntityRenderer<CableBlockEntity> {
public CableCoverEntityRenderer(BlockEntityRenderDispatcher dispatcher) {
public CableCoverRenderer(BlockEntityRenderDispatcher dispatcher) {
super(dispatcher);
}

View file

@ -41,9 +41,9 @@ import javax.annotation.Nullable;
/**
* Created by Mark on 13/03/2016.
*/
public class RenderNukePrimed extends EntityRenderer<EntityNukePrimed> {
public class NukeRenderer extends EntityRenderer<EntityNukePrimed> {
public RenderNukePrimed(EntityRenderDispatcher renderManager) {
public NukeRenderer(EntityRenderDispatcher renderManager) {
super(renderManager);
this.shadowSize = 0.5F;
}

View file

@ -16,8 +16,8 @@ import techreborn.blockentity.storage.item.StorageUnitBaseBlockEntity;
/**
* Created by drcrazy on 07-Jan-20 for TechReborn-1.15.
*/
public class StorageUnitEntityRenderer extends BlockEntityRenderer<StorageUnitBaseBlockEntity> {
public StorageUnitEntityRenderer(BlockEntityRenderDispatcher dispatcher) {
public class StorageUnitRenderer extends BlockEntityRenderer<StorageUnitBaseBlockEntity> {
public StorageUnitRenderer(BlockEntityRenderDispatcher dispatcher) {
super(dispatcher);
}

View file

@ -0,0 +1,94 @@
package techreborn.client.render.entitys;
import net.minecraft.client.model.Model;
import net.minecraft.client.model.ModelPart;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.WorldRenderer;
import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher;
import net.minecraft.client.render.block.entity.BlockEntityRenderer;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.client.util.math.Vector3f;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.Direction;
import techreborn.blockentity.generator.basic.WindMillBlockEntity;
public class TurbineRenderer extends BlockEntityRenderer<WindMillBlockEntity> {
private static final TurbineModel MODEL = new TurbineModel();
public static final Identifier TEXTURE = new Identifier("techreborn:textures/block/machines/generators/wind_mill_turbine.png");
public TurbineRenderer(BlockEntityRenderDispatcher dispatcher) {
super(dispatcher);
}
@Override
public void render(WindMillBlockEntity blockEntity, float tickDelta, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int light, int overlay) {
Direction facing = blockEntity.getFacing();
int renderLight = WorldRenderer.getLightmapCoordinates(blockEntity.getWorld(), blockEntity.getPos().offset(facing));
final VertexConsumer vertexConsumer = vertexConsumerProvider.getBuffer(RenderLayer.getEntitySolid(TEXTURE));
matrixStack.push();
matrixStack.translate(0.5, 0, 0.5);
matrixStack.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(-facing.rotateYCounterclockwise().asRotation() + 90));
matrixStack.translate(0, -1, -0.56);
float spin = blockEntity.bladeAngle + tickDelta * blockEntity.spinSpeed;
MODEL.setSpin(spin);
MODEL.render(matrixStack, vertexConsumer, renderLight, overlay, 1F, 1F, 1F, 1F);
matrixStack.pop();
}
private static class TurbineModel extends Model {
private final ModelPart base;
public TurbineModel() {
super(RenderLayer::getEntityCutoutNoCull);
textureWidth = 64;
textureHeight = 64;
base = new ModelPart(this);
base.setPivot(0.0F, 24.0F, 0.0F);
base.addCuboid(null, -2.0F, -2.0F, -1.0F, 4, 4, 2, 0.0F, 0, 0);
base.addCuboid(null, -1.0F, -1.0F, -2.0F, 2, 2, 1, 0.0F, 0, 6);
ModelPart blade1 = new ModelPart(this);
blade1.setPivot(0.0F, 0.0F, 0.0F);
setRotation(blade1, -0.5236F, 0.0F, 0.0F);
blade1.addCuboid(null, -24.0F, -1.0F, -0.5F, 24, 2, 1, 0.0F, 0, 9);
ModelPart blade2 = new ModelPart(this);
blade2.setPivot(0.0F, 0.0F, 0.0F);
setRotation(blade2, -0.5236F, 0.0F, 2.0944F);
blade2.addCuboid(null, -24.0F, -1.0F, -0.5F, 24, 2, 1, 0.0F, 0, 9);
ModelPart blade3 = new ModelPart(this);
blade3.setPivot(0.0F, 0.0F, 0.0F);
setRotation(blade3, -0.5236F, 0.0F, -2.0944F);
blade3.addCuboid(null, -24.0F, -2.0F, -1.075F, 24, 2, 1, 0.0F, 0, 9);
base.addChild(blade1);
base.addChild(blade2);
base.addChild(blade3);
}
private void setRotation(ModelPart model, float x, float y, float z) {
model.pitch = x;
model.yaw = y;
model.roll = z;
}
private void setSpin(float z) {
base.roll = z;
}
@Override
public void render(MatrixStack matrixStack, VertexConsumer vertexConsumer, int light, int overlay, float red, float green, float blue, float alpha) {
base.render(matrixStack, vertexConsumer, light, overlay);
}
}
}

View file

@ -1,11 +1,11 @@
{
"parent": "minecraft:block/orientable",
"textures": {
"up": "techreborn:block/machines/generators/wind_mill_top",
"down": "techreborn:block/machines/generators/wind_mill_bottom",
"west": "techreborn:block/machines/generators/wind_mill_left",
"east": "techreborn:block/machines/generators/wind_mill_right",
"south": "techreborn:block/machines/generators/generator_bottom",
"front": "techreborn:block/machines/generators/wind_mill_front_off"
}
}
{
"parent": "minecraft:block/orientable",
"textures": {
"up": "techreborn:block/machines/generators/wind_mill_top",
"down": "techreborn:block/machines/generators/wind_mill_bottom",
"west": "techreborn:block/machines/generators/wind_mill_left",
"east": "techreborn:block/machines/generators/wind_mill_right",
"south": "techreborn:block/machines/generators/generator_bottom",
"front": "techreborn:block/machines/generators/wind_mill_front"
}
}

View file

@ -1,11 +1,11 @@
{
"parent": "minecraft:block/orientable",
"textures": {
"up": "techreborn:block/machines/generators/wind_mill_top",
"down": "techreborn:block/machines/generators/wind_mill_bottom",
"west": "techreborn:block/machines/generators/wind_mill_left",
"east": "techreborn:block/machines/generators/wind_mill_right",
"south": "techreborn:block/machines/generators/generator_bottom",
"front": "techreborn:block/machines/generators/wind_mill_front_on"
}
}
{
"parent": "minecraft:block/orientable",
"textures": {
"up": "techreborn:block/machines/generators/wind_mill_top",
"down": "techreborn:block/machines/generators/wind_mill_bottom",
"west": "techreborn:block/machines/generators/wind_mill_left",
"east": "techreborn:block/machines/generators/wind_mill_right",
"south": "techreborn:block/machines/generators/generator_bottom",
"front": "techreborn:block/machines/generators/wind_mill_front"
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 772 B

After

Width:  |  Height:  |  Size: 741 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 802 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 769 B

After

Width:  |  Height:  |  Size: 748 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 769 B

After

Width:  |  Height:  |  Size: 758 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 784 B

After

Width:  |  Height:  |  Size: 749 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 859 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 386 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 431 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 482 B

After

Width:  |  Height:  |  Size: 411 B