tutorials/Spawning a Snake

OK, so, you want to spawn snakes right? Well if you've already linked to NightCrawlerCore, (see here if you haven't) then your able to start spawning snakes! First decide what kind of snake you want. If your using a config, then you can gather the properties from there, or you can make your own! Here's how to spawn a snake. It's basically a large constructor.

	Snake snake = new Snake(int length, Location loc, long speed, int hp, LivingEntity target,
int airLeft, long breathLength, int damage, boolean borrow, boolean othercol, boolean selfcol,
boolean ladder, boolean randompath, AbilityType[] abilites, int changetarget, byte scales,
byte damagescales, String head);

This is what each parameter does: (Copied from this plugin's JavaDoc)

  • length - The length of the snake, or how many body segments it has. This does not count the head however. If a value lower then 1 is entered, then the body length defaults to 1 segment.
  • loc - The location to spawn the snake at.
  • speed - The delay for the snakes movement in milliseconds. This means the snake moves 1 block every set number of milliseconds, unless a movement could not be made due to blockades.
  • hp - The max hp for the snake.
  • target - The name of the snake's first target. If null is entered, or the player with the requested name could not be found, the snake will not move until another target is selected. The snake will automatically choose a new target every configurable amount of seconds.
  • airLeft - The amount of air bubbles this snake has. Set to -1 for infinite air.
  • breathLength - The time in milliseconds that each bubble lasts. After all the air bubbles are gone, the snake will get damaged by 5hp every time this runs out.
  • damage - The attack power of the snake. This only applies to the snake if they have the ability of BASIC_ATTACK.
  • borrow - This asks if the snake is allowed to borrow or not. If true, the snake will destroy blocks as it digs through them, without a second though. If false however, all actions are client-side only. This feature is still slightly buggy however, and not recommended for use.
  • othercol - This asks if the snake should collide with other snakes or just pass through them. If set to false, then multiple snakes can occupy the space block at the same time. If set to true, snakes will run into each other as if hitting a wall.
  • selfcol - This asks if snakes should collide with their own tail or not. If they can, then they will stop as if hitting a wall or barrier. If set to false, then they can freely pass through as if it were air.
  • ladder - This option allows snakes to crawl on top of each other to get you. Snakes can walk on each other and even climb over their own tail! The animation for this is very glitchy though, it does work.
  • randompath - If set to true, then the path that the snakes travels to reach it's target is random. If after 5 tries the snake fails to find a usable path, it will skip the move event. If this option is set to false, then the snake will always head straight at the player, unless there is an obstacle in the way. The snake will only skip a movement if there is absolutely no possible path it can find.
  • abilites - An array of all the abilities that this snake has.
  • changetarget - The number of seconds it takes for a snake to change its target.
  • scales - The id for the type of plant inside the flower pots under normal circumstances.
  • damagescales - Same as scales, but for when the snake gets damaged.
  • head - The name of the player to copy the head from. Putting a numerical value in the string will make the head use the Minecraft id for that head.

This spawns a snake. (Don't worry, I plan to make a simpler way in the next update. I've already thought of a few things to do.) The snake will automatically try to follow and attack its target. And tada! Your done!


Comments

Posts Quoted:
Reply
Clear All Quotes