Package com.pahimar.ee3.tileentity

Source Code of com.pahimar.ee3.tileentity.TileEntityDummyArray

package com.pahimar.ee3.tileentity;

import com.pahimar.ee3.network.PacketHandler;
import com.pahimar.ee3.network.message.MessageTileEntityDummy;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.Packet;

public class TileEntityDummyArray extends TileEntityEE
{
    private int trueXCoord, trueYCoord, trueZCoord;
    private int ticksSinceSync;

    public TileEntityDummyArray()
    {
        super();
    }

    public int getTrueXCoord()
    {
        return trueXCoord;
    }

    public int getTrueYCoord()
    {
        return trueYCoord;
    }

    public int getTrueZCoord()
    {
        return trueZCoord;
    }

    public void setTrueCoords(int trueXCoord, int trueYCoord, int trueZCoord)
    {
        this.trueXCoord = trueXCoord;
        this.trueYCoord = trueYCoord;
        this.trueZCoord = trueZCoord;
    }

    @Override
    public void updateEntity()
    {
        super.updateEntity();

        if (++ticksSinceSync % 10 == 0)
        {
            if (!worldObj.isRemote && !(worldObj.getTileEntity(trueXCoord, trueYCoord, trueZCoord) instanceof TileEntityEE))
            {
                this.invalidate();
                worldObj.setBlockToAir(xCoord, yCoord, zCoord);
            }
        }
    }

    @Override
    public Packet getDescriptionPacket()
    {
        return PacketHandler.INSTANCE.getPacketFrom(new MessageTileEntityDummy(this));
    }

    @Override
    public void readFromNBT(NBTTagCompound nbtTagCompound)
    {
        super.readFromNBT(nbtTagCompound);

        this.trueXCoord = nbtTagCompound.getInteger("trueXCoord");
        this.trueYCoord = nbtTagCompound.getInteger("trueYCoord");
        this.trueZCoord = nbtTagCompound.getInteger("trueZCoord");
    }

    @Override
    public void writeToNBT(NBTTagCompound nbtTagCompound)
    {
        super.writeToNBT(nbtTagCompound);

        nbtTagCompound.setInteger("trueXCoord", trueXCoord);
        nbtTagCompound.setInteger("trueYCoord", trueYCoord);
        nbtTagCompound.setInteger("trueZCoord", trueZCoord);
    }
}
TOP

Related Classes of com.pahimar.ee3.tileentity.TileEntityDummyArray

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.