Jump to content

[1.5.2] How to make a block show the texture of the block it's touching?


AskHow1248

Recommended Posts

  I'm trying to make a block that blends in with it's surroundings, like a Ars Magica Illusion Block or a secret Rooms Mod Camo Block.  I have absolutely no idea how to go about this.  Any help would be appreciated.

 

update:  I think it might have something to do with the getBlockTexture method in the Block class.

Link to comment
Share on other sites

Hi.

 

I would suggest writing some custom rendering code for your block that looks to see what the adjacent block is and either copies its texture, or calls the rendering code for that block directly. 

 

A couple of keywords to search for:

ISimpleBlockRenderingHandler and

RenderBlocks.renderBlockByRenderType and

Block.getIcon

 

This link might help to understand how block rendering works:

 

http://greyminecraftcoder.blogspot.com.au/2013/07/block-rendering.html

 

with more detail:

 

http://greyminecraftcoder.blogspot.com.au/p/list-of-topics.html

 

Cheers  TGG

Link to comment
Share on other sites

Even simpler, you could create a TileEntity when the block is placed and simply store the Icon of the block next to it. Then override getBlockTexture() and return the icon stored in the TileEntity.

 

Hint:

 

        int ID = world.getBlockId(x, y+1, z); // change this as needed, maybe x+1, y-1, etc.
        int meta = world.getBlockMetadata(x, y+1, z); // change this as needed, maybe x+1, y-1, etc.
        int side = 0; // change this as needed
        
        // Icon ico = Block.blocksList[iD].getIcon(side, meta); // Use for blocks in hand / Creative tab
        Icon ico = Block.blocksList[iD].getBlockTexture(IBlockAccess, x, y, z, side); // Use for blocks placed in world

 

Edit:

 

modified example to include getBlockTexture()

Link to comment
Share on other sites

another update:  I have a method to get the block i wand to model, but am not sure what to do from there.  Is there a way to get and use the texture of a whole block (getIcon uses sides)?

 

getIcon() and getBlockTexture() use sides because of the multi-texture capability of blocks. You can get around this pretty simply though by incrementing the side and storing the result in an array.

 

Note: In your case you really want getBlockTexture() which is called for blocks in the world, getIcon() is called for blocks in your inventory and Creative tabs.

 

Here's some rough code:

 

Icon blockTextures[6];    // All blocks have 6 sides
int blockID = 0;  // you will need to get this by adapting my hint above

for (int side = 0; side < blockTextures.length; side++)
{
    blockTextures[side] = Block.blocksList[blockID].getBlockTexture(IBlockAccess, x, y, z, side);
}

 

Then when you override getBlockTexture() for your block you can return an array element based on the side the function is requesting.

 

If you don't want to mess with arrays, you could concievably just return the Icon from the block next to yours by using the opposite side. If the game is asking for (side=1) of your block then it would be (side=0) of the neighboring block that is touching your block so return its Icon instead.

Link to comment
Share on other sites

I think I have the texture code working but when I try to place an Illusion Block I get a ClassCastException.

Code:

 

 

Main Class:

--------------------------------------------------------------------------------------------------------------------------------------------------------

package RickyRyan.mod.SmokeAndMirrors.common;

 

 

 

import RickyRyan.mod.SmokeAndMirrors.Block.BlockIllusionBlock;

import net.minecraft.block.Block;

import net.minecraft.block.material.Material;

import net.minecraft.creativetab.CreativeTabs;

import net.minecraft.item.Item;

import net.minecraftforge.common.MinecraftForge;

import cpw.mods.fml.common.Mod;

import cpw.mods.fml.common.Mod.Init;

import cpw.mods.fml.common.event.FMLInitializationEvent;

import cpw.mods.fml.common.network.NetworkMod;

import cpw.mods.fml.common.registry.GameRegistry;

import cpw.mods.fml.common.registry.LanguageRegistry;

 

 

 

@Mod(modid = "SmokeAndMirrors", name = "SmokeAndMirrors", version = "pre 1.0")

@NetworkMod(clientSideRequired = true, serverSideRequired = false)

public class SmokeAndMirrors {

 

 

public static Block IllusionBlock;

 

 

 

 

 

 

 

 

 

@Init

public void load(FMLInitializationEvent event) {

 

IllusionBlock = new BlockIllusionBlock(3000, Material.rock).setUnlocalizedName("IllusionBlock").setCreativeTab(CreativeTabs.tabBlock).setHardness(10.0F).setResistance(1000.0F);

 

 

GameRegistry.registerTileEntity(RickyRyan.mod.SmokeAndMirrors.TileEntity.TileEntityIllusionBlock.class, "stringID");

 

MinecraftForge.setBlockHarvestLevel(IllusionBlock, "pickaxe", 2);

 

 

GameRegistry.registerBlock(IllusionBlock);

 

 

LanguageRegistry.addName(IllusionBlock, "Illusion Block");

 

}

}

 

--------------------------------------------------------------------------------------------------------------------------------------------------------

Block (IllusionBlock):

--------------------------------------------------------------------------------------------------------------------------------------------------------

package RickyRyan.mod.SmokeAndMirrors.Block;

 

import RickyRyan.mod.SmokeAndMirrors.TileEntity.TileEntityIllusionBlock;

import net.minecraft.block.Block;

import net.minecraft.block.material.Material;

import net.minecraft.client.renderer.texture.IconRegister;

import net.minecraft.tileentity.TileEntity;

import net.minecraft.util.AxisAlignedBB;

import net.minecraft.util.Icon;

import net.minecraft.world.IBlockAccess;

import net.minecraft.world.World;

 

public class BlockIllusionBlock extends Block {

 

public BlockIllusionBlock(int par1, Material par2Material) {

super(par1, par2Material);

setBlockBounds(0F, 0F, 0F, 1F, 1F, 1F);

}

 

public TileEntity createTileEntity(World world, int metadata)

{

  return new TileEntityIllusionBlock();

}

 

@Override

public Icon getBlockTexture(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5) {

 

TileEntity tile = createTileEntity((World)par1IBlockAccess, 1);

if(tile != null) {

Icon[] IconArray = ((TileEntityIllusionBlock) tile).getTextureToModel(par2, par3, par4);

 

return IconArray[par5];

 

} else {

return null;

}

 

 

}

 

 

 

 

 

 

public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int i, int j, int k)

    {

            return null;

    }

 

public boolean isOpaqueCube()

    {

        return false;

    }

 

//look into getBlockTexture in Block

 

 

 

 

 

public boolean renderAsNormalBlock()

    {

        return false;

    }

 

public int getRenderType()

    {

        return 0;

    }

 

}

--------------------------------------------------------------------------------------------------------------------------------------------------------

TileEntity:

--------------------------------------------------------------------------------------------------------------------------------------------------------

package RickyRyan.mod.SmokeAndMirrors.TileEntity;

 

import java.math.*;

import java.util.ArrayList;

 

import net.minecraft.block.Block;

import net.minecraft.client.renderer.texture.Texture;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.nbt.NBTTagCompound;

import net.minecraft.tileentity.TileEntity;

import net.minecraft.util.Icon;

 

public class TileEntityIllusionBlock extends TileEntity{

 

private int x = this.xCoord;

private int y = this.yCoord;

private int z = this.zCoord;

 

@Override

  public void writeToNBT(NBTTagCompound par1)

  {

      super.writeToNBT(par1);

      //par1.setInteger("customField", customField);

      par1.setInteger("xCord", x);

      par1.setInteger("yCord", y);

      par1.setInteger("zCord", z);

  }

 

  @Override

  public void readFromNBT(NBTTagCompound par1)

  {

      super.readFromNBT(par1);

      //this.customField = par1.getInteger("customField");

      this.x = par1.getInteger("xCord");

      this.y = par1.getInteger("yCord");

      this.z = par1.getInteger("zCord");

  }

 

 

public Icon[] getTextureToModel(int x, int y, int z) {

 

Block blockToModel = null;

Icon side1 = null;

Icon side2 = null;

Icon side3 = null;

Icon side4 = null;

Icon side5 = null;

Icon side6 = null;

 

if (!worldObj.isAirBlock((int)(x + 1), (int)(y), (int)(z))) {

int blockId = worldObj.getBlockId((int)(x + 1), (int)(y), (int)(z));

 

blockToModel = Block.blocksList[blockId];

side1 = blockToModel.getBlockTexture(worldObj, x + 1, y, z, 1);

side2 = blockToModel.getBlockTexture(worldObj, x + 1, y, z, 2);

side3 = blockToModel.getBlockTexture(worldObj, x + 1, y, z, 3);

side4 = blockToModel.getBlockTexture(worldObj, x + 1, y, z, 4);

side5 = blockToModel.getBlockTexture(worldObj, x + 1, y, z, 5);

side6 = blockToModel.getBlockTexture(worldObj, x + 1, y, z, 6);

 

} else if (!worldObj.isAirBlock((int)(x - 1), (int)(y), (int)(z))) {

int blockId = worldObj.getBlockId((int)(x - 1), (int)(y), (int)(z));

 

blockToModel = Block.blocksList[blockId];

side1 = blockToModel.getBlockTexture(worldObj, x - 1, y, z, 1);

side2 = blockToModel.getBlockTexture(worldObj, x - 1, y, z, 2);

side3 = blockToModel.getBlockTexture(worldObj, x - 1, y, z, 3);

side4 = blockToModel.getBlockTexture(worldObj, x - 1, y, z, 4);

side5 = blockToModel.getBlockTexture(worldObj, x - 1, y, z, 5);

side6 = blockToModel.getBlockTexture(worldObj, x - 1, y, z, 6);

 

}  else if (!worldObj.isAirBlock((int)(x), (int)(y + 1), (int)(z))) {

int blockId = worldObj.getBlockId((int)(x), (int)(y + 1), (int)(z));

 

blockToModel = Block.blocksList[blockId];

side1 = blockToModel.getBlockTexture(worldObj, x, y + 1, z, 1);

side2 = blockToModel.getBlockTexture(worldObj, x, y + 1, z, 2);

side3 = blockToModel.getBlockTexture(worldObj, x, y + 1, z, 3);

side4 = blockToModel.getBlockTexture(worldObj, x, y + 1, z, 4);

side5 = blockToModel.getBlockTexture(worldObj, x, y + 1, z, 5);

side6 = blockToModel.getBlockTexture(worldObj, x, y + 1, z, 6);

 

} else if (!worldObj.isAirBlock((int)(x), (int)(y - 1), (int)(z))) {

int blockId = worldObj.getBlockId((int)(x), (int)(y - 1), (int)(z));

 

blockToModel = Block.blocksList[blockId];

side1 = blockToModel.getBlockTexture(worldObj, x, y - 1, z, 1);

side2 = blockToModel.getBlockTexture(worldObj, x, y - 1, z, 2);

side3 = blockToModel.getBlockTexture(worldObj, x, y - 1, z, 3);

side4 = blockToModel.getBlockTexture(worldObj, x, y - 1, z, 4);

side5 = blockToModel.getBlockTexture(worldObj, x, y - 1, z, 5);

side6 = blockToModel.getBlockTexture(worldObj, x, y - 1, z, 6);

 

}  else if (!worldObj.isAirBlock((int)(x), (int)(y), (int)(z + 1))) {

int blockId = worldObj.getBlockId((int)(x), (int)(y), (int)(z + 1));

 

blockToModel = Block.blocksList[blockId];

side1 = blockToModel.getBlockTexture(worldObj, x, y, z + 1, 1);

side2 = blockToModel.getBlockTexture(worldObj, x, y, z + 1, 2);

side3 = blockToModel.getBlockTexture(worldObj, x, y, z + 1, 3);

side4 = blockToModel.getBlockTexture(worldObj, x, y, z + 1, 4);

side5 = blockToModel.getBlockTexture(worldObj, x, y, z + 1, 5);

side6 = blockToModel.getBlockTexture(worldObj, x, y, z + 1, 6);

 

}  else if (!worldObj.isAirBlock((int)(x), (int)(y), (int)(z - 1))) {

int blockId = worldObj.getBlockId((int)(x), (int)(y), (int)(z - 1));

 

blockToModel = Block.blocksList[blockId];

side1 = blockToModel.getBlockTexture(worldObj, x, y, z - 1, 1);

side2 = blockToModel.getBlockTexture(worldObj, x, y, z - 1, 2);

side3 = blockToModel.getBlockTexture(worldObj, x, y, z - 1, 3);

side4 = blockToModel.getBlockTexture(worldObj, x, y, z - 1, 4);

side5 = blockToModel.getBlockTexture(worldObj, x, y, z - 1, 5);

side6 = blockToModel.getBlockTexture(worldObj, x, y, z - 1, 6);

 

} else {

 

int xToCheck = x + 1;

int yToCheck = y;

int zToCheck = z + 0;

 

 

do {

xToCheck = x + 1;

yToCheck = y;

zToCheck = z + 0;

 

 

if (!worldObj.isAirBlock((int)(xToCheck), (int)(yToCheck), (int)(zToCheck))) {

int blockId = worldObj.getBlockId((int)(x), (int)(y), (int)(z - 1));

 

blockToModel = Block.blocksList[blockId];

 

side1 = blockToModel.getBlockTexture(worldObj, xToCheck, yToCheck, zToCheck, 1);

side2 = blockToModel.getBlockTexture(worldObj, xToCheck, yToCheck, zToCheck, 2);

side3 = blockToModel.getBlockTexture(worldObj, xToCheck, yToCheck, zToCheck, 3);

side4 = blockToModel.getBlockTexture(worldObj, xToCheck, yToCheck, zToCheck, 4);

side5 = blockToModel.getBlockTexture(worldObj, xToCheck, yToCheck, zToCheck, 5);

side6 = blockToModel.getBlockTexture(worldObj, xToCheck, yToCheck, zToCheck, 6);

}

 

 

} while (!worldObj.isAirBlock((int)(xToCheck), (int)(yToCheck), (int)(zToCheck)));

 

 

 

 

}

 

 

Icon[] IconArray = {side1, side2, side3, side4, side5, side6};

 

return IconArray;

 

 

 

 

 

}

 

 

 

 

 

 

 

 

 

}

 

--------------------------------------------------------------------------------------------------------------------------------------------------------

Forge Error Log:

--------------------------------------------------------------------------------------------------------------------------------------------------------

 

---- Minecraft Crash Report ----

// Sorry :(

 

Time: 9/14/13 8:04 PM

Description: Unexpected error

 

java.lang.ClassCastException: net.minecraft.world.ChunkCache cannot be cast to net.minecraft.world.World

at RickyRyan.mod.SmokeAndMirrors.Block.BlockIllusionBlock.getBlockTexture(BlockIllusionBlock.java:28)

at net.minecraft.client.renderer.RenderBlocks.getBlockIcon(RenderBlocks.java:8141)

at net.minecraft.client.renderer.RenderBlocks.renderStandardBlockWithAmbientOcclusion(RenderBlocks.java:4468)

at net.minecraft.client.renderer.RenderBlocks.renderStandardBlock(RenderBlocks.java:4163)

at net.minecraft.client.renderer.RenderBlocks.renderBlockByRenderType(RenderBlocks.java:445)

at net.minecraft.client.renderer.WorldRenderer.updateRenderer(WorldRenderer.java:226)

at net.minecraft.client.renderer.RenderGlobal.updateRenderers(RenderGlobal.java:1535)

at net.minecraft.client.renderer.EntityRenderer.renderWorld(EntityRenderer.java:1119)

at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:991)

at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:871)

at net.minecraft.client.Minecraft.run(Minecraft.java:760)

at java.lang.Thread.run(Unknown Source)

 

 

A detailed walkthrough of the error, its code path and all known details is as follows:

---------------------------------------------------------------------------------------

 

-- Head --

Stacktrace:

at RickyRyan.mod.SmokeAndMirrors.Block.BlockIllusionBlock.getBlockTexture(BlockIllusionBlock.java:28)

at net.minecraft.client.renderer.RenderBlocks.getBlockIcon(RenderBlocks.java:8141)

at net.minecraft.client.renderer.RenderBlocks.renderStandardBlockWithAmbientOcclusion(RenderBlocks.java:4468)

at net.minecraft.client.renderer.RenderBlocks.renderStandardBlock(RenderBlocks.java:4163)

at net.minecraft.client.renderer.RenderBlocks.renderBlockByRenderType(RenderBlocks.java:445)

at net.minecraft.client.renderer.WorldRenderer.updateRenderer(WorldRenderer.java:226)

at net.minecraft.client.renderer.RenderGlobal.updateRenderers(RenderGlobal.java:1535)

at net.minecraft.client.renderer.EntityRenderer.renderWorld(EntityRenderer.java:1119)

 

-- Affected level --

Details:

Level name: MpServer

All players: 1 total; [EntityClientPlayerMP['Player871'/166, l='MpServer', x=135.12, y=70.62, z=179.91]]

Chunk stats: MultiplayerChunkCache: 441

Level seed: 0

Level generator: ID 00 - default, ver 1. Features enabled: false

Level generator options:

Level spawn location: World: (132,64,188), Chunk: (at 4,4,12 in 8,11; contains blocks 128,0,176 to 143,255,191), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511)

Level time: 552 game time, 552 day time

Level dimension: 0

Level storage version: 0x00000 - Unknown?

Level weather: Rain time: 0 (now: false), thunder time: 0 (now: false)

Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: false

