Skip to content

Commit

Permalink
Support Forge Block Appearance API
Browse files Browse the repository at this point in the history
  • Loading branch information
Technici4n committed Nov 21, 2022
1 parent 5745916 commit fa909fc
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 25 deletions.
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ artifact_basename=appliedenergistics2-forge
minecraft_release=1.19
minecraft_version=1.19.2
minecraft_version_range=[1.19.2,1.19.3)
forge_version=43.1.25
forge_version_range=[43.1.24,44.0.0)
forge_version=43.1.55
forge_version_range=[43.1.55,44.0.0)

#########################################################
# Provided APIs #
Expand Down
23 changes: 4 additions & 19 deletions src/main/java/appeng/block/networking/CableBusBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -432,20 +432,15 @@ public boolean addDestroyEffects(BlockState state, Level level, BlockPos pos,
*/
public static ThreadLocal<Direction> RENDERING_FACADE_DIRECTION = new ThreadLocal<>();

// TODO: fix ugliness when forge finally merges #9066
// @Override
@Override
public BlockState getAppearance(BlockState state, BlockAndTintGetter renderView, BlockPos pos, Direction side,
@Nullable BlockState sourceState, @Nullable BlockPos sourcePos) {
// Just for access to the model data from the BE's level (waiting for #9066 to get it from renderView directly)
var be = renderView.getBlockEntity(pos);
if (be == null) {
return state;
}
ModelData modelData;
var modelDataManager = be.getLevel().getModelDataManager();
var modelDataManager = renderView.getModelDataManager();
if (modelDataManager == null) {
// We're on the server, use BE directly
modelData = be.getModelData();
BlockEntity be = renderView.getBlockEntity(pos);
modelData = be != null ? be.getModelData() : ModelData.EMPTY;
} else {
modelData = Objects.requireNonNullElse(modelDataManager.getAt(pos), ModelData.EMPTY);
}
Expand All @@ -468,14 +463,4 @@ public BlockState getAppearance(BlockState state, BlockAndTintGetter renderView,
}
return state;
}

// Just for query until #9066 is merged
public static BlockState getAppearanceTemp(BlockState state, BlockAndTintGetter renderView, BlockPos pos,
Direction side, @Nullable BlockState sourceState, @Nullable BlockPos sourcePos) {
if (state.getBlock() instanceof CableBusBlock cableBus) {
return cableBus.getAppearance(state, renderView, pos, side, sourceState, sourcePos);
} else {
return state;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@

import appeng.api.parts.PartHelper;
import appeng.api.util.AEAxisAlignedBB;
import appeng.block.networking.CableBusBlock;
import appeng.parts.misc.CableAnchorPart;
import appeng.thirdparty.codechicken.lib.model.pipeline.transformers.QuadClamper;
import appeng.thirdparty.codechicken.lib.model.pipeline.transformers.QuadCornerKicker;
Expand Down Expand Up @@ -288,7 +287,7 @@ public Mesh getFacadeMesh(CableBusRenderState renderState, Supplier<RandomSource
// Ignore quad if it's not supposed to connect to the adjacent block.
if (cullFace != null) {
BlockPos adjPos = pos.relative(cullFace);
BlockState adjState = CableBusBlock.getAppearanceTemp(level.getBlockState(adjPos), level, adjPos,
BlockState adjState = level.getBlockState(adjPos).getAppearance(level, adjPos,
cullFace.getOpposite(), blockState, pos);

if (blockState.skipRendering(adjState, cullFace)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
import net.minecraftforge.client.model.data.ModelProperty;
import net.minecraftforge.client.model.pipeline.QuadBakingVertexConsumer;

import appeng.block.networking.CableBusBlock;
import appeng.decorative.solid.GlassState;
import appeng.decorative.solid.QuartzGlassBlock;

Expand Down Expand Up @@ -316,7 +315,7 @@ private static GlassState getGlassState(BlockAndTintGetter level, BlockState sta
private static boolean isGlassBlock(BlockAndTintGetter level, BlockState state, BlockPos pos, Direction face,
Direction adjDir) {
var adjacentPos = pos.relative(adjDir);
return CableBusBlock.getAppearanceTemp(level.getBlockState(adjacentPos), level, adjacentPos, face, state, pos)
return level.getBlockState(adjacentPos).getAppearance(level, adjacentPos, face, state, pos)
.getBlock() instanceof QuartzGlassBlock;
}

Expand Down

0 comments on commit fa909fc

Please sign in to comment.