suddenly, everything is smooth and dry

- replace all usages of Minecraft.getRenderPartialTicks() with AnimationTickHolder.getPartialTicks()
 - refactor stabilized and mounted lighters into one class
 - separate fancy contraption render logic and entity render logic, should maybe move *all* rendering to ContraptionRenderDispatcher
This commit is contained in:
JozsefA 2021-01-23 23:07:12 -08:00
parent 55ea7e3e55
commit ebd20f5173
34 changed files with 204 additions and 317 deletions

View file

@ -3,17 +3,15 @@ package com.simibubi.create.compat.jei.category.animations;
import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.AllBlocks; import com.simibubi.create.AllBlocks;
import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.AnimationTickHolder;
import mezz.jei.api.gui.drawable.IDrawable; import mezz.jei.api.gui.drawable.IDrawable;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.util.Direction.Axis; import net.minecraft.util.Direction.Axis;
public abstract class AnimatedKinetics implements IDrawable { public abstract class AnimatedKinetics implements IDrawable {
public static float getCurrentAngle() { public static float getCurrentAngle() {
return ((AnimationTickHolder.ticks + Minecraft.getInstance().getRenderPartialTicks()) * 4f) % 360; return ((AnimationTickHolder.ticks + AnimationTickHolder.getPartialTicks()) * 4f) % 360;
} }
protected BlockState shaft(Axis axis) { protected BlockState shaft(Axis axis) {

View file

@ -1,13 +1,10 @@
package com.simibubi.create.compat.jei.category.animations; package com.simibubi.create.compat.jei.category.animations;
import static com.simibubi.create.foundation.utility.AnimationTickHolder.ticks;
import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.systems.RenderSystem;
import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.AllBlocks; import com.simibubi.create.AllBlocks;
import com.simibubi.create.foundation.gui.GuiGameElement; import com.simibubi.create.foundation.gui.GuiGameElement;
import com.simibubi.create.foundation.utility.AnimationTickHolder;
import net.minecraft.client.Minecraft;
import net.minecraft.util.Direction.Axis; import net.minecraft.util.Direction.Axis;
public class AnimatedPress extends AnimatedKinetics { public class AnimatedPress extends AnimatedKinetics {
@ -50,8 +47,7 @@ public class AnimatedPress extends AnimatedKinetics {
} }
private float getAnimatedHeadOffset() { private float getAnimatedHeadOffset() {
float cycle = (ticks + Minecraft.getInstance() float cycle = (AnimationTickHolder.getRenderTick()) % 30;
.getRenderPartialTicks()) % 30;
if (cycle < 10) { if (cycle < 10) {
float progress = cycle / 10; float progress = cycle / 10;
return -(progress * progress * progress); return -(progress * progress * progress);

View file

@ -1,23 +1,22 @@
package com.simibubi.create.compat.jei.category.animations; package com.simibubi.create.compat.jei.category.animations;
import static com.simibubi.create.foundation.utility.AnimationTickHolder.ticks;
import java.util.List;
import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.systems.RenderSystem;
import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.AllBlocks; import com.simibubi.create.AllBlocks;
import com.simibubi.create.foundation.fluid.FluidRenderer; import com.simibubi.create.foundation.fluid.FluidRenderer;
import com.simibubi.create.foundation.gui.GuiGameElement; import com.simibubi.create.foundation.gui.GuiGameElement;
import com.simibubi.create.foundation.utility.AnimationTickHolder;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.IRenderTypeBuffer.Impl; import net.minecraft.client.renderer.IRenderTypeBuffer.Impl;
import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.Tessellator;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import java.util.List;
import static com.simibubi.create.foundation.utility.AnimationTickHolder.ticks;
public class AnimatedSpout extends AnimatedKinetics { public class AnimatedSpout extends AnimatedKinetics {
private List<FluidStack> fluids; private List<FluidStack> fluids;
@ -39,8 +38,7 @@ public class AnimatedSpout extends AnimatedKinetics {
.scale(scale) .scale(scale)
.render(); .render();
float cycle = (ticks + Minecraft.getInstance() float cycle = (ticks + AnimationTickHolder.getPartialTicks()) % 30;
.getRenderPartialTicks()) % 30;
float squeeze = cycle < 20 ? MathHelper.sin((float) (cycle / 20f * Math.PI)) : 0; float squeeze = cycle < 20 ? MathHelper.sin((float) (cycle / 20f * Math.PI)) : 0;
squeeze *= 20; squeeze *= 20;

View file

@ -1,19 +1,16 @@
package com.simibubi.create.content.contraptions.components.actors; package com.simibubi.create.content.contraptions.components.actors;
import java.util.function.Consumer;
import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.vertex.IVertexBuilder; import com.mojang.blaze3d.vertex.IVertexBuilder;
import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.AllBlocks; import com.simibubi.create.AllBlocks;
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext; import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
import com.simibubi.create.foundation.render.SuperByteBuffer;
import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer; import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer;
import com.simibubi.create.foundation.utility.AngleHelper; 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.MatrixStacker;
import com.simibubi.create.foundation.render.SuperByteBuffer;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
@ -22,6 +19,8 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import java.util.function.Consumer;
public class PortableStorageInterfaceRenderer extends SafeTileEntityRenderer<PortableStorageInterfaceTileEntity> { public class PortableStorageInterfaceRenderer extends SafeTileEntityRenderer<PortableStorageInterfaceTileEntity> {
public PortableStorageInterfaceRenderer(TileEntityRendererDispatcher dispatcher) { public PortableStorageInterfaceRenderer(TileEntityRendererDispatcher dispatcher) {
@ -43,8 +42,7 @@ public class PortableStorageInterfaceRenderer extends SafeTileEntityRenderer<Por
BlockState blockState = context.state; BlockState blockState = context.state;
PortableStorageInterfaceTileEntity te = getTargetPSI(context); PortableStorageInterfaceTileEntity te = getTargetPSI(context);
IVertexBuilder vb = buffer.getBuffer(RenderType.getSolid()); IVertexBuilder vb = buffer.getBuffer(RenderType.getSolid());
float renderPartialTicks = Minecraft.getInstance() float renderPartialTicks = AnimationTickHolder.getPartialTicks();
.getRenderPartialTicks();
float progress = 0; float progress = 0;
boolean lit = false; boolean lit = false;
@ -58,22 +56,6 @@ public class PortableStorageInterfaceRenderer extends SafeTileEntityRenderer<Por
.renderInto(ms, vb), ms, msLocal); .renderInto(ms, vb), ms, msLocal);
} }
protected static PortableStorageInterfaceTileEntity getTargetPSI(MovementContext context) {
String _workingPos_ = PortableStorageInterfaceMovement._workingPos_;
if (!context.contraption.stalled || !context.data.contains(_workingPos_))
return null;
BlockPos pos = NBTUtil.readBlockPos(context.data.getCompound(_workingPos_));
TileEntity tileEntity = context.world.getTileEntity(pos);
if (!(tileEntity instanceof PortableStorageInterfaceTileEntity))
return null;
PortableStorageInterfaceTileEntity psi = (PortableStorageInterfaceTileEntity) tileEntity;
if (!psi.isTransferring())
return null;
return psi;
}
private static void render(BlockState blockState, float progress, boolean lit, private static void render(BlockState blockState, float progress, boolean lit,
Consumer<SuperByteBuffer> drawCallback, MatrixStack... matrixStacks) { Consumer<SuperByteBuffer> drawCallback, MatrixStack... matrixStacks) {
for (MatrixStack ms : matrixStacks) for (MatrixStack ms : matrixStacks)
@ -109,6 +91,22 @@ public class PortableStorageInterfaceRenderer extends SafeTileEntityRenderer<Por
ms.pop(); ms.pop();
} }
protected static PortableStorageInterfaceTileEntity getTargetPSI(MovementContext context) {
String _workingPos_ = PortableStorageInterfaceMovement._workingPos_;
if (!context.contraption.stalled || !context.data.contains(_workingPos_))
return null;
BlockPos pos = NBTUtil.readBlockPos(context.data.getCompound(_workingPos_));
TileEntity tileEntity = context.world.getTileEntity(pos);
if (!(tileEntity instanceof PortableStorageInterfaceTileEntity))
return null;
PortableStorageInterfaceTileEntity psi = (PortableStorageInterfaceTileEntity) tileEntity;
if (!psi.isTransferring())
return null;
return psi;
}
static AllBlockPartials getMiddleForState(BlockState state, boolean lit) { static AllBlockPartials getMiddleForState(BlockState state, boolean lit) {
if (AllBlocks.PORTABLE_FLUID_INTERFACE.has(state)) if (AllBlocks.PORTABLE_FLUID_INTERFACE.has(state))
return lit ? AllBlockPartials.PORTABLE_FLUID_INTERFACE_MIDDLE_POWERED return lit ? AllBlockPartials.PORTABLE_FLUID_INTERFACE_MIDDLE_POWERED

View file

@ -185,8 +185,7 @@ public class DeployerRenderer extends SafeTileEntityRenderer<DeployerTileEntity>
double distance = context.position.distanceTo(center); double distance = context.position.distanceTo(center);
double nextDistance = context.position.add(context.motion) double nextDistance = context.position.add(context.motion)
.distanceTo(center); .distanceTo(center);
factor = .5f - MathHelper.clamp(MathHelper.lerp(Minecraft.getInstance() factor = .5f - MathHelper.clamp(MathHelper.lerp(AnimationTickHolder.getPartialTicks(), distance, nextDistance), 0, 1);
.getRenderPartialTicks(), distance, nextDistance), 0, 1);
} }
Vec3d offset = new Vec3d(blockState.get(FACING) Vec3d offset = new Vec3d(blockState.get(FACING)

View file

@ -1,9 +1,7 @@
package com.simibubi.create.content.contraptions.components.structureMovement; package com.simibubi.create.content.contraptions.components.structureMovement;
import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.matrix.MatrixStack;
import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.foundation.render.contraption.ContraptionRenderDispatcher;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.culling.ClippingHelperImpl; import net.minecraft.client.renderer.culling.ClippingHelperImpl;
import net.minecraft.client.renderer.entity.EntityRenderer; import net.minecraft.client.renderer.entity.EntityRenderer;
@ -24,6 +22,14 @@ public abstract class AbstractContraptionEntityRenderer<C extends AbstractContra
protected abstract void transform(C contraptionEntity, float partialTicks, MatrixStack[] matrixStacks); protected abstract void transform(C contraptionEntity, float partialTicks, MatrixStack[] matrixStacks);
public MatrixStack makeTransformMatrix(C contraptionEntity, float partialTicks) {
MatrixStack stack = getLocalTransform(contraptionEntity, partialTicks);
transform(contraptionEntity, partialTicks, new MatrixStack[]{ stack });
return stack;
}
@Override @Override
public boolean shouldRender(C entity, ClippingHelperImpl p_225626_2_, double p_225626_3_, double p_225626_5_, public boolean shouldRender(C entity, ClippingHelperImpl p_225626_2_, double p_225626_3_, double p_225626_5_,
double p_225626_7_) { double p_225626_7_) {
@ -42,7 +48,7 @@ public abstract class AbstractContraptionEntityRenderer<C extends AbstractContra
super.render(entity, yaw, partialTicks, ms, buffers, overlay); super.render(entity, yaw, partialTicks, ms, buffers, overlay);
// Keep a copy of the transforms in order to determine correct lighting // Keep a copy of the transforms in order to determine correct lighting
MatrixStack msLocal = getLocalTransform(entity); MatrixStack msLocal = getLocalTransform(entity, AnimationTickHolder.getRenderTick());
MatrixStack[] matrixStacks = new MatrixStack[] { ms, msLocal }; MatrixStack[] matrixStacks = new MatrixStack[] { ms, msLocal };
ms.push(); ms.push();
@ -50,15 +56,13 @@ public abstract class AbstractContraptionEntityRenderer<C extends AbstractContra
Contraption contraption = entity.getContraption(); Contraption contraption = entity.getContraption();
if (contraption != null) { if (contraption != null) {
ContraptionRenderer.renderDynamic(entity.world, contraption, ms, msLocal, buffers); ContraptionRenderer.renderDynamic(entity.world, contraption, ms, msLocal, buffers);
ContraptionRenderDispatcher.markForRendering(entity.world, contraption, msLocal); //ContraptionRenderDispatcher.markForRendering(entity.world, contraption, msLocal);
} }
ms.pop(); ms.pop();
} }
protected MatrixStack getLocalTransform(AbstractContraptionEntity entity) { protected MatrixStack getLocalTransform(AbstractContraptionEntity entity, float pt) {
double pt = Minecraft.getInstance()
.getRenderPartialTicks();
MatrixStack matrixStack = new MatrixStack(); MatrixStack matrixStack = new MatrixStack();
double x = MathHelper.lerp(pt, entity.lastTickPosX, entity.getX()); double x = MathHelper.lerp(pt, entity.lastTickPosX, entity.getX());
double y = MathHelper.lerp(pt, entity.lastTickPosY, entity.getY()); double y = MathHelper.lerp(pt, entity.lastTickPosY, entity.getY());

View file

@ -1,30 +1,5 @@
package com.simibubi.create.content.contraptions.components.structureMovement; package com.simibubi.create.content.contraptions.components.structureMovement;
import static com.simibubi.create.content.contraptions.components.structureMovement.piston.MechanicalPistonBlock.isExtensionPole;
import static com.simibubi.create.content.contraptions.components.structureMovement.piston.MechanicalPistonBlock.isPistonHead;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;
import java.util.function.BiConsumer;
import java.util.stream.Collectors;
import javax.annotation.Nullable;
import com.simibubi.create.foundation.render.light.ContraptionLighter;
import com.simibubi.create.foundation.render.light.EmptyLighter;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import org.apache.commons.lang3.tuple.MutablePair;
import org.apache.commons.lang3.tuple.Pair;
import com.simibubi.create.AllBlocks; import com.simibubi.create.AllBlocks;
import com.simibubi.create.AllMovementBehaviours; import com.simibubi.create.AllMovementBehaviours;
import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntity;
@ -49,20 +24,14 @@ import com.simibubi.create.content.logistics.block.inventories.AdjustableCrateBl
import com.simibubi.create.content.logistics.block.redstone.RedstoneContactBlock; import com.simibubi.create.content.logistics.block.redstone.RedstoneContactBlock;
import com.simibubi.create.foundation.config.AllConfigs; import com.simibubi.create.foundation.config.AllConfigs;
import com.simibubi.create.foundation.fluid.CombinedTankWrapper; import com.simibubi.create.foundation.fluid.CombinedTankWrapper;
import com.simibubi.create.foundation.render.light.ContraptionLighter;
import com.simibubi.create.foundation.render.light.EmptyLighter;
import com.simibubi.create.foundation.utility.BlockFace; import com.simibubi.create.foundation.utility.BlockFace;
import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.Iterate;
import com.simibubi.create.foundation.utility.NBTHelper; import com.simibubi.create.foundation.utility.NBTHelper;
import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.VecHelper;
import com.simibubi.create.foundation.utility.worldWrappers.WrappedWorld; import com.simibubi.create.foundation.utility.worldWrappers.WrappedWorld;
import net.minecraft.block.*;
import net.minecraft.block.AbstractButtonBlock;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.ChestBlock;
import net.minecraft.block.DoorBlock;
import net.minecraft.block.IWaterLoggable;
import net.minecraft.block.PressurePlateBlock;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.fluid.Fluids; import net.minecraft.fluid.Fluids;
import net.minecraft.fluid.IFluidState; import net.minecraft.fluid.IFluidState;
@ -84,6 +53,8 @@ import net.minecraft.util.math.Vec3d;
import net.minecraft.world.IWorld; import net.minecraft.world.IWorld;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.gen.feature.template.Template.BlockInfo; import net.minecraft.world.gen.feature.template.Template.BlockInfo;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.common.util.Constants.BlockFlags; import net.minecraftforge.common.util.Constants.BlockFlags;
import net.minecraftforge.common.util.Constants.NBT; import net.minecraftforge.common.util.Constants.NBT;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
@ -93,6 +64,16 @@ import net.minecraftforge.fluids.capability.IFluidHandler.FluidAction;
import net.minecraftforge.fluids.capability.templates.FluidTank; import net.minecraftforge.fluids.capability.templates.FluidTank;
import net.minecraftforge.items.IItemHandlerModifiable; import net.minecraftforge.items.IItemHandlerModifiable;
import net.minecraftforge.items.wrapper.CombinedInvWrapper; import net.minecraftforge.items.wrapper.CombinedInvWrapper;
import org.apache.commons.lang3.tuple.MutablePair;
import org.apache.commons.lang3.tuple.Pair;
import javax.annotation.Nullable;
import java.util.*;
import java.util.function.BiConsumer;
import java.util.stream.Collectors;
import static com.simibubi.create.content.contraptions.components.structureMovement.piston.MechanicalPistonBlock.isExtensionPole;
import static com.simibubi.create.content.contraptions.components.structureMovement.piston.MechanicalPistonBlock.isPistonHead;
public abstract class Contraption { public abstract class Contraption {
@ -192,7 +173,7 @@ public abstract class Contraption {
// Create subcontraptions // Create subcontraptions
for (BlockFace blockFace : pendingSubContraptions) { for (BlockFace blockFace : pendingSubContraptions) {
Direction face = blockFace.getFace(); Direction face = blockFace.getFace();
StabilizedContraption subContraption = new StabilizedContraption(entity.getUniqueID(), face); StabilizedContraption subContraption = new StabilizedContraption(face);
World world = entity.world; World world = entity.world;
BlockPos pos = blockFace.getPos(); BlockPos pos = blockFace.getPos();
if (!subContraption.assemble(world, pos)) if (!subContraption.assemble(world, pos))

View file

@ -1,11 +1,11 @@
package com.simibubi.create.content.contraptions.components.structureMovement.mounted; package com.simibubi.create.content.contraptions.components.structureMovement;
import com.simibubi.create.foundation.render.contraption.RenderedContraption; import com.simibubi.create.foundation.render.contraption.RenderedContraption;
import com.simibubi.create.foundation.render.light.ContraptionLighter; import com.simibubi.create.foundation.render.light.ContraptionLighter;
import com.simibubi.create.foundation.render.light.GridAlignedBB; import com.simibubi.create.foundation.render.light.GridAlignedBB;
public class MountedLighter extends ContraptionLighter<MountedContraption> { public class NonStationaryLighter<C extends Contraption> extends ContraptionLighter<C> {
public MountedLighter(MountedContraption contraption) { public NonStationaryLighter(C contraption) {
super(contraption); super(contraption);
} }

View file

@ -2,15 +2,10 @@ package com.simibubi.create.content.contraptions.components.structureMovement.be
import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.matrix.MatrixStack;
import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.components.structureMovement.AbstractContraptionEntity; import com.simibubi.create.content.contraptions.components.structureMovement.*;
import com.simibubi.create.content.contraptions.components.structureMovement.ControlledContraptionEntity;
import com.simibubi.create.content.contraptions.components.structureMovement.MovementBehaviour;
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
import com.simibubi.create.content.contraptions.components.structureMovement.OrientedContraptionEntity;
import com.simibubi.create.foundation.utility.AngleHelper;
import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.render.SuperByteBuffer;
import com.simibubi.create.foundation.utility.AngleHelper;
import net.minecraft.client.Minecraft; import com.simibubi.create.foundation.utility.AnimationTickHolder;
import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.RenderType;
import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.state.properties.BlockStateProperties;
@ -28,8 +23,7 @@ public class StabilizedBearingMovementBehaviour extends MovementBehaviour {
Direction facing = context.state.get(BlockStateProperties.FACING); Direction facing = context.state.get(BlockStateProperties.FACING);
AllBlockPartials top = AllBlockPartials.BEARING_TOP; AllBlockPartials top = AllBlockPartials.BEARING_TOP;
SuperByteBuffer superBuffer = top.renderOn(context.state); SuperByteBuffer superBuffer = top.renderOn(context.state);
float renderPartialTicks = Minecraft.getInstance() float renderPartialTicks = AnimationTickHolder.getPartialTicks();
.getRenderPartialTicks();
// rotate to match blockstate // rotate to match blockstate
Axis axis = facing.getAxis(); Axis axis = facing.getAxis();

View file

@ -1,31 +1,22 @@
package com.simibubi.create.content.contraptions.components.structureMovement.bearing; package com.simibubi.create.content.contraptions.components.structureMovement.bearing;
import com.simibubi.create.content.contraptions.components.structureMovement.AbstractContraptionEntity;
import com.simibubi.create.content.contraptions.components.structureMovement.AllContraptionTypes; import com.simibubi.create.content.contraptions.components.structureMovement.AllContraptionTypes;
import com.simibubi.create.content.contraptions.components.structureMovement.Contraption; import com.simibubi.create.content.contraptions.components.structureMovement.Contraption;
import com.simibubi.create.content.contraptions.components.structureMovement.NonStationaryLighter;
import com.simibubi.create.foundation.render.light.ContraptionLighter; import com.simibubi.create.foundation.render.light.ContraptionLighter;
import com.simibubi.create.foundation.utility.NBTHelper;
import net.minecraft.entity.Entity;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
import net.minecraft.util.Direction.Axis; import net.minecraft.util.Direction.Axis;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
import java.util.UUID;
public class StabilizedContraption extends Contraption { public class StabilizedContraption extends Contraption {
public UUID parentID;
private Direction facing; private Direction facing;
public StabilizedContraption() {} public StabilizedContraption() {}
public StabilizedContraption(UUID parentID, Direction facing) { public StabilizedContraption(Direction facing) {
this.parentID = parentID;
this.facing = facing; this.facing = facing;
} }
@ -55,14 +46,12 @@ public class StabilizedContraption extends Contraption {
public CompoundNBT writeNBT(boolean spawnPacket) { public CompoundNBT writeNBT(boolean spawnPacket) {
CompoundNBT tag = super.writeNBT(spawnPacket); CompoundNBT tag = super.writeNBT(spawnPacket);
tag.putInt("Facing", facing.getIndex()); tag.putInt("Facing", facing.getIndex());
tag.putUniqueId("Parent", parentID);
return tag; return tag;
} }
@Override @Override
public void readNBT(World world, CompoundNBT tag, boolean spawnData) { public void readNBT(World world, CompoundNBT tag, boolean spawnData) {
facing = Direction.byIndex(tag.getInt("Facing")); facing = Direction.byIndex(tag.getInt("Facing"));
parentID = tag.getUniqueId("Parent");
super.readNBT(world, tag, spawnData); super.readNBT(world, tag, spawnData);
} }
@ -77,6 +66,6 @@ public class StabilizedContraption extends Contraption {
@Override @Override
public ContraptionLighter<?> makeLighter() { public ContraptionLighter<?> makeLighter() {
return new StabilizedLighter(this); return new NonStationaryLighter<>(this);
} }
} }

View file

@ -1,37 +0,0 @@
package com.simibubi.create.content.contraptions.components.structureMovement.bearing;
import com.simibubi.create.content.contraptions.components.structureMovement.AbstractContraptionEntity;
import com.simibubi.create.content.contraptions.components.structureMovement.Contraption;
import com.simibubi.create.foundation.render.contraption.RenderedContraption;
import com.simibubi.create.foundation.render.light.ContraptionLighter;
import com.simibubi.create.foundation.render.light.GridAlignedBB;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.entity.Entity;
import net.minecraft.util.math.Vec3i;
import java.util.List;
public class StabilizedLighter extends ContraptionLighter<StabilizedContraption> {
public StabilizedLighter(StabilizedContraption contraption) {
super(contraption);
}
@Override
public void tick(RenderedContraption owner) {
GridAlignedBB contraptionBounds = getContraptionBounds();
if (!contraptionBounds.sameAs(bounds)) {
lightVolume.move(contraption.entity.world, contraptionBoundsToVolume(contraptionBounds));
bounds = contraptionBounds;
}
}
@Override
public GridAlignedBB getContraptionBounds() {
GridAlignedBB bb = GridAlignedBB.fromAABB(contraption.bounds);
bb.translate(contraption.entity.getPosition());
return bb;
}
}

View file

@ -1,9 +1,5 @@
package com.simibubi.create.content.contraptions.components.structureMovement.glue; package com.simibubi.create.content.contraptions.components.structureMovement.glue;
import javax.annotation.Nullable;
import org.apache.commons.lang3.Validate;
import com.simibubi.create.AllEntityTypes; import com.simibubi.create.AllEntityTypes;
import com.simibubi.create.AllItems; import com.simibubi.create.AllItems;
import com.simibubi.create.AllSoundEvents; import com.simibubi.create.AllSoundEvents;
@ -12,17 +8,13 @@ import com.simibubi.create.content.schematics.ISpecialEntityItemRequirement;
import com.simibubi.create.content.schematics.ItemRequirement; import com.simibubi.create.content.schematics.ItemRequirement;
import com.simibubi.create.content.schematics.ItemRequirement.ItemUseType; import com.simibubi.create.content.schematics.ItemRequirement.ItemUseType;
import com.simibubi.create.foundation.networking.AllPackets; import com.simibubi.create.foundation.networking.AllPackets;
import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.foundation.utility.BlockFace; import com.simibubi.create.foundation.utility.BlockFace;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.player.ClientPlayerEntity; import net.minecraft.client.entity.player.ClientPlayerEntity;
import net.minecraft.client.world.ClientWorld; import net.minecraft.client.world.ClientWorld;
import net.minecraft.entity.Entity; import net.minecraft.entity.*;
import net.minecraft.entity.EntitySize;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.MoverType;
import net.minecraft.entity.Pose;
import net.minecraft.entity.effect.LightningBoltEntity; import net.minecraft.entity.effect.LightningBoltEntity;
import net.minecraft.entity.item.ItemEntity; import net.minecraft.entity.item.ItemEntity;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
@ -30,20 +22,9 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundNBT;
import net.minecraft.network.IPacket; import net.minecraft.network.IPacket;
import net.minecraft.network.PacketBuffer; import net.minecraft.network.PacketBuffer;
import net.minecraft.util.ActionResultType; import net.minecraft.util.*;
import net.minecraft.util.DamageSource;
import net.minecraft.util.Direction;
import net.minecraft.util.Direction.Axis; import net.minecraft.util.Direction.Axis;
import net.minecraft.util.Hand; import net.minecraft.util.math.*;
import net.minecraft.util.Mirror;
import net.minecraft.util.Rotation;
import net.minecraft.util.SoundEvents;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.RayTraceResult.Type; import net.minecraft.util.math.RayTraceResult.Type;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
@ -52,6 +33,9 @@ import net.minecraftforge.fml.DistExecutor;
import net.minecraftforge.fml.common.registry.IEntityAdditionalSpawnData; import net.minecraftforge.fml.common.registry.IEntityAdditionalSpawnData;
import net.minecraftforge.fml.network.NetworkHooks; import net.minecraftforge.fml.network.NetworkHooks;
import net.minecraftforge.fml.network.PacketDistributor; import net.minecraftforge.fml.network.PacketDistributor;
import org.apache.commons.lang3.Validate;
import javax.annotation.Nullable;
public class SuperGlueEntity extends Entity implements IEntityAdditionalSpawnData, ISpecialEntityItemRequirement { public class SuperGlueEntity extends Entity implements IEntityAdditionalSpawnData, ISpecialEntityItemRequirement {
@ -266,7 +250,7 @@ public class SuperGlueEntity extends Entity implements IEntityAdditionalSpawnDat
ClientPlayerEntity cPlayer = (ClientPlayerEntity) player; ClientPlayerEntity cPlayer = (ClientPlayerEntity) player;
Minecraft mc = Minecraft.getInstance(); Minecraft mc = Minecraft.getInstance();
RayTraceResult ray = RayTraceResult ray =
cPlayer.pick(mc.playerController.getBlockReachDistance(), mc.getRenderPartialTicks(), false); cPlayer.pick(mc.playerController.getBlockReachDistance(), AnimationTickHolder.getPartialTicks(), false);
if (!(ray instanceof BlockRayTraceResult)) if (!(ray instanceof BlockRayTraceResult))
return; return;

View file

@ -1,20 +1,14 @@
package com.simibubi.create.content.contraptions.components.structureMovement.mounted; package com.simibubi.create.content.contraptions.components.structureMovement.mounted;
import static com.simibubi.create.content.contraptions.components.structureMovement.mounted.CartAssemblerBlock.RAIL_SHAPE;
import java.util.List;
import com.simibubi.create.foundation.render.light.ContraptionLighter;
import org.apache.commons.lang3.tuple.Pair;
import com.simibubi.create.AllBlocks; import com.simibubi.create.AllBlocks;
import com.simibubi.create.content.contraptions.components.structureMovement.AllContraptionTypes; import com.simibubi.create.content.contraptions.components.structureMovement.AllContraptionTypes;
import com.simibubi.create.content.contraptions.components.structureMovement.Contraption; import com.simibubi.create.content.contraptions.components.structureMovement.Contraption;
import com.simibubi.create.content.contraptions.components.structureMovement.NonStationaryLighter;
import com.simibubi.create.content.contraptions.components.structureMovement.mounted.CartAssemblerTileEntity.CartMovementMode; import com.simibubi.create.content.contraptions.components.structureMovement.mounted.CartAssemblerTileEntity.CartMovementMode;
import com.simibubi.create.foundation.render.light.ContraptionLighter;
import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.Iterate;
import com.simibubi.create.foundation.utility.NBTHelper; import com.simibubi.create.foundation.utility.NBTHelper;
import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.VecHelper;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.item.minecart.AbstractMinecartEntity; import net.minecraft.entity.item.minecart.AbstractMinecartEntity;
@ -33,6 +27,11 @@ import net.minecraft.world.gen.feature.template.Template.BlockInfo;
import net.minecraftforge.items.IItemHandlerModifiable; import net.minecraftforge.items.IItemHandlerModifiable;
import net.minecraftforge.items.wrapper.CombinedInvWrapper; import net.minecraftforge.items.wrapper.CombinedInvWrapper;
import net.minecraftforge.items.wrapper.InvWrapper; import net.minecraftforge.items.wrapper.InvWrapper;
import org.apache.commons.lang3.tuple.Pair;
import java.util.List;
import static com.simibubi.create.content.contraptions.components.structureMovement.mounted.CartAssemblerBlock.RAIL_SHAPE;
public class MountedContraption extends Contraption { public class MountedContraption extends Contraption {
@ -164,6 +163,6 @@ public class MountedContraption extends Contraption {
@Override @Override
public ContraptionLighter<?> makeLighter() { public ContraptionLighter<?> makeLighter() {
return new MountedLighter(this); return new NonStationaryLighter<>(this);
} }
} }

View file

@ -1,19 +1,13 @@
package com.simibubi.create.content.contraptions.components.structureMovement.train; package com.simibubi.create.content.contraptions.components.structureMovement.train;
import static net.minecraft.util.math.MathHelper.lerp;
import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.vertex.IVertexBuilder; import com.mojang.blaze3d.vertex.IVertexBuilder;
import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.CreateClient; import com.simibubi.create.CreateClient;
import com.simibubi.create.content.contraptions.KineticDebugger; import com.simibubi.create.content.contraptions.KineticDebugger;
import com.simibubi.create.content.contraptions.components.structureMovement.train.capability.MinecartController; import com.simibubi.create.content.contraptions.components.structureMovement.train.capability.MinecartController;
import com.simibubi.create.foundation.utility.ColorHelper;
import com.simibubi.create.foundation.utility.Couple;
import com.simibubi.create.foundation.utility.MatrixStacker;
import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.render.SuperByteBuffer;
import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.*;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
@ -28,6 +22,8 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
import static net.minecraft.util.math.MathHelper.lerp;
public class CouplingRenderer { public class CouplingRenderer {
public static void renderAll(MatrixStack ms, IRenderTypeBuffer buffer) { public static void renderAll(MatrixStack ms, IRenderTypeBuffer buffer) {
@ -115,8 +111,7 @@ public class CouplingRenderer {
float y = (((float) (i >> 20 & 7L) + 0.5F) / 8.0F - 0.5F) * 0.004F + 0.375F; float y = (((float) (i >> 20 & 7L) + 0.5F) / 8.0F - 0.5F) * 0.004F + 0.375F;
float z = (((float) (i >> 24 & 7L) + 0.5F) / 8.0F - 0.5F) * 0.004F; float z = (((float) (i >> 24 & 7L) + 0.5F) / 8.0F - 0.5F) * 0.004F;
float pt = Minecraft.getInstance() float pt = AnimationTickHolder.getPartialTicks();
.getRenderPartialTicks();
double xIn = lerp(pt, cart.lastTickPosX, cart.getX()); double xIn = lerp(pt, cart.lastTickPosX, cart.getX());
double yIn = lerp(pt, cart.lastTickPosY, cart.getY()); double yIn = lerp(pt, cart.lastTickPosY, cart.getY());

View file

@ -1,8 +1,8 @@
package com.simibubi.create.content.contraptions.components.turntable; package com.simibubi.create.content.contraptions.components.turntable;
import com.simibubi.create.AllBlocks; import com.simibubi.create.AllBlocks;
import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.VecHelper;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
@ -38,7 +38,7 @@ public class TurntableHandler {
if (offset.length() > 1/4f) if (offset.length() > 1/4f)
speed *= MathHelper.clamp((1/2f - offset.length()) * 2, 0, 1); speed *= MathHelper.clamp((1/2f - offset.length()) * 2, 0, 1);
mc.player.rotationYaw = mc.player.prevRotationYaw - speed * mc.getRenderPartialTicks(); mc.player.rotationYaw = mc.player.prevRotationYaw - speed * AnimationTickHolder.getPartialTicks();
mc.player.renderYawOffset = mc.player.rotationYaw; mc.player.renderYawOffset = mc.player.rotationYaw;
} }

View file

@ -2,7 +2,6 @@ package com.simibubi.create.content.curiosities;
import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.foundation.utility.ColorHelper; import com.simibubi.create.foundation.utility.ColorHelper;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.color.IItemColor; import net.minecraft.client.renderer.color.IItemColor;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@ -13,7 +12,7 @@ public class ChromaticCompoundColor implements IItemColor {
@Override @Override
public int getColor(ItemStack stack, int layer) { public int getColor(ItemStack stack, int layer) {
Minecraft mc = Minecraft.getInstance(); Minecraft mc = Minecraft.getInstance();
float pt = mc.getRenderPartialTicks(); float pt = AnimationTickHolder.getPartialTicks();
float progress = (float) ((mc.player.getYaw(pt)) / 180 * Math.PI) + (AnimationTickHolder.getRenderTick() / 10f); float progress = (float) ((mc.player.getYaw(pt)) / 180 * Math.PI) + (AnimationTickHolder.getRenderTick() / 10f);
if (layer == 0) if (layer == 0)
return ColorHelper.mixColors(0x6e5773, 0x6B3074, ((float) MathHelper.sin(progress) + 1) / 2); return ColorHelper.mixColors(0x6e5773, 0x6B3074, ((float) MathHelper.sin(progress) + 1) / 2);

View file

@ -1,13 +1,11 @@
package com.simibubi.create.content.curiosities.tools; package com.simibubi.create.content.curiosities.tools;
import java.util.UUID;
import com.google.common.collect.HashMultimap; import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap; import com.google.common.collect.Multimap;
import com.simibubi.create.AllItems; import com.simibubi.create.AllItems;
import com.simibubi.create.foundation.advancement.AllTriggers; import com.simibubi.create.foundation.advancement.AllTriggers;
import com.simibubi.create.foundation.networking.AllPackets; import com.simibubi.create.foundation.networking.AllPackets;
import com.simibubi.create.foundation.utility.AnimationTickHolder;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.player.ClientPlayerEntity; import net.minecraft.client.entity.player.ClientPlayerEntity;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
@ -35,6 +33,8 @@ import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber; import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
import java.util.UUID;
@EventBusSubscriber @EventBusSubscriber
public class ExtendoGripItem extends Item { public class ExtendoGripItem extends Item {
@ -125,7 +125,7 @@ public class ExtendoGripItem extends Item {
.getValue(); .getValue();
if (!player.isCreative()) if (!player.isCreative())
d0 -= 0.5f; d0 -= 0.5f;
Vec3d vec3d = player.getEyePosition(mc.getRenderPartialTicks()); Vec3d vec3d = player.getEyePosition(AnimationTickHolder.getPartialTicks());
Vec3d vec3d1 = player.getLook(1.0F); Vec3d vec3d1 = player.getLook(1.0F);
Vec3d vec3d2 = vec3d.add(vec3d1.x * d0, vec3d1.y * d0, vec3d1.z * d0); Vec3d vec3d2 = vec3d.add(vec3d1.x * d0, vec3d1.y * d0, vec3d1.z * d0);
AxisAlignedBB axisalignedbb = player.getBoundingBox() AxisAlignedBB axisalignedbb = player.getBoundingBox()

View file

@ -6,8 +6,6 @@ import com.simibubi.create.foundation.block.render.CustomRenderedItemModelRender
import com.simibubi.create.foundation.item.PartialItemModelRenderer; import com.simibubi.create.foundation.item.PartialItemModelRenderer;
import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.foundation.utility.MatrixStacker; import com.simibubi.create.foundation.utility.MatrixStacker;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType; import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@ -28,9 +26,9 @@ public class ExtendoGripItemRenderer extends CustomRenderedItemModelRenderer<Ext
boolean leftHand = perspective == TransformType.FIRST_PERSON_LEFT_HAND; boolean leftHand = perspective == TransformType.FIRST_PERSON_LEFT_HAND;
boolean rightHand = perspective == TransformType.FIRST_PERSON_RIGHT_HAND; boolean rightHand = perspective == TransformType.FIRST_PERSON_RIGHT_HAND;
if (leftHand || rightHand) if (leftHand || rightHand)
animation = MathHelper.lerp(Minecraft.getInstance() animation = MathHelper.lerp(AnimationTickHolder.getPartialTicks(),
.getRenderPartialTicks(), ExtendoGripRenderHandler.lastMainHandAnimation, ExtendoGripRenderHandler.lastMainHandAnimation,
ExtendoGripRenderHandler.mainHandAnimation); ExtendoGripRenderHandler.mainHandAnimation);
animation = animation * animation * animation; animation = animation * animation * animation;
float extensionAngle = MathHelper.lerp(animation, 24f, 156f); float extensionAngle = MathHelper.lerp(animation, 24f, 156f);

View file

@ -3,8 +3,8 @@ package com.simibubi.create.content.curiosities.tools;
import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.matrix.MatrixStack;
import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.AllItems; import com.simibubi.create.AllItems;
import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.foundation.utility.MatrixStacker; import com.simibubi.create.foundation.utility.MatrixStacker;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.player.AbstractClientPlayerEntity; import net.minecraft.client.entity.player.AbstractClientPlayerEntity;
import net.minecraft.client.entity.player.ClientPlayerEntity; import net.minecraft.client.entity.player.ClientPlayerEntity;
@ -79,9 +79,9 @@ public class ExtendoGripRenderHandler {
if (1 - swingProgress > mainHandAnimation && swingProgress > 0) if (1 - swingProgress > mainHandAnimation && swingProgress > 0)
mainHandAnimation = 0.95f; mainHandAnimation = 0.95f;
float animation = MathHelper.lerp(Minecraft.getInstance() float animation = MathHelper.lerp(AnimationTickHolder.getPartialTicks(),
.getRenderPartialTicks(), ExtendoGripRenderHandler.lastMainHandAnimation, ExtendoGripRenderHandler.lastMainHandAnimation,
ExtendoGripRenderHandler.mainHandAnimation); ExtendoGripRenderHandler.mainHandAnimation);
animation = animation * animation * animation; animation = animation * animation * animation;
ms.translate(flip * (0.64000005F - .1f), -0.4F + equipProgress * -0.6F, -0.71999997F + .3f); ms.translate(flip * (0.64000005F - .1f), -0.4F + equipProgress * -0.6F, -0.71999997F + .3f);

View file

@ -4,7 +4,6 @@ import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.systems.RenderSystem;
import com.simibubi.create.foundation.block.render.CustomRenderedItemModel; import com.simibubi.create.foundation.block.render.CustomRenderedItemModel;
import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.AnimationTickHolder;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.player.ClientPlayerEntity; import net.minecraft.client.entity.player.ClientPlayerEntity;
import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.IRenderTypeBuffer;
@ -25,7 +24,7 @@ public class SandPaperItemRenderer extends ItemStackTileEntityRenderer {
ClientPlayerEntity player = Minecraft.getInstance().player; ClientPlayerEntity player = Minecraft.getInstance().player;
SandPaperModel mainModel = (SandPaperModel) itemRenderer.getItemModelWithOverrides(stack, Minecraft.getInstance().world, null); SandPaperModel mainModel = (SandPaperModel) itemRenderer.getItemModelWithOverrides(stack, Minecraft.getInstance().world, null);
TransformType perspective = mainModel.getCurrentPerspective(); TransformType perspective = mainModel.getCurrentPerspective();
float partialTicks = Minecraft.getInstance().getRenderPartialTicks(); float partialTicks = AnimationTickHolder.getPartialTicks();
boolean leftHand = perspective == TransformType.FIRST_PERSON_LEFT_HAND; boolean leftHand = perspective == TransformType.FIRST_PERSON_LEFT_HAND;
boolean firstPerson = leftHand || perspective == TransformType.FIRST_PERSON_RIGHT_HAND; boolean firstPerson = leftHand || perspective == TransformType.FIRST_PERSON_RIGHT_HAND;

View file

@ -1,14 +1,9 @@
package com.simibubi.create.content.curiosities.zapper; package com.simibubi.create.content.curiosities.zapper;
import java.util.LinkedList;
import java.util.List;
import java.util.Random;
import java.util.function.Supplier;
import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.matrix.MatrixStack;
import com.simibubi.create.AllSoundEvents; import com.simibubi.create.AllSoundEvents;
import com.simibubi.create.CreateClient; import com.simibubi.create.CreateClient;
import com.simibubi.create.foundation.utility.AnimationTickHolder;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.player.AbstractClientPlayerEntity; import net.minecraft.client.entity.player.AbstractClientPlayerEntity;
import net.minecraft.client.entity.player.ClientPlayerEntity; import net.minecraft.client.entity.player.ClientPlayerEntity;
@ -30,6 +25,11 @@ import net.minecraftforge.client.event.RenderHandEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber; import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
import java.util.LinkedList;
import java.util.List;
import java.util.Random;
import java.util.function.Supplier;
@EventBusSubscriber(value = Dist.CLIENT) @EventBusSubscriber(value = Dist.CLIENT)
public class ZapperRenderHandler { public class ZapperRenderHandler {
@ -63,8 +63,7 @@ public class ZapperRenderHandler {
} }
public static Vec3d getExactBarrelPos(boolean mainHand) { public static Vec3d getExactBarrelPos(boolean mainHand) {
float partialTicks = Minecraft.getInstance() float partialTicks = AnimationTickHolder.getPartialTicks();
.getRenderPartialTicks();
ClientPlayerEntity player = Minecraft.getInstance().player; ClientPlayerEntity player = Minecraft.getInstance().player;
float yaw = (float) ((player.getYaw(partialTicks)) / -180 * Math.PI); float yaw = (float) ((player.getYaw(partialTicks)) / -180 * Math.PI);
float pitch = (float) ((player.getPitch(partialTicks)) / -180 * Math.PI); float pitch = (float) ((player.getPitch(partialTicks)) / -180 * Math.PI);

View file

@ -1,20 +1,11 @@
package com.simibubi.create.content.curiosities.zapper.blockzapper; package com.simibubi.create.content.curiosities.zapper.blockzapper;
import static com.simibubi.create.content.curiosities.zapper.blockzapper.BlockzapperItem.Components.Accelerator;
import static com.simibubi.create.content.curiosities.zapper.blockzapper.BlockzapperItem.Components.Amplifier;
import static com.simibubi.create.content.curiosities.zapper.blockzapper.BlockzapperItem.Components.Body;
import static com.simibubi.create.content.curiosities.zapper.blockzapper.BlockzapperItem.Components.Retriever;
import static com.simibubi.create.content.curiosities.zapper.blockzapper.BlockzapperItem.Components.Scope;
import static java.lang.Math.max;
import static net.minecraft.util.math.MathHelper.clamp;
import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.matrix.MatrixStack;
import com.simibubi.create.content.curiosities.zapper.ZapperItemRenderer; import com.simibubi.create.content.curiosities.zapper.ZapperItemRenderer;
import com.simibubi.create.content.curiosities.zapper.blockzapper.BlockzapperItem.ComponentTier; import com.simibubi.create.content.curiosities.zapper.blockzapper.BlockzapperItem.ComponentTier;
import com.simibubi.create.content.curiosities.zapper.blockzapper.BlockzapperItem.Components; import com.simibubi.create.content.curiosities.zapper.blockzapper.BlockzapperItem.Components;
import com.simibubi.create.foundation.item.PartialItemModelRenderer; import com.simibubi.create.foundation.item.PartialItemModelRenderer;
import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.AnimationTickHolder;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.player.ClientPlayerEntity; import net.minecraft.client.entity.player.ClientPlayerEntity;
import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.IRenderTypeBuffer;
@ -25,6 +16,10 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.HandSide; import net.minecraft.util.HandSide;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import static com.simibubi.create.content.curiosities.zapper.blockzapper.BlockzapperItem.Components.*;
import static java.lang.Math.max;
import static net.minecraft.util.math.MathHelper.clamp;
public class BlockzapperItemRenderer extends ZapperItemRenderer<BlockzapperModel> { public class BlockzapperItemRenderer extends ZapperItemRenderer<BlockzapperModel> {
@Override @Override
@ -32,8 +27,7 @@ public class BlockzapperItemRenderer extends ZapperItemRenderer<BlockzapperModel
IRenderTypeBuffer buffer, int light, int overlay) { IRenderTypeBuffer buffer, int light, int overlay) {
super.render(stack, model, renderer, ms, buffer, light, overlay); super.render(stack, model, renderer, ms, buffer, light, overlay);
float pt = Minecraft.getInstance() float pt = AnimationTickHolder.getPartialTicks();
.getRenderPartialTicks();
float worldTime = AnimationTickHolder.getRenderTick() / 20; float worldTime = AnimationTickHolder.getRenderTick() / 20;
renderer.render(model.getBakedModel(), light); renderer.render(model.getBakedModel(), light);

View file

@ -1,13 +1,9 @@
package com.simibubi.create.content.curiosities.zapper.terrainzapper; package com.simibubi.create.content.curiosities.zapper.terrainzapper;
import static java.lang.Math.max;
import static net.minecraft.util.math.MathHelper.clamp;
import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.matrix.MatrixStack;
import com.simibubi.create.content.curiosities.zapper.ZapperItemRenderer; import com.simibubi.create.content.curiosities.zapper.ZapperItemRenderer;
import com.simibubi.create.foundation.item.PartialItemModelRenderer; import com.simibubi.create.foundation.item.PartialItemModelRenderer;
import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.AnimationTickHolder;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.player.ClientPlayerEntity; import net.minecraft.client.entity.player.ClientPlayerEntity;
import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.IRenderTypeBuffer;
@ -17,6 +13,9 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.HandSide; import net.minecraft.util.HandSide;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import static java.lang.Math.max;
import static net.minecraft.util.math.MathHelper.clamp;
public class WorldshaperItemRenderer extends ZapperItemRenderer<WorldshaperModel> { public class WorldshaperItemRenderer extends ZapperItemRenderer<WorldshaperModel> {
@Override @Override
@ -24,8 +23,7 @@ public class WorldshaperItemRenderer extends ZapperItemRenderer<WorldshaperModel
IRenderTypeBuffer buffer, int light, int overlay) { IRenderTypeBuffer buffer, int light, int overlay) {
super.render(stack, model, renderer, ms, buffer, light, overlay); super.render(stack, model, renderer, ms, buffer, light, overlay);
float pt = Minecraft.getInstance() float pt = AnimationTickHolder.getPartialTicks();
.getRenderPartialTicks();
float worldTime = AnimationTickHolder.getRenderTick() / 20; float worldTime = AnimationTickHolder.getRenderTick() / 20;
renderer.renderSolid(model.getBakedModel(), light); renderer.renderSolid(model.getBakedModel(), light);

View file

@ -1,30 +1,13 @@
package com.simibubi.create.content.schematics.client; package com.simibubi.create.content.schematics.client;
import java.io.IOException; import com.simibubi.create.*;
import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import org.apache.commons.io.IOUtils;
import com.simibubi.create.AllItems;
import com.simibubi.create.AllKeys;
import com.simibubi.create.AllSpecialTextures;
import com.simibubi.create.Create;
import com.simibubi.create.CreateClient;
import com.simibubi.create.content.schematics.ClientSchematicLoader; import com.simibubi.create.content.schematics.ClientSchematicLoader;
import com.simibubi.create.content.schematics.packet.InstantSchematicPacket; import com.simibubi.create.content.schematics.packet.InstantSchematicPacket;
import com.simibubi.create.foundation.gui.ScreenOpener; import com.simibubi.create.foundation.gui.ScreenOpener;
import com.simibubi.create.foundation.networking.AllPackets; import com.simibubi.create.foundation.networking.AllPackets;
import com.simibubi.create.foundation.utility.FilesHelper; import com.simibubi.create.foundation.utility.*;
import com.simibubi.create.foundation.utility.Lang;
import com.simibubi.create.foundation.utility.RaycastHelper;
import com.simibubi.create.foundation.utility.RaycastHelper.PredicateTraceResult; import com.simibubi.create.foundation.utility.RaycastHelper.PredicateTraceResult;
import com.simibubi.create.foundation.utility.VecHelper;
import com.simibubi.create.foundation.utility.outliner.Outliner; import com.simibubi.create.foundation.utility.outliner.Outliner;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.player.ClientPlayerEntity; import net.minecraft.client.entity.player.ClientPlayerEntity;
@ -35,15 +18,17 @@ import net.minecraft.nbt.CompressedStreamTools;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
import net.minecraft.util.Direction.AxisDirection; import net.minecraft.util.Direction.AxisDirection;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.*;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.MutableBoundingBox;
import net.minecraft.util.math.RayTraceResult.Type; import net.minecraft.util.math.RayTraceResult.Type;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.Vec3i;
import net.minecraft.world.gen.feature.template.Template; import net.minecraft.world.gen.feature.template.Template;
import org.apache.commons.io.IOUtils;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
public class SchematicAndQuillHandler { public class SchematicAndQuillHandler {
@ -139,8 +124,7 @@ public class SchematicAndQuillHandler {
ClientPlayerEntity player = Minecraft.getInstance().player; ClientPlayerEntity player = Minecraft.getInstance().player;
if (AllKeys.ACTIVATE_TOOL.isPressed()) { if (AllKeys.ACTIVATE_TOOL.isPressed()) {
float pt = Minecraft.getInstance() float pt = AnimationTickHolder.getPartialTicks();
.getRenderPartialTicks();
Vec3d targetVec = player.getEyePosition(pt) Vec3d targetVec = player.getEyePosition(pt)
.add(player.getLookVec() .add(player.getLookVec()
.scale(range)); .scale(range));

View file

@ -1,8 +1,5 @@
package com.simibubi.create.content.schematics.client; package com.simibubi.create.content.schematics.client;
import java.util.List;
import java.util.Vector;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.matrix.MatrixStack;
import com.simibubi.create.AllBlocks; import com.simibubi.create.AllBlocks;
@ -16,8 +13,8 @@ import com.simibubi.create.content.schematics.packet.SchematicSyncPacket;
import com.simibubi.create.foundation.gui.ToolSelectionScreen; import com.simibubi.create.foundation.gui.ToolSelectionScreen;
import com.simibubi.create.foundation.networking.AllPackets; import com.simibubi.create.foundation.networking.AllPackets;
import com.simibubi.create.foundation.renderState.SuperRenderTypeBuffer; import com.simibubi.create.foundation.renderState.SuperRenderTypeBuffer;
import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.foundation.utility.outliner.AABBOutline; import com.simibubi.create.foundation.utility.outliner.AABBOutline;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.player.ClientPlayerEntity; import net.minecraft.client.entity.player.ClientPlayerEntity;
import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.IRenderTypeBuffer;
@ -34,6 +31,9 @@ import net.minecraft.world.World;
import net.minecraft.world.gen.feature.template.PlacementSettings; import net.minecraft.world.gen.feature.template.PlacementSettings;
import net.minecraft.world.gen.feature.template.Template; import net.minecraft.world.gen.feature.template.Template;
import java.util.List;
import java.util.Vector;
public class SchematicHandler { public class SchematicHandler {
private String displayedSchematic; private String displayedSchematic;
@ -159,8 +159,7 @@ public class SchematicHandler {
transformation.applyGLTransformations(ms); transformation.applyGLTransformations(ms);
if (!renderers.isEmpty()) { if (!renderers.isEmpty()) {
float pt = Minecraft.getInstance() float pt = AnimationTickHolder.getPartialTicks();
.getRenderPartialTicks();
boolean lr = transformation.getScaleLR() boolean lr = transformation.getScaleLR()
.get(pt) < 0; .get(pt) < 0;
boolean fb = transformation.getScaleFB() boolean fb = transformation.getScaleFB()
@ -192,8 +191,7 @@ public class SchematicHandler {
currentTool.getTool() currentTool.getTool()
.renderOverlay(ms, buffer); .renderOverlay(ms, buffer);
selectionScreen.renderPassive(Minecraft.getInstance() selectionScreen.renderPassive(AnimationTickHolder.getPartialTicks());
.getRenderPartialTicks());
} }
public void onMouseInput(int button, boolean pressed) { public void onMouseInput(int button, boolean pressed) {

View file

@ -1,14 +1,11 @@
package com.simibubi.create.content.schematics.client; package com.simibubi.create.content.schematics.client;
import static java.lang.Math.abs;
import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.matrix.MatrixStack;
import com.simibubi.create.foundation.gui.widgets.InterpolatedChasingAngle; import com.simibubi.create.foundation.gui.widgets.InterpolatedChasingAngle;
import com.simibubi.create.foundation.gui.widgets.InterpolatedChasingValue; import com.simibubi.create.foundation.gui.widgets.InterpolatedChasingValue;
import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.foundation.utility.MatrixStacker; import com.simibubi.create.foundation.utility.MatrixStacker;
import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.VecHelper;
import net.minecraft.client.Minecraft;
import net.minecraft.util.Direction.Axis; import net.minecraft.util.Direction.Axis;
import net.minecraft.util.Mirror; import net.minecraft.util.Mirror;
import net.minecraft.util.Rotation; import net.minecraft.util.Rotation;
@ -17,6 +14,8 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
import net.minecraft.world.gen.feature.template.PlacementSettings; import net.minecraft.world.gen.feature.template.PlacementSettings;
import static java.lang.Math.abs;
public class SchematicTransformation { public class SchematicTransformation {
private InterpolatedChasingValue x, y, z, scaleFrontBack, scaleLeftRight; private InterpolatedChasingValue x, y, z, scaleFrontBack, scaleLeftRight;
@ -52,8 +51,7 @@ public class SchematicTransformation {
} }
public void applyGLTransformations(MatrixStack ms) { public void applyGLTransformations(MatrixStack ms) {
float pt = Minecraft.getInstance() float pt = AnimationTickHolder.getPartialTicks();
.getRenderPartialTicks();
// Translation // Translation
ms.translate(x.get(pt), y.get(pt), z.get(pt)); ms.translate(x.get(pt), y.get(pt), z.get(pt));
@ -93,8 +91,7 @@ public class SchematicTransformation {
} }
public Vec3d toLocalSpace(Vec3d vec) { public Vec3d toLocalSpace(Vec3d vec) {
float pt = Minecraft.getInstance() float pt = AnimationTickHolder.getPartialTicks();
.getRenderPartialTicks();
Vec3d rotationOffset = getRotationOffset(true); Vec3d rotationOffset = getRotationOffset(true);
vec = vec.subtract(x.get(pt), y.get(pt), z.get(pt)); vec = vec.subtract(x.get(pt), y.get(pt), z.get(pt));
@ -181,8 +178,7 @@ public class SchematicTransformation {
} }
public float getCurrentRotation() { public float getCurrentRotation() {
float pt = Minecraft.getInstance() float pt = AnimationTickHolder.getPartialTicks();
.getRenderPartialTicks();
return rotation.get(pt); return rotation.get(pt);
} }

View file

@ -4,10 +4,9 @@ import com.mojang.blaze3d.matrix.MatrixStack;
import com.simibubi.create.AllKeys; import com.simibubi.create.AllKeys;
import com.simibubi.create.content.schematics.client.SchematicTransformation; import com.simibubi.create.content.schematics.client.SchematicTransformation;
import com.simibubi.create.foundation.renderState.SuperRenderTypeBuffer; import com.simibubi.create.foundation.renderState.SuperRenderTypeBuffer;
import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.foundation.utility.MatrixStacker; import com.simibubi.create.foundation.utility.MatrixStacker;
import com.simibubi.create.foundation.utility.outliner.AABBOutline; import com.simibubi.create.foundation.utility.outliner.AABBOutline;
import net.minecraft.client.Minecraft;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTUtil; import net.minecraft.nbt.NBTUtil;
import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.AxisAlignedBB;
@ -43,8 +42,7 @@ public class DeployTool extends PlacementToolBase {
return; return;
ms.push(); ms.push();
float pt = Minecraft.getInstance() float pt = AnimationTickHolder.getPartialTicks();
.getRenderPartialTicks();
double x = MathHelper.lerp(pt, lastChasingSelectedPos.x, chasingSelectedPos.x); double x = MathHelper.lerp(pt, lastChasingSelectedPos.x, chasingSelectedPos.x);
double y = MathHelper.lerp(pt, lastChasingSelectedPos.y, chasingSelectedPos.y); double y = MathHelper.lerp(pt, lastChasingSelectedPos.y, chasingSelectedPos.y);
double z = MathHelper.lerp(pt, lastChasingSelectedPos.z, chasingSelectedPos.z); double z = MathHelper.lerp(pt, lastChasingSelectedPos.z, chasingSelectedPos.z);

View file

@ -1,8 +1,5 @@
package com.simibubi.create.content.schematics.client.tools; package com.simibubi.create.content.schematics.client.tools;
import java.util.Arrays;
import java.util.List;
import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.matrix.MatrixStack;
import com.simibubi.create.AllKeys; import com.simibubi.create.AllKeys;
import com.simibubi.create.AllSpecialTextures; import com.simibubi.create.AllSpecialTextures;
@ -10,11 +7,11 @@ import com.simibubi.create.CreateClient;
import com.simibubi.create.content.schematics.client.SchematicHandler; import com.simibubi.create.content.schematics.client.SchematicHandler;
import com.simibubi.create.content.schematics.client.SchematicTransformation; import com.simibubi.create.content.schematics.client.SchematicTransformation;
import com.simibubi.create.foundation.renderState.SuperRenderTypeBuffer; import com.simibubi.create.foundation.renderState.SuperRenderTypeBuffer;
import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.foundation.utility.RaycastHelper; import com.simibubi.create.foundation.utility.RaycastHelper;
import com.simibubi.create.foundation.utility.RaycastHelper.PredicateTraceResult; import com.simibubi.create.foundation.utility.RaycastHelper.PredicateTraceResult;
import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.VecHelper;
import com.simibubi.create.foundation.utility.outliner.AABBOutline; import com.simibubi.create.foundation.utility.outliner.AABBOutline;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.player.ClientPlayerEntity; import net.minecraft.client.entity.player.ClientPlayerEntity;
import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.IRenderTypeBuffer;
@ -25,6 +22,9 @@ import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.RayTraceResult.Type; import net.minecraft.util.math.RayTraceResult.Type;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
import java.util.Arrays;
import java.util.List;
public abstract class SchematicToolBase implements ISchematicTool { public abstract class SchematicToolBase implements ISchematicTool {
protected SchematicHandler schematicHandler; protected SchematicHandler schematicHandler;
@ -91,8 +91,7 @@ public abstract class SchematicToolBase implements ISchematicTool {
// Select location at distance // Select location at distance
if (selectIgnoreBlocks) { if (selectIgnoreBlocks) {
float pt = Minecraft.getInstance() float pt = AnimationTickHolder.getPartialTicks();
.getRenderPartialTicks();
selectedPos = new BlockPos(player.getEyePosition(pt) selectedPos = new BlockPos(player.getEyePosition(pt)
.add(player.getLookVec() .add(player.getLookVec()
.scale(selectionRange))); .scale(selectionRange)));

View file

@ -27,7 +27,6 @@ import com.simibubi.create.foundation.networking.LeftClickPacket;
import com.simibubi.create.foundation.render.FastRenderDispatcher; import com.simibubi.create.foundation.render.FastRenderDispatcher;
import com.simibubi.create.foundation.render.RenderWork; import com.simibubi.create.foundation.render.RenderWork;
import com.simibubi.create.foundation.render.contraption.ContraptionRenderDispatcher; import com.simibubi.create.foundation.render.contraption.ContraptionRenderDispatcher;
import com.simibubi.create.foundation.render.light.LightVolumeDebugger;
import com.simibubi.create.foundation.renderState.SuperRenderTypeBuffer; import com.simibubi.create.foundation.renderState.SuperRenderTypeBuffer;
import com.simibubi.create.foundation.tileEntity.behaviour.edgeInteraction.EdgeInteractionRenderer; import com.simibubi.create.foundation.tileEntity.behaviour.edgeInteraction.EdgeInteractionRenderer;
import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringRenderer; import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringRenderer;
@ -187,6 +186,7 @@ public class ClientEvents {
if (!isGameActive()) if (!isGameActive())
return; return;
TurntableHandler.gameRenderTick(); TurntableHandler.gameRenderTick();
ContraptionRenderDispatcher.renderTick(event);
} }
protected static boolean isGameActive() { protected static boolean isGameActive() {

View file

@ -3,8 +3,8 @@ package com.simibubi.create.foundation.render;
import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.matrix.MatrixStack;
import com.simibubi.create.Create; import com.simibubi.create.Create;
import com.simibubi.create.foundation.config.AllConfigs; import com.simibubi.create.foundation.config.AllConfigs;
import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.foundation.utility.MatrixStacker; import com.simibubi.create.foundation.utility.MatrixStacker;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.Matrix4f; import net.minecraft.client.renderer.Matrix4f;
import net.minecraft.client.renderer.Vector4f; import net.minecraft.client.renderer.Vector4f;
@ -22,8 +22,7 @@ public class TileEntityRenderHelper {
public static void renderTileEntities(World world, Iterable<TileEntity> customRenderTEs, MatrixStack ms, public static void renderTileEntities(World world, Iterable<TileEntity> customRenderTEs, MatrixStack ms,
MatrixStack localTransform, IRenderTypeBuffer buffer) { MatrixStack localTransform, IRenderTypeBuffer buffer) {
float pt = Minecraft.getInstance() float pt = AnimationTickHolder.getPartialTicks();
.getRenderPartialTicks();
Matrix4f matrix = localTransform.peek() Matrix4f matrix = localTransform.peek()
.getModel(); .getModel();

View file

@ -1,26 +1,39 @@
package com.simibubi.create.foundation.render.contraption; package com.simibubi.create.foundation.render.contraption;
import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.matrix.MatrixStack;
import com.simibubi.create.content.contraptions.components.structureMovement.AbstractContraptionEntity;
import com.simibubi.create.content.contraptions.components.structureMovement.AbstractContraptionEntityRenderer;
import com.simibubi.create.content.contraptions.components.structureMovement.Contraption; import com.simibubi.create.content.contraptions.components.structureMovement.Contraption;
import com.simibubi.create.content.contraptions.components.structureMovement.ContraptionHandler;
import com.simibubi.create.foundation.render.shader.Shader; import com.simibubi.create.foundation.render.shader.Shader;
import com.simibubi.create.foundation.render.shader.ShaderCallback; import com.simibubi.create.foundation.render.shader.ShaderCallback;
import com.simibubi.create.foundation.render.shader.ShaderHelper; import com.simibubi.create.foundation.render.shader.ShaderHelper;
import com.simibubi.create.foundation.utility.AnimationTickHolder;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.Matrix4f; import net.minecraft.client.renderer.Matrix4f;
import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.entity.EntityRenderer;
import net.minecraft.client.renderer.entity.EntityRendererManager;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.util.math.SectionPos; import net.minecraft.util.math.SectionPos;
import net.minecraft.world.ILightReader; import net.minecraft.world.ILightReader;
import net.minecraft.world.LightType; import net.minecraft.world.LightType;
import net.minecraft.world.World; import net.minecraft.world.World;
import org.lwjgl.opengl.*; import net.minecraftforge.event.TickEvent;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL13;
import org.lwjgl.opengl.GL40;
import java.lang.ref.WeakReference;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map;
public class ContraptionRenderDispatcher { public class ContraptionRenderDispatcher {
public static final HashMap<Integer, RenderedContraption> renderers = new HashMap<>(); public static final HashMap<Integer, RenderedContraption> renderers = new HashMap<>();
public static void markForRendering(World world, Contraption c, MatrixStack model) { public static void markForRendering(Contraption c, MatrixStack model) {
getRenderer(world, c).setRenderSettings(model.peek().getModel()); getRenderer(c.entity.world, c).setRenderSettings(model.peek().getModel());
} }
public static void notifyLightUpdate(ILightReader world, LightType type, SectionPos pos) { public static void notifyLightUpdate(ILightReader world, LightType type, SectionPos pos) {
@ -29,6 +42,31 @@ public class ContraptionRenderDispatcher {
} }
} }
public static void renderTick(TickEvent.RenderTickEvent event) {
ClientWorld world = Minecraft.getInstance().world;
if (event.phase == TickEvent.Phase.START && world != null) {
Map<Integer, WeakReference<AbstractContraptionEntity>> map = ContraptionHandler.loadedContraptions.get(world);
for (WeakReference<AbstractContraptionEntity> weakReference : map.values()) {
AbstractContraptionEntity entity = weakReference.get();
EntityRendererManager renderManager = Minecraft.getInstance().getRenderManager();
EntityRenderer<?> renderer = renderManager.getRenderer(entity);
if (renderer instanceof AbstractContraptionEntityRenderer) {
updateTransform(entity, (AbstractContraptionEntityRenderer<? super AbstractContraptionEntity>) renderer);
}
}
}
}
private static <C extends AbstractContraptionEntity> void updateTransform(C c, AbstractContraptionEntityRenderer<C> entityRenderer) {
MatrixStack stack = entityRenderer.makeTransformMatrix(c, AnimationTickHolder.getPartialTicks());
markForRendering(c.getContraption(), stack);
}
public static void tick() { public static void tick() {
for (RenderedContraption contraption : renderers.values()) { for (RenderedContraption contraption : renderers.values()) {
contraption.getLighter().tick(contraption); contraption.getLighter().tick(contraption);
@ -84,6 +122,7 @@ public class ContraptionRenderDispatcher {
} }
} }
for (Integer id : toRemove) { for (Integer id : toRemove) {
renderers.remove(id); renderers.remove(id);
} }

View file

@ -2,8 +2,7 @@ package com.simibubi.create.foundation.utility.outliner;
import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.matrix.MatrixStack;
import com.simibubi.create.foundation.renderState.SuperRenderTypeBuffer; import com.simibubi.create.foundation.renderState.SuperRenderTypeBuffer;
import com.simibubi.create.foundation.utility.AnimationTickHolder;
import net.minecraft.client.Minecraft;
import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
@ -30,8 +29,7 @@ public class ChasingAABBOutline extends AABBOutline {
@Override @Override
public void render(MatrixStack ms, SuperRenderTypeBuffer buffer) { public void render(MatrixStack ms, SuperRenderTypeBuffer buffer) {
renderBB(ms, buffer, interpolateBBs(prevBB, bb, Minecraft.getInstance() renderBB(ms, buffer, interpolateBBs(prevBB, bb, AnimationTickHolder.getPartialTicks()));
.getRenderPartialTicks()));
} }
private static AxisAlignedBB interpolateBBs(AxisAlignedBB current, AxisAlignedBB target, float pt) { private static AxisAlignedBB interpolateBBs(AxisAlignedBB current, AxisAlignedBB target, float pt) {

View file

@ -2,8 +2,7 @@ package com.simibubi.create.foundation.utility.outliner;
import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.matrix.MatrixStack;
import com.simibubi.create.foundation.renderState.SuperRenderTypeBuffer; import com.simibubi.create.foundation.renderState.SuperRenderTypeBuffer;
import com.simibubi.create.foundation.utility.AnimationTickHolder;
import net.minecraft.client.Minecraft;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
@ -47,8 +46,7 @@ public class LineOutline extends Outline {
@Override @Override
public void render(MatrixStack ms, SuperRenderTypeBuffer buffer) { public void render(MatrixStack ms, SuperRenderTypeBuffer buffer) {
float pt = Minecraft.getInstance() float pt = AnimationTickHolder.getPartialTicks();
.getRenderPartialTicks();
float distanceToTarget = 1 - MathHelper.lerp(pt, prevProgress, progress); float distanceToTarget = 1 - MathHelper.lerp(pt, prevProgress, progress);
Vec3d start = end.add(this.start.subtract(end) Vec3d start = end.add(this.start.subtract(end)
.scale(distanceToTarget)); .scale(distanceToTarget));

View file

@ -1,24 +1,18 @@
package com.simibubi.create.foundation.utility.outliner; package com.simibubi.create.foundation.utility.outliner;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.matrix.MatrixStack;
import com.simibubi.create.foundation.renderState.SuperRenderTypeBuffer; import com.simibubi.create.foundation.renderState.SuperRenderTypeBuffer;
import com.simibubi.create.foundation.tileEntity.behaviour.ValueBox; import com.simibubi.create.foundation.tileEntity.behaviour.ValueBox;
import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.foundation.utility.outliner.LineOutline.EndChasingLineOutline; import com.simibubi.create.foundation.utility.outliner.LineOutline.EndChasingLineOutline;
import com.simibubi.create.foundation.utility.outliner.Outline.OutlineParams; import com.simibubi.create.foundation.utility.outliner.Outline.OutlineParams;
import net.minecraft.client.Minecraft;
import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
import java.util.*;
public class Outliner { public class Outliner {
final Map<Object, OutlineEntry> outlines; final Map<Object, OutlineEntry> outlines;
@ -143,8 +137,7 @@ public class Outliner {
float fadeticks = OutlineEntry.fadeTicks; float fadeticks = OutlineEntry.fadeTicks;
float lastAlpha = prevTicks >= 0 ? 1 : 1 + (prevTicks / fadeticks); float lastAlpha = prevTicks >= 0 ? 1 : 1 + (prevTicks / fadeticks);
float currentAlpha = 1 + (entry.ticksTillRemoval / fadeticks); float currentAlpha = 1 + (entry.ticksTillRemoval / fadeticks);
float alpha = MathHelper.lerp(Minecraft.getInstance() float alpha = MathHelper.lerp(AnimationTickHolder.getPartialTicks(), lastAlpha, currentAlpha);
.getRenderPartialTicks(), lastAlpha, currentAlpha);
outline.params.alpha = alpha * alpha * alpha; outline.params.alpha = alpha * alpha * alpha;
if (outline.params.alpha < 1 / 8f) if (outline.params.alpha < 1 / 8f)