Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.crilleslo.tileentity;
- import com.crilleslo.testcraft.TestCraft;
- import net.minecraft.nbt.NBTTagCompound;
- import net.minecraft.network.Packet;
- import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
- import net.minecraft.tileentity.TileEntity;
- public class TileEntityWindmill extends TileEntity {
- private float rotation = 0F, rotationSpeed = 0F, energy = 0F, maxEnergy = 3000F;
- int direction = 0;
- public TileEntityWindmill() {
- System.out.println(direction);
- }
- public float getRotation() {
- return rotation;
- }
- public void writeToNBT(NBTTagCompound nbt) {
- nbt.setFloat("energyStored", this.energy);
- super.writeToNBT(nbt);
- }
- public void readFromNBT(NBTTagCompound nbt) {
- this.energy = nbt.getFloat("energyStored");
- super.readFromNBT(nbt);
- }
- public Packet getDescriptionPacket() {
- NBTTagCompound nbt = new NBTTagCompound();
- writeToNBT(nbt);
- return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, nbt);
- }
- public void updateEntity() {
- if(worldObj.isRemote) {
- System.out.println(energy);
- if(worldObj.canBlockSeeTheSky(xCoord, yCoord, zCoord)) {
- float speed = yCoord*0.1F;
- if(energy+speed < maxEnergy) {
- energy+=speed;
- if(rotationSpeed < speed) {
- rotationSpeed+=(TestCraft.rand.nextFloat()*TestCraft.rand.nextFloat());
- }
- } else {
- if(rotationSpeed > 0) {
- rotationSpeed-=(TestCraft.rand.nextFloat()*TestCraft.rand.nextFloat());
- }
- if(rotationSpeed < 0) {
- rotationSpeed = 0;
- }
- }
- rotation+=rotationSpeed;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment