diff --git a/common/src/main/java/dev/architectury/core/fluid/SimpleArchitecturyFluidAttributes.java b/common/src/main/java/dev/architectury/core/fluid/SimpleArchitecturyFluidAttributes.java index cd85638e..e99f991f 100644 --- a/common/src/main/java/dev/architectury/core/fluid/SimpleArchitecturyFluidAttributes.java +++ b/common/src/main/java/dev/architectury/core/fluid/SimpleArchitecturyFluidAttributes.java @@ -21,11 +21,9 @@ package dev.architectury.core.fluid; import com.google.common.base.Suppliers; import dev.architectury.fluid.FluidStack; -import dev.architectury.registry.registries.Registries; import dev.architectury.registry.registries.RegistrySupplier; import net.minecraft.Util; import net.minecraft.core.BlockPos; -import net.minecraft.core.Registry; import net.minecraft.resources.ResourceLocation; import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvents; @@ -66,7 +64,7 @@ public class SimpleArchitecturyFluidAttributes implements ArchitecturyFluidAttri private SoundEvent fillSound = SoundEvents.BUCKET_FILL; @Nullable private SoundEvent emptySound = SoundEvents.BUCKET_EMPTY; - private final Supplier defaultTranslationKey = Suppliers.memoize(() -> Util.makeDescriptionId("fluid", Registries.getId(getSourceFluid(), Registry.FLUID_REGISTRY))); + private final Supplier defaultTranslationKey = Suppliers.memoize(() -> Util.makeDescriptionId("fluid", getSourceFluid().arch$registryName())); public static SimpleArchitecturyFluidAttributes ofSupplier(Supplier> flowingFluid, Supplier> sourceFluid) { return of(() -> flowingFluid.get().get(), () -> sourceFluid.get().get()); diff --git a/common/src/main/java/dev/architectury/core/item/ArchitecturySpawnEggItem.java b/common/src/main/java/dev/architectury/core/item/ArchitecturySpawnEggItem.java index 0b300b20..2a763ae8 100644 --- a/common/src/main/java/dev/architectury/core/item/ArchitecturySpawnEggItem.java +++ b/common/src/main/java/dev/architectury/core/item/ArchitecturySpawnEggItem.java @@ -19,11 +19,9 @@ package dev.architectury.core.item; -import dev.architectury.registry.registries.Registries; import dev.architectury.registry.registries.RegistrySupplier; import net.minecraft.core.BlockSource; import net.minecraft.core.Direction; -import net.minecraft.core.Registry; import net.minecraft.core.dispenser.DefaultDispenseItemBehavior; import net.minecraft.core.dispenser.DispenseItemBehavior; import net.minecraft.nbt.CompoundTag; @@ -76,8 +74,8 @@ public class ArchitecturySpawnEggItem extends SpawnEggItem { this.entityType = Objects.requireNonNull(entityType, "entityType"); SpawnEggItem.BY_ID.remove(null); entityType.listen(type -> { - LOGGER.debug("Registering spawn egg {} for {}", Objects.toString(Registries.getId(this, Registry.ITEM_REGISTRY)), - Objects.toString(Registries.getId(type, Registry.ENTITY_TYPE_REGISTRY))); + LOGGER.debug("Registering spawn egg {} for {}", Objects.toString(this.arch$registryName()), + Objects.toString(type.arch$registryName())); SpawnEggItem.BY_ID.put(type, this); this.defaultType = type; diff --git a/common/src/main/java/dev/architectury/extensions/injected/InjectedBlockExtension.java b/common/src/main/java/dev/architectury/extensions/injected/InjectedBlockExtension.java new file mode 100644 index 00000000..70259962 --- /dev/null +++ b/common/src/main/java/dev/architectury/extensions/injected/InjectedBlockExtension.java @@ -0,0 +1,32 @@ +/* + * This file is part of architectury. + * Copyright (C) 2020, 2021, 2022 architectury + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +package dev.architectury.extensions.injected; + +import dev.architectury.registry.registries.Registries; +import net.minecraft.core.Holder; +import net.minecraft.core.Registry; +import net.minecraft.world.level.block.Block; + +public interface InjectedBlockExtension extends InjectedRegistryEntryExtension { + @Override + default Holder arch$holder() { + return ((Block) this).builtInRegistryHolder(); + } +} diff --git a/common/src/main/java/dev/architectury/extensions/injected/InjectedBucketItemExtension.java b/common/src/main/java/dev/architectury/extensions/injected/InjectedBucketItemExtension.java new file mode 100644 index 00000000..52656234 --- /dev/null +++ b/common/src/main/java/dev/architectury/extensions/injected/InjectedBucketItemExtension.java @@ -0,0 +1,11 @@ +package dev.architectury.extensions.injected; + +import dev.architectury.hooks.fluid.FluidBucketHooks; +import net.minecraft.world.item.BucketItem; +import net.minecraft.world.level.material.Fluid; + +public interface InjectedBucketItemExtension { + default Fluid arch$getFluid() { + return FluidBucketHooks.getFluid((BucketItem) this); + } +} diff --git a/common/src/main/java/dev/architectury/extensions/injected/InjectedEntityTypeExtension.java b/common/src/main/java/dev/architectury/extensions/injected/InjectedEntityTypeExtension.java new file mode 100644 index 00000000..0e33e148 --- /dev/null +++ b/common/src/main/java/dev/architectury/extensions/injected/InjectedEntityTypeExtension.java @@ -0,0 +1,32 @@ +/* + * This file is part of architectury. + * Copyright (C) 2020, 2021, 2022 architectury + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +package dev.architectury.extensions.injected; + +import dev.architectury.registry.registries.Registries; +import net.minecraft.core.Holder; +import net.minecraft.core.Registry; +import net.minecraft.world.entity.EntityType; + +public interface InjectedEntityTypeExtension extends InjectedRegistryEntryExtension> { + @Override + default Holder> arch$holder() { + return ((EntityType) this).builtInRegistryHolder(); + } +} diff --git a/common/src/main/java/dev/architectury/extensions/injected/InjectedFluidExtension.java b/common/src/main/java/dev/architectury/extensions/injected/InjectedFluidExtension.java new file mode 100644 index 00000000..15bb9b81 --- /dev/null +++ b/common/src/main/java/dev/architectury/extensions/injected/InjectedFluidExtension.java @@ -0,0 +1,32 @@ +/* + * This file is part of architectury. + * Copyright (C) 2020, 2021, 2022 architectury + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +package dev.architectury.extensions.injected; + +import dev.architectury.registry.registries.Registries; +import net.minecraft.core.Holder; +import net.minecraft.core.Registry; +import net.minecraft.world.level.material.Fluid; + +public interface InjectedFluidExtension extends InjectedRegistryEntryExtension { + @Override + default Holder arch$holder() { + return ((Fluid) this).builtInRegistryHolder(); + } +} diff --git a/common/src/main/java/dev/architectury/extensions/injected/InjectedFoodPropertiesBuilderExtension.java b/common/src/main/java/dev/architectury/extensions/injected/InjectedFoodPropertiesBuilderExtension.java new file mode 100644 index 00000000..9a2d6cd0 --- /dev/null +++ b/common/src/main/java/dev/architectury/extensions/injected/InjectedFoodPropertiesBuilderExtension.java @@ -0,0 +1,33 @@ +/* + * This file is part of architectury. + * Copyright (C) 2020, 2021, 2022 architectury + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +package dev.architectury.extensions.injected; + +import dev.architectury.hooks.item.food.FoodPropertiesHooks; +import net.minecraft.world.effect.MobEffectInstance; +import net.minecraft.world.food.FoodProperties; + +import java.util.function.Supplier; + +public interface InjectedFoodPropertiesBuilderExtension { + default FoodProperties.Builder arch$effect(Supplier effectSupplier, float chance) { + FoodPropertiesHooks.effect((FoodProperties.Builder) this, effectSupplier, chance); + return (FoodProperties.Builder) this; + } +} diff --git a/common/src/main/java/dev/architectury/extensions/injected/InjectedGameEventExtension.java b/common/src/main/java/dev/architectury/extensions/injected/InjectedGameEventExtension.java new file mode 100644 index 00000000..89c50986 --- /dev/null +++ b/common/src/main/java/dev/architectury/extensions/injected/InjectedGameEventExtension.java @@ -0,0 +1,30 @@ +/* + * This file is part of architectury. + * Copyright (C) 2020, 2021, 2022 architectury + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +package dev.architectury.extensions.injected; + +import net.minecraft.core.Holder; +import net.minecraft.world.level.gameevent.GameEvent; + +public interface InjectedGameEventExtension extends InjectedRegistryEntryExtension { + @Override + default Holder arch$holder() { + return ((GameEvent) this).builtInRegistryHolder(); + } +} diff --git a/common/src/main/java/dev/architectury/extensions/injected/InjectedItemExtension.java b/common/src/main/java/dev/architectury/extensions/injected/InjectedItemExtension.java new file mode 100644 index 00000000..b74637b1 --- /dev/null +++ b/common/src/main/java/dev/architectury/extensions/injected/InjectedItemExtension.java @@ -0,0 +1,32 @@ +/* + * This file is part of architectury. + * Copyright (C) 2020, 2021, 2022 architectury + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +package dev.architectury.extensions.injected; + +import dev.architectury.registry.registries.Registries; +import net.minecraft.core.Holder; +import net.minecraft.core.Registry; +import net.minecraft.world.item.Item; + +public interface InjectedItemExtension extends InjectedRegistryEntryExtension { + @Override + default Holder arch$holder() { + return ((Item) this).builtInRegistryHolder(); + } +} diff --git a/common/src/main/java/dev/architectury/extensions/injected/InjectedRegistryEntryExtension.java b/common/src/main/java/dev/architectury/extensions/injected/InjectedRegistryEntryExtension.java new file mode 100644 index 00000000..0a2d201d --- /dev/null +++ b/common/src/main/java/dev/architectury/extensions/injected/InjectedRegistryEntryExtension.java @@ -0,0 +1,34 @@ +/* + * This file is part of architectury. + * Copyright (C) 2020, 2021, 2022 architectury + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +package dev.architectury.extensions.injected; + +import net.minecraft.core.Holder; +import net.minecraft.resources.ResourceKey; +import net.minecraft.resources.ResourceLocation; +import org.jetbrains.annotations.Nullable; + +public interface InjectedRegistryEntryExtension { + Holder arch$holder(); + + @Nullable + default ResourceLocation arch$registryName() { + return arch$holder().unwrapKey().map(ResourceKey::location).orElse(null); + } +} diff --git a/common/src/main/java/dev/architectury/mixin/inject/MixinBlock.java b/common/src/main/java/dev/architectury/mixin/inject/MixinBlock.java new file mode 100644 index 00000000..341a292f --- /dev/null +++ b/common/src/main/java/dev/architectury/mixin/inject/MixinBlock.java @@ -0,0 +1,9 @@ +package dev.architectury.mixin.inject; + +import dev.architectury.extensions.injected.InjectedBlockExtension; +import net.minecraft.world.level.block.Block; +import org.spongepowered.asm.mixin.Mixin; + +@Mixin(Block.class) +public class MixinBlock implements InjectedBlockExtension { +} diff --git a/common/src/main/java/dev/architectury/mixin/inject/MixinBlockEntityType.java b/common/src/main/java/dev/architectury/mixin/inject/MixinBlockEntityType.java new file mode 100644 index 00000000..f944b980 --- /dev/null +++ b/common/src/main/java/dev/architectury/mixin/inject/MixinBlockEntityType.java @@ -0,0 +1,9 @@ +package dev.architectury.mixin.inject; + +import dev.architectury.extensions.injected.InjectedGameEventExtension; +import net.minecraft.world.level.block.entity.BlockEntityType; +import org.spongepowered.asm.mixin.Mixin; + +@Mixin(BlockEntityType.class) +public class MixinBlockEntityType implements InjectedGameEventExtension { +} diff --git a/common/src/main/java/dev/architectury/mixin/inject/MixinBucketItem.java b/common/src/main/java/dev/architectury/mixin/inject/MixinBucketItem.java new file mode 100644 index 00000000..fba02eea --- /dev/null +++ b/common/src/main/java/dev/architectury/mixin/inject/MixinBucketItem.java @@ -0,0 +1,9 @@ +package dev.architectury.mixin.inject; + +import dev.architectury.extensions.injected.InjectedBucketItemExtension; +import net.minecraft.world.item.BucketItem; +import org.spongepowered.asm.mixin.Mixin; + +@Mixin(BucketItem.class) +public class MixinBucketItem implements InjectedBucketItemExtension { +} diff --git a/common/src/main/java/dev/architectury/mixin/inject/MixinEntityType.java b/common/src/main/java/dev/architectury/mixin/inject/MixinEntityType.java new file mode 100644 index 00000000..b4536433 --- /dev/null +++ b/common/src/main/java/dev/architectury/mixin/inject/MixinEntityType.java @@ -0,0 +1,9 @@ +package dev.architectury.mixin.inject; + +import dev.architectury.extensions.injected.InjectedEntityTypeExtension; +import net.minecraft.world.entity.EntityType; +import org.spongepowered.asm.mixin.Mixin; + +@Mixin(EntityType.class) +public class MixinEntityType implements InjectedEntityTypeExtension { +} diff --git a/common/src/main/java/dev/architectury/mixin/inject/MixinFluid.java b/common/src/main/java/dev/architectury/mixin/inject/MixinFluid.java new file mode 100644 index 00000000..4782fb3a --- /dev/null +++ b/common/src/main/java/dev/architectury/mixin/inject/MixinFluid.java @@ -0,0 +1,9 @@ +package dev.architectury.mixin.inject; + +import dev.architectury.extensions.injected.InjectedFluidExtension; +import net.minecraft.world.level.material.Fluid; +import org.spongepowered.asm.mixin.Mixin; + +@Mixin(Fluid.class) +public class MixinFluid implements InjectedFluidExtension { +} diff --git a/common/src/main/java/dev/architectury/mixin/inject/MixinItem.java b/common/src/main/java/dev/architectury/mixin/inject/MixinItem.java new file mode 100644 index 00000000..1ef8b53a --- /dev/null +++ b/common/src/main/java/dev/architectury/mixin/inject/MixinItem.java @@ -0,0 +1,9 @@ +package dev.architectury.mixin.inject; + +import dev.architectury.extensions.injected.InjectedItemExtension; +import net.minecraft.world.item.Item; +import org.spongepowered.asm.mixin.Mixin; + +@Mixin(Item.class) +public class MixinItem implements InjectedItemExtension { +} diff --git a/common/src/main/resources/architectury-common.mixins.json b/common/src/main/resources/architectury-common.mixins.json index 989561ab..a301ee3a 100644 --- a/common/src/main/resources/architectury-common.mixins.json +++ b/common/src/main/resources/architectury-common.mixins.json @@ -6,6 +6,12 @@ "client": [ ], "mixins": [ + "inject.MixinBlock", + "inject.MixinBlockEntityType", + "inject.MixinBucketItem", + "inject.MixinEntityType", + "inject.MixinFluid", + "inject.MixinItem", "MixinLightningBolt" ], "injectors": { diff --git a/common/src/main/resources/architectury.common.json b/common/src/main/resources/architectury.common.json index 30ff27f0..1d89a440 100644 --- a/common/src/main/resources/architectury.common.json +++ b/common/src/main/resources/architectury.common.json @@ -1,3 +1,26 @@ { - "accessWidener": "architectury.accessWidener" + "accessWidener": "architectury.accessWidener", + "injected_interfaces": { + "net/minecraft/class_1792": [ + "dev/architectury/extensions/injected/InjectedItemExtension" + ], + "net/minecraft/class_2248": [ + "dev/architectury/extensions/injected/InjectedBlockExtension" + ], + "net/minecraft/class_3611": [ + "dev/architectury/extensions/injected/InjectedFluidExtension" + ], + "net/minecraft/class_1299": [ + "dev/architectury/extensions/injected/InjectedEntityTypeExtension" + ], + "net/minecraft/class_2591": [ + "dev/architectury/extensions/injected/InjectedBlockEntityTypeExtension" + ], + "net/minecraft/class_1755": [ + "dev/architectury/extensions/injected/InjectedBucketItemExtension" + ], + "net/minecraft/class_4174$class_4175": [ + "dev/architectury/extensions/injected/InjectedFoodPropertiesBuilderExtension" + ] + } } \ No newline at end of file diff --git a/fabric/src/main/java/dev/architectury/hooks/item/tool/fabric/HoeItemHooksImpl.java b/fabric/src/main/java/dev/architectury/hooks/item/tool/fabric/HoeItemHooksImpl.java index b1562249..2263be17 100644 --- a/fabric/src/main/java/dev/architectury/hooks/item/tool/fabric/HoeItemHooksImpl.java +++ b/fabric/src/main/java/dev/architectury/hooks/item/tool/fabric/HoeItemHooksImpl.java @@ -1,3 +1,22 @@ +/* + * This file is part of architectury. + * Copyright (C) 2020, 2021, 2022 architectury + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + package dev.architectury.hooks.item.tool.fabric; import com.google.common.collect.ImmutableMap; diff --git a/forge/src/main/java/dev/architectury/hooks/item/tool/forge/HoeItemHooksImpl.java b/forge/src/main/java/dev/architectury/hooks/item/tool/forge/HoeItemHooksImpl.java index 7b25ca60..07329baf 100644 --- a/forge/src/main/java/dev/architectury/hooks/item/tool/forge/HoeItemHooksImpl.java +++ b/forge/src/main/java/dev/architectury/hooks/item/tool/forge/HoeItemHooksImpl.java @@ -1,3 +1,22 @@ +/* + * This file is part of architectury. + * Copyright (C) 2020, 2021, 2022 architectury + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + package dev.architectury.hooks.item.tool.forge; import net.minecraft.world.item.context.UseOnContext;