Skip to content

Commit

Permalink
Initial port of the botania integration to 1.20.1
Browse files Browse the repository at this point in the history
Ported the integration and added some more functions to the spreader and mana pool
  • Loading branch information
SirEndii committed Apr 9, 2024
1 parent f688819 commit f87ce13
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 12 deletions.
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
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;
}

@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() {
if(getPoolItems().isEmpty())
return null;
List<ItemStack> items = getPoolItems();
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;
}

@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

0 comments on commit f87ce13

Please sign in to comment.