use of net.minecraft.block.Block in project PneumaticCraft by MineMaarten.
the class BlockEnderPlant method executeFullGrownEffect.
@Override
public void executeFullGrownEffect(World world, int x, int y, int z, Random rand) {
if (!world.isRemote) {
for (int i = 0; i < 50; i++) {
int randX = x + rand.nextInt(30) - 15;
int randY = y + rand.nextInt(8);
int randZ = z + rand.nextInt(30) - 15;
Block block = world.getBlock(randX, randY, randZ);
if (!block.getMaterial().blocksMovement()) {
ItemStack seed = new ItemStack(Itemss.plasticPlant, 1, ItemPlasticPlants.ENDER_PLANT_DAMAGE);
EntityItem plant = new EntityItem(world, randX + 0.5D, randY + 0.5D, randZ + 0.5D, seed);
// plant.motionX = plant.motionY = plant.motionZ = 0;
plant.lifespan = 300;
ItemPlasticPlants.markInactive(plant);
world.spawnEntityInWorld(plant);
plant.playSound("mob.endermen.portal", 0.2F, ((rand.nextFloat() - rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
short short1 = 128;
for (int j = 0; j < short1; ++j) {
double d6 = j / (short1 - 1.0D);
float f = (rand.nextFloat() - 0.5F) * 0.2F;
float f1 = (rand.nextFloat() - 0.5F) * 0.2F;
float f2 = (rand.nextFloat() - 0.5F) * 0.2F;
double d7 = x + 0.5D + (plant.posX - (x + 0.5D)) * d6 + (rand.nextDouble() - 0.5D);
double d8 = y + 0.5D + (plant.posY - (y + 0.5D)) * d6 + rand.nextDouble();
double d9 = z + 0.5D + (plant.posZ - (z + 0.5D)) * d6 + (rand.nextDouble() - 0.5D);
NetworkHandler.sendToAllAround(new PacketSpawnParticle("portal", d7, d8, d9, f, f1, f2), world);
}
world.setBlockMetadataWithNotify(x, y, z, world.getBlockMetadata(x, y, z) - 2, 3);
break;
}
}
}
}
use of net.minecraft.block.Block in project PneumaticCraft by MineMaarten.
the class ItemPlasticPlants method getBlockToSeedMap.
public static Map<Block, ItemStack> getBlockToSeedMap() {
Map<Block, ItemStack> blockToSeedMap = new HashMap<Block, ItemStack>();
List<ItemStack> seeds = new ArrayList<ItemStack>();
((ItemPlasticPlants) Itemss.plasticPlant).addSubItems(seeds);
for (ItemStack seed : seeds) {
blockToSeedMap.put(getPlantBlockIDFromSeed(seed.getItemDamage()), seed);
}
return blockToSeedMap;
}
use of net.minecraft.block.Block in project PneumaticCraft by MineMaarten.
the class ItemPlasticPlants method onEntityItemUpdate.
@Override
public boolean onEntityItemUpdate(EntityItem entityItem) {
MotionProperties motProps = (MotionProperties) entityItem.getExtendedProperties("plasticPlant");
double oldMotionX = entityItem.motionX;
double oldMotionY = entityItem.motionY;
double oldMotionZ = entityItem.motionZ;
if (motProps != null) {
oldMotionX = motProps.oldMotionX;
oldMotionY = motProps.oldMotionY;
oldMotionZ = motProps.oldMotionZ;
}
ItemStack stack = entityItem.getEntityItem();
int itemDamage = stack.getItemDamage();
if (motProps == null && (itemDamage % 16 == ItemPlasticPlants.PROPULSION_PLANT_DAMAGE || itemDamage % 16 == ItemPlasticPlants.REPULSION_PLANT_DAMAGE)) {
motProps = new MotionProperties();
entityItem.registerExtendedProperties("plasticPlant", motProps);
}
if (motProps != null)
motProps.update(entityItem);
boolean isDelayOver = isActive(entityItem) || entityItem.age > 60 && entityItem.delayBeforeCanPickup == 0;
if (entityItem.onGround || Math.abs(entityItem.motionY) < 0.13D && (itemDamage % 16 == ItemPlasticPlants.HELIUM_PLANT_DAMAGE || itemDamage % 16 == ItemPlasticPlants.SQUID_PLANT_DAMAGE)) {
if (!handleRepulsionBehaviour(entityItem, oldMotionX, oldMotionY, oldMotionZ))
return false;
if (!handlePropulsionBehaviour(entityItem, oldMotionX, oldMotionZ))
return false;
if (!entityItem.worldObj.isRemote) {
Block blockID = getPlantBlockIDFromSeed(itemDamage % 16);
// - 0.5F);
int landedBlockX = (int) Math.floor(entityItem.posX);
int landedBlockY = (int) Math.floor(entityItem.posY);
// - 0.5F);
int landedBlockZ = (int) Math.floor(entityItem.posZ);
boolean canSustain = false;
canSustain = ((BlockPneumaticPlantBase) blockID).canBlockStay(entityItem.worldObj, landedBlockX, landedBlockY, landedBlockZ);
if (itemDamage % 16 == ItemPlasticPlants.FIRE_FLOWER_DAMAGE && !canSustain && !isInChamber(entityItem.worldObj.getBlock(landedBlockX, landedBlockY - 1, landedBlockZ)) && net.minecraft.init.Blocks.fire.canPlaceBlockAt(entityItem.worldObj, landedBlockX, landedBlockY, landedBlockZ) && entityItem.worldObj.isAirBlock(landedBlockX, landedBlockY, landedBlockZ)) {
entityItem.worldObj.setBlock(landedBlockX, landedBlockY, landedBlockZ, net.minecraft.init.Blocks.fire);
}
if (canSustain && isDelayOver) {
if (entityItem.worldObj.isAirBlock(landedBlockX, landedBlockY, landedBlockZ)) {
entityItem.worldObj.setBlock(landedBlockX, landedBlockY, landedBlockZ, blockID, itemDamage > 15 || !isActive(entityItem) ? 0 : 7, 3);
entityItem.playSound("mob.chicken.plop", 1.0F, (rand.nextFloat() - rand.nextFloat()) * 0.2F + 1.0F);
for (int i = 0; i < 10; i++) {
spawnParticle(entityItem.worldObj, "explode", entityItem.posX + rand.nextDouble() - 0.5D, entityItem.posY + rand.nextDouble() - 0.5D, entityItem.posZ + rand.nextDouble() - 0.5D, 0.0D, 0.0D, 0.0D);
}
if (stack.stackSize == 1) {
entityItem.setDead();
} else {
stack.stackSize--;
}
}
}
}
}
// dirt, and the block above it is air, if yes, then plant it.
if (itemDamage % 16 == ItemPlasticPlants.SQUID_PLANT_DAMAGE && entityItem.worldObj.isMaterialInBB(entityItem.boundingBox.contract(0.003D, 0.003D, 0.003D), Material.water)) {
entityItem.motionY += 0.06D;
}
if (itemDamage % 16 == ItemPlasticPlants.HELIUM_PLANT_DAMAGE) {
entityItem.motionY += 0.08D;
}
if (itemDamage % 16 == ItemPlasticPlants.FLYING_FLOWER_DAMAGE) {
entityItem.motionY += 0.04D;
if (entityItem.age % 60 == 0) {
entityItem.motionX += (rand.nextDouble() - 0.5D) * 0.1D;
entityItem.motionY += (rand.nextDouble() - 0.6D) * 0.1D;
entityItem.motionZ += (rand.nextDouble() - 0.5D) * 0.1D;
}
}
return false;
}
use of net.minecraft.block.Block in project PneumaticCraft by MineMaarten.
the class Forestry method preInit.
@Override
public void preInit() {
plasticElectronTube = new ItemPlasticElectronTube("plasticElectronTube");
Itemss.registerItem(plasticElectronTube);
Collection col = Farmables.farmables.get("farmVegetables");
// if(col != null) {
ICircuitLayout layoutManaged = ChipsetManager.circuitRegistry.getLayout("forestry.farms.managed");
try {
Field field = ReflectionHelper.findField(Class.forName("forestry.farming.gadgets.StructureLogicFarm"), "bricks");
farmStructureBlocks = (HashSet<Block>) field.get(null);
} catch (Throwable e) {
Log.warning("Failed on getting Forestry's farm blocks, using defaults");
farmStructureBlocks = new HashSet<Block>();
farmStructureBlocks.add(Blocks.brick_block);
farmStructureBlocks.add(Blocks.stonebrick);
farmStructureBlocks.add(Blocks.sandstone);
farmStructureBlocks.add(Blocks.nether_brick);
farmStructureBlocks.add(Blocks.quartz_block);
}
try {
Constructor c = Class.forName("forestry.farming.circuits.CircuitFarmLogic").getConstructor(String.class, Class.class);
for (ItemStack stack : ((ItemPlasticElectronTube) plasticElectronTube).getSubItems()) {
int meta = stack.getItemDamage();
if (logics[meta] != null) {
ChipsetManager.solderManager.addRecipe(layoutManaged, new ItemStack(plasticElectronTube, 1, meta), (ICircuit) c.newInstance("plasticPlant" + meta, logics[meta]));
}
}
} catch (Throwable e) {
Log.error("Something happened when trying to register forestry farm logic");
e.printStackTrace();
}
/* } else {
Log.info("Forestry was found, but the 'farmVegetables' farmable wasn't. Is this forestry plugin loaded?");
}*/
}
use of net.minecraft.block.Block in project PneumaticCraft by MineMaarten.
the class MFR method preInit.
@Override
public void preInit() {
try {
for (Block block : ItemPlasticPlants.getBlockToSeedMap().keySet()) {
register("registerHarvestable", IFactoryHarvestable.class, new PlasticHarvester(block));
register("registerFertilizable", IFactoryFertilizable.class, new PlasticFertilizer(block));
}
register("registerPlantable", IFactoryPlantable.class, new PlasticPlanter());
} catch (Throwable e) {
e.printStackTrace();
}
}
Aggregations