Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

bxzsj

Members
  • Posts

    27
  • Joined

  • Last visited

Posts posted by bxzsj

  1. Try to use GL11.glRect to draw rectangles.

    But it don't work.

        @Override
        public void drawScreen(int mouseX, int mouseY, float partialTicks)
        {
            super.drawScreen(mouseX, mouseY, partialTicks);
            GlStateManager.disableTexture2D();
            GL11.glColor4f(1.0f,0,0,1.0f);
            GL11.glRecti(10,10,50,50);
            GL11.glPushMatrix();
            GL11.glLoadIdentity();
            GL11.glRectf(-0.5f, -0.5f, 0.5f, 0.5f);
            GL11.glPopMatrix();
            GlStateManager.enableTexture2D();
            GL11.glRecti(10,10,50,50);
            GL11.glPushMatrix();
            GL11.glLoadIdentity();
            GL11.glRectf(-0.5f, -0.5f, 0.5f, 0.5f);
            GL11.glPopMatrix();
        }

    image.png.04273efb62cb47f834ebee7502ef8322.png

    But if I try this:

            glBegin(GL_POLYGON);
            glVertex2i(10,10);
            glVertex2i(10,50);
            glVertex2i(50,50);
            glVertex2i(50,10);
            glEnd();

    It works.

    I find that the difference between GL11.glRect and the above code  is

    glRect(x1, y1, x2, y2) equal

    glBegin(GL_POLYGON);
    glVertex2(x1, y1);
    glVertex2(x2, y1);
    glVertex2(x2, y2);
    glVertex2(x1, y2);
    glEnd( );

    but the work one is:

    glBegin(GL_POLYGON);
    glVertex2(x1, y1);
    glVertex2(x1, y2);
    glVertex2(x2, y2);
    glVertex2(x2, y1);
    glEnd( );


    The difference between them is that the order of the vertices is different.

    I don't understand why this is happening. I hope someone can answer. Thank you!

  2. 15 minutes ago, Draco18s said:

    Sorry, I missed that. It was a little buried.

    Nothing in the log...
    https://github.com/bxz2311196368/someusefulthings/blob/1.10.2/src/main/java/com/bxzmod/someusefulthings/blocks/BlockRenderLoader.java#L18

    Why are you registering state mappers at all? You're using the default state mapper, you shouldn't need to do this.

     

    Sorry, I don't know what is a right way to register block state mapper,can you give me some document or tutorials about it?

    This is the only way I learned from a tutorial. I still haven't figured out how this part works.

  3. I'm trying to define a block use vanilla cube model to render with 7 variant,but got some problem that block not be right render.

    No error show in log(here).(block registry name is "energy_block")
    Item renders well, but block got wrong.

    block state in the following picture are correct.
    no error "Exception loading model for variant" about this block(energy_block).

    I'm sorry, I don't understand how json to model and connect with block state.


    I'm not sure if I've done the wrong thing that use a wrong register Block State Mapper(here)
    source code:

    block(here)

    Spoiler
    
    package com.bxzmod.someusefulthings.blocks;
    
    import com.bxzmod.someusefulthings.EnumIO;
    import com.bxzmod.someusefulthings.UnlistedPropertyIO;
    import com.bxzmod.someusefulthings.core.energy.IEnergySide;
    import com.bxzmod.someusefulthings.tileentity.EnergyBlockTileEntity;
    import com.google.common.collect.Lists;
    import com.google.common.primitives.Booleans;
    
    import net.minecraft.block.properties.IProperty;
    import net.minecraft.block.properties.PropertyDirection;
    import net.minecraft.block.properties.PropertyEnum;
    import net.minecraft.block.state.BlockStateContainer;
    import net.minecraft.block.state.IBlockState;
    import net.minecraft.entity.EntityLivingBase;
    import net.minecraft.item.ItemStack;
    import net.minecraft.tileentity.TileEntity;
    import net.minecraft.util.EnumFacing;
    import net.minecraft.util.math.BlockPos;
    import net.minecraft.world.IBlockAccess;
    import net.minecraft.world.World;
    import net.minecraftforge.common.property.ExtendedBlockState;
    import net.minecraftforge.common.property.IExtendedBlockState;
    import net.minecraftforge.common.property.IUnlistedProperty;
    
    public class EnergyBlock extends BaseBlockContainer
    {
    	public static final PropertyDirection FACING = PropertyDirection.create("facing", Lists.newArrayList(EnumFacing.values()));
    	public static final PropertyEnum<EnumIO> UP = PropertyEnum.create("up", EnumIO.class);
    	public static final PropertyEnum<EnumIO> DOWN = PropertyEnum.create("down", EnumIO.class);
    	public static final PropertyEnum<EnumIO> NORTH = PropertyEnum.create("north", EnumIO.class);
    	public static final PropertyEnum<EnumIO> SOUTH = PropertyEnum.create("south", EnumIO.class);
    	public static final PropertyEnum<EnumIO> EAST = PropertyEnum.create("east", EnumIO.class);
    	public static final PropertyEnum<EnumIO> WEST = PropertyEnum.create("west", EnumIO.class);
    
    	public EnergyBlock()
    	{
    		super();
    		this.setRegistryName("energy_block");
    		this.setUnlocalizedName("energyBlock");
    		this.setDefaultState(this.createBlockState().getBaseState().withProperty(FACING, EnumFacing.NORTH));
    	}
    
    	@Override
    	public TileEntity createNewTileEntity(World worldIn, int meta)
    	{
    		return new EnergyBlockTileEntity();
    	}
    
    	@Override
    	public IBlockState getStateFromMeta(int meta)
    	{
    		int a;
    		a = meta % 3;
    		EnumFacing facing = EnumFacing.getHorizontal(a);
    		return this.getDefaultState().withProperty(FACING, facing);
    	}
    
    	@Override
    	public int getMetaFromState(IBlockState state)
    	{
    		int facing = state.getValue(FACING).getIndex();
    		return facing;
    	}
    	
    	@Override
    	public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY,
    			float hitZ, int meta, EntityLivingBase placer, ItemStack stack)
    	{
    		IBlockState origin = super.getStateForPlacement(world, pos, facing, hitX, hitY, hitZ, meta, placer, stack);
    		return origin.withProperty(FACING, placer.getHorizontalFacing().getOpposite());
    	}
    
    	@Override
    	protected BlockStateContainer createBlockState()
    	{
    //		return new ExtendedBlockState(this, new IProperty[] { FACING, NORTH, SOUTH, WEST, EAST, UP, DOWN },
    //				new IUnlistedProperty[] {});
    		return new BlockStateContainer(this, FACING, NORTH, SOUTH, WEST, EAST, UP, DOWN);
    	}
    
    //	@Override
    //	public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos)
    //	{
    //		TileEntity te = world.getTileEntity(pos);
    //		//IExtendedBlockState s = (IExtendedBlockState) state;
    //		//state.withProperty(FACING, state.getValue(FACING));
    //		if (te instanceof IEnergySide)
    //		{
    //			IEnergySide config = (IEnergySide) te;
    //			System.out.println(Booleans.asList(config.getAllEnergySide()).toString());
    //			for(EnumFacing side:EnumFacing.VALUES)
    //				state.withProperty(this.getProperty(side), config.canReceive(side) ? EnumIO.INPUT : EnumIO.OUTPUT);
    //		}
    //		return super.getExtendedState(state, world, pos);
    //	}
    	
    	@Override
    	public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos)
    	{
    		TileEntity te = worldIn.getTileEntity(pos);
    		if (te instanceof IEnergySide)
    		{
    			IEnergySide config = (IEnergySide) te;
    			//System.out.println(Booleans.asList(config.getAllEnergySide()).toString());
    			for(EnumFacing side:EnumFacing.VALUES)
    				state.withProperty(this.getProperty(side), config.canReceive(side) ? EnumIO.INPUT : EnumIO.OUTPUT);
    		}
    		return state;
    	}
    
    	public PropertyEnum<EnumIO> getProperty(EnumFacing from)
    	{
    		switch (from)
    		{
    		case UP:
    			return this.UP;
    		case DOWN:
    			return this.DOWN;
    		case NORTH:
    			return this.NORTH;
    		case SOUTH:
    			return this.SOUTH;
    		case WEST:
    			return this.WEST;
    		case EAST:
    			return this.EAST;
    		default:
    			return null;
    		}
    
    	}
    
    }

     

    blockstate json(here)

    Spoiler
    
    {
        "forge_marker": 1,
        "defaults": {
            "model": "cube",
            "textures": {
                "down": "someusefulthings:blocks/remove_enchantment_side",
                "up": "someusefulthings:blocks/remove_enchantment_side",
                "north": "someusefulthings:blocks/eye_generator_on",
                "south": "someusefulthings:blocks/remove_enchantment_side",
                "west": "someusefulthings:blocks/remove_enchantment_side",
                "east": "someusefulthings:blocks/remove_enchantment_side"
            }
        },
        "variants": {
            "inventory": [{
                 "textures": { "down": "someusefulthings:blocks/remove_enchantment_side",
                "up": "someusefulthings:blocks/remove_enchantment_side",
                "north": "someusefulthings:blocks/eye_generator_on",
                "south": "someusefulthings:blocks/remove_enchantment_side",
                "west": "someusefulthings:blocks/remove_enchantment_side",
                "east": "someusefulthings:blocks/remove_enchantment_side" }
            }],
            "facing": {
                "east": { "y": 90, "uvlock": true },
                "north": {},
                "south": { "y": 180, "uvlock": true },
                "west": { "y": 270, "uvlock": true },
                "down": {},
                "up": {}
            },
            "up":{
            "input": { "textures": { "up": "someusefulthings:blocks/copy_enchantment_on" } },
            "output": { "textures": { "up": "someusefulthings:blocks/copy_enchantment_off" } },
            "all": { },
            "not": { }
            },
            "down":{
            "input": { "textures": { "down": "someusefulthings:blocks/copy_enchantment_on" } },
            "output": { "textures": { "down": "someusefulthings:blocks/copy_enchantment_off" } },
            "all": { },
            "not": { }
            },
            "north":{
            "input": { "textures": { "north": "someusefulthings:blocks/copy_enchantment_on" } },
            "output": { "textures": { "north": "someusefulthings:blocks/copy_enchantment_off" } },
            "all": { },
            "not": { }
            },
            "south":{
            "input": { "textures": { "south": "someusefulthings:blocks/copy_enchantment_on" } },
            "output": { "textures": { "south": "someusefulthings:blocks/copy_enchantment_off" } },
            "all": { },
            "not": { }
            },
            "west":{
            "input": { "textures": { "west": "someusefulthings:blocks/copy_enchantment_on" } },
            "output": { "textures": { "west": "someusefulthings:blocks/copy_enchantment_off" } },
            "all": { },
            "not": { }
            },
            "east":{
            "input": { "textures": { "east": "someusefulthings:blocks/copy_enchantment_on" } },
            "output": { "textures": { "east": "someusefulthings:blocks/copy_enchantment_off" } },
            "all": { },
            "not": { }
            }
        }
    }

     

     

    error_render.png

  4. 1 hour ago, Cadiboo said:

    so just modify it to fit your needs

    Thank you, I defind a method :

    public void drawZoomTexturedModalRect(int x, int y, int textureX, int textureY, int width, int height, float textureAreaWidth, float textureAreaHeight, float textureWidth, float textureHeight)
    {
    	float f = 1.0F / textureWidth;
    	float f1 = 1.0F / textureHeight;
    	Tessellator tessellator = Tessellator.getInstance();
    	VertexBuffer vertexbuffer = tessellator.getBuffer();
    	vertexbuffer.begin(7, DefaultVertexFormats.POSITION_TEX);
    	vertexbuffer.pos((double) x, (double) (y + height), (double) this.zLevel).tex((double) (textureX * f), (double) ((textureY + textureAreaHeight) * f1)).endVertex();
    	vertexbuffer.pos((double) (x + width), (double) (y + height), (double) this.zLevel).tex((double) ((textureX + textureAreaWidth) * f), (double) ((textureY + textureAreaHeight) * f1)).endVertex();
    	vertexbuffer.pos((double) (x + width), (double) y, (double) this.zLevel).tex((double) ((textureX + textureAreaWidth) * f), (double) (textureY * f1)).endVertex();
    	vertexbuffer.pos((double) x, (double) y, (double) this.zLevel).tex((double) (textureX * f), (double) (textureY * f1)).endVertex();
    	tessellator.draw();
    }

    it works.

  5. I want to draw a texture that 40*20 to 10*10,tried to use GlStateManager.scale but got a wrong display,and then I found this 

    drawScaledCustomSizeModalRect(int x, int y, float u, float v, int uWidth, int vHeight, int width, int height, float tileWidth, float tileHeight)

    but I don't know what those parameters mean.

    Could some one tell me how to use it?

    My texture(png) is 256*256 and texture offsetX is 0,offsetY is 20, width and height to display is 40 * 20 and zoom to 10*10.

  6. I have solved the model crash. But,my TileEntity doesn't save data.

    It reported a problem: (log L673)

    Caused by: java.lang.NullPointerException
    	at com.bxzmod.energyconversion.tileentity.PowerBlockTileEntity.func_145839_a(PowerBlockTileEntity.java:109) ~[PowerBlockTileEntity.class:?]

    the code is:

    	@Override
    	public void readFromNBT(NBTTagCompound nbt)
    	{
    		super.readFromNBT(nbt);
    		//LOGGER.info("read" + nbt.toString());
    		NBTTagList list = new NBTTagList();
    		this.totalEnergy = nbt.getInteger("totalEnergy");
    		list = (NBTTagList) nbt.getTag("sideType");//here didn't get nbt tag
    		for (int i = 0; i < 6; i++)
    			this.sideType[i] = ((NBTTagCompound) list.get(i)).getBoolean("side" + i);
    		if (totalEnergy > capacity)
    		{
    			totalEnergy = capacity;
    		}
    		storage.readFromNBT(nbt);
    	}
    
    	@Override
    	public NBTTagCompound writeToNBT(NBTTagCompound nbt)
    	{
    		super.writeToNBT(nbt);
    		nbt = storage.writeToNBT(nbt);
    		if (totalEnergy < 0)
    		{
    			totalEnergy = 0;
    		}
    		nbt.setInteger("totalEnergy", totalEnergy);
    		NBTTagList list = new NBTTagList();
    		for(int i = 0; i <6; i++)
    		{
    			NBTTagCompound a = new NBTTagCompound();
    			a.setBoolean("side" + i, this.sideType[i]);
    			list.appendTag(a);
    		}
    		nbt.setTag("sideType", list);
    		//LOGGER.info("write"+nbt.toString());
    		return nbt;
    	}

    I just want to save the block's side config data(as written above the NBTTagList list), but it got an error that once rejoin all side config lose and reset.

    And then I tried to output the "nbt" (LOGGER.info("read"+nbt.toString());),  and find that (log)  L650, L671, L674

    [13:51:27] [Server thread/INFO]: read{sideType:[0:{side0:0b},1:{side1:0b},2:{side2:1b},3:{side3:0b},4:{side4:0b},5:{side5:0b}],Energy:0,totalEnergy:0,x:-189,y:64,z:235,id:"energyconversion:PowerBlock"}
    [13:51:28] [Server thread/INFO]: VoiceServer: Starting up server...
    [13:51:28] [Server thread/INFO]: Changing view distance to 12, from 10
    [13:51:31] [Netty Local Client IO #0/INFO]: Server protocol version 2
    [13:51:31] [Netty Server IO #1/INFO]: Client protocol version 2
    [13:51:31] [Netty Server IO #1/INFO]: Client attempting to join with 22 mods : CodeChickenLib@2.5.9.283,MekanismGenerators@9.2.4,FML@8.0.99.99,theoneprobe@1.4.18,thermalexpansion@5.1.6,tesla@1.2.1.49,inventorytweaks@1.61-58-a1fd884,thermaldynamics@2.0.7,Forge@12.18.3.2422,<CoFH ASM>@000,Baubles@1.3.11,JEI@3.14.7.419,cofhcore@4.1.6,Mekanism@9.2.4,someusefulthings@1.0,mcmultipart@2.0.0_88,MekanismTools@9.2.4,energyconversion@1.0,thermalfoundation@2.1.2,IC2@2.6.234-ex110,mcp@9.19,ccl-entityhook@1.0
    [13:51:31] [Netty Local Client IO #0/INFO]: [Netty Local Client IO #0] Client side modded connection established
    [13:51:31] [Server thread/INFO]: [Server thread] Server side modded connection established
    [13:51:31] [Server thread/INFO]: 0x00000000[local:E:db3c6b1b] logged in with entity id 390 at (-187.07428959339794, 64.0, 233.18476770205746)
    [13:51:31] [Server thread/INFO]: 0x00000000 joined the game
    [13:51:31] [Server thread/INFO]: Sent config to 'TextComponent{text='', siblings=[TextComponent{text='0x00000000', siblings=[], style=Style{hasParent=true, color=null, bold=null, italic=null, underlined=null, obfuscated=null, clickEvent=ClickEvent{action=SUGGEST_COMMAND, value='/msg 0x00000000 '}, hoverEvent=HoverEvent{action=SHOW_ENTITY, value='TextComponent{text='{name:"0x00000000",id:"e1965b52-bc8f-995f-3766-d820e4b3717b"}', siblings=[], style=Style{hasParent=false, color=null, bold=null, italic=null, underlined=null, obfuscated=null, clickEvent=null, hoverEvent=null, insertion=null}}'}, insertion=0x00000000}}], style=Style{hasParent=false, color=null, bold=null, italic=null, underlined=null, obfuscated=null, clickEvent=ClickEvent{action=SUGGEST_COMMAND, value='/msg 0x00000000 '}, hoverEvent=HoverEvent{action=SHOW_ENTITY, value='TextComponent{text='{name:"0x00000000",id:"e1965b52-bc8f-995f-3766-d820e4b3717b"}', siblings=[], style=Style{hasParent=false, color=null, bold=null, italic=null, underlined=null, obfuscated=null, clickEvent=null, hoverEvent=null, insertion=null}}'}, insertion=0x00000000}}.'
    [13:51:33] [Server thread/INFO]: Saving and pausing game...
    [13:51:33] [Client thread/INFO]: Minecraft is in offline mode, could not check for updates.
    [13:51:33] [Client thread/INFO]: [CHAT] InvTweaks: Configuration loaded.
    [13:51:33] [Netty Local Client IO #0/INFO]: Received config from server.
    [13:51:33] [Netty Local Client IO #0/INFO]: Received Cardboard Box blacklist entries from server (15 total)
    [13:51:33] [Thread-15/INFO]: VoiceServer: Starting client connection...
    [13:51:33] [Server thread/INFO]: Saving chunks for level 'New World'/Overworld
    [13:51:33] [Thread-15/INFO]: VoiceServer: Successfully connected to server.
    [13:51:33] [VoiceServer Listen Thread/INFO]: VoiceServer: Accepted new connection.
    [13:51:33] [Thread-17/INFO]: VoiceServer: Traced IP in 1 attempts.
    [13:51:33] [Server thread/INFO]: write{sideType:[0:{side0:0b},1:{side1:0b},2:{side2:1b},3:{side3:0b},4:{side4:0b},5:{side5:0b}],Energy:0,totalEnergy:0,x:-189,y:64,z:235,id:"energyconversion:PowerBlock"}
    [13:51:33] [Server thread/INFO]: Saving chunks for level 'New World'/Nether
    [13:51:33] [Server thread/INFO]: Saving chunks for level 'New World'/The End
    [13:51:33] [Client thread/INFO]: read{x:-189,y:64,z:235,id:"energyconversion:PowerBlock"}
    [13:51:33] [Client thread/FATAL]: Error executing task
    java.util.concurrent.ExecutionException: java.lang.NullPointerException
    	at java.util.concurrent.FutureTask.report(Unknown Source) ~[?:1.8.0_141]
    	at java.util.concurrent.FutureTask.get(Unknown Source) ~[?:1.8.0_141]
    	at net.minecraft.util.Util.func_181617_a(SourceFile:46) [h.class:?]
    	at net.minecraft.client.Minecraft.func_71411_J(Minecraft.java:1045) [bcx.class:?]
    	at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:371) [bcx.class:?]
    	at net.minecraft.client.main.Main.main(SourceFile:124) [Main.class:?]
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_141]
    	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_141]
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_141]
    	at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_141]
    	at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?]
    	at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?]
    Caused by: java.lang.NullPointerException
    	at com.bxzmod.energyconversion.tileentity.PowerBlockTileEntity.func_145839_a(PowerBlockTileEntity.java:109) ~[PowerBlockTileEntity.class:?]
    	at net.minecraft.tileentity.TileEntity.handleUpdateTag(TileEntity.java:341) ~[aqk.class:?]
    	at net.minecraft.client.network.NetHandlerPlayClient.func_147263_a(NetHandlerPlayClient.java:728) ~[bll.class:?]
    	at net.minecraft.network.play.server.SPacketChunkData.func_148833_a(SourceFile:96) ~[gt.class:?]
    	at net.minecraft.network.play.server.SPacketChunkData.func_148833_a(SourceFile:18) ~[gt.class:?]
    	at net.minecraft.network.PacketThreadUtil$1.run(SourceFile:13) ~[fl$1.class:?]
    	at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) ~[?:1.8.0_141]
    	at java.util.concurrent.FutureTask.run(Unknown Source) ~[?:1.8.0_141]
    	at net.minecraft.util.Util.func_181617_a(SourceFile:45) ~[h.class:?]
    	... 9 more

     

    L671    The "writeToNBT" output   write{sideType:[0:{side0:0b},1:{side1:0b},2:{side2:1b},3:{side3:0b},4:{side4:0b},5:{side5:0b}],Energy:0,totalEnergy:0,x:-189,y:64,z:235,id:"energyconversion:PowerBlock"}

    L674    The "readFromNBT" Output    read{x:-189,y:64,z:235,id:"energyconversion:PowerBlock"   do not contain any additional nbt. 

    But other nbt "totalEnergy" and "Energy" works . Just "sideType" got wrong.

     

  7. Oh,thank you! I change it to

    	@Override
    	public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos)
    	{
    		IExtendedBlockState s = (IExtendedBlockState) state;
    		PowerBlockTileEntity te = (PowerBlockTileEntity) worldIn.getTileEntity(pos);
    		return s.withProperty(SIDE_CONFIG, te.getByte());
    	}

    But , suddenly find that this doesn't work:  (TileEntity)

    	@Override
    	public NBTTagCompound writeToNBT(NBTTagCompound nbt)
    	{
    
    		super.writeToNBT(nbt);
    		nbt = storage.writeToNBT(nbt);
    		if (totalEnergy < 0)
    		{
    			totalEnergy = 0;
    		}
    		nbt.setInteger("totalEnergy", totalEnergy);
    		nbt.setByteArray("sideType", this.bSideType);//this don't work
    		return nbt;
    	}

    game log show that

    MC: Caused by: java.lang.ArrayIndexOutOfBoundsException
    MC:     at java.lang.System.arraycopy(Native Method) ~[?:1.8.0_141]
    MC:     at com.bxzmod.energyconversion.tileentity.PowerBlockTileEntity.func_145839_a(PowerBlockTileEntity.java:103) ~[PowerBlockTileEntity.class:?]
    

    the code

    	@Override
    	public void readFromNBT(NBTTagCompound nbt)
    	{
    
    		super.readFromNBT(nbt);
    		this.totalEnergy = nbt.getInteger("totalEnergy");
    		System.arraycopy(nbt.getByteArray("sideType"), 0, this.bSideType, 0, 6);//here the problem
    		if (totalEnergy > capacity)
    		{
    			totalEnergy = capacity;
    		}
    		storage.readFromNBT(nbt);
    	}

    and my baked model seems not work 

    I tried to use this:  (BakedModel)

    LOGGER.info(extendedBlockState.getValue(PowerBlock.SIDE_CONFIG).toString());
    Minecraft.getMinecraft().thePlayer.addChatMessage(
    		new TextComponentString(extendedBlockState.getValue(PowerBlock.SIDE_CONFIG).toString()));

    to check block state work or not. But I didn't see any message show in game log and chat bar.

  8. All codes : GitHub

    Model here

          1.The block (codes here) can place ,and model works. But get crash when reload world(saved game and rejoin)  (I think it cause by can't get extend block state).  game log(L729 crash)

    I find that 

    Caused by: java.lang.ArrayIndexOutOfBoundsException: 0
    at com.bxzmod.energyconversion.blocks.blockmodel.PowerBlockBakedModel.func_188616_a(PowerBlockBakedModel.java:142) ~[PowerBlockBakedModel.class:?]

    In my code is (here)

    	@Override
    	public List<BakedQuad> getQuads(IBlockState state, EnumFacing side, long rand)
    	{
    		IExtendedBlockState extendedBlockState;
    		List<BakedQuad> quads = new ArrayList<>();
    
    		if (state == null)
    		{
    			for (EnumFacing f : EnumFacing.values())
    				quads.add(this.setQuad(f, 0));
    			return quads;
    		} else
    			extendedBlockState = (IExtendedBlockState) state;
    		if (side == null)
    		{
    			return Collections.emptyList();
    		}
    		byte[] a = extendedBlockState.getValue(PowerBlock.SIDE_CONFIG);
    		quads.add(this.setQuad(side, a[side.getIndex()]));
    		return quads;
    	}

    Does this crash mean that the model is loaded earlier than TileEntity?Or the parameter "state" not from block.getExtendedState ?

    And how can I repair it?

         2.When I change extend block state in TileEntity(codes here),it doesn't immediate refresh. I need to place a block to refresh it.

    	public void setSideType(EnumFacing form)
    	{
    		this.bSideType[form.getIndex()] = (byte) (this.bSideType[form.getIndex()] == 1 ? 0 : 1);
    		IExtendedBlockState extendedBlockState = (IExtendedBlockState) this.worldObj.getBlockState(this.pos);
    		extendedBlockState = extendedBlockState.withProperty(PowerBlock.SIDE_CONFIG, this.bSideType);
    	}

    Does this can update extend block state?If not ,how can i update extend block state ,I tried to use this.worldObj.setBlockState ,but crashed.

        3.Something I don't know what is wrong.

    Block side render was effected with it's opposite side.(codes here)

    This code from Mcjty's tutorial(here)(I don't understand what this mean)(Can someone explain it for me?)

    	private BakedQuad createQuad(Vec3d v1, Vec3d v2, Vec3d v3, Vec3d v4, int num)
    	{
    		Vec3d normal = v1.subtract(v2).crossProduct(v3.subtract(v2));
    		UnpackedBakedQuad.Builder builder = new UnpackedBakedQuad.Builder(format);
    		builder.setTexture(sprite[num]);
    		putVertex(builder, normal, v1.xCoord, v1.yCoord, v1.zCoord, 0, 0, num);
    		putVertex(builder, normal, v2.xCoord, v2.yCoord, v2.zCoord, 0, 16, num);
    		putVertex(builder, normal, v3.xCoord, v3.yCoord, v3.zCoord, 16, 16, num);
    		putVertex(builder, normal, v4.xCoord, v4.yCoord, v4.zCoord, 16, 0, num);
    		return builder.build();
    	}
    
    	private void putVertex(UnpackedBakedQuad.Builder builder, Vec3d normal, double x, double y, double z, float u,
    			float v, int num)
    	{
    		for (int e = 0; e < format.getElementCount(); e++)
    		{
    			switch (format.getElement(e).getUsage())
    			{
    			case POSITION:
    				builder.put(e, (float) x, (float) y, (float) z, 1.0f);
    				break;
    			case COLOR:
    				builder.put(e, 1.0f, 1.0f, 1.0f, 1.0f);
    				break;
    			case UV:
    				if (format.getElement(e).getIndex() == 0)
    				{
    					u = sprite[num].getInterpolatedU(u);
    					v = sprite[num].getInterpolatedV(v);
    					builder.put(e, u, v, 0f, 1f);
    					break;
    				}
    			case NORMAL:
    				builder.put(e, (float) normal.xCoord, (float) normal.yCoord, (float) normal.zCoord, 0f);
    				break;
    			default:
    				builder.put(e);
    				break;
    			}
    		}
    	}

    tHiIe.pngtHAGd.pngtHkPH.png

     

     

  9. I'm sorry , I don't know the meaning of the log.

    Could you tell me what's wrong with it?

    I only set two textures 

    at https://github.com/bxz2311196368/bxzpower/blob/master/src/main/java/com/bxzmod/energyconversion/blocks/blockmodel/PowerBlockBakedModel.java#L39

    	sprite[0] = bakedTextureGetter.apply(new ResourceLocation(Info.MODID, "blocks/power_block_in"));
    	sprite[1] = bakedTextureGetter.apply(new ResourceLocation(Info.MODID, "blocks/power_block_out"));

    https://github.com/bxz2311196368/bxzpower/blob/master/src/main/java/com/bxzmod/energyconversion/blocks/blockmodel/PowerBlockModel.java#L28

    	@Override
    	public Collection<ResourceLocation> getTextures()
    	{
    		return ImmutableSet.of(new ResourceLocation(Info.MODID, "blocks/power_block_in"),
    				new ResourceLocation(Info.MODID, "blocks/power_block_out"));
    	}

     

     

    And there is a problem :

    https://github.com/bxz2311196368/bxzpower/blob/master/src/main/java/com/bxzmod/energyconversion/blocks/blockmodel/PowerBlockBakedModel.java#L148

    	@Override
    	public TextureAtlasSprite getParticleTexture()
    	{
    		return sprite[0];
    	}

    I have two textures, but it can only return one, so I return one of them.

    Please help me to check what's wrong.

  10. Thank you! I made a stupid mistake.

    I changed it to:

    private TextureAtlasSprite sprite[] = new TextureAtlasSprite[2];

    it works. 

    But,I got another crash when rending item.

    I'am sorry ,I don't know how item render works.So I don't know where it went wrong.

    game log Crash Report start L608:

    http://paste.ubuntu.com/25667178/

    itemblock render at :

    https://github.com/bxz2311196368/bxzpower/blob/master/src/main/java/com/bxzmod/energyconversion/blocks/BlockRenderLoader.java#L36

  11. New to modding.

    Learn from mcjty's tutorials

    https://wiki.mcjty.eu/modding/index.php/Render_Block_Baked_Model-1.9

    Want to set two type textures for every side. Just like RF energy storage show send/receive on each side.

    game log: Crash Report start L477

    http://paste.ubuntu.com/25666108/

    codes here:

    https://github.com/bxz2311196368/bxzpower/tree/master/src/main/java/com/bxzmod/energyconversion/blocks/blockmodel

    I know error is here:

    https://github.com/bxz2311196368/bxzpower/blob/master/src/main/java/com/bxzmod/energyconversion/blocks/blockmodel/PowerBlockBakedModel.java#L39

    But I don't know how to repair it.

×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.