提供: Minecraft Modding Wiki
この編集を取り消せます。
下記の差分を確認して、本当に取り消していいか検証してください。よろしければ変更を保存して取り消しを完了してください。
最新版 | 編集中の文章 | ||
10行目: | 10行目: | ||
package custom.tool.item; | package custom.tool.item; | ||
− | |||
import net.minecraft.item.EnumToolMaterial; | import net.minecraft.item.EnumToolMaterial; | ||
− | + | import net.minecraftforge.MinecraftForgeClient; | |
− | |||
− | |||
− | import net.minecraftforge | ||
− | |||
import cpw.mods.fml.common.Mod; | import cpw.mods.fml.common.Mod; | ||
+ | import cpw.mods.fml.common.network.NetworkMod; | ||
import cpw.mods.fml.common.Mod.EventHandler; | import cpw.mods.fml.common.Mod.EventHandler; | ||
import cpw.mods.fml.common.event.FMLPreInitializationEvent; | import cpw.mods.fml.common.event.FMLPreInitializationEvent; | ||
− | |||
import cpw.mods.fml.common.registry.GameRegistry; | import cpw.mods.fml.common.registry.GameRegistry; | ||
import cpw.mods.fml.common.registry.LanguageRegistry; | import cpw.mods.fml.common.registry.LanguageRegistry; | ||
@Mod( | @Mod( | ||
− | modid = CustomModelTools | + | modid = "CustomModelTools", |
− | name = | + | name = "Custom Model Tools", |
− | version = | + | version = "1" |
) | ) | ||
@NetworkMod( | @NetworkMod( | ||
35行目: | 30行目: | ||
public class CustomModelTools | public class CustomModelTools | ||
{ | { | ||
− | |||
− | |||
− | |||
− | |||
public static final boolean clientSideRequiredBoolean = true; | public static final boolean clientSideRequiredBoolean = true; | ||
− | public static final boolean | + | public static final boolean serverSudeRequiredBoolean = false; |
public static boolean Model_ON_OFF_Boolean = true; | public static boolean Model_ON_OFF_Boolean = true; | ||
public static String ModelTexture; | public static String ModelTexture; | ||
− | public static String texture | + | public static String texture; |
− | |||
− | |||
public static EnumToolMaterial toolMaterial; | public static EnumToolMaterial toolMaterial; | ||
public static ItemTool mainItem; | public static ItemTool mainItem; | ||
− | |||
− | |||
− | |||
− | |||
− | @ | + | @EventHabdler |
public void mainLoading(FMLPreInitializationEvent event) | public void mainLoading(FMLPreInitializationEvent event) | ||
{ | { | ||
− | mainItem = | + | mainItem = new ItemCustomModelTools(3001, toolMaterial.rock).setData("CustomModelItem", "CustomModelItem"); |
− | registerItem(mainItem, "CustomModelItem", "Custom Model Item", "カスタムモデルアイテム", new ItemCustomModelToolsRenderer() | + | registerItem(mainItem, "CustomModelItem", "Custom Model Item", "カスタムモデルアイテム", new ItemCustomModelToolsRenderer(), texture, 64, 32); |
− | |||
} | } | ||
public void registerItem(Item items, String name, String en_US, String ja_JP, IItemRenderer itemRenderer, boolean modeling, String texture, int width, int height) | public void registerItem(Item items, String name, String en_US, String ja_JP, IItemRenderer itemRenderer, boolean modeling, String texture, int width, int height) | ||
{ | { | ||
− | + | GameReigstry.registerItem(items, name); | |
− | LanguageRegistry | + | LanguageRegistry.addNameForObject(items, "en_US", en_US); |
− | LanguageRegistry | + | LanguageRegistry.addNameForObject(items, "ja_JP", ja_JP); |
MinecraftForgeClient.registerItemRenderer(items.itemID, itemRenderer); | MinecraftForgeClient.registerItemRenderer(items.itemID, itemRenderer); | ||
Model_ON_OFF_Boolean = modeling; | Model_ON_OFF_Boolean = modeling; | ||
ModelTexture = texture; | ModelTexture = texture; | ||
− | ModelCustomModelTools | + | ModelCustomModelTools modeling = new ModelCustomModelTools(); |
− | + | modeling.setTextureSize(width, height); | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
} | } | ||
} | } | ||
92行目: | 66行目: | ||
<source lang = java> | <source lang = java> | ||
package custom.tool.item; | package custom.tool.item; | ||
− | + | ||
import net.minecraft.item.ItemTool; | import net.minecraft.item.ItemTool; | ||
− | |||
import net.minecraft.item.EnumToolMaterial; | import net.minecraft.item.EnumToolMaterial; | ||
import net.minecraft.block.Block; | import net.minecraft.block.Block; | ||
− | import net.minecraft.block | + | import net.minecraft.block.Material; |
public class ItemCustomModelTools extends ItemTool | public class ItemCustomModelTools extends ItemTool | ||
112行目: | 85行目: | ||
Block.tilledField, | Block.tilledField, | ||
Block.slowSand, | Block.slowSand, | ||
− | Block.mycelium | + | Block.mycelium |
// ItemPickaxe.java | // ItemPickaxe.java | ||
Block.cobblestone, | Block.cobblestone, | ||
134行目: | 107行目: | ||
Block.railDetector, | Block.railDetector, | ||
Block.railPowered, | Block.railPowered, | ||
− | Block.railActivator | + | Block.railActivator |
− | + | // ItemAxe.java | |
− | Block.planks, | + | Block.planks, Block.bookShelf, |
− | |||
Block.wood, Block.chest, | Block.wood, Block.chest, | ||
Block.stoneDoubleSlab, | Block.stoneDoubleSlab, | ||
144行目: | 116行目: | ||
Block.pumpkinLantern}; | Block.pumpkinLantern}; | ||
// 詳しい情報は、ItemSpade.java ItemPickaxe.java ItemAxe.javaを参照 | // 詳しい情報は、ItemSpade.java ItemPickaxe.java ItemAxe.javaを参照 | ||
− | + | ||
− | |||
public ItemCustomModelTools(int par1ID, EnumToolMaterial par2EnumToolMaterial) | public ItemCustomModelTools(int par1ID, EnumToolMaterial par2EnumToolMaterial) | ||
{ | { | ||
153行目: | 124行目: | ||
public boolean canHarvestBlock(Block par1Block) | public boolean canHarvestBlock(Block par1Block) | ||
{ | { | ||
− | + | return par1Block == Block.snow ? true : par1Block == Block.blockSnow : //雪 | |
+ | (par1Block == Block.obsidian ? this.toolMaterial.getHarvestLevel() == 3 : //黒曜石 | ||
+ | (par1Block != Block.blockDiamond && par1Block != Block.oreDiamond ? //ダイヤモンド | ||
+ | (par1Block != Block.oreEmerald && par1Block != Block.blockEmerald ? //エメラルド | ||
+ | (par1Block != Block.blockGold && par1Block != Block.oreGold ? //金 | ||
+ | (par1Block != Block.blockIron && par1Block != Block.oreIron ? //鉄 | ||
+ | (par1Block != Block.blockLapis && par1Block != Block.oreLapis ? //ラピスラズリ | ||
+ | (par1Block != Block.oreRedstone && par1Block != Block.oreRedstoneGlowing ? //レッドストーン | ||
+ | (par1Block.blockMaterial == Material.rock ? true : //マテリアル属性 石 | ||
+ | (par1Block.blockMaterial == Material.iron ? true : //マテリアル属性 鉄 | ||
+ | par1Block.blockMaterial == Material.anvil)) //マテリアル属性 金床 | ||
+ | this.toolMaterial.getHarvestLevel() >= 2) : //マテリアルレベル 2 | ||
+ | this.toolMaterial.getHarvestLevel() >= 1) : //マテリアルレベル 1 | ||
+ | this.toolMaterial.getHarvestLevel() >= 1) : //マテリアルレベル 1 | ||
+ | this.toolMaterial.getHarvestLevel() >= 2) : //マテリアルレベル 2 | ||
+ | this.toolMaterial.getHarvestLevel() >= 2) : //マテリアルレベル 2 | ||
+ | this.toolMaterial.getHarvestLevel() >= 2)); //マテリアルレベル 2 | ||
} | } | ||
@Override | @Override | ||
168行目: | 155行目: | ||
super.getStrVsBlock(par1ItemStack, par2Block); | super.getStrVsBlock(par1ItemStack, par2Block); | ||
} | } | ||
− | public Item setData(String domain, String path | + | public Item setData(String domain, String path) |
{ | { | ||
setUnlocalizedName(path); | setUnlocalizedName(path); | ||
iconString = domain + ":" + path; | iconString = domain + ":" + path; | ||
− | |||
− | |||
} | } | ||
} | } | ||
183行目: | 168行目: | ||
<source lang = java> | <source lang = java> | ||
package custom.tool.item; | package custom.tool.item; | ||
− | + | ||
+ | import net.minecraftforge.client.IItemRenderer; | ||
import net.minecraft.client.Minecraft; | import net.minecraft.client.Minecraft; | ||
− | |||
− | |||
import net.minecraft.util.ResourceLocation; | import net.minecraft.util.ResourceLocation; | ||
− | import | + | import org.lwjgl.opengl.GL11; |
− | |||
− | |||
public class ItemCustomModelToolsRenderer implements IItemRenderer | public class ItemCustomModelToolsRenderer implements IItemRenderer | ||
{ | { | ||
private ModelCustomModelTools modeling; | private ModelCustomModelTools modeling; | ||
+ | protected Minecraft mc; | ||
public ItemCustomModelToolsRenderer() | public ItemCustomModelToolsRenderer() | ||
{ | { | ||
223行目: | 206行目: | ||
{ | { | ||
GL11.glPushMatrix(); | GL11.glPushMatrix(); | ||
− | + | ||
float scala = 2.5F; | float scala = 2.5F; | ||
− | + | ||
− | GL11. | + | GL11.glScalaf(scala, scala, scala); |
− | + | ||
GL11.glRotatef(0F, -10.0F, 0.0F, 0.0F); | GL11.glRotatef(0F, -10.0F, 0.0F, 0.0F); | ||
GL11.glRotatef(8F, 0.0F, -10.0F, 0.0F); | GL11.glRotatef(8F, 0.0F, -10.0F, 0.0F); | ||
GL11.glRotatef(125F, 0.0F, 0.0F, -10.0F); | GL11.glRotatef(125F, 0.0F, 0.0F, -10.0F); | ||
− | + | ||
GL11.glTranslatef(-0.304800F, -0.500F, -0.09F); | GL11.glTranslatef(-0.304800F, -0.500F, -0.09F); | ||
− | + | ||
− | + | mc.renderEngine.bindTexture(new ResourceLocation(CustomModelTools.ModelTexture)); | |
− | + | ||
modeling.render((Entity) data[1], 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F); | modeling.render((Entity) data[1], 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F); | ||
− | + | ||
GL11.glPopMatrix(); | GL11.glPopMatrix(); | ||
} | } | ||
252行目: | 235行目: | ||
<source lang = java> | <source lang = java> | ||
package custom.tool.item; | package custom.tool.item; | ||
− | + | ||
− | import net.minecraft | + | import net.minecraft,client.model.ModelBase; |
import net.minecraft.client.model.ModelRenderer; | import net.minecraft.client.model.ModelRenderer; | ||
import net.minecraft.entity.Entity; | import net.minecraft.entity.Entity; | ||
− | + | ||
public class ModelCustomModelTools extends ModelBase | public class ModelCustomModelTools extends ModelBase | ||
{ | { | ||
270行目: | 253行目: | ||
public ModelRenderer AxeDown; | public ModelRenderer AxeDown; | ||
public ModelRenderer Forward; | public ModelRenderer Forward; | ||
− | + | ||
public int TextureSizeWidth = 64; | public int TextureSizeWidth = 64; | ||
public int TextureSizeHeight = 32; | public int TextureSizeHeight = 32; | ||
313行目: | 296行目: | ||
MainCenter.mirror = true; | MainCenter.mirror = true; | ||
setRotation(MainCenter, 0F, 0F, 0F); | setRotation(MainCenter, 0F, 0F, 0F); | ||
− | + | AxeUp = new ModelRenderer(this, 30, 14); | |
− | + | AxeUp.addBox(0F, 0F, 0F, 2, 6, 4); | |
− | + | AxeUp.setRotationPoint(-4F, -9F, -2F); | |
− | + | AxeUp.setTextureSize(TextureSizeWidth, TextureSizeHeight); | |
− | + | AxeUp.mirror = true; | |
− | + | setRotation(AxeUp, 0F, 0F, 0.7853982F); | |
− | + | AxeLeft = new ModelRenderer(this, 30, 2); | |
− | + | AxeLeft.addBox(0F, 0F, 0F, 2, 6, 6); | |
− | + | AxeLeft.setRotationPoint(-3F, -5F, -5F); | |
− | + | AxeLeft.setTextureSize(TextureSizeWidth, TextureSizeHeight); | |
− | + | AxeLeft.mirror = true; | |
− | + | setRotation(AxeLeft, 0F, -1.047198F, 0F); | |
− | + | AxeRight = new ModelRenderer(this, 30, 2); | |
− | + | AxeRight.addBox(0F, 0F, 0F, 2, 6, 6); | |
− | + | AxeRight.setRotationPoint(-8F, -5F, 2F); | |
− | + | AxeRight.setTextureSize(TextureSizeWidth, TextureSizeHeight); | |
− | + | AxeRight.mirror = true; | |
− | + | setRotation(AxeRight, 0F, 1.047198F, 0F); | |
− | + | AxeDown = new ModelRenderer(this, 30, 14); | |
− | + | AxeDown.addBox(0F, 0F, 0F, 2, 6, 4); | |
− | + | AxeDown.setRotationPoint(-8F, 1F, -2F); | |
− | + | AxeDown.setTextureSize(TextureSizeWidth, TextureSizeHeight); | |
− | + | AxeDown.mirror = true; | |
− | + | setRotation(AxeDown, 0F, 0F, -0.7853982F); | |
− | + | Forward = new ModelRenderer(this, 8, 6); | |
− | + | Forward.addBox(0F, 0F, 0F, 1, 4, 2); | |
− | + | Forward.setRotationPoint(-8.5F, -4F, -1F); | |
− | + | Forward.setTextureSize(TextureSizeWidth, TextureSizeHeight); | |
− | + | Forward.mirror = true; | |
− | + | setRotation(Forward, 0F, 0F, 0F); | |
} | } | ||
public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) | public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) | ||
366行目: | 349行目: | ||
model.rotateAngleZ = z; | model.rotateAngleZ = z; | ||
} | } | ||
− | public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) | + | public void setRotationAngles(float f, float f1, float, f2, float f3, float f4, float f5, Entity entity) |
{ | { | ||
super.setRotationAngles(f, f1, f2, f3, f4, f5, entity); | super.setRotationAngles(f, f1, f2, f3, f4, f5, entity); | ||
372行目: | 355行目: | ||
public void setTextureSize(int width, int height) | public void setTextureSize(int width, int height) | ||
{ | { | ||
− | TextureSizeWidth = width | + | TextureSizeWidth = width |
− | TextureSizeHeight = height | + | TextureSizeHeight = height |
} | } | ||
} | } | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
</source> | </source> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | 未完成<br> | |
+ | [[チュートリアル一覧]]に乗せる方がいるのなら、まだ乗せないで下さい |