hassansyyid

TE

Jun 23rd, 2015
287
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.    
  19.     public void setDirection(byte direction)
  20.     {
  21.         this.rotation = direction;
  22.     }
  23.  
  24.     @Override
  25.     public Packet getDescriptionPacket()
  26.     {
  27.         NBTTagCompound nbtTag = new NBTTagCompound();
  28.         this.writeToNBT(nbtTag);
  29.         return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, nbtTag);
  30.     }
  31.  
  32.     @Override
  33.     public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet)
  34.     {
  35.         readFromNBT(packet.func_148857_g());
  36.     }
  37.  
  38.     @Override
  39.     public void writeToNBT(NBTTagCompound nbt)
  40.     {
  41.         super.writeToNBT(nbt);
  42.         nbt.setInteger("Rotation", this.rotation);
  43.     }
  44.  
  45.     @Override
  46.     public void readFromNBT(NBTTagCompound nbt)
  47.     {
  48.         super.readFromNBT(nbt);
  49.         this.rotation = nbt.getInteger("Rotation");
  50.     }
  51.  
  52.     @Override
  53.     public void outputPower()
  54.     {
  55.         super.outputPower();
  56.     }
  57.  
  58.     @Override
  59.     public void outputPowerToTile(PoweredTileEntity tile, double voltage)
  60.     {
  61.         if (tile != null)
  62.         {
  63.             double previousVoltage = tile.getVoltage();
  64.             tile.setVoltage(voltage + previousVoltage);
  65.         }
  66.     }
  67.  
  68.     @Override
  69.     public boolean canOutputPower()
  70.     {
  71.         return true;
  72.     }
  73.  
  74.     @Override
  75.     public double getVoltage(){
  76.         addedVoltage = 24;
  77.  
  78.         if (getTop() instanceof TileEntityPowerline)
  79.         {
  80.             if(getTop().voltage > 0){
  81.                 return addedVoltage;
  82.             }
  83.         }
  84.        
  85.         if (getBottom() instanceof TileEntityPowerline)
  86.         {
  87.             if(getBottom().voltage > 0){
  88.                 return addedVoltage;
  89.             }
  90.         }
  91.        
  92.         if (getLeft() instanceof TileEntityPowerline)
  93.         {
  94.             if(getLeft().voltage > 0){
  95.                 return addedVoltage;
  96.             }
  97.         }
  98.        
  99.         if (getRight() instanceof TileEntityPowerline)
  100.         {
  101.             if(getRight().voltage > 0){
  102.                 return addedVoltage;
  103.             }
  104.         }
  105.        
  106.         if (getFront() instanceof TileEntityPowerline)
  107.         {
  108.                 if(getFront().voltage > 0 ){
  109.                     return addedVoltage;
  110.                 }
  111.         }
  112.        
  113.         if (getBack() instanceof TileEntityPowerline){
  114.             if(getBack().voltage > 0 ){
  115.                 return addedVoltage;
  116.             }
  117.         }      
  118.         return 0;
  119.     }
  120.  
  121.  
  122.     @Override
  123.     public void onVoltageTick()
  124.     {
  125.         ;
  126.     }
  127.  
  128.     @Override
  129.     public void onOverloadTick()
  130.     {
  131.         ;
  132.     }
  133.  
  134.     @Override
  135.     public void onUnderloadTick()
  136.     {
  137.         ;
  138.     }
  139.  
  140.     @Override
  141.     public double getMaxOperatingVoltage()
  142.     {
  143.         return 24000;
  144.     }
  145.  
  146.     @Override
  147.     public boolean isOriginalPowerSourceAttached() {
  148.         // TODO Auto-generated method stub
  149.         return false;
  150.     }
  151.  
  152.     @Override
  153.     public void getOriginalPowerSource() {
  154.         // TODO Auto-generated method stub
  155.        
  156.     }
  157.  
  158.     @Override
  159.     public TileEntityRepulsionGenerator getPowerSource() {
  160.         // TODO Auto-generated method stub
  161.         return null;
  162.     }
  163.  
  164.     @Override
  165.     public void setOriginalPowerSource(TileEntityRepulsionGenerator e) {
  166.         // TODO Auto-generated method stub
  167.        
  168.     }
  169.  
  170.     public void onRightClick(EntityPlayer player, World world, int x, int y, int z)
  171.     {
  172.         if(addedVoltage > 0){
  173.             addedVoltage = -24;
  174.         }
  175.         else{
  176.             addedVoltage = 24;
  177.         }
  178.     }
  179. }
Advertisement
Add Comment
Please, Sign In to add comment