Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package LivingSponge.common;
- import java.io.*;
- import java.nio.charset.Charset;
- import java.lang.reflect.*;
- import cpw.mods.fml.common.Mod;
- import cpw.mods.fml.common.Mod.Init;
- import cpw.mods.fml.common.event.FMLInitializationEvent;
- import cpw.mods.fml.common.network.IGuiHandler;
- import cpw.mods.fml.common.network.NetworkMod;
- import cpw.mods.fml.common.network.NetworkRegistry;
- import cpw.mods.fml.common.registry.GameRegistry;
- import cpw.mods.fml.common.registry.LanguageRegistry;
- import java.util.*;
- import java.util.Map.*;
- import net.minecraft.potion.Potion;
- import net.minecraft.src.*;
- import net.minecraft.world.biome.BiomeGenBase;
- import net.minecraft.world.biome.BiomeGenMushroomIsland;
- import net.minecraft.client.*;
- import net.minecraft.entity.EntityList;
- import net.minecraft.entity.EnumCreatureType;
- import net.minecraft.item.Item;
- import net.minecraft.item.ItemBucketMilk;
- import net.minecraft.item.ItemStack;
- import net.minecraftforge.common.*;
- import net.minecraftforge.oredict.*;
- import cpw.mods.fml.common.*;
- import cpw.mods.fml.common.Mod.*;
- import cpw.mods.fml.common.event.*;
- import cpw.mods.fml.common.network.*;
- import cpw.mods.fml.common.registry.*;
- import cpw.mods.fml.relauncher.*;
- import cpw.mods.fml.common.registry.EntityRegistry;
- @Mod(modid = "Living sponge", name = "Living sponge", version = Main.VERSION)
- @NetworkMod(clientSideRequired = true, serverSideRequired = false)
- public class Main<Entity>
- {
- public static final String VERSION = "1.2";
- @Instance("Living sponge")
- public static Main instance;
- public static Configuration CONFIG;
- public static File LANGFILE_PREFIX;
- public static HashMap<String, Configuration> LANG;
- public static final String TEXTUREFILE = "/LivingSponge/gfx/";
- // Blocks start
- net.minecraft.block.Block blockSmallSponge;
- net.minecraft.block.Block blockSmallWetSponge;
- net.minecraft.block.Block blockWetSponge;
- static net.minecraft.block.Block blockSpongeCake;
- net.minecraft.block.Block blockTinyStar;
- net.minecraft.block.Block blockSpongePortalFrame;
- public static net.minecraft.block.Block blockSpongePortal;
- // Blocks end
- //Items start
- net.minecraft.item.Item itemSpongeMaterial;
- net.minecraft.item.Item itemSpongeCookie;
- net.minecraft.item.Item itemSpongeCake;
- //Items end
- //Entities start
- Entity entitySpongeMonster;
- Entity entityJumpingSpongeMouseHead;
- //Entities end
- //Dimensions start
- public static int SpongeDimension = 3;
- //Dimensions end
- public ModContainer cont;
- private IGuiHandler guiHandlerObject;
- public Main(){}
- @SidedProxy(clientSide = "LivingSponge.common.ClientProxyBS", serverSide = "LivingSponge.common.CommonProxyBS")
- public static CommonProxyBS proxy;
- @PreInit
- public void preInit(FMLPreInitializationEvent event) throws IOException
- {
- instance = this;
- cont = Loader.instance().activeModContainer();
- if(cont.getMod() != this){throw new RuntimeException("Loader activeModContainer isn't current mod container! "+cont.getModId());}
- setMetadata();
- File cfgf = new File(Loader.instance().getConfigDir(),"LivingSponges/SS.cfg");
- if(!cfgf.getParentFile().exists())
- cfgf.getParentFile().mkdirs();
- if(!cfgf.exists())
- cfgf.createNewFile();
- CONFIG = new Configuration(cfgf);
- CONFIG.load();
- LANGFILE_PREFIX = new File(Loader.instance().getConfigDir(),"LivingSponges/lang/");
- if(!LANGFILE_PREFIX.exists())
- LANGFILE_PREFIX.mkdir();
- for(File f : LANGFILE_PREFIX.listFiles(new FilenameFilter() {
- @Override
- public boolean accept(File dir, String name) {
- return name.endsWith(".cfg");
- }
- }))
- {
- String fnm = f.getName(), lang = fnm.trim().substring(0, fnm.length()-4);
- Properties prs = new Properties();
- prs.load(new InputStreamReader(new FileInputStream(f), Charset.forName("UTF8")));
- for(Entry<Object,Object> ent: prs.entrySet())
- {
- String k = (String)ent.getKey(), v = (String)ent.getValue();
- LanguageRegistry.instance().addStringLocalization(k, lang, v);
- }
- }
- loadConfig();
- }
- @Init
- public void init(FMLInitializationEvent event) throws Throwable
- {
- addBlocks();
- addItems();
- addEntities();
- addGen();
- addDimension();
- }
- @PostInit
- public void postInit(FMLPostInitializationEvent event)
- {
- addRecipes();
- addSmelting();
- addEntities();
- addGen();
- addDimension();
- proxy.registerRenderThings();
- }
- public String getVersion() {
- return VERSION;
- }
- protected void setMetadata()
- {
- cont.getMetadata().autogenerated=false;
- cont.getMetadata().authorList.add("Adanos020 [on YouTube: MinecraftAdanos]");
- cont.getMetadata().credits = "";
- cont.getMetadata().description = "Sponges are achieveable now! To get sponges you have to kill sponge monsters! Now you can build a portal and travel to the mysterious Sponge World!";
- }
- protected void loadConfig()
- {
- CONFIG.save();
- }
- protected void addBlocks() throws IllegalArgumentException, IllegalAccessException
- {
- int tid;
- tid = CONFIG.getBlock("Small wet sponge", 1550).getInt();
- blockSmallWetSponge = new BlockSmallWetSponge(1550).setStepSound(net.minecraft.block.Block.soundGrassFootstep).setHardness(0.5F).setResistance(1.0F).setBlockName("Wet small sponge");
- GameRegistry.registerBlock(blockSmallWetSponge);
- LanguageRegistry.addName(blockSmallWetSponge, "Wet small sponge");
- tid = CONFIG.getBlock("Small sponge", 1551).getInt();
- blockSmallSponge = new BlockSmallSponge(1551).setStepSound(net.minecraft.block.Block.soundGrassFootstep).setHardness(0.5F).setResistance(1.0F).setBlockName("Small sponge");
- GameRegistry.registerBlock(blockSmallSponge);
- LanguageRegistry.addName(blockSmallSponge, "Small sponge");
- tid = CONFIG.getBlock("Wet sponge", 1552).getInt();
- blockWetSponge = new BlockWetSponge(1552).setStepSound(net.minecraft.block.Block.soundGrassFootstep).setHardness(0.5F).setResistance(1.0F).setBlockName("Wet sponge");
- GameRegistry.registerBlock(blockWetSponge);
- LanguageRegistry.addName(blockWetSponge, "Wet sponge");
- tid = CONFIG.getBlock("Sponge cake", 1553).getInt();
- blockSpongeCake = new BlockSpongeCake(1553, 48).setStepSound(net.minecraft.block.Block.soundGrassFootstep).setHardness(0.5F).setResistance(1.0F).setBlockName("Sponge cake");
- GameRegistry.registerBlock(blockSpongeCake);
- LanguageRegistry.addName(blockSpongeCake, "Sponge cake");
- tid = CONFIG.getBlock("Sponge portal frame", 1554).getInt();
- blockSpongePortalFrame = new BlockSpongePortalFrame(1554).setStepSound(net.minecraft.block.Block.soundStoneFootstep).setHardness(1F).setResistance(1.0F).setBlockName("Sponge portal frame");
- GameRegistry.registerBlock(blockSpongePortalFrame);
- LanguageRegistry.addName(blockSpongePortalFrame, "Sponge portal frame");
- tid = CONFIG.getBlock("Sponge portal", 1555).getInt();
- blockSpongePortal = new BlockSpongePortal(1555, 1).setBlockName("Sponge portal");
- GameRegistry.registerBlock(blockSpongePortal, "Sponge portal");
- LanguageRegistry.addName(blockSpongePortal, "Sponge portal");
- tid = CONFIG.getBlock("Tiny star", 1556).getInt();
- blockTinyStar = new BlockTinyStar(1556).setStepSound(net.minecraft.block.Block.soundStoneFootstep).setHardness(1F).setResistance(1.0F).setBlockName("Tiny star");
- GameRegistry.registerBlock(blockTinyStar);
- LanguageRegistry.addName(blockTinyStar, "Tiny star");
- CONFIG.save();
- }
- protected void addEntities()
- {
- addEntityName(registerEntity(EntitySpongeMonster.class, "Sponge", ModLoader.getUniqueEntityId(), 0xffff00, 0x000000), "Sponge");
- EntityRegistry.registerModEntity(EntitySpongeMonster.class, "Sponge", 44, this, 40, 1, true);
- EntityRegistry.addSpawn(EntitySpongeMonster.class, 2, 3, 5, EnumCreatureType.ambient, BiomeGenBase.beach, BiomeGenBase.jungle, BiomeGenBase.jungleHills, BiomeGenBase.mushroomIsland, BiomeGenBase.mushroomIslandShore, BiomeGenBase.ocean, BiomeGenBase.river, BiomeGenBase.swampland);
- addEntityName(registerEntity(EntitySpongeMonster.class, "Jumping sponge mouse head", ModLoader.getUniqueEntityId(), 0xffff00, 0xff00aa), "Jumping sponge mouse head");
- EntityRegistry.registerModEntity(EntityJumpingSpongeMouseHead.class, "Jumping sponge mouse head", 45, this, 41, 1, true);
- EntityRegistry.addSpawn(EntitySpongeMonster.class, 2, 3, 5, EnumCreatureType.ambient, BiomeGenBase.beach, BiomeGenBase.desert);
- }
- public static int registerEntity(Class class1, String str1, int i1, int i2, int i3)
- {
- ModLoader.registerEntityID(class1, str1, i1, i2, i3);
- return i1;
- }
- public static void addEntityName(int i1, String str2)
- {
- ModLoader.addLocalization("entity." + EntityList.getStringFromID(i1) + ".name", str2);
- }
- protected void addRecipes()
- {
- GameRegistry.addRecipe(new ItemStack(blockSmallSponge), new Object[]
- {
- "XXX", "XXX", "XXX", 'X', itemSpongeMaterial
- });
- GameRegistry.addRecipe(new ItemStack(net.minecraft.block.Block.sponge, 1), new Object[]
- {
- "XX", "XX", 'X', blockSmallSponge
- });
- GameRegistry.addRecipe(new ItemStack(itemSpongeCake, 1), new Object[]
- {
- "ZAZ", "YBY", "XXX", 'X', blockSmallSponge, 'Z', Item.bucketMilk, 'Y', Item.sugar, 'B', Item.egg, 'A', itemSpongeMaterial
- });
- GameRegistry.addShapelessRecipe(new ItemStack(blockSmallWetSponge), new Object[]
- {
- new ItemStack(Item.bucketWater), new ItemStack(blockSmallSponge)
- });
- GameRegistry.addShapelessRecipe(new ItemStack(blockWetSponge), new Object[]
- {
- new ItemStack(Item.bucketWater), new ItemStack(net.minecraft.block.Block.sponge)
- });
- GameRegistry.addRecipe(new ItemStack(itemSpongeCookie, 1), new Object[]
- {
- "XYX", 'X', itemSpongeMaterial, 'Y', new ItemStack(Item.dyePowder, 1, 3)
- });
- GameRegistry.addRecipe(new ItemStack(blockSpongePortalFrame), new Object[]
- {
- "XYX", "YZY", "XYX", 'X', Item.diamond, 'Y', net.minecraft.block.Block.sponge, 'Z', blockTinyStar
- });
- GameRegistry.addRecipe(new ItemStack(blockTinyStar), new Object[]
- {
- "0X0", "XYX", "0X0", 'X', Item.diamond, 'Y', Item.netherStar
- });
- }
- protected void addItems()
- {
- int tid;
- tid = CONFIG.getItem("Sponge material", 5550).getInt();
- itemSpongeMaterial = new ItemSpongeMaterial(5550).setItemName("Sponge material");
- LanguageRegistry.addName(itemSpongeMaterial, "Sponge material");
- tid = CONFIG.getItem("Sponge cookie", 5551).getInt();
- itemSpongeCookie = new ItemSpongeCookie(5551, 1, true).setItemName("Sponge cookie");
- LanguageRegistry.addName(itemSpongeCookie, "Sponge cookie");
- tid = CONFIG.getItem("Sponge cake", 5552).getInt();
- itemSpongeCake = new ItemSpongeCake(5552, 1, true, blockSpongeCake).setItemName("Sponge cake");
- LanguageRegistry.addName(itemSpongeCake, "Sponge cake");
- CONFIG.save();
- }
- protected void addSmelting()
- {
- }
- public void addGen()
- {
- GameRegistry.registerWorldGenerator(new WorldGenTinyStar());
- }
- private void addDimension()
- {
- DimensionManager.registerProviderType(SpongeDimension, WorldSpongeDimension.class, false);
- DimensionManager.registerDimension(SpongeDimension, SpongeDimension);
- }
- @ServerStarting
- public void onServerStarting(FMLServerStartingEvent ev)
- {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement