Fixed #827 by adding EnderIO custom planter for infused seeds

This commit is contained in:
nekosune committed 2016-02-03 12:10:41 +00:00
1 parent 81d9fe3d97
commit f3a167dc8a
7 files changed
+139 -19

No files matched your search

@@ -115,6 +115,13 @@ public class BlockInfusedGrain extends BlockCrops implements ITTinkererBlock {
@Override
public void breakBlock(World world, int x, int y, int z, Block block, int metadata) {
super.breakBlock(world, x, y, z, block, metadata);
}
@Override
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) {
ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
Random rand = new Random();
@@ -137,23 +144,7 @@ public class BlockInfusedGrain extends BlockCrops implements ITTinkererBlock {
} while (world.rand.nextInt(75) < getPrimalTendencyCount(world, x, y, z, Aspect.ORDER));
}
for (ItemStack item : ret) {
float f = 0.7F;
double d0 = (double) (rand.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
double d1 = (double) (rand.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
double d2 = (double) (rand.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
EntityItem entityitem = new EntityItem(world, (double) x + d0, (double) y + d1, (double) z + d2, item);
entityitem.delayBeforeCanPickup = 10;
world.spawnEntityInWorld(entityitem);
}
super.breakBlock(world, x, y, z, block, metadata);
}
@Override
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) {
return new ArrayList<ItemStack>();
return ret;
}
public int getPrimalTendencyCount(World world, int x, int y, int z, Aspect aspect) {
@@ -173,6 +164,7 @@ public class BlockInfusedGrain extends BlockCrops implements ITTinkererBlock {
}
}
public void updateTick(World world, int x, int y, int z, Random rand) {
//Prevent normal growth from occuring
//Growth takes place in the tile entity
@@ -45,7 +45,14 @@ public class TileInfusedGrain extends TileEntity implements IAspectContainer {
}
}
}
if(aspect==null) {
aspect = Aspect.AIR;
}
if(primalTendencies==null)
{
primalTendencies=new AspectList();
primalTendencies.merge(aspect,1);
}
//Aspect Exchange
if (worldObj.rand.nextInt((2550 - ((int) Math.pow(primalTendencies.getAmount(Aspect.AIR), 2))) * 10) == 0 && !aspect.isPrimal()) {
@@ -0,0 +1,16 @@
package thaumic.tinkerer.common.compat;
import crazypants.enderio.machine.farm.FarmersRegistry;
import crazypants.enderio.machine.farm.farmers.FarmersCommune;
import thaumic.tinkerer.common.lib.LibMisc;
/**
* Created by katsw on 02/02/2016.
*/
public class EnderIO {
public static void registerPlanters()
{
FarmersCommune.joinCommune(new InfusedSeedsPlanter());
}
}
@@ -0,0 +1,67 @@
package thaumic.tinkerer.common.compat;
import com.enderio.core.common.compat.ICompat;
import com.enderio.core.common.util.BlockCoord;
import crazypants.enderio.machine.farm.TileFarmStation;
import crazypants.enderio.machine.farm.farmers.IHarvestResult;
import crazypants.enderio.machine.farm.farmers.PlantableFarmer;
import net.minecraft.block.Block;
import net.minecraft.block.BlockFarmland;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.common.IPlantable;
import net.minecraftforge.common.util.ForgeDirection;
import thaumic.tinkerer.common.ThaumicTinkerer;
import thaumic.tinkerer.common.block.BlockInfusedFarmland;
import thaumic.tinkerer.common.block.BlockInfusedGrain;
import thaumic.tinkerer.common.block.tile.TileInfusedGrain;
import thaumic.tinkerer.common.item.ItemInfusedSeeds;
/**
* Created by katsw on 02/02/2016.
*/
public class InfusedSeedsPlanter extends PlantableFarmer implements ICompat{
@Override
public boolean canPlant(ItemStack stack) {
return stack.getItem()==ThaumicTinkerer.registry.getFirstItemFromClass(ItemInfusedSeeds.class);
}
@Override
protected boolean canPlant(World worldObj, BlockCoord bc, IPlantable plantable) {
return super.canPlant(worldObj, bc, plantable) || worldObj.getBlock(bc.x,bc.y-1,bc.z)==ThaumicTinkerer.registry.getFirstBlockFromClass(BlockInfusedFarmland.class);
}
@Override
public IHarvestResult harvestBlock(TileFarmStation farm, BlockCoord bc, Block block, int meta) {
return super.harvestBlock(farm, bc, block, meta);
}
@Override
public boolean prepareBlock(TileFarmStation farm, BlockCoord bc, Block block, int meta) {
boolean ready= super.prepareBlock(farm, bc, block, meta);
return ready;
}
@Override
protected boolean plant(TileFarmStation farm, World worldObj, BlockCoord bc, IPlantable plantable) {
ItemStack seeds=farm.getSeedTypeInSuppliesFor(bc);
if(seeds!=null) {
if (farm.getBlock(bc.getLocation(ForgeDirection.DOWN)) instanceof BlockFarmland) {
BlockCoord soil = bc.getLocation(ForgeDirection.DOWN);
farm.getWorldObj().setBlock(soil.x, soil.y, soil.z, ThaumicTinkerer.registry.getFirstBlockFromClass(BlockInfusedFarmland.class));
}
}
super.plant(farm, worldObj, bc, plantable);
if(seeds!=null) {
BlockInfusedGrain.setAspect(farm.getWorldObj(), bc.x, bc.y, bc.z, ItemInfusedSeeds.getAspect(seeds));
((TileInfusedGrain) farm.getWorldObj().getTileEntity(bc.x, bc.y, bc.z)).primalTendencies = ItemInfusedSeeds.getAspectTendencies(seeds);
}
return true;
}
}
@@ -1,8 +1,15 @@
package thaumic.tinkerer.common.core.helper;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import net.minecraft.block.IGrowable;
import net.minecraftforge.event.entity.player.BonemealEvent;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import thaumcraft.common.Thaumcraft;
import thaumcraft.common.blocks.BlockCustomPlant;
import thaumcraft.common.config.ConfigItems;
import thaumcraft.common.items.equipment.ItemElementalHoe;
import thaumic.tinkerer.common.block.BlockInfusedGrain;
import thaumic.tinkerer.common.block.tile.TileInfusedGrain;
import thaumic.tinkerer.common.core.handler.ConfigHandler;
/**
@@ -20,5 +27,24 @@ public class BonemealEventHandler {
}
}
}
@SubscribeEvent
public void onPlayerInteract(PlayerInteractEvent event) {
if (event.world.getBlock(event.x, event.y, event.z) instanceof BlockInfusedGrain) {
if (event.entityPlayer.getCurrentEquippedItem().getItem() == ConfigItems.itemHoeElemental) {
IGrowable igrowable = (IGrowable) event.world.getBlock(event.x, event.y, event.z);
if (igrowable.func_149851_a(event.world, event.x, event.y, event.z, event.world.isRemote)) {
if (!event.world.isRemote) {
if (igrowable.func_149852_a(event.world, event.world.rand, event.x, event.y, event.z)) {
igrowable.func_149853_b(event.world, event.world.rand, event.x, event.y, event.z);
}
}
}
event.entityPlayer.getCurrentEquippedItem().damageItem(25, event.entityPlayer);
Thaumcraft.proxy.blockSparkle(event.world, event.x, event.y, event.z, 0, 2);
}
}
}
}
@@ -33,6 +33,7 @@ import net.minecraft.util.EnumChatFormatting;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.EnumHelper;
import net.minecraftforge.event.world.ChunkDataEvent;
import thaumcraft.api.aspects.IEssentiaTransport;
import thaumcraft.api.wands.WandCap;
import thaumcraft.api.wands.WandRod;
@@ -41,6 +42,7 @@ import thaumic.tinkerer.common.ThaumicTinkerer;
import thaumic.tinkerer.common.block.tile.TileFunnel;
import thaumic.tinkerer.common.block.tile.TileRepairer;
import thaumic.tinkerer.common.block.tile.transvector.TileTransvectorInterface;
import thaumic.tinkerer.common.compat.EnderIO;
import thaumic.tinkerer.common.compat.FumeTool;
import thaumic.tinkerer.common.core.handler.ConfigHandler;
import thaumic.tinkerer.common.core.handler.ModCreativeTab;
@@ -119,6 +121,10 @@ public class TTCommonProxy {
if (Loader.isModLoaded("OpenComputers")) {
initOpenCDrivers();
}
if(Loader.isModLoaded("EnderIO"))
{
InitEnderIO();
}
if (Loader.isModLoaded("ForgeMultipart")) {
ThaumicTinkerer.log.trace("Attempting to load Multiparts");
@@ -160,6 +166,12 @@ public class TTCommonProxy {
AspectCropLootManager.populateLootMap();
ItemFocusDeflect.setupBlackList();
}
@Optional.Method(modid = "EnderIO")
protected void InitEnderIO()
{
EnderIO.registerPlanters();
}
@Optional.Method(modid = "ComputerCraft")
protected void initCCPeripherals() {
PeripheralHandler handler = new PeripheralHandler();
@@ -41,7 +41,7 @@ public class ItemInfusedSeeds extends ItemSeeds implements ITTinkererItem {
private static final String NBT_ASPEPCT_TENDENCIES = "aspectTendencies";
private IIcon[] icons;
public ItemInfusedSeeds() {
super(Blocks.wheat, Blocks.farmland);
super(ThaumicTinkerer.registry.getFirstBlockFromClass(BlockInfusedGrain.class), Blocks.farmland);
}
public static Aspect getAspect(ItemStack stack) {