mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2026-09-16 14:21:24 +00:00
Merge branch 'mc-1.20.x' into mc-1.21.x
This commit is contained in:
+2
-2
@@ -45,7 +45,7 @@ public class TurtleModemModeller implements TurtleUpgradeModeller<TurtleModem> {
|
||||
private static final ModemModels NORMAL = create("normal");
|
||||
private static final ModemModels ADVANCED = create("advanced");
|
||||
|
||||
public static ModemModels create(String type) {
|
||||
private static ModemModels create(String type) {
|
||||
return new ModemModels(
|
||||
ModelLocation.ofResource(ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "block/turtle_modem_" + type + "_off_left")),
|
||||
ModelLocation.ofResource(ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "block/turtle_modem_" + type + "_off_right")),
|
||||
@@ -54,7 +54,7 @@ public class TurtleModemModeller implements TurtleUpgradeModeller<TurtleModem> {
|
||||
);
|
||||
}
|
||||
|
||||
public Stream<ResourceLocation> getDependencies() {
|
||||
private Stream<ResourceLocation> getDependencies() {
|
||||
return Stream.of(leftOffModel, rightOffModel, leftOnModel, rightOnModel).flatMap(ModelLocation::getDependencies);
|
||||
}
|
||||
}
|
||||
|
||||
+8
-1
@@ -61,6 +61,11 @@ public abstract class SpeakerPeripheral implements IPeripheral {
|
||||
*/
|
||||
public static final int SAMPLE_RATE = 48000;
|
||||
|
||||
/**
|
||||
* The maximum length of a {@link ResourceLocation} played by {@link #playSound(ILuaContext, String, Optional, Optional)}.
|
||||
*/
|
||||
private static final int MAX_SOUND_LENGTH = 512;
|
||||
|
||||
private final UUID source = UUID.randomUUID();
|
||||
private final AttachedComputerSet computers = new AttachedComputerSet();
|
||||
|
||||
@@ -254,8 +259,10 @@ public abstract class SpeakerPeripheral implements IPeripheral {
|
||||
var volume = (float) clampVolume(checkFinite(1, volumeA.orElse(1.0)));
|
||||
var pitch = (float) checkFinite(2, pitchA.orElse(1.0));
|
||||
|
||||
if (name.length() > MAX_SOUND_LENGTH) throw new LuaException("bad argument #1 (sound name is too long)");
|
||||
|
||||
var identifier = ResourceLocation.tryParse(name);
|
||||
if (identifier == null) throw new LuaException("Malformed sound name '" + name + "' ");
|
||||
if (identifier == null) throw new LuaException("bad argument #1 (malformed sound name)");
|
||||
|
||||
// Prevent playing music discs.
|
||||
var soundEvent = BuiltInRegistries.SOUND_EVENT.get(identifier);
|
||||
|
||||
+2
-2
@@ -235,11 +235,11 @@ public class TurtlePlaceCommand implements TurtleCommand {
|
||||
}
|
||||
|
||||
private static void setSignText(Level world, SignBlockEntity sign, String message) {
|
||||
var lines = Splitter.on('\n').splitToList(message);
|
||||
var lines = Splitter.on('\n').splitToStream(message).limit(4).toList();
|
||||
var firstLine = lines.size() <= 2 ? 1 : 0;
|
||||
|
||||
var signText = new SignText();
|
||||
for (int i = 0, len = Math.min(lines.size(), 4); i < len; i++) {
|
||||
for (int i = 0, len = lines.size(); i < len; i++) {
|
||||
var line = lines.get(i);
|
||||
signText = signText.setMessage(i + firstLine, line.length() > 15
|
||||
? Component.literal(line.substring(0, 15))
|
||||
|
||||
@@ -24,7 +24,7 @@ import java.util.Optional;
|
||||
* Alternatively, one may specify the desired arguments as normal parameters and the argument parsing code will
|
||||
* be generated automatically.
|
||||
* <p>
|
||||
* Each parameter must be one of the given types supported by {@link IArguments} (for instance, {@link int} or
|
||||
* Each parameter must be one of the given types supported by {@link IArguments} (for instance, {@code int} or
|
||||
* {@link Map}). Optional values are supported by accepting a parameter of type {@link Optional}.
|
||||
* </li>
|
||||
* </ul>
|
||||
|
||||
+1
-1
@@ -129,7 +129,7 @@ public class WebsocketHandle {
|
||||
* -- }
|
||||
* ws.close()
|
||||
* }</pre>
|
||||
* @since 1.107.0
|
||||
* @since 1.117.0
|
||||
*/
|
||||
@LuaFunction
|
||||
public final Map<String, String> getResponseHeaders() {
|
||||
|
||||
@@ -545,11 +545,6 @@ final class ComputerExecutor implements ComputerScheduler.Worker {
|
||||
terminal.setCursorPos(0, terminal.getCursorY() + 1);
|
||||
terminal.write(extra);
|
||||
}
|
||||
|
||||
// And display our generic "CC may be installed incorrectly" message.
|
||||
terminal.setCursorPos(0, terminal.getCursorY() + 1);
|
||||
if (terminal.isColour()) terminal.setTextColour(15 - Colour.WHITE.ordinal());
|
||||
terminal.write("ComputerCraft may be installed incorrectly");
|
||||
}
|
||||
|
||||
private void resumeMachine(@Nullable String event, @Nullable Object @Nullable [] args) throws InterruptedException {
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
# New features in CC: Tweaked 1.117.1
|
||||
|
||||
Several bug fixes:
|
||||
* Several documentation fixes (MarianoAlipi, Pokebrouserkat).
|
||||
* Fix `pushFluid`/`pullFluid` not working when fluids have NBT (UQuark).
|
||||
* Limit length of sound in `speaker.playSound`.
|
||||
* Remove confusing "ComputerCraft may be installed incorrectly" message.
|
||||
|
||||
# New features in CC: Tweaked 1.117.0
|
||||
|
||||
* Support mouse input for pocket computers on a lectern.
|
||||
|
||||
@@ -1 +1 @@
|
||||
type determines the type of a file or directory. Prints "file", "directory" or "does not exist".
|
||||
type determines the type of a file or directory. Prints "file", "directory" or "No such path".
|
||||
|
||||
@@ -1,19 +1,9 @@
|
||||
New features in CC: Tweaked 1.117.0
|
||||
|
||||
* Support mouse input for pocket computers on a lectern.
|
||||
* Pocket computers on a lectern now attach the peripheral below.
|
||||
* Add map colour to block and item details (ShreksHellraiser).
|
||||
* Add potion effects to item details.
|
||||
* add `getResponseHeaders` method to websocket handles.
|
||||
* Update translations.
|
||||
New features in CC: Tweaked 1.117.1
|
||||
|
||||
Several bug fixes:
|
||||
* Many documentation fixes (McJack123, tomodachi94).
|
||||
* Fix crash when CC:T blocks are placed with Building Gadgets.
|
||||
* Fix redstone relays not updating redstone input/output on chunk load.
|
||||
* Fix inconsistency with handling `. .` on Windows.
|
||||
* Fix bundled cable input not updating with MoreRed.
|
||||
* Fix `websocket_closed` not always being closed when the socket closes due to an error.
|
||||
* Fix `nbt` hash failing to be computed for some items.
|
||||
* Several documentation fixes (MarianoAlipi, Pokebrouserkat).
|
||||
* Fix `pushFluid`/`pullFluid` not working when fluids have NBT (UQuark).
|
||||
* Limit length of sound in `speaker.playSound`.
|
||||
* Remove confusing "ComputerCraft may be installed incorrectly" message.
|
||||
|
||||
Type "help changelog" to see the full version history.
|
||||
|
||||
@@ -124,6 +124,9 @@ neoForge {
|
||||
}
|
||||
|
||||
configurations {
|
||||
// Force a more recent version of ASM, so we're compatible with Java 25.
|
||||
configureEach { resolutionStrategy.force(libs.asm) }
|
||||
|
||||
additionalRuntimeClasspath { extendsFrom(jarJar.get()) }
|
||||
|
||||
val testAdditionalRuntimeClasspath by registering {
|
||||
|
||||
+20
-8
@@ -13,6 +13,7 @@ import dan200.computercraft.shared.util.CapabilityUtil;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.material.Fluid;
|
||||
import net.neoforged.neoforge.capabilities.Capabilities;
|
||||
import net.neoforged.neoforge.fluids.FluidStack;
|
||||
import net.neoforged.neoforge.fluids.capability.IFluidHandler;
|
||||
@@ -63,7 +64,7 @@ public final class FluidMethods extends AbstractFluidMethods<IFluidHandler> {
|
||||
|
||||
return fluid == null
|
||||
? moveFluid(from, actualLimit, to)
|
||||
: moveFluid(from, new FluidStack(fluid, actualLimit), to);
|
||||
: moveFluid(from, fluid, actualLimit, to);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -88,7 +89,7 @@ public final class FluidMethods extends AbstractFluidMethods<IFluidHandler> {
|
||||
|
||||
return fluid == null
|
||||
? moveFluid(from, actualLimit, to)
|
||||
: moveFluid(from, new FluidStack(fluid, actualLimit), to);
|
||||
: moveFluid(from, fluid, actualLimit, to);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -111,7 +112,7 @@ public final class FluidMethods extends AbstractFluidMethods<IFluidHandler> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Move fluid from one handler to another.
|
||||
* Move any fluid from one handler to another.
|
||||
*
|
||||
* @param from The handler to move from.
|
||||
* @param limit The maximum amount of fluid to move.
|
||||
@@ -123,15 +124,26 @@ public final class FluidMethods extends AbstractFluidMethods<IFluidHandler> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Move fluid from one handler to another.
|
||||
* Move a specific fluid from one handler to another.
|
||||
*
|
||||
* @param from The handler to move from.
|
||||
* @param fluid The fluid and limit to move.
|
||||
* @param fluid The fluid to move.
|
||||
* @param limit The maximum amount of fluid to move.
|
||||
* @param to The handler to move to.
|
||||
* @return The amount of fluid moved.
|
||||
*/
|
||||
private static int moveFluid(IFluidHandler from, FluidStack fluid, IFluidHandler to) {
|
||||
return moveFluid(from, from.drain(fluid, IFluidHandler.FluidAction.SIMULATE), fluid.getAmount(), to);
|
||||
private static int moveFluid(IFluidHandler from, Fluid fluid, int limit, IFluidHandler to) {
|
||||
// Rather than constructing the FluidStack directly, we try to find a matching fluid (but with possibly
|
||||
// different NBT components) in the tank.
|
||||
for (int i = 0, len = from.getTanks(); i < len; i++) {
|
||||
var currentFluid = from.getFluidInTank(i);
|
||||
if (currentFluid.getFluid() != fluid) continue;
|
||||
|
||||
var extracted = from.drain(currentFluid, IFluidHandler.FluidAction.SIMULATE);
|
||||
if (!extracted.isEmpty()) return moveFluid(from, extracted, limit, to);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -144,7 +156,7 @@ public final class FluidMethods extends AbstractFluidMethods<IFluidHandler> {
|
||||
* @return The amount of fluid moved.
|
||||
*/
|
||||
private static int moveFluid(IFluidHandler from, FluidStack extracted, int limit, IFluidHandler to) {
|
||||
if (extracted.getAmount() <= 0) return 0;
|
||||
if (extracted.isEmpty()) return 0;
|
||||
|
||||
// Limit the amount to extract.
|
||||
extracted = extracted.copy();
|
||||
|
||||
Reference in New Issue
Block a user