初期に設定している値から変化しません。
引数のx,y,zをpropertiesファイルに書き込むメソッド
public boolean onItemUse(ItemStack itemStackIn, EntityPlayer playerIn, World p_77648_3_, int x, int y, int z, int Direction, float p_77648_8_, float p_77648_9_, float p_77648_10_){
if(!p_77648_3_.isRemote)
{
try {
//Propertiesオブジェクトを生成
Properties prop = new Properties();
// ファイルを読み込む
FileInputStream myConfFileIn = new FileInputStream("test.properties");
prop.load(myConfFileIn);
String X = String.valueOf(x);
String Y = String.valueOf(y);
String Z = String.valueOf(z);
// 値をセット
prop.setProperty("x", X);
prop.setProperty("y", Y);
prop.setProperty("z", Z);
//データの保存
FileOutputStream fos = new FileOutputStream(new File("test.properties"));
prop.store(fos, null);
fos.close();
} catch (Exception e) {
System.out.println("Exception : " + e);
}
}
return true;
}
protected void onImpact(MovingObjectPosition p_70184_1_) {
// TODO 自動生成されたメソッド・スタブ
try {
//Propertiesオブジェクトを生成
Properties prop = new Properties();
// ファイルを読み込む
prop.load(this.getClass().getResourceAsStream("../Items/test.properties"));
// 値を取得
String x = prop.getProperty("x");
String y = prop.getProperty("y");
String z = prop.getProperty("z");
telepox = Integer.parseInt(x);
telepoy = Integer.parseInt(y);
telepoz = Integer.parseInt(z);
} catch (Exception e) {
System.out.println("Exception : " + e);
}
/*ここから下は関係ないです*/
if(telepox!=0 && telepoy!=0 && telepoz!=0){
if (p_70184_1_.entityHit != null)
{
p_70184_1_.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), 0.0F);
}
for (int i = 0; i < 32; ++i)
{
this.worldObj.spawnParticle("portal", this.posX, this.posY + this.rand.nextDouble() * 2.0D, this.posZ, this.rand.nextGaussian(), 0.0D, this.rand.nextGaussian());
}
if (!this.worldObj.isRemote)
{
if (this.getThrower() != null && this.getThrower() instanceof EntityPlayerMP)
{
EntityPlayerMP entityplayermp = (EntityPlayerMP)this.getThrower();
if (entityplayermp.playerNetServerHandler.func_147362_b().isChannelOpen() && entityplayermp.worldObj == this.worldObj)
{
EnderTeleportEvent event = new EnderTeleportEvent(entityplayermp, this.posX, this.posY, this.posZ, 0F);
if (!MinecraftForge.EVENT_BUS.post(event))
{ // Don't indent to lower patch size
if (this.getThrower().isRiding())
{
this.getThrower().mountEntity((Entity)null);
}
this.getThrower().setPositionAndUpdate(telepox, telepoy+1, telepoz);
this.getThrower().fallDistance = 0.0F;
this.getThrower().attackEntityFrom(DamageSource.fall, event.attackDamage);
}
}
}
this.setDead();
}
}
}
二つのメソッドは別クラスのものです。
上に書いてあるメソッドでx,y,zの値をpropertiesファイルに保存し、下に書いてあるコードでpropertiesファイルからx,y,zの値を参照するという感じです。
色々なサイトを見ながら作っているのですが、初期の値を参照するだけで書き込んだ祭の値を参照してくれません。
どなたか分かる方がいらっしゃいましたら回答よろしくお願い致します。