From ff59451f6345d3debe043511d61ce42cf477fa19 Mon Sep 17 00:00:00 2001 From: Artemis System Date: Fri, 29 Dec 2023 12:40:45 +0100 Subject: [PATCH 1/2] Update patchouli and relax forge version requirement to 47.1.3 This is for compatibility, because a lot of mods have this as their latest supported version due to neoforge splitting off here. --- Fabric/build.gradle | 2 +- Forge/build.gradle | 4 ++-- Forge/src/main/resources/META-INF/mods.toml | 2 +- Xplat/build.gradle | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Fabric/build.gradle b/Fabric/build.gradle index e6aa4c2b71..98d11e3cd1 100644 --- a/Fabric/build.gradle +++ b/Fabric/build.gradle @@ -107,7 +107,7 @@ dependencies { compileOnly project(":Xplat") - modImplementation "vazkii.patchouli:Patchouli:${minecraft_version}-83-FABRIC" + modImplementation "vazkii.patchouli:Patchouli:${minecraft_version}-84-FABRIC" modCompileOnly "me.shedaniel:RoughlyEnoughItems-fabric:12.0.625" diff --git a/Forge/build.gradle b/Forge/build.gradle index b3df998876..b805ccda6d 100644 --- a/Forge/build.gradle +++ b/Forge/build.gradle @@ -95,11 +95,11 @@ minecraft { } dependencies { - minecraft "net.minecraftforge:forge:${minecraft_version}-47.1.47" + minecraft "net.minecraftforge:forge:${minecraft_version}-47.1.3" compileOnly project(":Xplat") annotationProcessor 'org.spongepowered:mixin:0.8.5:processor' - implementation fg.deobf("vazkii.patchouli:Patchouli:${minecraft_version}-83-FORGE") + implementation fg.deobf("vazkii.patchouli:Patchouli:${minecraft_version}-84-FORGE") compileOnly fg.deobf("mezz.jei:jei-1.20.1-common-api:15.2.0.27") runtimeOnly fg.deobf("mezz.jei:jei-1.20.1-forge:15.2.0.27") diff --git a/Forge/src/main/resources/META-INF/mods.toml b/Forge/src/main/resources/META-INF/mods.toml index 2ca5fd1c8c..596a2d286e 100644 --- a/Forge/src/main/resources/META-INF/mods.toml +++ b/Forge/src/main/resources/META-INF/mods.toml @@ -19,7 +19,7 @@ configBackground="botania:textures/block/livingrock_bricks.png" # background for [[dependencies.botania]] modId="forge" mandatory=true - versionRange="[47.1.47,)" + versionRange="[47.1.3,)" [[dependencies.botania]] modId="patchouli" diff --git a/Xplat/build.gradle b/Xplat/build.gradle index d1589a3c95..e760369f3a 100644 --- a/Xplat/build.gradle +++ b/Xplat/build.gradle @@ -30,7 +30,7 @@ repositories { dependencies { compileOnly group: 'org.spongepowered', name: 'mixin', version: '0.8.5' - compileOnly "vazkii.patchouli:Patchouli-xplat:${minecraft_version}-83" + compileOnly "vazkii.patchouli:Patchouli-xplat:${minecraft_version}-84" testImplementation 'org.junit.jupiter:junit-jupiter-api:5.6.1' testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.6.1' From cf6e6419f0f1302b75e34a4a295d744a9c51d46e Mon Sep 17 00:00:00 2001 From: Artemis System Date: Wed, 1 Nov 2023 11:52:49 +0100 Subject: [PATCH 2/2] Clean up how items are tagged as "in-world recipe spawned" This leads to some changes: - Runic altar and mana pools no longer store a cooldown, just a boolean. Meaning items will never re-enter the pool/altar before being picked up if they happen to land on top of it again. - Hopperhocks' 5 tick pickup delay now applies to items spawned from alfheim portals and petal apothecaries, not just altars and mana pools. --- .../AlfheimPortalBlockEntity.java | 5 +- .../PetalApothecaryBlockEntity.java | 2 - .../block_entity/RunicAltarBlockEntity.java | 6 +- .../mana/ManaPoolBlockEntity.java | 4 +- .../functional/HopperhockBlockEntity.java | 10 +-- .../internal_caps/ItemFlagsComponent.java | 77 ++++++++----------- 6 files changed, 41 insertions(+), 63 deletions(-) diff --git a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/AlfheimPortalBlockEntity.java b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/AlfheimPortalBlockEntity.java index 699348de24..74342c594b 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/AlfheimPortalBlockEntity.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/AlfheimPortalBlockEntity.java @@ -112,7 +112,6 @@ public TriPredicate getStatePredicate() { private static final String TAG_TICKS_SINCE_LAST_ITEM = "ticksSinceLastItem"; private static final String TAG_STACK_COUNT = "stackCount"; private static final String TAG_STACK = "portalStack"; - public static final String TAG_PORTAL_FLAG = "_elvenPortal"; private final List stacksIn = new ArrayList<>(); private final List cachedPylonPositions = new ArrayList<>(); @@ -156,7 +155,7 @@ public static void commonTick(Level level, BlockPos worldPosition, BlockState bl } ItemStack stack = item.getItem(); - if (XplatAbstractions.INSTANCE.itemFlagsComponent(item).alfPortalSpawned) { + if (XplatAbstractions.INSTANCE.itemFlagsComponent(item).elvenPortalSpawned) { continue; } @@ -300,7 +299,7 @@ private void resolveRecipes() { private void spawnItem(ItemStack stack) { ItemEntity item = new ItemEntity(level, worldPosition.getX() + 0.5, worldPosition.getY() + 1.5, worldPosition.getZ() + 0.5, stack); - XplatAbstractions.INSTANCE.itemFlagsComponent(item).alfPortalSpawned = true; + XplatAbstractions.INSTANCE.itemFlagsComponent(item).elvenPortalSpawned = true; level.addFreshEntity(item); ticksSinceLastItem = 0; } diff --git a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/PetalApothecaryBlockEntity.java b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/PetalApothecaryBlockEntity.java index 2d92fb9af4..db39237222 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/PetalApothecaryBlockEntity.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/PetalApothecaryBlockEntity.java @@ -56,8 +56,6 @@ public class PetalApothecaryBlockEntity extends SimpleInventoryBlockEntity imple private static final int SET_KEEP_TICKS_EVENT = 0; private static final int CRAFT_EFFECT_EVENT = 1; - public static final String ITEM_TAG_APOTHECARY_SPAWNED = "ApothecarySpawned"; - private List lastRecipe = null; private Ingredient lastReagent = Ingredient.EMPTY; private int recipeKeepTicks = 0; diff --git a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/RunicAltarBlockEntity.java b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/RunicAltarBlockEntity.java index f2c0dd2e87..a88c21620e 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/RunicAltarBlockEntity.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/RunicAltarBlockEntity.java @@ -165,7 +165,7 @@ public static void serverTick(Level level, BlockPos worldPosition, BlockState st List items = level.getEntitiesOfClass(ItemEntity.class, new AABB(worldPosition, worldPosition.offset(1, 1, 1))); for (ItemEntity item : items) { if (item.isAlive() && !item.getItem().isEmpty() && !item.getItem().is(BotaniaBlocks.livingrock.asItem()) - && XplatAbstractions.INSTANCE.itemFlagsComponent(item).getRunicAltarCooldown() == 0) { + && !XplatAbstractions.INSTANCE.itemFlagsComponent(item).runicAltarSpawned) { ItemStack stack = item.getItem(); if (self.addItem(null, stack, null)) { EntityHelper.syncItem(item); @@ -280,7 +280,7 @@ public boolean onUsedByWand(@Nullable Player player, ItemStack wand, Direction s receiveMana(-mana); ItemStack output = recipe.assemble(getItemHandler(), getLevel().registryAccess()); ItemEntity outputItem = new ItemEntity(level, worldPosition.getX() + 0.5, worldPosition.getY() + 1.5, worldPosition.getZ() + 0.5, output); - XplatAbstractions.INSTANCE.itemFlagsComponent(outputItem).markAltarOutput(); + XplatAbstractions.INSTANCE.itemFlagsComponent(outputItem).runicAltarSpawned = true; level.addFreshEntity(outputItem); currentRecipe = null; level.blockEvent(getBlockPos(), BotaniaBlocks.runeAltar, SET_COOLDOWN_EVENT, 60); @@ -292,7 +292,7 @@ public boolean onUsedByWand(@Nullable Player player, ItemStack wand, Direction s if (!stack.isEmpty()) { if (stack.getItem() instanceof RuneItem && (player == null || !player.getAbilities().instabuild)) { ItemEntity outputRune = new ItemEntity(level, getBlockPos().getX() + 0.5, getBlockPos().getY() + 1.5, getBlockPos().getZ() + 0.5, stack.copy()); - XplatAbstractions.INSTANCE.itemFlagsComponent(outputRune).markAltarOutput(); + XplatAbstractions.INSTANCE.itemFlagsComponent(outputRune).runicAltarSpawned = true; level.addFreshEntity(outputRune); } diff --git a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/mana/ManaPoolBlockEntity.java b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/mana/ManaPoolBlockEntity.java index 79ad17994a..2ecc151986 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/mana/ManaPoolBlockEntity.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/mana/ManaPoolBlockEntity.java @@ -164,7 +164,7 @@ public boolean collideEntityItem(ItemEntity item) { dissolvable.onDissolveTick(this, item); } - if (XplatAbstractions.INSTANCE.itemFlagsComponent(item).getManaInfusionCooldown() > 0) { + if (XplatAbstractions.INSTANCE.itemFlagsComponent(item).manaInfusionSpawned) { return false; } @@ -180,7 +180,7 @@ public boolean collideEntityItem(ItemEntity item) { item.setOnGround(false); //Force entity collision update to run every tick if crafting is in progress ItemEntity outputItem = new ItemEntity(level, worldPosition.getX() + 0.5, worldPosition.getY() + 1.5, worldPosition.getZ() + 0.5, output); - XplatAbstractions.INSTANCE.itemFlagsComponent(outputItem).markNewlyInfused(); + XplatAbstractions.INSTANCE.itemFlagsComponent(outputItem).manaInfusionSpawned = true; level.addFreshEntity(outputItem); craftingEffect(true); diff --git a/Xplat/src/main/java/vazkii/botania/common/block/flower/functional/HopperhockBlockEntity.java b/Xplat/src/main/java/vazkii/botania/common/block/flower/functional/HopperhockBlockEntity.java index 56c50cc5f9..3a09a78296 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/flower/functional/HopperhockBlockEntity.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/flower/functional/HopperhockBlockEntity.java @@ -82,15 +82,9 @@ public void tickFlower() { final ItemFlagsComponent flags = XplatAbstractions.INSTANCE.itemFlagsComponent(item); // Flat 5 tick delay for newly infused items - final int runicAltarCooldown = flags.getRunicAltarCooldown(); - if (runicAltarCooldown > 0) { - return runicAltarCooldown <= ItemFlagsComponent.INITIAL_RUNIC_ALTAR_COOLDOWN - 5; + if (flags.spawnedByInWorldRecipe()) { + return flags.timeCounter >= 5; } - var manaInfusionCooldown = flags.getManaInfusionCooldown(); - if (manaInfusionCooldown > 0) { - return manaInfusionCooldown <= ItemFlagsComponent.INITIAL_MANA_INFUSION_COOLDOWN - 5; - } - return DelayHelper.canInteractWith(this, item); }; List items = getLevel().getEntitiesOfClass(ItemEntity.class, new AABB(inPos.offset(-range, -range, -range), inPos.offset(range + 1, range + 1, range + 1)), shouldPickup); diff --git a/Xplat/src/main/java/vazkii/botania/common/internal_caps/ItemFlagsComponent.java b/Xplat/src/main/java/vazkii/botania/common/internal_caps/ItemFlagsComponent.java index 7bc807e3a9..3e7d5b5fde 100644 --- a/Xplat/src/main/java/vazkii/botania/common/internal_caps/ItemFlagsComponent.java +++ b/Xplat/src/main/java/vazkii/botania/common/internal_caps/ItemFlagsComponent.java @@ -10,13 +10,12 @@ import net.minecraft.nbt.CompoundTag; -import vazkii.botania.common.block.block_entity.AlfheimPortalBlockEntity; -import vazkii.botania.common.block.block_entity.PetalApothecaryBlockEntity; - // Component for misc internal Botania flags public class ItemFlagsComponent extends SerializableComponent { - public boolean alfPortalSpawned = false; + public boolean elvenPortalSpawned = false; public boolean apothecarySpawned = false; + public boolean manaInfusionSpawned = false; + public boolean runicAltarSpawned = false; /** * Similar to the age field on the actual entity, but always increases by 1 every tick, * no magic values like vanilla -32768, etc. @@ -24,59 +23,47 @@ public class ItemFlagsComponent extends SerializableComponent { * than zero in certain scenarios. */ public int timeCounter = 0; - /** - * Set to {@link #INITIAL_MANA_INFUSION_COOLDOWN} when an item is output by the pool then cools off to 0. - * Used so certain mechanics don't interact with items immediately after they're produced. - */ - private int manaInfusionCooldown = 0; - /** - * Similar to {@link #manaInfusionCooldown} but for the Runic Altar. - */ - private int runicAltarCooldown = 0; - public static final int INITIAL_MANA_INFUSION_COOLDOWN = 25; - public static final int INITIAL_RUNIC_ALTAR_COOLDOWN = 25; + + private static final String TAG_PORTAL_SPAWNED = "ElvenPortalSpawned"; + private static final String TAG_APOTHECARY_SPAWNED = "ApothecarySpawned"; + private static final String TAG_INFUSION_SPAWNED = "ManaInfusionSpawned"; + private static final String TAG_ALTAR_SPAWNED = "RunicAltarSpawned"; + + private static final String TAG_TIME_COUNTER = "timeCounter"; @Override public void readFromNbt(CompoundTag tag) { - alfPortalSpawned = tag.getBoolean(AlfheimPortalBlockEntity.TAG_PORTAL_FLAG); - apothecarySpawned = tag.getBoolean(PetalApothecaryBlockEntity.ITEM_TAG_APOTHECARY_SPAWNED); - timeCounter = tag.getInt("timeCounter"); - manaInfusionCooldown = tag.getInt("manaInfusionCooldown"); - runicAltarCooldown = tag.getInt("runicAltarCooldown"); + elvenPortalSpawned = tag.getBoolean(TAG_PORTAL_SPAWNED); + apothecarySpawned = tag.getBoolean(TAG_APOTHECARY_SPAWNED); + manaInfusionSpawned = tag.getBoolean(TAG_INFUSION_SPAWNED); + runicAltarSpawned = tag.getBoolean(TAG_ALTAR_SPAWNED); + timeCounter = tag.getInt(TAG_TIME_COUNTER); + // legacy tags + if (tag.getBoolean("_elvenPortal")) { + elvenPortalSpawned = true; + } + if (tag.getInt("manaInfusionCooldown") > 0) { + manaInfusionSpawned = true; + } + if (tag.getInt("runicAltarCooldown") > 0) { + runicAltarSpawned = true; + } } @Override public void writeToNbt(CompoundTag tag) { - tag.putBoolean(AlfheimPortalBlockEntity.TAG_PORTAL_FLAG, alfPortalSpawned); - tag.putBoolean(PetalApothecaryBlockEntity.ITEM_TAG_APOTHECARY_SPAWNED, apothecarySpawned); - tag.putInt("timeCounter", timeCounter); - tag.putInt("manaInfusionCooldown", manaInfusionCooldown); - tag.putInt("runicAltarCooldown", runicAltarCooldown); + tag.putBoolean(TAG_PORTAL_SPAWNED, elvenPortalSpawned); + tag.putBoolean(TAG_APOTHECARY_SPAWNED, apothecarySpawned); + tag.putBoolean(TAG_INFUSION_SPAWNED, runicAltarSpawned); + tag.putBoolean(TAG_ALTAR_SPAWNED, manaInfusionSpawned); + tag.putInt(TAG_TIME_COUNTER, timeCounter); } public void tick() { timeCounter++; - if (manaInfusionCooldown > 0) { - manaInfusionCooldown--; - } - if (runicAltarCooldown > 0) { - runicAltarCooldown--; - } - } - - public int getManaInfusionCooldown() { - return manaInfusionCooldown; - } - - public void markNewlyInfused() { - manaInfusionCooldown = INITIAL_MANA_INFUSION_COOLDOWN; - } - - public int getRunicAltarCooldown() { - return runicAltarCooldown; } - public void markAltarOutput() { - runicAltarCooldown = INITIAL_RUNIC_ALTAR_COOLDOWN; + public boolean spawnedByInWorldRecipe() { + return elvenPortalSpawned || apothecarySpawned || runicAltarSpawned || manaInfusionSpawned; } }