• R/O
  • HTTP
  • SSH
  • HTTPS

ChemiCraftNext: Commit


Commit MetaInfo

Revisióne3b8a25959f8255bfcb0ce58c42ea8dcfcf98856 (tree)
Tiempo2013-09-23 10:58:02
Autorinaka <inaka@tcrs...>
Commiterinaka

Log Message

TcrsCore2強化

Cambiar Resumen

Diferencia incremental

--- a/src/asia/tcrs/ccnp/ccnn/ChemiCraftNext.java
+++ b/src/asia/tcrs/ccnp/ccnn/ChemiCraftNext.java
@@ -1,6 +1,6 @@
11 package asia.tcrs.ccnp.ccnn;
22
3-import javax.print.attribute.standard.MediaSize.NA;
3+import java.util.logging.Level;
44
55 import net.minecraft.block.Block;
66 import net.minecraft.creativetab.CreativeTabs;
@@ -12,10 +12,10 @@ import asia.tcrs.ccnp.ccnn.Item.ItemAtoms;
1212 import asia.tcrs.ccnp.ccnn.Item.ItemCCN;
1313 import asia.tcrs.ccnp.ccnn.creativetab.CreativeTabChemiCraftNext;
1414 import asia.tcrs.ccnp.ccnn.system.PacketHandler;
15-import asia.tcrs.ccnp.ccnn.util.Auxiliary;
16-import asia.tcrs.ccnp.ccnn.util.Auxiliary.NameAuxiliary;
17-import asia.tcrs.ccnp.ccnn.villager.VillagerScientists;
15+import asia.tcrs.tcrscore.Auxiliary.NameAuxiliary;
16+//import asia.tcrs.ccnp.ccnn.villager.VillagerScientists;
1817 import asia.tcrs.tcrscore.TcrsCore;
18+import cpw.mods.fml.common.FMLLog;
1919 import cpw.mods.fml.common.Mod;
2020 import cpw.mods.fml.common.Mod.Init;
2121 import cpw.mods.fml.common.Mod.Instance;
@@ -63,7 +63,7 @@ public class ChemiCraftNext{
6363 public static int AlcoholLampID;
6464 public static int AlcoholID;
6565
66- public static VillagerScientists villagerScientists;
66+// public static VillagerScientists villagerScientists;
6767 public static int ScientistsVillagerProfession = 5;
6868
6969 public static final int sgdeguiID = 1;
@@ -91,29 +91,41 @@ public class ChemiCraftNext{
9191 public void preload(FMLPreInitializationEvent Event)
9292 {
9393 Configuration CCNconf1=new Configuration(TcrsCore.getconfigfile("ChemiCraftNext", "ItemBlockIDs"));
94- Property itemAtomsprop=CCNconf1.get(Configuration.CATEGORY_ITEM, "Atoms", 30000);
95- Property testtubeprop=CCNconf1.get(Configuration.CATEGORY_ITEM, "testtube", 30001);
96- Property Tripodprop=CCNconf1.get(Configuration.CATEGORY_ITEM, "Tripod", 30002);
97- Property AlcoholLampprop=CCNconf1.get(Configuration.CATEGORY_ITEM, "AlcoholLamp", 30003);
98- Property Alcoholprop=CCNconf1.get(Configuration.CATEGORY_ITEM, "Alcohol", 30004);
99- itemAtomsID=itemAtomsprop.getInt();
100- testtubeID=testtubeprop.getInt();
101- TripodID=Tripodprop.getInt();
102- AlcoholLampID=AlcoholLampprop.getInt();
103- AlcoholID=Alcoholprop.getInt();
94+ try
95+ {
96+ CCNconf1.load();
97+ Property itemAtomsprop=CCNconf1.get(Configuration.CATEGORY_ITEM, "Atoms", 30000);
98+ Property testtubeprop=CCNconf1.get(Configuration.CATEGORY_ITEM, "testtube", 30001);
99+ Property Tripodprop=CCNconf1.get(Configuration.CATEGORY_ITEM, "Tripod", 30002);
100+ Property AlcoholLampprop=CCNconf1.get(Configuration.CATEGORY_ITEM, "AlcoholLamp", 30003);
101+ Property Alcoholprop=CCNconf1.get(Configuration.CATEGORY_ITEM, "Alcohol", 30004);
102+ itemAtomsID=itemAtomsprop.getInt();
103+ testtubeID=testtubeprop.getInt();
104+ TripodID=Tripodprop.getInt();
105+ AlcoholLampID=AlcoholLampprop.getInt();
106+ AlcoholID=Alcoholprop.getInt();
107+ }
108+ catch (Exception e)
109+ {
110+ FMLLog.log(Level.SEVERE, e, "Error Message");
111+ }
112+ finally
113+ {
114+ CCNconf1.save();
115+ }
104116 }
105117
106118 @Init
107119 public void load(FMLInitializationEvent event)
108120 {
109- villagerScientists = new VillagerScientists();
121+// villagerScientists = new VillagerScientists();
110122 this.StaticBlackList();
111123 System.out.print(ATOMSNAME.length);
112- itemAtoms = new ItemAtoms(30000).setUnlocalizedName("atoms");
113- testtube = new ItemCCN(30001).setUnlocalizedName("testtube").setCreativeTab(ChemiCraftNext);
114- Tripod = new ItemCCN(30002).setUnlocalizedName("Tripod").setCreativeTab(ChemiCraftNext);
115- AlcoholLamp = new ItemCCN(30003).setUnlocalizedName("AlcoholLamp").setCreativeTab(ChemiCraftNext);
116- Alcohol = new ItemCCN(30004).setUnlocalizedName("Alcohol").setCreativeTab(ChemiCraftNext);
124+ itemAtoms = new ItemAtoms(itemAtomsID).setUnlocalizedName("atoms");
125+ testtube = new ItemCCN(testtubeID).setUnlocalizedName("testtube").setCreativeTab(ChemiCraftNext);
126+ Tripod = new ItemCCN(TripodID).setUnlocalizedName("Tripod").setCreativeTab(ChemiCraftNext);
127+ AlcoholLamp = new ItemCCN(AlcoholLampID).setUnlocalizedName("AlcoholLamp").setCreativeTab(ChemiCraftNext);
128+ Alcohol = new ItemCCN(AlcoholID).setUnlocalizedName("Alcohol").setCreativeTab(ChemiCraftNext);
117129
118130 sgde = new BlockSGDE(3800).setUnlocalizedName("SGDE");
119131
@@ -129,7 +141,7 @@ public class ChemiCraftNext{
129141
130142 VillagerRegistry.instance().registerVillagerType(ScientistsVillagerProfession, "/mob/villager/librarian.png");
131143
132- VillagerRegistry.instance().registerVillageTradeHandler(ScientistsVillagerProfession, villagerScientists);
144+// VillagerRegistry.instance().registerVillageTradeHandler(ScientistsVillagerProfession, villagerScientists);
133145
134146 }
135147 }
--- /dev/null
+++ b/src/asia/tcrs/tcrscore/Auxiliary.java
@@ -0,0 +1,316 @@
1+package asia.tcrs.tcrscore;
2+
3+import java.util.ArrayList;
4+
5+import net.minecraft.block.Block;
6+import net.minecraft.entity.Entity;
7+import net.minecraft.item.Item;
8+import net.minecraft.item.ItemStack;
9+import net.minecraft.world.World;
10+import cpw.mods.fml.common.registry.LanguageRegistry;
11+
12+/**
13+ * 補助クラス<br>
14+ * <br>
15+ * Copyright (c) 2012~2013, ChemiCraftNextProject<br>
16+ * All rights reserved.<br>
17+ * New BSD license<br>
18+ * <br>
19+ * @author mozipi,ponkotate
20+ */
21+public class Auxiliary {
22+
23+ public static class NameAuxiliary {
24+
25+ /**
26+ * 名前を設定します
27+ * @param object
28+ * @param Name
29+ */
30+ public static void addName(Object object,Object name){
31+ LanguageRegistry.addName(object, (String) name);
32+ }
33+
34+
35+
36+ /**
37+ * 名前を設定します(ItemStack版)
38+ * @param object
39+ * @param name
40+ * @param meta
41+ */
42+ public static void addName(ItemStack itemstack,Object name){
43+ LanguageRegistry.addName(itemstack, (String) name);
44+ }
45+
46+
47+
48+ /**
49+ * 指定言語にそって名前を追加します
50+ * @param object
51+ * @param lang
52+ * @param name
53+ */
54+ public static void addName(Object object,String lang,Object name){
55+ LanguageRegistry.instance().addNameForObject(object, lang, (String) name);
56+ }
57+
58+
59+
60+ /**
61+ * 指定言語にそって名前を追加します(ItemStack版)
62+ * @param object
63+ * @param lang
64+ * @param name
65+ */
66+ public static void addName(ItemStack object,String lang,Object name){
67+ LanguageRegistry.instance().addNameForObject(object, lang, (String) name);
68+ }
69+
70+
71+
72+ /**
73+ * メタデータごとに名前を追加します(Block版)
74+ * @param object
75+ * @param name
76+ */
77+ public static void addName(Block object,Object[] name){
78+ for(int i=0;i<name.length;i++){
79+ LanguageRegistry.addName(new ItemStack(object,0,i), (String) name[i]);
80+ }
81+ }
82+
83+
84+
85+ /**
86+ * メタデータごとに名前を追加します(Item版)
87+ * @param object
88+ * @param name
89+ */
90+ public static void addName(Item object,Object[] name){
91+ for(int i=0;i<name.length;i++){
92+ LanguageRegistry.addName(new ItemStack(object,0,i), (String) name[i]);
93+ }
94+ }
95+
96+
97+
98+ /**
99+ * 指定された言語にそってメタデータごとに名前を設定します(Block版)
100+ * @param object
101+ * @param name
102+ */
103+ public static void addName(Block object,String lang,Object[] name){
104+ for(int i=0;i<name.length;i++){
105+ LanguageRegistry.instance().addNameForObject(new ItemStack(object,0,i), lang, (String) name[i]);
106+ }
107+ }
108+
109+
110+
111+ /**
112+ * 指定された言語にそってメタデータごとに名前を設定します(Item版)
113+ * @param object
114+ * @param name
115+ */
116+ public static void addName(Item object,String lang, Object[] name){
117+ for(int i=0;i<name.length;i++){
118+ LanguageRegistry.instance().addNameForObject(new ItemStack(object,0,i), lang, (String) name[i]);
119+ }
120+ }
121+
122+ /**
123+ * 指定された言語にそってメタデータごとに名前を設定します(Block版)
124+ * また、配列の前に任意の文字列を追加できます。
125+ * @param object
126+ * @param name
127+ */
128+ public static void addName(Block object,String lang, String string, Object[] name){
129+ for(int i=0;i<name.length;i++){
130+ LanguageRegistry.instance().addNameForObject(new ItemStack(object,0,i), lang, string + (String) name[i]);
131+ }
132+ }
133+
134+
135+
136+ /**
137+ * 指定された言語にそってメタデータごとに名前を設定します(Item版)
138+ * また、配列の前に任意の文字列を追加できます。
139+ * @param object
140+ * @param name
141+ */
142+ public static void addName(Item object,String lang, String string, Object[] name){
143+ for(int i=0;i<name.length;i++){
144+ LanguageRegistry.instance().addNameForObject(new ItemStack(object,0,i), lang, string + (String) name[i]);
145+ }
146+ }
147+
148+ /**
149+ * 指定された言語にそってメタデータごとに名前を設定します(Block版)
150+ * また、配列の後ろに任意の文字列を追加できます。
151+ * @param object
152+ * @param name
153+ */
154+ public static void addName(Block object,String lang, Object[] name, String string){
155+ for(int i=0;i<name.length;i++){
156+ LanguageRegistry.instance().addNameForObject(new ItemStack(object,0,i), lang, (String) name[i] + string);
157+ }
158+ }
159+
160+
161+
162+ /**
163+ * 指定された言語にそってメタデータごとに名前を設定します(Item版)
164+ * また、配列の後ろに任意の文字列を追加できます。
165+ * @param object
166+ * @param name
167+ */
168+ public static void addName(Item object,String lang, Object[] name, String string){
169+ for(int i=0;i<name.length;i++){
170+ LanguageRegistry.instance().addNameForObject(new ItemStack(object,0,i), lang, (String) name[i] + string);
171+ }
172+ }
173+
174+ }
175+
176+ public static class ArrayAuxiliary{
177+
178+ public static ItemStack[] deleteNull(ItemStack[] array){
179+ int count = 0;
180+ ItemStack[] arrayCopy;
181+ for(int i = 0;i < array.length;i++){
182+ if(array[array.length - 1 - i] == null){
183+ count++;
184+ }else{
185+ break;
186+ }
187+ }
188+ arrayCopy = new ItemStack[array.length - count];
189+ for(int i = 0;i < arrayCopy.length;i++){
190+ arrayCopy[i] = array[i];
191+ }
192+ array = arrayCopy.clone();
193+ return array;
194+ }
195+
196+ }
197+
198+ public static class Probability {
199+
200+ /**
201+ * Return probability(0,1,2,etc...).
202+ */
203+ public int getProbability(double... par1){
204+ ArrayList<Double> var1 = new ArrayList<Double>();
205+ for (int var2 = 0; var2 < par1.length; var2++) {
206+ var1.add(par1[var2]);
207+ }
208+ return getProbability(var1);
209+ }
210+
211+ public int getProbability(ArrayList<Double> par1){
212+
213+ double var1 = 0;
214+
215+ for (int i = 0; i < par1.size(); i++){
216+ var1 += par1.get(i);
217+ }
218+
219+ double var2 = 0;
220+ double var3 = Math.random();
221+
222+ for (int j = 0; j < par1.size(); j++){
223+ double var4 = par1.get(j) / var1;
224+ var2 += var4;
225+ if (var2 >= var3){
226+ return j;
227+ }else{
228+ continue;
229+ }
230+ }
231+ return -1;
232+ }
233+
234+ }
235+
236+ public static class MathAuxiliary {
237+
238+ public static ArrayList<Entity> getTriangleEntitysByPlayer(World par1World,
239+ double par2, double par3, double par4,
240+ double yaw,
241+ double pitch,
242+ double angle,
243+ double rad) {
244+
245+ ArrayList<Entity> entitys = (ArrayList<Entity>) par1World.loadedEntityList;
246+ ArrayList<Entity> result = new ArrayList<Entity>();
247+ for (int i = 0; i < entitys.size(); i++) {
248+ String a = "";
249+ Entity entity = entitys.get(i);
250+ double x = entity.posX;
251+ double y = entity.posY;
252+ double z = entity.posZ;
253+ double bx = par2;
254+ double by = par3;
255+ double bz = par4;
256+ double look = Math.sin(Math.toRadians(yaw)) * 180;
257+ double lookPitch = Math.abs(pitch);
258+ double playerToEntityAngleXZ = Math.sin(Math.atan2(bx - x, bz - z)) * 180;
259+ double playerToEntityAngleY = Math.toDegrees(Math.atan(y - by));
260+ double length =
261+ Math.sqrt(
262+ Math.pow(Math.abs(bx - x), 2) +
263+ Math.pow(Math.abs(by - y), 2) +
264+ Math.pow(Math.abs(bz - z), 2));
265+
266+ if (look + angle/2 > playerToEntityAngleXZ && look - angle/2 < playerToEntityAngleXZ) {
267+ if (length < rad) {
268+ result.add(entity);
269+ }
270+ }
271+
272+ }
273+
274+ return result;
275+ }
276+
277+ public static ArrayList<Entity> getTriangleEntitys(World par1World,
278+ double par2, double par3, double par4,
279+ double yaw,
280+ double pitch,
281+ double angle,
282+ double rad) {
283+
284+ ArrayList<Entity> entitys = (ArrayList<Entity>) par1World.loadedEntityList;
285+ ArrayList<Entity> result = new ArrayList<Entity>();
286+ for (int i = 0; i < entitys.size(); i++) {
287+ String a = "";
288+ Entity entity = entitys.get(i);
289+ double x = entity.posX;
290+ double y = entity.posY;
291+ double z = entity.posZ;
292+ double bx = par2;
293+ double by = par3;
294+ double bz = par4;
295+ double playerToEntityAngleXZ = Math.sin(Math.atan2(bx - x, bz - z)) * 180;
296+ double playerToEntityAngleY = Math.toDegrees(Math.atan(y - by));
297+ double length =
298+ Math.sqrt(
299+ Math.pow(Math.abs(bx - x), 2) +
300+ Math.pow(Math.abs(by - y), 2) +
301+ Math.pow(Math.abs(bz - z), 2));
302+
303+ if (playerToEntityAngleXZ + angle/2 > playerToEntityAngleXZ && playerToEntityAngleXZ - angle/2 < playerToEntityAngleXZ) {
304+ if (length < rad) {
305+ result.add(entity);
306+ }
307+ }
308+
309+ }
310+
311+ return result;
312+ }
313+
314+ }
315+
316+}
--- a/src/asia/tcrs/tcrscore/TcrsCore.java
+++ b/src/asia/tcrs/tcrscore/TcrsCore.java
@@ -1,15 +1,12 @@
11 package asia.tcrs.tcrscore;
22
33 import java.io.File;
4-import java.util.*;
54
6-import net.minecraft.item.*;
75 import net.minecraft.item.Item;
8-import net.minecraft.item.crafting.*;
9-import net.minecraft.server.MinecraftServer;
10-import cpw.mods.fml.client.FMLClientHandler;
11-import cpw.mods.fml.common.Mod.*;
6+import net.minecraft.item.ItemStack;
127 import cpw.mods.fml.common.Mod;
8+import cpw.mods.fml.common.Mod.Init;
9+import cpw.mods.fml.common.Mod.PreInit;
1310 import cpw.mods.fml.common.SidedProxy;
1411 import cpw.mods.fml.common.event.FMLInitializationEvent;
1512 import cpw.mods.fml.common.event.FMLPreInitializationEvent;
@@ -54,6 +51,9 @@ public class TcrsCore{
5451 return new File(configdir, filename+".cfg");
5552
5653 }
54+ public static File getlogfilename(String filename) {
55+ return new File(new File(configdir.getParentFile(),"logs"),filename+".log");
56+ }
5757
5858 public static void delitem(Item par1Item)
5959 {
@@ -67,4 +67,4 @@ public class TcrsCore{
6767 {
6868 Platform.addChatMessage(text);
6969 }
70-}
70+}
\ No newline at end of file
--- a/src/asia/tcrs/tcrscore/UserNameOnKick.java
+++ b/src/asia/tcrs/tcrscore/UserNameOnKick.java
@@ -26,7 +26,7 @@ public final class UserNameOnKick {
2626 }
2727
2828 /**
29- * ユーザー名をコード見ただけではわからないよ隠蔽
29+ * ユーザー名をコード見ただけではわからないよう隠蔽
3030 * @param asciiCodes 隠ぺいしたID
3131 */
3232 public static void kick(byte[] asciiCodes) {
Show on old repository browser