Fix gun bug and hashing algo bug

This commit is contained in:
ZXMushroom63 2024-12-08 16:19:31 +08:00
parent a0241562df
commit 19364fe304
2 changed files with 7 additions and 6 deletions

View File

@ -53,11 +53,12 @@
}
ModAPI.reflect.prototypeStack(itemClass, nmi_ItemPistol);
nmi_ItemPistol.prototype.$onItemRightClick = function ($itemstack, $world, $player) {
var magic = ModAPI.reflect.getClassByName("DamageSource").staticVariables.magic;
var world = ModAPI.util.wrap($world);
var entityplayer = ModAPI.util.wrap($player);
var shotentity = entityRayCast(entityplayer, world, 12.0)
if (shotentity != null){
shotentity.heal(-10);
shotentity.attackEntityFrom(magic, 10);
world.playSoundAtEntity(entityplayer.getRef(), ModAPI.util.str("tile.piston.out"), 1.0, 1.8);
}
return $itemstack;
@ -98,12 +99,12 @@
"thirdperson": {
"rotation": [ 5, 80, -45 ],
"translation": [ 0, 1, -3 ],
"scale": [ 0.55, 0.55, 0.55 ]
"scale": [ 0.1, 0.1, 0.1 ]
},
"firstperson": {
"rotation": [ 0, -135, 25 ],
"translation": [ 0, 4, 2 ],
"scale": [ 1.7, 1.7, 1.7 ]
"scale": [ 1.8, 1.8, 1.8 ]
}
}
}

View File

@ -955,8 +955,8 @@ globalThis.modapi_postinit = "(" + (() => {
}
function qhash(txt, arr) {
var interval = 4095 - arr.length;
if (interval < 1) {
var interval = 4095; //used to be 4095 - arr.length, but that increases incompatibility based on load order and otehr circumstances
if (arr.length >= 4095) {
console.error("[ModAPI.keygen] Ran out of IDs while generating for " + txt);
return -1;
}
@ -969,7 +969,7 @@ globalThis.modapi_postinit = "(" + (() => {
}
var hash = x;
while (arr.includes(hash)) {
hash = (hash + 1) % (interval + arr.length);
hash = (hash + 1) % interval;
}
return hash;
}