Forced entities: 85 total; [EntityPig['Pig'/55, l='MpServer', x=61.50, y=63.00, z=154.50], EntityPig['Pig'/54, l='MpServer', x=61.66, y=63.00, z=156.31], EntityPig['Pig'/53, l='MpServer', x=54.94, y=63.00, z=154.97], EntityPig['Pig'/52, l='MpServer', x=66.50, y=63.00, z=156.50], EntityPig['Pig'/59, l='MpServer', x=75.75, y=65.00, z=105.41], EntityPig['Pig'/58, l='MpServer', x=70.50, y=66.00, z=106.81], EntityPig['Pig'/57, l='MpServer', x=74.50, y=65.00, z=104.50], EntityCow['Cow'/63, l='MpServer', x=81.31, y=67.00, z=229.66], EntityCow['Cow'/62, l='MpServer', x=78.72, y=68.00, z=228.50], EntityCow['Cow'/61, l='MpServer', x=83.50, y=67.00, z=231.50], EntityPig['Pig'/60, l='MpServer', x=68.09, y=66.00, z=103.88], EntityCow['Cow'/68, l='MpServer', x=78.50, y=68.00, z=232.50], EntityCow['Cow'/64, l='MpServer', x=77.47, y=68.00, z=228.50], EntityCow['Cow'/65, l='MpServer', x=76.50, y=67.00, z=235.50], EntityCow['Cow'/66, l='MpServer', x=71.19, y=63.00, z=244.56], EntityCow['Cow'/67, l='MpServer', x=80.50, y=67.00, z=234.19], EntityPig['Pig'/76, l='MpServer', x=108.50, y=64.00, z=131.50], EntityPig['Pig'/73, l='MpServer', x=105.50, y=64.00, z=124.22], EntityPig['Pig'/74, l='MpServer', x=105.50, y=64.00, z=125.81], EntityPig['Pig'/75, l='MpServer', x=111.78, y=64.00, z=128.44], EntityPig['Pig'/85, l='MpServer', x=136.76, y=66.00, z=192.38], EntityPig['Pig'/84, l='MpServer', x=129.75, y=66.00, z=189.50], EntityPig['Pig'/87, l='MpServer', x=125.03, y=65.00, z=189.84], EntityPig['Pig'/86, l='MpServer', x=133.44, y=65.00, z=193.31], EntityPig['Pig'/81, l='MpServer', x=132.50, y=64.00, z=124.84], EntityPig['Pig'/80, l='MpServer', x=139.91, y=63.00, z=117.16], EntityPig['Pig'/83, l='MpServer', x=135.50, y=61.29, z=114.50], EntityPig['Pig'/82, l='MpServer', x=132.19, y=63.00, z=116.38], EntityCow['Cow'/95, l='MpServer', x=155.50, y=69.00, z=237.50], EntityCow['Cow'/94, l='MpServer', x=156.50, y=69.00, z=234.50], EntityCow['Cow'/96, l='MpServer', x=156.50, y=69.00, z=239.50], EntityCow['Cow'/97, l='MpServer', x=153.50, y=69.00, z=240.50], EntitySquid['Squid'/208, l='MpServer', x=75.16, y=61.00, z=195.03], EntitySquid['Squid'/209, l='MpServer', x=79.28, y=61.00, z=190.72], EntitySquid['Squid'/210, l='MpServer', x=90.22, y=62.00, z=198.50], EntitySquid['Squid'/211, l='MpServer', x=85.41, y=61.34, z=192.69], EntityBat['Bat'/270, l='MpServer', x=61.07, y=19.00, z=184.01], EntityBat['Bat'/268, l='MpServer', x=57.75, y=19.10, z=187.75], EntityBat['Bat'/269, l='MpServer', x=61.55, y=18.05, z=184.61], EntityBat['Bat'/333, l='MpServer', x=91.52, y=16.88, z=170.25], EntityZombie['Zombie'/403, l='MpServer', x=102.50, y=44.00, z=178.50], EntityZombie['Zombie'/404, l='MpServer', x=101.97, y=45.00, z=171.50], EntityZombie['Zombie'/405, l='MpServer', x=103.44, y=44.00, z=180.50], EntityBat['Bat'/457, l='MpServer', x=59.50, y=28.58, z=177.52], EntityItem['item.tile.sapling.oak'/4337, l='MpServer', x=87.00, y=73.13, z=122.22], EntitySpider['Spider'/565, l='MpServer', x=57.13, y=27.00, z=180.72], EntityZombie['Zombie'/515, l='MpServer', x=128.50, y=38.00, z=148.50], EntityBat['Bat'/532, l='MpServer', x=102.76, y=53.29, z=139.80], EntityCreeper['Creeper'/610, l='MpServer', x=55.50, y=21.00, z=200.50], EntityBat['Bat'/617, l='MpServer', x=73.60, y=43.17, z=170.34], EntityBat['Bat'/578, l='MpServer', x=67.48, y=25.73, z=193.82], EntitySpider['Spider'/683, l='MpServer', x=102.56, y=37.00, z=155.28], EntitySkeleton['Skeleton'/767, l='MpServer', x=94.50, y=59.00, z=160.50], EntitySkeleton['Skeleton'/755, l='MpServer', x=96.50, y=16.00, z=199.50], EntityCreeper['Creeper'/756, l='MpServer', x=99.91, y=15.00, z=200.25], EntitySkeleton['Skeleton'/715, l='MpServer', x=104.50, y=20.00, z=183.47], EntityZombie['Zombie'/714, l='MpServer', x=101.50, y=21.00, z=182.50], EntitySkeleton['Skeleton'/725, l='MpServer', x=105.50, y=29.00, z=136.50], EntitySkeleton['Skeleton'/831, l='MpServer', x=95.56, y=51.00, z=209.06], EntityZombie['Zombie'/826, l='MpServer', x=169.50, y=34.00, z=134.50], EntityZombie['Zombie'/890, l='MpServer', x=191.50, y=43.00, z=124.50], EntitySkeleton['Skeleton'/879, l='MpServer', x=131.50, y=32.00, z=99.50], EntitySpider['Spider'/850, l='MpServer', x=112.50, y=33.00, z=154.50], EntityCreeper['Creeper'/863, l='MpServer', x=59.50, y=32.00, z=201.50], EntityCreeper['Creeper'/862, l='MpServer', x=63.56, y=33.00, z=208.06], EntityCreeper['Creeper'/861, l='MpServer', x=61.31, y=32.00, z=205.06], EntitySpider['Spider'/834, l='MpServer', x=104.63, y=49.00, z=203.97], EntitySkeleton['Skeleton'/832, l='MpServer', x=106.50, y=49.00, z=203.50], EntitySkeleton['Skeleton'/833, l='MpServer', x=103.50, y=49.00, z=202.50], EntityCreeper['Creeper'/956, l='MpServer', x=150.50, y=39.00, z=200.50], EntityCreeper['Creeper'/955, l='MpServer', x=151.50, y=39.00, z=199.50], EntityZombie['Zombie'/914, l='MpServer', x=136.50, y=16.00, z=196.50], EntitySkeleton['Skeleton'/913, l='MpServer', x=141.50, y=16.00, z=194.50], EntitySkeleton['Skeleton'/1018, l='MpServer', x=99.50, y=29.00, z=128.50], EntitySkeleton['Skeleton'/1019, l='MpServer', x=98.50, y=29.00, z=130.50], EntityZombie['Zombie'/1020, l='MpServer', x=139.00, y=35.00, z=110.56], EntityClientPlayerMP['Player871'/166, l='MpServer', x=135.12, y=70.62, z=179.91], EntityZombie['Zombie'/1079, l='MpServer', x=194.50, y=51.00, z=151.50], EntityCreeper['Creeper'/9486, l='MpServer', x=113.50, y=51.00, z=200.50], EntityZombie['Zombie'/9487, l='MpServer', x=106.13, y=49.00, z=202.64], EntityItem['item.item.sulphur'/9504, l='MpServer', x=78.65, y=35.46, z=191.36], EntityCreeper['Creeper'/9548, l='MpServer', x=64.50, y=25.00, z=204.50], EntityCreeper['Creeper'/9549, l='MpServer', x=67.50, y=25.00, z=206.50], EntitySkeleton['Skeleton'/9571, l='MpServer', x=112.50, y=37.00, z=159.50], EntityItem['item.tile.sapling.oak'/7386, l='MpServer', x=79.19, y=69.13, z=144.78]]

Retry entities: 0 total; []

Stacktrace:

at net.minecraft.client.multiplayer.WorldClient.addWorldInfoToCrashReport(WorldClient.java:441)

at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:2414)

at net.minecraft.client.Minecraft.run(Minecraft.java:783)

at java.lang.Thread.run(Unknown Source)

 

-- System Details --

Details:

Minecraft Version: 1.5.2

Operating System: Windows 7 (x86) version 6.1

Java Version: 1.7.0_25, Oracle Corporation

Java VM Version: Java HotSpot Client VM (mixed mode), Oracle Corporation

Memory: 790166544 bytes (753 MB) / 1060372480 bytes (1011 MB) up to 1060372480 bytes (1011 MB)

JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M

AABB Pool Size: 39218 (2196208 bytes; 2 MB) allocated, 3373 (188888 bytes; 0 MB) used

Suspicious classes: FML and Forge are installed

IntCache: cache: 0, tcache: 0, allocated: 3, tallocated: 63

FML: MCP v7.51 FML v5.2.23.737 Minecraft Forge 7.8.1.737 4 mods loaded, 4 mods active

mcp{7.51} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available

FML{5.2.23.737} [Forge Mod Loader] (coremods) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available

Forge{7.8.1.737} [Minecraft Forge] (coremods) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available

SmokeAndMirrors{pre 1.0} [smokeAndMirrors] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available

