hassansyyid

TETransformer

Jun 23rd, 2015
365
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.34 KB | None | 0 0
  1. package com.arisux.avp.entities.tile;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.List;
  5.  
  6. import net.minecraft.entity.player.EntityPlayer;
  7. import net.minecraft.nbt.NBTTagCompound;
  8. import net.minecraft.network.NetworkManager;
  9. import net.minecraft.network.Packet;
  10. import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
  11. import net.minecraft.tileentity.TileEntity;
  12. import net.minecraft.world.World;
  13.  
  14. public class TileEntityTransformer extends PoweredTileEntity
  15. {
  16.     public int rotation;
  17.     public double addedVoltage;
  18.     public double currentVoltage;
  19.    
  20.     public void setDirection(byte direction)
  21.     {
  22.         this.rotation = direction;
  23.     }
  24.    
  25.     @Override
  26.     public Packet getDescriptionPacket()
  27.     {
  28.         NBTTagCompound nbtTag = new NBTTagCompound();
  29.         this.writeToNBT(nbtTag);
  30.         return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, nbtTag);
  31.     }
  32.  
  33.     @Override
  34.     public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet)
  35.     {
  36.         this.readFromNBT(packet.func_148857_g());
  37.     }
  38.    
  39.     @Override
  40.     public void writeToNBT(NBTTagCompound tag)
  41.     {
  42.         super.writeToNBT(tag);
  43.  
  44.         tag.setDouble("Volts", this.voltage);
  45.         tag.setDouble("Amps", this.amps);
  46.     }
  47.  
  48.     @Override
  49.     public void readFromNBT(NBTTagCompound tag)
  50.     {
  51.         super.readFromNBT(tag);
  52.  
  53.         this.voltage = tag.getDouble("Volts");
  54.         this.amps = tag.getDouble("Amps");
  55.     }
  56.  
  57.     @Override
  58.     public void outputPower()
  59.     {
  60.         super.outputPower();
  61.     }
  62.  
  63.     @Override
  64.     public void outputPowerToTile(PoweredTileEntity tile, double voltage)
  65.     {
  66.         if (tile != null && tile instanceof TileEntityPowerline)
  67.         {
  68.             double previousVoltage = tile.getVoltage();
  69.             tile.setVoltage(voltage + previousVoltage);
  70.             currentVoltage = previousVoltage + voltage;
  71.         }
  72.     }
  73.  
  74.     @Override
  75.     public boolean canOutputPower()
  76.     {
  77.         return true;
  78.     }
  79.  
  80.     @Override
  81.     public double getVoltage(){
  82.         addedVoltage = 24;
  83.  
  84.         if (getTop() instanceof TileEntityPowerline)
  85.         {
  86.             if(getTop().voltage > 0){
  87.                 return addedVoltage;
  88.             }
  89.         }
  90.        
  91.         if (getBottom() instanceof TileEntityPowerline)
  92.         {
  93.             if(getBottom().voltage > 0){
  94.                 return addedVoltage;
  95.             }
  96.         }
  97.        
  98.         if (getLeft() instanceof TileEntityPowerline)
  99.         {
  100.             if(getLeft().voltage > 0){
  101.                 return addedVoltage;
  102.             }
  103.         }
  104.        
  105.         if (getRight() instanceof TileEntityPowerline)
  106.         {
  107.             if(getRight().voltage > 0){
  108.                 return addedVoltage;
  109.             }
  110.         }
  111.        
  112.         if (getFront() instanceof TileEntityPowerline)
  113.         {
  114.                 if(getFront().voltage > 0 ){
  115.                     return addedVoltage;
  116.                 }
  117.         }
  118.        
  119.         if (getBack() instanceof TileEntityPowerline){
  120.             if(getBack().voltage > 0 ){
  121.                 return addedVoltage;
  122.             }
  123.         }      
  124.         return 0;
  125.     }
  126.  
  127.  
  128.     @Override
  129.     public void onVoltageTick()
  130.     {
  131.         ;
  132.     }
  133.  
  134.     @Override
  135.     public void onOverloadTick()
  136.     {
  137.         ;
  138.     }
  139.  
  140.     @Override
  141.     public void onUnderloadTick()
  142.     {
  143.         ;
  144.     }
  145.  
  146.     @Override
  147.     public double getMaxOperatingVoltage()
  148.     {
  149.         return 24000;
  150.     }
  151.  
  152.     @Override
  153.     public boolean isOriginalPowerSourceAttached() {
  154.         // TODO Auto-generated method stub
  155.         return false;
  156.     }
  157.  
  158.     @Override
  159.     public void getOriginalPowerSource() {
  160.         // TODO Auto-generated method stub
  161.        
  162.     }
  163.  
  164.     @Override
  165.     public TileEntityRepulsionGenerator getPowerSource() {
  166.         // TODO Auto-generated method stub
  167.         return null;
  168.     }
  169.  
  170.     @Override
  171.     public void setOriginalPowerSource(PoweredTileEntity e) {
  172.         // TODO Auto-generated method stub
  173.        
  174.     }
  175. }
Advertisement
Add Comment
Please, Sign In to add comment