Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
package spyeedy.mods.privy.dienddriver.client;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
import net.minecraft.client.renderer.block.model.ItemOverrideList;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler;
import org.apache.commons.lang3.tuple.Pair;
import javax.annotation.Nullable;
import javax.vecmath.Matrix4f;
import java.util.ArrayList;
import java.util.List;
public class BakedModelDiendDriverFinalised implements IBakedModel {
private IBakedModel mainModel;
private IBakedModel cardModel;
private ItemStack stack;
public BakedModelDiendDriverFinalised(IBakedModel mainModel, IBakedModel cardModel) {
this.mainModel = mainModel;
this.cardModel = cardModel;
this.stack = ItemStack.EMPTY;
}
public BakedModelDiendDriverFinalised setItemStack(ItemStack stack) {
this.stack = stack;
return this;
}
@Override
public List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, long rand) {
List<BakedQuad> quads = new ArrayList<>();
quads.addAll(mainModel.getQuads(state, side, rand));
if (!stack.isEmpty()) {
//ItemDiendDriver diendDriver = (ItemDiendDriver) stack.getItem();
IItemHandler diendCardInv = stack.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
if (!diendCardInv.getStackInSlot(0).isEmpty()) {
quads.addAll(cardModel.getQuads(state, side, rand));
}
}
return quads;
}
@Override
public boolean isAmbientOcclusion() {
return this.mainModel.isAmbientOcclusion();
}
@Override
public boolean isGui3d() {
return this.mainModel.isGui3d();
}
@Override
public boolean isBuiltInRenderer() {
return this.mainModel.isBuiltInRenderer();
}
@Override
public TextureAtlasSprite getParticleTexture() {
return this.mainModel.getParticleTexture();
}
@Override
public ItemOverrideList getOverrides() {
return this.mainModel.getOverrides();
}
@Override
public Pair<? extends IBakedModel, Matrix4f> handlePerspective(ItemCameraTransforms.TransformType cameraTransformType) {
return Pair.of(this, this.mainModel.handlePerspective(cameraTransformType).getRight());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.