ZotCoreLoader
- исправлен setItemToDrop - изменён getItemFromProjectile - изменён базовый ProjectTile у предмета
This commit is contained in:
@@ -7,7 +7,6 @@ import cn.nukkit.entity.EntityHuman;
|
||||
import cn.nukkit.entity.EntityRideable;
|
||||
import cn.nukkit.entity.item.EntityItem;
|
||||
import cn.nukkit.entity.projectile.EntityProjectile;
|
||||
import cn.nukkit.entity.projectile.EntityThrownTrident;
|
||||
import cn.nukkit.event.entity.EntityDamageEvent;
|
||||
import cn.nukkit.item.Item;
|
||||
import cn.nukkit.level.Level;
|
||||
@@ -15,10 +14,13 @@ import cn.nukkit.level.Location;
|
||||
import cn.nukkit.level.Position;
|
||||
import cn.nukkit.math.BlockFace;
|
||||
import cn.nukkit.math.Vector3;
|
||||
import cn.nukkit.nbt.NBTIO;
|
||||
import cn.nukkit.nbt.tag.CompoundTag;
|
||||
import cn.nukkit.potion.Effect;
|
||||
import com.reider745.InnerCoreServer;
|
||||
import com.reider745.api.ReflectHelper;
|
||||
import com.reider745.hooks.ItemUtils;
|
||||
import com.reider745.item.CustomProjectileItem;
|
||||
import com.reider745.world.BlockSourceMethods;
|
||||
|
||||
public class EntityMethod {
|
||||
@@ -189,15 +191,15 @@ public class EntityMethod {
|
||||
|
||||
public static Item getItemFromProjectile(long unwrapEntity) {
|
||||
Entity ent = getEntityToLong(unwrapEntity);
|
||||
if(ent instanceof EntityThrownTrident entItem)
|
||||
return entItem.getItem();
|
||||
if(ent instanceof EntityProjectile entItem)
|
||||
return NBTIO.getItemHelper(entItem.namedTag.getCompound("ItemIc"));
|
||||
return Item.get(0).clone();
|
||||
}
|
||||
|
||||
public static void setItemToDrop(long unwrapEntity, int id, int count, int data, long unwrapValue) {
|
||||
Entity ent = getEntityToLong(unwrapEntity);
|
||||
if(ent instanceof EntityThrownTrident entItem)
|
||||
entItem.setItem(ItemUtils.get(id, count, data, unwrapValue));
|
||||
if(ent instanceof EntityItem entItem)
|
||||
ReflectHelper.setField(entItem, "item", ItemUtils.get(id, count, data, unwrapValue));
|
||||
}
|
||||
|
||||
public static void setEntityCarriedItem(long unwrapEntity, int id, int count, int data, long unwrapValue) {
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
package com.reider745.item;
|
||||
|
||||
import cn.nukkit.item.Item;
|
||||
import cn.nukkit.item.ItemDurable;
|
||||
import com.reider745.api.CustomManager;
|
||||
|
||||
public class CustomItemClass extends Item {
|
||||
public class CustomItemClass extends Item implements ItemDurable {
|
||||
private CustomManager parameters;
|
||||
|
||||
public CustomItemClass(int id, Integer meta, int count){
|
||||
@@ -29,6 +30,7 @@ public class CustomItemClass extends Item {
|
||||
return parameters.get("max_stack");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Item clone() {
|
||||
CustomItemClass item = (CustomItemClass) super.clone();
|
||||
|
||||
@@ -10,7 +10,7 @@ import com.reider745.api.CustomManager;
|
||||
public class CustomProjectileItem extends ProjectileItem {
|
||||
@Override
|
||||
public String getProjectileEntityType() {
|
||||
return "ThrownTrident";
|
||||
return "Snowball";
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -20,7 +20,7 @@ public class CustomProjectileItem extends ProjectileItem {
|
||||
|
||||
@Override
|
||||
protected void correctNBT(CompoundTag nbt) {
|
||||
nbt.put("Trident", NBTIO.putItemHelper(this));
|
||||
nbt.put("ItemIc", NBTIO.putItemHelper(this));
|
||||
}
|
||||
|
||||
private CustomManager parameters;
|
||||
|
||||
@@ -4,18 +4,24 @@ package com.zhekasmirnov.innercore.mod.build;
|
||||
* Created by zheka on 15.08.2017.
|
||||
*/
|
||||
|
||||
import com.android.dx.dex.file.DexFile;
|
||||
import com.zhekasmirnov.innercore.api.log.ICLog;
|
||||
import com.zhekasmirnov.innercore.mod.executable.Compiler;
|
||||
import com.zhekasmirnov.innercore.mod.executable.CompilerConfig;
|
||||
import com.zhekasmirnov.innercore.mod.executable.Executable;
|
||||
import com.zhekasmirnov.innercore.mod.executable.MultidexScript;
|
||||
import com.zhekasmirnov.innercore.ui.LoadingUI;
|
||||
import com.zhekasmirnov.innercore.utils.FileTools;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.mozilla.javascript.Context;
|
||||
import org.mozilla.javascript.Script;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Enumeration;
|
||||
|
||||
public class CompiledSources {
|
||||
private boolean isValid = true;
|
||||
@@ -122,6 +128,103 @@ public class CompiledSources {
|
||||
|
||||
return null;
|
||||
}
|
||||
/*private static int tempDexCounter = 0;
|
||||
public static Script loadScriptFromDex(File dexFile) throws IOException {
|
||||
File dexOut = new File(System.getProperty("java.io.tmpdir", "."), "classes/ic-dex-cache" + (tempDexCounter++));
|
||||
DexFile dex = DexFile.loadDex(dexFile.getAbsolutePath(), dexOut.getAbsolutePath(), 0);
|
||||
|
||||
Enumeration<String> entryIterator = dex.entries();
|
||||
|
||||
String className = null;
|
||||
while(entryIterator.hasMoreElements()) {
|
||||
String name = entryIterator.nextElement();
|
||||
//Log.d("COMPILER", name);
|
||||
if (className == null) {
|
||||
className = name;
|
||||
}
|
||||
else {
|
||||
throw new IOException("invalid compiled js dex file: more than one class entries (" + className + ", " + name + ")");
|
||||
}
|
||||
}
|
||||
|
||||
if (className == null) {
|
||||
throw new IOException("invalid compiled js dex file: no class entries found");
|
||||
}
|
||||
|
||||
try {
|
||||
Class clazz = dex.loadClass(className, AndroidContextFactory.class.getClassLoader());
|
||||
return (Script) clazz.newInstance();
|
||||
} catch (InstantiationException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
ICLog.d("COMPILER", "dex loading failed: " + className);
|
||||
return null;
|
||||
}
|
||||
|
||||
private static Executable wrapScript(Context ctx, Script script, CompilerConfig compilerConfig) {
|
||||
API apiInstance = compilerConfig.getApiInstance();
|
||||
|
||||
ScriptableObject scope = apiInstance != null ? ctx.initStandardObjects(apiInstance.newInstance(), false) : ctx.initStandardObjects();
|
||||
|
||||
if (compilerConfig.isLibrary) {
|
||||
return new Library(ctx, script, scope, compilerConfig, compilerConfig.getApiInstance());
|
||||
}
|
||||
else {
|
||||
if (apiInstance != null) {
|
||||
apiInstance.injectIntoScope(scope);
|
||||
}
|
||||
|
||||
return new Executable(ctx, script, scope, compilerConfig, compilerConfig.getApiInstance());
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
|
||||
/*public static Executable loadDex(File dex, final CompilerConfig compilerConfig) throws IOException {
|
||||
Context ctx = Compiler.enter(compilerConfig.getOptimizationLevel());
|
||||
|
||||
Script script = loadScriptFromDex(dex);
|
||||
|
||||
if (script == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Executable exec = wrapScript(ctx, script, compilerConfig);
|
||||
exec.isLoadedFromDex = true;
|
||||
return exec;
|
||||
}
|
||||
|
||||
public static Executable loadDexList(File[] dexes, final CompilerConfig compilerConfig) {
|
||||
Context ctx = Compiler.enter(compilerConfig.getOptimizationLevel());
|
||||
|
||||
MultidexScript multidex = new MultidexScript();
|
||||
LoadingUI.setTip("Wrapping " + compilerConfig.getFullName());
|
||||
|
||||
for (File dex : dexes) {
|
||||
try {
|
||||
Script script = loadScriptFromDex(dex);
|
||||
if (script != null) {
|
||||
multidex.addScript(script);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
ICLog.e("COMPILER", "failed to load dex file into multi-dex executable: file=" + dex, e);
|
||||
}
|
||||
}
|
||||
|
||||
if (multidex.getScriptCount() == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Executable exec = wrapScript(ctx, multidex, compilerConfig);
|
||||
exec.isLoadedFromDex = true;
|
||||
|
||||
LoadingUI.setTip("");
|
||||
return exec;
|
||||
}*/
|
||||
|
||||
|
||||
public Executable getCompiledExecutableFor(String name, CompilerConfig config) throws IOException {
|
||||
File[] dexFiles = getCompiledSourceFilesFor(name);
|
||||
|
||||
Reference in New Issue
Block a user