LWJGL: 2.4.2

OpenGL: Intel® HD Graphics Family GL version 3.0.0 - Build 8.15.10.2353, Intel

Is Modded: Definitely; Client brand changed to 'fml,forge'

Type: Client (map_client.txt)

Texture Pack: Default

Profiler Position: N/A (disabled)

Vec3 Pool Size: 5557 (311192 bytes; 0 MB) allocated, 1331 (74536 bytes; 0 MB) used

 

--------------------------------------------------------------------------------------------------------------------------------------------------------

[spoiler/]

Some of the code is rather messy, but I think it should work.  If you see an error please tell me. (I can give you the .java files if I have to) (the extra code is to make it so I can walk through the block)

Link to comment
Share on other sites

Hi

 

A couple of comments

1) If you're using the approach with the TileEntity, you need to create the entity when you place the block, not each time it's rendered.  eg Block.createTileEntity  - see also code in BlockSign.  To be honest I think you haven't really understood what Lycanus was suggesting.  Although using TileEntities has some advantages, you might be better off forgetting about TileEntities for now.

2) I would suggest that you practice with a couple of simpler tutorials first, on custom block rendering, that should help make some of the concepts a bit clearer. Wuppy has some good ones, for example http://wuppy29.blogspot.com/2013/08/wuppys-minecraft-forge-modding_14.html

 

-TGG

 

 

 

Link to comment
Share on other sites

Thank you.  Know the block is working but when I place it it just shows it's normal texture (dosn't camoflauge).  Do I need to override onBlockPlace?

Code:

 

 

Illusion Block Tile Entity:

--------------------------------------------------------------------------------------------------------------------------------------------------------package RickyRyan.mod.SmokeAndMirrors.TileEntity;

 

import java.math.*;

import java.util.ArrayList;

 

import RickyRyan.mod.SmokeAndMirrors.Block.BlockIllusionBlock;

import RickyRyan.mod.SmokeAndMirrors.Block.BlockInfo;

import RickyRyan.mod.SmokeAndMirrors.Block.Blocks;

 

import net.minecraft.block.Block;

import net.minecraft.block.material.Material;

import net.minecraft.client.renderer.texture.Texture;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.nbt.NBTTagCompound;

import net.minecraft.tileentity.TileEntity;

import net.minecraft.util.Icon;

 

public class TileEntityIllusionBlock extends TileEntity{

 

private int x = this.xCoord;

private int y = this.yCoord;

private int z = this.zCoord;

 

@Override

  public void writeToNBT(NBTTagCompound par1)

  {

      super.writeToNBT(par1);

      //par1.setInteger("customField", customField);

      par1.setInteger("xCord", x);

      par1.setInteger("yCord", y);

      par1.setInteger("zCord", z);

  }

 

  @Override

  public void readFromNBT(NBTTagCompound par1)

  {

      super.readFromNBT(par1);

      //this.customField = par1.getInteger("customField");

      this.x = par1.getInteger("xCord");

      this.y = par1.getInteger("yCord");

      this.z = par1.getInteger("zCord");

  }

 

 

public Icon[] getTextureToModel(int x, int y, int z) {

if(this.getWorldObj() != null) {

 

Block blockToModel = null;

Icon side1 = null;

Icon side2 = null;

Icon side3 = null;

Icon side4 = null;

Icon side5 = null;

Icon side6 = null;

 

if (!worldObj.isAirBlock((int)(x + 1), (int)(y), (int)(z))) {

int blockId = worldObj.getBlockId((int)(x + 1), (int)(y), (int)(z));

 

blockToModel = Block.blocksList[blockId];

side1 = blockToModel.getBlockTexture(worldObj, x + 1, y, z, 1);

side2 = blockToModel.getBlockTexture(worldObj, x + 1, y, z, 2);

side3 = blockToModel.getBlockTexture(worldObj, x + 1, y, z, 3);

side4 = blockToModel.getBlockTexture(worldObj, x + 1, y, z, 4);

side5 = blockToModel.getBlockTexture(worldObj, x + 1, y, z, 5);

side6 = blockToModel.getBlockTexture(worldObj, x + 1, y, z, 6);

 

} else if (!worldObj.isAirBlock((int)(x - 1), (int)(y), (int)(z))) {

int blockId = worldObj.getBlockId((int)(x - 1), (int)(y), (int)(z));

 

blockToModel = Block.blocksList[blockId];

side1 = blockToModel.getBlockTexture(worldObj, x - 1, y, z, 1);

side2 = blockToModel.getBlockTexture(worldObj, x - 1, y, z, 2);

side3 = blockToModel.getBlockTexture(worldObj, x - 1, y, z, 3);

side4 = blockToModel.getBlockTexture(worldObj, x - 1, y, z, 4);

side5 = blockToModel.getBlockTexture(worldObj, x - 1, y, z, 5);

side6 = blockToModel.getBlockTexture(worldObj, x - 1, y, z, 6);

 

}  else if (!worldObj.isAirBlock((int)(x), (int)(y + 1), (int)(z))) {

int blockId = worldObj.getBlockId((int)(x), (int)(y + 1), (int)(z));

 

blockToModel = Block.blocksList[blockId];

side1 = blockToModel.getBlockTexture(worldObj, x, y + 1, z, 1);

side2 = blockToModel.getBlockTexture(worldObj, x, y + 1, z, 2);

side3 = blockToModel.getBlockTexture(worldObj, x, y + 1, z, 3);

side4 = blockToModel.getBlockTexture(worldObj, x, y + 1, z, 4);

side5 = blockToModel.getBlockTexture(worldObj, x, y + 1, z, 5);

side6 = blockToModel.getBlockTexture(worldObj, x, y + 1, z, 6);

 

} else if (!worldObj.isAirBlock((int)(x), (int)(y - 1), (int)(z))) {

int blockId = worldObj.getBlockId((int)(x), (int)(y - 1), (int)(z));

 

blockToModel = Block.blocksList[blockId];

side1 = blockToModel.getBlockTexture(worldObj, x, y - 1, z, 1);

side2 = blockToModel.getBlockTexture(worldObj, x, y - 1, z, 2);

side3 = blockToModel.getBlockTexture(worldObj, x, y - 1, z, 3);

side4 = blockToModel.getBlockTexture(worldObj, x, y - 1, z, 4);

side5 = blockToModel.getBlockTexture(worldObj, x, y - 1, z, 5);

side6 = blockToModel.getBlockTexture(worldObj, x, y - 1, z, 6);

 

}  else if (!worldObj.isAirBlock((int)(x), (int)(y), (int)(z + 1))) {

int blockId = worldObj.getBlockId((int)(x), (int)(y), (int)(z + 1));

 

blockToModel = Block.blocksList[blockId];

side1 = blockToModel.getBlockTexture(worldObj, x, y, z + 1, 1);

side2 = blockToModel.getBlockTexture(worldObj, x, y, z + 1, 2);

side3 = blockToModel.getBlockTexture(worldObj, x, y, z + 1, 3);

side4 = blockToModel.getBlockTexture(worldObj, x, y, z + 1, 4);

side5 = blockToModel.getBlockTexture(worldObj, x, y, z + 1, 5);

side6 = blockToModel.getBlockTexture(worldObj, x, y, z + 1, 6);

 

}  else if (!worldObj.isAirBlock((int)(x), (int)(y), (int)(z - 1))) {

int blockId = worldObj.getBlockId((int)(x), (int)(y), (int)(z - 1));

 

blockToModel = Block.blocksList[blockId];

side1 = blockToModel.getBlockTexture(worldObj, x, y, z - 1, 1);

side2 = blockToModel.getBlockTexture(worldObj, x, y, z - 1, 2);

side3 = blockToModel.getBlockTexture(worldObj, x, y, z - 1, 3);

side4 = blockToModel.getBlockTexture(worldObj, x, y, z - 1, 4);

side5 = blockToModel.getBlockTexture(worldObj, x, y, z - 1, 5);

side6 = blockToModel.getBlockTexture(worldObj, x, y, z - 1, 6);

 

} else {

 

int xToCheck = x + 1;

int yToCheck = y;

int zToCheck = z + 0;

 

 

do {

xToCheck = x + 1;

yToCheck = y;

zToCheck = z + 0;

 

 

if (!worldObj.isAirBlock((int)(xToCheck), (int)(yToCheck), (int)(zToCheck))) {

int blockId = worldObj.getBlockId((int)(x), (int)(y), (int)(z - 1));

 

blockToModel = Block.blocksList[blockId];

 

side1 = blockToModel.getBlockTexture(worldObj, xToCheck, yToCheck, zToCheck, 1);

side2 = blockToModel.getBlockTexture(worldObj, xToCheck, yToCheck, zToCheck, 2);

side3 = blockToModel.getBlockTexture(worldObj, xToCheck, yToCheck, zToCheck, 3);

side4 = blockToModel.getBlockTexture(worldObj, xToCheck, yToCheck, zToCheck, 4);

side5 = blockToModel.getBlockTexture(worldObj, xToCheck, yToCheck, zToCheck, 5);

side6 = blockToModel.getBlockTexture(worldObj, xToCheck, yToCheck, zToCheck, 6);

}

 

 

} while (!worldObj.isAirBlock((int)(xToCheck), (int)(yToCheck), (int)(zToCheck)));

 

 

 

 

}

 

 

Icon[] IconArray = {side1, side2, side3, side4, side5, side6};

 

return IconArray;

 

 

} else {

Block IllusionBlock = Blocks.IllusionBlock;

Icon[] IconArray = {IllusionBlock.getIcon(BlockInfo.IllusionBlockId, 0), IllusionBlock.getIcon(BlockInfo.IllusionBlockId, 0), IllusionBlock.getIcon(BlockInfo.IllusionBlockId, 0), IllusionBlock.getIcon(BlockInfo.IllusionBlockId, 0), IllusionBlock.getIcon(BlockInfo.IllusionBlockId, 0), IllusionBlock.getIcon(BlockInfo.IllusionBlockId, 0)};

return IconArray;

}

 

 

}

 

 

 

 

 

 

 

 

 

}

 

