Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package net.railsofwar.row.tracks;
- import com.google.common.base.Function;
- import com.google.common.collect.ImmutableMap;
- import com.google.common.collect.Lists;
- import net.minecraft.block.state.IBlockState;
- import net.minecraft.client.Minecraft;
- import net.minecraft.client.renderer.block.model.*;
- import net.minecraft.client.renderer.texture.TextureAtlasSprite;
- import net.minecraft.util.EnumFacing;
- import net.minecraft.util.ResourceLocation;
- import net.minecraftforge.client.model.*;
- import net.minecraftforge.client.model.obj.OBJModel;
- import net.minecraftforge.common.model.IModelState;
- import net.minecraftforge.common.model.TRSRTransformation;
- import net.minecraftforge.common.property.IExtendedBlockState;
- import javax.annotation.Nullable;
- import javax.vecmath.Quat4f;
- import javax.vecmath.Vector3f;
- import java.util.Collections;
- import java.util.List;
- public class ModelTrack implements IBakedModel {
- private IBakedModel defaultModel;
- public static final ModelResourceLocation modelResourceLocation
- = new ModelResourceLocation("row:blockTrack");
- public ModelTrack(IBakedModel defaultModel) {
- super();
- this.defaultModel = defaultModel;
- }
- public final float[][] states = new float[][]{{0.5F, 0.0F, 0.5F}};
- @Override
- public List<BakedQuad> getQuads(@Nullable IBlockState blockState, @Nullable EnumFacing side, long rand) {
- if (side != null) return Collections.emptyList();
- assert IExtendedBlockState.class.isAssignableFrom(blockState.getClass());
- IModel model = null;
- try {
- model = ModelLoaderRegistry.getModel(new ResourceLocation("row:block/blockTrack.obj"));
- model = ((IRetexturableModel)model)
- .retexture(ImmutableMap.of("#None", "row:block/blockTrack"));
- //model = ((IRetexturableModel) ((IModelCustomData) model).process(ImmutableMap.of("flip-v", "true")))
- // .retexture(ImmutableMap.of("#None", "row:block/blockTrack"));
- System.out.println("OLOLO ROW TEXTURE = " + Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite("row:block/blockTrack"));
- //model = ((IModelCustomData) model).process(ImmutableMap.of("ambientocclusion", "false"));
- } catch (Exception e) {
- e.printStackTrace();
- }
- float ang1 = (float) Math.toRadians(90F);
- float a1 = (float) Math.sin(ang1 / 2.0F);
- float w1 = (float) Math.cos(ang1 / 2.0F);
- IModelState modelState = new OBJModel.OBJState(
- Lists.newArrayList(OBJModel.Group.ALL),
- true,
- new TRSRTransformation(
- new Vector3f(.5F, 0F, .5F),
- new Quat4f(0F * a1, 1F * a1, 0F * a1, w1),
- new Vector3f(1.0F, 1.0F, 1.0F),
- null));
- for (ResourceLocation loc : model.getTextures()){
- System.out.println("ROW LOADED MODEL TEXTURES " + Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(loc.toString()));
- }
- System.out.println("ROW DEFAULT MODEL TEXTURE " + defaultModel.getParticleTexture().toString());
- if (model == null)
- return Collections.emptyList();
- else{
- IBakedModel bakedModel = model.bake(modelState, Attributes.DEFAULT_BAKED_FORMAT, ModelLoader.defaultTextureGetter());
- List<BakedQuad> quads = bakedModel.getQuads(blockState, side, rand);
- List<BakedQuad> defaultQuads = defaultModel.getQuads(blockState, side, rand);
- for (BakedQuad quad : quads){
- System.out.println("ROW LOADED QUADS TEXTURES " + quad.getSprite());
- }
- for (BakedQuad quad : defaultQuads){
- System.out.println("ROW DEFAULT QUADS TEXTURES " + quad.getSprite());
- }
- //return defaultModel.getQuads(blockState, side, rand);
- return quads;
- /*
- return model.bake(modelState, Attributes.DEFAULT_BAKED_FORMAT, new Function<ResourceLocation, TextureAtlasSprite>() {
- @Override
- public TextureAtlasSprite apply(ResourceLocation location) {
- Minecraft mc = Minecraft.getMinecraft();
- return mc.getTextureMapBlocks().getAtlasSprite(location.toString());
- }
- }).getQuads(blockState, side, rand);
- */
- }
- }
- @Override
- public TextureAtlasSprite getParticleTexture() {
- return defaultModel.getParticleTexture();
- }
- @Override
- public boolean isAmbientOcclusion() {
- return false;
- }
- @Override
- public boolean isGui3d() {
- return false;
- }
- @Override
- public boolean isBuiltInRenderer() {
- return false;
- }
- @Override
- public ItemCameraTransforms getItemCameraTransforms() {
- return null;
- }
- @Override
- public ItemOverrideList getOverrides() {
- return null;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement