Skip to content

Commit

Permalink
Show elevator extension in NEI render (#87)
Browse files Browse the repository at this point in the history
  • Loading branch information
serenibyss authored Dec 3, 2024
1 parent ced1083 commit 39c6f6f
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 28 deletions.
1 change: 1 addition & 0 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ dependencies {
api('com.github.GTNewHorizons:GT5-Unofficial:5.09.50.81:dev')
api('com.github.GTNewHorizons:Galaxy-Space-GTNH:1.1.97-GTNH:dev')
api('com.github.GTNewHorizons:GTNHLib:0.5.21:dev')
compileOnly('com.github.GTNewHorizons:BlockRenderer6343:1.2.15:dev') {transitive = false}
compileOnly("com.github.GTNewHorizons:Hodgepodge:2.5.81:dev") {transitive = false}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.gtnewhorizons.gtnhintergalactic.tile.multi.elevator;

import static com.gtnewhorizon.structurelib.structure.StructureUtility.withChannel;
import static gregtech.api.metatileentity.BaseTileEntity.TOOLTIP_DELAY;
import static net.minecraft.util.EnumChatFormatting.GREEN;
import static net.minecraft.util.EnumChatFormatting.ITALIC;
Expand Down Expand Up @@ -27,8 +28,8 @@
import com.gtnewhorizon.structurelib.alignment.IAlignmentLimits;
import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable;
import com.gtnewhorizon.structurelib.alignment.enumerable.Rotation;
import com.gtnewhorizon.structurelib.structure.IItemSource;
import com.gtnewhorizon.structurelib.structure.IStructureDefinition;
import com.gtnewhorizon.structurelib.structure.ISurvivalBuildEnvironment;
import com.gtnewhorizon.structurelib.structure.StructureDefinition;
import com.gtnewhorizon.structurelib.structure.StructureUtility;
import com.gtnewhorizons.gtnhintergalactic.block.IGBlocks;
Expand All @@ -51,9 +52,11 @@
import com.gtnewhorizons.modularui.common.widget.SlotWidget;
import com.gtnewhorizons.modularui.common.widget.TextWidget;

import blockrenderer6343.client.world.ClientFakePlayer;
import galaxyspace.core.register.GSBlocks;
import gregtech.api.enums.GTValues;
import gregtech.api.enums.Materials;
import gregtech.api.enums.Mods;
import gregtech.api.enums.SoundResource;
import gregtech.api.enums.Textures;
import gregtech.api.interfaces.ITexture;
Expand Down Expand Up @@ -233,12 +236,14 @@ public class TileEntitySpaceElevator extends GT_MetaTileEntity_EnhancedMultiBloc
.addElement('F', StructureUtility.ofBlock(IGBlocks.SpaceElevatorCasing, 2)) // Internal Structure
.addElement(
'C',
StructureUtility.ofBlocksTiered(
ElevatorUtil.motorTierConverter(),
ElevatorUtil.getMotorTiers(),
0,
TileEntitySpaceElevator::setMotorTier,
TileEntitySpaceElevator::getMotorTier)) // Motors
withChannel(
"motor",
StructureUtility.ofBlocksTiered(
ElevatorUtil.motorTierConverter(),
ElevatorUtil.getMotorTiers(),
0,
TileEntitySpaceElevator::setMotorTier,
TileEntitySpaceElevator::getMotorTier))) // Motors
.addElement('A', StructureUtility.ofBlock(GSBlocks.DysonSwarmBlocks, 9)) // Concrete
.addElement('D', StructureUtility.ofBlock(IGBlocks.SpaceElevatorCasing, 0)) // Base Casing
.addElement(
Expand Down Expand Up @@ -397,46 +402,60 @@ public void construct(ItemStack stackSize, boolean hintsOnly) {
}
}

/**
* Construct the structure of the Space Elevator in survival
*
* @param stackSize Hologram projector item stack
* @param elementBudget Max at once placeable blocks
* @param source Source of the building material
* @param actor Player that is constructing
* @return Number of placed blocks
*/
@Override
public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) {
if (mMachine) {
return -1;
} else {
int consumedBudget = survivialBuildPiece(
public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) {
if (Mods.BlockRenderer6343.isModLoaded() && env.getActor() instanceof ClientFakePlayer) {
int built = survivialBuildPiece(
STRUCTURE_PIECE_MAIN,
stackSize,
STRUCTURE_PIECE_MAIN_HOR_OFFSET,
STRUCTURE_PIECE_MAIN_VERT_OFFSET,
STRUCTURE_PIECE_MAIN_DEPTH_OFFSET,
elementBudget,
source,
actor,
env,
false,
true);
if (isExtensionEnabled) {
consumedBudget += survivialBuildPiece(
if (built >= 0) return built;
if (stackSize.stackSize > 1) {
built = survivialBuildPiece(
STRUCTURE_PIECE_EXTENDED,
stackSize,
STRUCTURE_PIECE_EXTENDED_HOR_OFFSET,
STRUCTURE_PIECE_EXTENDED_VERT_OFFSET,
STRUCTURE_PIECE_EXTENDED_DEPTH_OFFSET,
elementBudget,
source,
actor,
env,
false,
true);
}
return consumedBudget;
return built;
}

if (mMachine) return -1;

int consumedBudget = survivialBuildPiece(
STRUCTURE_PIECE_MAIN,
stackSize,
STRUCTURE_PIECE_MAIN_HOR_OFFSET,
STRUCTURE_PIECE_MAIN_VERT_OFFSET,
STRUCTURE_PIECE_MAIN_DEPTH_OFFSET,
elementBudget,
env,
false,
true);
if (isExtensionEnabled) {
consumedBudget += survivialBuildPiece(
STRUCTURE_PIECE_EXTENDED,
stackSize,
STRUCTURE_PIECE_EXTENDED_HOR_OFFSET,
STRUCTURE_PIECE_EXTENDED_VERT_OFFSET,
STRUCTURE_PIECE_EXTENDED_DEPTH_OFFSET,
elementBudget,
env,
false,
true);
}
return consumedBudget;
}

/**
Expand Down

0 comments on commit 39c6f6f

Please sign in to comment.