--------------------------------------------------------------------------------------------------------------------------------------------------------

Illusion Block:

--------------------------------------------------------------------------------------------------------------------------------------------------------

package RickyRyan.mod.SmokeAndMirrors.Block;

 

import RickyRyan.mod.SmokeAndMirrors.TileEntity.TileEntityIllusionBlock;

import net.minecraft.block.Block;

import net.minecraft.block.BlockContainer;

import net.minecraft.block.material.Material;

import net.minecraft.client.renderer.texture.IconRegister;

import net.minecraft.tileentity.TileEntity;

import net.minecraft.util.AxisAlignedBB;

import net.minecraft.util.Icon;

import net.minecraft.world.IBlockAccess;

import net.minecraft.world.World;

 

public class BlockIllusionBlock extends BlockContainer {

 

public BlockIllusionBlock(int par1, Material par2Material) {

super(par1, par2Material);

setBlockBounds(0F, 0F, 0F, 1F, 1F, 1F);

}

 

 

 

 

@Override

public void registerIcons(IconRegister register) {

 

blockIcon = register.registerIcon("SmokeAndMirrors:IllusonBlockDefault");

 

}

 

 

@Override

public Icon getBlockTexture(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5) {

 

TileEntity tile = createNewTileEntity(par1IBlockAccess);

if(tile != null) {

Icon[] IconArray = ((TileEntityIllusionBlock) tile).getTextureToModel(par2, par3, par4);

if(IconArray != null){

return IconArray[par5];

} else {

return getIcon(BlockInfo.IllusionBlockId, 0);

}

} else {

return getIcon(BlockInfo.IllusionBlockId, 0);

}

 

 

}

 

 

 

 

 

 

public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int i, int j, int k)

    {

            return null;

    }

 

public boolean isOpaqueCube()

    {

        return false;

    }

 

//look into getBlockTexture in Block

 

 

 

 

 

public boolean renderAsNormalBlock()

    {

        return false;

    }

 

public int getRenderType()

    {

        return 0;

    }

 

@Override

public TileEntity createNewTileEntity(World world) {

 

return new TileEntityIllusionBlock();

}

 

public TileEntity createNewTileEntity(IBlockAccess par1IBlockAccess) {

 

return new TileEntityIllusionBlock();

}

}

[spoile/r]

Link to comment
Share on other sites

Just out of curiosity. Do you check all the blocks that are in direct contact with the block? Because if you don't... That would be pretty sad to have the block represent what is [ insert side here ] to it. I would suggest doing a check against all the blocks touching the camo-block and then seeing which ID there is the most of, then use that as the texture-getter. If there is say, only one block touching the camp-block, then you just make the texture of the block the texture of that single block.

 

 

 

P.S. USE CODE TAGS!!!!! AND USE SPOILER TAGS!!!!

 

And as a hint, here are the tags for that. ( Note that you NEED to remove the spaces for it to work xD )

[ s p o i l e r ]

[ c o d e ]

The stuff goes here

[ / c o d e ]

[ / s p o i l e r ]

 

This will result in this:

 

 

The stuff goes here

 

 

 

 

I am Mew. The Legendary Psychic. I behave oddly and am always playing practical jokes.

 

I have also found that I really love making extremely long and extremely but sometimes not so descriptive variables. Sort of like what I just did there xD

Link to comment
Share on other sites

Ohsitdude, you don't need custom renderers or TileEntities for this.

 

Here's some code from a block of mine.  It was called CamoPhaseStone (mod thread)

 

 

