1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-09-06 20:37:55 +00:00

Merge branch 'mc-1.20.x' into mc-1.21.x

This commit is contained in:
Jonathan Coates
2025-03-01 22:49:56 +00:00
26 changed files with 215 additions and 22 deletions

View File

@@ -39,7 +39,6 @@ dependencies {
compileOnly(libs.mixin)
compileOnly(libs.mixinExtra)
compileOnly(libs.bundles.externalMods.common)
compileOnly(variantOf(libs.create.forge) { classifier("slim") }) { isTransitive = false }
clientCompileOnly(variantOf(libs.emi) { classifier("api") })
annotationProcessorEverywhere(libs.autoService)

View File

@@ -45,8 +45,8 @@ public class LecternPocketModel {
public static final float TERM_HEIGHT = 14.0f / 32.0f;
// The size of the texture. The texture is 36x36, but is at 2x resolution.
private static final int TEXTURE_WIDTH = 36 / 2;
private static final int TEXTURE_HEIGHT = 36 / 2;
private static final int TEXTURE_WIDTH = 48 / 2;
private static final int TEXTURE_HEIGHT = 48 / 2;
private final ModelPart root;

View File

@@ -24,7 +24,7 @@ public class SpeakerInstance {
SpeakerInstance() {
}
private void pushAudio(EncodedAudio buffer) {
private void pushAudio(EncodedAudio buffer, float volume) {
var sound = this.sound;
var stream = currentStream;
@@ -32,18 +32,30 @@ public class SpeakerInstance {
var exhausted = stream.isEmpty();
stream.push(buffer);
// If we've got nothing left in the buffer, enqueue an additional one just in case.
if (exhausted && sound != null && sound.stream == stream && stream.channel != null && stream.executor != null) {
if (sound == null) return;
var volumeChanged = sound.setVolume(volume);
if ((exhausted || volumeChanged) && sound.stream == stream && stream.channel != null && stream.executor != null) {
var actualStream = sound.stream;
stream.executor.execute(() -> {
var channel = Nullability.assertNonNull(actualStream.channel);
if (!channel.stopped()) channel.pumpBuffers(1);
if (channel.stopped()) return;
// If we've got nothing left in the buffer, enqueue an additional one just in case.
if (exhausted) channel.pumpBuffers(1);
// Update the attenuation if the volume has changed: SoundEngine.tickNonPaused updates the volume
// itself, but leaves the attenuation unchanged. We mirror the logic of SoundEngine.play here.
if (volumeChanged) {
channel.linearAttenuation(Math.max(volume, 1) * sound.getSound().getAttenuationDistance());
}
});
}
}
public void playAudio(SpeakerPosition position, float volume, EncodedAudio buffer) {
pushAudio(buffer);
pushAudio(buffer, volume);
var soundManager = Minecraft.getInstance().getSoundManager();

View File

@@ -83,4 +83,10 @@ public class SpeakerSound extends AbstractSoundInstance implements TickableSound
public @Nullable AudioStream getStream() {
return stream;
}
boolean setVolume(float volume) {
if (volume == this.volume) return false;
this.volume = volume;
return true;
}
}

View File

@@ -3,7 +3,9 @@ package com.example.examplemod;
import com.example.examplemod.data.TurtleUpgradeProvider;
import com.example.examplemod.peripheral.FurnacePeripheral;
import dan200.computercraft.api.ComputerCraftAPI;
import dan200.computercraft.api.detail.VanillaDetailRegistries;
import dan200.computercraft.api.upgrades.UpgradeType;
import net.minecraft.core.component.DataComponents;
/**
* Our example mod, containing the various things we register.
@@ -34,6 +36,16 @@ public final class ExampleMod {
ComputerCraftAPI.registerGenericSource(new FurnacePeripheral());
// @end region=generic_source
// @start region=details
VanillaDetailRegistries.ITEM_STACK.addProvider((out, stack) -> {
var food = stack.get(DataComponents.FOOD);
if (food == null) return;
out.put("saturation", food.saturation());
out.put("nutrition", food.nutrition());
});
// @end region=details
ExampleAPI.register();
}
}

View File

@@ -0,0 +1,49 @@
package com.example.examplemod;
import dan200.computercraft.api.detail.DetailRegistry;
import dan200.computercraft.api.detail.VanillaDetailRegistries;
import dan200.computercraft.api.lua.LuaFunction;
import dan200.computercraft.api.peripheral.IPeripheral;
import dan200.computercraft.api.pocket.IPocketAccess;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.LivingEntity;
import org.jspecify.annotations.Nullable;
import java.util.Map;
/**
* An example peripheral for pocket computers. This currently doesn't have an associated upgrade it mostly exists to
* demonstrate other functionality.
*/
public class ExamplePocketPeripheral implements IPeripheral {
private final IPocketAccess pocket;
public ExamplePocketPeripheral(IPocketAccess pocket) {
this.pocket = pocket;
}
@Override
public String getType() {
return "example";
}
/**
* An example of using {@linkplain DetailRegistry detail registries} to get the current player's held item.
*
* @return The item details, or {@code null} if the player is not holding an item.
*/
// @start region=details
@LuaFunction(mainThread = true)
public final @Nullable Map<String, ?> getHeldItem() {
if (!(pocket.getEntity() instanceof LivingEntity entity)) return null;
var heldItem = entity.getItemInHand(InteractionHand.MAIN_HAND);
return heldItem.isEmpty() ? null : VanillaDetailRegistries.ITEM_STACK.getDetails(heldItem);
}
// @end region=details
@Override
public boolean equals(@Nullable IPeripheral other) {
return other instanceof ExamplePocketPeripheral o && pocket == o.pocket;
}
}

View File

@@ -1,34 +0,0 @@
// SPDX-FileCopyrightText: 2024 The CC: Tweaked Developers
//
// SPDX-License-Identifier: MPL-2.0
package dan200.computercraft.shared.integration;
import com.simibubi.create.content.contraptions.BlockMovementChecks;
import com.simibubi.create.content.contraptions.BlockMovementChecks.CheckResult;
import dan200.computercraft.shared.peripheral.modem.wired.CableBlock;
import dan200.computercraft.shared.peripheral.modem.wireless.WirelessModemBlock;
/**
* Integration with Create.
*/
public final class CreateIntegration {
public static final String ID = "create";
private CreateIntegration() {
}
public static void setup() {
// Allow modems to be treated as "attached" to their adjacent block.
BlockMovementChecks.registerAttachedCheck((state, world, pos, direction) -> {
var block = state.getBlock();
if (block instanceof WirelessModemBlock) {
return CheckResult.of(state.getValue(WirelessModemBlock.FACING) == direction);
} else if (block instanceof CableBlock) {
return CheckResult.of(state.getValue(CableBlock.MODEM).getFacing() == direction);
} else {
return CheckResult.PASS;
}
});
}
}

View File

@@ -27,9 +27,9 @@ public final class ExternalModTags {
/**
* Create's "brittle" tag, used to determine if this block needs to be moved before its neighbours.
*
* @see com.simibubi.create.content.contraptions.BlockMovementChecks#isBrittle(BlockState)
* @see com.simibubi.create.api.contraption.BlockMovementChecks#isBrittle(BlockState)
*/
public static final TagKey<Block> CREATE_BRITTLE = make(CreateIntegration.ID, "brittle");
public static final TagKey<Block> CREATE_BRITTLE = make("create", "brittle");
private static TagKey<Block> make(String mod, String name) {
return TagKey.create(Registries.BLOCK, ResourceLocation.fromNamespaceAndPath(mod, name));

View File

@@ -1,5 +1,6 @@
{
"argument.computercraft.argument_expected": "Parameter erwartet",
"argument.computercraft.computer.distance": "Entfernung zur Entität",
"argument.computercraft.computer.family": "Computer familie",
"argument.computercraft.computer.id": "Computer ID",
"argument.computercraft.computer.instance": "einzigartige Instanz ID",
@@ -98,6 +99,7 @@
"gui.computercraft.config.http.bandwidth.tooltip": "Limitiert die Bandbreite der Computer.",
"gui.computercraft.config.http.enabled": "HTTP-API aktivieren",
"gui.computercraft.config.http.max_requests": "Maximale Anzahl gleichzeitiger Anfragen",
"gui.computercraft.config.http.max_requests.tooltip": "Die Anzahl der http Anfragen, die ein Computer gleichzeitig machen kann. Zusätzliche Anfragen werden der Warteschlange hinzugefügt und nach den laufenden Anfragen gesendet. Für unendlich auf 0 setzen.",
"gui.computercraft.config.http.max_websockets": "Maximale Anzahl gleichzeitiger Websockets",
"gui.computercraft.config.http.max_websockets.tooltip": "Die Anzahl der Websockets die ein Computer gleichzeitig öffnen kann.",
"gui.computercraft.config.http.proxy": "Proxy",
@@ -114,6 +116,7 @@
"gui.computercraft.config.log_computer_errors": "Computerfehler loggen",
"gui.computercraft.config.maximum_open_files": "Maximalanzahl an gleichzeitig offenen Dateien je Computer",
"gui.computercraft.config.maximum_open_files.tooltip": "Legen Sie fest, wie viele Dateien gleichzeitig geöffnet werden können. Setzen Sie auf 0 für unbegrenzt.",
"gui.computercraft.config.monitor_distance": "Monitordistanz",
"gui.computercraft.config.peripheral": "Peripheriegeräte",
"gui.computercraft.config.peripheral.command_block_enabled": "Befehlsblöcke als Peripheriegerät erlauben",
"gui.computercraft.config.peripheral.command_block_enabled.tooltip": "Befehlsblock Peripherie Unterstützung aktivieren",

View File

@@ -1,8 +1,14 @@
{
"argument.computercraft.argument_expected": "Argument attendu",
"argument.computercraft.computer.distance": "Distance jusqu'à l'entité",
"argument.computercraft.computer.family": "Famille d'ordinateurs",
"argument.computercraft.computer.id": "ID de l'ordinateur",
"argument.computercraft.computer.instance": "ID unique de l'instance",
"argument.computercraft.computer.label": "Étiquette de l'ordinateur",
"argument.computercraft.computer.many_matching": "Plusieurs ordinateurs correspondent à '%s' (instances %s)",
"argument.computercraft.computer.no_matching": "Pas d'ordinateurs correspondant à '%s'",
"argument.computercraft.tracking_field.no_field": "Champ '%s' inconnu",
"argument.computercraft.unknown_computer_family": "Famille d'ordinateur '%s ' inconnue",
"block.computercraft.cable": "Câble réseau",
"block.computercraft.computer_advanced": "Ordinateur Avancé",
"block.computercraft.computer_command": "Ordinateur de commande",
@@ -11,6 +17,7 @@
"block.computercraft.monitor_advanced": "Moniteur Avancé",
"block.computercraft.monitor_normal": "Moniteur",
"block.computercraft.printer": "Imprimante",
"block.computercraft.redstone_relay": "Relais de Redstone",
"block.computercraft.speaker": "Haut-parleur",
"block.computercraft.turtle_advanced": "Tortue Avancée",
"block.computercraft.turtle_advanced.upgraded": "Tortue %s Avancée",
@@ -137,16 +144,22 @@
"gui.computercraft.config.term_sizes": "Tailles de terminal",
"gui.computercraft.config.term_sizes.computer": "Ordinateur",
"gui.computercraft.config.term_sizes.computer.height": "Hauteur du terminal",
"gui.computercraft.config.term_sizes.computer.height.tooltip": "Hauteur du terminal de l'ordinateur",
"gui.computercraft.config.term_sizes.computer.tooltip": "Taille du terminal des ordinateurs.",
"gui.computercraft.config.term_sizes.computer.width": "Largeur du terminal",
"gui.computercraft.config.term_sizes.computer.width.tooltip": "Largeur du terminal de l'ordinateur",
"gui.computercraft.config.term_sizes.monitor": "Moniteur",
"gui.computercraft.config.term_sizes.monitor.height": "Hauteur maximale du moniteur",
"gui.computercraft.config.term_sizes.monitor.height.tooltip": "Hauteur maximale des moniteurs",
"gui.computercraft.config.term_sizes.monitor.tooltip": "Taille maximale des moniteurs (en blocs).",
"gui.computercraft.config.term_sizes.monitor.width": "Largeur maximale du moniteur",
"gui.computercraft.config.term_sizes.monitor.width.tooltip": "Largeur maximale des moniteurs",
"gui.computercraft.config.term_sizes.pocket_computer": "Ordinateur de poche",
"gui.computercraft.config.term_sizes.pocket_computer.height": "Hauteur du terminal",
"gui.computercraft.config.term_sizes.pocket_computer.height.tooltip": "Hauteur du terminal de l'ordinateur de poche",
"gui.computercraft.config.term_sizes.pocket_computer.tooltip": "Taille du terminal des ordinateurs de poche.",
"gui.computercraft.config.term_sizes.pocket_computer.width": "Largeur du terminal",
"gui.computercraft.config.term_sizes.pocket_computer.width.tooltip": "Largeur du terminal de l'ordinateur de poche",
"gui.computercraft.config.term_sizes.tooltip": "Configure la taille des différents terminaux de l'ordinateur.\nLes terminaux plus grands nécessitent plus de bande passante, réglez donc avec précaution.",
"gui.computercraft.config.turtle": "Tortues",
"gui.computercraft.config.turtle.advanced_fuel_limit": "Limite de carburant par Tortue Avancée",
@@ -192,6 +205,8 @@
"item.computercraft.treasure_disk": "Disquette",
"itemGroup.computercraft": "ComputerCraft",
"tag.item.computercraft.computer": "Ordinateurs",
"tag.item.computercraft.monitor": "Moniteurs",
"tag.item.computercraft.turtle": "Tortues",
"tag.item.computercraft.wired_modem": "Modems câblés",
"tracking_field.computercraft.avg": "%s (moyenne)",
"tracking_field.computercraft.computer_tasks.name": "Tâches",
@@ -200,6 +215,7 @@
"tracking_field.computercraft.http_download.name": "Téléchargement HTTP",
"tracking_field.computercraft.http_requests.name": "Requêtes HTTP",
"tracking_field.computercraft.http_upload.name": "Publication HTTP",
"tracking_field.computercraft.java_allocation.name": "Allocations Java",
"tracking_field.computercraft.max": "%s (max)",
"tracking_field.computercraft.peripheral.name": "Appels aux périphériques",
"tracking_field.computercraft.server_tasks.name": "Tâches du serveur",

Binary file not shown.

Before

Width:  |  Height:  |  Size: 152 B

After

Width:  |  Height:  |  Size: 155 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 179 B

After

Width:  |  Height:  |  Size: 140 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 119 B

After

Width:  |  Height:  |  Size: 120 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 92 B

After

Width:  |  Height:  |  Size: 96 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 152 B

After

Width:  |  Height:  |  Size: 155 B