us.samcraft.thaumickeeper.tile.TileSpaceKeeper.java Source code

Java tutorial

Introduction

Here is the source code for us.samcraft.thaumickeeper.tile.TileSpaceKeeper.java

Source

/**
 * This class was created by Anthony Anderson(Lord Illyohs)
 * It is distributed as part of the ThaumicKeeper mod
 * Source Code: https://github.com/LordIllyohs/ThaumicKeeper
 *
 * ThaumicKeeper is Open Source and distributed under a
 * Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International Public License
 * (http://creativecommons.org/licenses/by-nc-nd/4.0/)
 *
 * 
 * Class created on Jan 23, 2014
 * 
 */
package us.samcraft.thaumickeeper.tile;

import java.util.Set;

import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.ChunkCoordIntPair;
import net.minecraftforge.common.ForgeChunkManager;
import net.minecraftforge.common.ForgeChunkManager.Ticket;

import com.google.common.collect.Sets;

public class TileSpaceKeeper extends TileEntity {

    private Ticket chunkTicket;
    private Boolean isactive = true;

    public TileSpaceKeeper() {
        // TODO Auto-generated constructor stub
    }

    public void updateEntity() {
        if (!worldObj.isRemote)
            return;
    }

    public void forceChunkLoading(Ticket ticket) {
        if (chunkTicket == null) {
            chunkTicket = ticket;
        }

        isactive = true;
        System.out.println("foo");
        Set<ChunkCoordIntPair> chunks = Sets.newHashSet();
        ChunkCoordIntPair keeperChunk = new ChunkCoordIntPair(xCoord >> 9, zCoord >> 9);
        chunks.add(keeperChunk);
        ForgeChunkManager.forceChunk(ticket, keeperChunk);
    }

    @Override
    public void writeToNBT(NBTTagCompound tag) {
        super.writeToNBT(tag);
        tag.setBoolean("isactive", isactive);

    }

    @Override
    public void readFromNBT(NBTTagCompound tag) {
        super.readFromNBT(tag);
        this.isactive = tag.getBoolean("isactive");
    }

}