Skip to content

Commit

Permalink
Merge branch 'VazkiiMods:1.20.x' into 1.20.x
Browse files Browse the repository at this point in the history
  • Loading branch information
blagdorfinguy authored Dec 29, 2023
2 parents 71c8480 + cf6e641 commit a168b21
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 68 deletions.
2 changes: 1 addition & 1 deletion Fabric/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
4 changes: 2 additions & 2 deletions Forge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
2 changes: 1 addition & 1 deletion Forge/src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion Xplat/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ public TriPredicate<BlockGetter, BlockPos, BlockState> 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<ItemStack> stacksIn = new ArrayList<>();
private final List<BlockPos> cachedPylonPositions = new ArrayList<>();
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ItemStack> lastRecipe = null;
private Ingredient lastReagent = Ingredient.EMPTY;
private int recipeKeepTicks = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public static void serverTick(Level level, BlockPos worldPosition, BlockState st
List<ItemEntity> 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);
Expand Down Expand Up @@ -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);
Expand All @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ItemEntity> items = getLevel().getEntitiesOfClass(ItemEntity.class, new AABB(inPos.offset(-range, -range, -range), inPos.offset(range + 1, range + 1, range + 1)), shouldPickup);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,73 +10,60 @@

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.
* Initialized to zero by default, but may still be initialized to values less
* 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;
}
}

0 comments on commit a168b21

Please sign in to comment.