Intensified flapping

- Sounds for the display board
This commit is contained in:
simibubi 2022-05-18 21:51:42 +02:00
parent 6353eedf13
commit 0399bc515c
3 changed files with 37 additions and 9 deletions

View file

@ -34,7 +34,7 @@ public class FillLevelDisplaySource extends NumericSingleLineDisplaySource {
.getString("Label");
int labelSize = label.isEmpty() ? 0 : label.length() + 1;
int length = Math.min(stats.maxColumns() - labelSize, 32);
int length = Math.min(stats.maxColumns() - labelSize, 128);
if (context.getTargetTE() instanceof SignBlockEntity)
length = (int) (length * 6f / 9f);

View file

@ -81,15 +81,18 @@ public class FlapDisplaySection {
spinningTicks = 0;
}
public void tick() {
public int tick() {
if (cyclingOptions == null)
return;
return 0;
int max = Math.max(4, (int) (cyclingOptions.length * 1.75f));
if (spinningTicks > max)
return;
return 0;
spinningTicks++;
if (spinningTicks <= max && spinningTicks < 2)
return;
return spinningTicks == 1 ? 0 : spinning.length;
int spinningFlaps = 0;
for (int i = 0; i < spinning.length; i++) {
int increasingChance = Mth.clamp(8 - spinningTicks, 1, 10);
boolean continueSpin = Create.RANDOM.nextInt(increasingChance * max / 4) != 0;
@ -102,7 +105,12 @@ public class FlapDisplaySection {
spinning[i + 1] &= continueSpin;
if (spinningTicks > max)
spinning[i] = false;
if (spinning[i])
spinningFlaps++;
}
return spinningFlaps;
}
public float getSize() {

View file

@ -5,6 +5,7 @@ import java.util.Arrays;
import java.util.List;
import com.google.gson.JsonElement;
import com.simibubi.create.AllSoundEvents;
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
import com.simibubi.create.foundation.utility.DyeHelper;
@ -18,6 +19,8 @@ import net.minecraft.core.Vec3i;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
import net.minecraft.util.Mth;
import net.minecraft.world.item.DyeColor;
import net.minecraft.world.level.block.entity.BlockEntity;
@ -104,9 +107,25 @@ public class FlapDisplayTileEntity extends KineticTileEntity {
isRunning = super.isSpeedRequirementFulfilled();
if (!level.isClientSide || !isRunning)
return;
List<FlapDisplayLayout> lines = getLines();
lines.forEach(l -> l.getSections()
.forEach(FlapDisplaySection::tick));
int activeFlaps = 0;
for (FlapDisplayLayout line : lines)
for (FlapDisplaySection section : line.getSections())
activeFlaps += section.tick();
if (activeFlaps == 0)
return;
float volume = Mth.clamp(activeFlaps / 20f, 0.25f, 1.5f);
float bgVolume = Mth.clamp(activeFlaps / 40f, 0.25f, 1f);
BlockPos middle = worldPosition.relative(getDirection().getClockWise(), xSize / 2)
.relative(Direction.DOWN, ySize / 2);
AllSoundEvents.SCROLL_VALUE.playAt(level, middle, volume, 0.56f, false);
level.playLocalSound(middle.getX(), middle.getY(), middle.getZ(), SoundEvents.CALCITE_HIT, SoundSource.BLOCKS,
.35f * bgVolume, 1.95f, false);
}
@Override
protected boolean isNoisy() {
return false;
}
@Override
@ -279,7 +298,8 @@ public class FlapDisplayTileEntity extends KineticTileEntity {
public int getLineColor(int line) {
DyeColor color = colour[line];
return color == null ? 0xFF_D3C6BA : DyeHelper.DYE_TABLE.get(color)
return color == null ? 0xFF_D3C6BA
: DyeHelper.DYE_TABLE.get(color)
.getFirst() | 0xFF_000000;
}
}