Jump to content

Recommended Posts

Posted

Hello everyone. I know i've been asking this for a while now, but still even without asking for help, I still cant get my fish mob working the way I want it to. My fish mob will float like regular mobs would. So can anyone help me? How can I make a water mob? Should I make my own AI for it or something? I really need help guys becuase I have no clue what to do. Any help is appretiated like always  :).

Hello everyone! I'm the developer and owner of a mod called MagZ Aquatic Life Experience. Right now it's being worked on, but when it's released, check it out!

 

--[Also Check Out My Website!]--

Posted

It floats like regular mobs would? Do you mean like EntityGhast or like entities which can swim or what?

Show the part of your code that doesn't work. It really depends your needs if you should create AI task for it. If your entity should not be very smart with moving (like pathfinding around the obstacles) you can do basic moving without AI tasks.

Posted

If you want AI behavior like vanilla, look at vanilla mobs. Probably what you want is EntityAISwimming, which is what pretty much every swimming mob using, e.g. zombies and skeletons.

If you want similar but not exact behavior, it is easy concept, the way Minecraft handles swimming is by entity's jump, if entity is under water and it jumps, it goes up. This way all you have to do is to use entity.getJumpHelper().setJumping() and it will go up on water and when it hits the surface, it will start going up and back to water just like how skeletons and zombies do.

Posted

What I mean is my water mob is jumping in the water like regular mobs do. Here is my code and yes I did extend the entitywatermob class. If things look like they shoudn't be there, it's becuase im trying to write my own AI since the entitysquid class isn't helping.

 

My entityfishmob class:

package com.MagZAquaticLifeExperience.common.entity;

import com.MagZAquaticLifeExperience.common.MagzAquaticLifeExperience;

import net.minecraft.block.material.Material;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.passive.EntityWaterMob;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;

public class EntityFishMob extends EntityWaterMob {

 private float randomMotionSpeed;
 private float randomMotionVecX;
 private float randomMotionVecY;
 private float randomMotionVecZ;

public EntityFishMob(World par1World) {
	super(par1World);
	 this.setSize(1.0F, 0.5F);
}


protected void applyEntityAttributes() {
	super.applyEntityAttributes();
    this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(4.0D);
}

public boolean canBreatheUnderwater()
    {
        return true;
    }

 public void moveEntityWithHeading(float par1, float par2) {

	 this.moveEntity(this.motionX, this.motionY, this.motionZ);
    
 }


@Override
public boolean isInWater() {
	return this.worldObj.handleMaterialAcceleration(this.boundingBox.expand(1.0D, 0.0D, 0.0D), Material.water, this);
}

@Override
public void onLivingUpdate() {

	super.onLivingUpdate();

	if(this.isInWater()) {

		this.randomMotionSpeed = 2.0F;
	}

	if(!this.isInWater()) {

		this.randomMotionSpeed = 0.0F;
	}
}

protected String getLivingSound() {
	return "";
}

protected String getDeathSound() {
	return "";
}

}


  

Hello everyone! I'm the developer and owner of a mod called MagZ Aquatic Life Experience. Right now it's being worked on, but when it's released, check it out!

 

--[Also Check Out My Website!]--

Posted

I think if you want it to swim like a fish (under the water instead of on the water surface, and smoothly instead of jerky like a squid) you will need custom AI and maybe custom pathfinding.  You can use the "new" AI where you create a list of tasks that have priority and mutual exclusivity or you can use the "old" UI which basically just processes all possible movement actions in one method.

 

I suspect that there are some open source code for other fish mods that may implement proper swimming.

 

If you end up coding your own I think to be fish like you'd basically choose some underwater point that you know you can get to and swim towards that and then occasionally (and bit randomly) decide to choose other target location.  Like a school of fish moving along and then switching direction.  In terms of moving up and down in the water, you'd probably have to check how much water is above and below and decide if it needs to move up or down based on how "deep" (maybe including some randomness) you want it to swim.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Posted

Thanks for the reply! But yeah I can't find any open source code for fish mobs :(. Could you possibly help me work things out? Like how to make it pathfind and such. I'm a little new to how mob AI's work for minecraft. I was mainly focused on gui's, tile entities and such. So could anyone help me out? Please don't post code, just tell me how to work things out. Thanks  :)

Hello everyone! I'm the developer and owner of a mod called MagZ Aquatic Life Experience. Right now it's being worked on, but when it's released, check it out!

 

--[Also Check Out My Website!]--

Posted
  On 8/20/2014 at 4:03 AM, MagnumMike55 said:

Thanks for the reply! But yeah I can't find any open source code for fish mobs :(. Could you possibly help me work things out? Like how to make it pathfind and such. I'm a little new to how mob AI's work for minecraft. I was mainly focused on gui's, tile entities and such. So could anyone help me out? Please don't post code, just tell me how to work things out. Thanks  :)

Look at the vanilla AI classes - some of those have path-finding algorithms in them; or look at EntitySquid to see how they are caused to move somewhat randomly, or EntityBat, which also has an interesting path-finding algorithm which may be more suitable for a fish than the squid's motion.

 

Then, either create a custom AI class and add it as a task for your fish (preferable), or add the movement code directly into the update tick like bats and squid (not as preferable, but still works).

