Guest User

Untitled

a guest
Sep 26th, 2014
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. package com.crilleslo.tileentity;
  2.  
  3. import com.crilleslo.testcraft.TestCraft;
  4.  
  5. import net.minecraft.nbt.NBTTagCompound;
  6. import net.minecraft.network.Packet;
  7. import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
  8. import net.minecraft.tileentity.TileEntity;
  9.  
  10. public class TileEntityWindmill extends TileEntity {
  11.  
  12. private float rotation = 0F, rotationSpeed = 0F, energy = 0F, maxEnergy = 3000F;
  13. int direction = 0;
  14.  
  15. public TileEntityWindmill() {
  16. System.out.println(direction);
  17. }
  18.  
  19. public float getRotation() {
  20. return rotation;
  21. }
  22.  
  23. public void writeToNBT(NBTTagCompound nbt) {
  24. nbt.setFloat("energyStored", this.energy);
  25. super.writeToNBT(nbt);
  26. }
  27.  
  28. public void readFromNBT(NBTTagCompound nbt) {
  29. this.energy = nbt.getFloat("energyStored");
  30. super.readFromNBT(nbt);
  31. }
  32.  
  33. public Packet getDescriptionPacket() {
  34. NBTTagCompound nbt = new NBTTagCompound();
  35. writeToNBT(nbt);
  36. return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, nbt);
  37. }
  38.  
  39. public void updateEntity() {
  40. if(worldObj.isRemote) {
  41. System.out.println(energy);
  42. if(worldObj.canBlockSeeTheSky(xCoord, yCoord, zCoord)) {
  43. float speed = yCoord*0.1F;
  44. if(energy+speed < maxEnergy) {
  45. energy+=speed;
  46. if(rotationSpeed < speed) {
  47. rotationSpeed+=(TestCraft.rand.nextFloat()*TestCraft.rand.nextFloat());
  48. }
  49. } else {
  50. if(rotationSpeed > 0) {
  51. rotationSpeed-=(TestCraft.rand.nextFloat()*TestCraft.rand.nextFloat());
  52. }
  53. if(rotationSpeed < 0) {
  54. rotationSpeed = 0;
  55. }
  56. }
  57. rotation+=rotationSpeed;
  58. }
  59. }
  60. }
  61.  
  62. }
Advertisement
Add Comment
Please, Sign In to add comment