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

Initial port of the botania integration to 1.20.1 #578

Merged
merged 6 commits into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
7 changes: 4 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ dependencies {

// Botania
compileOnly fg.deobf("vazkii.botania:Botania:${botania_version}")

runtimeOnly fg.deobf("vazkii.botania:Botania:${botania_version}")

// Minecolonies
// Remove/Comment this section if you want to use runData.
Expand All @@ -324,6 +324,7 @@ dependencies {

// Create
compileOnly fg.deobf("com.simibubi.create:create-1.20.1:${create_version}:all")
runtimeOnly fg.deobf("com.simibubi.create:create-1.20.1:${create_version}:all")

//Powah
implementation fg.deobf("curse.maven:powah-633483:${powah_version}")
Expand All @@ -346,8 +347,8 @@ dependencies {
implementation fg.deobf("mezz.jei:jei-${jei_version}")

// Create Crafts & Additions
compileOnly fg.deobf("curse.maven:createaddition-439890:5099757")
// runtimeOnly fg.deobf("curse.maven:createaddition-439890:5099757")
compileOnly fg.deobf("curse.maven:createaddition-439890:${createadditions_version}")
runtimeOnly fg.deobf("curse.maven:createaddition-439890:${createadditions_version}")
}


Expand Down
9 changes: 5 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ cc_version=1.108.4
curios_version=5.2.0+1.20.1
minecolonies_version=1.20.1-1.1.472-BETA
appliedenergistics_version=15.0.9-beta
patchouli_version=1.20.1-81
patchouli_version=1.20.1-84
refinedstorage_version=1.12.3
botania_version=1.19.2-436-SNAPSHOT
create_version=0.5.1.d-9
botania_version=1.20.1-443-FORGE
create_version=0.5.1.f-27
createca_version=5099757
mekanism_version=1.20.1-10.4.2.16
ae2things_version=4616683
Expand All @@ -49,4 +49,5 @@ domumornamentum_version=1.20-1.0.150-BETA
flywheel_version=0.6.8.a-1

# Mod dependencies for testing stuff(Only used in the dev environment)
jei_version=1.20.1-forge:15.2.0.22
jei_version=1.20.1-forge:15.2.0.22
createadditions_version=5099752
SirEndii marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,15 @@ public final int getMana() {
public final boolean isOnEnchantedSoil() {
return blockEntity.overgrowth;
}

@LuaFunction(mainThread = true)
public final boolean isFull() {
return blockEntity.getMana() >= blockEntity.getMaxMana();
}

@LuaFunction(mainThread = true)
public final boolean isEmpty() {
return getMana() == 0;
SirEndii marked this conversation as resolved.
Show resolved Hide resolved
}

}
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
package de.srendi.advancedperipherals.common.addons.botania;

import dan200.computercraft.api.lua.LuaFunction;
import de.srendi.advancedperipherals.common.util.LuaConverter;
import de.srendi.advancedperipherals.lib.peripherals.BlockEntityIntegrationPeripheral;
import net.minecraft.core.BlockPos;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.phys.AABB;
import org.jetbrains.annotations.NotNull;
import vazkii.botania.common.block.block_entity.mana.ManaPoolBlockEntity;

import java.util.List;
import java.util.stream.Collectors;

public class ManaPoolIntegration extends BlockEntityIntegrationPeripheral<ManaPoolBlockEntity> {

public ManaPoolIntegration(BlockEntity entity) {
Expand All @@ -25,8 +33,7 @@ public final int getMana() {

@LuaFunction(mainThread = true)
public final int getMaxMana() {
//TODO
return 0;
return blockEntity.getMaxMana();
}

@LuaFunction(mainThread = true)
Expand All @@ -39,4 +46,41 @@ public final boolean isFull() {
return blockEntity.isFull();
}

@LuaFunction(mainThread = true)
public final boolean isEmpty() {
return getMana() == 0;
SirEndii marked this conversation as resolved.
Show resolved Hide resolved
}

@LuaFunction(mainThread = true)
public final boolean hasItems() {
return !getPoolItems().isEmpty();
}

@LuaFunction(mainThread = true)
public final boolean canChargeItem() {
return blockEntity.isOutputtingPower();
}

@LuaFunction(mainThread = true)
public final Object getItems() {
List<ItemStack> items = getPoolItems();
SirEndii marked this conversation as resolved.
Show resolved Hide resolved
if(items.isEmpty())
return null;
Object[] luaStacks = new Object[items.size()];

for (int item = 0; item < items.size(); item++) {
luaStacks[item] = LuaConverter.stackToObject(items.get(item));
}

return luaStacks;
}

private List<ItemStack> getPoolItems() {
BlockPos position = blockEntity.getBlockPos();
return blockEntity.getLevel().getEntitiesOfClass(ItemEntity.class, new AABB(position, position.offset(1, 1, 1)))
.stream()
.map(ItemEntity::getItem)
.collect(Collectors.toList());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import dan200.computercraft.api.lua.LuaFunction;
import de.srendi.advancedperipherals.common.util.LuaConverter;
import de.srendi.advancedperipherals.lib.peripherals.BlockEntityIntegrationPeripheral;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.entity.BlockEntity;
import org.jetbrains.annotations.NotNull;
import vazkii.botania.common.block.block_entity.mana.ManaSpreaderBlockEntity;
Expand Down Expand Up @@ -47,7 +48,19 @@ public final boolean isFull() {

@LuaFunction(mainThread = true)
public final boolean isEmpty() {
return blockEntity.isEmpty();
return getMana() == 0;
SirEndii marked this conversation as resolved.
Show resolved Hide resolved
}

@LuaFunction(mainThread = true)
public final boolean hasLens() {
return blockEntity.getItem(0) != ItemStack.EMPTY;
}

@LuaFunction(mainThread = true)
public final Object getLens() {
if(blockEntity.getItem(0) == ItemStack.EMPTY)
return null;
return LuaConverter.stackToObject(blockEntity.getItem(0));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@

public class IntegrationPeripheralProvider implements IPeripheralProvider {

//private static final String[] SUPPORTED_MODS = new String[]{"botania", "create", "mekanism", "powah"};
private static final String[] SUPPORTED_MODS = new String[]{"powah", "create", "mekanism"};
private static final String[] SUPPORTED_MODS = new String[]{"powah", "create", "mekanism", "botania"};

private static final PriorityQueue<IPeripheralIntegration> integrations = new PriorityQueue<>(Comparator.comparingInt(IPeripheralIntegration::getPriority));

Expand Down