Posted

Quick question coolAlias. When you said "create a custom AI class and add it as a task for your fish" does that mean make the custom ai class and in my entityfishmob class, extend it?

 

Ex: public class EntityFishMob extends CustomAI() {

 

}

 

I think i'm just confused on what you're saying, even if it is obvious. Anyway thanks for the help!  :D

Hello everyone! I'm the developer and owner of a mod called MagZ Aquatic Life Experience. Right now it's being worked on, but when it's released, check it out!

 

--[Also Check Out My Website!]--

Posted

Have you ever looked at any of the vanilla mob classes? Most of them have an EntityAITasks field named 'tasks', and you will see in the class constructor all of the tasks that get added such as 'tasks.addTask(0, new EntityAISwimming(this));', where the number is the priority of execution (low number is high priority) and the second argument is an instance of the AI task that you want.

 

Spend some time looking through vanilla code and you will find the answers, and if you don't understand it, then spend some more time reading the code and look up as much Java as you need to figure out what's going on.

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • This mod lets you choose an element power, Earth, Wind, Fire, or Water. Also two secret element powers Light and Darkness. Each power gives good a bad things, Earth lets you dig through anything but ores and bedrock, Wind lets you jump high in the air every three seconds, Fir lets you throw fire balls and you are immune to any flame/lava but you can't go into water or else you take damage, Water you swim and break blocks under water quicker and you can get rid of water like a sponge but you take more damage when in fire/lava, Light makes you faster at day but slower at night you are able to throw light spears that do four hearts and can go through any armor, Darkness let's you be faster at night but slower at day mobs don't harm you but peaceful mobs run away from you you are able to spawn ink creatures around you that are like dogs but are stronger. another thing in the mod is that there are other dimensions that can get you ores to make better armor and weapons, each dimensions are are good for a certain element though each dimension has a boss depending on which dimension one dimension has more than one boss, each elements are required to defeat the bosses with each others help.
    • Read the posts above yours, it tells you exactly how to do it, instructions are the same if it's making a forge installation or a vanilla one, just make a new folder for the game directory.
    • Yes that’s the full log, I managed to get it working last night, the anvil fix mod is what was causing it to crash
    • Hey guys, i'm currently developping a mod with forge 1.12.2 2860 and i'm using optifine and gradle 4.9. The thing is i'm trying to figure out how to show the player's body in first person. So far everything's going well since i've try to use a shader. The player's body started to blink dark when using a shader. I've try a lot of shader like chocapic, zeus etc etc but still the same issue. So my question is : How should i apply the current shader to the body ? At the same time i'm also drawing a HUD so maybe it could be the problem?   Here is the issue :    And here is the code where i'm trying to display the body :    private static void renderFirstPersonBody(EntityPlayerSP player, float partialTicks) { Minecraft mc = Minecraft.getMinecraft(); GlStateManager.pushMatrix(); GlStateManager.pushAttrib(); try { // Préparation OpenGL GlStateManager.enableDepth(); GlStateManager.depthMask(true); GlStateManager.enableAlpha(); GlStateManager.alphaFunc(GL11.GL_GREATER, 0.1F); GlStateManager.enableBlend(); GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); // Éclairage correct pour shaders GlStateManager.enableLighting(); RenderHelper.enableStandardItemLighting(); GlStateManager.enableRescaleNormal(); // Active la lightmap pour les shaders mc.entityRenderer.enableLightmap(); // Position de rendu interpolée double px = player.lastTickPosX + (player.posX - player.lastTickPosX) * partialTicks; double py = player.lastTickPosY + (player.posY - player.lastTickPosY) * partialTicks; double pz = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * partialTicks; GlStateManager.translate( px - mc.getRenderManager().viewerPosX, py - mc.getRenderManager().viewerPosY, pz - mc.getRenderManager().viewerPosZ ); // Rendu du joueur sans la tête Render<?> render = mc.getRenderManager().getEntityRenderObject(player); if (render instanceof RenderPlayer) { RenderPlayer renderPlayer = (RenderPlayer) render; boolean oldHeadHidden = renderPlayer.getMainModel().bipedHead.isHidden; boolean oldHeadwearHidden = renderPlayer.getMainModel().bipedHeadwear.isHidden; renderPlayer.getMainModel().bipedHead.isHidden = true; renderPlayer.getMainModel().bipedHeadwear.isHidden = true; setArmorHeadVisibility(renderPlayer, false); renderPlayer.doRender(player, 0, 0, 0, player.rotationYaw, partialTicks); renderPlayer.getMainModel().bipedHead.isHidden = oldHeadHidden; renderPlayer.getMainModel().bipedHeadwear.isHidden = oldHeadwearHidden; setArmorHeadVisibility(renderPlayer, !oldHeadwearHidden); } // Nettoyage post rendu mc.entityRenderer.disableLightmap(); GlStateManager.disableRescaleNormal(); } catch (Exception e) { // silent fail } finally { GlStateManager.popAttrib(); GlStateManager.popMatrix(); } }   Ty for your help. 
    • Item successfully registered, but there was a problem with the texture of the item, it did not insert and has just the wrong texture.     
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.