mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-20 12:09:39 +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,58 @@
|
||||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.multiblock;
|
||||
|
||||
import forestry.api.apiculture.IBeeListener;
|
||||
import forestry.api.apiculture.IBeeModifier;
|
||||
import forestry.api.core.IClimateControlled;
|
||||
|
||||
/**
|
||||
* Needs to be implemented by TileEntities that want to be part of an alveary.
|
||||
* The sub-interfaces can be implemented to alter the operation of the alveary.
|
||||
* They are automatically detected and handled by the alveary when they join its structure.
|
||||
*/
|
||||
public interface IAlvearyComponent<T extends IMultiblockLogicAlveary> extends IMultiblockComponent {
|
||||
/**
|
||||
* @return the multiblock logic for this component
|
||||
*/
|
||||
@Override
|
||||
T getMultiblockLogic();
|
||||
|
||||
/**
|
||||
* Implemented by alveary parts to apply a beeListener to the completed structure.
|
||||
*/
|
||||
interface BeeListener extends IAlvearyComponent {
|
||||
IBeeListener getBeeListener();
|
||||
}
|
||||
|
||||
/**
|
||||
* Implemented by alveary parts to apply a beeModifier to the completed structure.
|
||||
*/
|
||||
interface BeeModifier extends IAlvearyComponent {
|
||||
IBeeModifier getBeeModifier();
|
||||
}
|
||||
|
||||
/**
|
||||
* Implemented by alveary parts to apply a climate change to the completed structure.
|
||||
*/
|
||||
interface Climatiser extends IAlvearyComponent {
|
||||
/**
|
||||
* Called every tick by the alveary.
|
||||
* @param tickCount the number of ticks in the world
|
||||
* @param alveary the climate controlled alveary
|
||||
*/
|
||||
void changeClimate(int tickCount, IClimateControlled alveary);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implemented by alveary parts to receive ticks from the completed structure.
|
||||
*/
|
||||
interface Active extends IAlvearyComponent {
|
||||
void updateServer(int tickCount);
|
||||
void updateClient(int tickCount);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.multiblock;
|
||||
|
||||
import forestry.api.apiculture.IBeeHousing;
|
||||
|
||||
/**
|
||||
* The IAlvearyController provides access to all the IMultiblockController and IBeeHousing methods
|
||||
* necessary for an IAlvearyComponent to function.
|
||||
*/
|
||||
public interface IAlvearyController extends IMultiblockController, IBeeHousing {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.multiblock;
|
||||
|
||||
import forestry.api.farming.IFarmListener;
|
||||
|
||||
/**
|
||||
* Needs to be implemented by TileEntities that want to be part of a farm.
|
||||
* The sub-interfaces can be implemented to alter the operation of the farm.
|
||||
* They are automatically detected and handled by the farm when they join its structure.
|
||||
*/
|
||||
public interface IFarmComponent<T extends IMultiblockLogicFarm> extends IMultiblockComponent {
|
||||
|
||||
/**
|
||||
* @return the multiblock logic for this component
|
||||
*/
|
||||
@Override
|
||||
T getMultiblockLogic();
|
||||
|
||||
/**
|
||||
* Implemented by farm parts to apply a farmListener to the completed structure.
|
||||
*/
|
||||
interface Listener extends IFarmComponent {
|
||||
IFarmListener getFarmListener();
|
||||
}
|
||||
|
||||
/**
|
||||
* Implemented by farm parts to receive ticks from the completed structure.
|
||||
*/
|
||||
interface Active extends IFarmComponent {
|
||||
void updateServer(int tickCount);
|
||||
void updateClient(int tickCount);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.multiblock;
|
||||
|
||||
import forestry.api.farming.IFarmHousing;
|
||||
|
||||
/**
|
||||
* The IFarmController provides access to all the IMultiblockController and IFarmHousing methods
|
||||
* necessary for an IFarmComponent to function.
|
||||
*/
|
||||
public interface IFarmController extends IMultiblockController, IFarmHousing {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.multiblock;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import net.minecraft.util.BlockPos;
|
||||
|
||||
/**
|
||||
* Basic interface for a multiblock machine component.
|
||||
* Implemented by TileEntities.
|
||||
*/
|
||||
public interface IMultiblockComponent {
|
||||
|
||||
/**
|
||||
* Returns the location of this tile entity in the world.
|
||||
* @return ChunkCoordinates set to the location of this tile entity in the world.
|
||||
*/
|
||||
BlockPos getCoordinates();
|
||||
|
||||
/**
|
||||
* @return the gameProfile of the player who owns this single component (not the entire multiblock)
|
||||
*/
|
||||
GameProfile getOwner();
|
||||
|
||||
/**
|
||||
* @return the multiblock logic for this part
|
||||
*/
|
||||
IMultiblockLogic getMultiblockLogic();
|
||||
|
||||
/**
|
||||
* Called when a machine is fully assembled from the disassembled state, meaning
|
||||
* it was constructed by a player/entity action, not by chunks loading.
|
||||
* Note that, for non-square machines, the min/max coordinates may not actually be part
|
||||
* of the machine! They form an outer bounding box for the whole machine itself.
|
||||
* @param multiblockController The controller to which this part is being assembled.
|
||||
*/
|
||||
void onMachineAssembled(IMultiblockController multiblockController, BlockPos minCoord, BlockPos maxCoord);
|
||||
|
||||
/**
|
||||
* Called when the machine is broken for game reasons, e.g. a player removed a block
|
||||
* or an explosion occurred.
|
||||
*/
|
||||
void onMachineBroken();
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.multiblock;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* IMultiblockController is used to handle the assembly of Multiblocks.
|
||||
* This class is created and updated by IMultiblockLogic and Forestry.
|
||||
* This is a minimal interface to hide the ugly details from the multiblock tile entities.
|
||||
*/
|
||||
public interface IMultiblockController {
|
||||
/**
|
||||
* @return True if this multiblock machine is considered assembled and ready to go.
|
||||
*/
|
||||
boolean isAssembled();
|
||||
|
||||
/**
|
||||
* Call to force the controller to check the multiblock's validity.
|
||||
* Use when important conditions around the multiblock change
|
||||
* (i.e. Alveary slabs are removed and the alveary block detects it's neighbor changed)
|
||||
* Changes to multiblock components are handled automatically and should not call this.
|
||||
*/
|
||||
void reassemble();
|
||||
|
||||
/**
|
||||
* @return A string representing the last error encountered when trying to assemble this
|
||||
* multiblock, or null if there is no error.
|
||||
*/
|
||||
String getLastValidationError();
|
||||
|
||||
/**
|
||||
* @return all the multiblock components attached to this controller
|
||||
*/
|
||||
@Nonnull
|
||||
Collection<IMultiblockComponent> getComponents();
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
/*******************************************************************************
|
||||
* 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.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.api.core.INBTTagable;
|
||||
|
||||
/**
|
||||
* Multiblock Logic implements the basic logic for IMultiblockComponent tile entities.
|
||||
* Instances must come from MultiblockManager.logicFactory, most of the implementation is hidden.
|
||||
*
|
||||
* IMultiblockComponent tile entities must wire up the methods in the "Updating and Synchronization" section.
|
||||
* As a starting point, you can use MultiblockTileEntityBase.
|
||||
*/
|
||||
public interface IMultiblockLogic extends INBTTagable {
|
||||
|
||||
/**
|
||||
* @return True if this block is connected to a multiblock controller. False otherwise.
|
||||
*/
|
||||
boolean isConnected();
|
||||
|
||||
/**
|
||||
* @return the multiblock controller for this logic
|
||||
*/
|
||||
IMultiblockController getController();
|
||||
|
||||
/* Updating and Synchronization */
|
||||
|
||||
/**
|
||||
* call on Tile.validate()
|
||||
**/
|
||||
void validate(World world, IMultiblockComponent part);
|
||||
|
||||
/**
|
||||
* call on Tile.invalidate()
|
||||
**/
|
||||
void invalidate(World world, IMultiblockComponent part);
|
||||
|
||||
/**
|
||||
* call on Tile.onChunkUnload()
|
||||
**/
|
||||
void onChunkUnload(World world, IMultiblockComponent part);
|
||||
|
||||
/**
|
||||
* Writes data for client synchronization.
|
||||
* Use this in Tile.getDescriptionPacket()
|
||||
*/
|
||||
void encodeDescriptionPacket(NBTTagCompound packetData);
|
||||
|
||||
/**
|
||||
* Reads data for client synchronization.
|
||||
* Use this in Tile.onDataPacket()
|
||||
*/
|
||||
void decodeDescriptionPacket(NBTTagCompound packetData);
|
||||
|
||||
/**
|
||||
* Read the logic's data from file.
|
||||
* Use this in Tile.readFromNBT()
|
||||
*/
|
||||
@Override
|
||||
void readFromNBT(NBTTagCompound nbttagcompound);
|
||||
|
||||
/**
|
||||
* Write the logic's data to file.
|
||||
* Use this in Tile.writeToNBT()
|
||||
*/
|
||||
@Override
|
||||
void writeToNBT(NBTTagCompound nbttagcompound);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.multiblock;
|
||||
|
||||
public interface IMultiblockLogicAlveary extends IMultiblockLogic {
|
||||
/**
|
||||
* @return the multiblock controller for this logic
|
||||
*/
|
||||
@Override
|
||||
IAlvearyController getController();
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.multiblock;
|
||||
|
||||
/**
|
||||
* Creates new instances of IMultiblockLogic.
|
||||
* Each IMultiblockComponent needs its own instance of IMultiblockLogic.
|
||||
*/
|
||||
public interface IMultiblockLogicFactory {
|
||||
IMultiblockLogicAlveary createAlvearyLogic();
|
||||
|
||||
IMultiblockLogicFarm createFarmLogic();
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.multiblock;
|
||||
|
||||
public interface IMultiblockLogicFarm extends IMultiblockLogic {
|
||||
/**
|
||||
* @return the multiblock controller for this logic
|
||||
*/
|
||||
@Override
|
||||
IFarmController getController();
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.multiblock;
|
||||
|
||||
public class MultiblockManager {
|
||||
public static IMultiblockLogicFactory logicFactory;
|
||||
}
|
||||
@@ -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) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
@API(apiVersion = "3.0.0", owner = "ForestryAPI|core", provides = "ForestryAPI|multiblock")
|
||||
package forestry.api.multiblock;
|
||||
|
||||
import net.minecraftforge.fml.common.API;
|
||||
Reference in new issue
Block a user