1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-10-17 15:07:38 +00:00

Compare commits

..

9 Commits

Author SHA1 Message Date
Merith-TK
d8b0037cfa CC:R 1.94.1-beta
Update version info, re-brand from CC:Tweaked For Fabric, to CC:Restitched
2021-03-28 22:49:15 -07:00
Merith-TK
91a9e7fdf7 Update .gitignore 2021-03-27 16:40:59 -07:00
Merith-TK
2c3573719b [Patchwork] Fix Network Config
Network config should now work in a stable mannor, the previous person did not port over the imports and thats why this broke in the first place, possibly required import did not exist for fabric at the time?
2021-03-27 15:19:09 -07:00
Devan-Kerman
46bc42d5a7 Update README.md 2021-03-04 19:23:36 -06:00
Devan-Kerman
1b9e93a80f Merge pull request #31 from davidqueneau/fabric
Revert "Cable modems can be placed against all blocks, including ches…
2021-03-04 19:23:07 -06:00
Devan-Kerman
7b93f91ffa Merge pull request #36 from Merith-TK/fabric
Update to Match CC:T version
2021-03-04 19:22:59 -06:00
Merith-TK
31a1027401 Clean up some examples a little bit
Would be good if they didn't crash and burn on entry :).
2021-03-02 23:12:53 -08:00
Merith-TK
e0fc994819 [TODO] Auto-generate monitor models
I didn't think it was worth it, and then I found myself needing to
update a dozen of them. The code isn't especially pretty, but it works,
so that's fine.

