Skip to content

Commit

Permalink
update to 1.19.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Minecraftschurli authored and williewillus committed Jan 26, 2023
1 parent 5bdecc0 commit 65cf54b
Show file tree
Hide file tree
Showing 63 changed files with 241 additions and 300 deletions.
8 changes: 4 additions & 4 deletions Fabric/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ dependencies {

minecraft "com.mojang:minecraft:${minecraft_version}"
mappings loom.officialMojangMappings()
modImplementation "net.fabricmc:fabric-loader:0.14.9"
modImplementation "net.fabricmc:fabric-loader:0.14.11"

modImplementation "net.fabricmc.fabric-api:fabric-api:0.60.0+1.19.2"
modImplementation "net.fabricmc.fabric-api:fabric-api:0.68.1+1.19.3"
compileOnly project(":Xplat")

modCompileOnly "mezz.jei:jei-1.19.2-common-api:11.2.0.247"

modCompileOnly("me.shedaniel:RoughlyEnoughItems-api-fabric:9.1.528") { transitive = false }
modCompileOnly("me.shedaniel.cloth:cloth-config-fabric:7.0.73") { transitive = false }
modCompileOnly("me.shedaniel:RoughlyEnoughItems-api-fabric:10.0.578") { transitive = false }
modCompileOnly("me.shedaniel.cloth:cloth-config-fabric:9.0.94") { transitive = false }
}

compileJava {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import net.minecraft.server.packs.PackType;
import net.minecraft.server.packs.resources.ResourceManager;
import net.minecraft.util.profiling.ProfilerFiller;

import vazkii.patchouli.api.PatchouliAPI;
import vazkii.patchouli.client.base.BookModel;
import vazkii.patchouli.client.base.ClientTicker;
Expand All @@ -33,7 +32,6 @@
import vazkii.patchouli.fabric.network.FabricMessageOpenBookGui;
import vazkii.patchouli.fabric.network.FabricMessageReloadBookContents;

import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;

Expand Down Expand Up @@ -92,11 +90,11 @@ public void onResourceManagerReload(ResourceManager manager) {
});
}

