mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-20 12:09:39 +00:00
Improve cocoons
This commit is contained in:
1 parent
46bb2cdccd
commit
fdd6d75d0e
4 files changed
+17
-14
No files matched your search
@@ -14,6 +14,7 @@ import forestry.api.genetics.ISpeciesRoot;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface IButterflyRoot extends ISpeciesRoot {
|
||||
@@ -52,7 +53,7 @@ public interface IButterflyRoot extends ISpeciesRoot {
|
||||
*/
|
||||
EntityLiving spawnButterflyInWorld(World world, IButterfly butterfly, double x, double y, double z);
|
||||
|
||||
boolean plantCocoon(World world, IButterflyNursery nursery, GameProfile owner, int age);
|
||||
BlockPos plantCocoon(World world, IButterflyNursery nursery, GameProfile owner, int age);
|
||||
|
||||
/**
|
||||
* @return true if passed item is mated.
|
||||
|
||||
@@ -139,7 +139,8 @@ public class WoodTextureManager {
|
||||
WoodTexture tex = getTexture(woodType);
|
||||
Map<String, String> locations = new HashMap<>();
|
||||
if (kindTexture != null && kindTexture instanceof SimpleTexture) {
|
||||
locations.putAll(((SimpleTexture) kindTexture).locations);
|
||||
SimpleTexture texture = (SimpleTexture) kindTexture;
|
||||
locations.putAll(texture.getLocations(kindName));
|
||||
}
|
||||
if (tex != null) {
|
||||
locations.putAll(tex.getLocations(kindName));
|
||||
|
||||
@@ -181,9 +181,9 @@ public class ButterflyRoot extends SpeciesRoot implements IButterflyRoot {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean plantCocoon(World world, IButterflyNursery nursery, GameProfile owner, int age) {
|
||||
public BlockPos plantCocoon(World world, IButterflyNursery nursery, GameProfile owner, int age) {
|
||||
if (nursery.getCaterpillar() == null) {
|
||||
return false;
|
||||
return BlockPos.ORIGIN;
|
||||
}
|
||||
|
||||
BlockRegistryLepidopterology blocks = PluginLepidopterology.getBlocks();
|
||||
@@ -192,18 +192,18 @@ public class ButterflyRoot extends SpeciesRoot implements IButterflyRoot {
|
||||
IBlockState state = blocks.cocoon.getDefaultState();
|
||||
boolean placed = world.setBlockState(pos, state);
|
||||
if (!placed) {
|
||||
return false;
|
||||
return BlockPos.ORIGIN;
|
||||
}
|
||||
|
||||
Block block = world.getBlockState(pos).getBlock();
|
||||
if (blocks.cocoon != block) {
|
||||
return false;
|
||||
return BlockPos.ORIGIN;
|
||||
}
|
||||
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
if (!(tile instanceof TileCocoon)) {
|
||||
world.setBlockToAir(pos);
|
||||
return false;
|
||||
return BlockPos.ORIGIN;
|
||||
}
|
||||
|
||||
TileCocoon cocoon = (TileCocoon) tile;
|
||||
@@ -212,7 +212,7 @@ public class ButterflyRoot extends SpeciesRoot implements IButterflyRoot {
|
||||
cocoon.setNursery(nursery);
|
||||
cocoon.setAge(age);
|
||||
|
||||
return true;
|
||||
return pos;
|
||||
}
|
||||
|
||||
private BlockPos getNextPos(World world, BlockPos pos) {
|
||||
|
||||
@@ -14,7 +14,6 @@ import javax.annotation.Nullable;
|
||||
import java.util.Random;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import forestry.api.arboriculture.ITree;
|
||||
import forestry.api.core.IModelManager;
|
||||
import forestry.api.core.ISpriteRegister;
|
||||
import forestry.api.core.ITextureManager;
|
||||
@@ -228,14 +227,16 @@ public class ItemButterflyGE extends ItemGE implements ISpriteRegister, IColored
|
||||
}
|
||||
BlockPos posDown = pos.add(0, -yShift, 0);
|
||||
|
||||
IButterflyNursery nursery = GeneticsUtil.getOrCreateNursery(world, posDown, player);
|
||||
IButterflyNursery nursery = GeneticsUtil.getOrCreateNursery(world, pos, 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, posDown,
|
||||
world.getBlockState(posDown));
|
||||
Proxies.net.sendNetworkPacket(packet, posDown, world);
|
||||
|
||||
pos = ButterflyManager.butterflyRoot.plantCocoon(world, nursery, player.getGameProfile(), age);
|
||||
if (pos != BlockPos.ORIGIN) {
|
||||
PacketFXSignal packet = new PacketFXSignal(PacketFXSignal.SoundFXType.BLOCK_PLACE, pos,
|
||||
world.getBlockState(pos));
|
||||
Proxies.net.sendNetworkPacket(packet, pos, world);
|
||||
|
||||
if (!player.capabilities.isCreativeMode) {
|
||||
stack.shrink(1);
|
||||
|
||||
Reference in new issue
Block a user