mirror of
https://github.com/Creators-of-Create/Create.git
synced 2025-02-27 20:34:43 +01:00
Touchups
- Bump flywheel version and remove #shouldReset - Water wheels and belt tunnels now properly handle updates without resetting - Fix flaps going crazy
This commit is contained in:
parent
26074dc3df
commit
d28fd7e47b
5 changed files with 80 additions and 43 deletions
|
@ -23,7 +23,7 @@ use_parchment = true
|
|||
# dependency versions
|
||||
registrate_version = MC1.20-1.3.3
|
||||
flywheel_minecraft_version = 1.20.1
|
||||
flywheel_version = 1.0.0-alpha-67
|
||||
flywheel_version = 1.0.0-alpha-78
|
||||
jei_minecraft_version = 1.20.1
|
||||
jei_version = 15.2.0.22
|
||||
curios_minecraft_version = 1.20.1
|
||||
|
|
|
@ -35,11 +35,6 @@ public abstract class ActorVisual implements Visual {
|
|||
public void update(float partialTick) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldReset() {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected abstract void _delete();
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,11 +1,16 @@
|
|||
package com.simibubi.create.content.kinetics.waterwheel;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import com.jozufozu.flywheel.api.instance.Instance;
|
||||
import com.jozufozu.flywheel.api.model.Model;
|
||||
import com.jozufozu.flywheel.api.visualization.VisualizationContext;
|
||||
import com.jozufozu.flywheel.lib.model.ModelCache;
|
||||
import com.jozufozu.flywheel.lib.model.baked.BakedModelBuilder;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.simibubi.create.content.kinetics.base.SingleRotatingVisual;
|
||||
import com.simibubi.create.content.kinetics.base.KineticBlockEntityVisual;
|
||||
import com.simibubi.create.content.kinetics.base.RotatingInstance;
|
||||
import com.simibubi.create.foundation.render.AllInstanceTypes;
|
||||
import com.simibubi.create.foundation.render.CachedBufferer;
|
||||
|
||||
import net.minecraft.client.resources.model.BakedModel;
|
||||
|
@ -13,16 +18,16 @@ import net.minecraft.core.Direction;
|
|||
import net.minecraft.core.Direction.AxisDirection;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
public class WaterWheelVisual<T extends WaterWheelBlockEntity> extends SingleRotatingVisual<T> {
|
||||
public class WaterWheelVisual<T extends WaterWheelBlockEntity> extends KineticBlockEntityVisual<T> {
|
||||
private static final ModelCache<WaterWheelModelKey> MODEL_CACHE = new ModelCache<>(WaterWheelVisual::createModel);
|
||||
|
||||
protected final boolean large;
|
||||
protected final WaterWheelModelKey key;
|
||||
protected BlockState lastMaterial;
|
||||
protected RotatingInstance rotatingModel;
|
||||
|
||||
public WaterWheelVisual(VisualizationContext context, T blockEntity, boolean large) {
|
||||
super(context, blockEntity);
|
||||
this.large = large;
|
||||
key = new WaterWheelModelKey(large, blockState, blockEntity.material);
|
||||
}
|
||||
|
||||
public static <T extends WaterWheelBlockEntity> WaterWheelVisual<T> standard(VisualizationContext context, T blockEntity) {
|
||||
|
@ -34,13 +39,41 @@ public class WaterWheelVisual<T extends WaterWheelBlockEntity> extends SingleRot
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldReset() {
|
||||
return super.shouldReset() || key.material() != blockEntity.material;
|
||||
public void init(float pt) {
|
||||
setupInstance();
|
||||
super.init(pt);
|
||||
}
|
||||
|
||||
private void setupInstance() {
|
||||
lastMaterial = blockEntity.material;
|
||||
rotatingModel = instancerProvider.instancer(AllInstanceTypes.ROTATING, MODEL_CACHE.get(new WaterWheelModelKey(large, blockState, blockEntity.material)))
|
||||
.createInstance();
|
||||
setup(rotatingModel);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Model model() {
|
||||
return MODEL_CACHE.get(key);
|
||||
public void update(float pt) {
|
||||
if (lastMaterial != blockEntity.material) {
|
||||
rotatingModel.delete();
|
||||
setupInstance();
|
||||
}
|
||||
|
||||
updateRotation(rotatingModel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateLight() {
|
||||
relight(pos, rotatingModel);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void _delete() {
|
||||
rotatingModel.delete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collectCrumblingInstances(Consumer<Instance> consumer) {
|
||||
consumer.accept(rotatingModel);
|
||||
}
|
||||
|
||||
private static Model createModel(WaterWheelModelKey key) {
|
||||
|
|
|
@ -17,7 +17,6 @@ import com.jozufozu.flywheel.lib.visual.SimpleDynamicVisual;
|
|||
import com.simibubi.create.AllPartialModels;
|
||||
import com.simibubi.create.content.logistics.flwdata.FlapInstance;
|
||||
import com.simibubi.create.foundation.render.AllInstanceTypes;
|
||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||
import com.simibubi.create.foundation.utility.animation.LerpedFloat;
|
||||
|
||||
import net.minecraft.core.Direction;
|
||||
|
@ -25,35 +24,35 @@ import net.minecraft.world.level.LightLayer;
|
|||
|
||||
public class BeltTunnelVisual extends AbstractBlockEntityVisual<BeltTunnelBlockEntity> implements SimpleDynamicVisual {
|
||||
|
||||
private final Map<Direction, ArrayList<FlapInstance>> tunnelFlaps;
|
||||
private final Map<Direction, ArrayList<FlapInstance>> tunnelFlaps = new EnumMap<>(Direction.class);
|
||||
|
||||
public BeltTunnelVisual(VisualizationContext context, BeltTunnelBlockEntity blockEntity) {
|
||||
super(context, blockEntity);
|
||||
}
|
||||
|
||||
tunnelFlaps = new EnumMap<>(Direction.class);
|
||||
private void setupFlaps(float partialTick) {
|
||||
Instancer<FlapInstance> model = instancerProvider.instancer(AllInstanceTypes.FLAPS, Models.partial(AllPartialModels.BELT_TUNNEL_FLAP));
|
||||
|
||||
Instancer<FlapInstance> model = instancerProvider.instancer(AllInstanceTypes.FLAPS, Models.partial(AllPartialModels.BELT_TUNNEL_FLAP));
|
||||
int blockLight = level.getBrightness(LightLayer.BLOCK, pos);
|
||||
int skyLight = level.getBrightness(LightLayer.SKY, pos);
|
||||
|
||||
int blockLight = level.getBrightness(LightLayer.BLOCK, pos);
|
||||
int skyLight = level.getBrightness(LightLayer.SKY, pos);
|
||||
blockEntity.flaps.forEach((direction, flapValue) -> {
|
||||
|
||||
blockEntity.flaps.forEach((direction, flapValue) -> {
|
||||
float flapness = flapValue.getValue(partialTick);
|
||||
|
||||
float flapness = flapValue.getValue(AnimationTickHolder.getPartialTicks());
|
||||
float horizontalAngle = direction.getOpposite().toYRot();
|
||||
|
||||
float horizontalAngle = direction.getOpposite().toYRot();
|
||||
float flapScale = direction.getAxis() == Direction.Axis.X ? 1 : -1;
|
||||
|
||||
float flapScale = direction.getAxis() == Direction.Axis.X ? 1 : -1;
|
||||
ArrayList<FlapInstance> flaps = new ArrayList<>(4);
|
||||
|
||||
ArrayList<FlapInstance> flaps = new ArrayList<>(4);
|
||||
for (int segment = 0; segment <= 3; segment++) {
|
||||
float intensity = segment == 3 ? 1.5f : segment + 1;
|
||||
float segmentOffset = -3.05f / 16f * segment + 0.075f / 16f;
|
||||
|
||||
for (int segment = 0; segment <= 3; segment++) {
|
||||
float intensity = segment == 3 ? 1.5f : segment + 1;
|
||||
float segmentOffset = -3.05f / 16f * segment + 0.075f / 16f;
|
||||
FlapInstance key = model.createInstance();
|
||||
|
||||
FlapInstance key = model.createInstance();
|
||||
|
||||
key.setPosition(getVisualPosition())
|
||||
key.setPosition(getVisualPosition())
|
||||
.setSegmentOffset(segmentOffset, 0, 0)
|
||||
.setBlockLight(blockLight)
|
||||
.setSkyLight(skyLight)
|
||||
|
@ -64,19 +63,29 @@ public class BeltTunnelVisual extends AbstractBlockEntityVisual<BeltTunnelBlockE
|
|||
.setIntensity(intensity)
|
||||
.setChanged();
|
||||
|
||||
flaps.add(key);
|
||||
}
|
||||
flaps.add(key);
|
||||
}
|
||||
|
||||
tunnelFlaps.put(direction, flaps);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldReset() {
|
||||
return super.shouldReset() || tunnelFlaps.size() != blockEntity.flaps.size();
|
||||
tunnelFlaps.put(direction, flaps);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void init(float partialTick) {
|
||||
setupFlaps(partialTick);
|
||||
|
||||
super.init(partialTick);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(float partialTick) {
|
||||
super.update(partialTick);
|
||||
|
||||
_delete();
|
||||
setupFlaps(partialTick);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beginFrame(VisualFrameContext ctx) {
|
||||
tunnelFlaps.forEach((direction, keys) -> {
|
||||
LerpedFloat lerpedFloat = blockEntity.flaps.get(direction);
|
||||
|
|
|
@ -18,8 +18,8 @@ float getFlapAngle(float flapness, float intensity, float scale) {
|
|||
void flw_instanceVertex(in FlwInstance flap) {
|
||||
float flapAngle = getFlapAngle(flap.flapness, flap.intensity, flap.flapScale);
|
||||
|
||||
vec4 orientation = quaternion(vec3(0., 1., 0.), -flap.horizontalAngle);
|
||||
vec4 flapRotation = quaternion(vec3(1., 0., 0.), flapAngle);
|
||||
vec4 orientation = quaternionDegrees(vec3(0., 1., 0.), -flap.horizontalAngle);
|
||||
vec4 flapRotation = quaternionDegrees(vec3(1., 0., 0.), flapAngle);
|
||||
|
||||
vec3 rotated = rotateByQuaternion(flw_vertexPos.xyz - flap.pivot, flapRotation) + flap.pivot + flap.segmentOffset;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue