Jump to content

Recommended Posts

Posted

Hey guys,

 

-EDIT-

 

Go to this post for cuz this issue was resolved :P

 

http://www.minecraftforge.net/forum/index.php/topic,32230.msg168433.html#msg168433

 

So I was trying to try a harder this than basic blocks and items and moved on to tile entites, YAY! Remarkable, I got them to work almost flawlessly, but one issue prevails, THE TEXTURES DON'T REGISTER. Here is what I mean:

 

 

SAJr3oa.png

 

 

Here is my folder structure:

 

 

M8bqppF.png

 

 

As you can see, the model for my tile entity works fine as there is a little thing sticking out from the top, I tried translating it and it looked good, but the block texture wont go away neither will the tile entity texture load, I also got this message in the console

 

[13:29:35] [Client thread/WARN]: Failed to load texture: rapierplus:blocks/tilemoulder.png
java.io.FileNotFoundException: rapierplus:blocks/tilemoulder.png

 

And here is my code for the Tile Entity Renderer:

 

 

package I_Iz_Shahids_Mods.net.RapierPlus.Render;

import java.util.Calendar;

import I_Iz_Shahids_Mods.net.RapierPlus.Main;
import I_Iz_Shahids_Mods.net.RapierPlus.Blocks.Entity.TileEntityMoulder;
import I_Iz_Shahids_Mods.net.RapierPlus.Models.Blocks.ModelMoulder;
import net.minecraft.block.Block;
import net.minecraft.block.BlockChest;
import net.minecraft.client.model.ModelChest;
import net.minecraft.client.model.ModelLargeChest;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityChest;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

@SideOnly(Side.CLIENT)
public class TileEntityMoulderRenderer extends TileEntitySpecialRenderer
{
private static final ResourceLocation textureNormal = new ResourceLocation(Main.MODID + ":" + "blocks/tilemoulder.png");
private ModelMoulder moulderModel = new ModelMoulder();

public TileEntityMoulderRenderer()
{

}

public void func_180538_a(TileEntityMoulder p_180535_1_, double p_180538_2_, double p_180538_4_, double p_180538_6_, float p_180538_8_, int p_180538_9_)
{


	ModelMoulder model;


	model = this.moulderModel;

	if (p_180538_9_ >= 0)
	{
		this.bindTexture(textureNormal);
		GlStateManager.matrixMode(5890);
		GlStateManager.pushMatrix();
		GlStateManager.scale(4.0F, 4.0F, 1.0F);
		GlStateManager.translate(0.0625F, 0.0625F, 0.0625F);
		GlStateManager.matrixMode(5888);
	}

	this.bindTexture(textureNormal);

	GlStateManager.pushMatrix();
	GlStateManager.enableRescaleNormal();

	if (p_180538_9_ < 0)
	{
		GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
	}

	GlStateManager.translate((float)p_180538_2_, (float)p_180538_4_ + 1.0F, (float)p_180538_6_ + 1.0F);
	GlStateManager.scale(1.0F, -1.0F, -1.0F);
	GlStateManager.translate(1F, 1F, 1F);
	short short1 = 0;

	GlStateManager.rotate((float)short1, 0.0F, 1.0F, 0.0F);
	GlStateManager.translate(-0.5F, -1.5F, -0.5F);
	model.renderAll();
	GlStateManager.disableRescaleNormal();
	GlStateManager.popMatrix();
	GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);

	if (p_180538_9_ >= 0)
	{
		GlStateManager.matrixMode(5890);
		GlStateManager.popMatrix();
		GlStateManager.matrixMode(5888);
	}

}

public void renderTileEntityAt(TileEntity p_180535_1_, double posX, double posZ, double p_180535_6_, float p_180535_8_, int p_180535_9_)
{
	this.func_180538_a((TileEntityMoulder)p_180535_1_, posX, posZ, p_180535_6_, p_180535_8_, p_180535_9_);
}
}

 

 

And finally my code for the block itself

 

 

package I_Iz_Shahids_Mods.net.RapierPlus.Blocks;

import java.util.Random;

import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyDirection;
import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.InventoryHelper;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import I_Iz_Shahids_Mods.net.RapierPlus.Main;
import I_Iz_Shahids_Mods.net.RapierPlus.Blocks.Entity.TileEntityMoulder;

public class Moulder
extends BlockContainer
{
    public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL);
    private static boolean hasTileEntity;

    public final static String name = "moulder";

    public Moulder()
    {
        super(Material.rock);
        setUnlocalizedName("Moulder");
        setDefaultState(blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH));
        setCreativeTab(Main.tabRapier);
        stepSound = soundTypeSnow;
        blockParticleGravity = 1.0F;
        slipperiness = 0.6F;
        setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
        lightOpacity = 20; // cast a light shadow
        setTickRandomly(false);
        useNeighborBrightness = false;
    }
    public boolean shouldSideBeRendered(IBlockAccess iblockaccess, int i, int j, int k, int l)
    {
       return false;
    }
    public boolean isFullCube()
    {
    	return false;
    }
    public boolean isOpaqueCube()
    {
	return false;
    }
    @Override
    public Item getItemDropped(IBlockState state, Random rand, int fortune)
    {
        return Item.getItemFromBlock(Main.moulder);
    }

    @Override
    public void onBlockAdded(World parWorld, BlockPos parBlockPos, IBlockState parIBlockState)
    {
        if (!parWorld.isRemote)
        {
            // Rotate block if the front side is blocked
            Block blockToNorth = parWorld.getBlockState(parBlockPos.offset(EnumFacing.NORTH)).getBlock();
            Block blockToSouth = parWorld.getBlockState(parBlockPos.offset(EnumFacing.SOUTH)).getBlock();
            Block blockToWest = parWorld.getBlockState(parBlockPos.offset(EnumFacing.WEST)).getBlock();
            Block blockToEast = parWorld.getBlockState(parBlockPos.offset(EnumFacing.EAST)).getBlock();
            EnumFacing enumfacing = (EnumFacing)parIBlockState.getValue(FACING);

            if (enumfacing == EnumFacing.NORTH 
                  && blockToNorth.isFullBlock() 
                  && !blockToSouth.isFullBlock())
            {
                enumfacing = EnumFacing.SOUTH;
            }
            else if (enumfacing == EnumFacing.SOUTH 
                  && blockToSouth.isFullBlock() 
                  && !blockToNorth.isFullBlock())
            {
                enumfacing = EnumFacing.NORTH;
            }
            else if (enumfacing == EnumFacing.WEST 
                  && blockToWest.isFullBlock() 
                  && !blockToEast.isFullBlock())
            {
                enumfacing = EnumFacing.EAST;
            }
            else if (enumfacing == EnumFacing.EAST 
                  && blockToEast.isFullBlock() 
                  && !blockToWest.isFullBlock())
            {
                enumfacing = EnumFacing.WEST;
            }

            parWorld.setBlockState(parBlockPos, parIBlockState
                  .withProperty(FACING, enumfacing), 2);
        }
    }

    @Override
    public boolean onBlockActivated(World parWorld, BlockPos parBlockPos, IBlockState parIBlockState, 
          EntityPlayer parPlayer, EnumFacing parSide, float hitX, float hitY, float hitZ)
    {
        if (!parWorld.isRemote)
        {
            parPlayer.openGui(Main.Instance, 
                  Main.GUI_ENUM.MOULDER.ordinal(), 
                  parWorld, 
                  parBlockPos.getX(), 
                  parBlockPos.getY(), 
                  parBlockPos.getZ()); 
        }
        
        return true;
    }

    @Override
    public TileEntity createNewTileEntity(World worldIn, int meta)
    {
     // DEBUG
     System.out.println("Moulder createNewTileEntity()");
        return new TileEntityMoulder();
    }

    @Override
    public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing,
    		float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
    {
        return getDefaultState().withProperty(FACING, placer.getHorizontalFacing().getOpposite());
    }

    @Override
    public void onBlockPlacedBy(
          World worldIn, 
          BlockPos pos, 
          IBlockState state, 
          EntityLivingBase placer, 
          ItemStack stack)
    {
        worldIn.setBlockState(pos, state.withProperty(FACING, placer.getHorizontalFacing().getOpposite()), 2);
    }

    @Override
    public void breakBlock(
          World worldIn, 
          BlockPos pos, 
          IBlockState state)
    {
        if (!hasTileEntity)
        {
            TileEntity tileentity = worldIn.getTileEntity(pos);

            if (tileentity instanceof TileEntityMoulder)
            {
                InventoryHelper.dropInventoryItems(worldIn, pos, (TileEntityMoulder)tileentity);
                worldIn.updateComparatorOutputLevel(pos, this);
            }
        }

        super.breakBlock(worldIn, pos, state);
    }

    @Override
    @SideOnly(Side.CLIENT)
    public Item getItem(World worldIn, BlockPos pos)
    {
        return Item.getItemFromBlock(Main.moulder);
    }

    @Override
    public int getRenderType()
    {
        return 3;
    }
    @Override
    @SideOnly(Side.CLIENT)
    public IBlockState getStateForEntityRender(IBlockState state)
    {
        return getDefaultState().withProperty(FACING, EnumFacing.SOUTH);
    }

    @Override
    public IBlockState getStateFromMeta(int meta)
    {
        EnumFacing enumfacing = EnumFacing.getFront(meta);

        if (enumfacing.getAxis() == EnumFacing.Axis.Y)
        {
            enumfacing = EnumFacing.NORTH;
        }

        return getDefaultState().withProperty(FACING, enumfacing);
    }

    @Override
    public int getMetaFromState(IBlockState state)
    {
        return ((EnumFacing)state.getValue(FACING)).getIndex();
    }

    @Override
    protected BlockState createBlockState()
    {
        return new BlockState(this, new IProperty[] {FACING});
    }

    @SideOnly(Side.CLIENT)
    static final class SwitchEnumFacing
    {
        static final int[] enumFacingArray = new int[EnumFacing.values().length];

        static
        {
            try
            {
                enumFacingArray[EnumFacing.WEST.ordinal()] = 1;
            }
            catch (NoSuchFieldError var4)
            {
                ;
            }

            try
            {
                enumFacingArray[EnumFacing.EAST.ordinal()] = 2;
            }
            catch (NoSuchFieldError var3)
            {
                ;
            }

            try
            {
                enumFacingArray[EnumFacing.NORTH.ordinal()] = 3;
            }
            catch (NoSuchFieldError var2)
            {
                ;
            }

            try
            {
                enumFacingArray[EnumFacing.SOUTH.ordinal()] = 4;
            }
            catch (NoSuchFieldError var1)
            {
                // You should improve the error handling here
            }
        }
    }    
    public String getName()
    {
    	return name;
    }
}

 

 

