2020-09-09 16:48:43 +02:00
|
|
|
package de.ellpeck.actuallyadditions.blocks.render;
|
2018-06-24 02:44:47 +02:00
|
|
|
|
|
|
|
import com.google.common.collect.ImmutableList;
|
|
|
|
import com.google.common.collect.ImmutableMap;
|
|
|
|
import com.google.common.collect.Maps;
|
2020-09-07 20:33:27 +02:00
|
|
|
import net.minecraft.block.BlockState;
|
2018-06-24 02:44:47 +02:00
|
|
|
import net.minecraft.client.Minecraft;
|
2020-09-07 20:33:27 +02:00
|
|
|
import net.minecraft.client.renderer.model.BakedQuad;
|
|
|
|
import net.minecraft.client.renderer.model.IBakedModel;
|
|
|
|
import net.minecraft.client.renderer.model.ItemOverrideList;
|
2018-06-24 02:44:47 +02:00
|
|
|
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
2020-09-07 20:33:27 +02:00
|
|
|
import net.minecraft.util.Direction;
|
2018-06-24 02:44:47 +02:00
|
|
|
|
2020-09-07 20:33:27 +02:00
|
|
|
import javax.annotation.Nullable;
|
|
|
|
import java.util.EnumMap;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Random;
|
|
|
|
|
|
|
|
// todo: come back and fix this render as It's broken atm :cry:
|
2018-06-24 02:44:47 +02:00
|
|
|
public class CompostModel implements IBakedModel {
|
|
|
|
public static IBakedModel compostBase;
|
|
|
|
private final IBakedModel display;
|
|
|
|
private final ImmutableList<BakedQuad> general;
|
2020-09-07 20:33:27 +02:00
|
|
|
private final ImmutableMap<Direction, ImmutableList<BakedQuad>> faces;
|
2018-06-24 02:44:47 +02:00
|
|
|
|
2020-09-07 20:33:27 +02:00
|
|
|
public CompostModel(BlockState flowerState, float height) {
|
|
|
|
this.display = Minecraft.getInstance().getBlockRendererDispatcher().getModelForState(flowerState);
|
2019-02-27 19:53:05 +01:00
|
|
|
|
2020-09-07 20:33:27 +02:00
|
|
|
// TRSRTransformation transform = TRSRTransformation.blockCenterToCorner(new TRSRTransformation(new Vector3f(0, -.218F, 0), null, new Vector3f(0.75F, height / 1.81F, 0.75F), null));
|
2018-06-24 02:44:47 +02:00
|
|
|
|
|
|
|
ImmutableList.Builder<BakedQuad> builder;
|
2020-09-07 20:33:27 +02:00
|
|
|
EnumMap<Direction, ImmutableList<BakedQuad>> faces = new EnumMap<>(Direction.class);
|
2018-06-24 02:44:47 +02:00
|
|
|
|
2020-09-07 20:33:27 +02:00
|
|
|
for (Direction face : Direction.values()) {
|
2018-06-24 02:44:47 +02:00
|
|
|
builder = ImmutableList.builder();
|
2019-02-27 19:53:05 +01:00
|
|
|
if (!this.display.isBuiltInRenderer()) {
|
2020-09-07 20:33:27 +02:00
|
|
|
// for (BakedQuad quad : this.display.getQuads(flowerState, face, 0)) {
|
|
|
|
// Transformer transformer = new Transformer(transform, quad.getFormat());
|
|
|
|
// quad.pipe(transformer);
|
|
|
|
// builder.add(transformer.build());
|
|
|
|
// }
|
|
|
|
builder.addAll(compostBase.getQuads(null, face, new Random()));
|
2018-06-24 02:44:47 +02:00
|
|
|
}
|
|
|
|
faces.put(face, builder.build());
|
|
|
|
}
|
|
|
|
|
2019-02-27 19:53:05 +01:00
|
|
|
if (!this.display.isBuiltInRenderer()) {
|
2018-06-24 02:44:47 +02:00
|
|
|
builder = ImmutableList.builder();
|
2020-09-07 20:33:27 +02:00
|
|
|
// for (BakedQuad quad : this.display.getQuads(flowerState, null, 0)) {
|
|
|
|
// Transformer transformer = new Matrix4f(transform, quad.getFormat());
|
|
|
|
// quad.pipe(transformer);
|
|
|
|
// builder.add(transformer.build());
|
|
|
|
// }
|
|
|
|
builder.addAll(compostBase.getQuads(null, null, new Random()));
|
2018-06-24 02:44:47 +02:00
|
|
|
this.general = builder.build();
|
2019-02-27 19:53:05 +01:00
|
|
|
} else this.general = ImmutableList.of();
|
2018-06-24 02:44:47 +02:00
|
|
|
|
|
|
|
this.faces = Maps.immutableEnumMap(faces);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2020-09-07 20:33:27 +02:00
|
|
|
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand) {
|
2019-02-27 19:53:05 +01:00
|
|
|
if (side == null) return this.general;
|
|
|
|
return this.faces.get(side);
|
2018-06-24 02:44:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isAmbientOcclusion() {
|
2019-02-27 19:53:05 +01:00
|
|
|
return compostBase.isAmbientOcclusion() && this.display.isAmbientOcclusion();
|
2018-06-24 02:44:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isGui3d() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-09-07 20:33:27 +02:00
|
|
|
// No idea what this does.. Something? I'm sure
|
|
|
|
@Override
|
|
|
|
public boolean func_230044_c_() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-06-24 02:44:47 +02:00
|
|
|
@Override
|
|
|
|
public boolean isBuiltInRenderer() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public TextureAtlasSprite getParticleTexture() {
|
|
|
|
return compostBase.getParticleTexture();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public ItemOverrideList getOverrides() {
|
2020-09-07 20:33:27 +02:00
|
|
|
return ItemOverrideList.EMPTY;
|
2018-06-24 02:44:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|