forked from MTSR/mapserver
parent
752e25730a
commit
4a7722c8bc
@ -66,7 +66,7 @@ func getNodePos(x, y, z int) int {
|
||||
}
|
||||
|
||||
func (inv *Inventory) IsEmpty() bool {
|
||||
if inv.Size == 0 || len(inv.Items) == 0 {
|
||||
if len(inv.Items) == 0 {
|
||||
return true
|
||||
}
|
||||
|
||||
|
@ -155,6 +155,7 @@ func parseMetadata(mapblock *MapBlock, data []byte) (int, error) {
|
||||
}
|
||||
|
||||
currentInventory.Items = append(currentInventory.Items, &item)
|
||||
currentInventory.Size += 1
|
||||
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,7 @@ func (this *SmartShopBlock) onMapObject(x, y, z int, block *mapblockparser.MapBl
|
||||
md := block.Metadata.GetMetadata(x, y, z)
|
||||
invMap := block.Metadata.GetInventoryMapAtPos(x, y, z)
|
||||
mainInv := invMap["main"]
|
||||
isCreative := md["type"] == "0"
|
||||
|
||||
if mainInv.IsEmpty() {
|
||||
return list
|
||||
@ -27,7 +28,7 @@ func (this *SmartShopBlock) onMapObject(x, y, z int, block *mapblockparser.MapBl
|
||||
pay := invMap[payInvName]
|
||||
give := invMap[giveInvName]
|
||||
|
||||
if pay.IsEmpty() || give.IsEmpty() {
|
||||
if len(pay.Items) == 0 || len(give.Items) == 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
@ -43,12 +44,18 @@ func (this *SmartShopBlock) onMapObject(x, y, z int, block *mapblockparser.MapBl
|
||||
|
||||
stock := 0
|
||||
|
||||
if isCreative {
|
||||
stock = 999
|
||||
|
||||
} else {
|
||||
for _, item := range mainInv.Items {
|
||||
if item.Name == out_item {
|
||||
stock += item.Count
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//multiples of out_count
|
||||
stock_factor := math.Floor(float64(stock) / float64(out_count))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user