mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-11-18 16:02:19 +01:00
Intensified flapping
- Sounds for the display board
This commit is contained in:
parent
6353eedf13
commit
0399bc515c
3 changed files with 37 additions and 9 deletions
|
@ -34,7 +34,7 @@ public class FillLevelDisplaySource extends NumericSingleLineDisplaySource {
|
||||||
.getString("Label");
|
.getString("Label");
|
||||||
|
|
||||||
int labelSize = label.isEmpty() ? 0 : label.length() + 1;
|
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)
|
if (context.getTargetTE() instanceof SignBlockEntity)
|
||||||
length = (int) (length * 6f / 9f);
|
length = (int) (length * 6f / 9f);
|
||||||
|
|
|
@ -81,15 +81,18 @@ public class FlapDisplaySection {
|
||||||
spinningTicks = 0;
|
spinningTicks = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void tick() {
|
public int tick() {
|
||||||
if (cyclingOptions == null)
|
if (cyclingOptions == null)
|
||||||
return;
|
return 0;
|
||||||
int max = Math.max(4, (int) (cyclingOptions.length * 1.75f));
|
int max = Math.max(4, (int) (cyclingOptions.length * 1.75f));
|
||||||
if (spinningTicks > max)
|
if (spinningTicks > max)
|
||||||
return;
|
return 0;
|
||||||
|
|
||||||
spinningTicks++;
|
spinningTicks++;
|
||||||
if (spinningTicks <= max && spinningTicks < 2)
|
if (spinningTicks <= max && spinningTicks < 2)
|
||||||
return;
|
return spinningTicks == 1 ? 0 : spinning.length;
|
||||||
|
|
||||||
|
int spinningFlaps = 0;
|
||||||
for (int i = 0; i < spinning.length; i++) {
|
for (int i = 0; i < spinning.length; i++) {
|
||||||
int increasingChance = Mth.clamp(8 - spinningTicks, 1, 10);
|
int increasingChance = Mth.clamp(8 - spinningTicks, 1, 10);
|
||||||
boolean continueSpin = Create.RANDOM.nextInt(increasingChance * max / 4) != 0;
|
boolean continueSpin = Create.RANDOM.nextInt(increasingChance * max / 4) != 0;
|
||||||
|
@ -102,7 +105,12 @@ public class FlapDisplaySection {
|
||||||
spinning[i + 1] &= continueSpin;
|
spinning[i + 1] &= continueSpin;
|
||||||
if (spinningTicks > max)
|
if (spinningTicks > max)
|
||||||
spinning[i] = false;
|
spinning[i] = false;
|
||||||
|
|
||||||
|
if (spinning[i])
|
||||||
|
spinningFlaps++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return spinningFlaps;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getSize() {
|
public float getSize() {
|
||||||
|
|
|
@ -5,6 +5,7 @@ import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
|
import com.simibubi.create.AllSoundEvents;
|
||||||
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
||||||
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
|
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
|
||||||
import com.simibubi.create.foundation.utility.DyeHelper;
|
import com.simibubi.create.foundation.utility.DyeHelper;
|
||||||
|
@ -18,6 +19,8 @@ import net.minecraft.core.Vec3i;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.network.chat.TextComponent;
|
import net.minecraft.network.chat.TextComponent;
|
||||||
|
import net.minecraft.sounds.SoundEvents;
|
||||||
|
import net.minecraft.sounds.SoundSource;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
import net.minecraft.world.item.DyeColor;
|
import net.minecraft.world.item.DyeColor;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
|
@ -104,9 +107,25 @@ public class FlapDisplayTileEntity extends KineticTileEntity {
|
||||||
isRunning = super.isSpeedRequirementFulfilled();
|
isRunning = super.isSpeedRequirementFulfilled();
|
||||||
if (!level.isClientSide || !isRunning)
|
if (!level.isClientSide || !isRunning)
|
||||||
return;
|
return;
|
||||||
List<FlapDisplayLayout> lines = getLines();
|
int activeFlaps = 0;
|
||||||
lines.forEach(l -> l.getSections()
|
for (FlapDisplayLayout line : lines)
|
||||||
.forEach(FlapDisplaySection::tick));
|
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
|
@Override
|
||||||
|
@ -279,7 +298,8 @@ public class FlapDisplayTileEntity extends KineticTileEntity {
|
||||||
|
|
||||||
public int getLineColor(int line) {
|
public int getLineColor(int line) {
|
||||||
DyeColor color = colour[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;
|
.getFirst() | 0xFF_000000;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue