Skip to content

Commit

Permalink
Add cocoon world genartion with config entry(default false) and add c…
Browse files Browse the repository at this point in the history
…ocoon loot and a greenhouse butterfly hatch
  • Loading branch information
Nedelosk committed Mar 29, 2016
1 parent bc0d105 commit cf23644
Show file tree
Hide file tree
Showing 35 changed files with 748 additions and 61 deletions.
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
mcversion=1.8.9
forgeversion=11.15.1.1755
mcp_mappings=snapshot_20160219
forgeversion=11.15.1.1808
mcp_mappings=snapshot_20160223

jei_version=2.28.+

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/forestry/Forestry.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
name = Constants.MOD_ID,
version = Constants.VERSION,
guiFactory = "forestry.core.config.ForestryGuiConfigFactory",
dependencies = "required-after:Forge@[10.13.4.1566,);"
dependencies = "required-after:Forge@[11.15.1.1808,);"
+ "after:Buildcraft|Core@[6.1.7,);"
+ "after:ExtrabiomesXL;"
+ "after:BiomesOPlenty;"
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/forestry/api/greenhouse/IGreenhouseState.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
******************************************************************************/
package forestry.api.greenhouse;

import java.util.Collection;
import java.util.List;

import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
import forestry.api.multiblock.IMultiblockComponent;
import net.minecraft.world.World;

