Skip to content

Commit

Permalink
Add Blood Magic Altar Compatibility to the Hologram projector (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
Superfrogman98 authored May 3, 2024
1 parent b3ead84 commit f3cca51
Show file tree
Hide file tree
Showing 3 changed files with 160 additions and 0 deletions.
2 changes: 2 additions & 0 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ dependencies {
transitive = false
}
implementation("com.github.GTNewHorizons:Railcraft:9.15.3:dev")

implementation("com.github.GTNewHorizons:BloodMagic:1.5.2:dev")
// for convenience of debug
runtimeOnlyNonPublishable("com.github.GTNewHorizons:NotEnoughItems:2.5.3-GTNH:dev")
runtimeOnlyNonPublishable("com.github.GTNewHorizons:waila:1.6.5:dev")
Expand Down
155 changes: 155 additions & 0 deletions src/main/java/net/glease/structurecompat/CompatBloodMagic.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
package net.glease.structurecompat;

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 net.minecraft.item.ItemStack;
import net.minecraft.util.StatCollector;

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.common.tileEntity.TEAltar;

@Compat("AWWayofTime")
public class CompatBloodMagic {

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";

public static final int[][] TIER_OFFSET = { { 0, 0, 0 }, { 1, -1, 1 }, { 3, 1, 3 }, { 5, 2, 5 }, { 8, -3, 8 },
{ 11, 3, 11 } };

public CompatBloodMagic() {
registerAltarStructureInfo();
}

private static void registerAltarStructureInfo() {
StructureDefinition.Builder<TEAltar> altarBuilder = IStructureDefinition.builder();
String T6_S = " ";
String T6_SR = "r r";
// region Structure
// spotless:off
IStructureDefinition<TEAltar> structureAltar = 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,T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.addElement('r',ofChain(ofBlockAnyMeta(ModBlocks.bloodRune),ofBlockAnyMeta(ModBlocks.speedRune),ofBlockAnyMeta(ModBlocks.runeOfSelfSacrifice),ofBlockAnyMeta(ModBlocks.runeOfSacrifice),ofBlockAnyMeta(ModBlocks.efficiencyRune)))
.addElement('g',ofBlock(AlchemicalWizardry.specialAltarBlock[1].getBlock(),0))
.addElement('t',ofBlock(AlchemicalWizardry.specialAltarBlock[0].getBlock(),0))
.addElement('b',ofBlock(AlchemicalWizardry.specialAltarBlock[3].getBlock(),0))
.addElement('v',ofBlock(AlchemicalWizardry.specialAltarBlock[2].getBlock(),0))
.addElement('e',ofBlock(AlchemicalWizardry.specialAltarBlock[4].getBlock(),0))
.addElement('c',ofBlock(AlchemicalWizardry.specialAltarBlock[6].getBlock(),0))
.addElement('i',ofBlock(AlchemicalWizardry.specialAltarBlock[5].getBlock(),0))
.build();
IMultiblockInfoContainer.registerTileClass(
TEAltar.class,
new CompatBloodMagic.AltarMultiblockInfoContainer(structureAltar));
// 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 ctx, ExtendedFacing aSide) {
int built = 0;
int tier = triggerStack.stackSize;
if (tier > 6) {
tier = 6;
}
if (ctx.getTier() >= tier) return -1;

for (int i = 1; i <= tier; i++) {
built += this.structureAltar.survivalBuild(
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],
elementBudge,
env,
false);
}
return built;
}

@Override
public String[] getDescription(ItemStack stackSize) {
return new String[] { StatCollector.translateToLocal("structureinfo.bloodmagic.altar.1"),
StatCollector.translateToLocal("structureinfo.bloodmagic.altar.2") };
}
}
}
3 changes: 3 additions & 0 deletions src/main/resources/assets/structurecompat/lang/en_US.lang
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@ structureinfo.railcraft.boiler.4=Width range: 1-3. Height range: depends on widt
structureinfo.railcraft.boiler.5=Uses sub channel §6boiler§r§7 to specify what type of boiler to use.
structureinfo.railcraft.boiler.error.invalid_dimension=Width %s Height %s is not a valid combination.

structureinfo.bloodmagic.altar.1=Blood Magic Altar
structureinfo.bloodmagic.altar.2=Hold 1-6 Hologram Projectors to determine the tier

structureelement.error.cannot_be_block=(%s, %s, %s) §cCANNOT§r be %s!

0 comments on commit f3cca51

Please sign in to comment.