mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-20 20:12:19 +00:00
Add missing code
This commit is contained in:
1 parent
aa21b31392
commit
46bb2cdccd
3 files changed
+40
-6
No files matched your search
@@ -1,3 +1,13 @@
|
||||
/*******************************************************************************
|
||||
* 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.models;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@@ -119,6 +119,31 @@ public class GeneticsUtil {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static IButterflyNursery getOrCreateNursery(World world, BlockPos pos, EntityPlayer player) {
|
||||
IButterflyNursery nursery = getNursery(world, pos);
|
||||
|
||||
if (nursery == null) {
|
||||
IIndividual pollen = GeneticsUtil.getPollen(world, pos);
|
||||
|
||||
if (pollen != null && pollen instanceof ITree) {
|
||||
ITree treeLeave = (ITree) pollen;
|
||||
if (treeLeave.setLeaves(world, player.getGameProfile(), pos)) {
|
||||
nursery = getNursery(world, pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
return nursery;
|
||||
}
|
||||
|
||||
public static IButterflyNursery getNursery(World world, BlockPos pos) {
|
||||
TileEntity tileEntity = world.getTileEntity(pos);
|
||||
|
||||
if (tileEntity instanceof IButterflyNursery) {
|
||||
return (IButterflyNursery) tileEntity;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets pollen from a location. Does not affect the pollen source.
|
||||
|
||||
@@ -226,16 +226,16 @@ public class ItemButterflyGE extends ItemGE implements ISpriteRegister, IColored
|
||||
} else {
|
||||
yShift = 0;
|
||||
}
|
||||
BlockPos posS = pos.add(0, -yShift, 0);
|
||||
BlockPos posDown = pos.add(0, -yShift, 0);
|
||||
|
||||
IButterflyNursery nursery = GeneticsUtil.getOrCreateNursery(world, pos, player);
|
||||
IButterflyNursery nursery = GeneticsUtil.getOrCreateNursery(world, posDown, player);
|
||||
if (nursery != null) {
|
||||
if (nursery.canNurse(flutter)) {
|
||||
nursery.setCaterpillar(flutter);
|
||||
if (ButterflyManager.butterflyRoot.plantCocoon(world, nursery, player.getGameProfile(), age)) {
|
||||
PacketFXSignal packet = new PacketFXSignal(PacketFXSignal.SoundFXType.BLOCK_PLACE, pos,
|
||||
world.getBlockState(posS));
|
||||
Proxies.net.sendNetworkPacket(packet, pos, world);
|
||||
PacketFXSignal packet = new PacketFXSignal(PacketFXSignal.SoundFXType.BLOCK_PLACE, posDown,
|
||||
world.getBlockState(posDown));
|
||||
Proxies.net.sendNetworkPacket(packet, posDown, world);
|
||||
|
||||
if (!player.capabilities.isCreativeMode) {
|
||||
stack.shrink(1);
|
||||
@@ -250,7 +250,6 @@ public class ItemButterflyGE extends ItemGE implements ISpriteRegister, IColored
|
||||
}
|
||||
return EnumActionResult.PASS;
|
||||
} else if (type == EnumFlutterType.CATERPILLAR) {
|
||||
|
||||
IButterflyNursery nursery = GeneticsUtil.getOrCreateNursery(world, pos, player);
|
||||
if (nursery != null) {
|
||||
if (!nursery.canNurse(flutter)) {
|
||||
|
||||
Reference in new issue
Block a user