public static void replaceBookModel(ModelBakery loader, Map<ResourceLocation, BakedModel> bakedRegistry) {
ModelResourceLocation key = new ModelResourceLocation(PatchouliItems.BOOK_ID, "inventory");
BakedModel oldModel = bakedRegistry.get(key);
if (oldModel != null) {
bakedRegistry.put(key, new BookModel(oldModel, loader));
public static BakedModel replaceBookModel(BakedModel oldModel, ModelBakery bakery, ResourceLocation key) {
ModelResourceLocation location = new ModelResourceLocation(PatchouliItems.BOOK_ID, "inventory");
if (oldModel != null && location.equals(key)) {
return new BookModel(oldModel, bakery);
}
return oldModel;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,25 @@
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
import net.fabricmc.fabric.api.event.player.UseBlockCallback;
import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents;
import net.minecraft.core.Registry;

import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.CreativeModeTabs;
import vazkii.patchouli.common.base.PatchouliSounds;
import vazkii.patchouli.common.book.BookRegistry;
import vazkii.patchouli.common.command.OpenBookCommand;
import vazkii.patchouli.common.handler.LecternEventHandler;
import vazkii.patchouli.common.handler.ReloadContentsHandler;
import vazkii.patchouli.common.item.ItemModBook;
import vazkii.patchouli.common.item.PatchouliItems;

public class FabricModInitializer implements ModInitializer {
@Override
public void onInitialize() {
PatchouliSounds.submitRegistrations((id, e) -> Registry.register(Registry.SOUND_EVENT, id, e));
PatchouliItems.submitItemRegistrations((id, e) -> Registry.register(Registry.ITEM, id, e));
PatchouliItems.submitRecipeSerializerRegistrations((id, e) -> Registry.register(Registry.RECIPE_SERIALIZER, id, e));
PatchouliSounds.submitRegistrations((id, e) -> Registry.register(BuiltInRegistries.SOUND_EVENT, id, e));
PatchouliItems.submitItemRegistrations((id, e) -> Registry.register(BuiltInRegistries.ITEM, id, e));
PatchouliItems.submitRecipeSerializerRegistrations((id, e) -> Registry.register(BuiltInRegistries.RECIPE_SERIALIZER, id, e));
FiberPatchouliConfig.setup();
CommandRegistrationCallback.EVENT.register((disp, buildCtx, selection) -> OpenBookCommand.register(disp));
UseBlockCallback.EVENT.register(LecternEventHandler::rightClick);
Expand All @@ -30,5 +34,16 @@ public void onInitialize() {
ReloadContentsHandler.dataReloaded(server);
}
});

BookRegistry.INSTANCE.books.values().forEach(b -> {
if (!b.noBook && !b.isExtension) {
ItemGroupEvents.modifyEntriesEvent(ResourceLocation.tryParse(b.creativeTab)).register(entries -> {
entries.accept(ItemModBook.forBook(b));
});
ItemGroupEvents.modifyEntriesEvent(CreativeModeTabs.searchTab()).register(entries -> {
entries.accept(ItemModBook.forBook(b));
});
}
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package vazkii.patchouli.mixin.client;

import net.minecraft.client.resources.model.BakedModel;
import net.minecraft.client.resources.model.ModelBakery;
import net.minecraft.resources.ResourceLocation;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyArg;
import vazkii.patchouli.fabric.client.FabricClientInitializer;

@Mixin(targets = "net.minecraft.client.resources.model.ModelBakery.ModelBakerImpl")
public class MixinModelBakery {

@ModifyArg(method = "bake(Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/client/resources/model/ModelState;)Lnet/minecraft/client/resources/model/BakedModel;", at = @At(value = "RETURN"))
public BakedModel insertBookModel(BakedModel model, ResourceLocation id, ModelBakery bakery) {
return FabricClientInitializer.replaceBookModel(model, bakery, id);
}
}

This file was deleted.

2 changes: 1 addition & 1 deletion Fabric/src/main/resources/patchouli_fabric.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"client": [
"client.MixinGameRenderer",
"client.MixinMinecraft",
"client.MixinModelManager",
"client.MixinModelBakery",
"client.MixinScreen"
],
"injectors": {
Expand Down
4 changes: 2 additions & 2 deletions Forge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,12 @@ minecraft {
}

dependencies {
minecraft "net.minecraftforge:forge:${minecraft_version}-43.0.11"
minecraft "net.minecraftforge:forge:${minecraft_version}-44.0.36"
implementation project(":Xplat")
annotationProcessor 'org.spongepowered:mixin:0.8.5:processor'

compileOnly fg.deobf("mezz.jei:jei-1.19.2-common-api:11.2.0.247")
runtimeOnly(fg.deobf("mezz.jei:jei-1.19.2-forge:11.2.0.247"))
//runtimeOnly(fg.deobf("mezz.jei:jei-1.19.2-forge:11.2.0.247"))
}

compileJava {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,8 @@ public static void onInitializeClient(FMLClientSetupEvent evt) {
}

@SubscribeEvent
public static void replaceBookModel(ModelEvent.BakingCompleted evt) {
public static void replaceBookModel(ModelEvent.ModifyBakingResult evt) {
ModelResourceLocation key = new ModelResourceLocation(PatchouliItems.BOOK_ID, "inventory");
BakedModel oldModel = evt.getModels().get(key);
if (oldModel != null) {
evt.getModels().put(key, new BookModel(oldModel, evt.getModelBakery()));
}
evt.getModels().computeIfPresent(key, (k, oldModel) -> new BookModel(oldModel, evt.getModelBakery()));
}
}
Original file line number Diff line number Diff line change
@@ -1,24 +1,30 @@
package vazkii.patchouli.forge.common;

import net.minecraft.core.Registry;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.CreativeModeTabs;
import net.minecraftforge.common.CreativeModeTabRegistry;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.CreativeModeTabEvent;
import net.minecraftforge.event.RegisterCommandsEvent;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.event.server.ServerStartedEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.registries.RegisterEvent;

import vazkii.patchouli.api.PatchouliAPI;
import vazkii.patchouli.common.base.PatchouliSounds;
import vazkii.patchouli.common.book.BookRegistry;
import vazkii.patchouli.common.command.OpenBookCommand;
import vazkii.patchouli.common.handler.LecternEventHandler;
import vazkii.patchouli.common.handler.ReloadContentsHandler;
import vazkii.patchouli.common.item.ItemModBook;
import vazkii.patchouli.common.item.PatchouliItems;
import vazkii.patchouli.forge.network.ForgeNetworkHandler;

import java.util.Objects;

@Mod.EventBusSubscriber(modid = PatchouliAPI.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
@Mod(PatchouliAPI.MOD_ID)
public class ForgeModInitializer {
Expand All @@ -28,17 +34,27 @@ public ForgeModInitializer() {

@SubscribeEvent
public static void register(RegisterEvent evt) {
evt.register(Registry.SOUND_EVENT_REGISTRY, rh -> {
evt.register(Registries.SOUND_EVENT, rh -> {
PatchouliSounds.submitRegistrations(rh::register);
});
evt.register(Registry.ITEM_REGISTRY, rh -> {
evt.register(Registries.ITEM, rh -> {
PatchouliItems.submitItemRegistrations(rh::register);
});
evt.register(Registry.RECIPE_SERIALIZER_REGISTRY, rh -> {
evt.register(Registries.RECIPE_SERIALIZER, rh -> {
PatchouliItems.submitRecipeSerializerRegistrations(rh::register);
});
}

@SubscribeEvent
public static void processCreativeTabs(CreativeModeTabEvent.BuildContents evt) {
ResourceLocation name = CreativeModeTabRegistry.getName(evt.getTab());
BookRegistry.INSTANCE.books.values().forEach(b -> {
if (!b.noBook && !b.isExtension && (evt.getTab() == CreativeModeTabs.searchTab() || Objects.equals(ResourceLocation.tryParse(b.creativeTab), name))) {
evt.accept(ItemModBook.forBook(b));
}
});
}

@SubscribeEvent
public static void onInitialize(FMLCommonSetupEvent evt) {
MinecraftForge.EVENT_BUS.addListener((RegisterCommandsEvent e) -> OpenBookCommand.register(e.getDispatcher()));
Expand Down
35 changes: 27 additions & 8 deletions Xplat/src/main/java/vazkii/patchouli/client/base/BookModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,21 @@
import net.minecraft.client.renderer.block.model.ItemOverrides;
import net.minecraft.client.renderer.block.model.ItemTransforms;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.resources.model.BakedModel;
import net.minecraft.client.resources.model.ModelBakery;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.client.resources.model.*;
import net.minecraft.core.Direction;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.RandomSource;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.state.BlockState;

import vazkii.patchouli.common.book.Book;
import vazkii.patchouli.common.item.ItemModBook;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import vazkii.patchouli.common.book.Book;
import vazkii.patchouli.common.item.ItemModBook;

import java.util.Collections;
import java.util.List;
import java.util.function.Function;

public class BookModel implements BakedModel {
private final BakedModel original;
Expand All @@ -33,7 +31,28 @@ public BookModel(BakedModel original, ModelBakery loader) {
this.original = original;
BlockModel missing = (BlockModel) loader.getModel(ModelBakery.MISSING_MODEL_LOCATION);

this.itemHandler = new ItemOverrides(loader, missing, id -> missing, Collections.emptyList()) {
this.itemHandler = new ItemOverrides(new ModelBaker() {
// soft implement IForgeModelBaker
public Function<Material, TextureAtlasSprite> getModelTextureGetter() {
return null;
}

// soft implement IForgeModelBaker
public BakedModel bake(ResourceLocation location, ModelState state, Function<Material, TextureAtlasSprite> sprites) {
return null;
}

@Override
public UnbakedModel getModel(ResourceLocation resourceLocation) {
return null;
}

@Nullable
@Override
public BakedModel bake(ResourceLocation resourceLocation, ModelState modelState) {
return null;
}
}, missing, Collections.emptyList()) {
@Override
public BakedModel resolve(@NotNull BakedModel original, @NotNull ItemStack stack,
@Nullable ClientLevel world, @Nullable LivingEntity entity, int seed) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@

import com.google.gson.JsonObject;
import com.mojang.blaze3d.vertex.PoseStack;

import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Font;
import net.minecraft.client.gui.components.Button;
import net.minecraft.client.resources.language.I18n;
import net.minecraft.network.chat.Component;

import vazkii.patchouli.client.base.ClientAdvancements;
import vazkii.patchouli.client.book.gui.GuiBookEntry;
import vazkii.patchouli.common.base.PatchouliConfig;
Expand Down Expand Up @@ -57,8 +55,8 @@ public void onHidden(GuiBookEntry parent) {
}

protected void addButton(Button button) {
button.x += (parent.bookLeft + left);
button.y += (parent.bookTop + top);
button.setX(button.getX() + (parent.bookLeft + left));
button.setY(button.getY() + (parent.bookTop + top));
buttons.add(button);
parent.addRenderableWidget(button);
}
Expand Down
Loading

0 comments on commit 65cf54b

Please sign in to comment.