| 1 | package net.minecraft.client.resources.model;
|
| 2 |
|
| 3 | import com.google.common.collect.Lists;
|
| 4 | import java.util.List;
|
| 5 | import net.minecraft.client.renderer.block.model.BakedQuad;
|
| 6 | import net.minecraft.client.renderer.block.model.BreakingFour;
|
| 7 | import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
|
| 8 | import net.minecraft.client.renderer.block.model.ModelBlock;
|
| 9 | import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
| 10 | import net.minecraft.util.EnumFacing;
|
| 11 |
|
| 12 | public class SimpleBakedModel implements IBakedModel
|
| 13 | {
|
| 14 | protected final List<BakedQuad> generalQuads;
|
| 15 | protected final List<List<BakedQuad>> faceQuads;
|
| 16 | protected final boolean ambientOcclusion;
|
| 17 | protected final boolean gui3d;
|
| 18 | protected final TextureAtlasSprite texture;
|
| 19 | protected final ItemCameraTransforms cameraTransforms;
|
| 20 |
|
| 21 | public SimpleBakedModel(List<BakedQuad> generalQuadsIn, List<List<BakedQuad>> faceQuadsIn, boolean ambientOcclusionIn, boolean gui3dIn, TextureAtlasSprite textureIn, ItemCameraTransforms cameraTransformsIn)
|
| 22 | {
|
| 23 | this.generalQuads = generalQuadsIn;
|
| 24 | this.faceQuads = faceQuadsIn;
|
| 25 | this.ambientOcclusion = ambientOcclusionIn;
|
| 26 | this.gui3d = gui3dIn;
|
| 27 | this.texture = textureIn;
|
| 28 | this.cameraTransforms = cameraTransformsIn;
|
| 29 | }
|
| 30 |
|
| 31 | public List<BakedQuad> getFaceQuads(EnumFacing facing)
|
| 32 | {
|
| 33 | return (List)this.faceQuads.get(facing.ordinal());
|
| 34 | }
|
| 35 |
|
| 36 | public List<BakedQuad> getGeneralQuads()
|
| 37 | {
|
| 38 | return this.generalQuads;
|
| 39 | }
|
| 40 |
|
| 41 | public boolean isAmbientOcclusion()
|
| 42 | {
|
| 43 | return this.ambientOcclusion;
|
| 44 | }
|
| 45 |
|
| 46 | public boolean isGui3d()
|
| 47 | {
|
| 48 | return this.gui3d;
|
| 49 | }
|
| 50 |
|
| 51 | public boolean isBuiltInRenderer()
|
| 52 | {
|
| 53 | return false;
|
| 54 | }
|
| 55 |
|
| 56 | public TextureAtlasSprite getParticleTexture()
|
| 57 | {
|
| 58 | return this.texture;
|
| 59 | }
|
| 60 |
|
| 61 | public ItemCameraTransforms getItemCameraTransforms()
|
| 62 | {
|
| 63 | return this.cameraTransforms;
|
| 64 | }
|
| 65 |
|
| 66 | public static class Builder
|
| 67 | {
|
| 68 | private final List<BakedQuad> builderGeneralQuads;
|
| 69 | private final List<List<BakedQuad>> builderFaceQuads;
|
| 70 | private final boolean builderAmbientOcclusion;
|
| 71 | private TextureAtlasSprite builderTexture;
|
| 72 | private boolean builderGui3d;
|
| 73 | private ItemCameraTransforms builderCameraTransforms;
|
| 74 |
|
| 75 | public Builder(ModelBlock model)
|
| 76 | {
|
| 77 | this(model.isAmbientOcclusion(), model.isGui3d(), model.getAllTransforms());
|
| 78 | }
|
| 79 |
|
| 80 | public Builder(IBakedModel bakedModel, TextureAtlasSprite texture)
|
| 81 | {
|
| 82 | this(bakedModel.isAmbientOcclusion(), bakedModel.isGui3d(), bakedModel.getItemCameraTransforms());
|
| 83 | this.builderTexture = bakedModel.getParticleTexture();
|
| 84 |
|
| 85 | for (EnumFacing enumfacing : EnumFacing.values())
|
| 86 | {
|
| 87 | this.addFaceBreakingFours(bakedModel, texture, enumfacing);
|
| 88 | }
|
| 89 |
|
| 90 | this.addGeneralBreakingFours(bakedModel, texture);
|
| 91 | }
|
| 92 |
|
| 93 | private void addFaceBreakingFours(IBakedModel bakedModel, TextureAtlasSprite texture, EnumFacing facing)
|
| 94 | {
|
| 95 | for (BakedQuad bakedquad : bakedModel.getFaceQuads(facing))
|
| 96 | {
|
| 97 | this.addFaceQuad(facing, new BreakingFour(bakedquad, texture));
|
| 98 | }
|
| 99 | }
|
| 100 |
|
| 101 | private void addGeneralBreakingFours(IBakedModel p_177647_1_, TextureAtlasSprite texture)
|
| 102 | {
|
| 103 | for (BakedQuad bakedquad : p_177647_1_.getGeneralQuads())
|
| 104 | {
|
| 105 | this.addGeneralQuad(new BreakingFour(bakedquad, texture));
|
| 106 | }
|
| 107 | }
|
| 108 |
|
| 109 | private Builder(boolean ambientOcclusion, boolean gui3d, ItemCameraTransforms cameraTransforms)
|
| 110 | {
|
| 111 | this.builderGeneralQuads = Lists.<BakedQuad>newArrayList();
|
| 112 | this.builderFaceQuads = Lists.<List<BakedQuad>>newArrayListWithCapacity(6);
|
| 113 |
|
| 114 | for (EnumFacing enumfacing : EnumFacing.values())
|
| 115 | {
|
| 116 | this.builderFaceQuads.add(Lists.<BakedQuad>newArrayList());
|
| 117 | }
|
| 118 |
|
| 119 | this.builderAmbientOcclusion = ambientOcclusion;
|
| 120 | this.builderGui3d = gui3d;
|
| 121 | this.builderCameraTransforms = cameraTransforms;
|
| 122 | }
|
| 123 |
|
| 124 | public SimpleBakedModel.Builder addFaceQuad(EnumFacing facing, BakedQuad quad)
|
| 125 | {
|
| 126 | ((List)this.builderFaceQuads.get(facing.ordinal())).add(quad);
|
| 127 | return this;
|
| 128 | }
|
| 129 |
|
| 130 | public SimpleBakedModel.Builder addGeneralQuad(BakedQuad quad)
|
| 131 | {
|
| 132 | this.builderGeneralQuads.add(quad);
|
| 133 | return this;
|
| 134 | }
|
| 135 |
|
| 136 | public SimpleBakedModel.Builder setTexture(TextureAtlasSprite texture)
|
| 137 | {
|
| 138 | this.builderTexture = texture;
|
| 139 | return this;
|
| 140 | }
|
| 141 |
|
| 142 | public IBakedModel makeBakedModel()
|
| 143 | {
|
| 144 | if (this.builderTexture == null)
|
| 145 | {
|
| 146 | throw new RuntimeException("Missing particle!");
|
| 147 | }
|
| 148 | else
|
| 149 | {
|
| 150 | return new SimpleBakedModel(this.builderGeneralQuads, this.builderFaceQuads, this.builderAmbientOcclusion, this.builderGui3d, this.builderTexture, this.builderCameraTransforms);
|
| 151 | }
|
| 152 | }
|
| 153 | }
|
| 154 | }
|
| 155 |
|