Also fixes several issues with us using the wrong texture (closes #572).
I've put together a wiki page[1] which describes each texture in a
little more detail.

[1] https://github.com/SquidDev-CC/CC-Tweaked/wiki/Monitor-texture-reference
2021-03-02 22:47:44 -08:00
David Queneau
00b458c39a Revert "Cable modems can be placed against all blocks, including chests."
This reverts commit 664df62d
2021-02-07 10:47:50 -08:00
22 changed files with 199 additions and 163 deletions

View File

@@ -29,7 +29,7 @@ jobs:
- name: Upload Jar
uses: actions/upload-artifact@v1
with:
name: CC-Tweaked
name: cc-restiched
path: build/libs
- name: Upload Coverage

5
.gitignore vendored
View File

@@ -9,6 +9,11 @@
/run-*
/test-files
# Autogenerated by IDE
/bin
/.settings
.classpath
*.ipr
*.iws
*.iml

View File

@@ -2,8 +2,4 @@
# This is a Work In Progress Port
*it runs and works-ish*
## Reached Parity with CC:T 1.94.0
THis is just a quick patchwork of my attempts at getting CC:R up to date with CC:T
The changelog is located at [PatchWork.md](patchwork.md)
PRs welcome

View File

@@ -9,7 +9,7 @@ targetCompatibility = JavaVersion.VERSION_1_8
version = mod_version
group = "dan200.computercraft"
archivesBaseName = "cc-tweaked-fabric-${mc_version}"
archivesBaseName = "cc-restiched"
repositories {
mavenCentral()
@@ -29,6 +29,8 @@ dependencies {
modImplementation "net.fabricmc:fabric-loader:${fabric_loader_version}"
modImplementation "net.fabricmc.fabric-api:fabric-api:${fabric_api_version}"
compile 'com.electronwill.night-config:json:3.6.0'
modImplementation "me.shedaniel.cloth:config-2:${cloth_config_version}"
modImplementation "io.github.prospector:modmenu:${modmenu_version}"

View File

@@ -2,7 +2,7 @@
org.gradle.jvmargs=-Xmx1G
# Mod properties
mod_version=1.94.0
mod_version=1.94.1-beta
# Minecraft properties
mc_version=1.16.2

View File

@@ -287,3 +287,27 @@ use arg[0] in all usage printouts (#571)
Bump to 1.94.0
```
[TODO] [M3R1-02] Zero Clue how to reimplement this in fabric.
```
c8aeddedd4ed430f9cb6428676ebb4fa39834182
Auto-generate monitor models
I didn't think it was worth it, and then I found myself needing to
update a dozen of them. The code isn't especially pretty, but it works,
so that's fine.
Also fixes several issues with us using the wrong texture (closes #572).
I've put together a wiki page[1] which describes each texture in a
little more detail.
[1] https://github.com/SquidDev-CC/CC-Tweaked/wiki/Monitor-texture-reference
```
7f90f2f7cadce0d5b9177b16626979591bce8137
```
Clean up some examples a little bit
Would be good if they didn't crash and burn on entry :).
```

View File

@@ -9,4 +9,4 @@ pluginManagement {
}
}
rootProject.name = "cc-tweaked-fabric-${mc_version}"
rootProject.name = "cc-restiched"

View File

@@ -6,120 +6,129 @@
package dan200.computercraft.core.apis.http.options;
import com.electronwill.nightconfig.core.CommentedConfig;
import com.electronwill.nightconfig.core.Config;
import com.electronwill.nightconfig.core.InMemoryCommentedFormat;
import com.electronwill.nightconfig.core.UnmodifiableConfig;
import dan200.computercraft.ComputerCraft;
import javax.annotation.Nullable;
import java.util.Locale;
import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
public class AddressRuleConfig {
// TODO haha config is gone, do fix
// TODO FIGURE OUT WHY THE HELL THE PREVIOUS GUY HAD TO COMMENT THIS OUT
public static UnmodifiableConfig makeRule( String host, Action action )
{
CommentedConfig config = InMemoryCommentedFormat.defaultInstance().createConfig( ConcurrentHashMap::new );
config.add( "host", host );
config.add( "action", action.name().toLowerCase( Locale.ROOT ) );
// public static UnmodifiableConfig makeRule( String host, Action action )
// {
// CommentedConfig config = InMemoryCommentedFormat.defaultInstance().createConfig( ConcurrentHashMap::new );
// config.add( "host", host );
// config.add( "action", action.name().toLowerCase( Locale.ROOT ) );
//
// if( host.equals( "*" ) && action == Action.ALLOW )
// {
// config.setComment( "timeout", "The period of time (in milliseconds) to wait before a HTTP request times out. Set to 0 for unlimited." );
// config.add( "timeout", AddressRule.TIMEOUT );
//
// config.setComment( "max_download", "The maximum size (in bytes) that a computer can download in a single request. Note that responses
// may receive more data than allowed, but this data will not be returned to the client." );
// config.set( "max_download", AddressRule.MAX_DOWNLOAD );
//
// config.setComment( "max_upload", "The maximum size (in bytes) that a computer can upload in a single request. This includes headers and
// POST text." );
// config.set( "max_upload", AddressRule.MAX_UPLOAD );
//
// config.setComment( "max_websocket_message", "The maximum size (in bytes) that a computer can send or receive in one websocket packet." );
// config.set( "max_websocket_message", AddressRule.WEBSOCKET_MESSAGE );
// }
//
// return config;
// }
//
// public static boolean checkRule( UnmodifiableConfig builder )
// {
// String hostObj = get( builder, "host", String.class ).orElse( null );
// return hostObj != null && checkEnum( builder, "action", Action.class )
// && check( builder, "port", Number.class )
// && check( builder, "timeout", Number.class )
// && check( builder, "max_upload", Number.class )
// && check( builder, "max_download", Number.class )
// && check( builder, "websocket_message", Number.class )
// && AddressRule.parse( hostObj, port, PartialOptions.DEFAULT ) != null;
// }
//
// @Nullable
// public static AddressRule parseRule( UnmodifiableConfig builder )
// {
// String hostObj = get( builder, "host", String.class ).orElse( null );
// Integer port = get( builder, "port", Number.class ).map( Number::intValue ).orElse( null );
// if( hostObj == null ) return null;
//
// Action action = getEnum( builder, "action", Action.class ).orElse( null );
// Integer timeout = get( builder, "timeout", Number.class ).map( Number::intValue ).orElse( null );
// Long maxUpload = get( builder, "max_upload", Number.class ).map( Number::longValue ).orElse( null );
// Long maxDownload = get( builder, "max_download", Number.class ).map( Number::longValue ).orElse( null );
// Integer websocketMessage = get( builder, "websocket_message", Number.class ).map( Number::intValue ).orElse( null );
//
// PartialOptions options = new PartialOptions(
// action,
// maxUpload,
// maxDownload,
// timeout,
// websocketMessage
// );
//
// return AddressRule.parse( hostObj, port, options );
// }
//
// private static <T> boolean check( UnmodifiableConfig config, String field, Class<T> klass )
// {
// Object value = config.get( field );
// if( value == null || klass.isInstance( value ) ) return true;
//
// ComputerCraft.log.warn( "HTTP rule's {} is not a {}.", field, klass.getSimpleName() );
// return false;
// }
//
// private static <T extends Enum<T>> boolean checkEnum( UnmodifiableConfig config, String field, Class<T> klass )
// {
// Object value = config.get( field );
// if( value == null ) return true;
//
// if( !(value instanceof String) )
// {
// ComputerCraft.log.warn( "HTTP rule's {} is not a string", field );
// return false;
// }
//
// if( parseEnum( klass, (String) value ) == null )
// {
// ComputerCraft.log.warn( "HTTP rule's {} is not a known option", field );
// return false;
// }
//
// return true;
// }
//
// private static <T> Optional<T> get( UnmodifiableConfig config, String field, Class<T> klass )
// {
// Object value = config.get( field );
// return klass.isInstance( value ) ? Optional.of( klass.cast( value ) ) : Optional.empty();
// }
//
// private static <T extends Enum<T>> Optional<T> getEnum( UnmodifiableConfig config, String field, Class<T> klass )
// {
// return get( config, field, String.class ).map( x -> parseEnum( klass, x ) );
// }
//
// @Nullable
// private static <T extends Enum<T>> T parseEnum( Class<T> klass, String x )
// {
// for( T value : klass.getEnumConstants() )
// {
// if( value.name().equalsIgnoreCase( x ) ) return value;
// }
// return null;
// }
if( host.equals( "*" ) && action == Action.ALLOW )
{
config.setComment( "timeout", "The period of time (in milliseconds) to wait before a HTTP request times out. Set to 0 for unlimited." );
config.add( "timeout", AddressRule.TIMEOUT );
config.setComment( "max_download", "The maximum size (in bytes) that a computer can download in a single request. Note that responses may receive more data than allowed, but this data will not be returned to the client." );
config.set( "max_download", AddressRule.MAX_DOWNLOAD );
config.setComment( "max_upload", "The maximum size (in bytes) that a computer can upload in a single request. This includes headers and POST text." );
config.set( "max_upload", AddressRule.MAX_UPLOAD );
config.setComment( "max_websocket_message", "The maximum size (in bytes) that a computer can send or receive in one websocket packet." );
config.set( "max_websocket_message", AddressRule.WEBSOCKET_MESSAGE );
}
return config;
}
public static boolean checkRule( UnmodifiableConfig builder )
{
String hostObj = get( builder, "host", String.class ).orElse( null );
Integer port = get( builder, "port", Number.class ).map( Number::intValue ).orElse( null );
return hostObj != null && checkEnum( builder, "action", Action.class )
&& check( builder, "port", Number.class )
&& check( builder, "timeout", Number.class )
&& check( builder, "max_upload", Number.class )
&& check( builder, "max_download", Number.class )
&& check( builder, "websocket_message", Number.class )
&& AddressRule.parse( hostObj, port, PartialOptions.DEFAULT ) != null;
}
@Nullable
public static AddressRule parseRule( UnmodifiableConfig builder )
{
String hostObj = get( builder, "host", String.class ).orElse( null );
Integer port = get( builder, "port", Number.class ).map( Number::intValue ).orElse( null );
if( hostObj == null ) return null;
Action action = getEnum( builder, "action", Action.class ).orElse( null );
Integer timeout = get( builder, "timeout", Number.class ).map( Number::intValue ).orElse( null );
Long maxUpload = get( builder, "max_upload", Number.class ).map( Number::longValue ).orElse( null );
Long maxDownload = get( builder, "max_download", Number.class ).map( Number::longValue ).orElse( null );
Integer websocketMessage = get( builder, "websocket_message", Number.class ).map( Number::intValue ).orElse( null );
PartialOptions options = new PartialOptions(
action,
maxUpload,
maxDownload,
timeout,
websocketMessage
);
return AddressRule.parse( hostObj, port, options );
}
private static <T> boolean check( UnmodifiableConfig config, String field, Class<T> klass )
{
Object value = config.get( field );
if( value == null || klass.isInstance( value ) ) return true;
ComputerCraft.log.warn( "HTTP rule's {} is not a {}.", field, klass.getSimpleName() );
return false;
}
private static <T extends Enum<T>> boolean checkEnum( UnmodifiableConfig config, String field, Class<T> klass )
{
Object value = config.get( field );
if( value == null ) return true;
if( !(value instanceof String) )
{
ComputerCraft.log.warn( "HTTP rule's {} is not a string", field );
return false;
}
if( parseEnum( klass, (String) value ) == null )
{
ComputerCraft.log.warn( "HTTP rule's {} is not a known option", field );
return false;
}
return true;
}
private static <T> Optional<T> get( UnmodifiableConfig config, String field, Class<T> klass )
{
Object value = config.get( field );
return klass.isInstance( value ) ? Optional.of( klass.cast( value ) ) : Optional.empty();
}
private static <T extends Enum<T>> Optional<T> getEnum( UnmodifiableConfig config, String field, Class<T> klass )
{
return get( config, field, String.class ).map( x -> parseEnum( klass, x ) );
}
@Nullable
private static <T extends Enum<T>> T parseEnum( Class<T> klass, String x )
{
for( T value : klass.getEnumConstants() )
{
if( value.name().equalsIgnoreCase( x ) ) return value;
}
return null;
}
}

View File

@@ -181,19 +181,17 @@ public class BlockCable extends BlockGeneric implements Waterloggable {
// : new ItemStack( ComputerCraftRegistry.ModItems.CABLE.get() );
// }
// Commenting override to allow cable modems to be placed on chests, so that chests can be generic inventory peripherals.
// TODO Perhaps there is a more selective way to achieve this?
// @Override
// @Deprecated
// public boolean canPlaceAt(BlockState state, @Nonnull WorldView world, @Nonnull BlockPos pos) {
// Direction facing = state.get(MODEM)
// .getFacing();
// if (facing == null) {
// return true;
// }
//
// return sideCoversSmallSquare(world, pos.offset(facing), facing.getOpposite());
// }
@Override
@Deprecated
public boolean canPlaceAt(BlockState state, @Nonnull WorldView world, @Nonnull BlockPos pos) {
Direction facing = state.get(MODEM)
.getFacing();
if (facing == null) {
return true;
}
return sideCoversSmallSquare(world, pos.offset(facing), facing.getOpposite());
}
@Nonnull
@Override

View File

@@ -1,4 +1,4 @@
View the source code at https://github.com/mystiacraft/cc-tweaked-fabric
View the source code at https://github.com/Merith-TK/cc-restiched
View the documentation at https://wiki.computercraft.cc
Visit the forum at https://forums.computercraft.cc
You can disable these messages by running "set motd.enable false"

View File

@@ -270,7 +270,7 @@ end
-- @treturn number The combined hexadecimal colour.
-- @usage
-- ```lua
-- colors.rgb(0.7, 0.2, 0.6)
-- colors.unpackRGB(0.7, 0.2, 0.6)
-- -- => 0xb23399
-- ```
function packRGB(r, g, b)
@@ -291,7 +291,7 @@ end
-- @treturn number The blue channel, will be between 0 and 1.
-- @usage
-- ```lua
-- colors.rgb(0xb23399)
-- colors.unpackRGB(0xb23399)
-- -- => 0.7, 0.2, 0.6
-- ```
-- @see colors.packRGB
@@ -317,12 +317,12 @@ end
-- @deprecated Use @{packRGB} or @{unpackRGB} directly.
-- @usage
-- ```lua
-- colors.rgb(0xb23399)
-- colors.unpackRGB(0xb23399)
-- -- => 0.7, 0.2, 0.6
-- ```
-- @usage
-- ```lua
-- colors.rgb(0.7, 0.2, 0.6)
-- colors.unpackRGB(0.7, 0.2, 0.6)
-- -- => 0xb23399
-- ```
function rgb8(r, g, b)

View File

@@ -22,7 +22,7 @@ end
--
-- @tparam string name The name of the disk drive.
-- @treturn boolean If something is in the disk drive.
-- @usage disk.isPresent(false)
-- @usage disk.isPresent("top")
function isPresent(name)
if isDrive(name) then
return peripheral.call(name, "isDiskPresent")

View File

@@ -32,7 +32,7 @@ end
-- @tparam string topic The topic to find
-- @treturn string|nil The path to the given topic's help file, or `nil` if it
-- cannot be found.
-- @usage print(help.lookup("disk"))
-- @usage help.lookup("disk")
function lookup(_sTopic)
expect(1, _sTopic, "string")
-- Look on the path variable

View File

@@ -145,6 +145,7 @@ keys.cimcumflex = keys.circumflex --- @local
--
-- @tparam number code The key code to look up.
-- @treturn string|nil The name of the key, or `nil` if not a valid key code.
-- @usage keys.getName(keys.enter)
function getName(_nKey)
expect(1, _nKey, "number")
return tKeys[_nKey]

View File

@@ -191,7 +191,7 @@ end
-- filter function, which takes the peripheral's name and wrapped table
-- and returns if it should be included in the result.
-- @treturn table... 0 or more wrapped peripherals matching the given filters.
-- @usage local monitors = { peripheral.find("monitor") }
-- @usage { peripheral.find("monitor") }
-- @usage peripheral.find("modem", rednet.open)
function find(ty, filter)
expect(1, ty, "string")

View File

@@ -9,7 +9,7 @@ local expect, field = expect.expect, expect.field
--- Slowly writes string text at current cursor position,
-- character-by-character.
--
-- Like @{write}, this does not insert a newline at the end.
-- Like @{_G.write}, this does not insert a newline at the end.
--
-- @tparam string sText The the text to write to the screen
-- @tparam[opt] number nRate The number of characters to write each second,
@@ -119,8 +119,8 @@ end
-- displayed before prompting.
-- @treturn number The number of lines printed.
-- @usage
-- local width, height = term.getSize()
-- textutils.pagedPrint(("This is a rather verbose dose of repetition.\n"):rep(30), height - 2)
-- local width, height = term.getSize()
-- textutils.pagedPrint(("This is a rather verbose dose of repetition.\n"):rep(30), height - 2)
function pagedPrint(_sText, _nFreeLines)
expect(2, _nFreeLines, "number", "nil")
-- Setup a redirector
@@ -706,7 +706,7 @@ unserialiseJSON = unserialise_json
--
-- @tparam string str The string to encode
-- @treturn string The encoded string.
-- @usage print("https://example.com/?view=" .. textutils.urlEncode(read()))
-- @usage print("https://example.com/?view=" .. textutils.urlEncode("some text&things"))
function urlEncode(str)
expect(1, str, "string")
if str then
@@ -744,8 +744,8 @@ local tEmpty = {}
--
-- @treturn { string... } The (possibly empty) list of completions.
-- @see shell.setCompletionFunction
-- @see read
-- @usage textutils.complete( "pa", getfenv() )
-- @see _G.read
-- @usage textutils.complete( "pa", _ENV )
function complete(sSearchText, tSearchTable)
expect(1, sSearchText, "string")
expect(2, tSearchTable, "table", "nil")

View File

@@ -1,5 +1,5 @@
--- A collection of helper methods for working with input completion, such
-- as that require by @{read}.
-- as that require by @{_G.read}.
--
-- @module cc.completion
-- @see cc.shell.completion For additional helpers to use with
@@ -29,7 +29,7 @@ end
-- @tparam { string... } choices The list of choices to complete from.
-- @tparam[opt] boolean add_space Whether to add a space after the completed item.
-- @treturn { string... } A list of suffixes of matching strings.
-- @usage Call @{read}, completing the names of various animals.
-- @usage Call @{_G.read}, completing the names of various animals.
--
-- local animals = { "dog", "cat", "lion", "unicorn" }
-- read(nil, nil, function(text) return choice(text, animals) end)

View File

@@ -13,11 +13,11 @@
-- @module cc.pretty
-- @usage Print a table to the terminal
-- local pretty = require "cc.pretty"
-- pretty.write(pretty.pretty({ 1, 2, 3 }))
-- pretty.print(pretty.pretty({ 1, 2, 3 }))
--
-- @usage Build a custom document and display it
-- local pretty = require "cc.pretty"
-- pretty.write(pretty.group(pretty.text("hello") .. pretty.space_line .. pretty.text("world")))
-- pretty.print(pretty.group(pretty.text("hello") .. pretty.space_line .. pretty.text("world")))
local expect = require "cc.expect"
local expect, field = expect.expect, expect.field

View File

@@ -8,7 +8,7 @@
-- wrap them using @{build}, or your own custom function.
--
-- @module cc.shell.completion
-- @see cc.completion For more general helpers, suitable for use with @{read}.
-- @see cc.completion For more general helpers, suitable for use with @{_G.read}.
-- @see shell.setCompletionFunction
local expect = require "cc.expect".expect

View File

@@ -1,5 +1,5 @@
Please report bugs at https://github.com/Zundrel/cc-tweaked-fabric. Thanks!
View the documentation at https://wiki.computercraft.cc
Please report bugs at https://github.com/Merith-TK/cc-restiched. Thanks!
View the documentation at https://tweaked.cc
Show off your programs or ask for help at our forum: https://forums.computercraft.cc
You can disable these messages by running "set motd.enable false".
Use "pastebin put" to upload a program to pastebin.

View File

@@ -383,7 +383,7 @@ end
--
-- @tparam string sLine The input to complete.
-- @treturn { string }|nil The list of possible completions.
-- @see read For more information about completion.
-- @see _G.read For more information about completion.
-- @see shell.completeProgram
-- @see shell.setCompletionFunction
-- @see shell.getCompletionInfo
@@ -461,7 +461,7 @@ end
-- The completion function.
-- @see cc.shell.completion Various utilities to help with writing completion functions.
-- @see shell.complete
-- @see read For more information about completion.
-- @see _G.read For more information about completion.
function shell.setCompletionFunction(program, complete)
expect(1, program, "string")
expect(2, complete, "function")

View File

@@ -1,20 +1,21 @@
{
"schemaVersion": 1,
"id": "computercraft",
"name": "CC:T for Fabric",
"name": "CC:Restitched",
"version": "${version}",
"description": "A fork of CC: Tweaked for use with the latest Fabric.",
"description": "CC: Tweaked for Fabric.",
"license": "ComputerCraft Public License",
"icon": "assets/computercraft/pack.png",
"contact": {
"homepage": "https://github.com/mystiacraft/cc-tweaked-fabric",
"issues": "https://github.com/mystiacraft/cc-tweaked-fabric/issues"
"homepage": "https://github.com/Merith-TK/cc-restiched",
"issues": "https://github.com/Merith-TK/cc-restiched/issues"
},
"authors": [
"Daniel Ratcliffe",
"Aaron Mills",
"SquidDev",
"parly"
"parly",
"Merith.TK"
],
"depends": {
"fabricloader": ">=0.4.0",