Skip to content

Commit

Permalink
Merge pull request #920 from P3pp3rF1y/1.19.x-dev
Browse files Browse the repository at this point in the history
Release merge
  • Loading branch information
P3pp3rF1y authored Nov 30, 2023
2 parents d7a93c8 + bba168c commit 6a68a1a
Show file tree
Hide file tree
Showing 16 changed files with 501 additions and 12 deletions.
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
org.gradle.daemon=false
minecraft_version=1.19.2
forge_version=43.2.13
mod_version=3.18.66
mod_version=3.19.1
jei_mc_version=1.19.2-forge
jei_version=11.6.0.+
curios_version=1.19.2-5.1.1.+
Expand All @@ -12,5 +12,5 @@ crafting_tweaks_cf_file_id=3914007
chipped_cf_file_id=4558849
ctm_cf_file_id=4393695
resourcefullib_cf_file_id=4477753
sc_version=1.19.2-0.5.104.+
sc_version=1.19.2-0.5.106.+
parchment_version=1.18.2-2022.06.05-1.19
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"parent": "minecraft:recipes/root",
"rewards": {
"recipes": [
"sophisticatedbackpacks:anvil_upgrade"
]
},
"criteria": {
"has_upgrade_base": {
"trigger": "minecraft:inventory_changed",
"conditions": {
"items": [
{
"items": [
"sophisticatedbackpacks:upgrade_base"
]
}
]
}
},
"has_the_recipe": {
"trigger": "minecraft:recipe_unlocked",
"conditions": {
"recipe": "sophisticatedbackpacks:anvil_upgrade"
}
}
},
"requirements": [
[
"has_upgrade_base",
"has_the_recipe"
]
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"type": "minecraft:crafting_shaped",
"conditions": [
{
"itemRegistryName": "sophisticatedbackpacks:anvil_upgrade",
"type": "sophisticatedcore:item_enabled"
}
],
"pattern": [
"ADA",
"IBI",
" C "
],
"key": {
"A": {
"item": "minecraft:anvil"
},
"D": {
"tag": "forge:gems/diamond"
},
"I": {
"tag": "forge:ingots/iron"
},
"B": {
"item": "sophisticatedbackpacks:upgrade_base"
},
"C": {
"tag": "forge:chests/wooden"
}
},
"result": {
"item": "sophisticatedbackpacks:anvil_upgrade"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.DistExecutor;
import net.minecraftforge.fml.ModList;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegisterEvent;
Expand All @@ -23,12 +24,15 @@
import net.p3pp3rf1y.sophisticatedcore.client.gui.utils.Position;
import net.p3pp3rf1y.sophisticatedcore.common.gui.UpgradeContainerRegistry;
import net.p3pp3rf1y.sophisticatedcore.common.gui.UpgradeContainerType;
import net.p3pp3rf1y.sophisticatedcore.compat.CompatModIds;
import net.p3pp3rf1y.sophisticatedcore.compat.ICompat;
import net.p3pp3rf1y.sophisticatedcore.compat.chipped.BlockTransformationUpgradeContainer;
import net.p3pp3rf1y.sophisticatedcore.compat.chipped.BlockTransformationUpgradeItem;
import net.p3pp3rf1y.sophisticatedcore.compat.chipped.BlockTransformationUpgradeTab;
import net.p3pp3rf1y.sophisticatedcore.compat.chipped.BlockTransformationUpgradeWrapper;

import java.util.function.Supplier;

public class ChippedCompat implements ICompat {

public static final RegistryObject<BlockTransformationUpgradeItem> BOTANIST_WORKBENCH_UPGRADE = ModItems.ITEMS.register("chipped/botanist_workbench_upgrade",
Expand All @@ -51,14 +55,17 @@ public void init() {
IEventBus modBus = FMLJavaModLoadingContext.get().getModEventBus();
modBus.addListener(this::registerContainers);

SBPPlugin.setAdditionalCatalystRegistrar(registration -> {
registration.addRecipeCatalyst(new ItemStack(BOTANIST_WORKBENCH_UPGRADE.get()), ChippedRecipeCategory.BOTANIST_WORKBENCH_RECIPE);
registration.addRecipeCatalyst(new ItemStack(GLASSBLOWER_WORKBENCH_UPGRADE.get()), ChippedRecipeCategory.GLASSBLOWER_RECIPE);
registration.addRecipeCatalyst(new ItemStack(CARPENTER_WORKBENCH_UPGRADE.get()), ChippedRecipeCategory.CARPENTERS_TABLE_RECIPE);
registration.addRecipeCatalyst(new ItemStack(SHEPHERD_WORKBENCH_UPGRADE.get()), ChippedRecipeCategory.LOOM_TABLE_RECIPE);
registration.addRecipeCatalyst(new ItemStack(MASON_WORKBENCH_UPGRADE.get()), ChippedRecipeCategory.MASON_TABLE_RECIPE);
registration.addRecipeCatalyst(new ItemStack(PHILOSOPHER_WORKBENCH_UPGRADE.get()), ChippedRecipeCategory.ALCHEMY_BENCH_RECIPE);
registration.addRecipeCatalyst(new ItemStack(TINKERER_WORKBENCH_UPGRADE.get()), ChippedRecipeCategory.TINKERING_TABLE_RECIPE); });
if (ModList.get().isLoaded(CompatModIds.JEI)) {
((Supplier<Runnable>) () -> () -> SBPPlugin.setAdditionalCatalystRegistrar(registration -> {
registration.addRecipeCatalyst(new ItemStack(BOTANIST_WORKBENCH_UPGRADE.get()), ChippedRecipeCategory.BOTANIST_WORKBENCH_RECIPE);
registration.addRecipeCatalyst(new ItemStack(GLASSBLOWER_WORKBENCH_UPGRADE.get()), ChippedRecipeCategory.GLASSBLOWER_RECIPE);
registration.addRecipeCatalyst(new ItemStack(CARPENTER_WORKBENCH_UPGRADE.get()), ChippedRecipeCategory.CARPENTERS_TABLE_RECIPE);
registration.addRecipeCatalyst(new ItemStack(SHEPHERD_WORKBENCH_UPGRADE.get()), ChippedRecipeCategory.LOOM_TABLE_RECIPE);
registration.addRecipeCatalyst(new ItemStack(MASON_WORKBENCH_UPGRADE.get()), ChippedRecipeCategory.MASON_TABLE_RECIPE);
registration.addRecipeCatalyst(new ItemStack(PHILOSOPHER_WORKBENCH_UPGRADE.get()), ChippedRecipeCategory.ALCHEMY_BENCH_RECIPE);
registration.addRecipeCatalyst(new ItemStack(TINKERER_WORKBENCH_UPGRADE.get()), ChippedRecipeCategory.TINKERING_TABLE_RECIPE);
})).get().run();
}
}

public void registerContainers(RegisterEvent event) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,18 @@ protected void buildCraftingRecipes(Consumer<FinishedRecipe> consumer) {
.unlockedBy("has_auto_smelting_upgrade", has(ModItems.AUTO_SMELTING_UPGRADE.get()))
.save(consumer, SophisticatedBackpacks.getRL("auto_blasting_upgrade_from_auto_smelting_upgrade"));

ShapeBasedRecipeBuilder.shaped(ModItems.ANVIL_UPGRADE.get())
.pattern("ADA")
.pattern("IBI")
.pattern(" C ")
.define('A', Items.ANVIL)
.define('D', Tags.Items.GEMS_DIAMOND)
.define('I', Tags.Items.INGOTS_IRON)
.define('B', ModItems.UPGRADE_BASE.get())
.define('C', Tags.Items.CHESTS_WOODEN)
.unlockedBy(HAS_UPGRADE_BASE, has(ModItems.UPGRADE_BASE.get()))
.save(consumer);

new UpgradeRecipeBuilder(ModItems.SMITHING_BACKPACK_UPGRADE_RECIPE_SERIALIZER.get(), Ingredient.of(ModItems.DIAMOND_BACKPACK.get()),
Ingredient.of(Items.NETHERITE_INGOT), ModItems.NETHERITE_BACKPACK.get())
.unlocks("has_diamond_backpack", has(ModItems.DIAMOND_BACKPACK.get()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@
import net.p3pp3rf1y.sophisticatedbackpacks.crafting.BackpackUpgradeRecipe;
import net.p3pp3rf1y.sophisticatedbackpacks.crafting.BasicBackpackRecipe;
import net.p3pp3rf1y.sophisticatedbackpacks.crafting.SmithingBackpackUpgradeRecipe;
import net.p3pp3rf1y.sophisticatedbackpacks.upgrades.anvil.AnvilUpgradeContainer;
import net.p3pp3rf1y.sophisticatedbackpacks.upgrades.anvil.AnvilUpgradeItem;
import net.p3pp3rf1y.sophisticatedbackpacks.upgrades.anvil.AnvilUpgradeTab;
import net.p3pp3rf1y.sophisticatedbackpacks.upgrades.anvil.AnvilUpgradeWrapper;
import net.p3pp3rf1y.sophisticatedbackpacks.upgrades.deposit.DepositUpgradeContainer;
import net.p3pp3rf1y.sophisticatedbackpacks.upgrades.deposit.DepositUpgradeItem;
import net.p3pp3rf1y.sophisticatedbackpacks.upgrades.deposit.DepositUpgradeTab;
Expand Down Expand Up @@ -243,6 +247,7 @@ private ModItems() {}
public static final RegistryObject<PumpUpgradeItem> PUMP_UPGRADE = ITEMS.register("pump_upgrade", () -> new PumpUpgradeItem(false, false, SophisticatedBackpacks.ITEM_GROUP, Config.SERVER.pumpUpgrade));
public static final RegistryObject<PumpUpgradeItem> ADVANCED_PUMP_UPGRADE = ITEMS.register("advanced_pump_upgrade", () -> new PumpUpgradeItem(true, true, SophisticatedBackpacks.ITEM_GROUP, Config.SERVER.pumpUpgrade));
public static final RegistryObject<XpPumpUpgradeItem> XP_PUMP_UPGRADE = ITEMS.register("xp_pump_upgrade", () -> new XpPumpUpgradeItem(SophisticatedBackpacks.ITEM_GROUP, Config.SERVER.xpPumpUpgrade));
public static final RegistryObject<AnvilUpgradeItem> ANVIL_UPGRADE = ITEMS.register("anvil_upgrade", () -> new AnvilUpgradeItem(SophisticatedBackpacks.ITEM_GROUP));

public static final RegistryObject<ItemBase> UPGRADE_BASE = ITEMS.register("upgrade_base", () -> new ItemBase(new Item.Properties().stacksTo(16), SophisticatedBackpacks.ITEM_GROUP));

Expand Down Expand Up @@ -310,6 +315,7 @@ private static void onResourceReload(AddReloadListenerEvent event) {
private static final UpgradeContainerType<PumpUpgradeWrapper, PumpUpgradeContainer> PUMP_TYPE = new UpgradeContainerType<>(PumpUpgradeContainer::new);
private static final UpgradeContainerType<PumpUpgradeWrapper, PumpUpgradeContainer> ADVANCED_PUMP_TYPE = new UpgradeContainerType<>(PumpUpgradeContainer::new);
private static final UpgradeContainerType<XpPumpUpgradeWrapper, XpPumpUpgradeContainer> XP_PUMP_TYPE = new UpgradeContainerType<>(XpPumpUpgradeContainer::new);
private static final UpgradeContainerType<AnvilUpgradeWrapper, AnvilUpgradeContainer> ANVIL_TYPE = new UpgradeContainerType<>(AnvilUpgradeContainer::new);

public static void registerContainers(RegisterEvent event) {
if (!event.getRegistryKey().equals(ForgeRegistries.Keys.MENU_TYPES)) {
Expand Down Expand Up @@ -350,6 +356,7 @@ public static void registerContainers(RegisterEvent event) {
UpgradeContainerRegistry.register(PUMP_UPGRADE.getId(), PUMP_TYPE);
UpgradeContainerRegistry.register(ADVANCED_PUMP_UPGRADE.getId(), ADVANCED_PUMP_TYPE);
UpgradeContainerRegistry.register(XP_PUMP_UPGRADE.getId(), XP_PUMP_TYPE);
UpgradeContainerRegistry.register(ANVIL_UPGRADE.getId(), ANVIL_TYPE);

DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> {
MenuScreens.register(BACKPACK_CONTAINER_TYPE.get(), BackpackScreen::constructScreen);
Expand Down Expand Up @@ -413,6 +420,7 @@ public static void registerContainers(RegisterEvent event) {
UpgradeGuiManager.registerTab(ADVANCED_PUMP_TYPE, PumpUpgradeTab.Advanced::new);
UpgradeGuiManager.registerTab(XP_PUMP_TYPE, (XpPumpUpgradeContainer upgradeContainer, Position position, StorageScreenBase<?> screen) ->
new XpPumpUpgradeTab(upgradeContainer, position, screen, Config.SERVER.xpPumpUpgrade.mendingOn.get()));
UpgradeGuiManager.registerTab(ANVIL_TYPE, AnvilUpgradeTab::new);
});
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
package net.p3pp3rf1y.sophisticatedbackpacks.upgrades.anvil;

import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.Container;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.AnvilMenu;
import net.minecraft.world.inventory.ContainerLevelAccess;
import net.minecraft.world.inventory.ResultSlot;
import net.minecraft.world.inventory.Slot;
import net.minecraft.world.item.ItemStack;
import net.p3pp3rf1y.sophisticatedcore.common.gui.UpgradeContainerBase;
import net.p3pp3rf1y.sophisticatedcore.common.gui.UpgradeContainerType;
import net.p3pp3rf1y.sophisticatedcore.util.NBTHelper;

public class AnvilUpgradeContainer extends UpgradeContainerBase<AnvilUpgradeWrapper, AnvilUpgradeContainer> {
private static final String DATA_SHIFT_CLICK_INTO_STORAGE = "shiftClickIntoStorage";
private final Slot resultSlot;

private PersistableAnvilMenu anvilMenuDelegate;
private Runnable slotsChangeListener = () -> {};
private boolean processingOnTakeLogic = false;
public AnvilUpgradeContainer(Player player, int upgradeContainerId, AnvilUpgradeWrapper upgradeWrapper, UpgradeContainerType<AnvilUpgradeWrapper, AnvilUpgradeContainer> type) {
super(player, upgradeContainerId, upgradeWrapper, type);

anvilMenuDelegate = new PersistableAnvilMenu(new Inventory(player), upgradeWrapper);

slots.add(anvilMenuDelegate.getSlot(0));
slots.add(anvilMenuDelegate.getSlot(1));
resultSlot = anvilMenuDelegate.getSlot(2);
slots.add(resultSlot);
}

public void setSlotsChangeListener(Runnable slotsChangeListener) {
this.slotsChangeListener = slotsChangeListener;
}

@Override
public void handleMessage(CompoundTag data) {
if (data.contains(DATA_SHIFT_CLICK_INTO_STORAGE)) {
setShiftClickIntoStorage(data.getBoolean(DATA_SHIFT_CLICK_INTO_STORAGE));
} else if (data.contains("itemName")) {
setItemName(data.getString("itemName"));
}
}

public boolean shouldShiftClickIntoStorage() {
return upgradeWrapper.shouldShiftClickIntoStorage();
}

public boolean isProcessingOnTakeLogic() {
return processingOnTakeLogic;
}

public void setShiftClickIntoStorage(boolean shiftClickIntoStorage) {
upgradeWrapper.setShiftClickIntoStorage(shiftClickIntoStorage);
sendDataToServer(() -> NBTHelper.putBoolean(new CompoundTag(), DATA_SHIFT_CLICK_INTO_STORAGE, shiftClickIntoStorage));
}

@Override
public boolean mergeIntoStorageFirst(Slot slot) {
return !(slot instanceof ResultSlot) || shouldShiftClickIntoStorage();
}

@Override
public boolean allowsPickupAll(Slot slot) {
return slot != resultSlot;
}

public void setItemName(String name) {
anvilMenuDelegate.setItemName(name);
upgradeWrapper.setItemName(name);
sendDataToServer(() -> NBTHelper.putString(new CompoundTag(), "itemName", name));
}

public int getCost() {
return anvilMenuDelegate.getCost();
}

public String getItemName() {
return anvilMenuDelegate.getItemName();
}

private class PersistableAnvilMenu extends AnvilMenu {

private final AnvilUpgradeWrapper wrapper;
private boolean initializing = true;
public PersistableAnvilMenu(Inventory playerInventory, AnvilUpgradeWrapper wrapper) {
super(0, playerInventory, ContainerLevelAccess.create(playerInventory.player.level, playerInventory.player.blockPosition()));
this.wrapper = wrapper;
inputSlots.setItem(0, wrapper.getInventory().getStackInSlot(0));
inputSlots.setItem(1, wrapper.getInventory().getStackInSlot(1));

super.setItemName(wrapper.getItemName());
initializing = false;
}

public String getItemName() {
return itemName;
}

@Override
public void slotsChanged(Container pInventory) {
super.slotsChanged(pInventory);
if (initializing) {
return;
}
wrapper.getInventory().setStackInSlot(0, inputSlots.getItem(0));
wrapper.getInventory().setStackInSlot(1, inputSlots.getItem(1));
slotsChangeListener.run();
}

@Override
protected void onTake(Player player, ItemStack stack) {
processingOnTakeLogic = true;
super.onTake(player, stack);
processingOnTakeLogic = false;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package net.p3pp3rf1y.sophisticatedbackpacks.upgrades.anvil;

import net.minecraft.world.item.CreativeModeTab;
import net.p3pp3rf1y.sophisticatedcore.upgrades.UpgradeItemBase;
import net.p3pp3rf1y.sophisticatedcore.upgrades.UpgradeType;

public class AnvilUpgradeItem extends UpgradeItemBase<AnvilUpgradeWrapper> {
private static final UpgradeType<AnvilUpgradeWrapper> TYPE = new UpgradeType<>(AnvilUpgradeWrapper::new);
public AnvilUpgradeItem(CreativeModeTab itemGroup) {
super(itemGroup);
}

@Override
public UpgradeType<AnvilUpgradeWrapper> getType() {
return TYPE;
}
}
Loading

0 comments on commit 6a68a1a

Please sign in to comment.