if(pain == 0)

{

   gain = 0;

}

Posted

Well the problem is that it cant find the file. What is the workspace location of the tilemoulder.png

 

you can see it in the folder structure, which is in modid/textures/blocks/tilemoulder.png

if(pain == 0)

{

   gain = 0;

}

Posted

The file is in textures/blocks/, but your ResourceLocation tells minecraft to look in blocks/ - without textures.

 

MY GOD, Thank you so much man! That's one hurdle outta the way, but now another :S. This is what it looks like now, the texture is loaded, i just need to adjust the lighting a bit

 

 

rQk1NTt.png

 

 

I can't get that block outta the way :/

 

Here are my JSON files:

 

Blockstates:

 

{
"variants": {
	"normal": { "model": "rapierplus:moulder" }
}
}

 

 

Items:

 

items:
{
"parent": "rapierplus:block/moulder",
"display": {
	"thirdperson": {
		"rotation": [ 10, -45, 170 ],
		"translation": [ 0, 1.5, -2.75 ],
		"scale": [ 0.375, 0.375, 0.375 ]
	}
}
}

 

 

Blocks:

 

{
"parent": "block/cube_all",
"textures": {
	"all": "rapierplus:blocks/moulder.png"
}
}

 

if(pain == 0)

{

   gain = 0;

}

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.