update license header, add .editorconfig, run formatter - close #28

This commit is contained in:
Adrian Siekierka 2019-04-26 20:18:20 +02:00
parent 99acb0615e
commit ab8198ed5f
182 changed files with 609 additions and 605 deletions

25
.editorconfig Normal file
View file

@ -0,0 +1,25 @@
root = true
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
tab_width = 4
[*.gradle]
indent_style = tab
[*.java]
indent_style = tab
[*.json]
indent_style = space
indent_size = 2
[*.properties]
indent_style = space
indent_size = 2
[.editorconfig]
indent_style = space
indent_size = 4

2
HEADER
View file

@ -1,4 +1,4 @@
Copyright (c) 2016, 2017, 2018 FabricMC Copyright (c) 2016, 2017, 2018, 2019 FabricMC
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.

View file

@ -4,6 +4,7 @@ plugins {
id 'idea' id 'idea'
id 'maven-publish' id 'maven-publish'
id 'fabric-loom' version '0.2.2-SNAPSHOT' apply false id 'fabric-loom' version '0.2.2-SNAPSHOT' apply false
id 'net.minecrell.licenser' version '0.4.1'
// id 'com.matthewprenger.cursegradle' version "1.1.2" // id 'com.matthewprenger.cursegradle' version "1.1.2"
} }
@ -15,6 +16,7 @@ def mcVersion = "1.14"
allprojects { allprojects {
apply plugin: 'maven-publish' apply plugin: 'maven-publish'
apply plugin: 'fabric-loom' apply plugin: 'fabric-loom'
apply plugin: 'net.minecrell.licenser'
sourceCompatibility = 1.8 sourceCompatibility = 1.8
targetCompatibility = 1.8 targetCompatibility = 1.8
@ -52,6 +54,12 @@ allprojects {
exclude "fabric.mod.json" exclude "fabric.mod.json"
} }
} }
license {
println(rootProject.file('HEADER'))
header rootProject.file('HEADER')
include '**/*.java'
}
} }
task sourcesJar(type: Jar, dependsOn: classes) { task sourcesJar(type: Jar, dependsOn: classes) {
@ -119,7 +127,7 @@ publishing {
def depNode = depsNode.appendNode("dependency") def depNode = depsNode.appendNode("dependency")
depNode.appendNode("groupId", it.group) depNode.appendNode("groupId", it.group)
depNode.appendNode("artifactId", it.name) depNode.appendNode("artifactId", it.name)
depNode.appendNode("version", it.version) depNode.appendNode("version", it.version)
depNode.appendNode("scope", "compile") depNode.appendNode("scope", "compile")
} }
} }
@ -139,6 +147,9 @@ publishing {
} }
} }
task licenseFormatAll
subprojects { p -> licenseFormatAll.dependsOn("${p.path}:licenseFormat") }
dependencies { dependencies {
afterEvaluate { afterEvaluate {
subprojects.each { subprojects.each {
@ -171,5 +182,4 @@ version = baseVersion + "+" + (ENV.BUILD_NUMBER ? ("build." + ENV.BUILD_NUMBER)
// } // }
//} //}
apply from: 'https://github.com/FabricMC/fabric-docs/raw/master/gradle/license.gradle'
apply from: 'https://github.com/FabricMC/fabric-docs/raw/master/gradle/ideconfig.gradle' apply from: 'https://github.com/FabricMC/fabric-docs/raw/master/gradle/ideconfig.gradle'

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -22,7 +22,7 @@ import net.minecraft.util.Identifier;
/** /**
* Expanded version of {@link KeyBinding} for use by Fabric mods. * Expanded version of {@link KeyBinding} for use by Fabric mods.
* * <p>
* *ALL* instantiated FabricKeyBindings should be registered in * *ALL* instantiated FabricKeyBindings should be registered in
* {@link KeyBindingRegistry#register(FabricKeyBinding)}! * {@link KeyBindingRegistry#register(FabricKeyBinding)}!
*/ */

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -29,6 +29,7 @@ public interface KeyBindingRegistry {
/** /**
* Add a new key binding category. * Add a new key binding category.
*
* @param categoryName The key binding category name. * @param categoryName The key binding category name.
* @return True if a new category was added. * @return True if a new category was added.
*/ */
@ -36,6 +37,7 @@ public interface KeyBindingRegistry {
/** /**
* Register a new key binding. * Register a new key binding.
*
* @param binding The key binding. * @param binding The key binding.
* @return True if a new key binding was registered. * @return True if a new key binding was registered.
*/ */

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -37,7 +37,7 @@ public interface ColorProviderRegistry<T, Provider> {
/** /**
* Get a color provider for the given object. * Get a color provider for the given object.
* * <p>
* Please note that the underlying registry may not be fully populated or stable until the game has started, * Please note that the underlying registry may not be fully populated or stable until the game has started,
* as other mods may overwrite the registry. * as other mods may overwrite the registry.
* *

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -37,7 +37,7 @@ public class MixinEntityRenderManager {
private Map<Class<? extends Entity>, EntityRenderer<? extends Entity>> renderers; private Map<Class<? extends Entity>, EntityRenderer<? extends Entity>> renderers;
@Inject(method = "<init>(Lnet/minecraft/client/texture/TextureManager;Lnet/minecraft/client/render/item/ItemRenderer;Lnet/minecraft/resource/ReloadableResourceManager;)V", at = @At("RETURN"), require = 0) @Inject(method = "<init>(Lnet/minecraft/client/texture/TextureManager;Lnet/minecraft/client/render/item/ItemRenderer;Lnet/minecraft/resource/ReloadableResourceManager;)V", at = @At("RETURN"), require = 0)
public void init(TextureManager textureManager,ItemRenderer itemRenderer, ReloadableResourceManager manager, CallbackInfo info) { public void init(TextureManager textureManager, ItemRenderer itemRenderer, ReloadableResourceManager manager, CallbackInfo info) {
EntityRendererRegistry.INSTANCE.initialize((EntityRenderDispatcher) (Object) this, textureManager, manager, itemRenderer, renderers); EntityRendererRegistry.INSTANCE.initialize((EntityRenderDispatcher) (Object) this, textureManager, manager, itemRenderer, renderers);
} }
} }

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -20,9 +20,6 @@ import com.mojang.brigadier.CommandDispatcher;
import net.fabricmc.fabric.impl.registry.CommandRegistryImpl; import net.fabricmc.fabric.impl.registry.CommandRegistryImpl;
import net.minecraft.server.command.ServerCommandSource; import net.minecraft.server.command.ServerCommandSource;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.function.Consumer; import java.util.function.Consumer;
/** /**
@ -33,10 +30,11 @@ public class CommandRegistry {
/** /**
* Register a command provider. * Register a command provider.
*
* @param dedicated If true, the command is only registered on the dedicated server. * @param dedicated If true, the command is only registered on the dedicated server.
* @param consumer The command provider, consuming {@link CommandDispatcher}. * @param consumer The command provider, consuming {@link CommandDispatcher}.
*/ */
public void register(boolean dedicated, Consumer<CommandDispatcher<ServerCommandSource>> consumer) { public void register(boolean dedicated, Consumer<CommandDispatcher<ServerCommandSource>> consumer) {
CommandRegistryImpl.INSTANCE.register(dedicated, consumer); CommandRegistryImpl.INSTANCE.register(dedicated, consumer);
} }
} }

View file

@ -1,7 +1,22 @@
/*
* Copyright (c) 2016, 2017, 2018, 2019 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.fabricmc.fabric.impl.registry; package net.fabricmc.fabric.impl.registry;
import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.CommandDispatcher;
import net.fabricmc.fabric.api.registry.CommandRegistry;
import net.minecraft.server.command.ServerCommandSource; import net.minecraft.server.command.ServerCommandSource;
import java.util.ArrayList; import java.util.ArrayList;
@ -10,25 +25,25 @@ import java.util.List;
import java.util.function.Consumer; import java.util.function.Consumer;
public class CommandRegistryImpl { public class CommandRegistryImpl {
public static final CommandRegistryImpl INSTANCE = new CommandRegistryImpl(); public static final CommandRegistryImpl INSTANCE = new CommandRegistryImpl();
private final List<Consumer<CommandDispatcher<ServerCommandSource>>> serverCommands; private final List<Consumer<CommandDispatcher<ServerCommandSource>>> serverCommands;
private final List<Consumer<CommandDispatcher<ServerCommandSource>>> dedicatedServerCommands; private final List<Consumer<CommandDispatcher<ServerCommandSource>>> dedicatedServerCommands;
public CommandRegistryImpl() { public CommandRegistryImpl() {
this.serverCommands = new ArrayList<>(); this.serverCommands = new ArrayList<>();
this.dedicatedServerCommands = new ArrayList<>(); this.dedicatedServerCommands = new ArrayList<>();
} }
public List<Consumer<CommandDispatcher<ServerCommandSource>>> entries(boolean dedicated) { public List<Consumer<CommandDispatcher<ServerCommandSource>>> entries(boolean dedicated) {
return Collections.unmodifiableList(dedicated ? dedicatedServerCommands : serverCommands); return Collections.unmodifiableList(dedicated ? dedicatedServerCommands : serverCommands);
} }
public void register(boolean dedicated, Consumer<CommandDispatcher<ServerCommandSource>> consumer) { public void register(boolean dedicated, Consumer<CommandDispatcher<ServerCommandSource>> consumer) {
if (dedicated) { if (dedicated) {
dedicatedServerCommands.add(consumer); dedicatedServerCommands.add(consumer);
} else { } else {
serverCommands.add(consumer); serverCommands.add(consumer);
} }
} }
} }

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -19,14 +19,11 @@ package net.fabricmc.fabric.mixin.registrycommands;
import com.mojang.authlib.GameProfileRepository; import com.mojang.authlib.GameProfileRepository;
import com.mojang.authlib.minecraft.MinecraftSessionService; import com.mojang.authlib.minecraft.MinecraftSessionService;
import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService; import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.datafixers.DataFixer; import com.mojang.datafixers.DataFixer;
import net.fabricmc.fabric.api.registry.CommandRegistry;
import net.fabricmc.fabric.impl.registry.CommandRegistryImpl; import net.fabricmc.fabric.impl.registry.CommandRegistryImpl;
import net.minecraft.server.MinecraftServer; import net.minecraft.server.MinecraftServer;
import net.minecraft.server.WorldGenerationProgressListenerFactory; import net.minecraft.server.WorldGenerationProgressListenerFactory;
import net.minecraft.server.command.CommandManager; import net.minecraft.server.command.CommandManager;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.server.dedicated.MinecraftDedicatedServer; import net.minecraft.server.dedicated.MinecraftDedicatedServer;
import net.minecraft.util.UserCache; import net.minecraft.util.UserCache;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
@ -36,7 +33,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.io.File; import java.io.File;
import java.net.Proxy; import java.net.Proxy;
import java.util.function.Consumer;
@Mixin(MinecraftDedicatedServer.class) @Mixin(MinecraftDedicatedServer.class)
public abstract class MixinMinecraftDedicatedServer extends MinecraftServer { public abstract class MixinMinecraftDedicatedServer extends MinecraftServer {
@ -46,7 +42,7 @@ public abstract class MixinMinecraftDedicatedServer extends MinecraftServer {
} }
@Inject(method = "setupServer", at = @At("HEAD")) @Inject(method = "setupServer", at = @At("HEAD"))
private void setupServer(CallbackInfoReturnable<Boolean> info){ private void setupServer(CallbackInfoReturnable<Boolean> info) {
CommandRegistryImpl.INSTANCE.entries(false).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())); CommandRegistryImpl.INSTANCE.entries(true).forEach((e) -> e.accept(getCommandManager().getDispatcher()));
} }

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -17,7 +17,6 @@
package net.fabricmc.fabric.mixin.registrycommands; package net.fabricmc.fabric.mixin.registrycommands;
import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.CommandDispatcher;
import net.fabricmc.fabric.api.registry.CommandRegistry;
import net.fabricmc.fabric.impl.registry.CommandRegistryImpl; import net.fabricmc.fabric.impl.registry.CommandRegistryImpl;
import net.minecraft.server.command.CommandManager; import net.minecraft.server.command.CommandManager;
import net.minecraft.server.command.ServerCommandSource; import net.minecraft.server.command.ServerCommandSource;
@ -38,7 +37,7 @@ public class MixinServerCommandManager {
@Inject(method = "<init>(Z)V", at = @At("RETURN")) @Inject(method = "<init>(Z)V", at = @At("RETURN"))
public void addMethods(boolean dedicated, CallbackInfo info) { public void addMethods(boolean dedicated, CallbackInfo info) {
// TODO: Run before findAmbiguities // TODO: Run before findAmbiguities
if(!dedicated){ if (!dedicated) {
CommandRegistryImpl.INSTANCE.entries(false).forEach((e) -> e.accept(dispatcher)); CommandRegistryImpl.INSTANCE.entries(false).forEach((e) -> e.accept(dispatcher));
} }
} }

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -28,21 +28,19 @@ public interface ScreenProviderRegistry {
ScreenProviderRegistry INSTANCE = ScreenProviderRegistryImpl.INSTANCE; ScreenProviderRegistry INSTANCE = ScreenProviderRegistryImpl.INSTANCE;
/** /**
*
* Register a "Container -> ContainerScreen" factory. This is used only on the client side. * Register a "Container -> ContainerScreen" factory. This is used only on the client side.
* *
* @param identifier a shared identifier, this identifier should also be used to register a container using {@link ContainerProviderRegistry} * @param identifier a shared identifier, this identifier should also be used to register a container using {@link ContainerProviderRegistry}
* @param containerScreenFactory the supplier that should be used to create the new gui * @param containerScreenFactory the supplier that should be used to create the new gui
*/ */
<C extends Container> void registerFactory(Identifier identifier, ContainerScreenFactory<C> containerScreenFactory); <C extends Container> void registerFactory(Identifier identifier, ContainerScreenFactory<C> containerScreenFactory);
/** /**
*
* Register a "packet -> ContainerScreen" factory. This is used only on the client side, and allows you * Register a "packet -> ContainerScreen" factory. This is used only on the client side, and allows you
* to override the default behaviour of re-using the existing "packet -> Container" logic. * to override the default behaviour of re-using the existing "packet -> Container" logic.
* *
* @param identifier a shared identifier, this identifier should also be used to register a container using {@link ContainerProviderRegistry} * @param identifier a shared identifier, this identifier should also be used to register a container using {@link ContainerProviderRegistry}
* @param factory the gui factory, this should return a new {@link ContainerScreen} * @param factory the gui factory, this should return a new {@link ContainerScreen}
*/ */
void registerFactory(Identifier identifier, ContainerFactory<ContainerScreen> factory); void registerFactory(Identifier identifier, ContainerFactory<ContainerScreen> factory);

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -24,13 +24,12 @@ import net.minecraft.util.PacketByteBuf;
public interface ContainerFactory<T> { public interface ContainerFactory<T> {
/** /**
*
* Creates the new object. * Creates the new object.
* *
* @param syncId The container synchronization ID. * @param syncId The container synchronization ID.
* @param identifier the Identifier is the name that was used when registering the factory * @param identifier the Identifier is the name that was used when registering the factory
* @param player the player that is opening the gui/container * @param player the player that is opening the gui/container
* @param buf the buffer contains the same data that was provided with {@Link ContainerProviderRegistry.openContainer} * @param buf the buffer contains the same data that was provided with {@Link ContainerProviderRegistry.openContainer}
* @return the new gui or container * @return the new gui or container
*/ */
T create(int syncId, Identifier identifier, PlayerEntity player, PacketByteBuf buf); T create(int syncId, Identifier identifier, PlayerEntity player, PacketByteBuf buf);

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -31,31 +31,28 @@ public interface ContainerProviderRegistry {
ContainerProviderRegistry INSTANCE = ContainerProviderImpl.INSTANCE; ContainerProviderRegistry INSTANCE = ContainerProviderImpl.INSTANCE;
/** /**
*
* Register a "packet buffer -> container" factory. This is used both on the client and server side. * Register a "packet buffer -> container" factory. This is used both on the client and server side.
* *
* @param identifier a shared identifier, this identifier should also be used to register a container using {@link ScreenProviderRegistry} * @param identifier a shared identifier, this identifier should also be used to register a container using {@link ScreenProviderRegistry}
* @param factory the ContainerFactory that should return a new {@link Container} * @param factory the ContainerFactory that should return a new {@link Container}
*/ */
void registerFactory(Identifier identifier, ContainerFactory<Container> factory); void registerFactory(Identifier identifier, ContainerFactory<Container> factory);
/** /**
*
* Open a modded container. * Open a modded container.
* *
* @param identifier the identifier that was used when registering the container * @param identifier the identifier that was used when registering the container
* @param player the player that should open the container * @param player the player that should open the container
* @param writer a PacketByteBuf where data can be written to, this data is then accessible by the container factory when creating the container or the gui * @param writer a PacketByteBuf where data can be written to, this data is then accessible by the container factory when creating the container or the gui
*/ */
void openContainer(Identifier identifier, ServerPlayerEntity player, Consumer<PacketByteBuf> writer); void openContainer(Identifier identifier, ServerPlayerEntity player, Consumer<PacketByteBuf> writer);
/** /**
*
* Open a modded container. This should be called on the server side - it has no effect on the client side. * Open a modded container. This should be called on the server side - it has no effect on the client side.
* *
* @param identifier the identifier that was used when registering the container * @param identifier the identifier that was used when registering the container
* @param player the player that should open the container * @param player the player that should open the container
* @param writer a PacketByteBuf where data can be written to, this data is then accessible by the container factory when creating the container or the gui * @param writer a PacketByteBuf where data can be written to, this data is then accessible by the container factory when creating the container or the gui
*/ */
void openContainer(Identifier identifier, PlayerEntity player, Consumer<PacketByteBuf> writer); void openContainer(Identifier identifier, PlayerEntity player, Consumer<PacketByteBuf> writer);
} }

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -54,7 +54,7 @@ public class ScreenProviderRegistryImpl implements ScreenProviderRegistry {
public <C extends Container> void registerFactory(Identifier identifier, ContainerScreenFactory<C> containerScreenFactory) { public <C extends Container> void registerFactory(Identifier identifier, ContainerScreenFactory<C> containerScreenFactory) {
registerFactory(identifier, (syncId, identifier1, player, buf) -> { registerFactory(identifier, (syncId, identifier1, player, buf) -> {
C container = ContainerProviderImpl.INSTANCE.createContainer(syncId, identifier1, player, buf); C container = ContainerProviderImpl.INSTANCE.createContainer(syncId, identifier1, player, buf);
if(container == null){ if (container == null) {
LOGGER.error("Could not open container for {} - a null object was created!", identifier1.toString()); LOGGER.error("Could not open container for {} - a null object was created!", identifier1.toString());
return null; return null;
} }

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -78,14 +78,14 @@ public class ContainerProviderImpl implements ContainerProviderRegistry {
clonedBuf.readUnsignedByte(); clonedBuf.readUnsignedByte();
Container container = createContainer(syncId, identifier, player, clonedBuf); Container container = createContainer(syncId, identifier, player, clonedBuf);
if(container == null){ if (container == null) {
return; return;
} }
player.container = container; player.container = container;
player.container.addListener(player); player.container.addListener(player);
} }
public <C extends Container> C createContainer(int syncId, Identifier identifier, PlayerEntity player, PacketByteBuf buf){ public <C extends Container> C createContainer(int syncId, Identifier identifier, PlayerEntity player, PacketByteBuf buf) {
ContainerFactory<Container> factory = FACTORIES.get(identifier); ContainerFactory<Container> factory = FACTORIES.get(identifier);
if (factory == null) { if (factory == null) {
LOGGER.error("No container factory found for {}!", identifier.toString()); LOGGER.error("No container factory found for {}!", identifier.toString());

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -23,9 +23,11 @@ import org.spongepowered.asm.mixin.Shadow;
@Mixin(ServerPlayerEntity.class) @Mixin(ServerPlayerEntity.class)
public abstract class MixinServerPlayerEntity implements SyncIdProvider { public abstract class MixinServerPlayerEntity implements SyncIdProvider {
@Shadow private int containerSyncId; @Shadow
private int containerSyncId;
@Shadow protected abstract void incrementContainerSyncId(); @Shadow
protected abstract void incrementContainerSyncId();
@Override @Override
public int fabric_incrementSyncId() { public int fabric_incrementSyncId() {

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -17,16 +17,20 @@
package net.fabricmc.fabric.api.util; package net.fabricmc.fabric.api.util;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemProvider;
import net.minecraft.tag.Tag; import net.minecraft.tag.Tag;
public interface Block2ObjectMap<V> { public interface Block2ObjectMap<V> {
V get(Block block); V get(Block block);
void add(Block block, V value); void add(Block block, V value);
void add(Tag<Block> tag, V value); void add(Tag<Block> tag, V value);
void remove(Block block); void remove(Block block);
void remove(Tag<Block> tag); void remove(Tag<Block> tag);
void clear(Block block); void clear(Block block);
void clear(Tag<Block> tag); void clear(Tag<Block> tag);
} }

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -22,10 +22,16 @@ import net.minecraft.tag.Tag;
public interface Item2ObjectMap<V> { public interface Item2ObjectMap<V> {
V get(ItemProvider item); V get(ItemProvider item);
void add(ItemProvider item, V value); void add(ItemProvider item, V value);
void add(Tag<Item> tag, V value); void add(Tag<Item> tag, V value);
void remove(ItemProvider item); void remove(ItemProvider item);
void remove(Tag<Item> tag); void remove(Tag<Item> tag);
void clear(ItemProvider item); void clear(ItemProvider item);
void clear(Tag<Item> tag); void clear(Tag<Item> tag);
} }

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -22,9 +22,6 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemProvider; import net.minecraft.item.ItemProvider;
import net.minecraft.tag.Tag; import net.minecraft.tag.Tag;
import java.util.ArrayList;
import java.util.List;
public class CompostingChanceRegistryImpl implements CompostingChanceRegistry { public class CompostingChanceRegistryImpl implements CompostingChanceRegistry {
@Override @Override
public Float get(ItemProvider item) { public Float get(ItemProvider item) {

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -17,7 +17,6 @@
package net.fabricmc.fabric.impl.registry; package net.fabricmc.fabric.impl.registry;
import net.fabricmc.fabric.api.registry.FlammableBlockRegistry; import net.fabricmc.fabric.api.registry.FlammableBlockRegistry;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
public interface FireBlockHooks { public interface FireBlockHooks {

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,10 +16,7 @@
package net.fabricmc.fabric.impl.registry; package net.fabricmc.fabric.impl.registry;
import it.unimi.dsi.fastutil.objects.Object2IntMap;
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
import net.fabricmc.fabric.api.registry.FlammableBlockRegistry; import net.fabricmc.fabric.api.registry.FlammableBlockRegistry;
import net.fabricmc.fabric.api.resource.IdentifiableResourceReloadListener;
import net.fabricmc.fabric.api.resource.ResourceManagerHelper; import net.fabricmc.fabric.api.resource.ResourceManagerHelper;
import net.fabricmc.fabric.api.resource.ResourceReloadListenerKeys; import net.fabricmc.fabric.api.resource.ResourceReloadListenerKeys;
import net.fabricmc.fabric.api.resource.SimpleSynchronousResourceReloadListener; import net.fabricmc.fabric.api.resource.SimpleSynchronousResourceReloadListener;
@ -28,13 +25,11 @@ import net.minecraft.resource.ResourceManager;
import net.minecraft.resource.ResourceType; import net.minecraft.resource.ResourceType;
import net.minecraft.tag.Tag; import net.minecraft.tag.Tag;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.profiler.Profiler;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.concurrent.CompletableFuture;
public class FlammableBlockRegistryImpl implements FlammableBlockRegistry, SimpleSynchronousResourceReloadListener { public class FlammableBlockRegistryImpl implements FlammableBlockRegistry, SimpleSynchronousResourceReloadListener {
private static final FlammableBlockRegistry.Entry REMOVED = new FlammableBlockRegistry.Entry(0, 0); private static final FlammableBlockRegistry.Entry REMOVED = new FlammableBlockRegistry.Entry(0, 0);

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -20,8 +20,6 @@ import net.fabricmc.fabric.api.registry.LootEntryTypeRegistry;
import net.minecraft.world.loot.entry.LootEntries; import net.minecraft.world.loot.entry.LootEntries;
import net.minecraft.world.loot.entry.LootEntry; import net.minecraft.world.loot.entry.LootEntry;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.function.Consumer; import java.util.function.Consumer;
@ -50,7 +48,8 @@ public final class LootEntryTypeRegistryImpl implements LootEntryTypeRegistry {
} }
} }
private LootEntryTypeRegistryImpl() {} private LootEntryTypeRegistryImpl() {
}
@Override @Override
public void register(LootEntry.Serializer<?> serializer) { public void register(LootEntry.Serializer<?> serializer) {

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -26,8 +26,6 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.util.*;
@Mixin(CrashReport.class) @Mixin(CrashReport.class)
public abstract class MixinCrashReport { public abstract class MixinCrashReport {
@Shadow @Shadow
@ -53,4 +51,4 @@ public abstract class MixinCrashReport {
return modString.toString(); return modString.toString();
}); });
} }
} }

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -28,12 +28,12 @@ import net.minecraft.world.World;
/** /**
* Callback for left-clicking ("attacking") a block. * Callback for left-clicking ("attacking") a block.
* Is hooked in before the spectator check, so make sure to check for the player's game mode as well! * Is hooked in before the spectator check, so make sure to check for the player's game mode as well!
* * <p>
* Upon return: * Upon return:
* - SUCCESS cancels further processing and, on the client, sends a packet to the server. * - SUCCESS cancels further processing and, on the client, sends a packet to the server.
* - PASS falls back to further processing. * - PASS falls back to further processing.
* - FAIL cancels further processing and does not send a packet to the server. * - FAIL cancels further processing and does not send a packet to the server.
* * <p>
* ATTACK_BLOCK does not let you control the packet sending process yet. * ATTACK_BLOCK does not let you control the packet sending process yet.
*/ */
public interface AttackBlockCallback { public interface AttackBlockCallback {

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -28,7 +28,7 @@ import net.minecraft.world.World;
/** /**
* Callback for left-clicking ("attacking") an entity. * Callback for left-clicking ("attacking") an entity.
* Is hooked in before the spectator check, so make sure to check for the player's game mode as well! * Is hooked in before the spectator check, so make sure to check for the player's game mode as well!
* * <p>
* Upon return: * Upon return:
* - SUCCESS cancels further processing and, on the client, sends a packet to the server. * - SUCCESS cancels further processing and, on the client, sends a packet to the server.
* - PASS falls back to further processing. * - PASS falls back to further processing.

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -27,7 +27,7 @@ import net.minecraft.world.World;
/** /**
* Callback for right-clicking ("using") a block. * Callback for right-clicking ("using") a block.
* Is hooked in before the spectator check, so make sure to check for the player's game mode as well! * Is hooked in before the spectator check, so make sure to check for the player's game mode as well!
* * <p>
* Upon return: * Upon return:
* - SUCCESS cancels further processing and, on the client, sends a packet to the server. * - SUCCESS cancels further processing and, on the client, sends a packet to the server.
* - PASS falls back to further processing. * - PASS falls back to further processing.

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -28,7 +28,7 @@ import net.minecraft.world.World;
/** /**
* Callback for right-clicking ("using") an entity. * Callback for right-clicking ("using") an entity.
* Is hooked in before the spectator check, so make sure to check for the player's game mode as well! * Is hooked in before the spectator check, so make sure to check for the player's game mode as well!
* * <p>
* Upon return: * Upon return:
* - SUCCESS cancels further processing and, on the client, sends a packet to the server. * - SUCCESS cancels further processing and, on the client, sends a packet to the server.
* - PASS falls back to further processing. * - PASS falls back to further processing.

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -26,7 +26,7 @@ import net.minecraft.world.World;
/** /**
* Callback for right-clicking ("using") an item. * Callback for right-clicking ("using") an item.
* Is hooked in before the spectator check, so make sure to check for the player's game mode as well! * Is hooked in before the spectator check, so make sure to check for the player's game mode as well!
* * <p>
* Upon return: * Upon return:
* - SUCCESS cancels further processing and, on the client, sends a packet to the server. * - SUCCESS cancels further processing and, on the client, sends a packet to the server.
* - PASS falls back to further processing. * - PASS falls back to further processing.

View file

@ -1,3 +1,19 @@
/*
* Copyright (c) 2016, 2017, 2018, 2019 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.fabricmc.fabric.impl.event; package net.fabricmc.fabric.impl.event;
import net.fabricmc.api.ModInitializer; import net.fabricmc.api.ModInitializer;
@ -7,21 +23,21 @@ import net.minecraft.block.BlockState;
import net.minecraft.util.ActionResult; import net.minecraft.util.ActionResult;
public class InteractionEventsRouter implements ModInitializer { public class InteractionEventsRouter implements ModInitializer {
@Override @Override
public void onInitialize() { public void onInitialize() {
AttackBlockCallback.EVENT.register((player, world, hand, pos, direction) -> { AttackBlockCallback.EVENT.register((player, world, hand, pos, direction) -> {
BlockState state = world.getBlockState(pos); BlockState state = world.getBlockState(pos);
if (state instanceof BlockAttackInteractionAware) { if (state instanceof BlockAttackInteractionAware) {
if (((BlockAttackInteractionAware) state).onAttackInteraction(state, world, pos, player, hand, direction)) { if (((BlockAttackInteractionAware) state).onAttackInteraction(state, world, pos, player, hand, direction)) {
return ActionResult.FAIL; return ActionResult.FAIL;
} }
} else if (state.getBlock() instanceof BlockAttackInteractionAware) { } else if (state.getBlock() instanceof BlockAttackInteractionAware) {
if (((BlockAttackInteractionAware) state.getBlock()).onAttackInteraction(state, world, pos, player, hand, direction)) { if (((BlockAttackInteractionAware) state.getBlock()).onAttackInteraction(state, world, pos, player, hand, direction)) {
return ActionResult.FAIL; return ActionResult.FAIL;
} }
} }
return ActionResult.PASS; return ActionResult.PASS;
}); });
} }
} }

View file

@ -1,3 +1,19 @@
/*
* Copyright (c) 2016, 2017, 2018, 2019 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.fabricmc.fabric.impl.event; package net.fabricmc.fabric.impl.event;
import net.fabricmc.api.ClientModInitializer; import net.fabricmc.api.ClientModInitializer;
@ -13,26 +29,26 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.BlockView; import net.minecraft.world.BlockView;
public class InteractionEventsRouterClient implements ClientModInitializer { public class InteractionEventsRouterClient implements ClientModInitializer {
@Override @Override
public void onInitializeClient() { public void onInitializeClient() {
ClientPickBlockGatherCallback.EVENT.register(((player, result) -> { ClientPickBlockGatherCallback.EVENT.register(((player, result) -> {
if (result instanceof BlockHitResult) { if (result instanceof BlockHitResult) {
BlockView view = player.getEntityWorld(); BlockView view = player.getEntityWorld();
BlockPos pos = ((BlockHitResult) result).getBlockPos(); BlockPos pos = ((BlockHitResult) result).getBlockPos();
BlockState state = view.getBlockState(pos); BlockState state = view.getBlockState(pos);
if (state.getBlock() instanceof BlockPickInteractionAware) { if (state.getBlock() instanceof BlockPickInteractionAware) {
return (((BlockPickInteractionAware) state.getBlock()).getPickedStack(state, view, pos, player, result)); return (((BlockPickInteractionAware) state.getBlock()).getPickedStack(state, view, pos, player, result));
} }
} else if (result instanceof EntityHitResult) { } else if (result instanceof EntityHitResult) {
Entity entity = ((EntityHitResult) result).getEntity(); Entity entity = ((EntityHitResult) result).getEntity();
if (entity instanceof EntityPickInteractionAware) { if (entity instanceof EntityPickInteractionAware) {
return ((EntityPickInteractionAware) entity).getPickedStack(player, result); return ((EntityPickInteractionAware) entity).getPickedStack(player, result);
} }
} }
return ItemStack.EMPTY; return ItemStack.EMPTY;
})); }));
} }
} }

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -32,7 +32,6 @@ import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.ModifyVariable; import org.spongepowered.asm.mixin.injection.ModifyVariable;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(MinecraftClient.class) @Mixin(MinecraftClient.class)
@ -96,6 +95,7 @@ public abstract class MixinMinecraftClient {
@Shadow @Shadow
public abstract void doItemPick(); public abstract void doItemPick();
@Shadow @Shadow
public abstract ItemStack addBlockEntityNbt(ItemStack itemStack_1, BlockEntity blockEntity_1); public abstract ItemStack addBlockEntityNbt(ItemStack itemStack_1, BlockEntity blockEntity_1);

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -17,12 +17,8 @@
package net.fabricmc.fabric.mixin.eventslifecycle; package net.fabricmc.fabric.mixin.eventslifecycle;
import net.fabricmc.fabric.api.event.client.ClientTickCallback; import net.fabricmc.fabric.api.event.client.ClientTickCallback;
import net.fabricmc.fabric.api.event.world.WorldTickCallback;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.MinecraftClient;
import net.minecraft.util.profiler.DisableableProfiler;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin; 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.At;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -20,9 +20,7 @@ import net.fabricmc.fabric.api.event.server.ServerStartCallback;
import net.fabricmc.fabric.api.event.server.ServerStopCallback; import net.fabricmc.fabric.api.event.server.ServerStopCallback;
import net.fabricmc.fabric.api.event.server.ServerTickCallback; import net.fabricmc.fabric.api.event.server.ServerTickCallback;
import net.minecraft.server.MinecraftServer; import net.minecraft.server.MinecraftServer;
import net.minecraft.util.profiler.DisableableProfiler;
import org.spongepowered.asm.mixin.Mixin; 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.At;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -17,16 +17,12 @@
package net.fabricmc.fabric.mixin.eventslifecycle; package net.fabricmc.fabric.mixin.eventslifecycle;
import net.fabricmc.fabric.api.event.world.WorldTickCallback; import net.fabricmc.fabric.api.event.world.WorldTickCallback;
import net.minecraft.util.profiler.Profiler;
import net.minecraft.world.World; import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin; 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.At;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.util.function.BooleanSupplier;
@Mixin(World.class) @Mixin(World.class)
public class MixinWorld { public class MixinWorld {
// TODO split into ClientWorld/ServerWorld ticks? mmm need more mappings // TODO split into ClientWorld/ServerWorld ticks? mmm need more mappings

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -37,7 +37,6 @@ public final class FabricItemGroupBuilder {
} }
/** /**
*
* Create a new Item Group Builder * Create a new Item Group Builder
* *
* @param identifier the id will become the name of the ItemGroup and will be used for the translation key * @param identifier the id will become the name of the ItemGroup and will be used for the translation key
@ -48,7 +47,6 @@ public final class FabricItemGroupBuilder {
} }
/** /**
*
* This is used to add an icon to to the item group * This is used to add an icon to to the item group
* *
* @param stackSupplier the supplier should return the item stack that you wish to show on the tab * @param stackSupplier the supplier should return the item stack that you wish to show on the tab
@ -60,7 +58,6 @@ public final class FabricItemGroupBuilder {
} }
/** /**
*
* This allows for a custom list of items to be displayed in a tab, this enabled tabs to be created with a custom set of items * This allows for a custom list of items to be displayed in a tab, this enabled tabs to be created with a custom set of items
* *
* @param appender Add ItemStack's to this list to show in the ItemGroup * @param appender Add ItemStack's to this list to show in the ItemGroup
@ -73,7 +70,6 @@ public final class FabricItemGroupBuilder {
} }
/** /**
*
* This allows for a custom list of items to be displayed in a tab, this enabled tabs to be created with a custom set of items * This allows for a custom list of items to be displayed in a tab, this enabled tabs to be created with a custom set of items
* *
* @param stacksForDisplay Add ItemStack's to this list to show in the ItemGroup * @param stacksForDisplay Add ItemStack's to this list to show in the ItemGroup
@ -85,20 +81,18 @@ public final class FabricItemGroupBuilder {
} }
/** /**
*
* This is a single method that makes creating an ItemGroup with an icon one call * This is a single method that makes creating an ItemGroup with an icon one call
* *
* @param identifier the id will become the name of the ItemGroup and will be used for the translation key * @param identifier the id will become the name of the ItemGroup and will be used for the translation key
* @param stackSupplier the supplier should return the item stack that you wish to show on the tab * @param stackSupplier the supplier should return the item stack that you wish to show on the tab
* @return An instance of the built ItemGroup * @return An instance of the built ItemGroup
*/ */
public static ItemGroup build(Identifier identifier, Supplier<ItemStack> stackSupplier){ public static ItemGroup build(Identifier identifier, Supplier<ItemStack> stackSupplier) {
return new FabricItemGroupBuilder(identifier).icon(stackSupplier).build(); return new FabricItemGroupBuilder(identifier).icon(stackSupplier).build();
} }
/** /**
* * Create an instance of the ItemGroup
* Create an instance of the ItemGroup
* *
* @return An instance of the built ItemGroup * @return An instance of the built ItemGroup
*/ */
@ -112,7 +106,7 @@ public final class FabricItemGroupBuilder {
@Override @Override
public void appendItems(DefaultedList<ItemStack> stacks) { public void appendItems(DefaultedList<ItemStack> stacks) {
if(stacksForDisplay != null){ if (stacksForDisplay != null) {
stacksForDisplay.accept(stacks); stacksForDisplay.accept(stacks);
return; return;
} }

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -64,7 +64,7 @@ public class FabricCreativeGuiComponents {
GlStateManager.color4f(1F, 1F, 1F, 1F); GlStateManager.color4f(1F, 1F, 1F, 1F);
this.blit(this.x, this.y, (type == Type.NEXT ? 12 : 0), (active ? 0 : 12), 12, 12); this.blit(this.x, this.y, (type == Type.NEXT ? 12 : 0), (active ? 0 : 12), 12, 12);
if(mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height){ if (mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height) {
gui.renderTooltip(I18n.translate("fabric.gui.creativeTabPage", extensions.fabric_currentPage() + 1, ((ItemGroup.GROUPS.length - 12) / 9) + 2), mouseX, mouseY); gui.renderTooltip(I18n.translate("fabric.gui.creativeTabPage", extensions.fabric_currentPage() + 1, ((ItemGroup.GROUPS.length - 12) / 9) + 2), mouseX, mouseY);
} }
} }

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -18,7 +18,6 @@ package net.fabricmc.fabric.mixin.itemgroup.client;
import net.fabricmc.fabric.impl.itemgroup.FabricCreativeGuiComponents; import net.fabricmc.fabric.impl.itemgroup.FabricCreativeGuiComponents;
import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemGroup;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -32,7 +32,7 @@ public abstract class Event<T> {
/** /**
* Returns the invoker instance. * Returns the invoker instance.
* * <p>
* An "invoker" is an object which hides multiple registered * An "invoker" is an object which hides multiple registered
* listeners of type T under one instance of type T, executing * listeners of type T under one instance of type T, executing
* them and leaving early as necessary. * them and leaving early as necessary.

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -50,9 +50,9 @@ public final class EventFactory {
/** /**
* Create an "array-backed" Event instance. * Create an "array-backed" Event instance.
* *
* @param type The listener class type. * @param type The listener class type.
* @param invokerFactory The invoker factory, combining multiple listeners into one instance. * @param invokerFactory The invoker factory, combining multiple listeners into one instance.
* @param <T> The listener type. * @param <T> The listener type.
* @return The Event instance. * @return The Event instance.
*/ */
public static <T> Event<T> createArrayBacked(Class<T> type, Function<T[], T> invokerFactory) { public static <T> Event<T> createArrayBacked(Class<T> type, Function<T[], T> invokerFactory) {
@ -61,15 +61,15 @@ public final class EventFactory {
/** /**
* Create an "array-backed" Event instance with a custom empty invoker. * Create an "array-backed" Event instance with a custom empty invoker.
* * <p>
* Having a custom empty invoker (of type (...) -> {}) increases performance * Having a custom empty invoker (of type (...) -> {}) increases performance
* relative to iterating over an empty array; however, it only really matters * relative to iterating over an empty array; however, it only really matters
* if the event is executed thousands of times a second. * if the event is executed thousands of times a second.
* *
* @param type The listener class type. * @param type The listener class type.
* @param emptyInvoker The custom empty invoker. * @param emptyInvoker The custom empty invoker.
* @param invokerFactory The invoker factory, combining multiple listeners into one instance. * @param invokerFactory The invoker factory, combining multiple listeners into one instance.
* @param <T> The listener type. * @param <T> The listener type.
* @return The Event instance. * @return The Event instance.
*/ */
// TODO: Deprecate this once we have working codegen // TODO: Deprecate this once we have working codegen

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -24,7 +24,7 @@ import net.minecraft.nbt.Tag;
* *
* @see CompoundTag#containsKey(String, int) * @see CompoundTag#containsKey(String, int)
* @see Tag#idToString(int) * @see Tag#idToString(int)
* * <p>
* For the current list of types, check with {@link Tag#TYPES}. * For the current list of types, check with {@link Tag#TYPES}.
*/ */
public final class NbtType { public final class NbtType {

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -21,7 +21,6 @@ import net.fabricmc.fabric.api.event.Event;
import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles; import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType; import java.lang.invoke.MethodType;
import java.lang.reflect.*;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.function.Function; import java.util.function.Function;
@ -97,7 +96,7 @@ public final class EventFactoryImpl {
final Object returnValue = defValue; final Object returnValue = defValue;
//noinspection unchecked //noinspection unchecked
return (T) Proxy.newProxyInstance(EventFactoryImpl.class.getClassLoader(), new Class[] { handlerClass }, return (T) Proxy.newProxyInstance(EventFactoryImpl.class.getClassLoader(), new Class[]{handlerClass},
(proxy, method, args) -> returnValue); (proxy, method, args) -> returnValue);
} }
} }

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -30,6 +30,7 @@ import java.util.Map;
public final class ToolManager { public final class ToolManager {
public interface Entry { public interface Entry {
void setBreakByHand(boolean value); void setBreakByHand(boolean value);
void putBreakByTool(Tag<Item> tag, int miningLevel); void putBreakByTool(Tag<Item> tag, int miningLevel);
} }

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,8 +16,8 @@
package net.fabricmc.fabric.mixin.tools; package net.fabricmc.fabric.mixin.tools;
import net.fabricmc.fabric.impl.tools.ToolManager;
import net.fabricmc.fabric.api.util.TriState; import net.fabricmc.fabric.api.util.TriState;
import net.fabricmc.fabric.impl.tools.ToolManager;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -26,7 +26,7 @@ import net.minecraft.util.Identifier;
public interface ModelProviderContext { public interface ModelProviderContext {
/** /**
* Load a model using a {@link Identifier}, {@link ModelIdentifier}, ... * Load a model using a {@link Identifier}, {@link ModelIdentifier}, ...
* * <p>
* Please note that the game engine keeps track of circular model loading calls on its own. * Please note that the game engine keeps track of circular model loading calls on its own.
* *
* @param id The model identifier. * @param id The model identifier.

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -17,26 +17,25 @@
package net.fabricmc.fabric.api.client.model; package net.fabricmc.fabric.api.client.model;
import net.minecraft.client.render.model.UnbakedModel; import net.minecraft.client.render.model.UnbakedModel;
import net.minecraft.client.util.ModelIdentifier;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
/** /**
* Interface for model resource providers. * Interface for model resource providers.
* * <p>
* Model resource providers hook the loading of model *files* from the resource tree; * Model resource providers hook the loading of model *files* from the resource tree;
* that is, in vanilla, it handles going from "minecraft:block/stone" to a * that is, in vanilla, it handles going from "minecraft:block/stone" to a
* "assets/minecraft/models/block/stone.json" file. * "assets/minecraft/models/block/stone.json" file.
* * <p>
* This is where you want to add your own custom model formats. * This is where you want to add your own custom model formats.
* * <p>
* As providers are instantiated with a new provider, it is safe * As providers are instantiated with a new provider, it is safe
* (and recommended!) to cache information inside a loader. * (and recommended!) to cache information inside a loader.
* * <p>
* Keep in mind that only *one* ModelResourceProvider may respond to a given model * Keep in mind that only *one* ModelResourceProvider may respond to a given model
* at any time. If you're writing, say, an OBJ loader, this means you could * at any time. If you're writing, say, an OBJ loader, this means you could
* easily conflict with another OBJ loader unless you take some precautions, * easily conflict with another OBJ loader unless you take some precautions,
* for example: * for example:
* * <p>
* a) Only load files with a mod-suffixed name, such as .architect.obj, * a) Only load files with a mod-suffixed name, such as .architect.obj,
* b) Only load files from an explicit list of namespaces, registered elsewhere. * b) Only load files from an explicit list of namespaces, registered elsewhere.
*/ */

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -18,22 +18,21 @@ package net.fabricmc.fabric.api.client.model;
import net.minecraft.client.render.model.UnbakedModel; import net.minecraft.client.render.model.UnbakedModel;
import net.minecraft.client.util.ModelIdentifier; import net.minecraft.client.util.ModelIdentifier;
import net.minecraft.util.Identifier;
/** /**
* Interface for model variant providers. * Interface for model variant providers.
* * <p>
* Model variant providers hook the resolution of ModelIdentifiers. In vanilla, this is * Model variant providers hook the resolution of ModelIdentifiers. In vanilla, this is
* the part where a "minecraft:stone#normal" identifier triggers the loading of a * the part where a "minecraft:stone#normal" identifier triggers the loading of a
* "minecraft:models/stone" model ({@link ModelResourceProvider} handles the later step). * "minecraft:models/stone" model ({@link ModelResourceProvider} handles the later step).
* * <p>
* The most common use of this is to cooperate with a {@link ModelAppender}, but it can * The most common use of this is to cooperate with a {@link ModelAppender}, but it can
* also allow you to add your own block- or item-state formats. To trigger the loading * also allow you to add your own block- or item-state formats. To trigger the loading
* of another model, use the passed {@link ModelProviderContext}. * of another model, use the passed {@link ModelProviderContext}.
* * <p>
* As every model loading is instantiated with a new provider, it is safe * As every model loading is instantiated with a new provider, it is safe
* (and recommended!) to cache information. * (and recommended!) to cache information.
* * <p>
* Keep in mind that only *one* ModelVariantProvider may respond to a given model * Keep in mind that only *one* ModelVariantProvider may respond to a given model
* at any time. * at any time.
*/ */

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -22,5 +22,6 @@ import net.minecraft.util.Identifier;
public interface ModelLoaderHooks { public interface ModelLoaderHooks {
void fabric_addModel(ModelIdentifier id); void fabric_addModel(ModelIdentifier id);
UnbakedModel fabric_loadModel(Identifier id); UnbakedModel fabric_loadModel(Identifier id);
} }

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -27,7 +27,6 @@ import net.minecraft.util.Identifier;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import java.util.*;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,8 +16,6 @@
package net.fabricmc.fabric.mixin.client.model; package net.fabricmc.fabric.mixin.client.model;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import net.fabricmc.fabric.impl.client.model.ModelLoaderHooks; import net.fabricmc.fabric.impl.client.model.ModelLoaderHooks;
import net.fabricmc.fabric.impl.client.model.ModelLoadingRegistryImpl; import net.fabricmc.fabric.impl.client.model.ModelLoadingRegistryImpl;
import net.minecraft.client.render.model.ModelLoader; import net.minecraft.client.render.model.ModelLoader;

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -24,5 +24,6 @@ import net.minecraft.nbt.CompoundTag;
*/ */
public interface BlockEntityClientSerializable { public interface BlockEntityClientSerializable {
void fromClientTag(CompoundTag tag); void fromClientTag(CompoundTag tag);
CompoundTag toClientTag(CompoundTag tag); CompoundTag toClientTag(CompoundTag tag);
} }

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -51,7 +51,7 @@ public interface C2SPacketTypeCallback {
* Accept a collection of types. * Accept a collection of types.
* *
* @param client The player who is the source of the packet. * @param client The player who is the source of the packet.
* @param types The provided collection of types. * @param types The provided collection of types.
*/ */
void accept(PlayerEntity client, Collection<Identifier> types); void accept(PlayerEntity client, Collection<Identifier> types);
} }

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, 2018 FabricMC * Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

Some files were not shown because too many files have changed in this diff Show more