mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-10-25 02:47:39 +00:00
Merge branch 'mc-1.19.x' into mc-1.20.x
This commit is contained in:
@@ -35,8 +35,6 @@ minecraft {
|
||||
property("forge.logging.markers", "REGISTRIES")
|
||||
property("forge.logging.console.level", "debug")
|
||||
|
||||
forceExit = false
|
||||
|
||||
mods.register("computercraft") {
|
||||
cct.sourceDirectories.get().forEach {
|
||||
if (it.classes) sources(it.sourceSet)
|
||||
@@ -262,11 +260,7 @@ val runGametest by tasks.registering(JavaExec::class) {
|
||||
dependsOn("cleanRunGametest")
|
||||
usesService(MinecraftRunnerService.get(gradle))
|
||||
|
||||
// Copy from runGameTestServer. We do it in this slightly odd way as runGameTestServer
|
||||
// isn't created until the task is configured (which is no good for us).
|
||||
val exec = tasks.getByName<JavaExec>("runGameTestServer")
|
||||
dependsOn(exec.dependsOn)
|
||||
exec.copyToFull(this)
|
||||
setRunConfig(minecraft.runs["gameTestServer"])
|
||||
|
||||
systemProperty("cctest.gametest-report", project.buildDir.resolve("test-results/$name.xml").absolutePath)
|
||||
}
|
||||
@@ -275,7 +269,7 @@ tasks.check { dependsOn(runGametest) }
|
||||
|
||||
val runGametestClient by tasks.registering(ClientJavaExec::class) {
|
||||
description = "Runs client-side gametests with no mods"
|
||||
copyFrom("runTestClient")
|
||||
setRunConfig(minecraft.runs["testClient"])
|
||||
tags("client")
|
||||
}
|
||||
cct.jacoco(runGametestClient)
|
||||
|
||||
@@ -11,9 +11,8 @@ import net.minecraft.world.item.ItemDisplayContext;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.client.model.BakedModelWrapper;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* The custom model for turtle items, which renders tools and overlays as part of the model.
|
||||
@@ -21,12 +20,11 @@ import java.util.Map;
|
||||
* @see TurtleModelParts
|
||||
*/
|
||||
public class TurtleModel extends BakedModelWrapper<BakedModel> {
|
||||
private final TurtleModelParts parts;
|
||||
private final Map<TurtleModelParts.Combination, List<BakedModel>> cachedModels = new HashMap<>();
|
||||
private final TurtleModelParts<List<BakedModel>> parts;
|
||||
|
||||
public TurtleModel(BakedModel familyModel, BakedModel colourModel) {
|
||||
super(familyModel);
|
||||
parts = new TurtleModelParts(familyModel, colourModel, TransformedBakedModel::new);
|
||||
parts = new TurtleModelParts<>(familyModel, colourModel, TransformedBakedModel::new, Function.identity());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -37,6 +35,6 @@ public class TurtleModel extends BakedModelWrapper<BakedModel> {
|
||||
|
||||
@Override
|
||||
public List<BakedModel> getRenderPasses(ItemStack stack, boolean fabulous) {
|
||||
return cachedModels.computeIfAbsent(parts.getCombination(stack), parts::buildModel);
|
||||
return parts.getModel(stack);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@
|
||||
"gui.computercraft.config.http.bandwidth.global_upload.tooltip": "The number of bytes which can be uploaded in a second. This is shared across all computers. (bytes/s).\nRange: > 1",
|
||||
"gui.computercraft.config.http.bandwidth.tooltip": "Limits bandwidth used by computers.",
|
||||
"gui.computercraft.config.http.enabled": "Enable the HTTP API",
|
||||
"gui.computercraft.config.http.enabled.tooltip": "Enable the \"http\" API on Computers. This also disables the \"pastebin\" and \"wget\"\nprograms, that many users rely on. It's recommended to leave this on and use the\n\"rules\" config option to impose more fine-grained control.",
|
||||
"gui.computercraft.config.http.enabled.tooltip": "Enable the \"http\" API on Computers. Disabling this also disables the \"pastebin\" and\n\"wget\" programs, that many users rely on. It's recommended to leave this on and use\nthe \"rules\" config option to impose more fine-grained control.",
|
||||
"gui.computercraft.config.http.max_requests": "Maximum concurrent requests",
|
||||
"gui.computercraft.config.http.max_requests.tooltip": "The number of http requests a computer can make at one time. Additional requests\nwill be queued, and sent when the running requests have finished. Set to 0 for\nunlimited.\nRange: > 0",
|
||||
"gui.computercraft.config.http.max_websockets": "Maximum concurrent websockets",
|
||||
@@ -113,7 +113,7 @@
|
||||
"gui.computercraft.config.http.proxy.type": "Proxy type",
|
||||
"gui.computercraft.config.http.proxy.type.tooltip": "The type of proxy to use.\nAllowed Values: HTTP, HTTPS, SOCKS4, SOCKS5",
|
||||
"gui.computercraft.config.http.rules": "Allow/deny rules",
|
||||
"gui.computercraft.config.http.rules.tooltip": "A list of rules which control behaviour of the \"http\" API for specific domains or\nIPs. Each rule is an item with a 'host' to match against, and a series of\nproperties. Rules are evaluated in order, meaning earlier rules override later\nones.\nThe host may be a domain name (\"pastebin.com\"), wildcard (\"*.pastebin.com\") or\nCIDR notation (\"127.0.0.0/8\").\nIf no rules, the domain is blocked.",
|
||||
"gui.computercraft.config.http.rules.tooltip": "A list of rules which control behaviour of the \"http\" API for specific domains or\nIPs. Each rule matches against a hostname and an optional port, and then sets several\nproperties for the request. Rules are evaluated in order, meaning earlier rules override\nlater ones.\n\nValid properties:\n - \"host\" (required): The domain or IP address this rule matches. This may be a domain name\n (\"pastebin.com\"), wildcard (\"*.pastebin.com\") or CIDR notation (\"127.0.0.0/8\").\n - \"port\" (optional): Only match requests for a specific port, such as 80 or 443.\n\n - \"action\" (optional): Whether to allow or deny this request.\n - \"max_download\" (optional): The maximum size (in bytes) that a computer can download in this\n request.\n - \"max_upload\" (optional): The maximum size (in bytes) that a computer can upload in a this request.\n - \"max_websocket_message\" (optional): The maximum size (in bytes) that a computer can send or\n receive in one websocket packet.\n - \"use_proxy\" (optional): Enable use of the HTTP/SOCKS proxy if it is configured.",
|
||||
"gui.computercraft.config.http.tooltip": "Controls the HTTP API",
|
||||
"gui.computercraft.config.http.websocket_enabled": "Enable websockets",
|
||||
"gui.computercraft.config.http.websocket_enabled.tooltip": "Enable use of http websockets. This requires the \"http_enable\" option to also be true.",
|
||||
|
||||
@@ -5,20 +5,22 @@
|
||||
package dan200.computercraft.shared.peripheral.generic;
|
||||
|
||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
import dan200.computercraft.core.asm.NamedMethod;
|
||||
import dan200.computercraft.core.asm.PeripheralMethod;
|
||||
import dan200.computercraft.shared.util.CapabilityUtil;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.util.NonNullConsumer;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Objects;
|
||||
|
||||
public class GenericPeripheralProvider {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(GenericPeripheralProvider.class);
|
||||
|
||||
private static final ArrayList<Capability<?>> capabilities = new ArrayList<>();
|
||||
|
||||
public static synchronized void addCapability(Capability<?> capability) {
|
||||
@@ -27,57 +29,26 @@ public class GenericPeripheralProvider {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static IPeripheral getPeripheral(Level world, BlockPos pos, Direction side, NonNullConsumer<Object> invalidate) {
|
||||
var tile = world.getBlockEntity(pos);
|
||||
if (tile == null) return null;
|
||||
public static IPeripheral getPeripheral(Level level, BlockPos pos, Direction side, NonNullConsumer<Object> invalidate) {
|
||||
var blockEntity = level.getBlockEntity(pos);
|
||||
if (blockEntity == null) return null;
|
||||
|
||||
var saturated = new GenericPeripheralBuilder();
|
||||
var server = level.getServer();
|
||||
if (server == null) {
|
||||
LOG.warn("Fetching peripherals on a non-server level {}.", level, new IllegalStateException("Fetching peripherals on a non-server level."));
|
||||
return null;
|
||||
}
|
||||
|
||||
var tileMethods = PeripheralMethod.GENERATOR.getMethods(tile.getClass());
|
||||
if (!tileMethods.isEmpty()) saturated.addMethods(tile, tileMethods);
|
||||
var builder = new GenericPeripheralBuilder(server);
|
||||
builder.addMethods(blockEntity);
|
||||
|
||||
for (var capability : capabilities) {
|
||||
var wrapper = CapabilityUtil.getCapability(tile, capability, side);
|
||||
var wrapper = CapabilityUtil.getCapability(blockEntity, capability, side);
|
||||
wrapper.ifPresent(contents -> {
|
||||
var capabilityMethods = PeripheralMethod.GENERATOR.getMethods(contents.getClass());
|
||||
if (capabilityMethods.isEmpty()) return;
|
||||
|
||||
saturated.addMethods(contents, capabilityMethods);
|
||||
CapabilityUtil.addListener(wrapper, invalidate);
|
||||
if (builder.addMethods(contents)) CapabilityUtil.addListener(wrapper, invalidate);
|
||||
});
|
||||
}
|
||||
|
||||
return saturated.toPeripheral(tile);
|
||||
}
|
||||
|
||||
private static class GenericPeripheralBuilder {
|
||||
private @Nullable String name;
|
||||
private final Set<String> additionalTypes = new HashSet<>(0);
|
||||
private final ArrayList<SaturatedMethod> methods = new ArrayList<>(0);
|
||||
|
||||
@Nullable
|
||||
IPeripheral toPeripheral(BlockEntity tile) {
|
||||
if (methods.isEmpty()) return null;
|
||||
|
||||
methods.trimToSize();
|
||||
return new GenericPeripheral(tile, name, additionalTypes, methods);
|
||||
}
|
||||
|
||||
void addMethods(Object target, List<NamedMethod<PeripheralMethod>> methods) {
|
||||
var saturatedMethods = this.methods;
|
||||
saturatedMethods.ensureCapacity(saturatedMethods.size() + methods.size());
|
||||
for (var method : methods) {
|
||||
saturatedMethods.add(new SaturatedMethod(target, method));
|
||||
|
||||
// If we have a peripheral type, use it. Always pick the smallest one, so it's consistent (assuming mods
|
||||
// don't change).
|
||||
var type = method.getGenericType();
|
||||
if (type != null && type.getPrimaryType() != null) {
|
||||
var name = type.getPrimaryType();
|
||||
if (this.name == null || this.name.compareTo(name) > 0) this.name = name;
|
||||
}
|
||||
if (type != null) additionalTypes.addAll(type.getAdditionalTypes());
|
||||
}
|
||||
}
|
||||
return builder.toPeripheral(blockEntity, side);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ package dan200.computercraft.shared.platform;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.MenuProvider;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityDimensions;
|
||||
@@ -16,6 +17,8 @@ import net.minecraftforge.common.util.FakePlayer;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.OptionalInt;
|
||||
|
||||
import static dan200.computercraft.shared.platform.FakePlayerConstants.MAX_REACH;
|
||||
|
||||
class FakePlayerExt extends FakePlayer {
|
||||
FakePlayerExt(ServerLevel serverLevel, GameProfile profile) {
|
||||
super(serverLevel, profile);
|
||||
@@ -45,4 +48,19 @@ class FakePlayerExt extends FakePlayer {
|
||||
public float getStandingEyeHeight(Pose pose, EntityDimensions dimensions) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBlockReach() {
|
||||
return MAX_REACH;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getEntityReach() {
|
||||
return MAX_REACH;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean broadcastToPlayer(ServerPlayer player) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,6 +63,7 @@ import net.minecraftforge.common.util.NonNullConsumer;
|
||||
import net.minecraftforge.event.ForgeEventFactory;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.fml.loading.FMLLoader;
|
||||
import net.minecraftforge.items.wrapper.InvWrapper;
|
||||
import net.minecraftforge.items.wrapper.SidedInvWrapper;
|
||||
import net.minecraftforge.network.NetworkHooks;
|
||||
@@ -77,6 +78,11 @@ import java.util.function.*;
|
||||
|
||||
@AutoService(dan200.computercraft.impl.PlatformHelper.class)
|
||||
public class PlatformHelperImpl implements PlatformHelper {
|
||||
@Override
|
||||
public boolean isDevelopmentEnvironment() {
|
||||
return !FMLLoader.isProduction();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigFile.Builder createConfigBuilder() {
|
||||
return new ForgeConfigFile.Builder();
|
||||
|
||||
Reference in New Issue
Block a user