mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-11-11 04:54:28 +01:00
Contraption actors and blockzapper screen
- Fixed harvesters and drill animating incorrectly on contraptions - Ported blockzapper and worldshaper screen
This commit is contained in:
parent
467af2ea20
commit
c53f9c2079
@ -7,6 +7,7 @@ import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
|
||||
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
|
||||
import com.simibubi.create.foundation.utility.AngleHelper;
|
||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||
import com.simibubi.create.foundation.utility.MatrixStacker;
|
||||
import com.simibubi.create.foundation.utility.SuperByteBuffer;
|
||||
@ -16,6 +17,7 @@ import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
import net.minecraft.util.Direction;
|
||||
|
||||
public class DrillRenderer extends KineticTileEntityRenderer {
|
||||
|
||||
@ -25,7 +27,7 @@ public class DrillRenderer extends KineticTileEntityRenderer {
|
||||
|
||||
@Override
|
||||
protected SuperByteBuffer getRotatedModel(KineticTileEntity te) {
|
||||
return getRotatingModel(te.getBlockState());
|
||||
return AllBlockPartials.DRILL_HEAD.renderOnDirectional(te.getBlockState());
|
||||
}
|
||||
|
||||
protected static SuperByteBuffer getRotatingModel(BlockState state) {
|
||||
@ -36,20 +38,25 @@ public class DrillRenderer extends KineticTileEntityRenderer {
|
||||
IRenderTypeBuffer buffer) {
|
||||
MatrixStack[] matrixStacks = new MatrixStack[] { ms, msLocal };
|
||||
BlockState state = context.state;
|
||||
SuperByteBuffer superBuffer = getRotatingModel(state);
|
||||
SuperByteBuffer superBuffer = AllBlockPartials.DRILL_HEAD.renderOn(state);
|
||||
Direction facing = state.get(DrillBlock.FACING);
|
||||
|
||||
float speed = (float) (context.contraption.stalled
|
||||
|| !VecHelper.isVecPointingTowards(context.relativeMotion, state.get(FACING)
|
||||
.getOpposite()) ? context.getAnimationSpeed() : 0);
|
||||
float time = AnimationTickHolder.getRenderTick() / 20;
|
||||
float angle = (float) (((time * speed) % 360) / 180 * (float) Math.PI);
|
||||
float angle = (float) (((time * speed) % 360));
|
||||
|
||||
for (MatrixStack m : matrixStacks)
|
||||
MatrixStacker.of(m)
|
||||
.centre()
|
||||
.rotateY(angle)
|
||||
.rotateY(AngleHelper.horizontalAngle(facing))
|
||||
.rotateX(AngleHelper.verticalAngle(facing))
|
||||
.rotateZ(angle)
|
||||
.unCentre();
|
||||
superBuffer.light(msLocal.peek()
|
||||
|
||||
superBuffer
|
||||
.light(msLocal.peek()
|
||||
.getModel())
|
||||
.renderInto(ms, buffer.getBuffer(RenderType.getSolid()));
|
||||
}
|
||||
|
@ -6,8 +6,8 @@ import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
|
||||
import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer;
|
||||
import com.simibubi.create.foundation.utility.AngleHelper;
|
||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||
import com.simibubi.create.foundation.utility.MatrixStacker;
|
||||
import com.simibubi.create.foundation.utility.SuperByteBuffer;
|
||||
import com.simibubi.create.foundation.utility.VecHelper;
|
||||
|
||||
@ -16,7 +16,6 @@ import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Direction.Axis;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
@ -30,42 +29,36 @@ public class HarvesterRenderer extends SafeTileEntityRenderer<HarvesterTileEntit
|
||||
protected void renderSafe(HarvesterTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer,
|
||||
int light, int overlay) {
|
||||
BlockState blockState = te.getBlockState();
|
||||
|
||||
SuperByteBuffer superBuffer = AllBlockPartials.HARVESTER_BLADE.renderOnHorizontal(blockState);
|
||||
transformHead(ms, 0);
|
||||
superBuffer.light(light)
|
||||
.renderInto(ms, buffer.getBuffer(RenderType.getCutoutMipped()));
|
||||
}
|
||||
|
||||
public static void renderInContraption(MovementContext context, MatrixStack ms, MatrixStack msLocal,
|
||||
IRenderTypeBuffer buffers) {
|
||||
MatrixStack[] matrixStacks = new MatrixStack[] { ms, msLocal };
|
||||
BlockState blockState = context.state;
|
||||
Direction facing = blockState.get(HORIZONTAL_FACING);
|
||||
SuperByteBuffer superBuffer = AllBlockPartials.HARVESTER_BLADE.renderOnHorizontal(blockState);
|
||||
int offset = facing.getAxisDirection()
|
||||
.getOffset() * (facing.getAxis() == Axis.X ? 1 : -1);
|
||||
SuperByteBuffer superBuffer = AllBlockPartials.HARVESTER_BLADE.renderOn(blockState);
|
||||
float speed = (float) (!VecHelper.isVecPointingTowards(context.relativeMotion, facing.getOpposite())
|
||||
? context.getAnimationSpeed() * offset
|
||||
? context.getAnimationSpeed()
|
||||
: 0);
|
||||
|
||||
if (context.contraption.stalled)
|
||||
speed = 0;
|
||||
float time = AnimationTickHolder.getRenderTick() / 20;
|
||||
float angle = (time * speed) % 360;
|
||||
float originOffset = 1 / 16f;
|
||||
Vec3d rotOffset = new Vec3d(0, -2 * originOffset, originOffset).add(VecHelper.getCenterOf(BlockPos.ZERO));
|
||||
|
||||
for (MatrixStack m : matrixStacks)
|
||||
transformHead(m, angle);
|
||||
superBuffer.light(msLocal.peek().getModel())
|
||||
superBuffer.rotateCentered(Direction.UP, AngleHelper.rad(AngleHelper.horizontalAngle(facing)))
|
||||
.translate(rotOffset.x, rotOffset.y, rotOffset.z)
|
||||
.rotate(Direction.WEST, AngleHelper.rad(angle))
|
||||
.translate(-rotOffset.x, -rotOffset.y, -rotOffset.z)
|
||||
.light(msLocal.peek()
|
||||
.getModel())
|
||||
.renderInto(ms, buffers.getBuffer(RenderType.getCutoutMipped()));
|
||||
}
|
||||
|
||||
public static void transformHead(MatrixStack ms, float angle) {
|
||||
float originOffset = 1 / 16f;
|
||||
Vec3d offset = new Vec3d(0, -2 * originOffset, -originOffset).add(VecHelper.getCenterOf(BlockPos.ZERO));
|
||||
MatrixStacker.of(ms)
|
||||
.translate(offset)
|
||||
.rotateX(angle)
|
||||
.translateBack(offset);
|
||||
}
|
||||
public static void transformHead(MatrixStack ms, float angle) {}
|
||||
|
||||
}
|
||||
|
@ -2,9 +2,6 @@ package com.simibubi.create.content.curiosities.zapper;
|
||||
|
||||
import java.util.Vector;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.platform.GlStateManager.DestFactor;
|
||||
import com.mojang.blaze3d.platform.GlStateManager.SourceFactor;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.simibubi.create.foundation.gui.AbstractSimiScreen;
|
||||
import com.simibubi.create.foundation.gui.AllGuiTextures;
|
||||
@ -17,10 +14,7 @@ import com.simibubi.create.foundation.utility.Lang;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType;
|
||||
import net.minecraft.client.renderer.texture.AtlasTexture;
|
||||
import net.minecraft.client.renderer.texture.OverlayTexture;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.NBTUtil;
|
||||
@ -68,12 +62,14 @@ public class ZapperScreen extends AbstractSimiScreen {
|
||||
int id = patternButtons.size();
|
||||
PlacementPatterns pattern = PlacementPatterns.values()[id];
|
||||
patternButtons.add(new IconButton(i + 147 + col * 18, j + 23 + row * 18, pattern.icon));
|
||||
patternButtons.get(id).setToolTip(Lang.translate("gui.blockzapper.pattern." + pattern.translationKey));
|
||||
patternButtons.get(id)
|
||||
.setToolTip(Lang.translate("gui.blockzapper.pattern." + pattern.translationKey));
|
||||
}
|
||||
}
|
||||
|
||||
if (nbt.contains("Pattern"))
|
||||
patternButtons.get(PlacementPatterns.valueOf(nbt.getString("Pattern")).ordinal()).active = false;
|
||||
patternButtons.get(PlacementPatterns.valueOf(nbt.getString("Pattern"))
|
||||
.ordinal()).active = false;
|
||||
|
||||
widgets.addAll(patternButtons);
|
||||
}
|
||||
@ -86,7 +82,8 @@ public class ZapperScreen extends AbstractSimiScreen {
|
||||
background.draw(this, i, j);
|
||||
drawOnBackground(i, j);
|
||||
|
||||
minecraft.getTextureManager().bindTexture(AtlasTexture.LOCATION_BLOCKS_TEXTURE);
|
||||
minecraft.getTextureManager()
|
||||
.bindTexture(AtlasTexture.LOCATION_BLOCKS_TEXTURE);
|
||||
RenderSystem.enableBlend();
|
||||
|
||||
renderBlock();
|
||||
@ -120,7 +117,8 @@ public class ZapperScreen extends AbstractSimiScreen {
|
||||
if (patternButton.isHovered()) {
|
||||
patternButtons.forEach(b -> b.active = true);
|
||||
patternButton.active = false;
|
||||
patternButton.playDownSound(Minecraft.getInstance().getSoundHandler());
|
||||
patternButton.playDownSound(Minecraft.getInstance()
|
||||
.getSoundHandler());
|
||||
nbt.putString("Pattern", PlacementPatterns.values()[patternButtons.indexOf(patternButton)].name());
|
||||
}
|
||||
}
|
||||
@ -129,50 +127,29 @@ public class ZapperScreen extends AbstractSimiScreen {
|
||||
}
|
||||
|
||||
protected void renderZapper() {
|
||||
RenderSystem.pushLightingAttributes();
|
||||
RenderSystem.pushMatrix();
|
||||
|
||||
RenderHelper.enable();
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.enableRescaleNormal();
|
||||
RenderSystem.enableAlphaTest();
|
||||
RenderSystem.alphaFunc(516, 0.1F);
|
||||
RenderSystem.blendFunc(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA);
|
||||
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
||||
RenderSystem.translated((this.width - this.sWidth) / 2 + 260, this.height / 2 - this.sHeight / 4, 100);
|
||||
RenderSystem.rotatef(90 + 0.2f * animationProgress, 0, 1, 0);
|
||||
RenderSystem.rotatef(-40, .8f, 0, -.0f);
|
||||
RenderSystem.scaled(100, -100, 100);
|
||||
|
||||
itemRenderer.renderItem(zapper, TransformType.FIXED, 0xF000F0, OverlayTexture.DEFAULT_UV, new MatrixStack(), getMinecraft().getBufferBuilders().getEntityVertexConsumers());
|
||||
|
||||
RenderSystem.disableAlphaTest();
|
||||
RenderSystem.disableRescaleNormal();
|
||||
RenderSystem.disableLighting();
|
||||
|
||||
RenderSystem.popMatrix();
|
||||
RenderSystem.popAttributes();
|
||||
GuiGameElement.of(zapper)
|
||||
.at((this.width - this.sWidth) / 2 + 210, this.height / 2 - this.sHeight / 4)
|
||||
.scale(4)
|
||||
.render();
|
||||
}
|
||||
|
||||
protected void renderBlock() {
|
||||
RenderSystem.pushMatrix();
|
||||
RenderSystem.translated(guiLeft + 1.7f, guiTop - 49, 120);
|
||||
RenderSystem.translated(guiLeft + 1.7f, guiTop + 48, 120);
|
||||
RenderSystem.rotatef(-30f, .5f, .9f, -.1f);
|
||||
RenderSystem.scaled(20, -20, 20);
|
||||
RenderSystem.scaled(20, 20, 20);
|
||||
|
||||
BlockState state = Blocks.AIR.getDefaultState();
|
||||
if (zapper.hasTag() && zapper.getTag().contains("BlockUsed"))
|
||||
state = NBTUtil.readBlockState(zapper.getTag().getCompound("BlockUsed"));
|
||||
|
||||
RenderSystem.translated(0, -5, 0);
|
||||
|
||||
GuiGameElement.of(state).render();
|
||||
if (zapper.hasTag() && zapper.getTag()
|
||||
.contains("BlockUsed"))
|
||||
state = NBTUtil.readBlockState(zapper.getTag()
|
||||
.getCompound("BlockUsed"));
|
||||
|
||||
GuiGameElement.of(state)
|
||||
.render();
|
||||
RenderSystem.popMatrix();
|
||||
}
|
||||
|
||||
protected void writeAdditionalOptions(CompoundNBT nbt) {
|
||||
}
|
||||
protected void writeAdditionalOptions(CompoundNBT nbt) {}
|
||||
|
||||
}
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
Loading…
Reference in New Issue
Block a user