mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2024-12-14 04:00:30 +00:00
Remove all references to the ComputerCraft class
Another ugly commit, not thrilled about it: - Move all config values to a separate Config class. - Replace ComputerCraft.log with class-specific loggers. - Replace ComputerCraft.MOD_ID with ComputerCraftAPI.MOD_ID
This commit is contained in:
parent
48285404b9
commit
4d50b48ea6
@ -14,13 +14,12 @@ import dan200.computercraft.api.pocket.PocketUpgradeSerialiser;
|
||||
import dan200.computercraft.api.turtle.TurtleUpgradeSerialiser;
|
||||
import dan200.computercraft.api.turtle.event.TurtleRefuelEvent;
|
||||
import dan200.computercraft.impl.TurtleRefuelHandlers;
|
||||
import dan200.computercraft.shared.Config;
|
||||
import dan200.computercraft.shared.ModRegistry;
|
||||
import dan200.computercraft.shared.config.ConfigSpec;
|
||||
import dan200.computercraft.shared.peripheral.generic.data.FluidData;
|
||||
import dan200.computercraft.shared.peripheral.generic.methods.EnergyMethods;
|
||||
import dan200.computercraft.shared.peripheral.generic.methods.FluidMethods;
|
||||
import dan200.computercraft.shared.peripheral.generic.methods.InventoryMethods;
|
||||
import dan200.computercraft.shared.peripheral.monitor.MonitorRenderer;
|
||||
import dan200.computercraft.shared.platform.NetworkHandler;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
||||
@ -31,56 +30,14 @@ import net.minecraftforge.fml.event.config.ModConfigEvent;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
import net.minecraftforge.registries.NewRegistryEvent;
|
||||
import net.minecraftforge.registries.RegistryBuilder;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.OptionalInt;
|
||||
|
||||
@Mod(ComputerCraft.MOD_ID)
|
||||
@Mod.EventBusSubscriber(modid = ComputerCraft.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||
@Mod(ComputerCraftAPI.MOD_ID)
|
||||
@Mod.EventBusSubscriber(modid = ComputerCraftAPI.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||
public final class ComputerCraft {
|
||||
public static final String MOD_ID = "computercraft";
|
||||
|
||||
public static int computerSpaceLimit = 1000 * 1000;
|
||||
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;
|
||||
public static int modemRangeDuringStorm = 64;
|
||||
public static int modemHighAltitudeRangeDuringStorm = 384;
|
||||
public static int maxNotesPerTick = 8;
|
||||
public static MonitorRenderer monitorRenderer = MonitorRenderer.BEST;
|
||||
public static int monitorDistance = 65;
|
||||
public static long monitorBandwidth = 1_000_000;
|
||||
|
||||
public static boolean turtlesNeedFuel = true;
|
||||
public static int turtleFuelLimit = 20000;
|
||||
public static int advancedTurtleFuelLimit = 100000;
|
||||
public static boolean turtlesObeyBlockProtection = true;
|
||||
public static boolean turtlesCanPush = true;
|
||||
|
||||
public static int computerTermWidth = 51;
|
||||
public static int computerTermHeight = 19;
|
||||
|
||||
public static final int turtleTermWidth = 39;
|
||||
public static final int turtleTermHeight = 13;
|
||||
|
||||
public static int pocketTermWidth = 26;
|
||||
public static int pocketTermHeight = 20;
|
||||
|
||||
public static int monitorWidth = 8;
|
||||
public static int monitorHeight = 6;
|
||||
|
||||
public static int uploadNagDelay = 5;
|
||||
|
||||
public static final Logger log = LoggerFactory.getLogger(MOD_ID);
|
||||
|
||||
public ComputerCraft() {
|
||||
Config.setup();
|
||||
ConfigSpec.setup();
|
||||
ModRegistry.register();
|
||||
|
||||
// Register a fallback handler for the turtle refuel event.
|
||||
@ -129,11 +86,11 @@ public final class ComputerCraft {
|
||||
|
||||
@SubscribeEvent
|
||||
public static void sync(ModConfigEvent.Loading event) {
|
||||
Config.sync(event.getConfig());
|
||||
ConfigSpec.sync(event.getConfig());
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void sync(ModConfigEvent.Reloading event) {
|
||||
Config.sync(event.getConfig());
|
||||
ConfigSpec.sync(event.getConfig());
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@
|
||||
package dan200.computercraft;
|
||||
|
||||
import com.google.auto.service.AutoService;
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import dan200.computercraft.api.detail.BlockReference;
|
||||
import dan200.computercraft.api.detail.DetailRegistry;
|
||||
import dan200.computercraft.api.detail.IDetailProvider;
|
||||
@ -80,7 +81,7 @@ public final class ComputerCraftAPIImpl implements ComputerCraftAPIForgeService
|
||||
@Override
|
||||
public String getInstalledVersion() {
|
||||
if (version != null) return version;
|
||||
return version = ModList.get().getModContainerById(ComputerCraft.MOD_ID)
|
||||
return version = ModList.get().getModContainerById(ComputerCraftAPI.MOD_ID)
|
||||
.map(x -> x.getModInfo().getVersion().toString())
|
||||
.orElse("unknown");
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
*/
|
||||
package dan200.computercraft.client;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import dan200.computercraft.api.client.ComputerCraftAPIClient;
|
||||
import dan200.computercraft.api.client.turtle.TurtleUpgradeModeller;
|
||||
import dan200.computercraft.client.gui.*;
|
||||
@ -57,12 +57,12 @@ public final class ClientRegistry {
|
||||
*/
|
||||
public static void register() {
|
||||
ComputerCraftAPIClient.registerTurtleUpgradeModeller(ModRegistry.TurtleSerialisers.SPEAKER.get(), TurtleUpgradeModeller.sided(
|
||||
new ResourceLocation(ComputerCraft.MOD_ID, "block/turtle_speaker_left"),
|
||||
new ResourceLocation(ComputerCraft.MOD_ID, "block/turtle_speaker_right")
|
||||
new ResourceLocation(ComputerCraftAPI.MOD_ID, "block/turtle_speaker_left"),
|
||||
new ResourceLocation(ComputerCraftAPI.MOD_ID, "block/turtle_speaker_right")
|
||||
));
|
||||
ComputerCraftAPIClient.registerTurtleUpgradeModeller(ModRegistry.TurtleSerialisers.WORKBENCH.get(), TurtleUpgradeModeller.sided(
|
||||
new ResourceLocation(ComputerCraft.MOD_ID, "block/turtle_crafting_table_left"),
|
||||
new ResourceLocation(ComputerCraft.MOD_ID, "block/turtle_crafting_table_right")
|
||||
new ResourceLocation(ComputerCraftAPI.MOD_ID, "block/turtle_crafting_table_left"),
|
||||
new ResourceLocation(ComputerCraftAPI.MOD_ID, "block/turtle_crafting_table_right")
|
||||
));
|
||||
ComputerCraftAPIClient.registerTurtleUpgradeModeller(ModRegistry.TurtleSerialisers.WIRELESS_MODEM_NORMAL.get(), new TurtleModemModeller(false));
|
||||
ComputerCraftAPIClient.registerTurtleUpgradeModeller(ModRegistry.TurtleSerialisers.WIRELESS_MODEM_ADVANCED.get(), new TurtleModemModeller(true));
|
||||
@ -97,7 +97,7 @@ public final class ClientRegistry {
|
||||
@SafeVarargs
|
||||
@SuppressWarnings("deprecation")
|
||||
private static void registerItemProperty(String name, ItemPropertyFunction getter, Supplier<? extends Item>... items) {
|
||||
var id = new ResourceLocation(ComputerCraft.MOD_ID, name);
|
||||
var id = new ResourceLocation(ComputerCraftAPI.MOD_ID, name);
|
||||
for (var item : items) ItemProperties.register(item.get(), id, getter);
|
||||
}
|
||||
|
||||
@ -125,15 +125,10 @@ public final class ClientRegistry {
|
||||
};
|
||||
|
||||
public static void registerExtraModels(Consumer<ResourceLocation> register) {
|
||||
for (var model : EXTRA_MODELS) register.accept(new ResourceLocation(ComputerCraft.MOD_ID, model));
|
||||
for (var model : EXTRA_MODELS) register.accept(new ResourceLocation(ComputerCraftAPI.MOD_ID, model));
|
||||
}
|
||||
|
||||
public static void registerItemColours(BiConsumer<ItemColor, ItemLike> register) {
|
||||
if (ModRegistry.Items.DISK == null || ModRegistry.Blocks.TURTLE_NORMAL == null) {
|
||||
ComputerCraft.log.warn("Block/item registration has failed. Skipping registration of item colours.");
|
||||
return;
|
||||
}
|
||||
|
||||
register.accept(
|
||||
(stack, layer) -> layer == 1 ? ((ItemDisk) stack.getItem()).getColour(stack) : 0xFFFFFF,
|
||||
ModRegistry.Items.DISK.get()
|
||||
|
@ -5,7 +5,7 @@
|
||||
*/
|
||||
package dan200.computercraft.client;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import dan200.computercraft.client.sound.SpeakerSound;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.client.event.*;
|
||||
@ -18,7 +18,7 @@ import net.minecraftforge.fml.common.Mod;
|
||||
/**
|
||||
* Forge-specific dispatch for {@link ClientHooks}.
|
||||
*/
|
||||
@Mod.EventBusSubscriber(modid = ComputerCraft.MOD_ID, value = Dist.CLIENT)
|
||||
@Mod.EventBusSubscriber(modid = ComputerCraftAPI.MOD_ID, value = Dist.CLIENT)
|
||||
public final class ForgeClientHooks {
|
||||
private ForgeClientHooks() {
|
||||
}
|
||||
|
@ -6,7 +6,6 @@
|
||||
package dan200.computercraft.client.gui;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.client.gui.widgets.ComputerSidebar;
|
||||
import dan200.computercraft.client.gui.widgets.DynamicImageButton;
|
||||
import dan200.computercraft.client.gui.widgets.WidgetTerminal;
|
||||
@ -17,6 +16,7 @@ import dan200.computercraft.shared.computer.core.InputHandler;
|
||||
import dan200.computercraft.shared.computer.inventory.ContainerComputerBase;
|
||||
import dan200.computercraft.shared.computer.upload.FileUpload;
|
||||
import dan200.computercraft.shared.computer.upload.UploadResult;
|
||||
import dan200.computercraft.shared.config.Config;
|
||||
import dan200.computercraft.shared.network.server.UploadFileMessage;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.Util;
|
||||
@ -25,6 +25,8 @@ import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.IOException;
|
||||
@ -39,6 +41,8 @@ import java.util.concurrent.TimeUnit;
|
||||
import static dan200.computercraft.core.util.Nullability.assertNonNull;
|
||||
|
||||
public abstract class ComputerScreenBase<T extends ContainerComputerBase> extends AbstractContainerScreen<T> {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ComputerScreenBase.class);
|
||||
|
||||
private static final Component OK = Component.translatable("gui.ok");
|
||||
private static final Component NO_RESPONSE_TITLE = Component.translatable("gui.computercraft.upload.no_response");
|
||||
private static final Component NO_RESPONSE_MSG = Component.translatable("gui.computercraft.upload.no_response.msg",
|
||||
@ -178,7 +182,7 @@ public abstract class ComputerScreenBase<T extends ContainerComputerBase> extend
|
||||
|
||||
toUpload.add(new FileUpload(name, buffer, digest));
|
||||
} catch (IOException e) {
|
||||
ComputerCraft.log.error("Failed uploading files", e);
|
||||
LOG.error("Failed uploading files", e);
|
||||
alert(UploadResult.FAILED_TITLE, Component.translatable("gui.computercraft.upload.failed.generic", "Cannot compute checksum"));
|
||||
}
|
||||
}
|
||||
@ -194,8 +198,8 @@ public abstract class ComputerScreenBase<T extends ContainerComputerBase> extend
|
||||
public void uploadResult(UploadResult result, @Nullable Component message) {
|
||||
switch (result) {
|
||||
case QUEUED -> {
|
||||
if (ComputerCraft.uploadNagDelay > 0) {
|
||||
uploadNagDeadline = Util.getNanos() + TimeUnit.SECONDS.toNanos(ComputerCraft.uploadNagDelay);
|
||||
if (Config.uploadNagDelay > 0) {
|
||||
uploadNagDeadline = Util.getNanos() + TimeUnit.SECONDS.toNanos(Config.uploadNagDelay);
|
||||
}
|
||||
}
|
||||
case CONSUMED -> uploadNagDeadline = Long.MAX_VALUE;
|
||||
|
@ -7,7 +7,7 @@ package dan200.computercraft.client.gui;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import dan200.computercraft.client.gui.widgets.ComputerSidebar;
|
||||
import dan200.computercraft.client.gui.widgets.WidgetTerminal;
|
||||
import dan200.computercraft.client.render.ComputerBorderRenderer;
|
||||
@ -20,8 +20,8 @@ import net.minecraft.world.entity.player.Inventory;
|
||||
import static dan200.computercraft.shared.turtle.inventory.ContainerTurtle.*;
|
||||
|
||||
public class GuiTurtle extends ComputerScreenBase<ContainerTurtle> {
|
||||
private static final ResourceLocation BACKGROUND_NORMAL = new ResourceLocation(ComputerCraft.MOD_ID, "textures/gui/turtle_normal.png");
|
||||
private static final ResourceLocation BACKGROUND_ADVANCED = new ResourceLocation(ComputerCraft.MOD_ID, "textures/gui/turtle_advanced.png");
|
||||
private static final ResourceLocation BACKGROUND_NORMAL = new ResourceLocation(ComputerCraftAPI.MOD_ID, "textures/gui/turtle_normal.png");
|
||||
private static final ResourceLocation BACKGROUND_ADVANCED = new ResourceLocation(ComputerCraftAPI.MOD_ID, "textures/gui/turtle_advanced.png");
|
||||
|
||||
private static final int TEX_WIDTH = 254;
|
||||
private static final int TEX_HEIGHT = 217;
|
||||
|
@ -6,7 +6,7 @@
|
||||
package dan200.computercraft.client.gui.widgets;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import dan200.computercraft.client.render.ComputerBorderRenderer;
|
||||
import dan200.computercraft.shared.computer.core.InputHandler;
|
||||
import net.minecraft.ChatFormatting;
|
||||
@ -24,7 +24,7 @@ import java.util.function.Consumer;
|
||||
* Registers buttons to interact with a computer.
|
||||
*/
|
||||
public final class ComputerSidebar {
|
||||
private static final ResourceLocation TEXTURE = new ResourceLocation(ComputerCraft.MOD_ID, "textures/gui/buttons.png");
|
||||
private static final ResourceLocation TEXTURE = new ResourceLocation(ComputerCraftAPI.MOD_ID, "textures/gui/buttons.png");
|
||||
|
||||
private static final int TEX_SIZE = 64;
|
||||
|
||||
|
@ -5,11 +5,11 @@
|
||||
*/
|
||||
package dan200.computercraft.client.pocket;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.core.terminal.Terminal;
|
||||
import dan200.computercraft.shared.computer.core.ComputerState;
|
||||
import dan200.computercraft.shared.computer.terminal.NetworkedTerminal;
|
||||
import dan200.computercraft.shared.computer.terminal.TerminalState;
|
||||
import dan200.computercraft.shared.config.Config;
|
||||
import dan200.computercraft.shared.pocket.core.PocketServerComputer;
|
||||
|
||||
/**
|
||||
@ -28,7 +28,7 @@ public class PocketComputerData {
|
||||
private int lightColour = -1;
|
||||
|
||||
public PocketComputerData(boolean colour) {
|
||||
terminal = new NetworkedTerminal(ComputerCraft.pocketTermWidth, ComputerCraft.pocketTermHeight, colour);
|
||||
terminal = new NetworkedTerminal(Config.pocketTermWidth, Config.pocketTermHeight, colour);
|
||||
}
|
||||
|
||||
public int getLightState() {
|
||||
|
@ -8,17 +8,17 @@ package dan200.computercraft.client.render;
|
||||
import com.mojang.blaze3d.vertex.Tesselator;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import com.mojang.math.Matrix4f;
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import dan200.computercraft.shared.computer.core.ComputerFamily;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
public class ComputerBorderRenderer {
|
||||
public static final ResourceLocation BACKGROUND_NORMAL = new ResourceLocation(ComputerCraft.MOD_ID, "textures/gui/corners_normal.png");
|
||||
public static final ResourceLocation BACKGROUND_ADVANCED = new ResourceLocation(ComputerCraft.MOD_ID, "textures/gui/corners_advanced.png");
|
||||
public static final ResourceLocation BACKGROUND_COMMAND = new ResourceLocation(ComputerCraft.MOD_ID, "textures/gui/corners_command.png");
|
||||
public static final ResourceLocation BACKGROUND_COLOUR = new ResourceLocation(ComputerCraft.MOD_ID, "textures/gui/corners_colour.png");
|
||||
public static final ResourceLocation BACKGROUND_NORMAL = new ResourceLocation(ComputerCraftAPI.MOD_ID, "textures/gui/corners_normal.png");
|
||||
public static final ResourceLocation BACKGROUND_ADVANCED = new ResourceLocation(ComputerCraftAPI.MOD_ID, "textures/gui/corners_advanced.png");
|
||||
public static final ResourceLocation BACKGROUND_COMMAND = new ResourceLocation(ComputerCraftAPI.MOD_ID, "textures/gui/corners_command.png");
|
||||
public static final ResourceLocation BACKGROUND_COLOUR = new ResourceLocation(ComputerCraftAPI.MOD_ID, "textures/gui/corners_colour.png");
|
||||
|
||||
/**
|
||||
* The margin between the terminal and its border.
|
||||
|
@ -7,7 +7,7 @@ package dan200.computercraft.client.render;
|
||||
|
||||
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
|
||||
import com.mojang.blaze3d.vertex.VertexFormat;
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import dan200.computercraft.client.render.text.FixedWidthFontRenderer;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.client.renderer.RenderStateShard;
|
||||
@ -63,7 +63,7 @@ public class RenderTypes {
|
||||
load.accept(
|
||||
new MonitorTextureBufferShader(
|
||||
resources,
|
||||
new ResourceLocation(ComputerCraft.MOD_ID, "monitor_tbo"),
|
||||
new ResourceLocation(ComputerCraftAPI.MOD_ID, "monitor_tbo"),
|
||||
MONITOR_TBO.format()
|
||||
),
|
||||
x -> monitorTboShader = (MonitorTextureBufferShader) x
|
||||
|
@ -15,7 +15,6 @@ import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import com.mojang.math.Matrix3f;
|
||||
import com.mojang.math.Matrix4f;
|
||||
import com.mojang.math.Vector3f;
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.client.FrameInfo;
|
||||
import dan200.computercraft.client.render.monitor.MonitorRenderState;
|
||||
import dan200.computercraft.client.render.text.DirectFixedWidthFontRenderer;
|
||||
@ -23,6 +22,7 @@ import dan200.computercraft.client.render.text.FixedWidthFontRenderer;
|
||||
import dan200.computercraft.client.util.DirectBuffers;
|
||||
import dan200.computercraft.client.util.DirectVertexBuffer;
|
||||
import dan200.computercraft.core.terminal.Terminal;
|
||||
import dan200.computercraft.shared.config.Config;
|
||||
import dan200.computercraft.shared.integration.ShaderMod;
|
||||
import dan200.computercraft.shared.peripheral.monitor.ClientMonitor;
|
||||
import dan200.computercraft.shared.peripheral.monitor.MonitorRenderer;
|
||||
@ -36,6 +36,8 @@ import org.lwjgl.opengl.GL;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL20;
|
||||
import org.lwjgl.opengl.GL31;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.nio.ByteBuffer;
|
||||
@ -46,6 +48,8 @@ import static dan200.computercraft.client.render.text.FixedWidthFontRenderer.FON
|
||||
import static dan200.computercraft.core.util.Nullability.assertNonNull;
|
||||
|
||||
public class TileEntityMonitorRenderer implements BlockEntityRenderer<TileMonitor> {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(TileEntityMonitorRenderer.class);
|
||||
|
||||
/**
|
||||
* {@link TileMonitor#RENDER_MARGIN}, but a tiny bit of additional padding to ensure that there is no space between
|
||||
* the monitor frame and contents.
|
||||
@ -254,7 +258,7 @@ public class TileEntityMonitorRenderer implements BlockEntityRenderer<TileMonito
|
||||
|
||||
@Override
|
||||
public int getViewDistance() {
|
||||
return ComputerCraft.monitorDistance;
|
||||
return Config.monitorDistance;
|
||||
}
|
||||
|
||||
|
||||
@ -264,19 +268,19 @@ public class TileEntityMonitorRenderer implements BlockEntityRenderer<TileMonito
|
||||
* @return The current renderer. Will not return {@link MonitorRenderer#BEST}.
|
||||
*/
|
||||
public static MonitorRenderer currentRenderer() {
|
||||
var current = ComputerCraft.monitorRenderer;
|
||||
if (current == MonitorRenderer.BEST) current = ComputerCraft.monitorRenderer = bestRenderer();
|
||||
var current = Config.monitorRenderer;
|
||||
if (current == MonitorRenderer.BEST) current = Config.monitorRenderer = bestRenderer();
|
||||
return current;
|
||||
}
|
||||
|
||||
private static MonitorRenderer bestRenderer() {
|
||||
if (!GL.getCapabilities().OpenGL31) {
|
||||
ComputerCraft.log.warn("Texture buffers are not supported on your graphics card. Falling back to VBO monitor renderer.");
|
||||
LOG.warn("Texture buffers are not supported on your graphics card. Falling back to VBO monitor renderer.");
|
||||
return MonitorRenderer.VBO;
|
||||
}
|
||||
|
||||
if (ShaderMod.INSTANCE.isShaderMod()) {
|
||||
ComputerCraft.log.warn("Optifine is loaded, assuming shaders are being used. Falling back to VBO monitor renderer.");
|
||||
LOG.warn("Optifine is loaded, assuming shaders are being used. Falling back to VBO monitor renderer.");
|
||||
return MonitorRenderer.VBO;
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@ package dan200.computercraft.client.render;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import com.mojang.math.Vector3f;
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import dan200.computercraft.api.turtle.TurtleSide;
|
||||
import dan200.computercraft.client.turtle.TurtleUpgradeModellers;
|
||||
import dan200.computercraft.shared.computer.core.ComputerFamily;
|
||||
@ -36,8 +36,8 @@ import java.util.List;
|
||||
public class TileEntityTurtleRenderer implements BlockEntityRenderer<TileTurtle> {
|
||||
private static final ModelResourceLocation NORMAL_TURTLE_MODEL = new ModelResourceLocation("computercraft:turtle_normal", "inventory");
|
||||
private static final ModelResourceLocation ADVANCED_TURTLE_MODEL = new ModelResourceLocation("computercraft:turtle_advanced", "inventory");
|
||||
private static final ResourceLocation COLOUR_TURTLE_MODEL = new ResourceLocation(ComputerCraft.MOD_ID, "block/turtle_colour");
|
||||
private static final ResourceLocation ELF_OVERLAY_MODEL = new ResourceLocation(ComputerCraft.MOD_ID, "block/turtle_elf_overlay");
|
||||
private static final ResourceLocation COLOUR_TURTLE_MODEL = new ResourceLocation(ComputerCraftAPI.MOD_ID, "block/turtle_colour");
|
||||
private static final ResourceLocation ELF_OVERLAY_MODEL = new ResourceLocation(ComputerCraftAPI.MOD_ID, "block/turtle_elf_overlay");
|
||||
|
||||
private final RandomSource random = RandomSource.create(0);
|
||||
|
||||
|
@ -8,7 +8,7 @@ package dan200.computercraft.client.render;
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import dan200.computercraft.client.model.turtle.TurtleModel;
|
||||
import net.minecraft.client.renderer.block.model.ItemOverrides;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
@ -25,7 +25,7 @@ import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
|
||||
public final class TurtleModelLoader implements IGeometryLoader<TurtleModelLoader.Unbaked> {
|
||||
private static final ResourceLocation COLOUR_TURTLE_MODEL = new ResourceLocation(ComputerCraft.MOD_ID, "block/turtle_colour");
|
||||
private static final ResourceLocation COLOUR_TURTLE_MODEL = new ResourceLocation(ComputerCraftAPI.MOD_ID, "block/turtle_colour");
|
||||
|
||||
public static final TurtleModelLoader INSTANCE = new TurtleModelLoader();
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
*/
|
||||
package dan200.computercraft.client.sound;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import dan200.computercraft.core.util.Nullability;
|
||||
import dan200.computercraft.shared.peripheral.speaker.SpeakerPosition;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
@ -18,7 +18,7 @@ import javax.annotation.Nullable;
|
||||
* An instance of a speaker, which is either playing a {@link DfpwmStream} stream or a normal sound.
|
||||
*/
|
||||
public class SpeakerInstance {
|
||||
public static final ResourceLocation DFPWM_STREAM = new ResourceLocation(ComputerCraft.MOD_ID, "speaker.dfpwm_fake_audio_should_not_be_played");
|
||||
public static final ResourceLocation DFPWM_STREAM = new ResourceLocation(ComputerCraftAPI.MOD_ID, "speaker.dfpwm_fake_audio_should_not_be_played");
|
||||
|
||||
private @Nullable DfpwmStream currentStream;
|
||||
private @Nullable SpeakerSound sound;
|
||||
|
@ -5,7 +5,7 @@
|
||||
*/
|
||||
package dan200.computercraft.client.turtle;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import dan200.computercraft.api.client.TransformedModel;
|
||||
import dan200.computercraft.api.client.turtle.TurtleUpgradeModeller;
|
||||
import dan200.computercraft.api.turtle.ITurtleAccess;
|
||||
@ -22,15 +22,15 @@ public class TurtleModemModeller implements TurtleUpgradeModeller<TurtleModem> {
|
||||
|
||||
public TurtleModemModeller(boolean advanced) {
|
||||
if (advanced) {
|
||||
leftOffModel = new ResourceLocation(ComputerCraft.MOD_ID, "block/turtle_modem_advanced_off_left");
|
||||
rightOffModel = new ResourceLocation(ComputerCraft.MOD_ID, "block/turtle_modem_advanced_off_right");
|
||||
leftOnModel = new ResourceLocation(ComputerCraft.MOD_ID, "block/turtle_modem_advanced_on_left");
|
||||
rightOnModel = new ResourceLocation(ComputerCraft.MOD_ID, "block/turtle_modem_advanced_on_right");
|
||||
leftOffModel = new ResourceLocation(ComputerCraftAPI.MOD_ID, "block/turtle_modem_advanced_off_left");
|
||||
rightOffModel = new ResourceLocation(ComputerCraftAPI.MOD_ID, "block/turtle_modem_advanced_off_right");
|
||||
leftOnModel = new ResourceLocation(ComputerCraftAPI.MOD_ID, "block/turtle_modem_advanced_on_left");
|
||||
rightOnModel = new ResourceLocation(ComputerCraftAPI.MOD_ID, "block/turtle_modem_advanced_on_right");
|
||||
} else {
|
||||
leftOffModel = new ResourceLocation(ComputerCraft.MOD_ID, "block/turtle_modem_normal_off_left");
|
||||
rightOffModel = new ResourceLocation(ComputerCraft.MOD_ID, "block/turtle_modem_normal_off_right");
|
||||
leftOnModel = new ResourceLocation(ComputerCraft.MOD_ID, "block/turtle_modem_normal_on_left");
|
||||
rightOnModel = new ResourceLocation(ComputerCraft.MOD_ID, "block/turtle_modem_normal_on_right");
|
||||
leftOffModel = new ResourceLocation(ComputerCraftAPI.MOD_ID, "block/turtle_modem_normal_off_left");
|
||||
rightOffModel = new ResourceLocation(ComputerCraftAPI.MOD_ID, "block/turtle_modem_normal_off_right");
|
||||
leftOnModel = new ResourceLocation(ComputerCraftAPI.MOD_ID, "block/turtle_modem_normal_on_left");
|
||||
rightOnModel = new ResourceLocation(ComputerCraftAPI.MOD_ID, "block/turtle_modem_normal_on_right");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
package dan200.computercraft.data;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import dan200.computercraft.shared.ModRegistry;
|
||||
import dan200.computercraft.shared.computer.blocks.BlockComputer;
|
||||
import dan200.computercraft.shared.peripheral.diskdrive.BlockDiskDrive;
|
||||
@ -39,27 +39,27 @@ import static net.minecraft.data.models.model.TextureMapping.getBlockTexture;
|
||||
|
||||
class BlockModelGenerator {
|
||||
private static final ModelTemplate MONITOR_BASE = new ModelTemplate(
|
||||
Optional.of(new ResourceLocation(ComputerCraft.MOD_ID, "block/monitor_base")),
|
||||
Optional.of(new ResourceLocation(ComputerCraftAPI.MOD_ID, "block/monitor_base")),
|
||||
Optional.empty(),
|
||||
TextureSlot.FRONT, TextureSlot.SIDE, TextureSlot.TOP, TextureSlot.BACK
|
||||
);
|
||||
private static final ModelTemplate MODEM = new ModelTemplate(
|
||||
Optional.of(new ResourceLocation(ComputerCraft.MOD_ID, "block/modem")),
|
||||
Optional.of(new ResourceLocation(ComputerCraftAPI.MOD_ID, "block/modem")),
|
||||
Optional.empty(),
|
||||
TextureSlot.FRONT, TextureSlot.BACK
|
||||
);
|
||||
private static final ModelTemplate TURTLE = new ModelTemplate(
|
||||
Optional.of(new ResourceLocation(ComputerCraft.MOD_ID, "block/turtle_base")),
|
||||
Optional.of(new ResourceLocation(ComputerCraftAPI.MOD_ID, "block/turtle_base")),
|
||||
Optional.empty(),
|
||||
TextureSlot.TEXTURE
|
||||
);
|
||||
private static final ModelTemplate TURTLE_UPGRADE_LEFT = new ModelTemplate(
|
||||
Optional.of(new ResourceLocation(ComputerCraft.MOD_ID, "block/turtle_upgrade_base_left")),
|
||||
Optional.of(new ResourceLocation(ComputerCraftAPI.MOD_ID, "block/turtle_upgrade_base_left")),
|
||||
Optional.of("_left"),
|
||||
TextureSlot.TEXTURE
|
||||
);
|
||||
private static final ModelTemplate TURTLE_UPGRADE_RIGHT = new ModelTemplate(
|
||||
Optional.of(new ResourceLocation(ComputerCraft.MOD_ID, "block/turtle_upgrade_base_right")),
|
||||
Optional.of(new ResourceLocation(ComputerCraftAPI.MOD_ID, "block/turtle_upgrade_base_right")),
|
||||
Optional.of("_left"),
|
||||
TextureSlot.TEXTURE
|
||||
);
|
||||
@ -181,10 +181,10 @@ class BlockModelGenerator {
|
||||
generators.blockStateOutput.accept(MultiVariantGenerator.multiVariant(fullBlock)
|
||||
.with(createModelDispatch(BlockWiredModemFull.MODEM_ON, BlockWiredModemFull.PERIPHERAL_ON, (on, peripheral) -> {
|
||||
var suffix = (on ? "_on" : "_off") + (peripheral ? "_peripheral" : "");
|
||||
var faceTexture = new ResourceLocation(ComputerCraft.MOD_ID, "block/wired_modem_face" + (peripheral ? "_peripheral" : "") + (on ? "_on" : ""));
|
||||
var faceTexture = new ResourceLocation(ComputerCraftAPI.MOD_ID, "block/wired_modem_face" + (peripheral ? "_peripheral" : "") + (on ? "_on" : ""));
|
||||
|
||||
// TODO: Do this somewhere more elegant!
|
||||
modemModel(generators, new ResourceLocation(ComputerCraft.MOD_ID, "block/wired_modem" + suffix), faceTexture);
|
||||
modemModel(generators, new ResourceLocation(ComputerCraftAPI.MOD_ID, "block/wired_modem" + suffix), faceTexture);
|
||||
|
||||
return ModelTemplates.CUBE_ALL.create(
|
||||
getModelLocation(fullBlock, suffix),
|
||||
@ -194,7 +194,7 @@ class BlockModelGenerator {
|
||||
})));
|
||||
|
||||
generators.delegateItemModel(fullBlock, getModelLocation(fullBlock, "_off"));
|
||||
generators.delegateItemModel(ModRegistry.Items.WIRED_MODEM.get(), new ResourceLocation(ComputerCraft.MOD_ID, "block/wired_modem_off"));
|
||||
generators.delegateItemModel(ModRegistry.Items.WIRED_MODEM.get(), new ResourceLocation(ComputerCraftAPI.MOD_ID, "block/wired_modem_off"));
|
||||
}
|
||||
|
||||
private static ResourceLocation modemModel(BlockModelGenerators generators, ResourceLocation name, ResourceLocation texture) {
|
||||
@ -202,7 +202,7 @@ class BlockModelGenerator {
|
||||
name,
|
||||
new TextureMapping()
|
||||
.put(TextureSlot.FRONT, texture)
|
||||
.put(TextureSlot.BACK, new ResourceLocation(ComputerCraft.MOD_ID, "block/modem_back")),
|
||||
.put(TextureSlot.BACK, new ResourceLocation(ComputerCraftAPI.MOD_ID, "block/modem_back")),
|
||||
generators.modelOutput
|
||||
);
|
||||
}
|
||||
@ -249,7 +249,7 @@ class BlockModelGenerator {
|
||||
var generator = MultiPartGenerator.multiPart(ModRegistry.Blocks.CABLE.get());
|
||||
|
||||
// When a cable only has a neighbour in a single direction, we redirect the core to face that direction.
|
||||
var coreFacing = new ResourceLocation(ComputerCraft.MOD_ID, "block/cable_core_facing");
|
||||
var coreFacing = new ResourceLocation(ComputerCraftAPI.MOD_ID, "block/cable_core_facing");
|
||||
// Up/Down
|
||||
generator.with(
|
||||
Condition.or(
|
||||
@ -279,7 +279,7 @@ class BlockModelGenerator {
|
||||
);
|
||||
|
||||
// Find all other possibilities and emit a "solid" core which doesn't have a facing direction.
|
||||
var core = new ResourceLocation(ComputerCraft.MOD_ID, "block/cable_core_any");
|
||||
var core = new ResourceLocation(ComputerCraftAPI.MOD_ID, "block/cable_core_any");
|
||||
List<Condition.TerminalCondition> rightAngles = new ArrayList<>();
|
||||
for (var i = 0; i < DirectionUtil.FACINGS.length; i++) {
|
||||
for (var j = i; j < DirectionUtil.FACINGS.length; j++) {
|
||||
@ -293,7 +293,7 @@ class BlockModelGenerator {
|
||||
generator.with(Condition.or(rightAngles.toArray(new Condition[0])), Variant.variant().with(VariantProperties.MODEL, core));
|
||||
|
||||
// Then emit the actual cable arms
|
||||
var arm = new ResourceLocation(ComputerCraft.MOD_ID, "block/cable_arm");
|
||||
var arm = new ResourceLocation(ComputerCraftAPI.MOD_ID, "block/cable_arm");
|
||||
for (var direction : DirectionUtil.FACINGS) {
|
||||
generator.with(
|
||||
new Condition.TerminalCondition().term(CABLE_DIRECTIONS[direction.ordinal()], true),
|
||||
@ -312,7 +312,7 @@ class BlockModelGenerator {
|
||||
generator.with(
|
||||
new Condition.TerminalCondition().term(BlockCable.MODEM, CableModemVariant.from(direction, on, peripheral)),
|
||||
Variant.variant()
|
||||
.with(VariantProperties.MODEL, new ResourceLocation(ComputerCraft.MOD_ID, "block/wired_modem" + suffix))
|
||||
.with(VariantProperties.MODEL, new ResourceLocation(ComputerCraftAPI.MOD_ID, "block/wired_modem" + suffix))
|
||||
.with(VariantProperties.X_ROT, toXAngle(direction))
|
||||
.with(VariantProperties.Y_ROT, toYAngle(direction))
|
||||
);
|
||||
@ -334,13 +334,13 @@ class BlockModelGenerator {
|
||||
|
||||
private static void registerTurtleUpgrade(BlockModelGenerators generators, String name, String texture) {
|
||||
TURTLE_UPGRADE_LEFT.create(
|
||||
new ResourceLocation(ComputerCraft.MOD_ID, name + "_left"),
|
||||
TextureMapping.defaultTexture(new ResourceLocation(ComputerCraft.MOD_ID, texture)),
|
||||
new ResourceLocation(ComputerCraftAPI.MOD_ID, name + "_left"),
|
||||
TextureMapping.defaultTexture(new ResourceLocation(ComputerCraftAPI.MOD_ID, texture)),
|
||||
generators.modelOutput
|
||||
);
|
||||
TURTLE_UPGRADE_RIGHT.create(
|
||||
new ResourceLocation(ComputerCraft.MOD_ID, name + "_right"),
|
||||
TextureMapping.defaultTexture(new ResourceLocation(ComputerCraft.MOD_ID, texture)),
|
||||
new ResourceLocation(ComputerCraftAPI.MOD_ID, name + "_right"),
|
||||
TextureMapping.defaultTexture(new ResourceLocation(ComputerCraftAPI.MOD_ID, texture)),
|
||||
generators.modelOutput
|
||||
);
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
*/
|
||||
package dan200.computercraft.data;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import dan200.computercraft.shared.ModRegistry;
|
||||
import net.minecraft.data.DataGenerator;
|
||||
import net.minecraft.data.tags.BlockTagsProvider;
|
||||
@ -16,7 +16,7 @@ import static dan200.computercraft.api.ComputerCraftTags.Blocks.*;
|
||||
|
||||
class BlockTagsGenerator extends BlockTagsProvider {
|
||||
BlockTagsGenerator(DataGenerator generator, ExistingFileHelper helper) {
|
||||
super(generator, ComputerCraft.MOD_ID, helper);
|
||||
super(generator, ComputerCraftAPI.MOD_ID, helper);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -5,7 +5,7 @@
|
||||
*/
|
||||
package dan200.computercraft.data;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import dan200.computercraft.shared.ModRegistry;
|
||||
import net.minecraft.data.models.ItemModelGenerators;
|
||||
import net.minecraft.data.models.model.ModelTemplate;
|
||||
@ -29,7 +29,7 @@ public final class ItemModelGenerator {
|
||||
|
||||
registerPocketComputer(generators, getModelLocation(ModRegistry.Items.POCKET_COMPUTER_NORMAL.get()), false);
|
||||
registerPocketComputer(generators, getModelLocation(ModRegistry.Items.POCKET_COMPUTER_ADVANCED.get()), false);
|
||||
registerPocketComputer(generators, new ResourceLocation(ComputerCraft.MOD_ID, "item/pocket_computer_colour"), true);
|
||||
registerPocketComputer(generators, new ResourceLocation(ComputerCraftAPI.MOD_ID, "item/pocket_computer_colour"), true);
|
||||
|
||||
generators.generateFlatItem(ModRegistry.Items.PRINTED_BOOK.get(), ModelTemplates.FLAT_ITEM);
|
||||
generators.generateFlatItem(ModRegistry.Items.PRINTED_PAGE.get(), ModelTemplates.FLAT_ITEM);
|
||||
@ -38,21 +38,21 @@ public final class ItemModelGenerator {
|
||||
|
||||
private static void registerPocketComputer(ItemModelGenerators generators, ResourceLocation id, boolean off) {
|
||||
createFlatItem(generators, addSuffix(id, "_blinking"),
|
||||
new ResourceLocation(ComputerCraft.MOD_ID, "item/pocket_computer_blink"),
|
||||
new ResourceLocation(ComputerCraftAPI.MOD_ID, "item/pocket_computer_blink"),
|
||||
id,
|
||||
new ResourceLocation(ComputerCraft.MOD_ID, "item/pocket_computer_light")
|
||||
new ResourceLocation(ComputerCraftAPI.MOD_ID, "item/pocket_computer_light")
|
||||
);
|
||||
|
||||
createFlatItem(generators, addSuffix(id, "_on"),
|
||||
new ResourceLocation(ComputerCraft.MOD_ID, "item/pocket_computer_on"),
|
||||
new ResourceLocation(ComputerCraftAPI.MOD_ID, "item/pocket_computer_on"),
|
||||
id,
|
||||
new ResourceLocation(ComputerCraft.MOD_ID, "item/pocket_computer_light")
|
||||
new ResourceLocation(ComputerCraftAPI.MOD_ID, "item/pocket_computer_light")
|
||||
);
|
||||
|
||||
// Don't emit the default/off state for advanced/normal pocket computers, as they have item overrides.
|
||||
if (off) {
|
||||
createFlatItem(generators, id,
|
||||
new ResourceLocation(ComputerCraft.MOD_ID, "item/pocket_computer_frame"),
|
||||
new ResourceLocation(ComputerCraftAPI.MOD_ID, "item/pocket_computer_frame"),
|
||||
id
|
||||
);
|
||||
}
|
||||
@ -60,8 +60,8 @@ public final class ItemModelGenerator {
|
||||
|
||||
private static void registerDisk(ItemModelGenerators generators, Item item) {
|
||||
createFlatItem(generators, item,
|
||||
new ResourceLocation(ComputerCraft.MOD_ID, "item/disk_frame"),
|
||||
new ResourceLocation(ComputerCraft.MOD_ID, "item/disk_colour")
|
||||
new ResourceLocation(ComputerCraftAPI.MOD_ID, "item/disk_frame"),
|
||||
new ResourceLocation(ComputerCraftAPI.MOD_ID, "item/disk_colour")
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
*/
|
||||
package dan200.computercraft.data;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import dan200.computercraft.api.ComputerCraftTags.Blocks;
|
||||
import dan200.computercraft.shared.ModRegistry;
|
||||
import net.minecraft.data.DataGenerator;
|
||||
@ -17,7 +17,7 @@ import static dan200.computercraft.api.ComputerCraftTags.Items.*;
|
||||
|
||||
class ItemTagsGenerator extends ItemTagsProvider {
|
||||
ItemTagsGenerator(DataGenerator generator, BlockTagsGenerator blockTags, ExistingFileHelper helper) {
|
||||
super(generator, blockTags, ComputerCraft.MOD_ID, helper);
|
||||
super(generator, blockTags, ComputerCraftAPI.MOD_ID, helper);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -6,7 +6,7 @@
|
||||
package dan200.computercraft.data;
|
||||
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import dan200.computercraft.shared.CommonHooks;
|
||||
import dan200.computercraft.shared.ModRegistry;
|
||||
import dan200.computercraft.shared.data.BlockNamedEntityLootCondition;
|
||||
@ -115,7 +115,7 @@ class LootTableGenerator extends LootTableProvider {
|
||||
private static void computerDrop(BiConsumer<ResourceLocation, LootTable.Builder> add, Supplier<? extends Block> block) {
|
||||
blockDrop(
|
||||
add, block,
|
||||
DynamicLoot.dynamicEntry(new ResourceLocation(ComputerCraft.MOD_ID, "computer")),
|
||||
DynamicLoot.dynamicEntry(new ResourceLocation(ComputerCraftAPI.MOD_ID, "computer")),
|
||||
AlternativeLootItemCondition.alternative(
|
||||
BlockNamedEntityLootCondition.BUILDER,
|
||||
HasComputerIdLootCondition.BUILDER,
|
||||
|
@ -5,10 +5,7 @@
|
||||
*/
|
||||
package dan200.computercraft.data;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonElement;
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.shared.platform.Registries;
|
||||
import net.minecraft.data.CachedOutput;
|
||||
import net.minecraft.data.DataGenerator;
|
||||
@ -21,6 +18,8 @@ import net.minecraft.data.models.model.ModelLocationUtils;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.HashMap;
|
||||
@ -38,7 +37,7 @@ import java.util.function.Supplier;
|
||||
* Please don't sue me Mojang. Or at least make these changes to vanilla before doing so!
|
||||
*/
|
||||
public class ModelProvider implements DataProvider {
|
||||
private static final Gson GSON = new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().create();
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ModelProvider.class);
|
||||
|
||||
private final DataGenerator.PathProvider blockStatePath;
|
||||
private final DataGenerator.PathProvider modelPath;
|
||||
@ -96,7 +95,7 @@ public class ModelProvider implements DataProvider {
|
||||
try {
|
||||
DataProvider.saveStable(output, entry.getValue().get(), path);
|
||||
} catch (Exception exception) {
|
||||
ComputerCraft.log.error("Couldn't save {}", path, exception);
|
||||
LOG.error("Couldn't save {}", path, exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
*/
|
||||
package dan200.computercraft.data;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import dan200.computercraft.api.pocket.PocketUpgradeDataProvider;
|
||||
import dan200.computercraft.api.pocket.PocketUpgradeSerialiser;
|
||||
import net.minecraft.data.DataGenerator;
|
||||
@ -29,6 +29,6 @@ class PocketUpgradeGenerator extends PocketUpgradeDataProvider {
|
||||
}
|
||||
|
||||
private static ResourceLocation id(String id) {
|
||||
return new ResourceLocation(ComputerCraft.MOD_ID, id);
|
||||
return new ResourceLocation(ComputerCraftAPI.MOD_ID, id);
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
package dan200.computercraft.data;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import dan200.computercraft.api.pocket.PocketUpgradeDataProvider;
|
||||
import dan200.computercraft.api.turtle.TurtleUpgradeDataProvider;
|
||||
import dan200.computercraft.core.util.Colour;
|
||||
@ -87,7 +87,7 @@ class RecipeGenerator extends RecipeProvider {
|
||||
.save(
|
||||
RecipeWrapper.wrap(ModRegistry.RecipeSerializers.IMPOSTOR_SHAPELESS.get(), add)
|
||||
.withResultTag(x -> x.putInt(IColouredItem.NBT_COLOUR, colour.getHex())),
|
||||
new ResourceLocation(ComputerCraft.MOD_ID, "disk_" + (colour.ordinal() + 1))
|
||||
new ResourceLocation(ComputerCraftAPI.MOD_ID, "disk_" + (colour.ordinal() + 1))
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -108,7 +108,7 @@ class RecipeGenerator extends RecipeProvider {
|
||||
var result = TurtleItemFactory.create(-1, null, -1, family, null, upgrade, -1, null);
|
||||
ShapedRecipeBuilder
|
||||
.shaped(result.getItem())
|
||||
.group(String.format("%s:turtle_%s", ComputerCraft.MOD_ID, nameId))
|
||||
.group(String.format("%s:turtle_%s", ComputerCraftAPI.MOD_ID, nameId))
|
||||
.pattern("#T")
|
||||
.define('T', base.getItem())
|
||||
.define('#', upgrade.getCraftingItem().getItem())
|
||||
@ -116,7 +116,7 @@ class RecipeGenerator extends RecipeProvider {
|
||||
inventoryChange(base.getItem(), upgrade.getCraftingItem().getItem()))
|
||||
.save(
|
||||
RecipeWrapper.wrap(ModRegistry.RecipeSerializers.IMPOSTOR_SHAPED.get(), add).withResultTag(result.getTag()),
|
||||
new ResourceLocation(ComputerCraft.MOD_ID, String.format("turtle_%s/%s/%s",
|
||||
new ResourceLocation(ComputerCraftAPI.MOD_ID, String.format("turtle_%s/%s/%s",
|
||||
nameId, upgrade.getUpgradeID().getNamespace(), upgrade.getUpgradeID().getPath()
|
||||
))
|
||||
);
|
||||
@ -140,7 +140,7 @@ class RecipeGenerator extends RecipeProvider {
|
||||
var result = PocketComputerItemFactory.create(-1, null, -1, family, upgrade);
|
||||
ShapedRecipeBuilder
|
||||
.shaped(result.getItem())
|
||||
.group(String.format("%s:pocket_%s", ComputerCraft.MOD_ID, nameId))
|
||||
.group(String.format("%s:pocket_%s", ComputerCraftAPI.MOD_ID, nameId))
|
||||
.pattern("#")
|
||||
.pattern("P")
|
||||
.define('P', base.getItem())
|
||||
@ -149,7 +149,7 @@ class RecipeGenerator extends RecipeProvider {
|
||||
inventoryChange(base.getItem(), upgrade.getCraftingItem().getItem()))
|
||||
.save(
|
||||
RecipeWrapper.wrap(ModRegistry.RecipeSerializers.IMPOSTOR_SHAPED.get(), add).withResultTag(result.getTag()),
|
||||
new ResourceLocation(ComputerCraft.MOD_ID, String.format("pocket_%s/%s/%s",
|
||||
new ResourceLocation(ComputerCraftAPI.MOD_ID, String.format("pocket_%s/%s/%s",
|
||||
nameId, upgrade.getUpgradeID().getNamespace(), upgrade.getUpgradeID().getPath()
|
||||
))
|
||||
);
|
||||
@ -201,7 +201,7 @@ class RecipeGenerator extends RecipeProvider {
|
||||
.unlockedBy("has_components", inventoryChange(itemPredicate(ModRegistry.Items.COMPUTER_NORMAL.get()), itemPredicate(ingredients.goldIngot())))
|
||||
.save(
|
||||
RecipeWrapper.wrap(ModRegistry.RecipeSerializers.COMPUTER_UPGRADE.get(), add).withExtraData(family(ComputerFamily.ADVANCED)),
|
||||
new ResourceLocation(ComputerCraft.MOD_ID, "computer_advanced_upgrade")
|
||||
new ResourceLocation(ComputerCraftAPI.MOD_ID, "computer_advanced_upgrade")
|
||||
);
|
||||
|
||||
ShapedRecipeBuilder
|
||||
@ -248,7 +248,7 @@ class RecipeGenerator extends RecipeProvider {
|
||||
.unlockedBy("has_components", inventoryChange(itemPredicate(ModRegistry.Items.TURTLE_NORMAL.get()), itemPredicate(ingredients.goldIngot())))
|
||||
.save(
|
||||
RecipeWrapper.wrap(ModRegistry.RecipeSerializers.COMPUTER_UPGRADE.get(), add).withExtraData(family(ComputerFamily.ADVANCED)),
|
||||
new ResourceLocation(ComputerCraft.MOD_ID, "turtle_advanced_upgrade")
|
||||
new ResourceLocation(ComputerCraftAPI.MOD_ID, "turtle_advanced_upgrade")
|
||||
);
|
||||
|
||||
ShapedRecipeBuilder
|
||||
@ -315,7 +315,7 @@ class RecipeGenerator extends RecipeProvider {
|
||||
.unlockedBy("has_components", inventoryChange(itemPredicate(ModRegistry.Items.POCKET_COMPUTER_NORMAL.get()), itemPredicate(ingredients.goldIngot())))
|
||||
.save(
|
||||
RecipeWrapper.wrap(ModRegistry.RecipeSerializers.COMPUTER_UPGRADE.get(), add).withExtraData(family(ComputerFamily.ADVANCED)),
|
||||
new ResourceLocation(ComputerCraft.MOD_ID, "pocket_computer_advanced_upgrade")
|
||||
new ResourceLocation(ComputerCraftAPI.MOD_ID, "pocket_computer_advanced_upgrade")
|
||||
);
|
||||
|
||||
ShapedRecipeBuilder
|
||||
@ -355,12 +355,12 @@ class RecipeGenerator extends RecipeProvider {
|
||||
.shapeless(ModRegistry.Blocks.WIRED_MODEM_FULL.get())
|
||||
.requires(ModRegistry.Items.WIRED_MODEM.get())
|
||||
.unlockedBy("has_modem", inventoryChange(WIRED_MODEM))
|
||||
.save(add, new ResourceLocation(ComputerCraft.MOD_ID, "wired_modem_full_from"));
|
||||
.save(add, new ResourceLocation(ComputerCraftAPI.MOD_ID, "wired_modem_full_from"));
|
||||
ShapelessRecipeBuilder
|
||||
.shapeless(ModRegistry.Items.WIRED_MODEM.get())
|
||||
.requires(ModRegistry.Blocks.WIRED_MODEM_FULL.get())
|
||||
.unlockedBy("has_modem", inventoryChange(WIRED_MODEM))
|
||||
.save(add, new ResourceLocation(ComputerCraft.MOD_ID, "wired_modem_full_to"));
|
||||
.save(add, new ResourceLocation(ComputerCraftAPI.MOD_ID, "wired_modem_full_to"));
|
||||
|
||||
ShapedRecipeBuilder
|
||||
.shaped(ModRegistry.Blocks.WIRELESS_MODEM_NORMAL.get())
|
||||
@ -391,7 +391,7 @@ class RecipeGenerator extends RecipeProvider {
|
||||
.save(
|
||||
RecipeWrapper.wrap(RecipeSerializer.SHAPELESS_RECIPE, add)
|
||||
.withResultTag(playerHead("Cloudhunter", "6d074736-b1e9-4378-a99b-bd8777821c9c")),
|
||||
new ResourceLocation(ComputerCraft.MOD_ID, "skull_cloudy")
|
||||
new ResourceLocation(ComputerCraftAPI.MOD_ID, "skull_cloudy")
|
||||
);
|
||||
|
||||
ShapelessRecipeBuilder
|
||||
@ -402,7 +402,7 @@ class RecipeGenerator extends RecipeProvider {
|
||||
.save(
|
||||
RecipeWrapper.wrap(RecipeSerializer.SHAPELESS_RECIPE, add)
|
||||
.withResultTag(playerHead("dan200", "f3c8d69b-0776-4512-8434-d1b2165909eb")),
|
||||
new ResourceLocation(ComputerCraft.MOD_ID, "skull_dan200")
|
||||
new ResourceLocation(ComputerCraftAPI.MOD_ID, "skull_dan200")
|
||||
);
|
||||
|
||||
ShapelessRecipeBuilder
|
||||
|
@ -5,7 +5,7 @@
|
||||
*/
|
||||
package dan200.computercraft.data;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import dan200.computercraft.api.ComputerCraftTags.Blocks;
|
||||
import dan200.computercraft.api.turtle.TurtleUpgradeDataProvider;
|
||||
import dan200.computercraft.api.turtle.TurtleUpgradeSerialiser;
|
||||
@ -37,7 +37,7 @@ class TurtleUpgradeGenerator extends TurtleUpgradeDataProvider {
|
||||
}
|
||||
|
||||
private static ResourceLocation id(String id) {
|
||||
return new ResourceLocation(ComputerCraft.MOD_ID, id);
|
||||
return new ResourceLocation(ComputerCraftAPI.MOD_ID, id);
|
||||
}
|
||||
|
||||
private static ResourceLocation vanilla(String id) {
|
||||
|
@ -5,17 +5,20 @@
|
||||
*/
|
||||
package dan200.computercraft.shared;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.redstone.IBundledRedstoneProvider;
|
||||
import dan200.computercraft.shared.common.DefaultBundledRedstoneProvider;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.level.Level;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Objects;
|
||||
|
||||
public final class BundledRedstone {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(BundledRedstone.class);
|
||||
|
||||
private static final ArrayList<IBundledRedstoneProvider> providers = new ArrayList<>();
|
||||
|
||||
private BundledRedstone() {
|
||||
@ -42,7 +45,7 @@ public final class BundledRedstone {
|
||||
combinedSignal = combinedSignal < 0 ? signal & 0xffff : combinedSignal | (signal & 0xffff);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
ComputerCraft.log.error("Bundled redstone provider " + bundledRedstoneProvider + " errored.", e);
|
||||
LOG.error("Bundled redstone provider " + bundledRedstoneProvider + " errored.", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
*/
|
||||
package dan200.computercraft.shared;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import dan200.computercraft.core.apis.http.NetworkUtils;
|
||||
import dan200.computercraft.shared.computer.core.ResourceMount;
|
||||
import dan200.computercraft.shared.computer.core.ServerContext;
|
||||
@ -76,7 +76,7 @@ public final class CommonHooks {
|
||||
MonitorWatcher.onWatch(chunk, player);
|
||||
}
|
||||
|
||||
public static final ResourceLocation LOOT_TREASURE_DISK = new ResourceLocation(ComputerCraft.MOD_ID, "treasure_disk");
|
||||
public static final ResourceLocation LOOT_TREASURE_DISK = new ResourceLocation(ComputerCraftAPI.MOD_ID, "treasure_disk");
|
||||
|
||||
private static final Set<ResourceLocation> TABLES = new HashSet<>(Arrays.asList(
|
||||
BuiltInLootTables.SIMPLE_DUNGEON,
|
||||
|
@ -5,10 +5,10 @@
|
||||
*/
|
||||
package dan200.computercraft.shared;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import dan200.computercraft.shared.command.CommandComputerCraft;
|
||||
import dan200.computercraft.shared.computer.blocks.TileComputer;
|
||||
import dan200.computercraft.shared.config.Config;
|
||||
import dan200.computercraft.shared.network.client.UpgradesLoadedMessage;
|
||||
import dan200.computercraft.shared.peripheral.commandblock.CommandBlockPeripheral;
|
||||
import dan200.computercraft.shared.peripheral.diskdrive.TileDiskDrive;
|
||||
@ -134,7 +134,7 @@ public class ForgeCommonHooks {
|
||||
event, INVENTORY, ITEM_HANDLER,
|
||||
s -> s == null ? new InvWrapper(printer) : new SidedInvWrapper(printer, s)
|
||||
);
|
||||
} else if (ComputerCraft.enableCommandBlock && blockEntity instanceof CommandBlockEntity commandBlock) {
|
||||
} else if (Config.enableCommandBlock && blockEntity instanceof CommandBlockEntity commandBlock) {
|
||||
CapabilityProvider.attach(event, PERIPHERAL, CAPABILITY_PERIPHERAL, () -> new CommandBlockPeripheral(commandBlock));
|
||||
}
|
||||
}
|
||||
|
@ -5,10 +5,11 @@
|
||||
*/
|
||||
package dan200.computercraft.shared;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.media.IMedia;
|
||||
import dan200.computercraft.api.media.IMediaProvider;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.LinkedHashSet;
|
||||
@ -16,6 +17,8 @@ import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
public final class MediaProviders {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(MediaProviders.class);
|
||||
|
||||
private static final Set<IMediaProvider> providers = new LinkedHashSet<>();
|
||||
|
||||
private MediaProviders() {
|
||||
@ -35,8 +38,8 @@ public final class MediaProviders {
|
||||
var media = mediaProvider.getMedia(stack);
|
||||
if (media != null) return media;
|
||||
} catch (Exception e) {
|
||||
// mod misbehaved, ignore it
|
||||
ComputerCraft.log.error("Media provider " + mediaProvider + " errored.", e);
|
||||
// Mod misbehaved, ignore it
|
||||
LOG.error("Media provider " + mediaProvider + " errored.", e);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
@ -5,7 +5,6 @@
|
||||
*/
|
||||
package dan200.computercraft.shared;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
import dan200.computercraft.api.peripheral.IPeripheralProvider;
|
||||
import dan200.computercraft.shared.peripheral.generic.GenericPeripheralProvider;
|
||||
@ -14,6 +13,9 @@ import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraftforge.common.util.NonNullConsumer;
|
||||
import org.jline.utils.Log;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collection;
|
||||
@ -23,6 +25,8 @@ import java.util.Objects;
|
||||
import static dan200.computercraft.shared.Capabilities.CAPABILITY_PERIPHERAL;
|
||||
|
||||
public final class Peripherals {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(Peripherals.class);
|
||||
|
||||
private static final Collection<IPeripheralProvider> providers = new LinkedHashSet<>();
|
||||
|
||||
private Peripherals() {
|
||||
@ -52,7 +56,7 @@ public final class Peripherals {
|
||||
var peripheral = peripheralProvider.getPeripheral(world, pos, side);
|
||||
if (peripheral.isPresent()) return CapabilityUtil.unwrap(peripheral, invalidate);
|
||||
} catch (Exception e) {
|
||||
ComputerCraft.log.error("Peripheral provider " + peripheralProvider + " errored.", e);
|
||||
Log.error("Peripheral provider " + peripheralProvider + " errored.", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
*/
|
||||
package dan200.computercraft.shared;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import dan200.computercraft.api.pocket.IPocketUpgrade;
|
||||
import dan200.computercraft.api.pocket.PocketUpgradeSerialiser;
|
||||
|
||||
@ -25,7 +25,7 @@ public final class PocketUpgrades {
|
||||
|
||||
public static Stream<IPocketUpgrade> getVanillaUpgrades() {
|
||||
return instance().getUpgradeWrappers().values().stream()
|
||||
.filter(x -> x.modId().equals(ComputerCraft.MOD_ID))
|
||||
.filter(x -> x.modId().equals(ComputerCraftAPI.MOD_ID))
|
||||
.map(UpgradeManager.UpgradeWrapper::upgrade);
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
*/
|
||||
package dan200.computercraft.shared;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import dan200.computercraft.api.turtle.ITurtleUpgrade;
|
||||
import dan200.computercraft.api.turtle.TurtleUpgradeSerialiser;
|
||||
|
||||
@ -25,7 +25,7 @@ public final class TurtleUpgrades {
|
||||
|
||||
public static Stream<ITurtleUpgrade> getVanillaUpgrades() {
|
||||
return instance().getUpgradeWrappers().values().stream()
|
||||
.filter(x -> x.modId().equals(ComputerCraft.MOD_ID))
|
||||
.filter(x -> x.modId().equals(ComputerCraftAPI.MOD_ID))
|
||||
.map(UpgradeManager.UpgradeWrapper::upgrade);
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
package dan200.computercraft.shared;
|
||||
|
||||
import com.google.gson.*;
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import dan200.computercraft.api.upgrades.IUpgradeBase;
|
||||
import dan200.computercraft.api.upgrades.UpgradeSerialiser;
|
||||
import dan200.computercraft.shared.platform.PlatformHelper;
|
||||
@ -122,7 +122,7 @@ public class UpgradeManager<R extends UpgradeSerialiser<? extends T>, T extends
|
||||
// TODO: Can we track which mod this resource came from and use that instead? It's theoretically possible,
|
||||
// but maybe not ideal for datapacks.
|
||||
var modId = id.getNamespace();
|
||||
if (modId.equals("minecraft") || modId.equals("")) modId = ComputerCraft.MOD_ID;
|
||||
if (modId.equals("minecraft") || modId.equals("")) modId = ComputerCraftAPI.MOD_ID;
|
||||
|
||||
var upgrade = serialiser.fromJson(id, root);
|
||||
if (!upgrade.getUpgradeID().equals(id)) {
|
||||
|
@ -7,7 +7,6 @@ package dan200.computercraft.shared.computer.apis;
|
||||
|
||||
import com.mojang.brigadier.tree.CommandNode;
|
||||
import com.mojang.brigadier.tree.LiteralCommandNode;
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.detail.BlockReference;
|
||||
import dan200.computercraft.api.detail.VanillaDetailRegistries;
|
||||
import dan200.computercraft.api.lua.*;
|
||||
@ -21,6 +20,8 @@ import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.level.Level;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@ -29,6 +30,8 @@ import java.util.*;
|
||||
* @cc.since 1.7
|
||||
*/
|
||||
public class CommandAPI implements ILuaAPI {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(CommandAPI.class);
|
||||
|
||||
private final TileCommandComputer computer;
|
||||
|
||||
public CommandAPI(TileCommandComputer computer) {
|
||||
@ -57,7 +60,7 @@ public class CommandAPI implements ILuaAPI {
|
||||
var result = commandManager.performPrefixedCommand(computer.getSource(), command);
|
||||
return new Object[]{ result > 0, receiver.copyOutput(), result };
|
||||
} catch (Throwable t) {
|
||||
ComputerCraft.log.error(Logging.JAVA_ERROR, "Error running command.", t);
|
||||
LOG.error(Logging.JAVA_ERROR, "Error running command.", t);
|
||||
return new Object[]{ false, createOutput("Java Exception Thrown: " + t) };
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
*/
|
||||
package dan200.computercraft.shared.computer.blocks;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import dan200.computercraft.shared.common.BlockGeneric;
|
||||
import dan200.computercraft.shared.common.IBundledRedstoneBlock;
|
||||
import dan200.computercraft.shared.computer.core.ComputerFamily;
|
||||
@ -35,7 +35,7 @@ import net.minecraft.world.phys.Vec3;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public abstract class BlockComputerBase<T extends TileComputerBase> extends BlockGeneric implements IBundledRedstoneBlock {
|
||||
private static final ResourceLocation DROP = new ResourceLocation(ComputerCraft.MOD_ID, "computer");
|
||||
private static final ResourceLocation DROP = new ResourceLocation(ComputerCraftAPI.MOD_ID, "computer");
|
||||
|
||||
private final ComputerFamily family;
|
||||
protected final RegistryEntry<BlockEntityType<T>> type;
|
||||
|
@ -5,10 +5,10 @@
|
||||
*/
|
||||
package dan200.computercraft.shared.computer.blocks;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.shared.computer.apis.CommandAPI;
|
||||
import dan200.computercraft.shared.computer.core.ComputerFamily;
|
||||
import dan200.computercraft.shared.computer.core.ServerComputer;
|
||||
import dan200.computercraft.shared.config.Config;
|
||||
import net.minecraft.commands.CommandSource;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.core.BlockPos;
|
||||
@ -105,7 +105,7 @@ public class TileCommandComputer extends TileComputer {
|
||||
if (server == null || !server.isCommandBlockEnabled()) {
|
||||
player.displayClientMessage(Component.translatable("advMode.notEnabled"), true);
|
||||
return false;
|
||||
} else if (ComputerCraft.commandRequireCreative ? !player.canUseGameMasterBlocks() : !server.getPlayerList().isOp(player.getGameProfile())) {
|
||||
} else if (Config.commandRequireCreative ? !player.canUseGameMasterBlocks() : !server.getPlayerList().isOp(player.getGameProfile())) {
|
||||
player.displayClientMessage(Component.translatable("advMode.notAllowed"), true);
|
||||
return false;
|
||||
}
|
||||
|
@ -5,7 +5,6 @@
|
||||
*/
|
||||
package dan200.computercraft.shared.computer.blocks;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
import dan200.computercraft.core.computer.ComputerSide;
|
||||
import dan200.computercraft.shared.ModRegistry;
|
||||
@ -13,6 +12,7 @@ import dan200.computercraft.shared.computer.core.ComputerFamily;
|
||||
import dan200.computercraft.shared.computer.core.ComputerState;
|
||||
import dan200.computercraft.shared.computer.core.ServerComputer;
|
||||
import dan200.computercraft.shared.computer.inventory.ComputerMenuWithoutInventory;
|
||||
import dan200.computercraft.shared.config.Config;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
@ -36,8 +36,8 @@ public class TileComputer extends TileComputerBase {
|
||||
var family = getFamily();
|
||||
return new ServerComputer(
|
||||
(ServerLevel) getLevel(), getBlockPos(), id, label,
|
||||
family, ComputerCraft.computerTermWidth,
|
||||
ComputerCraft.computerTermHeight
|
||||
family, Config.computerTermWidth,
|
||||
Config.computerTermHeight
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,6 @@ package dan200.computercraft.shared.computer.core;
|
||||
import com.google.common.cache.Cache;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.filesystem.IMount;
|
||||
import dan200.computercraft.core.apis.handles.ArrayByteChannel;
|
||||
import dan200.computercraft.core.filesystem.FileSystem;
|
||||
@ -18,6 +17,8 @@ import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.packs.resources.ResourceManager;
|
||||
import net.minecraft.server.packs.resources.SimplePreparableReloadListener;
|
||||
import net.minecraft.util.profiling.ProfilerFiller;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.IOException;
|
||||
@ -29,6 +30,8 @@ import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public final class ResourceMount implements IMount {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ResourceMount.class);
|
||||
|
||||
/**
|
||||
* Only cache files smaller than 1MiB.
|
||||
*/
|
||||
@ -100,9 +103,9 @@ public final class ResourceMount implements IMount {
|
||||
root = hasAny ? newRoot : null;
|
||||
|
||||
if (!hasAny) {
|
||||
ComputerCraft.log.warn("Cannot find any files under /data/{}/{} for resource mount.", namespace, subPath);
|
||||
LOG.warn("Cannot find any files under /data/{}/{} for resource mount.", namespace, subPath);
|
||||
if (existingNamespace != null) {
|
||||
ComputerCraft.log.warn("There are files under /data/{}/{} though. Did you get the wrong namespace?", existingNamespace, subPath);
|
||||
LOG.warn("There are files under /data/{}/{} though. Did you get the wrong namespace?", existingNamespace, subPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -137,7 +140,7 @@ public final class ResourceMount implements IMount {
|
||||
try {
|
||||
childPath = new ResourceLocation(namespace, subPath + "/" + path);
|
||||
} catch (ResourceLocationException e) {
|
||||
ComputerCraft.log.warn("Cannot create resource location for {} ({})", part, e.getMessage());
|
||||
LOG.warn("Cannot create resource location for {} ({})", part, e.getMessage());
|
||||
return;
|
||||
}
|
||||
lastEntry.children.put(part, nextEntry = new FileEntry(childPath));
|
||||
|
@ -5,7 +5,6 @@
|
||||
*/
|
||||
package dan200.computercraft.shared.computer.core;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import dan200.computercraft.api.filesystem.IWritableMount;
|
||||
import dan200.computercraft.api.lua.ILuaAPI;
|
||||
@ -18,6 +17,7 @@ import dan200.computercraft.core.metrics.MetricsObserver;
|
||||
import dan200.computercraft.shared.computer.menu.ComputerMenu;
|
||||
import dan200.computercraft.shared.computer.terminal.NetworkedTerminal;
|
||||
import dan200.computercraft.shared.computer.terminal.TerminalState;
|
||||
import dan200.computercraft.shared.config.Config;
|
||||
import dan200.computercraft.shared.network.NetworkMessage;
|
||||
import dan200.computercraft.shared.network.client.ClientNetworkContext;
|
||||
import dan200.computercraft.shared.network.client.ComputerTerminalClientMessage;
|
||||
@ -246,6 +246,6 @@ public class ServerComputer implements InputHandler, ComputerEnvironment {
|
||||
|
||||
@Override
|
||||
public @Nullable IWritableMount createRootMount() {
|
||||
return ComputerCraftAPI.createSaveDirMount(level, "computer/" + computer.getID(), ComputerCraft.computerSpaceLimit);
|
||||
return ComputerCraftAPI.createSaveDirMount(level, "computer/" + computer.getID(), Config.computerSpaceLimit);
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,6 @@
|
||||
package dan200.computercraft.shared.computer.core;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.ComputerCraftAPIImpl;
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import dan200.computercraft.api.filesystem.IMount;
|
||||
@ -18,11 +17,14 @@ import dan200.computercraft.core.lua.CobaltLuaMachine;
|
||||
import dan200.computercraft.core.lua.ILuaMachine;
|
||||
import dan200.computercraft.shared.CommonHooks;
|
||||
import dan200.computercraft.shared.computer.metrics.GlobalMetrics;
|
||||
import dan200.computercraft.shared.config.Config;
|
||||
import dan200.computercraft.shared.util.IDAssigner;
|
||||
import net.minecraft.SharedConstants;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.storage.LevelResource;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.InputStream;
|
||||
@ -41,7 +43,9 @@ import java.util.concurrent.TimeUnit;
|
||||
* @see CommonHooks for where the context is created and torn down.
|
||||
*/
|
||||
public final class ServerContext {
|
||||
private static final LevelResource FOLDER = new LevelResource(ComputerCraft.MOD_ID);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ServerContext.class);
|
||||
|
||||
private static final LevelResource FOLDER = new LevelResource(ComputerCraftAPI.MOD_ID);
|
||||
|
||||
@VisibleForTesting
|
||||
public static ILuaMachine.Factory luaMachine = CobaltLuaMachine::new;
|
||||
@ -63,7 +67,7 @@ public final class ServerContext {
|
||||
mainThread = new MainThread();
|
||||
context = new ComputerContext(
|
||||
new Environment(server),
|
||||
new ComputerThread(ComputerCraft.computerThreads),
|
||||
new ComputerThread(Config.computerThreads),
|
||||
mainThread, luaMachine
|
||||
);
|
||||
idAssigner = new IDAssigner(storageDir.resolve("ids.json"));
|
||||
@ -90,10 +94,10 @@ public final class ServerContext {
|
||||
instance.registry.close();
|
||||
try {
|
||||
if (!instance.context.close(1, TimeUnit.SECONDS)) {
|
||||
ComputerCraft.log.error("Failed to stop computers under deadline.");
|
||||
LOG.error("Failed to stop computers under deadline.");
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
ComputerCraft.log.error("Failed to stop computers.", e);
|
||||
LOG.error("Failed to stop computers.", e);
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
|
||||
@ -196,7 +200,7 @@ public final class ServerContext {
|
||||
|
||||
@Override
|
||||
public String getUserAgent() {
|
||||
return ComputerCraft.MOD_ID + "/" + ComputerCraftAPI.getInstalledVersion();
|
||||
return ComputerCraftAPI.MOD_ID + "/" + ComputerCraftAPI.getInstalledVersion();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,12 +5,12 @@
|
||||
*/
|
||||
package dan200.computercraft.shared.computer.items;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import dan200.computercraft.api.filesystem.IMount;
|
||||
import dan200.computercraft.api.media.IMedia;
|
||||
import dan200.computercraft.shared.computer.blocks.BlockComputerBase;
|
||||
import dan200.computercraft.shared.computer.core.ComputerFamily;
|
||||
import dan200.computercraft.shared.config.Config;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
@ -68,7 +68,7 @@ public abstract class ItemComputerBase extends BlockItem implements IComputerIte
|
||||
if (family != ComputerFamily.COMMAND) {
|
||||
var id = getComputerID(stack);
|
||||
if (id >= 0) {
|
||||
return ComputerCraftAPI.createSaveDirMount(world, "computer/" + id, ComputerCraft.computerSpaceLimit);
|
||||
return ComputerCraftAPI.createSaveDirMount(world, "computer/" + id, Config.computerSpaceLimit);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
@ -5,7 +5,6 @@
|
||||
*/
|
||||
package dan200.computercraft.shared.computer.menu;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.shared.computer.upload.*;
|
||||
import dan200.computercraft.shared.network.client.UploadResultMessage;
|
||||
import dan200.computercraft.shared.platform.PlatformHelper;
|
||||
@ -14,6 +13,8 @@ import it.unimi.dsi.fastutil.ints.IntSet;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
@ -28,6 +29,8 @@ import java.util.stream.Collectors;
|
||||
* @param <T> The type of container this server input belongs to.
|
||||
*/
|
||||
public class ServerInputState<T extends AbstractContainerMenu & ComputerMenu> implements ServerInputHandler {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ServerInputState.class);
|
||||
|
||||
private final T owner;
|
||||
private final IntSet keysDown = new IntOpenHashSet(4);
|
||||
|
||||
@ -118,7 +121,7 @@ public class ServerInputState<T extends AbstractContainerMenu & ComputerMenu> im
|
||||
@Override
|
||||
public void continueUpload(UUID uploadId, List<FileSlice> slices) {
|
||||
if (toUploadId == null || toUpload == null || !toUploadId.equals(uploadId)) {
|
||||
ComputerCraft.log.warn("Invalid continueUpload call, skipping.");
|
||||
LOG.warn("Invalid continueUpload call, skipping.");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -128,7 +131,7 @@ public class ServerInputState<T extends AbstractContainerMenu & ComputerMenu> im
|
||||
@Override
|
||||
public void finishUpload(ServerPlayer uploader, UUID uploadId) {
|
||||
if (toUploadId == null || toUpload == null || toUpload.isEmpty() || !toUploadId.equals(uploadId)) {
|
||||
ComputerCraft.log.warn("Invalid finishUpload call, skipping.");
|
||||
LOG.warn("Invalid finishUpload call, skipping.");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -143,7 +146,7 @@ public class ServerInputState<T extends AbstractContainerMenu & ComputerMenu> im
|
||||
|
||||
for (var upload : toUpload) {
|
||||
if (!upload.checksumMatches()) {
|
||||
ComputerCraft.log.warn("Checksum failed to match for {}.", upload.getName());
|
||||
LOG.warn("Checksum failed to match for {}.", upload.getName());
|
||||
return UploadResultMessage.error(owner, Component.translatable("gui.computercraft.upload.failed.corrupted"));
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,6 @@
|
||||
package dan200.computercraft.shared.computer.metrics;
|
||||
|
||||
import com.google.common.base.CaseFormat;
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.core.metrics.Metric;
|
||||
import dan200.computercraft.core.metrics.Metrics;
|
||||
import dan200.computercraft.shared.computer.core.ServerComputer;
|
||||
@ -16,6 +15,8 @@ import dan200.computercraft.shared.computer.metrics.basic.AggregatedMetric;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.management.*;
|
||||
@ -31,6 +32,8 @@ import java.util.function.LongSupplier;
|
||||
* An MBean which exposes aggregate statistics about all computers on the server.
|
||||
*/
|
||||
public final class ComputerMBean implements DynamicMBean, ComputerMetricsObserver {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ComputerMBean.class);
|
||||
|
||||
private static @Nullable ComputerMBean instance;
|
||||
|
||||
private final Map<String, LongSupplier> attributes = new HashMap<>();
|
||||
@ -60,7 +63,7 @@ public final class ComputerMBean implements DynamicMBean, ComputerMetricsObserve
|
||||
ManagementFactory.getPlatformMBeanServer().registerMBean(instance = new ComputerMBean(), new ObjectName("dan200.computercraft:type=Computers"));
|
||||
} catch (InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException |
|
||||
MalformedObjectNameException e) {
|
||||
ComputerCraft.log.warn("Failed to register JMX bean", e);
|
||||
LOG.warn("Failed to register JMX bean", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,21 +5,24 @@
|
||||
*/
|
||||
package dan200.computercraft.shared.computer.upload;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.List;
|
||||
|
||||
public record FileSlice(int fileId, int offset, ByteBuffer bytes) {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(FileSlice.class);
|
||||
|
||||
public void apply(List<FileUpload> files) {
|
||||
if (fileId < 0 || fileId >= files.size()) {
|
||||
ComputerCraft.log.warn("File ID is out-of-bounds (0 <= {} < {})", fileId, files.size());
|
||||
LOG.warn("File ID is out-of-bounds (0 <= {} < {})", fileId, files.size());
|
||||
return;
|
||||
}
|
||||
|
||||
var file = files.get(fileId).getBytes();
|
||||
if (offset < 0 || offset + bytes.remaining() > file.capacity()) {
|
||||
ComputerCraft.log.warn("File offset is out-of-bounds (0 <= {} <= {})", offset, file.capacity() - offset);
|
||||
LOG.warn("File offset is out-of-bounds (0 <= {} <= {})", offset, file.capacity() - offset);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,8 @@
|
||||
*/
|
||||
package dan200.computercraft.shared.computer.upload;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.nio.ByteBuffer;
|
||||
@ -14,6 +15,8 @@ import java.security.NoSuchAlgorithmException;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class FileUpload {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(FileUpload.class);
|
||||
|
||||
public static final int CHECKSUM_LENGTH = 32;
|
||||
|
||||
private final String name;
|
||||
@ -57,7 +60,7 @@ public class FileUpload {
|
||||
digest.update(bytes.duplicate());
|
||||
return digest.digest();
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
ComputerCraft.log.warn("Failed to compute digest ({})", e.toString());
|
||||
LOG.warn("Failed to compute digest ({})", e.toString());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -3,15 +3,16 @@
|
||||
* Copyright Daniel Ratcliffe, 2011-2022. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
*/
|
||||
package dan200.computercraft.shared;
|
||||
package dan200.computercraft.shared.config;
|
||||
|
||||
import com.electronwill.nightconfig.core.Config;
|
||||
import com.electronwill.nightconfig.core.InMemoryCommentedFormat;
|
||||
import com.electronwill.nightconfig.core.UnmodifiableConfig;
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.core.apis.http.options.Action;
|
||||
import dan200.computercraft.core.apis.http.options.AddressRule;
|
||||
import dan200.computercraft.core.apis.http.options.PartialOptions;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Locale;
|
||||
@ -23,7 +24,9 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
/**
|
||||
* Parses, checks and generates {@link Config}s for {@link AddressRule}.
|
||||
*/
|
||||
public class AddressRuleConfig {
|
||||
class AddressRuleConfig {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(AddressRuleConfig.class);
|
||||
|
||||
public static UnmodifiableConfig makeRule(String host, Action action) {
|
||||
var config = InMemoryCommentedFormat.defaultInstance().createConfig(ConcurrentHashMap::new);
|
||||
config.add("host", host);
|
||||
@ -85,7 +88,7 @@ public class AddressRuleConfig {
|
||||
var value = config.get(field);
|
||||
if (value == null || klass.isInstance(value)) return true;
|
||||
|
||||
ComputerCraft.log.warn("HTTP rule's {} is not a {}.", field, klass.getSimpleName());
|
||||
LOG.warn("HTTP rule's {} is not a {}.", field, klass.getSimpleName());
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -94,12 +97,12 @@ public class AddressRuleConfig {
|
||||
if (value == null) return true;
|
||||
|
||||
if (!(value instanceof String)) {
|
||||
ComputerCraft.log.warn("HTTP rule's {} is not a string", field);
|
||||
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);
|
||||
LOG.warn("HTTP rule's {} is not a known option", field);
|
||||
return false;
|
||||
}
|
||||
|
54
src/main/java/dan200/computercraft/shared/config/Config.java
Normal file
54
src/main/java/dan200/computercraft/shared/config/Config.java
Normal file
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* 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.config;
|
||||
|
||||
import dan200.computercraft.shared.peripheral.monitor.MonitorRenderer;
|
||||
|
||||
/**
|
||||
* ComputerCraft's global config.
|
||||
*
|
||||
* @see ConfigSpec The definition of our config values.
|
||||
*/
|
||||
public final class Config {
|
||||
public static int computerSpaceLimit = 1000 * 1000;
|
||||
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;
|
||||
public static int modemRangeDuringStorm = 64;
|
||||
public static int modemHighAltitudeRangeDuringStorm = 384;
|
||||
public static int maxNotesPerTick = 8;
|
||||
public static MonitorRenderer monitorRenderer = MonitorRenderer.BEST;
|
||||
public static int monitorDistance = 65;
|
||||
public static long monitorBandwidth = 1_000_000;
|
||||
|
||||
public static boolean turtlesNeedFuel = true;
|
||||
public static int turtleFuelLimit = 20000;
|
||||
public static int advancedTurtleFuelLimit = 100000;
|
||||
public static boolean turtlesObeyBlockProtection = true;
|
||||
public static boolean turtlesCanPush = true;
|
||||
|
||||
public static int computerTermWidth = 51;
|
||||
public static int computerTermHeight = 19;
|
||||
|
||||
public static final int turtleTermWidth = 39;
|
||||
public static final int turtleTermHeight = 13;
|
||||
|
||||
public static int pocketTermWidth = 26;
|
||||
public static int pocketTermHeight = 20;
|
||||
|
||||
public static int monitorWidth = 8;
|
||||
public static int monitorHeight = 6;
|
||||
|
||||
public static int uploadNagDelay = 5;
|
||||
|
||||
private Config() {
|
||||
}
|
||||
}
|
@ -3,10 +3,10 @@
|
||||
* Copyright Daniel Ratcliffe, 2011-2022. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
*/
|
||||
package dan200.computercraft.shared;
|
||||
package dan200.computercraft.shared.config;
|
||||
|
||||
import com.electronwill.nightconfig.core.UnmodifiableConfig;
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import dan200.computercraft.core.CoreConfig;
|
||||
import dan200.computercraft.core.Logging;
|
||||
import dan200.computercraft.core.apis.http.NetworkUtils;
|
||||
@ -25,7 +25,7 @@ import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public final class Config {
|
||||
public final class ConfigSpec {
|
||||
private static final int MODEM_MAX_RANGE = 100000;
|
||||
|
||||
private static final String TRANSLATION_PREFIX = "gui.computercraft.config.";
|
||||
@ -84,7 +84,7 @@ public final class Config {
|
||||
|
||||
private static MarkerFilter logFilter = MarkerFilter.createFilter(Logging.COMPUTER_ERROR.getName(), Filter.Result.ACCEPT, Filter.Result.NEUTRAL);
|
||||
|
||||
private Config() {
|
||||
private ConfigSpec() {
|
||||
}
|
||||
|
||||
static {
|
||||
@ -96,12 +96,12 @@ public final class Config {
|
||||
computerSpaceLimit = builder
|
||||
.comment("The disk space limit for computers and turtles, in bytes.")
|
||||
.translation(TRANSLATION_PREFIX + "computer_space_limit")
|
||||
.define("computer_space_limit", ComputerCraft.computerSpaceLimit);
|
||||
.define("computer_space_limit", Config.computerSpaceLimit);
|
||||
|
||||
floppySpaceLimit = builder
|
||||
.comment("The disk space limit for floppy disks, in bytes.")
|
||||
.translation(TRANSLATION_PREFIX + "floppy_space_limit")
|
||||
.define("floppy_space_limit", ComputerCraft.floppySpaceLimit);
|
||||
.define("floppy_space_limit", Config.floppySpaceLimit);
|
||||
|
||||
maximumFilesOpen = builder
|
||||
.comment("Set how many files a computer can have open at the same time. Set to 0 for unlimited.")
|
||||
@ -132,7 +132,7 @@ public final class Config {
|
||||
.comment("""
|
||||
Require players to be in creative mode and be opped in order to interact with
|
||||
command computers. This is the default behaviour for vanilla's Command blocks.""")
|
||||
.define("command_require_creative", ComputerCraft.commandRequireCreative);
|
||||
.define("command_require_creative", Config.commandRequireCreative);
|
||||
}
|
||||
|
||||
{
|
||||
@ -147,7 +147,7 @@ public final class Config {
|
||||
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", ComputerCraft.computerThreads, 1, Integer.MAX_VALUE);
|
||||
.defineInRange("computer_threads", Config.computerThreads, 1, Integer.MAX_VALUE);
|
||||
|
||||
maxMainGlobalTime = builder
|
||||
.comment("""
|
||||
@ -230,27 +230,27 @@ public final class Config {
|
||||
|
||||
commandBlockEnabled = builder
|
||||
.comment("Enable Command Block peripheral support")
|
||||
.define("command_block_enabled", ComputerCraft.enableCommandBlock);
|
||||
.define("command_block_enabled", Config.enableCommandBlock);
|
||||
|
||||
modemRange = builder
|
||||
.comment("The range of Wireless Modems at low altitude in clear weather, in meters.")
|
||||
.defineInRange("modem_range", ComputerCraft.modemRange, 0, MODEM_MAX_RANGE);
|
||||
.defineInRange("modem_range", Config.modemRange, 0, MODEM_MAX_RANGE);
|
||||
|
||||
modemHighAltitudeRange = builder
|
||||
.comment("The range of Wireless Modems at maximum altitude in clear weather, in meters.")
|
||||
.defineInRange("modem_high_altitude_range", ComputerCraft.modemHighAltitudeRange, 0, MODEM_MAX_RANGE);
|
||||
.defineInRange("modem_high_altitude_range", Config.modemHighAltitudeRange, 0, MODEM_MAX_RANGE);
|
||||
|
||||
modemRangeDuringStorm = builder
|
||||
.comment("The range of Wireless Modems at low altitude in stormy weather, in meters.")
|
||||
.defineInRange("modem_range_during_storm", ComputerCraft.modemRangeDuringStorm, 0, MODEM_MAX_RANGE);
|
||||
.defineInRange("modem_range_during_storm", Config.modemRangeDuringStorm, 0, MODEM_MAX_RANGE);
|
||||
|
||||
modemHighAltitudeRangeDuringStorm = builder
|
||||
.comment("The range of Wireless Modems at maximum altitude in stormy weather, in meters.")
|
||||
.defineInRange("modem_high_altitude_range_during_storm", ComputerCraft.modemHighAltitudeRangeDuringStorm, 0, MODEM_MAX_RANGE);
|
||||
.defineInRange("modem_high_altitude_range_during_storm", Config.modemHighAltitudeRangeDuringStorm, 0, MODEM_MAX_RANGE);
|
||||
|
||||
maxNotesPerTick = builder
|
||||
.comment("Maximum amount of notes a speaker can play at once.")
|
||||
.defineInRange("max_notes_per_tick", ComputerCraft.maxNotesPerTick, 1, Integer.MAX_VALUE);
|
||||
.defineInRange("max_notes_per_tick", Config.maxNotesPerTick, 1, Integer.MAX_VALUE);
|
||||
|
||||
monitorBandwidth = builder
|
||||
.comment("""
|
||||
@ -262,7 +262,7 @@ public final class Config {
|
||||
- A full sized monitor sends ~25kb of data. So the default (1MB) allows for ~40
|
||||
monitors to be updated in a single tick.
|
||||
Set to 0 to disable.""")
|
||||
.defineInRange("monitor_bandwidth", (int) ComputerCraft.monitorBandwidth, 0, Integer.MAX_VALUE);
|
||||
.defineInRange("monitor_bandwidth", (int) Config.monitorBandwidth, 0, Integer.MAX_VALUE);
|
||||
|
||||
builder.pop();
|
||||
}
|
||||
@ -273,27 +273,27 @@ public final class Config {
|
||||
|
||||
turtlesNeedFuel = builder
|
||||
.comment("Set whether Turtles require fuel to move.")
|
||||
.define("need_fuel", ComputerCraft.turtlesNeedFuel);
|
||||
.define("need_fuel", Config.turtlesNeedFuel);
|
||||
|
||||
turtleFuelLimit = builder
|
||||
.comment("The fuel limit for Turtles.")
|
||||
.defineInRange("normal_fuel_limit", ComputerCraft.turtleFuelLimit, 0, Integer.MAX_VALUE);
|
||||
.defineInRange("normal_fuel_limit", Config.turtleFuelLimit, 0, Integer.MAX_VALUE);
|
||||
|
||||
advancedTurtleFuelLimit = builder
|
||||
.comment("The fuel limit for Advanced Turtles.")
|
||||
.defineInRange("advanced_fuel_limit", ComputerCraft.advancedTurtleFuelLimit, 0, Integer.MAX_VALUE);
|
||||
.defineInRange("advanced_fuel_limit", Config.advancedTurtleFuelLimit, 0, Integer.MAX_VALUE);
|
||||
|
||||
turtlesObeyBlockProtection = builder
|
||||
.comment("""
|
||||
If set to true, Turtles will be unable to build, dig, or enter protected areas
|
||||
(such as near the server spawn point).""")
|
||||
.define("obey_block_protection", ComputerCraft.turtlesObeyBlockProtection);
|
||||
.define("obey_block_protection", Config.turtlesObeyBlockProtection);
|
||||
|
||||
turtlesCanPush = builder
|
||||
.comment("""
|
||||
If set to true, Turtles will push entities out of the way instead of stopping if
|
||||
there is space to do so.""")
|
||||
.define("can_push", ComputerCraft.turtlesCanPush);
|
||||
.define("can_push", Config.turtlesCanPush);
|
||||
|
||||
builder.pop();
|
||||
}
|
||||
@ -306,18 +306,18 @@ public final class Config {
|
||||
.push("term_sizes");
|
||||
|
||||
builder.comment("Terminal size of computers.").push("computer");
|
||||
computerTermWidth = builder.defineInRange("width", ComputerCraft.computerTermWidth, 1, 255);
|
||||
computerTermHeight = builder.defineInRange("height", ComputerCraft.computerTermHeight, 1, 255);
|
||||
computerTermWidth = builder.defineInRange("width", Config.computerTermWidth, 1, 255);
|
||||
computerTermHeight = builder.defineInRange("height", Config.computerTermHeight, 1, 255);
|
||||
builder.pop();
|
||||
|
||||
builder.comment("Terminal size of pocket computers.").push("pocket_computer");
|
||||
pocketTermWidth = builder.defineInRange("width", ComputerCraft.pocketTermWidth, 1, 255);
|
||||
pocketTermHeight = builder.defineInRange("height", ComputerCraft.pocketTermHeight, 1, 255);
|
||||
pocketTermWidth = builder.defineInRange("width", Config.pocketTermWidth, 1, 255);
|
||||
pocketTermHeight = builder.defineInRange("height", Config.pocketTermHeight, 1, 255);
|
||||
builder.pop();
|
||||
|
||||
builder.comment("Maximum size of monitors (in blocks).").push("monitor");
|
||||
monitorWidth = builder.defineInRange("width", ComputerCraft.monitorWidth, 1, 32);
|
||||
monitorHeight = builder.defineInRange("height", ComputerCraft.monitorHeight, 1, 32);
|
||||
monitorWidth = builder.defineInRange("width", Config.monitorWidth, 1, 32);
|
||||
monitorHeight = builder.defineInRange("height", Config.monitorHeight, 1, 32);
|
||||
builder.pop();
|
||||
|
||||
builder.pop();
|
||||
@ -339,7 +339,7 @@ public final class Config {
|
||||
.defineInRange("monitor_distance", 64, 16, 1024);
|
||||
uploadNagDelay = clientBuilder
|
||||
.comment("The delay in seconds after which we'll notify about unhandled imports. Set to 0 to disable.")
|
||||
.defineInRange("upload_nag_delay", ComputerCraft.uploadNagDelay, 0, 60);
|
||||
.defineInRange("upload_nag_delay", Config.uploadNagDelay, 0, 60);
|
||||
|
||||
clientSpec = clientBuilder.build();
|
||||
}
|
||||
@ -351,16 +351,16 @@ public final class Config {
|
||||
|
||||
private static void syncServer() {
|
||||
// General
|
||||
ComputerCraft.computerSpaceLimit = computerSpaceLimit.get();
|
||||
ComputerCraft.floppySpaceLimit = floppySpaceLimit.get();
|
||||
Config.computerSpaceLimit = computerSpaceLimit.get();
|
||||
Config.floppySpaceLimit = floppySpaceLimit.get();
|
||||
CoreConfig.maximumFilesOpen = maximumFilesOpen.get();
|
||||
CoreConfig.disableLua51Features = disableLua51Features.get();
|
||||
CoreConfig.defaultComputerSettings = defaultComputerSettings.get();
|
||||
ComputerCraft.computerThreads = computerThreads.get();
|
||||
ComputerCraft.commandRequireCreative = commandRequireCreative.get();
|
||||
Config.computerThreads = computerThreads.get();
|
||||
Config.commandRequireCreative = commandRequireCreative.get();
|
||||
|
||||
// Execution
|
||||
ComputerCraft.computerThreads = computerThreads.get();
|
||||
Config.computerThreads = computerThreads.get();
|
||||
CoreConfig.maxMainGlobalTime = TimeUnit.MILLISECONDS.toNanos(maxMainGlobalTime.get());
|
||||
CoreConfig.maxMainComputerTime = TimeUnit.MILLISECONDS.toNanos(maxMainComputerTime.get());
|
||||
|
||||
@ -370,9 +370,9 @@ public final class Config {
|
||||
logComputerErrors.get() ? Filter.Result.ACCEPT : Filter.Result.DENY,
|
||||
Filter.Result.NEUTRAL
|
||||
);
|
||||
if (!logFilter.equals(Config.logFilter)) {
|
||||
LoggerContext.getContext().removeFilter(Config.logFilter);
|
||||
LoggerContext.getContext().addFilter(Config.logFilter = logFilter);
|
||||
if (!logFilter.equals(ConfigSpec.logFilter)) {
|
||||
LoggerContext.getContext().removeFilter(ConfigSpec.logFilter);
|
||||
LoggerContext.getContext().addFilter(ConfigSpec.logFilter = logFilter);
|
||||
}
|
||||
|
||||
// HTTP
|
||||
@ -388,38 +388,38 @@ public final class Config {
|
||||
NetworkUtils.reloadConfig();
|
||||
|
||||
// Peripheral
|
||||
ComputerCraft.enableCommandBlock = commandBlockEnabled.get();
|
||||
ComputerCraft.maxNotesPerTick = maxNotesPerTick.get();
|
||||
ComputerCraft.modemRange = modemRange.get();
|
||||
ComputerCraft.modemHighAltitudeRange = modemHighAltitudeRange.get();
|
||||
ComputerCraft.modemRangeDuringStorm = modemRangeDuringStorm.get();
|
||||
ComputerCraft.modemHighAltitudeRangeDuringStorm = modemHighAltitudeRangeDuringStorm.get();
|
||||
ComputerCraft.monitorBandwidth = monitorBandwidth.get();
|
||||
Config.enableCommandBlock = commandBlockEnabled.get();
|
||||
Config.maxNotesPerTick = maxNotesPerTick.get();
|
||||
Config.modemRange = modemRange.get();
|
||||
Config.modemHighAltitudeRange = modemHighAltitudeRange.get();
|
||||
Config.modemRangeDuringStorm = modemRangeDuringStorm.get();
|
||||
Config.modemHighAltitudeRangeDuringStorm = modemHighAltitudeRangeDuringStorm.get();
|
||||
Config.monitorBandwidth = monitorBandwidth.get();
|
||||
|
||||
// Turtles
|
||||
ComputerCraft.turtlesNeedFuel = turtlesNeedFuel.get();
|
||||
ComputerCraft.turtleFuelLimit = turtleFuelLimit.get();
|
||||
ComputerCraft.advancedTurtleFuelLimit = advancedTurtleFuelLimit.get();
|
||||
ComputerCraft.turtlesObeyBlockProtection = turtlesObeyBlockProtection.get();
|
||||
ComputerCraft.turtlesCanPush = turtlesCanPush.get();
|
||||
Config.turtlesNeedFuel = turtlesNeedFuel.get();
|
||||
Config.turtleFuelLimit = turtleFuelLimit.get();
|
||||
Config.advancedTurtleFuelLimit = advancedTurtleFuelLimit.get();
|
||||
Config.turtlesObeyBlockProtection = turtlesObeyBlockProtection.get();
|
||||
Config.turtlesCanPush = turtlesCanPush.get();
|
||||
|
||||
// Terminal size
|
||||
ComputerCraft.computerTermWidth = computerTermWidth.get();
|
||||
ComputerCraft.computerTermHeight = computerTermHeight.get();
|
||||
ComputerCraft.pocketTermWidth = pocketTermWidth.get();
|
||||
ComputerCraft.pocketTermHeight = pocketTermHeight.get();
|
||||
ComputerCraft.monitorWidth = monitorWidth.get();
|
||||
ComputerCraft.monitorHeight = monitorHeight.get();
|
||||
Config.computerTermWidth = computerTermWidth.get();
|
||||
Config.computerTermHeight = computerTermHeight.get();
|
||||
Config.pocketTermWidth = pocketTermWidth.get();
|
||||
Config.pocketTermHeight = pocketTermHeight.get();
|
||||
Config.monitorWidth = monitorWidth.get();
|
||||
Config.monitorHeight = monitorHeight.get();
|
||||
}
|
||||
|
||||
private static void syncClient() {
|
||||
ComputerCraft.monitorRenderer = monitorRenderer.get();
|
||||
ComputerCraft.monitorDistance = monitorDistance.get();
|
||||
ComputerCraft.uploadNagDelay = uploadNagDelay.get();
|
||||
Config.monitorRenderer = monitorRenderer.get();
|
||||
Config.monitorDistance = monitorDistance.get();
|
||||
Config.uploadNagDelay = uploadNagDelay.get();
|
||||
}
|
||||
|
||||
public static void sync(ModConfig config) {
|
||||
if (!config.getModId().equals(ComputerCraft.MOD_ID)) return;
|
||||
if (!config.getModId().equals(ComputerCraftAPI.MOD_ID)) return;
|
||||
if (config.getType() == ModConfig.Type.SERVER) syncServer();
|
||||
if (config.getType() == ModConfig.Type.CLIENT) syncClient();
|
||||
}
|
@ -5,7 +5,7 @@
|
||||
*/
|
||||
package dan200.computercraft.shared.integration;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import dan200.computercraft.shared.PocketUpgrades;
|
||||
import dan200.computercraft.shared.TurtleUpgrades;
|
||||
import dan200.computercraft.shared.computer.core.ComputerFamily;
|
||||
@ -35,7 +35,7 @@ public final class RecipeModHelpers {
|
||||
* @return Whether it should be removed.
|
||||
*/
|
||||
public static boolean shouldRemoveRecipe(ResourceLocation id) {
|
||||
if (!id.getNamespace().equals(ComputerCraft.MOD_ID)) return false;
|
||||
if (!id.getNamespace().equals(ComputerCraftAPI.MOD_ID)) return false;
|
||||
|
||||
var path = id.getPath();
|
||||
return path.startsWith("turtle_normal/") || path.startsWith("turtle_advanced/")
|
||||
|
@ -5,7 +5,7 @@
|
||||
*/
|
||||
package dan200.computercraft.shared.integration;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import dan200.computercraft.api.pocket.IPocketUpgrade;
|
||||
import dan200.computercraft.api.turtle.ITurtleUpgrade;
|
||||
import dan200.computercraft.api.turtle.TurtleSide;
|
||||
@ -38,8 +38,8 @@ import static dan200.computercraft.shared.integration.RecipeModHelpers.MAIN_FAMI
|
||||
* @see RecipeModHelpers
|
||||
*/
|
||||
public class UpgradeRecipeGenerator<T> {
|
||||
private static final ResourceLocation TURTLE_UPGRADE = new ResourceLocation(ComputerCraft.MOD_ID, "turtle_upgrade");
|
||||
private static final ResourceLocation POCKET_UPGRADE = new ResourceLocation(ComputerCraft.MOD_ID, "pocket_upgrade");
|
||||
private static final ResourceLocation TURTLE_UPGRADE = new ResourceLocation(ComputerCraftAPI.MOD_ID, "turtle_upgrade");
|
||||
private static final ResourceLocation POCKET_UPGRADE = new ResourceLocation(ComputerCraftAPI.MOD_ID, "pocket_upgrade");
|
||||
|
||||
private final Function<CraftingRecipe, T> wrap;
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
*/
|
||||
package dan200.computercraft.shared.integration.jei;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import dan200.computercraft.api.turtle.TurtleSide;
|
||||
import dan200.computercraft.shared.ModRegistry;
|
||||
import dan200.computercraft.shared.integration.RecipeModHelpers;
|
||||
@ -29,7 +29,7 @@ import java.util.Collections;
|
||||
public class JEIComputerCraft implements IModPlugin {
|
||||
@Override
|
||||
public ResourceLocation getPluginUid() {
|
||||
return new ResourceLocation(ComputerCraft.MOD_ID, "jei");
|
||||
return new ResourceLocation(ComputerCraftAPI.MOD_ID, "jei");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -5,13 +5,13 @@
|
||||
*/
|
||||
package dan200.computercraft.shared.media.items;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import dan200.computercraft.api.filesystem.IMount;
|
||||
import dan200.computercraft.api.media.IMedia;
|
||||
import dan200.computercraft.core.util.Colour;
|
||||
import dan200.computercraft.shared.ModRegistry;
|
||||
import dan200.computercraft.shared.common.IColouredItem;
|
||||
import dan200.computercraft.shared.config.Config;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.NonNullList;
|
||||
@ -88,7 +88,7 @@ public class ItemDisk extends Item implements IMedia, IColouredItem {
|
||||
diskID = ComputerCraftAPI.createUniqueNumberedSaveDir(world, "disk");
|
||||
setDiskID(stack, diskID);
|
||||
}
|
||||
return ComputerCraftAPI.createSaveDirMount(world, "disk/" + diskID, ComputerCraft.floppySpaceLimit);
|
||||
return ComputerCraftAPI.createSaveDirMount(world, "disk/" + diskID, Config.floppySpaceLimit);
|
||||
}
|
||||
|
||||
public static int getDiskID(ItemStack stack) {
|
||||
|
@ -5,7 +5,7 @@
|
||||
*/
|
||||
package dan200.computercraft.shared.peripheral.generic.methods;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import dan200.computercraft.api.lua.LuaFunction;
|
||||
import dan200.computercraft.api.peripheral.GenericPeripheral;
|
||||
import dan200.computercraft.api.peripheral.PeripheralType;
|
||||
@ -33,7 +33,7 @@ public class EnergyMethods implements GenericPeripheral {
|
||||
|
||||
@Override
|
||||
public ResourceLocation id() {
|
||||
return new ResourceLocation(ComputerCraft.MOD_ID, "energy");
|
||||
return new ResourceLocation(ComputerCraftAPI.MOD_ID, "energy");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -5,7 +5,7 @@
|
||||
*/
|
||||
package dan200.computercraft.shared.peripheral.generic.methods;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import dan200.computercraft.api.detail.ForgeDetailRegistries;
|
||||
import dan200.computercraft.api.lua.LuaException;
|
||||
import dan200.computercraft.api.lua.LuaFunction;
|
||||
@ -41,7 +41,7 @@ public class FluidMethods implements GenericPeripheral {
|
||||
|
||||
@Override
|
||||
public ResourceLocation id() {
|
||||
return new ResourceLocation(ComputerCraft.MOD_ID, "fluid");
|
||||
return new ResourceLocation(ComputerCraftAPI.MOD_ID, "fluid");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -5,7 +5,7 @@
|
||||
*/
|
||||
package dan200.computercraft.shared.peripheral.generic.methods;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import dan200.computercraft.api.detail.VanillaDetailRegistries;
|
||||
import dan200.computercraft.api.lua.ILuaContext;
|
||||
import dan200.computercraft.api.lua.LuaException;
|
||||
@ -43,7 +43,7 @@ public class InventoryMethods implements GenericPeripheral {
|
||||
|
||||
@Override
|
||||
public ResourceLocation id() {
|
||||
return new ResourceLocation(ComputerCraft.MOD_ID, "inventory");
|
||||
return new ResourceLocation(ComputerCraftAPI.MOD_ID, "inventory");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -6,7 +6,6 @@
|
||||
package dan200.computercraft.shared.peripheral.modem.wired;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.filesystem.IMount;
|
||||
import dan200.computercraft.api.filesystem.IWritableMount;
|
||||
import dan200.computercraft.api.lua.*;
|
||||
@ -23,6 +22,8 @@ import dan200.computercraft.core.util.LuaUtil;
|
||||
import dan200.computercraft.shared.peripheral.modem.ModemPeripheral;
|
||||
import dan200.computercraft.shared.peripheral.modem.ModemState;
|
||||
import net.minecraft.world.level.Level;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.*;
|
||||
@ -30,6 +31,8 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
public abstract class WiredModemPeripheral extends ModemPeripheral implements IWiredSender {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(WiredModemPeripheral.class);
|
||||
|
||||
private final WiredModemElement modem;
|
||||
|
||||
private final Map<IComputerAccess, ConcurrentMap<String, RemotePeripheralWrapper>> peripheralWrappers = new HashMap<>(1);
|
||||
@ -334,7 +337,7 @@ public abstract class WiredModemPeripheral extends ModemPeripheral implements IW
|
||||
|
||||
synchronized (this) {
|
||||
if (!mounts.isEmpty()) {
|
||||
ComputerCraft.log.warn("Peripheral {} called mount but did not call unmount for {}", peripheral, mounts);
|
||||
LOG.warn("Peripheral {} called mount but did not call unmount for {}", peripheral, mounts);
|
||||
}
|
||||
|
||||
for (var mount : mounts) computer.unmount(mount);
|
||||
|
@ -5,9 +5,9 @@
|
||||
*/
|
||||
package dan200.computercraft.shared.peripheral.modem.wireless;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import dan200.computercraft.api.network.IPacketNetwork;
|
||||
import dan200.computercraft.shared.config.Config;
|
||||
import dan200.computercraft.shared.peripheral.modem.ModemPeripheral;
|
||||
import dan200.computercraft.shared.peripheral.modem.ModemState;
|
||||
|
||||
@ -35,11 +35,11 @@ public abstract class WirelessModemPeripheral extends ModemPeripheral {
|
||||
var world = getLevel();
|
||||
if (world != null) {
|
||||
var position = getPosition();
|
||||
double minRange = ComputerCraft.modemRange;
|
||||
double maxRange = ComputerCraft.modemHighAltitudeRange;
|
||||
double minRange = Config.modemRange;
|
||||
double maxRange = Config.modemHighAltitudeRange;
|
||||
if (world.isRaining() && world.isThundering()) {
|
||||
minRange = ComputerCraft.modemRangeDuringStorm;
|
||||
maxRange = ComputerCraft.modemHighAltitudeRangeDuringStorm;
|
||||
minRange = Config.modemRangeDuringStorm;
|
||||
maxRange = Config.modemHighAltitudeRangeDuringStorm;
|
||||
}
|
||||
if (position.y > 96.0 && maxRange > minRange) {
|
||||
return minRange + (position.y - 96.0) * ((maxRange - minRange) / ((world.getMaxBuildHeight() - 1) - 96.0));
|
||||
|
@ -5,9 +5,11 @@
|
||||
*/
|
||||
package dan200.computercraft.shared.peripheral.monitor;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.shared.config.Config;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.level.Level;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@ -15,6 +17,8 @@ import java.util.Objects;
|
||||
* Expands a monitor into available space. This tries to expand in each direction until a fixed point is reached.
|
||||
*/
|
||||
class Expander {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(Expander.class);
|
||||
|
||||
private final Level level;
|
||||
private final Direction down;
|
||||
private final Direction right;
|
||||
@ -40,13 +44,13 @@ class Expander {
|
||||
// if we merge right/down and the next monitor has a width/height of 0. This /should/ never happen - validation
|
||||
// will catch it - but I also have a complete lack of faith in the code.
|
||||
// As an aside, I think the actual limit is width+height resizes, but again - complete lack of faith.
|
||||
var changeLimit = ComputerCraft.monitorWidth * ComputerCraft.monitorHeight + 1;
|
||||
var changeLimit = Config.monitorWidth * Config.monitorHeight + 1;
|
||||
while (expandIn(true, false) || expandIn(true, true) ||
|
||||
expandIn(false, false) || expandIn(false, true)
|
||||
) {
|
||||
changedCount++;
|
||||
if (changedCount > changeLimit) {
|
||||
ComputerCraft.log.error("Monitor has grown too much. This suggests there's an empty monitor in the world.");
|
||||
LOG.error("Monitor has grown too much. This suggests there's an empty monitor in the world.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -73,11 +77,11 @@ class Expander {
|
||||
if (useXAxis) {
|
||||
if (otherMonitor.getYIndex() != 0 || otherMonitor.getHeight() != height) return false;
|
||||
width += otherMonitor.getWidth();
|
||||
if (width > ComputerCraft.monitorWidth) return false;
|
||||
if (width > Config.monitorWidth) return false;
|
||||
} else {
|
||||
if (otherMonitor.getXIndex() != 0 || otherMonitor.getWidth() != width) return false;
|
||||
height += otherMonitor.getHeight();
|
||||
if (height > ComputerCraft.monitorHeight) return false;
|
||||
if (height > Config.monitorHeight) return false;
|
||||
}
|
||||
|
||||
if (!isPositive) {
|
||||
|
@ -5,8 +5,8 @@
|
||||
*/
|
||||
package dan200.computercraft.shared.peripheral.monitor;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.shared.computer.terminal.TerminalState;
|
||||
import dan200.computercraft.shared.config.Config;
|
||||
import dan200.computercraft.shared.network.client.MonitorClientMessage;
|
||||
import dan200.computercraft.shared.platform.PlatformHelper;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
@ -48,7 +48,7 @@ public final class MonitorWatcher {
|
||||
public static void onTick() {
|
||||
// Find all enqueued monitors and send their contents to all nearby players.
|
||||
|
||||
var limit = ComputerCraft.monitorBandwidth;
|
||||
var limit = Config.monitorBandwidth;
|
||||
var obeyLimit = limit > 0;
|
||||
|
||||
TileMonitor tile;
|
||||
|
@ -6,12 +6,12 @@
|
||||
package dan200.computercraft.shared.peripheral.monitor;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.peripheral.IComputerAccess;
|
||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
import dan200.computercraft.core.terminal.Terminal;
|
||||
import dan200.computercraft.shared.common.TileGeneric;
|
||||
import dan200.computercraft.shared.computer.terminal.TerminalState;
|
||||
import dan200.computercraft.shared.config.Config;
|
||||
import dan200.computercraft.shared.util.TickScheduler;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
@ -24,6 +24,8 @@ import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.HashSet;
|
||||
@ -31,6 +33,8 @@ import java.util.Set;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class TileMonitor extends TileGeneric {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(TileMonitor.class);
|
||||
|
||||
public static final double RENDER_BORDER = 2.0 / 16.0;
|
||||
public static final double RENDER_MARGIN = 0.5 / 16.0;
|
||||
public static final double RENDER_PIXEL_SCALE = 1.0 / 64.0;
|
||||
@ -251,7 +255,7 @@ public class TileMonitor extends TileGeneric {
|
||||
|
||||
public final void read(TerminalState state) {
|
||||
if (xIndex != 0 || yIndex != 0) {
|
||||
ComputerCraft.log.warn("Receiving monitor state for non-origin terminal at {}", getBlockPos());
|
||||
LOG.warn("Receiving monitor state for non-origin terminal at {}", getBlockPos());
|
||||
return;
|
||||
}
|
||||
|
||||
@ -462,8 +466,8 @@ public class TileMonitor extends TileGeneric {
|
||||
private void validate() {
|
||||
if (xIndex == 0 && yIndex == 0 && width == 1 && height == 1) return;
|
||||
|
||||
if (xIndex >= 0 && xIndex <= width && width > 0 && width <= ComputerCraft.monitorWidth &&
|
||||
yIndex >= 0 && yIndex <= height && height > 0 && height <= ComputerCraft.monitorHeight &&
|
||||
if (xIndex >= 0 && xIndex <= width && width > 0 && width <= Config.monitorWidth &&
|
||||
yIndex >= 0 && yIndex <= height && height > 0 && height <= Config.monitorHeight &&
|
||||
checkMonitorAt(0, 0) && checkMonitorAt(0, height - 1) &&
|
||||
checkMonitorAt(width - 1, 0) && checkMonitorAt(width - 1, height - 1)) {
|
||||
return;
|
||||
@ -471,7 +475,7 @@ public class TileMonitor extends TileGeneric {
|
||||
|
||||
// Something in our monitor is invalid. For now, let's just reset ourselves and then try to integrate ourselves
|
||||
// later.
|
||||
ComputerCraft.log.warn("Monitor is malformed, resetting to 1x1.");
|
||||
LOG.warn("Monitor is malformed, resetting to 1x1.");
|
||||
resize(1, 1);
|
||||
needsUpdate = true;
|
||||
}
|
||||
|
@ -5,7 +5,6 @@
|
||||
*/
|
||||
package dan200.computercraft.shared.peripheral.speaker;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.lua.ILuaContext;
|
||||
import dan200.computercraft.api.lua.LuaException;
|
||||
import dan200.computercraft.api.lua.LuaFunction;
|
||||
@ -13,6 +12,7 @@ import dan200.computercraft.api.lua.LuaTable;
|
||||
import dan200.computercraft.api.peripheral.IComputerAccess;
|
||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
import dan200.computercraft.core.util.Nullability;
|
||||
import dan200.computercraft.shared.config.Config;
|
||||
import dan200.computercraft.shared.network.client.SpeakerAudioClientMessage;
|
||||
import dan200.computercraft.shared.network.client.SpeakerMoveClientMessage;
|
||||
import dan200.computercraft.shared.network.client.SpeakerPlayClientMessage;
|
||||
@ -217,7 +217,7 @@ public abstract class SpeakerPeripheral implements IPeripheral {
|
||||
if (instrument == null) throw new LuaException("Invalid instrument, \"" + instrument + "\"!");
|
||||
|
||||
synchronized (pendingNotes) {
|
||||
if (pendingNotes.size() >= ComputerCraft.maxNotesPerTick) return false;
|
||||
if (pendingNotes.size() >= Config.maxNotesPerTick) return false;
|
||||
pendingNotes.add(new PendingSound(Registries.SOUND_EVENTS.getKey(instrument.getSoundEvent()), volume, (float) Math.pow(2.0, (pitch - 12.0) / 12.0)));
|
||||
}
|
||||
return true;
|
||||
|
@ -5,7 +5,6 @@
|
||||
*/
|
||||
package dan200.computercraft.shared.pocket.core;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
import dan200.computercraft.api.pocket.IPocketAccess;
|
||||
import dan200.computercraft.api.pocket.IPocketUpgrade;
|
||||
@ -13,6 +12,7 @@ import dan200.computercraft.core.computer.ComputerSide;
|
||||
import dan200.computercraft.shared.common.IColouredItem;
|
||||
import dan200.computercraft.shared.computer.core.ComputerFamily;
|
||||
import dan200.computercraft.shared.computer.core.ServerComputer;
|
||||
import dan200.computercraft.shared.config.Config;
|
||||
import dan200.computercraft.shared.network.client.PocketComputerDataMessage;
|
||||
import dan200.computercraft.shared.network.client.PocketComputerDeletedClientMessage;
|
||||
import dan200.computercraft.shared.platform.PlatformHelper;
|
||||
@ -42,7 +42,7 @@ public class PocketServerComputer extends ServerComputer implements IPocketAcces
|
||||
private final Set<ServerPlayer> tracking = new HashSet<>();
|
||||
|
||||
public PocketServerComputer(ServerLevel world, BlockPos position, int computerID, @Nullable String label, ComputerFamily family) {
|
||||
super(world, position, computerID, label, family, ComputerCraft.pocketTermWidth, ComputerCraft.pocketTermHeight);
|
||||
super(world, position, computerID, label, family, Config.pocketTermWidth, Config.pocketTermHeight);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
@ -6,7 +6,6 @@
|
||||
package dan200.computercraft.shared.pocket.items;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import dan200.computercraft.api.filesystem.IMount;
|
||||
import dan200.computercraft.api.media.IMedia;
|
||||
@ -17,6 +16,7 @@ import dan200.computercraft.shared.common.IColouredItem;
|
||||
import dan200.computercraft.shared.computer.core.ComputerFamily;
|
||||
import dan200.computercraft.shared.computer.core.ServerContext;
|
||||
import dan200.computercraft.shared.computer.items.IComputerItem;
|
||||
import dan200.computercraft.shared.config.Config;
|
||||
import dan200.computercraft.shared.network.container.ComputerContainerData;
|
||||
import dan200.computercraft.shared.pocket.apis.PocketAPI;
|
||||
import dan200.computercraft.shared.pocket.core.PocketServerComputer;
|
||||
@ -185,7 +185,7 @@ public class ItemPocketComputer extends Item implements IComputerItem, IMedia, I
|
||||
// If we're a non-vanilla, non-CC upgrade then return whichever mod this upgrade
|
||||
// belongs to.
|
||||
var mod = PocketUpgrades.instance().getOwner(upgrade);
|
||||
if (mod != null && !mod.equals(ComputerCraft.MOD_ID)) return mod;
|
||||
if (mod != null && !mod.equals(ComputerCraftAPI.MOD_ID)) return mod;
|
||||
}
|
||||
|
||||
return super.getCreatorModId(stack);
|
||||
@ -267,7 +267,7 @@ public class ItemPocketComputer extends Item implements IComputerItem, IMedia, I
|
||||
public @Nullable IMount createDataMount(ItemStack stack, Level world) {
|
||||
var id = getComputerID(stack);
|
||||
if (id >= 0) {
|
||||
return ComputerCraftAPI.createSaveDirMount(world, "computer/" + id, ComputerCraft.computerSpaceLimit);
|
||||
return ComputerCraftAPI.createSaveDirMount(world, "computer/" + id, Config.computerSpaceLimit);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -6,7 +6,6 @@
|
||||
package dan200.computercraft.shared.turtle.blocks;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
import dan200.computercraft.api.turtle.ITurtleAccess;
|
||||
import dan200.computercraft.api.turtle.ITurtleUpgrade;
|
||||
@ -18,6 +17,7 @@ import dan200.computercraft.shared.computer.blocks.TileComputerBase;
|
||||
import dan200.computercraft.shared.computer.core.ComputerFamily;
|
||||
import dan200.computercraft.shared.computer.core.ComputerState;
|
||||
import dan200.computercraft.shared.computer.core.ServerComputer;
|
||||
import dan200.computercraft.shared.config.Config;
|
||||
import dan200.computercraft.shared.turtle.apis.TurtleAPI;
|
||||
import dan200.computercraft.shared.turtle.core.TurtleBrain;
|
||||
import dan200.computercraft.shared.turtle.inventory.ContainerTurtle;
|
||||
@ -80,8 +80,8 @@ public class TileTurtle extends TileComputerBase implements ITurtleTile, Default
|
||||
protected ServerComputer createComputer(int id) {
|
||||
var computer = new ServerComputer(
|
||||
(ServerLevel) getLevel(), getBlockPos(), id, label,
|
||||
getFamily(), ComputerCraft.turtleTermWidth,
|
||||
ComputerCraft.turtleTermHeight
|
||||
getFamily(), Config.turtleTermWidth,
|
||||
Config.turtleTermHeight
|
||||
);
|
||||
computer.addAPI(new TurtleAPI(computer.getAPIEnvironment(), getAccess()));
|
||||
brain.setupComputer(computer);
|
||||
|
@ -7,7 +7,6 @@ package dan200.computercraft.shared.turtle.core;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.lua.ILuaCallback;
|
||||
import dan200.computercraft.api.lua.MethodResult;
|
||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
@ -17,6 +16,7 @@ import dan200.computercraft.core.util.Colour;
|
||||
import dan200.computercraft.shared.TurtleUpgrades;
|
||||
import dan200.computercraft.shared.computer.core.ComputerFamily;
|
||||
import dan200.computercraft.shared.computer.core.ServerComputer;
|
||||
import dan200.computercraft.shared.config.Config;
|
||||
import dan200.computercraft.shared.platform.PlatformHelper;
|
||||
import dan200.computercraft.shared.turtle.blocks.TileTurtle;
|
||||
import dan200.computercraft.shared.util.Holiday;
|
||||
@ -387,7 +387,7 @@ public class TurtleBrain implements ITurtleAccess {
|
||||
|
||||
@Override
|
||||
public boolean isFuelNeeded() {
|
||||
return ComputerCraft.turtlesNeedFuel;
|
||||
return Config.turtlesNeedFuel;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -404,9 +404,9 @@ public class TurtleBrain implements ITurtleAccess {
|
||||
@Override
|
||||
public int getFuelLimit() {
|
||||
if (owner.getFamily() == ComputerFamily.ADVANCED) {
|
||||
return ComputerCraft.advancedTurtleFuelLimit;
|
||||
return Config.advancedTurtleFuelLimit;
|
||||
} else {
|
||||
return ComputerCraft.turtleFuelLimit;
|
||||
return Config.turtleFuelLimit;
|
||||
}
|
||||
}
|
||||
|
||||
@ -681,7 +681,7 @@ public class TurtleBrain implements ITurtleAccess {
|
||||
if (animation != TurtleAnimation.NONE) {
|
||||
var world = getLevel();
|
||||
|
||||
if (ComputerCraft.turtlesCanPush) {
|
||||
if (Config.turtlesCanPush) {
|
||||
// Advance entity pushing
|
||||
if (animation == TurtleAnimation.MOVE_FORWARD ||
|
||||
animation == TurtleAnimation.MOVE_BACK ||
|
||||
|
@ -5,12 +5,12 @@
|
||||
*/
|
||||
package dan200.computercraft.shared.turtle.core;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.turtle.ITurtleAccess;
|
||||
import dan200.computercraft.api.turtle.ITurtleCommand;
|
||||
import dan200.computercraft.api.turtle.TurtleAnimation;
|
||||
import dan200.computercraft.api.turtle.TurtleCommandResult;
|
||||
import dan200.computercraft.shared.TurtlePermissions;
|
||||
import dan200.computercraft.shared.config.Config;
|
||||
import dan200.computercraft.shared.util.WorldUtil;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
@ -58,7 +58,7 @@ public class TurtleMoveCommand implements ITurtleCommand {
|
||||
);
|
||||
|
||||
if (!oldWorld.isUnobstructed(null, collision)) {
|
||||
if (!ComputerCraft.turtlesCanPush || this.direction == MoveDirection.UP || this.direction == MoveDirection.DOWN) {
|
||||
if (!Config.turtlesCanPush || this.direction == MoveDirection.UP || this.direction == MoveDirection.DOWN) {
|
||||
return TurtleCommandResult.failure("Movement obstructed");
|
||||
}
|
||||
|
||||
@ -104,7 +104,7 @@ public class TurtleMoveCommand implements ITurtleCommand {
|
||||
if (!world.isInWorldBounds(position)) return TurtleCommandResult.failure("Cannot leave the world");
|
||||
|
||||
// Check spawn protection
|
||||
if (ComputerCraft.turtlesObeyBlockProtection && !TurtlePermissions.isBlockEnterable(world, position, turtlePlayer)) {
|
||||
if (Config.turtlesObeyBlockProtection && !TurtlePermissions.isBlockEnterable(world, position, turtlePlayer)) {
|
||||
return TurtleCommandResult.failure("Cannot enter protected area");
|
||||
}
|
||||
|
||||
|
@ -5,12 +5,12 @@
|
||||
*/
|
||||
package dan200.computercraft.shared.turtle.core;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.turtle.ITurtleAccess;
|
||||
import dan200.computercraft.api.turtle.ITurtleCommand;
|
||||
import dan200.computercraft.api.turtle.TurtleAnimation;
|
||||
import dan200.computercraft.api.turtle.TurtleCommandResult;
|
||||
import dan200.computercraft.shared.TurtlePermissions;
|
||||
import dan200.computercraft.shared.config.Config;
|
||||
import dan200.computercraft.shared.turtle.TurtleUtil;
|
||||
import dan200.computercraft.shared.util.DropConsumer;
|
||||
import dan200.computercraft.shared.util.InventoryUtil;
|
||||
@ -172,7 +172,7 @@ public class TurtlePlaceCommand implements ITurtleCommand {
|
||||
var replaceable = state.canBeReplaced(context);
|
||||
if (!allowReplaceable && replaceable) return false;
|
||||
|
||||
if (ComputerCraft.turtlesObeyBlockProtection) {
|
||||
if (Config.turtlesObeyBlockProtection) {
|
||||
// Check spawn protection
|
||||
var editable = replaceable
|
||||
? TurtlePermissions.isBlockEditable(world, position, player)
|
||||
|
@ -6,7 +6,6 @@
|
||||
package dan200.computercraft.shared.turtle.core;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.turtle.ITurtleAccess;
|
||||
import dan200.computercraft.shared.turtle.TurtleUtil;
|
||||
import dan200.computercraft.shared.util.DirectionUtil;
|
||||
@ -25,12 +24,15 @@ import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.entity.SignBlockEntity;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraftforge.common.util.FakePlayer;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.OptionalInt;
|
||||
import java.util.UUID;
|
||||
|
||||
public final class TurtlePlayer extends FakePlayer {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(TurtlePlayer.class);
|
||||
private static final GameProfile DEFAULT_PROFILE = new GameProfile(
|
||||
UUID.fromString("0d0c4ca0-4ff1-11e4-916c-0800200c9a66"),
|
||||
"[ComputerCraft]"
|
||||
@ -84,7 +86,7 @@ public final class TurtlePlayer extends FakePlayer {
|
||||
|
||||
private void setState(ITurtleAccess turtle) {
|
||||
if (containerMenu != inventoryMenu) {
|
||||
ComputerCraft.log.warn("Turtle has open container ({})", containerMenu);
|
||||
LOG.warn("Turtle has open container ({})", containerMenu);
|
||||
doCloseContainer();
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
*/
|
||||
package dan200.computercraft.shared.turtle.items;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import dan200.computercraft.api.turtle.ITurtleUpgrade;
|
||||
import dan200.computercraft.api.turtle.TurtleSide;
|
||||
import dan200.computercraft.shared.TurtleUpgrades;
|
||||
@ -97,13 +97,13 @@ public class ItemTurtle extends ItemComputerBase implements ITurtleItem {
|
||||
var left = getUpgrade(stack, TurtleSide.LEFT);
|
||||
if (left != null) {
|
||||
var mod = TurtleUpgrades.instance().getOwner(left);
|
||||
if (mod != null && !mod.equals(ComputerCraft.MOD_ID)) return mod;
|
||||
if (mod != null && !mod.equals(ComputerCraftAPI.MOD_ID)) return mod;
|
||||
}
|
||||
|
||||
var right = getUpgrade(stack, TurtleSide.RIGHT);
|
||||
if (right != null) {
|
||||
var mod = TurtleUpgrades.instance().getOwner(right);
|
||||
if (mod != null && !mod.equals(ComputerCraft.MOD_ID)) return mod;
|
||||
if (mod != null && !mod.equals(ComputerCraftAPI.MOD_ID)) return mod;
|
||||
}
|
||||
|
||||
return super.getCreatorModId(stack);
|
||||
|
@ -5,10 +5,10 @@
|
||||
*/
|
||||
package dan200.computercraft.shared.turtle.upgrades;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.ComputerCraftTags;
|
||||
import dan200.computercraft.api.turtle.*;
|
||||
import dan200.computercraft.shared.TurtlePermissions;
|
||||
import dan200.computercraft.shared.config.Config;
|
||||
import dan200.computercraft.shared.turtle.TurtleUtil;
|
||||
import dan200.computercraft.shared.turtle.core.TurtlePlaceCommand;
|
||||
import dan200.computercraft.shared.turtle.core.TurtlePlayer;
|
||||
@ -169,7 +169,7 @@ public class TurtleTool extends AbstractTurtleUpgrade {
|
||||
var turtlePlayer = TurtlePlayer.getWithPosition(turtle, turtlePosition, direction);
|
||||
turtlePlayer.loadInventory(item.copy());
|
||||
|
||||
if (ComputerCraft.turtlesObeyBlockProtection) {
|
||||
if (Config.turtlesObeyBlockProtection) {
|
||||
// Check spawn protection
|
||||
if (MinecraftForge.EVENT_BUS.post(new BlockEvent.BreakEvent(world, blockPosition, state, turtlePlayer))) {
|
||||
return TurtleCommandResult.failure("Cannot break protected block");
|
||||
|
@ -5,14 +5,14 @@
|
||||
*/
|
||||
package dan200.computercraft.shared.util;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import dan200.computercraft.shared.ModRegistry;
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
public class CreativeTabMain extends CreativeModeTab {
|
||||
public CreativeTabMain() {
|
||||
super(ComputerCraft.MOD_ID);
|
||||
super(ComputerCraftAPI.MOD_ID);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -8,7 +8,8 @@ package dan200.computercraft.shared.util;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.IOException;
|
||||
@ -22,6 +23,7 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public final class IDAssigner {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(IDAssigner.class);
|
||||
public static final String COMPUTER = "computer";
|
||||
|
||||
private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create();
|
||||
@ -46,7 +48,7 @@ public final class IDAssigner {
|
||||
try (Writer writer = Files.newBufferedWriter(idFile, StandardCharsets.UTF_8)) {
|
||||
GSON.toJson(ids, writer);
|
||||
} catch (IOException e) {
|
||||
ComputerCraft.log.error("Cannot update ID file '{}'", idFile, e);
|
||||
LOG.error("Cannot update ID file '{}'", idFile, e);
|
||||
}
|
||||
|
||||
return next;
|
||||
@ -57,13 +59,13 @@ public final class IDAssigner {
|
||||
try (Reader reader = Files.newBufferedReader(idFile, StandardCharsets.UTF_8)) {
|
||||
return GSON.fromJson(reader, ID_TOKEN);
|
||||
} catch (Exception e) {
|
||||
ComputerCraft.log.error("Cannot load id file '" + idFile + "'", e);
|
||||
LOG.error("Cannot load id file '" + idFile + "'", e);
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
Files.createDirectories(idFile.getParent());
|
||||
} catch (IOException e) {
|
||||
ComputerCraft.log.error("Cannot create owning directory, IDs will not be persisted", e);
|
||||
LOG.error("Cannot create owning directory, IDs will not be persisted", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,9 +6,10 @@
|
||||
package dan200.computercraft.shared.util;
|
||||
|
||||
import com.google.common.io.BaseEncoding;
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.core.util.Nullability;
|
||||
import net.minecraft.nbt.*;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.DataOutput;
|
||||
@ -22,6 +23,7 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public final class NBTUtil {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(NBTUtil.class);
|
||||
private static final BaseEncoding ENCODING = BaseEncoding.base16().lowerCase();
|
||||
|
||||
private NBTUtil() {
|
||||
@ -159,7 +161,7 @@ public final class NBTUtil {
|
||||
var hash = digest.digest();
|
||||
return ENCODING.encode(hash);
|
||||
} catch (NoSuchAlgorithmException | IOException e) {
|
||||
ComputerCraft.log.error("Cannot hash NBT", e);
|
||||
LOG.error("Cannot hash NBT", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,8 @@
|
||||
*/
|
||||
package dan200.computercraft.shared.wired;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Verifies certain elements of a network are "well formed".
|
||||
@ -14,6 +15,7 @@ import dan200.computercraft.ComputerCraft;
|
||||
* in a development environment.
|
||||
*/
|
||||
public final class InvariantChecker {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(InvariantChecker.class);
|
||||
private static final boolean ENABLED = false;
|
||||
|
||||
private InvariantChecker() {
|
||||
@ -24,17 +26,17 @@ public final class InvariantChecker {
|
||||
|
||||
var network = node.network;
|
||||
if (network == null) {
|
||||
ComputerCraft.log.error("Node's network is null", new Exception());
|
||||
LOG.error("Node's network is null", new Exception());
|
||||
return;
|
||||
}
|
||||
|
||||
if (network.nodes == null || !network.nodes.contains(node)) {
|
||||
ComputerCraft.log.error("Node's network does not contain node", new Exception());
|
||||
LOG.error("Node's network does not contain node", new Exception());
|
||||
}
|
||||
|
||||
for (var neighbour : node.neighbours) {
|
||||
if (!neighbour.neighbours.contains(node)) {
|
||||
ComputerCraft.log.error("Neighbour is missing node", new Exception());
|
||||
LOG.error("Neighbour is missing node", new Exception());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,8 @@ import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import com.mojang.brigadier.builder.RequiredArgumentBuilder;
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import dan200.computercraft.gametest.core.TestHooks;
|
||||
import dan200.computercraft.shared.platform.Registries;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.network.chat.Component;
|
||||
@ -73,17 +74,17 @@ public class Exporter {
|
||||
|
||||
// First find all CC items
|
||||
for (var item : Registries.ITEMS) {
|
||||
if (Registries.ITEMS.getKey(item).getNamespace().equals(ComputerCraft.MOD_ID)) items.add(item);
|
||||
if (Registries.ITEMS.getKey(item).getNamespace().equals(ComputerCraftAPI.MOD_ID)) items.add(item);
|
||||
}
|
||||
|
||||
// Now find all CC recipes.
|
||||
for (var recipe : Minecraft.getInstance().level.getRecipeManager().getAllRecipesFor(RecipeType.CRAFTING)) {
|
||||
var result = recipe.getResultItem();
|
||||
if (!Registries.ITEMS.getKey(result.getItem()).getNamespace().equals(ComputerCraft.MOD_ID)) {
|
||||
if (!Registries.ITEMS.getKey(result.getItem()).getNamespace().equals(ComputerCraftAPI.MOD_ID)) {
|
||||
continue;
|
||||
}
|
||||
if (result.hasTag()) {
|
||||
ComputerCraft.log.warn("Skipping recipe {} as it has NBT", recipe.getId());
|
||||
TestHooks.LOG.warn("Skipping recipe {} as it has NBT", recipe.getId());
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -110,7 +111,7 @@ public class Exporter {
|
||||
|
||||
dump.recipes.put(recipe.getId().toString(), converted);
|
||||
} else {
|
||||
ComputerCraft.log.info("Don't know how to handle recipe {}", recipe);
|
||||
TestHooks.LOG.info("Don't know how to handle recipe {}", recipe);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
package dan200.computercraft.gametest.core;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import dan200.computercraft.mixin.gametest.TestCommandAccessor;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
@ -32,7 +32,7 @@ import static net.minecraft.commands.Commands.literal;
|
||||
* Helper commands for importing/exporting the computer directory.
|
||||
*/
|
||||
class CCTestCommand {
|
||||
public static final LevelResource LOCATION = new LevelResource(ComputerCraft.MOD_ID);
|
||||
public static final LevelResource LOCATION = new LevelResource(ComputerCraftAPI.MOD_ID);
|
||||
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher) {
|
||||
dispatcher.register(choice("cctest")
|
||||
|
@ -5,7 +5,6 @@
|
||||
*/
|
||||
package dan200.computercraft.gametest.core;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.lua.IComputerSystem;
|
||||
import dan200.computercraft.api.lua.ILuaAPI;
|
||||
import dan200.computercraft.api.lua.LuaException;
|
||||
@ -37,10 +36,10 @@ public class TestAPI extends ComputerState implements ILuaAPI {
|
||||
if (label == null) label = system.getLabel();
|
||||
if (label == null) {
|
||||
label = "#" + system.getID();
|
||||
ComputerCraft.log.warn("Computer {} has no label", label);
|
||||
TestHooks.LOG.warn("Computer {} has no label", label);
|
||||
}
|
||||
|
||||
ComputerCraft.log.info("Computer '{}' has turned on.", label);
|
||||
TestHooks.LOG.info("Computer '{}' has turned on.", label);
|
||||
markers.clear();
|
||||
error = null;
|
||||
lookup.put(label, this);
|
||||
@ -48,7 +47,7 @@ public class TestAPI extends ComputerState implements ILuaAPI {
|
||||
|
||||
@Override
|
||||
public void shutdown() {
|
||||
ComputerCraft.log.info("Computer '{}' has shut down.", label);
|
||||
TestHooks.LOG.info("Computer '{}' has shut down.", label);
|
||||
if (lookup.get(label) == this) lookup.remove(label);
|
||||
}
|
||||
|
||||
@ -59,7 +58,7 @@ public class TestAPI extends ComputerState implements ILuaAPI {
|
||||
|
||||
@LuaFunction
|
||||
public final void fail(String message) throws LuaException {
|
||||
ComputerCraft.log.error("Computer '{}' failed with {}", label, message);
|
||||
TestHooks.LOG.error("Computer '{}' failed with {}", label, message);
|
||||
if (markers.contains(ComputerState.DONE)) throw new LuaException("Cannot call fail/ok multiple times.");
|
||||
markers.add(ComputerState.DONE);
|
||||
error = message;
|
||||
@ -78,6 +77,6 @@ public class TestAPI extends ComputerState implements ILuaAPI {
|
||||
|
||||
@LuaFunction
|
||||
public final void log(String message) {
|
||||
ComputerCraft.log.info("[Computer '{}'] {}", label, message);
|
||||
TestHooks.LOG.info("[Computer '{}'] {}", label, message);
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
public class TestHooks {
|
||||
public static final Logger LOGGER = LoggerFactory.getLogger(TestHooks.class);
|
||||
public static final Logger LOG = LoggerFactory.getLogger(TestHooks.class);
|
||||
|
||||
public static final Path sourceDir = Paths.get(System.getProperty("cctest.sources")).normalize().toAbsolutePath();
|
||||
|
||||
@ -39,17 +39,17 @@ public class TestHooks {
|
||||
var world = server.getLevel(Level.OVERWORLD);
|
||||
if (world != null) world.setDayTime(Times.NOON);
|
||||
|
||||
LOGGER.info("Cleaning up after last run");
|
||||
LOG.info("Cleaning up after last run");
|
||||
GameTestRunner.clearAllTests(server.overworld(), new BlockPos(0, -60, 0), GameTestTicker.SINGLETON, 200);
|
||||
|
||||
// Delete server context and add one with a mutable machine factory. This allows us to set the factory for
|
||||
// specific test batches without having to reset all computers.
|
||||
for (var computer : ServerContext.get(server).registry().getComputers()) {
|
||||
var label = computer.getLabel() == null ? "#" + computer.getID() : computer.getLabel();
|
||||
LOGGER.warn("Unexpected computer {}", label);
|
||||
LOG.warn("Unexpected computer {}", label);
|
||||
}
|
||||
|
||||
LOGGER.info("Importing files");
|
||||
LOG.info("Importing files");
|
||||
CCTestCommand.importFiles(server);
|
||||
}
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ class GameTestSequenceMixin {
|
||||
parent.fail(e);
|
||||
} catch (Exception e) {
|
||||
// Fail the test, rather than crashing the server.
|
||||
TestHooks.LOGGER.error("{} threw unexpected exception", parent.getTestName(), e);
|
||||
TestHooks.LOG.error("{} threw unexpected exception", parent.getTestName(), e);
|
||||
parent.fail(e);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user