mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-19 11:49:14 +00:00
Merge branch 'Greenhouse' of https://github.com/ForestryMC/ForestryMC into mc-1.12
This commit is contained in:
commit
26bf69effc
413 files changed
+13569
-7506
No files matched your search
Binary file not shown.
@@ -31,7 +31,6 @@ import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.core.EventHandlerCore;
|
||||
import forestry.core.climate.ClimateEventHandler;
|
||||
import forestry.core.config.Config;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.config.GameMode;
|
||||
@@ -58,7 +57,8 @@ import forestry.plugins.compat.PluginIC2;
|
||||
acceptedMinecraftVersions = "[1.12]",
|
||||
dependencies = "required-after:forge@[14.21.1.2395,);"
|
||||
+ "after:jei@[4.7.0,);"
|
||||
+ "after:" + PluginIC2.modId + ";")
|
||||
+ "after:" + PluginIC2.modId + ";"
|
||||
+ "after:toughasnails;")
|
||||
public class Forestry {
|
||||
|
||||
@SuppressWarnings("NullableProblems")
|
||||
@@ -91,7 +91,7 @@ public class Forestry {
|
||||
EventHandlerCore eventHandlerCore = new EventHandlerCore();
|
||||
MinecraftForge.EVENT_BUS.register(eventHandlerCore);
|
||||
MinecraftForge.EVENT_BUS.register(new MultiblockEventHandler());
|
||||
MinecraftForge.EVENT_BUS.register(new ClimateEventHandler());
|
||||
MinecraftForge.EVENT_BUS.register(Config.class);
|
||||
Proxies.common.registerEventHandlers();
|
||||
|
||||
configFolder = new File(event.getModConfigurationDirectory(), Constants.MOD_ID);
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.apiculture;
|
||||
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.apiculture;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
@@ -1,9 +1,15 @@
|
||||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.arboriculture;
|
||||
|
||||
import forestry.api.core.IArmorNaturalist;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.capabilities.CapabilityInject;
|
||||
|
||||
import forestry.api.core.IArmorNaturalist;
|
||||
|
||||
public class ArboricultureCapabilities {
|
||||
/**
|
||||
* Capability for {@link IArmorNaturalist}.
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.arboriculture;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.arboriculture;
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.arboriculture;
|
||||
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.arboriculture;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
@@ -8,6 +8,7 @@ package forestry.api.circuits;
|
||||
public enum CircuitSocketType implements ICircuitSocketType {
|
||||
NONE("none"),
|
||||
FARM("forestry.farm"),
|
||||
GREENHOUSE_CLIMATISER("forestry.greenhouse.climatiser"),
|
||||
ELECTRIC_ENGINE("forestry.electric.engine"),
|
||||
MACHINE("forestry.machine");
|
||||
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
/*******************************************************************************
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
/*******************************************************************************
|
||||
* 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.Objects;
|
||||
|
||||
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 Objects.toStringHelper(this).add("temperature", temperature).add("humidity", humidity).toString();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
/*******************************************************************************
|
||||
* 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.Objects;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
|
||||
import forestry.api.core.INbtReadable;
|
||||
|
||||
import static forestry.api.climate.ImmutableClimateState.MAX;
|
||||
import static forestry.api.climate.ImmutableClimateState.MIN;
|
||||
|
||||
/**
|
||||
* A {@link IClimateState} that has a range from 0.0F to 2.0F.
|
||||
*/
|
||||
public class ClimateState implements IClimateState, INbtReadable{
|
||||
|
||||
private static final String TEMPERATURE_NBT_KEY = "TEMP";
|
||||
private static final String HUMIDITY_NBT_KEY = "HUMID";
|
||||
|
||||
protected float temperature;
|
||||
protected float humidity;
|
||||
|
||||
public ClimateState(float temperature, float humidity) {
|
||||
addTemperature(temperature);
|
||||
addHumidity(humidity);
|
||||
}
|
||||
|
||||
public ClimateState(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);
|
||||
}
|
||||
|
||||
public void setTemperature(float temperature) {
|
||||
this.temperature = MathHelper.clamp(temperature, MIN.temperature, MAX.temperature);
|
||||
}
|
||||
|
||||
public void setHumidity(float humidity) {
|
||||
this.humidity = MathHelper.clamp(humidity, MIN.humidity, MAX.humidity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClimateState addTemperature(float temperature){
|
||||
setTemperature(this.temperature + temperature);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClimateState addHumidity(float humidity){
|
||||
setHumidity(this.humidity + humidity);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClimateState add(IClimateState state){
|
||||
addTemperature(state.getTemperature());
|
||||
addHumidity(state.getHumidity());
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClimateState remove(IClimateState state){
|
||||
addTemperature(-state.getTemperature());
|
||||
addHumidity(-state.getHumidity());
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getTemperature() {
|
||||
return temperature;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getHumidity() {
|
||||
return humidity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImmutableClimateState toImmutable(){
|
||||
return new ImmutableClimateState(temperature, humidity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClimateState toMutable(){
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if(!(obj instanceof IClimateState)){
|
||||
return false;
|
||||
}
|
||||
IClimateState otherState = (IClimateState) obj;
|
||||
return otherState.getTemperature() == temperature && otherState.getHumidity() == humidity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Float.hashCode(temperature) + Float.hashCode(humidity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return Objects.toStringHelper(this).add("temperature", temperature).add("humidity", humidity).toString();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*******************************************************************************
|
||||
* 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.Locale;
|
||||
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.core.ForestryAPI;
|
||||
|
||||
public enum ClimateType {
|
||||
TEMPERATURE, HUMIDITY;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public TextureAtlasSprite getSprite() {
|
||||
return ForestryAPI.textureManager.getDefault("misc/" + getName());
|
||||
}
|
||||
|
||||
public String getName(){
|
||||
return name().toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package forestry.api.climate;
|
||||
|
||||
public enum EnumClimatiserModes {
|
||||
|
||||
POSITIVE, NEGATIVE, BOTH
|
||||
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package forestry.api.climate;
|
||||
|
||||
public enum EnumClimatiserTypes {
|
||||
|
||||
TEMPERATURE, HUMIDITY, BOTH
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
/*******************************************************************************
|
||||
* 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
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/*******************************************************************************
|
||||
* 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();
|
||||
|
||||
}
|
||||
+7
-8
@@ -5,14 +5,13 @@
|
||||
******************************************************************************/
|
||||
package forestry.api.climate;
|
||||
|
||||
import java.util.Set;
|
||||
public interface IClimateContainerListener {
|
||||
|
||||
import forestry.api.core.ILocatable;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
public interface IClimateSourceProvider extends ILocatable {
|
||||
|
||||
IClimateSource getClimateSource();
|
||||
/**
|
||||
* 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);
|
||||
|
||||
Set<BlockPos> getPositionsInRange();
|
||||
}
|
||||
+4
-7
@@ -5,14 +5,11 @@
|
||||
******************************************************************************/
|
||||
package forestry.api.climate;
|
||||
|
||||
public interface IClimatiserDefinition {
|
||||
import java.util.Map;
|
||||
|
||||
float getChange();
|
||||
public interface IClimateData {
|
||||
|
||||
float getRange();
|
||||
|
||||
EnumClimatiserModes getMode();
|
||||
|
||||
EnumClimatiserTypes getType();
|
||||
IClimateData addData(ClimateType type, String displayName, float value);
|
||||
|
||||
Map<String, Float> getData(ClimateType type);
|
||||
}
|
||||
+7
-6
@@ -5,12 +5,13 @@
|
||||
******************************************************************************/
|
||||
package forestry.api.climate;
|
||||
|
||||
import forestry.api.core.ILocatable;
|
||||
public interface IClimateFactory {
|
||||
|
||||
public interface IClimateControlProvider extends ILocatable {
|
||||
|
||||
IClimateInfo getControlClimate();
|
||||
/**
|
||||
* @param climatedRegion
|
||||
*
|
||||
* @return Creates a climate container.
|
||||
*/
|
||||
IClimateContainer createContainer(IClimateHousing climatedRegion);
|
||||
|
||||
void setControlClimate(IClimateInfo climateControl);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*******************************************************************************
|
||||
* 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.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface IClimateHousing {
|
||||
|
||||
/**
|
||||
* @return The climate container of this region.
|
||||
*/
|
||||
IClimateContainer getClimateContainer();
|
||||
|
||||
/**
|
||||
* @return The size of the region in blocks.
|
||||
*/
|
||||
int getSize();
|
||||
|
||||
void onUpdateClimate();
|
||||
|
||||
/**
|
||||
* @return The default climate state. It is calculated out of all biomedata that this region contains.
|
||||
*/
|
||||
ImmutableClimateState getDefaultClimate();
|
||||
|
||||
/**
|
||||
* Must not be named "getWorld" to avoid SpecialSource issue https://github.com/md-5/SpecialSource/issues/12
|
||||
*
|
||||
* @return The position at that the housing is.
|
||||
*/
|
||||
BlockPos getCoordinates();
|
||||
|
||||
/**
|
||||
* Must not be named "getWorld" to avoid SpecialSource issue https://github.com/md-5/SpecialSource/issues/12
|
||||
*
|
||||
* @return The world in that the housing is.
|
||||
*/
|
||||
World getWorldObj();
|
||||
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
package forestry.api.climate;
|
||||
|
||||
public interface IClimateInfo {
|
||||
|
||||
float getTemperature();
|
||||
|
||||
float getHumidity();
|
||||
|
||||
}
|
||||
@@ -6,36 +6,42 @@
|
||||
package forestry.api.climate;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Collection;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.api.greenhouse.Position2D;
|
||||
|
||||
public interface IClimateManager {
|
||||
|
||||
IClimateInfo createInfo(float temperature, float humidity);
|
||||
|
||||
IClimateInfo getInfo(World world, BlockPos pos);
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
IClimateState getClimateState(World world, BlockPos pos);
|
||||
|
||||
/**
|
||||
* Creates a climate state with the help of the biome on this position.
|
||||
*/
|
||||
ImmutableClimateState getBiomeState(World world, BlockPos pos);
|
||||
|
||||
/**
|
||||
* @return Create a climate manager.
|
||||
*/
|
||||
IClimateProvider getDefaultClimate(World world, BlockPos pos);
|
||||
|
||||
void addRegion(IClimateRegion region);
|
||||
|
||||
void removeRegion(IClimateRegion region);
|
||||
|
||||
void addSource(IClimateSourceProvider source);
|
||||
|
||||
void removeSource(IClimateSourceProvider source);
|
||||
|
||||
void onWorldUnload(World world);
|
||||
|
||||
@Nullable
|
||||
IClimatePosition getPosition(World world, BlockPos pos);
|
||||
void addSource(IClimateSourceOwner owner);
|
||||
|
||||
void removeSource(IClimateSourceOwner owner);
|
||||
|
||||
@Nullable
|
||||
IClimateRegion getRegionForPos(World world, BlockPos pos);
|
||||
|
||||
Map<World, List<IClimateRegion>> getRegions();
|
||||
Collection<IClimateSourceOwner> getSources(World world, Position2D position);
|
||||
|
||||
}
|
||||
@@ -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.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,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.climate;
|
||||
|
||||
import forestry.api.core.INbtReadable;
|
||||
import forestry.api.core.INbtWritable;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
/**
|
||||
* A IClimatePosition contains the climate infos (temperature and humidity) of one position.
|
||||
*/
|
||||
public interface IClimatePosition extends INbtReadable, INbtWritable {
|
||||
|
||||
IClimateRegion getClimateRegion();
|
||||
|
||||
BlockPos getPos();
|
||||
|
||||
void setTemperature(float temperature);
|
||||
|
||||
void addTemperature(float temperature);
|
||||
|
||||
float getTemperature();
|
||||
|
||||
void setHumidity(float humidity);
|
||||
|
||||
void addHumidity(float humidity);
|
||||
|
||||
float getHumidity();
|
||||
|
||||
IClimateInfo getInfo();
|
||||
|
||||
}
|
||||
@@ -5,9 +5,10 @@
|
||||
******************************************************************************/
|
||||
package forestry.api.climate;
|
||||
|
||||
import net.minecraft.world.biome.Biome;
|
||||
|
||||
import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
|
||||
public interface IClimateProvider {
|
||||
Biome getBiome();
|
||||
|
||||
@@ -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;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import forestry.api.core.INbtReadable;
|
||||
import forestry.api.core.INbtWritable;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface IClimateRegion extends INbtReadable, INbtWritable {
|
||||
|
||||
World getWorld();
|
||||
|
||||
int getTicksPerUpdate();
|
||||
|
||||
void setPosition(BlockPos pos, float temperature, float humidity);
|
||||
|
||||
@Nullable
|
||||
IClimatePosition getPosition(BlockPos pos);
|
||||
|
||||
Collection<IClimatePosition> getPositions();
|
||||
|
||||
void addSource(IClimateSource source);
|
||||
|
||||
void removeSource(IClimateSource source);
|
||||
|
||||
Collection<IClimateSource> getSources();
|
||||
|
||||
void calculateAverageClimate();
|
||||
|
||||
float getAverageTemperature();
|
||||
|
||||
float getAverageHumidity();
|
||||
|
||||
/**
|
||||
* Update the climate in a region.
|
||||
*/
|
||||
void updateClimate(int ticks);
|
||||
|
||||
}
|
||||
@@ -8,23 +8,49 @@ package forestry.api.climate;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* A climate source is used to change the climate in a region.
|
||||
* 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 {
|
||||
|
||||
|
||||
/**
|
||||
* @param tickCount The current tick count.
|
||||
* @param region The climate region, in that the source stands.
|
||||
* @return Return true if the the climate has changed.
|
||||
* The owner of this source.
|
||||
*/
|
||||
boolean changeClimate(int tickCount, IClimateRegion region);
|
||||
|
||||
/**
|
||||
* @return The ticks that are required for one change.
|
||||
*/
|
||||
int getTicksForChange(IClimateRegion region);
|
||||
|
||||
@Nullable
|
||||
IClimateSourceProvider getProvider();
|
||||
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);
|
||||
|
||||
}
|
||||
+6
-13
@@ -5,18 +5,11 @@
|
||||
******************************************************************************/
|
||||
package forestry.api.climate;
|
||||
|
||||
public interface IClimateControl {
|
||||
|
||||
IClimateInfo getControlClimate();
|
||||
|
||||
void setControlClimate(IClimateInfo climateInfo);
|
||||
|
||||
float getControlTemperature();
|
||||
|
||||
float getControlHumidity();
|
||||
|
||||
void setControlTemperature(float temperature);
|
||||
|
||||
void setControlHumidity(float humidity);
|
||||
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);
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*******************************************************************************
|
||||
* 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);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/*******************************************************************************
|
||||
* 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();
|
||||
}
|
||||
@@ -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.climate;
|
||||
|
||||
import net.minecraft.world.biome.Biome;
|
||||
|
||||
import forestry.api.core.INbtWritable;
|
||||
|
||||
/**
|
||||
* A {@link IClimateState} is used to store and handle temperature and humidity.
|
||||
*
|
||||
* 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}.
|
||||
*/
|
||||
public interface IClimateState extends INbtWritable {
|
||||
|
||||
float getTemperature();
|
||||
|
||||
float getHumidity();
|
||||
|
||||
IClimateState addTemperature(float temperature);
|
||||
|
||||
IClimateState addHumidity(float humidity);
|
||||
|
||||
IClimateState add(IClimateState state);
|
||||
|
||||
IClimateState remove(IClimateState state);
|
||||
|
||||
default float get(ClimateType type){
|
||||
return type == ClimateType.HUMIDITY ? getHumidity() : getTemperature();
|
||||
}
|
||||
|
||||
ImmutableClimateState toImmutable();
|
||||
|
||||
ClimateState toMutable();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
/*******************************************************************************
|
||||
* 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.Objects;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
|
||||
import forestry.api.core.INbtWritable;
|
||||
|
||||
/**
|
||||
* A {@link IClimateState} that has a range from 0.0F to 2.0F and can not be changed.
|
||||
*/
|
||||
public class ImmutableClimateState implements IClimateState, INbtWritable{
|
||||
|
||||
// The minimum climate state.
|
||||
public static final ImmutableClimateState MIN = new ImmutableClimateState(0.0F, 0.0F);
|
||||
// The climate state of a plain biome.
|
||||
public static final ImmutableClimateState PLAIN = new ImmutableClimateState(0.8F, 0.4F);
|
||||
// The maximum climate state.
|
||||
public static final ImmutableClimateState MAX = new ImmutableClimateState(2.0F, 2.0F);
|
||||
|
||||
private static final String TEMPERATURE_NBT_KEY = "TEMP";
|
||||
private static final String HUMIDITY_NBT_KEY = "HUMID";
|
||||
|
||||
protected final float temperature;
|
||||
protected final float humidity;
|
||||
|
||||
public ImmutableClimateState(float temperature, float humidity) {
|
||||
this.temperature = MathHelper.clamp(temperature, 0.0F, 2.0F);
|
||||
this.humidity = MathHelper.clamp(humidity, 0.0F, 2.0F);
|
||||
|
||||
}
|
||||
|
||||
public ImmutableClimateState(NBTTagCompound compound) {
|
||||
float temperature = compound.getFloat(TEMPERATURE_NBT_KEY);
|
||||
float humidity = compound.getFloat(HUMIDITY_NBT_KEY);
|
||||
this.temperature = MathHelper.clamp(temperature, 0.0F, 2.0F);
|
||||
this.humidity = MathHelper.clamp(humidity, 0.0F, 2.0F);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound compound) {
|
||||
compound.setFloat(TEMPERATURE_NBT_KEY, temperature);
|
||||
compound.setFloat(HUMIDITY_NBT_KEY, humidity);
|
||||
return compound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getTemperature() {
|
||||
return temperature;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getHumidity() {
|
||||
return humidity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImmutableClimateState addTemperature(float temperature){
|
||||
return new ImmutableClimateState(this.temperature + temperature, humidity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImmutableClimateState addHumidity(float humidity){
|
||||
return new ImmutableClimateState(this.temperature, this.humidity + humidity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImmutableClimateState remove(IClimateState state) {
|
||||
return new ImmutableClimateState(temperature - state.getTemperature(), humidity - state.getHumidity());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImmutableClimateState add(IClimateState state) {
|
||||
return new ImmutableClimateState(temperature + state.getTemperature(), humidity + state.getHumidity());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImmutableClimateState toImmutable(){
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClimateState toMutable(){
|
||||
return new ClimateState(temperature, humidity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if(!(obj instanceof IClimateState)){
|
||||
return false;
|
||||
}
|
||||
IClimateState otherState = (IClimateState) obj;
|
||||
return otherState.getTemperature() == temperature && otherState.getHumidity() == humidity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Float.hashCode(temperature) + Float.hashCode(humidity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return Objects.toStringHelper(this).add("temperature", temperature).add("humidity", humidity).toString();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,10 +5,11 @@
|
||||
******************************************************************************/
|
||||
@ParametersAreNonnullByDefault
|
||||
@MethodsReturnNonnullByDefault
|
||||
@API(apiVersion = "2.1.0", owner = "Forestry", provides = "ForestryAPI|climate")
|
||||
@API(apiVersion = "5.0.0", owner = "Forestry", provides = "ForestryAPI|climate")
|
||||
package forestry.api.climate;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
|
||||
import mcp.MethodsReturnNonnullByDefault;
|
||||
import net.minecraftforge.fml.common.API;
|
||||
|
||||
import mcp.MethodsReturnNonnullByDefault;
|
||||
@@ -1,3 +1,8 @@
|
||||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.core;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
@@ -9,12 +9,4 @@ public class CamouflageManager {
|
||||
|
||||
public static ICamouflageAccess camouflageAccess;
|
||||
|
||||
public static final String BLOCK = "block";
|
||||
|
||||
public static final String GLASS = "glass";
|
||||
|
||||
public static final String DOOR = "door";
|
||||
|
||||
public static final String NONE = "none";
|
||||
|
||||
}
|
||||
@@ -20,6 +20,8 @@ public enum EnumHumidity {
|
||||
*/
|
||||
DAMP("Damp");
|
||||
|
||||
public static final EnumHumidity[] VALUES = values();
|
||||
|
||||
public final String name;
|
||||
|
||||
EnumHumidity(String name) {
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
******************************************************************************/
|
||||
package forestry.api.core;
|
||||
|
||||
import forestry.api.climate.IClimateState;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
@@ -73,7 +74,8 @@ public enum EnumTemperature {
|
||||
if (BiomeHelper.isBiomeHellish(biome)) {
|
||||
return HELLISH;
|
||||
}
|
||||
float temperature = ForestryAPI.climateManager.getInfo(world, pos).getTemperature();
|
||||
IClimateState state = ForestryAPI.climateManager.getClimateState(world, pos);
|
||||
float temperature = state.getTemperature();
|
||||
return getFromValue(temperature);
|
||||
}
|
||||
}
|
||||
@@ -7,11 +7,13 @@ package forestry.api.core;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.climate.IClimateFactory;
|
||||
import forestry.api.climate.IClimateManager;
|
||||
import forestry.api.farming.IFarmRegistry;
|
||||
import forestry.api.farming.ISimpleFarmLogic;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
/**
|
||||
* Forestry's API is divided into several subcategories to make it easier to understand.
|
||||
@@ -48,6 +50,12 @@ public class ForestryAPI {
|
||||
public static IModelManager modelManager;
|
||||
|
||||
public static IClimateManager climateManager;
|
||||
|
||||
/**
|
||||
* A factory to create climate related things.
|
||||
* @since 5.3.4
|
||||
*/
|
||||
public static IClimateFactory climateFactory;
|
||||
|
||||
/**
|
||||
* A registry for register fertilizers, {@link IFarmabeles}s and {@link ISimpleFarmLogic}s
|
||||
|
||||
@@ -7,6 +7,8 @@ package forestry.api.core;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface ICamouflageAccess {
|
||||
@@ -16,21 +18,20 @@ public interface ICamouflageAccess {
|
||||
*
|
||||
* @param itemHandler The handler that is to register.
|
||||
*/
|
||||
void registerCamouflageItemHandler(ICamouflageItemHandler itemHandler);
|
||||
void registerItemHandler(ICamouflageItemHandler itemHandler);
|
||||
|
||||
/**
|
||||
* @return A list of all item camouflage handler's that are registered for that camouflage type.
|
||||
*/
|
||||
List<ICamouflageItemHandler> getCamouflageItemHandler(String type);
|
||||
List<ICamouflageItemHandler> getItemHandlers();
|
||||
|
||||
void addItemToBlackList(String type, ItemStack camouflageBlock);
|
||||
void addItemToBlackList(ItemStack camouflageBlock);
|
||||
|
||||
void addModIdToBlackList(String type, String modID);
|
||||
void addModIdToBlackList(String modID);
|
||||
|
||||
boolean isItemBlackListed(String type, ItemStack camouflageBlock);
|
||||
|
||||
ICamouflageItemHandler getNoneItemHandler();
|
||||
boolean isItemBlackListed(ItemStack camouflageBlock);
|
||||
|
||||
ICamouflageItemHandler getHandlerFromItem(ItemStack stack);
|
||||
@Nullable
|
||||
ICamouflageItemHandler getHandler(ItemStack stack);
|
||||
|
||||
}
|
||||
@@ -12,22 +12,17 @@ public interface ICamouflageHandler extends ILocatable {
|
||||
/**
|
||||
* @return The item of the block that is the camouflage of this handler for the type.
|
||||
*/
|
||||
ItemStack getCamouflageBlock(String type);
|
||||
ItemStack getCamouflageBlock();
|
||||
|
||||
/**
|
||||
* @return The default camouflage block item for the type.
|
||||
*/
|
||||
ItemStack getDefaultCamouflageBlock(String type);
|
||||
|
||||
/**
|
||||
* @return True if the handler can handle this type of camouflage.
|
||||
*/
|
||||
boolean canHandleType(String type);
|
||||
ItemStack getDefaultCamouflageBlock();
|
||||
|
||||
/**
|
||||
* Set the camouflage block item for the type.
|
||||
*
|
||||
* @return True if the block has chanced.
|
||||
*/
|
||||
boolean setCamouflageBlock(String type, ItemStack camouflageBlock, boolean sendClientUpdate);
|
||||
boolean setCamouflageBlock(ItemStack camouflageBlock, boolean sendClientUpdate);
|
||||
}
|
||||
@@ -5,21 +5,19 @@
|
||||
******************************************************************************/
|
||||
package forestry.api.core;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
public interface ICamouflageItemHandler {
|
||||
|
||||
|
||||
boolean canHandle(ItemStack stack);
|
||||
|
||||
String getType();
|
||||
|
||||
float getLightTransmittance(ItemStack stack, ICamouflageHandler camouflageHandler);
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
Pair<IBlockState, IBakedModel> getModel(ItemStack stack, ICamouflageHandler camouflageHandler, ICamouflagedTile camouflageTile);
|
||||
|
||||
|
||||
@@ -5,12 +5,6 @@
|
||||
******************************************************************************/
|
||||
package forestry.api.core;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
public interface ICamouflagedTile {
|
||||
|
||||
String getCamouflageType();
|
||||
|
||||
BlockPos getCoordinates();
|
||||
public interface ICamouflagedTile extends ILocatable {
|
||||
|
||||
}
|
||||
@@ -1,23 +1,20 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.core;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
* Interface for things, that have a location.
|
||||
* Must not be named "getWorld" and "getPos" to avoid
|
||||
* SpecialSource issue https://github.com/md-5/SpecialSource/issues/12
|
||||
*/
|
||||
public interface ILocatable {
|
||||
BlockPos getCoordinates();
|
||||
|
||||
/**
|
||||
* Must not be named "getWorld" to avoid SpecialSource issue https://github.com/md-5/SpecialSource/issues/12
|
||||
*/
|
||||
World getWorldObj();
|
||||
}
|
||||
@@ -34,6 +34,8 @@ public interface IModelBaker {
|
||||
|
||||
void addBakedModel(@Nullable IBlockState state, IBakedModel model);
|
||||
|
||||
void addBakedModelPost(@Nullable IBlockState state, IBakedModel model);
|
||||
|
||||
void addFace(EnumFacing facing, TextureAtlasSprite sprite);
|
||||
|
||||
void setModelState(@Nullable IModelState modelState);
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.core;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
@@ -1,12 +1,7 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.core;
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
******************************************************************************/
|
||||
package forestry.api.farming;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collection;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -22,7 +23,10 @@ public interface IFarmRegistry {
|
||||
|
||||
/**
|
||||
* Can be used to create a simple version of a farm logic, like the vanilla vegetable or wheat farm logic.
|
||||
*
|
||||
* @return Null if the farming plugin is not active.
|
||||
*/
|
||||
@Nullable
|
||||
IFarmLogic createLogic(ISimpleFarmLogic simpleFarmLogic);
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.genetics;
|
||||
|
||||
import forestry.api.arboriculture.IAlleleFruit;
|
||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.genetics;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.genetics;
|
||||
|
||||
import net.minecraft.util.math.Vec3i;
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.genetics;
|
||||
|
||||
public interface IAlleleProperty<A extends IAlleleProperty<A>> extends IAllele, Comparable<A> {
|
||||
|
||||
@@ -207,7 +207,7 @@ public interface IAlleleRegistry {
|
||||
* @param handler IAlleleHandler to register.
|
||||
*/
|
||||
void registerAlleleHandler(IAlleleHandler handler);
|
||||
|
||||
|
||||
/* BLACKLIST */
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.genetics;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -1,12 +1,7 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.genetics;
|
||||
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.genetics;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
@@ -1,11 +1,17 @@
|
||||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.genetics;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
/**
|
||||
* @author Nedelosk
|
||||
* @since 5.12.16
|
||||
|
||||
@@ -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 forestry.api.multiblock.IGreenhouseController;
|
||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
|
||||
public class GreenhouseEvents extends Event {
|
||||
|
||||
public final IGreenhouseController controller;
|
||||
|
||||
public GreenhouseEvents(IGreenhouseController state) {
|
||||
this.controller = state;
|
||||
}
|
||||
|
||||
public static class InternalBlockEvent extends GreenhouseEvents {
|
||||
public final IInternalBlock internalBlock;
|
||||
|
||||
public InternalBlockEvent(IGreenhouseController controller, IInternalBlock internalBlock) {
|
||||
super(controller);
|
||||
|
||||
this.internalBlock = internalBlock;
|
||||
}
|
||||
}
|
||||
|
||||
public static class CreateInternalBlockEvent extends InternalBlockEvent {
|
||||
public CreateInternalBlockEvent(IGreenhouseController controller, IInternalBlock internalBlock) {
|
||||
super(controller, internalBlock);
|
||||
}
|
||||
}
|
||||
|
||||
public static class CheckInternalBlockFaceEvent extends InternalBlockEvent {
|
||||
public final IInternalBlockFace face;
|
||||
|
||||
public CheckInternalBlockFaceEvent(IGreenhouseController controller, IInternalBlock internalBlock, IInternalBlockFace face) {
|
||||
super(controller, internalBlock);
|
||||
|
||||
this.face = face;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -8,5 +8,7 @@ package forestry.api.greenhouse;
|
||||
public class GreenhouseManager {
|
||||
|
||||
public static IGreenhouseHelper greenhouseHelper;
|
||||
|
||||
public static IGreenhouseBlockManager greenhouseBlockManager;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*******************************************************************************
|
||||
* 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();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*******************************************************************************
|
||||
* 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();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*******************************************************************************
|
||||
* 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();
|
||||
}
|
||||
@@ -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.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);
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/*******************************************************************************
|
||||
* 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();
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/*******************************************************************************
|
||||
* 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);
|
||||
}
|
||||
@@ -5,17 +5,29 @@
|
||||
******************************************************************************/
|
||||
package forestry.api.greenhouse;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collection;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import forestry.api.climate.IClimateModifier;
|
||||
import forestry.api.multiblock.IGreenhouseController;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface IGreenhouseHelper {
|
||||
|
||||
/**
|
||||
* @return A {@link IGreenhouseController} of a greenhouse, when the pos is a greenhouse
|
||||
*/
|
||||
@Nullable
|
||||
IGreenhouseController getGreenhouseController(World world, BlockPos pos);
|
||||
|
||||
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,26 +5,43 @@
|
||||
******************************************************************************/
|
||||
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;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface IGreenhouseHousing extends IErrorLogicSource {
|
||||
|
||||
EnumTemperature getTemperature();
|
||||
|
||||
EnumHumidity getHumidity();
|
||||
|
||||
float getExactTemperature();
|
||||
|
||||
float getExactHumidity();
|
||||
|
||||
public interface IGreenhouseHousing extends IErrorLogicSource, IClimateHousing{
|
||||
|
||||
/**
|
||||
* Must not be named "getWorld" to avoid SpecialSource issue https://github.com/md-5/SpecialSource/issues/12
|
||||
*
|
||||
* @return The world in that the housing is.
|
||||
* @return The current tempreture as an enum.
|
||||
*/
|
||||
World getWorldObj();
|
||||
|
||||
EnumTemperature getTemperature();
|
||||
|
||||
/**
|
||||
* @return The current humidity as an enum.
|
||||
*/
|
||||
EnumHumidity getHumidity();
|
||||
|
||||
/**
|
||||
* @return The current tempreture as an float. Range: 0.0F ~ 2.0F
|
||||
*/
|
||||
float getExactTemperature();
|
||||
|
||||
/**
|
||||
* @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();
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/*******************************************************************************
|
||||
* 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();
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
/*******************************************************************************
|
||||
* 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.core.INbtReadable;
|
||||
import forestry.api.core.INbtWritable;
|
||||
|
||||
public interface IGreenhouseLogic extends INbtReadable, INbtWritable{
|
||||
|
||||
void work(int ticks);
|
||||
|
||||
String getUID();
|
||||
|
||||
}
|
||||
+4
-12
@@ -5,18 +5,10 @@
|
||||
******************************************************************************/
|
||||
package forestry.api.greenhouse;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collection;
|
||||
import forestry.api.multiblock.IGreenhouseController;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
public interface IInternalBlock {
|
||||
|
||||
BlockPos getPos();
|
||||
|
||||
@Nullable
|
||||
IInternalBlock getRoot();
|
||||
|
||||
Collection<IInternalBlockFace> getFaces();
|
||||
public interface IGreenhouseLogicFactory {
|
||||
|
||||
IGreenhouseLogic createLogic(IGreenhouseController controller);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
/*******************************************************************************
|
||||
* 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();
|
||||
}
|
||||
+4
-11
@@ -5,17 +5,10 @@
|
||||
******************************************************************************/
|
||||
package forestry.api.greenhouse;
|
||||
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
public interface IInternalBlockFace {
|
||||
|
||||
boolean isTested();
|
||||
|
||||
void setTested(boolean tested);
|
||||
|
||||
EnumFacing getFace();
|
||||
|
||||
BlockPos getPos();
|
||||
|
||||
public interface IGreenhouseProviderListener {
|
||||
|
||||
void onCheckPosition(BlockPos pos);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
/*******************************************************************************
|
||||
* 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);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
/*******************************************************************************
|
||||
* 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.Objects;
|
||||
|
||||
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 Objects.toStringHelper(this).add("x", this.getX()).add("z", this.getZ()).toString();
|
||||
}
|
||||
}
|
||||
@@ -10,5 +10,6 @@ package forestry.api.greenhouse;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
|
||||
import mcp.MethodsReturnNonnullByDefault;
|
||||
import net.minecraftforge.fml.common.API;
|
||||
|
||||
import mcp.MethodsReturnNonnullByDefault;
|
||||
@@ -1,12 +1,7 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.lepidopterology;
|
||||
|
||||
|
||||
@@ -1,12 +1,7 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.lepidopterology;
|
||||
|
||||
|
||||
@@ -1,12 +1,7 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.lepidopterology;
|
||||
|
||||
|
||||
@@ -1,12 +1,7 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.lepidopterology;
|
||||
|
||||
|
||||
@@ -1,12 +1,7 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.lepidopterology;
|
||||
|
||||
|
||||
@@ -5,14 +5,7 @@
|
||||
******************************************************************************/
|
||||
package forestry.api.multiblock;
|
||||
|
||||
import forestry.api.climate.IClimateControlProvider;
|
||||
import forestry.api.climate.IClimateSourceProvider;
|
||||
import forestry.api.climate.IClimatiserDefinition;
|
||||
import forestry.api.greenhouse.IGreenhouseListener;
|
||||
import forestry.api.lepidopterology.IButterflyCocoon;
|
||||
import forestry.api.lepidopterology.IButterflyNursery;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
|
||||
public interface IGreenhouseComponent<T extends IMultiblockLogicGreenhouse> extends IMultiblockComponent {
|
||||
@Override
|
||||
@@ -21,22 +14,7 @@ public interface IGreenhouseComponent<T extends IMultiblockLogicGreenhouse> exte
|
||||
interface Listener extends IGreenhouseComponent {
|
||||
IGreenhouseListener getGreenhouseListener();
|
||||
}
|
||||
|
||||
interface ClimateControl extends IGreenhouseComponent, IClimateControlProvider {
|
||||
|
||||
}
|
||||
|
||||
interface Door extends IGreenhouseComponent {
|
||||
}
|
||||
|
||||
interface Climatiser extends IGreenhouseComponent, IClimateSourceProvider {
|
||||
IClimatiserDefinition getDefinition();
|
||||
}
|
||||
|
||||
interface Nursery extends IGreenhouseComponent, IButterflyNursery {
|
||||
void addCocoonLoot(IButterflyCocoon cocoon, NonNullList<ItemStack> loot);
|
||||
}
|
||||
|
||||
|
||||
interface Active extends IGreenhouseComponent {
|
||||
void updateServer(int tickCount);
|
||||
|
||||
|
||||
@@ -5,35 +5,19 @@
|
||||
******************************************************************************/
|
||||
package forestry.api.multiblock;
|
||||
|
||||
import java.util.Set;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
import forestry.api.climate.IClimateControlProvider;
|
||||
import forestry.api.climate.IClimateRegion;
|
||||
import forestry.api.core.ICamouflageHandler;
|
||||
import forestry.api.greenhouse.IGreenhouseHousing;
|
||||
import forestry.api.greenhouse.IInternalBlock;
|
||||
import forestry.api.lepidopterology.IButterfly;
|
||||
import forestry.api.lepidopterology.IButterflyCocoon;
|
||||
|
||||
public interface IGreenhouseController extends IMultiblockController, IGreenhouseHousing, ICamouflageHandler, IClimateControlProvider {
|
||||
public interface IGreenhouseController extends IMultiblockController, IGreenhouseHousing, ICamouflageHandler {
|
||||
|
||||
/**
|
||||
* @return All internal blocks of the greenhouse.
|
||||
*
|
||||
* @return the position of the block at the top of the greenhouse structure that shows the state of the greenhouse.
|
||||
*/
|
||||
Set<IInternalBlock> getInternalBlocks();
|
||||
BlockPos getCenterCoordinates();
|
||||
|
||||
/**
|
||||
* spawns a butterfly in a greenhouse
|
||||
* @return true if it has spawned it, and false if it has not
|
||||
*/
|
||||
boolean spawnButterfly(IGreenhouseComponent.Nursery nursery);
|
||||
void setCenterCoordinates(BlockPos coordinates);
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #spawnButterfly(IButterflyCocoon)}
|
||||
*/
|
||||
@Deprecated
|
||||
boolean spawnButterfly(IButterfly butterfly);
|
||||
|
||||
IClimateRegion getRegion();
|
||||
|
||||
}
|
||||
@@ -1,12 +1,7 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.recipes;
|
||||
|
||||
|
||||
@@ -1,12 +1,7 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.recipes;
|
||||
|
||||
|
||||
@@ -49,4 +49,33 @@ public interface IFermenterManager extends ICraftingProvider<IFermenterRecipe> {
|
||||
* @throws NullPointerException if resource, output or liquid is null
|
||||
*/
|
||||
void addRecipe(ItemStack resource, int fermentationValue, float modifier, FluidStack output);
|
||||
|
||||
/**
|
||||
* Add a recipe to the fermenter
|
||||
*
|
||||
* @param resource String representing the resource as a {@link net.minecraftforge.oredict.OreDictionary} name.
|
||||
* @param fermentationValue Value of the given resource, i.e. how much needs
|
||||
* to be fermented for the output to be deposited into the product tank.
|
||||
* @param modifier Modifies the amount of liquid output per work cycle.
|
||||
* (water = 1.0f, honey = 1.5f)
|
||||
* @param output LiquidStack representing output liquid. Amount is
|
||||
* determined by fermentationValue*modifier.
|
||||
* @param liquid LiquidStack representing resource liquid and amount.
|
||||
* @throws NullPointerException if resource, output or liquid is null
|
||||
*/
|
||||
void addRecipe(String resource, int fermentationValue, float modifier, FluidStack output, FluidStack liquid);
|
||||
|
||||
/**
|
||||
* Add a recipe to the fermenter. Defaults to water as input liquid.
|
||||
*
|
||||
* @param resource String representing the resource as a {@link net.minecraftforge.oredict.OreDictionary} name.
|
||||
* @param modifier Modifies the amount of liquid output per work cycle.
|
||||
* (water = 1.0f, honey = 1.5f)
|
||||
* @param fermentationValue Value of the given resource, i.e. how much needs
|
||||
* to be fermented for the output to be deposited into the product tank.
|
||||
* @param output LiquidStack representing output liquid. Amount is
|
||||
* determined by fermentationValue*modifier.
|
||||
* @throws NullPointerException if resource, output or liquid is null
|
||||
*/
|
||||
void addRecipe(String resource, int fermentationValue, float modifier, FluidStack output);
|
||||
}
|
||||
@@ -5,16 +5,26 @@
|
||||
******************************************************************************/
|
||||
package forestry.api.recipes;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public interface IFermenterRecipe extends IForestryRecipe {
|
||||
public interface IFermenterRecipe extends IForestryRecipe, Comparable<IFermenterRecipe> {
|
||||
|
||||
/**
|
||||
* @return ItemStack representing the input resource.
|
||||
*/
|
||||
ItemStack getResource();
|
||||
|
||||
/**
|
||||
* @return String representing the input resource as a {@link net.minecraftforge.oredict.OreDictionary} name.
|
||||
*/
|
||||
@Nullable
|
||||
String getResourceOreName();
|
||||
|
||||
/**
|
||||
* @return FluidStack representing the input fluid resource.
|
||||
*/
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.storage;
|
||||
|
||||
import java.util.function.Predicate;
|
||||
|
||||
@@ -22,9 +22,11 @@ import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.properties.PropertyEnum;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.client.renderer.block.statemap.StateMapperBase;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
@@ -38,6 +40,13 @@ import net.minecraftforge.client.model.ModelLoader;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.properties.PropertyEnum;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.api.core.IModelManager;
|
||||
import forestry.api.core.IStateMapperRegister;
|
||||
import forestry.api.core.Tabs;
|
||||
@@ -56,6 +65,7 @@ import forestry.core.blocks.BlockStructure;
|
||||
import forestry.core.tiles.IActivatable;
|
||||
import forestry.core.tiles.TileUtil;
|
||||
import forestry.core.utils.BlockUtil;
|
||||
import forestry.core.utils.ItemTooltipUtil;
|
||||
import forestry.core.utils.NetworkUtil;
|
||||
import forestry.core.utils.Translator;
|
||||
|
||||
@@ -263,6 +273,10 @@ public abstract class BlockAlveary extends BlockStructure implements IStateMappe
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, @Nullable World world, List<String> tooltip, ITooltipFlag advanced) {
|
||||
tooltip.add(Translator.translateToLocal("tile.for.alveary.tooltip"));
|
||||
if(GuiScreen.isShiftKeyDown()){
|
||||
tooltip.add(Translator.translateToLocal("tile.for.alveary.tooltip"));
|
||||
}else{
|
||||
ItemTooltipUtil.addShiftInformation(stack, world, tooltip, advanced.isAdvanced());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,14 @@ import java.util.Arrays;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.apache.commons.lang3.text.WordUtils;
|
||||
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraftforge.common.BiomeDictionary;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
import forestry.api.apiculture.BeeManager;
|
||||
import forestry.api.apiculture.EnumBeeChromosome;
|
||||
import forestry.api.apiculture.EnumBeeType;
|
||||
@@ -36,11 +44,6 @@ import forestry.core.PluginCore;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.genetics.alleles.AlleleHelper;
|
||||
import forestry.core.genetics.alleles.EnumAllele;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.BiomeDictionary;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import org.apache.commons.lang3.text.WordUtils;
|
||||
|
||||
public enum BeeDefinition implements IBeeDefinition {
|
||||
/* HONEY BRANCH */
|
||||
|
||||
@@ -21,11 +21,9 @@ import forestry.api.apiculture.IBeeListener;
|
||||
import forestry.api.apiculture.IBeeModifier;
|
||||
import forestry.api.apiculture.IBeekeepingLogic;
|
||||
import forestry.api.climate.IClimateControlled;
|
||||
import forestry.api.climate.IClimatePosition;
|
||||
import forestry.api.core.BiomeHelper;
|
||||
import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.multiblock.IAlvearyComponent;
|
||||
import forestry.api.multiblock.IMultiblockComponent;
|
||||
import forestry.apiculture.AlvearyBeeModifier;
|
||||
@@ -429,10 +427,6 @@ public class AlvearyController extends RectangularMultiblockControllerBase imple
|
||||
data.writeVarInt(beekeepingLogic.getBeeProgressPercent());
|
||||
data.writeVarInt(Math.round(tempChange * 100));
|
||||
data.writeVarInt(Math.round(humidChange * 100));
|
||||
IClimatePosition position = ForestryAPI.climateManager.getPosition(world, getReferenceCoord());
|
||||
if (position != null) {
|
||||
ClimateUtil.writePositionData(position, data);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -440,9 +434,5 @@ public class AlvearyController extends RectangularMultiblockControllerBase imple
|
||||
breedingProgressPercent = data.readVarInt();
|
||||
tempChange = data.readVarInt() / 100.0F;
|
||||
humidChange = data.readVarInt() / 100.0F;
|
||||
IClimatePosition position = ForestryAPI.climateManager.getPosition(world, getReferenceCoord());
|
||||
if (position != null) {
|
||||
ClimateUtil.readPositionData(position, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,22 @@ package forestry.apiculture.multiblock;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.climate.IClimateControlled;
|
||||
import forestry.api.multiblock.IAlvearyComponent;
|
||||
import forestry.apiculture.blocks.BlockAlvearyType;
|
||||
@@ -24,20 +40,8 @@ import forestry.core.fluids.FluidHelper;
|
||||
import forestry.core.fluids.Fluids;
|
||||
import forestry.core.fluids.TankManager;
|
||||
import forestry.core.inventory.IInventoryAdapter;
|
||||
import forestry.core.recipes.HygroregulatorRecipe;
|
||||
import forestry.core.tiles.ILiquidTankTile;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class TileAlvearyHygroregulator extends TileAlveary implements IInventory, ILiquidTankTile, IAlvearyComponent.Climatiser {
|
||||
private final HygroregulatorRecipe[] recipes;
|
||||
@@ -186,18 +190,4 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory
|
||||
public Container getContainer(EntityPlayer player, int data) {
|
||||
return new ContainerAlvearyHygroregulator(player.inventory, this);
|
||||
}
|
||||
|
||||
private static class HygroregulatorRecipe {
|
||||
public final FluidStack liquid;
|
||||
public final int transferTime;
|
||||
public final float humidChange;
|
||||
public final float tempChange;
|
||||
|
||||
public HygroregulatorRecipe(FluidStack liquid, int transferTime, float humidChange, float tempChange) {
|
||||
this.liquid = liquid;
|
||||
this.transferTime = transferTime;
|
||||
this.humidChange = humidChange;
|
||||
this.tempChange = tempChange;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,10 +16,8 @@ import com.mojang.authlib.GameProfile;
|
||||
import forestry.api.apiculture.BeeManager;
|
||||
import forestry.api.apiculture.IBeeHousing;
|
||||
import forestry.api.apiculture.IBeekeepingLogic;
|
||||
import forestry.api.climate.IClimatePosition;
|
||||
import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.apiculture.gui.IGuiBeeHousingDelegate;
|
||||
import forestry.core.network.IStreamableGui;
|
||||
import forestry.core.network.PacketBufferForestry;
|
||||
@@ -162,19 +160,11 @@ public abstract class TileBeeHousingBase extends TileBase implements IBeeHousing
|
||||
@Override
|
||||
public void writeGuiData(PacketBufferForestry data) {
|
||||
data.writeVarInt(beeLogic.getBeeProgressPercent());
|
||||
IClimatePosition position = ForestryAPI.climateManager.getPosition(world, getPos());
|
||||
if (position != null) {
|
||||
ClimateUtil.writePositionData(position, data);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readGuiData(PacketBufferForestry data) throws IOException {
|
||||
breedingProgressPercent = data.readVarInt();
|
||||
IClimatePosition position = ForestryAPI.climateManager.getPosition(world, getPos());
|
||||
if (position != null) {
|
||||
ClimateUtil.readPositionData(position, data);
|
||||
}
|
||||
}
|
||||
|
||||
// / IBEEHOUSING
|
||||
|
||||
@@ -1,77 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.arboriculture;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import net.minecraft.block.BlockDoor;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.BlockModelShapes;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.core.CamouflageManager;
|
||||
import forestry.api.core.ICamouflageHandler;
|
||||
import forestry.api.core.ICamouflageItemHandler;
|
||||
import forestry.api.core.ICamouflagedTile;
|
||||
import forestry.arboriculture.items.ItemBlockWoodDoor;
|
||||
|
||||
public class CamouflageHandlerArbDoor implements ICamouflageItemHandler {
|
||||
|
||||
@Override
|
||||
public boolean canHandle(ItemStack stack) {
|
||||
return stack.getItem() instanceof ItemBlockWoodDoor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return CamouflageManager.DOOR;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getLightTransmittance(ItemStack stack, ICamouflageHandler camouflageHandler) {
|
||||
return 0F;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public Pair<IBlockState, IBakedModel> getModel(ItemStack stack, ICamouflageHandler camouflageHandler, ICamouflagedTile camouflageTile) {
|
||||
Preconditions.checkArgument(!stack.isEmpty(), "Stack must not be empty");
|
||||
Preconditions.checkArgument(stack.getItem() instanceof ItemBlockWoodDoor, "Item must be ItemBlockWoodDoor");
|
||||
|
||||
World world = camouflageHandler.getWorldObj();
|
||||
BlockPos pos = camouflageTile.getCoordinates();
|
||||
IBlockState blockState = world.getBlockState(pos);
|
||||
IBlockState currentState = blockState.getActualState(world, pos);
|
||||
|
||||
ItemBlockWoodDoor itemDoor = (ItemBlockWoodDoor) stack.getItem();
|
||||
|
||||
IBlockState doorState = itemDoor.getBlock().getDefaultState()
|
||||
.withProperty(BlockDoor.FACING, currentState.getValue(BlockDoor.FACING))
|
||||
.withProperty(BlockDoor.HINGE, currentState.getValue(BlockDoor.HINGE))
|
||||
.withProperty(BlockDoor.OPEN, currentState.getValue(BlockDoor.OPEN))
|
||||
.withProperty(BlockDoor.POWERED, currentState.getValue(BlockDoor.POWERED))
|
||||
.withProperty(BlockDoor.HALF, currentState.getValue(BlockDoor.HALF));
|
||||
|
||||
BlockModelShapes modelShapes = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes();
|
||||
|
||||
return Pair.of(doorState, modelShapes.getModelForState(doorState));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -26,6 +26,7 @@ import net.minecraft.block.BlockLeaves;
|
||||
import net.minecraft.block.BlockNewLeaf;
|
||||
import net.minecraft.block.BlockOldLeaf;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.passive.EntityVillager;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
@@ -40,11 +41,13 @@ import net.minecraftforge.client.event.ModelBakeEvent;
|
||||
import net.minecraftforge.client.event.TextureStitchEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.capabilities.CapabilityManager;
|
||||
import net.minecraftforge.event.entity.player.EntityItemPickupEvent;
|
||||
import net.minecraftforge.event.world.BlockEvent;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import net.minecraftforge.fml.common.SidedProxy;
|
||||
import net.minecraftforge.fml.common.event.FMLInterModComms.IMCMessage;
|
||||
import net.minecraftforge.fml.common.eventhandler.EventPriority;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.registry.ForgeRegistries;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
@@ -60,7 +63,6 @@ import forestry.api.arboriculture.ITree;
|
||||
import forestry.api.arboriculture.IWoodType;
|
||||
import forestry.api.arboriculture.TreeManager;
|
||||
import forestry.api.arboriculture.WoodBlockKind;
|
||||
import forestry.api.core.CamouflageManager;
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.core.IArmorNaturalist;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
@@ -218,14 +220,6 @@ public class PluginArboriculture extends BlankForestryPlugin {
|
||||
|
||||
// Commands
|
||||
PluginCore.rootCommand.addChildCommand(new CommandTree());
|
||||
|
||||
CamouflageManager.camouflageAccess.registerCamouflageItemHandler(new CamouflageHandlerArbDoor());
|
||||
TreeManager.pileWalls.add(new CharcoalPileWall(Blocks.CLAY, 3));
|
||||
TreeManager.pileWalls.add(new CharcoalPileWall(PluginArboriculture.getBlocks().loam, 5));
|
||||
TreeManager.pileWalls.add(new CharcoalPileWall(Blocks.END_STONE, 6));
|
||||
TreeManager.pileWalls.add(new CharcoalPileWall(Blocks.END_BRICKS, 6));
|
||||
TreeManager.pileWalls.add(new CharcoalPileWall(Blocks.DIRT, 2));
|
||||
TreeManager.pileWalls.add(new CharcoalPileWall(Blocks.NETHERRACK, 4));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -277,6 +271,18 @@ public class PluginArboriculture extends BlankForestryPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postInit() {
|
||||
TreeManager.pileWalls.add(new CharcoalPileWall(Blocks.CLAY, 3));
|
||||
TreeManager.pileWalls.add(new CharcoalPileWall(PluginArboriculture.getBlocks().loam, 4));
|
||||
TreeManager.pileWalls.add(new CharcoalPileWall(Blocks.END_STONE, 6));
|
||||
TreeManager.pileWalls.add(new CharcoalPileWall(Blocks.END_BRICKS, 6));
|
||||
TreeManager.pileWalls.add(new CharcoalPileWall(Blocks.DIRT, 2));
|
||||
TreeManager.pileWalls.add(new CharcoalPileWall(Blocks.GRAVEL, 1));
|
||||
TreeManager.pileWalls.add(new CharcoalPileWall(Blocks.NETHERRACK, 3));
|
||||
TreeManager.pileWalls.add(new CharcoalPileWall(PluginCore.getBlocks().ashBrick, 5));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerCrates() {
|
||||
ICrateRegistry crateRegistry = StorageManager.crateRegistry;
|
||||
@@ -459,9 +465,19 @@ public class PluginArboriculture extends BlankForestryPlugin {
|
||||
|
||||
//Wood Pile
|
||||
RecipeUtil.addShapelessRecipe("wood_pile", new ItemStack(blocks.woodPile), OreDictUtil.LOG_WOOD, OreDictUtil.LOG_WOOD, OreDictUtil.LOG_WOOD, OreDictUtil.LOG_WOOD);
|
||||
RecipeUtil.addShapelessRecipe("wood_pile_decorative", new ItemStack(blocks.woodPile), blocks.woodPileDecorative);
|
||||
RecipeUtil.addShapelessRecipe("decorative_wood_pile", new ItemStack(blocks.woodPileDecorative), blocks.woodPile);
|
||||
|
||||
//Charcoal
|
||||
RecipeUtil.addRecipe("charcoal_block", blocks.charcoal,
|
||||
"###",
|
||||
"###",
|
||||
"###",
|
||||
'#', new ItemStack(Items.COAL, 1, 1));
|
||||
RecipeUtil.addShapelessRecipe("charcoal", new ItemStack(Items.COAL, 9, 1), blocks.charcoal);
|
||||
|
||||
//Dirt Pile Block
|
||||
RecipeUtil.addShapelessRecipe("loam", new ItemStack(blocks.loam, 4), Items.CLAY_BALL, coreItems.compost, Items.CLAY_BALL, OreDictUtil.SAND, Items.CLAY_BALL, OreDictUtil.SAND, Items.CLAY_BALL, coreItems.compost, Items.CLAY_BALL);
|
||||
RecipeUtil.addShapelessRecipe("loam", new ItemStack(blocks.loam, 4), Items.CLAY_BALL, coreItems.fertilizerBio, Items.CLAY_BALL, OreDictUtil.SAND, Items.CLAY_BALL, OreDictUtil.SAND, Items.CLAY_BALL, coreItems.fertilizerBio, Items.CLAY_BALL);
|
||||
}
|
||||
|
||||
private static void registerAlleles() {
|
||||
|
||||
@@ -51,8 +51,10 @@ public abstract class BlockAbstractLeaves extends BlockLeaves implements IItemMo
|
||||
LeafDecayHelper.leafDecay(this, world, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract int getMetaFromState(IBlockState state);
|
||||
|
||||
@Override
|
||||
public abstract IBlockState getStateFromMeta(int meta);
|
||||
|
||||
@Override
|
||||
@@ -184,7 +186,7 @@ public abstract class BlockAbstractLeaves extends BlockLeaves implements IItemMo
|
||||
getLeafDrop(drops, world, playerProfile, pos, saplingModifier, fortune);
|
||||
this.drops.set(drops);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
|
||||
List<ItemStack> ret = this.drops.get();
|
||||
@@ -196,6 +198,6 @@ public abstract class BlockAbstractLeaves extends BlockLeaves implements IItemMo
|
||||
getLeafDrop(drops, (World) world, null, pos, 1.0f, fortune);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected abstract void getLeafDrop(NonNullList<ItemStack> drops, World world, @Nullable GameProfile playerProfile, BlockPos pos, float saplingModifier, int fortune);
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
package forestry.arboriculture.blocks;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.MapColor;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.PropertyInteger;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.statemap.StateMap;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.core.IItemModelRegister;
|
||||
import forestry.api.core.IModelManager;
|
||||
import forestry.api.core.IStateMapperRegister;
|
||||
import forestry.core.PluginCore;
|
||||
|
||||
public class BlockAsh extends Block implements IStateMapperRegister, IItemModelRegister {
|
||||
|
||||
public static final PropertyInteger AMOUNT = PropertyInteger.create("amount", 0, 15);
|
||||
|
||||
public BlockAsh() {
|
||||
super(Material.GROUND, MapColor.BLACK);
|
||||
setSoundType(SoundType.SAND);
|
||||
setHarvestLevel("shovel", 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockStateContainer createBlockState() {
|
||||
return new BlockStateContainer(this, AMOUNT);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void registerModel(Item item, IModelManager manager) {
|
||||
for(int i = 0;i < 16;i++){
|
||||
manager.registerItemModel(item, i, "ash_block");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(IBlockState state) {
|
||||
return getMetaFromState(state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetaFromState(IBlockState state) {
|
||||
return state.getValue(AMOUNT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getStateFromMeta(int meta) {
|
||||
return getDefaultState().withProperty(AMOUNT, meta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
|
||||
List<ItemStack> drops = new ArrayList<>();
|
||||
Random rand = world instanceof World ? ((World)world).rand : new Random();
|
||||
int amount = state.getValue(AMOUNT) + 9 + rand.nextInt(1 + fortune);
|
||||
drops.add(new ItemStack(Items.COAL, amount, 1));
|
||||
drops.add(new ItemStack(PluginCore.getItems().ash, 1 + rand.nextInt(amount / 4)));
|
||||
return drops;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void registerStateMapper() {
|
||||
ModelLoader.setCustomStateMapper(this, new StateMap.Builder().ignore(AMOUNT).build());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,30 +4,16 @@ import net.minecraft.block.Block;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.MapColor;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.PropertyInteger;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.statemap.StateMap;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.core.IItemModelRegister;
|
||||
import forestry.api.core.IModelManager;
|
||||
import forestry.api.core.IStateMapperRegister;
|
||||
import forestry.api.core.Tabs;
|
||||
|
||||
public class BlockCharcoal extends Block implements IStateMapperRegister, IItemModelRegister {
|
||||
|
||||
public static final PropertyInteger AMOUNT = PropertyInteger.create("amount", 0, 15);
|
||||
public class BlockCharcoal extends Block implements IItemModelRegister {
|
||||
|
||||
public BlockCharcoal() {
|
||||
super(Material.ROCK, MapColor.BLACK);
|
||||
@@ -35,43 +21,13 @@ public class BlockCharcoal extends Block implements IStateMapperRegister, IItemM
|
||||
setResistance(10.0F);
|
||||
setSoundType(SoundType.STONE);
|
||||
setCreativeTab(Tabs.tabArboriculture);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockStateContainer createBlockState() {
|
||||
return new BlockStateContainer(this, AMOUNT);
|
||||
setHarvestLevel("pickaxe", 1);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void registerModel(Item item, IModelManager manager) {
|
||||
for(int i = 0;i < 16;i++){
|
||||
manager.registerItemModel(item, i);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetaFromState(IBlockState state) {
|
||||
return state.getValue(AMOUNT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getStateFromMeta(int meta) {
|
||||
return getDefaultState().withProperty(AMOUNT, meta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
|
||||
if(state.getValue(AMOUNT) > 0){
|
||||
drops.add(new ItemStack(Items.COAL, state.getValue(AMOUNT) + 9, 1));
|
||||
}
|
||||
super.getDrops(drops, world, pos, state, fortune);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void registerStateMapper() {
|
||||
ModelLoader.setCustomStateMapper(this, new StateMap.Builder().ignore(AMOUNT).build());
|
||||
manager.registerItemModel(item, 0);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
package forestry.arboriculture.blocks;
|
||||
|
||||
import net.minecraft.block.BlockRotatedPillar;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.properties.PropertyEnum;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.Rotation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.core.IItemModelRegister;
|
||||
import forestry.api.core.IModelManager;
|
||||
import forestry.api.core.Tabs;
|
||||
|
||||
public class BlockDecorativeWoodPile extends BlockRotatedPillar implements IItemModelRegister {
|
||||
public static final PropertyEnum<EnumFacing.Axis> AXIS = PropertyEnum.<EnumFacing.Axis>create("axis", EnumFacing.Axis.class);
|
||||
|
||||
public BlockDecorativeWoodPile() {
|
||||
super(Material.WOOD);
|
||||
setSoundType(SoundType.WOOD);
|
||||
setHardness(1.5f);
|
||||
setCreativeTab(Tabs.tabArboriculture);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube(IBlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNormalCube(IBlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFullBlock(IBlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFireSpreadSpeed(IBlockAccess world, BlockPos pos, EnumFacing face) {
|
||||
return 12;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFlammable(IBlockAccess world, BlockPos pos, EnumFacing face) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFlammability(IBlockAccess world, BlockPos pos, EnumFacing face) {
|
||||
return 25;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void registerModel(Item item, IModelManager manager) {
|
||||
for(int i = 0;i < 3;i++) {
|
||||
manager.registerItemModel(item, i, "wood_pile");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean rotateBlock(net.minecraft.world.World world, BlockPos pos, EnumFacing axis) {
|
||||
net.minecraft.block.state.IBlockState state = world.getBlockState(pos);
|
||||
for (net.minecraft.block.properties.IProperty<?> prop : state.getProperties().keySet()) {
|
||||
if (prop.getName().equals("axis")) {
|
||||
world.setBlockState(pos, state.cycleProperty(prop));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public IBlockState withRotation(IBlockState state, Rotation rot) {
|
||||
switch (rot) {
|
||||
case COUNTERCLOCKWISE_90:
|
||||
case CLOCKWISE_90:
|
||||
|
||||
switch ((EnumFacing.Axis)state.getValue(AXIS)) {
|
||||
case X:
|
||||
return state.withProperty(AXIS, EnumFacing.Axis.Z);
|
||||
case Z:
|
||||
return state.withProperty(AXIS, EnumFacing.Axis.X);
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
||||
|
||||
public IBlockState getStateFromMeta(int meta) {
|
||||
return this.getDefaultState().withProperty(AXIS, EnumFacing.Axis.values()[meta]);
|
||||
}
|
||||
|
||||
public int getMetaFromState(IBlockState state) {
|
||||
return state.getValue(AXIS).ordinal();
|
||||
}
|
||||
|
||||
protected BlockStateContainer createBlockState()
|
||||
{
|
||||
return new BlockStateContainer(this, new IProperty[] {AXIS});
|
||||
}
|
||||
|
||||
protected ItemStack getSilkTouchDrop(IBlockState state)
|
||||
{
|
||||
return new ItemStack(Item.getItemFromBlock(this));
|
||||
}
|
||||
|
||||
public IBlockState getStateForPlacement(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer) {
|
||||
return super.getStateForPlacement(worldIn, pos, facing, hitX, hitY, hitZ, meta, placer).withProperty(AXIS, facing.getAxis());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -113,6 +113,7 @@ public abstract class BlockDefaultLeaves extends BlockAbstractLeaves {
|
||||
return i;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockStateContainer createBlockState() {
|
||||
return new BlockStateContainer(this, getVariant(), CHECK_DECAY, DECAYABLE);
|
||||
}
|
||||
|
||||
Loaded 100 of 413 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user