2018-09-21 09:15:03 +00:00
|
|
|
/*
|
|
|
|
* Minecraft Forge
|
|
|
|
* Copyright (c) 2016-2018.
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation version 2.1
|
|
|
|
* of the License.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
2018-09-09 21:27:15 +00:00
|
|
|
package net.minecraftforge.common.extensions;
|
|
|
|
|
|
|
|
import net.minecraft.nbt.NBTTagCompound;
|
|
|
|
import net.minecraft.tileentity.TileEntity;
|
|
|
|
import net.minecraftforge.common.capabilities.ICapabilitySerializable;
|
|
|
|
|
|
|
|
public interface IForgeTileEntity extends ICapabilitySerializable<NBTTagCompound>
|
|
|
|
{
|
|
|
|
default TileEntity getTileEntity() { return (TileEntity) this; }
|
2018-11-29 06:15:05 +00:00
|
|
|
|
2018-09-09 21:27:15 +00:00
|
|
|
@Override
|
|
|
|
default void deserializeNBT(NBTTagCompound nbt)
|
|
|
|
{
|
2018-09-22 10:40:22 +00:00
|
|
|
getTileEntity().read(nbt);
|
2018-09-09 21:27:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
default NBTTagCompound serializeNBT()
|
|
|
|
{
|
|
|
|
NBTTagCompound ret = new NBTTagCompound();
|
2018-09-22 10:40:22 +00:00
|
|
|
getTileEntity().write(ret);
|
2018-09-09 21:27:15 +00:00
|
|
|
return ret;
|
|
|
|
}
|
2018-11-29 06:15:05 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when you receive a TileEntityData packet for the location this
|
|
|
|
* TileEntity is currently in. On the client, the NetworkManager will always
|
|
|
|
* be the remote server. On the server, it will be whomever is responsible for
|
|
|
|
* sending the packet.
|
|
|
|
*
|
|
|
|
* @param net The NetworkManager the packet originated from
|
|
|
|
* @param pkt The data packet
|
|
|
|
*/
|
|
|
|
default void onDataPacket(net.minecraft.network.NetworkManager net, net.minecraft.network.play.server.SPacketUpdateTileEntity pkt){ }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when the chunk's TE update tag, gotten from {@link #getUpdateTag()}, is received on the client.
|
|
|
|
* <p>
|
|
|
|
* Used to handle this tag in a special way. By default this simply calls {@link #readFromNBT(NBTTagCompound)}.
|
|
|
|
*
|
|
|
|
* @param tag The {@link NBTTagCompound} sent from {@link #getUpdateTag()}
|
|
|
|
*/
|
|
|
|
default void handleUpdateTag(NBTTagCompound tag)
|
|
|
|
{
|
|
|
|
getTileEntity().read(tag);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets a {@link NBTTagCompound} that can be used to store custom data for this tile entity.
|
|
|
|
* It will be written, and read from disc, so it persists over world saves.
|
|
|
|
*
|
|
|
|
* @return A compound tag for custom data
|
|
|
|
*/
|
|
|
|
NBTTagCompound getTileData();
|
2018-12-13 09:15:53 +00:00
|
|
|
|
|
|
|
default void onChunkUnloaded(){}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when this is first added to the world (by {@link World#addTileEntity(TileEntity)}).
|
|
|
|
* Override instead of adding {@code if (firstTick)} stuff in update.
|
|
|
|
*/
|
|
|
|
default void onLoad(){}
|
2018-09-09 21:27:15 +00:00
|
|
|
}
|