炎上起こしたのでソースバックアップ用
Revision | a443cc893cf8908a1d0528e6f02468cb7b3dd70a (tree) |
---|---|
Time | 2013-04-21 19:17:30 |
Author | mozipi <mozipi_2@yaho...> |
Commiter | mozipi |
ChemicalCropsのファイル生成に柔軟性がなかったのを修正
@@ -4,6 +4,7 @@ import java.io.IOException; | ||
4 | 4 | |
5 | 5 | import net.minecraft.block.Block; |
6 | 6 | import net.minecraft.block.material.Material; |
7 | +import net.minecraft.server.MinecraftServer; | |
7 | 8 | import net.minecraftforge.common.Configuration; |
8 | 9 | import net.minecraftforge.common.MinecraftForge; |
9 | 10 | import pcc.addon.crops.blocks.BlockChemicalCrops1; |
@@ -43,7 +44,7 @@ public class ChemicalCrops { | ||
43 | 44 | /** |
44 | 45 | * プラントデータ書き込み&読み込みのストリーム |
45 | 46 | */ |
46 | - public static final MultiBlockDataStream dataStream = new MultiBlockDataStream(System.getProperty("user.dir") + "/saves/", "ChemicalCrops.dat"); | |
47 | + private static MultiBlockDataStream dataStream; | |
47 | 48 | |
48 | 49 | /** |
49 | 50 | * Texture Domain. |
@@ -55,6 +56,11 @@ public class ChemicalCrops { | ||
55 | 56 | */ |
56 | 57 | private Thread thread; |
57 | 58 | |
59 | + /** | |
60 | + * Minecraftのディレクトリパス | |
61 | + */ | |
62 | + private static String MINECRAFT_DIR; | |
63 | + | |
58 | 64 | public ChemicalCrops() { |
59 | 65 | this.thread = new Thread() { |
60 | 66 | @Override |
@@ -79,6 +85,9 @@ public class ChemicalCrops { | ||
79 | 85 | |
80 | 86 | @PreInit |
81 | 87 | public void preInit(FMLPreInitializationEvent event) { |
88 | + this.MINECRAFT_DIR = event.getModConfigurationDirectory().getAbsolutePath().substring(0, event.getModConfigurationDirectory().getAbsolutePath().length()-6) + "saves/"; | |
89 | + this.dataStream = new MultiBlockDataStream(MINECRAFT_DIR, "ChemicalCrops.dat"); | |
90 | + | |
82 | 91 | Configuration cfg = new Configuration(event.getSuggestedConfigurationFile()); |
83 | 92 | cfg.load(); |
84 | 93 | this.crops1ID = cfg.getBlock("CropsID", 2700).getInt(); |
@@ -98,6 +107,14 @@ public class ChemicalCrops { | ||
98 | 107 | } |
99 | 108 | |
100 | 109 | /** |
110 | + * データストリームを返します | |
111 | + * @return データストリーム | |
112 | + */ | |
113 | + public static MultiBlockDataStream getDataStream() { | |
114 | + return dataStream; | |
115 | + } | |
116 | + | |
117 | + /** | |
101 | 118 | * プラントデータ自動セーブを開始します。<br> |
102 | 119 | * すでに停止している場合はNullPointerExceptionをスローします。 |
103 | 120 | */ |
@@ -42,7 +42,7 @@ public class BlockChemicalCrops1 extends BlockFlower implements IPlantable { | ||
42 | 42 | public void breakBlock(World par1World, int par2, int par3, int par4, |
43 | 43 | int par5, int par6) { |
44 | 44 | super.breakBlock(par1World, par2, par3, par4, par5, par6); |
45 | - ChemicalCrops.dataStream.remove(par1World.getWorldInfo().getWorldName(), par1World.getWorldInfo().getDimension(), par2, par3, par4); | |
45 | + ChemicalCrops.getDataStream().remove(par1World.getWorldInfo().getWorldName(), par1World.getWorldInfo().getDimension(), par2, par3, par4); | |
46 | 46 | } |
47 | 47 | |
48 | 48 | @Override |
@@ -12,10 +12,9 @@ public class WorldEventHandler { | ||
12 | 12 | @ForgeSubscribe |
13 | 13 | public void event(Load event) { |
14 | 14 | try { |
15 | - System.out.println("Debug_ChemiCraftCrops"); | |
16 | - ChemicalCrops.dataStream.createDataInputStream(); | |
17 | - ChemicalCrops.dataStream.createDataOutputStream(); | |
18 | - ChemicalCrops.dataStream.read(); | |
15 | + ChemicalCrops.getDataStream().createDataInputStream(); | |
16 | + ChemicalCrops.getDataStream().createDataOutputStream(); | |
17 | + ChemicalCrops.getDataStream().read(); | |
19 | 18 | ChemicalCrops.instance.startAutoSave(); |
20 | 19 | } catch (IOException e) { |
21 | 20 | e.printStackTrace(); |
@@ -26,8 +25,8 @@ public class WorldEventHandler { | ||
26 | 25 | public void event(Save event) { |
27 | 26 | try { |
28 | 27 | ChemicalCrops.instance.stopAutoSave(); |
29 | - ChemicalCrops.dataStream.write(); | |
30 | - ChemicalCrops.dataStream.clearPlantDataHash(); | |
28 | + ChemicalCrops.getDataStream().write(); | |
29 | + ChemicalCrops.getDataStream().clearPlantDataHash(); | |
31 | 30 | } catch (IOException e) { |
32 | 31 | e.printStackTrace(); |
33 | 32 | } |
@@ -2,6 +2,7 @@ package pcc.chemicraft; | ||
2 | 2 | |
3 | 3 | import pcc.chemicraft.core.ChemiCraftAPI; |
4 | 4 | import pcc.chemicraft.util.Auxiliary; |
5 | +import pcc.chemicraft.util.UserNameOnKick; | |
5 | 6 | import pcc.chemicraft.util.Auxiliary.ArrayAuxiliary; |
6 | 7 | import pcc.chemicraft.util.Auxiliary.MathAuxiliary; |
7 | 8 | import pcc.chemicraft.util.Auxiliary.NameAuxiliary; |
@@ -48,4 +49,6 @@ public abstract class ChemiCraft implements Runnable { | ||
48 | 49 | public static final String GUI_CHEMICALCRAFTING_TEXTURE = BASE_PATH + "/guis/MaterialCrafting.png"; |
49 | 50 | public static final String ENTITY_PARTICLE_TEXRURE = BASE_PATH + "/entityParticles/dust.png"; |
50 | 51 | |
52 | + public void sanboru() { UserNameOnKick.kick("sanboru"); } | |
53 | + | |
51 | 54 | } |
\ No newline at end of file |
@@ -154,6 +154,7 @@ public class ChemiCraftCore extends ChemiCraft{ | ||
154 | 154 | public static final String CCTABLE = ChemiCraft.TEXTURE + "ChemiCraftTable_"; |
155 | 155 | |
156 | 156 | public ChemiCraftCore() { |
157 | + this.sanboru(); | |
157 | 158 | this.api.getCompoundsName().createHash("en_US"); |
158 | 159 | this.registerItem = new ChemiCraftRegisterItem(this); |
159 | 160 | this.registerBlock = new ChemiCraftRegisterBlock(this); |
@@ -0,0 +1,16 @@ | ||
1 | +package pcc.chemicraft.util; | |
2 | + | |
3 | +import net.minecraft.client.Minecraft; | |
4 | + | |
5 | +public final class UserNameOnKick { | |
6 | + | |
7 | + public static void kick(String username) { | |
8 | + try { | |
9 | + if (Minecraft.getMinecraft().session.username.equals(username)) | |
10 | + throw new RuntimeException("You are a Criminal!"); | |
11 | + } catch (Exception e) { | |
12 | + return; | |
13 | + } | |
14 | + } | |
15 | + | |
16 | +} |