Move Greenhouse classes out of the api

This commit is contained in:
Nedelosk committed 2017-08-14 20:57:34 +02:00
1 parent 8bb1b74b1c
commit 38189388f6
96 files changed
+537 -429

No files matched your search

@@ -1,24 +0,0 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.climate;
import net.minecraft.nbt.NBTTagCompound;
public class BlankClimateModifier implements IClimateModifier {
@Override
public IClimateState modifyTarget(IClimateContainer container, IClimateState newState, ImmutableClimateState oldState, NBTTagCompound data) {
return newState;
}
@Override
public void addData(IClimateContainer container, IClimateState climateState, NBTTagCompound nbtData, IClimateData data) {
}
@Override
public int getPriority() {
return 0;
}
}
@@ -1,114 +0,0 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.climate;
import com.google.common.base.MoreObjects;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.math.MathHelper;
import forestry.api.core.INbtReadable;
/**
* A {@link IClimateState} that has a range from 0.0F to 2.0F and can be positiv an negativ.
*
*
* It is mainly used by {@link IClimateSource} to change the {@link IClimateState} of the {@link IClimateContainer}.
*/
public class ClimateChange implements IClimateState, INbtReadable{
private static final String TEMPERATURE_NBT_KEY = "TEMP";
private static final String HUMIDITY_NBT_KEY = "HUMID";
public static final ClimateChange ORIGIN = new ClimateChange(0.0F, 0.0F);
public float temperature;
public float humidity;
public ClimateChange(float temperature, float humidity) {
addTemperature(temperature);
addHumidity(humidity);
}
public ClimateChange(NBTTagCompound compound) {
readFromNBT(compound);
}
@Override
public NBTTagCompound writeToNBT(NBTTagCompound compound) {
compound.setFloat(TEMPERATURE_NBT_KEY, temperature);
compound.setFloat(HUMIDITY_NBT_KEY, humidity);
return compound;
}
@Override
public void readFromNBT(NBTTagCompound compound) {
this.temperature = compound.getFloat(TEMPERATURE_NBT_KEY);
this.humidity = compound.getFloat(HUMIDITY_NBT_KEY);
}
@Override
public float getTemperature() {
return temperature;
}
@Override
public float getHumidity() {
return humidity;
}
public void setTemperature(float temperature) {
this.temperature = 0;
addTemperature(temperature);
}
public void setHumidity(float humidity) {
this.humidity = 0;
addHumidity(humidity);
}
@Override
public ClimateChange add(IClimateState state){
addTemperature(state.getTemperature());
addHumidity(state.getHumidity());
return this;
}
@Override
public ClimateChange remove(IClimateState state){
addTemperature(-state.getTemperature());
addHumidity(-state.getHumidity());
return this;
}
@Override
public ClimateChange addTemperature(float temperature){
this.temperature = MathHelper.clamp(this.temperature + temperature, -2.0F, 2.0F);
return this;
}
@Override
public ClimateChange addHumidity(float humidity){
this.humidity = MathHelper.clamp(this.humidity + humidity, -2.0F, 2.0F);
return this;
}
@Override
public ImmutableClimateState toImmutable() {
return new ImmutableClimateState(temperature, humidity);
}
@Override
public ClimateState toMutable() {
return new ClimateState(temperature, humidity);
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this).add("temperature", temperature).add("humidity", humidity).toString();
}
}
@@ -1,18 +0,0 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.climate;
public enum GreenhouseState {
CLOSED,
//If the greenhouse is not closed.
OPEN,
//If one chunk of the greenhouse is unloaded.
UNLOADED_CHUNK,
//The greenhouse has this state 20 ticks after all chunks are loaded, needed to load all climate sources.
UNLOADED,
//If the greenhouse is not assembled.
UNREADY
}
@@ -1,64 +0,0 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.climate;
import javax.annotation.Nullable;
import java.util.Collection;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.core.INbtReadable;
import forestry.api.core.INbtWritable;
public interface IClimateContainer extends INbtReadable, INbtWritable, IClimateSourceContainer {
/**
* @return The parent of this container.
*/
IClimateHousing getParent();
/**
* @return The current climate state.
*/
IClimateState getState();
World getWorld();
/**
* Update the climate in a region.
*/
void updateClimate(int ticks);
/**
* Add a listener to this container.
*/
void addListaner(IClimateContainerListener listener);
/**
* Remove a listener to this container.
*/
void removeListener(IClimateContainerListener listener);
/**
* All listeners of this container.
*/
Collection<IClimateContainerListener> getListeners();
/**
* @return the state that the container targets to get his climate state to.
*/
ImmutableClimateState getTargetedState();
void setTargetedState(ImmutableClimateState state);
@Nullable
@SideOnly(Side.CLIENT)
IClimateData getData();
}
@@ -1,17 +0,0 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.climate;
public interface IClimateContainerListener {
/**
* Test if the container is closed.
*
* @return true to let the container slowly set his climate state back to the default climate state.
*/
boolean isClosed(IClimateContainer container);
}
@@ -1,15 +0,0 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.climate;
import java.util.Map;
public interface IClimateData {
IClimateData addData(ClimateType type, String displayName, float value);
Map<String, Float> getData(ClimateType type);
}
@@ -1,17 +0,0 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.climate;
public interface IClimateFactory {
/**
* @param climatedRegion
*
* @return Creates a climate container.
*/
IClimateContainer createContainer(IClimateHousing climatedRegion);
}
@@ -5,23 +5,11 @@
******************************************************************************/
package forestry.api.climate;
import javax.annotation.Nullable;
import java.util.Collection;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import forestry.api.greenhouse.Position2D;
public interface IClimateManager {
/**
* @return The current state of a container at this position if one exists.
* @since 5.3.4
*/
@Nullable
IClimateContainer getContainer(World world, BlockPos pos);
/**
* Gets the current state of a container at this position or setSettings one with the datas from the biome.
* @since 5.3.4
@@ -37,11 +25,4 @@ public interface IClimateManager {
* @return Create a climate manager.
*/
IClimateProvider getDefaultClimate(World world, BlockPos pos);
void addSource(IClimateSourceOwner owner);
void removeSource(IClimateSourceOwner owner);
Collection<IClimateSourceOwner> getSources(World world, Position2D position);
}
@@ -1,37 +0,0 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.climate;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
/**
* This modifier is used by {@link IClimateContainer}s.
*/
public interface IClimateModifier {
/**
* Is called every 20 ticks by the {@link IClimateContainer} to change its climate state.
*
* @param container the climate container
* @param newState the new climate state
* @param oldState the climate static of the previous modification.
* @param data A {@link NBTTagCompound} that can be used to save custom data or to send it to the client to add it to the {@link IClimateData}.
* @return a modify newState or the newState.
*/
IClimateState modifyTarget(IClimateContainer container, IClimateState newState, ImmutableClimateState oldState, NBTTagCompound data);
@SideOnly(Side.CLIENT)
void addData(IClimateContainer container, IClimateState climateState, NBTTagCompound nbtData, IClimateData data);
/**
* @return The priority of this modifier. The modifier with the highest priority is called first and the modifier with the lowest at last.
*/
int getPriority();
}
@@ -1,56 +0,0 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.climate;
import javax.annotation.Nullable;
/**
* A climate source is stored in a {@link IClimateSourceOwner}. It is used by the {@link IClimateSourceContainer}s to change the climate of a {@link IClimateContainer}.
* One {@link IClimateSource} can only be used by one {@link IClimateSourceContainer} at the same time.
* <p>
* In forestry it is used in a part of a {@link IClimateModifier}.
*/
public interface IClimateSource {
/**
* The owner of this source.
*/
@Nullable
IClimateSourceOwner getOwner();
/**
* The range of this source.
*/
float getBoundaryModifier(ClimateType type, boolean boundaryUp);
/**
* @return true if this source affects this sourceType of climate.
*/
boolean affectClimateType(ClimateType type);
/**
* @param state the {@link IClimateState} that the source has to work on.
* @param target the by the {@link IClimateContainer} targeted {@link IClimateState}.
*
*/
ClimateChange work(IClimateState state, ImmutableClimateState target);
/**
* @return true if source has changed the climate at the last work cicle.
*/
boolean isActive();
/**
* Called if the source is added to a {@link IClimateContainer}.
*/
void onAdded(IClimateContainer container);
/**
* Called if the source is removed form a {@link IClimateContainer}.
*/
void onRemoved(IClimateContainer container);
}
@@ -1,15 +0,0 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.climate;
import forestry.api.circuits.ICircuit;
public interface IClimateSourceCircuitable extends IClimateSource {
/**
* Called by the {@link IClimateSourceOwner} if its {@link ICircuit} changes.
*/
void changeSourceConfig(ClimateType type, float changeChange, float rangeChange);
}
@@ -1,46 +0,0 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.climate;
import java.util.Collection;
/**
* @since 5.3.4
*
*/
public interface IClimateSourceContainer {
/**
* Add a climate source to this container.
*/
void addClimateSource(IClimateSource source);
/**
* Remove a climate source from this container.
*/
void removeClimateSource(IClimateSource source);
/**
* @return All climate sources of this container.
*/
Collection<IClimateSource> getClimateSources();
/**
* The climate of the {@link IClimateContainer} that results out of the {@link IClimateState} modifications of the {@link IClimateSource}s can not be higher than this bound.
*/
IClimateState getBoundaryUp();
/**
* The climate of the {@link IClimateContainer} that results out of the {@link IClimateState} modifications of the {@link IClimateSource}s can not be lower than this bound.
*/
IClimateState getBoundaryDown();
/**
* Has to be called if any range of a {@link IClimateSource} changes. It calculates the range of all {@link IClimateSource}s together.
*/
void recalculateBoundaries(double sizeModifier);
}
@@ -1,28 +0,0 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.climate;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.circuits.ICircuit;
import forestry.api.core.ILocatable;
public interface IClimateSourceOwner extends ILocatable {
IClimateSource getClimateSource();
@SideOnly(Side.CLIENT)
ItemStack getItemStack();
boolean isActive();
/**
* @return true if this climate source owner can hold a {@link ICircuit}
*/
boolean isCircuitable();
}
@@ -14,7 +14,7 @@ import forestry.api.core.INbtWritable;
*
* The range of the value of this two goes from 0.0F to 2.0F. And is oriented on the values of {@link Biome#getTemperature()} and {@link Biome#getRainfall()}.
*
* Default inmplementations are: {@link ImmutableClimateState}, {@link ClimateState} and {@link ClimateChange}.
* Default inmplementations are: {@link ImmutableClimateState}, {@link ClimateState}.
*/
public interface IClimateState extends INbtWritable {
@@ -10,7 +10,7 @@ import java.util.Set;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.climate.IClimateFactory;
import forestry.greenhouse.api.climate.IClimateFactory;
import forestry.api.climate.IClimateManager;
import forestry.api.farming.IFarmRegistry;
import forestry.api.farming.ISimpleFarmLogic;
@@ -1,17 +0,0 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.greenhouse;
import forestry.api.multiblock.IGreenhouseController;
public class DefaultGreenhouseListener implements IGreenhouseListener {
@Override
public boolean canWork(IGreenhouseController greenhouse, boolean canWork) {
return true;
}
}
@@ -1,14 +0,0 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.greenhouse;
public class GreenhouseManager {
public static IGreenhouseHelper greenhouseHelper;
public static IGreenhouseBlockManager greenhouseBlockManager;
}
@@ -1,44 +0,0 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.greenhouse;
import javax.annotation.Nullable;
import net.minecraft.util.EnumFacing;
public interface IBlankBlock extends IGreenhouseBlock {
@Override
@Nullable
IBlankBlock getRoot();
/**
* @return test if a face was already tested, false if not.
*/
boolean isFaceTested(EnumFacing facing);
void setFaceTested(EnumFacing facing, boolean isTested);
/**
* @return if this block has a {@link IWallBlock} next to him.
*/
boolean isNearWall();
void setNearWall(boolean nearWall);
/**
* Called after the block is created.
*/
void validate();
/**
* Called before the block will be removed.
*/
void invalidate(boolean chunkUnloading);
boolean isValid();
}
@@ -3,17 +3,14 @@
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.climate;
package forestry.api.greenhouse;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public interface IClimateHousing {
import forestry.api.climate.ImmutableClimateState;
/**
* @return The climate container of this region.
*/
IClimateContainer getClimateContainer();
public interface IClimateHousing {
/**
* @return The size of the region in blocks.
@@ -1,45 +0,0 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.greenhouse;
import javax.annotation.Nullable;
import java.util.Set;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
public interface IGreenhouseBlock {
/**
* @return the position of this block.
*/
BlockPos getPos();
/**
* @return the root block of this block.
*/
@Nullable
IGreenhouseBlock getRoot();
/**
* @return the side of this block that shows to the root block.
*/
@Nullable
EnumFacing getRootFace();
/**
* @return the manager of this block.
*/
IGreenhouseProvider getProvider();
/**
* Called if a neighbor block of this block is removed.
*/
void onNeighborRemoved(IBlankBlock changedBlock, EnumFacing facing, boolean forcedRemove, Set<IGreenhouseBlock> blocksToCheck);
IGreenhouseBlockHandler getHandler();
}
@@ -1,29 +0,0 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.greenhouse;
import javax.annotation.Nullable;
import java.util.List;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import forestry.greenhouse.multiblock.blocks.GreenhouseException;
public interface IGreenhouseBlockHandler<B extends IGreenhouseBlock, R extends IGreenhouseBlock> {
void onRemoveBlock(IGreenhouseBlockStorage storage, B blockToRemove);
B createBlock(IGreenhouseBlockStorage storage, @Nullable R root, @Nullable EnumFacing rootFacing, @Nullable BlockPos position);
B getBlock(IGreenhouseBlockStorage storage, BlockPos position);
List<IGreenhouseBlock> checkNeighborBlocks(IGreenhouseBlockStorage storage, B blockToCheck) throws GreenhouseException;
boolean onCheckPosition(IGreenhouseBlockStorage storage, R rootBlock, BlockPos position, EnumFacing facing, IGreenhouseBlock block, List<IGreenhouseBlock> newBlocksToCheck) throws GreenhouseException;
Class<? extends B> getBlockClass();
}
@@ -1,74 +0,0 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.greenhouse;
import javax.annotation.Nullable;
import java.util.List;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.world.World;
public interface IGreenhouseBlockManager {
/**
* @return the {@link IGreenhouseBlockHandler} that is used to handle blank blocks in the {@link IGreenhouseProvider}
*/
IGreenhouseBlockHandler<IBlankBlock, IBlankBlock> getBlankBlockHandler();
/**
* @return the {@link IGreenhouseBlockHandler} that is used to handle wall blocks in the {@link IGreenhouseProvider}
*/
IGreenhouseBlockHandler<IWallBlock, IBlankBlock> getWallBlockHandler();
/**
* Tries to get a {@link IGreenhouseBlock} from all managers that are located at the chunk of the pos.
*
* @return a {@link IGreenhouseBlock} if any manager of the chunk at this position has one block at this position, otherwise null.
*/
@Nullable
IGreenhouseBlock getBlock(World world, BlockPos pos);
/**
*
* @return the chunk that is at this position.
*/
@Nullable
IGreenhouseChunk getChunk(World world, long chunkPos);
/**
* @return the chunk that is at this position or if there is no it creates one.
*/
IGreenhouseChunk getOrCreateChunk(World world, long chunkPos);
/**
* @return creates a chunk and add it at this position
*/
IGreenhouseChunk createChunk(World world, long chunkPos);
default IGreenhouseChunk getChunk(World world, int xPos, int yPos){
return getChunk(world, ChunkPos.asLong(xPos, yPos));
}
default IGreenhouseChunk getOrCreateChunk(World world, int xPos, int yPos){
return getOrCreateChunk(world, ChunkPos.asLong(xPos, yPos));
}
default IGreenhouseChunk createChunk(World world, int xPos, int yPos){
return createChunk(world, ChunkPos.asLong(xPos, yPos));
}
@Nullable
void markChunkDirty(World world, long pos);
@Nullable
List<Long> getDirtyChunks(World world);
@Nullable
void markBlockDirty(World world, BlockPos pos);
void markProviderDirty(World world, BlockPos pos, IGreenhouseProvider provider);
}
@@ -1,35 +0,0 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.greenhouse;
import javax.annotation.Nullable;
import net.minecraft.util.math.BlockPos;
public interface IGreenhouseBlockStorage {
/**
* @return a {@link IGreenhouseBlock} if there is one on this position.
*/
@Nullable
IGreenhouseBlock getBlock(BlockPos pos);
/**
* Sets a {@link IGreenhouseBlock} to a position in the world.
*/
boolean setBlock(BlockPos pos, @Nullable IGreenhouseBlock block);
/**
* @return The number of {@link IBlankBlock}s that this provider contains.
*/
int getBlockCount();
/**
* Removes a {@link IGreenhouseBlock} from this provider and add its neighbor blocks to the set.
*/
<B extends IGreenhouseBlock> void removeBlock(IGreenhouseBlock block);
IGreenhouseProvider getProvider();
}
@@ -1,49 +0,0 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.greenhouse;
import javax.annotation.Nullable;
import java.util.Collection;
import net.minecraft.util.math.BlockPos;
/**
* A greenhouse chunk is used to save the greenhouse managers from the greenhouses that are located in the world chunk on this chunk position.
*/
public interface IGreenhouseChunk {
/**
* @return a {@link Collection} with all greenhouse managers of the greenhouses that are located in the world chunk on this chunk position.
*/
Collection<IGreenhouseProvider> getProviders();
/**
* Marks the manager, that has a {@link IGreenhouseBlock} on this position, as dirty.
*/
void markProviderDirty(BlockPos pos);
/**
* @return A {@link java.util.Collection} with all managers that were modified in the last tick.
*/
Collection<IGreenhouseProvider> getDirtyProviders();
/**
* Tries to get a {@link IGreenhouseBlock} from all managers that are located in this chunk.
*
* @return A {@link IGreenhouseBlock} if any manager has one block at this position, otherwise null.
*/
@Nullable
IGreenhouseBlock get(BlockPos pos);
/**
* Adds a manager to this chunk.
*/
void add(IGreenhouseProvider manager);
/**
* Removed a manager from this chunk.
*/
void remove(IGreenhouseProvider manager);
}
@@ -1,33 +0,0 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.greenhouse;
import java.util.Collection;
import net.minecraft.item.ItemStack;
import forestry.api.climate.IClimateModifier;
import forestry.api.multiblock.IGreenhouseController;
public interface IGreenhouseHelper {
void registerWindowGlass(String name, ItemStack item, String texture);
ItemStack getGlassItem(String name);
String getGlassTexture(String name);
Collection<String> getWindowGlasses();
void registerLogic(IGreenhouseLogicFactory logicFactory);
Collection<IGreenhouseLogic> createLogics(IGreenhouseController controller);
void registerModifier(IClimateModifier modifier);
Collection<IClimateModifier> getModifiers();
}
@@ -5,9 +5,6 @@
******************************************************************************/
package forestry.api.greenhouse;
import javax.annotation.Nullable;
import forestry.api.climate.IClimateHousing;
import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
import forestry.api.core.IErrorLogicSource;
@@ -33,15 +30,4 @@ public interface IGreenhouseHousing extends IErrorLogicSource, IClimateHousing{
* @return The current humidity as an float. Range: 0.0F ~ 2.0F
*/
float getExactHumidity();
/**
* @return the manager of this housing.
*/
IGreenhouseProvider getProvider();
/**
* @return the maximal and minimal settings of this housing.
*/
@Nullable
IGreenhouseLimits getLimits();
}
@@ -1,33 +0,0 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.greenhouse;
/**
* The limits that a greenhouse has. Used in the {@link IGreenhouseProvider} to test if the greenhouse is tested.
* At the test the provider stops if the currently tested position is out of this limits and marks the greenhouse as open.
*/
public interface IGreenhouseLimits {
/**
* @return The maximum bounding-box coordinate.
*/
Position2D getMaximumCoordinates();
/**
* @return The minimum bounding-box coordinate.
*/
Position2D getMinimumCoordinates();
/**
* @return the maximal height of the manager on the y axis.
*/
int getHeight();
/**
* @return the maximal depth of the manager on the y axis.
*/
int getDepth();
}
@@ -1,112 +0,0 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.greenhouse;
import javax.annotation.Nullable;
import java.util.Collection;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import forestry.api.climate.GreenhouseState;
import forestry.api.climate.IClimateContainer;
import forestry.greenhouse.multiblock.blocks.GreenhouseException;
/**
* Can be used to test if a space is closed. Is used by the greenhouse.
*
*/
public interface IGreenhouseProvider {
/**
* @return the climate container of this provider.
*/
@Nullable
IClimateContainer getClimateContainer();
/**
* Adds a listener to this provider.
*/
void addListener(IGreenhouseProviderListener listener);
/**
* @return All listeners that this provider has.
*/
Collection<IGreenhouseProviderListener> getListeners();
/**
* @param centerPos The position at that the provider starts to test.
*/
void init(BlockPos centerPos, IGreenhouseLimits limits);
/**
* Invalidate and delete all {@link IGreenhouseBlock}s of this provider.
*/
void clear(boolean chunkUnloading);
/**
* @return The last error that has coded that the provider is not closed.
*/
String getLastNotClosedError();
/**
* Called from the thread if a {@link IGreenhouseBlock} was modified by the player.
*/
void recreate();
void onUnloadChunk(long chunkPos);
void onLoadChunk(long chunkPos);
/**
* @return True if the provider waits for a chunk to be loaded, before he can test if it is closed.
*/
boolean hasUnloadedChunks();
/**
* @return The position from that the provider tests if it is closed.
*/
BlockPos getCenterPos();
/**
* @return The limits that a greenhouse has. Used to test if the greenhouse is tested.
* At the test the provider stops if the currently tested position is out of this limits and marks the greenhouse as open.
*/
IGreenhouseLimits getLimits();
/**
* Null if the provider is not created.
*/
@Nullable
IGreenhouseLimits getUsedLimits();
GreenhouseState getState();
World getWorld();
/**
* @return true if the space is closed.
*/
boolean isClosed();
/**
* Test if the provider is closed.
*/
void checkPosition(BlockPos position) throws GreenhouseException;
int getSize();
/**
* @return All {@link IGreenhouseBlockHandler}s that this provider uses.
*/
Collection<IGreenhouseBlockHandler> getHandlers();
IGreenhouseBlockStorage getStorage();
void onBlockChange();
void scheduledUpdate();
}
@@ -1,14 +0,0 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.greenhouse;
import net.minecraft.util.math.BlockPos;
public interface IGreenhouseProviderListener {
void onCheckPosition(BlockPos pos);
}
@@ -1,24 +0,0 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.greenhouse;
import net.minecraft.util.EnumFacing;
import forestry.api.climate.IClimateSource;
public interface IWallBlock extends IGreenhouseBlock {
void setRoot(IBlankBlock parent);
void setRootFace(EnumFacing facing);
void onCreate();
void onRemove();
void add(IClimateSource source);
}
@@ -1,122 +0,0 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.greenhouse;
import com.google.common.base.MoreObjects;
import javax.annotation.concurrent.Immutable;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3i;
import forestry.api.core.INbtWritable;
@Immutable
public class Position2D implements Comparable<Position2D>, INbtWritable {
public static final Position2D NULL_POSITION = new Position2D(0, 0);
/** X coordinate */
private final int x;
/** Z coordinate */
private final int z;
public Position2D(Vec3i pos) {
this(pos.getX(), pos.getZ());
}
public Position2D(Position2D pos) {
this(pos.getX(), pos.getZ());
}
public Position2D(int xIn, int zIn) {
this.x = xIn;
this.z = zIn;
}
public Position2D(NBTTagCompound nbtTagCompound) {
this.x = nbtTagCompound.getInteger("xPosition");
this.z = nbtTagCompound.getInteger("zPosition");
}
public boolean equals(Object o) {
if (this == o) {
return true;
} else if (o instanceof Vec3i) {
Vec3i position = (Vec3i) o;
return this.getX() == position.getX() && this.getZ() == position.getZ();
} else if (!(o instanceof Position2D)) {
return false;
} else {
Position2D position = (Position2D) o;
return this.getX() == position.getX() && this.getZ() == position.getZ();
}
}
public Position2D clamp(Position2D min, Position2D max) {
int x = MathHelper.clamp(this.x, min.getX(), max.getX());
int z = MathHelper.clamp(this.z, min.getZ(), max.getZ());
return new Position2D(x, z);
}
public Position2D add(int x, int z) {
return x == 0 && z == 0 ? this : new Position2D(this.getX() + x, this.getZ() + z);
}
public int hashCode() {
return (this.getZ() + this.getX() * 31);
}
public int compareTo(Position2D o) {
return this.getZ() == o.getZ() ? this.getX() - o.getX() : this.getZ() - o.getZ();
}
@Override
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
nbt.setInteger("xPosition", x);
nbt.setInteger("zPosition", z);
return nbt;
}
/**
* Gets the X coordinate.
*/
public int getX() {
return this.x;
}
/**
* Gets the Z coordinate.
*/
public int getZ() {
return this.z;
}
public double getDistance(int xIn, int zIn) {
double d0 = (double) (this.getX() - xIn);
double d2 = (double) (this.getZ() - zIn);
return Math.sqrt(d0 * d0 + d2 * d2);
}
public double distanceSq(double toX, double toZ) {
double d0 = (double) this.getX() - toX;
double d2 = (double) this.getZ() - toZ;
return d0 * d0 + d2 * d2;
}
public double distanceSqToCenter(double xIn, double zIn) {
double d0 = (double) this.getX() + 0.5D - xIn;
double d2 = (double) this.getZ() + 0.5D - zIn;
return d0 * d0 + d2 * d2;
}
public double distanceSq(Position2D to) {
return this.distanceSq((double) to.getX(), (double) to.getZ());
}
public String toString() {
return MoreObjects.toStringHelper(this).add("x", this.getX()).add("z", this.getZ()).toString();
}
}