mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-23 21:39:51 +00:00
Fix greenhouse climate info
This commit is contained in:
1 parent
2965f28403
commit
8f9ae45147
13 files changed
+40
-26
No files matched your search
@@ -13,8 +13,9 @@ 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.
|
||||
*/
|
||||
void changeClimate(int tickCount, IClimateRegion region);
|
||||
boolean changeClimate(int tickCount, IClimateRegion region);
|
||||
|
||||
/**
|
||||
* @return The ticks that are required for one change.
|
||||
|
||||
@@ -17,8 +17,6 @@ import java.util.Locale;
|
||||
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
|
||||
import net.minecraftforge.common.BiomeDictionary;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@@ -132,10 +132,10 @@ public class ClimateEventHandler {
|
||||
red = 0.75F;
|
||||
offset = 6;
|
||||
}
|
||||
event.getContext().func_189697_a(Block.FULL_BLOCK_AABB.offset(pos.getX() -d0, pos.getY() -d1, pos.getZ() -d2).offset(new BlockPos(deltaX - 1 * deltaX, 0, deltaZ)), red, green, blue, 0.35F);
|
||||
event.getContext().func_189696_b(Block.FULL_BLOCK_AABB.offset(pos.getX() -d0, pos.getY() -d1, pos.getZ() -d2).offset(new BlockPos(deltaX - 1 * deltaX, 0, deltaZ)), red, green, blue, 0.35F);
|
||||
event.getContext().func_189697_a(Block.FULL_BLOCK_AABB.offset(pos.getX() -d0, pos.getY() -d1, pos.getZ() -d2).offset(new BlockPos(deltaX + offset * deltaX, 0, deltaZ)), red, green, blue, 0.35F);
|
||||
event.getContext().func_189696_b(Block.FULL_BLOCK_AABB.offset(pos.getX() -d0, pos.getY() -d1, pos.getZ() -d2).offset(new BlockPos(deltaX + offset * deltaX, 0, deltaZ)), red, green, blue, 0.35F);
|
||||
event.getContext().drawSelectionBoundingBox(Block.FULL_BLOCK_AABB.offset(pos.getX() -d0, pos.getY() -d1, pos.getZ() -d2).offset(new BlockPos(deltaX - 1 * deltaX, 0, deltaZ)), red, green, blue, 0.35F);
|
||||
event.getContext().renderFilledBox(Block.FULL_BLOCK_AABB.offset(pos.getX() -d0, pos.getY() -d1, pos.getZ() -d2).offset(new BlockPos(deltaX - 1 * deltaX, 0, deltaZ)), red, green, blue, 0.35F);
|
||||
event.getContext().drawSelectionBoundingBox(Block.FULL_BLOCK_AABB.offset(pos.getX() -d0, pos.getY() -d1, pos.getZ() -d2).offset(new BlockPos(deltaX + offset * deltaX, 0, deltaZ)), red, green, blue, 0.35F);
|
||||
event.getContext().renderFilledBox(Block.FULL_BLOCK_AABB.offset(pos.getX() -d0, pos.getY() -d1, pos.getZ() -d2).offset(new BlockPos(deltaX + offset * deltaX, 0, deltaZ)), red, green, blue, 0.35F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ public class ClimateManager implements IClimateManager{
|
||||
}
|
||||
IClimateRegion region = getRegionForPos(source.getWorldObj(), source.getCoordinates());
|
||||
if(region != null){
|
||||
if(!region.getSources().contains(source.getClimateSource())){
|
||||
if(region.getSources().contains(source.getClimateSource())){
|
||||
region.removeSource(source.getClimateSource());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,10 +114,11 @@ public class ClimateRoom implements IClimateRegion, IStreamable {
|
||||
|
||||
@Override
|
||||
public void updateClimate(int ticks) {
|
||||
boolean hasChange = false;;
|
||||
for(IClimateSource source : sources){
|
||||
if(source != null){
|
||||
if(ticks % source.getTicksForChange(this) == 0){
|
||||
source.changeClimate(ticks, this);
|
||||
hasChange |= source.changeClimate(ticks, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -125,7 +126,7 @@ public class ClimateRoom implements IClimateRegion, IStreamable {
|
||||
for(Entry<BlockPos, IClimatePosition> position : positions.entrySet()){
|
||||
BlockPos pos = position.getKey();
|
||||
if(world.isBlockLoaded(pos)){
|
||||
updateSides(pos);
|
||||
hasChange |= updateSides(pos);
|
||||
|
||||
if(!controller.isAssembled()){
|
||||
IClimateControl climateControl = getControl(pos);
|
||||
@@ -134,25 +135,32 @@ public class ClimateRoom implements IClimateRegion, IStreamable {
|
||||
if(climatedInfo.getTemperature() != climateControl.getControlTemperature()){
|
||||
if(climatedInfo.getTemperature() > climateControl.getControlTemperature()){
|
||||
climatedInfo.addTemperature(-Math.min(0.01F, climatedInfo.getTemperature() - climateControl.getControlTemperature()));
|
||||
hasChange = true;
|
||||
}else{
|
||||
climatedInfo.addTemperature(Math.min(0.01F, climateControl.getControlTemperature() - climatedInfo.getTemperature()));
|
||||
hasChange = true;
|
||||
}
|
||||
}
|
||||
if(climatedInfo.getHumidity() != climateControl.getControlHumidity()){
|
||||
if(climatedInfo.getHumidity() > climateControl.getControlHumidity()){
|
||||
climatedInfo.addHumidity(-Math.min(0.01F, climatedInfo.getHumidity() - climateControl.getControlHumidity()));
|
||||
hasChange = true;
|
||||
}else{
|
||||
climatedInfo.addHumidity(Math.min(0.01F, climateControl.getControlHumidity() - climatedInfo.getHumidity()));
|
||||
|
||||
hasChange = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(hasChange){
|
||||
temperature = getExactTemperature();
|
||||
humidity = getExactHumidity();
|
||||
}
|
||||
}
|
||||
|
||||
protected void updateSides(BlockPos pos){
|
||||
protected boolean updateSides(BlockPos pos){
|
||||
IClimatePosition climatedInfo = positions.get(pos);
|
||||
IClimateControl climateControl = getControl(pos);
|
||||
boolean hasChange = false;
|
||||
@@ -175,10 +183,7 @@ public class ClimateRoom implements IClimateRegion, IStreamable {
|
||||
}
|
||||
}
|
||||
}
|
||||
if(hasChange){
|
||||
temperature = getExactTemperature();
|
||||
humidity = getExactHumidity();
|
||||
}
|
||||
return hasChange;
|
||||
}
|
||||
|
||||
protected IClimateControl getControl(BlockPos pos){
|
||||
|
||||
@@ -28,7 +28,8 @@ public abstract class ClimateSource<P extends IClimateSourceProvider> implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changeClimate(int tickCount, IClimateRegion region) {
|
||||
public boolean changeClimate(int tickCount, IClimateRegion region) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -29,7 +29,6 @@ import forestry.core.gui.slots.SlotForestry;
|
||||
import forestry.core.gui.slots.SlotLocked;
|
||||
import forestry.core.network.IForestryPacketClient;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.Log;
|
||||
import forestry.core.utils.SlotUtil;
|
||||
|
||||
import invtweaks.api.container.ContainerSection;
|
||||
|
||||
@@ -148,7 +148,7 @@ public class TextureMapForestry extends TextureMap {
|
||||
flag = false;
|
||||
return flag;
|
||||
} finally {
|
||||
IOUtils.closeQuietly((Closeable) iresource);
|
||||
IOUtils.closeQuietly(iresource);
|
||||
}
|
||||
|
||||
return flag;
|
||||
@@ -161,16 +161,19 @@ public class TextureMapForestry extends TextureMap {
|
||||
CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Applying mipmap");
|
||||
CrashReportCategory crashreportcategory = crashreport.makeCategory("Sprite being mipmapped");
|
||||
crashreportcategory.setDetail("Sprite name", new ICrashReportDetail<String>() {
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return texture.getIconName();
|
||||
}
|
||||
});
|
||||
crashreportcategory.setDetail("Sprite size", new ICrashReportDetail<String>() {
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return texture.getIconWidth() + " x " + texture.getIconHeight();
|
||||
}
|
||||
});
|
||||
crashreportcategory.setDetail("Sprite frames", new ICrashReportDetail<String>() {
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return texture.getFrameCount() + " frames";
|
||||
}
|
||||
|
||||
@@ -31,13 +31,14 @@ public class GreenhouseClimateSource<P extends TileGreenhouseClimatiser> extends
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changeClimate(int tickCount, IClimateRegion region) {
|
||||
public boolean changeClimate(int tickCount, IClimateRegion region) {
|
||||
World world = region.getWorld();
|
||||
IClimatiserDefinition definition = provider.getDefinition();
|
||||
IMultiblockLogic logic = provider.getMultiblockLogic();
|
||||
IMultiblockController controller = logic.getController();
|
||||
Iterable<BlockPos> positionsInRange = provider.getPositionsInRange();
|
||||
|
||||
boolean hasChange = false;
|
||||
boolean isActive = false;
|
||||
if(logic.isConnected() && controller.isAssembled() && controller instanceof IGreenhouseControllerInternal && positionsInRange != null && positionsInRange.iterator().hasNext() && region != null){
|
||||
IGreenhouseControllerInternal greenhouseInternal = (IGreenhouseControllerInternal) controller;
|
||||
@@ -88,10 +89,12 @@ public class GreenhouseClimateSource<P extends TileGreenhouseClimatiser> extends
|
||||
if(position.getTemperature() < controlTemp) {
|
||||
if(canChange(mode, EnumClimatiserModes.POSITIVE)){
|
||||
position.addTemperature(Math.min(change, controlTemp - position.getTemperature()));
|
||||
hasChange = true;
|
||||
}
|
||||
}else if(position.getTemperature() > controlTemp){
|
||||
if(canChange(mode, EnumClimatiserModes.NEGATIVE)){
|
||||
position.addTemperature(-Math.min(position.getTemperature() - controlTemp, change));
|
||||
hasChange = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -99,10 +102,12 @@ public class GreenhouseClimateSource<P extends TileGreenhouseClimatiser> extends
|
||||
if(position.getHumidity() < controlHum) {
|
||||
if(canChange(mode, EnumClimatiserModes.POSITIVE)){
|
||||
position.addHumidity(Math.min(change, controlHum - position.getHumidity()));
|
||||
hasChange = true;
|
||||
}
|
||||
}else if(position.getHumidity() > controlHum){
|
||||
if(canChange(mode, EnumClimatiserModes.NEGATIVE)){
|
||||
position.addHumidity(-Math.min(position.getHumidity() - controlHum, change));
|
||||
hasChange = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -114,6 +119,7 @@ public class GreenhouseClimateSource<P extends TileGreenhouseClimatiser> extends
|
||||
if(provider.isActive() != isActive){
|
||||
provider.setActive(isActive);
|
||||
}
|
||||
return hasChange;
|
||||
}
|
||||
|
||||
protected boolean canChange(EnumClimatiserTypes climatiserType, EnumClimatiserTypes type){
|
||||
|
||||
@@ -25,13 +25,14 @@ public class GreenhouseClimateWindow extends GreenhouseClimateSource<TileGreenho
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changeClimate(int tickCount, IClimateRegion region) {
|
||||
public boolean changeClimate(int tickCount, IClimateRegion region) {
|
||||
World world = region.getWorld();
|
||||
IClimatiserDefinition definition = provider.getDefinition();
|
||||
IMultiblockLogic logic = provider.getMultiblockLogic();
|
||||
IMultiblockController controller = logic.getController();
|
||||
Iterable<BlockPos> positionsInRange = provider.getPositionsInRange();
|
||||
|
||||
boolean hasChange = false;
|
||||
WindowMode windowMode = provider.getMode();
|
||||
if(logic.isConnected() && controller.isAssembled() && controller instanceof IGreenhouseControllerInternal && positionsInRange != null && positionsInRange.iterator().hasNext() && region != null){
|
||||
IGreenhouseControllerInternal greenhouseInternal = (IGreenhouseControllerInternal) controller;
|
||||
@@ -67,10 +68,12 @@ public class GreenhouseClimateWindow extends GreenhouseClimateSource<TileGreenho
|
||||
if(position.getTemperature() < controlTemp) {
|
||||
if(canChange(mode, EnumClimatiserModes.POSITIVE)){
|
||||
position.addTemperature(Math.min(change, controlTemp - position.getTemperature()));
|
||||
hasChange = true;
|
||||
}
|
||||
}else if(position.getTemperature() > controlTemp){
|
||||
if(canChange(mode, EnumClimatiserModes.NEGATIVE)){
|
||||
position.addTemperature(-Math.min(position.getTemperature() - controlTemp, change));
|
||||
hasChange = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -78,10 +81,12 @@ public class GreenhouseClimateWindow extends GreenhouseClimateSource<TileGreenho
|
||||
if(position.getHumidity() < controlHum) {
|
||||
if(canChange(mode, EnumClimatiserModes.POSITIVE)){
|
||||
position.addHumidity(Math.min(change, controlHum - position.getHumidity()));
|
||||
hasChange = true;
|
||||
}
|
||||
}else if(position.getHumidity() > controlHum){
|
||||
if(canChange(mode, EnumClimatiserModes.NEGATIVE)){
|
||||
position.addHumidity(-Math.min(position.getHumidity() - controlHum, change));
|
||||
hasChange = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -90,6 +95,7 @@ public class GreenhouseClimateWindow extends GreenhouseClimateSource<TileGreenho
|
||||
}
|
||||
}
|
||||
}
|
||||
return hasChange;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package forestry.lepidopterology.entities;
|
||||
|
||||
import forestry.lepidopterology.PluginLepidopterology;
|
||||
import net.minecraft.entity.EntityCreature;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
|
||||
@@ -16,10 +16,8 @@ import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockCrops;
|
||||
import net.minecraft.block.properties.PropertyInteger;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
|
||||
@@ -15,7 +15,6 @@ import java.awt.*;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
Reference in new issue
Block a user