Rework sytem

This commit is contained in:
Nedelosk committed 2016-06-12 01:16:25 +02:00
1 parent 725d85181d
commit 2cd76bdad7
20 files changed
+353 -604

No files matched your search

@@ -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.climate;
@@ -5,8 +5,12 @@
******************************************************************************/
package forestry.api.core.climate;
import java.util.List;
import java.util.Map;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
@@ -16,8 +20,14 @@ public interface IClimateManager {
float getHumidity(World world, BlockPos pos);
void registerWorld(IClimateWorld climateWorld);
void addRegion(IClimateRegion region);
Map<Integer, IClimateWorld> getClimateWorlds();
void removeRegion(IClimateRegion region);
@Nullable
IClimateRegion getRegionForPos(World world, BlockPos pos);
@Nonnull
Map<Integer, List<IClimateRegion>> getRegions();
}
@@ -5,37 +5,30 @@
******************************************************************************/
package forestry.api.core.climate;
import java.util.List;
import javax.annotation.Nonnull;
import forestry.api.core.INbtReadable;
import forestry.api.core.INbtWritable;
import forestry.core.climate.IClimateHandler;
import net.minecraft.util.math.BlockPos;
public interface IClimatedPosition extends INbtReadable, INbtWritable {
public interface IClimatePosition extends INbtReadable, INbtWritable {
@Nonnull
IClimateWorld getClimateWorld();
IClimateRegion getClimateRegion();
@Nonnull
BlockPos getPos();
void addHandler(IClimateHandler climateHandler);
void removeHandler(IClimateHandler climateHandler);
void setTemperature(float temperature);
void addTemperature(float temperature);
float getTemperature();
void setHumidity(float humidity);
void addHumidity(float humidity);
float getHumidity();
List<IClimateHandler> getHandlers();
void updateClimate();
}
@@ -0,0 +1,27 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.core.climate;
import java.util.Map;
import javax.annotation.Nonnull;
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 {
@Nonnull
World getWorld();
void updateClimate();
@Nonnull
Map<BlockPos, IClimatePosition> getPositions();
}
@@ -0,0 +1,10 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.core.climate;
public interface IClimateSource {
}
@@ -1,88 +0,0 @@
package forestry.api.core.climate;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Nonnull;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.world.World;
public interface IClimateWorld {
@Nonnull
World getWorld();
int getDimensionID();
void updateClimate();
void addPositions(BlockPos minPos, BlockPos maxPos);
void addPosition(BlockPos pos);
void addPosition(IClimatedPosition position);
void addPositions(List<IClimatedPosition> positions);
IClimatedPosition getPosition(BlockPos pos);
IClimatedPosition createPosition(BlockPos pos);
void addChunk(ClimateChunk climateChunk);
void removeChunk(ChunkPos pos);
@Nonnull
Map<ChunkPos, ClimateChunk> getClimateChunks();
@Nonnull
List<ClimateChunk> getDirtyClimateChunks();
void addDirtyClimateChunk(ClimateChunk chunk);
public static class ClimateChunk{
@Nonnull
protected final Map<BlockPos, IClimatedPosition> climates;
@Nonnull
protected final IClimateWorld world;
@Nonnull
protected final ChunkPos chunkPos;
public ClimateChunk(@Nonnull IClimateWorld world, @Nonnull ChunkPos chunkPos) {
this.world = world;
this.chunkPos = chunkPos;
climates = new HashMap<>();
for(int x = chunkPos.getXStart();x < chunkPos.getXEnd();x++){
for(int y = 0;y < world.getWorld().getActualHeight();y++){
for(int z = chunkPos.getZStart();z < chunkPos.getZEnd();z++){
BlockPos pos = new BlockPos(x, y, z);
climates.put(pos, world.createPosition(pos));
}
}
}
}
public void addPosition(IClimatedPosition position){
world.addDirtyClimateChunk(this);
climates.put(position.getPos(), position);
}
public Map<BlockPos, IClimatedPosition> getClimates() {
return climates;
}
public IClimateWorld getWorld() {
return world;
}
public ChunkPos getChunkPos() {
return chunkPos;
}
}
}
@@ -7,13 +7,15 @@ package forestry.api.multiblock;
import java.util.List;
import javax.annotation.Nullable;
import forestry.api.core.ICamouflageHandler;
import forestry.api.core.climate.IClimateRegion;
import forestry.api.greenhouse.EnumGreenhouseEventType;
import forestry.api.greenhouse.IGreenhouseHousing;
import forestry.api.greenhouse.IGreenhouseLogic;
import forestry.core.climate.IClimateHandler;
public interface IGreenhouseController extends IMultiblockController, IGreenhouseHousing, ICamouflageHandler, IClimateHandler {
public interface IGreenhouseController extends IMultiblockController, IGreenhouseHousing, ICamouflageHandler {
/**
* Handle change events.
@@ -24,5 +26,8 @@ public interface IGreenhouseController extends IMultiblockController, IGreenhous
* @return The logics of the greenhouse.
*/
List<IGreenhouseLogic> getLogics();
@Nullable
IClimateRegion getRegion();
}