Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.6.4 partial support #170

Merged
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
c09fd3d
Update to Loom and Legacy-Looming 1.6
thecatcore May 4, 2024
944f0fb
Add 1.6.4 submodule
thecatcore May 4, 2024
e66630a
Fix json translation files not being parsed correctly in some versions
thecatcore May 4, 2024
9715566
Add resource-loader support for 1.6.4
thecatcore May 4, 2024
e1fd2a8
Fix version requirement being wrong or missing for some modules
thecatcore May 4, 2024
9d7f021
Fix tested modules table in readme
thecatcore May 4, 2024
a3186b0
Port lifecycle module to 1.6.4
thecatcore May 4, 2024
028d1a0
Port keybindings module to 1.6.4
thecatcore May 4, 2024
a4b7195
Add testmod to command api v1
thecatcore May 4, 2024
9fd9e56
fix some test mod modid
thecatcore May 4, 2024
16d50f3
Port permission api module to 1.6.4
thecatcore May 5, 2024
da5a3a9
Barebone port of command api v2 (sponge) to 1.6.4
thecatcore May 5, 2024
653ed47
Small tweaks
thecatcore May 5, 2024
880d8ec
networking api will probably require a rewrite later to support pre-1.7
thecatcore May 5, 2024
9170d75
Add 1.6.4 to supported version range
thecatcore May 5, 2024
f96b8da
Port Item Group module to 1.6.4
thecatcore May 9, 2024
19b5d09
Item group lang files already exist in common module
thecatcore May 9, 2024
24f31ff
Improve command-api-v1 testmod
thecatcore May 9, 2024
85719be
Fix style
thecatcore May 9, 2024
4d4f2ee
Remove command-api-v2 port for now to be redone later
thecatcore May 9, 2024
3c1a071
Bump modules versions
thecatcore May 9, 2024
df20342
Update README
thecatcore May 9, 2024
3ccda76
Update mod description
thecatcore May 9, 2024
b887dcc
Merge branch 'main' into feature/1.6.4-partial-support
thecatcore May 9, 2024
26e9a5b
Merge branch 'refs/heads/main' into feature/1.6.4-partial-support
thecatcore May 19, 2024
2ce7a52
Clean up unnecessary code in permission-api-v1
thecatcore Jun 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@ For support, consider joining the [Legacy Fabric discord server](https://legacyf
? = Not sure if it was tested or working correctly\
❌ = Not working at all, likely crashing

| | 1.7.10 | 1.8 | 1.8.9 | 1.9.4 | 1.10.2 | 1.11.2 | 1.12.2 | 1.13.2 |
|----------------------|--------|-----|-------|-------|--------|--------|--------|--------|
| api-base | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| command-api-v1 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ |
| command-api-v2 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ |
| crash-report-info-v1 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| entity-events-v1 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ |
| gamerule-api-v1 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ? |
| item-groups-v1 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ |
| keybindings-api-v1 | ⚠ #132 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ |
| lifecycle-events-v1 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ |
| logger-api-v1 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| networking-api-v1 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ |
| permissions-api-v1 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ |
| registry-sync-api-v1 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ |
| rendering-api-v1 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ |
| resource-loader-v1 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ |
| | 1.6.4 | 1.7.10 | 1.8 | 1.8.9 | 1.9.4 | 1.10.2 | 1.11.2 | 1.12.2 | 1.13.2 |
|----------------------|------------------------------------|--------|-----|-------|-------|--------|--------|--------|--------|
| api-base | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| command-api-v1 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ |
| command-api-v2 | ⚠ <br/>Text formatting need rework | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ |
| crash-report-info-v1 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| entity-events-v1 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ |
| gamerule-api-v1 | ? | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ? |
| item-groups-v1 | ❌ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ |
| keybindings-api-v1 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ |
| lifecycle-events-v1 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ |
| logger-api-v1 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| networking-api-v1 | ❌ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ |
| permissions-api-v1 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ |
| registry-sync-api-v1 | ❌ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ |
| rendering-api-v1 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ |
| resource-loader-v1 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ |
7 changes: 4 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ plugins {
id "eclipse"
id "idea"
id "maven-publish"
id "fabric-loom" version "1.5.4" apply false
id "legacy-looming" version "1.5.3" apply false
id "fabric-loom" version "1.6.2" apply false
id "legacy-looming" version "1.6.3" apply false
id "com.diffplug.spotless" version "6.20.0"
id "org.ajoberstar.grgit" version "3.1.1"
id "me.modmuss50.mod-publish-plugin" version "0.4.5"
Expand All @@ -22,7 +22,8 @@ def supportedVersions = [
"1.9.4",
"1.8.9",
"1.8",
"1.7.10"
"1.7.10",
"1.6.4"
]
def supportedRanges = [
// ["1.8", "1.8.9", false] // third parameter is whether or not to include snapshots in the range.
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
1 change: 1 addition & 0 deletions legacy-fabric-command-api-v1/common/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
minVersionIncluded=1.3
maxVersionIncluded=1.12.2
artifactSuffix=
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
],
"description": "Adds command-related hooks.",
"depends": {
"minecraft": "${minecraft_version}"
"minecraft": "${minecraft_version}",
"legacy-fabric-lifecycle-events-v1-common": "*"
},
"custom": {
"modmenu": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright (c) 2020 - 2024 Legacy Fabric
* Copyright (c) 2016 - 2022 FabricMC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package net.legacyfabric.fabric.test.command;

import net.fabricmc.api.ModInitializer;

import net.legacyfabric.fabric.api.logger.v1.Logger;
import net.legacyfabric.fabric.api.registry.CommandRegistry;

public class CommandV1Test implements ModInitializer {
public static final Logger LOGGER = Logger.get("LegacyFabricAPI", "Test", "CommandV1Test");

@Override
public void onInitialize() {
CommandRegistry.INSTANCE.register(new ModMetadataCommandV1());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
* Copyright (c) 2020 - 2024 Legacy Fabric
* Copyright (c) 2016 - 2022 FabricMC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package net.legacyfabric.fabric.test.command;

import net.minecraft.command.AbstractCommand;
import net.minecraft.command.CommandException;
import net.minecraft.command.CommandSource;

import net.fabricmc.loader.api.FabricLoader;
import net.fabricmc.loader.api.metadata.ContactInformation;

public class ModMetadataCommandV1 extends AbstractCommand {
@Override
public String getCommandName() {
return "modmetadatav1";
}

@Override
public String getUsageTranslationKey(CommandSource source) {
return "modmetadatav1";
}

@Override
public void execute(CommandSource source, String[] args) throws CommandException {
if (args.length > 0) {
thecatcore marked this conversation as resolved.
Show resolved Hide resolved
FabricLoader.getInstance().getModContainer(args[0]).ifPresent(container -> {
StringBuilder builder = new StringBuilder();
builder.append("Mod Name: ".concat(container.getMetadata().getName()).concat("\n"));
builder.append("Description: ".concat(container.getMetadata().getDescription()).concat("\n"));
ContactInformation contact = container.getMetadata().getContact();

if (contact.get("issues").isPresent()) {
StringBuilder issueText = new StringBuilder("");
issueText.append("Issues: ");
StringBuilder issueUrl = new StringBuilder(contact.get("issues").get());
issueText.append(issueUrl);
issueText.append("\n");
builder.append(issueText);
}

if (contact.get("sources").isPresent()) {
StringBuilder sourcesText = new StringBuilder("");
sourcesText.append("Sources: ");
StringBuilder sourcesUrl = new StringBuilder(contact.get("sources").get());
sourcesText.append(sourcesUrl);
sourcesText.append("\n");
builder.append(sourcesText);
}

builder.append("Metadata Type: ".concat(container.getMetadata().getType()).concat("\n"));
CommandV1Test.LOGGER.info(builder.toString());
});
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"schemaVersion": 1,
"id": "legacy-fabric-command-api-v1-testmod",
"description": "Tests for api features",
"version": "1.0.0",
"entrypoints": {
"main": [
"net.legacyfabric.fabric.test.command.CommandV1Test"
]
},
"depends": {
"minecraft": "${minecraft_version}"
}
}
Empty file.
2 changes: 2 additions & 0 deletions legacy-fabric-command-api-v2/1.6.4/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
minVersionIncluded=1.3
maxVersionIncluded=1.6.4
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright (c) 2020 - 2024 Legacy Fabric
* Copyright (c) 2016 - 2022 FabricMC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package net.legacyfabric.fabric.api.command.v2;

import net.legacyfabric.fabric.api.command.v2.lib.sponge.CommandManager;
import net.legacyfabric.fabric.api.event.Event;
import net.legacyfabric.fabric.api.event.EventFactory;

/**
* An entrypoint and event for registering commands to the {@link CommandManager}.
*/
@FunctionalInterface
public interface CommandRegistrar {
Event<CommandRegistrar> EVENT = EventFactory.createArrayBacked(CommandRegistrar.class, listeners -> (manager, dedicated) -> {
for (CommandRegistrar registrar : listeners) {
registrar.register(manager, dedicated);
}
});

/**
* Register your commands here.
*
* @param manager The command manager
* @param dedicated Whether the mod is running on a dedicated server
*/
void register(CommandManager manager, boolean dedicated);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
/*
* Copyright (c) 2020 - 2024 Legacy Fabric
* Copyright (c) 2016 - 2022 FabricMC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package net.legacyfabric.fabric.api.command.v2;

import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Sets;

import net.minecraft.command.CommandSource;
import net.minecraft.entity.Entity;
import net.minecraft.server.MinecraftServer;

public enum Selector {
ALL_ENTITIES('e') {
@Override
public Set<Entity> resolve(CommandSource sender) {
return Sets.newHashSet(sender.getWorld().entities);
}
},
ALL_PLAYERS('a') {
@Override
public Set<Entity> resolve(CommandSource sender) {
return (Set<Entity>) sender.getWorld().playerEntities.stream().map(e -> (Entity) e).collect(Collectors.toSet());
}
},
NEAREST_PLAYER('p') {
@Override
public Set<Entity> resolve(CommandSource sender) {
return Sets.newHashSet(sender.getWorld().getClosestPlayer(sender.method_4086().x, sender.method_4086().y, sender.method_4086().z, 50.0D));
}
},
RANDOM_PLAYER('r') {
@Override
public Set<Entity> resolve(CommandSource sender) {
try {
return Sets.newHashSet((Entity) MinecraftServer.getServer().getPlayerManager().players.stream().findAny().orElseThrow(NullPointerException::new));
} catch (Throwable e) {
throw new RuntimeException(e);
}
}
},
EXECUTING_ENTITY('s') {
@Override
public Set<Entity> resolve(CommandSource sender) {
//TODO @s didn't exist this early in the game's development, and there seems to be no code to handle it, so maybe this'll work?
return Sets.newHashSet(sender.getWorld().getPlayerByName(sender.getUsername()));
thecatcore marked this conversation as resolved.
Show resolved Hide resolved
}
};

private final char key;
private static final Map<String, Selector> MAP;

Selector(char key) {
this.key = key;
}

public char getKey() {
return this.key;
}

public abstract Set<Entity> resolve(CommandSource sender);

public static List<String> complete(String s) {
if (s.startsWith("@") && s.length() == 2) {
return Arrays.stream(values()).map(Selector::getKey).map(String::valueOf).distinct().collect(Collectors.toList());
}

return ImmutableList.of();
}

public static Selector parse(String value) {
if (MAP.containsKey(value)) {
return MAP.get(value);
}

throw new IllegalArgumentException("Unknown selector");
}

static {
ImmutableMap.Builder<String, Selector> builder = ImmutableMap.builder();

for (Selector s : values()) {
builder.put("@" + s.getKey(), s);
}

MAP = builder.build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright (c) 2020 - 2024 Legacy Fabric
* Copyright (c) 2016 - 2022 FabricMC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package net.legacyfabric.fabric.api.command.v2;

/**
* Specifies a method to parse {@link String}s in a command.
*/
public enum StringType {
SINGLE_WORD(false),
GREEDY_PHRASE(true);

private final boolean all;

StringType(boolean all) {
this.all = all;
}

public boolean isAll() {
return this.all;
}
}
Loading
Loading