+ Antworten
Ergebnis 1 bis 7 von 7
  1. #1
    Super Architekt Avatar von Stuuupiiid
    Registriert seit
    22.04.2011
    Beiträge
    1.077
    Minecraft
    Stuuupiiid

    Hilfe bei TileEntity!

    Joa, also bei einem Server Command passiert folgendes:

    Code:
    player.worldObj.setBlockWithNotify(Mod.blablaBlock, x, y, z);
    TileEntityBla bla = (TileEntityBla) player.worldObj.getBlockTileEntity(x, y, z);
    bla.f = "ein String";
    bla.z = "ein neuer String :OO";
    doch das will nicht funktionieren (NullPointerException)

    Und nebenbei wollte ich noch wissen, was "NBT" ist und wofür das gut ist?

  2. #2
    Creeper-Jäger
    Registriert seit
    01.05.2012
    Beiträge
    247
    Minecraft
    firefligher
    NBT ist eine Art Speichermöglichkeit für Blöcke, in der man z.B. Zustände von Variablen speichern kann.
    Könntest du deinen Block posten (Code)? Hast du unter Forge den Block in die EntityRegistry reingeschrieben?
    Satzzeichen sind keine Rudeltiere.

  3. #3
    Super Architekt Avatar von Stuuupiiid
    Registriert seit
    22.04.2011
    Beiträge
    1.077
    Minecraft
    Stuuupiiid
    Zitat Zitat von firefligher Beitrag anzeigen
    NBT ist eine Art Speichermöglichkeit für Blöcke, in der man z.B. Zustände von Variablen speichern kann.
    Könntest du deinen Block posten (Code)? Hast du unter Forge den Block in die EntityRegistry reingeschrieben?
    TileEntities kommen doch in die GameRegistry (registerTileEntity(class, "name"))?

    jedenfalls:

    Code:
    package gamemodes;
    
    import java.util.ArrayList;
    import java.util.Iterator;
    import java.util.List;
    
    import net.minecraft.entity.player.EntityPlayer;
    import net.minecraft.tileentity.TileEntity;
    import net.minecraft.util.AxisAlignedBB;
    
    public class TileEntityEntry extends TileEntity
    {
    	public String z = null;
    	public String f = null;
    	private Zone zone = null;
    	public TileEntityFlagPole flag = null;
    	public ArrayList<TileEntitySpawn> spawnerList = new ArrayList<TileEntitySpawn>();
    	private boolean done = false;
    	
    	public void updateEntity()
    	{
    		if(!this.done)
    		{
    			for(int v1 = 0; v1 < Zone.instance().listZones.size(); ++v1)
    			{
    				if(Zone.instance().listZones.get(v1).zoneName.equals(this.z))
    				{
    					this.zone = Zone.instance().listZones.get(v1);
    					for(int v2 = 0; v2 < zone.flags.size(); ++v2)
    					{
    						if(zone.flags.get(v2).flagName.equals(this.f))
    						{
    							this.flag = zone.flags.get(v2);
    							this.done = true;
    							break;
    						}
    					}
    					break;
    				}
    			}
    		}
    		if(!this.spawnerList.isEmpty() && this.done)
    		{
    			if(this.z != null)
    			{
    		        AxisAlignedBB var4 = AxisAlignedBB.getAABBPool().addOrModifyAABBInPool((double)this.xCoord, (double)this.yCoord, (double)this.zCoord, (double)(this.xCoord + 1), (double)(this.yCoord + 1), (double)(this.zCoord + 1)).expand(1, 1, 1);
    		        List var5 = this.worldObj.getEntitiesWithinAABB(EntityPlayer.class, var4);
    		        Iterator var6 = var5.iterator();
    
    		        if(var6.hasNext())
    		        {
    		            spawn();
    		        }
    			}
    		}
    	}
    	
        public void spawn()
        {
        }
    }
    Code:
    package gamemodes;
    
    import net.minecraft.block.Block;
    import net.minecraft.block.material.Material;
    import net.minecraft.creativetab.CreativeTabs;
    import net.minecraft.tileentity.TileEntity;
    import net.minecraft.world.World;
    
    public class BlockEntry extends Block
    {
    	public BlockEntry(int par1)
    	{
    		super(par1, 41, Material.rock);
    		this.setCreativeTab(CreativeTabs.tabMisc);
    	}
    	
        public TileEntity createNewTileEntity(World par1World)
        {
            return new TileEntityEntry();
        }
    }

  4. #4
    Creeper-Jäger
    Registriert seit
    01.05.2012
    Beiträge
    247
    Minecraft
    firefligher
    TileEntities kommen doch in die GameRegistry (registerTileEntity(class, "name"))?
    Ups, tschuldige, mein Fehler

    extends Block
    Dein Block muss BlockContainer extenden.
    Satzzeichen sind keine Rudeltiere.

  5. #5
    Super Architekt Avatar von Stuuupiiid
    Registriert seit
    22.04.2011
    Beiträge
    1.077
    Minecraft
    Stuuupiiid
    das war schonmal ein Problem, danke.
    Ich bekomm jedoch immernoch Fehler bei:

    Code:
    player.worldObj.setBlockWithNotify(Mod.blablaBlock, x, y, z);
    TileEntityEntry bla = (TileEntityEntry) player.worldObj.getBlockTileEntity(x, y, z);
    bla.f = "ein String";
    bla.z = "ein neuer String :OO";
    EDIT: hab die Strings ausversehen oben nicht hingeschrieben, sie sind aber da
    Geändert von Stuuupiiid (22.12.2012 um 08:56 Uhr)

  6. #6
    Creeper-Jäger
    Registriert seit
    01.05.2012
    Beiträge
    247
    Minecraft
    firefligher
    Ich glaub du solltest folgendes noch versuchen:
    Code:
    player.worldObj.setBlockWithNotify(Mod.blablaBlock, x, y, z);
    TileEntityEntry bla = (TileEntityEntry) player.worldObj.getBlockTileEntity(x, y, z);
    if(bla != null) {
        bla.f = "ein String";
        bla.z = "ein neuer String :OO";
    }
    oder falls dass nichts bringt:
    Code:
    player.worldObj.setBlockWithNotify(Mod.blablaBlock, x, y, z);
    TileEntityEntry bla = (TileEntityEntry) player.worldObj.getBlockTileEntity(x, y, z);
    if(!player.worldObj.isRemote) {
        bla.f = "ein String";
        bla.z = "ein neuer String :OO";
    }
    Satzzeichen sind keine Rudeltiere.

  7. #7
    Super Architekt Avatar von Stuuupiiid
    Registriert seit
    22.04.2011
    Beiträge
    1.077
    Minecraft
    Stuuupiiid
    Zitat Zitat von firefligher Beitrag anzeigen
    Ich glaub du solltest folgendes noch versuchen:
    Code:
    player.worldObj.setBlockWithNotify(Mod.blablaBlock, x, y, z);
    TileEntityEntry bla = (TileEntityEntry) player.worldObj.getBlockTileEntity(x, y, z);
    if(bla != null) {
        bla.f = "ein String";
        bla.z = "ein neuer String :OO";
    }
    oder falls dass nichts bringt:
    Code:
    player.worldObj.setBlockWithNotify(Mod.blablaBlock, x, y, z);
    TileEntityEntry bla = (TileEntityEntry) player.worldObj.getBlockTileEntity(x, y, z);
    if(!player.worldObj.isRemote) {
        bla.f = "ein String";
        bla.z = "ein neuer String :OO";
    }
    bla war anscheinend immer null:

    Code:
    player.worldObj.setBlockWithNotify(Mod.blablaBlock, x, y, z);
    player.worldObj.setBlockWithNotify(x, y, z, Mod.blablaBlock);
    Ich bin so ein Trottel
    danke jedenfalls

+ Antworten