环境:php7.0
服务端:GenisysPro
我的世界版本:1.1.X
辅助工具:devtools.phar插件
目标:修改PureEntitiesX生物插件中僵尸的掉落物,从而延伸到所有实体
原始代码:
public function getDrops() {
$drops = []; // 初始化掉落物数组
if ($this->isLootDropAllowed()) { // 检查是否允许掉落物品
array_push($drops, Item::get(Item::ROTTEN_FLESH, 0, mt_rand(0, 2))); // 添加腐肉掉落,数量在0到2之间随机
switch (mt_rand(0, 5)) { // 随机选择一种物品进行掉落
case 1:
array_push($drops, Item::get(Item::CARROT, 0, 1)); // 添加胡萝卜掉落,数量为1
break;
case 2:
array_push($drops, Item::get(Item::POTATO, 0, 1)); // 添加土豆掉落,数量为1
break;
case 3:
array_push($drops, Item::get(Item::IRON_INGOT, 0, 1)); // 添加铁锭掉落,数量为1
break;
}
// 以9%的掉落几率添加装备
$this->getMobEquipment()->addLoot($drops);
}
return $drops; // 返回掉落物品数组
}
array_push(该数组,添加的数据) 函数是PHP中用于向数组末尾添加一个或多个元素的函数。它的基本功能是将新元素添加到已有数组的木末尾,并返回新数组的长度。
mt_rand(最小值,最大值) 函数返回一个随机数
Item::get(物品名称, 特殊值, 数量))
所以在这里我们可以稍作修改,让僵尸死亡后掉落0-2个TNT,胡萝卜,土豆,小麦种子,西瓜种子,南瓜种子这样我们就不用满世界乱跑地图去找种子了O(∩_∩)O哈哈~
修改后代码:
//-------------------------------------------------------------------------------------------------------------------
public function getDrops() {
$drops = []; // 初始化掉落物数组
if ($this->isLootDropAllowed()) { // 检查是否允许掉落物品
array_push($drops, Item::get(Item::ROTTEN_FLESH, 0, mt_rand(0, 2))); // 添加腐肉掉落,数量在0到2之间随机
switch (mt_rand(0, 5)) { // 随机选择一种物品进行掉落
case 1:
array_push($drops, Item::get(Item::CARROT, 0, 3)); // 添加胡萝卜掉落,数量为1
break;
case 2:
array_push($drops, Item::get(Item::POTATO, 0, 3)); // 添加土豆掉落,数量为1
break;
case 3:
array_push($drops, Item::get(Item::IRON_INGOT, 0, 1)); // 添加铁锭掉落,数量为1
break;
//------------------------------------------------------------------------------------
case 4:
array_push($drops, Item::get(Item::WHEAT_SEEDS, 0, 3)); //小麦种子
break;
case 5:
array_push($drops, Item::get(Item::PUMPKIN_SEEDS, 0, 3)); //南瓜种子
break;
case 6:
array_push($drops, Item::get(Item::MELON_SEEDS, 0, 3)); //西瓜种子
break;
//-------------------------------------------------------------------------------------------
}
// 以9%的掉落几率添加装备
$this->getMobEquipment()->addLoot($drops);
}
return $drops; // 返回掉落物品数组
}
//--------------------------------------------------------------------------------------------------------------------
效果图
先欠着
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END
- 最新
- 最热
查看全部Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /www/wwwroot/shumengya.top/wp-content/plugins/ACG/inc/options/functions.php on line 382
Warning: file_get_contents(https://api.oioweb.cn/api/ip/ipaddress?ip=183.221.133.61): failed to open stream: php_network_getaddresses: getaddrinfo failed: Name or service not known in /www/wwwroot/shumengya.top/wp-content/plugins/ACG/inc/options/functions.php on line 382