mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-20 04:09:40 +00:00
104 lines
3.2 KiB
Java
104 lines
3.2 KiB
Java
/**
|
|
* This class was created by <Vazkii>. It's distributed as
|
|
* part of the Botania Mod. Get the Source Code in github:
|
|
* https://github.com/Vazkii/Botania
|
|
*
|
|
* Botania is Open Source and distributed under the
|
|
* Botania License: http://botaniamod.net/license.php
|
|
*
|
|
* File Created @ [Jan 26, 2015, 6:08:29 PM (GMT)]
|
|
*/
|
|
package vazkii.botania.common.block;
|
|
|
|
import java.util.Random;
|
|
|
|
import net.minecraft.block.material.Material;
|
|
import net.minecraft.client.renderer.texture.IIconRegister;
|
|
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
import net.minecraft.init.Blocks;
|
|
import net.minecraft.item.Item;
|
|
import net.minecraft.item.ItemStack;
|
|
import net.minecraft.util.IIcon;
|
|
import net.minecraft.world.IBlockAccess;
|
|
import net.minecraft.world.World;
|
|
import net.minecraftforge.client.event.TextureStitchEvent;
|
|
import net.minecraftforge.common.EnumPlantType;
|
|
import net.minecraftforge.common.IPlantable;
|
|
import net.minecraftforge.common.MinecraftForge;
|
|
import net.minecraftforge.common.util.ForgeDirection;
|
|
import vazkii.botania.api.lexicon.ILexiconable;
|
|
import vazkii.botania.api.lexicon.LexiconEntry;
|
|
import vazkii.botania.client.render.block.InterpolatedIcon;
|
|
import vazkii.botania.common.lexicon.LexiconData;
|
|
import vazkii.botania.common.lib.LibBlockNames;
|
|
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
|
import cpw.mods.fml.relauncher.Side;
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
|
|
|
public class BlockEnchantedSoil extends BlockMod implements ILexiconable {
|
|
|
|
IIcon iconSide;
|
|
|
|
public BlockEnchantedSoil() {
|
|
super(Material.grass);
|
|
setHardness(0.6F);
|
|
setStepSound(soundTypeGrass);
|
|
setBlockName(LibBlockNames.ENCHANTED_SOIL);
|
|
MinecraftForge.EVENT_BUS.register(new EventHandler());
|
|
}
|
|
|
|
@Override
|
|
boolean registerInCreative() {
|
|
return false;
|
|
}
|
|
|
|
@Override
|
|
@SideOnly(Side.CLIENT)
|
|
public void registerBlockIcons(IIconRegister par1IconRegister) {
|
|
// NO-OP
|
|
}
|
|
|
|
@Override
|
|
@SideOnly(Side.CLIENT)
|
|
public IIcon getIcon(int side, int meta) {
|
|
return side == 0 ? Blocks.dirt.getIcon(0, 0) : side == 1 ? blockIcon : iconSide;
|
|
}
|
|
|
|
@Override
|
|
public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) {
|
|
return Blocks.dirt.getItemDropped(0, p_149650_2_, p_149650_3_);
|
|
}
|
|
|
|
@Override
|
|
public boolean canSustainPlant(IBlockAccess world, int x, int y, int z, ForgeDirection direction, IPlantable plantable) {
|
|
return plantable.getPlantType(world, x, y - 1, z) == EnumPlantType.Plains;
|
|
}
|
|
|
|
@Override
|
|
protected boolean canSilkHarvest() {
|
|
return false;
|
|
}
|
|
|
|
@Override
|
|
public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) {
|
|
return LexiconData.overgrowthSeed;
|
|
}
|
|
|
|
public class EventHandler{
|
|
@SubscribeEvent
|
|
@SideOnly(Side.CLIENT)
|
|
public void loadTextures(TextureStitchEvent.Pre event) {
|
|
if(event.map.getTextureType() == 0) {
|
|
TextureAtlasSprite icon = new InterpolatedIcon("botania:enchantedSoil0");
|
|
if(event.map.setTextureEntry("botania:enchantedSoil0", icon))
|
|
blockIcon = icon;
|
|
|
|
icon = new InterpolatedIcon("botania:enchantedSoil1");
|
|
if(event.map.setTextureEntry("botania:enchantedSoil1", icon))
|
|
iconSide = icon;
|
|
}
|
|
}
|
|
}
|
|
}
|