Everything posted by knokko
-
[1.7.10] slow custom mob
hello guys, I have a problem with my custom mob. I want my mob to run as quick as a player, but I can't get my mob faster than a walking player. Here is the mob class: public class EntityChow extends EntityNecromancerMinion{ public EntityChow(World world) { super(world); setCurrentItemOrArmor(0, new ItemStack(Items.wooden_sword)); } public void applyEntityAttributes(){ super.applyEntityAttributes(); getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(5); getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(5); } public EntityChow(Entity entity){ this(entity, TargetType.DEFENSIVE); setCurrentItemOrArmor(0, new ItemStack(Items.wooden_sword)); } public EntityChow(Entity entity, TargetType target){ super(entity, target, new Position(entity)); } } Here is the class the mob extends: public abstract class EntityNecromancerMinion extends EntityCreature{ /** * The master of the mob. This mob will fight for it's master as long as it is a necromancer. */ public Entity master; /** * The UUID of the master as String. */ public String masterId; /** * The way this mob will choose its target. */ public TargetType targetType; /** * The team of the minion, the master of the minion is always the leader of the team. * Every minion of the master is in the same team. */ public UndeadTeam team; private int pathCooldown = 0; private int strikeCooldown; public EntityNecromancerMinion(World world) { super(world); } public EntityNecromancerMinion(Entity owner){ this(owner, new Position(owner)); } public EntityNecromancerMinion(Entity owner, Position spawn){ this(owner, TargetType.DEFENSIVE, spawn); } public EntityNecromancerMinion(Entity owner, TargetType type, Position spawn){ super(owner.worldObj); setPosition(spawn.x, spawn.y, spawn.z); master = owner; team = UndeadTeam.getTeam(owner); targetType = type; } public EntityNecromancerMinion(Entity owner, double x, double y, double z){ this(owner, new Position(x, y, z)); } public EntityNecromancerMinion(Entity owner, TargetType type, double x, double y, double z){ this(owner, type, new Position(x, y, z)); } public EnumCreatureAttribute getCreatureAttribute(){ return EnumCreatureAttribute.UNDEAD; } public boolean canDespawn(){ return false; } public void writeEntityToNBT(NBTTagCompound nbt){ super.writeEntityToNBT(nbt); if(master != null){ nbt.setString("master", master.getUniqueID().toString()); } if(targetType != null){ targetType.writeToNBT(nbt); } } public void readEntityFromNBT(NBTTagCompound nbt){ super.readEntityFromNBT(nbt); masterId = nbt.getString("master"); targetType = TargetType.fromNBT(nbt); } public void onUpdate(){ super.onUpdate(); if(!worldObj.isRemote){ if(master == null){ if(masterId != null && !masterId.isEmpty()){ master = EntityUtils.getEntityByUUID(worldObj, masterId); } } if(team == null && master != null && !worldObj.isRemote){ team = UndeadTeam.getTeam(master); if(ticksExisted > 50 && team == null){ worldObj.spawnEntityInWorld(new UndeadTeam(master)); } } if(team != null){ if(!team.members.contains(this)){ team.members.add(this); } if(!team.members.contains(master) && master != null){ team.members.add(master); } entityToAttack = team.getTarget(this); } if(entityToAttack != null){ if(getFightType() == FightType.CLOSECOMBAT){ if((!hasPath() || pathCooldown == 0) && !worldObj.isRemote){ pathCooldown = 40; setPathToEntity(worldObj.getPathEntityToEntity(this, entityToAttack, (float) getEntityAttribute(SharedMonsterAttributes.followRange).getAttributeValue(), false, false, true, true)); } } if(entityToAttack.isDead){ entityToAttack = null; } } if(strikeCooldown > 0){ --strikeCooldown; } if((getFightType() == FightType.CLOSECOMBAT || getFightType() == FightType.MULTIPLY) && (!worldObj.isRemote && entityToAttack != null)){ if(Position.getSquaredDistance(new Position(this), new Position(entityToAttack)) < 3 && strikeCooldown <= 0){ entityToAttack.attackEntityFrom(DamageSource.causeMobDamage(this), (float) getEntityAttribute(SharedMonsterAttributes.attackDamage).getAttributeValue()); strikeCooldown = 10; } } if(master != null){ double distance = Position.getSquaredDistance(new Position(this), new Position(master)); if(distance > 32 && entityToAttack == null && !hasPath() && !isGhost()){ setPathToEntity(worldObj.getPathEntityToEntity(this, master, (float) getEntityAttribute(SharedMonsterAttributes.followRange).getAttributeValue(), false, false, true, true)); } if(distance > 48 && pathCooldown <= 0 && !isGhost()){ setPathToEntity(worldObj.getPathEntityToEntity(this, master, (float) getEntityAttribute(SharedMonsterAttributes.followRange).getAttributeValue(), false, false, true, true)); pathCooldown = 20; } } } } /** * How this entity will fight. It can be ranged, close combat or mulitply. * @return How this entity will fight. */ public FightType getFightType(){ return FightType.CLOSECOMBAT; } public boolean attackEntityFrom(DamageSource source, float damage){ Entity entity = source.getEntity(); if(entity instanceof EntityNecromancerMinion){ EntityNecromancerMinion minion = (EntityNecromancerMinion) entity; if(master != null && master == minion.master){ return false; } } else if(entity == master && master != null){ return false; } else if(entity instanceof EntityLivingBase && team != null){ team.addTarget(entity, false, true); } return super.attackEntityFrom(source, damage); } public void applyEntityAttributes(){ super.applyEntityAttributes(); getAttributeMap().registerAttribute(SharedMonsterAttributes.attackDamage); getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(64); } public boolean interact(EntityPlayer player){ return true; } public boolean isGhost(){ return false; } } If I set the movement speed slower, the mob will move slower, but how high I make the movementSpeed, the mob will not run faster than a walking player. Does anybody know how to make this mob faster.
-
Render distance of custom mob
The renderdistanceweight of a creeper = 1, so that can't be the problem. I have never seen something before.
-
[1.7.10] cameraZoom [UNSOLVED]
You can register it with MinecraftForge.EVENT_BUS.register(new FOVHandler()); this is my class as example: package knokko.rpg.events.other; import knokko.rpg.data.WorldData; import net.minecraftforge.client.event.FOVUpdateEvent; import cpw.mods.fml.common.eventhandler.SubscribeEvent; public class FOVHandler { @SubscribeEvent public void fovEvent(FOVUpdateEvent event){ if(WorldData.getString(event.entity, "race", "human").matches("eyeman")){ if(WorldData.getBooleanOption(event.entity, "zoom", false)){ event.newfov = 0.1F; } } } }
-
[1.7.10] cameraZoom [UNSOLVED]
I think you can better use the FOV update event instead of this stuff. I think that will not delete your bow. But I don't even understand how your bow disappeares.
-
[SOLVED][1.7.10]Projectile doesn't register hitting entities
You must use the constructor (World, EntityLivingBase) or your entity will spawn at 0,0,0
-
[1.7.10] cameraZoom [UNSOLVED]
What method are you using and what is your return statement?
-
[1.7.10] How to make mob attack?
Before you can attack a player, you need a player to attack. Try worldObj.getClosestPlayer to find methods for getting players. For getting a good damagesource: use DamageSource.causeMobDamage(this) use the ammount of damage you want instead of "par2". and like diesieben said: if you would know basic java, you would be finished allready!
-
How do you render non-living entities
Show your console, entities don't just disappear, it is very likely there is a big error in your console.
-
[1.7.10] How to make mob attack?
Use the method onUpdate(), don't forget to call super.onUpdate(). Than test if the distance to the closest player is very short. than use player.attackEntityFrom(DamageSource source, float damage);
-
[1.7.10] Advanced Forge Config
I think NBTTagCompound is the file you are looking for. You can store values under strings. If not, can you explain better what you want?
-
Controlling the Player
What is wrong with changing motion of the player? You can use it with no problems on servers if it is not too fast. And I know because I was really curious
-
[1.7.10] set attack target of zombies
I have edited the code to work on any undead mobs, but now the Zombie is the only entity I can't control. Here is my new code: Line line = Line.fromRaytrace(player, 100).toNearestBlock(world, false, 1); EntityLivingBase entity = (EntityLivingBase) line.getNearestEntity(world, EntityLivingBase.class, line.getPosition(1), player); System.out.println("entity = " + entity); if(entity != null){ double distance = Math.min(spirit * 5, 40); distance = 50; List entities = world.getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getBoundingBox(player.posX - distance, player.posY - distance, player.posZ - distance, player.posX + distance, player.posY + distance, player.posZ + distance)); System.out.println("entities = " + entities); int times = 0; while(times < entities.size()){ EntityLivingBase living = (EntityLivingBase) entities.get(times); if(living != entity && living.getCreatureAttribute() == EnumCreatureAttribute.UNDEAD){ living.setRevengeTarget(entity); if(living instanceof EntityCreature){ ((EntityCreature) living).setTarget(entity); } System.out.println("target is set."); } ++times; } } I can even control withers, but no zombies. EDIT: I can't control wither skeletons too. Why is target control different for every mob? Has anybody ever controlled zombies?
-
Making pig zombies attack a player
You only need pigzombie.setTarget(entityToAttack);
-
Share a boolean between all clients
The third option of storing data "in" entities is using WorldSavedData and set tags for every entity. But I don't think you are familiar with WorldSavedData, or with any way of saving data...
-
Controlling the Player
What are you going to do? Controlling players for multiplayer? And further: For moving the player: change the fields player.motionX, player.motionY, player.motionZ. Use player.rotationYaw and player.rotationPitch for turning the player. And I don't know how to do the part about punching.
-
[SOLVED][1.7.10]Projectile doesn't register hitting entities
You are registering your entity on the client side, that is not good. Only rendering goes on client side, the other part should be server side.
-
[Solved] My Mod Works for Me But Not For A Friend
Have you different systems on your computers? This could be a problem. Or just other minecraft (forge) versions? Or an other java version? And can your friend send a crash report?
-
[1.7.10] Can't manipulate player's inventory beyond slot 8
I don't know what is causing this, but you can try using player.inventory.mainInventory[number] = null;
-
[1.7.10] set attack target of zombies
hello, I am creating an item that has to "control" zombies. I am trying methods of EntityZombie for setting attack targets, but none of them seems to work. Now the strange thing is: The item works great on zombie pigmans, but zombies to not react at all. here is the important part of the code: Line line = Line.fromRaytrace(player, 100).toNearestBlock(world, false, 1); EntityLivingBase entity = (EntityLivingBase) line.getNearestEntity(world, EntityLivingBase.class, line.getPosition(1), player); System.out.println("entity = " + entity); if(entity != null){ double distance = Math.min(spirit * 5, 40); List zombies = world.getEntitiesWithinAABB(EntityZombie.class, AxisAlignedBB.getBoundingBox(player.posX - distance, player.posY - distance, player.posZ - distance, player.posX + distance, player.posY + distance, player.posZ + distance)); System.out.println("zombies = " + zombies); int times = 0; while(times < zombies.size()){ EntityZombie zombie = (EntityZombie) zombies.get(times); if(zombie != entity){ zombie.setTarget(entity); zombie.setAttackTarget(entity); zombie.setRevengeTarget(entity); System.out.println("target is set."); } ++times; } } Does anybody know a way to set the target of a zombie? And does anybody know why it works on zombie pigmans, but not on normal zombies?
-
[SOLVED][1.7.10]Projectile doesn't register hitting entities
First, if you are going to register your item, add a constructor that has only a World parameter. Further, I have a strange thing that is a little bit the same as your problem. In my code, the entity get attacked, but if the hit is an entity, it doesn't make a nice ball. @Override public void onImpact(MovingObjectPosition mop) { EnergyBall.makeBall(worldObj, posX, posY, posZ, 0.5, 1, 10, 5, 5000); if(mop.entityHit instanceof EntityLivingBase){ EntityLivingBase entity = (EntityLivingBase) mop.entityHit; DamageSource source = new EntityDamageSourceIndirect("ice spell", this, getThrower()); entity.attackEntityFrom(source, power); entity.addPotionEffect(new PotionEffect(2, (int) (20 * power), 1)); } setDead(); } I have never understanded it, but your problem is almost the same as mine.
-
drop a item in the world(x y z ) que por que si, solvig trouble item not consum
You can use world.spawnEntityInWorld(new EntityItem(...));
-
More mods to improve FPS / decrease lag
You are here on the modder support section, so if you are not going to make a mod like that, you are on the wrong section. This is made for people who have problems with making mods.
-
[1.7.10] Key Bindings wont work
I nowhere see you calling your init() method in KeyBindings, if you don't call this method, GunSound will not be initialisated and null. So if you use gunsound.isPressedd(), gunsound is null, so you will cause a NullPointerException.
-
[UNSOLVED] Cant sleep in custom bed
Try to use a new class that extends BlockBed. You don't have to duplicate the code of BlockBed than and you can change some things you want.
-
[SOLVED]Entities spawning and almost immediately vanishing on item right click
Check your console, there maybe an error inside it.
IPS spam blocked by CleanTalk.