+
|
オファレンMOD |
package nahama.ofalenmod;
/*略*/
/**@author Akasata Nahama*/
@Mod(modid = OfalenModCore.MODID, name = OfalenModCore.MODNAME, version = OfalenModCore.VERSION)
public class OfalenModCore {
public static final String MODID = "OfalenMod";
public static final String MODNAME = "Ofalen Mod";
public static final String VERSION = "[1.7.10]1.0.0";
/*略*/
/**最初に行われる処理。アイテム・ブロックの追加などを行う*/
@EventHandler
public void preInit(FMLPreInitializationEvent event) {
/*略*/
//アイテムを設定するメソッドを実行
OfalenModItemCore.registerItem();
//ブロックを設定するメソッドを実行
OfalenModBlockCore.registerBlock();
/*略*/
}
/**2番目に行われる処理。レシピの追加などを行う*/
@EventHandler
public void init (FMLInitializationEvent event) {
//鉱石を生成させる
GameRegistry.registerWorldGenerator(new OfalenOreGenerator(), 1);
/*略*/
}
/*略*/
}
+
|
あまり関係ないので格納 |
package nahama.ofalenmod.core;
/*略*/
public class OfalenModItemCore {
/*略*/
public static Item fragmentOfalen;
/*略*/
/**アイテムを設定する*/
public static void registerItem () {
/*略*/
fragmentOfalen = new Ofalen()
.setUnlocalizedName("fragmentOfalen")
.setTextureName("ofalenmod:ofalen_fragment");
GameRegistry.registerItem(fragmentOfalen,"fragmentOfalen");
/*略*/
}
}
package nahama.ofalenmod.item;
import net.minecraft.util.IIcon;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class Ofalen extends Parts {
public Ofalen () {
super (4);
}
/**メタデータにより返すIIconを変える。*/
@Override
@SideOnly(Side.CLIENT)
public IIcon getIconFromDamage(int meta) {
return iicon[meta & 3];
}
/**メタデータを返す。*/
@Override
public int getMetadata(int meta) {
return meta & 3;
}
}
package nahama.ofalenmod.item;
import java.util.List;
import nahama.ofalenmod.OfalenModCore;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class Parts extends Item {
protected IIcon[] iicon;
private final int type;
public Parts (int type) {
super ();
this.type = type;
this.setCreativeTab(OfalenModCore.tabOfalen);
this.setHasSubtypes(true);
this.setMaxDamage(0);
}
/**メタデータ違いのテクスチャを登録する*/
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister register) {
this.iicon = new IIcon[type];
for (int i = 0; i < type; i ++) {
this.iicon[i] = register.registerIcon(this.getIconString() + "-" + i);
}
}
/**メタデータにより返すIIconを変える*/
@Override
@SideOnly(Side.CLIENT)
public IIcon getIconFromDamage(int meta) {
return iicon[meta];
}
/**メタデータ違いのアイテムを登録する*/
@Override
@SideOnly(Side.CLIENT)
public void getSubItems(Item item, CreativeTabs creativeTab, List list) {
for (int i = 0; i < type; i ++) {
list.add(new ItemStack(this, 1, i));
}
}
/**メタデータを返す*/
@Override
public int getMetadata(int meta) {
return meta;
}
/**メタデータにより内部名を変える*/
@Override
public String getUnlocalizedName(ItemStack itemStack) {
return this.getUnlocalizedName() + "." + itemStack.getItemDamage();
}
}
|
package nahama.ofalenmod.core;
/*略*/
public class OfalenModBlockCore {
//ブロックの定義
public static Block oreOfalen;
/*略*/
/**ブロックを設定する*/
public static void registerBlock () {
oreOfalen = new OfalenOre()
.setBlockName("oreOfalen")
.setBlockTextureName("ofalenmod:ofalen_ore-");
GameRegistry.registerBlock(oreOfalen, ItemOfalenBlock.class, "oreOfalen");
/*略*/
}
}
package nahama.ofalenmod.block;
import java.util.List;
import java.util.Random;
import nahama.ofalenmod.OfalenModCore;
import nahama.ofalenmod.core.OfalenModConfigCore;
import nahama.ofalenmod.core.OfalenModItemCore;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class OfalenOre extends Block {
private IIcon[] iicon = new IIcon[4];
private Random random = new Random();
public OfalenOre() {
super(Material.rock);
this.setCreativeTab(OfalenModCore.tabOfalen);
this.setHardness(5.0F);
this.setResistance(7.5F);
this.setStepSound(Block.soundTypePiston);
this.setLightLevel(0.6F);
this.setHarvestLevel("pickaxe", 3);
}
/**ドロップアイテムの設定*/
@Override
public Item getItemDropped(int meta, Random random, int fortune) {
return OfalenModItemCore.fragmentOfalen;
}
/**ドロップ数の設定*/
@Override
public int quantityDropped(Random random) {
return OfalenModConfigCore.amountDrop;
}
/**fortuneによるドロップ増加の設定。BlockOre参照*/
@Override
public int quantityDroppedWithBonus(int level, Random random) {
//幸運のレベルが1以上で、ドロップアイテムがこのブロック自身でない場合
if (level > 0 && Item.getItemFromBlock(this) != this.getItemDropped(0, random, level)) {
int i = random.nextInt(level + 2) - 1;
if (i < 0) {
i = 0;
}
return this.quantityDropped(random) * (i + 1);
} else {
return this.quantityDropped(random);
}
}
/**経験値ドロップの設定*/
@Override
public int getExpDrop(IBlockAccess iBlockAccess, int meta, int fortune) {
return MathHelper.getRandomIntegerInRange(random, 3, 7);
}
/**メタデータ違いのテクスチャを登録する*/
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iicon) {
for (int i = 0; i < 4; i ++) {
this.iicon[i] = iicon.registerIcon(this.getTextureName() + i);
}
}
/**メタデータにより返すIIconを変える*/
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta) {
return iicon[meta & 3];
}
/**メタデータ違いのブロックを登録する*/
@Override
@SideOnly(Side.CLIENT)
public void getSubBlocks(Item item, CreativeTabs creativeTab, List list) {
for (int i = 0; i < 4; i ++) {
list.add(new ItemStack(item, 1, i));
}
}
/**メタデータによりドロップ品を変える*/
@Override
public int damageDropped(int meta) {
return meta & 3;
}
}
package nahama.ofalenmod.generator;
import java.util.Random;
import nahama.ofalenmod.core.OfalenModBlockCore;
import nahama.ofalenmod.core.OfalenModConfigCore;
import net.minecraft.init.Blocks;
import net.minecraft.world.World;
import net.minecraft.world.WorldProviderSurface;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.feature.WorldGenMinable;
import cpw.mods.fml.common.IWorldGenerator;
public class OfalenOreGenerator implements IWorldGenerator {
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {
if (OfalenModConfigCore.enabledGenerator) {
if (world.provider instanceof WorldProviderSurface) {
generateOreRed(world, random, chunkX << 4, chunkZ << 4);
generateOreGreen(world, random, chunkX << 4, chunkZ << 4);
generateOreBlue(world, random, chunkX << 4, chunkZ << 4);
generateOreBig(world, random, chunkX << 4, chunkZ << 4);
}
}
}
private void generateOreRed(World world, Random random, int x, int z) {
for(int i = 0; i < OfalenModConfigCore.probabilityGeneration; i++) {
int genX = x + random.nextInt(16);
int genY = 1 + random.nextInt(15);
int genZ = z + random.nextInt(16);
new WorldGenMinable(OfalenModBlockCore.oreOfalen, 0, OfalenModConfigCore.limitGeneration, Blocks.stone).generate(world, random, genX, genY, genZ);
}
}
private void generateOreGreen(World world, Random random, int x, int z) {
for(int i = 0; i < OfalenModConfigCore.probabilityGeneration; i++) {
int genX = x + random.nextInt(16);
int genY = 1 + random.nextInt(15);
int genZ = z + random.nextInt(16);
new WorldGenMinable(OfalenModBlockCore.oreOfalen, 1, OfalenModConfigCore.limitGeneration, Blocks.stone).generate(world, random, genX, genY, genZ);
}
}
private void generateOreBlue(World world, Random random, int x, int z) {
for(int i = 0; i < OfalenModConfigCore.probabilityGeneration; i++) {
int genX = x + random.nextInt(16);
int genY = 1 + random.nextInt(15);
int genZ = z + random.nextInt(16);
new WorldGenMinable(OfalenModBlockCore.oreOfalen, 2, OfalenModConfigCore.limitGeneration, Blocks.stone).generate(world, random, genX, genY, genZ);
}
}
private void generateOreBig(World world, Random random, int x, int z) {
int i = random.nextInt(10000);
if (i < OfalenModConfigCore.probabilityGenerationLode) {
int genX = x + random.nextInt(16);
int genY = 1 + random.nextInt(15);
int genZ = z + random.nextInt(16);
int type = random.nextInt(19)/3;
switch (type) {
case 0:
new WorldGenMinable(OfalenModBlockCore.oreOfalen, 0, 40, Blocks.stone).generate(world, random, genX, genY, genZ);
new WorldGenMinable(OfalenModBlockCore.oreOfalen, 1, 40, Blocks.stone).generate(world, random, genX, genY, genZ);
new WorldGenMinable(OfalenModBlockCore.oreOfalen, 2, 40, Blocks.stone).generate(world, random, genX, genY, genZ);
break;
case 1:
new WorldGenMinable(OfalenModBlockCore.oreOfalen, 0, 40, Blocks.stone).generate(world, random, genX, genY, genZ);
new WorldGenMinable(OfalenModBlockCore.oreOfalen, 2, 40, Blocks.stone).generate(world, random, genX, genY, genZ);
new WorldGenMinable(OfalenModBlockCore.oreOfalen, 1, 40, Blocks.stone).generate(world, random, genX, genY, genZ);
break;
case 2:
new WorldGenMinable(OfalenModBlockCore.oreOfalen, 1, 40, Blocks.stone).generate(world, random, genX, genY, genZ);
new WorldGenMinable(OfalenModBlockCore.oreOfalen, 0, 40, Blocks.stone).generate(world, random, genX, genY, genZ);
new WorldGenMinable(OfalenModBlockCore.oreOfalen, 2, 40, Blocks.stone).generate(world, random, genX, genY, genZ);
break;
case 3:
new WorldGenMinable(OfalenModBlockCore.oreOfalen, 1, 40, Blocks.stone).generate(world, random, genX, genY, genZ);
new WorldGenMinable(OfalenModBlockCore.oreOfalen, 2, 40, Blocks.stone).generate(world, random, genX, genY, genZ);
new WorldGenMinable(OfalenModBlockCore.oreOfalen, 0, 40, Blocks.stone).generate(world, random, genX, genY, genZ);
break;
case 4:
new WorldGenMinable(OfalenModBlockCore.oreOfalen, 2, 40, Blocks.stone).generate(world, random, genX, genY, genZ);
new WorldGenMinable(OfalenModBlockCore.oreOfalen, 0, 40, Blocks.stone).generate(world, random, genX, genY, genZ);
new WorldGenMinable(OfalenModBlockCore.oreOfalen, 1, 40, Blocks.stone).generate(world, random, genX, genY, genZ);
break;
case 5:
new WorldGenMinable(OfalenModBlockCore.oreOfalen, 2, 40, Blocks.stone).generate(world, random, genX, genY, genZ);
new WorldGenMinable(OfalenModBlockCore.oreOfalen, 1, 40, Blocks.stone).generate(world, random, genX, genY, genZ);
new WorldGenMinable(OfalenModBlockCore.oreOfalen, 0, 40, Blocks.stone).generate(world, random, genX, genY, genZ);
break;
case 6:
new WorldGenMinable(OfalenModBlockCore.oreOfalen, 3, 40, Blocks.stone).generate(world, random, genX, genY, genZ);
}
new WorldGenMinable(OfalenModBlockCore.oreOfalen, 3, 40, Blocks.stone).generate(world, random, genX, genY, genZ);
}
}
}
|