un probléme avec un item qui fait spawn une entity.



  • Bonjour/Bonsoir j'ai un petit probleme avec un de mes item moddée.

    je vais d'abord vous expliquez se qu'il fait:
    il fait spawn une structure (generer avec un .schematic) avec a l'interieur un mob modé.

    Erreur:
    tout marche bien sauf qu'il y a deux mob un normal puis un autre qui ne fait rien ne marche pas.
    puis le seul moyen de le faire despawn ses de deco reco du monde.

    (celle a droite est celle sans IA)
    0_1531661479337_2018-07-15_15.26.28.png

    Mon code:

    ce qui fait spawn mon entity est en bas.

    package com.scpcraft.items;
    
    import java.util.List;
    
    import com.scpcraft.init.SCPItem;
    import com.scpcraft.mod.SCPMod;
    
    import net.minecraft.block.Block;
    import net.minecraft.creativetab.CreativeTabs;
    import net.minecraft.entity.Entity;
    import net.minecraft.entity.EntityList;
    import net.minecraft.entity.player.EntityPlayer;
    import net.minecraft.init.Items;
    import net.minecraft.item.Item;
    import net.minecraft.item.ItemStack;
    import net.minecraft.server.MinecraftServer;
    import net.minecraft.util.ChatComponentText;
    import net.minecraft.world.World;
    
    public class SCPDocument173 extends Item {
    
    	public SCPDocument173(int par1) {
    		setMaxDamage(0);
    		maxStackSize = 1;
    		setUnlocalizedName("Document173");
    		setTextureName("document_euclid");
    		setCreativeTab(SCPMod.tabSCPDocuments);
    	}
    
    	public int getItemEnchantability() {
    		return 0;
    	}
    
    	public int getMaxItemUseDuration(ItemStack par1ItemStack) {
    		return 0;
    	}
    
    	public float getStrVsBlock(ItemStack par1ItemStack, Block par2Block) {
    		return 1.0F;
    	}
    
    	public boolean onItemUse(ItemStack itemStack, EntityPlayer entity, World world, int i, int j, int k, int l, float a, float b, float c) {
    		float var4 = 1.0F;
    
    		if (true) {
    			boolean place = true;
    
    			if (place) {
    				world.setBlock(i + 0, j + 0, k + 0, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 1, j + 0, k + 0, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 2, j + 0, k + 0, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 3, j + 0, k + 0, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 4, j + 0, k + 0, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 5, j + 0, k + 0, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 6, j + 0, k + 0, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 0, j + 0, k + 1, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 1, j + 0, k + 1, Block.getBlockById(166), 1, 2);
    				world.setBlock(i + 2, j + 0, k + 1, Block.getBlockById(166), 1, 2);
    				world.setBlock(i + 3, j + 0, k + 1, Block.getBlockById(166), 1, 2);
    				world.setBlock(i + 4, j + 0, k + 1, Block.getBlockById(166), 1, 2);
    				world.setBlock(i + 5, j + 0, k + 1, Block.getBlockById(166), 2, 2);
    				world.setBlock(i + 6, j + 0, k + 1, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 0, j + 0, k + 2, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 1, j + 0, k + 2, Block.getBlockById(166), 0, 2);
    				world.setBlock(i + 2, j + 0, k + 2, Block.getBlockById(166), 1, 2);
    				world.setBlock(i + 3, j + 0, k + 2, Block.getBlockById(166), 2, 2);
    				world.setBlock(i + 4, j + 0, k + 2, Block.getBlockById(166), 1, 2);
    				world.setBlock(i + 5, j + 0, k + 2, Block.getBlockById(166), 2, 2);
    				world.setBlock(i + 6, j + 0, k + 2, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 0, j + 0, k + 3, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 1, j + 0, k + 3, Block.getBlockById(166), 0, 2);
    				world.setBlock(i + 2, j + 0, k + 3, Block.getBlockById(166), 2, 2);
    				world.setBlock(i + 3, j + 0, k + 3, Block.getBlockById(166), 2, 2);
    				world.setBlock(i + 4, j + 0, k + 3, Block.getBlockById(166), 2, 2);
    				world.setBlock(i + 5, j + 0, k + 3, Block.getBlockById(166), 2, 2);
    				world.setBlock(i + 6, j + 0, k + 3, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 0, j + 0, k + 4, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 1, j + 0, k + 4, Block.getBlockById(166), 0, 2);
    				world.setBlock(i + 2, j + 0, k + 4, Block.getBlockById(166), 1, 2);
    				world.setBlock(i + 3, j + 0, k + 4, Block.getBlockById(166), 2, 2);
    				world.setBlock(i + 4, j + 0, k + 4, Block.getBlockById(166), 0, 2);
    				world.setBlock(i + 5, j + 0, k + 4, Block.getBlockById(166), 2, 2);
    				world.setBlock(i + 6, j + 0, k + 4, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 0, j + 0, k + 5, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 1, j + 0, k + 5, Block.getBlockById(166), 1, 2);
    				world.setBlock(i + 2, j + 0, k + 5, Block.getBlockById(166), 3, 2);
    				world.setBlock(i + 3, j + 0, k + 5, Block.getBlockById(166), 3, 2);
    				world.setBlock(i + 4, j + 0, k + 5, Block.getBlockById(166), 3, 2);
    				world.setBlock(i + 5, j + 0, k + 5, Block.getBlockById(166), 3, 2);
    				world.setBlock(i + 6, j + 0, k + 5, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 0, j + 0, k + 6, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 1, j + 0, k + 6, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 2, j + 0, k + 6, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 3, j + 0, k + 6, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 4, j + 0, k + 6, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 5, j + 0, k + 6, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 6, j + 0, k + 6, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 0, j + 1, k + 0, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 1, j + 1, k + 0, Block.getBlockById(165), 0, 2);
    				world.setBlock(i + 2, j + 1, k + 0, Block.getBlockById(165), 3, 2);
    				world.setBlock(i + 3, j + 1, k + 0, Block.getBlockById(165), 3, 2);
    				world.setBlock(i + 4, j + 1, k + 0, Block.getBlockById(165), 3, 2);
    				world.setBlock(i + 5, j + 1, k + 0, Block.getBlockById(165), 3, 2);
    				world.setBlock(i + 6, j + 1, k + 0, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 0, j + 1, k + 1, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 6, j + 1, k + 1, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 0, j + 1, k + 2, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 6, j + 1, k + 2, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 0, j + 1, k + 3, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 6, j + 1, k + 3, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 0, j + 1, k + 4, Block.getBlockById(71), 0, 2);
    				world.setBlock(i + 6, j + 1, k + 4, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 0, j + 1, k + 5, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 6, j + 1, k + 5, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 0, j + 1, k + 6, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 1, j + 1, k + 6, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 2, j + 1, k + 6, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 3, j + 1, k + 6, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 4, j + 1, k + 6, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 5, j + 1, k + 6, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 6, j + 1, k + 6, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 0, j + 2, k + 0, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 1, j + 2, k + 0, Block.getBlockById(165), 0, 2);
    				world.setBlock(i + 2, j + 2, k + 0, Block.getBlockById(165), 3, 2);
    				world.setBlock(i + 3, j + 2, k + 0, Block.getBlockById(165), 3, 2);
    				world.setBlock(i + 4, j + 2, k + 0, Block.getBlockById(165), 3, 2);
    				world.setBlock(i + 5, j + 2, k + 0, Block.getBlockById(165), 3, 2);
    				world.setBlock(i + 6, j + 2, k + 0, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 0, j + 2, k + 1, Block.getBlockById(102), 0, 2);
    				world.setBlock(i + 6, j + 2, k + 1, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 0, j + 2, k + 2, Block.getBlockById(102), 0, 2);
    				world.setBlock(i + 6, j + 2, k + 2, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 0, j + 2, k + 3, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 1, j + 2, k + 3, Block.getBlockById(77), 1, 2);
    				world.setBlock(i + 6, j + 2, k + 3, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 0, j + 2, k + 4, Block.getBlockById(71), 8, 2);
    				world.setBlock(i + 6, j + 2, k + 4, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 0, j + 2, k + 5, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 6, j + 2, k + 5, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 0, j + 2, k + 6, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 1, j + 2, k + 6, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 2, j + 2, k + 6, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 3, j + 2, k + 6, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 4, j + 2, k + 6, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 5, j + 2, k + 6, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 6, j + 2, k + 6, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 0, j + 3, k + 0, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 1, j + 3, k + 0, Block.getBlockById(165), 3, 2);
    				world.setBlock(i + 2, j + 3, k + 0, Block.getBlockById(165), 3, 2);
    				world.setBlock(i + 3, j + 3, k + 0, Block.getBlockById(165), 3, 2);
    				world.setBlock(i + 4, j + 3, k + 0, Block.getBlockById(165), 3, 2);
    				world.setBlock(i + 5, j + 3, k + 0, Block.getBlockById(165), 0, 2);
    				world.setBlock(i + 6, j + 3, k + 0, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 0, j + 3, k + 1, Block.getBlockById(102), 0, 2);
    				world.setBlock(i + 6, j + 3, k + 1, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 0, j + 3, k + 2, Block.getBlockById(102), 0, 2);
    				world.setBlock(i + 6, j + 3, k + 2, Block.getBlockById(102), 0, 2);
    				world.setBlock(i + 0, j + 3, k + 3, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 6, j + 3, k + 3, Block.getBlockById(102), 0, 2);
    				world.setBlock(i + 0, j + 3, k + 4, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 6, j + 3, k + 4, Block.getBlockById(102), 0, 2);
    				world.setBlock(i + 0, j + 3, k + 5, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 6, j + 3, k + 5, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 0, j + 3, k + 6, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 1, j + 3, k + 6, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 2, j + 3, k + 6, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 3, j + 3, k + 6, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 4, j + 3, k + 6, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 5, j + 3, k + 6, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 6, j + 3, k + 6, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 0, j + 4, k + 0, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 1, j + 4, k + 0, Block.getBlockById(165), 2, 2);
    				world.setBlock(i + 2, j + 4, k + 0, Block.getBlockById(165), 2, 2);
    				world.setBlock(i + 3, j + 4, k + 0, Block.getBlockById(165), 2, 2);
    				world.setBlock(i + 4, j + 4, k + 0, Block.getBlockById(165), 2, 2);
    				world.setBlock(i + 5, j + 4, k + 0, Block.getBlockById(165), 2, 2);
    				world.setBlock(i + 6, j + 4, k + 0, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 0, j + 4, k + 1, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 6, j + 4, k + 1, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 0, j + 4, k + 2, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 6, j + 4, k + 2, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 0, j + 4, k + 3, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 6, j + 4, k + 3, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 0, j + 4, k + 4, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 6, j + 4, k + 4, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 0, j + 4, k + 5, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 6, j + 4, k + 5, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 0, j + 4, k + 6, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 1, j + 4, k + 6, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 2, j + 4, k + 6, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 3, j + 4, k + 6, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 4, j + 4, k + 6, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 5, j + 4, k + 6, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 6, j + 4, k + 6, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 0, j + 5, k + 0, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 1, j + 5, k + 0, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 2, j + 5, k + 0, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 3, j + 5, k + 0, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 4, j + 5, k + 0, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 5, j + 5, k + 0, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 6, j + 5, k + 0, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 0, j + 5, k + 1, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 1, j + 5, k + 1, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 2, j + 5, k + 1, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 3, j + 5, k + 1, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 4, j + 5, k + 1, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 5, j + 5, k + 1, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 6, j + 5, k + 1, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 0, j + 5, k + 2, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 1, j + 5, k + 2, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 2, j + 5, k + 2, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 3, j + 5, k + 2, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 4, j + 5, k + 2, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 5, j + 5, k + 2, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 6, j + 5, k + 2, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 0, j + 5, k + 3, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 1, j + 5, k + 3, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 2, j + 5, k + 3, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 3, j + 5, k + 3, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 4, j + 5, k + 3, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 5, j + 5, k + 3, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 6, j + 5, k + 3, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 0, j + 5, k + 4, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 1, j + 5, k + 4, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 2, j + 5, k + 4, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 3, j + 5, k + 4, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 4, j + 5, k + 4, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 5, j + 5, k + 4, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 6, j + 5, k + 4, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 0, j + 5, k + 5, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 1, j + 5, k + 5, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 2, j + 5, k + 5, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 3, j + 5, k + 5, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 4, j + 5, k + 5, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 5, j + 5, k + 5, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 6, j + 5, k + 5, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 0, j + 5, k + 6, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 1, j + 5, k + 6, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 2, j + 5, k + 6, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 3, j + 5, k + 6, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 4, j + 5, k + 6, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 5, j + 5, k + 6, Block.getBlockById(42), 0, 2);
    				world.setBlock(i + 6, j + 5, k + 6, Block.getBlockById(42), 0, 2);
    				Entity sentity0 = EntityList.createEntityByName("SCP173", world);
    				if (sentity0 != null) {
    					sentity0.setLocationAndAngles(i + 4.486269476211419, j + 1.0, k + 1.300000011920929,               world.rand.nextFloat() * 360F, 0);
    					world.spawnEntityInWorld(sentity0);
    				}
    			}
    		}
    
    		if (true) {
    			if (entity instanceof EntityPlayer)
    				((EntityPlayer) entity).inventory.consumeInventoryItem(SCPItem.Document173);
    		}
    
    		return true;
    	}
    
    	public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List list, boolean par4) {
    		 list.add("§eSCP-173");
    		 list.add("§7The Sculpture");
    	}
    
    
    
    }
    

    j'éspere que quel'qun vas trouvée une solution merci d'avance 🙂



  • Dans ta méthode

    public boolean onItemUse(ItemStack itemStack, EntityPlayer entity, World world, int i, int j, int k, int l, float a, float b, float c) {}
    

    Avant if(true), ajoute un petit if(!world.isRemote)



  • @ama a dit dans un probléme avec un item qui fait spawn une entity. :

    if(!world.isRemote)

    Wow sa marche!!! merci!!!


Log in to reply