Jump to content

Recommended Posts

Posted

Hi there !

 

I've created a two blocks tall corn crop. When you break the lower block, the upper block is supposed to break, but it doesn't !Also, if you grow a single crop at it's max, all the upper part of other crops, even when they're not totally grown, will render as grown as the most grown crop.

And if I quit the game, with some corn in it, when I want to play on the save with corn, the came crashs.

 

A few other details:

-Bone powder doesn't work on the upper part

-The "link" between the crops occur even if they don't share any X, Y, or Z axis

 

 

The crash report

 

---- Minecraft Crash Report ----
// This is a token for 1 free hug. Redeem at your nearest Mojangsta: [~~HUG~~]

Time: 04/09/14 12:36
Description: Unexpected error

java.lang.NullPointerException: Unexpected error
at com.hamsterfurtif.elisancecraft.blocks.BlockMais.getIcon(BlockMais.java:103)
at net.minecraft.client.renderer.RenderBlocks.getBlockIconFromSideAndMetadata(RenderBlocks.java:8203)
at net.minecraft.client.renderer.RenderBlocks.renderCrossedSquares(RenderBlocks.java:3548)
at net.minecraft.client.renderer.RenderBlocks.renderBlockByRenderType(RenderBlocks.java:255)
at net.minecraft.client.renderer.WorldRenderer.updateRenderer(WorldRenderer.java:180)
at net.minecraft.client.renderer.RenderGlobal.updateRenderers(RenderGlobal.java:1522)
at net.minecraft.client.renderer.EntityRenderer.renderWorld(EntityRenderer.java:1175)
at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1010)
at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:942)
at net.minecraft.client.Minecraft.run(Minecraft.java:833)
at net.minecraft.client.main.Main.main(SourceFile:103)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at net.minecraft.launchwrapper.Launch.launch(Launch.java:134)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)


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

-- Head --
Stacktrace:
at com.hamsterfurtif.elisancecraft.blocks.BlockMais.getIcon(BlockMais.java:103)
at net.minecraft.client.renderer.RenderBlocks.getBlockIconFromSideAndMetadata(RenderBlocks.java:8203)
at net.minecraft.client.renderer.RenderBlocks.renderCrossedSquares(RenderBlocks.java:3548)
at net.minecraft.client.renderer.RenderBlocks.renderBlockByRenderType(RenderBlocks.java:255)
at net.minecraft.client.renderer.WorldRenderer.updateRenderer(WorldRenderer.java:180)
at net.minecraft.client.renderer.RenderGlobal.updateRenderers(RenderGlobal.java:1522)
at net.minecraft.client.renderer.EntityRenderer.renderWorld(EntityRenderer.java:1175)

-- Affected level --
Details:
Level name: MpServer
All players: 1 total; [EntityClientPlayerMP['Player613'/203, l='MpServer', x=-27,42, y=68,62, z=188,89]]
Chunk stats: MultiplayerChunkCache: 45, 45
Level seed: 0
Level generator: ID 00 - default, ver 1. Features enabled: false
Level generator options:
Level spawn location: World: (-40,64,200), Chunk: (at 8,4,8 in -3,12; contains blocks -48,0,192 to -33,255,207), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,0,0 to -1,255,511)
Level time: 787 game time, 787 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: 17 total; [EntityWolf['Wolf'/96, l='MpServer', x=-32,25, y=63,00, z=147,50], EntityPig['Pig'/97, l='MpServer', x=-33,88, y=68,00, z=170,31], EntityBat['Bat'/131, l='MpServer', x=3,11, y=24,00, z=194,42], EntityChicken['Chicken'/133, l='MpServer', x=30,50, y=63,00, z=198,50], EntityChicken['Chicken'/134, l='MpServer', x=31,63, y=63,00, z=199,47], EntityClientPlayerMP['Player613'/203, l='MpServer', x=-27,42, y=68,62, z=188,89], EntityPig['Pig'/108, l='MpServer', x=-22,50, y=68,00, z=173,59], EntityPig['Pig'/109, l='MpServer', x=-27,09, y=68,00, z=165,03], EntityPig['Pig'/110, l='MpServer', x=-17,19, y=69,00, z=162,72], EntityCow['Cow'/80, l='MpServer', x=-78,50, y=75,00, z=221,50], EntityCow['Cow'/81, l='MpServer', x=-75,50, y=68,00, z=220,50], EntityCow['Cow'/82, l='MpServer', x=-67,25, y=69,00, z=219,41], EntityCow['Cow'/83, l='MpServer', x=-78,50, y=67,00, z=224,50], EntityBat['Bat'/87, l='MpServer', x=-50,47, y=19,10, z=216,41], EntityWolf['Wolf'/93, l='MpServer', x=-36,50, y=63,00, z=139,50], EntityWolf['Wolf'/94, l='MpServer', x=-36,50, y=64,00, z=138,50], EntityWolf['Wolf'/95, l='MpServer', x=-35,50, y=73,00, z=137,50]]
Retry entities: 0 total; []
Server brand: fml,forge
Server type: Integrated singleplayer server
Stacktrace:
at net.minecraft.client.multiplayer.WorldClient.addWorldInfoToCrashReport(WorldClient.java:368)
at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:2380)
at net.minecraft.client.Minecraft.run(Minecraft.java:862)
at net.minecraft.client.main.Main.main(SourceFile:103)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at net.minecraft.launchwrapper.Launch.launch(Launch.java:134)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)

-- System Details --
Details:
Minecraft Version: 1.7.2
Operating System: Windows 7 (amd64) version 6.1
Java Version: 1.8.0_05, Oracle Corporation
Java VM Version: Java HotSpot™ 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 41342504 bytes (39 MB) / 236453888 bytes (225 MB) up to 1430257664 bytes (1364 MB)
JVM Flags: 0 total;
AABB Pool Size: 15779 (883624 bytes; 0 MB) allocated, 1145 (64120 bytes; 0 MB) used
IntCache: cache: 0, tcache: 0, allocated: 13, tallocated: 95
FML: MCP v9.01-pre FML v7.2.156.1060 Minecraft Forge 10.12.1.1060 4 mods loaded, 4 mods active
mcp{8.09} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
FML{7.2.156.1060} [Forge Mod Loader] (forgeBin-1.7.2-10.12.1.1060.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
Forge{10.12.1.1060} [Minecraft Forge] (forgeBin-1.7.2-10.12.1.1060.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
elisancecraft{1.0} [Elisancecraft] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
Launched Version: 1.6
LWJGL: 2.9.0
OpenGL: GeForce GTS 240/PCIe/SSE2 GL version 3.3.0, NVIDIA Corporation
Is Modded: Definitely; Client brand changed to 'fml,forge'
Type: Client (map_client.txt)
Resource Packs: []
Current Language: ~~ERROR~~ NullPointerException: null
Profiler Position: N/A (disabled)
Vec3 Pool Size: 288 (16128 bytes; 0 MB) allocated, 288 (16128 bytes; 0 MB) used
Anisotropic Filtering: Off (1)

 

 

Lower crop class:

 

package com.hamsterfurtif.elisancecraft.blocks;

import com.hamsterfurtif.elisancecraft.ElisanceCraftMOD;
import com.hamsterfurtif.elisancecraft.lib.References;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.BlockCrops;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;

@SuppressWarnings("unused")
public class BlockMais extends BlockCrops
{
    private IIcon[] iIcon;
int f_posX;
int f_posY;
int f_posZ;
World f_world;

    @Override
    public boolean canBlockStay (World world, int posX, int posY, int posZ) 
    {

    	
    	Block dessous = world.getBlock(posX, posY - 1, posZ);
    	Block dessus = world.getBlock(posX, posY + 1, posZ);
    	int met = world.getBlockMetadata(posX, posY, posZ);


    	if (dessous == Blocks.farmland && dessus == ElisanceCraftMOD.mais_pousse_top)
    	{
    		
    		return true;
    	}

    	else 
    	{
    		return false;
    	}
    	
    	
    }
    
    

    
    


    protected Item func_149866_P()
    {
        return ElisanceCraftMOD.mais_epis;
    }

    protected Item func_149865_i()
    {
        return ElisanceCraftMOD.mais_epis;
        
    }
    
    public void onBlockAdded (World world, int posX, int posY, int posZ)
    {
    	this.f_posX = posX;
    	this.f_posY = posY;
    	this.f_posZ = posZ;
    	this.f_world = world;
    	world.setBlock(posX, posY + 1, posZ, ElisanceCraftMOD.mais_pousse_top);
    }

    @Override
  
    public void registerBlockIcons(IIconRegister parIIconRegister)
    {
          iIcon = new IIcon[8];
          iIcon[0] = parIIconRegister.registerIcon(References.MODID + ":pousse_mais_stage_0");
          iIcon[1] = parIIconRegister.registerIcon(References.MODID + ":pousse_mais_stage_0");
          iIcon[2] = parIIconRegister.registerIcon(References.MODID + ":pousse_mais_stage_1");
          iIcon[3] = parIIconRegister.registerIcon(References.MODID + ":pousse_mais_stage_1");
          iIcon[4] = parIIconRegister.registerIcon(References.MODID + ":pousse_mais_stage_2");
          iIcon[5] = parIIconRegister.registerIcon(References.MODID + ":pousse_mais_stage_2");
          iIcon[6] = parIIconRegister.registerIcon(References.MODID + ":pousse_mais_stage_3");
          iIcon[7] = parIIconRegister.registerIcon(References.MODID + ":pousse_mais_stage_3");
    }
     
    
    public IIcon getIcon(int parSide, int parGrowthStage)
    {
    	if ( parGrowthStage > 3 && parGrowthStage < 6)
    	{
    		f_world.setBlockMetadataWithNotify(f_posX, f_posY + 1, f_posZ, 1, 2);
    	}
    	else if ( parGrowthStage > 5)
    	{
    		f_world.setBlockMetadataWithNotify(f_posX, f_posY + 1, f_posZ, 2, 2);
    	}
    		
    	return iIcon[parGrowthStage];
    }
    
    

    
    

    public int getRenderType()
    {
    	return 1;
    }
    
    public Item getItem(World world, int posX, int posY, int posZ)
    {
        return ElisanceCraftMOD.mais_epis;
    }
}
    
    

 

 

Upper crop class:

 

package com.hamsterfurtif.elisancecraft.blocks;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;

import com.hamsterfurtif.elisancecraft.ElisanceCraftMOD;
import com.hamsterfurtif.elisancecraft.lib.References;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

public class BlockMaisTop extends Block{

IIcon[] iIcon;
int f_posX;
int f_posY;
int f_posZ;
World f_world;



public BlockMaisTop()
{
	super(Material.plants);
	this.setHardness(0);
	this.setResistance(0);
	this.setBlockName("mais_pousse_top");


}



    public void onBlockAdded (World world, int posX, int posY, int posZ)
    {
    	this.f_posX = posX;
    	this.f_posY = posY;
    	this.f_posZ = posZ;
    	this.f_world = world;
    	world.setBlockMetadataWithNotify(posX, posY, posZ, 0, 2);
    }


    public boolean isOpaqueCube()
    {
    		return false;
    }
    
    public boolean renderAsNormalBlock()
    {
    	return false;
    }

    public int getRenderType()
    {
    	return 1;
    }
    
    @Override
    @SideOnly(Side.CLIENT)
    public void registerBlockIcons(IIconRegister parIIconRegister)
    {
          iIcon = new IIcon[3];
          // seems that crops like to have 8 growth icons, but okay to repeat actual texture if you want
          iIcon[0] = parIIconRegister.registerIcon(References.MODID + ":pousse_mais_top_stage_0");
          iIcon[1] = parIIconRegister.registerIcon(References.MODID + ":pousse_mais_top_stage_2");
          iIcon[2] = parIIconRegister.registerIcon(References.MODID + ":pousse_mais_top_stage_3");

    }
     
    @SideOnly(Side.CLIENT)
    public IIcon getIcon(int parSide, int parGrowthStage)
    {
    	return iIcon[this.f_world.getBlockMetadata(f_posX, f_posY, f_posZ)];
    }
    


    public boolean canBlockStay (World world, int posX, int posY, int posZ) 
    {
    	
       // Block soil = blocksList[world.getBlockId(x, y - 1, z)];
       //return (world.getFullBlockLightValue(x, y, z) >= 8 || world.canBlockSeeTheSky(x, y, z)) && (soil != null && soil.canSustainPlant(world, x, y - 1, z,ForgeDirection.UP, Generic.tomatoSeeds));
    	//this.blockdudessu(world, posX, posY, posZ);
    	
    	Block dessous = world.getBlock(posX, posY, posZ);

    	if (dessous == ElisanceCraftMOD.mais_pousse && !isAir(world, posX, posY - 1, posZ))
    	{
    		
    		return true;
    	}

    	else 
    	{
    		return false;
    	}
    	
    	
    }
    
    public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int posX, int posY, int posZ)
    {
        return null;
    }
    

    

}

 

 

A few screenshots to help you understand :

 

1rst stage for all

I starts growing the middle crop only

As you see, the upper blocks grow all together

I break the middle crop

Then all the lower crops. The upper blocks don't break.

Even when they're not side by side,

the upper blocks grow  all together,

even when they're not at the same height,

or if they don't share any axes !

 

 

 

 

Posted

Save all variables in a tile entity, I have had problems like this in the past. Add an onBlockDestroyed to the lower that destroys the upper. Either add a method for registering right clicks to the upper block or also make it extend blockcrops. Do you speak French, looking at variable names :)? Hope this helps!

Posted

Eternaldoom:

 

I wanted to change the upper block metadata as the lower block's change, and as the getIcon function is kind of linked with the metadata, I thought  it would be the easier way to do so.

 

david476:

 

In the  world.destroyBlockInWorldPartially(posX, posY, posZ, 0, 2) function, what I am supposed to use as the two last arguments ?

 

By the way, yes, I'm french.

Posted

For just making a block go away use setBlockToAir. If you want to do more advanced things use setBlock. To see descriptions of methods in eclipse, type "." (after class, variable, etc...) or press Ctrl + Space and then select the method (do not double click or press enter) and another popup should appear next to it.

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.