fix: damage item
- обновлён Nukkit-Mot - исправлено отображение прочности предметов иннера - Добавлена поддержка getRainLevel, setRainLevel
This commit is contained in:
Binary file not shown.
@@ -13,6 +13,7 @@ import com.reider745.api.hooks.annotation.Hooks;
|
|||||||
import com.reider745.api.hooks.annotation.Inject;
|
import com.reider745.api.hooks.annotation.Inject;
|
||||||
import com.reider745.block.CustomBlock;
|
import com.reider745.block.CustomBlock;
|
||||||
import com.reider745.item.CustomItem;
|
import com.reider745.item.CustomItem;
|
||||||
|
import com.reider745.item.ItemMethod;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||||
|
|
||||||
@@ -63,17 +64,18 @@ public class RuntimeItemsHooks implements HookClass {
|
|||||||
CustomItem.customItems.forEach((name, id) -> {
|
CustomItem.customItems.forEach((name, id) -> {
|
||||||
paletteBuffer.putString(name);
|
paletteBuffer.putString(name);
|
||||||
paletteBuffer.putLShort(id);
|
paletteBuffer.putLShort(id);
|
||||||
paletteBuffer.putBoolean(false); // Component item
|
paletteBuffer.putBoolean(true); // Component item
|
||||||
|
|
||||||
int fullId = RuntimeItems.getFullId(id, 0);
|
int fullId = RuntimeItems.getFullId(id, 0);
|
||||||
int legacyId = id;
|
int legacyId = id;
|
||||||
int runtimeId = id;
|
int runtimeId = id;
|
||||||
boolean hasData = CustomItem.hasData(id);
|
int damage = ItemMethod.getMaxDamageForId(id, 0);
|
||||||
|
boolean hasData = damage <= 0;
|
||||||
|
|
||||||
runtimeId2Name.put(runtimeId, name);
|
runtimeId2Name.put(runtimeId, name);
|
||||||
name2RuntimeId.put(name, runtimeId);
|
name2RuntimeId.put(name, runtimeId);
|
||||||
|
|
||||||
RuntimeItemMapping.LegacyEntry legacyEntry = new RuntimeItemMapping.LegacyEntry(legacyId, hasData, 0);
|
RuntimeItemMapping.LegacyEntry legacyEntry = new RuntimeItemMapping.LegacyEntry(legacyId, hasData, damage);
|
||||||
|
|
||||||
runtime2Legacy.put(runtimeId, legacyEntry);
|
runtime2Legacy.put(runtimeId, legacyEntry);
|
||||||
identifier2Legacy.put(name, legacyEntry);
|
identifier2Legacy.put(name, legacyEntry);
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import com.reider745.item.ItemMethod.PropertiesNames;
|
|||||||
import com.zhekasmirnov.innercore.api.NativeCallback;
|
import com.zhekasmirnov.innercore.api.NativeCallback;
|
||||||
import com.zhekasmirnov.innercore.api.runtime.Callback;
|
import com.zhekasmirnov.innercore.api.runtime.Callback;
|
||||||
|
|
||||||
public class CustomItemClass extends Item implements ItemDurable {
|
public class CustomItemClass extends Item {
|
||||||
private CustomManager parameters;
|
private CustomManager parameters;
|
||||||
private int max_damage, max_stack;
|
private int max_damage, max_stack;
|
||||||
private boolean use_no_target;
|
private boolean use_no_target;
|
||||||
@@ -32,7 +32,7 @@ public class CustomItemClass extends Item implements ItemDurable {
|
|||||||
|
|
||||||
CompoundTag tag = getOrCreateNamedTag();
|
CompoundTag tag = getOrCreateNamedTag();
|
||||||
|
|
||||||
// tag.putInt("Damage", max_damage);
|
tag.putInt("Damage", max_damage);
|
||||||
|
|
||||||
CompoundTag components = tag.getCompound("components");
|
CompoundTag components = tag.getCompound("components");
|
||||||
if(components == null){
|
if(components == null){
|
||||||
|
|||||||
@@ -42,8 +42,8 @@ public class ItemMethod {
|
|||||||
return Item.get(id, data).getMaxDurability();
|
return Item.get(id, data).getMaxDurability();
|
||||||
CustomManager manager = getCustomManager(id);
|
CustomManager manager = getCustomManager(id);
|
||||||
if(manager != null)
|
if(manager != null)
|
||||||
return manager.get(PropertiesNames.MAX_DAMAGE);
|
return manager.get(PropertiesNames.MAX_DAMAGE, 0);
|
||||||
return 64;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setMaxDamage(CustomManager manager, int id){
|
public static void setMaxDamage(CustomManager manager, int id){
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ public class WorldMethod {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void setGameMode(int mode) {
|
public static void setGameMode(int mode) {
|
||||||
|
InnerCoreServer.useNotSupport("World.setGameMode");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getDifficulty() {
|
public static int getDifficulty() {
|
||||||
@@ -38,17 +39,25 @@ public class WorldMethod {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static double getRainLevel() {
|
public static double getRainLevel() {
|
||||||
|
Level level = getLevel();
|
||||||
|
if(level != null)
|
||||||
|
return level.isRaining() ? 1 : 0;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setRainLevel(float v) {
|
public static void setRainLevel(float v) {
|
||||||
|
Level level = getLevel();
|
||||||
|
if(level != null)
|
||||||
|
level.setRaining(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double getLightningLevel() {
|
public static double getLightningLevel() {
|
||||||
|
InnerCoreServer.useNotSupport("World.setGameMode");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setLightningLevel(float v) {
|
public static void setLightningLevel(float v) {
|
||||||
|
InnerCoreServer.useNotSupport("World.setGameMode");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static long getSeed() {
|
public static long getSeed() {
|
||||||
|
|||||||
@@ -470,7 +470,7 @@ public class NativeAPI {
|
|||||||
EntityMethod.getRotation(entity, rotation);
|
EntityMethod.getRotation(entity, rotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static /* int */ long getSeed() {
|
public static long getSeed() {
|
||||||
return WorldMethod.getSeed();
|
return WorldMethod.getSeed();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -491,7 +491,6 @@ public class NativeAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static int getUiProfile() {
|
public static int getUiProfile() {
|
||||||
InnerCoreServer.useClientMethod("NativeAPI.getUiProfile()");
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user