提供: Minecraft Modding Wiki
移動先: 案内検索

警告: ログインしていません。編集を行うと、あなたの IP アドレスが公開されます。ログインまたはアカウントを作成すれば、あなたの編集はその利用者名とともに表示されるほか、その他の利点もあります。

この編集を取り消せます。 下記の差分を確認して、本当に取り消していいか検証してください。よろしければ変更を保存して取り消しを完了してください。
最新版 編集中の文章
10行目: 10行目:
 
import java.util.List;
 
import java.util.List;
  
public class ItemTNTRemote extends Item
+
public class ItemTNTRemote extends Item {
{
 
 
public int posx,posy,posz;
 
public int posx,posy,posz;
  
public ItemHoge(int id)
+
ItemHoge(int id){
{
 
 
super(id);
 
super(id);
 
//スタック不可能にする。
 
//スタック不可能にする。
25行目: 23行目:
 
//1.3.xのみメソッド名がtryPlaceIntoWorldなので注意
 
//1.3.xのみメソッド名がtryPlaceIntoWorldなので注意
 
@Override
 
@Override
public boolean onItemUse(ItemStack itemstack, EntityPlayer entityplayer, World world, int x, int y, int z, int side)
+
public boolean onItemUse(ItemStack itemstack, EntityPlayer entityplayer, World world, int x, int y, int z, int side){
{
+
if(!world.isRemote){
if(!world.isRemote)
 
{
 
 
//NBTタグを取得します。
 
//NBTタグを取得します。
 
NBTTagCompound nbt = itemstack.getTagCompound();
 
NBTTagCompound nbt = itemstack.getTagCompound();
if(nbt == null)
+
if(nbt == null){
{
 
 
nbt = new NBTTagCompound();
 
nbt = new NBTTagCompound();
 
itemstack.setTagCompound(nbt);
 
itemstack.setTagCompound(nbt);
 
}
 
}
 
//対象ブロックがTNTの場合は位置を記録し、それ以外の場合は着火処理を行う。
 
//対象ブロックがTNTの場合は位置を記録し、それ以外の場合は着火処理を行う。
if(world.getBlockId(x, y, z) == Block.tnt.blockID)
+
if(world.getBlockId(x, y, z) == Block.tnt.blockID){
{
 
 
nbt.setInteger("PosX", x);
 
nbt.setInteger("PosX", x);
 
nbt.setInteger("PosY", y);
 
nbt.setInteger("PosY", y);
 
nbt.setInteger("PosZ", z);
 
nbt.setInteger("PosZ", z);
}
+
}else{
else
 
{
 
 
onItemRightClick(itemstack, world, entityplayer);
 
onItemRightClick(itemstack, world, entityplayer);
 
}
 
}
53行目: 45行目:
 
//空中を右クリックした場合に呼ばれます。
 
//空中を右クリックした場合に呼ばれます。
 
@Override
 
@Override
public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer)
+
public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer){
{
+
if(!world.isRemote){
if(!world.isRemote)
 
{
 
 
NBTTagCompound nbt = itemstack.getTagCompound();
 
NBTTagCompound nbt = itemstack.getTagCompound();
 
if(nbt == null)
 
if(nbt == null)
63行目: 53行目:
 
posy = nbt.getInteger("PosY");
 
posy = nbt.getInteger("PosY");
 
posz = nbt.getInteger("PosZ");
 
posz = nbt.getInteger("PosZ");
if(world.getBlockId(posx, posy, posz) == Block.tnt.blockID)
+
if(world.getBlockId(posx, posy, posz) == Block.tnt.blockID){
{
 
 
Block.tnt.onBlockDestroyedByPlayer(world, posx, posy, posz, 1);
 
Block.tnt.onBlockDestroyedByPlayer(world, posx, posy, posz, 1);
 
world.setBlockWithNotify(posx, posy, posz, 0);
 
world.setBlockWithNotify(posx, posy, posz, 0);
75行目: 64行目:
 
@Override
 
@Override
 
public void addInformation(ItemStack itemstack, List list)
 
public void addInformation(ItemStack itemstack, List list)
{
+
    {
 
NBTTagCompound nbt = itemstack.getTagCompound();
 
NBTTagCompound nbt = itemstack.getTagCompound();
 
if(nbt == null)
 
if(nbt == null)
84行目: 73行目:
 
posz = nbt.getInteger("PosZ");
 
posz = nbt.getInteger("PosZ");
 
list.add("[" + posx + "," + posy + "," + posz + "]");
 
list.add("[" + posx + "," + posy + "," + posz + "]");
}
+
    }
  
 
}
 
}
93行目: 82行目:
 
<source lang="java">
 
<source lang="java">
 
NBTTagCompound nbt = itemstack.getTagCompound();
 
NBTTagCompound nbt = itemstack.getTagCompound();
if(nbt == null)
+
if(nbt == null){
{
 
 
nbt = new NBTTagCompound();
 
nbt = new NBTTagCompound();
 
itemstack.setTagCompound(nbt);
 
itemstack.setTagCompound(nbt);
103行目: 91行目:
 
**なのでnullが返ってきた場合は、新しくNBTタグを作成し、アイテムに登録します。
 
**なのでnullが返ってきた場合は、新しくNBTタグを作成し、アイテムに登録します。
 
<source lang="java">
 
<source lang="java">
if(world.getBlockId(x, y, z) == Block.tnt.blockID)
+
if(world.getBlockId(x, y, z) == Block.tnt.blockID){
{
 
 
nbt.setInteger("PosX", x);
 
nbt.setInteger("PosX", x);
 
nbt.setInteger("PosY", y);
 
nbt.setInteger("PosY", y);
 
nbt.setInteger("PosZ", z);
 
nbt.setInteger("PosZ", z);
}
+
}else{
else
 
{
 
 
onItemRightClick(itemstack, world, entityplayer);
 
onItemRightClick(itemstack, world, entityplayer);
 
}
 
}
117行目: 102行目:
 
===onItemRightClick===
 
===onItemRightClick===
 
<source lang="java">
 
<source lang="java">
 +
NBTTagCompound nbt = itemstack.getTagCompound();
 
NBTTagCompound nbt = itemstack.getTagCompound();
 
NBTTagCompound nbt = itemstack.getTagCompound();
 
if(nbt == null)
 
if(nbt == null)

Minecraft Modding Wikiへの投稿はすべて、他の投稿者によって編集、変更、除去される場合があります。 自分が書いたものが他の人に容赦なく編集されるのを望まない場合は、ここに投稿しないでください。
また、投稿するのは、自分で書いたものか、パブリック ドメインまたはそれに類するフリーな資料からの複製であることを約束してください(詳細はMinecraft Modding Wiki:著作権を参照)。 著作権保護されている作品は、許諾なしに投稿しないでください!

このページを編集するには、下記の確認用の質問に回答してください (詳細):

取り消し 編集の仕方 (新しいウィンドウで開きます)

このページで使用されているテンプレート: