From 16bfde5c1698b04b25373604cbb902dbf8fb57e9 Mon Sep 17 00:00:00 2001 From: SD <62552372+BoogieMonster1O1@users.noreply.github.com> Date: Fri, 10 Jul 2020 01:44:34 +0530 Subject: [PATCH] Fabric events Lifecycle v0 (#4) * Created event lifecycle project Changes to be committed: modified: build.gradle new file: fabric-events-lifecycle-v0/build.gradle new file: fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinMinecraftClient.java new file: fabric-events-lifecycle-v0/src/main/resources/assets/fabric-events-lifecycle-v0/icon.png new file: fabric-events-lifecycle-v0/src/main/resources/fabric-events-lifecycle-v0.mixins.json new file: fabric-events-lifecycle-v0/src/main/resources/fabric.mod.json modified: settings.gradle * Created ClientTickCallback Changes to be committed: new file: fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/client/ClientTickCallback.java modified: fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinMinecraftClient.java * Added ItemTooltipCallback Changes to be committed: new file: fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/client/ItemTooltipCallback.java new file: fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinItem.java modified: fabric-events-lifecycle-v0/src/main/resources/fabric-events-lifecycle-v0.mixins.json * Added notice Changes to be committed: modified: fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/client/ClientTickCallback.java modified: fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/client/ItemTooltipCallback.java modified: fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinItem.java modified: fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinMinecraftClient.java * Added ServerStartCallback Changes to be committed: new file: fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/server/ServerStartCallback.java new file: fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinMinecraftServer.java modified: fabric-events-lifecycle-v0/src/main/resources/fabric-events-lifecycle-v0.mixins.json * Added ServerStopCallback Changes to be committed: new file: fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/server/ServerStopCallback.java modified: fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinMinecraftServer.java * Added ServerTickCallback Changes to be committed: modified: fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/server/ServerStopCallback.java new file: fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/server/ServerTickCallback.java modified: fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinMinecraftServer.java * Added WorldTickCallback Time to make more events now! Changes to be committed: new file: fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/world/WorldTickCallback.java new file: fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinWorld.java modified: fabric-events-lifecycle-v0/src/main/resources/fabric-events-lifecycle-v0.mixins.json * Added ClientStopCallback Changes to be committed: new file: fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/client/ClientStopCallback.java modified: fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinMinecraftClient.java * Fixed mixin target Changes to be committed: modified: fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinMinecraftClient.java * Added ClientStartCallback Changes to be committed: new file: fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/client/ClientStartCallback.java modified: fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinMinecraftClient.java * Removed lifecycle events from unfinished Changes to be committed: deleted: unfinished/fabric-events-lifecycle-v0/build.gradle deleted: unfinished/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/client/ClientTickCallback.java deleted: unfinished/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/client/ItemTooltipCallback.java deleted: unfinished/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/server/ServerStartCallback.java deleted: unfinished/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/server/ServerStopCallback.java deleted: unfinished/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/server/ServerTickCallback.java deleted: unfinished/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/world/WorldTickCallback.java deleted: unfinished/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinItemStack.java deleted: unfinished/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinMinecraftClient.java deleted: unfinished/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinMinecraftServer.java deleted: unfinished/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinWorld.java deleted: unfinished/fabric-events-lifecycle-v0/src/main/resources/assets/fabric-events-lifecycle-v0/icon.png deleted: unfinished/fabric-events-lifecycle-v0/src/main/resources/fabric-events-lifecycle-v0.mixins.json deleted: unfinished/fabric-events-lifecycle-v0/src/main/resources/fabric.mod.json * Added PlayerJoinCallback Changes to be committed: new file: fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/server/PlayerJoinCallback.java new file: fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinPlayerManager.java modified: fabric-events-lifecycle-v0/src/main/resources/fabric-events-lifecycle-v0.mixins.json * Added EntityKilledCallback Changes to be committed: new file: fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/world/EntityKilledCallback.java new file: fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinEntity.java modified: fabric-events-lifecycle-v0/src/main/resources/fabric-events-lifecycle-v0.mixins.json * Added LanServerPublishedCallback Changes to be committed: new file: fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/client/LanServerPublishedCallback.java new file: fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinIntegratedServer.java modified: fabric-events-lifecycle-v0/src/main/resources/fabric-events-lifecycle-v0.mixins.json * Added chunks saved callback Changes to be committed: new file: fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/world/ChunksSavedCallback.java new file: fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinThreadedAnvilChunkStorage.java modified: fabric-events-lifecycle-v0/src/main/resources/fabric-events-lifecycle-v0.mixins.json * Added EntityHurtCallback Changes to be committed: new file: fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/world/EntityHurtCallback.java new file: fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinDamageTracker.java modified: fabric-events-lifecycle-v0/src/main/resources/fabric-events-lifecycle-v0.mixins.json * Added DedicatedServerSetupCallback and ServerPlayerTickCallback Changes to be committed: new file: fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/server/DedicatedServerSetupCallback.java new file: fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/world/ServerPlayerTickCallback.java new file: fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinMinecraftDedicatedServer.java new file: fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinServerPlayerEntity.java modified: fabric-events-lifecycle-v0/src/main/resources/fabric-events-lifecycle-v0.mixins.json * Updated yarn and applied license header and temperorily disabled checkstyle Changes to be committed: modified: build.gradle modified: fabric-api-base/src/main/java/net/fabricmc/fabric/api/util/NbtType.java modified: fabric-api-base/src/main/java/net/fabricmc/fabric/impl/base/util/ActionResult.java modified: fabric-api-base/src/main/java/net/fabricmc/fabric/impl/base/util/TypedActionResult.java modified: fabric-content-registries-v1/src/main/java/net/fabricmc/fabric/api/content/registries/v1/BlockRegistry.java modified: fabric-content-registries-v1/src/main/java/net/fabricmc/fabric/api/content/registries/v1/ItemRegistry.java modified: fabric-content-registries-v1/src/main/java/net/fabricmc/fabric/impl/content/registries/ContentRegistryImpl.java modified: fabric-content-registries-v1/src/main/java/net/fabricmc/fabric/impl/content/registries/TestMod.java modified: fabric-content-registries-v1/src/main/java/net/fabricmc/fabric/mixin/content/registries/BlockAccessor.java modified: fabric-content-registries-v1/src/main/java/net/fabricmc/fabric/mixin/content/registries/ItemAccessor.java modified: fabric-content-registries-v1/src/main/java/net/fabricmc/fabric/mixin/content/registries/MutableRegistryAccessor.java modified: fabric-content-registries-v1/src/main/java/net/fabricmc/fabric/mixin/content/registries/SimpleRegistryAccessor.java modified: fabric-content-registries-v1/src/main/java/net/fabricmc/fabric/mixin/content/registries/WorldMixin.java modified: fabric-crash-report-info-v1/src/main/java/net/fabricmc/fabric/mixin/crash/report/info/MixinCrashReport.java modified: fabric-events-interaction-v0/src/main/java/net/fabricmc/fabric/impl/util/BlockHitResult.java modified: fabric-events-interaction-v0/src/main/java/net/fabricmc/fabric/impl/util/EntityHitResult.java modified: fabric-events-interaction-v0/src/main/java/net/fabricmc/fabric/mixin/event/interaction/MixinServerPlayerEntity.java modified: fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/client/ClientStartCallback.java modified: fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/client/ClientStopCallback.java modified: fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/client/LanServerPublishedCallback.java modified: fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/server/DedicatedServerSetupCallback.java modified: fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/world/ChunksSavedCallback.java modified: fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/world/EntityHurtCallback.java modified: fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/world/EntityKilledCallback.java modified: fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/world/ServerPlayerTickCallback.java modified: fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinDamageTracker.java new file: fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinDedicatedServer.java modified: fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinEntity.java modified: fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinIntegratedServer.java deleted: fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinMinecraftDedicatedServer.java modified: fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinServerPlayerEntity.java modified: fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinThreadedAnvilChunkStorage.java modified: fabric-events-lifecycle-v0/src/main/resources/fabric-events-lifecycle-v0.mixins.json modified: fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/mixin/resource/loader/MixinKeyedResourceReloadListener.java * Bumped version Changes to be committed: modified: build.gradle * Re-applyed the checkstyle plugin Changes to be committed: modified: build.gradle * Annotated method, fixed mixin and renamed parameter Changes to be committed: modified: fabric-content-registries-v1/src/main/java/net/fabricmc/fabric/mixin/content/registries/WorldMixin.java modified: fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinMinecraftClient.java * PlayerJoinCallback -> PlayerConnectCallback Changes to be committed: renamed: fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/server/PlayerJoinCallback.java -> fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/server/PlayerConnectCallback.java modified: fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinPlayerManager.java * Added RegistryBlockAddedEvent and RegistryItemAddedEvent to content registries Changes to be committed: modified: fabric-content-registries-v1/build.gradle modified: fabric-content-registries-v1/src/main/java/net/fabricmc/fabric/api/content/registries/v1/BlockRegistry.java modified: fabric-content-registries-v1/src/main/java/net/fabricmc/fabric/api/content/registries/v1/ItemRegistry.java new file: fabric-content-registries-v1/src/main/java/net/fabricmc/fabric/api/event/registries/v1/RegistryBlockAddedCallback.java new file: fabric-content-registries-v1/src/main/java/net/fabricmc/fabric/api/event/registries/v1/RegistryItemAddedCallback.java --- build.gradle | 6 +- .../net/fabricmc/fabric/api/util/NbtType.java | 7 +- .../fabric/impl/base/util/ActionResult.java | 16 ++++ .../impl/base/util/TypedActionResult.java | 18 +++- fabric-content-registries-v1/build.gradle | 6 +- .../content/registries/v1/BlockRegistry.java | 21 ++++- .../content/registries/v1/ItemRegistry.java | 19 +++++ .../v1/RegistryBlockAddedCallback.java | 19 +++++ .../v1/RegistryItemAddedCallback.java | 19 +++++ .../registries/ContentRegistryImpl.java | 20 ++++- .../impl/content/registries/TestMod.java | 23 +++++- .../content/registries/BlockAccessor.java | 16 ++++ .../content/registries/ItemAccessor.java | 16 ++++ .../registries/MutableRegistryAccessor.java | 16 ++++ .../registries/SimpleRegistryAccessor.java | 16 ++++ .../mixin/content/registries/WorldMixin.java | 77 +++++++++--------- .../crash/report/info/MixinCrashReport.java | 3 +- .../fabric/impl/util/BlockHitResult.java | 16 ++++ .../fabric/impl/util/EntityHitResult.java | 16 ++++ .../interaction/MixinServerPlayerEntity.java | 11 +-- fabric-events-lifecycle-v0/build.gradle | 6 ++ .../api/event/client/ClientStartCallback.java | 35 ++++++++ .../api/event/client/ClientStopCallback.java | 33 ++++++++ .../api/event/client/ClientTickCallback.java | 42 +++++----- .../api/event/client/ItemTooltipCallback.java | 27 ++---- .../client/LanServerPublishedCallback.java | 34 ++++++++ .../server/DedicatedServerSetupCallback.java | 35 ++++++++ .../event/server/PlayerConnectCallback.java | 34 ++++++++ .../api/event/server/ServerStartCallback.java | 4 +- .../api/event/server/ServerStopCallback.java | 3 +- .../api/event/server/ServerTickCallback.java | 11 ++- .../api/event/world/ChunksSavedCallback.java | 30 +++++++ .../api/event/world/EntityHurtCallback.java | 32 ++++++++ .../api/event/world/EntityKilledCallback.java | 31 +++++++ .../event/world/ServerPlayerTickCallback.java | 33 ++++++++ .../api/event/world/WorldTickCallback.java | 11 ++- .../event/lifecycle/MixinDamageTracker.java | 40 +++++++++ .../event/lifecycle/MixinDedicatedServer.java | 35 ++++++++ .../mixin/event/lifecycle/MixinEntity.java | 16 ++-- .../lifecycle/MixinIntegratedServer.java | 47 +++++++++++ .../mixin/event/lifecycle/MixinItem.java | 28 +++---- .../event/lifecycle/MixinMinecraftClient.java | 47 +++++++++++ .../event/lifecycle/MixinMinecraftServer.java | 18 ++-- .../event/lifecycle/MixinPlayerManager.java | 34 ++++++++ .../lifecycle/MixinServerPlayerEntity.java | 33 ++++++++ .../MixinThreadedAnvilChunkStorage.java | 34 ++++++++ .../mixin/event/lifecycle/MixinWorld.java | 11 +-- .../fabric-events-lifecycle-v0/icon.png | Bin .../fabric-events-lifecycle-v0.mixins.json | 11 ++- .../src/main/resources/fabric.mod.json | 0 .../MixinKeyedResourceReloadListener.java | 4 +- settings.gradle | 1 + .../fabric-events-lifecycle-v0/build.gradle | 6 -- 53 files changed, 957 insertions(+), 170 deletions(-) create mode 100644 fabric-content-registries-v1/src/main/java/net/fabricmc/fabric/api/event/registries/v1/RegistryBlockAddedCallback.java create mode 100644 fabric-content-registries-v1/src/main/java/net/fabricmc/fabric/api/event/registries/v1/RegistryItemAddedCallback.java create mode 100644 fabric-events-lifecycle-v0/build.gradle create mode 100644 fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/client/ClientStartCallback.java create mode 100644 fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/client/ClientStopCallback.java rename {unfinished/fabric-events-lifecycle-v0 => fabric-events-lifecycle-v0}/src/main/java/net/fabricmc/fabric/api/event/client/ClientTickCallback.java (63%) rename {unfinished/fabric-events-lifecycle-v0 => fabric-events-lifecycle-v0}/src/main/java/net/fabricmc/fabric/api/event/client/ItemTooltipCallback.java (61%) create mode 100644 fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/client/LanServerPublishedCallback.java create mode 100644 fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/server/DedicatedServerSetupCallback.java create mode 100644 fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/server/PlayerConnectCallback.java rename {unfinished/fabric-events-lifecycle-v0 => fabric-events-lifecycle-v0}/src/main/java/net/fabricmc/fabric/api/event/server/ServerStartCallback.java (100%) rename {unfinished/fabric-events-lifecycle-v0 => fabric-events-lifecycle-v0}/src/main/java/net/fabricmc/fabric/api/event/server/ServerStopCallback.java (99%) rename {unfinished/fabric-events-lifecycle-v0 => fabric-events-lifecycle-v0}/src/main/java/net/fabricmc/fabric/api/event/server/ServerTickCallback.java (87%) create mode 100644 fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/world/ChunksSavedCallback.java create mode 100644 fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/world/EntityHurtCallback.java create mode 100644 fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/world/EntityKilledCallback.java create mode 100644 fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/world/ServerPlayerTickCallback.java rename {unfinished/fabric-events-lifecycle-v0 => fabric-events-lifecycle-v0}/src/main/java/net/fabricmc/fabric/api/event/world/WorldTickCallback.java (87%) create mode 100644 fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinDamageTracker.java create mode 100644 fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinDedicatedServer.java rename unfinished/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinMinecraftClient.java => fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinEntity.java (72%) create mode 100644 fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinIntegratedServer.java rename unfinished/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinItemStack.java => fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinItem.java (69%) create mode 100644 fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinMinecraftClient.java rename {unfinished/fabric-events-lifecycle-v0 => fabric-events-lifecycle-v0}/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinMinecraftServer.java (86%) create mode 100644 fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinPlayerManager.java create mode 100644 fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinServerPlayerEntity.java create mode 100644 fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinThreadedAnvilChunkStorage.java rename {unfinished/fabric-events-lifecycle-v0 => fabric-events-lifecycle-v0}/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinWorld.java (84%) rename {unfinished/fabric-events-lifecycle-v0 => fabric-events-lifecycle-v0}/src/main/resources/assets/fabric-events-lifecycle-v0/icon.png (100%) rename {unfinished/fabric-events-lifecycle-v0 => fabric-events-lifecycle-v0}/src/main/resources/fabric-events-lifecycle-v0.mixins.json (53%) rename {unfinished/fabric-events-lifecycle-v0 => fabric-events-lifecycle-v0}/src/main/resources/fabric.mod.json (100%) delete mode 100644 unfinished/fabric-events-lifecycle-v0/build.gradle diff --git a/build.gradle b/build.gradle index 5c2e792c43..ea3de8ac28 100644 --- a/build.gradle +++ b/build.gradle @@ -3,7 +3,7 @@ plugins { id 'eclipse' id 'idea' id 'maven-publish' - id 'fabric-loom' version '0.2.7-SNAPSHOT' apply false + id 'fabric-loom' version '0.4-SNAPSHOT' apply false id 'net.minecrell.licenser' version '0.4.1' id "org.ajoberstar.grgit" version "3.1.1" id 'com.matthewprenger.cursegradle' version "1.4.0" @@ -15,9 +15,9 @@ plugins { def ENV = System.getenv() class Globals { - static def baseVersion = "0.1.1" + static def baseVersion = "0.1.2" static def mcVersion = "1.8.9" - static def yarnVersion = "+build.202005150113" + static def yarnVersion = "+build.202007090605" } version = Globals.baseVersion + "-" + getBranch() diff --git a/fabric-api-base/src/main/java/net/fabricmc/fabric/api/util/NbtType.java b/fabric-api-base/src/main/java/net/fabricmc/fabric/api/util/NbtType.java index 6cb8afce33..09fc8d0912 100644 --- a/fabric-api-base/src/main/java/net/fabricmc/fabric/api/util/NbtType.java +++ b/fabric-api-base/src/main/java/net/fabricmc/fabric/api/util/NbtType.java @@ -17,15 +17,14 @@ package net.fabricmc.fabric.api.util; import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.Tag; +import net.minecraft.nbt.NbtTag; /** * NBT type ID constants. Useful for filtering by value type in a few cases. * - *

For the current list of types, check with {@link Tag#TYPES}. + *

For the current list of types, check with {@link NbtTag#TYPES}. * - * @see CompoundTag#containsKey(String, int) - * @see Tag#idToString(int) + * @see CompoundTag#contains(String, int) */ public final class NbtType { public static final int END = 0; diff --git a/fabric-api-base/src/main/java/net/fabricmc/fabric/impl/base/util/ActionResult.java b/fabric-api-base/src/main/java/net/fabricmc/fabric/impl/base/util/ActionResult.java index 3191828b33..339a52a1ad 100644 --- a/fabric-api-base/src/main/java/net/fabricmc/fabric/impl/base/util/ActionResult.java +++ b/fabric-api-base/src/main/java/net/fabricmc/fabric/impl/base/util/ActionResult.java @@ -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.base.util; public enum ActionResult { diff --git a/fabric-api-base/src/main/java/net/fabricmc/fabric/impl/base/util/TypedActionResult.java b/fabric-api-base/src/main/java/net/fabricmc/fabric/impl/base/util/TypedActionResult.java index 0e3a9a1ce7..5587497244 100644 --- a/fabric-api-base/src/main/java/net/fabricmc/fabric/impl/base/util/TypedActionResult.java +++ b/fabric-api-base/src/main/java/net/fabricmc/fabric/impl/base/util/TypedActionResult.java @@ -1,6 +1,20 @@ -package net.fabricmc.fabric.impl.base.util; +/* + * 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. + */ -import net.minecraft.item.ItemStack; +package net.fabricmc.fabric.impl.base.util; public class TypedActionResult { private final ActionResult result; diff --git a/fabric-content-registries-v1/build.gradle b/fabric-content-registries-v1/build.gradle index 955d3ccf3f..6bfc586ce3 100644 --- a/fabric-content-registries-v1/build.gradle +++ b/fabric-content-registries-v1/build.gradle @@ -1,2 +1,6 @@ archivesBaseName = "fabric-content-registries" -version = getSubprojectVersion(project, "0.1.0") +version = getSubprojectVersion(project, "0.1.1") + +dependencies { + compile project(path: ':fabric-api-base', configuration: 'dev') +} \ No newline at end of file diff --git a/fabric-content-registries-v1/src/main/java/net/fabricmc/fabric/api/content/registries/v1/BlockRegistry.java b/fabric-content-registries-v1/src/main/java/net/fabricmc/fabric/api/content/registries/v1/BlockRegistry.java index 7e15a62550..1e399be3bf 100644 --- a/fabric-content-registries-v1/src/main/java/net/fabricmc/fabric/api/content/registries/v1/BlockRegistry.java +++ b/fabric-content-registries-v1/src/main/java/net/fabricmc/fabric/api/content/registries/v1/BlockRegistry.java @@ -1,16 +1,35 @@ +/* + * 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.api.content.registries.v1; import net.minecraft.block.Block; import net.minecraft.util.Identifier; +import net.fabricmc.fabric.api.event.registries.v1.RegistryBlockAddedCallback; import net.fabricmc.fabric.impl.content.registries.ContentRegistryImpl; public final class BlockRegistry { public static boolean blockIdsSetup = false; - private BlockRegistry() { } + private BlockRegistry() { + } public static Block register(Identifier id, Block block) { + RegistryBlockAddedCallback.EVENT.invoker().blockAdded(id,block); return ContentRegistryImpl.registerBlock(id, block); } } diff --git a/fabric-content-registries-v1/src/main/java/net/fabricmc/fabric/api/content/registries/v1/ItemRegistry.java b/fabric-content-registries-v1/src/main/java/net/fabricmc/fabric/api/content/registries/v1/ItemRegistry.java index 0818d7e4c4..353bd56f80 100644 --- a/fabric-content-registries-v1/src/main/java/net/fabricmc/fabric/api/content/registries/v1/ItemRegistry.java +++ b/fabric-content-registries-v1/src/main/java/net/fabricmc/fabric/api/content/registries/v1/ItemRegistry.java @@ -1,8 +1,25 @@ +/* + * 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.api.content.registries.v1; import net.minecraft.item.Item; import net.minecraft.util.Identifier; +import net.fabricmc.fabric.api.event.registries.v1.RegistryItemAddedCallback; import net.fabricmc.fabric.impl.content.registries.ContentRegistryImpl; public final class ItemRegistry { @@ -12,10 +29,12 @@ private ItemRegistry() { } public static Item register(Identifier id, Item item) { + RegistryItemAddedCallback.EVENT.invoker().itemAdded(id,item); return ContentRegistryImpl.registerItem(id, item); } public static Item registerBlockItem(Identifier id, Item item) { + RegistryItemAddedCallback.EVENT.invoker().itemAdded(id,item); return ContentRegistryImpl.registerItem(id, item); } } diff --git a/fabric-content-registries-v1/src/main/java/net/fabricmc/fabric/api/event/registries/v1/RegistryBlockAddedCallback.java b/fabric-content-registries-v1/src/main/java/net/fabricmc/fabric/api/event/registries/v1/RegistryBlockAddedCallback.java new file mode 100644 index 0000000000..e276346289 --- /dev/null +++ b/fabric-content-registries-v1/src/main/java/net/fabricmc/fabric/api/event/registries/v1/RegistryBlockAddedCallback.java @@ -0,0 +1,19 @@ +package net.fabricmc.fabric.api.event.registries.v1; + +import net.minecraft.block.Block; +import net.minecraft.util.Identifier; + +import net.fabricmc.fabric.api.event.Event; +import net.fabricmc.fabric.api.event.EventFactory; + +public interface RegistryBlockAddedCallback { + + Event EVENT = EventFactory.createArrayBacked(RegistryBlockAddedCallback.class, (listeners) -> (id, block) -> { + for (RegistryBlockAddedCallback callback : listeners) { + callback.blockAdded(id,block); + } + }); + + void blockAdded(Identifier id, Block block); + +} diff --git a/fabric-content-registries-v1/src/main/java/net/fabricmc/fabric/api/event/registries/v1/RegistryItemAddedCallback.java b/fabric-content-registries-v1/src/main/java/net/fabricmc/fabric/api/event/registries/v1/RegistryItemAddedCallback.java new file mode 100644 index 0000000000..607d8eb435 --- /dev/null +++ b/fabric-content-registries-v1/src/main/java/net/fabricmc/fabric/api/event/registries/v1/RegistryItemAddedCallback.java @@ -0,0 +1,19 @@ +package net.fabricmc.fabric.api.event.registries.v1; + +import net.minecraft.item.Item; +import net.minecraft.util.Identifier; + +import net.fabricmc.fabric.api.event.Event; +import net.fabricmc.fabric.api.event.EventFactory; + +public interface RegistryItemAddedCallback { + + Event EVENT = EventFactory.createArrayBacked(RegistryItemAddedCallback.class, (listeners) -> (id, item) -> { + for (RegistryItemAddedCallback callback : listeners) { + callback.itemAdded(id,item); + } + }); + + void itemAdded(Identifier id, Item item); + +} diff --git a/fabric-content-registries-v1/src/main/java/net/fabricmc/fabric/impl/content/registries/ContentRegistryImpl.java b/fabric-content-registries-v1/src/main/java/net/fabricmc/fabric/impl/content/registries/ContentRegistryImpl.java index bb1b611b2b..69b8b46a5f 100644 --- a/fabric-content-registries-v1/src/main/java/net/fabricmc/fabric/impl/content/registries/ContentRegistryImpl.java +++ b/fabric-content-registries-v1/src/main/java/net/fabricmc/fabric/impl/content/registries/ContentRegistryImpl.java @@ -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.content.registries; import java.util.HashMap; @@ -48,7 +64,7 @@ public static Block registerBlock(Identifier id, Block block) { unsortedBlocks.put(id, block); Block.REGISTRY.add(unorderedNextBlockId, id, block); - for (BlockState state : block.method_630().method_1228()) { + for (BlockState state : block.getStateManager().method_1228()) { Block.BLOCK_STATES.set(state, unorderedNextBlockId << 4 | block.getData(state)); } @@ -128,7 +144,7 @@ public static void reorderBlockEntries(BiMap idMap) { Block block = unsortedBlocks.get(entry.getValue()); Block.REGISTRY.add(entry.getKey(), entry.getValue(), block); - for (BlockState state : block.method_630().method_1228()) { + for (BlockState state : block.getStateManager().method_1228()) { states.set(state, unorderedNextBlockId << 4 | block.getData(state)); } } diff --git a/fabric-content-registries-v1/src/main/java/net/fabricmc/fabric/impl/content/registries/TestMod.java b/fabric-content-registries-v1/src/main/java/net/fabricmc/fabric/impl/content/registries/TestMod.java index f52537c096..9ef07c35ee 100644 --- a/fabric-content-registries-v1/src/main/java/net/fabricmc/fabric/impl/content/registries/TestMod.java +++ b/fabric-content-registries-v1/src/main/java/net/fabricmc/fabric/impl/content/registries/TestMod.java @@ -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.content.registries; import java.util.UUID; @@ -19,20 +35,23 @@ public class TestMod implements ModInitializer { @Override public void onInitialize() { - System.out.println("dadawdaw"); + if (!a) { Block block = new Block(Material.DIRT, MaterialColor.YELLOW).setTranslationKey("test:cool_item").setItemGroup(ItemGroup.FOOD); BlockRegistry.register(new Identifier(block.getTranslationKey()), block); Item item = new BlockItem(block).setItemGroup(ItemGroup.FOOD); ItemRegistry.registerBlockItem(new Identifier(block.getTranslationKey()), item); + for (int i = 0; i < 5; i++) { String s = UUID.randomUUID().toString(); ItemRegistry.register(new Identifier(s), new Item().setTranslationKey(s).setItemGroup(ItemGroup.FOOD)); } + ItemRegistry.register(new Identifier("dada"), new Item().setTranslationKey("dada").setItemGroup(ItemGroup.FOOD)); } + a = true; -// Item.REGISTRY.add(4096, new Identifier("dada"), new Item().setTranslationKey("a:a").setItemGroup(ItemGroup.FOOD)); + // Item.REGISTRY.add(4096, new Identifier("dada"), new Item().setTranslationKey("a:a").setItemGroup(ItemGroup.FOOD)); } } diff --git a/fabric-content-registries-v1/src/main/java/net/fabricmc/fabric/mixin/content/registries/BlockAccessor.java b/fabric-content-registries-v1/src/main/java/net/fabricmc/fabric/mixin/content/registries/BlockAccessor.java index 564df5544c..d835f47609 100644 --- a/fabric-content-registries-v1/src/main/java/net/fabricmc/fabric/mixin/content/registries/BlockAccessor.java +++ b/fabric-content-registries-v1/src/main/java/net/fabricmc/fabric/mixin/content/registries/BlockAccessor.java @@ -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.mixin.content.registries; import org.spongepowered.asm.mixin.Mixin; diff --git a/fabric-content-registries-v1/src/main/java/net/fabricmc/fabric/mixin/content/registries/ItemAccessor.java b/fabric-content-registries-v1/src/main/java/net/fabricmc/fabric/mixin/content/registries/ItemAccessor.java index fe5a1d6bed..6c1a9d3534 100644 --- a/fabric-content-registries-v1/src/main/java/net/fabricmc/fabric/mixin/content/registries/ItemAccessor.java +++ b/fabric-content-registries-v1/src/main/java/net/fabricmc/fabric/mixin/content/registries/ItemAccessor.java @@ -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.mixin.content.registries; import java.util.Map; diff --git a/fabric-content-registries-v1/src/main/java/net/fabricmc/fabric/mixin/content/registries/MutableRegistryAccessor.java b/fabric-content-registries-v1/src/main/java/net/fabricmc/fabric/mixin/content/registries/MutableRegistryAccessor.java index c72c58fc1f..d678e9cd8f 100644 --- a/fabric-content-registries-v1/src/main/java/net/fabricmc/fabric/mixin/content/registries/MutableRegistryAccessor.java +++ b/fabric-content-registries-v1/src/main/java/net/fabricmc/fabric/mixin/content/registries/MutableRegistryAccessor.java @@ -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.mixin.content.registries; import java.util.Map; diff --git a/fabric-content-registries-v1/src/main/java/net/fabricmc/fabric/mixin/content/registries/SimpleRegistryAccessor.java b/fabric-content-registries-v1/src/main/java/net/fabricmc/fabric/mixin/content/registries/SimpleRegistryAccessor.java index dd1ecbf78e..26f984d063 100644 --- a/fabric-content-registries-v1/src/main/java/net/fabricmc/fabric/mixin/content/registries/SimpleRegistryAccessor.java +++ b/fabric-content-registries-v1/src/main/java/net/fabricmc/fabric/mixin/content/registries/SimpleRegistryAccessor.java @@ -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.mixin.content.registries; import java.util.Map; diff --git a/fabric-content-registries-v1/src/main/java/net/fabricmc/fabric/mixin/content/registries/WorldMixin.java b/fabric-content-registries-v1/src/main/java/net/fabricmc/fabric/mixin/content/registries/WorldMixin.java index 99508bece0..0194a495ad 100644 --- a/fabric-content-registries-v1/src/main/java/net/fabricmc/fabric/mixin/content/registries/WorldMixin.java +++ b/fabric-content-registries-v1/src/main/java/net/fabricmc/fabric/mixin/content/registries/WorldMixin.java @@ -1,10 +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.mixin.content.registries; -import java.io.BufferedReader; -import java.io.File; -import java.io.FileOutputStream; -import java.io.FileReader; -import java.io.PrintWriter; +import java.io.*; import java.util.Map; import com.google.common.collect.BiMap; @@ -12,11 +24,12 @@ import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import net.minecraft.class_635; +import net.minecraft.world.SaveHandler; import net.minecraft.util.Identifier; import net.minecraft.util.profiler.Profiler; import net.minecraft.world.World; @@ -34,28 +47,14 @@ public class WorldMixin { public boolean isClient; @Inject(at = @At("RETURN"), method = "") - public void init(class_635 arg, LevelProperties levelProperties, Dimension dimension, Profiler profiler, boolean client, CallbackInfo ci) { + public void init(SaveHandler arg, LevelProperties levelProperties, Dimension dimension, Profiler profiler, boolean client, CallbackInfo ci) { if (!isClient) { try { if (!BlockRegistry.blockIdsSetup) { File blockIds = new File(arg.getDataFile("blocks").getAbsoluteFile().getAbsolutePath().replace(".dat", ".registry")); blockIds.getParentFile().mkdirs(); BiMap idMap = HashBiMap.create(); - - if (blockIds.exists()) { - FileReader fileReader = new FileReader(blockIds); - BufferedReader bufferedReader = new BufferedReader(fileReader); - String line; - - while ((line = bufferedReader.readLine()) != null) { - if (line.isEmpty()) continue; - int index = Integer.parseInt(line.substring(0, line.indexOf('\t'))); - String id = line.substring(line.indexOf('\t') + 1); - idMap.put(index, new Identifier(id)); - } - - fileReader.close(); - } + this.writeIdsToFile(idMap, blockIds); ContentRegistryImpl.fillBlocksMapWithUnknownEntries(idMap); PrintWriter writer = new PrintWriter(new FileOutputStream(blockIds, false)); @@ -72,21 +71,7 @@ public void init(class_635 arg, LevelProperties levelProperties, Dimension dimen File itemIds = new File(arg.getDataFile("items").getAbsoluteFile().getAbsolutePath().replace(".dat", ".registry")); itemIds.getParentFile().mkdirs(); BiMap idMap = HashBiMap.create(); - - if (itemIds.exists()) { - FileReader fileReader = new FileReader(itemIds); - BufferedReader bufferedReader = new BufferedReader(fileReader); - String line; - - while ((line = bufferedReader.readLine()) != null) { - if (line.isEmpty()) continue; - int index = Integer.parseInt(line.substring(0, line.indexOf('\t'))); - String id = line.substring(line.indexOf('\t') + 1); - idMap.put(index, new Identifier(id)); - } - - fileReader.close(); - } + this.writeIdsToFile(idMap, itemIds); ContentRegistryImpl.fillItemsMapWithUnknownEntries(idMap); PrintWriter writer = new PrintWriter(new FileOutputStream(itemIds, false)); @@ -103,4 +88,22 @@ public void init(class_635 arg, LevelProperties levelProperties, Dimension dimen } } } + + @Unique + private void writeIdsToFile(BiMap idMap, File file) throws IOException { + if (file.exists()) { + FileReader fileReader = new FileReader(file); + BufferedReader bufferedReader = new BufferedReader(fileReader); + String line; + + while ((line = bufferedReader.readLine()) != null) { + if (line.isEmpty()) continue; + int index = Integer.parseInt(line.substring(0, line.indexOf('\t'))); + String id = line.substring(line.indexOf('\t') + 1); + idMap.put(index, new Identifier(id)); + } + + fileReader.close(); + } + } } diff --git a/fabric-crash-report-info-v1/src/main/java/net/fabricmc/fabric/mixin/crash/report/info/MixinCrashReport.java b/fabric-crash-report-info-v1/src/main/java/net/fabricmc/fabric/mixin/crash/report/info/MixinCrashReport.java index 9ce0187561..b73ea4c2da 100644 --- a/fabric-crash-report-info-v1/src/main/java/net/fabricmc/fabric/mixin/crash/report/info/MixinCrashReport.java +++ b/fabric-crash-report-info-v1/src/main/java/net/fabricmc/fabric/mixin/crash/report/info/MixinCrashReport.java @@ -34,12 +34,11 @@ @Mixin(CrashReport.class) public abstract class MixinCrashReport { - @Shadow @Final private CrashReportSection systemDetailsSection; - public String getFabricMods(){ + public String getFabricMods() { Map mods = new TreeMap<>(); for (ModContainer container : FabricLoader.getInstance().getAllMods()) { diff --git a/fabric-events-interaction-v0/src/main/java/net/fabricmc/fabric/impl/util/BlockHitResult.java b/fabric-events-interaction-v0/src/main/java/net/fabricmc/fabric/impl/util/BlockHitResult.java index 9d10128688..a10dbfdf06 100644 --- a/fabric-events-interaction-v0/src/main/java/net/fabricmc/fabric/impl/util/BlockHitResult.java +++ b/fabric-events-interaction-v0/src/main/java/net/fabricmc/fabric/impl/util/BlockHitResult.java @@ -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.util; import net.minecraft.util.hit.HitResult; diff --git a/fabric-events-interaction-v0/src/main/java/net/fabricmc/fabric/impl/util/EntityHitResult.java b/fabric-events-interaction-v0/src/main/java/net/fabricmc/fabric/impl/util/EntityHitResult.java index d8cc268962..2e494554fd 100644 --- a/fabric-events-interaction-v0/src/main/java/net/fabricmc/fabric/impl/util/EntityHitResult.java +++ b/fabric-events-interaction-v0/src/main/java/net/fabricmc/fabric/impl/util/EntityHitResult.java @@ -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.util; import net.minecraft.entity.Entity; diff --git a/fabric-events-interaction-v0/src/main/java/net/fabricmc/fabric/mixin/event/interaction/MixinServerPlayerEntity.java b/fabric-events-interaction-v0/src/main/java/net/fabricmc/fabric/mixin/event/interaction/MixinServerPlayerEntity.java index 08c8e84c23..22fd526a3c 100644 --- a/fabric-events-interaction-v0/src/main/java/net/fabricmc/fabric/mixin/event/interaction/MixinServerPlayerEntity.java +++ b/fabric-events-interaction-v0/src/main/java/net/fabricmc/fabric/mixin/event/interaction/MixinServerPlayerEntity.java @@ -18,17 +18,8 @@ import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import net.fabricmc.fabric.impl.base.util.ActionResult; -import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.ServerPlayerEntity; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -import net.minecraft.entity.Entity; -import net.minecraft.server.network.ServerPlayerEntity; - -import net.fabricmc.fabric.api.event.player.AttackEntityCallback; @Mixin(ServerPlayerEntity.class) @Environment(EnvType.CLIENT) diff --git a/fabric-events-lifecycle-v0/build.gradle b/fabric-events-lifecycle-v0/build.gradle new file mode 100644 index 0000000000..cc2f000b18 --- /dev/null +++ b/fabric-events-lifecycle-v0/build.gradle @@ -0,0 +1,6 @@ +archivesBaseName = "fabric-resource-loader-v0" +version = getSubprojectVersion(project, "0.1.0") + +dependencies { + compile project(path: ':fabric-api-base', configuration: 'dev') +} diff --git a/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/client/ClientStartCallback.java b/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/client/ClientStartCallback.java new file mode 100644 index 0000000000..2763a18a00 --- /dev/null +++ b/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/client/ClientStartCallback.java @@ -0,0 +1,35 @@ +/* + * 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.api.event.client; + +import net.fabricmc.fabric.api.event.Event; +import net.fabricmc.fabric.api.event.EventFactory; +import net.minecraft.client.MinecraftClient; + +public interface ClientStartCallback { + + Event EVENT = EventFactory.createArrayBacked(ClientStartCallback.class, + (listeners) -> (client) -> { + for (ClientStartCallback event : listeners) { + event.onStartClient(client); + } + } + ); + + void onStartClient(MinecraftClient client); + +} diff --git a/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/client/ClientStopCallback.java b/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/client/ClientStopCallback.java new file mode 100644 index 0000000000..bb45cf6306 --- /dev/null +++ b/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/client/ClientStopCallback.java @@ -0,0 +1,33 @@ +/* + * 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.api.event.client; + +import net.fabricmc.fabric.api.event.Event; +import net.fabricmc.fabric.api.event.EventFactory; +import net.minecraft.client.MinecraftClient; + +public interface ClientStopCallback { + Event EVENT = EventFactory.createArrayBacked(ClientStopCallback.class, + (listeners) -> (client) -> { + for (ClientStopCallback event : listeners) { + event.onStopClient(client); + } + } + ); + + void onStopClient(MinecraftClient client); +} diff --git a/unfinished/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/client/ClientTickCallback.java b/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/client/ClientTickCallback.java similarity index 63% rename from unfinished/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/client/ClientTickCallback.java rename to fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/client/ClientTickCallback.java index 653ed4f33a..743815f772 100644 --- a/unfinished/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/client/ClientTickCallback.java +++ b/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/client/ClientTickCallback.java @@ -16,35 +16,33 @@ package net.fabricmc.fabric.api.event.client; -import net.minecraft.client.MinecraftClient; - import net.fabricmc.fabric.api.event.Event; import net.fabricmc.fabric.api.event.EventFactory; +import net.minecraft.client.MinecraftClient; public interface ClientTickCallback { - Event EVENT = EventFactory.createArrayBacked(ClientTickCallback.class, - (listeners) -> { - if (EventFactory.isProfilingEnabled()) { - return (client) -> { - client.getProfiler().push("fabricClientTick"); - for (ClientTickCallback event : listeners) { - client.getProfiler().push(EventFactory.getHandlerName(event)); - event.tick(client); - client.getProfiler().pop(); - } + Event EVENT = EventFactory.createArrayBacked(ClientTickCallback.class,(listeners)->{ + if(EventFactory.isProfilingEnabled()){ + return (client) -> { + client.profiler.push("fabricClientTick"); + + for (ClientTickCallback event : listeners) { + client.profiler.push(EventFactory.getHandlerName(event)); + event.tick(client); + client.profiler.pop(); + } - client.getProfiler().pop(); - }; - } else { - return (client) -> { - for (ClientTickCallback event : listeners) { - event.tick(client); - } - }; + client.profiler.pop(); + }; + } else{ + return (client) -> { + for (ClientTickCallback event : listeners) { + event.tick(client); } - } - ); + }; + } + }); void tick(MinecraftClient client); } diff --git a/unfinished/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/client/ItemTooltipCallback.java b/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/client/ItemTooltipCallback.java similarity index 61% rename from unfinished/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/client/ItemTooltipCallback.java rename to fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/client/ItemTooltipCallback.java index 7aab920554..e4ed17f7ee 100644 --- a/unfinished/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/client/ItemTooltipCallback.java +++ b/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/client/ItemTooltipCallback.java @@ -16,30 +16,21 @@ package net.fabricmc.fabric.api.event.client; -import java.util.List; - -import net.minecraft.client.item.TooltipContext; -import net.minecraft.item.ItemStack; -import net.minecraft.text.Text; - import net.fabricmc.fabric.api.event.Event; import net.fabricmc.fabric.api.event.EventFactory; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.ItemStack; + +import java.util.List; public interface ItemTooltipCallback { - /** - * Fired after the game has appended all base tooltip lines to the list. - */ - Event EVENT = EventFactory.createArrayBacked(ItemTooltipCallback.class, (listeners) -> (stack, tooltipContext, lines) -> { + + Event EVENT = EventFactory.createArrayBacked(ItemTooltipCallback.class, (listeners) -> (stack,player, lines) -> { for (ItemTooltipCallback callback : listeners) { - callback.getTooltip(stack, tooltipContext, lines); + callback.getTooltip(stack, player,lines); } }); - /** - * Called when an item stack's tooltip is rendered. Text added to {@code lines} will be - * rendered with the tooltip. - * - * @param lines the list containing the lines of text displayed on the stack's tooltip - */ - void getTooltip(ItemStack stack, TooltipContext tooltipContext, List lines); + void getTooltip(ItemStack stack, PlayerEntity player, List lines); + } diff --git a/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/client/LanServerPublishedCallback.java b/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/client/LanServerPublishedCallback.java new file mode 100644 index 0000000000..bd3ddb6d2d --- /dev/null +++ b/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/client/LanServerPublishedCallback.java @@ -0,0 +1,34 @@ +/* + * 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.api.event.client; + +import net.fabricmc.fabric.api.event.Event; +import net.fabricmc.fabric.api.event.EventFactory; +import net.minecraft.client.MinecraftClient; +import net.minecraft.world.level.LevelInfo; + +public interface LanServerPublishedCallback { + Event EVENT = EventFactory.createArrayBacked(LanServerPublishedCallback.class, + (listeners) -> (client,gameMode,cheats,levelinfo) -> { + for (LanServerPublishedCallback event : listeners) { + event.onServerPublished(client,gameMode,cheats,levelinfo); + } + } + ); + + void onServerPublished(MinecraftClient client,LevelInfo.GameMode gameMode, boolean cheats,LevelInfo levelInfo); +} diff --git a/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/server/DedicatedServerSetupCallback.java b/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/server/DedicatedServerSetupCallback.java new file mode 100644 index 0000000000..3bdb7554a3 --- /dev/null +++ b/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/server/DedicatedServerSetupCallback.java @@ -0,0 +1,35 @@ +/* + * 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.api.event.server; + +import net.fabricmc.fabric.api.event.Event; +import net.fabricmc.fabric.api.event.EventFactory; +import net.minecraft.server.dedicated.DedicatedServer; + +public interface DedicatedServerSetupCallback { + + Event EVENT = EventFactory.createArrayBacked(DedicatedServerSetupCallback.class, + (listeners) -> (server) -> { + for (DedicatedServerSetupCallback event : listeners) { + event.onServerSetup(server); + } + } + ); + + void onServerSetup(DedicatedServer server); + +} diff --git a/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/server/PlayerConnectCallback.java b/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/server/PlayerConnectCallback.java new file mode 100644 index 0000000000..cce448fa71 --- /dev/null +++ b/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/server/PlayerConnectCallback.java @@ -0,0 +1,34 @@ +/* + * 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.api.event.server; + +import net.fabricmc.fabric.api.event.Event; +import net.fabricmc.fabric.api.event.EventFactory; +import net.minecraft.entity.player.ServerPlayerEntity; +import net.minecraft.network.ClientConnection; + +public interface PlayerConnectCallback { + + Event EVENT = EventFactory.createArrayBacked(PlayerConnectCallback.class, (listeners) -> (conn, player) -> { + for (PlayerConnectCallback callback : listeners) { + callback.playerJoin(conn,player); + } + }); + + void playerJoin(ClientConnection connection, ServerPlayerEntity player); + +} diff --git a/unfinished/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/server/ServerStartCallback.java b/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/server/ServerStartCallback.java similarity index 100% rename from unfinished/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/server/ServerStartCallback.java rename to fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/server/ServerStartCallback.java index e314f93668..697fc2d6cd 100644 --- a/unfinished/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/server/ServerStartCallback.java +++ b/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/server/ServerStartCallback.java @@ -16,12 +16,12 @@ package net.fabricmc.fabric.api.event.server; -import net.minecraft.server.MinecraftServer; - import net.fabricmc.fabric.api.event.Event; import net.fabricmc.fabric.api.event.EventFactory; +import net.minecraft.server.MinecraftServer; public interface ServerStartCallback { + Event EVENT = EventFactory.createArrayBacked(ServerStartCallback.class, (listeners) -> (server) -> { for (ServerStartCallback event : listeners) { diff --git a/unfinished/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/server/ServerStopCallback.java b/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/server/ServerStopCallback.java similarity index 99% rename from unfinished/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/server/ServerStopCallback.java rename to fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/server/ServerStopCallback.java index d44b522a2b..0c0b2ff0e3 100644 --- a/unfinished/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/server/ServerStopCallback.java +++ b/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/server/ServerStopCallback.java @@ -16,10 +16,9 @@ package net.fabricmc.fabric.api.event.server; -import net.minecraft.server.MinecraftServer; - import net.fabricmc.fabric.api.event.Event; import net.fabricmc.fabric.api.event.EventFactory; +import net.minecraft.server.MinecraftServer; public interface ServerStopCallback { Event EVENT = EventFactory.createArrayBacked(ServerStopCallback.class, diff --git a/unfinished/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/server/ServerTickCallback.java b/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/server/ServerTickCallback.java similarity index 87% rename from unfinished/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/server/ServerTickCallback.java rename to fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/server/ServerTickCallback.java index 56a2bc7fb2..20557aab23 100644 --- a/unfinished/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/server/ServerTickCallback.java +++ b/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/server/ServerTickCallback.java @@ -16,25 +16,24 @@ package net.fabricmc.fabric.api.event.server; -import net.minecraft.server.MinecraftServer; - import net.fabricmc.fabric.api.event.Event; import net.fabricmc.fabric.api.event.EventFactory; +import net.minecraft.server.MinecraftServer; public interface ServerTickCallback { Event EVENT = EventFactory.createArrayBacked(ServerTickCallback.class, (listeners) -> { if (EventFactory.isProfilingEnabled()) { return (server) -> { - server.getProfiler().push("fabricServerTick"); + server.profiler.push("fabricServerTick"); for (ServerTickCallback event : listeners) { - server.getProfiler().push(EventFactory.getHandlerName(event)); + server.profiler.push(EventFactory.getHandlerName(event)); event.tick(server); - server.getProfiler().pop(); + server.profiler.pop(); } - server.getProfiler().pop(); + server.profiler.pop(); }; } else { return (server) -> { diff --git a/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/world/ChunksSavedCallback.java b/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/world/ChunksSavedCallback.java new file mode 100644 index 0000000000..2b973620f6 --- /dev/null +++ b/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/world/ChunksSavedCallback.java @@ -0,0 +1,30 @@ +/* + * 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.api.event.world; + +import net.fabricmc.fabric.api.event.Event; +import net.fabricmc.fabric.api.event.EventFactory; + +public interface ChunksSavedCallback { + Event EVENT = EventFactory.createArrayBacked(ChunksSavedCallback.class, (listeners) -> () -> { + for (ChunksSavedCallback callback : listeners) { + callback.chunksSaved(); + } + }); + + void chunksSaved(); +} diff --git a/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/world/EntityHurtCallback.java b/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/world/EntityHurtCallback.java new file mode 100644 index 0000000000..08a4989f95 --- /dev/null +++ b/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/world/EntityHurtCallback.java @@ -0,0 +1,32 @@ +/* + * 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.api.event.world; + +import net.fabricmc.fabric.api.event.Event; +import net.fabricmc.fabric.api.event.EventFactory; +import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.damage.DamageSource; + +public interface EntityHurtCallback { + Event EVENT = EventFactory.createArrayBacked(EntityHurtCallback.class, (listeners) -> (entity,source,original,damage) -> { + for (EntityHurtCallback callback : listeners) { + callback.chunksSaved(entity,source,original,damage); + } + }); + + void chunksSaved(LivingEntity entity, DamageSource damageSource, float originalHealth, float damage); +} diff --git a/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/world/EntityKilledCallback.java b/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/world/EntityKilledCallback.java new file mode 100644 index 0000000000..b7eae071ac --- /dev/null +++ b/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/world/EntityKilledCallback.java @@ -0,0 +1,31 @@ +/* + * 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.api.event.world; + +import net.fabricmc.fabric.api.event.Event; +import net.fabricmc.fabric.api.event.EventFactory; +import net.minecraft.entity.Entity; + +public interface EntityKilledCallback { + Event EVENT = EventFactory.createArrayBacked(EntityKilledCallback.class, (listeners) -> (entity) -> { + for (EntityKilledCallback callback : listeners) { + callback.entityKilled(entity); + } + }); + + void entityKilled(Entity killed); +} diff --git a/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/world/ServerPlayerTickCallback.java b/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/world/ServerPlayerTickCallback.java new file mode 100644 index 0000000000..7f48330994 --- /dev/null +++ b/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/world/ServerPlayerTickCallback.java @@ -0,0 +1,33 @@ +/* + * 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.api.event.world; + +import net.fabricmc.fabric.api.event.Event; +import net.fabricmc.fabric.api.event.EventFactory; +import net.minecraft.entity.player.PlayerEntity; + +public interface ServerPlayerTickCallback { + Event EVENT = EventFactory.createArrayBacked(ServerPlayerTickCallback.class, + (listeners) -> (player) -> { + for (ServerPlayerTickCallback event : listeners) { + event.tick(player); + } + } + ); + + void tick(PlayerEntity player); +} diff --git a/unfinished/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/world/WorldTickCallback.java b/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/world/WorldTickCallback.java similarity index 87% rename from unfinished/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/world/WorldTickCallback.java rename to fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/world/WorldTickCallback.java index 38cda986f7..3febae964d 100644 --- a/unfinished/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/world/WorldTickCallback.java +++ b/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/api/event/world/WorldTickCallback.java @@ -16,25 +16,24 @@ package net.fabricmc.fabric.api.event.world; -import net.minecraft.world.World; - import net.fabricmc.fabric.api.event.Event; import net.fabricmc.fabric.api.event.EventFactory; +import net.minecraft.world.World; public interface WorldTickCallback { Event EVENT = EventFactory.createArrayBacked(WorldTickCallback.class, (listeners) -> { if (EventFactory.isProfilingEnabled()) { return (world) -> { - world.getProfiler().push("fabricWorldTick"); + world.profiler.push("fabricWorldTick"); for (WorldTickCallback event : listeners) { - world.getProfiler().push(EventFactory.getHandlerName(event)); + world.profiler.push(EventFactory.getHandlerName(event)); event.tick(world); - world.getProfiler().pop(); + world.profiler.pop(); } - world.getProfiler().pop(); + world.profiler.pop(); }; } else { return (world) -> { diff --git a/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinDamageTracker.java b/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinDamageTracker.java new file mode 100644 index 0000000000..b11ed7baa8 --- /dev/null +++ b/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinDamageTracker.java @@ -0,0 +1,40 @@ +/* + * 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.mixin.event.lifecycle; + +import net.fabricmc.fabric.api.event.world.EntityHurtCallback; +import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.damage.DamageSource; +import net.minecraft.entity.damage.DamageTracker; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(DamageTracker.class) +public class MixinDamageTracker { + @Shadow + @Final + private LivingEntity entity; + + @Inject(at=@At("HEAD"),method="onDamage") + public void onDamage(DamageSource damageSource, float originalHealth, float damage, CallbackInfo info){ + EntityHurtCallback.EVENT.invoker().chunksSaved(this.entity,damageSource,originalHealth,damage); + } +} diff --git a/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinDedicatedServer.java b/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinDedicatedServer.java new file mode 100644 index 0000000000..ef7bf65f90 --- /dev/null +++ b/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinDedicatedServer.java @@ -0,0 +1,35 @@ +/* + * 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.mixin.event.lifecycle; + +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; +import net.fabricmc.fabric.api.event.server.DedicatedServerSetupCallback; +import net.minecraft.server.dedicated.DedicatedServer; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Environment(EnvType.SERVER) +@Mixin(DedicatedServer.class) +public class MixinDedicatedServer { + @Inject(at=@At("TAIL"),method="setupServer") + public void setupServer(CallbackInfoReturnable info){ + DedicatedServerSetupCallback.EVENT.invoker().onServerSetup((DedicatedServer) (Object)this); + } +} diff --git a/unfinished/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinMinecraftClient.java b/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinEntity.java similarity index 72% rename from unfinished/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinMinecraftClient.java rename to fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinEntity.java index a34368aea1..1bc65671d1 100644 --- a/unfinished/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinMinecraftClient.java +++ b/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinEntity.java @@ -16,19 +16,17 @@ package net.fabricmc.fabric.mixin.event.lifecycle; +import net.fabricmc.fabric.api.event.world.EntityKilledCallback; +import net.minecraft.entity.Entity; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import net.minecraft.client.MinecraftClient; - -import net.fabricmc.fabric.api.event.client.ClientTickCallback; - -@Mixin(MinecraftClient.class) -public class MixinMinecraftClient { - @Inject(at = @At("RETURN"), method = "tick") - public void tick(CallbackInfo info) { - ClientTickCallback.EVENT.invoker().tick((MinecraftClient) (Object) this); +@Mixin(Entity.class) +public class MixinEntity { + @Inject(at=@At("HEAD"),method="kill") + public void entityKilled(CallbackInfo info){ + EntityKilledCallback.EVENT.invoker().entityKilled((Entity)(Object)this); } } diff --git a/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinIntegratedServer.java b/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinIntegratedServer.java new file mode 100644 index 0000000000..7371324d7a --- /dev/null +++ b/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinIntegratedServer.java @@ -0,0 +1,47 @@ +/* + * 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.mixin.event.lifecycle; + +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; +import net.fabricmc.fabric.api.event.client.LanServerPublishedCallback; +import net.minecraft.client.MinecraftClient; +import net.minecraft.server.integrated.IntegratedServer; +import net.minecraft.world.level.LevelInfo; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Environment(EnvType.CLIENT) +@Mixin(IntegratedServer.class) +public class MixinIntegratedServer { + @Shadow + @Final + private MinecraftClient client; + + @Shadow + @Final + private LevelInfo levelInfo; + + @Inject(method="method_6437",at=@At("HEAD")) + public void publishToLan(LevelInfo.GameMode gameMode, boolean cheats, CallbackInfoReturnable info){ + LanServerPublishedCallback.EVENT.invoker().onServerPublished(this.client,gameMode,cheats,this.levelInfo); + } +} diff --git a/unfinished/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinItemStack.java b/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinItem.java similarity index 69% rename from unfinished/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinItemStack.java rename to fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinItem.java index c6f025066d..4e2ed7e8a5 100644 --- a/unfinished/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinItemStack.java +++ b/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinItem.java @@ -16,24 +16,24 @@ package net.fabricmc.fabric.mixin.event.lifecycle; -import java.util.List; - +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; +import net.fabricmc.fabric.api.event.client.ItemTooltipCallback; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import net.minecraft.client.item.TooltipContext; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.text.Text; - -import net.fabricmc.fabric.api.event.client.ItemTooltipCallback; +import java.util.List; -@Mixin(ItemStack.class) -public class MixinItemStack { - @Inject(method = "getTooltip", at = @At("RETURN")) - private void getTooltip(PlayerEntity entity, TooltipContext tooltipContext, CallbackInfoReturnable> info) { - ItemTooltipCallback.EVENT.invoker().getTooltip((ItemStack) (Object) this, tooltipContext, info.getReturnValue()); +@Environment(EnvType.CLIENT) +@Mixin(Item.class) +public class MixinItem { + @Inject(method = "method_8265", at = @At("RETURN")) + private void getTooltip(ItemStack itemStack, PlayerEntity playerEntity, List list, boolean bl, CallbackInfo info) { + ItemTooltipCallback.EVENT.invoker().getTooltip(new ItemStack((Item)(Object)this), playerEntity, list); } } diff --git a/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinMinecraftClient.java b/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinMinecraftClient.java new file mode 100644 index 0000000000..60a7aa45af --- /dev/null +++ b/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinMinecraftClient.java @@ -0,0 +1,47 @@ +/* + * 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.mixin.event.lifecycle; + +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; +import net.fabricmc.fabric.api.event.client.ClientStartCallback; +import net.fabricmc.fabric.api.event.client.ClientStopCallback; +import net.fabricmc.fabric.api.event.client.ClientTickCallback; +import net.minecraft.client.MinecraftClient; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Environment(EnvType.CLIENT) +@Mixin(MinecraftClient.class) +public class MixinMinecraftClient { + @Inject(at = @At("RETURN"), method = "tick") + public void tick(CallbackInfo info) { + ClientTickCallback.EVENT.invoker().tick((MinecraftClient) (Object) this); + } + + @Inject(at = @At("HEAD"),method = "scheduleStop") + public void stop(CallbackInfo info){ + ClientStopCallback.EVENT.invoker().onStopClient((MinecraftClient) (Object) this); + } + + @Inject(at = @At("HEAD"),method = "run") + public void start(CallbackInfo info){ + ClientStartCallback.EVENT.invoker().onStartClient((MinecraftClient) (Object) this); + } +} diff --git a/unfinished/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinMinecraftServer.java b/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinMinecraftServer.java similarity index 86% rename from unfinished/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinMinecraftServer.java rename to fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinMinecraftServer.java index b531bf3b13..13234bc1ec 100644 --- a/unfinished/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinMinecraftServer.java +++ b/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinMinecraftServer.java @@ -16,22 +16,18 @@ package net.fabricmc.fabric.mixin.event.lifecycle; -import java.util.function.BooleanSupplier; - +import net.fabricmc.fabric.api.event.server.ServerStartCallback; +import net.fabricmc.fabric.api.event.server.ServerStopCallback; +import net.fabricmc.fabric.api.event.server.ServerTickCallback; +import net.minecraft.server.MinecraftServer; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import net.minecraft.server.MinecraftServer; - -import net.fabricmc.fabric.api.event.server.ServerStartCallback; -import net.fabricmc.fabric.api.event.server.ServerStopCallback; -import net.fabricmc.fabric.api.event.server.ServerTickCallback; - @Mixin(MinecraftServer.class) public class MixinMinecraftServer { - @Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/server/MinecraftServer;setFavicon(Lnet/minecraft/server/ServerMetadata;)V", ordinal = 0), method = "run") + @Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/server/MinecraftServer;setServerMeta(Lnet/minecraft/server/ServerMetadata;)V", ordinal = 0), method = "run") public void afterSetupServer(CallbackInfo info) { ServerStartCallback.EVENT.invoker().onStartServer((MinecraftServer) (Object) this); } @@ -41,8 +37,8 @@ public void beforeShutdownServer(CallbackInfo info) { ServerStopCallback.EVENT.invoker().onStopServer((MinecraftServer) (Object) this); } - @Inject(at = @At("RETURN"), method = "tick") - protected void tick(BooleanSupplier var1, CallbackInfo info) { + @Inject(at = @At(value = "INVOKE",target = "Ljava/lang/Thread;sleep(J)V"), method = "run") + protected void tick(CallbackInfo info) { ServerTickCallback.EVENT.invoker().tick((MinecraftServer) (Object) this); } } diff --git a/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinPlayerManager.java b/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinPlayerManager.java new file mode 100644 index 0000000000..48828b388b --- /dev/null +++ b/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinPlayerManager.java @@ -0,0 +1,34 @@ +/* + * 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.mixin.event.lifecycle; + +import net.fabricmc.fabric.api.event.server.PlayerConnectCallback; +import net.minecraft.entity.player.ServerPlayerEntity; +import net.minecraft.network.ClientConnection; +import net.minecraft.server.PlayerManager; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(PlayerManager.class) +public class MixinPlayerManager { + @Inject(at=@At("HEAD"),method = "onPlayerConnect") + public void onPlayerConnect(ClientConnection connection, ServerPlayerEntity player, CallbackInfo info){ + PlayerConnectCallback.EVENT.invoker().playerJoin(connection,player); + } +} diff --git a/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinServerPlayerEntity.java b/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinServerPlayerEntity.java new file mode 100644 index 0000000000..6f4d5f9b65 --- /dev/null +++ b/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinServerPlayerEntity.java @@ -0,0 +1,33 @@ +/* + * 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.mixin.event.lifecycle; + +import net.fabricmc.fabric.api.event.world.ServerPlayerTickCallback; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.ServerPlayerEntity; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(ServerPlayerEntity.class) +public class MixinServerPlayerEntity { + @Inject(at=@At("TAIL"),method = "tick") + public void tick(CallbackInfo ci){ + ServerPlayerTickCallback.EVENT.invoker().tick((PlayerEntity)(Object)this); + } +} diff --git a/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinThreadedAnvilChunkStorage.java b/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinThreadedAnvilChunkStorage.java new file mode 100644 index 0000000000..ca690de059 --- /dev/null +++ b/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinThreadedAnvilChunkStorage.java @@ -0,0 +1,34 @@ +/* + * 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.mixin.event.lifecycle; + +import net.fabricmc.fabric.api.event.world.ChunksSavedCallback; +import net.minecraft.world.chunk.ThreadedAnvilChunkStorage; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(ThreadedAnvilChunkStorage.class) +public class MixinThreadedAnvilChunkStorage { + + @Inject(at=@At(value = "INVOKE",target = "Lorg/apache/logging/log4j/Logger;info(Ljava/lang/String;[Ljava/lang/Object;)V"),method = "shouldRenderOverlay") + public void shouldRenderOverlay(CallbackInfoReturnable info){ + ChunksSavedCallback.EVENT.invoker().chunksSaved(); + } + +} diff --git a/unfinished/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinWorld.java b/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinWorld.java similarity index 84% rename from unfinished/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinWorld.java rename to fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinWorld.java index 9b797509bc..d69adb1dc9 100644 --- a/unfinished/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinWorld.java +++ b/fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MixinWorld.java @@ -16,20 +16,17 @@ package net.fabricmc.fabric.mixin.event.lifecycle; +import net.fabricmc.fabric.api.event.world.WorldTickCallback; +import net.minecraft.world.World; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import net.minecraft.world.World; - -import net.fabricmc.fabric.api.event.world.WorldTickCallback; - @Mixin(World.class) public class MixinWorld { - // TODO split into ClientWorld/ServerWorld ticks? mmm need more mappings - @Inject(at = @At("RETURN"), method = "tickBlockEntities") + @Inject(at = @At("HEAD"), method = "tick") public void tickBlockEntitiesAfter(CallbackInfo info) { - WorldTickCallback.EVENT.invoker().tick((World) (Object) this); + WorldTickCallback.EVENT.invoker().tick((World)(Object)this); } } diff --git a/unfinished/fabric-events-lifecycle-v0/src/main/resources/assets/fabric-events-lifecycle-v0/icon.png b/fabric-events-lifecycle-v0/src/main/resources/assets/fabric-events-lifecycle-v0/icon.png similarity index 100% rename from unfinished/fabric-events-lifecycle-v0/src/main/resources/assets/fabric-events-lifecycle-v0/icon.png rename to fabric-events-lifecycle-v0/src/main/resources/assets/fabric-events-lifecycle-v0/icon.png diff --git a/unfinished/fabric-events-lifecycle-v0/src/main/resources/fabric-events-lifecycle-v0.mixins.json b/fabric-events-lifecycle-v0/src/main/resources/fabric-events-lifecycle-v0.mixins.json similarity index 53% rename from unfinished/fabric-events-lifecycle-v0/src/main/resources/fabric-events-lifecycle-v0.mixins.json rename to fabric-events-lifecycle-v0/src/main/resources/fabric-events-lifecycle-v0.mixins.json index 738bbd9a1d..ecea9032b4 100644 --- a/unfinished/fabric-events-lifecycle-v0/src/main/resources/fabric-events-lifecycle-v0.mixins.json +++ b/fabric-events-lifecycle-v0/src/main/resources/fabric-events-lifecycle-v0.mixins.json @@ -3,13 +3,22 @@ "package": "net.fabricmc.fabric.mixin.event.lifecycle", "compatibilityLevel": "JAVA_8", "mixins": [ + "MixinDamageTracker", + "MixinEntity", "MixinMinecraftServer", + "MixinServerPlayerEntity", + "MixinPlayerManager", + "MixinThreadedAnvilChunkStorage", "MixinWorld" ], "client": [ - "MixinItemStack", + "MixinIntegratedServer", + "MixinItem", "MixinMinecraftClient" ], + "server": [ + "MixinDedicatedServer" + ], "injectors": { "defaultRequire": 1 } diff --git a/unfinished/fabric-events-lifecycle-v0/src/main/resources/fabric.mod.json b/fabric-events-lifecycle-v0/src/main/resources/fabric.mod.json similarity index 100% rename from unfinished/fabric-events-lifecycle-v0/src/main/resources/fabric.mod.json rename to fabric-events-lifecycle-v0/src/main/resources/fabric.mod.json diff --git a/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/mixin/resource/loader/MixinKeyedResourceReloadListener.java b/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/mixin/resource/loader/MixinKeyedResourceReloadListener.java index 0bb8c1a21d..266fa37167 100644 --- a/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/mixin/resource/loader/MixinKeyedResourceReloadListener.java +++ b/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/mixin/resource/loader/MixinKeyedResourceReloadListener.java @@ -25,10 +25,10 @@ import net.minecraft.class_1254; import net.minecraft.class_1255; import net.minecraft.client.font.TextRenderer; -import net.minecraft.client.render.GameRenderer; import net.minecraft.client.render.WorldRenderer; import net.minecraft.client.render.block.BlockRenderManager; import net.minecraft.client.render.item.ItemRenderer; +import net.minecraft.client.render.EntityRenderer; import net.minecraft.client.render.model.BakedModelManager; import net.minecraft.client.resource.language.LanguageManager; import net.minecraft.client.sound.SoundManager; @@ -39,7 +39,7 @@ public class MixinKeyedResourceReloadListener { @Mixin({ - SoundManager.class, GameRenderer.class, LanguageManager.class, class_1255.class, class_1254.class, TextureManager.class, + SoundManager.class, EntityRenderer.class, LanguageManager.class, class_1255.class, class_1254.class, TextureManager.class, WorldRenderer.class, BlockRenderManager.class, ItemRenderer.class, BakedModelManager.class, TextRenderer.class }) public abstract static class Client implements IdentifiableResourceReloadListener { diff --git a/settings.gradle b/settings.gradle index 8b7d34aa83..e31f557960 100644 --- a/settings.gradle +++ b/settings.gradle @@ -17,3 +17,4 @@ include 'fabric-content-registries-v1' include 'fabric-crash-report-info-v1' include 'fabric-resource-loader-v0' include 'fabric-events-interaction-v0' +include 'fabric-events-lifecycle-v0' diff --git a/unfinished/fabric-events-lifecycle-v0/build.gradle b/unfinished/fabric-events-lifecycle-v0/build.gradle deleted file mode 100644 index 21bb53d87d..0000000000 --- a/unfinished/fabric-events-lifecycle-v0/build.gradle +++ /dev/null @@ -1,6 +0,0 @@ -archivesBaseName = "fabric-events-lifecycle-v0" -version = getSubprojectVersion(project, "0.1.2") - -dependencies { - compile project(path: ':fabric-api-base', configuration: 'dev') -}