mirror of
https://github.com/FabricMC/fabric.git
synced 2024-11-14 19:25:23 -05:00
[#148] Migrate to a modular JAR-in-JAR system, update to Loader 0.4.x
This commit is contained in:
parent
12310858de
commit
dff44ec84f
260 changed files with 1101 additions and 574 deletions
6
.gitignore
vendored
6
.gitignore
vendored
|
@ -1,6 +1,10 @@
|
|||
# Ignore everything
|
||||
/*
|
||||
|
||||
# Subprojects
|
||||
!/fabric-*
|
||||
/fabric-*/build
|
||||
|
||||
# Folders
|
||||
!/gradle
|
||||
!/src
|
||||
|
@ -17,4 +21,4 @@
|
|||
!/Jenkinsfile
|
||||
!/LICENSE
|
||||
!/README.md
|
||||
!/settings.gradle
|
||||
!/settings.gradle
|
||||
|
|
159
build.gradle
159
build.gradle
|
@ -1,65 +1,138 @@
|
|||
buildscript {
|
||||
repositories {
|
||||
jcenter()
|
||||
gradlePluginPortal()
|
||||
maven {
|
||||
name = 'Fabric'
|
||||
url = 'https://maven.fabricmc.net/'
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
classpath "net.fabricmc:fabric-loom:0.2.2-SNAPSHOT"
|
||||
}
|
||||
}
|
||||
|
||||
plugins {
|
||||
id 'java'
|
||||
id 'eclipse'
|
||||
id 'idea'
|
||||
id 'maven-publish'
|
||||
id 'fabric-loom' version '0.2.2-SNAPSHOT' apply false
|
||||
id 'com.matthewprenger.cursegradle' version "1.1.2"
|
||||
}
|
||||
|
||||
apply plugin: net.fabricmc.loom.LoomGradlePlugin
|
||||
def ENV = System.getenv()
|
||||
|
||||
sourceCompatibility = 1.8
|
||||
targetCompatibility = 1.8
|
||||
|
||||
archivesBaseName = "fabric"
|
||||
|
||||
def baseVersion = "0.2.7"
|
||||
def baseVersion = "0.3.0"
|
||||
def mcVersion = "1.14 Pre-Release 5"
|
||||
|
||||
def ENV = System.getenv()
|
||||
version = baseVersion + "+" + (ENV.BUILD_NUMBER ? ("build." + ENV.BUILD_NUMBER) : "local")
|
||||
allprojects {
|
||||
apply plugin: 'maven-publish'
|
||||
apply plugin: 'fabric-loom'
|
||||
|
||||
minecraft {
|
||||
refmapName = "net.fabricmc.fabric.refmap.json"
|
||||
sourceCompatibility = 1.8
|
||||
targetCompatibility = 1.8
|
||||
|
||||
dependencies {
|
||||
minecraft "com.mojang:minecraft:$mcVersion"
|
||||
mappings "net.fabricmc:yarn:$mcVersion+build.6"
|
||||
modCompile "net.fabricmc:fabric-loader:0.4.2+build.131"
|
||||
}
|
||||
|
||||
configurations {
|
||||
dev
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
mavenJava(MavenPublication) {
|
||||
artifact(file("${project.buildDir}/libs/$archivesBaseName-${version}-maven.jar")) {
|
||||
builtBy remapMavenJar
|
||||
}
|
||||
artifact(sourcesJar) {
|
||||
builtBy remapSourcesJar
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
url "http://mavenupload.modmuss50.me/"
|
||||
if (project.hasProperty('mavenPass')) {
|
||||
credentials {
|
||||
username 'buildslave'
|
||||
password project.getProperty('mavenPass')
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
afterEvaluate {
|
||||
artifacts {
|
||||
dev file: file("${project.buildDir}/libs/$archivesBaseName-${version}-dev.jar"), type: "jar", builtBy: remapJar
|
||||
}
|
||||
|
||||
processResources {
|
||||
inputs.property "version", project.version
|
||||
|
||||
from(sourceSets.main.resources.srcDirs) {
|
||||
include "fabric.mod.json"
|
||||
expand "version": project.version
|
||||
}
|
||||
|
||||
from(sourceSets.main.resources.srcDirs) {
|
||||
exclude "fabric.mod.json"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
task sourcesJar(type: Jar, dependsOn: classes) {
|
||||
classifier = 'sources'
|
||||
from sourceSets.main.allSource
|
||||
}
|
||||
}
|
||||
|
||||
subprojects {
|
||||
task remapMavenJar(type: Copy, dependsOn: remapJar) {
|
||||
afterEvaluate {
|
||||
from("${project.buildDir}/libs/$archivesBaseName-${version}.jar")
|
||||
into("${project.buildDir}/libs/")
|
||||
rename { String fn -> "$archivesBaseName-${version}-maven.jar" }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
task remapMavenJar(type: net.fabricmc.loom.task.RemapJar, dependsOn: remapJar) {
|
||||
afterEvaluate {
|
||||
println("${project.buildDir}/libs/${archivesBaseName}-${version}-dev.jar")
|
||||
jar = file("${project.buildDir}/libs/${archivesBaseName}-${version}-dev.jar")
|
||||
destination = file("${project.buildDir}/libs/${archivesBaseName}-${version}-maven.jar")
|
||||
nestJar = false
|
||||
}
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
mavenJava(MavenPublication) {
|
||||
pom.withXml {
|
||||
def depsNode = asNode().appendNode("dependencies")
|
||||
subprojects.each {
|
||||
def depNode = depsNode.appendNode("dependency")
|
||||
depNode.appendNode("groupId", it.group)
|
||||
depNode.appendNode("artifactId", it.name)
|
||||
depNode.appendNode("version", it.version)
|
||||
depNode.appendNode("scope", "compile")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
minecraft "com.mojang:minecraft:$mcVersion"
|
||||
mappings "net.fabricmc:yarn:$mcVersion+build.2"
|
||||
modCompile "net.fabricmc:fabric-loader:0.4.2+build.131"
|
||||
}
|
||||
|
||||
processResources {
|
||||
inputs.property "version", project.version
|
||||
|
||||
from(sourceSets.main.resources.srcDirs) {
|
||||
include "fabric.mod.json"
|
||||
expand "version": project.version
|
||||
afterEvaluate {
|
||||
subprojects.each {
|
||||
compile project(path: ":${it.name}", configuration: "dev")
|
||||
include project("${it.name}:")
|
||||
}
|
||||
}
|
||||
|
||||
from(sourceSets.main.resources.srcDirs) {
|
||||
exclude "fabric.mod.json"
|
||||
}
|
||||
// workaround linux segfault
|
||||
compile "org.lwjgl:lwjgl-jemalloc:3.2.1"
|
||||
}
|
||||
|
||||
task sourcesJar(type: Jar, dependsOn: classes) {
|
||||
classifier = 'sources'
|
||||
from sourceSets.main.allSource
|
||||
}
|
||||
archivesBaseName = "fabric"
|
||||
version = baseVersion + "+" + (ENV.BUILD_NUMBER ? ("build." + ENV.BUILD_NUMBER) : "local")
|
||||
|
||||
curseforge {
|
||||
if (project.hasProperty('curse_api_key')){
|
||||
|
|
6
fabric-client-registries/build.gradle
Normal file
6
fabric-client-registries/build.gradle
Normal file
|
@ -0,0 +1,6 @@
|
|||
archivesBaseName = "fabric-client-registries"
|
||||
version = "0.1.0"
|
||||
|
||||
dependencies {
|
||||
compile project(path: ':fabric-lib', configuration: 'dev')
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"required": true,
|
||||
"package": "net.fabricmc.fabric.mixin.client",
|
||||
"compatibilityLevel": "JAVA_8",
|
||||
"client": [
|
||||
"keybinding.MixinGameOptions",
|
||||
"keybinding.MixinKeyBinding",
|
||||
"render.MixinBlockColorMap",
|
||||
"render.MixinBlockEntityRenderManager",
|
||||
"render.MixinEntityRenderManager",
|
||||
"render.MixinItemColorMap"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"schemaVersion": 1,
|
||||
"id": "fabric-client-registries",
|
||||
"version": "${version}",
|
||||
"license": "Apache-2.0",
|
||||
"mixins": [
|
||||
"fabric-client-registries.mixins.json"
|
||||
]
|
||||
}
|
6
fabric-commands/build.gradle
Normal file
6
fabric-commands/build.gradle
Normal file
|
@ -0,0 +1,6 @@
|
|||
archivesBaseName = "fabric-registry-commands"
|
||||
version = "0.1.0"
|
||||
|
||||
dependencies {
|
||||
compile project(path: ':fabric-lib', configuration: 'dev')
|
||||
}
|
|
@ -17,6 +17,7 @@
|
|||
package net.fabricmc.fabric.api.registry;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import net.fabricmc.fabric.impl.registry.CommandRegistryImpl;
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -30,32 +31,12 @@ import java.util.function.Consumer;
|
|||
public class CommandRegistry {
|
||||
public static final CommandRegistry INSTANCE = new CommandRegistry();
|
||||
|
||||
private final List<Consumer<CommandDispatcher<ServerCommandSource>>> serverCommands;
|
||||
private final List<Consumer<CommandDispatcher<ServerCommandSource>>> dedicatedServerCommands;
|
||||
|
||||
protected CommandRegistry() {
|
||||
this.serverCommands = new ArrayList<>();
|
||||
this.dedicatedServerCommands = new ArrayList<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Will be removed in 0.3.0; should not have been exposed.
|
||||
*/
|
||||
@Deprecated
|
||||
public List<Consumer<CommandDispatcher<ServerCommandSource>>> entries(boolean dedicated) {
|
||||
return Collections.unmodifiableList(dedicated ? dedicatedServerCommands : serverCommands);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a command provider.
|
||||
* @param dedicated If true, the command is only registered on the dedicated server.
|
||||
* @param consumer The command provider, consuming {@link CommandDispatcher}.
|
||||
*/
|
||||
public void register(boolean dedicated, Consumer<CommandDispatcher<ServerCommandSource>> consumer) {
|
||||
if (dedicated) {
|
||||
dedicatedServerCommands.add(consumer);
|
||||
} else {
|
||||
serverCommands.add(consumer);
|
||||
}
|
||||
public void register(boolean dedicated, Consumer<CommandDispatcher<ServerCommandSource>> consumer) {
|
||||
CommandRegistryImpl.INSTANCE.register(dedicated, consumer);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package net.fabricmc.fabric.impl.registry;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import net.fabricmc.fabric.api.registry.CommandRegistry;
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class CommandRegistryImpl {
|
||||
public static final CommandRegistryImpl INSTANCE = new CommandRegistryImpl();
|
||||
|
||||
private final List<Consumer<CommandDispatcher<ServerCommandSource>>> serverCommands;
|
||||
private final List<Consumer<CommandDispatcher<ServerCommandSource>>> dedicatedServerCommands;
|
||||
|
||||
public CommandRegistryImpl() {
|
||||
this.serverCommands = new ArrayList<>();
|
||||
this.dedicatedServerCommands = new ArrayList<>();
|
||||
}
|
||||
|
||||
public List<Consumer<CommandDispatcher<ServerCommandSource>>> entries(boolean dedicated) {
|
||||
return Collections.unmodifiableList(dedicated ? dedicatedServerCommands : serverCommands);
|
||||
}
|
||||
|
||||
public void register(boolean dedicated, Consumer<CommandDispatcher<ServerCommandSource>> consumer) {
|
||||
if (dedicated) {
|
||||
dedicatedServerCommands.add(consumer);
|
||||
} else {
|
||||
serverCommands.add(consumer);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package net.fabricmc.fabric.mixin.commands;
|
||||
package net.fabricmc.fabric.mixin.registrycommands;
|
||||
|
||||
import com.mojang.authlib.GameProfileRepository;
|
||||
import com.mojang.authlib.minecraft.MinecraftSessionService;
|
||||
|
@ -22,6 +22,7 @@ import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService;
|
|||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.datafixers.DataFixer;
|
||||
import net.fabricmc.fabric.api.registry.CommandRegistry;
|
||||
import net.fabricmc.fabric.impl.registry.CommandRegistryImpl;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.WorldGenerationProgressListenerFactory;
|
||||
import net.minecraft.server.command.CommandManager;
|
||||
|
@ -46,7 +47,7 @@ public abstract class MixinMinecraftDedicatedServer extends MinecraftServer {
|
|||
|
||||
@Inject(method = "setupServer", at = @At("HEAD"))
|
||||
private void setupServer(CallbackInfoReturnable<Boolean> info){
|
||||
CommandRegistry.INSTANCE.entries(false).forEach((e) -> e.accept(getCommandManager().getDispatcher()));
|
||||
CommandRegistry.INSTANCE.entries(true).forEach((e) -> e.accept(getCommandManager().getDispatcher()));
|
||||
CommandRegistryImpl.INSTANCE.entries(false).forEach((e) -> e.accept(getCommandManager().getDispatcher()));
|
||||
CommandRegistryImpl.INSTANCE.entries(true).forEach((e) -> e.accept(getCommandManager().getDispatcher()));
|
||||
}
|
||||
}
|
|
@ -14,10 +14,11 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package net.fabricmc.fabric.mixin.commands;
|
||||
package net.fabricmc.fabric.mixin.registrycommands;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import net.fabricmc.fabric.api.registry.CommandRegistry;
|
||||
import net.fabricmc.fabric.impl.registry.CommandRegistryImpl;
|
||||
import net.minecraft.server.command.CommandManager;
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
@ -38,7 +39,7 @@ public class MixinServerCommandManager {
|
|||
public void addMethods(boolean dedicated, CallbackInfo info) {
|
||||
// TODO: Run before findAmbiguities
|
||||
if(!dedicated){
|
||||
CommandRegistry.INSTANCE.entries(false).forEach((e) -> e.accept(dispatcher));
|
||||
CommandRegistryImpl.INSTANCE.entries(false).forEach((e) -> e.accept(dispatcher));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"required": true,
|
||||
"package": "net.fabricmc.fabric.mixin.registrycommands",
|
||||
"compatibilityLevel": "JAVA_8",
|
||||
"mixins": [
|
||||
"MixinMinecraftDedicatedServer",
|
||||
"MixinServerCommandManager"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
}
|
||||
}
|
9
fabric-commands/src/main/resources/fabric.mod.json
Normal file
9
fabric-commands/src/main/resources/fabric.mod.json
Normal file
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"schemaVersion": 1,
|
||||
"id": "fabric-commands",
|
||||
"version": "${version}",
|
||||
"license": "Apache-2.0",
|
||||
"mixins": [
|
||||
"fabric-commands.mixins.json"
|
||||
]
|
||||
}
|
7
fabric-containers/build.gradle
Normal file
7
fabric-containers/build.gradle
Normal file
|
@ -0,0 +1,7 @@
|
|||
archivesBaseName = "fabric-containers"
|
||||
version = "0.1.0"
|
||||
|
||||
dependencies {
|
||||
compile project(path: ':fabric-lib', configuration: 'dev')
|
||||
compile project(path: ':fabric-networking', configuration: 'dev')
|
||||
}
|
|
@ -62,7 +62,7 @@ public class ScreenProviderRegistryImpl implements ScreenProviderRegistry {
|
|||
});
|
||||
}
|
||||
|
||||
public void init() {
|
||||
public static void init() {
|
||||
ClientSidePacketRegistry.INSTANCE.register(PacketTypes.OPEN_CONTAINER, (packetContext, packetByteBuf) -> {
|
||||
Identifier identifier = packetByteBuf.readIdentifier();
|
||||
int syncId = packetByteBuf.readUnsignedByte();
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"required": true,
|
||||
"package": "net.fabricmc.fabric.mixin.container",
|
||||
"compatibilityLevel": "JAVA_8",
|
||||
"mixins": [
|
||||
"MixinServerPlayerEntity"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
}
|
||||
}
|
14
fabric-containers/src/main/resources/fabric.mod.json
Normal file
14
fabric-containers/src/main/resources/fabric.mod.json
Normal file
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"schemaVersion": 1,
|
||||
"id": "fabric-containers",
|
||||
"version": "${version}",
|
||||
"license": "Apache-2.0",
|
||||
"mixins": [
|
||||
"fabric-containers.mixins.json"
|
||||
],
|
||||
"entrypoints": {
|
||||
"client": [
|
||||
"net.fabricmc.fabric.impl.client.gui.ScreenProviderRegistryImpl::init"
|
||||
]
|
||||
}
|
||||
}
|
7
fabric-content-registries/build.gradle
Normal file
7
fabric-content-registries/build.gradle
Normal file
|
@ -0,0 +1,7 @@
|
|||
archivesBaseName = "fabric-content-registries"
|
||||
version = "0.1.0"
|
||||
|
||||
dependencies {
|
||||
compile project(path: ':fabric-lib', configuration: 'dev')
|
||||
compile project(path: ':fabric-resource-loader', configuration: 'dev')
|
||||
}
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package net.fabricmc.fabric.mixin.item;
|
||||
package net.fabricmc.fabric.mixin.registryextras;
|
||||
|
||||
import net.fabricmc.fabric.impl.registry.FuelRegistryImpl;
|
||||
import net.minecraft.block.entity.AbstractFurnaceBlockEntity;
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package net.fabricmc.fabric.mixin.block;
|
||||
package net.fabricmc.fabric.mixin.registryextras;
|
||||
|
||||
import net.fabricmc.fabric.api.registry.FlammableBlockRegistry;
|
||||
import net.fabricmc.fabric.impl.registry.FireBlockHooks;
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"required": true,
|
||||
"package": "net.fabricmc.fabric.mixin.registryextras",
|
||||
"compatibilityLevel": "JAVA_8",
|
||||
"mixins": [
|
||||
"MixinAbstractFurnaceBlockEntity",
|
||||
"MixinFireBlock"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"schemaVersion": 1,
|
||||
"id": "fabric-content-registries",
|
||||
"version": "${version}",
|
||||
"license": "Apache-2.0",
|
||||
"mixins": [
|
||||
"fabric-content-registries.mixins.json"
|
||||
]
|
||||
}
|
2
fabric-crash-report-info/build.gradle
Normal file
2
fabric-crash-report-info/build.gradle
Normal file
|
@ -0,0 +1,2 @@
|
|||
archivesBaseName = "fabric-crash-report-info"
|
||||
version = "0.1.0"
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package net.fabricmc.fabric.mixin.misc;
|
||||
package net.fabricmc.fabric.mixin.crash;
|
||||
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.fabricmc.loader.api.ModContainer;
|
||||
|
@ -38,9 +38,7 @@ public abstract class MixinCrashReport {
|
|||
getSystemDetailsSection().add("Fabric Mods", () -> {
|
||||
Map<String, String> mods = new TreeMap<>();
|
||||
for (ModContainer container : FabricLoader.getInstance().getAllMods()) {
|
||||
// mods.put(container.getInfo().getName(), container.getInfo().getVersionString() + " (" + container.getOriginUrl().getFile() + ")");
|
||||
// TODO getName, getOriginUrl
|
||||
mods.put(container.getMetadata().getId(), container.getMetadata().getVersion().getFriendlyString());
|
||||
mods.put(container.getMetadata().getId(), container.getMetadata().getName() + " " + container.getMetadata().getVersion().getFriendlyString());
|
||||
}
|
||||
|
||||
StringBuilder modString = new StringBuilder();
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"required": true,
|
||||
"package": "net.fabricmc.fabric.mixin.crash",
|
||||
"compatibilityLevel": "JAVA_8",
|
||||
"mixins": [
|
||||
"MixinCrashReport"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"schemaVersion": 1,
|
||||
"id": "fabric-crash-report-info",
|
||||
"version": "${version}",
|
||||
"license": "Apache-2.0",
|
||||
"mixins": [
|
||||
"fabric-crash-report-info.mixins.json"
|
||||
]
|
||||
}
|
6
fabric-creative-tabs/build.gradle
Normal file
6
fabric-creative-tabs/build.gradle
Normal file
|
@ -0,0 +1,6 @@
|
|||
archivesBaseName = "fabric-creative-tabs"
|
||||
version = "0.1.0"
|
||||
|
||||
dependencies {
|
||||
compile project(path: ':fabric-resource-loader', configuration: 'dev')
|
||||
}
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package net.fabricmc.fabric.mixin.client.itemgroup;
|
||||
package net.fabricmc.fabric.mixin.itemgroup.client;
|
||||
|
||||
import net.fabricmc.fabric.impl.itemgroup.CreativeGuiExtensions;
|
||||
import net.fabricmc.fabric.impl.itemgroup.FabricCreativeGuiComponents;
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package net.fabricmc.fabric.mixin.client.itemgroup;
|
||||
package net.fabricmc.fabric.mixin.itemgroup.client;
|
||||
|
||||
import net.fabricmc.fabric.impl.itemgroup.FabricCreativeGuiComponents;
|
||||
import net.minecraft.item.ItemGroup;
|
Before Width: | Height: | Size: 859 B After Width: | Height: | Size: 859 B |
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"required": true,
|
||||
"package": "net.fabricmc.fabric.mixin.itemgroup",
|
||||
"compatibilityLevel": "JAVA_8",
|
||||
"mixins": [
|
||||
"MixinItemGroup"
|
||||
],
|
||||
"client": [
|
||||
"client.MixinItemGroup",
|
||||
"client.MixinCreativePlayerInventoryGui"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
}
|
||||
}
|
9
fabric-creative-tabs/src/main/resources/fabric.mod.json
Normal file
9
fabric-creative-tabs/src/main/resources/fabric.mod.json
Normal file
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"schemaVersion": 1,
|
||||
"id": "fabric-creative-tabs",
|
||||
"version": "${version}",
|
||||
"license": "Apache-2.0",
|
||||
"mixins": [
|
||||
"fabric-creative-tabs.mixins.json"
|
||||
]
|
||||
}
|
6
fabric-events-interaction/build.gradle
Normal file
6
fabric-events-interaction/build.gradle
Normal file
|
@ -0,0 +1,6 @@
|
|||
archivesBaseName = "fabric-events-interaction"
|
||||
version = "0.1.0"
|
||||
|
||||
dependencies {
|
||||
compile project(path: ':fabric-lib', configuration: 'dev')
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package net.fabricmc.fabric.impl.event;
|
||||
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
import net.fabricmc.fabric.api.block.BlockAttackInteractionAware;
|
||||
import net.fabricmc.fabric.api.event.player.AttackBlockCallback;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.util.ActionResult;
|
||||
|
||||
public class InteractionEventsRouter implements ModInitializer {
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
AttackBlockCallback.EVENT.register((player, world, hand, pos, direction) -> {
|
||||
BlockState state = world.getBlockState(pos);
|
||||
if (state instanceof BlockAttackInteractionAware) {
|
||||
if (((BlockAttackInteractionAware) state).onAttackInteraction(state, world, pos, player, hand, direction)) {
|
||||
return ActionResult.FAIL;
|
||||
}
|
||||
} else if (state.getBlock() instanceof BlockAttackInteractionAware) {
|
||||
if (((BlockAttackInteractionAware) state.getBlock()).onAttackInteraction(state, world, pos, player, hand, direction)) {
|
||||
return ActionResult.FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
return ActionResult.PASS;
|
||||
});
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
package net.fabricmc.fabric.impl.event;
|
||||
|
||||
import net.fabricmc.api.ClientModInitializer;
|
||||
import net.fabricmc.fabric.api.block.BlockPickInteractionAware;
|
||||
import net.fabricmc.fabric.api.entity.EntityPickInteractionAware;
|
||||
import net.fabricmc.fabric.api.event.client.player.ClientPickBlockGatherCallback;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.hit.EntityHitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.BlockView;
|
||||
|
||||
public class InteractionEventsRouterClient implements ClientModInitializer {
|
||||
@Override
|
||||
public void onInitializeClient() {
|
||||
ClientPickBlockGatherCallback.EVENT.register(((player, result) -> {
|
||||
if (result instanceof BlockHitResult) {
|
||||
BlockView view = player.getEntityWorld();
|
||||
BlockPos pos = ((BlockHitResult) result).getBlockPos();
|
||||
BlockState state = view.getBlockState(pos);
|
||||
|
||||
if (state.getBlock() instanceof BlockPickInteractionAware) {
|
||||
return (((BlockPickInteractionAware) state.getBlock()).getPickedStack(state, view, pos, player, result));
|
||||
}
|
||||
} else if (result instanceof EntityHitResult) {
|
||||
Entity entity = ((EntityHitResult) result).getEntity();
|
||||
|
||||
if (entity instanceof EntityPickInteractionAware) {
|
||||
return ((EntityPickInteractionAware) entity).getPickedStack(player, result);
|
||||
}
|
||||
}
|
||||
|
||||
return ItemStack.EMPTY;
|
||||
}));
|
||||
}
|
||||
}
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package net.fabricmc.fabric.mixin.events.playerinteraction;
|
||||
package net.fabricmc.fabric.mixin.eventsinteraction;
|
||||
|
||||
import net.fabricmc.fabric.api.event.player.*;
|
||||
import net.minecraft.client.MinecraftClient;
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package net.fabricmc.fabric.mixin.events.playerinteraction;
|
||||
package net.fabricmc.fabric.mixin.eventsinteraction;
|
||||
|
||||
import net.fabricmc.fabric.api.event.client.player.ClientPickBlockApplyCallback;
|
||||
import net.fabricmc.fabric.api.event.client.player.ClientPickBlockCallback;
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package net.fabricmc.fabric.mixin.events.playerinteraction;
|
||||
package net.fabricmc.fabric.mixin.eventsinteraction;
|
||||
|
||||
import net.fabricmc.fabric.api.event.player.UseEntityCallback;
|
||||
import net.minecraft.entity.Entity;
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package net.fabricmc.fabric.mixin.events.playerinteraction;
|
||||
package net.fabricmc.fabric.mixin.eventsinteraction;
|
||||
|
||||
import net.fabricmc.fabric.api.event.player.AttackEntityCallback;
|
||||
import net.minecraft.entity.Entity;
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package net.fabricmc.fabric.mixin.events.playerinteraction;
|
||||
package net.fabricmc.fabric.mixin.eventsinteraction;
|
||||
|
||||
import net.fabricmc.fabric.api.event.player.AttackBlockCallback;
|
||||
import net.fabricmc.fabric.api.event.player.UseBlockCallback;
|
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"required": true,
|
||||
"package": "net.fabricmc.fabric.mixin.eventsinteraction",
|
||||
"compatibilityLevel": "JAVA_8",
|
||||
"mixins": [
|
||||
"MixinServerPlayerEntity",
|
||||
"MixinServerPlayerInteractionManager",
|
||||
"MixinServerPlayNetworkHandler"
|
||||
],
|
||||
"client": [
|
||||
"MixinClientPlayerInteractionManager",
|
||||
"MixinMinecraftClient"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"schemaVersion": 1,
|
||||
"id": "fabric-events-interaction",
|
||||
"version": "${version}",
|
||||
"license": "Apache-2.0",
|
||||
"mixins": [
|
||||
"fabric-events-interaction.mixins.json"
|
||||
]
|
||||
}
|
6
fabric-events-lifecycle/build.gradle
Normal file
6
fabric-events-lifecycle/build.gradle
Normal file
|
@ -0,0 +1,6 @@
|
|||
archivesBaseName = "fabric-events-lifecycle"
|
||||
version = "0.1.0"
|
||||
|
||||
dependencies {
|
||||
compile project(path: ':fabric-lib', configuration: 'dev')
|
||||
}
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package net.fabricmc.fabric.mixin.events.tick;
|
||||
package net.fabricmc.fabric.mixin.eventslifecycle;
|
||||
|
||||
import net.fabricmc.fabric.api.event.client.ClientTickCallback;
|
||||
import net.fabricmc.fabric.api.event.world.WorldTickCallback;
|
|
@ -14,16 +14,21 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package net.fabricmc.fabric.mixin.events.server;
|
||||
package net.fabricmc.fabric.mixin.eventslifecycle;
|
||||
|
||||
import net.fabricmc.fabric.api.event.server.ServerStartCallback;
|
||||
import net.fabricmc.fabric.api.event.server.ServerStopCallback;
|
||||
import net.fabricmc.fabric.api.event.server.ServerTickCallback;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.profiler.DisableableProfiler;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import java.util.function.BooleanSupplier;
|
||||
|
||||
@Mixin(MinecraftServer.class)
|
||||
public class MixinMinecraftServer {
|
||||
@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/server/MinecraftServer;setFavicon(Lnet/minecraft/server/ServerMetadata;)V", ordinal = 0), method = "run")
|
||||
|
@ -35,4 +40,9 @@ public class MixinMinecraftServer {
|
|||
public void beforeShutdownServer(CallbackInfo info) {
|
||||
ServerStopCallback.EVENT.invoker().onStopServer((MinecraftServer) (Object) this);
|
||||
}
|
||||
|
||||
@Inject(at = @At("RETURN"), method = "tick")
|
||||
protected void tick(BooleanSupplier var1, CallbackInfo info) {
|
||||
ServerTickCallback.EVENT.invoker().tick((MinecraftServer) (Object) this);
|
||||
}
|
||||
}
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package net.fabricmc.fabric.mixin.events.tick;
|
||||
package net.fabricmc.fabric.mixin.eventslifecycle;
|
||||
|
||||
import net.fabricmc.fabric.api.event.world.WorldTickCallback;
|
||||
import net.minecraft.util.profiler.Profiler;
|
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"required": true,
|
||||
"package": "net.fabricmc.fabric.mixin.eventslifecycle",
|
||||
"compatibilityLevel": "JAVA_8",
|
||||
"mixins": [
|
||||
"MixinMinecraftServer",
|
||||
"MixinWorld"
|
||||
],
|
||||
"client": [
|
||||
"MixinMinecraftClient"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"schemaVersion": 1,
|
||||
"id": "fabric-events-lifecycle",
|
||||
"version": "${version}",
|
||||
"license": "Apache-2.0",
|
||||
"mixins": [
|
||||
"fabric-events-lifecycle.mixins.json"
|
||||
]
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue