Last active
August 29, 2015 14:00
-
-
Save mrtska/11075907 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package mrtska.gui; | |
import java.io.BufferedInputStream; | |
import java.io.ByteArrayInputStream; | |
import java.io.DataInputStream; | |
import java.io.DataOutputStream; | |
import java.io.File; | |
import java.io.FilenameFilter; | |
import java.io.IOException; | |
import java.io.RandomAccessFile; | |
import java.util.zip.InflaterInputStream; | |
import mrtska.corner.BlockCorners; | |
import mrtska.edgecorner.BlockEdgeCorners; | |
import mrtska.edgecorner.overlap.BlockOverlapEdgeCorners; | |
import mrtska.halfslope.BlockHalfSlopes; | |
import mrtska.halfslope.overlap.BlockOverlapHalfSlopes; | |
import mrtska.obliqueslope.BlockObliqueSlopes; | |
import mrtska.slope.BlockSlopes; | |
import mrtska.slope.overlap.BlockOverlapSlopes; | |
import mrtska.slope.track.BlockSlopeTrack; | |
import mrtska.util.BlockIDs; | |
import mrtska.util.OldBlockIDs; | |
import mrtska.workbench.BlockSlopeWorkbench; | |
import net.minecraft.block.Block; | |
import net.minecraft.client.gui.GuiButton; | |
import net.minecraft.client.gui.GuiScreen; | |
import net.minecraft.client.renderer.Tessellator; | |
import net.minecraft.client.resources.I18n; | |
import net.minecraft.nbt.CompressedStreamTools; | |
import net.minecraft.nbt.NBTTagCompound; | |
import net.minecraft.nbt.NBTTagList; | |
import net.minecraft.world.chunk.NibbleArray; | |
import net.minecraft.world.chunk.storage.ExtendedBlockStorage; | |
import net.minecraft.world.chunk.storage.RegionFileCache; | |
import net.minecraftforge.common.util.Constants.NBT; | |
import org.lwjgl.opengl.GL11; | |
import cpw.mods.fml.client.FMLClientHandler; | |
import cpw.mods.fml.common.registry.GameRegistry; | |
import cpw.mods.fml.common.registry.GameRegistry.UniqueIdentifier; | |
/** | |
* | |
* @author StarRing | |
* Copyright 2014 StarRing.mrtska All Rights Reserved. | |
*/ | |
public class ConfigScreen extends GuiScreen { | |
/** | |
* Mod一覧に戻るためにインスタンスを保持しておく | |
*/ | |
private final GuiScreen parent; | |
/** | |
* ワールドデータのリスト | |
*/ | |
private GuiWorldList list; | |
/** | |
* 選択したワールドの中にある斜面ブロック群のリスト | |
*/ | |
protected GuiBlockList blockList; | |
/** | |
* 0 = 未処理 | |
* 1 = ワールド解析中 | |
* 2 = 変換は必要ない | |
* 3 = 変換する必要がある | |
*/ | |
protected int result = 0; | |
/** | |
* resultに応じてメッセージを取得出来るようにする | |
*/ | |
private String[] resultStrings = { "", I18n.format("slopeandcorner.convert.wait") | |
, I18n.format("slopeandcorner.convert.without") | |
, I18n.format("slopeandcorner.convert.need") | |
, I18n.format("slopeandcorner.convert.done") | |
, I18n.format("slopeandcorner.convert.converting") }; | |
/** | |
* コンストラクタ | |
* @param screen | |
*/ | |
public ConfigScreen(GuiScreen screen) { | |
this.parent = screen; | |
if(blockList != null) { | |
blockList.clear(); | |
} | |
} | |
@Override | |
/** | |
* ボタンなどを初期化する | |
*/ | |
public void initGui() { | |
super.initGui(); | |
//---完了ボタン追加--- | |
this.buttonList.add(new GuiButton(1, this.width / 2 - 100, this.height - 38, I18n.format("gui.done"))); | |
//------ | |
//---ワールドチェックボタン追加--- | |
this.buttonList.add(new GuiButton(2, this.width / 2 - 110, 50, 100, 20, I18n.format("slopeandcorner.gui.convert.check"))); | |
//------ | |
//---ワールド変換ボタン追加--- | |
GuiButton doo = new GuiButton(3, this.width / 2 + 10, 50, 100, 20, I18n.format("slopeandcorner.gui.convert.do")); | |
doo.enabled = false; //デフォルトは無効 | |
this.buttonList.add(doo); | |
//------ | |
//---スクロール出来るリストを初期化--- | |
list = new GuiWorldList(this); | |
blockList = new GuiBlockList(this); | |
//------ | |
} | |
@Override | |
protected void actionPerformed(final GuiButton button) { | |
//---完了ボタンが押下された時の処理--- | |
if(button.enabled && button.id == 1) { | |
FMLClientHandler.instance().showGuiScreen(parent); //GUIを切り替える | |
return; | |
} | |
//------ | |
//---ワールドチェックボタンが押下された時の処理--- | |
if(button.enabled && button.id == 2) { | |
((GuiButton) buttonList.get(0)).enabled = false; | |
new Thread(new Runnable() { | |
@Override | |
public void run() { | |
try { | |
blockList.clear(); //ワールドのブロックリストを初期化する | |
result = 1; | |
result = analyseWorldSavedata(list.getSelectedFile().getName(), true); | |
if(result == 3) { //ワールド変換が必要な場合はワールド変換ボタンを有効にする | |
((GuiButton) buttonList.get(2)).enabled = true; | |
} | |
((GuiButton) buttonList.get(0)).enabled = true; | |
} catch(IOException e) { | |
e.printStackTrace(); | |
} | |
} | |
}).start(); | |
return; | |
} | |
//------ | |
//---ワールド変換ボタンが押下された時の処理--- | |
if(button.enabled && button.id == 3) { | |
button.enabled = false; | |
((GuiButton) buttonList.get(0)).enabled = false; | |
result = 5; | |
new Thread(new Runnable() { | |
@Override | |
public void run() { | |
try { | |
analyseWorldSavedata(list.getSelectedFile().getName(), false); | |
result = 4; | |
((GuiButton) buttonList.get(0)).enabled = true; | |
} catch(IOException e) { | |
e.printStackTrace(); | |
} | |
} | |
}).start(); | |
return; | |
} | |
//------ | |
} | |
@Override | |
/** | |
* レンダリング | |
*/ | |
public void drawScreen(int mouseX, int mouseY, float par3) { | |
this.drawDefaultBackground(); | |
this.drawCenteredString(fontRendererObj, I18n.format("slopeandcorner.gui.convert"), width / 2, 20, 0xFFFFFF); | |
//---スクロールリストを描画する | |
list.drawScreen(mouseX, mouseY, par3); | |
blockList.drawScreen(mouseX, mouseY, par3); | |
GL11.glEnable(GL11.GL_BLEND); //アルファーブレンドを有効にする | |
//---ステータス画面を描画する--- | |
Tessellator tessellator = Tessellator.instance; | |
tessellator.startDrawingQuads(); | |
tessellator.setColorRGBA_F(0, 0, 0, 0.5F); | |
tessellator.addVertex(width / 2 - 100, height / 2, 0); | |
tessellator.addVertex(width / 2 - 100, height / 2 + 50, 0); | |
tessellator.addVertex(width / 2 + 100, height / 2 + 50, 0); | |
tessellator.addVertex(width / 2 + 100, height / 2, 0); | |
tessellator.draw(); | |
//------ | |
this.drawString(fontRendererObj, this.resultStrings[result], width / 2 - 100, height / 2, 0xFFFFFF); //リザルトの文字列を描画する | |
super.drawScreen(mouseX, mouseY, par3); //スーパークラスのメソッドを呼び出してボタンを描画する | |
} | |
private class Filter implements FilenameFilter { | |
@Override | |
public boolean accept(File dir, String name) { | |
if(name.substring(name.length() - 4, name.length()).equals(".mca")) { | |
return true; | |
} else { | |
return false; | |
} | |
} | |
} | |
/** | |
* | |
* @param fileName | |
* @param type true = ワールド解析実行 | |
* false = ワールド変換実行 | |
* @return リザルト | |
* @throws IOException | |
*/ | |
public int analyseWorldSavedata(String fileName, boolean type) throws IOException { | |
File file = new File("./saves/" + fileName + "/region/"); | |
int[] result = { 2, 2, 2 }; | |
//regionディレクトリ内にあるマップデータすべてを変換する | |
for(File c : file.listFiles(new Filter())) { | |
RandomAccessFile randomFile = new RandomAccessFile(c, "rw"); | |
if(type) { | |
if(result[0] == 2) { | |
result[0] = checkWorldSavedata(c, randomFile); | |
} else { | |
checkWorldSavedata(c, randomFile); | |
} | |
} else { | |
convertWorldSavedata(c, randomFile, fileName, false); | |
} | |
randomFile.close(); | |
} | |
File dimensionFile = new File(file, "../DIM-1/region/"); | |
if(dimensionFile.exists()) { | |
for(File c : dimensionFile.listFiles(new Filter())) { | |
RandomAccessFile randomFile = new RandomAccessFile(c, "rw"); | |
if(type) { | |
if(result[1] == 2) { | |
result[1] = checkWorldSavedata(c, randomFile); | |
} else { | |
checkWorldSavedata(c, randomFile); | |
} | |
} else { | |
convertWorldSavedata(c, randomFile, fileName, true); | |
} | |
randomFile.close(); | |
} | |
} | |
File dimensionFile2 = new File(file, "../DIM1/region"); | |
if(dimensionFile2.exists()) { | |
for(File c : dimensionFile2.listFiles(new Filter())) { | |
RandomAccessFile randomFile = new RandomAccessFile(c, "rw"); | |
if(type) { | |
if(result[2] == 2) { | |
result[2] = checkWorldSavedata(c, randomFile); | |
} else { | |
checkWorldSavedata(c, randomFile); | |
} | |
} else { | |
convertWorldSavedata(c, randomFile, fileName, true); | |
} | |
randomFile.close(); | |
} | |
} | |
int ans = 0; | |
ans = result[0] == 2 ? (result[1] == 2 ? (result[2] == 2 ? 2 : 3) : 3) : 3; | |
return ans; | |
} | |
/** | |
* blockListに渡すデータをカウントする | |
* @param name | |
*/ | |
private void incrCountBlock(String name) { | |
NBTTagCompound blockCompound = this.blockList.getTag(name); | |
if(blockCompound == null) { | |
blockCompound = new NBTTagCompound(); | |
blockCompound.setInteger("count", 0); | |
} | |
blockCompound.setInteger("count", blockCompound.getInteger("count") + 1); | |
blockCompound.setString("id", name); | |
this.blockList.addTag(name, blockCompound); | |
} | |
private void decrCountBlock(String name) { | |
NBTTagCompound blockCompound = this.blockList.getTag(name); | |
if(blockCompound == null) { | |
blockCompound = new NBTTagCompound(); | |
blockCompound.setInteger("count", 0); | |
} | |
blockCompound.setInteger("count", blockCompound.getInteger("count") - 1); | |
blockCompound.setString("id", name); | |
this.blockList.addTag(name, blockCompound); | |
} | |
private int convertIndexWithRemove(NBTTagCompound tileEntity, String name) { | |
int index = tileEntity.getInteger(name); | |
int newIndex = BlockIDs.convertBlockIndex(index); | |
tileEntity.setInteger("BlockIndex", newIndex); | |
tileEntity.removeTag(name); | |
return index; | |
} | |
private void setBlock(NBTTagCompound tileEntity, int index) { | |
int ID = OldBlockIDs.IDList.get(index); | |
UniqueIdentifier identifier = GameRegistry.findUniqueIdentifierFor(Block.getBlockById(ID)); | |
tileEntity.setString("Block", identifier.toString()); | |
} | |
private void setBlock(NBTTagCompound tileEntity, int index, String another) { | |
int ID = OldBlockIDs.IDList.get(index); | |
UniqueIdentifier identifier = GameRegistry.findUniqueIdentifierFor(Block.getBlockById(ID)); | |
tileEntity.setString(another, identifier.toString()); | |
} | |
private int getIntegerWithRemove(NBTTagCompound tileEntity, String name) { | |
int integer = tileEntity.getInteger(name); | |
tileEntity.removeTag(name); | |
return integer; | |
} | |
/** | |
* ワールドを解析する処理 | |
* @param regionFile | |
* @param randomFile | |
* @return リザルト | |
* @throws IOException | |
*/ | |
public int checkWorldSavedata(File regionFile, RandomAccessFile randomFile) throws IOException { | |
int result = 2; //デフォルトのリザルト | |
long length = regionFile.length(); //ファイルサイズ | |
for(int j = 0; j < 1024; ++j) { | |
this.offsets[j] = randomFile.readInt(); | |
} | |
for(int j = 0; j < 1024; ++j) { | |
this.chunkTimestamps[j] = randomFile.readInt(); | |
} | |
//サイズをファイルのオフセットに変換 | |
length = length / 4096 - 2; | |
for(int i = 0; i < length; i++) { | |
//ファイルヘッダを飛び越える | |
randomFile.seek(i * 0x1000 + 0x2000); | |
//圧縮されたチャンクデータの大きさ | |
int ind = randomFile.readInt(); | |
//圧縮方法 1 = GZIP, 2 = Deflater | |
byte b = randomFile.readByte(); | |
//indが不正値だった場合に戻る | |
if(ind < 0 || ind > 0x1000 * 0x10) { | |
continue; | |
} | |
if(b == 2) { | |
//圧縮されたデータを保持するbyte配列 | |
byte[] abyte = new byte[ind - 1]; | |
//RamdomAccessFileから取得 | |
randomFile.read(abyte); | |
//DataInputStreamとして解凍したものを代入 | |
DataInputStream stream = new DataInputStream(new BufferedInputStream(new InflaterInputStream(new ByteArrayInputStream(abyte)))); | |
//解凍したDataInputStreamをNBTTagCompoundに変換 | |
NBTTagCompound compound = CompressedStreamTools.read(stream); | |
//解凍したNBTTagCompoundからLevelTagを取得 | |
NBTTagCompound levelCompound = compound.getCompoundTag("Level"); | |
//DataInputStreamをクローズする | |
stream.close(); | |
//---チャンクの位置--- | |
int xPos = levelCompound.getInteger("xPos"); | |
int zPos = levelCompound.getInteger("zPos"); | |
//------ | |
//Levelからセクションデータを取得 | |
NBTTagList sections = levelCompound.getTagList("Sections", 10); | |
//セーブデータからブロックデータを取得するための配列 | |
ExtendedBlockStorage[] storageArray = new ExtendedBlockStorage[16]; | |
//セクションデータを走査する | |
for(int k = 0; k < sections.tagCount(); k++) { | |
//ブロックデータを取得 | |
NBTTagCompound blockData = sections.getCompoundTagAt(k); | |
//Yデータを取得 | |
byte Y = blockData.getByte("Y"); | |
//Yデータから新しいブロックストレージを作る | |
ExtendedBlockStorage storage = new ExtendedBlockStorage(Y << 4, !false); | |
//ストレージにブロックデータを代入する | |
storage.setBlockLSBArray(blockData.getByteArray("Blocks")); | |
//blockIDが255を超えている場合に使われる | |
if(blockData.hasKey("Add")) { | |
storage.setBlockMSBArray(new NibbleArray(blockData.getByteArray("Add"), 4)); | |
} | |
//ストレージにメタデータを代入 | |
storage.setBlockMetadataArray(new NibbleArray(blockData.getByteArray("Data"), 4)); | |
//ストレージに明るさを代入 | |
storage.setBlocklightArray(new NibbleArray(blockData.getByteArray("BlockLight"), 4)); | |
//ネザー、エンドはこれを実行しない | |
if(!false) { | |
storage.setSkylightArray(new NibbleArray(blockData.getByteArray("SkyLight"), 4)); | |
} | |
//無効なブロックをストレージから消去 | |
storage.removeInvalidBlocks(); | |
//配列に代入 | |
storageArray[Y] = storage; | |
} | |
//LevelからTileEntityを取得 | |
NBTTagList tileEntitiesList = levelCompound.getTagList("TileEntities", 10); | |
//TileEntityを走査する | |
for(int j = 0; j < tileEntitiesList.tagCount(); j++) { | |
//一つづつTileEntityを代入していく | |
NBTTagCompound tileEntity = tileEntitiesList.getCompoundTagAt(j); | |
if(tileEntity.getString("id").equals("Corner")) { //コーナーブロック | |
incrCountBlock("corner"); | |
result = 3; | |
} else if(tileEntity.getString("id").equals("Slope")) { //スロープブロック | |
incrCountBlock("slope"); | |
result = 3; | |
} else if(tileEntity.getString("id").equals("HalfSlope")) { //ハーフスロープ | |
incrCountBlock("halfslope"); | |
result = 3; | |
} else if(tileEntity.getString("id").equals("EdgeCorner")) { //エッジコーナー | |
incrCountBlock("edgecorner"); | |
result = 3; | |
} else if(tileEntity.getString("id").equals("InterFace")) { //斜面作業台 | |
incrCountBlock("slopeworkbench"); | |
result = 3; | |
} else if(tileEntity.getString("id").equals("Track")) { //レール付スロープ | |
incrCountBlock("track"); | |
result = 3; | |
} else if(tileEntity.getString("id").equals("FusionSlope")) { //重なるスロープ | |
incrCountBlock("overlapslope"); | |
result = 3; | |
} else if(tileEntity.getString("id").equals("FusionHalfSlope")) { //重なるハーフスロープ | |
incrCountBlock("overlaphalfslope"); | |
result = 3; | |
} else if(tileEntity.getString("id").equals("FusionEdgeCorner")) { //重なるエッジコーナー | |
incrCountBlock("overlapedgecorner"); | |
result = 3; | |
} else if(tileEntity.getString("id").equals("ObliqueSlope")) { //欠けたスロープ | |
incrCountBlock("obliqueslope"); | |
result = 3; | |
} | |
} | |
} | |
} | |
return result; | |
} | |
private final int[] offsets = new int[1024]; | |
private final int[] chunkTimestamps = new int[1024]; | |
private int getOffset(int x, int z) { | |
return this.offsets[x + z * 32]; | |
} | |
/** | |
* セーブデータを変換する処理 | |
* @param regionFile | |
* @param randomFile | |
* @param outputName | |
* @throws IOException | |
*/ | |
public void convertWorldSavedata(File regionFile, RandomAccessFile randomFile, String outputName, boolean isNether) throws IOException { | |
//ファイルサイズ | |
long length = regionFile.length(); | |
for(int j = 0; j < 1024; ++j) { | |
this.offsets[j] = randomFile.readInt(); | |
} | |
for(int j = 0; j < 1024; ++j) { | |
this.chunkTimestamps[j] = randomFile.readInt(); | |
} | |
//ファイルサイズをオフセットに変換 | |
length = length / 4096 - 2; | |
//randomFileを走査 | |
for(int i = 0; i < length; i++) { | |
//ファイルヘッダを飛び越す | |
randomFile.seek(i * 0x1000 + 0x2000); | |
//解凍前のデータサイズ | |
int ind = randomFile.readInt(); | |
//圧縮方法 | |
byte b = randomFile.readByte(); | |
//不正値の場合は戻る | |
if(ind < 0 || ind > 0x1000 * 0x10) { | |
continue; | |
} | |
if(b == 2) { | |
//解凍前のデータを保持するbyte配列 | |
byte[] abyte = new byte[ind - 1]; | |
//解凍前のデータをabyteに代入する | |
randomFile.read(abyte); | |
//DataInputStreamとして解凍したものを代入 | |
DataInputStream stream = new DataInputStream(new BufferedInputStream(new InflaterInputStream(new ByteArrayInputStream(abyte)))); | |
//DataInputStreamをNBTTagCompoundに変換 | |
NBTTagCompound compound = CompressedStreamTools.read(stream); | |
//チャンクデータからLevelを取得 | |
NBTTagCompound levelCompound = compound.getCompoundTag("Level"); | |
//ストリームを閉じる | |
stream.close(); | |
//---チャンクの座標を取得--- | |
int xPos = levelCompound.getInteger("xPos"); | |
int zPos = levelCompound.getInteger("zPos"); | |
//------ | |
//Levelからセクションデータを取得 | |
NBTTagList sections = levelCompound.getTagList("Sections", 10); | |
//セーブデータからブロックデータを取得するための配列 | |
ExtendedBlockStorage[] storageArray = new ExtendedBlockStorage[16]; | |
//セクションデータを走査する | |
for(int k = 0; k < sections.tagCount(); k++) { | |
//ブロックデータを取得 | |
NBTTagCompound blockData = sections.getCompoundTagAt(k); | |
//Yデータを取得 | |
byte Y = blockData.getByte("Y"); | |
//Yデータから新しいブロックストレージを作る | |
ExtendedBlockStorage storage = new ExtendedBlockStorage(Y << 4, !isNether); | |
//ストレージにブロックデータを代入する | |
storage.setBlockLSBArray(blockData.getByteArray("Blocks")); | |
//blockIDが255を超えている場合に使われる | |
if(blockData.hasKey("Add")) { | |
storage.setBlockMSBArray(new NibbleArray(blockData.getByteArray("Add"), 4)); | |
} | |
//ストレージにメタデータを代入 | |
storage.setBlockMetadataArray(new NibbleArray(blockData.getByteArray("Data"), 4)); | |
//ストレージに明るさを代入 | |
storage.setBlocklightArray(new NibbleArray(blockData.getByteArray("BlockLight"), 4)); | |
//ネザー、エンドはこれを実行しない | |
if(!isNether) { | |
storage.setSkylightArray(new NibbleArray(blockData.getByteArray("SkyLight"), 4)); | |
} | |
//無効なブロックをストレージから消去 | |
storage.removeInvalidBlocks(); | |
//配列に代入 | |
storageArray[Y] = storage; | |
} | |
//TileEntityをLevelから取得 | |
NBTTagList tileEntities = levelCompound.getTagList("TileEntities", NBT.TAG_COMPOUND); | |
boolean flag = false; | |
//TileEntityを走査 | |
for(int j = 0; j < tileEntities.tagCount(); j++) { | |
//TileEntityをNBTとして代入 | |
NBTTagCompound tileEntity = tileEntities.getCompoundTagAt(j); | |
//---座標データをTileEntityから取得--- | |
int x = tileEntity.getInteger("x"); | |
int y = tileEntity.getInteger("y"); | |
int z = tileEntity.getInteger("z"); | |
//------ | |
//書き込みフラグ | |
if(tileEntity.getString("id").equals("Corner")) { //コーナーブロック | |
//指定した位置にブロックを置く | |
storageArray[y >> 4].func_150818_a(x & 15, y & 15, z & 15, BlockCorners.block); | |
//TileEntityのIDを上書きする | |
tileEntity.setString("id", "tileentity.corner"); | |
//BlockIndexを取得、変換、代入する | |
int index = convertIndexWithRemove(tileEntity, "CornerBlockIndex"); | |
//旧BlockIndexからBlockIDを取得、TileEntityにセットする | |
setBlock(tileEntity, index); | |
decrCountBlock("corner"); | |
flag = true; | |
} else if(tileEntity.getString("id").equals("Slope")) { | |
//指定した位置にブロックを置く | |
storageArray[y >> 4].func_150818_a(x & 15, y & 15, z & 15, BlockSlopes.block); | |
//TileEntityのIDを上書きする | |
tileEntity.setString("id", "tileentity.slope"); | |
//---BlockIndexを取得、変換、代入する--- | |
int index = convertIndexWithRemove(tileEntity, "SlopeBlockIndex"); | |
//旧BlockIndexからBlockIDを取得、TileEntityにセットする | |
setBlock(tileEntity, index); | |
decrCountBlock("slope"); | |
flag = true; | |
} else if(tileEntity.getString("id").equals("HalfSlope")) { | |
//指定した位置にブロックを置く | |
storageArray[y >> 4].func_150818_a(x & 15, y & 15, z & 15, BlockHalfSlopes.block); | |
//TileEntityのIDを上書きする | |
tileEntity.setString("id", "tileentity.halfslope"); | |
//---BlockIndexを取得、変換、代入する--- | |
int index = convertIndexWithRemove(tileEntity, "HalfSlopeBlockIndex"); | |
//旧BlockIndexからBlockIDを取得、TileEntityにセットする | |
setBlock(tileEntity, index); | |
decrCountBlock("halfslope"); | |
flag = true; | |
} else if(tileEntity.getString("id").equals("EdgeCorner")) { | |
//指定した位置にブロックを置く | |
storageArray[y >> 4].func_150818_a(x & 15, y & 15, z & 15, BlockEdgeCorners.block); | |
//TileEntityのIDを上書きする | |
tileEntity.setString("id", "tileentity.edgecorner"); | |
//---BlockIndexを取得、変換、代入する--- | |
int index = convertIndexWithRemove(tileEntity, "EdgeCornerBlockIndex"); | |
//旧BlockIndexからBlockIDを取得、TileEntityにセットする | |
setBlock(tileEntity, index); | |
decrCountBlock("edgecorner"); | |
flag = true; | |
} else if(tileEntity.getString("id").equals("InterFace")) { | |
//指定した位置にブロックを置く | |
storageArray[y >> 4].func_150818_a(x & 15, y & 15, z & 15, BlockSlopeWorkbench.block); | |
//TileEntityのIDを上書きする | |
tileEntity.setString("id", "tileentity.slopeworkbench"); | |
decrCountBlock("slopeworkbench"); | |
flag = true; | |
} else if(tileEntity.getString("id").equals("Track")) { | |
//指定した位置にブロックを置く | |
storageArray[y >> 4].func_150818_a(x & 15, y & 15, z & 15, BlockSlopeTrack.block); | |
//TileEntityのIDを上書きする | |
tileEntity.setString("id", "tileentity.slope.track"); | |
//BlockIndexを取得、変換、代入する | |
int index = convertIndexWithRemove(tileEntity, "TrackBlockIndex"); | |
//旧BlockIndexからBlockIDを取得、TileEntityにセットする | |
setBlock(tileEntity, index); | |
decrCountBlock("track"); | |
flag = true; | |
} else if(tileEntity.getString("id").equals("FusionSlope")) { | |
//指定した位置にブロックを置く | |
storageArray[y >> 4].func_150818_a(x & 15, y & 15, z & 15, BlockOverlapSlopes.block); | |
//TileEntityのIDを上書きする | |
tileEntity.setString("id", "tileentity.slope.overlap"); | |
int topIcon = getIntegerWithRemove(tileEntity, "TopIcon"); | |
int bottomIcon = getIntegerWithRemove(tileEntity, "BottomIcon"); | |
int newIndex = BlockIDs.convertBlockIndex(topIcon); | |
tileEntity.setInteger("BlockIndex", newIndex); | |
tileEntity.removeTag("FusionBlockIndex"); | |
int newAnoIndex = BlockIDs.convertBlockIndex(bottomIcon); | |
tileEntity.setInteger("AnotherBlockIndex", newAnoIndex); | |
setBlock(tileEntity, topIcon); | |
setBlock(tileEntity, bottomIcon, "AnotherBlock"); | |
decrCountBlock("overlapslope"); | |
flag = true; | |
} else if(tileEntity.getString("id").equals("FusionHalfSlope")) { | |
//指定した位置にブロックを置く | |
storageArray[y >> 4].func_150818_a(x & 15, y & 15, z & 15, BlockOverlapHalfSlopes.block); | |
//TileEntityのIDを上書きする | |
tileEntity.setString("id", "tileentity.halfslope.overlap"); | |
int icon1 = getIntegerWithRemove(tileEntity, "Icon1"); | |
int icon2 = getIntegerWithRemove(tileEntity, "Icon2"); | |
int icon3 = getIntegerWithRemove(tileEntity, "Icon3"); | |
int icon4 = getIntegerWithRemove(tileEntity, "Icon4"); | |
int index1 = BlockIDs.convertBlockIndex(icon1); | |
tileEntity.setInteger("BlockIndex", index1); | |
int index2 = BlockIDs.convertBlockIndex(icon2); | |
tileEntity.setInteger("BlockIndex2", index2); | |
int index3 = BlockIDs.convertBlockIndex(icon3); | |
tileEntity.setInteger("BlockIndex3", index3 << 8 | tileEntity.getInteger("IconMetadata3")); | |
int index4 = BlockIDs.convertBlockIndex(icon4); | |
tileEntity.setInteger("BlockIndex4", index4); | |
tileEntity.removeTag("FusionHalfSlopeBlockIndex"); | |
if(icon1 != -1) { | |
setBlock(tileEntity, icon1); | |
} | |
if(icon2 != -1) { | |
setBlock(tileEntity, icon2, "Block2"); | |
} | |
if(icon3 != -1) { | |
setBlock(tileEntity, icon3, "Block3"); | |
} | |
if(icon4 != -1) { | |
setBlock(tileEntity, icon4, "Block4"); | |
} | |
decrCountBlock("overlaphalfslope"); | |
flag = true; | |
} else if(tileEntity.getString("id").equals("FusionEdgeCorner")) { | |
//指定した位置にブロックを置く | |
int metadata = storageArray[y >> 4].getExtBlockMetadata(x & 15, y & 15, z & 15); | |
if(metadata >= 8 && metadata <= 11) { | |
storageArray[y >> 4].func_150818_a(x & 15, y & 15, z & 15, BlockObliqueSlopes.block); | |
//TileEntityのIDを上書きする | |
tileEntity.setString("id", "tileentity.obliqueslopes"); | |
//---BlockIndexを取得、変換、代入する--- | |
int index = convertIndexWithRemove(tileEntity, "BlockIndex"); | |
//旧BlockIndexからBlockIDを取得、TileEntityにセットする | |
setBlock(tileEntity, index); | |
} else { | |
storageArray[y >> 4].func_150818_a(x & 15, y & 15, z & 15, BlockOverlapEdgeCorners.block); | |
//TileEntityのIDを上書きする | |
tileEntity.setString("id", "tileentity.edgecorner.overlap"); | |
int topIcon = getIntegerWithRemove(tileEntity, "TopIcon"); | |
int bottomIcon = getIntegerWithRemove(tileEntity, "BottomIcon"); | |
int newIndex = BlockIDs.convertBlockIndex(topIcon); | |
tileEntity.setInteger("BlockIndex", newIndex); | |
int newAnoIndex = BlockIDs.convertBlockIndex(bottomIcon); | |
tileEntity.setInteger("AnotherBlockIndex", newAnoIndex); | |
setBlock(tileEntity, topIcon); | |
setBlock(tileEntity, bottomIcon, "AnotherBlock"); | |
} | |
decrCountBlock("overlapedgecorner"); | |
flag = true; | |
} else if(tileEntity.getString("id").equals("ObliqueSlope")) { | |
//指定した位置にブロックを置く | |
storageArray[y >> 4].func_150818_a(x & 15, y & 15, z & 15, BlockObliqueSlopes.block); | |
//TileEntityのIDを上書きする | |
tileEntity.setString("id", "tileentity.obliqueslopes"); | |
//---BlockIndexを取得、変換、代入する--- | |
int index = tileEntity.getInteger("BlockIndex"); | |
int newindex = BlockIDs.convertBlockIndex(index); | |
tileEntity.setInteger("BlockIndex", newindex); | |
//旧BlockIndexからBlockIDを取得、TileEntityにセットする | |
setBlock(tileEntity, index); | |
decrCountBlock("obliqueslope"); | |
flag = true; | |
} | |
if(flag) { | |
DataOutputStream output = RegionFileCache.getChunkOutputStream(new File(regionFile, "../../"), xPos, zPos); | |
CompressedStreamTools.write(compound, output); | |
output.close(); | |
} | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment