mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-20 12:09:39 +00:00
Update greenhouse climate system and improve camouflage system (#1334)
This commit is contained in:
1 parent
ddffe5d4ce
commit
b5faab51c3
103 files changed
+2062
-1085
No files matched your search
@@ -28,6 +28,7 @@ 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;
|
||||
@@ -78,6 +79,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());
|
||||
|
||||
configFolder = new File(event.getModConfigurationDirectory(), Constants.MOD_ID);
|
||||
Config.load();
|
||||
|
||||
@@ -92,10 +92,12 @@ public enum EnumForestryWoodType implements IWoodType {
|
||||
return VALUES[meta];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCarbonization() {
|
||||
return carbonization;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCombustability() {
|
||||
return combustability;
|
||||
}
|
||||
|
||||
+9
-3
@@ -5,8 +5,14 @@
|
||||
******************************************************************************/
|
||||
package forestry.api.core;
|
||||
|
||||
public enum EnumCamouflageType {
|
||||
DEFAULT, GLASS, DOOR;
|
||||
public class CamouflageManager {
|
||||
|
||||
public static final EnumCamouflageType[] VALUES = values();
|
||||
public static ICamouflageAccess camouflageAccess;
|
||||
|
||||
public static final String DEFAULT = "default";
|
||||
|
||||
public static final String GLASS = "glass";
|
||||
|
||||
public static final String DOOR = "door";
|
||||
|
||||
}
|
||||
@@ -7,6 +7,7 @@ package forestry.api.core;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import forestry.api.core.climate.IClimateManager;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
|
||||
@@ -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.core;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface ICamouflageAccess {
|
||||
|
||||
/**
|
||||
* Register a item camouflage handler for a type.
|
||||
*
|
||||
* @param type The camouflage type for of handler.
|
||||
* @param itemHandler The handler that is to register.
|
||||
*/
|
||||
void registerCamouflageItemHandler(@Nonnull ICamouflageItemHandler itemHandler);
|
||||
|
||||
/**
|
||||
* @return A list of all item camouflage handler's that are registered for that camouflage type.
|
||||
*/
|
||||
List<ICamouflageItemHandler> getCamouflageItemHandler(@Nonnull String type);
|
||||
|
||||
void addItemToBlackList(@Nonnull String type, @Nonnull ItemStack camouflageBlock);
|
||||
|
||||
boolean isItemBlackListed(@Nonnull String type, @Nonnull ItemStack camouflageBlock);
|
||||
|
||||
}
|
||||
@@ -7,27 +7,34 @@ package forestry.api.core;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface ICamouflageHandler{
|
||||
|
||||
/**
|
||||
* @return The item of the block that is the camouflage of this handler for the EnumCamouflageType.
|
||||
* @return The item of the block that is the camouflage of this handler for the type.
|
||||
*/
|
||||
ItemStack getCamouflageBlock(EnumCamouflageType type);
|
||||
ItemStack getCamouflageBlock(String type);
|
||||
|
||||
/**
|
||||
* @return The default camouflage block item for the EnumCamouflageType.
|
||||
* @return The default camouflage block item for the type.
|
||||
*/
|
||||
ItemStack getDefaultCamouflageBlock(EnumCamouflageType type);
|
||||
ItemStack getDefaultCamouflageBlock(String type);
|
||||
|
||||
/**
|
||||
* @return True if the handler can handle this type of camouflage.
|
||||
*/
|
||||
boolean canHandleType(String type);
|
||||
|
||||
/**
|
||||
* Set the camouflage block item for the EnumCamouflageType.
|
||||
* Set the camouflage block item for the type.
|
||||
*/
|
||||
void setCamouflageBlock(EnumCamouflageType type, ItemStack camouflageBlock);
|
||||
void setCamouflageBlock(String type, ItemStack camouflageBlock);
|
||||
|
||||
/**
|
||||
* @return The coordinates of the handler as a BlockPos.
|
||||
*/
|
||||
BlockPos getCoordinates();
|
||||
|
||||
World getWorld();
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
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;
|
||||
|
||||
public interface ICamouflageItemHandler {
|
||||
|
||||
boolean canHandle(ItemStack stack, ICamouflageHandler camouflageHandler);
|
||||
|
||||
String getType();
|
||||
|
||||
float getLightTransmittance(ItemStack stack, ICamouflageHandler camouflageHandler);
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
Pair<IBlockState, IBakedModel> getModel(ItemStack stack, ICamouflageHandler camouflageHandler, ICamouflagedTile camouflageTile);
|
||||
|
||||
}
|
||||
@@ -9,7 +9,7 @@ import net.minecraft.util.math.BlockPos;
|
||||
|
||||
public interface ICamouflagedTile {
|
||||
|
||||
EnumCamouflageType getCamouflageType();
|
||||
String getCamouflageType();
|
||||
|
||||
BlockPos getCoordinates();
|
||||
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* 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.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface IClimateManager {
|
||||
|
||||
float getTemperature(World world, BlockPos pos);
|
||||
|
||||
float getHumidity(World world, BlockPos pos);
|
||||
|
||||
IClimateProvider getDefaultClimate(World world, BlockPos pos);
|
||||
|
||||
}
|
||||
@@ -8,8 +8,6 @@ package forestry.api.core;
|
||||
import net.minecraft.client.renderer.ItemMeshDefinition;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
|
||||
+3
-8
@@ -1,14 +1,9 @@
|
||||
/*******************************************************************************
|
||||
* 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;
|
||||
package forestry.api.core.climate;
|
||||
|
||||
public interface IClimateControlled {
|
||||
/**
|
||||
@@ -0,0 +1,43 @@
|
||||
/*******************************************************************************
|
||||
* 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.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import forestry.api.core.IClimateProvider;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface IClimateManager {
|
||||
|
||||
float getTemperature(World world, BlockPos pos);
|
||||
|
||||
float getHumidity(World world, BlockPos pos);
|
||||
|
||||
IClimateProvider getDefaultClimate(World world, BlockPos pos);
|
||||
|
||||
void addRegion(IClimateRegion region);
|
||||
|
||||
void removeRegion(IClimateRegion region);
|
||||
|
||||
void addSource(IClimateSource source);
|
||||
|
||||
void removeSource(IClimateSource source);
|
||||
|
||||
@Nullable
|
||||
IClimateRegion getRegionForPos(World world, BlockPos pos);
|
||||
|
||||
@Nonnull
|
||||
Map<Integer, List<IClimateRegion>> getRegions();
|
||||
|
||||
@Nonnull
|
||||
Map<Integer, Map<BlockPos, IClimateSource>> getSources();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*******************************************************************************
|
||||
* 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 javax.annotation.Nonnull;
|
||||
|
||||
import forestry.api.core.INbtReadable;
|
||||
import forestry.api.core.INbtWritable;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
public interface IClimatePosition extends INbtReadable, INbtWritable {
|
||||
|
||||
@Nonnull
|
||||
IClimateRegion getClimateRegion();
|
||||
|
||||
@Nonnull
|
||||
BlockPos getPos();
|
||||
|
||||
void setTemperature(float temperature);
|
||||
|
||||
void addTemperature(float temperature);
|
||||
|
||||
float getTemperature();
|
||||
|
||||
void setHumidity(float humidity);
|
||||
|
||||
void addHumidity(float humidity);
|
||||
|
||||
float getHumidity();
|
||||
|
||||
}
|
||||
@@ -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.core.climate;
|
||||
|
||||
import java.util.List;
|
||||
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();
|
||||
|
||||
/**
|
||||
* Update the climate in a region, all 20 world ticks.
|
||||
*/
|
||||
void updateClimate();
|
||||
|
||||
@Nonnull
|
||||
Map<BlockPos, IClimatePosition> getPositions();
|
||||
|
||||
int getTicksPerUpdate();
|
||||
|
||||
List<BlockPos> getOtherPositions();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/*******************************************************************************
|
||||
* 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 net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
* A climate source is used to change the climate in a region.
|
||||
*/
|
||||
public interface IClimateSource {
|
||||
|
||||
/**
|
||||
* @param tickCount The current tick count.
|
||||
* @param region The climate region, in that the source stands.
|
||||
*/
|
||||
void changeClimate(int tickCount, IClimateRegion region);
|
||||
|
||||
/**
|
||||
* @return The ticks that are required for one change.
|
||||
*/
|
||||
int getTicksForChange(IClimateRegion region);
|
||||
|
||||
World getWorld();
|
||||
|
||||
BlockPos getPos();
|
||||
|
||||
}
|
||||
@@ -5,10 +5,12 @@
|
||||
******************************************************************************/
|
||||
package forestry.api.genetics;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
|
||||
import net.minecraftforge.common.BiomeDictionary;
|
||||
|
||||
import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraftforge.common.BiomeDictionary;
|
||||
|
||||
/** Set custom mutation requirements */
|
||||
public interface IMutationBuilder {
|
||||
|
||||
@@ -10,7 +10,7 @@ import forestry.api.multiblock.IGreenhouseController;
|
||||
public class DefaultGreenhouseListener implements IGreenhouseListener {
|
||||
|
||||
@Override
|
||||
public <G extends IGreenhouseController & IGreenhouseHousing> boolean canWork(G greenhouse, boolean canWork) {
|
||||
public boolean canWork(IGreenhouseController greenhouse, boolean canWork) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -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.greenhouse;
|
||||
|
||||
@@ -15,17 +10,17 @@ import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
|
||||
import forestry.api.core.EnumCamouflageType;
|
||||
import forestry.api.core.ICamouflageHandler;
|
||||
import forestry.api.core.ICamouflagedTile;
|
||||
import forestry.api.multiblock.IGreenhouseController;
|
||||
|
||||
public class GreenhouseEvents extends Event {
|
||||
|
||||
@Nullable
|
||||
public final IGreenhouseState state;
|
||||
public final IGreenhouseController controller;
|
||||
|
||||
public GreenhouseEvents(@Nullable IGreenhouseState state) {
|
||||
this.state = state;
|
||||
public GreenhouseEvents(@Nullable IGreenhouseController state) {
|
||||
this.controller = state;
|
||||
}
|
||||
|
||||
public static class CamouflageChangeEvent extends GreenhouseEvents{
|
||||
@@ -35,10 +30,10 @@ public class GreenhouseEvents extends Event {
|
||||
@Nonnull
|
||||
public ICamouflageHandler camouflageHandler;
|
||||
@Nonnull
|
||||
public final EnumCamouflageType camouflageType;
|
||||
public final String camouflageType;
|
||||
|
||||
public CamouflageChangeEvent(IGreenhouseState state, @Nullable ICamouflagedTile camouflagedBlock, @Nonnull ICamouflageHandler camouflageHandler, @Nonnull EnumCamouflageType camouflageType) {
|
||||
super(state);
|
||||
public CamouflageChangeEvent(IGreenhouseController controller, @Nullable ICamouflagedTile camouflagedBlock, @Nonnull ICamouflageHandler camouflageHandler, @Nonnull String camouflageType) {
|
||||
super(controller);
|
||||
|
||||
this.camouflagedBlock = camouflagedBlock;
|
||||
this.camouflageHandler = camouflageHandler;
|
||||
@@ -51,8 +46,8 @@ public class GreenhouseEvents extends Event {
|
||||
@Nonnull
|
||||
public IInternalBlock internalBlock;
|
||||
|
||||
public InternalBlockEvent(IGreenhouseState state, @Nonnull IInternalBlock internalBlock) {
|
||||
super(state);
|
||||
public InternalBlockEvent(IGreenhouseController controller, @Nonnull IInternalBlock internalBlock) {
|
||||
super(controller);
|
||||
|
||||
this.internalBlock = internalBlock;
|
||||
}
|
||||
@@ -60,8 +55,8 @@ public class GreenhouseEvents extends Event {
|
||||
|
||||
public static class CreateInternalBlockEvent extends InternalBlockEvent{
|
||||
|
||||
public CreateInternalBlockEvent(IGreenhouseState state, IInternalBlock internalBlock) {
|
||||
super(state, internalBlock);
|
||||
public CreateInternalBlockEvent(IGreenhouseController controller, IInternalBlock internalBlock) {
|
||||
super(controller, internalBlock);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,8 +65,8 @@ public class GreenhouseEvents extends Event {
|
||||
@Nonnull
|
||||
public final IInternalBlockFace face;
|
||||
|
||||
public CheckInternalBlockFaceEvent(IGreenhouseState state, IInternalBlock internalBlock, @Nonnull IInternalBlockFace face) {
|
||||
super(state, internalBlock);
|
||||
public CheckInternalBlockFaceEvent(IGreenhouseController controller, IInternalBlock internalBlock, @Nonnull IInternalBlockFace face) {
|
||||
super(controller, internalBlock);
|
||||
|
||||
this.face = face;
|
||||
}
|
||||
|
||||
@@ -5,15 +5,8 @@
|
||||
******************************************************************************/
|
||||
package forestry.api.greenhouse;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class GreenhouseManager {
|
||||
|
||||
public static IGreenhouseAccess greenhouseAccess;
|
||||
|
||||
public static IGreenhouseHelper greenhouseHelper;
|
||||
|
||||
public static List<Class<? extends IGreenhouseLogic>> greenhouseLogics = new ArrayList<>();
|
||||
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.greenhouse;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import forestry.api.core.EnumCamouflageType;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IGreenhouseAccess {
|
||||
|
||||
void registerGreenhouseGlass(@Nonnull ItemStack glass, float lightTransmittance);
|
||||
|
||||
boolean isGreenhouseGlass(@Nonnull ItemStack glass);
|
||||
|
||||
float getGreenhouseGlassLightTransmittance(@Nonnull ItemStack glass);
|
||||
|
||||
void addToCamouflageBlockBlackList(@Nonnull EnumCamouflageType type, @Nonnull ItemStack camouflageBlock);
|
||||
|
||||
boolean isOnCamouflageBlockBlackList(@Nonnull EnumCamouflageType type, @Nonnull ItemStack camouflageBlock);
|
||||
|
||||
}
|
||||
@@ -5,14 +5,21 @@
|
||||
******************************************************************************/
|
||||
package forestry.api.greenhouse;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import forestry.api.multiblock.IGreenhouseController;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface IGreenhouseHelper {
|
||||
|
||||
/**
|
||||
* @return A {@link IGreenhouseState} of a greenhouse, when the pos is a greenhouse
|
||||
* @return A {@link IGreenhouseController} of a greenhouse, when the pos is a greenhouse
|
||||
*/
|
||||
IGreenhouseState getGreenhouseState(World world, BlockPos pos);
|
||||
IGreenhouseController getGreenhouseController(World world, BlockPos pos);
|
||||
|
||||
void addGreenhouseLogic(Class<? extends IGreenhouseLogic> logic);
|
||||
|
||||
List<Class<? extends IGreenhouseLogic>> getGreenhouseLogics();
|
||||
|
||||
}
|
||||
@@ -10,12 +10,12 @@ import forestry.api.multiblock.IGreenhouseController;
|
||||
public interface IGreenhouseListener {
|
||||
|
||||
/**
|
||||
* Called before the greenhouse work.
|
||||
* Called before the greenhouse update the climate system.
|
||||
*
|
||||
* @param greenhouse The greenhouse multiblock.
|
||||
* @param greenhouse The greenhouse of the listener.
|
||||
* @param canWork The actual {@link Boolean} value.
|
||||
* @return True if the greenhouse can work.
|
||||
* @return True if the greenhouse can update the climate.
|
||||
*/
|
||||
<G extends IGreenhouseController & IGreenhouseHousing> boolean canWork(G greenhouse, boolean canWork);
|
||||
boolean canWork(IGreenhouseController greenhouse, boolean canWork);
|
||||
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.greenhouse;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
|
||||
import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import forestry.api.multiblock.IMultiblockComponent;
|
||||
|
||||
public interface IGreenhouseState {
|
||||
|
||||
EnumTemperature getTemperature();
|
||||
|
||||
EnumHumidity getHumidity();
|
||||
|
||||
float getExactTemperature();
|
||||
|
||||
float getExactHumidity();
|
||||
|
||||
Set<IInternalBlock> getInternalBlocks();
|
||||
|
||||
Collection<IMultiblockComponent> getGreenhouseComponents();
|
||||
|
||||
}
|
||||
@@ -7,6 +7,7 @@ package forestry.api.greenhouse;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
@@ -7,7 +7,7 @@ package forestry.api.multiblock;
|
||||
|
||||
import forestry.api.apiculture.IBeeListener;
|
||||
import forestry.api.apiculture.IBeeModifier;
|
||||
import forestry.api.core.IClimateControlled;
|
||||
import forestry.api.core.climate.IClimateControlled;
|
||||
|
||||
/**
|
||||
* Needs to be implemented by TileEntities that want to be part of an alveary.
|
||||
|
||||
@@ -5,8 +5,7 @@
|
||||
******************************************************************************/
|
||||
package forestry.api.multiblock;
|
||||
|
||||
import forestry.api.core.IClimateControlled;
|
||||
import forestry.api.greenhouse.IGreenhouseHousing;
|
||||
import forestry.api.core.climate.IClimateSource;
|
||||
import forestry.api.greenhouse.IGreenhouseListener;
|
||||
import forestry.api.lepidopterology.IButterflyCocoon;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -22,8 +21,7 @@ public interface IGreenhouseComponent<T extends IMultiblockLogicGreenhouse> exte
|
||||
interface Door extends IGreenhouseComponent {
|
||||
}
|
||||
|
||||
interface Climatiser extends IGreenhouseComponent {
|
||||
<G extends IGreenhouseController & IGreenhouseHousing & IClimateControlled> void changeClimate(int tickCount, G greenhouse);
|
||||
interface Climatiser extends IGreenhouseComponent, IClimateSource {
|
||||
}
|
||||
|
||||
interface ButterflyHatch extends IGreenhouseComponent {
|
||||
|
||||
@@ -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.IClimateControlled;
|
||||
import forestry.api.core.climate.IClimateRegion;
|
||||
import forestry.api.greenhouse.EnumGreenhouseEventType;
|
||||
import forestry.api.greenhouse.IGreenhouseHousing;
|
||||
import forestry.api.greenhouse.IGreenhouseLogic;
|
||||
|
||||
public interface IGreenhouseController extends IMultiblockController, IGreenhouseHousing, ICamouflageHandler, IClimateControlled {
|
||||
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();
|
||||
|
||||
}
|
||||
@@ -15,4 +15,6 @@ public interface IMultiblockLogicFactory {
|
||||
IMultiblockLogicFarm createFarmLogic();
|
||||
|
||||
IMultiblockLogicGreenhouse createGreenhouseLogic();
|
||||
|
||||
IMultiblockLogicCharcoalPile createCharcoalPileLogic();
|
||||
}
|
||||
@@ -25,7 +25,7 @@ import forestry.api.core.BiomeHelper;
|
||||
import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.core.IClimateControlled;
|
||||
import forestry.api.core.climate.IClimateControlled;
|
||||
import forestry.api.multiblock.IAlvearyComponent;
|
||||
import forestry.api.multiblock.IMultiblockComponent;
|
||||
import forestry.apiculture.AlvearyBeeModifier;
|
||||
|
||||
@@ -15,8 +15,7 @@ import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import forestry.api.core.IClimateControlled;
|
||||
import forestry.api.core.climate.IClimateControlled;
|
||||
import forestry.api.multiblock.IAlvearyComponent;
|
||||
import forestry.apiculture.network.packets.PacketActiveUpdate;
|
||||
import forestry.core.proxy.Proxies;
|
||||
|
||||
@@ -22,8 +22,7 @@ import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
|
||||
import forestry.api.core.IClimateControlled;
|
||||
import forestry.api.core.climate.IClimateControlled;
|
||||
import forestry.api.multiblock.IAlvearyComponent;
|
||||
import forestry.apiculture.blocks.BlockAlvearyType;
|
||||
import forestry.apiculture.gui.ContainerAlvearyHygroregulator;
|
||||
|
||||
@@ -17,7 +17,7 @@ import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockDoor;
|
||||
import net.minecraft.block.BlockFenceGate;
|
||||
import net.minecraft.block.BlockHorizontal;
|
||||
import net.minecraft.block.BlockLog;
|
||||
import net.minecraft.block.BlockSlab;
|
||||
import net.minecraft.block.BlockStairs;
|
||||
@@ -57,9 +57,8 @@ import forestry.apiculture.flowers.Flower;
|
||||
import forestry.apiculture.flowers.FlowerRegistry;
|
||||
import forestry.apiculture.tiles.TileBeeHouse;
|
||||
import forestry.arboriculture.PluginArboriculture;
|
||||
import forestry.arboriculture.blocks.log.BlockArbLog;
|
||||
import forestry.core.PluginCore;
|
||||
import forestry.core.blocks.BlockCore;
|
||||
import forestry.core.blocks.BlockBase;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.tiles.TileUtil;
|
||||
import forestry.plugins.ForestryPluginUids;
|
||||
@@ -140,9 +139,9 @@ public class VillageApiaristHouse extends StructureVillagePieces.House1 {
|
||||
fillWithBlocks(world, structBoundingBox, 8, 1, 6, 8, 1, 10, fence, fence, false);
|
||||
fillWithBlocks(world, structBoundingBox, 2, 1, 10, 7, 1, 10, fence, fence, false);
|
||||
|
||||
setBlockState(world, fenceGate.withProperty(BlockFenceGate.FACING, EnumFacing.EAST), 8, 1, 8, structBoundingBox);
|
||||
setBlockState(world, fenceGate.withProperty(BlockFenceGate.FACING, EnumFacing.EAST), 1, 1, 8, structBoundingBox);
|
||||
setBlockState(world, fenceGate.withProperty(BlockFenceGate.FACING, EnumFacing.NORTH), 4, 1, 10, structBoundingBox);
|
||||
setBlockState(world, fenceGate.withProperty(BlockHorizontal.FACING, EnumFacing.EAST), 8, 1, 8, structBoundingBox);
|
||||
setBlockState(world, fenceGate.withProperty(BlockHorizontal.FACING, EnumFacing.EAST), 1, 1, 8, structBoundingBox);
|
||||
setBlockState(world, fenceGate.withProperty(BlockHorizontal.FACING, EnumFacing.NORTH), 4, 1, 10, structBoundingBox);
|
||||
|
||||
// Flowers
|
||||
plantFlowerGarden(world, structBoundingBox, 2, 1, 5, 7, 1, 9);
|
||||
@@ -171,7 +170,7 @@ public class VillageApiaristHouse extends StructureVillagePieces.House1 {
|
||||
IBlockState slabCeiling = slabs.withProperty(BlockSlab.HALF, BlockSlab.EnumBlockHalf.TOP);
|
||||
fillWithBlocks(world, structBoundingBox, 1, 4, 1, 7, 4, 4, slabCeiling, slabCeiling, false);
|
||||
|
||||
IBlockState logBracing = logs.withProperty(BlockArbLog.LOG_AXIS, BlockLog.EnumAxis.X);
|
||||
IBlockState logBracing = logs.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.X);
|
||||
fillWithBlocks(world, structBoundingBox, 0, 4, 1, 8, 4, 1, logBracing, logBracing, false);
|
||||
fillWithBlocks(world, structBoundingBox, 0, 4, 4, 8, 4, 4, logBracing, logBracing, false);
|
||||
|
||||
@@ -219,7 +218,7 @@ public class VillageApiaristHouse extends StructureVillagePieces.House1 {
|
||||
|
||||
// Escritoire
|
||||
if (random.nextInt(2) == 0) {
|
||||
IBlockState escritoireBlock = PluginCore.blocks.escritoire.getDefaultState().withProperty(BlockCore.FACING, EnumFacing.EAST);
|
||||
IBlockState escritoireBlock = PluginCore.blocks.escritoire.getDefaultState().withProperty(BlockBase.FACING, EnumFacing.EAST);
|
||||
setBlockState(world, escritoireBlock, 1, 1, 3, structBoundingBox);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
/*******************************************************************************
|
||||
* 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 forestry.api.core.CamouflageManager;
|
||||
import forestry.api.core.ICamouflageHandler;
|
||||
import forestry.api.core.ICamouflageItemHandler;
|
||||
import forestry.api.core.ICamouflagedTile;
|
||||
import forestry.arboriculture.items.ItemBlockWoodDoor;
|
||||
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;
|
||||
|
||||
public class CamouflageHandlerArbDoor implements ICamouflageItemHandler {
|
||||
|
||||
@Override
|
||||
public boolean canHandle(ItemStack stack, ICamouflageHandler camouflageHandler) {
|
||||
if(camouflageHandler == null || stack == null || stack.getItem() == null || stack.stackSize <= 0){
|
||||
return false;
|
||||
}
|
||||
if(stack.getItem() instanceof ItemBlockWoodDoor){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return CamouflageManager.DOOR;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getLightTransmittance(ItemStack stack, ICamouflageHandler camouflageHandler) {
|
||||
return 0F;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public IBakedModel getModel(ItemStack stack, ICamouflageHandler camouflageHandler, ICamouflagedTile camouflageTile) {
|
||||
if(camouflageHandler == null || stack == null || stack.getItem() == null || stack.stackSize <= 0 || !(stack.getItem() instanceof ItemBlockWoodDoor)){
|
||||
return null;
|
||||
}
|
||||
World world = camouflageHandler.getWorld();
|
||||
BlockPos pos = camouflageTile.getCoordinates();
|
||||
IBlockState blockState = world.getBlockState(pos);
|
||||
IBlockState currentState = blockState.getActualState(world, pos);
|
||||
|
||||
ItemBlockWoodDoor itemDoor = (ItemBlockWoodDoor) stack.getItem();
|
||||
|
||||
IBlockState doorState = itemDoor.block.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 modelShapes.getModelForState(doorState);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -27,6 +27,7 @@ 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.genetics.AlleleManager;
|
||||
import forestry.api.genetics.ILeafTranslator;
|
||||
@@ -173,6 +174,8 @@ public class PluginArboriculture extends BlankForestryPlugin {
|
||||
|
||||
// Commands
|
||||
PluginCore.rootCommand.addChildCommand(new CommandTree());
|
||||
|
||||
CamouflageManager.camouflageAccess.registerCamouflageItemHandler(new CamouflageHandlerArbDoor());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -18,7 +18,6 @@ import java.util.List;
|
||||
import net.minecraft.block.BlockFenceGate;
|
||||
import net.minecraft.block.BlockPlanks.EnumType;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.ModelBakery;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
|
||||
@@ -5,7 +5,6 @@ import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
import net.minecraft.block.BlockStairs;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.ModelBakery;
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
@@ -5,7 +5,6 @@ import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.BlockLog;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.ModelBakery;
|
||||
|
||||
@@ -10,12 +10,8 @@
|
||||
******************************************************************************/
|
||||
package forestry.arboriculture.worldgen;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
|
||||
@@ -10,12 +10,8 @@
|
||||
******************************************************************************/
|
||||
package forestry.arboriculture.worldgen;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
|
||||
@@ -10,12 +10,8 @@
|
||||
******************************************************************************/
|
||||
package forestry.arboriculture.worldgen;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
|
||||
@@ -10,12 +10,8 @@
|
||||
******************************************************************************/
|
||||
package forestry.arboriculture.worldgen;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
|
||||
@@ -10,12 +10,8 @@
|
||||
******************************************************************************/
|
||||
package forestry.arboriculture.worldgen;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
/*******************************************************************************
|
||||
* 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.core;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import forestry.api.core.ICamouflageAccess;
|
||||
import forestry.api.core.ICamouflageHandler;
|
||||
import forestry.api.core.ICamouflageItemHandler;
|
||||
import forestry.core.utils.Log;
|
||||
|
||||
public class CamouflageAccess implements ICamouflageAccess {
|
||||
|
||||
private static final Map<String, List<ICamouflageItemHandler>> camouflageItemHandlers = new HashMap<>();
|
||||
private static final Map<String, List<ItemStack>> camouflageItemBlacklist = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public void registerCamouflageItemHandler(@Nonnull ICamouflageItemHandler itemHandler) {
|
||||
if(itemHandler == null){
|
||||
Log.error("Fail to register a camouflage item handler, because the handler is null. The handler is form the mod with the ID: " + Loader.instance().activeModContainer().getModId() + ".");
|
||||
return;
|
||||
}
|
||||
String type = itemHandler.getType();
|
||||
if(!camouflageItemHandlers.containsKey(type)){
|
||||
camouflageItemHandlers.put(type, new ArrayList<>());
|
||||
}
|
||||
if(!camouflageItemHandlers.containsValue(itemHandler)){
|
||||
camouflageItemHandlers.get(type).add(itemHandler);
|
||||
}else{
|
||||
Log.error("Fail to register a camouflage item handler, because the handler is already registered. The handler is form the mod with the ID: " + Loader.instance().activeModContainer().getModId() + ".");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ICamouflageItemHandler> getCamouflageItemHandler(String type) {
|
||||
if(!camouflageItemHandlers.containsKey(type)){
|
||||
return null;
|
||||
}
|
||||
return camouflageItemHandlers.get(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addItemToBlackList(String type, ItemStack camouflageBlock) {
|
||||
if (camouflageBlock == null || camouflageBlock.getItem() == null) {
|
||||
Log.error("Fail to add camouflage block item to the black list, because it is null");
|
||||
return;
|
||||
}
|
||||
Block block = Block.getBlockFromItem(camouflageBlock.getItem());
|
||||
if (block == null) {
|
||||
Log.error("Fail to add camouflage block item to the black list: because it has no block.");
|
||||
return;
|
||||
}
|
||||
for (ItemStack camouflageBlacklisted : camouflageItemBlacklist.get(type)) {
|
||||
if (camouflageBlacklisted.getItem() == camouflageBlock.getItem() && camouflageBlacklisted.getItemDamage() == camouflageBlock.getItemDamage() && ItemStack.areItemStackTagsEqual(camouflageBlock, camouflageBlacklisted)) {
|
||||
Log.error("Fail to add camouflage block item to the black list, because it is already registered: " + camouflageBlock + ".");
|
||||
return;
|
||||
}
|
||||
}
|
||||
camouflageItemBlacklist.get(type).add(camouflageBlock);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemBlackListed(String type, ItemStack camouflageBlock) {
|
||||
if (camouflageBlock == null || camouflageBlock.getItem() == null || Block.getBlockFromItem(camouflageBlock.getItem()) == null || !camouflageItemBlacklist.containsKey(type)) {
|
||||
return false;
|
||||
}
|
||||
for (ItemStack camouflageBlacklisted : camouflageItemBlacklist.get(type)) {
|
||||
if (camouflageBlacklisted.getItem() == camouflageBlock.getItem() && camouflageBlacklisted.getItemDamage() == camouflageBlock.getItemDamage() && ItemStack.areItemStackTagsEqual(camouflageBlock, camouflageBlacklisted)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static ICamouflageItemHandler getHandlerFromItem(@Nonnull ItemStack camouflageItem, ICamouflageHandler camouflageHandler){
|
||||
for(List<ICamouflageItemHandler> handlers : camouflageItemHandlers.values()){
|
||||
for(ICamouflageItemHandler handler : handlers){
|
||||
if(handler.canHandle(camouflageItem, camouflageHandler)){
|
||||
return handler;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/*******************************************************************************
|
||||
* 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.core;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import forestry.api.core.CamouflageManager;
|
||||
import forestry.api.core.ICamouflageHandler;
|
||||
import forestry.api.core.ICamouflageItemHandler;
|
||||
import forestry.api.core.ICamouflagedTile;
|
||||
import net.minecraft.block.Block;
|
||||
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.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class CamouflageHandlerDefault implements ICamouflageItemHandler {
|
||||
|
||||
@Override
|
||||
public boolean canHandle(ItemStack stack, ICamouflageHandler camouflageHandler) {
|
||||
if(camouflageHandler == null || stack == null || stack.getItem() == null || stack.stackSize <= 0 || Block.getBlockFromItem(stack.getItem()) == null){
|
||||
return false;
|
||||
}
|
||||
Block block = Block.getBlockFromItem(stack.getItem());
|
||||
IBlockState stateFromMeta = block.getStateFromMeta(stack.getItemDamage());
|
||||
|
||||
return stateFromMeta.isOpaqueCube() && !block.hasTileEntity(stateFromMeta) && block.isNormalCube(stateFromMeta, camouflageHandler.getWorld(), camouflageHandler.getCoordinates());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return CamouflageManager.DEFAULT;
|
||||
}
|
||||
|
||||
@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) {
|
||||
if(camouflageHandler == null || stack == null || stack.getItem() == null || stack.stackSize <= 0 || Block.getBlockFromItem(stack.getItem()) == null){
|
||||
return null;
|
||||
}
|
||||
BlockModelShapes modelShapes = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes();
|
||||
Block block = Block.getBlockFromItem(stack.getItem());
|
||||
IBlockState state = block.getStateFromMeta(stack.getItemDamage());
|
||||
|
||||
return Pair.of(state, modelShapes.getModelForState(state));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
/*******************************************************************************
|
||||
* 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.core;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import forestry.api.core.CamouflageManager;
|
||||
import forestry.api.core.ICamouflageHandler;
|
||||
import forestry.api.core.ICamouflageItemHandler;
|
||||
import forestry.api.core.ICamouflagedTile;
|
||||
import net.minecraft.block.Block;
|
||||
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.ItemDoor;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class CamouflageHandlerDoor implements ICamouflageItemHandler {
|
||||
|
||||
@Override
|
||||
public boolean canHandle(ItemStack stack, ICamouflageHandler camouflageHandler) {
|
||||
if(camouflageHandler == null || stack == null || stack.getItem() == null || stack.stackSize <= 0){
|
||||
return false;
|
||||
}
|
||||
if(stack.getItem() instanceof ItemDoor){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return CamouflageManager.DOOR;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getLightTransmittance(ItemStack stack, ICamouflageHandler camouflageHandler) {
|
||||
return 0.25F;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public Pair<IBlockState, IBakedModel> getModel(ItemStack stack, ICamouflageHandler camouflageHandler, ICamouflagedTile camouflageTile) {
|
||||
if(camouflageHandler == null || stack == null || stack.getItem() == null || stack.stackSize <= 0 || !(stack.getItem() instanceof ItemDoor)){
|
||||
return null;
|
||||
}
|
||||
World world = camouflageHandler.getWorld();
|
||||
BlockPos pos = camouflageTile.getCoordinates();
|
||||
IBlockState blockState = world.getBlockState(pos);
|
||||
IBlockState currentState = blockState.getActualState(world, pos);
|
||||
|
||||
ItemDoor itemDoor = (ItemDoor) stack.getItem();
|
||||
Block doorBlock = ObfuscationReflectionHelper.getPrivateValue(ItemDoor.class, itemDoor, 0);
|
||||
|
||||
IBlockState doorState = doorBlock.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));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/*******************************************************************************
|
||||
* 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.core;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import forestry.api.core.CamouflageManager;
|
||||
import forestry.api.core.ICamouflageHandler;
|
||||
import forestry.api.core.ICamouflageItemHandler;
|
||||
import forestry.api.core.ICamouflagedTile;
|
||||
import net.minecraft.block.Block;
|
||||
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.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class CamouflageHandlerGlass implements ICamouflageItemHandler {
|
||||
|
||||
@Override
|
||||
public boolean canHandle(ItemStack stack, ICamouflageHandler camouflageHandler) {
|
||||
if(camouflageHandler == null || stack == null || stack.getItem() == null || stack.stackSize <= 0 || Block.getBlockFromItem(stack.getItem()) == null){
|
||||
return false;
|
||||
}
|
||||
Block block = Block.getBlockFromItem(stack.getItem());
|
||||
IBlockState stateFromMeta = block.getStateFromMeta(stack.getItemDamage());
|
||||
|
||||
return !stateFromMeta.isOpaqueCube() && !block.hasTileEntity(stateFromMeta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return CamouflageManager.GLASS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getLightTransmittance(ItemStack stack, ICamouflageHandler camouflageHandler) {
|
||||
return 0.25F;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public Pair<IBlockState, IBakedModel> getModel(ItemStack stack, ICamouflageHandler camouflageHandler, ICamouflagedTile camouflageTile) {
|
||||
if(camouflageHandler == null || stack == null || stack.getItem() == null || stack.stackSize <= 0 || Block.getBlockFromItem(stack.getItem()) == null){
|
||||
return null;
|
||||
}
|
||||
BlockModelShapes modelShapes = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes();
|
||||
Block block = Block.getBlockFromItem(stack.getItem());
|
||||
IBlockState state = block.getStateFromMeta(stack.getItemDamage());
|
||||
|
||||
return Pair.of(state, modelShapes.getModelForState(state));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,50 +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.core;
|
||||
|
||||
import forestry.api.core.IClimateProvider;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
|
||||
import forestry.api.core.IClimateManager;
|
||||
import forestry.api.greenhouse.GreenhouseManager;
|
||||
import forestry.api.greenhouse.IGreenhouseState;
|
||||
|
||||
public class ClimateManager implements IClimateManager{
|
||||
|
||||
@Override
|
||||
public float getTemperature(World world, BlockPos pos) {
|
||||
IGreenhouseState state = GreenhouseManager.greenhouseHelper.getGreenhouseState(world, pos);
|
||||
Biome biome = world.getBiome(pos);
|
||||
|
||||
if(state != null){
|
||||
return state.getExactTemperature();
|
||||
}
|
||||
return biome.getTemperature();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getHumidity(World world, BlockPos pos) {
|
||||
IGreenhouseState state = GreenhouseManager.greenhouseHelper.getGreenhouseState(world, pos);
|
||||
Biome biome = world.getBiome(pos);
|
||||
|
||||
if(state != null){
|
||||
return state.getExactHumidity();
|
||||
}
|
||||
return biome.getRainfall();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IClimateProvider getDefaultClimate(World world, BlockPos pos) {
|
||||
return new DefaultClimateProvider(world, pos);
|
||||
}
|
||||
}
|
||||
@@ -37,6 +37,7 @@ import net.minecraftforge.oredict.OreDictionary;
|
||||
import net.minecraftforge.oredict.RecipeSorter;
|
||||
|
||||
import forestry.api.circuits.ChipsetManager;
|
||||
import forestry.api.core.CamouflageManager;
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.multiblock.MultiblockManager;
|
||||
@@ -48,6 +49,7 @@ import forestry.core.blocks.BlockRegistryCore;
|
||||
import forestry.core.blocks.EnumResourceType;
|
||||
import forestry.core.circuits.CircuitRegistry;
|
||||
import forestry.core.circuits.SolderManager;
|
||||
import forestry.core.climate.ClimateManager;
|
||||
import forestry.core.commands.CommandPlugins;
|
||||
import forestry.core.commands.RootCommand;
|
||||
import forestry.core.config.Config;
|
||||
@@ -108,6 +110,8 @@ public class PluginCore extends BlankForestryPlugin {
|
||||
|
||||
MultiblockManager.logicFactory = new MultiblockLogicFactory();
|
||||
ForestryAPI.climateManager = new ClimateManager();
|
||||
|
||||
CamouflageManager.camouflageAccess = new CamouflageAccess();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -125,6 +129,10 @@ public class PluginCore extends BlankForestryPlugin {
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
|
||||
rootCommand.addChildCommand(new CommandPlugins());
|
||||
|
||||
CamouflageManager.camouflageAccess.registerCamouflageItemHandler(new CamouflageHandlerDefault());
|
||||
CamouflageManager.camouflageAccess.registerCamouflageItemHandler(new CamouflageHandlerGlass());
|
||||
CamouflageManager.camouflageAccess.registerCamouflageItemHandler(new CamouflageHandlerDoor());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
package forestry.core.climate;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.core.climate.IClimateManager;
|
||||
import forestry.api.core.climate.IClimateRegion;
|
||||
import forestry.api.core.climate.IClimateSource;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.event.world.WorldEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
||||
|
||||
public class ClimateEventHandler {
|
||||
|
||||
Map<Integer, Integer> serverTicks;
|
||||
|
||||
public ClimateEventHandler() {
|
||||
serverTicks = new HashMap<>();
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onLoadWorld(WorldEvent.Load event){
|
||||
IClimateManager manager = ForestryAPI.climateManager;
|
||||
Integer dimonsionID = Integer.valueOf(event.getWorld().provider.getDimension());
|
||||
Map<Integer, List<IClimateRegion>> regions = manager.getRegions();
|
||||
Map<Integer, Map<BlockPos, IClimateSource>> sources = manager.getSources();
|
||||
if(regions.get(dimonsionID) == null){
|
||||
regions.put(dimonsionID, new ArrayList<>());
|
||||
}
|
||||
if(sources.get(dimonsionID) == null){
|
||||
sources.put(dimonsionID, new HashMap<>());
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onWorldTick(TickEvent.WorldTickEvent event) {
|
||||
Integer dim = Integer.valueOf(event.world.provider.getDimension());
|
||||
if (event.phase == TickEvent.Phase.END) {
|
||||
if(!serverTicks.containsKey(dim)){
|
||||
serverTicks.put(dim, 1);
|
||||
}
|
||||
int ticks = serverTicks.get(dim);
|
||||
Map<Integer, List<IClimateRegion>> regions = ForestryAPI.climateManager.getRegions();
|
||||
if(regions != null && regions.containsKey(dim)){
|
||||
for(IClimateRegion region : regions.get(dim)){
|
||||
if(ticks % region.getTicksPerUpdate() == 0){
|
||||
region.updateClimate();
|
||||
}
|
||||
}
|
||||
}
|
||||
Map<Integer, Map<BlockPos, IClimateSource>> sources = ForestryAPI.climateManager.getSources();
|
||||
if(sources != null && sources.containsKey(dim)){
|
||||
for(IClimateSource source : sources.get(dim).values()){
|
||||
IClimateRegion region = ForestryAPI.climateManager.getRegionForPos(event.world, source.getPos());
|
||||
if(region != null){
|
||||
if(ticks % source.getTicksForChange(region) == 0){
|
||||
source.changeClimate(ticks, region);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
serverTicks.put(dim, ticks+1);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
/*******************************************************************************
|
||||
* 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.core.climate;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import forestry.api.core.IClimateProvider;
|
||||
import forestry.api.core.climate.IClimateManager;
|
||||
import forestry.api.core.climate.IClimatePosition;
|
||||
import forestry.api.core.climate.IClimateRegion;
|
||||
import forestry.api.core.climate.IClimateSource;
|
||||
import forestry.core.DefaultClimateProvider;
|
||||
import forestry.core.multiblock.MultiblockRegistry;
|
||||
import forestry.core.multiblock.MultiblockWorldRegistry;
|
||||
|
||||
public class ClimateManager implements IClimateManager{
|
||||
|
||||
protected Map<Integer, List<IClimateRegion>> regions;
|
||||
protected Map<Integer, Map<BlockPos, IClimateSource>> sources;
|
||||
|
||||
private final Object regionsMutex;
|
||||
|
||||
public ClimateManager() {
|
||||
regions = new HashMap<>();
|
||||
sources = new HashMap<>();
|
||||
regionsMutex = new Object();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRegion(IClimateRegion region) {
|
||||
if(region == null){
|
||||
return;
|
||||
}
|
||||
List<IClimateRegion> regions = this.regions.get(Integer.valueOf(region.getWorld().provider.getDimension()));
|
||||
|
||||
synchronized (regionsMutex) {
|
||||
if(!regions.contains(region)){
|
||||
for(BlockPos pos : region.getPositions().keySet()){
|
||||
if(getRegionForPos(region.getWorld(), pos) != null){
|
||||
return;
|
||||
}
|
||||
}
|
||||
regions.add(region);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeRegion(IClimateRegion region) {
|
||||
if(region == null){
|
||||
return;
|
||||
}
|
||||
synchronized (regionsMutex) {
|
||||
List<IClimateRegion> regions = this.regions.get(Integer.valueOf(region.getWorld().provider.getDimension()));
|
||||
if(regions.contains(region)){
|
||||
regions.remove(region);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeSource(IClimateSource source) {
|
||||
if(sources.get(Integer.valueOf(source.getWorld().provider.getDimension())) == null){
|
||||
sources.put(Integer.valueOf(source.getWorld().provider.getDimension()), new HashMap<>());
|
||||
}
|
||||
if(sources.get(Integer.valueOf(source.getWorld().provider.getDimension())).keySet().contains(source.getPos())){
|
||||
sources.get(Integer.valueOf(source.getWorld().provider.getDimension())).remove(source.getPos(), source);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addSource(IClimateSource source) {
|
||||
if(sources.get(Integer.valueOf(source.getWorld().provider.getDimension())) == null){
|
||||
sources.put(Integer.valueOf(source.getWorld().provider.getDimension()), new HashMap<>());
|
||||
}
|
||||
if(sources.get(Integer.valueOf(source.getWorld().provider.getDimension())).get(source.getPos()) == null){
|
||||
sources.get(Integer.valueOf(source.getWorld().provider.getDimension())).put(source.getPos(), source);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getTemperature(World world, BlockPos pos) {
|
||||
Biome biome = world.getBiome(pos);
|
||||
IClimateRegion region = getRegionForPos(world, pos);
|
||||
if(region!= null){
|
||||
IClimatePosition position = region.getPositions().get(pos);
|
||||
|
||||
if(position != null){
|
||||
return position.getTemperature();
|
||||
}
|
||||
}
|
||||
return biome.getTemperature();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getHumidity(World world, BlockPos pos) {
|
||||
Biome biome = world.getBiome(pos);
|
||||
IClimateRegion region = getRegionForPos(world, pos);
|
||||
if(region!= null){
|
||||
IClimatePosition position = region.getPositions().get(pos);
|
||||
|
||||
if(position != null){
|
||||
return position.getHumidity();
|
||||
}
|
||||
}
|
||||
return biome.getRainfall();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Integer, List<IClimateRegion>> getRegions() {
|
||||
return regions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IClimateRegion getRegionForPos(World world, BlockPos pos){
|
||||
List<IClimateRegion> regions = this.regions.get(Integer.valueOf(world.provider.getDimension()));
|
||||
for(IClimateRegion region : regions){
|
||||
if(region.getPositions().keySet().contains(pos)){
|
||||
return region;
|
||||
}else if(region.getOtherPositions().contains(pos)){
|
||||
return region;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Integer, Map<BlockPos, IClimateSource>> getSources() {
|
||||
return sources;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IClimateProvider getDefaultClimate(World world, BlockPos pos) {
|
||||
return new DefaultClimateProvider(world, pos);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
/*******************************************************************************
|
||||
* 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.core.climate;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import forestry.api.core.climate.IClimateRegion;
|
||||
import forestry.api.core.climate.IClimatePosition;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
|
||||
public class ClimatePosition implements IClimatePosition {
|
||||
|
||||
@Nonnull
|
||||
protected final IClimateRegion climateRegion;
|
||||
@Nonnull
|
||||
protected final BlockPos pos;
|
||||
protected float temperature;
|
||||
protected float humidity;
|
||||
|
||||
public ClimatePosition(IClimateRegion climateRegion, BlockPos pos) {
|
||||
Biome biome = climateRegion.getWorld().getBiome(pos);
|
||||
this.climateRegion = climateRegion;
|
||||
this.pos = pos;
|
||||
this.temperature = biome.getTemperature();
|
||||
this.humidity = biome.getRainfall();
|
||||
}
|
||||
|
||||
public ClimatePosition(@Nonnull IClimateRegion climateRegion, @Nonnull BlockPos pos, float temperature, float humidity) {
|
||||
this.climateRegion = climateRegion;
|
||||
this.pos = pos;
|
||||
this.temperature = temperature;
|
||||
this.humidity = humidity;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IClimateRegion getClimateRegion() {
|
||||
return climateRegion;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public BlockPos getPos() {
|
||||
return pos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTemperature(float temperature) {
|
||||
this.temperature = temperature;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getTemperature() {
|
||||
return temperature;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addTemperature(float temperature) {
|
||||
setTemperature(getTemperature() + temperature);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addHumidity(float humidity) {
|
||||
setHumidity(getHumidity() + humidity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHumidity(float humidity) {
|
||||
this.humidity = humidity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getHumidity() {
|
||||
return humidity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
temperature = nbt.getFloat("Temperature");
|
||||
humidity = nbt.getFloat("Humidity");
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
|
||||
nbt.setFloat("Temperature", temperature);
|
||||
nbt.setFloat("Humidity", humidity);
|
||||
return nbt;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,216 @@
|
||||
package forestry.core.climate;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import forestry.api.core.climate.IClimatePosition;
|
||||
import forestry.api.core.climate.IClimateRegion;
|
||||
import forestry.api.multiblock.IGreenhouseController;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
import forestry.core.network.IStreamable;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
|
||||
public class ClimateRoom implements IClimateRegion, IStreamable {
|
||||
|
||||
protected World world;
|
||||
protected IGreenhouseController controller;
|
||||
protected Map<BlockPos, IClimatePosition> positions;
|
||||
protected List<BlockPos> wallPositions;
|
||||
|
||||
public ClimateRoom(ClimateRoom oldRoom, Map<BlockPos, IClimatePosition> innerPositions, List<BlockPos> wallPositions) {
|
||||
this.world = oldRoom.getWorld();
|
||||
this.controller = oldRoom.controller;
|
||||
Map<BlockPos, IClimatePosition> newPositions = new HashMap<>();
|
||||
for(Entry<BlockPos, IClimatePosition> positionEntry : innerPositions.entrySet()){
|
||||
IClimatePosition position = oldRoom.getPositions().get(positionEntry.getKey());
|
||||
if(position == null){
|
||||
newPositions.put(positionEntry.getKey(), positionEntry.getValue());
|
||||
}else{
|
||||
newPositions.put(positionEntry.getKey(), position);
|
||||
}
|
||||
}
|
||||
this.positions = newPositions;
|
||||
this.wallPositions = wallPositions;
|
||||
}
|
||||
|
||||
public ClimateRoom(IGreenhouseController controller, Map<BlockPos, IClimatePosition> innerPositions, List<BlockPos> wallPositions) {
|
||||
this.world = controller.getWorldObj();
|
||||
this.controller = controller;
|
||||
this.positions = innerPositions;
|
||||
this.wallPositions = wallPositions;
|
||||
}
|
||||
|
||||
public ClimateRoom(IGreenhouseController controller, NBTTagCompound nbtTag) {
|
||||
this.world = controller.getWorldObj();
|
||||
this.controller = controller;
|
||||
this.positions = new HashMap<>();
|
||||
readFromNBT(nbtTag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateClimate() {
|
||||
for(Entry<BlockPos, IClimatePosition> position : positions.entrySet()){
|
||||
BlockPos pos = position.getKey();
|
||||
if(world.isBlockLoaded(pos)){
|
||||
updateSides(pos);
|
||||
if(!controller.isAssembled()){
|
||||
Biome biome = world.getBiome(pos);
|
||||
|
||||
float biomeTemperature = biome.getTemperature();
|
||||
float biomeHumidity = biome.getRainfall();
|
||||
IClimatePosition climatedInfo = positions.get(pos);
|
||||
|
||||
if(climatedInfo.getTemperature() != biomeTemperature){
|
||||
if(climatedInfo.getTemperature() > biomeTemperature){
|
||||
climatedInfo.addTemperature(-0.01F);
|
||||
}else{
|
||||
climatedInfo.addTemperature(0.01F);
|
||||
}
|
||||
}
|
||||
|
||||
if(climatedInfo.getHumidity() != biomeHumidity){
|
||||
if(climatedInfo.getHumidity() > biomeHumidity){
|
||||
climatedInfo.addHumidity(-0.01F);
|
||||
}else{
|
||||
climatedInfo.addHumidity(0.01F);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateSides(BlockPos pos){
|
||||
IClimatePosition climatedInfo = positions.get(pos);
|
||||
for(EnumFacing facing : EnumFacing.VALUES){
|
||||
BlockPos facePos = pos.offset(facing);
|
||||
IClimatePosition climatedInfoFace = positions.get(facePos);
|
||||
if(climatedInfoFace != null){
|
||||
if(climatedInfoFace.getTemperature() >= 2.0F){
|
||||
if(climatedInfoFace.getTemperature() > 2.0F){
|
||||
climatedInfoFace.setTemperature(2.0F);
|
||||
}
|
||||
continue;
|
||||
}else if(climatedInfoFace.getTemperature() <= 0.0F){
|
||||
if(climatedInfoFace.getTemperature() < 0.0F){
|
||||
climatedInfoFace.setTemperature(0.0F);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if(climatedInfoFace.getHumidity() >= 2.0F){
|
||||
if(climatedInfoFace.getHumidity() > 2.0F){
|
||||
climatedInfoFace.setHumidity(2.0F);
|
||||
}
|
||||
continue;
|
||||
}else if(climatedInfoFace.getHumidity() <= 0.0F){
|
||||
if(climatedInfoFace.getHumidity() < 0.0F){
|
||||
climatedInfoFace.setHumidity(0.0F);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if(climatedInfo.getTemperature() > climatedInfoFace.getTemperature() + 0.01F){
|
||||
climatedInfo.addTemperature(-0.01F);
|
||||
climatedInfoFace.addTemperature(0.01F);
|
||||
}
|
||||
if(climatedInfo.getHumidity() > climatedInfoFace.getHumidity() + 0.01F){
|
||||
climatedInfo.addHumidity(-0.01F);
|
||||
climatedInfoFace.addHumidity(0.01F);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
|
||||
NBTTagList positionList = new NBTTagList();
|
||||
for(Entry<BlockPos, IClimatePosition> entry : positions.entrySet()){
|
||||
BlockPos pos = entry.getKey();
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
tag.setInteger("XPos", pos.getX());
|
||||
tag.setInteger("YPos", pos.getY());
|
||||
tag.setInteger("ZPos", pos.getZ());
|
||||
positionList.appendTag(entry.getValue().writeToNBT(tag));
|
||||
}
|
||||
nbt.setTag("Positions", positionList);
|
||||
return nbt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
NBTTagList positionList = nbt.getTagList("Positions", 10);
|
||||
for(int i = 0;i < positionList.tagCount();i++){
|
||||
NBTTagCompound positionTag = positionList.getCompoundTagAt(i);
|
||||
int xPos = positionTag.getInteger("XPos");
|
||||
int yPos = positionTag.getInteger("YPos");
|
||||
int zPos = positionTag.getInteger("ZPos");
|
||||
BlockPos pos = new BlockPos(xPos, yPos, zPos);
|
||||
ClimatePosition position = new ClimatePosition(this, pos);
|
||||
position.readFromNBT(positionTag);
|
||||
positions.put(pos, position);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTicksPerUpdate() {
|
||||
return 20;
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorld() {
|
||||
return world;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<BlockPos, IClimatePosition> getPositions() {
|
||||
return positions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BlockPos> getOtherPositions() {
|
||||
return wallPositions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeData(DataOutputStreamForestry data) throws IOException {
|
||||
if(!positions.isEmpty()){
|
||||
data.writeInt(positions.size());
|
||||
for(IClimatePosition pos : positions.values()){
|
||||
data.writeInt(pos.getPos().getX());
|
||||
data.writeInt(pos.getPos().getY());
|
||||
data.writeInt(pos.getPos().getZ());
|
||||
data.writeFloat(pos.getTemperature());
|
||||
data.writeFloat(pos.getHumidity());
|
||||
}
|
||||
}else{
|
||||
data.writeInt(0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readData(DataInputStreamForestry data) throws IOException {
|
||||
int size = data.readInt();
|
||||
if(size != 0){
|
||||
positions = new HashMap<>();
|
||||
for(int index = 0;index < size;index++){
|
||||
int xPos = data.readInt();
|
||||
int yPos = data.readInt();
|
||||
int zPos = data.readInt();
|
||||
float temperature = data.readFloat();
|
||||
float humidity = data.readFloat();
|
||||
|
||||
BlockPos pos = new BlockPos(xPos, yPos, zPos);
|
||||
positions.put(pos, new ClimatePosition(this, pos, temperature, humidity));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -88,7 +88,7 @@ public class ParticleColoredDripParticle extends Particle {
|
||||
d0 = BlockLiquid.getLiquidHeightPercent(iblockstate.getValue(BlockLiquid.LEVEL));
|
||||
}
|
||||
|
||||
double d1 = (double) (MathHelper.floor_double(this.posY) + 1) - d0;
|
||||
double d1 = MathHelper.floor_double(this.posY) + 1 - d0;
|
||||
|
||||
if (this.posY < d1) {
|
||||
this.setExpired();
|
||||
|
||||
@@ -14,6 +14,11 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.common.BiomeDictionary;
|
||||
import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import forestry.api.core.IClimateProvider;
|
||||
@@ -23,10 +28,6 @@ import forestry.api.genetics.IGenome;
|
||||
import forestry.api.genetics.IMutation;
|
||||
import forestry.api.genetics.IMutationBuilder;
|
||||
import forestry.api.genetics.IMutationCondition;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.BiomeDictionary;
|
||||
|
||||
public abstract class Mutation implements IMutation, IMutationBuilder {
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@ import forestry.core.gui.slots.SlotOutput;
|
||||
import forestry.core.inventory.InventoryEscritoire;
|
||||
import forestry.core.network.packets.PacketGuiSelectRequest;
|
||||
import forestry.core.network.packets.PacketGuiUpdate;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.tiles.EscritoireGame;
|
||||
import forestry.core.tiles.TileEscritoire;
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
******************************************************************************/
|
||||
package forestry.core.gui;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Stack;
|
||||
|
||||
@@ -94,6 +94,10 @@ public class ItemCraftingMaterial extends ItemForestry {
|
||||
}
|
||||
|
||||
public ItemStack getCamouflagedPaneling() {
|
||||
return new ItemStack(this, 1, 7);
|
||||
return getCamouflagedPaneling(1);
|
||||
}
|
||||
|
||||
public ItemStack getCamouflagedPaneling(int stackSize) {
|
||||
return new ItemStack(this, stackSize, 7);
|
||||
}
|
||||
}
|
||||
@@ -19,13 +19,19 @@ public class BlockModelIndex {
|
||||
public final ModelResourceLocation blockModelLocation;
|
||||
public final ModelResourceLocation itemModelLocation;
|
||||
public final IBakedModel model;
|
||||
public final boolean addStateMapper;
|
||||
public final Block block;
|
||||
|
||||
public BlockModelIndex(ModelResourceLocation blockModelLocation, ModelResourceLocation itemModelLocation, IBakedModel model, Block block) {
|
||||
this(blockModelLocation, itemModelLocation, model, block, true);
|
||||
}
|
||||
|
||||
public BlockModelIndex(ModelResourceLocation blockModelLocation, ModelResourceLocation itemModelLocation, IBakedModel model, Block block, boolean addStateMapper) {
|
||||
this.blockModelLocation = blockModelLocation;
|
||||
this.itemModelLocation = itemModelLocation;
|
||||
this.model = model;
|
||||
this.block = block;
|
||||
this.addStateMapper = addStateMapper;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -23,7 +23,6 @@ import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.ItemMeshDefinition;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType;
|
||||
import net.minecraft.client.renderer.block.model.ModelBakery;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.client.renderer.color.BlockColors;
|
||||
import net.minecraft.client.renderer.color.IBlockColor;
|
||||
@@ -31,7 +30,6 @@ import net.minecraft.client.renderer.color.IItemColor;
|
||||
import net.minecraft.client.renderer.color.ItemColors;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.registry.IRegistry;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
@@ -262,7 +260,9 @@ public class ModelManager implements IModelManager {
|
||||
IRegistry<ModelResourceLocation, IBakedModel> registry = event.getModelRegistry();
|
||||
for (final BlockModelIndex index : customBlockModels) {
|
||||
registry.putObject(index.blockModelLocation, index.model);
|
||||
registry.putObject(index.itemModelLocation, index.model);
|
||||
if(index.itemModelLocation != null){
|
||||
registry.putObject(index.itemModelLocation, index.model);
|
||||
}
|
||||
}
|
||||
|
||||
for (final ModelIndex index : customModels) {
|
||||
|
||||
@@ -12,7 +12,6 @@ package forestry.core.models.baker;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@@ -11,10 +11,12 @@
|
||||
package forestry.core.multiblock;
|
||||
|
||||
import forestry.api.multiblock.IMultiblockLogicAlveary;
|
||||
import forestry.api.multiblock.IMultiblockLogicCharcoalPile;
|
||||
import forestry.api.multiblock.IMultiblockLogicFactory;
|
||||
import forestry.api.multiblock.IMultiblockLogicFarm;
|
||||
import forestry.api.multiblock.IMultiblockLogicGreenhouse;
|
||||
import forestry.apiculture.multiblock.MultiblockLogicAlveary;
|
||||
import forestry.arboriculture.multiblock.MultiblockLogicCharcoalPile;
|
||||
import forestry.farming.multiblock.MultiblockLogicFarm;
|
||||
import forestry.greenhouse.multiblock.MultiblockLogicGreenhouse;
|
||||
|
||||
@@ -34,4 +36,9 @@ public class MultiblockLogicFactory implements IMultiblockLogicFactory {
|
||||
public IMultiblockLogicGreenhouse createGreenhouseLogic() {
|
||||
return new MultiblockLogicGreenhouse();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMultiblockLogicCharcoalPile createCharcoalPileLogic() {
|
||||
return new MultiblockLogicCharcoalPile();
|
||||
}
|
||||
}
|
||||
@@ -18,14 +18,11 @@ import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.management.UserListOpsEntry;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fml.client.FMLClientHandler;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
|
||||
import forestry.core.TickHandlerCoreServer;
|
||||
|
||||
@@ -136,8 +136,10 @@ public class ProxyRenderClient extends ProxyRender {
|
||||
@Override
|
||||
public void registerBlockModel(@Nonnull final BlockModelIndex index) {
|
||||
ModelManager.getInstance().registerCustomBlockModel(index);
|
||||
StateMapperBase ignoreState = new BlockModeStateMapper(index);
|
||||
registerStateMapper(index.block, ignoreState);
|
||||
if(index.addStateMapper){
|
||||
StateMapperBase ignoreState = new BlockModeStateMapper(index);
|
||||
registerStateMapper(index.block, ignoreState);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -15,8 +15,6 @@ import javax.annotation.Nullable;
|
||||
import java.io.IOException;
|
||||
import java.util.Random;
|
||||
|
||||
import forestry.core.owner.IOwnedTile;
|
||||
import forestry.core.owner.IOwnerHandler;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
@@ -37,7 +35,6 @@ import net.minecraftforge.items.wrapper.SidedInvWrapper;
|
||||
|
||||
import forestry.api.core.IErrorLogic;
|
||||
import forestry.api.core.IErrorLogicSource;
|
||||
import forestry.core.owner.OwnerHandler;
|
||||
import forestry.core.errors.ErrorLogic;
|
||||
import forestry.core.gui.IGuiHandlerTile;
|
||||
import forestry.core.inventory.FakeInventoryAdapter;
|
||||
|
||||
@@ -12,7 +12,6 @@ package forestry.core.utils;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import forestry.api.core.EnumCamouflageType;
|
||||
import forestry.api.core.ICamouflageHandler;
|
||||
import forestry.api.core.ICamouflagedTile;
|
||||
import forestry.api.multiblock.IMultiblockComponent;
|
||||
@@ -26,26 +25,26 @@ import net.minecraft.world.IBlockAccess;
|
||||
|
||||
public class CamouflageUtil {
|
||||
|
||||
public static void writeCamouflageBlockToNBT(NBTTagCompound data, ICamouflageHandler handler, EnumCamouflageType type){
|
||||
public static void writeCamouflageBlockToNBT(NBTTagCompound data, ICamouflageHandler handler, String type){
|
||||
ItemStack camouflageBlock = handler.getCamouflageBlock(type);
|
||||
if(camouflageBlock != null){
|
||||
NBTTagCompound nbtTag = new NBTTagCompound();
|
||||
camouflageBlock.writeToNBT(nbtTag);
|
||||
data.setTag("Camouflage" + type.name(), nbtTag);
|
||||
data.setTag("Camouflage" + type, nbtTag);
|
||||
}
|
||||
}
|
||||
|
||||
public static void readCamouflageBlockFromNBT(NBTTagCompound data, ICamouflageHandler handler, EnumCamouflageType type){
|
||||
if(data.hasKey("Camouflage" + type.name())){
|
||||
handler.setCamouflageBlock(type, ItemStack.loadItemStackFromNBT(data.getCompoundTag("Camouflage" + type.name())));
|
||||
public static void readCamouflageBlockFromNBT(NBTTagCompound data, ICamouflageHandler handler, String type){
|
||||
if(data.hasKey("Camouflage" + type)){
|
||||
handler.setCamouflageBlock(type, ItemStack.loadItemStackFromNBT(data.getCompoundTag("Camouflage" + type)));
|
||||
}
|
||||
}
|
||||
|
||||
public static void writeCamouflageBlockToData(DataOutputStreamForestry data, ICamouflageHandler handler, EnumCamouflageType type) throws IOException{
|
||||
public static void writeCamouflageBlockToData(DataOutputStreamForestry data, ICamouflageHandler handler, String type) throws IOException{
|
||||
ItemStack camouflageBlock = handler.getCamouflageBlock(type);
|
||||
if(camouflageBlock != null){
|
||||
data.writeShort(1);
|
||||
data.writeShort(type.ordinal());
|
||||
data.writeUTF(type);
|
||||
data.writeItemStack(camouflageBlock);
|
||||
}else{
|
||||
data.writeShort(0);
|
||||
@@ -54,7 +53,7 @@ public class CamouflageUtil {
|
||||
|
||||
public static void readCamouflageBlockFromData(DataInputStreamForestry data, ICamouflageHandler handler) throws IOException{
|
||||
if(data.readShort() == 1){
|
||||
handler.setCamouflageBlock(EnumCamouflageType.VALUES[data.readShort()], data.readItemStack());
|
||||
handler.setCamouflageBlock(data.readUTF(), data.readItemStack());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,29 +62,50 @@ public class CamouflageUtil {
|
||||
return null;
|
||||
}
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
|
||||
if(tile instanceof ICamouflageHandler){
|
||||
return (ICamouflageHandler) tile;
|
||||
}
|
||||
if(tile instanceof IMultiblockComponent){
|
||||
IMultiblockComponent component = (IMultiblockComponent) tile;
|
||||
if(component.getMultiblockLogic().getController() instanceof ICamouflageHandler){
|
||||
return (ICamouflageHandler) component.getMultiblockLogic().getController();
|
||||
if(tile instanceof ICamouflagedTile){
|
||||
ICamouflagedTile block = (ICamouflagedTile) tile;
|
||||
String type = block.getCamouflageType();
|
||||
ItemStack camouflageStack = null;
|
||||
ICamouflageHandler handler = null;
|
||||
if(tile instanceof ICamouflageHandler){
|
||||
handler = (ICamouflageHandler) tile;
|
||||
camouflageStack = handler.getCamouflageBlock(type);
|
||||
}
|
||||
if(camouflageStack == null && tile instanceof IMultiblockComponent){
|
||||
IMultiblockComponent component = (IMultiblockComponent) tile;
|
||||
if(component.getMultiblockLogic().getController() instanceof ICamouflageHandler){
|
||||
handler = (ICamouflageHandler) component.getMultiblockLogic().getController();
|
||||
}
|
||||
}
|
||||
return handler;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static ItemStack getCamouflageBlock(IBlockAccess world, BlockPos pos){
|
||||
ICamouflageHandler handler = getCamouflageHandler(world, pos);
|
||||
if(handler == null){
|
||||
if(pos == null){
|
||||
return null;
|
||||
}
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
if(tile instanceof ICamouflagedTile){
|
||||
ICamouflagedTile block = (ICamouflagedTile) tile;
|
||||
|
||||
return handler.getCamouflageBlock(block.getCamouflageType());
|
||||
String type = block.getCamouflageType();
|
||||
ItemStack camouflageStack = null;
|
||||
if(tile instanceof ICamouflageHandler){
|
||||
ICamouflageHandler handler = (ICamouflageHandler) tile;
|
||||
camouflageStack = handler.getCamouflageBlock(type);
|
||||
}
|
||||
if(camouflageStack == null && tile instanceof IMultiblockComponent){
|
||||
IMultiblockComponent component = (IMultiblockComponent) tile;
|
||||
if(component.getMultiblockLogic().getController() instanceof ICamouflageHandler){
|
||||
ICamouflageHandler handler = (ICamouflageHandler) component.getMultiblockLogic().getController();
|
||||
camouflageStack = handler.getCamouflageBlock(type);
|
||||
if(camouflageStack == null){
|
||||
camouflageStack = handler.getDefaultCamouflageBlock(type);
|
||||
}
|
||||
}
|
||||
}
|
||||
return camouflageStack;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -199,7 +199,7 @@ public abstract class ItemStackUtil {
|
||||
public static ItemStack createSplitStack(ItemStack stack, int amount) {
|
||||
ItemStack split = new ItemStack(stack.getItem(), amount, stack.getItemDamage());
|
||||
if (stack.getTagCompound() != null) {
|
||||
NBTTagCompound nbttagcompound = (NBTTagCompound) stack.getTagCompound().copy();
|
||||
NBTTagCompound nbttagcompound = stack.getTagCompound().copy();
|
||||
split.setTagCompound(nbttagcompound);
|
||||
}
|
||||
return split;
|
||||
|
||||
@@ -25,8 +25,6 @@ import com.mojang.authlib.GameProfile;
|
||||
|
||||
import net.minecraftforge.common.util.FakePlayerFactory;
|
||||
|
||||
import forestry.core.owner.IOwnerHandler;
|
||||
|
||||
public abstract class PlayerUtil {
|
||||
|
||||
//TODO: use null everywhere instead of an emptyUUID
|
||||
|
||||
@@ -12,7 +12,6 @@ package forestry.factory.inventory;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import forestry.core.owner.IOwnedTile;
|
||||
import forestry.core.inventory.InventoryAdapterTile;
|
||||
|
||||
public class InventoryGhostCrafting<T extends TileEntity> extends InventoryAdapterTile<T> {
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
******************************************************************************/
|
||||
package forestry.factory.inventory;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
@@ -9,8 +9,6 @@ import forestry.api.recipes.IFermenterRecipe;
|
||||
import forestry.api.recipes.IVariableFermentable;
|
||||
import forestry.api.recipes.RecipeManagers;
|
||||
import forestry.core.utils.Log;
|
||||
import forestry.factory.recipes.jei.FactoryJeiPlugin;
|
||||
|
||||
import mezz.jei.api.recipe.IStackHelper;
|
||||
|
||||
public class FermenterRecipeMaker {
|
||||
|
||||
@@ -2,11 +2,8 @@ package forestry.factory.recipes.jei.squeezer;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import forestry.api.recipes.ISqueezerRecipe;
|
||||
import forestry.core.recipes.jei.ForestryRecipeCategoryUid;
|
||||
import forestry.core.recipes.jei.ForestryRecipeWrapper;
|
||||
import forestry.factory.recipes.ISqueezerContainerRecipe;
|
||||
|
||||
import mezz.jei.api.recipe.IRecipeHandler;
|
||||
import mezz.jei.api.recipe.IRecipeWrapper;
|
||||
|
||||
|
||||
@@ -42,7 +42,6 @@ import forestry.core.tiles.IItemStackDisplay;
|
||||
import forestry.core.tiles.ILiquidTankTile;
|
||||
import forestry.core.tiles.TilePowered;
|
||||
import forestry.core.utils.InventoryUtil;
|
||||
import forestry.core.utils.PlayerUtil;
|
||||
import forestry.factory.gui.ContainerCarpenter;
|
||||
import forestry.factory.gui.GuiCarpenter;
|
||||
import forestry.factory.inventory.InventoryCarpenter;
|
||||
|
||||
@@ -1,57 +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.greenhouse;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import forestry.api.greenhouse.IGreenhouseState;
|
||||
import forestry.api.greenhouse.IInternalBlock;
|
||||
import forestry.api.multiblock.IMultiblockComponent;
|
||||
|
||||
public class FakeGreenhouseState implements IGreenhouseState {
|
||||
|
||||
public static final FakeGreenhouseState instance = new FakeGreenhouseState();
|
||||
|
||||
@Override
|
||||
public EnumTemperature getTemperature() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumHumidity getHumidity() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getExactTemperature() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getExactHumidity() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<IInternalBlock> getInternalBlocks() {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<IMultiblockComponent> getGreenhouseComponents() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,124 +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.greenhouse;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import forestry.api.core.EnumCamouflageType;
|
||||
import forestry.api.greenhouse.IGreenhouseAccess;
|
||||
import forestry.core.utils.Log;
|
||||
|
||||
public class GreenhouseAccess implements IGreenhouseAccess {
|
||||
|
||||
private final Map<ItemStack, Float> greenhouseGlasses = new HashMap<>();
|
||||
private final Map<EnumCamouflageType, List<ItemStack>> camouflageBlockBlacklist = new EnumMap<>(EnumCamouflageType.class);
|
||||
|
||||
public GreenhouseAccess() {
|
||||
for (EnumCamouflageType type : EnumCamouflageType.VALUES) {
|
||||
camouflageBlockBlacklist.put(type, new ArrayList<>());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerGreenhouseGlass(@Nonnull ItemStack glass, float lightTransmittance) {
|
||||
if (glass == null || glass.getItem() == null) {
|
||||
Log.error("Fail to register greenhouse glass, because it is null");
|
||||
return;
|
||||
}
|
||||
Block block = Block.getBlockFromItem(glass.getItem());
|
||||
if (block == null) {
|
||||
Log.error("Fail to register greenhouse glass, it has no matching block: " + glass + ".");
|
||||
return;
|
||||
}
|
||||
IBlockState defaultBlockState = block.getDefaultState();
|
||||
if (block.isOpaqueCube(defaultBlockState)) {
|
||||
Log.error("Fail to register greenhouse glass, it is opaque: " + block + ".");
|
||||
return;
|
||||
}
|
||||
for (ItemStack greenhouseGlass : greenhouseGlasses.keySet()) {
|
||||
if (greenhouseGlass.getItem() == glass.getItem() && greenhouseGlass.getItemDamage() == glass.getItemDamage() && ItemStack.areItemStackTagsEqual(glass, greenhouseGlass)) {
|
||||
Log.error("Fail to register greenhouse glass, because it is already registered: " + glass + ".");
|
||||
return;
|
||||
}
|
||||
}
|
||||
greenhouseGlasses.put(glass, lightTransmittance);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getGreenhouseGlassLightTransmittance(@Nonnull ItemStack glass) {
|
||||
if (glass == null || glass.getItem() == null || Block.getBlockFromItem(glass.getItem()) == null) {
|
||||
return 0.5F;
|
||||
}
|
||||
for (Map.Entry<ItemStack, Float> greenhouseGlassEntry : greenhouseGlasses.entrySet()) {
|
||||
ItemStack greenhouseGlass = greenhouseGlassEntry.getKey();
|
||||
if (greenhouseGlass.getItem() == glass.getItem() && greenhouseGlass.getItemDamage() == glass.getItemDamage() && ItemStack.areItemStackTagsEqual(glass, greenhouseGlass)) {
|
||||
return greenhouseGlassEntry.getValue();
|
||||
}
|
||||
}
|
||||
return 0.5F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGreenhouseGlass(@Nonnull ItemStack glass) {
|
||||
if (glass == null || glass.getItem() == null || Block.getBlockFromItem(glass.getItem()) == null) {
|
||||
return false;
|
||||
}
|
||||
for (ItemStack greenhouseGlass : greenhouseGlasses.keySet()) {
|
||||
if (greenhouseGlass.getItem() == glass.getItem() && greenhouseGlass.getItemDamage() == glass.getItemDamage() && ItemStack.areItemStackTagsEqual(glass, greenhouseGlass)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addToCamouflageBlockBlackList(@Nonnull EnumCamouflageType type, @Nonnull ItemStack camouflageBlock) {
|
||||
if (camouflageBlock == null || camouflageBlock.getItem() == null) {
|
||||
Log.error("Fail to add camouflage block item to the black list, because it is null");
|
||||
return;
|
||||
}
|
||||
Block block = Block.getBlockFromItem(camouflageBlock.getItem());
|
||||
if (block == null) {
|
||||
Log.error("Fail to add camouflage block item to the black list: because it has no block.");
|
||||
return;
|
||||
}
|
||||
for (ItemStack camouflageBlacklisted : camouflageBlockBlacklist.get(type)) {
|
||||
if (camouflageBlacklisted.getItem() == camouflageBlock.getItem() && camouflageBlacklisted.getItemDamage() == camouflageBlock.getItemDamage() && ItemStack.areItemStackTagsEqual(camouflageBlock, camouflageBlacklisted)) {
|
||||
Log.error("Fail to add camouflage block item to the black list, because it is already registered: " + camouflageBlock + ".");
|
||||
return;
|
||||
}
|
||||
}
|
||||
camouflageBlockBlacklist.get(type).add(camouflageBlock);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOnCamouflageBlockBlackList(@Nonnull EnumCamouflageType type, @Nonnull ItemStack camouflageBlock) {
|
||||
if (camouflageBlock == null || camouflageBlock.getItem() == null || Block.getBlockFromItem(camouflageBlock.getItem()) == null) {
|
||||
return false;
|
||||
}
|
||||
for (ItemStack camouflageBlacklisted : camouflageBlockBlacklist.get(type)) {
|
||||
if (camouflageBlacklisted.getItem() == camouflageBlock.getItem() && camouflageBlacklisted.getItemDamage() == camouflageBlock.getItemDamage() && ItemStack.areItemStackTagsEqual(camouflageBlock, camouflageBlacklisted)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -13,9 +13,13 @@ package forestry.greenhouse;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import forestry.api.greenhouse.IGreenhouseHelper;
|
||||
import forestry.api.greenhouse.IGreenhouseState;
|
||||
import forestry.api.greenhouse.IGreenhouseLogic;
|
||||
import forestry.api.greenhouse.IInternalBlock;
|
||||
import forestry.api.multiblock.IGreenhouseController;
|
||||
import forestry.core.multiblock.IMultiblockControllerInternal;
|
||||
import forestry.core.multiblock.MultiblockRegistry;
|
||||
import forestry.greenhouse.multiblock.IGreenhouseControllerInternal;
|
||||
@@ -23,14 +27,16 @@ import forestry.greenhouse.multiblock.InternalBlockCheck;
|
||||
|
||||
public class GreenhouseHelper implements IGreenhouseHelper {
|
||||
|
||||
private final List<Class<? extends IGreenhouseLogic>> greenhouseLogics = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public IGreenhouseState getGreenhouseState(World world, BlockPos pos) {
|
||||
public IGreenhouseController getGreenhouseController(World world, BlockPos pos) {
|
||||
if (MultiblockRegistry.getControllersFromWorld(world) != null) {
|
||||
for (IMultiblockControllerInternal controllerInternal : MultiblockRegistry.getControllersFromWorld(world)) {
|
||||
if (controllerInternal instanceof IGreenhouseControllerInternal) {
|
||||
if (controllerInternal.isAssembled()) {
|
||||
if (isPositionInGreenhouse((IGreenhouseControllerInternal) controllerInternal, pos)) {
|
||||
return ((IGreenhouseControllerInternal) controllerInternal).createState();
|
||||
return (IGreenhouseController) controllerInternal;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -43,5 +49,17 @@ public class GreenhouseHelper implements IGreenhouseHelper {
|
||||
IInternalBlock checkBlock = new InternalBlockCheck(pos);
|
||||
return controller.getInternalBlocks().contains(checkBlock);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addGreenhouseLogic(Class<? extends IGreenhouseLogic> logic) {
|
||||
if(!greenhouseLogics.contains(logic)){
|
||||
greenhouseLogics.add(logic);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Class<? extends IGreenhouseLogic>> getGreenhouseLogics() {
|
||||
return greenhouseLogics;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,71 +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.greenhouse;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
|
||||
import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import forestry.api.greenhouse.IGreenhouseState;
|
||||
import forestry.api.greenhouse.IInternalBlock;
|
||||
import forestry.api.multiblock.IMultiblockComponent;
|
||||
import forestry.greenhouse.multiblock.GreenhouseController;
|
||||
|
||||
public final class GreenhouseState implements IGreenhouseState {
|
||||
|
||||
private final float humidity;
|
||||
private final float temperature;
|
||||
private final Set<IInternalBlock> internalBlocks;
|
||||
private final Collection<IMultiblockComponent> greenhouseComponents;
|
||||
|
||||
public GreenhouseState(float humidity, float temperature, Set<IInternalBlock> internalBlocks, Collection<IMultiblockComponent> greenhouseComponents) {
|
||||
this.humidity = humidity;
|
||||
this.temperature = temperature;
|
||||
this.internalBlocks = internalBlocks;
|
||||
this.greenhouseComponents = greenhouseComponents;
|
||||
}
|
||||
|
||||
public GreenhouseState(GreenhouseController controller) {
|
||||
this(controller.getExactHumidity(), controller.getExactTemperature(), controller.getInternalBlocks(), controller.getComponents());
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumTemperature getTemperature() {
|
||||
return EnumTemperature.getFromValue(temperature);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumHumidity getHumidity() {
|
||||
return EnumHumidity.getFromValue(humidity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getExactTemperature() {
|
||||
return temperature;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getExactHumidity() {
|
||||
return humidity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<IInternalBlock> getInternalBlocks() {
|
||||
return internalBlocks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<IMultiblockComponent> getGreenhouseComponents() {
|
||||
return greenhouseComponents;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -20,7 +20,6 @@ import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.greenhouse.GreenhouseManager;
|
||||
import forestry.api.greenhouse.IGreenhouseAccess;
|
||||
import forestry.api.recipes.RecipeManagers;
|
||||
import forestry.core.PluginCore;
|
||||
import forestry.core.config.Constants;
|
||||
@@ -60,7 +59,6 @@ public class PluginGreenhouse extends BlankForestryPlugin {
|
||||
|
||||
@Override
|
||||
public void setupAPI() {
|
||||
GreenhouseManager.greenhouseAccess = new GreenhouseAccess();
|
||||
GreenhouseManager.greenhouseHelper = new GreenhouseHelper();
|
||||
}
|
||||
|
||||
@@ -174,7 +172,7 @@ public class PluginGreenhouse extends BlankForestryPlugin {
|
||||
'G', blocks.getGreenhouseBlock(BlockGreenhouseType.GLASS));
|
||||
|
||||
if (ForestryAPI.enabledPlugins.contains(ForestryPluginUids.FACTORY)) {
|
||||
RecipeManagers.carpenterManager.addRecipe(50, Fluids.BIOMASS.getFluid(500), null, PluginCore.items.craftingMaterial.getCamouflagedPaneling(),
|
||||
RecipeManagers.carpenterManager.addRecipe(50, Fluids.BIOMASS.getFluid(500), null, PluginCore.items.craftingMaterial.getCamouflagedPaneling(4),
|
||||
" A ", "###", "RPR",
|
||||
'#', "plankWood",
|
||||
'A', "dustAsh",
|
||||
@@ -206,30 +204,10 @@ public class PluginGreenhouse extends BlankForestryPlugin {
|
||||
public void preInit() {
|
||||
MinecraftForge.EVENT_BUS.register(new EventHandlerGreenhouse());
|
||||
|
||||
IGreenhouseAccess greenhouseAccess = GreenhouseManager.greenhouseAccess;
|
||||
|
||||
greenhouseAccess.registerGreenhouseGlass(new ItemStack(Blocks.GLASS, 1, 0), 0.5F);
|
||||
greenhouseAccess.registerGreenhouseGlass(new ItemStack(Blocks.STAINED_GLASS, 1, 0), 0.25F);
|
||||
greenhouseAccess.registerGreenhouseGlass(new ItemStack(Blocks.STAINED_GLASS, 1, 1), 0.25F);
|
||||
greenhouseAccess.registerGreenhouseGlass(new ItemStack(Blocks.STAINED_GLASS, 1, 2), 0.25F);
|
||||
greenhouseAccess.registerGreenhouseGlass(new ItemStack(Blocks.STAINED_GLASS, 1, 3), 0.25F);
|
||||
greenhouseAccess.registerGreenhouseGlass(new ItemStack(Blocks.STAINED_GLASS, 1, 4), 0.25F);
|
||||
greenhouseAccess.registerGreenhouseGlass(new ItemStack(Blocks.STAINED_GLASS, 1, 5), 0.25F);
|
||||
greenhouseAccess.registerGreenhouseGlass(new ItemStack(Blocks.STAINED_GLASS, 1, 6), 0.25F);
|
||||
greenhouseAccess.registerGreenhouseGlass(new ItemStack(Blocks.STAINED_GLASS, 1, 7), 0.25F);
|
||||
greenhouseAccess.registerGreenhouseGlass(new ItemStack(Blocks.STAINED_GLASS, 1, 8), 0.25F);
|
||||
greenhouseAccess.registerGreenhouseGlass(new ItemStack(Blocks.STAINED_GLASS, 1, 9), 0.25F);
|
||||
greenhouseAccess.registerGreenhouseGlass(new ItemStack(Blocks.STAINED_GLASS, 1, 10), 0.25F);
|
||||
greenhouseAccess.registerGreenhouseGlass(new ItemStack(Blocks.STAINED_GLASS, 1, 11), 0.25F);
|
||||
greenhouseAccess.registerGreenhouseGlass(new ItemStack(Blocks.STAINED_GLASS, 1, 12), 0.25F);
|
||||
greenhouseAccess.registerGreenhouseGlass(new ItemStack(Blocks.STAINED_GLASS, 1, 13), 0.25F);
|
||||
greenhouseAccess.registerGreenhouseGlass(new ItemStack(Blocks.STAINED_GLASS, 1, 14), 0.25F);
|
||||
greenhouseAccess.registerGreenhouseGlass(new ItemStack(Blocks.STAINED_GLASS, 1, 15), 0.25F);
|
||||
|
||||
proxy.initializeModels();
|
||||
|
||||
GreenhouseManager.greenhouseLogics.add(GreenhouseLogicGreenhouseEffect.class);
|
||||
GreenhouseManager.greenhouseLogics.add(GreenhouseLogicGreenhouseDoor.class);
|
||||
GreenhouseManager.greenhouseHelper.addGreenhouseLogic(GreenhouseLogicGreenhouseEffect.class);
|
||||
GreenhouseManager.greenhouseHelper.addGreenhouseLogic(GreenhouseLogicGreenhouseDoor.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -160,7 +160,7 @@ public abstract class BlockGreenhouse extends BlockStructure implements ISpriteR
|
||||
|
||||
@Override
|
||||
public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos) {
|
||||
if (getGreenhouseType() != BlockGreenhouseType.SPRINKLER && getGreenhouseType() != BlockGreenhouseType.DOOR) {
|
||||
if (getGreenhouseType() != BlockGreenhouseType.SPRINKLER) {
|
||||
return ((IExtendedBlockState) super.getExtendedState(state, world, pos)).withProperty(UnlistedBlockPos.POS, pos)
|
||||
.withProperty(UnlistedBlockAccess.BLOCKACCESS, world);
|
||||
}
|
||||
@@ -186,7 +186,7 @@ public abstract class BlockGreenhouse extends BlockStructure implements ISpriteR
|
||||
return super.getActualState(state, worldIn, pos);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubBlocks(Item item, CreativeTabs tab, List<ItemStack> list) {
|
||||
@@ -209,10 +209,10 @@ public abstract class BlockGreenhouse extends BlockStructure implements ISpriteR
|
||||
return new TileGreenhouseFan();
|
||||
case HEATER:
|
||||
return new TileGreenhouseHeater();
|
||||
case CONTROL:
|
||||
return new TileGreenhouseControl();
|
||||
case DOOR:
|
||||
return new TileGreenhouseDoor();
|
||||
case CONTROL:
|
||||
return new TileGreenhouseControl();
|
||||
case HATCH_INPUT:
|
||||
case HATCH_OUTPUT:
|
||||
return new TileGreenhouseHatch();
|
||||
@@ -234,11 +234,13 @@ public abstract class BlockGreenhouse extends BlockStructure implements ISpriteR
|
||||
|
||||
if (tintIndex < 100 && camouflageStack != null) {
|
||||
Block block = Block.getBlockFromItem(camouflageStack.getItem());
|
||||
IBlockState camouflageState = block.getStateFromMeta(camouflageStack.getItemDamage());
|
||||
|
||||
int color = Minecraft.getMinecraft().getBlockColors().colorMultiplier(camouflageState, worldIn, pos, tintIndex);
|
||||
if(color != -1){
|
||||
return color;
|
||||
if(block != null){
|
||||
IBlockState camouflageState = block.getStateFromMeta(camouflageStack.getItemDamage());
|
||||
|
||||
int color = Minecraft.getMinecraft().getBlockColors().colorMultiplier(camouflageState, worldIn, pos, tintIndex);
|
||||
if(color != -1){
|
||||
return color;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,13 +17,13 @@ import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockDoor;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.EnumPushReaction;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.properties.PropertyBool;
|
||||
import net.minecraft.block.properties.PropertyDirection;
|
||||
import net.minecraft.block.properties.PropertyEnum;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.client.renderer.block.statemap.StateMap;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -37,14 +37,20 @@ import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
import net.minecraftforge.common.property.ExtendedBlockState;
|
||||
import net.minecraftforge.common.property.IUnlistedProperty;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.core.IModelManager;
|
||||
import forestry.api.core.IStateMapperRegister;
|
||||
import forestry.core.blocks.propertys.UnlistedBlockAccess;
|
||||
import forestry.core.blocks.propertys.UnlistedBlockPos;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.tiles.TileUtil;
|
||||
import forestry.core.utils.CamouflageUtil;
|
||||
import forestry.core.utils.Translator;
|
||||
import forestry.greenhouse.tiles.TileGreenhouseDoor;
|
||||
import forestry.greenhouse.models.GreenhouseDoorStateMapper;
|
||||
import forestry.greenhouse.tiles.TileGreenhouse;
|
||||
|
||||
public class BlockGreenhouseDoor extends BlockGreenhouse implements IStateMapperRegister {
|
||||
|
||||
@@ -54,6 +60,7 @@ public class BlockGreenhouseDoor extends BlockGreenhouse implements IStateMapper
|
||||
private static final PropertyEnum<BlockDoor.EnumHingePosition> HINGE = BlockDoor.HINGE;
|
||||
private static final PropertyBool POWERED = BlockDoor.POWERED;
|
||||
private static final PropertyEnum<BlockDoor.EnumDoorHalf> HALF = BlockDoor.HALF;
|
||||
public static final PropertyBool CAMOUFLAGED = PropertyBool.create("camouflaged");
|
||||
|
||||
protected static final AxisAlignedBB SOUTH_AABB = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 0.1875D);
|
||||
protected static final AxisAlignedBB NORTH_AABB = new AxisAlignedBB(0.0D, 0.0D, 0.8125D, 1.0D, 1.0D, 1.0D);
|
||||
@@ -62,7 +69,7 @@ public class BlockGreenhouseDoor extends BlockGreenhouse implements IStateMapper
|
||||
|
||||
public BlockGreenhouseDoor() {
|
||||
setSoundType(SoundType.GLASS);
|
||||
setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH).withProperty(OPEN, false).withProperty(HINGE, BlockDoor.EnumHingePosition.LEFT).withProperty(POWERED, false).withProperty(HALF, BlockDoor.EnumDoorHalf.LOWER));
|
||||
setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH).withProperty(OPEN, false).withProperty(HINGE, BlockDoor.EnumHingePosition.LEFT).withProperty(POWERED, false).withProperty(HALF, BlockDoor.EnumDoorHalf.LOWER).withProperty(CAMOUFLAGED, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -109,9 +116,17 @@ public class BlockGreenhouseDoor extends BlockGreenhouse implements IStateMapper
|
||||
@Override
|
||||
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) {
|
||||
TileEntity tile = worldIn.getTileEntity(pos);
|
||||
if (!(tile instanceof TileGreenhouseDoor)) {
|
||||
if (!(tile instanceof TileGreenhouse)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
TileGreenhouse door = (TileGreenhouse) tile;
|
||||
if(playerIn.isSneaking() && playerIn.getHeldItem(hand) == null){
|
||||
if (!worldIn.isRemote) {
|
||||
door.openGui(playerIn);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
BlockPos blockpos = state.getValue(HALF) == BlockDoor.EnumDoorHalf.LOWER ? pos : pos.down();
|
||||
IBlockState iblockstate = pos.equals(blockpos) ? state : worldIn.getBlockState(blockpos);
|
||||
@@ -232,6 +247,13 @@ public class BlockGreenhouseDoor extends BlockGreenhouse implements IStateMapper
|
||||
state = state.withProperty(FACING, iblockstate1.getValue(FACING)).withProperty(OPEN, iblockstate1.getValue(OPEN));
|
||||
}
|
||||
}
|
||||
TileGreenhouse tile = TileUtil.getTile(worldIn, pos, TileGreenhouse.class);
|
||||
boolean isCamouflaged = false;
|
||||
if(tile != null){
|
||||
ItemStack camouflage = CamouflageUtil.getCamouflageBlock(worldIn, pos);
|
||||
isCamouflaged = camouflage != null;
|
||||
}
|
||||
state = state.withProperty(CAMOUFLAGED, isCamouflaged);
|
||||
|
||||
return state;
|
||||
}
|
||||
@@ -281,7 +303,7 @@ public class BlockGreenhouseDoor extends BlockGreenhouse implements IStateMapper
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void registerStateMapper() {
|
||||
Proxies.render.registerStateMapper(this, new StateMap.Builder().ignore(BlockDoor.POWERED).build());
|
||||
Proxies.render.registerStateMapper(this, new GreenhouseDoorStateMapper());
|
||||
}
|
||||
|
||||
protected static int removeHalfBit(int meta) {
|
||||
@@ -314,12 +336,7 @@ public class BlockGreenhouseDoor extends BlockGreenhouse implements IStateMapper
|
||||
|
||||
@Override
|
||||
protected BlockStateContainer createBlockState() {
|
||||
return new BlockStateContainer(this, HALF, FACING, OPEN, HINGE, POWERED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos) {
|
||||
return state;
|
||||
return new ExtendedBlockState(this, new IProperty[]{HALF, FACING, OPEN, HINGE, POWERED, CAMOUFLAGED}, new IUnlistedProperty[]{UnlistedBlockPos.POS, UnlistedBlockAccess.BLOCKACCESS});
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
||||
@@ -26,7 +26,7 @@ public class ContainerGreenhouse extends ContainerTile<TileGreenhouse> {
|
||||
|
||||
addSlotToContainer(new SlotLiquidIn(tile, 0, 125, 37));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
super.detectAndSendChanges();
|
||||
|
||||
@@ -16,7 +16,6 @@ import net.minecraftforge.fluids.IFluidTank;
|
||||
|
||||
import forestry.core.gui.ContainerTile;
|
||||
import forestry.core.gui.slots.SlotOutput;
|
||||
import forestry.core.network.packets.PacketGuiUpdate;
|
||||
import forestry.greenhouse.tiles.TileGreenhouseButterflyHatch;
|
||||
|
||||
public class ContainerGreenhouseButterflyHatch extends ContainerTile<TileGreenhouseButterflyHatch> {
|
||||
@@ -29,13 +28,6 @@ public class ContainerGreenhouseButterflyHatch extends ContainerTile<TileGreenho
|
||||
addSlotToContainer(new SlotOutput(tile, 2, 101, 40));
|
||||
addSlotToContainer(new SlotOutput(tile, 3, 80, 53));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
super.detectAndSendChanges();
|
||||
PacketGuiUpdate packet = new PacketGuiUpdate(tile);
|
||||
sendPacketToListeners(packet);
|
||||
}
|
||||
|
||||
public IFluidTank getTank(int slot) {
|
||||
return tile.getMultiblockLogic().getController().getTankManager().getTank(slot);
|
||||
|
||||
@@ -11,12 +11,14 @@
|
||||
package forestry.greenhouse.gui;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
import forestry.api.core.EnumCamouflageType;
|
||||
import forestry.api.core.CamouflageManager;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.gui.GuiForestryTitled;
|
||||
import forestry.core.gui.ledgers.ClimateLedger;
|
||||
import forestry.core.gui.ledgers.Ledger;
|
||||
import forestry.core.gui.widgets.TankWidget;
|
||||
import forestry.core.render.TextureManager;
|
||||
import forestry.core.utils.Translator;
|
||||
import forestry.greenhouse.gui.widgets.WidgetCamouflageSlot;
|
||||
import forestry.greenhouse.multiblock.IGreenhouseControllerInternal;
|
||||
import forestry.greenhouse.tiles.TileGreenhouse;
|
||||
@@ -30,9 +32,9 @@ public class GuiGreenhouse extends GuiForestryTitled<ContainerGreenhouse, TileGr
|
||||
widgetManager.add(new TankWidget(widgetManager, 152, 16, 0).setOverlayOrigin(176, 0));
|
||||
|
||||
//Add the multiblock camouflage slots
|
||||
widgetManager.add(new WidgetCamouflageSlot(widgetManager, 8, 16, inventory.getMultiblockLogic().getController(), EnumCamouflageType.DEFAULT));
|
||||
widgetManager.add(new WidgetCamouflageSlot(widgetManager, 8, 37, inventory.getMultiblockLogic().getController(), EnumCamouflageType.GLASS));
|
||||
//widgetManager.add(new WidgetCamouflageSlot(widgetManager, 8, 58, inventory.getMultiblockLogic().getController(), EnumCamouflageType.DOOR));
|
||||
widgetManager.add(new WidgetCamouflageSlot(widgetManager, 8, 16, inventory.getMultiblockLogic().getController(), CamouflageManager.DEFAULT));
|
||||
widgetManager.add(new WidgetCamouflageSlot(widgetManager, 8, 37, inventory.getMultiblockLogic().getController(), CamouflageManager.GLASS));
|
||||
widgetManager.add(new WidgetCamouflageSlot(widgetManager, 8, 58, inventory.getMultiblockLogic().getController(), CamouflageManager.DOOR));
|
||||
|
||||
//Add the tile camouflage slots
|
||||
widgetManager.add(new WidgetCamouflageSlot(widgetManager, 35, 37, inventory, tile.getCamouflageType()));
|
||||
@@ -43,6 +45,39 @@ public class GuiGreenhouse extends GuiForestryTitled<ContainerGreenhouse, TileGr
|
||||
IGreenhouseControllerInternal greenhouseController = inventory.getMultiblockLogic().getController();
|
||||
|
||||
ledgerManager.add(new ClimateLedger(ledgerManager, greenhouseController));
|
||||
ledgerManager.add(new EnergyLedger());
|
||||
super.addLedgers();
|
||||
}
|
||||
|
||||
protected class EnergyLedger extends Ledger {
|
||||
|
||||
public EnergyLedger() {
|
||||
super(ledgerManager, "power");
|
||||
maxHeight = 48;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(int x, int y) {
|
||||
|
||||
// Draw background
|
||||
drawBackground(x, y);
|
||||
|
||||
// Draw icon
|
||||
drawSprite(TextureManager.getInstance().getDefault("misc/energy"), x + 3, y + 4);
|
||||
|
||||
if (!isFullyOpened()) {
|
||||
return;
|
||||
}
|
||||
|
||||
drawHeader(Translator.translateToLocal("for.gui.energy"), x + 22, y + 8);
|
||||
|
||||
drawSubheader(Translator.translateToLocal("for.gui.stored") + ':', x + 22, y + 20);
|
||||
drawText(inventory.getMultiblockLogic().getController().getEnergyManager().getEnergyStored(null) + " RF", x + 22, y + 32);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return Translator.translateToLocal("for.gui.energy") + ": " + inventory.getMultiblockLogic().getController().getEnergyManager().getEnergyStored(null) + " RF/t";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,10 +10,6 @@
|
||||
******************************************************************************/
|
||||
package forestry.greenhouse.gui.widgets;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.renderer.RenderItem;
|
||||
@@ -24,10 +20,9 @@ import net.minecraft.util.text.TextFormatting;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.core.EnumCamouflageType;
|
||||
import forestry.api.core.CamouflageManager;
|
||||
import forestry.api.core.ICamouflageHandler;
|
||||
import forestry.api.greenhouse.GreenhouseManager;
|
||||
import forestry.api.core.ICamouflageItemHandler;
|
||||
import forestry.api.multiblock.IMultiblockController;
|
||||
import forestry.core.gui.tooltips.ToolTip;
|
||||
import forestry.core.gui.widgets.Widget;
|
||||
@@ -38,9 +33,9 @@ import forestry.core.utils.Translator;
|
||||
public class WidgetCamouflageSlot extends Widget {
|
||||
|
||||
private final ICamouflageHandler camouflageHandler;
|
||||
private final EnumCamouflageType type;
|
||||
private final String type;
|
||||
|
||||
public WidgetCamouflageSlot(WidgetManager manager, int xPos, int yPos, ICamouflageHandler camouflageHandler, EnumCamouflageType type) {
|
||||
public WidgetCamouflageSlot(WidgetManager manager, int xPos, int yPos, ICamouflageHandler camouflageHandler, String type) {
|
||||
super(manager, xPos, yPos);
|
||||
|
||||
this.camouflageHandler = camouflageHandler;
|
||||
@@ -67,14 +62,12 @@ public class WidgetCamouflageSlot extends Widget {
|
||||
} else {
|
||||
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
|
||||
ItemStack stack = player.inventory.getItemStack();
|
||||
if (stack != null && Block.getBlockFromItem(stack.getItem()) != null) {
|
||||
Block block = Block.getBlockFromItem(stack.getItem());
|
||||
if (!GreenhouseManager.greenhouseAccess.isOnCamouflageBlockBlackList(type, stack)) {
|
||||
IBlockState stateFromMeta = block.getStateFromMeta(stack.getItemDamage());
|
||||
if (type == EnumCamouflageType.DEFAULT && block.isOpaqueCube(stateFromMeta) && !block.hasTileEntity(stateFromMeta) && block.isNormalCube(stateFromMeta, player.worldObj, camouflageHandler.getCoordinates())) {
|
||||
camouflageHandler.setCamouflageBlock(type, stack);
|
||||
} else if (type == EnumCamouflageType.GLASS && GreenhouseManager.greenhouseAccess.isGreenhouseGlass(stack)) {
|
||||
camouflageHandler.setCamouflageBlock(type, stack);
|
||||
if (stack != null) {
|
||||
if (!CamouflageManager.camouflageAccess.isItemBlackListed(type, stack)) {
|
||||
for(ICamouflageItemHandler handler : CamouflageManager.camouflageAccess.getCamouflageItemHandler(type)){
|
||||
if(handler != null && handler.canHandle(stack, camouflageHandler)){
|
||||
camouflageHandler.setCamouflageBlock(type, stack.copy());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -95,9 +88,8 @@ public class WidgetCamouflageSlot extends Widget {
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void refresh() {
|
||||
toolTip.clear();
|
||||
String typeName = type.name().toLowerCase(Locale.ENGLISH);
|
||||
if (camouflageHandler instanceof IMultiblockController) {
|
||||
toolTip.add(Translator.translateToLocal("for.gui.empty.slot.camouflage.multiblock." + typeName) + ": ");
|
||||
toolTip.add(Translator.translateToLocal("for.gui.empty.slot.camouflage.multiblock." + type) + ": ");
|
||||
} else {
|
||||
toolTip.add(Translator.translateToLocal("for.gui.empty.slot.camouflage") + ": ");
|
||||
}
|
||||
|
||||
@@ -10,15 +10,11 @@
|
||||
******************************************************************************/
|
||||
package forestry.greenhouse.logics;
|
||||
|
||||
import net.minecraft.block.BlockDoor;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import forestry.api.greenhouse.DefaultGreenhouseLogic;
|
||||
import forestry.api.greenhouse.IGreenhouseClimaLogic;
|
||||
import forestry.api.multiblock.IGreenhouseController;
|
||||
import forestry.api.multiblock.IMultiblockComponent;
|
||||
import forestry.greenhouse.tiles.TileGreenhouseDoor;
|
||||
|
||||
public class GreenhouseLogicGreenhouseDoor extends DefaultGreenhouseLogic implements IGreenhouseClimaLogic {
|
||||
|
||||
@@ -30,7 +26,7 @@ public class GreenhouseLogicGreenhouseDoor extends DefaultGreenhouseLogic implem
|
||||
|
||||
@Override
|
||||
public void work() {
|
||||
if (controller == null || !controller.isAssembled()) {
|
||||
/*if (controller == null || !controller.isAssembled()) {
|
||||
return;
|
||||
}
|
||||
if (workTimer++ > 20) {
|
||||
@@ -46,7 +42,7 @@ public class GreenhouseLogicGreenhouseDoor extends DefaultGreenhouseLogic implem
|
||||
controller.addTemperatureChange(-0.0001F * openDoors, 0.05F, 2.5F);
|
||||
controller.addHumidityChange(-0.0001F * openDoors, 0.05F, 2.5F);
|
||||
workTimer = 0;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -13,15 +13,15 @@ package forestry.greenhouse.logics;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.api.core.EnumCamouflageType;
|
||||
import forestry.api.core.CamouflageManager;
|
||||
import forestry.api.core.ICamouflageItemHandler;
|
||||
import forestry.api.core.ICamouflagedTile;
|
||||
import forestry.api.greenhouse.DefaultGreenhouseLogic;
|
||||
import forestry.api.greenhouse.EnumGreenhouseEventType;
|
||||
import forestry.api.greenhouse.GreenhouseManager;
|
||||
import forestry.api.greenhouse.IGreenhouseClimaLogic;
|
||||
import forestry.api.multiblock.IGreenhouseController;
|
||||
import forestry.api.multiblock.IMultiblockComponent;
|
||||
import forestry.core.CamouflageAccess;
|
||||
import forestry.core.utils.CamouflageUtil;
|
||||
|
||||
public class GreenhouseLogicGreenhouseEffect extends DefaultGreenhouseLogic implements IGreenhouseClimaLogic {
|
||||
@@ -36,7 +36,7 @@ public class GreenhouseLogicGreenhouseEffect extends DefaultGreenhouseLogic impl
|
||||
|
||||
@Override
|
||||
public void work() {
|
||||
if (controller == null || !controller.isAssembled()) {
|
||||
/*if (controller == null || !controller.isAssembled()) {
|
||||
return;
|
||||
}
|
||||
if (controller.getWorldObj().isDaytime()) {
|
||||
@@ -44,7 +44,7 @@ public class GreenhouseLogicGreenhouseEffect extends DefaultGreenhouseLogic impl
|
||||
controller.addTemperatureChange(lightTransmittance / 100, 0F, 2.5F);
|
||||
workTimer = 0;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -73,10 +73,11 @@ public class GreenhouseLogicGreenhouseEffect extends DefaultGreenhouseLogic impl
|
||||
for (IMultiblockComponent component : controller.getComponents()) {
|
||||
if (component instanceof ICamouflagedTile) {
|
||||
ICamouflagedTile block = (ICamouflagedTile) component;
|
||||
if (block.getCamouflageType() == EnumCamouflageType.GLASS) {
|
||||
if (block.getCamouflageType() == CamouflageManager.GLASS) {
|
||||
if (world.canBlockSeeSky(component.getCoordinates())) {
|
||||
ItemStack camouflageStack = CamouflageUtil.getCamouflageBlock(world, component.getCoordinates());
|
||||
float camouflageLightTransmittance = GreenhouseManager.greenhouseAccess.getGreenhouseGlassLightTransmittance(camouflageStack);
|
||||
ICamouflageItemHandler handler = CamouflageAccess.getHandlerFromItem(camouflageStack, controller);
|
||||
float camouflageLightTransmittance = handler.getLightTransmittance(camouflageStack, controller);
|
||||
|
||||
if (camouflageLightTransmittance < 1 && camouflageLightTransmittance > 0) {
|
||||
lightTransmittance = lightTransmittance + camouflageLightTransmittance;
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package forestry.greenhouse.models;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import forestry.core.render.ForestryStateMapper;
|
||||
import forestry.greenhouse.blocks.BlockGreenhouseDoor;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockDoor;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
|
||||
public class GreenhouseDoorStateMapper extends ForestryStateMapper {
|
||||
|
||||
@Override
|
||||
public Map<IBlockState, ModelResourceLocation> putStateModelLocations(Block block) {
|
||||
for(IBlockState state : block.getBlockState().getValidStates()){
|
||||
if(state.getValue(BlockGreenhouseDoor.CAMOUFLAGED)){
|
||||
mapStateModelLocations.put(state, new ModelResourceLocation(block.getRegistryName(), "camouflage"));
|
||||
}else{
|
||||
LinkedHashMap<IProperty<?>, Comparable<?>> linkedhashmap = Maps.newLinkedHashMap(state.getProperties());
|
||||
linkedhashmap.remove(BlockGreenhouseDoor.CAMOUFLAGED);
|
||||
linkedhashmap.remove(BlockDoor.POWERED);
|
||||
mapStateModelLocations.put(state, new ModelResourceLocation(block.getRegistryName(), getPropertyString(linkedhashmap)));
|
||||
}
|
||||
}
|
||||
return mapStateModelLocations;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -13,10 +13,13 @@ package forestry.greenhouse.models;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
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.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@@ -24,8 +27,11 @@ import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
import net.minecraftforge.common.property.IExtendedBlockState;
|
||||
|
||||
import forestry.api.core.ICamouflageHandler;
|
||||
import forestry.api.core.ICamouflageItemHandler;
|
||||
import forestry.api.core.ICamouflagedTile;
|
||||
import forestry.api.core.IModelBaker;
|
||||
import forestry.core.CamouflageAccess;
|
||||
import forestry.core.models.ModelBlockDefault;
|
||||
import forestry.core.utils.CamouflageUtil;
|
||||
import forestry.greenhouse.blocks.BlockGreenhouse;
|
||||
@@ -51,11 +57,15 @@ public class ModelGreenhouse extends ModelBlockDefault<BlockGreenhouse> {
|
||||
|
||||
private static void bakeBlockModel(@Nonnull BlockGreenhouse block, @Nullable IBlockAccess world, @Nullable BlockPos pos, @Nullable IExtendedBlockState stateExtended, @Nonnull IModelBaker baker, @Nullable ItemStack camouflageStack) {
|
||||
if (camouflageStack != null) {
|
||||
BlockModelShapes modelShapes = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes();
|
||||
IBlockState state = Block.getBlockFromItem(camouflageStack.getItem()).getStateFromMeta(camouflageStack.getItemDamage());
|
||||
|
||||
baker.addBakedModel(state, modelShapes.getModelForState(state));
|
||||
baker.setParticleSprite(modelShapes.getModelForState(Block.getBlockFromItem(camouflageStack.getItem()).getStateFromMeta(camouflageStack.getItemDamage())).getParticleTexture());
|
||||
ICamouflageHandler camouflageHandler = CamouflageUtil.getCamouflageHandler(world, pos);
|
||||
ICamouflagedTile camouflageTile = (ICamouflagedTile) world.getTileEntity(pos);
|
||||
ICamouflageItemHandler itemHandler = CamouflageAccess.getHandlerFromItem(camouflageStack, camouflageHandler);
|
||||
if(itemHandler != null){
|
||||
Pair<IBlockState, IBakedModel> model = itemHandler.getModel(camouflageStack, camouflageHandler, camouflageTile);
|
||||
|
||||
baker.addBakedModel(model.getLeft(), model.getRight());
|
||||
baker.setParticleSprite(model.getRight().getParticleTexture());
|
||||
}
|
||||
}
|
||||
|
||||
//Bake the default blocks
|
||||
|
||||
@@ -17,19 +17,18 @@ import java.util.Set;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
import forestry.api.core.EnumCamouflageType;
|
||||
import net.minecraft.world.World;
|
||||
import forestry.api.core.climate.IClimateRegion;
|
||||
import forestry.api.greenhouse.EnumGreenhouseEventType;
|
||||
import forestry.api.greenhouse.IGreenhouseLogic;
|
||||
import forestry.api.greenhouse.IGreenhouseState;
|
||||
import forestry.api.greenhouse.IInternalBlock;
|
||||
import forestry.api.multiblock.IGreenhouseComponent.Listener;
|
||||
import forestry.core.fluids.FakeTankManager;
|
||||
import forestry.core.fluids.ITankManager;
|
||||
import forestry.core.inventory.FakeInventoryAdapter;
|
||||
import forestry.core.inventory.IInventoryAdapter;
|
||||
import forestry.core.multiblock.FakeMultiblockController;
|
||||
import forestry.energy.EnergyManager;
|
||||
import forestry.greenhouse.FakeGreenhouseState;
|
||||
|
||||
public class FakeGreenhouseController extends FakeMultiblockController implements IGreenhouseControllerInternal {
|
||||
public static final FakeGreenhouseController instance = new FakeGreenhouseController();
|
||||
@@ -55,19 +54,24 @@ public class FakeGreenhouseController extends FakeMultiblockController implement
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getCamouflageBlock(EnumCamouflageType type) {
|
||||
public ItemStack getCamouflageBlock(String type) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getDefaultCamouflageBlock(EnumCamouflageType type) {
|
||||
public ItemStack getDefaultCamouflageBlock(String type) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCamouflageBlock(EnumCamouflageType type, ItemStack camouflageBlock) {
|
||||
public void setCamouflageBlock(String type, ItemStack camouflageBlock) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canHandleType(String type) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockPos getCoordinates() {
|
||||
@@ -82,20 +86,6 @@ public class FakeGreenhouseController extends FakeMultiblockController implement
|
||||
@Override
|
||||
public void onChange(EnumGreenhouseEventType type, Object event) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addTemperatureChange(float change, float boundaryDown, float boundaryUp) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addHumidityChange(float change, float boundaryDown, float boundaryUp) {
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IGreenhouseState createState() {
|
||||
return FakeGreenhouseState.instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<IInternalBlock> getInternalBlocks() {
|
||||
@@ -106,4 +96,23 @@ public class FakeGreenhouseController extends FakeMultiblockController implement
|
||||
public String getUnlocalizedType() {
|
||||
return "for.multiblock.greenhouse.type";
|
||||
}
|
||||
|
||||
@Override
|
||||
public IClimateRegion getRegion() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearRegion() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Listener> getListenerComponents() {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorld() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -14,8 +14,10 @@ import javax.annotation.Nonnull;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.Stack;
|
||||
|
||||
@@ -27,28 +29,30 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
|
||||
import forestry.api.core.EnumCamouflageType;
|
||||
import forestry.api.core.CamouflageManager;
|
||||
import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.core.ICamouflagedTile;
|
||||
import forestry.api.core.climate.IClimatePosition;
|
||||
import forestry.api.core.climate.IClimateRegion;
|
||||
import forestry.api.core.climate.IClimateSource;
|
||||
import forestry.api.greenhouse.EnumGreenhouseEventType;
|
||||
import forestry.api.greenhouse.GreenhouseEvents.CamouflageChangeEvent;
|
||||
import forestry.api.greenhouse.GreenhouseEvents.CheckInternalBlockFaceEvent;
|
||||
import forestry.api.greenhouse.GreenhouseEvents.CreateInternalBlockEvent;
|
||||
import forestry.api.greenhouse.GreenhouseManager;
|
||||
import forestry.api.greenhouse.IGreenhouseLogic;
|
||||
import forestry.api.greenhouse.IGreenhouseState;
|
||||
import forestry.api.greenhouse.IInternalBlock;
|
||||
import forestry.api.greenhouse.IInternalBlockFace;
|
||||
import forestry.api.multiblock.IGreenhouseComponent;
|
||||
import forestry.api.multiblock.IGreenhouseComponent.ButterflyHatch;
|
||||
import forestry.api.multiblock.IGreenhouseController;
|
||||
import forestry.api.multiblock.IMultiblockComponent;
|
||||
import forestry.core.climate.ClimateRoom;
|
||||
import forestry.core.climate.ClimatePosition;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.fluids.TankManager;
|
||||
import forestry.core.fluids.tanks.FilteredTank;
|
||||
@@ -67,7 +71,6 @@ import forestry.core.utils.ItemStackUtil;
|
||||
import forestry.core.utils.Log;
|
||||
import forestry.core.utils.Translator;
|
||||
import forestry.energy.EnergyManager;
|
||||
import forestry.greenhouse.GreenhouseState;
|
||||
import forestry.greenhouse.blocks.BlockGreenhouse;
|
||||
import forestry.greenhouse.blocks.BlockGreenhouseType;
|
||||
import forestry.greenhouse.inventory.InventoryGreenhouse;
|
||||
@@ -78,36 +81,32 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
|
||||
private final Set<IInternalBlock> internalBlocks = new HashSet<>();
|
||||
private final Set<IGreenhouseComponent.Listener> listenerComponents = new HashSet<>();
|
||||
private final Set<IGreenhouseComponent.Climatiser> climatiserComponents = new HashSet<>();
|
||||
private final Set<IGreenhouseComponent.Active> activeComponents = new HashSet<>();
|
||||
private final List<IGreenhouseLogic> logics = new ArrayList<>();
|
||||
|
||||
private float tempChange;
|
||||
private float humidChange;
|
||||
private Biome cachedBiome;
|
||||
private final TankManager tankManager;
|
||||
private final StandardTank resourceTank;
|
||||
private final EnergyManager energyManager;
|
||||
private final InventoryGreenhouse inventory;
|
||||
private final boolean needRenderUpdate = false;
|
||||
|
||||
//Camouflage blocks
|
||||
private ItemStack camouflagePlainBlock;
|
||||
private ItemStack camouflageGlassBlock;
|
||||
private ItemStack camouflageDoorBlock;
|
||||
private ClimateRoom region;
|
||||
|
||||
public GreenhouseController(World world) {
|
||||
super(world, GreenhouseMultiblockSizeLimits.instance);
|
||||
this.tempChange = 0;
|
||||
this.humidChange = 0;
|
||||
|
||||
this.resourceTank = new FilteredTank(Constants.PROCESSOR_TANK_CAPACITY).setFilters(FluidRegistry.WATER);
|
||||
this.tankManager = new TankManager(this, resourceTank);
|
||||
this.energyManager = new EnergyManager(2000, 100000);
|
||||
this.energyManager = new EnergyManager(200, 100000);
|
||||
this.inventory = new InventoryGreenhouse(this);
|
||||
|
||||
camouflagePlainBlock = getDefaultCamouflageBlock(EnumCamouflageType.DEFAULT);
|
||||
camouflageGlassBlock = getDefaultCamouflageBlock(EnumCamouflageType.GLASS);
|
||||
camouflageDoorBlock = getDefaultCamouflageBlock(EnumCamouflageType.DOOR);
|
||||
camouflagePlainBlock = getDefaultCamouflageBlock(CamouflageManager.DEFAULT);
|
||||
camouflageGlassBlock = getDefaultCamouflageBlock(CamouflageManager.GLASS);
|
||||
camouflageDoorBlock = getDefaultCamouflageBlock(CamouflageManager.DOOR);
|
||||
}
|
||||
|
||||
/* CLIMATE */
|
||||
@@ -116,14 +115,6 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
BlockPos coords = getReferenceCoord();
|
||||
return EnumTemperature.getFromValue(getExactTemperature());
|
||||
}
|
||||
|
||||
private Biome getBiome() {
|
||||
if (cachedBiome == null) {
|
||||
BlockPos coords = getReferenceCoord();
|
||||
cachedBiome = worldObj.getBiome(coords);
|
||||
}
|
||||
return cachedBiome;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumHumidity getHumidity() {
|
||||
@@ -132,45 +123,31 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
|
||||
@Override
|
||||
public float getExactTemperature() {
|
||||
BlockPos coords = getReferenceCoord();
|
||||
return getBiome().getFloatTemperature(coords) + tempChange;
|
||||
int dimensionID = worldObj.provider.getDimension();
|
||||
|
||||
float temperature = 0.0F;
|
||||
|
||||
for(IInternalBlock internalBlock : internalBlocks){
|
||||
IClimatePosition position = region.getPositions().get(internalBlock.getPos());
|
||||
if(position != null){
|
||||
temperature+=position.getTemperature();
|
||||
}
|
||||
}
|
||||
return temperature / internalBlocks.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getExactHumidity() {
|
||||
return getBiome().getRainfall() + humidChange;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addTemperatureChange(float change, float boundaryDown, float boundaryUp) {
|
||||
BlockPos coordinates = getCoordinates();
|
||||
|
||||
float temperature = getBiome().getFloatTemperature(coordinates);
|
||||
|
||||
tempChange += change;
|
||||
tempChange = Math.max(boundaryDown - temperature, tempChange);
|
||||
tempChange = Math.min(boundaryUp - temperature, tempChange);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addHumidityChange(float change, float boundaryDown, float boundaryUp) {
|
||||
float humidity = getBiome().getRainfall();
|
||||
|
||||
humidChange += change;
|
||||
humidChange = Math.max(boundaryDown - humidity, humidChange);
|
||||
humidChange = Math.min(boundaryUp - humidity, humidChange);
|
||||
}
|
||||
|
||||
private static float equalizeChange(float change) {
|
||||
if (change == 0) {
|
||||
return 0;
|
||||
int dimensionID = worldObj.provider.getDimension();
|
||||
float humidity = 0.0F;
|
||||
|
||||
for(IInternalBlock internalBlock : internalBlocks){
|
||||
IClimatePosition position = region.getPositions().get(internalBlock.getPos());
|
||||
if(position != null){
|
||||
humidity+=position.getHumidity();
|
||||
}
|
||||
}
|
||||
|
||||
change *= 0.95f;
|
||||
if (change <= 0.001f && change >= -0.001f) {
|
||||
change = 0;
|
||||
}
|
||||
return change;
|
||||
return humidity / internalBlocks.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -189,21 +166,23 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound data) {
|
||||
data = super.writeToNBT(data);
|
||||
|
||||
data.setFloat("Temperature", tempChange);
|
||||
data.setFloat("Humidity", humidChange);
|
||||
tankManager.writeToNBT(data);
|
||||
energyManager.writeToNBT(data);
|
||||
inventory.writeToNBT(data);
|
||||
|
||||
CamouflageUtil.writeCamouflageBlockToNBT(data, this, EnumCamouflageType.DEFAULT);
|
||||
CamouflageUtil.writeCamouflageBlockToNBT(data, this, EnumCamouflageType.GLASS);
|
||||
CamouflageUtil.writeCamouflageBlockToNBT(data, this, EnumCamouflageType.DOOR);
|
||||
CamouflageUtil.writeCamouflageBlockToNBT(data, this, CamouflageManager.DEFAULT);
|
||||
CamouflageUtil.writeCamouflageBlockToNBT(data, this, CamouflageManager.GLASS);
|
||||
CamouflageUtil.writeCamouflageBlockToNBT(data, this, CamouflageManager.DOOR);
|
||||
|
||||
for (IGreenhouseLogic logic : getLogics()) {
|
||||
NBTTagCompound nbtTag = new NBTTagCompound();
|
||||
logic.writeToNBT(nbtTag);
|
||||
data.setTag("logic" + logic.getName(), nbtTag);
|
||||
}
|
||||
|
||||
if(region != null){
|
||||
data.setTag("Region", region.writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
@@ -212,15 +191,13 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
public void readFromNBT(NBTTagCompound data) {
|
||||
super.readFromNBT(data);
|
||||
|
||||
tempChange = data.getFloat("Temperature");
|
||||
humidChange = data.getFloat("Humidity");
|
||||
tankManager.readFromNBT(data);
|
||||
energyManager.readFromNBT(data);
|
||||
inventory.readFromNBT(data);
|
||||
|
||||
CamouflageUtil.readCamouflageBlockFromNBT(data, this, EnumCamouflageType.DEFAULT);
|
||||
CamouflageUtil.readCamouflageBlockFromNBT(data, this, EnumCamouflageType.GLASS);
|
||||
CamouflageUtil.readCamouflageBlockFromNBT(data, this, EnumCamouflageType.DOOR);
|
||||
CamouflageUtil.readCamouflageBlockFromNBT(data, this, CamouflageManager.DEFAULT);
|
||||
CamouflageUtil.readCamouflageBlockFromNBT(data, this, CamouflageManager.GLASS);
|
||||
CamouflageUtil.readCamouflageBlockFromNBT(data, this, CamouflageManager.DOOR);
|
||||
|
||||
if (logics.isEmpty()) {
|
||||
createLogics();
|
||||
@@ -229,6 +206,11 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
for (IGreenhouseLogic logic : getLogics()) {
|
||||
logic.readFromNBT(data.getCompoundTag("logic" + logic.getName()));
|
||||
}
|
||||
|
||||
if(data.hasKey("Region")){
|
||||
NBTTagCompound nbtTag = data.getCompoundTag("Region");
|
||||
region = new ClimateRoom(this, nbtTag);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -249,40 +231,50 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
/* GUI DATA */
|
||||
@Override
|
||||
public void writeGuiData(DataOutputStreamForestry data) throws IOException {
|
||||
data.writeVarInt(Math.round(tempChange * 100));
|
||||
data.writeVarInt(Math.round(humidChange * 100));
|
||||
tankManager.writeData(data);
|
||||
energyManager.writeData(data);
|
||||
inventory.writeData(data);
|
||||
CamouflageUtil.writeCamouflageBlockToData(data, this, EnumCamouflageType.DEFAULT);
|
||||
CamouflageUtil.writeCamouflageBlockToData(data, this, EnumCamouflageType.GLASS);
|
||||
CamouflageUtil.writeCamouflageBlockToData(data, this, EnumCamouflageType.DOOR);
|
||||
CamouflageUtil.writeCamouflageBlockToData(data, this, CamouflageManager.DEFAULT);
|
||||
CamouflageUtil.writeCamouflageBlockToData(data, this, CamouflageManager.GLASS);
|
||||
CamouflageUtil.writeCamouflageBlockToData(data, this, CamouflageManager.DOOR);
|
||||
if(region != null){
|
||||
data.writeBoolean(true);
|
||||
region.writeData(data);
|
||||
}else{
|
||||
data.writeBoolean(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readGuiData(DataInputStreamForestry data) throws IOException {
|
||||
tempChange = data.readVarInt() / 100.0F;
|
||||
humidChange = data.readVarInt() / 100.0F;
|
||||
tankManager.readData(data);
|
||||
energyManager.readData(data);
|
||||
inventory.readData(data);
|
||||
CamouflageUtil.readCamouflageBlockFromData(data, this);
|
||||
CamouflageUtil.readCamouflageBlockFromData(data, this);
|
||||
CamouflageUtil.readCamouflageBlockFromData(data, this);
|
||||
if(data.readBoolean()){
|
||||
region.readData(data);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canHandleType(String type) {
|
||||
return type.equals(CamouflageManager.DEFAULT) || type.equals(CamouflageManager.GLASS) || type.equals(CamouflageManager.DOOR);
|
||||
}
|
||||
|
||||
/* CAMOUFLAGE */
|
||||
@Override
|
||||
public void setCamouflageBlock(EnumCamouflageType type, ItemStack camouflageBlock) {
|
||||
public void setCamouflageBlock(String type, ItemStack camouflageBlock) {
|
||||
ItemStack oldCamouflageBlock;
|
||||
switch (type) {
|
||||
case DEFAULT:
|
||||
case CamouflageManager.DEFAULT:
|
||||
oldCamouflageBlock = camouflagePlainBlock;
|
||||
break;
|
||||
case GLASS:
|
||||
case CamouflageManager.GLASS:
|
||||
oldCamouflageBlock = camouflageGlassBlock;
|
||||
break;
|
||||
case DOOR:
|
||||
case CamouflageManager.DOOR:
|
||||
oldCamouflageBlock = camouflageDoorBlock;
|
||||
break;
|
||||
default:
|
||||
@@ -291,13 +283,13 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
|
||||
if(!ItemStackUtil.isIdenticalItem(camouflageBlock, oldCamouflageBlock)){
|
||||
switch (type) {
|
||||
case DEFAULT:
|
||||
case CamouflageManager.DEFAULT:
|
||||
camouflagePlainBlock = camouflageBlock;
|
||||
break;
|
||||
case GLASS:
|
||||
case CamouflageManager.GLASS:
|
||||
camouflageGlassBlock = camouflageBlock;
|
||||
break;
|
||||
case DOOR:
|
||||
case CamouflageManager.DOOR:
|
||||
camouflageDoorBlock = camouflageBlock;
|
||||
break;
|
||||
default:
|
||||
@@ -306,6 +298,7 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
|
||||
if (worldObj != null) {
|
||||
if (worldObj.isRemote) {
|
||||
Proxies.net.sendToServer(new PacketCamouflageUpdate(this, type, true));
|
||||
for (IMultiblockComponent comp : connectedParts) {
|
||||
if (comp instanceof ICamouflagedTile) {
|
||||
ICamouflagedTile camBlock = (ICamouflagedTile) comp;
|
||||
@@ -314,22 +307,21 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
}
|
||||
}
|
||||
}
|
||||
Proxies.net.sendToServer(new PacketCamouflageUpdate(this, type, true));
|
||||
}
|
||||
}
|
||||
|
||||
MinecraftForge.EVENT_BUS.post(new CamouflageChangeEvent(createState(), null, this, type));
|
||||
MinecraftForge.EVENT_BUS.post(new CamouflageChangeEvent(this, null, this, type));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getCamouflageBlock(EnumCamouflageType type) {
|
||||
public ItemStack getCamouflageBlock(String type) {
|
||||
switch (type) {
|
||||
case DEFAULT:
|
||||
case CamouflageManager.DEFAULT:
|
||||
return camouflagePlainBlock;
|
||||
case GLASS:
|
||||
case CamouflageManager.GLASS:
|
||||
return camouflageGlassBlock;
|
||||
case DOOR:
|
||||
case CamouflageManager.DOOR:
|
||||
return camouflageDoorBlock;
|
||||
default:
|
||||
return null;
|
||||
@@ -337,13 +329,13 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getDefaultCamouflageBlock(EnumCamouflageType type) {
|
||||
public ItemStack getDefaultCamouflageBlock(String type) {
|
||||
switch (type) {
|
||||
case DEFAULT:
|
||||
case CamouflageManager.DEFAULT:
|
||||
return new ItemStack(Blocks.BRICK_BLOCK);
|
||||
case GLASS:
|
||||
case CamouflageManager.GLASS:
|
||||
return new ItemStack(Blocks.STAINED_GLASS, 1, 13);
|
||||
case DOOR:
|
||||
case CamouflageManager.DOOR:
|
||||
return null;
|
||||
default:
|
||||
return null;
|
||||
@@ -351,12 +343,6 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
}
|
||||
|
||||
/* GREENHOUSE */
|
||||
@Nonnull
|
||||
@Override
|
||||
public IGreenhouseState createState() {
|
||||
return new GreenhouseState(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChange(EnumGreenhouseEventType type, Object event) {
|
||||
for (IGreenhouseLogic logic : logics) {
|
||||
@@ -367,7 +353,7 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
/* GREENHOUSE LOGICS */
|
||||
private void createLogics() {
|
||||
logics.clear();
|
||||
for (Class<? extends IGreenhouseLogic> logicClass : GreenhouseManager.greenhouseLogics) {
|
||||
for (Class<? extends IGreenhouseLogic> logicClass : GreenhouseManager.greenhouseHelper.getGreenhouseLogics()) {
|
||||
IGreenhouseLogic logic = createLogic(logicClass);
|
||||
if (logic != null) {
|
||||
logics.add(logic);
|
||||
@@ -418,6 +404,38 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
super.onMachineAssembled();
|
||||
|
||||
createLogics();
|
||||
if(region != null){
|
||||
Map<BlockPos, IClimatePosition> internalPositions = new HashMap<>();
|
||||
List<BlockPos> wallPositions = new ArrayList<>();
|
||||
for(IMultiblockComponent comp : connectedParts){
|
||||
if(comp != null){
|
||||
wallPositions.add(comp.getCoordinates());
|
||||
}
|
||||
}
|
||||
for(IInternalBlock block : internalBlocks){
|
||||
if(block != null){
|
||||
internalPositions.put(block.getPos(), new ClimatePosition(region, block.getPos()));
|
||||
}
|
||||
}
|
||||
ForestryAPI.climateManager.removeRegion(region);
|
||||
region = new ClimateRoom(region, internalPositions, wallPositions);
|
||||
ForestryAPI.climateManager.addRegion(region);
|
||||
}else{
|
||||
Map<BlockPos, IClimatePosition> internalPositions = new HashMap<>();
|
||||
List<BlockPos> wallPositions = new ArrayList<>();
|
||||
for(IMultiblockComponent comp : connectedParts){
|
||||
if(comp != null){
|
||||
wallPositions.add(comp.getCoordinates());
|
||||
}
|
||||
}
|
||||
region = new ClimateRoom(this, internalPositions, wallPositions);
|
||||
for(IInternalBlock block : internalBlocks){
|
||||
if(block != null){
|
||||
internalPositions.put(block.getPos(), new ClimatePosition(region, block.getPos()));
|
||||
}
|
||||
}
|
||||
ForestryAPI.climateManager.addRegion(region);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -433,7 +451,7 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
if (newPart instanceof IGreenhouseComponent.Listener) {
|
||||
listenerComponents.add((IGreenhouseComponent.Listener) newPart);
|
||||
} else if (newPart instanceof IGreenhouseComponent.Climatiser) {
|
||||
climatiserComponents.add((IGreenhouseComponent.Climatiser) newPart);
|
||||
ForestryAPI.climateManager.addSource((IClimateSource) newPart);
|
||||
} else if (newPart instanceof IGreenhouseComponent.Active) {
|
||||
activeComponents.add((IGreenhouseComponent.Active) newPart);
|
||||
}
|
||||
@@ -444,7 +462,7 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
if (oldPart instanceof IGreenhouseComponent.Listener) {
|
||||
listenerComponents.remove(oldPart);
|
||||
} else if (oldPart instanceof IGreenhouseComponent.Climatiser) {
|
||||
climatiserComponents.remove(oldPart);
|
||||
ForestryAPI.climateManager.removeSource((IClimateSource) oldPart);
|
||||
} else if (oldPart instanceof IGreenhouseComponent.Active) {
|
||||
activeComponents.remove(oldPart);
|
||||
}
|
||||
@@ -452,65 +470,44 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
|
||||
@Override
|
||||
protected void onAssimilate(IMultiblockControllerInternal assimilated) {
|
||||
if(assimilated != null && ((IGreenhouseControllerInternal)assimilated).getRegion() != null){
|
||||
IGreenhouseControllerInternal internal = (IGreenhouseControllerInternal) assimilated;
|
||||
if(region != null){
|
||||
ForestryAPI.climateManager.removeRegion(region);
|
||||
List<BlockPos> wallPositions = new ArrayList<>();
|
||||
for(IMultiblockComponent comp : connectedParts){
|
||||
if(comp != null){
|
||||
wallPositions.add(comp.getCoordinates());
|
||||
}
|
||||
}
|
||||
region = new ClimateRoom(region,internal.getRegion().getPositions(), wallPositions);
|
||||
ForestryAPI.climateManager.addRegion(region);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAssimilated(IMultiblockControllerInternal assimilator) {
|
||||
if(region != null){
|
||||
ForestryAPI.climateManager.removeRegion(region);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean updateServer(int tickCount) {
|
||||
if (!isAssembled()) {
|
||||
boolean hasChangeClima = false;
|
||||
if (updateOnInterval(45)) {
|
||||
if (humidChange > 0F) {
|
||||
if (humidChange > 0.25F) {
|
||||
humidChange = -0.25F;
|
||||
} else {
|
||||
humidChange = 0F;
|
||||
}
|
||||
hasChangeClima = true;
|
||||
}
|
||||
if (tempChange > 0F) {
|
||||
if (tempChange > 0.25F) {
|
||||
tempChange = -0.25F;
|
||||
} else {
|
||||
tempChange = 0F;
|
||||
}
|
||||
hasChangeClima = true;
|
||||
}
|
||||
}
|
||||
return hasChangeClima;
|
||||
} else {
|
||||
if (updateOnInterval(20)) {
|
||||
inventory.drainCan(tankManager);
|
||||
}
|
||||
|
||||
for (IGreenhouseLogic logic : logics) {
|
||||
logic.work();
|
||||
}
|
||||
|
||||
for (IGreenhouseComponent.Active activeComponent : activeComponents) {
|
||||
activeComponent.updateServer(tickCount);
|
||||
}
|
||||
|
||||
boolean canWork = true;
|
||||
for (IGreenhouseComponent.Listener listenerComponent : listenerComponents) {
|
||||
canWork = listenerComponent.getGreenhouseListener().canWork(this, canWork);
|
||||
}
|
||||
|
||||
if (canWork) {
|
||||
|
||||
for (IGreenhouseComponent.Climatiser climatiser : climatiserComponents) {
|
||||
climatiser.changeClimate(tickCount, this);
|
||||
}
|
||||
|
||||
tempChange = equalizeChange(tempChange);
|
||||
humidChange = equalizeChange(humidChange);
|
||||
}
|
||||
|
||||
return canWork;
|
||||
if (updateOnInterval(20)) {
|
||||
inventory.drainCan(tankManager);
|
||||
}
|
||||
|
||||
for (IGreenhouseLogic logic : logics) {
|
||||
logic.work();
|
||||
}
|
||||
|
||||
for (IGreenhouseComponent.Active activeComponent : activeComponents) {
|
||||
activeComponent.updateServer(tickCount);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -519,6 +516,10 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
int minY = getSizeLimits().getMinimumYSize();
|
||||
int minZ = getSizeLimits().getMinimumZSize();
|
||||
|
||||
if (connectedParts.size() < getSizeLimits().getMinimumNumberOfBlocksForAssembledMachine()) {
|
||||
throw new MultiblockValidationException(Translator.translateToLocalFormatted("for.multiblock.error.small", minX, minY, minZ));
|
||||
}
|
||||
|
||||
BlockPos maximumCoord = getMaximumCoord();
|
||||
BlockPos minimumCoord = getMinimumCoord();
|
||||
|
||||
@@ -549,11 +550,7 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
if (deltaZ < minZ) {
|
||||
throw new MultiblockValidationException(Translator.translateToLocalFormatted("for.multiblock.error.small.z", minZ));
|
||||
}
|
||||
|
||||
if (connectedParts.size() < getSizeLimits().getMinimumNumberOfBlocksForAssembledMachine()) {
|
||||
throw new MultiblockValidationException(Translator.translateToLocalFormatted("for.multiblock.greenhouse.error.space.closed", minX, minY, minZ));
|
||||
}
|
||||
|
||||
|
||||
// Now we run a simple check on each block within that volume.
|
||||
// Any block deviating = NO DEAL SIR
|
||||
TileEntity te;
|
||||
@@ -561,8 +558,7 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
boolean isNextRoof = false;
|
||||
Class<? extends RectangularMultiblockControllerBase> myClass = this.getClass();
|
||||
|
||||
height:
|
||||
for (int y = minimumCoord.getY(); y <= maximumCoord.getY(); y++) {
|
||||
for (int y = minimumCoord.getY(); y <= maximumCoord.getY() && !isNextRoof; y++) {
|
||||
for (int x = minimumCoord.getX(); x <= maximumCoord.getX(); x++) {
|
||||
for (int z = minimumCoord.getZ(); z <= maximumCoord.getZ(); z++) {
|
||||
// Okay, figure out what sort of block this should be.
|
||||
@@ -603,15 +599,6 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
|
||||
if (extremes >= 1) {
|
||||
// Side
|
||||
BlockPos posUp = pos.up();
|
||||
TileEntity tileUp = worldObj.getTileEntity(posUp);
|
||||
if (sides >= 1 && !(tileUp instanceof IGreenhouseComponent)) {
|
||||
int delta = y - minimumCoord.getY();
|
||||
if (delta + 1 >= minY) {
|
||||
isNextRoof = true;
|
||||
}
|
||||
break height;
|
||||
}
|
||||
|
||||
int exteriorLevel = y - minimumCoord.getY();
|
||||
if (part != null) {
|
||||
@@ -635,6 +622,15 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
isBlockGoodForInterior(this.worldObj, pos);
|
||||
}
|
||||
}
|
||||
|
||||
BlockPos posUp = pos.up(2);
|
||||
TileEntity tileUp = worldObj.getTileEntity(posUp);
|
||||
if (sides >= 1 && !(tileUp instanceof IGreenhouseComponent)) {
|
||||
int delta = y - minimumCoord.getY();
|
||||
if (delta + 2 >= minY) {
|
||||
isNextRoof = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -652,7 +648,7 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
}
|
||||
|
||||
if (internalBlocks.isEmpty()) {
|
||||
throw new MultiblockValidationException(Translator.translateToLocalFormatted("for.multiblock.greenhouse.error.space.closed"));
|
||||
throw new MultiblockValidationException(Translator.translateToLocal("for.multiblock.greenhouse.error.space.closed"));
|
||||
}
|
||||
|
||||
int hatches = 0;
|
||||
@@ -662,7 +658,7 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
}
|
||||
}
|
||||
if (hatches > 1) {
|
||||
throw new MultiblockValidationException(Translator.translateToLocalFormatted("for.multiblock.greenhouse.error.butterflyhatch.toomany"));
|
||||
throw new MultiblockValidationException(Translator.translateToLocal("for.multiblock.greenhouse.error.butterflyhatch.toomany"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -682,7 +678,7 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
|
||||
isBlockGoodForInterior(worldObj, posRoot);
|
||||
for (IInternalBlockFace faceToCheck : blockToCheck.getFaces()) {
|
||||
CheckInternalBlockFaceEvent checkEvent = new CheckInternalBlockFaceEvent(createState(), blockToCheck, faceToCheck);
|
||||
CheckInternalBlockFaceEvent checkEvent = new CheckInternalBlockFaceEvent(this, blockToCheck, faceToCheck);
|
||||
MinecraftForge.EVENT_BUS.post(checkEvent);
|
||||
|
||||
if (!faceToCheck.isTested()) {
|
||||
@@ -720,7 +716,7 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
}
|
||||
|
||||
private IInternalBlock createInternalBlock(IInternalBlock internalBlock) {
|
||||
CreateInternalBlockEvent createEvent = new CreateInternalBlockEvent(createState(), internalBlock);
|
||||
CreateInternalBlockEvent createEvent = new CreateInternalBlockEvent(this, internalBlock);
|
||||
|
||||
MinecraftForge.EVENT_BUS.post(createEvent);
|
||||
|
||||
@@ -734,11 +730,11 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
}
|
||||
|
||||
public static ButterflyHatch getGreenhouseButterflyHatch(World world, BlockPos pos) {
|
||||
if (GreenhouseManager.greenhouseHelper.getGreenhouseState(world, pos) == null) {
|
||||
if (GreenhouseManager.greenhouseHelper.getGreenhouseController(world, pos) == null) {
|
||||
return null;
|
||||
}
|
||||
IGreenhouseState state = GreenhouseManager.greenhouseHelper.getGreenhouseState(world, pos);
|
||||
for (IMultiblockComponent greenhouse : state.getGreenhouseComponents()) {
|
||||
IGreenhouseController controller = GreenhouseManager.greenhouseHelper.getGreenhouseController(world, pos);
|
||||
for (IMultiblockComponent greenhouse : controller.getComponents()) {
|
||||
if (greenhouse instanceof ButterflyHatch) {
|
||||
return (ButterflyHatch) greenhouse;
|
||||
}
|
||||
@@ -760,4 +756,24 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
protected void isBlockGoodForInterior(World world, BlockPos pos) throws MultiblockValidationException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IClimateRegion getRegion() {
|
||||
return region;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearRegion() {
|
||||
region = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorld() {
|
||||
return worldObj;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<IGreenhouseComponent.Listener> getListenerComponents() {
|
||||
return listenerComponents;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,8 +14,8 @@ import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Set;
|
||||
|
||||
import forestry.api.greenhouse.IGreenhouseState;
|
||||
import forestry.api.greenhouse.IInternalBlock;
|
||||
import forestry.api.multiblock.IGreenhouseComponent;
|
||||
import forestry.api.multiblock.IGreenhouseController;
|
||||
import forestry.core.owner.IOwnedTile;
|
||||
import forestry.core.fluids.ITankManager;
|
||||
@@ -45,15 +45,15 @@ public interface IGreenhouseControllerInternal extends IGreenhouseController, IM
|
||||
@Nullable
|
||||
EnergyManager getEnergyManager();
|
||||
|
||||
|
||||
/**
|
||||
* @return The current state of the greenhouse controller.
|
||||
*/
|
||||
@Nonnull
|
||||
IGreenhouseState createState();
|
||||
|
||||
/**
|
||||
* @return All internal blocks of the greenhouse.
|
||||
*/
|
||||
Set<IInternalBlock> getInternalBlocks();
|
||||
|
||||
/**
|
||||
* Set the region to null.
|
||||
*/
|
||||
void clearRegion();
|
||||
|
||||
Set<IGreenhouseComponent.Listener> getListenerComponents();
|
||||
}
|
||||
@@ -18,7 +18,6 @@ import java.util.List;
|
||||
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
import forestry.api.greenhouse.IInternalBlock;
|
||||
import forestry.api.greenhouse.IInternalBlockFace;
|
||||
|
||||
|
||||
@@ -15,8 +15,6 @@ import java.io.IOException;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import forestry.api.core.EnumCamouflageType;
|
||||
import forestry.api.core.ICamouflageHandler;
|
||||
import forestry.api.multiblock.IMultiblockComponent;
|
||||
import forestry.api.multiblock.IMultiblockController;
|
||||
@@ -26,23 +24,23 @@ import forestry.core.network.IForestryPacketServer;
|
||||
import forestry.core.network.PacketIdServer;
|
||||
import forestry.core.network.packets.PacketCoordinates;
|
||||
|
||||
public class PacketCamouflageUpdate extends PacketCoordinates implements IForestryPacketServer {
|
||||
public class PacketCamouflageUpdate extends PacketCoordinates implements IForestryPacketServer{
|
||||
|
||||
private ItemStack camouflageStack;
|
||||
private EnumCamouflageType type;
|
||||
private String type;
|
||||
private boolean isMultiblock;
|
||||
|
||||
public PacketCamouflageUpdate() {
|
||||
}
|
||||
|
||||
public PacketCamouflageUpdate(ICamouflageHandler tile, EnumCamouflageType type, boolean isMultiblock) {
|
||||
public PacketCamouflageUpdate(ICamouflageHandler tile, String type, boolean isMultiblock) {
|
||||
super(tile.getCoordinates());
|
||||
this.camouflageStack = tile.getCamouflageBlock(type);
|
||||
this.isMultiblock = isMultiblock;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public PacketCamouflageUpdate(ICamouflageHandler tile, EnumCamouflageType type) {
|
||||
public PacketCamouflageUpdate(ICamouflageHandler tile, String type) {
|
||||
super(tile.getCoordinates());
|
||||
this.camouflageStack = tile.getCamouflageBlock(type);
|
||||
this.isMultiblock = false;
|
||||
@@ -58,7 +56,7 @@ public class PacketCamouflageUpdate extends PacketCoordinates implements IForest
|
||||
protected void writeData(DataOutputStreamForestry data) throws IOException {
|
||||
super.writeData(data);
|
||||
data.writeBoolean(isMultiblock);
|
||||
data.writeShort(type.ordinal());
|
||||
data.writeUTF(type);
|
||||
data.writeItemStack(camouflageStack);
|
||||
}
|
||||
|
||||
@@ -66,7 +64,7 @@ public class PacketCamouflageUpdate extends PacketCoordinates implements IForest
|
||||
public void readData(DataInputStreamForestry data) throws IOException {
|
||||
super.readData(data);
|
||||
isMultiblock = data.readBoolean();
|
||||
type = EnumCamouflageType.VALUES[data.readShort()];
|
||||
type = data.readUTF();
|
||||
camouflageStack = data.readItemStack();
|
||||
}
|
||||
|
||||
|
||||
@@ -15,13 +15,14 @@ import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
|
||||
import net.minecraftforge.client.model.animation.AnimationTESR;
|
||||
import net.minecraftforge.fml.client.registry.ClientRegistry;
|
||||
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.core.models.BlockModelIndex;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.greenhouse.PluginGreenhouse;
|
||||
import forestry.greenhouse.blocks.BlockGreenhouseType;
|
||||
import forestry.greenhouse.models.ModelGreenhouse;
|
||||
import forestry.greenhouse.tiles.TileGreenhouseSprinkler;
|
||||
import forestry.plugins.ForestryPluginUids;
|
||||
|
||||
public class ProxyGreenhouseClient extends ProxyGreenhouse {
|
||||
|
||||
@@ -29,10 +30,17 @@ public class ProxyGreenhouseClient extends ProxyGreenhouse {
|
||||
public void initializeModels() {
|
||||
for (BlockGreenhouseType greenhouseType : BlockGreenhouseType.VALUES) {
|
||||
if (greenhouseType == BlockGreenhouseType.DOOR) {
|
||||
Proxies.render.registerBlockModel(new BlockModelIndex(new ModelResourceLocation("forestry:greenhouse." + greenhouseType, "camouflage"),
|
||||
null, new ModelGreenhouse(),
|
||||
PluginGreenhouse.blocks.getGreenhouseBlock(greenhouseType), false));
|
||||
continue;
|
||||
} else if (greenhouseType == BlockGreenhouseType.SPRINKLER) {
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileGreenhouseSprinkler.class, new AnimationTESR<>());
|
||||
continue;
|
||||
}else if(greenhouseType == BlockGreenhouseType.BUTTERFLY_HATCH){
|
||||
if(!ForestryAPI.enabledPlugins.contains(ForestryPluginUids.LEPIDOPTEROLOGY)){
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
Block greenhouseBlock = PluginGreenhouse.blocks.getGreenhouseBlock(greenhouseType);
|
||||
|
||||
@@ -11,19 +11,20 @@
|
||||
package forestry.greenhouse.tiles;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import forestry.core.owner.IOwnedTile;
|
||||
import forestry.core.owner.IOwnerHandler;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
import forestry.api.core.EnumCamouflageType;
|
||||
import forestry.api.core.CamouflageManager;
|
||||
import forestry.api.core.ICamouflageHandler;
|
||||
import forestry.api.core.ICamouflagedTile;
|
||||
import forestry.api.core.IErrorLogic;
|
||||
@@ -42,6 +43,7 @@ import forestry.core.proxy.Proxies;
|
||||
import forestry.core.tiles.ITitled;
|
||||
import forestry.core.utils.ItemStackUtil;
|
||||
import forestry.greenhouse.blocks.BlockGreenhouse;
|
||||
import forestry.greenhouse.blocks.BlockGreenhouseDoor;
|
||||
import forestry.greenhouse.blocks.BlockGreenhouseType;
|
||||
import forestry.greenhouse.gui.ContainerGreenhouse;
|
||||
import forestry.greenhouse.gui.GuiGreenhouse;
|
||||
@@ -50,12 +52,20 @@ import forestry.greenhouse.network.packets.PacketCamouflageUpdate;
|
||||
|
||||
public abstract class TileGreenhouse extends MultiblockTileEntityForestry<MultiblockLogicGreenhouse> implements IGreenhouseComponent, IHintSource, IStreamableGui, IErrorLogicSource, IOwnedTile, ITitled, ICamouflageHandler, ICamouflagedTile {
|
||||
|
||||
private ItemStack camouflageBlock;
|
||||
protected ItemStack camouflageBlock;
|
||||
|
||||
protected TileGreenhouse() {
|
||||
super(new MultiblockLogicGreenhouse());
|
||||
camouflageBlock = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRefresh(World world, BlockPos pos, IBlockState oldState, IBlockState newSate){
|
||||
if(newSate.getBlock() instanceof BlockGreenhouseDoor && oldState.getBlock() instanceof BlockGreenhouseDoor){
|
||||
return false;
|
||||
}
|
||||
return super.shouldRefresh(world, pos, oldState, newSate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMachineAssembled(IMultiblockController multiblockController, BlockPos minCoord, BlockPos maxCoord) {
|
||||
@@ -92,27 +102,32 @@ public abstract class TileGreenhouse extends MultiblockTileEntityForestry<Multib
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCamouflageBlock(EnumCamouflageType type, ItemStack camouflageBlock) {
|
||||
public void setCamouflageBlock(String type, ItemStack camouflageBlock) {
|
||||
if(!ItemStackUtil.isIdenticalItem(camouflageBlock, this.camouflageBlock)){
|
||||
this.camouflageBlock = camouflageBlock;
|
||||
|
||||
if (worldObj != null) {
|
||||
if (worldObj.isRemote) {
|
||||
worldObj.markBlockRangeForRenderUpdate(getPos(), getPos());
|
||||
Proxies.net.sendToServer(new PacketCamouflageUpdate(this, type));
|
||||
worldObj.markBlockRangeForRenderUpdate(getPos(), getPos());
|
||||
}
|
||||
}
|
||||
MinecraftForge.EVENT_BUS.post(new CamouflageChangeEvent(getMultiblockLogic().getController().createState(), this, this, type));
|
||||
MinecraftForge.EVENT_BUS.post(new CamouflageChangeEvent(getMultiblockLogic().getController(), this, this, type));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getCamouflageBlock(EnumCamouflageType type) {
|
||||
public boolean canHandleType(String type) {
|
||||
return type.equals(getCamouflageType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getCamouflageBlock(String type) {
|
||||
return camouflageBlock;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getDefaultCamouflageBlock(EnumCamouflageType type) {
|
||||
public ItemStack getDefaultCamouflageBlock(String type) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -142,28 +157,6 @@ public abstract class TileGreenhouse extends MultiblockTileEntityForestry<Multib
|
||||
return Config.hints.get("greenhouse");
|
||||
}
|
||||
|
||||
/* IStreamableGui */
|
||||
@Override
|
||||
public void writeGuiData(DataOutputStreamForestry data) throws IOException {
|
||||
getMultiblockLogic().getController().writeGuiData(data);
|
||||
ItemStack camouflageBlock = getCamouflageBlock(getCamouflageType());
|
||||
if (camouflageBlock != null) {
|
||||
data.writeShort(1);
|
||||
data.writeItemStack(camouflageBlock);
|
||||
} else {
|
||||
data.writeShort(0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readGuiData(DataInputStreamForestry data) throws IOException {
|
||||
getMultiblockLogic().getController().readGuiData(data);
|
||||
if (data.readShort() == 1) {
|
||||
setCamouflageBlock(getCamouflageType(), data.readItemStack());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* IErrorLogicSource */
|
||||
@Override
|
||||
public IErrorLogic getErrorLogic() {
|
||||
@@ -180,6 +173,17 @@ public abstract class TileGreenhouse extends MultiblockTileEntityForestry<Multib
|
||||
public String getUnlocalizedTitle() {
|
||||
return "for.gui.greenhouse.title";
|
||||
}
|
||||
|
||||
/* IStreamableGui */
|
||||
@Override
|
||||
public void writeGuiData(DataOutputStreamForestry data) throws IOException {
|
||||
getMultiblockLogic().getController().writeGuiData(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readGuiData(DataInputStreamForestry data) throws IOException {
|
||||
getMultiblockLogic().getController().readGuiData(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getGui(EntityPlayer player, int data) {
|
||||
@@ -192,15 +196,18 @@ public abstract class TileGreenhouse extends MultiblockTileEntityForestry<Multib
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumCamouflageType getCamouflageType() {
|
||||
public String getCamouflageType() {
|
||||
if (getBlockType() instanceof BlockGreenhouse && ((BlockGreenhouse) getBlockType()).getGreenhouseType() == BlockGreenhouseType.GLASS) {
|
||||
return EnumCamouflageType.GLASS;
|
||||
return CamouflageManager.GLASS;
|
||||
}else if (((BlockGreenhouse) getBlockType()).getGreenhouseType() == BlockGreenhouseType.DOOR) {
|
||||
return CamouflageManager.DOOR;
|
||||
}
|
||||
return EnumCamouflageType.DEFAULT;
|
||||
return CamouflageManager.DEFAULT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventoryAdapter getInternalInventory() {
|
||||
return getMultiblockLogic().getController().getInternalInventory();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -13,11 +13,12 @@ package forestry.greenhouse.tiles;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import forestry.api.core.IClimateControlled;
|
||||
import forestry.api.greenhouse.IGreenhouseHousing;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import forestry.api.core.climate.IClimatePosition;
|
||||
import forestry.api.core.climate.IClimateRegion;
|
||||
import forestry.api.multiblock.IGreenhouseComponent;
|
||||
import forestry.api.multiblock.IGreenhouseController;
|
||||
import forestry.api.multiblock.IMultiblockController;
|
||||
import forestry.apiculture.network.packets.PacketActiveUpdate;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.tiles.IActivatable;
|
||||
@@ -26,24 +27,29 @@ import forestry.greenhouse.multiblock.IGreenhouseControllerInternal;
|
||||
public class TileGreenhouseClimatiser extends TileGreenhouse implements IActivatable, IGreenhouseComponent.Climatiser {
|
||||
|
||||
protected static final int WORK_CYCLES = 1;
|
||||
protected static final int ENERGY_PER_OPERATION = 50;
|
||||
protected static final int ENERGY_PER_OPERATION = 150;
|
||||
|
||||
protected enum ClimitiserType {
|
||||
TEMPERATURE, HUMIDITY
|
||||
}
|
||||
|
||||
protected interface IClimitiserDefinition {
|
||||
float getChangePerTransfer();
|
||||
|
||||
float getBoundaryUp();
|
||||
|
||||
float getBoundaryDown();
|
||||
float getChange();
|
||||
|
||||
boolean isPositiv();
|
||||
|
||||
int getClimitiseRange();
|
||||
|
||||
ClimitiserType getType();
|
||||
}
|
||||
|
||||
private final IClimitiserDefinition definition;
|
||||
|
||||
protected EnumFacing inwards;
|
||||
protected EnumFacing leftwards;
|
||||
protected BlockPos maxPos;
|
||||
protected BlockPos minPos;
|
||||
|
||||
protected int workingTime = 0;
|
||||
|
||||
private boolean active;
|
||||
@@ -53,23 +59,109 @@ public class TileGreenhouseClimatiser extends TileGreenhouse implements IActivat
|
||||
}
|
||||
|
||||
@Override
|
||||
public <G extends IGreenhouseController & IGreenhouseHousing & IClimateControlled> void changeClimate(int tick, G greenhouse) {
|
||||
IGreenhouseControllerInternal greenhouseInternal = (IGreenhouseControllerInternal) greenhouse;
|
||||
if (workingTime < 20 && greenhouseInternal.getEnergyManager().consumeEnergyToDoWork(WORK_CYCLES, ENERGY_PER_OPERATION)) {
|
||||
// one tick of work for every 10 RF
|
||||
workingTime += ENERGY_PER_OPERATION / 10;
|
||||
public void onMachineBroken() {
|
||||
inwards = null;
|
||||
leftwards = null;
|
||||
|
||||
minPos = null;
|
||||
maxPos = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMachineAssembled(IMultiblockController multiblockController, BlockPos minCoord, BlockPos maxCoord) {
|
||||
recalculateDirections(minCoord, maxCoord);
|
||||
|
||||
if(leftwards != null){
|
||||
maxPos = getPos().offset(inwards, definition.getClimitiseRange() / 2).offset(leftwards, definition.getClimitiseRange() / 2).offset(EnumFacing.UP, definition.getClimitiseRange() / 2);
|
||||
minPos = getPos().offset(inwards).offset(leftwards.getOpposite(), definition.getClimitiseRange() / 2).offset(EnumFacing.DOWN, definition.getClimitiseRange() / 2);
|
||||
|
||||
}else{
|
||||
maxPos = getPos().offset(inwards, definition.getClimitiseRange() / 2).offset(EnumFacing.EAST, definition.getClimitiseRange() / 2).offset(EnumFacing.NORTH, definition.getClimitiseRange() / 2);
|
||||
minPos = getPos().offset(inwards).offset(EnumFacing.WEST, definition.getClimitiseRange() / 2).offset(EnumFacing.SOUTH, definition.getClimitiseRange() / 2);
|
||||
}
|
||||
|
||||
if (workingTime > 0) {
|
||||
workingTime--;
|
||||
if (definition.getType() == ClimitiserType.TEMPERATURE) {
|
||||
greenhouse.addTemperatureChange(definition.getChangePerTransfer(), definition.getBoundaryDown(), definition.getBoundaryUp());
|
||||
} else if (definition.getType() == ClimitiserType.HUMIDITY) {
|
||||
greenhouse.addHumidityChange(definition.getChangePerTransfer(), definition.getBoundaryDown(), definition.getBoundaryUp());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTicksForChange(IClimateRegion region) {
|
||||
return 20;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changeClimate(int tick, IClimateRegion region) {
|
||||
IMultiblockController controller = getMultiblockLogic().getController();
|
||||
if(getMultiblockLogic().isConnected() && controller != null && controller.isAssembled() && minPos != null && maxPos != null && region != null){
|
||||
IGreenhouseControllerInternal greenhouseInternal = (IGreenhouseControllerInternal) controller;
|
||||
boolean canWork = true;
|
||||
for (IGreenhouseComponent.Listener listenerComponent : greenhouseInternal.getListenerComponents()) {
|
||||
if(canWork){
|
||||
canWork = listenerComponent.getGreenhouseListener().canWork(greenhouseInternal, canWork);
|
||||
}
|
||||
}
|
||||
if (canWork && workingTime == 0 && greenhouseInternal.getEnergyManager().consumeEnergyToDoWork(WORK_CYCLES, ENERGY_PER_OPERATION)) {
|
||||
int dimensionID = worldObj.provider.getDimension();
|
||||
|
||||
for(BlockPos pos : BlockPos.getAllInBox(maxPos, minPos)){
|
||||
IClimatePosition position = region.getPositions().get(pos);
|
||||
if(position != null){
|
||||
if (definition.getType() == ClimitiserType.TEMPERATURE) {
|
||||
if(definition.isPositiv()){
|
||||
if(position.getTemperature() >= 2.0F){
|
||||
if(position.getTemperature() > 2.0F){
|
||||
position.setTemperature(2.0F);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}else{
|
||||
if(position.getTemperature() <= 0.0F){
|
||||
if(position.getTemperature() < 0.0F){
|
||||
position.setTemperature(0.0F);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
if(definition.isPositiv()){
|
||||
if(position.getHumidity() >= 2.0F){
|
||||
if(position.getHumidity() > 2.0F){
|
||||
position.setHumidity(2.0F);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}else{
|
||||
if(position.getHumidity() <= 0.0F){
|
||||
if(position.getHumidity() < 0.0F){
|
||||
position.setHumidity(0.0F);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
double distance = pos.distanceSq(this.pos);
|
||||
int maxDistance = definition.getClimitiseRange();
|
||||
if(distance <= maxDistance){
|
||||
if (definition.getType() == ClimitiserType.TEMPERATURE) {
|
||||
position.addTemperature((definition.isPositiv() ? +1 : -1) * (float) (definition.getChange() / distance));
|
||||
}else{
|
||||
position.addHumidity((definition.isPositiv() ? +1 : -1) * (float) (definition.getChange() / distance));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Add config entry for a time modifier and a energy modifier.
|
||||
// one tick of work for every 10 RF
|
||||
workingTime += ENERGY_PER_OPERATION / 25;
|
||||
}
|
||||
|
||||
if (workingTime > 0) {
|
||||
workingTime--;
|
||||
}
|
||||
|
||||
setActive(workingTime > 0);
|
||||
}else if(isActive()){
|
||||
setActive(false);
|
||||
}
|
||||
|
||||
setActive(workingTime > 0);
|
||||
}
|
||||
|
||||
/* LOADING & SAVING */
|
||||
@@ -107,6 +199,43 @@ public class TileGreenhouseClimatiser extends TileGreenhouse implements IActivat
|
||||
return active;
|
||||
}
|
||||
|
||||
public void recalculateDirections(BlockPos minCoord, BlockPos maxCoord) {
|
||||
inwards = null;
|
||||
leftwards = null;
|
||||
|
||||
int facesMatching = 0;
|
||||
if (maxCoord.getX() == getPos().getX() || minCoord.getX() == getPos().getX()) {
|
||||
facesMatching++;
|
||||
}
|
||||
if (maxCoord.getY() == getPos().getY() || minCoord.getY() == getPos().getY()) {
|
||||
facesMatching++;
|
||||
}
|
||||
if (maxCoord.getZ() == getPos().getZ() || minCoord.getZ() == getPos().getZ()) {
|
||||
facesMatching++;
|
||||
}
|
||||
if (facesMatching == 1) {
|
||||
if (maxCoord.getX() == getPos().getX()) {
|
||||
inwards = EnumFacing.WEST;
|
||||
leftwards = EnumFacing.SOUTH;
|
||||
} else if (minCoord.getX() == getPos().getX()) {
|
||||
inwards = EnumFacing.EAST;
|
||||
leftwards = EnumFacing.NORTH;
|
||||
} else if (maxCoord.getZ() == getPos().getZ()) {
|
||||
inwards = EnumFacing.NORTH;
|
||||
leftwards = EnumFacing.WEST;
|
||||
} else if (minCoord.getZ() == getPos().getZ()) {
|
||||
inwards = EnumFacing.SOUTH;
|
||||
leftwards = EnumFacing.EAST;
|
||||
} else if (maxCoord.getY() == getPos().getY()) {
|
||||
inwards = EnumFacing.DOWN;
|
||||
} else {
|
||||
inwards = EnumFacing.UP;
|
||||
}
|
||||
}else{
|
||||
inwards = EnumFacing.DOWN;
|
||||
}
|
||||
}
|
||||
|
||||
public IClimitiserDefinition getDefinition() {
|
||||
return definition;
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.api.greenhouse.DefaultGreenhouseListener;
|
||||
import forestry.api.greenhouse.IGreenhouseHousing;
|
||||
import forestry.api.greenhouse.IGreenhouseListener;
|
||||
import forestry.api.multiblock.IGreenhouseComponent;
|
||||
import forestry.api.multiblock.IGreenhouseController;
|
||||
@@ -41,7 +40,7 @@ public class TileGreenhouseControl extends TileGreenhouse implements IGreenhouse
|
||||
}
|
||||
|
||||
@Override
|
||||
public <G extends IGreenhouseController & IGreenhouseHousing> boolean canWork(G greenhouse, boolean canWork) {
|
||||
public boolean canWork(IGreenhouseController greenhouse, boolean canWork) {
|
||||
return canWork && !hasRedstoneSignal();
|
||||
}
|
||||
|
||||
|
||||
@@ -10,53 +10,28 @@
|
||||
******************************************************************************/
|
||||
package forestry.greenhouse.tiles;
|
||||
|
||||
import forestry.api.core.IErrorLogic;
|
||||
import forestry.api.core.IErrorLogicSource;
|
||||
import forestry.api.multiblock.IGreenhouseComponent;
|
||||
import forestry.api.multiblock.IMultiblockController;
|
||||
import forestry.core.owner.IOwnerHandler;
|
||||
import forestry.core.owner.IOwnedTile;
|
||||
import forestry.core.multiblock.MultiblockTileEntityForestry;
|
||||
import forestry.greenhouse.multiblock.MultiblockLogicGreenhouse;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import forestry.core.utils.ItemStackUtil;
|
||||
|
||||
public class TileGreenhouseDoor extends MultiblockTileEntityForestry<MultiblockLogicGreenhouse> implements IGreenhouseComponent.Door, IErrorLogicSource, IOwnedTile {
|
||||
public class TileGreenhouseDoor extends TileGreenhouse {
|
||||
|
||||
public TileGreenhouseDoor() {
|
||||
super(new MultiblockLogicGreenhouse());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMachineAssembled(IMultiblockController multiblockController, BlockPos minCoord, BlockPos maxCoord) {
|
||||
worldObj.notifyBlockOfStateChange(getPos(), worldObj.getBlockState(pos).getBlock());
|
||||
markDirty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMachineBroken() {
|
||||
worldObj.notifyBlockOfStateChange(getPos(), worldObj.getBlockState(pos).getBlock());
|
||||
markDirty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IErrorLogic getErrorLogic() {
|
||||
return getMultiblockLogic().getController().getErrorLogic();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IOwnerHandler getOwnerHandler() {
|
||||
return getMultiblockLogic().getController().getOwnerHandler();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getGui(EntityPlayer player, int data) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getContainer(EntityPlayer player, int data) {
|
||||
return null;
|
||||
public void setCamouflageBlock(String type, ItemStack camouflageBlock) {
|
||||
if(!ItemStackUtil.isIdenticalItem(camouflageBlock, this.camouflageBlock)){
|
||||
super.setCamouflageBlock(type, camouflageBlock);
|
||||
TileGreenhouseDoor otherDoorTile = null;
|
||||
if(worldObj.getTileEntity(pos.up()) instanceof TileGreenhouseDoor){
|
||||
otherDoorTile = (TileGreenhouseDoor) worldObj.getTileEntity(pos.up());
|
||||
}else if(worldObj.getTileEntity(pos.down()) instanceof TileGreenhouseDoor){
|
||||
otherDoorTile = (TileGreenhouseDoor) worldObj.getTileEntity(pos.down());
|
||||
}
|
||||
if(otherDoorTile != null){
|
||||
otherDoorTile.setCamouflageBlock(type, camouflageBlock);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -21,18 +21,18 @@ public class TileGreenhouseDryer extends TileGreenhouseClimatiser {
|
||||
private static class DryerDefinition implements IClimitiserDefinition {
|
||||
|
||||
@Override
|
||||
public float getChangePerTransfer() {
|
||||
return -0.01f;
|
||||
public float getChange() {
|
||||
return 0.015F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPositiv() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getBoundaryUp() {
|
||||
return 2.5f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getBoundaryDown() {
|
||||
return 0.05f;
|
||||
public int getClimitiseRange() {
|
||||
return 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -22,24 +22,24 @@ public class TileGreenhouseFan extends TileGreenhouseClimatiser {
|
||||
private static class FanDefinition implements IClimitiserDefinition {
|
||||
|
||||
@Override
|
||||
public float getChangePerTransfer() {
|
||||
return -0.01f;
|
||||
public float getChange() {
|
||||
return 0.015F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getBoundaryUp() {
|
||||
return 2.5f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getBoundaryDown() {
|
||||
return 0.05f;
|
||||
public int getClimitiseRange() {
|
||||
return 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClimitiserType getType() {
|
||||
return ClimitiserType.TEMPERATURE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPositiv() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -12,6 +12,8 @@ package forestry.greenhouse.tiles;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import forestry.core.owner.IOwnerHandler;
|
||||
@@ -25,15 +27,10 @@ import com.mojang.authlib.GameProfile;
|
||||
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import forestry.api.core.EnumCamouflageType;
|
||||
import forestry.api.core.CamouflageManager;
|
||||
import forestry.api.core.ICamouflageHandler;
|
||||
import forestry.api.core.ICamouflagedTile;
|
||||
import forestry.api.core.IErrorLogic;
|
||||
@@ -45,6 +42,9 @@ import forestry.api.multiblock.MultiblockTileEntityBase;
|
||||
import forestry.core.owner.IOwnedTile;
|
||||
import forestry.core.config.Config;
|
||||
import forestry.core.gui.IHintSource;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
import forestry.core.network.IStreamableGui;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.tiles.TileUtil;
|
||||
import forestry.core.utils.ItemStackUtil;
|
||||
@@ -59,7 +59,7 @@ import cofh.api.energy.IEnergyHandler;
|
||||
import cofh.api.energy.IEnergyProvider;
|
||||
import cofh.api.energy.IEnergyReceiver;
|
||||
|
||||
public class TileGreenhouseHatch extends MultiblockTileEntityBase<MultiblockLogicGreenhouse> implements IGreenhouseComponent, IHintSource, IErrorLogicSource, IOwnedTile, ICamouflageHandler, ICamouflagedTile, IFluidHandler, IEnergyProvider, IEnergyReceiver {
|
||||
public class TileGreenhouseHatch extends MultiblockTileEntityBase<MultiblockLogicGreenhouse> implements IGreenhouseComponent, IStreamableGui, IHintSource, IErrorLogicSource, IOwnedTile, ICamouflageHandler, ICamouflagedTile, IEnergyProvider, IEnergyReceiver {
|
||||
|
||||
EnumFacing outwards;
|
||||
private ItemStack camouflageBlock;
|
||||
@@ -140,29 +140,45 @@ public class TileGreenhouseHatch extends MultiblockTileEntityBase<MultiblockLogi
|
||||
|
||||
/* CONSTRUCTION MATERIAL */
|
||||
@Override
|
||||
public void setCamouflageBlock(EnumCamouflageType type, ItemStack camouflageBlock) {
|
||||
public void setCamouflageBlock(String type, ItemStack camouflageBlock) {
|
||||
if(!ItemStackUtil.isIdenticalItem(camouflageBlock, this.camouflageBlock)){
|
||||
this.camouflageBlock = camouflageBlock;
|
||||
|
||||
if (worldObj != null) {
|
||||
if (worldObj.isRemote) {
|
||||
worldObj.markBlockRangeForRenderUpdate(getPos(), getPos());
|
||||
Proxies.net.sendToServer(new PacketCamouflageUpdate(this, type));
|
||||
worldObj.markBlockRangeForRenderUpdate(getPos(), getPos());
|
||||
}
|
||||
}
|
||||
MinecraftForge.EVENT_BUS.post(new CamouflageChangeEvent(getMultiblockLogic().getController().createState(), this, this, type));
|
||||
MinecraftForge.EVENT_BUS.post(new CamouflageChangeEvent(getMultiblockLogic().getController(), this, this, type));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getCamouflageBlock(EnumCamouflageType type) {
|
||||
public ItemStack getCamouflageBlock(String type) {
|
||||
return camouflageBlock;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getDefaultCamouflageBlock(EnumCamouflageType type) {
|
||||
public ItemStack getDefaultCamouflageBlock(String type) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canHandleType(String type) {
|
||||
return type.equals(getCamouflageType());
|
||||
}
|
||||
|
||||
/* IStreamableGui */
|
||||
@Override
|
||||
public void writeGuiData(DataOutputStreamForestry data) throws IOException {
|
||||
getMultiblockLogic().getController().writeGuiData(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readGuiData(DataInputStreamForestry data) throws IOException {
|
||||
getMultiblockLogic().getController().readGuiData(data);
|
||||
}
|
||||
|
||||
/* TILEFORESTRY */
|
||||
@Override
|
||||
@@ -201,11 +217,11 @@ public class TileGreenhouseHatch extends MultiblockTileEntityBase<MultiblockLogi
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumCamouflageType getCamouflageType() {
|
||||
public String getCamouflageType() {
|
||||
if (getBlockType() instanceof BlockGreenhouse && ((BlockGreenhouse) getBlockType()).getGreenhouseType() == BlockGreenhouseType.GLASS) {
|
||||
return EnumCamouflageType.GLASS;
|
||||
return CamouflageManager.GLASS;
|
||||
}
|
||||
return EnumCamouflageType.DEFAULT;
|
||||
return CamouflageManager.DEFAULT;
|
||||
}
|
||||
|
||||
private IItemHandler getOutwardsInventory() {
|
||||
@@ -222,14 +238,6 @@ public class TileGreenhouseHatch extends MultiblockTileEntityBase<MultiblockLogi
|
||||
return worldObj.getTileEntity(getPos().offset(outwards));
|
||||
}
|
||||
|
||||
private IFluidHandler getOutwardFluidHandler() {
|
||||
TileEntity tile = getOutwardsTile();
|
||||
if (!(tile instanceof IFluidHandler)) {
|
||||
return null;
|
||||
}
|
||||
return (IFluidHandler) tile;
|
||||
}
|
||||
|
||||
private IEnergyConnection getOutwardEnergyConnection() {
|
||||
TileEntity tile = getOutwardsTile();
|
||||
if (!(tile instanceof IEnergyConnection)) {
|
||||
@@ -361,60 +369,6 @@ public class TileGreenhouseHatch extends MultiblockTileEntityBase<MultiblockLogi
|
||||
}
|
||||
return provider.extractEnergy(from, maxExtract, simulate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(EnumFacing from, FluidStack resource, boolean doFill) {
|
||||
IFluidHandler handler = getOutwardFluidHandler();
|
||||
if (handler == null) {
|
||||
return 0;
|
||||
}
|
||||
return handler.fill(from, resource, doFill);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(EnumFacing from, FluidStack resource, boolean doDrain) {
|
||||
IFluidHandler handler = getOutwardFluidHandler();
|
||||
if (handler == null) {
|
||||
return null;
|
||||
}
|
||||
return handler.drain(from, resource, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(EnumFacing from, int maxDrain, boolean doDrain) {
|
||||
IFluidHandler handler = getOutwardFluidHandler();
|
||||
if (handler == null) {
|
||||
return null;
|
||||
}
|
||||
return handler.drain(from, maxDrain, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill(EnumFacing from, Fluid fluid) {
|
||||
IFluidHandler handler = getOutwardFluidHandler();
|
||||
if (handler == null) {
|
||||
return false;
|
||||
}
|
||||
return handler.canFill(from, fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain(EnumFacing from, Fluid fluid) {
|
||||
IFluidHandler handler = getOutwardFluidHandler();
|
||||
if (handler == null) {
|
||||
return false;
|
||||
}
|
||||
return handler.canDrain(from, fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo(EnumFacing from) {
|
||||
IFluidHandler handler = getOutwardFluidHandler();
|
||||
if (handler == null) {
|
||||
return null;
|
||||
}
|
||||
return handler.getTankInfo(from);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Loaded 100 of 103 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user