public Icon getBlockTexture(IBlockAccess world, int x, int y, int z, int side)
    {
	int mymeta = world.getBlockMetadata(x, y, z);
	if(mymeta == 0) {
        int[] id = {world.getBlockId(x, y-1, z),world.getBlockId(x, y+1, z),world.getBlockId(x-1, y, z),world.getBlockId(x+1, y, z),world.getBlockId(x, y, z-1),world.getBlockId(x, y, z+1)};
        int[] meta = {world.getBlockMetadata(x, y-1, z),world.getBlockMetadata(x, y+1, z),world.getBlockMetadata(x-1, y, z),world.getBlockMetadata(x+1, y, z),world.getBlockMetadata(x, y, z-1),world.getBlockMetadata(x, y, z+1)};
        //.get.getBlockTextureFromSideAndMetadata(par5, par1IBlockAccess.getBlockMetadata(par2, par3, par4));
        for(int i = 0; i < id.length; i++) {
        	Block block = Block.blocksList[id[i]];
        	if(block != null) {
        		if(block != this) {
	        		Icon icon = block.getBlockTextureFromSideAndMetadata(side, meta[i]);
	        		if(icon != null) {
	        			return icon;
	        		}
        		}
        		else {
        			Icon icon = Block.grass.getBlockTextureFromSide(1);
        			switch(i) {
        				case 0:
	        				icon = ((CamoPhaseStone)block).getBlockTextureDirectional(world, x, y-1, z, side, 0);
	        				break;
        				case 1:
	        				icon = ((CamoPhaseStone)block).getBlockTextureDirectional(world, x, y+1, z, side, 1);
	        				break;
        				case 2:
	        				icon = ((CamoPhaseStone)block).getBlockTextureDirectional(world, x-1, y, z, side, 2);
	        				break;
        				case 3:
	        				icon = ((CamoPhaseStone)block).getBlockTextureDirectional(world, x+1, y, z, side, 3);
	        				break;
        				case 4:
	        				icon = ((CamoPhaseStone)block).getBlockTextureDirectional(world, x, y, z-1, side, 4);
	        				break;
        				case 5:
	        				icon = ((CamoPhaseStone)block).getBlockTextureDirectional(world, x, y, z+1, side, 5);
	        				break;
        			}
	        		if(icon != null && icon != Block.grass.getBlockTextureFromSide(1)) {
	        			return icon;
	        		}
        		}
        	}
        }
        return Block.grass.getBlockTextureFromSide(1);
	}
	else {
		return blockIcon;
	}
    }

public Icon getBlockTextureDirectional(IBlockAccess world, int x, int y, int z, int side, int direction) {

	int id = world.getBlockId(x, y, z);
	int meta = world.getBlockMetadata(x, y, z);
	Block block = Block.blocksList[id];
	if(block != null) {
		if(block != this) {
			Icon icon = block.getBlockTextureFromSideAndMetadata(side, meta);
        		if(icon != null) {
        			return icon;
        		}
		}
		else {
			Icon icon = Block.grass.getBlockTextureFromSide(1);
    			switch(direction) {
    				case 0:
        				icon = ((CamoPhaseStone)block).getBlockTextureDirectional(world, x, y-1, z, side, 0);
        				break;
    				case 1:
        				icon = ((CamoPhaseStone)block).getBlockTextureDirectional(world, x, y+1, z, side, 1);
        				break;
    				case 2:
        				icon = ((CamoPhaseStone)block).getBlockTextureDirectional(world, x-1, y, z, side, 2);
        				break;
    				case 3:
        				icon = ((CamoPhaseStone)block).getBlockTextureDirectional(world, x+1, y, z, side, 3);
        				break;
    				case 4:
        				icon = ((CamoPhaseStone)block).getBlockTextureDirectional(world, x, y, z-1, side, 4);
        				break;
    				case 5:
        				icon = ((CamoPhaseStone)block).getBlockTextureDirectional(world, x, y, z+1, side, 5);
        				break;
    			}
    			return icon;
		}
	}
	return Block.grass.getBlockTextureFromSide(1);
}

 

 

Now, it would only grab textures in an orthogonal line from its position, but this was done to prevent infinite loops where one block would ask another block what it's texture was, and that block would ask the first block.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

This works for the textures but the colors dont show up (grass is gray).  I think I need to override the getRenderColor method in Block but I don't get the world and the cords as arguments.  Also, what does getBlockTextureDirectional do?

 

Its the same as getBlockTexture, but rather than looping through the directions (up,down,left,right,forward,backward) it is passed the direction to look at.

 

This prevents blockA -> blockB -> blockA -> infinite loop texture requests.

 

And yes, it doesn't work well for grass. :(

Grass is such a pain in the ass to fake, due to using three textures, only one of which (the top) needs to get colored, but the getBlockColor() method takes no parameters!  getRenderColor() is slightly better, but passes only a single integer (side?), not enough to know if the block that is being rendered is a supposed to be mimicking grass or not.  colorMultiplier() is better still, but doesn't distinguish by side.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

This works for the textures but the colors dont show up (grass is gray).  I think I need to override the getRenderColor method in Block

 

Grass has its own functions for determining color:

 

BlockGrass.java

    public int getBlockColor()
    {
        double d0 = 0.5D;
        double d1 = 1.0D;
        return ColorizerGrass.getGrassColor(d0, d1);
    }

 

ColorizerGrass.java

    /**
     * Gets grass color from temperature and humidity. Args: temperature, humidity
     */
    public static int getGrassColor(double par0, double par2)
    {
        par2 *= par0;
        int i = (int)((1.0D - par0) * 255.0D);
        int j = (int)((1.0D - par2) * 255.0D);
        return grassBuffer[j << 8 | i];
    }

 

Try implementing those in your block. If you can get the temp and humidity you should be able to mimic the grass color.

 

Hint:

 

BiomeGenBase.java

        double d0 = (double)MathHelper.clamp_float(this.getFloatTemperature(), 0.0F, 1.0F);
        double d1 = (double)MathHelper.clamp_float(this.getFloatRainfall(), 0.0F, 1.0F);

Link to comment
Share on other sites

I have overridden getBlockColor like this:

 public int getBlockColor()
    {
	 if(blockToCopy != null) {
			return blockToCopy.getBlockColor();
	 }
				return 16777215;
    }

Where blockToCopy is the block whose texture I'm using.

Also: Leaves do the same thing as grass.  Plus it makes Ice opaque and some blocks (tall grass) use the wrong render type.

Link to comment
Share on other sites

I have overridden getBlockColor like this:

 public int getBlockColor()
       {
       if(blockToCopy != null) {
            return blockToCopy.getBlockColor();
       }
               return 16777215;
       }

Where blockToCopy is the block whose texture I'm using.

Also: Leaves do the same thing as grass.  Plus it makes Ice opaque and some blocks (tall grass) use the wrong render type.

 

Did you override or edit the function directly? You shouldn't see any changes to default blocks if you put it in your block class file with the @Override annotation.

Link to comment
Share on other sites

