Merge remote-tracking branch 'concealed/mc1.20.1/feature-dev' into mc1.20.1/feature-dev

This commit is contained in:
IThundxr 2024-12-26 22:13:49 -05:00
commit b555b8c877
Failed to generate hash of commit
9 changed files with 144 additions and 20 deletions

View file

@ -23,12 +23,12 @@ use_parchment = true
# dependency versions
registrate_version = MC1.20-1.3.3
flywheel_minecraft_version = 1.20.1
flywheel_version = 1.0.0-beta-171
flywheel_version = 1.0.0-beta-175
jei_minecraft_version = 1.20.1
jei_version = 15.10.0.39
curios_minecraft_version = 1.20.1
curios_version = 5.3.1
catnip_version = 0.8.37
catnip_version = 0.8.38
ponder_version = 0.8.12
mixin_extras_version = 0.4.1

View file

@ -1151,7 +1151,9 @@ public abstract class Contraption {
storage.addStorageToWorld(block, blockEntity);
}
transform.apply(blockEntity);
if (blockEntity != null) {
transform.apply(blockEntity);
}
}
}

View file

@ -9,10 +9,10 @@ import com.simibubi.create.content.contraptions.ContraptionWorld;
import com.simibubi.create.foundation.virtualWorld.VirtualRenderWorld;
import dev.engine_room.flywheel.api.visualization.VisualizationManager;
import dev.engine_room.flywheel.lib.model.ModelUtil;
import net.createmod.catnip.render.ShadedBlockSbbBuilder;
import net.createmod.catnip.render.SuperByteBuffer;
import net.createmod.catnip.render.SuperByteBufferCache;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.block.BlockRenderDispatcher;
import net.minecraft.client.renderer.block.ModelBlockRenderer;
@ -102,7 +102,7 @@ public class ContraptionRenderInfo {
}
private SuperByteBuffer buildStructureBuffer(RenderType layer) {
BlockRenderDispatcher dispatcher = ModelUtil.VANILLA_RENDERER;
BlockRenderDispatcher dispatcher = Minecraft.getInstance().getBlockRenderer();
ModelBlockRenderer renderer = dispatcher.getModelRenderer();
ThreadLocalObjects objects = THREAD_LOCAL_OBJECTS.get();

View file

@ -1,6 +1,7 @@
package com.simibubi.create.content.fluids.tank;
import java.util.Arrays;
import java.util.EnumMap;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@ -8,6 +9,7 @@ import java.util.Set;
import org.jetbrains.annotations.NotNull;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.AllSoundEvents;
import com.simibubi.create.Create;
import com.simibubi.create.content.decoration.steamWhistle.WhistleBlock;
import com.simibubi.create.content.decoration.steamWhistle.WhistleBlockEntity;
@ -29,6 +31,8 @@ import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
import net.minecraft.util.Mth;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockState;
@ -65,10 +69,25 @@ public class BoilerData {
public LerpedFloat gauge = LerpedFloat.linear();
// client only sound control
// re-use the same lambda for each side
private final SoundPool.Sound sound = (level, pos) -> {
float volume = 3f / Math.max(2, attachedEngines / 6);
float pitch = 1.18f - level.random.nextFloat() * .25f;
level.playLocalSound(pos.getX(), pos.getY(), pos.getZ(),
SoundEvents.CANDLE_EXTINGUISH, SoundSource.BLOCKS, volume, pitch, false);
AllSoundEvents.STEAM.playAt(level, pos, volume / 16, .8f, false);
};
// separate pools for each side so they sound distinct when standing at corners of the boiler
private final EnumMap<Direction, SoundPool> pools = new EnumMap<>(Direction.class);
public void tick(FluidTankBlockEntity controller) {
if (!isActive())
return;
if (controller.getLevel().isClientSide) {
pools.values().forEach(p -> p.play(controller.getLevel()));
gauge.tickChaser();
float current = gauge.getValue(1);
if (current > 1 && Create.RANDOM.nextFloat() < 1 / 2f)
@ -105,6 +124,15 @@ public class BoilerData {
controller.notifyUpdate();
}
public void queueSoundOnSide(BlockPos pos, Direction side) {
SoundPool pool = pools.get(side);
if (pool == null) {
pool = new SoundPool(4, 2, sound);
pools.put(side, pool);
}
pool.queueAt(pos);
}
public int getTheoreticalHeatLevel() {
return activeHeat;
}

View file

@ -0,0 +1,101 @@
package com.simibubi.create.content.fluids.tank;
import it.unimi.dsi.fastutil.longs.LongArrayList;
import it.unimi.dsi.fastutil.longs.LongList;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Vec3i;
import net.minecraft.world.level.Level;
/**
* One person walking sounds like one person walking, and you can easily distinguish where they are.
*
* <br>With two people walking, you can still pick out which footsteps belong to which person.
*
* <br>Try and listen to three people walking in a group, however, and you'll find that you can't distinguish
* individual footsteps anymore. You now just hear the sound of a group of people walking.
*
* <p>You'll likely find that you perceive any number of people walking in a group as a single distinguishable sound.
* This class is a helper to take advantage of that for sound effects in Create to avoid saturating the sound engine
* without a perceptible loss in quality.
*
* <p>NOTE: It's up to the user of this class to decide how to group sounds such that they are perceived as a single
* sound. There are no spatial calculations made here.
*/
public class SoundPool {
/**
* The maximum number of sounds that can be played at once.
*/
private final int maxConcurrent;
/**
* The number of ticks to wait before playing sounds. Useful if sounds are queued across many block entities,
* and you don't have control over the tick order.
*/
private final int mergeTicks;
private final Sound sound;
private final LongList queuedPositions = new LongArrayList();
private final BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos();
private int ticks = 0;
public SoundPool(int maxConcurrent, int mergeTicks, Sound sound) {
this.maxConcurrent = maxConcurrent;
this.sound = sound;
this.mergeTicks = mergeTicks;
}
public void queueAt(BlockPos pos) {
queueAt(pos.asLong());
}
public void queueAt(long pos) {
queuedPositions.add(pos);
}
public void play(Level level) {
if (queuedPositions.isEmpty()) {
return;
}
ticks++;
if (ticks < mergeTicks) {
// Wait for more sounds to be queued in further ticks.
return;
}
ticks = 0;
var numberOfPositions = queuedPositions.size();
if (numberOfPositions <= maxConcurrent) {
// Fewer sound positions than maxConcurrent, play them all.
for (long pos : queuedPositions) {
playAt(level, pos);
}
} else {
// Roll for n random positions and play there.
while (!queuedPositions.isEmpty() && queuedPositions.size() > numberOfPositions - maxConcurrent) {
rollNextPosition(level);
}
}
queuedPositions.clear();
}
private void rollNextPosition(Level level) {
int index = level.random.nextInt(queuedPositions.size());
long pos = queuedPositions.removeLong(index);
playAt(level, pos);
}
private void playAt(Level level, long pos) {
sound.playAt(level, this.pos.set(pos));
}
public interface Sound {
void playAt(Level level, Vec3i pos);
}
}

View file

@ -6,7 +6,6 @@ import java.util.List;
import javax.annotation.Nullable;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.AllSoundEvents;
import com.simibubi.create.content.contraptions.bearing.WindmillBearingBlockEntity.RotationDirection;
import com.simibubi.create.content.equipment.goggles.IHaveGoggleInformation;
import com.simibubi.create.content.fluids.tank.FluidTankBlockEntity;
@ -26,8 +25,6 @@ import net.minecraft.core.Direction;
import net.minecraft.core.Direction.Axis;
import net.minecraft.core.Direction.AxisDirection;
import net.minecraft.network.chat.Component;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
import net.minecraft.util.Mth;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType;
@ -208,11 +205,7 @@ public class SteamEngineBlockEntity extends SmartBlockEntity implements IHaveGog
if (sourceBE != null) {
FluidTankBlockEntity controller = sourceBE.getControllerBE();
if (controller != null && controller.boiler != null) {
float volume = 3f / Math.max(2, controller.boiler.attachedEngines / 6);
float pitch = 1.18f - level.random.nextFloat() * .25f;
level.playLocalSound(worldPosition.getX(), worldPosition.getY(), worldPosition.getZ(),
SoundEvents.CANDLE_EXTINGUISH, SoundSource.BLOCKS, volume, pitch, false);
AllSoundEvents.STEAM.playAt(level, worldPosition, volume / 16, .8f, false);
controller.boiler.queueSoundOnSide(worldPosition, SteamEngineBlock.getFacing(getBlockState()));
}
}

View file

@ -11,7 +11,7 @@ import dev.engine_room.flywheel.api.instance.Instance;
import dev.engine_room.flywheel.api.model.Model;
import dev.engine_room.flywheel.api.visualization.VisualizationContext;
import dev.engine_room.flywheel.lib.model.baked.BakedModelBuilder;
import dev.engine_room.flywheel.lib.util.ResourceReloadCache;
import dev.engine_room.flywheel.lib.util.RendererReloadCache;
import net.createmod.catnip.render.CachedBuffers;
import net.minecraft.client.resources.model.BakedModel;
import net.minecraft.core.Direction;
@ -19,7 +19,7 @@ import net.minecraft.core.Direction.AxisDirection;
import net.minecraft.world.level.block.state.BlockState;
public class WaterWheelVisual<T extends WaterWheelBlockEntity> extends KineticBlockEntityVisual<T> {
private static final ResourceReloadCache<WaterWheelModelKey, Model> MODEL_CACHE = new ResourceReloadCache<>(WaterWheelVisual::createModel);
private static final RendererReloadCache<WaterWheelModelKey, Model> MODEL_CACHE = new RendererReloadCache<>(WaterWheelVisual::createModel);
protected final boolean large;
protected BlockState lastMaterial;

View file

@ -6,7 +6,6 @@ import java.util.Map;
import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.foundation.render.BlockEntityRenderHelper;
import dev.engine_room.flywheel.lib.model.ModelUtil;
import net.createmod.catnip.render.ShadedBlockSbbBuilder;
import net.createmod.catnip.render.SuperByteBuffer;
import net.createmod.catnip.render.SuperRenderTypeBuffer;
@ -85,7 +84,8 @@ public class SchematicRenderer {
}
protected SuperByteBuffer drawLayer(RenderType layer) {
BlockRenderDispatcher dispatcher = ModelUtil.VANILLA_RENDERER;
BlockRenderDispatcher dispatcher = Minecraft.getInstance()
.getBlockRenderer();
ModelBlockRenderer renderer = dispatcher.getModelRenderer();
ThreadLocalObjects objects = THREAD_LOCAL_OBJECTS.get();

View file

@ -9,15 +9,15 @@ import dev.engine_room.flywheel.lib.material.SimpleMaterial;
import dev.engine_room.flywheel.lib.model.ModelUtil;
import dev.engine_room.flywheel.lib.model.baked.BakedModelBuilder;
import dev.engine_room.flywheel.lib.model.baked.PartialModel;
import dev.engine_room.flywheel.lib.util.ResourceReloadCache;
import dev.engine_room.flywheel.lib.util.RendererReloadCache;
import net.minecraft.client.renderer.RenderType;
public class ShaderLightPartial {
private static final ResourceReloadCache<PartialModel, Model> FLAT = new ResourceReloadCache<>(it -> BakedModelBuilder.create(it.get())
private static final RendererReloadCache<PartialModel, Model> FLAT = new RendererReloadCache<>(it -> BakedModelBuilder.create(it.get())
.materialFunc((renderType, aBoolean) -> getMaterial(renderType, aBoolean, LightShaders.FLAT))
.build());
private static final ResourceReloadCache<PartialModel, Model> SMOOTH = new ResourceReloadCache<>(it -> BakedModelBuilder.create(it.get())
private static final RendererReloadCache<PartialModel, Model> SMOOTH = new RendererReloadCache<>(it -> BakedModelBuilder.create(it.get())
.materialFunc((renderType, aBoolean) -> getMaterial(renderType, aBoolean, LightShaders.SMOOTH))
.build());