public interface IGreenhouseState {
Expand All @@ -22,6 +24,8 @@ public interface IGreenhouseState {
float getExactHumidity();

List<IInternalBlock> getInternalBlocks();

Collection<IMultiblockComponent> getGreenhouseComponents();

/**
* @return The world in that the greenhouse standing
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/forestry/api/greenhouse/package-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
@API(apiVersion = "5.0.0", owner = "ForestryAPI|greenhouse", provides = "ForestryAPI|greenhouse")
@API(apiVersion = "5.0.0", owner = "ForestryAPI|core", provides = "ForestryAPI|greenhouse")
package forestry.api.greenhouse;

import net.minecraftforge.fml.common.API;
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,17 @@
******************************************************************************/
package forestry.api.lepidopterology;

import java.util.Map;

import forestry.api.genetics.IAllele;
import net.minecraft.item.ItemStack;

public interface IAlleleButterflyCocoon extends IAllele {

EnumCocoonType getCocoonType();

String getCocoonTexture(int age);

Map<ItemStack, Float> getCocoonLoot();

}
6 changes: 6 additions & 0 deletions src/main/java/forestry/api/lepidopterology/IButterfly.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ public interface IButterfly extends IIndividualLiving {
*/
ItemStack[] getCaterpillarDrop(IButterflyNursery nursery, boolean playerKill, int lootLevel);

/**
* @param cocoon
* @return Array of itemstacks to drop on breaking of the cocoon.
*/
ItemStack[] getCocoonDrop(IButterflyCocoon cocoon);

/**
* Create an exact copy of this butterfly.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import forestry.api.genetics.IHousing;

public interface IButterflyCocoon extends IHousing{

IButterfly getCaterpillar();

void setCaterpillar(IButterfly butterfly);
Expand All @@ -22,4 +22,6 @@ public interface IButterflyCocoon extends IHousing{

void setNursery(IButterflyNursery nursery);

boolean isSolid();

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import forestry.api.core.IClimateControlled;
import forestry.api.greenhouse.IGreenhouseHousing;
import forestry.api.greenhouse.IGreenhouseListener;
import forestry.api.lepidopterology.IButterflyCocoon;
import net.minecraft.item.ItemStack;

public interface IGreenhouseComponent<T extends IMultiblockLogicGreenhouse> extends IMultiblockComponent {
@Override
Expand All @@ -23,6 +25,10 @@ interface Door extends IGreenhouseComponent {
interface Climatiser extends IGreenhouseComponent {
<G extends IGreenhouseController & IGreenhouseHousing & IClimateControlled> void changeClimate(int tickCount, G greenhouse);
}

interface ButterflyHatch extends IGreenhouseComponent {
ItemStack[] addCocoonLoot(IButterflyCocoon cocoon);
}

interface Active extends IGreenhouseComponent {
void updateServer(int tickCount);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/forestry/core/gui/GuiUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -142,4 +142,4 @@ public static void drawToolTips(GuiForestry gui, Collection<?> objects, int mous
}
}
}
}
}
15 changes: 15 additions & 0 deletions src/main/java/forestry/core/utils/ItemStackUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,11 @@ public static List<ItemStack> parseItemStackStrings(String itemStackStrings, int
List<Stack> stacks = Stack.parseStackStrings(itemStackStrings, missingMetaValue);
return getItemStacks(stacks);
}

public static ItemStack parseItemStackString(String itemStackString, int missingMetaValue) {
Stack stack = Stack.parseStackString(itemStackString, missingMetaValue);
return getItemStack(stack);
}

private static List<ItemStack> getItemStacks(List<Stack> stacks) {
List<ItemStack> itemStacks = new ArrayList<>(stacks.size());
Expand All @@ -453,5 +458,15 @@ private static List<ItemStack> getItemStacks(List<Stack> stacks) {
}
return itemStacks;
}

private static ItemStack getItemStack(Stack stack) {
Item item = stack.getItem();
if (item != null) {
int meta = stack.getMeta();
ItemStack itemStack = new ItemStack(item, 1, meta);
return itemStack;
}
return null;
}

}
13 changes: 11 additions & 2 deletions src/main/java/forestry/greenhouse/GreenhouseState.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@
******************************************************************************/
package forestry.greenhouse;

import java.util.Collection;
import java.util.List;

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;
import net.minecraft.world.World;

Expand All @@ -25,16 +27,18 @@ public final class GreenhouseState implements IGreenhouseState {
private final float temperature;
private final World world;
private final List<IInternalBlock> internalBlocks;
private final Collection<IMultiblockComponent> greenhouseComponents;

public GreenhouseState(World world, float humidity, float temperature, List<IInternalBlock> internalBlocks) {
public GreenhouseState(World world, float humidity, float temperature, List<IInternalBlock> internalBlocks, Collection<IMultiblockComponent> greenhouseComponents) {
this.world = world;
this.humidity = humidity;
this.temperature = temperature;
this.internalBlocks = internalBlocks;
this.greenhouseComponents = greenhouseComponents;
}

public GreenhouseState(GreenhouseController controller) {
this(controller.getWorld(), controller.getExactHumidity(), controller.getExactTemperature(), controller.getInternalBlocks());
this(controller.getWorld(), controller.getExactHumidity(), controller.getExactTemperature(), controller.getInternalBlocks(), controller.getComponents());
}

@Override
Expand Down Expand Up @@ -66,5 +70,10 @@ public World getWorld() {
public List<IInternalBlock> getInternalBlocks() {
return internalBlocks;
}

@Override
public Collection<IMultiblockComponent> getGreenhouseComponents() {
return greenhouseComponents;
}

}
4 changes: 4 additions & 0 deletions src/main/java/forestry/greenhouse/PluginGreenhouse.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import forestry.greenhouse.logics.GreenhouseLogicGreenhouseEffect;
import forestry.greenhouse.network.PacketRegistryGreenhouse;
import forestry.greenhouse.proxy.ProxyGreenhouse;
import forestry.greenhouse.tiles.TileGreenhouseButterflyHatch;
import forestry.greenhouse.tiles.TileGreenhouseControl;
import forestry.greenhouse.tiles.TileGreenhouseDoor;
import forestry.greenhouse.tiles.TileGreenhouseDryer;
Expand Down Expand Up @@ -191,6 +192,9 @@ public void doInit() {
GameRegistry.registerTileEntity(TileGreenhousePlain.class, "forestry.GreenhousePlain");
GameRegistry.registerTileEntity(TileGreenhouseDoor.class, "forestry.GreenhouseDoor");
GameRegistry.registerTileEntity(TileGreenhouseHatch.class, "forestry.GreenhouseHatch");
if(ForestryAPI.enabledPlugins.contains(ForestryPluginUids.LEPIDOPTEROLOGY)){
GameRegistry.registerTileEntity(TileGreenhouseButterflyHatch.class, "forestry.GreenhouseButterflyHatch");
}
}

@Override
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/forestry/greenhouse/blocks/BlockGreenhouse.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ public String getName() {
public static Map<BlockGreenhouseType, BlockGreenhouse> create() {
Map<BlockGreenhouseType, BlockGreenhouse> blockMap = new EnumMap<>(BlockGreenhouseType.class);
for (final BlockGreenhouseType type : BlockGreenhouseType.VALUES) {
if(type == BlockGreenhouseType.BUTTERFLY_HATCH){
if(!ForestryAPI.enabledPlugins.contains(ForestryPluginUids.LEPIDOPTEROLOGY)) {
continue;
}
}

BlockGreenhouse block;
if(type == BlockGreenhouseType.DOOR){
block = new BlockGreenhouseDoor();
Expand Down Expand Up @@ -204,6 +210,8 @@ public TileEntity createTileEntity(World world, IBlockState state) {
case HATCH_INPUT:
case HATCH_OUTPUT:
return new TileGreenhouseHatch();
case BUTTERFLY_HATCH:
return new TileGreenhouseHatch();
default:
return new TileGreenhousePlain();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ public enum BlockGreenhouseType {
DRYER(true, true),
CONTROL(true),
SPRINKLER(false, true),
DOOR;
DOOR,
BUTTERFLY_HATCH(true);

public static final BlockGreenhouseType[] VALUES = values();

Expand All @@ -57,7 +58,7 @@ public enum BlockGreenhouseType {
private static EnumMap<BlockGreenhouseSprites, TextureAtlasSprite> sprites;

private static enum BlockGreenhouseSprites{
PLAIN, GLASS, GEARS("gears"), VALVE("valve"), FAN_OFF("fan.off"), FAN_ON("fan.on"), HEATER_OFF("heater.off"), HEATER_ON("heater.on"), DRYER("dryer"), CONTROL("control"), HATCH_DEFAULT("hatch"), HATCH_INPUT("hatch_input"), HATCH_OUTPUT("hatch_output");
PLAIN, GLASS, GEARS("gears"), VALVE("valve"), FAN_OFF("fan.off"), FAN_ON("fan.on"), HEATER_OFF("heater.off"), HEATER_ON("heater.on"), DRYER("dryer"), CONTROL("control"), HATCH_DEFAULT("hatch"), HATCH_INPUT("hatch_input"), HATCH_OUTPUT("hatch_output"), BUTTERFLY_HATCH("butterfly_hatch");

public static final BlockGreenhouseSprites[] VALUES = values();

Expand Down Expand Up @@ -135,6 +136,11 @@ public static TextureAtlasSprite getSprite(BlockGreenhouseType type, EnumFacing
return sprites.get(BlockGreenhouseSprites.HATCH_INPUT);
}
return null;
case BUTTERFLY_HATCH:
if(facing == EnumFacing.DOWN || facing == EnumFacing.UP){
return null;
}
return sprites.get(BlockGreenhouseSprites.BUTTERFLY_HATCH);
default:
return Minecraft.getMinecraft().getTextureMapBlocks().getMissingSprite();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*******************************************************************************
* 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.gui;

import net.minecraft.entity.player.InventoryPlayer;
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> {

public ContainerGreenhouseButterflyHatch(InventoryPlayer playerInventory, TileGreenhouseButterflyHatch tile) {
super(tile, playerInventory, 8, 84);

addSlotToContainer(new SlotOutput(tile, 0, 60, 40));
addSlotToContainer(new SlotOutput(tile, 1, 80, 27));
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);
sendPacketToCrafters(packet);
}

public IFluidTank getTank(int slot) {
return tile.getMultiblockLogic().getController().getTankManager().getTank(slot);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*******************************************************************************
* 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.gui;

import net.minecraft.entity.player.EntityPlayer;
import forestry.core.config.Constants;
import forestry.core.gui.GuiForestryTitled;
import forestry.core.gui.ledgers.ClimateLedger;
import forestry.greenhouse.gui.widgets.WidgetCamouflageSlot;
import forestry.greenhouse.multiblock.IGreenhouseControllerInternal;
import forestry.greenhouse.tiles.TileGreenhouseButterflyHatch;

public class GuiGreenhouseButterflyHatch extends GuiForestryTitled<ContainerGreenhouseButterflyHatch, TileGreenhouseButterflyHatch> {

public GuiGreenhouseButterflyHatch(EntityPlayer player, TileGreenhouseButterflyHatch tile) {
super(Constants.TEXTURE_PATH_GUI + "/greenhouse_butterfly_hatch.png", new ContainerGreenhouseButterflyHatch(player.inventory, tile), tile);

//Add the tile camouflage slots
widgetManager.add(new WidgetCamouflageSlot(widgetManager, 8, 17, inventory, tile.getCamouflageType()));
}

@Override
protected void addLedgers() {
IGreenhouseControllerInternal greenhouseController = inventory.getMultiblockLogic().getController();

ledgerManager.add(new ClimateLedger(ledgerManager, greenhouseController));
super.addLedgers();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.greenhouse.multiblock;
package forestry.greenhouse.inventory;

import forestry.core.fluids.FluidHelper;
import forestry.core.fluids.TankManager;
import forestry.core.inventory.InventoryAdapterRestricted;
import forestry.greenhouse.multiblock.GreenhouseController;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.Fluid;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*******************************************************************************
* 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.inventory;

import forestry.core.inventory.InventoryAdapterTile;
import forestry.greenhouse.tiles.TileGreenhouseButterflyHatch;

public class InventoryGreenhouseButterflyHatch extends InventoryAdapterTile<TileGreenhouseButterflyHatch> {

public static final int SLOTS = 4;

public InventoryGreenhouseButterflyHatch(TileGreenhouseButterflyHatch tile) {
super(tile, SLOTS, "Items");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ private void bakeBlockModel(@Nonnull BlockGreenhouse block, @Nullable IBlockAcce
BlockModelShapes modelShapes = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes();

baker.addBakedModel(modelShapes.getModelForState(Block.getBlockFromItem(camouflageStack.getItem()).getStateFromMeta(camouflageStack.getItemDamage())));
baker.setParticleSprite(modelShapes.getModelForState(Block.getBlockFromItem(camouflageStack.getItem()).getStateFromMeta(camouflageStack.getItemDamage())).getParticleTexture());
}

//Bake the default blocks
Expand Down
Loading

0 comments on commit cf23644

Please sign in to comment.