mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-10-15 22:17:39 +00:00
Compare commits
50 Commits
hotfix/ite
...
v1.19.3-1.
Author | SHA1 | Date | |
---|---|---|---|
![]() |
9e6e0c8b88 | ||
![]() |
5502412181 | ||
![]() |
62e3c5f9aa | ||
![]() |
7e54a40fa9 | ||
![]() |
8ac42566ec | ||
![]() |
66b20d2bdb | ||
![]() |
81dad421d5 | ||
![]() |
3075d3cea8 | ||
![]() |
cdab8f429e | ||
![]() |
2e5cd29e12 | ||
![]() |
22cadd6730 | ||
![]() |
366052ec48 | ||
![]() |
3224e0bf8b | ||
![]() |
fb4b097a66 | ||
![]() |
67f3d91850 | ||
![]() |
1e3a930543 | ||
![]() |
b21e2f4e63 | ||
![]() |
a12b405acf | ||
![]() |
e076818b29 | ||
![]() |
1554c7b397 | ||
![]() |
6cd32a6368 | ||
![]() |
7335a892b5 | ||
![]() |
83eddc6636 | ||
![]() |
d066d175bf | ||
![]() |
9873ccfa0d | ||
![]() |
da7a50368d | ||
![]() |
8cfbfe7ceb | ||
![]() |
67244b17af | ||
![]() |
9e1de23f4a | ||
![]() |
86b60855d6 | ||
![]() |
db6b6fd173 | ||
![]() |
2014e9527e | ||
![]() |
f43b839056 | ||
![]() |
f561572509 | ||
![]() |
edb21f33be | ||
![]() |
02b68b259e | ||
![]() |
28a55349a9 | ||
![]() |
2457a31728 | ||
![]() |
cdc91a8e5d | ||
![]() |
8024017f53 | ||
![]() |
592ff84aea | ||
![]() |
4360458416 | ||
![]() |
717e096b94 | ||
![]() |
34a31abd9c | ||
![]() |
bdecb88cca | ||
![]() |
af15030fa4 | ||
![]() |
3a883db49e | ||
![]() |
8ea5b64f64 | ||
![]() |
7b6caf76e4 | ||
![]() |
230c7ee904 |
8
.github/workflows/main-ci.yml
vendored
8
.github/workflows/main-ci.yml
vendored
@@ -38,11 +38,17 @@ jobs:
|
||||
# These are a little flaky on GH actions: its useful to run them, but don't break the build.
|
||||
continue-on-error: true
|
||||
|
||||
- name: Prepare Jars
|
||||
run: |
|
||||
# Find the main jar and append the git hash onto it.
|
||||
mkdir -p jars
|
||||
find projects/forge/build/libs projects/fabric/build/libs -type f -regex '.*[0-9.]+\(-SNAPSHOT\)?\.jar$' -exec bash -c 'cp {} "jars/$(basename {} .jar)-$(git rev-parse HEAD).jar"' \;
|
||||
|
||||
- name: Upload Jar
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: CC-Tweaked
|
||||
path: projects/forge/build/libs
|
||||
path: ./jars
|
||||
|
||||
- name: Upload coverage
|
||||
uses: codecov/codecov-action@v3
|
||||
|
@@ -34,7 +34,7 @@ abstract class CheckChangelog : DefaultTask() {
|
||||
|
||||
var ok = true
|
||||
|
||||
// Check we're targetting the current version
|
||||
// Check we're targeting the current version
|
||||
var whatsNew = whatsNew.get().asFile.readLines()
|
||||
if (whatsNew[0] != "New features in CC: Tweaked $version") {
|
||||
ok = false
|
||||
|
@@ -3,19 +3,20 @@ module: [kind=event] alarm
|
||||
see: os.setAlarm To start an alarm.
|
||||
---
|
||||
|
||||
The @{timer} event is fired when an alarm started with @{os.setAlarm} completes.
|
||||
The @{alarm} event is fired when an alarm started with @{os.setAlarm} completes.
|
||||
|
||||
## Return Values
|
||||
1. @{string}: The event name.
|
||||
2. @{number}: The ID of the alarm that finished.
|
||||
|
||||
## Example
|
||||
Starts a timer and then prints its ID:
|
||||
Starts a timer and then waits for it to complete.
|
||||
|
||||
```lua
|
||||
local alarmID = os.setAlarm(os.time() + 0.05)
|
||||
local alarm_id = os.setAlarm(os.time() + 0.05)
|
||||
local event, id
|
||||
repeat
|
||||
event, id = os.pullEvent("alarm")
|
||||
until id == alarmID
|
||||
until id == alarm_id
|
||||
print("Alarm with ID " .. id .. " was fired")
|
||||
```
|
||||
|
@@ -3,7 +3,7 @@ module: [kind=event] char
|
||||
see: key To listen to any key press.
|
||||
---
|
||||
|
||||
The @{char} event is fired when a character is _typed_ on the keyboard.
|
||||
The @{char} event is fired when a character is typed on the keyboard.
|
||||
|
||||
The @{char} event is different to a key press. Sometimes multiple key presses may result in one character being
|
||||
typed (for instance, on some European keyboards). Similarly, some keys (e.g. <kbd>Ctrl</kbd>) do not have any
|
||||
@@ -16,9 +16,10 @@ corresponding character. The @{key} should be used if you want to listen to key
|
||||
|
||||
## Example
|
||||
Prints each character the user presses:
|
||||
|
||||
```lua
|
||||
while true do
|
||||
local event, character = os.pullEvent("char")
|
||||
print(character .. " was pressed.")
|
||||
local event, character = os.pullEvent("char")
|
||||
print(character .. " was pressed.")
|
||||
end
|
||||
```
|
||||
|
@@ -6,7 +6,7 @@ The @{computer_command} event is fired when the `/computercraft queue` command i
|
||||
|
||||
## Return Values
|
||||
1. @{string}: The event name.
|
||||
... @{string}: The arguments passed to the command.
|
||||
2. @{string}<abbr title="Variable number of arguments">…</abbr>: The arguments passed to the command.
|
||||
|
||||
## Example
|
||||
Prints the contents of messages sent:
|
||||
|
@@ -5,9 +5,9 @@ since: 1.101.0
|
||||
|
||||
The @{file_transfer} event is queued when a user drags-and-drops a file on an open computer.
|
||||
|
||||
This event contains a single argument, that in turn has a single method @{TransferredFiles.getFiles|getFiles}. This
|
||||
returns the list of files that are being transferred. Each file is a @{fs.BinaryReadHandle|binary file handle} with an
|
||||
additional @{TransferredFile.getName|getName} method.
|
||||
This event contains a single argument of type @{TransferredFiles}, which can be used to @{TransferredFiles.getFiles|get
|
||||
the files to be transferred}. Each file returned is a @{fs.BinaryReadHandle|binary file handle} with an additional
|
||||
@{TransferredFile.getName|getName} method.
|
||||
|
||||
## Return values
|
||||
1. @{string}: The event name
|
||||
|
@@ -11,4 +11,4 @@ This event is normally handled inside @{http.checkURL}, but it can still be seen
|
||||
1. @{string}: The event name.
|
||||
2. @{string}: The URL requested to be checked.
|
||||
3. @{boolean}: Whether the check succeeded.
|
||||
4. @{string|nil}: If the check failed, a reason explaining why the check failed.
|
||||
4. <span class="type">@{string}|@{nil}</span>: If the check failed, a reason explaining why the check failed.
|
||||
|
@@ -11,7 +11,8 @@ This event is normally handled inside @{http.get} and @{http.post}, but it can s
|
||||
1. @{string}: The event name.
|
||||
2. @{string}: The URL of the site requested.
|
||||
3. @{string}: An error describing the failure.
|
||||
4. @{http.Response|nil}: A response handle if the connection succeeded, but the server's response indicated failure.
|
||||
4. <span class="type">@{http.Response}|@{nil}</span>: A response handle if the connection succeeded, but the server's
|
||||
response indicated failure.
|
||||
|
||||
## Example
|
||||
Prints an error why the website cannot be contacted:
|
||||
|
@@ -10,7 +10,7 @@ This event is normally handled inside @{http.get} and @{http.post}, but it can s
|
||||
## Return Values
|
||||
1. @{string}: The event name.
|
||||
2. @{string}: The URL of the site requested.
|
||||
3. @{http.Response}: The handle for the response text.
|
||||
3. @{http.Response}: The successful HTTP response.
|
||||
|
||||
## Example
|
||||
Prints the content of a website (this may fail if the request fails):
|
||||
|
@@ -10,7 +10,7 @@ The @{modem_message} event is fired when a message is received on an open channe
|
||||
3. @{number}: The channel that the message was sent on.
|
||||
4. @{number}: The reply channel set by the sender.
|
||||
5. @{any}: The message as sent by the sender.
|
||||
6. @{number}: The distance between the sender and the receiver, in blocks.
|
||||
6. <span class="type">@{number}|@{nil}</span>: The distance between the sender and the receiver in blocks, or @{nil} if the message was sent between dimensions.
|
||||
|
||||
## Example
|
||||
Wraps a @{modem} peripheral, opens channel 0 for listening, and prints all received messages.
|
||||
@@ -20,7 +20,9 @@ local modem = peripheral.find("modem") or error("No modem attached", 0)
|
||||
modem.open(0)
|
||||
|
||||
while true do
|
||||
local event, side, channel, replyChannel, message, distance = os.pullEvent("modem_message")
|
||||
print(("Message received on side %s on channel %d (reply to %d) from %f blocks away with message %s"):format(side, channel, replyChannel, distance, tostring(message)))
|
||||
local event, side, channel, replyChannel, message, distance = os.pullEvent("modem_message")
|
||||
print(("Message received on side %s on channel %d (reply to %d) from %f blocks away with message %s"):format(
|
||||
side, channel, replyChannel, distance, tostring(message)
|
||||
))
|
||||
end
|
||||
```
|
||||
|
@@ -6,10 +6,11 @@ The @{monitor_resize} event is fired when an adjacent or networked monitor's siz
|
||||
|
||||
## Return Values
|
||||
1. @{string}: The event name.
|
||||
2. @{string}: The side or network ID of the monitor that resized.
|
||||
2. @{string}: The side or network ID of the monitor that was resized.
|
||||
|
||||
## Example
|
||||
Prints a message when a monitor is resized:
|
||||
|
||||
```lua
|
||||
while true do
|
||||
local event, side = os.pullEvent("monitor_resize")
|
||||
|
@@ -14,7 +14,7 @@ This event is usually handled by @{rednet.receive}, but it can also be pulled ma
|
||||
1. @{string}: The event name.
|
||||
2. @{number}: The ID of the sending computer.
|
||||
3. @{any}: The message sent.
|
||||
4. @{string|nil}: The protocol of the message, if provided.
|
||||
4. <span class="type">@{string}|@{nil}</span>: The protocol of the message, if provided.
|
||||
|
||||
## Example
|
||||
Prints a message when one is sent:
|
||||
|
@@ -4,6 +4,9 @@ module: [kind=event] redstone
|
||||
|
||||
The @{event!redstone} event is fired whenever any redstone inputs on the computer change.
|
||||
|
||||
## Return values
|
||||
1. @{string}: The event name.
|
||||
|
||||
## Example
|
||||
Prints a message when a redstone input changes:
|
||||
```lua
|
||||
|
@@ -10,7 +10,7 @@ The @{task_complete} event is fired when an asynchronous task completes. This is
|
||||
2. @{number}: The ID of the task that completed.
|
||||
3. @{boolean}: Whether the command succeeded.
|
||||
4. @{string}: If the command failed, an error message explaining the failure. (This is not present if the command succeeded.)
|
||||
...: Any parameters returned from the command.
|
||||
5. <abbr title="Variable number of arguments">…</abbr>: Any parameters returned from the command.
|
||||
|
||||
## Example
|
||||
Prints the results of an asynchronous command:
|
||||
|
@@ -9,8 +9,12 @@ The @{term_resize} event is fired when the main terminal is resized. For instanc
|
||||
When this event fires, some parts of the terminal may have been moved or deleted. Simple terminal programs (those
|
||||
not using @{term.setCursorPos}) can ignore this event, but more complex GUI programs should redraw the entire screen.
|
||||
|
||||
## Return values
|
||||
1. @{string}: The event name.
|
||||
|
||||
## Example
|
||||
Prints :
|
||||
Print a message each time the terminal is resized.
|
||||
|
||||
```lua
|
||||
while true do
|
||||
os.pullEvent("term_resize")
|
||||
|
@@ -8,6 +8,9 @@ This event is normally handled by @{os.pullEvent}, and will not be returned. How
|
||||
|
||||
@{terminate} will be sent even when a filter is provided to @{os.pullEventRaw}. When using @{os.pullEventRaw} with a filter, make sure to check that the event is not @{terminate}.
|
||||
|
||||
## Return values
|
||||
1. @{string}: The event name.
|
||||
|
||||
## Example
|
||||
Prints a message when Ctrl-T is held:
|
||||
```lua
|
||||
|
@@ -10,12 +10,12 @@ The @{timer} event is fired when a timer started with @{os.startTimer} completes
|
||||
2. @{number}: The ID of the timer that finished.
|
||||
|
||||
## Example
|
||||
Starts a timer and then prints its ID:
|
||||
Start and wait for a timer to finish.
|
||||
```lua
|
||||
local timerID = os.startTimer(2)
|
||||
local timer_id = os.startTimer(2)
|
||||
local event, id
|
||||
repeat
|
||||
event, id = os.pullEvent("timer")
|
||||
until id == timerID
|
||||
until id == timer_id
|
||||
print("Timer with ID " .. id .. " was fired")
|
||||
```
|
||||
|
@@ -4,6 +4,9 @@ module: [kind=event] turtle_inventory
|
||||
|
||||
The @{turtle_inventory} event is fired when a turtle's inventory is changed.
|
||||
|
||||
## Return values
|
||||
1. @{string}: The event name.
|
||||
|
||||
## Example
|
||||
Prints a message when the inventory is changed:
|
||||
```lua
|
||||
|
@@ -25,7 +25,7 @@ single-player or multiplayer. Look for lines that look like this:
|
||||
```
|
||||
|
||||
On 1.95.0 and later, this will be a single entry with `host = "$private"`. On earlier versions, this will be a number of
|
||||
`[[http.rules]]` with various IP addresses. You will want to remove all of the `[[http.rules]]` entires that have
|
||||
`[[http.rules]]` with various IP addresses. You will want to remove all of the `[[http.rules]]` entries that have
|
||||
`action = "deny"`. Then save the file and relaunch Minecraft (Server).
|
||||
|
||||
Here's what it should look like after removing:
|
||||
@@ -54,7 +54,7 @@ like this:
|
||||
```toml
|
||||
#A list of wildcards for domains or IP ranges that cannot be accessed through the "http" API on Computers.
|
||||
#If this is empty then all whitelisted domains will be accessible. Example: "*.github.com" will block access to all subdomains of github.com.
|
||||
#You can use domain names ("pastebin.com"), wilcards ("*.pastebin.com") or CIDR notation ("127.0.0.0/8").
|
||||
#You can use domain names ("pastebin.com"), wildcards ("*.pastebin.com") or CIDR notation ("127.0.0.0/8").
|
||||
blacklist = ["127.0.0.0/8", "10.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16", "fd00::/8"]
|
||||
```
|
||||
|
||||
@@ -65,7 +65,7 @@ Here's what it should look like after removing:
|
||||
```toml
|
||||
#A list of wildcards for domains or IP ranges that cannot be accessed through the "http" API on Computers.
|
||||
#If this is empty then all whitelisted domains will be accessible. Example: "*.github.com" will block access to all subdomains of github.com.
|
||||
#You can use domain names ("pastebin.com"), wilcards ("*.pastebin.com") or CIDR notation ("127.0.0.0/8").
|
||||
#You can use domain names ("pastebin.com"), wildcards ("*.pastebin.com") or CIDR notation ("127.0.0.0/8").
|
||||
blacklist = []
|
||||
```
|
||||
|
||||
|
@@ -5,8 +5,8 @@ kotlin.stdlib.default.dependency=false
|
||||
kotlin.jvm.target.validation.mode=error
|
||||
|
||||
# Mod properties
|
||||
isUnstable=true
|
||||
modVersion=1.102.0
|
||||
isUnstable=false
|
||||
modVersion=1.103.0
|
||||
|
||||
# Minecraft properties: We want to configure this here so we can read it in settings.gradle
|
||||
mcVersion=1.19.3
|
||||
|
@@ -4,7 +4,7 @@
|
||||
# MC version is specified in gradle.properties, as we need that in settings.gradle.
|
||||
fabric-api = "0.68.1+1.19.3"
|
||||
fabric-loader = "0.14.11"
|
||||
forge = "44.0.18"
|
||||
forge = "44.1.0"
|
||||
forgeSpi = "6.0.0"
|
||||
mixin = "0.8.5"
|
||||
parchment = "2022.11.27"
|
||||
@@ -14,19 +14,19 @@ parchmentMc = "1.19.2"
|
||||
asm = "9.3"
|
||||
autoService = "1.0.1"
|
||||
checkerFramework = "3.12.0"
|
||||
cobalt = "0.5.9"
|
||||
cobalt = "0.6.0"
|
||||
fastutil = "8.5.9"
|
||||
guava = "31.1-jre"
|
||||
jetbrainsAnnotations = "23.0.0"
|
||||
jsr305 = "3.0.2"
|
||||
kotlin = "1.7.10"
|
||||
kotlin-coroutines = "1.6.0"
|
||||
kotlin = "1.8.0"
|
||||
kotlin-coroutines = "1.6.4"
|
||||
netty = "4.1.82.Final"
|
||||
nightConfig = "3.6.5"
|
||||
slf4j = "1.7.36"
|
||||
|
||||
# Minecraft mods
|
||||
forgeConfig = "5.0.3"
|
||||
forgeConfig = "5.0.4"
|
||||
iris = "1.19.3-v1.4.6"
|
||||
jei = "11.3.0.262"
|
||||
modmenu = "5.0.1"
|
||||
@@ -42,7 +42,7 @@ jqwik = "1.7.0"
|
||||
junit = "5.9.1"
|
||||
|
||||
# Build tools
|
||||
cctJavadoc = "1.5.3"
|
||||
cctJavadoc = "1.6.0"
|
||||
checkstyle = "10.3.4"
|
||||
curseForgeGradle = "1.0.11"
|
||||
errorProne-core = "2.14.0"
|
||||
@@ -51,7 +51,7 @@ fabric-loom = "1.0-SNAPSHOT"
|
||||
forgeGradle = "5.1.+"
|
||||
githubRelease = "2.2.12"
|
||||
ideaExt = "1.1.6"
|
||||
illuaminate = "0.1.0-7-g2a5a89c"
|
||||
illuaminate = "0.1.0-13-g689d73d"
|
||||
librarian = "1.+"
|
||||
minotaur = "2.+"
|
||||
mixinGradle = "0.7.+"
|
||||
@@ -73,8 +73,9 @@ forgeSpi = { module = "net.minecraftforge:forgespi", version.ref = "forgeSpi" }
|
||||
guava = { module = "com.google.guava:guava", version.ref = "guava" }
|
||||
jetbrainsAnnotations = { module = "org.jetbrains:annotations", version.ref = "jetbrainsAnnotations" }
|
||||
jsr305 = { module = "com.google.code.findbugs:jsr305", version.ref = "jsr305" }
|
||||
kotlin-platform = { module = "org.jetbrains.kotlin:kotlin-bom", version.ref = "kotlin" }
|
||||
kotlin-coroutines = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlin-coroutines" }
|
||||
kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib-jdk8", version.ref = "kotlin" }
|
||||
kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib", version.ref = "kotlin" }
|
||||
netty-http = { module = "io.netty:netty-codec-http", version.ref = "netty" }
|
||||
nightConfig-core = { module = "com.electronwill.night-config:core", version.ref = "nightConfig" }
|
||||
nightConfig-toml = { module = "com.electronwill.night-config:toml", version.ref = "nightConfig" }
|
||||
|
@@ -8,7 +8,11 @@ package dan200.computercraft.api;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.context.UseOnContext;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
||||
/**
|
||||
@@ -21,6 +25,15 @@ public class ComputerCraftTags {
|
||||
public static final TagKey<Item> WIRED_MODEM = make("wired_modem");
|
||||
public static final TagKey<Item> MONITOR = make("monitor");
|
||||
|
||||
/**
|
||||
* Items which can be {@linkplain Item#use(Level, Player, InteractionHand) used} when calling
|
||||
* {@code turtle.place()}.
|
||||
* <p>
|
||||
* This does not cover items who handle placing inside {@link Item#useOn(UseOnContext)}, as that is always
|
||||
* called.
|
||||
*/
|
||||
public static final TagKey<Item> TURTLE_CAN_PLACE = make("turtle_can_place");
|
||||
|
||||
private static TagKey<Item> make(String name) {
|
||||
return TagKey.create(Registries.ITEM, new ResourceLocation(ComputerCraftAPI.MOD_ID, name));
|
||||
}
|
||||
|
@@ -32,6 +32,8 @@ public interface DetailRegistry<T> {
|
||||
/**
|
||||
* Compute basic details about an object. This is cheaper than computing all details operation, and so is suitable
|
||||
* for when you need to compute the details for a large number of values.
|
||||
* <p>
|
||||
* This method <em>MAY</em> be thread safe: consult the instance's documentation for details.
|
||||
*
|
||||
* @param object The object to get details for.
|
||||
* @return The basic details.
|
||||
@@ -40,6 +42,8 @@ public interface DetailRegistry<T> {
|
||||
|
||||
/**
|
||||
* Compute all details about an object, using {@link #getBasicDetails(Object)} and any registered providers.
|
||||
* <p>
|
||||
* This method is <em>NOT</em> thread safe. It should only be called from the computer thread.
|
||||
*
|
||||
* @param object The object to get details for.
|
||||
* @return The computed details.
|
||||
|
@@ -15,12 +15,17 @@ import net.minecraft.world.level.block.Block;
|
||||
public class VanillaDetailRegistries {
|
||||
/**
|
||||
* Provides details for {@link ItemStack}s.
|
||||
* <p>
|
||||
* This instance's {@link DetailRegistry#getBasicDetails(Object)} is thread safe (assuming the stack is immutable)
|
||||
* and may be called from the computer thread.
|
||||
*/
|
||||
public static final DetailRegistry<ItemStack> ITEM_STACK = ComputerCraftAPIService.get().getItemStackDetailRegistry();
|
||||
|
||||
/**
|
||||
* Provides details for {@link BlockReference}, a reference to a {@link Block} in the world.
|
||||
* <p>
|
||||
* This instance's {@link DetailRegistry#getBasicDetails(Object)} is thread safe and may be called from the computer
|
||||
* thread.
|
||||
*/
|
||||
public static final DetailRegistry<BlockReference> BLOCK_IN_WORLD = ComputerCraftAPIService.get().getBlockInWorldDetailRegistry();
|
||||
|
||||
}
|
||||
|
@@ -15,6 +15,7 @@ import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.world.Container;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@@ -24,6 +25,7 @@ import javax.annotation.Nullable;
|
||||
* This should not be implemented by your classes. Do not interact with turtles except via this interface and
|
||||
* {@link ITurtleUpgrade}.
|
||||
*/
|
||||
@ApiStatus.NonExtendable
|
||||
public interface ITurtleAccess {
|
||||
/**
|
||||
* Returns the world in which the turtle resides.
|
||||
|
@@ -98,7 +98,7 @@ public abstract class TurtleUpgradeDataProvider extends UpgradeDataProvider<ITur
|
||||
* get the final damage.
|
||||
*
|
||||
* @param damageMultiplier The damage multiplier.
|
||||
* @return The tool builder, for futher use.
|
||||
* @return The tool builder, for further use.
|
||||
*/
|
||||
public ToolBuilder damageMultiplier(float damageMultiplier) {
|
||||
this.damageMultiplier = damageMultiplier;
|
||||
|
@@ -144,7 +144,7 @@ public abstract class UpgradeDataProvider<T extends UpgradeBase, R extends Upgra
|
||||
}
|
||||
|
||||
public List<T> getGeneratedUpgrades() {
|
||||
if (upgrades == null) throw new IllegalStateException("Upgrades have not beeen generated yet");
|
||||
if (upgrades == null) throw new IllegalStateException("Upgrades have not been generated yet");
|
||||
return upgrades;
|
||||
}
|
||||
|
||||
|
@@ -30,6 +30,7 @@ public class TerminalWidget extends AbstractWidget {
|
||||
private static final Component DESCRIPTION = Component.translatable("gui.computercraft.terminal");
|
||||
|
||||
private static final float TERMINATE_TIME = 0.5f;
|
||||
private static final float KEY_SUPPRESS_DELAY = 0.2f;
|
||||
|
||||
private final Terminal terminal;
|
||||
private final InputHandler computer;
|
||||
@@ -79,15 +80,12 @@ public class TerminalWidget extends AbstractWidget {
|
||||
switch (key) {
|
||||
case GLFW.GLFW_KEY_T -> {
|
||||
if (terminateTimer < 0) terminateTimer = 0;
|
||||
return true;
|
||||
}
|
||||
case GLFW.GLFW_KEY_S -> {
|
||||
if (shutdownTimer < 0) shutdownTimer = 0;
|
||||
return true;
|
||||
}
|
||||
case GLFW.GLFW_KEY_R -> {
|
||||
if (rebootTimer < 0) rebootTimer = 0;
|
||||
return true;
|
||||
}
|
||||
case GLFW.GLFW_KEY_V -> {
|
||||
// Ctrl+V for paste
|
||||
@@ -118,7 +116,7 @@ public class TerminalWidget extends AbstractWidget {
|
||||
}
|
||||
}
|
||||
|
||||
if (key >= 0 && terminateTimer < 0 && rebootTimer < 0 && shutdownTimer < 0) {
|
||||
if (key >= 0 && terminateTimer < KEY_SUPPRESS_DELAY && rebootTimer < KEY_SUPPRESS_DELAY && shutdownTimer < KEY_SUPPRESS_DELAY) {
|
||||
// Queue the "key" event and add to the down set
|
||||
var repeat = keysDown.get(key);
|
||||
keysDown.set(key);
|
||||
|
@@ -15,7 +15,6 @@ import dan200.computercraft.client.render.TurtleBlockEntityRenderer;
|
||||
import dan200.computercraft.client.turtle.TurtleUpgradeModellers;
|
||||
import dan200.computercraft.shared.turtle.items.TurtleItem;
|
||||
import dan200.computercraft.shared.util.Holiday;
|
||||
import dan200.computercraft.shared.util.HolidayUtil;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.resources.model.BakedModel;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
@@ -71,13 +70,16 @@ public final class TurtleModelParts {
|
||||
}
|
||||
|
||||
public Combination getCombination(ItemStack stack) {
|
||||
var turtle = (TurtleItem) stack.getItem();
|
||||
var christmas = Holiday.getCurrent() == Holiday.CHRISTMAS;
|
||||
|
||||
if (!(stack.getItem() instanceof TurtleItem turtle)) {
|
||||
return new Combination(false, null, null, null, christmas, false);
|
||||
}
|
||||
|
||||
var colour = turtle.getColour(stack);
|
||||
var leftUpgrade = turtle.getUpgrade(stack, TurtleSide.LEFT);
|
||||
var rightUpgrade = turtle.getUpgrade(stack, TurtleSide.RIGHT);
|
||||
var overlay = turtle.getOverlay(stack);
|
||||
var christmas = HolidayUtil.getCurrentHoliday() == Holiday.CHRISTMAS;
|
||||
var label = turtle.getLabel(stack);
|
||||
var flip = label != null && (label.equals("Dinnerbone") || label.equals("Grumm"));
|
||||
|
||||
|
@@ -17,7 +17,6 @@ import dan200.computercraft.shared.computer.core.ComputerFamily;
|
||||
import dan200.computercraft.shared.turtle.blocks.TurtleBlockEntity;
|
||||
import dan200.computercraft.shared.util.DirectionUtil;
|
||||
import dan200.computercraft.shared.util.Holiday;
|
||||
import dan200.computercraft.shared.util.HolidayUtil;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
@@ -112,7 +111,7 @@ public class TurtleBlockEntityRenderer implements BlockEntityRenderer<TurtleBloc
|
||||
renderModel(transform, buffer, lightmapCoord, overlayLight, getTurtleModel(family, colour != -1), colour == -1 ? null : new int[]{ colour });
|
||||
|
||||
// Render the overlay
|
||||
var overlayModel = getTurtleOverlayModel(overlay, HolidayUtil.getCurrentHoliday() == Holiday.CHRISTMAS);
|
||||
var overlayModel = getTurtleOverlayModel(overlay, Holiday.getCurrent() == Holiday.CHRISTMAS);
|
||||
if (overlayModel != null) {
|
||||
renderModel(transform, buffer, lightmapCoord, overlayLight, overlayModel, null);
|
||||
}
|
||||
|
@@ -65,6 +65,7 @@ class RecipeProvider extends net.minecraft.data.recipes.RecipeProvider {
|
||||
addSpecial(add, ModRegistry.RecipeSerializers.PRINTOUT.get());
|
||||
addSpecial(add, ModRegistry.RecipeSerializers.DISK.get());
|
||||
addSpecial(add, ModRegistry.RecipeSerializers.DYEABLE_ITEM.get());
|
||||
addSpecial(add, ModRegistry.RecipeSerializers.DYEABLE_ITEM_CLEAR.get());
|
||||
addSpecial(add, ModRegistry.RecipeSerializers.TURTLE_UPGRADE.get());
|
||||
addSpecial(add, ModRegistry.RecipeSerializers.POCKET_COMPUTER_UPGRADE.get());
|
||||
}
|
||||
|
@@ -15,6 +15,7 @@ import net.minecraft.tags.ItemTags;
|
||||
import net.minecraft.tags.TagBuilder;
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
|
||||
@@ -85,6 +86,10 @@ class TagProvider {
|
||||
ModRegistry.Items.WIRELESS_MODEM_ADVANCED.get(), ModRegistry.Items.POCKET_COMPUTER_ADVANCED.get(),
|
||||
ModRegistry.Items.MONITOR_ADVANCED.get()
|
||||
);
|
||||
|
||||
tags.tag(ComputerCraftTags.Items.TURTLE_CAN_PLACE)
|
||||
.add(Items.GLASS_BOTTLE)
|
||||
.addTag(ItemTags.BOATS);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -114,8 +114,9 @@ public class UpgradeManager<R extends UpgradeSerialiser<? extends T>, T extends
|
||||
|
||||
private void loadUpgrade(Map<String, UpgradeWrapper<R, T>> current, ResourceLocation id, JsonElement json) {
|
||||
var root = GsonHelper.convertToJsonObject(json, "top element");
|
||||
var serialiserId = new ResourceLocation(GsonHelper.getAsString(root, "type"));
|
||||
if (!PlatformHelper.get().shouldLoadResource(root)) return;
|
||||
|
||||
var serialiserId = new ResourceLocation(GsonHelper.getAsString(root, "type"));
|
||||
var serialiser = PlatformHelper.get().tryGetRegistryObject(registry, serialiserId);
|
||||
if (serialiser == null) throw new JsonSyntaxException("Unknown upgrade type '" + serialiserId + "'");
|
||||
|
||||
|
@@ -19,6 +19,7 @@ import dan200.computercraft.shared.command.arguments.ComputerArgumentType;
|
||||
import dan200.computercraft.shared.command.arguments.ComputersArgumentType;
|
||||
import dan200.computercraft.shared.command.arguments.RepeatArgumentType;
|
||||
import dan200.computercraft.shared.command.arguments.TrackingFieldArgumentType;
|
||||
import dan200.computercraft.shared.common.ClearColourRecipe;
|
||||
import dan200.computercraft.shared.common.ColourableRecipe;
|
||||
import dan200.computercraft.shared.common.DefaultBundledRedstoneProvider;
|
||||
import dan200.computercraft.shared.common.HeldItemMenu;
|
||||
@@ -351,6 +352,7 @@ public final class ModRegistry {
|
||||
}
|
||||
|
||||
public static final RegistryEntry<SimpleCraftingRecipeSerializer<ColourableRecipe>> DYEABLE_ITEM = simple("colour", ColourableRecipe::new);
|
||||
public static final RegistryEntry<SimpleCraftingRecipeSerializer<ClearColourRecipe>> DYEABLE_ITEM_CLEAR = simple("clear_colour", ClearColourRecipe::new);
|
||||
public static final RegistryEntry<TurtleRecipe.Serializer> TURTLE = REGISTRY.register("turtle", TurtleRecipe.Serializer::new);
|
||||
public static final RegistryEntry<SimpleCraftingRecipeSerializer<TurtleUpgradeRecipe>> TURTLE_UPGRADE = simple("turtle_upgrade", TurtleUpgradeRecipe::new);
|
||||
public static final RegistryEntry<SimpleCraftingRecipeSerializer<PocketComputerUpgradeRecipe>> POCKET_COMPUTER_UPGRADE = simple("pocket_computer_upgrade", PocketComputerUpgradeRecipe::new);
|
||||
|
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2022. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
*/
|
||||
package dan200.computercraft.shared.common;
|
||||
|
||||
import dan200.computercraft.shared.ModRegistry;
|
||||
import net.minecraft.core.NonNullList;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.inventory.CraftingContainer;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.item.crafting.CraftingBookCategory;
|
||||
import net.minecraft.world.item.crafting.CustomRecipe;
|
||||
import net.minecraft.world.item.crafting.RecipeSerializer;
|
||||
import net.minecraft.world.level.Level;
|
||||
|
||||
/**
|
||||
* Craft a wet sponge with a {@linkplain IColouredItem dyable item} to remove its dye.
|
||||
*/
|
||||
public final class ClearColourRecipe extends CustomRecipe {
|
||||
public ClearColourRecipe(ResourceLocation id, CraftingBookCategory category) {
|
||||
super(id, category);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(CraftingContainer inv, Level world) {
|
||||
var hasColourable = false;
|
||||
var hasSponge = false;
|
||||
for (var i = 0; i < inv.getContainerSize(); i++) {
|
||||
var stack = inv.getItem(i);
|
||||
if (stack.isEmpty()) continue;
|
||||
|
||||
if (stack.getItem() instanceof IColouredItem colourable) {
|
||||
if (hasColourable) return false;
|
||||
if (colourable.getColour(stack) == -1) return false;
|
||||
hasColourable = true;
|
||||
} else if (stack.getItem() == Items.WET_SPONGE) {
|
||||
if (hasSponge) return false;
|
||||
hasSponge = true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return hasColourable && hasSponge;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack assemble(CraftingContainer inv) {
|
||||
var colourable = ItemStack.EMPTY;
|
||||
|
||||
for (var i = 0; i < inv.getContainerSize(); i++) {
|
||||
var stack = inv.getItem(i);
|
||||
if (stack.getItem() instanceof IColouredItem) colourable = stack;
|
||||
}
|
||||
|
||||
if (colourable.isEmpty()) return ItemStack.EMPTY;
|
||||
|
||||
var stack = ((IColouredItem) colourable.getItem()).withColour(colourable, -1);
|
||||
stack.setCount(1);
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NonNullList<ItemStack> getRemainingItems(CraftingContainer container) {
|
||||
var remaining = NonNullList.withSize(container.getContainerSize(), ItemStack.EMPTY);
|
||||
for (var i = 0; i < remaining.size(); i++) {
|
||||
if (container.getItem(i).getItem() == Items.WET_SPONGE) remaining.set(i, new ItemStack(Items.WET_SPONGE));
|
||||
}
|
||||
return remaining;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCraftInDimensions(int x, int y) {
|
||||
return x * y >= 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecipeSerializer<ClearColourRecipe> getSerializer() {
|
||||
return ModRegistry.RecipeSerializers.DYEABLE_ITEM_CLEAR.get();
|
||||
}
|
||||
}
|
@@ -74,7 +74,7 @@ public final class ColourableRecipe extends CustomRecipe {
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecipeSerializer<?> getSerializer() {
|
||||
public RecipeSerializer<ColourableRecipe> getSerializer() {
|
||||
return ModRegistry.RecipeSerializers.DYEABLE_ITEM.get();
|
||||
}
|
||||
}
|
||||
|
@@ -18,7 +18,7 @@ import dan200.computercraft.core.lua.ILuaMachine;
|
||||
import dan200.computercraft.impl.AbstractComputerCraftAPI;
|
||||
import dan200.computercraft.shared.CommonHooks;
|
||||
import dan200.computercraft.shared.computer.metrics.GlobalMetrics;
|
||||
import dan200.computercraft.shared.config.Config;
|
||||
import dan200.computercraft.shared.config.ConfigSpec;
|
||||
import dan200.computercraft.shared.peripheral.modem.wireless.WirelessNetwork;
|
||||
import dan200.computercraft.shared.util.IDAssigner;
|
||||
import net.minecraft.SharedConstants;
|
||||
@@ -69,7 +69,7 @@ public final class ServerContext {
|
||||
mainThread = new MainThread();
|
||||
context = new ComputerContext(
|
||||
new Environment(server),
|
||||
new ComputerThread(Config.computerThreads),
|
||||
new ComputerThread(ConfigSpec.computerThreads.get()),
|
||||
mainThread, luaMachine
|
||||
);
|
||||
idAssigner = new IDAssigner(storageDir.resolve("ids.json"));
|
||||
|
@@ -17,8 +17,6 @@ public final class Config {
|
||||
public static int floppySpaceLimit = 125 * 1000;
|
||||
public static boolean commandRequireCreative = true;
|
||||
|
||||
public static int computerThreads = 1;
|
||||
|
||||
public static boolean enableCommandBlock = false;
|
||||
public static int modemRange = 64;
|
||||
public static int modemHighAltitudeRange = 384;
|
||||
|
@@ -142,7 +142,7 @@ public final class ConfigSpec {
|
||||
computers can run at once, but may induce lag. Please note that some mods may
|
||||
not work with a thread count higher than 1. Use with caution.""")
|
||||
.worldRestart()
|
||||
.defineInRange("computer_threads", Config.computerThreads, 1, Integer.MAX_VALUE);
|
||||
.defineInRange("computer_threads", 1, 1, Integer.MAX_VALUE);
|
||||
|
||||
maxMainGlobalTime = builder
|
||||
.comment("""
|
||||
@@ -342,11 +342,9 @@ public final class ConfigSpec {
|
||||
CoreConfig.maximumFilesOpen = maximumFilesOpen.get();
|
||||
CoreConfig.disableLua51Features = disableLua51Features.get();
|
||||
CoreConfig.defaultComputerSettings = defaultComputerSettings.get();
|
||||
Config.computerThreads = computerThreads.get();
|
||||
Config.commandRequireCreative = commandRequireCreative.get();
|
||||
|
||||
// Execution
|
||||
Config.computerThreads = computerThreads.get();
|
||||
CoreConfig.maxMainGlobalTime = TimeUnit.MILLISECONDS.toNanos(maxMainGlobalTime.get());
|
||||
CoreConfig.maxMainComputerTime = TimeUnit.MILLISECONDS.toNanos(maxMainComputerTime.get());
|
||||
|
||||
|
@@ -25,14 +25,9 @@ import java.util.*;
|
||||
* Data providers for items.
|
||||
*/
|
||||
public class ItemDetails {
|
||||
public static <T extends Map<? super String, Object>> T fillBasicSafe(T data, ItemStack stack) {
|
||||
public static void fillBasic(Map<? super String, Object> data, ItemStack stack) {
|
||||
data.put("name", DetailHelpers.getId(RegistryWrappers.ITEMS, stack.getItem()));
|
||||
data.put("count", stack.getCount());
|
||||
return data;
|
||||
}
|
||||
|
||||
public static void fillBasic(Map<? super String, Object> data, ItemStack stack) {
|
||||
fillBasicSafe(data, stack);
|
||||
var hash = NBTUtil.getNBTHash(stack.getTag());
|
||||
if (hash != null) data.put("nbt", hash);
|
||||
}
|
||||
|
@@ -82,10 +82,10 @@ public class UpgradesLoadedMessage implements NetworkMessage<ClientNetworkContex
|
||||
|
||||
var serialiser = entry.getValue().serialiser();
|
||||
@SuppressWarnings("unchecked")
|
||||
var unwrapedSerialiser = (UpgradeSerialiser<T>) serialiser;
|
||||
var unwrappedSerialiser = (UpgradeSerialiser<T>) serialiser;
|
||||
|
||||
buf.writeResourceLocation(Objects.requireNonNull(registry.getKey(serialiser), "Serialiser is not registered!"));
|
||||
unwrapedSerialiser.toNetwork(buf, entry.getValue().upgrade());
|
||||
unwrappedSerialiser.toNetwork(buf, entry.getValue().upgrade());
|
||||
|
||||
buf.writeUtf(entry.getValue().modId());
|
||||
}
|
||||
|
@@ -6,6 +6,7 @@
|
||||
package dan200.computercraft.shared.peripheral.diskdrive;
|
||||
|
||||
import com.google.errorprone.annotations.concurrent.GuardedBy;
|
||||
import dan200.computercraft.api.filesystem.Mount;
|
||||
import dan200.computercraft.api.filesystem.WritableMount;
|
||||
import dan200.computercraft.api.peripheral.IComputerAccess;
|
||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
@@ -47,11 +48,14 @@ public final class DiskDriveBlockEntity extends AbstractContainerBlockEntity {
|
||||
private final NonNullList<ItemStack> inventory = NonNullList.withSize(1, ItemStack.EMPTY);
|
||||
|
||||
private MediaStack media = MediaStack.EMPTY;
|
||||
private @Nullable Mount mount;
|
||||
|
||||
private boolean recordPlaying = false;
|
||||
// In order to avoid main-thread calls in the peripheral, we set flags to mark which operation should be performed,
|
||||
// then read them when ticking.
|
||||
private final AtomicReference<RecordCommand> recordQueued = new AtomicReference<>(null);
|
||||
private final AtomicBoolean ejectQueued = new AtomicBoolean(false);
|
||||
private final AtomicBoolean mountQueued = new AtomicBoolean(false);
|
||||
|
||||
public DiskDriveBlockEntity(BlockEntityType<DiskDriveBlockEntity> type, BlockPos pos, BlockState state) {
|
||||
super(type, pos, state);
|
||||
@@ -109,6 +113,12 @@ public final class DiskDriveBlockEntity extends AbstractContainerBlockEntity {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (mountQueued.get()) {
|
||||
synchronized (this) {
|
||||
mountAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -124,9 +134,9 @@ public final class DiskDriveBlockEntity extends AbstractContainerBlockEntity {
|
||||
|
||||
private void updateItem() {
|
||||
var newDisk = getDiskStack();
|
||||
if (ItemStack.isSame(newDisk, media.stack)) return;
|
||||
if (ItemStack.isSameItemSameTags(newDisk, media.stack)) return;
|
||||
|
||||
var media = new MediaStack(newDisk.copy());
|
||||
var media = MediaStack.of(newDisk);
|
||||
|
||||
if (newDisk.isEmpty()) {
|
||||
updateBlockState(DiskDriveState.EMPTY);
|
||||
@@ -146,12 +156,10 @@ public final class DiskDriveBlockEntity extends AbstractContainerBlockEntity {
|
||||
recordPlaying = false;
|
||||
}
|
||||
|
||||
mount = null;
|
||||
this.media = media;
|
||||
|
||||
// Mount new disk
|
||||
if (!this.media.stack.isEmpty()) {
|
||||
for (var computer : computers.entrySet()) mountDisk(computer.getKey(), computer.getValue(), this.media);
|
||||
}
|
||||
mountAll();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,11 +171,30 @@ public final class DiskDriveBlockEntity extends AbstractContainerBlockEntity {
|
||||
return media;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the current disk stack, mounting/unmounting if needed.
|
||||
*
|
||||
* @param stack The new disk stack.
|
||||
*/
|
||||
void setDiskStack(ItemStack stack) {
|
||||
setItem(0, stack);
|
||||
setChanged();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the current disk stack, assuming the underlying item does not change. Unlike
|
||||
* {@link #setDiskStack(ItemStack)} this will not change any mounts.
|
||||
*
|
||||
* @param stack The new disk stack.
|
||||
*/
|
||||
void updateDiskStack(ItemStack stack) {
|
||||
setItem(0, stack);
|
||||
if (!ItemStack.isSameItemSameTags(stack, media.stack)) {
|
||||
media = MediaStack.of(stack);
|
||||
super.setChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
String getDiskMountPath(IComputerAccess computer) {
|
||||
synchronized (this) {
|
||||
@@ -176,15 +203,21 @@ public final class DiskDriveBlockEntity extends AbstractContainerBlockEntity {
|
||||
}
|
||||
}
|
||||
|
||||
void mount(IComputerAccess computer) {
|
||||
/**
|
||||
* Attach a computer to this disk drive. This sets up the {@link MountInfo} map and flags us to mount next tick. We
|
||||
* don't mount here, as that might require mutating the current stack.
|
||||
*
|
||||
* @param computer The computer to attach.
|
||||
*/
|
||||
void attach(IComputerAccess computer) {
|
||||
synchronized (this) {
|
||||
var info = new MountInfo();
|
||||
computers.put(computer, info);
|
||||
mountDisk(computer, info, media);
|
||||
mountQueued.set(true);
|
||||
}
|
||||
}
|
||||
|
||||
void unmount(IComputerAccess computer) {
|
||||
void detach(IComputerAccess computer) {
|
||||
synchronized (this) {
|
||||
unmountDisk(computer, computers.remove(computer));
|
||||
}
|
||||
@@ -202,10 +235,35 @@ public final class DiskDriveBlockEntity extends AbstractContainerBlockEntity {
|
||||
ejectQueued.set(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add our mount to all computers.
|
||||
*/
|
||||
@GuardedBy("this")
|
||||
private void mountDisk(IComputerAccess computer, MountInfo info, MediaStack disk) {
|
||||
var mount = disk.getMount((ServerLevel) getLevel());
|
||||
if (mount != null) {
|
||||
private void mountAll() {
|
||||
doMountAll();
|
||||
mountQueued.set(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* The worker for {@link #mountAll()}. This is responsible for creating the mount and placing it on all computers.
|
||||
*/
|
||||
@GuardedBy("this")
|
||||
private void doMountAll() {
|
||||
if (computers.isEmpty() || media.media == null) return;
|
||||
|
||||
if (mount == null) {
|
||||
var stack = getDiskStack();
|
||||
mount = media.media.createDataMount(stack, (ServerLevel) level);
|
||||
setDiskStack(stack);
|
||||
}
|
||||
|
||||
if (mount == null) return;
|
||||
|
||||
for (var entry : computers.entrySet()) {
|
||||
var computer = entry.getKey();
|
||||
var info = entry.getValue();
|
||||
if (info.mountPath != null) continue;
|
||||
|
||||
if (mount instanceof WritableMount writable) {
|
||||
// Try mounting at the lowest numbered "disk" name we can
|
||||
var n = 1;
|
||||
@@ -221,11 +279,9 @@ public final class DiskDriveBlockEntity extends AbstractContainerBlockEntity {
|
||||
n++;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
info.mountPath = null;
|
||||
}
|
||||
|
||||
computer.queueEvent("disk", computer.getAttachmentName());
|
||||
computer.queueEvent("disk", computer.getAttachmentName());
|
||||
}
|
||||
}
|
||||
|
||||
private static void unmountDisk(IComputerAccess computer, MountInfo info) {
|
||||
@@ -251,7 +307,7 @@ public final class DiskDriveBlockEntity extends AbstractContainerBlockEntity {
|
||||
if (stack.isEmpty()) return;
|
||||
setDiskStack(ItemStack.EMPTY);
|
||||
|
||||
WorldUtil.dropItemStack(stack, getLevel(), getBlockPos(), getDirection());
|
||||
WorldUtil.dropItemStack(getLevel(), getBlockPos(), getDirection(), stack);
|
||||
getLevel().levelEvent(LevelEvent.SOUND_DISPENSER_DISPENSE, getBlockPos(), 0);
|
||||
}
|
||||
|
||||
|
@@ -84,11 +84,12 @@ public class DiskDrivePeripheral implements IPeripheral {
|
||||
var media = diskDrive.getMedia();
|
||||
if (media.media == null) return;
|
||||
|
||||
var stack = media.stack.copy();
|
||||
// We're on the main thread so the stack and media should be in sync.
|
||||
var stack = diskDrive.getDiskStack();
|
||||
if (!media.media.setLabel(stack, label.map(StringUtil::normaliseLabel).orElse(null))) {
|
||||
throw new LuaException("Disk label cannot be changed");
|
||||
}
|
||||
diskDrive.setDiskStack(stack);
|
||||
diskDrive.updateDiskStack(stack);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -178,12 +179,12 @@ public class DiskDrivePeripheral implements IPeripheral {
|
||||
|
||||
@Override
|
||||
public void attach(IComputerAccess computer) {
|
||||
diskDrive.mount(computer);
|
||||
diskDrive.attach(computer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detach(IComputerAccess computer) {
|
||||
diskDrive.unmount(computer);
|
||||
diskDrive.detach(computer);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -5,10 +5,8 @@
|
||||
*/
|
||||
package dan200.computercraft.shared.peripheral.diskdrive;
|
||||
|
||||
import dan200.computercraft.api.filesystem.Mount;
|
||||
import dan200.computercraft.api.media.IMedia;
|
||||
import dan200.computercraft.impl.MediaProviders;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
@@ -17,18 +15,22 @@ import javax.annotation.Nullable;
|
||||
/**
|
||||
* An immutable snapshot of the current disk. This allows us to read the stack in a thread-safe manner.
|
||||
*/
|
||||
class MediaStack {
|
||||
static final MediaStack EMPTY = new MediaStack(ItemStack.EMPTY);
|
||||
final class MediaStack {
|
||||
static final MediaStack EMPTY = new MediaStack(ItemStack.EMPTY, null);
|
||||
|
||||
final ItemStack stack;
|
||||
final @Nullable IMedia media;
|
||||
|
||||
@Nullable
|
||||
private Mount mount;
|
||||
|
||||
MediaStack(ItemStack stack) {
|
||||
private MediaStack(ItemStack stack, @Nullable IMedia media) {
|
||||
this.stack = stack;
|
||||
media = MediaProviders.get(stack);
|
||||
this.media = media;
|
||||
}
|
||||
|
||||
public static MediaStack of(ItemStack stack) {
|
||||
if (stack.isEmpty()) return EMPTY;
|
||||
|
||||
var freshStack = stack.copy();
|
||||
return new MediaStack(freshStack, MediaProviders.get(freshStack));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -40,12 +42,4 @@ class MediaStack {
|
||||
String getAudioTitle() {
|
||||
return media != null ? media.getAudioTitle(stack) : null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Mount getMount(ServerLevel level) {
|
||||
if (media == null) return null;
|
||||
|
||||
if (mount == null) mount = media.createDataMount(stack, level);
|
||||
return mount;
|
||||
}
|
||||
}
|
||||
|
@@ -52,6 +52,15 @@ import java.util.Set;
|
||||
* <li><strong>Wired modems:</strong> These send messages to other any other wired modems connected to the same network
|
||||
* (using <em>Networking Cable</em>). They also can be used to attach additional peripherals to a computer.</li></ul>
|
||||
*
|
||||
* ## Recipes
|
||||
* <div class="recipe-container">
|
||||
* <mc-recipe recipe="computercraft:wireless_modem_normal"></mc-recipe>
|
||||
* <mc-recipe recipe="computercraft:wireless_modem_advanced"></mc-recipe>
|
||||
* <mc-recipe recipe="computercraft:wired_modem"></mc-recipe>
|
||||
* <mc-recipe recipe="computercraft:cable"></mc-recipe>
|
||||
* <mc-recipe recipe="computercraft:wired_modem_full_from"></mc-recipe>
|
||||
* </div>
|
||||
*
|
||||
* @cc.module modem
|
||||
* @cc.see modem_message Queued when a modem receives a message on an {@link #open(int) open channel}.
|
||||
* @cc.see rednet A networking API built on top of the modem peripheral.
|
||||
@@ -74,14 +83,6 @@ import java.util.Set;
|
||||
* print("Received a reply: " .. tostring(message))
|
||||
* }</pre>
|
||||
* <p>
|
||||
* ## Recipes
|
||||
* <div class="recipe-container">
|
||||
* <mc-recipe recipe="computercraft:wireless_modem_normal"></mc-recipe>
|
||||
* <mc-recipe recipe="computercraft:wireless_modem_advanced"></mc-recipe>
|
||||
* <mc-recipe recipe="computercraft:wired_modem"></mc-recipe>
|
||||
* <mc-recipe recipe="computercraft:cable"></mc-recipe>
|
||||
* <mc-recipe recipe="computercraft:wired_modem_full_from"></mc-recipe>
|
||||
* </div>
|
||||
*/
|
||||
public abstract class ModemPeripheral implements IPeripheral, PacketSender, PacketReceiver {
|
||||
private @Nullable PacketNetwork network;
|
||||
|
@@ -8,7 +8,6 @@ package dan200.computercraft.shared.peripheral.speaker;
|
||||
import dan200.computercraft.api.lua.LuaException;
|
||||
import dan200.computercraft.api.lua.LuaTable;
|
||||
import dan200.computercraft.shared.util.PauseAwareTimer;
|
||||
import net.minecraft.util.Mth;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.nio.ByteBuffer;
|
||||
@@ -16,6 +15,7 @@ import java.util.Optional;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static dan200.computercraft.shared.peripheral.speaker.SpeakerPeripheral.SAMPLE_RATE;
|
||||
import static dan200.computercraft.shared.peripheral.speaker.SpeakerPeripheral.clampVolume;
|
||||
|
||||
/**
|
||||
* Internal state of the DFPWM decoder and the state of playback.
|
||||
@@ -82,7 +82,7 @@ class DfpwmState {
|
||||
buffer.flip();
|
||||
|
||||
pendingAudio = buffer;
|
||||
pendingVolume = Mth.clamp(volume.orElse((double) pendingVolume).floatValue(), 0.0f, 3.0f);
|
||||
pendingVolume = (float) clampVolume(volume.orElse((double) pendingVolume));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@@ -27,6 +27,7 @@ import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.level.block.state.properties.NoteBlockInstrument;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@@ -203,7 +204,7 @@ public abstract class SpeakerPeripheral implements IPeripheral {
|
||||
*/
|
||||
@LuaFunction
|
||||
public final boolean playNote(ILuaContext context, String instrumentA, Optional<Double> volumeA, Optional<Double> pitchA) throws LuaException {
|
||||
var volume = (float) checkFinite(1, volumeA.orElse(1.0));
|
||||
var volume = (float) clampVolume(checkFinite(1, volumeA.orElse(1.0)));
|
||||
var pitch = (float) checkFinite(2, pitchA.orElse(1.0));
|
||||
|
||||
NoteBlockInstrument instrument = null;
|
||||
@@ -241,14 +242,14 @@ public abstract class SpeakerPeripheral implements IPeripheral {
|
||||
* @throws LuaException If the sound name was invalid.
|
||||
* @cc.usage Play a creeper hiss with the speaker.
|
||||
*
|
||||
* <pre>{@code
|
||||
* <pre data-peripheral="speaker">{@code
|
||||
* local speaker = peripheral.find("speaker")
|
||||
* speaker.playSound("entity.creeper.primed")
|
||||
* }</pre>
|
||||
*/
|
||||
@LuaFunction
|
||||
public final boolean playSound(ILuaContext context, String name, Optional<Double> volumeA, Optional<Double> pitchA) throws LuaException {
|
||||
var volume = (float) checkFinite(1, volumeA.orElse(1.0));
|
||||
var volume = (float) clampVolume(checkFinite(1, volumeA.orElse(1.0)));
|
||||
var pitch = (float) checkFinite(2, pitchA.orElse(1.0));
|
||||
|
||||
ResourceLocation identifier;
|
||||
@@ -293,7 +294,7 @@ public abstract class SpeakerPeripheral implements IPeripheral {
|
||||
* @cc.since 1.100
|
||||
* @cc.usage Read an audio file, decode it using @{cc.audio.dfpwm}, and play it using the speaker.
|
||||
*
|
||||
* <pre>{@code
|
||||
* <pre data-peripheral="speaker">{@code
|
||||
* local dfpwm = require("cc.audio.dfpwm")
|
||||
* local speaker = peripheral.find("speaker")
|
||||
*
|
||||
@@ -361,6 +362,10 @@ public abstract class SpeakerPeripheral implements IPeripheral {
|
||||
}
|
||||
}
|
||||
|
||||
static double clampVolume(double volume) {
|
||||
return Mth.clamp(volume, 0, 3);
|
||||
}
|
||||
|
||||
private record PendingSound<T>(T sound, float volume, float pitch) {
|
||||
}
|
||||
}
|
||||
|
@@ -5,6 +5,7 @@
|
||||
*/
|
||||
package dan200.computercraft.shared.platform;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.brigadier.arguments.ArgumentType;
|
||||
import dan200.computercraft.api.network.wired.WiredElement;
|
||||
@@ -96,6 +97,16 @@ public interface PlatformHelper extends dan200.computercraft.impl.PlatformHelper
|
||||
@Nullable
|
||||
<T> T tryGetRegistryObject(ResourceKey<Registry<T>> registry, ResourceLocation id);
|
||||
|
||||
/**
|
||||
* Determine if this resource should be loaded, based on platform-specific loot conditions.
|
||||
* <p>
|
||||
* This should only be called from the {@code apply} stage of a reload listener.
|
||||
*
|
||||
* @param object The root JSON object of this resource.
|
||||
* @return If this resource should be loaded.
|
||||
*/
|
||||
boolean shouldLoadResource(JsonObject object);
|
||||
|
||||
/**
|
||||
* Create a new block entity type which serves a particular block.
|
||||
*
|
||||
|
@@ -69,7 +69,7 @@ public class PocketAPI implements ILuaAPI {
|
||||
if (newUpgrade == null) return new Object[]{ false, "Cannot find a valid upgrade" };
|
||||
|
||||
// Remove the current upgrade
|
||||
if (previousUpgrade != null) storeItem(player, previousUpgrade.getCraftingItem());
|
||||
if (previousUpgrade != null) storeItem(player, previousUpgrade.getCraftingItem().copy());
|
||||
|
||||
// Set the new upgrade
|
||||
computer.setUpgrade(newUpgrade);
|
||||
@@ -88,14 +88,13 @@ public class PocketAPI implements ILuaAPI {
|
||||
public final Object[] unequipBack() {
|
||||
var entity = computer.getEntity();
|
||||
if (!(entity instanceof Player player)) return new Object[]{ false, "Cannot find player" };
|
||||
var inventory = player.getInventory();
|
||||
var previousUpgrade = computer.getUpgrade();
|
||||
|
||||
if (previousUpgrade == null) return new Object[]{ false, "Nothing to unequip" };
|
||||
|
||||
computer.setUpgrade(null);
|
||||
|
||||
storeItem(player, previousUpgrade.getCraftingItem());
|
||||
storeItem(player, previousUpgrade.getCraftingItem().copy());
|
||||
|
||||
return new Object[]{ true };
|
||||
}
|
||||
|
@@ -46,7 +46,7 @@ public class TurtleUtil {
|
||||
public static void storeItemOrDrop(ITurtleAccess turtle, ItemStack stack) {
|
||||
if (stack.isEmpty()) return;
|
||||
if (turtle.isRemoved()) {
|
||||
WorldUtil.dropItemStack(stack, turtle.getLevel(), turtle.getPosition(), null);
|
||||
WorldUtil.dropItemStack(turtle.getLevel(), turtle.getPosition(), null, stack);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ public class TurtleUtil {
|
||||
var remainder = InventoryUtil.storeItemsFromOffset(turtle.getInventory(), stack, turtle.getSelectedSlot());
|
||||
if (remainder.isEmpty()) return;
|
||||
|
||||
WorldUtil.dropItemStack(remainder, turtle.getLevel(), turtle.getPosition(), turtle.getDirection().getOpposite());
|
||||
WorldUtil.dropItemStack(turtle.getLevel(), turtle.getPosition(), turtle.getDirection().getOpposite(), remainder);
|
||||
}
|
||||
|
||||
public static Function<ItemStack, ItemStack> dropConsumer(ITurtleAccess turtle) {
|
||||
|
@@ -7,16 +7,13 @@ package dan200.computercraft.shared.turtle.apis;
|
||||
|
||||
import dan200.computercraft.api.detail.VanillaDetailRegistries;
|
||||
import dan200.computercraft.api.lua.*;
|
||||
import dan200.computercraft.api.turtle.ITurtleAccess;
|
||||
import dan200.computercraft.api.turtle.TurtleCommand;
|
||||
import dan200.computercraft.api.turtle.TurtleCommandResult;
|
||||
import dan200.computercraft.api.turtle.TurtleSide;
|
||||
import dan200.computercraft.core.apis.IAPIEnvironment;
|
||||
import dan200.computercraft.core.metrics.Metrics;
|
||||
import dan200.computercraft.shared.details.ItemDetails;
|
||||
import dan200.computercraft.shared.turtle.core.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
@@ -70,9 +67,9 @@ import java.util.Optional;
|
||||
*/
|
||||
public class TurtleAPI implements ILuaAPI {
|
||||
private final IAPIEnvironment environment;
|
||||
private final ITurtleAccess turtle;
|
||||
private final TurtleAccessInternal turtle;
|
||||
|
||||
public TurtleAPI(IAPIEnvironment environment, ITurtleAccess turtle) {
|
||||
public TurtleAPI(IAPIEnvironment environment, TurtleAccessInternal turtle) {
|
||||
this.environment = environment;
|
||||
this.turtle = turtle;
|
||||
}
|
||||
@@ -136,7 +133,7 @@ public class TurtleAPI implements ILuaAPI {
|
||||
}
|
||||
|
||||
/**
|
||||
* Rotate the turtle 90 degress to the left.
|
||||
* Rotate the turtle 90 degrees to the left.
|
||||
*
|
||||
* @return The turtle command result.
|
||||
* @cc.treturn boolean Whether the turtle could successfully turn.
|
||||
@@ -148,7 +145,7 @@ public class TurtleAPI implements ILuaAPI {
|
||||
}
|
||||
|
||||
/**
|
||||
* Rotate the turtle 90 degress to the right.
|
||||
* Rotate the turtle 90 degrees to the right.
|
||||
*
|
||||
* @return The turtle command result.
|
||||
* @cc.treturn boolean Whether the turtle could successfully turn.
|
||||
@@ -555,7 +552,7 @@ public class TurtleAPI implements ILuaAPI {
|
||||
* @throws LuaException If the refuel count is out of range.
|
||||
* @cc.treturn [1] true If the turtle was refuelled.
|
||||
* @cc.treturn [2] false If the turtle was not refuelled.
|
||||
* @cc.treturn [2] string The reason the turtle was not refuelled (
|
||||
* @cc.treturn [2] string The reason the turtle was not refuelled.
|
||||
* @cc.usage Refuel a turtle from the currently selected slot.
|
||||
* <pre>{@code
|
||||
* local level = turtle.getFuelLevel()
|
||||
@@ -652,7 +649,7 @@ public class TurtleAPI implements ILuaAPI {
|
||||
* previous upgrade is removed and placed into the turtle's inventory. If there is no item in the slot, the previous
|
||||
* upgrade is removed, but no new one is equipped.
|
||||
*
|
||||
* @return Whether an item was equiped or not.
|
||||
* @return Whether an item was equipped or not.
|
||||
* @cc.treturn [1] true If the item was equipped.
|
||||
* @cc.treturn [2] false If we could not equip the item.
|
||||
* @cc.treturn [2] string The reason equipping this item failed.
|
||||
@@ -671,7 +668,7 @@ public class TurtleAPI implements ILuaAPI {
|
||||
* previous upgrade is removed and placed into the turtle's inventory. If there is no item in the slot, the previous
|
||||
* upgrade is removed, but no new one is equipped.
|
||||
*
|
||||
* @return Whether an item was equiped or not.
|
||||
* @return Whether an item was equipped or not.
|
||||
* @cc.treturn [1] true If the item was equipped.
|
||||
* @cc.treturn [2] false If we could not equip the item.
|
||||
* @cc.treturn [2] string The reason equipping this item failed.
|
||||
@@ -760,20 +757,15 @@ public class TurtleAPI implements ILuaAPI {
|
||||
@LuaFunction
|
||||
public final MethodResult getItemDetail(ILuaContext context, Optional<Integer> slot, Optional<Boolean> detailed) throws LuaException {
|
||||
int actualSlot = checkSlot(slot).orElse(turtle.getSelectedSlot());
|
||||
return detailed.orElse(false)
|
||||
? context.executeMainThreadTask(() -> getItemDetail(actualSlot, true))
|
||||
: MethodResult.of(getItemDetail(actualSlot, false));
|
||||
}
|
||||
|
||||
private Object[] getItemDetail(int slot, boolean detailed) {
|
||||
var stack = turtle.getInventory().getItem(slot);
|
||||
if (stack.isEmpty()) return new Object[]{ null };
|
||||
|
||||
var table = detailed
|
||||
? VanillaDetailRegistries.ITEM_STACK.getDetails(stack)
|
||||
: ItemDetails.fillBasicSafe(new HashMap<>(), stack);
|
||||
|
||||
return new Object[]{ table };
|
||||
if (detailed.orElse(false)) {
|
||||
return context.executeMainThreadTask(() -> {
|
||||
var stack = turtle.getInventory().getItem(actualSlot);
|
||||
return new Object[]{ stack.isEmpty() ? null : VanillaDetailRegistries.ITEM_STACK.getDetails(stack) };
|
||||
});
|
||||
} else {
|
||||
var stack = turtle.getItemSnapshot(actualSlot);
|
||||
return MethodResult.of(stack.isEmpty() ? null : VanillaDetailRegistries.ITEM_STACK.getBasicDetails(stack));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@@ -29,14 +29,10 @@ import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||
import net.minecraft.world.item.DyeItem;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
@@ -56,7 +52,7 @@ public class TurtleBlockEntity extends AbstractComputerBlockEntity implements Ba
|
||||
}
|
||||
|
||||
private final NonNullList<ItemStack> inventory = NonNullList.withSize(INVENTORY_SIZE, ItemStack.EMPTY);
|
||||
private final NonNullList<ItemStack> previousInventory = NonNullList.withSize(INVENTORY_SIZE, ItemStack.EMPTY);
|
||||
private final NonNullList<ItemStack> inventorySnapshot = NonNullList.withSize(INVENTORY_SIZE, ItemStack.EMPTY);
|
||||
private boolean inventoryChanged = false;
|
||||
private TurtleBrain brain = new TurtleBrain(this);
|
||||
private MoveState moveState = MoveState.NOT_MOVED;
|
||||
@@ -78,7 +74,7 @@ public class TurtleBlockEntity extends AbstractComputerBlockEntity implements Ba
|
||||
getFamily(), Config.turtleTermWidth,
|
||||
Config.turtleTermHeight
|
||||
);
|
||||
computer.addAPI(new TurtleAPI(computer.getAPIEnvironment(), getAccess()));
|
||||
computer.addAPI(new TurtleAPI(computer.getAPIEnvironment(), brain));
|
||||
brain.setupComputer(computer);
|
||||
return computer;
|
||||
}
|
||||
@@ -88,42 +84,6 @@ public class TurtleBlockEntity extends AbstractComputerBlockEntity implements Ba
|
||||
if (!hasMoved()) super.unload();
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractionResult use(Player player, InteractionHand hand) {
|
||||
// Apply dye
|
||||
var currentItem = player.getItemInHand(hand);
|
||||
if (!currentItem.isEmpty()) {
|
||||
if (currentItem.getItem() instanceof DyeItem dyeItem) {
|
||||
// Dye to change turtle colour
|
||||
if (!getLevel().isClientSide) {
|
||||
var dye = dyeItem.getDyeColor();
|
||||
if (brain.getDyeColour() != dye) {
|
||||
brain.setDyeColour(dye);
|
||||
if (!player.isCreative()) {
|
||||
currentItem.shrink(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
return InteractionResult.sidedSuccess(getLevel().isClientSide);
|
||||
} else if (currentItem.getItem() == Items.WATER_BUCKET && brain.getColour() != -1) {
|
||||
// Water to remove turtle colour
|
||||
if (!getLevel().isClientSide) {
|
||||
if (brain.getColour() != -1) {
|
||||
brain.setColour(-1);
|
||||
if (!player.isCreative()) {
|
||||
player.setItemInHand(hand, new ItemStack(Items.BUCKET));
|
||||
player.getInventory().setChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
return InteractionResult.sidedSuccess(getLevel().isClientSide);
|
||||
}
|
||||
}
|
||||
|
||||
// Open GUI or whatever
|
||||
return super.use(player, hand);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canNameWithTag(Player player) {
|
||||
return true;
|
||||
@@ -141,11 +101,7 @@ public class TurtleBlockEntity extends AbstractComputerBlockEntity implements Ba
|
||||
if (inventoryChanged) {
|
||||
var computer = getServerComputer();
|
||||
if (computer != null) computer.queueEvent("turtle_inventory");
|
||||
|
||||
inventoryChanged = false;
|
||||
for (var n = 0; n < getContainerSize(); n++) {
|
||||
previousInventory.set(n, getItem(n).copy());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,13 +134,13 @@ public class TurtleBlockEntity extends AbstractComputerBlockEntity implements Ba
|
||||
// Read inventory
|
||||
var nbttaglist = nbt.getList("Items", Tag.TAG_COMPOUND);
|
||||
inventory.clear();
|
||||
previousInventory.clear();
|
||||
inventorySnapshot.clear();
|
||||
for (var i = 0; i < nbttaglist.size(); i++) {
|
||||
var tag = nbttaglist.getCompound(i);
|
||||
var slot = tag.getByte("Slot") & 0xff;
|
||||
if (slot < getContainerSize()) {
|
||||
inventory.set(slot, ItemStack.of(tag));
|
||||
previousInventory.set(slot, inventory.get(slot).copy());
|
||||
inventorySnapshot.set(slot, inventory.get(slot).copy());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -273,7 +229,7 @@ public class TurtleBlockEntity extends AbstractComputerBlockEntity implements Ba
|
||||
|
||||
void setOwningPlayer(GameProfile player) {
|
||||
brain.setOwningPlayer(player);
|
||||
setChanged();
|
||||
onTileEntityChange();
|
||||
}
|
||||
|
||||
// IInventory
|
||||
@@ -283,16 +239,20 @@ public class TurtleBlockEntity extends AbstractComputerBlockEntity implements Ba
|
||||
return inventory;
|
||||
}
|
||||
|
||||
public ItemStack getItemSnapshot(int slot) {
|
||||
return slot >= 0 && slot < inventorySnapshot.size() ? inventorySnapshot.get(slot) : ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setChanged() {
|
||||
super.setChanged();
|
||||
if (!inventoryChanged) {
|
||||
for (var n = 0; n < getContainerSize(); n++) {
|
||||
if (!ItemStack.matches(getItem(n), previousInventory.get(n))) {
|
||||
inventoryChanged = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (var slot = 0; slot < getContainerSize(); slot++) {
|
||||
var item = getItem(slot);
|
||||
if (ItemStack.matches(item, inventorySnapshot.get(slot))) continue;
|
||||
|
||||
inventoryChanged = true;
|
||||
inventorySnapshot.set(slot, item.copy());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -340,7 +300,7 @@ public class TurtleBlockEntity extends AbstractComputerBlockEntity implements Ba
|
||||
public void transferStateFrom(TurtleBlockEntity copy) {
|
||||
super.transferStateFrom(copy);
|
||||
Collections.copy(inventory, copy.inventory);
|
||||
Collections.copy(previousInventory, copy.previousInventory);
|
||||
Collections.copy(inventorySnapshot, copy.inventorySnapshot);
|
||||
inventoryChanged = copy.inventoryChanged;
|
||||
brain = copy.brain;
|
||||
brain.setOwner(this);
|
||||
|
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2022. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
*/
|
||||
package dan200.computercraft.shared.turtle.core;
|
||||
|
||||
import dan200.computercraft.api.turtle.ITurtleAccess;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
/**
|
||||
* An internal version of {@link ITurtleAccess}.
|
||||
* <p>
|
||||
* This exposes additional functionality we don't want in the public API, but where we don't want access to the full
|
||||
* {@link TurtleBrain} interface.
|
||||
*/
|
||||
public interface TurtleAccessInternal extends ITurtleAccess {
|
||||
/**
|
||||
* Get an immutable snapshot of an item in the inventory. This is a thread-safe version of
|
||||
* {@code getInventory().getItem()}.
|
||||
*
|
||||
* @param slot The slot
|
||||
* @return The current item. This should NOT be modified.
|
||||
* @see net.minecraft.world.Container#getItem(int)
|
||||
*/
|
||||
ItemStack getItemSnapshot(int slot);
|
||||
}
|
@@ -10,7 +10,10 @@ import com.mojang.authlib.GameProfile;
|
||||
import dan200.computercraft.api.lua.ILuaCallback;
|
||||
import dan200.computercraft.api.lua.MethodResult;
|
||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
import dan200.computercraft.api.turtle.*;
|
||||
import dan200.computercraft.api.turtle.ITurtleUpgrade;
|
||||
import dan200.computercraft.api.turtle.TurtleAnimation;
|
||||
import dan200.computercraft.api.turtle.TurtleCommand;
|
||||
import dan200.computercraft.api.turtle.TurtleSide;
|
||||
import dan200.computercraft.core.computer.ComputerSide;
|
||||
import dan200.computercraft.core.util.Colour;
|
||||
import dan200.computercraft.impl.TurtleUpgrades;
|
||||
@@ -21,7 +24,6 @@ import dan200.computercraft.shared.container.InventoryDelegate;
|
||||
import dan200.computercraft.shared.turtle.blocks.TurtleBlockEntity;
|
||||
import dan200.computercraft.shared.util.BlockEntityHelpers;
|
||||
import dan200.computercraft.shared.util.Holiday;
|
||||
import dan200.computercraft.shared.util.HolidayUtil;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.particles.ParticleTypes;
|
||||
@@ -34,6 +36,7 @@ import net.minecraft.world.Container;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.MoverType;
|
||||
import net.minecraft.world.item.DyeColor;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.material.PushReaction;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
@@ -47,7 +50,7 @@ import java.util.function.Predicate;
|
||||
import static dan200.computercraft.shared.common.IColouredItem.NBT_COLOUR;
|
||||
import static dan200.computercraft.shared.util.WaterloggableHelpers.WATERLOGGED;
|
||||
|
||||
public class TurtleBrain implements ITurtleAccess {
|
||||
public class TurtleBrain implements TurtleAccessInternal {
|
||||
public static final String NBT_RIGHT_UPGRADE = "RightUpgrade";
|
||||
public static final String NBT_RIGHT_UPGRADE_DATA = "RightUpgradeNbt";
|
||||
public static final String NBT_LEFT_UPGRADE = "LeftUpgrade";
|
||||
@@ -456,7 +459,7 @@ public class TurtleBrain implements ITurtleAccess {
|
||||
return overlay;
|
||||
}
|
||||
|
||||
public void setOverlay(ResourceLocation overlay) {
|
||||
public void setOverlay(@Nullable ResourceLocation overlay) {
|
||||
if (!Objects.equal(this.overlay, overlay)) {
|
||||
this.overlay = overlay;
|
||||
BlockEntityHelpers.updateBlock(owner);
|
||||
@@ -735,7 +738,7 @@ public class TurtleBrain implements ITurtleAccess {
|
||||
// Advance valentines day easter egg
|
||||
if (world.isClientSide && animation == TurtleAnimation.MOVE_FORWARD && animationProgress == 4) {
|
||||
// Spawn love pfx if valentines day
|
||||
var currentHoliday = HolidayUtil.getCurrentHoliday();
|
||||
var currentHoliday = Holiday.getCurrent();
|
||||
if (currentHoliday == Holiday.VALENTINES) {
|
||||
var position = getVisualPosition(1.0f);
|
||||
if (position != null) {
|
||||
@@ -768,6 +771,11 @@ public class TurtleBrain implements ITurtleAccess {
|
||||
return previous + (next - previous) * f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemSnapshot(int slot) {
|
||||
return owner.getItemSnapshot(slot);
|
||||
}
|
||||
|
||||
private static final class CommandCallback implements ILuaCallback {
|
||||
final MethodResult pull = MethodResult.pullEvent("turtle_response", this);
|
||||
private final int command;
|
||||
|
@@ -58,7 +58,7 @@ public class TurtleDropCommand implements TurtleCommand {
|
||||
turtle.getInventory().setChanged();
|
||||
transferred = stack.getCount();
|
||||
|
||||
WorldUtil.dropItemStack(stack, world, oldPosition, direction);
|
||||
WorldUtil.dropItemStack(world, oldPosition, direction, stack);
|
||||
world.globalLevelEvent(LevelEvent.SOUND_DISPENSER_DISPENSE, newPosition, 0);
|
||||
}
|
||||
}
|
||||
|
@@ -8,7 +8,6 @@ package dan200.computercraft.shared.turtle.core;
|
||||
import dan200.computercraft.api.turtle.*;
|
||||
import dan200.computercraft.impl.TurtleUpgrades;
|
||||
import dan200.computercraft.shared.turtle.TurtleUtil;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
public class TurtleEquipCommand implements TurtleCommand {
|
||||
private final TurtleSide side;
|
||||
@@ -19,32 +18,22 @@ public class TurtleEquipCommand implements TurtleCommand {
|
||||
|
||||
@Override
|
||||
public TurtleCommandResult execute(ITurtleAccess turtle) {
|
||||
// Determine the upgrade to replace
|
||||
var oldUpgrade = turtle.getUpgrade(side);
|
||||
|
||||
// Determine the upgrade to equipLeft
|
||||
ITurtleUpgrade newUpgrade;
|
||||
ItemStack newUpgradeStack;
|
||||
var selectedStack = turtle.getInventory().getItem(turtle.getSelectedSlot());
|
||||
if (!selectedStack.isEmpty()) {
|
||||
newUpgradeStack = selectedStack.copy();
|
||||
newUpgrade = TurtleUpgrades.instance().get(newUpgradeStack);
|
||||
newUpgrade = TurtleUpgrades.instance().get(selectedStack);
|
||||
if (newUpgrade == null) return TurtleCommandResult.failure("Not a valid upgrade");
|
||||
} else {
|
||||
newUpgradeStack = null;
|
||||
newUpgrade = null;
|
||||
}
|
||||
|
||||
// Determine the upgrade to replace
|
||||
ItemStack oldUpgradeStack;
|
||||
var oldUpgrade = turtle.getUpgrade(side);
|
||||
if (oldUpgrade != null) {
|
||||
var craftingItem = oldUpgrade.getCraftingItem();
|
||||
oldUpgradeStack = !craftingItem.isEmpty() ? craftingItem.copy() : null;
|
||||
} else {
|
||||
oldUpgradeStack = null;
|
||||
}
|
||||
|
||||
// Do the swapping:
|
||||
if (newUpgradeStack != null) turtle.getInventory().removeItem(turtle.getSelectedSlot(), 1);
|
||||
if (oldUpgradeStack != null) TurtleUtil.storeItemOrDrop(turtle, oldUpgradeStack);
|
||||
if (newUpgrade != null) turtle.getInventory().removeItem(turtle.getSelectedSlot(), 1);
|
||||
if (oldUpgrade != null) TurtleUtil.storeItemOrDrop(turtle, oldUpgrade.getCraftingItem().copy());
|
||||
turtle.setUpgrade(side, newUpgrade);
|
||||
|
||||
// Animate
|
||||
|
@@ -6,6 +6,7 @@
|
||||
package dan200.computercraft.shared.turtle.core;
|
||||
|
||||
import com.google.common.base.Splitter;
|
||||
import dan200.computercraft.api.ComputerCraftTags;
|
||||
import dan200.computercraft.api.turtle.ITurtleAccess;
|
||||
import dan200.computercraft.api.turtle.TurtleAnimation;
|
||||
import dan200.computercraft.api.turtle.TurtleCommand;
|
||||
@@ -21,9 +22,7 @@ import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.SignItem;
|
||||
import net.minecraft.world.item.*;
|
||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||
import net.minecraft.world.item.context.UseOnContext;
|
||||
import net.minecraft.world.level.Level;
|
||||
@@ -209,7 +208,7 @@ public class TurtlePlaceCommand implements TurtleCommand {
|
||||
|
||||
// We special case some items which we allow to place "normally". Yes, this is very ugly.
|
||||
var item = stack.getItem();
|
||||
if (item.getUseDuration(stack) == 0) {
|
||||
if (item instanceof BucketItem || item instanceof PlaceOnWaterBlockItem || stack.is(ComputerCraftTags.Items.TURTLE_CAN_PLACE)) {
|
||||
return turtlePlayer.player().gameMode.useItem(turtlePlayer.player(), turtlePlayer.player().level, stack, InteractionHand.MAIN_HAND);
|
||||
}
|
||||
|
||||
|
@@ -61,7 +61,7 @@ public final class DropConsumer {
|
||||
|
||||
public static void clearAndDrop(Level world, BlockPos pos, @Nullable Direction direction) {
|
||||
var remainingDrops = clear();
|
||||
for (var remaining : remainingDrops) WorldUtil.dropItemStack(remaining, world, pos, direction);
|
||||
for (var remaining : remainingDrops) WorldUtil.dropItemStack(world, pos, direction, remaining);
|
||||
}
|
||||
|
||||
private static void handleDrops(ItemStack stack) {
|
||||
|
@@ -5,10 +5,30 @@
|
||||
*/
|
||||
package dan200.computercraft.shared.util;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.Month;
|
||||
|
||||
public enum Holiday {
|
||||
NONE,
|
||||
|
||||
/**
|
||||
* 14th February.
|
||||
*/
|
||||
VALENTINES,
|
||||
APRIL_FOOLS_DAY,
|
||||
HALLOWEEN,
|
||||
CHRISTMAS,
|
||||
|
||||
/**
|
||||
* 24th-26th December.
|
||||
*
|
||||
* @see net.minecraft.client.renderer.blockentity.ChestRenderer
|
||||
*/
|
||||
CHRISTMAS;
|
||||
|
||||
public static Holiday getCurrent() {
|
||||
var calendar = LocalDateTime.now();
|
||||
var month = calendar.getMonth();
|
||||
var day = calendar.getDayOfMonth();
|
||||
if (month == Month.FEBRUARY && day == 14) return VALENTINES;
|
||||
if (month == Month.DECEMBER && day >= 24 && day <= 26) return CHRISTMAS;
|
||||
return NONE;
|
||||
}
|
||||
}
|
||||
|
@@ -1,27 +0,0 @@
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2022. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
*/
|
||||
package dan200.computercraft.shared.util;
|
||||
|
||||
import java.util.Calendar;
|
||||
|
||||
public final class HolidayUtil {
|
||||
private HolidayUtil() {
|
||||
}
|
||||
|
||||
public static Holiday getCurrentHoliday() {
|
||||
return getHoliday(Calendar.getInstance());
|
||||
}
|
||||
|
||||
private static Holiday getHoliday(Calendar calendar) {
|
||||
var month = calendar.get(Calendar.MONTH);
|
||||
var day = calendar.get(Calendar.DAY_OF_MONTH);
|
||||
if (month == Calendar.FEBRUARY && day == 14) return Holiday.VALENTINES;
|
||||
if (month == Calendar.APRIL && day == 1) return Holiday.APRIL_FOOLS_DAY;
|
||||
if (month == Calendar.OCTOBER && day == 31) return Holiday.HALLOWEEN;
|
||||
if (month == Calendar.DECEMBER && day >= 24 && day <= 30) return Holiday.CHRISTMAS;
|
||||
return Holiday.NONE;
|
||||
}
|
||||
}
|
@@ -8,6 +8,8 @@ package dan200.computercraft.shared.util;
|
||||
import dan200.computercraft.shared.platform.PlatformHelper;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.Position;
|
||||
import net.minecraft.core.dispenser.DefaultDispenseItemBehavior;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.item.ItemEntity;
|
||||
@@ -118,11 +120,21 @@ public final class WorldUtil {
|
||||
return getRayStart(player).add(look.x * reach, look.y * reach, look.z * reach);
|
||||
}
|
||||
|
||||
public static void dropItemStack(ItemStack stack, Level world, BlockPos pos) {
|
||||
dropItemStack(stack, world, pos, null);
|
||||
}
|
||||
private static final double DROP_SPEED = 0.0172275 * 6;
|
||||
|
||||
public static void dropItemStack(ItemStack stack, Level world, BlockPos pos, @Nullable Direction direction) {
|
||||
/**
|
||||
* Drop an item stack into the world from a block.
|
||||
* <p>
|
||||
* This behaves similarly to {@link DefaultDispenseItemBehavior#spawnItem(Level, ItemStack, int, Direction, Position)},
|
||||
* though supports a {@code null} direction (in which case the item will have no velocity) and produces a slightly
|
||||
* different arc.
|
||||
*
|
||||
* @param level The level to drop the item in.
|
||||
* @param pos The position to drop the stack from.
|
||||
* @param direction The direction to drop in, or {@code null}.
|
||||
* @param stack The stack to drop.
|
||||
*/
|
||||
public static void dropItemStack(Level level, BlockPos pos, @Nullable Direction direction, ItemStack stack) {
|
||||
double xDir;
|
||||
double yDir;
|
||||
double zDir;
|
||||
@@ -136,25 +148,20 @@ public final class WorldUtil {
|
||||
zDir = 0.0;
|
||||
}
|
||||
|
||||
var xPos = pos.getX() + 0.5 + xDir * 0.4;
|
||||
var yPos = pos.getY() + 0.5 + yDir * 0.4;
|
||||
var zPos = pos.getZ() + 0.5 + zDir * 0.4;
|
||||
dropItemStack(stack, world, new Vec3(xPos, yPos, zPos), xDir, yDir, zDir);
|
||||
}
|
||||
var xPos = pos.getX() + 0.5 + xDir * 0.7;
|
||||
var yPos = pos.getY() + 0.5 + yDir * 0.7;
|
||||
var zPos = pos.getZ() + 0.5 + zDir * 0.7;
|
||||
|
||||
public static void dropItemStack(ItemStack stack, Level world, Vec3 pos) {
|
||||
dropItemStack(stack, world, pos, 0.0, 0.0, 0.0);
|
||||
}
|
||||
|
||||
public static void dropItemStack(ItemStack stack, Level world, Vec3 pos, double xDir, double yDir, double zDir) {
|
||||
var item = new ItemEntity(world, pos.x, pos.y, pos.z, stack.copy());
|
||||
var item = new ItemEntity(level, xPos, yPos, zPos, stack.copy());
|
||||
var baseSpeed = level.random.nextDouble() * 0.1 + 0.2;
|
||||
item.setDeltaMovement(
|
||||
xDir * 0.7 + world.getRandom().nextFloat() * 0.2 - 0.1,
|
||||
yDir * 0.7 + world.getRandom().nextFloat() * 0.2 - 0.1,
|
||||
zDir * 0.7 + world.getRandom().nextFloat() * 0.2 - 0.1
|
||||
level.random.triangle(xDir * baseSpeed, DROP_SPEED),
|
||||
// Vanilla ignores the yDir and does a constant 0.2, but that gives the item a higher arc than we want.
|
||||
level.random.triangle(yDir * baseSpeed, DROP_SPEED),
|
||||
level.random.triangle(zDir * baseSpeed, DROP_SPEED)
|
||||
);
|
||||
item.setDefaultPickUpDelay();
|
||||
world.addFreshEntity(item);
|
||||
level.addFreshEntity(item);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -171,8 +178,8 @@ public final class WorldUtil {
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getBlockShape(BlockState state, BlockGetter levle, BlockPos pos) {
|
||||
return block.get(state, levle, pos, CollisionContext.empty());
|
||||
public VoxelShape getBlockShape(BlockState state, BlockGetter level, BlockPos pos) {
|
||||
return block.get(state, level, pos, CollisionContext.empty());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -139,5 +139,48 @@
|
||||
"upgrade.minecraft.diamond_hoe.adjective": "Contadina",
|
||||
"upgrade.minecraft.diamond_pickaxe.adjective": "Minatrice",
|
||||
"upgrade.minecraft.diamond_shovel.adjective": "Scavatrice",
|
||||
"upgrade.minecraft.diamond_sword.adjective": "Da Combattimento"
|
||||
"upgrade.minecraft.diamond_sword.adjective": "Da Combattimento",
|
||||
"gui.computercraft.config.term_sizes.computer.width.tooltip": "Intervallo: 1 ~ 255",
|
||||
"gui.computercraft.config.turtle.need_fuel.tooltip": "Imposta se la Tartaruga richiede del carburante per muoversi.",
|
||||
"gui.computercraft.config.command_require_creative": "Il computer Comando richiede la modalità creativa",
|
||||
"tracking_field.computercraft.http_requests.name": "Richieste HTTP",
|
||||
"gui.computercraft.config.command_require_creative.tooltip": "Richiede che i giocatori siano in modalità creativa e che siano operatori in ordine per interagire con\ni computer di commando. Questo è il comportamento predefinito dei blocchi di comando.",
|
||||
"gui.computercraft.config.disable_lua51_features.tooltip": "Imposta a \"true\" per disattivare le funzionalità di Lua 5.1 che saranno rimosse in un\naggiornamento futuro. Utile per assicurare futura compatibilità con i tuoi programmi.",
|
||||
"gui.computercraft.config.execution": "Esecuzione",
|
||||
"gui.computercraft.config.execution.max_main_computer_time": "Limite di tempo nei tick del server dei computer",
|
||||
"gui.computercraft.config.execution.max_main_computer_time.tooltip": "Il tempo massimo ideale che un computer può eseguire in un tick, in millisecondi.\nNota, potremmo andare ben sopra questo limite, perché non c'è modo di sapere\nquanto impiega, questa configurazione mira ad essere il limite maggiore del tempo medio.\nRange: > 1",
|
||||
"gui.computercraft.config.execution.max_main_global_time": "Limite tempo globale dei tick del server",
|
||||
"gui.computercraft.config.execution.tooltip": "Controlla comportamento esecuzione dei computer. Questo è largamente utilizzato\nper ritoccare la performance dei server, e generale non dovrebbe essere toccato.",
|
||||
"gui.computercraft.config.floppy_space_limit.tooltip": "Limite di spazio di archiviazione per i dischi floppy, in byte.",
|
||||
"gui.computercraft.config.http.bandwidth": "Banda larga",
|
||||
"gui.computercraft.config.http.bandwidth.global_download": "Limite download globale",
|
||||
"gui.computercraft.config.http.bandwidth.global_download.tooltip": "Numero di byte che possono essere scaricati in un secondo. Questo è condiviso tra tutti i computer. (bytes/s).\nRange: > 1",
|
||||
"gui.computercraft.config.http.bandwidth.global_upload": "Limite upload globale",
|
||||
"gui.computercraft.config.http.bandwidth.global_upload.tooltip": "Numero di byte che possono essere caricati in un secondo. Questo è condiviso tra tutti i computer. (bytes/s).\nRange: > 1",
|
||||
"gui.computercraft.config.http.bandwidth.tooltip": "Limita la banda larga usato dai computer.",
|
||||
"gui.computercraft.config.http.max_requests.tooltip": "Il numero di richieste http che un computer può fare alla volta. Ulteriori richieste\nverranno messe in coda, ed inviate quando le richieste correnti sono terminate.\nImposta a 0 per illimitato.\nRange: > 0",
|
||||
"gui.computercraft.config.http.max_websockets.tooltip": "Il numero di websocket che un computer può avere aperte allo stesso momento.\nImposta a 0 per illimitato.\nRange: > 1",
|
||||
"gui.computercraft.config.http.rules": "Concedi/nega regole",
|
||||
"gui.computercraft.config.maximum_open_files.tooltip": "Imposta quanti file possono essere aperti allo stesso momento su un computer. Imposta a 0 per illimitato.\nRange: > 0",
|
||||
"gui.computercraft.config.monitor_distance": "Distanza monitor",
|
||||
"gui.computercraft.config.monitor_distance.tooltip": "Distanza massima che i monitor vengono renderizzati. Questo è predefinito al limite\nstandard dei tile entity, ma può essere esteso se desideri construire monitor più grandi.\nRange: 16 ~ 1024",
|
||||
"gui.computercraft.config.monitor_renderer": "Renderizzatore monitor",
|
||||
"gui.computercraft.config.peripheral.command_block_enabled.tooltip": "Attiva il supporto ai blocchi di comando come periferiche",
|
||||
"gui.computercraft.config.peripheral.max_notes_per_tick.tooltip": "Quantità massima di note che un altoparlante può riprodurre allo stesso momento.\nRange: > 1",
|
||||
"gui.computercraft.config.peripheral.modem_high_altitude_range.tooltip": "La distanza massima dei modem wireless all'altitudine massima durante il meteo soleggiato. in metri.\nRange: 0 ~ 100000",
|
||||
"gui.computercraft.config.peripheral.modem_high_altitude_range_during_storm.tooltip": "La distanza massima dei modem wireless all'altitudine massima durante una tempesta. in metri.\nRange: 0 ~ 100000",
|
||||
"gui.computercraft.config.peripheral.modem_range.tooltip": "La distanza massima dei modem wireless ad altitudini basse durante il meteo soleggiato. in metri.\nRange: 0 ~ 100000",
|
||||
"gui.computercraft.config.peripheral.modem_range_during_storm.tooltip": "La distanza massima dei modem wireless ad altitudini basse durante una tempesta. in metri.\nRange: 0 ~ 100000",
|
||||
"gui.computercraft.config.peripheral.monitor_bandwidth": "Banda larga monitor",
|
||||
"gui.computercraft.config.computer_space_limit.tooltip": "Limite di spazio di archiviazione per i computer e le tartarughe, in byte.",
|
||||
"gui.computercraft.config.default_computer_settings.tooltip": "Una lista di impostazioni predefinite per i nuovi computer, separate da virgola.\nEsempio: \"shell.autocomplete=false,lua.autocomplete=false,edit.autocomplete=false\"\ndisattiverà tutti gli autocompletamenti.",
|
||||
"gui.computercraft.config.execution.computer_threads.tooltip": "Imposta la quantità di thread che possono eseguire i computer. Un numero più alto significa\nche più computer possono essere eseguiti alla volta, ma può indurre a lag. Alcune mod potrebbero\nnon funzionare con numeri di thread maggiore a 1. Usare con cautela.\nRange: > 1",
|
||||
"gui.computercraft.config.execution.max_main_global_time.tooltip": "Il limite massimo di tempo che può essere usato per eseguire task in un singolo tick,\nin millisecondi.\nNota, potremmo andare ben sopra questo limite, perché non c'è modo di sapere\nquanto impiega, questa configurazione mira ad essere il limite maggiore del tempo medio.\nRange: > 1",
|
||||
"gui.computercraft.config.http.enabled.tooltip": "Attiva l'API \"http\" sui computer. Questo disabilita i programmi \"pastebin\" e \"wget\", \nche molti utenti dipendono. È raccomandato lasciarlo attivo ed utlizzare l'opzione \n\"rules\" per imporre controlli più adeguati.",
|
||||
"gui.computercraft.config.http.rules.tooltip": "Una lista di regole che controllano il comportamento dell'API \"http\" per specifici domini\no indirizzi IP. Ogni regola è un elemento con un 'host' da confrontare, e una serie di\nproprietà. Le regole sono valutate in ordine, cioè le prime regole sovvrascrivono le successive.\nL'host può essere un dominio (\"pastebin.com\"), wildcard (\"*.pastebin.com\") oppure\nuna notazione CIDR (\"127.0.0.0/8\").\nSe non è presente nessuna regola, il dominio è bloccato.",
|
||||
"gui.computercraft.config.http.tooltip": "Controlla l'API HTTP",
|
||||
"gui.computercraft.config.http.websocket_enabled.tooltip": "Attiva l'uso di websocket http. Questo richiede che l'opzione \"http_enable\" sia attiva.",
|
||||
"gui.computercraft.config.log_computer_errors.tooltip": "Registra le eccezioni lanciate dalle periferiche e altri oggetti di Lua. Questo rende più facile\nper gli autori di mod per il debug di problemi, ma potrebbe risultare in spam di log durante\nl'uso di metodi buggati.",
|
||||
"gui.computercraft.config.monitor_renderer.tooltip": "Il renderizzatore da usare per i monitor. Generalmente si dovrebbe lasciare su \"best\", se\ni monitor hanno problemi di performance, puoi sperimentare con renderizzatori alternativi.\nValori concessi: BEST, TBO, VBO",
|
||||
"gui.computercraft.config.peripheral.monitor_bandwidth.tooltip": "Il limite di quanti dati dei monitor possono essere inviati *al tick*. Nota:\n - La banda larga è misurata prima della compressione, così che il dato inviato al client è\n più piccolo."
|
||||
}
|
||||
|
@@ -0,0 +1,128 @@
|
||||
{
|
||||
"block.computercraft.disk_drive": "tomo pi lipu sona",
|
||||
"block.computercraft.printer": "ilo sitelen",
|
||||
"block.computercraft.monitor_normal": "ilo lukin",
|
||||
"block.computercraft.monitor_advanced": "ilo lukin wawa",
|
||||
"block.computercraft.speaker": "ilo kalama",
|
||||
"commands.computercraft.generic.exception": "pakala awen ala (%s)",
|
||||
"block.computercraft.computer_command": "ilo sona pi toki wawa",
|
||||
"block.computercraft.turtle_advanced": "ilo sona pali wawa",
|
||||
"block.computercraft.turtle_normal": "ilo sona pali",
|
||||
"block.computercraft.computer_advanced": "ilo sona wawa",
|
||||
"block.computercraft.computer_normal": "ilo sona",
|
||||
"argument.computercraft.argument_expected": "mi wile e ijo",
|
||||
"block.computercraft.turtle_advanced.upgraded": "ilo sona pali wawa (%s)",
|
||||
"block.computercraft.turtle_normal.upgraded": "ilo sona pali (%s)",
|
||||
"commands.computercraft.dump.action": "o lukin e sona mute pi ilo sona ni",
|
||||
"commands.computercraft.generic.no_position": "<lon ala>",
|
||||
"chat.computercraft.wired_modem.peripheral_connected": "ijo sona \"%s\" li linja tawa kulupu",
|
||||
"chat.computercraft.wired_modem.peripheral_disconnected": "ijo sona \"%s\" li linja ala tawa kulupu",
|
||||
"block.computercraft.wired_modem": "ilo toki linja",
|
||||
"block.computercraft.wired_modem_full": "ilo toki linja",
|
||||
"block.computercraft.wireless_modem_normal": "ilo toki linja ala",
|
||||
"commands.computercraft.generic.additional_rows": "mute %d…",
|
||||
"argument.computercraft.computer.no_matching": "mi ken ala alasa e ilo sona pi nimi '%s'",
|
||||
"commands.computercraft.dump.open_path": "o lukin e lipu pi ilo sona ni",
|
||||
"commands.computercraft.dump.synopsis": "mi pana e sona pi ilo sona.",
|
||||
"block.computercraft.cable": "linja toki",
|
||||
"block.computercraft.wireless_modem_advanced": "ilo toki pi ma End",
|
||||
"commands.computercraft.generic.position": "%s, %s, %s",
|
||||
"commands.computercraft.help.no_children": "toki wawa '%s' li jo ala e toki wawa insa",
|
||||
"commands.computercraft.help.no_command": "toki wawa '%s' li lon ala",
|
||||
"commands.computercraft.help.desc": "mi pana e toki ni",
|
||||
"commands.computercraft.help.synopsis": "mi pana e sona pi toki wawa ale",
|
||||
"commands.computercraft.reload.done": "mi kama open sin e ante nasin",
|
||||
"commands.computercraft.shutdown.done": "mi kama pini e ilo sona %s/%s",
|
||||
"commands.computercraft.shutdown.synopsis": "mi pini weka e ilo sona.",
|
||||
"commands.computercraft.queue.synopsis": "mi pana e toki computer_command tawa ilo sona pi toki wawa",
|
||||
"commands.computercraft.tp.desc": "o tawa ilo sona. ilo sona la, sina ken pana e nanpa pi ijo (sama 123) anu nanpa (sama #123).",
|
||||
"commands.computercraft.synopsis": "mi jo e toki wawa ante tawa ni: sina lawa e ilo sona.",
|
||||
"commands.computercraft.tp.action": "o tawa pi ilo sona",
|
||||
"commands.computercraft.tp.not_player": "jan ala la, mi ken ala open e sitelen pi ilo sona",
|
||||
"commands.computercraft.track.dump.computer": "ilo sona",
|
||||
"commands.computercraft.tp.synopsis": "mi tawa pi ilo sona e sina.",
|
||||
"commands.computercraft.tp.not_there": "mi ken ala alasa e ilo sona pi lon ma",
|
||||
"commands.computercraft.track.desc": "ilo sona la, mi sitelen e tenpo pali e mute toki. toki wawa /forge track la, mi pana pi nasin sama e sona. mi pona tawa alasa pi tenpo ike.",
|
||||
"commands.computercraft.track.dump.no_timings": "mi ken ala alasa e tenpo",
|
||||
"commands.computercraft.track.stop.synopsis": "mi pini e sitelen sona ale",
|
||||
"commands.computercraft.track.start.synopsis": "mi open sitelen sona e ilo sona ale",
|
||||
"commands.computercraft.track.stop.action": "o luka tawa ni: mi pini sitelen sona",
|
||||
"commands.computercraft.track.stop.not_enabled": "tenpo ni la, mi sitelen ala sona e ilo sona",
|
||||
"commands.computercraft.track.dump.synopsis": "mi pana e sona tan sitelen sona pi sin mute",
|
||||
"commands.computercraft.track.stop.desc": "ilo sona la, mi pini sitelen sona e tenpo pali e mute toki",
|
||||
"commands.computercraft.track.synopsis": "mi sitelen tenpo pali e ilo sona.",
|
||||
"commands.computercraft.track.dump.desc": "mi pana e sona tan sitelen sona pi sin mute.",
|
||||
"commands.computercraft.view.action": "o lukin e ilo sona ni",
|
||||
"commands.computercraft.view.synopsis": "o lukin e sitelen pi ilo sona.",
|
||||
"commands.computercraft.turn_on.done": "mi kama open e ilo sona %s/%s",
|
||||
"commands.computercraft.turn_on.synopsis": "mi open weka e ilo sona.",
|
||||
"commands.computercraft.view.not_player": "jan ala la, mi ken ala open e sitelen pi ilo sona",
|
||||
"gui.computercraft.config.command_require_creative": "ilo sona pi toki wawa li wile e jan sewi",
|
||||
"gui.computercraft.config.execution.computer_threads": "linja pi ilo sona",
|
||||
"gui.computercraft.config.http.bandwidth": "mute sona",
|
||||
"gui.computercraft.config.http": "ijo HTTP",
|
||||
"gui.computercraft.config.execution": "pali",
|
||||
"gui.computercraft.config.monitor_renderer": "nasin sitelen pi ilo lukin",
|
||||
"gui.computercraft.config.term_sizes.pocket_computer.width": "suli poka pi ilo sitelen",
|
||||
"gui.computercraft.config.term_sizes": "suli pi ilo sitelen",
|
||||
"gui.computercraft.config.term_sizes.computer": "ilo sona",
|
||||
"gui.computercraft.config.term_sizes.monitor": "ilo lukin",
|
||||
"gui.computercraft.config.term_sizes.pocket_computer": "ilo sona lili",
|
||||
"gui.computercraft.config.term_sizes.pocket_computer.height": "suli sewi pi ilo sitelen",
|
||||
"gui.computercraft.config.term_sizes.computer.height": "suli sewi pi ilo sitelen",
|
||||
"gui.computercraft.config.term_sizes.computer.width": "suli poka pi ito sitelen",
|
||||
"gui.computercraft.config.term_sizes.computer.tooltip": "suli pi ilo sitelen pi ilo sona.",
|
||||
"gui.computercraft.config.peripheral.monitor_bandwidth": "mute sona pi ilo lukin",
|
||||
"gui.computercraft.config.peripheral.modem_range": "suli ken ilo pi ilo toki (pona)",
|
||||
"gui.computercraft.config.peripheral.modem_high_altitude_range": "suli ken ilo pi ilo toki (sewi mute)",
|
||||
"item.computercraft.printed_page": "lipu pi ilo sitelen",
|
||||
"item.computercraft.printed_pages": "lipu mute pi ilo sitelen",
|
||||
"item.computercraft.treasure_disk": "lipu sona",
|
||||
"gui.computercraft.tooltip.turn_on": "o open e ilo sona ni",
|
||||
"gui.computercraft.tooltip.computer_id": "nanpa pi ilo sona: %s",
|
||||
"gui.computercraft.tooltip.turn_off": "o pini e ilo sona ni",
|
||||
"item.computercraft.pocket_computer_advanced": "ilo sona lili wawa",
|
||||
"item.computercraft.pocket_computer_advanced.upgraded": "ilo sona lili wawa (%s)",
|
||||
"item.computercraft.pocket_computer_normal": "ilo sona lili",
|
||||
"item.computercraft.pocket_computer_normal.upgraded": "ilo sona lili (%s)",
|
||||
"gui.computercraft.terminal": "ilo sitelen pi ilo sona",
|
||||
"itemGroup.computercraft": "ComputerCraft",
|
||||
"tracking_field.computercraft.computer_tasks.name": "pali",
|
||||
"tracking_field.computercraft.turtle_ops.name": "pali pi ilo sona pali",
|
||||
"upgrade.computercraft.speaker.adjective": "kalama",
|
||||
"tracking_field.computercraft.count": "%s (mute)",
|
||||
"tracking_field.computercraft.coroutines_created.name": "open linja",
|
||||
"tracking_field.computercraft.coroutines_dead.name": "pini linja",
|
||||
"tracking_field.computercraft.max": "%s (sewi)",
|
||||
"upgrade.minecraft.crafting_table.adjective": "pali",
|
||||
"upgrade.minecraft.diamond_axe.adjective": "ilo kipisi",
|
||||
"upgrade.minecraft.diamond_hoe.adjective": "ilo kasi",
|
||||
"upgrade.computercraft.wireless_modem_normal.adjective": "toki linja ala",
|
||||
"upgrade.minecraft.diamond_pickaxe.adjective": "ilo pakala",
|
||||
"upgrade.minecraft.diamond_shovel.adjective": "ilo ma",
|
||||
"upgrade.minecraft.diamond_sword.adjective": "utala",
|
||||
"block.computercraft.turtle_advanced.upgraded_twice": "ilo sona pali wawa (%s, %s)",
|
||||
"block.computercraft.turtle_normal.upgraded_twice": "ilo sona pali (%s, %s)",
|
||||
"gui.computercraft.config.turtle": "ilo sona pali",
|
||||
"item.computercraft.disk": "lipu sona",
|
||||
"item.computercraft.printed_book": "lipu suli pi ilo sitelen",
|
||||
"upgrade.computercraft.wireless_modem_advanced.adjective": "toki pi ma End",
|
||||
"gui.computercraft.tooltip.disk_id": "nanpa pi lipu sona: %s",
|
||||
"gui.computercraft.config.peripheral": "ijo sona",
|
||||
"gui.computercraft.config.peripheral.modem_range_during_storm": "suli ken ilo pi ilo toki (sewi ike)",
|
||||
"argument.computercraft.tracking_field.no_field": "mi sona ala e nimi '%s'",
|
||||
"argument.computercraft.computer.many_matching": "mi alasa e ilo sona mute pi nimi '%s' (ijo %s)",
|
||||
"commands.computercraft.desc": "ilo sona la, toki wawa /computercraft li lawa li luka li pakala ala.",
|
||||
"commands.computercraft.reload.desc": "mi open sin e ante nasin",
|
||||
"commands.computercraft.reload.synopsis": "mi open sin e ante nasin",
|
||||
"commands.computercraft.shutdown.desc": "mi pini e ilo sona pi pana sina anu ale. ilo sona la, sina ken pana e nanpa pi ijo (sama 123) anu nanpa (sama #123) anu nimi (sama \"@ilo sona mi\").",
|
||||
"gui.computercraft.config.term_sizes.pocket_computer.tooltip": "suli pi ilo sitelen pi ilo sona lili.",
|
||||
"gui.computercraft.config.peripheral.modem_high_altitude_range_during_storm": "suli ken ilo pi ilo toki (sewi mute, sewi ike)",
|
||||
"gui.computercraft.pocket_computer_overlay": "sina open e ilo sona lili. o luka e nena ESC tawa pini.",
|
||||
"commands.computercraft.dump.desc": "sona pi ilo sona la, mi pana e ale anu wan. ilo sona la, sina ken pana e nanpa pi ijo (sama 123) anu nanpa (sama #123) anu nimi (sama \"@ilo sona mi\").",
|
||||
"commands.computercraft.turn_on.desc": "mi open e ilo sona pi pana sina. ilo sona la, sina ken pana e nanpa pi ijo (sama 123) anu nanpa (sama #123) anu nimi (sama \"@ilo sona mi\").",
|
||||
"commands.computercraft.track.start.stop": "o toki wawa %s tawa ni: sina pini sitelen sona. sina lukin e sona ni",
|
||||
"commands.computercraft.track.start.desc": "ilo sona la, mi open sitelen sona e tenpo pali e mute toki. mi weka e sitelen sona pini.",
|
||||
"commands.computercraft.view.desc": "mi open e sitelen pi ilo sona tawa ni: sina lawa weka e ilo sona. taso, sina ken ala open e jo pi ilo sona pali. ilo sona la, sina ken pana e nanpa pi ijo (sama 123) anu nanpa (sama #123).",
|
||||
"gui.computercraft.config.disable_lua51_features": "ijo pona pi ilo Lua 5.1 li weka"
|
||||
}
|
@@ -6,6 +6,7 @@
|
||||
package dan200.computercraft;
|
||||
|
||||
import com.google.auto.service.AutoService;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.brigadier.arguments.ArgumentType;
|
||||
import dan200.computercraft.api.network.wired.WiredElement;
|
||||
@@ -77,6 +78,17 @@ public class TestPlatformHelper extends AbstractComputerCraftAPI implements Plat
|
||||
throw new UnsupportedOperationException("Cannot query registry inside tests");
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public <T> T tryGetRegistryObject(ResourceKey<Registry<T>> registry, ResourceLocation id) {
|
||||
throw new UnsupportedOperationException("Cannot query registries");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldLoadResource(JsonObject object) {
|
||||
throw new UnsupportedOperationException("Cannot use loot conditions");
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends BlockEntity> BlockEntityType<T> createBlockEntityType(BiFunction<BlockPos, BlockState, T> factory, Block block) {
|
||||
throw new UnsupportedOperationException("Cannot create BlockEntityType inside tests");
|
||||
@@ -219,10 +231,4 @@ public class TestPlatformHelper extends AbstractComputerCraftAPI implements Plat
|
||||
public String getInstalledVersion() {
|
||||
return "1.0";
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public <T> T tryGetRegistryObject(ResourceKey<Registry<T>> registry, ResourceLocation id) {
|
||||
throw new UnsupportedOperationException("Cannot query registries");
|
||||
}
|
||||
}
|
||||
|
@@ -8,6 +8,7 @@ package dan200.computercraft.gametest.core;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import dan200.computercraft.mixin.gametest.TestCommandAccessor;
|
||||
import dan200.computercraft.shared.ModRegistry;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.gametest.framework.GameTestRegistry;
|
||||
@@ -81,6 +82,27 @@ class CCTestCommand {
|
||||
player.getLevel().addFreshEntity(armorStand);
|
||||
return 0;
|
||||
}))
|
||||
|
||||
.then(literal("give-computer").executes(context -> {
|
||||
var player = context.getSource().getPlayerOrException();
|
||||
var pos = StructureUtils.findNearestStructureBlock(player.blockPosition(), 15, player.getLevel());
|
||||
if (pos == null) return error(context.getSource(), "No nearby test");
|
||||
|
||||
var structureBlock = (StructureBlockEntity) player.getLevel().getBlockEntity(pos);
|
||||
if (structureBlock == null) return error(context.getSource(), "No nearby structure block");
|
||||
var info = GameTestRegistry.getTestFunction(structureBlock.getStructurePath());
|
||||
|
||||
var item = ModRegistry.Items.COMPUTER_ADVANCED.get().create(1, info.getTestName());
|
||||
if (!player.getInventory().add(item)) {
|
||||
var itemEntity = player.drop(item, false);
|
||||
if (itemEntity != null) {
|
||||
itemEntity.setNoPickUpDelay();
|
||||
itemEntity.setOwner(player.getUUID());
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}))
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -8,6 +8,7 @@ package dan200.computercraft.gametest
|
||||
import dan200.computercraft.core.apis.FSAPI
|
||||
import dan200.computercraft.gametest.api.*
|
||||
import dan200.computercraft.shared.ModRegistry
|
||||
import dan200.computercraft.shared.media.items.DiskItem
|
||||
import dan200.computercraft.shared.peripheral.diskdrive.DiskDriveBlock
|
||||
import dan200.computercraft.shared.peripheral.diskdrive.DiskDriveState
|
||||
import dan200.computercraft.test.core.assertArrayEquals
|
||||
@@ -45,10 +46,14 @@ class Disk_Drive_Test {
|
||||
thenWaitUntil { helper.assertItemEntityPresent(Items.MUSIC_DISC_13, stackAt, 0.0) }
|
||||
}
|
||||
|
||||
/**
|
||||
* A mount is initially attached, and then removed when the disk is ejected.
|
||||
*/
|
||||
@GameTest
|
||||
fun Adds_removes_mount(helper: GameTestHelper) = helper.sequence {
|
||||
thenIdle(2)
|
||||
thenOnComputer {
|
||||
thenOnComputer { } // Wait for the computer to start up
|
||||
thenIdle(2) // Let the disk drive tick once to create the mount
|
||||
thenOnComputer { // Then actually assert things!
|
||||
getApi<FSAPI>().getDrive("disk").assertArrayEquals("right")
|
||||
callPeripheral("right", "ejectDisk")
|
||||
}
|
||||
@@ -56,6 +61,18 @@ class Disk_Drive_Test {
|
||||
thenOnComputer { assertEquals(null, getApi<FSAPI>().getDrive("disk")) }
|
||||
}
|
||||
|
||||
/**
|
||||
* When creating a new mount, the item is with a new disk ID.
|
||||
*/
|
||||
@GameTest
|
||||
fun Creates_disk_id(helper: GameTestHelper) = helper.sequence {
|
||||
val drivePos = BlockPos(2, 2, 2)
|
||||
thenWaitUntil {
|
||||
val drive = helper.getBlockEntity(drivePos, ModRegistry.BlockEntities.DISK_DRIVE.get())
|
||||
if (DiskItem.getDiskID(drive.getItem(0)) == -1) helper.fail("Disk has no item", drivePos)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check comparators can read the contents of the disk drive
|
||||
*/
|
||||
|
@@ -70,6 +70,20 @@ class Modem_Test {
|
||||
.assertArrayEquals("modem_message", "left", 12, 34, "Hello", 4, message = "Modem message")
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert that full block modems act like cables.
|
||||
*
|
||||
* @see [#1278](https://github.com/cc-tweaked/CC-Tweaked/issues/1278)
|
||||
*/
|
||||
@GameTest(setupTicks = 1)
|
||||
fun Full_modems_form_networks(helper: GameTestHelper) = helper.sequence {
|
||||
thenExecute {
|
||||
val modem1 = helper.getBlockEntity(BlockPos(1, 2, 1), ModRegistry.BlockEntities.WIRED_MODEM_FULL.get())
|
||||
val modem2 = helper.getBlockEntity(BlockPos(3, 2, 1), ModRegistry.BlockEntities.WIRED_MODEM_FULL.get())
|
||||
assertEquals(modem1.element.node.network, modem2.element.node.network, "On the same network")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun LuaTaskContext.findPeripheral(type: String): String? {
|
||||
|
@@ -63,7 +63,7 @@ class Monitor_Test {
|
||||
}
|
||||
|
||||
/**
|
||||
* Test
|
||||
* Test monitors render correctly
|
||||
*/
|
||||
@GameTestGenerator
|
||||
fun Render_monitor_tests(): List<TestFunction> {
|
||||
@@ -72,7 +72,7 @@ class Monitor_Test {
|
||||
fun addTest(label: String, renderer: MonitorRenderer, time: Long = Times.NOON, tag: String = TestTags.CLIENT) {
|
||||
if (!TestTags.isEnabled(tag)) return
|
||||
|
||||
val className = Monitor_Test::class.java.simpleName.lowercase()
|
||||
val className = this::class.java.simpleName.lowercase()
|
||||
val testName = "$className.render_monitor"
|
||||
|
||||
tests.add(
|
||||
|
@@ -0,0 +1,53 @@
|
||||
package dan200.computercraft.gametest
|
||||
|
||||
import dan200.computercraft.gametest.api.*
|
||||
import net.minecraft.gametest.framework.GameTestGenerator
|
||||
import net.minecraft.gametest.framework.GameTestHelper
|
||||
import net.minecraft.gametest.framework.TestFunction
|
||||
|
||||
class Printout_Test {
|
||||
/**
|
||||
* Test printouts render correctly
|
||||
*/
|
||||
@GameTestGenerator
|
||||
fun Render_in_frame(): List<TestFunction> {
|
||||
val tests = mutableListOf<TestFunction>()
|
||||
|
||||
fun addTest(label: String, time: Long = Times.NOON, tag: String = TestTags.CLIENT) {
|
||||
if (!TestTags.isEnabled(tag)) return
|
||||
|
||||
val className = this::class.java.simpleName.lowercase()
|
||||
val testName = "$className.render_in_frame"
|
||||
|
||||
tests.add(
|
||||
TestFunction(
|
||||
"$testName.$label",
|
||||
"$testName.$label",
|
||||
testName,
|
||||
Timeouts.DEFAULT,
|
||||
0,
|
||||
true,
|
||||
) { renderPrintout(it, time) },
|
||||
)
|
||||
}
|
||||
|
||||
addTest("noon", Times.NOON)
|
||||
addTest("midnight", Times.MIDNIGHT)
|
||||
|
||||
addTest("sodium", tag = "sodium")
|
||||
|
||||
addTest("iris_noon", Times.NOON, tag = "iris")
|
||||
addTest("iris_midnight", Times.MIDNIGHT, tag = "iris")
|
||||
|
||||
return tests
|
||||
}
|
||||
|
||||
private fun renderPrintout(helper: GameTestHelper, time: Long) = helper.sequence {
|
||||
thenExecute {
|
||||
helper.level.dayTime = time
|
||||
helper.positionAtArmorStand()
|
||||
}
|
||||
|
||||
thenScreenshot()
|
||||
}
|
||||
}
|
@@ -80,6 +80,7 @@ object TestHooks {
|
||||
Monitor_Test::class.java,
|
||||
Pocket_Computer_Test::class.java,
|
||||
Printer_Test::class.java,
|
||||
Printout_Test::class.java,
|
||||
Recipe_Test::class.java,
|
||||
Turtle_Test::class.java,
|
||||
)
|
||||
|
138
projects/common/src/testMod/resources/data/cctest/structures/disk_drive_test.creates_disk_id.snbt
generated
Normal file
138
projects/common/src/testMod/resources/data/cctest/structures/disk_drive_test.creates_disk_id.snbt
generated
Normal file
@@ -0,0 +1,138 @@
|
||||
{
|
||||
DataVersion: 3218,
|
||||
size: [5, 5, 5],
|
||||
data: [
|
||||
{pos: [0, 0, 0], state: "minecraft:polished_andesite"},
|
||||
{pos: [0, 0, 1], state: "minecraft:polished_andesite"},
|
||||
{pos: [0, 0, 2], state: "minecraft:polished_andesite"},
|
||||
{pos: [0, 0, 3], state: "minecraft:polished_andesite"},
|
||||
{pos: [0, 0, 4], state: "minecraft:polished_andesite"},
|
||||
{pos: [1, 0, 0], state: "minecraft:polished_andesite"},
|
||||
{pos: [1, 0, 1], state: "minecraft:polished_andesite"},
|
||||
{pos: [1, 0, 2], state: "minecraft:polished_andesite"},
|
||||
{pos: [1, 0, 3], state: "minecraft:polished_andesite"},
|
||||
{pos: [1, 0, 4], state: "minecraft:polished_andesite"},
|
||||
{pos: [2, 0, 0], state: "minecraft:polished_andesite"},
|
||||
{pos: [2, 0, 1], state: "minecraft:polished_andesite"},
|
||||
{pos: [2, 0, 2], state: "minecraft:polished_andesite"},
|
||||
{pos: [2, 0, 3], state: "minecraft:polished_andesite"},
|
||||
{pos: [2, 0, 4], state: "minecraft:polished_andesite"},
|
||||
{pos: [3, 0, 0], state: "minecraft:polished_andesite"},
|
||||
{pos: [3, 0, 1], state: "minecraft:polished_andesite"},
|
||||
{pos: [3, 0, 2], state: "minecraft:polished_andesite"},
|
||||
{pos: [3, 0, 3], state: "minecraft:polished_andesite"},
|
||||
{pos: [3, 0, 4], state: "minecraft:polished_andesite"},
|
||||
{pos: [4, 0, 0], state: "minecraft:polished_andesite"},
|
||||
{pos: [4, 0, 1], state: "minecraft:polished_andesite"},
|
||||
{pos: [4, 0, 2], state: "minecraft:polished_andesite"},
|
||||
{pos: [4, 0, 3], state: "minecraft:polished_andesite"},
|
||||
{pos: [4, 0, 4], state: "minecraft:polished_andesite"},
|
||||
{pos: [0, 1, 0], state: "minecraft:air"},
|
||||
{pos: [0, 1, 1], state: "minecraft:air"},
|
||||
{pos: [0, 1, 2], state: "minecraft:air"},
|
||||
{pos: [0, 1, 3], state: "minecraft:air"},
|
||||
{pos: [0, 1, 4], state: "minecraft:air"},
|
||||
{pos: [1, 1, 0], state: "minecraft:air"},
|
||||
{pos: [1, 1, 1], state: "minecraft:air"},
|
||||
{pos: [1, 1, 2], state: "computercraft:computer_advanced{facing:north,state:on}", nbt: {ComputerId: 1, Label: "disk_drive_test.creates_disk_id", On: 1b, id: "computercraft:computer_advanced"}},
|
||||
{pos: [1, 1, 3], state: "minecraft:air"},
|
||||
{pos: [1, 1, 4], state: "minecraft:air"},
|
||||
{pos: [2, 1, 0], state: "minecraft:air"},
|
||||
{pos: [2, 1, 1], state: "minecraft:air"},
|
||||
{pos: [2, 1, 2], state: "computercraft:disk_drive{facing:north,state:full}", nbt: {Item: {Count: 1b, id: "computercraft:disk", tag: {Color: 1118481}}, id: "computercraft:disk_drive"}},
|
||||
{pos: [2, 1, 3], state: "minecraft:air"},
|
||||
{pos: [2, 1, 4], state: "minecraft:air"},
|
||||
{pos: [3, 1, 0], state: "minecraft:air"},
|
||||
{pos: [3, 1, 1], state: "minecraft:air"},
|
||||
{pos: [3, 1, 2], state: "minecraft:air"},
|
||||
{pos: [3, 1, 3], state: "minecraft:air"},
|
||||
{pos: [3, 1, 4], state: "minecraft:air"},
|
||||
{pos: [4, 1, 0], state: "minecraft:air"},
|
||||
{pos: [4, 1, 1], state: "minecraft:air"},
|
||||
{pos: [4, 1, 2], state: "minecraft:air"},
|
||||
{pos: [4, 1, 3], state: "minecraft:air"},
|
||||
{pos: [4, 1, 4], state: "minecraft:air"},
|
||||
{pos: [0, 2, 0], state: "minecraft:air"},
|
||||
{pos: [0, 2, 1], state: "minecraft:air"},
|
||||
{pos: [0, 2, 2], state: "minecraft:air"},
|
||||
{pos: [0, 2, 3], state: "minecraft:air"},
|
||||
{pos: [0, 2, 4], state: "minecraft:air"},
|
||||
{pos: [1, 2, 0], state: "minecraft:air"},
|
||||
{pos: [1, 2, 1], state: "minecraft:air"},
|
||||
{pos: [1, 2, 2], state: "minecraft:air"},
|
||||
{pos: [1, 2, 3], state: "minecraft:air"},
|
||||
{pos: [1, 2, 4], state: "minecraft:air"},
|
||||
{pos: [2, 2, 0], state: "minecraft:air"},
|
||||
{pos: [2, 2, 1], state: "minecraft:air"},
|
||||
{pos: [2, 2, 2], state: "minecraft:air"},
|
||||
{pos: [2, 2, 3], state: "minecraft:air"},
|
||||
{pos: [2, 2, 4], state: "minecraft:air"},
|
||||
{pos: [3, 2, 0], state: "minecraft:air"},
|
||||
{pos: [3, 2, 1], state: "minecraft:air"},
|
||||
{pos: [3, 2, 2], state: "minecraft:air"},
|
||||
{pos: [3, 2, 3], state: "minecraft:air"},
|
||||
{pos: [3, 2, 4], state: "minecraft:air"},
|
||||
{pos: [4, 2, 0], state: "minecraft:air"},
|
||||
{pos: [4, 2, 1], state: "minecraft:air"},
|
||||
{pos: [4, 2, 2], state: "minecraft:air"},
|
||||
{pos: [4, 2, 3], state: "minecraft:air"},
|
||||
{pos: [4, 2, 4], state: "minecraft:air"},
|
||||
{pos: [0, 3, 0], state: "minecraft:air"},
|
||||
{pos: [0, 3, 1], state: "minecraft:air"},
|
||||
{pos: [0, 3, 2], state: "minecraft:air"},
|
||||
{pos: [0, 3, 3], state: "minecraft:air"},
|
||||
{pos: [0, 3, 4], state: "minecraft:air"},
|
||||
{pos: [1, 3, 0], state: "minecraft:air"},
|
||||
{pos: [1, 3, 1], state: "minecraft:air"},
|
||||
{pos: [1, 3, 2], state: "minecraft:air"},
|
||||
{pos: [1, 3, 3], state: "minecraft:air"},
|
||||
{pos: [1, 3, 4], state: "minecraft:air"},
|
||||
{pos: [2, 3, 0], state: "minecraft:air"},
|
||||
{pos: [2, 3, 1], state: "minecraft:air"},
|
||||
{pos: [2, 3, 2], state: "minecraft:air"},
|
||||
{pos: [2, 3, 3], state: "minecraft:air"},
|
||||
{pos: [2, 3, 4], state: "minecraft:air"},
|
||||
{pos: [3, 3, 0], state: "minecraft:air"},
|
||||
{pos: [3, 3, 1], state: "minecraft:air"},
|
||||
{pos: [3, 3, 2], state: "minecraft:air"},
|
||||
{pos: [3, 3, 3], state: "minecraft:air"},
|
||||
{pos: [3, 3, 4], state: "minecraft:air"},
|
||||
{pos: [4, 3, 0], state: "minecraft:air"},
|
||||
{pos: [4, 3, 1], state: "minecraft:air"},
|
||||
{pos: [4, 3, 2], state: "minecraft:air"},
|
||||
{pos: [4, 3, 3], state: "minecraft:air"},
|
||||
{pos: [4, 3, 4], state: "minecraft:air"},
|
||||
{pos: [0, 4, 0], state: "minecraft:air"},
|
||||
{pos: [0, 4, 1], state: "minecraft:air"},
|
||||
{pos: [0, 4, 2], state: "minecraft:air"},
|
||||
{pos: [0, 4, 3], state: "minecraft:air"},
|
||||
{pos: [0, 4, 4], state: "minecraft:air"},
|
||||
{pos: [1, 4, 0], state: "minecraft:air"},
|
||||
{pos: [1, 4, 1], state: "minecraft:air"},
|
||||
{pos: [1, 4, 2], state: "minecraft:air"},
|
||||
{pos: [1, 4, 3], state: "minecraft:air"},
|
||||
{pos: [1, 4, 4], state: "minecraft:air"},
|
||||
{pos: [2, 4, 0], state: "minecraft:air"},
|
||||
{pos: [2, 4, 1], state: "minecraft:air"},
|
||||
{pos: [2, 4, 2], state: "minecraft:air"},
|
||||
{pos: [2, 4, 3], state: "minecraft:air"},
|
||||
{pos: [2, 4, 4], state: "minecraft:air"},
|
||||
{pos: [3, 4, 0], state: "minecraft:air"},
|
||||
{pos: [3, 4, 1], state: "minecraft:air"},
|
||||
{pos: [3, 4, 2], state: "minecraft:air"},
|
||||
{pos: [3, 4, 3], state: "minecraft:air"},
|
||||
{pos: [3, 4, 4], state: "minecraft:air"},
|
||||
{pos: [4, 4, 0], state: "minecraft:air"},
|
||||
{pos: [4, 4, 1], state: "minecraft:air"},
|
||||
{pos: [4, 4, 2], state: "minecraft:air"},
|
||||
{pos: [4, 4, 3], state: "minecraft:air"},
|
||||
{pos: [4, 4, 4], state: "minecraft:air"}
|
||||
],
|
||||
entities: [],
|
||||
palette: [
|
||||
"minecraft:polished_andesite",
|
||||
"minecraft:air",
|
||||
"computercraft:computer_advanced{facing:north,state:on}",
|
||||
"computercraft:disk_drive{facing:north,state:full}"
|
||||
]
|
||||
}
|
137
projects/common/src/testMod/resources/data/cctest/structures/modem_test.full_modems_form_networks.snbt
generated
Normal file
137
projects/common/src/testMod/resources/data/cctest/structures/modem_test.full_modems_form_networks.snbt
generated
Normal file
@@ -0,0 +1,137 @@
|
||||
{
|
||||
DataVersion: 3218,
|
||||
size: [5, 5, 5],
|
||||
data: [
|
||||
{pos: [0, 0, 0], state: "minecraft:polished_andesite"},
|
||||
{pos: [0, 0, 1], state: "minecraft:polished_andesite"},
|
||||
{pos: [0, 0, 2], state: "minecraft:polished_andesite"},
|
||||
{pos: [0, 0, 3], state: "minecraft:polished_andesite"},
|
||||
{pos: [0, 0, 4], state: "minecraft:polished_andesite"},
|
||||
{pos: [1, 0, 0], state: "minecraft:polished_andesite"},
|
||||
{pos: [1, 0, 1], state: "minecraft:polished_andesite"},
|
||||
{pos: [1, 0, 2], state: "minecraft:polished_andesite"},
|
||||
{pos: [1, 0, 3], state: "minecraft:polished_andesite"},
|
||||
{pos: [1, 0, 4], state: "minecraft:polished_andesite"},
|
||||
{pos: [2, 0, 0], state: "minecraft:polished_andesite"},
|
||||
{pos: [2, 0, 1], state: "minecraft:polished_andesite"},
|
||||
{pos: [2, 0, 2], state: "minecraft:polished_andesite"},
|
||||
{pos: [2, 0, 3], state: "minecraft:polished_andesite"},
|
||||
{pos: [2, 0, 4], state: "minecraft:polished_andesite"},
|
||||
{pos: [3, 0, 0], state: "minecraft:polished_andesite"},
|
||||
{pos: [3, 0, 1], state: "minecraft:polished_andesite"},
|
||||
{pos: [3, 0, 2], state: "minecraft:polished_andesite"},
|
||||
{pos: [3, 0, 3], state: "minecraft:polished_andesite"},
|
||||
{pos: [3, 0, 4], state: "minecraft:polished_andesite"},
|
||||
{pos: [4, 0, 0], state: "minecraft:polished_andesite"},
|
||||
{pos: [4, 0, 1], state: "minecraft:polished_andesite"},
|
||||
{pos: [4, 0, 2], state: "minecraft:polished_andesite"},
|
||||
{pos: [4, 0, 3], state: "minecraft:polished_andesite"},
|
||||
{pos: [4, 0, 4], state: "minecraft:polished_andesite"},
|
||||
{pos: [0, 1, 0], state: "minecraft:air"},
|
||||
{pos: [0, 1, 1], state: "minecraft:air"},
|
||||
{pos: [0, 1, 2], state: "minecraft:air"},
|
||||
{pos: [0, 1, 3], state: "minecraft:air"},
|
||||
{pos: [0, 1, 4], state: "minecraft:air"},
|
||||
{pos: [1, 1, 0], state: "minecraft:air"},
|
||||
{pos: [1, 1, 1], state: "computercraft:wired_modem_full{modem:false,peripheral:false}", nbt: {PeripheralAccess: 0b, id: "computercraft:wired_modem_full"}},
|
||||
{pos: [1, 1, 2], state: "computercraft:wired_modem_full{modem:false,peripheral:false}", nbt: {PeripheralAccess: 0b, id: "computercraft:wired_modem_full"}},
|
||||
{pos: [1, 1, 3], state: "computercraft:wired_modem_full{modem:false,peripheral:false}", nbt: {PeripheralAccess: 0b, id: "computercraft:wired_modem_full"}},
|
||||
{pos: [1, 1, 4], state: "minecraft:air"},
|
||||
{pos: [2, 1, 0], state: "minecraft:air"},
|
||||
{pos: [2, 1, 1], state: "minecraft:air"},
|
||||
{pos: [2, 1, 2], state: "minecraft:air"},
|
||||
{pos: [2, 1, 3], state: "computercraft:wired_modem_full{modem:false,peripheral:false}", nbt: {PeripheralAccess: 0b, id: "computercraft:wired_modem_full"}},
|
||||
{pos: [2, 1, 4], state: "minecraft:air"},
|
||||
{pos: [3, 1, 0], state: "minecraft:air"},
|
||||
{pos: [3, 1, 1], state: "computercraft:wired_modem_full{modem:false,peripheral:false}", nbt: {PeripheralAccess: 0b, id: "computercraft:wired_modem_full"}},
|
||||
{pos: [3, 1, 2], state: "computercraft:wired_modem_full{modem:false,peripheral:false}", nbt: {PeripheralAccess: 0b, id: "computercraft:wired_modem_full"}},
|
||||
{pos: [3, 1, 3], state: "computercraft:wired_modem_full{modem:false,peripheral:false}", nbt: {PeripheralAccess: 0b, id: "computercraft:wired_modem_full"}},
|
||||
{pos: [3, 1, 4], state: "minecraft:air"},
|
||||
{pos: [4, 1, 0], state: "minecraft:air"},
|
||||
{pos: [4, 1, 1], state: "minecraft:air"},
|
||||
{pos: [4, 1, 2], state: "minecraft:air"},
|
||||
{pos: [4, 1, 3], state: "minecraft:air"},
|
||||
{pos: [4, 1, 4], state: "minecraft:air"},
|
||||
{pos: [0, 2, 0], state: "minecraft:air"},
|
||||
{pos: [0, 2, 1], state: "minecraft:air"},
|
||||
{pos: [0, 2, 2], state: "minecraft:air"},
|
||||
{pos: [0, 2, 3], state: "minecraft:air"},
|
||||
{pos: [0, 2, 4], state: "minecraft:air"},
|
||||
{pos: [1, 2, 0], state: "minecraft:air"},
|
||||
{pos: [1, 2, 1], state: "minecraft:air"},
|
||||
{pos: [1, 2, 2], state: "minecraft:air"},
|
||||
{pos: [1, 2, 3], state: "minecraft:air"},
|
||||
{pos: [1, 2, 4], state: "minecraft:air"},
|
||||
{pos: [2, 2, 0], state: "minecraft:air"},
|
||||
{pos: [2, 2, 1], state: "minecraft:air"},
|
||||
{pos: [2, 2, 2], state: "minecraft:air"},
|
||||
{pos: [2, 2, 3], state: "minecraft:air"},
|
||||
{pos: [2, 2, 4], state: "minecraft:air"},
|
||||
{pos: [3, 2, 0], state: "minecraft:air"},
|
||||
{pos: [3, 2, 1], state: "minecraft:air"},
|
||||
{pos: [3, 2, 2], state: "minecraft:air"},
|
||||
{pos: [3, 2, 3], state: "minecraft:air"},
|
||||
{pos: [3, 2, 4], state: "minecraft:air"},
|
||||
{pos: [4, 2, 0], state: "minecraft:air"},
|
||||
{pos: [4, 2, 1], state: "minecraft:air"},
|
||||
{pos: [4, 2, 2], state: "minecraft:air"},
|
||||
{pos: [4, 2, 3], state: "minecraft:air"},
|
||||
{pos: [4, 2, 4], state: "minecraft:air"},
|
||||
{pos: [0, 3, 0], state: "minecraft:air"},
|
||||
{pos: [0, 3, 1], state: "minecraft:air"},
|
||||
{pos: [0, 3, 2], state: "minecraft:air"},
|
||||
{pos: [0, 3, 3], state: "minecraft:air"},
|
||||
{pos: [0, 3, 4], state: "minecraft:air"},
|
||||
{pos: [1, 3, 0], state: "minecraft:air"},
|
||||
{pos: [1, 3, 1], state: "minecraft:air"},
|
||||
{pos: [1, 3, 2], state: "minecraft:air"},
|
||||
{pos: [1, 3, 3], state: "minecraft:air"},
|
||||
{pos: [1, 3, 4], state: "minecraft:air"},
|
||||
{pos: [2, 3, 0], state: "minecraft:air"},
|
||||
{pos: [2, 3, 1], state: "minecraft:air"},
|
||||
{pos: [2, 3, 2], state: "minecraft:air"},
|
||||
{pos: [2, 3, 3], state: "minecraft:air"},
|
||||
{pos: [2, 3, 4], state: "minecraft:air"},
|
||||
{pos: [3, 3, 0], state: "minecraft:air"},
|
||||
{pos: [3, 3, 1], state: "minecraft:air"},
|
||||
{pos: [3, 3, 2], state: "minecraft:air"},
|
||||
{pos: [3, 3, 3], state: "minecraft:air"},
|
||||
{pos: [3, 3, 4], state: "minecraft:air"},
|
||||
{pos: [4, 3, 0], state: "minecraft:air"},
|
||||
{pos: [4, 3, 1], state: "minecraft:air"},
|
||||
{pos: [4, 3, 2], state: "minecraft:air"},
|
||||
{pos: [4, 3, 3], state: "minecraft:air"},
|
||||
{pos: [4, 3, 4], state: "minecraft:air"},
|
||||
{pos: [0, 4, 0], state: "minecraft:air"},
|
||||
{pos: [0, 4, 1], state: "minecraft:air"},
|
||||
{pos: [0, 4, 2], state: "minecraft:air"},
|
||||
{pos: [0, 4, 3], state: "minecraft:air"},
|
||||
{pos: [0, 4, 4], state: "minecraft:air"},
|
||||
{pos: [1, 4, 0], state: "minecraft:air"},
|
||||
{pos: [1, 4, 1], state: "minecraft:air"},
|
||||
{pos: [1, 4, 2], state: "minecraft:air"},
|
||||
{pos: [1, 4, 3], state: "minecraft:air"},
|
||||
{pos: [1, 4, 4], state: "minecraft:air"},
|
||||
{pos: [2, 4, 0], state: "minecraft:air"},
|
||||
{pos: [2, 4, 1], state: "minecraft:air"},
|
||||
{pos: [2, 4, 2], state: "minecraft:air"},
|
||||
{pos: [2, 4, 3], state: "minecraft:air"},
|
||||
{pos: [2, 4, 4], state: "minecraft:air"},
|
||||
{pos: [3, 4, 0], state: "minecraft:air"},
|
||||
{pos: [3, 4, 1], state: "minecraft:air"},
|
||||
{pos: [3, 4, 2], state: "minecraft:air"},
|
||||
{pos: [3, 4, 3], state: "minecraft:air"},
|
||||
{pos: [3, 4, 4], state: "minecraft:air"},
|
||||
{pos: [4, 4, 0], state: "minecraft:air"},
|
||||
{pos: [4, 4, 1], state: "minecraft:air"},
|
||||
{pos: [4, 4, 2], state: "minecraft:air"},
|
||||
{pos: [4, 4, 3], state: "minecraft:air"},
|
||||
{pos: [4, 4, 4], state: "minecraft:air"}
|
||||
],
|
||||
entities: [],
|
||||
palette: [
|
||||
"minecraft:polished_andesite",
|
||||
"minecraft:air",
|
||||
"computercraft:wired_modem_full{modem:false,peripheral:false}"
|
||||
]
|
||||
}
|
139
projects/common/src/testMod/resources/data/cctest/structures/printout_test.render_in_frame.snbt
generated
Normal file
139
projects/common/src/testMod/resources/data/cctest/structures/printout_test.render_in_frame.snbt
generated
Normal file
@@ -0,0 +1,139 @@
|
||||
{
|
||||
DataVersion: 3218,
|
||||
size: [5, 5, 5],
|
||||
data: [
|
||||
{pos: [0, 0, 0], state: "minecraft:polished_andesite"},
|
||||
{pos: [0, 0, 1], state: "minecraft:polished_andesite"},
|
||||
{pos: [0, 0, 2], state: "minecraft:polished_andesite"},
|
||||
{pos: [0, 0, 3], state: "minecraft:polished_andesite"},
|
||||
{pos: [0, 0, 4], state: "minecraft:polished_andesite"},
|
||||
{pos: [1, 0, 0], state: "minecraft:polished_andesite"},
|
||||
{pos: [1, 0, 1], state: "minecraft:polished_andesite"},
|
||||
{pos: [1, 0, 2], state: "minecraft:polished_andesite"},
|
||||
{pos: [1, 0, 3], state: "minecraft:polished_andesite"},
|
||||
{pos: [1, 0, 4], state: "minecraft:polished_andesite"},
|
||||
{pos: [2, 0, 0], state: "minecraft:polished_andesite"},
|
||||
{pos: [2, 0, 1], state: "minecraft:polished_andesite"},
|
||||
{pos: [2, 0, 2], state: "minecraft:polished_andesite"},
|
||||
{pos: [2, 0, 3], state: "minecraft:polished_andesite"},
|
||||
{pos: [2, 0, 4], state: "minecraft:polished_andesite"},
|
||||
{pos: [3, 0, 0], state: "minecraft:polished_andesite"},
|
||||
{pos: [3, 0, 1], state: "minecraft:polished_andesite"},
|
||||
{pos: [3, 0, 2], state: "minecraft:polished_andesite"},
|
||||
{pos: [3, 0, 3], state: "minecraft:polished_andesite"},
|
||||
{pos: [3, 0, 4], state: "minecraft:polished_andesite"},
|
||||
{pos: [4, 0, 0], state: "minecraft:polished_andesite"},
|
||||
{pos: [4, 0, 1], state: "minecraft:polished_andesite"},
|
||||
{pos: [4, 0, 2], state: "minecraft:polished_andesite"},
|
||||
{pos: [4, 0, 3], state: "minecraft:polished_andesite"},
|
||||
{pos: [4, 0, 4], state: "minecraft:polished_andesite"},
|
||||
{pos: [0, 1, 0], state: "minecraft:air"},
|
||||
{pos: [0, 1, 1], state: "minecraft:air"},
|
||||
{pos: [0, 1, 2], state: "minecraft:air"},
|
||||
{pos: [0, 1, 3], state: "minecraft:air"},
|
||||
{pos: [0, 1, 4], state: "minecraft:air"},
|
||||
{pos: [1, 1, 0], state: "minecraft:air"},
|
||||
{pos: [1, 1, 1], state: "minecraft:air"},
|
||||
{pos: [1, 1, 2], state: "minecraft:air"},
|
||||
{pos: [1, 1, 3], state: "minecraft:air"},
|
||||
{pos: [1, 1, 4], state: "minecraft:air"},
|
||||
{pos: [2, 1, 0], state: "minecraft:air"},
|
||||
{pos: [2, 1, 1], state: "minecraft:air"},
|
||||
{pos: [2, 1, 2], state: "minecraft:air"},
|
||||
{pos: [2, 1, 3], state: "minecraft:air"},
|
||||
{pos: [2, 1, 4], state: "minecraft:polished_andesite"},
|
||||
{pos: [3, 1, 0], state: "minecraft:air"},
|
||||
{pos: [3, 1, 1], state: "minecraft:air"},
|
||||
{pos: [3, 1, 2], state: "minecraft:air"},
|
||||
{pos: [3, 1, 3], state: "minecraft:air"},
|
||||
{pos: [3, 1, 4], state: "minecraft:air"},
|
||||
{pos: [4, 1, 0], state: "minecraft:air"},
|
||||
{pos: [4, 1, 1], state: "minecraft:air"},
|
||||
{pos: [4, 1, 2], state: "minecraft:air"},
|
||||
{pos: [4, 1, 3], state: "minecraft:air"},
|
||||
{pos: [4, 1, 4], state: "minecraft:air"},
|
||||
{pos: [0, 2, 0], state: "minecraft:air"},
|
||||
{pos: [0, 2, 1], state: "minecraft:air"},
|
||||
{pos: [0, 2, 2], state: "minecraft:air"},
|
||||
{pos: [0, 2, 3], state: "minecraft:air"},
|
||||
{pos: [0, 2, 4], state: "minecraft:air"},
|
||||
{pos: [1, 2, 0], state: "minecraft:air"},
|
||||
{pos: [1, 2, 1], state: "minecraft:air"},
|
||||
{pos: [1, 2, 2], state: "minecraft:air"},
|
||||
{pos: [1, 2, 3], state: "minecraft:air"},
|
||||
{pos: [1, 2, 4], state: "minecraft:air"},
|
||||
{pos: [2, 2, 0], state: "minecraft:air"},
|
||||
{pos: [2, 2, 1], state: "minecraft:air"},
|
||||
{pos: [2, 2, 2], state: "minecraft:air"},
|
||||
{pos: [2, 2, 3], state: "minecraft:air"},
|
||||
{pos: [2, 2, 4], state: "minecraft:polished_andesite"},
|
||||
{pos: [3, 2, 0], state: "minecraft:air"},
|
||||
{pos: [3, 2, 1], state: "minecraft:air"},
|
||||
{pos: [3, 2, 2], state: "minecraft:air"},
|
||||
{pos: [3, 2, 3], state: "minecraft:air"},
|
||||
{pos: [3, 2, 4], state: "minecraft:air"},
|
||||
{pos: [4, 2, 0], state: "minecraft:air"},
|
||||
{pos: [4, 2, 1], state: "minecraft:air"},
|
||||
{pos: [4, 2, 2], state: "minecraft:air"},
|
||||
{pos: [4, 2, 3], state: "minecraft:air"},
|
||||
{pos: [4, 2, 4], state: "minecraft:air"},
|
||||
{pos: [0, 3, 0], state: "minecraft:air"},
|
||||
{pos: [0, 3, 1], state: "minecraft:air"},
|
||||
{pos: [0, 3, 2], state: "minecraft:air"},
|
||||
{pos: [0, 3, 3], state: "minecraft:air"},
|
||||
{pos: [0, 3, 4], state: "minecraft:air"},
|
||||
{pos: [1, 3, 0], state: "minecraft:air"},
|
||||
{pos: [1, 3, 1], state: "minecraft:air"},
|
||||
{pos: [1, 3, 2], state: "minecraft:air"},
|
||||
{pos: [1, 3, 3], state: "minecraft:air"},
|
||||
{pos: [1, 3, 4], state: "minecraft:air"},
|
||||
{pos: [2, 3, 0], state: "minecraft:air"},
|
||||
{pos: [2, 3, 1], state: "minecraft:air"},
|
||||
{pos: [2, 3, 2], state: "minecraft:air"},
|
||||
{pos: [2, 3, 3], state: "minecraft:air"},
|
||||
{pos: [2, 3, 4], state: "minecraft:air"},
|
||||
{pos: [3, 3, 0], state: "minecraft:air"},
|
||||
{pos: [3, 3, 1], state: "minecraft:air"},
|
||||
{pos: [3, 3, 2], state: "minecraft:air"},
|
||||
{pos: [3, 3, 3], state: "minecraft:air"},
|
||||
{pos: [3, 3, 4], state: "minecraft:air"},
|
||||
{pos: [4, 3, 0], state: "minecraft:air"},
|
||||
{pos: [4, 3, 1], state: "minecraft:air"},
|
||||
{pos: [4, 3, 2], state: "minecraft:air"},
|
||||
{pos: [4, 3, 3], state: "minecraft:air"},
|
||||
{pos: [4, 3, 4], state: "minecraft:air"},
|
||||
{pos: [0, 4, 0], state: "minecraft:air"},
|
||||
{pos: [0, 4, 1], state: "minecraft:air"},
|
||||
{pos: [0, 4, 2], state: "minecraft:air"},
|
||||
{pos: [0, 4, 3], state: "minecraft:air"},
|
||||
{pos: [0, 4, 4], state: "minecraft:air"},
|
||||
{pos: [1, 4, 0], state: "minecraft:air"},
|
||||
{pos: [1, 4, 1], state: "minecraft:air"},
|
||||
{pos: [1, 4, 2], state: "minecraft:air"},
|
||||
{pos: [1, 4, 3], state: "minecraft:air"},
|
||||
{pos: [1, 4, 4], state: "minecraft:air"},
|
||||
{pos: [2, 4, 0], state: "minecraft:air"},
|
||||
{pos: [2, 4, 1], state: "minecraft:air"},
|
||||
{pos: [2, 4, 2], state: "minecraft:air"},
|
||||
{pos: [2, 4, 3], state: "minecraft:air"},
|
||||
{pos: [2, 4, 4], state: "minecraft:air"},
|
||||
{pos: [3, 4, 0], state: "minecraft:air"},
|
||||
{pos: [3, 4, 1], state: "minecraft:air"},
|
||||
{pos: [3, 4, 2], state: "minecraft:air"},
|
||||
{pos: [3, 4, 3], state: "minecraft:air"},
|
||||
{pos: [3, 4, 4], state: "minecraft:air"},
|
||||
{pos: [4, 4, 0], state: "minecraft:air"},
|
||||
{pos: [4, 4, 1], state: "minecraft:air"},
|
||||
{pos: [4, 4, 2], state: "minecraft:air"},
|
||||
{pos: [4, 4, 3], state: "minecraft:air"},
|
||||
{pos: [4, 4, 4], state: "minecraft:air"}
|
||||
],
|
||||
entities: [
|
||||
{blockPos: [2, 1, 2], pos: [2.583196949396921d, 1.0d, 2.608974919959593d], nbt: {AbsorptionAmount: 0.0f, Air: 300s, ArmorItems: [{}, {}, {}, {}], Attributes: [{Base: 0.699999988079071d, Name: "minecraft:generic.movement_speed"}], Brain: {memories: {}}, CustomName: '{"text":"printouttest.in_frame_at_night"}', DeathTime: 0s, DisabledSlots: 0, FallDistance: 0.0f, FallFlying: 0b, Fire: -1s, HandItems: [{}, {}], Health: 20.0f, HurtByTimestamp: 0, HurtTime: 0s, Invisible: 1b, Invulnerable: 0b, Marker: 1b, Motion: [0.0d, 0.0d, 0.0d], NoBasePlate: 0b, OnGround: 0b, PortalCooldown: 0, Pos: [221.58319694939692d, -58.0d, 92.60897491995959d], Pose: {}, Rotation: [1.3504658f, 6.7031174f], ShowArms: 0b, Small: 0b, UUID: [I; 1854159985, -991539606, -1317309541, 1483112386], id: "minecraft:armor_stand"}},
|
||||
{blockPos: [2, 2, 3], pos: [2.5d, 2.5d, 3.96875d], nbt: {Air: 300s, Facing: 2b, FallDistance: 0.0f, Fire: -1s, Fixed: 0b, Invisible: 0b, Invulnerable: 0b, Item: {Count: 1b, id: "computercraft:printed_page", tag: {Color0: "eeeeeeeeeeeeeeeeeeeeeeeee", Color1: "eeeeeeeeeeeeeeeeeeeeeeeee", Color10: "eeeeeeeeeeeeeeeeeeeeeeeee", Color11: "eeeeeeeeeeeeeeeeeeeeeeeee", Color12: "eeeeeeeeeeeeeeeeeeeeeeeee", Color13: "eeeeeeeeeeeeeeeeeeeeeeeee", Color14: "eeeeeeeeeeeeeeeeeeeeeeeee", Color15: "eeeeeeeeeeeeeeeeeeeeeeeee", Color16: "eeeeeeeeeeeeeeeeeeeeeeeee", Color17: "eeeeeeeeeeeeeeeeeeeeeeeee", Color18: "eeeeeeeeeeeeeeeeeeeeeeeee", Color19: "eeeeeeeeeeeeeeeeeeeeeeeee", Color2: "eeeeeeeeeeeeeeeeeeeeeeeee", Color20: "eeeeeeeeeeeeeeeeeeeeeeeee", Color3: "eeeeeeeeeeeeeeeeeeeeeeeee", Color4: "eeeeeeeeeeeeeeeeeeeeeeeee", Color5: "eeeeeeeeeeeeeeeeeeeeeeeee", Color6: "eeeeeeeeeeeeeeeeeeeeeeeee", Color7: "eeeeeeeeeeeeeeeeeeeeeeeee", Color8: "eeeeeeeeeeeeeeeeeeeeeeeee", Color9: "eeeeeeeeeeeeeeeeeeeeeeeee", Pages: 1, Text0: "If you're reading this, ", Text1: "the test failed. ", Text10: " ", Text11: " ", Text12: " ", Text13: " ", Text14: " ", Text15: " ", Text16: " ", Text17: " ", Text18: " ", Text19: " ", Text2: " ", Text20: " ", Text3: " ", Text4: " ", Text5: " ", Text6: " ", Text7: " ", Text8: " ", Text9: " ", Title: "a.lua"}}, ItemDropChance: 1.0f, ItemRotation: 0b, Motion: [0.0d, 0.0d, 0.0d], OnGround: 0b, PortalCooldown: 0, Pos: [221.5d, -56.5d, 93.96875d], Rotation: [-540.0f, 0.0f], TileX: 221, TileY: -57, TileZ: 93, UUID: [I; 1972443954, 193152445, -1823446000, -1684171214], id: "minecraft:item_frame"}}
|
||||
],
|
||||
palette: [
|
||||
"minecraft:polished_andesite",
|
||||
"minecraft:air"
|
||||
]
|
||||
}
|
@@ -1,140 +0,0 @@
|
||||
{
|
||||
DataVersion: 2730,
|
||||
size: [5, 5, 5],
|
||||
data: [
|
||||
{pos: [0, 0, 0], state: "minecraft:polished_andesite"},
|
||||
{pos: [0, 0, 1], state: "minecraft:polished_andesite"},
|
||||
{pos: [0, 0, 2], state: "minecraft:polished_andesite"},
|
||||
{pos: [0, 0, 3], state: "minecraft:polished_andesite"},
|
||||
{pos: [0, 0, 4], state: "minecraft:polished_andesite"},
|
||||
{pos: [1, 0, 0], state: "minecraft:polished_andesite"},
|
||||
{pos: [1, 0, 1], state: "minecraft:polished_andesite"},
|
||||
{pos: [1, 0, 2], state: "minecraft:polished_andesite"},
|
||||
{pos: [1, 0, 3], state: "minecraft:polished_andesite"},
|
||||
{pos: [1, 0, 4], state: "minecraft:polished_andesite"},
|
||||
{pos: [2, 0, 0], state: "minecraft:polished_andesite"},
|
||||
{pos: [2, 0, 1], state: "minecraft:polished_andesite"},
|
||||
{pos: [2, 0, 2], state: "minecraft:polished_andesite"},
|
||||
{pos: [2, 0, 3], state: "minecraft:polished_andesite"},
|
||||
{pos: [2, 0, 4], state: "minecraft:polished_andesite"},
|
||||
{pos: [3, 0, 0], state: "minecraft:polished_andesite"},
|
||||
{pos: [3, 0, 1], state: "minecraft:polished_andesite"},
|
||||
{pos: [3, 0, 2], state: "minecraft:polished_andesite"},
|
||||
{pos: [3, 0, 3], state: "minecraft:polished_andesite"},
|
||||
{pos: [3, 0, 4], state: "minecraft:polished_andesite"},
|
||||
{pos: [4, 0, 0], state: "minecraft:polished_andesite"},
|
||||
{pos: [4, 0, 1], state: "minecraft:polished_andesite"},
|
||||
{pos: [4, 0, 2], state: "minecraft:polished_andesite"},
|
||||
{pos: [4, 0, 3], state: "minecraft:polished_andesite"},
|
||||
{pos: [4, 0, 4], state: "minecraft:polished_andesite"},
|
||||
{pos: [0, 1, 0], state: "minecraft:white_concrete"},
|
||||
{pos: [0, 1, 1], state: "minecraft:white_concrete"},
|
||||
{pos: [0, 1, 2], state: "minecraft:white_concrete"},
|
||||
{pos: [0, 1, 3], state: "minecraft:white_concrete"},
|
||||
{pos: [0, 1, 4], state: "minecraft:white_concrete"},
|
||||
{pos: [1, 1, 0], state: "minecraft:white_concrete"},
|
||||
{pos: [1, 1, 1], state: "minecraft:air"},
|
||||
{pos: [1, 1, 2], state: "minecraft:air"},
|
||||
{pos: [1, 1, 3], state: "minecraft:air"},
|
||||
{pos: [1, 1, 4], state: "minecraft:white_concrete"},
|
||||
{pos: [2, 1, 0], state: "minecraft:white_concrete"},
|
||||
{pos: [2, 1, 1], state: "minecraft:air"},
|
||||
{pos: [2, 1, 2], state: "minecraft:air"},
|
||||
{pos: [2, 1, 3], state: "minecraft:air"},
|
||||
{pos: [2, 1, 4], state: "minecraft:white_concrete"},
|
||||
{pos: [3, 1, 0], state: "minecraft:white_concrete"},
|
||||
{pos: [3, 1, 1], state: "minecraft:air"},
|
||||
{pos: [3, 1, 2], state: "minecraft:air"},
|
||||
{pos: [3, 1, 3], state: "minecraft:air"},
|
||||
{pos: [3, 1, 4], state: "minecraft:white_concrete"},
|
||||
{pos: [4, 1, 0], state: "minecraft:white_concrete"},
|
||||
{pos: [4, 1, 1], state: "minecraft:white_concrete"},
|
||||
{pos: [4, 1, 2], state: "minecraft:white_concrete"},
|
||||
{pos: [4, 1, 3], state: "minecraft:white_concrete"},
|
||||
{pos: [4, 1, 4], state: "minecraft:white_concrete"},
|
||||
{pos: [0, 2, 0], state: "minecraft:white_concrete"},
|
||||
{pos: [0, 2, 1], state: "minecraft:white_concrete"},
|
||||
{pos: [0, 2, 2], state: "minecraft:white_concrete"},
|
||||
{pos: [0, 2, 3], state: "minecraft:white_concrete"},
|
||||
{pos: [0, 2, 4], state: "minecraft:white_concrete"},
|
||||
{pos: [1, 2, 0], state: "minecraft:white_concrete"},
|
||||
{pos: [1, 2, 1], state: "minecraft:air"},
|
||||
{pos: [1, 2, 2], state: "minecraft:air"},
|
||||
{pos: [1, 2, 3], state: "minecraft:air"},
|
||||
{pos: [1, 2, 4], state: "minecraft:white_concrete"},
|
||||
{pos: [2, 2, 0], state: "minecraft:white_concrete"},
|
||||
{pos: [2, 2, 1], state: "minecraft:air"},
|
||||
{pos: [2, 2, 2], state: "minecraft:air"},
|
||||
{pos: [2, 2, 3], state: "minecraft:air"},
|
||||
{pos: [2, 2, 4], state: "minecraft:white_concrete"},
|
||||
{pos: [3, 2, 0], state: "minecraft:white_concrete"},
|
||||
{pos: [3, 2, 1], state: "minecraft:air"},
|
||||
{pos: [3, 2, 2], state: "minecraft:air"},
|
||||
{pos: [3, 2, 3], state: "minecraft:air"},
|
||||
{pos: [3, 2, 4], state: "minecraft:white_concrete"},
|
||||
{pos: [4, 2, 0], state: "minecraft:white_concrete"},
|
||||
{pos: [4, 2, 1], state: "minecraft:white_concrete"},
|
||||
{pos: [4, 2, 2], state: "minecraft:white_concrete"},
|
||||
{pos: [4, 2, 3], state: "minecraft:white_concrete"},
|
||||
{pos: [4, 2, 4], state: "minecraft:white_concrete"},
|
||||
{pos: [0, 3, 0], state: "minecraft:white_concrete"},
|
||||
{pos: [0, 3, 1], state: "minecraft:white_concrete"},
|
||||
{pos: [0, 3, 2], state: "minecraft:white_concrete"},
|
||||
{pos: [0, 3, 3], state: "minecraft:white_concrete"},
|
||||
{pos: [0, 3, 4], state: "minecraft:white_concrete"},
|
||||
{pos: [1, 3, 0], state: "minecraft:white_concrete"},
|
||||
{pos: [1, 3, 1], state: "minecraft:air"},
|
||||
{pos: [1, 3, 2], state: "minecraft:air"},
|
||||
{pos: [1, 3, 3], state: "minecraft:air"},
|
||||
{pos: [1, 3, 4], state: "minecraft:white_concrete"},
|
||||
{pos: [2, 3, 0], state: "minecraft:white_concrete"},
|
||||
{pos: [2, 3, 1], state: "minecraft:air"},
|
||||
{pos: [2, 3, 2], state: "minecraft:air"},
|
||||
{pos: [2, 3, 3], state: "minecraft:air"},
|
||||
{pos: [2, 3, 4], state: "minecraft:white_concrete"},
|
||||
{pos: [3, 3, 0], state: "minecraft:white_concrete"},
|
||||
{pos: [3, 3, 1], state: "minecraft:air"},
|
||||
{pos: [3, 3, 2], state: "minecraft:air"},
|
||||
{pos: [3, 3, 3], state: "minecraft:air"},
|
||||
{pos: [3, 3, 4], state: "minecraft:white_concrete"},
|
||||
{pos: [4, 3, 0], state: "minecraft:white_concrete"},
|
||||
{pos: [4, 3, 1], state: "minecraft:white_concrete"},
|
||||
{pos: [4, 3, 2], state: "minecraft:white_concrete"},
|
||||
{pos: [4, 3, 3], state: "minecraft:white_concrete"},
|
||||
{pos: [4, 3, 4], state: "minecraft:white_concrete"},
|
||||
{pos: [0, 4, 0], state: "minecraft:white_concrete"},
|
||||
{pos: [0, 4, 1], state: "minecraft:white_concrete"},
|
||||
{pos: [0, 4, 2], state: "minecraft:white_concrete"},
|
||||
{pos: [0, 4, 3], state: "minecraft:white_concrete"},
|
||||
{pos: [0, 4, 4], state: "minecraft:white_concrete"},
|
||||
{pos: [1, 4, 0], state: "minecraft:white_concrete"},
|
||||
{pos: [1, 4, 1], state: "minecraft:white_concrete"},
|
||||
{pos: [1, 4, 2], state: "minecraft:white_concrete"},
|
||||
{pos: [1, 4, 3], state: "minecraft:white_concrete"},
|
||||
{pos: [1, 4, 4], state: "minecraft:white_concrete"},
|
||||
{pos: [2, 4, 0], state: "minecraft:white_concrete"},
|
||||
{pos: [2, 4, 1], state: "minecraft:white_concrete"},
|
||||
{pos: [2, 4, 2], state: "minecraft:white_concrete"},
|
||||
{pos: [2, 4, 3], state: "minecraft:white_concrete"},
|
||||
{pos: [2, 4, 4], state: "minecraft:white_concrete"},
|
||||
{pos: [3, 4, 0], state: "minecraft:white_concrete"},
|
||||
{pos: [3, 4, 1], state: "minecraft:white_concrete"},
|
||||
{pos: [3, 4, 2], state: "minecraft:white_concrete"},
|
||||
{pos: [3, 4, 3], state: "minecraft:white_concrete"},
|
||||
{pos: [3, 4, 4], state: "minecraft:white_concrete"},
|
||||
{pos: [4, 4, 0], state: "minecraft:white_concrete"},
|
||||
{pos: [4, 4, 1], state: "minecraft:white_concrete"},
|
||||
{pos: [4, 4, 2], state: "minecraft:white_concrete"},
|
||||
{pos: [4, 4, 3], state: "minecraft:white_concrete"},
|
||||
{pos: [4, 4, 4], state: "minecraft:white_concrete"}
|
||||
],
|
||||
entities: [
|
||||
{blockPos: [2, 2, 3], pos: [2.5d, 2.5d, 3.96875d], nbt: {Air: 300s, CanUpdate: 1b, Facing: 2b, FallDistance: 0.0f, Fire: -1s, Fixed: 0b, Invisible: 0b, Invulnerable: 0b, Item: {Count: 1b, id: "computercraft:printed_page", tag: {Color0: "eeeeeeeeeeeeeeeeeeeeeeeee", Color1: "eeeeeeeeeeeeeeeeeeeeeeeee", Color10: "eeeeeeeeeeeeeeeeeeeeeeeee", Color11: "eeeeeeeeeeeeeeeeeeeeeeeee", Color12: "eeeeeeeeeeeeeeeeeeeeeeeee", Color13: "eeeeeeeeeeeeeeeeeeeeeeeee", Color14: "eeeeeeeeeeeeeeeeeeeeeeeee", Color15: "eeeeeeeeeeeeeeeeeeeeeeeee", Color16: "eeeeeeeeeeeeeeeeeeeeeeeee", Color17: "eeeeeeeeeeeeeeeeeeeeeeeee", Color18: "eeeeeeeeeeeeeeeeeeeeeeeee", Color19: "eeeeeeeeeeeeeeeeeeeeeeeee", Color2: "eeeeeeeeeeeeeeeeeeeeeeeee", Color20: "eeeeeeeeeeeeeeeeeeeeeeeee", Color3: "eeeeeeeeeeeeeeeeeeeeeeeee", Color4: "eeeeeeeeeeeeeeeeeeeeeeeee", Color5: "eeeeeeeeeeeeeeeeeeeeeeeee", Color6: "eeeeeeeeeeeeeeeeeeeeeeeee", Color7: "eeeeeeeeeeeeeeeeeeeeeeeee", Color8: "eeeeeeeeeeeeeeeeeeeeeeeee", Color9: "eeeeeeeeeeeeeeeeeeeeeeeee", Pages: 1, Text0: "If you're reading this, ", Text1: "the test failed. ", Text10: " ", Text11: " ", Text12: " ", Text13: " ", Text14: " ", Text15: " ", Text16: " ", Text17: " ", Text18: " ", Text19: " ", Text2: " ", Text20: " ", Text3: " ", Text4: " ", Text5: " ", Text6: " ", Text7: " ", Text8: " ", Text9: " ", Title: "a.lua"}}, ItemDropChance: 1.0f, ItemRotation: 0b, Motion: [0.0d, 0.0d, 0.0d], OnGround: 0b, PortalCooldown: 0, Pos: [10.5d, 7.5d, 44.96875d], Rotation: [180.0f, 0.0f], TileX: 10, TileY: 7, TileZ: 44, UUID: [I; 1043973837, -2076424529, -1762893135, -165665834], id: "minecraft:item_frame"}},
|
||||
{blockPos: [2, 1, 2], pos: [2.583196949396914d, 1.0d, 2.6089749199596d], nbt: {AbsorptionAmount: 0.0f, Air: 300s, ArmorItems: [{}, {}, {}, {}], Attributes: [{Base: 0.699999988079071d, Name: "minecraft:generic.movement_speed"}], Brain: {memories: {}}, CanUpdate: 1b, CustomName: '{"text":"printouttest.in_frame_at_night"}', DeathTime: 0s, DisabledSlots: 0, FallDistance: 0.0f, FallFlying: 0b, Fire: -1s, HandItems: [{}, {}], Health: 20.0f, HurtByTimestamp: 0, HurtTime: 0s, Invisible: 1b, Invulnerable: 0b, Marker: 1b, Motion: [0.0d, 0.0d, 0.0d], NoBasePlate: 0b, OnGround: 0b, PortalCooldown: 0, Pos: [10.583196949396914d, 6.0d, 43.6089749199596d], Pose: {}, Rotation: [1.3504658f, 6.7031174f], ShowArms: 0b, Small: 0b, UUID: [I; -1917933016, 1390888530, -2109873447, -2136052677], id: "minecraft:armor_stand"}}
|
||||
],
|
||||
palette: [
|
||||
"minecraft:polished_andesite",
|
||||
"minecraft:white_concrete",
|
||||
"minecraft:air"
|
||||
]
|
||||
}
|
@@ -20,6 +20,7 @@ dependencies {
|
||||
implementation(libs.asm)
|
||||
|
||||
testFixturesImplementation(libs.slf4j)
|
||||
testFixturesApi(platform(libs.kotlin.platform))
|
||||
testFixturesApi(libs.bundles.test)
|
||||
testFixturesApi(libs.bundles.kotlin)
|
||||
|
||||
@@ -31,7 +32,7 @@ dependencies {
|
||||
tasks.processResources {
|
||||
inputs.property("gitHash", cct.gitHash)
|
||||
|
||||
filesMatching("data/computercraft/lua/rom/help/credits.txt") {
|
||||
filesMatching("data/computercraft/lua/rom/help/credits.md") {
|
||||
expand(mapOf("gitContributors" to cct.gitContributors.map { it.joinToString("\n") }.get()))
|
||||
}
|
||||
}
|
||||
|
@@ -15,10 +15,12 @@ public final class Logging {
|
||||
public static final Marker COMPUTER_ERROR = MarkerFactory.getMarker("COMPUTER_ERROR");
|
||||
public static final Marker HTTP_ERROR = MarkerFactory.getMarker("COMPUTER_ERROR.HTTP");
|
||||
public static final Marker JAVA_ERROR = MarkerFactory.getMarker("COMPUTER_ERROR.JAVA");
|
||||
public static final Marker VM_ERROR = MarkerFactory.getMarker("COMPUTER_ERROR.VM");
|
||||
|
||||
static {
|
||||
HTTP_ERROR.add(COMPUTER_ERROR);
|
||||
JAVA_ERROR.add(JAVA_ERROR);
|
||||
JAVA_ERROR.add(COMPUTER_ERROR);
|
||||
VM_ERROR.add(COMPUTER_ERROR);
|
||||
}
|
||||
|
||||
private Logging() {
|
||||
|
@@ -117,7 +117,7 @@ public class RedstoneAPI implements ILuaAPI {
|
||||
*
|
||||
* @param side The side to set.
|
||||
* @param value The signal strength between 0 and 15.
|
||||
* @throws LuaException If {@code value} is not betwene 0 and 15.
|
||||
* @throws LuaException If {@code value} is not between 0 and 15.
|
||||
* @cc.since 1.51
|
||||
*/
|
||||
@LuaFunction({ "setAnalogOutput", "setAnalogueOutput" })
|
||||
|
@@ -42,8 +42,8 @@ public class BinaryWritableHandle extends HandleGeneric {
|
||||
*
|
||||
* @param arguments The value to write.
|
||||
* @throws LuaException If the file has been closed.
|
||||
* @cc.tparam [1] number The byte to write.
|
||||
* @cc.tparam [2] string The string to write.
|
||||
* @cc.tparam [1] number charcode The byte to write.
|
||||
* @cc.tparam [2] string contents The string to write.
|
||||
* @cc.changed 1.80pr1 Now accepts a string to write multiple bytes.
|
||||
*/
|
||||
@LuaFunction
|
||||
|
@@ -51,7 +51,7 @@ public class EncodedWritableHandle extends HandleGeneric {
|
||||
}
|
||||
|
||||
/**
|
||||
* Write a string of characters to the file, follwing them with a new line character.
|
||||
* Write a string of characters to the file, following them with a new line character.
|
||||
*
|
||||
* @param args The value to write.
|
||||
* @throws LuaException If the file has been closed.
|
||||
|
@@ -17,8 +17,8 @@ import java.net.URI;
|
||||
* A version of {@link WebSocketClientHandshaker13} which doesn't add the {@link HttpHeaderNames#ORIGIN} header to the
|
||||
* original HTTP request.
|
||||
*/
|
||||
public class NoOriginWebSocketHanshakder extends WebSocketClientHandshaker13 {
|
||||
public NoOriginWebSocketHanshakder(URI webSocketURL, WebSocketVersion version, String subprotocol, boolean allowExtensions, HttpHeaders customHeaders, int maxFramePayloadLength) {
|
||||
public class NoOriginWebSocketHandshaker extends WebSocketClientHandshaker13 {
|
||||
public NoOriginWebSocketHandshaker(URI webSocketURL, WebSocketVersion version, String subprotocol, boolean allowExtensions, HttpHeaders customHeaders, int maxFramePayloadLength) {
|
||||
super(webSocketURL, version, subprotocol, allowExtensions, customHeaders, maxFramePayloadLength);
|
||||
}
|
||||
|
@@ -133,7 +133,7 @@ public class Websocket extends Resource<Websocket> {
|
||||
}
|
||||
|
||||
var subprotocol = headers.get(HttpHeaderNames.SEC_WEBSOCKET_PROTOCOL);
|
||||
WebSocketClientHandshaker handshaker = new NoOriginWebSocketHanshakder(
|
||||
WebSocketClientHandshaker handshaker = new NoOriginWebSocketHandshaker(
|
||||
uri, WebSocketVersion.V13, subprotocol, true, headers,
|
||||
options.websocketMessage <= 0 ? MAX_MESSAGE_SIZE : options.websocketMessage
|
||||
);
|
||||
|
@@ -83,6 +83,11 @@ public class CobaltLuaMachine implements ILuaMachine {
|
||||
}
|
||||
});
|
||||
})
|
||||
.errorReporter((e, msg) -> {
|
||||
if (LOG.isErrorEnabled(Logging.VM_ERROR)) {
|
||||
LOG.error(Logging.VM_ERROR, "Error occurred in the Lua runtime. Computer will continue to execute:\n{}", msg.get(), e);
|
||||
}
|
||||
})
|
||||
.build();
|
||||
|
||||
globals = new LuaTable();
|
||||
|
@@ -7,7 +7,7 @@ local expect
|
||||
|
||||
do
|
||||
local h = fs.open("rom/modules/main/cc/expect.lua", "r")
|
||||
local f, err = loadstring(h.readAll(), "@expect.lua")
|
||||
local f, err = loadstring(h.readAll(), "@/rom/modules/main/cc/expect.lua")
|
||||
h.close()
|
||||
|
||||
if not f then error(err) end
|
||||
@@ -467,7 +467,7 @@ function loadfile(filename, mode, env)
|
||||
local file = fs.open(filename, "r")
|
||||
if not file then return nil, "File not found" end
|
||||
|
||||
local func, err = load(file.readAll(), "@" .. fs.getName(filename), mode, env)
|
||||
local func, err = load(file.readAll(), "@/" .. fs.combine(filename), mode, env)
|
||||
file.close()
|
||||
return func, err
|
||||
end
|
||||
@@ -700,7 +700,7 @@ settings.define("motd.path", {
|
||||
|
||||
settings.define("lua.warn_against_use_of_local", {
|
||||
default = true,
|
||||
description = [[Print a message when input in the Lua REPL starts with the word 'local'. Local variables defined in the Lua REPL are be inaccessable on the next input.]],
|
||||
description = [[Print a message when input in the Lua REPL starts with the word 'local'. Local variables defined in the Lua REPL are be inaccessible on the next input.]],
|
||||
type = "boolean",
|
||||
})
|
||||
settings.define("lua.function_args", {
|
||||
|
@@ -52,7 +52,7 @@ This table also accepts the following options:
|
||||
return fs.complete(str, "", {
|
||||
include_files = true,
|
||||
include_dirs = false,
|
||||
included_hidden = false,
|
||||
include_hidden = false,
|
||||
})
|
||||
end)
|
||||
]]
|
||||
|
@@ -16,7 +16,7 @@ function path()
|
||||
return sPath
|
||||
end
|
||||
|
||||
--- Sets the colon-seperated list of directories where help files are searched
|
||||
--- Sets the colon-separated list of directories where help files are searched
|
||||
-- for to `newPath`
|
||||
--
|
||||
-- @tparam string newPath The new path to use.
|
||||
|
@@ -1,6 +1,6 @@
|
||||
--[[- A simple way to run several functions at once.
|
||||
|
||||
Functions are not actually executed simultaniously, but rather this API will
|
||||
Functions are not actually executed simultaneously, but rather this API will
|
||||
automatically switch between them whenever they yield (e.g. whenever they call
|
||||
@{coroutine.yield}, or functions that call that - such as @{os.pullEvent} - or
|
||||
functions that call that, etc - basically, anything that causes the function
|
||||
|
@@ -17,12 +17,13 @@ You can list the names of all peripherals with the `peripherals` program, or the
|
||||
@{peripheral.getNames} function.
|
||||
|
||||
It's also possible to use peripherals which are further away from your computer
|
||||
through the use of @{modem|Wired Modems}. Place one modem against your computer,
|
||||
run Networking Cable to your peripheral, and then place another modem against
|
||||
that block. You can then right click the modem to use (or *attach*) the
|
||||
peripheral. This will print a peripheral name to chat, which can then be used
|
||||
just like a direction name to access the peripheral. You can click on the message
|
||||
to copy the name to your clipboard.
|
||||
through the use of @{modem|Wired Modems}. Place one modem against your computer
|
||||
(you may need to sneak and right click), run Networking Cable to your
|
||||
peripheral, and then place another modem against that block. You can then right
|
||||
click the modem to use (or *attach*) the peripheral. This will print a
|
||||
peripheral name to chat, which can then be used just like a direction name to
|
||||
access the peripheral. You can click on the message to copy the name to your
|
||||
clipboard.
|
||||
|
||||
## Using peripherals
|
||||
|
||||
|
@@ -193,7 +193,7 @@ function send(recipient, message, protocol)
|
||||
local sent = false
|
||||
if recipient == os.getComputerID() then
|
||||
-- Loopback to ourselves
|
||||
os.queueEvent("rednet_message", os.getComputerID(), message_wrapper, protocol)
|
||||
os.queueEvent("rednet_message", os.getComputerID(), message, protocol)
|
||||
sent = true
|
||||
else
|
||||
-- Send on all open modems, to the target and to repeaters
|
||||
@@ -217,9 +217,10 @@ end
|
||||
channel. The message will be received by every device listening to rednet.
|
||||
|
||||
@param message The message to send. This should not contain coroutines or
|
||||
functions, as they will be converted to @{nil}. @tparam[opt] string protocol
|
||||
The "protocol" to send this message under. When using @{rednet.receive} one can
|
||||
filter to only receive messages sent under a particular protocol.
|
||||
functions, as they will be converted to @{nil}.
|
||||
@tparam[opt] string protocol The "protocol" to send this message under. When
|
||||
using @{rednet.receive} one can filter to only receive messages sent under a
|
||||
particular protocol.
|
||||
@see rednet.receive
|
||||
@changed 1.6 Added protocol parameter.
|
||||
@usage Broadcast the words "Hello, world!" to every computer using rednet.
|
||||
@@ -318,7 +319,7 @@ different, or if they only join a given network after "registering" themselves
|
||||
before doing so (eg while offline or part of a different network).
|
||||
|
||||
@tparam string protocol The protocol this computer provides.
|
||||
@tparam string hostname The name this protocol exposes for the given protocol.
|
||||
@tparam string hostname The name this computer exposes for the given protocol.
|
||||
@throws If trying to register a hostname which is reserved, or currently in use.
|
||||
@see rednet.unhost
|
||||
@see rednet.lookup
|
||||
|
@@ -157,7 +157,7 @@ function pagedPrint(text, free_lines)
|
||||
-- Removed the redirector
|
||||
term.redirect(oldTerm)
|
||||
|
||||
-- Propogate errors
|
||||
-- Propagate errors
|
||||
if not ok then
|
||||
error(err, 0)
|
||||
end
|
||||
|
@@ -1,3 +1,42 @@
|
||||
# New features in CC: Tweaked 1.103.0
|
||||
|
||||
* The shell now supports hashbangs (`#!`) (emmachase).
|
||||
* Error messages in `edit` are now displayed in red on advanced computers.
|
||||
* `turtle.getItemDetail` now always includes the `nbt` hash.
|
||||
* Improvements to the display of errors in the shell and REPL.
|
||||
* Turtles, pocket computers, and disks can be undyed by careful application (i.e. crafting) of a sponge.
|
||||
* Turtles can no longer be dyed/undyed by right clicking.
|
||||
|
||||
Several bug fixes:
|
||||
* Several documentation improvements and fixes (ouroborus, LelouBil)
|
||||
* Fix rednet queueing the wrong message when sending a message to the current computer.
|
||||
* Fix the Lua VM crashing when a `__len` metamethod yields.
|
||||
* `pocket.{un,}equipBack` now correctly copies the stack when unequipping an upgrade.
|
||||
* Fix `key` events not being queued while pressing computer shortcuts.
|
||||
|
||||
# New features in CC: Tweaked 1.102.2
|
||||
|
||||
Several bug fixes:
|
||||
* Fix printouts crashing in item frames
|
||||
* Fix disks not being assigned an ID when placed in a disk drive.
|
||||
|
||||
# New features in CC: Tweaked 1.102.1
|
||||
|
||||
Several bug fixes:
|
||||
* Fix crash on Fabric when refuelling with a non-fuel item (emmachase).
|
||||
* Fix crash when calling `pocket.equipBack()` with a wireless modem.
|
||||
* Fix turtles dropping their inventory when moving (emmachase).
|
||||
* Fix crash when inserting items into a full inventory (emmachase).
|
||||
* Simplify wired cable breaking code, fixing items sometimes not dropping.
|
||||
* Correctly handle double chests being treated as single threads under Fabric.
|
||||
* Fix `mouse_up` not being fired under Fabric.
|
||||
* Fix full-block Wired modems not connecting to adjacent cables when placed.
|
||||
* Hide the search tab from the `itemGroups` item details.
|
||||
* Fix speakers playing too loudly.
|
||||
* Change where turtles drop items from, reducing the chance that items clip through blocks.
|
||||
* Fix the `computer_threads` config option not applying under Fabric.
|
||||
* Fix stack overflow in logging code.
|
||||
|
||||
# New features in CC: Tweaked 1.102.0
|
||||
|
||||
* `fs.isReadOnly` now reads filesystem attributes (Lemmmy).
|
||||
@@ -238,7 +277,7 @@ And several bug fixes:
|
||||
|
||||
And several bug fixes:
|
||||
* Fix NPE when using a treasure disk when no treasure disks are available.
|
||||
* Prevent command computers discarding command ouput when certain game rules are off.
|
||||
* Prevent command computers discarding command output when certain game rules are off.
|
||||
* Fix turtles not updating peripherals when upgrades are unequipped (Ronan-H).
|
||||
* Fix computers not shutting down on fatal errors within the Lua VM.
|
||||
* Speakers now correctly stop playing when broken, and sound follows noisy turtles and pocket computers.
|
||||
@@ -248,32 +287,6 @@ And several bug fixes:
|
||||
* Correctly render the transparent background on pocket/normal computers.
|
||||
* Don't apply CraftTweaker actions twice on single-player worlds.
|
||||
|
||||
# New features in CC: Tweaked 1.97.0
|
||||
|
||||
* Update several translations (Anavrins, Jummit, Naheulf).
|
||||
* Add button to view a computer's folder to `/computercraft dump`.
|
||||
* Allow cleaning dyed turtles in a cauldron.
|
||||
* Add scale subcommand to `monitor` program (MCJack123).
|
||||
* Add option to make `textutils.serialize` not write an indent (magiczocker10).
|
||||
* Allow comparing vectors using `==` (fatboychummy).
|
||||
* Improve HTTP error messages for SSL failures.
|
||||
* Allow `craft` program to craft unlimited items (fatboychummy).
|
||||
* Impose some limits on various command queues.
|
||||
* Add buttons to shutdown and terminate to computer GUIs.
|
||||
* Add program subcompletion to several programs (Wojbie).
|
||||
* Update the `help` program to accept and (partially) highlight markdown files.
|
||||
* Remove config option for the debug API.
|
||||
* Allow setting the subprotocol header for websockets.
|
||||
|
||||
And several bug fixes:
|
||||
* Fix NPE when using a treasure disk when no treasure disks are available.
|
||||
* Prevent command computers discarding command ouput when certain game rules are off.
|
||||
* Fix turtles not updating peripherals when upgrades are unequipped (Ronan-H).
|
||||
* Fix computers not shutting down on fatal errors within the Lua VM.
|
||||
* Speakers now correctly stop playing when broken, and sound follows noisy turtles and pocket computers.
|
||||
* Update the `wget` to be more resiliant in the face of user-errors.
|
||||
* Fix exiting `paint` typing "e" in the shell.
|
||||
|
||||
# New features in CC: Tweaked 1.96.0
|
||||
|
||||
* Use lightGrey for folders within the "list" program.
|
||||
@@ -325,7 +338,7 @@ Several bug fixes:
|
||||
# New features in CC: Tweaked 1.95.0
|
||||
|
||||
* Optimise the paint program's initial render.
|
||||
* Several documentation improvments (Gibbo3771, MCJack123).
|
||||
* Several documentation improvements (Gibbo3771, MCJack123).
|
||||
* `fs.combine` now accepts multiple arguments.
|
||||
* Add a setting (`bios.strict_globals`) to error when accidentally declaring a global. (Lupus590).
|
||||
* Add an improved help viewer which allows scrolling up and down (MCJack123).
|
||||
@@ -365,7 +378,7 @@ And several bug fixes:
|
||||
|
||||
* Update Swedish translations (Granddave).
|
||||
* Printers use item tags to check dyes.
|
||||
* HTTP rules may now be targetted for a specific port.
|
||||
* HTTP rules may now be targeted for a specific port.
|
||||
* Don't propagate adjacent redstone signals through computers.
|
||||
|
||||
And several bug fixes:
|
||||
@@ -485,7 +498,7 @@ And several bug fixes:
|
||||
- Add `utf8` lib.
|
||||
- Mirror Lua's behaviour of tail calls more closely. Native functions are no longer tail called, and tail calls are displayed in the stack trace.
|
||||
- `table.unpack` now uses `__len` and `__index` metamethods.
|
||||
- Parser errors now include the token where the error occured.
|
||||
- Parser errors now include the token where the error occurred.
|
||||
* Add `textutils.unserializeJSON`. This can be used to decode standard JSON and stringified-NBT.
|
||||
* The `settings` API now allows "defining" settings. This allows settings to specify a default value and description.
|
||||
* Enable the motd on non-pocket computers.
|
||||
@@ -493,7 +506,7 @@ And several bug fixes:
|
||||
* Add Danish and Korean translations (ChristianLW, mindy15963)
|
||||
* Fire `mouse_up` events in the monitor program.
|
||||
* Allow specifying a timeout to `websocket.receive`.
|
||||
* Increase the maximimum limit for websocket messages.
|
||||
* Increase the maximum limit for websocket messages.
|
||||
* Optimise capacity checking of computer/disk folders.
|
||||
|
||||
And several bug fixes:
|
||||
|
@@ -0,0 +1,390 @@
|
||||
ComputerCraft was created by Daniel "dan200" Ratcliffe, with additional code by Aaron "Cloudy" Mills.
|
||||
Thanks to nitrogenfingers, GopherATL and RamiLego for program contributions.
|
||||
Thanks to Mojang, the Forge team, and the MCP team.
|
||||
Uses LuaJ from http://luaj.sourceforge.net/
|
||||
|
||||
The ComputerCraft 1.76 update was sponsored by MinecraftU and Deep Space.
|
||||
Visit http://www.minecraftu.org and http://www.deepspace.me/space-cadets to find out more.
|
||||
|
||||
Join the ComputerCraft community online at https://computercraft.cc
|
||||
Follow @DanTwoHundred on Twitter!
|
||||
|
||||
To help contribute to CC: Tweaked, browse the source code at https://github.com/cc-tweaked/cc-tweaked.
|
||||
|
||||
# GitHub
|
||||
Numerous people have contributed to CC: Tweaked over the years:
|
||||
|
||||
${gitContributors}
|
||||
|
||||
Thank you to everyone who has contributed
|
||||
|
||||
# Software Licenses
|
||||
CC: Tweaked would not be possible without the work of other open source libraries. Their licenses are included below:
|
||||
|
||||
## Apache 2.0
|
||||
CC: Tweaked contains code from the following Apache 2.0 licensed libraries:
|
||||
|
||||
- Netty (https://github.com/netty/netty)
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
## GNU Lesser General Public License 3.0
|
||||
CC: Tweaked contains code from the following LGPL 3.0 licensed libraries:
|
||||
|
||||
- NightConfig (https://github.com/TheElectronWill/night-config/tree/master)
|
||||
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
|
||||
|
||||
This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below.
|
||||
|
||||
0. Additional Definitions.
|
||||
|
||||
As used herein, "this License" refers to version 3 of the GNU Lesser General Public License, and the "GNU GPL" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"The Library" refers to a covered work governed by this License, other than an Application or a Combined Work as defined below.
|
||||
|
||||
An "Application" is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library.
|
||||
|
||||
A "Combined Work" is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the "Linked Version".
|
||||
|
||||
The "Minimal Corresponding Source" for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version.
|
||||
|
||||
The "Corresponding Application Code" for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work.
|
||||
|
||||
1. Exception to Section 3 of the GNU GPL.
|
||||
You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL.
|
||||
|
||||
2. Conveying Modified Versions.
|
||||
If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version:
|
||||
|
||||
a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or
|
||||
|
||||
b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy.
|
||||
|
||||
3. Object Code Incorporating Material from Library Header Files.
|
||||
The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following:
|
||||
|
||||
a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License.
|
||||
|
||||
b) Accompany the object code with a copy of the GNU GPL and this license document.
|
||||
|
||||
4. Combined Works.
|
||||
You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following:
|
||||
|
||||
a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License.
|
||||
|
||||
b) Accompany the Combined Work with a copy of the GNU GPL and this license document.
|
||||
|
||||
c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document.
|
||||
|
||||
d) Do one of the following:
|
||||
|
||||
0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.
|
||||
|
||||
1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version.
|
||||
|
||||
e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.)
|
||||
|
||||
5. Combined Libraries.
|
||||
You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License.
|
||||
|
||||
b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work.
|
||||
|
||||
6. Revised Versions of the GNU Lesser General Public License.
|
||||
The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation.
|
||||
|
||||
If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall
|
||||
apply, that proxy's public statement of acceptance of any version is permanent authorization for you to choose that version for the Library.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright © 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
"Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
## Cobalt (https://github.com/SquidDev/Cobalt)
|
||||
The MIT License (MIT)
|
||||
|
||||
Original Source: Copyright (c) 2009-2011 Luaj.org. All rights reserved.
|
||||
Modifications: Copyright (c) 2015-2020 SquidDev
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
## double-conversion (https://github.com/google/double-conversion/)
|
||||
Copyright 2006-2012 the V8 project authors. All rights reserved.
|
||||
Java Port Copyright 2021 sir-maniac. All Rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name of Google Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
@@ -1,15 +0,0 @@
|
||||
ComputerCraft was created by Daniel "dan200" Ratcliffe, with additional code by Aaron "Cloudy" Mills.
|
||||
Thanks to nitrogenfingers, GopherATL and RamiLego for program contributions.
|
||||
Thanks to Mojang, the Forge team, and the MCP team.
|
||||
Uses LuaJ from http://luaj.sourceforge.net/
|
||||
|
||||
The ComputerCraft 1.76 update was sponsored by MinecraftU and Deep Space.
|
||||
Visit http://www.minecraftu.org and http://www.deepspace.me/space-cadets to find out more.
|
||||
|
||||
Join the ComputerCraft community online at https://computercraft.cc
|
||||
Follow @DanTwoHundred on Twitter!
|
||||
|
||||
To help contribute to ComputerCraft, browse the source code at https://github.com/dan200/ComputerCraft.
|
||||
|
||||
GitHub Contributors:
|
||||
${gitContributors}
|
@@ -1,2 +1,2 @@
|
||||
io is a standard Lua5.1 API, reimplemented for CraftOS. Not all the features are availiable.
|
||||
io is a standard Lua5.1 API, reimplemented for CraftOS. Not all the features are available.
|
||||
Refer to http://www.lua.org/manual/5.1/ for more information.
|
||||
|
@@ -7,5 +7,5 @@ To terminate a program stuck in a loop, hold Ctrl+T for 1 second.
|
||||
To quickly shutdown a computer, hold Ctrl+S for 1 second.
|
||||
To quickly reboot a computer, hold Ctrl+R for 1 second.
|
||||
|
||||
To learn about the programming APIs availiable, type "apis" or "help apis".
|
||||
To learn about the programming APIs available, type "apis" or "help apis".
|
||||
If you get stuck, visit the forums at http://www.computercraft.info/ for advice and tutorials.
|
||||
|
@@ -1,4 +1,4 @@
|
||||
turtle is an api availiable on Turtles, which controls their movement.
|
||||
turtle is an api available on Turtles, which controls their movement.
|
||||
Functions in the Turtle API:
|
||||
turtle.forward()
|
||||
turtle.back()
|
||||
|
@@ -1,14 +1,17 @@
|
||||
New features in CC: Tweaked 1.102.0
|
||||
New features in CC: Tweaked 1.103.0
|
||||
|
||||
* `fs.isReadOnly` now reads filesystem attributes (Lemmmy).
|
||||
* `IComputerAccess.executeMainThreadTask` no longer roundtrips values through Lua.
|
||||
* The turtle label now animates when the turtle moves.
|
||||
* The shell now supports hashbangs (`#!`) (emmachase).
|
||||
* Error messages in `edit` are now displayed in red on advanced computers.
|
||||
* `turtle.getItemDetail` now always includes the `nbt` hash.
|
||||
* Improvements to the display of errors in the shell and REPL.
|
||||
* Turtles, pocket computers, and disks can be undyed by careful application (i.e. crafting) of a sponge.
|
||||
* Turtles can no longer be dyed/undyed by right clicking.
|
||||
|
||||
Several bug fixes:
|
||||
* Trim spaces from filesystem paths.
|
||||
* Correctly format 12AM/PM with `%I`.
|
||||
* Fix `import.lua` failing to upload a file.
|
||||
* Fix duplicated swing animations on high-ping servers (emmachase).
|
||||
* Fix several issues with sparse Lua tables (Shiranuit).
|
||||
* Several documentation improvements and fixes (ouroborus, LelouBil)
|
||||
* Fix rednet queueing the wrong message when sending a message to the current computer.
|
||||
* Fix the Lua VM crashing when a `__len` metamethod yields.
|
||||
* `pocket.{un,}equipBack` now correctly copies the stack when unequipping an upgrade.
|
||||
* Fix `key` events not being queued while pressing computer shortcuts.
|
||||
|
||||
Type "help changelog" to see the full version history.
|
||||
|
@@ -0,0 +1,173 @@
|
||||
--[[- A pretty-printer for Lua errors.
|
||||
|
||||
:::warning
|
||||
This is an internal module and SHOULD NOT be used in your own code. It may
|
||||
be removed or changed at any time.
|
||||
:::
|
||||
|
||||
This consumes a list of messages and "annotations" and displays the error to the
|
||||
terminal.
|
||||
|
||||
@see cc.internal.syntax.errors For errors produced by the parser.
|
||||
@local
|
||||
]]
|
||||
|
||||
local pretty = require "cc.pretty"
|
||||
local expect = require "cc.expect"
|
||||
local expect, field = expect.expect, expect.field
|
||||
local wrap = require "cc.strings".wrap
|
||||
|
||||
--- Write a message to the screen.
|
||||
-- @tparam cc.pretty.Doc|string msg The message to write.
|
||||
local function display(msg)
|
||||
if type(msg) == "table" then pretty.print(msg) else print(msg) end
|
||||
end
|
||||
|
||||
-- Write a message to the screen, aligning to the current cursor position.
|
||||
-- @tparam cc.pretty.Doc|string msg The message to write.
|
||||
local function display_here(msg, preamble)
|
||||
expect(1, msg, "string", "table")
|
||||
local x = term.getCursorPos()
|
||||
local width, height = term.getSize()
|
||||
width = width - x + 1
|
||||
|
||||
local function newline()
|
||||
local _, y = term.getCursorPos()
|
||||
if y >= height then
|
||||
term.scroll(1)
|
||||
else
|
||||
y = y + 1
|
||||
end
|
||||
|
||||
preamble(y)
|
||||
term.setCursorPos(x, y)
|
||||
end
|
||||
|
||||
if type(msg) == "string" then
|
||||
local lines = wrap(msg, width)
|
||||
term.write(lines[1])
|
||||
for i = 2, #lines do
|
||||
newline()
|
||||
term.write(lines[i])
|
||||
end
|
||||
else
|
||||
local def_colour = term.getTextColour()
|
||||
local function display_impl(doc)
|
||||
expect(1, doc, "table")
|
||||
local kind = doc.tag
|
||||
if kind == "nil" then return
|
||||
elseif kind == "text" then
|
||||
-- TODO: cc.strings.wrap doesn't support a leading indent. We should
|
||||
-- fix that!
|
||||
-- Might also be nice to add a wrap_iter, which returns an iterator over
|
||||
-- start_pos, end_pos instead.
|
||||
|
||||
if doc.colour then term.setTextColour(doc.colour) end
|
||||
local x1 = term.getCursorPos()
|
||||
|
||||
local lines = wrap((" "):rep(x1 - x) .. doc.text, width)
|
||||
term.write(lines[1]:sub(x1 - x + 1))
|
||||
for i = 2, #lines do
|
||||
newline()
|
||||
term.write(lines[i])
|
||||
end
|
||||
|
||||
if doc.colour then term.setTextColour(def_colour) end
|
||||
elseif kind == "concat" then
|
||||
for i = 1, doc.n do display_impl(doc[i]) end
|
||||
else
|
||||
error("Unknown doc " .. kind)
|
||||
end
|
||||
end
|
||||
display_impl(msg)
|
||||
end
|
||||
print()
|
||||
end
|
||||
|
||||
--- A list of colours we can use for error messages.
|
||||
local error_colours = { colours.red, colours.green, colours.magenta, colours.orange }
|
||||
|
||||
--- The accent line used to denote a block of code.
|
||||
local code_accent = pretty.text("\x95", colours.cyan)
|
||||
|
||||
--[[-
|
||||
@tparam { get_pos = function, get_line = function } context
|
||||
The context where the error was reported. This effectively acts as a view
|
||||
over the underlying source, exposing the following functions:
|
||||
- `get_pos`: Get the line and column of an opaque position.
|
||||
- `get_line`: Get the source code for an opaque position.
|
||||
@tparam table message The message to display, as produced by @{cc.internal.syntax.errors}.
|
||||
]]
|
||||
return function(context, message)
|
||||
expect(1, context, "table")
|
||||
expect(2, message, "table")
|
||||
field(context, "get_pos", "function")
|
||||
field(context, "get_line", "function")
|
||||
|
||||
if #message == 0 then error("Message is empty", 2) end
|
||||
|
||||
local error_colour = 1
|
||||
local width = term.getSize()
|
||||
|
||||
for msg_idx = 1, #message do
|
||||
if msg_idx > 1 then print() end
|
||||
|
||||
local msg = message[msg_idx]
|
||||
if type(msg) == "table" and msg.tag == "annotate" then
|
||||
local line, col = context.get_pos(msg.start_pos)
|
||||
local end_line, end_col = context.get_pos(msg.end_pos)
|
||||
local contents = context.get_line(msg.start_pos)
|
||||
|
||||
-- Pick a starting column. We pick the left-most position which fits
|
||||
-- in one of the following:
|
||||
-- - 10 characters after the start column.
|
||||
-- - 5 characters after the end column.
|
||||
-- - The end of the line.
|
||||
if line ~= end_line then end_col = #contents end
|
||||
local start_col = math.max(1, math.min(col + 10, end_col + 5, #contents + 1) - width + 1)
|
||||
|
||||
-- Pick a colour for this annotation.
|
||||
local colour = colours.toBlit(error_colours[error_colour])
|
||||
error_colour = (error_colour % #error_colours) + 1
|
||||
|
||||
-- Print the line number and snippet of code. We display french
|
||||
-- quotes on either side of the string if it is truncated.
|
||||
local str_start, str_end = start_col, start_col + width - 2
|
||||
local prefix, suffix = "", ""
|
||||
if start_col > 1 then
|
||||
str_start = str_start + 1
|
||||
prefix = pretty.text("\xab", colours.grey)
|
||||
end
|
||||
if str_end < #contents then
|
||||
str_end = str_end - 1
|
||||
suffix = pretty.text("\xbb", colours.grey)
|
||||
end
|
||||
|
||||
pretty.print(code_accent .. pretty.text("Line " .. line, colours.cyan))
|
||||
pretty.print(code_accent .. prefix .. pretty.text(contents:sub(str_start, str_end), colours.lightGrey) .. suffix)
|
||||
|
||||
-- Print a line highlighting the region of text.
|
||||
local _, y = term.getCursorPos()
|
||||
pretty.write(code_accent)
|
||||
|
||||
local indicator_end = end_col
|
||||
if end_col > str_end then indicator_end = str_end end
|
||||
|
||||
local indicator_len = indicator_end - col + 1
|
||||
term.setCursorPos(col - start_col + 2, y)
|
||||
term.blit(("\x83"):rep(indicator_len), colour:rep(indicator_len), ("f"):rep(indicator_len))
|
||||
print()
|
||||
|
||||
-- And then print the annotation's message, if present.
|
||||
if msg.msg ~= "" then
|
||||
term.blit("\x95", colour, "f")
|
||||
display_here(msg.msg, function(y)
|
||||
term.setCursorPos(1, y)
|
||||
term.blit("\x95", colour, "f")
|
||||
end)
|
||||
end
|
||||
else
|
||||
display(msg)
|
||||
end
|
||||
end
|
||||
end
|
@@ -0,0 +1,119 @@
|
||||
--[[- Internal tools for working with errors.
|
||||
|
||||
:::warning
|
||||
This is an internal module and SHOULD NOT be used in your own code. It may
|
||||
be removed or changed at any time.
|
||||
:::
|
||||
|
||||
@local
|
||||
]]
|
||||
|
||||
local expect = require "cc.expect".expect
|
||||
local error_printer = require "cc.internal.error_printer"
|
||||
|
||||
local function find_frame(thread, file, line)
|
||||
-- Scan the first 16 frames for something interesting.
|
||||
for offset = 0, 15 do
|
||||
local frame = debug.getinfo(thread, offset, "Sl")
|
||||
if not frame then break end
|
||||
|
||||
if frame.short_src == file and frame.what ~= "C" and frame.currentline == line then
|
||||
return frame
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--[[- Attempt to call the provided function `func` with the provided arguments.
|
||||
|
||||
@tparam function func The function to call.
|
||||
@param ... Arguments to this function.
|
||||
|
||||
@treturn[1] true If the function ran successfully.
|
||||
|
||||
@treturn[2] false If the function failed.
|
||||
@return[2] The error message
|
||||
@treturn[2] coroutine The thread where the error occurred.
|
||||
]]
|
||||
local function try(func, ...)
|
||||
expect(1, func, "function")
|
||||
|
||||
local co = coroutine.create(func)
|
||||
local ok, result = coroutine.resume(co, ...)
|
||||
|
||||
while coroutine.status(co) ~= "dead" do
|
||||
local event = table.pack(os.pullEventRaw(result))
|
||||
if result == nil or event[1] == result or event[1] == "terminate" then
|
||||
ok, result = coroutine.resume(co, table.unpack(event, 1, event.n))
|
||||
end
|
||||
end
|
||||
|
||||
if not ok then return false, result, co end
|
||||
return true
|
||||
end
|
||||
|
||||
--[[- Report additional context about an error.
|
||||
|
||||
@param err The error to report.
|
||||
@tparam coroutine thread The coroutine where the error occurred.
|
||||
@tparam[opt] { [string] = string } source_map Map of chunk names to their contents.
|
||||
]]
|
||||
local function report(err, thread, source_map)
|
||||
expect(2, thread, "thread")
|
||||
expect(3, source_map, "table", "nil")
|
||||
|
||||
if type(err) ~= "string" then return end
|
||||
|
||||
local file, line = err:match("^([^:]+):(%d+):")
|
||||
if not file then return end
|
||||
line = tonumber(line)
|
||||
|
||||
local frame = find_frame(thread, file, line)
|
||||
if not frame or not frame.currentcolumn then return end
|
||||
|
||||
local column = frame.currentcolumn
|
||||
local line_contents
|
||||
if source_map and source_map[frame.source] then
|
||||
-- File exists in the source map.
|
||||
local pos, contents = 1, source_map[frame.source]
|
||||
-- Try to remap our position. The interface for this only makes sense
|
||||
-- for single line sources, but that's sufficient for where we need it
|
||||
-- (the REPL).
|
||||
if type(contents) == "table" then
|
||||
column = column - contents.offset
|
||||
contents = contents.contents
|
||||
end
|
||||
|
||||
for _ = 1, line - 1 do
|
||||
local next_pos = contents:find("\n", pos)
|
||||
if not next_pos then return end
|
||||
pos = next_pos + 1
|
||||
end
|
||||
|
||||
local end_pos = contents:find("\n", pos)
|
||||
line_contents = contents:sub(pos, end_pos and end_pos - 1 or #contents)
|
||||
|
||||
elseif frame.source:sub(1, 2) == "@/" then
|
||||
-- Read the file from disk.
|
||||
local handle = fs.open(frame.source:sub(3), "r")
|
||||
if not handle then return end
|
||||
for _ = 1, line - 1 do handle.readLine() end
|
||||
|
||||
line_contents = handle.readLine()
|
||||
end
|
||||
|
||||
-- Could not determine the line. Bail.
|
||||
if not line_contents or #line_contents == "" then return end
|
||||
|
||||
error_printer({
|
||||
get_pos = function() return line, column end,
|
||||
get_line = function() return line_contents end,
|
||||
}, {
|
||||
{ tag = "annotate", start_pos = column, end_pos = column, msg = "" },
|
||||
})
|
||||
end
|
||||
|
||||
|
||||
return {
|
||||
try = try,
|
||||
report = report,
|
||||
}
|
@@ -1,8 +1,16 @@
|
||||
-- Internal module for handling file uploads. This has NO stability guarantees,
|
||||
-- and so SHOULD NOT be relyed on in user code.
|
||||
--[[- Upload a list of files, as received by the @{event!file_transfer} event.
|
||||
|
||||
:::warning
|
||||
This is an internal module and SHOULD NOT be used in your own code. It may
|
||||
be removed or changed at any time.
|
||||
:::
|
||||
|
||||
@local
|
||||
]]
|
||||
|
||||
local completion = require "cc.completion"
|
||||
|
||||
--- @tparam { file_transfer.TransferredFile ...} files The files to upload.
|
||||
return function(files)
|
||||
local overwrite = {}
|
||||
for _, file in pairs(files) do
|
@@ -0,0 +1,552 @@
|
||||
--[[- The error messages reported by our lexer and parser.
|
||||
|
||||
:::warning
|
||||
This is an internal module and SHOULD NOT be used in your own code. It may
|
||||
be removed or changed at any time.
|
||||
:::
|
||||
|
||||
This provides a list of factory methods which take source positions and produce
|
||||
appropriate error messages targeting that location. These error messages can
|
||||
then be displayed to the user via @{cc.internal.error_printer}.
|
||||
|
||||
@local
|
||||
]]
|
||||
|
||||
local pretty = require "cc.pretty"
|
||||
local expect = require "cc.expect".expect
|
||||
local tokens = require "cc.internal.syntax.parser".tokens
|
||||
|
||||
local function annotate(start_pos, end_pos, msg)
|
||||
if msg == nil and (type(end_pos) == "string" or type(end_pos) == "table" or type(end_pos) == "nil") then
|
||||
end_pos, msg = start_pos, end_pos
|
||||
end
|
||||
|
||||
expect(1, start_pos, "number")
|
||||
expect(2, end_pos, "number")
|
||||
expect(3, msg, "string", "table", "nil")
|
||||
|
||||
return { tag = "annotate", start_pos = start_pos, end_pos = end_pos, msg = msg or "" }
|
||||
end
|
||||
|
||||
--- Format a string as a non-highlighted block of code.
|
||||
--
|
||||
-- @tparam string msg The code to format.
|
||||
-- @treturn cc.pretty.Doc The formatted code.
|
||||
local function code(msg) return pretty.text(msg, colours.lightGrey) end
|
||||
|
||||
--- Maps tokens to a more friendly version.
|
||||
local token_names = setmetatable({
|
||||
-- Specific tokens.
|
||||
[tokens.IDENT] = "identifier",
|
||||
[tokens.NUMBER] = "number",
|
||||
[tokens.STRING] = "string",
|
||||
[tokens.EOF] = "end of file",
|
||||
-- Symbols and keywords
|
||||
[tokens.ADD] = code("+"),
|
||||
[tokens.AND] = code("and"),
|
||||
[tokens.BREAK] = code("break"),
|
||||
[tokens.CBRACE] = code("}"),
|
||||
[tokens.COLON] = code(":"),
|
||||
[tokens.COMMA] = code(","),
|
||||
[tokens.CONCAT] = code(".."),
|
||||
[tokens.CPAREN] = code(")"),
|
||||
[tokens.CSQUARE] = code("]"),
|
||||
[tokens.DIV] = code("/"),
|
||||
[tokens.DO] = code("do"),
|
||||
[tokens.DOT] = code("."),
|
||||
[tokens.DOTS] = code("..."),
|
||||
[tokens.ELSE] = code("else"),
|
||||
[tokens.ELSEIF] = code("elseif"),
|
||||
[tokens.END] = code("end"),
|
||||
[tokens.EQ] = code("=="),
|
||||
[tokens.EQUALS] = code("="),
|
||||
[tokens.FALSE] = code("false"),
|
||||
[tokens.FOR] = code("for"),
|
||||
[tokens.FUNCTION] = code("function"),
|
||||
[tokens.GE] = code(">="),
|
||||
[tokens.GT] = code(">"),
|
||||
[tokens.IF] = code("if"),
|
||||
[tokens.IN] = code("in"),
|
||||
[tokens.LE] = code("<="),
|
||||
[tokens.LEN] = code("#"),
|
||||
[tokens.LOCAL] = code("local"),
|
||||
[tokens.LT] = code("<"),
|
||||
[tokens.MOD] = code("%"),
|
||||
[tokens.MUL] = code("*"),
|
||||
[tokens.NE] = code("~="),
|
||||
[tokens.NIL] = code("nil"),
|
||||
[tokens.NOT] = code("not"),
|
||||
[tokens.OBRACE] = code("{"),
|
||||
[tokens.OPAREN] = code("("),
|
||||
[tokens.OR] = code("or"),
|
||||
[tokens.OSQUARE] = code("["),
|
||||
[tokens.POW] = code("^"),
|
||||
[tokens.REPEAT] = code("repeat"),
|
||||
[tokens.RETURN] = code("return"),
|
||||
[tokens.SEMICOLON] = code(";"),
|
||||
[tokens.SUB] = code("-"),
|
||||
[tokens.THEN] = code("then"),
|
||||
[tokens.TRUE] = code("true"),
|
||||
[tokens.UNTIL] = code("until"),
|
||||
[tokens.WHILE] = code("while"),
|
||||
}, { __index = function(_, name) error("No such token " .. tostring(name), 2) end })
|
||||
|
||||
local errors = {}
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- Lexer errors
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
--[[- A string which ends without a closing quote.
|
||||
|
||||
@tparam number start_pos The start position of the string.
|
||||
@tparam number end_pos The end position of the string.
|
||||
@tparam string quote The kind of quote (`"` or `'`).
|
||||
@return The resulting parse error.
|
||||
]]
|
||||
function errors.unfinished_string(start_pos, end_pos, quote)
|
||||
expect(1, start_pos, "number")
|
||||
expect(2, end_pos, "number")
|
||||
expect(3, quote, "string")
|
||||
|
||||
return {
|
||||
"This string is not finished. Are you missing a closing quote (" .. code(quote) .. ")?",
|
||||
annotate(start_pos, "String started here."),
|
||||
annotate(end_pos, "Expected a closing quote here."),
|
||||
}
|
||||
end
|
||||
|
||||
--[[- A string which ends with an escape sequence (so a literal `"foo\`). This
|
||||
is slightly different from @{unfinished_string}, as we don't want to suggest
|
||||
adding a quote.
|
||||
|
||||
@tparam number start_pos The start position of the string.
|
||||
@tparam number end_pos The end position of the string.
|
||||
@tparam string quote The kind of quote (`"` or `'`).
|
||||
@return The resulting parse error.
|
||||
]]
|
||||
function errors.unfinished_string_escape(start_pos, end_pos, quote)
|
||||
expect(1, start_pos, "number")
|
||||
expect(2, end_pos, "number")
|
||||
expect(3, quote, "string")
|
||||
|
||||
return {
|
||||
"This string is not finished.",
|
||||
annotate(start_pos, "String started here."),
|
||||
annotate(end_pos, "An escape sequence was started here, but with nothing following it."),
|
||||
}
|
||||
end
|
||||
|
||||
--[[- A long string was never finished.
|
||||
|
||||
@tparam number start_pos The start position of the long string delimiter.
|
||||
@tparam number end_pos The end position of the long string delimiter.
|
||||
@tparam number ;em The length of the long string delimiter, excluding the first `[`.
|
||||
@return The resulting parse error.
|
||||
]]
|
||||
function errors.unfinished_long_string(start_pos, end_pos, len)
|
||||
expect(1, start_pos, "number")
|
||||
expect(2, end_pos, "number")
|
||||
expect(3, len, "number")
|
||||
|
||||
return {
|
||||
"This string was never finished.",
|
||||
annotate(start_pos, end_pos, "String was started here."),
|
||||
"We expected a closing delimiter (" .. code("]" .. ("="):rep(len - 1) .. "]") .. ") somewhere after this string was started.",
|
||||
}
|
||||
end
|
||||
|
||||
--[[- Malformed opening to a long string (i.e. `[=`).
|
||||
|
||||
@tparam number start_pos The start position of the long string delimiter.
|
||||
@tparam number end_pos The end position of the long string delimiter.
|
||||
@tparam number len The length of the long string delimiter, excluding the first `[`.
|
||||
@return The resulting parse error.
|
||||
]]
|
||||
function errors.malformed_long_string(start_pos, end_pos, len)
|
||||
expect(1, start_pos, "number")
|
||||
expect(2, end_pos, "number")
|
||||
expect(3, len, "number")
|
||||
|
||||
return {
|
||||
"Incorrect start of a long string.",
|
||||
annotate(start_pos, end_pos),
|
||||
"Tip: If you wanted to start a long string here, add an extra " .. code("[") .. " here.",
|
||||
}
|
||||
end
|
||||
|
||||
--[[- Malformed nesting of a long string.
|
||||
|
||||
@tparam number start_pos The start position of the long string delimiter.
|
||||
@tparam number end_pos The end position of the long string delimiter.
|
||||
@return The resulting parse error.
|
||||
]]
|
||||
function errors.nested_long_str(start_pos, end_pos)
|
||||
expect(1, start_pos, "number")
|
||||
expect(2, end_pos, "number")
|
||||
|
||||
return {
|
||||
code("[[") .. " cannot be nested inside another " .. code("[[ ... ]]"),
|
||||
annotate(start_pos, end_pos),
|
||||
}
|
||||
end
|
||||
|
||||
--[[- A malformed numeric literal.
|
||||
|
||||
@tparam number start_pos The start position of the number.
|
||||
@tparam number end_pos The end position of the number.
|
||||
@return The resulting parse error.
|
||||
]]
|
||||
function errors.malformed_number(start_pos, end_pos)
|
||||
expect(1, start_pos, "number")
|
||||
expect(2, end_pos, "number")
|
||||
|
||||
return {
|
||||
"This isn't a valid number.",
|
||||
annotate(start_pos, end_pos),
|
||||
"Numbers must be in one of the following formats: " .. code("123") .. ", "
|
||||
.. code("3.14") .. ", " .. code("23e35") .. ", " .. code("0x01AF") .. ".",
|
||||
}
|
||||
end
|
||||
|
||||
--[[- A long comment was never finished.
|
||||
|
||||
@tparam number start_pos The start position of the long string delimiter.
|
||||
@tparam number end_pos The end position of the long string delimiter.
|
||||
@tparam number len The length of the long string delimiter, excluding the first `[`.
|
||||
@return The resulting parse error.
|
||||
]]
|
||||
function errors.unfinished_long_comment(start_pos, end_pos, len)
|
||||
expect(1, start_pos, "number")
|
||||
expect(2, end_pos, "number")
|
||||
expect(3, len, "number")
|
||||
|
||||
return {
|
||||
"This comment was never finished.",
|
||||
annotate(start_pos, end_pos, "Comment was started here."),
|
||||
"We expected a closing delimiter (" .. code("]" .. ("="):rep(len - 1) .. "]") .. ") somewhere after this comment was started.",
|
||||
}
|
||||
end
|
||||
|
||||
--[[- `&&` was used instead of `and`.
|
||||
|
||||
@tparam number start_pos The start position of the token.
|
||||
@tparam number end_pos The end position of the token.
|
||||
@return The resulting parse error.
|
||||
]]
|
||||
function errors.wrong_and(start_pos, end_pos)
|
||||
expect(1, start_pos, "number")
|
||||
expect(2, end_pos, "number")
|
||||
|
||||
return {
|
||||
"Unexpected character.",
|
||||
annotate(start_pos, end_pos),
|
||||
"Tip: Replace this with " .. code("and") .. " to check if both values are true.",
|
||||
}
|
||||
end
|
||||
|
||||
--[[- `||` was used instead of `or`.
|
||||
|
||||
@tparam number start_pos The start position of the token.
|
||||
@tparam number end_pos The end position of the token.
|
||||
@return The resulting parse error.
|
||||
]]
|
||||
function errors.wrong_or(start_pos, end_pos)
|
||||
expect(1, start_pos, "number")
|
||||
expect(2, end_pos, "number")
|
||||
|
||||
return {
|
||||
"Unexpected character.",
|
||||
annotate(start_pos, end_pos),
|
||||
"Tip: Replace this with " .. code("or") .. " to check if either value is true.",
|
||||
}
|
||||
end
|
||||
|
||||
--[[- `!=` was used instead of `~=`.
|
||||
|
||||
@tparam number start_pos The start position of the token.
|
||||
@tparam number end_pos The end position of the token.
|
||||
@return The resulting parse error.
|
||||
]]
|
||||
function errors.wrong_ne(start_pos, end_pos)
|
||||
expect(1, start_pos, "number")
|
||||
expect(2, end_pos, "number")
|
||||
|
||||
return {
|
||||
"Unexpected character.",
|
||||
annotate(start_pos, end_pos),
|
||||
"Tip: Replace this with " .. code("~=") .. " to check if two values are not equal.",
|
||||
}
|
||||
end
|
||||
|
||||
--[[- An unexpected character was used.
|
||||
|
||||
@tparam number pos The position of this character.
|
||||
@return The resulting parse error.
|
||||
]]
|
||||
function errors.unexpected_character(pos)
|
||||
expect(1, pos, "number")
|
||||
return {
|
||||
"Unexpected character.",
|
||||
annotate(pos, "This character isn't usable in Lua code."),
|
||||
}
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- Expression parsing errors
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
--[[- A fallback error when we expected an expression but received another token.
|
||||
|
||||
@tparam number token The token id.
|
||||
@tparam number start_pos The start position of the token.
|
||||
@tparam number end_pos The end position of the token.
|
||||
@return The resulting parse error.
|
||||
]]
|
||||
function errors.expected_expression(token, start_pos, end_pos)
|
||||
expect(1, token, "number")
|
||||
expect(2, start_pos, "number")
|
||||
expect(3, end_pos, "number")
|
||||
return {
|
||||
"Unexpected " .. token_names[token] .. ". Expected an expression.",
|
||||
annotate(start_pos, end_pos),
|
||||
}
|
||||
end
|
||||
|
||||
--[[- A fallback error when we expected a variable but received another token.
|
||||
|
||||
@tparam number token The token id.
|
||||
@tparam number start_pos The start position of the token.
|
||||
@tparam number end_pos The end position of the token.
|
||||
@return The resulting parse error.
|
||||
]]
|
||||
function errors.expected_var(token, start_pos, end_pos)
|
||||
expect(1, token, "number")
|
||||
expect(2, start_pos, "number")
|
||||
expect(3, end_pos, "number")
|
||||
return {
|
||||
"Unexpected " .. token_names[token] .. ". Expected a variable name.",
|
||||
annotate(start_pos, end_pos),
|
||||
}
|
||||
end
|
||||
|
||||
--[[- `=` was used in an expression context.
|
||||
|
||||
@tparam number start_pos The start position of the `=` token.
|
||||
@tparam number end_pos The end position of the `=` token.
|
||||
@return The resulting parse error.
|
||||
]]
|
||||
function errors.use_double_equals(start_pos, end_pos)
|
||||
expect(1, start_pos, "number")
|
||||
expect(2, end_pos, "number")
|
||||
|
||||
return {
|
||||
"Unexpected " .. code("=") .. " in expression.",
|
||||
annotate(start_pos, end_pos),
|
||||
"Tip: Replace this with " .. code("==") .. " to check if two values are equal.",
|
||||
}
|
||||
end
|
||||
|
||||
--[[- `=` was used after an expression inside a table.
|
||||
|
||||
@tparam number start_pos The start position of the `=` token.
|
||||
@tparam number end_pos The end position of the `=` token.
|
||||
@return The resulting parse error.
|
||||
]]
|
||||
function errors.table_key_equals(start_pos, end_pos)
|
||||
expect(1, start_pos, "number")
|
||||
expect(2, end_pos, "number")
|
||||
|
||||
return {
|
||||
"Unexpected " .. code("=") .. " in expression.",
|
||||
annotate(start_pos, end_pos),
|
||||
"Tip: Wrap the preceding expression in " .. code("[") .. " and " .. code("]") .. " to use it as a table key.",
|
||||
}
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- Statement parsing errors
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
--[[- A fallback error when we expected a statement but received another token.
|
||||
|
||||
@tparam number token The token id.
|
||||
@tparam number start_pos The start position of the token.
|
||||
@tparam number end_pos The end position of the token.
|
||||
@return The resulting parse error.
|
||||
]]
|
||||
function errors.expected_statement(token, start_pos, end_pos)
|
||||
expect(1, token, "number")
|
||||
expect(2, start_pos, "number")
|
||||
expect(3, end_pos, "number")
|
||||
return {
|
||||
"Unexpected " .. token_names[token] .. ". Expected a statement.",
|
||||
annotate(start_pos, end_pos),
|
||||
}
|
||||
end
|
||||
|
||||
--[[- `local function` was used with a table identifier.
|
||||
|
||||
@tparam number local_start The start position of the `local` token.
|
||||
@tparam number local_end The end position of the `local` token.
|
||||
@tparam number dot_start The start position of the `.` token.
|
||||
@tparam number dot_end The end position of the `.` token.
|
||||
@return The resulting parse error.
|
||||
]]
|
||||
function errors.local_function_dot(local_start, local_end, dot_start, dot_end)
|
||||
expect(1, local_start, "number")
|
||||
expect(2, local_end, "number")
|
||||
expect(3, dot_start, "number")
|
||||
expect(4, dot_end, "number")
|
||||
|
||||
return {
|
||||
"Cannot use " .. code("local function") .. " with a table key.",
|
||||
annotate(dot_start, dot_end, code(".") .. " appears here."),
|
||||
annotate(local_start, local_end, "Tip: " .. "Try removing this " .. code("local") .. " keyword."),
|
||||
}
|
||||
end
|
||||
|
||||
--[[- A statement of the form `x.y z`
|
||||
|
||||
@tparam number pos The position right after this name.
|
||||
@return The resulting parse error.
|
||||
]]
|
||||
function errors.standalone_name(pos)
|
||||
expect(1, pos, "number")
|
||||
|
||||
return {
|
||||
"Unexpected symbol after name.",
|
||||
annotate(pos),
|
||||
"Did you mean to assign this or call it as a function?",
|
||||
}
|
||||
end
|
||||
|
||||
--[[- A statement of the form `x.y`. This is similar to @{standalone_name}, but
|
||||
when the next token is on another line.
|
||||
|
||||
@tparam number pos The position right after this name.
|
||||
@return The resulting parse error.
|
||||
]]
|
||||
function errors.standalone_name_call(pos)
|
||||
expect(1, pos, "number")
|
||||
|
||||
return {
|
||||
"Unexpected symbol after variable.",
|
||||
annotate(pos + 1, "Expected something before the end of the line."),
|
||||
"Tip: Use " .. code("()") .. " to call with no arguments.",
|
||||
}
|
||||
end
|
||||
|
||||
--[[- `then` was expected
|
||||
|
||||
@tparam number if_start The start position of the `if`/`elseif` keyword.
|
||||
@tparam number if_end The end position of the `if`/`elseif` keyword.
|
||||
@tparam number token_pos The current token position.
|
||||
@return The resulting parse error.
|
||||
]]
|
||||
function errors.expected_then(if_start, if_end, token_pos)
|
||||
expect(1, if_start, "number")
|
||||
expect(2, if_end, "number")
|
||||
expect(3, token_pos, "number")
|
||||
|
||||
return {
|
||||
"Expected " .. code("then") .. " after if condition.",
|
||||
annotate(if_start, if_end, "If statement started here."),
|
||||
annotate(token_pos, "Expected " .. code("then") .. " before here."),
|
||||
}
|
||||
|
||||
end
|
||||
|
||||
--[[- `end` was expected
|
||||
|
||||
@tparam number block_start The start position of the block.
|
||||
@tparam number block_end The end position of the block.
|
||||
@tparam number token The current token position.
|
||||
@tparam number token_start The current token position.
|
||||
@tparam number token_end The current token position.
|
||||
@return The resulting parse error.
|
||||
]]
|
||||
function errors.expected_end(block_start, block_end, token, token_start, token_end)
|
||||
return {
|
||||
"Unexpected " .. token_names[token] .. ". Expected " .. code("end") .. " or another statement.",
|
||||
annotate(block_start, block_end, "Block started here."),
|
||||
annotate(token_start, token_end, "Expected end of block here."),
|
||||
}
|
||||
end
|
||||
|
||||
--[[- An unexpected `end` in a statement.
|
||||
|
||||
@tparam number start_pos The start position of the token.
|
||||
@tparam number end_pos The end position of the token.
|
||||
@return The resulting parse error.
|
||||
]]
|
||||
function errors.unexpected_end(start_pos, end_pos)
|
||||
return {
|
||||
"Unexpected " .. code("end") .. ".",
|
||||
annotate(start_pos, end_pos),
|
||||
"Your program contains more " .. code("end") .. "s than needed. Check " ..
|
||||
"each block (" .. code("if") .. ", " .. code("for") .. ", " ..
|
||||
code("function") .. ", ...) only has one " .. code("end") .. ".",
|
||||
}
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- Generic parsing errors
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
--[[- A fallback error when we can't produce anything more useful.
|
||||
|
||||
@tparam number token The token id.
|
||||
@tparam number start_pos The start position of the token.
|
||||
@tparam number end_pos The end position of the token.
|
||||
@return The resulting parse error.
|
||||
]]
|
||||
function errors.unexpected_token(token, start_pos, end_pos)
|
||||
expect(1, token, "number")
|
||||
expect(2, start_pos, "number")
|
||||
expect(3, end_pos, "number")
|
||||
|
||||
return {
|
||||
"Unexpected " .. token_names[token] .. ".",
|
||||
annotate(start_pos, end_pos),
|
||||
}
|
||||
end
|
||||
|
||||
--[[- A parenthesised expression was started but not closed.
|
||||
|
||||
@tparam number open_start The start position of the opening bracket.
|
||||
@tparam number open_end The end position of the opening bracket.
|
||||
@tparam number tok_start The start position of the opening bracket.
|
||||
@return The resulting parse error.
|
||||
]]
|
||||
function errors.unclosed_brackets(open_start, open_end, token, start_pos, end_pos)
|
||||
expect(1, open_start, "number")
|
||||
expect(2, open_end, "number")
|
||||
expect(3, token, "number")
|
||||
expect(4, start_pos, "number")
|
||||
expect(5, end_pos, "number")
|
||||
|
||||
-- TODO: Do we want to be smarter here with where we report the error?
|
||||
return {
|
||||
"Unexpected " .. token_names[token] .. ". Are you missing a closing bracket?",
|
||||
annotate(open_start, open_end, "Brackets were opened here."),
|
||||
annotate(start_pos, end_pos, "Unexpected " .. token_names[token] .. " here."),
|
||||
|
||||
}
|
||||
end
|
||||
|
||||
--[[- Expected `(` to open our function arguments.
|
||||
|
||||
@tparam number token The token id.
|
||||
@tparam number start_pos The start position of the token.
|
||||
@tparam number end_pos The end position of the token.
|
||||
@return The resulting parse error.
|
||||
]]
|
||||
function errors.expected_function_args(token, start_pos, end_pos)
|
||||
return {
|
||||
"Unexpected " .. token_names[token] .. ". Expected " .. code("(") .. " to start function arguments.",
|
||||
annotate(start_pos, end_pos),
|
||||
}
|
||||
end
|
||||
|
||||
return errors
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user