1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-10-26 11:27:38 +00:00

Merge branch 'mc-1.16.x' into mc-1.17.x

This commit is contained in:
Jonathan Coates
2021-08-20 21:47:34 +01:00
93 changed files with 2209 additions and 1602 deletions

View File

@@ -60,6 +60,7 @@ public class SoundManager
setPosition( position );
this.volume = volume;
this.pitch = pitch;
attenuation = Attenuation.LINEAR;
}
void setPosition( Vec3 position )

View File

@@ -30,15 +30,15 @@ import dan200.computercraft.core.computer.ComputerSide;
*
* @cc.usage Toggle the redstone signal above the computer every 0.5 seconds.
*
* <pre>
* <pre>{@code
* while true do
* redstone.setOutput("top", not redstone.getOutput("top"))
* sleep(0.5)
* end
* </pre>
* }</pre>
* @cc.usage Mimic a redstone comparator in [subtraction mode][comparator].
*
* <pre>
* <pre>{@code
* while true do
* local rear = rs.getAnalogueInput("back")
* local sides = math.max(rs.getAnalogueInput("left"), rs.getAnalogueInput("right"))
@@ -46,7 +46,7 @@ import dan200.computercraft.core.computer.ComputerSide;
*
* os.pullEvent("redstone") -- Wait for a change to inputs.
* end
* </pre>
* }</pre>
*
* [comparator]: https://minecraft.gamepedia.com/Redstone_Comparator#Subtract_signal_strength "Redstone Comparator on
* the Minecraft wiki."
@@ -205,9 +205,9 @@ public class RedstoneAPI implements ILuaAPI
* @param mask The mask to test.
* @return If the colours are on.
* @cc.usage Check if @{colors.white} and @{colors.black} are on above the computer.
* <pre>
* <pre>{@code
* print(redstone.testBundledInput("top", colors.combine(colors.white, colors.black)))
* </pre>
* }</pre>
* @see #getBundledInput
*/
@LuaFunction

View File

@@ -91,9 +91,9 @@ public class CommandAPI implements ILuaAPI
* @cc.treturn number|nil The number of "affected" objects, or `nil` if the command failed. The definition of this
* varies from command to command.
* @cc.usage Set the block above the command computer to stone.
* <pre>
* <pre>{@code
* commands.exec("setblock ~ ~1 ~ minecraft:stone")
* </pre>
* }</pre>
*/
@LuaFunction( mainThread = true )
public final Object[] exec( String command )
@@ -117,9 +117,9 @@ public class CommandAPI implements ILuaAPI
* @return The "task id". When this command has been executed, it will queue a `task_complete` event with a matching id.
* @throws LuaException (hidden) If the task cannot be created.
* @cc.usage Asynchronously sets the block above the computer to stone.
* <pre>
* <pre>{@code
* commands.execAsync("~ ~1 ~ minecraft:stone")
* </pre>
* }</pre>
* @cc.see parallel One may also use the parallel API to run multiple commands at once.
*/
@LuaFunction

View File

@@ -90,7 +90,6 @@ public final class NetworkHandler
}
/**
* /**
* Register packet, and a thread-unsafe handler for it.
*
* @param <T> The type of the packet to send.

View File

@@ -34,7 +34,7 @@ public final class WiredModemLocalPeripheral
private static final String NBT_PERIPHERAL_TYPE = "PeripheralType";
private static final String NBT_PERIPHERAL_ID = "PeripheralId";
private int id;
private int id = -1;
private String type;
private IPeripheral peripheral;

View File

@@ -28,11 +28,11 @@ import javax.annotation.Nullable;
* @cc.module monitor
* @cc.usage Write "Hello, world!" to an adjacent monitor:
*
* <pre>
* <pre>{@code
* local monitor = peripheral.find("monitor")
* monitor.setCursorPos(1, 1)
* monitor.write("Hello, world!")
* </pre>
* }</pre>
*/
public class MonitorPeripheral extends TermMethods implements IPeripheral
{

View File

@@ -176,7 +176,8 @@ public abstract class SpeakerPeripheral implements IPeripheral
Level world = getLevel();
Vec3 pos = getPosition();
float range = Mth.clamp( volume, 1.0f, 3.0f ) * 16;
float actualVolume = Mth.clamp( volume, 0.0f, 3.0f );
float range = actualVolume * 16;
context.issueMainThreadTask( () -> {
MinecraftServer server = world.getServer();
@@ -186,13 +187,13 @@ public abstract class SpeakerPeripheral implements IPeripheral
{
server.getPlayerList().broadcast(
null, pos.x, pos.y, pos.z, range, world.dimension(),
new ClientboundCustomSoundPacket( name, SoundSource.RECORDS, pos, range, pitch )
new ClientboundCustomSoundPacket( name, SoundSource.RECORDS, pos, actualVolume, pitch )
);
}
else
{
NetworkHandler.sendToAllAround(
new SpeakerPlayClientMessage( getSource(), pos, name, range, pitch ),
new SpeakerPlayClientMessage( getSource(), pos, name, actualVolume, pitch ),
world, pos, range
);
}

View File

@@ -25,13 +25,13 @@ import net.minecraftforge.items.wrapper.PlayerMainInvWrapper;
* This API is only available on pocket computers. As such, you may use its presence to determine what kind of computer
* you are using:
*
* <pre>
* <pre>{@code
* if pocket then
* print("On a pocket computer")
* else
* print("On something else")
* end
* </pre>
* }</pre>
*
* @cc.module pocket
*/