use of com.simibubi.create.content.contraptions.base.IRotate.SpeedLevel in project Create by Creators-of-Create.
the class KineticEffectHandler method spawnRotationIndicators.
public void spawnRotationIndicators() {
float speed = kte.getSpeed();
if (speed == 0)
return;
BlockState state = kte.getBlockState();
Block block = state.getBlock();
if (!(block instanceof KineticBlock))
return;
KineticBlock kb = (KineticBlock) block;
float radius1 = kb.getParticleInitialRadius();
float radius2 = kb.getParticleTargetRadius();
Axis axis = kb.getRotationAxis(state);
BlockPos pos = kte.getBlockPos();
Level world = kte.getLevel();
if (axis == null)
return;
if (world == null)
return;
char axisChar = axis.name().charAt(0);
Vec3 vec = VecHelper.getCenterOf(pos);
SpeedLevel speedLevel = SpeedLevel.of(speed);
int color = speedLevel.getColor();
int particleSpeed = speedLevel.getParticleSpeed();
particleSpeed *= Math.signum(speed);
if (world instanceof ServerLevel) {
AllTriggers.triggerForNearbyPlayers(AllTriggers.ROTATION, world, pos, 5);
RotationIndicatorParticleData particleData = new RotationIndicatorParticleData(color, particleSpeed, radius1, radius2, 10, axisChar);
((ServerLevel) world).sendParticles(particleData, vec.x, vec.y, vec.z, 20, 0, 0, 0, 1);
}
}
use of com.simibubi.create.content.contraptions.base.IRotate.SpeedLevel in project Create by Creators-of-Create.
the class GeneratingKineticTileEntity method updateGeneratedRotation.
public void updateGeneratedRotation() {
float speed = getGeneratedSpeed();
float prevSpeed = this.speed;
if (level.isClientSide)
return;
if (prevSpeed != speed) {
if (!hasSource()) {
SpeedLevel levelBefore = SpeedLevel.of(this.speed);
SpeedLevel levelafter = SpeedLevel.of(speed);
if (levelBefore != levelafter)
effects.queueRotationIndicators();
}
applyNewSpeed(prevSpeed, speed);
}
if (hasNetwork() && speed != 0) {
KineticNetwork network = getOrCreateNetwork();
notifyStressCapacityChange(calculateAddedStressCapacity());
getOrCreateNetwork().updateStressFor(this, calculateStressApplied());
network.updateStress();
}
onSpeedChanged(prevSpeed);
sendData();
}
use of com.simibubi.create.content.contraptions.base.IRotate.SpeedLevel in project Create by Creators-of-Create.
the class ItemDescription method getKineticStats.
public static List<Component> getKineticStats(Block block) {
List<Component> list = new ArrayList<>();
CKinetics config = AllConfigs.SERVER.kinetics;
Component rpmUnit = Lang.translate("generic.unit.rpm");
boolean hasGoggles = AllItems.GOGGLES.isIn(Minecraft.getInstance().player.getItemBySlot(EquipmentSlot.HEAD));
SpeedLevel minimumRequiredSpeedLevel;
boolean showStressImpact;
if (!(block instanceof IRotate)) {
minimumRequiredSpeedLevel = SpeedLevel.NONE;
showStressImpact = true;
} else {
minimumRequiredSpeedLevel = ((IRotate) block).getMinimumRequiredSpeedLevel();
showStressImpact = !((IRotate) block).hideStressImpact();
}
boolean hasSpeedRequirement = minimumRequiredSpeedLevel != SpeedLevel.NONE;
boolean hasStressImpact = StressImpact.isEnabled() && showStressImpact && BlockStressValues.getImpact(block) > 0;
boolean hasStressCapacity = StressImpact.isEnabled() && BlockStressValues.hasCapacity(block);
if (hasSpeedRequirement) {
List<Component> speedLevels = Lang.translatedOptions("tooltip.speedRequirement", "none", "medium", "high");
int index = minimumRequiredSpeedLevel.ordinal();
MutableComponent level = new TextComponent(makeProgressBar(3, index)).withStyle(minimumRequiredSpeedLevel.getTextColor());
if (hasGoggles)
level.append(String.valueOf(minimumRequiredSpeedLevel.getSpeedValue())).append(rpmUnit).append("+");
else
level.append(speedLevels.get(index));
list.add(Lang.translate("tooltip.speedRequirement").withStyle(GRAY));
list.add(level);
}
if (hasStressImpact) {
List<Component> stressLevels = Lang.translatedOptions("tooltip.stressImpact", "low", "medium", "high");
double impact = BlockStressValues.getImpact(block);
StressImpact impactId = impact >= config.highStressImpact.get() ? StressImpact.HIGH : (impact >= config.mediumStressImpact.get() ? StressImpact.MEDIUM : StressImpact.LOW);
int index = impactId.ordinal();
MutableComponent level = new TextComponent(makeProgressBar(3, index)).withStyle(impactId.getAbsoluteColor());
if (hasGoggles)
level.append(impact + "x ").append(rpmUnit);
else
level.append(stressLevels.get(index));
list.add(Lang.translate("tooltip.stressImpact").withStyle(GRAY));
list.add(level);
}
if (hasStressCapacity) {
List<Component> stressCapacityLevels = Lang.translatedOptions("tooltip.capacityProvided", "low", "medium", "high");
double capacity = BlockStressValues.getCapacity(block);
StressImpact impactId = capacity >= config.highCapacity.get() ? StressImpact.LOW : (capacity >= config.mediumCapacity.get() ? StressImpact.MEDIUM : StressImpact.HIGH);
int index = StressImpact.values().length - 2 - impactId.ordinal();
MutableComponent level = new TextComponent(makeProgressBar(3, index)).withStyle(impactId.getAbsoluteColor());
if (hasGoggles)
level.append(capacity + "x ").append(rpmUnit);
else
level.append(stressCapacityLevels.get(index));
// if (!isEngine && ((IRotate) block).showCapacityWithAnnotation())
// level +=
// " " + DARK_GRAY + TextFormatting.ITALIC + Lang.translate("tooltip.capacityProvided.asGenerator");
list.add(Lang.translate("tooltip.capacityProvided").withStyle(GRAY));
list.add(level);
MutableComponent genSpeed = generatorSpeed(block, rpmUnit);
if (!genSpeed.getString().isEmpty())
list.add(new TextComponent(" ").append(genSpeed).withStyle(DARK_GRAY));
}
// add(linesOnShift, "");
return list;
}
use of com.simibubi.create.content.contraptions.base.IRotate.SpeedLevel in project Create by Creators-of-Create.
the class KineticTileEntity method isSpeedRequirementFulfilled.
public boolean isSpeedRequirementFulfilled() {
BlockState state = getBlockState();
if (!(getBlockState().getBlock() instanceof IRotate))
return true;
IRotate def = (IRotate) state.getBlock();
SpeedLevel minimumRequiredSpeedLevel = def.getMinimumRequiredSpeedLevel();
if (minimumRequiredSpeedLevel == null)
return true;
if (minimumRequiredSpeedLevel == SpeedLevel.MEDIUM)
return Math.abs(getSpeed()) >= AllConfigs.SERVER.kinetics.mediumSpeed.get();
if (minimumRequiredSpeedLevel == SpeedLevel.FAST)
return Math.abs(getSpeed()) >= AllConfigs.SERVER.kinetics.fastSpeed.get();
return true;
}
Aggregations