Where blockToCopy is the block whose texture I'm using.

 

blockToCopy is in the wrong scope.  It'll be overwritten by every block in your world every render, so its not guaranteed to be the same block when that function is called.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

I have overridden getBlockColor like this:

 public int getBlockColor()
       {
       if(blockToCopy != null) {
            return blockToCopy.getBlockColor();
       }
               return 16777215;
       }

Where blockToCopy is the block whose texture I'm using.

Also: Leaves do the same thing as grass.  Plus it makes Ice opaque and some blocks (tall grass) use the wrong render type.

 

Did you override or edit the function directly? You shouldn't see any changes to default blocks if you put it in your block class file with the @Override annotation.

 

Sorry.  By Ice and Leaves I mean my block when it tries to copy Ice and Leaves

 

Link to comment
Share on other sites

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.



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • rp.crazyheal.xyz mods  
    • I'm developing a dimension, but it's kinda resource intensive so some times during player teleporting it lags behind making the player phase down into the void, so im trying to implement some kind of pregeneration to force the game loading a small set of chunks in the are the player will teleport to. Some of the things i've tried like using ServerLevel and ServerChunkCache methods like getChunk() dont actually trigger chunk generation if the chunk isn't already on persistent storage (already generated) or placing tickets, but that doesn't work either. Ideally i should be able to check when the task has ended too. I've peeked around some pregen engines, but they're too complex for my current understanding of the system of which I have just a basic understanding (how ServerLevel ,ServerChunkCache  and ChunkMap work) of. Any tips or other classes I should be looking into to understand how to do this correctly?
    • https://mclo.gs/4UC49Ao
    • Way back in the Forge 1.17 days, work started for adding JPMS (Java Platform Module Support) to ModLauncher and ForgeModLoader. This has been used internally by Forge and some libraries for a while now, but mods (those with mods.toml specifically) have not been able to take advantage of it. As of Forge 1.21.1 and 1.21.3, this is now possible!   What is JPMS and what does it mean for modders? JPMS is the Java Platform Module System, introduced in Java 9. It allows you to define modules, which are collections of packages and resources that can be exported or hidden from other modules. This allows for much more fine-tuned control over visibility, cleaner syntax for service declarations and support for sealed types across packages. For example, you might have a mod with a module called `com.example.mod` that exports `com.example.mod.api` and `com.example.mod.impl` to other mods, but hides `com.example.mod.internal` from them. This would allow you to have a clean API for other mods to use, while keeping your internal implementation details hidden from IDE hints, helping prevent accidental usage of internals that might break without prior notice. This is particularly useful if you'd like to use public records with module-private constructors or partially module-private record components, as you can create a sealed interface that only your record implements, having the interface be exported and the record hidden. It's also nice for declaring and using services, as you'll get compile-time errors from the Java compiler for typos and the like, rather than deferring to runtime errors. In more advanced cases, you can also have public methods that are only accessible to specific other modules -- handy if you want internal interactions between multiple of your own mods.   How do I bypass it? We understand there may be drama in implementing a system that prevents mods from accessing each other's internals when necessary (like when a mod is abandoned or you need to fix a compat issue) -- after all, we are already modding a game that doesn't have explicit support for Java mods yet. We have already thought of this and are offering APIs from day one to selectively bypass module restrictions. Let me be clear: Forge mods are not required to use JPMS. If you don't want to use it, you don't have to. The default behaviour is to have fully open, fully exported automatic modules. In Java, you can use the `Add-Opens` and `Add-Exports` manifest attributes to selectively bypass module restrictions of other mods at launch time, and we've added explicit support for these when loading your Forge mods. At compile-time, you can use existing solutions such as the extra-java-module-info Gradle plugin to deal with non-modular dependencies and add extra opens and exports to other modules. Here's an example on how to make the internal package `com.example.examplemod.internal` open to your mod in your build.gradle: tasks.named('jar', Jar) { manifest { attributes([ 'Add-Opens' : 'com.example.examplemod/com.example.examplemod.internal' 'Specification-Title' : mod_id, 'Specification-Vendor' : mod_authors // (...) ]) } } With the above in your mod's jar manifest, you can now reflectively access the classes inside that internal package. Multiple entries are separated with a space, as per Java's official spec. You can also use Add-Exports to directly call without reflection, however you'd need to use the Gradle plugin mentioned earlier to be able to compile. The syntax for Add-Exports is the same as Add-Opens, and instructions for the compile-time step with the Gradle plugin are detailed later in this post. Remember to prefer the opens and exports keywords inside module-info.java for sources you control. The Add-Opens/Add-Exports attributes are only intended for forcing open other mods.   What else is new with module support? Previously, the runtime module name was always forced to the first mod ID in your `mods.toml` file and all packages were forced fully open and exported. Module names are now distinguished from mod IDs, meaning the module name in your module-info.java can be different from the mod ID in your `mods.toml`. This allows you to have a more descriptive module name that doesn't have to be the same as your mod ID, however we strongly recommend including your mod ID as part of your module name to aid troubleshooting. The `Automatic-Module-Name` manifest attribute is now also honoured, allowing you to specify a module name for your mod without needing to create a `module-info.java` file. This is particularly useful for mods that don't care about JPMS features but want to have a more descriptive module name and easier integration with other mods that do use JPMS.   How do I use it? The first step is to create a `module-info.java` file in your mod's source directory. This file should be in the same package as your main mod class, and should look something like this: open module com.example.examplemod { requires net.minecraftforge.eventbus; requires net.minecraftforge.fmlcore; requires net.minecraftforge.forge; requires net.minecraftforge.javafmlmod; requires net.minecraftforge.mergetool.api; requires org.slf4j; requires logging; } For now, we're leaving the whole module open to reflection, which is a good starting point. When we know we want to close something off, we can remove the open modifier from the module and open or export individual packages instead. Remember that you need to be open to Forge (module name net.minecraftforge.forge), otherwise it can't call your mod's constructor. Next is fixing modules in Gradle. While Forge and Java support modules properly, Gradle does not put automatic modules on the module path by default, meaning that the logging module (from com.mojang:logging) is not found. To fix this, add the Gradle plugin and add a compile-time module definition for that Mojang library: plugins { // (...) id 'org.gradlex.extra-java-module-info' version "1.9" } // (...) extraJavaModuleInfo { failOnMissingModuleInfo = false automaticModule("com.mojang:logging", "logging") } The automatic module override specified in your build.gradle should match the runtime one to avoid errors. You can do the same for any library or mod dependency that is missing either a module-info or explicit Automatic-Module-Name, however be aware that you may need to update your mod once said library adds one. That's all you need to get started with module support in your mods. You can learn more about modules and how to use them at dev.java.
    • Faire la mise à jour grâce à ce lien m'a aider personnellement, merci à @Paint_Ninja. https://www.amd.com/en/support 
  • Topics

×
×
  • Create New...

Important Information

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