Besoin d'aide pour ma Voiture..
-
Bonjour,
il y a quelque jours je suis parti dans l’idée de créer une voiture dans Minecraft…
c’était une bonne idée mais voila le problème c’est que ma voiture existe bien dans le jeux avec sont Entity, Render, Model, ect…
mais je ne peut pas Monter dedans…. de base ma voiture doit se charger en fuel(coal) en fessant Shift + click droit avec le coal dans la main, je devrait aussi pouvoir ouvrir un inventaire avec shift + click et bien entendu monter dedans en fessant click droit mais rien n’a faire…
s’il vous plait aider moi cela ma pris beaucoup de temps…//ITEMCARS\
public class ItemCars extends Item { public int colour; public ItemCars(int colour) { setUnlocalizedName((new StringBuilder()).append("Voiture").toString()); this.colour = colour; setMaxStackSize(1); setCreativeTab(ModFuZzionSurvie.FuZzionTabs); } public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int par7, float par8, float par9, float par10) { if(!player.capabilities.isCreativeMode) { stack.stackSize--; } if(!world.isRemote) { EntityCars entityCars = new EntityCars(world, x, y + 1, z, colour, player.getCommandSenderName()); entityCars.rotationYaw = ((MathHelper.floor_double((double)((player.rotationYaw * 4F) / 360F) + 0.5D) & 3) - 1) * 90 - 90; world.spawnEntityInWorld(entityCars); } if(player.capabilities.isCreativeMode) { stack.stackSize--; } return true; } }
//ENTITYCARS\
package fr.mod.FuZzionSurvie.common; import io.netty.buffer.ByteBuf; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.inventory.IInventory; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.ChatComponentText; import net.minecraft.util.DamageSource; import net.minecraft.util.MathHelper; import net.minecraft.world.World; import org.lwjgl.input.Keyboard; import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData; public class EntityCars extends Entity implements IEntityAdditionalSpawnData, IInventory { public double speed; public double accelaration; public double maxSpeed; public int carColour; public String owner; public int fuel; public double fuelTime; private ItemStack invItems[]; public EntityCars(World world) { super(world); fuel = 0; fuelTime = 0.0D; invItems = new ItemStack[36]; preventEntitySpawning = true; setSize(1.5F, 0.8F); yOffset = height / 2.0F; stepHeight = 1.1F; accelaration = 0.10000000000000001D; maxSpeed = 0.5D; } protected boolean canTriggerWalking() { return false; } protected void entityInit() { dataWatcher.addObject(17, new Integer(0)); dataWatcher.addObject(18, new Integer(1)); dataWatcher.addObject(19, new Float(0.0F)); dataWatcher.addObject(20, new Float(speed)); dataWatcher.addObject(21, new Float(rotationYaw)); dataWatcher.addObject(22, new Float(motionX)); dataWatcher.addObject(23, new Float(motionY)); dataWatcher.addObject(24, new Float(motionZ)); dataWatcher.addObject(25, new Integer(fuel)); dataWatcher.addObject(26, new Float(speed)); } public AxisAlignedBB getCollisionBox(Entity entity) { return entity.boundingBox; } public AxisAlignedBB getBoundingBox() { return boundingBox; } public boolean canBePushed() { return false; } public EntityCars(World world, int x, int y, int z, int colour, String owner) { this(world); setPosition(x, (double)y + (double)yOffset, z); motionX = 0.0D; motionY = 0.0D; motionZ = 0.0D; prevPosX = x; prevPosY = y; prevPosZ = z; carColour = colour; this.owner = owner; } public double getMountedOffset() { return (double)height * 0.0D - 0.0010000119209289599D; } public boolean attackEntityFrom(DamageSource damageSource, float damage) { if(isEntityInvulnerable()) { return false; } if(!worldObj.isRemote && !isDead) { setForwardDirection(-getForwardDirection()); setTimeSinceHit(10); setDamageTaken(getDamageTaken() + damage * 6F); setBeenAttacked(); boolean isCreativeMode = (damageSource.getEntity() instanceof EntityPlayer) && ((EntityPlayer)damageSource.getEntity()).capabilities.isCreativeMode; if(!isCreativeMode && (damageSource.getEntity() instanceof EntityPlayer)) { EntityPlayer player = (EntityPlayer)damageSource.getEntity(); if(!player.getCommandSenderName().equalsIgnoreCase(owner)) { player.addChatMessage(new ChatComponentText((new StringBuilder()).append("Your name isn't ").append(owner).append("!").toString())); return false; } } if(isCreativeMode || getDamageTaken() > 40F) { if(riddenByEntity != null) { riddenByEntity.mountEntity(this); } if(!isCreativeMode) { func_145778_a(ModFuZzionSurvie.getCarDrop(carColour), 1, 0.0F); for(int i = 0; i < fuel; i++) { ItemStack itemstack = new ItemStack(Items.coal); float f = rand.nextFloat() * 0.8F + 0.1F; float f1 = rand.nextFloat() * 0.8F + 0.1F; float f2 = rand.nextFloat() * 0.8F + 0.1F; while(itemstack.stackSize > 0) { int j = rand.nextInt(21) + 10; if(j > itemstack.stackSize) { j = itemstack.stackSize; } itemstack.stackSize -= j; EntityItem entityitem = new EntityItem(worldObj, posX + (double)f, posY + (double)f1, posZ + (double)f2, new ItemStack(itemstack.getItem(), j, itemstack.getItemDamage())); float f3 = 0.05F; entityitem.motionX = (float)rand.nextGaussian() * f3; entityitem.motionY = (float)rand.nextGaussian() * f3 + 0.2F; entityitem.motionZ = (float)rand.nextGaussian() * f3; worldObj.spawnEntityInWorld(entityitem); } } label0: for(int i = 0; i < getSizeInventory(); i++) { ItemStack itemstack = getStackInSlot(i); if(itemstack == null) { continue; } float f = rand.nextFloat() * 0.8F + 0.1F; float f1 = rand.nextFloat() * 0.8F + 0.1F; float f2 = rand.nextFloat() * 0.8F + 0.1F; do { if(itemstack.stackSize <= 0) { continue label0; } int j = rand.nextInt(21) + 10; if(j > itemstack.stackSize) { j = itemstack.stackSize; } itemstack.stackSize -= j; EntityItem entityitem = new EntityItem(worldObj, posX + (double)f, posY + (double)f1, posZ + (double)f2, new ItemStack(itemstack.getItem(), j, itemstack.getItemDamage())); float f3 = 0.05F; entityitem.motionX = (float)rand.nextGaussian() * f3; entityitem.motionY = (float)rand.nextGaussian() * f3 + 0.2F; entityitem.motionZ = (float)rand.nextGaussian() * f3; worldObj.spawnEntityInWorld(entityitem); } while(true); } } setDead(); } return true; } else { return true; } } public void performHurtAnimation() { setForwardDirection(-getForwardDirection()); setTimeSinceHit(10); setDamageTaken(getDamageTaken() * 11F); } public boolean canBeCollideWith() { return !isDead; } public void setPositionAndRotation(double x, double y, double z, float yaw, float pitch, int par9) { setPositionAndRotation(x, y + 0.025999999999999999D, z, yaw, pitch); } public void onUpdate() { super.onUpdate(); if(getTimeSinceHit() > 0) { setTimeSinceHit(getTimeSinceHit() - 1); } if(getDamageTaken() > 0.0F) { setDamageTaken(getDamageTaken() - 1.0F); } prevPosX = posX; prevPosY = posY; prevPosZ = posZ; if(worldObj.isRemote) { speed = dataWatcher.getWatchableObjectFloat(20); rotationYaw = dataWatcher.getWatchableObjectFloat(21); motionX = dataWatcher.getWatchableObjectFloat(22); motionY = dataWatcher.getWatchableObjectFloat(23); motionZ = dataWatcher.getWatchableObjectFloat(24); fuel = dataWatcher.getWatchableObjectInt(25); speed = dataWatcher.getWatchableObjectFloat(26); } double cos = Math.cos(((double)rotationYaw * 3.1415926535897931D) / 180D); double sin = Math.sin(((double)rotationYaw * 3.1415926535897931D) / 180D); motionX = -sin * speed; motionZ = cos * speed; motionY = -0.54312320000000003D; if(riddenByEntity != null) { if(riddenByEntity instanceof EntityLivingBase) { EntityLivingBase entity = (EntityLivingBase)riddenByEntity; if(worldObj.isRemote && Keyboard.isKeyDown(57)) { FuZzionSoundHandler.hoot(this, 20F, 1.0F); } if(!isInWater() && speed > 0.10000000000000001D && fuel > 0) { if(carColour == 10) { for(int i = 0; i < 20; i++) { worldObj.spawnParticle("reddust", posX + (rand.nextDouble() - 0.5D) * (double)width, (posY + rand.nextDouble() * (double)height) - 0.25D, posZ + (rand.nextDouble() - 0.5D) * (double)width, 0.0D + rand.nextDouble(), 25D + rand.nextDouble(), 45D + rand.nextDouble()); worldObj.spawnParticle("reddust", posX + (rand.nextDouble() - 0.5D) * (double)width, (posY + rand.nextDouble() * (double)height) - 0.25D, posZ + (rand.nextDouble() - 0.5D) * (double)width, 0.0D + rand.nextDouble(), 25D + rand.nextDouble(), 0.0D + rand.nextDouble()); worldObj.spawnParticle("reddust", posX + (rand.nextDouble() - 0.5D) * (double)width, (posY + rand.nextDouble() * (double)height) - 0.25D, posZ + (rand.nextDouble() - 0.5D) * (double)width, 0.0D + rand.nextDouble(), 0.0D + rand.nextDouble(), 25D + rand.nextDouble()); worldObj.spawnParticle("reddust", posX + (rand.nextDouble() - 0.5D) * (double)width, (posY + rand.nextDouble() * (double)height) - 0.25D, posZ + (rand.nextDouble() - 0.5D) * (double)width, 25D + rand.nextDouble(), 0.0D + rand.nextDouble(), 0.0D + rand.nextDouble()); worldObj.spawnParticle("reddust", posX + (rand.nextDouble() - 0.5D) * (double)width, (posY + rand.nextDouble() * (double)height) - 0.25D, posZ + (rand.nextDouble() - 0.5D) * (double)width, 25D + rand.nextDouble(), 0.0D + rand.nextDouble(), 0.0D + rand.nextDouble()); worldObj.spawnParticle("reddust", posX + (rand.nextDouble() - 0.5D) * (double)width, (posY + rand.nextDouble() * (double)height) - 0.25D, posZ + (rand.nextDouble() - 0.5D) * (double)width, 25D + rand.nextDouble(), 25D + rand.nextDouble(), 0.0D + rand.nextDouble()); } } else { for(int i = 0; i < 10; i++) { worldObj.spawnParticle("smoke", posX + (rand.nextDouble() - 0.5D) * (double)width, (posY + rand.nextDouble() * (double)height) - 0.25D, posZ + (rand.nextDouble() - 0.5D) * (double)width, 0.0D, 0.0D, 0.0D); } } } if(fuel > 0) { if(!isInWater()) { speed += (double)entity.moveForward * accelaration; if(speed > maxSpeed) { speed = maxSpeed; } if(speed < -maxSpeed) { speed = -maxSpeed; } if(speed > 0.0D) { if(fuelTime <= 0.0D) { fuel–; fuelTime = 5000D; } else { fuelTime -= speed * 50D; } } } else { speed *= 0.84999999999999998D; } } else if(speed > 0.0D) { speed *= 0.84999999999999998D; } if(entity.moveForward <= 0.0F) { speed *= 0.84999999999999998D; } rotationYaw = MathHelper.wrapAngleTo180_float(entity.getRotationYawHead()); } } else { speed *= 0.84999999999999998D; } setRotation(rotationYaw, rotationPitch); moveEntity(motionX, motionY, motionZ); if(!worldObj.isRemote) { dataWatcher.updateObject(20, new Float(speed)); dataWatcher.updateObject(21, new Float(rotationYaw)); dataWatcher.updateObject(22, new Float(motionX)); dataWatcher.updateObject(23, new Float(motionY)); dataWatcher.updateObject(24, new Float(motionZ)); dataWatcher.updateObject(25, new Integer(fuel)); dataWatcher.updateObject(26, new Float(speed)); } } public void updateRiderPosition() { if(riddenByEntity != null) { double dZ = Math.cos(((double)rotationYaw * 3.1415926535897931D) / 180D) * -0.10000000000000001D; double dX = -Math.sin(((double)rotationYaw * 3.1415926535897931D) / 180D) * -0.10000000000000001D; riddenByEntity.setPosition(posX + dX, posY + getMountedOffset() + riddenByEntity.getYOffset(), posZ + dZ); } } protected void writeEntityToNBT(NBTTagCompound nbt) { nbt.setInteger("colour", carColour); nbt.setString("owner", owner); nbt.setInteger("fuel", fuel); nbt.setDouble("fuelTime", fuelTime); NBTTagList nbttaglist = new NBTTagList(); for(int i = 0; i < invItems.length; i++) { if(invItems* != null) { NBTTagCompound slotTag = new NBTTagCompound(); slotTag.setByte("Slot", (byte)i); invItems*.writeToNBT(slotTag); nbttaglist.appendTag(slotTag); } } nbt.setTag("Items", nbttaglist); } protected void readEntityFromNBT(NBTTagCompound nbt) { carColour = nbt.getInteger("colour"); owner = nbt.getString("owner"); fuel = nbt.getInteger("fuel"); fuelTime = nbt.getDouble("fuelTime"); NBTTagList nbttaglist = nbt.getTagList("Items", 10); invItems = new ItemStack[getSizeInventory()]; for(int i = 0; i < nbttaglist.tagCount(); i++) { NBTTagCompound slotTag = nbttaglist.getCompoundTagAt(i); int j = slotTag.getByte("Slot") & 0xff; if(j >= 0 && j < invItems.length) { invItems[j] = ItemStack.loadItemStackFromNBT(slotTag); } } } public float getShadowSize() { return 0.0F; } public boolean interactFirst(EntityPlayer player) { if(riddenByEntity != null && (riddenByEntity instanceof EntityPlayer) && riddenByEntity != player) { return true; } if(player.getCommandSenderName().equalsIgnoreCase(owner)) { if(player.isSneaking()) { if(player.getHeldItem() != null && (player.getHeldItem().getItem() == Items.coal || player.getHeldItem().getItem() == Item.getItemFromBlock(Blocks.coal_block))) { if(player.getHeldItem().getItem() == Items.coal) { fuel += player.getHeldItem().stackSize; player.getHeldItem().stackSize = 0; player.addChatMessage(new ChatComponentText((new StringBuilder()).append("Car Fuel: ").append(fuel).toString())); } else if(player.getHeldItem().getItem() == Item.getItemFromBlock(Blocks.coal_block)) { fuel += player.getHeldItem().stackSize * 9; player.getHeldItem().stackSize = 0; player.addChatMessage(new ChatComponentText((new StringBuilder()).append("Car Fuel: ").append(fuel).toString())); } } else { player.displayGUIChest(this); } } else if(!worldObj.isRemote) { player.mountEntity(this); } } else if(!worldObj.isRemote) { player.addChatMessage(new ChatComponentText("You are not the owner of this car!")); } return true; } protected void updateFallState(double distanceFallenThisTick, boolean onGround) { fallDistance = 0.0F; } public void setDamageTaken(float damage) { dataWatcher.updateObject(19, Float.valueOf(damage)); } public float getDamageTaken() { return dataWatcher.getWatchableObjectFloat(19); } public void setTimeSinceHit(int time) { dataWatcher.updateObject(17, Integer.valueOf(time)); } public int getTimeSinceHit() { return dataWatcher.getWatchableObjectInt(17); } public void setForwardDirection(int direction) { dataWatcher.updateObject(18, Integer.valueOf(direction)); } public int getForwardDirection() { return dataWatcher.getWatchableObjectInt(18); } public void readSpawnData(ByteBuf buf) { carColour = buf.readByte(); } public void writeSpawnData(ByteBuf buf) { buf.writeByte(carColour); } public ItemStack getStackInSlot(int slot) { return invItems[slot]; } public ItemStack decrStackSize(int slot, int amount) { if(invItems[slot] != null) { ItemStack itemstack; if(invItems[slot].stackSize <= amount) { itemstack = invItems[slot]; invItems[slot] = null; return itemstack; } itemstack = invItems[slot].splitStack(amount); if(invItems[slot].stackSize == 0) { invItems[slot] = null; } return itemstack; } else { return null; } } public ItemStack getStackInSlotOnClosing(int slot) { if(invItems[slot] != null) { ItemStack itemstack = invItems[slot]; invItems[slot] = null; return itemstack; } else { return null; } } public void setInventorySlotContents(int slot, ItemStack stack) { invItems[slot] = stack; if(stack != null && stack.stackSize > getInventoryStackLimit()) { stack.stackSize = getInventoryStackLimit(); } } public void markDirty() { } public boolean isUseableByPlayer(EntityPlayer player) { return isDead ? false : player.getDistanceSqToEntity(this) <= 64D; } public void openInventory() { } public void closeInventory() { } public boolean isItemValidForSlot(int slot, ItemStack stack) { return true; } public String getInventoryName() { return "Cars"; } public int getInventoryStackLimit() { return 64; } public int getSizeInventory() { return invItems.length; } public boolean hasCustomInventoryName() { return true; } }
//RENDERCARS\
package fr.mod.FuZzionSurvie.client; import net.minecraft.client.model.ModelBase; import net.minecraft.client.renderer.entity.Render; import net.minecraft.entity.Entity; import net.minecraft.util.MathHelper; import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; import fr.mod.FuZzionSurvie.common.EntityCars; public class RenderCars extends Render { public ModelBase model; public RenderCars() { model = new ModelVoiture(); } public void doRenderCars(EntityCars car, double x, double y, double z, float rotationYaw, float par1) { if(!car.isDead) { GL11.glPushMatrix(); GL11.glTranslatef((float)x, (float)y + 1.1F, (float)z); GL11.glRotatef(180F - rotationYaw, 0.0F, 1.0F, 0.0F); float timeSinceHit = (float)car.getTimeSinceHit() - par1; float damageTaken = car.getDamageTaken() - par1; if(damageTaken < 0.0F) { damageTaken = 0.0F; } if(timeSinceHit > 0.0F) { GL11.glRotatef(((MathHelper.sin(timeSinceHit) * timeSinceHit * damageTaken) / 10F) * (float)car.getForwardDirection(), 0.0F, 0.0F, 1.0F); } float f4 = 0.75F; GL11.glScalef(f4, f4, f4); GL11.glScalef(1.0F / f4, 1.0F / f4, 1.0F / f4); bindEntityTexture(car); GL11.glScalef(-1F, -1F, 1.0F); model.render(car, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); GL11.glPopMatrix(); } } public void doRender(Entity entity, double x, double y, double z, float rotationYaw, float par1) { doRenderCars((EntityCars)entity, x, y, z, rotationYaw, par1); } protected ResourceLocation getEntityTexture(Entity entity) { return getCarTexture((EntityCars)entity); } public ResourceLocation getCarTexture(EntityCars car) { return new ResourceLocation("modfuzzionsurvie", "textures/entity/Voiture.png"); } }
//CLIENTPROXY\
package fr.mod.FuZzionSurvie.proxy; import net.minecraft.client.model.ModelBiped; import net.minecraft.client.renderer.entity.RenderSnowball; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.MinecraftForgeClient; import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.client.registry.ClientRegistry; import cpw.mods.fml.client.registry.RenderingRegistry; import fr.mod.FuZzionSurvie.client.ItemRendererCars; import fr.mod.FuZzionSurvie.client.ModelVoiture; import fr.mod.FuZzionSurvie.client.RenderCars; import fr.mod.FuZzionSurvie.client.RenderFuZzionNudiste; import fr.mod.FuZzionSurvie.client.RenderMunition; import fr.mod.FuZzionSurvie.common.EntityCars; import fr.mod.FuZzionSurvie.common.EntityFuZzionNudiste; import fr.mod.FuZzionSurvie.common.EntityGrenade; import fr.mod.FuZzionSurvie.common.EntityMunition; import fr.mod.FuZzionSurvie.common.ModFuZzionSurvie; import fr.mod.FuZzionSurvie.common.TileEntityChaise; import fr.mod.FuZzionSurvie.common.TileEntityTable; import fr.mod.FuZzionSurvie.common.TileEntityXray; public class ClientProxy extends CommonProxy { public static int tesrRenderId; @Override public void registerRender() { tesrRenderId = RenderingRegistry.getNextAvailableRenderId(); RenderingRegistry.registerBlockHandler(new TESRInventoryRenderer()); //Entity RenderingRegistry.registerEntityRenderingHandler(EntityFuZzionNudiste.class, new RenderFuZzionNudiste(new ModelBiped(), 0.5F)); RenderingRegistry.registerEntityRenderingHandler(EntityGrenade.class, new RenderSnowball(ModFuZzionSurvie.Grenade)); RenderingRegistry.registerEntityRenderingHandler(EntityMunition.class, new RenderMunition()); RenderingRegistry.registerEntityRenderingHandler(EntityCars.class, new RenderCars()); //Block Custom ClientRegistry.bindTileEntitySpecialRenderer(TileEntityTable.class, new TileEntityTableSpecialRenderer()); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityChaise.class, new TileEntityChaiseSpecialRenderer()); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityXray.class, new TileEntityXraySpecialRenderer()); } }
-
Salut,
La prochaine fois pense à mettre les balises Java, sinon le code est juste illisible … J’ai modifié ton message.Pour commencer :
player.displayGUIChest(this);
Ceci ne fonctionnera jamais, tu essaye d’afficher le gui d’un coffre, or pour ça il faut le container du coffre qui va avec et le tile entity.
Si tu veux ouvrir un gui il faut faire un gui custom et passer par player.openGuiEnsuite tu as tout mit dans interactFirst. Il existe aussi une autre fonction nommé interact, il aurait peut-être plutôt utiliser celle-ci.
Pour trouver d’où vient le problème il faudrait aussi mettre du debug dans cette fonction, par exemple quelque System.out.println(“quelque chose”); serait pratique pour voir si la fonction est bien exécuté.
Tu peux aussi mettre des trucs du genre System.out.println("owner : " + owner); pour voir si l’owner est null ou pas et avoir son nom, etc … -
Salut robin,
ne mis connaissant pas trop je sens que cela va être compliqué de plus
la Console ne m’affiche rien j’ai mis "System.out.println(“owner : " + owner)”
dans la fonction en la renommant interact mais j’ai l’impression que la console ne reconnait pas L’entity de la Voiture :/* -
@‘fuzziongaming’:
dans la fonction en la renommant interact mais j’ai l’impression que la console ne reconnait pas L’entity de la Voiture :/*
Cette phrase n’a aucun sens x)
La console ne fait que afficher tout ce qu’on lui demande, ce n’est pas possible qu’elle ne reconnaisse pas l’entité de la voiture, ça serait plutôt le jeu qui ne la reconnait pas.Si tu as ajoute @Override au dessus de la fonction interact, eclipse indique une erreur ou ça passe ?
-
il m’indique une erreur au niveau de la fonction interact et ma demande de remove @Override
-
Dans ce cas ça veut dire que la fonction interact n’existe pas dans Entity.java, la fonction a peut être un autre nom, je vais regarder ça.
Autant pour moi, je viens de regarder interact n’existe que dans EntityLiving, c’était bien interactFirst qui fallait mettre.
Remet donc interactFirst et mets les System.out.println comme je t’ai dit. -
Non, il ne se passe toujours rien au niveau de la console…
@Override public boolean interactFirst(EntityPlayer player) { if(riddenByEntity != null && (riddenByEntity instanceof EntityPlayer) && riddenByEntity != player) { return true; } if(player.getCommandSenderName().equalsIgnoreCase(owner)) { if(player.isSneaking()) { System.out.println("owner:"+ owner); if(player.getHeldItem() != null && (player.getHeldItem().getItem() == Items.coal || player.getHeldItem().getItem() == Item.getItemFromBlock(Blocks.coal_block))) { if(player.getHeldItem().getItem() == Items.coal) { fuel += player.getHeldItem().stackSize; player.getHeldItem().stackSize = 0; player.addChatMessage(new ChatComponentText((new StringBuilder()).append("Car Fuel: ").append(fuel).toString())); } else if(player.getHeldItem().getItem() == Item.getItemFromBlock(Blocks.coal_block)) { fuel += player.getHeldItem().stackSize * 9; player.getHeldItem().stackSize = 0; player.addChatMessage(new ChatComponentText((new StringBuilder()).append("Car Fuel: ").append(fuel).toString())); } } else { player.displayGUIChest(this); } } else if(!worldObj.isRemote) { player.mountEntity(this); } } else if(!worldObj.isRemote) { player.addChatMessage(new ChatComponentText("You are not the owner of this car!")); } return true; }
-
C’est pas juste avec un System.out.println que tu vas trouve d’où vient le problème.
Il faut regarder condition par condition pour bien comprendre ce qui se passe.
Fait comme ça :@Override public boolean interactFirst(EntityPlayer player) { if(riddenByEntity != null && (riddenByEntity instanceof EntityPlayer) && riddenByEntity != player) { System.out.println("il y a déjà un autre joueur sur le car"); return true; } System.out.println("Nom du joueur qui a fait le clic droit : " + player.getCommandSenderName()); System.out.println("owner:" + owner); if(player.getCommandSenderName().equalsIgnoreCase(owner)) { if(player.isSneaking()) { System.out.println("le joueur sneak"); if(player.getHeldItem() != null && (player.getHeldItem().getItem() == Items.coal || player.getHeldItem().getItem() == Item.getItemFromBlock(Blocks.coal_block))) { if(player.getHeldItem().getItem() == Items.coal) { fuel += player.getHeldItem().stackSize; player.getHeldItem().stackSize = 0; player.addChatMessage(new ChatComponentText((new StringBuilder()).append("Car Fuel: ").append(fuel).toString())); } else if(player.getHeldItem().getItem() == Item.getItemFromBlock(Blocks.coal_block)) { fuel += player.getHeldItem().stackSize * 9; player.getHeldItem().stackSize = 0; player.addChatMessage(new ChatComponentText((new StringBuilder()).append("Car Fuel: ").append(fuel).toString())); } } else { player.displayGUIChest(this); } } else if(!worldObj.isRemote) { System.out.println("Le joueur monte sur le car"); player.mountEntity(this); } } else if(!worldObj.isRemote) { player.addChatMessage(new ChatComponentText("You are not the owner of this car!")); } return true; }
Tu devais déjà y voir plus claire (et moi aussi).
-
La console ne m’affiche rien… ```
[20:48:46] [main/INFO] [GradleStart]: Extra: []
[20:48:46] [main/INFO] [GradleStart]: Running with arguments: [–userProperties, {}, --assetsDir, C:/Users/MaXxi/.gradle/caches/minecraft/assets, --assetIndex, 1.7.10, --accessToken, {REDACTED}, --version, 1.7.10, --tweakClass, cpw.mods.fml.common.launcher.FMLTweaker, --tweakClass, net.minecraftforge.gradle.GradleStartCommon$GradleStartTweaker]
[20:48:46] [main/INFO] [LaunchWrapper]: Loading tweak class name cpw.mods.fml.common.launcher.FMLTweaker
[20:48:46] [main/INFO] [LaunchWrapper]: Using primary tweak class name cpw.mods.fml.common.launcher.FMLTweaker
[20:48:46] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.gradle.GradleStartCommon$GradleStartTweaker
[20:48:46] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.common.launcher.FMLTweaker
[20:48:46] [main/INFO] [FML]: Forge Mod Loader version 7.10.85.1235 for Minecraft 1.7.10 loading
[20:48:46] [main/INFO] [FML]: Java is Java HotSpot 64-Bit Server VM, version 1.8.0_20, running on Windows 8.1:amd64:6.3, installed at C:\Program Files\Java\jre1.8.0_20
[20:48:46] [main/INFO] [FML]: Managed to load a deobfuscated Minecraft name- we are in a deobfuscated environment. Skipping runtime deobfuscation
[20:48:47] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.gradle.GradleStartCommon$GradleStartTweaker
[20:48:47] [main/INFO] [GradleStart]: Injecting location in coremod cpw.mods.fml.relauncher.FMLCorePlugin
[20:48:47] [main/INFO] [GradleStart]: Injecting location in coremod net.minecraftforge.classloading.FMLForgePlugin
[20:48:47] [main/INFO] [LaunchWrapper]: Loading tweak class name cpw.mods.fml.common.launcher.FMLInjectionAndSortingTweaker
[20:48:47] [main/INFO] [LaunchWrapper]: Loading tweak class name cpw.mods.fml.common.launcher.FMLDeobfTweaker
[20:48:47] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.common.launcher.FMLInjectionAndSortingTweaker
[20:48:47] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.common.launcher.FMLInjectionAndSortingTweaker
[20:48:47] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.relauncher.CoreModManager$FMLPluginWrapper
[20:48:48] [main/ERROR] [FML]: The binary patch set is missing. Either you are in a development environment, or things are not going to work!
[20:49:05] [main/ERROR] [FML]: FML appears to be missing any signature data. This is not a good thing
[20:49:05] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.relauncher.CoreModManager$FMLPluginWrapper
[20:49:05] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.common.launcher.FMLDeobfTweaker
[20:49:07] [main/INFO] [LaunchWrapper]: Loading tweak class name cpw.mods.fml.common.launcher.TerminalTweaker
[20:49:07] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.common.launcher.TerminalTweaker
[20:49:07] [main/INFO] [LaunchWrapper]: Launching wrapped minecraft {net.minecraft.client.main.Main}
[20:49:10] [main/INFO]: Setting user: Player15
[20:49:19] [Client thread/INFO]: LWJGL Version: 2.9.1
[20:49:22] [Client thread/INFO] [MinecraftForge]: Attempting early MinecraftForge initialization
[20:49:22] [Client thread/INFO] [FML]: MinecraftForge v10.13.2.1235 Initialized
[20:49:22] [Client thread/INFO] [FML]: Replaced 182 ore recipies
[20:49:23] [Client thread/INFO] [MinecraftForge]: Completed early MinecraftForge initialization
[20:49:24] [Client thread/INFO] [FML]: Searching C:\Users\MaXxi\Documents\Mes Documents\document\MAXIME\MES MODS\FuZzion survie\Forge Modding 1.7.10\eclipse\mods for mods
[20:49:32] [Client thread/INFO] [FML]: Forge Mod Loader has identified 4 mods to load
[20:49:34] [Client thread/INFO] [FML]: Attempting connection with missing mods [mcp, FML, Forge, modfuzzionsurvie] at CLIENT
[20:49:34] [Client thread/INFO] [FML]: Attempting connection with missing mods [mcp, FML, Forge, modfuzzionsurvie] at SERVER
[20:49:35] [Client thread/INFO]: Reloading ResourceManager: Default, FMLFileResourcePack:Forge Mod Loader, FMLFileResourcePack:Minecraft Forge, FMLFileResourcePack:FuZzion Survie
[20:49:36] [Client thread/INFO] [FML]: Processing ObjectHolder annotations
[20:49:36] [Client thread/INFO] [FML]: Found 341 ObjectHolder annotations
[20:49:36] [Client thread/INFO] [FML]: Configured a dormant chunk cache size of 0
[20:49:36] [Client thread/INFO] [FML]: Applying holder lookups
[20:49:36] [Client thread/INFO] [FML]: Holder lookups applied
[20:49:37] [Sound Library Loader/INFO] [STDOUT]: [paulscode.sound.SoundSystemLogger:message:69]:
[20:49:37] [Sound Library Loader/INFO] [STDOUT]: [paulscode.sound.SoundSystemLogger:message:69]: Starting up SoundSystem…
[20:49:37] [Thread-6/INFO] [STDOUT]: [paulscode.sound.SoundSystemLogger:message:69]: Initializing LWJGL OpenAL
[20:49:37] [Thread-6/INFO] [STDOUT]: [paulscode.sound.SoundSystemLogger:message:69]: (The LWJGL binding of OpenAL. For more information, see http://www.lwjgl.org)
[20:49:37] [Thread-6/INFO] [STDOUT]: [paulscode.sound.SoundSystemLogger:message:69]: OpenAL initialized.
[20:49:37] [Sound Library Loader/INFO] [STDOUT]: [paulscode.sound.SoundSystemLogger:message:69]:
[20:49:37] [Sound Library Loader/INFO]: Sound engine started
[20:49:53] [Client thread/INFO]: Created: 512x512 textures/blocks-atlas
[20:49:54] [Client thread/ERROR]: Using missing texture, unable to load minecraft:textures/items/MISSING_ICON_ITEM_4096_Voiture.png
java.io.FileNotFoundException: minecraft:textures/items/MISSING_ICON_ITEM_4096_Voiture.png
at net.minecraft.client.resources.FallbackResourceManager.getResource(FallbackResourceManager.java:65) ~[FallbackResourceManager.class:?]
at net.minecraft.client.resources.SimpleReloadableResourceManager.getResource(SimpleReloadableResourceManager.java:67) ~[SimpleReloadableResourceManager.class:?]
at net.minecraft.client.renderer.texture.TextureMap.loadTextureAtlas(TextureMap.java:126) [TextureMap.class:?]
at net.minecraft.client.renderer.texture.TextureMap.loadTexture(TextureMap.java:91) [TextureMap.class:?]
at net.minecraft.client.renderer.texture.TextureManager.loadTexture(TextureManager.java:89) [TextureManager.class:?]
at net.minecraft.client.renderer.texture.TextureManager.loadTickableTexture(TextureManager.java:71) [TextureManager.class:?]
at net.minecraft.client.renderer.texture.TextureManager.loadTextureMap(TextureManager.java:58) [TextureManager.class:?]
at net.minecraft.client.Minecraft.startGame(Minecraft.java:583) [Minecraft.class:?]
at net.minecraft.client.Minecraft.run(Minecraft.java:931) [Minecraft.class:?]
at net.minecraft.client.main.Main.main(Main.java:164) [Main.class:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_20]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_20]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_20]
at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_20]
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.11.jar:?]
at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.11.jar:?]
at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:78) [start/:?]
at GradleStart.main(GradleStart.java:45) [start/:?]
[20:49:54] [Client thread/INFO]: Created: 256x256 textures/items-atlas
[20:49:55] [Client thread/INFO] [FML]: Forge Mod Loader has successfully loaded 4 mods
[20:49:55] [Client thread/INFO]: Reloading ResourceManager: Default, FMLFileResourcePack:Forge Mod Loader, FMLFileResourcePack:Minecraft Forge, FMLFileResourcePack:FuZzion Survie
[20:49:56] [Client thread/INFO]: Created: 512x512 textures/blocks-atlas
[20:49:57] [Client thread/ERROR]: Using missing texture, unable to load minecraft:textures/items/MISSING_ICON_ITEM_4096_Voiture.png
java.io.FileNotFoundException: minecraft:textures/items/MISSING_ICON_ITEM_4096_Voiture.png
at net.minecraft.client.resources.FallbackResourceManager.getResource(FallbackResourceManager.java:65) ~[FallbackResourceManager.class:?]
at net.minecraft.client.resources.SimpleReloadableResourceManager.getResource(SimpleReloadableResourceManager.java:67) ~[SimpleReloadableResourceManager.class:?]
at net.minecraft.client.renderer.texture.TextureMap.loadTextureAtlas(TextureMap.java:126) [TextureMap.class:?]
at net.minecraft.client.renderer.texture.TextureMap.loadTexture(TextureMap.java:91) [TextureMap.class:?]
at net.minecraft.client.renderer.texture.TextureManager.loadTexture(TextureManager.java:89) [TextureManager.class:?]
at net.minecraft.client.renderer.texture.TextureManager.onResourceManagerReload(TextureManager.java:170) [TextureManager.class:?]
at net.minecraft.client.resources.SimpleReloadableResourceManager.notifyReloadListeners(SimpleReloadableResourceManager.java:134) [SimpleReloadableResourceManager.class:?]
at net.minecraft.client.resources.SimpleReloadableResourceManager.reloadResources(SimpleReloadableResourceManager.java:118) [SimpleReloadableResourceManager.class:?]
at net.minecraft.client.Minecraft.refreshResources(Minecraft.java:643) [Minecraft.class:?]
at cpw.mods.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:303) [FMLClientHandler.class:?]
at net.minecraft.client.Minecraft.startGame(Minecraft.java:586) [Minecraft.class:?]
at net.minecraft.client.Minecraft.run(Minecraft.java:931) [Minecraft.class:?]
at net.minecraft.client.main.Main.main(Main.java:164) [Main.class:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_20]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_20]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_20]
at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_20]
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.11.jar:?]
at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.11.jar:?]
at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:78) [start/:?]
at GradleStart.main(GradleStart.java:45) [start/:?]
[20:49:57] [Client thread/INFO]: Created: 256x256 textures/items-atlas
[20:49:57] [Client thread/INFO] [STDOUT]: [paulscode.sound.SoundSystemLogger:message:69]:
[20:49:57] [Client thread/INFO] [STDOUT]: [paulscode.sound.SoundSystemLogger:message:69]: SoundSystem shutting down…
[20:49:57] [Client thread/INFO] [STDOUT]: [paulscode.sound.SoundSystemLogger:importantMessage:90]: Author: Paul Lamb, www.paulscode.com
[20:49:57] [Client thread/INFO] [STDOUT]: [paulscode.sound.SoundSystemLogger:message:69]:
[20:49:57] [Sound Library Loader/INFO] [STDOUT]: [paulscode.sound.SoundSystemLogger:message:69]:
[20:49:57] [Sound Library Loader/INFO] [STDOUT]: [paulscode.sound.SoundSystemLogger:message:69]: Starting up SoundSystem…
[20:49:57] [Thread-8/INFO] [STDOUT]: [paulscode.sound.SoundSystemLogger:message:69]: Initializing LWJGL OpenAL
[20:49:57] [Thread-8/INFO] [STDOUT]: [paulscode.sound.SoundSystemLogger:message:69]: (The LWJGL binding of OpenAL. For more information, see http://www.lwjgl.org)
[20:49:57] [Thread-8/INFO] [STDOUT]: [paulscode.sound.SoundSystemLogger:message:69]: OpenAL initialized.
[20:49:58] [Sound Library Loader/INFO] [STDOUT]: [paulscode.sound.SoundSystemLogger:message:69]:
[20:49:58] [Sound Library Loader/INFO]: Sound engine started
[20:50:57] [Server thread/INFO]: Starting integrated minecraft server version 1.7.10
[20:50:57] [Server thread/INFO]: Generating keypair
[20:50:57] [Server thread/INFO] [FML]: Injecting existing block and item data into this server instance
[20:50:58] [Server thread/INFO] [FML]: Applying holder lookups
[20:50:58] [Server thread/INFO] [FML]: Holder lookups applied
[20:50:59] [Server thread/INFO] [FML]: Loading dimension 0 (Test World) (net.minecraft.server.integrated.IntegratedServer@2726a4d4)
[20:50:59] [Server thread/INFO] [FML]: Loading dimension 1 (Test World) (net.minecraft.server.integrated.IntegratedServer@2726a4d4)
[20:50:59] [Server thread/INFO] [FML]: Loading dimension -1 (Test World) (net.minecraft.server.integrated.IntegratedServer@2726a4d4)
[20:50:59] [Server thread/INFO]: Preparing start region for level 0
[20:51:00] [Server thread/INFO]: Preparing spawn area: 11%
[20:51:01] [Server thread/INFO]: Preparing spawn area: 61%
[20:51:03] [Server thread/INFO]: Changing view distance to 12, from 10
[20:51:05] [Netty Client IO #0/INFO] [FML]: Server protocol version 1
[20:51:05] [Netty IO #1/INFO] [FML]: Client protocol version 1
[20:51:05] [Netty IO #1/INFO] [FML]: Client attempting to join with 4 mods : modfuzzionsurvie@1.0.0,FML@7.10.85.1235,Forge@10.13.2.1235,mcp@9.05
[20:51:05] [Netty IO #1/INFO] [FML]: Attempting connection with missing mods [] at CLIENT
[20:51:05] [Netty Client IO #0/INFO] [FML]: Attempting connection with missing mods [] at SERVER
[20:51:05] [Server thread/INFO] [FML]: [Server thread] Server side modded connection established
[20:51:05] [Client thread/INFO] [FML]: [Client thread] Client side modded connection established
[20:51:05] [Server thread/INFO]: Player15[local:E:115f878c] logged in with entity id 284 at (107.67034172069779, 64.0, 322.7299430436911)
[20:51:05] [Server thread/INFO]: Player15 joined the game
[20:51:06] [Server thread/WARN]: Can’t keep up! Did the system time change, or is the server overloaded? Running 3478ms behind, skipping 69 tick(s)
[20:51:19] [Server thread/INFO]: Saving and pausing game…
[20:51:19] [Server thread/INFO]: Saving chunks for level ‘Test World’/Overworld
[20:51:20] [Server thread/INFO]: Saving chunks for level ‘Test World’/Nether
[20:51:20] [Server thread/INFO]: Saving chunks for level ‘Test World’/The End
[20:52:00] [Server thread/INFO]: Saving and pausing game…
[20:52:00] [Server thread/INFO]: Saving chunks for level ‘Test World’/Overworld
[20:52:00] [Server thread/INFO]: Saving chunks for level ‘Test World’/Nether
[20:52:00] [Server thread/INFO]: Saving chunks for level ‘Test World’/The End -
à mon avis, si ça n’affiche rien, c’est que la méthode n’est pas appelée.
-
oui d’accord mais comment l’appelé alors ?
-
Tu as bien fait un clic droit sur le véhicule ?
-
Oui j’ai tous essayer clic droit, Shift + clic droit …
mais je n’arrive pas a voir le problème -
Demande a peugeot, je pense que ils s’y connaissent bien en voiture. Sinon mise a par ça la fonction “interact” viens de la classe EntityLiving, donc si elle est pas extends de cet classe elle fonctionne pas. Passe regarder la classe EntittLiving pour comprendre ^^.
-
XD non mais enfaite L’entity de la Voiture n’est pas une EntityLiving je ne peut donc pas utiliser la fonction interact c’est ce que Robin m’a bien expliquer mais du coup je me retrouve bloquer avec une voiture dans laquelle je ne peut pas monter X)
-
Bha il suffit de l’extends EntityLiving
-
le trucs c’est que si je la change en EntityLiving toutes mon Entity a des erreurs….
-
Je vais peut être dire des connerie mais es ce que cela pourrait avoir un rapport avec sa Matrix Parce-que je vient de remarquer que la voiture est donc considérer comme une Entité mais que a la fois si j’appuie sur la molette de ma souris pour l’avoir dans ma main comme un Item, je passe totalement a travers puisque je prend le bloc du dessous…
Ce que je pense n’est pas Normal puisque le Minecart par exemple lui ne fait pas sa…
Ce qui donc peut sans doute expliquer pourquoi je ne peux Interagir avec, car mon Player “clic droit” sur la block dans dessous…
Vous en Pense Quoi vous ? -
regarde en changent le nom de la fonction en “interactFirst”, et je croit que il faut mettre une condition d’un event.
-
C’est à Dire ? je n’est pas bien compris mais la Fonction est déjà en InteractFirst