Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.20 #115

Merged
merged 7 commits into from
Aug 7, 2024
Merged

1.20 #115

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
# AkashicTome
The book of books.

This mod requires [AutoRegLib](https://github.com/Vazkii/AutoRegLib).
The book of books.
34 changes: 12 additions & 22 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,21 +1,12 @@
buildscript {
repositories {
maven { url = 'https://maven.minecraftforge.net' }
maven { url = 'https://repo.spongepowered.org/maven' }
jcenter()
mavenCentral()
}
dependencies {
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true
}
}
plugins {
id 'eclipse'
id 'maven-publish'
id 'pmd'
id 'com.diffplug.spotless' version '5.12.5'
id 'net.minecraftforge.gradle' version '5.1.+'
id 'org.parchmentmc.librarian.forgegradle' version '1.+'
id 'org.spongepowered.mixin' version '0.7.+'
}
apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'eclipse'
apply plugin: 'maven-publish'
apply plugin: 'pmd'

ext.configFile = file('build.properties')
ext.config = parseConfig(configFile)
Expand Down Expand Up @@ -55,7 +46,7 @@ minecraft {
property 'forge.logging.console.level', 'debug'

mods {
examplemod {
akashictome {
source sourceSets.main
}
}
Expand All @@ -71,7 +62,7 @@ minecraft {
property 'forge.logging.console.level', 'debug'

mods {
examplemod {
akashictome {
source sourceSets.main
}
}
Expand All @@ -81,16 +72,15 @@ minecraft {

repositories {
maven {
// for AutoRegLib
name "blamejared"
url "https://maven.blamejared.com/"
url "https://cursemaven.com"
}
}

dependencies {
minecraft "net.minecraftforge:forge:${config.mc_version}-${config.forge_version}"

implementation fg.deobf("vazkii.autoreglib:AutoRegLib:${config.arl_version}")
implementation fg.deobf("curse.maven:curios-309927:5367944")
implementation fg.deobf("curse.maven:patchouli-306770:4966125")
implementation fg.deobf("curse.maven:botania-225643:5594997")
}

spotless {
Expand Down
11 changes: 5 additions & 6 deletions build.properties
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
#Mon Aug 05 18:32:28 UTC 2024
mapping_channel=official
forge_version=43.1.52
mapping_channel=parchment
forge_version=47.2.0
mod_id=akashictome
dir_repo=./
build_number=27
arl_version=1.8.2-56.125
dir_output=../Build Output/AkashicTome/
mapping_version=1.19.2
version=1.6
mapping_version=2023.09.03-1.20.1
version=1.7
mod_name=AkashicTome
mc_version=1.19.2
mc_version=1.20.1
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip
10 changes: 10 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
pluginManagement {
repositories {
gradlePluginPortal()
jcenter()
mavenCentral()
maven { url = 'https://maven.minecraftforge.net/' }
maven { url = 'https://maven.parchmentmc.org' }
maven { url = "https://repo.spongepowered.org/repository/maven-public/" }
}
}
29 changes: 13 additions & 16 deletions src/main/java/vazkii/akashictome/AkashicTome.java
Original file line number Diff line number Diff line change
@@ -1,48 +1,45 @@
package vazkii.akashictome;

import net.minecraft.world.item.CreativeModeTabs;
import net.minecraftforge.event.BuildCreativeModeTabContentsEvent;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.DistExecutor;
import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.config.ModConfig;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.network.NetworkDirection;

import vazkii.akashictome.network.MessageMorphTome;
import vazkii.akashictome.network.MessageUnmorphTome;
import vazkii.akashictome.network.NetworkHandler;
import vazkii.akashictome.proxy.ClientProxy;
import vazkii.akashictome.proxy.CommonProxy;
import vazkii.arl.network.IMessage;
import vazkii.arl.network.NetworkHandler;

@Mod(AkashicTome.MOD_ID)
public class AkashicTome {

public static final String MOD_ID = "akashictome";
public static NetworkHandler NETWORKHANDLER;
public static CommonProxy proxy;

public AkashicTome() {
IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus();
bus.addListener(this::commonSetup);
bus.register(ModItems.class);

Registries.ITEMS.register(bus);
Registries.SERIALIZERS.register(bus);

bus.addListener(this::addToCreativeTab);
ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, ConfigHandler.CONFIG_SPEC);

proxy = DistExecutor.runForDist(() -> ClientProxy::new, () -> CommonProxy::new);
proxy = DistExecutor.safeRunForDist(() -> ClientProxy::new, () -> CommonProxy::new);
proxy.preInit();

NETWORKHANDLER = new NetworkHandler(MOD_ID, 1);
}

public void commonSetup(FMLCommonSetupEvent event) {
NETWORKHANDLER.register(MessageMorphTome.class, NetworkDirection.PLAY_TO_SERVER);
NETWORKHANDLER.register(MessageUnmorphTome.class, NetworkDirection.PLAY_TO_SERVER);
NetworkHandler.register();
}

public static void sendToServer(IMessage msg) {
NETWORKHANDLER.sendToServer(msg);
private void addToCreativeTab(BuildCreativeModeTabContentsEvent event) {
if (event.getTabKey() == CreativeModeTabs.TOOLS_AND_UTILITIES) {
event.accept(Registries.TOME);
}
}

}
20 changes: 10 additions & 10 deletions src/main/java/vazkii/akashictome/AttachementRecipe.java
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
package vazkii.akashictome;

import net.minecraft.core.NonNullList;
import net.minecraft.core.RegistryAccess;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.inventory.CraftingContainer;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.CraftingBookCategory;
import net.minecraft.world.item.crafting.CustomRecipe;
import net.minecraft.world.item.crafting.RecipeSerializer;
import net.minecraft.world.level.Level;
import net.minecraftforge.registries.ForgeRegistries;

import vazkii.arl.util.ItemNBTHelper;

public class AttachementRecipe extends CustomRecipe {

public AttachementRecipe(ResourceLocation idIn) {
super(idIn);
public AttachementRecipe(ResourceLocation idIn, CraftingBookCategory pCategory) {
super(idIn, pCategory);
}

@Override
Expand All @@ -30,7 +30,7 @@ public boolean matches(CraftingContainer var1, Level var2) {
if (foundTarget)
return false;
foundTarget = true;
} else if (stack.getItem() == ModItems.tome) {
} else if (stack.is(Registries.TOME.get())) {
if (foundTool)
return false;
foundTool = true;
Expand All @@ -43,14 +43,14 @@ public boolean matches(CraftingContainer var1, Level var2) {
}

@Override
public ItemStack assemble(CraftingContainer var1) {
public ItemStack assemble(CraftingContainer var1, RegistryAccess pRegistryAccess) {
ItemStack tool = ItemStack.EMPTY;
ItemStack target = ItemStack.EMPTY;

for (int i = 0; i < var1.getContainerSize(); i++) {
ItemStack stack = var1.getItem(i);
if (!stack.isEmpty()) {
if (stack.getItem() == ModItems.tome)
if (stack.is(Registries.TOME.get()))
tool = stack;
else
target = stack;
Expand Down Expand Up @@ -80,7 +80,7 @@ public ItemStack assemble(CraftingContainer var1) {

CompoundTag modCmp = new CompoundTag();
if (tries > 0)
ItemNBTHelper.setString(target, MorphingHandler.TAG_ITEM_DEFINED_MOD, mod);
NBTUtils.setString(target, MorphingHandler.TAG_ITEM_DEFINED_MOD, mod);

target.save(modCmp);
morphData.put(mod, modCmp);
Expand Down Expand Up @@ -125,7 +125,7 @@ public boolean isTarget(ItemStack stack) {
}

@Override
public ItemStack getResultItem() {
public ItemStack getResultItem(RegistryAccess pRegistryAccess) {
return ItemStack.EMPTY;
}

Expand All @@ -136,7 +136,7 @@ public NonNullList<ItemStack> getRemainingItems(CraftingContainer inv) {

@Override
public RecipeSerializer<?> getSerializer() {
return ModItems.ATTACHMENT;
return Registries.ATTACHMENT.get();
}

}
28 changes: 0 additions & 28 deletions src/main/java/vazkii/akashictome/ModItems.java

This file was deleted.

25 changes: 13 additions & 12 deletions src/main/java/vazkii/akashictome/MorphingHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import net.minecraftforge.registries.ForgeRegistries;

import vazkii.akashictome.network.MessageUnmorphTome;
import vazkii.arl.util.ItemNBTHelper;
import vazkii.akashictome.network.NetworkHandler;

import java.util.HashMap;
import java.util.Locale;
Expand All @@ -36,8 +36,8 @@ public final class MorphingHandler {
@SubscribeEvent
public void onPlayerLeftClick(PlayerInteractEvent.LeftClickEmpty event) {
ItemStack stack = event.getItemStack();
if (!stack.isEmpty() && isAkashicTome(stack) && stack.getItem() != ModItems.tome) {
AkashicTome.sendToServer(new MessageUnmorphTome());
if (!stack.isEmpty() && isAkashicTome(stack) && !stack.is(Registries.TOME.get())) {
NetworkHandler.sendToServer(new MessageUnmorphTome());
}
}

Expand All @@ -48,9 +48,9 @@ public void onItemDropped(ItemTossEvent event) {

ItemEntity e = event.getEntity();
ItemStack stack = e.getItem();
if (!stack.isEmpty() && isAkashicTome(stack) && stack.getItem() != ModItems.tome) {
if (!stack.isEmpty() && isAkashicTome(stack) && !stack.is(Registries.TOME.get())) {
CompoundTag morphData = stack.getTag().getCompound(TAG_TOME_DATA).copy();
String currentMod = ItemNBTHelper.getString(stack, TAG_ITEM_DEFINED_MOD, getModFromStack(stack));
String currentMod = NBTUtils.getString(stack, TAG_ITEM_DEFINED_MOD, getModFromStack(stack));

ItemStack morph = makeMorphedStack(stack, MINECRAFT, morphData);
CompoundTag newMorphData = morph.getTag().getCompound(TAG_TOME_DATA);
Expand Down Expand Up @@ -98,7 +98,7 @@ public static String getModOrAlias(String mod) {
return aliases.getOrDefault(mod, mod);
}

public static boolean doesStackHaveModAttached(ItemStack stack, String mod) {
public static boolean doesStackHaveModAttached(ItemStack stack, String mod) { //TODO what was this used for?
if (!stack.hasTag())
return false;

Expand All @@ -111,7 +111,7 @@ public static ItemStack getShiftStackForMod(ItemStack stack, String mod) {
return stack;

String currentMod = getModFromStack(stack);
String defined = ItemNBTHelper.getString(stack, TAG_ITEM_DEFINED_MOD, "");
String defined = NBTUtils.getString(stack, TAG_ITEM_DEFINED_MOD, "");
if (!defined.isEmpty())
currentMod = defined;

Expand All @@ -124,7 +124,7 @@ public static ItemStack getShiftStackForMod(ItemStack stack, String mod) {

public static ItemStack makeMorphedStack(ItemStack currentStack, String targetMod, CompoundTag morphData) {
String currentMod = getModFromStack(currentStack);
String defined = ItemNBTHelper.getString(currentStack, TAG_ITEM_DEFINED_MOD, "");
String defined = NBTUtils.getString(currentStack, TAG_ITEM_DEFINED_MOD, "");
if (!defined.isEmpty())
currentMod = defined;

Expand All @@ -139,14 +139,14 @@ public static ItemStack makeMorphedStack(ItemStack currentStack, String targetMo

ItemStack stack;
if (targetMod.equals(MINECRAFT))
stack = new ItemStack(ModItems.tome);
stack = new ItemStack(Registries.TOME.get());
else {
CompoundTag targetCmp = morphData.getCompound(targetMod);
morphData.remove(targetMod);

stack = ItemStack.of(targetCmp);
if (stack.isEmpty())
stack = new ItemStack(ModItems.tome);
stack = new ItemStack(Registries.TOME.get());
}

if (!stack.hasTag())
Expand All @@ -156,7 +156,7 @@ public static ItemStack makeMorphedStack(ItemStack currentStack, String targetMo
stackCmp.put(TAG_TOME_DATA, morphData);
stackCmp.putBoolean(TAG_MORPHING, true);

if (stack.getItem() != ModItems.tome) {
if (!stack.is(Registries.TOME.get())) {
CompoundTag displayName = new CompoundTag();
CompoundTag ogDisplayName = displayName;
displayName.putString("text", Component.Serializer.toJson(stack.getHoverName()));
Expand All @@ -166,6 +166,7 @@ public static ItemStack makeMorphedStack(ItemStack currentStack, String targetMo
else
stackCmp.put(TAG_TOME_DISPLAY_NAME, displayName);


MutableComponent rawComp = Component.Serializer.fromJson(displayName.getString("text"));
if (rawComp == null) {
stackCmp.put(TAG_TOME_DISPLAY_NAME, displayName);
Expand Down Expand Up @@ -197,7 +198,7 @@ public static boolean isAkashicTome(ItemStack stack) {
if (stack.isEmpty())
return false;

if (stack.getItem() == ModItems.tome)
if (stack.is(Registries.TOME.get()))
return true;

return stack.hasTag() && stack.getTag().getBoolean(TAG_MORPHING);
Expand Down
Loading
Loading