Skip to content

Commit

Permalink
Fix duplicated call on bake() in DistributionTransformerFormedModel
Browse files Browse the repository at this point in the history
  • Loading branch information
rikka0w0 committed Jun 10, 2020
1 parent 66479e5 commit 2964656
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,14 @@ else if (type.equals("distribution_transformer")) {
EnumDistributionTransformerBlockType.forName(
JSONUtils.getString(modelContents, "part"));

if (blockType.formed) {
if (blockType == EnumDistributionTransformerBlockType.PlaceHolder) {
return new ModelGeometryWrapper(null, DistributionTransformerFormedModel.class, (context)->{
return DistributionTransformerFormedModel.instance;
});
} else if (blockType.formed) {
return new ModelGeometryWrapper(null, null, (context)->{
return DistributionTransformerFormedModel.instanceNoBaking;
});
} else {
return new ModelGeometryWrapper(null, DistributionTransformerComponentModel.class, (context)->{
Direction facing = context.getFacing();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,16 @@ private void distributionTransformer(BlockDistributionTransformer block) {
});

// Generate item model
models().getBuilder("item/"+name).parent(modelFile);
BlockModelBuilder itemModelBuilder = models().getBuilder("item/"+name);
if (blockType.formed) {
itemModelBuilder.parent(
customLoader(
new ResourceLocation(domain, BuiltInModelLoader.dir + name + "_inventory"),
GeneratedModelLoader.placeholder()
)
);
} else {
itemModelBuilder.parent(modelFile);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import java.util.List;
import java.util.Random;
import java.util.function.Function;
import com.google.common.collect.ImmutableList;

import net.minecraft.block.BlockState;
import net.minecraft.client.renderer.model.BakedQuad;
Expand All @@ -30,6 +29,7 @@
@OnlyIn(Dist.CLIENT)
public class DistributionTransformerFormedModel extends CodeBasedModel {
public final static DistributionTransformerFormedModel instance = new DistributionTransformerFormedModel();
public final static NoBaking instanceNoBaking = new NoBaking();

@EasyTextureLoader.Mark(ResourcePaths.hv_cable)
private final TextureAtlasSprite textureCable = null;
Expand Down Expand Up @@ -60,25 +60,29 @@ private DistributionTransformerFormedModel() {
}
}
}


protected boolean skipLegacyTextureRegistration() {
return true;
}

@Override
public List<BakedQuad> getQuads(BlockState state, Direction side, Random rand, IModelData extraData) {
if (side != null)
return ImmutableList.of();
return emptyQuadList;

IMultiBlockTile te = extraData.getData(IMultiBlockTile.prop);
if (te == null)
return ImmutableList.of();
return emptyQuadList;

MultiBlockTileInfo mbInfo = te.getMultiBlockTileInfo();
if (mbInfo == null)
return ImmutableList.of();
return emptyQuadList;

EnumDistributionTransformerRenderPart part = mbInfo.lookup( BlockDistributionTransformer.renderParts);
Direction facing = mbInfo.facing;

if (part == null || facing == null)
return ImmutableList.of();
return emptyQuadList;

return quads[part.ordinal()][facing.ordinal()-2];
}
Expand Down Expand Up @@ -361,4 +365,29 @@ private void bakePart(EnumDistributionTransformerRenderPart part, Direction faci
model.translateCoord(0.5F, 0, 0.5F);
model.bake(list);
}

private static class NoBaking extends CodeBasedModel {
protected boolean skipLegacyTextureRegistration() {
return true;
}

@Override
public List<BakedQuad> getQuads(BlockState state, Direction side, Random rand, IModelData extraData) {
if (instance == null)
return emptyQuadList;
return instance.getQuads(state, side, rand, extraData);
}

@Override
public TextureAtlasSprite getParticleTexture() {
if (instance == null)
return null;
return instance.getParticleTexture();
}

@Override
protected void bake(Function<ResourceLocation, TextureAtlasSprite> textureRegistry) {

}
}
}

0 comments on commit 2964656

Please sign in to comment.