-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge as much code from CC-Tweaked/mc-1.18.x into CC:R as possible.
Hopefully this will make tracking changes and merging future CC: Tweaked development easier! A lot of this is making whitespace and method ordering even with Tweaked to bring down the diffs, but it also fast forwards us to CC:T 1.99.0 features.
- Loading branch information
Showing
259 changed files
with
7,297 additions
and
8,844 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,20 @@ | ||
image: | ||
file: .gitpod.Dockerfile | ||
file: config/gitpod/Dockerfile | ||
|
||
ports: | ||
- port: 25565 | ||
onOpen: notify | ||
|
||
vscode: | ||
extensions: | ||
- eamodio.gitlens | ||
- github.vscode-pull-request-github | ||
- ms-azuretools.vscode-docker | ||
- redhat.java | ||
- richardwillis.vscode-gradle | ||
- vscjava.vscode-java-debug | ||
- vscode.github | ||
|
||
|
||
tasks: | ||
- init: ./gradlew | ||
- name: Setup pre-commit hool | ||
init: pre-commit install --config config/pre-commit/config.yml --allow-missing-config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,12 +3,11 @@ | |
* Copyright Daniel Ratcliffe, 2011-2021. Do not distribute without permission. | ||
* Send enquiries to [email protected] | ||
*/ | ||
|
||
package dan200.computercraft; | ||
|
||
import dan200.computercraft.core.apis.http.options.Action; | ||
import dan200.computercraft.core.apis.http.options.AddressRule; | ||
import dan200.computercraft.shared.ComputerCraftRegistry.ModBlocks; | ||
import dan200.computercraft.shared.Registry.ModBlocks; | ||
import dan200.computercraft.shared.common.ColourableRecipe; | ||
import dan200.computercraft.shared.computer.core.ClientComputerRegistry; | ||
import dan200.computercraft.shared.computer.core.ServerComputerRegistry; | ||
|
@@ -37,24 +36,20 @@ | |
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
|
||
import java.util.Arrays; | ||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
import static dan200.computercraft.shared.ComputerCraftRegistry.init; | ||
import static dan200.computercraft.shared.Registry.init; | ||
|
||
public final class ComputerCraft implements ModInitializer | ||
{ | ||
public static final String MOD_ID = "computercraft"; | ||
|
||
// Configuration fields | ||
public static int computerSpaceLimit = 1000 * 1000; | ||
public static int floppySpaceLimit = 125 * 1000; | ||
public static int maximumFilesOpen = 128; | ||
public static boolean disableLua51Features = false; | ||
public static String defaultComputerSettings = ""; | ||
public static boolean debugEnable = true; | ||
public static boolean logComputerErrors = true; | ||
public static boolean commandRequireCreative = true; | ||
|
||
|
@@ -64,10 +59,11 @@ public final class ComputerCraft implements ModInitializer | |
|
||
public static boolean httpEnabled = true; | ||
public static boolean httpWebsocketEnabled = true; | ||
public static List<AddressRule> httpRules = Collections.unmodifiableList( Arrays.asList( | ||
public static List<AddressRule> httpRules = List.of( | ||
AddressRule.parse( "$private", null, Action.DENY.toPartial() ), | ||
AddressRule.parse( "*", null, Action.ALLOW.toPartial() ) | ||
) ); | ||
); | ||
|
||
public static int httpMaxRequests = 16; | ||
public static int httpMaxWebsockets = 4; | ||
public static int httpDownloadBandwidth = 32 * 1024 * 1024; | ||
|
@@ -80,7 +76,6 @@ public final class ComputerCraft implements ModInitializer | |
public static int modemHighAltitudeRangeDuringStorm = 384; | ||
public static int maxNotesPerTick = 8; | ||
public static MonitorRenderer monitorRenderer = MonitorRenderer.BEST; | ||
public static double monitorDistanceSq = 4096; | ||
public static int monitorDistance = 65; | ||
public static long monitorBandwidth = 1_000_000; | ||
|
||
|
@@ -98,6 +93,7 @@ public final class ComputerCraft implements ModInitializer | |
|
||
public static int pocketTermWidth = 26; | ||
public static int pocketTermHeight = 20; | ||
|
||
public static int monitorWidth = 8; | ||
public static int monitorHeight = 6; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,6 @@ | |
* Copyright Daniel Ratcliffe, 2011-2021. Do not distribute without permission. | ||
* Send enquiries to [email protected] | ||
*/ | ||
|
||
package dan200.computercraft; | ||
|
||
import dan200.computercraft.api.ComputerCraftAPI.IComputerCraftAPI; | ||
|
@@ -35,7 +34,6 @@ | |
import net.minecraft.core.BlockPos; | ||
import net.minecraft.core.Direction; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.server.MinecraftServer; | ||
import net.minecraft.server.packs.resources.ReloadableResourceManager; | ||
import net.minecraft.world.level.BlockGetter; | ||
import net.minecraft.world.level.Level; | ||
|
@@ -59,36 +57,24 @@ private ComputerCraftAPIImpl() | |
|
||
public static InputStream getResourceFile( String domain, String subPath ) | ||
{ | ||
MinecraftServer server = GameInstanceUtils.getServer(); | ||
if( server != null ) | ||
ReloadableResourceManager manager = (ReloadableResourceManager) ((MinecraftServerAccess) GameInstanceUtils.getServer()).callGetResourceManager(); | ||
try | ||
{ | ||
ReloadableResourceManager manager = (ReloadableResourceManager) ((MinecraftServerAccess) server).callGetResourceManager(); | ||
try | ||
{ | ||
return manager.getResource( new ResourceLocation( domain, subPath ) ) | ||
.getInputStream(); | ||
} | ||
catch( IOException ignored ) | ||
{ | ||
return null; | ||
} | ||
return manager.getResource( new ResourceLocation( domain, subPath ) ).getInputStream(); | ||
} | ||
catch( IOException ignored ) | ||
{ | ||
return null; | ||
} | ||
return null; | ||
} | ||
|
||
@Nonnull | ||
@Override | ||
public String getInstalledVersion() | ||
{ | ||
if( version != null ) | ||
{ | ||
return version; | ||
} | ||
return version = FabricLoader.getInstance() | ||
.getModContainer( ComputerCraft.MOD_ID ) | ||
.map( x -> x.getMetadata() | ||
.getVersion() | ||
.toString() ) | ||
if( version != null ) return version; | ||
return version = FabricLoader.getInstance().getModContainer( ComputerCraft.MOD_ID ) | ||
.map( x -> x.getMetadata().getVersion().toString() ) | ||
.orElse( "unknown" ); | ||
} | ||
|
||
|
@@ -114,14 +100,9 @@ public IWritableMount createSaveDirMount( @Nonnull Level world, @Nonnull String | |
@Override | ||
public IMount createResourceMount( @Nonnull String domain, @Nonnull String subPath ) | ||
{ | ||
MinecraftServer server = GameInstanceUtils.getServer(); | ||
if( server != null ) | ||
{ | ||
ReloadableResourceManager manager = (ReloadableResourceManager) ((MinecraftServerAccess) server).callGetResourceManager(); | ||
ResourceMount mount = ResourceMount.get( domain, subPath, manager ); | ||
return mount.exists( "" ) ? mount : null; | ||
} | ||
return null; | ||
ReloadableResourceManager manager = (ReloadableResourceManager) ((MinecraftServerAccess) GameInstanceUtils.getServer()).callGetResourceManager(); | ||
ResourceMount mount = ResourceMount.get( domain, subPath, manager ); | ||
return mount.exists( "" ) ? mount : null; | ||
} | ||
|
||
@Override | ||
|
@@ -131,39 +112,39 @@ public void registerPeripheralProvider( @Nonnull IPeripheralProvider provider ) | |
} | ||
|
||
@Override | ||
public void registerTurtleUpgrade( @Nonnull ITurtleUpgrade upgrade ) | ||
public void registerGenericSource( @Nonnull GenericSource source ) | ||
{ | ||
TurtleUpgrades.register( upgrade ); | ||
GenericMethod.register( source ); | ||
} | ||
|
||
@Override | ||
public void registerBundledRedstoneProvider( @Nonnull IBundledRedstoneProvider provider ) | ||
public void registerTurtleUpgrade( @Nonnull ITurtleUpgrade upgrade ) | ||
{ | ||
BundledRedstone.register( provider ); | ||
TurtleUpgrades.register( upgrade ); | ||
} | ||
|
||
@Override | ||
public int getBundledRedstoneOutput( @Nonnull Level world, @Nonnull BlockPos pos, @Nonnull Direction side ) | ||
public void registerPocketUpgrade( @Nonnull IPocketUpgrade upgrade ) | ||
{ | ||
return BundledRedstone.getDefaultOutput( world, pos, side ); | ||
PocketUpgrades.register( upgrade ); | ||
} | ||
|
||
@Override | ||
public void registerMediaProvider( @Nonnull IMediaProvider provider ) | ||
public void registerBundledRedstoneProvider( @Nonnull IBundledRedstoneProvider provider ) | ||
{ | ||
MediaProviders.register( provider ); | ||
BundledRedstone.register( provider ); | ||
} | ||
|
||
@Override | ||
public void registerPocketUpgrade( @Nonnull IPocketUpgrade upgrade ) | ||
public int getBundledRedstoneOutput( @Nonnull Level world, @Nonnull BlockPos pos, @Nonnull Direction side ) | ||
{ | ||
PocketUpgrades.register( upgrade ); | ||
return BundledRedstone.getDefaultOutput( world, pos, side ); | ||
} | ||
|
||
@Override | ||
public void registerGenericSource( @Nonnull GenericSource source ) | ||
public void registerMediaProvider( @Nonnull IMediaProvider provider ) | ||
{ | ||
GenericMethod.register( source ); | ||
MediaProviders.register( provider ); | ||
} | ||
|
||
@Nonnull | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
src/main/java/dan200/computercraft/api/ComputerCraftTags.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* This file is part of the public ComputerCraft API - http://www.computercraft.info | ||
* Copyright Daniel Ratcliffe, 2011-2021. This API may be redistributed unmodified and in full only. | ||
* For help using the API, and posting your mods, visit the forums at computercraft.info. | ||
*/ | ||
package dan200.computercraft.api; | ||
|
||
import dan200.computercraft.ComputerCraft; | ||
import net.fabricmc.fabric.api.tag.TagFactory; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.tags.Tag; | ||
import net.minecraft.world.item.Item; | ||
import net.minecraft.world.level.block.Block; | ||
|
||
/** | ||
* Tags provided by ComputerCraft. | ||
*/ | ||
public class ComputerCraftTags | ||
{ | ||
public static class Items | ||
{ | ||
public static final Tag.Named<Item> COMPUTER = make( "computer" ); | ||
public static final Tag.Named<Item> TURTLE = make( "turtle" ); | ||
public static final Tag.Named<Item> WIRED_MODEM = make( "wired_modem" ); | ||
public static final Tag.Named<Item> MONITOR = make( "monitor" ); | ||
|
||
private static Tag.Named<Item> make( String name ) | ||
{ | ||
return TagFactory.ITEM.create( new ResourceLocation( ComputerCraft.MOD_ID, name ) ); | ||
} | ||
} | ||
|
||
public static class Blocks | ||
{ | ||
public static final Tag.Named<Block> COMPUTER = make( "computer" ); | ||
public static final Tag.Named<Block> TURTLE = make( "turtle" ); | ||
public static final Tag.Named<Block> WIRED_MODEM = make( "wired_modem" ); | ||
public static final Tag.Named<Block> MONITOR = make( "monitor" ); | ||
|
||
/** | ||
* Blocks which can be broken by any turtle tool. | ||
*/ | ||
public static final Tag.Named<Block> TURTLE_ALWAYS_BREAKABLE = make( "turtle_always_breakable" ); | ||
|
||
/** | ||
* Blocks which can be broken by the default shovel tool. | ||
*/ | ||
public static final Tag.Named<Block> TURTLE_SHOVEL_BREAKABLE = make( "turtle_shovel_harvestable" ); | ||
|
||
/** | ||
* Blocks which can be broken with the default sword tool. | ||
*/ | ||
public static final Tag.Named<Block> TURTLE_SWORD_BREAKABLE = make( "turtle_sword_harvestable" ); | ||
|
||
/** | ||
* Blocks which can be broken with the default hoe tool. | ||
*/ | ||
public static final Tag.Named<Block> TURTLE_HOE_BREAKABLE = make( "turtle_hoe_harvestable" ); | ||
|
||
private static Tag.Named<Block> make( String name ) | ||
{ | ||
return TagFactory.BLOCK.create( new ResourceLocation( ComputerCraft.MOD_ID, name ) ); | ||
} | ||
} | ||
} |
Oops, something went wrong.