mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-21 04:22:32 +00:00
Add greenhouse logics
This commit is contained in:
1 parent
ad69242a40
commit
eebd9c6ecf
33 files changed
+586
-243
No files matched your search
@@ -0,0 +1,41 @@
|
||||
/*******************************************************************************
|
||||
* 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.api.core;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
|
||||
public class CamouflageEvents extends Event {
|
||||
|
||||
@Nullable
|
||||
public ICamouflagedBlock camouflagedBlock;
|
||||
@Nonnull
|
||||
public ICamouflageHandler camouflageHandler;
|
||||
@Nonnull
|
||||
public final EnumCamouflageType camouflageType;
|
||||
|
||||
private CamouflageEvents(ICamouflagedBlock camouflagedBlock, ICamouflageHandler camouflageHandler, EnumCamouflageType camouflageType) {
|
||||
this.camouflagedBlock = camouflagedBlock;
|
||||
this.camouflageHandler = camouflageHandler;
|
||||
this.camouflageType = camouflageType;
|
||||
}
|
||||
|
||||
public static class CamouflageChangeEvent extends CamouflageEvents{
|
||||
|
||||
public CamouflageChangeEvent(ICamouflagedBlock camouflagedBlock, ICamouflageHandler camouflageHandler, EnumCamouflageType camouflageType) {
|
||||
super(camouflagedBlock, camouflageHandler, camouflageType);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.greenhouse;
|
||||
|
||||
import forestry.api.multiblock.IGreenhouseController;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class DefaultGreenhouseLogic implements IGreenhouseLogic {
|
||||
|
||||
public final IGreenhouseController controller;
|
||||
private final String name;
|
||||
|
||||
public DefaultGreenhouseLogic(IGreenhouseController controller, String name) {
|
||||
this.controller = controller;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWork() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChange(EnumGreenhouseChangeType type, Object event) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGreenhouseController getController() {
|
||||
return controller;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.greenhouse;
|
||||
|
||||
public enum EnumGreenhouseChangeType {
|
||||
|
||||
CAMOUFLAGE
|
||||
|
||||
}
|
||||
@@ -1,7 +1,17 @@
|
||||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.greenhouse;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class GreenhouseManager {
|
||||
|
||||
public static IGreenhouseItemAccess greenhouseItemAccess;
|
||||
public static IGreenhouseAccess greenhouseAccess;
|
||||
|
||||
public static List<Class<? extends IGreenhouseLogic>> greenhouseLogics = new ArrayList();
|
||||
|
||||
}
|
||||
+4
-2
@@ -10,12 +10,14 @@ import javax.annotation.Nonnull;
|
||||
import forestry.api.core.EnumCamouflageType;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IGreenhouseItemAccess {
|
||||
public interface IGreenhouseAccess {
|
||||
|
||||
void registerGreenhouseGlass(@Nonnull ItemStack glass);
|
||||
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);
|
||||
@@ -0,0 +1,11 @@
|
||||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.greenhouse;
|
||||
|
||||
public interface IGreenhouseClimaLogic extends IGreenhouseLogic {
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/*******************************************************************************
|
||||
* 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.api.greenhouse;
|
||||
|
||||
import forestry.api.core.INbtReadable;
|
||||
import forestry.api.core.INbtWritable;
|
||||
import forestry.api.multiblock.IGreenhouseController;
|
||||
|
||||
public interface IGreenhouseLogic extends INbtWritable, INbtReadable {
|
||||
|
||||
void onWork();
|
||||
|
||||
void onChange(EnumGreenhouseChangeType type, Object event);
|
||||
|
||||
IGreenhouseController getController();
|
||||
|
||||
String getName();
|
||||
|
||||
}
|
||||
@@ -5,8 +5,18 @@
|
||||
******************************************************************************/
|
||||
package forestry.api.multiblock;
|
||||
|
||||
import forestry.api.greenhouse.IGreenhouseHousing;
|
||||
import java.util.List;
|
||||
|
||||
public interface IGreenhouseController extends IMultiblockController, IGreenhouseHousing {
|
||||
import forestry.api.core.ICamouflageHandler;
|
||||
import forestry.api.core.IClimateControlled;
|
||||
import forestry.api.greenhouse.EnumGreenhouseChangeType;
|
||||
import forestry.api.greenhouse.IGreenhouseHousing;
|
||||
import forestry.api.greenhouse.IGreenhouseLogic;
|
||||
|
||||
public interface IGreenhouseController extends IMultiblockController, IGreenhouseHousing, ICamouflageHandler, IClimateControlled {
|
||||
|
||||
void onChange(EnumGreenhouseChangeType type, Object event);
|
||||
|
||||
List<IGreenhouseLogic> getLogics();
|
||||
|
||||
}
|
||||
@@ -414,7 +414,7 @@ public abstract class MultiblockControllerBase implements IMultiblockControllerI
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.assemblyState != AssemblyState.Assembled) {
|
||||
if (onlyUpdateWhenAssembled() && this.assemblyState != AssemblyState.Assembled) {
|
||||
// Not assembled - don't run game logic
|
||||
return;
|
||||
}
|
||||
@@ -884,4 +884,8 @@ public abstract class MultiblockControllerBase implements IMultiblockControllerI
|
||||
private static boolean isInvalid(IMultiblockComponent part) {
|
||||
return part instanceof TileEntity && ((TileEntity) part).isInvalid();
|
||||
}
|
||||
|
||||
protected boolean onlyUpdateWhenAssembled(){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -51,9 +51,6 @@ public enum PacketIdClient implements IPacketId {
|
||||
|
||||
// Arboriculture
|
||||
RIPENING_UPDATE,
|
||||
|
||||
// Greanhouse
|
||||
TILE_FORESTRY_CAMOUFLAGE,
|
||||
|
||||
// Mail
|
||||
TRADING_ADDRESS_RESPONSE,
|
||||
|
||||
@@ -14,10 +14,15 @@ import java.io.IOException;
|
||||
|
||||
import forestry.api.core.EnumCamouflageType;
|
||||
import forestry.api.core.ICamouflageHandler;
|
||||
import forestry.api.core.ICamouflagedBlock;
|
||||
import forestry.api.multiblock.IMultiblockComponent;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
public class CamouflageUtil {
|
||||
|
||||
@@ -53,4 +58,33 @@ public class CamouflageUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public static ICamouflageHandler getCamouflageHandler(IBlockAccess world, BlockPos pos){
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
|
||||
if(tile instanceof IMultiblockComponent){
|
||||
IMultiblockComponent component = (IMultiblockComponent) tile;
|
||||
if(component.getMultiblockLogic().getController() instanceof ICamouflageHandler){
|
||||
return (ICamouflageHandler) component.getMultiblockLogic().getController();
|
||||
}
|
||||
}
|
||||
if(tile instanceof ICamouflageHandler){
|
||||
return (ICamouflageHandler) tile;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static ItemStack getCamouflageBlock(IBlockAccess world, BlockPos pos){
|
||||
ICamouflageHandler handler = getCamouflageHandler(world, pos);
|
||||
if(handler == null){
|
||||
return null;
|
||||
}
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
if(tile instanceof ICamouflagedBlock){
|
||||
ICamouflagedBlock block = (ICamouflagedBlock) tile;
|
||||
|
||||
return handler.getCamouflageBlock(block.getCamouflageType());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,11 +14,10 @@ import forestry.core.tiles.TileEngine;
|
||||
import forestry.core.utils.BlockUtil;
|
||||
|
||||
import cofh.api.energy.EnergyStorage;
|
||||
import cofh.api.energy.IEnergyHandler;
|
||||
import cofh.api.energy.IEnergyProvider;
|
||||
import cofh.api.energy.IEnergyReceiver;
|
||||
|
||||
public class EnergyManager implements IEnergyHandler, IEnergyReceiver, IEnergyProvider, IStreamable {
|
||||
public class EnergyManager implements IEnergyReceiver, IEnergyProvider, IStreamable {
|
||||
private enum EnergyTransferMode {
|
||||
EXTRACT, RECEIVE, BOTH
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
/*******************************************************************************
|
||||
* 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 forestry.api.core.CamouflageEvents.CamouflageChangeEvent;
|
||||
import forestry.api.core.ICamouflageHandler;
|
||||
import forestry.api.greenhouse.EnumGreenhouseChangeType;
|
||||
import forestry.api.multiblock.IGreenhouseComponent;
|
||||
import forestry.api.multiblock.IGreenhouseController;
|
||||
import forestry.greenhouse.blocks.BlockGreenhouseType;
|
||||
import net.minecraftforge.client.event.TextureStitchEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class EventHandlerGreenhouse {
|
||||
|
||||
@SubscribeEvent
|
||||
public void onCamouflageChance(CamouflageChangeEvent event){
|
||||
ICamouflageHandler handler = event.camouflageHandler;
|
||||
|
||||
IGreenhouseController controller = null;
|
||||
if(handler instanceof IGreenhouseController){
|
||||
controller = (IGreenhouseController) handler;
|
||||
}
|
||||
|
||||
if(handler instanceof IGreenhouseComponent){
|
||||
IGreenhouseComponent component = (IGreenhouseComponent) handler;
|
||||
controller = component.getMultiblockLogic().getController();
|
||||
}
|
||||
|
||||
if(controller != null){
|
||||
controller.onChange(EnumGreenhouseChangeType.CAMOUFLAGE, event);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void handleTextureRemap(TextureStitchEvent.Pre event) {
|
||||
BlockGreenhouseType.registerSprites();
|
||||
}
|
||||
|
||||
}
|
||||
+23
-10
@@ -12,32 +12,31 @@ package forestry.greenhouse;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import forestry.api.core.EnumCamouflageType;
|
||||
import forestry.api.greenhouse.IGreenhouseItemAccess;
|
||||
import forestry.api.greenhouse.IGreenhouseAccess;
|
||||
import forestry.core.utils.Log;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class GreenhouseItemAccess implements IGreenhouseItemAccess {
|
||||
public class GreenhouseAccess implements IGreenhouseAccess {
|
||||
|
||||
private final List<ItemStack> greenhouseGlass = Lists.newArrayList();
|
||||
private final Map<ItemStack, Float> greenhouseGlass = new HashMap();
|
||||
private final Map<EnumCamouflageType, List<ItemStack>> camouflageBlockBlacklist = new EnumMap(EnumCamouflageType.class);
|
||||
|
||||
public GreenhouseItemAccess() {
|
||||
public GreenhouseAccess() {
|
||||
for(EnumCamouflageType type : EnumCamouflageType.VALUES){
|
||||
camouflageBlockBlacklist.put(type, new ArrayList());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerGreenhouseGlass(@Nonnull ItemStack glass) {
|
||||
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;
|
||||
@@ -47,13 +46,27 @@ public class GreenhouseItemAccess implements IGreenhouseItemAccess {
|
||||
Log.error("Fail to register greenhouse glass: " + block + ".");
|
||||
return;
|
||||
}
|
||||
for(ItemStack greenhouseGlass : greenhouseGlass){
|
||||
for(ItemStack greenhouseGlass : greenhouseGlass.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;
|
||||
}
|
||||
}
|
||||
greenhouseGlass.add(glass);
|
||||
greenhouseGlass.put(glass, lightTransmittance);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getGreenhouseGlassLightTransmittance(ItemStack glass) {
|
||||
if(glass == null || glass.getItem() == null || Block.getBlockFromItem(glass.getItem()) == null) {
|
||||
return 0.5F;
|
||||
}
|
||||
for(Map.Entry<ItemStack, Float> greenhouseGlassEntry : greenhouseGlass.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
|
||||
@@ -61,7 +74,7 @@ public class GreenhouseItemAccess implements IGreenhouseItemAccess {
|
||||
if(glass == null || glass.getItem() == null || Block.getBlockFromItem(glass.getItem()) == null) {
|
||||
return false;
|
||||
}
|
||||
for(ItemStack greenhouseGlass : greenhouseGlass){
|
||||
for(ItemStack greenhouseGlass : greenhouseGlass.keySet()){
|
||||
if(greenhouseGlass.getItem() == glass.getItem() && greenhouseGlass.getItemDamage() == glass.getItemDamage() && ItemStack.areItemStackTagsEqual(glass, greenhouseGlass)){
|
||||
return true;
|
||||
}
|
||||
@@ -11,11 +11,11 @@
|
||||
package forestry.greenhouse;
|
||||
|
||||
import forestry.api.greenhouse.GreenhouseManager;
|
||||
import forestry.api.greenhouse.IGreenhouseItemAccess;
|
||||
import forestry.api.greenhouse.IGreenhouseAccess;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.network.IPacketRegistry;
|
||||
import forestry.greenhouse.blocks.BlockGreenhouseType;
|
||||
import forestry.greenhouse.blocks.BlockRegistryGreenhouse;
|
||||
import forestry.greenhouse.logics.GreenhouseEffect;
|
||||
import forestry.greenhouse.network.PacketRegistryGreenhouse;
|
||||
import forestry.greenhouse.proxy.ProxyGreenhouse;
|
||||
import forestry.greenhouse.tiles.TileGreenhouseControl;
|
||||
@@ -33,13 +33,9 @@ import forestry.plugins.ForestryPlugin;
|
||||
import forestry.plugins.ForestryPluginUids;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.client.event.TextureStitchEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fml.common.SidedProxy;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@ForestryPlugin(pluginID = ForestryPluginUids.GREENHOUSE, name = "Greenhouse", author = "Nedelosk", url = Constants.URL, unlocalizedDescription = "for.plugin.greenhouse.description")
|
||||
public class PluginGreenhouse extends BlankForestryPlugin {
|
||||
@@ -51,7 +47,7 @@ public class PluginGreenhouse extends BlankForestryPlugin {
|
||||
|
||||
@Override
|
||||
public void setupAPI() {
|
||||
GreenhouseManager.greenhouseItemAccess = new GreenhouseItemAccess();
|
||||
GreenhouseManager.greenhouseAccess = new GreenhouseAccess();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -77,29 +73,31 @@ public class PluginGreenhouse extends BlankForestryPlugin {
|
||||
|
||||
@Override
|
||||
public void preInit(){
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
MinecraftForge.EVENT_BUS.register(new EventHandlerGreenhouse());
|
||||
|
||||
IGreenhouseItemAccess greenhouseAccess = GreenhouseManager.greenhouseItemAccess;
|
||||
IGreenhouseAccess greenhouseAccess = GreenhouseManager.greenhouseAccess;
|
||||
|
||||
greenhouseAccess.registerGreenhouseGlass(new ItemStack(Blocks.glass, 1, 0));
|
||||
greenhouseAccess.registerGreenhouseGlass(new ItemStack(Blocks.stained_glass, 1, 0));
|
||||
greenhouseAccess.registerGreenhouseGlass(new ItemStack(Blocks.stained_glass, 1, 1));
|
||||
greenhouseAccess.registerGreenhouseGlass(new ItemStack(Blocks.stained_glass, 1, 2));
|
||||
greenhouseAccess.registerGreenhouseGlass(new ItemStack(Blocks.stained_glass, 1, 3));
|
||||
greenhouseAccess.registerGreenhouseGlass(new ItemStack(Blocks.stained_glass, 1, 4));
|
||||
greenhouseAccess.registerGreenhouseGlass(new ItemStack(Blocks.stained_glass, 1, 5));
|
||||
greenhouseAccess.registerGreenhouseGlass(new ItemStack(Blocks.stained_glass, 1, 6));
|
||||
greenhouseAccess.registerGreenhouseGlass(new ItemStack(Blocks.stained_glass, 1, 7));
|
||||
greenhouseAccess.registerGreenhouseGlass(new ItemStack(Blocks.stained_glass, 1, 8));
|
||||
greenhouseAccess.registerGreenhouseGlass(new ItemStack(Blocks.stained_glass, 1, 9));
|
||||
greenhouseAccess.registerGreenhouseGlass(new ItemStack(Blocks.stained_glass, 1, 10));
|
||||
greenhouseAccess.registerGreenhouseGlass(new ItemStack(Blocks.stained_glass, 1, 11));
|
||||
greenhouseAccess.registerGreenhouseGlass(new ItemStack(Blocks.stained_glass, 1, 12));
|
||||
greenhouseAccess.registerGreenhouseGlass(new ItemStack(Blocks.stained_glass, 1, 13));
|
||||
greenhouseAccess.registerGreenhouseGlass(new ItemStack(Blocks.stained_glass, 1, 14));
|
||||
greenhouseAccess.registerGreenhouseGlass(new ItemStack(Blocks.stained_glass, 1, 15));
|
||||
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(GreenhouseEffect.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -107,10 +105,4 @@ public class PluginGreenhouse extends BlankForestryPlugin {
|
||||
return new PacketRegistryGreenhouse();
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void handleTextureRemap(TextureStitchEvent.Pre event) {
|
||||
BlockGreenhouseType.registerSprites();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -43,7 +43,6 @@ import net.minecraftforge.common.property.Properties;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.core.ICamouflageHandler;
|
||||
import forestry.api.core.ICamouflagedBlock;
|
||||
import forestry.api.core.IModelManager;
|
||||
import forestry.api.core.Tabs;
|
||||
@@ -52,7 +51,7 @@ import forestry.core.CreativeTabForestry;
|
||||
import forestry.core.blocks.BlockStructure;
|
||||
import forestry.core.blocks.propertys.UnlistedBlockAccess;
|
||||
import forestry.core.blocks.propertys.UnlistedBlockPos;
|
||||
import forestry.greenhouse.multiblock.IGreenhouseControllerInternal;
|
||||
import forestry.core.utils.CamouflageUtil;
|
||||
import forestry.greenhouse.tiles.TileGreenhouseControl;
|
||||
import forestry.greenhouse.tiles.TileGreenhouseDoor;
|
||||
import forestry.greenhouse.tiles.TileGreenhouseDryer;
|
||||
@@ -219,8 +218,10 @@ public abstract class BlockGreenhouse extends BlockStructure {
|
||||
public int colorMultiplier(IBlockAccess world, BlockPos pos, int renderPass) {
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
if(tile instanceof ICamouflagedBlock){
|
||||
if(renderPass < 100 && BlockGreenhouse.getCamouflageBlock(world, pos) != null){
|
||||
return Block.getBlockFromItem(BlockGreenhouse.getCamouflageBlock(world, pos).getItem()).colorMultiplier(world, pos, renderPass);
|
||||
ItemStack camouflageStack = CamouflageUtil.getCamouflageBlock(world, pos);
|
||||
|
||||
if(renderPass < 100 && camouflageStack != null){
|
||||
return Block.getBlockFromItem(camouflageStack.getItem()).colorMultiplier(world, pos, renderPass);
|
||||
}
|
||||
|
||||
return super.colorMultiplier(world, pos, renderPass);
|
||||
@@ -286,21 +287,6 @@ public abstract class BlockGreenhouse extends BlockStructure {
|
||||
|
||||
return block == this ? false : super.shouldSideBeRendered(worldIn, pos, side);
|
||||
}
|
||||
|
||||
public static <G extends TileEntity & IGreenhouseComponent & ICamouflageHandler & ICamouflagedBlock> ItemStack getCamouflageBlock(IBlockAccess world, BlockPos pos){
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
if(tile instanceof IGreenhouseComponent && tile instanceof ICamouflageHandler && tile instanceof ICamouflagedBlock){
|
||||
G greenhouse = (G) tile;
|
||||
IGreenhouseControllerInternal greenhouseController = (IGreenhouseControllerInternal) greenhouse.getMultiblockLogic().getController();
|
||||
|
||||
ICamouflageHandler camouflageHandler = greenhouse;
|
||||
if(greenhouse.getCamouflageBlock(greenhouse.getCamouflageType()) == null && greenhouseController.getCamouflageBlock(greenhouse.getCamouflageType()) != null){
|
||||
camouflageHandler = greenhouseController;
|
||||
}
|
||||
return camouflageHandler.getCamouflageBlock(greenhouse.getCamouflageType());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
|
||||
@@ -65,7 +65,7 @@ public class WidgetCamouflageSlot extends Widget {
|
||||
if(stack != null && Block.getBlockFromItem(stack.getItem()) != null){
|
||||
Block block = Block.getBlockFromItem(stack.getItem());
|
||||
|
||||
if(!GreenhouseManager.greenhouseItemAccess.isOnCamouflageBlockBlackList(type, stack) && (type == EnumCamouflageType.DEFAULT && block.isOpaqueCube() && !block.hasTileEntity(block.getStateFromMeta(stack.getItemDamage())) && block.isNormalCube(player.worldObj, camouflageHandler.getCoordinates()) || type == EnumCamouflageType.GLASS && GreenhouseManager.greenhouseItemAccess.isGreenhouseGlass(stack))){
|
||||
if(!GreenhouseManager.greenhouseAccess.isOnCamouflageBlockBlackList(type, stack) && (type == EnumCamouflageType.DEFAULT && block.isOpaqueCube() && !block.hasTileEntity(block.getStateFromMeta(stack.getItemDamage())) && block.isNormalCube(player.worldObj, camouflageHandler.getCoordinates()) || type == EnumCamouflageType.GLASS && GreenhouseManager.greenhouseAccess.isGreenhouseGlass(stack))){
|
||||
camouflageHandler.setCamouflageBlock(type, stack);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
/*******************************************************************************
|
||||
* 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.logics;
|
||||
|
||||
import forestry.api.core.EnumCamouflageType;
|
||||
import forestry.api.core.ICamouflagedBlock;
|
||||
import forestry.api.greenhouse.DefaultGreenhouseLogic;
|
||||
import forestry.api.greenhouse.EnumGreenhouseChangeType;
|
||||
import forestry.api.greenhouse.GreenhouseManager;
|
||||
import forestry.api.greenhouse.IGreenhouseClimaLogic;
|
||||
import forestry.api.multiblock.IGreenhouseController;
|
||||
import forestry.api.multiblock.IMultiblockComponent;
|
||||
import forestry.core.utils.CamouflageUtil;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class GreenhouseEffect extends DefaultGreenhouseLogic implements IGreenhouseClimaLogic {
|
||||
|
||||
private float lightTransmittance;
|
||||
private int workTimer;
|
||||
|
||||
public GreenhouseEffect(IGreenhouseController controller) {
|
||||
super(controller, "GreenhouseEffect");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWork() {
|
||||
if(controller == null || !controller.isAssembled()){
|
||||
return;
|
||||
}
|
||||
if(controller.getWorld().isDaytime()){
|
||||
controller.addTemperatureChange(lightTransmittance / 100, 0F, 2.5F);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt) {
|
||||
nbt.setInteger("workTimer", workTimer);
|
||||
nbt.setFloat("lightTransmittance", lightTransmittance);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
workTimer = nbt.getInteger("workTimer");
|
||||
lightTransmittance = nbt.getFloat("lightTransmittance");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChange(EnumGreenhouseChangeType type, Object event) {
|
||||
if(type == EnumGreenhouseChangeType.CAMOUFLAGE){
|
||||
if(controller == null || !controller.isAssembled()) {
|
||||
return;
|
||||
}
|
||||
float lightTransmittance = 0F;
|
||||
int i = 0;
|
||||
|
||||
World world = controller.getWorld();
|
||||
for(IMultiblockComponent component : controller.getComponents()){
|
||||
if(component instanceof ICamouflagedBlock){
|
||||
ICamouflagedBlock block = (ICamouflagedBlock) component;
|
||||
if(block.getCamouflageType() == EnumCamouflageType.GLASS){
|
||||
if(world.canBlockSeeSky(component.getCoordinates())){
|
||||
ItemStack camouflageStack = CamouflageUtil.getCamouflageBlock(world, component.getCoordinates());
|
||||
float camouflageLightTransmittance = GreenhouseManager.greenhouseAccess.getGreenhouseGlassLightTransmittance(camouflageStack);
|
||||
|
||||
if(camouflageLightTransmittance < 1 && camouflageLightTransmittance > 0){
|
||||
lightTransmittance=+ camouflageLightTransmittance;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(i != 0){
|
||||
this.lightTransmittance = lightTransmittance / i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -31,6 +31,7 @@ import forestry.api.core.ICamouflagedBlock;
|
||||
import forestry.api.core.IModelBaker;
|
||||
import forestry.api.multiblock.IGreenhouseComponent;
|
||||
import forestry.core.models.ModelBlockOverlay;
|
||||
import forestry.core.utils.CamouflageUtil;
|
||||
|
||||
public class ModelGreenhouse<G extends TileEntity & IGreenhouseComponent & ICamouflageHandler & ICamouflagedBlock> extends ModelBlockOverlay<BlockGreenhouse> {
|
||||
|
||||
@@ -45,14 +46,16 @@ public class ModelGreenhouse<G extends TileEntity & IGreenhouseComponent & ICamo
|
||||
|
||||
@Override
|
||||
protected void bakeWorldBlock(BlockGreenhouse block, IBlockAccess world, BlockPos pos, IExtendedBlockState stateExtended, IModelBaker baker) {
|
||||
bakeBlockModel(block, world, pos, stateExtended, baker, BlockGreenhouse.getCamouflageBlock(world, pos));
|
||||
ItemStack camouflageStack = CamouflageUtil.getCamouflageBlock(world, pos);
|
||||
|
||||
bakeBlockModel(block, world, pos, stateExtended, baker, camouflageStack);
|
||||
}
|
||||
|
||||
private void bakeBlockModel(@Nonnull BlockGreenhouse block, @Nullable IBlockAccess world, @Nullable BlockPos pos, @Nullable IExtendedBlockState stateExtended, @Nonnull IModelBaker baker, @Nullable ItemStack camouflageBlock){
|
||||
if(camouflageBlock != null){
|
||||
private 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();
|
||||
|
||||
baker.addBakedModel(modelShapes.getModelForState(Block.getBlockFromItem(camouflageBlock.getItem()).getStateFromMeta(camouflageBlock.getItemDamage())));
|
||||
baker.addBakedModel(modelShapes.getModelForState(Block.getBlockFromItem(camouflageStack.getItem()).getStateFromMeta(camouflageStack.getItemDamage())));
|
||||
}
|
||||
|
||||
//Bake the default blocks
|
||||
|
||||
@@ -10,7 +10,12 @@
|
||||
******************************************************************************/
|
||||
package forestry.greenhouse.multiblock;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import forestry.api.core.EnumCamouflageType;
|
||||
import forestry.api.greenhouse.EnumGreenhouseChangeType;
|
||||
import forestry.api.greenhouse.IGreenhouseLogic;
|
||||
import forestry.core.fluids.FakeTankManager;
|
||||
import forestry.core.fluids.ITankManager;
|
||||
import forestry.core.inventory.FakeInventoryAdapter;
|
||||
@@ -24,7 +29,6 @@ public class FakeGreenhouseController extends FakeMultiblockController implement
|
||||
public static final FakeGreenhouseController instance = new FakeGreenhouseController();
|
||||
|
||||
private FakeGreenhouseController() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -67,6 +71,25 @@ public class FakeGreenhouseController extends FakeMultiblockController implement
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<IGreenhouseLogic> getLogics() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChange(EnumGreenhouseChangeType type, Object event) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createLogics() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addTemperatureChange(float change, float boundaryDown, float boundaryUp) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addHumidityChange(float change, float boundaryDown, float boundaryUp) {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,6 +11,8 @@
|
||||
package forestry.greenhouse.multiblock;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
@@ -20,12 +22,16 @@ import java.util.Set;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import forestry.api.core.CamouflageEvents.CamouflageChangeEvent;
|
||||
import forestry.api.greenhouse.EnumGreenhouseChangeType;
|
||||
import forestry.api.greenhouse.GreenhouseManager;
|
||||
import forestry.api.greenhouse.IGreenhouseLogic;
|
||||
import forestry.api.core.EnumCamouflageType;
|
||||
import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import forestry.api.core.ICamouflagedBlock;
|
||||
import forestry.api.core.IClimateControlled;
|
||||
import forestry.api.multiblock.IGreenhouseComponent;
|
||||
import forestry.api.multiblock.IGreenhouseController;
|
||||
import forestry.api.multiblock.IMultiblockComponent;
|
||||
import forestry.core.access.EnumAccess;
|
||||
import forestry.core.config.Constants;
|
||||
@@ -42,11 +48,11 @@ import forestry.core.network.DataOutputStreamForestry;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.tiles.ILiquidTankTile;
|
||||
import forestry.core.utils.CamouflageUtil;
|
||||
import forestry.core.utils.Log;
|
||||
import forestry.energy.EnergyManager;
|
||||
import forestry.greenhouse.blocks.BlockGreenhouse;
|
||||
import forestry.greenhouse.blocks.BlockGreenhouseType;
|
||||
import forestry.greenhouse.network.packets.PacketCamouflageUpdateToClient;
|
||||
import forestry.greenhouse.network.packets.PacketCamouflageUpdateToServer;
|
||||
import forestry.greenhouse.network.packets.PacketCamouflageUpdate;
|
||||
import forestry.greenhouse.tiles.TileGreenhouseSprinkler;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.init.Blocks;
|
||||
@@ -58,14 +64,16 @@ import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
|
||||
public class GreenhouseController extends RectangularMultiblockControllerBase implements IGreenhouseControllerInternal, IClimateControlled, ILiquidTankTile {
|
||||
public class GreenhouseController extends RectangularMultiblockControllerBase implements IGreenhouseControllerInternal, ILiquidTankTile {
|
||||
|
||||
private final List<InternalBlock> internalBlocks = Lists.newArrayList();
|
||||
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<InternalBlock> internalBlocks = new ArrayList();
|
||||
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;
|
||||
@@ -90,6 +98,23 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
this.energyManager = new EnergyManager(2000, 100000);
|
||||
this.inventory = new InventoryGreenhouse(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createLogics() {
|
||||
logics.clear();
|
||||
for(Class<? extends IGreenhouseLogic> logicClass : GreenhouseManager.greenhouseLogics){
|
||||
try{
|
||||
logics.add(createLogic(logicClass));
|
||||
}catch(Exception e){
|
||||
Log.error("Fail to create a greenhouse logic with the class: " + logicClass);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private IGreenhouseLogic createLogic(Class<? extends IGreenhouseLogic> logicClass) throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException{
|
||||
return logicClass.getConstructor(IGreenhouseController.class).newInstance(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventoryAdapter getInternalInventory() {
|
||||
@@ -190,6 +215,12 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
CamouflageUtil.writeCamouflageBlockToNBT(data, this, EnumCamouflageType.DEFAULT);
|
||||
CamouflageUtil.writeCamouflageBlockToNBT(data, this, EnumCamouflageType.GLASS);
|
||||
CamouflageUtil.writeCamouflageBlockToNBT(data, this, EnumCamouflageType.DOOR);
|
||||
|
||||
for(IGreenhouseLogic logic : getLogics()){
|
||||
NBTTagCompound nbtTag = new NBTTagCompound();
|
||||
logic.writeToNBT(nbtTag);
|
||||
data.setTag("logic" + logic.getName(), nbtTag);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -205,6 +236,10 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
CamouflageUtil.readCamouflageBlockFromNBT(data, this, EnumCamouflageType.DEFAULT);
|
||||
CamouflageUtil.readCamouflageBlockFromNBT(data, this, EnumCamouflageType.GLASS);
|
||||
CamouflageUtil.readCamouflageBlockFromNBT(data, this, EnumCamouflageType.DOOR);
|
||||
|
||||
for(IGreenhouseLogic logic : getLogics()){
|
||||
logic.readFromNBT(data.getCompoundTag("logic" + logic.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -271,11 +306,11 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
}
|
||||
}
|
||||
}
|
||||
Proxies.net.sendToServer(new PacketCamouflageUpdateToServer(this, type, true));
|
||||
}else{
|
||||
Proxies.net.sendNetworkPacket(new PacketCamouflageUpdateToClient(this, type, true), worldObj);
|
||||
Proxies.net.sendToServer(new PacketCamouflageUpdate(this, type, true));
|
||||
}
|
||||
}
|
||||
|
||||
MinecraftForge.EVENT_BUS.post(new CamouflageChangeEvent(null, this, type));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -327,11 +362,19 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
readFromNBT(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onMachineAssembled() {
|
||||
super.onMachineAssembled();
|
||||
|
||||
createLogics();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onMachineDisassembled() {
|
||||
super.onMachineDisassembled();
|
||||
|
||||
internalBlocks.clear();
|
||||
logics.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -366,30 +409,53 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
|
||||
@Override
|
||||
protected boolean updateServer(int tickCount) {
|
||||
if (updateOnInterval(20)) {
|
||||
inventory.drainCan(tankManager);
|
||||
}
|
||||
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 (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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
tempChange = equalizeChange(tempChange);
|
||||
humidChange = equalizeChange(humidChange);
|
||||
return canWork;
|
||||
}
|
||||
|
||||
return canWork;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -618,4 +684,16 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChange(EnumGreenhouseChangeType type, Object event) {
|
||||
for(IGreenhouseLogic logic : logics){
|
||||
logic.onChange(type, event);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IGreenhouseLogic> getLogics() {
|
||||
return logics;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -12,7 +12,6 @@ package forestry.greenhouse.multiblock;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import forestry.api.core.ICamouflageHandler;
|
||||
import forestry.api.multiblock.IGreenhouseController;
|
||||
import forestry.core.access.IRestrictedAccess;
|
||||
import forestry.core.fluids.ITankManager;
|
||||
@@ -21,7 +20,7 @@ import forestry.core.multiblock.IMultiblockControllerInternal;
|
||||
import forestry.core.network.IStreamableGui;
|
||||
import forestry.energy.EnergyManager;
|
||||
|
||||
public interface IGreenhouseControllerInternal extends IGreenhouseController, IMultiblockControllerInternal, IRestrictedAccess, IStreamableGui, ICamouflageHandler {
|
||||
public interface IGreenhouseControllerInternal extends IGreenhouseController, IMultiblockControllerInternal, IRestrictedAccess, IStreamableGui {
|
||||
|
||||
IInventoryAdapter getInternalInventory();
|
||||
|
||||
@@ -30,4 +29,6 @@ public interface IGreenhouseControllerInternal extends IGreenhouseController, IM
|
||||
@Nullable
|
||||
EnergyManager getEnergyManager();
|
||||
|
||||
void createLogics();
|
||||
|
||||
}
|
||||
@@ -11,13 +11,11 @@
|
||||
package forestry.greenhouse.network;
|
||||
|
||||
import forestry.core.network.PacketRegistry;
|
||||
import forestry.greenhouse.network.packets.PacketCamouflageUpdateToClient;
|
||||
import forestry.greenhouse.network.packets.PacketCamouflageUpdateToServer;
|
||||
import forestry.greenhouse.network.packets.PacketCamouflageUpdate;
|
||||
|
||||
public class PacketRegistryGreenhouse extends PacketRegistry {
|
||||
@Override
|
||||
public void registerPackets() {
|
||||
registerServerPacket(new PacketCamouflageUpdateToServer());
|
||||
registerClientPacket(new PacketCamouflageUpdateToClient());
|
||||
registerServerPacket(new PacketCamouflageUpdate());
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -25,23 +25,23 @@ import forestry.core.network.IForestryPacketServer;
|
||||
import forestry.core.network.PacketIdServer;
|
||||
import forestry.core.network.packets.PacketCoordinates;
|
||||
|
||||
public class PacketCamouflageUpdateToServer extends PacketCoordinates implements IForestryPacketServer {
|
||||
public class PacketCamouflageUpdate extends PacketCoordinates implements IForestryPacketServer {
|
||||
|
||||
private ItemStack camouflageBlock;
|
||||
private EnumCamouflageType type;
|
||||
private boolean isMultiblock;
|
||||
|
||||
public PacketCamouflageUpdateToServer() {
|
||||
public PacketCamouflageUpdate() {
|
||||
}
|
||||
|
||||
public PacketCamouflageUpdateToServer(ICamouflageHandler tile, EnumCamouflageType type, boolean isMultiblock) {
|
||||
public PacketCamouflageUpdate(ICamouflageHandler tile, EnumCamouflageType type, boolean isMultiblock) {
|
||||
super(tile.getCoordinates());
|
||||
this.camouflageBlock = tile.getCamouflageBlock(type);
|
||||
this.isMultiblock = isMultiblock;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public PacketCamouflageUpdateToServer(ICamouflageHandler tile, EnumCamouflageType type) {
|
||||
public PacketCamouflageUpdate(ICamouflageHandler tile, EnumCamouflageType type) {
|
||||
super(tile.getCoordinates());
|
||||
this.camouflageBlock = tile.getCamouflageBlock(type);
|
||||
this.isMultiblock = false;
|
||||
@@ -1,89 +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.network.packets;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
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;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
import forestry.core.network.IForestryPacketClient;
|
||||
import forestry.core.network.PacketIdClient;
|
||||
import forestry.core.network.packets.PacketCoordinates;
|
||||
|
||||
public class PacketCamouflageUpdateToClient extends PacketCoordinates implements IForestryPacketClient {
|
||||
|
||||
private ItemStack camouflageBlock;
|
||||
private EnumCamouflageType type;
|
||||
private boolean isMultiblock;
|
||||
|
||||
public PacketCamouflageUpdateToClient() {
|
||||
}
|
||||
|
||||
public PacketCamouflageUpdateToClient(ICamouflageHandler tile, EnumCamouflageType type, boolean isMultiblock) {
|
||||
super(tile.getCoordinates());
|
||||
this.camouflageBlock = tile.getCamouflageBlock(type);
|
||||
this.isMultiblock = isMultiblock;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public PacketCamouflageUpdateToClient(ICamouflageHandler tile, EnumCamouflageType type) {
|
||||
super(tile.getCoordinates());
|
||||
this.camouflageBlock = tile.getCamouflageBlock(type);
|
||||
this.isMultiblock = false;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketIdClient getPacketId() {
|
||||
return PacketIdClient.TILE_FORESTRY_CAMOUFLAGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeData(DataOutputStreamForestry data) throws IOException {
|
||||
super.writeData(data);
|
||||
data.writeBoolean(isMultiblock);
|
||||
data.writeShort(type.ordinal());
|
||||
data.writeItemStack(camouflageBlock);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readData(DataInputStreamForestry data) throws IOException {
|
||||
super.readData(data);
|
||||
isMultiblock = data.readBoolean();
|
||||
type = EnumCamouflageType.VALUES[data.readShort()];
|
||||
camouflageBlock = data.readItemStack();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacketData(DataInputStreamForestry data, EntityPlayer player) {
|
||||
TileEntity tile = getTarget(player.worldObj);
|
||||
ICamouflageHandler handler = null;
|
||||
if(isMultiblock && tile instanceof IMultiblockComponent){
|
||||
IMultiblockController controller = ((IMultiblockComponent) tile).getMultiblockLogic().getController();
|
||||
if(controller instanceof ICamouflageHandler){
|
||||
handler = (ICamouflageHandler) controller;
|
||||
}
|
||||
}
|
||||
else if (tile instanceof ICamouflageHandler) {
|
||||
handler = (ICamouflageHandler) tile;
|
||||
}
|
||||
if(handler != null){
|
||||
handler.setCamouflageBlock(type, camouflageBlock);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,11 +17,13 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import forestry.api.core.EnumCamouflageType;
|
||||
import forestry.api.core.ICamouflageHandler;
|
||||
import forestry.api.core.ICamouflagedBlock;
|
||||
import forestry.api.core.IErrorLogic;
|
||||
import forestry.api.core.IErrorLogicSource;
|
||||
import forestry.api.core.CamouflageEvents.CamouflageChangeEvent;
|
||||
import forestry.api.multiblock.IGreenhouseComponent;
|
||||
import forestry.api.multiblock.IMultiblockController;
|
||||
import forestry.core.access.EnumAccess;
|
||||
@@ -41,8 +43,7 @@ import forestry.greenhouse.blocks.BlockGreenhouseType;
|
||||
import forestry.greenhouse.gui.ContainerGreenhouse;
|
||||
import forestry.greenhouse.gui.GuiGreenhouse;
|
||||
import forestry.greenhouse.multiblock.MultiblockLogicGreenhouse;
|
||||
import forestry.greenhouse.network.packets.PacketCamouflageUpdateToClient;
|
||||
import forestry.greenhouse.network.packets.PacketCamouflageUpdateToServer;
|
||||
import forestry.greenhouse.network.packets.PacketCamouflageUpdate;
|
||||
|
||||
public abstract class TileGreenhouse extends MultiblockTileEntityForestry<MultiblockLogicGreenhouse> implements IGreenhouseComponent, IHintSource, IStreamableGui, IErrorLogicSource, IRestrictedAccess, ITitled, ICamouflageHandler, ICamouflagedBlock {
|
||||
|
||||
@@ -92,7 +93,6 @@ public abstract class TileGreenhouse extends MultiblockTileEntityForestry<Multib
|
||||
}
|
||||
}
|
||||
|
||||
/* CONSTRUCTION MATERIAL */
|
||||
@Override
|
||||
public void setCamouflageBlock(EnumCamouflageType type, ItemStack camouflageBlock) {
|
||||
this.camouflageBlock = camouflageBlock;
|
||||
@@ -100,11 +100,10 @@ public abstract class TileGreenhouse extends MultiblockTileEntityForestry<Multib
|
||||
if (worldObj != null) {
|
||||
if (worldObj.isRemote) {
|
||||
worldObj.markBlockForUpdate(getPos());
|
||||
Proxies.net.sendToServer(new PacketCamouflageUpdateToServer(this, type));
|
||||
} else {
|
||||
Proxies.net.sendNetworkPacket(new PacketCamouflageUpdateToClient(this, type), worldObj);
|
||||
Proxies.net.sendToServer(new PacketCamouflageUpdate(this, type));
|
||||
}
|
||||
}
|
||||
MinecraftForge.EVENT_BUS.post(new CamouflageChangeEvent(this, this, type));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -25,6 +25,7 @@ import forestry.api.core.ICamouflageHandler;
|
||||
import forestry.api.core.ICamouflagedBlock;
|
||||
import forestry.api.core.IErrorLogic;
|
||||
import forestry.api.core.IErrorLogicSource;
|
||||
import forestry.api.core.CamouflageEvents.CamouflageChangeEvent;
|
||||
import forestry.api.multiblock.IGreenhouseComponent;
|
||||
import forestry.api.multiblock.IMultiblockController;
|
||||
import forestry.api.multiblock.MultiblockTileEntityBase;
|
||||
@@ -39,13 +40,14 @@ import forestry.core.utils.PlayerUtil;
|
||||
import forestry.greenhouse.blocks.BlockGreenhouse;
|
||||
import forestry.greenhouse.blocks.BlockGreenhouseType;
|
||||
import forestry.greenhouse.multiblock.MultiblockLogicGreenhouse;
|
||||
import forestry.greenhouse.network.packets.PacketCamouflageUpdateToServer;
|
||||
import forestry.greenhouse.network.packets.PacketCamouflageUpdate;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
@@ -138,10 +140,10 @@ public class TileGreenhouseHatch extends MultiblockTileEntityBase<MultiblockLogi
|
||||
if (worldObj != null) {
|
||||
if (worldObj.isRemote) {
|
||||
worldObj.markBlockForUpdate(getPos());
|
||||
} else {
|
||||
Proxies.net.sendToServer(new PacketCamouflageUpdateToServer(this, type));
|
||||
Proxies.net.sendToServer(new PacketCamouflageUpdate(this, type));
|
||||
}
|
||||
}
|
||||
MinecraftForge.EVENT_BUS.post(new CamouflageChangeEvent(this, this, type));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -41,12 +41,12 @@ import forestry.lepidopterology.blocks.BlockRegistryLepidopterology;
|
||||
import forestry.lepidopterology.blocks.BlockTypeLepidopterologyTesr;
|
||||
import forestry.lepidopterology.commands.CommandButterfly;
|
||||
import forestry.lepidopterology.entities.EntityButterfly;
|
||||
import forestry.lepidopterology.genetics.AlleleButterflyEffect;
|
||||
import forestry.lepidopterology.genetics.ButterflyBranchDefinition;
|
||||
import forestry.lepidopterology.genetics.ButterflyDefinition;
|
||||
import forestry.lepidopterology.genetics.ButterflyFactory;
|
||||
import forestry.lepidopterology.genetics.ButterflyRoot;
|
||||
import forestry.lepidopterology.genetics.MothDefinition;
|
||||
import forestry.lepidopterology.genetics.alleles.AlleleButterflyEffect;
|
||||
import forestry.lepidopterology.items.ItemButterflyGE;
|
||||
import forestry.lepidopterology.items.ItemRegistryLepidopterology;
|
||||
import forestry.lepidopterology.proxy.ProxyLepidopterology;
|
||||
|
||||
@@ -20,6 +20,7 @@ import forestry.api.lepidopterology.EnumButterflyChromosome;
|
||||
import forestry.core.genetics.IBranchDefinition;
|
||||
import forestry.core.genetics.alleles.AlleleHelper;
|
||||
import forestry.core.genetics.alleles.EnumAllele;
|
||||
import forestry.lepidopterology.genetics.alleles.AlleleButterflyEffect;
|
||||
|
||||
public enum ButterflyBranchDefinition implements IBranchDefinition {
|
||||
Anthocharis,
|
||||
|
||||
@@ -15,6 +15,7 @@ import java.awt.Color;
|
||||
import forestry.api.genetics.IClassification;
|
||||
import forestry.api.lepidopterology.IAlleleButterflySpeciesBuilder;
|
||||
import forestry.api.lepidopterology.IButterflyFactory;
|
||||
import forestry.lepidopterology.genetics.alleles.AlleleButterflySpecies;
|
||||
|
||||
public class ButterflyFactory implements IButterflyFactory {
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.lepidopterology.genetics;
|
||||
package forestry.lepidopterology.genetics.alleles;
|
||||
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.IEffectData;
|
||||
+22
-22
@@ -1,22 +1,22 @@
|
||||
/*******************************************************************************
|
||||
* 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.lepidopterology.genetics;
|
||||
|
||||
public class AlleleButterflyEffectNone extends AlleleButterflyEffect {
|
||||
public AlleleButterflyEffectNone() {
|
||||
super("none", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName() {
|
||||
return "for.lepidopterology.effect.none";
|
||||
}
|
||||
}
|
||||
/*******************************************************************************
|
||||
* 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.lepidopterology.genetics.alleles;
|
||||
|
||||
public class AlleleButterflyEffectNone extends AlleleButterflyEffect {
|
||||
public AlleleButterflyEffectNone() {
|
||||
super("none", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName() {
|
||||
return "for.lepidopterology.effect.none";
|
||||
}
|
||||
}
|
||||
Executable → Regular
+1
-1
@@ -8,7 +8,7 @@
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.lepidopterology.genetics;
|
||||
package forestry.lepidopterology.genetics.alleles;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.util.EnumSet;
|
||||
Reference in new issue
Block a user