Merge remote-tracking branch 'origin/structurelib' into dev

This commit is contained in:
Martin Robertz committed 2025-05-04 12:52:12 +02:00
commit fd09bc9c8e
6 files changed
+279

No files matched your search

+2
View File
@@ -39,4 +39,6 @@ dependencies {
compileOnly("thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev") {transitive = false }
compileOnly("curse.maven:guide-api-228832:2287185") {transitive = false }
compileOnly("com.github.GTNewHorizons:StructureLib:1.4.6:dev")
}
@@ -277,6 +277,7 @@ import WayofTime.alchemicalWizardry.common.tileEntity.TEWritingTable;
import WayofTime.alchemicalWizardry.common.tileEntity.gui.GuiHandler;
import WayofTime.alchemicalWizardry.common.tweaker.MineTweakerIntegration;
import WayofTime.alchemicalWizardry.compat.BloodMagicWailaPlugin;
import WayofTime.alchemicalWizardry.compat.structurelib.CompatStructureLib;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.Mod;
@@ -3332,6 +3333,10 @@ public class AlchemicalWizardry {
isFMPLoaded = Loader.isModLoaded("ForgeMultipart");
isChiselLoaded = Loader.isModLoaded("chisel");
if (Loader.isModLoaded("structurelib")) {
CompatStructureLib.init();
}
BloodMagicConfiguration.loadBlacklist();
BloodMagicConfiguration.blacklistRituals();
BloodMagicConfiguration.loadCustomLPValues();
@@ -0,0 +1,207 @@
/*
* Original class by https://github.com/Superfrogman98, copied with permission Original PR:
* https://github.com/GTNewHorizons/StructureCompat/pull/6 Link to message giving permission (GT: New Horizons Discord
* server): https://discord.com/channels/181078474394566657/603348502637969419/1367345532376453130
*/
package WayofTime.alchemicalWizardry.compat.structurelib;
import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock;
import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlockAnyMeta;
import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain;
import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose;
import java.util.ArrayList;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.util.StatCollector;
import com.google.common.base.Joiner;
import com.gtnewhorizon.structurelib.alignment.constructable.IMultiblockInfoContainer;
import com.gtnewhorizon.structurelib.alignment.enumerable.ExtendedFacing;
import com.gtnewhorizon.structurelib.structure.IStructureDefinition;
import com.gtnewhorizon.structurelib.structure.ISurvivalBuildEnvironment;
import com.gtnewhorizon.structurelib.structure.StructureDefinition;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.ModBlocks;
import WayofTime.alchemicalWizardry.api.BlockStack;
import WayofTime.alchemicalWizardry.common.tileEntity.TEAltar;
public class AltarStructure {
private static final String STRUCTURE_ALTAR = "tier1";
private static final String STRUCTURE_TIER_2 = "tier2";
private static final String STRUCTURE_TIER_3 = "tier3";
private static final String STRUCTURE_TIER_4 = "tier4";
private static final String STRUCTURE_TIER_5 = "tier5";
private static final String STRUCTURE_TIER_6 = "tier6";
@SuppressWarnings("rawtypes")
private static final AnyBlock ANY_BLOCK = new AnyBlock();
public static final int[][] TIER_OFFSET = { { 0, 0, 0 }, { 1, -1, 1 }, { 3, 1, 3 }, { 5, 2, 5 }, { 8, -3, 8 },
{ 11, 3, 11 } };
@SuppressWarnings("unchecked")
public static void registerAltarStructureInfo() {
StructureDefinition.Builder<TEAltar> altarBuilder = IStructureDefinition.builder();
String T6_S = " ";
String T6_SR = "r r";
// region Structure
// spotless:off
altarBuilder
.addShape(STRUCTURE_ALTAR, new String[][] {{"a"}})
.addShape(STRUCTURE_TIER_2, transpose(new String[][] {{"rrr","r r","rrr"}}))
.addShape(STRUCTURE_TIER_3, transpose(new String[][] {{"g g"," "," "," "," "," ","g g"},
{"t t"," "," "," "," "," ","t t"},
{"t t"," "," "," "," "," ","t t"},
{" rrrrr ","r r","r r","r r","r r","r r"," rrrrr "}}))
.addShape(STRUCTURE_TIER_4, transpose(new String[][]
{{"b b"," "," "," "," "," "," "," "," "," ","b b"},
{"v v"," "," "," "," "," "," "," "," "," ","v v"},
{"v v"," "," "," "," "," "," "," "," "," ","v v"},
{"v v"," "," "," "," "," "," "," "," "," ","v v"},
{"v v"," "," "," "," "," "," "," "," "," ","v v"},
{" rrrrrrr "," ","r r","r r","r r","r r","r r","r r","r r"," "," rrrrrrr "}}))
.addShape(STRUCTURE_TIER_5, transpose(new String[][] {{"e e"," "," "," "," "," "," "," "," "," "," "," "," "," "," "," ","e e"},
{" rrrrrrrrrrrrr "," ","r r","r r","r r","r r","r r","r r","r r","r r","r r","r r","r r","r r","r r"," "," rrrrrrrrrrrrr "}}))
.addShape(STRUCTURE_TIER_6, transpose(new String[][]
{
{"c c",T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,"c c"},
{"i i",T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,"i i"},
{"i i",T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,"i i"},
{"i i",T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,"i i"},
{"i i",T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,"i i"},
{"i i",T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,"i i"},
{"i i",T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,"i i"},
{"i i",T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,T6_S,"i i"},
{" rrrrrrrrrrrrrrrrrrr ",T6_S,T6_SR,T6_SR,T6_SR,T6_SR,T6_SR,T6_SR,T6_SR,T6_SR,T6_SR,T6_SR,T6_SR,T6_SR,T6_SR,T6_SR,T6_SR,T6_SR,T6_SR,T6_SR,T6_SR,T6_S, " rrrrrrrrrrrrrrrrrrr "},
}))
.addElement('a',ofBlock(ModBlocks.blockAltar,0))
.addElement('r',ofChain(ofBlockAnyMeta(ModBlocks.bloodRune),ofBlockAnyMeta(ModBlocks.speedRune),ofBlockAnyMeta(ModBlocks.runeOfSelfSacrifice),ofBlockAnyMeta(ModBlocks.runeOfSacrifice),ofBlockAnyMeta(ModBlocks.efficiencyRune)));
char[] keys = {'t', 'g', 'v', 'b', 'e', 'i', 'c'};
for (int i = 0; i < keys.length; i++) {
BlockStack stack = AlchemicalWizardry.specialAltarBlock[i];
if (stack != null && stack.getBlock() != Blocks.air) {
altarBuilder.addElement(keys[i], ofBlock(stack.getBlock(), stack.getMeta()));
} else {
altarBuilder.addElement(keys[i], ANY_BLOCK);
}
}
IMultiblockInfoContainer.registerTileClass(TEAltar.class,
new AltarStructure.AltarMultiblockInfoContainer(altarBuilder.build()));
// spotless:on
}
private static class AltarMultiblockInfoContainer implements IMultiblockInfoContainer<TEAltar> {
private final IStructureDefinition<TEAltar> structureAltar;
public AltarMultiblockInfoContainer(IStructureDefinition<TEAltar> structureAltar) {
this.structureAltar = structureAltar;
}
@Override
public void construct(ItemStack triggerStack, boolean hintsOnly, TEAltar ctx, ExtendedFacing aSide) {
int tier = triggerStack.stackSize;
if (tier > 6) {
tier = 6;
}
for (int i = 1; i <= tier; i++) {
this.structureAltar.buildOrHints(
ctx,
triggerStack,
"tier" + i,
ctx.getWorldObj(),
ExtendedFacing.DEFAULT,
ctx.xCoord,
ctx.yCoord,
ctx.zCoord,
TIER_OFFSET[i - 1][0],
TIER_OFFSET[i - 1][1],
TIER_OFFSET[i - 1][2],
hintsOnly);
}
}
@Override
public int survivalConstruct(ItemStack triggerStack, int elementBudge, ISurvivalBuildEnvironment env,
TEAltar altar, ExtendedFacing aSide) {
int built = 0;
int tier = triggerStack.stackSize;
if (tier > 6) {
tier = 6;
}
if (altar.getTier() >= tier) return -1;
for (int i = 1; i <= tier; i++) {
built += this.structureAltar.survivalBuild(
altar,
triggerStack,
"tier" + i,
altar.getWorldObj(),
ExtendedFacing.DEFAULT,
altar.xCoord,
altar.yCoord,
altar.zCoord,
TIER_OFFSET[i - 1][0],
TIER_OFFSET[i - 1][1],
TIER_OFFSET[i - 1][2],
elementBudge,
env,
false);
}
return built;
}
@Override
public String[] getDescription(ItemStack stackSize) {
ArrayList<String> out = new ArrayList<>();
out.add(StatCollector.translateToLocal("structurelib.bloodmagic.altar.1"));
out.add(StatCollector.translateToLocal("structurelib.bloodmagic.altar.2"));
int[] pillarIndices = { 0, 2, 5 };
int[] pillarTiers = { 3, 4, 6 };
ArrayList<Integer> pillars = new ArrayList<>();
for (int i = 0; i < pillarIndices.length; i++) {
if (AlchemicalWizardry.specialAltarBlock[pillarIndices[i]].getBlock() == Blocks.air) {
pillars.add(pillarTiers[i]);
}
}
if (!pillars.isEmpty()) {
out.add(
StatCollector.translateToLocalFormatted(
"structurelib.bloodmagic.altar.3",
Joiner.on(", ").join(pillars)));
}
int[] capIndices = { 1, 3, 6 };
int[] capTiers = { 3, 4, 6 };
ArrayList<Integer> caps = new ArrayList<>();
for (int i = 0; i < capIndices.length; i++) {
if (AlchemicalWizardry.specialAltarBlock[capIndices[i]].getBlock() == Blocks.air) {
caps.add(capTiers[i]);
}
}
if (!caps.isEmpty()) {
out.add(
StatCollector.translateToLocalFormatted(
"structurelib.bloodmagic.altar.4",
Joiner.on(", ").join(caps)));
}
if (AlchemicalWizardry.specialAltarBlock[4].getBlock() == Blocks.air) { // T5 Beacon
out.add(StatCollector.translateToLocal("structurelib.bloodmagic.altar.5"));
}
return out.toArray(new String[0]);
}
}
}
@@ -0,0 +1,50 @@
package WayofTime.alchemicalWizardry.compat.structurelib;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import com.gtnewhorizon.structurelib.StructureLibAPI;
import com.gtnewhorizon.structurelib.structure.AutoPlaceEnvironment;
import com.gtnewhorizon.structurelib.structure.IStructureElement;
public class AnyBlock<T> implements IStructureElement<T> {
@Override
public boolean check(Object t, World world, int x, int y, int z) {
return !world.isAirBlock(x, y, z);
}
@Override
public boolean couldBeValid(Object t, World world, int x, int y, int z, ItemStack trigger) {
return check(t, world, x, y, z);
}
@Override
public boolean spawnHint(Object o, World world, int x, int y, int z, ItemStack trigger) {
StructureLibAPI.hintParticle(world, x, y, z, StructureLibAPI.getBlockHint(), 14);
return true;
}
@Override
public boolean placeBlock(Object o, World world, int x, int y, int z, ItemStack trigger) {
world.setBlock(x, y, z, Blocks.stonebrick, 0, 2);
return true;
}
@Override
public BlocksToPlace getBlocksToPlace(Object o, World world, int x, int y, int z, ItemStack trigger,
AutoPlaceEnvironment env) {
return BlocksToPlace.create(Blocks.stonebrick, 0);
}
@Override
public PlaceResult survivalPlaceBlock(Object o, World world, int x, int y, int z, ItemStack trigger,
AutoPlaceEnvironment env) {
if (world.provider.dimensionId == Integer.MAX_VALUE) { // Required for the NEI preview to work
world.setBlock(x, y, z, Blocks.stonebrick, 0, 2);
return PlaceResult.ACCEPT;
}
return PlaceResult.SKIP;
}
}
@@ -0,0 +1,8 @@
package WayofTime.alchemicalWizardry.compat.structurelib;
public class CompatStructureLib {
public static void init() {
AltarStructure.registerAltarStructureInfo();
}
}
@@ -652,3 +652,10 @@ option.bm.bloodAltar=Blood Altar
option.bm.ritualController=Ritual Stones
option.bm.teleposer=Teleposer
option.bm.chemistrySet=Alchemical Chemistry Set
# StructureLib
structurelib.bloodmagic.altar.1=Blood Altar
structurelib.bloodmagic.altar.2=Hold 1-6 Hologram Projectors to determine the tier
structurelib.bloodmagic.altar.3=Tier %s pillars accept any block
structurelib.bloodmagic.altar.4=Tier %s caps accept any block
structurelib.bloodmagic.altar.5=Tier 5 beacons accept any block