Advertisement
Guest User

Tortoise

a guest
Feb 25th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 16.05 KB | None | 0 0
  1. package mod.mcreator;
  2.  
  3. import net.minecraftforge.fml.relauncher.SideOnly;
  4. import net.minecraftforge.fml.relauncher.Side;
  5. import net.minecraftforge.fml.common.registry.EntityRegistry;
  6. import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
  7. import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
  8. import net.minecraftforge.fml.common.event.FMLInitializationEvent;
  9. import net.minecraftforge.fml.client.registry.RenderingRegistry;
  10.  
  11. import net.minecraft.world.biome.Biome;
  12. import net.minecraft.world.World;
  13. import net.minecraft.util.math.MathHelper;
  14. import net.minecraft.util.ResourceLocation;
  15. import net.minecraft.util.EnumHand;
  16. import net.minecraft.util.DamageSource;
  17. import net.minecraft.item.ItemStack;
  18. import net.minecraft.item.Item;
  19. import net.minecraft.entity.player.EntityPlayer;
  20. import net.minecraft.entity.passive.EntityDonkey;
  21. import net.minecraft.entity.effect.EntityLightningBolt;
  22. import net.minecraft.entity.ai.EntityAIWander;
  23. import net.minecraft.entity.ai.EntityAISwimming;
  24. import net.minecraft.entity.ai.EntityAILookIdle;
  25. import net.minecraft.entity.SharedMonsterAttributes;
  26. import net.minecraft.entity.EnumCreatureType;
  27. import net.minecraft.entity.Entity;
  28. import net.minecraft.client.renderer.entity.RenderLiving;
  29. import net.minecraft.client.model.ModelRenderer;
  30. import net.minecraft.client.model.ModelHorse;
  31. import net.minecraft.client.model.ModelBase;
  32. import net.minecraft.client.Minecraft;
  33.  
  34. import java.util.Random;
  35. import java.util.Iterator;
  36. import java.util.ArrayList;
  37.  
  38. @SuppressWarnings("unchecked")
  39. public class mcreator_arideableTortoise {
  40.  
  41. public int mobid = 0;
  42. public static Object instance;
  43.  
  44. public void load(FMLInitializationEvent event) {
  45. }
  46.  
  47. public void generateNether(World world, Random random, int chunkX, int chunkZ) {
  48. }
  49.  
  50. public void generateSurface(World world, Random random, int chunkX, int chunkZ) {
  51. }
  52.  
  53. public int addFuel(ItemStack fuel) {
  54. return 0;
  55. }
  56.  
  57. @SideOnly(Side.CLIENT)
  58. public void registerRenderers() {
  59. RenderLiving customRender = new RenderLiving(Minecraft.getMinecraft().getRenderManager(), new mcreator_arideableTortoise.ModelHorse(), 0) {
  60. protected ResourceLocation getEntityTexture(Entity par1Entity) {
  61. return new ResourceLocation("tortoise.png");
  62. }
  63. };
  64. RenderingRegistry.registerEntityRenderingHandler(mcreator_arideableTortoise.EntityarideableTortoise.class, customRender);
  65.  
  66. }
  67.  
  68. public void serverLoad(FMLServerStartingEvent event) {
  69. }
  70.  
  71. public void preInit(FMLPreInitializationEvent event) {
  72. int entityID = MathHelper.getRandomUUID().hashCode();
  73. mobid = entityID;
  74. EntityRegistry.registerModEntity(new ResourceLocation("testenvironmentmod:arideableTortoise"),
  75. mcreator_arideableTortoise.EntityarideableTortoise.class, "arideableTortoise", entityID, instance, 64, 1, true, (0 << 16)
  76. + (153 << 8) + 0, (255 << 16) + (255 << 8) + 255);
  77. EntityRegistry.addSpawn(mcreator_arideableTortoise.EntityarideableTortoise.class, 0, 0, 0, EnumCreatureType.CREATURE, clean(Biome.REGISTRY));
  78.  
  79. }
  80.  
  81. public static Biome[] clean(net.minecraft.util.registry.RegistryNamespaced<ResourceLocation, Biome> in) {
  82. Iterator<Biome> itr = in.iterator();
  83. ArrayList<Biome> ls = new ArrayList<Biome>();
  84. while (itr.hasNext()) {
  85. ls.add(itr.next());
  86. }
  87. return ls.toArray(new Biome[ls.size()]);
  88. }
  89.  
  90. public static class EntityarideableTortoise extends EntityDonkey {
  91. World world = null;
  92.  
  93. public EntityarideableTortoise(World var1) {
  94. super(var1);
  95. world = var1;
  96. experienceValue = 0;
  97. this.isImmuneToFire = false;
  98. addRandomArmor();
  99. setNoAI(!true);
  100. this.tasks.addTask(0, new EntityAISwimming(this));
  101. this.tasks.addTask(6, new EntityAIWander(this, 1.0D));
  102. this.tasks.addTask(8, new EntityAILookIdle(this));
  103.  
  104. }
  105.  
  106. protected void addRandomArmor() {
  107.  
  108. }
  109.  
  110. public void moveEntityWithHeading(float strafe, float forward) {
  111. Entity entity = this.getPassengers().isEmpty() ? null : (Entity) this.getPassengers().get(0);
  112.  
  113. if (this.isBeingRidden() && this.canBeSteered()) {
  114. this.rotationYaw = entity.rotationYaw;
  115. this.prevRotationYaw = this.rotationYaw;
  116. this.rotationPitch = entity.rotationPitch * 0.5F;
  117. this.setRotation(this.rotationYaw, this.rotationPitch);
  118. this.renderYawOffset = this.rotationYaw;
  119. this.rotationYawHead = this.rotationYaw;
  120. this.stepHeight = 1.0F;
  121. this.jumpMovementFactor = this.getAIMoveSpeed() * 0.1F;
  122.  
  123. if (this.canPassengerSteer()) {
  124. float f = (float) this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).getAttributeValue() * 0.1F;
  125. this.setAIMoveSpeed(f);
  126. super.moveEntityWithHeading(0.0F, 1.0F);
  127. } else {
  128. this.motionX = 0.0D;
  129. this.motionY = 0.0D;
  130. this.motionZ = 0.0D;
  131. }
  132.  
  133. this.prevLimbSwingAmount = this.limbSwingAmount;
  134. double d1 = this.posX - this.prevPosX;
  135. double d0 = this.posZ - this.prevPosZ;
  136. float f1 = MathHelper.sqrt(d1 * d1 + d0 * d0) * 4.0F;
  137.  
  138. if (f1 > 1.0F) {
  139. f1 = 1.0F;
  140. }
  141.  
  142. this.limbSwingAmount += (f1 - this.limbSwingAmount) * 0.4F;
  143. this.limbSwing += this.limbSwingAmount;
  144. } else {
  145. this.stepHeight = 0.5F;
  146. this.jumpMovementFactor = 0.02F;
  147. super.moveEntityWithHeading(strafe, forward);
  148. }
  149. }
  150.  
  151. @Override
  152. protected Item getDropItem() {
  153. return null;
  154. }
  155.  
  156. @Override
  157. protected net.minecraft.util.SoundEvent getAmbientSound() {
  158. return (net.minecraft.util.SoundEvent) net.minecraft.util.SoundEvent.REGISTRY.getObject(new ResourceLocation(""));
  159. }
  160.  
  161. @Override
  162. protected net.minecraft.util.SoundEvent getHurtSound() {
  163. return (net.minecraft.util.SoundEvent) net.minecraft.util.SoundEvent.REGISTRY.getObject(new ResourceLocation("game.neutral.hurt"));
  164. }
  165.  
  166. @Override
  167. protected net.minecraft.util.SoundEvent getDeathSound() {
  168. return (net.minecraft.util.SoundEvent) net.minecraft.util.SoundEvent.REGISTRY.getObject(new ResourceLocation("game.neutral.die"));
  169. }
  170.  
  171. @Override
  172. public void onStruckByLightning(EntityLightningBolt entityLightningBolt) {
  173. super.onStruckByLightning(entityLightningBolt);
  174. int i = (int) this.posX;
  175. int j = (int) this.posY;
  176. int k = (int) this.posZ;
  177. Entity entity = this;
  178.  
  179. }
  180.  
  181. @Override
  182. public void fall(float l, float d) {
  183. super.fall(l, d);
  184. int i = (int) this.posX;
  185. int j = (int) this.posY;
  186. int k = (int) this.posZ;
  187. super.fall(l, d);
  188. Entity entity = this;
  189.  
  190. }
  191.  
  192. @Override
  193. public void onDeath(DamageSource source) {
  194. super.onDeath(source);
  195. int i = (int) this.posX;
  196. int j = (int) this.posY;
  197. int k = (int) this.posZ;
  198. Entity entity = this;
  199.  
  200. }
  201.  
  202. @Override
  203. public boolean processInteract(EntityPlayer entity, EnumHand hand) {
  204. super.processInteract(entity, hand);
  205. int i = (int) this.posX;
  206. int j = (int) this.posY;
  207. int k = (int) this.posZ;
  208.  
  209. entity.startRiding(this);
  210.  
  211. return true;
  212. }
  213.  
  214. @Override
  215. protected float getSoundVolume() {
  216. return 1.0F;
  217. }
  218.  
  219. }
  220.  
  221. /**
  222. * ModelHorse - Either Mojang or a mod author Created using Tabula 5.1.0
  223. */
  224. public static class ModelHorse extends ModelBase {
  225. public ModelRenderer shelltop;
  226. public ModelRenderer shellundertop;
  227. public ModelRenderer undershell;
  228. public ModelRenderer sideleft;
  229. public ModelRenderer sideright;
  230. public ModelRenderer sideback;
  231. public ModelRenderer sidefront;
  232. public ModelRenderer head;
  233. public ModelRenderer tail;
  234. public ModelRenderer leftfrontleg;
  235. public ModelRenderer rightfrontleg;
  236. public ModelRenderer rightbackleg;
  237. public ModelRenderer leftbackleg;
  238. public ModelRenderer chest;
  239. public ModelRenderer crafting;
  240. public ModelRenderer tinybox;
  241. public ModelRenderer tiny;
  242. public ModelRenderer headtop;
  243. public ModelRenderer snouth;
  244. public ModelRenderer mouth;
  245. public ModelRenderer horn1;
  246. public ModelRenderer horn2;
  247. public ModelRenderer horn3;
  248. public ModelRenderer horn4;
  249. public ModelRenderer horn5;
  250. public ModelRenderer leftfrontfoot;
  251. public ModelRenderer rightfrontfoot;
  252. public ModelRenderer rightbackfoot;
  253. public ModelRenderer leftbackfoot;
  254.  
  255. public ModelHorse() {
  256. this.textureWidth = 128;
  257. this.textureHeight = 128;
  258. this.sidefront = new ModelRenderer(this, 99, 16);
  259. this.sidefront.setRotationPoint(-6.0F, 6.0F, -11.6F);
  260. this.sidefront.addBox(0.0F, 0.0F, 0.0F, 13, 8, 1, 0.0F);
  261. this.leftfrontfoot = new ModelRenderer(this, 0, 0);
  262. this.leftfrontfoot.setRotationPoint(0.0F, 5.0F, 0.0F);
  263. this.leftfrontfoot.addBox(0.0F, 0.0F, 0.0F, 4, 4, 4, 0.0F);
  264. this.setRotateAngle(leftfrontfoot, 0.27314402793711257F, 0.0F, 0.0F);
  265. this.headtop = new ModelRenderer(this, 0, 0);
  266. this.headtop.setRotationPoint(0.0F, 2.0F, -4.6F);
  267. this.headtop.addBox(0.0F, 0.0F, 0.0F, 5, 5, 5, 0.0F);
  268. this.setRotateAngle(headtop, 0.40980330836826856F, 0.0F, 0.0F);
  269. this.sideright = new ModelRenderer(this, 29, 1);
  270. this.sideright.setRotationPoint(8.1F, 5.9F, -10.1F);
  271. this.sideright.addBox(0.0F, 0.0F, 0.0F, 1, 8, 17, 0.0F);
  272. this.rightbackleg = new ModelRenderer(this, 0, 0);
  273. this.rightbackleg.setRotationPoint(4.0F, 15.2F, 2.6F);
  274. this.rightbackleg.addBox(0.0F, 0.0F, 0.0F, 4, 5, 4, 0.0F);
  275. this.setRotateAngle(rightbackleg, -0.27314402793711257F, 0.0F, 0.0F);
  276. this.tinybox = new ModelRenderer(this, 0, 0);
  277. this.tinybox.setRotationPoint(-5.2F, 2.0F, 3.7F);
  278. this.tinybox.addBox(0.0F, 0.0F, 0.0F, 3, 3, 3, 0.0F);
  279. this.leftbackfoot = new ModelRenderer(this, 0, 0);
  280. this.leftbackfoot.setRotationPoint(0.0F, 5.0F, 0.0F);
  281. this.leftbackfoot.addBox(0.0F, 0.0F, 0.0F, 4, 4, 4, 0.0F);
  282. this.setRotateAngle(leftbackfoot, 0.27314402793711257F, 0.0F, 0.0F);
  283. this.snouth = new ModelRenderer(this, 0, 16);
  284. this.snouth.setRotationPoint(0.0F, 4.6F, -7.7F);
  285. this.snouth.addBox(0.0F, 0.0F, 0.0F, 5, 3, 4, 0.0F);
  286. this.setRotateAngle(snouth, 0.6951646410693414F, 0.0F, 0.0F);
  287. this.rightbackfoot = new ModelRenderer(this, 0, 0);
  288. this.rightbackfoot.setRotationPoint(0.0F, 5.0F, 0.0F);
  289. this.rightbackfoot.addBox(0.0F, 0.0F, 0.0F, 4, 4, 4, 0.0F);
  290. this.setRotateAngle(rightbackfoot, 0.27314402793711257F, 0.0F, 0.0F);
  291. this.tiny = new ModelRenderer(this, 0, 0);
  292. this.tiny.setRotationPoint(0.0F, -0.5F, 6.2F);
  293. this.tiny.addBox(0.0F, 0.0F, 0.0F, 1, 2, 1, 0.0F);
  294. this.shellundertop = new ModelRenderer(this, -1, 58);
  295. this.shellundertop.setRotationPoint(-7.5F, 5.0F, -11.1F);
  296. this.shellundertop.addBox(0.0F, 0.0F, 0.0F, 16, 12, 19, 0.0F);
  297. this.crafting = new ModelRenderer(this, 0, 0);
  298. this.crafting.setRotationPoint(2.8F, 0.0F, 2.6F);
  299. this.crafting.addBox(0.0F, 0.0F, 0.0F, 4, 4, 4, 0.0F);
  300. this.head = new ModelRenderer(this, 64, 1);
  301. this.head.setRotationPoint(-2.4F, 8.5F, -14.4F);
  302. this.head.addBox(0.0F, -0.5F, -0.4F, 5, 6, 8, -0.4F);
  303. this.setRotateAngle(head, -0.36075955638722795F, -0.022689280275926284F, 0.0F);
  304. this.leftbackleg = new ModelRenderer(this, 0, 0);
  305. this.leftbackleg.setRotationPoint(-7.0F, 15.2F, 2.6F);
  306. this.leftbackleg.addBox(0.0F, 0.0F, 0.0F, 4, 5, 4, 0.0F);
  307. this.setRotateAngle(leftbackleg, -0.27314402793711257F, 0.0F, 0.0F);
  308. this.sideleft = new ModelRenderer(this, 69, 26);
  309. this.sideleft.setRotationPoint(-8.0F, 5.8F, -10.1F);
  310. this.sideleft.addBox(0.0F, 0.0F, 0.0F, 1, 8, 17, 0.0F);
  311. this.rightfrontleg = new ModelRenderer(this, 0, 0);
  312. this.rightfrontleg.setRotationPoint(4.0F, 15.2F, -10.0F);
  313. this.rightfrontleg.addBox(0.0F, 0.0F, 0.0F, 4, 5, 4, 0.0F);
  314. this.setRotateAngle(rightfrontleg, -0.27314402793711257F, 0.0F, 0.0F);
  315. this.mouth = new ModelRenderer(this, 0, 0);
  316. this.mouth.setRotationPoint(1.9F, 5.9F, -5.6F);
  317. this.mouth.addBox(-1.5F, 0.0F, -0.3F, 4, 2, 4, 0.0F);
  318. this.setRotateAngle(mouth, 0.5462880558742251F, 0.0F, 0.0F);
  319. this.sideback = new ModelRenderer(this, 100, 0);
  320. this.sideback.setRotationPoint(-5.9F, 6.0F, 7.3F);
  321. this.sideback.addBox(0.0F, 0.0F, 0.0F, 13, 8, 1, 0.0F);
  322. this.leftfrontleg = new ModelRenderer(this, 0, 0);
  323. this.leftfrontleg.setRotationPoint(-7.0F, 15.2F, -10.0F);
  324. this.leftfrontleg.addBox(0.0F, 0.0F, 0.0F, 4, 5, 4, 0.0F);
  325. this.setRotateAngle(leftfrontleg, -0.27314402793711257F, 0.0F, 0.0F);
  326. this.horn1 = new ModelRenderer(this, 0, 0);
  327. this.horn1.setRotationPoint(1.7F, 1.8F, -6.2F);
  328. this.horn1.addBox(0.0F, 0.0F, 0.0F, 1, 3, 1, 0.0F);
  329. this.horn3 = new ModelRenderer(this, 0, 0);
  330. this.horn3.setRotationPoint(1.8F, -1.4F, -1.1F);
  331. this.horn3.addBox(0.0F, 0.0F, 0.0F, 1, 3, 1, 0.0F);
  332. this.rightfrontfoot = new ModelRenderer(this, 0, 0);
  333. this.rightfrontfoot.setRotationPoint(0.0F, 5.0F, 0.0F);
  334. this.rightfrontfoot.addBox(0.0F, 0.0F, 0.0F, 4, 4, 4, 0.0F);
  335. this.setRotateAngle(rightfrontfoot, 0.27314402793711257F, 0.0F, 0.0F);
  336. this.chest = new ModelRenderer(this, 0, 0);
  337. this.chest.setRotationPoint(-2.2F, 1.1F, 3.0F);
  338. this.chest.addBox(0.0F, 0.0F, 0.0F, 5, 5, 5, 0.0F);
  339. this.horn5 = new ModelRenderer(this, 0, 0);
  340. this.horn5.setRotationPoint(0.0F, -1.3F, 4.8F);
  341. this.horn5.addBox(0.0F, 0.0F, 0.0F, 1, 2, 1, 0.0F);
  342. this.setRotateAngle(horn5, -0.36425021489121656F, 0.0F, 0.0F);
  343. this.horn4 = new ModelRenderer(this, 0, 0);
  344. this.horn4.setRotationPoint(0.5F, -1.3F, 2.7F);
  345. this.horn4.addBox(0.0F, 0.0F, 0.0F, 1, 2, 1, 0.0F);
  346. this.setRotateAngle(horn4, -0.36425021489121656F, 0.0F, 0.0F);
  347. this.shelltop = new ModelRenderer(this, 0, 34);
  348. this.shelltop.setRotationPoint(-1.6F, 11.6F, 9.0F);
  349. this.shelltop.addBox(-5.0F, -8.0F, -19.0F, 14, 2, 17, 0.0F);
  350. this.horn2 = new ModelRenderer(this, 0, 0);
  351. this.horn2.setRotationPoint(1.8F, -0.1F, -3.7F);
  352. this.horn2.addBox(0.0F, 0.0F, 0.0F, 1, 3, 1, 0.0F);
  353. this.undershell = new ModelRenderer(this, 0, 96);
  354. this.undershell.setRotationPoint(-8.4F, 13.6F, -12.3F);
  355. this.undershell.addBox(0.0F, 0.0F, 0.0F, 18, 2, 21, 0.0F);
  356. this.tail = new ModelRenderer(this, 28, 0);
  357. this.tail.setRotationPoint(0.0F, 15.0F, 7.3F);
  358. this.tail.addBox(0.0F, 0.0F, 0.0F, 2, 2, 6, 0.0F);
  359. this.setRotateAngle(tail, -0.22759093446006054F, 0.0F, 0.0F);
  360. this.leftfrontleg.addChild(this.leftfrontfoot);
  361. this.head.addChild(this.headtop);
  362. this.leftbackleg.addChild(this.leftbackfoot);
  363. this.head.addChild(this.snouth);
  364. this.rightbackleg.addChild(this.rightbackfoot);
  365. this.head.addChild(this.mouth);
  366. this.head.addChild(this.horn1);
  367. this.head.addChild(this.horn3);
  368. this.rightfrontleg.addChild(this.rightfrontfoot);
  369. this.tail.addChild(this.horn5);
  370. this.tail.addChild(this.horn4);
  371. this.head.addChild(this.horn2);
  372. }
  373.  
  374. @Override
  375. public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) {
  376. this.sidefront.render(f5);
  377. this.sideright.render(f5);
  378. this.rightbackleg.render(f5);
  379. this.tinybox.render(f5);
  380. this.tiny.render(f5);
  381. this.shellundertop.render(f5);
  382. this.crafting.render(f5);
  383. this.head.render(f5);
  384. this.leftbackleg.render(f5);
  385. this.sideleft.render(f5);
  386. this.rightfrontleg.render(f5);
  387. this.sideback.render(f5);
  388. this.leftfrontleg.render(f5);
  389. this.chest.render(f5);
  390. this.shelltop.render(f5);
  391. this.undershell.render(f5);
  392. this.tail.render(f5);
  393. }
  394.  
  395. /**
  396. * This is a helper function from Tabula to set the rotation of model
  397. * parts
  398. */
  399. public void setRotateAngle(ModelRenderer modelRenderer, float x, float y, float z) {
  400. modelRenderer.rotateAngleX = x;
  401. modelRenderer.rotateAngleY = y;
  402. modelRenderer.rotateAngleZ = z;
  403. }
  404.  
  405. public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity e)
  406.  
  407. {
  408. super.setRotationAngles(f, f1, f2, f3, f4, f5, e);
  409. this.head.rotateAngleY = f3 / (360F / (float) Math.PI) + -0.36075955638722795F;
  410. this.head.rotateAngleX = f4 / (360F / (float) Math.PI) + -0.36075955638722795F;
  411. this.leftfrontleg.rotateAngleX = MathHelper.cos(f * 1.0F) * -1.0F * f1 + -0.27314402793711257F;
  412. this.rightfrontleg.rotateAngleX = MathHelper.cos(f * 1.0F) * 1.0F * f1 + -0.27314402793711257F;
  413. this.leftbackleg.rotateAngleX = MathHelper.cos(f * 1.0F) * -1.0F * f1 + -0.27314402793711257F;
  414. this.rightbackleg.rotateAngleX = MathHelper.cos(f * 1.0F) * 1.0F * f1 + -0.27314402793711257F;
  415.  
  416. }
  417. }
  418.  
  419. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement