mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-16 01:54:40 +00:00
Get things compiling.
Move ForestryAPI into the Forestry project instead of as a submodule Include the new RF API Remove code for mods that have not yet ported to 1.8.9 (add it back later) Bump version to 5.0.0
This commit is contained in:
1 parent
73812d8765
commit
8da0c0dc95
325 files changed
+9600
-4026
No files matched your search
@@ -0,0 +1,111 @@
|
||||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.multiblock;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
* Base logic class for Multiblock-connected tile entities.
|
||||
* Most multiblock components should derive from this.
|
||||
* Supply it an IMultiblockLogic from MultiblockManager.logicFactory
|
||||
*/
|
||||
public abstract class MultiblockTileEntityBase<T extends IMultiblockLogic> extends TileEntity implements IMultiblockComponent {
|
||||
private final T multiblockLogic;
|
||||
|
||||
public MultiblockTileEntityBase(T multiblockLogic) {
|
||||
this.multiblockLogic = multiblockLogic;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockPos getCoordinates() {
|
||||
return getPos();
|
||||
}
|
||||
|
||||
@Override
|
||||
public T getMultiblockLogic() {
|
||||
return multiblockLogic;
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract void onMachineAssembled(IMultiblockController multiblockController, BlockPos minCoord, BlockPos maxCoord);
|
||||
|
||||
@Override
|
||||
public abstract void onMachineBroken();
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound data) {
|
||||
super.readFromNBT(data);
|
||||
multiblockLogic.readFromNBT(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound data) {
|
||||
super.writeToNBT(data);
|
||||
multiblockLogic.writeToNBT(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void invalidate() {
|
||||
super.invalidate();
|
||||
multiblockLogic.invalidate(worldObj, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void onChunkUnload() {
|
||||
super.onChunkUnload();
|
||||
multiblockLogic.onChunkUnload(worldObj, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void validate() {
|
||||
super.validate();
|
||||
multiblockLogic.validate(worldObj, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRefresh(World world, BlockPos pos, IBlockState oldState, IBlockState newSate)
|
||||
{
|
||||
return oldState.getBlock() != newSate.getBlock();
|
||||
}
|
||||
|
||||
/* Network Communication */
|
||||
|
||||
@Override
|
||||
public final Packet getDescriptionPacket() {
|
||||
NBTTagCompound packetData = new NBTTagCompound();
|
||||
multiblockLogic.encodeDescriptionPacket(packetData);
|
||||
this.encodeDescriptionPacket(packetData);
|
||||
return new S35PacketUpdateTileEntity(getPos(), 0, packetData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void onDataPacket(NetworkManager network, S35PacketUpdateTileEntity packet) {
|
||||
NBTTagCompound nbtData = packet.getNbtCompound();
|
||||
multiblockLogic.decodeDescriptionPacket(nbtData);
|
||||
this.decodeDescriptionPacket(nbtData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to write tileEntity-specific data to the descriptionPacket
|
||||
*/
|
||||
protected void encodeDescriptionPacket(NBTTagCompound packetData) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to read tileEntity-specific data from the descriptionPacket (onDataPacket)
|
||||
*/
|
||||
protected void decodeDescriptionPacket(NBTTagCompound packetData) {
|
||||
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user