Improve greenhouse api and add events

This commit is contained in:
Nedelosk committed 2016-03-19 19:49:45 +01:00
1 parent 7924e9fa83
commit 336d388b4b
21 files changed
+362 -123

No files matched your search

@@ -1,41 +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.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);
}
}
}
@@ -31,7 +31,7 @@ public class DefaultGreenhouseLogic implements IGreenhouseLogic {
}
@Override
public void onChange(EnumGreenhouseChangeType type, Object event) {
public void onEvent(EnumGreenhouseEventType type, Object event) {
}
@Override
@@ -5,7 +5,7 @@
******************************************************************************/
package forestry.api.greenhouse;
public enum EnumGreenhouseChangeType {
public enum EnumGreenhouseEventType {
CAMOUFLAGE
@@ -0,0 +1,79 @@
/*******************************************************************************
* 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 javax.annotation.Nonnull;
import javax.annotation.Nullable;
import forestry.api.core.EnumCamouflageType;
import forestry.api.core.ICamouflageHandler;
import forestry.api.core.ICamouflagedBlock;
import net.minecraftforge.fml.common.eventhandler.Event;
public class GreenhouseEvents extends Event {
@Nullable
public final IGreenhouseState state;
public GreenhouseEvents(IGreenhouseState state) {
this.state = state;
}
public static class CamouflageChangeEvent extends GreenhouseEvents{
@Nullable
public ICamouflagedBlock camouflagedBlock;
@Nonnull
public ICamouflageHandler camouflageHandler;
@Nonnull
public final EnumCamouflageType camouflageType;
public CamouflageChangeEvent(IGreenhouseState state, ICamouflagedBlock camouflagedBlock, ICamouflageHandler camouflageHandler, EnumCamouflageType camouflageType) {
super(state);
this.camouflagedBlock = camouflagedBlock;
this.camouflageHandler = camouflageHandler;
this.camouflageType = camouflageType;
}
}
public static class InternalBlockEvent extends GreenhouseEvents{
@Nonnull
public IInternalBlock internalBlock;
public InternalBlockEvent(IGreenhouseState state, IInternalBlock internalBlock) {
super(state);
this.internalBlock = internalBlock;
}
}
public static class CreateInternalBlockEvent extends InternalBlockEvent{
public CreateInternalBlockEvent(IGreenhouseState state, IInternalBlock internalBlock) {
super(state, internalBlock);
}
}
public static class CheckInternalBlockFaceEvent extends InternalBlockEvent{
@Nonnull
public final IInternalBlockFace face;
public CheckInternalBlockFaceEvent(IGreenhouseState state, IInternalBlock internalBlock, IInternalBlockFace face) {
super(state, internalBlock);
this.face = face;
}
}
}
@@ -18,7 +18,7 @@ public interface IGreenhouseLogic extends INbtWritable, INbtReadable {
void work();
void onChange(EnumGreenhouseChangeType type, Object event);
void onEvent(EnumGreenhouseEventType type, Object event);
IGreenhouseController getController();
@@ -5,6 +5,8 @@
******************************************************************************/
package forestry.api.greenhouse;
import java.util.List;
import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
import net.minecraft.world.World;
@@ -18,6 +20,8 @@ public interface IGreenhouseState {
float getExactTemperature();
float getExactHumidity();
List<IInternalBlock> getInternalBlocks();
/**
* @return The world in that the greenhouse standing
@@ -0,0 +1,29 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.greenhouse;
import java.util.Collection;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
public interface IInternalBlock {
@Nonnull
World getWorld();
@Nonnull
BlockPos getPos();
@Nullable
IInternalBlock getRoot();
@Nonnull
Collection<IInternalBlockFace> getFaces();
}
@@ -0,0 +1,25 @@
/*******************************************************************************
* 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 net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
public interface IInternalBlockFace {
boolean isTested();
void setTested(boolean tested);
@Nonnull
EnumFacing getFace();
@Nonnull
BlockPos getPos();
}
@@ -9,7 +9,7 @@ import java.util.List;
import forestry.api.core.ICamouflageHandler;
import forestry.api.core.IClimateControlled;
import forestry.api.greenhouse.EnumGreenhouseChangeType;
import forestry.api.greenhouse.EnumGreenhouseEventType;
import forestry.api.greenhouse.IGreenhouseHousing;
import forestry.api.greenhouse.IGreenhouseLogic;
@@ -18,7 +18,7 @@ public interface IGreenhouseController extends IMultiblockController, IGreenhous
/**
* Handle change events
*/
void onChange(EnumGreenhouseChangeType type, Object event);
void onChange(EnumGreenhouseEventType type, Object event);
/**
* @return The logics of the greenhouse